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
sarthakmeh03/django
django/conf/locale/__init__.py
100
12442
# -*- encoding: utf-8 -*- from __future__ import unicode_literals """ LANG_INFO is a dictionary structure to provide meta information about languages. About name_local: capitalize it as if your language name was appearing inside a sentence in your language. The 'fallback' key can be used to specify a special fallback logic which doesn't follow the traditional 'fr-ca' -> 'fr' fallback logic. """ LANG_INFO = { 'af': { 'bidi': False, 'code': 'af', 'name': 'Afrikaans', 'name_local': 'Afrikaans', }, 'ar': { 'bidi': True, 'code': 'ar', 'name': 'Arabic', 'name_local': 'العربيّة', }, 'ast': { 'bidi': False, 'code': 'ast', 'name': 'Asturian', 'name_local': 'asturianu', }, 'az': { 'bidi': True, 'code': 'az', 'name': 'Azerbaijani', 'name_local': 'Azərbaycanca', }, 'be': { 'bidi': False, 'code': 'be', 'name': 'Belarusian', 'name_local': 'беларуская', }, 'bg': { 'bidi': False, 'code': 'bg', 'name': 'Bulgarian', 'name_local': 'български', }, 'bn': { 'bidi': False, 'code': 'bn', 'name': 'Bengali', 'name_local': 'বাংলা', }, 'br': { 'bidi': False, 'code': 'br', 'name': 'Breton', 'name_local': 'brezhoneg', }, 'bs': { 'bidi': False, 'code': 'bs', 'name': 'Bosnian', 'name_local': 'bosanski', }, 'ca': { 'bidi': False, 'code': 'ca', 'name': 'Catalan', 'name_local': 'català', }, 'cs': { 'bidi': False, 'code': 'cs', 'name': 'Czech', 'name_local': 'česky', }, 'cy': { 'bidi': False, 'code': 'cy', 'name': 'Welsh', 'name_local': 'Cymraeg', }, 'da': { 'bidi': False, 'code': 'da', 'name': 'Danish', 'name_local': 'dansk', }, 'de': { 'bidi': False, 'code': 'de', 'name': 'German', 'name_local': 'Deutsch', }, 'dsb': { 'bidi': False, 'code': 'dsb', 'name': 'Lower Sorbian', 'name_local': 'dolnoserbski', }, 'el': { 'bidi': False, 'code': 'el', 'name': 'Greek', 'name_local': 'Ελληνικά', }, 'en': { 'bidi': False, 'code': 'en', 'name': 'English', 'name_local': 'English', }, 'en-au': { 'bidi': False, 'code': 'en-au', 'name': 'Australian English', 'name_local': 'Australian English', }, 'en-gb': { 'bidi': False, 'code': 'en-gb', 'name': 'British English', 'name_local': 'British English', }, 'eo': { 'bidi': False, 'code': 'eo', 'name': 'Esperanto', 'name_local': 'Esperanto', }, 'es': { 'bidi': False, 'code': 'es', 'name': 'Spanish', 'name_local': 'español', }, 'es-ar': { 'bidi': False, 'code': 'es-ar', 'name': 'Argentinian Spanish', 'name_local': 'español de Argentina', }, 'es-co': { 'bidi': False, 'code': 'es-co', 'name': 'Colombian Spanish', 'name_local': 'español de Colombia', }, 'es-mx': { 'bidi': False, 'code': 'es-mx', 'name': 'Mexican Spanish', 'name_local': 'español de Mexico', }, 'es-ni': { 'bidi': False, 'code': 'es-ni', 'name': 'Nicaraguan Spanish', 'name_local': 'español de Nicaragua', }, 'es-ve': { 'bidi': False, 'code': 'es-ve', 'name': 'Venezuelan Spanish', 'name_local': 'español de Venezuela', }, 'et': { 'bidi': False, 'code': 'et', 'name': 'Estonian', 'name_local': 'eesti', }, 'eu': { 'bidi': False, 'code': 'eu', 'name': 'Basque', 'name_local': 'Basque', }, 'fa': { 'bidi': True, 'code': 'fa', 'name': 'Persian', 'name_local': 'فارسی', }, 'fi': { 'bidi': False, 'code': 'fi', 'name': 'Finnish', 'name_local': 'suomi', }, 'fr': { 'bidi': False, 'code': 'fr', 'name': 'French', 'name_local': 'français', }, 'fy': { 'bidi': False, 'code': 'fy', 'name': 'Frisian', 'name_local': 'frysk', }, 'ga': { 'bidi': False, 'code': 'ga', 'name': 'Irish', 'name_local': 'Gaeilge', }, 'gd': { 'bidi': False, 'code': 'gd', 'name': 'Scottish Gaelic', 'name_local': 'Gàidhlig', }, 'gl': { 'bidi': False, 'code': 'gl', 'name': 'Galician', 'name_local': 'galego', }, 'he': { 'bidi': True, 'code': 'he', 'name': 'Hebrew', 'name_local': 'עברית', }, 'hi': { 'bidi': False, 'code': 'hi', 'name': 'Hindi', 'name_local': 'Hindi', }, 'hr': { 'bidi': False, 'code': 'hr', 'name': 'Croatian', 'name_local': 'Hrvatski', }, 'hsb': { 'bidi': False, 'code': 'hsb', 'name': 'Upper Sorbian', 'name_local': 'hornjoserbsce', }, 'hu': { 'bidi': False, 'code': 'hu', 'name': 'Hungarian', 'name_local': 'Magyar', }, 'ia': { 'bidi': False, 'code': 'ia', 'name': 'Interlingua', 'name_local': 'Interlingua', }, 'io': { 'bidi': False, 'code': 'io', 'name': 'Ido', 'name_local': 'ido', }, 'id': { 'bidi': False, 'code': 'id', 'name': 'Indonesian', 'name_local': 'Bahasa Indonesia', }, 'is': { 'bidi': False, 'code': 'is', 'name': 'Icelandic', 'name_local': 'Íslenska', }, 'it': { 'bidi': False, 'code': 'it', 'name': 'Italian', 'name_local': 'italiano', }, 'ja': { 'bidi': False, 'code': 'ja', 'name': 'Japanese', 'name_local': '日本語', }, 'ka': { 'bidi': False, 'code': 'ka', 'name': 'Georgian', 'name_local': 'ქართული', }, 'kk': { 'bidi': False, 'code': 'kk', 'name': 'Kazakh', 'name_local': 'Қазақ', }, 'km': { 'bidi': False, 'code': 'km', 'name': 'Khmer', 'name_local': 'Khmer', }, 'kn': { 'bidi': False, 'code': 'kn', 'name': 'Kannada', 'name_local': 'Kannada', }, 'ko': { 'bidi': False, 'code': 'ko', 'name': 'Korean', 'name_local': '한국어', }, 'lb': { 'bidi': False, 'code': 'lb', 'name': 'Luxembourgish', 'name_local': 'Lëtzebuergesch', }, 'lt': { 'bidi': False, 'code': 'lt', 'name': 'Lithuanian', 'name_local': 'Lietuviškai', }, 'lv': { 'bidi': False, 'code': 'lv', 'name': 'Latvian', 'name_local': 'latviešu', }, 'mk': { 'bidi': False, 'code': 'mk', 'name': 'Macedonian', 'name_local': 'Македонски', }, 'ml': { 'bidi': False, 'code': 'ml', 'name': 'Malayalam', 'name_local': 'Malayalam', }, 'mn': { 'bidi': False, 'code': 'mn', 'name': 'Mongolian', 'name_local': 'Mongolian', }, 'mr': { 'bidi': False, 'code': 'mr', 'name': 'Marathi', 'name_local': 'मराठी', }, 'my': { 'bidi': False, 'code': 'my', 'name': 'Burmese', 'name_local': 'မြန်မာဘာသာ', }, 'nb': { 'bidi': False, 'code': 'nb', 'name': 'Norwegian Bokmal', 'name_local': 'norsk (bokmål)', }, 'ne': { 'bidi': False, 'code': 'ne', 'name': 'Nepali', 'name_local': 'नेपाली', }, 'nl': { 'bidi': False, 'code': 'nl', 'name': 'Dutch', 'name_local': 'Nederlands', }, 'nn': { 'bidi': False, 'code': 'nn', 'name': 'Norwegian Nynorsk', 'name_local': 'norsk (nynorsk)', }, 'no': { 'bidi': False, 'code': 'no', 'name': 'Norwegian', 'name_local': 'norsk', }, 'os': { 'bidi': False, 'code': 'os', 'name': 'Ossetic', 'name_local': 'Ирон', }, 'pa': { 'bidi': False, 'code': 'pa', 'name': 'Punjabi', 'name_local': 'Punjabi', }, 'pl': { 'bidi': False, 'code': 'pl', 'name': 'Polish', 'name_local': 'polski', }, 'pt': { 'bidi': False, 'code': 'pt', 'name': 'Portuguese', 'name_local': 'Português', }, 'pt-br': { 'bidi': False, 'code': 'pt-br', 'name': 'Brazilian Portuguese', 'name_local': 'Português Brasileiro', }, 'ro': { 'bidi': False, 'code': 'ro', 'name': 'Romanian', 'name_local': 'Română', }, 'ru': { 'bidi': False, 'code': 'ru', 'name': 'Russian', 'name_local': 'Русский', }, 'sk': { 'bidi': False, 'code': 'sk', 'name': 'Slovak', 'name_local': 'Slovensky', }, 'sl': { 'bidi': False, 'code': 'sl', 'name': 'Slovenian', 'name_local': 'Slovenščina', }, 'sq': { 'bidi': False, 'code': 'sq', 'name': 'Albanian', 'name_local': 'shqip', }, 'sr': { 'bidi': False, 'code': 'sr', 'name': 'Serbian', 'name_local': 'српски', }, 'sr-latn': { 'bidi': False, 'code': 'sr-latn', 'name': 'Serbian Latin', 'name_local': 'srpski (latinica)', }, 'sv': { 'bidi': False, 'code': 'sv', 'name': 'Swedish', 'name_local': 'svenska', }, 'sw': { 'bidi': False, 'code': 'sw', 'name': 'Swahili', 'name_local': 'Kiswahili', }, 'ta': { 'bidi': False, 'code': 'ta', 'name': 'Tamil', 'name_local': 'தமிழ்', }, 'te': { 'bidi': False, 'code': 'te', 'name': 'Telugu', 'name_local': 'తెలుగు', }, 'th': { 'bidi': False, 'code': 'th', 'name': 'Thai', 'name_local': 'ภาษาไทย', }, 'tr': { 'bidi': False, 'code': 'tr', 'name': 'Turkish', 'name_local': 'Türkçe', }, 'tt': { 'bidi': False, 'code': 'tt', 'name': 'Tatar', 'name_local': 'Татарча', }, 'udm': { 'bidi': False, 'code': 'udm', 'name': 'Udmurt', 'name_local': 'Удмурт', }, 'uk': { 'bidi': False, 'code': 'uk', 'name': 'Ukrainian', 'name_local': 'Українська', }, 'ur': { 'bidi': True, 'code': 'ur', 'name': 'Urdu', 'name_local': 'اردو', }, 'vi': { 'bidi': False, 'code': 'vi', 'name': 'Vietnamese', 'name_local': 'Tiếng Việt', }, 'zh-cn': { 'fallback': ['zh-hans'], }, 'zh-hans': { 'bidi': False, 'code': 'zh-hans', 'name': 'Simplified Chinese', 'name_local': '简体中文', }, 'zh-hant': { 'bidi': False, 'code': 'zh-hant', 'name': 'Traditional Chinese', 'name_local': '繁體中文', }, 'zh-hk': { 'fallback': ['zh-hant'], }, 'zh-mo': { 'fallback': ['zh-hant'], }, 'zh-my': { 'fallback': ['zh-hans'], }, 'zh-sg': { 'fallback': ['zh-hans'], }, 'zh-tw': { 'fallback': ['zh-hant'], }, }
bsd-3-clause
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 624, 199, 7442, 63, 4531, 365, 282, 2600, 5523, 370, 5647, 3404, 2556, 3595, 10815, 14, 199, 199, 18816, 536, 63, 1832, 26, 17094, 794, 652, 465, 340, 2195, 2637, 536, 1990, 7468, 316, 199, 17183, 282, 14537, 315, 2195, 2637, 14, 199, 1918, 283, 10538, 7, 790, 883, 506, 1202, 370, 4165, 282, 4539, 9567, 9661, 1314, 3181, 1133, 199, 7207, 314, 1468, 2603, 283, 4391, 13, 696, 7, 1035, 283, 4391, 7, 9567, 9661, 14, 199, 624, 199, 199, 7442, 63, 4531, 275, 469, 272, 283, 2756, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 2756, 297, 267, 283, 354, 356, 283, 14799, 322, 7351, 796, 297, 267, 283, 354, 63, 1832, 356, 283, 14799, 322, 7351, 796, 297, 272, 1660, 272, 283, 285, 356, 469, 267, 283, 21555, 356, 715, 12, 267, 283, 600, 356, 283, 285, 297, 267, 283, 354, 356, 283, 33, 24176, 297, 267, 283, 354, 63, 1832, 356, 283, 15305, 20328, 13273, 25044, 15441, 150, 240, 22863, 297, 272, 1660, 272, 283, 1810, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1810, 297, 267, 283, 354, 356, 283, 33, 270, 2302, 290, 297, 267, 283, 354, 63, 1832, 356, 283, 1810, 2302, 290, 85, 297, 272, 1660, 272, 283, 4651, 356, 469, 267, 283, 21555, 356, 715, 12, 267, 283, 600, 356, 283, 4651, 297, 267, 283, 354, 356, 283, 33, 2282, 2470, 7879, 26455, 297, 267, 283, 354, 63, 1832, 356, 283, 32171, 134, 248, 4848, 1187, 2425, 696, 297, 272, 1660, 272, 283, 1235, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1235, 297, 267, 283, 354, 356, 283, 34, 352, 285, 85, 6214, 297, 267, 283, 354, 63, 1832, 356, 283, 141, 110, 30598, 27559, 12195, 8474, 29352, 14978, 297, 272, 1660, 272, 283, 6856, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 6856, 297, 267, 283, 354, 356, 283, 34, 27092, 15289, 297, 267, 283, 354, 63, 1832, 356, 283, 141, 110, 142, 233, 10356, 141, 112, 27559, 8474, 11487, 6500, 297, 272, 1660, 272, 283, 10472, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 10472, 297, 267, 283, 354, 356, 283, 34, 22329, 297, 267, 283, 354, 63, 1832, 356, 283, 157, 100, 106, 157, 100, 123, 157, 100, 225, 157, 100, 111, 157, 100, 123, 297, 272, 1660, 272, 283, 3289, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 3289, 297, 267, 283, 354, 356, 283, 34, 264, 1860, 297, 267, 283, 354, 63, 1832, 356, 283, 10205, 3951, 368, 71, 297, 272, 1660, 272, 283, 1533, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1533, 297, 267, 283, 354, 356, 283, 34, 736, 78, 5653, 297, 267, 283, 354, 63, 1832, 356, 283, 656, 26052, 8810, 297, 272, 1660, 272, 283, 696, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 696, 297, 267, 283, 354, 356, 283, 35, 7539, 290, 297, 267, 283, 354, 63, 1832, 356, 283, 3385, 279, 26482, 297, 272, 1660, 272, 283, 1259, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1259, 297, 267, 283, 354, 356, 283, 35, 806, 335, 297, 267, 283, 354, 63, 1832, 356, 283, 31493, 397, 10562, 297, 272, 1660, 272, 283, 1480, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1480, 297, 267, 283, 354, 356, 283, 55, 352, 609, 297, 267, 283, 354, 63, 1832, 356, 283, 9156, 77, 345, 5902, 297, 272, 1660, 272, 283, 983, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 983, 297, 267, 283, 354, 356, 283, 29336, 2453, 297, 267, 283, 354, 63, 1832, 356, 283, 68, 796, 75, 297, 272, 1660, 272, 283, 271, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 271, 297, 267, 283, 354, 356, 283, 27866, 1237, 297, 267, 283, 354, 63, 1832, 356, 283, 872, 14608, 335, 297, 272, 1660, 272, 283, 795, 66, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 795, 66, 297, 267, 283, 354, 356, 283, 17846, 428, 269, 9662, 297, 267, 283, 354, 63, 1832, 356, 283, 68, 393, 889, 332, 66, 10728, 297, 272, 1660, 272, 283, 352, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 352, 297, 267, 283, 354, 356, 283, 29480, 297, 267, 283, 354, 63, 1832, 356, 283, 139, 244, 28085, 28085, 21694, 17444, 16426, 26839, 139, 106, 297, 272, 1660, 272, 283, 287, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 287, 297, 267, 283, 354, 356, 283, 19410, 297, 267, 283, 354, 63, 1832, 356, 283, 19410, 297, 272, 1660, 272, 283, 287, 13, 3844, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 287, 13, 3844, 297, 267, 283, 354, 356, 283, 33, 11409, 25861, 20144, 297, 267, 283, 354, 63, 1832, 356, 283, 33, 11409, 25861, 20144, 297, 272, 1660, 272, 283, 287, 13, 4908, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 287, 13, 4908, 297, 267, 283, 354, 356, 283, 34, 322, 23184, 20144, 297, 267, 283, 354, 63, 1832, 356, 283, 34, 322, 23184, 20144, 297, 272, 1660, 272, 283, 20805, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 20805, 297, 267, 283, 354, 356, 283, 21658, 529, 290, 475, 297, 267, 283, 354, 63, 1832, 356, 283, 21658, 529, 290, 475, 297, 272, 1660, 272, 283, 397, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 397, 297, 267, 283, 354, 356, 283, 23717, 2453, 297, 267, 283, 354, 63, 1832, 356, 283, 397, 387, 22692, 393, 297, 272, 1660, 272, 283, 397, 13, 285, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 624, 199, 7442, 63, 4531, 365, 282, 2600, 5523, 370, 5647, 3404, 2556, 3595, 10815, 14, 199, 199, 18816, 536, 63, 1832, 26, 17094, 794, 652, 465, 340, 2195, 2637, 536, 1990, 7468, 316, 199, 17183, 282, 14537, 315, 2195, 2637, 14, 199, 1918, 283, 10538, 7, 790, 883, 506, 1202, 370, 4165, 282, 4539, 9567, 9661, 1314, 3181, 1133, 199, 7207, 314, 1468, 2603, 283, 4391, 13, 696, 7, 1035, 283, 4391, 7, 9567, 9661, 14, 199, 624, 199, 199, 7442, 63, 4531, 275, 469, 272, 283, 2756, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 2756, 297, 267, 283, 354, 356, 283, 14799, 322, 7351, 796, 297, 267, 283, 354, 63, 1832, 356, 283, 14799, 322, 7351, 796, 297, 272, 1660, 272, 283, 285, 356, 469, 267, 283, 21555, 356, 715, 12, 267, 283, 600, 356, 283, 285, 297, 267, 283, 354, 356, 283, 33, 24176, 297, 267, 283, 354, 63, 1832, 356, 283, 15305, 20328, 13273, 25044, 15441, 150, 240, 22863, 297, 272, 1660, 272, 283, 1810, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1810, 297, 267, 283, 354, 356, 283, 33, 270, 2302, 290, 297, 267, 283, 354, 63, 1832, 356, 283, 1810, 2302, 290, 85, 297, 272, 1660, 272, 283, 4651, 356, 469, 267, 283, 21555, 356, 715, 12, 267, 283, 600, 356, 283, 4651, 297, 267, 283, 354, 356, 283, 33, 2282, 2470, 7879, 26455, 297, 267, 283, 354, 63, 1832, 356, 283, 32171, 134, 248, 4848, 1187, 2425, 696, 297, 272, 1660, 272, 283, 1235, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1235, 297, 267, 283, 354, 356, 283, 34, 352, 285, 85, 6214, 297, 267, 283, 354, 63, 1832, 356, 283, 141, 110, 30598, 27559, 12195, 8474, 29352, 14978, 297, 272, 1660, 272, 283, 6856, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 6856, 297, 267, 283, 354, 356, 283, 34, 27092, 15289, 297, 267, 283, 354, 63, 1832, 356, 283, 141, 110, 142, 233, 10356, 141, 112, 27559, 8474, 11487, 6500, 297, 272, 1660, 272, 283, 10472, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 10472, 297, 267, 283, 354, 356, 283, 34, 22329, 297, 267, 283, 354, 63, 1832, 356, 283, 157, 100, 106, 157, 100, 123, 157, 100, 225, 157, 100, 111, 157, 100, 123, 297, 272, 1660, 272, 283, 3289, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 3289, 297, 267, 283, 354, 356, 283, 34, 264, 1860, 297, 267, 283, 354, 63, 1832, 356, 283, 10205, 3951, 368, 71, 297, 272, 1660, 272, 283, 1533, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1533, 297, 267, 283, 354, 356, 283, 34, 736, 78, 5653, 297, 267, 283, 354, 63, 1832, 356, 283, 656, 26052, 8810, 297, 272, 1660, 272, 283, 696, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 696, 297, 267, 283, 354, 356, 283, 35, 7539, 290, 297, 267, 283, 354, 63, 1832, 356, 283, 3385, 279, 26482, 297, 272, 1660, 272, 283, 1259, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1259, 297, 267, 283, 354, 356, 283, 35, 806, 335, 297, 267, 283, 354, 63, 1832, 356, 283, 31493, 397, 10562, 297, 272, 1660, 272, 283, 1480, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 1480, 297, 267, 283, 354, 356, 283, 55, 352, 609, 297, 267, 283, 354, 63, 1832, 356, 283, 9156, 77, 345, 5902, 297, 272, 1660, 272, 283, 983, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 983, 297, 267, 283, 354, 356, 283, 29336, 2453, 297, 267, 283, 354, 63, 1832, 356, 283, 68, 796, 75, 297, 272, 1660, 272, 283, 271, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 271, 297, 267, 283, 354, 356, 283, 27866, 1237, 297, 267, 283, 354, 63, 1832, 356, 283, 872, 14608, 335, 297, 272, 1660, 272, 283, 795, 66, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 795, 66, 297, 267, 283, 354, 356, 283, 17846, 428, 269, 9662, 297, 267, 283, 354, 63, 1832, 356, 283, 68, 393, 889, 332, 66, 10728, 297, 272, 1660, 272, 283, 352, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 352, 297, 267, 283, 354, 356, 283, 29480, 297, 267, 283, 354, 63, 1832, 356, 283, 139, 244, 28085, 28085, 21694, 17444, 16426, 26839, 139, 106, 297, 272, 1660, 272, 283, 287, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 287, 297, 267, 283, 354, 356, 283, 19410, 297, 267, 283, 354, 63, 1832, 356, 283, 19410, 297, 272, 1660, 272, 283, 287, 13, 3844, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 287, 13, 3844, 297, 267, 283, 354, 356, 283, 33, 11409, 25861, 20144, 297, 267, 283, 354, 63, 1832, 356, 283, 33, 11409, 25861, 20144, 297, 272, 1660, 272, 283, 287, 13, 4908, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 287, 13, 4908, 297, 267, 283, 354, 356, 283, 34, 322, 23184, 20144, 297, 267, 283, 354, 63, 1832, 356, 283, 34, 322, 23184, 20144, 297, 272, 1660, 272, 283, 20805, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 20805, 297, 267, 283, 354, 356, 283, 21658, 529, 290, 475, 297, 267, 283, 354, 63, 1832, 356, 283, 21658, 529, 290, 475, 297, 272, 1660, 272, 283, 397, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 283, 397, 297, 267, 283, 354, 356, 283, 23717, 2453, 297, 267, 283, 354, 63, 1832, 356, 283, 397, 387, 22692, 393, 297, 272, 1660, 272, 283, 397, 13, 285, 356, 469, 267, 283, 21555, 356, 756, 12, 267, 283, 600, 356, 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, 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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 ]
rwl/muntjac
muntjac/data/validators/composite_validator.py
1
6530
# @MUNTJAC_COPYRIGHT@ # @MUNTJAC_LICENSE@ """Allows you to chain (compose) many validators to validate one field.""" from muntjac.data.validators.abstract_validator import AbstractValidator from muntjac.data.validator import InvalidValueException class CompositeValidator(AbstractValidator): """The C{CompositeValidator} allows you to chain (compose) many validators to validate one field. The contained validators may be required to all validate the value to validate or it may be enough that one contained validator validates the value. This behaviour is controlled by the modes C{AND} and C{OR}. @author: Vaadin Ltd. @author: Richard Lincoln @version: @VERSION@ """ #: The validators are combined with C{AND} clause: validity of # the composite implies validity of the all validators it is composed of # must be valid. MODE_AND = 0 #: The validators are combined with C{OR} clause: validity of the # composite implies that some of validators it is composed of must be # valid. MODE_OR = 1 #: The validators are combined with and clause: validity of the composite # implies validity of the all validators it is composed of MODE_DEFAULT = MODE_AND def __init__(self, mode=None, errorMessage=None): """Constructs a composite validator in given mode. """ #: Operation mode. self._mode = self.MODE_DEFAULT #: List of contained validators. self._validators = list() if mode is None: super(CompositeValidator, self).__init__('') else: super(CompositeValidator, self).__init__(errorMessage) self.setMode(mode) def validate(self, value): """Validates the given value. The value is valid, if: - C{MODE_AND}: All of the sub-validators are valid - C{MODE_OR}: Any of the sub-validators are valid If the value is invalid, validation error is thrown. If the error message is set (non-null), it is used. If the error message has not been set, the first error occurred is thrown. @param value: the value to check. @raise InvalidValueException: if the value is not valid. """ if self._mode == self.MODE_AND: for validator in self._validators: validator.validate(value) return elif self._mode == self.MODE_OR: first = None for v in self._validators: try: v.validate(value) return except InvalidValueException, e: if first is None: first = e if first is None: return em = self.getErrorMessage() if em is not None: raise InvalidValueException(em) else: raise first raise ValueError, 'The validator is in unsupported operation mode' def isValid(self, value): """Checks the validity of the the given value. The value is valid, if: - C{MODE_AND}: All of the sub-validators are valid - C{MODE_OR}: Any of the sub-validators are valid @param value: the value to check. """ if self._mode == self.MODE_AND: for v in self._validators: if not v.isValid(value): return False return True elif self._mode == self.MODE_OR: for v in self._validators: if v.isValid(value): return True return False raise ValueError, 'The valitor is in unsupported operation mode' def getMode(self): """Gets the mode of the validator. @return: Operation mode of the validator: C{MODE_AND} or C{MODE_OR}. """ return self._mode def setMode(self, mode): """Sets the mode of the validator. The valid modes are: - C{MODE_AND} (default) - C{MODE_OR} @param mode: the mode to set. """ if mode != self.MODE_AND and mode != self.MODE_OR: raise ValueError, 'Mode ' + mode + ' unsupported' self._mode = mode def getErrorMessage(self): """Gets the error message for the composite validator. If the error message is C{None}, original error messages of the sub-validators are used instead. """ if super(CompositeValidator, self).getErrorMessage() is not None: return super(CompositeValidator, self).getErrorMessage() # TODO: return composite error message return None def addValidator(self, validator): """Adds validator to the interface. @param validator: the Validator object which performs validation checks on this set of data field values. """ if validator is None: return self._validators.append(validator) def removeValidator(self, validator): """Removes a validator from the composite. @param validator: the Validator object which performs validation checks on this set of data field values. """ self._validators.remove(validator) def getSubValidators(self, validatorType): """Gets sub-validators by class. If the component contains directly or recursively (it contains another composite containing the validator) validators compatible with given type they are returned. This only applies to C{AND} mode composite validators. If the validator is in C{OR} mode or does not contain any validators of given type null is returned. @return: iterable of validators compatible with given type that must apply or null if none found. """ if self._mode != self.MODE_AND: return None found = set() for v in self._validators: if issubclass(v.__class__, validatorType): found.add(v) if (isinstance(v, CompositeValidator) and v.getMode() == self.MODE_AND): c = v.getSubValidators(validatorType) if c is not None: for cc in c: found.add(cc) return None if len(found) == 0 else found
apache-2.0
[ 3, 768, 45, 17252, 42, 1348, 63, 32324, 5716, 32, 199, 3, 768, 45, 17252, 42, 1348, 63, 3961, 32, 199, 199, 624, 19780, 1265, 370, 6036, 334, 12607, 9, 5002, 14370, 370, 4107, 1373, 901, 1041, 199, 199, 504, 333, 638, 9299, 14, 576, 14, 11346, 14, 6198, 63, 11034, 492, 11836, 8640, 199, 504, 333, 638, 9299, 14, 576, 14, 11034, 492, 6378, 1110, 1726, 421, 199, 533, 27506, 2124, 8640, 8, 8458, 8640, 304, 272, 408, 1918, 445, 91, 24039, 8640, 93, 6127, 1265, 370, 6036, 334, 12607, 9, 5002, 272, 14370, 370, 4107, 1373, 901, 14, 710, 10470, 14370, 1443, 506, 1415, 272, 370, 1006, 4107, 314, 574, 370, 4107, 503, 652, 1443, 506, 8321, 626, 1373, 272, 10470, 11822, 29280, 314, 574, 14, 961, 13942, 365, 22284, 701, 272, 314, 12404, 445, 91, 3649, 93, 436, 445, 91, 726, 5565, 339, 768, 2502, 26, 812, 65, 350, 262, 12126, 14, 272, 768, 2502, 26, 30846, 1005, 29730, 761, 78, 272, 768, 1023, 26, 768, 4612, 32, 272, 408, 339, 6079, 710, 14370, 787, 12149, 543, 445, 91, 3649, 93, 8502, 26, 25667, 402, 272, 327, 221, 314, 19306, 22660, 25667, 402, 314, 1006, 14370, 652, 365, 26356, 402, 272, 327, 221, 1471, 506, 1686, 14, 272, 27065, 63, 3649, 275, 378, 339, 6079, 710, 14370, 787, 12149, 543, 445, 91, 726, 93, 8502, 26, 25667, 402, 314, 272, 327, 221, 19306, 22660, 626, 2005, 402, 14370, 652, 365, 26356, 402, 1471, 506, 272, 327, 221, 1686, 14, 272, 27065, 63, 726, 275, 413, 339, 6079, 710, 14370, 787, 12149, 543, 436, 8502, 26, 25667, 402, 314, 19306, 272, 327, 221, 22660, 25667, 402, 314, 1006, 14370, 652, 365, 26356, 402, 272, 27065, 63, 3472, 275, 27065, 63, 3649, 339, 347, 636, 826, 721, 277, 12, 818, 29, 403, 12, 1125, 2209, 29, 403, 304, 267, 408, 27943, 282, 19306, 11822, 315, 1627, 818, 14, 267, 408, 267, 6079, 17954, 818, 14, 267, 291, 423, 632, 275, 291, 14, 6963, 63, 3472, 398, 6079, 3820, 402, 10470, 14370, 14, 267, 291, 423, 11346, 275, 769, 342, 398, 340, 818, 365, 488, 26, 288, 1613, 8, 24039, 8640, 12, 291, 2843, 826, 363, 8355, 267, 587, 26, 288, 1613, 8, 24039, 8640, 12, 291, 2843, 826, 721, 705, 2209, 9, 288, 291, 14, 409, 1385, 8, 632, 9, 2378, 347, 4107, 8, 277, 12, 574, 304, 267, 408, 3490, 2335, 314, 1627, 574, 14, 398, 710, 574, 365, 1686, 12, 340, 26, 881, 446, 445, 91, 6963, 63, 3649, 9160, 2900, 402, 314, 1007, 13, 11346, 787, 1686, 881, 446, 445, 91, 6963, 63, 726, 9160, 6184, 402, 314, 1007, 13, 11346, 787, 1686, 398, 982, 314, 574, 365, 3866, 12, 6411, 1125, 365, 14031, 14, 982, 314, 1125, 267, 1245, 365, 663, 334, 2865, 13, 2307, 395, 652, 365, 1202, 14, 982, 314, 1125, 1245, 965, 440, 267, 2757, 663, 12, 314, 1642, 1125, 8920, 365, 14031, 14, 398, 768, 635, 574, 26, 673, 314, 574, 370, 1104, 14, 267, 768, 3730, 6378, 1110, 1726, 26, 490, 340, 314, 574, 365, 440, 1686, 14, 267, 408, 267, 340, 291, 423, 632, 508, 291, 14, 6963, 63, 3649, 26, 288, 367, 11822, 315, 291, 423, 11346, 26, 355, 11822, 14, 3502, 8, 585, 9, 288, 372, 267, 916, 291, 423, 632, 508, 291, 14, 6963, 63, 726, 26, 288, 1642, 275, 488, 288, 367, 373, 315, 291, 423, 11346, 26, 355, 862, 26, 490, 373, 14, 3502, 8, 585, 9, 490, 372, 355, 871, 6378, 1110, 1726, 12, 325, 26, 490, 340, 1642, 365, 488, 26, 717, 1642, 275, 325, 288, 340, 1642, 365, 488, 26, 355, 372, 288, 18564, 275, 291, 14, 362, 547, 2209, 342, 288, 340, 18564, 365, 440, 488, 26, 355, 746, 6378, 1110, 1726, 8, 5633, 9, 288, 587, 26, 355, 746, 1642, 398, 746, 1722, 12, 283, 1918, 11822, 365, 315, 16313, 3439, 818, 7, 2378, 347, 365, 3490, 8, 277, 12, 574, 304, 267, 408, 11834, 314, 25667, 402, 314, 314, 1627, 574, 14, 710, 574, 365, 1686, 12, 340, 26, 881, 446, 445, 91, 6963, 63, 3649, 9160, 2900, 402, 314, 1007, 13, 11346, 787, 1686, 881, 446, 445, 91, 6963, 63, 726, 9160, 6184, 402, 314, 1007, 13, 11346, 787, 1686, 398, 768, 635, 574, 26, 673, 314, 574, 370, 1104, 14, 267, 408, 267, 340, 291, 423, 632, 508, 291, 14, 6963, 63, 3649, 26, 288, 367, 373, 315, 291, 423, 11346, 26, 355, 340, 440, 373, 14, 18728, 8, 585, 304, 490, 372, 756, 288, 372, 715, 398, 916, 291, 423, 632, 508, 291, 14, 6963, 63, 726, 26, 288, 367, 373, 315, 291, 423, 11346, 26, 355, 340, 373, 14, 18728, 8, 585, 304, 490, 372, 715, 288, 372, 756, 398, 746, 1722, 12, 283, 1918, 1139, 4330, 365, 315, 16313, 3439, 818, 7, 2378, 347, 664, 1385, 8, 277, 304, 267, 408, 14426, 314, 818, 402, 314, 11822, 14, 398, 768, 1107, 26, 17954, 818, 402, 314, 11822, 26, 445, 91, 6963, 63, 3649, 93, 503, 445, 91, 6963, 63, 726, 5565, 267, 408, 267, 372, 291, 423, 632, 2378, 347, 663, 1385, 8, 277, 12, 818, 304, 267, 408, 9899, 314, 818, 402, 314, 11822, 14, 710, 1686, 12404, 787, 26, 881, 446, 445, 91, 6963, 63, 3649, 93, 334, 885, 9, 881, 446, 445, 91, 6963, 63, 726, 93, 398, 768, 635, 818, 26, 673, 314, 818, 370, 663, 14, 267, 408, 267, 340, 818, 1137, 291, 14, 6963, 63, 3649, 436, 818, 1137, 291, 14, 6963, 63, 726, 26, 288, 746, 1722, 12, 283, 1385, 283, 435, 818, 435, 283, 16313, 7, 398, 291, 423, 632, 275, 818, 2378, 347, 664, 547, 2209, 8, 277, 304, 267, 408, 14426, 314, 1125, 1245, 367, 314, 19306, 11822, 14, 982, 314, 1125, 267, 1245, 365, 445, 91, 403, 1386, 3379, 1125, 3788, 402, 314, 1007, 13, 11346, 787, 267, 1202, 3140, 14, 267, 408, 267, 340, 1613, 8, 24039, 8640, 12, 291, 680, 362, 547, 2209, 342, 365, 440, 488, 26, 288, 372, 1613, 8, 24039, 8640, 12, 291, 680, 362, 547, 2209, 342, 398, 327, 3254 ]
[ 768, 45, 17252, 42, 1348, 63, 32324, 5716, 32, 199, 3, 768, 45, 17252, 42, 1348, 63, 3961, 32, 199, 199, 624, 19780, 1265, 370, 6036, 334, 12607, 9, 5002, 14370, 370, 4107, 1373, 901, 1041, 199, 199, 504, 333, 638, 9299, 14, 576, 14, 11346, 14, 6198, 63, 11034, 492, 11836, 8640, 199, 504, 333, 638, 9299, 14, 576, 14, 11034, 492, 6378, 1110, 1726, 421, 199, 533, 27506, 2124, 8640, 8, 8458, 8640, 304, 272, 408, 1918, 445, 91, 24039, 8640, 93, 6127, 1265, 370, 6036, 334, 12607, 9, 5002, 272, 14370, 370, 4107, 1373, 901, 14, 710, 10470, 14370, 1443, 506, 1415, 272, 370, 1006, 4107, 314, 574, 370, 4107, 503, 652, 1443, 506, 8321, 626, 1373, 272, 10470, 11822, 29280, 314, 574, 14, 961, 13942, 365, 22284, 701, 272, 314, 12404, 445, 91, 3649, 93, 436, 445, 91, 726, 5565, 339, 768, 2502, 26, 812, 65, 350, 262, 12126, 14, 272, 768, 2502, 26, 30846, 1005, 29730, 761, 78, 272, 768, 1023, 26, 768, 4612, 32, 272, 408, 339, 6079, 710, 14370, 787, 12149, 543, 445, 91, 3649, 93, 8502, 26, 25667, 402, 272, 327, 221, 314, 19306, 22660, 25667, 402, 314, 1006, 14370, 652, 365, 26356, 402, 272, 327, 221, 1471, 506, 1686, 14, 272, 27065, 63, 3649, 275, 378, 339, 6079, 710, 14370, 787, 12149, 543, 445, 91, 726, 93, 8502, 26, 25667, 402, 314, 272, 327, 221, 19306, 22660, 626, 2005, 402, 14370, 652, 365, 26356, 402, 1471, 506, 272, 327, 221, 1686, 14, 272, 27065, 63, 726, 275, 413, 339, 6079, 710, 14370, 787, 12149, 543, 436, 8502, 26, 25667, 402, 314, 19306, 272, 327, 221, 22660, 25667, 402, 314, 1006, 14370, 652, 365, 26356, 402, 272, 27065, 63, 3472, 275, 27065, 63, 3649, 339, 347, 636, 826, 721, 277, 12, 818, 29, 403, 12, 1125, 2209, 29, 403, 304, 267, 408, 27943, 282, 19306, 11822, 315, 1627, 818, 14, 267, 408, 267, 6079, 17954, 818, 14, 267, 291, 423, 632, 275, 291, 14, 6963, 63, 3472, 398, 6079, 3820, 402, 10470, 14370, 14, 267, 291, 423, 11346, 275, 769, 342, 398, 340, 818, 365, 488, 26, 288, 1613, 8, 24039, 8640, 12, 291, 2843, 826, 363, 8355, 267, 587, 26, 288, 1613, 8, 24039, 8640, 12, 291, 2843, 826, 721, 705, 2209, 9, 288, 291, 14, 409, 1385, 8, 632, 9, 2378, 347, 4107, 8, 277, 12, 574, 304, 267, 408, 3490, 2335, 314, 1627, 574, 14, 398, 710, 574, 365, 1686, 12, 340, 26, 881, 446, 445, 91, 6963, 63, 3649, 9160, 2900, 402, 314, 1007, 13, 11346, 787, 1686, 881, 446, 445, 91, 6963, 63, 726, 9160, 6184, 402, 314, 1007, 13, 11346, 787, 1686, 398, 982, 314, 574, 365, 3866, 12, 6411, 1125, 365, 14031, 14, 982, 314, 1125, 267, 1245, 365, 663, 334, 2865, 13, 2307, 395, 652, 365, 1202, 14, 982, 314, 1125, 1245, 965, 440, 267, 2757, 663, 12, 314, 1642, 1125, 8920, 365, 14031, 14, 398, 768, 635, 574, 26, 673, 314, 574, 370, 1104, 14, 267, 768, 3730, 6378, 1110, 1726, 26, 490, 340, 314, 574, 365, 440, 1686, 14, 267, 408, 267, 340, 291, 423, 632, 508, 291, 14, 6963, 63, 3649, 26, 288, 367, 11822, 315, 291, 423, 11346, 26, 355, 11822, 14, 3502, 8, 585, 9, 288, 372, 267, 916, 291, 423, 632, 508, 291, 14, 6963, 63, 726, 26, 288, 1642, 275, 488, 288, 367, 373, 315, 291, 423, 11346, 26, 355, 862, 26, 490, 373, 14, 3502, 8, 585, 9, 490, 372, 355, 871, 6378, 1110, 1726, 12, 325, 26, 490, 340, 1642, 365, 488, 26, 717, 1642, 275, 325, 288, 340, 1642, 365, 488, 26, 355, 372, 288, 18564, 275, 291, 14, 362, 547, 2209, 342, 288, 340, 18564, 365, 440, 488, 26, 355, 746, 6378, 1110, 1726, 8, 5633, 9, 288, 587, 26, 355, 746, 1642, 398, 746, 1722, 12, 283, 1918, 11822, 365, 315, 16313, 3439, 818, 7, 2378, 347, 365, 3490, 8, 277, 12, 574, 304, 267, 408, 11834, 314, 25667, 402, 314, 314, 1627, 574, 14, 710, 574, 365, 1686, 12, 340, 26, 881, 446, 445, 91, 6963, 63, 3649, 9160, 2900, 402, 314, 1007, 13, 11346, 787, 1686, 881, 446, 445, 91, 6963, 63, 726, 9160, 6184, 402, 314, 1007, 13, 11346, 787, 1686, 398, 768, 635, 574, 26, 673, 314, 574, 370, 1104, 14, 267, 408, 267, 340, 291, 423, 632, 508, 291, 14, 6963, 63, 3649, 26, 288, 367, 373, 315, 291, 423, 11346, 26, 355, 340, 440, 373, 14, 18728, 8, 585, 304, 490, 372, 756, 288, 372, 715, 398, 916, 291, 423, 632, 508, 291, 14, 6963, 63, 726, 26, 288, 367, 373, 315, 291, 423, 11346, 26, 355, 340, 373, 14, 18728, 8, 585, 304, 490, 372, 715, 288, 372, 756, 398, 746, 1722, 12, 283, 1918, 1139, 4330, 365, 315, 16313, 3439, 818, 7, 2378, 347, 664, 1385, 8, 277, 304, 267, 408, 14426, 314, 818, 402, 314, 11822, 14, 398, 768, 1107, 26, 17954, 818, 402, 314, 11822, 26, 445, 91, 6963, 63, 3649, 93, 503, 445, 91, 6963, 63, 726, 5565, 267, 408, 267, 372, 291, 423, 632, 2378, 347, 663, 1385, 8, 277, 12, 818, 304, 267, 408, 9899, 314, 818, 402, 314, 11822, 14, 710, 1686, 12404, 787, 26, 881, 446, 445, 91, 6963, 63, 3649, 93, 334, 885, 9, 881, 446, 445, 91, 6963, 63, 726, 93, 398, 768, 635, 818, 26, 673, 314, 818, 370, 663, 14, 267, 408, 267, 340, 818, 1137, 291, 14, 6963, 63, 3649, 436, 818, 1137, 291, 14, 6963, 63, 726, 26, 288, 746, 1722, 12, 283, 1385, 283, 435, 818, 435, 283, 16313, 7, 398, 291, 423, 632, 275, 818, 2378, 347, 664, 547, 2209, 8, 277, 304, 267, 408, 14426, 314, 1125, 1245, 367, 314, 19306, 11822, 14, 982, 314, 1125, 267, 1245, 365, 445, 91, 403, 1386, 3379, 1125, 3788, 402, 314, 1007, 13, 11346, 787, 267, 1202, 3140, 14, 267, 408, 267, 340, 1613, 8, 24039, 8640, 12, 291, 680, 362, 547, 2209, 342, 365, 440, 488, 26, 288, 372, 1613, 8, 24039, 8640, 12, 291, 680, 362, 547, 2209, 342, 398, 327, 3254, 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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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 ]
tutumcloud/django-registration
registration/backends/default/urls.py
57
2265
""" URLconf for registration and activation, using django-registration's default backend. If the default behavior of these views is acceptable to you, simply use a line like this in your root URLconf to set up the default URLs for registration:: (r'^accounts/', include('registration.backends.default.urls')), This will also automatically set up the views in ``django.contrib.auth`` at sensible default locations. If you'd like to customize registration behavior, feel free to set up your own URL patterns for these views instead. """ from django.conf.urls import patterns from django.conf.urls import include from django.conf.urls import url from django.views.generic.base import TemplateView from registration.backends.default.views import ActivationView from registration.backends.default.views import RegistrationView urlpatterns = patterns('', url(r'^activate/complete/$', TemplateView.as_view(template_name='registration/activation_complete.html'), name='registration_activation_complete'), # Activation keys get matched by \w+ instead of the more specific # [a-fA-F0-9]{40} because a bad activation key should still get to the view; # that way it can return a sensible "invalid key" message instead of a # confusing 404. url(r'^activate/(?P<activation_key>\w+)/$', ActivationView.as_view(), name='registration_activate'), url(r'^register/$', RegistrationView.as_view(), name='registration_register'), url(r'^register/complete/$', TemplateView.as_view(template_name='registration/registration_complete.html'), name='registration_complete'), url(r'^register/closed/$', TemplateView.as_view(template_name='registration/registration_closed.html'), name='registration_disallowed'), (r'', include('registration.auth_urls')), )
bsd-3-clause
[ 624, 199, 2632, 2190, 367, 10991, 436, 10361, 12, 1808, 1639, 13, 8054, 1159, 199, 885, 4865, 14, 199, 199, 3917, 314, 849, 5953, 402, 3520, 6858, 365, 14712, 370, 1265, 12, 9329, 199, 1180, 282, 1004, 2839, 642, 315, 2195, 1738, 2851, 2190, 370, 663, 1536, 314, 849, 10867, 199, 509, 10991, 447, 339, 334, 82, 4289, 8370, 3678, 2387, 360, 8054, 14, 7765, 14, 885, 14, 3603, 3855, 199, 199, 2765, 911, 2597, 5847, 663, 1536, 314, 6858, 315, 199, 1040, 1176, 14, 2828, 14, 1178, 1040, 737, 27962, 849, 9918, 14, 199, 199, 3917, 1265, 5121, 2839, 370, 17551, 10991, 5953, 12, 23109, 2867, 370, 663, 1536, 199, 12695, 5705, 2851, 7970, 367, 3520, 6858, 3140, 14, 199, 199, 624, 421, 199, 504, 1639, 14, 2190, 14, 3603, 492, 7970, 199, 504, 1639, 14, 2190, 14, 3603, 492, 2387, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 504, 1639, 14, 4196, 14, 6767, 14, 1095, 492, 5458, 2768, 199, 199, 504, 10991, 14, 7765, 14, 885, 14, 4196, 492, 29441, 2768, 199, 504, 10991, 14, 7765, 14, 885, 14, 4196, 492, 20764, 2768, 421, 199, 20050, 275, 7970, 8594, 2432, 1166, 8, 82, 4289, 8222, 15, 4883, 10884, 2574, 5458, 2768, 14, 305, 63, 1345, 8, 1160, 63, 354, 534, 8054, 15, 12312, 63, 4883, 14, 1360, 659, 2574, 536, 534, 8054, 63, 12312, 63, 4883, 659, 2432, 327, 29441, 2883, 664, 7838, 701, 971, 87, 11, 3140, 402, 314, 1655, 2488, 2432, 327, 359, 65, 13, 13753, 13, 38, 16, 13, 25, 8194, 2167, 93, 2952, 282, 4875, 10361, 790, 1077, 5139, 664, 370, 314, 2455, 27, 2432, 327, 626, 4340, 652, 883, 372, 282, 27962, 298, 3197, 790, 2, 1245, 3140, 402, 282, 2432, 327, 3743, 4941, 7901, 14, 2432, 1166, 8, 82, 4289, 8222, 9448, 48, 28, 12312, 63, 498, 3072, 87, 18830, 4268, 2574, 29441, 2768, 14, 305, 63, 1345, 1062, 2574, 536, 534, 8054, 63, 8222, 659, 2432, 1166, 8, 82, 4289, 2683, 10884, 2574, 20764, 2768, 14, 305, 63, 1345, 1062, 2574, 536, 534, 8054, 63, 2683, 659, 2432, 1166, 8, 82, 4289, 2683, 15, 4883, 10884, 2574, 5458, 2768, 14, 305, 63, 1345, 8, 1160, 63, 354, 534, 8054, 15, 8054, 63, 4883, 14, 1360, 659, 2574, 536, 534, 8054, 63, 4883, 659, 2432, 1166, 8, 82, 4289, 2683, 15, 5938, 10884, 2574, 5458, 2768, 14, 305, 63, 1345, 8, 1160, 63, 354, 534, 8054, 15, 8054, 63, 5938, 14, 1360, 659, 2574, 536, 534, 8054, 63, 2297, 6541, 659, 2432, 334, 82, 6448, 2387, 360, 8054, 14, 1178, 63, 3603, 3855, 2432, 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 ]
[ 199, 2632, 2190, 367, 10991, 436, 10361, 12, 1808, 1639, 13, 8054, 1159, 199, 885, 4865, 14, 199, 199, 3917, 314, 849, 5953, 402, 3520, 6858, 365, 14712, 370, 1265, 12, 9329, 199, 1180, 282, 1004, 2839, 642, 315, 2195, 1738, 2851, 2190, 370, 663, 1536, 314, 849, 10867, 199, 509, 10991, 447, 339, 334, 82, 4289, 8370, 3678, 2387, 360, 8054, 14, 7765, 14, 885, 14, 3603, 3855, 199, 199, 2765, 911, 2597, 5847, 663, 1536, 314, 6858, 315, 199, 1040, 1176, 14, 2828, 14, 1178, 1040, 737, 27962, 849, 9918, 14, 199, 199, 3917, 1265, 5121, 2839, 370, 17551, 10991, 5953, 12, 23109, 2867, 370, 663, 1536, 199, 12695, 5705, 2851, 7970, 367, 3520, 6858, 3140, 14, 199, 199, 624, 421, 199, 504, 1639, 14, 2190, 14, 3603, 492, 7970, 199, 504, 1639, 14, 2190, 14, 3603, 492, 2387, 199, 504, 1639, 14, 2190, 14, 3603, 492, 1166, 199, 504, 1639, 14, 4196, 14, 6767, 14, 1095, 492, 5458, 2768, 199, 199, 504, 10991, 14, 7765, 14, 885, 14, 4196, 492, 29441, 2768, 199, 504, 10991, 14, 7765, 14, 885, 14, 4196, 492, 20764, 2768, 421, 199, 20050, 275, 7970, 8594, 2432, 1166, 8, 82, 4289, 8222, 15, 4883, 10884, 2574, 5458, 2768, 14, 305, 63, 1345, 8, 1160, 63, 354, 534, 8054, 15, 12312, 63, 4883, 14, 1360, 659, 2574, 536, 534, 8054, 63, 12312, 63, 4883, 659, 2432, 327, 29441, 2883, 664, 7838, 701, 971, 87, 11, 3140, 402, 314, 1655, 2488, 2432, 327, 359, 65, 13, 13753, 13, 38, 16, 13, 25, 8194, 2167, 93, 2952, 282, 4875, 10361, 790, 1077, 5139, 664, 370, 314, 2455, 27, 2432, 327, 626, 4340, 652, 883, 372, 282, 27962, 298, 3197, 790, 2, 1245, 3140, 402, 282, 2432, 327, 3743, 4941, 7901, 14, 2432, 1166, 8, 82, 4289, 8222, 9448, 48, 28, 12312, 63, 498, 3072, 87, 18830, 4268, 2574, 29441, 2768, 14, 305, 63, 1345, 1062, 2574, 536, 534, 8054, 63, 8222, 659, 2432, 1166, 8, 82, 4289, 2683, 10884, 2574, 20764, 2768, 14, 305, 63, 1345, 1062, 2574, 536, 534, 8054, 63, 2683, 659, 2432, 1166, 8, 82, 4289, 2683, 15, 4883, 10884, 2574, 5458, 2768, 14, 305, 63, 1345, 8, 1160, 63, 354, 534, 8054, 15, 8054, 63, 4883, 14, 1360, 659, 2574, 536, 534, 8054, 63, 4883, 659, 2432, 1166, 8, 82, 4289, 2683, 15, 5938, 10884, 2574, 5458, 2768, 14, 305, 63, 1345, 8, 1160, 63, 354, 534, 8054, 15, 8054, 63, 5938, 14, 1360, 659, 2574, 536, 534, 8054, 63, 2297, 6541, 659, 2432, 334, 82, 6448, 2387, 360, 8054, 14, 1178, 63, 3603, 3855, 2432, 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, 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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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 ]
pjryan126/solid-start-careers
store/api/glassdoor/venv/lib/python2.7/site-packages/pip/_vendor/colorama/win32.py
196
4911
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. # from winbase.h STDOUT = -11 STDERR = -12 import ctypes from ctypes import LibraryLoader try: windll = LibraryLoader(ctypes.WinDLL) from ctypes import wintypes except (AttributeError, ImportError): windll = None SetConsoleTextAttribute = lambda *_: None else: from ctypes import ( byref, Structure, c_char, c_short, c_uint32, c_ushort, POINTER ) class CONSOLE_SCREEN_BUFFER_INFO(Structure): """struct in wincon.h.""" _fields_ = [ ("dwSize", wintypes._COORD), ("dwCursorPosition", wintypes._COORD), ("wAttributes", wintypes.WORD), ("srWindow", wintypes.SMALL_RECT), ("dwMaximumWindowSize", wintypes._COORD), ] def __str__(self): return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % ( self.dwSize.Y, self.dwSize.X , self.dwCursorPosition.Y, self.dwCursorPosition.X , self.wAttributes , self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right , self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X ) _GetStdHandle = windll.kernel32.GetStdHandle _GetStdHandle.argtypes = [ wintypes.DWORD, ] _GetStdHandle.restype = wintypes.HANDLE _GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo _GetConsoleScreenBufferInfo.argtypes = [ wintypes.HANDLE, POINTER(CONSOLE_SCREEN_BUFFER_INFO), ] _GetConsoleScreenBufferInfo.restype = wintypes.BOOL _SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute _SetConsoleTextAttribute.argtypes = [ wintypes.HANDLE, wintypes.WORD, ] _SetConsoleTextAttribute.restype = wintypes.BOOL _SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition _SetConsoleCursorPosition.argtypes = [ wintypes.HANDLE, wintypes._COORD, ] _SetConsoleCursorPosition.restype = wintypes.BOOL _FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA _FillConsoleOutputCharacterA.argtypes = [ wintypes.HANDLE, c_char, wintypes.DWORD, wintypes._COORD, POINTER(wintypes.DWORD), ] _FillConsoleOutputCharacterA.restype = wintypes.BOOL _FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute _FillConsoleOutputAttribute.argtypes = [ wintypes.HANDLE, wintypes.WORD, wintypes.DWORD, wintypes._COORD, POINTER(wintypes.DWORD), ] _FillConsoleOutputAttribute.restype = wintypes.BOOL handles = { STDOUT: _GetStdHandle(STDOUT), STDERR: _GetStdHandle(STDERR), } def GetConsoleScreenBufferInfo(stream_id=STDOUT): handle = handles[stream_id] csbi = CONSOLE_SCREEN_BUFFER_INFO() success = _GetConsoleScreenBufferInfo( handle, byref(csbi)) return csbi def SetConsoleTextAttribute(stream_id, attrs): handle = handles[stream_id] return _SetConsoleTextAttribute(handle, attrs) def SetConsoleCursorPosition(stream_id, position): position = wintypes._COORD(*position) # If the position is out of range, do nothing. if position.Y <= 0 or position.X <= 0: return # Adjust for Windows' SetConsoleCursorPosition: # 1. being 0-based, while ANSI is 1-based. # 2. expecting (x,y), while ANSI uses (y,x). adjusted_position = wintypes._COORD(position.Y - 1, position.X - 1) # Adjust for viewport's scroll position sr = GetConsoleScreenBufferInfo(STDOUT).srWindow adjusted_position.Y += sr.Top adjusted_position.X += sr.Left # Resume normal processing handle = handles[stream_id] return _SetConsoleCursorPosition(handle, adjusted_position) def FillConsoleOutputCharacter(stream_id, char, length, start): handle = handles[stream_id] char = c_char(char) length = wintypes.DWORD(length) num_written = wintypes.DWORD(0) # Note that this is hard-coded for ANSI (vs wide) bytes. success = _FillConsoleOutputCharacterA( handle, char, length, start, byref(num_written)) return num_written.value def FillConsoleOutputAttribute(stream_id, attr, length, start): ''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )''' handle = handles[stream_id] attribute = wintypes.WORD(attr) length = wintypes.DWORD(length) num_written = wintypes.DWORD(0) # Note that this is hard-coded for ANSI (vs wide) bytes. return _FillConsoleOutputAttribute( handle, attribute, length, start, byref(num_written))
gpl-2.0
[ 3, 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 199, 3, 687, 4747, 1095, 14, 72, 199, 13850, 275, 446, 845, 199, 18472, 2666, 275, 446, 713, 199, 199, 646, 5577, 199, 504, 5577, 492, 11243, 5455, 199, 199, 893, 26, 272, 22350, 275, 11243, 5455, 8, 9798, 14, 8886, 15982, 9, 272, 687, 5577, 492, 29762, 199, 2590, 334, 10227, 12, 3545, 304, 272, 22350, 275, 488, 272, 2494, 9270, 1872, 1646, 275, 2400, 627, 10388, 488, 199, 2836, 26, 272, 687, 5577, 492, 334, 267, 15968, 12, 21730, 12, 286, 63, 1560, 12, 286, 63, 3612, 12, 286, 63, 1635, 708, 12, 286, 63, 27170, 12, 6569, 272, 776, 339, 1021, 1868, 26792, 63, 25070, 63, 10960, 63, 4531, 8, 10766, 304, 267, 408, 1820, 315, 4747, 388, 14, 72, 1041, 267, 485, 955, 63, 275, 359, 288, 1689, 10772, 2320, 401, 29762, 423, 21901, 395, 288, 1689, 10772, 32766, 401, 29762, 423, 21901, 395, 288, 1689, 87, 5379, 401, 29762, 14, 5172, 395, 288, 1689, 5474, 4301, 401, 29762, 14, 28570, 63, 4168, 395, 288, 1689, 10772, 10915, 4301, 2320, 401, 29762, 423, 21901, 395, 267, 1622, 267, 347, 636, 495, 721, 277, 304, 288, 372, 25676, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 3171, 450, 334, 355, 291, 14, 10772, 2320, 14, 57, 12, 291, 14, 10772, 2320, 14, 56, 355, 2360, 291, 14, 10772, 32766, 14, 57, 12, 291, 14, 10772, 32766, 14, 56, 355, 2360, 291, 14, 87, 5379, 355, 2360, 291, 14, 5474, 4301, 14, 6105, 12, 291, 14, 5474, 4301, 14, 8185, 12, 291, 14, 5474, 4301, 14, 22886, 12, 291, 14, 5474, 4301, 14, 9121, 355, 2360, 291, 14, 10772, 10915, 4301, 2320, 14, 57, 12, 291, 14, 10772, 10915, 4301, 2320, 14, 56, 288, 776, 339, 485, 1002, 11976, 5940, 275, 22350, 14, 4989, 708, 14, 1002, 11976, 5940, 272, 485, 1002, 11976, 5940, 14, 10025, 275, 359, 267, 29762, 14, 24754, 12, 272, 1622, 272, 485, 1002, 11976, 5940, 14, 9990, 275, 29762, 14, 15885, 339, 485, 1002, 9270, 9616, 3299, 2354, 275, 22350, 14, 4989, 708, 14, 1002, 9270, 9616, 3299, 2354, 272, 485, 1002, 9270, 9616, 3299, 2354, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 6569, 8, 31774, 63, 25070, 63, 10960, 63, 4531, 395, 272, 1622, 272, 485, 1002, 9270, 9616, 3299, 2354, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 1872, 1646, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 1872, 1646, 272, 485, 1084, 9270, 1872, 1646, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 14, 5172, 12, 272, 1622, 272, 485, 1084, 9270, 1872, 1646, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 32766, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 32766, 272, 485, 1084, 9270, 32766, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 423, 21901, 12, 272, 1622, 272, 485, 1084, 9270, 32766, 14, 9990, 275, 29762, 14, 16026, 339, 485, 12914, 9270, 2959, 14852, 33, 275, 22350, 14, 4989, 708, 14, 12914, 9270, 2959, 14852, 33, 272, 485, 12914, 9270, 2959, 14852, 33, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 286, 63, 1560, 12, 267, 29762, 14, 24754, 12, 267, 29762, 423, 21901, 12, 267, 6569, 8, 27171, 14, 24754, 395, 272, 1622, 272, 485, 12914, 9270, 2959, 14852, 33, 14, 9990, 275, 29762, 14, 16026, 339, 485, 12914, 9270, 2959, 1646, 275, 22350, 14, 4989, 708, 14, 12914, 9270, 2959, 1646, 272, 485, 12914, 9270, 2959, 1646, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 14, 5172, 12, 267, 29762, 14, 24754, 12, 267, 29762, 423, 21901, 12, 267, 6569, 8, 27171, 14, 24754, 395, 272, 1622, 272, 485, 12914, 9270, 2959, 1646, 14, 9990, 275, 29762, 14, 16026, 339, 10022, 275, 469, 267, 4384, 12619, 26, 485, 1002, 11976, 5940, 8, 13850, 395, 267, 30118, 2666, 26, 485, 1002, 11976, 5940, 8, 18472, 2666, 395, 272, 789, 339, 347, 2372, 9270, 9616, 3299, 2354, 8, 1745, 63, 344, 29, 13850, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 7117, 4492, 275, 1868, 26792, 63, 25070, 63, 10960, 63, 4531, 342, 267, 3182, 275, 485, 1002, 9270, 9616, 3299, 2354, 8, 288, 2429, 12, 15968, 8, 1259, 4492, 430, 267, 372, 7117, 4492, 339, 347, 2494, 9270, 1872, 1646, 8, 1745, 63, 344, 12, 3290, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 372, 485, 1084, 9270, 1872, 1646, 8, 2479, 12, 3290, 9, 339, 347, 2494, 9270, 32766, 8, 1745, 63, 344, 12, 3421, 304, 267, 3421, 275, 29762, 423, 21901, 2031, 3124, 9, 267, 327, 982, 314, 3421, 365, 734, 402, 1425, 12, 886, 6548, 14, 267, 340, 3421, 14, 57, 2695, 378, 503, 3421, 14, 56, 2695, 378, 26, 288, 372, 267, 327, 26412, 367, 5417, 7, 2494, 9270, 32766, 26, 267, 327, 259, 413, 14, 3769, 378, 13, 6788, 12, 1830, 25600, 365, 413, 13, 6788, 14, 267, 327, 259, 499, 14, 21055, 334, 88, 12, 89, 395, 1830, 25600, 4440, 334, 89, 12, 88, 680, 267, 19477, 63, 3124, 275, 29762, 423, 21901, 8, 3124, 14, 57, 446, 413, 12, 3421, 14, 56, 446, 413, 9, 267, 327, 26412, 367, 2455, 719, 1159, 13704, 3421, 267, 11483, 275, 2372, 9270, 9616, 3299, 2354, 8, 13850, 680, 5474, 4301, 267, 19477, 63, 3124, 14, 57, 847, 11483, 14, 6105, 267, 19477, 63, 3124, 14, 56, 847, 11483, 14, 8185, 267, 327, 3591, 940, 3293, 6661, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 372, 485, 1084, 9270, 32766, 8, 2479, 12, 19477, 63, 3124, 9, 339, 347, 24797, 9270, 2959, 14852, 8, 1745, 63, 344, 12, 1495, 12, 2582, 12, 1343, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 1495, 275, 286, 63, 1560, 8, 1560, 9, 267, 2582, 275, 29762, 14, 24754, 8, 1267, 9, 267, 1967, 63, 8938, 275, 29762, 14, 24754, 8, 16, 9, 267, 327, 3390, 626 ]
[ 1898, 1603, 265, 1619, 290, 869, 580, 15515, 6171, 14, 6289, 650, 13, 16009, 4190, 12, 1937, 5113, 570, 14, 199, 199, 3, 687, 4747, 1095, 14, 72, 199, 13850, 275, 446, 845, 199, 18472, 2666, 275, 446, 713, 199, 199, 646, 5577, 199, 504, 5577, 492, 11243, 5455, 199, 199, 893, 26, 272, 22350, 275, 11243, 5455, 8, 9798, 14, 8886, 15982, 9, 272, 687, 5577, 492, 29762, 199, 2590, 334, 10227, 12, 3545, 304, 272, 22350, 275, 488, 272, 2494, 9270, 1872, 1646, 275, 2400, 627, 10388, 488, 199, 2836, 26, 272, 687, 5577, 492, 334, 267, 15968, 12, 21730, 12, 286, 63, 1560, 12, 286, 63, 3612, 12, 286, 63, 1635, 708, 12, 286, 63, 27170, 12, 6569, 272, 776, 339, 1021, 1868, 26792, 63, 25070, 63, 10960, 63, 4531, 8, 10766, 304, 267, 408, 1820, 315, 4747, 388, 14, 72, 1041, 267, 485, 955, 63, 275, 359, 288, 1689, 10772, 2320, 401, 29762, 423, 21901, 395, 288, 1689, 10772, 32766, 401, 29762, 423, 21901, 395, 288, 1689, 87, 5379, 401, 29762, 14, 5172, 395, 288, 1689, 5474, 4301, 401, 29762, 14, 28570, 63, 4168, 395, 288, 1689, 10772, 10915, 4301, 2320, 401, 29762, 423, 21901, 395, 267, 1622, 267, 347, 636, 495, 721, 277, 304, 288, 372, 25676, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 8719, 68, 3171, 450, 334, 355, 291, 14, 10772, 2320, 14, 57, 12, 291, 14, 10772, 2320, 14, 56, 355, 2360, 291, 14, 10772, 32766, 14, 57, 12, 291, 14, 10772, 32766, 14, 56, 355, 2360, 291, 14, 87, 5379, 355, 2360, 291, 14, 5474, 4301, 14, 6105, 12, 291, 14, 5474, 4301, 14, 8185, 12, 291, 14, 5474, 4301, 14, 22886, 12, 291, 14, 5474, 4301, 14, 9121, 355, 2360, 291, 14, 10772, 10915, 4301, 2320, 14, 57, 12, 291, 14, 10772, 10915, 4301, 2320, 14, 56, 288, 776, 339, 485, 1002, 11976, 5940, 275, 22350, 14, 4989, 708, 14, 1002, 11976, 5940, 272, 485, 1002, 11976, 5940, 14, 10025, 275, 359, 267, 29762, 14, 24754, 12, 272, 1622, 272, 485, 1002, 11976, 5940, 14, 9990, 275, 29762, 14, 15885, 339, 485, 1002, 9270, 9616, 3299, 2354, 275, 22350, 14, 4989, 708, 14, 1002, 9270, 9616, 3299, 2354, 272, 485, 1002, 9270, 9616, 3299, 2354, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 6569, 8, 31774, 63, 25070, 63, 10960, 63, 4531, 395, 272, 1622, 272, 485, 1002, 9270, 9616, 3299, 2354, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 1872, 1646, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 1872, 1646, 272, 485, 1084, 9270, 1872, 1646, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 14, 5172, 12, 272, 1622, 272, 485, 1084, 9270, 1872, 1646, 14, 9990, 275, 29762, 14, 16026, 339, 485, 1084, 9270, 32766, 275, 22350, 14, 4989, 708, 14, 1084, 9270, 32766, 272, 485, 1084, 9270, 32766, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 423, 21901, 12, 272, 1622, 272, 485, 1084, 9270, 32766, 14, 9990, 275, 29762, 14, 16026, 339, 485, 12914, 9270, 2959, 14852, 33, 275, 22350, 14, 4989, 708, 14, 12914, 9270, 2959, 14852, 33, 272, 485, 12914, 9270, 2959, 14852, 33, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 286, 63, 1560, 12, 267, 29762, 14, 24754, 12, 267, 29762, 423, 21901, 12, 267, 6569, 8, 27171, 14, 24754, 395, 272, 1622, 272, 485, 12914, 9270, 2959, 14852, 33, 14, 9990, 275, 29762, 14, 16026, 339, 485, 12914, 9270, 2959, 1646, 275, 22350, 14, 4989, 708, 14, 12914, 9270, 2959, 1646, 272, 485, 12914, 9270, 2959, 1646, 14, 10025, 275, 359, 267, 29762, 14, 15885, 12, 267, 29762, 14, 5172, 12, 267, 29762, 14, 24754, 12, 267, 29762, 423, 21901, 12, 267, 6569, 8, 27171, 14, 24754, 395, 272, 1622, 272, 485, 12914, 9270, 2959, 1646, 14, 9990, 275, 29762, 14, 16026, 339, 10022, 275, 469, 267, 4384, 12619, 26, 485, 1002, 11976, 5940, 8, 13850, 395, 267, 30118, 2666, 26, 485, 1002, 11976, 5940, 8, 18472, 2666, 395, 272, 789, 339, 347, 2372, 9270, 9616, 3299, 2354, 8, 1745, 63, 344, 29, 13850, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 7117, 4492, 275, 1868, 26792, 63, 25070, 63, 10960, 63, 4531, 342, 267, 3182, 275, 485, 1002, 9270, 9616, 3299, 2354, 8, 288, 2429, 12, 15968, 8, 1259, 4492, 430, 267, 372, 7117, 4492, 339, 347, 2494, 9270, 1872, 1646, 8, 1745, 63, 344, 12, 3290, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 372, 485, 1084, 9270, 1872, 1646, 8, 2479, 12, 3290, 9, 339, 347, 2494, 9270, 32766, 8, 1745, 63, 344, 12, 3421, 304, 267, 3421, 275, 29762, 423, 21901, 2031, 3124, 9, 267, 327, 982, 314, 3421, 365, 734, 402, 1425, 12, 886, 6548, 14, 267, 340, 3421, 14, 57, 2695, 378, 503, 3421, 14, 56, 2695, 378, 26, 288, 372, 267, 327, 26412, 367, 5417, 7, 2494, 9270, 32766, 26, 267, 327, 259, 413, 14, 3769, 378, 13, 6788, 12, 1830, 25600, 365, 413, 13, 6788, 14, 267, 327, 259, 499, 14, 21055, 334, 88, 12, 89, 395, 1830, 25600, 4440, 334, 89, 12, 88, 680, 267, 19477, 63, 3124, 275, 29762, 423, 21901, 8, 3124, 14, 57, 446, 413, 12, 3421, 14, 56, 446, 413, 9, 267, 327, 26412, 367, 2455, 719, 1159, 13704, 3421, 267, 11483, 275, 2372, 9270, 9616, 3299, 2354, 8, 13850, 680, 5474, 4301, 267, 19477, 63, 3124, 14, 57, 847, 11483, 14, 6105, 267, 19477, 63, 3124, 14, 56, 847, 11483, 14, 8185, 267, 327, 3591, 940, 3293, 6661, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 372, 485, 1084, 9270, 32766, 8, 2479, 12, 19477, 63, 3124, 9, 339, 347, 24797, 9270, 2959, 14852, 8, 1745, 63, 344, 12, 1495, 12, 2582, 12, 1343, 304, 267, 2429, 275, 10022, 59, 1745, 63, 344, 61, 267, 1495, 275, 286, 63, 1560, 8, 1560, 9, 267, 2582, 275, 29762, 14, 24754, 8, 1267, 9, 267, 1967, 63, 8938, 275, 29762, 14, 24754, 8, 16, 9, 267, 327, 3390, 626, 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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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 ]
tedlaz/pyted
ted17/ted17/dec.py
1
3802
# -*- coding: utf-8 -*- import decimal from collections import OrderedDict import textwrap def isNum(val): # is val number or not ? """Check if val is number or not :param val: value to check :return: Boolean """ try: float(val) except ValueError: return False else: return True def dec(poso=0, decimals=2): """ Always returns a decimal number. If poso is not a number or None returns dec(0) :param poso: Mumber in any format (string, float, int, ...) :param decimals: Number of decimals (default 2) :return: A decimal number rounded to decimals parameter """ if poso is None: poso = 0 PLACES = decimal.Decimal(10) ** (-1 * decimals) if isNum(poso): tmp = decimal.Decimal(poso) else: tmp = decimal.Decimal('0') # in case of tmp = -0.00 to remove negative sign if tmp == decimal.Decimal(0): tmp = decimal.Decimal(0) return tmp.quantize(PLACES) def triades(txt, separator='.'): ''' Help function to split digits to thousants ( 123456 becomes 123.456 ) ''' return separator.join(textwrap.wrap(txt[::-1], 3))[::-1] def dec2gr(poso, decimals=2, zero_as_space=False): ''' Returns string with Greek Formatted decimal (12345.67 becomes 12.345,67) ''' dposo = dec(poso, decimals) if dposo == dec(0): if zero_as_space: return ' ' sdposo = str(dposo) meion = '-' separator = '.' decimal_ceparator = ',' prosimo = '' if sdposo.startswith(meion): prosimo = meion sdposo = sdposo.replace(meion, '') if '.' in sdposo: sint, sdec = sdposo.split('.') else: sint = sdposo decimal_ceparator = '' sdec = '' return prosimo + triades(sint) + decimal_ceparator + sdec def gr2dec(poso): ''' Returns decimal (12.345,67 becomes 12345.67) ''' st = poso.replace('.', '') ds = st.replace(',', '.') return dec(ds) class Ddict(dict): ''' Dictionary of decimals only ''' def __init__(self, *args, **kwargs): # self.update(*args, **kwargs) fkw = {} for key in kwargs: fkw[key] = dec(kwargs[key]) dict.__init__(self, *args, **fkw) def __setitem__(self, key, val): dval = dec(val) dict.__setitem__(self, key, dval) class Ddi(dict): ''' Dictionary of decimals or text values ''' def __init__(self, *args, **kwargs): # self.update(*args, **kwargs) fkw = {} for key in kwargs: if key.startswith('_'): fkw[key] = dec(kwargs[key]) else: fkw[key] = kwargs[key] dict.__init__(self, *args, **fkw) def __setitem__(self, key, val): if key.startswith('_'): dval = dec(val) else: dval = val dict.__setitem__(self, key, dval) def distribute(val, distArray, decimals=2): """ input parameters: :param val: Decimal value for distribution :param distArray: Distribution Array :param decimals: Number of decimal digits :return: Tuple of distributed val """ tmpArr = [] val = dec(val, decimals) try: tar = dec(sum(distArray), decimals) except: return 0 for el in distArray: tmpArr.append(dec(val * dec(el, decimals) / tar, decimals)) nval = sum(tmpArr) dif = val - nval # Get the possible difference to fix round problem if dif != 0: # Max number Element gets the difference tmpArr[tmpArr.index(max(tmpArr))] += dif return tuple(tmpArr)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 646, 6107, 202, 199, 504, 5055, 492, 8773, 202, 199, 646, 13390, 8065, 199, 318, 365, 5667, 8, 637, 304, 221, 327, 365, 1139, 1329, 503, 440, 5805, 1128, 408, 1799, 340, 1139, 365, 1329, 503, 440, 2958, 520, 635, 1139, 26, 574, 370, 1104, 1128, 520, 1107, 26, 9411, 1128, 408, 1128, 862, 26, 1039, 2069, 8, 637, 9, 1128, 871, 1722, 26, 1039, 372, 756, 1128, 587, 26, 1039, 372, 715, 8065, 199, 318, 9700, 8, 555, 1152, 29, 16, 12, 6107, 83, 29, 18, 304, 1128, 408, 1128, 16763, 2529, 282, 6107, 1329, 14, 982, 2086, 79, 365, 440, 282, 1329, 503, 488, 1128, 2529, 9700, 8, 16, 9, 2958, 520, 635, 2086, 79, 26, 603, 884, 315, 1263, 1475, 334, 875, 12, 2069, 12, 1109, 12, 19172, 1128, 520, 635, 6107, 83, 26, 4860, 402, 6107, 83, 334, 885, 499, 9, 1128, 520, 1107, 26, 437, 6107, 1329, 24671, 370, 6107, 83, 2725, 1128, 408, 1128, 340, 2086, 79, 365, 488, 26, 1039, 2086, 79, 275, 378, 1128, 10092, 21287, 275, 6107, 14, 6745, 8, 709, 9, 1011, 5868, 17, 627, 6107, 83, 9, 1128, 340, 365, 5667, 8, 555, 1152, 304, 1039, 3529, 275, 6107, 14, 6745, 8, 555, 1152, 9, 1128, 587, 26, 1039, 3529, 275, 6107, 14, 6745, 360, 16, 358, 1128, 327, 315, 1930, 402, 3529, 275, 446, 16, 14, 383, 370, 2813, 6946, 2070, 1128, 340, 3529, 508, 6107, 14, 6745, 8, 16, 304, 1039, 3529, 275, 6107, 14, 6745, 8, 16, 9, 1128, 372, 3529, 14, 25897, 8, 2749, 21287, 9, 8065, 199, 318, 3229, 65, 3424, 8, 2424, 12, 9432, 15637, 735, 1128, 1449, 1128, 15456, 805, 370, 3715, 7576, 370, 294, 1785, 2285, 334, 14763, 1367, 15410, 11869, 14, 11419, 776, 1128, 1449, 1128, 372, 9432, 14, 904, 8, 505, 3823, 14, 3823, 8, 2424, 14172, 17, 467, 650, 430, 14172, 17, 61, 8065, 199, 318, 9700, 18, 2587, 8, 555, 1152, 12, 6107, 83, 29, 18, 12, 4697, 63, 305, 63, 2638, 29, 797, 304, 1128, 1449, 1128, 1803, 1059, 543, 598, 14291, 9701, 471, 6107, 334, 13261, 14, 1822, 15410, 3144, 14, 9908, 12, 1822, 9, 1128, 1449, 1128, 366, 555, 1152, 275, 9700, 8, 555, 1152, 12, 6107, 83, 9, 1128, 340, 366, 555, 1152, 508, 9700, 8, 16, 304, 1039, 340, 4697, 63, 305, 63, 2638, 26, 1675, 372, 283, 283, 1128, 14613, 555, 1152, 275, 620, 8, 68, 555, 1152, 9, 1128, 562, 1636, 275, 10791, 1128, 9432, 275, 7815, 1128, 6107, 63, 301, 462, 707, 275, 13647, 1128, 557, 338, 573, 275, 2125, 1128, 340, 14613, 555, 1152, 14, 2460, 8, 278, 1636, 304, 1039, 557, 338, 573, 275, 562, 1636, 1039, 14613, 555, 1152, 275, 14613, 555, 1152, 14, 1814, 8, 278, 1636, 12, 4074, 1128, 340, 7815, 315, 14613, 555, 1152, 26, 1039, 308, 442, 12, 308, 7778, 275, 14613, 555, 1152, 14, 1294, 7563, 1128, 587, 26, 1039, 308, 442, 275, 14613, 555, 1152, 1039, 6107, 63, 301, 462, 707, 275, 2125, 1039, 308, 7778, 275, 2125, 1128, 372, 557, 338, 573, 435, 3229, 65, 3424, 8, 30171, 9, 435, 6107, 63, 301, 462, 707, 435, 308, 7778, 8065, 199, 318, 7192, 18, 7778, 8, 555, 1152, 304, 1128, 1449, 1128, 1803, 6107, 334, 713, 14, 9908, 12, 1822, 15410, 25538, 14, 1822, 9, 1128, 1449, 1128, 410, 275, 2086, 79, 14, 1814, 14078, 4074, 1128, 6364, 275, 410, 14, 1814, 32718, 20093, 1128, 372, 9700, 8, 795, 9, 8065, 199, 533, 577, 807, 8, 807, 304, 2958, 1449, 1128, 11932, 402, 6107, 83, 1454, 1128, 1449, 2958, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 1039, 327, 291, 14, 873, 2031, 589, 12, 1011, 958, 9, 1039, 289, 829, 275, 1052, 1039, 367, 790, 315, 2074, 26, 1675, 289, 829, 59, 498, 61, 275, 9700, 8, 958, 59, 498, 566, 1039, 1211, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 70, 829, 9, 2958, 347, 636, 8617, 721, 277, 12, 790, 12, 1139, 304, 1039, 366, 637, 275, 9700, 8, 637, 9, 1039, 1211, 855, 8617, 721, 277, 12, 790, 12, 366, 637, 9, 8065, 199, 533, 577, 328, 8, 807, 304, 2958, 1449, 1128, 11932, 402, 6107, 83, 503, 1318, 1338, 1128, 1449, 2958, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 1039, 327, 291, 14, 873, 2031, 589, 12, 1011, 958, 9, 1039, 289, 829, 275, 1052, 1039, 367, 790, 315, 2074, 26, 1675, 340, 790, 14, 2460, 30018, 2628, 289, 829, 59, 498, 61, 275, 9700, 8, 958, 59, 498, 566, 1675, 587, 26, 2628, 289, 829, 59, 498, 61, 275, 2074, 59, 498, 61, 1039, 1211, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 70, 829, 9, 2958, 347, 636, 8617, 721, 277, 12, 790, 12, 1139, 304, 1039, 340, 790, 14, 2460, 30018, 1675, 366, 637, 275, 9700, 8, 637, 9, 1039, 587, 26, 1675, 366, 637, 275, 1139, 1039, 1211, 855, 8617, 721, 277, 12, 790, 12, 366, 637, 9, 8065, 199, 318, 11207, 8, 637, 12, 2917, 3836, 12, 6107, 83, 29, 18, 304, 1128, 408, 1128, 1324, 2633, 26, 2958, 520, 635, 1139, 26, 6345, 574, 367, 4084, 1128, 520, 635, 2917, 3836, 26, 11839, 8725, 1128, 520, 635, 6107, 83, 26, 4860, 402, 6107, 7576, 1128, 520, 1107, 26, 11634, 402, 1854, 1139, 1128, 408, 1128, 3529, 22011, 275, 942, 1128, 1139, 275, 9700, 8, 637, 12, 6107, 83, 9, 1128, 862, 26, 1039, 5330, 275, 9700, 8, 1838, 8, 2686, 3836, 395, 6107, 83, 9, 1128, 871, 26, 1039, 372, 378, 1128, 367, 579, 315, 2917, 3836, 26, 1039, 3529, 22011, 14, 740, 8, 7778, 8, 637, 627, 9700, 8, 352, 12, 6107, 83, 9, 1182, 5330, 12, 6107, 83, 430, 1128, 302, 637, 275, 3089, 8, 2791, 22011, 9, 1128, 487, 70, 275, 1139, 446, 302, 637, 221, 327, 2372, 314, 3962, 8865, 370, 5325, 6168, 5160, 1128, 340, 487, 70, 1137, 378, 26, 1039, 327, 8228, 1329, 6566, 7545, 314, 8865, 1039, 3529, 22011, 59, 2791, 22011, 14, 1080, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 646, 6107, 202, 199, 504, 5055, 492, 8773, 202, 199, 646, 13390, 8065, 199, 318, 365, 5667, 8, 637, 304, 221, 327, 365, 1139, 1329, 503, 440, 5805, 1128, 408, 1799, 340, 1139, 365, 1329, 503, 440, 2958, 520, 635, 1139, 26, 574, 370, 1104, 1128, 520, 1107, 26, 9411, 1128, 408, 1128, 862, 26, 1039, 2069, 8, 637, 9, 1128, 871, 1722, 26, 1039, 372, 756, 1128, 587, 26, 1039, 372, 715, 8065, 199, 318, 9700, 8, 555, 1152, 29, 16, 12, 6107, 83, 29, 18, 304, 1128, 408, 1128, 16763, 2529, 282, 6107, 1329, 14, 982, 2086, 79, 365, 440, 282, 1329, 503, 488, 1128, 2529, 9700, 8, 16, 9, 2958, 520, 635, 2086, 79, 26, 603, 884, 315, 1263, 1475, 334, 875, 12, 2069, 12, 1109, 12, 19172, 1128, 520, 635, 6107, 83, 26, 4860, 402, 6107, 83, 334, 885, 499, 9, 1128, 520, 1107, 26, 437, 6107, 1329, 24671, 370, 6107, 83, 2725, 1128, 408, 1128, 340, 2086, 79, 365, 488, 26, 1039, 2086, 79, 275, 378, 1128, 10092, 21287, 275, 6107, 14, 6745, 8, 709, 9, 1011, 5868, 17, 627, 6107, 83, 9, 1128, 340, 365, 5667, 8, 555, 1152, 304, 1039, 3529, 275, 6107, 14, 6745, 8, 555, 1152, 9, 1128, 587, 26, 1039, 3529, 275, 6107, 14, 6745, 360, 16, 358, 1128, 327, 315, 1930, 402, 3529, 275, 446, 16, 14, 383, 370, 2813, 6946, 2070, 1128, 340, 3529, 508, 6107, 14, 6745, 8, 16, 304, 1039, 3529, 275, 6107, 14, 6745, 8, 16, 9, 1128, 372, 3529, 14, 25897, 8, 2749, 21287, 9, 8065, 199, 318, 3229, 65, 3424, 8, 2424, 12, 9432, 15637, 735, 1128, 1449, 1128, 15456, 805, 370, 3715, 7576, 370, 294, 1785, 2285, 334, 14763, 1367, 15410, 11869, 14, 11419, 776, 1128, 1449, 1128, 372, 9432, 14, 904, 8, 505, 3823, 14, 3823, 8, 2424, 14172, 17, 467, 650, 430, 14172, 17, 61, 8065, 199, 318, 9700, 18, 2587, 8, 555, 1152, 12, 6107, 83, 29, 18, 12, 4697, 63, 305, 63, 2638, 29, 797, 304, 1128, 1449, 1128, 1803, 1059, 543, 598, 14291, 9701, 471, 6107, 334, 13261, 14, 1822, 15410, 3144, 14, 9908, 12, 1822, 9, 1128, 1449, 1128, 366, 555, 1152, 275, 9700, 8, 555, 1152, 12, 6107, 83, 9, 1128, 340, 366, 555, 1152, 508, 9700, 8, 16, 304, 1039, 340, 4697, 63, 305, 63, 2638, 26, 1675, 372, 283, 283, 1128, 14613, 555, 1152, 275, 620, 8, 68, 555, 1152, 9, 1128, 562, 1636, 275, 10791, 1128, 9432, 275, 7815, 1128, 6107, 63, 301, 462, 707, 275, 13647, 1128, 557, 338, 573, 275, 2125, 1128, 340, 14613, 555, 1152, 14, 2460, 8, 278, 1636, 304, 1039, 557, 338, 573, 275, 562, 1636, 1039, 14613, 555, 1152, 275, 14613, 555, 1152, 14, 1814, 8, 278, 1636, 12, 4074, 1128, 340, 7815, 315, 14613, 555, 1152, 26, 1039, 308, 442, 12, 308, 7778, 275, 14613, 555, 1152, 14, 1294, 7563, 1128, 587, 26, 1039, 308, 442, 275, 14613, 555, 1152, 1039, 6107, 63, 301, 462, 707, 275, 2125, 1039, 308, 7778, 275, 2125, 1128, 372, 557, 338, 573, 435, 3229, 65, 3424, 8, 30171, 9, 435, 6107, 63, 301, 462, 707, 435, 308, 7778, 8065, 199, 318, 7192, 18, 7778, 8, 555, 1152, 304, 1128, 1449, 1128, 1803, 6107, 334, 713, 14, 9908, 12, 1822, 15410, 25538, 14, 1822, 9, 1128, 1449, 1128, 410, 275, 2086, 79, 14, 1814, 14078, 4074, 1128, 6364, 275, 410, 14, 1814, 32718, 20093, 1128, 372, 9700, 8, 795, 9, 8065, 199, 533, 577, 807, 8, 807, 304, 2958, 1449, 1128, 11932, 402, 6107, 83, 1454, 1128, 1449, 2958, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 1039, 327, 291, 14, 873, 2031, 589, 12, 1011, 958, 9, 1039, 289, 829, 275, 1052, 1039, 367, 790, 315, 2074, 26, 1675, 289, 829, 59, 498, 61, 275, 9700, 8, 958, 59, 498, 566, 1039, 1211, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 70, 829, 9, 2958, 347, 636, 8617, 721, 277, 12, 790, 12, 1139, 304, 1039, 366, 637, 275, 9700, 8, 637, 9, 1039, 1211, 855, 8617, 721, 277, 12, 790, 12, 366, 637, 9, 8065, 199, 533, 577, 328, 8, 807, 304, 2958, 1449, 1128, 11932, 402, 6107, 83, 503, 1318, 1338, 1128, 1449, 2958, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 1039, 327, 291, 14, 873, 2031, 589, 12, 1011, 958, 9, 1039, 289, 829, 275, 1052, 1039, 367, 790, 315, 2074, 26, 1675, 340, 790, 14, 2460, 30018, 2628, 289, 829, 59, 498, 61, 275, 9700, 8, 958, 59, 498, 566, 1675, 587, 26, 2628, 289, 829, 59, 498, 61, 275, 2074, 59, 498, 61, 1039, 1211, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 70, 829, 9, 2958, 347, 636, 8617, 721, 277, 12, 790, 12, 1139, 304, 1039, 340, 790, 14, 2460, 30018, 1675, 366, 637, 275, 9700, 8, 637, 9, 1039, 587, 26, 1675, 366, 637, 275, 1139, 1039, 1211, 855, 8617, 721, 277, 12, 790, 12, 366, 637, 9, 8065, 199, 318, 11207, 8, 637, 12, 2917, 3836, 12, 6107, 83, 29, 18, 304, 1128, 408, 1128, 1324, 2633, 26, 2958, 520, 635, 1139, 26, 6345, 574, 367, 4084, 1128, 520, 635, 2917, 3836, 26, 11839, 8725, 1128, 520, 635, 6107, 83, 26, 4860, 402, 6107, 7576, 1128, 520, 1107, 26, 11634, 402, 1854, 1139, 1128, 408, 1128, 3529, 22011, 275, 942, 1128, 1139, 275, 9700, 8, 637, 12, 6107, 83, 9, 1128, 862, 26, 1039, 5330, 275, 9700, 8, 1838, 8, 2686, 3836, 395, 6107, 83, 9, 1128, 871, 26, 1039, 372, 378, 1128, 367, 579, 315, 2917, 3836, 26, 1039, 3529, 22011, 14, 740, 8, 7778, 8, 637, 627, 9700, 8, 352, 12, 6107, 83, 9, 1182, 5330, 12, 6107, 83, 430, 1128, 302, 637, 275, 3089, 8, 2791, 22011, 9, 1128, 487, 70, 275, 1139, 446, 302, 637, 221, 327, 2372, 314, 3962, 8865, 370, 5325, 6168, 5160, 1128, 340, 487, 70, 1137, 378, 26, 1039, 327, 8228, 1329, 6566, 7545, 314, 8865, 1039, 3529, 22011, 59, 2791, 22011, 14, 1080, 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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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
morreene/tradenews
venv/Lib/site-packages/sqlalchemy/orm/collections.py
34
53549
# orm/collections.py # Copyright (C) 2005-2016 the SQLAlchemy authors and contributors # <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """Support for collections of mapped entities. The collections package supplies the machinery used to inform the ORM of collection membership changes. An instrumentation via decoration approach is used, allowing arbitrary types (including built-ins) to be used as entity collections without requiring inheritance from a base class. Instrumentation decoration relays membership change events to the :class:`.CollectionAttributeImpl` that is currently managing the collection. The decorators observe function call arguments and return values, tracking entities entering or leaving the collection. Two decorator approaches are provided. One is a bundle of generic decorators that map function arguments and return values to events:: from sqlalchemy.orm.collections import collection class MyClass(object): # ... @collection.adds(1) def store(self, item): self.data.append(item) @collection.removes_return() def pop(self): return self.data.pop() The second approach is a bundle of targeted decorators that wrap appropriate append and remove notifiers around the mutation methods present in the standard Python ``list``, ``set`` and ``dict`` interfaces. These could be specified in terms of generic decorator recipes, but are instead hand-tooled for increased efficiency. The targeted decorators occasionally implement adapter-like behavior, such as mapping bulk-set methods (``extend``, ``update``, ``__setslice__``, etc.) into the series of atomic mutation events that the ORM requires. The targeted decorators are used internally for automatic instrumentation of entity collection classes. Every collection class goes through a transformation process roughly like so: 1. If the class is a built-in, substitute a trivial sub-class 2. Is this class already instrumented? 3. Add in generic decorators 4. Sniff out the collection interface through duck-typing 5. Add targeted decoration to any undecorated interface method This process modifies the class at runtime, decorating methods and adding some bookkeeping properties. This isn't possible (or desirable) for built-in classes like ``list``, so trivial sub-classes are substituted to hold decoration:: class InstrumentedList(list): pass Collection classes can be specified in ``relationship(collection_class=)`` as types or a function that returns an instance. Collection classes are inspected and instrumented during the mapper compilation phase. The collection_class callable will be executed once to produce a specimen instance, and the type of that specimen will be instrumented. Functions that return built-in types like ``lists`` will be adapted to produce instrumented instances. When extending a known type like ``list``, additional decorations are not generally not needed. Odds are, the extension method will delegate to a method that's already instrumented. For example:: class QueueIsh(list): def push(self, item): self.append(item) def shift(self): return self.pop(0) There's no need to decorate these methods. ``append`` and ``pop`` are already instrumented as part of the ``list`` interface. Decorating them would fire duplicate events, which should be avoided. The targeted decoration tries not to rely on other methods in the underlying collection class, but some are unavoidable. Many depend on 'read' methods being present to properly instrument a 'write', for example, ``__setitem__`` needs ``__getitem__``. "Bulk" methods like ``update`` and ``extend`` may also reimplemented in terms of atomic appends and removes, so the ``extend`` decoration will actually perform many ``append`` operations and not call the underlying method at all. Tight control over bulk operation and the firing of events is also possible by implementing the instrumentation internally in your methods. The basic instrumentation package works under the general assumption that collection mutation will not raise unusual exceptions. If you want to closely orchestrate append and remove events with exception management, internal instrumentation may be the answer. Within your method, ``collection_adapter(self)`` will retrieve an object that you can use for explicit control over triggering append and remove events. The owning object and :class:`.CollectionAttributeImpl` are also reachable through the adapter, allowing for some very sophisticated behavior. """ import inspect import operator import weakref from ..sql import expression from .. import util, exc as sa_exc from . import base from sqlalchemy.util.compat import inspect_getargspec __all__ = ['collection', 'collection_adapter', 'mapped_collection', 'column_mapped_collection', 'attribute_mapped_collection'] __instrumentation_mutex = util.threading.Lock() class _PlainColumnGetter(object): """Plain column getter, stores collection of Column objects directly. Serializes to a :class:`._SerializableColumnGetterV2` which has more expensive __call__() performance and some rare caveats. """ def __init__(self, cols): self.cols = cols self.composite = len(cols) > 1 def __reduce__(self): return _SerializableColumnGetterV2._reduce_from_cols(self.cols) def _cols(self, mapper): return self.cols def __call__(self, value): state = base.instance_state(value) m = base._state_mapper(state) key = [ m._get_state_attr_by_column(state, state.dict, col) for col in self._cols(m) ] if self.composite: return tuple(key) else: return key[0] class _SerializableColumnGetter(object): """Column-based getter used in version 0.7.6 only. Remains here for pickle compatibility with 0.7.6. """ def __init__(self, colkeys): self.colkeys = colkeys self.composite = len(colkeys) > 1 def __reduce__(self): return _SerializableColumnGetter, (self.colkeys,) def __call__(self, value): state = base.instance_state(value) m = base._state_mapper(state) key = [m._get_state_attr_by_column( state, state.dict, m.mapped_table.columns[k]) for k in self.colkeys] if self.composite: return tuple(key) else: return key[0] class _SerializableColumnGetterV2(_PlainColumnGetter): """Updated serializable getter which deals with multi-table mapped classes. Two extremely unusual cases are not supported. Mappings which have tables across multiple metadata objects, or which are mapped to non-Table selectables linked across inheriting mappers may fail to function here. """ def __init__(self, colkeys): self.colkeys = colkeys self.composite = len(colkeys) > 1 def __reduce__(self): return self.__class__, (self.colkeys,) @classmethod def _reduce_from_cols(cls, cols): def _table_key(c): if not isinstance(c.table, expression.TableClause): return None else: return c.table.key colkeys = [(c.key, _table_key(c)) for c in cols] return _SerializableColumnGetterV2, (colkeys,) def _cols(self, mapper): cols = [] metadata = getattr(mapper.local_table, 'metadata', None) for (ckey, tkey) in self.colkeys: if tkey is None or \ metadata is None or \ tkey not in metadata: cols.append(mapper.local_table.c[ckey]) else: cols.append(metadata.tables[tkey].c[ckey]) return cols def column_mapped_collection(mapping_spec): """A dictionary-based collection type with column-based keying. Returns a :class:`.MappedCollection` factory with a keying function generated from mapping_spec, which may be a Column or a sequence of Columns. The key value must be immutable for the lifetime of the object. You can not, for example, map on foreign key values if those key values will change during the session, i.e. from None to a database-assigned integer after a session flush. """ cols = [expression._only_column_elements(q, "mapping_spec") for q in util.to_list(mapping_spec) ] keyfunc = _PlainColumnGetter(cols) return lambda: MappedCollection(keyfunc) class _SerializableAttrGetter(object): def __init__(self, name): self.name = name self.getter = operator.attrgetter(name) def __call__(self, target): return self.getter(target) def __reduce__(self): return _SerializableAttrGetter, (self.name, ) def attribute_mapped_collection(attr_name): """A dictionary-based collection type with attribute-based keying. Returns a :class:`.MappedCollection` factory with a keying based on the 'attr_name' attribute of entities in the collection, where ``attr_name`` is the string name of the attribute. The key value must be immutable for the lifetime of the object. You can not, for example, map on foreign key values if those key values will change during the session, i.e. from None to a database-assigned integer after a session flush. """ getter = _SerializableAttrGetter(attr_name) return lambda: MappedCollection(getter) def mapped_collection(keyfunc): """A dictionary-based collection type with arbitrary keying. Returns a :class:`.MappedCollection` factory with a keying function generated from keyfunc, a callable that takes an entity and returns a key value. The key value must be immutable for the lifetime of the object. You can not, for example, map on foreign key values if those key values will change during the session, i.e. from None to a database-assigned integer after a session flush. """ return lambda: MappedCollection(keyfunc) class collection(object): """Decorators for entity collection classes. The decorators fall into two groups: annotations and interception recipes. The annotating decorators (appender, remover, iterator, linker, converter, internally_instrumented) indicate the method's purpose and take no arguments. They are not written with parens:: @collection.appender def append(self, append): ... The recipe decorators all require parens, even those that take no arguments:: @collection.adds('entity') def insert(self, position, entity): ... @collection.removes_return() def popitem(self): ... """ # Bundled as a class solely for ease of use: packaging, doc strings, # importability. @staticmethod def appender(fn): """Tag the method as the collection appender. The appender method is called with one positional argument: the value to append. The method will be automatically decorated with 'adds(1)' if not already decorated:: @collection.appender def add(self, append): ... # or, equivalently @collection.appender @collection.adds(1) def add(self, append): ... # for mapping type, an 'append' may kick out a previous value # that occupies that slot. consider d['a'] = 'foo'- any previous # value in d['a'] is discarded. @collection.appender @collection.replaces(1) def add(self, entity): key = some_key_func(entity) previous = None if key in self: previous = self[key] self[key] = entity return previous If the value to append is not allowed in the collection, you may raise an exception. Something to remember is that the appender will be called for each object mapped by a database query. If the database contains rows that violate your collection semantics, you will need to get creative to fix the problem, as access via the collection will not work. If the appender method is internally instrumented, you must also receive the keyword argument '_sa_initiator' and ensure its promulgation to collection events. """ fn._sa_instrument_role = 'appender' return fn @staticmethod def remover(fn): """Tag the method as the collection remover. The remover method is called with one positional argument: the value to remove. The method will be automatically decorated with :meth:`removes_return` if not already decorated:: @collection.remover def zap(self, entity): ... # or, equivalently @collection.remover @collection.removes_return() def zap(self, ): ... If the value to remove is not present in the collection, you may raise an exception or return None to ignore the error. If the remove method is internally instrumented, you must also receive the keyword argument '_sa_initiator' and ensure its promulgation to collection events. """ fn._sa_instrument_role = 'remover' return fn @staticmethod def iterator(fn): """Tag the method as the collection remover. The iterator method is called with no arguments. It is expected to return an iterator over all collection members:: @collection.iterator def __iter__(self): ... """ fn._sa_instrument_role = 'iterator' return fn @staticmethod def internally_instrumented(fn): """Tag the method as instrumented. This tag will prevent any decoration from being applied to the method. Use this if you are orchestrating your own calls to :func:`.collection_adapter` in one of the basic SQLAlchemy interface methods, or to prevent an automatic ABC method decoration from wrapping your implementation:: # normally an 'extend' method on a list-like class would be # automatically intercepted and re-implemented in terms of # SQLAlchemy events and append(). your implementation will # never be called, unless: @collection.internally_instrumented def extend(self, items): ... """ fn._sa_instrumented = True return fn @staticmethod def linker(fn): """Tag the method as a "linked to attribute" event handler. This optional event handler will be called when the collection class is linked to or unlinked from the InstrumentedAttribute. It is invoked immediately after the '_sa_adapter' property is set on the instance. A single argument is passed: the collection adapter that has been linked, or None if unlinking. .. deprecated:: 1.0.0 - the :meth:`.collection.linker` handler is superseded by the :meth:`.AttributeEvents.init_collection` and :meth:`.AttributeEvents.dispose_collection` handlers. """ fn._sa_instrument_role = 'linker' return fn link = linker """deprecated; synonym for :meth:`.collection.linker`.""" @staticmethod def converter(fn): """Tag the method as the collection converter. This optional method will be called when a collection is being replaced entirely, as in:: myobj.acollection = [newvalue1, newvalue2] The converter method will receive the object being assigned and should return an iterable of values suitable for use by the ``appender`` method. A converter must not assign values or mutate the collection, its sole job is to adapt the value the user provides into an iterable of values for the ORM's use. The default converter implementation will use duck-typing to do the conversion. A dict-like collection will be convert into an iterable of dictionary values, and other types will simply be iterated:: @collection.converter def convert(self, other): ... If the duck-typing of the object does not match the type of this collection, a TypeError is raised. Supply an implementation of this method if you want to expand the range of possible types that can be assigned in bulk or perform validation on the values about to be assigned. """ fn._sa_instrument_role = 'converter' return fn @staticmethod def adds(arg): """Mark the method as adding an entity to the collection. Adds "add to collection" handling to the method. The decorator argument indicates which method argument holds the SQLAlchemy-relevant value. Arguments can be specified positionally (i.e. integer) or by name:: @collection.adds(1) def push(self, item): ... @collection.adds('entity') def do_stuff(self, thing, entity=None): ... """ def decorator(fn): fn._sa_instrument_before = ('fire_append_event', arg) return fn return decorator @staticmethod def replaces(arg): """Mark the method as replacing an entity in the collection. Adds "add to collection" and "remove from collection" handling to the method. The decorator argument indicates which method argument holds the SQLAlchemy-relevant value to be added, and return value, if any will be considered the value to remove. Arguments can be specified positionally (i.e. integer) or by name:: @collection.replaces(2) def __setitem__(self, index, item): ... """ def decorator(fn): fn._sa_instrument_before = ('fire_append_event', arg) fn._sa_instrument_after = 'fire_remove_event' return fn return decorator @staticmethod def removes(arg): """Mark the method as removing an entity in the collection. Adds "remove from collection" handling to the method. The decorator argument indicates which method argument holds the SQLAlchemy-relevant value to be removed. Arguments can be specified positionally (i.e. integer) or by name:: @collection.removes(1) def zap(self, item): ... For methods where the value to remove is not known at call-time, use collection.removes_return. """ def decorator(fn): fn._sa_instrument_before = ('fire_remove_event', arg) return fn return decorator @staticmethod def removes_return(): """Mark the method as removing an entity in the collection. Adds "remove from collection" handling to the method. The return value of the method, if any, is considered the value to remove. The method arguments are not inspected:: @collection.removes_return() def pop(self): ... For methods where the value to remove is known at call-time, use collection.remove. """ def decorator(fn): fn._sa_instrument_after = 'fire_remove_event' return fn return decorator collection_adapter = operator.attrgetter('_sa_adapter') """Fetch the :class:`.CollectionAdapter` for a collection.""" class CollectionAdapter(object): """Bridges between the ORM and arbitrary Python collections. Proxies base-level collection operations (append, remove, iterate) to the underlying Python collection, and emits add/remove events for entities entering or leaving the collection. The ORM uses :class:`.CollectionAdapter` exclusively for interaction with entity collections. """ invalidated = False def __init__(self, attr, owner_state, data): self._key = attr.key self._data = weakref.ref(data) self.owner_state = owner_state data._sa_adapter = self def _warn_invalidated(self): util.warn("This collection has been invalidated.") @property def data(self): "The entity collection being adapted." return self._data() @property def _referenced_by_owner(self): """return True if the owner state still refers to this collection. This will return False within a bulk replace operation, where this collection is the one being replaced. """ return self.owner_state.dict[self._key] is self._data() @util.memoized_property def attr(self): return self.owner_state.manager[self._key].impl def adapt_like_to_iterable(self, obj): """Converts collection-compatible objects to an iterable of values. Can be passed any type of object, and if the underlying collection determines that it can be adapted into a stream of values it can use, returns an iterable of values suitable for append()ing. This method may raise TypeError or any other suitable exception if adaptation fails. If a converter implementation is not supplied on the collection, a default duck-typing-based implementation is used. """ converter = self._data()._sa_converter if converter is not None: return converter(obj) setting_type = util.duck_type_collection(obj) receiving_type = util.duck_type_collection(self._data()) if obj is None or setting_type != receiving_type: given = obj is None and 'None' or obj.__class__.__name__ if receiving_type is None: wanted = self._data().__class__.__name__ else: wanted = receiving_type.__name__ raise TypeError( "Incompatible collection type: %s is not %s-like" % ( given, wanted)) # If the object is an adapted collection, return the (iterable) # adapter. if getattr(obj, '_sa_adapter', None) is not None: return obj._sa_adapter elif setting_type == dict: if util.py3k: return obj.values() else: return getattr(obj, 'itervalues', obj.values)() else: return iter(obj) def append_with_event(self, item, initiator=None): """Add an entity to the collection, firing mutation events.""" self._data()._sa_appender(item, _sa_initiator=initiator) def append_without_event(self, item): """Add or restore an entity to the collection, firing no events.""" self._data()._sa_appender(item, _sa_initiator=False) def append_multiple_without_event(self, items): """Add or restore an entity to the collection, firing no events.""" appender = self._data()._sa_appender for item in items: appender(item, _sa_initiator=False) def remove_with_event(self, item, initiator=None): """Remove an entity from the collection, firing mutation events.""" self._data()._sa_remover(item, _sa_initiator=initiator) def remove_without_event(self, item): """Remove an entity from the collection, firing no events.""" self._data()._sa_remover(item, _sa_initiator=False) def clear_with_event(self, initiator=None): """Empty the collection, firing a mutation event for each entity.""" remover = self._data()._sa_remover for item in list(self): remover(item, _sa_initiator=initiator) def clear_without_event(self): """Empty the collection, firing no events.""" remover = self._data()._sa_remover for item in list(self): remover(item, _sa_initiator=False) def __iter__(self): """Iterate over entities in the collection.""" return iter(self._data()._sa_iterator()) def __len__(self): """Count entities in the collection.""" return len(list(self._data()._sa_iterator())) def __bool__(self): return True __nonzero__ = __bool__ def fire_append_event(self, item, initiator=None): """Notify that a entity has entered the collection. Initiator is a token owned by the InstrumentedAttribute that initiated the membership mutation, and should be left as None unless you are passing along an initiator value from a chained operation. """ if initiator is not False: if self.invalidated: self._warn_invalidated() return self.attr.fire_append_event( self.owner_state, self.owner_state.dict, item, initiator) else: return item def fire_remove_event(self, item, initiator=None): """Notify that a entity has been removed from the collection. Initiator is the InstrumentedAttribute that initiated the membership mutation, and should be left as None unless you are passing along an initiator value from a chained operation. """ if initiator is not False: if self.invalidated: self._warn_invalidated() self.attr.fire_remove_event( self.owner_state, self.owner_state.dict, item, initiator) def fire_pre_remove_event(self, initiator=None): """Notify that an entity is about to be removed from the collection. Only called if the entity cannot be removed after calling fire_remove_event(). """ if self.invalidated: self._warn_invalidated() self.attr.fire_pre_remove_event( self.owner_state, self.owner_state.dict, initiator=initiator) def __getstate__(self): return {'key': self._key, 'owner_state': self.owner_state, 'data': self.data} def __setstate__(self, d): self._key = d['key'] self.owner_state = d['owner_state'] self._data = weakref.ref(d['data']) def bulk_replace(values, existing_adapter, new_adapter): """Load a new collection, firing events based on prior like membership. Appends instances in ``values`` onto the ``new_adapter``. Events will be fired for any instance not present in the ``existing_adapter``. Any instances in ``existing_adapter`` not present in ``values`` will have remove events fired upon them. :param values: An iterable of collection member instances :param existing_adapter: A :class:`.CollectionAdapter` of instances to be replaced :param new_adapter: An empty :class:`.CollectionAdapter` to load with ``values`` """ if not isinstance(values, list): values = list(values) idset = util.IdentitySet existing_idset = idset(existing_adapter or ()) constants = existing_idset.intersection(values or ()) additions = idset(values or ()).difference(constants) removals = existing_idset.difference(constants) for member in values or (): if member in additions: new_adapter.append_with_event(member) elif member in constants: new_adapter.append_without_event(member) if existing_adapter: for member in removals: existing_adapter.remove_with_event(member) def prepare_instrumentation(factory): """Prepare a callable for future use as a collection class factory. Given a collection class factory (either a type or no-arg callable), return another factory that will produce compatible instances when called. This function is responsible for converting collection_class=list into the run-time behavior of collection_class=InstrumentedList. """ # Convert a builtin to 'Instrumented*' if factory in __canned_instrumentation: factory = __canned_instrumentation[factory] # Create a specimen cls = type(factory()) # Did factory callable return a builtin? if cls in __canned_instrumentation: # Wrap it so that it returns our 'Instrumented*' factory = __converting_factory(cls, factory) cls = factory() # Instrument the class if needed. if __instrumentation_mutex.acquire(): try: if getattr(cls, '_sa_instrumented', None) != id(cls): _instrument_class(cls) finally: __instrumentation_mutex.release() return factory def __converting_factory(specimen_cls, original_factory): """Return a wrapper that converts a "canned" collection like set, dict, list into the Instrumented* version. """ instrumented_cls = __canned_instrumentation[specimen_cls] def wrapper(): collection = original_factory() return instrumented_cls(collection) # often flawed but better than nothing wrapper.__name__ = "%sWrapper" % original_factory.__name__ wrapper.__doc__ = original_factory.__doc__ return wrapper def _instrument_class(cls): """Modify methods in a class and install instrumentation.""" # In the normal call flow, a request for any of the 3 basic collection # types is transformed into one of our trivial subclasses # (e.g. InstrumentedList). Catch anything else that sneaks in here... if cls.__module__ == '__builtin__': raise sa_exc.ArgumentError( "Can not instrument a built-in type. Use a " "subclass, even a trivial one.") roles, methods = _locate_roles_and_methods(cls) _setup_canned_roles(cls, roles, methods) _assert_required_roles(cls, roles, methods) _set_collection_attributes(cls, roles, methods) def _locate_roles_and_methods(cls): """search for _sa_instrument_role-decorated methods in method resolution order, assign to roles. """ roles = {} methods = {} for supercls in cls.__mro__: for name, method in vars(supercls).items(): if not util.callable(method): continue # note role declarations if hasattr(method, '_sa_instrument_role'): role = method._sa_instrument_role assert role in ('appender', 'remover', 'iterator', 'linker', 'converter') roles.setdefault(role, name) # transfer instrumentation requests from decorated function # to the combined queue before, after = None, None if hasattr(method, '_sa_instrument_before'): op, argument = method._sa_instrument_before assert op in ('fire_append_event', 'fire_remove_event') before = op, argument if hasattr(method, '_sa_instrument_after'): op = method._sa_instrument_after assert op in ('fire_append_event', 'fire_remove_event') after = op if before: methods[name] = before + (after, ) elif after: methods[name] = None, None, after return roles, methods def _setup_canned_roles(cls, roles, methods): """see if this class has "canned" roles based on a known collection type (dict, set, list). Apply those roles as needed to the "roles" dictionary, and also prepare "decorator" methods """ collection_type = util.duck_type_collection(cls) if collection_type in __interfaces: canned_roles, decorators = __interfaces[collection_type] for role, name in canned_roles.items(): roles.setdefault(role, name) # apply ABC auto-decoration to methods that need it for method, decorator in decorators.items(): fn = getattr(cls, method, None) if (fn and method not in methods and not hasattr(fn, '_sa_instrumented')): setattr(cls, method, decorator(fn)) def _assert_required_roles(cls, roles, methods): """ensure all roles are present, and apply implicit instrumentation if needed """ if 'appender' not in roles or not hasattr(cls, roles['appender']): raise sa_exc.ArgumentError( "Type %s must elect an appender method to be " "a collection class" % cls.__name__) elif (roles['appender'] not in methods and not hasattr(getattr(cls, roles['appender']), '_sa_instrumented')): methods[roles['appender']] = ('fire_append_event', 1, None) if 'remover' not in roles or not hasattr(cls, roles['remover']): raise sa_exc.ArgumentError( "Type %s must elect a remover method to be " "a collection class" % cls.__name__) elif (roles['remover'] not in methods and not hasattr(getattr(cls, roles['remover']), '_sa_instrumented')): methods[roles['remover']] = ('fire_remove_event', 1, None) if 'iterator' not in roles or not hasattr(cls, roles['iterator']): raise sa_exc.ArgumentError( "Type %s must elect an iterator method to be " "a collection class" % cls.__name__) def _set_collection_attributes(cls, roles, methods): """apply ad-hoc instrumentation from decorators, class-level defaults and implicit role declarations """ for method_name, (before, argument, after) in methods.items(): setattr(cls, method_name, _instrument_membership_mutator(getattr(cls, method_name), before, argument, after)) # intern the role map for role, method_name in roles.items(): setattr(cls, '_sa_%s' % role, getattr(cls, method_name)) cls._sa_adapter = None if not hasattr(cls, '_sa_converter'): cls._sa_converter = None cls._sa_instrumented = id(cls) def _instrument_membership_mutator(method, before, argument, after): """Route method args and/or return value through the collection adapter.""" # This isn't smart enough to handle @adds(1) for 'def fn(self, (a, b))' if before: fn_args = list(util.flatten_iterator(inspect_getargspec(method)[0])) if isinstance(argument, int): pos_arg = argument named_arg = len(fn_args) > argument and fn_args[argument] or None else: if argument in fn_args: pos_arg = fn_args.index(argument) else: pos_arg = None named_arg = argument del fn_args def wrapper(*args, **kw): if before: if pos_arg is None: if named_arg not in kw: raise sa_exc.ArgumentError( "Missing argument %s" % argument) value = kw[named_arg] else: if len(args) > pos_arg: value = args[pos_arg] elif named_arg in kw: value = kw[named_arg] else: raise sa_exc.ArgumentError( "Missing argument %s" % argument) initiator = kw.pop('_sa_initiator', None) if initiator is False: executor = None else: executor = args[0]._sa_adapter if before and executor: getattr(executor, before)(value, initiator) if not after or not executor: return method(*args, **kw) else: res = method(*args, **kw) if res is not None: getattr(executor, after)(res, initiator) return res wrapper._sa_instrumented = True if hasattr(method, "_sa_instrument_role"): wrapper._sa_instrument_role = method._sa_instrument_role wrapper.__name__ = method.__name__ wrapper.__doc__ = method.__doc__ return wrapper def __set(collection, item, _sa_initiator=None): """Run set events, may eventually be inlined into decorators.""" if _sa_initiator is not False: executor = collection._sa_adapter if executor: item = executor.fire_append_event(item, _sa_initiator) return item def __del(collection, item, _sa_initiator=None): """Run del events, may eventually be inlined into decorators.""" if _sa_initiator is not False: executor = collection._sa_adapter if executor: executor.fire_remove_event(item, _sa_initiator) def __before_delete(collection, _sa_initiator=None): """Special method to run 'commit existing value' methods""" executor = collection._sa_adapter if executor: executor.fire_pre_remove_event(_sa_initiator) def _list_decorators(): """Tailored instrumentation wrappers for any list-like class.""" def _tidy(fn): fn._sa_instrumented = True fn.__doc__ = getattr(list, fn.__name__).__doc__ def append(fn): def append(self, item, _sa_initiator=None): item = __set(self, item, _sa_initiator) fn(self, item) _tidy(append) return append def remove(fn): def remove(self, value, _sa_initiator=None): __before_delete(self, _sa_initiator) # testlib.pragma exempt:__eq__ fn(self, value) __del(self, value, _sa_initiator) _tidy(remove) return remove def insert(fn): def insert(self, index, value): value = __set(self, value) fn(self, index, value) _tidy(insert) return insert def __setitem__(fn): def __setitem__(self, index, value): if not isinstance(index, slice): existing = self[index] if existing is not None: __del(self, existing) value = __set(self, value) fn(self, index, value) else: # slice assignment requires __delitem__, insert, __len__ step = index.step or 1 start = index.start or 0 if start < 0: start += len(self) if index.stop is not None: stop = index.stop else: stop = len(self) if stop < 0: stop += len(self) if step == 1: for i in range(start, stop, step): if len(self) > start: del self[start] for i, item in enumerate(value): self.insert(i + start, item) else: rng = list(range(start, stop, step)) if len(value) != len(rng): raise ValueError( "attempt to assign sequence of size %s to " "extended slice of size %s" % (len(value), len(rng))) for i, item in zip(rng, value): self.__setitem__(i, item) _tidy(__setitem__) return __setitem__ def __delitem__(fn): def __delitem__(self, index): if not isinstance(index, slice): item = self[index] __del(self, item) fn(self, index) else: # slice deletion requires __getslice__ and a slice-groking # __getitem__ for stepped deletion # note: not breaking this into atomic dels for item in self[index]: __del(self, item) fn(self, index) _tidy(__delitem__) return __delitem__ if util.py2k: def __setslice__(fn): def __setslice__(self, start, end, values): for value in self[start:end]: __del(self, value) values = [__set(self, value) for value in values] fn(self, start, end, values) _tidy(__setslice__) return __setslice__ def __delslice__(fn): def __delslice__(self, start, end): for value in self[start:end]: __del(self, value) fn(self, start, end) _tidy(__delslice__) return __delslice__ def extend(fn): def extend(self, iterable): for value in iterable: self.append(value) _tidy(extend) return extend def __iadd__(fn): def __iadd__(self, iterable): # list.__iadd__ takes any iterable and seems to let TypeError # raise as-is instead of returning NotImplemented for value in iterable: self.append(value) return self _tidy(__iadd__) return __iadd__ def pop(fn): def pop(self, index=-1): __before_delete(self) item = fn(self, index) __del(self, item) return item _tidy(pop) return pop if not util.py2k: def clear(fn): def clear(self, index=-1): for item in self: __del(self, item) fn(self) _tidy(clear) return clear # __imul__ : not wrapping this. all members of the collection are already # present, so no need to fire appends... wrapping it with an explicit # decorator is still possible, so events on *= can be had if they're # desired. hard to imagine a use case for __imul__, though. l = locals().copy() l.pop('_tidy') return l def _dict_decorators(): """Tailored instrumentation wrappers for any dict-like mapping class.""" def _tidy(fn): fn._sa_instrumented = True fn.__doc__ = getattr(dict, fn.__name__).__doc__ Unspecified = util.symbol('Unspecified') def __setitem__(fn): def __setitem__(self, key, value, _sa_initiator=None): if key in self: __del(self, self[key], _sa_initiator) value = __set(self, value, _sa_initiator) fn(self, key, value) _tidy(__setitem__) return __setitem__ def __delitem__(fn): def __delitem__(self, key, _sa_initiator=None): if key in self: __del(self, self[key], _sa_initiator) fn(self, key) _tidy(__delitem__) return __delitem__ def clear(fn): def clear(self): for key in self: __del(self, self[key]) fn(self) _tidy(clear) return clear def pop(fn): def pop(self, key, default=Unspecified): if key in self: __del(self, self[key]) if default is Unspecified: return fn(self, key) else: return fn(self, key, default) _tidy(pop) return pop def popitem(fn): def popitem(self): __before_delete(self) item = fn(self) __del(self, item[1]) return item _tidy(popitem) return popitem def setdefault(fn): def setdefault(self, key, default=None): if key not in self: self.__setitem__(key, default) return default else: return self.__getitem__(key) _tidy(setdefault) return setdefault def update(fn): def update(self, __other=Unspecified, **kw): if __other is not Unspecified: if hasattr(__other, 'keys'): for key in list(__other): if (key not in self or self[key] is not __other[key]): self[key] = __other[key] else: for key, value in __other: if key not in self or self[key] is not value: self[key] = value for key in kw: if key not in self or self[key] is not kw[key]: self[key] = kw[key] _tidy(update) return update l = locals().copy() l.pop('_tidy') l.pop('Unspecified') return l _set_binop_bases = (set, frozenset) def _set_binops_check_strict(self, obj): """Allow only set, frozenset and self.__class__-derived objects in binops.""" return isinstance(obj, _set_binop_bases + (self.__class__,)) def _set_binops_check_loose(self, obj): """Allow anything set-like to participate in set binops.""" return (isinstance(obj, _set_binop_bases + (self.__class__,)) or util.duck_type_collection(obj) == set) def _set_decorators(): """Tailored instrumentation wrappers for any set-like class.""" def _tidy(fn): fn._sa_instrumented = True fn.__doc__ = getattr(set, fn.__name__).__doc__ Unspecified = util.symbol('Unspecified') def add(fn): def add(self, value, _sa_initiator=None): if value not in self: value = __set(self, value, _sa_initiator) # testlib.pragma exempt:__hash__ fn(self, value) _tidy(add) return add def discard(fn): def discard(self, value, _sa_initiator=None): # testlib.pragma exempt:__hash__ if value in self: __del(self, value, _sa_initiator) # testlib.pragma exempt:__hash__ fn(self, value) _tidy(discard) return discard def remove(fn): def remove(self, value, _sa_initiator=None): # testlib.pragma exempt:__hash__ if value in self: __del(self, value, _sa_initiator) # testlib.pragma exempt:__hash__ fn(self, value) _tidy(remove) return remove def pop(fn): def pop(self): __before_delete(self) item = fn(self) __del(self, item) return item _tidy(pop) return pop def clear(fn): def clear(self): for item in list(self): self.remove(item) _tidy(clear) return clear def update(fn): def update(self, value): for item in value: self.add(item) _tidy(update) return update def __ior__(fn): def __ior__(self, value): if not _set_binops_check_strict(self, value): return NotImplemented for item in value: self.add(item) return self _tidy(__ior__) return __ior__ def difference_update(fn): def difference_update(self, value): for item in value: self.discard(item) _tidy(difference_update) return difference_update def __isub__(fn): def __isub__(self, value): if not _set_binops_check_strict(self, value): return NotImplemented for item in value: self.discard(item) return self _tidy(__isub__) return __isub__ def intersection_update(fn): def intersection_update(self, other): want, have = self.intersection(other), set(self) remove, add = have - want, want - have for item in remove: self.remove(item) for item in add: self.add(item) _tidy(intersection_update) return intersection_update def __iand__(fn): def __iand__(self, other): if not _set_binops_check_strict(self, other): return NotImplemented want, have = self.intersection(other), set(self) remove, add = have - want, want - have for item in remove: self.remove(item) for item in add: self.add(item) return self _tidy(__iand__) return __iand__ def symmetric_difference_update(fn): def symmetric_difference_update(self, other): want, have = self.symmetric_difference(other), set(self) remove, add = have - want, want - have for item in remove: self.remove(item) for item in add: self.add(item) _tidy(symmetric_difference_update) return symmetric_difference_update def __ixor__(fn): def __ixor__(self, other): if not _set_binops_check_strict(self, other): return NotImplemented want, have = self.symmetric_difference(other), set(self) remove, add = have - want, want - have for item in remove: self.remove(item) for item in add: self.add(item) return self _tidy(__ixor__) return __ixor__ l = locals().copy() l.pop('_tidy') l.pop('Unspecified') return l class InstrumentedList(list): """An instrumented version of the built-in list.""" class InstrumentedSet(set): """An instrumented version of the built-in set.""" class InstrumentedDict(dict): """An instrumented version of the built-in dict.""" __canned_instrumentation = { list: InstrumentedList, set: InstrumentedSet, dict: InstrumentedDict, } __interfaces = { list: ( {'appender': 'append', 'remover': 'remove', 'iterator': '__iter__'}, _list_decorators() ), set: ({'appender': 'add', 'remover': 'remove', 'iterator': '__iter__'}, _set_decorators() ), # decorators are required for dicts and object collections. dict: ({'iterator': 'values'}, _dict_decorators()) if util.py3k else ({'iterator': 'itervalues'}, _dict_decorators()), } class MappedCollection(dict): """A basic dictionary-based collection class. Extends dict with the minimal bag semantics that collection classes require. ``set`` and ``remove`` are implemented in terms of a keying function: any callable that takes an object and returns an object for use as a dictionary key. """ def __init__(self, keyfunc): """Create a new collection with keying provided by keyfunc. keyfunc may be any callable that takes an object and returns an object for use as a dictionary key. The keyfunc will be called every time the ORM needs to add a member by value-only (such as when loading instances from the database) or remove a member. The usual cautions about dictionary keying apply- ``keyfunc(object)`` should return the same output for the life of the collection. Keying based on mutable properties can result in unreachable instances "lost" in the collection. """ self.keyfunc = keyfunc @collection.appender @collection.internally_instrumented def set(self, value, _sa_initiator=None): """Add an item by value, consulting the keyfunc for the key.""" key = self.keyfunc(value) self.__setitem__(key, value, _sa_initiator) @collection.remover @collection.internally_instrumented def remove(self, value, _sa_initiator=None): """Remove an item by value, consulting the keyfunc for the key.""" key = self.keyfunc(value) # Let self[key] raise if key is not in this collection # testlib.pragma exempt:__ne__ if self[key] != value: raise sa_exc.InvalidRequestError( "Can not remove '%s': collection holds '%s' for key '%s'. " "Possible cause: is the MappedCollection key function " "based on mutable properties or properties that only obtain " "values after flush?" % (value, self[key], key)) self.__delitem__(key, _sa_initiator) @collection.converter def _convert(self, dictlike): """Validate and convert a dict-like object into values for set()ing. This is called behind the scenes when a MappedCollection is replaced entirely by another collection, as in:: myobj.mappedcollection = {'a':obj1, 'b': obj2} # ... Raises a TypeError if the key in any (key, value) pair in the dictlike object does not match the key that this collection's keyfunc would have assigned for that value. """ for incoming_key, value in util.dictlike_iteritems(dictlike): new_key = self.keyfunc(value) if incoming_key != new_key: raise TypeError( "Found incompatible key %r for value %r; this " "collection's " "keying function requires a key of %r for this value." % ( incoming_key, value, new_key)) yield value # ensure instrumentation is associated with # these built-in classes; if a user-defined class # subclasses these and uses @internally_instrumented, # the superclass is otherwise not instrumented. # see [ticket:2406]. _instrument_class(MappedCollection) _instrument_class(InstrumentedList) _instrument_class(InstrumentedSet)
bsd-3-clause
[ 3, 9813, 15, 7882, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 9261, 314, 14303, 11462, 436, 8417, 199, 3, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 624, 11532, 367, 5055, 402, 9994, 9045, 14, 199, 199, 1918, 5055, 2559, 4973, 6528, 314, 28540, 1202, 370, 315, 964, 314, 23383, 402, 199, 3627, 14616, 4493, 14, 221, 1626, 14498, 425, 4799, 5509, 425, 18140, 365, 199, 2972, 12, 17266, 9697, 2943, 334, 15768, 6137, 13, 3617, 9, 370, 506, 1202, 465, 4642, 199, 7882, 1928, 29963, 15433, 687, 282, 1300, 1021, 14, 199, 199, 14915, 425, 5509, 425, 295, 9316, 14616, 1570, 4474, 370, 314, 199, 26, 533, 5026, 7768, 1646, 4748, 64, 626, 365, 5544, 28453, 314, 3245, 14, 199, 1918, 20419, 2607, 4909, 805, 1240, 2368, 436, 372, 1338, 12, 15161, 199, 8327, 9509, 316, 503, 23188, 314, 3245, 14, 221, 16853, 7531, 18140, 397, 787, 199, 16929, 14, 221, 7309, 365, 282, 8844, 402, 7809, 20419, 626, 2341, 805, 2368, 199, 460, 372, 1338, 370, 4474, 447, 819, 687, 8335, 14, 1025, 14, 7882, 492, 3245, 523, 1021, 4932, 2543, 8, 785, 304, 489, 327, 2263, 2541, 768, 3627, 14, 525, 83, 8, 17, 9, 489, 347, 3877, 8, 277, 12, 1242, 304, 881, 291, 14, 576, 14, 740, 8, 1053, 9, 2541, 768, 3627, 14, 264, 4912, 63, 1107, 342, 489, 347, 4560, 8, 277, 304, 881, 372, 291, 14, 576, 14, 1935, 342, 421, 199, 1918, 3499, 18140, 365, 282, 8844, 402, 307, 20174, 20419, 626, 4816, 5827, 199, 740, 436, 2813, 949, 1428, 1192, 6818, 314, 31083, 3102, 3451, 315, 314, 199, 6807, 2018, 1124, 513, 4542, 1124, 409, 1040, 436, 1124, 807, 1040, 8386, 14, 221, 5723, 4293, 506, 199, 10085, 315, 2895, 402, 7809, 7531, 17121, 83, 12, 1325, 787, 3140, 4926, 13, 7354, 1146, 199, 509, 10035, 11185, 25978, 14, 221, 710, 307, 20174, 20419, 14706, 305, 1636, 1183, 5669, 199, 10394, 13, 2930, 5953, 12, 4066, 465, 4412, 13137, 13, 409, 3102, 15693, 2880, 4542, 199, 1040, 873, 4542, 9035, 2193, 3037, 363, 4542, 5423, 4959, 1901, 314, 6779, 402, 15374, 31083, 4474, 199, 9099, 314, 23383, 5074, 14, 199, 199, 1918, 307, 20174, 20419, 787, 1202, 14448, 367, 4834, 14498, 425, 402, 199, 4502, 3245, 3992, 14, 221, 18414, 3245, 1021, 13538, 4012, 282, 199, 31400, 2112, 28568, 590, 2839, 880, 26, 199, 199, 17, 14, 982, 314, 1021, 365, 282, 6137, 13, 262, 12, 23080, 282, 28586, 1007, 13, 533, 199, 18, 14, 6596, 642, 1021, 2575, 18885, 12546, 31, 199, 19, 14, 2654, 315, 7809, 20419, 199, 20, 14, 428, 8445, 556, 734, 314, 3245, 3217, 4012, 366, 10112, 13, 29747, 199, 21, 14, 2654, 307, 20174, 5509, 425, 370, 1263, 625, 29299, 3217, 1083, 199, 199, 2765, 2112, 26473, 314, 1021, 737, 8836, 12, 5509, 1958, 3102, 436, 7791, 2005, 199, 2706, 3250, 316, 4382, 14, 221, 961, 5712, 1133, 3962, 334, 269, 477, 338, 6842, 9, 367, 6137, 13, 262, 199, 2888, 2839, 1124, 513, 4542, 880, 28586, 1007, 13, 2888, 787, 10004, 4241, 370, 10266, 199, 6518, 425, 447, 819, 1021, 1010, 495, 12546, 1296, 8, 513, 304, 489, 986, 199, 199, 7768, 3992, 883, 506, 2013, 315, 1124, 11704, 8, 3627, 63, 533, 29, 9719, 465, 199, 1313, 503, 282, 805, 626, 2529, 376, 1256, 14, 221, 18003, 3992, 787, 199, 3617, 1043, 436, 18885, 12546, 5309, 314, 7796, 18653, 7669, 14, 221, 710, 199, 3627, 63, 533, 4550, 911, 506, 7934, 5403, 370, 7389, 282, 1106, 1410, 199, 842, 12, 436, 314, 730, 402, 626, 1106, 1410, 911, 506, 18885, 12546, 14, 221, 17471, 626, 199, 1107, 6137, 13, 262, 2943, 2839, 1124, 6717, 1040, 911, 506, 26266, 370, 7389, 18885, 12546, 199, 5990, 14, 199, 199, 11423, 2178, 1098, 282, 6040, 730, 2839, 1124, 513, 4542, 4722, 5509, 1298, 787, 440, 199, 2038, 1183, 440, 4346, 14, 221, 593, 617, 83, 787, 12, 314, 3329, 1083, 911, 13080, 370, 282, 199, 765, 626, 1159, 2575, 18885, 12546, 14, 221, 2104, 2893, 447, 819, 1021, 10703, 41, 609, 8, 513, 304, 1362, 347, 6675, 8, 277, 12, 1242, 304, 268, 291, 14, 740, 8, 1053, 9, 1362, 347, 7706, 8, 277, 304, 268, 372, 291, 14, 1935, 8, 16, 9, 199, 199, 10924, 1159, 949, 1929, 370, 24774, 3520, 3102, 14, 221, 1124, 740, 1040, 436, 1124, 1935, 1040, 787, 2575, 199, 21309, 12546, 465, 1777, 402, 314, 1124, 513, 1040, 3217, 14, 221, 13966, 269, 1958, 3062, 3955, 8344, 199, 11081, 4474, 12, 1314, 1077, 506, 2289, 16142, 770, 14, 199, 199, 1918, 307, 20174, 5509, 425, 11275, 440, 370, 19687, 641, 1163, 3102, 315, 314, 8793, 199, 3627, 1021, 12, 1325, 2005, 787, 625, 27403, 461, 14, 221, 15517, 11687, 641, 283, 739, 7, 3102, 199, 1235, 316, 3451, 370, 7684, 14498, 282, 283, 952, 297, 367, 2893, 12, 9035, 8617, 18762, 199, 10065, 9035, 6095, 363, 4345, 221, 298, 26033, 2, 3102, 2839, 1124, 873, 1040, 436, 1124, 2880, 1040, 1443, 2597, 199, 264, 13825, 315, 2895, 402, 15374, 1145, 3198, 436, 14185, 12, 880, 314, 1124, 2880, 1040, 199, 6518, 425, 911, 5965, 5147, 5002, 1124, 740, 1040, 5331, 436, 440, 1240, 314, 199, 7138, 6670, 1083, 737, 1006, 14, 199, 199, 52, 1070, 3304, 1806, 13137, 3439, 436, 314, 289, 16648, 402, 4474, 365, 2597, 3962, 701, 199, 21463, 316, 314, 14498, 425, 14448, 315, 2195, 3102, 14, 221, 710, 5678, 199, 13321, 425, 2559, 5419, 1334, 314, 8605, 30075, 626, 3245, 199, 11627, 911, 440, 746, 625, 527, 1061, 4967, 14, 221, 982, 1265, 2934, 370, 4002, 590, 199, 269, 595, 18161, 5666, 436, 2813, 4474, 543, 1919, 10041, 12, 5007, 199, 13321, 425, 1443, 506, 314, 6385, 14, 221, 8777, 262, 2195, 1083, 12, 199, 1040, 3627, 63, 10394, 8, 277, 9719, 911, 8044, 376, 909, 626, 1265, 883, 675, 367, 199, 10306, 3304, 1806, 6804, 316, 5666, 436, 2813, 4474, 14 ]
[ 9813, 15, 7882, 14, 647, 199, 3, 1898, 334, 35, 9, 11811, 13, 9261, 314, 14303, 11462, 436, 8417, 199, 3, 665, 3239, 10610, 570, 30, 199, 3, 199, 3, 961, 859, 365, 1777, 402, 14303, 436, 365, 14286, 1334, 199, 3, 314, 10697, 844, 26, 1455, 921, 1544, 14, 16374, 14, 1308, 15, 2383, 15, 1147, 13, 1682, 14, 8624, 199, 199, 624, 11532, 367, 5055, 402, 9994, 9045, 14, 199, 199, 1918, 5055, 2559, 4973, 6528, 314, 28540, 1202, 370, 315, 964, 314, 23383, 402, 199, 3627, 14616, 4493, 14, 221, 1626, 14498, 425, 4799, 5509, 425, 18140, 365, 199, 2972, 12, 17266, 9697, 2943, 334, 15768, 6137, 13, 3617, 9, 370, 506, 1202, 465, 4642, 199, 7882, 1928, 29963, 15433, 687, 282, 1300, 1021, 14, 199, 199, 14915, 425, 5509, 425, 295, 9316, 14616, 1570, 4474, 370, 314, 199, 26, 533, 5026, 7768, 1646, 4748, 64, 626, 365, 5544, 28453, 314, 3245, 14, 199, 1918, 20419, 2607, 4909, 805, 1240, 2368, 436, 372, 1338, 12, 15161, 199, 8327, 9509, 316, 503, 23188, 314, 3245, 14, 221, 16853, 7531, 18140, 397, 787, 199, 16929, 14, 221, 7309, 365, 282, 8844, 402, 7809, 20419, 626, 2341, 805, 2368, 199, 460, 372, 1338, 370, 4474, 447, 819, 687, 8335, 14, 1025, 14, 7882, 492, 3245, 523, 1021, 4932, 2543, 8, 785, 304, 489, 327, 2263, 2541, 768, 3627, 14, 525, 83, 8, 17, 9, 489, 347, 3877, 8, 277, 12, 1242, 304, 881, 291, 14, 576, 14, 740, 8, 1053, 9, 2541, 768, 3627, 14, 264, 4912, 63, 1107, 342, 489, 347, 4560, 8, 277, 304, 881, 372, 291, 14, 576, 14, 1935, 342, 421, 199, 1918, 3499, 18140, 365, 282, 8844, 402, 307, 20174, 20419, 626, 4816, 5827, 199, 740, 436, 2813, 949, 1428, 1192, 6818, 314, 31083, 3102, 3451, 315, 314, 199, 6807, 2018, 1124, 513, 4542, 1124, 409, 1040, 436, 1124, 807, 1040, 8386, 14, 221, 5723, 4293, 506, 199, 10085, 315, 2895, 402, 7809, 7531, 17121, 83, 12, 1325, 787, 3140, 4926, 13, 7354, 1146, 199, 509, 10035, 11185, 25978, 14, 221, 710, 307, 20174, 20419, 14706, 305, 1636, 1183, 5669, 199, 10394, 13, 2930, 5953, 12, 4066, 465, 4412, 13137, 13, 409, 3102, 15693, 2880, 4542, 199, 1040, 873, 4542, 9035, 2193, 3037, 363, 4542, 5423, 4959, 1901, 314, 6779, 402, 15374, 31083, 4474, 199, 9099, 314, 23383, 5074, 14, 199, 199, 1918, 307, 20174, 20419, 787, 1202, 14448, 367, 4834, 14498, 425, 402, 199, 4502, 3245, 3992, 14, 221, 18414, 3245, 1021, 13538, 4012, 282, 199, 31400, 2112, 28568, 590, 2839, 880, 26, 199, 199, 17, 14, 982, 314, 1021, 365, 282, 6137, 13, 262, 12, 23080, 282, 28586, 1007, 13, 533, 199, 18, 14, 6596, 642, 1021, 2575, 18885, 12546, 31, 199, 19, 14, 2654, 315, 7809, 20419, 199, 20, 14, 428, 8445, 556, 734, 314, 3245, 3217, 4012, 366, 10112, 13, 29747, 199, 21, 14, 2654, 307, 20174, 5509, 425, 370, 1263, 625, 29299, 3217, 1083, 199, 199, 2765, 2112, 26473, 314, 1021, 737, 8836, 12, 5509, 1958, 3102, 436, 7791, 2005, 199, 2706, 3250, 316, 4382, 14, 221, 961, 5712, 1133, 3962, 334, 269, 477, 338, 6842, 9, 367, 6137, 13, 262, 199, 2888, 2839, 1124, 513, 4542, 880, 28586, 1007, 13, 2888, 787, 10004, 4241, 370, 10266, 199, 6518, 425, 447, 819, 1021, 1010, 495, 12546, 1296, 8, 513, 304, 489, 986, 199, 199, 7768, 3992, 883, 506, 2013, 315, 1124, 11704, 8, 3627, 63, 533, 29, 9719, 465, 199, 1313, 503, 282, 805, 626, 2529, 376, 1256, 14, 221, 18003, 3992, 787, 199, 3617, 1043, 436, 18885, 12546, 5309, 314, 7796, 18653, 7669, 14, 221, 710, 199, 3627, 63, 533, 4550, 911, 506, 7934, 5403, 370, 7389, 282, 1106, 1410, 199, 842, 12, 436, 314, 730, 402, 626, 1106, 1410, 911, 506, 18885, 12546, 14, 221, 17471, 626, 199, 1107, 6137, 13, 262, 2943, 2839, 1124, 6717, 1040, 911, 506, 26266, 370, 7389, 18885, 12546, 199, 5990, 14, 199, 199, 11423, 2178, 1098, 282, 6040, 730, 2839, 1124, 513, 4542, 4722, 5509, 1298, 787, 440, 199, 2038, 1183, 440, 4346, 14, 221, 593, 617, 83, 787, 12, 314, 3329, 1083, 911, 13080, 370, 282, 199, 765, 626, 1159, 2575, 18885, 12546, 14, 221, 2104, 2893, 447, 819, 1021, 10703, 41, 609, 8, 513, 304, 1362, 347, 6675, 8, 277, 12, 1242, 304, 268, 291, 14, 740, 8, 1053, 9, 1362, 347, 7706, 8, 277, 304, 268, 372, 291, 14, 1935, 8, 16, 9, 199, 199, 10924, 1159, 949, 1929, 370, 24774, 3520, 3102, 14, 221, 1124, 740, 1040, 436, 1124, 1935, 1040, 787, 2575, 199, 21309, 12546, 465, 1777, 402, 314, 1124, 513, 1040, 3217, 14, 221, 13966, 269, 1958, 3062, 3955, 8344, 199, 11081, 4474, 12, 1314, 1077, 506, 2289, 16142, 770, 14, 199, 199, 1918, 307, 20174, 5509, 425, 11275, 440, 370, 19687, 641, 1163, 3102, 315, 314, 8793, 199, 3627, 1021, 12, 1325, 2005, 787, 625, 27403, 461, 14, 221, 15517, 11687, 641, 283, 739, 7, 3102, 199, 1235, 316, 3451, 370, 7684, 14498, 282, 283, 952, 297, 367, 2893, 12, 9035, 8617, 18762, 199, 10065, 9035, 6095, 363, 4345, 221, 298, 26033, 2, 3102, 2839, 1124, 873, 1040, 436, 1124, 2880, 1040, 1443, 2597, 199, 264, 13825, 315, 2895, 402, 15374, 1145, 3198, 436, 14185, 12, 880, 314, 1124, 2880, 1040, 199, 6518, 425, 911, 5965, 5147, 5002, 1124, 740, 1040, 5331, 436, 440, 1240, 314, 199, 7138, 6670, 1083, 737, 1006, 14, 199, 199, 52, 1070, 3304, 1806, 13137, 3439, 436, 314, 289, 16648, 402, 4474, 365, 2597, 3962, 701, 199, 21463, 316, 314, 14498, 425, 14448, 315, 2195, 3102, 14, 221, 710, 5678, 199, 13321, 425, 2559, 5419, 1334, 314, 8605, 30075, 626, 3245, 199, 11627, 911, 440, 746, 625, 527, 1061, 4967, 14, 221, 982, 1265, 2934, 370, 4002, 590, 199, 269, 595, 18161, 5666, 436, 2813, 4474, 543, 1919, 10041, 12, 5007, 199, 13321, 425, 1443, 506, 314, 6385, 14, 221, 8777, 262, 2195, 1083, 12, 199, 1040, 3627, 63, 10394, 8, 277, 9719, 911, 8044, 376, 909, 626, 1265, 883, 675, 367, 199, 10306, 3304, 1806, 6804, 316, 5666, 436, 2813, 4474, 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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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 ]
djdduty/mongo
marrow/mongo/core/field.py
1
2849
# encoding: utf-8 from inspect import isroutine from marrow.schema import Attribute from marrow.schema.transform import BaseTransform from marrow.schema.validate import Validator from ..query import Queryable from ..util import adjust_attribute_sequence from ..util.compat import py3 @adjust_attribute_sequence(1000, 'transformer', 'validator', 'translated', 'generated') class Field(Attribute, Queryable): # Possible values include a literal operator, or one of: # * #rel -- allow/prevent all relative comparison such as $gt, $gte, $lt, etc. # * #array -- allow/prevent all array-related compraison such as $all, $size, etc. # * #document -- allow/prevent all document-related comparison such as $elemMatch. __allowed_operators__ = set() __disallowed_operators__ = set() choices = Attribute(default=None) required = Attribute(default=False) # Must have value assigned; None and an empty string are values. nullable = Attribute(default=False) # If True, will store None. If False, will store non-None default, or not store. project = Attribute(default=None) transformer = Attribute(default=BaseTransform()) validator = Attribute(default=Validator()) translated = Attribute(default=False) # If truthy this field should be stored in the per-language subdocument. generated = Attribute(default=False) # If truthy attempt to access and store resulting variable when instantiated. # Descriptor Protocol def __get__(self, obj, cls=None): """Executed when retrieving a Field instance attribute.""" # If this is class attribute (and not instance attribute) access, we return ourselves. if obj is None: return self # Attempt to retrieve the data from the warehouse. try: return super(Attribute, self).__get__(obj, cls) except AttributeError: pass # Attempt to utilize the defined default value. try: default = self.default except AttributeError: pass else: # Process and optionally store the default value. value = default() if isroutine(default) else default if self.generated: self.__set__(obj, value) return value # If we still don't have a value, this attribute doesn't yet exist. raise AttributeError('\'{0}\' object has no attribute \'{1}\''.format( obj.__class__.__name__, self.__name__ )) def __set__(self, obj, value): """Executed when assigning a value to a DataAttribute instance attribute.""" # Simply store the value in the warehouse. obj.__data__[self.__name__] = value def __delete__(self, obj): """Executed via the ``del`` statement with a DataAttribute instance attribute as the argument.""" # Delete the data completely from the warehouse. del obj.__data__[self.__name__] # Other Python Protocols def __unicode__(self): return self.__name__ if py3: __str__ = __unicode__ del __unicode__
mit
[ 3, 2644, 26, 2774, 13, 24, 199, 199, 504, 6485, 492, 365, 17765, 199, 504, 7557, 1143, 14, 3629, 492, 3882, 199, 504, 7557, 1143, 14, 3629, 14, 4711, 492, 3523, 6939, 199, 504, 7557, 1143, 14, 3629, 14, 3502, 492, 4821, 707, 199, 199, 504, 2508, 1131, 492, 8133, 461, 199, 504, 2508, 1974, 492, 11311, 63, 3215, 63, 4041, 199, 504, 2508, 1974, 14, 5819, 492, 1134, 19, 421, 199, 32, 10917, 63, 3215, 63, 4041, 8, 5279, 12, 283, 19754, 297, 283, 11034, 297, 283, 18065, 297, 283, 10176, 358, 199, 533, 5024, 8, 1646, 12, 8133, 461, 304, 199, 198, 3, 18558, 1338, 2387, 282, 8785, 4182, 12, 503, 1373, 402, 26, 199, 198, 3, 221, 627, 327, 3369, 1553, 2040, 15, 657, 782, 1006, 3847, 9132, 4066, 465, 2672, 3308, 12, 2672, 19586, 12, 2672, 4116, 12, 5423, 14, 199, 198, 3, 221, 627, 327, 1144, 1553, 2040, 15, 657, 782, 1006, 1625, 13, 2407, 1013, 345, 28287, 4066, 465, 2672, 452, 12, 2672, 890, 12, 5423, 14, 199, 198, 3, 221, 627, 327, 3554, 1553, 2040, 15, 657, 782, 1006, 2213, 13, 2407, 9132, 4066, 465, 2672, 6086, 4486, 14, 199, 198, 363, 6541, 63, 12688, 363, 275, 663, 342, 199, 198, 363, 2297, 6541, 63, 12688, 363, 275, 663, 342, 8299, 198, 4577, 275, 3882, 8, 885, 29, 403, 9, 199, 198, 2427, 275, 3882, 8, 885, 29, 797, 9, 221, 327, 9498, 1172, 574, 7943, 27, 488, 436, 376, 2701, 1059, 787, 1338, 14, 199, 198, 16375, 275, 3882, 8, 885, 29, 797, 9, 221, 327, 982, 715, 12, 911, 3877, 488, 14, 221, 982, 756, 12, 911, 3877, 2222, 13, 403, 849, 12, 503, 440, 3877, 14, 8299, 198, 1715, 275, 3882, 8, 885, 29, 403, 9, 199, 198, 19754, 275, 3882, 8, 885, 29, 1563, 6939, 1012, 199, 198, 11034, 275, 3882, 8, 885, 29, 8640, 1012, 199, 198, 18065, 275, 3882, 8, 885, 29, 797, 9, 221, 327, 982, 16865, 89, 642, 901, 1077, 506, 5489, 315, 314, 1126, 13, 3671, 1007, 3554, 14, 199, 198, 10176, 275, 3882, 8, 885, 29, 797, 9, 221, 327, 982, 16865, 89, 7427, 370, 2879, 436, 3877, 9183, 1750, 1380, 17544, 14, 8299, 198, 3, 28131, 11557, 8299, 198, 318, 636, 362, 721, 277, 12, 1559, 12, 843, 29, 403, 304, 507, 198, 624, 4858, 4241, 1380, 23812, 282, 5024, 1256, 2225, 1041, 9068, 198, 3, 982, 642, 365, 1021, 2225, 334, 460, 440, 1256, 2225, 9, 2879, 12, 781, 372, 26495, 14, 507, 198, 692, 1559, 365, 488, 26, 686, 198, 1107, 291, 9068, 198, 3, 23115, 370, 8044, 314, 666, 687, 314, 13782, 14, 507, 198, 893, 26, 686, 198, 1107, 1613, 8, 1646, 12, 291, 2843, 362, 721, 1113, 12, 843, 9, 507, 198, 2590, 4281, 26, 686, 198, 1529, 9068, 198, 3, 23115, 370, 7678, 13559, 314, 3247, 849, 574, 14, 507, 198, 893, 26, 686, 198, 885, 275, 291, 14, 885, 507, 198, 2590, 4281, 26, 686, 198, 1529, 507, 198, 2836, 26, 686, 198, 3, 7132, 436, 14190, 3877, 314, 849, 574, 14, 686, 198, 585, 275, 849, 342, 340, 365, 17765, 8, 885, 9, 587, 849, 686, 198, 692, 291, 14, 10176, 26, 1585, 198, 277, 855, 409, 721, 1113, 12, 574, 9, 686, 198, 1107, 574, 9068, 198, 3, 982, 781, 5139, 2793, 1133, 1172, 282, 574, 12, 642, 2225, 3181, 1133, 5966, 2187, 14, 507, 198, 3730, 4281, 2258, 16019, 16, 93, 3985, 909, 965, 949, 2225, 8891, 91, 17, 4988, 17067, 908, 8, 1585, 198, 1113, 855, 533, 4914, 354, 3108, 1585, 198, 277, 855, 354, 363, 686, 198, 430, 8299, 198, 318, 636, 409, 721, 277, 12, 1559, 12, 574, 304, 507, 198, 624, 4858, 4241, 1380, 26694, 282, 574, 370, 282, 3918, 1646, 1256, 2225, 1041, 9068, 198, 3, 29094, 590, 3877, 314, 574, 315, 314, 13782, 14, 507, 198, 1113, 855, 576, 12298, 277, 855, 354, 22705, 275, 574, 8299, 198, 318, 636, 1807, 721, 277, 12, 1559, 304, 507, 198, 624, 4858, 4241, 4799, 314, 1124, 2264, 1040, 5164, 543, 282, 3918, 1646, 1256, 2225, 465, 314, 1423, 1041, 9068, 198, 3, 8496, 314, 666, 14793, 687, 314, 13782, 14, 507, 198, 2264, 1559, 855, 576, 12298, 277, 855, 354, 22705, 8299, 198, 3, 5439, 2018, 2165, 475, 4574, 8299, 198, 318, 636, 2975, 721, 277, 304, 507, 198, 1107, 291, 855, 354, 363, 8299, 198, 692, 1134, 19, 26, 507, 198, 363, 495, 363, 275, 636, 2975, 363, 507, 198, 2264, 636, 2975, 363, 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 ]
[ 2644, 26, 2774, 13, 24, 199, 199, 504, 6485, 492, 365, 17765, 199, 504, 7557, 1143, 14, 3629, 492, 3882, 199, 504, 7557, 1143, 14, 3629, 14, 4711, 492, 3523, 6939, 199, 504, 7557, 1143, 14, 3629, 14, 3502, 492, 4821, 707, 199, 199, 504, 2508, 1131, 492, 8133, 461, 199, 504, 2508, 1974, 492, 11311, 63, 3215, 63, 4041, 199, 504, 2508, 1974, 14, 5819, 492, 1134, 19, 421, 199, 32, 10917, 63, 3215, 63, 4041, 8, 5279, 12, 283, 19754, 297, 283, 11034, 297, 283, 18065, 297, 283, 10176, 358, 199, 533, 5024, 8, 1646, 12, 8133, 461, 304, 199, 198, 3, 18558, 1338, 2387, 282, 8785, 4182, 12, 503, 1373, 402, 26, 199, 198, 3, 221, 627, 327, 3369, 1553, 2040, 15, 657, 782, 1006, 3847, 9132, 4066, 465, 2672, 3308, 12, 2672, 19586, 12, 2672, 4116, 12, 5423, 14, 199, 198, 3, 221, 627, 327, 1144, 1553, 2040, 15, 657, 782, 1006, 1625, 13, 2407, 1013, 345, 28287, 4066, 465, 2672, 452, 12, 2672, 890, 12, 5423, 14, 199, 198, 3, 221, 627, 327, 3554, 1553, 2040, 15, 657, 782, 1006, 2213, 13, 2407, 9132, 4066, 465, 2672, 6086, 4486, 14, 199, 198, 363, 6541, 63, 12688, 363, 275, 663, 342, 199, 198, 363, 2297, 6541, 63, 12688, 363, 275, 663, 342, 8299, 198, 4577, 275, 3882, 8, 885, 29, 403, 9, 199, 198, 2427, 275, 3882, 8, 885, 29, 797, 9, 221, 327, 9498, 1172, 574, 7943, 27, 488, 436, 376, 2701, 1059, 787, 1338, 14, 199, 198, 16375, 275, 3882, 8, 885, 29, 797, 9, 221, 327, 982, 715, 12, 911, 3877, 488, 14, 221, 982, 756, 12, 911, 3877, 2222, 13, 403, 849, 12, 503, 440, 3877, 14, 8299, 198, 1715, 275, 3882, 8, 885, 29, 403, 9, 199, 198, 19754, 275, 3882, 8, 885, 29, 1563, 6939, 1012, 199, 198, 11034, 275, 3882, 8, 885, 29, 8640, 1012, 199, 198, 18065, 275, 3882, 8, 885, 29, 797, 9, 221, 327, 982, 16865, 89, 642, 901, 1077, 506, 5489, 315, 314, 1126, 13, 3671, 1007, 3554, 14, 199, 198, 10176, 275, 3882, 8, 885, 29, 797, 9, 221, 327, 982, 16865, 89, 7427, 370, 2879, 436, 3877, 9183, 1750, 1380, 17544, 14, 8299, 198, 3, 28131, 11557, 8299, 198, 318, 636, 362, 721, 277, 12, 1559, 12, 843, 29, 403, 304, 507, 198, 624, 4858, 4241, 1380, 23812, 282, 5024, 1256, 2225, 1041, 9068, 198, 3, 982, 642, 365, 1021, 2225, 334, 460, 440, 1256, 2225, 9, 2879, 12, 781, 372, 26495, 14, 507, 198, 692, 1559, 365, 488, 26, 686, 198, 1107, 291, 9068, 198, 3, 23115, 370, 8044, 314, 666, 687, 314, 13782, 14, 507, 198, 893, 26, 686, 198, 1107, 1613, 8, 1646, 12, 291, 2843, 362, 721, 1113, 12, 843, 9, 507, 198, 2590, 4281, 26, 686, 198, 1529, 9068, 198, 3, 23115, 370, 7678, 13559, 314, 3247, 849, 574, 14, 507, 198, 893, 26, 686, 198, 885, 275, 291, 14, 885, 507, 198, 2590, 4281, 26, 686, 198, 1529, 507, 198, 2836, 26, 686, 198, 3, 7132, 436, 14190, 3877, 314, 849, 574, 14, 686, 198, 585, 275, 849, 342, 340, 365, 17765, 8, 885, 9, 587, 849, 686, 198, 692, 291, 14, 10176, 26, 1585, 198, 277, 855, 409, 721, 1113, 12, 574, 9, 686, 198, 1107, 574, 9068, 198, 3, 982, 781, 5139, 2793, 1133, 1172, 282, 574, 12, 642, 2225, 3181, 1133, 5966, 2187, 14, 507, 198, 3730, 4281, 2258, 16019, 16, 93, 3985, 909, 965, 949, 2225, 8891, 91, 17, 4988, 17067, 908, 8, 1585, 198, 1113, 855, 533, 4914, 354, 3108, 1585, 198, 277, 855, 354, 363, 686, 198, 430, 8299, 198, 318, 636, 409, 721, 277, 12, 1559, 12, 574, 304, 507, 198, 624, 4858, 4241, 1380, 26694, 282, 574, 370, 282, 3918, 1646, 1256, 2225, 1041, 9068, 198, 3, 29094, 590, 3877, 314, 574, 315, 314, 13782, 14, 507, 198, 1113, 855, 576, 12298, 277, 855, 354, 22705, 275, 574, 8299, 198, 318, 636, 1807, 721, 277, 12, 1559, 304, 507, 198, 624, 4858, 4241, 4799, 314, 1124, 2264, 1040, 5164, 543, 282, 3918, 1646, 1256, 2225, 465, 314, 1423, 1041, 9068, 198, 3, 8496, 314, 666, 14793, 687, 314, 13782, 14, 507, 198, 2264, 1559, 855, 576, 12298, 277, 855, 354, 22705, 8299, 198, 3, 5439, 2018, 2165, 475, 4574, 8299, 198, 318, 636, 2975, 721, 277, 304, 507, 198, 1107, 291, 855, 354, 363, 8299, 198, 692, 1134, 19, 26, 507, 198, 363, 495, 363, 275, 636, 2975, 363, 507, 198, 2264, 636, 2975, 363, 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, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
shiblon/pytour
static/js/pypyjs/pypy-nojit.js-0.3.1/lib/modules/test/test_deque.py
8
25614
from collections import deque import unittest from test import test_support, seq_tests import gc import weakref import copy import cPickle as pickle import random import struct BIG = 100000 def fail(): raise SyntaxError yield 1 class BadCmp: def __eq__(self, other): raise RuntimeError class MutateCmp: def __init__(self, deque, result): self.deque = deque self.result = result def __eq__(self, other): self.deque.clear() return self.result class TestBasic(unittest.TestCase): def test_basics(self): d = deque(xrange(-5125, -5000)) d.__init__(xrange(200)) for i in xrange(200, 400): d.append(i) for i in reversed(xrange(-200, 0)): d.appendleft(i) self.assertEqual(list(d), range(-200, 400)) self.assertEqual(len(d), 600) left = [d.popleft() for i in xrange(250)] self.assertEqual(left, range(-200, 50)) self.assertEqual(list(d), range(50, 400)) right = [d.pop() for i in xrange(250)] right.reverse() self.assertEqual(right, range(150, 400)) self.assertEqual(list(d), range(50, 150)) def test_maxlen(self): self.assertRaises(ValueError, deque, 'abc', -1) self.assertRaises(ValueError, deque, 'abc', -2) it = iter(range(10)) d = deque(it, maxlen=3) self.assertEqual(list(it), []) self.assertEqual(repr(d), 'deque([7, 8, 9], maxlen=3)') self.assertEqual(list(d), range(7, 10)) self.assertEqual(d, deque(range(10), 3)) d.append(10) self.assertEqual(list(d), range(8, 11)) d.appendleft(7) self.assertEqual(list(d), range(7, 10)) d.extend([10, 11]) self.assertEqual(list(d), range(9, 12)) d.extendleft([8, 7]) self.assertEqual(list(d), range(7, 10)) d = deque(xrange(200), maxlen=10) d.append(d) test_support.unlink(test_support.TESTFN) fo = open(test_support.TESTFN, "wb") try: print >> fo, d, fo.close() fo = open(test_support.TESTFN, "rb") self.assertEqual(fo.read(), repr(d)) finally: fo.close() test_support.unlink(test_support.TESTFN) d = deque(range(10), maxlen=None) self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])') fo = open(test_support.TESTFN, "wb") try: print >> fo, d, fo.close() fo = open(test_support.TESTFN, "rb") self.assertEqual(fo.read(), repr(d)) finally: fo.close() test_support.unlink(test_support.TESTFN) def test_maxlen_zero(self): it = iter(range(100)) deque(it, maxlen=0) self.assertEqual(list(it), []) it = iter(range(100)) d = deque(maxlen=0) d.extend(it) self.assertEqual(list(it), []) it = iter(range(100)) d = deque(maxlen=0) d.extendleft(it) self.assertEqual(list(it), []) def test_maxlen_attribute(self): self.assertEqual(deque().maxlen, None) self.assertEqual(deque('abc').maxlen, None) self.assertEqual(deque('abc', maxlen=4).maxlen, 4) self.assertEqual(deque('abc', maxlen=2).maxlen, 2) self.assertEqual(deque('abc', maxlen=0).maxlen, 0) with self.assertRaises((AttributeError, TypeError)): d = deque('abc') d.maxlen = 10 def test_count(self): for s in ('', 'abracadabra', 'simsalabim'*500+'abc'): s = list(s) d = deque(s) for letter in 'abcdefghijklmnopqrstuvwxyz': self.assertEqual(s.count(letter), d.count(letter), (s, d, letter)) self.assertRaises(TypeError, d.count) # too few args self.assertRaises(TypeError, d.count, 1, 2) # too many args class BadCompare: def __eq__(self, other): raise ArithmeticError d = deque([1, 2, BadCompare(), 3]) self.assertRaises(ArithmeticError, d.count, 2) d = deque([1, 2, 3]) self.assertRaises(ArithmeticError, d.count, BadCompare()) class MutatingCompare: def __eq__(self, other): self.d.pop() return True m = MutatingCompare() d = deque([1, 2, 3, m, 4, 5]) m.d = d self.assertRaises(RuntimeError, d.count, 3) # test issue11004 # block advance failed after rotation aligned elements on right side of block d = deque([None]*16) for i in range(len(d)): d.rotate(-1) d.rotate(1) self.assertEqual(d.count(1), 0) self.assertEqual(d.count(None), 16) def test_comparisons(self): d = deque('xabc'); d.popleft() for e in [d, deque('abc'), deque('ab'), deque(), list(d)]: self.assertEqual(d==e, type(d)==type(e) and list(d)==list(e)) self.assertEqual(d!=e, not(type(d)==type(e) and list(d)==list(e))) args = map(deque, ('', 'a', 'b', 'ab', 'ba', 'abc', 'xba', 'xabc', 'cba')) for x in args: for y in args: self.assertEqual(x == y, list(x) == list(y), (x,y)) self.assertEqual(x != y, list(x) != list(y), (x,y)) self.assertEqual(x < y, list(x) < list(y), (x,y)) self.assertEqual(x <= y, list(x) <= list(y), (x,y)) self.assertEqual(x > y, list(x) > list(y), (x,y)) self.assertEqual(x >= y, list(x) >= list(y), (x,y)) self.assertEqual(cmp(x,y), cmp(list(x),list(y)), (x,y)) def test_extend(self): d = deque('a') self.assertRaises(TypeError, d.extend, 1) d.extend('bcd') self.assertEqual(list(d), list('abcd')) d.extend(d) self.assertEqual(list(d), list('abcdabcd')) def test_iadd(self): d = deque('a') d += 'bcd' self.assertEqual(list(d), list('abcd')) d += d self.assertEqual(list(d), list('abcdabcd')) def test_extendleft(self): d = deque('a') self.assertRaises(TypeError, d.extendleft, 1) d.extendleft('bcd') self.assertEqual(list(d), list(reversed('abcd'))) d.extendleft(d) self.assertEqual(list(d), list('abcddcba')) d = deque() d.extendleft(range(1000)) self.assertEqual(list(d), list(reversed(range(1000)))) self.assertRaises(SyntaxError, d.extendleft, fail()) def test_getitem(self): n = 200 d = deque(xrange(n)) l = range(n) for i in xrange(n): d.popleft() l.pop(0) if random.random() < 0.5: d.append(i) l.append(i) for j in xrange(1-len(l), len(l)): assert d[j] == l[j] d = deque('superman') self.assertEqual(d[0], 's') self.assertEqual(d[-1], 'n') d = deque() self.assertRaises(IndexError, d.__getitem__, 0) self.assertRaises(IndexError, d.__getitem__, -1) def test_setitem(self): n = 200 d = deque(xrange(n)) for i in xrange(n): d[i] = 10 * i self.assertEqual(list(d), [10*i for i in xrange(n)]) l = list(d) for i in xrange(1-n, 0, -1): d[i] = 7*i l[i] = 7*i self.assertEqual(list(d), l) def test_delitem(self): n = 500 # O(n**2) test, don't make this too big d = deque(xrange(n)) self.assertRaises(IndexError, d.__delitem__, -n-1) self.assertRaises(IndexError, d.__delitem__, n) for i in xrange(n): self.assertEqual(len(d), n-i) j = random.randrange(-len(d), len(d)) val = d[j] self.assertIn(val, d) del d[j] self.assertNotIn(val, d) self.assertEqual(len(d), 0) def test_reverse(self): n = 500 # O(n**2) test, don't make this too big data = [random.random() for i in range(n)] for i in range(n): d = deque(data[:i]) r = d.reverse() self.assertEqual(list(d), list(reversed(data[:i]))) self.assertIs(r, None) d.reverse() self.assertEqual(list(d), data[:i]) self.assertRaises(TypeError, d.reverse, 1) # Arity is zero def test_rotate(self): s = tuple('abcde') n = len(s) d = deque(s) d.rotate(1) # verify rot(1) self.assertEqual(''.join(d), 'eabcd') d = deque(s) d.rotate(-1) # verify rot(-1) self.assertEqual(''.join(d), 'bcdea') d.rotate() # check default to 1 self.assertEqual(tuple(d), s) for i in xrange(n*3): d = deque(s) e = deque(d) d.rotate(i) # check vs. rot(1) n times for j in xrange(i): e.rotate(1) self.assertEqual(tuple(d), tuple(e)) d.rotate(-i) # check that it works in reverse self.assertEqual(tuple(d), s) e.rotate(n-i) # check that it wraps forward self.assertEqual(tuple(e), s) for i in xrange(n*3): d = deque(s) e = deque(d) d.rotate(-i) for j in xrange(i): e.rotate(-1) # check vs. rot(-1) n times self.assertEqual(tuple(d), tuple(e)) d.rotate(i) # check that it works in reverse self.assertEqual(tuple(d), s) e.rotate(i-n) # check that it wraps backaround self.assertEqual(tuple(e), s) d = deque(s) e = deque(s) e.rotate(BIG+17) # verify on long series of rotates dr = d.rotate for i in xrange(BIG+17): dr() self.assertEqual(tuple(d), tuple(e)) self.assertRaises(TypeError, d.rotate, 'x') # Wrong arg type self.assertRaises(TypeError, d.rotate, 1, 10) # Too many args d = deque() d.rotate() # rotate an empty deque self.assertEqual(d, deque()) def test_len(self): d = deque('ab') self.assertEqual(len(d), 2) d.popleft() self.assertEqual(len(d), 1) d.pop() self.assertEqual(len(d), 0) self.assertRaises(IndexError, d.pop) self.assertEqual(len(d), 0) d.append('c') self.assertEqual(len(d), 1) d.appendleft('d') self.assertEqual(len(d), 2) d.clear() self.assertEqual(len(d), 0) def test_underflow(self): d = deque() self.assertRaises(IndexError, d.pop) self.assertRaises(IndexError, d.popleft) def test_clear(self): d = deque(xrange(100)) self.assertEqual(len(d), 100) d.clear() self.assertEqual(len(d), 0) self.assertEqual(list(d), []) d.clear() # clear an emtpy deque self.assertEqual(list(d), []) def test_remove(self): d = deque('abcdefghcij') d.remove('c') self.assertEqual(d, deque('abdefghcij')) d.remove('c') self.assertEqual(d, deque('abdefghij')) self.assertRaises(ValueError, d.remove, 'c') self.assertEqual(d, deque('abdefghij')) # Handle comparison errors d = deque(['a', 'b', BadCmp(), 'c']) e = deque(d) self.assertRaises(RuntimeError, d.remove, 'c') for x, y in zip(d, e): # verify that original order and values are retained. self.assertTrue(x is y) # Handle evil mutator for match in (True, False): d = deque(['ab']) d.extend([MutateCmp(d, match), 'c']) # On CPython we get IndexError: deque mutated during remove(). # Why is it an IndexError during remove() only??? # On PyPy it is a RuntimeError, as in the other operations. self.assertRaises((IndexError, RuntimeError), d.remove, 'c') self.assertEqual(d, deque()) def test_repr(self): d = deque(xrange(200)) e = eval(repr(d)) self.assertEqual(list(d), list(e)) d.append(d) self.assertIn('...', repr(d)) def test_print(self): d = deque(xrange(200)) d.append(d) test_support.unlink(test_support.TESTFN) fo = open(test_support.TESTFN, "wb") try: print >> fo, d, fo.close() fo = open(test_support.TESTFN, "rb") self.assertEqual(fo.read(), repr(d)) finally: fo.close() test_support.unlink(test_support.TESTFN) def test_init(self): self.assertRaises(TypeError, deque, 'abc', 2, 3); self.assertRaises(TypeError, deque, 1); def test_hash(self): self.assertRaises(TypeError, hash, deque('abc')) def test_long_steadystate_queue_popleft(self): for size in (0, 1, 2, 100, 1000): d = deque(xrange(size)) append, pop = d.append, d.popleft for i in xrange(size, BIG): append(i) x = pop() if x != i - size: self.assertEqual(x, i-size) self.assertEqual(list(d), range(BIG-size, BIG)) def test_long_steadystate_queue_popright(self): for size in (0, 1, 2, 100, 1000): d = deque(reversed(xrange(size))) append, pop = d.appendleft, d.pop for i in xrange(size, BIG): append(i) x = pop() if x != i - size: self.assertEqual(x, i-size) self.assertEqual(list(reversed(list(d))), range(BIG-size, BIG)) def test_big_queue_popleft(self): pass d = deque() append, pop = d.append, d.popleft for i in xrange(BIG): append(i) for i in xrange(BIG): x = pop() if x != i: self.assertEqual(x, i) def test_big_queue_popright(self): d = deque() append, pop = d.appendleft, d.pop for i in xrange(BIG): append(i) for i in xrange(BIG): x = pop() if x != i: self.assertEqual(x, i) def test_big_stack_right(self): d = deque() append, pop = d.append, d.pop for i in xrange(BIG): append(i) for i in reversed(xrange(BIG)): x = pop() if x != i: self.assertEqual(x, i) self.assertEqual(len(d), 0) def test_big_stack_left(self): d = deque() append, pop = d.appendleft, d.popleft for i in xrange(BIG): append(i) for i in reversed(xrange(BIG)): x = pop() if x != i: self.assertEqual(x, i) self.assertEqual(len(d), 0) def test_roundtrip_iter_init(self): d = deque(xrange(200)) e = deque(d) self.assertNotEqual(id(d), id(e)) self.assertEqual(list(d), list(e)) def test_pickle(self): d = deque(xrange(200)) for i in range(pickle.HIGHEST_PROTOCOL + 1): s = pickle.dumps(d, i) e = pickle.loads(s) self.assertNotEqual(id(d), id(e)) self.assertEqual(list(d), list(e)) ## def test_pickle_recursive(self): ## d = deque('abc') ## d.append(d) ## for i in range(pickle.HIGHEST_PROTOCOL + 1): ## e = pickle.loads(pickle.dumps(d, i)) ## self.assertNotEqual(id(d), id(e)) ## self.assertEqual(id(e), id(e[-1])) def test_deepcopy(self): mut = [10] d = deque([mut]) e = copy.deepcopy(d) self.assertEqual(list(d), list(e)) mut[0] = 11 self.assertNotEqual(id(d), id(e)) self.assertNotEqual(list(d), list(e)) def test_copy(self): mut = [10] d = deque([mut]) e = copy.copy(d) self.assertEqual(list(d), list(e)) mut[0] = 11 self.assertNotEqual(id(d), id(e)) self.assertEqual(list(d), list(e)) def test_reversed(self): for s in ('abcd', xrange(2000)): self.assertEqual(list(reversed(deque(s))), list(reversed(s))) def test_gc_doesnt_blowup(self): import gc # This used to assert-fail in deque_traverse() under a debug # build, or run wild with a NULL pointer in a release build. d = deque() for i in xrange(100): d.append(1) gc.collect() def test_container_iterator(self): # Bug #3680: tp_traverse was not implemented for deque iterator objects class C(object): pass for i in range(2): obj = C() ref = weakref.ref(obj) if i == 0: container = deque([obj, 1]) else: container = reversed(deque([obj, 1])) obj.x = iter(container) del obj, container test_support.gc_collect() self.assertTrue(ref() is None, "Cycle was not collected") check_sizeof = test_support.check_sizeof @test_support.cpython_only def test_sizeof(self): BLOCKLEN = 62 basesize = test_support.calcobjsize('2P4PlP') blocksize = struct.calcsize('2P%dP' % BLOCKLEN) self.assertEqual(object.__sizeof__(deque()), basesize) check = self.check_sizeof check(deque(), basesize + blocksize) check(deque('a'), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2)), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2 + 1)), basesize + 2 * blocksize) check(deque('a' * (42 * BLOCKLEN)), basesize + 43 * blocksize) class TestVariousIteratorArgs(unittest.TestCase): def test_constructor(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (seq_tests.Sequence, seq_tests.IterFunc, seq_tests.IterGen, seq_tests.IterFuncStop, seq_tests.itermulti, seq_tests.iterfunc): self.assertEqual(list(deque(g(s))), list(g(s))) self.assertRaises(TypeError, deque, seq_tests.IterNextOnly(s)) self.assertRaises(TypeError, deque, seq_tests.IterNoNext(s)) self.assertRaises(ZeroDivisionError, deque, seq_tests.IterGenExc(s)) def test_iter_with_altered_data(self): d = deque('abcdefg') it = iter(d) d.pop() self.assertRaises(RuntimeError, it.next) def test_runtime_error_on_empty_deque(self): d = deque() it = iter(d) d.append(10) self.assertRaises(RuntimeError, it.next) class Deque(deque): pass class DequeWithBadIter(deque): def __iter__(self): raise TypeError class TestSubclass(unittest.TestCase): def test_basics(self): d = Deque(xrange(25)) d.__init__(xrange(200)) for i in xrange(200, 400): d.append(i) for i in reversed(xrange(-200, 0)): d.appendleft(i) self.assertEqual(list(d), range(-200, 400)) self.assertEqual(len(d), 600) left = [d.popleft() for i in xrange(250)] self.assertEqual(left, range(-200, 50)) self.assertEqual(list(d), range(50, 400)) right = [d.pop() for i in xrange(250)] right.reverse() self.assertEqual(right, range(150, 400)) self.assertEqual(list(d), range(50, 150)) d.clear() self.assertEqual(len(d), 0) def test_copy_pickle(self): d = Deque('abc') e = d.__copy__() self.assertEqual(type(d), type(e)) self.assertEqual(list(d), list(e)) e = Deque(d) self.assertEqual(type(d), type(e)) self.assertEqual(list(d), list(e)) s = pickle.dumps(d) e = pickle.loads(s) self.assertNotEqual(id(d), id(e)) self.assertEqual(type(d), type(e)) self.assertEqual(list(d), list(e)) d = Deque('abcde', maxlen=4) e = d.__copy__() self.assertEqual(type(d), type(e)) self.assertEqual(list(d), list(e)) e = Deque(d) self.assertEqual(type(d), type(e)) self.assertEqual(list(d), list(e)) s = pickle.dumps(d) e = pickle.loads(s) self.assertNotEqual(id(d), id(e)) self.assertEqual(type(d), type(e)) self.assertEqual(list(d), list(e)) ## def test_pickle(self): ## d = Deque('abc') ## d.append(d) ## ## e = pickle.loads(pickle.dumps(d)) ## self.assertNotEqual(id(d), id(e)) ## self.assertEqual(type(d), type(e)) ## dd = d.pop() ## ee = e.pop() ## self.assertEqual(id(e), id(ee)) ## self.assertEqual(d, e) ## ## d.x = d ## e = pickle.loads(pickle.dumps(d)) ## self.assertEqual(id(e), id(e.x)) ## ## d = DequeWithBadIter('abc') ## self.assertRaises(TypeError, pickle.dumps, d) def test_weakref(self): d = deque('gallahad') p = weakref.proxy(d) self.assertEqual(str(p), str(d)) d = None test_support.gc_collect() self.assertRaises(ReferenceError, str, p) def test_strange_subclass(self): class X(deque): def __iter__(self): return iter([]) d1 = X([1,2,3]) d2 = X([4,5,6]) d1 == d2 # not clear if this is supposed to be True or False, # but it used to give a SystemError class SubclassWithKwargs(deque): def __init__(self, newarg=1): deque.__init__(self) class TestSubclassWithKwargs(unittest.TestCase): def test_subclass_with_kwargs(self): # SF bug #1486663 -- this used to erroneously raise a TypeError SubclassWithKwargs(newarg=1) #============================================================================== libreftest = """ Example from the Library Reference: Doc/lib/libcollections.tex >>> from collections import deque >>> d = deque('ghi') # make a new deque with three items >>> for elem in d: # iterate over the deque's elements ... print elem.upper() G H I >>> d.append('j') # add a new entry to the right side >>> d.appendleft('f') # add a new entry to the left side >>> d # show the representation of the deque deque(['f', 'g', 'h', 'i', 'j']) >>> d.pop() # return and remove the rightmost item 'j' >>> d.popleft() # return and remove the leftmost item 'f' >>> list(d) # list the contents of the deque ['g', 'h', 'i'] >>> d[0] # peek at leftmost item 'g' >>> d[-1] # peek at rightmost item 'i' >>> list(reversed(d)) # list the contents of a deque in reverse ['i', 'h', 'g'] >>> 'h' in d # search the deque True >>> d.extend('jkl') # add multiple elements at once >>> d deque(['g', 'h', 'i', 'j', 'k', 'l']) >>> d.rotate(1) # right rotation >>> d deque(['l', 'g', 'h', 'i', 'j', 'k']) >>> d.rotate(-1) # left rotation >>> d deque(['g', 'h', 'i', 'j', 'k', 'l']) >>> deque(reversed(d)) # make a new deque in reverse order deque(['l', 'k', 'j', 'i', 'h', 'g']) >>> d.clear() # empty the deque >>> d.pop() # cannot pop from an empty deque Traceback (most recent call last): File "<pyshell#6>", line 1, in -toplevel- d.pop() IndexError: pop from an empty deque >>> d.extendleft('abc') # extendleft() reverses the input order >>> d deque(['c', 'b', 'a']) >>> def delete_nth(d, n): ... d.rotate(-n) ... d.popleft() ... d.rotate(n) ... >>> d = deque('abcdef') >>> delete_nth(d, 2) # remove the entry at d[2] >>> d deque(['a', 'b', 'd', 'e', 'f']) >>> def roundrobin(*iterables): ... pending = deque(iter(i) for i in iterables) ... while pending: ... task = pending.popleft() ... try: ... yield task.next() ... except StopIteration: ... continue ... pending.append(task) ... >>> for value in roundrobin('abc', 'd', 'efgh'): ... print value ... a d e b f c g h >>> def maketree(iterable): ... d = deque(iterable) ... while len(d) > 1: ... pair = [d.popleft(), d.popleft()] ... d.append(pair) ... return list(d) ... >>> print maketree('abcdefgh') [[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]] """ #============================================================================== __test__ = {'libreftest' : libreftest} def test_main(verbose=None): import sys test_classes = ( TestBasic, TestVariousIteratorArgs, TestSubclass, TestSubclassWithKwargs, ) test_support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print counts # doctests from test import test_deque test_support.run_doctest(test_deque, verbose) if __name__ == "__main__": test_main(verbose=True)
apache-2.0
[ 504, 5055, 492, 15782, 199, 646, 2882, 199, 504, 511, 492, 511, 63, 4058, 12, 5412, 63, 2219, 199, 646, 9486, 199, 646, 13852, 199, 646, 1331, 199, 646, 17572, 465, 5927, 199, 646, 2196, 199, 646, 2702, 199, 199, 18643, 275, 25761, 199, 199, 318, 2449, 837, 272, 746, 12053, 272, 1995, 413, 199, 199, 533, 8857, 31207, 26, 272, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 746, 6064, 199, 199, 533, 26550, 323, 31207, 26, 272, 347, 636, 826, 721, 277, 12, 15782, 12, 754, 304, 267, 291, 14, 22983, 275, 15782, 267, 291, 14, 1099, 275, 754, 272, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 291, 14, 22983, 14, 3584, 342, 267, 372, 291, 14, 1099, 199, 199, 533, 1379, 6845, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4316, 83, 8, 277, 304, 267, 366, 275, 15782, 8, 21120, 2801, 21, 6889, 12, 446, 13128, 430, 267, 366, 855, 826, 721, 21120, 8, 1840, 430, 267, 367, 284, 315, 4945, 8, 1840, 12, 8290, 304, 288, 366, 14, 740, 8, 73, 9, 267, 367, 284, 315, 10822, 8, 21120, 2801, 1840, 12, 378, 2298, 288, 366, 14, 740, 3039, 8, 73, 9, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 2801, 1840, 12, 8290, 430, 267, 291, 14, 629, 8, 552, 8, 68, 395, 11624, 9, 398, 3602, 275, 359, 68, 14, 25704, 342, 367, 284, 315, 4945, 8, 7991, 1874, 267, 291, 14, 629, 8, 3039, 12, 1425, 2801, 1840, 12, 5238, 430, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 1400, 12, 8290, 430, 398, 2451, 275, 359, 68, 14, 1935, 342, 367, 284, 315, 4945, 8, 7991, 1874, 267, 2451, 14, 4471, 342, 267, 291, 14, 629, 8, 1019, 12, 1425, 8, 8251, 12, 8290, 430, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 1400, 12, 14711, 430, 339, 347, 511, 63, 29078, 8, 277, 304, 267, 291, 14, 1855, 8, 3393, 12, 15782, 12, 283, 3175, 297, 446, 17, 9, 267, 291, 14, 1855, 8, 3393, 12, 15782, 12, 283, 3175, 297, 446, 18, 9, 267, 652, 275, 2740, 8, 1842, 8, 709, 430, 267, 366, 275, 15782, 8, 390, 12, 21037, 29, 19, 9, 267, 291, 14, 629, 8, 513, 8, 390, 395, 3073, 267, 291, 14, 629, 8, 2722, 8, 68, 395, 283, 22983, 779, 23, 12, 1695, 12, 1749, 467, 21037, 29, 19, 5942, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 23, 12, 1616, 430, 267, 291, 14, 629, 8, 68, 12, 15782, 8, 1842, 8, 709, 395, 650, 430, 267, 366, 14, 740, 8, 709, 9, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 24, 12, 4119, 430, 267, 366, 14, 740, 3039, 8, 23, 9, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 23, 12, 1616, 430, 267, 366, 14, 2880, 779, 709, 12, 4119, 566, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 25, 12, 3144, 430, 267, 366, 14, 2880, 3039, 779, 24, 12, 1520, 566, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 23, 12, 1616, 430, 267, 366, 275, 15782, 8, 21120, 8, 1840, 395, 21037, 29, 709, 9, 267, 366, 14, 740, 8, 68, 9, 267, 511, 63, 4058, 14, 7162, 8, 396, 63, 4058, 14, 10179, 9, 267, 7090, 275, 1551, 8, 396, 63, 4058, 14, 10179, 12, 298, 6603, 531, 267, 862, 26, 288, 870, 4331, 7090, 12, 366, 12, 288, 7090, 14, 1600, 342, 288, 7090, 275, 1551, 8, 396, 63, 4058, 14, 10179, 12, 298, 4848, 531, 288, 291, 14, 629, 8, 545, 14, 739, 1062, 4700, 8, 68, 430, 267, 3753, 26, 288, 7090, 14, 1600, 342, 288, 511, 63, 4058, 14, 7162, 8, 396, 63, 4058, 14, 10179, 9, 398, 366, 275, 15782, 8, 1842, 8, 709, 395, 21037, 29, 403, 9, 267, 291, 14, 629, 8, 2722, 8, 68, 395, 283, 22983, 779, 16, 12, 413, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 1695, 12, 1749, 566, 358, 267, 7090, 275, 1551, 8, 396, 63, 4058, 14, 10179, 12, 298, 6603, 531, 267, 862, 26, 288, 870, 4331, 7090, 12, 366, 12, 288, 7090, 14, 1600, 342, 288, 7090, 275, 1551, 8, 396, 63, 4058, 14, 10179, 12, 298, 4848, 531, 288, 291, 14, 629, 8, 545, 14, 739, 1062, 4700, 8, 68, 430, 267, 3753, 26, 288, 7090, 14, 1600, 342, 288, 511, 63, 4058, 14, 7162, 8, 396, 63, 4058, 14, 10179, 9, 339, 347, 511, 63, 29078, 63, 4262, 8, 277, 304, 267, 652, 275, 2740, 8, 1842, 8, 1960, 430, 267, 15782, 8, 390, 12, 21037, 29, 16, 9, 267, 291, 14, 629, 8, 513, 8, 390, 395, 3073, 398, 652, 275, 2740, 8, 1842, 8, 1960, 430, 267, 366, 275, 15782, 8, 29078, 29, 16, 9, 267, 366, 14, 2880, 8, 390, 9, 267, 291, 14, 629, 8, 513, 8, 390, 395, 3073, 398, 652, 275, 2740, 8, 1842, 8, 1960, 430, 267, 366, 275, 15782, 8, 29078, 29, 16, 9, 267, 366, 14, 2880, 3039, 8, 390, 9, 267, 291, 14, 629, 8, 513, 8, 390, 395, 3073, 339, 347, 511, 63, 29078, 63, 3215, 8, 277, 304, 267, 291, 14, 629, 8, 22983, 1252, 29078, 12, 488, 9, 267, 291, 14, 629, 8, 22983, 360, 3175, 1959, 29078, 12, 488, 9, 267, 291, 14, 629, 8, 22983, 360, 3175, 297, 21037, 29, 20, 680, 29078, 12, 841, 9, 267, 291, 14, 629, 8, 22983, 360, 3175, 297, 21037, 29, 18, 680, 29078, 12, 499, 9, 267, 291, 14, 629, 8, 22983, 360, 3175, 297, 21037, 29, 16, 680, 29078, 12, 378, 9, 267, 543, 291, 14, 1855, 1332, 10227, 12, 3146, 2298, 288, 366, 275, 15782, 360, 3175, 358, 288, 366, 14, 29078, 275, 1616, 339, 347, 511, 63, 835, 8, 277, 304, 267, 367, 308, 315, 13134, 283, 371, 6457, 350, 371, 345, 297, 283, 338, 706, 279, 371, 1017, 16804, 5783, 4786, 3175, 735, 288, 308, 275, 769, 8, 83, 9, 288, 366, 275, 15782 ]
[ 5055, 492, 15782, 199, 646, 2882, 199, 504, 511, 492, 511, 63, 4058, 12, 5412, 63, 2219, 199, 646, 9486, 199, 646, 13852, 199, 646, 1331, 199, 646, 17572, 465, 5927, 199, 646, 2196, 199, 646, 2702, 199, 199, 18643, 275, 25761, 199, 199, 318, 2449, 837, 272, 746, 12053, 272, 1995, 413, 199, 199, 533, 8857, 31207, 26, 272, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 746, 6064, 199, 199, 533, 26550, 323, 31207, 26, 272, 347, 636, 826, 721, 277, 12, 15782, 12, 754, 304, 267, 291, 14, 22983, 275, 15782, 267, 291, 14, 1099, 275, 754, 272, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 291, 14, 22983, 14, 3584, 342, 267, 372, 291, 14, 1099, 199, 199, 533, 1379, 6845, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4316, 83, 8, 277, 304, 267, 366, 275, 15782, 8, 21120, 2801, 21, 6889, 12, 446, 13128, 430, 267, 366, 855, 826, 721, 21120, 8, 1840, 430, 267, 367, 284, 315, 4945, 8, 1840, 12, 8290, 304, 288, 366, 14, 740, 8, 73, 9, 267, 367, 284, 315, 10822, 8, 21120, 2801, 1840, 12, 378, 2298, 288, 366, 14, 740, 3039, 8, 73, 9, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 2801, 1840, 12, 8290, 430, 267, 291, 14, 629, 8, 552, 8, 68, 395, 11624, 9, 398, 3602, 275, 359, 68, 14, 25704, 342, 367, 284, 315, 4945, 8, 7991, 1874, 267, 291, 14, 629, 8, 3039, 12, 1425, 2801, 1840, 12, 5238, 430, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 1400, 12, 8290, 430, 398, 2451, 275, 359, 68, 14, 1935, 342, 367, 284, 315, 4945, 8, 7991, 1874, 267, 2451, 14, 4471, 342, 267, 291, 14, 629, 8, 1019, 12, 1425, 8, 8251, 12, 8290, 430, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 1400, 12, 14711, 430, 339, 347, 511, 63, 29078, 8, 277, 304, 267, 291, 14, 1855, 8, 3393, 12, 15782, 12, 283, 3175, 297, 446, 17, 9, 267, 291, 14, 1855, 8, 3393, 12, 15782, 12, 283, 3175, 297, 446, 18, 9, 267, 652, 275, 2740, 8, 1842, 8, 709, 430, 267, 366, 275, 15782, 8, 390, 12, 21037, 29, 19, 9, 267, 291, 14, 629, 8, 513, 8, 390, 395, 3073, 267, 291, 14, 629, 8, 2722, 8, 68, 395, 283, 22983, 779, 23, 12, 1695, 12, 1749, 467, 21037, 29, 19, 5942, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 23, 12, 1616, 430, 267, 291, 14, 629, 8, 68, 12, 15782, 8, 1842, 8, 709, 395, 650, 430, 267, 366, 14, 740, 8, 709, 9, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 24, 12, 4119, 430, 267, 366, 14, 740, 3039, 8, 23, 9, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 23, 12, 1616, 430, 267, 366, 14, 2880, 779, 709, 12, 4119, 566, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 25, 12, 3144, 430, 267, 366, 14, 2880, 3039, 779, 24, 12, 1520, 566, 267, 291, 14, 629, 8, 513, 8, 68, 395, 1425, 8, 23, 12, 1616, 430, 267, 366, 275, 15782, 8, 21120, 8, 1840, 395, 21037, 29, 709, 9, 267, 366, 14, 740, 8, 68, 9, 267, 511, 63, 4058, 14, 7162, 8, 396, 63, 4058, 14, 10179, 9, 267, 7090, 275, 1551, 8, 396, 63, 4058, 14, 10179, 12, 298, 6603, 531, 267, 862, 26, 288, 870, 4331, 7090, 12, 366, 12, 288, 7090, 14, 1600, 342, 288, 7090, 275, 1551, 8, 396, 63, 4058, 14, 10179, 12, 298, 4848, 531, 288, 291, 14, 629, 8, 545, 14, 739, 1062, 4700, 8, 68, 430, 267, 3753, 26, 288, 7090, 14, 1600, 342, 288, 511, 63, 4058, 14, 7162, 8, 396, 63, 4058, 14, 10179, 9, 398, 366, 275, 15782, 8, 1842, 8, 709, 395, 21037, 29, 403, 9, 267, 291, 14, 629, 8, 2722, 8, 68, 395, 283, 22983, 779, 16, 12, 413, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 12, 1520, 12, 1695, 12, 1749, 566, 358, 267, 7090, 275, 1551, 8, 396, 63, 4058, 14, 10179, 12, 298, 6603, 531, 267, 862, 26, 288, 870, 4331, 7090, 12, 366, 12, 288, 7090, 14, 1600, 342, 288, 7090, 275, 1551, 8, 396, 63, 4058, 14, 10179, 12, 298, 4848, 531, 288, 291, 14, 629, 8, 545, 14, 739, 1062, 4700, 8, 68, 430, 267, 3753, 26, 288, 7090, 14, 1600, 342, 288, 511, 63, 4058, 14, 7162, 8, 396, 63, 4058, 14, 10179, 9, 339, 347, 511, 63, 29078, 63, 4262, 8, 277, 304, 267, 652, 275, 2740, 8, 1842, 8, 1960, 430, 267, 15782, 8, 390, 12, 21037, 29, 16, 9, 267, 291, 14, 629, 8, 513, 8, 390, 395, 3073, 398, 652, 275, 2740, 8, 1842, 8, 1960, 430, 267, 366, 275, 15782, 8, 29078, 29, 16, 9, 267, 366, 14, 2880, 8, 390, 9, 267, 291, 14, 629, 8, 513, 8, 390, 395, 3073, 398, 652, 275, 2740, 8, 1842, 8, 1960, 430, 267, 366, 275, 15782, 8, 29078, 29, 16, 9, 267, 366, 14, 2880, 3039, 8, 390, 9, 267, 291, 14, 629, 8, 513, 8, 390, 395, 3073, 339, 347, 511, 63, 29078, 63, 3215, 8, 277, 304, 267, 291, 14, 629, 8, 22983, 1252, 29078, 12, 488, 9, 267, 291, 14, 629, 8, 22983, 360, 3175, 1959, 29078, 12, 488, 9, 267, 291, 14, 629, 8, 22983, 360, 3175, 297, 21037, 29, 20, 680, 29078, 12, 841, 9, 267, 291, 14, 629, 8, 22983, 360, 3175, 297, 21037, 29, 18, 680, 29078, 12, 499, 9, 267, 291, 14, 629, 8, 22983, 360, 3175, 297, 21037, 29, 16, 680, 29078, 12, 378, 9, 267, 543, 291, 14, 1855, 1332, 10227, 12, 3146, 2298, 288, 366, 275, 15782, 360, 3175, 358, 288, 366, 14, 29078, 275, 1616, 339, 347, 511, 63, 835, 8, 277, 304, 267, 367, 308, 315, 13134, 283, 371, 6457, 350, 371, 345, 297, 283, 338, 706, 279, 371, 1017, 16804, 5783, 4786, 3175, 735, 288, 308, 275, 769, 8, 83, 9, 288, 366, 275, 15782, 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,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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 ]
TeutoNet-Netzdienste/ansible
v2/ansible/plugins/action/group_by.py
16
1313
# Copyright 2012, Jeroen Hoekx <jeroen@hoekx.be> # # 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/>. from ansible.errors import * from ansible.plugins.action import ActionBase class ActionModule(ActionBase): ''' Create inventory groups based on variables ''' ### We need to be able to modify the inventory BYPASS_HOST_LOOP = True TRANSFERS_FILES = False def run(self, tmp=None, task_vars=dict()): if not 'key' in self._task.args: return dict(failed=True, msg="the 'key' param is required when using group_by") group_name = self._task.args.get('key') group_name = group_name.replace(' ','-') return dict(changed=True, add_group=group_name)
gpl-3.0
[ 3, 1898, 6029, 12, 1603, 3478, 287, 28673, 5711, 88, 665, 74, 3478, 287, 32, 526, 5711, 88, 14, 1235, 30, 199, 3, 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, 199, 504, 3242, 14, 2550, 492, 627, 199, 504, 3242, 14, 5265, 14, 1287, 492, 10033, 1563, 199, 199, 533, 10033, 2377, 8, 3310, 1563, 304, 272, 1449, 2790, 8200, 4652, 4079, 641, 2860, 1449, 339, 6754, 2136, 1929, 370, 506, 7688, 370, 2811, 314, 8200, 272, 6515, 6909, 63, 5449, 63, 26573, 275, 715, 272, 9074, 5622, 38, 3960, 63, 9472, 275, 756, 339, 347, 1255, 8, 277, 12, 3529, 29, 403, 12, 2120, 63, 2936, 29, 807, 5109, 398, 340, 440, 283, 498, 7, 315, 291, 423, 1765, 14, 589, 26, 288, 372, 1211, 8, 4892, 29, 549, 12, 1499, 628, 1589, 283, 498, 7, 1215, 365, 1415, 1380, 1808, 1572, 63, 991, 531, 398, 1572, 63, 354, 275, 291, 423, 1765, 14, 589, 14, 362, 360, 498, 358, 267, 1572, 63, 354, 275, 1572, 63, 354, 14, 1814, 360, 1656, 12418, 358, 398, 372, 1211, 8, 2489, 29, 549, 12, 1050, 63, 923, 29, 923, 63, 354, 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 ]
[ 1898, 6029, 12, 1603, 3478, 287, 28673, 5711, 88, 665, 74, 3478, 287, 32, 526, 5711, 88, 14, 1235, 30, 199, 3, 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, 199, 504, 3242, 14, 2550, 492, 627, 199, 504, 3242, 14, 5265, 14, 1287, 492, 10033, 1563, 199, 199, 533, 10033, 2377, 8, 3310, 1563, 304, 272, 1449, 2790, 8200, 4652, 4079, 641, 2860, 1449, 339, 6754, 2136, 1929, 370, 506, 7688, 370, 2811, 314, 8200, 272, 6515, 6909, 63, 5449, 63, 26573, 275, 715, 272, 9074, 5622, 38, 3960, 63, 9472, 275, 756, 339, 347, 1255, 8, 277, 12, 3529, 29, 403, 12, 2120, 63, 2936, 29, 807, 5109, 398, 340, 440, 283, 498, 7, 315, 291, 423, 1765, 14, 589, 26, 288, 372, 1211, 8, 4892, 29, 549, 12, 1499, 628, 1589, 283, 498, 7, 1215, 365, 1415, 1380, 1808, 1572, 63, 991, 531, 398, 1572, 63, 354, 275, 291, 423, 1765, 14, 589, 14, 362, 360, 498, 358, 267, 1572, 63, 354, 275, 1572, 63, 354, 14, 1814, 360, 1656, 12418, 358, 398, 372, 1211, 8, 2489, 29, 549, 12, 1050, 63, 923, 29, 923, 63, 354, 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, 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,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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 ]
googleapis/python-webrisk
tests/unit/gapic/webrisk_v1/test_web_risk_service.py
1
67484
# -*- coding: utf-8 -*- # Copyright 2020 Google LLC # # 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 mock import packaging.version import grpc from grpc.experimental import aio import math import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule from google.api_core import client_options from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.webrisk_v1.services.web_risk_service import WebRiskServiceAsyncClient from google.cloud.webrisk_v1.services.web_risk_service import WebRiskServiceClient from google.cloud.webrisk_v1.services.web_risk_service import transports from google.cloud.webrisk_v1.services.web_risk_service.transports.base import ( _GOOGLE_AUTH_VERSION, ) from google.cloud.webrisk_v1.types import webrisk from google.oauth2 import service_account from google.protobuf import timestamp_pb2 # type: ignore import google.auth # TODO(busunkim): Once google-auth >= 1.25.0 is required transitively # through google-api-core: # - Delete the auth "less than" test cases # - Delete these pytest markers (Make the "greater than or equal to" tests the default). requires_google_auth_lt_1_25_0 = pytest.mark.skipif( packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), reason="This test requires google-auth < 1.25.0", ) requires_google_auth_gte_1_25_0 = pytest.mark.skipif( packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), reason="This test requires google-auth >= 1.25.0", ) def client_cert_source_callback(): return b"cert bytes", b"key bytes" # If default endpoint is localhost, then default mtls endpoint will be the same. # This method modifies the default endpoint so the client can produce a different # mtls endpoint for endpoint testing purposes. def modify_default_endpoint(client): return ( "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT ) def test__get_default_mtls_endpoint(): api_endpoint = "example.googleapis.com" api_mtls_endpoint = "example.mtls.googleapis.com" sandbox_endpoint = "example.sandbox.googleapis.com" sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" non_googleapi = "api.example.com" assert WebRiskServiceClient._get_default_mtls_endpoint(None) is None assert ( WebRiskServiceClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint ) assert ( WebRiskServiceClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint ) assert ( WebRiskServiceClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint ) assert ( WebRiskServiceClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint ) assert ( WebRiskServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi ) @pytest.mark.parametrize( "client_class", [WebRiskServiceClient, WebRiskServiceAsyncClient,] ) def test_web_risk_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} client = client_class.from_service_account_info(info) assert client.transport._credentials == creds assert isinstance(client, client_class) assert client.transport._host == "webrisk.googleapis.com:443" @pytest.mark.parametrize( "client_class", [WebRiskServiceClient, WebRiskServiceAsyncClient,] ) def test_web_risk_service_client_service_account_always_use_jwt(client_class): with mock.patch.object( service_account.Credentials, "with_always_use_jwt_access", create=True ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) use_jwt.assert_called_with(True) @pytest.mark.parametrize( "client_class", [WebRiskServiceClient, WebRiskServiceAsyncClient,] ) def test_web_risk_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") assert client.transport._credentials == creds assert isinstance(client, client_class) client = client_class.from_service_account_json("dummy/file/path.json") assert client.transport._credentials == creds assert isinstance(client, client_class) assert client.transport._host == "webrisk.googleapis.com:443" def test_web_risk_service_client_get_transport_class(): transport = WebRiskServiceClient.get_transport_class() available_transports = [ transports.WebRiskServiceGrpcTransport, ] assert transport in available_transports transport = WebRiskServiceClient.get_transport_class("grpc") assert transport == transports.WebRiskServiceGrpcTransport @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ (WebRiskServiceClient, transports.WebRiskServiceGrpcTransport, "grpc"), ( WebRiskServiceAsyncClient, transports.WebRiskServiceGrpcAsyncIOTransport, "grpc_asyncio", ), ], ) @mock.patch.object( WebRiskServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(WebRiskServiceClient), ) @mock.patch.object( WebRiskServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(WebRiskServiceAsyncClient), ) def test_web_risk_service_client_client_options( client_class, transport_class, transport_name ): # Check that if channel is provided we won't create a new one. with mock.patch.object(WebRiskServiceClient, "get_transport_class") as gtc: transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() # Check that if channel is provided via str we will create a new one. with mock.patch.object(WebRiskServiceClient, "get_transport_class") as gtc: client = client_class(transport=transport_name) gtc.assert_called() # Check the case api_endpoint is provided. options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, host="squid.clam.whelk", scopes=None, client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "never". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( credentials=None, credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is # "always". with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class() patched.assert_called_once_with( credentials=None, credentials_file=None, host=client.DEFAULT_MTLS_ENDPOINT, scopes=None, client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): client = client_class() # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): client = client_class() # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, ) @pytest.mark.parametrize( "client_class,transport_class,transport_name,use_client_cert_env", [ (WebRiskServiceClient, transports.WebRiskServiceGrpcTransport, "grpc", "true"), ( WebRiskServiceAsyncClient, transports.WebRiskServiceGrpcAsyncIOTransport, "grpc_asyncio", "true", ), (WebRiskServiceClient, transports.WebRiskServiceGrpcTransport, "grpc", "false"), ( WebRiskServiceAsyncClient, transports.WebRiskServiceGrpcAsyncIOTransport, "grpc_asyncio", "false", ), ], ) @mock.patch.object( WebRiskServiceClient, "DEFAULT_ENDPOINT", modify_default_endpoint(WebRiskServiceClient), ) @mock.patch.object( WebRiskServiceAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(WebRiskServiceAsyncClient), ) @mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) def test_web_risk_service_client_mtls_env_auto( client_class, transport_class, transport_name, use_client_cert_env ): # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. # Check the case client_cert_source is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} ): options = client_options.ClientOptions( client_cert_source=client_cert_source_callback ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None expected_host = client.DEFAULT_ENDPOINT else: expected_client_cert_source = client_cert_source_callback expected_host = client.DEFAULT_MTLS_ENDPOINT patched.assert_called_once_with( credentials=None, credentials_file=None, host=expected_host, scopes=None, client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} ): with mock.patch.object(transport_class, "__init__") as patched: with mock.patch( "google.auth.transport.mtls.has_default_client_cert_source", return_value=True, ): with mock.patch( "google.auth.transport.mtls.default_client_cert_source", return_value=client_cert_source_callback, ): if use_client_cert_env == "false": expected_host = client.DEFAULT_ENDPOINT expected_client_cert_source = None else: expected_host = client.DEFAULT_MTLS_ENDPOINT expected_client_cert_source = client_cert_source_callback patched.return_value = None client = client_class() patched.assert_called_once_with( credentials=None, credentials_file=None, host=expected_host, scopes=None, client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) # Check the case client_cert_source and ADC client cert are not provided. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} ): with mock.patch.object(transport_class, "__init__") as patched: with mock.patch( "google.auth.transport.mtls.has_default_client_cert_source", return_value=False, ): patched.return_value = None client = client_class() patched.assert_called_once_with( credentials=None, credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ (WebRiskServiceClient, transports.WebRiskServiceGrpcTransport, "grpc"), ( WebRiskServiceAsyncClient, transports.WebRiskServiceGrpcAsyncIOTransport, "grpc_asyncio", ), ], ) def test_web_risk_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=["1", "2"], client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ (WebRiskServiceClient, transports.WebRiskServiceGrpcTransport, "grpc"), ( WebRiskServiceAsyncClient, transports.WebRiskServiceGrpcAsyncIOTransport, "grpc_asyncio", ), ], ) def test_web_risk_service_client_client_options_credentials_file( client_class, transport_class, transport_name ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", host=client.DEFAULT_ENDPOINT, scopes=None, client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) def test_web_risk_service_client_client_options_from_dict(): with mock.patch( "google.cloud.webrisk_v1.services.web_risk_service.transports.WebRiskServiceGrpcTransport.__init__" ) as grpc_transport: grpc_transport.return_value = None client = WebRiskServiceClient( client_options={"api_endpoint": "squid.clam.whelk"} ) grpc_transport.assert_called_once_with( credentials=None, credentials_file=None, host="squid.clam.whelk", scopes=None, client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) def test_compute_threat_list_diff( transport: str = "grpc", request_type=webrisk.ComputeThreatListDiffRequest ): client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.compute_threat_list_diff), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = webrisk.ComputeThreatListDiffResponse( response_type=webrisk.ComputeThreatListDiffResponse.ResponseType.DIFF, new_version_token=b"new_version_token_blob", ) response = client.compute_threat_list_diff(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0] == webrisk.ComputeThreatListDiffRequest() # Establish that the response is the type that we expect. assert isinstance(response, webrisk.ComputeThreatListDiffResponse) assert ( response.response_type == webrisk.ComputeThreatListDiffResponse.ResponseType.DIFF ) assert response.new_version_token == b"new_version_token_blob" def test_compute_threat_list_diff_from_dict(): test_compute_threat_list_diff(request_type=dict) def test_compute_threat_list_diff_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.compute_threat_list_diff), "__call__" ) as call: client.compute_threat_list_diff() call.assert_called() _, args, _ = call.mock_calls[0] assert args[0] == webrisk.ComputeThreatListDiffRequest() @pytest.mark.asyncio async def test_compute_threat_list_diff_async( transport: str = "grpc_asyncio", request_type=webrisk.ComputeThreatListDiffRequest ): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.compute_threat_list_diff), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( webrisk.ComputeThreatListDiffResponse( response_type=webrisk.ComputeThreatListDiffResponse.ResponseType.DIFF, new_version_token=b"new_version_token_blob", ) ) response = await client.compute_threat_list_diff(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0] == webrisk.ComputeThreatListDiffRequest() # Establish that the response is the type that we expect. assert isinstance(response, webrisk.ComputeThreatListDiffResponse) assert ( response.response_type == webrisk.ComputeThreatListDiffResponse.ResponseType.DIFF ) assert response.new_version_token == b"new_version_token_blob" @pytest.mark.asyncio async def test_compute_threat_list_diff_async_from_dict(): await test_compute_threat_list_diff_async(request_type=dict) def test_compute_threat_list_diff_flattened(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.compute_threat_list_diff), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = webrisk.ComputeThreatListDiffResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.compute_threat_list_diff( threat_type=webrisk.ThreatType.MALWARE, version_token=b"version_token_blob", constraints=webrisk.ComputeThreatListDiffRequest.Constraints( max_diff_entries=1687 ), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0].threat_type == webrisk.ThreatType.MALWARE assert args[0].version_token == b"version_token_blob" assert args[0].constraints == webrisk.ComputeThreatListDiffRequest.Constraints( max_diff_entries=1687 ) def test_compute_threat_list_diff_flattened_error(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.compute_threat_list_diff( webrisk.ComputeThreatListDiffRequest(), threat_type=webrisk.ThreatType.MALWARE, version_token=b"version_token_blob", constraints=webrisk.ComputeThreatListDiffRequest.Constraints( max_diff_entries=1687 ), ) @pytest.mark.asyncio async def test_compute_threat_list_diff_flattened_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.compute_threat_list_diff), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = webrisk.ComputeThreatListDiffResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( webrisk.ComputeThreatListDiffResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.compute_threat_list_diff( threat_type=webrisk.ThreatType.MALWARE, version_token=b"version_token_blob", constraints=webrisk.ComputeThreatListDiffRequest.Constraints( max_diff_entries=1687 ), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0].threat_type == webrisk.ThreatType.MALWARE assert args[0].version_token == b"version_token_blob" assert args[0].constraints == webrisk.ComputeThreatListDiffRequest.Constraints( max_diff_entries=1687 ) @pytest.mark.asyncio async def test_compute_threat_list_diff_flattened_error_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.compute_threat_list_diff( webrisk.ComputeThreatListDiffRequest(), threat_type=webrisk.ThreatType.MALWARE, version_token=b"version_token_blob", constraints=webrisk.ComputeThreatListDiffRequest.Constraints( max_diff_entries=1687 ), ) def test_search_uris(transport: str = "grpc", request_type=webrisk.SearchUrisRequest): client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_uris), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = webrisk.SearchUrisResponse() response = client.search_uris(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0] == webrisk.SearchUrisRequest() # Establish that the response is the type that we expect. assert isinstance(response, webrisk.SearchUrisResponse) def test_search_uris_from_dict(): test_search_uris(request_type=dict) def test_search_uris_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_uris), "__call__") as call: client.search_uris() call.assert_called() _, args, _ = call.mock_calls[0] assert args[0] == webrisk.SearchUrisRequest() @pytest.mark.asyncio async def test_search_uris_async( transport: str = "grpc_asyncio", request_type=webrisk.SearchUrisRequest ): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_uris), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( webrisk.SearchUrisResponse() ) response = await client.search_uris(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0] == webrisk.SearchUrisRequest() # Establish that the response is the type that we expect. assert isinstance(response, webrisk.SearchUrisResponse) @pytest.mark.asyncio async def test_search_uris_async_from_dict(): await test_search_uris_async(request_type=dict) def test_search_uris_flattened(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_uris), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = webrisk.SearchUrisResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_uris( uri="uri_value", threat_types=[webrisk.ThreatType.MALWARE], ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0].uri == "uri_value" assert args[0].threat_types == [webrisk.ThreatType.MALWARE] def test_search_uris_flattened_error(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.search_uris( webrisk.SearchUrisRequest(), uri="uri_value", threat_types=[webrisk.ThreatType.MALWARE], ) @pytest.mark.asyncio async def test_search_uris_flattened_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_uris), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = webrisk.SearchUrisResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( webrisk.SearchUrisResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.search_uris( uri="uri_value", threat_types=[webrisk.ThreatType.MALWARE], ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0].uri == "uri_value" assert args[0].threat_types == [webrisk.ThreatType.MALWARE] @pytest.mark.asyncio async def test_search_uris_flattened_error_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.search_uris( webrisk.SearchUrisRequest(), uri="uri_value", threat_types=[webrisk.ThreatType.MALWARE], ) def test_search_hashes( transport: str = "grpc", request_type=webrisk.SearchHashesRequest ): client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_hashes), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = webrisk.SearchHashesResponse() response = client.search_hashes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0] == webrisk.SearchHashesRequest() # Establish that the response is the type that we expect. assert isinstance(response, webrisk.SearchHashesResponse) def test_search_hashes_from_dict(): test_search_hashes(request_type=dict) def test_search_hashes_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_hashes), "__call__") as call: client.search_hashes() call.assert_called() _, args, _ = call.mock_calls[0] assert args[0] == webrisk.SearchHashesRequest() @pytest.mark.asyncio async def test_search_hashes_async( transport: str = "grpc_asyncio", request_type=webrisk.SearchHashesRequest ): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_hashes), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( webrisk.SearchHashesResponse() ) response = await client.search_hashes(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0] == webrisk.SearchHashesRequest() # Establish that the response is the type that we expect. assert isinstance(response, webrisk.SearchHashesResponse) @pytest.mark.asyncio async def test_search_hashes_async_from_dict(): await test_search_hashes_async(request_type=dict) def test_search_hashes_flattened(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_hashes), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = webrisk.SearchHashesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_hashes( hash_prefix=b"hash_prefix_blob", threat_types=[webrisk.ThreatType.MALWARE], ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0].hash_prefix == b"hash_prefix_blob" assert args[0].threat_types == [webrisk.ThreatType.MALWARE] def test_search_hashes_flattened_error(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.search_hashes( webrisk.SearchHashesRequest(), hash_prefix=b"hash_prefix_blob", threat_types=[webrisk.ThreatType.MALWARE], ) @pytest.mark.asyncio async def test_search_hashes_flattened_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_hashes), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = webrisk.SearchHashesResponse() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( webrisk.SearchHashesResponse() ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.search_hashes( hash_prefix=b"hash_prefix_blob", threat_types=[webrisk.ThreatType.MALWARE], ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0].hash_prefix == b"hash_prefix_blob" assert args[0].threat_types == [webrisk.ThreatType.MALWARE] @pytest.mark.asyncio async def test_search_hashes_flattened_error_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.search_hashes( webrisk.SearchHashesRequest(), hash_prefix=b"hash_prefix_blob", threat_types=[webrisk.ThreatType.MALWARE], ) def test_create_submission( transport: str = "grpc", request_type=webrisk.CreateSubmissionRequest ): client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_submission), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = webrisk.Submission(uri="uri_value",) response = client.create_submission(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0] == webrisk.CreateSubmissionRequest() # Establish that the response is the type that we expect. assert isinstance(response, webrisk.Submission) assert response.uri == "uri_value" def test_create_submission_from_dict(): test_create_submission(request_type=dict) def test_create_submission_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_submission), "__call__" ) as call: client.create_submission() call.assert_called() _, args, _ = call.mock_calls[0] assert args[0] == webrisk.CreateSubmissionRequest() @pytest.mark.asyncio async def test_create_submission_async( transport: str = "grpc_asyncio", request_type=webrisk.CreateSubmissionRequest ): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_submission), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( webrisk.Submission(uri="uri_value",) ) response = await client.create_submission(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0] == webrisk.CreateSubmissionRequest() # Establish that the response is the type that we expect. assert isinstance(response, webrisk.Submission) assert response.uri == "uri_value" @pytest.mark.asyncio async def test_create_submission_async_from_dict(): await test_create_submission_async(request_type=dict) def test_create_submission_field_headers(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = webrisk.CreateSubmissionRequest() request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_submission), "__call__" ) as call: call.return_value = webrisk.Submission() client.create_submission(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0] == request # Establish that the field header was sent. _, _, kw = call.mock_calls[0] assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] @pytest.mark.asyncio async def test_create_submission_field_headers_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = webrisk.CreateSubmissionRequest() request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_submission), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(webrisk.Submission()) await client.create_submission(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0] == request # Establish that the field header was sent. _, _, kw = call.mock_calls[0] assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] def test_create_submission_flattened(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_submission), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = webrisk.Submission() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_submission( parent="parent_value", submission=webrisk.Submission(uri="uri_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0].parent == "parent_value" assert args[0].submission == webrisk.Submission(uri="uri_value") def test_create_submission_flattened_error(): client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.create_submission( webrisk.CreateSubmissionRequest(), parent="parent_value", submission=webrisk.Submission(uri="uri_value"), ) @pytest.mark.asyncio async def test_create_submission_flattened_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_submission), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = webrisk.Submission() call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(webrisk.Submission()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_submission( parent="parent_value", submission=webrisk.Submission(uri="uri_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0].parent == "parent_value" assert args[0].submission == webrisk.Submission(uri="uri_value") @pytest.mark.asyncio async def test_create_submission_flattened_error_async(): client = WebRiskServiceAsyncClient( credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.create_submission( webrisk.CreateSubmissionRequest(), parent="parent_value", submission=webrisk.Submission(uri="uri_value"), ) def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.WebRiskServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.WebRiskServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = WebRiskServiceClient( client_options={"credentials_file": "credentials.json"}, transport=transport, ) # It is an error to provide scopes and a transport instance. transport = transports.WebRiskServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = WebRiskServiceClient( client_options={"scopes": ["1", "2"]}, transport=transport, ) def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.WebRiskServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) client = WebRiskServiceClient(transport=transport) assert client.transport is transport def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.WebRiskServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.WebRiskServiceGrpcAsyncIOTransport( credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @pytest.mark.parametrize( "transport_class", [ transports.WebRiskServiceGrpcTransport, transports.WebRiskServiceGrpcAsyncIOTransport, ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. with mock.patch.object(google.auth, "default") as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = WebRiskServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.WebRiskServiceGrpcTransport,) def test_web_risk_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.WebRiskServiceTransport( credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) def test_web_risk_service_base_transport(): # Instantiate the base transport. with mock.patch( "google.cloud.webrisk_v1.services.web_risk_service.transports.WebRiskServiceTransport.__init__" ) as Transport: Transport.return_value = None transport = transports.WebRiskServiceTransport( credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly # raise NotImplementedError. methods = ( "compute_threat_list_diff", "search_uris", "search_hashes", "create_submission", ) for method in methods: with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) @requires_google_auth_gte_1_25_0 def test_web_risk_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.webrisk_v1.services.web_risk_service.transports.WebRiskServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.WebRiskServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", scopes=None, default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @requires_google_auth_lt_1_25_0 def test_web_risk_service_base_transport_with_credentials_file_old_google_auth(): # Instantiate the base transport with a credentials file with mock.patch.object( google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.webrisk_v1.services.web_risk_service.transports.WebRiskServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.WebRiskServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) def test_web_risk_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.webrisk_v1.services.web_risk_service.transports.WebRiskServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.WebRiskServiceTransport() adc.assert_called_once() @requires_google_auth_gte_1_25_0 def test_web_risk_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) WebRiskServiceClient() adc.assert_called_once_with( scopes=None, default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @requires_google_auth_lt_1_25_0 def test_web_risk_service_auth_adc_old_google_auth(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) WebRiskServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id=None, ) @pytest.mark.parametrize( "transport_class", [ transports.WebRiskServiceGrpcTransport, transports.WebRiskServiceGrpcAsyncIOTransport, ], ) @requires_google_auth_gte_1_25_0 def test_web_risk_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus", scopes=["1", "2"]) adc.assert_called_once_with( scopes=["1", "2"], default_scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @pytest.mark.parametrize( "transport_class", [ transports.WebRiskServiceGrpcTransport, transports.WebRiskServiceGrpcAsyncIOTransport, ], ) @requires_google_auth_lt_1_25_0 def test_web_risk_service_transport_auth_adc_old_google_auth(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) @pytest.mark.parametrize( "transport_class,grpc_helpers", [ (transports.WebRiskServiceGrpcTransport, grpc_helpers), (transports.WebRiskServiceGrpcAsyncIOTransport, grpc_helpers_async), ], ) def test_web_risk_service_transport_create_channel(transport_class, grpc_helpers): # If credentials and host are not provided, the transport class should use # ADC credentials. with mock.patch.object( google.auth, "default", autospec=True ) as adc, mock.patch.object( grpc_helpers, "create_channel", autospec=True ) as create_channel: creds = ga_credentials.AnonymousCredentials() adc.return_value = (creds, None) transport_class(quota_project_id="octopus", scopes=["1", "2"]) create_channel.assert_called_with( "webrisk.googleapis.com:443", credentials=creds, credentials_file=None, quota_project_id="octopus", default_scopes=("https://www.googleapis.com/auth/cloud-platform",), scopes=["1", "2"], default_host="webrisk.googleapis.com", ssl_credentials=None, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], ) @pytest.mark.parametrize( "transport_class", [ transports.WebRiskServiceGrpcTransport, transports.WebRiskServiceGrpcAsyncIOTransport, ], ) def test_web_risk_service_grpc_transport_client_cert_source_for_mtls(transport_class): cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: mock_ssl_channel_creds = mock.Mock() transport_class( host="squid.clam.whelk", credentials=cred, ssl_channel_credentials=mock_ssl_channel_creds, ) mock_create_channel.assert_called_once_with( "squid.clam.whelk:443", credentials=cred, credentials_file=None, scopes=("https://www.googleapis.com/auth/cloud-platform",), ssl_credentials=mock_ssl_channel_creds, quota_project_id=None, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], ) # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls # is used. with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: transport_class( credentials=cred, client_cert_source_for_mtls=client_cert_source_callback, ) expected_cert, expected_key = client_cert_source_callback() mock_ssl_cred.assert_called_once_with( certificate_chain=expected_cert, private_key=expected_key ) def test_web_risk_service_host_no_port(): client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="webrisk.googleapis.com" ), ) assert client.transport._host == "webrisk.googleapis.com:443" def test_web_risk_service_host_with_port(): client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="webrisk.googleapis.com:8000" ), ) assert client.transport._host == "webrisk.googleapis.com:8000" def test_web_risk_service_grpc_transport_channel(): channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.WebRiskServiceGrpcTransport( host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" assert transport._ssl_channel_credentials == None def test_web_risk_service_grpc_asyncio_transport_channel(): channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.WebRiskServiceGrpcAsyncIOTransport( host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" assert transport._ssl_channel_credentials == None # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. @pytest.mark.parametrize( "transport_class", [ transports.WebRiskServiceGrpcTransport, transports.WebRiskServiceGrpcAsyncIOTransport, ], ) def test_web_risk_service_transport_channel_mtls_with_client_cert_source( transport_class, ): with mock.patch( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", api_mtls_endpoint="mtls.squid.clam.whelk", client_cert_source=client_cert_source_callback, ) adc.assert_called_once() grpc_ssl_channel_cred.assert_called_once_with( certificate_chain=b"cert bytes", private_key=b"key bytes" ) grpc_create_channel.assert_called_once_with( "mtls.squid.clam.whelk:443", credentials=cred, credentials_file=None, scopes=("https://www.googleapis.com/auth/cloud-platform",), ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], ) assert transport.grpc_channel == mock_grpc_channel assert transport._ssl_channel_credentials == mock_ssl_cred # Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are # removed from grpc/grpc_asyncio transport constructor. @pytest.mark.parametrize( "transport_class", [ transports.WebRiskServiceGrpcTransport, transports.WebRiskServiceGrpcAsyncIOTransport, ], ) def test_web_risk_service_transport_channel_mtls_with_adc(transport_class): mock_ssl_cred = mock.Mock() with mock.patch.multiple( "google.auth.transport.grpc.SslCredentials", __init__=mock.Mock(return_value=None), ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel mock_cred = mock.Mock() with pytest.warns(DeprecationWarning): transport = transport_class( host="squid.clam.whelk", credentials=mock_cred, api_mtls_endpoint="mtls.squid.clam.whelk", client_cert_source=None, ) grpc_create_channel.assert_called_once_with( "mtls.squid.clam.whelk:443", credentials=mock_cred, credentials_file=None, scopes=("https://www.googleapis.com/auth/cloud-platform",), ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ ("grpc.max_send_message_length", -1), ("grpc.max_receive_message_length", -1), ], ) assert transport.grpc_channel == mock_grpc_channel def test_common_billing_account_path(): billing_account = "squid" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) actual = WebRiskServiceClient.common_billing_account_path(billing_account) assert expected == actual def test_parse_common_billing_account_path(): expected = { "billing_account": "clam", } path = WebRiskServiceClient.common_billing_account_path(**expected) # Check that the path construction is reversible. actual = WebRiskServiceClient.parse_common_billing_account_path(path) assert expected == actual def test_common_folder_path(): folder = "whelk" expected = "folders/{folder}".format(folder=folder,) actual = WebRiskServiceClient.common_folder_path(folder) assert expected == actual def test_parse_common_folder_path(): expected = { "folder": "octopus", } path = WebRiskServiceClient.common_folder_path(**expected) # Check that the path construction is reversible. actual = WebRiskServiceClient.parse_common_folder_path(path) assert expected == actual def test_common_organization_path(): organization = "oyster" expected = "organizations/{organization}".format(organization=organization,) actual = WebRiskServiceClient.common_organization_path(organization) assert expected == actual def test_parse_common_organization_path(): expected = { "organization": "nudibranch", } path = WebRiskServiceClient.common_organization_path(**expected) # Check that the path construction is reversible. actual = WebRiskServiceClient.parse_common_organization_path(path) assert expected == actual def test_common_project_path(): project = "cuttlefish" expected = "projects/{project}".format(project=project,) actual = WebRiskServiceClient.common_project_path(project) assert expected == actual def test_parse_common_project_path(): expected = { "project": "mussel", } path = WebRiskServiceClient.common_project_path(**expected) # Check that the path construction is reversible. actual = WebRiskServiceClient.parse_common_project_path(path) assert expected == actual def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) actual = WebRiskServiceClient.common_location_path(project, location) assert expected == actual def test_parse_common_location_path(): expected = { "project": "scallop", "location": "abalone", } path = WebRiskServiceClient.common_location_path(**expected) # Check that the path construction is reversible. actual = WebRiskServiceClient.parse_common_location_path(path) assert expected == actual def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( transports.WebRiskServiceTransport, "_prep_wrapped_messages" ) as prep: client = WebRiskServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) with mock.patch.object( transports.WebRiskServiceTransport, "_prep_wrapped_messages" ) as prep: transport_class = WebRiskServiceClient.get_transport_class() transport = transport_class( credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 25455, 4475, 20376, 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, 199, 646, 747, 199, 646, 1683, 199, 646, 27369, 14, 1023, 199, 199, 646, 19753, 199, 504, 19753, 14, 18924, 492, 282, 2308, 199, 646, 3473, 199, 646, 4613, 199, 504, 4104, 14, 18376, 14, 4423, 14, 9356, 492, 31836, 5065, 12, 18267, 5065, 421, 199, 504, 6233, 14, 1246, 63, 1018, 492, 1890, 63, 1419, 199, 504, 6233, 14, 1246, 63, 1018, 492, 4967, 465, 6170, 63, 3924, 199, 504, 6233, 14, 1246, 63, 1018, 492, 16301, 530, 63, 86, 17, 199, 504, 6233, 14, 1246, 63, 1018, 492, 19753, 63, 7546, 199, 504, 6233, 14, 1246, 63, 1018, 492, 19753, 63, 7546, 63, 4146, 199, 504, 6233, 14, 1178, 492, 6235, 465, 16072, 63, 6942, 199, 504, 6233, 14, 1178, 14, 3924, 492, 26550, 1061, 10224, 5358, 547, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 5950, 14, 2520, 63, 27473, 63, 1364, 492, 6001, 50, 28600, 3167, 12807, 3041, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 5950, 14, 2520, 63, 27473, 63, 1364, 492, 6001, 50, 28600, 3167, 3041, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 5950, 14, 2520, 63, 27473, 63, 1364, 492, 7773, 83, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 5950, 14, 2520, 63, 27473, 63, 1364, 14, 5545, 83, 14, 1095, 492, 334, 272, 485, 24243, 63, 5580, 63, 4612, 12, 199, 9, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 1313, 492, 3330, 27473, 199, 504, 6233, 14, 6126, 18, 492, 2435, 63, 2048, 199, 504, 6233, 14, 7204, 492, 4913, 63, 3317, 18, 221, 327, 730, 26, 3686, 199, 646, 6233, 14, 1178, 421, 199, 3, 3254, 8, 5610, 1778, 1017, 304, 19468, 6233, 13, 1178, 2356, 413, 14, 821, 14, 16, 365, 1415, 7115, 338, 9462, 199, 3, 4012, 6233, 13, 1246, 13, 1018, 26, 199, 3, 446, 8496, 314, 1790, 298, 2003, 2419, 2, 511, 5560, 199, 3, 446, 8496, 3520, 4613, 14327, 334, 5483, 314, 298, 13154, 2419, 503, 4472, 370, 2, 2295, 314, 849, 680, 199, 6537, 63, 3098, 63, 1178, 63, 4116, 63, 17, 63, 821, 63, 16, 275, 4613, 14, 1657, 14, 22696, 8, 272, 27369, 14, 1023, 14, 1122, 1547, 24243, 63, 5580, 63, 4612, 9, 2356, 27369, 14, 1023, 14, 1122, 480, 17, 14, 821, 14, 16, 1288, 272, 4499, 628, 2765, 511, 5074, 6233, 13, 1178, 665, 413, 14, 821, 14, 16, 401, 199, 9, 199, 6537, 63, 3098, 63, 1178, 63, 19586, 63, 17, 63, 821, 63, 16, 275, 4613, 14, 1657, 14, 22696, 8, 272, 27369, 14, 1023, 14, 1122, 1547, 24243, 63, 5580, 63, 4612, 9, 665, 27369, 14, 1023, 14, 1122, 480, 17, 14, 821, 14, 16, 1288, 272, 4499, 628, 2765, 511, 5074, 6233, 13, 1178, 2356, 413, 14, 821, 14, 16, 401, 199, 9, 421, 199, 318, 1890, 63, 4736, 63, 1365, 63, 3058, 837, 272, 372, 330, 2, 4736, 2783, 401, 330, 2, 498, 2783, 2, 421, 199, 3, 982, 849, 6037, 365, 11667, 12, 2066, 849, 333, 9945, 6037, 911, 506, 314, 2011, 14, 199, 3, 961, 1083, 26473, 314, 849, 6037, 880, 314, 1890, 883, 7389, 282, 3365, 199, 3, 333, 9945, 6037, 367, 6037, 5343, 12901, 14, 199, 318, 2811, 63, 885, 63, 6520, 8, 1258, 304, 272, 372, 334, 267, 298, 1421, 14, 17533, 14, 957, 2, 267, 340, 1689, 5967, 2, 315, 1890, 14, 3472, 63, 21054, 9, 267, 587, 1890, 14, 3472, 63, 21054, 272, 776, 421, 199, 318, 511, 363, 362, 63, 885, 63, 2037, 478, 63, 6520, 837, 272, 2986, 63, 6520, 275, 298, 2694, 14, 17533, 14, 957, 2, 272, 2986, 63, 2037, 478, 63, 6520, 275, 298, 2694, 14, 2037, 478, 14, 17533, 14, 957, 2, 272, 19699, 63, 6520, 275, 298, 2694, 14, 16647, 14, 17533, 14, 957, 2, 272, 19699, 63, 2037, 478, 63, 6520, 275, 298, 2694, 14, 2037, 478, 14, 16647, 14, 17533, 14, 957, 2, 272, 2222, 63, 3098, 1246, 275, 298, 1246, 14, 2694, 14, 957, 2, 339, 702, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 403, 9, 365, 488, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 1246, 63, 6520, 9, 267, 508, 2986, 63, 2037, 478, 63, 6520, 272, 776, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 1246, 63, 2037, 478, 63, 6520, 9, 267, 508, 2986, 63, 2037, 478, 63, 6520, 272, 776, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 16647, 63, 6520, 9, 267, 508, 19699, 63, 2037, 478, 63, 6520, 272, 776, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 16647, 63, 2037, 478, 63, 6520, 9, 267, 508, 19699, 63, 2037, 478, 63, 6520, 272, 776, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 2865, 63, 3098, 1246, 9, 508, 2222, 63, 3098, 1246, 272, 776, 421, 199, 32, 4462, 14, 1657 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 25455, 4475, 20376, 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, 199, 646, 747, 199, 646, 1683, 199, 646, 27369, 14, 1023, 199, 199, 646, 19753, 199, 504, 19753, 14, 18924, 492, 282, 2308, 199, 646, 3473, 199, 646, 4613, 199, 504, 4104, 14, 18376, 14, 4423, 14, 9356, 492, 31836, 5065, 12, 18267, 5065, 421, 199, 504, 6233, 14, 1246, 63, 1018, 492, 1890, 63, 1419, 199, 504, 6233, 14, 1246, 63, 1018, 492, 4967, 465, 6170, 63, 3924, 199, 504, 6233, 14, 1246, 63, 1018, 492, 16301, 530, 63, 86, 17, 199, 504, 6233, 14, 1246, 63, 1018, 492, 19753, 63, 7546, 199, 504, 6233, 14, 1246, 63, 1018, 492, 19753, 63, 7546, 63, 4146, 199, 504, 6233, 14, 1178, 492, 6235, 465, 16072, 63, 6942, 199, 504, 6233, 14, 1178, 14, 3924, 492, 26550, 1061, 10224, 5358, 547, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 5950, 14, 2520, 63, 27473, 63, 1364, 492, 6001, 50, 28600, 3167, 12807, 3041, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 5950, 14, 2520, 63, 27473, 63, 1364, 492, 6001, 50, 28600, 3167, 3041, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 5950, 14, 2520, 63, 27473, 63, 1364, 492, 7773, 83, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 5950, 14, 2520, 63, 27473, 63, 1364, 14, 5545, 83, 14, 1095, 492, 334, 272, 485, 24243, 63, 5580, 63, 4612, 12, 199, 9, 199, 504, 6233, 14, 4091, 14, 2520, 27473, 63, 86, 17, 14, 1313, 492, 3330, 27473, 199, 504, 6233, 14, 6126, 18, 492, 2435, 63, 2048, 199, 504, 6233, 14, 7204, 492, 4913, 63, 3317, 18, 221, 327, 730, 26, 3686, 199, 646, 6233, 14, 1178, 421, 199, 3, 3254, 8, 5610, 1778, 1017, 304, 19468, 6233, 13, 1178, 2356, 413, 14, 821, 14, 16, 365, 1415, 7115, 338, 9462, 199, 3, 4012, 6233, 13, 1246, 13, 1018, 26, 199, 3, 446, 8496, 314, 1790, 298, 2003, 2419, 2, 511, 5560, 199, 3, 446, 8496, 3520, 4613, 14327, 334, 5483, 314, 298, 13154, 2419, 503, 4472, 370, 2, 2295, 314, 849, 680, 199, 6537, 63, 3098, 63, 1178, 63, 4116, 63, 17, 63, 821, 63, 16, 275, 4613, 14, 1657, 14, 22696, 8, 272, 27369, 14, 1023, 14, 1122, 1547, 24243, 63, 5580, 63, 4612, 9, 2356, 27369, 14, 1023, 14, 1122, 480, 17, 14, 821, 14, 16, 1288, 272, 4499, 628, 2765, 511, 5074, 6233, 13, 1178, 665, 413, 14, 821, 14, 16, 401, 199, 9, 199, 6537, 63, 3098, 63, 1178, 63, 19586, 63, 17, 63, 821, 63, 16, 275, 4613, 14, 1657, 14, 22696, 8, 272, 27369, 14, 1023, 14, 1122, 1547, 24243, 63, 5580, 63, 4612, 9, 665, 27369, 14, 1023, 14, 1122, 480, 17, 14, 821, 14, 16, 1288, 272, 4499, 628, 2765, 511, 5074, 6233, 13, 1178, 2356, 413, 14, 821, 14, 16, 401, 199, 9, 421, 199, 318, 1890, 63, 4736, 63, 1365, 63, 3058, 837, 272, 372, 330, 2, 4736, 2783, 401, 330, 2, 498, 2783, 2, 421, 199, 3, 982, 849, 6037, 365, 11667, 12, 2066, 849, 333, 9945, 6037, 911, 506, 314, 2011, 14, 199, 3, 961, 1083, 26473, 314, 849, 6037, 880, 314, 1890, 883, 7389, 282, 3365, 199, 3, 333, 9945, 6037, 367, 6037, 5343, 12901, 14, 199, 318, 2811, 63, 885, 63, 6520, 8, 1258, 304, 272, 372, 334, 267, 298, 1421, 14, 17533, 14, 957, 2, 267, 340, 1689, 5967, 2, 315, 1890, 14, 3472, 63, 21054, 9, 267, 587, 1890, 14, 3472, 63, 21054, 272, 776, 421, 199, 318, 511, 363, 362, 63, 885, 63, 2037, 478, 63, 6520, 837, 272, 2986, 63, 6520, 275, 298, 2694, 14, 17533, 14, 957, 2, 272, 2986, 63, 2037, 478, 63, 6520, 275, 298, 2694, 14, 2037, 478, 14, 17533, 14, 957, 2, 272, 19699, 63, 6520, 275, 298, 2694, 14, 16647, 14, 17533, 14, 957, 2, 272, 19699, 63, 2037, 478, 63, 6520, 275, 298, 2694, 14, 2037, 478, 14, 16647, 14, 17533, 14, 957, 2, 272, 2222, 63, 3098, 1246, 275, 298, 1246, 14, 2694, 14, 957, 2, 339, 702, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 403, 9, 365, 488, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 1246, 63, 6520, 9, 267, 508, 2986, 63, 2037, 478, 63, 6520, 272, 776, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 1246, 63, 2037, 478, 63, 6520, 9, 267, 508, 2986, 63, 2037, 478, 63, 6520, 272, 776, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 16647, 63, 6520, 9, 267, 508, 19699, 63, 2037, 478, 63, 6520, 272, 776, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 16647, 63, 2037, 478, 63, 6520, 9, 267, 508, 19699, 63, 2037, 478, 63, 6520, 272, 776, 272, 702, 334, 267, 6001, 50, 28600, 3167, 3041, 423, 362, 63, 885, 63, 2037, 478, 63, 6520, 8, 2865, 63, 3098, 1246, 9, 508, 2222, 63, 3098, 1246, 272, 776, 421, 199, 32, 4462, 14, 1657, 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,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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 ]
ydirson/serna-free
serna/docutils/migration/check-text.py
5
2973
## ## Copyright(c) 2009 Syntext, Inc. All Rights Reserved. ## Contact: info@syntext.com, http://www.syntext.com ## ## This file is part of Syntext Serna XML Editor. ## ## COMMERCIAL USAGE ## Licensees holding valid Syntext Serna commercial licenses may use this file ## in accordance with the Syntext Serna Commercial License Agreement provided ## with the software, or, alternatively, in accorance with the terms contained ## in a written agreement between you and Syntext, Inc. ## ## GNU GENERAL PUBLIC LICENSE USAGE ## Alternatively, this file may be used under the terms of the GNU General ## Public License versions 2.0 or 3.0 as published by the Free Software ## Foundation and appearing in the file LICENSE.GPL included in the packaging ## of this file. In addition, as a special exception, Syntext, Inc. gives you ## certain additional rights, which are described in the Syntext, Inc. GPL ## Exception for Syntext Serna Free Edition, included in the file ## GPL_EXCEPTION.txt in this package. ## ## You should have received a copy of appropriate licenses along with this ## package. If not, see <http://www.syntext.com/legal/>. If you are unsure ## which license is appropriate for your use, please contact the sales ## department at sales@syntext.com. ## ## This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ## WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ## #!/usr/bin/python import sys, os, re class textfile: wordre = re.compile(r"\w+", re.M) def __init__(self, name): self.name_ = name self.stat_ = os.stat(self.name_) def __getattr__(self, name): if name == 'st_name': return self.name_.replace('.text', '') elif name == 'st_words': if not hasattr(self, "wordcount_"): self.wordcount_ = self.count_words() return self.wordcount_ elif hasattr(self.stat_, name): return getattr(self.stat_, name) raise AttributeError def unlink(self): os.unlink(self.name_) def count_words(self): return len(self.wordre.findall(open(self.name_, "r").read())) mark = " Wrote to " def pct(x,y): return abs(100*(x-y)/x) for line in sys.stdin: if line.startswith(mark): lhs, rhs = [ textfile(x.strip()) for x in line[len(mark):].split(',') ] if lhs.st_size and rhs.st_size: diff = pct(lhs.st_size, rhs.st_size) print '\n'.join(["%s%s%s%s"]*3) % tuple([str(x).ljust(16) for x in \ (' ', lhs.st_name, rhs.st_name, 'diff(%)', 'bytes', lhs.st_size, rhs.st_size, diff, 'words', lhs.st_words, rhs.st_words, pct(lhs.st_words, rhs.st_words))]) print lhs.unlink() rhs.unlink() if diff > 1: print >> sys.stderr, "Difference is %d%%" % diff sys.exit(-1)
gpl-3.0
[ 309, 221, 199, 309, 1898, 8, 67, 9, 8937, 29988, 505, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 309, 18684, 26, 2256, 32, 9466, 505, 14, 957, 12, 1455, 921, 1544, 14, 9466, 505, 14, 957, 199, 309, 221, 199, 309, 961, 570, 365, 1777, 402, 29988, 505, 3739, 3540, 4692, 30318, 14, 199, 309, 221, 199, 309, 31457, 19635, 2962, 199, 309, 844, 397, 17573, 1686, 29988, 505, 3739, 3540, 2414, 23012, 12378, 1443, 675, 642, 570, 199, 309, 315, 1066, 1577, 554, 543, 314, 29988, 505, 3739, 3540, 5429, 23012, 844, 28629, 2741, 199, 309, 543, 314, 2032, 12, 503, 12, 8679, 17330, 12, 315, 1066, 989, 554, 543, 314, 2895, 10470, 199, 309, 315, 282, 5313, 25025, 3382, 1265, 436, 29988, 505, 12, 3277, 14, 199, 309, 221, 199, 309, 1664, 29087, 748, 21755, 5113, 19635, 2962, 199, 309, 26776, 12, 642, 570, 1443, 506, 1202, 1334, 314, 2895, 402, 314, 1664, 1696, 221, 199, 309, 1684, 844, 5459, 499, 14, 16, 503, 650, 14, 16, 465, 3267, 701, 314, 2868, 2290, 221, 199, 309, 2752, 436, 7468, 316, 315, 314, 570, 5113, 14, 12006, 5120, 315, 314, 27369, 221, 199, 309, 402, 642, 570, 14, 1010, 10234, 12, 465, 282, 4539, 1919, 12, 29988, 505, 12, 3277, 14, 10557, 1265, 199, 309, 9842, 4722, 4481, 12, 1314, 787, 11736, 315, 314, 29988, 505, 12, 3277, 14, 14629, 221, 199, 309, 2186, 367, 29988, 505, 3739, 3540, 2868, 662, 1671, 12, 5120, 315, 314, 570, 221, 199, 309, 14629, 63, 15375, 14, 2424, 315, 642, 2559, 14, 199, 309, 221, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 5827, 12378, 3180, 543, 642, 221, 199, 309, 2559, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 9466, 505, 14, 957, 15, 9666, 4743, 982, 1265, 787, 625, 3253, 199, 309, 1314, 4190, 365, 5827, 367, 2195, 675, 12, 8749, 8966, 314, 21702, 221, 199, 309, 27669, 737, 21702, 32, 9466, 505, 14, 957, 14, 199, 309, 221, 199, 309, 961, 570, 365, 2741, 4319, 2281, 543, 4825, 3408, 1634, 1821, 3826, 12, 6931, 2334, 199, 309, 3408, 1634, 11758, 3203, 12, 3169, 2401, 3092, 2381, 437, 3115, 3104, 14, 199, 309, 221, 199, 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 984, 12, 747, 12, 295, 199, 199, 533, 1318, 493, 26, 272, 4349, 264, 275, 295, 14, 2014, 8, 82, 3212, 87, 22758, 295, 14, 45, 9, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 63, 275, 536, 267, 291, 14, 3736, 63, 275, 747, 14, 3736, 8, 277, 14, 354, 4602, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 536, 508, 283, 270, 63, 354, 356, 288, 372, 291, 14, 354, 3754, 1814, 5175, 505, 297, 4074, 267, 916, 536, 508, 283, 270, 63, 3148, 356, 288, 340, 440, 2688, 8, 277, 12, 298, 1027, 835, 63, 2349, 355, 291, 14, 1027, 835, 63, 275, 291, 14, 835, 63, 3148, 342, 288, 372, 291, 14, 1027, 835, 63, 267, 916, 2688, 8, 277, 14, 3736, 3131, 536, 304, 288, 372, 2519, 8, 277, 14, 3736, 3131, 536, 9, 267, 746, 4281, 339, 347, 17002, 8, 277, 304, 267, 747, 14, 7162, 8, 277, 14, 354, 4602, 339, 347, 2338, 63, 3148, 8, 277, 304, 267, 372, 822, 8, 277, 14, 1027, 264, 14, 6452, 8, 1490, 8, 277, 14, 354, 3131, 298, 82, 3471, 739, 4059, 199, 199, 1657, 275, 298, 221, 644, 22665, 370, 298, 199, 199, 318, 299, 319, 8, 88, 12, 89, 304, 372, 2853, 8, 1960, 5830, 88, 13, 89, 2447, 88, 9, 199, 199, 509, 1004, 315, 984, 14, 6626, 26, 272, 340, 1004, 14, 2460, 8, 1657, 304, 267, 13180, 12, 9085, 275, 359, 1318, 493, 8, 88, 14, 1913, 1012, 2151, 367, 671, 315, 1004, 59, 552, 8, 1657, 304, 1055, 1294, 11917, 1622, 267, 340, 13180, 14, 270, 63, 890, 436, 9085, 14, 270, 63, 890, 26, 288, 3915, 275, 299, 319, 8, 12697, 14, 270, 63, 890, 12, 9085, 14, 270, 63, 890, 9, 288, 870, 1557, 78, 1370, 904, 30387, 83, 5, 83, 5, 83, 5, 83, 937, 10, 19, 9, 450, 2008, 779, 495, 8, 88, 680, 19996, 8, 975, 9, 367, 671, 315, 971, 355, 661, 1656, 13180, 14, 270, 63, 354, 12, 9085, 14, 270, 63, 354, 12, 283, 3028, 4042, 3196, 326, 283, 2394, 297, 13180, 14, 270, 63, 890, 12, 9085, 14, 270, 63, 890, 12, 3915, 12, 326, 283, 3148, 297, 13180, 14, 270, 63, 3148, 12, 9085, 14, 270, 63, 3148, 12, 490, 299, 319, 8, 12697, 14, 270, 63, 3148, 12, 9085, 14, 270, 63, 3148, 18229, 288, 870, 288, 13180, 14, 7162, 342, 288, 9085, 14, 7162, 342, 288, 340, 3915, 690, 413, 26, 355, 870, 4331, 984, 14, 3083, 12, 298, 32279, 365, 450, 68, 8530, 2, 450, 3915, 355, 984, 14, 2224, 2801, 17, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 221, 199, 309, 1898, 8, 67, 9, 8937, 29988, 505, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 309, 18684, 26, 2256, 32, 9466, 505, 14, 957, 12, 1455, 921, 1544, 14, 9466, 505, 14, 957, 199, 309, 221, 199, 309, 961, 570, 365, 1777, 402, 29988, 505, 3739, 3540, 4692, 30318, 14, 199, 309, 221, 199, 309, 31457, 19635, 2962, 199, 309, 844, 397, 17573, 1686, 29988, 505, 3739, 3540, 2414, 23012, 12378, 1443, 675, 642, 570, 199, 309, 315, 1066, 1577, 554, 543, 314, 29988, 505, 3739, 3540, 5429, 23012, 844, 28629, 2741, 199, 309, 543, 314, 2032, 12, 503, 12, 8679, 17330, 12, 315, 1066, 989, 554, 543, 314, 2895, 10470, 199, 309, 315, 282, 5313, 25025, 3382, 1265, 436, 29988, 505, 12, 3277, 14, 199, 309, 221, 199, 309, 1664, 29087, 748, 21755, 5113, 19635, 2962, 199, 309, 26776, 12, 642, 570, 1443, 506, 1202, 1334, 314, 2895, 402, 314, 1664, 1696, 221, 199, 309, 1684, 844, 5459, 499, 14, 16, 503, 650, 14, 16, 465, 3267, 701, 314, 2868, 2290, 221, 199, 309, 2752, 436, 7468, 316, 315, 314, 570, 5113, 14, 12006, 5120, 315, 314, 27369, 221, 199, 309, 402, 642, 570, 14, 1010, 10234, 12, 465, 282, 4539, 1919, 12, 29988, 505, 12, 3277, 14, 10557, 1265, 199, 309, 9842, 4722, 4481, 12, 1314, 787, 11736, 315, 314, 29988, 505, 12, 3277, 14, 14629, 221, 199, 309, 2186, 367, 29988, 505, 3739, 3540, 2868, 662, 1671, 12, 5120, 315, 314, 570, 221, 199, 309, 14629, 63, 15375, 14, 2424, 315, 642, 2559, 14, 199, 309, 221, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 5827, 12378, 3180, 543, 642, 221, 199, 309, 2559, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 9466, 505, 14, 957, 15, 9666, 4743, 982, 1265, 787, 625, 3253, 199, 309, 1314, 4190, 365, 5827, 367, 2195, 675, 12, 8749, 8966, 314, 21702, 221, 199, 309, 27669, 737, 21702, 32, 9466, 505, 14, 957, 14, 199, 309, 221, 199, 309, 961, 570, 365, 2741, 4319, 2281, 543, 4825, 3408, 1634, 1821, 3826, 12, 6931, 2334, 199, 309, 3408, 1634, 11758, 3203, 12, 3169, 2401, 3092, 2381, 437, 3115, 3104, 14, 199, 309, 221, 199, 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 984, 12, 747, 12, 295, 199, 199, 533, 1318, 493, 26, 272, 4349, 264, 275, 295, 14, 2014, 8, 82, 3212, 87, 22758, 295, 14, 45, 9, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 63, 275, 536, 267, 291, 14, 3736, 63, 275, 747, 14, 3736, 8, 277, 14, 354, 4602, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 536, 508, 283, 270, 63, 354, 356, 288, 372, 291, 14, 354, 3754, 1814, 5175, 505, 297, 4074, 267, 916, 536, 508, 283, 270, 63, 3148, 356, 288, 340, 440, 2688, 8, 277, 12, 298, 1027, 835, 63, 2349, 355, 291, 14, 1027, 835, 63, 275, 291, 14, 835, 63, 3148, 342, 288, 372, 291, 14, 1027, 835, 63, 267, 916, 2688, 8, 277, 14, 3736, 3131, 536, 304, 288, 372, 2519, 8, 277, 14, 3736, 3131, 536, 9, 267, 746, 4281, 339, 347, 17002, 8, 277, 304, 267, 747, 14, 7162, 8, 277, 14, 354, 4602, 339, 347, 2338, 63, 3148, 8, 277, 304, 267, 372, 822, 8, 277, 14, 1027, 264, 14, 6452, 8, 1490, 8, 277, 14, 354, 3131, 298, 82, 3471, 739, 4059, 199, 199, 1657, 275, 298, 221, 644, 22665, 370, 298, 199, 199, 318, 299, 319, 8, 88, 12, 89, 304, 372, 2853, 8, 1960, 5830, 88, 13, 89, 2447, 88, 9, 199, 199, 509, 1004, 315, 984, 14, 6626, 26, 272, 340, 1004, 14, 2460, 8, 1657, 304, 267, 13180, 12, 9085, 275, 359, 1318, 493, 8, 88, 14, 1913, 1012, 2151, 367, 671, 315, 1004, 59, 552, 8, 1657, 304, 1055, 1294, 11917, 1622, 267, 340, 13180, 14, 270, 63, 890, 436, 9085, 14, 270, 63, 890, 26, 288, 3915, 275, 299, 319, 8, 12697, 14, 270, 63, 890, 12, 9085, 14, 270, 63, 890, 9, 288, 870, 1557, 78, 1370, 904, 30387, 83, 5, 83, 5, 83, 5, 83, 937, 10, 19, 9, 450, 2008, 779, 495, 8, 88, 680, 19996, 8, 975, 9, 367, 671, 315, 971, 355, 661, 1656, 13180, 14, 270, 63, 354, 12, 9085, 14, 270, 63, 354, 12, 283, 3028, 4042, 3196, 326, 283, 2394, 297, 13180, 14, 270, 63, 890, 12, 9085, 14, 270, 63, 890, 12, 3915, 12, 326, 283, 3148, 297, 13180, 14, 270, 63, 3148, 12, 9085, 14, 270, 63, 3148, 12, 490, 299, 319, 8, 12697, 14, 270, 63, 3148, 12, 9085, 14, 270, 63, 3148, 18229, 288, 870, 288, 13180, 14, 7162, 342, 288, 9085, 14, 7162, 342, 288, 340, 3915, 690, 413, 26, 355, 870, 4331, 984, 14, 3083, 12, 298, 32279, 365, 450, 68, 8530, 2, 450, 3915, 355, 984, 14, 2224, 2801, 17, 9, 4388, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
kcompher/topik
topik/tokenizers.py
1
12129
from __future__ import absolute_import, print_function import logging import itertools import re from textblob import TextBlob import gensim from gensim.parsing.preprocessing import STOPWORDS from topik.utils import collocations, entities # imports used only for doctests from topik.tests import test_data_path from topik.readers import read_input logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) def tokenize_simple(text, stopwords=STOPWORDS): """A text tokenizer that simply lowercases, matches alphabetic characters and removes stopwords. Uses gensim.utils.tokenize and gensim.parsing.preprocessing.STOPWORDS. Parameters ---------- text: input text to be tokenized stopwords: words to ignore as noise >>> id_documents = read_input( ... '{}/test_data_json_stream.json'.format(test_data_path), ... content_field="abstract") >>> id, doc_text = next(iter(id_documents)) >>> doc_text == str( ... 'Transition metal oxides are being considered as the next generation ' ... 'materials in field such as electronics and advanced catalysts; between' ... ' them is Tantalum (V) Oxide; however, there are few reports for the ' ... 'synthesis of this material at the nanometer size which could have ' ... 'unusual properties. Hence, in this work we present the synthesis of ' ... 'Ta2O5 nanorods by sol gel method using DNA as structure directing ' ... 'agent, the size of the nanorods was of the order of 40 to 100 nm in ' ... 'diameter and several microns in length; this easy method can be useful' ... ' in the preparation of nanomaterials for electronics, biomedical ' ... 'applications as well as catalysts.') True >>> tokens = tokenize_simple(doc_text) >>> tokens == [ ... u'transition', u'metal', u'oxides', u'considered', u'generation', ... u'materials', u'field', u'electronics', u'advanced', u'catalysts', ... u'tantalum', u'v', u'oxide', u'reports', u'synthesis', u'material', ... u'nanometer', u'size', u'unusual', u'properties', u'work', u'present', ... u'synthesis', u'ta', u'o', u'nanorods', u'sol', u'gel', u'method', ... u'dna', u'structure', u'directing', u'agent', u'size', u'nanorods', ... u'order', u'nm', u'diameter', u'microns', u'length', u'easy', u'method', ... u'useful', u'preparation', u'nanomaterials', u'electronics', ... u'biomedical', u'applications', u'catalysts'] True """ return [word for word in gensim.utils.tokenize(text, lower=True) if word not in stopwords] def collect_bigrams_and_trigrams(collection, top_n = 10000, min_bigram_freq=50, min_trigram_freq=20, stopwords=STOPWORDS): """collects bigrams and trigrams from collection of documents. Input to collocation tokenizer. bigrams are pairs of words that recur in the collection. Parameters ---------- collection: iterable data to examine top_n: limit results to this many entries min_bigram_freq: (integer) threshold of when to consider a pair of words as a recognized bigram min_trigram_freq: (integer) threshold of when to consider a triplet of words as a recognized trigram stopwords: (iterable) collection of words to ignore in the corpus >>> raw_data = read_input( ... '{}/test_data_json_stream.json'.format(test_data_path), ... content_field="abstract") >>> bigrams, trigrams = collect_bigrams_and_trigrams(raw_data, min_bigram_freq=5, min_trigram_freq=3) >>> bigrams.pattern == str( ... '(free standing|centered cubic|spatial resolution|vapor deposition|wear' ... ' resistance|plastic deformation|electrical conductivity|field magnets|' ... 'transmission electron|ray diffraction|electron microscopy|room ' ... 'temperature|diffraction xrd|electron microscope|results indicate|' ... 'scanning electron|doped zno|microscopy tem|polymer matrix|size ' ... 'distribution|mechanical properties|grain size|high spatial|particle ' ... 'size|high resolution|high field|high strength)') True >>> trigrams.pattern == str( ... '(differential scanning calorimetry|face centered cubic|ray ' ... 'microanalysis analytical|physical vapor deposition|transmission ' ... 'electron microscopy|microanalysis analytical electron|chemical vapor ' ... 'deposition|high aspect ratio|analytical electron microscope|ray ' ... 'diffraction xrd|high spatial resolution|high field magnets|atomic ' ... 'force microscopy|electron microscopy tem|narrow size distribution|' ... 'scanning electron microscopy|building high field|silicon oxide ' ... 'nanowires)') True """ # generator of documents, turn each element to its list of words documents = (_split_words(text, stopwords) for text in collection.get_generator_without_id()) # generator, concatenate (chain) all words into a single sequence, lazily words = itertools.chain.from_iterable(documents) bigrams, trigrams = collocations(words, top_n=top_n, min_bigram_freq=min_bigram_freq, min_trigram_freq=min_trigram_freq) return bigrams, trigrams def _split_words(text, stopwords): """Split text into a list of single words. Ignore any token in the `stopwords` set. """ return [word for word in gensim.utils.tokenize(text, lower=True) if word not in stopwords and len(word) > 2] def tokenize_collocation(text, bigrams, trigrams, stopwords=STOPWORDS): """A text tokenizer that includes collocations(bigrams and trigrams). A collocation is sequence of words or terms that co-occur more often than would be expected by chance. Bigrams and trigrams must be found from the document collection a-priori. Use the collect_bigrams_and_trigrams function to do so. Uses gensim.parsing.preprocessing.STOPWORDS to remove stopwords and nltk.collocations.TrigramCollocationFinder to find trigrams and bigrams. Parameters ---------- reader: generator A generator that yields each of the documents to tokenize. (e.g. topik.readers.iter_document_json_stream) top_n: int Number of collocations to retrieve from the stream of words (order by decreasing frequency). Default is 10000 min_bigram_freq: int Minimum frequency of a bigram in order to retrieve it. Default is 50. min_trigram_freq: int Minimum frequency of a trigram in order to retrieve it. Default is 20. >>> id_documents = read_input('{}/test_data_json_stream.json'.format(test_data_path), content_field="abstract") >>> bigrams, trigrams = collect_bigrams_and_trigrams(id_documents, min_bigram_freq=2, min_trigram_freq=2) >>> id, doc_text = next(iter(id_documents)) >>> tokenized_text = tokenize_collocation(doc_text, bigrams, trigrams) >>> tokenized_text == [ ... u'transition_metal', u'oxides', u'considered', u'generation', ... u'materials', u'field', u'electronics', u'advanced', u'catalysts', ... u'tantalum', u'oxide', u'reports', u'synthesis', u'material', ... u'nanometer_size', u'unusual', u'properties', u'work_present', ... u'synthesis', u'nanorods', u'sol', u'gel', u'method', u'dna', ... u'structure', u'directing', u'agent', u'size', u'nanorods', u'order', ... u'diameter', u'microns', u'length', u'easy', u'method', u'useful', ... u'preparation', u'nanomaterials', u'electronics', u'biomedical', ... u'applications', u'catalysts'] True """ text = ' '.join(_split_words(text, stopwords)) text = re.sub(trigrams, lambda match: match.group(0).replace(' ', '_'), text) text = re.sub(bigrams, lambda match: match.group(0).replace(' ', '_'), text) return text.split() def find_entities(collection, freq_min=2, freq_max=10000): return entities(collection, freq_max=freq_max, freq_min=freq_min) def tokenize_entities(text, entities, stopwords=STOPWORDS): """A tokenizer that extracts noun phrases from text. Requires that you first establish entities Uses gensim.parsing.preprocessing.STOPWORDS. to remove stopwords and textblob.TextBlob().noun_phrases to find `noun_phrases`. Parameters ---------- reader: generator A generator that yields each of the documents to tokenize. (e.g. topik.readers.iter_document_json_stream) freq_min: int Minimum frequency of a noun phrase occurrences in order to retrieve it. Default is 2. freq_max: int Maximum frequency of a noun phrase occurrences in order to retrieve it. Default is 10000. >> id_documents = read_input('{}/test_data_json_stream.json'.format(test_data_path), "abstract") >> entities = find_entities(id_documents) >> print('entities: %r' % entities) >> len(entities) >> i = iter(id_documents) >> id, doc_text = next(i) >> doc_text >> tokenized_text = tokenize_entities(doc_text, entities) >> tokenized_text >> id, doc_text = next(i) >> doc_text >> tokenized_text = tokenize_entities(doc_text, entities) 2015-02-04 17:18:55,618 : INFO : collecting entities from <generator object iter_document_json_stream at 0x10eaf0280> 2015-02-04 17:18:55,618 : INFO : at document #0, considering 0 phrases: []... 2015-02-04 17:18:57,363 : INFO : selected 563 entities: [u'simulation examples', u'comparison trials', u'vldb', u'intelligent optimization algorithm', u'study outcomes', u'ge', u'standard program modules', u'optimization activity', u'opposite context', u'direct victimization']... >> tokenized_text [[u'rapid_solution_phase_chemical_reduction_method', u'inert_gas_protection', u'stable_copper_nanoparticle_colloid', u'average_particle_size', u'narrow_size_distribution', u'synthesis_route', u'ascorbic_acid', u'natural_vitamin_c', u'vc', u'copper_salt_precursor', u'general_oxidation_process', u'newborn_nanoparticles', u'xrd', u'uv_vis', u'copper_nanoparticles', u'excellent_antioxidant_ability', u'ascorbic_acid']] """ result = [] for np in TextBlob(text).noun_phrases: if np not in entities: # only consider phrases detected in entities (with frequency parameters) continue token = '_'.join(part for part in gensim.utils.tokenize(np)) if len(token) < 2 or token in stopwords: # ignore very short phrases and stop words continue result.append(token) return result def tokenize_mixed(text, entities, stopwords=STOPWORDS): """A text tokenizer that retrieves entities ('noun phrases') first and simple words for the rest of the text. Parameters ---------- reader: generator A generator that yields each of the documents to tokenize. (e.g. topik.readers.iter_document_json_stream) >>> raw_data = read_input('{}/test_data_json_stream.json'.format(test_data_path), content_field="abstract") >>> entities = find_entities(raw_data) >>> id, text = next(iter(raw_data)) >>> tokenized_text = tokenize_mixed(text, entities) """ result = [] for np in TextBlob(text).noun_phrases: if ' ' in np and np not in entities: tokens = [word for word in gensim.utils.tokenize(np, lower=True) if word not in stopwords] result.extend(tokens) else: token = '_'.join(part for part in gensim.utils.tokenize(np) if len(part) > 2) if len(token) < 2 or token in stopwords: # ignore very short phrases and stop words continue result.append(token) return result # Add additional methods here as necessary to expose them to outside consumers. tokenizer_methods = {"simple": tokenize_simple, "collocation": tokenize_collocation, "entities": tokenize_entities, "mixed": tokenize_mixed }
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2050, 199, 646, 7975, 199, 646, 295, 199, 199, 504, 1318, 6582, 492, 4516, 16799, 199, 646, 3805, 5206, 199, 504, 3805, 5206, 14, 11059, 14, 21402, 492, 22348, 19984, 199, 199, 504, 370, 1038, 75, 14, 1208, 492, 1048, 8022, 12, 9045, 199, 199, 3, 8925, 1202, 1454, 367, 26721, 199, 504, 370, 1038, 75, 14, 2219, 492, 511, 63, 576, 63, 515, 199, 504, 370, 1038, 75, 14, 27056, 492, 1586, 63, 1210, 421, 199, 4806, 14, 19602, 8, 908, 29342, 18331, 9, 83, 520, 2818, 20056, 9, 83, 520, 2818, 1188, 9, 83, 297, 15324, 2166, 29, 4806, 14, 4531, 9, 421, 199, 318, 13343, 63, 4129, 8, 505, 12, 3631, 3148, 29, 11632, 19984, 304, 272, 408, 33, 1318, 14803, 626, 9329, 5117, 9403, 12, 4450, 23331, 764, 272, 4110, 436, 14185, 3631, 3148, 14, 272, 14911, 3805, 5206, 14, 1208, 14, 15246, 436, 3805, 5206, 14, 11059, 14, 21402, 14, 11632, 19984, 14, 339, 3897, 272, 4143, 272, 1318, 26, 1324, 1318, 370, 506, 1526, 1759, 272, 3631, 3148, 26, 5932, 370, 3686, 465, 11145, 339, 1306, 1305, 63, 12233, 275, 1586, 63, 1210, 8, 272, 2263, 463, 9005, 15, 396, 63, 576, 63, 1001, 63, 1745, 14, 1001, 1370, 908, 8, 396, 63, 576, 63, 515, 395, 272, 2263, 463, 1564, 63, 698, 628, 6198, 531, 272, 1306, 1305, 12, 1382, 63, 505, 275, 2163, 8, 1661, 8, 344, 63, 12233, 430, 272, 1306, 1382, 63, 505, 508, 620, 8, 272, 2263, 283, 21881, 7647, 279, 312, 88, 2655, 83, 787, 3769, 8652, 465, 314, 2163, 10152, 283, 272, 2263, 283, 23231, 315, 901, 4066, 465, 325, 16728, 2932, 436, 19472, 6230, 2618, 10329, 27, 3382, 7, 272, 2263, 283, 3062, 365, 377, 867, 279, 453, 334, 54, 9, 593, 88, 2655, 27, 13432, 12, 2337, 787, 9284, 13924, 367, 314, 283, 272, 2263, 283, 9466, 14925, 402, 642, 6285, 737, 314, 12055, 1377, 351, 1568, 1314, 4293, 1172, 283, 272, 2263, 283, 324, 527, 1061, 4382, 14, 869, 4894, 12, 315, 642, 1736, 781, 3451, 314, 9560, 14925, 402, 283, 272, 2263, 283, 22620, 18, 47, 21, 12055, 269, 364, 83, 701, 8597, 2312, 76, 1083, 1808, 577, 7170, 465, 5523, 4125, 316, 283, 272, 2263, 283, 4054, 12, 314, 1568, 402, 314, 12055, 269, 364, 83, 1990, 402, 314, 1865, 402, 6335, 370, 2948, 16751, 315, 283, 272, 2263, 283, 328, 1787, 436, 9978, 333, 530, 2641, 83, 315, 2582, 27, 642, 8837, 1083, 883, 506, 2997, 7, 272, 2263, 283, 315, 314, 876, 462, 425, 402, 12055, 676, 4428, 83, 367, 325, 16728, 2932, 12, 12111, 1377, 328, 915, 283, 272, 2263, 283, 15853, 465, 5521, 465, 6230, 2618, 10329, 2659, 272, 715, 272, 1306, 4645, 275, 13343, 63, 4129, 8, 1301, 63, 505, 9, 272, 1306, 4645, 508, 359, 272, 2263, 399, 1133, 1312, 1588, 297, 399, 6704, 386, 279, 297, 399, 7, 19131, 2655, 83, 297, 399, 7, 388, 2441, 581, 297, 399, 7, 15043, 297, 272, 2263, 399, 6704, 4428, 83, 297, 399, 7, 698, 297, 399, 7, 30169, 2932, 297, 399, 7, 14652, 297, 399, 7, 3385, 2618, 10329, 297, 272, 2263, 399, 1133, 867, 279, 453, 297, 399, 7, 86, 297, 399, 7, 19131, 2655, 297, 399, 3984, 5203, 297, 399, 1159, 1236, 14925, 297, 399, 6704, 4428, 297, 272, 2263, 399, 7, 4304, 1377, 351, 297, 399, 1159, 794, 297, 399, 7, 324, 527, 1061, 297, 399, 7, 3282, 297, 399, 7, 800, 297, 399, 7, 1881, 297, 272, 2263, 399, 1159, 1236, 14925, 297, 399, 1133, 65, 297, 399, 7, 79, 297, 399, 7, 4304, 269, 364, 83, 297, 399, 1159, 393, 297, 399, 7, 24920, 297, 399, 6704, 69, 594, 297, 272, 2263, 399, 5121, 3540, 297, 399, 1159, 454, 918, 608, 297, 399, 5121, 73, 1201, 316, 297, 399, 7, 4054, 297, 399, 1159, 794, 297, 399, 7, 4304, 269, 364, 83, 297, 272, 2263, 399, 7, 1648, 297, 399, 7, 10756, 297, 399, 5121, 73, 1787, 297, 399, 6704, 530, 2641, 83, 297, 399, 7, 1267, 297, 399, 7, 13581, 297, 399, 6704, 69, 594, 297, 272, 2263, 399, 7, 1180, 1893, 297, 399, 7, 657, 462, 425, 297, 399, 7, 4304, 676, 4428, 83, 297, 399, 7, 30169, 2932, 297, 272, 2263, 399, 7, 4492, 1377, 328, 915, 297, 399, 7, 15853, 297, 399, 7, 3385, 2618, 10329, 418, 272, 715, 272, 408, 272, 372, 359, 1027, 367, 4349, 315, 3805, 5206, 14, 1208, 14, 15246, 8, 505, 12, 5117, 29, 549, 9, 288, 340, 4349, 440, 315, 3631, 3148, 61, 4388, 199, 318, 8775, 63, 5076, 345, 706, 63, 460, 63, 599, 9292, 8, 3627, 12, 2746, 63, 78, 275, 11630, 12, 1748, 63, 5076, 5975, 63, 5646, 29, 1400, 12, 639, 1748, 63, 599, 1679, 63, 5646, 29, 1165, 12, 3631, 3148, 29, 11632, 19984, 304, 272, 408, 7112, 83, 7282, 345, 706, 436, 3229, 9292, 687, 3245, 402, 8247, 14, 221, 6924, 370, 1048, 1985, 14803, 14, 339, 7282, 345, 706, 787, 6342, 402, 5932, 626, 5344, 315, 314, 3245, 14, 339, 3897, 272, 4143, 272, 3245, 26, 6076, 666, 370, 31758, 272, 2746, 63, 78, 26, 2304, 2058, 370, 642, 5002, 4811, 272, 1748, 63, 5076, 5975, 63, 5646, 26, 334, 4115, 9, 8765, 402, 1380, 370, 11201, 282, 4092, 402, 5932, 465, 282, 18054, 7282, 5975, 272, 1748, 63, 599, 1679, 63, 5646, 26, 334, 4115, 9, 8765, 402, 1380, 370, 11201, 282, 18038, 2723, 402, 5932, 465, 282, 18054, 3229, 1679, 272, 3631, 3148, 26, 334, 8147, 9, 3245, 402, 5932, 370, 3686, 315, 314, 16831, 339, 1306, 3066, 63, 576, 275, 1586, 63, 1210, 8, 272, 2263, 463, 9005, 15, 396, 63, 576, 63, 1001, 63, 1745, 14, 1001, 1370, 908, 8, 396, 63, 576, 63, 515, 395, 272, 2263, 463, 1564, 63, 698, 628, 6198, 531, 272, 1306, 7282, 345, 706, 12, 3229, 9292, 275, 8775, 63, 5076, 345, 706, 63, 460, 63, 599, 9292, 8, 1773, 63, 576, 12, 1748, 63, 5076, 5975, 63, 5646, 29, 21, 12, 1748, 63 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 646, 2050, 199, 646, 7975, 199, 646, 295, 199, 199, 504, 1318, 6582, 492, 4516, 16799, 199, 646, 3805, 5206, 199, 504, 3805, 5206, 14, 11059, 14, 21402, 492, 22348, 19984, 199, 199, 504, 370, 1038, 75, 14, 1208, 492, 1048, 8022, 12, 9045, 199, 199, 3, 8925, 1202, 1454, 367, 26721, 199, 504, 370, 1038, 75, 14, 2219, 492, 511, 63, 576, 63, 515, 199, 504, 370, 1038, 75, 14, 27056, 492, 1586, 63, 1210, 421, 199, 4806, 14, 19602, 8, 908, 29342, 18331, 9, 83, 520, 2818, 20056, 9, 83, 520, 2818, 1188, 9, 83, 297, 15324, 2166, 29, 4806, 14, 4531, 9, 421, 199, 318, 13343, 63, 4129, 8, 505, 12, 3631, 3148, 29, 11632, 19984, 304, 272, 408, 33, 1318, 14803, 626, 9329, 5117, 9403, 12, 4450, 23331, 764, 272, 4110, 436, 14185, 3631, 3148, 14, 272, 14911, 3805, 5206, 14, 1208, 14, 15246, 436, 3805, 5206, 14, 11059, 14, 21402, 14, 11632, 19984, 14, 339, 3897, 272, 4143, 272, 1318, 26, 1324, 1318, 370, 506, 1526, 1759, 272, 3631, 3148, 26, 5932, 370, 3686, 465, 11145, 339, 1306, 1305, 63, 12233, 275, 1586, 63, 1210, 8, 272, 2263, 463, 9005, 15, 396, 63, 576, 63, 1001, 63, 1745, 14, 1001, 1370, 908, 8, 396, 63, 576, 63, 515, 395, 272, 2263, 463, 1564, 63, 698, 628, 6198, 531, 272, 1306, 1305, 12, 1382, 63, 505, 275, 2163, 8, 1661, 8, 344, 63, 12233, 430, 272, 1306, 1382, 63, 505, 508, 620, 8, 272, 2263, 283, 21881, 7647, 279, 312, 88, 2655, 83, 787, 3769, 8652, 465, 314, 2163, 10152, 283, 272, 2263, 283, 23231, 315, 901, 4066, 465, 325, 16728, 2932, 436, 19472, 6230, 2618, 10329, 27, 3382, 7, 272, 2263, 283, 3062, 365, 377, 867, 279, 453, 334, 54, 9, 593, 88, 2655, 27, 13432, 12, 2337, 787, 9284, 13924, 367, 314, 283, 272, 2263, 283, 9466, 14925, 402, 642, 6285, 737, 314, 12055, 1377, 351, 1568, 1314, 4293, 1172, 283, 272, 2263, 283, 324, 527, 1061, 4382, 14, 869, 4894, 12, 315, 642, 1736, 781, 3451, 314, 9560, 14925, 402, 283, 272, 2263, 283, 22620, 18, 47, 21, 12055, 269, 364, 83, 701, 8597, 2312, 76, 1083, 1808, 577, 7170, 465, 5523, 4125, 316, 283, 272, 2263, 283, 4054, 12, 314, 1568, 402, 314, 12055, 269, 364, 83, 1990, 402, 314, 1865, 402, 6335, 370, 2948, 16751, 315, 283, 272, 2263, 283, 328, 1787, 436, 9978, 333, 530, 2641, 83, 315, 2582, 27, 642, 8837, 1083, 883, 506, 2997, 7, 272, 2263, 283, 315, 314, 876, 462, 425, 402, 12055, 676, 4428, 83, 367, 325, 16728, 2932, 12, 12111, 1377, 328, 915, 283, 272, 2263, 283, 15853, 465, 5521, 465, 6230, 2618, 10329, 2659, 272, 715, 272, 1306, 4645, 275, 13343, 63, 4129, 8, 1301, 63, 505, 9, 272, 1306, 4645, 508, 359, 272, 2263, 399, 1133, 1312, 1588, 297, 399, 6704, 386, 279, 297, 399, 7, 19131, 2655, 83, 297, 399, 7, 388, 2441, 581, 297, 399, 7, 15043, 297, 272, 2263, 399, 6704, 4428, 83, 297, 399, 7, 698, 297, 399, 7, 30169, 2932, 297, 399, 7, 14652, 297, 399, 7, 3385, 2618, 10329, 297, 272, 2263, 399, 1133, 867, 279, 453, 297, 399, 7, 86, 297, 399, 7, 19131, 2655, 297, 399, 3984, 5203, 297, 399, 1159, 1236, 14925, 297, 399, 6704, 4428, 297, 272, 2263, 399, 7, 4304, 1377, 351, 297, 399, 1159, 794, 297, 399, 7, 324, 527, 1061, 297, 399, 7, 3282, 297, 399, 7, 800, 297, 399, 7, 1881, 297, 272, 2263, 399, 1159, 1236, 14925, 297, 399, 1133, 65, 297, 399, 7, 79, 297, 399, 7, 4304, 269, 364, 83, 297, 399, 1159, 393, 297, 399, 7, 24920, 297, 399, 6704, 69, 594, 297, 272, 2263, 399, 5121, 3540, 297, 399, 1159, 454, 918, 608, 297, 399, 5121, 73, 1201, 316, 297, 399, 7, 4054, 297, 399, 1159, 794, 297, 399, 7, 4304, 269, 364, 83, 297, 272, 2263, 399, 7, 1648, 297, 399, 7, 10756, 297, 399, 5121, 73, 1787, 297, 399, 6704, 530, 2641, 83, 297, 399, 7, 1267, 297, 399, 7, 13581, 297, 399, 6704, 69, 594, 297, 272, 2263, 399, 7, 1180, 1893, 297, 399, 7, 657, 462, 425, 297, 399, 7, 4304, 676, 4428, 83, 297, 399, 7, 30169, 2932, 297, 272, 2263, 399, 7, 4492, 1377, 328, 915, 297, 399, 7, 15853, 297, 399, 7, 3385, 2618, 10329, 418, 272, 715, 272, 408, 272, 372, 359, 1027, 367, 4349, 315, 3805, 5206, 14, 1208, 14, 15246, 8, 505, 12, 5117, 29, 549, 9, 288, 340, 4349, 440, 315, 3631, 3148, 61, 4388, 199, 318, 8775, 63, 5076, 345, 706, 63, 460, 63, 599, 9292, 8, 3627, 12, 2746, 63, 78, 275, 11630, 12, 1748, 63, 5076, 5975, 63, 5646, 29, 1400, 12, 639, 1748, 63, 599, 1679, 63, 5646, 29, 1165, 12, 3631, 3148, 29, 11632, 19984, 304, 272, 408, 7112, 83, 7282, 345, 706, 436, 3229, 9292, 687, 3245, 402, 8247, 14, 221, 6924, 370, 1048, 1985, 14803, 14, 339, 7282, 345, 706, 787, 6342, 402, 5932, 626, 5344, 315, 314, 3245, 14, 339, 3897, 272, 4143, 272, 3245, 26, 6076, 666, 370, 31758, 272, 2746, 63, 78, 26, 2304, 2058, 370, 642, 5002, 4811, 272, 1748, 63, 5076, 5975, 63, 5646, 26, 334, 4115, 9, 8765, 402, 1380, 370, 11201, 282, 4092, 402, 5932, 465, 282, 18054, 7282, 5975, 272, 1748, 63, 599, 1679, 63, 5646, 26, 334, 4115, 9, 8765, 402, 1380, 370, 11201, 282, 18038, 2723, 402, 5932, 465, 282, 18054, 3229, 1679, 272, 3631, 3148, 26, 334, 8147, 9, 3245, 402, 5932, 370, 3686, 315, 314, 16831, 339, 1306, 3066, 63, 576, 275, 1586, 63, 1210, 8, 272, 2263, 463, 9005, 15, 396, 63, 576, 63, 1001, 63, 1745, 14, 1001, 1370, 908, 8, 396, 63, 576, 63, 515, 395, 272, 2263, 463, 1564, 63, 698, 628, 6198, 531, 272, 1306, 7282, 345, 706, 12, 3229, 9292, 275, 8775, 63, 5076, 345, 706, 63, 460, 63, 599, 9292, 8, 1773, 63, 576, 12, 1748, 63, 5076, 5975, 63, 5646, 29, 21, 12, 1748, 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, 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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 ]
restran/api-gateway-dashboard
accounts/backends.py
1
1096
# !/usr/bin/env python # -*- coding: utf-8 -*- # created by restran on 2016/1/2 from __future__ import unicode_literals, absolute_import from .models import SiteUser class EmailAuthBackend(object): """ Email Authentication Backend Allows a user to sign in using an email/password pair rather than a username/password pair. """ def authenticate(self, email=None, password=None): """ Authenticate a user based on email address as the user name. """ try: user = SiteUser.objects.get(email=email) if user.check_password(password): return user except SiteUser.DoesNotExist: return None def get_user(self, user_id): """ Get a User object from the user_id. """ try: user = SiteUser.objects.get(pk=user_id) # user.last_login = datetime.datetime.now() # 用户上线 # user.save(update_fields=['last_login']) # 将数据写入数据库 except SiteUser.DoesNotExist: return None else: return user
mit
[ 3, 8546, 15, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 2737, 701, 295, 495, 290, 641, 7800, 15, 17, 15, 18, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 3679, 63, 646, 199, 199, 504, 1275, 992, 492, 11666, 1899, 421, 199, 533, 11426, 2817, 8447, 8, 785, 304, 272, 408, 272, 11426, 15995, 25674, 2286, 22819, 282, 922, 370, 2070, 315, 1808, 376, 3031, 15, 2060, 4092, 7830, 2419, 272, 282, 3434, 15, 2060, 4092, 14, 272, 408, 339, 347, 12895, 8, 277, 12, 3031, 29, 403, 12, 2505, 29, 403, 304, 267, 408, 3590, 7672, 282, 922, 4079, 641, 3031, 2287, 465, 314, 922, 536, 14, 408, 267, 862, 26, 288, 922, 275, 11666, 1899, 14, 1462, 14, 362, 8, 2123, 29, 2123, 9, 288, 340, 922, 14, 1074, 63, 2060, 8, 2060, 304, 355, 372, 922, 267, 871, 11666, 1899, 14, 7400, 26, 288, 372, 488, 339, 347, 664, 63, 751, 8, 277, 12, 922, 63, 344, 304, 267, 408, 2372, 282, 2876, 909, 687, 314, 922, 63, 344, 14, 408, 267, 862, 26, 288, 922, 275, 11666, 1899, 14, 1462, 14, 362, 8, 2051, 29, 751, 63, 344, 9, 288, 327, 922, 14, 2019, 63, 2886, 275, 2197, 14, 2083, 14, 2131, 342, 221, 327, 221, 22445, 22661, 13389, 124, 288, 327, 922, 14, 2117, 8, 873, 63, 955, 2968, 2019, 63, 2886, 1105, 221, 327, 7094, 109, 229, 22730, 17950, 248, 18236, 22730, 15013, 242, 267, 871, 11666, 1899, 14, 7400, 26, 288, 372, 488, 267, 587, 26, 288, 372, 922, 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 ]
[ 8546, 15, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 2737, 701, 295, 495, 290, 641, 7800, 15, 17, 15, 18, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 3679, 63, 646, 199, 199, 504, 1275, 992, 492, 11666, 1899, 421, 199, 533, 11426, 2817, 8447, 8, 785, 304, 272, 408, 272, 11426, 15995, 25674, 2286, 22819, 282, 922, 370, 2070, 315, 1808, 376, 3031, 15, 2060, 4092, 7830, 2419, 272, 282, 3434, 15, 2060, 4092, 14, 272, 408, 339, 347, 12895, 8, 277, 12, 3031, 29, 403, 12, 2505, 29, 403, 304, 267, 408, 3590, 7672, 282, 922, 4079, 641, 3031, 2287, 465, 314, 922, 536, 14, 408, 267, 862, 26, 288, 922, 275, 11666, 1899, 14, 1462, 14, 362, 8, 2123, 29, 2123, 9, 288, 340, 922, 14, 1074, 63, 2060, 8, 2060, 304, 355, 372, 922, 267, 871, 11666, 1899, 14, 7400, 26, 288, 372, 488, 339, 347, 664, 63, 751, 8, 277, 12, 922, 63, 344, 304, 267, 408, 2372, 282, 2876, 909, 687, 314, 922, 63, 344, 14, 408, 267, 862, 26, 288, 922, 275, 11666, 1899, 14, 1462, 14, 362, 8, 2051, 29, 751, 63, 344, 9, 288, 327, 922, 14, 2019, 63, 2886, 275, 2197, 14, 2083, 14, 2131, 342, 221, 327, 221, 22445, 22661, 13389, 124, 288, 327, 922, 14, 2117, 8, 873, 63, 955, 2968, 2019, 63, 2886, 1105, 221, 327, 7094, 109, 229, 22730, 17950, 248, 18236, 22730, 15013, 242, 267, 871, 11666, 1899, 14, 7400, 26, 288, 372, 488, 267, 587, 26, 288, 372, 922, 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, 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,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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 ]
caphrim007/ansible
test/units/modules/network/slxos/test_slxos_linkagg.py
23
4950
# # (c) 2018 Extreme Networks Inc. # # 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/>. # from __future__ import (absolute_import, division, print_function) __metaclass__ = type import re import json from ansible.compat.tests.mock import patch from ansible.modules.network.slxos import slxos_linkagg from units.modules.utils import set_module_args from .slxos_module import TestSlxosModule, load_fixture class TestSlxosLinkaggModule(TestSlxosModule): module = slxos_linkagg def setUp(self): super(TestSlxosLinkaggModule, self).setUp() self._patch_get_config = patch( 'ansible.modules.network.slxos.slxos_linkagg.get_config' ) self._patch_load_config = patch( 'ansible.modules.network.slxos.slxos_linkagg.load_config' ) self._get_config = self._patch_get_config.start() self._load_config = self._patch_load_config.start() def tearDown(self): super(TestSlxosLinkaggModule, self).tearDown() self._patch_get_config.stop() self._patch_load_config.stop() def load_fixtures(self, commands=None): config_file = 'slxos_config_config.cfg' self._get_config.return_value = load_fixture(config_file) self._load_config.return_value = None def test_slxos_linkagg_group_present(self, *args, **kwargs): set_module_args(dict( group='10', state='present' )) result = self.execute_module(changed=True) self.assertEqual( result, { 'commands': [ 'interface port-channel 10', 'exit' ], 'changed': True } ) def test_slxos_linkagg_group_members_active(self, *args, **kwargs): set_module_args(dict( group='10', mode='active', members=[ 'Ethernet 0/1', 'Ethernet 0/2' ] )) result = self.execute_module(changed=True) self.assertEqual( result, { 'commands': [ 'interface port-channel 10', 'exit', 'interface Ethernet 0/1', 'channel-group 10 mode active', 'interface Ethernet 0/2', 'channel-group 10 mode active' ], 'changed': True } ) def test_slxos_linkagg_group_member_removal(self, *args, **kwargs): set_module_args(dict( group='20', mode='active', members=[ 'Ethernet 0/10', ] )) result = self.execute_module(changed=True) self.assertEqual( result, { 'commands': [ 'interface port-channel 20', 'exit', 'interface Ethernet 0/11', 'no channel-group' ], 'changed': True } ) def test_slxos_linkagg_group_members_absent(self, *args, **kwargs): set_module_args(dict( group='20', state='absent' )) result = self.execute_module(changed=True) self.assertEqual( result, { 'commands': [ 'no interface port-channel 20' ], 'changed': True } ) set_module_args(dict( group='10', state='absent' )) result = self.execute_module(changed=False) self.assertEqual( result, { 'commands': [], 'changed': False } ) def test_slxos_linkagg_invalid_argument(self, *args, **kwargs): set_module_args(dict( group='10', shawshank='Redemption' )) result = self.execute_module(failed=True) self.assertEqual(result['failed'], True) self.assertTrue(re.match( r'Unsupported parameters for \((basic.pyc|basic.py)\) module: ' 'shawshank Supported parameters include: aggregate, group, ' 'members, mode, purge, state', result['msg'] ))
gpl-3.0
[ 3, 199, 3, 334, 67, 9, 14894, 7255, 17817, 17138, 3277, 14, 199, 3, 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, 3, 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, 295, 199, 646, 2022, 199, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 2482, 22101, 492, 5340, 22101, 63, 1073, 13452, 199, 504, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 504, 1275, 2482, 22101, 63, 578, 492, 1379, 11592, 22101, 2377, 12, 2248, 63, 5997, 421, 199, 533, 1379, 11592, 22101, 3834, 13452, 2377, 8, 774, 11592, 22101, 2377, 304, 272, 859, 275, 5340, 22101, 63, 1073, 13452, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 11592, 22101, 3834, 13452, 2377, 12, 291, 680, 5996, 342, 267, 291, 423, 2068, 63, 362, 63, 888, 275, 3371, 8, 288, 283, 4853, 14, 3112, 14, 1200, 14, 2482, 22101, 14, 2482, 22101, 63, 1073, 13452, 14, 362, 63, 888, 7, 267, 776, 267, 291, 423, 2068, 63, 912, 63, 888, 275, 3371, 8, 288, 283, 4853, 14, 3112, 14, 1200, 14, 2482, 22101, 14, 2482, 22101, 63, 1073, 13452, 14, 912, 63, 888, 7, 267, 776, 398, 291, 423, 362, 63, 888, 275, 291, 423, 2068, 63, 362, 63, 888, 14, 928, 342, 267, 291, 423, 912, 63, 888, 275, 291, 423, 2068, 63, 912, 63, 888, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 774, 11592, 22101, 3834, 13452, 2377, 12, 291, 680, 12336, 342, 267, 291, 423, 2068, 63, 362, 63, 888, 14, 2379, 342, 267, 291, 423, 2068, 63, 912, 63, 888, 14, 2379, 342, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 304, 267, 1101, 63, 493, 275, 283, 2482, 22101, 63, 888, 63, 888, 14, 4128, 7, 267, 291, 423, 362, 63, 888, 14, 1107, 63, 585, 275, 2248, 63, 5997, 8, 888, 63, 493, 9, 267, 291, 423, 912, 63, 888, 14, 1107, 63, 585, 275, 488, 339, 347, 511, 63, 2482, 22101, 63, 1073, 13452, 63, 923, 63, 1881, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 709, 297, 288, 1174, 534, 1881, 7, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 359, 490, 283, 3266, 1844, 13, 2775, 1616, 297, 490, 283, 2224, 7, 355, 2156, 355, 283, 2489, 356, 715, 288, 789, 267, 776, 339, 347, 511, 63, 2482, 22101, 63, 1073, 13452, 63, 923, 63, 6334, 63, 2682, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 709, 297, 288, 818, 534, 2682, 297, 288, 7556, 1524, 355, 283, 22056, 378, 15, 17, 297, 355, 283, 22056, 378, 15, 18, 7, 288, 1622, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 359, 490, 283, 3266, 1844, 13, 2775, 1616, 297, 490, 283, 2224, 297, 490, 283, 3266, 26125, 378, 15, 17, 297, 490, 283, 2775, 13, 923, 1616, 818, 4702, 297, 490, 283, 3266, 26125, 378, 15, 18, 297, 490, 283, 2775, 13, 923, 1616, 818, 4702, 7, 355, 2156, 355, 283, 2489, 356, 715, 288, 789, 267, 776, 339, 347, 511, 63, 2482, 22101, 63, 1073, 13452, 63, 923, 63, 1114, 63, 25818, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 1165, 297, 288, 818, 534, 2682, 297, 288, 7556, 1524, 355, 283, 22056, 378, 15, 709, 297, 288, 1622, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 359, 490, 283, 3266, 1844, 13, 2775, 3388, 297, 490, 283, 2224, 297, 490, 283, 3266, 26125, 378, 15, 845, 297, 490, 283, 889, 3623, 13, 923, 7, 355, 2156, 355, 283, 2489, 356, 715, 288, 789, 267, 776, 339, 347, 511, 63, 2482, 22101, 63, 1073, 13452, 63, 923, 63, 6334, 63, 5575, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 1165, 297, 288, 1174, 534, 5575, 7, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 359, 490, 283, 889, 3217, 1844, 13, 2775, 3388, 7, 355, 2156, 355, 283, 2489, 356, 715, 288, 789, 267, 776, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 709, 297, 288, 1174, 534, 5575, 7, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 990, 355, 283, 2489, 356, 756, 288, 789, 267, 776, 339, 347, 511 ]
[ 199, 3, 334, 67, 9, 14894, 7255, 17817, 17138, 3277, 14, 199, 3, 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, 3, 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, 295, 199, 646, 2022, 199, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 199, 504, 3242, 14, 3112, 14, 1200, 14, 2482, 22101, 492, 5340, 22101, 63, 1073, 13452, 199, 504, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 504, 1275, 2482, 22101, 63, 578, 492, 1379, 11592, 22101, 2377, 12, 2248, 63, 5997, 421, 199, 533, 1379, 11592, 22101, 3834, 13452, 2377, 8, 774, 11592, 22101, 2377, 304, 272, 859, 275, 5340, 22101, 63, 1073, 13452, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 11592, 22101, 3834, 13452, 2377, 12, 291, 680, 5996, 342, 267, 291, 423, 2068, 63, 362, 63, 888, 275, 3371, 8, 288, 283, 4853, 14, 3112, 14, 1200, 14, 2482, 22101, 14, 2482, 22101, 63, 1073, 13452, 14, 362, 63, 888, 7, 267, 776, 267, 291, 423, 2068, 63, 912, 63, 888, 275, 3371, 8, 288, 283, 4853, 14, 3112, 14, 1200, 14, 2482, 22101, 14, 2482, 22101, 63, 1073, 13452, 14, 912, 63, 888, 7, 267, 776, 398, 291, 423, 362, 63, 888, 275, 291, 423, 2068, 63, 362, 63, 888, 14, 928, 342, 267, 291, 423, 912, 63, 888, 275, 291, 423, 2068, 63, 912, 63, 888, 14, 928, 342, 339, 347, 6766, 8, 277, 304, 267, 1613, 8, 774, 11592, 22101, 3834, 13452, 2377, 12, 291, 680, 12336, 342, 267, 291, 423, 2068, 63, 362, 63, 888, 14, 2379, 342, 267, 291, 423, 2068, 63, 912, 63, 888, 14, 2379, 342, 339, 347, 2248, 63, 8769, 8, 277, 12, 3718, 29, 403, 304, 267, 1101, 63, 493, 275, 283, 2482, 22101, 63, 888, 63, 888, 14, 4128, 7, 267, 291, 423, 362, 63, 888, 14, 1107, 63, 585, 275, 2248, 63, 5997, 8, 888, 63, 493, 9, 267, 291, 423, 912, 63, 888, 14, 1107, 63, 585, 275, 488, 339, 347, 511, 63, 2482, 22101, 63, 1073, 13452, 63, 923, 63, 1881, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 709, 297, 288, 1174, 534, 1881, 7, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 359, 490, 283, 3266, 1844, 13, 2775, 1616, 297, 490, 283, 2224, 7, 355, 2156, 355, 283, 2489, 356, 715, 288, 789, 267, 776, 339, 347, 511, 63, 2482, 22101, 63, 1073, 13452, 63, 923, 63, 6334, 63, 2682, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 709, 297, 288, 818, 534, 2682, 297, 288, 7556, 1524, 355, 283, 22056, 378, 15, 17, 297, 355, 283, 22056, 378, 15, 18, 7, 288, 1622, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 359, 490, 283, 3266, 1844, 13, 2775, 1616, 297, 490, 283, 2224, 297, 490, 283, 3266, 26125, 378, 15, 17, 297, 490, 283, 2775, 13, 923, 1616, 818, 4702, 297, 490, 283, 3266, 26125, 378, 15, 18, 297, 490, 283, 2775, 13, 923, 1616, 818, 4702, 7, 355, 2156, 355, 283, 2489, 356, 715, 288, 789, 267, 776, 339, 347, 511, 63, 2482, 22101, 63, 1073, 13452, 63, 923, 63, 1114, 63, 25818, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 1165, 297, 288, 818, 534, 2682, 297, 288, 7556, 1524, 355, 283, 22056, 378, 15, 709, 297, 288, 1622, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 359, 490, 283, 3266, 1844, 13, 2775, 3388, 297, 490, 283, 2224, 297, 490, 283, 3266, 26125, 378, 15, 845, 297, 490, 283, 889, 3623, 13, 923, 7, 355, 2156, 355, 283, 2489, 356, 715, 288, 789, 267, 776, 339, 347, 511, 63, 2482, 22101, 63, 1073, 13452, 63, 923, 63, 6334, 63, 5575, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 1165, 297, 288, 1174, 534, 5575, 7, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 549, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 359, 490, 283, 889, 3217, 1844, 13, 2775, 3388, 7, 355, 2156, 355, 283, 2489, 356, 715, 288, 789, 267, 776, 267, 663, 63, 578, 63, 589, 8, 807, 8, 288, 1572, 534, 709, 297, 288, 1174, 534, 5575, 7, 267, 5082, 267, 754, 275, 291, 14, 2526, 63, 578, 8, 2489, 29, 797, 9, 267, 291, 14, 629, 8, 288, 754, 12, 288, 469, 355, 283, 4405, 356, 990, 355, 283, 2489, 356, 756, 288, 789, 267, 776, 339, 347, 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, 1, 1, 1, 1, 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 ]
tksarah/ansible-modules-core
system/group.py
81
13394
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2012, Stephen Fromm <sfromm@gmail.com> # # 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: group author: "Stephen Fromm (@sfromm)" version_added: "0.0.2" short_description: Add or remove groups requirements: [ groupadd, groupdel, groupmod ] description: - Manage presence of groups on a host. options: name: required: true description: - Name of the group to manage. gid: required: false description: - Optional I(GID) to set for the group. state: required: false default: "present" choices: [ present, absent ] description: - Whether the group should be present or not on the remote host. system: required: false default: "no" choices: [ "yes", "no" ] description: - If I(yes), indicates that the group created is a system group. ''' EXAMPLES = ''' # Example group command from Ansible Playbooks - group: name=somegroup state=present ''' import grp import syslog import platform class Group(object): """ This is a generic Group manipulation class that is subclassed based on platform. A subclass may wish to override the following action methods:- - group_del() - group_add() - group_mod() All subclasses MUST define platform and distribution (which may be None). """ platform = 'Generic' distribution = None GROUPFILE = '/etc/group' def __new__(cls, *args, **kwargs): return load_platform_subclass(Group, args, kwargs) def __init__(self, module): self.module = module self.state = module.params['state'] self.name = module.params['name'] self.gid = module.params['gid'] self.system = module.params['system'] self.syslogging = False def execute_command(self, cmd): if self.syslogging: syslog.openlog('ansible-%s' % os.path.basename(__file__)) syslog.syslog(syslog.LOG_NOTICE, 'Command %s' % '|'.join(cmd)) return self.module.run_command(cmd) def group_del(self): cmd = [self.module.get_bin_path('groupdel', True), self.name] return self.execute_command(cmd) def group_add(self, **kwargs): cmd = [self.module.get_bin_path('groupadd', True)] for key in kwargs: if key == 'gid' and kwargs[key] is not None: cmd.append('-g') cmd.append(kwargs[key]) elif key == 'system' and kwargs[key] == True: cmd.append('-r') cmd.append(self.name) return self.execute_command(cmd) def group_mod(self, **kwargs): cmd = [self.module.get_bin_path('groupmod', True)] info = self.group_info() for key in kwargs: if key == 'gid': if kwargs[key] is not None and info[2] != int(kwargs[key]): cmd.append('-g') cmd.append(kwargs[key]) if len(cmd) == 1: return (None, '', '') if self.module.check_mode: return (0, '', '') cmd.append(self.name) return self.execute_command(cmd) def group_exists(self): try: if grp.getgrnam(self.name): return True except KeyError: return False def group_info(self): if not self.group_exists(): return False try: info = list(grp.getgrnam(self.name)) except KeyError: return False return info # =========================================== class SunOS(Group): """ This is a SunOS Group manipulation class. Solaris doesn't have the 'system' group concept. This overrides the following methods from the generic class:- - group_add() """ platform = 'SunOS' distribution = None GROUPFILE = '/etc/group' def group_add(self, **kwargs): cmd = [self.module.get_bin_path('groupadd', True)] for key in kwargs: if key == 'gid' and kwargs[key] is not None: cmd.append('-g') cmd.append(kwargs[key]) cmd.append(self.name) return self.execute_command(cmd) # =========================================== class AIX(Group): """ This is a AIX Group manipulation class. This overrides the following methods from the generic class:- - group_del() - group_add() - group_mod() """ platform = 'AIX' distribution = None GROUPFILE = '/etc/group' def group_del(self): cmd = [self.module.get_bin_path('rmgroup', True), self.name] return self.execute_command(cmd) def group_add(self, **kwargs): cmd = [self.module.get_bin_path('mkgroup', True)] for key in kwargs: if key == 'gid' and kwargs[key] is not None: cmd.append('id='+kwargs[key]) elif key == 'system' and kwargs[key] == True: cmd.append('-a') cmd.append(self.name) return self.execute_command(cmd) def group_mod(self, **kwargs): cmd = [self.module.get_bin_path('chgroup', True)] info = self.group_info() for key in kwargs: if key == 'gid': if kwargs[key] is not None and info[2] != int(kwargs[key]): cmd.append('id='+kwargs[key]) if len(cmd) == 1: return (None, '', '') if self.module.check_mode: return (0, '', '') cmd.append(self.name) return self.execute_command(cmd) # =========================================== class FreeBsdGroup(Group): """ This is a FreeBSD Group manipulation class. This overrides the following methods from the generic class:- - group_del() - group_add() - group_mod() """ platform = 'FreeBSD' distribution = None GROUPFILE = '/etc/group' def group_del(self): cmd = [self.module.get_bin_path('pw', True), 'groupdel', self.name] return self.execute_command(cmd) def group_add(self, **kwargs): cmd = [self.module.get_bin_path('pw', True), 'groupadd', self.name] if self.gid is not None: cmd.append('-g') cmd.append('%d' % int(self.gid)) return self.execute_command(cmd) def group_mod(self, **kwargs): cmd = [self.module.get_bin_path('pw', True), 'groupmod', self.name] info = self.group_info() cmd_len = len(cmd) if self.gid is not None and int(self.gid) != info[2]: cmd.append('-g') cmd.append('%d' % int(self.gid)) # modify the group if cmd will do anything if cmd_len != len(cmd): if self.module.check_mode: return (0, '', '') return self.execute_command(cmd) return (None, '', '') # =========================================== class DarwinGroup(Group): """ This is a Mac OS X Darwin Group manipulation class. This overrides the following methods from the generic class:- - group_del() - group_add() - group_mod() group manupulation are done using dseditgroup(1). """ platform = 'Darwin' distribution = None def group_add(self, **kwargs): cmd = [self.module.get_bin_path('dseditgroup', True)] cmd += [ '-o', 'create' ] if self.gid is not None: cmd += [ '-i', self.gid ] cmd += [ '-L', self.name ] (rc, out, err) = self.execute_command(cmd) return (rc, out, err) def group_del(self): cmd = [self.module.get_bin_path('dseditgroup', True)] cmd += [ '-o', 'delete' ] cmd += [ '-L', self.name ] (rc, out, err) = self.execute_command(cmd) return (rc, out, err) def group_mod(self, gid=None): info = self.group_info() if self.gid is not None and int(self.gid) != info[2]: cmd = [self.module.get_bin_path('dseditgroup', True)] cmd += [ '-o', 'edit' ] if gid is not None: cmd += [ '-i', gid ] cmd += [ '-L', self.name ] (rc, out, err) = self.execute_command(cmd) return (rc, out, err) return (None, '', '') class OpenBsdGroup(Group): """ This is a OpenBSD Group manipulation class. This overrides the following methods from the generic class:- - group_del() - group_add() - group_mod() """ platform = 'OpenBSD' distribution = None GROUPFILE = '/etc/group' def group_del(self): cmd = [self.module.get_bin_path('groupdel', True), self.name] return self.execute_command(cmd) def group_add(self, **kwargs): cmd = [self.module.get_bin_path('groupadd', True)] if self.gid is not None: cmd.append('-g') cmd.append('%d' % int(self.gid)) cmd.append(self.name) return self.execute_command(cmd) def group_mod(self, **kwargs): cmd = [self.module.get_bin_path('groupmod', True)] info = self.group_info() cmd_len = len(cmd) if self.gid is not None and int(self.gid) != info[2]: cmd.append('-g') cmd.append('%d' % int(self.gid)) if len(cmd) == 1: return (None, '', '') if self.module.check_mode: return (0, '', '') cmd.append(self.name) return self.execute_command(cmd) # =========================================== class NetBsdGroup(Group): """ This is a NetBSD Group manipulation class. This overrides the following methods from the generic class:- - group_del() - group_add() - group_mod() """ platform = 'NetBSD' distribution = None GROUPFILE = '/etc/group' def group_del(self): cmd = [self.module.get_bin_path('groupdel', True), self.name] return self.execute_command(cmd) def group_add(self, **kwargs): cmd = [self.module.get_bin_path('groupadd', True)] if self.gid is not None: cmd.append('-g') cmd.append('%d' % int(self.gid)) cmd.append(self.name) return self.execute_command(cmd) def group_mod(self, **kwargs): cmd = [self.module.get_bin_path('groupmod', True)] info = self.group_info() cmd_len = len(cmd) if self.gid is not None and int(self.gid) != info[2]: cmd.append('-g') cmd.append('%d' % int(self.gid)) if len(cmd) == 1: return (None, '', '') if self.module.check_mode: return (0, '', '') cmd.append(self.name) return self.execute_command(cmd) # =========================================== def main(): module = AnsibleModule( argument_spec = dict( state=dict(default='present', choices=['present', 'absent'], type='str'), name=dict(required=True, type='str'), gid=dict(default=None, type='str'), system=dict(default=False, type='bool'), ), supports_check_mode=True ) group = Group(module) if group.syslogging: syslog.openlog('ansible-%s' % os.path.basename(__file__)) syslog.syslog(syslog.LOG_NOTICE, 'Group instantiated - platform %s' % group.platform) if user.distribution: syslog.syslog(syslog.LOG_NOTICE, 'Group instantiated - distribution %s' % group.distribution) rc = None out = '' err = '' result = {} result['name'] = group.name result['state'] = group.state if group.state == 'absent': if group.group_exists(): if module.check_mode: module.exit_json(changed=True) (rc, out, err) = group.group_del() if rc != 0: module.fail_json(name=group.name, msg=err) elif group.state == 'present': if not group.group_exists(): if module.check_mode: module.exit_json(changed=True) (rc, out, err) = group.group_add(gid=group.gid, system=group.system) else: (rc, out, err) = group.group_mod(gid=group.gid) if rc is not None and rc != 0: module.fail_json(name=group.name, msg=err) if rc is None: result['changed'] = False else: result['changed'] = True if out: result['stdout'] = out if err: result['stderr'] = err if group.group_exists(): info = group.group_info() result['system'] = group.system result['gid'] = info[2] module.exit_json(**result) # import module snippets from ansible.module_utils.basic import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6029, 12, 17854, 17579, 11606, 77, 665, 83, 504, 77, 32, 6799, 14, 957, 30, 199, 3, 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, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 1572, 199, 2502, 26, 298, 26696, 17579, 11606, 77, 8593, 83, 504, 77, 2924, 199, 1023, 63, 3270, 26, 298, 16, 14, 16, 14, 18, 2, 199, 3612, 63, 1802, 26, 2654, 503, 2813, 4652, 199, 7538, 26, 359, 1572, 525, 12, 1572, 2264, 12, 1572, 1494, 1622, 199, 1802, 26, 272, 446, 14944, 20024, 402, 4652, 641, 282, 1591, 14, 199, 1419, 26, 272, 536, 26, 267, 1415, 26, 2549, 267, 1369, 26, 288, 446, 2812, 402, 314, 1572, 370, 9635, 14, 272, 15122, 26, 267, 1415, 26, 3055, 267, 1369, 26, 288, 446, 4879, 473, 8, 39, 998, 9, 370, 663, 367, 314, 1572, 14, 272, 1174, 26, 267, 1415, 26, 3055, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 359, 3451, 12, 9552, 1622, 267, 1369, 26, 288, 446, 7480, 314, 1572, 1077, 506, 3451, 503, 440, 641, 314, 3982, 1591, 14, 272, 2656, 26, 267, 1415, 26, 3055, 267, 849, 26, 298, 889, 2, 267, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 267, 1369, 26, 288, 446, 982, 473, 8, 5066, 395, 9126, 626, 314, 1572, 2737, 365, 282, 2656, 1572, 14, 199, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 1572, 1414, 687, 2622, 16527, 8858, 199, 13, 1572, 26, 536, 29, 3972, 923, 1174, 29, 1881, 199, 2344, 199, 199, 646, 18598, 199, 646, 22112, 199, 646, 4298, 199, 199, 533, 5611, 8, 785, 304, 272, 408, 272, 961, 365, 282, 7809, 5611, 26212, 1021, 626, 365, 1007, 28271, 272, 4079, 641, 4298, 14, 339, 437, 5516, 1443, 13809, 370, 4278, 314, 2569, 1595, 3102, 6809, 489, 446, 1572, 63, 2264, 342, 489, 446, 1572, 63, 525, 342, 489, 446, 1572, 63, 1494, 342, 339, 2900, 9180, 18095, 5627, 4298, 436, 4084, 334, 6777, 1443, 506, 488, 680, 272, 408, 339, 4298, 275, 283, 9417, 7, 272, 4084, 275, 488, 272, 15443, 3817, 275, 1994, 6839, 15, 923, 7, 339, 347, 636, 1222, 721, 1886, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 2248, 63, 3246, 63, 6083, 8, 2448, 12, 1249, 12, 2074, 9, 339, 347, 636, 826, 721, 277, 12, 859, 304, 267, 291, 14, 578, 258, 275, 859, 267, 291, 14, 929, 420, 275, 859, 14, 1162, 459, 929, 418, 267, 291, 14, 354, 755, 275, 859, 14, 1162, 459, 354, 418, 267, 291, 14, 8787, 263, 275, 859, 14, 1162, 459, 8787, 418, 267, 291, 14, 2253, 258, 275, 859, 14, 1162, 459, 2253, 418, 267, 291, 14, 1274, 4806, 275, 756, 339, 347, 5341, 63, 1531, 8, 277, 12, 2088, 304, 267, 340, 291, 14, 1274, 4806, 26, 288, 22112, 14, 1490, 793, 360, 4853, 3295, 83, 7, 450, 747, 14, 515, 14, 4846, 3460, 493, 8964, 288, 22112, 14, 16878, 8, 16878, 14, 4947, 63, 4609, 4047, 12, 283, 3110, 450, 83, 7, 450, 21590, 904, 8, 1760, 430, 398, 372, 291, 14, 578, 14, 1065, 63, 1531, 8, 1760, 9, 339, 347, 1572, 63, 2264, 8, 277, 304, 267, 2088, 275, 359, 277, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 923, 2264, 297, 715, 395, 291, 14, 354, 61, 267, 372, 291, 14, 2526, 63, 1531, 8, 1760, 9, 339, 347, 1572, 63, 525, 8, 277, 12, 1011, 958, 304, 267, 2088, 275, 359, 277, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 923, 525, 297, 715, 1874, 267, 367, 790, 315, 2074, 26, 288, 340, 790, 508, 283, 8787, 7, 436, 2074, 59, 498, 61, 365, 440, 488, 26, 355, 2088, 14, 740, 3654, 71, 358, 355, 2088, 14, 740, 8, 958, 59, 498, 566, 288, 916, 790, 508, 283, 2253, 7, 436, 2074, 59, 498, 61, 508, 715, 26, 355, 2088, 14, 740, 3654, 82, 358, 267, 2088, 14, 740, 8, 277, 14, 354, 9, 267, 372, 291, 14, 2526, 63, 1531, 8, 1760, 9, 339, 347, 1572, 63, 1494, 8, 277, 12, 1011, 958, 304, 267, 2088, 275, 359, 277, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 923, 1494, 297, 715, 1874, 267, 2256, 275, 291, 14, 923, 63, 815, 342, 267, 367, 790, 315, 2074, 26, 288, 340, 790, 508, 283, 8787, 356, 355, 340, 2074, 59, 498, 61, 365, 440, 488, 436, 2256, 59, 18, 61, 1137, 1109, 8, 958, 59, 498, 4682, 490, 2088, 14, 740, 3654, 71, 358, 490, 2088, 14, 740, 8, 958, 59, 498, 566, 267, 340, 822, 8, 1760, 9, 508, 413, 26, 288, 372, 334, 403, 12, 3260, 4074, 267, 340, 291, 14, 578, 14, 1074, 63, 632, 26, 288, 372, 334, 16, 12, 3260, 4074, 267, 2088, 14, 740, 8, 277, 14, 354, 9, 267, 372, 291, 14, 2526, 63, 1531, 8, 1760, 9, 339, 347, 1572, 63, 2444, 8, 277, 304, 267, 862, 26, 288, 340, 18598, 14, 362, 2587, 17811, 8, 277, 14, 354, 304, 355, 372, 715, 267, 871, 4067, 26, 288, 372, 756, 339, 347, 1572, 63, 815, 8 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6029, 12, 17854, 17579, 11606, 77, 665, 83, 504, 77, 32, 6799, 14, 957, 30, 199, 3, 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, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 1572, 199, 2502, 26, 298, 26696, 17579, 11606, 77, 8593, 83, 504, 77, 2924, 199, 1023, 63, 3270, 26, 298, 16, 14, 16, 14, 18, 2, 199, 3612, 63, 1802, 26, 2654, 503, 2813, 4652, 199, 7538, 26, 359, 1572, 525, 12, 1572, 2264, 12, 1572, 1494, 1622, 199, 1802, 26, 272, 446, 14944, 20024, 402, 4652, 641, 282, 1591, 14, 199, 1419, 26, 272, 536, 26, 267, 1415, 26, 2549, 267, 1369, 26, 288, 446, 2812, 402, 314, 1572, 370, 9635, 14, 272, 15122, 26, 267, 1415, 26, 3055, 267, 1369, 26, 288, 446, 4879, 473, 8, 39, 998, 9, 370, 663, 367, 314, 1572, 14, 272, 1174, 26, 267, 1415, 26, 3055, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 359, 3451, 12, 9552, 1622, 267, 1369, 26, 288, 446, 7480, 314, 1572, 1077, 506, 3451, 503, 440, 641, 314, 3982, 1591, 14, 272, 2656, 26, 267, 1415, 26, 3055, 267, 849, 26, 298, 889, 2, 267, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 267, 1369, 26, 288, 446, 982, 473, 8, 5066, 395, 9126, 626, 314, 1572, 2737, 365, 282, 2656, 1572, 14, 199, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5679, 1572, 1414, 687, 2622, 16527, 8858, 199, 13, 1572, 26, 536, 29, 3972, 923, 1174, 29, 1881, 199, 2344, 199, 199, 646, 18598, 199, 646, 22112, 199, 646, 4298, 199, 199, 533, 5611, 8, 785, 304, 272, 408, 272, 961, 365, 282, 7809, 5611, 26212, 1021, 626, 365, 1007, 28271, 272, 4079, 641, 4298, 14, 339, 437, 5516, 1443, 13809, 370, 4278, 314, 2569, 1595, 3102, 6809, 489, 446, 1572, 63, 2264, 342, 489, 446, 1572, 63, 525, 342, 489, 446, 1572, 63, 1494, 342, 339, 2900, 9180, 18095, 5627, 4298, 436, 4084, 334, 6777, 1443, 506, 488, 680, 272, 408, 339, 4298, 275, 283, 9417, 7, 272, 4084, 275, 488, 272, 15443, 3817, 275, 1994, 6839, 15, 923, 7, 339, 347, 636, 1222, 721, 1886, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 2248, 63, 3246, 63, 6083, 8, 2448, 12, 1249, 12, 2074, 9, 339, 347, 636, 826, 721, 277, 12, 859, 304, 267, 291, 14, 578, 258, 275, 859, 267, 291, 14, 929, 420, 275, 859, 14, 1162, 459, 929, 418, 267, 291, 14, 354, 755, 275, 859, 14, 1162, 459, 354, 418, 267, 291, 14, 8787, 263, 275, 859, 14, 1162, 459, 8787, 418, 267, 291, 14, 2253, 258, 275, 859, 14, 1162, 459, 2253, 418, 267, 291, 14, 1274, 4806, 275, 756, 339, 347, 5341, 63, 1531, 8, 277, 12, 2088, 304, 267, 340, 291, 14, 1274, 4806, 26, 288, 22112, 14, 1490, 793, 360, 4853, 3295, 83, 7, 450, 747, 14, 515, 14, 4846, 3460, 493, 8964, 288, 22112, 14, 16878, 8, 16878, 14, 4947, 63, 4609, 4047, 12, 283, 3110, 450, 83, 7, 450, 21590, 904, 8, 1760, 430, 398, 372, 291, 14, 578, 14, 1065, 63, 1531, 8, 1760, 9, 339, 347, 1572, 63, 2264, 8, 277, 304, 267, 2088, 275, 359, 277, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 923, 2264, 297, 715, 395, 291, 14, 354, 61, 267, 372, 291, 14, 2526, 63, 1531, 8, 1760, 9, 339, 347, 1572, 63, 525, 8, 277, 12, 1011, 958, 304, 267, 2088, 275, 359, 277, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 923, 525, 297, 715, 1874, 267, 367, 790, 315, 2074, 26, 288, 340, 790, 508, 283, 8787, 7, 436, 2074, 59, 498, 61, 365, 440, 488, 26, 355, 2088, 14, 740, 3654, 71, 358, 355, 2088, 14, 740, 8, 958, 59, 498, 566, 288, 916, 790, 508, 283, 2253, 7, 436, 2074, 59, 498, 61, 508, 715, 26, 355, 2088, 14, 740, 3654, 82, 358, 267, 2088, 14, 740, 8, 277, 14, 354, 9, 267, 372, 291, 14, 2526, 63, 1531, 8, 1760, 9, 339, 347, 1572, 63, 1494, 8, 277, 12, 1011, 958, 304, 267, 2088, 275, 359, 277, 14, 578, 14, 362, 63, 1393, 63, 515, 360, 923, 1494, 297, 715, 1874, 267, 2256, 275, 291, 14, 923, 63, 815, 342, 267, 367, 790, 315, 2074, 26, 288, 340, 790, 508, 283, 8787, 356, 355, 340, 2074, 59, 498, 61, 365, 440, 488, 436, 2256, 59, 18, 61, 1137, 1109, 8, 958, 59, 498, 4682, 490, 2088, 14, 740, 3654, 71, 358, 490, 2088, 14, 740, 8, 958, 59, 498, 566, 267, 340, 822, 8, 1760, 9, 508, 413, 26, 288, 372, 334, 403, 12, 3260, 4074, 267, 340, 291, 14, 578, 14, 1074, 63, 632, 26, 288, 372, 334, 16, 12, 3260, 4074, 267, 2088, 14, 740, 8, 277, 14, 354, 9, 267, 372, 291, 14, 2526, 63, 1531, 8, 1760, 9, 339, 347, 1572, 63, 2444, 8, 277, 304, 267, 862, 26, 288, 340, 18598, 14, 362, 2587, 17811, 8, 277, 14, 354, 304, 355, 372, 715, 267, 871, 4067, 26, 288, 372, 756, 339, 347, 1572, 63, 815, 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, 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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 ]
dezelin/virtualbox
src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py
11
10222
# 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! THIS CODE IS AUTOGENERATED BY unpack.py */ #include "unpacker.h" #include "cr_opcodes.h" #include "cr_error.h" #include "cr_mem.h" #include "cr_spu.h" #include "unpack_extend.h" #include <stdio.h> #include <memory.h> #include <iprt/cdefs.h> DECLEXPORT(const unsigned char *) cr_unpackData = NULL; SPUDispatchTable cr_unpackDispatch; static void crUnpackExtend(void); static void crUnpackExtendDbg(void); /*#define CR_UNPACK_DEBUG_OPCODES*/ /*#define CR_UNPACK_DEBUG_LAST_OPCODES*/ """ nodebug_opcodes = [ "CR_MULTITEXCOORD2FARB_OPCODE", "CR_VERTEX3F_OPCODE", "CR_NORMAL3F_OPCODE", "CR_COLOR4UB_OPCODE", "CR_LOADIDENTITY_OPCODE", "CR_MATRIXMODE_OPCODE", "CR_LOADMATRIXF_OPCODE", "CR_DISABLE_OPCODE", "CR_COLOR4F_OPCODE", "CR_ENABLE_OPCODE", "CR_BEGIN_OPCODE", "CR_END_OPCODE", "CR_SECONDARYCOLOR3FEXT_OPCODE" ] nodebug_extopcodes = [ "CR_ACTIVETEXTUREARB_EXTEND_OPCODE" ] # # Useful functions # def ReadData( offset, arg_type ): """Emit a READ_DOUBLE or READ_DATA call for pulling a GL function argument out of the buffer's operand area.""" if arg_type == "GLdouble" or arg_type == "GLclampd": retval = "READ_DOUBLE( %d )" % offset else: retval = "READ_DATA( %d, %s )" % (offset, arg_type) return retval def FindReturnPointer( return_type, params ): """For GL functions that return values (either as the return value or through a pointer parameter) emit a SET_RETURN_PTR call.""" arg_len = apiutil.PacketLength( params ) if (return_type != 'void'): print '\tSET_RETURN_PTR( %d );' % (arg_len + 8) # extended opcode plus packet length else: paramList = [ ('foo', 'void *', 0) ] print '\tSET_RETURN_PTR( %d );' % (arg_len + 8 - apiutil.PacketLength(paramList)) def FindWritebackPointer( return_type, params ): """Emit a SET_WRITEBACK_PTR call.""" arg_len = apiutil.PacketLength( params ) if return_type != 'void': paramList = [ ('foo', 'void *', 0) ] arg_len += apiutil.PacketLength( paramList ) print '\tSET_WRITEBACK_PTR( %d );' % (arg_len + 8) # extended opcode plus packet length def MakeNormalCall( return_type, func_name, params, counter_init = 0 ): counter = counter_init copy_of_params = params[:] for i in range( 0, len(params) ): (name, type, vecSize) = params[i] if apiutil.IsPointer(copy_of_params[i][1]): params[i] = ('NULL', type, vecSize) copy_of_params[i] = (copy_of_params[i][0], 'void', 0) if not "get" in apiutil.Properties(func_name): print '\tcrError( "%s needs to be special cased!" );' % func_name else: print "\t%s %s = %s;" % ( copy_of_params[i][1], name, ReadData( counter, copy_of_params[i][1] ) ) counter += apiutil.sizeof(copy_of_params[i][1]) if ("get" in apiutil.Properties(func_name)): FindReturnPointer( return_type, params ) FindWritebackPointer( return_type, params ) if return_type != "void": print "\t(void)", else: print "\t", print "cr_unpackDispatch.%s( %s );" % (func_name, apiutil.MakeCallString(params)) def MakeVectorCall( return_type, func_name, arg_type ): """Convert a call like glVertex3f to glVertex3fv.""" vec_func = apiutil.VectorFunction(func_name) params = apiutil.Parameters(vec_func) assert len(params) == 1 (arg_name, vecType, vecSize) = params[0] if arg_type == "GLdouble" or arg_type == "GLclampd": print "#ifdef CR_UNALIGNED_ACCESS_OKAY" print "\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType) print "#else" for index in range(0, vecSize): print "\tGLdouble v" + `index` + " = READ_DOUBLE(", `index * 8`, ");" if return_type != "void": print "\t(void) cr_unpackDispatch.%s(" % func_name, else: print "\tcr_unpackDispatch.%s(" % func_name, for index in range(0, vecSize): print "v" + `index`, if index != vecSize - 1: print ",", print ");" print "#endif" else: print "\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType) keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") # # Generate unpack functions for all the simple functions. # for func_name in keys: if (not "pack" in apiutil.ChromiumProps(func_name) or apiutil.FindSpecial( "unpacker", func_name )): continue params = apiutil.Parameters(func_name) return_type = apiutil.ReturnType(func_name) print "static void crUnpack%s(void)" % func_name print "{" vector_func = apiutil.VectorFunction(func_name) if (vector_func and len(apiutil.Parameters(vector_func)) == 1): MakeVectorCall( return_type, func_name, params[0][1] ) else: MakeNormalCall( return_type, func_name, params ) packet_length = apiutil.PacketLength( params ) if packet_length == 0: print "\tINCR_DATA_PTR_NO_ARGS( );" else: print "\tINCR_DATA_PTR( %d );" % packet_length print "}\n" # # Emit some code # print """ typedef struct __dispatchNode { const unsigned char *unpackData; struct __dispatchNode *next; } DispatchNode; static DispatchNode *unpackStack = NULL; static SPUDispatchTable *cr_lastDispatch = NULL; void crUnpackPush(void) { DispatchNode *node = (DispatchNode*)crAlloc( sizeof( *node ) ); node->next = unpackStack; unpackStack = node; node->unpackData = cr_unpackData; } void crUnpackPop(void) { DispatchNode *node = unpackStack; if (!node) { crError( "crUnpackPop called with an empty stack!" ); } unpackStack = node->next; cr_unpackData = node->unpackData; crFree( node ); } void crUnpack( const void *data, const void *opcodes, unsigned int num_opcodes, SPUDispatchTable *table ) { unsigned int i; const unsigned char *unpack_opcodes; if (table != cr_lastDispatch) { crSPUCopyDispatchTable( &cr_unpackDispatch, table ); cr_lastDispatch = table; } unpack_opcodes = (const unsigned char *)opcodes; cr_unpackData = (const unsigned char *)data; #if defined(CR_UNPACK_DEBUG_OPCODES) || defined(CR_UNPACK_DEBUG_LAST_OPCODES) crDebug("crUnpack: %d opcodes", num_opcodes); #endif for (i = 0 ; i < num_opcodes ; i++) { CRDBGPTR_CHECKZ(writeback_ptr); CRDBGPTR_CHECKZ(return_ptr); /*crDebug(\"Unpacking opcode \%d\", *unpack_opcodes);*/ switch( *unpack_opcodes ) {""" # # Emit switch cases for all unextended opcodes # for func_name in keys: if "pack" in apiutil.ChromiumProps(func_name): print '\t\t\tcase %s:' % apiutil.OpcodeName( func_name ) if not apiutil.OpcodeName(func_name) in nodebug_opcodes: print """ #ifdef CR_UNPACK_DEBUG_LAST_OPCODES if (i==(num_opcodes-1)) #endif #if defined(CR_UNPACK_DEBUG_OPCODES) || defined(CR_UNPACK_DEBUG_LAST_OPCODES) crDebug("Unpack: %s"); #endif """ % apiutil.OpcodeName(func_name) print '\t\t\t\tcrUnpack%s(); \n\t\t\t\tbreak;' % func_name print """ case CR_EXTEND_OPCODE: #ifdef CR_UNPACK_DEBUG_OPCODES crUnpackExtendDbg(); #else # ifdef CR_UNPACK_DEBUG_LAST_OPCODES if (i==(num_opcodes-1)) crUnpackExtendDbg(); else # endif crUnpackExtend(); #endif break; default: crError( "Unknown opcode: %d", *unpack_opcodes ); break; } CRDBGPTR_CHECKZ(writeback_ptr); CRDBGPTR_CHECKZ(return_ptr); unpack_opcodes--; } }""" # # Emit unpack functions for extended opcodes, non-special functions only. # for func_name in keys: if ("extpack" in apiutil.ChromiumProps(func_name) and not apiutil.FindSpecial("unpacker", func_name)): return_type = apiutil.ReturnType(func_name) params = apiutil.Parameters(func_name) print 'static void crUnpackExtend%s(void)' % func_name print '{' MakeNormalCall( return_type, func_name, params, 8 ) print '}\n' print 'static void crUnpackExtend(void)' print '{' print '\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' ); print '' print '\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/' print '\tswitch( extend_opcode )' print '\t{' # # Emit switch statement for extended opcodes # for func_name in keys: if "extpack" in apiutil.ChromiumProps(func_name): print '\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name ) # print '\t\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name ) print '\t\t\tcrUnpackExtend%s( );' % func_name print '\t\t\tbreak;' print """ default: crError( "Unknown extended opcode: %d", (int) extend_opcode ); break; } INCR_VAR_PTR(); }""" print 'static void crUnpackExtendDbg(void)' print '{' print '\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' ); print '' print '\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/' print '\tswitch( extend_opcode )' print '\t{' # # Emit switch statement for extended opcodes # for func_name in keys: if "extpack" in apiutil.ChromiumProps(func_name): print '\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name ) if not apiutil.ExtendedOpcodeName(func_name) in nodebug_extopcodes: print '\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name ) print '\t\t\tcrUnpackExtend%s( );' % func_name print '\t\t\tbreak;' print """ default: crError( "Unknown extended opcode: %d", (int) extend_opcode ); break; } INCR_VAR_PTR(); }"""
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, 1, 221, 5749, 22547, 2281, 25420, 12795, 6989, 6515, 7787, 14, 647, 11589, 199, 199, 3, 2613, 298, 5301, 281, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 22022, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 705, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 5286, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 681, 85, 14, 72, 2, 199, 3, 2613, 298, 5301, 63, 2880, 14, 72, 2, 199, 3, 2613, 665, 32011, 14, 72, 30, 199, 3, 2613, 665, 4844, 14, 72, 30, 199, 199, 3, 2613, 665, 711, 2591, 15, 67, 8710, 14, 72, 30, 199, 199, 16387, 8066, 3657, 8, 1297, 7381, 1495, 24104, 2467, 63, 5301, 1451, 275, 5962, 27, 199, 5763, 53, 20628, 3186, 2467, 63, 5301, 20628, 27, 199, 199, 1986, 2309, 2467, 26472, 30775, 8, 1647, 2736, 199, 1986, 2309, 2467, 26472, 30775, 36, 6856, 8, 1647, 2736, 199, 199, 6331, 3, 4640, 17101, 63, 29100, 63, 5287, 63, 32382, 15870, 199, 6331, 3, 4640, 17101, 63, 29100, 63, 5287, 63, 16901, 63, 32382, 15870, 199, 624, 199, 199, 932, 1266, 63, 22022, 275, 359, 272, 298, 2944, 63, 8203, 649, 1438, 21901, 18, 38, 8611, 63, 23077, 401, 272, 298, 2944, 63, 15411, 19, 38, 63, 23077, 401, 272, 298, 2944, 63, 10765, 19, 38, 63, 23077, 401, 272, 298, 2944, 63, 7134, 20, 2533, 63, 23077, 401, 272, 298, 2944, 63, 7405, 7466, 1922, 63, 23077, 401, 272, 298, 2944, 63, 23483, 6963, 63, 23077, 401, 272, 298, 2944, 63, 7405, 23483, 38, 63, 23077, 401, 272, 298, 2944, 63, 13052, 63, 23077, 401, 272, 298, 2944, 63, 7134, 20, 38, 63, 23077, 401, 272, 298, 2944, 63, 8898, 63, 23077, 401, 272, 298, 2944, 63, 15947, 63, 23077, 401, 272, 298, 2944, 63, 3902, 63, 23077, 401, 272, 298, 2944, 63, 24236, 4392, 7134, 19, 38, 2472, 63, 23077, 2, 199, 61, 199, 199, 932, 1266, 63, 832, 22022, 275, 359, 272, 298, 2944, 63, 20425, 775, 2472, 3942, 8611, 63, 2472, 3902, 63, 23077, 2, 199, 61, 199, 199, 3, 199, 3, 18491, 3423, 199, 3, 199, 199, 318, 5574, 1451, 8, 3268, 12, 1680, 63, 466, 3461, 272, 408, 37, 1147, 282, 16767, 63, 14989, 503, 16767, 63, 3998, 1240, 367, 10299, 316, 282, 3563, 805, 272, 1423, 734, 402, 314, 3335, 1159, 14888, 9150, 1041, 272, 340, 1680, 63, 466, 508, 298, 2226, 3157, 2, 503, 1680, 63, 466, 508, 298, 2226, 3995, 311, 68, 582, 267, 9151, 275, 298, 5670, 63, 14989, 8, 450, 68, 776, 2, 450, 3268, 272, 587, 26, 267, 9151, 275, 298, 5670, 63, 3998, 8, 450, 68, 12, 450, 83, 776, 2, 450, 334, 2743, 12, 1680, 63, 466, 9, 272, 372, 9151, 421, 199, 318, 6668, 1767, 12190, 8, 372, 63, 466, 12, 1862, 3461, 272, 408, 1858, 3563, 3423, 626, 372, 1338, 334, 22051, 465, 314, 372, 574, 503, 272, 4012, 282, 7849, 2725, 9, 8689, 282, 11543, 63, 9677, 63, 14528, 1240, 1041, 272, 1680, 63, 552, 275, 2986, 1974, 14, 2726, 4625, 8, 1862, 776, 272, 340, 334, 1107, 63, 466, 1137, 283, 1647, 735, 267, 870, 1557, 84, 3597, 63, 9677, 63, 14528, 8, 450, 68, 776, 8942, 450, 334, 1273, 63, 552, 435, 1695, 9, 327, 9243, 10508, 12254, 3644, 2582, 272, 587, 26, 267, 1215, 1296, 275, 359, 661, 1421, 297, 283, 1647, 6039, 378, 9, 1622, 267, 870, 1557, 84, 3597, 63, 9677, 63, 14528, 8, 450, 68, 776, 8942, 450, 334, 1273, 63, 552, 435, 1695, 446, 2986, 1974, 14, 2726, 4625, 8, 635, 1296, 430, 421, 199, 318, 6668, 3534, 894, 12190, 8, 372, 63, 466, 12, 1862, 3461, 272, 408, 37, 1147, 282, 11543, 63, 10387, 7111, 63, 14528, 1240, 1041, 272, 1680, 63, 552, 275, 2986, 1974, 14, 2726, 4625, 8, 1862, 776, 272, 340, 372, 63, 466, 1137, 283, 1647, 356, 267, 1215, 1296, 275, 359, 661, 1421, 297, 283, 1647, 6039, 378, 9, 1622, 267, 1680, 63, 552, 847, 2986, 1974, 14, 2726, 4625, 8, 1215, 1296, 776, 339, 870, 1557, 84, 3597, 63, 10387, 7111, 63, 14528, 8, 450, 68, 776, 8942, 450, 334, 1273, 63, 552, 435, 1695, 9, 327, 9243, 10508, 12254, 3644, 2582, 421, 199, 318, 4155, 6241, 2176, 8, 372, 63, 466, 12, 2562, 63, 354, 12, 1862, 12, 7055, 63, 826, 275, 378, 3461, 272, 7055, 275, 7055, 63, 826, 272, 1331, 63, 1618, 63, 1162, 275, 1862, 5873, 339, 367, 284, 315, 1425, 8, 378, 12, 822, 8, 1162, 9, 3461, 267, 334, 354, 12, 730, 12, 10782, 2320, 9, 275, 1862, 59, 73, 61, 267, 340, 2986, 1974, 14, 1831, 12190, 8, 1574, 63, 1618, 63, 1162, 59, 73, 1527, 17, 4682, 288, 1862, 59, 73, 61, 275, 661, 8084, 297, 730, 12, 10782, 2320, 9, 288, 1331, 63, 1618, 63, 1162, 59, 73, 61, 275, 334, 1574, 63, 1618, 63, 1162, 59, 73, 1527, 16, 467, 283, 1647, 297, 378, 9, 288, 340, 440, 298, 362, 2, 315, 2986, 1974, 14, 8516, 8, 1532, 63, 354, 304, 355, 870, 1557, 84, 1556, 547, 8, 2071, 83, 4839, 370, 506, 4539, 1930, 68, 9539, 776, 8942, 450, 2562, 63, 354, 267, 587, 26, 288, 870, 1867, 84, 5, 83, 450, 83, 275, 450, 83, 9426, 450, 334, 1331, 63, 1618, 63, 1162, 59, 73, 1527, 17, 467, 536, 12, 5574, 1451, 8, 7055, 12, 1331, 63, 1618, 63, 1162, 59, 73, 1527, 17, 61, 776, 776, 267, 7055, 847, 2986, 1974, 14, 12590, 8, 1574, 63, 1618, 63, 1162, 59, 73, 1527, 17, 566, 339, 340, 1689, 362, 2, 315, 2986, 1974, 14, 8516, 8, 1532, 63, 354, 2298, 267, 6668, 1767, 12190, 8, 372, 63, 466, 12, 1862, 776, 267, 6668, 3534, 894, 12190, 8 ]
[ 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, 1, 221, 5749, 22547, 2281, 25420, 12795, 6989, 6515, 7787, 14, 647, 11589, 199, 199, 3, 2613, 298, 5301, 281, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 22022, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 705, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 5286, 14, 72, 2, 199, 3, 2613, 298, 1556, 63, 681, 85, 14, 72, 2, 199, 3, 2613, 298, 5301, 63, 2880, 14, 72, 2, 199, 3, 2613, 665, 32011, 14, 72, 30, 199, 3, 2613, 665, 4844, 14, 72, 30, 199, 199, 3, 2613, 665, 711, 2591, 15, 67, 8710, 14, 72, 30, 199, 199, 16387, 8066, 3657, 8, 1297, 7381, 1495, 24104, 2467, 63, 5301, 1451, 275, 5962, 27, 199, 5763, 53, 20628, 3186, 2467, 63, 5301, 20628, 27, 199, 199, 1986, 2309, 2467, 26472, 30775, 8, 1647, 2736, 199, 1986, 2309, 2467, 26472, 30775, 36, 6856, 8, 1647, 2736, 199, 199, 6331, 3, 4640, 17101, 63, 29100, 63, 5287, 63, 32382, 15870, 199, 6331, 3, 4640, 17101, 63, 29100, 63, 5287, 63, 16901, 63, 32382, 15870, 199, 624, 199, 199, 932, 1266, 63, 22022, 275, 359, 272, 298, 2944, 63, 8203, 649, 1438, 21901, 18, 38, 8611, 63, 23077, 401, 272, 298, 2944, 63, 15411, 19, 38, 63, 23077, 401, 272, 298, 2944, 63, 10765, 19, 38, 63, 23077, 401, 272, 298, 2944, 63, 7134, 20, 2533, 63, 23077, 401, 272, 298, 2944, 63, 7405, 7466, 1922, 63, 23077, 401, 272, 298, 2944, 63, 23483, 6963, 63, 23077, 401, 272, 298, 2944, 63, 7405, 23483, 38, 63, 23077, 401, 272, 298, 2944, 63, 13052, 63, 23077, 401, 272, 298, 2944, 63, 7134, 20, 38, 63, 23077, 401, 272, 298, 2944, 63, 8898, 63, 23077, 401, 272, 298, 2944, 63, 15947, 63, 23077, 401, 272, 298, 2944, 63, 3902, 63, 23077, 401, 272, 298, 2944, 63, 24236, 4392, 7134, 19, 38, 2472, 63, 23077, 2, 199, 61, 199, 199, 932, 1266, 63, 832, 22022, 275, 359, 272, 298, 2944, 63, 20425, 775, 2472, 3942, 8611, 63, 2472, 3902, 63, 23077, 2, 199, 61, 199, 199, 3, 199, 3, 18491, 3423, 199, 3, 199, 199, 318, 5574, 1451, 8, 3268, 12, 1680, 63, 466, 3461, 272, 408, 37, 1147, 282, 16767, 63, 14989, 503, 16767, 63, 3998, 1240, 367, 10299, 316, 282, 3563, 805, 272, 1423, 734, 402, 314, 3335, 1159, 14888, 9150, 1041, 272, 340, 1680, 63, 466, 508, 298, 2226, 3157, 2, 503, 1680, 63, 466, 508, 298, 2226, 3995, 311, 68, 582, 267, 9151, 275, 298, 5670, 63, 14989, 8, 450, 68, 776, 2, 450, 3268, 272, 587, 26, 267, 9151, 275, 298, 5670, 63, 3998, 8, 450, 68, 12, 450, 83, 776, 2, 450, 334, 2743, 12, 1680, 63, 466, 9, 272, 372, 9151, 421, 199, 318, 6668, 1767, 12190, 8, 372, 63, 466, 12, 1862, 3461, 272, 408, 1858, 3563, 3423, 626, 372, 1338, 334, 22051, 465, 314, 372, 574, 503, 272, 4012, 282, 7849, 2725, 9, 8689, 282, 11543, 63, 9677, 63, 14528, 1240, 1041, 272, 1680, 63, 552, 275, 2986, 1974, 14, 2726, 4625, 8, 1862, 776, 272, 340, 334, 1107, 63, 466, 1137, 283, 1647, 735, 267, 870, 1557, 84, 3597, 63, 9677, 63, 14528, 8, 450, 68, 776, 8942, 450, 334, 1273, 63, 552, 435, 1695, 9, 327, 9243, 10508, 12254, 3644, 2582, 272, 587, 26, 267, 1215, 1296, 275, 359, 661, 1421, 297, 283, 1647, 6039, 378, 9, 1622, 267, 870, 1557, 84, 3597, 63, 9677, 63, 14528, 8, 450, 68, 776, 8942, 450, 334, 1273, 63, 552, 435, 1695, 446, 2986, 1974, 14, 2726, 4625, 8, 635, 1296, 430, 421, 199, 318, 6668, 3534, 894, 12190, 8, 372, 63, 466, 12, 1862, 3461, 272, 408, 37, 1147, 282, 11543, 63, 10387, 7111, 63, 14528, 1240, 1041, 272, 1680, 63, 552, 275, 2986, 1974, 14, 2726, 4625, 8, 1862, 776, 272, 340, 372, 63, 466, 1137, 283, 1647, 356, 267, 1215, 1296, 275, 359, 661, 1421, 297, 283, 1647, 6039, 378, 9, 1622, 267, 1680, 63, 552, 847, 2986, 1974, 14, 2726, 4625, 8, 1215, 1296, 776, 339, 870, 1557, 84, 3597, 63, 10387, 7111, 63, 14528, 8, 450, 68, 776, 8942, 450, 334, 1273, 63, 552, 435, 1695, 9, 327, 9243, 10508, 12254, 3644, 2582, 421, 199, 318, 4155, 6241, 2176, 8, 372, 63, 466, 12, 2562, 63, 354, 12, 1862, 12, 7055, 63, 826, 275, 378, 3461, 272, 7055, 275, 7055, 63, 826, 272, 1331, 63, 1618, 63, 1162, 275, 1862, 5873, 339, 367, 284, 315, 1425, 8, 378, 12, 822, 8, 1162, 9, 3461, 267, 334, 354, 12, 730, 12, 10782, 2320, 9, 275, 1862, 59, 73, 61, 267, 340, 2986, 1974, 14, 1831, 12190, 8, 1574, 63, 1618, 63, 1162, 59, 73, 1527, 17, 4682, 288, 1862, 59, 73, 61, 275, 661, 8084, 297, 730, 12, 10782, 2320, 9, 288, 1331, 63, 1618, 63, 1162, 59, 73, 61, 275, 334, 1574, 63, 1618, 63, 1162, 59, 73, 1527, 16, 467, 283, 1647, 297, 378, 9, 288, 340, 440, 298, 362, 2, 315, 2986, 1974, 14, 8516, 8, 1532, 63, 354, 304, 355, 870, 1557, 84, 1556, 547, 8, 2071, 83, 4839, 370, 506, 4539, 1930, 68, 9539, 776, 8942, 450, 2562, 63, 354, 267, 587, 26, 288, 870, 1867, 84, 5, 83, 450, 83, 275, 450, 83, 9426, 450, 334, 1331, 63, 1618, 63, 1162, 59, 73, 1527, 17, 467, 536, 12, 5574, 1451, 8, 7055, 12, 1331, 63, 1618, 63, 1162, 59, 73, 1527, 17, 61, 776, 776, 267, 7055, 847, 2986, 1974, 14, 12590, 8, 1574, 63, 1618, 63, 1162, 59, 73, 1527, 17, 566, 339, 340, 1689, 362, 2, 315, 2986, 1974, 14, 8516, 8, 1532, 63, 354, 2298, 267, 6668, 1767, 12190, 8, 372, 63, 466, 12, 1862, 776, 267, 6668, 3534, 894, 12190, 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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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 ]
sudheesh001/oh-mainline
vendor/packages/gdata/tests/gdata_tests/projecthosting/data_test.py
41
6526
#!/usr/bin/env python # # Copyright (C) 2009 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # This module is used for version 2 of the Google Data APIs. __author__ = 'jlapenna@google.com (Joe LaPenna)' import unittest from gdata import test_data import gdata.projecthosting.data import atom.core import gdata.test_config as conf ISSUE_ENTRY = """\ <entry xmlns='http://www.w3.org/2005/Atom' xmlns:issues='http://schemas.google.com/projecthosting/issues/2009'> <id>http://code.google.com/feeds/issues/p/PROJECT_NAME/issues/full/1</id> <updated>2009-09-09T20:34:35.365Z</updated> <title>This is updated issue summary</title> <content type='html'>This is issue description</content> <link rel='self' type='application/atom+xml' href='http://code.google.com/feeds/issues/p/PROJECT_NAME/issues/full/3'/> <link rel='edit' type='application/atom+xml' href='http://code.google.com/feeds/issues/p/PROJECT_NAME/issues/full/3'/> <author> <name>elizabeth.bennet</name> <uri>/u/elizabeth.bennet/</uri> </author> <issues:cc> <issues:uri>/u/@UBhTQl1UARRAVga7/</issues:uri> <issues:username>mar...@domain.com</issues:username> </issues:cc> <issues:cc> <issues:uri>/u/fitzwilliam.darcy/</issues:uri> <issues:username>fitzwilliam.darcy</issues:username> </issues:cc> <issues:label>Type-Enhancement</issues:label> <issues:label>Priority-Low</issues:label> <issues:owner> <issues:uri>/u/charlotte.lucas/</issues:uri> <issues:username>charlotte.lucas</issues:username> </issues:owner> <issues:stars>0</issues:stars> <issues:state>open</issues:state> <issues:status>Started</issues:status> </entry> """ ISSUES_FEED = """\ <?xml version='1.0' encoding='UTF-8'?> <feed xmlns='http://www.w3.org/2005/Atom'> <id>http://code.google.com/feeds/issues/p/android-test2/issues/full</id> <link href="http://code.google.com/feeds/issues/p/android-test2/issues/full" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" /> <link href="http://code.google.com/feeds/issues/p/android-test2/issues/full" rel="http://schemas.google.com/g/2005#post" type="application/atom+xml" /> <link href="http://code.google.com/feeds/issues/p/android-test2/issues/full" rel="self" type="application/atom+xml" /> <updated>2009-09-22T04:06:32.794Z</updated> %s </feed> """ % ISSUE_ENTRY COMMENT_ENTRY = """\ <?xml version='1.0' encoding='UTF-8'?> <entry xmlns='http://www.w3.org/2005/Atom' xmlns:issues='http://schemas.google.com/projecthosting/issues/2009'> <content type='html'>This is comment - update issue</content> <author> <name>elizabeth.bennet</name> </author> <issues:updates> <issues:summary>This is updated issue summary</issues:summary> <issues:status>Started</issues:status> <issues:ownerUpdate>charlotte.lucas</issues:ownerUpdate> <issues:label>-Type-Defect</issues:label> <issues:label>Type-Enhancement</issues:label> <issues:label>-Milestone-2009</issues:label> <issues:label>-Priority-Medium</issues:label> <issues:label>Priority-Low</issues:label> <issues:ccUpdate>-fitzwilliam.darcy</issues:ccUpdate> <issues:ccUpdate>marialucas@domain.com</issues:ccUpdate> </issues:updates> </entry> """ class CommentEntryTest(unittest.TestCase): def testParsing(self): entry = atom.core.parse(COMMENT_ENTRY, gdata.projecthosting.data.CommentEntry) updates = entry.updates self.assertEquals(updates.summary.text, 'This is updated issue summary') self.assertEquals(updates.status.text, 'Started') self.assertEquals(updates.ownerUpdate.text, 'charlotte.lucas') self.assertEquals(len(updates.label), 5) self.assertEquals(updates.label[0].text, '-Type-Defect') self.assertEquals(updates.label[1].text, 'Type-Enhancement') self.assertEquals(updates.label[2].text, '-Milestone-2009') self.assertEquals(updates.label[3].text, '-Priority-Medium') self.assertEquals(updates.label[4].text, 'Priority-Low') self.assertEquals(len(updates.ccUpdate), 2) self.assertEquals(updates.ccUpdate[0].text, '-fitzwilliam.darcy') self.assertEquals(updates.ccUpdate[1].text, 'marialucas@domain.com') class IssueEntryTest(unittest.TestCase): def testParsing(self): entry = atom.core.parse(ISSUE_ENTRY, gdata.projecthosting.data.IssueEntry) self.assertEquals(entry.owner.uri.text, '/u/charlotte.lucas/') self.assertEqual(entry.owner.username.text, 'charlotte.lucas') self.assertEquals(len(entry.cc), 2) cc_0 = entry.cc[0] self.assertEquals(cc_0.uri.text, '/u/@UBhTQl1UARRAVga7/') self.assertEquals(cc_0.username.text, 'mar...@domain.com') cc_1 = entry.cc[1] self.assertEquals(cc_1.uri.text, '/u/fitzwilliam.darcy/') self.assertEquals(cc_1.username.text, 'fitzwilliam.darcy') self.assertEquals(len(entry.label), 2) self.assertEquals(entry.label[0].text, 'Type-Enhancement') self.assertEquals(entry.label[1].text, 'Priority-Low') self.assertEquals(entry.stars.text, '0') self.assertEquals(entry.state.text, 'open') self.assertEquals(entry.status.text, 'Started') class DataClassSanityTest(unittest.TestCase): def test_basic_element_structure(self): conf.check_data_classes(self, [ gdata.projecthosting.data.Uri, gdata.projecthosting.data.Username, gdata.projecthosting.data.Cc, gdata.projecthosting.data.Label, gdata.projecthosting.data.Owner, gdata.projecthosting.data.Stars, gdata.projecthosting.data.State, gdata.projecthosting.data.Status, gdata.projecthosting.data.Summary, gdata.projecthosting.data.Updates, gdata.projecthosting.data.IssueEntry, gdata.projecthosting.data.IssuesFeed, gdata.projecthosting.data.CommentEntry, gdata.projecthosting.data.CommentsFeed]) def suite(): return conf.build_suite([IssueEntryTest, DataClassSanityTest]) if __name__ == '__main__': unittest.main()
agpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4475, 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, 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, 3, 961, 859, 365, 1202, 367, 1015, 499, 402, 314, 4475, 3918, 15913, 14, 199, 199, 363, 2502, 363, 275, 283, 74, 416, 897, 3540, 32, 3098, 14, 957, 334, 5691, 69, 7964, 15597, 3540, 3171, 421, 199, 646, 2882, 199, 199, 504, 11006, 492, 511, 63, 576, 199, 199, 646, 11006, 14, 5468, 825, 15157, 316, 14, 576, 199, 646, 6222, 14, 1018, 199, 646, 11006, 14, 396, 63, 888, 465, 3743, 421, 199, 1311, 51, 4187, 63, 7285, 275, 9638, 199, 28, 2373, 9604, 534, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 7, 267, 9604, 26, 10115, 534, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5468, 825, 15157, 316, 15, 10115, 15, 8664, 8423, 523, 665, 344, 30, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 10797, 63, 2339, 15, 10115, 15, 2861, 15, 17, 1108, 344, 30, 523, 665, 5334, 30, 8664, 13, 1643, 13, 1643, 52, 1165, 26, 1082, 26, 1276, 14, 12664, 58, 1108, 5334, 30, 523, 665, 1213, 30, 2765, 365, 4588, 4976, 6212, 1108, 1213, 30, 523, 665, 1317, 730, 534, 1360, 8423, 2765, 365, 4976, 1369, 1108, 1317, 30, 523, 665, 1073, 4668, 534, 277, 7, 730, 534, 3578, 15, 4188, 11, 1652, 7, 489, 4369, 534, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 10797, 63, 2339, 15, 10115, 15, 2861, 15, 19, 22619, 523, 665, 1073, 4668, 534, 3773, 7, 730, 534, 3578, 15, 4188, 11, 1652, 7, 489, 4369, 534, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 10797, 63, 2339, 15, 10115, 15, 2861, 15, 19, 22619, 523, 665, 2502, 30, 272, 665, 354, 30, 18865, 90, 7570, 273, 14, 18486, 846, 1108, 354, 30, 272, 665, 2302, 12202, 85, 15, 18865, 90, 7570, 273, 14, 18486, 846, 15, 1108, 2302, 30, 523, 3068, 2502, 30, 523, 665, 10115, 26, 2055, 30, 272, 665, 10115, 26, 2302, 12202, 85, 15, 32, 2533, 72, 52, 49, 76, 17, 53, 1920, 6087, 5294, 23, 15, 1108, 10115, 26, 2302, 30, 272, 665, 10115, 26, 2473, 30, 4584, 1396, 32, 2261, 14, 957, 1108, 10115, 26, 2473, 30, 523, 3068, 10115, 26, 2055, 30, 523, 665, 10115, 26, 2055, 30, 272, 665, 10115, 26, 2302, 12202, 85, 15, 3269, 90, 87, 8148, 455, 14, 4460, 1480, 15, 1108, 10115, 26, 2302, 30, 272, 665, 10115, 26, 2473, 30, 3269, 90, 87, 8148, 455, 14, 4460, 1480, 1108, 10115, 26, 2473, 30, 523, 3068, 10115, 26, 2055, 30, 523, 665, 10115, 26, 1302, 30, 804, 13, 1327, 14666, 434, 1108, 10115, 26, 1302, 30, 523, 665, 10115, 26, 1302, 30, 14354, 13, 10281, 1108, 10115, 26, 1302, 30, 523, 665, 10115, 26, 4597, 30, 272, 665, 10115, 26, 2302, 12202, 85, 15, 1560, 1653, 266, 14, 29918, 305, 15, 1108, 10115, 26, 2302, 30, 272, 665, 10115, 26, 2473, 30, 1560, 1653, 266, 14, 29918, 305, 1108, 10115, 26, 2473, 30, 523, 3068, 10115, 26, 4597, 30, 523, 665, 10115, 26, 270, 4291, 30, 16, 1108, 10115, 26, 270, 4291, 30, 523, 665, 10115, 26, 929, 30, 1490, 1108, 10115, 26, 929, 30, 523, 665, 10115, 26, 1205, 30, 21031, 1108, 10115, 26, 1205, 30, 199, 1108, 2373, 30, 199, 624, 199, 199, 1311, 6195, 654, 63, 18068, 275, 9638, 199, 28, 31, 1652, 1015, 534, 17, 14, 16, 7, 2644, 534, 6610, 13, 24, 27716, 30, 199, 28, 3871, 9604, 534, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 8423, 523, 665, 344, 30, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 6238, 13, 396, 18, 15, 10115, 15, 2861, 1108, 344, 30, 523, 665, 1073, 4369, 628, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 6238, 13, 396, 18, 15, 10115, 15, 2861, 2, 489, 4668, 628, 1014, 921, 9482, 14, 3098, 14, 957, 15, 71, 15, 9397, 3, 3871, 2, 730, 628, 3578, 15, 4188, 11, 1652, 2, 7082, 523, 665, 1073, 4369, 628, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 6238, 13, 396, 18, 15, 10115, 15, 2861, 2, 489, 4668, 628, 1014, 921, 9482, 14, 3098, 14, 957, 15, 71, 15, 9397, 3, 1932, 2, 730, 628, 3578, 15, 4188, 11, 1652, 2, 7082, 523, 665, 1073, 4369, 628, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 6238, 13, 396, 18, 15, 10115, 15, 2861, 2, 489, 4668, 628, 277, 2, 730, 628, 3578, 15, 4188, 11, 1652, 2, 7082, 523, 665, 5334, 30, 8664, 13, 1643, 13, 1081, 52, 966, 26, 1690, 26, 708, 14, 21618, 58, 1108, 5334, 30, 523, 450, 83, 199, 1108, 3871, 30, 199, 624, 450, 2281, 51, 4187, 63, 7285, 421, 199, 10973, 63, 7285, 275, 9638, 199, 28, 31, 1652, 1015, 534, 17, 14, 16, 7, 2644, 534, 6610, 13, 24, 27716, 30, 199, 28, 2373, 9604, 534, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 7, 272, 9604, 26, 10115, 534, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5468, 825, 15157, 316, 15 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 4475, 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, 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, 3, 961, 859, 365, 1202, 367, 1015, 499, 402, 314, 4475, 3918, 15913, 14, 199, 199, 363, 2502, 363, 275, 283, 74, 416, 897, 3540, 32, 3098, 14, 957, 334, 5691, 69, 7964, 15597, 3540, 3171, 421, 199, 646, 2882, 199, 199, 504, 11006, 492, 511, 63, 576, 199, 199, 646, 11006, 14, 5468, 825, 15157, 316, 14, 576, 199, 646, 6222, 14, 1018, 199, 646, 11006, 14, 396, 63, 888, 465, 3743, 421, 199, 1311, 51, 4187, 63, 7285, 275, 9638, 199, 28, 2373, 9604, 534, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 7, 267, 9604, 26, 10115, 534, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5468, 825, 15157, 316, 15, 10115, 15, 8664, 8423, 523, 665, 344, 30, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 10797, 63, 2339, 15, 10115, 15, 2861, 15, 17, 1108, 344, 30, 523, 665, 5334, 30, 8664, 13, 1643, 13, 1643, 52, 1165, 26, 1082, 26, 1276, 14, 12664, 58, 1108, 5334, 30, 523, 665, 1213, 30, 2765, 365, 4588, 4976, 6212, 1108, 1213, 30, 523, 665, 1317, 730, 534, 1360, 8423, 2765, 365, 4976, 1369, 1108, 1317, 30, 523, 665, 1073, 4668, 534, 277, 7, 730, 534, 3578, 15, 4188, 11, 1652, 7, 489, 4369, 534, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 10797, 63, 2339, 15, 10115, 15, 2861, 15, 19, 22619, 523, 665, 1073, 4668, 534, 3773, 7, 730, 534, 3578, 15, 4188, 11, 1652, 7, 489, 4369, 534, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 10797, 63, 2339, 15, 10115, 15, 2861, 15, 19, 22619, 523, 665, 2502, 30, 272, 665, 354, 30, 18865, 90, 7570, 273, 14, 18486, 846, 1108, 354, 30, 272, 665, 2302, 12202, 85, 15, 18865, 90, 7570, 273, 14, 18486, 846, 15, 1108, 2302, 30, 523, 3068, 2502, 30, 523, 665, 10115, 26, 2055, 30, 272, 665, 10115, 26, 2302, 12202, 85, 15, 32, 2533, 72, 52, 49, 76, 17, 53, 1920, 6087, 5294, 23, 15, 1108, 10115, 26, 2302, 30, 272, 665, 10115, 26, 2473, 30, 4584, 1396, 32, 2261, 14, 957, 1108, 10115, 26, 2473, 30, 523, 3068, 10115, 26, 2055, 30, 523, 665, 10115, 26, 2055, 30, 272, 665, 10115, 26, 2302, 12202, 85, 15, 3269, 90, 87, 8148, 455, 14, 4460, 1480, 15, 1108, 10115, 26, 2302, 30, 272, 665, 10115, 26, 2473, 30, 3269, 90, 87, 8148, 455, 14, 4460, 1480, 1108, 10115, 26, 2473, 30, 523, 3068, 10115, 26, 2055, 30, 523, 665, 10115, 26, 1302, 30, 804, 13, 1327, 14666, 434, 1108, 10115, 26, 1302, 30, 523, 665, 10115, 26, 1302, 30, 14354, 13, 10281, 1108, 10115, 26, 1302, 30, 523, 665, 10115, 26, 4597, 30, 272, 665, 10115, 26, 2302, 12202, 85, 15, 1560, 1653, 266, 14, 29918, 305, 15, 1108, 10115, 26, 2302, 30, 272, 665, 10115, 26, 2473, 30, 1560, 1653, 266, 14, 29918, 305, 1108, 10115, 26, 2473, 30, 523, 3068, 10115, 26, 4597, 30, 523, 665, 10115, 26, 270, 4291, 30, 16, 1108, 10115, 26, 270, 4291, 30, 523, 665, 10115, 26, 929, 30, 1490, 1108, 10115, 26, 929, 30, 523, 665, 10115, 26, 1205, 30, 21031, 1108, 10115, 26, 1205, 30, 199, 1108, 2373, 30, 199, 624, 199, 199, 1311, 6195, 654, 63, 18068, 275, 9638, 199, 28, 31, 1652, 1015, 534, 17, 14, 16, 7, 2644, 534, 6610, 13, 24, 27716, 30, 199, 28, 3871, 9604, 534, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 8423, 523, 665, 344, 30, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 6238, 13, 396, 18, 15, 10115, 15, 2861, 1108, 344, 30, 523, 665, 1073, 4369, 628, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 6238, 13, 396, 18, 15, 10115, 15, 2861, 2, 489, 4668, 628, 1014, 921, 9482, 14, 3098, 14, 957, 15, 71, 15, 9397, 3, 3871, 2, 730, 628, 3578, 15, 4188, 11, 1652, 2, 7082, 523, 665, 1073, 4369, 628, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 6238, 13, 396, 18, 15, 10115, 15, 2861, 2, 489, 4668, 628, 1014, 921, 9482, 14, 3098, 14, 957, 15, 71, 15, 9397, 3, 1932, 2, 730, 628, 3578, 15, 4188, 11, 1652, 2, 7082, 523, 665, 1073, 4369, 628, 1014, 921, 600, 14, 3098, 14, 957, 15, 11522, 15, 10115, 15, 80, 15, 6238, 13, 396, 18, 15, 10115, 15, 2861, 2, 489, 4668, 628, 277, 2, 730, 628, 3578, 15, 4188, 11, 1652, 2, 7082, 523, 665, 5334, 30, 8664, 13, 1643, 13, 1081, 52, 966, 26, 1690, 26, 708, 14, 21618, 58, 1108, 5334, 30, 523, 450, 83, 199, 1108, 3871, 30, 199, 624, 450, 2281, 51, 4187, 63, 7285, 421, 199, 10973, 63, 7285, 275, 9638, 199, 28, 31, 1652, 1015, 534, 17, 14, 16, 7, 2644, 534, 6610, 13, 24, 27716, 30, 199, 28, 2373, 9604, 534, 1014, 921, 1544, 14, 87, 19, 14, 1308, 15, 9397, 15, 12097, 7, 272, 9604, 26, 10115, 534, 1014, 921, 9482, 14, 3098, 14, 957, 15, 5468, 825, 15157, 316, 15, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
handroissuazo/tensorflow
tensorflow/python/kernel_tests/losses_test.py
21
54130
# 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 losses.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors_impl from tensorflow.python.framework import ops from tensorflow.python.framework import random_seed from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope from tensorflow.python.ops import variables from tensorflow.python.ops.losses import losses from tensorflow.python.ops.losses import util from tensorflow.python.platform import test from tensorflow.python.training import momentum as momentum_lib class AbsoluteDifferenceLossTest(test.TestCase): def setUp(self): self._predictions = constant_op.constant([4, 8, 12, 8, 1, 3], shape=(2, 3)) self._labels = constant_op.constant([1, 9, 2, -5, -2, 6], shape=(2, 3)) def testValueErrorThrownWhenWeightIsNone(self): with self.test_session(): with self.assertRaises(ValueError): losses.absolute_difference( self._predictions, self._predictions, weights=None) def testAllCorrectNoLossWeight(self): loss = losses.absolute_difference(self._predictions, self._predictions) with self.test_session(): self.assertAlmostEqual(0.0, loss.eval(), 3) def testNonZeroLoss(self): loss = losses.absolute_difference(self._labels, self._predictions) with self.test_session(): self.assertAlmostEqual(5.5, loss.eval(), 3) def testNonZeroLossWithPythonScalarWeight(self): weights = 2.3 loss = losses.absolute_difference(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(5.5 * weights, loss.eval(), 3) def testNonZeroLossWithScalarTensorWeight(self): weights = 2.3 loss = losses.absolute_difference(self._labels, self._predictions, constant_op.constant(weights)) with self.test_session(): self.assertAlmostEqual(5.5 * weights, loss.eval(), 3) def testNonZeroLossWithOneDimBatchSpecificWeights(self): weights = constant_op.constant((1.2, 0.0), shape=(2, 1)) loss = losses.absolute_difference(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(5.6, loss.eval(), 3) def testNonZeroLossWithTwoDimBatchSpecificWeights(self): weights = constant_op.constant([1.2, 0.0], shape=[2, 1]) loss = losses.absolute_difference(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(5.6, loss.eval(), 3) def testNonZeroLossWithSampleSpecificWeights(self): weights = constant_op.constant([3, 6, 5, 0, 4, 2], shape=[2, 3]) loss = losses.absolute_difference(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(16.6, loss.eval(), 3) def testNonZeroLossWithSampleSpecificWeightsMostZero(self): weights = constant_op.constant([0, 0, 0, 0, 0, 2], shape=[2, 3]) loss = losses.absolute_difference(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(6.0, loss.eval(), 3) def testLossWithSampleSpecificWeightsAllZero(self): weights = array_ops.zeros((2, 3)) loss = losses.absolute_difference(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(0.0, loss.eval(), 3) class SoftmaxCrossEntropyLossTest(test.TestCase): def testNoneWeightRaisesValueError(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) with self.test_session(): with self.assertRaises(ValueError): losses.softmax_cross_entropy(labels, logits, weights=None) def testAllCorrect(self): with self.test_session(): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) loss = losses.softmax_cross_entropy(labels, logits) self.assertEquals('softmax_cross_entropy_loss/value', loss.op.name) self.assertAlmostEqual(loss.eval(), 0.0, 3) def testAllWrong(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0, 0, 1], [1, 0, 0], [0, 1, 0]]) with self.test_session(): loss = losses.softmax_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 10.0, 3) def testNonZeroLossWithPythonScalarWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0, 0, 1], [1, 0, 0], [0, 1, 0]]) weights = 2.3 with self.test_session(): loss = losses.softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(weights * 10.0, loss.eval(), 3) def testNonZeroLossWithScalarTensorWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0, 0, 1], [1, 0, 0], [0, 1, 0]]) weights = 2.3 with self.test_session(): loss = losses.softmax_cross_entropy(labels, logits, constant_op.constant(weights)) self.assertAlmostEqual(weights * 10.0, loss.eval(), 3) def testNonZeroLossWithOneDimBatchSpecificWeights(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0, 0, 1], [1, 0, 0], [0, 1, 0]]) weights = constant_op.constant((1.2, 3.4, 5.6)) with self.test_session(): loss = losses.softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual((1.2 + 3.4 + 5.6) * 10.0 / 3.0, loss.eval(), 3) def testAllWrongAllWeightsMissing(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0, 0, 1], [1, 0, 0], [0, 1, 0]]) weights = constant_op.constant([0, 0, 0], shape=[3]) with self.test_session(): loss = losses.softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(0.0, loss.eval(), 3) def testSomeWeightsMissing(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0, 0, 1], [1, 0, 0], [0, 1, 0]]) weights = constant_op.constant([1.2, 0, 0], shape=[3]) with self.test_session(): loss = losses.softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(12.0, loss.eval(), 3) def testSoftmaxWithMeasurementSpecificWeightsRaisesException(self): with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], [-100.0, 100.0, -100.0], [-100.0, -100.0, 100.0]]) labels = constant_op.constant([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) weights = constant_op.constant([[3, 4, 5], [2, 6, 0], [8, 0, 1]]) with self.assertRaises(ValueError): losses.softmax_cross_entropy(labels, logits, weights=weights).eval() def testSoftmaxLabelSmoothing(self): with self.test_session(): # Softmax Cross Entropy Loss is: # -\sum_i p_i \log q_i # where for a softmax activation # \log q_i = x_i - \log \sum_j \exp x_j # = x_i - x_max - \log \sum_j \exp (x_j - x_max) # For our activations, [100, -100, -100] the log partion function becomes # \log ( exp(0) + exp(-200) + exp(-200) ) = 0 # so our log softmaxes become: [0, -200, -200] # so our cross entropy loss is: # -(1 - L + L/n) * 0 + 400 * L/n = 400 L/n logits = constant_op.constant([[100.0, -100.0, -100.0]]) labels = constant_op.constant([[1, 0, 0]]) label_smoothing = 0.1 loss = losses.softmax_cross_entropy( labels, logits, label_smoothing=label_smoothing) self.assertEquals(loss.op.name, 'softmax_cross_entropy_loss/value') expected_value = 400.0 * label_smoothing / 3.0 self.assertAlmostEqual(loss.eval(), expected_value, 3) class SparseSoftmaxCrossEntropyLossTest(test.TestCase): def testNoneWeightRaisesValueError(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0], [1], [2]]) with self.test_session(): with self.assertRaises(ValueError): losses.sparse_softmax_cross_entropy(labels, logits, weights=None) def testAllCorrectInt32Labels(self): with self.test_session(): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0], [1], [2]], dtype=dtypes.int32) loss = losses.sparse_softmax_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 0.0, 3) def testAllCorrectInt64Labels(self): with self.test_session(): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[0], [1], [2]], dtype=dtypes.int64) loss = losses.sparse_softmax_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 0.0, 3) def testAllCorrectNonColumnLabels(self): with self.test_session(): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([0, 1, 2]) loss = losses.sparse_softmax_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 0.0, 3) def testAllWrongInt32Labels(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]], dtype=dtypes.int32) with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 10.0, 3) def testAllWrongInt64Labels(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]], dtype=dtypes.int64) with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 10.0, 3) def testAllWrongNonColumnLabels(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([2, 0, 1]) with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sparse_softmax_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 10.0, 3) def testNonZeroLossWithPythonScalarWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]]) weights = 2.3 with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(weights * 10.0, loss.eval(), 3) def testNonZeroLossWithScalarTensorWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]]) weights = 2.3 with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits, constant_op.constant(weights)) self.assertAlmostEqual(weights * 10.0, loss.eval(), 3) def testNonZeroLossWith1DTensorWeight(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]]) weights = 2.3 with self.test_session(): loss = losses.sparse_softmax_cross_entropy( labels, logits, constant_op.constant((weights,))) self.assertAlmostEqual(weights * 10.0, loss.eval(), 3) def testNonZeroLossWithPlaceholderForWeights(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]]) weights = array_ops.placeholder(dtypes.float32) with self.test_session() as sess: loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) loss_val = sess.run(loss, feed_dict={weights: ((1.2,), (3.4,), (5.6,))}) self.assertAlmostEqual((1.2 + 3.4 + 5.6) * 10.0 / 3.0, loss_val, 3) def testNonZeroLossWithPlaceholderForLogitsLabelsAndWeights(self): logits = array_ops.placeholder(dtypes.float32, shape=(None, 3)) labels = array_ops.placeholder(dtypes.int32, shape=(None, 1)) weights = array_ops.placeholder(dtypes.float32) with self.test_session() as sess: loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) loss_val = sess.run(loss, feed_dict={ logits: [[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]], labels: [[2], [0], [1]], weights: ((1.2,), (3.4,), (5.6,)), }) self.assertAlmostEqual((1.2 + 3.4 + 5.6) * 10.0 / 3.0, loss_val, 3) def testNonZeroLossWithOneDimBatchSpecificWeights(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]]) weights = constant_op.constant([1.2, 3.4, 5.6], shape=(3, 1)) with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual((1.2 + 3.4 + 5.6) * 10.0 / 3.0, loss.eval(), 3) def testNonZeroLossWithColumnWeights(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]]) weights = constant_op.constant([[1.2], [3.4], [5.6]]) with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual((1.2 + 3.4 + 5.6) * 10.0 / 3.0, loss.eval(), 3) def testAllWrongAllWeightsMissing(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]]) weights = constant_op.constant([0, 0, 0], shape=(3, 1)) with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(0.0, loss.eval(), 3) def testSomeWeightsMissing(self): logits = constant_op.constant([[10.0, 0.0, 0.0], [0.0, 10.0, 0.0], [0.0, 0.0, 10.0]]) labels = constant_op.constant([[2], [0], [1]]) weights = constant_op.constant([1.2, 0, 0], shape=(3, 1)) with self.test_session(): loss = losses.sparse_softmax_cross_entropy(labels, logits, weights) self.assertAlmostEqual(12.0, loss.eval(), 3) def testMeasurementSpecificWeightsRaisesException(self): with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], [-100.0, 100.0, -100.0], [-100.0, -100.0, 100.0]]) labels = constant_op.constant([[0], [1], [2]]) weights = constant_op.constant([[3, 4, 5], [2, 6, 0], [8, 0, 1]]) with self.assertRaises(ValueError): losses.sparse_softmax_cross_entropy( labels, logits, weights=weights).eval() def testInconsistentWeightSizeRaisesException(self): """The weight tensor has incorrect number of elements.""" with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], [-100.0, 100.0, -100.0], [-100.0, -100.0, 100.0]]) labels = constant_op.constant([[0], [1], [2]]) weights = constant_op.constant([1.2, 3.4, 5.6, 7.8]) with self.assertRaises(ValueError): losses.sparse_softmax_cross_entropy( labels, logits, weights=weights).eval() def testInconsistentLabelSizeRaisesException(self): """The label tensor has incorrect number of elements.""" with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], [-100.0, 100.0, -100.0], [-100.0, -100.0, 100.0]]) labels = constant_op.constant([[0], [1], [2], [3]]) weights = constant_op.constant([1.2, 3.4, 5.6]) with self.assertRaises(ValueError): losses.sparse_softmax_cross_entropy( labels, logits, weights=weights).eval() def testInconsistentWeightShapeRaisesException(self): """The weight tensor has incorrect shape.""" with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0, -100.0], [-100.0, 100.0, -100.0, -100.0], [-100.0, -100.0, 100.0, -100.0], [-100.0, -100.0, -100.0, 100.0]]) labels = constant_op.constant([[0], [1], [2], [3]]) weights = constant_op.constant([[1.2, 3.4], [5.6, 7.8]]) with self.assertRaises(ValueError): losses.sparse_softmax_cross_entropy( labels, logits, weights=weights).eval() def testInconsistentLabelShapeRaisesException(self): """The label tensor has incorrect shape.""" with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0, -100.0], [-100.0, 100.0, -100.0, -100.0], [-100.0, -100.0, 100.0, -100.0], [-100.0, -100.0, -100.0, 100.0]]) labels = constant_op.constant([[0, 1], [2, 3]]) weights = constant_op.constant(1.2) with self.assertRaisesRegexp(ValueError, 'dimension'): losses.sparse_softmax_cross_entropy( labels, logits, weights=weights).eval() class SigmoidCrossEntropyLossTest(test.TestCase): def testAllCorrectSigmoid(self): with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], [-100.0, 100.0, -100.0], [-100.0, -100.0, 100.0]]) labels = constant_op.constant([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) loss = losses.sigmoid_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sigmoid_cross_entropy_loss/value') self.assertAlmostEqual(0.0, loss.eval(), 3) def testLossWithSingleDimPlaceholderForLogitsAndWeights1(self): logits = array_ops.placeholder(dtypes.float32, shape=(None, 1)) labels = array_ops.placeholder(dtypes.float32, shape=(None, 1)) weights = array_ops.ones_like(logits, dtype=dtypes.float32) loss = losses.sigmoid_cross_entropy(labels, logits, weights) with self.test_session() as sess: loss = sess.run(loss, feed_dict={ logits: np.ones((32, 1)), labels: np.ones((32, 1)), }) self.assertAlmostEqual(0.313, loss, 3) def testLossWithSingleDimPlaceholderForLogitsAndWeights2(self): logits = array_ops.placeholder(dtypes.float32, shape=(None, 2)) labels = array_ops.placeholder(dtypes.float32, shape=(None, 2)) weights = array_ops.ones_like(logits, dtype=dtypes.float32) loss = losses.sigmoid_cross_entropy(labels, logits, weights) with self.test_session() as sess: loss = sess.run(loss, feed_dict={ logits: np.ones((32, 2)), labels: np.ones((32, 2)), }) self.assertAlmostEqual(0.313, loss, 3) def testAllWrongSigmoid(self): with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], [-100.0, 100.0, -100.0], [-100.0, -100.0, 100.0]]) labels = constant_op.constant([[0, 0, 1], [1, 0, 0], [0, 1, 0]]) loss = losses.sigmoid_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sigmoid_cross_entropy_loss/value') self.assertAlmostEqual(loss.eval(), 600.0 / 9.0, 3) def testAllWrongSigmoidWithMeasurementSpecificWeights(self): with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0], [-100.0, 100.0, -100.0], [-100.0, -100.0, 100.0]]) labels = constant_op.constant([[0, 0, 1], [1, 0, 0], [0, 1, 0]]) weights = constant_op.constant([[3, 4, 5], [2, 6, 0], [8, 0, 1]]) loss = losses.sigmoid_cross_entropy(labels, logits, weights) self.assertEquals(loss.op.name, 'sigmoid_cross_entropy_loss/value') self.assertAlmostEqual(1700.0 / 7.0, loss.eval(), 3) def testMultiCorrectSigmoid(self): logits = constant_op.constant([[100.0, -100.0, 100.0], [100.0, 100.0, -100.0], [-100.0, 100.0, 100.0]]) labels = constant_op.constant([[1, 0, 1], [1, 1, 0], [0, 1, 1]]) loss = losses.sigmoid_cross_entropy(labels, logits) self.assertEquals(loss.op.name, 'sigmoid_cross_entropy_loss/value') with self.test_session(): self.assertAlmostEqual(loss.eval(), 0.0, 3) def testSigmoidLabelSmoothingCorrect(self): with self.test_session(): logits = constant_op.constant([[100.0, -100.0, -100.0]]) labels = constant_op.constant([[1, 0, 1]]) # Sigmoid cross entropy loss is: # max(x,0) - x*z + log(1 + exp(-abs(x))) # The new labels are: # z' = z * (1 - L) + 0.5 L # 1 -> 1 - 0.5 L # 0 -> 0.5 L # here we expect: # 1/3 * (100 - 100 * (1 - 0.5 L) + 0 # + 0 + 100 * (0.5 L) + 0 # + 0 + 100 * (1 - 0.5 L) + 0) # = 1/3 * (100 + 50 L) label_smoothing = 0.1 loss = losses.sigmoid_cross_entropy( labels, logits, label_smoothing=label_smoothing) self.assertEquals(loss.op.name, 'sigmoid_cross_entropy_loss/value') expected_value = (100.0 + 50.0 * label_smoothing) / 3.0 self.assertAlmostEqual(loss.eval(), expected_value, 3) def testSigmoidLabelSmoothingEqualsSoftmaxTwoLabel(self): with self.test_session(): label_smoothing = 0.1 sigmoid_logits = constant_op.constant([[100.0, -100.0, -100.0]]) sigmoid_labels = constant_op.constant([[1, 0, 1]]) sigmoid_loss = losses.sigmoid_cross_entropy( sigmoid_labels, sigmoid_logits, label_smoothing=label_smoothing) softmax_logits = constant_op.constant( [[0.0, 100.0], [100.0, 0.0], [100.0, 0.0]]) softmax_labels = constant_op.constant([[0, 1], [1, 0], [0, 1]]) softmax_loss = losses.softmax_cross_entropy( softmax_labels, softmax_logits, label_smoothing=label_smoothing) self.assertAlmostEqual(sigmoid_loss.eval(), softmax_loss.eval(), 3) class LogLossTest(test.TestCase): def setUp(self): predictions = np.asarray([.9, .2, .2, .8, .4, .6]).reshape((2, 3)) labels = np.asarray([1.0, 0.0, 1.0, 1.0, 0.0, 0.0]).reshape((2, 3)) self._np_predictions = predictions self._np_labels = labels epsilon = 1e-7 self._expected_losses = np.multiply( labels, np.log(predictions + epsilon)) + np.multiply( 1 - labels, np.log(1 - predictions + epsilon)) self._predictions = constant_op.constant(predictions) self._labels = constant_op.constant(labels) def testValueErrorThrownWhenWeightIsNone(self): with self.test_session(): with self.assertRaises(ValueError): losses.log_loss(self._labels, self._labels, weights=None) def testAllCorrectNoLossWeight(self): loss = losses.log_loss(self._labels, self._labels) with self.test_session(): self.assertAlmostEqual(0.0, loss.eval(), 3) def testAllCorrectNoLossWeightWithPlaceholder(self): tf_predictions = array_ops.placeholder( dtypes.float32, shape=self._np_labels.shape) loss = losses.log_loss(self._labels, tf_predictions) with self.test_session(): self.assertAlmostEqual( 0.0, loss.eval(feed_dict={tf_predictions: self._np_labels}), 3) def testNonZeroLoss(self): loss = losses.log_loss(self._labels, self._predictions) with self.test_session(): self.assertAlmostEqual(-np.sum(self._expected_losses) / 6.0, loss.eval(), 3) def testNonZeroLossWithPythonScalarWeight(self): weights = 2.3 loss = losses.log_loss(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(weights * -np.sum(self._expected_losses) / 6.0, loss.eval(), 3) def testNonZeroLossWithScalarTensorWeight(self): weights = 2.3 loss = losses.log_loss(self._labels, self._predictions, constant_op.constant(weights)) with self.test_session(): self.assertAlmostEqual(weights * -np.sum(self._expected_losses) / 6.0, loss.eval(), 3) def testNonZeroLossWithScalarTensorWeightAndPlaceholder(self): tf_predictions = array_ops.placeholder( dtypes.float32, shape=self._np_predictions.shape) weights = 2.3 loss = losses.log_loss(self._labels, tf_predictions, constant_op.constant(weights)) with self.test_session() as sess: loss = sess.run(loss, feed_dict={tf_predictions: self._np_predictions}) self.assertAlmostEqual(weights * -np.sum(self._expected_losses) / 6.0, loss, 3) def testNonZeroLossWithScalarTensorWeightAndPlaceholderWithRankOnly(self): tf_predictions = array_ops.placeholder(dtypes.float32, shape=[None, None]) weights = 2.3 loss = losses.log_loss(self._labels, tf_predictions, constant_op.constant(weights)) with self.test_session() as sess: loss = sess.run(loss, feed_dict={tf_predictions: self._np_predictions}) self.assertAlmostEqual(weights * -np.sum(self._expected_losses) / 6.0, loss, 3) def testNonZeroLossWithOneDimBatchSpecificWeights(self): weights = constant_op.constant((1.2, 3.4), shape=(2, 1)) expected_losses = np.multiply( self._expected_losses, np.asarray([1.2, 1.2, 1.2, 3.4, 3.4, 3.4]).reshape((2, 3))) loss = losses.log_loss(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(-np.sum(expected_losses) / 6.0, loss.eval(), 3) def testNonZeroLossWithOneDimBatchSpecificWeightsSomeZero(self): weights = constant_op.constant((1.2, 0), shape=(2, 1)) expected_losses = np.multiply(self._expected_losses, np.asarray([1.2, 1.2, 1.2, 0, 0, 0]).reshape( (2, 3))) loss = losses.log_loss(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(-np.sum(expected_losses) / 3.0, loss.eval(), 3) def testNonZeroLossWithTwoDimBatchSpecificWeightsSomeZero(self): weights = constant_op.constant([1.2, 0], shape=[2, 1]) expected_losses = np.multiply(self._expected_losses, np.asarray([1.2, 1.2, 1.2, 0, 0, 0]).reshape( (2, 3))) loss = losses.log_loss(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(-np.sum(expected_losses) / 3.0, loss.eval(), 3) def testWeightsWithSameNumDimsButWrongShapeThrowsException(self): weights = constant_op.constant(np.random.normal(size=(2, 4)), shape=[2, 4]) with self.test_session(): with self.assertRaises(ValueError): losses.log_loss(self._labels, self._predictions, weights) def testNonZeroLossWithMeasurementSpecificWeights(self): weights = np.array([3, 6, 5, 0, 4, 2]).reshape((2, 3)) expected_losses = np.multiply(self._expected_losses, weights) loss = losses.log_loss( self._labels, self._predictions, constant_op.constant( weights, shape=(2, 3))) with self.test_session(): self.assertAlmostEqual(-np.sum(expected_losses) / 5.0, loss.eval(), 3) def testNonZeroLossWithMeasurementSpecificWeightsWithPlaceholder(self): weights = np.array([3, 6, 5, 0, 4, 2]).reshape((2, 3)) expected_losses = np.multiply(self._expected_losses, weights) tf_predictions = array_ops.placeholder(dtypes.float32, shape=[2, 3]) loss = losses.log_loss( self._labels, tf_predictions, constant_op.constant( weights, shape=(2, 3))) with self.test_session() as sess: loss = sess.run(loss, feed_dict={tf_predictions: self._np_predictions}) self.assertAlmostEqual(-np.sum(expected_losses) / 5.0, loss, 3) def testNonZeroLossWithSampleSpecificWeightsMostZero(self): weights = np.array([0, 0, 0, 0, 0, 2]).reshape((2, 3)) expected_losses = np.multiply(self._expected_losses, weights) loss = losses.log_loss( self._labels, self._predictions, constant_op.constant( weights, shape=(2, 3))) with self.test_session(): self.assertAlmostEqual(-np.sum(expected_losses), loss.eval(), 3) def testNonZeroLossWithSampleSpecificWeightsMostZeroWithPlaceholder(self): weights = np.array([0, 0, 0, 0, 0, 2]).reshape((2, 3)) expected_losses = np.multiply(self._expected_losses, weights) tf_predictions = array_ops.placeholder(dtypes.float32, shape=[2, 3]) tf_weights = constant_op.constant(weights, shape=(2, 3)) loss = losses.log_loss(self._labels, tf_predictions, tf_weights) with self.test_session() as sess: loss = sess.run(loss, feed_dict={tf_predictions: self._np_predictions}) self.assertAlmostEqual(-np.sum(expected_losses), loss, 3) def testLossWithSampleSpecificWeightsAllZero(self): tf_weights = array_ops.zeros(shape=(2, 3)) loss = losses.log_loss(self._labels, self._predictions, tf_weights) with self.test_session(): self.assertAlmostEqual(0.0, loss.eval(), 3) class HingeLossTest(test.TestCase): def testIncompatibleShapes(self): with self.test_session(): logits = constant_op.constant([[-1.0], [2.1]]) labels = constant_op.constant([0.0, 1.0]) with self.assertRaises(ValueError): _ = losses.hinge_loss(labels, logits).eval() def testAllOutsideMargin(self): with self.test_session(): logits = constant_op.constant([1.2, -1.4, -1.0, 2.1]) labels = constant_op.constant([1.0, 0.0, 0.0, 1.0]) loss = losses.hinge_loss(labels, logits) self.assertAllClose(loss.eval(), 0.0, atol=1e-3) def testSomeInsideMargin(self): with self.test_session(): logits = constant_op.constant([[-0.7], [-1.4], [1.4], [0.6]]) labels = constant_op.constant([[0.0], [0.0], [1.0], [1.0]]) loss = losses.hinge_loss(labels, logits) # Examples 1 and 4 are on the correct side of the hyperplane but within # the margin so they incur some (small) loss. self.assertAllClose(loss.eval(), 0.175, atol=1e-3) def testSomeMisclassified(self): with self.test_session(): logits = constant_op.constant([[[1.2], [0.4], [-1.0], [-1.1]]]) labels = constant_op.constant([[[1.0], [0.0], [0.0], [1.0]]]) loss = losses.hinge_loss(labels, logits) # Examples 2 and 4 are on the wrong side of the hyperplane so they incur # some (fairly large) loss. self.assertAllClose(loss.eval(), 0.875, atol=1e-3) class MeanSquaredErrorTest(test.TestCase): def setUp(self): self._predictions = constant_op.constant([4, 8, 12, 8, 1, 3], shape=(2, 3)) self._labels = constant_op.constant([1, 9, 2, -5, -2, 6], shape=(2, 3)) def testValueErrorThrownWhenWeightIsNone(self): with self.test_session(): with self.assertRaises(ValueError): losses.mean_squared_error( self._predictions, self._predictions, weights=None) def testScalar(self): with self.test_session(): self.assertEqual( 0.0, losses.mean_squared_error(predictions=constant_op.constant(0), labels=constant_op.constant(0)).eval()) def testAllCorrectNoLossWeight(self): loss = losses.mean_squared_error(self._predictions, self._predictions) with self.test_session(): self.assertAlmostEqual(0.0, loss.eval(), 3) def testNonZeroLoss(self): loss = losses.mean_squared_error(self._labels, self._predictions) with self.test_session(): self.assertAlmostEqual(49.5, loss.eval(), 3) def testNonZeroLossWithPythonScalarWeight(self): weights = 2.3 loss = losses.mean_squared_error(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(49.5 * weights, loss.eval(), 3) def testNonZeroLossWithScalarTensorWeight(self): weights = 2.3 loss = losses.mean_squared_error(self._labels, self._predictions, constant_op.constant(weights)) with self.test_session(): self.assertAlmostEqual(49.5 * weights, loss.eval(), 3) def testNonZeroLossWithOneDimBatchSpecificWeights(self): weights = constant_op.constant([1.2, 3.4], shape=(2, 1)) loss = losses.mean_squared_error(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(767.8 / 6.0, loss.eval(), 3) def testNonZeroLossWithTwoDimBatchSpecificWeights(self): weights = constant_op.constant([1.2, 3.4], shape=[2, 1]) loss = losses.mean_squared_error(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(767.8 / 6.0, loss.eval(), 3) def testNonZeroLossWithSampleSpecificWeights(self): weights = constant_op.constant([3, 6, 5, 0, 4, 2], shape=[2, 3]) loss = losses.mean_squared_error(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(587 / 5.0, loss.eval(), 3) def testNonZeroLossWithSampleSpecificWeightsMostZero(self): weights = constant_op.constant([0, 0, 0, 0, 0, 2], shape=[2, 3]) loss = losses.mean_squared_error(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(18.0, loss.eval(), 3) def testLossWithSampleSpecificWeightsAllZero(self): weights = array_ops.zeros((2, 3)) loss = losses.mean_squared_error(self._labels, self._predictions, weights) with self.test_session(): self.assertAlmostEqual(0.0, loss.eval(), 3) class MeanPairwiseSquaredErrorTest(test.TestCase): def setUp(self): self._predictions = np.array([[4, 8, 12], [8, 1, 3]]) self._labels = np.array([[1, 9, 2], [-5, -5, 7]]) batch_size, dims = self._labels.shape # Compute the expected loss 'manually'. total = np.zeros((batch_size,)) for b in range(batch_size): for i in range(dims): for j in range(dims): x = self._predictions[b, i].item() - self._predictions[b, j].item() y = self._labels[b, i].item() - self._labels[b, j].item() diff = (x - y) total[b] += (diff * diff) self._expected_losses = np.divide(total, 9.0) def testValueErrorThrownWhenWeightIsNone(self): with self.test_session(): with self.assertRaises(ValueError): losses.mean_pairwise_squared_error( predictions=constant_op.constant(self._labels), labels=constant_op.constant(self._labels), weights=None) def _test_valid_weights( self, labels, predictions, expected_loss, weights=1.0): with self.test_session(): static_inputs_op = losses.mean_pairwise_squared_error( predictions=predictions, labels=labels, weights=weights) self.assertAlmostEqual(expected_loss, static_inputs_op.eval(), places=3) predictions_placeholder = array_ops.placeholder( dtypes.float32, shape=np.asarray(predictions.shape)) labels_placeholder = array_ops.placeholder( dtypes.int32, shape=np.asarray(labels.shape)) weights_placeholder = array_ops.placeholder( dtypes.float32, shape=np.asarray(weights).shape) dynamic_inputs_op = losses.mean_pairwise_squared_error( predictions=predictions_placeholder, labels=labels_placeholder, weights=weights_placeholder) feed_dict = { predictions_placeholder: predictions, labels_placeholder: labels, weights_placeholder: weights, } self.assertAlmostEqual( expected_loss, dynamic_inputs_op.eval(feed_dict=feed_dict), places=3) def testAllCorrectNoLossWeight(self): self._test_valid_weights( self._labels, self._labels, expected_loss=0.0) def testNonZeroLoss(self): self._test_valid_weights( self._labels, self._predictions, expected_loss=np.sum(self._expected_losses)) def testGradientWithZeroWeight(self): with ops.Graph().as_default(): random_seed.set_random_seed(0) inputs = array_ops.ones((2, 3)) weights = variable_scope.get_variable( 'weights', shape=[3, 4], initializer=init_ops.truncated_normal_initializer()) predictions = math_ops.matmul(inputs, weights) optimizer = momentum_lib.MomentumOptimizer( learning_rate=0.001, momentum=0.9) loss = losses.mean_pairwise_squared_error(predictions, predictions, 0) gradients_to_variables = optimizer.compute_gradients(loss) init_op = variables.global_variables_initializer() with self.test_session() as sess: sess.run(init_op) for grad, _ in gradients_to_variables: np_grad = sess.run(grad) self.assertFalse(np.isnan(np_grad).any()) def testNonZeroLossWithPythonScalarWeight(self): weight = 2.3 self._test_valid_weights( self._labels, self._predictions, expected_loss=weight * np.sum(self._expected_losses), weights=weight) def testNonZeroLossWithScalarTensorWeight(self): weights = 2.3 loss = losses.mean_pairwise_squared_error( predictions=constant_op.constant(self._predictions), labels=constant_op.constant(self._labels), weights=constant_op.constant(weights)) with self.test_session(): self.assertAlmostEqual(weights * np.sum(self._expected_losses), loss.eval(), 3) def testNonZeroLossWithScalarZeroWeight(self): self._test_valid_weights( self._labels, self._predictions, expected_loss=0.0, weights=0.0) def test3d(self): labels = np.array([ [[1, 9, 2], [12, 11, 10], [9, 8, 7]], [[-5, -5, 7], [6, 5, 4], [3, 2, 1]], ]) predictions = np.array([ [[4, 8, 12], [1, 2, 3], [4, 5, 6]], [[8, 1, 3], [7, 8, 9], [10, 11, 12]], ]) self._test_valid_weights( labels, predictions, expected_loss=122.22222) def test3dWeightedScalar(self): labels = np.array([ [[1, 9, 2], [12, 11, 10], [9, 8, 7]], [[-5, -5, 7], [6, 5, 4], [3, 2, 1]], ]) predictions = np.array([ [[4, 8, 12], [1, 2, 3], [4, 5, 6]], [[8, 1, 3], [7, 8, 9], [10, 11, 12]], ]) weight = 3.0 self._test_valid_weights( labels, predictions, expected_loss=weight * 122.22222, weights=weight) def _test_invalid_weights( self, labels, predictions, weights=1.0): expected_error_msg = 'weights can not be broadcast to values' # Static check. with self.assertRaisesRegexp(ValueError, expected_error_msg): losses.mean_pairwise_squared_error( predictions=predictions, labels=labels, weights=weights) # Dynamic check. predictions_placeholder = array_ops.placeholder(dtypes.float32) labels_placeholder = array_ops.placeholder(dtypes.int32) weights_placeholder = array_ops.placeholder(dtypes.float32) dynamic_inputs_op = losses.mean_pairwise_squared_error( predictions=predictions_placeholder, labels=labels_placeholder, weights=weights_placeholder) with self.test_session(): with self.assertRaisesRegexp(errors_impl.OpError, expected_error_msg): dynamic_inputs_op.eval(feed_dict={ predictions_placeholder: predictions, labels_placeholder: labels, weights_placeholder: weights, }) def testInvalid3dWeighted2x0(self): labels = np.array([ [[1, 9, 2], [12, 11, 10], [9, 8, 7]], [[-5, -5, 7], [6, 5, 4], [3, 2, 1]], ]) predictions = np.array([ [[4, 8, 12], [1, 2, 3], [4, 5, 6]], [[8, 1, 3], [7, 8, 9], [10, 11, 12]], ]) self._test_invalid_weights( labels, predictions, weights=np.asarray((1.2, 3.4))) def test3dWeighted2x3x3(self): labels = np.array([ [[1, 9, 2], [12, 11, 10], [9, 8, 7]], [[-5, -5, 7], [6, 5, 4], [3, 2, 1]], ]) predictions = np.array([ [[4, 8, 12], [1, 2, 3], [4, 5, 6]], [[8, 1, 3], [7, 8, 9], [10, 11, 12]], ]) self._test_valid_weights( # TODO(ptucker): This doesn't look right. labels, predictions, expected_loss=9 * 122.22222, weights=np.ones((2, 3, 3))) def testLossWithAllZeroBatchSpecificWeights(self): self._test_valid_weights( self._labels, self._predictions, expected_loss=0.0, weights=np.zeros((2, 1))) class CosineDistanceLossTest(test.TestCase): def setUp(self): self._predictions = np.asarray([ [1, 0, 0], # Batch 1 [0, 0, -1], [1, 0, 0], # Batch 2 [1, 0, 0], [0, 0, -1], # Batch 3 [1, 0, 0] ]).reshape((3, 2, 3)) self._labels = np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 0, 1], [0, 1, 0]]).reshape((3, 2, 3)) def testValueErrorThrownWhenWeightIsNone(self): with self.test_session(): with self.assertRaises(ValueError): losses.cosine_distance( predictions=constant_op.constant(self._labels), labels=constant_op.constant(self._labels), dim=2, weights=None) def testAllCorrectNoWeights(self): loss = losses.cosine_distance( predictions=constant_op.constant(self._labels), labels=constant_op.constant(self._labels), dim=2) with self.test_session(): self.assertAlmostEqual(0, loss.eval(), 5) def testPartiallyCorrectWithIntegerValues(self): loss = losses.cosine_distance( predictions=constant_op.constant(self._predictions), labels=constant_op.constant(self._labels), dim=2) with self.test_session(): self.assertAlmostEqual(1, loss.eval(), 5) def testPartiallyCorrectFloatingPointValues(self): predictions = np.matrix( ('0.819031913261206 0.567041924552012 0.087465312324590;' '-0.665139432070255 -0.739487441769973 -0.103671883216994;' '0.707106781186548 -0.707106781186548 0')) labels = np.matrix(('0.819031913261206 0.567041924552012 0.087465312324590;' '0.665139432070255 0.739487441769973 0.103671883216994;' '0.707106781186548 0.707106781186548 0')) tf_preds = constant_op.constant( predictions, shape=(3, 1, 3), dtype=dtypes.float32) tf_labels = constant_op.constant( labels, shape=(3, 1, 3), dtype=dtypes.float32) loss = losses.cosine_distance(tf_labels, tf_preds, dim=2) with self.test_session(): self.assertAlmostEqual(1.0, loss.eval(), 5) def testSampleSpecificWeights(self): loss = losses.cosine_distance( predictions=constant_op.constant(self._predictions), labels=constant_op.constant(self._labels), dim=2, weights=np.asarray((1, 0, 0)).reshape((3, 1, 1))) with self.test_session(): self.assertEqual(1.0, loss.eval()) def testMeasurementSpecificWeights(self): loss = losses.cosine_distance( predictions=constant_op.constant(self._predictions), labels=constant_op.constant(self._labels), dim=2, weights=constant_op.constant( [1, 0, 0, 1, 1, 1], shape=(3, 2, 1))) with self.test_session(): self.assertEqual(3.0 / 4.0, loss.eval()) def testMeasurementSpecificWeightsWithPlaceholderWithShape(self): tf_predictions = array_ops.placeholder( dtypes.float32, shape=self._labels.shape) loss = losses.cosine_distance( predictions=tf_predictions, labels=constant_op.constant(self._labels), dim=2, weights=constant_op.constant( [1, 0, 0, 1, 1, 1], shape=(3, 2, 1))) with self.test_session() as sess: loss = sess.run(loss, feed_dict={tf_predictions: self._predictions}) self.assertEqual(3.0 / 4.0, loss) def testZeroLossWhenAllSampleSpecificWeightsAreZero(self): loss = losses.cosine_distance( predictions=constant_op.constant(self._predictions), labels=constant_op.constant(self._labels), dim=2, weights=array_ops.zeros((3, 1, 1))) with self.test_session(): self.assertEqual(0, loss.eval()) def testZeroLossWhenAllMeasurementSpecificWeightsAreZero(self): loss = losses.cosine_distance( predictions=constant_op.constant(self._predictions), labels=constant_op.constant(self._labels), dim=2, weights=array_ops.zeros((3, 2, 1))) with self.test_session(): self.assertEqual(0, loss.eval()) class AddLossTest(test.TestCase): def testNoCollectLossesBatch2(self): logits = constant_op.constant([[1.2, 0.4, -1.0, -1.1]] * 2) labels = constant_op.constant([[1.0, 0.0, 0.0, 1.0]] * 2) self.assertFalse(util.get_losses()) losses.absolute_difference(logits, labels, loss_collection=None) losses.log_loss(logits, labels, loss_collection=None) losses.mean_squared_error(logits, labels, loss_collection=None) losses.sigmoid_cross_entropy(logits, labels, loss_collection=None) losses.softmax_cross_entropy(logits, labels, loss_collection=None) self.assertFalse(util.get_losses()) class ComputeWeightedLossTest(test.TestCase): def setUp(self): self._shape = (3, 2, 4) raw_losses = np.zeros(self._shape) next_loss = 0.0 for i in range(self._shape[0]): for j in range(self._shape[1]): for k in range(self._shape[2]): raw_losses[i][j][k] = next_loss next_loss += 1.0 raw_losses.setflags(write=False) self._raw_losses = raw_losses self._unweighted_loss = np.mean(self._raw_losses) def testUnweighted(self): with ops.Graph().as_default(): self.assertEqual(0, len(util.get_losses())) raw_losses = self._raw_losses unweighted_losses = ( losses.compute_weighted_loss(raw_losses), losses.compute_weighted_loss(raw_losses, weights=np.ones((1, 1, 1))), losses.compute_weighted_loss(raw_losses, weights=np.ones((1, 1, 4))), losses.compute_weighted_loss(raw_losses, weights=np.ones((1, 2, 1))), losses.compute_weighted_loss(raw_losses, weights=np.ones((1, 2, 4))), losses.compute_weighted_loss(raw_losses, weights=np.ones((3, 1, 1))), losses.compute_weighted_loss(raw_losses, weights=np.ones((3, 1, 4))), losses.compute_weighted_loss(raw_losses, weights=np.ones((3, 2, 1))), losses.compute_weighted_loss(raw_losses, weights=np.ones(self._shape)) ) self.assertEqual(9, len(util.get_losses())) with self.test_session(): for unweighted_loss in unweighted_losses: self.assertAllClose(self._unweighted_loss, unweighted_loss.eval()) def testScalarWeight(self): with ops.Graph().as_default(): self.assertEqual(0, len(util.get_losses())) weight = 17.0 weighted_loss = losses.compute_weighted_loss( self._raw_losses, weights=weight) self.assertEqual(1, len(util.get_losses())) with self.test_session(): self.assertAllClose( np.mean(weight * self._raw_losses), weighted_loss.eval()) def _test_invalid_weights(self, weights): with ops.Graph().as_default(): self.assertEqual(0, len(util.get_losses())) expected_error_msg = 'weights can not be broadcast to values' # Static check. with self.assertRaisesRegexp(ValueError, expected_error_msg): losses.compute_weighted_loss(self._raw_losses, weights=weights) # Dynamic check. weights_placeholder = array_ops.placeholder(dtypes.float32) weighted_loss = losses.compute_weighted_loss( self._raw_losses, weights=weights_placeholder) self.assertEqual(1, len(util.get_losses())) with self.test_session(): with self.assertRaisesRegexp(errors_impl.OpError, expected_error_msg): weighted_loss.eval(feed_dict={weights_placeholder: weights}) def testInvalidWeightTooManyDims(self): self._test_invalid_weights(np.zeros(shape=(2, 2, 2, 2))) def testInvalidWeightMismatchedDim(self): with ops.Graph().as_default(): raw_losses = array_ops.reshape(self._raw_losses, shape=(3, 2, 4, 1)) weights = np.ones(shape=(3, 2, 4, 2)) expected_error_msg = 'weights can not be broadcast to values' self.assertEqual(0, len(util.get_losses())) # Static check. with self.assertRaisesRegexp(ValueError, expected_error_msg): losses.compute_weighted_loss(raw_losses, weights=weights) # Dynamic check. weights_placeholder = array_ops.placeholder(dtypes.float32) weighted_loss = losses.compute_weighted_loss( raw_losses, weights=weights_placeholder) self.assertEqual(1, len(util.get_losses())) with self.test_session(): with self.assertRaisesRegexp(errors_impl.OpError, expected_error_msg): weighted_loss.eval(feed_dict={weights_placeholder: weights}) def testInvalid3Weight(self): self._test_invalid_weights((17.0, 5.0, 2.0)) def testInvalid3x1Weight(self): self._test_invalid_weights(((17.0,), (5.0,), (2.0,),)) def testInvalid3x2Weight(self): self._test_invalid_weights(( (17.0, 3.0), (5.0, 31.0), (2.0, 7.0),)) def testInvalid1x2Weight(self): self._test_invalid_weights((17.0, 3.0,),) def testInvalidScalar1DWeight(self): self._test_invalid_weights((17.0,),) def _test_valid_weights(self, weights): with ops.Graph().as_default(): self.assertEqual(0, len(util.get_losses())) weighted_loss = losses.compute_weighted_loss( self._raw_losses, weights=weights) self.assertEqual(1, len(util.get_losses())) with self.test_session(): self.assertAllClose( np.mean(weights * self._raw_losses), weighted_loss.eval()) def test1x1x1Weight(self): self._test_valid_weights((((17.0,),),)) def test1x2x1Weight(self): self._test_valid_weights((((17.0,), (3.0,),),)) def test1x1x4Weight(self): self._test_valid_weights((((17.0, 13.0, 2.0, 5.0),),)) def test3x1x1Weight(self): self._test_valid_weights((((17.0,),), ((5.0,),), ((2.0,),),)) def test3x2x1Weight(self): self._test_valid_weights(( ((17.0,), (3.0,)), ((5.0,), (31.0,)), ((2.0,), (7.0,)), )) def test3x1x4Weight(self): self._test_valid_weights(( ((17.0, 13.0, 2.0, 5.0),), ((5.0, 31.0, 17.0, 5.0),), ((7.0, 3.0, 11.0, 5.0),), )) def test1x2x4Weight(self): self._test_valid_weights((( (17.0, 13.0, 2.0, 5.0), (3.0, 13.0, 11.0, 2.0), ),)) def test3x2x4Weight(self): self._test_valid_weights(( ((17.0, 13.0, 2.0, 5.0), (3.0, 13.0, 11.0, 2.0),), ((5.0, 31.0, 17.0, 5.0), (13.0, 3.0, 1.0, 11.0),), ((7.0, 3.0, 11.0, 5.0), (13.0, 11.0, 1.0, 7.0),), )) 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, 21289, 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, 2680, 465, 980, 199, 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, 2552, 63, 5472, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 4205, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 21289, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 4884, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 7588, 492, 23887, 465, 23887, 63, 773, 421, 199, 533, 24964, 32279, 8610, 774, 8, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 9869, 275, 4413, 63, 411, 14, 4083, 779, 20, 12, 1695, 12, 3144, 12, 1695, 12, 413, 12, 650, 467, 2215, 2687, 18, 12, 650, 430, 272, 291, 423, 3512, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 1749, 12, 499, 12, 446, 21, 12, 446, 18, 12, 1227, 467, 2215, 2687, 18, 12, 650, 430, 819, 347, 511, 3393, 2719, 18406, 11423, 16359, 1831, 403, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 543, 291, 14, 1855, 8, 3393, 304, 267, 21289, 14, 6116, 63, 9196, 8, 288, 291, 423, 9869, 12, 291, 423, 9869, 12, 4931, 29, 403, 9, 819, 347, 511, 2422, 19993, 1944, 8610, 16359, 8, 277, 304, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 9869, 12, 291, 423, 9869, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 16, 14, 16, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 8, 277, 304, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 21, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 4718, 13090, 16359, 8, 277, 304, 272, 4931, 275, 499, 14, 19, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 21, 627, 4931, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 13090, 3861, 16359, 8, 277, 304, 272, 4931, 275, 499, 14, 19, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4228, 4413, 63, 411, 14, 4083, 8, 4916, 430, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 21, 627, 4931, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 4395, 19156, 8842, 16786, 23885, 8, 277, 304, 272, 4931, 275, 4413, 63, 411, 14, 4083, 1332, 17, 14, 18, 12, 378, 14, 16, 395, 2215, 2687, 18, 12, 413, 430, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 22, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 11467, 19156, 8842, 16786, 23885, 8, 277, 304, 272, 4931, 275, 4413, 63, 411, 14, 4083, 779, 17, 14, 18, 12, 378, 14, 16, 467, 2215, 1524, 18, 12, 413, 566, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 22, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 8176, 16786, 23885, 8, 277, 304, 272, 4931, 275, 4413, 63, 411, 14, 4083, 779, 19, 12, 1227, 12, 959, 12, 378, 12, 841, 12, 499, 467, 2215, 1524, 18, 12, 650, 566, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 975, 14, 22, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 8176, 16786, 23885, 24625, 8681, 8, 277, 304, 272, 4931, 275, 4413, 63, 411, 14, 4083, 779, 16, 12, 378, 12, 378, 12, 378, 12, 378, 12, 499, 467, 2215, 1524, 18, 12, 650, 566, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 22, 14, 16, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 8610, 3007, 8176 ]
[ 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, 21289, 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, 2680, 465, 980, 199, 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, 2552, 63, 5472, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2196, 63, 5176, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 4205, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 21289, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 4884, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 7588, 492, 23887, 465, 23887, 63, 773, 421, 199, 533, 24964, 32279, 8610, 774, 8, 396, 14, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 291, 423, 9869, 275, 4413, 63, 411, 14, 4083, 779, 20, 12, 1695, 12, 3144, 12, 1695, 12, 413, 12, 650, 467, 2215, 2687, 18, 12, 650, 430, 272, 291, 423, 3512, 275, 4413, 63, 411, 14, 4083, 779, 17, 12, 1749, 12, 499, 12, 446, 21, 12, 446, 18, 12, 1227, 467, 2215, 2687, 18, 12, 650, 430, 819, 347, 511, 3393, 2719, 18406, 11423, 16359, 1831, 403, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 543, 291, 14, 1855, 8, 3393, 304, 267, 21289, 14, 6116, 63, 9196, 8, 288, 291, 423, 9869, 12, 291, 423, 9869, 12, 4931, 29, 403, 9, 819, 347, 511, 2422, 19993, 1944, 8610, 16359, 8, 277, 304, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 9869, 12, 291, 423, 9869, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 16, 14, 16, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 8, 277, 304, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 21, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 4718, 13090, 16359, 8, 277, 304, 272, 4931, 275, 499, 14, 19, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 21, 627, 4931, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 13090, 3861, 16359, 8, 277, 304, 272, 4931, 275, 499, 14, 19, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4228, 4413, 63, 411, 14, 4083, 8, 4916, 430, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 21, 627, 4931, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 4395, 19156, 8842, 16786, 23885, 8, 277, 304, 272, 4931, 275, 4413, 63, 411, 14, 4083, 1332, 17, 14, 18, 12, 378, 14, 16, 395, 2215, 2687, 18, 12, 413, 430, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 22, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 11467, 19156, 8842, 16786, 23885, 8, 277, 304, 272, 4931, 275, 4413, 63, 411, 14, 4083, 779, 17, 14, 18, 12, 378, 14, 16, 467, 2215, 1524, 18, 12, 413, 566, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 21, 14, 22, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 8176, 16786, 23885, 8, 277, 304, 272, 4931, 275, 4413, 63, 411, 14, 4083, 779, 19, 12, 1227, 12, 959, 12, 378, 12, 841, 12, 499, 467, 2215, 1524, 18, 12, 650, 566, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 975, 14, 22, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 6932, 8681, 8610, 3007, 8176, 16786, 23885, 24625, 8681, 8, 277, 304, 272, 4931, 275, 4413, 63, 411, 14, 4083, 779, 16, 12, 378, 12, 378, 12, 378, 12, 378, 12, 499, 467, 2215, 1524, 18, 12, 650, 566, 272, 5621, 275, 21289, 14, 6116, 63, 9196, 8, 277, 423, 3512, 12, 291, 423, 9869, 12, 4931, 9, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 291, 14, 7904, 8, 22, 14, 16, 12, 5621, 14, 2579, 1062, 650, 9, 819, 347, 511, 8610, 3007, 8176, 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, 1 ]
18padx08/PPTex
PPTexEnv_x86_64/lib/python2.7/site-packages/numpy/compat/py3k.py
35
2009
""" Python 3 compatibility tools. """ from __future__ import division, absolute_import, print_function __all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar', 'unicode', 'asunicode', 'asbytes_nested', 'asunicode_nested', 'asstr', 'open_latin1', 'long', 'basestring', 'sixu', 'integer_types'] import sys if sys.version_info[0] >= 3: import io long = int integer_types = (int,) basestring = str unicode = str bytes = bytes def asunicode(s): if isinstance(s, bytes): return s.decode('latin1') return str(s) def asbytes(s): if isinstance(s, bytes): return s return str(s).encode('latin1') def asstr(s): if isinstance(s, bytes): return s.decode('latin1') return str(s) def isfileobj(f): return isinstance(f, (io.FileIO, io.BufferedReader, io.BufferedWriter)) def open_latin1(filename, mode='r'): return open(filename, mode=mode, encoding='iso-8859-1') def sixu(s): return s strchar = 'U' else: bytes = str long = long basestring = basestring unicode = unicode integer_types = (int, long) asbytes = str asstr = str strchar = 'S' def isfileobj(f): return isinstance(f, file) def asunicode(s): if isinstance(s, unicode): return s return str(s).decode('ascii') def open_latin1(filename, mode='r'): return open(filename, mode=mode) def sixu(s): return unicode(s, 'unicode_escape') def getexception(): return sys.exc_info()[1] def asbytes_nested(x): if hasattr(x, '__iter__') and not isinstance(x, (bytes, unicode)): return [asbytes_nested(y) for y in x] else: return asbytes(x) def asunicode_nested(x): if hasattr(x, '__iter__') and not isinstance(x, (bytes, unicode)): return [asunicode_nested(y) for y in x] else: return asunicode(x)
mit
[ 624, 199, 4718, 650, 7163, 7249, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 363, 452, 363, 275, 788, 2394, 297, 283, 305, 2394, 297, 283, 6292, 1113, 297, 283, 303, 3858, 814, 297, 283, 495, 1560, 297, 1779, 283, 2975, 297, 283, 305, 2975, 297, 283, 305, 2394, 63, 6376, 297, 283, 305, 2975, 63, 6376, 297, 1779, 283, 305, 495, 297, 283, 1490, 63, 10378, 17, 297, 283, 2809, 297, 283, 17628, 297, 283, 4174, 85, 297, 1779, 283, 4115, 63, 1313, 418, 199, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 492, 5890, 339, 1846, 275, 1109, 272, 3000, 63, 1313, 275, 334, 442, 4258, 272, 7116, 275, 620, 272, 2649, 275, 620, 272, 2783, 275, 2783, 339, 347, 465, 2975, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2783, 304, 288, 372, 308, 14, 2708, 360, 10378, 17, 358, 267, 372, 620, 8, 83, 9, 339, 347, 28217, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2783, 304, 288, 372, 308, 267, 372, 620, 8, 83, 680, 2143, 360, 10378, 17, 358, 339, 347, 465, 495, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2783, 304, 288, 372, 308, 14, 2708, 360, 10378, 17, 358, 267, 372, 620, 8, 83, 9, 339, 347, 365, 9234, 8, 70, 304, 267, 372, 1228, 8, 70, 12, 334, 2308, 14, 26126, 12, 5890, 14, 23139, 5929, 12, 5890, 14, 23139, 6261, 430, 339, 347, 1551, 63, 10378, 17, 8, 1501, 12, 818, 534, 82, 735, 267, 372, 1551, 8, 1501, 12, 818, 29, 632, 12, 2644, 534, 4595, 13, 4830, 13, 17, 358, 339, 347, 3816, 85, 8, 83, 304, 267, 372, 308, 339, 620, 1560, 275, 283, 53, 7, 421, 199, 2836, 26, 272, 2783, 275, 620, 272, 1846, 275, 1846, 272, 7116, 275, 7116, 272, 2649, 275, 2649, 272, 3000, 63, 1313, 275, 334, 442, 12, 1846, 9, 272, 28217, 275, 620, 272, 465, 495, 275, 620, 272, 620, 1560, 275, 283, 51, 7, 2378, 347, 365, 9234, 8, 70, 304, 267, 372, 1228, 8, 70, 12, 570, 9, 339, 347, 465, 2975, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2649, 304, 288, 372, 308, 267, 372, 620, 8, 83, 680, 2708, 360, 4371, 358, 339, 347, 1551, 63, 10378, 17, 8, 1501, 12, 818, 534, 82, 735, 267, 372, 1551, 8, 1501, 12, 818, 29, 632, 9, 339, 347, 3816, 85, 8, 83, 304, 267, 372, 2649, 8, 83, 12, 283, 2975, 63, 3765, 358, 421, 199, 318, 2312, 3858, 814, 837, 272, 372, 984, 14, 2804, 63, 815, 3430, 17, 61, 199, 199, 318, 28217, 63, 6376, 8, 88, 304, 272, 340, 2688, 8, 88, 12, 2560, 1661, 13766, 436, 440, 1228, 8, 88, 12, 334, 2394, 12, 2649, 2298, 267, 372, 359, 305, 2394, 63, 6376, 8, 89, 9, 367, 612, 315, 671, 61, 272, 587, 26, 267, 372, 28217, 8, 88, 9, 199, 199, 318, 465, 2975, 63, 6376, 8, 88, 304, 272, 340, 2688, 8, 88, 12, 2560, 1661, 13766, 436, 440, 1228, 8, 88, 12, 334, 2394, 12, 2649, 2298, 267, 372, 359, 305, 2975, 63, 6376, 8, 89, 9, 367, 612, 315, 671, 61, 272, 587, 26, 267, 372, 465, 2975, 8, 88, 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 ]
[ 199, 4718, 650, 7163, 7249, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 12, 870, 63, 1593, 199, 199, 363, 452, 363, 275, 788, 2394, 297, 283, 305, 2394, 297, 283, 6292, 1113, 297, 283, 303, 3858, 814, 297, 283, 495, 1560, 297, 1779, 283, 2975, 297, 283, 305, 2975, 297, 283, 305, 2394, 63, 6376, 297, 283, 305, 2975, 63, 6376, 297, 1779, 283, 305, 495, 297, 283, 1490, 63, 10378, 17, 297, 283, 2809, 297, 283, 17628, 297, 283, 4174, 85, 297, 1779, 283, 4115, 63, 1313, 418, 199, 199, 646, 984, 199, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 492, 5890, 339, 1846, 275, 1109, 272, 3000, 63, 1313, 275, 334, 442, 4258, 272, 7116, 275, 620, 272, 2649, 275, 620, 272, 2783, 275, 2783, 339, 347, 465, 2975, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2783, 304, 288, 372, 308, 14, 2708, 360, 10378, 17, 358, 267, 372, 620, 8, 83, 9, 339, 347, 28217, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2783, 304, 288, 372, 308, 267, 372, 620, 8, 83, 680, 2143, 360, 10378, 17, 358, 339, 347, 465, 495, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2783, 304, 288, 372, 308, 14, 2708, 360, 10378, 17, 358, 267, 372, 620, 8, 83, 9, 339, 347, 365, 9234, 8, 70, 304, 267, 372, 1228, 8, 70, 12, 334, 2308, 14, 26126, 12, 5890, 14, 23139, 5929, 12, 5890, 14, 23139, 6261, 430, 339, 347, 1551, 63, 10378, 17, 8, 1501, 12, 818, 534, 82, 735, 267, 372, 1551, 8, 1501, 12, 818, 29, 632, 12, 2644, 534, 4595, 13, 4830, 13, 17, 358, 339, 347, 3816, 85, 8, 83, 304, 267, 372, 308, 339, 620, 1560, 275, 283, 53, 7, 421, 199, 2836, 26, 272, 2783, 275, 620, 272, 1846, 275, 1846, 272, 7116, 275, 7116, 272, 2649, 275, 2649, 272, 3000, 63, 1313, 275, 334, 442, 12, 1846, 9, 272, 28217, 275, 620, 272, 465, 495, 275, 620, 272, 620, 1560, 275, 283, 51, 7, 2378, 347, 365, 9234, 8, 70, 304, 267, 372, 1228, 8, 70, 12, 570, 9, 339, 347, 465, 2975, 8, 83, 304, 267, 340, 1228, 8, 83, 12, 2649, 304, 288, 372, 308, 267, 372, 620, 8, 83, 680, 2708, 360, 4371, 358, 339, 347, 1551, 63, 10378, 17, 8, 1501, 12, 818, 534, 82, 735, 267, 372, 1551, 8, 1501, 12, 818, 29, 632, 9, 339, 347, 3816, 85, 8, 83, 304, 267, 372, 2649, 8, 83, 12, 283, 2975, 63, 3765, 358, 421, 199, 318, 2312, 3858, 814, 837, 272, 372, 984, 14, 2804, 63, 815, 3430, 17, 61, 199, 199, 318, 28217, 63, 6376, 8, 88, 304, 272, 340, 2688, 8, 88, 12, 2560, 1661, 13766, 436, 440, 1228, 8, 88, 12, 334, 2394, 12, 2649, 2298, 267, 372, 359, 305, 2394, 63, 6376, 8, 89, 9, 367, 612, 315, 671, 61, 272, 587, 26, 267, 372, 28217, 8, 88, 9, 199, 199, 318, 465, 2975, 63, 6376, 8, 88, 304, 272, 340, 2688, 8, 88, 12, 2560, 1661, 13766, 436, 440, 1228, 8, 88, 12, 334, 2394, 12, 2649, 2298, 267, 372, 359, 305, 2975, 63, 6376, 8, 89, 9, 367, 612, 315, 671, 61, 272, 587, 26, 267, 372, 465, 2975, 8, 88, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
victorkeophila/alien4cloud-cloudify3-provider
src/test/resources/outputs/blueprints/amazon/lamp/plugins/custom_wf_plugin/plugin/workflows.py
1
36447
from cloudify.decorators import workflow from cloudify.workflows import ctx from cloudify.workflows import tasks as workflow_tasks from utils import set_state_task from utils import operation_task from utils import link_tasks from utils import CustomContext from utils import generate_native_node_workflows from utils import _get_all_nodes from utils import _get_all_nodes_instances from utils import _get_all_modified_node_instances from utils import is_host_node from workflow import WfStartEvent from workflow import build_pre_event # subworkflow 'install' for host 'DataBase' def install_host_database(ctx, graph, custom_context): custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') set_state_task(ctx, graph, 'Mysql', 'configuring', 'Mysql_configuring', custom_context) operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.create', 'create_Mysql', custom_context) operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.configure', 'configure_Mysql', custom_context) set_state_task(ctx, graph, 'Mysql', 'created', 'Mysql_created', custom_context) custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_install') set_state_task(ctx, graph, 'Mysql', 'creating', 'Mysql_creating', custom_context) set_state_task(ctx, graph, 'Mysql', 'starting', 'Mysql_starting', custom_context) set_state_task(ctx, graph, 'Mysql', 'configured', 'Mysql_configured', custom_context) set_state_task(ctx, graph, 'Mysql', 'started', 'Mysql_started', custom_context) set_state_task(ctx, graph, 'Mysql', 'initial', 'Mysql_initial', custom_context) operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.start', 'start_Mysql', custom_context) generate_native_node_workflows(ctx, graph, custom_context, 'install') link_tasks(graph, 'configure_Mysql', 'Mysql_configuring', custom_context) link_tasks(graph, 'Mysql_created', 'create_Mysql', custom_context) link_tasks(graph, 'Mysql_configured', 'configure_Mysql', custom_context) link_tasks(graph, 'Mysql_configuring', 'Mysql_created', custom_context) link_tasks(graph, 'Mysql_initial', 'DataBase_install', custom_context) link_tasks(graph, 'create_Mysql', 'Mysql_creating', custom_context) link_tasks(graph, 'start_Mysql', 'Mysql_starting', custom_context) link_tasks(graph, 'Mysql_starting', 'Mysql_configured', custom_context) link_tasks(graph, 'Mysql_creating', 'Mysql_initial', custom_context) link_tasks(graph, 'Mysql_started', 'start_Mysql', custom_context) # subworkflow 'install' for host 'Server' def install_host_server(ctx, graph, custom_context): custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('PHP') set_state_task(ctx, graph, 'PHP', 'starting', 'PHP_starting', custom_context) set_state_task(ctx, graph, 'Wordpress', 'started', 'Wordpress_started', custom_context) set_state_task(ctx, graph, 'Apache', 'initial', 'Apache_initial', custom_context) set_state_task(ctx, graph, 'Wordpress', 'configured', 'Wordpress_configured', custom_context) set_state_task(ctx, graph, 'Wordpress', 'starting', 'Wordpress_starting', custom_context) operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.start', 'start_PHP', custom_context) set_state_task(ctx, graph, 'Apache', 'starting', 'Apache_starting', custom_context) set_state_task(ctx, graph, 'PHP', 'configuring', 'PHP_configuring', custom_context) custom_context.register_native_delegate_wf_step('Server', 'Server_install') set_state_task(ctx, graph, 'PHP', 'created', 'PHP_created', custom_context) operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.start', 'start_Wordpress', custom_context) operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.configure', 'configure_Apache', custom_context) operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.create', 'create_Apache', custom_context) set_state_task(ctx, graph, 'Wordpress', 'initial', 'Wordpress_initial', custom_context) set_state_task(ctx, graph, 'Apache', 'configured', 'Apache_configured', custom_context) set_state_task(ctx, graph, 'PHP', 'started', 'PHP_started', custom_context) set_state_task(ctx, graph, 'Wordpress', 'configuring', 'Wordpress_configuring', custom_context) set_state_task(ctx, graph, 'PHP', 'creating', 'PHP_creating', custom_context) operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.configure', 'configure_Wordpress', custom_context) set_state_task(ctx, graph, 'Apache', 'creating', 'Apache_creating', custom_context) operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.create', 'create_PHP', custom_context) operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.start', 'start_Apache', custom_context) operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.configure', 'configure_PHP', custom_context) operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.create', 'create_Wordpress', custom_context) set_state_task(ctx, graph, 'Wordpress', 'creating', 'Wordpress_creating', custom_context) set_state_task(ctx, graph, 'Apache', 'created', 'Apache_created', custom_context) set_state_task(ctx, graph, 'Apache', 'started', 'Apache_started', custom_context) set_state_task(ctx, graph, 'Wordpress', 'created', 'Wordpress_created', custom_context) set_state_task(ctx, graph, 'Apache', 'configuring', 'Apache_configuring', custom_context) set_state_task(ctx, graph, 'PHP', 'initial', 'PHP_initial', custom_context) set_state_task(ctx, graph, 'PHP', 'configured', 'PHP_configured', custom_context) generate_native_node_workflows(ctx, graph, custom_context, 'install') link_tasks(graph, 'start_PHP', 'PHP_starting', custom_context) link_tasks(graph, 'Apache_creating', 'Apache_initial', custom_context) link_tasks(graph, 'Wordpress_starting', 'Wordpress_configured', custom_context) link_tasks(graph, 'start_Wordpress', 'Wordpress_starting', custom_context) link_tasks(graph, 'PHP_started', 'start_PHP', custom_context) link_tasks(graph, 'start_Apache', 'Apache_starting', custom_context) link_tasks(graph, 'configure_PHP', 'PHP_configuring', custom_context) link_tasks(graph, 'Apache_initial', 'Server_install', custom_context) link_tasks(graph, 'PHP_initial', 'Server_install', custom_context) link_tasks(graph, 'PHP_configuring', 'PHP_created', custom_context) link_tasks(graph, 'Wordpress_started', 'start_Wordpress', custom_context) link_tasks(graph, 'Apache_configured', 'configure_Apache', custom_context) link_tasks(graph, 'Apache_created', 'create_Apache', custom_context) link_tasks(graph, 'Wordpress_creating', 'Wordpress_initial', custom_context) link_tasks(graph, 'Apache_starting', 'Apache_configured', custom_context) link_tasks(graph, 'Wordpress_configuring', 'PHP_started', custom_context) link_tasks(graph, 'configure_Wordpress', 'Wordpress_configuring', custom_context) link_tasks(graph, 'create_PHP', 'PHP_creating', custom_context) link_tasks(graph, 'Wordpress_configured', 'configure_Wordpress', custom_context) link_tasks(graph, 'create_Apache', 'Apache_creating', custom_context) link_tasks(graph, 'PHP_created', 'create_PHP', custom_context) link_tasks(graph, 'Apache_started', 'start_Apache', custom_context) link_tasks(graph, 'PHP_configured', 'configure_PHP', custom_context) link_tasks(graph, 'Wordpress_created', 'create_Wordpress', custom_context) link_tasks(graph, 'create_Wordpress', 'Wordpress_creating', custom_context) link_tasks(graph, 'Apache_configuring', 'Apache_created', custom_context) link_tasks(graph, 'Wordpress_initial', 'Apache_started', custom_context) link_tasks(graph, 'PHP_configuring', 'Wordpress_created', custom_context) link_tasks(graph, 'Wordpress_configuring', 'Wordpress_created', custom_context) link_tasks(graph, 'configure_Apache', 'Apache_configuring', custom_context) link_tasks(graph, 'PHP_creating', 'PHP_initial', custom_context) link_tasks(graph, 'PHP_starting', 'PHP_configured', custom_context) # subworkflow 'uninstall' for host 'DataBase' def uninstall_host_database(ctx, graph, custom_context): custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') set_state_task(ctx, graph, 'Mysql', 'deleted', 'Mysql_deleted', custom_context) set_state_task(ctx, graph, 'Mysql', 'deleting', 'Mysql_deleting', custom_context) custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_uninstall') set_state_task(ctx, graph, 'Mysql', 'stopped', 'Mysql_stopped', custom_context) set_state_task(ctx, graph, 'Mysql', 'stopping', 'Mysql_stopping', custom_context) generate_native_node_workflows(ctx, graph, custom_context, 'uninstall') link_tasks(graph, 'DataBase_uninstall', 'Mysql_deleted', custom_context) link_tasks(graph, 'Mysql_deleted', 'Mysql_deleting', custom_context) link_tasks(graph, 'Mysql_deleting', 'Mysql_stopped', custom_context) link_tasks(graph, 'Mysql_stopped', 'Mysql_stopping', custom_context) # subworkflow 'uninstall' for host 'Server' def uninstall_host_server(ctx, graph, custom_context): custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('PHP') set_state_task(ctx, graph, 'PHP', 'stopping', 'PHP_stopping', custom_context) set_state_task(ctx, graph, 'Wordpress', 'deleting', 'Wordpress_deleting', custom_context) set_state_task(ctx, graph, 'Apache', 'stopped', 'Apache_stopped', custom_context) set_state_task(ctx, graph, 'Apache', 'deleted', 'Apache_deleted', custom_context) set_state_task(ctx, graph, 'Wordpress', 'deleted', 'Wordpress_deleted', custom_context) set_state_task(ctx, graph, 'Apache', 'deleting', 'Apache_deleting', custom_context) set_state_task(ctx, graph, 'Apache', 'stopping', 'Apache_stopping', custom_context) set_state_task(ctx, graph, 'Wordpress', 'stopped', 'Wordpress_stopped', custom_context) set_state_task(ctx, graph, 'PHP', 'deleting', 'PHP_deleting', custom_context) custom_context.register_native_delegate_wf_step('Server', 'Server_uninstall') set_state_task(ctx, graph, 'PHP', 'stopped', 'PHP_stopped', custom_context) set_state_task(ctx, graph, 'Wordpress', 'stopping', 'Wordpress_stopping', custom_context) set_state_task(ctx, graph, 'PHP', 'deleted', 'PHP_deleted', custom_context) generate_native_node_workflows(ctx, graph, custom_context, 'uninstall') link_tasks(graph, 'PHP_stopped', 'PHP_stopping', custom_context) link_tasks(graph, 'Wordpress_deleted', 'Wordpress_deleting', custom_context) link_tasks(graph, 'Apache_deleting', 'Apache_stopped', custom_context) link_tasks(graph, 'Server_uninstall', 'Apache_deleted', custom_context) link_tasks(graph, 'Apache_stopping', 'Wordpress_deleted', custom_context) link_tasks(graph, 'Apache_deleted', 'Apache_deleting', custom_context) link_tasks(graph, 'Apache_stopped', 'Apache_stopping', custom_context) link_tasks(graph, 'Wordpress_deleting', 'Wordpress_stopped', custom_context) link_tasks(graph, 'PHP_deleted', 'PHP_deleting', custom_context) link_tasks(graph, 'PHP_deleting', 'PHP_stopped', custom_context) link_tasks(graph, 'Wordpress_stopped', 'Wordpress_stopping', custom_context) link_tasks(graph, 'Server_uninstall', 'PHP_deleted', custom_context) def install_host(ctx, graph, custom_context, compute): options = {} options['DataBase'] = install_host_database options['Server'] = install_host_server options[compute](ctx, graph, custom_context) def uninstall_host(ctx, graph, custom_context, compute): options = {} options['DataBase'] = uninstall_host_database options['Server'] = uninstall_host_server options[compute](ctx, graph, custom_context) @workflow def a4c_install(**kwargs): graph = ctx.graph_mode() nodes = _get_all_nodes(ctx) instances = _get_all_nodes_instances(ctx) custom_context = CustomContext(ctx, instances, nodes) ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('install'))) _a4c_install(ctx, graph, custom_context) return graph.execute() @workflow def a4c_uninstall(**kwargs): graph = ctx.graph_mode() nodes = _get_all_nodes(ctx) instances = _get_all_nodes_instances(ctx) custom_context = CustomContext(ctx, instances, nodes) ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('uninstall'))) _a4c_uninstall(ctx, graph, custom_context) return graph.execute() def _a4c_install(ctx, graph, custom_context): # following code can be pasted in src/test/python/workflows/tasks.py for simulation custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('PHP') set_state_task(ctx, graph, 'PHP', 'starting', 'PHP_starting', custom_context) set_state_task(ctx, graph, 'Wordpress', 'started', 'Wordpress_started', custom_context) set_state_task(ctx, graph, 'Mysql', 'configuring', 'Mysql_configuring', custom_context) operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.create', 'create_Mysql', custom_context) set_state_task(ctx, graph, 'Apache', 'initial', 'Apache_initial', custom_context) operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.configure', 'configure_Mysql', custom_context) set_state_task(ctx, graph, 'Wordpress', 'configured', 'Wordpress_configured', custom_context) set_state_task(ctx, graph, 'Wordpress', 'starting', 'Wordpress_starting', custom_context) set_state_task(ctx, graph, 'Mysql', 'created', 'Mysql_created', custom_context) custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_install') operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.start', 'start_PHP', custom_context) set_state_task(ctx, graph, 'Apache', 'starting', 'Apache_starting', custom_context) set_state_task(ctx, graph, 'PHP', 'configuring', 'PHP_configuring', custom_context) custom_context.register_native_delegate_wf_step('Server', 'Server_install') set_state_task(ctx, graph, 'PHP', 'created', 'PHP_created', custom_context) operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.start', 'start_Wordpress', custom_context) operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.configure', 'configure_Apache', custom_context) set_state_task(ctx, graph, 'Mysql', 'creating', 'Mysql_creating', custom_context) operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.create', 'create_Apache', custom_context) set_state_task(ctx, graph, 'Wordpress', 'initial', 'Wordpress_initial', custom_context) set_state_task(ctx, graph, 'Apache', 'configured', 'Apache_configured', custom_context) set_state_task(ctx, graph, 'PHP', 'started', 'PHP_started', custom_context) set_state_task(ctx, graph, 'Wordpress', 'configuring', 'Wordpress_configuring', custom_context) set_state_task(ctx, graph, 'PHP', 'creating', 'PHP_creating', custom_context) operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.configure', 'configure_Wordpress', custom_context) set_state_task(ctx, graph, 'Mysql', 'starting', 'Mysql_starting', custom_context) set_state_task(ctx, graph, 'Mysql', 'configured', 'Mysql_configured', custom_context) custom_context.register_native_delegate_wf_step('NetPub', 'NetPub_install') set_state_task(ctx, graph, 'Apache', 'creating', 'Apache_creating', custom_context) operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.create', 'create_PHP', custom_context) operation_task(ctx, graph, 'Apache', 'cloudify.interfaces.lifecycle.start', 'start_Apache', custom_context) operation_task(ctx, graph, 'PHP', 'cloudify.interfaces.lifecycle.configure', 'configure_PHP', custom_context) set_state_task(ctx, graph, 'Mysql', 'started', 'Mysql_started', custom_context) operation_task(ctx, graph, 'Wordpress', 'cloudify.interfaces.lifecycle.create', 'create_Wordpress', custom_context) set_state_task(ctx, graph, 'Wordpress', 'creating', 'Wordpress_creating', custom_context) set_state_task(ctx, graph, 'Mysql', 'initial', 'Mysql_initial', custom_context) set_state_task(ctx, graph, 'Apache', 'created', 'Apache_created', custom_context) set_state_task(ctx, graph, 'Apache', 'started', 'Apache_started', custom_context) set_state_task(ctx, graph, 'Wordpress', 'created', 'Wordpress_created', custom_context) set_state_task(ctx, graph, 'Apache', 'configuring', 'Apache_configuring', custom_context) operation_task(ctx, graph, 'Mysql', 'cloudify.interfaces.lifecycle.start', 'start_Mysql', custom_context) set_state_task(ctx, graph, 'PHP', 'initial', 'PHP_initial', custom_context) set_state_task(ctx, graph, 'PHP', 'configured', 'PHP_configured', custom_context) generate_native_node_workflows(ctx, graph, custom_context, 'install') link_tasks(graph, 'PHP_starting', 'PHP_configured', custom_context) link_tasks(graph, 'Wordpress_started', 'start_Wordpress', custom_context) link_tasks(graph, 'Mysql_configuring', 'Wordpress_created', custom_context) link_tasks(graph, 'Mysql_configuring', 'Mysql_created', custom_context) link_tasks(graph, 'create_Mysql', 'Mysql_creating', custom_context) link_tasks(graph, 'Apache_initial', 'Server_install', custom_context) link_tasks(graph, 'configure_Mysql', 'Mysql_configuring', custom_context) link_tasks(graph, 'Wordpress_configured', 'configure_Wordpress', custom_context) link_tasks(graph, 'Wordpress_starting', 'Wordpress_configured', custom_context) link_tasks(graph, 'Mysql_created', 'create_Mysql', custom_context) link_tasks(graph, 'start_PHP', 'PHP_starting', custom_context) link_tasks(graph, 'Apache_starting', 'Apache_configured', custom_context) link_tasks(graph, 'PHP_configuring', 'PHP_created', custom_context) link_tasks(graph, 'PHP_configuring', 'Wordpress_created', custom_context) link_tasks(graph, 'PHP_created', 'create_PHP', custom_context) link_tasks(graph, 'start_Wordpress', 'Wordpress_starting', custom_context) link_tasks(graph, 'configure_Apache', 'Apache_configuring', custom_context) link_tasks(graph, 'Mysql_creating', 'Mysql_initial', custom_context) link_tasks(graph, 'create_Apache', 'Apache_creating', custom_context) link_tasks(graph, 'Wordpress_initial', 'Apache_started', custom_context) link_tasks(graph, 'Apache_configured', 'configure_Apache', custom_context) link_tasks(graph, 'PHP_started', 'start_PHP', custom_context) link_tasks(graph, 'Wordpress_configuring', 'Mysql_started', custom_context) link_tasks(graph, 'Wordpress_configuring', 'PHP_started', custom_context) link_tasks(graph, 'Wordpress_configuring', 'Wordpress_created', custom_context) link_tasks(graph, 'PHP_creating', 'PHP_initial', custom_context) link_tasks(graph, 'configure_Wordpress', 'Wordpress_configuring', custom_context) link_tasks(graph, 'Mysql_starting', 'Mysql_configured', custom_context) link_tasks(graph, 'Mysql_configured', 'configure_Mysql', custom_context) link_tasks(graph, 'Apache_creating', 'Apache_initial', custom_context) link_tasks(graph, 'create_PHP', 'PHP_creating', custom_context) link_tasks(graph, 'start_Apache', 'Apache_starting', custom_context) link_tasks(graph, 'configure_PHP', 'PHP_configuring', custom_context) link_tasks(graph, 'Mysql_started', 'start_Mysql', custom_context) link_tasks(graph, 'create_Wordpress', 'Wordpress_creating', custom_context) link_tasks(graph, 'Wordpress_creating', 'Wordpress_initial', custom_context) link_tasks(graph, 'Mysql_initial', 'DataBase_install', custom_context) link_tasks(graph, 'Apache_created', 'create_Apache', custom_context) link_tasks(graph, 'Apache_started', 'start_Apache', custom_context) link_tasks(graph, 'Wordpress_created', 'create_Wordpress', custom_context) link_tasks(graph, 'Apache_configuring', 'Apache_created', custom_context) link_tasks(graph, 'start_Mysql', 'Mysql_starting', custom_context) link_tasks(graph, 'PHP_initial', 'Server_install', custom_context) link_tasks(graph, 'PHP_configured', 'configure_PHP', custom_context) def _a4c_uninstall(ctx, graph, custom_context): # following code can be pasted in src/test/python/workflows/tasks.py for simulation custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Apache') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Mysql') custom_context.add_customized_wf_node('Wordpress') custom_context.add_customized_wf_node('PHP') custom_context.add_customized_wf_node('Mysql') set_state_task(ctx, graph, 'PHP', 'stopping', 'PHP_stopping', custom_context) set_state_task(ctx, graph, 'Wordpress', 'deleting', 'Wordpress_deleting', custom_context) set_state_task(ctx, graph, 'Apache', 'stopped', 'Apache_stopped', custom_context) set_state_task(ctx, graph, 'Mysql', 'deleted', 'Mysql_deleted', custom_context) set_state_task(ctx, graph, 'Apache', 'deleted', 'Apache_deleted', custom_context) set_state_task(ctx, graph, 'Wordpress', 'deleted', 'Wordpress_deleted', custom_context) set_state_task(ctx, graph, 'Mysql', 'deleting', 'Mysql_deleting', custom_context) custom_context.register_native_delegate_wf_step('NetPub', 'NetPub_uninstall') custom_context.register_native_delegate_wf_step('DataBase', 'DataBase_uninstall') set_state_task(ctx, graph, 'Apache', 'deleting', 'Apache_deleting', custom_context) set_state_task(ctx, graph, 'Apache', 'stopping', 'Apache_stopping', custom_context) set_state_task(ctx, graph, 'Wordpress', 'stopped', 'Wordpress_stopped', custom_context) set_state_task(ctx, graph, 'PHP', 'deleting', 'PHP_deleting', custom_context) custom_context.register_native_delegate_wf_step('Server', 'Server_uninstall') set_state_task(ctx, graph, 'PHP', 'stopped', 'PHP_stopped', custom_context) set_state_task(ctx, graph, 'Mysql', 'stopped', 'Mysql_stopped', custom_context) set_state_task(ctx, graph, 'Wordpress', 'stopping', 'Wordpress_stopping', custom_context) set_state_task(ctx, graph, 'PHP', 'deleted', 'PHP_deleted', custom_context) set_state_task(ctx, graph, 'Mysql', 'stopping', 'Mysql_stopping', custom_context) generate_native_node_workflows(ctx, graph, custom_context, 'uninstall') link_tasks(graph, 'Wordpress_deleting', 'Wordpress_stopped', custom_context) link_tasks(graph, 'Apache_stopped', 'Apache_stopping', custom_context) link_tasks(graph, 'Mysql_deleted', 'Mysql_deleting', custom_context) link_tasks(graph, 'Apache_deleted', 'Apache_deleting', custom_context) link_tasks(graph, 'Wordpress_deleted', 'Wordpress_deleting', custom_context) link_tasks(graph, 'Mysql_deleting', 'Mysql_stopped', custom_context) link_tasks(graph, 'DataBase_uninstall', 'Mysql_deleted', custom_context) link_tasks(graph, 'Apache_deleting', 'Apache_stopped', custom_context) link_tasks(graph, 'Apache_stopping', 'Wordpress_deleted', custom_context) link_tasks(graph, 'Wordpress_stopped', 'Wordpress_stopping', custom_context) link_tasks(graph, 'PHP_deleting', 'PHP_stopped', custom_context) link_tasks(graph, 'Server_uninstall', 'Apache_deleted', custom_context) link_tasks(graph, 'Server_uninstall', 'PHP_deleted', custom_context) link_tasks(graph, 'PHP_stopped', 'PHP_stopping', custom_context) link_tasks(graph, 'Mysql_stopped', 'Mysql_stopping', custom_context) link_tasks(graph, 'PHP_deleted', 'PHP_deleting', custom_context) def _get_scaling_group_name_from_node_id(ctx, node_id): scaling_groups=ctx.deployment.scaling_groups for group_name, scaling_group in ctx.deployment.scaling_groups.iteritems(): for member in scaling_group['members']: if member == node_id: ctx.logger.info("Node {} found in scaling group {}".format(node_id, group_name)) return group_name return None @workflow def a4c_scale(ctx, node_id, delta, scale_compute, **kwargs): delta = int(delta) scalable_entity_name = _get_scaling_group_name_from_node_id(ctx, node_id) scaling_group = ctx.deployment.scaling_groups.get(scalable_entity_name) if scalable_entity_name: curr_num_instances = scaling_group['properties']['current_instances'] planned_num_instances = curr_num_instances + delta scale_id = scalable_entity_name else: scaled_node = ctx.get_node(scalable_entity_name) if not scaled_node: raise ValueError("Node {0} doesn't exist".format(scalable_entity_name)) if not is_host_node(scaled_node): raise ValueError("Node {0} is not a host. This workflow can only scale hosts".format(scalable_entity_name)) if delta == 0: ctx.logger.info('delta parameter is 0, so no scaling will take place.') return curr_num_instances = scaled_node.number_of_instances planned_num_instances = curr_num_instances + delta scale_id = scaled_node.id if planned_num_instances < 1: raise ValueError('Provided delta: {0} is illegal. current number of' 'instances of node/group {1} is {2}' .format(delta, scalable_entity_name, curr_num_instances)) modification = ctx.deployment.start_modification({ scale_id: { 'instances': planned_num_instances } }) ctx.logger.info('Deployment modification started. [modification_id={0} : {1}]'.format(modification.id, dir(modification))) try: if delta > 0: ctx.logger.info('Scaling host/group {0} adding {1} instances'.format(scalable_entity_name, delta)) added_and_related = _get_all_nodes(modification.added) added = _get_all_modified_node_instances(added_and_related, 'added') graph = ctx.graph_mode() ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('scale', 'install'))) custom_context = CustomContext(ctx, added, added_and_related) install_host(ctx, graph, custom_context, node_id) try: graph.execute() except: ctx.logger.error('Scale failed. Uninstalling node/group {0}'.format(scalable_entity_name)) graph = ctx.internal.task_graph for task in graph.tasks_iter(): graph.remove_task(task) try: custom_context = CustomContext(ctx, added, added_and_related) uninstall_host(ctx, graph, custom_context, scalable_entity_name) graph.execute() except: ctx.logger.error('Node {0} uninstallation following scale failure has failed'.format(scalable_entity_name)) raise else: ctx.logger.info('Unscaling host/group {0} removing {1} instances'.format(scalable_entity_name, delta)) removed_and_related = _get_all_nodes(modification.removed) removed = _get_all_modified_node_instances(removed_and_related, 'removed') graph = ctx.graph_mode() ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('scale', 'uninstall'))) custom_context = CustomContext(ctx, removed, removed_and_related) uninstall_host(ctx, graph, custom_context, node_id) try: graph.execute() except: ctx.logger.error('Unscale failed.') raise except: ctx.logger.warn('Rolling back deployment modification. [modification_id={0}]'.format(modification.id)) try: modification.rollback() except: ctx.logger.warn('Deployment modification rollback failed. The ' 'deployment model is most likely in some corrupted' ' state.' '[modification_id={0}]'.format(modification.id)) raise raise else: try: modification.finish() except: ctx.logger.warn('Deployment modification finish failed. The ' 'deployment model is most likely in some corrupted' ' state.' '[modification_id={0}]'.format(modification.id)) raise @workflow def a4c_heal( ctx, node_instance_id, diagnose_value='Not provided', **kwargs): """Reinstalls the whole subgraph of the system topology The subgraph consists of all the nodes that are hosted in the failing node's compute and the compute itself. Additionally it unlinks and establishes appropriate relationships :param ctx: cloudify context :param node_id: failing node's id :param diagnose_value: diagnosed reason of failure """ ctx.logger.info("Starting 'heal' workflow on {0}, Diagnosis: {1}" .format(node_instance_id, diagnose_value)) failing_node = ctx.get_node_instance(node_instance_id) host_instance_id = failing_node._node_instance.host_id failing_node_host = ctx.get_node_instance(host_instance_id) node_id = failing_node_host.node_id subgraph_node_instances = failing_node_host.get_contained_subgraph() added_and_related = _get_all_nodes(ctx) try: graph = ctx.graph_mode() ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('heal', 'uninstall'))) custom_context = CustomContext(ctx, subgraph_node_instances, added_and_related) uninstall_host(ctx, graph, custom_context, node_id) graph.execute() except: ctx.logger.error('Uninstall while healing failed.') graph = ctx.internal.task_graph for task in graph.tasks_iter(): graph.remove_task(task) ctx.internal.send_workflow_event(event_type='a4c_workflow_started', message=build_pre_event(WfStartEvent('heal', 'install'))) custom_context = CustomContext(ctx, subgraph_node_instances, added_and_related) install_host(ctx, graph, custom_context, node_id) graph.execute() #following code can be pasted in src/test/python/workflows/context.py for simulation #def _build_nodes(ctx): #types = [] #types.append('alien.nodes.Apache') #types.append('tosca.nodes.WebServer') #types.append('tosca.nodes.SoftwareComponent') #types.append('tosca.nodes.Root') #node_Apache = _build_node(ctx, 'Apache', types, 1) #types = [] #types.append('alien.cloudify.aws.nodes.Compute') #types.append('tosca.nodes.Compute') #types.append('tosca.nodes.Root') #node_DataBase = _build_node(ctx, 'DataBase', types, 1) #types = [] #types.append('alien.nodes.PHP') #types.append('tosca.nodes.SoftwareComponent') #types.append('tosca.nodes.Root') #node_PHP = _build_node(ctx, 'PHP', types, 1) #types = [] #types.append('alien.nodes.Wordpress') #types.append('tosca.nodes.WebApplication') #types.append('tosca.nodes.Root') #node_Wordpress = _build_node(ctx, 'Wordpress', types, 1) #types = [] #types.append('alien.nodes.aws.PublicNetwork') #types.append('alien.nodes.PublicNetwork') #types.append('tosca.nodes.Network') #types.append('tosca.nodes.Root') #node_NetPub = _build_node(ctx, 'NetPub', types, 1) #types = [] #types.append('alien.cloudify.aws.nodes.Compute') #types.append('tosca.nodes.Compute') #types.append('tosca.nodes.Root') #node_Server = _build_node(ctx, 'Server', types, 1) #types = [] #types.append('alien.nodes.Mysql') #types.append('tosca.nodes.Database') #types.append('tosca.nodes.Root') #node_Mysql = _build_node(ctx, 'Mysql', types, 1) #_add_relationship(node_Apache, node_Server) #_add_relationship(node_PHP, node_Server) #_add_relationship(node_Wordpress, node_PHP) #_add_relationship(node_Wordpress, node_Apache) #_add_relationship(node_Wordpress, node_Mysql) #_add_relationship(node_Server, node_NetPub) #_add_relationship(node_Mysql, node_DataBase)
apache-2.0
[ 504, 2463, 14525, 1399, 14, 11582, 492, 10431, 199, 504, 2463, 14525, 1399, 14, 25964, 492, 4027, 199, 504, 2463, 14525, 1399, 14, 25964, 492, 6527, 465, 10431, 63, 5054, 199, 504, 3778, 492, 663, 63, 929, 63, 1765, 199, 504, 3778, 492, 3439, 63, 1765, 199, 504, 3778, 492, 2142, 63, 5054, 199, 504, 3778, 492, 8388, 2998, 199, 504, 3778, 492, 3550, 63, 6106, 63, 932, 63, 25964, 199, 504, 3778, 492, 485, 362, 63, 452, 63, 2415, 199, 504, 3778, 492, 485, 362, 63, 452, 63, 2415, 63, 5990, 199, 504, 3778, 492, 485, 362, 63, 452, 63, 5540, 63, 932, 63, 5990, 199, 504, 3778, 492, 365, 63, 1102, 63, 932, 199, 504, 10431, 492, 644, 70, 3162, 2390, 199, 504, 10431, 492, 1900, 63, 657, 63, 1430, 421, 199, 3, 1007, 8856, 283, 3174, 7, 367, 1591, 283, 1451, 1563, 7, 199, 318, 3907, 63, 1102, 63, 4659, 8, 3799, 12, 3343, 12, 3537, 63, 1100, 304, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 888, 4039, 297, 283, 45, 6398, 63, 888, 4039, 297, 3537, 63, 1100, 9, 272, 3439, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 1251, 14525, 1399, 14, 7436, 14, 28346, 14, 981, 297, 283, 981, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 3439, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 1251, 14525, 1399, 14, 7436, 14, 28346, 14, 6472, 297, 283, 6472, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 3966, 297, 283, 45, 6398, 63, 3966, 297, 3537, 63, 1100, 9, 272, 3537, 63, 1100, 14, 2683, 63, 6106, 63, 15286, 63, 14114, 63, 2926, 360, 1451, 1563, 297, 283, 1451, 1563, 63, 3174, 358, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 20358, 297, 283, 45, 6398, 63, 20358, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 15769, 297, 283, 45, 6398, 63, 15769, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 11786, 297, 283, 45, 6398, 63, 11786, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 8924, 297, 283, 45, 6398, 63, 8924, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 2747, 297, 283, 45, 6398, 63, 2747, 297, 3537, 63, 1100, 9, 272, 3439, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 1251, 14525, 1399, 14, 7436, 14, 28346, 14, 928, 297, 283, 928, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 3550, 63, 6106, 63, 932, 63, 25964, 8, 3799, 12, 3343, 12, 3537, 63, 1100, 12, 283, 3174, 358, 272, 2142, 63, 5054, 8, 2180, 12, 283, 6472, 63, 45, 6398, 297, 283, 45, 6398, 63, 888, 4039, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 3966, 297, 283, 981, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 11786, 297, 283, 6472, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 888, 4039, 297, 283, 45, 6398, 63, 3966, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 2747, 297, 283, 1451, 1563, 63, 3174, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 981, 63, 45, 6398, 297, 283, 45, 6398, 63, 20358, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 928, 63, 45, 6398, 297, 283, 45, 6398, 63, 15769, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 15769, 297, 283, 45, 6398, 63, 11786, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 20358, 297, 283, 45, 6398, 63, 2747, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 8924, 297, 283, 928, 63, 45, 6398, 297, 3537, 63, 1100, 9, 421, 199, 3, 1007, 8856, 283, 3174, 7, 367, 1591, 283, 3120, 7, 199, 318, 3907, 63, 1102, 63, 1000, 8, 3799, 12, 3343, 12, 3537, 63, 1100, 304, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 31300, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 10155, 2915, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 28993, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 10155, 2915, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 10155, 2915, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 28993, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 31300, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 31300, 358, 272, 3537, 63, 1100, 14, 525, 63 ]
[ 2463, 14525, 1399, 14, 11582, 492, 10431, 199, 504, 2463, 14525, 1399, 14, 25964, 492, 4027, 199, 504, 2463, 14525, 1399, 14, 25964, 492, 6527, 465, 10431, 63, 5054, 199, 504, 3778, 492, 663, 63, 929, 63, 1765, 199, 504, 3778, 492, 3439, 63, 1765, 199, 504, 3778, 492, 2142, 63, 5054, 199, 504, 3778, 492, 8388, 2998, 199, 504, 3778, 492, 3550, 63, 6106, 63, 932, 63, 25964, 199, 504, 3778, 492, 485, 362, 63, 452, 63, 2415, 199, 504, 3778, 492, 485, 362, 63, 452, 63, 2415, 63, 5990, 199, 504, 3778, 492, 485, 362, 63, 452, 63, 5540, 63, 932, 63, 5990, 199, 504, 3778, 492, 365, 63, 1102, 63, 932, 199, 504, 10431, 492, 644, 70, 3162, 2390, 199, 504, 10431, 492, 1900, 63, 657, 63, 1430, 421, 199, 3, 1007, 8856, 283, 3174, 7, 367, 1591, 283, 1451, 1563, 7, 199, 318, 3907, 63, 1102, 63, 4659, 8, 3799, 12, 3343, 12, 3537, 63, 1100, 304, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 45, 6398, 358, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 888, 4039, 297, 283, 45, 6398, 63, 888, 4039, 297, 3537, 63, 1100, 9, 272, 3439, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 1251, 14525, 1399, 14, 7436, 14, 28346, 14, 981, 297, 283, 981, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 3439, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 1251, 14525, 1399, 14, 7436, 14, 28346, 14, 6472, 297, 283, 6472, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 3966, 297, 283, 45, 6398, 63, 3966, 297, 3537, 63, 1100, 9, 272, 3537, 63, 1100, 14, 2683, 63, 6106, 63, 15286, 63, 14114, 63, 2926, 360, 1451, 1563, 297, 283, 1451, 1563, 63, 3174, 358, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 20358, 297, 283, 45, 6398, 63, 20358, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 15769, 297, 283, 45, 6398, 63, 15769, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 11786, 297, 283, 45, 6398, 63, 11786, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 8924, 297, 283, 45, 6398, 63, 8924, 297, 3537, 63, 1100, 9, 272, 663, 63, 929, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 2747, 297, 283, 45, 6398, 63, 2747, 297, 3537, 63, 1100, 9, 272, 3439, 63, 1765, 8, 3799, 12, 3343, 12, 283, 45, 6398, 297, 283, 1251, 14525, 1399, 14, 7436, 14, 28346, 14, 928, 297, 283, 928, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 3550, 63, 6106, 63, 932, 63, 25964, 8, 3799, 12, 3343, 12, 3537, 63, 1100, 12, 283, 3174, 358, 272, 2142, 63, 5054, 8, 2180, 12, 283, 6472, 63, 45, 6398, 297, 283, 45, 6398, 63, 888, 4039, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 3966, 297, 283, 981, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 11786, 297, 283, 6472, 63, 45, 6398, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 888, 4039, 297, 283, 45, 6398, 63, 3966, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 2747, 297, 283, 1451, 1563, 63, 3174, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 981, 63, 45, 6398, 297, 283, 45, 6398, 63, 20358, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 928, 63, 45, 6398, 297, 283, 45, 6398, 63, 15769, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 15769, 297, 283, 45, 6398, 63, 11786, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 20358, 297, 283, 45, 6398, 63, 2747, 297, 3537, 63, 1100, 9, 272, 2142, 63, 5054, 8, 2180, 12, 283, 45, 6398, 63, 8924, 297, 283, 928, 63, 45, 6398, 297, 3537, 63, 1100, 9, 421, 199, 3, 1007, 8856, 283, 3174, 7, 367, 1591, 283, 3120, 7, 199, 318, 3907, 63, 1102, 63, 1000, 8, 3799, 12, 3343, 12, 3537, 63, 1100, 304, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 31300, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 10155, 2915, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 28993, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 10155, 2915, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 10155, 2915, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 28993, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 31300, 358, 272, 3537, 63, 1100, 14, 525, 63, 4229, 1759, 63, 14114, 63, 932, 360, 31300, 358, 272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1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bitcity/django
tests/many_to_one_null/tests.py
142
6484
from __future__ import unicode_literals from django.test import TestCase from .models import Article, Car, Driver, Reporter class ManyToOneNullTests(TestCase): def setUp(self): # Create a Reporter. self.r = Reporter(name='John Smith') self.r.save() # Create an Article. self.a = Article(headline="First", reporter=self.r) self.a.save() # Create an Article via the Reporter object. self.a2 = self.r.article_set.create(headline="Second") # Create an Article with no Reporter by passing "reporter=None". self.a3 = Article(headline="Third", reporter=None) self.a3.save() # Create another article and reporter self.r2 = Reporter(name='Paul Jones') self.r2.save() self.a4 = self.r2.article_set.create(headline='Fourth') def test_get_related(self): self.assertEqual(self.a.reporter.id, self.r.id) # Article objects have access to their related Reporter objects. r = self.a.reporter self.assertEqual(r.id, self.r.id) def test_created_via_related_set(self): self.assertEqual(self.a2.reporter.id, self.r.id) def test_related_set(self): # Reporter objects have access to their related Article objects. self.assertQuerysetEqual(self.r.article_set.all(), ['<Article: First>', '<Article: Second>']) self.assertQuerysetEqual(self.r.article_set.filter(headline__startswith='Fir'), ['<Article: First>']) self.assertEqual(self.r.article_set.count(), 2) def test_created_without_related(self): self.assertEqual(self.a3.reporter, None) # Need to reget a3 to refresh the cache a3 = Article.objects.get(pk=self.a3.pk) self.assertRaises(AttributeError, getattr, a3.reporter, 'id') # Accessing an article's 'reporter' attribute returns None # if the reporter is set to None. self.assertEqual(a3.reporter, None) # To retrieve the articles with no reporters set, use "reporter__isnull=True". self.assertQuerysetEqual(Article.objects.filter(reporter__isnull=True), ['<Article: Third>']) # We can achieve the same thing by filtering for the case where the # reporter is None. self.assertQuerysetEqual(Article.objects.filter(reporter=None), ['<Article: Third>']) # Set the reporter for the Third article self.assertQuerysetEqual(self.r.article_set.all(), ['<Article: First>', '<Article: Second>']) self.r.article_set.add(a3) self.assertQuerysetEqual(self.r.article_set.all(), ['<Article: First>', '<Article: Second>', '<Article: Third>']) # Remove an article from the set, and check that it was removed. self.r.article_set.remove(a3) self.assertQuerysetEqual(self.r.article_set.all(), ['<Article: First>', '<Article: Second>']) self.assertQuerysetEqual(Article.objects.filter(reporter__isnull=True), ['<Article: Third>']) def test_remove_from_wrong_set(self): self.assertQuerysetEqual(self.r2.article_set.all(), ['<Article: Fourth>']) # Try to remove a4 from a set it does not belong to self.assertRaises(Reporter.DoesNotExist, self.r.article_set.remove, self.a4) self.assertQuerysetEqual(self.r2.article_set.all(), ['<Article: Fourth>']) def test_set(self): # Use manager.set() to allocate ForeignKey. Null is legal, so existing # members of the set that are not in the assignment set are set to null. self.r2.article_set.set([self.a2, self.a3]) self.assertQuerysetEqual(self.r2.article_set.all(), ['<Article: Second>', '<Article: Third>']) # Use manager.set(clear=True) self.r2.article_set.set([self.a3, self.a4], clear=True) self.assertQuerysetEqual(self.r2.article_set.all(), ['<Article: Fourth>', '<Article: Third>']) # Clear the rest of the set self.r2.article_set.set([]) self.assertQuerysetEqual(self.r2.article_set.all(), []) self.assertQuerysetEqual(Article.objects.filter(reporter__isnull=True), ['<Article: Fourth>', '<Article: Second>', '<Article: Third>']) def test_assign_clear_related_set(self): # Use descriptor assignment to allocate ForeignKey. Null is legal, so # existing members of the set that are not in the assignment set are # set to null. self.r2.article_set = [self.a2, self.a3] self.assertQuerysetEqual(self.r2.article_set.all(), ['<Article: Second>', '<Article: Third>']) # Clear the rest of the set self.r.article_set.clear() self.assertQuerysetEqual(self.r.article_set.all(), []) self.assertQuerysetEqual(Article.objects.filter(reporter__isnull=True), ['<Article: First>', '<Article: Fourth>']) def test_assign_with_queryset(self): # Ensure that querysets used in reverse FK assignments are pre-evaluated # so their value isn't affected by the clearing operation in # ForeignRelatedObjectsDescriptor.__set__. Refs #19816. self.r2.article_set = [self.a2, self.a3] qs = self.r2.article_set.filter(headline="Second") self.r2.article_set = qs self.assertEqual(1, self.r2.article_set.count()) self.assertEqual(1, qs.count()) def test_add_efficiency(self): r = Reporter.objects.create() articles = [] for _ in range(3): articles.append(Article.objects.create()) with self.assertNumQueries(1): r.article_set.add(*articles) self.assertEqual(r.article_set.count(), 3) def test_clear_efficiency(self): r = Reporter.objects.create() for _ in range(3): r.article_set.create() with self.assertNumQueries(1): r.article_set.clear() self.assertEqual(r.article_set.count(), 0) def test_related_null_to_field(self): c1 = Car.objects.create() d1 = Driver.objects.create() self.assertIs(d1.car, None) with self.assertNumQueries(0): self.assertEqual(list(c1.drivers.all()), [])
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 8281, 12, 14243, 12, 19447, 12, 23786, 421, 199, 533, 15517, 10939, 8849, 2925, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 327, 2790, 282, 23786, 14, 267, 291, 14, 82, 275, 23786, 8, 354, 534, 12923, 25924, 358, 267, 291, 14, 82, 14, 2117, 342, 267, 327, 2790, 376, 8281, 14, 267, 291, 14, 65, 275, 8281, 8, 11268, 628, 7147, 401, 17663, 29, 277, 14, 82, 9, 267, 291, 14, 65, 14, 2117, 342, 267, 327, 2790, 376, 8281, 4799, 314, 23786, 909, 14, 267, 291, 14, 65, 18, 275, 291, 14, 82, 14, 6934, 63, 409, 14, 981, 8, 11268, 628, 11906, 531, 267, 327, 2790, 376, 8281, 543, 949, 23786, 701, 9476, 298, 12222, 29, 403, 1674, 267, 291, 14, 65, 19, 275, 8281, 8, 11268, 628, 28611, 401, 17663, 29, 403, 9, 267, 291, 14, 65, 19, 14, 2117, 342, 267, 327, 2790, 4573, 9772, 436, 17663, 267, 291, 14, 82, 18, 275, 23786, 8, 354, 534, 28282, 1603, 4548, 358, 267, 291, 14, 82, 18, 14, 2117, 342, 267, 291, 14, 65, 20, 275, 291, 14, 82, 18, 14, 6934, 63, 409, 14, 981, 8, 11268, 534, 24766, 273, 358, 339, 347, 511, 63, 362, 63, 2407, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 65, 14, 12222, 14, 344, 12, 291, 14, 82, 14, 344, 9, 267, 327, 8281, 2251, 1172, 2879, 370, 3932, 4048, 23786, 2251, 14, 267, 519, 275, 291, 14, 65, 14, 12222, 267, 291, 14, 629, 8, 82, 14, 344, 12, 291, 14, 82, 14, 344, 9, 339, 347, 511, 63, 3966, 63, 12897, 63, 2407, 63, 409, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 65, 18, 14, 12222, 14, 344, 12, 291, 14, 82, 14, 344, 9, 339, 347, 511, 63, 2407, 63, 409, 8, 277, 304, 267, 327, 23786, 2251, 1172, 2879, 370, 3932, 4048, 8281, 2251, 14, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 452, 1062, 639, 12329, 7221, 26, 7758, 4206, 2650, 7221, 26, 16707, 24782, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 1541, 8, 11268, 363, 2460, 534, 28692, 659, 639, 12329, 7221, 26, 7758, 24782, 267, 291, 14, 629, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 835, 1062, 499, 9, 339, 347, 511, 63, 3966, 63, 7395, 63, 2407, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 65, 19, 14, 12222, 12, 488, 9, 267, 327, 14012, 370, 295, 362, 282, 19, 370, 9236, 314, 2581, 267, 282, 19, 275, 8281, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 65, 19, 14, 2051, 9, 267, 291, 14, 1855, 8, 10227, 12, 2519, 12, 282, 19, 14, 12222, 12, 283, 344, 358, 267, 327, 11003, 316, 376, 9772, 1159, 283, 12222, 7, 2225, 2529, 488, 267, 327, 340, 314, 17663, 365, 663, 370, 488, 14, 267, 291, 14, 629, 8, 65, 19, 14, 12222, 12, 488, 9, 267, 327, 4005, 8044, 314, 23242, 543, 949, 1833, 27568, 663, 12, 675, 298, 12222, 363, 15114, 29, 549, 1674, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 12222, 363, 15114, 29, 549, 395, 639, 12329, 7221, 26, 31079, 24782, 267, 327, 2136, 883, 32194, 314, 2011, 8377, 701, 14545, 367, 314, 1930, 2382, 314, 267, 327, 17663, 365, 488, 14, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 12222, 29, 403, 395, 639, 12329, 7221, 26, 31079, 24782, 267, 327, 2494, 314, 17663, 367, 314, 31079, 9772, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 452, 1062, 288, 12329, 7221, 26, 7758, 4206, 2650, 7221, 26, 16707, 24782, 267, 291, 14, 82, 14, 6934, 63, 409, 14, 525, 8, 65, 19, 9, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 452, 1062, 288, 12329, 7221, 26, 7758, 4206, 2650, 7221, 26, 16707, 4206, 2650, 7221, 26, 31079, 24782, 267, 327, 5852, 376, 9772, 687, 314, 663, 12, 436, 1104, 626, 652, 1990, 4829, 14, 267, 291, 14, 82, 14, 6934, 63, 409, 14, 2168, 8, 65, 19, 9, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 452, 1062, 639, 12329, 7221, 26, 7758, 4206, 2650, 7221, 26, 16707, 24782, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 12222, 363, 15114, 29, 549, 395, 639, 12329, 7221, 26, 31079, 24782, 339, 347, 511, 63, 2168, 63, 504, 63, 10603, 63, 409, 8, 277, 304, 267, 291, 14, 7108, 8, 277, 14, 82, 18, 14, 6934, 63, 409, 14, 452, 1062, 12329, 7221, 26, 23843, 273, 24782, 267, 327, 7649, 370, 2813, 282, 20, 687, 282, 663, 652, 1630, 440, 13511, 370, 267, 291, 14, 1855, 8, 15891, 14, 7400, 12, 291, 14, 82, 14, 6934, 63, 409, 14, 2168, 12, 291, 14, 65, 20, 9, 267, 291, 14, 7108, 8, 277, 14, 82, 18, 14, 6934, 63, 409, 14, 452, 1062, 12329, 7221, 26, 23843, 273, 24782, 339, 347, 511, 63, 409, 8, 277, 304, 267, 327, 3645, 5256, 14, 409, 342, 370, 18310, 12718, 14, 12119, 365, 18393, 12, 880, 3411, 267, 327, 7556, 402, 314, 663, 626, 787, 440, 315, 314, 9801, 663, 787, 663, 370, 2973, 14, 267, 291, 14, 82, 18, 14, 6934, 63, 409, 14, 409, 779, 277, 14, 65, 18, 12, 291, 14, 65, 19, 566, 267, 291, 14, 7108, 8, 277, 14, 82, 18, 14, 6934, 63, 409, 14, 452, 1062, 639, 12329, 7221, 26, 16707, 4206, 2650, 7221, 26, 31079, 24782, 267, 327, 3645, 5256, 14, 409, 8, 3584, 29, 549, 9, 267, 291, 14, 82, 18, 14, 6934, 63, 409, 14, 409, 779, 277, 14, 65, 19, 12, 291, 14, 65, 20, 467, 5436, 29, 549, 9, 267, 291, 14, 7108, 8, 277, 14, 82, 18, 14, 6934, 63, 409, 14, 452, 1062, 639, 12329, 7221, 26, 23843, 273, 4206, 2650, 7221, 26, 31079, 24782, 267, 327, 14836, 314, 4618, 402, 314 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 8281, 12, 14243, 12, 19447, 12, 23786, 421, 199, 533, 15517, 10939, 8849, 2925, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 327, 2790, 282, 23786, 14, 267, 291, 14, 82, 275, 23786, 8, 354, 534, 12923, 25924, 358, 267, 291, 14, 82, 14, 2117, 342, 267, 327, 2790, 376, 8281, 14, 267, 291, 14, 65, 275, 8281, 8, 11268, 628, 7147, 401, 17663, 29, 277, 14, 82, 9, 267, 291, 14, 65, 14, 2117, 342, 267, 327, 2790, 376, 8281, 4799, 314, 23786, 909, 14, 267, 291, 14, 65, 18, 275, 291, 14, 82, 14, 6934, 63, 409, 14, 981, 8, 11268, 628, 11906, 531, 267, 327, 2790, 376, 8281, 543, 949, 23786, 701, 9476, 298, 12222, 29, 403, 1674, 267, 291, 14, 65, 19, 275, 8281, 8, 11268, 628, 28611, 401, 17663, 29, 403, 9, 267, 291, 14, 65, 19, 14, 2117, 342, 267, 327, 2790, 4573, 9772, 436, 17663, 267, 291, 14, 82, 18, 275, 23786, 8, 354, 534, 28282, 1603, 4548, 358, 267, 291, 14, 82, 18, 14, 2117, 342, 267, 291, 14, 65, 20, 275, 291, 14, 82, 18, 14, 6934, 63, 409, 14, 981, 8, 11268, 534, 24766, 273, 358, 339, 347, 511, 63, 362, 63, 2407, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 65, 14, 12222, 14, 344, 12, 291, 14, 82, 14, 344, 9, 267, 327, 8281, 2251, 1172, 2879, 370, 3932, 4048, 23786, 2251, 14, 267, 519, 275, 291, 14, 65, 14, 12222, 267, 291, 14, 629, 8, 82, 14, 344, 12, 291, 14, 82, 14, 344, 9, 339, 347, 511, 63, 3966, 63, 12897, 63, 2407, 63, 409, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 65, 18, 14, 12222, 14, 344, 12, 291, 14, 82, 14, 344, 9, 339, 347, 511, 63, 2407, 63, 409, 8, 277, 304, 267, 327, 23786, 2251, 1172, 2879, 370, 3932, 4048, 8281, 2251, 14, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 452, 1062, 639, 12329, 7221, 26, 7758, 4206, 2650, 7221, 26, 16707, 24782, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 1541, 8, 11268, 363, 2460, 534, 28692, 659, 639, 12329, 7221, 26, 7758, 24782, 267, 291, 14, 629, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 835, 1062, 499, 9, 339, 347, 511, 63, 3966, 63, 7395, 63, 2407, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 65, 19, 14, 12222, 12, 488, 9, 267, 327, 14012, 370, 295, 362, 282, 19, 370, 9236, 314, 2581, 267, 282, 19, 275, 8281, 14, 1462, 14, 362, 8, 2051, 29, 277, 14, 65, 19, 14, 2051, 9, 267, 291, 14, 1855, 8, 10227, 12, 2519, 12, 282, 19, 14, 12222, 12, 283, 344, 358, 267, 327, 11003, 316, 376, 9772, 1159, 283, 12222, 7, 2225, 2529, 488, 267, 327, 340, 314, 17663, 365, 663, 370, 488, 14, 267, 291, 14, 629, 8, 65, 19, 14, 12222, 12, 488, 9, 267, 327, 4005, 8044, 314, 23242, 543, 949, 1833, 27568, 663, 12, 675, 298, 12222, 363, 15114, 29, 549, 1674, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 12222, 363, 15114, 29, 549, 395, 639, 12329, 7221, 26, 31079, 24782, 267, 327, 2136, 883, 32194, 314, 2011, 8377, 701, 14545, 367, 314, 1930, 2382, 314, 267, 327, 17663, 365, 488, 14, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 12222, 29, 403, 395, 639, 12329, 7221, 26, 31079, 24782, 267, 327, 2494, 314, 17663, 367, 314, 31079, 9772, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 452, 1062, 288, 12329, 7221, 26, 7758, 4206, 2650, 7221, 26, 16707, 24782, 267, 291, 14, 82, 14, 6934, 63, 409, 14, 525, 8, 65, 19, 9, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 452, 1062, 288, 12329, 7221, 26, 7758, 4206, 2650, 7221, 26, 16707, 4206, 2650, 7221, 26, 31079, 24782, 267, 327, 5852, 376, 9772, 687, 314, 663, 12, 436, 1104, 626, 652, 1990, 4829, 14, 267, 291, 14, 82, 14, 6934, 63, 409, 14, 2168, 8, 65, 19, 9, 267, 291, 14, 7108, 8, 277, 14, 82, 14, 6934, 63, 409, 14, 452, 1062, 639, 12329, 7221, 26, 7758, 4206, 2650, 7221, 26, 16707, 24782, 267, 291, 14, 7108, 8, 7221, 14, 1462, 14, 1541, 8, 12222, 363, 15114, 29, 549, 395, 639, 12329, 7221, 26, 31079, 24782, 339, 347, 511, 63, 2168, 63, 504, 63, 10603, 63, 409, 8, 277, 304, 267, 291, 14, 7108, 8, 277, 14, 82, 18, 14, 6934, 63, 409, 14, 452, 1062, 12329, 7221, 26, 23843, 273, 24782, 267, 327, 7649, 370, 2813, 282, 20, 687, 282, 663, 652, 1630, 440, 13511, 370, 267, 291, 14, 1855, 8, 15891, 14, 7400, 12, 291, 14, 82, 14, 6934, 63, 409, 14, 2168, 12, 291, 14, 65, 20, 9, 267, 291, 14, 7108, 8, 277, 14, 82, 18, 14, 6934, 63, 409, 14, 452, 1062, 12329, 7221, 26, 23843, 273, 24782, 339, 347, 511, 63, 409, 8, 277, 304, 267, 327, 3645, 5256, 14, 409, 342, 370, 18310, 12718, 14, 12119, 365, 18393, 12, 880, 3411, 267, 327, 7556, 402, 314, 663, 626, 787, 440, 315, 314, 9801, 663, 787, 663, 370, 2973, 14, 267, 291, 14, 82, 18, 14, 6934, 63, 409, 14, 409, 779, 277, 14, 65, 18, 12, 291, 14, 65, 19, 566, 267, 291, 14, 7108, 8, 277, 14, 82, 18, 14, 6934, 63, 409, 14, 452, 1062, 639, 12329, 7221, 26, 16707, 4206, 2650, 7221, 26, 31079, 24782, 267, 327, 3645, 5256, 14, 409, 8, 3584, 29, 549, 9, 267, 291, 14, 82, 18, 14, 6934, 63, 409, 14, 409, 779, 277, 14, 65, 19, 12, 291, 14, 65, 20, 467, 5436, 29, 549, 9, 267, 291, 14, 7108, 8, 277, 14, 82, 18, 14, 6934, 63, 409, 14, 452, 1062, 639, 12329, 7221, 26, 23843, 273, 4206, 2650, 7221, 26, 31079, 24782, 267, 327, 14836, 314, 4618, 402, 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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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 ]
bosstb/HaberPush
youtube_dl/extractor/sprout.py
59
1923
# coding: utf-8 from __future__ import unicode_literals from .adobepass import AdobePassIE from ..utils import ( extract_attributes, update_url_query, smuggle_url, ) class SproutIE(AdobePassIE): _VALID_URL = r'https?://(?:www\.)?sproutonline\.com/watch/(?P<id>[^/?#]+)' _TEST = { 'url': 'http://www.sproutonline.com/watch/cowboy-adventure', 'md5': '74bf14128578d1e040c3ebc82088f45f', 'info_dict': { 'id': '9dexnwtmh8_X', 'ext': 'mp4', 'title': 'A Cowboy Adventure', 'description': 'Ruff-Ruff, Tweet and Dave get to be cowboys for the day at Six Cow Corral.', 'timestamp': 1437758640, 'upload_date': '20150724', 'uploader': 'NBCU-SPROUT-NEW', } } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_component = self._search_regex( r'(?s)(<div[^>]+data-component="video"[^>]*?>)', webpage, 'video component', default=None) if video_component: options = self._parse_json(extract_attributes( video_component)['data-options'], video_id) theplatform_url = options['video'] query = { 'mbr': 'true', 'manifest': 'm3u', } if options.get('protected'): query['auth'] = self._extract_mvpd_auth(url, options['pid'], 'sprout', 'sprout') theplatform_url = smuggle_url(update_url_query( theplatform_url, query), {'force_smil_url': True}) else: iframe = self._search_regex( r'(<iframe[^>]+id="sproutVideoIframe"[^>]*?>)', webpage, 'iframe') theplatform_url = extract_attributes(iframe)['src'] return self.url_result(theplatform_url, 'ThePlatform')
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 5129, 1235, 1529, 492, 437, 1117, 1235, 4986, 4332, 199, 504, 2508, 1208, 492, 334, 272, 5536, 63, 2987, 12, 272, 1678, 63, 633, 63, 1131, 12, 272, 4383, 1518, 3845, 63, 633, 12, 199, 9, 421, 199, 533, 428, 496, 337, 4332, 8, 33, 1117, 1235, 4986, 4332, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 83, 496, 337, 15178, 4537, 957, 15, 6821, 9448, 48, 28, 344, 13489, 10197, 3, 29716, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 83, 496, 337, 15178, 14, 957, 15, 6821, 15, 19969, 656, 89, 13, 350, 782, 608, 297, 267, 283, 1064, 21, 356, 283, 1342, 4361, 1079, 3933, 14992, 68, 17, 69, 11189, 67, 19, 26816, 24, 1165, 1299, 70, 2322, 70, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 25, 731, 13100, 7574, 72, 24, 63, 56, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 33, 445, 583, 656, 89, 4431, 782, 608, 297, 288, 283, 1802, 356, 283, 50, 3043, 13, 50, 3043, 12, 377, 11554, 436, 577, 811, 664, 370, 506, 512, 87, 656, 588, 367, 314, 5382, 737, 428, 1148, 445, 583, 7499, 13984, 3130, 288, 283, 3954, 356, 29235, 1138, 2010, 12021, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 13583, 1194, 297, 288, 283, 13671, 356, 283, 46, 6265, 53, 13, 51, 2514, 934, 13, 11365, 297, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 267, 3991, 63, 3173, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 10120, 83, 5130, 28, 3015, 25524, 576, 13, 3173, 628, 3722, 2, 28959, 31, 30, 3196, 288, 9248, 12, 283, 3722, 3931, 297, 849, 29, 403, 9, 267, 340, 3991, 63, 3173, 26, 288, 1511, 275, 291, 423, 1122, 63, 1001, 8, 5005, 63, 2987, 8, 355, 3991, 63, 3173, 11820, 576, 13, 1419, 995, 3991, 63, 344, 9, 288, 314, 3246, 63, 633, 275, 1511, 459, 3722, 418, 288, 1827, 275, 469, 355, 283, 887, 82, 356, 283, 2052, 297, 355, 283, 6418, 356, 283, 77, 19, 85, 297, 288, 789, 288, 340, 1511, 14, 362, 360, 6798, 735, 355, 1827, 459, 1178, 418, 275, 291, 423, 5005, 63, 12393, 8961, 63, 1178, 8, 633, 12, 1511, 459, 3150, 995, 283, 83, 496, 337, 297, 283, 83, 496, 337, 358, 288, 314, 3246, 63, 633, 275, 4383, 1518, 3845, 63, 633, 8, 873, 63, 633, 63, 1131, 8, 355, 314, 3246, 63, 633, 12, 1827, 395, 791, 3990, 63, 3300, 382, 63, 633, 356, 715, 1552, 267, 587, 26, 288, 340, 1186, 275, 291, 423, 1733, 63, 3821, 8, 355, 519, 6774, 28, 20052, 25524, 344, 628, 83, 496, 337, 9166, 41, 1943, 2, 28959, 31, 30, 3196, 355, 9248, 12, 283, 20052, 358, 288, 314, 3246, 63, 633, 275, 5536, 63, 2987, 8, 20052, 11820, 2164, 418, 398, 372, 291, 14, 633, 63, 1099, 8, 1589, 3246, 63, 633, 12, 283, 1918, 10397, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 5129, 1235, 1529, 492, 437, 1117, 1235, 4986, 4332, 199, 504, 2508, 1208, 492, 334, 272, 5536, 63, 2987, 12, 272, 1678, 63, 633, 63, 1131, 12, 272, 4383, 1518, 3845, 63, 633, 12, 199, 9, 421, 199, 533, 428, 496, 337, 4332, 8, 33, 1117, 1235, 4986, 4332, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 83, 496, 337, 15178, 4537, 957, 15, 6821, 9448, 48, 28, 344, 13489, 10197, 3, 29716, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 83, 496, 337, 15178, 14, 957, 15, 6821, 15, 19969, 656, 89, 13, 350, 782, 608, 297, 267, 283, 1064, 21, 356, 283, 1342, 4361, 1079, 3933, 14992, 68, 17, 69, 11189, 67, 19, 26816, 24, 1165, 1299, 70, 2322, 70, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 25, 731, 13100, 7574, 72, 24, 63, 56, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 33, 445, 583, 656, 89, 4431, 782, 608, 297, 288, 283, 1802, 356, 283, 50, 3043, 13, 50, 3043, 12, 377, 11554, 436, 577, 811, 664, 370, 506, 512, 87, 656, 588, 367, 314, 5382, 737, 428, 1148, 445, 583, 7499, 13984, 3130, 288, 283, 3954, 356, 29235, 1138, 2010, 12021, 12, 288, 283, 5064, 63, 602, 356, 283, 1797, 13583, 1194, 297, 288, 283, 13671, 356, 283, 46, 6265, 53, 13, 51, 2514, 934, 13, 11365, 297, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 3991, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 267, 3991, 63, 3173, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 10120, 83, 5130, 28, 3015, 25524, 576, 13, 3173, 628, 3722, 2, 28959, 31, 30, 3196, 288, 9248, 12, 283, 3722, 3931, 297, 849, 29, 403, 9, 267, 340, 3991, 63, 3173, 26, 288, 1511, 275, 291, 423, 1122, 63, 1001, 8, 5005, 63, 2987, 8, 355, 3991, 63, 3173, 11820, 576, 13, 1419, 995, 3991, 63, 344, 9, 288, 314, 3246, 63, 633, 275, 1511, 459, 3722, 418, 288, 1827, 275, 469, 355, 283, 887, 82, 356, 283, 2052, 297, 355, 283, 6418, 356, 283, 77, 19, 85, 297, 288, 789, 288, 340, 1511, 14, 362, 360, 6798, 735, 355, 1827, 459, 1178, 418, 275, 291, 423, 5005, 63, 12393, 8961, 63, 1178, 8, 633, 12, 1511, 459, 3150, 995, 283, 83, 496, 337, 297, 283, 83, 496, 337, 358, 288, 314, 3246, 63, 633, 275, 4383, 1518, 3845, 63, 633, 8, 873, 63, 633, 63, 1131, 8, 355, 314, 3246, 63, 633, 12, 1827, 395, 791, 3990, 63, 3300, 382, 63, 633, 356, 715, 1552, 267, 587, 26, 288, 340, 1186, 275, 291, 423, 1733, 63, 3821, 8, 355, 519, 6774, 28, 20052, 25524, 344, 628, 83, 496, 337, 9166, 41, 1943, 2, 28959, 31, 30, 3196, 355, 9248, 12, 283, 20052, 358, 288, 314, 3246, 63, 633, 275, 5536, 63, 2987, 8, 20052, 11820, 2164, 418, 398, 372, 291, 14, 633, 63, 1099, 8, 1589, 3246, 63, 633, 12, 283, 1918, 10397, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
MicroMagnum/MicroMagnum
src/magnum/micromagnetics/stephandler/fancy_screen_log.py
1
1782
# Copyright 2012, 2013 by the Micromagnum authors. # # This file is part of MicroMagnum. # # MicroMagnum 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. # # MicroMagnum 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 MicroMagnum. If not, see <http://www.gnu.org/licenses/>. from __future__ import print_function from magnum.solver import StepHandler import sys class FancyScreenLog(StepHandler): def __init__(self): super(FancyScreenLog, self).__init__() info = [ ("Step number..... : %i", lambda state: state.step), ("Time............ : %2.6f ns", lambda state: state.t * 1e9), ("Step size....... : %2.6f ns", lambda state: state.h * 1e9), ("<Mx>,<My>,<Mz>.. : %8.2f, %8.2f, %8.2f", lambda state: state.M.average()) ] def handle(self, state): sys.stdout.write("\033[s") # save cursor position sys.stdout.write("\033[H") # Cursor to top left corner erase_line = "\033[2K" print(erase_line + "+================================================================+") for fmt, fn in FancyScreenLog.info: print(erase_line + fmt % fn(state)) print(erase_line + "+================================================================+") sys.stdout.write("\033[u") # restore cursor position def done(self): pass
gpl-3.0
[ 3, 1898, 6029, 12, 6171, 701, 314, 27022, 19902, 453, 11462, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 27022, 22745, 1507, 14, 199, 3, 199, 3, 27022, 22745, 1507, 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, 27022, 22745, 1507, 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, 27022, 22745, 1507, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 15916, 453, 14, 11263, 492, 13382, 2461, 199, 199, 646, 984, 199, 199, 533, 481, 9844, 9616, 2445, 8, 7801, 2461, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 38, 9844, 9616, 2445, 12, 291, 2843, 826, 4533, 339, 2256, 275, 359, 489, 1689, 7801, 1329, 703, 1396, 520, 450, 73, 401, 2400, 1174, 26, 1174, 14, 2926, 395, 489, 1689, 1366, 7955, 4496, 520, 450, 18, 14, 22, 70, 700, 401, 2400, 1174, 26, 1174, 14, 84, 627, 413, 69, 25, 395, 489, 1689, 7801, 1568, 4496, 1396, 520, 450, 18, 14, 22, 70, 700, 401, 2400, 1174, 26, 1174, 14, 72, 627, 413, 69, 25, 395, 489, 1689, 28, 45, 88, 32659, 5713, 32659, 23332, 30, 703, 520, 450, 24, 14, 18, 70, 12, 450, 24, 14, 18, 70, 12, 450, 24, 14, 18, 70, 401, 2400, 1174, 26, 1174, 14, 45, 14, 8536, 1012, 272, 1622, 339, 347, 2429, 8, 277, 12, 1174, 304, 267, 984, 14, 2703, 14, 952, 4582, 8762, 59, 83, 531, 327, 3354, 3920, 3421, 267, 984, 14, 2703, 14, 952, 4582, 8762, 59, 40, 531, 327, 20385, 370, 2746, 3602, 17703, 398, 28343, 63, 604, 275, 1867, 8762, 59, 18, 43, 2, 398, 870, 8, 22087, 63, 604, 435, 7210, 5695, 21425, 267, 367, 7104, 12, 4325, 315, 481, 9844, 9616, 2445, 14, 815, 26, 288, 870, 8, 22087, 63, 604, 435, 7104, 450, 4325, 8, 929, 430, 267, 870, 8, 22087, 63, 604, 435, 7210, 5695, 21425, 398, 984, 14, 2703, 14, 952, 4582, 8762, 59, 85, 531, 327, 9066, 3920, 3421, 339, 347, 4224, 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 ]
[ 1898, 6029, 12, 6171, 701, 314, 27022, 19902, 453, 11462, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 27022, 22745, 1507, 14, 199, 3, 199, 3, 27022, 22745, 1507, 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, 27022, 22745, 1507, 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, 27022, 22745, 1507, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 15916, 453, 14, 11263, 492, 13382, 2461, 199, 199, 646, 984, 199, 199, 533, 481, 9844, 9616, 2445, 8, 7801, 2461, 304, 272, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 38, 9844, 9616, 2445, 12, 291, 2843, 826, 4533, 339, 2256, 275, 359, 489, 1689, 7801, 1329, 703, 1396, 520, 450, 73, 401, 2400, 1174, 26, 1174, 14, 2926, 395, 489, 1689, 1366, 7955, 4496, 520, 450, 18, 14, 22, 70, 700, 401, 2400, 1174, 26, 1174, 14, 84, 627, 413, 69, 25, 395, 489, 1689, 7801, 1568, 4496, 1396, 520, 450, 18, 14, 22, 70, 700, 401, 2400, 1174, 26, 1174, 14, 72, 627, 413, 69, 25, 395, 489, 1689, 28, 45, 88, 32659, 5713, 32659, 23332, 30, 703, 520, 450, 24, 14, 18, 70, 12, 450, 24, 14, 18, 70, 12, 450, 24, 14, 18, 70, 401, 2400, 1174, 26, 1174, 14, 45, 14, 8536, 1012, 272, 1622, 339, 347, 2429, 8, 277, 12, 1174, 304, 267, 984, 14, 2703, 14, 952, 4582, 8762, 59, 83, 531, 327, 3354, 3920, 3421, 267, 984, 14, 2703, 14, 952, 4582, 8762, 59, 40, 531, 327, 20385, 370, 2746, 3602, 17703, 398, 28343, 63, 604, 275, 1867, 8762, 59, 18, 43, 2, 398, 870, 8, 22087, 63, 604, 435, 7210, 5695, 21425, 267, 367, 7104, 12, 4325, 315, 481, 9844, 9616, 2445, 14, 815, 26, 288, 870, 8, 22087, 63, 604, 435, 7104, 450, 4325, 8, 929, 430, 267, 870, 8, 22087, 63, 604, 435, 7210, 5695, 21425, 398, 984, 14, 2703, 14, 952, 4582, 8762, 59, 85, 531, 327, 9066, 3920, 3421, 339, 347, 4224, 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, 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,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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 ]
colinligertwood/odoo
addons/crm/validate_email.py
462
5978
# RFC 2822 - style email validation for Python # (c) 2012 Syrus Akbary <me@syrusakbary.com> # Extended from (c) 2011 Noel Bush <noel@aitools.org> # for support of mx and user check # This code is made available to you under the GNU LGPL v3. # # This module provides a single method, valid_email_address(), # which returns True or False to indicate whether a given address # is valid according to the 'addr-spec' part of the specification # given in RFC 2822. Ideally, we would like to find this # in some other library, already thoroughly tested and well- # maintained. The standard Python library email.utils # contains a parse_addr() function, but it is not sufficient # to detect many malformed addresses. # # This implementation aims to be faithful to the RFC, with the # exception of a circular definition (see comments below), and # with the omission of the pattern components marked as "obsolete". import re import smtplib import socket try: import DNS ServerError = DNS.ServerError except: DNS = None class ServerError(Exception): pass # All we are really doing is comparing the input string to one # gigantic regular expression. But building that regexp, and # ensuring its correctness, is made much easier by assembling it # from the "tokens" defined by the RFC. Each of these tokens is # tested in the accompanying unit test file. # # The section of RFC 2822 from which each pattern component is # derived is given in an accompanying comment. # # (To make things simple, every string below is given as 'raw', # even when it's not strictly necessary. This way we don't forget # when it is necessary.) # WSP = r'[ \t]' # see 2.2.2. Structured Header Field Bodies CRLF = r'(?:\r\n)' # see 2.2.3. Long Header Fields NO_WS_CTL = r'\x01-\x08\x0b\x0c\x0f-\x1f\x7f' # see 3.2.1. Primitive Tokens QUOTED_PAIR = r'(?:\\.)' # see 3.2.2. Quoted characters FWS = r'(?:(?:' + WSP + r'*' + CRLF + r')?' + \ WSP + r'+)' # see 3.2.3. Folding white space and comments CTEXT = r'[' + NO_WS_CTL + \ r'\x21-\x27\x2a-\x5b\x5d-\x7e]' # see 3.2.3 CCONTENT = r'(?:' + CTEXT + r'|' + \ QUOTED_PAIR + r')' # see 3.2.3 (NB: The RFC includes COMMENT here # as well, but that would be circular.) COMMENT = r'\((?:' + FWS + r'?' + CCONTENT + \ r')*' + FWS + r'?\)' # see 3.2.3 CFWS = r'(?:' + FWS + r'?' + COMMENT + ')*(?:' + \ FWS + '?' + COMMENT + '|' + FWS + ')' # see 3.2.3 ATEXT = r'[\w!#$%&\'\*\+\-/=\?\^`\{\|\}~]' # see 3.2.4. Atom ATOM = CFWS + r'?' + ATEXT + r'+' + CFWS + r'?' # see 3.2.4 DOT_ATOM_TEXT = ATEXT + r'+(?:\.' + ATEXT + r'+)*' # see 3.2.4 DOT_ATOM = CFWS + r'?' + DOT_ATOM_TEXT + CFWS + r'?' # see 3.2.4 QTEXT = r'[' + NO_WS_CTL + \ r'\x21\x23-\x5b\x5d-\x7e]' # see 3.2.5. Quoted strings QCONTENT = r'(?:' + QTEXT + r'|' + \ QUOTED_PAIR + r')' # see 3.2.5 QUOTED_STRING = CFWS + r'?' + r'"(?:' + FWS + \ r'?' + QCONTENT + r')*' + FWS + \ r'?' + r'"' + CFWS + r'?' LOCAL_PART = r'(?:' + DOT_ATOM + r'|' + \ QUOTED_STRING + r')' # see 3.4.1. Addr-spec specification DTEXT = r'[' + NO_WS_CTL + r'\x21-\x5a\x5e-\x7e]' # see 3.4.1 DCONTENT = r'(?:' + DTEXT + r'|' + \ QUOTED_PAIR + r')' # see 3.4.1 DOMAIN_LITERAL = CFWS + r'?' + r'\[' + \ r'(?:' + FWS + r'?' + DCONTENT + \ r')*' + FWS + r'?\]' + CFWS + r'?' # see 3.4.1 DOMAIN = r'(?:' + DOT_ATOM + r'|' + \ DOMAIN_LITERAL + r')' # see 3.4.1 ADDR_SPEC = LOCAL_PART + r'@' + DOMAIN # see 3.4.1 # A valid address will match exactly the 3.4.1 addr-spec. VALID_ADDRESS_REGEXP = '^' + ADDR_SPEC + '$' def validate_email(email, check_mx=False,verify=False): """Indicate whether the given string is a valid email address according to the 'addr-spec' portion of RFC 2822 (see section 3.4.1). Parts of the spec that are marked obsolete are *not* included in this test, and certain arcane constructions that depend on circular definitions in the spec may not pass, but in general this should correctly identify any email address likely to be in use as of 2011.""" try: assert re.match(VALID_ADDRESS_REGEXP, email) is not None check_mx |= verify if check_mx: if not DNS: raise Exception('For check the mx records or check if the email exists you must have installed pyDNS python package') DNS.DiscoverNameServers() hostname = email[email.find('@')+1:] mx_hosts = DNS.mxlookup(hostname) for mx in mx_hosts: try: smtp = smtplib.SMTP() smtp.connect(mx[1]) if not verify: return True status, _ = smtp.helo() if status != 250: continue smtp.mail('') status, _ = smtp.rcpt(email) if status != 250: return False break except smtplib.SMTPServerDisconnected: #Server not permits verify user break except smtplib.SMTPConnectError: continue except (AssertionError, ServerError): return False return True # import sys # sys.modules[__name__],sys.modules['validate_email_module'] = validate_email,sys.modules[__name__] # from validate_email_module import *
agpl-3.0
[ 3, 7329, 7294, 1081, 446, 3449, 3031, 6411, 367, 2018, 199, 3, 334, 67, 9, 6029, 5515, 20791, 437, 7862, 695, 665, 278, 32, 1786, 20791, 1151, 66, 695, 14, 957, 30, 199, 3, 13706, 687, 334, 67, 9, 7760, 3091, 352, 699, 2084, 665, 889, 352, 32, 2781, 5998, 14, 1308, 30, 199, 3, 367, 2291, 402, 8728, 436, 922, 1104, 199, 3, 961, 1233, 365, 6326, 2808, 370, 1265, 1334, 314, 1664, 32426, 373, 19, 14, 199, 3, 199, 3, 961, 859, 6571, 282, 2849, 1083, 12, 1686, 63, 2123, 63, 1562, 1062, 199, 3, 1314, 2529, 715, 503, 756, 370, 6623, 3775, 282, 1627, 2287, 199, 3, 365, 1686, 7182, 370, 314, 283, 2697, 13, 1650, 7, 1777, 402, 314, 8929, 199, 3, 1627, 315, 7329, 7294, 1081, 14, 221, 473, 271, 1183, 12, 781, 3955, 2839, 370, 2342, 642, 199, 3, 315, 2005, 1163, 3555, 12, 2575, 294, 269, 4937, 590, 12470, 436, 5521, 13, 199, 3, 26391, 14, 221, 710, 4465, 2018, 3555, 3031, 14, 1208, 199, 3, 3509, 282, 2198, 63, 2697, 342, 805, 12, 1325, 652, 365, 440, 19258, 199, 3, 370, 9696, 5002, 24159, 7149, 14, 199, 3, 199, 3, 961, 4514, 282, 11171, 370, 506, 1433, 448, 1893, 370, 314, 7329, 12, 543, 314, 199, 3, 1919, 402, 282, 15032, 5492, 334, 3239, 6786, 5084, 395, 436, 199, 3, 543, 314, 312, 2250, 402, 314, 3851, 7323, 11584, 465, 298, 25385, 1674, 199, 199, 646, 295, 199, 646, 30475, 199, 646, 2838, 199, 199, 893, 26, 272, 492, 10237, 272, 7146, 547, 275, 10237, 14, 17692, 199, 2590, 26, 272, 10237, 275, 488, 272, 1021, 7146, 547, 8, 1726, 304, 986, 199, 3, 2900, 781, 787, 7710, 9689, 365, 20234, 314, 1324, 1059, 370, 1373, 199, 3, 486, 528, 290, 764, 5578, 3965, 14, 221, 11017, 10015, 626, 13156, 12, 436, 199, 3, 12889, 4039, 2399, 29102, 12, 365, 6326, 8298, 14905, 701, 465, 8946, 2983, 652, 199, 3, 687, 314, 298, 4504, 2, 3247, 701, 314, 7329, 14, 221, 7048, 402, 3520, 4645, 365, 199, 3, 12470, 315, 314, 23073, 4137, 511, 570, 14, 199, 3, 199, 3, 710, 3420, 402, 7329, 7294, 1081, 687, 1314, 1924, 3851, 3931, 365, 199, 3, 7131, 365, 1627, 315, 376, 23073, 3721, 14, 199, 3, 199, 3, 334, 1378, 1852, 7645, 3486, 12, 4036, 1059, 5084, 365, 1627, 465, 283, 1773, 297, 199, 3, 2755, 1380, 652, 1159, 440, 22699, 5784, 14, 221, 961, 4340, 781, 2793, 1133, 19459, 199, 3, 1380, 652, 365, 5784, 4959, 199, 3, 199, 5035, 48, 275, 519, 3894, 971, 84, 6616, 2476, 755, 327, 1937, 499, 14, 18, 14, 18, 14, 13039, 3297, 10240, 5024, 5088, 18245, 199, 35, 20190, 275, 519, 10120, 3427, 82, 60, 78, 3171, 15530, 327, 1937, 499, 14, 18, 14, 19, 14, 19944, 10240, 16424, 199, 2826, 63, 5035, 63, 23745, 275, 519, 1154, 88, 614, 2696, 88, 2036, 60, 88, 16, 66, 60, 88, 16, 67, 60, 88, 16, 70, 2696, 88, 17, 70, 60, 88, 23, 70, 7, 263, 327, 1937, 650, 14, 18, 14, 17, 14, 8538, 9191, 8767, 83, 199, 18654, 1149, 63, 28263, 275, 519, 20459, 20942, 3171, 17907, 327, 1937, 650, 14, 18, 14, 18, 14, 5843, 5731, 4110, 199, 38, 5035, 275, 519, 20459, 2229, 4881, 435, 644, 5763, 435, 519, 7, 10223, 435, 25862, 435, 519, 358, 14069, 435, 971, 288, 644, 5763, 435, 519, 6828, 3171, 27503, 327, 1937, 650, 14, 18, 14, 19, 14, 481, 13122, 10424, 4601, 436, 6786, 199, 1028, 2472, 275, 519, 7, 459, 435, 4825, 63, 5035, 63, 23745, 435, 971, 355, 519, 1154, 88, 2025, 2696, 88, 1465, 60, 88, 18, 65, 2696, 88, 21, 66, 60, 88, 21, 68, 2696, 88, 23, 69, 6616, 4519, 327, 1937, 650, 14, 18, 14, 19, 199, 35, 9663, 275, 519, 10120, 4881, 435, 445, 3876, 435, 519, 26972, 435, 971, 2151, 11364, 1149, 63, 28263, 435, 519, 358, 7, 12788, 327, 1937, 650, 14, 18, 14, 19, 334, 16170, 26, 710, 7329, 6952, 25071, 2348, 12268, 12793, 327, 465, 5521, 12, 1325, 626, 3955, 506, 15032, 4959, 199, 10973, 275, 519, 1154, 17304, 4881, 435, 481, 5035, 435, 519, 7, 14069, 435, 445, 9663, 435, 971, 490, 519, 358, 10223, 435, 481, 5035, 435, 519, 7, 8995, 3171, 9668, 327, 1937, 650, 14, 18, 14, 19, 199, 5487, 5035, 275, 519, 10120, 4881, 435, 481, 5035, 435, 519, 7, 14069, 435, 25071, 435, 283, 3342, 2229, 4881, 435, 971, 1467, 481, 5035, 435, 15539, 435, 25071, 435, 24628, 435, 481, 5035, 435, 16107, 260, 327, 1937, 650, 14, 18, 14, 19, 199, 619, 2472, 275, 519, 22123, 87, 1, 3, 22074, 6, 24908, 7590, 7896, 13, 15, 9529, 8995, 62, 25502, 12911, 6113, 93, 94, 6616, 3698, 327, 1937, 650, 14, 18, 14, 20, 14, 18840, 199, 22479, 275, 6035, 5035, 435, 519, 7, 14069, 435, 437, 3876, 435, 519, 30269, 435, 6035, 5035, 435, 519, 7, 14069, 420, 327, 1937, 650, 14, 18, 14, 20, 199, 13203, 63, 22479, 63, 3876, 275, 437, 3876, 435, 519, 6828, 15840, 3530, 435, 437, 3876, 435, 519, 6828, 3342, 7, 257, 327, 1937, 650, 14, 18, 14, 20, 199, 13203, 63, 22479, 275, 6035, 5035, 435, 519, 7, 14069, 435, 15854, 63, 22479, 63, 3876, 435, 6035, 5035, 435, 519, 7, 14069, 327, 1937, 650, 14, 18, 14, 20, 199, 49, 3876, 275, 519, 7, 459, 435, 4825, 63, 5035, 63, 23745, 435, 971, 355, 519, 1154, 88, 2025, 60, 88, 1789, 2696, 88, 21, 66, 60, 88, 21, 68, 2696, 88, 23, 69, 6616, 7861, 327, 1937, 650, 14, 18, 14, 21, 14, 5843, 5731, 3326, 199, 49, 9663, 275, 519, 10120, 4881, 435, 1413, 3876, 435, 519, 26972, 435, 971, 2151, 11364, 1149, 63, 28263, 435, 519, 358, 7, 12788, 327, 1937, 650, 14, 18, 14, 21, 199, 18654, 1149, 63, 5353, 275, 6035, 5035, 435, 519, 7, 14069, 435, 519, 4065, 2229, 4881, 435, 481, 5035, 435, 971, 1816, 519, 7, 14069, 435, 1413, 9663, 435, 519, 358, 10223, 435, 481, 5035, 435, 971, 1816, 519, 7, 14069, 435, 519, 30385, 435 ]
[ 7329, 7294, 1081, 446, 3449, 3031, 6411, 367, 2018, 199, 3, 334, 67, 9, 6029, 5515, 20791, 437, 7862, 695, 665, 278, 32, 1786, 20791, 1151, 66, 695, 14, 957, 30, 199, 3, 13706, 687, 334, 67, 9, 7760, 3091, 352, 699, 2084, 665, 889, 352, 32, 2781, 5998, 14, 1308, 30, 199, 3, 367, 2291, 402, 8728, 436, 922, 1104, 199, 3, 961, 1233, 365, 6326, 2808, 370, 1265, 1334, 314, 1664, 32426, 373, 19, 14, 199, 3, 199, 3, 961, 859, 6571, 282, 2849, 1083, 12, 1686, 63, 2123, 63, 1562, 1062, 199, 3, 1314, 2529, 715, 503, 756, 370, 6623, 3775, 282, 1627, 2287, 199, 3, 365, 1686, 7182, 370, 314, 283, 2697, 13, 1650, 7, 1777, 402, 314, 8929, 199, 3, 1627, 315, 7329, 7294, 1081, 14, 221, 473, 271, 1183, 12, 781, 3955, 2839, 370, 2342, 642, 199, 3, 315, 2005, 1163, 3555, 12, 2575, 294, 269, 4937, 590, 12470, 436, 5521, 13, 199, 3, 26391, 14, 221, 710, 4465, 2018, 3555, 3031, 14, 1208, 199, 3, 3509, 282, 2198, 63, 2697, 342, 805, 12, 1325, 652, 365, 440, 19258, 199, 3, 370, 9696, 5002, 24159, 7149, 14, 199, 3, 199, 3, 961, 4514, 282, 11171, 370, 506, 1433, 448, 1893, 370, 314, 7329, 12, 543, 314, 199, 3, 1919, 402, 282, 15032, 5492, 334, 3239, 6786, 5084, 395, 436, 199, 3, 543, 314, 312, 2250, 402, 314, 3851, 7323, 11584, 465, 298, 25385, 1674, 199, 199, 646, 295, 199, 646, 30475, 199, 646, 2838, 199, 199, 893, 26, 272, 492, 10237, 272, 7146, 547, 275, 10237, 14, 17692, 199, 2590, 26, 272, 10237, 275, 488, 272, 1021, 7146, 547, 8, 1726, 304, 986, 199, 3, 2900, 781, 787, 7710, 9689, 365, 20234, 314, 1324, 1059, 370, 1373, 199, 3, 486, 528, 290, 764, 5578, 3965, 14, 221, 11017, 10015, 626, 13156, 12, 436, 199, 3, 12889, 4039, 2399, 29102, 12, 365, 6326, 8298, 14905, 701, 465, 8946, 2983, 652, 199, 3, 687, 314, 298, 4504, 2, 3247, 701, 314, 7329, 14, 221, 7048, 402, 3520, 4645, 365, 199, 3, 12470, 315, 314, 23073, 4137, 511, 570, 14, 199, 3, 199, 3, 710, 3420, 402, 7329, 7294, 1081, 687, 1314, 1924, 3851, 3931, 365, 199, 3, 7131, 365, 1627, 315, 376, 23073, 3721, 14, 199, 3, 199, 3, 334, 1378, 1852, 7645, 3486, 12, 4036, 1059, 5084, 365, 1627, 465, 283, 1773, 297, 199, 3, 2755, 1380, 652, 1159, 440, 22699, 5784, 14, 221, 961, 4340, 781, 2793, 1133, 19459, 199, 3, 1380, 652, 365, 5784, 4959, 199, 3, 199, 5035, 48, 275, 519, 3894, 971, 84, 6616, 2476, 755, 327, 1937, 499, 14, 18, 14, 18, 14, 13039, 3297, 10240, 5024, 5088, 18245, 199, 35, 20190, 275, 519, 10120, 3427, 82, 60, 78, 3171, 15530, 327, 1937, 499, 14, 18, 14, 19, 14, 19944, 10240, 16424, 199, 2826, 63, 5035, 63, 23745, 275, 519, 1154, 88, 614, 2696, 88, 2036, 60, 88, 16, 66, 60, 88, 16, 67, 60, 88, 16, 70, 2696, 88, 17, 70, 60, 88, 23, 70, 7, 263, 327, 1937, 650, 14, 18, 14, 17, 14, 8538, 9191, 8767, 83, 199, 18654, 1149, 63, 28263, 275, 519, 20459, 20942, 3171, 17907, 327, 1937, 650, 14, 18, 14, 18, 14, 5843, 5731, 4110, 199, 38, 5035, 275, 519, 20459, 2229, 4881, 435, 644, 5763, 435, 519, 7, 10223, 435, 25862, 435, 519, 358, 14069, 435, 971, 288, 644, 5763, 435, 519, 6828, 3171, 27503, 327, 1937, 650, 14, 18, 14, 19, 14, 481, 13122, 10424, 4601, 436, 6786, 199, 1028, 2472, 275, 519, 7, 459, 435, 4825, 63, 5035, 63, 23745, 435, 971, 355, 519, 1154, 88, 2025, 2696, 88, 1465, 60, 88, 18, 65, 2696, 88, 21, 66, 60, 88, 21, 68, 2696, 88, 23, 69, 6616, 4519, 327, 1937, 650, 14, 18, 14, 19, 199, 35, 9663, 275, 519, 10120, 4881, 435, 445, 3876, 435, 519, 26972, 435, 971, 2151, 11364, 1149, 63, 28263, 435, 519, 358, 7, 12788, 327, 1937, 650, 14, 18, 14, 19, 334, 16170, 26, 710, 7329, 6952, 25071, 2348, 12268, 12793, 327, 465, 5521, 12, 1325, 626, 3955, 506, 15032, 4959, 199, 10973, 275, 519, 1154, 17304, 4881, 435, 481, 5035, 435, 519, 7, 14069, 435, 445, 9663, 435, 971, 490, 519, 358, 10223, 435, 481, 5035, 435, 519, 7, 8995, 3171, 9668, 327, 1937, 650, 14, 18, 14, 19, 199, 5487, 5035, 275, 519, 10120, 4881, 435, 481, 5035, 435, 519, 7, 14069, 435, 25071, 435, 283, 3342, 2229, 4881, 435, 971, 1467, 481, 5035, 435, 15539, 435, 25071, 435, 24628, 435, 481, 5035, 435, 16107, 260, 327, 1937, 650, 14, 18, 14, 19, 199, 619, 2472, 275, 519, 22123, 87, 1, 3, 22074, 6, 24908, 7590, 7896, 13, 15, 9529, 8995, 62, 25502, 12911, 6113, 93, 94, 6616, 3698, 327, 1937, 650, 14, 18, 14, 20, 14, 18840, 199, 22479, 275, 6035, 5035, 435, 519, 7, 14069, 435, 437, 3876, 435, 519, 30269, 435, 6035, 5035, 435, 519, 7, 14069, 420, 327, 1937, 650, 14, 18, 14, 20, 199, 13203, 63, 22479, 63, 3876, 275, 437, 3876, 435, 519, 6828, 15840, 3530, 435, 437, 3876, 435, 519, 6828, 3342, 7, 257, 327, 1937, 650, 14, 18, 14, 20, 199, 13203, 63, 22479, 275, 6035, 5035, 435, 519, 7, 14069, 435, 15854, 63, 22479, 63, 3876, 435, 6035, 5035, 435, 519, 7, 14069, 327, 1937, 650, 14, 18, 14, 20, 199, 49, 3876, 275, 519, 7, 459, 435, 4825, 63, 5035, 63, 23745, 435, 971, 355, 519, 1154, 88, 2025, 60, 88, 1789, 2696, 88, 21, 66, 60, 88, 21, 68, 2696, 88, 23, 69, 6616, 7861, 327, 1937, 650, 14, 18, 14, 21, 14, 5843, 5731, 3326, 199, 49, 9663, 275, 519, 10120, 4881, 435, 1413, 3876, 435, 519, 26972, 435, 971, 2151, 11364, 1149, 63, 28263, 435, 519, 358, 7, 12788, 327, 1937, 650, 14, 18, 14, 21, 199, 18654, 1149, 63, 5353, 275, 6035, 5035, 435, 519, 7, 14069, 435, 519, 4065, 2229, 4881, 435, 481, 5035, 435, 971, 1816, 519, 7, 14069, 435, 1413, 9663, 435, 519, 358, 10223, 435, 481, 5035, 435, 971, 1816, 519, 7, 14069, 435, 519, 30385, 435, 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,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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
loco-odoo/localizacion_co
openerp/addons/l10n_in_hr_payroll/report/report_hr_yearly_salary_detail.py
374
6855
#-*- coding:utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2011 OpenERP SA (<http://openerp.com>). All Rights Reserved # # 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 time import datetime from openerp.report import report_sxw from openerp.osv import osv class employees_yearly_salary_report(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(employees_yearly_salary_report, self).__init__(cr, uid, name, context) self.localcontext.update({ 'time': time, 'get_employee': self.get_employee, 'get_employee_detail': self.get_employee_detail, 'cal_monthly_amt': self.cal_monthly_amt, 'get_periods': self.get_periods, 'get_total': self.get_total, 'get_allow': self.get_allow, 'get_deduct': self.get_deduct, }) self.context = context def get_periods(self, form): self.mnths = [] # Get start year-month-date and end year-month-date first_year = int(form['date_from'][0:4]) last_year = int(form['date_to'][0:4]) first_month = int(form['date_from'][5:7]) last_month = int(form['date_to'][5:7]) no_months = (last_year-first_year) * 12 + last_month - first_month + 1 current_month = first_month current_year = first_year # Get name of the months from integer mnth_name = [] for count in range(0, no_months): m = datetime.date(current_year, current_month, 1).strftime('%b') mnth_name.append(m) self.mnths.append(str(current_month) + '-' + str(current_year)) if current_month == 12: current_month = 0 current_year = last_year current_month = current_month + 1 for c in range(0, (12-no_months)): mnth_name.append('') self.mnths.append('') return [mnth_name] def get_employee(self, form): return self.pool.get('hr.employee').browse(self.cr,self.uid, form.get('employee_ids', []), context=self.context) def get_employee_detail(self, form, obj): self.allow_list = [] self.deduct_list = [] self.total = 0.00 gross = False net = False payslip_lines = self.cal_monthly_amt(form, obj.id) for line in payslip_lines: for line[0] in line: if line[0][0] == "Gross": gross = line[0] elif line[0][0] == "Net": net = line[0] elif line[0][13] > 0.0 and line[0][0] != "Net": self.total += line[0][len(line[0])-1] self.allow_list.append(line[0]) elif line[0][13] < 0.0: self.total += line[0][len(line[0])-1] self.deduct_list.append(line[0]) if gross: self.allow_list.append(gross) if net: self.deduct_list.append(net) return None def cal_monthly_amt(self, form, emp_id): category_obj = self.pool.get('hr.salary.rule.category') result = [] res = [] salaries = {} self.cr.execute('''SELECT rc.code, pl.name, sum(pl.total), \ to_char(date_to,'mm-yyyy') as to_date FROM hr_payslip_line as pl \ LEFT JOIN hr_salary_rule_category AS rc on (pl.category_id = rc.id) \ LEFT JOIN hr_payslip as p on pl.slip_id = p.id \ LEFT JOIN hr_employee as emp on emp.id = p.employee_id \ WHERE p.employee_id = %s \ GROUP BY rc.parent_id, pl.sequence, pl.id, pl.category_id,pl.name,p.date_to,rc.code \ ORDER BY pl.sequence, rc.parent_id''',(emp_id,)) salary = self.cr.fetchall() for category in salary: if category[0] not in salaries: salaries.setdefault(category[0], {}) salaries[category[0]].update({category[1]: {category[3]: category[2]}}) elif category[1] not in salaries[category[0]]: salaries[category[0]].setdefault(category[1], {}) salaries[category[0]][category[1]].update({category[3]: category[2]}) else: salaries[category[0]][category[1]].update({category[3]: category[2]}) category_ids = category_obj.search(self.cr,self.uid, [], context=self.context) categories = category_obj.read(self.cr, self.uid, category_ids, ['code'], context=self.context) for code in map(lambda x: x['code'], categories): if code in salaries: res = self.salary_list(salaries[code]) result.append(res) return result def salary_list(self, salaries): cat_salary_all = [] for category_name,amount in salaries.items(): cat_salary = [] total = 0.0 cat_salary.append(category_name) for mnth in self.mnths: if mnth <> 'None': if len(mnth) != 7: mnth = '0' + str(mnth) if mnth in amount and amount[mnth]: cat_salary.append(amount[mnth]) total += amount[mnth] else: cat_salary.append(0.00) else: cat_salary.append('') cat_salary.append(total) cat_salary_all.append(cat_salary) return cat_salary_all def get_allow(self): return self.allow_list def get_deduct(self): return self.deduct_list def get_total(self): return self.total class wrapped_report_payslip(osv.AbstractModel): _name = 'report.l10n_in_hr_payroll.report_hryearlysalary' _inherit = 'report.abstract_report' _template = 'l10n_in_hr_payroll.report_hryearlysalary' _wrapped_report_class = employees_yearly_salary_report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 13, 1837, 2803, 26, 1624, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7760, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 2900, 5924, 5702, 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, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 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, 900, 199, 646, 2197, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 199, 504, 5166, 14, 4795, 492, 9506, 199, 199, 533, 9052, 18149, 63, 16785, 63, 22025, 63, 3070, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 304, 339, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 304, 267, 1613, 8, 24561, 63, 16785, 63, 22025, 63, 3070, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 9, 398, 291, 14, 17886, 14, 873, 2561, 288, 283, 521, 356, 900, 12, 288, 283, 362, 63, 10103, 356, 291, 14, 362, 63, 10103, 12, 288, 283, 362, 63, 10103, 63, 5506, 356, 291, 14, 362, 63, 10103, 63, 5506, 12, 288, 283, 915, 63, 30517, 63, 19582, 356, 291, 14, 915, 63, 30517, 63, 19582, 12, 288, 283, 362, 63, 20441, 356, 291, 14, 362, 63, 20441, 12, 288, 283, 362, 63, 2923, 356, 291, 14, 362, 63, 2923, 12, 288, 283, 362, 63, 3306, 356, 291, 14, 362, 63, 3306, 12, 288, 283, 362, 63, 770, 918, 356, 291, 14, 362, 63, 770, 918, 12, 267, 3828, 398, 291, 14, 1100, 275, 1067, 339, 347, 664, 63, 20441, 8, 277, 12, 1824, 304, 267, 291, 14, 10344, 273, 83, 275, 942, 199, 3, 755, 2372, 1343, 5361, 13, 4482, 13, 602, 436, 1284, 5361, 13, 4482, 13, 602, 267, 1642, 63, 3403, 275, 1109, 8, 964, 459, 602, 63, 504, 3488, 16, 26, 20, 566, 267, 2061, 63, 3403, 275, 1109, 8, 964, 459, 602, 63, 475, 3488, 16, 26, 20, 566, 398, 1642, 63, 4482, 275, 1109, 8, 964, 459, 602, 63, 504, 3488, 21, 26, 23, 566, 267, 2061, 63, 4482, 275, 1109, 8, 964, 459, 602, 63, 475, 3488, 21, 26, 23, 566, 267, 949, 63, 16745, 275, 334, 2019, 63, 3403, 13, 2246, 63, 3403, 9, 627, 3144, 435, 2061, 63, 4482, 446, 1642, 63, 4482, 435, 413, 267, 1453, 63, 4482, 275, 1642, 63, 4482, 267, 1453, 63, 3403, 275, 1642, 63, 3403, 199, 199, 3, 755, 2372, 536, 402, 314, 20096, 687, 3000, 267, 333, 16621, 63, 354, 275, 942, 267, 367, 2338, 315, 1425, 8, 16, 12, 949, 63, 16745, 304, 288, 333, 275, 2197, 14, 602, 8, 1818, 63, 3403, 12, 1453, 63, 4482, 12, 413, 680, 6205, 3508, 66, 358, 288, 333, 16621, 63, 354, 14, 740, 8, 77, 9, 288, 291, 14, 10344, 273, 83, 14, 740, 8, 495, 8, 1818, 63, 4482, 9, 435, 10791, 435, 620, 8, 1818, 63, 3403, 430, 288, 340, 1453, 63, 4482, 508, 3144, 26, 355, 1453, 63, 4482, 275, 378, 355, 1453, 63, 3403, 275, 2061, 63, 3403, 288, 1453, 63, 4482, 275, 1453, 63, 4482, 435, 413, 267, 367, 286, 315, 1425, 8, 16, 12, 334, 713, 13, 889, 63, 16745, 2298, 288, 333, 16621, 63, 354, 14, 740, 8355, 288, 291, 14, 10344, 273, 83, 14, 740, 8355, 267, 372, 359, 10344, 273, 63, 354, 61, 339, 347, 664, 63, 10103, 8, 277, 12, 1824, 304, 267, 372, 291, 14, 2293, 14, 362, 360, 6271, 14, 10103, 1959, 4570, 8, 277, 14, 1556, 12, 277, 14, 1535, 12, 1824, 14, 362, 360, 10103, 63, 1580, 297, 14431, 1067, 29, 277, 14, 1100, 9, 339, 347, 664, 63, 10103, 63, 5506, 8, 277, 12, 1824, 12, 1559, 304, 267, 291, 14, 3306, 63, 513, 275, 942, 267, 291, 14, 770, 918, 63, 513, 275, 942, 267, 291, 14, 2923, 275, 378, 14, 383, 267, 486, 3685, 275, 756, 267, 1851, 275, 756, 398, 691, 18909, 63, 1278, 275, 291, 14, 915, 63, 30517, 63, 19582, 8, 964, 12, 1559, 14, 344, 9, 267, 367, 1004, 315, 691, 18909, 63, 1278, 26, 288, 367, 1004, 59, 16, 61, 315, 1004, 26, 355, 340, 1004, 59, 16, 1527, 16, 61, 221, 508, 298, 39, 3685, 582, 490, 486, 3685, 275, 1004, 59, 16, 61, 355, 916, 1004, 59, 16, 1527, 16, 61, 221, 508, 298, 2480, 582, 490, 1851, 275, 1004, 59, 16, 61, 355, 916, 1004, 59, 16, 1527, 969, 61, 690, 378, 14, 16, 436, 1004, 59, 16, 1527, 16, 61, 1137, 298, 2480, 582, 490, 291, 14, 2923, 847, 1004, 59, 16, 1527, 552, 8, 604, 59, 16, 566, 13, 17, 61, 490, 291, 14, 3306, 63, 513, 14, 740, 8, 604, 59, 16, 566, 355, 916, 1004, 59, 16, 1527, 969, 61, 665, 378, 14, 16, 26, 490, 291, 14, 2923, 847, 1004, 59, 16, 1527, 552, 8, 604, 59, 16, 566, 13, 17, 61, 490, 291, 14, 770, 918, 63, 513, 14, 740, 8, 604, 59, 16, 566, 267, 340, 486, 3685, 26, 288, 291, 14, 3306, 63, 513, 14, 740, 8, 71, 3685, 9, 267, 340, 1851, 26, 288, 291, 14, 770, 918, 63, 513, 14, 740, 8, 846, 9, 267, 372, 488, 339, 347, 3213, 63, 30517, 63 ]
[ 13, 1837, 2803, 26, 1624, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7760, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 2900, 5924, 5702, 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, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 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, 900, 199, 646, 2197, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 199, 504, 5166, 14, 4795, 492, 9506, 199, 199, 533, 9052, 18149, 63, 16785, 63, 22025, 63, 3070, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 304, 339, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 304, 267, 1613, 8, 24561, 63, 16785, 63, 22025, 63, 3070, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 9, 398, 291, 14, 17886, 14, 873, 2561, 288, 283, 521, 356, 900, 12, 288, 283, 362, 63, 10103, 356, 291, 14, 362, 63, 10103, 12, 288, 283, 362, 63, 10103, 63, 5506, 356, 291, 14, 362, 63, 10103, 63, 5506, 12, 288, 283, 915, 63, 30517, 63, 19582, 356, 291, 14, 915, 63, 30517, 63, 19582, 12, 288, 283, 362, 63, 20441, 356, 291, 14, 362, 63, 20441, 12, 288, 283, 362, 63, 2923, 356, 291, 14, 362, 63, 2923, 12, 288, 283, 362, 63, 3306, 356, 291, 14, 362, 63, 3306, 12, 288, 283, 362, 63, 770, 918, 356, 291, 14, 362, 63, 770, 918, 12, 267, 3828, 398, 291, 14, 1100, 275, 1067, 339, 347, 664, 63, 20441, 8, 277, 12, 1824, 304, 267, 291, 14, 10344, 273, 83, 275, 942, 199, 3, 755, 2372, 1343, 5361, 13, 4482, 13, 602, 436, 1284, 5361, 13, 4482, 13, 602, 267, 1642, 63, 3403, 275, 1109, 8, 964, 459, 602, 63, 504, 3488, 16, 26, 20, 566, 267, 2061, 63, 3403, 275, 1109, 8, 964, 459, 602, 63, 475, 3488, 16, 26, 20, 566, 398, 1642, 63, 4482, 275, 1109, 8, 964, 459, 602, 63, 504, 3488, 21, 26, 23, 566, 267, 2061, 63, 4482, 275, 1109, 8, 964, 459, 602, 63, 475, 3488, 21, 26, 23, 566, 267, 949, 63, 16745, 275, 334, 2019, 63, 3403, 13, 2246, 63, 3403, 9, 627, 3144, 435, 2061, 63, 4482, 446, 1642, 63, 4482, 435, 413, 267, 1453, 63, 4482, 275, 1642, 63, 4482, 267, 1453, 63, 3403, 275, 1642, 63, 3403, 199, 199, 3, 755, 2372, 536, 402, 314, 20096, 687, 3000, 267, 333, 16621, 63, 354, 275, 942, 267, 367, 2338, 315, 1425, 8, 16, 12, 949, 63, 16745, 304, 288, 333, 275, 2197, 14, 602, 8, 1818, 63, 3403, 12, 1453, 63, 4482, 12, 413, 680, 6205, 3508, 66, 358, 288, 333, 16621, 63, 354, 14, 740, 8, 77, 9, 288, 291, 14, 10344, 273, 83, 14, 740, 8, 495, 8, 1818, 63, 4482, 9, 435, 10791, 435, 620, 8, 1818, 63, 3403, 430, 288, 340, 1453, 63, 4482, 508, 3144, 26, 355, 1453, 63, 4482, 275, 378, 355, 1453, 63, 3403, 275, 2061, 63, 3403, 288, 1453, 63, 4482, 275, 1453, 63, 4482, 435, 413, 267, 367, 286, 315, 1425, 8, 16, 12, 334, 713, 13, 889, 63, 16745, 2298, 288, 333, 16621, 63, 354, 14, 740, 8355, 288, 291, 14, 10344, 273, 83, 14, 740, 8355, 267, 372, 359, 10344, 273, 63, 354, 61, 339, 347, 664, 63, 10103, 8, 277, 12, 1824, 304, 267, 372, 291, 14, 2293, 14, 362, 360, 6271, 14, 10103, 1959, 4570, 8, 277, 14, 1556, 12, 277, 14, 1535, 12, 1824, 14, 362, 360, 10103, 63, 1580, 297, 14431, 1067, 29, 277, 14, 1100, 9, 339, 347, 664, 63, 10103, 63, 5506, 8, 277, 12, 1824, 12, 1559, 304, 267, 291, 14, 3306, 63, 513, 275, 942, 267, 291, 14, 770, 918, 63, 513, 275, 942, 267, 291, 14, 2923, 275, 378, 14, 383, 267, 486, 3685, 275, 756, 267, 1851, 275, 756, 398, 691, 18909, 63, 1278, 275, 291, 14, 915, 63, 30517, 63, 19582, 8, 964, 12, 1559, 14, 344, 9, 267, 367, 1004, 315, 691, 18909, 63, 1278, 26, 288, 367, 1004, 59, 16, 61, 315, 1004, 26, 355, 340, 1004, 59, 16, 1527, 16, 61, 221, 508, 298, 39, 3685, 582, 490, 486, 3685, 275, 1004, 59, 16, 61, 355, 916, 1004, 59, 16, 1527, 16, 61, 221, 508, 298, 2480, 582, 490, 1851, 275, 1004, 59, 16, 61, 355, 916, 1004, 59, 16, 1527, 969, 61, 690, 378, 14, 16, 436, 1004, 59, 16, 1527, 16, 61, 1137, 298, 2480, 582, 490, 291, 14, 2923, 847, 1004, 59, 16, 1527, 552, 8, 604, 59, 16, 566, 13, 17, 61, 490, 291, 14, 3306, 63, 513, 14, 740, 8, 604, 59, 16, 566, 355, 916, 1004, 59, 16, 1527, 969, 61, 665, 378, 14, 16, 26, 490, 291, 14, 2923, 847, 1004, 59, 16, 1527, 552, 8, 604, 59, 16, 566, 13, 17, 61, 490, 291, 14, 770, 918, 63, 513, 14, 740, 8, 604, 59, 16, 566, 267, 340, 486, 3685, 26, 288, 291, 14, 3306, 63, 513, 14, 740, 8, 71, 3685, 9, 267, 340, 1851, 26, 288, 291, 14, 770, 918, 63, 513, 14, 740, 8, 846, 9, 267, 372, 488, 339, 347, 3213, 63, 30517, 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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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 ]
tectronics/arsenalsuite
cpp/lib/PyQt4/examples/mainwindows/mdi/mdi.py
14
16495
#!/usr/bin/env python ############################################################################# ## ## Copyright (C) 2010 Riverbank Computing Limited. ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ## All rights reserved. ## ## This file is part of the examples of PyQt. ## ## $QT_BEGIN_LICENSE:BSD$ ## You may use this file under the terms of the BSD license as follows: ## ## "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 Nokia Corporation and its Subsidiary(-ies) 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." ## $QT_END_LICENSE$ ## ############################################################################# # This is only needed for Python v2 but is harmless for Python v3. import sip sip.setapi('QVariant', 2) from PyQt4 import QtCore, QtGui import mdi_rc class MdiChild(QtGui.QTextEdit): sequenceNumber = 1 def __init__(self): super(MdiChild, self).__init__() self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.isUntitled = True def newFile(self): self.isUntitled = True self.curFile = "document%d.txt" % MdiChild.sequenceNumber MdiChild.sequenceNumber += 1 self.setWindowTitle(self.curFile + '[*]') self.document().contentsChanged.connect(self.documentWasModified) def loadFile(self, fileName): file = QtCore.QFile(fileName) if not file.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning(self, "MDI", "Cannot read file %s:\n%s." % (fileName, file.errorString())) return False instr = QtCore.QTextStream(file) QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) self.setPlainText(instr.readAll()) QtGui.QApplication.restoreOverrideCursor() self.setCurrentFile(fileName) self.document().contentsChanged.connect(self.documentWasModified) return True def save(self): if self.isUntitled: return self.saveAs() else: return self.saveFile(self.curFile) def saveAs(self): fileName = QtGui.QFileDialog.getSaveFileName(self, "Save As", self.curFile) if not fileName: return False return self.saveFile(fileName) def saveFile(self, fileName): file = QtCore.QFile(fileName) if not file.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning(self, "MDI", "Cannot write file %s:\n%s." % (fileName, file.errorString())) return False outstr = QtCore.QTextStream(file) QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) outstr << self.toPlainText() QtGui.QApplication.restoreOverrideCursor() self.setCurrentFile(fileName) return True def userFriendlyCurrentFile(self): return self.strippedName(self.curFile) def currentFile(self): return self.curFile def closeEvent(self, event): if self.maybeSave(): event.accept() else: event.ignore() def documentWasModified(self): self.setWindowModified(self.document().isModified()) def maybeSave(self): if self.document().isModified(): ret = QtGui.QMessageBox.warning(self, "MDI", "'%s' has been modified.\nDo you want to save your " "changes?" % self.userFriendlyCurrentFile(), QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel) if ret == QtGui.QMessageBox.Save: return self.save() elif ret == QtGui.QMessageBox.Cancel: return False return True def setCurrentFile(self, fileName): self.curFile = QtCore.QFileInfo(fileName).canonicalFilePath() self.isUntitled = False self.document().setModified(False) self.setWindowModified(False) self.setWindowTitle(self.userFriendlyCurrentFile() + "[*]") def strippedName(self, fullFileName): return QtCore.QFileInfo(fullFileName).fileName() class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.mdiArea = QtGui.QMdiArea() self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.setCentralWidget(self.mdiArea) self.mdiArea.subWindowActivated.connect(self.updateMenus) self.windowMapper = QtCore.QSignalMapper(self) self.windowMapper.mapped[QtGui.QWidget].connect(self.setActiveSubWindow) self.createActions() self.createMenus() self.createToolBars() self.createStatusBar() self.updateMenus() self.readSettings() self.setWindowTitle("MDI") self.setUnifiedTitleAndToolBarOnMac(True) def closeEvent(self, event): self.mdiArea.closeAllSubWindows() if self.mdiArea.currentSubWindow(): event.ignore() else: self.writeSettings() event.accept() def newFile(self): child = self.createMdiChild() child.newFile() child.show() def open(self): fileName = QtGui.QFileDialog.getOpenFileName(self) if fileName: existing = self.findMdiChild(fileName) if existing: self.mdiArea.setActiveSubWindow(existing) return child = self.createMdiChild() if child.loadFile(fileName): self.statusBar().showMessage("File loaded", 2000) child.show() else: child.close() def save(self): if self.activeMdiChild() and self.activeMdiChild().save(): self.statusBar().showMessage("File saved", 2000) def saveAs(self): if self.activeMdiChild() and self.activeMdiChild().saveAs(): self.statusBar().showMessage("File saved", 2000) def cut(self): if self.activeMdiChild(): self.activeMdiChild().cut() def copy(self): if self.activeMdiChild(): self.activeMdiChild().copy() def paste(self): if self.activeMdiChild(): self.activeMdiChild().paste() def about(self): QtGui.QMessageBox.about(self, "About MDI", "The <b>MDI</b> example demonstrates how to write multiple " "document interface applications using Qt.") def updateMenus(self): hasMdiChild = (self.activeMdiChild() is not None) self.saveAct.setEnabled(hasMdiChild) self.saveAsAct.setEnabled(hasMdiChild) self.pasteAct.setEnabled(hasMdiChild) self.closeAct.setEnabled(hasMdiChild) self.closeAllAct.setEnabled(hasMdiChild) self.tileAct.setEnabled(hasMdiChild) self.cascadeAct.setEnabled(hasMdiChild) self.nextAct.setEnabled(hasMdiChild) self.previousAct.setEnabled(hasMdiChild) self.separatorAct.setVisible(hasMdiChild) hasSelection = (self.activeMdiChild() is not None and self.activeMdiChild().textCursor().hasSelection()) self.cutAct.setEnabled(hasSelection) self.copyAct.setEnabled(hasSelection) def updateWindowMenu(self): self.windowMenu.clear() self.windowMenu.addAction(self.closeAct) self.windowMenu.addAction(self.closeAllAct) self.windowMenu.addSeparator() self.windowMenu.addAction(self.tileAct) self.windowMenu.addAction(self.cascadeAct) self.windowMenu.addSeparator() self.windowMenu.addAction(self.nextAct) self.windowMenu.addAction(self.previousAct) self.windowMenu.addAction(self.separatorAct) windows = self.mdiArea.subWindowList() self.separatorAct.setVisible(len(windows) != 0) for i, window in enumerate(windows): child = window.widget() text = "%d %s" % (i + 1, child.userFriendlyCurrentFile()) if i < 9: text = '&' + text action = self.windowMenu.addAction(text) action.setCheckable(True) action.setChecked(child is self.activeMdiChild()) action.triggered.connect(self.windowMapper.map) self.windowMapper.setMapping(action, window) def createMdiChild(self): child = MdiChild() self.mdiArea.addSubWindow(child) child.copyAvailable.connect(self.cutAct.setEnabled) child.copyAvailable.connect(self.copyAct.setEnabled) return child def createActions(self): self.newAct = QtGui.QAction(QtGui.QIcon(':/images/new.png'), "&New", self, shortcut=QtGui.QKeySequence.New, statusTip="Create a new file", triggered=self.newFile) self.openAct = QtGui.QAction(QtGui.QIcon(':/images/open.png'), "&Open...", self, shortcut=QtGui.QKeySequence.Open, statusTip="Open an existing file", triggered=self.open) self.saveAct = QtGui.QAction(QtGui.QIcon(':/images/save.png'), "&Save", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save the document to disk", triggered=self.save) self.saveAsAct = QtGui.QAction("Save &As...", self, shortcut=QtGui.QKeySequence.SaveAs, statusTip="Save the document under a new name", triggered=self.saveAs) self.exitAct = QtGui.QAction("E&xit", self, shortcut=QtGui.QKeySequence.Quit, statusTip="Exit the application", triggered=QtGui.qApp.closeAllWindows) self.cutAct = QtGui.QAction(QtGui.QIcon(':/images/cut.png'), "Cu&t", self, shortcut=QtGui.QKeySequence.Cut, statusTip="Cut the current selection's contents to the clipboard", triggered=self.cut) self.copyAct = QtGui.QAction(QtGui.QIcon(':/images/copy.png'), "&Copy", self, shortcut=QtGui.QKeySequence.Copy, statusTip="Copy the current selection's contents to the clipboard", triggered=self.copy) self.pasteAct = QtGui.QAction(QtGui.QIcon(':/images/paste.png'), "&Paste", self, shortcut=QtGui.QKeySequence.Paste, statusTip="Paste the clipboard's contents into the current selection", triggered=self.paste) self.closeAct = QtGui.QAction("Cl&ose", self, statusTip="Close the active window", triggered=self.mdiArea.closeActiveSubWindow) self.closeAllAct = QtGui.QAction("Close &All", self, statusTip="Close all the windows", triggered=self.mdiArea.closeAllSubWindows) self.tileAct = QtGui.QAction("&Tile", self, statusTip="Tile the windows", triggered=self.mdiArea.tileSubWindows) self.cascadeAct = QtGui.QAction("&Cascade", self, statusTip="Cascade the windows", triggered=self.mdiArea.cascadeSubWindows) self.nextAct = QtGui.QAction("Ne&xt", self, shortcut=QtGui.QKeySequence.NextChild, statusTip="Move the focus to the next window", triggered=self.mdiArea.activateNextSubWindow) self.previousAct = QtGui.QAction("Pre&vious", self, shortcut=QtGui.QKeySequence.PreviousChild, statusTip="Move the focus to the previous window", triggered=self.mdiArea.activatePreviousSubWindow) self.separatorAct = QtGui.QAction(self) self.separatorAct.setSeparator(True) self.aboutAct = QtGui.QAction("&About", self, statusTip="Show the application's About box", triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt) def createMenus(self): self.fileMenu = self.menuBar().addMenu("&File") self.fileMenu.addAction(self.newAct) self.fileMenu.addAction(self.openAct) self.fileMenu.addAction(self.saveAct) self.fileMenu.addAction(self.saveAsAct) self.fileMenu.addSeparator() action = self.fileMenu.addAction("Switch layout direction") action.triggered.connect(self.switchLayoutDirection) self.fileMenu.addAction(self.exitAct) self.editMenu = self.menuBar().addMenu("&Edit") self.editMenu.addAction(self.cutAct) self.editMenu.addAction(self.copyAct) self.editMenu.addAction(self.pasteAct) self.windowMenu = self.menuBar().addMenu("&Window") self.updateWindowMenu() self.windowMenu.aboutToShow.connect(self.updateWindowMenu) self.menuBar().addSeparator() self.helpMenu = self.menuBar().addMenu("&Help") self.helpMenu.addAction(self.aboutAct) self.helpMenu.addAction(self.aboutQtAct) def createToolBars(self): self.fileToolBar = self.addToolBar("File") self.fileToolBar.addAction(self.newAct) self.fileToolBar.addAction(self.openAct) self.fileToolBar.addAction(self.saveAct) self.editToolBar = self.addToolBar("Edit") self.editToolBar.addAction(self.cutAct) self.editToolBar.addAction(self.copyAct) self.editToolBar.addAction(self.pasteAct) def createStatusBar(self): self.statusBar().showMessage("Ready") def readSettings(self): settings = QtCore.QSettings('Trolltech', 'MDI Example') pos = settings.value('pos', QtCore.QPoint(200, 200)) size = settings.value('size', QtCore.QSize(400, 400)) self.move(pos) self.resize(size) def writeSettings(self): settings = QtCore.QSettings('Trolltech', 'MDI Example') settings.setValue('pos', self.pos()) settings.setValue('size', self.size()) def activeMdiChild(self): activeSubWindow = self.mdiArea.activeSubWindow() if activeSubWindow: return activeSubWindow.widget() return None def findMdiChild(self, fileName): canonicalFilePath = QtCore.QFileInfo(fileName).canonicalFilePath() for window in self.mdiArea.subWindowList(): if window.widget().currentFile() == canonicalFilePath: return window return None def switchLayoutDirection(self): if self.layoutDirection() == QtCore.Qt.LeftToRight: QtGui.qApp.setLayoutDirection(QtCore.Qt.RightToLeft) else: QtGui.qApp.setLayoutDirection(QtCore.Qt.LeftToRight) def setActiveSubWindow(self, window): if window: self.mdiArea.setActiveSubWindow(window) if __name__ == '__main__': import sys app = QtGui.QApplication(sys.argv) mainWin = MainWindow() mainWin.show() sys.exit(app.exec_())
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 421, 199, 31635, 199, 309, 199, 309, 1898, 334, 35, 9, 7129, 820, 4380, 9860, 27799, 23954, 14, 199, 309, 1898, 334, 35, 9, 7129, 653, 745, 4674, 11098, 436, 15, 269, 2399, 1007, 338, 328, 695, 2801, 1500, 680, 199, 309, 2900, 4481, 4644, 14, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 314, 7251, 402, 14084, 14, 199, 309, 199, 309, 2672, 19229, 63, 15947, 63, 3961, 26, 15400, 4, 199, 309, 2047, 1443, 675, 642, 570, 1334, 314, 2895, 402, 314, 6289, 4190, 465, 11924, 26, 199, 309, 199, 309, 298, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 309, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 309, 7647, 26, 199, 309, 257, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 309, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 309, 257, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 309, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 309, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 309, 258, 4084, 14, 199, 309, 257, 627, 11443, 314, 536, 402, 653, 745, 4674, 11098, 436, 2399, 4804, 338, 328, 695, 2801, 1500, 9, 6590, 199, 309, 258, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 309, 258, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 309, 258, 4983, 14, 199, 309, 199, 309, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 309, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 309, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 309, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 309, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 309, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 309, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 309, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 309, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 309, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 309, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 2122, 199, 309, 2672, 19229, 63, 3902, 63, 3961, 4, 199, 309, 199, 31635, 421, 199, 3, 961, 365, 1454, 4346, 367, 2018, 373, 18, 1325, 365, 394, 5362, 2003, 367, 2018, 373, 19, 14, 199, 646, 25342, 199, 17839, 14, 409, 1246, 360, 49, 12935, 297, 499, 9, 199, 199, 504, 14084, 20, 492, 10565, 12, 5928, 199, 199, 646, 333, 328, 63, 1195, 421, 199, 533, 603, 328, 3493, 8, 10604, 14, 49, 1872, 4685, 304, 272, 3414, 3259, 275, 413, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 45, 328, 3493, 12, 291, 2843, 826, 4533, 398, 291, 14, 17618, 8, 10901, 14, 4238, 14, 9004, 63, 5392, 3314, 4724, 9, 267, 291, 14, 374, 1358, 1213, 68, 275, 715, 339, 347, 892, 1173, 8, 277, 304, 267, 291, 14, 374, 1358, 1213, 68, 275, 715, 267, 291, 14, 895, 1173, 275, 298, 3554, 5, 68, 14, 2424, 2, 450, 603, 328, 3493, 14, 4041, 3259, 267, 603, 328, 3493, 14, 4041, 3259, 847, 413, 267, 291, 14, 30601, 8, 277, 14, 895, 1173, 435, 6730, 10, 10374, 398, 291, 14, 3554, 1252, 4407, 6970, 14, 2242, 8, 277, 14, 3554, 55, 305, 11911, 9, 339, 347, 2248, 1173, 8, 277, 12, 18305, 304, 267, 570, 275, 10565, 14, 49, 1173, 8, 15450, 9, 267, 340, 440, 570, 14, 1490, 8, 10901, 14, 49, 1173, 14, 22210, 1204, 10565, 14, 49, 1173, 14, 1872, 304, 288, 5928, 14, 30798, 14, 3764, 8, 277, 12, 298, 45, 1914, 401, 490, 298, 6612, 1586, 570, 450, 83, 3427, 78, 5, 83, 2122, 450, 334, 15450, 12, 570, 14, 705, 1558, 4059, 288, 372, 756, 398, 18885, 275, 10565, 14, 49, 1872, 3296, 8, 493, 9, 267, 5928, 14, 12757, 14, 409, 11954, 8993, 8, 10901, 14, 4238, 14, 7536, 8993, 9, 267, 291, 14, 409, 20711, 1872, 8, 21309, 14, 739, 2422, 1012, 267, 5928, 14, 12757, 14, 8011, 11954, 8993, 342, 398, 291, 14, 23222, 1173, 8, 15450, 9, 398, 291, 14, 3554, 1252, 4407, 6970, 14, 2242, 8, 277, 14, 3554, 55, 305, 11911, 9, 398, 372, 715, 339, 347, 3354, 8, 277, 304, 267, 340, 291, 14, 374, 1358, 1213, 68, 26, 288, 372, 291, 14, 2117, 2822, 342, 267, 587, 26, 288, 372, 291, 14, 2117, 1173, 8, 277, 14, 895, 1173, 9, 339, 347, 3354, 2822, 8, 277, 304, 267, 18305, 275, 5928, 14, 49, 25213, 14, 362, 8229, 7733, 8, 277, 12, 298, 8229, 3709, 401, 355, 291, 14, 895, 1173, 9, 267, 340, 440, 18305, 26, 288, 372, 756, 398, 372, 291, 14, 2117, 1173, 8, 15450, 9, 339, 347, 3354, 1173, 8, 277, 12, 18305, 304, 267, 570, 275, 10565, 14, 49, 1173, 8, 15450, 9, 398, 340, 440, 570, 14, 1490, 8, 10901, 14, 49, 1173, 14, 3534, 5903, 1204, 10565, 14, 49, 1173, 14, 1872, 304, 288, 5928, 14, 30798, 14, 3764, 8, 277, 12, 298, 45, 1914, 401, 490, 298, 6612, 2218, 570, 450, 83, 3427, 78, 5, 83, 2122, 450, 334, 15450, 12, 570, 14, 705, 1558, 4059, 288, 372, 756, 398, 24632, 275, 10565, 14, 49, 1872, 3296, 8, 493, 9, 267, 5928, 14, 12757, 14, 409, 11954, 8993, 8, 10901, 14, 4238, 14, 7536, 8993, 9, 267, 24632, 5213, 291, 14, 475, 20711, 1872, 342, 267, 5928, 14, 12757, 14, 8011, 11954, 8993, 342, 398, 291, 14, 23222, 1173, 8, 15450, 9, 267, 372, 715, 339, 347, 922, 38, 11974, 5639, 1173, 8, 277, 304, 267, 372, 291, 14, 25382, 985, 8, 277, 14, 895, 1173, 9, 339, 347, 1453, 1173, 8, 277, 304, 267 ]
[ 2647, 15, 1393, 15, 1813, 2366, 421, 199, 31635, 199, 309, 199, 309, 1898, 334, 35, 9, 7129, 820, 4380, 9860, 27799, 23954, 14, 199, 309, 1898, 334, 35, 9, 7129, 653, 745, 4674, 11098, 436, 15, 269, 2399, 1007, 338, 328, 695, 2801, 1500, 680, 199, 309, 2900, 4481, 4644, 14, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 314, 7251, 402, 14084, 14, 199, 309, 199, 309, 2672, 19229, 63, 15947, 63, 3961, 26, 15400, 4, 199, 309, 2047, 1443, 675, 642, 570, 1334, 314, 2895, 402, 314, 6289, 4190, 465, 11924, 26, 199, 309, 199, 309, 298, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 309, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 309, 7647, 26, 199, 309, 257, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 309, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 309, 257, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 309, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 199, 309, 258, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 309, 258, 4084, 14, 199, 309, 257, 627, 11443, 314, 536, 402, 653, 745, 4674, 11098, 436, 2399, 4804, 338, 328, 695, 2801, 1500, 9, 6590, 199, 309, 258, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 309, 258, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 309, 258, 4983, 14, 199, 309, 199, 309, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 309, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 309, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 309, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 309, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 309, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 309, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 309, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 309, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 309, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 309, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 2122, 199, 309, 2672, 19229, 63, 3902, 63, 3961, 4, 199, 309, 199, 31635, 421, 199, 3, 961, 365, 1454, 4346, 367, 2018, 373, 18, 1325, 365, 394, 5362, 2003, 367, 2018, 373, 19, 14, 199, 646, 25342, 199, 17839, 14, 409, 1246, 360, 49, 12935, 297, 499, 9, 199, 199, 504, 14084, 20, 492, 10565, 12, 5928, 199, 199, 646, 333, 328, 63, 1195, 421, 199, 533, 603, 328, 3493, 8, 10604, 14, 49, 1872, 4685, 304, 272, 3414, 3259, 275, 413, 339, 347, 636, 826, 721, 277, 304, 267, 1613, 8, 45, 328, 3493, 12, 291, 2843, 826, 4533, 398, 291, 14, 17618, 8, 10901, 14, 4238, 14, 9004, 63, 5392, 3314, 4724, 9, 267, 291, 14, 374, 1358, 1213, 68, 275, 715, 339, 347, 892, 1173, 8, 277, 304, 267, 291, 14, 374, 1358, 1213, 68, 275, 715, 267, 291, 14, 895, 1173, 275, 298, 3554, 5, 68, 14, 2424, 2, 450, 603, 328, 3493, 14, 4041, 3259, 267, 603, 328, 3493, 14, 4041, 3259, 847, 413, 267, 291, 14, 30601, 8, 277, 14, 895, 1173, 435, 6730, 10, 10374, 398, 291, 14, 3554, 1252, 4407, 6970, 14, 2242, 8, 277, 14, 3554, 55, 305, 11911, 9, 339, 347, 2248, 1173, 8, 277, 12, 18305, 304, 267, 570, 275, 10565, 14, 49, 1173, 8, 15450, 9, 267, 340, 440, 570, 14, 1490, 8, 10901, 14, 49, 1173, 14, 22210, 1204, 10565, 14, 49, 1173, 14, 1872, 304, 288, 5928, 14, 30798, 14, 3764, 8, 277, 12, 298, 45, 1914, 401, 490, 298, 6612, 1586, 570, 450, 83, 3427, 78, 5, 83, 2122, 450, 334, 15450, 12, 570, 14, 705, 1558, 4059, 288, 372, 756, 398, 18885, 275, 10565, 14, 49, 1872, 3296, 8, 493, 9, 267, 5928, 14, 12757, 14, 409, 11954, 8993, 8, 10901, 14, 4238, 14, 7536, 8993, 9, 267, 291, 14, 409, 20711, 1872, 8, 21309, 14, 739, 2422, 1012, 267, 5928, 14, 12757, 14, 8011, 11954, 8993, 342, 398, 291, 14, 23222, 1173, 8, 15450, 9, 398, 291, 14, 3554, 1252, 4407, 6970, 14, 2242, 8, 277, 14, 3554, 55, 305, 11911, 9, 398, 372, 715, 339, 347, 3354, 8, 277, 304, 267, 340, 291, 14, 374, 1358, 1213, 68, 26, 288, 372, 291, 14, 2117, 2822, 342, 267, 587, 26, 288, 372, 291, 14, 2117, 1173, 8, 277, 14, 895, 1173, 9, 339, 347, 3354, 2822, 8, 277, 304, 267, 18305, 275, 5928, 14, 49, 25213, 14, 362, 8229, 7733, 8, 277, 12, 298, 8229, 3709, 401, 355, 291, 14, 895, 1173, 9, 267, 340, 440, 18305, 26, 288, 372, 756, 398, 372, 291, 14, 2117, 1173, 8, 15450, 9, 339, 347, 3354, 1173, 8, 277, 12, 18305, 304, 267, 570, 275, 10565, 14, 49, 1173, 8, 15450, 9, 398, 340, 440, 570, 14, 1490, 8, 10901, 14, 49, 1173, 14, 3534, 5903, 1204, 10565, 14, 49, 1173, 14, 1872, 304, 288, 5928, 14, 30798, 14, 3764, 8, 277, 12, 298, 45, 1914, 401, 490, 298, 6612, 2218, 570, 450, 83, 3427, 78, 5, 83, 2122, 450, 334, 15450, 12, 570, 14, 705, 1558, 4059, 288, 372, 756, 398, 24632, 275, 10565, 14, 49, 1872, 3296, 8, 493, 9, 267, 5928, 14, 12757, 14, 409, 11954, 8993, 8, 10901, 14, 4238, 14, 7536, 8993, 9, 267, 24632, 5213, 291, 14, 475, 20711, 1872, 342, 267, 5928, 14, 12757, 14, 8011, 11954, 8993, 342, 398, 291, 14, 23222, 1173, 8, 15450, 9, 267, 372, 715, 339, 347, 922, 38, 11974, 5639, 1173, 8, 277, 304, 267, 372, 291, 14, 25382, 985, 8, 277, 14, 895, 1173, 9, 339, 347, 1453, 1173, 8, 277, 304, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
VinceZK/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/tool/steps/update.py
124
2342
# 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. import logging from webkitpy.tool.steps.abstractstep import AbstractStep from webkitpy.tool.steps.options import Options _log = logging.getLogger(__name__) class Update(AbstractStep): @classmethod def options(cls): return AbstractStep.options() + [ Options.non_interactive, Options.update, Options.quiet, ] def run(self, state): if not self._options.update: return _log.info("Updating working directory") self._tool.executive.run_and_throw_if_fail(self._update_command(), quiet=self._options.quiet, cwd=self._tool.scm().checkout_root) def _update_command(self): update_command = self._tool.deprecated_port().update_webkit_command(self._options.non_interactive) return update_command
bsd-3-clause
[ 3, 1898, 334, 35, 9, 7129, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 221, 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, 221, 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, 221, 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, 646, 2050, 199, 199, 504, 18007, 14, 3557, 14, 5895, 14, 6198, 2926, 492, 11836, 7801, 199, 504, 18007, 14, 3557, 14, 5895, 14, 1419, 492, 8394, 199, 199, 63, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 6162, 8, 8458, 7801, 304, 272, 768, 3744, 272, 347, 1511, 8, 1886, 304, 267, 372, 11836, 7801, 14, 1419, 342, 435, 359, 288, 8394, 14, 2865, 63, 13543, 12, 288, 8394, 14, 873, 12, 288, 8394, 14, 10243, 12, 267, 1622, 339, 347, 1255, 8, 277, 12, 1174, 304, 267, 340, 440, 291, 423, 1419, 14, 873, 26, 288, 372, 267, 485, 793, 14, 815, 480, 24993, 6449, 2082, 531, 267, 291, 423, 3557, 14, 1628, 13441, 14, 1065, 63, 460, 63, 11964, 63, 692, 63, 1633, 8, 277, 423, 873, 63, 1531, 1062, 11971, 29, 277, 423, 1419, 14, 10243, 12, 8288, 29, 277, 423, 3557, 14, 17143, 1252, 12891, 63, 1231, 9, 339, 347, 485, 873, 63, 1531, 8, 277, 304, 267, 1678, 63, 1531, 275, 291, 423, 3557, 14, 6667, 63, 719, 1252, 873, 63, 12554, 63, 1531, 8, 277, 423, 1419, 14, 2865, 63, 13543, 9, 267, 372, 1678, 63, 1531, 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 ]
[ 1898, 334, 35, 9, 7129, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 221, 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, 221, 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, 221, 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, 646, 2050, 199, 199, 504, 18007, 14, 3557, 14, 5895, 14, 6198, 2926, 492, 11836, 7801, 199, 504, 18007, 14, 3557, 14, 5895, 14, 1419, 492, 8394, 199, 199, 63, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 6162, 8, 8458, 7801, 304, 272, 768, 3744, 272, 347, 1511, 8, 1886, 304, 267, 372, 11836, 7801, 14, 1419, 342, 435, 359, 288, 8394, 14, 2865, 63, 13543, 12, 288, 8394, 14, 873, 12, 288, 8394, 14, 10243, 12, 267, 1622, 339, 347, 1255, 8, 277, 12, 1174, 304, 267, 340, 440, 291, 423, 1419, 14, 873, 26, 288, 372, 267, 485, 793, 14, 815, 480, 24993, 6449, 2082, 531, 267, 291, 423, 3557, 14, 1628, 13441, 14, 1065, 63, 460, 63, 11964, 63, 692, 63, 1633, 8, 277, 423, 873, 63, 1531, 1062, 11971, 29, 277, 423, 1419, 14, 10243, 12, 8288, 29, 277, 423, 3557, 14, 17143, 1252, 12891, 63, 1231, 9, 339, 347, 485, 873, 63, 1531, 8, 277, 304, 267, 1678, 63, 1531, 275, 291, 423, 3557, 14, 6667, 63, 719, 1252, 873, 63, 12554, 63, 1531, 8, 277, 423, 1419, 14, 2865, 63, 13543, 9, 267, 372, 1678, 63, 1531, 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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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 ]
bbockelm/htcondor
src/condor_contrib/aviary/test/setattr.py
5
2536
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2009-2011 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. # # uses Suds - https://fedorahosted.org/suds/ from suds import * from suds.client import Client from sys import exit from optparse import OptionParser from aviary.util import * # change these for other default locations and ports wsdl = 'file:/var/lib/condor/aviary/services/job/aviary-job.wsdl' types = ['BOOLEAN','EXPRESSION','FLOAT','INTEGER','STRING'] parser = build_basic_parser('Set job attributes remotely via SOAP.','http://localhost:39090/services/job/setJobAttribute') parser.add_option('--name', action="store", dest='name', help='attribute name') parser.add_option('--type', action="store", choices=(types), dest='type', help=str(types)) parser.add_option('--value', action="store", dest='value', help='attribute value') parser.add_option('--cproc', action="store", dest='cproc', help="a cluster.proc id like '1.0' or '5.3'") (opts,args) = parser.parse_args() # the joy that is optparse... if opts.name is None: print 'You must provide an attribute name' parser.print_help() exit(1) if opts.type is None: print 'You must provide an attribute type' parser.print_help() exit(1) if opts.value is None: print 'You must provide an attribute value' parser.print_help() exit(1) if opts.cproc is None: print 'You must provide a cluster.proc job id' parser.print_help() exit(1) client = create_suds_client(opts,wsdl,None) client.set_options(location=opts.url) # set up our JobID jobId = client.factory.create('ns0:JobID') jobId.job = opts.cproc # set up the Attribute aviary_attr = client.factory.create('ns0:Attribute') aviary_attr.name = opts.name aviary_attr.type = opts.type aviary_attr.value = opts.value try: print 'invoking', opts.url, 'for job', opts.cproc result = client.service.setJobAttribute(jobId, aviary_attr) except Exception, e: print "unable to access scheduler at: ", opts.url print e exit(1) if result.code != "OK": print result.code,":", result.text
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 8937, 13, 8128, 9572, 13002, 12, 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, 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, 199, 199, 3, 4440, 428, 14577, 446, 4178, 921, 28803, 24127, 14, 1308, 15, 9648, 795, 15, 199, 504, 30713, 492, 627, 199, 504, 30713, 14, 1258, 492, 6810, 199, 504, 984, 492, 4458, 199, 504, 8691, 492, 13491, 199, 504, 21661, 695, 14, 1974, 492, 627, 199, 199, 3, 1570, 3520, 367, 1163, 849, 9918, 436, 8873, 199, 21452, 275, 283, 493, 11254, 1391, 15, 773, 15, 2067, 269, 15, 7194, 695, 15, 5950, 15, 2423, 15, 7194, 695, 13, 2423, 14, 21452, 7, 199, 1313, 275, 788, 25312, 1673, 1438, 5786, 1075, 1673, 11783, 1673, 9596, 1673, 5353, 418, 199, 199, 2087, 275, 1900, 63, 4316, 63, 2087, 360, 1084, 3906, 3004, 3982, 590, 4799, 26805, 14, 1673, 1014, 921, 5967, 26, 1355, 18526, 15, 5950, 15, 2423, 15, 409, 6694, 1646, 358, 199, 2087, 14, 525, 63, 1422, 4517, 354, 297, 1595, 628, 1617, 401, 2053, 534, 354, 297, 1720, 534, 3215, 536, 358, 199, 2087, 14, 525, 63, 1422, 4517, 466, 297, 1595, 628, 1617, 401, 3415, 2687, 1313, 395, 2053, 534, 466, 297, 1720, 29, 495, 8, 1313, 430, 199, 2087, 14, 525, 63, 1422, 4517, 585, 297, 1595, 628, 1617, 401, 2053, 534, 585, 297, 1720, 534, 3215, 574, 358, 199, 2087, 14, 525, 63, 1422, 4517, 67, 4687, 297, 1595, 628, 1617, 401, 2053, 534, 67, 4687, 297, 1720, 628, 65, 4350, 14, 4687, 1305, 2839, 283, 17, 14, 16, 7, 503, 283, 21, 14, 19, 9859, 199, 8, 3291, 12, 589, 9, 275, 221, 1798, 14, 1122, 63, 589, 342, 199, 199, 3, 314, 5225, 89, 626, 365, 8691, 1396, 199, 692, 3999, 14, 354, 365, 488, 26, 199, 198, 1361, 283, 5556, 1471, 5647, 376, 2225, 536, 7, 199, 198, 2087, 14, 1361, 63, 3437, 342, 199, 198, 2224, 8, 17, 9, 199, 199, 692, 3999, 14, 466, 365, 488, 26, 199, 198, 1361, 283, 5556, 1471, 5647, 376, 2225, 730, 7, 199, 198, 2087, 14, 1361, 63, 3437, 342, 199, 198, 2224, 8, 17, 9, 199, 199, 692, 3999, 14, 585, 365, 488, 26, 199, 198, 1361, 283, 5556, 1471, 5647, 376, 2225, 574, 7, 199, 198, 2087, 14, 1361, 63, 3437, 342, 199, 198, 2224, 8, 17, 9, 199, 199, 692, 3999, 14, 67, 4687, 365, 488, 26, 199, 198, 1361, 283, 5556, 1471, 5647, 282, 4350, 14, 4687, 3906, 1305, 7, 199, 198, 2087, 14, 1361, 63, 3437, 342, 199, 198, 2224, 8, 17, 9, 199, 199, 1258, 275, 1218, 63, 9648, 795, 63, 1258, 8, 3291, 12, 21452, 12, 403, 9, 199, 1258, 14, 409, 63, 1419, 8, 1985, 29, 3291, 14, 633, 9, 199, 199, 3, 663, 1536, 4154, 15057, 998, 199, 2423, 1304, 275, 1890, 14, 3702, 14, 981, 360, 561, 16, 26, 6694, 998, 358, 199, 2423, 1304, 14, 2423, 275, 3999, 14, 67, 4687, 199, 199, 3, 663, 1536, 314, 3882, 199, 7194, 695, 63, 962, 275, 1890, 14, 3702, 14, 981, 360, 561, 16, 26, 1646, 358, 199, 7194, 695, 63, 962, 14, 354, 275, 3999, 14, 354, 199, 7194, 695, 63, 962, 14, 466, 275, 3999, 14, 466, 199, 7194, 695, 63, 962, 14, 585, 275, 3999, 14, 585, 199, 199, 893, 26, 199, 198, 1361, 283, 5350, 17967, 297, 3999, 14, 633, 12, 283, 509, 3906, 297, 3999, 14, 67, 4687, 199, 198, 1099, 275, 1890, 14, 1364, 14, 409, 6694, 1646, 8, 2423, 1304, 12, 21661, 695, 63, 962, 9, 199, 2590, 2186, 12, 325, 26, 199, 198, 1361, 298, 17200, 370, 2879, 11899, 737, 26, 3872, 3999, 14, 633, 199, 198, 1361, 325, 199, 198, 2224, 8, 17, 9, 199, 199, 692, 754, 14, 600, 1137, 298, 3593, 582, 199, 198, 1361, 754, 14, 600, 12, 582, 401, 754, 14, 505, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 8937, 13, 8128, 9572, 13002, 12, 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, 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, 199, 199, 3, 4440, 428, 14577, 446, 4178, 921, 28803, 24127, 14, 1308, 15, 9648, 795, 15, 199, 504, 30713, 492, 627, 199, 504, 30713, 14, 1258, 492, 6810, 199, 504, 984, 492, 4458, 199, 504, 8691, 492, 13491, 199, 504, 21661, 695, 14, 1974, 492, 627, 199, 199, 3, 1570, 3520, 367, 1163, 849, 9918, 436, 8873, 199, 21452, 275, 283, 493, 11254, 1391, 15, 773, 15, 2067, 269, 15, 7194, 695, 15, 5950, 15, 2423, 15, 7194, 695, 13, 2423, 14, 21452, 7, 199, 1313, 275, 788, 25312, 1673, 1438, 5786, 1075, 1673, 11783, 1673, 9596, 1673, 5353, 418, 199, 199, 2087, 275, 1900, 63, 4316, 63, 2087, 360, 1084, 3906, 3004, 3982, 590, 4799, 26805, 14, 1673, 1014, 921, 5967, 26, 1355, 18526, 15, 5950, 15, 2423, 15, 409, 6694, 1646, 358, 199, 2087, 14, 525, 63, 1422, 4517, 354, 297, 1595, 628, 1617, 401, 2053, 534, 354, 297, 1720, 534, 3215, 536, 358, 199, 2087, 14, 525, 63, 1422, 4517, 466, 297, 1595, 628, 1617, 401, 3415, 2687, 1313, 395, 2053, 534, 466, 297, 1720, 29, 495, 8, 1313, 430, 199, 2087, 14, 525, 63, 1422, 4517, 585, 297, 1595, 628, 1617, 401, 2053, 534, 585, 297, 1720, 534, 3215, 574, 358, 199, 2087, 14, 525, 63, 1422, 4517, 67, 4687, 297, 1595, 628, 1617, 401, 2053, 534, 67, 4687, 297, 1720, 628, 65, 4350, 14, 4687, 1305, 2839, 283, 17, 14, 16, 7, 503, 283, 21, 14, 19, 9859, 199, 8, 3291, 12, 589, 9, 275, 221, 1798, 14, 1122, 63, 589, 342, 199, 199, 3, 314, 5225, 89, 626, 365, 8691, 1396, 199, 692, 3999, 14, 354, 365, 488, 26, 199, 198, 1361, 283, 5556, 1471, 5647, 376, 2225, 536, 7, 199, 198, 2087, 14, 1361, 63, 3437, 342, 199, 198, 2224, 8, 17, 9, 199, 199, 692, 3999, 14, 466, 365, 488, 26, 199, 198, 1361, 283, 5556, 1471, 5647, 376, 2225, 730, 7, 199, 198, 2087, 14, 1361, 63, 3437, 342, 199, 198, 2224, 8, 17, 9, 199, 199, 692, 3999, 14, 585, 365, 488, 26, 199, 198, 1361, 283, 5556, 1471, 5647, 376, 2225, 574, 7, 199, 198, 2087, 14, 1361, 63, 3437, 342, 199, 198, 2224, 8, 17, 9, 199, 199, 692, 3999, 14, 67, 4687, 365, 488, 26, 199, 198, 1361, 283, 5556, 1471, 5647, 282, 4350, 14, 4687, 3906, 1305, 7, 199, 198, 2087, 14, 1361, 63, 3437, 342, 199, 198, 2224, 8, 17, 9, 199, 199, 1258, 275, 1218, 63, 9648, 795, 63, 1258, 8, 3291, 12, 21452, 12, 403, 9, 199, 1258, 14, 409, 63, 1419, 8, 1985, 29, 3291, 14, 633, 9, 199, 199, 3, 663, 1536, 4154, 15057, 998, 199, 2423, 1304, 275, 1890, 14, 3702, 14, 981, 360, 561, 16, 26, 6694, 998, 358, 199, 2423, 1304, 14, 2423, 275, 3999, 14, 67, 4687, 199, 199, 3, 663, 1536, 314, 3882, 199, 7194, 695, 63, 962, 275, 1890, 14, 3702, 14, 981, 360, 561, 16, 26, 1646, 358, 199, 7194, 695, 63, 962, 14, 354, 275, 3999, 14, 354, 199, 7194, 695, 63, 962, 14, 466, 275, 3999, 14, 466, 199, 7194, 695, 63, 962, 14, 585, 275, 3999, 14, 585, 199, 199, 893, 26, 199, 198, 1361, 283, 5350, 17967, 297, 3999, 14, 633, 12, 283, 509, 3906, 297, 3999, 14, 67, 4687, 199, 198, 1099, 275, 1890, 14, 1364, 14, 409, 6694, 1646, 8, 2423, 1304, 12, 21661, 695, 63, 962, 9, 199, 2590, 2186, 12, 325, 26, 199, 198, 1361, 298, 17200, 370, 2879, 11899, 737, 26, 3872, 3999, 14, 633, 199, 198, 1361, 325, 199, 198, 2224, 8, 17, 9, 199, 199, 692, 754, 14, 600, 1137, 298, 3593, 582, 199, 198, 1361, 754, 14, 600, 12, 582, 401, 754, 14, 505, 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,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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 ]
TangXT/GreatCatMOOC
lms/djangoapps/courseware/migrations/0006_create_student_module_history.py
80
8157
# -*- 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 model 'StudentModuleHistory' db.create_table('courseware_studentmodulehistory', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('student_module', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['courseware.StudentModule'])), ('version', self.gf('django.db.models.fields.CharField')(max_length=255, db_index=True)), ('created', self.gf('django.db.models.fields.DateTimeField')(db_index=True)), ('state', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), ('grade', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), ('max_grade', self.gf('django.db.models.fields.FloatField')(null=True, blank=True)), )) db.send_create_signal('courseware', ['StudentModuleHistory']) def backwards(self, orm): # Deleting model 'StudentModuleHistory' db.delete_table('courseware_studentmodulehistory') 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'}) }, 'courseware.offlinecomputedgrade': { 'Meta': {'unique_together': "(('user', 'course_id'),)", 'object_name': 'OfflineComputedGrade'}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), 'gradeset': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'courseware.offlinecomputedgradelog': { 'Meta': {'ordering': "['-created']", 'object_name': 'OfflineComputedGradeLog'}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'nstudents': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'seconds': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'courseware.studentmodule': { 'Meta': {'unique_together': "(('student', 'module_state_key', 'course_id'),)", 'object_name': 'StudentModule'}, 'course_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), 'done': ('django.db.models.fields.CharField', [], {'default': "'na'", 'max_length': '8', 'db_index': 'True'}), 'grade': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'max_grade': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), 'module_state_key': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_column': "'module_id'", 'db_index': 'True'}), 'module_type': ('django.db.models.fields.CharField', [], {'default': "'problem'", 'max_length': '32', 'db_index': 'True'}), 'state': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'student': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}) }, 'courseware.studentmodulehistory': { 'Meta': {'object_name': 'StudentModuleHistory'}, 'created': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), 'grade': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'max_grade': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}), 'state': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'student_module': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['courseware.StudentModule']"}), 'version': ('django.db.models.fields.CharField', [], {'max_length': '255', 'db_index': 'True'}) } } complete_apps = ['courseware']
agpl-3.0
[ 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, 1402, 283, 18086, 2377, 12114, 7, 267, 1592, 14, 981, 63, 1224, 360, 17744, 63, 5500, 578, 5570, 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, 5500, 63, 578, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 17744, 14, 18086, 2377, 16607, 288, 661, 1023, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 697, 63, 1080, 29, 549, 1826, 288, 661, 929, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 4523, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 988, 63, 4523, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 17744, 297, 788, 18086, 2377, 12114, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 18086, 2377, 12114, 7, 267, 1592, 14, 1807, 63, 1224, 360, 17744, 63, 5500, 578, 5570, 358, 2378, 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 ]
[ 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, 1402, 283, 18086, 2377, 12114, 7, 267, 1592, 14, 981, 63, 1224, 360, 17744, 63, 5500, 578, 5570, 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, 5500, 63, 578, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 17744, 14, 18086, 2377, 16607, 288, 661, 1023, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 1592, 63, 1080, 29, 549, 1826, 288, 661, 3966, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 7533, 697, 63, 1080, 29, 549, 1826, 288, 661, 929, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 6254, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 4523, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 988, 63, 4523, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 13019, 7533, 2307, 29, 549, 12, 4596, 29, 549, 1826, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 17744, 297, 788, 18086, 2377, 12114, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 267, 327, 15920, 1402, 283, 18086, 2377, 12114, 7, 267, 1592, 14, 1807, 63, 1224, 360, 17744, 63, 5500, 578, 5570, 358, 2378, 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, 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,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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bitcoinclassic/bitcoinclassic
qa/rpc-tests/httpbasics.py
4
4809
#!/usr/bin/env python2 # Copyright (c) 2014-2015 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 rpc http basics # from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * try: import http.client as httplib except ImportError: import httplib try: import urllib.parse as urlparse except ImportError: import urlparse class HTTPBasicsTest (BitcoinTestFramework): def setup_nodes(self): return start_nodes(4, self.options.tmpdir) def run_test(self): ################################################# # lowlevel check for http persistent connection # ################################################# url = urlparse.urlparse(self.nodes[0].url) authpair = url.username + ':' + url.password headers = {"Authorization": "Basic " + str_to_b64str(authpair)} conn = httplib.HTTPConnection(url.hostname, url.port) conn.connect() conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert('"error":null' in out1) assert(conn.sock!=None) #according to http/1.1 connection must still be open! #send 2nd request without closing connection conn.request('POST', '/', '{"method": "getchaintips"}', headers) out2 = conn.getresponse().read() assert('"error":null' in out1) #must also response with a correct json-rpc message assert(conn.sock!=None) #according to http/1.1 connection must still be open! conn.close() #same should be if we add keep-alive because this should be the std. behaviour headers = {"Authorization": "Basic " + str_to_b64str(authpair), "Connection": "keep-alive"} conn = httplib.HTTPConnection(url.hostname, url.port) conn.connect() conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert('"error":null' in out1) assert(conn.sock!=None) #according to http/1.1 connection must still be open! #send 2nd request without closing connection conn.request('POST', '/', '{"method": "getchaintips"}', headers) out2 = conn.getresponse().read() assert('"error":null' in out1) #must also response with a correct json-rpc message assert(conn.sock!=None) #according to http/1.1 connection must still be open! conn.close() #now do the same with "Connection: close" headers = {"Authorization": "Basic " + str_to_b64str(authpair), "Connection":"close"} conn = httplib.HTTPConnection(url.hostname, url.port) conn.connect() conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert('"error":null' in out1) assert(conn.sock==None) #now the connection must be closed after the response #node1 (2nd node) is running with disabled keep-alive option urlNode1 = urlparse.urlparse(self.nodes[1].url) authpair = urlNode1.username + ':' + urlNode1.password headers = {"Authorization": "Basic " + str_to_b64str(authpair)} conn = httplib.HTTPConnection(urlNode1.hostname, urlNode1.port) conn.connect() conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert('"error":null' in out1) #node2 (third node) is running with standard keep-alive parameters which means keep-alive is on urlNode2 = urlparse.urlparse(self.nodes[2].url) authpair = urlNode2.username + ':' + urlNode2.password headers = {"Authorization": "Basic " + str_to_b64str(authpair)} conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port) conn.connect() conn.request('POST', '/', '{"method": "getbestblockhash"}', headers) out1 = conn.getresponse().read() assert('"error":null' in out1) assert(conn.sock!=None) #connection must be closed because bitcoind should use keep-alive by default # Check excessive request size conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port) conn.connect() conn.request('GET', '/' + ('x'*1000), '', headers) out1 = conn.getresponse() assert_equal(out1.status, httplib.NOT_FOUND) conn = httplib.HTTPConnection(urlNode2.hostname, urlNode2.port) conn.connect() conn.request('GET', '/' + ('x'*10000), '', headers) out1 = conn.getresponse() assert_equal(out1.status, httplib.BAD_REQUEST) if __name__ == '__main__': HTTPBasicsTest ().main ()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 1898, 334, 67, 9, 6927, 13, 7806, 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, 199, 3, 199, 3, 1379, 8985, 1455, 5678, 83, 199, 3, 199, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 627, 199, 199, 893, 26, 272, 492, 1455, 14, 1258, 465, 8809, 199, 2590, 3545, 26, 272, 492, 8809, 199, 893, 26, 272, 492, 4011, 14, 1122, 465, 7097, 199, 2590, 3545, 26, 272, 492, 7097, 199, 199, 533, 3101, 6845, 26935, 334, 4734, 9061, 26203, 304, 272, 347, 3272, 63, 2415, 8, 277, 304, 267, 372, 1343, 63, 2415, 8, 20, 12, 291, 14, 1419, 14, 8616, 9, 339, 347, 1255, 63, 396, 8, 277, 304, 398, 20286, 3, 267, 327, 6465, 1896, 1104, 367, 1455, 16149, 1950, 327, 267, 20286, 3, 267, 1166, 275, 7097, 14, 10290, 8, 277, 14, 2415, 59, 16, 1055, 633, 9, 267, 1790, 3852, 275, 1166, 14, 2473, 435, 10871, 435, 1166, 14, 2060, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 6769, 398, 2557, 275, 8809, 14, 19114, 8, 633, 14, 4269, 12, 1166, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 267, 702, 8, 1631, 14, 5096, 1111, 403, 9, 327, 645, 5422, 370, 1455, 15, 17, 14, 17, 1950, 1471, 5139, 506, 1551, 1, 398, 327, 2254, 499, 977, 1056, 1928, 11261, 1950, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 4429, 25842, 3570, 297, 2323, 9, 267, 734, 18, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 327, 7790, 2597, 1177, 543, 282, 3211, 2022, 13, 4354, 1245, 267, 702, 8, 1631, 14, 5096, 1111, 403, 9, 327, 645, 5422, 370, 1455, 15, 17, 14, 17, 1950, 1471, 5139, 506, 1551, 1, 267, 2557, 14, 1600, 342, 398, 327, 7191, 1077, 506, 340, 781, 1050, 4215, 13, 9631, 2952, 642, 1077, 506, 314, 2418, 14, 13942, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 395, 298, 3225, 582, 298, 3250, 13, 9631, 3570, 398, 2557, 275, 8809, 14, 19114, 8, 633, 14, 4269, 12, 1166, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 267, 702, 8, 1631, 14, 5096, 1111, 403, 9, 327, 645, 5422, 370, 1455, 15, 17, 14, 17, 1950, 1471, 5139, 506, 1551, 1, 398, 327, 2254, 499, 977, 1056, 1928, 11261, 1950, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 4429, 25842, 3570, 297, 2323, 9, 267, 734, 18, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 327, 7790, 2597, 1177, 543, 282, 3211, 2022, 13, 4354, 1245, 267, 702, 8, 1631, 14, 5096, 1111, 403, 9, 327, 645, 5422, 370, 1455, 15, 17, 14, 17, 1950, 1471, 5139, 506, 1551, 1, 267, 2557, 14, 1600, 342, 398, 327, 2131, 886, 314, 2011, 543, 298, 3225, 26, 4002, 2, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 395, 298, 3225, 5122, 1600, 3570, 398, 2557, 275, 8809, 14, 19114, 8, 633, 14, 4269, 12, 1166, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 267, 702, 8, 1631, 14, 5096, 389, 403, 9, 327, 2131, 314, 1950, 1471, 506, 6876, 2410, 314, 1177, 398, 327, 932, 17, 334, 18, 977, 1031, 9, 365, 3879, 543, 6980, 4215, 13, 9631, 945, 267, 1166, 1716, 17, 275, 7097, 14, 10290, 8, 277, 14, 2415, 59, 17, 1055, 633, 9, 267, 1790, 3852, 275, 1166, 1716, 17, 14, 2473, 435, 10871, 435, 1166, 1716, 17, 14, 2060, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 6769, 398, 2557, 275, 8809, 14, 19114, 8, 633, 1716, 17, 14, 4269, 12, 1166, 1716, 17, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 398, 327, 932, 18, 334, 11470, 1031, 9, 365, 3879, 543, 4465, 4215, 13, 9631, 2633, 1314, 4910, 4215, 13, 9631, 365, 641, 267, 1166, 1716, 18, 275, 7097, 14, 10290, 8, 277, 14, 2415, 59, 18, 1055, 633, 9, 267, 1790, 3852, 275, 1166, 1716, 18, 14, 2473, 435, 10871, 435, 1166, 1716, 18, 14, 2060, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 6769, 398, 2557, 275, 8809, 14, 19114, 8, 633, 1716, 18, 14, 4269, 12, 1166, 1716, 18, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 267, 702, 8, 1631, 14, 5096 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 1898, 334, 67, 9, 6927, 13, 7806, 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, 199, 3, 199, 3, 1379, 8985, 1455, 5678, 83, 199, 3, 199, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 627, 199, 199, 893, 26, 272, 492, 1455, 14, 1258, 465, 8809, 199, 2590, 3545, 26, 272, 492, 8809, 199, 893, 26, 272, 492, 4011, 14, 1122, 465, 7097, 199, 2590, 3545, 26, 272, 492, 7097, 199, 199, 533, 3101, 6845, 26935, 334, 4734, 9061, 26203, 304, 272, 347, 3272, 63, 2415, 8, 277, 304, 267, 372, 1343, 63, 2415, 8, 20, 12, 291, 14, 1419, 14, 8616, 9, 339, 347, 1255, 63, 396, 8, 277, 304, 398, 20286, 3, 267, 327, 6465, 1896, 1104, 367, 1455, 16149, 1950, 327, 267, 20286, 3, 267, 1166, 275, 7097, 14, 10290, 8, 277, 14, 2415, 59, 16, 1055, 633, 9, 267, 1790, 3852, 275, 1166, 14, 2473, 435, 10871, 435, 1166, 14, 2060, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 6769, 398, 2557, 275, 8809, 14, 19114, 8, 633, 14, 4269, 12, 1166, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 267, 702, 8, 1631, 14, 5096, 1111, 403, 9, 327, 645, 5422, 370, 1455, 15, 17, 14, 17, 1950, 1471, 5139, 506, 1551, 1, 398, 327, 2254, 499, 977, 1056, 1928, 11261, 1950, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 4429, 25842, 3570, 297, 2323, 9, 267, 734, 18, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 327, 7790, 2597, 1177, 543, 282, 3211, 2022, 13, 4354, 1245, 267, 702, 8, 1631, 14, 5096, 1111, 403, 9, 327, 645, 5422, 370, 1455, 15, 17, 14, 17, 1950, 1471, 5139, 506, 1551, 1, 267, 2557, 14, 1600, 342, 398, 327, 7191, 1077, 506, 340, 781, 1050, 4215, 13, 9631, 2952, 642, 1077, 506, 314, 2418, 14, 13942, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 395, 298, 3225, 582, 298, 3250, 13, 9631, 3570, 398, 2557, 275, 8809, 14, 19114, 8, 633, 14, 4269, 12, 1166, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 267, 702, 8, 1631, 14, 5096, 1111, 403, 9, 327, 645, 5422, 370, 1455, 15, 17, 14, 17, 1950, 1471, 5139, 506, 1551, 1, 398, 327, 2254, 499, 977, 1056, 1928, 11261, 1950, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 4429, 25842, 3570, 297, 2323, 9, 267, 734, 18, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 327, 7790, 2597, 1177, 543, 282, 3211, 2022, 13, 4354, 1245, 267, 702, 8, 1631, 14, 5096, 1111, 403, 9, 327, 645, 5422, 370, 1455, 15, 17, 14, 17, 1950, 1471, 5139, 506, 1551, 1, 267, 2557, 14, 1600, 342, 398, 327, 2131, 886, 314, 2011, 543, 298, 3225, 26, 4002, 2, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 395, 298, 3225, 5122, 1600, 3570, 398, 2557, 275, 8809, 14, 19114, 8, 633, 14, 4269, 12, 1166, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 267, 702, 8, 1631, 14, 5096, 389, 403, 9, 327, 2131, 314, 1950, 1471, 506, 6876, 2410, 314, 1177, 398, 327, 932, 17, 334, 18, 977, 1031, 9, 365, 3879, 543, 6980, 4215, 13, 9631, 945, 267, 1166, 1716, 17, 275, 7097, 14, 10290, 8, 277, 14, 2415, 59, 17, 1055, 633, 9, 267, 1790, 3852, 275, 1166, 1716, 17, 14, 2473, 435, 10871, 435, 1166, 1716, 17, 14, 2060, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 6769, 398, 2557, 275, 8809, 14, 19114, 8, 633, 1716, 17, 14, 4269, 12, 1166, 1716, 17, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 398, 327, 932, 18, 334, 11470, 1031, 9, 365, 3879, 543, 4465, 4215, 13, 9631, 2633, 1314, 4910, 4215, 13, 9631, 365, 641, 267, 1166, 1716, 18, 275, 7097, 14, 10290, 8, 277, 14, 2415, 59, 18, 1055, 633, 9, 267, 1790, 3852, 275, 1166, 1716, 18, 14, 2473, 435, 10871, 435, 1166, 1716, 18, 14, 2060, 267, 2323, 275, 2420, 11626, 582, 298, 6845, 298, 435, 620, 63, 475, 63, 66, 772, 495, 8, 1178, 3852, 6769, 398, 2557, 275, 8809, 14, 19114, 8, 633, 1716, 18, 14, 4269, 12, 1166, 1716, 18, 14, 719, 9, 267, 2557, 14, 2242, 342, 267, 2557, 14, 1069, 360, 4030, 297, 17220, 17137, 765, 582, 298, 362, 7010, 25848, 3570, 297, 2323, 9, 267, 734, 17, 275, 2557, 14, 25006, 1252, 739, 342, 267, 702, 14088, 705, 582, 2307, 7, 315, 734, 17, 9, 267, 702, 8, 1631, 14, 5096, 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, 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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 ]
Mj258/weiboapi
srapyDemo/envs/Lib/site-packages/pip/_vendor/_markerlib/markers.py
1769
3979
# -*- coding: utf-8 -*- """Interpret PEP 345 environment markers. EXPR [in|==|!=|not in] EXPR [or|and] ... where EXPR belongs to any of those: python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1]) python_full_version = sys.version.split()[0] os.name = os.name sys.platform = sys.platform platform.version = platform.version() platform.machine = platform.machine() platform.python_implementation = platform.python_implementation() a free string, like '2.6', or 'win32' """ __all__ = ['default_environment', 'compile', 'interpret'] import ast import os import platform import sys import weakref _builtin_compile = compile try: from platform import python_implementation except ImportError: if os.name == "java": # Jython 2.5 has ast module, but not platform.python_implementation() function. def python_implementation(): return "Jython" else: raise # restricted set of variables _VARS = {'sys.platform': sys.platform, 'python_version': '%s.%s' % sys.version_info[:2], # FIXME parsing sys.platform is not reliable, but there is no other # way to get e.g. 2.7.2+, and the PEP is defined with sys.version 'python_full_version': sys.version.split(' ', 1)[0], 'os.name': os.name, 'platform.version': platform.version(), 'platform.machine': platform.machine(), 'platform.python_implementation': python_implementation(), 'extra': None # wheel extension } for var in list(_VARS.keys()): if '.' in var: _VARS[var.replace('.', '_')] = _VARS[var] def default_environment(): """Return copy of default PEP 385 globals dictionary.""" return dict(_VARS) class ASTWhitelist(ast.NodeTransformer): def __init__(self, statement): self.statement = statement # for error messages ALLOWED = (ast.Compare, ast.BoolOp, ast.Attribute, ast.Name, ast.Load, ast.Str) # Bool operations ALLOWED += (ast.And, ast.Or) # Comparison operations ALLOWED += (ast.Eq, ast.Gt, ast.GtE, ast.In, ast.Is, ast.IsNot, ast.Lt, ast.LtE, ast.NotEq, ast.NotIn) def visit(self, node): """Ensure statement only contains allowed nodes.""" if not isinstance(node, self.ALLOWED): raise SyntaxError('Not allowed in environment markers.\n%s\n%s' % (self.statement, (' ' * node.col_offset) + '^')) return ast.NodeTransformer.visit(self, node) def visit_Attribute(self, node): """Flatten one level of attribute access.""" new_node = ast.Name("%s.%s" % (node.value.id, node.attr), node.ctx) return ast.copy_location(new_node, node) def parse_marker(marker): tree = ast.parse(marker, mode='eval') new_tree = ASTWhitelist(marker).generic_visit(tree) return new_tree def compile_marker(parsed_marker): return _builtin_compile(parsed_marker, '<environment marker>', 'eval', dont_inherit=True) _cache = weakref.WeakValueDictionary() def compile(marker): """Return compiled marker as a function accepting an environment dict.""" try: return _cache[marker] except KeyError: pass if not marker.strip(): def marker_fn(environment=None, override=None): """""" return True else: compiled_marker = compile_marker(parse_marker(marker)) def marker_fn(environment=None, override=None): """override updates environment""" if override is None: override = {} if environment is None: environment = default_environment() environment.update(override) return eval(compiled_marker, environment) marker_fn.__doc__ = marker _cache[marker] = marker_fn return _cache[marker] def interpret(marker, environment=None): return compile(marker)(environment)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2620, 25133, 13663, 30044, 3734, 14327, 14, 199, 199, 1438, 3311, 359, 262, 92, 389, 92, 1111, 92, 1397, 315, 61, 3651, 3311, 359, 269, 92, 460, 61, 2263, 199, 199, 4509, 3651, 3311, 15006, 370, 1263, 402, 5204, 26, 339, 2366, 63, 1023, 275, 1543, 83, 4111, 83, 7, 450, 334, 1274, 14, 1023, 63, 815, 59, 16, 467, 984, 14, 1023, 63, 815, 59, 17, 566, 272, 2366, 63, 2861, 63, 1023, 275, 984, 14, 1023, 14, 1294, 3430, 16, 61, 272, 747, 14, 354, 275, 747, 14, 354, 272, 984, 14, 3246, 275, 984, 14, 3246, 272, 4298, 14, 1023, 275, 4298, 14, 1023, 342, 272, 4298, 14, 6744, 275, 4298, 14, 6744, 342, 272, 4298, 14, 1548, 63, 12236, 275, 4298, 14, 1548, 63, 12236, 342, 272, 282, 2867, 1059, 12, 2839, 283, 18, 14, 22, 297, 503, 283, 2676, 708, 7, 199, 624, 199, 199, 363, 452, 363, 275, 788, 885, 63, 5418, 297, 283, 2014, 297, 283, 21533, 418, 199, 199, 646, 6073, 199, 646, 747, 199, 646, 4298, 199, 646, 984, 199, 646, 13852, 199, 199, 63, 5351, 63, 2014, 275, 6555, 199, 199, 893, 26, 272, 687, 4298, 492, 2366, 63, 12236, 199, 2590, 3545, 26, 272, 340, 747, 14, 354, 508, 298, 6138, 582, 267, 327, 25333, 499, 14, 21, 965, 6073, 859, 12, 1325, 440, 4298, 14, 1548, 63, 12236, 342, 805, 14, 267, 347, 2366, 63, 12236, 837, 288, 372, 298, 42, 11361, 2, 272, 587, 26, 267, 746, 421, 199, 3, 15297, 663, 402, 2860, 199, 63, 21367, 275, 791, 1274, 14, 3246, 356, 984, 14, 3246, 12, 268, 283, 1548, 63, 1023, 356, 1543, 83, 4111, 83, 7, 450, 984, 14, 1023, 63, 815, 1491, 18, 467, 268, 327, 7600, 6057, 984, 14, 3246, 365, 440, 32150, 12, 1325, 2337, 365, 949, 1163, 268, 327, 4340, 370, 664, 325, 14, 71, 14, 499, 14, 23, 14, 18, 28061, 436, 314, 13663, 365, 3247, 543, 984, 14, 1023, 268, 283, 1548, 63, 2861, 63, 1023, 356, 984, 14, 1023, 14, 1294, 360, 1656, 413, 2788, 16, 467, 268, 283, 736, 14, 354, 356, 747, 14, 354, 12, 268, 283, 3246, 14, 1023, 356, 4298, 14, 1023, 1062, 268, 283, 3246, 14, 6744, 356, 4298, 14, 6744, 1062, 268, 283, 3246, 14, 1548, 63, 12236, 356, 2366, 63, 12236, 1062, 268, 283, 2911, 356, 488, 327, 9989, 3329, 267, 789, 199, 199, 509, 2729, 315, 769, 1547, 21367, 14, 1612, 5109, 272, 340, 7815, 315, 2729, 26, 267, 485, 21367, 59, 1391, 14, 1814, 14078, 2513, 5440, 275, 485, 21367, 59, 1391, 61, 199, 199, 318, 849, 63, 5418, 837, 272, 408, 1767, 1331, 402, 849, 13663, 650, 2426, 7992, 2600, 1041, 272, 372, 1211, 1547, 21367, 9, 199, 199, 533, 20788, 19803, 513, 8, 1810, 14, 1716, 19761, 304, 272, 347, 636, 826, 721, 277, 12, 5164, 304, 267, 291, 14, 6242, 275, 5164, 327, 367, 1125, 3788, 339, 27805, 1149, 275, 334, 1810, 14, 16051, 12, 6073, 14, 10349, 4619, 12, 6073, 14, 1646, 12, 6073, 14, 985, 12, 6073, 14, 6200, 12, 6073, 14, 2848, 9, 272, 327, 19287, 5331, 272, 27805, 1149, 847, 334, 1810, 14, 3325, 12, 6073, 14, 2844, 9, 272, 327, 3599, 5447, 5331, 272, 27805, 1149, 847, 334, 1810, 14, 19706, 12, 6073, 14, 39, 84, 12, 6073, 14, 39, 84, 37, 12, 6073, 14, 607, 12, 6073, 14, 1831, 12, 6073, 14, 1831, 1763, 12, 6073, 14, 31252, 12, 6073, 14, 31252, 37, 12, 6073, 14, 1763, 19706, 12, 6073, 14, 1763, 607, 9, 339, 347, 5684, 8, 277, 12, 1031, 304, 267, 408, 13913, 5164, 1454, 3509, 4370, 3380, 1041, 267, 340, 440, 1228, 8, 932, 12, 291, 14, 17350, 304, 288, 746, 12053, 360, 1763, 4370, 315, 3734, 14327, 3134, 78, 5, 83, 60, 78, 5, 83, 7, 450, 3044, 334, 277, 14, 6242, 12, 3044, 661, 283, 627, 1031, 14, 761, 63, 2743, 9, 435, 14452, 1333, 267, 372, 6073, 14, 1716, 19761, 14, 5427, 8, 277, 12, 1031, 9, 339, 347, 5684, 63, 1646, 8, 277, 12, 1031, 304, 267, 408, 29302, 1373, 2166, 402, 2225, 2879, 1041, 267, 892, 63, 932, 275, 6073, 14, 985, 3647, 83, 4111, 83, 2, 450, 334, 932, 14, 585, 14, 344, 12, 1031, 14, 962, 395, 1031, 14, 3799, 9, 267, 372, 6073, 14, 1574, 63, 1985, 8, 1222, 63, 932, 12, 1031, 9, 199, 199, 318, 2198, 63, 4211, 8, 4211, 304, 272, 3123, 275, 6073, 14, 1122, 8, 4211, 12, 818, 534, 2579, 358, 272, 892, 63, 2350, 275, 20788, 19803, 513, 8, 4211, 680, 6767, 63, 5427, 8, 2350, 9, 272, 372, 892, 63, 2350, 199, 199, 318, 6555, 63, 4211, 8, 6751, 63, 4211, 304, 272, 372, 485, 5351, 63, 2014, 8, 6751, 63, 4211, 12, 2650, 5418, 3608, 4206, 283, 2579, 297, 673, 21542, 63, 6486, 29, 549, 9, 199, 199, 63, 1637, 275, 13852, 14, 18889, 1110, 11728, 342, 199, 199, 318, 6555, 8, 4211, 304, 272, 408, 1767, 10311, 3608, 465, 282, 805, 32163, 376, 3734, 1211, 1041, 272, 862, 26, 267, 372, 485, 1637, 59, 4211, 61, 272, 871, 4067, 26, 267, 986, 272, 340, 440, 3608, 14, 1913, 837, 267, 347, 3608, 63, 2324, 8, 5418, 29, 403, 12, 4278, 29, 403, 304, 288, 408, 624, 288, 372, 715, 272, 587, 26, 267, 10311, 63, 4211, 275, 6555, 63, 4211, 8, 1122, 63, 4211, 8, 4211, 430, 267, 347, 3608, 63, 2324, 8, 5418, 29, 403, 12, 4278, 29, 403, 304, 288, 408, 4415, 7029, 3734, 624, 288, 340, 4278, 365, 488, 26, 355, 4278, 275, 1052, 288, 340, 3734, 365, 488, 26, 355, 3734, 275, 849, 63, 5418, 342, 288, 3734, 14, 873, 8, 4415, 9, 288, 372, 3468, 8, 8427, 63, 4211, 12, 3734, 9, 272, 3608, 63, 2324, 855, 1301, 363, 275, 3608, 272, 485, 1637, 59, 4211, 61, 275, 3608, 63, 2324, 272, 372, 485, 1637, 59, 4211, 61, 199, 199, 318, 15579, 8, 4211, 12, 3734, 29, 403, 304, 272, 372, 6555, 8, 4211, 5130, 5418, 9, 199, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2620, 25133, 13663, 30044, 3734, 14327, 14, 199, 199, 1438, 3311, 359, 262, 92, 389, 92, 1111, 92, 1397, 315, 61, 3651, 3311, 359, 269, 92, 460, 61, 2263, 199, 199, 4509, 3651, 3311, 15006, 370, 1263, 402, 5204, 26, 339, 2366, 63, 1023, 275, 1543, 83, 4111, 83, 7, 450, 334, 1274, 14, 1023, 63, 815, 59, 16, 467, 984, 14, 1023, 63, 815, 59, 17, 566, 272, 2366, 63, 2861, 63, 1023, 275, 984, 14, 1023, 14, 1294, 3430, 16, 61, 272, 747, 14, 354, 275, 747, 14, 354, 272, 984, 14, 3246, 275, 984, 14, 3246, 272, 4298, 14, 1023, 275, 4298, 14, 1023, 342, 272, 4298, 14, 6744, 275, 4298, 14, 6744, 342, 272, 4298, 14, 1548, 63, 12236, 275, 4298, 14, 1548, 63, 12236, 342, 272, 282, 2867, 1059, 12, 2839, 283, 18, 14, 22, 297, 503, 283, 2676, 708, 7, 199, 624, 199, 199, 363, 452, 363, 275, 788, 885, 63, 5418, 297, 283, 2014, 297, 283, 21533, 418, 199, 199, 646, 6073, 199, 646, 747, 199, 646, 4298, 199, 646, 984, 199, 646, 13852, 199, 199, 63, 5351, 63, 2014, 275, 6555, 199, 199, 893, 26, 272, 687, 4298, 492, 2366, 63, 12236, 199, 2590, 3545, 26, 272, 340, 747, 14, 354, 508, 298, 6138, 582, 267, 327, 25333, 499, 14, 21, 965, 6073, 859, 12, 1325, 440, 4298, 14, 1548, 63, 12236, 342, 805, 14, 267, 347, 2366, 63, 12236, 837, 288, 372, 298, 42, 11361, 2, 272, 587, 26, 267, 746, 421, 199, 3, 15297, 663, 402, 2860, 199, 63, 21367, 275, 791, 1274, 14, 3246, 356, 984, 14, 3246, 12, 268, 283, 1548, 63, 1023, 356, 1543, 83, 4111, 83, 7, 450, 984, 14, 1023, 63, 815, 1491, 18, 467, 268, 327, 7600, 6057, 984, 14, 3246, 365, 440, 32150, 12, 1325, 2337, 365, 949, 1163, 268, 327, 4340, 370, 664, 325, 14, 71, 14, 499, 14, 23, 14, 18, 28061, 436, 314, 13663, 365, 3247, 543, 984, 14, 1023, 268, 283, 1548, 63, 2861, 63, 1023, 356, 984, 14, 1023, 14, 1294, 360, 1656, 413, 2788, 16, 467, 268, 283, 736, 14, 354, 356, 747, 14, 354, 12, 268, 283, 3246, 14, 1023, 356, 4298, 14, 1023, 1062, 268, 283, 3246, 14, 6744, 356, 4298, 14, 6744, 1062, 268, 283, 3246, 14, 1548, 63, 12236, 356, 2366, 63, 12236, 1062, 268, 283, 2911, 356, 488, 327, 9989, 3329, 267, 789, 199, 199, 509, 2729, 315, 769, 1547, 21367, 14, 1612, 5109, 272, 340, 7815, 315, 2729, 26, 267, 485, 21367, 59, 1391, 14, 1814, 14078, 2513, 5440, 275, 485, 21367, 59, 1391, 61, 199, 199, 318, 849, 63, 5418, 837, 272, 408, 1767, 1331, 402, 849, 13663, 650, 2426, 7992, 2600, 1041, 272, 372, 1211, 1547, 21367, 9, 199, 199, 533, 20788, 19803, 513, 8, 1810, 14, 1716, 19761, 304, 272, 347, 636, 826, 721, 277, 12, 5164, 304, 267, 291, 14, 6242, 275, 5164, 327, 367, 1125, 3788, 339, 27805, 1149, 275, 334, 1810, 14, 16051, 12, 6073, 14, 10349, 4619, 12, 6073, 14, 1646, 12, 6073, 14, 985, 12, 6073, 14, 6200, 12, 6073, 14, 2848, 9, 272, 327, 19287, 5331, 272, 27805, 1149, 847, 334, 1810, 14, 3325, 12, 6073, 14, 2844, 9, 272, 327, 3599, 5447, 5331, 272, 27805, 1149, 847, 334, 1810, 14, 19706, 12, 6073, 14, 39, 84, 12, 6073, 14, 39, 84, 37, 12, 6073, 14, 607, 12, 6073, 14, 1831, 12, 6073, 14, 1831, 1763, 12, 6073, 14, 31252, 12, 6073, 14, 31252, 37, 12, 6073, 14, 1763, 19706, 12, 6073, 14, 1763, 607, 9, 339, 347, 5684, 8, 277, 12, 1031, 304, 267, 408, 13913, 5164, 1454, 3509, 4370, 3380, 1041, 267, 340, 440, 1228, 8, 932, 12, 291, 14, 17350, 304, 288, 746, 12053, 360, 1763, 4370, 315, 3734, 14327, 3134, 78, 5, 83, 60, 78, 5, 83, 7, 450, 3044, 334, 277, 14, 6242, 12, 3044, 661, 283, 627, 1031, 14, 761, 63, 2743, 9, 435, 14452, 1333, 267, 372, 6073, 14, 1716, 19761, 14, 5427, 8, 277, 12, 1031, 9, 339, 347, 5684, 63, 1646, 8, 277, 12, 1031, 304, 267, 408, 29302, 1373, 2166, 402, 2225, 2879, 1041, 267, 892, 63, 932, 275, 6073, 14, 985, 3647, 83, 4111, 83, 2, 450, 334, 932, 14, 585, 14, 344, 12, 1031, 14, 962, 395, 1031, 14, 3799, 9, 267, 372, 6073, 14, 1574, 63, 1985, 8, 1222, 63, 932, 12, 1031, 9, 199, 199, 318, 2198, 63, 4211, 8, 4211, 304, 272, 3123, 275, 6073, 14, 1122, 8, 4211, 12, 818, 534, 2579, 358, 272, 892, 63, 2350, 275, 20788, 19803, 513, 8, 4211, 680, 6767, 63, 5427, 8, 2350, 9, 272, 372, 892, 63, 2350, 199, 199, 318, 6555, 63, 4211, 8, 6751, 63, 4211, 304, 272, 372, 485, 5351, 63, 2014, 8, 6751, 63, 4211, 12, 2650, 5418, 3608, 4206, 283, 2579, 297, 673, 21542, 63, 6486, 29, 549, 9, 199, 199, 63, 1637, 275, 13852, 14, 18889, 1110, 11728, 342, 199, 199, 318, 6555, 8, 4211, 304, 272, 408, 1767, 10311, 3608, 465, 282, 805, 32163, 376, 3734, 1211, 1041, 272, 862, 26, 267, 372, 485, 1637, 59, 4211, 61, 272, 871, 4067, 26, 267, 986, 272, 340, 440, 3608, 14, 1913, 837, 267, 347, 3608, 63, 2324, 8, 5418, 29, 403, 12, 4278, 29, 403, 304, 288, 408, 624, 288, 372, 715, 272, 587, 26, 267, 10311, 63, 4211, 275, 6555, 63, 4211, 8, 1122, 63, 4211, 8, 4211, 430, 267, 347, 3608, 63, 2324, 8, 5418, 29, 403, 12, 4278, 29, 403, 304, 288, 408, 4415, 7029, 3734, 624, 288, 340, 4278, 365, 488, 26, 355, 4278, 275, 1052, 288, 340, 3734, 365, 488, 26, 355, 3734, 275, 849, 63, 5418, 342, 288, 3734, 14, 873, 8, 4415, 9, 288, 372, 3468, 8, 8427, 63, 4211, 12, 3734, 9, 272, 3608, 63, 2324, 855, 1301, 363, 275, 3608, 272, 485, 1637, 59, 4211, 61, 275, 3608, 63, 2324, 272, 372, 485, 1637, 59, 4211, 61, 199, 199, 318, 15579, 8, 4211, 12, 3734, 29, 403, 304, 272, 372, 6555, 8, 4211, 5130, 5418, 9, 199, 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, 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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, 0 ]
yland/coala
tests/parsing/CliParsingTest.py
18
2415
import argparse import unittest from coalib.parsing.CliParsing import parse_cli, check_conflicts class CliParserTest(unittest.TestCase): def setUp(self): self.test_arg_parser = argparse.ArgumentParser() self.test_arg_parser.add_argument('-t', nargs='+', dest='test') self.test_arg_parser.add_argument('-S', '--settings', nargs='+', dest='settings') @staticmethod def dict_from_sections(parsed_sections): parsed_dict = {} for section_name, section in parsed_sections.items(): parsed_dict[section_name] = ( set([(key, str(value)) for key, value in section.contents.items()])) return parsed_dict def test_parse_cli(self): # regular parse parsed_sections = parse_cli( ['-t', 'ignored1', 'ignored2', '-t', 'taken', '-S', 'section1.key1,section2.key2=value1,value2', 'section2.key2=only_this_value', 'SECTION2.key2a=k2a', 'invalid.=shouldnt_be_shown', '.=not_either', '.key=only_in_default', 'default_key1,default_key2=single_value', 'default_key3=first_value,second_value'], arg_parser=self.test_arg_parser) expected_dict = { 'default': { ("test", "taken"), ("key", "only_in_default"), ("default_key1", "single_value"), ("default_key2", "single_value"), ("default_key3", "first_value,second_value")}, 'section1': { ("key1", "value1,value2")}, 'section2': { ("key2", "only_this_value"), ("key2a", "k2a")}} self.assertEqual(parsed_sections["default"].name, "Default") self.assertEqual(self.dict_from_sections(parsed_sections), expected_dict) def test_check_conflicts(self): sections = parse_cli(arg_list=["--save", "--no-config"]) with self.assertRaises(SystemExit) as cm: check_conflicts(sections) self.assertEqual(cm.exception.code, 2) sections = parse_cli(arg_list=["--no-config", "-S", "val=42"]) self.assertTrue(check_conflicts(sections))
agpl-3.0
[ 646, 7534, 199, 646, 2882, 199, 199, 504, 512, 25530, 14, 11059, 14, 20653, 17412, 492, 2198, 63, 2764, 12, 1104, 63, 22654, 421, 199, 533, 445, 317, 2842, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 396, 63, 1273, 63, 2087, 275, 7534, 14, 10730, 342, 267, 291, 14, 396, 63, 1273, 63, 2087, 14, 525, 63, 2094, 3654, 84, 297, 9237, 534, 7386, 2053, 534, 396, 358, 267, 291, 14, 396, 63, 1273, 63, 2087, 14, 525, 63, 2094, 3654, 51, 297, 5101, 2850, 1751, 297, 5101, 9237, 534, 7386, 5101, 2053, 534, 1751, 358, 339, 768, 4639, 272, 347, 1211, 63, 504, 63, 7786, 8, 6751, 63, 7786, 304, 267, 4565, 63, 807, 275, 1052, 267, 367, 3420, 63, 354, 12, 3420, 315, 4565, 63, 7786, 14, 1744, 837, 288, 4565, 63, 807, 59, 2792, 63, 354, 61, 275, 334, 355, 663, 7694, 498, 12, 1993, 620, 8, 585, 430, 367, 790, 12, 574, 315, 3420, 14, 4407, 14, 1744, 342, 2459, 267, 372, 4565, 63, 807, 339, 347, 511, 63, 1122, 63, 2764, 8, 277, 304, 267, 327, 5578, 2198, 267, 4565, 63, 7786, 275, 2198, 63, 2764, 8, 288, 11573, 84, 297, 283, 11996, 17, 297, 283, 11996, 18, 297, 1467, 2475, 84, 297, 283, 28549, 297, 1467, 2475, 51, 297, 283, 2792, 17, 14, 498, 17, 12, 2792, 18, 14, 498, 18, 29, 585, 17, 12, 585, 18, 297, 1467, 283, 2792, 18, 14, 498, 18, 29, 2118, 63, 3749, 63, 585, 297, 1467, 283, 13835, 18, 14, 498, 18, 65, 29, 75, 18, 65, 297, 1467, 283, 3197, 14, 29, 5626, 343, 63, 1235, 63, 24422, 297, 1467, 1987, 29, 1397, 63, 22051, 297, 1467, 1987, 498, 29, 2118, 63, 262, 63, 885, 297, 1467, 283, 885, 63, 498, 17, 12, 885, 63, 498, 18, 29, 4780, 63, 585, 297, 1467, 283, 885, 63, 498, 19, 29, 2246, 63, 585, 12, 4375, 63, 585, 995, 288, 1680, 63, 2087, 29, 277, 14, 396, 63, 1273, 63, 2087, 9, 267, 1420, 63, 807, 275, 469, 288, 283, 885, 356, 469, 355, 1689, 396, 401, 298, 28549, 1288, 355, 1689, 498, 401, 298, 2118, 63, 262, 63, 885, 1288, 355, 1689, 885, 63, 498, 17, 401, 298, 4780, 63, 585, 1288, 355, 1689, 885, 63, 498, 18, 401, 298, 4780, 63, 585, 1288, 355, 1689, 885, 63, 498, 19, 401, 298, 2246, 63, 585, 12, 4375, 63, 585, 25988, 288, 283, 2792, 17, 356, 469, 355, 1689, 498, 17, 401, 298, 585, 17, 12, 585, 18, 25988, 288, 283, 2792, 18, 356, 469, 355, 1689, 498, 18, 401, 298, 2118, 63, 3749, 63, 585, 1288, 355, 1689, 498, 18, 65, 401, 298, 75, 18, 65, 531, 4863, 267, 291, 14, 629, 8, 6751, 63, 7786, 905, 885, 4140, 354, 12, 298, 2698, 531, 267, 291, 14, 629, 8, 277, 14, 807, 63, 504, 63, 7786, 8, 6751, 63, 7786, 395, 586, 1420, 63, 807, 9, 339, 347, 511, 63, 1074, 63, 22654, 8, 277, 304, 267, 10189, 275, 2198, 63, 2764, 8, 1273, 63, 513, 6270, 306, 2117, 401, 4320, 889, 13, 888, 3135, 267, 543, 291, 14, 1855, 8, 24738, 9, 465, 6904, 26, 288, 1104, 63, 22654, 8, 7786, 9, 288, 291, 14, 629, 8, 4400, 14, 1971, 14, 600, 12, 499, 9, 398, 10189, 275, 2198, 63, 2764, 8, 1273, 63, 513, 6270, 306, 889, 13, 888, 401, 3905, 51, 401, 298, 637, 29, 2260, 3135, 267, 291, 14, 1815, 8, 1074, 63, 22654, 8, 7786, 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 ]
[ 7534, 199, 646, 2882, 199, 199, 504, 512, 25530, 14, 11059, 14, 20653, 17412, 492, 2198, 63, 2764, 12, 1104, 63, 22654, 421, 199, 533, 445, 317, 2842, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 396, 63, 1273, 63, 2087, 275, 7534, 14, 10730, 342, 267, 291, 14, 396, 63, 1273, 63, 2087, 14, 525, 63, 2094, 3654, 84, 297, 9237, 534, 7386, 2053, 534, 396, 358, 267, 291, 14, 396, 63, 1273, 63, 2087, 14, 525, 63, 2094, 3654, 51, 297, 5101, 2850, 1751, 297, 5101, 9237, 534, 7386, 5101, 2053, 534, 1751, 358, 339, 768, 4639, 272, 347, 1211, 63, 504, 63, 7786, 8, 6751, 63, 7786, 304, 267, 4565, 63, 807, 275, 1052, 267, 367, 3420, 63, 354, 12, 3420, 315, 4565, 63, 7786, 14, 1744, 837, 288, 4565, 63, 807, 59, 2792, 63, 354, 61, 275, 334, 355, 663, 7694, 498, 12, 1993, 620, 8, 585, 430, 367, 790, 12, 574, 315, 3420, 14, 4407, 14, 1744, 342, 2459, 267, 372, 4565, 63, 807, 339, 347, 511, 63, 1122, 63, 2764, 8, 277, 304, 267, 327, 5578, 2198, 267, 4565, 63, 7786, 275, 2198, 63, 2764, 8, 288, 11573, 84, 297, 283, 11996, 17, 297, 283, 11996, 18, 297, 1467, 2475, 84, 297, 283, 28549, 297, 1467, 2475, 51, 297, 283, 2792, 17, 14, 498, 17, 12, 2792, 18, 14, 498, 18, 29, 585, 17, 12, 585, 18, 297, 1467, 283, 2792, 18, 14, 498, 18, 29, 2118, 63, 3749, 63, 585, 297, 1467, 283, 13835, 18, 14, 498, 18, 65, 29, 75, 18, 65, 297, 1467, 283, 3197, 14, 29, 5626, 343, 63, 1235, 63, 24422, 297, 1467, 1987, 29, 1397, 63, 22051, 297, 1467, 1987, 498, 29, 2118, 63, 262, 63, 885, 297, 1467, 283, 885, 63, 498, 17, 12, 885, 63, 498, 18, 29, 4780, 63, 585, 297, 1467, 283, 885, 63, 498, 19, 29, 2246, 63, 585, 12, 4375, 63, 585, 995, 288, 1680, 63, 2087, 29, 277, 14, 396, 63, 1273, 63, 2087, 9, 267, 1420, 63, 807, 275, 469, 288, 283, 885, 356, 469, 355, 1689, 396, 401, 298, 28549, 1288, 355, 1689, 498, 401, 298, 2118, 63, 262, 63, 885, 1288, 355, 1689, 885, 63, 498, 17, 401, 298, 4780, 63, 585, 1288, 355, 1689, 885, 63, 498, 18, 401, 298, 4780, 63, 585, 1288, 355, 1689, 885, 63, 498, 19, 401, 298, 2246, 63, 585, 12, 4375, 63, 585, 25988, 288, 283, 2792, 17, 356, 469, 355, 1689, 498, 17, 401, 298, 585, 17, 12, 585, 18, 25988, 288, 283, 2792, 18, 356, 469, 355, 1689, 498, 18, 401, 298, 2118, 63, 3749, 63, 585, 1288, 355, 1689, 498, 18, 65, 401, 298, 75, 18, 65, 531, 4863, 267, 291, 14, 629, 8, 6751, 63, 7786, 905, 885, 4140, 354, 12, 298, 2698, 531, 267, 291, 14, 629, 8, 277, 14, 807, 63, 504, 63, 7786, 8, 6751, 63, 7786, 395, 586, 1420, 63, 807, 9, 339, 347, 511, 63, 1074, 63, 22654, 8, 277, 304, 267, 10189, 275, 2198, 63, 2764, 8, 1273, 63, 513, 6270, 306, 2117, 401, 4320, 889, 13, 888, 3135, 267, 543, 291, 14, 1855, 8, 24738, 9, 465, 6904, 26, 288, 1104, 63, 22654, 8, 7786, 9, 288, 291, 14, 629, 8, 4400, 14, 1971, 14, 600, 12, 499, 9, 398, 10189, 275, 2198, 63, 2764, 8, 1273, 63, 513, 6270, 306, 889, 13, 888, 401, 3905, 51, 401, 298, 637, 29, 2260, 3135, 267, 291, 14, 1815, 8, 1074, 63, 22654, 8, 7786, 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, 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, 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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 ]
microsoft/ANCE
data/process_fn.py
1
5115
import torch def pad_ids(input_ids, attention_mask, token_type_ids, max_length, pad_token, mask_padding_with_zero, pad_token_segment_id, pad_on_left=False): padding_length = max_length - len(input_ids) if pad_on_left: input_ids = ([pad_token] * padding_length) + input_ids attention_mask = ([0 if mask_padding_with_zero else 1] * padding_length) + attention_mask token_type_ids = ([pad_token_segment_id] * padding_length) + token_type_ids else: input_ids += [pad_token] * padding_length attention_mask += [0 if mask_padding_with_zero else 1] * padding_length token_type_ids += [pad_token_segment_id] * padding_length return input_ids, attention_mask, token_type_ids def dual_process_fn(line, i, tokenizer, args): features = [] cells = line.split("\t") if len(cells) == 2: # this is for training and validation # id, passage = line mask_padding_with_zero = True pad_token_segment_id = 0 pad_on_left = False text = cells[1].strip() input_id_a = tokenizer.encode( text, add_special_tokens=True, max_length=args.max_seq_length,) token_type_ids_a = [0] * len(input_id_a) attention_mask_a = [ 1 if mask_padding_with_zero else 0] * len(input_id_a) input_id_a, attention_mask_a, token_type_ids_a = pad_ids( input_id_a, attention_mask_a, token_type_ids_a, args.max_seq_length, tokenizer.pad_token_id, mask_padding_with_zero, pad_token_segment_id, pad_on_left) features += [torch.tensor(input_id_a, dtype=torch.int), torch.tensor( attention_mask_a, dtype=torch.bool), torch.tensor(token_type_ids_a, dtype=torch.uint8)] qid = int(cells[0]) features.append(qid) else: raise Exception( "Line doesn't have correct length: {0}. Expected 2.".format(str(len(cells)))) return [features] def triple_process_fn(line, i, tokenizer, args): features = [] cells = line.split("\t") if len(cells) == 3: # this is for training and validation # query, positive_passage, negative_passage = line mask_padding_with_zero = True pad_token_segment_id = 0 pad_on_left = False for text in cells: input_id_a = tokenizer.encode( text.strip(), add_special_tokens=True, max_length=args.max_seq_length,) token_type_ids_a = [0] * len(input_id_a) attention_mask_a = [ 1 if mask_padding_with_zero else 0] * len(input_id_a) input_id_a, attention_mask_a, token_type_ids_a = pad_ids( input_id_a, attention_mask_a, token_type_ids_a, args.max_seq_length, tokenizer.pad_token_id, mask_padding_with_zero, pad_token_segment_id, pad_on_left) features += [torch.tensor(input_id_a, dtype=torch.int), torch.tensor(attention_mask_a, dtype=torch.bool)] else: raise Exception( "Line doesn't have correct length: {0}. Expected 3.".format(str(len(cells)))) return [features] def triple2dual_process_fn(line, i, tokenizer, args): ret = [] cells = line.split("\t") if len(cells) == 3: # this is for training and validation # query, positive_passage, negative_passage = line # return 2 entries per line, 1 pos + 1 neg mask_padding_with_zero = True pad_token_segment_id = 0 pad_on_left = False pos_feats = [] neg_feats = [] for i, text in enumerate(cells): input_id_a = tokenizer.encode( text.strip(), add_special_tokens=True, max_length=args.max_seq_length,) token_type_ids_a = [0] * len(input_id_a) attention_mask_a = [ 1 if mask_padding_with_zero else 0] * len(input_id_a) input_id_a, attention_mask_a, token_type_ids_a = pad_ids( input_id_a, attention_mask_a, token_type_ids_a, args.max_seq_length, tokenizer.pad_token_id, mask_padding_with_zero, pad_token_segment_id, pad_on_left) if i == 0: pos_feats += [torch.tensor(input_id_a, dtype=torch.int), torch.tensor(attention_mask_a, dtype=torch.bool)] neg_feats += [torch.tensor(input_id_a, dtype=torch.int), torch.tensor(attention_mask_a, dtype=torch.bool)] elif i == 1: pos_feats += [torch.tensor(input_id_a, dtype=torch.int), torch.tensor(attention_mask_a, dtype=torch.bool), 1] else: neg_feats += [torch.tensor(input_id_a, dtype=torch.int), torch.tensor(attention_mask_a, dtype=torch.bool), 0] ret = [pos_feats, neg_feats] else: raise Exception( "Line doesn't have correct length: {0}. Expected 3.".format(str(len(cells)))) return ret
mit
[ 646, 21416, 8065, 199, 318, 6567, 63, 1580, 8, 1210, 63, 1580, 12, 22814, 63, 2629, 12, 1526, 63, 466, 63, 1580, 12, 1390, 63, 1267, 12, 6567, 63, 1418, 12, 3656, 63, 8358, 63, 1045, 63, 4262, 12, 6567, 63, 1418, 63, 9255, 63, 344, 12, 6567, 63, 265, 63, 3039, 29, 797, 304, 1128, 6273, 63, 1267, 275, 1390, 63, 1267, 446, 822, 8, 1210, 63, 1580, 9, 1128, 340, 6567, 63, 265, 63, 3039, 26, 1039, 1324, 63, 1580, 275, 7287, 6226, 63, 1418, 61, 627, 6273, 63, 1267, 9, 435, 1324, 63, 1580, 1039, 22814, 63, 2629, 275, 7287, 16, 340, 3656, 63, 8358, 63, 1045, 63, 4262, 587, 413, 61, 202, 2079, 627, 6273, 63, 1267, 9, 435, 22814, 63, 2629, 1039, 1526, 63, 466, 63, 1580, 275, 7287, 6226, 63, 1418, 63, 9255, 63, 344, 61, 627, 202, 2079, 6273, 63, 1267, 9, 435, 1526, 63, 466, 63, 1580, 1128, 587, 26, 1039, 1324, 63, 1580, 847, 359, 6226, 63, 1418, 61, 627, 6273, 63, 1267, 1039, 22814, 63, 2629, 847, 359, 16, 340, 3656, 63, 8358, 63, 1045, 63, 4262, 587, 413, 61, 627, 6273, 63, 1267, 1039, 1526, 63, 466, 63, 1580, 847, 359, 6226, 63, 1418, 63, 9255, 63, 344, 61, 627, 6273, 63, 1267, 2958, 372, 1324, 63, 1580, 12, 22814, 63, 2629, 12, 1526, 63, 466, 63, 1580, 8065, 199, 318, 21164, 63, 1412, 63, 2324, 8, 604, 12, 284, 12, 14803, 12, 1249, 304, 1128, 4534, 275, 942, 1128, 10106, 275, 1004, 14, 1294, 4582, 84, 531, 1128, 340, 822, 8, 9041, 9, 508, 499, 26, 1039, 327, 642, 365, 367, 6093, 436, 6411, 1039, 327, 1305, 12, 986, 474, 275, 1004, 1039, 3656, 63, 8358, 63, 1045, 63, 4262, 275, 715, 1039, 6567, 63, 1418, 63, 9255, 63, 344, 275, 378, 1039, 6567, 63, 265, 63, 3039, 275, 756, 4341, 1318, 275, 10106, 59, 17, 1055, 1913, 342, 1039, 1324, 63, 344, 63, 65, 275, 14803, 14, 2143, 8, 1675, 1318, 12, 1050, 63, 6664, 63, 4504, 29, 549, 12, 1390, 63, 1267, 29, 589, 14, 988, 63, 3610, 63, 1267, 4258, 1039, 1526, 63, 466, 63, 1580, 63, 65, 275, 359, 16, 61, 627, 822, 8, 1210, 63, 344, 63, 65, 9, 1039, 22814, 63, 2629, 63, 65, 275, 359, 1675, 413, 340, 3656, 63, 8358, 63, 1045, 63, 4262, 587, 378, 61, 627, 822, 8, 1210, 63, 344, 63, 65, 9, 1039, 1324, 63, 344, 63, 65, 12, 22814, 63, 2629, 63, 65, 12, 1526, 63, 466, 63, 1580, 63, 65, 275, 6567, 63, 1580, 8, 1675, 1324, 63, 344, 63, 65, 12, 22814, 63, 2629, 63, 65, 12, 1526, 63, 466, 63, 1580, 63, 65, 12, 1249, 14, 988, 63, 3610, 63, 1267, 12, 14803, 14, 6226, 63, 1418, 63, 344, 12, 3656, 63, 8358, 63, 1045, 63, 4262, 12, 6567, 63, 1418, 63, 9255, 63, 344, 12, 6567, 63, 265, 63, 3039, 9, 1039, 4534, 847, 359, 29676, 14, 3128, 8, 1210, 63, 344, 63, 65, 12, 2152, 29, 29676, 14, 442, 395, 21416, 14, 3128, 8, 1675, 22814, 63, 2629, 63, 65, 12, 2152, 29, 29676, 14, 2245, 395, 21416, 14, 3128, 8, 1418, 63, 466, 63, 1580, 63, 65, 12, 2152, 29, 29676, 14, 1635, 24, 1874, 1039, 1894, 344, 275, 1109, 8, 9041, 59, 16, 566, 1039, 4534, 14, 740, 8, 81, 344, 9, 1128, 587, 26, 1039, 746, 2186, 8, 1675, 298, 3049, 3181, 1133, 1172, 3211, 2582, 26, 469, 16, 5565, 13796, 499, 15848, 908, 8, 495, 8, 552, 8, 9041, 7845, 1128, 372, 359, 3179, 61, 8065, 199, 318, 19671, 63, 1412, 63, 2324, 8, 604, 12, 284, 12, 14803, 12, 1249, 304, 1128, 4534, 275, 942, 1128, 10106, 275, 1004, 14, 1294, 4582, 84, 531, 1128, 340, 822, 8, 9041, 9, 508, 650, 26, 1039, 327, 642, 365, 367, 6093, 436, 6411, 1039, 327, 1827, 12, 7317, 63, 1529, 474, 12, 6946, 63, 1529, 474, 275, 1004, 1039, 3656, 63, 8358, 63, 1045, 63, 4262, 275, 715, 1039, 6567, 63, 1418, 63, 9255, 63, 344, 275, 378, 1039, 6567, 63, 265, 63, 3039, 275, 756, 4341, 367, 1318, 315, 10106, 26, 1675, 1324, 63, 344, 63, 65, 275, 14803, 14, 2143, 8, 2628, 1318, 14, 1913, 1062, 1050, 63, 6664, 63, 4504, 29, 549, 12, 1390, 63, 1267, 29, 589, 14, 988, 63, 3610, 63, 1267, 4258, 1675, 1526, 63, 466, 63, 1580, 63, 65, 275, 359, 16, 61, 627, 822, 8, 1210, 63, 344, 63, 65, 9, 1675, 22814, 63, 2629, 63, 65, 275, 359, 2628, 413, 340, 3656, 63, 8358, 63, 1045, 63, 4262, 587, 378, 61, 627, 822, 8, 1210, 63, 344, 63, 65, 9, 1675, 1324, 63, 344, 63, 65, 12, 22814, 63, 2629, 63, 65, 12, 1526, 63, 466, 63, 1580, 63, 65, 275, 6567, 63, 1580, 8, 2628, 1324, 63, 344, 63, 65, 12, 22814, 63, 2629, 63, 65, 12, 1526, 63, 466, 63, 1580, 63, 65, 12, 1249, 14, 988, 63, 3610, 63, 1267, 12, 14803, 14, 6226, 63, 1418, 63, 344, 12, 3656, 63, 8358, 63, 1045, 63, 4262, 12, 6567, 63, 1418, 63, 9255, 63, 344, 12, 6567, 63, 265, 63, 3039, 9, 1675, 4534, 847, 359, 29676, 14, 3128, 8, 1210, 63, 344, 63, 65, 12, 2152, 29, 29676, 14, 442, 395, 202, 586, 21416, 14, 3128, 8, 22393, 63, 2629, 63, 65, 12, 2152, 29, 29676, 14, 2245, 1874, 1128, 587, 26, 1039, 746, 2186, 8, 1675, 298, 3049, 3181, 1133, 1172, 3211, 2582, 26, 469, 16, 5565, 13796, 650, 15848, 908, 8, 495, 8, 552, 8, 9041, 7845, 1128, 372, 359, 3179, 61, 8065, 199, 318, 19671, 18, 17962, 63, 1412, 63, 2324, 8, 604, 12, 284, 12, 14803, 12, 1249, 304, 1128, 2203, 275, 942, 1128, 10106, 275, 1004, 14, 1294, 4582, 84, 531, 1128, 340, 822, 8, 9041, 9, 508, 650, 26, 1039, 327, 642, 365, 367, 6093, 436, 6411, 1039, 327, 1827, 12, 7317, 63, 1529, 474, 12, 6946, 63, 1529, 474, 275, 1004, 1039, 327, 372, 499, 4811, 1126, 1004, 12, 413, 2086, 435, 413, 14158, 1039, 3656, 63, 8358, 63, 1045, 63, 4262 ]
[ 21416, 8065, 199, 318, 6567, 63, 1580, 8, 1210, 63, 1580, 12, 22814, 63, 2629, 12, 1526, 63, 466, 63, 1580, 12, 1390, 63, 1267, 12, 6567, 63, 1418, 12, 3656, 63, 8358, 63, 1045, 63, 4262, 12, 6567, 63, 1418, 63, 9255, 63, 344, 12, 6567, 63, 265, 63, 3039, 29, 797, 304, 1128, 6273, 63, 1267, 275, 1390, 63, 1267, 446, 822, 8, 1210, 63, 1580, 9, 1128, 340, 6567, 63, 265, 63, 3039, 26, 1039, 1324, 63, 1580, 275, 7287, 6226, 63, 1418, 61, 627, 6273, 63, 1267, 9, 435, 1324, 63, 1580, 1039, 22814, 63, 2629, 275, 7287, 16, 340, 3656, 63, 8358, 63, 1045, 63, 4262, 587, 413, 61, 202, 2079, 627, 6273, 63, 1267, 9, 435, 22814, 63, 2629, 1039, 1526, 63, 466, 63, 1580, 275, 7287, 6226, 63, 1418, 63, 9255, 63, 344, 61, 627, 202, 2079, 6273, 63, 1267, 9, 435, 1526, 63, 466, 63, 1580, 1128, 587, 26, 1039, 1324, 63, 1580, 847, 359, 6226, 63, 1418, 61, 627, 6273, 63, 1267, 1039, 22814, 63, 2629, 847, 359, 16, 340, 3656, 63, 8358, 63, 1045, 63, 4262, 587, 413, 61, 627, 6273, 63, 1267, 1039, 1526, 63, 466, 63, 1580, 847, 359, 6226, 63, 1418, 63, 9255, 63, 344, 61, 627, 6273, 63, 1267, 2958, 372, 1324, 63, 1580, 12, 22814, 63, 2629, 12, 1526, 63, 466, 63, 1580, 8065, 199, 318, 21164, 63, 1412, 63, 2324, 8, 604, 12, 284, 12, 14803, 12, 1249, 304, 1128, 4534, 275, 942, 1128, 10106, 275, 1004, 14, 1294, 4582, 84, 531, 1128, 340, 822, 8, 9041, 9, 508, 499, 26, 1039, 327, 642, 365, 367, 6093, 436, 6411, 1039, 327, 1305, 12, 986, 474, 275, 1004, 1039, 3656, 63, 8358, 63, 1045, 63, 4262, 275, 715, 1039, 6567, 63, 1418, 63, 9255, 63, 344, 275, 378, 1039, 6567, 63, 265, 63, 3039, 275, 756, 4341, 1318, 275, 10106, 59, 17, 1055, 1913, 342, 1039, 1324, 63, 344, 63, 65, 275, 14803, 14, 2143, 8, 1675, 1318, 12, 1050, 63, 6664, 63, 4504, 29, 549, 12, 1390, 63, 1267, 29, 589, 14, 988, 63, 3610, 63, 1267, 4258, 1039, 1526, 63, 466, 63, 1580, 63, 65, 275, 359, 16, 61, 627, 822, 8, 1210, 63, 344, 63, 65, 9, 1039, 22814, 63, 2629, 63, 65, 275, 359, 1675, 413, 340, 3656, 63, 8358, 63, 1045, 63, 4262, 587, 378, 61, 627, 822, 8, 1210, 63, 344, 63, 65, 9, 1039, 1324, 63, 344, 63, 65, 12, 22814, 63, 2629, 63, 65, 12, 1526, 63, 466, 63, 1580, 63, 65, 275, 6567, 63, 1580, 8, 1675, 1324, 63, 344, 63, 65, 12, 22814, 63, 2629, 63, 65, 12, 1526, 63, 466, 63, 1580, 63, 65, 12, 1249, 14, 988, 63, 3610, 63, 1267, 12, 14803, 14, 6226, 63, 1418, 63, 344, 12, 3656, 63, 8358, 63, 1045, 63, 4262, 12, 6567, 63, 1418, 63, 9255, 63, 344, 12, 6567, 63, 265, 63, 3039, 9, 1039, 4534, 847, 359, 29676, 14, 3128, 8, 1210, 63, 344, 63, 65, 12, 2152, 29, 29676, 14, 442, 395, 21416, 14, 3128, 8, 1675, 22814, 63, 2629, 63, 65, 12, 2152, 29, 29676, 14, 2245, 395, 21416, 14, 3128, 8, 1418, 63, 466, 63, 1580, 63, 65, 12, 2152, 29, 29676, 14, 1635, 24, 1874, 1039, 1894, 344, 275, 1109, 8, 9041, 59, 16, 566, 1039, 4534, 14, 740, 8, 81, 344, 9, 1128, 587, 26, 1039, 746, 2186, 8, 1675, 298, 3049, 3181, 1133, 1172, 3211, 2582, 26, 469, 16, 5565, 13796, 499, 15848, 908, 8, 495, 8, 552, 8, 9041, 7845, 1128, 372, 359, 3179, 61, 8065, 199, 318, 19671, 63, 1412, 63, 2324, 8, 604, 12, 284, 12, 14803, 12, 1249, 304, 1128, 4534, 275, 942, 1128, 10106, 275, 1004, 14, 1294, 4582, 84, 531, 1128, 340, 822, 8, 9041, 9, 508, 650, 26, 1039, 327, 642, 365, 367, 6093, 436, 6411, 1039, 327, 1827, 12, 7317, 63, 1529, 474, 12, 6946, 63, 1529, 474, 275, 1004, 1039, 3656, 63, 8358, 63, 1045, 63, 4262, 275, 715, 1039, 6567, 63, 1418, 63, 9255, 63, 344, 275, 378, 1039, 6567, 63, 265, 63, 3039, 275, 756, 4341, 367, 1318, 315, 10106, 26, 1675, 1324, 63, 344, 63, 65, 275, 14803, 14, 2143, 8, 2628, 1318, 14, 1913, 1062, 1050, 63, 6664, 63, 4504, 29, 549, 12, 1390, 63, 1267, 29, 589, 14, 988, 63, 3610, 63, 1267, 4258, 1675, 1526, 63, 466, 63, 1580, 63, 65, 275, 359, 16, 61, 627, 822, 8, 1210, 63, 344, 63, 65, 9, 1675, 22814, 63, 2629, 63, 65, 275, 359, 2628, 413, 340, 3656, 63, 8358, 63, 1045, 63, 4262, 587, 378, 61, 627, 822, 8, 1210, 63, 344, 63, 65, 9, 1675, 1324, 63, 344, 63, 65, 12, 22814, 63, 2629, 63, 65, 12, 1526, 63, 466, 63, 1580, 63, 65, 275, 6567, 63, 1580, 8, 2628, 1324, 63, 344, 63, 65, 12, 22814, 63, 2629, 63, 65, 12, 1526, 63, 466, 63, 1580, 63, 65, 12, 1249, 14, 988, 63, 3610, 63, 1267, 12, 14803, 14, 6226, 63, 1418, 63, 344, 12, 3656, 63, 8358, 63, 1045, 63, 4262, 12, 6567, 63, 1418, 63, 9255, 63, 344, 12, 6567, 63, 265, 63, 3039, 9, 1675, 4534, 847, 359, 29676, 14, 3128, 8, 1210, 63, 344, 63, 65, 12, 2152, 29, 29676, 14, 442, 395, 202, 586, 21416, 14, 3128, 8, 22393, 63, 2629, 63, 65, 12, 2152, 29, 29676, 14, 2245, 1874, 1128, 587, 26, 1039, 746, 2186, 8, 1675, 298, 3049, 3181, 1133, 1172, 3211, 2582, 26, 469, 16, 5565, 13796, 650, 15848, 908, 8, 495, 8, 552, 8, 9041, 7845, 1128, 372, 359, 3179, 61, 8065, 199, 318, 19671, 18, 17962, 63, 1412, 63, 2324, 8, 604, 12, 284, 12, 14803, 12, 1249, 304, 1128, 2203, 275, 942, 1128, 10106, 275, 1004, 14, 1294, 4582, 84, 531, 1128, 340, 822, 8, 9041, 9, 508, 650, 26, 1039, 327, 642, 365, 367, 6093, 436, 6411, 1039, 327, 1827, 12, 7317, 63, 1529, 474, 12, 6946, 63, 1529, 474, 275, 1004, 1039, 327, 372, 499, 4811, 1126, 1004, 12, 413, 2086, 435, 413, 14158, 1039, 3656, 63, 8358, 63, 1045, 63, 4262, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 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
1
202304
# Author: Nic Wolfe <nic@wolfeden.ca> # URL: http://code.google.com/p/sickbeard/ # # This file is part of SickRage. # # SickRage 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. # # SickRage 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 SickRage. If not, see <http://www.gnu.org/licenses/>. from __future__ import with_statement import traceback import os import time import urllib import re import datetime import sickbeard from sickbeard import config, sab from sickbeard import clients from sickbeard import history, notifiers, processTV from sickbeard import ui from sickbeard import logger, helpers, exceptions, classes, db from sickbeard import encodingKludge as ek from sickbeard import search_queue from sickbeard import image_cache from sickbeard import naming from sickbeard import scene_exceptions from sickbeard import subtitles from sickbeard import network_timezones from sickbeard import sbdatetime from sickbeard.providers import newznab, rsstorrent from sickbeard.common import Quality, Overview, statusStrings, qualityPresetStrings, cpu_presets from sickbeard.common import SNATCHED, UNAIRED, IGNORED, ARCHIVED, WANTED, FAILED from sickbeard.common import SD, HD720p, HD1080p from sickbeard.exceptions import ex from sickbeard.blackandwhitelist import BlackAndWhiteList from sickbeard.scene_exceptions import get_scene_exceptions from sickbeard.browser import foldersAtPath from sickbeard.scene_numbering import get_scene_numbering, set_scene_numbering, get_scene_numbering_for_show, \ get_xem_numbering_for_show, get_scene_absolute_numbering_for_show, get_xem_absolute_numbering_for_show, \ get_scene_absolute_numbering from lib.dateutil import tz, parser as dateutil_parser from lib.unrar2 import RarFile from lib import adba, subliminal from lib.trakt import TraktAPI from lib.trakt.exceptions import traktException, traktAuthException, traktServerBusy try: import json except ImportError: from lib import simplejson as json try: import xml.etree.cElementTree as etree except ImportError: import xml.etree.ElementTree as etree from Cheetah.Template import Template as CheetahTemplate from Cheetah.Filters import Filter as CheetahFilter from tornado.routes import route from tornado.web import RequestHandler, HTTPError, authenticated, asynchronous from tornado.gen import coroutine from tornado.ioloop import IOLoop from tornado.concurrent import run_on_executor from concurrent.futures import ThreadPoolExecutor route_locks = {} class html_entities(CheetahFilter): def filter(self, val, **dummy_kw): if isinstance(val, unicode): filtered = val.encode('ascii', 'xmlcharrefreplace') elif val is None: filtered = '' elif isinstance(val, str): filtered = val.decode(sickbeard.SYS_ENCODING).encode('ascii', 'xmlcharrefreplace') else: filtered = self.filter(str(val)) return filtered class PageTemplate(CheetahTemplate): def __init__(self, rh, *args, **kwargs): kwargs['file'] = os.path.join(sickbeard.PROG_DIR, "gui/" + sickbeard.GUI_NAME + "/interfaces/default/", kwargs['file']) kwargs['filter'] = html_entities super(PageTemplate, self).__init__(*args, **kwargs) self.sbRoot = sickbeard.WEB_ROOT self.sbHttpPort = sickbeard.WEB_PORT self.sbHttpsPort = sickbeard.WEB_PORT self.sbHttpsEnabled = sickbeard.ENABLE_HTTPS self.sbHandleReverseProxy = sickbeard.HANDLE_REVERSE_PROXY self.sbThemeName = sickbeard.THEME_NAME self.sbLogin = rh.get_current_user() if rh.request.headers['Host'][0] == '[': self.sbHost = re.match("^\[.*\]", rh.request.headers['Host'], re.X | re.M | re.S).group(0) else: self.sbHost = re.match("^[^:]+", rh.request.headers['Host'], re.X | re.M | re.S).group(0) if "X-Forwarded-Host" in rh.request.headers: self.sbHost = rh.request.headers['X-Forwarded-Host'] if "X-Forwarded-Port" in rh.request.headers: sbHttpPort = rh.request.headers['X-Forwarded-Port'] self.sbHttpsPort = sbHttpPort if "X-Forwarded-Proto" in rh.request.headers: self.sbHttpsEnabled = True if rh.request.headers['X-Forwarded-Proto'] == 'https' else False logPageTitle = 'Logs &amp; Errors' if len(classes.ErrorViewer.errors): logPageTitle += ' (' + str(len(classes.ErrorViewer.errors)) + ')' self.logPageTitle = logPageTitle self.sbPID = str(sickbeard.PID) self.menu = [ {'title': 'Home', 'key': 'home'}, {'title': 'Coming Episodes', 'key': 'comingEpisodes'}, {'title': 'History', 'key': 'history'}, {'title': 'Manage', 'key': 'manage'}, {'title': 'Config', 'key': 'config'}, {'title': logPageTitle, 'key': 'errorlogs'}, ] def compile(self, *args, **kwargs): if not os.path.exists(os.path.join(sickbeard.CACHE_DIR, 'cheetah')): os.mkdir(os.path.join(sickbeard.CACHE_DIR, 'cheetah')) kwargs['cacheModuleFilesForTracebacks'] = True kwargs['cacheDirForModuleFiles'] = os.path.join(sickbeard.CACHE_DIR, 'cheetah') return super(PageTemplate, self).compile(*args, **kwargs) class BaseHandler(RequestHandler): def __init__(self, *args, **kwargs): super(BaseHandler, self).__init__(*args, **kwargs) def set_default_headers(self): self.set_header('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') def write_error(self, status_code, **kwargs): # handle 404 http errors if status_code == 404: url = self.request.uri if sickbeard.WEB_ROOT and self.request.uri.startswith(sickbeard.WEB_ROOT): url = url[len(sickbeard.WEB_ROOT) + 1:] if url[:3] != 'api': return self.redirect('/') else: self.finish('Wrong API key used') elif self.settings.get("debug") and "exc_info" in kwargs: exc_info = kwargs["exc_info"] trace_info = ''.join(["%s<br/>" % line for line in traceback.format_exception(*exc_info)]) request_info = ''.join(["<strong>%s</strong>: %s<br/>" % (k, self.request.__dict__[k] ) for k in self.request.__dict__.keys()]) error = exc_info[1] self.set_header('Content-Type', 'text/html') self.finish("""<html> <title>%s</title> <body> <h2>Error</h2> <p>%s</p> <h2>Traceback</h2> <p>%s</p> <h2>Request Info</h2> <p>%s</p> <button onclick="window.location='%s/errorlogs/';">View Log(Errors)</button> </body> </html>""" % (error, error, trace_info, request_info, sickbeard.WEB_ROOT)) def redirect(self, url, permanent=False, status=None): if not url.startswith(sickbeard.WEB_ROOT): url = sickbeard.WEB_ROOT + url super(BaseHandler, self).redirect(url, permanent, status) def get_current_user(self, *args, **kwargs): if not isinstance(self, UI) and sickbeard.WEB_USERNAME and sickbeard.WEB_PASSWORD: return self.get_secure_cookie('sickrage_user') else: return True class WebHandler(BaseHandler): def __init__(self, *args, **kwargs): super(WebHandler, self).__init__(*args, **kwargs) self.io_loop = IOLoop.current() executor = ThreadPoolExecutor(50) @coroutine @asynchronous @authenticated def get(self, route, *args, **kwargs): try: # route -> method obj route = route.strip('/').replace('.', '_') or 'index' method = getattr(self, route) # process request async self.async_call(method, callback=self.async_done) except: logger.log('Failed doing webui request "%s": %s' % (route, traceback.format_exc()), logger.DEBUG) raise HTTPError(404) @run_on_executor def async_call(self, function, callback=None): try: kwargs = self.request.arguments for arg, value in kwargs.items(): if len(value) == 1: kwargs[arg] = value[0] result = function(**kwargs) if callback: callback(result) return result except: logger.log('Failed doing webui callback: %s' % (traceback.format_exc()), logger.ERROR) raise def async_done(self, results): try: if results: self.finish(results) except: logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG) raise # post uses get method post = get class LoginHandler(BaseHandler): def get(self, *args, **kwargs): if self.get_current_user(): self.redirect('/home/') else: t = PageTemplate(rh=self, file="login.tmpl") self.finish(t.respond()) def post(self, *args, **kwargs): api_key = None username = sickbeard.WEB_USERNAME password = sickbeard.WEB_PASSWORD if (self.get_argument('username') == username or not username) \ and (self.get_argument('password') == password or not password): api_key = sickbeard.API_KEY if api_key: remember_me = int(self.get_argument('remember_me', default=0) or 0) self.set_secure_cookie('sickrage_user', api_key, expires_days=30 if remember_me > 0 else None) self.redirect('/home/') class LogoutHandler(BaseHandler): def get(self, *args, **kwargs): self.clear_cookie("sickrage_user") self.redirect('/login/') class KeyHandler(RequestHandler): def __init__(self, *args, **kwargs): super(KeyHandler, self).__init__(*args, **kwargs) def get(self, *args, **kwargs): api_key = None try: username = sickbeard.WEB_USERNAME password = sickbeard.WEB_PASSWORD if (self.get_argument('u', None) == username or not username) and \ (self.get_argument('p', None) == password or not password): api_key = sickbeard.API_KEY self.finish({'success': api_key is not None, 'api_key': api_key}) except: logger.log('Failed doing key request: %s' % (traceback.format_exc()), logger.ERROR) self.finish({'success': False, 'error': 'Failed returning results'}) @route('(.*)(/?)') class WebRoot(WebHandler): def __init__(self, *args, **kwargs): super(WebRoot, self).__init__(*args, **kwargs) def index(self): return self.redirect('/home/') def robots_txt(self): """ Keep web crawlers out """ self.set_header('Content-Type', 'text/plain') return "User-agent: *\nDisallow: /" def apibuilder(self): t = PageTemplate(rh=self, file="apiBuilder.tmpl") def titler(x): return (helpers.remove_article(x), x)[not x or sickbeard.SORT_ARTICLE] t.sortedShowList = sorted(sickbeard.showList, lambda x, y: cmp(titler(x.name), titler(y.name))) myDB = db.DBConnection(row_type="dict") seasonSQLResults = {} episodeSQLResults = {} for curShow in t.sortedShowList: seasonSQLResults[curShow.indexerid] = myDB.select( "SELECT DISTINCT season FROM tv_episodes WHERE showid = ? ORDER BY season DESC", [curShow.indexerid]) for curShow in t.sortedShowList: episodeSQLResults[curShow.indexerid] = myDB.select( "SELECT DISTINCT season,episode FROM tv_episodes WHERE showid = ? ORDER BY season DESC, episode DESC", [curShow.indexerid]) t.seasonSQLResults = seasonSQLResults t.episodeSQLResults = episodeSQLResults if len(sickbeard.API_KEY) == 32: t.apikey = sickbeard.API_KEY else: t.apikey = "api key not generated" return t.respond() def showPoster(self, show=None, which=None): # Redirect initial poster/banner thumb to default images if which[0:6] == 'poster': default_image_name = 'poster.png' else: default_image_name = 'banner.png' # image_path = ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', 'slick', 'images', default_image_name) static_image_path = os.path.join('/images', default_image_name) if show and sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)): cache_obj = image_cache.ImageCache() image_file_name = None if which == 'poster': image_file_name = cache_obj.poster_path(show) if which == 'poster_thumb' or which == 'small': image_file_name = cache_obj.poster_thumb_path(show) if which == 'banner': image_file_name = cache_obj.banner_path(show) if which == 'banner_thumb': image_file_name = cache_obj.banner_thumb_path(show) if ek.ek(os.path.isfile, image_file_name): static_image_path = os.path.normpath(image_file_name.replace(sickbeard.CACHE_DIR, '/cache')) static_image_path = static_image_path.replace('\\', '/') return self.redirect(static_image_path) def setHomeLayout(self, layout): if layout not in ('poster', 'small', 'banner', 'simple'): layout = 'poster' sickbeard.HOME_LAYOUT = layout return self.redirect("/home/") def setPosterSortBy(self, sort): if sort not in ('name', 'date', 'network', 'progress'): sort = 'name' sickbeard.POSTER_SORTBY = sort sickbeard.save_config() def setPosterSortDir(self, direction): sickbeard.POSTER_SORTDIR = int(direction) sickbeard.save_config() def setHistoryLayout(self, layout): if layout not in ('compact', 'detailed'): layout = 'detailed' sickbeard.HISTORY_LAYOUT = layout return self.redirect("/history/") def toggleDisplayShowSpecials(self, show): sickbeard.DISPLAY_SHOW_SPECIALS = not sickbeard.DISPLAY_SHOW_SPECIALS return self.redirect("/home/displayShow?show=" + show) def setComingEpsLayout(self, layout): if layout not in ('poster', 'banner', 'list', 'calendar'): layout = 'banner' if layout == 'calendar': sickbeard.COMING_EPS_SORT = 'date' sickbeard.COMING_EPS_LAYOUT = layout return self.redirect("/comingEpisodes/") def toggleComingEpsDisplayPaused(self): sickbeard.COMING_EPS_DISPLAY_PAUSED = not sickbeard.COMING_EPS_DISPLAY_PAUSED return self.redirect("/comingEpisodes/") def setComingEpsSort(self, sort): if sort not in ('date', 'network', 'show'): sort = 'date' if sickbeard.COMING_EPS_LAYOUT == 'calendar': sort \ = 'date' sickbeard.COMING_EPS_SORT = sort return self.redirect("/comingEpisodes/") def comingEpisodes(self, layout="None"): today1 = datetime.date.today() today = today1.toordinal() next_week1 = (datetime.date.today() + datetime.timedelta(days=7)) next_week = next_week1.toordinal() recently = (datetime.date.today() - datetime.timedelta(days=sickbeard.COMING_EPS_MISSED_RANGE)).toordinal() done_show_list = [] qualList = Quality.DOWNLOADED + Quality.SNATCHED + [ARCHIVED, IGNORED] myDB = db.DBConnection() sql_results = myDB.select( "SELECT *, tv_shows.status AS show_status FROM tv_episodes, tv_shows WHERE season != 0 AND airdate >= ? AND airdate < ? AND tv_shows.indexer_id = tv_episodes.showid AND tv_episodes.status NOT IN (" + ','.join( ['?'] * len(qualList)) + ")", [today, next_week] + qualList) for cur_result in sql_results: done_show_list.append(int(cur_result["showid"])) more_sql_results = myDB.select( "SELECT *, tv_shows.status AS show_status FROM tv_episodes outer_eps, tv_shows WHERE season != 0 AND showid NOT IN (" + ','.join( ['?'] * len( done_show_list)) + ") AND tv_shows.indexer_id = outer_eps.showid AND airdate = (SELECT airdate FROM tv_episodes inner_eps WHERE inner_eps.season != 0 AND inner_eps.showid = outer_eps.showid AND inner_eps.airdate >= ? ORDER BY inner_eps.airdate ASC LIMIT 1) AND outer_eps.status NOT IN (" + ','.join( ['?'] * len(Quality.DOWNLOADED + Quality.SNATCHED)) + ")", done_show_list + [next_week] + Quality.DOWNLOADED + Quality.SNATCHED) sql_results += more_sql_results more_sql_results = myDB.select( "SELECT *, tv_shows.status AS show_status FROM tv_episodes, tv_shows WHERE season != 0 AND tv_shows.indexer_id = tv_episodes.showid AND airdate < ? AND airdate >= ? AND tv_episodes.status = ? AND tv_episodes.status NOT IN (" + ','.join( ['?'] * len(qualList)) + ")", [today, recently, WANTED] + qualList) sql_results += more_sql_results # sort by localtime sorts = { 'date': (lambda x, y: cmp(x["localtime"], y["localtime"])), 'show': (lambda a, b: cmp((a["show_name"], a["localtime"]), (b["show_name"], b["localtime"]))), 'network': (lambda a, b: cmp((a["network"], a["localtime"]), (b["network"], b["localtime"]))), } # make a dict out of the sql results sql_results = [dict(row) for row in sql_results] # add localtime to the dict for index, item in enumerate(sql_results): sql_results[index]['localtime'] = sbdatetime.sbdatetime.convert_to_setting( network_timezones.parse_date_time(item['airdate'], item['airs'], item['network'])) sql_results.sort(sorts[sickbeard.COMING_EPS_SORT]) t = PageTemplate(rh=self, file="comingEpisodes.tmpl") # paused_item = { 'title': '', 'path': 'toggleComingEpsDisplayPaused' } # paused_item['title'] = 'Hide Paused' if sickbeard.COMING_EPS_DISPLAY_PAUSED else 'Show Paused' paused_item = {'title': 'View Paused:', 'path': {'': ''}} paused_item['path'] = {'Hide': 'toggleComingEpsDisplayPaused'} if sickbeard.COMING_EPS_DISPLAY_PAUSED else { 'Show': 'toggleComingEpsDisplayPaused'} t.submenu = [ {'title': 'Sort by:', 'path': {'Date': 'setComingEpsSort/?sort=date', 'Show': 'setComingEpsSort/?sort=show', 'Network': 'setComingEpsSort/?sort=network', }}, {'title': 'Layout:', 'path': {'Banner': 'setComingEpsLayout/?layout=banner', 'Poster': 'setComingEpsLayout/?layout=poster', 'List': 'setComingEpsLayout/?layout=list', 'Calendar': 'setComingEpsLayout/?layout=calendar', }}, paused_item, ] t.next_week = datetime.datetime.combine(next_week1, datetime.time(tzinfo=network_timezones.sb_timezone)) t.today = datetime.datetime.now().replace(tzinfo=network_timezones.sb_timezone) t.sql_results = sql_results # Allow local overriding of layout parameter if layout and layout in ('poster', 'banner', 'list', 'calendar'): t.layout = layout else: t.layout = sickbeard.COMING_EPS_LAYOUT return t.respond() class CalendarHandler(BaseHandler): def get(self, *args, **kwargs): if sickbeard.CALENDAR_UNPROTECTED: self.write(self.calendar()) else: self.calendar_auth() @authenticated def calendar_auth(self): self.write(self.calendar()) # Raw iCalendar implementation by Pedro Jose Pereira Vieito (@pvieito). # # iCalendar (iCal) - Standard RFC 5545 <http://tools.ietf.org/html/rfc5546> # Works with iCloud, Google Calendar and Outlook. def calendar(self): """ Provides a subscribeable URL for iCal subscriptions """ logger.log(u"Receiving iCal request from %s" % self.request.remote_ip) # Create a iCal string ical = 'BEGIN:VCALENDAR\r\n' ical += 'VERSION:2.0\r\n' ical += 'X-WR-CALNAME:SickRage\r\n' ical += 'X-WR-CALDESC:SickRage\r\n' ical += 'PRODID://Sick-Beard Upcoming Episodes//\r\n' # Limit dates past_date = (datetime.date.today() + datetime.timedelta(weeks=-52)).toordinal() future_date = (datetime.date.today() + datetime.timedelta(weeks=52)).toordinal() # Get all the shows that are not paused and are currently on air (from kjoconnor Fork) myDB = db.DBConnection() calendar_shows = myDB.select( "SELECT show_name, indexer_id, network, airs, runtime FROM tv_shows WHERE ( status = 'Continuing' OR status = 'Returning Series' ) AND paused != '1'") for show in calendar_shows: # Get all episodes of this show airing between today and next month episode_list = myDB.select( "SELECT indexerid, name, season, episode, description, airdate FROM tv_episodes WHERE airdate >= ? AND airdate < ? AND showid = ?", (past_date, future_date, int(show["indexer_id"]))) utc = tz.gettz('GMT') for episode in episode_list: air_date_time = network_timezones.parse_date_time(episode['airdate'], show["airs"], show['network']).astimezone(utc) air_date_time_end = air_date_time + datetime.timedelta( minutes=helpers.tryInt(show["runtime"], 60)) # Create event for episode ical = ical + 'BEGIN:VEVENT\r\n' ical = ical + 'DTSTART:' + air_date_time.strftime("%Y%m%d") + 'T' + air_date_time.strftime( "%H%M%S") + 'Z\r\n' ical = ical + 'DTEND:' + air_date_time_end.strftime( "%Y%m%d") + 'T' + air_date_time_end.strftime( "%H%M%S") + 'Z\r\n' ical = ical + 'SUMMARY:' + show['show_name'] + ' - ' + str( episode['season']) + "x" + str(episode['episode']) + " - " + episode['name'] + '\r\n' ical = ical + 'UID:Sick-Beard-' + str(datetime.date.today().isoformat()) + '-' + show[ 'show_name'].replace(" ", "-") + '-E' + str(episode['episode']) + 'S' + str( episode['season']) + '\r\n' if episode['description']: ical = ical + 'DESCRIPTION: {0} on {1} \\n\\n {2}\r\n'.format( (show['airs'] or '(Unknown airs)'), (show['network'] or 'Unknown network'), episode['description'].splitlines()[0]) else: ical = ical + 'DESCRIPTION:' + (show['airs'] or '(Unknown airs)') + ' on ' + ( show['network'] or 'Unknown network') + '\r\n' ical = ical + 'END:VEVENT\r\n' # Ending the iCal ical += 'END:VCALENDAR' return ical @route('/ui(/?.*)') class UI(WebRoot): def __init__(self, *args, **kwargs): super(UI, self).__init__(*args, **kwargs) def add_message(self): ui.notifications.message('Test 1', 'This is test number 1') ui.notifications.error('Test 2', 'This is test number 2') return "ok" def get_messages(self): messages = {} cur_notification_num = 1 for cur_notification in ui.notifications.get_notifications(self.request.remote_ip): messages['notification-' + str(cur_notification_num)] = {'title': cur_notification.title, 'message': cur_notification.message, 'type': cur_notification.type} cur_notification_num += 1 return json.dumps(messages) @route('/browser(/?.*)') class WebFileBrowser(WebRoot): def __init__(self, *args, **kwargs): super(WebFileBrowser, self).__init__(*args, **kwargs) def index(self, path='', includeFiles=False, *args, **kwargs): self.set_header("Content-Type", "application/json") return json.dumps(foldersAtPath(path, True, bool(int(includeFiles)))) def complete(self, term, includeFiles=0, *args, **kwargs): self.set_header("Content-Type", "application/json") paths = [entry['path'] for entry in foldersAtPath(os.path.dirname(term), includeFiles=bool(int(includeFiles))) if 'path' in entry] return json.dumps(paths) @route('/home(/?.*)') class Home(WebRoot): def __init__(self, *args, **kwargs): super(Home, self).__init__(*args, **kwargs) def HomeMenu(self): menu = [ {'title': 'Add Shows', 'path': 'home/addShows/', }, {'title': 'Manual Post-Processing', 'path': 'home/postprocess/'}, {'title': 'Update KODI', 'path': 'home/updateKODI/', 'requires': self.haveKODI}, {'title': 'Update Plex', 'path': 'home/updatePLEX/', 'requires': self.havePLEX}, {'title': 'Manage Torrents', 'path': 'manage/manageTorrents/', 'requires': self.haveTORRENT}, ] return menu def _genericMessage(self, subject, message): t = PageTemplate(rh=self, file="genericMessage.tmpl") t.submenu = self.HomeMenu() t.subject = subject t.message = message return t.respond() def _getEpisode(self, show, season=None, episode=None, absolute=None): if show is None: return "Invalid show parameters" showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj is None: return "Invalid show paramaters" if absolute: epObj = showObj.getEpisode(absolute_number=int(absolute)) elif season and episode: epObj = showObj.getEpisode(int(season), int(episode)) else: return "Invalid paramaters" if epObj is None: return "Episode couldn't be retrieved" return epObj def index(self): t = PageTemplate(rh=self, file="home.tmpl") if sickbeard.ANIME_SPLIT_HOME: shows = [] anime = [] for show in sickbeard.showList: if show.is_anime: anime.append(show) else: shows.append(show) t.showlists = [["Shows", shows], ["Anime", anime]] else: t.showlists = [["Shows", sickbeard.showList]] t.submenu = self.HomeMenu() return t.respond() def is_alive(self, *args, **kwargs): if 'callback' in kwargs and '_' in kwargs: callback, _ = kwargs['callback'], kwargs['_'] else: return "Error: Unsupported Request. Send jsonp request with 'callback' variable in the query string." # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') self.set_header('Content-Type', 'text/javascript') self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Headers', 'x-requested-with') if sickbeard.started: return callback + '(' + json.dumps( {"msg": str(sickbeard.PID)}) + ');' else: return callback + '(' + json.dumps({"msg": "nope"}) + ');' def haveKODI(self): return sickbeard.USE_KODI and sickbeard.KODI_UPDATE_LIBRARY def havePLEX(self): return sickbeard.USE_PLEX and sickbeard.PLEX_UPDATE_LIBRARY def haveTORRENT(self): if sickbeard.USE_TORRENTS and sickbeard.TORRENT_METHOD != 'blackhole' \ and (sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'https' or not sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'http:'): return True else: return False def testSABnzbd(self, host=None, username=None, password=None, apikey=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_url(host) connection, accesMsg = sab.getSabAccesMethod(host, username, password, apikey) if connection: authed, authMsg = sab.testAuthentication(host, username, password, apikey) # @UnusedVariable if authed: return "Success. Connected and authenticated" else: return "Authentication failed. SABnzbd expects '" + accesMsg + "' as authentication method" else: return "Unable to connect to host" def testTorrent(self, torrent_method=None, host=None, username=None, password=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_url(host) client = clients.getClientIstance(torrent_method) connection, accesMsg = client(host, username, password).testAuthentication() return accesMsg def testFreeMobile(self, freemobile_id=None, freemobile_apikey=None): result, message = notifiers.freemobile_notifier.test_notify(freemobile_id, freemobile_apikey) if result: return "SMS sent successfully" else: return "Problem sending SMS: " + message def testGrowl(self, host=None, password=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_host(host, default_port=23053) result = notifiers.growl_notifier.test_notify(host, password) if password is None or password == '': pw_append = '' else: pw_append = " with password: " + password if result: return "Registered and Tested growl successfully " + urllib.unquote_plus(host) + pw_append else: return "Registration and Testing of growl failed " + urllib.unquote_plus(host) + pw_append def testProwl(self, prowl_api=None, prowl_priority=0): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.prowl_notifier.test_notify(prowl_api, prowl_priority) if result: return "Test prowl notice sent successfully" else: return "Test prowl notice failed" def testBoxcar(self, username=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.boxcar_notifier.test_notify(username) if result: return "Boxcar notification succeeded. Check your Boxcar clients to make sure it worked" else: return "Error sending Boxcar notification" def testBoxcar2(self, accesstoken=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.boxcar2_notifier.test_notify(accesstoken) if result: return "Boxcar2 notification succeeded. Check your Boxcar2 clients to make sure it worked" else: return "Error sending Boxcar2 notification" def testPushover(self, userKey=None, apiKey=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.pushover_notifier.test_notify(userKey, apiKey) if result: return "Pushover notification succeeded. Check your Pushover clients to make sure it worked" else: return "Error sending Pushover notification" def twitterStep1(self): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') return notifiers.twitter_notifier._get_authorization() def twitterStep2(self, key): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.twitter_notifier._get_credentials(key) logger.log(u"result: " + str(result)) if result: return "Key verification successful" else: return "Unable to verify key" def testTwitter(self): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.twitter_notifier.test_notify() if result: return "Tweet successful, check your twitter to make sure it worked" else: return "Error sending tweet" def testKODI(self, host=None, username=None, password=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_hosts(host) finalResult = '' for curHost in [x.strip() for x in host.split(",")]: curResult = notifiers.kodi_notifier.test_notify(urllib.unquote_plus(curHost), username, password) if len(curResult.split(":")) > 2 and 'OK' in curResult.split(":")[2]: finalResult += "Test KODI notice sent successfully to " + urllib.unquote_plus(curHost) else: finalResult += "Test KODI notice failed to " + urllib.unquote_plus(curHost) finalResult += "<br />\n" return finalResult def testPLEX(self, host=None, username=None, password=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') finalResult = '' for curHost in [x.strip() for x in host.split(",")]: curResult = notifiers.plex_notifier.test_notify(urllib.unquote_plus(curHost), username, password) if len(curResult.split(":")) > 2 and 'OK' in curResult.split(":")[2]: finalResult += "Test Plex notice sent successfully to " + urllib.unquote_plus(curHost) else: finalResult += "Test Plex notice failed to " + urllib.unquote_plus(curHost) finalResult += "<br />\n" return finalResult def testLibnotify(self): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') if notifiers.libnotify_notifier.test_notify(): return "Tried sending desktop notification via libnotify" else: return notifiers.libnotify.diagnose() def testNMJ(self, host=None, database=None, mount=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_host(host) result = notifiers.nmj_notifier.test_notify(urllib.unquote_plus(host), database, mount) if result: return "Successfully started the scan update" else: return "Test failed to start the scan update" def settingsNMJ(self, host=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_host(host) result = notifiers.nmj_notifier.notify_settings(urllib.unquote_plus(host)) if result: return '{"message": "Got settings from %(host)s", "database": "%(database)s", "mount": "%(mount)s"}' % { "host": host, "database": sickbeard.NMJ_DATABASE, "mount": sickbeard.NMJ_MOUNT} else: return '{"message": "Failed! Make sure your Popcorn is on and NMJ is running. (see Log & Errors -> Debug for detailed info)", "database": "", "mount": ""}' def testNMJv2(self, host=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_host(host) result = notifiers.nmjv2_notifier.test_notify(urllib.unquote_plus(host)) if result: return "Test notice sent successfully to " + urllib.unquote_plus(host) else: return "Test notice failed to " + urllib.unquote_plus(host) def settingsNMJv2(self, host=None, dbloc=None, instance=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_host(host) result = notifiers.nmjv2_notifier.notify_settings(urllib.unquote_plus(host), dbloc, instance) if result: return '{"message": "NMJ Database found at: %(host)s", "database": "%(database)s"}' % {"host": host, "database": sickbeard.NMJv2_DATABASE} else: return '{"message": "Unable to find NMJ Database at location: %(dbloc)s. Is the right location selected and PCH running?", "database": ""}' % { "dbloc": dbloc} def testTrakt(self, username=None, password=None, disable_ssl=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') if disable_ssl == 'true': disable_ssl = True else: disable_ssl = False return notifiers.trakt_notifier.test_notify(username, password, disable_ssl) def loadShowNotifyLists(self): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') myDB = db.DBConnection() rows = myDB.select("SELECT show_id, show_name, notify_list FROM tv_shows ORDER BY show_name ASC") data = {} size = 0 for r in rows: data[r['show_id']] = {'id': r['show_id'], 'name': r['show_name'], 'list': r['notify_list']} size += 1 data['_size'] = size return json.dumps(data) def saveShowNotifyList(self, show=None, emails=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') myDB = db.DBConnection() if myDB.action("UPDATE tv_shows SET notify_list = ? WHERE show_id = ?", [emails, show]): return 'OK' else: return 'ERROR: %s' % myDB.last_err def testEmail(self, host=None, port=None, smtp_from=None, use_tls=None, user=None, pwd=None, to=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') host = config.clean_host(host) if notifiers.email_notifier.test_notify(host, port, smtp_from, use_tls, user, pwd, to): return 'Test email sent successfully! Check inbox.' else: return 'ERROR: %s' % notifiers.email_notifier.last_err def testNMA(self, nma_api=None, nma_priority=0): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.nma_notifier.test_notify(nma_api, nma_priority) if result: return "Test NMA notice sent successfully" else: return "Test NMA notice failed" def testPushalot(self, authorizationToken=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.pushalot_notifier.test_notify(authorizationToken) if result: return "Pushalot notification succeeded. Check your Pushalot clients to make sure it worked" else: return "Error sending Pushalot notification" def testPushbullet(self, api=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.pushbullet_notifier.test_notify(api) if result: return "Pushbullet notification succeeded. Check your device to make sure it worked" else: return "Error sending Pushbullet notification" def getPushbulletDevices(self, api=None): # self.set_header('Cache-Control', 'max-age=0,no-cache,no-store') result = notifiers.pushbullet_notifier.get_devices(api) if result: return result else: return "Error sending Pushbullet notification" def shutdown(self, pid=None): if str(pid) != str(sickbeard.PID): return self.redirect("/home/") sickbeard.events.put(sickbeard.events.SystemEvent.SHUTDOWN) title = "Shutting down" message = "SickRage is shutting down..." return self._genericMessage(title, message) def restart(self, pid=None): if str(pid) != str(sickbeard.PID): return self.redirect("/home/") t = PageTemplate(rh=self, file="restart.tmpl") t.submenu = self.HomeMenu() # restart sickbeard.events.put(sickbeard.events.SystemEvent.RESTART) return t.respond() def updateCheck(self, pid=None): if str(pid) != str(sickbeard.PID): return self.redirect('/home/') sickbeard.versionCheckScheduler.action.check_for_new_version(force=True) return self.redirect('/home/') def update(self, pid=None): if str(pid) != str(sickbeard.PID): return self.redirect('/home/') if sickbeard.versionCheckScheduler.action.update(): # do a hard restart sickbeard.events.put(sickbeard.events.SystemEvent.RESTART) t = PageTemplate(rh=self, file="restart_bare.tmpl") return t.respond() else: return self._genericMessage("Update Failed", "Update wasn't successful, not restarting. Check your log for more information.") def branchCheckout(self, branch): sickbeard.BRANCH = branch ui.notifications.message('Checking out branch: ', branch) return self.update(sickbeard.PID) def displayShow(self, show=None): if show is None: return self._genericMessage("Error", "Invalid show ID") else: showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj is None: return self._genericMessage("Error", "Show not in show list") myDB = db.DBConnection() seasonResults = myDB.select( "SELECT DISTINCT season FROM tv_episodes WHERE showid = ? ORDER BY season DESC", [showObj.indexerid] ) sqlResults = myDB.select( "SELECT * FROM tv_episodes WHERE showid = ? ORDER BY season DESC, episode DESC", [showObj.indexerid] ) t = PageTemplate(rh=self, file="displayShow.tmpl") t.submenu = [{'title': 'Edit', 'path': 'home/editShow?show=%d' % showObj.indexerid}] try: t.showLoc = (showObj.location, True) except sickbeard.exceptions.ShowDirNotFoundException: t.showLoc = (showObj._location, False) show_message = '' if sickbeard.showQueueScheduler.action.isBeingAdded(showObj): show_message = 'This show is in the process of being downloaded - the info below is incomplete.' elif sickbeard.showQueueScheduler.action.isBeingUpdated(showObj): show_message = 'The information on this page is in the process of being updated.' elif sickbeard.showQueueScheduler.action.isBeingRefreshed(showObj): show_message = 'The episodes below are currently being refreshed from disk' elif sickbeard.showQueueScheduler.action.isBeingSubtitled(showObj): show_message = 'Currently downloading subtitles for this show' elif sickbeard.showQueueScheduler.action.isInRefreshQueue(showObj): show_message = 'This show is queued to be refreshed.' elif sickbeard.showQueueScheduler.action.isInUpdateQueue(showObj): show_message = 'This show is queued and awaiting an update.' elif sickbeard.showQueueScheduler.action.isInSubtitleQueue(showObj): show_message = 'This show is queued and awaiting subtitles download.' if not sickbeard.showQueueScheduler.action.isBeingAdded(showObj): if not sickbeard.showQueueScheduler.action.isBeingUpdated(showObj): t.submenu.append( {'title': 'Remove', 'path': 'home/deleteShow?show=%d' % showObj.indexerid, 'confirm': True}) t.submenu.append({'title': 'Re-scan files', 'path': 'home/refreshShow?show=%d' % showObj.indexerid}) t.submenu.append( {'title': 'Force Full Update', 'path': 'home/updateShow?show=%d&amp;force=1' % showObj.indexerid}) t.submenu.append({'title': 'Update show in KODI', 'path': 'home/updateKODI?showName=%s' % urllib.quote_plus( showObj.name.encode('utf-8')), 'requires': self.haveKODI}) t.submenu.append({'title': 'Preview Rename', 'path': 'home/testRename?show=%d' % showObj.indexerid}) if sickbeard.USE_SUBTITLES and not sickbeard.showQueueScheduler.action.isBeingSubtitled( showObj) and showObj.subtitles: t.submenu.append( {'title': 'Download Subtitles', 'path': 'home/subtitleShow?show=%d' % showObj.indexerid}) t.show = showObj t.sqlResults = sqlResults t.seasonResults = seasonResults t.show_message = show_message epCounts = {} epCats = {} epCounts[Overview.SKIPPED] = 0 epCounts[Overview.WANTED] = 0 epCounts[Overview.QUAL] = 0 epCounts[Overview.GOOD] = 0 epCounts[Overview.UNAIRED] = 0 epCounts[Overview.SNATCHED] = 0 for curResult in sqlResults: curEpCat = showObj.getOverview(int(curResult["status"] or -1)) if curEpCat: epCats[str(curResult["season"]) + "x" + str(curResult["episode"])] = curEpCat epCounts[curEpCat] += 1 def titler(x): return (helpers.remove_article(x), x)[not x or sickbeard.SORT_ARTICLE] if sickbeard.ANIME_SPLIT_HOME: shows = [] anime = [] for show in sickbeard.showList: if show.is_anime: anime.append(show) else: shows.append(show) t.sortedShowLists = [["Shows", sorted(shows, lambda x, y: cmp(titler(x.name), titler(y.name)))], ["Anime", sorted(anime, lambda x, y: cmp(titler(x.name), titler(y.name)))]] else: t.sortedShowLists = [ ["Shows", sorted(sickbeard.showList, lambda x, y: cmp(titler(x.name), titler(y.name)))]] t.bwl = None if showObj.is_anime: t.bwl = BlackAndWhiteList(showObj.indexerid) t.epCounts = epCounts t.epCats = epCats showObj.exceptions = scene_exceptions.get_scene_exceptions(showObj.indexerid) indexerid = int(showObj.indexerid) indexer = int(showObj.indexer) t.all_scene_exceptions = showObj.exceptions t.scene_numbering = get_scene_numbering_for_show(indexerid, indexer) t.xem_numbering = get_xem_numbering_for_show(indexerid, indexer) t.scene_absolute_numbering = get_scene_absolute_numbering_for_show(indexerid, indexer) t.xem_absolute_numbering = get_xem_absolute_numbering_for_show(indexerid, indexer) return t.respond() def plotDetails(self, show, season, episode): myDB = db.DBConnection() result = myDB.selectOne( "SELECT description FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?", (int(show), int(season), int(episode))) return result['description'] if result else 'Episode not found.' def sceneExceptions(self, show): exceptionsList = sickbeard.scene_exceptions.get_all_scene_exceptions(show) if not exceptionsList: return "No scene exceptions" out = [] for season, names in iter(sorted(exceptionsList.iteritems())): if season == -1: season = "*" out.append("S" + str(season) + ": " + ", ".join(names)) return "<br/>".join(out) def editShow(self, show=None, location=None, anyQualities=[], bestQualities=[], exceptions_list=[], flatten_folders=None, paused=None, directCall=False, air_by_date=None, sports=None, dvdorder=None, indexerLang=None, subtitles=None, archive_firstmatch=None, rls_ignore_words=None, rls_require_words=None, anime=None, blackWords=None, whiteWords=None, blacklist=None, whitelist=None, scene=None, defaultEpStatus=None): if show is None: errString = "Invalid show ID: " + str(show) if directCall: return [errString] else: return self._genericMessage("Error", errString) showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if not showObj: errString = "Unable to find the specified show: " + str(show) if directCall: return [errString] else: return self._genericMessage("Error", errString) showObj.exceptions = scene_exceptions.get_scene_exceptions(showObj.indexerid) if not location and not anyQualities and not bestQualities and not flatten_folders: t = PageTemplate(rh=self, file="editShow.tmpl") t.submenu = self.HomeMenu() if showObj.is_anime: bwl = BlackAndWhiteList(showObj.indexerid) t.whiteWords = "" if "global" in bwl.whiteDict: t.whiteWords = ", ".join(bwl.whiteDict["global"]) t.blackWords = "" if "global" in bwl.blackDict: t.blackWords = ", ".join(bwl.blackDict["global"]) t.whitelist = [] if bwl.whiteDict.has_key("release_group"): t.whitelist = bwl.whiteDict["release_group"] t.blacklist = [] if bwl.blackDict.has_key("release_group"): t.blacklist = bwl.blackDict["release_group"] t.groups = [] if helpers.set_up_anidb_connection(): anime = adba.Anime(sickbeard.ADBA_CONNECTION, name=showObj.name) t.groups = anime.get_groups() with showObj.lock: t.show = showObj t.scene_exceptions = get_scene_exceptions(showObj.indexerid) return t.respond() flatten_folders = config.checkbox_to_value(flatten_folders) dvdorder = config.checkbox_to_value(dvdorder) archive_firstmatch = config.checkbox_to_value(archive_firstmatch) paused = config.checkbox_to_value(paused) air_by_date = config.checkbox_to_value(air_by_date) scene = config.checkbox_to_value(scene) sports = config.checkbox_to_value(sports) anime = config.checkbox_to_value(anime) subtitles = config.checkbox_to_value(subtitles) if indexerLang and indexerLang in sickbeard.indexerApi(showObj.indexer).indexer().config['valid_languages']: indexer_lang = indexerLang else: indexer_lang = showObj.lang # if we changed the language then kick off an update if indexer_lang == showObj.lang: do_update = False else: do_update = True if scene == showObj.scene and anime == showObj.anime: do_update_scene_numbering = False else: do_update_scene_numbering = True if type(anyQualities) != list: anyQualities = [anyQualities] if type(bestQualities) != list: bestQualities = [bestQualities] if type(exceptions_list) != list: exceptions_list = [exceptions_list] # If directCall from mass_edit_update no scene exceptions handling or blackandwhite list handling if directCall: do_update_exceptions = False else: if set(exceptions_list) == set(showObj.exceptions): do_update_exceptions = False else: do_update_exceptions = True if showObj.is_anime: bwl = BlackAndWhiteList(showObj.indexerid) if whitelist: whitelist = whitelist.split(",") shortWhiteList = [] if helpers.set_up_anidb_connection(): for groupName in whitelist: group = sickbeard.ADBA_CONNECTION.group(gname=groupName) for line in group.datalines: if line["shortname"]: shortWhiteList.append(line["shortname"]) else: if not groupName in shortWhiteList: shortWhiteList.append(groupName) else: shortWhiteList = whitelist bwl.set_white_keywords_for("release_group", shortWhiteList) else: bwl.set_white_keywords_for("release_group", []) if blacklist: blacklist = blacklist.split(",") shortBlacklist = [] if helpers.set_up_anidb_connection(): for groupName in blacklist: group = sickbeard.ADBA_CONNECTION.group(gname=groupName) for line in group.datalines: if line["shortname"]: shortBlacklist.append(line["shortname"]) else: if not groupName in shortBlacklist: shortBlacklist.append(groupName) else: shortBlacklist = blacklist bwl.set_black_keywords_for("release_group", shortBlacklist) else: bwl.set_black_keywords_for("release_group", []) if whiteWords: whiteWords = [x.strip() for x in whiteWords.split(",")] bwl.set_white_keywords_for("global", whiteWords) else: bwl.set_white_keywords_for("global", []) if blackWords: blackWords = [x.strip() for x in blackWords.split(",")] bwl.set_black_keywords_for("global", blackWords) else: bwl.set_black_keywords_for("global", []) errors = [] with showObj.lock: newQuality = Quality.combineQualities(map(int, anyQualities), map(int, bestQualities)) showObj.quality = newQuality showObj.archive_firstmatch = archive_firstmatch # reversed for now if bool(showObj.flatten_folders) != bool(flatten_folders): showObj.flatten_folders = flatten_folders try: sickbeard.showQueueScheduler.action.refreshShow(showObj) except exceptions.CantRefreshException, e: errors.append("Unable to refresh this show: " + ex(e)) showObj.paused = paused showObj.scene = scene showObj.anime = anime showObj.sports = sports showObj.subtitles = subtitles showObj.air_by_date = air_by_date showObj.default_ep_status = int(defaultEpStatus) if not directCall: showObj.lang = indexer_lang showObj.dvdorder = dvdorder showObj.rls_ignore_words = rls_ignore_words.strip() showObj.rls_require_words = rls_require_words.strip() # if we change location clear the db of episodes, change it, write to db, and rescan if os.path.normpath(showObj._location) != os.path.normpath(location): logger.log(os.path.normpath(showObj._location) + " != " + os.path.normpath(location), logger.DEBUG) if not ek.ek(os.path.isdir, location) and not sickbeard.CREATE_MISSING_SHOW_DIRS: errors.append("New location <tt>%s</tt> does not exist" % location) # don't bother if we're going to update anyway elif not do_update: # change it try: showObj.location = location try: sickbeard.showQueueScheduler.action.refreshShow(showObj) except exceptions.CantRefreshException, e: errors.append("Unable to refresh this show:" + ex(e)) # grab updated info from TVDB # showObj.loadEpisodesFromIndexer() # rescan the episodes in the new folder except exceptions.NoNFOException: errors.append( "The folder at <tt>%s</tt> doesn't contain a tvshow.nfo - copy your files to that folder before you change the directory in SickRage." % location) # save it to the DB showObj.saveToDB() # force the update if do_update: try: sickbeard.showQueueScheduler.action.updateShow(showObj, True) time.sleep(cpu_presets[sickbeard.CPU_PRESET]) except exceptions.CantUpdateException, e: errors.append("Unable to force an update on the show.") if do_update_exceptions: try: scene_exceptions.update_scene_exceptions(showObj.indexerid, exceptions_list) # @UndefinedVdexerid) time.sleep(cpu_presets[sickbeard.CPU_PRESET]) except exceptions.CantUpdateException, e: errors.append("Unable to force an update on scene exceptions of the show.") if do_update_scene_numbering: try: sickbeard.scene_numbering.xem_refresh(showObj.indexerid, showObj.indexer) time.sleep(cpu_presets[sickbeard.CPU_PRESET]) except exceptions.CantUpdateException, e: errors.append("Unable to force an update on scene numbering of the show.") if directCall: return errors if len(errors) > 0: ui.notifications.error('%d error%s while saving changes:' % (len(errors), "" if len(errors) == 1 else "s"), '<ul>' + '\n'.join(['<li>%s</li>' % error for error in errors]) + "</ul>") return self.redirect("/home/displayShow?show=" + show) def deleteShow(self, show=None, full=0): if show is None: return self._genericMessage("Error", "Invalid show ID") showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj is None: return self._genericMessage("Error", "Unable to find the specified show") if sickbeard.showQueueScheduler.action.isBeingAdded( showObj) or sickbeard.showQueueScheduler.action.isBeingUpdated(showObj): return self._genericMessage("Error", "Shows can't be deleted while they're being added or updated.") if sickbeard.USE_TRAKT and sickbeard.TRAKT_SYNC: # remove show from trakt.tv library sickbeard.traktCheckerScheduler.action.removeShowFromTraktLibrary(showObj) showObj.deleteShow(bool(full)) ui.notifications.message('<b>%s</b> has been %s %s' % (showObj.name, ('deleted', 'trashed')[sickbeard.TRASH_REMOVE_SHOW], ('(media untouched)', '(with all related media)')[bool(full)])) return self.redirect("/home/") def refreshShow(self, show=None): if show is None: return self._genericMessage("Error", "Invalid show ID") showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj is None: return self._genericMessage("Error", "Unable to find the specified show") # force the update from the DB try: sickbeard.showQueueScheduler.action.refreshShow(showObj) except exceptions.CantRefreshException, e: ui.notifications.error("Unable to refresh this show.", ex(e)) time.sleep(cpu_presets[sickbeard.CPU_PRESET]) return self.redirect("/home/displayShow?show=" + str(showObj.indexerid)) def updateShow(self, show=None, force=0): if show is None: return self._genericMessage("Error", "Invalid show ID") showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj is None: return self._genericMessage("Error", "Unable to find the specified show") # force the update try: sickbeard.showQueueScheduler.action.updateShow(showObj, bool(force)) except exceptions.CantUpdateException, e: ui.notifications.error("Unable to update this show.", ex(e)) # just give it some time time.sleep(cpu_presets[sickbeard.CPU_PRESET]) return self.redirect("/home/displayShow?show=" + str(showObj.indexerid)) def subtitleShow(self, show=None, force=0): if show is None: return self._genericMessage("Error", "Invalid show ID") showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj is None: return self._genericMessage("Error", "Unable to find the specified show") # search and download subtitles sickbeard.showQueueScheduler.action.downloadSubtitles(showObj, bool(force)) time.sleep(cpu_presets[sickbeard.CPU_PRESET]) return self.redirect("/home/displayShow?show=" + str(showObj.indexerid)) def updateKODI(self, showName=None): # only send update to first host in the list -- workaround for kodi sql backend users if sickbeard.KODI_UPDATE_ONLYFIRST: # only send update to first host in the list -- workaround for kodi sql backend users host = sickbeard.KODI_HOST.split(",")[0].strip() else: host = sickbeard.KODI_HOST if notifiers.kodi_notifier.update_library(showName=showName): ui.notifications.message("Library update command sent to KODI host(s): " + host) else: ui.notifications.error("Unable to contact one or more KODI host(s): " + host) return self.redirect('/home/') def updatePLEX(self): if notifiers.plex_notifier.update_library(): ui.notifications.message( "Library update command sent to Plex Media Server host: " + sickbeard.PLEX_SERVER_HOST) else: ui.notifications.error("Unable to contact Plex Media Server host: " + sickbeard.PLEX_SERVER_HOST) return self.redirect('/home/') def setStatus(self, show=None, eps=None, status=None, direct=False): if show is None or eps is None or status is None: errMsg = "You must specify a show and at least one episode" if direct: ui.notifications.error('Error', errMsg) return json.dumps({'result': 'error'}) else: return self._genericMessage("Error", errMsg) if not statusStrings.has_key(int(status)): errMsg = "Invalid status" if direct: ui.notifications.error('Error', errMsg) return json.dumps({'result': 'error'}) else: return self._genericMessage("Error", errMsg) showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj is None: errMsg = "Error", "Show not in show list" if direct: ui.notifications.error('Error', errMsg) return json.dumps({'result': 'error'}) else: return self._genericMessage("Error", errMsg) segments = {} if eps is not None: sql_l = [] for curEp in eps.split('|'): logger.log(u"Attempting to set status on episode " + curEp + " to " + status, logger.DEBUG) epInfo = curEp.split('x') epObj = showObj.getEpisode(int(epInfo[0]), int(epInfo[1])) if epObj is None: return self._genericMessage("Error", "Episode couldn't be retrieved") if int(status) in [WANTED, FAILED]: # figure out what episodes are wanted so we can backlog them if epObj.season in segments: segments[epObj.season].append(epObj) else: segments[epObj.season] = [epObj] with epObj.lock: # don't let them mess up UNAIRED episodes if epObj.status == UNAIRED: logger.log(u"Refusing to change status of " + curEp + " because it is UNAIRED", logger.ERROR) continue if int( status) in Quality.DOWNLOADED and epObj.status not in Quality.SNATCHED + Quality.SNATCHED_PROPER + Quality.DOWNLOADED + [ IGNORED] and not ek.ek(os.path.isfile, epObj.location): logger.log( u"Refusing to change status of " + curEp + " to DOWNLOADED because it's not SNATCHED/DOWNLOADED", logger.ERROR) continue if int( status) == FAILED and epObj.status not in Quality.SNATCHED + Quality.SNATCHED_PROPER + Quality.DOWNLOADED: logger.log( u"Refusing to change status of " + curEp + " to FAILED because it's not SNATCHED/DOWNLOADED", logger.ERROR) continue epObj.status = int(status) # mass add to database sql_l.append(epObj.get_sql()) if len(sql_l) > 0: myDB = db.DBConnection() myDB.mass_action(sql_l) if int(status) == WANTED: msg = "Backlog was automatically started for the following seasons of <b>" + showObj.name + "</b>:<br />" msg += '<ul>' for season, segment in segments.items(): cur_backlog_queue_item = search_queue.BacklogQueueItem(showObj, segment) sickbeard.searchQueueScheduler.action.add_item(cur_backlog_queue_item) msg += "<li>Season " + str(season) + "</li>" logger.log(u"Sending backlog for " + showObj.name + " season " + str( season) + " because some eps were set to wanted") msg += "</ul>" if segments: ui.notifications.message("Backlog started", msg) if int(status) == FAILED: msg = "Retrying Search was automatically started for the following season of <b>" + showObj.name + "</b>:<br />" msg += '<ul>' for season, segment in segments.items(): cur_failed_queue_item = search_queue.FailedQueueItem(showObj, segment) sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item) msg += "<li>Season " + str(season) + "</li>" logger.log(u"Retrying Search for " + showObj.name + " season " + str( season) + " because some eps were set to failed") msg += "</ul>" if segments: ui.notifications.message("Retry Search started", msg) if direct: return json.dumps({'result': 'success'}) else: return self.redirect("/home/displayShow?show=" + show) def testRename(self, show=None): if show is None: return self._genericMessage("Error", "You must specify a show") showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj is None: return self._genericMessage("Error", "Show not in show list") try: show_loc = showObj.location # @UnusedVariable except exceptions.ShowDirNotFoundException: return self._genericMessage("Error", "Can't rename episodes when the show dir is missing.") ep_obj_rename_list = [] ep_obj_list = showObj.getAllEpisodes(has_location=True) for cur_ep_obj in ep_obj_list: # Only want to rename if we have a location if cur_ep_obj.location: if cur_ep_obj.relatedEps: # do we have one of multi-episodes in the rename list already have_already = False for cur_related_ep in cur_ep_obj.relatedEps + [cur_ep_obj]: if cur_related_ep in ep_obj_rename_list: have_already = True break if not have_already: ep_obj_rename_list.append(cur_ep_obj) else: ep_obj_rename_list.append(cur_ep_obj) if ep_obj_rename_list: # present season DESC episode DESC on screen ep_obj_rename_list.reverse() t = PageTemplate(rh=self, file="testRename.tmpl") t.submenu = [{'title': 'Edit', 'path': 'home/editShow?show=%d' % showObj.indexerid}] t.ep_obj_list = ep_obj_rename_list t.show = showObj return t.respond() def doRename(self, show=None, eps=None): if show is None or eps is None: errMsg = "You must specify a show and at least one episode" return self._genericMessage("Error", errMsg) show_obj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if show_obj is None: errMsg = "Error", "Show not in show list" return self._genericMessage("Error", errMsg) try: show_loc = show_obj.location # @UnusedVariable except exceptions.ShowDirNotFoundException: return self._genericMessage("Error", "Can't rename episodes when the show dir is missing.") if eps is None: return self.redirect("/home/displayShow?show=" + show) myDB = db.DBConnection() for curEp in eps.split('|'): epInfo = curEp.split('x') # this is probably the worst possible way to deal with double eps but I've kinda painted myself into a corner here with this stupid database ep_result = myDB.select( "SELECT * FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ? AND 5=5", [show, epInfo[0], epInfo[1]]) if not ep_result: logger.log(u"Unable to find an episode for " + curEp + ", skipping", logger.WARNING) continue related_eps_result = myDB.select("SELECT * FROM tv_episodes WHERE location = ? AND episode != ?", [ep_result[0]["location"], epInfo[1]]) root_ep_obj = show_obj.getEpisode(int(epInfo[0]), int(epInfo[1])) root_ep_obj.relatedEps = [] for cur_related_ep in related_eps_result: related_ep_obj = show_obj.getEpisode(int(cur_related_ep["season"]), int(cur_related_ep["episode"])) if related_ep_obj not in root_ep_obj.relatedEps: root_ep_obj.relatedEps.append(related_ep_obj) root_ep_obj.rename() return self.redirect("/home/displayShow?show=" + show) def searchEpisode(self, show=None, season=None, episode=None): # retrieve the episode object and fail if we can't get one ep_obj = self._getEpisode(show, season, episode) if isinstance(ep_obj, str): return json.dumps({'result': 'failure'}) # make a queue item for it and put it on the queue ep_queue_item = search_queue.ManualSearchQueueItem(ep_obj.show, ep_obj) sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) if not ep_queue_item.started and ep_queue_item.success is None: return json.dumps( {'result': 'success'}) # I Actually want to call it queued, because the search hasnt been started yet! if ep_queue_item.started and ep_queue_item.success is None: return json.dumps({'result': 'success'}) else: return json.dumps({'result': 'failure'}) ### Returns the current ep_queue_item status for the current viewed show. # Possible status: Downloaded, Snatched, etc... # Returns {'show': 279530, 'episodes' : ['episode' : 6, 'season' : 1, 'searchstatus' : 'queued', 'status' : 'running', 'quality': '4013'] def getManualSearchStatus(self, show=None, season=None): def getEpisodes(searchThread, searchstatus): results = [] if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem): results.append({'episode': searchThread.segment.episode, 'episodeindexid': searchThread.segment.indexerid, 'season': searchThread.segment.season, 'searchstatus': searchstatus, 'status': statusStrings[searchThread.segment.status], 'quality': self.getQualityClass(searchThread.segment)}) else: for epObj in searchThread.segment: results.append({'episode': epObj.episode, 'episodeindexid': epObj.indexerid, 'season': epObj.season, 'searchstatus': searchstatus, 'status': statusStrings[epObj.status], 'quality': self.getQualityClass(epObj)}) return results episodes = [] # Queued Searches searchstatus = 'queued' for searchThread in sickbeard.searchQueueScheduler.action.get_all_ep_from_queue(show): episodes += getEpisodes(searchThread, searchstatus) # Running Searches searchstatus = 'searching' if (sickbeard.searchQueueScheduler.action.is_manualsearch_in_progress()): searchThread = sickbeard.searchQueueScheduler.action.currentItem if searchThread.success: searchstatus = 'finished' episodes += getEpisodes(searchThread, searchstatus) # Finished Searches searchstatus = 'finished' for searchThread in sickbeard.search_queue.MANUAL_SEARCH_HISTORY: if not str(searchThread.show.indexerid) == show: continue if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem): if not [x for x in episodes if x['episodeindexid'] == searchThread.segment.indexerid]: episodes += getEpisodes(searchThread, searchstatus) else: ### These are only Failed Downloads/Retry SearchThreadItems.. lets loop through the segement/episodes if not [i for i, j in zip(searchThread.segment, episodes) if i.indexerid == j['episodeindexid']]: episodes += getEpisodes(searchThread, searchstatus) return json.dumps({'show': show, 'episodes': episodes}) def getQualityClass(self, ep_obj): # return the correct json value # Find the quality class for the episode quality_class = Quality.qualityStrings[Quality.UNKNOWN] ep_status, ep_quality = Quality.splitCompositeStatus(ep_obj.status) for x in (SD, HD720p, HD1080p): if ep_quality in Quality.splitQuality(x)[0]: quality_class = qualityPresetStrings[x] break return quality_class def searchEpisodeSubtitles(self, show=None, season=None, episode=None): # retrieve the episode object and fail if we can't get one ep_obj = self._getEpisode(show, season, episode) if isinstance(ep_obj, str): return json.dumps({'result': 'failure'}) # try do download subtitles for that episode previous_subtitles = set(subliminal.language.Language(x) for x in ep_obj.subtitles) try: ep_obj.subtitles = set(x.language for x in ep_obj.downloadSubtitles().values()[0]) except: return json.dumps({'result': 'failure'}) # return the correct json value if previous_subtitles != ep_obj.subtitles: status = 'New subtitles downloaded: %s' % ' '.join([ "<img src='" + sickbeard.WEB_ROOT + "/images/flags/" + x.alpha2 + ".png' alt='" + x.name + "'/>" for x in sorted(list(ep_obj.subtitles.difference(previous_subtitles)))]) else: status = 'No subtitles downloaded' ui.notifications.message('Subtitles Search', status) return json.dumps({'result': status, 'subtitles': ','.join(sorted([x.alpha2 for x in ep_obj.subtitles.union( previous_subtitles)]))}) def setSceneNumbering(self, show, indexer, forSeason=None, forEpisode=None, forAbsolute=None, sceneSeason=None, sceneEpisode=None, sceneAbsolute=None): # sanitize: if forSeason in ['null', '']: forSeason = None if forEpisode in ['null', '']: forEpisode = None if forAbsolute in ['null', '']: forAbsolute = None if sceneSeason in ['null', '']: sceneSeason = None if sceneEpisode in ['null', '']: sceneEpisode = None if sceneAbsolute in ['null', '']: sceneAbsolute = None showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(show)) if showObj.is_anime: result = { 'success': True, 'forAbsolute': forAbsolute, } else: result = { 'success': True, 'forSeason': forSeason, 'forEpisode': forEpisode, } # retrieve the episode object and fail if we can't get one if showObj.is_anime: ep_obj = self._getEpisode(show, absolute=forAbsolute) else: ep_obj = self._getEpisode(show, forSeason, forEpisode) if isinstance(ep_obj, str): result['success'] = False result['errorMessage'] = ep_obj elif showObj.is_anime: logger.log(u"setAbsoluteSceneNumbering for %s from %s to %s" % (show, forAbsolute, sceneAbsolute), logger.DEBUG) show = int(show) indexer = int(indexer) forAbsolute = int(forAbsolute) if sceneAbsolute is not None: sceneAbsolute = int(sceneAbsolute) set_scene_numbering(show, indexer, absolute_number=forAbsolute, sceneAbsolute=sceneAbsolute) else: logger.log(u"setEpisodeSceneNumbering for %s from %sx%s to %sx%s" % (show, forSeason, forEpisode, sceneSeason, sceneEpisode), logger.DEBUG) show = int(show) indexer = int(indexer) forSeason = int(forSeason) forEpisode = int(forEpisode) if sceneSeason is not None: sceneSeason = int(sceneSeason) if sceneEpisode is not None: sceneEpisode = int(sceneEpisode) set_scene_numbering(show, indexer, season=forSeason, episode=forEpisode, sceneSeason=sceneSeason, sceneEpisode=sceneEpisode) if showObj.is_anime: sn = get_scene_absolute_numbering(show, indexer, forAbsolute) if sn: result['sceneAbsolute'] = sn else: result['sceneAbsolute'] = None else: sn = get_scene_numbering(show, indexer, forSeason, forEpisode) if sn: (result['sceneSeason'], result['sceneEpisode']) = sn else: (result['sceneSeason'], result['sceneEpisode']) = (None, None) return json.dumps(result) def retryEpisode(self, show, season, episode): # retrieve the episode object and fail if we can't get one ep_obj = self._getEpisode(show, season, episode) if isinstance(ep_obj, str): return json.dumps({'result': 'failure'}) # make a queue item for it and put it on the queue ep_queue_item = search_queue.FailedQueueItem(ep_obj.show, [ep_obj]) sickbeard.searchQueueScheduler.action.add_item(ep_queue_item) if not ep_queue_item.started and ep_queue_item.success is None: return json.dumps( {'result': 'success'}) # I Actually want to call it queued, because the search hasnt been started yet! if ep_queue_item.started and ep_queue_item.success is None: return json.dumps({'result': 'success'}) else: return json.dumps({'result': 'failure'}) @route('/home/postprocess(/?.*)') class HomePostProcess(Home): def __init__(self, *args, **kwargs): super(HomePostProcess, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="home_postprocess.tmpl") t.submenu = self.HomeMenu() return t.respond() def processEpisode(self, dir=None, nzbName=None, jobName=None, quiet=None, process_method=None, force=None, is_priority=None, failed="0", type="auto", *args, **kwargs): if failed == "0": failed = False else: failed = True if force in ["on", "1"]: force = True else: force = False if is_priority in ["on", "1"]: is_priority = True else: is_priority = False if not dir: return self.redirect("/home/postprocess/") else: result = processTV.processDir(dir, nzbName, process_method=process_method, force=force, is_priority=is_priority, failed=failed, type=type) if quiet is not None and int(quiet) == 1: return result result = result.replace("\n", "<br />\n") return self._genericMessage("Postprocessing results", result) @route('/home/addShows(/?.*)') class HomeAddShows(Home): def __init__(self, *args, **kwargs): super(HomeAddShows, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="home_addShows.tmpl") t.submenu = self.HomeMenu() return t.respond() def getIndexerLanguages(self): result = sickbeard.indexerApi().config['valid_languages'] # Make sure list is sorted alphabetically but 'en' is in front if 'en' in result: del result[result.index('en')] result.sort() result.insert(0, 'en') return json.dumps({'results': result}) def sanitizeFileName(self, name): return helpers.sanitizeFileName(name) def searchIndexersForShowName(self, search_term, lang="en", indexer=None): if not lang or lang == 'null': lang = "en" search_term = search_term.encode('utf-8') results = {} final_results = [] # Query Indexers for each search term and build the list of results for indexer in sickbeard.indexerApi().indexers if not int(indexer) else [int(indexer)]: lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy() lINDEXER_API_PARMS['language'] = lang lINDEXER_API_PARMS['custom_ui'] = classes.AllShowsListUI t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS) logger.log("Searching for Show with searchterm: %s on Indexer: %s" % ( search_term, sickbeard.indexerApi(indexer).name), logger.DEBUG) try: # add search results results.setdefault(indexer, []).extend(t[search_term]) except Exception, e: continue map(final_results.extend, ([[sickbeard.indexerApi(id).name, id, sickbeard.indexerApi(id).config["show_url"], int(show['id']), show['seriesname'], show['firstaired']] for show in shows] for id, shows in results.items())) lang_id = sickbeard.indexerApi().config['langabbv_to_id'][lang] return json.dumps({'results': final_results, 'langid': lang_id}) def massAddTable(self, rootDir=None): t = PageTemplate(rh=self, file="home_massAddTable.tmpl") t.submenu = self.HomeMenu() if not rootDir: return "No folders selected." elif type(rootDir) != list: root_dirs = [rootDir] else: root_dirs = rootDir root_dirs = [urllib.unquote_plus(x) for x in root_dirs] if sickbeard.ROOT_DIRS: default_index = int(sickbeard.ROOT_DIRS.split('|')[0]) else: default_index = 0 if len(root_dirs) > default_index: tmp = root_dirs[default_index] if tmp in root_dirs: root_dirs.remove(tmp) root_dirs = [tmp] + root_dirs dir_list = [] myDB = db.DBConnection() for root_dir in root_dirs: try: file_list = ek.ek(os.listdir, root_dir) except: continue for cur_file in file_list: try: cur_path = ek.ek(os.path.normpath, ek.ek(os.path.join, root_dir, cur_file)) if not ek.ek(os.path.isdir, cur_path): continue except: continue cur_dir = { 'dir': cur_path, 'display_dir': '<b>' + ek.ek(os.path.dirname, cur_path) + os.sep + '</b>' + ek.ek( os.path.basename, cur_path), } # see if the folder is in KODI already dirResults = myDB.select("SELECT * FROM tv_shows WHERE location = ?", [cur_path]) if dirResults: cur_dir['added_already'] = True else: cur_dir['added_already'] = False dir_list.append(cur_dir) indexer_id = show_name = indexer = None for cur_provider in sickbeard.metadata_provider_dict.values(): if not (indexer_id and show_name): (indexer_id, show_name, indexer) = cur_provider.retrieveShowMetadata(cur_path) # default to TVDB if indexer was not detected if show_name and not (indexer or indexer_id): (sn, idx, id) = helpers.searchIndexerForShowID(show_name, indexer, indexer_id) # set indexer and indexer_id from found info if not indexer and idx: indexer = idx if not indexer_id and id: indexer_id = id cur_dir['existing_info'] = (indexer_id, show_name, indexer) if indexer_id and helpers.findCertainShow(sickbeard.showList, indexer_id): cur_dir['added_already'] = True t.dirList = dir_list return t.respond() def newShow(self, show_to_add=None, other_shows=None): """ Display the new show page which collects a tvdb id, folder, and extra options and posts them to addNewShow """ t = PageTemplate(rh=self, file="home_newShow.tmpl") t.submenu = self.HomeMenu() indexer, show_dir, indexer_id, show_name = self.split_extra_show(show_to_add) if indexer_id and indexer and show_name: use_provided_info = True else: use_provided_info = False # tell the template whether we're giving it show name & Indexer ID t.use_provided_info = use_provided_info # use the given show_dir for the indexer search if available if not show_dir: t.default_show_name = '' elif not show_name: t.default_show_name = re.sub(' \(\d{4}\)', '', ek.ek(os.path.basename, ek.ek(os.path.normpath, show_dir)).replace('.', ' ')) else: t.default_show_name = show_name # carry a list of other dirs if given if not other_shows: other_shows = [] elif type(other_shows) != list: other_shows = [other_shows] if use_provided_info: t.provided_indexer_id = int(indexer_id or 0) t.provided_indexer_name = show_name t.provided_show_dir = show_dir t.other_shows = other_shows t.provided_indexer = int(indexer or sickbeard.INDEXER_DEFAULT) t.indexers = sickbeard.indexerApi().indexers return t.respond() def recommendedShows(self): """ Display the new show page which collects a tvdb id, folder, and extra options and posts them to addNewShow """ t = PageTemplate(rh=self, file="home_recommendedShows.tmpl") t.submenu = self.HomeMenu() return t.respond() def getRecommendedShows(self): final_results = [] logger.log(u"Getting recommended shows from Trakt.tv", logger.DEBUG) trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY, sickbeard.TRAKT_TIMEOUT) try: recommendedlist = trakt_api.traktRequest("recommendations/shows?extended=full,images") if recommendedlist: indexers = ['tvdb', 'tvrage'] map(final_results.append, ( [int(show['ids'][indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]]), 'http://www.trakt.tv/shows/%s' % show['ids']['slug'], show['title'], show['overview'], None if show['first_aired'] is None else dateutil_parser.parse(show['first_aired']).strftime('%Y%m%d')] for show in recommendedlist if not helpers.findCertainShow(sickbeard.showList, [ int(show['ids'][indexers[sickbeard.TRAKT_DEFAULT_INDEXER - 1]])]))) except (traktException, traktAuthException, traktServerBusy) as e: logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING) return json.dumps({'results': final_results}) def addRecommendedShow(self, whichSeries=None, indexerLang="en", rootDir=None, defaultStatus=None, anyQualities=None, bestQualities=None, flatten_folders=None, subtitles=None, fullShowPath=None, other_shows=None, skipShow=None, providedIndexer=None, anime=None, scene=None): indexer = 1 indexer_name = sickbeard.indexerApi(int(indexer)).name show_url = whichSeries.split('|')[1] indexer_id = whichSeries.split('|')[0] show_name = whichSeries.split('|')[2] return self.addNewShow('|'.join([indexer_name, str(indexer), show_url, indexer_id, show_name, ""]), indexerLang, rootDir, defaultStatus, anyQualities, bestQualities, flatten_folders, subtitles, fullShowPath, other_shows, skipShow, providedIndexer, anime, scene) def trendingShows(self): """ Display the new show page which collects a tvdb id, folder, and extra options and posts them to addNewShow """ t = PageTemplate(rh=self, file="home_trendingShows.tmpl") t.submenu = self.HomeMenu() return t.respond() def getTrendingShows(self): """ Display the new show page which collects a tvdb id, folder, and extra options and posts them to addNewShow """ t = PageTemplate(rh=self, file="trendingShows.tmpl") t.submenu = self.HomeMenu() t.trending_shows = [] trakt_api = TraktAPI(sickbeard.TRAKT_API_KEY, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, sickbeard.TRAKT_DISABLE_SSL_VERIFY, sickbeard.TRAKT_TIMEOUT) try: shows = trakt_api.traktRequest("shows/trending?limit=50&extended=full,images") or [] for show in shows: try: tvdb_id = int(show['show']['ids']['tvdb']) tvrage_id = int(show['show']['ids']['tvrage'] or 0) if not helpers.findCertainShow(sickbeard.showList, [tvdb_id, tvrage_id]): t.trending_shows += [show] except exceptions.MultipleShowObjectsException: continue except (traktException, traktAuthException, traktServerBusy) as e: logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING) return t.respond() def existingShows(self): """ Prints out the page to add existing shows from a root dir """ t = PageTemplate(rh=self, file="home_addExistingShow.tmpl") t.submenu = self.HomeMenu() return t.respond() def addTraktShow(self, indexer_id, showName): if helpers.findCertainShow(sickbeard.showList, int(indexer_id)): return if sickbeard.ROOT_DIRS: root_dirs = sickbeard.ROOT_DIRS.split('|') location = root_dirs[int(root_dirs[0]) + 1] else: location = None if location: show_dir = ek.ek(os.path.join, location, helpers.sanitizeFileName(showName)) dir_exists = helpers.makeDir(show_dir) if not dir_exists: logger.log(u"Unable to create the folder " + show_dir + ", can't add the show", logger.ERROR) return else: helpers.chmodAsParent(show_dir) sickbeard.showQueueScheduler.action.addShow(1, int(indexer_id), show_dir, default_status=sickbeard.STATUS_DEFAULT, quality=sickbeard.QUALITY_DEFAULT, flatten_folders=sickbeard.FLATTEN_FOLDERS_DEFAULT, subtitles=sickbeard.SUBTITLES_DEFAULT, anime=sickbeard.ANIME_DEFAULT, scene=sickbeard.SCENE_DEFAULT) ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir) else: logger.log(u"There was an error creating the show, no root directory setting found", logger.ERROR) return "No root directories setup, please go back and add one." # done adding show return self.redirect('/home/') def addNewShow(self, whichSeries=None, indexerLang="en", rootDir=None, defaultStatus=None, anyQualities=None, bestQualities=None, flatten_folders=None, subtitles=None, fullShowPath=None, other_shows=None, skipShow=None, providedIndexer=None, anime=None, scene=None): """ Receive tvdb id, dir, and other options and create a show from them. If extra show dirs are provided then it forwards back to newShow, if not it goes to /home. """ # grab our list of other dirs if given if not other_shows: other_shows = [] elif type(other_shows) != list: other_shows = [other_shows] def finishAddShow(): # if there are no extra shows then go home if not other_shows: return self.redirect('/home/') # peel off the next one next_show_dir = other_shows[0] rest_of_show_dirs = other_shows[1:] # go to add the next show return self.newShow(next_show_dir, rest_of_show_dirs) # if we're skipping then behave accordingly if skipShow: return finishAddShow() # sanity check on our inputs if (not rootDir and not fullShowPath) or not whichSeries: return "Missing params, no Indexer ID or folder:" + repr(whichSeries) + " and " + repr( rootDir) + "/" + repr(fullShowPath) # figure out what show we're adding and where series_pieces = whichSeries.split('|') if (whichSeries and rootDir) or (whichSeries and fullShowPath and len(series_pieces) > 1): if len(series_pieces) < 6: logger.log("Unable to add show due to show selection. Not anough arguments: %s" % (repr(series_pieces)), logger.ERROR) ui.notifications.error("Unknown error. Unable to add show due to problem with show selection.") return self.redirect('/home/addShows/existingShows/') indexer = int(series_pieces[1]) indexer_id = int(series_pieces[3]) show_name = series_pieces[4] else: # if no indexer was provided use the default indexer set in General settings if not providedIndexer: providedIndexer = sickbeard.INDEXER_DEFAULT indexer = int(providedIndexer) indexer_id = int(whichSeries) show_name = os.path.basename(os.path.normpath(fullShowPath)) # use the whole path if it's given, or else append the show name to the root dir to get the full show path if fullShowPath: show_dir = ek.ek(os.path.normpath, fullShowPath) else: show_dir = ek.ek(os.path.join, rootDir, helpers.sanitizeFileName(show_name)) # blanket policy - if the dir exists you should have used "add existing show" numbnuts if ek.ek(os.path.isdir, show_dir) and not fullShowPath: ui.notifications.error("Unable to add show", "Folder " + show_dir + " exists already") return self.redirect('/home/addShows/existingShows/') # don't create show dir if config says not to if sickbeard.ADD_SHOWS_WO_DIR: logger.log(u"Skipping initial creation of " + show_dir + " due to config.ini setting") else: dir_exists = helpers.makeDir(show_dir) if not dir_exists: logger.log(u"Unable to create the folder " + show_dir + ", can't add the show", logger.ERROR) ui.notifications.error("Unable to add show", "Unable to create the folder " + show_dir + ", can't add the show") return self.redirect("/home/") else: helpers.chmodAsParent(show_dir) # prepare the inputs for passing along scene = config.checkbox_to_value(scene) anime = config.checkbox_to_value(anime) flatten_folders = config.checkbox_to_value(flatten_folders) subtitles = config.checkbox_to_value(subtitles) if not anyQualities: anyQualities = [] if not bestQualities: bestQualities = [] if type(anyQualities) != list: anyQualities = [anyQualities] if type(bestQualities) != list: bestQualities = [bestQualities] newQuality = Quality.combineQualities(map(int, anyQualities), map(int, bestQualities)) # add the show sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), newQuality, flatten_folders, indexerLang, subtitles, anime, scene) ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir) return finishAddShow() def split_extra_show(self, extra_show): if not extra_show: return (None, None, None, None) split_vals = extra_show.split('|') if len(split_vals) < 4: indexer = split_vals[0] show_dir = split_vals[1] return (indexer, show_dir, None, None) indexer = split_vals[0] show_dir = split_vals[1] indexer_id = split_vals[2] show_name = '|'.join(split_vals[3:]) return (indexer, show_dir, indexer_id, show_name) def addExistingShows(self, shows_to_add=None, promptForSettings=None): """ Receives a dir list and add them. Adds the ones with given TVDB IDs first, then forwards along to the newShow page. """ # grab a list of other shows to add, if provided if not shows_to_add: shows_to_add = [] elif type(shows_to_add) != list: shows_to_add = [shows_to_add] shows_to_add = [urllib.unquote_plus(x) for x in shows_to_add] promptForSettings = config.checkbox_to_value(promptForSettings) indexer_id_given = [] dirs_only = [] # separate all the ones with Indexer IDs for cur_dir in shows_to_add: if '|' in cur_dir: split_vals = cur_dir.split('|') if len(split_vals) < 3: dirs_only.append(cur_dir) if not '|' in cur_dir: dirs_only.append(cur_dir) else: indexer, show_dir, indexer_id, show_name = self.split_extra_show(cur_dir) if not show_dir or not indexer_id or not show_name: continue indexer_id_given.append((int(indexer), show_dir, int(indexer_id), show_name)) # if they want me to prompt for settings then I will just carry on to the newShow page if promptForSettings and shows_to_add: return self.newShow(shows_to_add[0], shows_to_add[1:]) # if they don't want me to prompt for settings then I can just add all the nfo shows now num_added = 0 for cur_show in indexer_id_given: indexer, show_dir, indexer_id, show_name = cur_show if indexer is not None and indexer_id is not None: # add the show sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir, default_status=sickbeard.STATUS_DEFAULT, quality=sickbeard.QUALITY_DEFAULT, flatten_folders=sickbeard.FLATTEN_FOLDERS_DEFAULT, subtitles=sickbeard.SUBTITLES_DEFAULT, anime=sickbeard.ANIME_DEFAULT, scene=sickbeard.SCENE_DEFAULT) num_added += 1 if num_added: ui.notifications.message("Shows Added", "Automatically added " + str(num_added) + " from their existing metadata files") # if we're done then go home if not dirs_only: return self.redirect('/home/') # for the remaining shows we need to prompt for each one, so forward this on to the newShow page return self.newShow(dirs_only[0], dirs_only[1:]) @route('/manage(/?.*)') class Manage(Home, WebRoot): def __init__(self, *args, **kwargs): super(Manage, self).__init__(*args, **kwargs) def ManageMenu(self): menu = [ {'title': 'Backlog Overview', 'path': 'manage/backlogOverview/'}, {'title': 'Manage Searches', 'path': 'manage/manageSearches/'}, {'title': 'Episode Status Management', 'path': 'manage/episodeStatuses/'}, ] if sickbeard.USE_TORRENTS and sickbeard.TORRENT_METHOD != 'blackhole' \ and (sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'https' or not sickbeard.ENABLE_HTTPS and sickbeard.TORRENT_HOST[:5] == 'http:'): menu.append({'title': 'Manage Torrents', 'path': 'manage/manageTorrents/'}) if sickbeard.USE_SUBTITLES: menu.append({'title': 'Missed Subtitle Management', 'path': 'manage/subtitleMissed/'}) if sickbeard.USE_FAILED_DOWNLOADS: menu.append({'title': 'Failed Downloads', 'path': 'manage/failedDownloads/'}) return menu def index(self): t = PageTemplate(rh=self, file="manage.tmpl") t.submenu = self.ManageMenu() return t.respond() def showEpisodeStatuses(self, indexer_id, whichStatus): status_list = [int(whichStatus)] if status_list[0] == SNATCHED: status_list = Quality.SNATCHED + Quality.SNATCHED_PROPER myDB = db.DBConnection() cur_show_results = myDB.select( "SELECT season, episode, name FROM tv_episodes WHERE showid = ? AND season != 0 AND status IN (" + ','.join( ['?'] * len(status_list)) + ")", [int(indexer_id)] + status_list) result = {} for cur_result in cur_show_results: cur_season = int(cur_result["season"]) cur_episode = int(cur_result["episode"]) if cur_season not in result: result[cur_season] = {} result[cur_season][cur_episode] = cur_result["name"] return json.dumps(result) def episodeStatuses(self, whichStatus=None): if whichStatus: whichStatus = int(whichStatus) status_list = [whichStatus] if status_list[0] == SNATCHED: status_list = Quality.SNATCHED + Quality.SNATCHED_PROPER else: status_list = [] t = PageTemplate(rh=self, file="manage_episodeStatuses.tmpl") t.submenu = self.ManageMenu() t.whichStatus = whichStatus # if we have no status then this is as far as we need to go if not status_list: return t.respond() myDB = db.DBConnection() status_results = myDB.select( "SELECT show_name, tv_shows.indexer_id AS indexer_id FROM tv_episodes, tv_shows WHERE tv_episodes.status IN (" + ','.join( ['?'] * len( status_list)) + ") AND season != 0 AND tv_episodes.showid = tv_shows.indexer_id ORDER BY show_name", status_list) ep_counts = {} show_names = {} sorted_show_ids = [] for cur_status_result in status_results: cur_indexer_id = int(cur_status_result["indexer_id"]) if cur_indexer_id not in ep_counts: ep_counts[cur_indexer_id] = 1 else: ep_counts[cur_indexer_id] += 1 show_names[cur_indexer_id] = cur_status_result["show_name"] if cur_indexer_id not in sorted_show_ids: sorted_show_ids.append(cur_indexer_id) t.show_names = show_names t.ep_counts = ep_counts t.sorted_show_ids = sorted_show_ids return t.respond() def changeEpisodeStatuses(self, oldStatus, newStatus, *args, **kwargs): status_list = [int(oldStatus)] if status_list[0] == SNATCHED: status_list = Quality.SNATCHED + Quality.SNATCHED_PROPER to_change = {} # make a list of all shows and their associated args for arg in kwargs: indexer_id, what = arg.split('-') # we don't care about unchecked checkboxes if kwargs[arg] != 'on': continue if indexer_id not in to_change: to_change[indexer_id] = [] to_change[indexer_id].append(what) myDB = db.DBConnection() for cur_indexer_id in to_change: # get a list of all the eps we want to change if they just said "all" if 'all' in to_change[cur_indexer_id]: all_eps_results = myDB.select( "SELECT season, episode FROM tv_episodes WHERE status IN (" + ','.join( ['?'] * len(status_list)) + ") AND season != 0 AND showid = ?", status_list + [cur_indexer_id]) all_eps = [str(x["season"]) + 'x' + str(x["episode"]) for x in all_eps_results] to_change[cur_indexer_id] = all_eps self.setStatus(cur_indexer_id, '|'.join(to_change[cur_indexer_id]), newStatus, direct=True) return self.redirect('/manage/episodeStatuses/') def showSubtitleMissed(self, indexer_id, whichSubs): myDB = db.DBConnection() cur_show_results = myDB.select( "SELECT season, episode, name, subtitles FROM tv_episodes WHERE showid = ? AND season != 0 AND status LIKE '%4'", [int(indexer_id)]) result = {} for cur_result in cur_show_results: if whichSubs == 'all': if len(set(cur_result["subtitles"].split(',')).intersection(set(subtitles.wantedLanguages()))) >= len( subtitles.wantedLanguages()): continue elif whichSubs in cur_result["subtitles"].split(','): continue cur_season = int(cur_result["season"]) cur_episode = int(cur_result["episode"]) if cur_season not in result: result[cur_season] = {} if cur_episode not in result[cur_season]: result[cur_season][cur_episode] = {} result[cur_season][cur_episode]["name"] = cur_result["name"] result[cur_season][cur_episode]["subtitles"] = ",".join( subliminal.language.Language(subtitle).alpha2 for subtitle in cur_result["subtitles"].split(',')) if not \ cur_result["subtitles"] == '' else '' return json.dumps(result) def subtitleMissed(self, whichSubs=None): t = PageTemplate(rh=self, file="manage_subtitleMissed.tmpl") t.submenu = self.ManageMenu() t.whichSubs = whichSubs if not whichSubs: return t.respond() myDB = db.DBConnection() status_results = myDB.select( "SELECT show_name, tv_shows.indexer_id as indexer_id, tv_episodes.subtitles subtitles FROM tv_episodes, tv_shows WHERE tv_shows.subtitles = 1 AND tv_episodes.status LIKE '%4' AND tv_episodes.season != 0 AND tv_episodes.showid = tv_shows.indexer_id ORDER BY show_name") ep_counts = {} show_names = {} sorted_show_ids = [] for cur_status_result in status_results: if whichSubs == 'all': if len(set(cur_status_result["subtitles"].split(',')).intersection( set(subtitles.wantedLanguages()))) >= len(subtitles.wantedLanguages()): continue elif whichSubs in cur_status_result["subtitles"].split(','): continue cur_indexer_id = int(cur_status_result["indexer_id"]) if cur_indexer_id not in ep_counts: ep_counts[cur_indexer_id] = 1 else: ep_counts[cur_indexer_id] += 1 show_names[cur_indexer_id] = cur_status_result["show_name"] if cur_indexer_id not in sorted_show_ids: sorted_show_ids.append(cur_indexer_id) t.show_names = show_names t.ep_counts = ep_counts t.sorted_show_ids = sorted_show_ids return t.respond() def downloadSubtitleMissed(self, *args, **kwargs): to_download = {} # make a list of all shows and their associated args for arg in kwargs: indexer_id, what = arg.split('-') # we don't care about unchecked checkboxes if kwargs[arg] != 'on': continue if indexer_id not in to_download: to_download[indexer_id] = [] to_download[indexer_id].append(what) for cur_indexer_id in to_download: # get a list of all the eps we want to download subtitles if they just said "all" if 'all' in to_download[cur_indexer_id]: myDB = db.DBConnection() all_eps_results = myDB.select( "SELECT season, episode FROM tv_episodes WHERE status LIKE '%4' AND season != 0 AND showid = ?", [cur_indexer_id]) to_download[cur_indexer_id] = [str(x["season"]) + 'x' + str(x["episode"]) for x in all_eps_results] for epResult in to_download[cur_indexer_id]: season, episode = epResult.split('x') show = sickbeard.helpers.findCertainShow(sickbeard.showList, int(cur_indexer_id)) subtitles = show.getEpisode(int(season), int(episode)).downloadSubtitles() return self.redirect('/manage/subtitleMissed/') def backlogShow(self, indexer_id): show_obj = helpers.findCertainShow(sickbeard.showList, int(indexer_id)) if show_obj: sickbeard.backlogSearchScheduler.action.searchBacklog([show_obj]) return self.redirect("/manage/backlogOverview/") def backlogOverview(self): t = PageTemplate(rh=self, file="manage_backlogOverview.tmpl") t.submenu = self.ManageMenu() showCounts = {} showCats = {} showSQLResults = {} myDB = db.DBConnection() for curShow in sickbeard.showList: epCounts = {} epCats = {} epCounts[Overview.SKIPPED] = 0 epCounts[Overview.WANTED] = 0 epCounts[Overview.QUAL] = 0 epCounts[Overview.GOOD] = 0 epCounts[Overview.UNAIRED] = 0 epCounts[Overview.SNATCHED] = 0 sqlResults = myDB.select( "SELECT * FROM tv_episodes WHERE showid = ? ORDER BY season DESC, episode DESC", [curShow.indexerid]) for curResult in sqlResults: curEpCat = curShow.getOverview(int(curResult["status"] or -1)) if curEpCat: epCats[str(curResult["season"]) + "x" + str(curResult["episode"])] = curEpCat epCounts[curEpCat] += 1 showCounts[curShow.indexerid] = epCounts showCats[curShow.indexerid] = epCats showSQLResults[curShow.indexerid] = sqlResults t.showCounts = showCounts t.showCats = showCats t.showSQLResults = showSQLResults return t.respond() def massEdit(self, toEdit=None): t = PageTemplate(rh=self, file="manage_massEdit.tmpl") t.submenu = self.ManageMenu() if not toEdit: return self.redirect("/manage/") showIDs = toEdit.split("|") showList = [] for curID in showIDs: curID = int(curID) showObj = helpers.findCertainShow(sickbeard.showList, curID) if showObj: showList.append(showObj) archive_firstmatch_all_same = True last_archive_firstmatch = None flatten_folders_all_same = True last_flatten_folders = None paused_all_same = True last_paused = None default_ep_status_all_same = True last_default_ep_status = None anime_all_same = True last_anime = None sports_all_same = True last_sports = None quality_all_same = True last_quality = None subtitles_all_same = True last_subtitles = None scene_all_same = True last_scene = None air_by_date_all_same = True last_air_by_date = None root_dir_list = [] for curShow in showList: cur_root_dir = ek.ek(os.path.dirname, curShow._location) if cur_root_dir not in root_dir_list: root_dir_list.append(cur_root_dir) if archive_firstmatch_all_same: # if we had a value already and this value is different then they're not all the same if last_archive_firstmatch not in (None, curShow.archive_firstmatch): archive_firstmatch_all_same = False else: last_archive_firstmatch = curShow.archive_firstmatch # if we know they're not all the same then no point even bothering if paused_all_same: # if we had a value already and this value is different then they're not all the same if last_paused not in (None, curShow.paused): paused_all_same = False else: last_paused = curShow.paused if default_ep_status_all_same: if last_default_ep_status not in (None, curShow.default_ep_status): default_ep_status_all_same = False else: last_default_ep_status = curShow.default_ep_status if anime_all_same: # if we had a value already and this value is different then they're not all the same if last_anime not in (None, curShow.is_anime): anime_all_same = False else: last_anime = curShow.anime if flatten_folders_all_same: if last_flatten_folders not in (None, curShow.flatten_folders): flatten_folders_all_same = False else: last_flatten_folders = curShow.flatten_folders if quality_all_same: if last_quality not in (None, curShow.quality): quality_all_same = False else: last_quality = curShow.quality if subtitles_all_same: if last_subtitles not in (None, curShow.subtitles): subtitles_all_same = False else: last_subtitles = curShow.subtitles if scene_all_same: if last_scene not in (None, curShow.scene): scene_all_same = False else: last_scene = curShow.scene if sports_all_same: if last_sports not in (None, curShow.sports): sports_all_same = False else: last_sports = curShow.sports if air_by_date_all_same: if last_air_by_date not in (None, curShow.air_by_date): air_by_date_all_same = False else: last_air_by_date = curShow.air_by_date t.showList = toEdit t.archive_firstmatch_value = last_archive_firstmatch if archive_firstmatch_all_same else None t.default_ep_status_value = last_default_ep_status if default_ep_status_all_same else None t.paused_value = last_paused if paused_all_same else None t.anime_value = last_anime if anime_all_same else None t.flatten_folders_value = last_flatten_folders if flatten_folders_all_same else None t.quality_value = last_quality if quality_all_same else None t.subtitles_value = last_subtitles if subtitles_all_same else None t.scene_value = last_scene if scene_all_same else None t.sports_value = last_sports if sports_all_same else None t.air_by_date_value = last_air_by_date if air_by_date_all_same else None t.root_dir_list = root_dir_list return t.respond() def massEditSubmit(self, archive_firstmatch=None, paused=None, default_ep_status=None, anime=None, sports=None, scene=None, flatten_folders=None, quality_preset=False, subtitles=None, air_by_date=None, anyQualities=[], bestQualities=[], toEdit=None, *args, **kwargs): dir_map = {} for cur_arg in kwargs: if not cur_arg.startswith('orig_root_dir_'): continue which_index = cur_arg.replace('orig_root_dir_', '') end_dir = kwargs['new_root_dir_' + which_index] dir_map[kwargs[cur_arg]] = end_dir showIDs = toEdit.split("|") errors = [] for curShow in showIDs: curErrors = [] showObj = helpers.findCertainShow(sickbeard.showList, int(curShow)) if not showObj: continue cur_root_dir = ek.ek(os.path.dirname, showObj._location) cur_show_dir = ek.ek(os.path.basename, showObj._location) if cur_root_dir in dir_map and cur_root_dir != dir_map[cur_root_dir]: new_show_dir = ek.ek(os.path.join, dir_map[cur_root_dir], cur_show_dir) logger.log( u"For show " + showObj.name + " changing dir from " + showObj._location + " to " + new_show_dir) else: new_show_dir = showObj._location if archive_firstmatch == 'keep': new_archive_firstmatch = showObj.archive_firstmatch else: new_archive_firstmatch = True if archive_firstmatch == 'enable' else False new_archive_firstmatch = 'on' if new_archive_firstmatch else 'off' if paused == 'keep': new_paused = showObj.paused else: new_paused = True if paused == 'enable' else False new_paused = 'on' if new_paused else 'off' if default_ep_status == 'keep': new_default_ep_status = showObj.default_ep_status else: new_default_ep_status = default_ep_status if anime == 'keep': new_anime = showObj.anime else: new_anime = True if anime == 'enable' else False new_anime = 'on' if new_anime else 'off' if sports == 'keep': new_sports = showObj.sports else: new_sports = True if sports == 'enable' else False new_sports = 'on' if new_sports else 'off' if scene == 'keep': new_scene = showObj.is_scene else: new_scene = True if scene == 'enable' else False new_scene = 'on' if new_scene else 'off' if air_by_date == 'keep': new_air_by_date = showObj.air_by_date else: new_air_by_date = True if air_by_date == 'enable' else False new_air_by_date = 'on' if new_air_by_date else 'off' if flatten_folders == 'keep': new_flatten_folders = showObj.flatten_folders else: new_flatten_folders = True if flatten_folders == 'enable' else False new_flatten_folders = 'on' if new_flatten_folders else 'off' if subtitles == 'keep': new_subtitles = showObj.subtitles else: new_subtitles = True if subtitles == 'enable' else False new_subtitles = 'on' if new_subtitles else 'off' if quality_preset == 'keep': anyQualities, bestQualities = Quality.splitQuality(showObj.quality) exceptions_list = [] curErrors += self.editShow(curShow, new_show_dir, anyQualities, bestQualities, exceptions_list, defaultEpStatus=new_default_ep_status, archive_firstmatch=new_archive_firstmatch, flatten_folders=new_flatten_folders, paused=new_paused, sports=new_sports, subtitles=new_subtitles, anime=new_anime, scene=new_scene, air_by_date=new_air_by_date, directCall=True) if curErrors: logger.log(u"Errors: " + str(curErrors), logger.ERROR) errors.append('<b>%s:</b>\n<ul>' % showObj.name + ' '.join( ['<li>%s</li>' % error for error in curErrors]) + "</ul>") if len(errors) > 0: ui.notifications.error('%d error%s while saving changes:' % (len(errors), "" if len(errors) == 1 else "s"), " ".join(errors)) return self.redirect("/manage/") def massUpdate(self, toUpdate=None, toRefresh=None, toRename=None, toDelete=None, toRemove=None, toMetadata=None, toSubtitle=None): if toUpdate is not None: toUpdate = toUpdate.split('|') else: toUpdate = [] if toRefresh is not None: toRefresh = toRefresh.split('|') else: toRefresh = [] if toRename is not None: toRename = toRename.split('|') else: toRename = [] if toSubtitle is not None: toSubtitle = toSubtitle.split('|') else: toSubtitle = [] if toDelete is not None: toDelete = toDelete.split('|') else: toDelete = [] if toRemove is not None: toRemove = toRemove.split('|') else: toRemove = [] if toMetadata is not None: toMetadata = toMetadata.split('|') else: toMetadata = [] errors = [] refreshes = [] updates = [] renames = [] subtitles = [] for curShowID in set(toUpdate + toRefresh + toRename + toSubtitle + toDelete + toRemove + toMetadata): if curShowID == '': continue showObj = sickbeard.helpers.findCertainShow(sickbeard.showList, int(curShowID)) if showObj is None: continue if curShowID in toDelete: showObj.deleteShow(True) # don't do anything else if it's being deleted continue if curShowID in toRemove: showObj.deleteShow() # don't do anything else if it's being remove continue if curShowID in toUpdate: try: sickbeard.showQueueScheduler.action.updateShow(showObj, True) updates.append(showObj.name) except exceptions.CantUpdateException, e: errors.append("Unable to update show " + showObj.name + ": " + ex(e)) # don't bother refreshing shows that were updated anyway if curShowID in toRefresh and curShowID not in toUpdate: try: sickbeard.showQueueScheduler.action.refreshShow(showObj) refreshes.append(showObj.name) except exceptions.CantRefreshException, e: errors.append("Unable to refresh show " + showObj.name + ": " + ex(e)) if curShowID in toRename: sickbeard.showQueueScheduler.action.renameShowEpisodes(showObj) renames.append(showObj.name) if curShowID in toSubtitle: sickbeard.showQueueScheduler.action.downloadSubtitles(showObj) subtitles.append(showObj.name) if len(errors) > 0: ui.notifications.error("Errors encountered", '<br >\n'.join(errors)) messageDetail = "" if len(updates) > 0: messageDetail += "<br /><b>Updates</b><br /><ul><li>" messageDetail += "</li><li>".join(updates) messageDetail += "</li></ul>" if len(refreshes) > 0: messageDetail += "<br /><b>Refreshes</b><br /><ul><li>" messageDetail += "</li><li>".join(refreshes) messageDetail += "</li></ul>" if len(renames) > 0: messageDetail += "<br /><b>Renames</b><br /><ul><li>" messageDetail += "</li><li>".join(renames) messageDetail += "</li></ul>" if len(subtitles) > 0: messageDetail += "<br /><b>Subtitles</b><br /><ul><li>" messageDetail += "</li><li>".join(subtitles) messageDetail += "</li></ul>" if len(updates + refreshes + renames + subtitles) > 0: ui.notifications.message("The following actions were queued:", messageDetail) return self.redirect("/manage/") def manageTorrents(self): t = PageTemplate(rh=self, file="manage_torrents.tmpl") t.info_download_station = '' t.submenu = self.ManageMenu() if re.search('localhost', sickbeard.TORRENT_HOST): if sickbeard.LOCALHOST_IP == '': t.webui_url = re.sub('localhost', helpers.get_lan_ip(), sickbeard.TORRENT_HOST) else: t.webui_url = re.sub('localhost', sickbeard.LOCALHOST_IP, sickbeard.TORRENT_HOST) else: t.webui_url = sickbeard.TORRENT_HOST if sickbeard.TORRENT_METHOD == 'utorrent': t.webui_url = '/'.join(s.strip('/') for s in (t.webui_url, 'gui/')) if sickbeard.TORRENT_METHOD == 'download_station': if helpers.check_url(t.webui_url + 'download/'): t.webui_url = t.webui_url + 'download/' else: t.info_download_station = '<p>To have a better experience please set the Download Station alias as <code>download</code>, you can check this setting in the Synology DSM <b>Control Panel</b> > <b>Application Portal</b>. Make sure you allow DSM to be embedded with iFrames too in <b>Control Panel</b> > <b>DSM Settings</b> > <b>Security</b>.</p><br/><p>There is more information about this available <a href="https://github.com/midgetspy/Sick-Beard/pull/338">here</a>.</p><br/>' if not sickbeard.TORRENT_PASSWORD == "" and not sickbeard.TORRENT_USERNAME == "": t.webui_url = re.sub('://', '://' + str(sickbeard.TORRENT_USERNAME) + ':' + str(sickbeard.TORRENT_PASSWORD) + '@' ,t.webui_url) return t.respond() def failedDownloads(self, limit=100, toRemove=None): myDB = db.DBConnection('failed.db') if limit == "0": sqlResults = myDB.select("SELECT * FROM failed") else: sqlResults = myDB.select("SELECT * FROM failed LIMIT ?", [limit]) toRemove = toRemove.split("|") if toRemove is not None else [] for release in toRemove: myDB.action("DELETE FROM failed WHERE failed.release = ?", [release]) if toRemove: return self.redirect('/manage/failedDownloads/') t = PageTemplate(rh=self, file="manage_failedDownloads.tmpl") t.failedResults = sqlResults t.limit = limit t.submenu = self.ManageMenu() return t.respond() @route('/manage/manageSearches(/?.*)') class ManageSearches(Manage): def __init__(self, *args, **kwargs): super(ManageSearches, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="manage_manageSearches.tmpl") # t.backlogPI = sickbeard.backlogSearchScheduler.action.getProgressIndicator() t.backlogPaused = sickbeard.searchQueueScheduler.action.is_backlog_paused() t.backlogRunning = sickbeard.searchQueueScheduler.action.is_backlog_in_progress() t.dailySearchStatus = sickbeard.dailySearchScheduler.action.amActive t.findPropersStatus = sickbeard.properFinderScheduler.action.amActive t.queueLength = sickbeard.searchQueueScheduler.action.queue_length() t.submenu = self.ManageMenu() return t.respond() def forceBacklog(self): # force it to run the next time it looks result = sickbeard.backlogSearchScheduler.forceRun() if result: logger.log(u"Backlog search forced") ui.notifications.message('Backlog search started') return self.redirect("/manage/manageSearches/") def forceSearch(self): # force it to run the next time it looks result = sickbeard.dailySearchScheduler.forceRun() if result: logger.log(u"Daily search forced") ui.notifications.message('Daily search started') return self.redirect("/manage/manageSearches/") def forceFindPropers(self): # force it to run the next time it looks result = sickbeard.properFinderScheduler.forceRun() if result: logger.log(u"Find propers search forced") ui.notifications.message('Find propers search started') return self.redirect("/manage/manageSearches/") def pauseBacklog(self, paused=None): if paused == "1": sickbeard.searchQueueScheduler.action.pause_backlog() else: sickbeard.searchQueueScheduler.action.unpause_backlog() return self.redirect("/manage/manageSearches/") @route('/history(/?.*)') class History(WebRoot): def __init__(self, *args, **kwargs): super(History, self).__init__(*args, **kwargs) def index(self, limit=100): # sqlResults = myDB.select("SELECT h.*, show_name, name FROM history h, tv_shows s, tv_episodes e WHERE h.showid=s.indexer_id AND h.showid=e.showid AND h.season=e.season AND h.episode=e.episode ORDER BY date DESC LIMIT "+str(numPerPage*(p-1))+", "+str(numPerPage)) myDB = db.DBConnection() if limit == "0": sqlResults = myDB.select( "SELECT h.*, show_name FROM history h, tv_shows s WHERE h.showid=s.indexer_id ORDER BY date DESC") else: sqlResults = myDB.select( "SELECT h.*, show_name FROM history h, tv_shows s WHERE h.showid=s.indexer_id ORDER BY date DESC LIMIT ?", [limit]) history = {'show_id': 0, 'season': 0, 'episode': 0, 'quality': 0, 'actions': [{'time': '', 'action': '', 'provider': ''}]} compact = [] for sql_result in sqlResults: if not any((history['show_id'] == sql_result['showid'] and history['season'] == sql_result['season'] and history['episode'] == sql_result['episode'] and history['quality'] == sql_result['quality']) for history in compact): history = {} history['show_id'] = sql_result['showid'] history['season'] = sql_result['season'] history['episode'] = sql_result['episode'] history['quality'] = sql_result['quality'] history['show_name'] = sql_result['show_name'] history['resource'] = sql_result['resource'] action = {} history['actions'] = [] action['time'] = sql_result['date'] action['action'] = sql_result['action'] action['provider'] = sql_result['provider'] action['resource'] = sql_result['resource'] history['actions'].append(action) history['actions'].sort(key=lambda x: x['time']) compact.append(history) else: index = [i for i, dict in enumerate(compact) \ if dict['show_id'] == sql_result['showid'] \ and dict['season'] == sql_result['season'] \ and dict['episode'] == sql_result['episode'] and dict['quality'] == sql_result['quality']][0] action = {} history = compact[index] action['time'] = sql_result['date'] action['action'] = sql_result['action'] action['provider'] = sql_result['provider'] action['resource'] = sql_result['resource'] history['actions'].append(action) history['actions'].sort(key=lambda x: x['time'], reverse=True) t = PageTemplate(rh=self, file="history.tmpl") t.historyResults = sqlResults t.compactResults = compact t.limit = limit t.submenu = [ {'title': 'Clear History', 'path': 'history/clearHistory'}, {'title': 'Trim History', 'path': 'history/trimHistory'}, ] return t.respond() def clearHistory(self): myDB = db.DBConnection() myDB.action("DELETE FROM history WHERE 1=1") ui.notifications.message('History cleared') return self.redirect("/history/") def trimHistory(self): myDB = db.DBConnection() myDB.action("DELETE FROM history WHERE date < " + str( (datetime.datetime.today() - datetime.timedelta(days=30)).strftime(history.dateFormat))) ui.notifications.message('Removed history entries greater than 30 days old') return self.redirect("/history/") @route('/config(/?.*)') class Config(WebRoot): def __init__(self, *args, **kwargs): super(Config, self).__init__(*args, **kwargs) def ConfigMenu(self): menu = [ {'title': 'General', 'path': 'config/general/'}, {'title': 'Backup/Restore', 'path': 'config/backuprestore/'}, {'title': 'Search Settings', 'path': 'config/search/'}, {'title': 'Search Providers', 'path': 'config/providers/'}, {'title': 'Subtitles Settings', 'path': 'config/subtitles/'}, {'title': 'Post Processing', 'path': 'config/postProcessing/'}, {'title': 'Notifications', 'path': 'config/notifications/'}, {'title': 'Anime', 'path': 'config/anime/'}, ] return menu def index(self): t = PageTemplate(rh=self, file="config.tmpl") t.submenu = self.ConfigMenu() return t.respond() @route('/config/general(/?.*)') class ConfigGeneral(Config): def __init__(self, *args, **kwargs): super(ConfigGeneral, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="config_general.tmpl") t.submenu = self.ConfigMenu() return t.respond() def generateApiKey(self): return helpers.generateApiKey() def saveRootDirs(self, rootDirString=None): sickbeard.ROOT_DIRS = rootDirString def saveAddShowDefaults(self, defaultStatus, anyQualities, bestQualities, defaultFlattenFolders, subtitles=False, anime=False, scene=False): if anyQualities: anyQualities = anyQualities.split(',') else: anyQualities = [] if bestQualities: bestQualities = bestQualities.split(',') else: bestQualities = [] newQuality = Quality.combineQualities(map(int, anyQualities), map(int, bestQualities)) sickbeard.STATUS_DEFAULT = int(defaultStatus) sickbeard.QUALITY_DEFAULT = int(newQuality) sickbeard.FLATTEN_FOLDERS_DEFAULT = config.checkbox_to_value(defaultFlattenFolders) sickbeard.SUBTITLES_DEFAULT = config.checkbox_to_value(subtitles) sickbeard.ANIME_DEFAULT = config.checkbox_to_value(anime) sickbeard.SCENE_DEFAULT = config.checkbox_to_value(scene) sickbeard.save_config() def saveGeneral(self, log_dir=None, log_nr = 5, log_size = 1048576, web_port=None, web_log=None, encryption_version=None, web_ipv6=None, update_shows_on_start=None, trash_remove_show=None, trash_rotate_logs=None, update_frequency=None, launch_browser=None, showupdate_hour=3, web_username=None, api_key=None, indexer_default=None, timezone_display=None, cpu_preset=None, web_password=None, version_notify=None, enable_https=None, https_cert=None, https_key=None, handle_reverse_proxy=None, sort_article=None, auto_update=None, notify_on_update=None, proxy_setting=None, proxy_indexers=None, anon_redirect=None, git_path=None, git_remote=None, calendar_unprotected=None, display_filesize=None, fuzzy_dating=None, trim_zero=None, date_preset=None, date_preset_na=None, time_preset=None, indexer_timeout=None, play_videos=None, download_url=None, rootDir=None, theme_name=None, git_reset=None, git_username=None, git_password=None, git_autoissues=None): results = [] # Misc sickbeard.PLAY_VIDEOS = config.checkbox_to_value(play_videos) sickbeard.DOWNLOAD_URL = download_url sickbeard.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser) sickbeard.SHOWUPDATE_HOUR = config.to_int(showupdate_hour) config.change_VERSION_NOTIFY(config.checkbox_to_value(version_notify)) sickbeard.AUTO_UPDATE = config.checkbox_to_value(auto_update) sickbeard.NOTIFY_ON_UPDATE = config.checkbox_to_value(notify_on_update) # sickbeard.LOG_DIR is set in config.change_LOG_DIR() sickbeard.LOG_NR = log_nr sickbeard.LOG_SIZE = log_size sickbeard.UPDATE_SHOWS_ON_START = config.checkbox_to_value(update_shows_on_start) sickbeard.TRASH_REMOVE_SHOW = config.checkbox_to_value(trash_remove_show) sickbeard.TRASH_ROTATE_LOGS = config.checkbox_to_value(trash_rotate_logs) config.change_UPDATE_FREQUENCY(update_frequency) sickbeard.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser) sickbeard.SORT_ARTICLE = config.checkbox_to_value(sort_article) sickbeard.CPU_PRESET = cpu_preset sickbeard.ANON_REDIRECT = anon_redirect sickbeard.PROXY_SETTING = proxy_setting sickbeard.PROXY_INDEXERS = config.checkbox_to_value(proxy_indexers) sickbeard.GIT_USERNAME = git_username sickbeard.GIT_PASSWORD = git_password sickbeard.GIT_RESET = config.checkbox_to_value(git_reset) sickbeard.GIT_AUTOISSUES = config.checkbox_to_value(git_autoissues) sickbeard.GIT_PATH = git_path sickbeard.GIT_REMOTE = git_remote sickbeard.CALENDAR_UNPROTECTED = config.checkbox_to_value(calendar_unprotected) # sickbeard.LOG_DIR is set in config.change_LOG_DIR() sickbeard.WEB_PORT = config.to_int(web_port) sickbeard.WEB_IPV6 = config.checkbox_to_value(web_ipv6) # sickbeard.WEB_LOG is set in config.change_LOG_DIR() sickbeard.ENCRYPTION_VERSION = config.checkbox_to_value(encryption_version) sickbeard.WEB_USERNAME = web_username sickbeard.WEB_PASSWORD = web_password sickbeard.DISPLAY_FILESIZE = config.checkbox_to_value(display_filesize) sickbeard.FUZZY_DATING = config.checkbox_to_value(fuzzy_dating) sickbeard.TRIM_ZERO = config.checkbox_to_value(trim_zero) if date_preset: sickbeard.DATE_PRESET = date_preset discarded_na_data = date_preset_na if indexer_default: sickbeard.INDEXER_DEFAULT = config.to_int(indexer_default) if indexer_timeout: sickbeard.INDEXER_TIMEOUT = config.to_int(indexer_timeout) if time_preset: sickbeard.TIME_PRESET_W_SECONDS = time_preset sickbeard.TIME_PRESET = sickbeard.TIME_PRESET_W_SECONDS.replace(u":%S", u"") sickbeard.TIMEZONE_DISPLAY = timezone_display if not config.change_LOG_DIR(log_dir, web_log): results += ["Unable to create directory " + os.path.normpath(log_dir) + ", log directory not changed."] sickbeard.API_KEY = api_key sickbeard.ENABLE_HTTPS = config.checkbox_to_value(enable_https) if not config.change_HTTPS_CERT(https_cert): results += [ "Unable to create directory " + os.path.normpath(https_cert) + ", https cert directory not changed."] if not config.change_HTTPS_KEY(https_key): results += [ "Unable to create directory " + os.path.normpath(https_key) + ", https key directory not changed."] sickbeard.HANDLE_REVERSE_PROXY = config.checkbox_to_value(handle_reverse_proxy) sickbeard.THEME_NAME = theme_name sickbeard.save_config() if len(results) > 0: for x in results: logger.log(x, logger.ERROR) ui.notifications.error('Error(s) Saving Configuration', '<br />\n'.join(results)) else: ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) return self.redirect("/config/general/") @route('/config/backuprestore(/?.*)') class ConfigBackupRestore(Config): def __init__(self, *args, **kwargs): super(ConfigBackupRestore, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="config_backuprestore.tmpl") t.submenu = self.ConfigMenu() return t.respond() def backup(self, backupDir=None): finalResult = '' if backupDir: source = [os.path.join(sickbeard.DATA_DIR, 'sickbeard.db'), sickbeard.CONFIG_FILE] target = os.path.join(backupDir, 'sickrage-' + time.strftime('%Y%m%d%H%M%S') + '.zip') for (dir, _, files) in os.walk(sickbeard.CACHE_DIR): for f in files: source.append(os.path.join(dir, f)) if helpers.makeZip(source, target): finalResult += "Successful backup to " + target else: finalResult += "Backup FAILED" else: finalResult += "You need to choose a folder to save your backup to!" finalResult += "<br />\n" return finalResult def restore(self, backupFile=None): finalResult = '' if backupFile: source = backupFile target_dir = os.path.join(sickbeard.DATA_DIR, 'restore') if helpers.extractZip(source, target_dir): finalResult += "Successfully extracted restore files to " + target_dir finalResult += "<br>Restart sickrage to complete the restore." else: finalResult += "Restore FAILED" else: finalResult += "You need to select a backup file to restore!" finalResult += "<br />\n" return finalResult @route('/config/search(/?.*)') class ConfigSearch(Config): def __init__(self, *args, **kwargs): super(ConfigSearch, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="config_search.tmpl") t.submenu = self.ConfigMenu() return t.respond() def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_username=None, sab_password=None, sab_apikey=None, sab_category=None, sab_category_anime=None, sab_host=None, nzbget_username=None, nzbget_password=None, nzbget_category=None, nzbget_category_anime=None, nzbget_priority=None, nzbget_host=None, nzbget_use_https=None, backlog_days=None, backlog_frequency=None, dailysearch_frequency=None, nzb_method=None, torrent_method=None, usenet_retention=None, download_propers=None, check_propers_interval=None, allow_high_priority=None, randomize_providers=None, backlog_startup=None, dailysearch_startup=None, torrent_dir=None, torrent_username=None, torrent_password=None, torrent_host=None, torrent_label=None, torrent_label_anime=None, torrent_path=None, torrent_verify_cert=None, torrent_seed_time=None, torrent_paused=None, torrent_high_bandwidth=None, torrent_rpcurl=None, torrent_auth_type = None, ignore_words=None, require_words=None): results = [] if not config.change_NZB_DIR(nzb_dir): results += ["Unable to create directory " + os.path.normpath(nzb_dir) + ", dir not changed."] if not config.change_TORRENT_DIR(torrent_dir): results += ["Unable to create directory " + os.path.normpath(torrent_dir) + ", dir not changed."] config.change_DAILYSEARCH_FREQUENCY(dailysearch_frequency) config.change_BACKLOG_FREQUENCY(backlog_frequency) sickbeard.BACKLOG_DAYS = config.to_int(backlog_days, default=7) sickbeard.USE_NZBS = config.checkbox_to_value(use_nzbs) sickbeard.USE_TORRENTS = config.checkbox_to_value(use_torrents) sickbeard.NZB_METHOD = nzb_method sickbeard.TORRENT_METHOD = torrent_method sickbeard.USENET_RETENTION = config.to_int(usenet_retention, default=500) sickbeard.IGNORE_WORDS = ignore_words if ignore_words else "" sickbeard.REQUIRE_WORDS = require_words if require_words else "" sickbeard.RANDOMIZE_PROVIDERS = config.checkbox_to_value(randomize_providers) sickbeard.DOWNLOAD_PROPERS = config.checkbox_to_value(download_propers) sickbeard.CHECK_PROPERS_INTERVAL = check_propers_interval sickbeard.ALLOW_HIGH_PRIORITY = config.checkbox_to_value(allow_high_priority) sickbeard.DAILYSEARCH_STARTUP = config.checkbox_to_value(dailysearch_startup) sickbeard.BACKLOG_STARTUP = config.checkbox_to_value(backlog_startup) sickbeard.SAB_USERNAME = sab_username sickbeard.SAB_PASSWORD = sab_password sickbeard.SAB_APIKEY = sab_apikey.strip() sickbeard.SAB_CATEGORY = sab_category sickbeard.SAB_CATEGORY_ANIME = sab_category_anime sickbeard.SAB_HOST = config.clean_url(sab_host) sickbeard.NZBGET_USERNAME = nzbget_username sickbeard.NZBGET_PASSWORD = nzbget_password sickbeard.NZBGET_CATEGORY = nzbget_category sickbeard.NZBGET_CATEGORY_ANIME = nzbget_category_anime sickbeard.NZBGET_HOST = config.clean_host(nzbget_host) sickbeard.NZBGET_USE_HTTPS = config.checkbox_to_value(nzbget_use_https) sickbeard.NZBGET_PRIORITY = config.to_int(nzbget_priority, default=100) sickbeard.TORRENT_USERNAME = torrent_username sickbeard.TORRENT_PASSWORD = torrent_password sickbeard.TORRENT_LABEL = torrent_label sickbeard.TORRENT_LABEL_ANIME = torrent_label_anime sickbeard.TORRENT_VERIFY_CERT = config.checkbox_to_value(torrent_verify_cert) sickbeard.TORRENT_PATH = torrent_path sickbeard.TORRENT_SEED_TIME = torrent_seed_time sickbeard.TORRENT_PAUSED = config.checkbox_to_value(torrent_paused) sickbeard.TORRENT_HIGH_BANDWIDTH = config.checkbox_to_value(torrent_high_bandwidth) sickbeard.TORRENT_HOST = config.clean_url(torrent_host) sickbeard.TORRENT_RPCURL = torrent_rpcurl sickbeard.TORRENT_AUTH_TYPE = torrent_auth_type sickbeard.save_config() if len(results) > 0: for x in results: logger.log(x, logger.ERROR) ui.notifications.error('Error(s) Saving Configuration', '<br />\n'.join(results)) else: ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) return self.redirect("/config/search/") @route('/config/postProcessing(/?.*)') class ConfigPostProcessing(Config): def __init__(self, *args, **kwargs): super(ConfigPostProcessing, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="config_postProcessing.tmpl") t.submenu = self.ConfigMenu() return t.respond() def savePostProcessing(self, naming_pattern=None, naming_multi_ep=None, kodi_data=None, kodi_12plus_data=None, mediabrowser_data=None, sony_ps3_data=None, wdtv_data=None, tivo_data=None, mede8er_data=None, keep_processed_dir=None, process_method=None, process_automatically=None, rename_episodes=None, airdate_episodes=None, unpack=None, move_associated_files=None, postpone_if_sync_files=None, nfo_rename=None, tv_download_dir=None, naming_custom_abd=None, naming_anime=None, naming_abd_pattern=None, naming_strip_year=None, use_failed_downloads=None, delete_failed=None, extra_scripts=None, skip_removed_files=None, naming_custom_sports=None, naming_sports_pattern=None, naming_custom_anime=None, naming_anime_pattern=None, naming_anime_multi_ep=None, autopostprocesser_frequency=None): results = [] if not config.change_TV_DOWNLOAD_DIR(tv_download_dir): results += ["Unable to create directory " + os.path.normpath(tv_download_dir) + ", dir not changed."] sickbeard.PROCESS_AUTOMATICALLY = config.checkbox_to_value(process_automatically) config.change_AUTOPOSTPROCESSER_FREQUENCY(autopostprocesser_frequency) if sickbeard.PROCESS_AUTOMATICALLY and not sickbeard.autoPostProcesserScheduler.isAlive(): sickbeard.autoPostProcesserScheduler.silent = False try: sickbeard.autoPostProcesserScheduler.start() except: pass elif not sickbeard.PROCESS_AUTOMATICALLY: sickbeard.autoPostProcesserScheduler.stop.set() sickbeard.autoPostProcesserScheduler.silent = True try: sickbeard.autoPostProcesserScheduler.join(5) except: pass if unpack: if self.isRarSupported() != 'not supported': sickbeard.UNPACK = config.checkbox_to_value(unpack) else: sickbeard.UNPACK = 0 results.append("Unpacking Not Supported, disabling unpack setting") else: sickbeard.UNPACK = config.checkbox_to_value(unpack) sickbeard.KEEP_PROCESSED_DIR = config.checkbox_to_value(keep_processed_dir) sickbeard.PROCESS_METHOD = process_method sickbeard.EXTRA_SCRIPTS = [x.strip() for x in extra_scripts.split('|') if x.strip()] sickbeard.RENAME_EPISODES = config.checkbox_to_value(rename_episodes) sickbeard.AIRDATE_EPISODES = config.checkbox_to_value(airdate_episodes) sickbeard.MOVE_ASSOCIATED_FILES = config.checkbox_to_value(move_associated_files) sickbeard.POSTPONE_IF_SYNC_FILES = config.checkbox_to_value(postpone_if_sync_files) sickbeard.NAMING_CUSTOM_ABD = config.checkbox_to_value(naming_custom_abd) sickbeard.NAMING_CUSTOM_SPORTS = config.checkbox_to_value(naming_custom_sports) sickbeard.NAMING_CUSTOM_ANIME = config.checkbox_to_value(naming_custom_anime) sickbeard.NAMING_STRIP_YEAR = config.checkbox_to_value(naming_strip_year) sickbeard.USE_FAILED_DOWNLOADS = config.checkbox_to_value(use_failed_downloads) sickbeard.DELETE_FAILED = config.checkbox_to_value(delete_failed) sickbeard.SKIP_REMOVED_FILES = config.checkbox_to_value(skip_removed_files) sickbeard.NFO_RENAME = config.checkbox_to_value(nfo_rename) sickbeard.METADATA_KODI = kodi_data sickbeard.METADATA_KODI_12PLUS = kodi_12plus_data sickbeard.METADATA_MEDIABROWSER = mediabrowser_data sickbeard.METADATA_PS3 = sony_ps3_data sickbeard.METADATA_WDTV = wdtv_data sickbeard.METADATA_TIVO = tivo_data sickbeard.METADATA_MEDE8ER = mede8er_data sickbeard.metadata_provider_dict['KODI'].set_config(sickbeard.METADATA_KODI) sickbeard.metadata_provider_dict['KODI 12+'].set_config(sickbeard.METADATA_KODI_12PLUS) sickbeard.metadata_provider_dict['MediaBrowser'].set_config(sickbeard.METADATA_MEDIABROWSER) sickbeard.metadata_provider_dict['Sony PS3'].set_config(sickbeard.METADATA_PS3) sickbeard.metadata_provider_dict['WDTV'].set_config(sickbeard.METADATA_WDTV) sickbeard.metadata_provider_dict['TIVO'].set_config(sickbeard.METADATA_TIVO) sickbeard.metadata_provider_dict['Mede8er'].set_config(sickbeard.METADATA_MEDE8ER) if self.isNamingValid(naming_pattern, naming_multi_ep, anime_type=naming_anime) != "invalid": sickbeard.NAMING_PATTERN = naming_pattern sickbeard.NAMING_MULTI_EP = int(naming_multi_ep) sickbeard.NAMING_ANIME = int(naming_anime) sickbeard.NAMING_FORCE_FOLDERS = naming.check_force_season_folders() else: if int(naming_anime) in [1, 2]: results.append("You tried saving an invalid anime naming config, not saving your naming settings") else: results.append("You tried saving an invalid naming config, not saving your naming settings") if self.isNamingValid(naming_anime_pattern, naming_anime_multi_ep, anime_type=naming_anime) != "invalid": sickbeard.NAMING_ANIME_PATTERN = naming_anime_pattern sickbeard.NAMING_ANIME_MULTI_EP = int(naming_anime_multi_ep) sickbeard.NAMING_ANIME = int(naming_anime) sickbeard.NAMING_FORCE_FOLDERS = naming.check_force_season_folders() else: if int(naming_anime) in [1, 2]: results.append("You tried saving an invalid anime naming config, not saving your naming settings") else: results.append("You tried saving an invalid naming config, not saving your naming settings") if self.isNamingValid(naming_abd_pattern, None, abd=True) != "invalid": sickbeard.NAMING_ABD_PATTERN = naming_abd_pattern else: results.append( "You tried saving an invalid air-by-date naming config, not saving your air-by-date settings") if self.isNamingValid(naming_sports_pattern, None, sports=True) != "invalid": sickbeard.NAMING_SPORTS_PATTERN = naming_sports_pattern else: results.append( "You tried saving an invalid sports naming config, not saving your sports settings") sickbeard.save_config() if len(results) > 0: for x in results: logger.log(x, logger.ERROR) ui.notifications.error('Error(s) Saving Configuration', '<br />\n'.join(results)) else: ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) return self.redirect("/config/postProcessing/") def testNaming(self, pattern=None, multi=None, abd=False, sports=False, anime_type=None): if multi is not None: multi = int(multi) if anime_type is not None: anime_type = int(anime_type) result = naming.test_name(pattern, multi, abd, sports, anime_type) result = ek.ek(os.path.join, result['dir'], result['name']) return result def isNamingValid(self, pattern=None, multi=None, abd=False, sports=False, anime_type=None): if pattern is None: return "invalid" if multi is not None: multi = int(multi) if anime_type is not None: anime_type = int(anime_type) # air by date shows just need one check, we don't need to worry about season folders if abd: is_valid = naming.check_valid_abd_naming(pattern) require_season_folders = False # sport shows just need one check, we don't need to worry about season folders elif sports: is_valid = naming.check_valid_sports_naming(pattern) require_season_folders = False else: # check validity of single and multi ep cases for the whole path is_valid = naming.check_valid_naming(pattern, multi, anime_type) # check validity of single and multi ep cases for only the file name require_season_folders = naming.check_force_season_folders(pattern, multi, anime_type) if is_valid and not require_season_folders: return "valid" elif is_valid and require_season_folders: return "seasonfolders" else: return "invalid" def isRarSupported(self): """ Test Packing Support: - Simulating in memory rar extraction on test.rar file """ try: rar_path = os.path.join(sickbeard.PROG_DIR, 'lib', 'unrar2', 'test.rar') testing = RarFile(rar_path).read_files('*test.txt') if testing[0][1] == 'This is only a test.': return 'supported' logger.log(u'Rar Not Supported: Can not read the content of test file', logger.ERROR) return 'not supported' except Exception, e: logger.log(u'Rar Not Supported: ' + ex(e), logger.ERROR) return 'not supported' @route('/config/providers(/?.*)') class ConfigProviders(Config): def __init__(self, *args, **kwargs): super(ConfigProviders, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="config_providers.tmpl") t.submenu = self.ConfigMenu() return t.respond() def canAddNewznabProvider(self, name): if not name: return json.dumps({'error': 'No Provider Name specified'}) providerDict = dict(zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList)) tempProvider = newznab.NewznabProvider(name, '') if tempProvider.getID() in providerDict: return json.dumps({'error': 'Provider Name already exists as ' + providerDict[tempProvider.getID()].name}) else: return json.dumps({'success': tempProvider.getID()}) def saveNewznabProvider(self, name, url, key=''): if not name or not url: return '0' providerDict = dict(zip([x.name for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList)) if name in providerDict: if not providerDict[name].default: providerDict[name].name = name providerDict[name].url = config.clean_url(url) providerDict[name].key = key # a 0 in the key spot indicates that no key is needed if key == '0': providerDict[name].needs_auth = False else: providerDict[name].needs_auth = True return providerDict[name].getID() + '|' + providerDict[name].configStr() else: newProvider = newznab.NewznabProvider(name, url, key=key) sickbeard.newznabProviderList.append(newProvider) return newProvider.getID() + '|' + newProvider.configStr() def getNewznabCategories(self, name, url, key): ''' Retrieves a list of possible categories with category id's Using the default url/api?cat http://yournewznaburl.com/api?t=caps&apikey=yourapikey ''' error = "" success = False if not name: error += "\nNo Provider Name specified" if not url: error += "\nNo Provider Url specified" if not key: error += "\nNo Provider Api key specified" if error <> "": return json.dumps({'success': False, 'error': error}) # Get list with Newznabproviders # providerDict = dict(zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList)) # Get newznabprovider obj with provided name tempProvider = newznab.NewznabProvider(name, url, key) success, tv_categories, error = tempProvider.get_newznab_categories() return json.dumps({'success': success, 'tv_categories': tv_categories, 'error': error}) def deleteNewznabProvider(self, nnid): providerDict = dict(zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList)) if nnid not in providerDict or providerDict[nnid].default: return '0' # delete it from the list sickbeard.newznabProviderList.remove(providerDict[nnid]) if nnid in sickbeard.PROVIDER_ORDER: sickbeard.PROVIDER_ORDER.remove(nnid) return '1' def canAddTorrentRssProvider(self, name, url, cookies): if not name: return json.dumps({'error': 'Invalid name specified'}) providerDict = dict( zip([x.getID() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList)) tempProvider = rsstorrent.TorrentRssProvider(name, url, cookies) if tempProvider.getID() in providerDict: return json.dumps({'error': 'Exists as ' + providerDict[tempProvider.getID()].name}) else: (succ, errMsg) = tempProvider.validateRSS() if succ: return json.dumps({'success': tempProvider.getID()}) else: return json.dumps({'error': errMsg}) def saveTorrentRssProvider(self, name, url, cookies): if not name or not url: return '0' providerDict = dict(zip([x.name for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList)) if name in providerDict: providerDict[name].name = name providerDict[name].url = config.clean_url(url) providerDict[name].cookies = cookies return providerDict[name].getID() + '|' + providerDict[name].configStr() else: newProvider = rsstorrent.TorrentRssProvider(name, url, cookies) sickbeard.torrentRssProviderList.append(newProvider) return newProvider.getID() + '|' + newProvider.configStr() def deleteTorrentRssProvider(self, id): providerDict = dict( zip([x.getID() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList)) if id not in providerDict: return '0' # delete it from the list sickbeard.torrentRssProviderList.remove(providerDict[id]) if id in sickbeard.PROVIDER_ORDER: sickbeard.PROVIDER_ORDER.remove(id) return '1' def saveProviders(self, newznab_string='', torrentrss_string='', provider_order=None, **kwargs): results = [] provider_str_list = provider_order.split() provider_list = [] newznabProviderDict = dict( zip([x.getID() for x in sickbeard.newznabProviderList], sickbeard.newznabProviderList)) finishedNames = [] # add all the newznab info we got into our list if newznab_string: for curNewznabProviderStr in newznab_string.split('!!!'): if not curNewznabProviderStr: continue cur_name, cur_url, cur_key, cur_cat = curNewznabProviderStr.split('|') cur_url = config.clean_url(cur_url) newProvider = newznab.NewznabProvider(cur_name, cur_url, key=cur_key) cur_id = newProvider.getID() # if it already exists then update it if cur_id in newznabProviderDict: newznabProviderDict[cur_id].name = cur_name newznabProviderDict[cur_id].url = cur_url newznabProviderDict[cur_id].key = cur_key newznabProviderDict[cur_id].catIDs = cur_cat # a 0 in the key spot indicates that no key is needed if cur_key == '0': newznabProviderDict[cur_id].needs_auth = False else: newznabProviderDict[cur_id].needs_auth = True try: newznabProviderDict[cur_id].search_mode = str(kwargs[cur_id + '_search_mode']).strip() except: pass try: newznabProviderDict[cur_id].search_fallback = config.checkbox_to_value( kwargs[cur_id + '_search_fallback']) except: newznabProviderDict[cur_id].search_fallback = 0 try: newznabProviderDict[cur_id].enable_daily = config.checkbox_to_value( kwargs[cur_id + '_enable_daily']) except: newznabProviderDict[cur_id].enable_daily = 0 try: newznabProviderDict[cur_id].enable_backlog = config.checkbox_to_value( kwargs[cur_id + '_enable_backlog']) except: newznabProviderDict[cur_id].enable_backlog = 0 else: sickbeard.newznabProviderList.append(newProvider) finishedNames.append(cur_id) # delete anything that is missing for curProvider in sickbeard.newznabProviderList: if curProvider.getID() not in finishedNames: sickbeard.newznabProviderList.remove(curProvider) torrentRssProviderDict = dict( zip([x.getID() for x in sickbeard.torrentRssProviderList], sickbeard.torrentRssProviderList)) finishedNames = [] if torrentrss_string: for curTorrentRssProviderStr in torrentrss_string.split('!!!'): if not curTorrentRssProviderStr: continue curName, curURL, curCookies = curTorrentRssProviderStr.split('|') curURL = config.clean_url(curURL) newProvider = rsstorrent.TorrentRssProvider(curName, curURL, curCookies) curID = newProvider.getID() # if it already exists then update it if curID in torrentRssProviderDict: torrentRssProviderDict[curID].name = curName torrentRssProviderDict[curID].url = curURL torrentRssProviderDict[curID].cookies = curCookies else: sickbeard.torrentRssProviderList.append(newProvider) finishedNames.append(curID) # delete anything that is missing for curProvider in sickbeard.torrentRssProviderList: if curProvider.getID() not in finishedNames: sickbeard.torrentRssProviderList.remove(curProvider) # do the enable/disable for curProviderStr in provider_str_list: curProvider, curEnabled = curProviderStr.split(':') curEnabled = config.to_int(curEnabled) curProvObj = [x for x in sickbeard.providers.sortedProviderList() if x.getID() == curProvider and hasattr(x, 'enabled')] if curProvObj: curProvObj[0].enabled = bool(curEnabled) provider_list.append(curProvider) if curProvider in newznabProviderDict: newznabProviderDict[curProvider].enabled = bool(curEnabled) elif curProvider in torrentRssProviderDict: torrentRssProviderDict[curProvider].enabled = bool(curEnabled) # dynamically load provider settings for curTorrentProvider in [curProvider for curProvider in sickbeard.providers.sortedProviderList() if curProvider.providerType == sickbeard.GenericProvider.TORRENT]: if hasattr(curTorrentProvider, 'minseed'): try: curTorrentProvider.minseed = int(str(kwargs[curTorrentProvider.getID() + '_minseed']).strip()) except: curTorrentProvider.minseed = 0 if hasattr(curTorrentProvider, 'minleech'): try: curTorrentProvider.minleech = int(str(kwargs[curTorrentProvider.getID() + '_minleech']).strip()) except: curTorrentProvider.minleech = 0 if hasattr(curTorrentProvider, 'ratio'): try: curTorrentProvider.ratio = str(kwargs[curTorrentProvider.getID() + '_ratio']).strip() except: curTorrentProvider.ratio = None if hasattr(curTorrentProvider, 'digest'): try: curTorrentProvider.digest = str(kwargs[curTorrentProvider.getID() + '_digest']).strip() except: curTorrentProvider.digest = None if hasattr(curTorrentProvider, 'hash'): try: curTorrentProvider.hash = str(kwargs[curTorrentProvider.getID() + '_hash']).strip() except: curTorrentProvider.hash = None if hasattr(curTorrentProvider, 'api_key'): try: curTorrentProvider.api_key = str(kwargs[curTorrentProvider.getID() + '_api_key']).strip() except: curTorrentProvider.api_key = None if hasattr(curTorrentProvider, 'username'): try: curTorrentProvider.username = str(kwargs[curTorrentProvider.getID() + '_username']).strip() except: curTorrentProvider.username = None if hasattr(curTorrentProvider, 'password'): try: curTorrentProvider.password = str(kwargs[curTorrentProvider.getID() + '_password']).strip() except: curTorrentProvider.password = None if hasattr(curTorrentProvider, 'passkey'): try: curTorrentProvider.passkey = str(kwargs[curTorrentProvider.getID() + '_passkey']).strip() except: curTorrentProvider.passkey = None if hasattr(curTorrentProvider, 'confirmed'): try: curTorrentProvider.confirmed = config.checkbox_to_value( kwargs[curTorrentProvider.getID() + '_confirmed']) except: curTorrentProvider.confirmed = 0 if hasattr(curTorrentProvider, 'proxy'): try: curTorrentProvider.proxy.enabled = config.checkbox_to_value( kwargs[curTorrentProvider.getID() + '_proxy']) except: curTorrentProvider.proxy.enabled = 0 if hasattr(curTorrentProvider.proxy, 'url'): try: curTorrentProvider.proxy.url = str(kwargs[curTorrentProvider.getID() + '_proxy_url']).strip() except: curTorrentProvider.proxy.url = None if hasattr(curTorrentProvider, 'freeleech'): try: curTorrentProvider.freeleech = config.checkbox_to_value( kwargs[curTorrentProvider.getID() + '_freeleech']) except: curTorrentProvider.freeleech = 0 if hasattr(curTorrentProvider, 'search_mode'): try: curTorrentProvider.search_mode = str(kwargs[curTorrentProvider.getID() + '_search_mode']).strip() except: curTorrentProvider.search_mode = 'eponly' if hasattr(curTorrentProvider, 'search_fallback'): try: curTorrentProvider.search_fallback = config.checkbox_to_value( kwargs[curTorrentProvider.getID() + '_search_fallback']) except: curTorrentProvider.search_fallback = 0 # these exceptions are catching unselected checkboxes if hasattr(curTorrentProvider, 'enable_daily'): try: curTorrentProvider.enable_daily = config.checkbox_to_value( kwargs[curTorrentProvider.getID() + '_enable_daily']) except: curTorrentProvider.enable_daily = 0 # these exceptions are actually catching unselected checkboxes if hasattr(curTorrentProvider, 'enable_backlog'): try: curTorrentProvider.enable_backlog = config.checkbox_to_value( kwargs[curTorrentProvider.getID() + '_enable_backlog']) except: curTorrentProvider.enable_backlog = 0 # these exceptions are actually catching unselected checkboxes for curNzbProvider in [curProvider for curProvider in sickbeard.providers.sortedProviderList() if curProvider.providerType == sickbeard.GenericProvider.NZB]: if hasattr(curNzbProvider, 'api_key'): try: curNzbProvider.api_key = str(kwargs[curNzbProvider.getID() + '_api_key']).strip() except: curNzbProvider.api_key = None if hasattr(curNzbProvider, 'username'): try: curNzbProvider.username = str(kwargs[curNzbProvider.getID() + '_username']).strip() except: curNzbProvider.username = None if hasattr(curNzbProvider, 'search_mode'): try: curNzbProvider.search_mode = str(kwargs[curNzbProvider.getID() + '_search_mode']).strip() except: curNzbProvider.search_mode = 'eponly' if hasattr(curNzbProvider, 'search_fallback'): try: curNzbProvider.search_fallback = config.checkbox_to_value( kwargs[curNzbProvider.getID() + '_search_fallback']) except: curNzbProvider.search_fallback = 0 # these exceptions are actually catching unselected checkboxes if hasattr(curNzbProvider, 'enable_daily'): try: curNzbProvider.enable_daily = config.checkbox_to_value( kwargs[curNzbProvider.getID() + '_enable_daily']) except: curNzbProvider.enable_daily = 0 # these exceptions are actually catching unselected checkboxes if hasattr(curNzbProvider, 'enable_backlog'): try: curNzbProvider.enable_backlog = config.checkbox_to_value( kwargs[curNzbProvider.getID() + '_enable_backlog']) except: curNzbProvider.enable_backlog = 0 # these exceptions are actually catching unselected checkboxes sickbeard.NEWZNAB_DATA = '!!!'.join([x.configStr() for x in sickbeard.newznabProviderList]) sickbeard.PROVIDER_ORDER = provider_list sickbeard.save_config() if len(results) > 0: for x in results: logger.log(x, logger.ERROR) ui.notifications.error('Error(s) Saving Configuration', '<br />\n'.join(results)) else: ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) return self.redirect("/config/providers/") @route('/config/notifications(/?.*)') class ConfigNotifications(Config): def __init__(self, *args, **kwargs): super(ConfigNotifications, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="config_notifications.tmpl") t.submenu = self.ConfigMenu() return t.respond() def saveNotifications(self, use_kodi=None, kodi_always_on=None, kodi_notify_onsnatch=None, kodi_notify_ondownload=None, kodi_notify_onsubtitledownload=None, kodi_update_onlyfirst=None, kodi_update_library=None, kodi_update_full=None, kodi_host=None, kodi_username=None, kodi_password=None, use_plex=None, plex_notify_onsnatch=None, plex_notify_ondownload=None, plex_notify_onsubtitledownload=None, plex_update_library=None, plex_server_host=None, plex_server_token=None, plex_host=None, plex_username=None, plex_password=None, use_growl=None, growl_notify_onsnatch=None, growl_notify_ondownload=None, growl_notify_onsubtitledownload=None, growl_host=None, growl_password=None, use_freemobile=None, freemobile_notify_onsnatch=None, freemobile_notify_ondownload=None, freemobile_notify_onsubtitledownload=None, freemobile_id=None, freemobile_apikey=None, use_prowl=None, prowl_notify_onsnatch=None, prowl_notify_ondownload=None, prowl_notify_onsubtitledownload=None, prowl_api=None, prowl_priority=0, use_twitter=None, twitter_notify_onsnatch=None, twitter_notify_ondownload=None, twitter_notify_onsubtitledownload=None, use_boxcar=None, boxcar_notify_onsnatch=None, boxcar_notify_ondownload=None, boxcar_notify_onsubtitledownload=None, boxcar_username=None, use_boxcar2=None, boxcar2_notify_onsnatch=None, boxcar2_notify_ondownload=None, boxcar2_notify_onsubtitledownload=None, boxcar2_accesstoken=None, use_pushover=None, pushover_notify_onsnatch=None, pushover_notify_ondownload=None, pushover_notify_onsubtitledownload=None, pushover_userkey=None, pushover_apikey=None, use_libnotify=None, libnotify_notify_onsnatch=None, libnotify_notify_ondownload=None, libnotify_notify_onsubtitledownload=None, use_nmj=None, nmj_host=None, nmj_database=None, nmj_mount=None, use_synoindex=None, use_nmjv2=None, nmjv2_host=None, nmjv2_dbloc=None, nmjv2_database=None, use_trakt=None, trakt_username=None, trakt_password=None, trakt_remove_watchlist=None, trakt_use_watchlist=None, trakt_method_add=None, trakt_start_paused=None, trakt_use_recommended=None, trakt_sync=None, trakt_default_indexer=None, trakt_remove_serieslist=None, trakt_disable_ssl_verify=None, trakt_timeout=None, use_synologynotifier=None, synologynotifier_notify_onsnatch=None, synologynotifier_notify_ondownload=None, synologynotifier_notify_onsubtitledownload=None, use_pytivo=None, pytivo_notify_onsnatch=None, pytivo_notify_ondownload=None, pytivo_notify_onsubtitledownload=None, pytivo_update_library=None, pytivo_host=None, pytivo_share_name=None, pytivo_tivo_name=None, use_nma=None, nma_notify_onsnatch=None, nma_notify_ondownload=None, nma_notify_onsubtitledownload=None, nma_api=None, nma_priority=0, use_pushalot=None, pushalot_notify_onsnatch=None, pushalot_notify_ondownload=None, pushalot_notify_onsubtitledownload=None, pushalot_authorizationtoken=None, use_pushbullet=None, pushbullet_notify_onsnatch=None, pushbullet_notify_ondownload=None, pushbullet_notify_onsubtitledownload=None, pushbullet_api=None, pushbullet_device=None, pushbullet_device_list=None, use_email=None, email_notify_onsnatch=None, email_notify_ondownload=None, email_notify_onsubtitledownload=None, email_host=None, email_port=25, email_from=None, email_tls=None, email_user=None, email_password=None, email_list=None, email_show_list=None, email_show=None): results = [] sickbeard.USE_KODI = config.checkbox_to_value(use_kodi) sickbeard.KODI_ALWAYS_ON = config.checkbox_to_value(kodi_always_on) sickbeard.KODI_NOTIFY_ONSNATCH = config.checkbox_to_value(kodi_notify_onsnatch) sickbeard.KODI_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(kodi_notify_ondownload) sickbeard.KODI_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(kodi_notify_onsubtitledownload) sickbeard.KODI_UPDATE_LIBRARY = config.checkbox_to_value(kodi_update_library) sickbeard.KODI_UPDATE_FULL = config.checkbox_to_value(kodi_update_full) sickbeard.KODI_UPDATE_ONLYFIRST = config.checkbox_to_value(kodi_update_onlyfirst) sickbeard.KODI_HOST = config.clean_hosts(kodi_host) sickbeard.KODI_USERNAME = kodi_username sickbeard.KODI_PASSWORD = kodi_password sickbeard.USE_PLEX = config.checkbox_to_value(use_plex) sickbeard.PLEX_NOTIFY_ONSNATCH = config.checkbox_to_value(plex_notify_onsnatch) sickbeard.PLEX_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(plex_notify_ondownload) sickbeard.PLEX_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(plex_notify_onsubtitledownload) sickbeard.PLEX_UPDATE_LIBRARY = config.checkbox_to_value(plex_update_library) sickbeard.PLEX_HOST = config.clean_hosts(plex_host) sickbeard.PLEX_SERVER_HOST = config.clean_host(plex_server_host) sickbeard.PLEX_SERVER_TOKEN = config.clean_host(plex_server_token) sickbeard.PLEX_USERNAME = plex_username sickbeard.PLEX_PASSWORD = plex_password sickbeard.USE_GROWL = config.checkbox_to_value(use_growl) sickbeard.GROWL_NOTIFY_ONSNATCH = config.checkbox_to_value(growl_notify_onsnatch) sickbeard.GROWL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(growl_notify_ondownload) sickbeard.GROWL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(growl_notify_onsubtitledownload) sickbeard.GROWL_HOST = config.clean_host(growl_host, default_port=23053) sickbeard.GROWL_PASSWORD = growl_password sickbeard.USE_FREEMOBILE = config.checkbox_to_value(use_freemobile) sickbeard.FREEMOBILE_NOTIFY_ONSNATCH = config.checkbox_to_value(freemobile_notify_onsnatch) sickbeard.FREEMOBILE_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(freemobile_notify_ondownload) sickbeard.FREEMOBILE_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(freemobile_notify_onsubtitledownload) sickbeard.FREEMOBILE_ID = freemobile_id sickbeard.FREEMOBILE_APIKEY = freemobile_apikey sickbeard.USE_PROWL = config.checkbox_to_value(use_prowl) sickbeard.PROWL_NOTIFY_ONSNATCH = config.checkbox_to_value(prowl_notify_onsnatch) sickbeard.PROWL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(prowl_notify_ondownload) sickbeard.PROWL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(prowl_notify_onsubtitledownload) sickbeard.PROWL_API = prowl_api sickbeard.PROWL_PRIORITY = prowl_priority sickbeard.USE_TWITTER = config.checkbox_to_value(use_twitter) sickbeard.TWITTER_NOTIFY_ONSNATCH = config.checkbox_to_value(twitter_notify_onsnatch) sickbeard.TWITTER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(twitter_notify_ondownload) sickbeard.TWITTER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(twitter_notify_onsubtitledownload) sickbeard.USE_BOXCAR = config.checkbox_to_value(use_boxcar) sickbeard.BOXCAR_NOTIFY_ONSNATCH = config.checkbox_to_value(boxcar_notify_onsnatch) sickbeard.BOXCAR_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(boxcar_notify_ondownload) sickbeard.BOXCAR_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(boxcar_notify_onsubtitledownload) sickbeard.BOXCAR_USERNAME = boxcar_username sickbeard.USE_BOXCAR2 = config.checkbox_to_value(use_boxcar2) sickbeard.BOXCAR2_NOTIFY_ONSNATCH = config.checkbox_to_value(boxcar2_notify_onsnatch) sickbeard.BOXCAR2_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(boxcar2_notify_ondownload) sickbeard.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(boxcar2_notify_onsubtitledownload) sickbeard.BOXCAR2_ACCESSTOKEN = boxcar2_accesstoken sickbeard.USE_PUSHOVER = config.checkbox_to_value(use_pushover) sickbeard.PUSHOVER_NOTIFY_ONSNATCH = config.checkbox_to_value(pushover_notify_onsnatch) sickbeard.PUSHOVER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(pushover_notify_ondownload) sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(pushover_notify_onsubtitledownload) sickbeard.PUSHOVER_USERKEY = pushover_userkey sickbeard.PUSHOVER_APIKEY = pushover_apikey sickbeard.USE_LIBNOTIFY = config.checkbox_to_value(use_libnotify) sickbeard.LIBNOTIFY_NOTIFY_ONSNATCH = config.checkbox_to_value(libnotify_notify_onsnatch) sickbeard.LIBNOTIFY_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(libnotify_notify_ondownload) sickbeard.LIBNOTIFY_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(libnotify_notify_onsubtitledownload) sickbeard.USE_NMJ = config.checkbox_to_value(use_nmj) sickbeard.NMJ_HOST = config.clean_host(nmj_host) sickbeard.NMJ_DATABASE = nmj_database sickbeard.NMJ_MOUNT = nmj_mount sickbeard.USE_NMJv2 = config.checkbox_to_value(use_nmjv2) sickbeard.NMJv2_HOST = config.clean_host(nmjv2_host) sickbeard.NMJv2_DATABASE = nmjv2_database sickbeard.NMJv2_DBLOC = nmjv2_dbloc sickbeard.USE_SYNOINDEX = config.checkbox_to_value(use_synoindex) sickbeard.USE_SYNOLOGYNOTIFIER = config.checkbox_to_value(use_synologynotifier) sickbeard.SYNOLOGYNOTIFIER_NOTIFY_ONSNATCH = config.checkbox_to_value(synologynotifier_notify_onsnatch) sickbeard.SYNOLOGYNOTIFIER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(synologynotifier_notify_ondownload) sickbeard.SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( synologynotifier_notify_onsubtitledownload) sickbeard.USE_TRAKT = config.checkbox_to_value(use_trakt) sickbeard.TRAKT_USERNAME = trakt_username sickbeard.TRAKT_PASSWORD = trakt_password sickbeard.TRAKT_REMOVE_WATCHLIST = config.checkbox_to_value(trakt_remove_watchlist) sickbeard.TRAKT_REMOVE_SERIESLIST = config.checkbox_to_value(trakt_remove_serieslist) sickbeard.TRAKT_USE_WATCHLIST = config.checkbox_to_value(trakt_use_watchlist) sickbeard.TRAKT_METHOD_ADD = int(trakt_method_add) sickbeard.TRAKT_START_PAUSED = config.checkbox_to_value(trakt_start_paused) sickbeard.TRAKT_USE_RECOMMENDED = config.checkbox_to_value(trakt_use_recommended) sickbeard.TRAKT_SYNC = config.checkbox_to_value(trakt_sync) sickbeard.TRAKT_DEFAULT_INDEXER = int(trakt_default_indexer) sickbeard.TRAKT_DISABLE_SSL_VERIFY = config.checkbox_to_value(trakt_disable_ssl_verify) sickbeard.TRAKT_TIMEOUT = int(trakt_timeout) if sickbeard.USE_TRAKT: sickbeard.traktCheckerScheduler.silent = False else: sickbeard.traktCheckerScheduler.silent = True sickbeard.USE_EMAIL = config.checkbox_to_value(use_email) sickbeard.EMAIL_NOTIFY_ONSNATCH = config.checkbox_to_value(email_notify_onsnatch) sickbeard.EMAIL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(email_notify_ondownload) sickbeard.EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(email_notify_onsubtitledownload) sickbeard.EMAIL_HOST = config.clean_host(email_host) sickbeard.EMAIL_PORT = config.to_int(email_port, default=25) sickbeard.EMAIL_FROM = email_from sickbeard.EMAIL_TLS = config.checkbox_to_value(email_tls) sickbeard.EMAIL_USER = email_user sickbeard.EMAIL_PASSWORD = email_password sickbeard.EMAIL_LIST = email_list sickbeard.USE_PYTIVO = config.checkbox_to_value(use_pytivo) sickbeard.PYTIVO_NOTIFY_ONSNATCH = config.checkbox_to_value(pytivo_notify_onsnatch) sickbeard.PYTIVO_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(pytivo_notify_ondownload) sickbeard.PYTIVO_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(pytivo_notify_onsubtitledownload) sickbeard.PYTIVO_UPDATE_LIBRARY = config.checkbox_to_value(pytivo_update_library) sickbeard.PYTIVO_HOST = config.clean_host(pytivo_host) sickbeard.PYTIVO_SHARE_NAME = pytivo_share_name sickbeard.PYTIVO_TIVO_NAME = pytivo_tivo_name sickbeard.USE_NMA = config.checkbox_to_value(use_nma) sickbeard.NMA_NOTIFY_ONSNATCH = config.checkbox_to_value(nma_notify_onsnatch) sickbeard.NMA_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(nma_notify_ondownload) sickbeard.NMA_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(nma_notify_onsubtitledownload) sickbeard.NMA_API = nma_api sickbeard.NMA_PRIORITY = nma_priority sickbeard.USE_PUSHALOT = config.checkbox_to_value(use_pushalot) sickbeard.PUSHALOT_NOTIFY_ONSNATCH = config.checkbox_to_value(pushalot_notify_onsnatch) sickbeard.PUSHALOT_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(pushalot_notify_ondownload) sickbeard.PUSHALOT_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(pushalot_notify_onsubtitledownload) sickbeard.PUSHALOT_AUTHORIZATIONTOKEN = pushalot_authorizationtoken sickbeard.USE_PUSHBULLET = config.checkbox_to_value(use_pushbullet) sickbeard.PUSHBULLET_NOTIFY_ONSNATCH = config.checkbox_to_value(pushbullet_notify_onsnatch) sickbeard.PUSHBULLET_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(pushbullet_notify_ondownload) sickbeard.PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(pushbullet_notify_onsubtitledownload) sickbeard.PUSHBULLET_API = pushbullet_api sickbeard.PUSHBULLET_DEVICE = pushbullet_device_list sickbeard.save_config() if len(results) > 0: for x in results: logger.log(x, logger.ERROR) ui.notifications.error('Error(s) Saving Configuration', '<br />\n'.join(results)) else: ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) return self.redirect("/config/notifications/") @route('/config/subtitles(/?.*)') class ConfigSubtitles(Config): def __init__(self, *args, **kwargs): super(ConfigSubtitles, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="config_subtitles.tmpl") t.submenu = self.ConfigMenu() return t.respond() def saveSubtitles(self, use_subtitles=None, subtitles_plugins=None, subtitles_languages=None, subtitles_dir=None, service_order=None, subtitles_history=None, subtitles_finder_frequency=None, subtitles_multi=None): results = [] if subtitles_finder_frequency == '' or subtitles_finder_frequency is None: subtitles_finder_frequency = 1 if use_subtitles == "on" and not sickbeard.subtitlesFinderScheduler.isAlive(): sickbeard.subtitlesFinderScheduler.silent = False try: sickbeard.subtitlesFinderScheduler.start() except: pass elif not use_subtitles == "on": sickbeard.subtitlesFinderScheduler.stop.set() sickbeard.subtitlesFinderScheduler.silent = True try: sickbeard.subtitlesFinderScheduler.join(5) except: pass sickbeard.USE_SUBTITLES = config.checkbox_to_value(use_subtitles) sickbeard.SUBTITLES_LANGUAGES = [lang.alpha2 for lang in subtitles.isValidLanguage( subtitles_languages.replace(' ', '').split(','))] if subtitles_languages != '' else '' sickbeard.SUBTITLES_DIR = subtitles_dir sickbeard.SUBTITLES_HISTORY = config.checkbox_to_value(subtitles_history) sickbeard.SUBTITLES_FINDER_FREQUENCY = config.to_int(subtitles_finder_frequency, default=1) sickbeard.SUBTITLES_MULTI = config.checkbox_to_value(subtitles_multi) # Subtitles services services_str_list = service_order.split() subtitles_services_list = [] subtitles_services_enabled = [] for curServiceStr in services_str_list: curService, curEnabled = curServiceStr.split(':') subtitles_services_list.append(curService) subtitles_services_enabled.append(int(curEnabled)) sickbeard.SUBTITLES_SERVICES_LIST = subtitles_services_list sickbeard.SUBTITLES_SERVICES_ENABLED = subtitles_services_enabled sickbeard.save_config() if len(results) > 0: for x in results: logger.log(x, logger.ERROR) ui.notifications.error('Error(s) Saving Configuration', '<br />\n'.join(results)) else: ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) return self.redirect("/config/subtitles/") @route('/config/anime(/?.*)') class ConfigAnime(Config): def __init__(self, *args, **kwargs): super(ConfigAnime, self).__init__(*args, **kwargs) def index(self): t = PageTemplate(rh=self, file="config_anime.tmpl") t.submenu = self.ConfigMenu() return t.respond() def saveAnime(self, use_anidb=None, anidb_username=None, anidb_password=None, anidb_use_mylist=None, split_home=None): results = [] sickbeard.USE_ANIDB = config.checkbox_to_value(use_anidb) sickbeard.ANIDB_USERNAME = anidb_username sickbeard.ANIDB_PASSWORD = anidb_password sickbeard.ANIDB_USE_MYLIST = config.checkbox_to_value(anidb_use_mylist) sickbeard.ANIME_SPLIT_HOME = config.checkbox_to_value(split_home) sickbeard.save_config() if len(results) > 0: for x in results: logger.log(x, logger.ERROR) ui.notifications.error('Error(s) Saving Configuration', '<br />\n'.join(results)) else: ui.notifications.message('Configuration Saved', ek.ek(os.path.join, sickbeard.CONFIG_FILE)) return self.redirect("/config/anime/") @route('/errorlogs(/?.*)') class ErrorLogs(WebRoot): def __init__(self, *args, **kwargs): super(ErrorLogs, self).__init__(*args, **kwargs) def ErrorLogsMenu(self): menu = [ {'title': 'Clear Errors', 'path': 'errorlogs/clearerrors/'}, {'title': 'Submit Errors', 'path': 'errorlogs/submit_errors/', 'requires': self.haveErrors}, ] return menu def index(self): t = PageTemplate(rh=self, file="errorlogs.tmpl") t.submenu = self.ErrorLogsMenu() return t.respond() def haveErrors(self): if len(classes.ErrorViewer.errors) > 0: return True def clearerrors(self): classes.ErrorViewer.clear() return self.redirect("/errorlogs/") def viewlog(self, minLevel=logger.INFO, maxLines=500): t = PageTemplate(rh=self, file="viewlogs.tmpl") t.submenu = self.ErrorLogsMenu() minLevel = int(minLevel) data = [] if os.path.isfile(logger.logFile): with ek.ek(open, logger.logFile) as f: data = f.readlines() regex = "^(\d\d\d\d)\-(\d\d)\-(\d\d)\s*(\d\d)\:(\d\d):(\d\d)\s*([A-Z]+)\s*(.+?)\s*\:\:\s*(.*)$" finalData = [] numLines = 0 lastLine = False numToShow = min(maxLines, len(data)) for x in reversed(data): x = ek.ss(x) match = re.match(regex, x) if match: level = match.group(7) if level not in logger.reverseNames: lastLine = False continue if logger.reverseNames[level] >= minLevel: lastLine = True finalData.append(x) else: lastLine = False continue elif lastLine: finalData.append("AA" + x) numLines += 1 if numLines >= numToShow: break result = "".join(finalData) t.logLines = result t.minLevel = minLevel return t.respond() def submit_errors(self): if not (sickbeard.GIT_USERNAME and sickbeard.GIT_PASSWORD): logger.log(u'Please set your GitHub username and password in the config, unable to submit issue ticket to GitHub!') else: issue = logger.submit_errors() if issue: ui.notifications.message('Your issue ticket #%s was submitted successfully!' % issue.number) return self.redirect("/errorlogs/")
gpl-3.0
[ 3, 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 31066, 14, 199, 3, 199, 3, 28964, 31066, 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, 28964, 31066, 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, 28964, 31066, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 5190, 199, 646, 747, 199, 646, 900, 199, 646, 4011, 199, 646, 295, 199, 646, 2197, 199, 199, 646, 17898, 199, 504, 17898, 492, 1101, 12, 308, 371, 199, 504, 17898, 492, 13431, 199, 504, 17898, 492, 7994, 12, 949, 1428, 1192, 12, 2112, 12764, 199, 504, 17898, 492, 8574, 199, 504, 17898, 492, 2512, 12, 10897, 12, 4967, 12, 3992, 12, 1592, 199, 504, 17898, 492, 2644, 43, 76, 16603, 465, 325, 75, 199, 504, 17898, 492, 2754, 63, 1825, 199, 504, 17898, 492, 1834, 63, 1637, 199, 504, 17898, 492, 19720, 199, 504, 17898, 492, 13856, 63, 3924, 199, 504, 17898, 492, 19297, 199, 504, 17898, 492, 2784, 63, 7145, 83, 199, 504, 17898, 492, 20088, 2083, 199, 504, 17898, 14, 9710, 492, 892, 31591, 371, 12, 10717, 8041, 640, 199, 504, 17898, 14, 2330, 492, 24108, 12, 7259, 1345, 12, 2004, 12672, 12, 11030, 2398, 409, 12672, 12, 5033, 63, 657, 2193, 199, 504, 17898, 14, 2330, 492, 428, 46, 8078, 1149, 12, 6778, 7730, 7387, 12, 27499, 25517, 12, 4160, 1244, 30487, 12, 644, 1441, 1149, 12, 26892, 199, 504, 17898, 14, 2330, 492, 428, 36, 12, 869, 36, 18386, 80, 12, 869, 36, 23514, 80, 199, 504, 17898, 14, 3924, 492, 444, 199, 504, 17898, 14, 8399, 460, 14189, 492, 30593, 3325, 19803, 1296, 199, 504, 17898, 14, 10436, 63, 3924, 492, 664, 63, 10436, 63, 3924, 199, 504, 17898, 14, 5750, 492, 16533, 1271, 2042, 199, 504, 17898, 14, 10436, 63, 1955, 316, 492, 664, 63, 10436, 63, 1955, 316, 12, 663, 63, 10436, 63, 1955, 316, 12, 664, 63, 10436, 63, 1955, 316, 63, 509, 63, 2384, 12, 971, 272, 664, 63, 1845, 77, 63, 1955, 316, 63, 509, 63, 2384, 12, 664, 63, 10436, 63, 6116, 63, 1955, 316, 63, 509, 63, 2384, 12, 664, 63, 1845, 77, 63, 6116, 63, 1955, 316, 63, 509, 63, 2384, 12, 971, 272, 664, 63, 10436, 63, 6116, 63, 1955, 316, 199, 199, 504, 1973, 14, 602, 1974, 492, 5823, 12, 1798, 465, 22208, 63, 2087, 199, 504, 1973, 14, 324, 26378, 18, 492, 820, 285, 1173, 199, 504, 1973, 492, 282, 27634, 12, 1007, 13769, 279, 199, 504, 1973, 14, 28257, 492, 12643, 5973, 3735, 199, 504, 1973, 14, 28257, 14, 3924, 492, 30501, 1726, 12, 30501, 2817, 1726, 12, 30501, 3120, 28759, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 687, 1973, 492, 13804, 465, 2022, 199, 199, 893, 26, 272, 492, 2748, 14, 9464, 14, 67, 15325, 465, 7559, 199, 2590, 3545, 26, 272, 492, 2748, 14, 9464, 14, 15325, 465, 7559, 199, 199, 504, 445, 426, 1841, 72, 14, 4231, 492, 5458, 465, 445, 426, 1841, 72, 4231, 199, 504, 445, 426, 1841, 72, 14, 18053, 492, 9388, 465, 445, 426, 1841, 72, 4131, 199, 199, 504, 12148, 14, 13243, 492, 7475, 199, 504, 12148, 14, 2520, 492, 4784, 2461, 12, 15050, 12, 15082, 12, 15608, 199, 504, 12148, 14, 2268, 492, 1970, 13242, 199, 504, 12148, 14, 27212, 492, 25584, 199, 504, 12148, 14, 27237, 492, 1255, 63, 265, 63, 13471, 199, 504, 23002, 14, 25513, 492, 11086, 5453, 16752, 199, 199, 4449, 63, 20218, 275, 1052, 421, 199, 533, 3517, 63, 8327, 8, 20335, 1841, 72, 4131, 304, 272, 347, 2457, 8, 277, 12, 1139, 12, 1011, 5869, 63, 829, 304, 267, 340, 1228, 8, 637, 12, 2649, 304, 288, 9806, 275, 1139, 14, 2143, 360, 4371, 297, 283, 1652, 24253, 1814, 358, 267, 916, 1139, 365, 488, 26, 288, 9806, 275, 2125, 267, 916, 1228, 8, 637, 12, 620, 304, 288, 9806, 275, 1139, 14, 2708, 8, 32370, 15283, 14, 13326, 63, 16314, 680, 2143, 360, 4371, 297, 283, 1652, 24253, 1814, 358, 267, 587, 26, 288, 9806, 275, 291, 14, 1541, 8, 495, 8, 637, 430, 398, 372, 9806, 421, 199, 533, 10331, 4231, 8, 20335, 1841, 72, 4231, 304, 272, 347, 636, 826, 721, 277, 12, 26006, 12, 627, 589, 12, 1011, 958, 304, 267, 2074, 459, 493, 418, 275, 747, 14, 515, 14, 904, 8, 32370, 15283, 14, 2514, 39, 63, 3022, 12, 298, 5885, 6687, 435, 17898, 14, 14438, 63, 2339, 435, 3286, 7436, 15, 885, 10665, 2074, 459, 493, 1105, 267, 2074, 459, 1541, 418, 275, 3517, 63, 8327, 267, 1613, 8, 3276, 4231, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 398, 291, 14, 9264, 6405, 275, 17898, 14, 13166, 63, 5441, 267, 291, 14, 9264, 5779, 4313, 275, 17898, 14, 13166, 63, 3657, 267, 291, 14, 9264, 5779, 83, 4313, 275, 17898, 14, 13166, 63, 3657, 267, 291, 14, 9264, 5779, 83, 6589, 275, 17898, 14, 8898, 63, 14921, 267, 291, 14, 9264, 5940, 14987, 4936, 275, 17898, 14, 15885, 63, 907, 21233, 63, 20026, 267, 291, 14, 9264, 16849, 985, 275, 17898, 14, 18061, 3635, 63, 2339, 267, 291, 14, 9264, 8880, 275, 26006, 14, 362, 63 ]
[ 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 31066, 14, 199, 3, 199, 3, 28964, 31066, 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, 28964, 31066, 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, 28964, 31066, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 199, 646, 5190, 199, 646, 747, 199, 646, 900, 199, 646, 4011, 199, 646, 295, 199, 646, 2197, 199, 199, 646, 17898, 199, 504, 17898, 492, 1101, 12, 308, 371, 199, 504, 17898, 492, 13431, 199, 504, 17898, 492, 7994, 12, 949, 1428, 1192, 12, 2112, 12764, 199, 504, 17898, 492, 8574, 199, 504, 17898, 492, 2512, 12, 10897, 12, 4967, 12, 3992, 12, 1592, 199, 504, 17898, 492, 2644, 43, 76, 16603, 465, 325, 75, 199, 504, 17898, 492, 2754, 63, 1825, 199, 504, 17898, 492, 1834, 63, 1637, 199, 504, 17898, 492, 19720, 199, 504, 17898, 492, 13856, 63, 3924, 199, 504, 17898, 492, 19297, 199, 504, 17898, 492, 2784, 63, 7145, 83, 199, 504, 17898, 492, 20088, 2083, 199, 504, 17898, 14, 9710, 492, 892, 31591, 371, 12, 10717, 8041, 640, 199, 504, 17898, 14, 2330, 492, 24108, 12, 7259, 1345, 12, 2004, 12672, 12, 11030, 2398, 409, 12672, 12, 5033, 63, 657, 2193, 199, 504, 17898, 14, 2330, 492, 428, 46, 8078, 1149, 12, 6778, 7730, 7387, 12, 27499, 25517, 12, 4160, 1244, 30487, 12, 644, 1441, 1149, 12, 26892, 199, 504, 17898, 14, 2330, 492, 428, 36, 12, 869, 36, 18386, 80, 12, 869, 36, 23514, 80, 199, 504, 17898, 14, 3924, 492, 444, 199, 504, 17898, 14, 8399, 460, 14189, 492, 30593, 3325, 19803, 1296, 199, 504, 17898, 14, 10436, 63, 3924, 492, 664, 63, 10436, 63, 3924, 199, 504, 17898, 14, 5750, 492, 16533, 1271, 2042, 199, 504, 17898, 14, 10436, 63, 1955, 316, 492, 664, 63, 10436, 63, 1955, 316, 12, 663, 63, 10436, 63, 1955, 316, 12, 664, 63, 10436, 63, 1955, 316, 63, 509, 63, 2384, 12, 971, 272, 664, 63, 1845, 77, 63, 1955, 316, 63, 509, 63, 2384, 12, 664, 63, 10436, 63, 6116, 63, 1955, 316, 63, 509, 63, 2384, 12, 664, 63, 1845, 77, 63, 6116, 63, 1955, 316, 63, 509, 63, 2384, 12, 971, 272, 664, 63, 10436, 63, 6116, 63, 1955, 316, 199, 199, 504, 1973, 14, 602, 1974, 492, 5823, 12, 1798, 465, 22208, 63, 2087, 199, 504, 1973, 14, 324, 26378, 18, 492, 820, 285, 1173, 199, 504, 1973, 492, 282, 27634, 12, 1007, 13769, 279, 199, 504, 1973, 14, 28257, 492, 12643, 5973, 3735, 199, 504, 1973, 14, 28257, 14, 3924, 492, 30501, 1726, 12, 30501, 2817, 1726, 12, 30501, 3120, 28759, 199, 199, 893, 26, 272, 492, 2022, 199, 2590, 3545, 26, 272, 687, 1973, 492, 13804, 465, 2022, 199, 199, 893, 26, 272, 492, 2748, 14, 9464, 14, 67, 15325, 465, 7559, 199, 2590, 3545, 26, 272, 492, 2748, 14, 9464, 14, 15325, 465, 7559, 199, 199, 504, 445, 426, 1841, 72, 14, 4231, 492, 5458, 465, 445, 426, 1841, 72, 4231, 199, 504, 445, 426, 1841, 72, 14, 18053, 492, 9388, 465, 445, 426, 1841, 72, 4131, 199, 199, 504, 12148, 14, 13243, 492, 7475, 199, 504, 12148, 14, 2520, 492, 4784, 2461, 12, 15050, 12, 15082, 12, 15608, 199, 504, 12148, 14, 2268, 492, 1970, 13242, 199, 504, 12148, 14, 27212, 492, 25584, 199, 504, 12148, 14, 27237, 492, 1255, 63, 265, 63, 13471, 199, 504, 23002, 14, 25513, 492, 11086, 5453, 16752, 199, 199, 4449, 63, 20218, 275, 1052, 421, 199, 533, 3517, 63, 8327, 8, 20335, 1841, 72, 4131, 304, 272, 347, 2457, 8, 277, 12, 1139, 12, 1011, 5869, 63, 829, 304, 267, 340, 1228, 8, 637, 12, 2649, 304, 288, 9806, 275, 1139, 14, 2143, 360, 4371, 297, 283, 1652, 24253, 1814, 358, 267, 916, 1139, 365, 488, 26, 288, 9806, 275, 2125, 267, 916, 1228, 8, 637, 12, 620, 304, 288, 9806, 275, 1139, 14, 2708, 8, 32370, 15283, 14, 13326, 63, 16314, 680, 2143, 360, 4371, 297, 283, 1652, 24253, 1814, 358, 267, 587, 26, 288, 9806, 275, 291, 14, 1541, 8, 495, 8, 637, 430, 398, 372, 9806, 421, 199, 533, 10331, 4231, 8, 20335, 1841, 72, 4231, 304, 272, 347, 636, 826, 721, 277, 12, 26006, 12, 627, 589, 12, 1011, 958, 304, 267, 2074, 459, 493, 418, 275, 747, 14, 515, 14, 904, 8, 32370, 15283, 14, 2514, 39, 63, 3022, 12, 298, 5885, 6687, 435, 17898, 14, 14438, 63, 2339, 435, 3286, 7436, 15, 885, 10665, 2074, 459, 493, 1105, 267, 2074, 459, 1541, 418, 275, 3517, 63, 8327, 267, 1613, 8, 3276, 4231, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 398, 291, 14, 9264, 6405, 275, 17898, 14, 13166, 63, 5441, 267, 291, 14, 9264, 5779, 4313, 275, 17898, 14, 13166, 63, 3657, 267, 291, 14, 9264, 5779, 83, 4313, 275, 17898, 14, 13166, 63, 3657, 267, 291, 14, 9264, 5779, 83, 6589, 275, 17898, 14, 8898, 63, 14921, 267, 291, 14, 9264, 5940, 14987, 4936, 275, 17898, 14, 15885, 63, 907, 21233, 63, 20026, 267, 291, 14, 9264, 16849, 985, 275, 17898, 14, 18061, 3635, 63, 2339, 267, 291, 14, 9264, 8880, 275, 26006, 14, 362, 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, 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 ]
cjhak/b2share
invenio/modules/workflows/tasks/logic_tasks.py
15
10445
# -*- coding: utf-8 -*- # This file is part of Invenio. # Copyright (C) 2013, 2014 CERN. # # Invenio 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. # # Invenio 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 Invenio; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. """Set of workflow logic tasks.""" from six import callable from functools import wraps def foreach(get_list_function=None, savename=None, cache_data=False, order="ASC"): """Simple for each without memory of previous state. :param get_list_function: function returning the list on which we should iterate. :param savename: name of variable to save the current loop state in the extra_data in case you want to reuse the value somewhere in a task. :param cache_data: can be True or False in case of True, the list will be cached in memory instead of being recomputed everytime. In case of caching the list is no more dynamic. :param order: because we should iterate over a list you can choose in which order you want to iterate over your list from start to end(ASC) or from end to start (DSC). """ if order not in ["ASC", "DSC"]: order = "ASC" @wraps(foreach) def _foreach(obj, eng): my_list_to_process = [] step = str(eng.getCurrTaskId()) try: if "_Iterators" not in eng.extra_data: eng.extra_data["_Iterators"] = {} except KeyError: eng.extra_data["_Iterators"] = {} if step not in eng.extra_data["_Iterators"]: eng.extra_data["_Iterators"][step] = {} if cache_data: if callable(get_list_function): eng.extra_data["_Iterators"][step]["cache"] = get_list_function(obj, eng) elif isinstance(get_list_function, list): eng.extra_data["_Iterators"][step]["cache"] = get_list_function else: eng.extra_data["_Iterators"][step]["cache"] = [] my_list_to_process = eng.extra_data["_Iterators"][step]["cache"] if order == "ASC": eng.extra_data["_Iterators"][step].update({"value": 0}) elif order == "DSC": eng.extra_data["_Iterators"][step].update({"value": len(my_list_to_process) - 1}) eng.extra_data["_Iterators"][step]["previous_data"] = obj.data if callable(get_list_function): if cache_data: my_list_to_process = eng.extra_data["_Iterators"][step]["cache"] else: my_list_to_process = get_list_function(obj, eng) elif isinstance(get_list_function, list): my_list_to_process = get_list_function else: my_list_to_process = [] if order == "ASC" and eng.extra_data["_Iterators"][step]["value"] < len(my_list_to_process): obj.data = my_list_to_process[eng.extra_data["_Iterators"][step]["value"]] if savename is not None: obj.extra_data[savename] = obj.data eng.extra_data["_Iterators"][step]["value"] += 1 elif order == "DSC" and eng.extra_data["_Iterators"][step]["value"] > -1: obj.data = my_list_to_process[eng.extra_data["_Iterators"][step]["value"]] if savename is not None: obj.extra_data[savename] = obj.data eng.extra_data["_Iterators"][step]["value"] -= 1 else: obj.data = eng.extra_data["_Iterators"][step]["previous_data"] del eng.extra_data["_Iterators"][step] coordonatex = len(eng.getCurrTaskId()) - 1 coordonatey = eng.getCurrTaskId()[coordonatex] new_vector = eng.getCurrTaskId() new_vector[coordonatex] = coordonatey + 2 eng.setPosition(eng.getCurrObjId(), new_vector) _foreach.hide = True return _foreach def simple_for(inita, enda, incrementa, variable_name=None): """Simple for going from inita to enda by step of incrementa. :param inita: the starting value :param enda: the ending value :param incrementa: the increment of the value for each iteration :param variable_name: if needed the name in extra_data where we want to store the value """ @wraps(simple_for) def _simple_for(obj, eng): init = inita end = enda increment = incrementa while callable(init): init = init(obj, eng) while callable(end): end = end(obj, eng) while callable(increment): increment = increment(obj, eng) finish = False step = str(eng.getCurrTaskId()) try: if "_Iterators" not in eng.extra_data: eng.extra_data["_Iterators"] = {} except KeyError: eng.extra_data["_Iterators"] = {} if step not in eng.extra_data["_Iterators"]: eng.extra_data["_Iterators"][step] = {} eng.extra_data["_Iterators"][step].update({"value": init}) if (increment > 0 and eng.extra_data["_Iterators"][step]["value"] > end) or \ (increment < 0 and eng.extra_data["_Iterators"][step]["value"] < end): finish = True if not finish: if variable_name is not None: eng.extra_data["_Iterators"][variable_name] = eng.extra_data["_Iterators"][step]["value"] eng.extra_data["_Iterators"][step]["value"] += increment else: del eng.extra_data["_Iterators"][step] coordonatex = len(eng.getCurrTaskId()) - 1 coordonatey = eng.getCurrTaskId()[coordonatex] new_vector = eng.getCurrTaskId() new_vector[coordonatex] = coordonatey + 2 eng.setPosition(eng.getCurrObjId(), new_vector) _simple_for.hide = True return _simple_for def end_for(obj, eng): """Workflow task indicating the end of a for(each) loop.""" coordonatex = len(eng.getCurrTaskId()) - 1 coordonatey = eng.getCurrTaskId()[coordonatex] new_vector = eng.getCurrTaskId() new_vector[coordonatex] = coordonatey - 3 eng.setPosition(eng.getCurrObjId(), new_vector) end_for.hide = True def execute_if(fun, *args): """Simple conditional execution task.""" @wraps(execute_if) def _execute_if(obj, eng): for rule in args: res = rule(obj, eng) if not res: eng.jumpCallForward(1) fun(obj, eng) _execute_if.hide = True return _execute_if def workflow_if(cond, neg=False): """Simple if statement. The goal of this function is to allow the creation of if else statement without the use of lambda and get a safer way. """ @wraps(workflow_if) def _workflow_if(obj, eng): conda = cond while callable(conda): conda = conda(obj, eng) if "_state" not in eng.extra_data: eng.extra_data["_state"] = {} step = str(eng.getCurrTaskId()) if neg: conda = not conda if step not in eng.extra_data["_state"]: eng.extra_data["_state"].update({step: conda}) else: eng.extra_data["_state"][step] = conda if conda: eng.jumpCallForward(1) else: coordonatex = len(eng.getCurrTaskId()) - 1 coordonatey = eng.getCurrTaskId()[coordonatex] new_vector = eng.getCurrTaskId() new_vector[coordonatex] = coordonatey + 1 eng.setPosition(eng.getCurrObjId(), new_vector) _workflow_if.hide = True _workflow_if.branch = True return _workflow_if def workflow_else(obj, eng): """Simple else statement. The goal of this function is to allow the creation of if else statement without the use of lambda and get a safer way. """ coordonatex = len(eng.getCurrTaskId()) - 1 coordonatey = eng.getCurrTaskId()[coordonatex] new_vector = eng.getCurrTaskId()[:] new_vector[coordonatex] = coordonatey - 2 if not eng.extra_data["_state"][str(new_vector)]: eng.jumpCallForward(1) else: coordonatex = len(eng.getCurrTaskId()) - 1 coordonatey = eng.getCurrTaskId()[coordonatex] new_vector = eng.getCurrTaskId() new_vector[coordonatex] = coordonatey + 1 eng.setPosition(eng.getCurrObjId(), new_vector) workflow_else.hide = True workflow_else.branch = True def compare_logic(a, b, op): """Task that can be used in if or something else to compare two values. :param a: value A to compare :param b: value B to compare :param op: Operator can be : - eq A equal B - gt A greater than B - gte A greater than or equal B - lt A lesser than B - lte A lesser than or equal B :return: Boolean: result of the test """ @wraps(compare_logic) def _compare_logic(obj, eng): my_a = a my_b = b if callable(my_a): while callable(my_a): my_a = my_a(obj, eng) if callable(my_b): while callable(my_b): my_b = my_b(obj, eng) if op == "eq": if my_a == my_b: return True else: return False elif "gt" in op: if "e" in op: if my_a >= my_b: return True else: return False else: if my_a > my_b: return True else: return False elif "lt" in op: if "e" in op: if my_a <= my_b: return True else: return False else: if my_a < my_b: return True else: return False else: return False _compare_logic.hide = True return _compare_logic
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6171, 12, 6927, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 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, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 1084, 402, 10431, 9661, 6527, 1041, 199, 199, 504, 3816, 492, 4550, 199, 504, 9143, 492, 14018, 421, 199, 318, 11257, 1225, 8, 362, 63, 513, 63, 1593, 29, 403, 12, 308, 15556, 313, 29, 403, 12, 2581, 63, 576, 29, 797, 12, 1865, 628, 22767, 2349, 272, 408, 3184, 367, 1924, 1928, 4402, 402, 4136, 1174, 14, 339, 520, 635, 664, 63, 513, 63, 1593, 26, 805, 8152, 314, 769, 641, 1314, 781, 1077, 272, 13974, 14, 272, 520, 635, 308, 15556, 313, 26, 536, 402, 1750, 370, 3354, 314, 1453, 4438, 1174, 315, 314, 272, 2402, 63, 576, 315, 1930, 1265, 2934, 370, 12598, 314, 574, 23430, 315, 282, 2120, 14, 272, 520, 635, 2581, 63, 576, 26, 883, 506, 715, 503, 756, 315, 1930, 402, 715, 12, 314, 769, 911, 506, 272, 6328, 315, 4402, 3140, 402, 3769, 295, 14378, 4036, 521, 14, 1010, 1930, 402, 13627, 272, 314, 769, 365, 949, 1655, 8336, 14, 272, 520, 635, 1865, 26, 2952, 781, 1077, 13974, 1806, 282, 769, 1265, 883, 11496, 315, 1314, 272, 1865, 1265, 2934, 370, 13974, 1806, 2195, 769, 687, 1343, 370, 1284, 8, 22767, 9, 503, 687, 1284, 272, 370, 1343, 334, 3177, 35, 680, 272, 408, 272, 340, 1865, 440, 315, 2097, 22767, 401, 298, 3177, 35, 6229, 267, 1865, 275, 298, 22767, 2, 339, 768, 13582, 8, 32591, 9, 272, 347, 485, 32591, 8, 1113, 12, 20171, 304, 267, 3002, 63, 513, 63, 475, 63, 1412, 275, 942, 267, 3650, 275, 620, 8, 7420, 14, 362, 3864, 82, 4476, 1304, 1012, 267, 862, 26, 288, 340, 2668, 3315, 2750, 2, 440, 315, 20171, 14, 2911, 63, 576, 26, 355, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 937, 275, 1052, 267, 871, 4067, 26, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 937, 275, 1052, 398, 340, 3650, 440, 315, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 6229, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 61, 275, 1052, 288, 340, 2581, 63, 576, 26, 355, 340, 4550, 8, 362, 63, 513, 63, 1593, 304, 490, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 275, 664, 63, 513, 63, 1593, 8, 1113, 12, 20171, 9, 355, 916, 1228, 8, 362, 63, 513, 63, 1593, 12, 769, 304, 490, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 275, 664, 63, 513, 63, 1593, 355, 587, 26, 490, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 275, 942, 2234, 3002, 63, 513, 63, 475, 63, 1412, 275, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 288, 340, 1865, 508, 298, 22767, 582, 355, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 1055, 873, 6333, 585, 582, 378, 1552, 288, 916, 1865, 508, 298, 3177, 35, 582, 355, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 1055, 873, 6333, 585, 582, 822, 8, 1662, 63, 513, 63, 475, 63, 1412, 9, 446, 413, 1552, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 6352, 63, 576, 937, 275, 1559, 14, 576, 398, 340, 4550, 8, 362, 63, 513, 63, 1593, 304, 288, 340, 2581, 63, 576, 26, 355, 3002, 63, 513, 63, 475, 63, 1412, 275, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 288, 587, 26, 355, 3002, 63, 513, 63, 475, 63, 1412, 275, 664, 63, 513, 63, 1593, 8, 1113, 12, 20171, 9, 267, 916, 1228, 8, 362, 63, 513, 63, 1593, 12, 769, 304, 288, 3002, 63, 513, 63, 475, 63, 1412, 275, 664, 63, 513, 63, 1593, 267, 587, 26, 288, 3002, 63, 513, 63, 475, 63, 1412, 275, 942, 398, 340, 1865, 508, 298, 22767, 2, 436, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 937, 665, 822, 8, 1662, 63, 513, 63, 475, 63, 1412, 304, 288, 1559, 14, 576, 275, 3002, 63, 513, 63, 475, 63, 1412, 59, 7420, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 15261, 288, 340, 308, 15556, 313, 365, 440, 488, 26, 355, 1559, 14, 2911, 63, 576, 59, 83, 15556, 313, 61, 275, 1559, 14, 576, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 937, 847, 413, 267, 916, 1865, 508, 298, 3177, 35, 2, 436, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 937, 690, 446, 17, 26, 288, 1559, 14, 576, 275, 3002, 63, 513, 63, 475, 63, 1412, 59, 7420, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 15261, 288, 340, 308, 15556, 313, 365, 440, 488, 26, 355, 1559, 14, 2911, 63, 576, 59, 83, 15556, 313, 61, 275, 1559, 14, 576, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 937, 4862, 413, 267, 587, 26, 288, 1559, 14, 576, 275, 20171, 14, 2911, 63, 576, 18524 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6171, 12, 6927, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 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, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 624, 1084, 402, 10431, 9661, 6527, 1041, 199, 199, 504, 3816, 492, 4550, 199, 504, 9143, 492, 14018, 421, 199, 318, 11257, 1225, 8, 362, 63, 513, 63, 1593, 29, 403, 12, 308, 15556, 313, 29, 403, 12, 2581, 63, 576, 29, 797, 12, 1865, 628, 22767, 2349, 272, 408, 3184, 367, 1924, 1928, 4402, 402, 4136, 1174, 14, 339, 520, 635, 664, 63, 513, 63, 1593, 26, 805, 8152, 314, 769, 641, 1314, 781, 1077, 272, 13974, 14, 272, 520, 635, 308, 15556, 313, 26, 536, 402, 1750, 370, 3354, 314, 1453, 4438, 1174, 315, 314, 272, 2402, 63, 576, 315, 1930, 1265, 2934, 370, 12598, 314, 574, 23430, 315, 282, 2120, 14, 272, 520, 635, 2581, 63, 576, 26, 883, 506, 715, 503, 756, 315, 1930, 402, 715, 12, 314, 769, 911, 506, 272, 6328, 315, 4402, 3140, 402, 3769, 295, 14378, 4036, 521, 14, 1010, 1930, 402, 13627, 272, 314, 769, 365, 949, 1655, 8336, 14, 272, 520, 635, 1865, 26, 2952, 781, 1077, 13974, 1806, 282, 769, 1265, 883, 11496, 315, 1314, 272, 1865, 1265, 2934, 370, 13974, 1806, 2195, 769, 687, 1343, 370, 1284, 8, 22767, 9, 503, 687, 1284, 272, 370, 1343, 334, 3177, 35, 680, 272, 408, 272, 340, 1865, 440, 315, 2097, 22767, 401, 298, 3177, 35, 6229, 267, 1865, 275, 298, 22767, 2, 339, 768, 13582, 8, 32591, 9, 272, 347, 485, 32591, 8, 1113, 12, 20171, 304, 267, 3002, 63, 513, 63, 475, 63, 1412, 275, 942, 267, 3650, 275, 620, 8, 7420, 14, 362, 3864, 82, 4476, 1304, 1012, 267, 862, 26, 288, 340, 2668, 3315, 2750, 2, 440, 315, 20171, 14, 2911, 63, 576, 26, 355, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 937, 275, 1052, 267, 871, 4067, 26, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 937, 275, 1052, 398, 340, 3650, 440, 315, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 6229, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 61, 275, 1052, 288, 340, 2581, 63, 576, 26, 355, 340, 4550, 8, 362, 63, 513, 63, 1593, 304, 490, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 275, 664, 63, 513, 63, 1593, 8, 1113, 12, 20171, 9, 355, 916, 1228, 8, 362, 63, 513, 63, 1593, 12, 769, 304, 490, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 275, 664, 63, 513, 63, 1593, 355, 587, 26, 490, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 275, 942, 2234, 3002, 63, 513, 63, 475, 63, 1412, 275, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 288, 340, 1865, 508, 298, 22767, 582, 355, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 1055, 873, 6333, 585, 582, 378, 1552, 288, 916, 1865, 508, 298, 3177, 35, 582, 355, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 1055, 873, 6333, 585, 582, 822, 8, 1662, 63, 513, 63, 475, 63, 1412, 9, 446, 413, 1552, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 6352, 63, 576, 937, 275, 1559, 14, 576, 398, 340, 4550, 8, 362, 63, 513, 63, 1593, 304, 288, 340, 2581, 63, 576, 26, 355, 3002, 63, 513, 63, 475, 63, 1412, 275, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 1637, 937, 288, 587, 26, 355, 3002, 63, 513, 63, 475, 63, 1412, 275, 664, 63, 513, 63, 1593, 8, 1113, 12, 20171, 9, 267, 916, 1228, 8, 362, 63, 513, 63, 1593, 12, 769, 304, 288, 3002, 63, 513, 63, 475, 63, 1412, 275, 664, 63, 513, 63, 1593, 267, 587, 26, 288, 3002, 63, 513, 63, 475, 63, 1412, 275, 942, 398, 340, 1865, 508, 298, 22767, 2, 436, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 937, 665, 822, 8, 1662, 63, 513, 63, 475, 63, 1412, 304, 288, 1559, 14, 576, 275, 3002, 63, 513, 63, 475, 63, 1412, 59, 7420, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 15261, 288, 340, 308, 15556, 313, 365, 440, 488, 26, 355, 1559, 14, 2911, 63, 576, 59, 83, 15556, 313, 61, 275, 1559, 14, 576, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 937, 847, 413, 267, 916, 1865, 508, 298, 3177, 35, 2, 436, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 937, 690, 446, 17, 26, 288, 1559, 14, 576, 275, 3002, 63, 513, 63, 475, 63, 1412, 59, 7420, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 15261, 288, 340, 308, 15556, 313, 365, 440, 488, 26, 355, 1559, 14, 2911, 63, 576, 59, 83, 15556, 313, 61, 275, 1559, 14, 576, 288, 20171, 14, 2911, 63, 576, 18524, 3315, 2750, 9210, 2926, 7541, 585, 937, 4862, 413, 267, 587, 26, 288, 1559, 14, 576, 275, 20171, 14, 2911, 63, 576, 18524, 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, 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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 ]
rohithpr/py-web-search
pws/google.py
1
7518
#coding=utf-8 from bs4 import BeautifulSoup from time import sleep as wait import re import requests try: from html.parser import HTMLParser except ImportError: from HTMLParser import HTMLParser ################################################## # Copied code ################################################## class MLStripper(HTMLParser): # Code copied from StackOverflow http://stackoverflow.com/a/925630/3664835 def __init__(self): self.reset() self.strict = False self.convert_charrefs= True self.fed = [] def handle_data(self, d): self.fed.append(d) def get_data(self): return ''.join(self.fed) def strip_tags(html): # Code copied from StackOverflow http://stackoverflow.com/a/925630/3664835 s = MLStripper() s.feed(html) return ' '.join(s.get_data().split()) ################################################## # Helpers ################################################## # https://www.google.com/search?q=hello+world&num=3&start=0 def generate_url(query, num, start, recent, country_code): """(str, str, str) -> str A url in the required format is generated. """ query = '+'.join(query.split()) url = 'https://www.google.com/search?q=' + query + '&num=' + num + '&start=' + start if recent in ['h', 'd', 'w', 'm', 'y']: url += '&tbs=qdr:' + recent if country_code is not None: url += '&gl=' + country_code return url # Sortbydate: tbs=sbd:1 # Best: https://www.google.co.in/search?q=hello+world&tbm=nws#q=hello+world&tbas=0&tbm=nws # 1 hour: &tbs=qdr:h # 1 day: &tbs=qdr:d # 1 week: &tbs=qdr:w # 1 month: &tbs=qdr:m # 1 year: &tbs=qdr:y def generate_news_url(query, num, start, recent, country_code): query = '+'.join(query.split()) url = 'https://www.google.com/search?q=' + query + '&num=' + num + '&start=' + start url += '&tbm=nws#q=' + query + '&tbas=0&tbs=sbd:1&tbm=nws' if recent in ['h', 'd', 'w', 'm', 'y']: url += '&tbs=qdr:' + recent if country_code is not None: url += '&gl=' + country_code return url def try_cast_int(s): """(str) -> int All the digits in a given string are concatenated and converted into a single number. """ try: temp = re.findall('\d', str(s)) temp = ''.join(temp) return int(temp) except: return s ################################################## # Class ################################################## class Google: @staticmethod def search(query, num=10, start=0, sleep=True, recent=None, country_code=None): if sleep: wait(1) url = generate_url(query, str(num), str(start), recent, country_code) soup = BeautifulSoup(requests.get(url).text, "html.parser") results = Google.scrape_search_result(soup) related_queries = Google.scrape_related(soup) raw_total_results = soup.find('div', attrs = {'class' : 'sd'}).string total_results = 0 if raw_total_results is not None: for i in raw_total_results: try: temp = int(i) total_results = total_results * 10 + temp except: continue temp = {'results' : results, 'url' : url, 'expected_num' : num, 'received_num' : len(results), 'start' : start, 'search_engine': 'google', 'related_queries' : related_queries, 'total_results' : total_results, 'country_code': country_code, } return temp @staticmethod def scrape_search_result(soup): raw_results = soup.find_all('div', attrs = {'class' : 'g'}) results = [] for result in raw_results: link = result.find('a').get('href')[7:] raw_link_text = result.find('a') link_text = strip_tags(str(raw_link_text)) raw_link_info = result.find('span', attrs = {'class' : 'st'}) link_info = strip_tags(str(raw_link_info)) additional_links = dict() raw_additional_links = result.find('div', attrs = {'class' : 'osl'}) if raw_additional_links is not None: for temp in raw_additional_links.find_all('a'): additional_links[strip_tags(str(temp))] = temp.get('href')[7:] temp = { 'link' : link, 'link_text' : link_text, 'link_info' : link_info, 'additional_links' : additional_links, } results.append(temp) return results @staticmethod def scrape_related(soup): related_queries = [] raw_related = soup.find_all('p', attrs = {'class' : '_Bmc'}) for related in raw_related: related_queries.append(strip_tags(str(related.find('a')))) return related_queries @staticmethod def search_news(query, num=10, start=0,sleep=True, recent=None, country_code=None, proxies=None): if sleep: wait(1) url = generate_news_url(query, str(num), str(start), recent, country_code) soup = BeautifulSoup(requests.get(url,proxies).text, "html.parser") results = Google.scrape_news_result(soup) raw_total_results = soup.find('div', attrs = {'class' : 'sd'}).string total_results = 0 for i in raw_total_results: try: temp = int(i) total_results = total_results * 10 + temp except: continue temp = {'results' : results, 'url' : url, 'num' : num, 'start' : start, 'search_engine' : 'google', 'total_results' : total_results, 'country_code': country_code, } return temp @staticmethod def scrape_news_result(soup): raw_results = soup.find_all('div', attrs = {'class' : 'g'}) results = [] for result in raw_results: link = result.find('a').get('href')[7:] raw_link_text = result.find('a') link_text = strip_tags(str(raw_link_text)) raw_link_info = result.find('div', attrs = {'class' : 'st'}) link_info = strip_tags(str(raw_link_info)) raw_source = result.find('span', attrs = {'class' : 'f'}) raw_source = strip_tags(str(raw_source)).split(' - ') source = raw_source[0] time = raw_source[1] additional_links = dict() # Crazy hack! Fix it. + Buggy! try: raw_a_links = result.find_all('a')[1:] if raw_a_links: raw_source = list(map(strip_tags, list(map(str, result.find_all('span', attrs = {'class' : 'f'})[1:])))) for idx in range(len(raw_a_links)-1): additional_links[strip_tags(str(raw_a_links[idx]))] = (raw_a_links[idx].get('href'), raw_source[idx]) except: pass temp = { 'link' : link, 'link_text' : link_text, 'link_info' : link_info, 'additional_links' : additional_links, 'source' : source, 'time' : time, } results.append(temp) return results
mit
[ 3, 1523, 29, 1624, 13, 24, 199, 199, 504, 9922, 20, 492, 17132, 199, 504, 900, 492, 9435, 465, 3618, 199, 646, 295, 199, 646, 4145, 199, 199, 893, 26, 272, 687, 3517, 14, 2087, 492, 24581, 199, 2590, 3545, 26, 272, 687, 24581, 492, 24581, 199, 199, 22529, 309, 199, 3, 29622, 5299, 1233, 199, 22529, 309, 199, 199, 533, 603, 5296, 7254, 529, 8, 27375, 304, 272, 327, 5495, 8876, 687, 13894, 5674, 1659, 1455, 921, 23153, 14, 957, 15, 65, 15, 25, 3912, 1216, 15, 1344, 10552, 1276, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3958, 342, 267, 291, 14, 4768, 275, 756, 267, 291, 14, 3916, 63, 1560, 7655, 29, 715, 267, 291, 14, 15800, 275, 942, 272, 347, 2429, 63, 576, 8, 277, 12, 366, 304, 267, 291, 14, 15800, 14, 740, 8, 68, 9, 272, 347, 664, 63, 576, 8, 277, 304, 267, 372, 6522, 904, 8, 277, 14, 15800, 9, 199, 199, 318, 6202, 63, 2969, 8, 1360, 304, 272, 327, 5495, 8876, 687, 13894, 5674, 1659, 1455, 921, 23153, 14, 957, 15, 65, 15, 25, 3912, 1216, 15, 1344, 10552, 1276, 272, 308, 275, 603, 5296, 7254, 529, 342, 272, 308, 14, 3871, 8, 1360, 9, 272, 372, 283, 1987, 904, 8, 83, 14, 362, 63, 576, 1252, 1294, 1012, 199, 199, 22529, 309, 199, 3, 11642, 83, 199, 22529, 309, 199, 199, 3, 4178, 921, 1544, 14, 3098, 14, 957, 15, 1733, 31, 81, 29, 5006, 11, 7617, 6, 1507, 29, 19, 6, 928, 29, 16, 199, 318, 3550, 63, 633, 8, 1131, 12, 1967, 12, 1343, 12, 8058, 12, 9023, 63, 600, 304, 272, 408, 8, 495, 12, 620, 12, 620, 9, 1035, 620, 272, 437, 1166, 315, 314, 1415, 1475, 365, 4046, 14, 272, 408, 272, 1827, 275, 6681, 1370, 904, 8, 1131, 14, 1294, 1012, 272, 1166, 275, 283, 2859, 921, 1544, 14, 3098, 14, 957, 15, 1733, 31, 81, 534, 435, 1827, 435, 7673, 1507, 534, 435, 1967, 435, 7673, 928, 534, 435, 1343, 272, 340, 8058, 315, 788, 72, 297, 283, 68, 297, 283, 87, 297, 283, 77, 297, 283, 89, 2565, 267, 1166, 847, 7673, 84, 1533, 29, 81, 5012, 4881, 435, 8058, 272, 340, 9023, 63, 600, 365, 440, 488, 26, 267, 1166, 847, 7673, 3528, 534, 435, 9023, 63, 600, 272, 372, 1166, 199, 199, 3, 16722, 991, 602, 26, 307, 1533, 29, 83, 3691, 26, 17, 199, 3, 699, 597, 26, 420, 4178, 921, 1544, 14, 3098, 14, 331, 14, 262, 15, 1733, 31, 81, 29, 5006, 11, 7617, 6, 5842, 77, 29, 78, 3569, 3, 81, 29, 5006, 11, 7617, 6, 5842, 305, 29, 16, 6, 5842, 77, 29, 78, 3569, 199, 3, 413, 6925, 26, 259, 1253, 84, 1533, 29, 81, 5012, 26, 72, 199, 3, 413, 5382, 26, 258, 1253, 84, 1533, 29, 81, 5012, 26, 68, 199, 3, 413, 8620, 26, 259, 1253, 84, 1533, 29, 81, 5012, 26, 87, 199, 3, 413, 5794, 26, 257, 1253, 84, 1533, 29, 81, 5012, 26, 77, 199, 3, 413, 5361, 26, 259, 1253, 84, 1533, 29, 81, 5012, 26, 89, 199, 318, 3550, 63, 13224, 63, 633, 8, 1131, 12, 1967, 12, 1343, 12, 8058, 12, 9023, 63, 600, 304, 272, 1827, 275, 6681, 1370, 904, 8, 1131, 14, 1294, 1012, 272, 1166, 275, 283, 2859, 921, 1544, 14, 3098, 14, 957, 15, 1733, 31, 81, 534, 435, 1827, 435, 7673, 1507, 534, 435, 1967, 435, 7673, 928, 534, 435, 1343, 272, 1166, 847, 7673, 5842, 77, 29, 78, 3569, 3, 81, 534, 435, 1827, 435, 7673, 5842, 305, 29, 16, 6, 84, 1533, 29, 83, 3691, 26, 17, 6, 5842, 77, 29, 78, 3569, 7, 272, 340, 8058, 315, 788, 72, 297, 283, 68, 297, 283, 87, 297, 283, 77, 297, 283, 89, 2565, 267, 1166, 847, 7673, 84, 1533, 29, 81, 5012, 4881, 435, 8058, 272, 340, 9023, 63, 600, 365, 440, 488, 26, 267, 1166, 847, 7673, 3528, 534, 435, 9023, 63, 600, 272, 372, 1166, 199, 199, 318, 862, 63, 2931, 63, 442, 8, 83, 304, 272, 408, 8, 495, 9, 1035, 1109, 272, 2900, 314, 7576, 315, 282, 1627, 1059, 787, 26271, 436, 6702, 1901, 282, 2849, 1329, 14, 272, 408, 272, 862, 26, 267, 2388, 275, 295, 14, 6452, 2258, 68, 297, 620, 8, 83, 430, 267, 2388, 275, 6522, 904, 8, 808, 9, 267, 372, 1109, 8, 808, 9, 272, 871, 26, 267, 372, 308, 199, 199, 22529, 309, 199, 3, 8089, 199, 22529, 309, 421, 199, 533, 4475, 26, 272, 768, 4639, 272, 347, 2754, 8, 1131, 12, 1967, 29, 709, 12, 1343, 29, 16, 12, 9435, 29, 549, 12, 8058, 29, 403, 12, 9023, 63, 600, 29, 403, 304, 267, 340, 9435, 26, 288, 3618, 8, 17, 9, 267, 1166, 275, 3550, 63, 633, 8, 1131, 12, 620, 8, 1507, 395, 620, 8, 928, 395, 8058, 12, 9023, 63, 600, 9, 267, 9108, 275, 17132, 8, 6615, 14, 362, 8, 633, 680, 505, 12, 298, 1360, 14, 2087, 531, 267, 2058, 275, 4475, 14, 12865, 321, 63, 1733, 63, 1099, 8, 9317, 9, 267, 4048, 63, 10590, 275, 4475, 14, 12865, 321, 63, 2407, 8, 9317, 9, 398, 3066, 63, 2923, 63, 2604, 275, 9108, 14, 1623, 360, 3015, 297, 3290, 275, 791, 533, 7, 520, 283, 3893, 936, 680, 875, 267, 3141, 63, 2604, 275, 378, 267, 340, 3066, 63, 2923, 63, 2604, 365, 440, 488, 26, 288, 367, 284, 315, 3066, 63, 2923, 63, 2604, 26, 355, 862, 26, 490, 2388, 275, 1109, 8, 73, 9, 490, 3141, 63, 2604, 275, 3141, 63, 2604, 627, 1616, 435, 2388, 355, 871, 26, 490, 1980, 398, 2388, 275, 791, 2604, 7, 520, 2058, 12, 355, 283, 633, 7, 520, 1166, 12, 355, 283, 2062, 63, 1507, 7, 520, 1967, 12, 355, 283, 9226, 63, 1507, 7, 520, 822, 8, 2604, 395, 355, 283, 928, 7, 520, 1343, 12, 355, 283, 1733, 63, 3908, 356, 283, 3098, 297, 355, 283, 2407, 63, 10590, 7, 520, 4048, 63, 10590, 12, 355, 283, 2923, 63, 2604, 7, 520, 3141, 63, 2604, 12, 355, 283, 6063 ]
[ 1523, 29, 1624, 13, 24, 199, 199, 504, 9922, 20, 492, 17132, 199, 504, 900, 492, 9435, 465, 3618, 199, 646, 295, 199, 646, 4145, 199, 199, 893, 26, 272, 687, 3517, 14, 2087, 492, 24581, 199, 2590, 3545, 26, 272, 687, 24581, 492, 24581, 199, 199, 22529, 309, 199, 3, 29622, 5299, 1233, 199, 22529, 309, 199, 199, 533, 603, 5296, 7254, 529, 8, 27375, 304, 272, 327, 5495, 8876, 687, 13894, 5674, 1659, 1455, 921, 23153, 14, 957, 15, 65, 15, 25, 3912, 1216, 15, 1344, 10552, 1276, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 3958, 342, 267, 291, 14, 4768, 275, 756, 267, 291, 14, 3916, 63, 1560, 7655, 29, 715, 267, 291, 14, 15800, 275, 942, 272, 347, 2429, 63, 576, 8, 277, 12, 366, 304, 267, 291, 14, 15800, 14, 740, 8, 68, 9, 272, 347, 664, 63, 576, 8, 277, 304, 267, 372, 6522, 904, 8, 277, 14, 15800, 9, 199, 199, 318, 6202, 63, 2969, 8, 1360, 304, 272, 327, 5495, 8876, 687, 13894, 5674, 1659, 1455, 921, 23153, 14, 957, 15, 65, 15, 25, 3912, 1216, 15, 1344, 10552, 1276, 272, 308, 275, 603, 5296, 7254, 529, 342, 272, 308, 14, 3871, 8, 1360, 9, 272, 372, 283, 1987, 904, 8, 83, 14, 362, 63, 576, 1252, 1294, 1012, 199, 199, 22529, 309, 199, 3, 11642, 83, 199, 22529, 309, 199, 199, 3, 4178, 921, 1544, 14, 3098, 14, 957, 15, 1733, 31, 81, 29, 5006, 11, 7617, 6, 1507, 29, 19, 6, 928, 29, 16, 199, 318, 3550, 63, 633, 8, 1131, 12, 1967, 12, 1343, 12, 8058, 12, 9023, 63, 600, 304, 272, 408, 8, 495, 12, 620, 12, 620, 9, 1035, 620, 272, 437, 1166, 315, 314, 1415, 1475, 365, 4046, 14, 272, 408, 272, 1827, 275, 6681, 1370, 904, 8, 1131, 14, 1294, 1012, 272, 1166, 275, 283, 2859, 921, 1544, 14, 3098, 14, 957, 15, 1733, 31, 81, 534, 435, 1827, 435, 7673, 1507, 534, 435, 1967, 435, 7673, 928, 534, 435, 1343, 272, 340, 8058, 315, 788, 72, 297, 283, 68, 297, 283, 87, 297, 283, 77, 297, 283, 89, 2565, 267, 1166, 847, 7673, 84, 1533, 29, 81, 5012, 4881, 435, 8058, 272, 340, 9023, 63, 600, 365, 440, 488, 26, 267, 1166, 847, 7673, 3528, 534, 435, 9023, 63, 600, 272, 372, 1166, 199, 199, 3, 16722, 991, 602, 26, 307, 1533, 29, 83, 3691, 26, 17, 199, 3, 699, 597, 26, 420, 4178, 921, 1544, 14, 3098, 14, 331, 14, 262, 15, 1733, 31, 81, 29, 5006, 11, 7617, 6, 5842, 77, 29, 78, 3569, 3, 81, 29, 5006, 11, 7617, 6, 5842, 305, 29, 16, 6, 5842, 77, 29, 78, 3569, 199, 3, 413, 6925, 26, 259, 1253, 84, 1533, 29, 81, 5012, 26, 72, 199, 3, 413, 5382, 26, 258, 1253, 84, 1533, 29, 81, 5012, 26, 68, 199, 3, 413, 8620, 26, 259, 1253, 84, 1533, 29, 81, 5012, 26, 87, 199, 3, 413, 5794, 26, 257, 1253, 84, 1533, 29, 81, 5012, 26, 77, 199, 3, 413, 5361, 26, 259, 1253, 84, 1533, 29, 81, 5012, 26, 89, 199, 318, 3550, 63, 13224, 63, 633, 8, 1131, 12, 1967, 12, 1343, 12, 8058, 12, 9023, 63, 600, 304, 272, 1827, 275, 6681, 1370, 904, 8, 1131, 14, 1294, 1012, 272, 1166, 275, 283, 2859, 921, 1544, 14, 3098, 14, 957, 15, 1733, 31, 81, 534, 435, 1827, 435, 7673, 1507, 534, 435, 1967, 435, 7673, 928, 534, 435, 1343, 272, 1166, 847, 7673, 5842, 77, 29, 78, 3569, 3, 81, 534, 435, 1827, 435, 7673, 5842, 305, 29, 16, 6, 84, 1533, 29, 83, 3691, 26, 17, 6, 5842, 77, 29, 78, 3569, 7, 272, 340, 8058, 315, 788, 72, 297, 283, 68, 297, 283, 87, 297, 283, 77, 297, 283, 89, 2565, 267, 1166, 847, 7673, 84, 1533, 29, 81, 5012, 4881, 435, 8058, 272, 340, 9023, 63, 600, 365, 440, 488, 26, 267, 1166, 847, 7673, 3528, 534, 435, 9023, 63, 600, 272, 372, 1166, 199, 199, 318, 862, 63, 2931, 63, 442, 8, 83, 304, 272, 408, 8, 495, 9, 1035, 1109, 272, 2900, 314, 7576, 315, 282, 1627, 1059, 787, 26271, 436, 6702, 1901, 282, 2849, 1329, 14, 272, 408, 272, 862, 26, 267, 2388, 275, 295, 14, 6452, 2258, 68, 297, 620, 8, 83, 430, 267, 2388, 275, 6522, 904, 8, 808, 9, 267, 372, 1109, 8, 808, 9, 272, 871, 26, 267, 372, 308, 199, 199, 22529, 309, 199, 3, 8089, 199, 22529, 309, 421, 199, 533, 4475, 26, 272, 768, 4639, 272, 347, 2754, 8, 1131, 12, 1967, 29, 709, 12, 1343, 29, 16, 12, 9435, 29, 549, 12, 8058, 29, 403, 12, 9023, 63, 600, 29, 403, 304, 267, 340, 9435, 26, 288, 3618, 8, 17, 9, 267, 1166, 275, 3550, 63, 633, 8, 1131, 12, 620, 8, 1507, 395, 620, 8, 928, 395, 8058, 12, 9023, 63, 600, 9, 267, 9108, 275, 17132, 8, 6615, 14, 362, 8, 633, 680, 505, 12, 298, 1360, 14, 2087, 531, 267, 2058, 275, 4475, 14, 12865, 321, 63, 1733, 63, 1099, 8, 9317, 9, 267, 4048, 63, 10590, 275, 4475, 14, 12865, 321, 63, 2407, 8, 9317, 9, 398, 3066, 63, 2923, 63, 2604, 275, 9108, 14, 1623, 360, 3015, 297, 3290, 275, 791, 533, 7, 520, 283, 3893, 936, 680, 875, 267, 3141, 63, 2604, 275, 378, 267, 340, 3066, 63, 2923, 63, 2604, 365, 440, 488, 26, 288, 367, 284, 315, 3066, 63, 2923, 63, 2604, 26, 355, 862, 26, 490, 2388, 275, 1109, 8, 73, 9, 490, 3141, 63, 2604, 275, 3141, 63, 2604, 627, 1616, 435, 2388, 355, 871, 26, 490, 1980, 398, 2388, 275, 791, 2604, 7, 520, 2058, 12, 355, 283, 633, 7, 520, 1166, 12, 355, 283, 2062, 63, 1507, 7, 520, 1967, 12, 355, 283, 9226, 63, 1507, 7, 520, 822, 8, 2604, 395, 355, 283, 928, 7, 520, 1343, 12, 355, 283, 1733, 63, 3908, 356, 283, 3098, 297, 355, 283, 2407, 63, 10590, 7, 520, 4048, 63, 10590, 12, 355, 283, 2923, 63, 2604, 7, 520, 3141, 63, 2604, 12, 355, 283, 6063, 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, 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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 ]
40223245/w16b_test
static/Brython3.1.1-20150328-091302/Lib/xml/etree/ElementPath.py
785
9477
# # ElementTree # $Id: ElementPath.py 3375 2008-02-13 08:05:08Z fredrik $ # # limited xpath support for element trees # # history: # 2003-05-23 fl created # 2003-05-28 fl added support for // etc # 2003-08-27 fl fixed parsing of periods in element names # 2007-09-10 fl new selection engine # 2007-09-12 fl fixed parent selector # 2007-09-13 fl added iterfind; changed findall to return a list # 2007-11-30 fl added namespaces support # 2009-10-30 fl added child element value filter # # Copyright (c) 2003-2009 by Fredrik Lundh. All rights reserved. # # fredrik@pythonware.com # http://www.pythonware.com # # -------------------------------------------------------------------- # The ElementTree toolkit is # # Copyright (c) 1999-2009 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: # # Permission to use, copy, modify, and distribute this software and # its associated documentation for any purpose and without fee is # hereby granted, provided that the above copyright notice appears in # all copies, and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Secret Labs AB or the author not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD # TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- # ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # -------------------------------------------------------------------- # Licensed to PSF under a Contributor Agreement. # See http://www.python.org/psf/license for licensing details. ## # Implementation module for XPath support. There's usually no reason # to import this module directly; the <b>ElementTree</b> does this for # you, if needed. ## import re xpath_tokenizer_re = re.compile( "(" "'[^']*'|\"[^\"]*\"|" "::|" "//?|" "\.\.|" "\(\)|" "[/.*:\[\]\(\)@=])|" "((?:\{[^}]+\})?[^/\[\]\(\)@=\s]+)|" "\s+" ) def xpath_tokenizer(pattern, namespaces=None): for token in xpath_tokenizer_re.findall(pattern): tag = token[1] if tag and tag[0] != "{" and ":" in tag: try: prefix, uri = tag.split(":", 1) if not namespaces: raise KeyError yield token[0], "{%s}%s" % (namespaces[prefix], uri) except KeyError: raise SyntaxError("prefix %r not found in prefix map" % prefix) else: yield token def get_parent_map(context): parent_map = context.parent_map if parent_map is None: context.parent_map = parent_map = {} for p in context.root.iter(): for e in p: parent_map[e] = p return parent_map def prepare_child(next, token): tag = token[1] def select(context, result): for elem in result: for e in elem: if e.tag == tag: yield e return select def prepare_star(next, token): def select(context, result): for elem in result: for e in elem: yield e return select def prepare_self(next, token): def select(context, result): for elem in result: yield elem return select def prepare_descendant(next, token): token = next() if token[0] == "*": tag = "*" elif not token[0]: tag = token[1] else: raise SyntaxError("invalid descendant") def select(context, result): for elem in result: for e in elem.iter(tag): if e is not elem: yield e return select def prepare_parent(next, token): def select(context, result): # FIXME: raise error if .. is applied at toplevel? parent_map = get_parent_map(context) result_map = {} for elem in result: if elem in parent_map: parent = parent_map[elem] if parent not in result_map: result_map[parent] = None yield parent return select def prepare_predicate(next, token): # FIXME: replace with real parser!!! refs: # http://effbot.org/zone/simple-iterator-parser.htm # http://javascript.crockford.com/tdop/tdop.html signature = [] predicate = [] while 1: token = next() if token[0] == "]": break if token[0] and token[0][:1] in "'\"": token = "'", token[0][1:-1] signature.append(token[0] or "-") predicate.append(token[1]) signature = "".join(signature) # use signature to determine predicate type if signature == "@-": # [@attribute] predicate key = predicate[1] def select(context, result): for elem in result: if elem.get(key) is not None: yield elem return select if signature == "@-='": # [@attribute='value'] key = predicate[1] value = predicate[-1] def select(context, result): for elem in result: if elem.get(key) == value: yield elem return select if signature == "-" and not re.match("\d+$", predicate[0]): # [tag] tag = predicate[0] def select(context, result): for elem in result: if elem.find(tag) is not None: yield elem return select if signature == "-='" and not re.match("\d+$", predicate[0]): # [tag='value'] tag = predicate[0] value = predicate[-1] def select(context, result): for elem in result: for e in elem.findall(tag): if "".join(e.itertext()) == value: yield elem break return select if signature == "-" or signature == "-()" or signature == "-()-": # [index] or [last()] or [last()-index] if signature == "-": index = int(predicate[0]) - 1 else: if predicate[0] != "last": raise SyntaxError("unsupported function") if signature == "-()-": try: index = int(predicate[2]) - 1 except ValueError: raise SyntaxError("unsupported expression") else: index = -1 def select(context, result): parent_map = get_parent_map(context) for elem in result: try: parent = parent_map[elem] # FIXME: what if the selector is "*" ? elems = list(parent.findall(elem.tag)) if elems[index] is elem: yield elem except (IndexError, KeyError): pass return select raise SyntaxError("invalid predicate") ops = { "": prepare_child, "*": prepare_star, ".": prepare_self, "..": prepare_parent, "//": prepare_descendant, "[": prepare_predicate, } _cache = {} class _SelectorContext: parent_map = None def __init__(self, root): self.root = root # -------------------------------------------------------------------- ## # Generate all matching objects. def iterfind(elem, path, namespaces=None): # compile selector pattern if path[-1:] == "/": path = path + "*" # implicit all (FIXME: keep this?) try: selector = _cache[path] except KeyError: if len(_cache) > 100: _cache.clear() if path[:1] == "/": raise SyntaxError("cannot use absolute path on element") next = iter(xpath_tokenizer(path, namespaces)).__next__ token = next() selector = [] while 1: try: selector.append(ops[token[0]](next, token)) except StopIteration: raise SyntaxError("invalid path") try: token = next() if token[0] == "/": token = next() except StopIteration: break _cache[path] = selector # execute selector pattern result = [elem] context = _SelectorContext(elem) for select in selector: result = select(context, result) return result ## # Find first matching object. def find(elem, path, namespaces=None): try: return next(iterfind(elem, path, namespaces)) except StopIteration: return None ## # Find all matching objects. def findall(elem, path, namespaces=None): return list(iterfind(elem, path, namespaces)) ## # Find text for first matching object. def findtext(elem, path, default=None, namespaces=None): try: elem = next(iterfind(elem, path, namespaces)) return elem.text or "" except StopIteration: return default
gpl-3.0
[ 3, 199, 3, 13139, 199, 3, 2672, 1304, 26, 6566, 2042, 14, 647, 650, 9946, 9079, 13, 996, 13, 969, 19363, 26, 1717, 26, 2036, 58, 289, 581, 25844, 2672, 199, 3, 199, 3, 13988, 14462, 2291, 367, 1819, 14416, 199, 3, 199, 3, 7994, 26, 199, 3, 13004, 13, 1717, 13, 1789, 2717, 257, 2737, 199, 3, 13004, 13, 1717, 13, 1651, 2717, 257, 3483, 2291, 367, 5001, 5423, 199, 3, 13004, 13, 2036, 13, 1465, 2717, 257, 6317, 6057, 402, 17382, 315, 1819, 1561, 199, 3, 10219, 13, 1643, 13, 709, 2717, 257, 892, 7267, 6869, 199, 3, 10219, 13, 1643, 13, 713, 2717, 257, 6317, 1676, 9759, 199, 3, 10219, 13, 1643, 13, 969, 2717, 257, 3483, 2740, 1623, 27, 2896, 2342, 452, 370, 372, 282, 769, 199, 3, 10219, 13, 845, 13, 1216, 2717, 257, 3483, 10747, 2291, 199, 3, 8937, 13, 709, 13, 1216, 2717, 257, 3483, 1982, 1819, 574, 2457, 199, 3, 199, 3, 1898, 334, 67, 9, 13004, 13, 8664, 701, 481, 581, 25844, 491, 725, 72, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 289, 581, 25844, 32, 1548, 1068, 14, 957, 199, 3, 1455, 921, 1544, 14, 1548, 1068, 14, 957, 199, 3, 199, 3, 23567, 199, 3, 710, 13139, 4744, 6065, 365, 199, 3, 199, 3, 1898, 334, 67, 9, 21300, 13, 8664, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 4885, 12408, 12, 1808, 12, 436, 15, 269, 16743, 642, 2032, 436, 15, 269, 2399, 199, 3, 4568, 3794, 12, 1265, 10601, 626, 1265, 1172, 1586, 12, 1334, 14308, 364, 12, 199, 3, 436, 911, 1013, 590, 543, 314, 2569, 2895, 436, 3704, 26, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 199, 3, 2399, 4568, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 199, 3, 11882, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 199, 3, 1006, 6866, 12, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 23580, 491, 2101, 14840, 503, 314, 4132, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 5795, 11771, 491, 27851, 14840, 2401, 2334, 17632, 8990, 51, 11727, 2990, 1663, 14142, 7816, 199, 3, 2296, 5749, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3121, 13, 199, 3, 14840, 2273, 2401, 3092, 14, 221, 1621, 4825, 6461, 7000, 5795, 11771, 491, 27851, 14840, 1549, 2334, 17632, 199, 3, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 199, 3, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 199, 3, 1634, 5749, 4141, 14, 199, 3, 23567, 199, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 1666, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 1190, 70, 15, 1682, 367, 32572, 2436, 14, 199, 199, 309, 199, 3, 24425, 859, 367, 1323, 2042, 2291, 14, 221, 6006, 1159, 9987, 949, 4499, 199, 3, 370, 492, 642, 859, 5370, 27, 314, 665, 66, 30, 15325, 1108, 66, 30, 1630, 642, 367, 199, 3, 1265, 12, 340, 4346, 14, 199, 309, 199, 199, 646, 295, 199, 199, 8006, 63, 13771, 63, 264, 275, 295, 14, 2014, 8, 272, 26054, 272, 3546, 4735, 418, 10223, 92, 4451, 16045, 937, 10, 4451, 25576, 272, 27472, 25576, 272, 23057, 20910, 2, 272, 1867, 3134, 14, 25576, 272, 1867, 2961, 8636, 2, 272, 7369, 15, 2795, 3427, 7023, 7272, 2961, 9, 32, 29, 566, 25576, 272, 298, 17304, 3427, 91, 4735, 93, 24621, 1552, 31, 4735, 6307, 7023, 7272, 2961, 9, 32, 9529, 83, 2807, 8636, 2, 272, 1867, 83, 5207, 272, 776, 199, 199, 318, 14462, 63, 13771, 8, 3401, 12, 10747, 29, 403, 304, 272, 367, 1526, 315, 14462, 63, 13771, 63, 264, 14, 6452, 8, 3401, 304, 267, 1947, 275, 1526, 59, 17, 61, 267, 340, 1947, 436, 1947, 59, 16, 61, 1137, 5310, 2, 436, 14725, 315, 1947, 26, 288, 862, 26, 355, 2403, 12, 5108, 275, 1947, 14, 1294, 480, 6783, 413, 9, 355, 340, 440, 10747, 26, 490, 746, 4067, 355, 1995, 1526, 59, 16, 467, 22704, 83, 22109, 83, 2, 450, 334, 9247, 59, 1861, 467, 5108, 9, 288, 871, 4067, 26, 355, 746, 12053, 480, 1861, 450, 82, 440, 1911, 315, 2403, 2341, 2, 450, 2403, 9, 267, 587, 26, 288, 1995, 1526, 199, 199, 318, 664, 63, 1708, 63, 1130, 8, 1100, 304, 272, 1676, 63, 1130, 275, 1067, 14, 1708, 63, 1130, 272, 340, 1676, 63, 1130, 365, 488, 26, 267, 1067, 14, 1708, 63, 1130, 275, 1676, 63, 1130, 275, 1052, 267, 367, 299, 315, 1067, 14, 1231, 14, 1661, 837, 288, 367, 325, 315, 299, 26, 355, 1676, 63, 1130, 59, 69, 61, 275, 299, 272, 372, 1676, 63, 1130, 199, 199, 318, 9275, 63, 1739, 8, 2184, 12, 1526, 304, 272, 1947, 275, 1526, 59, 17, 61, 272, 347, 3504, 8, 1100, 12, 754, 304, 267, 367, 6193, 315, 754, 26, 288, 367, 325, 315, 6193, 26, 355, 340, 325, 14, 1450, 508, 1947, 26, 490, 1995, 325, 272, 372, 3504, 199, 199, 318, 9275, 63, 7848, 8, 2184, 12, 1526, 304, 272, 347, 3504, 8, 1100, 12, 754, 304, 267, 367, 6193, 315, 754, 26, 288, 367, 325, 315, 6193, 26, 355, 1995, 325, 272, 372, 3504, 199, 199, 318, 9275, 63, 277, 8, 2184, 12, 1526, 304, 272, 347, 3504, 8, 1100, 12, 754, 304, 267, 367, 6193, 315, 754, 26, 288, 1995, 6193, 272, 372, 3504, 199, 199, 318, 9275, 63, 31759, 8, 2184, 12, 1526, 304, 272, 1526, 275, 2163, 342, 272, 340, 1526, 59, 16, 61, 508, 8969, 582, 267, 1947, 275, 22423, 272, 916, 440, 1526, 59, 16, 2189, 267, 1947, 275, 1526, 59, 17, 61, 272 ]
[ 199, 3, 13139, 199, 3, 2672, 1304, 26, 6566, 2042, 14, 647, 650, 9946, 9079, 13, 996, 13, 969, 19363, 26, 1717, 26, 2036, 58, 289, 581, 25844, 2672, 199, 3, 199, 3, 13988, 14462, 2291, 367, 1819, 14416, 199, 3, 199, 3, 7994, 26, 199, 3, 13004, 13, 1717, 13, 1789, 2717, 257, 2737, 199, 3, 13004, 13, 1717, 13, 1651, 2717, 257, 3483, 2291, 367, 5001, 5423, 199, 3, 13004, 13, 2036, 13, 1465, 2717, 257, 6317, 6057, 402, 17382, 315, 1819, 1561, 199, 3, 10219, 13, 1643, 13, 709, 2717, 257, 892, 7267, 6869, 199, 3, 10219, 13, 1643, 13, 713, 2717, 257, 6317, 1676, 9759, 199, 3, 10219, 13, 1643, 13, 969, 2717, 257, 3483, 2740, 1623, 27, 2896, 2342, 452, 370, 372, 282, 769, 199, 3, 10219, 13, 845, 13, 1216, 2717, 257, 3483, 10747, 2291, 199, 3, 8937, 13, 709, 13, 1216, 2717, 257, 3483, 1982, 1819, 574, 2457, 199, 3, 199, 3, 1898, 334, 67, 9, 13004, 13, 8664, 701, 481, 581, 25844, 491, 725, 72, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 289, 581, 25844, 32, 1548, 1068, 14, 957, 199, 3, 1455, 921, 1544, 14, 1548, 1068, 14, 957, 199, 3, 199, 3, 23567, 199, 3, 710, 13139, 4744, 6065, 365, 199, 3, 199, 3, 1898, 334, 67, 9, 21300, 13, 8664, 701, 481, 581, 25844, 491, 725, 72, 199, 3, 199, 3, 4885, 12408, 12, 1808, 12, 436, 15, 269, 16743, 642, 2032, 436, 15, 269, 2399, 199, 3, 4568, 3794, 12, 1265, 10601, 626, 1265, 1172, 1586, 12, 1334, 14308, 364, 12, 199, 3, 436, 911, 1013, 590, 543, 314, 2569, 2895, 436, 3704, 26, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 199, 3, 2399, 4568, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 199, 3, 11882, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 11337, 315, 199, 3, 1006, 6866, 12, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 23580, 491, 2101, 14840, 503, 314, 4132, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 5795, 11771, 491, 27851, 14840, 2401, 2334, 17632, 8990, 51, 11727, 2990, 1663, 14142, 7816, 199, 3, 2296, 5749, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3121, 13, 199, 3, 14840, 2273, 2401, 3092, 14, 221, 1621, 4825, 6461, 7000, 5795, 11771, 491, 27851, 14840, 1549, 2334, 17632, 199, 3, 6262, 7024, 2381, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 199, 3, 6736, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 199, 3, 1634, 5749, 4141, 14, 199, 3, 23567, 199, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 3, 1666, 1455, 921, 1544, 14, 1548, 14, 1308, 15, 1190, 70, 15, 1682, 367, 32572, 2436, 14, 199, 199, 309, 199, 3, 24425, 859, 367, 1323, 2042, 2291, 14, 221, 6006, 1159, 9987, 949, 4499, 199, 3, 370, 492, 642, 859, 5370, 27, 314, 665, 66, 30, 15325, 1108, 66, 30, 1630, 642, 367, 199, 3, 1265, 12, 340, 4346, 14, 199, 309, 199, 199, 646, 295, 199, 199, 8006, 63, 13771, 63, 264, 275, 295, 14, 2014, 8, 272, 26054, 272, 3546, 4735, 418, 10223, 92, 4451, 16045, 937, 10, 4451, 25576, 272, 27472, 25576, 272, 23057, 20910, 2, 272, 1867, 3134, 14, 25576, 272, 1867, 2961, 8636, 2, 272, 7369, 15, 2795, 3427, 7023, 7272, 2961, 9, 32, 29, 566, 25576, 272, 298, 17304, 3427, 91, 4735, 93, 24621, 1552, 31, 4735, 6307, 7023, 7272, 2961, 9, 32, 9529, 83, 2807, 8636, 2, 272, 1867, 83, 5207, 272, 776, 199, 199, 318, 14462, 63, 13771, 8, 3401, 12, 10747, 29, 403, 304, 272, 367, 1526, 315, 14462, 63, 13771, 63, 264, 14, 6452, 8, 3401, 304, 267, 1947, 275, 1526, 59, 17, 61, 267, 340, 1947, 436, 1947, 59, 16, 61, 1137, 5310, 2, 436, 14725, 315, 1947, 26, 288, 862, 26, 355, 2403, 12, 5108, 275, 1947, 14, 1294, 480, 6783, 413, 9, 355, 340, 440, 10747, 26, 490, 746, 4067, 355, 1995, 1526, 59, 16, 467, 22704, 83, 22109, 83, 2, 450, 334, 9247, 59, 1861, 467, 5108, 9, 288, 871, 4067, 26, 355, 746, 12053, 480, 1861, 450, 82, 440, 1911, 315, 2403, 2341, 2, 450, 2403, 9, 267, 587, 26, 288, 1995, 1526, 199, 199, 318, 664, 63, 1708, 63, 1130, 8, 1100, 304, 272, 1676, 63, 1130, 275, 1067, 14, 1708, 63, 1130, 272, 340, 1676, 63, 1130, 365, 488, 26, 267, 1067, 14, 1708, 63, 1130, 275, 1676, 63, 1130, 275, 1052, 267, 367, 299, 315, 1067, 14, 1231, 14, 1661, 837, 288, 367, 325, 315, 299, 26, 355, 1676, 63, 1130, 59, 69, 61, 275, 299, 272, 372, 1676, 63, 1130, 199, 199, 318, 9275, 63, 1739, 8, 2184, 12, 1526, 304, 272, 1947, 275, 1526, 59, 17, 61, 272, 347, 3504, 8, 1100, 12, 754, 304, 267, 367, 6193, 315, 754, 26, 288, 367, 325, 315, 6193, 26, 355, 340, 325, 14, 1450, 508, 1947, 26, 490, 1995, 325, 272, 372, 3504, 199, 199, 318, 9275, 63, 7848, 8, 2184, 12, 1526, 304, 272, 347, 3504, 8, 1100, 12, 754, 304, 267, 367, 6193, 315, 754, 26, 288, 367, 325, 315, 6193, 26, 355, 1995, 325, 272, 372, 3504, 199, 199, 318, 9275, 63, 277, 8, 2184, 12, 1526, 304, 272, 347, 3504, 8, 1100, 12, 754, 304, 267, 367, 6193, 315, 754, 26, 288, 1995, 6193, 272, 372, 3504, 199, 199, 318, 9275, 63, 31759, 8, 2184, 12, 1526, 304, 272, 1526, 275, 2163, 342, 272, 340, 1526, 59, 16, 61, 508, 8969, 582, 267, 1947, 275, 22423, 272, 916, 440, 1526, 59, 16, 2189, 267, 1947, 275, 1526, 59, 17, 61, 272, 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, 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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 ]
unlimitedcoin-dev/unlimited-core
qa/rpc-tests/listtransactions.py
1
10129
#!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. # Exercise the listtransactions API from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * from test_framework.mininode import CTransaction, COIN from io import BytesIO def txFromHex(hexstring): tx = CTransaction() f = BytesIO(hex_str_to_bytes(hexstring)) tx.deserialize(f) return tx class ListTransactionsTest(BitcoinTestFramework): def setup_nodes(self): #This test requires mocktime enable_mocktime() return start_nodes(4, self.options.tmpdir) def run_test(self): # Simple send, 0 to 1: txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1) self.sync_all() assert_array_result(self.nodes[0].listtransactions(), {"txid":txid}, {"category":"send","account":"","amount":Decimal("-0.1"),"confirmations":0}) assert_array_result(self.nodes[1].listtransactions(), {"txid":txid}, {"category":"receive","account":"","amount":Decimal("0.1"),"confirmations":0}) # mine a block, confirmations should change: self.nodes[0].generate(1) self.sync_all() assert_array_result(self.nodes[0].listtransactions(), {"txid":txid}, {"category":"send","account":"","amount":Decimal("-0.1"),"confirmations":1}) assert_array_result(self.nodes[1].listtransactions(), {"txid":txid}, {"category":"receive","account":"","amount":Decimal("0.1"),"confirmations":1}) # send-to-self: txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 0.2) assert_array_result(self.nodes[0].listtransactions(), {"txid":txid, "category":"send"}, {"amount":Decimal("-0.2")}) assert_array_result(self.nodes[0].listtransactions(), {"txid":txid, "category":"receive"}, {"amount":Decimal("0.2")}) # sendmany from node1: twice to self, twice to node2: send_to = { self.nodes[0].getnewaddress() : 0.11, self.nodes[1].getnewaddress() : 0.22, self.nodes[0].getaccountaddress("from1") : 0.33, self.nodes[1].getaccountaddress("toself") : 0.44 } txid = self.nodes[1].sendmany("", send_to) self.sync_all() assert_array_result(self.nodes[1].listtransactions(), {"category":"send","amount":Decimal("-0.11")}, {"txid":txid} ) assert_array_result(self.nodes[0].listtransactions(), {"category":"receive","amount":Decimal("0.11")}, {"txid":txid} ) assert_array_result(self.nodes[1].listtransactions(), {"category":"send","amount":Decimal("-0.22")}, {"txid":txid} ) assert_array_result(self.nodes[1].listtransactions(), {"category":"receive","amount":Decimal("0.22")}, {"txid":txid} ) assert_array_result(self.nodes[1].listtransactions(), {"category":"send","amount":Decimal("-0.33")}, {"txid":txid} ) assert_array_result(self.nodes[0].listtransactions(), {"category":"receive","amount":Decimal("0.33")}, {"txid":txid, "account" : "from1"} ) assert_array_result(self.nodes[1].listtransactions(), {"category":"send","amount":Decimal("-0.44")}, {"txid":txid, "account" : ""} ) assert_array_result(self.nodes[1].listtransactions(), {"category":"receive","amount":Decimal("0.44")}, {"txid":txid, "account" : "toself"} ) multisig = self.nodes[1].createmultisig(1, [self.nodes[1].getnewaddress()]) self.nodes[0].importaddress(multisig["redeemScript"], "watchonly", False, True) txid = self.nodes[1].sendtoaddress(multisig["address"], 0.1) self.nodes[1].generate(1) self.sync_all() assert(len(self.nodes[0].listtransactions("watchonly", 100, 0, False)) == 0) assert_array_result(self.nodes[0].listtransactions("watchonly", 100, 0, True), {"category":"receive","amount":Decimal("0.1")}, {"txid":txid, "account" : "watchonly"} ) # rbf is disabled in Ulm Core # self.run_rbf_opt_in_test() # Check that the opt-in-rbf flag works properly, for sent and received # transactions. def run_rbf_opt_in_test(self): # Check whether a transaction signals opt-in RBF itself def is_opt_in(node, txid): rawtx = node.getrawtransaction(txid, 1) for x in rawtx["vin"]: if x["sequence"] < 0xfffffffe: return True return False # Find an unconfirmed output matching a certain txid def get_unconfirmed_utxo_entry(node, txid_to_match): utxo = node.listunspent(0, 0) for i in utxo: if i["txid"] == txid_to_match: return i return None # 1. Chain a few transactions that don't opt-in. txid_1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1) assert(not is_opt_in(self.nodes[0], txid_1)) assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_1}, {"bip125-replaceable":"no"}) sync_mempools(self.nodes) assert_array_result(self.nodes[1].listtransactions(), {"txid": txid_1}, {"bip125-replaceable":"no"}) # Tx2 will build off txid_1, still not opting in to RBF. utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[1], txid_1) # Create tx2 using createrawtransaction inputs = [{"txid":utxo_to_use["txid"], "vout":utxo_to_use["vout"]}] outputs = {self.nodes[0].getnewaddress(): 0.999} tx2 = self.nodes[1].createrawtransaction(inputs, outputs) tx2_signed = self.nodes[1].signrawtransaction(tx2)["hex"] txid_2 = self.nodes[1].sendrawtransaction(tx2_signed) # ...and check the result assert(not is_opt_in(self.nodes[1], txid_2)) assert_array_result(self.nodes[1].listtransactions(), {"txid": txid_2}, {"bip125-replaceable":"no"}) sync_mempools(self.nodes) assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_2}, {"bip125-replaceable":"no"}) # Tx3 will opt-in to RBF utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[0], txid_2) inputs = [{"txid": txid_2, "vout":utxo_to_use["vout"]}] outputs = {self.nodes[1].getnewaddress(): 0.998} tx3 = self.nodes[0].createrawtransaction(inputs, outputs) tx3_modified = txFromHex(tx3) tx3_modified.vin[0].nSequence = 0 tx3 = bytes_to_hex_str(tx3_modified.serialize()) tx3_signed = self.nodes[0].signrawtransaction(tx3)['hex'] txid_3 = self.nodes[0].sendrawtransaction(tx3_signed) assert(is_opt_in(self.nodes[0], txid_3)) assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_3}, {"bip125-replaceable":"yes"}) sync_mempools(self.nodes) assert_array_result(self.nodes[1].listtransactions(), {"txid": txid_3}, {"bip125-replaceable":"yes"}) # Tx4 will chain off tx3. Doesn't signal itself, but depends on one # that does. utxo_to_use = get_unconfirmed_utxo_entry(self.nodes[1], txid_3) inputs = [{"txid": txid_3, "vout":utxo_to_use["vout"]}] outputs = {self.nodes[0].getnewaddress(): 0.997} tx4 = self.nodes[1].createrawtransaction(inputs, outputs) tx4_signed = self.nodes[1].signrawtransaction(tx4)["hex"] txid_4 = self.nodes[1].sendrawtransaction(tx4_signed) assert(not is_opt_in(self.nodes[1], txid_4)) assert_array_result(self.nodes[1].listtransactions(), {"txid": txid_4}, {"bip125-replaceable":"yes"}) sync_mempools(self.nodes) assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_4}, {"bip125-replaceable":"yes"}) # Replace tx3, and check that tx4 becomes unknown tx3_b = tx3_modified tx3_b.vout[0].nValue -= int(Decimal("0.004") * COIN) # bump the fee tx3_b = bytes_to_hex_str(tx3_b.serialize()) tx3_b_signed = self.nodes[0].signrawtransaction(tx3_b)['hex'] txid_3b = self.nodes[0].sendrawtransaction(tx3_b_signed, True) assert(is_opt_in(self.nodes[0], txid_3b)) assert_array_result(self.nodes[0].listtransactions(), {"txid": txid_4}, {"bip125-replaceable":"unknown"}) sync_mempools(self.nodes) assert_array_result(self.nodes[1].listtransactions(), {"txid": txid_4}, {"bip125-replaceable":"unknown"}) # Check gettransaction as well: for n in self.nodes[0:2]: assert_equal(n.gettransaction(txid_1)["bip125-replaceable"], "no") assert_equal(n.gettransaction(txid_2)["bip125-replaceable"], "no") assert_equal(n.gettransaction(txid_3)["bip125-replaceable"], "yes") assert_equal(n.gettransaction(txid_3b)["bip125-replaceable"], "yes") assert_equal(n.gettransaction(txid_4)["bip125-replaceable"], "unknown") # After mining a transaction, it's no longer BIP125-replaceable self.nodes[0].generate(1) assert(txid_3b not in self.nodes[0].getrawmempool()) assert_equal(self.nodes[0].gettransaction(txid_3b)["bip125-replaceable"], "no") assert_equal(self.nodes[0].gettransaction(txid_4)["bip125-replaceable"], "unknown") if __name__ == '__main__': ListTransactionsTest().main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 1898, 334, 67, 9, 6927, 13, 7806, 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, 199, 3, 1316, 20616, 314, 769, 13754, 3261, 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, 5099, 568, 199, 504, 5890, 492, 11808, 199, 199, 318, 4773, 2532, 10373, 8, 4097, 875, 304, 272, 4773, 275, 445, 10161, 342, 272, 289, 275, 11808, 8, 4097, 63, 495, 63, 475, 63, 2394, 8, 4097, 875, 430, 272, 4773, 14, 11143, 8, 70, 9, 272, 372, 4773, 199, 199, 533, 3820, 3188, 3723, 774, 8, 4734, 9061, 26203, 304, 339, 347, 3272, 63, 2415, 8, 277, 304, 267, 327, 2765, 511, 5074, 1683, 521, 267, 4756, 63, 1805, 521, 342, 267, 372, 1343, 63, 2415, 8, 20, 12, 291, 14, 1419, 14, 8616, 9, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 327, 5870, 3222, 12, 378, 370, 413, 26, 267, 22083, 275, 291, 14, 2415, 59, 16, 1055, 23267, 1562, 8, 277, 14, 2415, 59, 17, 1055, 21102, 1062, 378, 14, 17, 9, 267, 291, 14, 5186, 63, 452, 342, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 1386, 2574, 2420, 3710, 5122, 2254, 2266, 2048, 582, 341, 4589, 4606, 582, 6745, 6096, 16, 14, 17, 1288, 2, 388, 27389, 582, 16, 1552, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 1386, 2574, 2420, 3710, 5122, 9391, 2266, 2048, 582, 341, 4589, 4606, 582, 6745, 480, 16, 14, 17, 1288, 2, 388, 27389, 582, 16, 1552, 267, 327, 30820, 282, 1853, 12, 406, 27389, 1077, 1570, 26, 267, 291, 14, 2415, 59, 16, 1055, 4208, 8, 17, 9, 267, 291, 14, 5186, 63, 452, 342, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 1386, 2574, 2420, 3710, 5122, 2254, 2266, 2048, 582, 341, 4589, 4606, 582, 6745, 6096, 16, 14, 17, 1288, 2, 388, 27389, 582, 17, 1552, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 1386, 2574, 2420, 3710, 5122, 9391, 2266, 2048, 582, 341, 4589, 4606, 582, 6745, 480, 16, 14, 17, 1288, 2, 388, 27389, 582, 17, 1552, 398, 327, 3222, 13, 475, 13, 277, 26, 267, 22083, 275, 291, 14, 2415, 59, 16, 1055, 23267, 1562, 8, 277, 14, 2415, 59, 16, 1055, 21102, 1062, 378, 14, 18, 9, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 12, 298, 3710, 5122, 2254, 6018, 2574, 2420, 4606, 582, 6745, 6096, 16, 14, 18, 531, 1552, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 12, 298, 3710, 5122, 9391, 6018, 2574, 2420, 4606, 582, 6745, 480, 16, 14, 18, 531, 1552, 398, 327, 3222, 3479, 687, 1031, 17, 26, 13373, 370, 291, 12, 13373, 370, 1031, 18, 26, 267, 3222, 63, 475, 275, 469, 291, 14, 2415, 59, 16, 1055, 21102, 342, 520, 378, 14, 845, 12, 490, 291, 14, 2415, 59, 17, 1055, 21102, 342, 520, 378, 14, 1081, 12, 490, 291, 14, 2415, 59, 16, 1055, 362, 2048, 1562, 480, 504, 17, 531, 520, 378, 14, 1153, 12, 490, 291, 14, 2415, 59, 17, 1055, 362, 2048, 1562, 480, 475, 277, 531, 520, 378, 14, 1602, 789, 267, 22083, 275, 291, 14, 2415, 59, 17, 1055, 2254, 3479, 12398, 3222, 63, 475, 9, 267, 291, 14, 5186, 63, 452, 342, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 2254, 2266, 4606, 582, 6745, 6096, 16, 14, 845, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 9391, 2266, 4606, 582, 6745, 480, 16, 14, 845, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 2254, 2266, 4606, 582, 6745, 6096, 16, 14, 1081, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 9391, 2266, 4606, 582, 6745, 480, 16, 14, 1081, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 2254, 2266, 4606, 582, 6745, 6096, 16, 14, 1153, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 9391, 2266, 4606, 582, 6745, 480, 16, 14, 1153, 25988, 2574, 2420, 14113, 582, 14113, 12, 298, 2048, 2, 520, 298, 504, 17, 3570, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 2254, 2266, 4606, 582, 6745, 6096, 16, 14, 1602, 25988, 2574, 2420, 14113, 582, 14113, 12, 298, 2048, 2, 520, 3087, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 9391, 2266, 4606, 582, 6745, 480, 16, 14, 1602, 25988, 2574, 2420, 14113, 582, 14113, 12, 298, 2048, 2, 520, 298, 475, 277, 3570, 776, 398, 3510, 4093, 275, 291, 14, 2415, 59, 17, 1055, 981, 3029, 4093, 8, 17, 12, 359, 277, 14, 2415, 59, 17, 1055, 21102, 9383, 267, 291, 14, 2415, 59, 16, 1055, 646 ]
[ 2647, 15, 1393, 15, 1813, 2366, 18, 199, 3, 1898, 334, 67, 9, 6927, 13, 7806, 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, 199, 3, 1316, 20616, 314, 769, 13754, 3261, 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, 5099, 568, 199, 504, 5890, 492, 11808, 199, 199, 318, 4773, 2532, 10373, 8, 4097, 875, 304, 272, 4773, 275, 445, 10161, 342, 272, 289, 275, 11808, 8, 4097, 63, 495, 63, 475, 63, 2394, 8, 4097, 875, 430, 272, 4773, 14, 11143, 8, 70, 9, 272, 372, 4773, 199, 199, 533, 3820, 3188, 3723, 774, 8, 4734, 9061, 26203, 304, 339, 347, 3272, 63, 2415, 8, 277, 304, 267, 327, 2765, 511, 5074, 1683, 521, 267, 4756, 63, 1805, 521, 342, 267, 372, 1343, 63, 2415, 8, 20, 12, 291, 14, 1419, 14, 8616, 9, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 327, 5870, 3222, 12, 378, 370, 413, 26, 267, 22083, 275, 291, 14, 2415, 59, 16, 1055, 23267, 1562, 8, 277, 14, 2415, 59, 17, 1055, 21102, 1062, 378, 14, 17, 9, 267, 291, 14, 5186, 63, 452, 342, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 1386, 2574, 2420, 3710, 5122, 2254, 2266, 2048, 582, 341, 4589, 4606, 582, 6745, 6096, 16, 14, 17, 1288, 2, 388, 27389, 582, 16, 1552, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 1386, 2574, 2420, 3710, 5122, 9391, 2266, 2048, 582, 341, 4589, 4606, 582, 6745, 480, 16, 14, 17, 1288, 2, 388, 27389, 582, 16, 1552, 267, 327, 30820, 282, 1853, 12, 406, 27389, 1077, 1570, 26, 267, 291, 14, 2415, 59, 16, 1055, 4208, 8, 17, 9, 267, 291, 14, 5186, 63, 452, 342, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 1386, 2574, 2420, 3710, 5122, 2254, 2266, 2048, 582, 341, 4589, 4606, 582, 6745, 6096, 16, 14, 17, 1288, 2, 388, 27389, 582, 17, 1552, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 1386, 2574, 2420, 3710, 5122, 9391, 2266, 2048, 582, 341, 4589, 4606, 582, 6745, 480, 16, 14, 17, 1288, 2, 388, 27389, 582, 17, 1552, 398, 327, 3222, 13, 475, 13, 277, 26, 267, 22083, 275, 291, 14, 2415, 59, 16, 1055, 23267, 1562, 8, 277, 14, 2415, 59, 16, 1055, 21102, 1062, 378, 14, 18, 9, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 12, 298, 3710, 5122, 2254, 6018, 2574, 2420, 4606, 582, 6745, 6096, 16, 14, 18, 531, 1552, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 14113, 582, 14113, 12, 298, 3710, 5122, 9391, 6018, 2574, 2420, 4606, 582, 6745, 480, 16, 14, 18, 531, 1552, 398, 327, 3222, 3479, 687, 1031, 17, 26, 13373, 370, 291, 12, 13373, 370, 1031, 18, 26, 267, 3222, 63, 475, 275, 469, 291, 14, 2415, 59, 16, 1055, 21102, 342, 520, 378, 14, 845, 12, 490, 291, 14, 2415, 59, 17, 1055, 21102, 342, 520, 378, 14, 1081, 12, 490, 291, 14, 2415, 59, 16, 1055, 362, 2048, 1562, 480, 504, 17, 531, 520, 378, 14, 1153, 12, 490, 291, 14, 2415, 59, 17, 1055, 362, 2048, 1562, 480, 475, 277, 531, 520, 378, 14, 1602, 789, 267, 22083, 275, 291, 14, 2415, 59, 17, 1055, 2254, 3479, 12398, 3222, 63, 475, 9, 267, 291, 14, 5186, 63, 452, 342, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 2254, 2266, 4606, 582, 6745, 6096, 16, 14, 845, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 9391, 2266, 4606, 582, 6745, 480, 16, 14, 845, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 2254, 2266, 4606, 582, 6745, 6096, 16, 14, 1081, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 9391, 2266, 4606, 582, 6745, 480, 16, 14, 1081, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 2254, 2266, 4606, 582, 6745, 6096, 16, 14, 1153, 25988, 2574, 2420, 14113, 582, 14113, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 16, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 9391, 2266, 4606, 582, 6745, 480, 16, 14, 1153, 25988, 2574, 2420, 14113, 582, 14113, 12, 298, 2048, 2, 520, 298, 504, 17, 3570, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 2254, 2266, 4606, 582, 6745, 6096, 16, 14, 1602, 25988, 2574, 2420, 14113, 582, 14113, 12, 298, 2048, 2, 520, 3087, 93, 776, 267, 702, 63, 1144, 63, 1099, 8, 277, 14, 2415, 59, 17, 1055, 513, 13754, 1062, 2574, 2420, 3710, 5122, 9391, 2266, 4606, 582, 6745, 480,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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 ]
SAP/pyhdb
tests/test_dummy_sql.py
8
3703
# Copyright 2014, 2015 SAP SE. # # 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 random import datetime from decimal import Decimal, getcontext import pytest @pytest.mark.hanatest def test_dummy_sql_int(connection): cursor = connection.cursor() cursor.execute("SELECT 1 FROM DUMMY") result = cursor.fetchone() assert result == (1,) @pytest.mark.hanatest def test_dummy_sql_decimal(connection): getcontext().prec = 36 cursor = connection.cursor() cursor.execute("SELECT -312313212312321.1245678910111213142 FROM DUMMY") result = cursor.fetchone() assert result == (Decimal('-312313212312321.1245678910111213142'),) @pytest.mark.hanatest def test_dummy_sql_string(connection): cursor = connection.cursor() cursor.execute("SELECT 'Hello World' FROM DUMMY") result = cursor.fetchone() assert result == ("Hello World",) @pytest.mark.hanatest def test_dummy_sql_long_string(connection): test_string = '%030x' % random.randrange(16**300) cursor = connection.cursor() cursor.execute("SELECT '%s' FROM DUMMY" % test_string) result = cursor.fetchone() assert result == (test_string,) @pytest.mark.hanatest def test_dummy_sql_binary(connection): cursor = connection.cursor() cursor.execute("SELECT X'FF00FFA3B5' FROM DUMMY") result = cursor.fetchone() assert result == (b"\xFF\x00\xFF\xA3\xB5",) @pytest.mark.hanatest def test_dummy_sql_current_time(connection): cursor = connection.cursor() cursor.execute("SELECT current_time FROM DUMMY") result = cursor.fetchone() assert isinstance(result[0], datetime.time) @pytest.mark.hanatest def test_dummy_sql_to_time(connection): now = datetime.datetime.now().time() cursor = connection.cursor() cursor.execute("SELECT to_time(%s) FROM DUMMY", (now,)) result = cursor.fetchone() # No support of microsecond assert result[0] == now.replace(microsecond=0) @pytest.mark.hanatest def test_dummy_sql_current_date(connection): cursor = connection.cursor() cursor.execute("SELECT current_date FROM DUMMY") result = cursor.fetchone() assert isinstance(result[0], datetime.date) @pytest.mark.hanatest def test_dummy_sql_to_date(connection): today = datetime.date.today() cursor = connection.cursor() cursor.execute("SELECT to_date(%s) FROM DUMMY", (today,)) result = cursor.fetchone() assert result[0] == today @pytest.mark.hanatest def test_dummy_sql_current_timestamp(connection): cursor = connection.cursor() cursor.execute("SELECT current_timestamp FROM DUMMY") result = cursor.fetchone() assert isinstance(result[0], datetime.datetime) @pytest.mark.hanatest def test_dummy_sql_to_timestamp(connection): now = datetime.datetime.now() now = now.replace(microsecond=123000) cursor = connection.cursor() cursor.execute("SELECT to_timestamp(%s) FROM DUMMY", (now,)) result = cursor.fetchone() assert result[0] == now @pytest.mark.hanatest def test_dummy_sql_without_result(connection): cursor = connection.cursor() cursor.execute("SELECT 1 FROM DUMMY WHERE 1 != 1") result = cursor.fetchone() assert result is None
apache-2.0
[ 3, 1898, 6927, 12, 6900, 428, 1282, 5795, 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, 1455, 26, 5001, 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, 3826, 12, 199, 3, 1902, 4056, 503, 2478, 14, 1666, 314, 844, 367, 314, 2488, 199, 3, 2637, 4210, 3443, 436, 4204, 1334, 314, 844, 14, 199, 199, 646, 2196, 199, 646, 2197, 199, 504, 6107, 492, 6345, 12, 664, 1100, 199, 199, 646, 4613, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 442, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 413, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 334, 17, 4258, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 6355, 8, 2105, 304, 272, 664, 1100, 1252, 9218, 275, 8780, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 446, 16683, 2192, 708, 4288, 713, 12638, 14, 7214, 6690, 4893, 6094, 969, 12199, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 334, 6745, 3654, 16683, 2192, 708, 4288, 713, 12638, 14, 7214, 6690, 4893, 6094, 969, 12199, 659, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 875, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 283, 6257, 13064, 7, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 1689, 6257, 13064, 26360, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 2809, 63, 875, 8, 2105, 304, 272, 511, 63, 875, 275, 1543, 22739, 88, 7, 450, 2196, 14, 20539, 8, 975, 538, 5863, 9, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1543, 83, 7, 4442, 577, 22472, 2, 450, 511, 63, 875, 9, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 334, 396, 63, 875, 4258, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 3008, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1323, 7, 1665, 383, 1665, 33, 19, 34, 21, 7, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 334, 66, 3212, 9039, 60, 88, 383, 60, 9039, 60, 7471, 19, 60, 8094, 21, 26360, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 1818, 63, 521, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1453, 63, 521, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 1228, 8, 1099, 59, 16, 467, 2197, 14, 521, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 475, 63, 521, 8, 2105, 304, 272, 3063, 275, 2197, 14, 2083, 14, 2131, 1252, 521, 342, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 370, 63, 521, 4042, 83, 9, 4442, 577, 22472, 401, 334, 2131, 4641, 339, 754, 275, 3920, 14, 11591, 342, 339, 327, 3091, 2291, 402, 25824, 272, 702, 754, 59, 16, 61, 508, 3063, 14, 1814, 8, 16627, 29, 16, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 1818, 63, 602, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1453, 63, 602, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 1228, 8, 1099, 59, 16, 467, 2197, 14, 602, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 475, 63, 602, 8, 2105, 304, 272, 11168, 275, 2197, 14, 602, 14, 8136, 342, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 370, 63, 602, 4042, 83, 9, 4442, 577, 22472, 401, 334, 8136, 4641, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 59, 16, 61, 508, 11168, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 1818, 63, 3954, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1453, 63, 3954, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 1228, 8, 1099, 59, 16, 467, 2197, 14, 2083, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 475, 63, 3954, 8, 2105, 304, 272, 3063, 275, 2197, 14, 2083, 14, 2131, 342, 272, 3063, 275, 3063, 14, 1814, 8, 16627, 29, 4288, 1493, 9, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 370, 63, 3954, 4042, 83, 9, 4442, 577, 22472, 401, 334, 2131, 4641, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 59, 16, 61, 508, 3063, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 7395, 63, 1099, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 413, 4442, 577, 22472, 6038, 413, 1137, 413, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 365, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6927, 12, 6900, 428, 1282, 5795, 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, 1455, 26, 5001, 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, 3826, 12, 199, 3, 1902, 4056, 503, 2478, 14, 1666, 314, 844, 367, 314, 2488, 199, 3, 2637, 4210, 3443, 436, 4204, 1334, 314, 844, 14, 199, 199, 646, 2196, 199, 646, 2197, 199, 504, 6107, 492, 6345, 12, 664, 1100, 199, 199, 646, 4613, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 442, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 413, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 334, 17, 4258, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 6355, 8, 2105, 304, 272, 664, 1100, 1252, 9218, 275, 8780, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 446, 16683, 2192, 708, 4288, 713, 12638, 14, 7214, 6690, 4893, 6094, 969, 12199, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 334, 6745, 3654, 16683, 2192, 708, 4288, 713, 12638, 14, 7214, 6690, 4893, 6094, 969, 12199, 659, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 875, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 283, 6257, 13064, 7, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 1689, 6257, 13064, 26360, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 2809, 63, 875, 8, 2105, 304, 272, 511, 63, 875, 275, 1543, 22739, 88, 7, 450, 2196, 14, 20539, 8, 975, 538, 5863, 9, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1543, 83, 7, 4442, 577, 22472, 2, 450, 511, 63, 875, 9, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 334, 396, 63, 875, 4258, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 3008, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1323, 7, 1665, 383, 1665, 33, 19, 34, 21, 7, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 508, 334, 66, 3212, 9039, 60, 88, 383, 60, 9039, 60, 7471, 19, 60, 8094, 21, 26360, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 1818, 63, 521, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1453, 63, 521, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 1228, 8, 1099, 59, 16, 467, 2197, 14, 521, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 475, 63, 521, 8, 2105, 304, 272, 3063, 275, 2197, 14, 2083, 14, 2131, 1252, 521, 342, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 370, 63, 521, 4042, 83, 9, 4442, 577, 22472, 401, 334, 2131, 4641, 339, 754, 275, 3920, 14, 11591, 342, 339, 327, 3091, 2291, 402, 25824, 272, 702, 754, 59, 16, 61, 508, 3063, 14, 1814, 8, 16627, 29, 16, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 1818, 63, 602, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1453, 63, 602, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 1228, 8, 1099, 59, 16, 467, 2197, 14, 602, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 475, 63, 602, 8, 2105, 304, 272, 11168, 275, 2197, 14, 602, 14, 8136, 342, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 370, 63, 602, 4042, 83, 9, 4442, 577, 22472, 401, 334, 8136, 4641, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 59, 16, 61, 508, 11168, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 1818, 63, 3954, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 1453, 63, 3954, 4442, 577, 22472, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 1228, 8, 1099, 59, 16, 467, 2197, 14, 2083, 9, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 475, 63, 3954, 8, 2105, 304, 272, 3063, 275, 2197, 14, 2083, 14, 2131, 342, 272, 3063, 275, 3063, 14, 1814, 8, 16627, 29, 4288, 1493, 9, 339, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 370, 63, 3954, 4042, 83, 9, 4442, 577, 22472, 401, 334, 2131, 4641, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 59, 16, 61, 508, 3063, 421, 199, 32, 4462, 14, 1657, 14, 19262, 27126, 199, 318, 511, 63, 5869, 63, 3009, 63, 7395, 63, 1099, 8, 2105, 304, 272, 3920, 275, 1950, 14, 3937, 342, 272, 3920, 14, 2526, 480, 4859, 413, 4442, 577, 22472, 6038, 413, 1137, 413, 531, 339, 754, 275, 3920, 14, 11591, 342, 272, 702, 754, 365, 488, 199, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
trankmichael/scipy
scipy/linalg/matfuncs.py
46
19913
# # Author: Travis Oliphant, March 2002 # from __future__ import division, print_function, absolute_import __all__ = ['expm','expm2','expm3','cosm','sinm','tanm','coshm','sinhm', 'tanhm','logm','funm','signm','sqrtm', 'expm_frechet', 'expm_cond', 'fractional_matrix_power'] from numpy import (Inf, dot, diag, exp, product, logical_not, cast, ravel, transpose, conjugate, absolute, amax, sign, isfinite, sqrt, single) import numpy as np import warnings # Local imports from .misc import norm from .basic import solve, inv from .special_matrices import triu from .decomp import eig from .decomp_svd import svd from .decomp_schur import schur, rsf2csf from ._expm_frechet import expm_frechet, expm_cond from ._matfuncs_sqrtm import sqrtm eps = np.finfo(float).eps feps = np.finfo(single).eps _array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1} ############################################################################### # Utility functions. def _asarray_square(A): """ Wraps asarray with the extra requirement that the input be a square matrix. The motivation is that the matfuncs module has real functions that have been lifted to square matrix functions. Parameters ---------- A : array_like A square matrix. Returns ------- out : ndarray An ndarray copy or view or other representation of A. """ A = np.asarray(A) if len(A.shape) != 2 or A.shape[0] != A.shape[1]: raise ValueError('expected square array_like input') return A def _maybe_real(A, B, tol=None): """ Return either B or the real part of B, depending on properties of A and B. The motivation is that B has been computed as a complicated function of A, and B may be perturbed by negligible imaginary components. If A is real and B is complex with small imaginary components, then return a real copy of B. The assumption in that case would be that the imaginary components of B are numerical artifacts. Parameters ---------- A : ndarray Input array whose type is to be checked as real vs. complex. B : ndarray Array to be returned, possibly without its imaginary part. tol : float Absolute tolerance. Returns ------- out : real or complex array Either the input array B or only the real part of the input array B. """ # Note that booleans and integers compare as real. if np.isrealobj(A) and np.iscomplexobj(B): if tol is None: tol = {0:feps*1e3, 1:eps*1e6}[_array_precision[B.dtype.char]] if np.allclose(B.imag, 0.0, atol=tol): B = B.real return B ############################################################################### # Matrix functions. def fractional_matrix_power(A, t): """ Compute the fractional power of a matrix. Proceeds according to the discussion in section (6) of [1]_. Parameters ---------- A : (N, N) array_like Matrix whose fractional power to evaluate. t : float Fractional power. Returns ------- X : (N, N) array_like The fractional power of the matrix. References ---------- .. [1] Nicholas J. Higham and Lijing lin (2011) "A Schur-Pade Algorithm for Fractional Powers of a Matrix." SIAM Journal on Matrix Analysis and Applications, 32 (3). pp. 1056-1078. ISSN 0895-4798 Examples -------- >>> from scipy.linalg import fractional_matrix_power >>> a = np.array([[1.0, 3.0], [1.0, 4.0]]) >>> b = fractional_matrix_power(a, 0.5) >>> b array([[ 0.75592895, 1.13389342], [ 0.37796447, 1.88982237]]) >>> np.dot(b, b) # Verify square root array([[ 1., 3.], [ 1., 4.]]) """ # This fixes some issue with imports; # this function calls onenormest which is in scipy.sparse. A = _asarray_square(A) import scipy.linalg._matfuncs_inv_ssq return scipy.linalg._matfuncs_inv_ssq._fractional_matrix_power(A, t) def logm(A, disp=True): """ Compute matrix logarithm. The matrix logarithm is the inverse of expm: expm(logm(`A`)) == `A` Parameters ---------- A : (N, N) array_like Matrix whose logarithm to evaluate disp : bool, optional Print warning if error in the result is estimated large instead of returning estimated error. (Default: True) Returns ------- logm : (N, N) ndarray Matrix logarithm of `A` errest : float (if disp == False) 1-norm of the estimated error, ||err||_1 / ||A||_1 References ---------- .. [1] Awad H. Al-Mohy and Nicholas J. Higham (2012) "Improved Inverse Scaling and Squaring Algorithms for the Matrix Logarithm." SIAM Journal on Scientific Computing, 34 (4). C152-C169. ISSN 1095-7197 .. [2] Nicholas J. Higham (2008) "Functions of Matrices: Theory and Computation" ISBN 978-0-898716-46-7 .. [3] Nicholas J. Higham and Lijing lin (2011) "A Schur-Pade Algorithm for Fractional Powers of a Matrix." SIAM Journal on Matrix Analysis and Applications, 32 (3). pp. 1056-1078. ISSN 0895-4798 Examples -------- >>> from scipy.linalg import logm, expm >>> a = np.array([[1.0, 3.0], [1.0, 4.0]]) >>> b = logm(a) >>> b array([[-1.02571087, 2.05142174], [ 0.68380725, 1.02571087]]) >>> expm(b) # Verify expm(logm(a)) returns a array([[ 1., 3.], [ 1., 4.]]) """ A = _asarray_square(A) # Avoid circular import ... this is OK, right? import scipy.linalg._matfuncs_inv_ssq F = scipy.linalg._matfuncs_inv_ssq._logm(A) errtol = 1000*eps #TODO use a better error approximation errest = norm(expm(F)-A,1) / norm(A,1) if disp: if not isfinite(errest) or errest >= errtol: print("logm result may be inaccurate, approximate err =", errest) return F else: return F, errest def expm(A, q=None): """ Compute the matrix exponential using Pade approximation. Parameters ---------- A : (N, N) array_like or sparse matrix Matrix to be exponentiated. Returns ------- expm : (N, N) ndarray Matrix exponential of `A`. References ---------- .. [1] Awad H. Al-Mohy and Nicholas J. Higham (2009) "A New Scaling and Squaring Algorithm for the Matrix Exponential." SIAM Journal on Matrix Analysis and Applications. 31 (3). pp. 970-989. ISSN 1095-7162 Examples -------- >>> from scipy.linalg import expm, sinm, cosm Matrix version of the formula exp(0) = 1: >>> expm(np.zeros((2,2))) array([[ 1., 0.], [ 0., 1.]]) Euler's identity (exp(i*theta) = cos(theta) + i*sin(theta)) applied to a matrix: >>> a = np.array([[1.0, 2.0], [-1.0, 3.0]]) >>> expm(1j*a) array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j], [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]]) >>> cosm(a) + 1j*sinm(a) array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j], [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]]) """ if q is not None: msg = "argument q=... in scipy.linalg.expm is deprecated." warnings.warn(msg, DeprecationWarning) # Input checking and conversion is provided by sparse.linalg.expm(). import scipy.sparse.linalg return scipy.sparse.linalg.expm(A) # deprecated, but probably should be left there in the long term @np.deprecate(new_name="expm") def expm2(A): """ Compute the matrix exponential using eigenvalue decomposition. Parameters ---------- A : (N, N) array_like Matrix to be exponentiated Returns ------- expm2 : (N, N) ndarray Matrix exponential of `A` """ A = _asarray_square(A) t = A.dtype.char if t not in ['f','F','d','D']: A = A.astype('d') t = 'd' s, vr = eig(A) vri = inv(vr) r = dot(dot(vr, diag(exp(s))), vri) if t in ['f', 'd']: return r.real.astype(t) else: return r.astype(t) # deprecated, but probably should be left there in the long term @np.deprecate(new_name="expm") def expm3(A, q=20): """ Compute the matrix exponential using Taylor series. Parameters ---------- A : (N, N) array_like Matrix to be exponentiated q : int Order of the Taylor series used is `q-1` Returns ------- expm3 : (N, N) ndarray Matrix exponential of `A` """ A = _asarray_square(A) n = A.shape[0] t = A.dtype.char if t not in ['f','F','d','D']: A = A.astype('d') t = 'd' eA = np.identity(n, dtype=t) trm = np.identity(n, dtype=t) castfunc = cast[t] for k in range(1, q): trm[:] = trm.dot(A) / castfunc(k) eA += trm return eA def cosm(A): """ Compute the matrix cosine. This routine uses expm to compute the matrix exponentials. Parameters ---------- A : (N, N) array_like Input array Returns ------- cosm : (N, N) ndarray Matrix cosine of A Examples -------- >>> from scipy.linalg import expm, sinm, cosm Euler's identity (exp(i*theta) = cos(theta) + i*sin(theta)) applied to a matrix: >>> a = np.array([[1.0, 2.0], [-1.0, 3.0]]) >>> expm(1j*a) array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j], [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]]) >>> cosm(a) + 1j*sinm(a) array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j], [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]]) """ A = _asarray_square(A) if np.iscomplexobj(A): return 0.5*(expm(1j*A) + expm(-1j*A)) else: return expm(1j*A).real def sinm(A): """ Compute the matrix sine. This routine uses expm to compute the matrix exponentials. Parameters ---------- A : (N, N) array_like Input array. Returns ------- sinm : (N, N) ndarray Matrix cosine of `A` Examples -------- >>> from scipy.linalg import expm, sinm, cosm Euler's identity (exp(i*theta) = cos(theta) + i*sin(theta)) applied to a matrix: >>> a = np.array([[1.0, 2.0], [-1.0, 3.0]]) >>> expm(1j*a) array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j], [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]]) >>> cosm(a) + 1j*sinm(a) array([[ 0.42645930+1.89217551j, -2.13721484-0.97811252j], [ 1.06860742+0.48905626j, -1.71075555+0.91406299j]]) """ A = _asarray_square(A) if np.iscomplexobj(A): return -0.5j*(expm(1j*A) - expm(-1j*A)) else: return expm(1j*A).imag def tanm(A): """ Compute the matrix tangent. This routine uses expm to compute the matrix exponentials. Parameters ---------- A : (N, N) array_like Input array. Returns ------- tanm : (N, N) ndarray Matrix tangent of `A` Examples -------- >>> from scipy.linalg import tanm, sinm, cosm >>> a = np.array([[1.0, 3.0], [1.0, 4.0]]) >>> t = tanm(a) >>> t array([[ -2.00876993, -8.41880636], [ -2.80626879, -10.42757629]]) Verify tanm(a) = sinm(a).dot(inv(cosm(a))) >>> s = sinm(a) >>> c = cosm(a) >>> s.dot(np.linalg.inv(c)) array([[ -2.00876993, -8.41880636], [ -2.80626879, -10.42757629]]) """ A = _asarray_square(A) return _maybe_real(A, solve(cosm(A), sinm(A))) def coshm(A): """ Compute the hyperbolic matrix cosine. This routine uses expm to compute the matrix exponentials. Parameters ---------- A : (N, N) array_like Input array. Returns ------- coshm : (N, N) ndarray Hyperbolic matrix cosine of `A` Examples -------- >>> from scipy.linalg import tanhm, sinhm, coshm >>> a = np.array([[1.0, 3.0], [1.0, 4.0]]) >>> c = coshm(a) >>> c array([[ 11.24592233, 38.76236492], [ 12.92078831, 50.00828725]]) Verify tanhm(a) = sinhm(a).dot(inv(coshm(a))) >>> t = tanhm(a) >>> s = sinhm(a) >>> t - s.dot(np.linalg.inv(c)) array([[ 2.72004641e-15, 4.55191440e-15], [ 0.00000000e+00, -5.55111512e-16]]) """ A = _asarray_square(A) return _maybe_real(A, 0.5 * (expm(A) + expm(-A))) def sinhm(A): """ Compute the hyperbolic matrix sine. This routine uses expm to compute the matrix exponentials. Parameters ---------- A : (N, N) array_like Input array. Returns ------- sinhm : (N, N) ndarray Hyperbolic matrix sine of `A` Examples -------- >>> from scipy.linalg import tanhm, sinhm, coshm >>> a = np.array([[1.0, 3.0], [1.0, 4.0]]) >>> s = sinhm(a) >>> s array([[ 10.57300653, 39.28826594], [ 13.09608865, 49.86127247]]) Verify tanhm(a) = sinhm(a).dot(inv(coshm(a))) >>> t = tanhm(a) >>> c = coshm(a) >>> t - s.dot(np.linalg.inv(c)) array([[ 2.72004641e-15, 4.55191440e-15], [ 0.00000000e+00, -5.55111512e-16]]) """ A = _asarray_square(A) return _maybe_real(A, 0.5 * (expm(A) - expm(-A))) def tanhm(A): """ Compute the hyperbolic matrix tangent. This routine uses expm to compute the matrix exponentials. Parameters ---------- A : (N, N) array_like Input array Returns ------- tanhm : (N, N) ndarray Hyperbolic matrix tangent of `A` Examples -------- >>> from scipy.linalg import tanhm, sinhm, coshm >>> a = np.array([[1.0, 3.0], [1.0, 4.0]]) >>> t = tanhm(a) >>> t array([[ 0.3428582 , 0.51987926], [ 0.17329309, 0.86273746]]) Verify tanhm(a) = sinhm(a).dot(inv(coshm(a))) >>> s = sinhm(a) >>> c = coshm(a) >>> t - s.dot(np.linalg.inv(c)) array([[ 2.72004641e-15, 4.55191440e-15], [ 0.00000000e+00, -5.55111512e-16]]) """ A = _asarray_square(A) return _maybe_real(A, solve(coshm(A), sinhm(A))) def funm(A, func, disp=True): """ Evaluate a matrix function specified by a callable. Returns the value of matrix-valued function ``f`` at `A`. The function ``f`` is an extension of the scalar-valued function `func` to matrices. Parameters ---------- A : (N, N) array_like Matrix at which to evaluate the function func : callable Callable object that evaluates a scalar function f. Must be vectorized (eg. using vectorize). disp : bool, optional Print warning if error in the result is estimated large instead of returning estimated error. (Default: True) Returns ------- funm : (N, N) ndarray Value of the matrix function specified by func evaluated at `A` errest : float (if disp == False) 1-norm of the estimated error, ||err||_1 / ||A||_1 Examples -------- >>> from scipy.linalg import funm >>> a = np.array([[1.0, 3.0], [1.0, 4.0]]) >>> funm(a, lambda x: x*x) array([[ 4., 15.], [ 5., 19.]]) >>> a.dot(a) array([[ 4., 15.], [ 5., 19.]]) Notes ----- This function implements the general algorithm based on Schur decomposition (Algorithm 9.1.1. in [1]_). If the input matrix is known to be diagonalizable, then relying on the eigendecomposition is likely to be faster. For example, if your matrix is Hermitian, you can do >>> from scipy.linalg import eigh >>> def funm_herm(a, func, check_finite=False): ... w, v = eigh(a, check_finite=check_finite) ... ## if you further know that your matrix is positive semidefinite, ... ## you can optionally guard against precision errors by doing ... # w = np.maximum(w, 0) ... w = func(w) ... return (v * w).dot(v.conj().T) References ---------- .. [1] Gene H. Golub, Charles F. van Loan, Matrix Computations 4th ed. """ A = _asarray_square(A) # Perform Shur decomposition (lapack ?gees) T, Z = schur(A) T, Z = rsf2csf(T,Z) n,n = T.shape F = diag(func(diag(T))) # apply function to diagonal elements F = F.astype(T.dtype.char) # e.g. when F is real but T is complex minden = abs(T[0,0]) # implement Algorithm 11.1.1 from Golub and Van Loan # "matrix Computations." for p in range(1,n): for i in range(1,n-p+1): j = i + p s = T[i-1,j-1] * (F[j-1,j-1] - F[i-1,i-1]) ksl = slice(i,j-1) val = dot(T[i-1,ksl],F[ksl,j-1]) - dot(F[i-1,ksl],T[ksl,j-1]) s = s + val den = T[j-1,j-1] - T[i-1,i-1] if den != 0.0: s = s / den F[i-1,j-1] = s minden = min(minden,abs(den)) F = dot(dot(Z, F), transpose(conjugate(Z))) F = _maybe_real(A, F) tol = {0:feps, 1:eps}[_array_precision[F.dtype.char]] if minden == 0.0: minden = tol err = min(1, max(tol,(tol/minden)*norm(triu(T,1),1))) if product(ravel(logical_not(isfinite(F))),axis=0): err = Inf if disp: if err > 1000*tol: print("funm result may be inaccurate, approximate err =", err) return F else: return F, err def signm(A, disp=True): """ Matrix sign function. Extension of the scalar sign(x) to matrices. Parameters ---------- A : (N, N) array_like Matrix at which to evaluate the sign function disp : bool, optional Print warning if error in the result is estimated large instead of returning estimated error. (Default: True) Returns ------- signm : (N, N) ndarray Value of the sign function at `A` errest : float (if disp == False) 1-norm of the estimated error, ||err||_1 / ||A||_1 Examples -------- >>> from scipy.linalg import signm, eigvals >>> a = [[1,2,3], [1,2,1], [1,1,1]] >>> eigvals(a) array([ 4.12488542+0.j, -0.76155718+0.j, 0.63667176+0.j]) >>> eigvals(signm(a)) array([-1.+0.j, 1.+0.j, 1.+0.j]) """ A = _asarray_square(A) def rounded_sign(x): rx = np.real(x) if rx.dtype.char == 'f': c = 1e3*feps*amax(x) else: c = 1e3*eps*amax(x) return sign((absolute(rx) > c) * rx) result, errest = funm(A, rounded_sign, disp=0) errtol = {0:1e3*feps, 1:1e3*eps}[_array_precision[result.dtype.char]] if errest < errtol: return result # Handle signm of defective matrices: # See "E.D.Denman and J.Leyva-Ramos, Appl.Math.Comp., # 8:237-250,1981" for how to improve the following (currently a # rather naive) iteration process: # a = result # sometimes iteration converges faster but where?? # Shifting to avoid zero eigenvalues. How to ensure that shifting does # not change the spectrum too much? vals = svd(A, compute_uv=0) max_sv = np.amax(vals) # min_nonzero_sv = vals[(vals>max_sv*errtol).tolist().count(1)-1] # c = 0.5/min_nonzero_sv c = 0.5/max_sv S0 = A + c*np.identity(A.shape[0]) prev_errest = errest for i in range(100): iS0 = inv(S0) S0 = 0.5*(S0 + iS0) Pp = 0.5*(dot(S0,S0)+S0) errest = norm(dot(Pp,Pp)-Pp,1) if errest < errtol or prev_errest == errest: break prev_errest = errest if disp: if not isfinite(errest) or errest >= errtol: print("signm result may be inaccurate, approximate err =", errest) return S0 else: return S0, errest
bsd-3-clause
[ 3, 199, 3, 6529, 26, 12643, 5068, 593, 317, 838, 867, 12, 603, 1047, 14790, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 363, 452, 363, 275, 788, 32561, 1673, 32561, 18, 1673, 32561, 19, 1673, 331, 3300, 1673, 5911, 77, 1673, 12990, 77, 1673, 15106, 77, 1673, 5911, 14038, 297, 1779, 283, 12990, 14038, 1673, 793, 77, 1673, 7036, 77, 1673, 1037, 77, 1673, 5079, 77, 297, 1779, 283, 32561, 63, 20153, 335, 386, 297, 283, 32561, 63, 2067, 297, 283, 13054, 279, 63, 3642, 63, 5652, 418, 199, 199, 504, 2680, 492, 334, 17354, 12, 6308, 12, 8348, 12, 1437, 12, 3336, 12, 11461, 63, 1397, 12, 9106, 12, 660, 1090, 12, 267, 16992, 12, 27246, 12, 3679, 12, 282, 988, 12, 2070, 12, 365, 8005, 12, 7452, 12, 2849, 9, 199, 646, 2680, 465, 980, 199, 646, 3598, 199, 199, 3, 10111, 8925, 199, 504, 1275, 9923, 492, 6316, 199, 504, 1275, 4316, 492, 14241, 12, 4572, 199, 504, 1275, 6664, 63, 19032, 492, 3229, 85, 199, 504, 1275, 271, 863, 492, 26547, 199, 504, 1275, 271, 863, 63, 18675, 492, 26937, 199, 504, 1275, 271, 863, 63, 15820, 300, 492, 308, 335, 300, 12, 519, 7646, 18, 1259, 70, 199, 504, 13653, 32561, 63, 20153, 335, 386, 492, 1437, 77, 63, 20153, 335, 386, 12, 1437, 77, 63, 2067, 199, 504, 13653, 569, 9204, 63, 5079, 77, 492, 7452, 77, 199, 199, 8277, 275, 980, 14, 23087, 8, 1609, 680, 8277, 199, 771, 1190, 275, 980, 14, 23087, 8, 4780, 680, 8277, 199, 199, 63, 1144, 63, 6833, 275, 791, 73, 356, 413, 12, 283, 76, 356, 413, 12, 283, 70, 356, 378, 12, 283, 68, 356, 413, 12, 283, 38, 356, 378, 12, 283, 36, 356, 413, 93, 421, 199, 11490, 199, 3, 20511, 3423, 14, 421, 199, 318, 485, 8748, 63, 9646, 8, 33, 304, 272, 408, 272, 644, 8146, 24144, 543, 314, 2402, 10685, 626, 314, 1324, 506, 282, 12386, 3634, 14, 339, 710, 1303, 280, 4255, 365, 626, 314, 2530, 9204, 859, 965, 3363, 3423, 626, 1172, 272, 2757, 221, 853, 471, 370, 12386, 3634, 3423, 14, 339, 3897, 272, 4143, 272, 437, 520, 1625, 63, 2930, 267, 437, 12386, 3634, 14, 339, 1803, 272, 5514, 272, 734, 520, 6800, 267, 1626, 6800, 1331, 503, 2455, 503, 1163, 6025, 402, 437, 14, 339, 408, 272, 437, 275, 980, 14, 8748, 8, 33, 9, 272, 340, 822, 8, 33, 14, 1392, 9, 1137, 499, 503, 437, 14, 1392, 59, 16, 61, 1137, 437, 14, 1392, 59, 17, 2189, 267, 746, 1722, 360, 2062, 12386, 1625, 63, 2930, 1324, 358, 272, 372, 437, 421, 199, 318, 485, 11853, 63, 3093, 8, 33, 12, 699, 12, 9561, 29, 403, 304, 272, 408, 272, 1432, 1902, 699, 503, 314, 3363, 1777, 402, 699, 12, 10298, 641, 4382, 402, 437, 436, 699, 14, 339, 710, 1303, 280, 4255, 365, 626, 699, 965, 2757, 9235, 465, 282, 23515, 805, 402, 437, 12, 272, 436, 699, 1443, 506, 1126, 16218, 6123, 701, 14158, 317, 28297, 30249, 7323, 14, 272, 982, 437, 365, 3363, 436, 699, 365, 6114, 543, 7425, 30249, 7323, 12, 272, 2066, 372, 282, 3363, 1331, 402, 699, 14, 221, 710, 30075, 315, 626, 1930, 3955, 506, 626, 272, 314, 30249, 7323, 402, 699, 787, 15470, 27990, 14, 339, 3897, 272, 4143, 272, 437, 520, 6800, 267, 6924, 1625, 7447, 730, 365, 370, 506, 7923, 465, 3363, 8118, 14, 6114, 14, 272, 699, 520, 6800, 267, 8725, 370, 506, 2138, 12, 12570, 1928, 2399, 30249, 1777, 14, 272, 9561, 520, 2069, 267, 24964, 13464, 14, 339, 1803, 272, 5514, 272, 734, 520, 3363, 503, 6114, 1625, 267, 13083, 314, 1324, 1625, 699, 503, 1454, 314, 3363, 1777, 402, 314, 1324, 1625, 699, 14, 339, 408, 272, 327, 3390, 626, 1234, 16721, 796, 436, 9446, 6540, 465, 3363, 14, 272, 340, 980, 14, 374, 3093, 1113, 8, 33, 9, 436, 980, 14, 374, 5254, 1113, 8, 34, 304, 267, 340, 9561, 365, 488, 26, 288, 9561, 275, 469, 16, 26, 771, 1190, 10, 17, 69, 19, 12, 413, 26, 8277, 10, 17, 69, 22, 93, 13040, 1144, 63, 6833, 59, 34, 14, 2271, 14, 1560, 2677, 267, 340, 980, 14, 7520, 8, 34, 14, 14688, 12, 378, 14, 16, 12, 9543, 29, 6896, 304, 288, 699, 275, 699, 14, 3093, 272, 372, 699, 421, 199, 11490, 199, 3, 8449, 3423, 14, 421, 199, 318, 27487, 63, 3642, 63, 5652, 8, 33, 12, 307, 304, 272, 408, 272, 8354, 314, 27487, 7074, 402, 282, 3634, 14, 339, 2165, 301, 5923, 7182, 370, 314, 16582, 315, 3420, 334, 22, 9, 402, 359, 17, 61, 3754, 339, 3897, 272, 4143, 272, 437, 520, 334, 46, 12, 653, 9, 1625, 63, 2930, 267, 8449, 7447, 27487, 7074, 370, 9352, 14, 272, 307, 520, 2069, 267, 17980, 279, 7074, 14, 339, 1803, 272, 5514, 272, 1323, 520, 334, 46, 12, 653, 9, 1625, 63, 2930, 267, 710, 27487, 7074, 402, 314, 3634, 14, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 653, 1158, 393, 305, 1603, 14, 16332, 455, 436, 491, 7879, 316, 7403, 334, 8128, 9, 1779, 298, 33, 22985, 300, 13, 4232, 271, 23823, 367, 17980, 279, 510, 583, 1192, 402, 282, 8449, 2122, 1779, 428, 41, 1156, 22142, 641, 8449, 21916, 436, 24636, 12, 1779, 4337, 334, 19, 680, 11618, 14, 1616, 1367, 13, 709, 2277, 14, 2281, 8199, 378, 11382, 13, 14847, 24, 339, 6058, 272, 3001, 272, 1306, 687, 7026, 14, 10096, 492, 27487, 63, 3642, 63, 5652, 272, 1306, 282, 275, 980, 14, 1144, 4038, 17, 14, 16, 12, 650, 14, 16, 467, 359, 17, 14, 16, 12, 841, 14, 16, 3934, 272, 1306, 330, 275, 27487, 63, 3642, 63, 5652, 8, 65, 12, 378, 14, 21, 9, 272, 1306, 330, 272, 1625, 4038, 378, 14, 12315, 2942, 11382, 12, 221, 413, 14, 10456, 1407, 14519, 467, 1779, 359, 378, 14, 7332, 31124, 2417, 12, 221, 413, 14, 1299, 2905, 1081, 1401, 3934, 272, 1306, 980, 14, 3287, 8, 66, 12, 330, 9, 420, 327, 7635, 12386, 1738 ]
[ 199, 3, 6529, 26, 12643, 5068, 593, 317, 838, 867, 12, 603, 1047, 14790, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 363, 452, 363, 275, 788, 32561, 1673, 32561, 18, 1673, 32561, 19, 1673, 331, 3300, 1673, 5911, 77, 1673, 12990, 77, 1673, 15106, 77, 1673, 5911, 14038, 297, 1779, 283, 12990, 14038, 1673, 793, 77, 1673, 7036, 77, 1673, 1037, 77, 1673, 5079, 77, 297, 1779, 283, 32561, 63, 20153, 335, 386, 297, 283, 32561, 63, 2067, 297, 283, 13054, 279, 63, 3642, 63, 5652, 418, 199, 199, 504, 2680, 492, 334, 17354, 12, 6308, 12, 8348, 12, 1437, 12, 3336, 12, 11461, 63, 1397, 12, 9106, 12, 660, 1090, 12, 267, 16992, 12, 27246, 12, 3679, 12, 282, 988, 12, 2070, 12, 365, 8005, 12, 7452, 12, 2849, 9, 199, 646, 2680, 465, 980, 199, 646, 3598, 199, 199, 3, 10111, 8925, 199, 504, 1275, 9923, 492, 6316, 199, 504, 1275, 4316, 492, 14241, 12, 4572, 199, 504, 1275, 6664, 63, 19032, 492, 3229, 85, 199, 504, 1275, 271, 863, 492, 26547, 199, 504, 1275, 271, 863, 63, 18675, 492, 26937, 199, 504, 1275, 271, 863, 63, 15820, 300, 492, 308, 335, 300, 12, 519, 7646, 18, 1259, 70, 199, 504, 13653, 32561, 63, 20153, 335, 386, 492, 1437, 77, 63, 20153, 335, 386, 12, 1437, 77, 63, 2067, 199, 504, 13653, 569, 9204, 63, 5079, 77, 492, 7452, 77, 199, 199, 8277, 275, 980, 14, 23087, 8, 1609, 680, 8277, 199, 771, 1190, 275, 980, 14, 23087, 8, 4780, 680, 8277, 199, 199, 63, 1144, 63, 6833, 275, 791, 73, 356, 413, 12, 283, 76, 356, 413, 12, 283, 70, 356, 378, 12, 283, 68, 356, 413, 12, 283, 38, 356, 378, 12, 283, 36, 356, 413, 93, 421, 199, 11490, 199, 3, 20511, 3423, 14, 421, 199, 318, 485, 8748, 63, 9646, 8, 33, 304, 272, 408, 272, 644, 8146, 24144, 543, 314, 2402, 10685, 626, 314, 1324, 506, 282, 12386, 3634, 14, 339, 710, 1303, 280, 4255, 365, 626, 314, 2530, 9204, 859, 965, 3363, 3423, 626, 1172, 272, 2757, 221, 853, 471, 370, 12386, 3634, 3423, 14, 339, 3897, 272, 4143, 272, 437, 520, 1625, 63, 2930, 267, 437, 12386, 3634, 14, 339, 1803, 272, 5514, 272, 734, 520, 6800, 267, 1626, 6800, 1331, 503, 2455, 503, 1163, 6025, 402, 437, 14, 339, 408, 272, 437, 275, 980, 14, 8748, 8, 33, 9, 272, 340, 822, 8, 33, 14, 1392, 9, 1137, 499, 503, 437, 14, 1392, 59, 16, 61, 1137, 437, 14, 1392, 59, 17, 2189, 267, 746, 1722, 360, 2062, 12386, 1625, 63, 2930, 1324, 358, 272, 372, 437, 421, 199, 318, 485, 11853, 63, 3093, 8, 33, 12, 699, 12, 9561, 29, 403, 304, 272, 408, 272, 1432, 1902, 699, 503, 314, 3363, 1777, 402, 699, 12, 10298, 641, 4382, 402, 437, 436, 699, 14, 339, 710, 1303, 280, 4255, 365, 626, 699, 965, 2757, 9235, 465, 282, 23515, 805, 402, 437, 12, 272, 436, 699, 1443, 506, 1126, 16218, 6123, 701, 14158, 317, 28297, 30249, 7323, 14, 272, 982, 437, 365, 3363, 436, 699, 365, 6114, 543, 7425, 30249, 7323, 12, 272, 2066, 372, 282, 3363, 1331, 402, 699, 14, 221, 710, 30075, 315, 626, 1930, 3955, 506, 626, 272, 314, 30249, 7323, 402, 699, 787, 15470, 27990, 14, 339, 3897, 272, 4143, 272, 437, 520, 6800, 267, 6924, 1625, 7447, 730, 365, 370, 506, 7923, 465, 3363, 8118, 14, 6114, 14, 272, 699, 520, 6800, 267, 8725, 370, 506, 2138, 12, 12570, 1928, 2399, 30249, 1777, 14, 272, 9561, 520, 2069, 267, 24964, 13464, 14, 339, 1803, 272, 5514, 272, 734, 520, 3363, 503, 6114, 1625, 267, 13083, 314, 1324, 1625, 699, 503, 1454, 314, 3363, 1777, 402, 314, 1324, 1625, 699, 14, 339, 408, 272, 327, 3390, 626, 1234, 16721, 796, 436, 9446, 6540, 465, 3363, 14, 272, 340, 980, 14, 374, 3093, 1113, 8, 33, 9, 436, 980, 14, 374, 5254, 1113, 8, 34, 304, 267, 340, 9561, 365, 488, 26, 288, 9561, 275, 469, 16, 26, 771, 1190, 10, 17, 69, 19, 12, 413, 26, 8277, 10, 17, 69, 22, 93, 13040, 1144, 63, 6833, 59, 34, 14, 2271, 14, 1560, 2677, 267, 340, 980, 14, 7520, 8, 34, 14, 14688, 12, 378, 14, 16, 12, 9543, 29, 6896, 304, 288, 699, 275, 699, 14, 3093, 272, 372, 699, 421, 199, 11490, 199, 3, 8449, 3423, 14, 421, 199, 318, 27487, 63, 3642, 63, 5652, 8, 33, 12, 307, 304, 272, 408, 272, 8354, 314, 27487, 7074, 402, 282, 3634, 14, 339, 2165, 301, 5923, 7182, 370, 314, 16582, 315, 3420, 334, 22, 9, 402, 359, 17, 61, 3754, 339, 3897, 272, 4143, 272, 437, 520, 334, 46, 12, 653, 9, 1625, 63, 2930, 267, 8449, 7447, 27487, 7074, 370, 9352, 14, 272, 307, 520, 2069, 267, 17980, 279, 7074, 14, 339, 1803, 272, 5514, 272, 1323, 520, 334, 46, 12, 653, 9, 1625, 63, 2930, 267, 710, 27487, 7074, 402, 314, 3634, 14, 339, 14504, 272, 4143, 272, 2508, 359, 17, 61, 653, 1158, 393, 305, 1603, 14, 16332, 455, 436, 491, 7879, 316, 7403, 334, 8128, 9, 1779, 298, 33, 22985, 300, 13, 4232, 271, 23823, 367, 17980, 279, 510, 583, 1192, 402, 282, 8449, 2122, 1779, 428, 41, 1156, 22142, 641, 8449, 21916, 436, 24636, 12, 1779, 4337, 334, 19, 680, 11618, 14, 1616, 1367, 13, 709, 2277, 14, 2281, 8199, 378, 11382, 13, 14847, 24, 339, 6058, 272, 3001, 272, 1306, 687, 7026, 14, 10096, 492, 27487, 63, 3642, 63, 5652, 272, 1306, 282, 275, 980, 14, 1144, 4038, 17, 14, 16, 12, 650, 14, 16, 467, 359, 17, 14, 16, 12, 841, 14, 16, 3934, 272, 1306, 330, 275, 27487, 63, 3642, 63, 5652, 8, 65, 12, 378, 14, 21, 9, 272, 1306, 330, 272, 1625, 4038, 378, 14, 12315, 2942, 11382, 12, 221, 413, 14, 10456, 1407, 14519, 467, 1779, 359, 378, 14, 7332, 31124, 2417, 12, 221, 413, 14, 1299, 2905, 1081, 1401, 3934, 272, 1306, 980, 14, 3287, 8, 66, 12, 330, 9, 420, 327, 7635, 12386, 1738, 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 ]
richm/designate
designate/cmd/api.py
1
1217
# Copyright 2013 Hewlett-Packard Development Company, L.P. # # Author: Kiall Mac Innes <kiall@hp.com> # # 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 sys from oslo.config import cfg from designate.openstack.common import log as logging from designate.openstack.common import service from designate import rpc from designate import utils from designate.api import service as api_service CONF = cfg.CONF CONF.import_opt('workers', 'designate.api', group='service:api') def main(): utils.read_config('designate', sys.argv) logging.setup('designate') rpc.init(CONF) launcher = service.launch(api_service.Service(), CONF['service:api'].workers) launcher.wait()
apache-2.0
[ 3, 1898, 6171, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 199, 3, 6529, 26, 1804, 73, 452, 10444, 1010, 17775, 665, 8810, 452, 32, 12025, 14, 957, 30, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 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, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 646, 984, 199, 504, 11258, 14, 888, 492, 4810, 199, 504, 12899, 323, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 12899, 323, 14, 8512, 14, 2330, 492, 2435, 199, 504, 12899, 323, 492, 8985, 199, 504, 12899, 323, 492, 3778, 199, 504, 12899, 323, 14, 1246, 492, 2435, 465, 2986, 63, 1364, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 646, 63, 2992, 360, 11009, 297, 283, 14748, 323, 14, 1246, 297, 1572, 534, 1364, 26, 1246, 358, 421, 199, 318, 2446, 837, 272, 3778, 14, 739, 63, 888, 360, 14748, 323, 297, 984, 14, 3020, 9, 272, 2050, 14, 2758, 360, 14748, 323, 358, 339, 8985, 14, 826, 8, 3103, 9, 339, 28757, 275, 2435, 14, 9850, 8, 1246, 63, 1364, 14, 3167, 1062, 2892, 6392, 459, 1364, 26, 1246, 2278, 11009, 9, 272, 28757, 14, 2573, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 199, 3, 6529, 26, 1804, 73, 452, 10444, 1010, 17775, 665, 8810, 452, 32, 12025, 14, 957, 30, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 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, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 646, 984, 199, 504, 11258, 14, 888, 492, 4810, 199, 504, 12899, 323, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 12899, 323, 14, 8512, 14, 2330, 492, 2435, 199, 504, 12899, 323, 492, 8985, 199, 504, 12899, 323, 492, 3778, 199, 504, 12899, 323, 14, 1246, 492, 2435, 465, 2986, 63, 1364, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 646, 63, 2992, 360, 11009, 297, 283, 14748, 323, 14, 1246, 297, 1572, 534, 1364, 26, 1246, 358, 421, 199, 318, 2446, 837, 272, 3778, 14, 739, 63, 888, 360, 14748, 323, 297, 984, 14, 3020, 9, 272, 2050, 14, 2758, 360, 14748, 323, 358, 339, 8985, 14, 826, 8, 3103, 9, 339, 28757, 275, 2435, 14, 9850, 8, 1246, 63, 1364, 14, 3167, 1062, 2892, 6392, 459, 1364, 26, 1246, 2278, 11009, 9, 272, 28757, 14, 2573, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mambocab/python-driver
tests/integration/cqlengine/model/test_equality_operations.py
3
2190
# Copyright DataStax, 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 uuid import uuid4 from tests.integration.cqlengine.base import BaseCassEngTestCase from cassandra.cqlengine.management import sync_table from cassandra.cqlengine.management import drop_table from cassandra.cqlengine.models import Model from cassandra.cqlengine import columns class TestModel(Model): id = columns.UUID(primary_key=True, default=lambda:uuid4()) count = columns.Integer() text = columns.Text(required=False) class TestEqualityOperators(BaseCassEngTestCase): @classmethod def setUpClass(cls): super(TestEqualityOperators, cls).setUpClass() sync_table(TestModel) def setUp(self): super(TestEqualityOperators, self).setUp() self.t0 = TestModel.create(count=5, text='words') self.t1 = TestModel.create(count=5, text='words') @classmethod def tearDownClass(cls): super(TestEqualityOperators, cls).tearDownClass() drop_table(TestModel) def test_an_instance_evaluates_as_equal_to_itself(self): """ """ assert self.t0 == self.t0 def test_two_instances_referencing_the_same_rows_and_different_values_evaluate_not_equal(self): """ """ t0 = TestModel.get(id=self.t0.id) t0.text = 'bleh' assert t0 != self.t0 def test_two_instances_referencing_the_same_rows_and_values_evaluate_equal(self): """ """ t0 = TestModel.get(id=self.t0.id) assert t0 == self.t0 def test_two_instances_referencing_different_rows_evaluate_to_not_equal(self): """ """ assert self.t0 != self.t1
apache-2.0
[ 3, 1898, 3918, 3391, 88, 12, 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, 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, 504, 5377, 492, 5377, 20, 199, 504, 2295, 14, 15092, 14, 26853, 552, 2598, 14, 1095, 492, 3523, 35, 405, 16197, 1746, 199, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 8110, 492, 7604, 63, 1224, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 8110, 492, 5978, 63, 1224, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 992, 492, 5822, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 4362, 199, 199, 533, 1379, 1685, 8, 1685, 304, 339, 1305, 420, 275, 4362, 14, 8757, 8, 3327, 63, 498, 29, 549, 12, 849, 29, 2734, 26, 2580, 20, 1012, 272, 2338, 257, 275, 4362, 14, 2674, 342, 272, 1318, 259, 275, 4362, 14, 1872, 8, 2427, 29, 797, 9, 199, 199, 533, 1379, 22977, 3632, 2750, 8, 1563, 35, 405, 16197, 1746, 304, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 774, 22977, 3632, 2750, 12, 843, 680, 27777, 342, 267, 7604, 63, 1224, 8, 18282, 9, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 22977, 3632, 2750, 12, 291, 680, 5996, 342, 267, 291, 14, 84, 16, 275, 1379, 1685, 14, 981, 8, 835, 29, 21, 12, 1318, 534, 3148, 358, 267, 291, 14, 84, 17, 275, 1379, 1685, 14, 981, 8, 835, 29, 21, 12, 1318, 534, 3148, 358, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 1613, 8, 774, 22977, 3632, 2750, 12, 843, 680, 12336, 2543, 342, 267, 5978, 63, 1224, 8, 18282, 9, 339, 347, 511, 63, 290, 63, 842, 63, 2579, 85, 2335, 63, 305, 63, 1452, 63, 475, 63, 390, 277, 8, 277, 304, 267, 408, 267, 408, 267, 702, 291, 14, 84, 16, 508, 291, 14, 84, 16, 339, 347, 511, 63, 5601, 63, 5990, 63, 264, 21532, 63, 1589, 63, 7191, 63, 3838, 63, 460, 63, 14020, 63, 1459, 63, 7383, 63, 1397, 63, 1452, 8, 277, 304, 267, 408, 267, 408, 267, 307, 16, 275, 1379, 1685, 14, 362, 8, 344, 29, 277, 14, 84, 16, 14, 344, 9, 267, 307, 16, 14, 505, 275, 283, 830, 72, 7, 267, 702, 307, 16, 1137, 291, 14, 84, 16, 339, 347, 511, 63, 5601, 63, 5990, 63, 264, 21532, 63, 1589, 63, 7191, 63, 3838, 63, 460, 63, 1459, 63, 7383, 63, 1452, 8, 277, 304, 267, 408, 267, 408, 267, 307, 16, 275, 1379, 1685, 14, 362, 8, 344, 29, 277, 14, 84, 16, 14, 344, 9, 267, 702, 307, 16, 508, 291, 14, 84, 16, 339, 347, 511, 63, 5601, 63, 5990, 63, 264, 21532, 63, 14020, 63, 3838, 63, 7383, 63, 475, 63, 1397, 63, 1452, 8, 277, 304, 267, 408, 267, 408, 267, 702, 291, 14, 84, 16, 1137, 291, 14, 84, 17, 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 ]
[ 1898, 3918, 3391, 88, 12, 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, 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, 504, 5377, 492, 5377, 20, 199, 504, 2295, 14, 15092, 14, 26853, 552, 2598, 14, 1095, 492, 3523, 35, 405, 16197, 1746, 199, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 8110, 492, 7604, 63, 1224, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 8110, 492, 5978, 63, 1224, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 992, 492, 5822, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 4362, 199, 199, 533, 1379, 1685, 8, 1685, 304, 339, 1305, 420, 275, 4362, 14, 8757, 8, 3327, 63, 498, 29, 549, 12, 849, 29, 2734, 26, 2580, 20, 1012, 272, 2338, 257, 275, 4362, 14, 2674, 342, 272, 1318, 259, 275, 4362, 14, 1872, 8, 2427, 29, 797, 9, 199, 199, 533, 1379, 22977, 3632, 2750, 8, 1563, 35, 405, 16197, 1746, 304, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 774, 22977, 3632, 2750, 12, 843, 680, 27777, 342, 267, 7604, 63, 1224, 8, 18282, 9, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 22977, 3632, 2750, 12, 291, 680, 5996, 342, 267, 291, 14, 84, 16, 275, 1379, 1685, 14, 981, 8, 835, 29, 21, 12, 1318, 534, 3148, 358, 267, 291, 14, 84, 17, 275, 1379, 1685, 14, 981, 8, 835, 29, 21, 12, 1318, 534, 3148, 358, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 1613, 8, 774, 22977, 3632, 2750, 12, 843, 680, 12336, 2543, 342, 267, 5978, 63, 1224, 8, 18282, 9, 339, 347, 511, 63, 290, 63, 842, 63, 2579, 85, 2335, 63, 305, 63, 1452, 63, 475, 63, 390, 277, 8, 277, 304, 267, 408, 267, 408, 267, 702, 291, 14, 84, 16, 508, 291, 14, 84, 16, 339, 347, 511, 63, 5601, 63, 5990, 63, 264, 21532, 63, 1589, 63, 7191, 63, 3838, 63, 460, 63, 14020, 63, 1459, 63, 7383, 63, 1397, 63, 1452, 8, 277, 304, 267, 408, 267, 408, 267, 307, 16, 275, 1379, 1685, 14, 362, 8, 344, 29, 277, 14, 84, 16, 14, 344, 9, 267, 307, 16, 14, 505, 275, 283, 830, 72, 7, 267, 702, 307, 16, 1137, 291, 14, 84, 16, 339, 347, 511, 63, 5601, 63, 5990, 63, 264, 21532, 63, 1589, 63, 7191, 63, 3838, 63, 460, 63, 1459, 63, 7383, 63, 1452, 8, 277, 304, 267, 408, 267, 408, 267, 307, 16, 275, 1379, 1685, 14, 362, 8, 344, 29, 277, 14, 84, 16, 14, 344, 9, 267, 702, 307, 16, 508, 291, 14, 84, 16, 339, 347, 511, 63, 5601, 63, 5990, 63, 264, 21532, 63, 14020, 63, 3838, 63, 7383, 63, 475, 63, 1397, 63, 1452, 8, 277, 304, 267, 408, 267, 408, 267, 702, 291, 14, 84, 16, 1137, 291, 14, 84, 17, 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, 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,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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. # ============================================================================== # # Automatically update TensorFlow version in source files # # Usage: # ./tensorflow/tools/ci_build/update_version.py --version 1.4.0-rc1 # ./tensorflow/tools/ci_build/update_version.py --nightly # """Update version of TensorFlow script.""" # pylint: disable=superfluous-parens import argparse import fileinput import os import re import subprocess import time # File parameters TF_SRC_DIR = "tensorflow" VERSION_H = "%s/core/public/version.h" % TF_SRC_DIR SETUP_PY = "%s/tools/pip_package/setup.py" % TF_SRC_DIR README_MD = "./README.md" DEVEL_DOCKERFILE = "%s/tools/docker/Dockerfile.devel" % TF_SRC_DIR GPU_DEVEL_DOCKERFILE = "%s/tools/docker/Dockerfile.devel-gpu" % TF_SRC_DIR RELEVANT_FILES = [TF_SRC_DIR, VERSION_H, SETUP_PY, README_MD, DEVEL_DOCKERFILE, GPU_DEVEL_DOCKERFILE] # Version type parameters NIGHTLY_VERSION = 1 REGULAR_VERSION = 0 def replace_line(old_line, new_line, filename): """Replace a line in a file.""" for line in fileinput.input(filename, inplace=True): print(line.rstrip().replace(old_line, new_line)) def check_existence(filename): """Check the existence of file or dir.""" if not os.path.exists(filename): raise RuntimeError("%s not found. Are you under the TensorFlow source root" " directory?") def check_all_files(): """Check all relevant files necessary for upgrade.""" for file_name in RELEVANT_FILES: check_existence(file_name) def replace_with_sed(query, filename): """Replace with sed when regex is required.""" subprocess.check_call(['sed', '-i', '-r', '-e', query, filename]) class Version(object): """Version class object that stores SemVer version information.""" def __init__(self, major, minor, patch, identifier_string, version_type): """Constructor. Args: major: major string eg. (1) minor: minor string eg. (3) patch: patch string eg. (1) identifier_string: extension string eg. (-rc0) version_type: version parameter ((REGULAR|NIGHTLY)_VERSION) """ self.string = "%s.%s.%s%s" % (major, minor, patch, identifier_string) self.major = major self.minor = minor self.patch = patch self.identifier_string = identifier_string self.version_type = version_type def __str__(self): return self.string @property def pep_440_str(self): if self.version_type == REGULAR_VERSION: return_string = "%s.%s.%s%s" % (self.major, self.minor, self.patch, self.identifier_string) return return_string.replace("-", "") else: return_string = "%s.%s.%s" % (self.major, self.minor, self.identifier_string) return return_string.replace("-", "") @staticmethod def parse_from_string(string, version_type): """Returns version object from Semver string. Args: string: version string version_type: version parameter Raises: RuntimeError: If the version string is not valid. """ # Check validity of new version string if not re.search(r"[0-9]+\.[0-9]+\.[a-zA-Z0-9]+", string): raise RuntimeError("Invalid version string: %s" % string) major, minor, extension = string.split(".", 2) # Isolate patch and identifier string if identifier string exists extension_split = extension.split("-", 1) patch = extension_split[0] if len(extension_split) == 2: identifier_string = "-" + extension_split[1] else: identifier_string = "" return Version(major, minor, patch, identifier_string, version_type) def get_current_semver_version(): """Returns a Version object of current version. Returns: version: Version object of current SemVer string based on information from core/public/version.h """ # Get current version information version_file = open(VERSION_H, "r") for line in version_file: major_match = re.search("^#define TF_MAJOR_VERSION ([0-9]+)", line) minor_match = re.search("^#define TF_MINOR_VERSION ([0-9]+)", line) patch_match = re.search("^#define TF_PATCH_VERSION ([0-9]+)", line) extension_match = re.search("^#define TF_VERSION_SUFFIX \"(.*)\"", line) if major_match: old_major = major_match.group(1) if minor_match: old_minor = minor_match.group(1) if patch_match: old_patch_num = patch_match.group(1) if extension_match: old_extension = extension_match.group(1) break if "dev" in old_extension: version_type = NIGHTLY_VERSION else: version_type = REGULAR_VERSION return Version(old_major, old_minor, old_patch_num, old_extension, version_type) def update_version_h(old_version, new_version): """Update tensorflow/core/public/version.h.""" replace_line("#define TF_MAJOR_VERSION %s" % old_version.major, "#define TF_MAJOR_VERSION %s" % new_version.major, VERSION_H) replace_line("#define TF_MINOR_VERSION %s" % old_version.minor, "#define TF_MINOR_VERSION %s" % new_version.minor, VERSION_H) replace_line("#define TF_PATCH_VERSION %s" % old_version.patch, "#define TF_PATCH_VERSION %s" % new_version.patch, VERSION_H) replace_line("#define TF_VERSION_SUFFIX \"%s\"" % old_version.identifier_string, "#define TF_VERSION_SUFFIX \"%s\"" % new_version.identifier_string, VERSION_H) def update_setup_dot_py(old_version, new_version): """Update setup.py.""" replace_line("_VERSION = '%s'" % old_version.string, "_VERSION = '%s'" % new_version.string, SETUP_PY) def update_readme(old_version, new_version): """Update README.""" pep_440_str = new_version.pep_440_str replace_with_sed(r"s/%s\.%s\.([[:alnum:]]+)-/%s-/g" % (old_version.major, old_version.minor, pep_440_str), README_MD) def update_md_files(old_version, new_version): """Update the md doc files. Args: old_version: Version object of current version new_version: Version object of new version """ old_pep_version = old_version.pep_440_str new_pep_version = new_version.pep_440_str for filename in ["linux", "mac", "windows", "sources"]: filepath = "%s/docs_src/install/install_%s.md" % (TF_SRC_DIR, filename) replace_with_sed("s/tensorflow-%s/tensorflow-%s/g" % (old_pep_version, new_pep_version), filepath) replace_with_sed("s/tensorflow_gpu-%s/tensorflow_gpu-%s/g" % (old_pep_version, new_pep_version), filepath) replace_with_sed("s/TensorFlow %s/TensorFlow %s/g" % (old_pep_version, new_pep_version), filepath) for filename in ["java", "go", "c"]: filepath = "%s/docs_src/install/install_%s.md" % (TF_SRC_DIR, filename) replace_with_sed(r"s/x86_64-%s/x86_64-%s/g" % (old_version, new_version), filepath) replace_with_sed(r"s/libtensorflow-%s.jar/libtensorflow-%s.jar/g" % (old_version, new_version), filepath) replace_with_sed(r"s/<version>%s<\/version>/<version>%s<\/version>/g" % (old_version, new_version), filepath) def major_minor_change(old_version, new_version): """Check if a major or minor change occurred.""" major_mismatch = old_version.major != new_version.major minor_mismatch = old_version.minor != new_version.minor if major_mismatch or minor_mismatch: return True return False def update_dockerfiles(old_version, new_version): """Update dockerfiles if there was a major change.""" if major_minor_change(old_version, new_version): old_r_major_minor = r"r%s\.%s" % (old_version.major, old_version.minor) old_r_major_minor_string = old_r_major_minor.replace("\\", "") r_major_minor = r"r%s\.%s" % (new_version.major, new_version.minor) r_major_minor_string = r_major_minor.replace("\\", "") print("Detected Major.Minor change.") print("Updating pattern %s to %s in additional files" % (old_r_major_minor_string, r_major_minor_string)) # Update dockerfiles replace_with_sed("s/%s/%s/g" % (old_r_major_minor, r_major_minor), DEVEL_DOCKERFILE) replace_with_sed("s/%s/%s/g" % (old_r_major_minor, r_major_minor), GPU_DEVEL_DOCKERFILE) def check_for_lingering_string(lingering_string): """Check for given lingering strings.""" formatted_string = lingering_string.replace(".", r"\.") try: linger_str_output = subprocess.check_output( ["grep", "-rnoH", formatted_string, TF_SRC_DIR]) linger_strs = linger_str_output.decode("utf8").split("\n") except subprocess.CalledProcessError: linger_strs = [] if linger_strs: print("WARNING: Below are potentially instances of lingering old version " "string \"%s\" in source directory \"%s/\" that are not " "updated by this script. Please check them manually!" % (lingering_string, TF_SRC_DIR)) for linger_str in linger_strs: print(linger_str) else: print("No lingering old version strings \"%s\" found in source directory" " \"%s/\". Good." % (lingering_string, TF_SRC_DIR)) def check_for_old_version(old_version, new_version): """Check for old version references.""" for old_ver in [old_version.string, old_version.pep_440_str]: check_for_lingering_string(old_ver) if major_minor_change(old_version, new_version): old_r_major_minor = "r%s.%s" % (old_version.major, old_version.minor) check_for_lingering_string(old_r_major_minor) def main(): """This script updates all instances of version in the tensorflow directory. Requirements: version: The version tag OR nightly: Create a nightly tag with current date Raises: RuntimeError: If the script is not being run from tf source dir """ parser = argparse.ArgumentParser(description="Cherry picking automation.") group = parser.add_mutually_exclusive_group(required=True) # Arg information group.add_argument("--version", help="<new_major_ver>.<new_minor_ver>.<new_patch_ver>", default="") group.add_argument("--nightly", help="disable the service provisioning step", action="store_true") args = parser.parse_args() check_all_files() old_version = get_current_semver_version() if args.nightly: # dev minor version is one ahead of official nightly_minor_ver = int(old_version.minor) + 1 new_version = Version(old_version.major, str(nightly_minor_ver), old_version.patch, "-dev" + time.strftime("%Y%m%d"), NIGHTLY_VERSION) else: new_version = Version.parse_from_string(args.version, REGULAR_VERSION) update_version_h(old_version, new_version) update_setup_dot_py(old_version, new_version) update_readme(old_version, new_version) update_md_files(old_version, new_version) update_dockerfiles(old_version, new_version) # Print transition details print("Major: %s -> %s" % (old_version.major, new_version.major)) print("Minor: %s -> %s" % (old_version.minor, new_version.minor)) print("Patch: %s -> %s\n" % (old_version.patch, new_version.patch)) check_for_old_version(old_version, new_version) if __name__ == "__main__": main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 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, 3, 199, 3, 9195, 17174, 1678, 9134, 1015, 315, 1350, 1584, 199, 3, 199, 3, 11028, 26, 199, 3, 3698, 16605, 16008, 15, 2537, 15, 559, 63, 1506, 15, 873, 63, 1023, 14, 647, 1553, 1023, 413, 14, 20, 14, 16, 13, 1195, 17, 199, 3, 3698, 16605, 16008, 15, 2537, 15, 559, 63, 1506, 15, 873, 63, 1023, 14, 647, 1553, 14873, 590, 199, 3, 199, 624, 4152, 1015, 402, 9134, 2884, 1041, 199, 199, 3, 4287, 26, 3507, 29, 4792, 2327, 7514, 13, 31910, 199, 199, 646, 7534, 199, 646, 570, 1210, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 900, 199, 199, 3, 3814, 2633, 199, 6145, 63, 12447, 63, 3022, 275, 298, 16008, 2, 199, 4612, 63, 40, 275, 2071, 83, 15, 1018, 15, 3455, 15, 1023, 14, 72, 2, 450, 21721, 63, 12447, 63, 3022, 199, 20836, 63, 4521, 275, 2071, 83, 15, 2537, 15, 9983, 63, 2491, 15, 2758, 14, 647, 2, 450, 21721, 63, 12447, 63, 3022, 199, 18195, 63, 5127, 275, 26069, 18195, 14, 1064, 2, 199, 1093, 10429, 63, 29953, 3817, 275, 2071, 83, 15, 2537, 15, 9991, 15, 31463, 493, 14, 27870, 2, 450, 21721, 63, 12447, 63, 3022, 199, 20769, 63, 1093, 10429, 63, 29953, 3817, 275, 2071, 83, 15, 2537, 15, 9991, 15, 31463, 493, 14, 27870, 13, 6477, 2, 450, 21721, 63, 12447, 63, 3022, 199, 907, 906, 54, 1441, 63, 9472, 275, 359, 6145, 63, 12447, 63, 3022, 12, 2116, 15945, 63, 40, 12, 2116, 11543, 2160, 63, 4521, 12, 2116, 27781, 63, 5127, 12, 2116, 3265, 10429, 63, 29953, 3817, 12, 2116, 18613, 63, 1093, 10429, 63, 29953, 3817, 61, 199, 199, 3, 3394, 730, 2633, 199, 46, 2830, 6084, 63, 4612, 275, 413, 199, 5616, 3038, 63, 4612, 275, 378, 421, 199, 318, 3350, 63, 604, 8, 1753, 63, 604, 12, 892, 63, 604, 12, 1788, 304, 523, 408, 11328, 282, 1004, 315, 282, 570, 1041, 523, 367, 1004, 315, 570, 1210, 14, 1210, 8, 1501, 12, 16304, 29, 549, 304, 272, 870, 8, 604, 14, 6735, 1252, 1814, 8, 1753, 63, 604, 12, 892, 63, 604, 430, 421, 199, 318, 1104, 63, 476, 18586, 8, 1501, 304, 523, 408, 1799, 314, 23780, 402, 570, 503, 2935, 1041, 523, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 272, 746, 6064, 3647, 83, 440, 1911, 14, 23889, 1265, 1334, 314, 9134, 1350, 1738, 2, 2432, 298, 2082, 18582, 421, 199, 318, 1104, 63, 452, 63, 1725, 837, 523, 408, 1799, 1006, 12082, 1584, 5784, 367, 10754, 1041, 523, 367, 570, 63, 354, 315, 5363, 906, 54, 1441, 63, 9472, 26, 272, 1104, 63, 476, 18586, 8, 493, 63, 354, 9, 421, 199, 318, 3350, 63, 1045, 63, 939, 8, 1131, 12, 1788, 304, 523, 408, 11328, 543, 542, 68, 1380, 5163, 365, 1415, 1041, 523, 3873, 14, 1074, 63, 1250, 2941, 939, 297, 2475, 73, 297, 2475, 82, 297, 2475, 69, 297, 1827, 12, 1788, 566, 421, 199, 533, 3394, 8, 785, 304, 523, 408, 3353, 1021, 909, 626, 14086, 3240, 77, 3673, 1015, 2556, 1041, 819, 347, 636, 826, 721, 277, 12, 12160, 12, 12612, 12, 3371, 12, 5148, 63, 875, 12, 1015, 63, 466, 304, 272, 408, 11447, 14, 339, 3033, 26, 489, 12160, 26, 12160, 1059, 11837, 14, 334, 17, 9, 489, 12612, 26, 12612, 1059, 11837, 14, 334, 19, 9, 489, 3371, 26, 3371, 1059, 11837, 14, 334, 17, 9, 489, 5148, 63, 875, 26, 3329, 1059, 11837, 14, 5868, 1195, 16, 9, 489, 1015, 63, 466, 26, 1015, 2725, 3666, 5616, 3038, 92, 46, 2830, 6084, 9, 63, 4612, 9, 272, 408, 272, 291, 14, 875, 275, 2071, 83, 4111, 83, 4111, 83, 5, 83, 2, 450, 334, 8452, 12, 3303, 12612, 12, 3303, 3371, 12, 3303, 5148, 63, 875, 9, 272, 291, 14, 8452, 275, 12160, 272, 291, 14, 11067, 275, 12612, 272, 291, 14, 2068, 275, 3371, 272, 291, 14, 5364, 63, 875, 275, 5148, 63, 875, 272, 291, 14, 1023, 63, 466, 275, 1015, 63, 466, 819, 347, 636, 495, 721, 277, 304, 272, 372, 291, 14, 875, 819, 768, 1829, 523, 347, 22602, 63, 14162, 63, 495, 8, 277, 304, 272, 340, 291, 14, 1023, 63, 466, 508, 14142, 3038, 63, 4612, 26, 489, 372, 63, 875, 275, 2071, 83, 4111, 83, 4111, 83, 5, 83, 2, 450, 334, 277, 14, 8452, 12, 4228, 291, 14, 11067, 12, 4228, 291, 14, 2068, 12, 4228, 291, 14, 5364, 63, 875, 9, 489, 372, 372, 63, 875, 14, 1814, 6096, 401, 6899, 272, 587, 26, 489, 372, 63, 875, 275, 2071, 83, 4111, 83, 4111, 83, 2, 450, 334, 277, 14, 8452, 12, 2511, 291, 14, 11067, 12, 2511, 291, 14, 5364, 63, 875, 9, 489, 372, 372, 63, 875, 14, 1814, 6096, 401, 6899, 819, 768, 4639, 523, 347, 2198, 63, 504, 63, 875, 8, 875, 12, 1015, 63, 466, 304, 272, 408, 3407, 1015, 909, 687, 3240, 77, 422, 1059, 14, 339, 3033, 26, 489, 1059, 26, 1015, 1059, 489, 1015, 63, 466, 26, 1015, 2725, 339, 6218, 26, 489, 6064, 26, 982, 314, 1015, 1059, 365, 440, 1686, 14, 272, 408, 272, 327, 2670, 25667, 402, 892, 1015, 1059, 272, 340 ]
[ 2647, 15, 1393, 15, 1548, 199, 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, 3, 199, 3, 9195, 17174, 1678, 9134, 1015, 315, 1350, 1584, 199, 3, 199, 3, 11028, 26, 199, 3, 3698, 16605, 16008, 15, 2537, 15, 559, 63, 1506, 15, 873, 63, 1023, 14, 647, 1553, 1023, 413, 14, 20, 14, 16, 13, 1195, 17, 199, 3, 3698, 16605, 16008, 15, 2537, 15, 559, 63, 1506, 15, 873, 63, 1023, 14, 647, 1553, 14873, 590, 199, 3, 199, 624, 4152, 1015, 402, 9134, 2884, 1041, 199, 199, 3, 4287, 26, 3507, 29, 4792, 2327, 7514, 13, 31910, 199, 199, 646, 7534, 199, 646, 570, 1210, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 646, 900, 199, 199, 3, 3814, 2633, 199, 6145, 63, 12447, 63, 3022, 275, 298, 16008, 2, 199, 4612, 63, 40, 275, 2071, 83, 15, 1018, 15, 3455, 15, 1023, 14, 72, 2, 450, 21721, 63, 12447, 63, 3022, 199, 20836, 63, 4521, 275, 2071, 83, 15, 2537, 15, 9983, 63, 2491, 15, 2758, 14, 647, 2, 450, 21721, 63, 12447, 63, 3022, 199, 18195, 63, 5127, 275, 26069, 18195, 14, 1064, 2, 199, 1093, 10429, 63, 29953, 3817, 275, 2071, 83, 15, 2537, 15, 9991, 15, 31463, 493, 14, 27870, 2, 450, 21721, 63, 12447, 63, 3022, 199, 20769, 63, 1093, 10429, 63, 29953, 3817, 275, 2071, 83, 15, 2537, 15, 9991, 15, 31463, 493, 14, 27870, 13, 6477, 2, 450, 21721, 63, 12447, 63, 3022, 199, 907, 906, 54, 1441, 63, 9472, 275, 359, 6145, 63, 12447, 63, 3022, 12, 2116, 15945, 63, 40, 12, 2116, 11543, 2160, 63, 4521, 12, 2116, 27781, 63, 5127, 12, 2116, 3265, 10429, 63, 29953, 3817, 12, 2116, 18613, 63, 1093, 10429, 63, 29953, 3817, 61, 199, 199, 3, 3394, 730, 2633, 199, 46, 2830, 6084, 63, 4612, 275, 413, 199, 5616, 3038, 63, 4612, 275, 378, 421, 199, 318, 3350, 63, 604, 8, 1753, 63, 604, 12, 892, 63, 604, 12, 1788, 304, 523, 408, 11328, 282, 1004, 315, 282, 570, 1041, 523, 367, 1004, 315, 570, 1210, 14, 1210, 8, 1501, 12, 16304, 29, 549, 304, 272, 870, 8, 604, 14, 6735, 1252, 1814, 8, 1753, 63, 604, 12, 892, 63, 604, 430, 421, 199, 318, 1104, 63, 476, 18586, 8, 1501, 304, 523, 408, 1799, 314, 23780, 402, 570, 503, 2935, 1041, 523, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 272, 746, 6064, 3647, 83, 440, 1911, 14, 23889, 1265, 1334, 314, 9134, 1350, 1738, 2, 2432, 298, 2082, 18582, 421, 199, 318, 1104, 63, 452, 63, 1725, 837, 523, 408, 1799, 1006, 12082, 1584, 5784, 367, 10754, 1041, 523, 367, 570, 63, 354, 315, 5363, 906, 54, 1441, 63, 9472, 26, 272, 1104, 63, 476, 18586, 8, 493, 63, 354, 9, 421, 199, 318, 3350, 63, 1045, 63, 939, 8, 1131, 12, 1788, 304, 523, 408, 11328, 543, 542, 68, 1380, 5163, 365, 1415, 1041, 523, 3873, 14, 1074, 63, 1250, 2941, 939, 297, 2475, 73, 297, 2475, 82, 297, 2475, 69, 297, 1827, 12, 1788, 566, 421, 199, 533, 3394, 8, 785, 304, 523, 408, 3353, 1021, 909, 626, 14086, 3240, 77, 3673, 1015, 2556, 1041, 819, 347, 636, 826, 721, 277, 12, 12160, 12, 12612, 12, 3371, 12, 5148, 63, 875, 12, 1015, 63, 466, 304, 272, 408, 11447, 14, 339, 3033, 26, 489, 12160, 26, 12160, 1059, 11837, 14, 334, 17, 9, 489, 12612, 26, 12612, 1059, 11837, 14, 334, 19, 9, 489, 3371, 26, 3371, 1059, 11837, 14, 334, 17, 9, 489, 5148, 63, 875, 26, 3329, 1059, 11837, 14, 5868, 1195, 16, 9, 489, 1015, 63, 466, 26, 1015, 2725, 3666, 5616, 3038, 92, 46, 2830, 6084, 9, 63, 4612, 9, 272, 408, 272, 291, 14, 875, 275, 2071, 83, 4111, 83, 4111, 83, 5, 83, 2, 450, 334, 8452, 12, 3303, 12612, 12, 3303, 3371, 12, 3303, 5148, 63, 875, 9, 272, 291, 14, 8452, 275, 12160, 272, 291, 14, 11067, 275, 12612, 272, 291, 14, 2068, 275, 3371, 272, 291, 14, 5364, 63, 875, 275, 5148, 63, 875, 272, 291, 14, 1023, 63, 466, 275, 1015, 63, 466, 819, 347, 636, 495, 721, 277, 304, 272, 372, 291, 14, 875, 819, 768, 1829, 523, 347, 22602, 63, 14162, 63, 495, 8, 277, 304, 272, 340, 291, 14, 1023, 63, 466, 508, 14142, 3038, 63, 4612, 26, 489, 372, 63, 875, 275, 2071, 83, 4111, 83, 4111, 83, 5, 83, 2, 450, 334, 277, 14, 8452, 12, 4228, 291, 14, 11067, 12, 4228, 291, 14, 2068, 12, 4228, 291, 14, 5364, 63, 875, 9, 489, 372, 372, 63, 875, 14, 1814, 6096, 401, 6899, 272, 587, 26, 489, 372, 63, 875, 275, 2071, 83, 4111, 83, 4111, 83, 2, 450, 334, 277, 14, 8452, 12, 2511, 291, 14, 11067, 12, 2511, 291, 14, 5364, 63, 875, 9, 489, 372, 372, 63, 875, 14, 1814, 6096, 401, 6899, 819, 768, 4639, 523, 347, 2198, 63, 504, 63, 875, 8, 875, 12, 1015, 63, 466, 304, 272, 408, 3407, 1015, 909, 687, 3240, 77, 422, 1059, 14, 339, 3033, 26, 489, 1059, 26, 1015, 1059, 489, 1015, 63, 466, 26, 1015, 2725, 339, 6218, 26, 489, 6064, 26, 982, 314, 1015, 1059, 365, 440, 1686, 14, 272, 408, 272, 327, 2670, 25667, 402, 892, 1015, 1059, 272, 340, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1,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ib/minify.py
3
7510
#!/usr/bin/env python # -*- coding: utf-8 -*- # vim: sw=4 ts=4 fenc=utf-8 """Minification helpers. This module provides enhanced versions of the ``javascript_link`` and ``stylesheet_link`` helpers in ``webhelpers.html.tags``. These versions add three additional arguments: * **minified**: If true, reduce the file size by squeezing out whitespace and other characters insignificant to the Javascript or CSS syntax. * **combined**: If true, concatenate the specified files into one file to reduce page load time. * **beaker_kwargs** (dict): arguments to pass to ``beaker_cache``. Dependencies: ``Pylons``, ``Beaker``, ``jsmin``, and ``cssutils`` (all available in PyPI). If "jsmin" is not installed, the helper issues a warning and passes Javascript through unchanged. (Changed in WebHelpers 1.1: removed built-in "_jsmin" package due to licensing issues; details in webhelpers/pylonslib/_jsmin.py .) PYRAMID USERS: this implementation is incompatible with Pyramid. No Pyramid-compatible implementation is currently known. Contributed by Pedro Algarvio and Domen Kozar <ufs@ufsoft.org>. URL: http://docs.fubar.si/minwebhelpers/ """ import re import os import logging import StringIO import warnings from webhelpers.html.tags import javascript_link as __javascript_link from webhelpers.html.tags import stylesheet_link as __stylesheet_link try: from jsmin import JavascriptMinify except ImportError: class JavascriptMinify(object): def minify(self, instream, outstream): warnings.warn(JSMIN_MISSING_MESSAGE, UserWarning) data = instream.read() outstream.write(data) instream.close() JSMIN_MISSING_MESSAGE = """\ _jsmin has been removed from WebHelpers due to licensing issues Your Javascript code has been passed through unchanged. You can install the "jsmin" package from PyPI, and this helper will use it. """ __all__ = ['javascript_link', 'stylesheet_link'] log = logging.getLogger(__name__) beaker_kwargs = dict(key='sources', expire='never', type='memory') def combine_sources(sources, ext, fs_root): if len(sources) < 2: return sources names = list() js_buffer = StringIO.StringIO() base = os.path.commonprefix([os.path.dirname(s) for s in sources]) for source in sources: # get a list of all filenames without extensions js_file = os.path.basename(source) js_file_name = os.path.splitext(js_file)[0] names.append(js_file_name) # build a master file with all contents full_source = os.path.join(fs_root, source.lstrip('/')) f = open(full_source, 'r') js_buffer.write(f.read()) js_buffer.write('\n') f.close() # glue a new name and generate path to it fname = '.'.join(names + ['COMBINED', ext]) fpath = os.path.join(fs_root, base.strip('/'), fname) # write the combined file f = open(fpath, 'w') f.write(js_buffer.getvalue()) f.close() return [os.path.join(base, fname)] def minify_sources(sources, ext, fs_root=''): import cssutils if 'js' in ext: js_minify = JavascriptMinify() minified_sources = [] for source in sources: # generate full path to source no_ext_source = os.path.splitext(source)[0] full_source = os.path.join(fs_root, (no_ext_source + ext).lstrip('/')) # generate minified source path full_source = os.path.join(fs_root, (source).lstrip('/')) no_ext_full_source = os.path.splitext(full_source)[0] minified = no_ext_full_source + ext f_minified_source = open(minified, 'w') # minify js source (read stream is auto-closed inside) if 'js' in ext: js_minify.minify(open(full_source, 'r'), f_minified_source) # minify css source if 'css' in ext: serializer = get_serializer() sheet = cssutils.parseFile(full_source) sheet.setSerializer(serializer) cssutils.ser.prefs.useMinified() f_minified_source.write(sheet.cssText) f_minified_source.close() minified_sources.append(no_ext_source + ext) return minified_sources def base_link(ext, *sources, **options): from pylons import config from pylons.decorators.cache import beaker_cache combined = options.pop('combined', False) minified = options.pop('minified', False) beaker_options = options.pop('beaker_kwargs', False) fs_root = config.get('pylons.paths').get('static_files') if not (config.get('debug', False) or options.get('builtins', False)): if beaker_options: beaker_kwargs.update(beaker_options) if combined: sources = beaker_cache(**beaker_kwargs)(combine_sources)(list(sources), ext, fs_root) if minified: sources = beaker_cache(**beaker_kwargs)(minify_sources)(list(sources), '.min.' + ext, fs_root) if 'js' in ext: return __javascript_link(*sources, **options) if 'css' in ext: return __stylesheet_link(*sources, **options) def javascript_link(*sources, **options): return base_link('js', *sources, **options) def stylesheet_link(*sources, **options): return base_link('css', *sources, **options) _serializer_class = None def get_serializer(): # This is in a function to prevent a global import of ``cssutils``, # which is not a WebHelpers dependency. # The class is cached in a global variable so that it will be # compiled only once. import cssutils global _serializer_class if not _serializer_class: class CSSUtilsMinificationSerializer(cssutils.CSSSerializer): def __init__(self, prefs=None): cssutils.CSSSerializer.__init__(self, prefs) def do_css_CSSStyleDeclaration(self, style, separator=None): try: color = style.getPropertyValue('color') if color and color is not u'': color = self.change_colors(color) style.setProperty('color', color) except: pass return re.sub(r'0\.([\d])+', r'.\1', re.sub(r'(([^\d][0])+(px|em)+)+', r'\2', cssutils.CSSSerializer.do_css_CSSStyleDeclaration( self, style, separator))) def change_colors(self, color): colours = { 'black': '#000000', 'fuchia': '#ff00ff', 'yellow': '#ffff00', '#808080': 'gray', '#008000': 'green', '#800000': 'maroon', '#000800': 'navy', '#808000': 'olive', '#800080': 'purple', '#ff0000': 'red', '#c0c0c0': 'silver', '#008080': 'teal' } if color.lower() in colours: color = colours[color.lower()] if color.startswith('#') and len(color) == 7: if color[1]==color[2] and color[3]==color[4] and color[5]==color[6]: color = '#%s%s%s' % (color[1], color[3], color[5]) return color # End of class CSSUtilsMinificationSerializer _serializer_class = CSSUtilsMinificationSerializer return _serializer_class()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 6695, 26, 5584, 29, 20, 6714, 29, 20, 289, 10945, 29, 1624, 13, 24, 199, 624, 4649, 7313, 10897, 14, 199, 199, 2765, 859, 6571, 655, 24384, 5459, 402, 314, 1124, 9554, 63, 1073, 1040, 436, 199, 1040, 15479, 63, 1073, 1040, 10897, 315, 1124, 2520, 7546, 14, 1360, 14, 2969, 4345, 221, 5723, 5459, 1050, 199, 10480, 4722, 2368, 26, 199, 199, 10, 1011, 827, 4541, 26742, 982, 2549, 12, 7114, 314, 570, 1568, 701, 308, 12221, 20135, 734, 523, 8139, 436, 1163, 4110, 315, 1037, 14266, 370, 314, 31861, 503, 15750, 6302, 14, 199, 10, 1011, 17583, 26742, 982, 2549, 12, 24788, 314, 2013, 1584, 1901, 1373, 570, 370, 523, 7114, 2034, 2248, 900, 14, 199, 10, 1011, 1235, 12630, 63, 958, 538, 334, 807, 304, 2368, 370, 986, 370, 1124, 1235, 12630, 63, 1637, 4345, 199, 199, 11927, 26, 1124, 2713, 76, 4654, 4542, 1124, 3655, 12630, 4542, 1124, 3596, 827, 4542, 436, 1124, 3919, 1208, 1040, 334, 452, 199, 4561, 315, 24330, 680, 982, 298, 3596, 827, 2, 365, 440, 4903, 12, 314, 5922, 10876, 282, 5721, 199, 460, 14933, 31861, 4012, 14874, 14, 334, 6970, 315, 6001, 4433, 83, 413, 14, 17, 26, 4829, 199, 11730, 13, 262, 2668, 3596, 827, 2, 2559, 7037, 370, 32572, 10876, 27, 2436, 315, 221, 199, 2520, 7546, 15, 647, 76, 4654, 773, 15607, 3596, 827, 14, 647, 1275, 9, 199, 199, 48, 3763, 1156, 998, 13044, 51, 26, 642, 4514, 365, 18457, 543, 1611, 20785, 14, 3091, 199, 2713, 20785, 13, 6490, 4514, 365, 5544, 6040, 14, 199, 199, 714, 24855, 701, 510, 379, 293, 4580, 23909, 32052, 436, 577, 1377, 78, 1804, 26051, 285, 665, 1286, 83, 32, 1286, 4617, 14, 1308, 10827, 199, 2632, 26, 1455, 921, 4757, 14, 70, 23863, 14, 338, 15, 827, 2520, 7546, 15, 199, 624, 199, 199, 646, 295, 199, 646, 747, 199, 646, 2050, 199, 646, 5228, 199, 646, 3598, 199, 199, 504, 3330, 7546, 14, 1360, 14, 2969, 492, 18910, 63, 1073, 465, 636, 9554, 63, 1073, 199, 504, 3330, 7546, 14, 1360, 14, 2969, 492, 3449, 5069, 63, 1073, 465, 636, 15479, 63, 1073, 199, 199, 893, 26, 272, 687, 8586, 827, 492, 31861, 4649, 2021, 199, 2590, 3545, 26, 272, 1021, 31861, 4649, 2021, 8, 785, 304, 267, 347, 1748, 2021, 8, 277, 12, 315, 1745, 12, 734, 1745, 304, 288, 3598, 14, 4050, 8, 42, 4029, 568, 63, 18701, 63, 8272, 12, 2876, 3849, 9, 288, 666, 275, 315, 1745, 14, 739, 342, 288, 734, 1745, 14, 952, 8, 576, 9, 288, 315, 1745, 14, 1600, 342, 199, 199, 42, 4029, 568, 63, 18701, 63, 8272, 275, 9638, 199, 63, 3596, 827, 965, 2757, 4829, 687, 6001, 4433, 83, 7037, 370, 32572, 10876, 199, 14398, 31861, 1233, 965, 2757, 3032, 4012, 14874, 14, 199, 5556, 883, 3907, 314, 298, 3596, 827, 2, 2559, 687, 24330, 12, 436, 642, 5922, 911, 675, 652, 14, 199, 624, 421, 199, 363, 452, 363, 275, 788, 9554, 63, 1073, 297, 283, 15479, 63, 1073, 418, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 1235, 12630, 63, 958, 275, 1211, 8, 498, 534, 4553, 297, 2151, 16667, 534, 18178, 297, 2151, 730, 534, 4844, 358, 199, 199, 318, 13323, 63, 4553, 8, 4553, 12, 1599, 12, 7449, 63, 1231, 304, 272, 340, 822, 8, 4553, 9, 665, 499, 26, 267, 372, 5274, 339, 1561, 275, 769, 342, 272, 8586, 63, 2738, 275, 5228, 14, 6424, 342, 272, 1300, 275, 747, 14, 515, 14, 2330, 1861, 779, 736, 14, 515, 14, 3475, 8, 83, 9, 367, 308, 315, 5274, 566, 339, 367, 1350, 315, 5274, 26, 267, 327, 664, 282, 769, 402, 1006, 6203, 1928, 5478, 267, 8586, 63, 493, 275, 747, 14, 515, 14, 4846, 8, 1365, 9, 267, 8586, 63, 493, 63, 354, 275, 747, 14, 515, 14, 7973, 8, 3596, 63, 493, 2788, 16, 61, 267, 1561, 14, 740, 8, 3596, 63, 493, 63, 354, 9, 398, 327, 1900, 282, 5288, 570, 543, 1006, 4072, 267, 2615, 63, 1365, 275, 747, 14, 515, 14, 904, 8, 2319, 63, 1231, 12, 1350, 14, 10124, 28684, 267, 289, 275, 1551, 8, 2861, 63, 1365, 12, 283, 82, 358, 267, 8586, 63, 2738, 14, 952, 8, 70, 14, 739, 1012, 267, 8586, 63, 2738, 14, 952, 2258, 78, 358, 267, 289, 14, 1600, 342, 339, 327, 6482, 310, 282, 892, 536, 436, 3550, 931, 370, 652, 272, 6748, 275, 15671, 904, 8, 1247, 435, 788, 1439, 4567, 568, 1149, 297, 1599, 566, 272, 30540, 275, 747, 14, 515, 14, 904, 8, 2319, 63, 1231, 12, 1300, 14, 1913, 2336, 659, 6748, 9, 339, 327, 2218, 314, 12149, 570, 272, 289, 275, 1551, 8, 23248, 12, 283, 87, 358, 272, 289, 14, 952, 8, 3596, 63, 2738, 14, 7150, 1012, 272, 289, 14, 1600, 342, 339, 372, 359, 736, 14, 515, 14, 904, 8, 1095, 12, 6748, 1874, 199, 199, 318, 1748, 2021, 63, 4553, 8, 4553, 12, 1599, 12, 7449, 63, 1231, 9280, 272, 492, 11431, 1208, 18407, 340, 283, 3596, 7, 315, 1599, 26, 267, 8586, 63, 827, 2021, 275, 31861, 4649, 2021, 342, 272, 1748, 4541, 63, 4553, 275, 942, 339, 367, 1350, 315, 5274, 26, 267, 327, 3550, 2615, 931, 370, 1350, 267, 949, 63, 832, 63, 1365, 275, 747, 14, 515, 14, 7973, 8, 1365, 2788, 16, 61, 267, 2615, 63, 1365, 275, 747, 14, 515, 14, 904, 8, 2319, 63, 1231, 12, 334, 889, 63, 832, 63, 1365, 435, 1599, 680, 10124, 28684, 398, 327, 3550, 1748, 4541, 1350, 931, 267, 2615, 63, 1365, 275, 747, 14, 515, 14, 904, 8, 2319, 63, 1231, 12, 334, 1365, 680, 10124, 28684, 267, 949, 63, 832, 63, 2861, 63, 1365, 275, 747, 14, 515, 14, 7973, 8, 2861, 63, 1365, 2788, 16, 61, 267, 1748, 4541, 275, 949, 63, 832, 63, 2861, 63, 1365, 435, 1599, 398, 289, 63, 827, 4541, 63, 1365, 275, 1551, 8, 827, 4541, 12, 283, 87, 358, 398, 327, 1748, 2021, 8586, 1350, 334, 739, 2547, 365, 2599 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 6695, 26, 5584, 29, 20, 6714, 29, 20, 289, 10945, 29, 1624, 13, 24, 199, 624, 4649, 7313, 10897, 14, 199, 199, 2765, 859, 6571, 655, 24384, 5459, 402, 314, 1124, 9554, 63, 1073, 1040, 436, 199, 1040, 15479, 63, 1073, 1040, 10897, 315, 1124, 2520, 7546, 14, 1360, 14, 2969, 4345, 221, 5723, 5459, 1050, 199, 10480, 4722, 2368, 26, 199, 199, 10, 1011, 827, 4541, 26742, 982, 2549, 12, 7114, 314, 570, 1568, 701, 308, 12221, 20135, 734, 523, 8139, 436, 1163, 4110, 315, 1037, 14266, 370, 314, 31861, 503, 15750, 6302, 14, 199, 10, 1011, 17583, 26742, 982, 2549, 12, 24788, 314, 2013, 1584, 1901, 1373, 570, 370, 523, 7114, 2034, 2248, 900, 14, 199, 10, 1011, 1235, 12630, 63, 958, 538, 334, 807, 304, 2368, 370, 986, 370, 1124, 1235, 12630, 63, 1637, 4345, 199, 199, 11927, 26, 1124, 2713, 76, 4654, 4542, 1124, 3655, 12630, 4542, 1124, 3596, 827, 4542, 436, 1124, 3919, 1208, 1040, 334, 452, 199, 4561, 315, 24330, 680, 982, 298, 3596, 827, 2, 365, 440, 4903, 12, 314, 5922, 10876, 282, 5721, 199, 460, 14933, 31861, 4012, 14874, 14, 334, 6970, 315, 6001, 4433, 83, 413, 14, 17, 26, 4829, 199, 11730, 13, 262, 2668, 3596, 827, 2, 2559, 7037, 370, 32572, 10876, 27, 2436, 315, 221, 199, 2520, 7546, 15, 647, 76, 4654, 773, 15607, 3596, 827, 14, 647, 1275, 9, 199, 199, 48, 3763, 1156, 998, 13044, 51, 26, 642, 4514, 365, 18457, 543, 1611, 20785, 14, 3091, 199, 2713, 20785, 13, 6490, 4514, 365, 5544, 6040, 14, 199, 199, 714, 24855, 701, 510, 379, 293, 4580, 23909, 32052, 436, 577, 1377, 78, 1804, 26051, 285, 665, 1286, 83, 32, 1286, 4617, 14, 1308, 10827, 199, 2632, 26, 1455, 921, 4757, 14, 70, 23863, 14, 338, 15, 827, 2520, 7546, 15, 199, 624, 199, 199, 646, 295, 199, 646, 747, 199, 646, 2050, 199, 646, 5228, 199, 646, 3598, 199, 199, 504, 3330, 7546, 14, 1360, 14, 2969, 492, 18910, 63, 1073, 465, 636, 9554, 63, 1073, 199, 504, 3330, 7546, 14, 1360, 14, 2969, 492, 3449, 5069, 63, 1073, 465, 636, 15479, 63, 1073, 199, 199, 893, 26, 272, 687, 8586, 827, 492, 31861, 4649, 2021, 199, 2590, 3545, 26, 272, 1021, 31861, 4649, 2021, 8, 785, 304, 267, 347, 1748, 2021, 8, 277, 12, 315, 1745, 12, 734, 1745, 304, 288, 3598, 14, 4050, 8, 42, 4029, 568, 63, 18701, 63, 8272, 12, 2876, 3849, 9, 288, 666, 275, 315, 1745, 14, 739, 342, 288, 734, 1745, 14, 952, 8, 576, 9, 288, 315, 1745, 14, 1600, 342, 199, 199, 42, 4029, 568, 63, 18701, 63, 8272, 275, 9638, 199, 63, 3596, 827, 965, 2757, 4829, 687, 6001, 4433, 83, 7037, 370, 32572, 10876, 199, 14398, 31861, 1233, 965, 2757, 3032, 4012, 14874, 14, 199, 5556, 883, 3907, 314, 298, 3596, 827, 2, 2559, 687, 24330, 12, 436, 642, 5922, 911, 675, 652, 14, 199, 624, 421, 199, 363, 452, 363, 275, 788, 9554, 63, 1073, 297, 283, 15479, 63, 1073, 418, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 1235, 12630, 63, 958, 275, 1211, 8, 498, 534, 4553, 297, 2151, 16667, 534, 18178, 297, 2151, 730, 534, 4844, 358, 199, 199, 318, 13323, 63, 4553, 8, 4553, 12, 1599, 12, 7449, 63, 1231, 304, 272, 340, 822, 8, 4553, 9, 665, 499, 26, 267, 372, 5274, 339, 1561, 275, 769, 342, 272, 8586, 63, 2738, 275, 5228, 14, 6424, 342, 272, 1300, 275, 747, 14, 515, 14, 2330, 1861, 779, 736, 14, 515, 14, 3475, 8, 83, 9, 367, 308, 315, 5274, 566, 339, 367, 1350, 315, 5274, 26, 267, 327, 664, 282, 769, 402, 1006, 6203, 1928, 5478, 267, 8586, 63, 493, 275, 747, 14, 515, 14, 4846, 8, 1365, 9, 267, 8586, 63, 493, 63, 354, 275, 747, 14, 515, 14, 7973, 8, 3596, 63, 493, 2788, 16, 61, 267, 1561, 14, 740, 8, 3596, 63, 493, 63, 354, 9, 398, 327, 1900, 282, 5288, 570, 543, 1006, 4072, 267, 2615, 63, 1365, 275, 747, 14, 515, 14, 904, 8, 2319, 63, 1231, 12, 1350, 14, 10124, 28684, 267, 289, 275, 1551, 8, 2861, 63, 1365, 12, 283, 82, 358, 267, 8586, 63, 2738, 14, 952, 8, 70, 14, 739, 1012, 267, 8586, 63, 2738, 14, 952, 2258, 78, 358, 267, 289, 14, 1600, 342, 339, 327, 6482, 310, 282, 892, 536, 436, 3550, 931, 370, 652, 272, 6748, 275, 15671, 904, 8, 1247, 435, 788, 1439, 4567, 568, 1149, 297, 1599, 566, 272, 30540, 275, 747, 14, 515, 14, 904, 8, 2319, 63, 1231, 12, 1300, 14, 1913, 2336, 659, 6748, 9, 339, 327, 2218, 314, 12149, 570, 272, 289, 275, 1551, 8, 23248, 12, 283, 87, 358, 272, 289, 14, 952, 8, 3596, 63, 2738, 14, 7150, 1012, 272, 289, 14, 1600, 342, 339, 372, 359, 736, 14, 515, 14, 904, 8, 1095, 12, 6748, 1874, 199, 199, 318, 1748, 2021, 63, 4553, 8, 4553, 12, 1599, 12, 7449, 63, 1231, 9280, 272, 492, 11431, 1208, 18407, 340, 283, 3596, 7, 315, 1599, 26, 267, 8586, 63, 827, 2021, 275, 31861, 4649, 2021, 342, 272, 1748, 4541, 63, 4553, 275, 942, 339, 367, 1350, 315, 5274, 26, 267, 327, 3550, 2615, 931, 370, 1350, 267, 949, 63, 832, 63, 1365, 275, 747, 14, 515, 14, 7973, 8, 1365, 2788, 16, 61, 267, 2615, 63, 1365, 275, 747, 14, 515, 14, 904, 8, 2319, 63, 1231, 12, 334, 889, 63, 832, 63, 1365, 435, 1599, 680, 10124, 28684, 398, 327, 3550, 1748, 4541, 1350, 931, 267, 2615, 63, 1365, 275, 747, 14, 515, 14, 904, 8, 2319, 63, 1231, 12, 334, 1365, 680, 10124, 28684, 267, 949, 63, 832, 63, 2861, 63, 1365, 275, 747, 14, 515, 14, 7973, 8, 2861, 63, 1365, 2788, 16, 61, 267, 1748, 4541, 275, 949, 63, 832, 63, 2861, 63, 1365, 435, 1599, 398, 289, 63, 827, 4541, 63, 1365, 275, 1551, 8, 827, 4541, 12, 283, 87, 358, 398, 327, 1748, 2021, 8586, 1350, 334, 739, 2547, 365, 2599, 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, 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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 ]
jumpstarter-io/neutron
neutron/agent/linux/ovs_lib.py
5
22667
# Copyright 2011 VMware, 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. import itertools import operator from oslo.config import cfg from neutron.agent.linux import ip_lib from neutron.agent.linux import utils from neutron.common import exceptions from neutron.openstack.common import excutils from neutron.openstack.common import jsonutils from neutron.openstack.common import log as logging from neutron.plugins.common import constants # Default timeout for ovs-vsctl command DEFAULT_OVS_VSCTL_TIMEOUT = 10 # Special return value for an invalid OVS ofport INVALID_OFPORT = '-1' OPTS = [ cfg.IntOpt('ovs_vsctl_timeout', default=DEFAULT_OVS_VSCTL_TIMEOUT, help=_('Timeout in seconds for ovs-vsctl commands')), ] cfg.CONF.register_opts(OPTS) LOG = logging.getLogger(__name__) class VifPort: def __init__(self, port_name, ofport, vif_id, vif_mac, switch): self.port_name = port_name self.ofport = ofport self.vif_id = vif_id self.vif_mac = vif_mac self.switch = switch def __str__(self): return ("iface-id=" + self.vif_id + ", vif_mac=" + self.vif_mac + ", port_name=" + self.port_name + ", ofport=" + str(self.ofport) + ", bridge_name=" + self.switch.br_name) class BaseOVS(object): def __init__(self, root_helper): self.root_helper = root_helper self.vsctl_timeout = cfg.CONF.ovs_vsctl_timeout def run_vsctl(self, args, check_error=False): full_args = ["ovs-vsctl", "--timeout=%d" % self.vsctl_timeout] + args try: return utils.execute(full_args, root_helper=self.root_helper) except Exception as e: with excutils.save_and_reraise_exception() as ctxt: LOG.error(_("Unable to execute %(cmd)s. " "Exception: %(exception)s"), {'cmd': full_args, 'exception': e}) if not check_error: ctxt.reraise = False def add_bridge(self, bridge_name): self.run_vsctl(["--", "--may-exist", "add-br", bridge_name]) return OVSBridge(bridge_name, self.root_helper) def delete_bridge(self, bridge_name): self.run_vsctl(["--", "--if-exists", "del-br", bridge_name]) def bridge_exists(self, bridge_name): try: self.run_vsctl(['br-exists', bridge_name], check_error=True) except RuntimeError as e: with excutils.save_and_reraise_exception() as ctxt: if 'Exit code: 2\n' in str(e): ctxt.reraise = False return False return True def get_bridge_name_for_port_name(self, port_name): try: return self.run_vsctl(['port-to-br', port_name], check_error=True) except RuntimeError as e: with excutils.save_and_reraise_exception() as ctxt: if 'Exit code: 1\n' in str(e): ctxt.reraise = False def port_exists(self, port_name): return bool(self.get_bridge_name_for_port_name(port_name)) class OVSBridge(BaseOVS): def __init__(self, br_name, root_helper): super(OVSBridge, self).__init__(root_helper) self.br_name = br_name def set_controller(self, controller_names): vsctl_command = ['--', 'set-controller', self.br_name] vsctl_command.extend(controller_names) self.run_vsctl(vsctl_command, check_error=True) def del_controller(self): self.run_vsctl(['--', 'del-controller', self.br_name], check_error=True) def get_controller(self): res = self.run_vsctl(['--', 'get-controller', self.br_name], check_error=True) if res: return res.strip().split('\n') return res def set_secure_mode(self): self.run_vsctl(['--', 'set-fail-mode', self.br_name, 'secure'], check_error=True) def set_protocols(self, protocols): self.run_vsctl(['--', 'set', 'bridge', self.br_name, "protocols=%s" % protocols], check_error=True) def create(self): self.add_bridge(self.br_name) def destroy(self): self.delete_bridge(self.br_name) def reset_bridge(self): self.destroy() self.create() def add_port(self, port_name): self.run_vsctl(["--", "--may-exist", "add-port", self.br_name, port_name]) return self.get_port_ofport(port_name) def delete_port(self, port_name): self.run_vsctl(["--", "--if-exists", "del-port", self.br_name, port_name]) def set_db_attribute(self, table_name, record, column, value): args = ["set", table_name, record, "%s=%s" % (column, value)] self.run_vsctl(args) def clear_db_attribute(self, table_name, record, column): args = ["clear", table_name, record, column] self.run_vsctl(args) def run_ofctl(self, cmd, args, process_input=None): full_args = ["ovs-ofctl", cmd, self.br_name] + args try: return utils.execute(full_args, root_helper=self.root_helper, process_input=process_input) except Exception as e: LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"), {'cmd': full_args, 'exception': e}) def count_flows(self): flow_list = self.run_ofctl("dump-flows", []).split("\n")[1:] return len(flow_list) - 1 def remove_all_flows(self): self.run_ofctl("del-flows", []) def get_port_ofport(self, port_name): ofport = self.db_get_val("Interface", port_name, "ofport") # This can return a non-integer string, like '[]' so ensure a # common failure case try: int(ofport) return ofport except (ValueError, TypeError): return INVALID_OFPORT def get_datapath_id(self): return self.db_get_val('Bridge', self.br_name, 'datapath_id').strip('"') def do_action_flows(self, action, kwargs_list): flow_strs = [_build_flow_expr_str(kw, action) for kw in kwargs_list] self.run_ofctl('%s-flows' % action, ['-'], '\n'.join(flow_strs)) def add_flow(self, **kwargs): self.do_action_flows('add', [kwargs]) def mod_flow(self, **kwargs): self.do_action_flows('mod', [kwargs]) def delete_flows(self, **kwargs): self.do_action_flows('del', [kwargs]) def dump_flows_for_table(self, table): retval = None flow_str = "table=%s" % table flows = self.run_ofctl("dump-flows", [flow_str]) if flows: retval = '\n'.join(item for item in flows.splitlines() if 'NXST' not in item) return retval def deferred(self, **kwargs): return DeferredOVSBridge(self, **kwargs) def add_tunnel_port(self, port_name, remote_ip, local_ip, tunnel_type=constants.TYPE_GRE, vxlan_udp_port=constants.VXLAN_UDP_PORT, dont_fragment=True): vsctl_command = ["--", "--may-exist", "add-port", self.br_name, port_name] vsctl_command.extend(["--", "set", "Interface", port_name, "type=%s" % tunnel_type]) if tunnel_type == constants.TYPE_VXLAN: # Only set the VXLAN UDP port if it's not the default if vxlan_udp_port != constants.VXLAN_UDP_PORT: vsctl_command.append("options:dst_port=%s" % vxlan_udp_port) vsctl_command.append(("options:df_default=%s" % bool(dont_fragment)).lower()) vsctl_command.extend(["options:remote_ip=%s" % remote_ip, "options:local_ip=%s" % local_ip, "options:in_key=flow", "options:out_key=flow"]) self.run_vsctl(vsctl_command) ofport = self.get_port_ofport(port_name) if (tunnel_type == constants.TYPE_VXLAN and ofport == INVALID_OFPORT): LOG.error(_('Unable to create VXLAN tunnel port. Please ensure ' 'that an openvswitch version that supports VXLAN is ' 'installed.')) return ofport def add_patch_port(self, local_name, remote_name): self.run_vsctl(["add-port", self.br_name, local_name, "--", "set", "Interface", local_name, "type=patch", "options:peer=%s" % remote_name]) return self.get_port_ofport(local_name) def db_get_map(self, table, record, column, check_error=False): output = self.run_vsctl(["get", table, record, column], check_error) if output: output_str = output.rstrip("\n\r") return self.db_str_to_map(output_str) return {} def db_get_val(self, table, record, column, check_error=False): output = self.run_vsctl(["get", table, record, column], check_error) if output: return output.rstrip("\n\r") def db_str_to_map(self, full_str): list = full_str.strip("{}").split(", ") ret = {} for e in list: if e.find("=") == -1: continue arr = e.split("=") ret[arr[0]] = arr[1].strip("\"") return ret def get_port_name_list(self): res = self.run_vsctl(["list-ports", self.br_name], check_error=True) if res: return res.strip().split("\n") return [] def get_port_stats(self, port_name): return self.db_get_map("Interface", port_name, "statistics") def get_xapi_iface_id(self, xs_vif_uuid): args = ["xe", "vif-param-get", "param-name=other-config", "param-key=nicira-iface-id", "uuid=%s" % xs_vif_uuid] try: return utils.execute(args, root_helper=self.root_helper).strip() except Exception as e: with excutils.save_and_reraise_exception(): LOG.error(_("Unable to execute %(cmd)s. " "Exception: %(exception)s"), {'cmd': args, 'exception': e}) # returns a VIF object for each VIF port def get_vif_ports(self): edge_ports = [] port_names = self.get_port_name_list() for name in port_names: external_ids = self.db_get_map("Interface", name, "external_ids", check_error=True) ofport = self.db_get_val("Interface", name, "ofport", check_error=True) if "iface-id" in external_ids and "attached-mac" in external_ids: p = VifPort(name, ofport, external_ids["iface-id"], external_ids["attached-mac"], self) edge_ports.append(p) elif ("xs-vif-uuid" in external_ids and "attached-mac" in external_ids): # if this is a xenserver and iface-id is not automatically # synced to OVS from XAPI, we grab it from XAPI directly iface_id = self.get_xapi_iface_id(external_ids["xs-vif-uuid"]) p = VifPort(name, ofport, iface_id, external_ids["attached-mac"], self) edge_ports.append(p) return edge_ports def get_vif_port_set(self): port_names = self.get_port_name_list() edge_ports = set() args = ['--format=json', '--', '--columns=name,external_ids,ofport', 'list', 'Interface'] result = self.run_vsctl(args, check_error=True) if not result: return edge_ports for row in jsonutils.loads(result)['data']: name = row[0] if name not in port_names: continue external_ids = dict(row[1][1]) # Do not consider VIFs which aren't yet ready # This can happen when ofport values are either [] or ["set", []] # We will therefore consider only integer values for ofport ofport = row[2] try: int_ofport = int(ofport) except (ValueError, TypeError): LOG.warn(_("Found not yet ready openvswitch port: %s"), row) else: if int_ofport > 0: if ("iface-id" in external_ids and "attached-mac" in external_ids): edge_ports.add(external_ids['iface-id']) elif ("xs-vif-uuid" in external_ids and "attached-mac" in external_ids): # if this is a xenserver and iface-id is not # automatically synced to OVS from XAPI, we grab it # from XAPI directly iface_id = self.get_xapi_iface_id( external_ids["xs-vif-uuid"]) edge_ports.add(iface_id) else: LOG.warn(_("Found failed openvswitch port: %s"), row) return edge_ports def get_port_tag_dict(self): """Get a dict of port names and associated vlan tags. e.g. the returned dict is of the following form:: {u'int-br-eth2': [], u'patch-tun': [], u'qr-76d9e6b6-21': 1, u'tapce5318ff-78': 1, u'tape1400310-e6': 1} The TAG ID is only available in the "Port" table and is not available in the "Interface" table queried by the get_vif_port_set() method. """ port_names = self.get_port_name_list() args = ['--format=json', '--', '--columns=name,tag', 'list', 'Port'] result = self.run_vsctl(args, check_error=True) port_tag_dict = {} if not result: return port_tag_dict for name, tag in jsonutils.loads(result)['data']: if name not in port_names: continue # 'tag' can be [u'set', []] or an integer if isinstance(tag, list): tag = tag[1] port_tag_dict[name] = tag return port_tag_dict def get_vif_port_by_id(self, port_id): args = ['--format=json', '--', '--columns=external_ids,name,ofport', 'find', 'Interface', 'external_ids:iface-id="%s"' % port_id] result = self.run_vsctl(args) if not result: return json_result = jsonutils.loads(result) try: # Retrieve the indexes of the columns we're looking for headings = json_result['headings'] ext_ids_idx = headings.index('external_ids') name_idx = headings.index('name') ofport_idx = headings.index('ofport') # If data attribute is missing or empty the line below will raise # an exeception which will be captured in this block. # We won't deal with the possibility of ovs-vsctl return multiple # rows since the interface identifier is unique data = json_result['data'][0] port_name = data[name_idx] switch = get_bridge_for_iface(self.root_helper, port_name) if switch != self.br_name: LOG.info(_("Port: %(port_name)s is on %(switch)s," " not on %(br_name)s"), {'port_name': port_name, 'switch': switch, 'br_name': self.br_name}) return ofport = data[ofport_idx] # ofport must be integer otherwise return None if not isinstance(ofport, int) or ofport == -1: LOG.warn(_("ofport: %(ofport)s for VIF: %(vif)s is not a " "positive integer"), {'ofport': ofport, 'vif': port_id}) return # Find VIF's mac address in external ids ext_id_dict = dict((item[0], item[1]) for item in data[ext_ids_idx][1]) vif_mac = ext_id_dict['attached-mac'] return VifPort(port_name, ofport, port_id, vif_mac, self) except Exception as e: LOG.warn(_("Unable to parse interface details. Exception: %s"), e) return def delete_ports(self, all_ports=False): if all_ports: port_names = self.get_port_name_list() else: port_names = (port.port_name for port in self.get_vif_ports()) for port_name in port_names: self.delete_port(port_name) def get_local_port_mac(self): """Retrieve the mac of the bridge's local port.""" address = ip_lib.IPDevice(self.br_name, self.root_helper).link.address if address: return address else: msg = _('Unable to determine mac address for %s') % self.br_name raise Exception(msg) def __enter__(self): self.create() return self def __exit__(self, exc_type, exc_value, exc_tb): self.destroy() class DeferredOVSBridge(object): '''Deferred OVSBridge. This class wraps add_flow, mod_flow and delete_flows calls to an OVSBridge and defers their application until apply_flows call in order to perform bulk calls. It wraps also ALLOWED_PASSTHROUGHS calls to avoid mixing OVSBridge and DeferredOVSBridge uses. This class can be used as a context, in such case apply_flows is called on __exit__ except if an exception is raised. This class is not thread-safe, that's why for every use a new instance must be implemented. ''' ALLOWED_PASSTHROUGHS = 'add_port', 'add_tunnel_port', 'delete_port' def __init__(self, br, full_ordered=False, order=('add', 'mod', 'del')): '''Constructor. :param br: wrapped bridge :param full_ordered: Optional, disable flow reordering (slower) :param order: Optional, define in which order flow are applied ''' self.br = br self.full_ordered = full_ordered self.order = order if not self.full_ordered: self.weights = dict((y, x) for x, y in enumerate(self.order)) self.action_flow_tuples = [] def __getattr__(self, name): if name in self.ALLOWED_PASSTHROUGHS: return getattr(self.br, name) raise AttributeError(name) def add_flow(self, **kwargs): self.action_flow_tuples.append(('add', kwargs)) def mod_flow(self, **kwargs): self.action_flow_tuples.append(('mod', kwargs)) def delete_flows(self, **kwargs): self.action_flow_tuples.append(('del', kwargs)) def apply_flows(self): action_flow_tuples = self.action_flow_tuples self.action_flow_tuples = [] if not action_flow_tuples: return if not self.full_ordered: action_flow_tuples.sort(key=lambda af: self.weights[af[0]]) grouped = itertools.groupby(action_flow_tuples, key=operator.itemgetter(0)) itemgetter_1 = operator.itemgetter(1) for action, action_flow_list in grouped: flows = map(itemgetter_1, action_flow_list) self.br.do_action_flows(action, flows) def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): if exc_type is None: self.apply_flows() else: LOG.exception(_("OVS flows could not be applied on bridge %s"), self.br.br_name) def get_bridge_for_iface(root_helper, iface): args = ["ovs-vsctl", "--timeout=%d" % cfg.CONF.ovs_vsctl_timeout, "iface-to-br", iface] try: return utils.execute(args, root_helper=root_helper).strip() except Exception: LOG.exception(_("Interface %s not found."), iface) return None def get_bridges(root_helper): args = ["ovs-vsctl", "--timeout=%d" % cfg.CONF.ovs_vsctl_timeout, "list-br"] try: return utils.execute(args, root_helper=root_helper).strip().split("\n") except Exception as e: with excutils.save_and_reraise_exception(): LOG.exception(_("Unable to retrieve bridges. Exception: %s"), e) def get_bridge_external_bridge_id(root_helper, bridge): args = ["ovs-vsctl", "--timeout=2", "br-get-external-id", bridge, "bridge-id"] try: return utils.execute(args, root_helper=root_helper).strip() except Exception: LOG.exception(_("Bridge %s not found."), bridge) return None def _build_flow_expr_str(flow_dict, cmd): flow_expr_arr = [] actions = None if cmd == 'add': flow_expr_arr.append("hard_timeout=%s" % flow_dict.pop('hard_timeout', '0')) flow_expr_arr.append("idle_timeout=%s" % flow_dict.pop('idle_timeout', '0')) flow_expr_arr.append("priority=%s" % flow_dict.pop('priority', '1')) elif 'priority' in flow_dict: msg = _("Cannot match priority on flow deletion or modification") raise exceptions.InvalidInput(error_message=msg) if cmd != 'del': if "actions" not in flow_dict: msg = _("Must specify one or more actions on flow addition" " or modification") raise exceptions.InvalidInput(error_message=msg) actions = "actions=%s" % flow_dict.pop('actions') for key, value in flow_dict.iteritems(): if key == 'proto': flow_expr_arr.append(value) else: flow_expr_arr.append("%s=%s" % (key, str(value))) if actions: flow_expr_arr.append(actions) return ','.join(flow_expr_arr)
apache-2.0
[ 3, 1898, 7760, 27391, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 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, 646, 7975, 199, 646, 4182, 199, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 8224, 14, 4054, 14, 5135, 492, 3384, 63, 773, 199, 504, 8224, 14, 4054, 14, 5135, 492, 3778, 199, 504, 8224, 14, 2330, 492, 4967, 199, 504, 8224, 14, 8512, 14, 2330, 492, 32763, 199, 504, 8224, 14, 8512, 14, 2330, 492, 18705, 199, 504, 8224, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 8224, 14, 5265, 14, 2330, 492, 5262, 199, 199, 3, 3758, 2653, 367, 23671, 13, 3122, 8077, 1414, 199, 3472, 63, 47, 7428, 63, 7428, 23745, 63, 8899, 275, 1616, 199, 199, 3, 12568, 372, 574, 367, 376, 3866, 593, 7428, 402, 719, 199, 9692, 63, 3359, 3657, 275, 2475, 17, 7, 199, 199, 25636, 275, 359, 272, 4810, 14, 3241, 9985, 360, 22409, 63, 3122, 8077, 63, 2593, 297, 2049, 849, 29, 3472, 63, 47, 7428, 63, 7428, 23745, 63, 8899, 12, 2049, 1720, 12397, 6372, 315, 4696, 367, 23671, 13, 3122, 8077, 3718, 3855, 199, 61, 199, 4128, 14, 3103, 14, 2683, 63, 3291, 8, 25636, 9, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 812, 692, 4313, 26, 272, 347, 636, 826, 721, 277, 12, 1844, 63, 354, 12, 402, 719, 12, 15205, 63, 344, 12, 15205, 63, 3088, 12, 6258, 304, 267, 291, 14, 719, 63, 354, 275, 1844, 63, 354, 267, 291, 14, 1618, 719, 275, 402, 719, 267, 291, 14, 14430, 63, 344, 275, 15205, 63, 344, 267, 291, 14, 14430, 63, 3088, 275, 15205, 63, 3088, 267, 291, 14, 5656, 275, 6258, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 11166, 13, 344, 628, 435, 291, 14, 14430, 63, 344, 435, 3872, 15205, 63, 3088, 628, 435, 355, 291, 14, 14430, 63, 3088, 435, 3872, 1844, 63, 354, 628, 435, 291, 14, 719, 63, 354, 435, 355, 3872, 402, 719, 628, 435, 620, 8, 277, 14, 1618, 719, 9, 435, 3872, 13928, 63, 354, 628, 435, 355, 291, 14, 5656, 14, 3289, 63, 354, 9, 421, 199, 533, 3523, 47, 7428, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1738, 63, 3676, 304, 267, 291, 14, 1231, 63, 3676, 275, 1738, 63, 3676, 267, 291, 14, 3122, 8077, 63, 2593, 275, 4810, 14, 3103, 14, 22409, 63, 3122, 8077, 63, 2593, 339, 347, 1255, 63, 3122, 8077, 8, 277, 12, 1249, 12, 1104, 63, 705, 29, 797, 304, 267, 2615, 63, 589, 275, 2097, 22409, 13, 3122, 8077, 401, 4320, 2593, 2458, 68, 2, 450, 291, 14, 3122, 8077, 63, 2593, 61, 435, 1249, 267, 862, 26, 288, 372, 3778, 14, 2526, 8, 2861, 63, 589, 12, 1738, 63, 3676, 29, 277, 14, 1231, 63, 3676, 9, 267, 871, 2186, 465, 325, 26, 288, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 342, 465, 11216, 26, 355, 5051, 14, 705, 6115, 6005, 370, 5341, 2818, 1760, 9, 83, 14, 298, 1169, 298, 1726, 26, 2818, 1971, 9, 83, 1288, 2079, 791, 1760, 356, 2615, 63, 589, 12, 283, 1971, 356, 325, 1552, 355, 340, 440, 1104, 63, 705, 26, 490, 11216, 14, 20614, 275, 756, 339, 347, 1050, 63, 9528, 8, 277, 12, 13928, 63, 354, 304, 267, 291, 14, 1065, 63, 3122, 8077, 5234, 306, 401, 4320, 7551, 13, 4494, 401, 298, 525, 13, 3289, 401, 13928, 63, 354, 566, 267, 372, 593, 7428, 14491, 8, 9528, 63, 354, 12, 291, 14, 1231, 63, 3676, 9, 339, 347, 3145, 63, 9528, 8, 277, 12, 13928, 63, 354, 304, 267, 291, 14, 1065, 63, 3122, 8077, 5234, 306, 401, 4320, 692, 13, 2444, 401, 298, 2264, 13, 3289, 401, 13928, 63, 354, 566, 339, 347, 13928, 63, 2444, 8, 277, 12, 13928, 63, 354, 304, 267, 862, 26, 288, 291, 14, 1065, 63, 3122, 8077, 2941, 3289, 13, 2444, 297, 13928, 63, 354, 467, 1104, 63, 705, 29, 549, 9, 267, 871, 6064, 465, 325, 26, 288, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 342, 465, 11216, 26, 355, 340, 283, 6699, 1233, 26, 499, 60, 78, 7, 315, 620, 8, 69, 304, 490, 11216, 14, 20614, 275, 756, 490, 372, 756, 267, 372, 715, 339, 347, 664, 63, 9528, 63, 354, 63, 509, 63, 719, 63, 354, 8, 277, 12, 1844, 63, 354, 304, 267, 862, 26, 288, 372, 291, 14, 1065, 63, 3122, 8077, 2941, 719, 13, 475, 13, 3289, 297, 1844, 63, 354, 467, 1104, 63, 705, 29, 549, 9, 267, 871, 6064, 465, 325, 26, 288, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 342, 465, 11216, 26, 355, 340, 283, 6699, 1233, 26, 413, 60, 78, 7, 315, 620, 8, 69, 304, 490, 11216, 14, 20614, 275, 756, 339, 347, 1844, 63, 2444, 8, 277, 12, 1844, 63, 354, 304, 267, 372, 2155, 8, 277, 14, 362, 63, 9528, 63, 354, 63, 509, 63, 719, 63, 354, 8, 719, 63, 354, 430, 421, 199, 533, 593, 7428, 14491, 8, 1563, 47, 7428, 304, 272, 347, 636, 826, 721, 277, 12, 11665, 63, 354, 12, 1738, 63, 3676, 304, 267, 1613, 8, 47, 7428, 14491, 12, 291, 2843, 826, 721, 1231, 63, 3676, 9, 267, 291, 14, 3289, 63, 354, 275 ]
[ 1898, 7760, 27391, 12, 3277, 14, 199, 3, 2900, 5924, 5702, 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, 646, 7975, 199, 646, 4182, 199, 199, 504, 11258, 14, 888, 492, 4810, 199, 199, 504, 8224, 14, 4054, 14, 5135, 492, 3384, 63, 773, 199, 504, 8224, 14, 4054, 14, 5135, 492, 3778, 199, 504, 8224, 14, 2330, 492, 4967, 199, 504, 8224, 14, 8512, 14, 2330, 492, 32763, 199, 504, 8224, 14, 8512, 14, 2330, 492, 18705, 199, 504, 8224, 14, 8512, 14, 2330, 492, 943, 465, 2050, 199, 504, 8224, 14, 5265, 14, 2330, 492, 5262, 199, 199, 3, 3758, 2653, 367, 23671, 13, 3122, 8077, 1414, 199, 3472, 63, 47, 7428, 63, 7428, 23745, 63, 8899, 275, 1616, 199, 199, 3, 12568, 372, 574, 367, 376, 3866, 593, 7428, 402, 719, 199, 9692, 63, 3359, 3657, 275, 2475, 17, 7, 199, 199, 25636, 275, 359, 272, 4810, 14, 3241, 9985, 360, 22409, 63, 3122, 8077, 63, 2593, 297, 2049, 849, 29, 3472, 63, 47, 7428, 63, 7428, 23745, 63, 8899, 12, 2049, 1720, 12397, 6372, 315, 4696, 367, 23671, 13, 3122, 8077, 3718, 3855, 199, 61, 199, 4128, 14, 3103, 14, 2683, 63, 3291, 8, 25636, 9, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 812, 692, 4313, 26, 272, 347, 636, 826, 721, 277, 12, 1844, 63, 354, 12, 402, 719, 12, 15205, 63, 344, 12, 15205, 63, 3088, 12, 6258, 304, 267, 291, 14, 719, 63, 354, 275, 1844, 63, 354, 267, 291, 14, 1618, 719, 275, 402, 719, 267, 291, 14, 14430, 63, 344, 275, 15205, 63, 344, 267, 291, 14, 14430, 63, 3088, 275, 15205, 63, 3088, 267, 291, 14, 5656, 275, 6258, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1689, 11166, 13, 344, 628, 435, 291, 14, 14430, 63, 344, 435, 3872, 15205, 63, 3088, 628, 435, 355, 291, 14, 14430, 63, 3088, 435, 3872, 1844, 63, 354, 628, 435, 291, 14, 719, 63, 354, 435, 355, 3872, 402, 719, 628, 435, 620, 8, 277, 14, 1618, 719, 9, 435, 3872, 13928, 63, 354, 628, 435, 355, 291, 14, 5656, 14, 3289, 63, 354, 9, 421, 199, 533, 3523, 47, 7428, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1738, 63, 3676, 304, 267, 291, 14, 1231, 63, 3676, 275, 1738, 63, 3676, 267, 291, 14, 3122, 8077, 63, 2593, 275, 4810, 14, 3103, 14, 22409, 63, 3122, 8077, 63, 2593, 339, 347, 1255, 63, 3122, 8077, 8, 277, 12, 1249, 12, 1104, 63, 705, 29, 797, 304, 267, 2615, 63, 589, 275, 2097, 22409, 13, 3122, 8077, 401, 4320, 2593, 2458, 68, 2, 450, 291, 14, 3122, 8077, 63, 2593, 61, 435, 1249, 267, 862, 26, 288, 372, 3778, 14, 2526, 8, 2861, 63, 589, 12, 1738, 63, 3676, 29, 277, 14, 1231, 63, 3676, 9, 267, 871, 2186, 465, 325, 26, 288, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 342, 465, 11216, 26, 355, 5051, 14, 705, 6115, 6005, 370, 5341, 2818, 1760, 9, 83, 14, 298, 1169, 298, 1726, 26, 2818, 1971, 9, 83, 1288, 2079, 791, 1760, 356, 2615, 63, 589, 12, 283, 1971, 356, 325, 1552, 355, 340, 440, 1104, 63, 705, 26, 490, 11216, 14, 20614, 275, 756, 339, 347, 1050, 63, 9528, 8, 277, 12, 13928, 63, 354, 304, 267, 291, 14, 1065, 63, 3122, 8077, 5234, 306, 401, 4320, 7551, 13, 4494, 401, 298, 525, 13, 3289, 401, 13928, 63, 354, 566, 267, 372, 593, 7428, 14491, 8, 9528, 63, 354, 12, 291, 14, 1231, 63, 3676, 9, 339, 347, 3145, 63, 9528, 8, 277, 12, 13928, 63, 354, 304, 267, 291, 14, 1065, 63, 3122, 8077, 5234, 306, 401, 4320, 692, 13, 2444, 401, 298, 2264, 13, 3289, 401, 13928, 63, 354, 566, 339, 347, 13928, 63, 2444, 8, 277, 12, 13928, 63, 354, 304, 267, 862, 26, 288, 291, 14, 1065, 63, 3122, 8077, 2941, 3289, 13, 2444, 297, 13928, 63, 354, 467, 1104, 63, 705, 29, 549, 9, 267, 871, 6064, 465, 325, 26, 288, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 342, 465, 11216, 26, 355, 340, 283, 6699, 1233, 26, 499, 60, 78, 7, 315, 620, 8, 69, 304, 490, 11216, 14, 20614, 275, 756, 490, 372, 756, 267, 372, 715, 339, 347, 664, 63, 9528, 63, 354, 63, 509, 63, 719, 63, 354, 8, 277, 12, 1844, 63, 354, 304, 267, 862, 26, 288, 372, 291, 14, 1065, 63, 3122, 8077, 2941, 719, 13, 475, 13, 3289, 297, 1844, 63, 354, 467, 1104, 63, 705, 29, 549, 9, 267, 871, 6064, 465, 325, 26, 288, 543, 32763, 14, 2117, 63, 460, 63, 20614, 63, 1971, 342, 465, 11216, 26, 355, 340, 283, 6699, 1233, 26, 413, 60, 78, 7, 315, 620, 8, 69, 304, 490, 11216, 14, 20614, 275, 756, 339, 347, 1844, 63, 2444, 8, 277, 12, 1844, 63, 354, 304, 267, 372, 2155, 8, 277, 14, 362, 63, 9528, 63, 354, 63, 509, 63, 719, 63, 354, 8, 719, 63, 354, 430, 421, 199, 533, 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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 ]
chadrosenquist/logging-test-case
examples/assertnologs_example1.py
1
2548
""" MIT License Copyright (c) 2018 Chad Rosenquist 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. Created on Nov 22, 2018 @author: Chad Rosenquist """ import unittest import logging import loggingtestcase class AssertNoLogsExample(loggingtestcase.LoggingTestCase): """Example on how to use LoggingTestCase and no logging.""" def __init__(self, methodName='runTest', testlogger=None, testlevel=None): """ To change the logger or log level, override __init__. By default, the root logger is used and the log level is logging.INFO. """ # testlevel = logging.ERROR super().__init__(methodName, testlogger, testlevel) def setUp(self): self.logger = logging.getLogger(__name__) def test_assert_no_logs_fail(self): """The test fails because logs are emitted. Here is the output: E AssertionError: The follow messages were unexpectedly logged: E ERROR:examples.assertnologs_example1:first message E ERROR:examples.assertnologs_example1:second message """ with self.assertNoLogs(): self.logger.error('first message') self.logger.error('second message') def test_assert_no_logs_pass(self): """The test passes because no logs are emitted inside the context manager.""" self.logger.error('first message') with self.assertNoLogs(): pass self.logger.error('second message') if __name__ == "__main__": unittest.main()
mit
[ 624, 199, 13965, 844, 199, 199, 7384, 334, 67, 9, 14894, 2799, 350, 6848, 2464, 392, 631, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 26734, 14, 199, 199, 10502, 641, 3091, 86, 6928, 12, 14894, 199, 199, 32, 2502, 26, 2799, 350, 6848, 2464, 392, 631, 199, 624, 199, 646, 2882, 199, 646, 2050, 199, 199, 646, 2050, 10847, 421, 199, 533, 10716, 1944, 16333, 9846, 8, 4806, 10847, 14, 14054, 1746, 304, 272, 408, 9846, 641, 4212, 370, 675, 19928, 1746, 436, 949, 2050, 1041, 339, 347, 636, 826, 721, 277, 12, 23352, 534, 27850, 297, 511, 2921, 29, 403, 12, 511, 1896, 29, 403, 304, 267, 408, 267, 4005, 1570, 314, 2512, 503, 943, 2166, 12, 4278, 636, 826, 4343, 267, 4885, 849, 12, 314, 1738, 2512, 365, 1202, 436, 314, 943, 2166, 365, 2050, 14, 4531, 14, 267, 408, 267, 327, 511, 1896, 275, 2050, 14, 3170, 267, 1613, 11027, 826, 721, 765, 985, 12, 511, 2921, 12, 511, 1896, 9, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 339, 347, 511, 63, 479, 63, 889, 63, 7270, 63, 1633, 8, 277, 304, 267, 408, 1918, 511, 6918, 2952, 9610, 787, 19515, 14, 398, 11842, 365, 314, 1072, 26, 267, 662, 5185, 9070, 26, 710, 2035, 3788, 4898, 10537, 590, 10367, 26, 267, 662, 7861, 12539, 26, 8589, 14, 479, 889, 7270, 63, 2694, 17, 26, 2246, 1245, 267, 662, 7861, 12539, 26, 8589, 14, 479, 889, 7270, 63, 2694, 17, 26, 4375, 1245, 398, 408, 267, 543, 291, 14, 22389, 16333, 837, 288, 291, 14, 2921, 14, 705, 360, 2246, 1245, 358, 288, 291, 14, 2921, 14, 705, 360, 4375, 1245, 358, 339, 347, 511, 63, 479, 63, 889, 63, 7270, 63, 1529, 8, 277, 304, 267, 408, 1918, 511, 14933, 2952, 949, 9610, 787, 19515, 6272, 314, 1067, 5256, 1041, 267, 291, 14, 2921, 14, 705, 360, 2246, 1245, 358, 267, 543, 291, 14, 22389, 16333, 837, 288, 986, 267, 291, 14, 2921, 14, 705, 360, 4375, 1245, 358, 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 ]
[ 199, 13965, 844, 199, 199, 7384, 334, 67, 9, 14894, 2799, 350, 6848, 2464, 392, 631, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 16847, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 26734, 14, 199, 199, 10502, 641, 3091, 86, 6928, 12, 14894, 199, 199, 32, 2502, 26, 2799, 350, 6848, 2464, 392, 631, 199, 624, 199, 646, 2882, 199, 646, 2050, 199, 199, 646, 2050, 10847, 421, 199, 533, 10716, 1944, 16333, 9846, 8, 4806, 10847, 14, 14054, 1746, 304, 272, 408, 9846, 641, 4212, 370, 675, 19928, 1746, 436, 949, 2050, 1041, 339, 347, 636, 826, 721, 277, 12, 23352, 534, 27850, 297, 511, 2921, 29, 403, 12, 511, 1896, 29, 403, 304, 267, 408, 267, 4005, 1570, 314, 2512, 503, 943, 2166, 12, 4278, 636, 826, 4343, 267, 4885, 849, 12, 314, 1738, 2512, 365, 1202, 436, 314, 943, 2166, 365, 2050, 14, 4531, 14, 267, 408, 267, 327, 511, 1896, 275, 2050, 14, 3170, 267, 1613, 11027, 826, 721, 765, 985, 12, 511, 2921, 12, 511, 1896, 9, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 339, 347, 511, 63, 479, 63, 889, 63, 7270, 63, 1633, 8, 277, 304, 267, 408, 1918, 511, 6918, 2952, 9610, 787, 19515, 14, 398, 11842, 365, 314, 1072, 26, 267, 662, 5185, 9070, 26, 710, 2035, 3788, 4898, 10537, 590, 10367, 26, 267, 662, 7861, 12539, 26, 8589, 14, 479, 889, 7270, 63, 2694, 17, 26, 2246, 1245, 267, 662, 7861, 12539, 26, 8589, 14, 479, 889, 7270, 63, 2694, 17, 26, 4375, 1245, 398, 408, 267, 543, 291, 14, 22389, 16333, 837, 288, 291, 14, 2921, 14, 705, 360, 2246, 1245, 358, 288, 291, 14, 2921, 14, 705, 360, 4375, 1245, 358, 339, 347, 511, 63, 479, 63, 889, 63, 7270, 63, 1529, 8, 277, 304, 267, 408, 1918, 511, 14933, 2952, 949, 9610, 787, 19515, 6272, 314, 1067, 5256, 1041, 267, 291, 14, 2921, 14, 705, 360, 2246, 1245, 358, 267, 543, 291, 14, 22389, 16333, 837, 288, 986, 267, 291, 14, 2921, 14, 705, 360, 4375, 1245, 358, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
josrolgil/exjobbCalvin
calvin/actorstore/systemactors/text/Format.py
3
1940
# -*- coding: utf-8 -*- # Copyright (c) 2015 Ericsson AB # # 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 calvin.actor.actor import Actor, manage, condition, ActionResult def value_for_key(d, keypath): keylist = keypath.split('.') res = d for key in keylist: res = res[key] return res class Format(Actor): """ Format output according to 'fmt' using dict Format string uses \"{access.key.path}\" to access dict Inputs: dict : Outputs: text : Formatted string """ REGEX = r"{(.+?)}" @manage(['fmt', 'fmtkeys']) def init(self, fmt): self.fmt = fmt self.use('calvinsys.native.python-re', shorthand="regex") self.fmtkeys = self['regex'].findall(Format.REGEX, fmt) @condition(['dict'], ['text']) def action(self, d): res = {} try: for fmtkey in self.fmtkeys: res[fmtkey] = value_for_key(d, fmtkey) except Exception: res = {} retval = self.fmt for key, value in res.iteritems(): retval = retval.replace('{' + key + '}', str(value)) return ActionResult(production=(retval, )) action_priority = (action, ) requires = ['calvinsys.native.python-re'] test_args = ["{huey.dewey.louie}"] test_set = [ {'in': {'dict': [{'huey': {'dewey': {'louie': 'gotcha!'}}}]}}, {'out': {'text': ['gotcha!']}} ]
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 6900, 662, 1567, 385, 265, 14840, 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, 504, 3213, 11908, 14, 5021, 14, 5021, 492, 437, 630, 12, 9635, 12, 5558, 12, 10033, 2889, 421, 199, 318, 574, 63, 509, 63, 498, 8, 68, 12, 790, 515, 304, 272, 790, 513, 275, 790, 515, 14, 1294, 7563, 272, 522, 275, 366, 272, 367, 790, 315, 790, 513, 26, 267, 522, 275, 522, 59, 498, 61, 272, 372, 522, 421, 199, 533, 9701, 8, 12258, 304, 339, 408, 272, 9701, 1072, 7182, 370, 283, 5045, 7, 1808, 1211, 339, 9701, 1059, 4440, 8441, 91, 2732, 14, 498, 14, 515, 93, 4451, 370, 2879, 1211, 339, 30520, 26, 489, 1211, 520, 272, 29206, 26, 489, 1318, 520, 9701, 471, 1059, 272, 408, 339, 14142, 1438, 275, 519, 14381, 28149, 6769, 2, 339, 768, 9053, 2941, 5045, 297, 283, 5045, 1612, 1105, 272, 347, 4205, 8, 277, 12, 7104, 304, 267, 291, 14, 5045, 275, 7104, 267, 291, 14, 1180, 360, 915, 11908, 1274, 14, 6106, 14, 1548, 13, 264, 297, 1033, 23999, 628, 3821, 531, 267, 291, 14, 5045, 1612, 275, 291, 459, 3821, 2278, 6452, 8, 3484, 14, 10710, 12, 7104, 9, 339, 768, 5394, 2941, 807, 995, 788, 505, 1105, 272, 347, 1595, 8, 277, 12, 366, 304, 267, 522, 275, 1052, 267, 862, 26, 288, 367, 7104, 498, 315, 291, 14, 5045, 1612, 26, 355, 522, 59, 5045, 498, 61, 275, 574, 63, 509, 63, 498, 8, 68, 12, 7104, 498, 9, 267, 871, 2186, 26, 288, 522, 275, 1052, 267, 9151, 275, 291, 14, 5045, 267, 367, 790, 12, 574, 315, 522, 14, 4611, 837, 288, 9151, 275, 9151, 14, 1814, 360, 1445, 435, 790, 435, 283, 7293, 620, 8, 585, 430, 398, 372, 10033, 2889, 8, 10777, 2687, 18476, 12, 5082, 339, 1595, 63, 6693, 275, 334, 1287, 12, 776, 272, 5074, 275, 788, 915, 11908, 1274, 14, 6106, 14, 1548, 13, 264, 418, 339, 511, 63, 589, 275, 2097, 91, 25016, 89, 14, 271, 1129, 89, 14, 320, 85, 1873, 93, 937, 272, 511, 63, 409, 275, 359, 267, 791, 262, 356, 791, 807, 356, 9016, 25016, 89, 356, 791, 271, 1129, 89, 356, 791, 320, 85, 1873, 356, 283, 7808, 9518, 1, 936, 4863, 9420, 1386, 267, 791, 548, 356, 791, 505, 356, 788, 7808, 9518, 1, 418, 4863, 272, 1622, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 6900, 662, 1567, 385, 265, 14840, 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, 504, 3213, 11908, 14, 5021, 14, 5021, 492, 437, 630, 12, 9635, 12, 5558, 12, 10033, 2889, 421, 199, 318, 574, 63, 509, 63, 498, 8, 68, 12, 790, 515, 304, 272, 790, 513, 275, 790, 515, 14, 1294, 7563, 272, 522, 275, 366, 272, 367, 790, 315, 790, 513, 26, 267, 522, 275, 522, 59, 498, 61, 272, 372, 522, 421, 199, 533, 9701, 8, 12258, 304, 339, 408, 272, 9701, 1072, 7182, 370, 283, 5045, 7, 1808, 1211, 339, 9701, 1059, 4440, 8441, 91, 2732, 14, 498, 14, 515, 93, 4451, 370, 2879, 1211, 339, 30520, 26, 489, 1211, 520, 272, 29206, 26, 489, 1318, 520, 9701, 471, 1059, 272, 408, 339, 14142, 1438, 275, 519, 14381, 28149, 6769, 2, 339, 768, 9053, 2941, 5045, 297, 283, 5045, 1612, 1105, 272, 347, 4205, 8, 277, 12, 7104, 304, 267, 291, 14, 5045, 275, 7104, 267, 291, 14, 1180, 360, 915, 11908, 1274, 14, 6106, 14, 1548, 13, 264, 297, 1033, 23999, 628, 3821, 531, 267, 291, 14, 5045, 1612, 275, 291, 459, 3821, 2278, 6452, 8, 3484, 14, 10710, 12, 7104, 9, 339, 768, 5394, 2941, 807, 995, 788, 505, 1105, 272, 347, 1595, 8, 277, 12, 366, 304, 267, 522, 275, 1052, 267, 862, 26, 288, 367, 7104, 498, 315, 291, 14, 5045, 1612, 26, 355, 522, 59, 5045, 498, 61, 275, 574, 63, 509, 63, 498, 8, 68, 12, 7104, 498, 9, 267, 871, 2186, 26, 288, 522, 275, 1052, 267, 9151, 275, 291, 14, 5045, 267, 367, 790, 12, 574, 315, 522, 14, 4611, 837, 288, 9151, 275, 9151, 14, 1814, 360, 1445, 435, 790, 435, 283, 7293, 620, 8, 585, 430, 398, 372, 10033, 2889, 8, 10777, 2687, 18476, 12, 5082, 339, 1595, 63, 6693, 275, 334, 1287, 12, 776, 272, 5074, 275, 788, 915, 11908, 1274, 14, 6106, 14, 1548, 13, 264, 418, 339, 511, 63, 589, 275, 2097, 91, 25016, 89, 14, 271, 1129, 89, 14, 320, 85, 1873, 93, 937, 272, 511, 63, 409, 275, 359, 267, 791, 262, 356, 791, 807, 356, 9016, 25016, 89, 356, 791, 271, 1129, 89, 356, 791, 320, 85, 1873, 356, 283, 7808, 9518, 1, 936, 4863, 9420, 1386, 267, 791, 548, 356, 791, 505, 356, 788, 7808, 9518, 1, 418, 4863, 272, 1622, 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, 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,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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 ]
mhahn/stacker
stacker/commands/stacker/diff.py
1
1480
""" Diffs the config against the currently running CloudFormation stacks Sometimes small changes can have big impacts. Run "stacker diff" before "stacker build" to detect bad things(tm) from happening in advance! """ from .base import BaseCommand from ...actions import diff class Diff(BaseCommand): name = "diff" description = __doc__ def add_arguments(self, parser): super(Diff, self).add_arguments(parser) parser.add_argument("--force", action="append", default=[], metavar="STACKNAME", type=str, help="If a stackname is provided to --force, it " "will be diffed, even if it is locked in " "the config.") parser.add_argument("--stacks", action="append", metavar="STACKNAME", type=str, help="Only work on the stacks given. Can be " "specified more than once. If not specified " "then stacker will work on all stacks in the " "config file.") def run(self, options, **kwargs): super(Diff, self).run(options, **kwargs) action = diff.Action(options.context, provider=options.provider) action.execute() def get_context_kwargs(self, options, **kwargs): return {"stack_names": options.stacks, "force_stacks": options.force}
bsd-2-clause
[ 624, 27134, 83, 314, 1101, 6169, 314, 5544, 3879, 8142, 1858, 1615, 26733, 199, 199, 7700, 4508, 7425, 4493, 883, 1172, 7282, 1742, 22282, 14, 221, 3378, 298, 2340, 281, 3915, 2, 2544, 199, 2, 2340, 281, 1900, 2, 370, 9696, 4875, 7645, 8, 7574, 9, 687, 5992, 316, 315, 18695, 1, 199, 624, 199, 199, 504, 1275, 1095, 492, 22239, 199, 504, 2263, 3723, 492, 3915, 421, 199, 533, 27134, 8, 25150, 304, 272, 536, 275, 298, 3028, 2, 272, 1369, 275, 636, 1301, 363, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1613, 8, 10746, 12, 291, 680, 525, 63, 4958, 8, 2087, 9, 267, 1798, 14, 525, 63, 2094, 6739, 3990, 401, 1595, 628, 740, 401, 849, 6034, 1169, 8214, 628, 17014, 2339, 401, 730, 29, 495, 12, 1169, 1720, 628, 3917, 282, 3464, 354, 365, 2741, 370, 1553, 3990, 12, 652, 298, 639, 298, 14117, 506, 3915, 379, 12, 2755, 340, 652, 365, 14233, 315, 298, 639, 298, 1589, 1101, 2685, 267, 1798, 14, 525, 63, 2094, 6739, 21707, 401, 1595, 628, 740, 401, 1169, 8214, 628, 17014, 2339, 401, 730, 29, 495, 12, 1169, 1720, 628, 5903, 1736, 641, 314, 26733, 1627, 14, 6855, 506, 298, 639, 298, 10085, 1655, 2419, 5403, 14, 982, 440, 2013, 298, 639, 298, 12726, 3464, 281, 911, 1736, 641, 1006, 26733, 315, 314, 298, 639, 298, 888, 570, 2685, 339, 347, 1255, 8, 277, 12, 1511, 12, 1011, 958, 304, 267, 1613, 8, 10746, 12, 291, 680, 1065, 8, 1419, 12, 1011, 958, 9, 267, 1595, 275, 3915, 14, 3310, 8, 1419, 14, 1100, 12, 5022, 29, 1419, 14, 3780, 9, 267, 1595, 14, 2526, 342, 339, 347, 664, 63, 1100, 63, 958, 8, 277, 12, 1511, 12, 1011, 958, 304, 267, 372, 2420, 2340, 63, 1247, 582, 1511, 14, 21707, 12, 298, 3990, 63, 21707, 582, 1511, 14, 3990, 93, 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 ]
[ 27134, 83, 314, 1101, 6169, 314, 5544, 3879, 8142, 1858, 1615, 26733, 199, 199, 7700, 4508, 7425, 4493, 883, 1172, 7282, 1742, 22282, 14, 221, 3378, 298, 2340, 281, 3915, 2, 2544, 199, 2, 2340, 281, 1900, 2, 370, 9696, 4875, 7645, 8, 7574, 9, 687, 5992, 316, 315, 18695, 1, 199, 624, 199, 199, 504, 1275, 1095, 492, 22239, 199, 504, 2263, 3723, 492, 3915, 421, 199, 533, 27134, 8, 25150, 304, 272, 536, 275, 298, 3028, 2, 272, 1369, 275, 636, 1301, 363, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1613, 8, 10746, 12, 291, 680, 525, 63, 4958, 8, 2087, 9, 267, 1798, 14, 525, 63, 2094, 6739, 3990, 401, 1595, 628, 740, 401, 849, 6034, 1169, 8214, 628, 17014, 2339, 401, 730, 29, 495, 12, 1169, 1720, 628, 3917, 282, 3464, 354, 365, 2741, 370, 1553, 3990, 12, 652, 298, 639, 298, 14117, 506, 3915, 379, 12, 2755, 340, 652, 365, 14233, 315, 298, 639, 298, 1589, 1101, 2685, 267, 1798, 14, 525, 63, 2094, 6739, 21707, 401, 1595, 628, 740, 401, 1169, 8214, 628, 17014, 2339, 401, 730, 29, 495, 12, 1169, 1720, 628, 5903, 1736, 641, 314, 26733, 1627, 14, 6855, 506, 298, 639, 298, 10085, 1655, 2419, 5403, 14, 982, 440, 2013, 298, 639, 298, 12726, 3464, 281, 911, 1736, 641, 1006, 26733, 315, 314, 298, 639, 298, 888, 570, 2685, 339, 347, 1255, 8, 277, 12, 1511, 12, 1011, 958, 304, 267, 1613, 8, 10746, 12, 291, 680, 1065, 8, 1419, 12, 1011, 958, 9, 267, 1595, 275, 3915, 14, 3310, 8, 1419, 14, 1100, 12, 5022, 29, 1419, 14, 3780, 9, 267, 1595, 14, 2526, 342, 339, 347, 664, 63, 1100, 63, 958, 8, 277, 12, 1511, 12, 1011, 958, 304, 267, 372, 2420, 2340, 63, 1247, 582, 1511, 14, 21707, 12, 298, 3990, 63, 21707, 582, 1511, 14, 3990, 93, 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, 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, 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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 ]
willl4/Final-Project
ggame/pygamedeps.py
228
12266
def module_exists(module_name): try: __import__(module_name) except ImportError: return False else: return True # PYTHON 3 and PYGAME DEPENDENCIES if module_exists('pygame'): import pygame class _body(object): def __init__(self): self.events = {} def appendChild(self, obj): self.child = obj def bind(self, evt, action): self.events[evt] = action print("Binding {} to {}".format(evt, action)) class _document(object): def __init__(self): self.body = _body() class _window(object): def __init__(self): self.document = _document() self.animatex = 0 def open(self, s1, s2): return self def requestAnimationFrame(self, target): if self.animatex < 10: self.animatex += 1 target('dummy') print("Animation frame") class _Container(object): def __init__(self): pass def destroy(self): pass class _Renderer(object): def __init__(self, x, y, argsdict): self.x = x self.y = y self.argsdict = argsdict self.view = 'view' print("Rendering created with {}x{} area".format(x, y)) def render(self, stage): pass class _GFX(object): def __init__(self): self.Container = _Container self.autoDetectRenderer = _Renderer window = _window() GFX = _GFX() #document = object() def JSConstructor(cls): return cls def JSObject(obj): return obj class _GFX_Rectangle(pygame.Rect): pass GFX_Rectangle = _GFX_Rectangle class _Texture(object): def __init__(self, img='', crossdomain=False): self.name = img if not img == '': self.img = pygame.image.load(img) # pygame surface self.basewidth = self.img.get_width() self.baseheight = self.img.get_height() self.width = self.basewidth self.height = self.baseheight print("Texture from image {}, {}x{} pixels".format(img, self.basewidth, self.baseheight)) self.baserect = _GFX_Rectangle(0, 0, self.basewidth, self.baseheight) self.framerect = self.baserect @classmethod def fromTexture(cls, texture, frame): inst = cls() inst.img = pygame.Surface((frame.width, frame.height)) inst.img.blit(texture.img, (0,0), frame) inst.name = texture.name inst.basewidth = texture.basewidth inst.baseheight = texture.baseheight inst.baserect = texture.baserect inst.framerect = frame inst.width = frame.width inst.height = frame.height print("Texture from base texture {}, {}x{} subframe {}x{}".format(inst.name, inst.basewidth, inst.baseheight, inst.framerect.width, inst.framerect.height)) return inst def destroy(self): try: self.img.close() print("Destroying an image") except: print("Destroying a non-image") GFX_Texture = _Texture.fromTexture GFX_Texture_fromImage = _Texture class vector(object): def __init__(self, x, y): self.x = x self.y = y def __getitem__(self, key): if key == 0: return self.x elif key == 1: return self.y else: raise KeyError def __setitem(self, key, value): if key == 0: self.x = value elif key == 1: self.y = value else: raise KeyError class GFX_Sprite(object): def __init__(self, texture): self.basetexture = texture self.texture = self.basetexture self.visible = True self.pos = vector(0,0) self.anch = vector(0,0) self.scal = vector(1.0, 1.0) self.width = texture.width self.height = texture.height self.rotation = 0.0 @property def position(self): return self.pos @position.setter def position(self, value): self.pos.x = value[0] self.pos.y = value[1] @property def anchor(self): return self.anch @anchor.setter def anchor(self, value): self.anch.x = value[0] self.anch.y = value[1] @property def scale(self): return self.scal @scale.setter def scale(self, value): self.scal.x = value[0] self.scal.y = value[1] def destroy(self): pass class _GFX_Graphics(object): def __init__(self): self.clear() def clear(self): self.cleared = True self.visible = True self.lwidth = None self.color = None self.alpha = None self.fillcolor = None self.fillalpha = None self.x = None self.y = None self.rwidth = None self.rheight = None self.radius = None self.ehw = None self.ehh = None self.xto = None self.yto = None self.jpath = None self.width = None self.height = None self.position = vector(0,0) def destroy(self): self.clear() def clone(self): clone = type(self)() clone.cleared = self.cleared clone.visible = self.visible clone.lwidth = self.lwidth clone.color = self.color clone.alpha = self.alpha clone.fillalpha = self.fillalpha clone.fillcolor = self.fillcolor clone.x = self.x clone.y = self.y clone.rwidth = self.rwidth clone.rheight = self.rheight clone.radius = self.radius clone.ehw = self.ehw clone.ehh = self.ehh clone.xto = self.xto clone.yto = self.yto clone.jpath = self.jpath clone.width = self.width clone.height = self.height clone.position = self.position return clone def lineStyle(self, width, color, alpha): self.width = width self.color = color self.alpha = alpha def beginFill(self, color, alpha): self.fillcolor = color self.fillalpha = alpha def drawRect(self, x, y, w, h): self.x = x self.y = y self.position = vector(x,y) self.rwidth = w self.rheight = h self.width = w self.height = h self.cleared = False print("Rectangle {}x{} at {},{}".format(w,h,x,y)) return self def drawCircle(self, x, y, radius): self.x = x self.y = y self.position = vector(x,y) self.radius = radius self.cleared = False self.width = radius*2 self.height = radius*2 print("Circle, radius {} at {},{}".format(radius,x,y)) return self def drawEllipse(self, x, y, hw, hh): self.x = x self.y = y self.position = vector(x,y) self.ehw = hw self.ehh = hh self.width = hw*2 self.height = hh*2 self.cleared = False print("Ellipse, {}x{} at {},{}".format(hw,hh,x,y)) return self def drawPolygon(self, jpath): self.jpath = jpath self.cleared = False self.position = vector(jpath[0],jpath[1]) x = [] y = [] for i in range(0,len(jpath)-1,2): x.append(jpath[i]) y.append(jpath[i+1]) self.width = max(x)-min(x) self.height = max(y)-min(y) print("Polygon") return self def moveTo(self, x, y): self.x = x self.y = y self.position = vector(x,y) return self def lineTo(self, x, y): self.xto = x self.yto = y self.width = abs(x) self.height = abs(y) self.cleared = False print("Line from {},{} to {},{}".format(self.x, self.y, x, y)) return self class _GFX_Text(object): def __init__(self, text, styledict): self.text = text self.styledict = styledict self.alpha = None self.visible = None self.width = 99 self.height = 99 self.position = vector(0,0) print("Text: {} in {}".format(text, styledict['font'])) def clone(self): clone = type(self)(self.text, self.styledict) return clone def destroy(self): self.text = '' GFX_Text = _GFX_Text _globalGraphics = _GFX_Graphics() GFX_Graphics = _globalGraphics def GFX_DetectRenderer(): pass class _SND_all(object): def __init__(self): pass def stop(self): print("Stopping all sounds") class _SND(object): def __init__(self): self.all = _SND_all SND = _SND() class _SND_Sound(object): def __init__(self, url): self.url = url print("Creating sound object {}".format(url)) def load(self): pass def play(self): print("Playing sound object {}".format(self.url)) SND_Sound = _SND_Sound class HwEvent(object): evtmap = {2: 'keydown', 3: 'keyup', 4: 'mousemove', 5: 'mousedown', 6: 'mouseup'} keymap = {304:16, 303:16, 306:17, 308:18, 301:20, 276:37, 273:38, 275:39, 274:40, 97:65, 98:66, 99:67, 100:68, 101:69, 102:70, 103:71, 104:72, 105:73, 106:74, 107:75, 108:76, 109:77, 110:78, 111:79, 112:80, 113:81, 114:82, 115:83, 116:84, 117:85, 118:86, 119:87, 120:88, 121:89, 122:90, 282:112, 283:113, 284:114, 285:115, 286:116, 287:117, 288:118, 289:119, 290:120, 291:121, 292:122, 293:123, 59:186, 61:187, 44:188, 46:190, 45:189, 47:191, 96:192, 92:220, 91:219, 93:221, 39:222} def __init__(self, pevent): self.type = HwEvent.evtmap.get(pevent.type, None) if self.type in ['keydown', 'keyup']: self.keyCode = HwEvent.keymap.get(pevent.key, pevent.key) elif self.type in ['mousemove', 'mousedown', 'mouseup']: self.wheelDelta = 0 if self.type != 'mousemove' and pevent.button == 5: if self.type == 'mousedown': self.wheelDelta = 1 else: self.wheelDelta = -1 self.clientX = pevent.pos[0] self.clientY = pevent.pos[1] class GFX_Window(object): def __init__(self, width, height, onclose): pygame.init() self._w = pygame.display.set_mode((width, height)) self.clock = pygame.time.Clock() self.sprites = [] self.animatestarted = False self.bindings = {} self.onclose = onclose self.stop = False #self._w = window.open("", "") #self._stage = JSConstructor(GFX.Container)() #self._renderer = GFX.autoDetectRenderer(width, height, {'transparent':True}) #self._w.document.body.appendChild(self._renderer.view) #self._w.onunload = onclose def bind(self, evtspec, callback): self.bindings[evtspec] = callback def add(self, obj): self.sprites.append(obj) #self._stage.addChild(obj) def remove(self, obj): self.sprites.remove(obj) #self._stage.removeChild(obj) def animate(self, stepcallback): # do stuff required to display self._w.fill(pygame.Color('white')) for s in self.sprites: self._w.blit(s.texture.img, (s.pos.x, s.pos.y)) pygame.display.flip() events = pygame.event.get() for event in events: hwevent = HwEvent(event) if hwevent.type != None: self.bindings[hwevent.type](hwevent) if event.type == 12: print("Close!") self.onclose() self.destroy() self.stop = True if not self.animatestarted: self.animatestarted = True while not self.stop: self.clock.tick_busy_loop(30) stepcallback(0) #self._renderer.render(self._stage) #self._w.requestAnimationFrame(stepcallback) def destroy(self): pass #SND.all().stop() #self._stage.destroy()
mit
[ 318, 859, 63, 2444, 8, 578, 63, 354, 304, 272, 862, 26, 267, 636, 646, 721, 578, 63, 354, 9, 272, 871, 3545, 26, 267, 372, 756, 272, 587, 26, 267, 372, 715, 199, 199, 3, 18280, 650, 436, 7843, 39, 1991, 30850, 3902, 9415, 2563, 199, 692, 859, 63, 2444, 360, 22278, 735, 819, 492, 9193, 12244, 1021, 485, 2030, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 304, 489, 291, 14, 4368, 275, 1052, 339, 347, 5666, 3493, 8, 277, 12, 1559, 304, 489, 291, 14, 1739, 275, 1559, 339, 347, 5398, 8, 277, 12, 16330, 12, 1595, 304, 489, 291, 14, 4368, 59, 19296, 61, 275, 1595, 489, 870, 480, 17490, 1052, 370, 8352, 908, 8, 19296, 12, 1595, 430, 819, 1021, 485, 3554, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 304, 489, 291, 14, 2030, 275, 485, 2030, 342, 819, 1021, 485, 3806, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 489, 291, 14, 3554, 275, 485, 3554, 342, 489, 291, 14, 27062, 88, 275, 378, 339, 347, 1551, 8, 277, 12, 308, 17, 12, 308, 18, 304, 489, 372, 291, 339, 347, 1056, 15957, 3160, 8, 277, 12, 1347, 304, 489, 340, 291, 14, 27062, 88, 665, 1616, 26, 267, 291, 14, 27062, 88, 847, 413, 267, 1347, 360, 5869, 358, 267, 870, 480, 15957, 2787, 531, 819, 1021, 485, 4076, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 489, 986, 339, 347, 11972, 8, 277, 304, 489, 986, 819, 1021, 485, 11355, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 12, 671, 12, 612, 12, 1249, 807, 304, 489, 291, 14, 88, 275, 671, 489, 291, 14, 89, 275, 612, 489, 291, 14, 589, 807, 275, 1249, 807, 489, 291, 14, 1345, 275, 283, 1345, 7, 489, 870, 480, 9216, 316, 2737, 543, 1052, 88, 2440, 9150, 1674, 908, 8, 88, 12, 612, 430, 339, 347, 3795, 8, 277, 12, 9546, 304, 489, 986, 819, 1021, 485, 17395, 56, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 304, 489, 291, 14, 4076, 275, 485, 4076, 489, 291, 14, 2495, 20064, 11355, 275, 485, 11355, 819, 4353, 275, 485, 3806, 342, 819, 598, 22322, 275, 485, 17395, 56, 342, 819, 327, 3554, 275, 909, 342, 12244, 347, 18001, 11447, 8, 1886, 304, 272, 372, 843, 27404, 347, 18001, 1692, 8, 1113, 304, 272, 372, 1559, 12244, 1021, 485, 17395, 56, 63, 18127, 8, 22278, 14, 8252, 304, 272, 986, 12244, 598, 22322, 63, 18127, 275, 485, 17395, 56, 63, 18127, 523, 523, 1021, 485, 17165, 8, 785, 304, 20950, 347, 636, 826, 721, 277, 12, 6050, 4581, 8059, 2261, 29, 797, 304, 489, 291, 14, 354, 275, 6050, 489, 340, 440, 6050, 508, 8061, 267, 291, 14, 4060, 275, 9193, 14, 1569, 14, 912, 8, 4060, 9, 221, 327, 9193, 13195, 267, 291, 14, 1095, 2063, 275, 291, 14, 4060, 14, 362, 63, 2063, 342, 267, 291, 14, 1095, 3333, 275, 291, 14, 4060, 14, 362, 63, 3333, 342, 267, 291, 14, 2063, 275, 291, 14, 1095, 2063, 267, 291, 14, 3333, 275, 291, 14, 1095, 3333, 267, 870, 480, 17165, 687, 1834, 5479, 1052, 88, 2440, 11094, 1674, 908, 8, 4060, 12, 291, 14, 1095, 2063, 12, 291, 14, 1095, 3333, 430, 267, 291, 14, 1095, 1201, 275, 485, 17395, 56, 63, 18127, 8, 16, 12, 378, 12, 291, 14, 1095, 2063, 12, 291, 14, 1095, 3333, 9, 267, 291, 14, 1943, 1201, 275, 291, 14, 1095, 1201, 339, 768, 3744, 272, 347, 687, 17165, 8, 1886, 12, 14855, 12, 2787, 304, 489, 2727, 275, 843, 342, 489, 2727, 14, 4060, 275, 9193, 14, 16923, 1332, 1943, 14, 2063, 12, 2787, 14, 3333, 430, 489, 2727, 14, 4060, 14, 15574, 8, 12611, 14, 4060, 12, 334, 16, 12, 16, 395, 2787, 9, 489, 2727, 14, 354, 275, 14855, 14, 354, 489, 2727, 14, 1095, 2063, 275, 14855, 14, 1095, 2063, 489, 2727, 14, 1095, 3333, 275, 14855, 14, 1095, 3333, 489, 2727, 14, 1095, 1201, 275, 14855, 14, 1095, 1201, 489, 2727, 14, 1943, 1201, 275, 2787, 489, 2727, 14, 2063, 275, 2787, 14, 2063, 489, 2727, 14, 3333, 275, 2787, 14, 3333, 489, 870, 480, 17165, 687, 1300, 14855, 5479, 1052, 88, 2440, 1007, 1943, 1052, 88, 13536, 908, 8, 3615, 14, 354, 12, 2727, 14, 1095, 2063, 12, 2727, 14, 1095, 3333, 12, 2727, 14, 1943, 1201, 14, 2063, 12, 2727, 14, 1943, 1201, 14, 3333, 430, 489, 372, 2727, 339, 347, 11972, 8, 277, 304, 489, 862, 26, 267, 291, 14, 4060, 14, 1600, 342, 267, 870, 480, 14704, 316, 376, 1834, 531, 489, 871, 26, 267, 870, 480, 14704, 316, 282, 2222, 13, 1569, 531, 819, 598, 22322, 63, 17165, 275, 485, 17165, 14, 504, 17165, 12244, 598, 22322, 63, 17165, 63, 504, 3491, 275, 485, 17165, 257, 8330, 1021, 5477, 8, 785, 304, 2043, 272, 347, 636, 826, 721, 277, 12, 671, 12, 612, 304, 489, 291, 14, 88, 275, 671, 489, 291, 14, 89, 275, 612, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 489, 340, 790, 508, 378, 26, 267, 372, 291, 14, 88, 489, 916, 790, 508, 413, 26, 267, 372, 291, 14, 89, 489, 587, 26, 267, 746, 4067, 339, 347, 636, 8617, 8, 277, 12, 790, 12, 574, 304, 489, 340, 790, 508, 378, 26, 267, 291, 14, 88, 275, 574, 489, 916, 790, 508, 413, 26, 267, 291, 14, 89, 275, 574, 489, 587, 26, 267, 746, 4067, 12244, 1021, 598, 22322, 63, 30185, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 12, 14855, 304, 489, 291, 14, 1095, 12611, 275, 14855, 489, 291, 14, 12611, 275, 291, 14, 1095, 12611, 489, 291, 14, 6604, 275, 715, 489, 291, 14, 1712, 275, 5477, 8, 16, 12, 16, 9, 489, 291, 14, 290, 335, 275, 5477, 8, 16, 12, 16, 9, 489, 291, 14, 4732, 275, 5477, 8, 17, 14, 16, 12, 413, 14, 16, 9, 489, 291, 14, 2063, 275, 14855, 14, 2063, 489, 291, 14, 3333, 275, 14855, 14, 3333, 489, 291, 14, 15362, 275, 378, 14, 16, 339, 768, 1829, 272, 347, 3421, 8 ]
[ 859, 63, 2444, 8, 578, 63, 354, 304, 272, 862, 26, 267, 636, 646, 721, 578, 63, 354, 9, 272, 871, 3545, 26, 267, 372, 756, 272, 587, 26, 267, 372, 715, 199, 199, 3, 18280, 650, 436, 7843, 39, 1991, 30850, 3902, 9415, 2563, 199, 692, 859, 63, 2444, 360, 22278, 735, 819, 492, 9193, 12244, 1021, 485, 2030, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 304, 489, 291, 14, 4368, 275, 1052, 339, 347, 5666, 3493, 8, 277, 12, 1559, 304, 489, 291, 14, 1739, 275, 1559, 339, 347, 5398, 8, 277, 12, 16330, 12, 1595, 304, 489, 291, 14, 4368, 59, 19296, 61, 275, 1595, 489, 870, 480, 17490, 1052, 370, 8352, 908, 8, 19296, 12, 1595, 430, 819, 1021, 485, 3554, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 304, 489, 291, 14, 2030, 275, 485, 2030, 342, 819, 1021, 485, 3806, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 489, 291, 14, 3554, 275, 485, 3554, 342, 489, 291, 14, 27062, 88, 275, 378, 339, 347, 1551, 8, 277, 12, 308, 17, 12, 308, 18, 304, 489, 372, 291, 339, 347, 1056, 15957, 3160, 8, 277, 12, 1347, 304, 489, 340, 291, 14, 27062, 88, 665, 1616, 26, 267, 291, 14, 27062, 88, 847, 413, 267, 1347, 360, 5869, 358, 267, 870, 480, 15957, 2787, 531, 819, 1021, 485, 4076, 8, 785, 304, 339, 347, 636, 826, 721, 277, 304, 489, 986, 339, 347, 11972, 8, 277, 304, 489, 986, 819, 1021, 485, 11355, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 12, 671, 12, 612, 12, 1249, 807, 304, 489, 291, 14, 88, 275, 671, 489, 291, 14, 89, 275, 612, 489, 291, 14, 589, 807, 275, 1249, 807, 489, 291, 14, 1345, 275, 283, 1345, 7, 489, 870, 480, 9216, 316, 2737, 543, 1052, 88, 2440, 9150, 1674, 908, 8, 88, 12, 612, 430, 339, 347, 3795, 8, 277, 12, 9546, 304, 489, 986, 819, 1021, 485, 17395, 56, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 304, 489, 291, 14, 4076, 275, 485, 4076, 489, 291, 14, 2495, 20064, 11355, 275, 485, 11355, 819, 4353, 275, 485, 3806, 342, 819, 598, 22322, 275, 485, 17395, 56, 342, 819, 327, 3554, 275, 909, 342, 12244, 347, 18001, 11447, 8, 1886, 304, 272, 372, 843, 27404, 347, 18001, 1692, 8, 1113, 304, 272, 372, 1559, 12244, 1021, 485, 17395, 56, 63, 18127, 8, 22278, 14, 8252, 304, 272, 986, 12244, 598, 22322, 63, 18127, 275, 485, 17395, 56, 63, 18127, 523, 523, 1021, 485, 17165, 8, 785, 304, 20950, 347, 636, 826, 721, 277, 12, 6050, 4581, 8059, 2261, 29, 797, 304, 489, 291, 14, 354, 275, 6050, 489, 340, 440, 6050, 508, 8061, 267, 291, 14, 4060, 275, 9193, 14, 1569, 14, 912, 8, 4060, 9, 221, 327, 9193, 13195, 267, 291, 14, 1095, 2063, 275, 291, 14, 4060, 14, 362, 63, 2063, 342, 267, 291, 14, 1095, 3333, 275, 291, 14, 4060, 14, 362, 63, 3333, 342, 267, 291, 14, 2063, 275, 291, 14, 1095, 2063, 267, 291, 14, 3333, 275, 291, 14, 1095, 3333, 267, 870, 480, 17165, 687, 1834, 5479, 1052, 88, 2440, 11094, 1674, 908, 8, 4060, 12, 291, 14, 1095, 2063, 12, 291, 14, 1095, 3333, 430, 267, 291, 14, 1095, 1201, 275, 485, 17395, 56, 63, 18127, 8, 16, 12, 378, 12, 291, 14, 1095, 2063, 12, 291, 14, 1095, 3333, 9, 267, 291, 14, 1943, 1201, 275, 291, 14, 1095, 1201, 339, 768, 3744, 272, 347, 687, 17165, 8, 1886, 12, 14855, 12, 2787, 304, 489, 2727, 275, 843, 342, 489, 2727, 14, 4060, 275, 9193, 14, 16923, 1332, 1943, 14, 2063, 12, 2787, 14, 3333, 430, 489, 2727, 14, 4060, 14, 15574, 8, 12611, 14, 4060, 12, 334, 16, 12, 16, 395, 2787, 9, 489, 2727, 14, 354, 275, 14855, 14, 354, 489, 2727, 14, 1095, 2063, 275, 14855, 14, 1095, 2063, 489, 2727, 14, 1095, 3333, 275, 14855, 14, 1095, 3333, 489, 2727, 14, 1095, 1201, 275, 14855, 14, 1095, 1201, 489, 2727, 14, 1943, 1201, 275, 2787, 489, 2727, 14, 2063, 275, 2787, 14, 2063, 489, 2727, 14, 3333, 275, 2787, 14, 3333, 489, 870, 480, 17165, 687, 1300, 14855, 5479, 1052, 88, 2440, 1007, 1943, 1052, 88, 13536, 908, 8, 3615, 14, 354, 12, 2727, 14, 1095, 2063, 12, 2727, 14, 1095, 3333, 12, 2727, 14, 1943, 1201, 14, 2063, 12, 2727, 14, 1943, 1201, 14, 3333, 430, 489, 372, 2727, 339, 347, 11972, 8, 277, 304, 489, 862, 26, 267, 291, 14, 4060, 14, 1600, 342, 267, 870, 480, 14704, 316, 376, 1834, 531, 489, 871, 26, 267, 870, 480, 14704, 316, 282, 2222, 13, 1569, 531, 819, 598, 22322, 63, 17165, 275, 485, 17165, 14, 504, 17165, 12244, 598, 22322, 63, 17165, 63, 504, 3491, 275, 485, 17165, 257, 8330, 1021, 5477, 8, 785, 304, 2043, 272, 347, 636, 826, 721, 277, 12, 671, 12, 612, 304, 489, 291, 14, 88, 275, 671, 489, 291, 14, 89, 275, 612, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 489, 340, 790, 508, 378, 26, 267, 372, 291, 14, 88, 489, 916, 790, 508, 413, 26, 267, 372, 291, 14, 89, 489, 587, 26, 267, 746, 4067, 339, 347, 636, 8617, 8, 277, 12, 790, 12, 574, 304, 489, 340, 790, 508, 378, 26, 267, 291, 14, 88, 275, 574, 489, 916, 790, 508, 413, 26, 267, 291, 14, 89, 275, 574, 489, 587, 26, 267, 746, 4067, 12244, 1021, 598, 22322, 63, 30185, 8, 785, 304, 2286, 347, 636, 826, 721, 277, 12, 14855, 304, 489, 291, 14, 1095, 12611, 275, 14855, 489, 291, 14, 12611, 275, 291, 14, 1095, 12611, 489, 291, 14, 6604, 275, 715, 489, 291, 14, 1712, 275, 5477, 8, 16, 12, 16, 9, 489, 291, 14, 290, 335, 275, 5477, 8, 16, 12, 16, 9, 489, 291, 14, 4732, 275, 5477, 8, 17, 14, 16, 12, 413, 14, 16, 9, 489, 291, 14, 2063, 275, 14855, 14, 2063, 489,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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 ]
conan-io/conan
conans/client/remover.py
1
11380
import os from conans.client.cache.remote_registry import Remote from conans.errors import ConanException, PackageNotFoundException, RecipeNotFoundException from conans.errors import NotFoundException from conans.model.ref import ConanFileReference, PackageReference, check_valid_ref from conans.paths import SYSTEM_REQS, rm_conandir from conans.search.search import filter_outdated, search_packages, search_recipes from conans.util.log import logger class DiskRemover(object): def _remove(self, path, ref, msg=""): try: logger.debug("REMOVE: folder %s" % path) rm_conandir(path) except OSError: error_msg = "Folder busy (open or some file open): %s" % path raise ConanException("%s: Unable to remove %s\n\t%s" % (repr(ref), msg, error_msg)) def _remove_file(self, path, ref, msg=""): try: logger.debug("REMOVE: file %s" % path) if os.path.exists(path): os.remove(path) except OSError: error_msg = "File busy (open): %s" % path raise ConanException("Unable to remove %s %s\n\t%s" % (repr(ref), msg, error_msg)) def remove_recipe(self, package_layout, output): self.remove_src(package_layout) package_layout.export_remove() for f in package_layout.conanfile_lock_files(output=output): try: os.remove(f) except OSError: pass def remove(self, package_layout, output): self.remove_recipe(package_layout, output=output) self.remove_builds(package_layout) self.remove_packages(package_layout) self._remove(package_layout.base_folder(), package_layout.ref) def remove_src(self, package_layout): package_layout.sources_remove() def remove_builds(self, package_layout, ids=None): if not ids: path = package_layout.builds() for build in package_layout.conan_builds(): self._remove(os.path.join(path, build), package_layout.ref, "build folder:%s" % build) self._remove(path, package_layout.ref, "builds") else: for id_ in ids: # Removal build IDs should be those of the build_id if present pkg_path = package_layout.build(PackageReference(package_layout.ref, id_)) self._remove(pkg_path, package_layout.ref, "package:%s" % id_) def remove_packages(self, package_layout, ids_filter=None): if not ids_filter: # Remove all path = package_layout.packages() # Necessary for short_paths removal for package_id in package_layout.package_ids(): pref = PackageReference(package_layout.ref, package_id) package_layout.package_remove(pref) self._remove(path, package_layout.ref, "packages") self._remove_file(package_layout.system_reqs(), package_layout.ref, SYSTEM_REQS) else: for package_id in ids_filter: # remove just the specified packages pref = PackageReference(package_layout.ref, package_id) if not package_layout.package_exists(pref): raise PackageNotFoundException(pref) package_layout.package_remove(pref) self._remove_file(package_layout.system_reqs_package(pref), package_layout.ref, "%s/%s" % (package_id, SYSTEM_REQS)) class ConanRemover(object): """ Class responsible for removing locally/remotely conans, package folders, etc. """ def __init__(self, cache, remote_manager, user_io, remotes): self._user_io = user_io self._cache = cache self._remote_manager = remote_manager self._remotes = remotes def _remote_remove(self, ref, package_ids, remote): assert(isinstance(remote, Remote)) if package_ids is None: result = self._remote_manager.remove_recipe(ref, remote) return result else: tmp = self._remote_manager.remove_packages(ref, package_ids, remote) return tmp @staticmethod def _message_removing_editable(ref): return "Package '{r}' is installed as editable, remove it first using " \ "command 'conan editable remove {r}'".format(r=ref) def _local_remove(self, ref, src, build_ids, package_ids): if self._cache.installed_as_editable(ref): self._user_io.out.warn(self._message_removing_editable(ref)) return # Get the package layout using 'short_paths=False', remover will make use of the # function 'rm_conandir' which already takes care of the linked folder. package_layout = self._cache.package_layout(ref, short_paths=False) package_layout.remove_package_locks() # Make sure to clean the locks too remover = DiskRemover() if src: remover.remove_src(package_layout) if build_ids is not None: remover.remove_builds(package_layout, build_ids) if package_ids is not None: remover.remove_packages(package_layout, package_ids) with package_layout.update_metadata() as metadata: for package_id in package_ids: metadata.clear_package(package_id) if not src and build_ids is None and package_ids is None: remover.remove(package_layout, output=self._user_io.out) def remove(self, pattern, remote_name, src=None, build_ids=None, package_ids_filter=None, force=False, packages_query=None, outdated=False): """ Remove local/remote conans, package folders, etc. @param src: Remove src folder @param pattern: it could be OpenCV* or OpenCV or a ConanFileReference @param build_ids: Lists with ids or empty for all. (Its a filter) @param package_ids_filter: Lists with ids or empty for all. (Its a filter) @param force: if True, it will be deleted without requesting anything @param packages_query: Only if src is a reference. Query settings and options """ if remote_name and (build_ids is not None or src): raise ConanException("Remotes don't have 'build' or 'src' folder, just packages") is_reference = check_valid_ref(pattern) input_ref = ConanFileReference.loads(pattern) if is_reference else None if not input_ref and packages_query is not None: raise ConanException("query parameter only allowed with a valid recipe " "reference as the search pattern.") if input_ref and package_ids_filter and not input_ref.revision: for package_id in package_ids_filter: if "#" in package_id: raise ConanException("Specify a recipe revision if you specify a package " "revision") if remote_name: remote = self._remotes[remote_name] if input_ref: if not self._cache.config.revisions_enabled and input_ref.revision: raise ConanException("Revisions not enabled in the client, cannot remove " "revisions in the server") refs = [input_ref] else: refs = self._remote_manager.search_recipes(remote, pattern) else: if input_ref: refs = [] if self._cache.installed_as_editable(input_ref): raise ConanException(self._message_removing_editable(input_ref)) if not self._cache.package_layout(input_ref).recipe_exists(): raise RecipeNotFoundException(input_ref, print_rev=self._cache.config.revisions_enabled) refs.append(input_ref) else: refs = search_recipes(self._cache, pattern) if not refs: self._user_io.out.warn("No package recipe matches '%s'" % str(pattern)) return if input_ref and not input_ref.revision: # Ignore revisions for deleting if the input was not with a revision # (Removing all the recipe revisions from a reference) refs = [r.copy_clear_rev() for r in refs] deleted_refs = [] for ref in refs: assert isinstance(ref, ConanFileReference) package_layout = self._cache.package_layout(ref) package_ids = package_ids_filter if packages_query or outdated: # search packages if remote_name: packages = self._remote_manager.search_packages(remote, ref, packages_query) else: packages = search_packages(package_layout, packages_query) if outdated: if remote_name: manifest, ref = self._remote_manager.get_recipe_manifest(ref, remote) recipe_hash = manifest.summary_hash else: recipe_hash = package_layout.recipe_manifest().summary_hash packages = filter_outdated(packages, recipe_hash) if package_ids_filter: package_ids = [p for p in packages if p in package_ids_filter] else: package_ids = list(packages.keys()) if not package_ids: self._user_io.out.warn("No matching packages to remove for %s" % ref.full_str()) continue if self._ask_permission(ref, src, build_ids, package_ids, force): try: if remote_name: self._remote_remove(ref, package_ids, remote) else: self._local_remove(ref, src, build_ids, package_ids) except NotFoundException: # If we didn't specify a pattern but a concrete ref, fail if there is no # ref to remove if input_ref: raise else: deleted_refs.append(ref) if not remote_name: self._cache.delete_empty_dirs(deleted_refs) def _ask_permission(self, ref, src, build_ids, package_ids_filter, force): def stringlist(alist): return ", ".join(['"%s"' % p for p in alist]) if force: return True aux_str = [] if src: aux_str.append(" src folder") if build_ids is not None: if build_ids: aux_str.append(" %s builds" % stringlist(build_ids)) else: aux_str.append(" all builds") if package_ids_filter is not None: if package_ids_filter: aux_str.append(" %s packages" % stringlist(package_ids_filter)) else: # All packages to remove, no filter aux_str.append(" all packages") return self._user_io.request_boolean("Are you sure you want to delete%s from '%s'" % (", ".join(aux_str), str(ref)))
mit
[ 646, 747, 199, 199, 504, 406, 796, 14, 1258, 14, 1637, 14, 3846, 63, 5189, 492, 17283, 199, 504, 406, 796, 14, 2550, 492, 1448, 290, 1726, 12, 15665, 22646, 12, 799, 8233, 22646, 199, 504, 406, 796, 14, 2550, 492, 21909, 1726, 199, 504, 406, 796, 14, 1238, 14, 1121, 492, 1448, 290, 26044, 12, 15665, 5083, 12, 1104, 63, 1078, 63, 1121, 199, 504, 406, 796, 14, 3771, 492, 20859, 63, 14583, 51, 12, 14267, 63, 388, 290, 694, 199, 504, 406, 796, 14, 1733, 14, 1733, 492, 2457, 63, 548, 19074, 12, 2754, 63, 5154, 12, 2754, 63, 25200, 199, 504, 406, 796, 14, 1974, 14, 793, 492, 2512, 421, 199, 533, 26287, 497, 573, 422, 8, 785, 304, 339, 347, 485, 2168, 8, 277, 12, 931, 12, 2984, 12, 1499, 17364, 267, 862, 26, 288, 2512, 14, 1757, 480, 25856, 26, 4922, 450, 83, 2, 450, 931, 9, 288, 14267, 63, 388, 290, 694, 8, 515, 9, 267, 871, 6440, 26, 288, 1125, 63, 1328, 275, 298, 7850, 10414, 89, 334, 1490, 503, 2005, 570, 1551, 304, 450, 83, 2, 450, 931, 288, 746, 1448, 290, 1726, 3647, 83, 26, 30849, 370, 2813, 450, 83, 60, 78, 60, 84, 5, 83, 2, 450, 334, 2722, 8, 1121, 395, 1499, 12, 1125, 63, 1328, 430, 339, 347, 485, 2168, 63, 493, 8, 277, 12, 931, 12, 2984, 12, 1499, 17364, 267, 862, 26, 288, 2512, 14, 1757, 480, 25856, 26, 570, 450, 83, 2, 450, 931, 9, 288, 340, 747, 14, 515, 14, 2444, 8, 515, 304, 355, 747, 14, 2168, 8, 515, 9, 267, 871, 6440, 26, 288, 1125, 63, 1328, 275, 298, 1173, 10414, 89, 334, 1490, 304, 450, 83, 2, 450, 931, 288, 746, 1448, 290, 1726, 480, 6005, 370, 2813, 450, 83, 450, 83, 60, 78, 60, 84, 5, 83, 2, 450, 334, 2722, 8, 1121, 395, 1499, 12, 1125, 63, 1328, 430, 339, 347, 2813, 63, 13191, 8, 277, 12, 2559, 63, 4209, 12, 1072, 304, 267, 291, 14, 2168, 63, 2164, 8, 2491, 63, 4209, 9, 267, 2559, 63, 4209, 14, 3790, 63, 2168, 342, 267, 367, 289, 315, 2559, 63, 4209, 14, 388, 290, 493, 63, 831, 63, 1725, 8, 1199, 29, 1199, 304, 288, 862, 26, 355, 747, 14, 2168, 8, 70, 9, 288, 871, 6440, 26, 355, 986, 339, 347, 2813, 8, 277, 12, 2559, 63, 4209, 12, 1072, 304, 267, 291, 14, 2168, 63, 13191, 8, 2491, 63, 4209, 12, 1072, 29, 1199, 9, 267, 291, 14, 2168, 63, 10838, 8, 2491, 63, 4209, 9, 267, 291, 14, 2168, 63, 5154, 8, 2491, 63, 4209, 9, 267, 291, 423, 2168, 8, 2491, 63, 4209, 14, 1095, 63, 3741, 1062, 2559, 63, 4209, 14, 1121, 9, 339, 347, 2813, 63, 2164, 8, 277, 12, 2559, 63, 4209, 304, 267, 2559, 63, 4209, 14, 4553, 63, 2168, 342, 339, 347, 2813, 63, 10838, 8, 277, 12, 2559, 63, 4209, 12, 2762, 29, 403, 304, 267, 340, 440, 2762, 26, 288, 931, 275, 2559, 63, 4209, 14, 10838, 342, 288, 367, 1900, 315, 2559, 63, 4209, 14, 388, 290, 63, 10838, 837, 355, 291, 423, 2168, 8, 736, 14, 515, 14, 904, 8, 515, 12, 1900, 395, 2559, 63, 4209, 14, 1121, 12, 2490, 298, 1506, 4922, 2689, 83, 2, 450, 1900, 9, 288, 291, 423, 2168, 8, 515, 12, 2559, 63, 4209, 14, 1121, 12, 298, 10838, 531, 267, 587, 26, 288, 367, 1305, 63, 315, 2762, 26, 355, 327, 799, 14128, 1900, 11449, 1077, 506, 5204, 402, 314, 1900, 63, 344, 340, 3451, 355, 5496, 63, 515, 275, 2559, 63, 4209, 14, 1506, 8, 8599, 5083, 8, 2491, 63, 4209, 14, 1121, 12, 1305, 13309, 355, 291, 423, 2168, 8, 4600, 63, 515, 12, 2559, 63, 4209, 14, 1121, 12, 298, 2491, 2689, 83, 2, 450, 1305, 4602, 339, 347, 2813, 63, 5154, 8, 277, 12, 2559, 63, 4209, 12, 2762, 63, 1541, 29, 403, 304, 267, 340, 440, 2762, 63, 1541, 26, 221, 327, 5852, 1006, 288, 931, 275, 2559, 63, 4209, 14, 5154, 342, 288, 327, 5612, 5205, 367, 3974, 63, 3771, 20055, 288, 367, 2559, 63, 344, 315, 2559, 63, 4209, 14, 2491, 63, 1580, 837, 355, 20491, 275, 15665, 5083, 8, 2491, 63, 4209, 14, 1121, 12, 2559, 63, 344, 9, 355, 2559, 63, 4209, 14, 2491, 63, 2168, 8, 13829, 9, 288, 291, 423, 2168, 8, 515, 12, 2559, 63, 4209, 14, 1121, 12, 298, 5154, 531, 288, 291, 423, 2168, 63, 493, 8, 2491, 63, 4209, 14, 2253, 63, 12720, 1062, 2559, 63, 4209, 14, 1121, 12, 20859, 63, 14583, 51, 9, 267, 587, 26, 288, 367, 2559, 63, 344, 315, 2762, 63, 1541, 26, 221, 327, 2813, 2951, 314, 2013, 6117, 355, 20491, 275, 15665, 5083, 8, 2491, 63, 4209, 14, 1121, 12, 2559, 63, 344, 9, 355, 340, 440, 2559, 63, 4209, 14, 2491, 63, 2444, 8, 13829, 304, 490, 746, 15665, 22646, 8, 13829, 9, 355, 2559, 63, 4209, 14, 2491, 63, 2168, 8, 13829, 9, 355, 291, 423, 2168, 63, 493, 8, 2491, 63, 4209, 14, 2253, 63, 12720, 63, 2491, 8, 13829, 395, 2559, 63, 4209, 14, 1121, 12, 3303, 2071, 83, 3149, 83, 2, 450, 334, 2491, 63, 344, 12, 20859, 63, 14583, 51, 430, 421, 199, 533, 1448, 290, 497, 573, 422, 8, 785, 304, 272, 408, 8089, 17845, 367, 12881, 17738, 15, 3846, 590, 406, 796, 12, 2559, 16533, 12, 5423, 14, 408, 339, 347, 636, 826, 721, 277, 12, 2581, 12, 3982, 63, 2609, 12, 922, 63, 2308, 12, 32178, 744, 304, 267, 291, 423, 751, 63, 2308, 275, 922, 63, 2308, 267, 291, 423, 1637, 275, 2581, 267, 291, 423, 3846, 63, 2609, 275, 3982, 63, 2609, 267, 291, 423, 21420, 744, 275, 32178, 744, 339, 347, 485, 3846, 63, 2168, 8, 277, 12, 2984, 12, 2559, 63, 1580, 12, 3982, 304, 267, 702, 8, 6074, 8, 3846, 12, 17283, 430, 267, 340, 2559, 63, 1580, 365, 488, 26, 288, 754, 275, 291, 423, 3846, 63, 2609, 14, 2168, 63, 13191, 8, 1121, 12, 3982, 9, 288, 372, 754, 267, 587, 26, 288, 3529, 275, 291 ]
[ 747, 199, 199, 504, 406, 796, 14, 1258, 14, 1637, 14, 3846, 63, 5189, 492, 17283, 199, 504, 406, 796, 14, 2550, 492, 1448, 290, 1726, 12, 15665, 22646, 12, 799, 8233, 22646, 199, 504, 406, 796, 14, 2550, 492, 21909, 1726, 199, 504, 406, 796, 14, 1238, 14, 1121, 492, 1448, 290, 26044, 12, 15665, 5083, 12, 1104, 63, 1078, 63, 1121, 199, 504, 406, 796, 14, 3771, 492, 20859, 63, 14583, 51, 12, 14267, 63, 388, 290, 694, 199, 504, 406, 796, 14, 1733, 14, 1733, 492, 2457, 63, 548, 19074, 12, 2754, 63, 5154, 12, 2754, 63, 25200, 199, 504, 406, 796, 14, 1974, 14, 793, 492, 2512, 421, 199, 533, 26287, 497, 573, 422, 8, 785, 304, 339, 347, 485, 2168, 8, 277, 12, 931, 12, 2984, 12, 1499, 17364, 267, 862, 26, 288, 2512, 14, 1757, 480, 25856, 26, 4922, 450, 83, 2, 450, 931, 9, 288, 14267, 63, 388, 290, 694, 8, 515, 9, 267, 871, 6440, 26, 288, 1125, 63, 1328, 275, 298, 7850, 10414, 89, 334, 1490, 503, 2005, 570, 1551, 304, 450, 83, 2, 450, 931, 288, 746, 1448, 290, 1726, 3647, 83, 26, 30849, 370, 2813, 450, 83, 60, 78, 60, 84, 5, 83, 2, 450, 334, 2722, 8, 1121, 395, 1499, 12, 1125, 63, 1328, 430, 339, 347, 485, 2168, 63, 493, 8, 277, 12, 931, 12, 2984, 12, 1499, 17364, 267, 862, 26, 288, 2512, 14, 1757, 480, 25856, 26, 570, 450, 83, 2, 450, 931, 9, 288, 340, 747, 14, 515, 14, 2444, 8, 515, 304, 355, 747, 14, 2168, 8, 515, 9, 267, 871, 6440, 26, 288, 1125, 63, 1328, 275, 298, 1173, 10414, 89, 334, 1490, 304, 450, 83, 2, 450, 931, 288, 746, 1448, 290, 1726, 480, 6005, 370, 2813, 450, 83, 450, 83, 60, 78, 60, 84, 5, 83, 2, 450, 334, 2722, 8, 1121, 395, 1499, 12, 1125, 63, 1328, 430, 339, 347, 2813, 63, 13191, 8, 277, 12, 2559, 63, 4209, 12, 1072, 304, 267, 291, 14, 2168, 63, 2164, 8, 2491, 63, 4209, 9, 267, 2559, 63, 4209, 14, 3790, 63, 2168, 342, 267, 367, 289, 315, 2559, 63, 4209, 14, 388, 290, 493, 63, 831, 63, 1725, 8, 1199, 29, 1199, 304, 288, 862, 26, 355, 747, 14, 2168, 8, 70, 9, 288, 871, 6440, 26, 355, 986, 339, 347, 2813, 8, 277, 12, 2559, 63, 4209, 12, 1072, 304, 267, 291, 14, 2168, 63, 13191, 8, 2491, 63, 4209, 12, 1072, 29, 1199, 9, 267, 291, 14, 2168, 63, 10838, 8, 2491, 63, 4209, 9, 267, 291, 14, 2168, 63, 5154, 8, 2491, 63, 4209, 9, 267, 291, 423, 2168, 8, 2491, 63, 4209, 14, 1095, 63, 3741, 1062, 2559, 63, 4209, 14, 1121, 9, 339, 347, 2813, 63, 2164, 8, 277, 12, 2559, 63, 4209, 304, 267, 2559, 63, 4209, 14, 4553, 63, 2168, 342, 339, 347, 2813, 63, 10838, 8, 277, 12, 2559, 63, 4209, 12, 2762, 29, 403, 304, 267, 340, 440, 2762, 26, 288, 931, 275, 2559, 63, 4209, 14, 10838, 342, 288, 367, 1900, 315, 2559, 63, 4209, 14, 388, 290, 63, 10838, 837, 355, 291, 423, 2168, 8, 736, 14, 515, 14, 904, 8, 515, 12, 1900, 395, 2559, 63, 4209, 14, 1121, 12, 2490, 298, 1506, 4922, 2689, 83, 2, 450, 1900, 9, 288, 291, 423, 2168, 8, 515, 12, 2559, 63, 4209, 14, 1121, 12, 298, 10838, 531, 267, 587, 26, 288, 367, 1305, 63, 315, 2762, 26, 355, 327, 799, 14128, 1900, 11449, 1077, 506, 5204, 402, 314, 1900, 63, 344, 340, 3451, 355, 5496, 63, 515, 275, 2559, 63, 4209, 14, 1506, 8, 8599, 5083, 8, 2491, 63, 4209, 14, 1121, 12, 1305, 13309, 355, 291, 423, 2168, 8, 4600, 63, 515, 12, 2559, 63, 4209, 14, 1121, 12, 298, 2491, 2689, 83, 2, 450, 1305, 4602, 339, 347, 2813, 63, 5154, 8, 277, 12, 2559, 63, 4209, 12, 2762, 63, 1541, 29, 403, 304, 267, 340, 440, 2762, 63, 1541, 26, 221, 327, 5852, 1006, 288, 931, 275, 2559, 63, 4209, 14, 5154, 342, 288, 327, 5612, 5205, 367, 3974, 63, 3771, 20055, 288, 367, 2559, 63, 344, 315, 2559, 63, 4209, 14, 2491, 63, 1580, 837, 355, 20491, 275, 15665, 5083, 8, 2491, 63, 4209, 14, 1121, 12, 2559, 63, 344, 9, 355, 2559, 63, 4209, 14, 2491, 63, 2168, 8, 13829, 9, 288, 291, 423, 2168, 8, 515, 12, 2559, 63, 4209, 14, 1121, 12, 298, 5154, 531, 288, 291, 423, 2168, 63, 493, 8, 2491, 63, 4209, 14, 2253, 63, 12720, 1062, 2559, 63, 4209, 14, 1121, 12, 20859, 63, 14583, 51, 9, 267, 587, 26, 288, 367, 2559, 63, 344, 315, 2762, 63, 1541, 26, 221, 327, 2813, 2951, 314, 2013, 6117, 355, 20491, 275, 15665, 5083, 8, 2491, 63, 4209, 14, 1121, 12, 2559, 63, 344, 9, 355, 340, 440, 2559, 63, 4209, 14, 2491, 63, 2444, 8, 13829, 304, 490, 746, 15665, 22646, 8, 13829, 9, 355, 2559, 63, 4209, 14, 2491, 63, 2168, 8, 13829, 9, 355, 291, 423, 2168, 63, 493, 8, 2491, 63, 4209, 14, 2253, 63, 12720, 63, 2491, 8, 13829, 395, 2559, 63, 4209, 14, 1121, 12, 3303, 2071, 83, 3149, 83, 2, 450, 334, 2491, 63, 344, 12, 20859, 63, 14583, 51, 430, 421, 199, 533, 1448, 290, 497, 573, 422, 8, 785, 304, 272, 408, 8089, 17845, 367, 12881, 17738, 15, 3846, 590, 406, 796, 12, 2559, 16533, 12, 5423, 14, 408, 339, 347, 636, 826, 721, 277, 12, 2581, 12, 3982, 63, 2609, 12, 922, 63, 2308, 12, 32178, 744, 304, 267, 291, 423, 751, 63, 2308, 275, 922, 63, 2308, 267, 291, 423, 1637, 275, 2581, 267, 291, 423, 3846, 63, 2609, 275, 3982, 63, 2609, 267, 291, 423, 21420, 744, 275, 32178, 744, 339, 347, 485, 3846, 63, 2168, 8, 277, 12, 2984, 12, 2559, 63, 1580, 12, 3982, 304, 267, 702, 8, 6074, 8, 3846, 12, 17283, 430, 267, 340, 2559, 63, 1580, 365, 488, 26, 288, 754, 275, 291, 423, 3846, 63, 2609, 14, 2168, 63, 13191, 8, 1121, 12, 3982, 9, 288, 372, 754, 267, 587, 26, 288, 3529, 275, 291, 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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license as the Django package. # # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j E Y' TIME_FORMAT = 'H:i:s' DATETIME_FORMAT = 'j E Y H:i:s' YEAR_MONTH_FORMAT = 'F Y' MONTH_DAY_FORMAT = 'j F' SHORT_DATE_FORMAT = 'd-m-Y' SHORT_DATETIME_FORMAT = 'd-m-Y H:i:s' FIRST_DAY_OF_WEEK = 1 # Monday # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_INPUT_FORMATS = ( '%d.%m.%Y', '%d.%m.%y', # '25.10.2006', '25.10.06' '%Y-%m-%d', '%y-%m-%d', # '2006-10-25', '06-10-25' # '%d. %B %Y', '%d. %b. %Y', # '25. October 2006', '25. Oct. 2006' ) TIME_INPUT_FORMATS = ( '%H:%M:%S', # '14:30:59' '%H:%M', # '14:30' ) DATETIME_INPUT_FORMATS = ( '%d.%m.%Y %H:%M:%S', # '25.10.2006 14:30:59' '%d.%m.%Y %H:%M', # '25.10.2006 14:30' '%d.%m.%Y', # '25.10.2006' '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' '%Y-%m-%d %H:%M', # '2006-10-25 14:30' '%Y-%m-%d', # '2006-10-25' ) DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = u' ' NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 662, 1488, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 26, 83, 7, 199, 12488, 63, 4807, 275, 283, 74, 662, 1488, 869, 26, 73, 26, 83, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 68, 13, 77, 13, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 68, 13, 77, 13, 57, 221, 869, 26, 73, 26, 83, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 1543, 89, 3295, 77, 3295, 68, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 297, 283, 1690, 13, 709, 13, 821, 7, 272, 327, 1543, 68, 14, 450, 34, 450, 57, 297, 1543, 68, 14, 450, 66, 14, 450, 57, 297, 221, 327, 283, 821, 14, 18365, 22459, 8315, 297, 283, 821, 14, 18365, 14, 8315, 7, 199, 9, 199, 4961, 63, 7321, 63, 14019, 275, 334, 272, 1543, 40, 2689, 45, 2689, 51, 297, 327, 283, 1079, 26, 1216, 26, 1427, 7, 272, 1543, 40, 2689, 45, 297, 259, 327, 283, 1079, 26, 1216, 7, 199, 9, 199, 12488, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 259, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 755, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 3777, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 259, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 755, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 3777, 327, 283, 7968, 13, 709, 13, 821, 7, 199, 9, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 399, 7, 10619, 7, 199, 9190, 63, 7823, 1206, 275, 650, 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 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 662, 1488, 7, 199, 4961, 63, 4807, 275, 283, 40, 26, 73, 26, 83, 7, 199, 12488, 63, 4807, 275, 283, 74, 662, 1488, 869, 26, 73, 26, 83, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 68, 13, 77, 13, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 68, 13, 77, 13, 57, 221, 869, 26, 73, 26, 83, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 297, 1543, 68, 4111, 77, 4111, 89, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 297, 283, 821, 14, 709, 14, 1690, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 1543, 89, 3295, 77, 3295, 68, 297, 258, 327, 283, 7968, 13, 709, 13, 821, 297, 283, 1690, 13, 709, 13, 821, 7, 272, 327, 1543, 68, 14, 450, 34, 450, 57, 297, 1543, 68, 14, 450, 66, 14, 450, 57, 297, 221, 327, 283, 821, 14, 18365, 22459, 8315, 297, 283, 821, 14, 18365, 14, 8315, 7, 199, 9, 199, 4961, 63, 7321, 63, 14019, 275, 334, 272, 1543, 40, 2689, 45, 2689, 51, 297, 327, 283, 1079, 26, 1216, 26, 1427, 7, 272, 1543, 40, 2689, 45, 297, 259, 327, 283, 1079, 26, 1216, 7, 199, 9, 199, 12488, 63, 7321, 63, 14019, 275, 334, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 259, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 755, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 3777, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 297, 259, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 297, 755, 327, 283, 7968, 13, 709, 13, 821, 4329, 26, 1216, 7, 272, 1543, 57, 3295, 77, 3295, 68, 297, 3777, 327, 283, 7968, 13, 709, 13, 821, 7, 199, 9, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 399, 7, 10619, 7, 199, 9190, 63, 7823, 1206, 275, 650, 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, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mccheung/kbengine
kbe/res/scripts/common/Lib/test/test_code.py
94
3626
"""This module includes tests of the code object representation. >>> def f(x): ... def g(y): ... return x + y ... return g ... >>> dump(f.__code__) name: f argcount: 1 kwonlyargcount: 0 names: () varnames: ('x', 'g') cellvars: ('x',) freevars: () nlocals: 2 flags: 3 consts: ('None', '<code object g>', "'f.<locals>.g'") >>> dump(f(4).__code__) name: g argcount: 1 kwonlyargcount: 0 names: () varnames: ('y',) cellvars: () freevars: ('x',) nlocals: 1 flags: 19 consts: ('None',) >>> def h(x, y): ... a = x + y ... b = x - y ... c = a * b ... return c ... >>> dump(h.__code__) name: h argcount: 2 kwonlyargcount: 0 names: () varnames: ('x', 'y', 'a', 'b', 'c') cellvars: () freevars: () nlocals: 5 flags: 67 consts: ('None',) >>> def attrs(obj): ... print(obj.attr1) ... print(obj.attr2) ... print(obj.attr3) >>> dump(attrs.__code__) name: attrs argcount: 1 kwonlyargcount: 0 names: ('print', 'attr1', 'attr2', 'attr3') varnames: ('obj',) cellvars: () freevars: () nlocals: 1 flags: 67 consts: ('None',) >>> def optimize_away(): ... 'doc string' ... 'not a docstring' ... 53 ... 0x53 >>> dump(optimize_away.__code__) name: optimize_away argcount: 0 kwonlyargcount: 0 names: () varnames: () cellvars: () freevars: () nlocals: 0 flags: 67 consts: ("'doc string'", 'None') >>> def keywordonly_args(a,b,*,k1): ... return a,b,k1 ... >>> dump(keywordonly_args.__code__) name: keywordonly_args argcount: 2 kwonlyargcount: 1 names: () varnames: ('a', 'b', 'k1') cellvars: () freevars: () nlocals: 3 flags: 67 consts: ('None',) """ import unittest import weakref from test.support import run_doctest, run_unittest, cpython_only def consts(t): """Yield a doctest-safe sequence of object reprs.""" for elt in t: r = repr(elt) if r.startswith("<code object"): yield "<code object %s>" % elt.co_name else: yield r def dump(co): """Print out a text representation of a code object.""" for attr in ["name", "argcount", "kwonlyargcount", "names", "varnames", "cellvars", "freevars", "nlocals", "flags"]: print("%s: %s" % (attr, getattr(co, "co_" + attr))) print("consts:", tuple(consts(co.co_consts))) class CodeTest(unittest.TestCase): @cpython_only def test_newempty(self): import _testcapi co = _testcapi.code_newempty("filename", "funcname", 15) self.assertEqual(co.co_filename, "filename") self.assertEqual(co.co_name, "funcname") self.assertEqual(co.co_firstlineno, 15) class CodeWeakRefTest(unittest.TestCase): def test_basic(self): # Create a code object in a clean environment so that we know we have # the only reference to it left. namespace = {} exec("def f(): pass", globals(), namespace) f = namespace["f"] del namespace self.called = False def callback(code): self.called = True # f is now the last reference to the function, and through it, the code # object. While we hold it, check that we can create a weakref and # deref it. Then delete it, and check that the callback gets called and # the reference dies. coderef = weakref.ref(f.__code__, callback) self.assertTrue(bool(coderef())) del f self.assertFalse(bool(coderef())) self.assertTrue(self.called) def test_main(verbose=None): from test import test_code run_doctest(test_code, verbose) run_unittest(CodeTest, CodeWeakRefTest) if __name__ == "__main__": test_main()
lgpl-3.0
[ 624, 2765, 859, 6952, 2295, 402, 314, 1233, 909, 6025, 14, 199, 199, 6071, 347, 289, 8, 88, 304, 199, 1396, 258, 347, 486, 8, 89, 304, 199, 1396, 260, 372, 671, 435, 612, 199, 1396, 258, 372, 486, 199, 1396, 199, 199, 6071, 5461, 8, 70, 855, 600, 3368, 199, 354, 26, 289, 199, 30513, 26, 413, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 661, 88, 297, 283, 71, 358, 199, 3890, 2936, 26, 661, 88, 9538, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 499, 199, 2469, 26, 650, 199, 20473, 26, 661, 403, 297, 2650, 600, 909, 486, 4206, 3546, 70, 21455, 9350, 10827, 71, 9859, 199, 199, 6071, 5461, 8, 70, 8, 20, 2843, 600, 3368, 199, 354, 26, 486, 199, 30513, 26, 413, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 661, 89, 9538, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 661, 88, 9538, 199, 78, 9350, 26, 413, 199, 2469, 26, 5851, 199, 20473, 26, 661, 403, 9538, 199, 199, 6071, 347, 394, 8, 88, 12, 612, 304, 199, 1396, 258, 282, 275, 671, 435, 612, 199, 1396, 258, 330, 275, 671, 446, 612, 199, 1396, 258, 286, 275, 282, 627, 330, 199, 1396, 258, 372, 286, 199, 1396, 199, 199, 6071, 5461, 8, 72, 855, 600, 3368, 199, 354, 26, 394, 199, 30513, 26, 499, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 661, 88, 297, 283, 89, 297, 283, 65, 297, 283, 66, 297, 283, 67, 358, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 959, 199, 2469, 26, 13296, 199, 20473, 26, 661, 403, 9538, 199, 199, 6071, 347, 3290, 8, 1113, 304, 199, 1396, 258, 870, 8, 1113, 14, 962, 17, 9, 199, 1396, 258, 870, 8, 1113, 14, 962, 18, 9, 199, 1396, 258, 870, 8, 1113, 14, 962, 19, 9, 199, 199, 6071, 5461, 8, 3288, 855, 600, 3368, 199, 354, 26, 3290, 199, 30513, 26, 413, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 661, 1361, 297, 283, 962, 17, 297, 283, 962, 18, 297, 283, 962, 19, 358, 199, 1391, 1247, 26, 661, 1113, 9538, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 413, 199, 2469, 26, 13296, 199, 20473, 26, 661, 403, 9538, 199, 199, 6071, 347, 13497, 63, 22703, 837, 199, 1396, 258, 283, 1301, 1059, 7, 199, 1396, 258, 283, 1397, 282, 9214, 7, 199, 1396, 258, 13564, 199, 1396, 258, 378, 88, 2481, 199, 199, 6071, 5461, 8, 13416, 63, 22703, 855, 600, 3368, 199, 354, 26, 13497, 63, 22703, 199, 30513, 26, 378, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 6248, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 378, 199, 2469, 26, 13296, 199, 20473, 26, 1689, 7, 1301, 1059, 4662, 283, 403, 358, 199, 199, 6071, 347, 4252, 2118, 63, 589, 8, 65, 12, 66, 12, 10381, 75, 17, 304, 199, 1396, 258, 372, 282, 12, 66, 12, 75, 17, 199, 1396, 199, 199, 6071, 5461, 8, 6691, 2118, 63, 589, 855, 600, 3368, 199, 354, 26, 4252, 2118, 63, 589, 199, 30513, 26, 499, 199, 829, 2118, 30513, 26, 413, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 661, 65, 297, 283, 66, 297, 283, 75, 17, 358, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 650, 199, 2469, 26, 13296, 199, 20473, 26, 661, 403, 9538, 199, 199, 624, 199, 199, 646, 2882, 199, 646, 13852, 199, 504, 511, 14, 4058, 492, 1255, 63, 11390, 12, 1255, 63, 2796, 12, 286, 1548, 63, 2118, 421, 199, 318, 950, 83, 8, 84, 304, 272, 408, 22889, 282, 8868, 13, 3489, 3414, 402, 909, 1833, 2393, 1041, 272, 367, 18409, 315, 307, 26, 267, 519, 275, 4700, 8, 15330, 9, 267, 340, 519, 14, 2460, 6757, 600, 909, 2349, 288, 1995, 3886, 600, 909, 450, 83, 4335, 450, 18409, 14, 331, 63, 354, 267, 587, 26, 288, 1995, 519, 199, 199, 318, 5461, 8, 331, 304, 272, 408, 5375, 734, 282, 1318, 6025, 402, 282, 1233, 909, 1041, 272, 367, 1921, 315, 2097, 354, 401, 298, 30513, 401, 298, 829, 2118, 30513, 401, 298, 1247, 401, 298, 1391, 1247, 401, 326, 298, 3890, 2936, 401, 298, 4624, 2936, 401, 298, 78, 9350, 401, 298, 2469, 6229, 267, 870, 3647, 83, 26, 450, 83, 2, 450, 334, 962, 12, 2519, 8, 331, 12, 298, 331, 12172, 435, 1921, 1724, 272, 870, 480, 20473, 6783, 2008, 8, 20473, 8, 331, 14, 331, 63, 20473, 1724, 421, 199, 533, 5495, 774, 8, 2796, 14, 1746, 304, 339, 768, 67, 1548, 63, 2118, 272, 347, 511, 63, 1222, 1667, 8, 277, 304, 267, 492, 485, 396, 14145, 267, 512, 275, 485, 396, 14145, 14, 600, 63, 1222, 1667, 480, 1501, 401, 298, 29577, 401, 4114, 9, 267, 291, 14, 629, 8, 331, 14, 331, 63, 1501, 12, 298, 1501, 531, 267, 291, 14, 629, 8, 331, 14, 331, 63, 354, 12, 298, 29577, 531, 267, 291, 14, 629, 8, 331, 14, 331, 63, 30114, 12, 4114, 9, 421, 199, 533, 5495, 18889, 2891, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 327, 2790, 282, 1233, 909, 315, 282, 3633, 3734, 880, 626, 781, 5715, 781, 1172, 267, 327, 314, 1454, 3659, 370, 652, 3602, 14, 267, 3231, 275, 1052, 267, 2146, 480, 318, 289, 837, 986, 401, 7992, 1062, 3231, 9, 267, 289, 275, 3231, 905, 70, 937, 267, 2150, 3231, 398, 291, 14, 3527, 275, 756, 267, 347, 3233, 8, 600, 304, 288, 291, 14, 3527, 275, 715, 398, 327, 289, 365, 3063, 314, 2061, 3659, 370, 314, 805, 12, 436, 4012, 652, 12, 314, 1233, 267, 327, 909, 14, 221, 22117, 781, 10266, 652, 12, 1104, 626, 781, 883, 1218, 282, 13852, 436, 267, 327, 477, 1121, 652, 14, 221, 9442, 3145, 652, 12, 436, 1104, 626, 314, 3233, 7545, 2797, 436, 267, 327 ]
[ 2765, 859, 6952, 2295, 402, 314, 1233, 909, 6025, 14, 199, 199, 6071, 347, 289, 8, 88, 304, 199, 1396, 258, 347, 486, 8, 89, 304, 199, 1396, 260, 372, 671, 435, 612, 199, 1396, 258, 372, 486, 199, 1396, 199, 199, 6071, 5461, 8, 70, 855, 600, 3368, 199, 354, 26, 289, 199, 30513, 26, 413, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 661, 88, 297, 283, 71, 358, 199, 3890, 2936, 26, 661, 88, 9538, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 499, 199, 2469, 26, 650, 199, 20473, 26, 661, 403, 297, 2650, 600, 909, 486, 4206, 3546, 70, 21455, 9350, 10827, 71, 9859, 199, 199, 6071, 5461, 8, 70, 8, 20, 2843, 600, 3368, 199, 354, 26, 486, 199, 30513, 26, 413, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 661, 89, 9538, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 661, 88, 9538, 199, 78, 9350, 26, 413, 199, 2469, 26, 5851, 199, 20473, 26, 661, 403, 9538, 199, 199, 6071, 347, 394, 8, 88, 12, 612, 304, 199, 1396, 258, 282, 275, 671, 435, 612, 199, 1396, 258, 330, 275, 671, 446, 612, 199, 1396, 258, 286, 275, 282, 627, 330, 199, 1396, 258, 372, 286, 199, 1396, 199, 199, 6071, 5461, 8, 72, 855, 600, 3368, 199, 354, 26, 394, 199, 30513, 26, 499, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 661, 88, 297, 283, 89, 297, 283, 65, 297, 283, 66, 297, 283, 67, 358, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 959, 199, 2469, 26, 13296, 199, 20473, 26, 661, 403, 9538, 199, 199, 6071, 347, 3290, 8, 1113, 304, 199, 1396, 258, 870, 8, 1113, 14, 962, 17, 9, 199, 1396, 258, 870, 8, 1113, 14, 962, 18, 9, 199, 1396, 258, 870, 8, 1113, 14, 962, 19, 9, 199, 199, 6071, 5461, 8, 3288, 855, 600, 3368, 199, 354, 26, 3290, 199, 30513, 26, 413, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 661, 1361, 297, 283, 962, 17, 297, 283, 962, 18, 297, 283, 962, 19, 358, 199, 1391, 1247, 26, 661, 1113, 9538, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 413, 199, 2469, 26, 13296, 199, 20473, 26, 661, 403, 9538, 199, 199, 6071, 347, 13497, 63, 22703, 837, 199, 1396, 258, 283, 1301, 1059, 7, 199, 1396, 258, 283, 1397, 282, 9214, 7, 199, 1396, 258, 13564, 199, 1396, 258, 378, 88, 2481, 199, 199, 6071, 5461, 8, 13416, 63, 22703, 855, 600, 3368, 199, 354, 26, 13497, 63, 22703, 199, 30513, 26, 378, 199, 829, 2118, 30513, 26, 378, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 6248, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 378, 199, 2469, 26, 13296, 199, 20473, 26, 1689, 7, 1301, 1059, 4662, 283, 403, 358, 199, 199, 6071, 347, 4252, 2118, 63, 589, 8, 65, 12, 66, 12, 10381, 75, 17, 304, 199, 1396, 258, 372, 282, 12, 66, 12, 75, 17, 199, 1396, 199, 199, 6071, 5461, 8, 6691, 2118, 63, 589, 855, 600, 3368, 199, 354, 26, 4252, 2118, 63, 589, 199, 30513, 26, 499, 199, 829, 2118, 30513, 26, 413, 199, 1247, 26, 6248, 199, 1391, 1247, 26, 661, 65, 297, 283, 66, 297, 283, 75, 17, 358, 199, 3890, 2936, 26, 6248, 199, 4624, 2936, 26, 6248, 199, 78, 9350, 26, 650, 199, 2469, 26, 13296, 199, 20473, 26, 661, 403, 9538, 199, 199, 624, 199, 199, 646, 2882, 199, 646, 13852, 199, 504, 511, 14, 4058, 492, 1255, 63, 11390, 12, 1255, 63, 2796, 12, 286, 1548, 63, 2118, 421, 199, 318, 950, 83, 8, 84, 304, 272, 408, 22889, 282, 8868, 13, 3489, 3414, 402, 909, 1833, 2393, 1041, 272, 367, 18409, 315, 307, 26, 267, 519, 275, 4700, 8, 15330, 9, 267, 340, 519, 14, 2460, 6757, 600, 909, 2349, 288, 1995, 3886, 600, 909, 450, 83, 4335, 450, 18409, 14, 331, 63, 354, 267, 587, 26, 288, 1995, 519, 199, 199, 318, 5461, 8, 331, 304, 272, 408, 5375, 734, 282, 1318, 6025, 402, 282, 1233, 909, 1041, 272, 367, 1921, 315, 2097, 354, 401, 298, 30513, 401, 298, 829, 2118, 30513, 401, 298, 1247, 401, 298, 1391, 1247, 401, 326, 298, 3890, 2936, 401, 298, 4624, 2936, 401, 298, 78, 9350, 401, 298, 2469, 6229, 267, 870, 3647, 83, 26, 450, 83, 2, 450, 334, 962, 12, 2519, 8, 331, 12, 298, 331, 12172, 435, 1921, 1724, 272, 870, 480, 20473, 6783, 2008, 8, 20473, 8, 331, 14, 331, 63, 20473, 1724, 421, 199, 533, 5495, 774, 8, 2796, 14, 1746, 304, 339, 768, 67, 1548, 63, 2118, 272, 347, 511, 63, 1222, 1667, 8, 277, 304, 267, 492, 485, 396, 14145, 267, 512, 275, 485, 396, 14145, 14, 600, 63, 1222, 1667, 480, 1501, 401, 298, 29577, 401, 4114, 9, 267, 291, 14, 629, 8, 331, 14, 331, 63, 1501, 12, 298, 1501, 531, 267, 291, 14, 629, 8, 331, 14, 331, 63, 354, 12, 298, 29577, 531, 267, 291, 14, 629, 8, 331, 14, 331, 63, 30114, 12, 4114, 9, 421, 199, 533, 5495, 18889, 2891, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 327, 2790, 282, 1233, 909, 315, 282, 3633, 3734, 880, 626, 781, 5715, 781, 1172, 267, 327, 314, 1454, 3659, 370, 652, 3602, 14, 267, 3231, 275, 1052, 267, 2146, 480, 318, 289, 837, 986, 401, 7992, 1062, 3231, 9, 267, 289, 275, 3231, 905, 70, 937, 267, 2150, 3231, 398, 291, 14, 3527, 275, 756, 267, 347, 3233, 8, 600, 304, 288, 291, 14, 3527, 275, 715, 398, 327, 289, 365, 3063, 314, 2061, 3659, 370, 314, 805, 12, 436, 4012, 652, 12, 314, 1233, 267, 327, 909, 14, 221, 22117, 781, 10266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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 ]
crosswalk-project/chromium-crosswalk-efl
third_party/google_appengine_cloudstorage/cloudstorage/errors.py
102
3860
# Copyright 2012 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. """Google Cloud Storage specific Files API calls.""" __all__ = ['AuthorizationError', 'check_status', 'Error', 'FatalError', 'FileClosedError', 'ForbiddenError', 'NotFoundError', 'ServerError', 'TimeoutError', 'TransientError', ] import httplib class Error(Exception): """Base error for all gcs operations. Error can happen on GAE side or GCS server side. For details on a particular GCS HTTP response code, see https://developers.google.com/storage/docs/reference-status#standardcodes """ class TransientError(Error): """TransientError could be retried.""" class TimeoutError(TransientError): """HTTP 408 timeout.""" class FatalError(Error): """FatalError shouldn't be retried.""" class FileClosedError(FatalError): """File is already closed. This can happen when the upload has finished but 'write' is called on a stale upload handle. """ class NotFoundError(FatalError): """HTTP 404 resource not found.""" class ForbiddenError(FatalError): """HTTP 403 Forbidden. While GCS replies with a 403 error for many reasons, the most common one is due to bucket permission not correctly setup for your app to access. """ class AuthorizationError(FatalError): """HTTP 401 authentication required. Unauthorized request has been received by GCS. This error is mostly handled by GCS client. GCS client will request a new access token and retry the request. """ class InvalidRange(FatalError): """HTTP 416 RequestRangeNotSatifiable.""" class ServerError(TransientError): """HTTP >= 500 server side error.""" def check_status(status, expected, path, headers=None, resp_headers=None, extras=None): """Check HTTP response status is expected. Args: status: HTTP response status. int. expected: a list of expected statuses. A list of ints. path: filename or a path prefix. headers: HTTP request headers. resp_headers: HTTP response headers. extras: extra info to be logged verbatim if error occurs. Raises: AuthorizationError: if authorization failed. NotFoundError: if an object that's expected to exist doesn't. TimeoutError: if HTTP request timed out. ServerError: if server experienced some errors. FatalError: if any other unexpected errors occurred. """ if status in expected: return msg = ('Expect status %r from Google Storage. But got status %d.\n' 'Path: %r.\n' 'Request headers: %r.\n' 'Response headers: %r.\n' 'Extra info: %r.\n' % (expected, status, path, headers, resp_headers, extras)) if status == httplib.UNAUTHORIZED: raise AuthorizationError(msg) elif status == httplib.FORBIDDEN: raise ForbiddenError(msg) elif status == httplib.NOT_FOUND: raise NotFoundError(msg) elif status == httplib.REQUEST_TIMEOUT: raise TimeoutError(msg) elif status == httplib.REQUESTED_RANGE_NOT_SATISFIABLE: raise InvalidRange(msg) elif (status == httplib.OK and 308 in expected and httplib.OK not in expected): raise FileClosedError(msg) elif status >= 500: raise ServerError(msg) else: raise FatalError(msg)
bsd-3-clause
[ 3, 1898, 6029, 4475, 3277, 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, 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, 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, 3826, 12, 199, 3, 1902, 4056, 503, 2478, 14, 1666, 314, 844, 367, 314, 2488, 199, 3, 2637, 4210, 3443, 436, 4204, 1334, 314, 844, 14, 199, 199, 624, 13266, 8142, 10533, 2488, 16920, 3261, 4882, 1041, 28154, 199, 363, 452, 363, 275, 788, 11626, 547, 297, 1779, 283, 1074, 63, 1205, 297, 1779, 283, 547, 297, 1779, 283, 19507, 547, 297, 1779, 283, 1173, 15190, 547, 297, 1779, 283, 17454, 547, 297, 1779, 283, 10870, 297, 1779, 283, 17692, 297, 1779, 283, 19382, 297, 1779, 283, 14612, 14928, 547, 297, 881, 1622, 199, 199, 646, 8809, 421, 199, 533, 4520, 8, 1726, 304, 523, 408, 1563, 1125, 367, 1006, 486, 1259, 5331, 14, 819, 4520, 883, 5992, 641, 598, 12500, 5366, 503, 598, 3298, 1654, 5366, 14, 523, 2104, 2436, 641, 282, 6770, 598, 3298, 3101, 1177, 1233, 12, 1937, 523, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3494, 15, 4757, 15, 4443, 13, 1205, 3, 6807, 6021, 523, 408, 421, 199, 533, 19894, 14928, 547, 8, 547, 304, 523, 408, 14612, 14928, 547, 4293, 506, 4444, 379, 1041, 421, 199, 533, 31886, 8, 14612, 14928, 547, 304, 523, 408, 2856, 841, 2036, 2653, 1041, 421, 199, 533, 481, 7539, 547, 8, 547, 304, 523, 408, 19507, 547, 9296, 1133, 506, 4444, 379, 1041, 421, 199, 533, 3814, 15190, 547, 8, 19507, 547, 304, 523, 408, 1173, 365, 2575, 6876, 14, 819, 961, 883, 5992, 1380, 314, 5802, 965, 9158, 1325, 283, 952, 7, 365, 2797, 641, 523, 282, 20149, 5802, 2429, 14, 523, 408, 421, 199, 533, 21909, 547, 8, 19507, 547, 304, 523, 408, 2856, 7901, 2073, 440, 1911, 1041, 421, 199, 533, 2104, 10912, 547, 8, 19507, 547, 304, 523, 408, 2856, 13269, 2104, 10912, 14, 819, 22117, 598, 3298, 1833, 6528, 543, 282, 13269, 1125, 367, 5002, 14872, 12, 314, 4750, 2863, 1373, 523, 365, 7037, 370, 5315, 4983, 440, 6657, 3272, 367, 2195, 1145, 370, 2879, 14, 523, 408, 421, 199, 533, 21527, 547, 8, 19507, 547, 304, 523, 408, 2856, 13952, 6299, 1415, 14, 819, 1910, 11497, 1056, 965, 2757, 3086, 701, 598, 3298, 14, 819, 961, 1125, 365, 19762, 8860, 701, 598, 3298, 1890, 14, 598, 3298, 1890, 911, 1056, 523, 282, 892, 2879, 1526, 436, 7269, 314, 1056, 14, 523, 408, 421, 199, 533, 6378, 4709, 8, 19507, 547, 304, 523, 408, 2856, 841, 975, 4784, 4709, 1763, 12226, 1428, 461, 1041, 421, 199, 533, 7146, 547, 8, 14612, 14928, 547, 304, 523, 408, 2856, 2356, 6891, 1654, 5366, 1125, 1041, 421, 199, 318, 1104, 63, 1205, 8, 1205, 12, 1420, 12, 931, 12, 2323, 29, 403, 12, 326, 3085, 63, 2139, 29, 403, 12, 13751, 29, 403, 304, 523, 408, 1799, 3101, 1177, 2004, 365, 1420, 14, 819, 3033, 26, 272, 2004, 26, 3101, 1177, 2004, 14, 1109, 14, 272, 1420, 26, 282, 769, 402, 1420, 24498, 14, 437, 769, 402, 14526, 14, 272, 931, 26, 1788, 503, 282, 931, 2403, 14, 272, 2323, 26, 3101, 1056, 2323, 14, 272, 3085, 63, 2139, 26, 3101, 1177, 2323, 14, 272, 13751, 26, 2402, 2256, 370, 506, 10367, 16041, 24218, 340, 1125, 11058, 14, 819, 6218, 26, 272, 21527, 547, 26, 340, 13448, 3405, 14, 272, 21909, 547, 26, 340, 376, 909, 626, 1159, 1420, 370, 2187, 3181, 1133, 14, 272, 31886, 26, 340, 3101, 1056, 18590, 734, 14, 272, 7146, 547, 26, 340, 1654, 444, 24242, 68, 2005, 2552, 14, 272, 481, 7539, 547, 26, 340, 1263, 1163, 10537, 2552, 8920, 14, 523, 408, 523, 340, 2004, 315, 1420, 26, 272, 372, 819, 1499, 275, 661, 13495, 2004, 450, 82, 687, 4475, 10533, 14, 11017, 4788, 2004, 450, 68, 3134, 78, 7, 268, 283, 2042, 26, 450, 82, 3134, 78, 7, 268, 283, 2017, 2323, 26, 450, 82, 3134, 78, 7, 268, 283, 2364, 2323, 26, 450, 82, 3134, 78, 7, 268, 283, 7426, 2256, 26, 450, 82, 3134, 78, 7, 450, 268, 334, 2062, 12, 2004, 12, 931, 12, 2323, 12, 3085, 63, 2139, 12, 13751, 430, 819, 340, 2004, 508, 8809, 14, 1734, 25303, 1149, 26, 272, 746, 21527, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 2707, 34, 22436, 26, 272, 746, 2104, 10912, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 4609, 63, 13945, 26, 272, 746, 21909, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 6780, 63, 8899, 26, 272, 746, 31886, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 6780, 1149, 63, 15167, 63, 4609, 63, 51, 619, 1311, 1976, 2617, 26, 272, 746, 6378, 4709, 8, 1328, 9, 523, 916, 334, 1205, 508, 8809, 14, 3593, 436, 650, 2036, 315, 1420, 436, 267, 8809, 14, 3593, 440, 315, 1420, 304, 272, 746, 3814, 15190, 547, 8, 1328, 9, 523, 916, 2004, 2356, 6891, 26, 272, 746, 7146, 547, 8, 1328, 9, 523, 587, 26, 272, 746, 481, 7539, 547, 8, 1328, 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 ]
[ 1898, 6029, 4475, 3277, 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, 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, 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, 3826, 12, 199, 3, 1902, 4056, 503, 2478, 14, 1666, 314, 844, 367, 314, 2488, 199, 3, 2637, 4210, 3443, 436, 4204, 1334, 314, 844, 14, 199, 199, 624, 13266, 8142, 10533, 2488, 16920, 3261, 4882, 1041, 28154, 199, 363, 452, 363, 275, 788, 11626, 547, 297, 1779, 283, 1074, 63, 1205, 297, 1779, 283, 547, 297, 1779, 283, 19507, 547, 297, 1779, 283, 1173, 15190, 547, 297, 1779, 283, 17454, 547, 297, 1779, 283, 10870, 297, 1779, 283, 17692, 297, 1779, 283, 19382, 297, 1779, 283, 14612, 14928, 547, 297, 881, 1622, 199, 199, 646, 8809, 421, 199, 533, 4520, 8, 1726, 304, 523, 408, 1563, 1125, 367, 1006, 486, 1259, 5331, 14, 819, 4520, 883, 5992, 641, 598, 12500, 5366, 503, 598, 3298, 1654, 5366, 14, 523, 2104, 2436, 641, 282, 6770, 598, 3298, 3101, 1177, 1233, 12, 1937, 523, 4178, 921, 23826, 14, 3098, 14, 957, 15, 3494, 15, 4757, 15, 4443, 13, 1205, 3, 6807, 6021, 523, 408, 421, 199, 533, 19894, 14928, 547, 8, 547, 304, 523, 408, 14612, 14928, 547, 4293, 506, 4444, 379, 1041, 421, 199, 533, 31886, 8, 14612, 14928, 547, 304, 523, 408, 2856, 841, 2036, 2653, 1041, 421, 199, 533, 481, 7539, 547, 8, 547, 304, 523, 408, 19507, 547, 9296, 1133, 506, 4444, 379, 1041, 421, 199, 533, 3814, 15190, 547, 8, 19507, 547, 304, 523, 408, 1173, 365, 2575, 6876, 14, 819, 961, 883, 5992, 1380, 314, 5802, 965, 9158, 1325, 283, 952, 7, 365, 2797, 641, 523, 282, 20149, 5802, 2429, 14, 523, 408, 421, 199, 533, 21909, 547, 8, 19507, 547, 304, 523, 408, 2856, 7901, 2073, 440, 1911, 1041, 421, 199, 533, 2104, 10912, 547, 8, 19507, 547, 304, 523, 408, 2856, 13269, 2104, 10912, 14, 819, 22117, 598, 3298, 1833, 6528, 543, 282, 13269, 1125, 367, 5002, 14872, 12, 314, 4750, 2863, 1373, 523, 365, 7037, 370, 5315, 4983, 440, 6657, 3272, 367, 2195, 1145, 370, 2879, 14, 523, 408, 421, 199, 533, 21527, 547, 8, 19507, 547, 304, 523, 408, 2856, 13952, 6299, 1415, 14, 819, 1910, 11497, 1056, 965, 2757, 3086, 701, 598, 3298, 14, 819, 961, 1125, 365, 19762, 8860, 701, 598, 3298, 1890, 14, 598, 3298, 1890, 911, 1056, 523, 282, 892, 2879, 1526, 436, 7269, 314, 1056, 14, 523, 408, 421, 199, 533, 6378, 4709, 8, 19507, 547, 304, 523, 408, 2856, 841, 975, 4784, 4709, 1763, 12226, 1428, 461, 1041, 421, 199, 533, 7146, 547, 8, 14612, 14928, 547, 304, 523, 408, 2856, 2356, 6891, 1654, 5366, 1125, 1041, 421, 199, 318, 1104, 63, 1205, 8, 1205, 12, 1420, 12, 931, 12, 2323, 29, 403, 12, 326, 3085, 63, 2139, 29, 403, 12, 13751, 29, 403, 304, 523, 408, 1799, 3101, 1177, 2004, 365, 1420, 14, 819, 3033, 26, 272, 2004, 26, 3101, 1177, 2004, 14, 1109, 14, 272, 1420, 26, 282, 769, 402, 1420, 24498, 14, 437, 769, 402, 14526, 14, 272, 931, 26, 1788, 503, 282, 931, 2403, 14, 272, 2323, 26, 3101, 1056, 2323, 14, 272, 3085, 63, 2139, 26, 3101, 1177, 2323, 14, 272, 13751, 26, 2402, 2256, 370, 506, 10367, 16041, 24218, 340, 1125, 11058, 14, 819, 6218, 26, 272, 21527, 547, 26, 340, 13448, 3405, 14, 272, 21909, 547, 26, 340, 376, 909, 626, 1159, 1420, 370, 2187, 3181, 1133, 14, 272, 31886, 26, 340, 3101, 1056, 18590, 734, 14, 272, 7146, 547, 26, 340, 1654, 444, 24242, 68, 2005, 2552, 14, 272, 481, 7539, 547, 26, 340, 1263, 1163, 10537, 2552, 8920, 14, 523, 408, 523, 340, 2004, 315, 1420, 26, 272, 372, 819, 1499, 275, 661, 13495, 2004, 450, 82, 687, 4475, 10533, 14, 11017, 4788, 2004, 450, 68, 3134, 78, 7, 268, 283, 2042, 26, 450, 82, 3134, 78, 7, 268, 283, 2017, 2323, 26, 450, 82, 3134, 78, 7, 268, 283, 2364, 2323, 26, 450, 82, 3134, 78, 7, 268, 283, 7426, 2256, 26, 450, 82, 3134, 78, 7, 450, 268, 334, 2062, 12, 2004, 12, 931, 12, 2323, 12, 3085, 63, 2139, 12, 13751, 430, 819, 340, 2004, 508, 8809, 14, 1734, 25303, 1149, 26, 272, 746, 21527, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 2707, 34, 22436, 26, 272, 746, 2104, 10912, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 4609, 63, 13945, 26, 272, 746, 21909, 547, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 6780, 63, 8899, 26, 272, 746, 31886, 8, 1328, 9, 523, 916, 2004, 508, 8809, 14, 6780, 1149, 63, 15167, 63, 4609, 63, 51, 619, 1311, 1976, 2617, 26, 272, 746, 6378, 4709, 8, 1328, 9, 523, 916, 334, 1205, 508, 8809, 14, 3593, 436, 650, 2036, 315, 1420, 436, 267, 8809, 14, 3593, 440, 315, 1420, 304, 272, 746, 3814, 15190, 547, 8, 1328, 9, 523, 916, 2004, 2356, 6891, 26, 272, 746, 7146, 547, 8, 1328, 9, 523, 587, 26, 272, 746, 481, 7539, 547, 8, 1328, 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, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Jovennan/curso-rails
node_modules/node-gyp/gyp/pylib/gyp/generator/android.py
960
45344
# Copyright (c) 2012 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Notes: # # This generates makefiles suitable for inclusion into the Android build system # via an Android.mk file. It is based on make.py, the standard makefile # generator. # # The code below generates a separate .mk file for each target, but # all are sourced by the top-level GypAndroid.mk. This means that all # variables in .mk-files clobber one another, and furthermore that any # variables set potentially clash with other Android build system variables. # Try to avoid setting global variables where possible. import gyp import gyp.common import gyp.generator.make as make # Reuse global functions from make backend. import os import re import subprocess generator_default_variables = { 'OS': 'android', 'EXECUTABLE_PREFIX': '', 'EXECUTABLE_SUFFIX': '', 'STATIC_LIB_PREFIX': 'lib', 'SHARED_LIB_PREFIX': 'lib', 'STATIC_LIB_SUFFIX': '.a', 'SHARED_LIB_SUFFIX': '.so', 'INTERMEDIATE_DIR': '$(gyp_intermediate_dir)', 'SHARED_INTERMEDIATE_DIR': '$(gyp_shared_intermediate_dir)', 'PRODUCT_DIR': '$(gyp_shared_intermediate_dir)', 'SHARED_LIB_DIR': '$(builddir)/lib.$(TOOLSET)', 'LIB_DIR': '$(obj).$(TOOLSET)', 'RULE_INPUT_ROOT': '%(INPUT_ROOT)s', # This gets expanded by Python. 'RULE_INPUT_DIRNAME': '%(INPUT_DIRNAME)s', # This gets expanded by Python. 'RULE_INPUT_PATH': '$(RULE_SOURCES)', 'RULE_INPUT_EXT': '$(suffix $<)', 'RULE_INPUT_NAME': '$(notdir $<)', 'CONFIGURATION_NAME': '$(GYP_CONFIGURATION)', } # Make supports multiple toolsets generator_supports_multiple_toolsets = True # Generator-specific gyp specs. generator_additional_non_configuration_keys = [ # Boolean to declare that this target does not want its name mangled. 'android_unmangled_name', # Map of android build system variables to set. 'aosp_build_settings', ] generator_additional_path_sections = [] generator_extra_sources_for_rules = [] ALL_MODULES_FOOTER = """\ # "gyp_all_modules" is a concatenation of the "gyp_all_modules" targets from # all the included sub-makefiles. This is just here to clarify. gyp_all_modules: """ header = """\ # This file is generated by gyp; do not edit. """ # Map gyp target types to Android module classes. MODULE_CLASSES = { 'static_library': 'STATIC_LIBRARIES', 'shared_library': 'SHARED_LIBRARIES', 'executable': 'EXECUTABLES', } def IsCPPExtension(ext): return make.COMPILABLE_EXTENSIONS.get(ext) == 'cxx' def Sourceify(path): """Convert a path to its source directory form. The Android backend does not support options.generator_output, so this function is a noop.""" return path # Map from qualified target to path to output. # For Android, the target of these maps is a tuple ('static', 'modulename'), # ('dynamic', 'modulename'), or ('path', 'some/path') instead of a string, # since we link by module. target_outputs = {} # Map from qualified target to any linkable output. A subset # of target_outputs. E.g. when mybinary depends on liba, we want to # include liba in the linker line; when otherbinary depends on # mybinary, we just want to build mybinary first. target_link_deps = {} class AndroidMkWriter(object): """AndroidMkWriter packages up the writing of one target-specific Android.mk. Its only real entry point is Write(), and is mostly used for namespacing. """ def __init__(self, android_top_dir): self.android_top_dir = android_top_dir def Write(self, qualified_target, relative_target, base_path, output_filename, spec, configs, part_of_all, write_alias_target, sdk_version): """The main entry point: writes a .mk file for a single target. Arguments: qualified_target: target we're generating relative_target: qualified target name relative to the root base_path: path relative to source root we're building in, used to resolve target-relative paths output_filename: output .mk file name to write spec, configs: gyp info part_of_all: flag indicating this target is part of 'all' write_alias_target: flag indicating whether to create short aliases for this target sdk_version: what to emit for LOCAL_SDK_VERSION in output """ gyp.common.EnsureDirExists(output_filename) self.fp = open(output_filename, 'w') self.fp.write(header) self.qualified_target = qualified_target self.relative_target = relative_target self.path = base_path self.target = spec['target_name'] self.type = spec['type'] self.toolset = spec['toolset'] deps, link_deps = self.ComputeDeps(spec) # Some of the generation below can add extra output, sources, or # link dependencies. All of the out params of the functions that # follow use names like extra_foo. extra_outputs = [] extra_sources = [] self.android_class = MODULE_CLASSES.get(self.type, 'GYP') self.android_module = self.ComputeAndroidModule(spec) (self.android_stem, self.android_suffix) = self.ComputeOutputParts(spec) self.output = self.output_binary = self.ComputeOutput(spec) # Standard header. self.WriteLn('include $(CLEAR_VARS)\n') # Module class and name. self.WriteLn('LOCAL_MODULE_CLASS := ' + self.android_class) self.WriteLn('LOCAL_MODULE := ' + self.android_module) # Only emit LOCAL_MODULE_STEM if it's different to LOCAL_MODULE. # The library module classes fail if the stem is set. ComputeOutputParts # makes sure that stem == modulename in these cases. if self.android_stem != self.android_module: self.WriteLn('LOCAL_MODULE_STEM := ' + self.android_stem) self.WriteLn('LOCAL_MODULE_SUFFIX := ' + self.android_suffix) if self.toolset == 'host': self.WriteLn('LOCAL_IS_HOST_MODULE := true') self.WriteLn('LOCAL_MULTILIB := $(GYP_HOST_MULTILIB)') elif sdk_version > 0: self.WriteLn('LOCAL_MODULE_TARGET_ARCH := ' '$(TARGET_$(GYP_VAR_PREFIX)ARCH)') self.WriteLn('LOCAL_SDK_VERSION := %s' % sdk_version) # Grab output directories; needed for Actions and Rules. if self.toolset == 'host': self.WriteLn('gyp_intermediate_dir := ' '$(call local-intermediates-dir,,$(GYP_HOST_VAR_PREFIX))') else: self.WriteLn('gyp_intermediate_dir := ' '$(call local-intermediates-dir,,$(GYP_VAR_PREFIX))') self.WriteLn('gyp_shared_intermediate_dir := ' '$(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX))') self.WriteLn() # List files this target depends on so that actions/rules/copies/sources # can depend on the list. # TODO: doesn't pull in things through transitive link deps; needed? target_dependencies = [x[1] for x in deps if x[0] == 'path'] self.WriteLn('# Make sure our deps are built first.') self.WriteList(target_dependencies, 'GYP_TARGET_DEPENDENCIES', local_pathify=True) # Actions must come first, since they can generate more OBJs for use below. if 'actions' in spec: self.WriteActions(spec['actions'], extra_sources, extra_outputs) # Rules must be early like actions. if 'rules' in spec: self.WriteRules(spec['rules'], extra_sources, extra_outputs) if 'copies' in spec: self.WriteCopies(spec['copies'], extra_outputs) # GYP generated outputs. self.WriteList(extra_outputs, 'GYP_GENERATED_OUTPUTS', local_pathify=True) # Set LOCAL_ADDITIONAL_DEPENDENCIES so that Android's build rules depend # on both our dependency targets and our generated files. self.WriteLn('# Make sure our deps and generated files are built first.') self.WriteLn('LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) ' '$(GYP_GENERATED_OUTPUTS)') self.WriteLn() # Sources. if spec.get('sources', []) or extra_sources: self.WriteSources(spec, configs, extra_sources) self.WriteTarget(spec, configs, deps, link_deps, part_of_all, write_alias_target) # Update global list of target outputs, used in dependency tracking. target_outputs[qualified_target] = ('path', self.output_binary) # Update global list of link dependencies. if self.type == 'static_library': target_link_deps[qualified_target] = ('static', self.android_module) elif self.type == 'shared_library': target_link_deps[qualified_target] = ('shared', self.android_module) self.fp.close() return self.android_module def WriteActions(self, actions, extra_sources, extra_outputs): """Write Makefile code for any 'actions' from the gyp input. extra_sources: a list that will be filled in with newly generated source files, if any extra_outputs: a list that will be filled in with any outputs of these actions (used to make other pieces dependent on these actions) """ for action in actions: name = make.StringToMakefileVariable('%s_%s' % (self.relative_target, action['action_name'])) self.WriteLn('### Rules for action "%s":' % action['action_name']) inputs = action['inputs'] outputs = action['outputs'] # Build up a list of outputs. # Collect the output dirs we'll need. dirs = set() for out in outputs: if not out.startswith('$'): print ('WARNING: Action for target "%s" writes output to local path ' '"%s".' % (self.target, out)) dir = os.path.split(out)[0] if dir: dirs.add(dir) if int(action.get('process_outputs_as_sources', False)): extra_sources += outputs # Prepare the actual command. command = gyp.common.EncodePOSIXShellList(action['action']) if 'message' in action: quiet_cmd = 'Gyp action: %s ($@)' % action['message'] else: quiet_cmd = 'Gyp action: %s ($@)' % name if len(dirs) > 0: command = 'mkdir -p %s' % ' '.join(dirs) + '; ' + command cd_action = 'cd $(gyp_local_path)/%s; ' % self.path command = cd_action + command # The makefile rules are all relative to the top dir, but the gyp actions # are defined relative to their containing dir. This replaces the gyp_* # variables for the action rule with an absolute version so that the # output goes in the right place. # Only write the gyp_* rules for the "primary" output (:1); # it's superfluous for the "extra outputs", and this avoids accidentally # writing duplicate dummy rules for those outputs. main_output = make.QuoteSpaces(self.LocalPathify(outputs[0])) self.WriteLn('%s: gyp_local_path := $(LOCAL_PATH)' % main_output) self.WriteLn('%s: gyp_var_prefix := $(GYP_VAR_PREFIX)' % main_output) self.WriteLn('%s: gyp_intermediate_dir := ' '$(abspath $(gyp_intermediate_dir))' % main_output) self.WriteLn('%s: gyp_shared_intermediate_dir := ' '$(abspath $(gyp_shared_intermediate_dir))' % main_output) # Android's envsetup.sh adds a number of directories to the path including # the built host binary directory. This causes actions/rules invoked by # gyp to sometimes use these instead of system versions, e.g. bison. # The built host binaries may not be suitable, and can cause errors. # So, we remove them from the PATH using the ANDROID_BUILD_PATHS variable # set by envsetup. self.WriteLn('%s: export PATH := $(subst $(ANDROID_BUILD_PATHS),,$(PATH))' % main_output) # Don't allow spaces in input/output filenames, but make an exception for # filenames which start with '$(' since it's okay for there to be spaces # inside of make function/macro invocations. for input in inputs: if not input.startswith('$(') and ' ' in input: raise gyp.common.GypError( 'Action input filename "%s" in target %s contains a space' % (input, self.target)) for output in outputs: if not output.startswith('$(') and ' ' in output: raise gyp.common.GypError( 'Action output filename "%s" in target %s contains a space' % (output, self.target)) self.WriteLn('%s: %s $(GYP_TARGET_DEPENDENCIES)' % (main_output, ' '.join(map(self.LocalPathify, inputs)))) self.WriteLn('\t@echo "%s"' % quiet_cmd) self.WriteLn('\t$(hide)%s\n' % command) for output in outputs[1:]: # Make each output depend on the main output, with an empty command # to force make to notice that the mtime has changed. self.WriteLn('%s: %s ;' % (self.LocalPathify(output), main_output)) extra_outputs += outputs self.WriteLn() self.WriteLn() def WriteRules(self, rules, extra_sources, extra_outputs): """Write Makefile code for any 'rules' from the gyp input. extra_sources: a list that will be filled in with newly generated source files, if any extra_outputs: a list that will be filled in with any outputs of these rules (used to make other pieces dependent on these rules) """ if len(rules) == 0: return for rule in rules: if len(rule.get('rule_sources', [])) == 0: continue name = make.StringToMakefileVariable('%s_%s' % (self.relative_target, rule['rule_name'])) self.WriteLn('\n### Generated for rule "%s":' % name) self.WriteLn('# "%s":' % rule) inputs = rule.get('inputs') for rule_source in rule.get('rule_sources', []): (rule_source_dirname, rule_source_basename) = os.path.split(rule_source) (rule_source_root, rule_source_ext) = \ os.path.splitext(rule_source_basename) outputs = [self.ExpandInputRoot(out, rule_source_root, rule_source_dirname) for out in rule['outputs']] dirs = set() for out in outputs: if not out.startswith('$'): print ('WARNING: Rule for target %s writes output to local path %s' % (self.target, out)) dir = os.path.dirname(out) if dir: dirs.add(dir) extra_outputs += outputs if int(rule.get('process_outputs_as_sources', False)): extra_sources.extend(outputs) components = [] for component in rule['action']: component = self.ExpandInputRoot(component, rule_source_root, rule_source_dirname) if '$(RULE_SOURCES)' in component: component = component.replace('$(RULE_SOURCES)', rule_source) components.append(component) command = gyp.common.EncodePOSIXShellList(components) cd_action = 'cd $(gyp_local_path)/%s; ' % self.path command = cd_action + command if dirs: command = 'mkdir -p %s' % ' '.join(dirs) + '; ' + command # We set up a rule to build the first output, and then set up # a rule for each additional output to depend on the first. outputs = map(self.LocalPathify, outputs) main_output = outputs[0] self.WriteLn('%s: gyp_local_path := $(LOCAL_PATH)' % main_output) self.WriteLn('%s: gyp_var_prefix := $(GYP_VAR_PREFIX)' % main_output) self.WriteLn('%s: gyp_intermediate_dir := ' '$(abspath $(gyp_intermediate_dir))' % main_output) self.WriteLn('%s: gyp_shared_intermediate_dir := ' '$(abspath $(gyp_shared_intermediate_dir))' % main_output) # See explanation in WriteActions. self.WriteLn('%s: export PATH := ' '$(subst $(ANDROID_BUILD_PATHS),,$(PATH))' % main_output) main_output_deps = self.LocalPathify(rule_source) if inputs: main_output_deps += ' ' main_output_deps += ' '.join([self.LocalPathify(f) for f in inputs]) self.WriteLn('%s: %s $(GYP_TARGET_DEPENDENCIES)' % (main_output, main_output_deps)) self.WriteLn('\t%s\n' % command) for output in outputs[1:]: # Make each output depend on the main output, with an empty command # to force make to notice that the mtime has changed. self.WriteLn('%s: %s ;' % (output, main_output)) self.WriteLn() self.WriteLn() def WriteCopies(self, copies, extra_outputs): """Write Makefile code for any 'copies' from the gyp input. extra_outputs: a list that will be filled in with any outputs of this action (used to make other pieces dependent on this action) """ self.WriteLn('### Generated for copy rule.') variable = make.StringToMakefileVariable(self.relative_target + '_copies') outputs = [] for copy in copies: for path in copy['files']: # The Android build system does not allow generation of files into the # source tree. The destination should start with a variable, which will # typically be $(gyp_intermediate_dir) or # $(gyp_shared_intermediate_dir). Note that we can't use an assertion # because some of the gyp tests depend on this. if not copy['destination'].startswith('$'): print ('WARNING: Copy rule for target %s writes output to ' 'local path %s' % (self.target, copy['destination'])) # LocalPathify() calls normpath, stripping trailing slashes. path = Sourceify(self.LocalPathify(path)) filename = os.path.split(path)[1] output = Sourceify(self.LocalPathify(os.path.join(copy['destination'], filename))) self.WriteLn('%s: %s $(GYP_TARGET_DEPENDENCIES) | $(ACP)' % (output, path)) self.WriteLn('\t@echo Copying: $@') self.WriteLn('\t$(hide) mkdir -p $(dir $@)') self.WriteLn('\t$(hide) $(ACP) -rpf $< $@') self.WriteLn() outputs.append(output) self.WriteLn('%s = %s' % (variable, ' '.join(map(make.QuoteSpaces, outputs)))) extra_outputs.append('$(%s)' % variable) self.WriteLn() def WriteSourceFlags(self, spec, configs): """Write out the flags and include paths used to compile source files for the current target. Args: spec, configs: input from gyp. """ for configname, config in sorted(configs.iteritems()): extracted_includes = [] self.WriteLn('\n# Flags passed to both C and C++ files.') cflags, includes_from_cflags = self.ExtractIncludesFromCFlags( config.get('cflags', []) + config.get('cflags_c', [])) extracted_includes.extend(includes_from_cflags) self.WriteList(cflags, 'MY_CFLAGS_%s' % configname) self.WriteList(config.get('defines'), 'MY_DEFS_%s' % configname, prefix='-D', quoter=make.EscapeCppDefine) self.WriteLn('\n# Include paths placed before CFLAGS/CPPFLAGS') includes = list(config.get('include_dirs', [])) includes.extend(extracted_includes) includes = map(Sourceify, map(self.LocalPathify, includes)) includes = self.NormalizeIncludePaths(includes) self.WriteList(includes, 'LOCAL_C_INCLUDES_%s' % configname) self.WriteLn('\n# Flags passed to only C++ (and not C) files.') self.WriteList(config.get('cflags_cc'), 'LOCAL_CPPFLAGS_%s' % configname) self.WriteLn('\nLOCAL_CFLAGS := $(MY_CFLAGS_$(GYP_CONFIGURATION)) ' '$(MY_DEFS_$(GYP_CONFIGURATION))') # Undefine ANDROID for host modules # TODO: the source code should not use macro ANDROID to tell if it's host # or target module. if self.toolset == 'host': self.WriteLn('# Undefine ANDROID for host modules') self.WriteLn('LOCAL_CFLAGS += -UANDROID') self.WriteLn('LOCAL_C_INCLUDES := $(GYP_COPIED_SOURCE_ORIGIN_DIRS) ' '$(LOCAL_C_INCLUDES_$(GYP_CONFIGURATION))') self.WriteLn('LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS_$(GYP_CONFIGURATION))') # Android uses separate flags for assembly file invocations, but gyp expects # the same CFLAGS to be applied: self.WriteLn('LOCAL_ASFLAGS := $(LOCAL_CFLAGS)') def WriteSources(self, spec, configs, extra_sources): """Write Makefile code for any 'sources' from the gyp input. These are source files necessary to build the current target. We need to handle shared_intermediate directory source files as a special case by copying them to the intermediate directory and treating them as a genereated sources. Otherwise the Android build rules won't pick them up. Args: spec, configs: input from gyp. extra_sources: Sources generated from Actions or Rules. """ sources = filter(make.Compilable, spec.get('sources', [])) generated_not_sources = [x for x in extra_sources if not make.Compilable(x)] extra_sources = filter(make.Compilable, extra_sources) # Determine and output the C++ extension used by these sources. # We simply find the first C++ file and use that extension. all_sources = sources + extra_sources local_cpp_extension = '.cpp' for source in all_sources: (root, ext) = os.path.splitext(source) if IsCPPExtension(ext): local_cpp_extension = ext break if local_cpp_extension != '.cpp': self.WriteLn('LOCAL_CPP_EXTENSION := %s' % local_cpp_extension) # We need to move any non-generated sources that are coming from the # shared intermediate directory out of LOCAL_SRC_FILES and put them # into LOCAL_GENERATED_SOURCES. We also need to move over any C++ files # that don't match our local_cpp_extension, since Android will only # generate Makefile rules for a single LOCAL_CPP_EXTENSION. local_files = [] for source in sources: (root, ext) = os.path.splitext(source) if '$(gyp_shared_intermediate_dir)' in source: extra_sources.append(source) elif '$(gyp_intermediate_dir)' in source: extra_sources.append(source) elif IsCPPExtension(ext) and ext != local_cpp_extension: extra_sources.append(source) else: local_files.append(os.path.normpath(os.path.join(self.path, source))) # For any generated source, if it is coming from the shared intermediate # directory then we add a Make rule to copy them to the local intermediate # directory first. This is because the Android LOCAL_GENERATED_SOURCES # must be in the local module intermediate directory for the compile rules # to work properly. If the file has the wrong C++ extension, then we add # a rule to copy that to intermediates and use the new version. final_generated_sources = [] # If a source file gets copied, we still need to add the orginal source # directory as header search path, for GCC searches headers in the # directory that contains the source file by default. origin_src_dirs = [] for source in extra_sources: local_file = source if not '$(gyp_intermediate_dir)/' in local_file: basename = os.path.basename(local_file) local_file = '$(gyp_intermediate_dir)/' + basename (root, ext) = os.path.splitext(local_file) if IsCPPExtension(ext) and ext != local_cpp_extension: local_file = root + local_cpp_extension if local_file != source: self.WriteLn('%s: %s' % (local_file, self.LocalPathify(source))) self.WriteLn('\tmkdir -p $(@D); cp $< $@') origin_src_dirs.append(os.path.dirname(source)) final_generated_sources.append(local_file) # We add back in all of the non-compilable stuff to make sure that the # make rules have dependencies on them. final_generated_sources.extend(generated_not_sources) self.WriteList(final_generated_sources, 'LOCAL_GENERATED_SOURCES') origin_src_dirs = gyp.common.uniquer(origin_src_dirs) origin_src_dirs = map(Sourceify, map(self.LocalPathify, origin_src_dirs)) self.WriteList(origin_src_dirs, 'GYP_COPIED_SOURCE_ORIGIN_DIRS') self.WriteList(local_files, 'LOCAL_SRC_FILES') # Write out the flags used to compile the source; this must be done last # so that GYP_COPIED_SOURCE_ORIGIN_DIRS can be used as an include path. self.WriteSourceFlags(spec, configs) def ComputeAndroidModule(self, spec): """Return the Android module name used for a gyp spec. We use the complete qualified target name to avoid collisions between duplicate targets in different directories. We also add a suffix to distinguish gyp-generated module names. """ if int(spec.get('android_unmangled_name', 0)): assert self.type != 'shared_library' or self.target.startswith('lib') return self.target if self.type == 'shared_library': # For reasons of convention, the Android build system requires that all # shared library modules are named 'libfoo' when generating -l flags. prefix = 'lib_' else: prefix = '' if spec['toolset'] == 'host': suffix = '_$(TARGET_$(GYP_VAR_PREFIX)ARCH)_host_gyp' else: suffix = '_gyp' if self.path: middle = make.StringToMakefileVariable('%s_%s' % (self.path, self.target)) else: middle = make.StringToMakefileVariable(self.target) return ''.join([prefix, middle, suffix]) def ComputeOutputParts(self, spec): """Return the 'output basename' of a gyp spec, split into filename + ext. Android libraries must be named the same thing as their module name, otherwise the linker can't find them, so product_name and so on must be ignored if we are building a library, and the "lib" prepending is not done for Android. """ assert self.type != 'loadable_module' # TODO: not supported? target = spec['target_name'] target_prefix = '' target_ext = '' if self.type == 'static_library': target = self.ComputeAndroidModule(spec) target_ext = '.a' elif self.type == 'shared_library': target = self.ComputeAndroidModule(spec) target_ext = '.so' elif self.type == 'none': target_ext = '.stamp' elif self.type != 'executable': print ("ERROR: What output file should be generated?", "type", self.type, "target", target) if self.type != 'static_library' and self.type != 'shared_library': target_prefix = spec.get('product_prefix', target_prefix) target = spec.get('product_name', target) product_ext = spec.get('product_extension') if product_ext: target_ext = '.' + product_ext target_stem = target_prefix + target return (target_stem, target_ext) def ComputeOutputBasename(self, spec): """Return the 'output basename' of a gyp spec. E.g., the loadable module 'foobar' in directory 'baz' will produce 'libfoobar.so' """ return ''.join(self.ComputeOutputParts(spec)) def ComputeOutput(self, spec): """Return the 'output' (full output path) of a gyp spec. E.g., the loadable module 'foobar' in directory 'baz' will produce '$(obj)/baz/libfoobar.so' """ if self.type == 'executable': # We install host executables into shared_intermediate_dir so they can be # run by gyp rules that refer to PRODUCT_DIR. path = '$(gyp_shared_intermediate_dir)' elif self.type == 'shared_library': if self.toolset == 'host': path = '$($(GYP_HOST_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES)' else: path = '$($(GYP_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)' else: # Other targets just get built into their intermediate dir. if self.toolset == 'host': path = ('$(call intermediates-dir-for,%s,%s,true,,' '$(GYP_HOST_VAR_PREFIX))' % (self.android_class, self.android_module)) else: path = ('$(call intermediates-dir-for,%s,%s,,,$(GYP_VAR_PREFIX))' % (self.android_class, self.android_module)) assert spec.get('product_dir') is None # TODO: not supported? return os.path.join(path, self.ComputeOutputBasename(spec)) def NormalizeIncludePaths(self, include_paths): """ Normalize include_paths. Convert absolute paths to relative to the Android top directory. Args: include_paths: A list of unprocessed include paths. Returns: A list of normalized include paths. """ normalized = [] for path in include_paths: if path[0] == '/': path = gyp.common.RelativePath(path, self.android_top_dir) normalized.append(path) return normalized def ExtractIncludesFromCFlags(self, cflags): """Extract includes "-I..." out from cflags Args: cflags: A list of compiler flags, which may be mixed with "-I.." Returns: A tuple of lists: (clean_clfags, include_paths). "-I.." is trimmed. """ clean_cflags = [] include_paths = [] for flag in cflags: if flag.startswith('-I'): include_paths.append(flag[2:]) else: clean_cflags.append(flag) return (clean_cflags, include_paths) def FilterLibraries(self, libraries): """Filter the 'libraries' key to separate things that shouldn't be ldflags. Library entries that look like filenames should be converted to android module names instead of being passed to the linker as flags. Args: libraries: the value of spec.get('libraries') Returns: A tuple (static_lib_modules, dynamic_lib_modules, ldflags) """ static_lib_modules = [] dynamic_lib_modules = [] ldflags = [] for libs in libraries: # Libs can have multiple words. for lib in libs.split(): # Filter the system libraries, which are added by default by the Android # build system. if (lib == '-lc' or lib == '-lstdc++' or lib == '-lm' or lib.endswith('libgcc.a')): continue match = re.search(r'([^/]+)\.a$', lib) if match: static_lib_modules.append(match.group(1)) continue match = re.search(r'([^/]+)\.so$', lib) if match: dynamic_lib_modules.append(match.group(1)) continue if lib.startswith('-l'): ldflags.append(lib) return (static_lib_modules, dynamic_lib_modules, ldflags) def ComputeDeps(self, spec): """Compute the dependencies of a gyp spec. Returns a tuple (deps, link_deps), where each is a list of filenames that will need to be put in front of make for either building (deps) or linking (link_deps). """ deps = [] link_deps = [] if 'dependencies' in spec: deps.extend([target_outputs[dep] for dep in spec['dependencies'] if target_outputs[dep]]) for dep in spec['dependencies']: if dep in target_link_deps: link_deps.append(target_link_deps[dep]) deps.extend(link_deps) return (gyp.common.uniquer(deps), gyp.common.uniquer(link_deps)) def WriteTargetFlags(self, spec, configs, link_deps): """Write Makefile code to specify the link flags and library dependencies. spec, configs: input from gyp. link_deps: link dependency list; see ComputeDeps() """ # Libraries (i.e. -lfoo) # These must be included even for static libraries as some of them provide # implicit include paths through the build system. libraries = gyp.common.uniquer(spec.get('libraries', [])) static_libs, dynamic_libs, ldflags_libs = self.FilterLibraries(libraries) if self.type != 'static_library': for configname, config in sorted(configs.iteritems()): ldflags = list(config.get('ldflags', [])) self.WriteLn('') self.WriteList(ldflags, 'LOCAL_LDFLAGS_%s' % configname) self.WriteList(ldflags_libs, 'LOCAL_GYP_LIBS') self.WriteLn('LOCAL_LDFLAGS := $(LOCAL_LDFLAGS_$(GYP_CONFIGURATION)) ' '$(LOCAL_GYP_LIBS)') # Link dependencies (i.e. other gyp targets this target depends on) # These need not be included for static libraries as within the gyp build # we do not use the implicit include path mechanism. if self.type != 'static_library': static_link_deps = [x[1] for x in link_deps if x[0] == 'static'] shared_link_deps = [x[1] for x in link_deps if x[0] == 'shared'] else: static_link_deps = [] shared_link_deps = [] # Only write the lists if they are non-empty. if static_libs or static_link_deps: self.WriteLn('') self.WriteList(static_libs + static_link_deps, 'LOCAL_STATIC_LIBRARIES') self.WriteLn('# Enable grouping to fix circular references') self.WriteLn('LOCAL_GROUP_STATIC_LIBRARIES := true') if dynamic_libs or shared_link_deps: self.WriteLn('') self.WriteList(dynamic_libs + shared_link_deps, 'LOCAL_SHARED_LIBRARIES') def WriteTarget(self, spec, configs, deps, link_deps, part_of_all, write_alias_target): """Write Makefile code to produce the final target of the gyp spec. spec, configs: input from gyp. deps, link_deps: dependency lists; see ComputeDeps() part_of_all: flag indicating this target is part of 'all' write_alias_target: flag indicating whether to create short aliases for this target """ self.WriteLn('### Rules for final target.') if self.type != 'none': self.WriteTargetFlags(spec, configs, link_deps) settings = spec.get('aosp_build_settings', {}) if settings: self.WriteLn('### Set directly by aosp_build_settings.') for k, v in settings.iteritems(): if isinstance(v, list): self.WriteList(v, k) else: self.WriteLn('%s := %s' % (k, make.QuoteIfNecessary(v))) self.WriteLn('') # Add to the set of targets which represent the gyp 'all' target. We use the # name 'gyp_all_modules' as the Android build system doesn't allow the use # of the Make target 'all' and because 'all_modules' is the equivalent of # the Make target 'all' on Android. if part_of_all and write_alias_target: self.WriteLn('# Add target alias to "gyp_all_modules" target.') self.WriteLn('.PHONY: gyp_all_modules') self.WriteLn('gyp_all_modules: %s' % self.android_module) self.WriteLn('') # Add an alias from the gyp target name to the Android module name. This # simplifies manual builds of the target, and is required by the test # framework. if self.target != self.android_module and write_alias_target: self.WriteLn('# Alias gyp target name.') self.WriteLn('.PHONY: %s' % self.target) self.WriteLn('%s: %s' % (self.target, self.android_module)) self.WriteLn('') # Add the command to trigger build of the target type depending # on the toolset. Ex: BUILD_STATIC_LIBRARY vs. BUILD_HOST_STATIC_LIBRARY # NOTE: This has to come last! modifier = '' if self.toolset == 'host': modifier = 'HOST_' if self.type == 'static_library': self.WriteLn('include $(BUILD_%sSTATIC_LIBRARY)' % modifier) elif self.type == 'shared_library': self.WriteLn('LOCAL_PRELINK_MODULE := false') self.WriteLn('include $(BUILD_%sSHARED_LIBRARY)' % modifier) elif self.type == 'executable': self.WriteLn('LOCAL_CXX_STL := libc++_static') # Executables are for build and test purposes only, so they're installed # to a directory that doesn't get included in the system image. self.WriteLn('LOCAL_MODULE_PATH := $(gyp_shared_intermediate_dir)') self.WriteLn('include $(BUILD_%sEXECUTABLE)' % modifier) else: self.WriteLn('LOCAL_MODULE_PATH := $(PRODUCT_OUT)/gyp_stamp') self.WriteLn('LOCAL_UNINSTALLABLE_MODULE := true') if self.toolset == 'target': self.WriteLn('LOCAL_2ND_ARCH_VAR_PREFIX := $(GYP_VAR_PREFIX)') else: self.WriteLn('LOCAL_2ND_ARCH_VAR_PREFIX := $(GYP_HOST_VAR_PREFIX)') self.WriteLn() self.WriteLn('include $(BUILD_SYSTEM)/base_rules.mk') self.WriteLn() self.WriteLn('$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES)') self.WriteLn('\t$(hide) echo "Gyp timestamp: $@"') self.WriteLn('\t$(hide) mkdir -p $(dir $@)') self.WriteLn('\t$(hide) touch $@') self.WriteLn() self.WriteLn('LOCAL_2ND_ARCH_VAR_PREFIX :=') def WriteList(self, value_list, variable=None, prefix='', quoter=make.QuoteIfNecessary, local_pathify=False): """Write a variable definition that is a list of values. E.g. WriteList(['a','b'], 'foo', prefix='blah') writes out foo = blaha blahb but in a pretty-printed style. """ values = '' if value_list: value_list = [quoter(prefix + l) for l in value_list] if local_pathify: value_list = [self.LocalPathify(l) for l in value_list] values = ' \\\n\t' + ' \\\n\t'.join(value_list) self.fp.write('%s :=%s\n\n' % (variable, values)) def WriteLn(self, text=''): self.fp.write(text + '\n') def LocalPathify(self, path): """Convert a subdirectory-relative path into a normalized path which starts with the make variable $(LOCAL_PATH) (i.e. the top of the project tree). Absolute paths, or paths that contain variables, are just normalized.""" if '$(' in path or os.path.isabs(path): # path is not a file in the project tree in this case, but calling # normpath is still important for trimming trailing slashes. return os.path.normpath(path) local_path = os.path.join('$(LOCAL_PATH)', self.path, path) local_path = os.path.normpath(local_path) # Check that normalizing the path didn't ../ itself out of $(LOCAL_PATH) # - i.e. that the resulting path is still inside the project tree. The # path may legitimately have ended up containing just $(LOCAL_PATH), though, # so we don't look for a slash. assert local_path.startswith('$(LOCAL_PATH)'), ( 'Path %s attempts to escape from gyp path %s !)' % (path, self.path)) return local_path def ExpandInputRoot(self, template, expansion, dirname): if '%(INPUT_ROOT)s' not in template and '%(INPUT_DIRNAME)s' not in template: return template path = template % { 'INPUT_ROOT': expansion, 'INPUT_DIRNAME': dirname, } return os.path.normpath(path) def PerformBuild(data, configurations, params): # The android backend only supports the default configuration. options = params['options'] makefile = os.path.abspath(os.path.join(options.toplevel_dir, 'GypAndroid.mk')) env = dict(os.environ) env['ONE_SHOT_MAKEFILE'] = makefile arguments = ['make', '-C', os.environ['ANDROID_BUILD_TOP'], 'gyp_all_modules'] print 'Building: %s' % arguments subprocess.check_call(arguments, env=env) def GenerateOutput(target_list, target_dicts, data, params): options = params['options'] generator_flags = params.get('generator_flags', {}) builddir_name = generator_flags.get('output_dir', 'out') limit_to_target_all = generator_flags.get('limit_to_target_all', False) write_alias_targets = generator_flags.get('write_alias_targets', True) sdk_version = generator_flags.get('aosp_sdk_version', 0) android_top_dir = os.environ.get('ANDROID_BUILD_TOP') assert android_top_dir, '$ANDROID_BUILD_TOP not set; you need to run lunch.' def CalculateMakefilePath(build_file, base_name): """Determine where to write a Makefile for a given gyp file.""" # Paths in gyp files are relative to the .gyp file, but we want # paths relative to the source root for the master makefile. Grab # the path of the .gyp file as the base to relativize against. # E.g. "foo/bar" when we're constructing targets for "foo/bar/baz.gyp". base_path = gyp.common.RelativePath(os.path.dirname(build_file), options.depth) # We write the file in the base_path directory. output_file = os.path.join(options.depth, base_path, base_name) assert not options.generator_output, ( 'The Android backend does not support options.generator_output.') base_path = gyp.common.RelativePath(os.path.dirname(build_file), options.toplevel_dir) return base_path, output_file # TODO: search for the first non-'Default' target. This can go # away when we add verification that all targets have the # necessary configurations. default_configuration = None toolsets = set([target_dicts[target]['toolset'] for target in target_list]) for target in target_list: spec = target_dicts[target] if spec['default_configuration'] != 'Default': default_configuration = spec['default_configuration'] break if not default_configuration: default_configuration = 'Default' srcdir = '.' makefile_name = 'GypAndroid' + options.suffix + '.mk' makefile_path = os.path.join(options.toplevel_dir, makefile_name) assert not options.generator_output, ( 'The Android backend does not support options.generator_output.') gyp.common.EnsureDirExists(makefile_path) root_makefile = open(makefile_path, 'w') root_makefile.write(header) # We set LOCAL_PATH just once, here, to the top of the project tree. This # allows all the other paths we use to be relative to the Android.mk file, # as the Android build system expects. root_makefile.write('\nLOCAL_PATH := $(call my-dir)\n') # Find the list of targets that derive from the gyp file(s) being built. needed_targets = set() for build_file in params['build_files']: for target in gyp.common.AllTargets(target_list, target_dicts, build_file): needed_targets.add(target) build_files = set() include_list = set() android_modules = {} for qualified_target in target_list: build_file, target, toolset = gyp.common.ParseQualifiedTarget( qualified_target) relative_build_file = gyp.common.RelativePath(build_file, options.toplevel_dir) build_files.add(relative_build_file) included_files = data[build_file]['included_files'] for included_file in included_files: # The included_files entries are relative to the dir of the build file # that included them, so we have to undo that and then make them relative # to the root dir. relative_include_file = gyp.common.RelativePath( gyp.common.UnrelativePath(included_file, build_file), options.toplevel_dir) abs_include_file = os.path.abspath(relative_include_file) # If the include file is from the ~/.gyp dir, we should use absolute path # so that relocating the src dir doesn't break the path. if (params['home_dot_gyp'] and abs_include_file.startswith(params['home_dot_gyp'])): build_files.add(abs_include_file) else: build_files.add(relative_include_file) base_path, output_file = CalculateMakefilePath(build_file, target + '.' + toolset + options.suffix + '.mk') spec = target_dicts[qualified_target] configs = spec['configurations'] part_of_all = qualified_target in needed_targets if limit_to_target_all and not part_of_all: continue relative_target = gyp.common.QualifiedTarget(relative_build_file, target, toolset) writer = AndroidMkWriter(android_top_dir) android_module = writer.Write(qualified_target, relative_target, base_path, output_file, spec, configs, part_of_all=part_of_all, write_alias_target=write_alias_targets, sdk_version=sdk_version) if android_module in android_modules: print ('ERROR: Android module names must be unique. The following ' 'targets both generate Android module name %s.\n %s\n %s' % (android_module, android_modules[android_module], qualified_target)) return android_modules[android_module] = qualified_target # Our root_makefile lives at the source root. Compute the relative path # from there to the output_file for including. mkfile_rel_path = gyp.common.RelativePath(output_file, os.path.dirname(makefile_path)) include_list.add(mkfile_rel_path) root_makefile.write('GYP_CONFIGURATION ?= %s\n' % default_configuration) root_makefile.write('GYP_VAR_PREFIX ?=\n') root_makefile.write('GYP_HOST_VAR_PREFIX ?=\n') root_makefile.write('GYP_HOST_MULTILIB ?= first\n') # Write out the sorted list of includes. root_makefile.write('\n') for include_file in sorted(include_list): root_makefile.write('include $(LOCAL_PATH)/' + include_file + '\n') root_makefile.write('\n') if write_alias_targets: root_makefile.write(ALL_MODULES_FOOTER) root_makefile.close()
mit
[ 3, 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 3, 8144, 26, 199, 3, 199, 3, 961, 12821, 1852, 1725, 11233, 367, 20396, 1901, 314, 14694, 1900, 2656, 199, 3, 4799, 376, 14694, 14, 3880, 570, 14, 2779, 365, 4079, 641, 1852, 14, 647, 12, 314, 4465, 16818, 199, 3, 4306, 14, 199, 3, 199, 3, 710, 1233, 5084, 12821, 282, 7396, 1275, 3880, 570, 367, 1924, 1347, 12, 1325, 199, 3, 1006, 787, 1350, 68, 701, 314, 2746, 13, 1896, 14133, 20762, 14, 3880, 14, 221, 961, 4910, 626, 1006, 199, 3, 2860, 315, 1275, 3880, 13, 1725, 286, 22669, 1373, 4573, 12, 436, 9848, 6878, 626, 1263, 199, 3, 2860, 663, 18994, 30109, 543, 1163, 14694, 1900, 2656, 2860, 14, 199, 3, 7649, 370, 5126, 4260, 2288, 2860, 2382, 3962, 14, 199, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 4679, 14, 1875, 465, 1852, 221, 327, 799, 1180, 2288, 3423, 687, 1852, 4865, 14, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 3100, 356, 283, 6238, 297, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 12273, 356, 1987, 1152, 297, 523, 283, 23227, 63, 3022, 356, 9774, 6179, 63, 15940, 63, 694, 3196, 523, 283, 13772, 63, 23227, 63, 3022, 356, 9774, 6179, 63, 5555, 63, 15940, 63, 694, 3196, 523, 283, 14853, 63, 3022, 356, 9774, 6179, 63, 5555, 63, 15940, 63, 694, 3196, 523, 283, 13772, 63, 5617, 63, 3022, 356, 9774, 21728, 2447, 773, 24752, 16892, 3196, 523, 283, 5617, 63, 3022, 356, 9774, 1113, 680, 6629, 16892, 3196, 523, 283, 13578, 63, 7321, 63, 5441, 356, 9487, 7321, 63, 5441, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 9487, 7321, 63, 3022, 2339, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3243, 356, 9774, 13578, 63, 25744, 3196, 523, 283, 13578, 63, 7321, 63, 2472, 356, 9774, 4511, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2339, 356, 9774, 1397, 694, 2672, 28, 3196, 523, 283, 22212, 63, 2339, 356, 9774, 14884, 63, 22212, 3196, 199, 93, 199, 199, 3, 4155, 5171, 3663, 4744, 2193, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 421, 199, 3, 15042, 13, 6100, 4902, 15941, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 359, 272, 327, 9411, 370, 20771, 626, 642, 1347, 1630, 440, 2934, 2399, 536, 333, 22183, 14, 272, 283, 6238, 63, 324, 77, 22183, 63, 354, 297, 272, 327, 9672, 402, 15516, 1900, 2656, 2860, 370, 663, 14, 272, 283, 8035, 681, 63, 1506, 63, 1751, 297, 199, 61, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 421, 199, 1761, 63, 21194, 63, 13046, 1157, 275, 9638, 199, 3, 298, 6179, 63, 452, 63, 3112, 2, 365, 282, 28207, 402, 314, 298, 6179, 63, 452, 63, 3112, 2, 4545, 687, 199, 3, 1006, 314, 5120, 1007, 13, 1875, 1725, 14, 961, 365, 2951, 2348, 370, 824, 285, 2021, 14, 199, 6179, 63, 452, 63, 3112, 26, 199, 624, 199, 199, 1291, 275, 9638, 199, 3, 961, 570, 365, 4046, 701, 4902, 27, 886, 440, 5283, 14, 199, 199, 624, 199, 199, 3, 9672, 4902, 1347, 2943, 370, 14694, 859, 3992, 14, 199, 10001, 63, 13748, 275, 469, 272, 283, 1986, 63, 4342, 356, 283, 10449, 63, 32723, 297, 272, 283, 5555, 63, 4342, 356, 283, 13772, 63, 32723, 297, 272, 283, 5904, 356, 283, 18074, 17041, 297, 199, 93, 421, 199, 318, 6596, 14533, 6382, 8, 832, 304, 523, 372, 1852, 14, 6790, 1193, 2617, 63, 18451, 14, 362, 8, 832, 9, 508, 283, 9634, 7, 421, 199, 318, 5800, 2021, 8, 515, 304, 523, 408, 7306, 282, 931, 370, 2399, 1350, 2082, 1824, 14, 710, 14694, 4865, 1630, 440, 1362, 2291, 1511, 14, 4679, 63, 1199, 12, 880, 642, 805, 365, 282, 29689, 1041, 523, 372, 931, 421, 199, 3, 9672, 687, 12313, 1347, 370, 931, 370, 1072, 14, 199, 3, 2104, 14694, 12, 314, 1347, 402, 3520, 9033, 365, 282, 2008, 661, 1986, 297, 283, 22582, 659, 199, 3, 661, 7764, 297, 283, 22582, 659, 503, 661, 515, 297, 283, 3972, 15, 515, 358, 3140, 402, 282, 1059, 12, 199, 3, 3967, 781, 2142, 701, 859, 14, 199, 1375, 63, 4467, 275, 1052, 199, 3, 9672, 687, 12313, 1347, 370, 1263, 30258, 1072, 14, 221, 437, 10026, 199, 3, 402, 1347, 63, 4467, 14, 221, 662, 14, 71, 14, 1380, 3002, 3008, 8350, 641, 1973, 65, 12, 781, 2934, 370, 199, 3, 2387, 1973, 65, 315, 314, 17261, 1004, 27, 1380, 1163, 3008, 8350, 641, 199, 3, 3002, 3008, 12, 781, 2951, 2934, 370, 1900, 3002, 3008, 1642, 14, 199, 1375, 63, 1073, 63, 5846, 275, 1052, 421, 199, 533, 14694, 31506, 6261, 8, 785, 304, 523, 408, 20762, 31506, 6261, 6117, 1536, 314, 3575, 402, 1373, 1347, 13, 6100, 14694, 14, 3880, 14, 819, 22940, 1454, 3363, 2397, 2376, 365, 6990, 1062, 436, 365, 19762, 1202, 367, 1561, 29277, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 15516, 63, 2119, 63, 694, 304, 272, 291, 14, 6238, 63, 2119, 63, 694, 275, 15516, 63, 2119, 63, 694, 819, 347, 6990, 8, 277, 12, 12313, 63, 1375, 12, 3847, 63, 1375, 12, 1300, 63, 515, 12, 1072, 63, 1501, 12, 288, 3158, 12, 11585, 12, 1777, 63, 1618, 63, 452, 12, 2218, 63, 3620, 63, 1375, 12, 13628, 63, 1023, 304, 272, 408, 1918, 2446, 2397, 2376, 26, 14511 ]
[ 1898, 334, 67, 9, 6029, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 3, 8144, 26, 199, 3, 199, 3, 961, 12821, 1852, 1725, 11233, 367, 20396, 1901, 314, 14694, 1900, 2656, 199, 3, 4799, 376, 14694, 14, 3880, 570, 14, 2779, 365, 4079, 641, 1852, 14, 647, 12, 314, 4465, 16818, 199, 3, 4306, 14, 199, 3, 199, 3, 710, 1233, 5084, 12821, 282, 7396, 1275, 3880, 570, 367, 1924, 1347, 12, 1325, 199, 3, 1006, 787, 1350, 68, 701, 314, 2746, 13, 1896, 14133, 20762, 14, 3880, 14, 221, 961, 4910, 626, 1006, 199, 3, 2860, 315, 1275, 3880, 13, 1725, 286, 22669, 1373, 4573, 12, 436, 9848, 6878, 626, 1263, 199, 3, 2860, 663, 18994, 30109, 543, 1163, 14694, 1900, 2656, 2860, 14, 199, 3, 7649, 370, 5126, 4260, 2288, 2860, 2382, 3962, 14, 199, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 4679, 14, 1875, 465, 1852, 221, 327, 799, 1180, 2288, 3423, 687, 1852, 4865, 14, 199, 646, 747, 199, 646, 295, 199, 646, 3873, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 3100, 356, 283, 6238, 297, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 12273, 356, 1987, 1152, 297, 523, 283, 23227, 63, 3022, 356, 9774, 6179, 63, 15940, 63, 694, 3196, 523, 283, 13772, 63, 23227, 63, 3022, 356, 9774, 6179, 63, 5555, 63, 15940, 63, 694, 3196, 523, 283, 14853, 63, 3022, 356, 9774, 6179, 63, 5555, 63, 15940, 63, 694, 3196, 523, 283, 13772, 63, 5617, 63, 3022, 356, 9774, 21728, 2447, 773, 24752, 16892, 3196, 523, 283, 5617, 63, 3022, 356, 9774, 1113, 680, 6629, 16892, 3196, 523, 283, 13578, 63, 7321, 63, 5441, 356, 9487, 7321, 63, 5441, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 9487, 7321, 63, 3022, 2339, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3243, 356, 9774, 13578, 63, 25744, 3196, 523, 283, 13578, 63, 7321, 63, 2472, 356, 9774, 4511, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2339, 356, 9774, 1397, 694, 2672, 28, 3196, 523, 283, 22212, 63, 2339, 356, 9774, 14884, 63, 22212, 3196, 199, 93, 199, 199, 3, 4155, 5171, 3663, 4744, 2193, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 421, 199, 3, 15042, 13, 6100, 4902, 15941, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 359, 272, 327, 9411, 370, 20771, 626, 642, 1347, 1630, 440, 2934, 2399, 536, 333, 22183, 14, 272, 283, 6238, 63, 324, 77, 22183, 63, 354, 297, 272, 327, 9672, 402, 15516, 1900, 2656, 2860, 370, 663, 14, 272, 283, 8035, 681, 63, 1506, 63, 1751, 297, 199, 61, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 421, 199, 1761, 63, 21194, 63, 13046, 1157, 275, 9638, 199, 3, 298, 6179, 63, 452, 63, 3112, 2, 365, 282, 28207, 402, 314, 298, 6179, 63, 452, 63, 3112, 2, 4545, 687, 199, 3, 1006, 314, 5120, 1007, 13, 1875, 1725, 14, 961, 365, 2951, 2348, 370, 824, 285, 2021, 14, 199, 6179, 63, 452, 63, 3112, 26, 199, 624, 199, 199, 1291, 275, 9638, 199, 3, 961, 570, 365, 4046, 701, 4902, 27, 886, 440, 5283, 14, 199, 199, 624, 199, 199, 3, 9672, 4902, 1347, 2943, 370, 14694, 859, 3992, 14, 199, 10001, 63, 13748, 275, 469, 272, 283, 1986, 63, 4342, 356, 283, 10449, 63, 32723, 297, 272, 283, 5555, 63, 4342, 356, 283, 13772, 63, 32723, 297, 272, 283, 5904, 356, 283, 18074, 17041, 297, 199, 93, 421, 199, 318, 6596, 14533, 6382, 8, 832, 304, 523, 372, 1852, 14, 6790, 1193, 2617, 63, 18451, 14, 362, 8, 832, 9, 508, 283, 9634, 7, 421, 199, 318, 5800, 2021, 8, 515, 304, 523, 408, 7306, 282, 931, 370, 2399, 1350, 2082, 1824, 14, 710, 14694, 4865, 1630, 440, 1362, 2291, 1511, 14, 4679, 63, 1199, 12, 880, 642, 805, 365, 282, 29689, 1041, 523, 372, 931, 421, 199, 3, 9672, 687, 12313, 1347, 370, 931, 370, 1072, 14, 199, 3, 2104, 14694, 12, 314, 1347, 402, 3520, 9033, 365, 282, 2008, 661, 1986, 297, 283, 22582, 659, 199, 3, 661, 7764, 297, 283, 22582, 659, 503, 661, 515, 297, 283, 3972, 15, 515, 358, 3140, 402, 282, 1059, 12, 199, 3, 3967, 781, 2142, 701, 859, 14, 199, 1375, 63, 4467, 275, 1052, 199, 3, 9672, 687, 12313, 1347, 370, 1263, 30258, 1072, 14, 221, 437, 10026, 199, 3, 402, 1347, 63, 4467, 14, 221, 662, 14, 71, 14, 1380, 3002, 3008, 8350, 641, 1973, 65, 12, 781, 2934, 370, 199, 3, 2387, 1973, 65, 315, 314, 17261, 1004, 27, 1380, 1163, 3008, 8350, 641, 199, 3, 3002, 3008, 12, 781, 2951, 2934, 370, 1900, 3002, 3008, 1642, 14, 199, 1375, 63, 1073, 63, 5846, 275, 1052, 421, 199, 533, 14694, 31506, 6261, 8, 785, 304, 523, 408, 20762, 31506, 6261, 6117, 1536, 314, 3575, 402, 1373, 1347, 13, 6100, 14694, 14, 3880, 14, 819, 22940, 1454, 3363, 2397, 2376, 365, 6990, 1062, 436, 365, 19762, 1202, 367, 1561, 29277, 14, 523, 408, 819, 347, 636, 826, 721, 277, 12, 15516, 63, 2119, 63, 694, 304, 272, 291, 14, 6238, 63, 2119, 63, 694, 275, 15516, 63, 2119, 63, 694, 819, 347, 6990, 8, 277, 12, 12313, 63, 1375, 12, 3847, 63, 1375, 12, 1300, 63, 515, 12, 1072, 63, 1501, 12, 288, 3158, 12, 11585, 12, 1777, 63, 1618, 63, 452, 12, 2218, 63, 3620, 63, 1375, 12, 13628, 63, 1023, 304, 272, 408, 1918, 2446, 2397, 2376, 26, 14511, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
songmonit/CTTMSONLINE
addons/decimal_precision/tests/test_qweb_float.py
103
2000
# -*- coding: utf-8 -*- from openerp.tests import common class TestFloatExport(common.TransactionCase): def setUp(self): super(TestFloatExport, self).setUp() self.Model = self.registry('decimal.precision.test') def get_converter(self, name): converter = self.registry('ir.qweb.field.float') column = self.Model._all_columns[name].column return lambda value, options=None: converter.value_to_html( self.cr, self.uid, value, column, options=options, context=None) def test_basic_float(self): converter = self.get_converter('float') self.assertEqual( converter(42.0), "42.0") self.assertEqual( converter(42.12345), "42.12345") converter = self.get_converter('float_2') self.assertEqual( converter(42.0), "42.00") self.assertEqual( converter(42.12345), "42.12") converter = self.get_converter('float_4') self.assertEqual( converter(42.0), '42.0000') self.assertEqual( converter(42.12345), '42.1234') def test_precision_domain(self): DP = self.registry('decimal.precision') DP.create(self.cr, self.uid, { 'name': 'A', 'digits': 2, }) DP.create(self.cr, self.uid, { 'name': 'B', 'digits': 6, }) converter = self.get_converter('float') self.assertEqual( converter(42.0, {'decimal_precision': 'A'}), '42.00') self.assertEqual( converter(42.0, {'decimal_precision': 'B'}), '42.000000') converter = self.get_converter('float_4') self.assertEqual( converter(42.12345, {'decimal_precision': 'A'}), '42.12') self.assertEqual( converter(42.12345, {'decimal_precision': 'B'}), '42.123450')
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 5166, 14, 2219, 492, 2863, 199, 199, 533, 1379, 5136, 11399, 8, 2330, 14, 10161, 1538, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 5136, 11399, 12, 291, 680, 5996, 342, 267, 291, 14, 1685, 275, 291, 14, 5189, 360, 6355, 14, 6833, 14, 396, 358, 339, 347, 664, 63, 11256, 8, 277, 12, 536, 304, 267, 11109, 275, 291, 14, 5189, 360, 723, 14, 22600, 14, 698, 14, 1609, 358, 267, 2763, 275, 291, 14, 1685, 423, 452, 63, 3406, 59, 354, 1055, 2301, 398, 372, 2400, 574, 12, 1511, 29, 403, 26, 11109, 14, 585, 63, 475, 63, 1360, 8, 288, 291, 14, 1556, 12, 291, 14, 1535, 12, 574, 12, 2763, 12, 1511, 29, 1419, 12, 1067, 29, 403, 9, 339, 347, 511, 63, 4316, 63, 1609, 8, 277, 304, 267, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 395, 288, 298, 2260, 14, 16, 531, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 395, 288, 298, 2260, 14, 13261, 531, 398, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 63, 18, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 395, 288, 298, 2260, 14, 383, 531, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 395, 288, 298, 2260, 14, 713, 531, 398, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 63, 20, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 395, 288, 283, 2260, 14, 993, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 395, 288, 283, 2260, 14, 4321, 358, 339, 347, 511, 63, 6833, 63, 2261, 8, 277, 304, 267, 577, 48, 275, 291, 14, 5189, 360, 6355, 14, 6833, 358, 267, 577, 48, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 283, 33, 297, 288, 283, 7022, 356, 499, 12, 267, 3828, 267, 577, 48, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 283, 34, 297, 288, 283, 7022, 356, 1227, 12, 267, 3828, 398, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 12, 791, 6355, 63, 6833, 356, 283, 33, 1604, 288, 283, 2260, 14, 383, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 12, 791, 6355, 63, 6833, 356, 283, 34, 1604, 288, 283, 2260, 14, 3273, 358, 398, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 63, 20, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 12, 791, 6355, 63, 6833, 356, 283, 33, 1604, 288, 283, 2260, 14, 713, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 12, 791, 6355, 63, 6833, 356, 283, 34, 1604, 288, 283, 2260, 14, 4321, 1400, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 504, 5166, 14, 2219, 492, 2863, 199, 199, 533, 1379, 5136, 11399, 8, 2330, 14, 10161, 1538, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 5136, 11399, 12, 291, 680, 5996, 342, 267, 291, 14, 1685, 275, 291, 14, 5189, 360, 6355, 14, 6833, 14, 396, 358, 339, 347, 664, 63, 11256, 8, 277, 12, 536, 304, 267, 11109, 275, 291, 14, 5189, 360, 723, 14, 22600, 14, 698, 14, 1609, 358, 267, 2763, 275, 291, 14, 1685, 423, 452, 63, 3406, 59, 354, 1055, 2301, 398, 372, 2400, 574, 12, 1511, 29, 403, 26, 11109, 14, 585, 63, 475, 63, 1360, 8, 288, 291, 14, 1556, 12, 291, 14, 1535, 12, 574, 12, 2763, 12, 1511, 29, 1419, 12, 1067, 29, 403, 9, 339, 347, 511, 63, 4316, 63, 1609, 8, 277, 304, 267, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 395, 288, 298, 2260, 14, 16, 531, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 395, 288, 298, 2260, 14, 13261, 531, 398, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 63, 18, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 395, 288, 298, 2260, 14, 383, 531, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 395, 288, 298, 2260, 14, 713, 531, 398, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 63, 20, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 395, 288, 283, 2260, 14, 993, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 395, 288, 283, 2260, 14, 4321, 358, 339, 347, 511, 63, 6833, 63, 2261, 8, 277, 304, 267, 577, 48, 275, 291, 14, 5189, 360, 6355, 14, 6833, 358, 267, 577, 48, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 283, 33, 297, 288, 283, 7022, 356, 499, 12, 267, 3828, 267, 577, 48, 14, 981, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 469, 288, 283, 354, 356, 283, 34, 297, 288, 283, 7022, 356, 1227, 12, 267, 3828, 398, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 12, 791, 6355, 63, 6833, 356, 283, 33, 1604, 288, 283, 2260, 14, 383, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 16, 12, 791, 6355, 63, 6833, 356, 283, 34, 1604, 288, 283, 2260, 14, 3273, 358, 398, 11109, 275, 291, 14, 362, 63, 11256, 360, 1609, 63, 20, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 12, 791, 6355, 63, 6833, 356, 283, 33, 1604, 288, 283, 2260, 14, 713, 358, 267, 291, 14, 629, 8, 288, 11109, 8, 2260, 14, 13261, 12, 791, 6355, 63, 6833, 356, 283, 34, 1604, 288, 283, 2260, 14, 4321, 1400, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0 ]
camptocamp/ngo-addons-backport
addons/membership/wizard/__init__.py
432
1071
# -*- 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 membership_invoice # 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, 14616, 63, 5404, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 14616, 63, 5404, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
fitermay/intellij-community
python/helpers/profiler/thriftpy/protocol/multiplex.py
33
1145
# -*- coding: utf-8 -*- from thriftpy.thrift import TMultiplexedProcessor, TMessageType class TMultiplexedProtocol(object): """Multiplex the protocol by prepend service name to api for every api call. Can be used together with all original protocols. """ def __init__(self, proto, service_name): self.service_name = service_name self._proto = proto def __getattr__(self, name): return getattr(self._proto, name) def write_message_begin(self, name, ttype, seqid): if ttype in (TMessageType.CALL, TMessageType.ONEWAY): self._proto.write_message_begin( self.service_name + TMultiplexedProcessor.SEPARATOR + name, ttype, seqid) else: self._proto.write_message_begin(name, ttype, seqid) class TMultiplexedProtocolFactory(object): def __init__(self, proto_factory, service_name): self._proto_factory = proto_factory self.service_name = service_name def get_protocol(self, trans): proto = self._proto_factory.get_protocol(trans) return TMultiplexedProtocol(proto, self.service_name)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 17199, 647, 14, 8430, 492, 377, 8433, 7887, 10438, 12, 20998, 421, 199, 533, 377, 8433, 7887, 3658, 8, 785, 304, 272, 408, 8433, 88, 314, 4113, 701, 18213, 2435, 536, 370, 2986, 367, 4036, 2986, 1240, 14, 272, 6855, 506, 1202, 10451, 543, 1006, 3379, 19230, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4104, 12, 2435, 63, 354, 304, 267, 291, 14, 1364, 63, 354, 275, 2435, 63, 354, 267, 291, 423, 2625, 275, 4104, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 2519, 8, 277, 423, 2625, 12, 536, 9, 339, 347, 2218, 63, 1188, 63, 5037, 8, 277, 12, 536, 12, 17860, 12, 25995, 304, 267, 340, 17860, 315, 334, 52, 12091, 14, 11978, 12, 20998, 14, 4817, 17488, 304, 288, 291, 423, 2625, 14, 952, 63, 1188, 63, 5037, 8, 355, 291, 14, 1364, 63, 354, 435, 377, 8433, 7887, 10438, 14, 15828, 435, 536, 12, 355, 17860, 12, 25995, 9, 267, 587, 26, 288, 291, 423, 2625, 14, 952, 63, 1188, 63, 5037, 8, 354, 12, 17860, 12, 25995, 9, 421, 199, 533, 377, 8433, 7887, 3658, 2927, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4104, 63, 3702, 12, 2435, 63, 354, 304, 267, 291, 423, 2625, 63, 3702, 275, 4104, 63, 3702, 267, 291, 14, 1364, 63, 354, 275, 2435, 63, 354, 339, 347, 664, 63, 3922, 8, 277, 12, 1752, 304, 267, 4104, 275, 291, 423, 2625, 63, 3702, 14, 362, 63, 3922, 8, 1515, 9, 267, 372, 377, 8433, 7887, 3658, 8, 2625, 12, 291, 14, 1364, 63, 354, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 199, 504, 17199, 647, 14, 8430, 492, 377, 8433, 7887, 10438, 12, 20998, 421, 199, 533, 377, 8433, 7887, 3658, 8, 785, 304, 272, 408, 8433, 88, 314, 4113, 701, 18213, 2435, 536, 370, 2986, 367, 4036, 2986, 1240, 14, 272, 6855, 506, 1202, 10451, 543, 1006, 3379, 19230, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 4104, 12, 2435, 63, 354, 304, 267, 291, 14, 1364, 63, 354, 275, 2435, 63, 354, 267, 291, 423, 2625, 275, 4104, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 2519, 8, 277, 423, 2625, 12, 536, 9, 339, 347, 2218, 63, 1188, 63, 5037, 8, 277, 12, 536, 12, 17860, 12, 25995, 304, 267, 340, 17860, 315, 334, 52, 12091, 14, 11978, 12, 20998, 14, 4817, 17488, 304, 288, 291, 423, 2625, 14, 952, 63, 1188, 63, 5037, 8, 355, 291, 14, 1364, 63, 354, 435, 377, 8433, 7887, 10438, 14, 15828, 435, 536, 12, 355, 17860, 12, 25995, 9, 267, 587, 26, 288, 291, 423, 2625, 14, 952, 63, 1188, 63, 5037, 8, 354, 12, 17860, 12, 25995, 9, 421, 199, 533, 377, 8433, 7887, 3658, 2927, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4104, 63, 3702, 12, 2435, 63, 354, 304, 267, 291, 423, 2625, 63, 3702, 275, 4104, 63, 3702, 267, 291, 14, 1364, 63, 354, 275, 2435, 63, 354, 339, 347, 664, 63, 3922, 8, 277, 12, 1752, 304, 267, 4104, 275, 291, 423, 2625, 63, 3702, 14, 362, 63, 3922, 8, 1515, 9, 267, 372, 377, 8433, 7887, 3658, 8, 2625, 12, 291, 14, 1364, 63, 354, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
pedropena/iteexe
exe/engine/lom/test/lomclassification.py
11
6720
#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest from exe.engine.lom.lomclassification import Classification class TestLOM(unittest.TestCase): def setUp(self): pass def test_lomClassificationAccesibilidad(self): results = [{u'10': u'TIPO DE CONTADOR DE EJECUCI\xd3N', u'1': u'DECLARACI\xd3N DEL MODO DE ACCESO AL SIGUIENTE NIVEL', u'3': u'TRABAJA A PANTALLA COMPLETA', u'2': u'DECLARACI\xd3N DEL MODO DE INTERACCI\xd3N EN LA ACTIVIDAD DE APRENDIZAJE', u'5': u'PERMITE CAMBIO DE RESOLUCI\xd3N CON AJUSTE DE CONTENIDO', u'4': u'RESOLUCI\xd3N DE PANTALLA NATIVA', u'7': u'VISUALIZACI\xd3N ADAPTABLE', u'6': u'PERMITE ADAPTAR LA VISUALIZACI\xd3N', u'9': u'TIENE CONTROL DEL TIEMPO DE EJECUCI\xd3N', u'8': u'DECLARACI\xd3N DE ADAPTABILIDAD'}, {u'1.1': u'Modo de presentaci\xf3n de la informaci\xf3n en el acceso', u'1.2': u'Modo de interacci\xf3n para el acceso '}, {u'1.1.1': u'Auditivo', u'1.1.3': u'Textual', u'1.1.2': u'T\xe1ctil', u'1.1.4': u'Visual'}, {u'1.1.1.1': u'Informativo', u'1.1.1.2': u'Decorativo', u'1.1.1.3': u'Motivacional'}, {u'10': u'TIPO DE CONTADOR DE EJECUCI\xd3N', u'1': u'DECLARACI\xd3N DEL MODO DE ACCESO AL SIGUIENTE NIVEL', u'3': u'TRABAJA A PANTALLA COMPLETA', u'2': u'DECLARACI\xd3N DEL MODO DE INTERACCI\xd3N EN LA ACTIVIDAD DE APRENDIZAJE', u'5': u'PERMITE CAMBIO DE RESOLUCI\xd3N CON AJUSTE DE CONTENIDO', u'4': u'RESOLUCI\xd3N DE PANTALLA NATIVA', u'7': u'VISUALIZACI\xd3N ADAPTABLE', u'6': u'PERMITE ADAPTAR LA VISUALIZACI\xd3N', u'9': u'TIENE CONTROL DEL TIEMPO DE EJECUCI\xd3N', u'8': u'DECLARACI\xd3N DE ADAPTABILIDAD'}, {u'10': u'TIPO DE CONTADOR DE EJECUCI\xd3N', u'1': u'DECLARACI\xd3N DEL MODO DE ACCESO AL SIGUIENTE NIVEL', u'3': u'TRABAJA A PANTALLA COMPLETA', u'2': u'DECLARACI\xd3N DEL MODO DE INTERACCI\xd3N EN LA ACTIVIDAD DE APRENDIZAJE', u'5': u'PERMITE CAMBIO DE RESOLUCI\xd3N CON AJUSTE DE CONTENIDO', u'4': u'RESOLUCI\xd3N DE PANTALLA NATIVA', u'7': u'VISUALIZACI\xd3N ADAPTABLE', u'6': u'PERMITE ADAPTAR LA VISUALIZACI\xd3N', u'9': u'TIENE CONTROL DEL TIEMPO DE EJECUCI\xd3N', u'8': u'DECLARACI\xd3N DE ADAPTABILIDAD'}, {}, {}, {}] cl = Classification('exe/engine/lom/test/sources/PODPL_02_accesibilidad_LOM-ES_es.xml') rootLevel = cl.getElementsByIdentifier() self.assertEqual(rootLevel, results[0]) print rootLevel i = 1 for v in ['1', '1.1', '1.1.1', False, 0, 1, '1.6', '1.x.y.z']: data = cl.getElementsByIdentifier(v) self.assertEqual(data, results[i]) i += 1 print data def test_lomClassificationCompetencia(self): results = [{u'1': u'Competencias Generales y Personales', u'3': u'Competencias Sociales y de Trabajo en Equipo', u'2': u'Competencias Acad\xe9micas'}, {u'1.4': u'Autoestima', u'1.5': u'Autorreflexi\xf3n y autoevaluaci\xf3n', u'1.6': u'B\xfasqueda de empleo', u'1.7': u'B\xfasqueda de informaci\xf3n relevante', u'1.1': u'Actitud positiva al cambio', u'1.2': u'Afectividad', u'1.3': u'Autoaprendizaje a lo largo de la vida', u'1.8': u'Comunicaci\xf3n en lengua materna (escuchar, hablar, leer y escribir).', u'1.9': u'Conocimiento de los principios b\xe1sicos de la naturaleza', u'1.16': u'Iniciativa personal', u'1.17': u'Inter\xe9s por la expresi\xf3n cultural (literatura, m\xfasica, artes esc\xe9nicas y pl\xe1sticas)', u'1.14': u'Formulaci\xf3n de preguntas pertinentes', u'1.15': u'Honestidad y \xe9tica personal', u'1.12': u'Esp\xedritu de empresa', u'1.13': u'Expresi\xf3n y compresi\xf3n b\xe1sica de lengua extranjera', u'1.10': u'Conocimiento y aprecio por la cultura y lengua de las Comunidades Aut\xf3nomas', u'1.11': u'Conocimiento y pr\xe1ctica deportiva', u'1.18': u'Invenci\xf3n y creaci\xf3n', u'1.19': u'Motivaci\xf3n intr\xednseca', u'1.30': u'Uso b\xe1sico de las TIC', u'1.29': u'Uso eficiente de la informaci\xf3n', u'1.28': u'Soluci\xf3n de problemas', u'1.23': u'Realizaci\xf3n de juicios informados', u'1.22': u'Planificaci\xf3n y gesti\xf3n de recursos propios (tiempo, dinero,...)', u'1.21': u'Perseverancia', u'1.20': u'Pensamiento cr\xedtico', u'1.27': u'Responsabilidad', u'1.26': u'Resistencia al fracaso', u'1.25': u'Resistencia a la ambig\xfcedad', u'1.24': u'Reconocimiento y respeto a las diferencias individuales'}, {}, {}, {u'1': u'Competencias Generales y Personales', u'3': u'Competencias Sociales y de Trabajo en Equipo', u'2': u'Competencias Acad\xe9micas'}, {u'1': u'Competencias Generales y Personales', u'3': u'Competencias Sociales y de Trabajo en Equipo', u'2': u'Competencias Acad\xe9micas'}, {}, {}, {}] cl = Classification('exe/engine/lom/test/sources/PODPL_01_competencia_LOM-ES_es.xml') rootLevel = cl.getElementsByIdentifier() self.assertEqual(rootLevel, results[0]) print rootLevel i = 1 for v in ['1', '1.1', '1.1.1', False, 0, 1, '1.6', '1.x.y.z']: data = cl.getElementsByIdentifier(v) self.assertEqual(data, results[i]) i += 1 print data # Para que funciones los siguientes test de deben incluir los ficheros de fuentes en el directorio #'exe/engine/lom/test/sources/ y descomentarlos # def test_lomClassificationNivelEducativo(self): # cl = Classification('exe/engine/lom/test/sources/PODPL_01_nivel_educativo_LOM-ES_es.xml') # rootLevel = cl.getElementsByIdentifier() # print rootLevel # for v in ['1', '1.1', '1.1.1', False, 0, 1, '1.6', '1.x.y.z']: # data = cl.getElementsByIdentifier(v) # print data # # def test_lomClassificationArbolCurricular(self): # cl = Classification('exe/engine/lom/test/sources/PODPL_02_Arbol_curricular_LOE_2006_es.xml') # rootLevel = cl.getElementsByIdentifier() # print rootLevel # for v in ['1', '1.1', '1.1.1', False, 0, 1, '1.6', '1.x.y.z']: # data = cl.getElementsByIdentifier(v) # print data # # def test_lomClassificationDisciplinaETBLRE(self): # cl = Classification('exe/engine/lom/test/sources/ETB-LRE MEC-CCAA V.1.0_es.xml') # rootLevel = cl.getElementsByIdentifier(stype=2) # print rootLevel # m50 = cl.getElementsByIdentifier('M50', stype=2) # print m50 # m70 = cl.getElementsByIdentifier('M70', stype=2) # print m70 # s1277 = cl.getElementsByIdentifier('1277', stype=2) # print s1277 if __name__ == '__main__': unittest.main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2882, 199, 504, 14778, 14, 3908, 14, 320, 77, 14, 320, 77, 14368, 492, 8465, 7789, 421, 199, 533, 1379, 1484, 45, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 511, 63, 320, 77, 28362, 1945, 301, 6637, 1638, 25805, 8, 277, 304, 267, 2058, 275, 8910, 85, 7, 709, 356, 399, 7, 13247, 1512, 3265, 7408, 1554, 726, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 17, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 16362, 654, 47, 12112, 15522, 6379, 1309, 37, 653, 5399, 44, 297, 399, 7, 19, 356, 399, 7, 1766, 1217, 33, 29849, 437, 510, 1441, 1761, 33, 5099, 3950, 15808, 297, 399, 7, 18, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 8729, 1348, 3553, 60, 2207, 19, 46, 5070, 31046, 21401, 41, 5437, 1554, 3265, 437, 3311, 19526, 21959, 25074, 297, 399, 7, 21, 356, 399, 7, 29065, 4427, 445, 1156, 34, 2090, 3265, 12565, 2228, 53, 3553, 60, 2207, 19, 46, 1868, 437, 42, 7698, 37, 3265, 7408, 742, 998, 47, 297, 399, 7, 20, 356, 399, 7, 3830, 2228, 53, 3553, 60, 2207, 19, 46, 3265, 510, 1441, 1761, 33, 31363, 6882, 33, 297, 399, 7, 23, 356, 399, 7, 11793, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 16271, 1282, 8723, 297, 399, 7, 22, 356, 399, 7, 29065, 4427, 16271, 26086, 689, 31046, 812, 1311, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 297, 399, 7, 25, 356, 399, 7, 13247, 742, 37, 8098, 12355, 377, 41, 2769, 1512, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 24, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 3265, 16271, 1282, 10129, 1193, 998, 1554, 2267, 2116, 469, 85, 7, 17, 14, 17, 356, 399, 7, 9871, 79, 477, 3451, 22832, 60, 1949, 19, 78, 477, 1127, 315, 10928, 559, 60, 1949, 19, 78, 655, 579, 1066, 823, 79, 297, 399, 7, 17, 14, 18, 356, 399, 7, 9871, 79, 477, 315, 2967, 67, 559, 60, 1949, 19, 78, 12665, 579, 1066, 823, 79, 283, 1386, 2116, 469, 85, 7, 17, 14, 17, 14, 17, 356, 399, 7, 33, 14525, 280, 2392, 297, 399, 7, 17, 14, 17, 14, 19, 356, 399, 7, 1872, 1061, 297, 399, 7, 17, 14, 17, 14, 18, 356, 399, 7, 52, 60, 1845, 17, 67, 2270, 297, 399, 7, 17, 14, 17, 14, 20, 356, 399, 7, 15039, 2267, 2116, 469, 85, 7, 17, 14, 17, 14, 17, 14, 17, 356, 399, 7, 607, 10928, 280, 2392, 297, 399, 7, 17, 14, 17, 14, 17, 14, 18, 356, 399, 7, 8584, 269, 2159, 2392, 297, 399, 7, 17, 14, 17, 14, 17, 14, 19, 356, 399, 7, 3716, 280, 3042, 559, 8125, 2267, 2116, 469, 85, 7, 709, 356, 399, 7, 13247, 1512, 3265, 7408, 1554, 726, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 17, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 16362, 654, 47, 12112, 15522, 6379, 1309, 37, 653, 5399, 44, 297, 399, 7, 19, 356, 399, 7, 1766, 1217, 33, 29849, 437, 510, 1441, 1761, 33, 5099, 3950, 15808, 297, 399, 7, 18, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 8729, 1348, 3553, 60, 2207, 19, 46, 5070, 31046, 21401, 41, 5437, 1554, 3265, 437, 3311, 19526, 21959, 25074, 297, 399, 7, 21, 356, 399, 7, 29065, 4427, 445, 1156, 34, 2090, 3265, 12565, 2228, 53, 3553, 60, 2207, 19, 46, 1868, 437, 42, 7698, 37, 3265, 7408, 742, 998, 47, 297, 399, 7, 20, 356, 399, 7, 3830, 2228, 53, 3553, 60, 2207, 19, 46, 3265, 510, 1441, 1761, 33, 31363, 6882, 33, 297, 399, 7, 23, 356, 399, 7, 11793, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 16271, 1282, 8723, 297, 399, 7, 22, 356, 399, 7, 29065, 4427, 16271, 26086, 689, 31046, 812, 1311, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 297, 399, 7, 25, 356, 399, 7, 13247, 742, 37, 8098, 12355, 377, 41, 2769, 1512, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 24, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 3265, 16271, 1282, 10129, 1193, 998, 1554, 2267, 2116, 469, 85, 7, 709, 356, 399, 7, 13247, 1512, 3265, 7408, 1554, 726, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 17, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 16362, 654, 47, 12112, 15522, 6379, 1309, 37, 653, 5399, 44, 297, 399, 7, 19, 356, 399, 7, 1766, 1217, 33, 29849, 437, 510, 1441, 1761, 33, 5099, 3950, 15808, 297, 399, 7, 18, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 8729, 1348, 3553, 60, 2207, 19, 46, 5070, 31046, 21401, 41, 5437, 1554, 3265, 437, 3311, 19526, 21959, 25074, 297, 399, 7, 21, 356, 399, 7, 29065, 4427, 445, 1156, 34, 2090, 3265, 12565, 2228, 53, 3553, 60, 2207, 19, 46, 1868, 437, 42, 7698, 37, 3265, 7408, 742, 998, 47, 297, 399, 7, 20, 356, 399, 7, 3830, 2228, 53, 3553, 60, 2207, 19, 46, 3265, 510, 1441, 1761, 33, 31363, 6882, 33, 297, 399, 7, 23, 356, 399, 7, 11793, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 16271, 1282, 8723, 297, 399, 7, 22, 356, 399, 7, 29065, 4427, 16271, 26086, 689, 31046, 812, 1311, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 297, 399, 7, 25, 356, 399, 7, 13247, 742, 37, 8098, 12355, 377, 41, 2769, 1512, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 24, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 3265, 16271, 1282, 10129, 1193, 998, 1554, 2267, 2116, 5479, 2116, 5479, 2116, 1052, 61, 267, 824, 275 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 2882, 199, 504, 14778, 14, 3908, 14, 320, 77, 14, 320, 77, 14368, 492, 8465, 7789, 421, 199, 533, 1379, 1484, 45, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 986, 339, 347, 511, 63, 320, 77, 28362, 1945, 301, 6637, 1638, 25805, 8, 277, 304, 267, 2058, 275, 8910, 85, 7, 709, 356, 399, 7, 13247, 1512, 3265, 7408, 1554, 726, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 17, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 16362, 654, 47, 12112, 15522, 6379, 1309, 37, 653, 5399, 44, 297, 399, 7, 19, 356, 399, 7, 1766, 1217, 33, 29849, 437, 510, 1441, 1761, 33, 5099, 3950, 15808, 297, 399, 7, 18, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 8729, 1348, 3553, 60, 2207, 19, 46, 5070, 31046, 21401, 41, 5437, 1554, 3265, 437, 3311, 19526, 21959, 25074, 297, 399, 7, 21, 356, 399, 7, 29065, 4427, 445, 1156, 34, 2090, 3265, 12565, 2228, 53, 3553, 60, 2207, 19, 46, 1868, 437, 42, 7698, 37, 3265, 7408, 742, 998, 47, 297, 399, 7, 20, 356, 399, 7, 3830, 2228, 53, 3553, 60, 2207, 19, 46, 3265, 510, 1441, 1761, 33, 31363, 6882, 33, 297, 399, 7, 23, 356, 399, 7, 11793, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 16271, 1282, 8723, 297, 399, 7, 22, 356, 399, 7, 29065, 4427, 16271, 26086, 689, 31046, 812, 1311, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 297, 399, 7, 25, 356, 399, 7, 13247, 742, 37, 8098, 12355, 377, 41, 2769, 1512, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 24, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 3265, 16271, 1282, 10129, 1193, 998, 1554, 2267, 2116, 469, 85, 7, 17, 14, 17, 356, 399, 7, 9871, 79, 477, 3451, 22832, 60, 1949, 19, 78, 477, 1127, 315, 10928, 559, 60, 1949, 19, 78, 655, 579, 1066, 823, 79, 297, 399, 7, 17, 14, 18, 356, 399, 7, 9871, 79, 477, 315, 2967, 67, 559, 60, 1949, 19, 78, 12665, 579, 1066, 823, 79, 283, 1386, 2116, 469, 85, 7, 17, 14, 17, 14, 17, 356, 399, 7, 33, 14525, 280, 2392, 297, 399, 7, 17, 14, 17, 14, 19, 356, 399, 7, 1872, 1061, 297, 399, 7, 17, 14, 17, 14, 18, 356, 399, 7, 52, 60, 1845, 17, 67, 2270, 297, 399, 7, 17, 14, 17, 14, 20, 356, 399, 7, 15039, 2267, 2116, 469, 85, 7, 17, 14, 17, 14, 17, 14, 17, 356, 399, 7, 607, 10928, 280, 2392, 297, 399, 7, 17, 14, 17, 14, 17, 14, 18, 356, 399, 7, 8584, 269, 2159, 2392, 297, 399, 7, 17, 14, 17, 14, 17, 14, 19, 356, 399, 7, 3716, 280, 3042, 559, 8125, 2267, 2116, 469, 85, 7, 709, 356, 399, 7, 13247, 1512, 3265, 7408, 1554, 726, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 17, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 16362, 654, 47, 12112, 15522, 6379, 1309, 37, 653, 5399, 44, 297, 399, 7, 19, 356, 399, 7, 1766, 1217, 33, 29849, 437, 510, 1441, 1761, 33, 5099, 3950, 15808, 297, 399, 7, 18, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 8729, 1348, 3553, 60, 2207, 19, 46, 5070, 31046, 21401, 41, 5437, 1554, 3265, 437, 3311, 19526, 21959, 25074, 297, 399, 7, 21, 356, 399, 7, 29065, 4427, 445, 1156, 34, 2090, 3265, 12565, 2228, 53, 3553, 60, 2207, 19, 46, 1868, 437, 42, 7698, 37, 3265, 7408, 742, 998, 47, 297, 399, 7, 20, 356, 399, 7, 3830, 2228, 53, 3553, 60, 2207, 19, 46, 3265, 510, 1441, 1761, 33, 31363, 6882, 33, 297, 399, 7, 23, 356, 399, 7, 11793, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 16271, 1282, 8723, 297, 399, 7, 22, 356, 399, 7, 29065, 4427, 16271, 26086, 689, 31046, 812, 1311, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 297, 399, 7, 25, 356, 399, 7, 13247, 742, 37, 8098, 12355, 377, 41, 2769, 1512, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 24, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 3265, 16271, 1282, 10129, 1193, 998, 1554, 2267, 2116, 469, 85, 7, 709, 356, 399, 7, 13247, 1512, 3265, 7408, 1554, 726, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 17, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 16362, 654, 47, 12112, 15522, 6379, 1309, 37, 653, 5399, 44, 297, 399, 7, 19, 356, 399, 7, 1766, 1217, 33, 29849, 437, 510, 1441, 1761, 33, 5099, 3950, 15808, 297, 399, 7, 18, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 12355, 10362, 1649, 3265, 8729, 1348, 3553, 60, 2207, 19, 46, 5070, 31046, 21401, 41, 5437, 1554, 3265, 437, 3311, 19526, 21959, 25074, 297, 399, 7, 21, 356, 399, 7, 29065, 4427, 445, 1156, 34, 2090, 3265, 12565, 2228, 53, 3553, 60, 2207, 19, 46, 1868, 437, 42, 7698, 37, 3265, 7408, 742, 998, 47, 297, 399, 7, 20, 356, 399, 7, 3830, 2228, 53, 3553, 60, 2207, 19, 46, 3265, 510, 1441, 1761, 33, 31363, 6882, 33, 297, 399, 7, 23, 356, 399, 7, 11793, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 16271, 1282, 8723, 297, 399, 7, 22, 356, 399, 7, 29065, 4427, 16271, 26086, 689, 31046, 812, 1311, 13841, 5357, 1348, 41, 60, 2207, 19, 46, 297, 399, 7, 25, 356, 399, 7, 13247, 742, 37, 8098, 12355, 377, 41, 2769, 1512, 3265, 662, 42, 4220, 53, 3553, 60, 2207, 19, 46, 297, 399, 7, 24, 356, 399, 7, 27402, 689, 1348, 41, 60, 2207, 19, 46, 3265, 16271, 1282, 10129, 1193, 998, 1554, 2267, 2116, 5479, 2116, 5479, 2116, 1052, 61, 267, 824, 275, 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, 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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 ]
elsonrodriguez/madhatter
cobbler/modules/manage_isc.py
4
6674
""" This is some of the code behind 'cobbler sync'. Copyright 2006-2009, Red Hat, Inc Michael DeHaan <mdehaan@redhat.com> John Eckersberg <jeckersb@redhat.com> 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. 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """ import os import os.path import shutil import time import sys import glob import traceback import errno from utils import popen2 from shlex import shlex import utils from cexceptions import * import templar import item_distro import item_profile import item_repo import item_system from utils import _ def register(): """ The mandatory cobbler module registration hook. """ return "manage" class IscManager: def what(self): return "isc" def __init__(self,config,logger): """ Constructor """ self.logger = logger self.config = config self.api = config.api self.distros = config.distros() self.profiles = config.profiles() self.systems = config.systems() self.settings = config.settings() self.repos = config.repos() self.templar = templar.Templar(config) self.settings_file = utils.dhcpconf_location(self.api) def write_dhcp_file(self): """ DHCP files are written when manage_dhcp is set in /var/lib/cobbler/settings. """ template_file = "/etc/cobbler/dhcp.template" blender_cache = {} try: f2 = open(template_file,"r") except: raise CX(_("error writing template to file: %s") % template_file) template_data = "" template_data = f2.read() f2.close() # use a simple counter for generating generic names where a hostname # is not available counter = 0 # we used to just loop through each system, but now we must loop # through each network interface of each system. dhcp_tags = { "default": {} } elilo = "/elilo-3.6-ia64.efi" yaboot = "/yaboot-1.3.14" for system in self.systems: if not system.is_management_supported(cidr_ok=False): continue profile = system.get_conceptual_parent() distro = profile.get_conceptual_parent() # if distro is None then the profile is really an image # record! for (name, interface) in system.interfaces.iteritems(): # this is really not a per-interface setting # but we do this to make the templates work # without upgrade interface["gateway"] = system.gateway mac = interface["mac_address"] if interface["bonding"] == "slave": if interface["bonding_master"] not in system.interfaces: # Can't write DHCP entry; master interface does not # exist continue ip = system.interfaces[interface["bonding_master"]]["ip_address"] interface["ip_address"] = ip host = system.interfaces[interface["bonding_master"]]["dns_name"] else: ip = interface["ip_address"] host = interface["dns_name"] if distro is not None: interface["distro"] = distro.to_datastruct() if mac is None or mac == "": # can't write a DHCP entry for this system continue counter = counter + 1 # the label the entry after the hostname if possible if host is not None and host != "": if name != "eth0": interface["name"] = "%s_%s" % (host,name) else: interface["name"] = "%s" % (host) else: interface["name"] = "generic%d" % counter # add references to the system, profile, and distro # for use in the template if blender_cache.has_key(system.name): blended_system = blender_cache[system.name] else: blended_system = utils.blender( self.api, False, system ) blender_cache[system.name] = blended_system interface["next_server"] = blended_system["server"] interface["netboot_enabled"] = blended_system["netboot_enabled"] interface["hostname"] = blended_system["hostname"] interface["filename"] = "/pxelinux.0" # can't use pxelinux.0 anymore if distro is not None: if distro.arch == "ia64": interface["filename"] = elilo elif distro.arch.startswith("ppc"): interface["filename"] = yaboot dhcp_tag = interface["dhcp_tag"] if dhcp_tag == "": dhcp_tag = "default" if not dhcp_tags.has_key(dhcp_tag): dhcp_tags[dhcp_tag] = { mac: interface } else: dhcp_tags[dhcp_tag][mac] = interface # we are now done with the looping through each interface of each system metadata = { "date" : time.asctime(time.gmtime()), "cobbler_server" : self.settings.server, "next_server" : self.settings.next_server, "elilo" : elilo, "yaboot" : yaboot, "dhcp_tags" : dhcp_tags } if self.logger is not None: self.logger.info("generating %s" % self.settings_file) self.templar.render(template_data, metadata, self.settings_file, None) def regen_ethers(self): pass # ISC/BIND do not use this def get_manager(config,logger): return IscManager(config,logger)
gpl-2.0
[ 624, 199, 2765, 365, 2005, 402, 314, 1233, 22172, 283, 331, 26722, 7604, 1370, 199, 199, 7384, 8315, 13, 8664, 12, 9572, 13002, 12, 3277, 199, 45, 11781, 22453, 665, 77, 24247, 32, 17164, 14, 957, 30, 199, 12923, 662, 346, 1192, 14630, 665, 6532, 346, 1192, 66, 32, 17164, 14, 957, 30, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 996, 6019, 13, 10067, 221, 8217, 199, 624, 199, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 5145, 199, 646, 900, 199, 646, 984, 199, 646, 5739, 199, 646, 5190, 199, 646, 7554, 199, 504, 3778, 492, 17758, 18, 199, 504, 16701, 492, 16701, 421, 199, 646, 3778, 199, 504, 286, 3924, 492, 627, 199, 646, 28038, 199, 199, 646, 1242, 63, 18371, 199, 646, 1242, 63, 2913, 199, 646, 1242, 63, 3417, 199, 646, 1242, 63, 2253, 199, 199, 504, 3778, 492, 485, 421, 199, 318, 2274, 837, 2043, 408, 2043, 710, 15230, 512, 26722, 859, 10991, 5759, 14, 2043, 408, 2043, 372, 298, 9053, 2, 421, 199, 533, 473, 551, 2988, 26, 339, 347, 4052, 8, 277, 304, 267, 372, 298, 10840, 2, 339, 347, 636, 826, 721, 277, 12, 888, 12, 2921, 304, 267, 408, 267, 20297, 267, 408, 267, 291, 14, 2921, 263, 275, 2512, 267, 291, 14, 888, 263, 275, 1101, 267, 291, 14, 1246, 3698, 275, 1101, 14, 1246, 267, 291, 14, 2686, 4796, 755, 275, 1101, 14, 2686, 4796, 342, 267, 291, 14, 11225, 420, 275, 1101, 14, 11225, 342, 267, 291, 14, 19135, 755, 275, 1101, 14, 19135, 342, 267, 291, 14, 1751, 420, 275, 1101, 14, 1751, 342, 267, 291, 14, 11857, 260, 275, 1101, 14, 11857, 342, 267, 291, 14, 26718, 755, 275, 28038, 14, 6530, 9828, 8, 888, 9, 267, 291, 14, 1751, 63, 493, 275, 3778, 14, 10801, 2190, 63, 1985, 8, 277, 14, 1246, 9, 339, 347, 2218, 63, 10801, 63, 493, 8, 277, 304, 267, 408, 267, 26821, 1584, 787, 5313, 1380, 9635, 63, 10801, 365, 663, 315, 267, 1182, 1391, 15, 773, 15, 331, 26722, 15, 1751, 14, 267, 408, 398, 1978, 63, 493, 275, 3286, 6839, 15, 331, 26722, 15, 10801, 14, 1160, 2, 267, 330, 24912, 63, 1637, 275, 1052, 398, 862, 26, 288, 289, 18, 275, 1551, 8, 1160, 63, 493, 4589, 82, 531, 267, 871, 26, 288, 746, 445, 56, 6115, 705, 3575, 1978, 370, 570, 26, 450, 83, 531, 450, 1978, 63, 493, 9, 267, 1978, 63, 576, 275, 3087, 267, 1978, 63, 576, 275, 289, 18, 14, 739, 342, 267, 289, 18, 14, 1600, 342, 398, 327, 675, 282, 3486, 7055, 367, 12999, 7809, 1561, 2382, 282, 6246, 267, 327, 365, 440, 2808, 267, 7055, 275, 378, 398, 327, 781, 1202, 370, 2951, 4438, 4012, 1924, 2656, 12, 1325, 3063, 781, 1471, 4438, 267, 327, 4012, 1924, 2784, 3217, 402, 1924, 2656, 14, 267, 19064, 63, 2969, 275, 469, 298, 885, 582, 1052, 789, 267, 28214, 320, 275, 3286, 18865, 320, 13, 19, 14, 22, 13, 4674, 772, 14, 69, 329, 2, 267, 612, 13113, 357, 275, 3286, 89, 13113, 357, 13, 17, 14, 19, 14, 1079, 2, 398, 367, 2656, 315, 291, 14, 19135, 26, 288, 340, 440, 2656, 14, 374, 63, 8110, 63, 4946, 8, 10509, 63, 745, 29, 797, 304, 355, 1980, 953, 4690, 275, 2656, 14, 362, 63, 21318, 1061, 63, 1708, 342, 288, 20499, 221, 275, 4690, 14, 362, 63, 21318, 1061, 63, 1708, 342, 953, 327, 340, 20499, 365, 488, 2066, 314, 4690, 365, 7710, 376, 1834, 288, 327, 2777, 1, 953, 367, 334, 354, 12, 3217, 9, 315, 2656, 14, 7436, 14, 4611, 837, 2234, 327, 642, 365, 7710, 440, 282, 1126, 13, 3266, 4260, 355, 327, 1325, 781, 886, 642, 370, 1852, 314, 7009, 1736, 355, 327, 1928, 10754, 355, 3217, 905, 7019, 937, 275, 2656, 14, 7019, 2234, 4497, 221, 275, 3217, 905, 3088, 63, 1562, 937, 355, 340, 3217, 905, 13520, 1098, 937, 508, 298, 12384, 582, 490, 340, 3217, 905, 13520, 1098, 63, 4133, 937, 440, 315, 2656, 14, 7436, 26, 717, 327, 6855, 1133, 2218, 26821, 2397, 27, 5288, 3217, 1630, 440, 717, 327, 2187, 717, 1980, 490, 3384, 275, 2656, 14, 7436, 59, 3266, 905, 13520, 1098, 63, 4133, 937, 7541, 711, 63, 1562, 937, 490, 3217, 905, 711, 63, 1562, 937, 275, 3384, 490, 1591, 275, 2656, 14, 7436, 59, 3266, 905, 13520, 1098, 63, 4133, 937, 7541, 5797, 63, 354, 937, 355, 587, 26, 490, 3384, 257, 275, 3217, 905, 711, 63, 1562, 937, 490, 1591, 275, 3217, 905, 5797, 63, 354, 937, 2234, 340, 20499, 365, 440, 488, 26, 490, 3217, 905, 18371, 937, 221, 275, 20499, 14, 475, 63, 576, 1820, 342, 2234, 340, 4497, 365, 488, 503, 4497, 508, 10812, 490, 327, 883, 1133, 2218, 282, 26821, 2397, 367, 642, 2656, 490, 1980, 2234, 7055, 275, 7055, 435, 413, 2234, 327, 314, 1768, 314, 2397, 2410, 314, 6246, 340, 3962, 355, 340, 1591, 365, 440, 488, 436, 1591, 1137, 10812, 490, 340, 536, 1137, 298, 12391, 16, 582, 717, 3217, 905, 354, 937, 275, 2071, 83, 4970, 83, 2, 450, 334, 1102, 12, 354, 9, 490, 587, 26, 717, 3217, 905, 354, 937, 275, 2071, 83, 2, 450, 334, 1102, 9, 355, 587, 26, 490, 3217, 905, 354, 937, 275, 298, 6767, 5, 68 ]
[ 199, 2765, 365, 2005, 402, 314, 1233, 22172, 283, 331, 26722, 7604, 1370, 199, 199, 7384, 8315, 13, 8664, 12, 9572, 13002, 12, 3277, 199, 45, 11781, 22453, 665, 77, 24247, 32, 17164, 14, 957, 30, 199, 12923, 662, 346, 1192, 14630, 665, 6532, 346, 1192, 66, 32, 17164, 14, 957, 30, 199, 199, 2765, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 21632, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 30216, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 199, 996, 6019, 13, 10067, 221, 8217, 199, 624, 199, 199, 646, 747, 199, 646, 747, 14, 515, 199, 646, 5145, 199, 646, 900, 199, 646, 984, 199, 646, 5739, 199, 646, 5190, 199, 646, 7554, 199, 504, 3778, 492, 17758, 18, 199, 504, 16701, 492, 16701, 421, 199, 646, 3778, 199, 504, 286, 3924, 492, 627, 199, 646, 28038, 199, 199, 646, 1242, 63, 18371, 199, 646, 1242, 63, 2913, 199, 646, 1242, 63, 3417, 199, 646, 1242, 63, 2253, 199, 199, 504, 3778, 492, 485, 421, 199, 318, 2274, 837, 2043, 408, 2043, 710, 15230, 512, 26722, 859, 10991, 5759, 14, 2043, 408, 2043, 372, 298, 9053, 2, 421, 199, 533, 473, 551, 2988, 26, 339, 347, 4052, 8, 277, 304, 267, 372, 298, 10840, 2, 339, 347, 636, 826, 721, 277, 12, 888, 12, 2921, 304, 267, 408, 267, 20297, 267, 408, 267, 291, 14, 2921, 263, 275, 2512, 267, 291, 14, 888, 263, 275, 1101, 267, 291, 14, 1246, 3698, 275, 1101, 14, 1246, 267, 291, 14, 2686, 4796, 755, 275, 1101, 14, 2686, 4796, 342, 267, 291, 14, 11225, 420, 275, 1101, 14, 11225, 342, 267, 291, 14, 19135, 755, 275, 1101, 14, 19135, 342, 267, 291, 14, 1751, 420, 275, 1101, 14, 1751, 342, 267, 291, 14, 11857, 260, 275, 1101, 14, 11857, 342, 267, 291, 14, 26718, 755, 275, 28038, 14, 6530, 9828, 8, 888, 9, 267, 291, 14, 1751, 63, 493, 275, 3778, 14, 10801, 2190, 63, 1985, 8, 277, 14, 1246, 9, 339, 347, 2218, 63, 10801, 63, 493, 8, 277, 304, 267, 408, 267, 26821, 1584, 787, 5313, 1380, 9635, 63, 10801, 365, 663, 315, 267, 1182, 1391, 15, 773, 15, 331, 26722, 15, 1751, 14, 267, 408, 398, 1978, 63, 493, 275, 3286, 6839, 15, 331, 26722, 15, 10801, 14, 1160, 2, 267, 330, 24912, 63, 1637, 275, 1052, 398, 862, 26, 288, 289, 18, 275, 1551, 8, 1160, 63, 493, 4589, 82, 531, 267, 871, 26, 288, 746, 445, 56, 6115, 705, 3575, 1978, 370, 570, 26, 450, 83, 531, 450, 1978, 63, 493, 9, 267, 1978, 63, 576, 275, 3087, 267, 1978, 63, 576, 275, 289, 18, 14, 739, 342, 267, 289, 18, 14, 1600, 342, 398, 327, 675, 282, 3486, 7055, 367, 12999, 7809, 1561, 2382, 282, 6246, 267, 327, 365, 440, 2808, 267, 7055, 275, 378, 398, 327, 781, 1202, 370, 2951, 4438, 4012, 1924, 2656, 12, 1325, 3063, 781, 1471, 4438, 267, 327, 4012, 1924, 2784, 3217, 402, 1924, 2656, 14, 267, 19064, 63, 2969, 275, 469, 298, 885, 582, 1052, 789, 267, 28214, 320, 275, 3286, 18865, 320, 13, 19, 14, 22, 13, 4674, 772, 14, 69, 329, 2, 267, 612, 13113, 357, 275, 3286, 89, 13113, 357, 13, 17, 14, 19, 14, 1079, 2, 398, 367, 2656, 315, 291, 14, 19135, 26, 288, 340, 440, 2656, 14, 374, 63, 8110, 63, 4946, 8, 10509, 63, 745, 29, 797, 304, 355, 1980, 953, 4690, 275, 2656, 14, 362, 63, 21318, 1061, 63, 1708, 342, 288, 20499, 221, 275, 4690, 14, 362, 63, 21318, 1061, 63, 1708, 342, 953, 327, 340, 20499, 365, 488, 2066, 314, 4690, 365, 7710, 376, 1834, 288, 327, 2777, 1, 953, 367, 334, 354, 12, 3217, 9, 315, 2656, 14, 7436, 14, 4611, 837, 2234, 327, 642, 365, 7710, 440, 282, 1126, 13, 3266, 4260, 355, 327, 1325, 781, 886, 642, 370, 1852, 314, 7009, 1736, 355, 327, 1928, 10754, 355, 3217, 905, 7019, 937, 275, 2656, 14, 7019, 2234, 4497, 221, 275, 3217, 905, 3088, 63, 1562, 937, 355, 340, 3217, 905, 13520, 1098, 937, 508, 298, 12384, 582, 490, 340, 3217, 905, 13520, 1098, 63, 4133, 937, 440, 315, 2656, 14, 7436, 26, 717, 327, 6855, 1133, 2218, 26821, 2397, 27, 5288, 3217, 1630, 440, 717, 327, 2187, 717, 1980, 490, 3384, 275, 2656, 14, 7436, 59, 3266, 905, 13520, 1098, 63, 4133, 937, 7541, 711, 63, 1562, 937, 490, 3217, 905, 711, 63, 1562, 937, 275, 3384, 490, 1591, 275, 2656, 14, 7436, 59, 3266, 905, 13520, 1098, 63, 4133, 937, 7541, 5797, 63, 354, 937, 355, 587, 26, 490, 3384, 257, 275, 3217, 905, 711, 63, 1562, 937, 490, 1591, 275, 3217, 905, 5797, 63, 354, 937, 2234, 340, 20499, 365, 440, 488, 26, 490, 3217, 905, 18371, 937, 221, 275, 20499, 14, 475, 63, 576, 1820, 342, 2234, 340, 4497, 365, 488, 503, 4497, 508, 10812, 490, 327, 883, 1133, 2218, 282, 26821, 2397, 367, 642, 2656, 490, 1980, 2234, 7055, 275, 7055, 435, 413, 2234, 327, 314, 1768, 314, 2397, 2410, 314, 6246, 340, 3962, 355, 340, 1591, 365, 440, 488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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 ]
openstack/mistral-dashboard
mistraldashboard/workbooks/views.py
1
4166
# Copyright 2014 - StackStorm, 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.urls import reverse_lazy from django.utils.translation import ugettext_lazy as _ from django.views import generic from horizon import exceptions from horizon import forms from horizon import tables from mistraldashboard import api from mistraldashboard.workbooks import forms as mistral_forms from mistraldashboard.workbooks import tables as mistral_tables class IndexView(tables.DataTableView): table_class = mistral_tables.WorkbooksTable template_name = 'mistral/workbooks/index.html' def get_data(self): return api.workbook_list(self.request) class DetailView(generic.TemplateView): template_name = 'mistral/workbooks/detail.html' page_title = _("Workbook Definition") def get_context_data(self, **kwargs): context = super(DetailView, self).get_context_data(**kwargs) workbook = self.get_data(self.request, **kwargs) breadcrumb = [(workbook.name, reverse( 'horizon:mistral:workbooks:detail', args=[workbook.name] ))] context["custom_breadcrumb"] = breadcrumb context['definition'] = workbook.definition return context def get_data(self, request, **kwargs): try: workbook_name = kwargs['workbook_name'] workbook = api.workbook_get(request, workbook_name) except Exception: msg = _('Unable to get workbook "%s".') % workbook_name redirect = reverse('horizon:mistral:workbooks:index') exceptions.handle(self.request, msg, redirect=redirect) return workbook class SelectDefinitionView(forms.ModalFormView): template_name = 'mistral/workbooks/select_definition.html' modal_header = _("Create Workbook") form_id = "select_definition" form_class = mistral_forms.DefinitionForm submit_label = _("Validate") submit_url = reverse_lazy("horizon:mistral:workbooks:select_definition") success_url = reverse_lazy('horizon:mistral:workbooks:create') page_title = _("Select Definition") def get_form_kwargs(self): kwargs = super(SelectDefinitionView, self).get_form_kwargs() kwargs['next_view'] = CreateView return kwargs class ChangeDefinitionView(SelectDefinitionView): modal_header = _("Update Workbook") submit_url = reverse_lazy("horizon:mistral:workbooks:change_definition") success_url = reverse_lazy('horizon:mistral:workbooks:update') page_title = _("Update Definition") def get_form_kwargs(self): kwargs = super(ChangeDefinitionView, self).get_form_kwargs() kwargs['next_view'] = UpdateView return kwargs class CreateView(forms.ModalFormView): template_name = 'mistral/workbooks/create.html' modal_header = _("Create Workbook") form_id = "create_workbook" form_class = mistral_forms.CreateForm submit_label = _("Create") submit_url = reverse_lazy("horizon:mistral:workbooks:create") success_url = reverse_lazy('horizon:mistral:workbooks:index') page_title = _("Create Workbook") def get_initial(self): initial = {} if 'definition' in self.kwargs: initial['definition'] = self.kwargs['definition'] return initial class UpdateView(CreateView): template_name = 'mistral/workbooks/update.html' modal_header = _("Update Workbook") form_id = "update_workbook" form_class = mistral_forms.UpdateForm submit_label = _("Update") submit_url = reverse_lazy("horizon:mistral:workbooks:update") page_title = _("Update Workbook")
apache-2.0
[ 3, 1898, 6927, 446, 13894, 933, 1025, 12, 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, 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, 504, 1639, 14, 3603, 492, 3837, 199, 504, 1639, 14, 3603, 492, 3837, 63, 6395, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 4196, 492, 7809, 199, 199, 504, 21726, 492, 4967, 199, 504, 21726, 492, 4513, 199, 504, 21726, 492, 6716, 199, 199, 504, 333, 3075, 279, 9743, 492, 2986, 199, 504, 333, 3075, 279, 9743, 14, 800, 8858, 492, 4513, 465, 333, 3075, 279, 63, 3351, 199, 504, 333, 3075, 279, 9743, 14, 800, 8858, 492, 6716, 465, 333, 3075, 279, 63, 5987, 421, 199, 533, 5499, 2768, 8, 5987, 14, 1451, 3186, 2768, 304, 272, 1817, 63, 533, 275, 333, 3075, 279, 63, 5987, 14, 6517, 8858, 3186, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 1080, 14, 1360, 7, 339, 347, 664, 63, 576, 8, 277, 304, 267, 372, 2986, 14, 30765, 63, 513, 8, 277, 14, 1069, 9, 421, 199, 533, 13302, 2768, 8, 6767, 14, 4231, 2768, 304, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 5506, 14, 1360, 7, 272, 2034, 63, 1213, 275, 3824, 6517, 2706, 29398, 531, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 1067, 275, 1613, 8, 28539, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 1736, 2706, 275, 291, 14, 362, 63, 576, 8, 277, 14, 1069, 12, 1011, 958, 9, 267, 330, 25972, 4295, 275, 3842, 30765, 14, 354, 12, 3837, 8, 288, 283, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 5506, 297, 288, 1249, 1524, 30765, 14, 354, 61, 267, 5082, 61, 398, 1067, 905, 4229, 63, 66, 25972, 4295, 937, 275, 330, 25972, 4295, 267, 1067, 459, 7463, 418, 275, 1736, 2706, 14, 7463, 398, 372, 1067, 339, 347, 664, 63, 576, 8, 277, 12, 1056, 12, 1011, 958, 304, 267, 862, 26, 288, 1736, 2706, 63, 354, 275, 2074, 459, 30765, 63, 354, 418, 288, 1736, 2706, 275, 2986, 14, 30765, 63, 362, 8, 1069, 12, 1736, 2706, 63, 354, 9, 267, 871, 2186, 26, 288, 1499, 275, 4018, 6005, 370, 664, 1736, 2706, 2071, 83, 1674, 358, 450, 1736, 2706, 63, 354, 288, 4660, 275, 3837, 360, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 1080, 358, 288, 4967, 14, 2479, 8, 277, 14, 1069, 12, 1499, 12, 4660, 29, 4876, 9, 398, 372, 1736, 2706, 421, 199, 533, 9496, 10701, 2768, 8, 3351, 14, 23689, 2821, 2768, 304, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 2416, 63, 7463, 14, 1360, 7, 272, 21698, 63, 1291, 275, 3824, 2499, 9361, 2706, 531, 272, 1824, 63, 344, 275, 298, 2416, 63, 7463, 2, 272, 1824, 63, 533, 275, 333, 3075, 279, 63, 3351, 14, 10701, 2821, 272, 11482, 63, 1302, 275, 3824, 12584, 531, 272, 11482, 63, 633, 275, 3837, 63, 6395, 480, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 2416, 63, 7463, 531, 272, 3182, 63, 633, 275, 3837, 63, 6395, 360, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 981, 358, 272, 2034, 63, 1213, 275, 3824, 5446, 29398, 531, 339, 347, 664, 63, 964, 63, 958, 8, 277, 304, 267, 2074, 275, 1613, 8, 5446, 10701, 2768, 12, 291, 680, 362, 63, 964, 63, 958, 342, 267, 2074, 459, 2184, 63, 1345, 418, 275, 2790, 2768, 398, 372, 2074, 421, 199, 533, 7743, 10701, 2768, 8, 5446, 10701, 2768, 304, 272, 21698, 63, 1291, 275, 3824, 4152, 9361, 2706, 531, 272, 11482, 63, 633, 275, 3837, 63, 6395, 480, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 1461, 63, 7463, 531, 272, 3182, 63, 633, 275, 3837, 63, 6395, 360, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 873, 358, 272, 2034, 63, 1213, 275, 3824, 4152, 29398, 531, 339, 347, 664, 63, 964, 63, 958, 8, 277, 304, 267, 2074, 275, 1613, 8, 4001, 10701, 2768, 12, 291, 680, 362, 63, 964, 63, 958, 342, 267, 2074, 459, 2184, 63, 1345, 418, 275, 6162, 2768, 398, 372, 2074, 421, 199, 533, 2790, 2768, 8, 3351, 14, 23689, 2821, 2768, 304, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 981, 14, 1360, 7, 272, 21698, 63, 1291, 275, 3824, 2499, 9361, 2706, 531, 272, 1824, 63, 344, 275, 298, 981, 63, 30765, 2, 272, 1824, 63, 533, 275, 333, 3075, 279, 63, 3351, 14, 2499, 2821, 272, 11482, 63, 1302, 275, 3824, 2499, 531, 272, 11482, 63, 633, 275, 3837, 63, 6395, 480, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 981, 531, 272, 3182, 63, 633, 275, 3837, 63, 6395, 360, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 1080, 358, 272, 2034, 63, 1213, 275, 3824, 2499, 9361, 2706, 531, 339, 347, 664, 63, 2747, 8, 277, 304, 267, 2536, 275, 1052, 398, 340, 283, 7463, 7, 315, 291, 14, 958, 26, 288, 2536, 459, 7463, 418, 275, 291, 14, 958, 459, 7463, 418, 398, 372, 2536, 421, 199, 533, 6162, 2768, 8, 2499, 2768, 304, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 873, 14, 1360, 7, 272, 21698, 63, 1291, 275, 3824, 4152, 9361, 2706, 531, 272, 1824, 63, 344, 275, 298, 873, 63, 30765, 2, 272, 1824, 63, 533, 275, 333, 3075, 279, 63, 3351, 14 ]
[ 1898, 6927, 446, 13894, 933, 1025, 12, 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, 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, 504, 1639, 14, 3603, 492, 3837, 199, 504, 1639, 14, 3603, 492, 3837, 63, 6395, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 4196, 492, 7809, 199, 199, 504, 21726, 492, 4967, 199, 504, 21726, 492, 4513, 199, 504, 21726, 492, 6716, 199, 199, 504, 333, 3075, 279, 9743, 492, 2986, 199, 504, 333, 3075, 279, 9743, 14, 800, 8858, 492, 4513, 465, 333, 3075, 279, 63, 3351, 199, 504, 333, 3075, 279, 9743, 14, 800, 8858, 492, 6716, 465, 333, 3075, 279, 63, 5987, 421, 199, 533, 5499, 2768, 8, 5987, 14, 1451, 3186, 2768, 304, 272, 1817, 63, 533, 275, 333, 3075, 279, 63, 5987, 14, 6517, 8858, 3186, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 1080, 14, 1360, 7, 339, 347, 664, 63, 576, 8, 277, 304, 267, 372, 2986, 14, 30765, 63, 513, 8, 277, 14, 1069, 9, 421, 199, 533, 13302, 2768, 8, 6767, 14, 4231, 2768, 304, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 5506, 14, 1360, 7, 272, 2034, 63, 1213, 275, 3824, 6517, 2706, 29398, 531, 339, 347, 664, 63, 1100, 63, 576, 8, 277, 12, 1011, 958, 304, 267, 1067, 275, 1613, 8, 28539, 12, 291, 680, 362, 63, 1100, 63, 576, 3682, 958, 9, 267, 1736, 2706, 275, 291, 14, 362, 63, 576, 8, 277, 14, 1069, 12, 1011, 958, 9, 267, 330, 25972, 4295, 275, 3842, 30765, 14, 354, 12, 3837, 8, 288, 283, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 5506, 297, 288, 1249, 1524, 30765, 14, 354, 61, 267, 5082, 61, 398, 1067, 905, 4229, 63, 66, 25972, 4295, 937, 275, 330, 25972, 4295, 267, 1067, 459, 7463, 418, 275, 1736, 2706, 14, 7463, 398, 372, 1067, 339, 347, 664, 63, 576, 8, 277, 12, 1056, 12, 1011, 958, 304, 267, 862, 26, 288, 1736, 2706, 63, 354, 275, 2074, 459, 30765, 63, 354, 418, 288, 1736, 2706, 275, 2986, 14, 30765, 63, 362, 8, 1069, 12, 1736, 2706, 63, 354, 9, 267, 871, 2186, 26, 288, 1499, 275, 4018, 6005, 370, 664, 1736, 2706, 2071, 83, 1674, 358, 450, 1736, 2706, 63, 354, 288, 4660, 275, 3837, 360, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 1080, 358, 288, 4967, 14, 2479, 8, 277, 14, 1069, 12, 1499, 12, 4660, 29, 4876, 9, 398, 372, 1736, 2706, 421, 199, 533, 9496, 10701, 2768, 8, 3351, 14, 23689, 2821, 2768, 304, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 2416, 63, 7463, 14, 1360, 7, 272, 21698, 63, 1291, 275, 3824, 2499, 9361, 2706, 531, 272, 1824, 63, 344, 275, 298, 2416, 63, 7463, 2, 272, 1824, 63, 533, 275, 333, 3075, 279, 63, 3351, 14, 10701, 2821, 272, 11482, 63, 1302, 275, 3824, 12584, 531, 272, 11482, 63, 633, 275, 3837, 63, 6395, 480, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 2416, 63, 7463, 531, 272, 3182, 63, 633, 275, 3837, 63, 6395, 360, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 981, 358, 272, 2034, 63, 1213, 275, 3824, 5446, 29398, 531, 339, 347, 664, 63, 964, 63, 958, 8, 277, 304, 267, 2074, 275, 1613, 8, 5446, 10701, 2768, 12, 291, 680, 362, 63, 964, 63, 958, 342, 267, 2074, 459, 2184, 63, 1345, 418, 275, 2790, 2768, 398, 372, 2074, 421, 199, 533, 7743, 10701, 2768, 8, 5446, 10701, 2768, 304, 272, 21698, 63, 1291, 275, 3824, 4152, 9361, 2706, 531, 272, 11482, 63, 633, 275, 3837, 63, 6395, 480, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 1461, 63, 7463, 531, 272, 3182, 63, 633, 275, 3837, 63, 6395, 360, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 873, 358, 272, 2034, 63, 1213, 275, 3824, 4152, 29398, 531, 339, 347, 664, 63, 964, 63, 958, 8, 277, 304, 267, 2074, 275, 1613, 8, 4001, 10701, 2768, 12, 291, 680, 362, 63, 964, 63, 958, 342, 267, 2074, 459, 2184, 63, 1345, 418, 275, 6162, 2768, 398, 372, 2074, 421, 199, 533, 2790, 2768, 8, 3351, 14, 23689, 2821, 2768, 304, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 981, 14, 1360, 7, 272, 21698, 63, 1291, 275, 3824, 2499, 9361, 2706, 531, 272, 1824, 63, 344, 275, 298, 981, 63, 30765, 2, 272, 1824, 63, 533, 275, 333, 3075, 279, 63, 3351, 14, 2499, 2821, 272, 11482, 63, 1302, 275, 3824, 2499, 531, 272, 11482, 63, 633, 275, 3837, 63, 6395, 480, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 981, 531, 272, 3182, 63, 633, 275, 3837, 63, 6395, 360, 16561, 26, 2664, 31943, 26, 800, 8858, 26, 1080, 358, 272, 2034, 63, 1213, 275, 3824, 2499, 9361, 2706, 531, 339, 347, 664, 63, 2747, 8, 277, 304, 267, 2536, 275, 1052, 398, 340, 283, 7463, 7, 315, 291, 14, 958, 26, 288, 2536, 459, 7463, 418, 275, 291, 14, 958, 459, 7463, 418, 398, 372, 2536, 421, 199, 533, 6162, 2768, 8, 2499, 2768, 304, 272, 1978, 63, 354, 275, 283, 2664, 31943, 15, 800, 8858, 15, 873, 14, 1360, 7, 272, 21698, 63, 1291, 275, 3824, 4152, 9361, 2706, 531, 272, 1824, 63, 344, 275, 298, 873, 63, 30765, 2, 272, 1824, 63, 533, 275, 333, 3075, 279, 63, 3351, 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, 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 ]
TeamEOS/external_chromium_org
build/android/pylib/base/base_test_runner.py
8
7557
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Base class for running tests on a single device.""" import logging import time from pylib import ports from pylib.chrome_test_server_spawner import SpawningServer from pylib.device import device_utils from pylib.forwarder import Forwarder from pylib.valgrind_tools import CreateTool # TODO(frankf): Move this to pylib/utils import lighttpd_server # A file on device to store ports of net test server. The format of the file is # test-spawner-server-port:test-server-port NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports' class BaseTestRunner(object): """Base class for running tests on a single device.""" def __init__(self, device_serial, tool, push_deps=True, cleanup_test_files=False): """ Args: device: Tests will run on the device of this ID. tool: Name of the Valgrind tool. push_deps: If True, push all dependencies to the device. cleanup_test_files: Whether or not to cleanup test files on device. """ self.device_serial = device_serial self.device = device_utils.DeviceUtils(device_serial) self.tool = CreateTool(tool, self.device) self._http_server = None self._forwarder_device_port = 8000 self.forwarder_base_url = ('http://localhost:%d' % self._forwarder_device_port) self._spawning_server = None # We will allocate port for test server spawner when calling method # LaunchChromeTestServerSpawner and allocate port for test server when # starting it in TestServerThread. self.test_server_spawner_port = 0 self.test_server_port = 0 self._push_deps = push_deps self._cleanup_test_files = cleanup_test_files def _PushTestServerPortInfoToDevice(self): """Pushes the latest port information to device.""" self.device.old_interface.SetFileContents( self.device.GetExternalStoragePath() + '/' + NET_TEST_SERVER_PORT_INFO_FILE, '%d:%d' % (self.test_server_spawner_port, self.test_server_port)) def RunTest(self, test): """Runs a test. Needs to be overridden. Args: test: A test to run. Returns: Tuple containing: (base_test_result.TestRunResults, tests to rerun or None) """ raise NotImplementedError def InstallTestPackage(self): """Installs the test package once before all tests are run.""" pass def PushDataDeps(self): """Push all data deps to device once before all tests are run.""" pass def SetUp(self): """Run once before all tests are run.""" self.InstallTestPackage() push_size_before = self.device.old_interface.GetPushSizeInfo() if self._push_deps: logging.warning('Pushing data files to device.') self.PushDataDeps() push_size_after = self.device.old_interface.GetPushSizeInfo() logging.warning( 'Total data: %0.3fMB' % ((push_size_after[0] - push_size_before[0]) / float(2 ** 20))) logging.warning( 'Total data transferred: %0.3fMB' % ((push_size_after[1] - push_size_before[1]) / float(2 ** 20))) else: logging.warning('Skipping pushing data to device.') def TearDown(self): """Run once after all tests are run.""" self.ShutdownHelperToolsForTestSuite() if self._cleanup_test_files: self.device.old_interface.RemovePushedFiles() def LaunchTestHttpServer(self, document_root, port=None, extra_config_contents=None): """Launches an HTTP server to serve HTTP tests. Args: document_root: Document root of the HTTP server. port: port on which we want to the http server bind. extra_config_contents: Extra config contents for the HTTP server. """ self._http_server = lighttpd_server.LighttpdServer( document_root, port=port, extra_config_contents=extra_config_contents) if self._http_server.StartupHttpServer(): logging.info('http server started: http://localhost:%s', self._http_server.port) else: logging.critical('Failed to start http server') self._ForwardPortsForHttpServer() return (self._forwarder_device_port, self._http_server.port) def _ForwardPorts(self, port_pairs): """Forwards a port.""" Forwarder.Map(port_pairs, self.device, self.tool) def _UnmapPorts(self, port_pairs): """Unmap previously forwarded ports.""" for (device_port, _) in port_pairs: Forwarder.UnmapDevicePort(device_port, self.device) # Deprecated: Use ForwardPorts instead. def StartForwarder(self, port_pairs): """Starts TCP traffic forwarding for the given |port_pairs|. Args: host_port_pairs: A list of (device_port, local_port) tuples to forward. """ self._ForwardPorts(port_pairs) def _ForwardPortsForHttpServer(self): """Starts a forwarder for the HTTP server. The forwarder forwards HTTP requests and responses between host and device. """ self._ForwardPorts([(self._forwarder_device_port, self._http_server.port)]) def _RestartHttpServerForwarderIfNecessary(self): """Restarts the forwarder if it's not open.""" # Checks to see if the http server port is being used. If not forwards the # request. # TODO(dtrainor): This is not always reliable because sometimes the port # will be left open even after the forwarder has been killed. if not ports.IsDevicePortUsed(self.device, self._forwarder_device_port): self._ForwardPortsForHttpServer() def ShutdownHelperToolsForTestSuite(self): """Shuts down the server and the forwarder.""" if self._http_server: self._UnmapPorts([(self._forwarder_device_port, self._http_server.port)]) self._http_server.ShutdownHttpServer() if self._spawning_server: self._spawning_server.Stop() def CleanupSpawningServerState(self): """Tells the spawning server to clean up any state. If the spawning server is reused for multiple tests, this should be called after each test to prevent tests affecting each other. """ if self._spawning_server: self._spawning_server.CleanupState() def LaunchChromeTestServerSpawner(self): """Launches test server spawner.""" server_ready = False error_msgs = [] # TODO(pliard): deflake this function. The for loop should be removed as # well as IsHttpServerConnectable(). spawning_server.Start() should also # block until the server is ready. # Try 3 times to launch test spawner server. for _ in xrange(0, 3): self.test_server_spawner_port = ports.AllocateTestServerPort() self._ForwardPorts( [(self.test_server_spawner_port, self.test_server_spawner_port)]) self._spawning_server = SpawningServer(self.test_server_spawner_port, self.device, self.tool) self._spawning_server.Start() server_ready, error_msg = ports.IsHttpServerConnectable( '127.0.0.1', self.test_server_spawner_port, path='/ping', expected_read='ready') if server_ready: break else: error_msgs.append(error_msg) self._spawning_server.Stop() # Wait for 2 seconds then restart. time.sleep(2) if not server_ready: logging.error(';'.join(error_msgs)) raise Exception('Can not start the test spawner server.') self._PushTestServerPortInfoToDevice()
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 1563, 1021, 367, 3879, 2295, 641, 282, 2849, 2243, 1041, 199, 199, 646, 2050, 199, 646, 900, 199, 199, 504, 29219, 492, 8873, 199, 504, 29219, 14, 9887, 63, 396, 63, 1000, 63, 3770, 4977, 492, 17812, 87, 1835, 3120, 199, 504, 29219, 14, 1782, 492, 2243, 63, 1208, 199, 504, 29219, 14, 509, 26829, 492, 2104, 26829, 199, 504, 29219, 14, 637, 21510, 63, 2537, 492, 2790, 5157, 199, 3, 3254, 8, 70, 4648, 70, 304, 14171, 642, 370, 29219, 15, 1208, 199, 646, 10540, 683, 68, 63, 1000, 421, 199, 3, 437, 570, 641, 2243, 370, 3877, 8873, 402, 1851, 511, 1654, 14, 710, 1475, 402, 314, 570, 365, 199, 3, 511, 13, 3770, 4977, 13, 1000, 13, 719, 26, 396, 13, 1000, 13, 719, 199, 7278, 63, 2864, 63, 6613, 63, 3657, 63, 4531, 63, 3817, 275, 283, 846, 13, 396, 13, 1000, 13, 5203, 7, 421, 199, 533, 3523, 13649, 8, 785, 304, 523, 408, 1563, 1021, 367, 3879, 2295, 641, 282, 2849, 2243, 1041, 819, 347, 636, 826, 721, 277, 12, 2243, 63, 2171, 12, 4744, 12, 6675, 63, 5846, 29, 549, 12, 2049, 9058, 63, 396, 63, 1725, 29, 797, 304, 272, 408, 489, 3033, 26, 267, 2243, 26, 6496, 911, 1255, 641, 314, 2243, 402, 642, 2870, 14, 267, 4744, 26, 2812, 402, 314, 26263, 21510, 4744, 14, 267, 6675, 63, 5846, 26, 982, 715, 12, 6675, 1006, 5124, 370, 314, 2243, 14, 267, 9058, 63, 396, 63, 1725, 26, 7480, 503, 440, 370, 9058, 511, 1584, 641, 2243, 14, 272, 408, 272, 291, 14, 1782, 63, 2171, 275, 2243, 63, 2171, 272, 291, 14, 1782, 275, 2243, 63, 1208, 14, 2510, 7535, 8, 1782, 63, 2171, 9, 272, 291, 14, 3557, 275, 2790, 5157, 8, 3557, 12, 291, 14, 1782, 9, 272, 291, 423, 1014, 63, 1000, 275, 488, 272, 291, 423, 509, 26829, 63, 1782, 63, 719, 275, 29855, 272, 291, 14, 509, 26829, 63, 1095, 63, 633, 275, 661, 1014, 921, 5967, 2689, 68, 7, 450, 267, 291, 423, 509, 26829, 63, 1782, 63, 719, 9, 272, 291, 423, 3770, 87, 1835, 63, 1000, 275, 488, 272, 327, 2136, 911, 18310, 1844, 367, 511, 1654, 5844, 4977, 1380, 6358, 1083, 272, 327, 23615, 18083, 774, 3120, 12739, 4977, 436, 18310, 1844, 367, 511, 1654, 1380, 272, 327, 6617, 652, 315, 1379, 3120, 4436, 14, 272, 291, 14, 396, 63, 1000, 63, 3770, 4977, 63, 719, 275, 378, 272, 291, 14, 396, 63, 1000, 63, 719, 275, 378, 272, 291, 423, 5335, 63, 5846, 275, 6675, 63, 5846, 272, 291, 423, 7661, 63, 396, 63, 1725, 275, 9058, 63, 396, 63, 1725, 819, 347, 485, 10731, 774, 3120, 4313, 2354, 1378, 2510, 8, 277, 304, 272, 408, 10731, 397, 314, 8839, 1844, 2556, 370, 2243, 1041, 272, 291, 14, 1782, 14, 1753, 63, 3266, 14, 1084, 1173, 11383, 8, 267, 291, 14, 1782, 14, 1002, 11389, 6408, 2042, 342, 435, 7324, 435, 288, 18340, 63, 2864, 63, 6613, 63, 3657, 63, 4531, 63, 3817, 12, 267, 1543, 68, 2689, 68, 7, 450, 334, 277, 14, 396, 63, 1000, 63, 3770, 4977, 63, 719, 12, 291, 14, 396, 63, 1000, 63, 719, 430, 819, 347, 3378, 774, 8, 277, 12, 511, 304, 272, 408, 16291, 282, 511, 14, 29613, 370, 506, 10087, 14, 339, 3033, 26, 489, 511, 26, 437, 511, 370, 1255, 14, 339, 1803, 26, 489, 11634, 3035, 26, 267, 334, 1095, 63, 396, 63, 1099, 14, 21228, 6579, 12, 2295, 370, 295, 1065, 503, 488, 9, 272, 408, 272, 746, 4279, 819, 347, 13276, 774, 8599, 8, 277, 304, 272, 408, 8154, 83, 314, 511, 2559, 5403, 2544, 1006, 2295, 787, 1255, 1041, 272, 986, 819, 347, 22643, 1451, 27683, 8, 277, 304, 272, 408, 10731, 1006, 666, 10140, 370, 2243, 5403, 2544, 1006, 2295, 787, 1255, 1041, 272, 986, 819, 347, 2494, 1721, 8, 277, 304, 272, 408, 2540, 5403, 2544, 1006, 2295, 787, 1255, 1041, 272, 291, 14, 8154, 774, 8599, 342, 272, 6675, 63, 890, 63, 5182, 275, 291, 14, 1782, 14, 1753, 63, 3266, 14, 1002, 10731, 2320, 2354, 342, 272, 340, 291, 423, 5335, 63, 5846, 26, 489, 2050, 14, 3764, 360, 10731, 316, 666, 1584, 370, 2243, 2659, 489, 291, 14, 10731, 1451, 27683, 342, 489, 6675, 63, 890, 63, 4399, 275, 291, 14, 1782, 14, 1753, 63, 3266, 14, 1002, 10731, 2320, 2354, 342, 489, 2050, 14, 3764, 8, 881, 283, 7316, 666, 26, 450, 16, 14, 19, 70, 4567, 7, 450, 881, 3666, 5335, 63, 890, 63, 4399, 59, 16, 61, 446, 6675, 63, 890, 63, 5182, 59, 16, 566, 1182, 2069, 8, 18, 1011, 3388, 1724, 489, 2050, 14, 3764, 8, 881, 283, 7316, 666, 1752, 5057, 26, 450, 16, 14, 19, 70, 4567, 7, 450, 881, 3666, 5335, 63, 890, 63, 4399, 59, 17, 61, 446, 6675, 63, 890, 63, 5182, 59, 17, 566, 1182, 2069, 8, 18, 1011, 3388, 1724, 272, 587, 26, 489, 2050, 14, 3764, 360, 18297, 6675, 316, 666, 370, 2243, 2659, 819, 347, 377, 25236, 8, 277, 304, 272, 408, 2540, 5403, 2410, 1006, 2295, 787, 1255, 1041, 272, 291, 14, 20043, 4433, 11654, 1858, 10591, 342, 272, 340, 291, 423, 7661, 63, 396, 63, 1725, 26, 489, 291, 14, 1782, 14, 1753, 63, 3266, 14, 5587, 10731, 379, 5535, 342, 819, 347, 23615, 774, 5779, 3120, 8, 277, 12, 2213, 63, 1231, 12, 1844, 29, 403, 12, 2574, 2402, 63, 888, 63, 4407, 29, 403, 304, 272, 408, 18543, 397, 376, 3101, 1654, 370, 14062, 3101, 2295, 14, 339, 3033, 26, 489, 2213, 63, 1231, 26, 7543, 1738, 402, 314, 3101, 1654, 14, 489, 1844, 26, 1844, 641, 1314, 781, 2934, 370, 314, 1455, 1654, 5398, 14, 489, 2402, 63, 888, 63, 4407, 26, 11177, 1101, 4072, 367, 314, 3101, 1654, 14, 272, 408, 272, 291, 423, 1014, 63, 1000, 275, 10540, 683, 68 ]
[ 1898, 334, 67, 9, 6029, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 1563, 1021, 367, 3879, 2295, 641, 282, 2849, 2243, 1041, 199, 199, 646, 2050, 199, 646, 900, 199, 199, 504, 29219, 492, 8873, 199, 504, 29219, 14, 9887, 63, 396, 63, 1000, 63, 3770, 4977, 492, 17812, 87, 1835, 3120, 199, 504, 29219, 14, 1782, 492, 2243, 63, 1208, 199, 504, 29219, 14, 509, 26829, 492, 2104, 26829, 199, 504, 29219, 14, 637, 21510, 63, 2537, 492, 2790, 5157, 199, 3, 3254, 8, 70, 4648, 70, 304, 14171, 642, 370, 29219, 15, 1208, 199, 646, 10540, 683, 68, 63, 1000, 421, 199, 3, 437, 570, 641, 2243, 370, 3877, 8873, 402, 1851, 511, 1654, 14, 710, 1475, 402, 314, 570, 365, 199, 3, 511, 13, 3770, 4977, 13, 1000, 13, 719, 26, 396, 13, 1000, 13, 719, 199, 7278, 63, 2864, 63, 6613, 63, 3657, 63, 4531, 63, 3817, 275, 283, 846, 13, 396, 13, 1000, 13, 5203, 7, 421, 199, 533, 3523, 13649, 8, 785, 304, 523, 408, 1563, 1021, 367, 3879, 2295, 641, 282, 2849, 2243, 1041, 819, 347, 636, 826, 721, 277, 12, 2243, 63, 2171, 12, 4744, 12, 6675, 63, 5846, 29, 549, 12, 2049, 9058, 63, 396, 63, 1725, 29, 797, 304, 272, 408, 489, 3033, 26, 267, 2243, 26, 6496, 911, 1255, 641, 314, 2243, 402, 642, 2870, 14, 267, 4744, 26, 2812, 402, 314, 26263, 21510, 4744, 14, 267, 6675, 63, 5846, 26, 982, 715, 12, 6675, 1006, 5124, 370, 314, 2243, 14, 267, 9058, 63, 396, 63, 1725, 26, 7480, 503, 440, 370, 9058, 511, 1584, 641, 2243, 14, 272, 408, 272, 291, 14, 1782, 63, 2171, 275, 2243, 63, 2171, 272, 291, 14, 1782, 275, 2243, 63, 1208, 14, 2510, 7535, 8, 1782, 63, 2171, 9, 272, 291, 14, 3557, 275, 2790, 5157, 8, 3557, 12, 291, 14, 1782, 9, 272, 291, 423, 1014, 63, 1000, 275, 488, 272, 291, 423, 509, 26829, 63, 1782, 63, 719, 275, 29855, 272, 291, 14, 509, 26829, 63, 1095, 63, 633, 275, 661, 1014, 921, 5967, 2689, 68, 7, 450, 267, 291, 423, 509, 26829, 63, 1782, 63, 719, 9, 272, 291, 423, 3770, 87, 1835, 63, 1000, 275, 488, 272, 327, 2136, 911, 18310, 1844, 367, 511, 1654, 5844, 4977, 1380, 6358, 1083, 272, 327, 23615, 18083, 774, 3120, 12739, 4977, 436, 18310, 1844, 367, 511, 1654, 1380, 272, 327, 6617, 652, 315, 1379, 3120, 4436, 14, 272, 291, 14, 396, 63, 1000, 63, 3770, 4977, 63, 719, 275, 378, 272, 291, 14, 396, 63, 1000, 63, 719, 275, 378, 272, 291, 423, 5335, 63, 5846, 275, 6675, 63, 5846, 272, 291, 423, 7661, 63, 396, 63, 1725, 275, 9058, 63, 396, 63, 1725, 819, 347, 485, 10731, 774, 3120, 4313, 2354, 1378, 2510, 8, 277, 304, 272, 408, 10731, 397, 314, 8839, 1844, 2556, 370, 2243, 1041, 272, 291, 14, 1782, 14, 1753, 63, 3266, 14, 1084, 1173, 11383, 8, 267, 291, 14, 1782, 14, 1002, 11389, 6408, 2042, 342, 435, 7324, 435, 288, 18340, 63, 2864, 63, 6613, 63, 3657, 63, 4531, 63, 3817, 12, 267, 1543, 68, 2689, 68, 7, 450, 334, 277, 14, 396, 63, 1000, 63, 3770, 4977, 63, 719, 12, 291, 14, 396, 63, 1000, 63, 719, 430, 819, 347, 3378, 774, 8, 277, 12, 511, 304, 272, 408, 16291, 282, 511, 14, 29613, 370, 506, 10087, 14, 339, 3033, 26, 489, 511, 26, 437, 511, 370, 1255, 14, 339, 1803, 26, 489, 11634, 3035, 26, 267, 334, 1095, 63, 396, 63, 1099, 14, 21228, 6579, 12, 2295, 370, 295, 1065, 503, 488, 9, 272, 408, 272, 746, 4279, 819, 347, 13276, 774, 8599, 8, 277, 304, 272, 408, 8154, 83, 314, 511, 2559, 5403, 2544, 1006, 2295, 787, 1255, 1041, 272, 986, 819, 347, 22643, 1451, 27683, 8, 277, 304, 272, 408, 10731, 1006, 666, 10140, 370, 2243, 5403, 2544, 1006, 2295, 787, 1255, 1041, 272, 986, 819, 347, 2494, 1721, 8, 277, 304, 272, 408, 2540, 5403, 2544, 1006, 2295, 787, 1255, 1041, 272, 291, 14, 8154, 774, 8599, 342, 272, 6675, 63, 890, 63, 5182, 275, 291, 14, 1782, 14, 1753, 63, 3266, 14, 1002, 10731, 2320, 2354, 342, 272, 340, 291, 423, 5335, 63, 5846, 26, 489, 2050, 14, 3764, 360, 10731, 316, 666, 1584, 370, 2243, 2659, 489, 291, 14, 10731, 1451, 27683, 342, 489, 6675, 63, 890, 63, 4399, 275, 291, 14, 1782, 14, 1753, 63, 3266, 14, 1002, 10731, 2320, 2354, 342, 489, 2050, 14, 3764, 8, 881, 283, 7316, 666, 26, 450, 16, 14, 19, 70, 4567, 7, 450, 881, 3666, 5335, 63, 890, 63, 4399, 59, 16, 61, 446, 6675, 63, 890, 63, 5182, 59, 16, 566, 1182, 2069, 8, 18, 1011, 3388, 1724, 489, 2050, 14, 3764, 8, 881, 283, 7316, 666, 1752, 5057, 26, 450, 16, 14, 19, 70, 4567, 7, 450, 881, 3666, 5335, 63, 890, 63, 4399, 59, 17, 61, 446, 6675, 63, 890, 63, 5182, 59, 17, 566, 1182, 2069, 8, 18, 1011, 3388, 1724, 272, 587, 26, 489, 2050, 14, 3764, 360, 18297, 6675, 316, 666, 370, 2243, 2659, 819, 347, 377, 25236, 8, 277, 304, 272, 408, 2540, 5403, 2410, 1006, 2295, 787, 1255, 1041, 272, 291, 14, 20043, 4433, 11654, 1858, 10591, 342, 272, 340, 291, 423, 7661, 63, 396, 63, 1725, 26, 489, 291, 14, 1782, 14, 1753, 63, 3266, 14, 5587, 10731, 379, 5535, 342, 819, 347, 23615, 774, 5779, 3120, 8, 277, 12, 2213, 63, 1231, 12, 1844, 29, 403, 12, 2574, 2402, 63, 888, 63, 4407, 29, 403, 304, 272, 408, 18543, 397, 376, 3101, 1654, 370, 14062, 3101, 2295, 14, 339, 3033, 26, 489, 2213, 63, 1231, 26, 7543, 1738, 402, 314, 3101, 1654, 14, 489, 1844, 26, 1844, 641, 1314, 781, 2934, 370, 314, 1455, 1654, 5398, 14, 489, 2402, 63, 888, 63, 4407, 26, 11177, 1101, 4072, 367, 314, 3101, 1654, 14, 272, 408, 272, 291, 423, 1014, 63, 1000, 275, 10540, 683, 68, 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,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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 ]
darkwing/kuma
vendor/packages/translate/lang/test_fa.py
33
2840
#!/usr/bin/env python # -*- coding: utf-8 -*- from translate.lang import factory def test_punctranslate(): """Tests that we can translate punctuation.""" language = factory.getlanguage('fa') assert language.punctranslate(u"") == u"" assert language.punctranslate(u"abc efg") == u"abc efg" assert language.punctranslate(u"abc efg.") == u"abc efg." assert language.punctranslate(u"Delete file: %s?") == u"Delete file: %s؟" assert language.punctranslate(u'"root" is powerful') == u"«root» is powerful" assert language.punctranslate(u"'root' is powerful") == u"«root» is powerful" assert language.punctranslate(u"`root' is powerful") == u"«root» is powerful" assert language.punctranslate(u'The user "root"') == u"The user «root»" assert language.punctranslate(u"The user 'root'") == u"The user «root»" assert language.punctranslate(u"The user `root'") == u"The user «root»" assert language.punctranslate(u'The user "root"?') == u"The user «root»؟" assert language.punctranslate(u"The user 'root'?") == u"The user «root»؟" assert language.punctranslate(u"The user `root'?") == u"The user «root»؟" assert language.punctranslate(u'Watch the " mark') == u'Watch the " mark' assert language.punctranslate(u"Watch the ' mark") == u"Watch the ' mark" assert language.punctranslate(u"Watch the ` mark") == u"Watch the ` mark" assert language.punctranslate(u'Watch the “mark”') == u"Watch the «mark»" assert language.punctranslate(u'The <a href="info">user</a> "root"?') == u'The <a href="info">user</a> «root»؟' assert language.punctranslate(u"The <a href='info'>user</a> 'root'?") == u"The <a href='info'>user</a> «root»؟" #Broken because we test for equal number of ` and ' in the string #assert language.punctranslate(u"The <a href='info'>user</a> `root'?") == u"The <a href='info'>user</a> «root»؟" assert language.punctranslate(u"The <a href='http://koeie'>user</a>") == u"The <a href='http://koeie'>user</a>" assert language.punctranslate(u"Copying `%s' to `%s'") == u"Copying «%s» to «%s»" # We are very careful by checking that the ` and ' match, so we miss this because of internal punctuation: #assert language.punctranslate(u"Shlib `%s' didn't contain `%s'") == u"Shlib «%s» didn't contain «%s»" def test_sentences(): """Tests basic functionality of sentence segmentation.""" language = factory.getlanguage('fa') sentences = language.sentences(u"") assert sentences == [] sentences = language.sentences(u"Normal case. Nothing interesting.") assert sentences == [u"Normal case.", u"Nothing interesting."] sentences = language.sentences(u"Is that the case ? Sounds interesting !") assert sentences == [u"Is that the case ?", u"Sounds interesting !"]
mpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 9028, 14, 4159, 492, 6434, 421, 199, 318, 511, 63, 27003, 1320, 750, 837, 272, 408, 2925, 626, 781, 883, 9028, 22929, 1041, 272, 2637, 275, 6434, 14, 362, 3671, 360, 667, 358, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7230, 508, 399, 341, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 3175, 9530, 71, 531, 508, 399, 2, 3175, 9530, 71, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 3175, 9530, 71, 2685, 508, 399, 2, 3175, 9530, 71, 2122, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 5392, 570, 26, 450, 83, 18582, 508, 399, 2, 5392, 570, 26, 450, 83, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 4065, 1231, 2, 365, 7074, 1893, 358, 508, 399, 2, 127, 105, 1231, 127, 120, 365, 7074, 1893, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 4507, 1231, 7, 365, 7074, 1893, 531, 508, 399, 2, 127, 105, 1231, 127, 120, 365, 7074, 1893, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 64, 1231, 7, 365, 7074, 1893, 531, 508, 399, 2, 127, 105, 1231, 127, 120, 365, 7074, 1893, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 1918, 922, 298, 1231, 9008, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 922, 283, 1231, 9859, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 922, 658, 1231, 9859, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 1918, 922, 298, 1231, 14863, 358, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 922, 283, 1231, 7, 18582, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 922, 658, 1231, 7, 18582, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 13978, 314, 298, 2216, 358, 508, 399, 7, 13978, 314, 298, 2216, 7, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 13978, 314, 283, 2216, 531, 508, 399, 2, 13978, 314, 283, 2216, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 13978, 314, 658, 2216, 531, 508, 399, 2, 13978, 314, 658, 2216, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 13978, 314, 27430, 251, 1657, 8477, 252, 358, 508, 399, 2, 13978, 314, 22405, 105, 1657, 127, 120, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 1918, 665, 65, 4369, 628, 815, 1743, 751, 1108, 65, 30, 298, 1231, 14863, 358, 508, 399, 7, 1918, 665, 65, 4369, 628, 815, 1743, 751, 1108, 65, 30, 22405, 105, 1231, 127, 120, 149, 254, 7, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 665, 65, 4369, 534, 815, 8423, 751, 1108, 65, 30, 283, 1231, 7, 18582, 508, 399, 2, 1918, 665, 65, 4369, 534, 815, 8423, 751, 1108, 65, 30, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 327, 30509, 2952, 781, 511, 367, 4472, 1329, 402, 658, 436, 283, 315, 314, 1059, 272, 327, 479, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 665, 65, 4369, 534, 815, 8423, 751, 1108, 65, 30, 658, 1231, 7, 18582, 508, 399, 2, 1918, 665, 65, 4369, 534, 815, 8423, 751, 1108, 65, 30, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 665, 65, 4369, 534, 1014, 921, 7697, 69, 1873, 8423, 751, 1108, 65, 9579, 508, 399, 2, 1918, 665, 65, 4369, 534, 1014, 921, 7697, 69, 1873, 8423, 751, 1108, 65, 4335, 339, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 32596, 18633, 83, 7, 370, 18633, 83, 9859, 508, 399, 2, 32596, 22405, 105, 5, 83, 127, 120, 370, 22405, 105, 5, 83, 127, 120, 2, 272, 327, 2136, 787, 7437, 25082, 701, 7907, 626, 314, 658, 436, 283, 1336, 12, 880, 781, 26747, 642, 2952, 402, 5007, 22929, 26, 272, 327, 479, 2637, 14, 27003, 1320, 750, 8, 85, 2, 2662, 773, 18633, 83, 7, 9980, 1133, 1395, 18633, 83, 9859, 508, 399, 2, 2662, 773, 22405, 105, 5, 83, 127, 120, 9980, 1133, 1395, 22405, 105, 5, 83, 127, 120, 2, 421, 199, 318, 511, 63, 25669, 837, 272, 408, 2925, 5678, 9330, 402, 14537, 27315, 1041, 272, 2637, 275, 6434, 14, 362, 3671, 360, 667, 358, 272, 24256, 275, 2637, 14, 25669, 8, 85, 7230, 272, 702, 24256, 508, 942, 339, 24256, 275, 2637, 14, 25669, 8, 85, 2, 6241, 1930, 14, 20550, 19604, 2685, 272, 702, 24256, 508, 359, 85, 2, 6241, 1930, 4765, 399, 2, 19627, 19604, 14, 937, 272, 24256, 275, 2637, 14, 25669, 8, 85, 2, 1831, 626, 314, 1930, 5805, 428, 1034, 83, 19604, 8546, 531, 272, 702, 24256, 508, 359, 85, 2, 1831, 626, 314, 1930, 5805, 401, 399, 2, 18670, 83, 19604, 8546, 937, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 9028, 14, 4159, 492, 6434, 421, 199, 318, 511, 63, 27003, 1320, 750, 837, 272, 408, 2925, 626, 781, 883, 9028, 22929, 1041, 272, 2637, 275, 6434, 14, 362, 3671, 360, 667, 358, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7230, 508, 399, 341, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 3175, 9530, 71, 531, 508, 399, 2, 3175, 9530, 71, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 3175, 9530, 71, 2685, 508, 399, 2, 3175, 9530, 71, 2122, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 5392, 570, 26, 450, 83, 18582, 508, 399, 2, 5392, 570, 26, 450, 83, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 4065, 1231, 2, 365, 7074, 1893, 358, 508, 399, 2, 127, 105, 1231, 127, 120, 365, 7074, 1893, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 4507, 1231, 7, 365, 7074, 1893, 531, 508, 399, 2, 127, 105, 1231, 127, 120, 365, 7074, 1893, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 64, 1231, 7, 365, 7074, 1893, 531, 508, 399, 2, 127, 105, 1231, 127, 120, 365, 7074, 1893, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 1918, 922, 298, 1231, 9008, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 922, 283, 1231, 9859, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 922, 658, 1231, 9859, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 1918, 922, 298, 1231, 14863, 358, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 922, 283, 1231, 7, 18582, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 922, 658, 1231, 7, 18582, 508, 399, 2, 1918, 922, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 13978, 314, 298, 2216, 358, 508, 399, 7, 13978, 314, 298, 2216, 7, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 13978, 314, 283, 2216, 531, 508, 399, 2, 13978, 314, 283, 2216, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 13978, 314, 658, 2216, 531, 508, 399, 2, 13978, 314, 658, 2216, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 13978, 314, 27430, 251, 1657, 8477, 252, 358, 508, 399, 2, 13978, 314, 22405, 105, 1657, 127, 120, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 7, 1918, 665, 65, 4369, 628, 815, 1743, 751, 1108, 65, 30, 298, 1231, 14863, 358, 508, 399, 7, 1918, 665, 65, 4369, 628, 815, 1743, 751, 1108, 65, 30, 22405, 105, 1231, 127, 120, 149, 254, 7, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 665, 65, 4369, 534, 815, 8423, 751, 1108, 65, 30, 283, 1231, 7, 18582, 508, 399, 2, 1918, 665, 65, 4369, 534, 815, 8423, 751, 1108, 65, 30, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 327, 30509, 2952, 781, 511, 367, 4472, 1329, 402, 658, 436, 283, 315, 314, 1059, 272, 327, 479, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 665, 65, 4369, 534, 815, 8423, 751, 1108, 65, 30, 658, 1231, 7, 18582, 508, 399, 2, 1918, 665, 65, 4369, 534, 815, 8423, 751, 1108, 65, 30, 22405, 105, 1231, 127, 120, 149, 254, 2, 272, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 1918, 665, 65, 4369, 534, 1014, 921, 7697, 69, 1873, 8423, 751, 1108, 65, 9579, 508, 399, 2, 1918, 665, 65, 4369, 534, 1014, 921, 7697, 69, 1873, 8423, 751, 1108, 65, 4335, 339, 702, 2637, 14, 27003, 1320, 750, 8, 85, 2, 32596, 18633, 83, 7, 370, 18633, 83, 9859, 508, 399, 2, 32596, 22405, 105, 5, 83, 127, 120, 370, 22405, 105, 5, 83, 127, 120, 2, 272, 327, 2136, 787, 7437, 25082, 701, 7907, 626, 314, 658, 436, 283, 1336, 12, 880, 781, 26747, 642, 2952, 402, 5007, 22929, 26, 272, 327, 479, 2637, 14, 27003, 1320, 750, 8, 85, 2, 2662, 773, 18633, 83, 7, 9980, 1133, 1395, 18633, 83, 9859, 508, 399, 2, 2662, 773, 22405, 105, 5, 83, 127, 120, 9980, 1133, 1395, 22405, 105, 5, 83, 127, 120, 2, 421, 199, 318, 511, 63, 25669, 837, 272, 408, 2925, 5678, 9330, 402, 14537, 27315, 1041, 272, 2637, 275, 6434, 14, 362, 3671, 360, 667, 358, 272, 24256, 275, 2637, 14, 25669, 8, 85, 7230, 272, 702, 24256, 508, 942, 339, 24256, 275, 2637, 14, 25669, 8, 85, 2, 6241, 1930, 14, 20550, 19604, 2685, 272, 702, 24256, 508, 359, 85, 2, 6241, 1930, 4765, 399, 2, 19627, 19604, 14, 937, 272, 24256, 275, 2637, 14, 25669, 8, 85, 2, 1831, 626, 314, 1930, 5805, 428, 1034, 83, 19604, 8546, 531, 272, 702, 24256, 508, 359, 85, 2, 1831, 626, 314, 1930, 5805, 401, 399, 2, 18670, 83, 19604, 8546, 937, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
orangeduck/PyAutoC
Python27/Lib/idlelib/keybindingDialog.py
89
12407
""" Dialog for building Tkinter accelerator key bindings """ from Tkinter import * import tkMessageBox import string class GetKeysDialog(Toplevel): def __init__(self,parent,title,action,currentKeySequences): """ action - string, the name of the virtual event these keys will be mapped to currentKeys - list, a list of all key sequence lists currently mapped to virtual events, for overlap checking """ Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.resizable(height=FALSE,width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Cancel) self.parent = parent self.action=action self.currentKeySequences=currentKeySequences self.result='' self.keyString=StringVar(self) self.keyString.set('') self.SetModifiersForPlatform() # set self.modifiers, self.modifier_label self.modifier_vars = [] for modifier in self.modifiers: variable = StringVar(self) variable.set('') self.modifier_vars.append(variable) self.advanced = False self.CreateWidgets() self.LoadFinalKeyList() self.withdraw() #hide while setting geometry self.update_idletasks() self.geometry("+%d+%d" % ((parent.winfo_rootx()+((parent.winfo_width()/2) -(self.winfo_reqwidth()/2)), parent.winfo_rooty()+((parent.winfo_height()/2) -(self.winfo_reqheight()/2)) )) ) #centre dialog over parent self.deiconify() #geometry set, unhide self.wait_window() def CreateWidgets(self): frameMain = Frame(self,borderwidth=2,relief=SUNKEN) frameMain.pack(side=TOP,expand=TRUE,fill=BOTH) frameButtons=Frame(self) frameButtons.pack(side=BOTTOM,fill=X) self.buttonOK = Button(frameButtons,text='OK', width=8,command=self.OK) self.buttonOK.grid(row=0,column=0,padx=5,pady=5) self.buttonCancel = Button(frameButtons,text='Cancel', width=8,command=self.Cancel) self.buttonCancel.grid(row=0,column=1,padx=5,pady=5) self.frameKeySeqBasic = Frame(frameMain) self.frameKeySeqAdvanced = Frame(frameMain) self.frameControlsBasic = Frame(frameMain) self.frameHelpAdvanced = Frame(frameMain) self.frameKeySeqAdvanced.grid(row=0,column=0,sticky=NSEW,padx=5,pady=5) self.frameKeySeqBasic.grid(row=0,column=0,sticky=NSEW,padx=5,pady=5) self.frameKeySeqBasic.lift() self.frameHelpAdvanced.grid(row=1,column=0,sticky=NSEW,padx=5) self.frameControlsBasic.grid(row=1,column=0,sticky=NSEW,padx=5) self.frameControlsBasic.lift() self.buttonLevel = Button(frameMain,command=self.ToggleLevel, text='Advanced Key Binding Entry >>') self.buttonLevel.grid(row=2,column=0,stick=EW,padx=5,pady=5) labelTitleBasic = Label(self.frameKeySeqBasic, text="New keys for '"+self.action+"' :") labelTitleBasic.pack(anchor=W) labelKeysBasic = Label(self.frameKeySeqBasic,justify=LEFT, textvariable=self.keyString,relief=GROOVE,borderwidth=2) labelKeysBasic.pack(ipadx=5,ipady=5,fill=X) self.modifier_checkbuttons = {} column = 0 for modifier, variable in zip(self.modifiers, self.modifier_vars): label = self.modifier_label.get(modifier, modifier) check=Checkbutton(self.frameControlsBasic, command=self.BuildKeyString, text=label,variable=variable,onvalue=modifier,offvalue='') check.grid(row=0,column=column,padx=2,sticky=W) self.modifier_checkbuttons[modifier] = check column += 1 labelFnAdvice=Label(self.frameControlsBasic,justify=LEFT, text=\ "Select the desired modifier keys\n"+ "above, and the final key from the\n"+ "list on the right.\n\n" + "Use upper case Symbols when using\n" + "the Shift modifier. (Letters will be\n" + "converted automatically.)") labelFnAdvice.grid(row=1,column=0,columnspan=4,padx=2,sticky=W) self.listKeysFinal=Listbox(self.frameControlsBasic,width=15,height=10, selectmode=SINGLE) self.listKeysFinal.bind('<ButtonRelease-1>',self.FinalKeySelected) self.listKeysFinal.grid(row=0,column=4,rowspan=4,sticky=NS) scrollKeysFinal=Scrollbar(self.frameControlsBasic,orient=VERTICAL, command=self.listKeysFinal.yview) self.listKeysFinal.config(yscrollcommand=scrollKeysFinal.set) scrollKeysFinal.grid(row=0,column=5,rowspan=4,sticky=NS) self.buttonClear=Button(self.frameControlsBasic, text='Clear Keys',command=self.ClearKeySeq) self.buttonClear.grid(row=2,column=0,columnspan=4) labelTitleAdvanced = Label(self.frameKeySeqAdvanced,justify=LEFT, text="Enter new binding(s) for '"+self.action+"' :\n"+ "(These bindings will not be checked for validity!)") labelTitleAdvanced.pack(anchor=W) self.entryKeysAdvanced=Entry(self.frameKeySeqAdvanced, textvariable=self.keyString) self.entryKeysAdvanced.pack(fill=X) labelHelpAdvanced=Label(self.frameHelpAdvanced,justify=LEFT, text="Key bindings are specified using Tkinter keysyms as\n"+ "in these samples: <Control-f>, <Shift-F2>, <F12>,\n" "<Control-space>, <Meta-less>, <Control-Alt-Shift-X>.\n" "Upper case is used when the Shift modifier is present!\n\n" + "'Emacs style' multi-keystroke bindings are specified as\n" + "follows: <Control-x><Control-y>, where the first key\n" + "is the 'do-nothing' keybinding.\n\n" + "Multiple separate bindings for one action should be\n"+ "separated by a space, eg., <Alt-v> <Meta-v>." ) labelHelpAdvanced.grid(row=0,column=0,sticky=NSEW) def SetModifiersForPlatform(self): """Determine list of names of key modifiers for this platform. The names are used to build Tk bindings -- it doesn't matter if the keyboard has these keys, it matters if Tk understands them. The order is also important: key binding equality depends on it, so config-keys.def must use the same ordering. """ from idlelib import macosxSupport if macosxSupport.runningAsOSXApp(): self.modifiers = ['Shift', 'Control', 'Option', 'Command'] else: self.modifiers = ['Control', 'Alt', 'Shift'] self.modifier_label = {'Control': 'Ctrl'} # short name def ToggleLevel(self): if self.buttonLevel.cget('text')[:8]=='Advanced': self.ClearKeySeq() self.buttonLevel.config(text='<< Basic Key Binding Entry') self.frameKeySeqAdvanced.lift() self.frameHelpAdvanced.lift() self.entryKeysAdvanced.focus_set() self.advanced = True else: self.ClearKeySeq() self.buttonLevel.config(text='Advanced Key Binding Entry >>') self.frameKeySeqBasic.lift() self.frameControlsBasic.lift() self.advanced = False def FinalKeySelected(self,event): self.BuildKeyString() def BuildKeyString(self): keyList = modifiers = self.GetModifiers() finalKey = self.listKeysFinal.get(ANCHOR) if finalKey: finalKey = self.TranslateKey(finalKey, modifiers) keyList.append(finalKey) self.keyString.set('<' + string.join(keyList,'-') + '>') def GetModifiers(self): modList = [variable.get() for variable in self.modifier_vars] return [mod for mod in modList if mod] def ClearKeySeq(self): self.listKeysFinal.select_clear(0,END) self.listKeysFinal.yview(MOVETO, '0.0') for variable in self.modifier_vars: variable.set('') self.keyString.set('') def LoadFinalKeyList(self): #these tuples are also available for use in validity checks self.functionKeys=('F1','F2','F2','F4','F5','F6','F7','F8','F9', 'F10','F11','F12') self.alphanumKeys=tuple(string.ascii_lowercase+string.digits) self.punctuationKeys=tuple('~!@#%^&*()_-+={}[]|;:,.<>/?') self.whitespaceKeys=('Tab','Space','Return') self.editKeys=('BackSpace','Delete','Insert') self.moveKeys=('Home','End','Page Up','Page Down','Left Arrow', 'Right Arrow','Up Arrow','Down Arrow') #make a tuple of most of the useful common 'final' keys keys=(self.alphanumKeys+self.punctuationKeys+self.functionKeys+ self.whitespaceKeys+self.editKeys+self.moveKeys) self.listKeysFinal.insert(END, *keys) def TranslateKey(self, key, modifiers): "Translate from keycap symbol to the Tkinter keysym" translateDict = {'Space':'space', '~':'asciitilde','!':'exclam','@':'at','#':'numbersign', '%':'percent','^':'asciicircum','&':'ampersand','*':'asterisk', '(':'parenleft',')':'parenright','_':'underscore','-':'minus', '+':'plus','=':'equal','{':'braceleft','}':'braceright', '[':'bracketleft',']':'bracketright','|':'bar',';':'semicolon', ':':'colon',',':'comma','.':'period','<':'less','>':'greater', '/':'slash','?':'question','Page Up':'Prior','Page Down':'Next', 'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up', 'Down Arrow': 'Down', 'Tab':'Tab'} if key in translateDict.keys(): key = translateDict[key] if 'Shift' in modifiers and key in string.ascii_lowercase: key = key.upper() key = 'Key-' + key return key def OK(self, event=None): if self.advanced or self.KeysOK(): # doesn't check advanced string yet self.result=self.keyString.get() self.destroy() def Cancel(self, event=None): self.result='' self.destroy() def KeysOK(self): '''Validity check on user's 'basic' keybinding selection. Doesn't check the string produced by the advanced dialog because 'modifiers' isn't set. ''' keys = self.keyString.get() keys.strip() finalKey = self.listKeysFinal.get(ANCHOR) modifiers = self.GetModifiers() # create a key sequence list for overlap check: keySequence = keys.split() keysOK = False title = 'Key Sequence Error' if not keys: tkMessageBox.showerror(title=title, parent=self, message='No keys specified.') elif not keys.endswith('>'): tkMessageBox.showerror(title=title, parent=self, message='Missing the final Key') elif (not modifiers and finalKey not in self.functionKeys + self.moveKeys): tkMessageBox.showerror(title=title, parent=self, message='No modifier key(s) specified.') elif (modifiers == ['Shift']) \ and (finalKey not in self.functionKeys + self.moveKeys + ('Tab', 'Space')): msg = 'The shift modifier by itself may not be used with'\ ' this key symbol.' tkMessageBox.showerror(title=title, parent=self, message=msg) elif keySequence in self.currentKeySequences: msg = 'This key combination is already in use.' tkMessageBox.showerror(title=title, parent=self, message=msg) else: keysOK = True return keysOK if __name__ == '__main__': #test the dialog root=Tk() def run(): keySeq='' dlg=GetKeysDialog(root,'Get Keys','find-again',[]) print dlg.result Button(root,text='Dialog',command=run).pack() root.mainloop()
bsd-2-clause
[ 624, 199, 5619, 367, 10015, 16826, 1066, 27139, 790, 17792, 199, 624, 199, 504, 16826, 492, 627, 199, 646, 10157, 13695, 199, 646, 1059, 199, 199, 533, 2372, 6340, 5619, 8, 6105, 1896, 304, 272, 347, 636, 826, 721, 277, 12, 1708, 12, 1213, 12, 1287, 12, 1818, 1197, 1513, 6227, 304, 267, 408, 267, 1595, 446, 1059, 12, 314, 536, 402, 314, 5791, 1566, 3520, 2883, 911, 506, 326, 9994, 370, 267, 1453, 6340, 446, 769, 12, 282, 769, 402, 1006, 790, 3414, 5548, 5544, 9994, 326, 370, 5791, 4474, 12, 367, 15145, 7907, 267, 408, 267, 14132, 1896, 855, 826, 721, 277, 12, 1676, 9, 267, 291, 14, 6472, 8, 8665, 2063, 29, 21, 9, 267, 291, 14, 264, 5946, 461, 8, 3333, 29, 19823, 12, 2063, 29, 19823, 9, 267, 291, 14, 1213, 8, 1213, 9, 267, 291, 14, 23387, 8, 1708, 9, 267, 291, 14, 22090, 63, 409, 342, 267, 291, 14, 3922, 480, 13073, 63, 7014, 63, 15480, 401, 291, 14, 9083, 9, 267, 291, 14, 1708, 275, 1676, 267, 291, 14, 1287, 29, 1287, 267, 291, 14, 1818, 1197, 1513, 6227, 29, 1818, 1197, 1513, 6227, 267, 291, 14, 1099, 19070, 267, 291, 14, 498, 1558, 29, 1558, 5894, 8, 277, 9, 267, 291, 14, 498, 1558, 14, 409, 8355, 267, 291, 14, 1084, 7469, 6069, 1858, 10397, 342, 327, 663, 291, 14, 17431, 12, 291, 14, 18156, 63, 1302, 267, 291, 14, 18156, 63, 2936, 275, 942, 267, 367, 17880, 315, 291, 14, 17431, 26, 288, 1750, 275, 2624, 5894, 8, 277, 9, 288, 1750, 14, 409, 8355, 288, 291, 14, 18156, 63, 2936, 14, 740, 8, 1975, 9, 267, 291, 14, 14652, 275, 756, 267, 291, 14, 2499, 12462, 342, 267, 291, 14, 6200, 12776, 1197, 1296, 342, 267, 291, 14, 1045, 5485, 342, 327, 8191, 1830, 4260, 3400, 267, 291, 14, 873, 63, 12000, 5054, 342, 267, 291, 14, 7660, 480, 25389, 68, 25389, 68, 2, 450, 288, 3666, 1708, 14, 23562, 63, 1231, 88, 24543, 1332, 1708, 14, 23562, 63, 2063, 29728, 18, 9, 355, 24953, 277, 14, 23562, 63, 2103, 2063, 29728, 18, 1826, 1598, 1676, 14, 23562, 63, 1231, 89, 24543, 1332, 1708, 14, 23562, 63, 3333, 29728, 18, 9, 355, 24953, 277, 14, 23562, 63, 2103, 3333, 29728, 18, 430, 5082, 776, 327, 31748, 9592, 1806, 1676, 267, 291, 14, 271, 4677, 2021, 342, 327, 7660, 663, 12, 625, 8191, 267, 291, 14, 2573, 63, 3806, 342, 339, 347, 2790, 12462, 8, 277, 304, 267, 2787, 6756, 275, 11726, 8, 277, 12, 8665, 2063, 29, 18, 12, 26557, 2829, 29, 23627, 6945, 9, 267, 2787, 6756, 14, 1389, 8, 2441, 29, 11422, 12, 4441, 29, 15064, 12, 4498, 29, 28784, 9, 267, 2787, 24021, 29, 3160, 8, 277, 9, 267, 2787, 24021, 14, 1389, 8, 2441, 29, 27838, 12, 4498, 29, 56, 9, 267, 291, 14, 3887, 3593, 275, 16005, 8, 1943, 24021, 12, 505, 534, 3593, 297, 355, 3462, 29, 24, 12, 1531, 29, 277, 14, 3593, 9, 267, 291, 14, 3887, 3593, 14, 3825, 8, 1143, 29, 16, 12, 2301, 29, 16, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 291, 14, 3887, 9083, 275, 16005, 8, 1943, 24021, 12, 505, 534, 9083, 297, 355, 3462, 29, 24, 12, 1531, 29, 277, 14, 9083, 9, 267, 291, 14, 3887, 9083, 14, 3825, 8, 1143, 29, 16, 12, 2301, 29, 17, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 291, 14, 1943, 1197, 11205, 6845, 275, 11726, 8, 1943, 6756, 9, 267, 291, 14, 1943, 1197, 11205, 23613, 275, 11726, 8, 1943, 6756, 9, 267, 291, 14, 1943, 25457, 6845, 275, 11726, 8, 1943, 6756, 9, 267, 291, 14, 1943, 8673, 23613, 275, 11726, 8, 1943, 6756, 9, 267, 291, 14, 1943, 1197, 11205, 23613, 14, 3825, 8, 1143, 29, 16, 12, 2301, 29, 16, 12, 27364, 29, 46, 899, 55, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 291, 14, 1943, 1197, 11205, 6845, 14, 3825, 8, 1143, 29, 16, 12, 2301, 29, 16, 12, 27364, 29, 46, 899, 55, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 291, 14, 1943, 1197, 11205, 6845, 14, 30133, 342, 267, 291, 14, 1943, 8673, 23613, 14, 3825, 8, 1143, 29, 17, 12, 2301, 29, 16, 12, 27364, 29, 46, 899, 55, 12, 6226, 88, 29, 21, 9, 267, 291, 14, 1943, 25457, 6845, 14, 3825, 8, 1143, 29, 17, 12, 2301, 29, 16, 12, 27364, 29, 46, 899, 55, 12, 6226, 88, 29, 21, 9, 267, 291, 14, 1943, 25457, 6845, 14, 30133, 342, 267, 291, 14, 3887, 4670, 275, 16005, 8, 1943, 6756, 12, 1531, 29, 277, 14, 24743, 4670, 12, 355, 1318, 534, 23613, 2606, 22630, 316, 11855, 4331, 358, 267, 291, 14, 3887, 4670, 14, 3825, 8, 1143, 29, 18, 12, 2301, 29, 16, 12, 18043, 29, 37, 55, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 1768, 6888, 6845, 275, 10354, 8, 277, 14, 1943, 1197, 11205, 6845, 12, 355, 1318, 628, 4665, 2883, 367, 221, 5522, 11, 277, 14, 1287, 11, 4507, 520, 531, 267, 1768, 6888, 6845, 14, 1389, 8, 11498, 29, 55, 9, 267, 1768, 6340, 6845, 275, 10354, 8, 277, 14, 1943, 1197, 11205, 6845, 12, 4764, 2021, 29, 9894, 12, 355, 1318, 1975, 29, 277, 14, 498, 1558, 12, 26557, 2829, 29, 39, 1092, 47, 2524, 12, 8665, 2063, 29, 18, 9, 267, 1768, 6340, 6845, 14, 1389, 8, 711, 350, 88, 29, 21, 12, 711, 350, 89, 29, 21, 12, 4498, 29, 56, 9, 267, 291, 14, 18156, 63, 1074, 15687, 275, 1052, 267, 2763, 275, 378, 267, 367, 17880, 12, 1750, 315, 3482, 8, 277, 14, 17431, 12, 291, 14, 18156, 63, 2936, 304, 288, 1768, 275, 291, 14, 18156, 63, 1302, 14, 362, 8, 18156, 12, 17880, 9, 288, 1104, 29, 1799, 3887, 8, 277, 14, 1943, 25457, 6845, 12, 355, 1414, 29, 277, 14, 3425, 1197, 1558, 12, 355, 1318, 29, 1302, 12, 1975, 29, 1975, 12, 265, 585, 29, 18156, 12, 1997, 585, 13275, 288, 1104, 14 ]
[ 199, 5619, 367, 10015, 16826, 1066, 27139, 790, 17792, 199, 624, 199, 504, 16826, 492, 627, 199, 646, 10157, 13695, 199, 646, 1059, 199, 199, 533, 2372, 6340, 5619, 8, 6105, 1896, 304, 272, 347, 636, 826, 721, 277, 12, 1708, 12, 1213, 12, 1287, 12, 1818, 1197, 1513, 6227, 304, 267, 408, 267, 1595, 446, 1059, 12, 314, 536, 402, 314, 5791, 1566, 3520, 2883, 911, 506, 326, 9994, 370, 267, 1453, 6340, 446, 769, 12, 282, 769, 402, 1006, 790, 3414, 5548, 5544, 9994, 326, 370, 5791, 4474, 12, 367, 15145, 7907, 267, 408, 267, 14132, 1896, 855, 826, 721, 277, 12, 1676, 9, 267, 291, 14, 6472, 8, 8665, 2063, 29, 21, 9, 267, 291, 14, 264, 5946, 461, 8, 3333, 29, 19823, 12, 2063, 29, 19823, 9, 267, 291, 14, 1213, 8, 1213, 9, 267, 291, 14, 23387, 8, 1708, 9, 267, 291, 14, 22090, 63, 409, 342, 267, 291, 14, 3922, 480, 13073, 63, 7014, 63, 15480, 401, 291, 14, 9083, 9, 267, 291, 14, 1708, 275, 1676, 267, 291, 14, 1287, 29, 1287, 267, 291, 14, 1818, 1197, 1513, 6227, 29, 1818, 1197, 1513, 6227, 267, 291, 14, 1099, 19070, 267, 291, 14, 498, 1558, 29, 1558, 5894, 8, 277, 9, 267, 291, 14, 498, 1558, 14, 409, 8355, 267, 291, 14, 1084, 7469, 6069, 1858, 10397, 342, 327, 663, 291, 14, 17431, 12, 291, 14, 18156, 63, 1302, 267, 291, 14, 18156, 63, 2936, 275, 942, 267, 367, 17880, 315, 291, 14, 17431, 26, 288, 1750, 275, 2624, 5894, 8, 277, 9, 288, 1750, 14, 409, 8355, 288, 291, 14, 18156, 63, 2936, 14, 740, 8, 1975, 9, 267, 291, 14, 14652, 275, 756, 267, 291, 14, 2499, 12462, 342, 267, 291, 14, 6200, 12776, 1197, 1296, 342, 267, 291, 14, 1045, 5485, 342, 327, 8191, 1830, 4260, 3400, 267, 291, 14, 873, 63, 12000, 5054, 342, 267, 291, 14, 7660, 480, 25389, 68, 25389, 68, 2, 450, 288, 3666, 1708, 14, 23562, 63, 1231, 88, 24543, 1332, 1708, 14, 23562, 63, 2063, 29728, 18, 9, 355, 24953, 277, 14, 23562, 63, 2103, 2063, 29728, 18, 1826, 1598, 1676, 14, 23562, 63, 1231, 89, 24543, 1332, 1708, 14, 23562, 63, 3333, 29728, 18, 9, 355, 24953, 277, 14, 23562, 63, 2103, 3333, 29728, 18, 430, 5082, 776, 327, 31748, 9592, 1806, 1676, 267, 291, 14, 271, 4677, 2021, 342, 327, 7660, 663, 12, 625, 8191, 267, 291, 14, 2573, 63, 3806, 342, 339, 347, 2790, 12462, 8, 277, 304, 267, 2787, 6756, 275, 11726, 8, 277, 12, 8665, 2063, 29, 18, 12, 26557, 2829, 29, 23627, 6945, 9, 267, 2787, 6756, 14, 1389, 8, 2441, 29, 11422, 12, 4441, 29, 15064, 12, 4498, 29, 28784, 9, 267, 2787, 24021, 29, 3160, 8, 277, 9, 267, 2787, 24021, 14, 1389, 8, 2441, 29, 27838, 12, 4498, 29, 56, 9, 267, 291, 14, 3887, 3593, 275, 16005, 8, 1943, 24021, 12, 505, 534, 3593, 297, 355, 3462, 29, 24, 12, 1531, 29, 277, 14, 3593, 9, 267, 291, 14, 3887, 3593, 14, 3825, 8, 1143, 29, 16, 12, 2301, 29, 16, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 291, 14, 3887, 9083, 275, 16005, 8, 1943, 24021, 12, 505, 534, 9083, 297, 355, 3462, 29, 24, 12, 1531, 29, 277, 14, 9083, 9, 267, 291, 14, 3887, 9083, 14, 3825, 8, 1143, 29, 16, 12, 2301, 29, 17, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 291, 14, 1943, 1197, 11205, 6845, 275, 11726, 8, 1943, 6756, 9, 267, 291, 14, 1943, 1197, 11205, 23613, 275, 11726, 8, 1943, 6756, 9, 267, 291, 14, 1943, 25457, 6845, 275, 11726, 8, 1943, 6756, 9, 267, 291, 14, 1943, 8673, 23613, 275, 11726, 8, 1943, 6756, 9, 267, 291, 14, 1943, 1197, 11205, 23613, 14, 3825, 8, 1143, 29, 16, 12, 2301, 29, 16, 12, 27364, 29, 46, 899, 55, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 291, 14, 1943, 1197, 11205, 6845, 14, 3825, 8, 1143, 29, 16, 12, 2301, 29, 16, 12, 27364, 29, 46, 899, 55, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 291, 14, 1943, 1197, 11205, 6845, 14, 30133, 342, 267, 291, 14, 1943, 8673, 23613, 14, 3825, 8, 1143, 29, 17, 12, 2301, 29, 16, 12, 27364, 29, 46, 899, 55, 12, 6226, 88, 29, 21, 9, 267, 291, 14, 1943, 25457, 6845, 14, 3825, 8, 1143, 29, 17, 12, 2301, 29, 16, 12, 27364, 29, 46, 899, 55, 12, 6226, 88, 29, 21, 9, 267, 291, 14, 1943, 25457, 6845, 14, 30133, 342, 267, 291, 14, 3887, 4670, 275, 16005, 8, 1943, 6756, 12, 1531, 29, 277, 14, 24743, 4670, 12, 355, 1318, 534, 23613, 2606, 22630, 316, 11855, 4331, 358, 267, 291, 14, 3887, 4670, 14, 3825, 8, 1143, 29, 18, 12, 2301, 29, 16, 12, 18043, 29, 37, 55, 12, 6226, 88, 29, 21, 12, 6226, 89, 29, 21, 9, 267, 1768, 6888, 6845, 275, 10354, 8, 277, 14, 1943, 1197, 11205, 6845, 12, 355, 1318, 628, 4665, 2883, 367, 221, 5522, 11, 277, 14, 1287, 11, 4507, 520, 531, 267, 1768, 6888, 6845, 14, 1389, 8, 11498, 29, 55, 9, 267, 1768, 6340, 6845, 275, 10354, 8, 277, 14, 1943, 1197, 11205, 6845, 12, 4764, 2021, 29, 9894, 12, 355, 1318, 1975, 29, 277, 14, 498, 1558, 12, 26557, 2829, 29, 39, 1092, 47, 2524, 12, 8665, 2063, 29, 18, 9, 267, 1768, 6340, 6845, 14, 1389, 8, 711, 350, 88, 29, 21, 12, 711, 350, 89, 29, 21, 12, 4498, 29, 56, 9, 267, 291, 14, 18156, 63, 1074, 15687, 275, 1052, 267, 2763, 275, 378, 267, 367, 17880, 12, 1750, 315, 3482, 8, 277, 14, 17431, 12, 291, 14, 18156, 63, 2936, 304, 288, 1768, 275, 291, 14, 18156, 63, 1302, 14, 362, 8, 18156, 12, 17880, 9, 288, 1104, 29, 1799, 3887, 8, 277, 14, 1943, 25457, 6845, 12, 355, 1414, 29, 277, 14, 3425, 1197, 1558, 12, 355, 1318, 29, 1302, 12, 1975, 29, 1975, 12, 265, 585, 29, 18156, 12, 1997, 585, 13275, 288, 1104, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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imageviewer/imageviewer_rc.py
1
33804
############################################################################### ## ## Copyright (C) 2006-2011, University of Utah. ## All rights reserved. ## Contact: contact@vistrails.org ## ## This file is part of VisTrails. ## ## "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 the University of Utah 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 HOLDER 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." ## ############################################################################### # Resource object code # # Created: Thu Sep 21 00:22:30 2006 # by: The Resource Compiler for PyQt (Qt v4.1.3) # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore qt_resource_data = "\ \x00\x00\x07\xc2\ \x89\ \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ \x00\x00\x20\x00\x00\x00\x20\x08\x06\x00\x00\x00\x73\x7a\x7a\xf4\ \x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\ \x01\x00\x9a\x9c\x18\x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xd8\ \xeb\xf5\x1c\x14\xaa\x00\x00\x00\x20\x63\x48\x52\x4d\x00\x00\x6e\ \x27\x00\x00\x73\xaf\x00\x00\xf6\x37\x00\x00\x80\xa5\x00\x00\x70\ \x23\x00\x00\xdd\x02\x00\x00\x30\x3e\x00\x00\x16\xb2\xce\x5d\x77\ \x0a\x00\x00\x07\x38\x49\x44\x41\x54\x78\xda\x62\x64\x20\x12\x18\ \xcd\x7d\x64\x00\xa4\x02\x80\xd8\x1e\x88\x1d\xfe\xff\xff\xcf\xf0\ \xe7\xcf\x7f\x86\x7f\x7f\x81\xf8\xdf\x7f\x86\xbf\x7f\xc1\xec\x03\ \x7f\xfe\xfe\x3b\x08\x64\x6f\x78\x5c\xa9\x7e\x81\x18\x73\x01\x02\ \x88\x91\x08\x8b\x13\x80\x54\xbe\x00\x07\x8b\x81\x9a\x28\x07\x83\ \x8a\x30\x07\x83\x08\x17\x0b\x03\x23\x23\x23\xc3\x1f\xa0\xc5\x40\ \xc4\xf0\xe3\xf7\x3f\x86\xaf\xbf\xfe\x32\xbc\xf8\xf4\x8b\xe1\xf6\ \xcb\xef\x0c\x77\x5f\x7e\x63\xf8\xf8\xf5\xf7\x85\xbf\x7f\xfe\x4d\ \x7c\xd5\xa8\xbd\x00\x9f\xf9\x00\x01\xc4\x88\xc7\x62\x05\x20\x35\ \x5f\x82\x97\xd5\xc1\x53\x5d\x90\x41\x86\x8f\x0d\x68\x29\x44\x8e\ \x99\x89\x91\x01\x5d\xe3\x3f\x60\x88\x7c\xf9\xf9\x8f\xe1\xe3\xcf\ \xbf\x0c\x2f\x3f\xff\x62\xb8\xff\xfa\x07\xc3\xf1\x1b\xef\x19\xde\ \x7c\xfc\x75\xe0\xcf\x9f\x7f\x89\x9f\xba\xf4\x1e\x60\xb3\x07\x20\ \x80\x18\x71\x58\x1e\xc0\xc9\xca\xb4\xc0\x41\x89\x8f\xdf\x52\x8e\ \x97\x01\x68\x36\xdc\x72\x62\xc1\x8b\xcf\xbf\x19\xae\xbf\xfe\xce\ \x70\xfe\xee\x27\x86\x8b\x77\x3e\x7e\xfc\xf1\xf3\x6f\xc2\xd7\x3e\ \xfd\x0d\xe8\xea\x00\x02\x88\x11\x5b\x90\x73\xb0\x30\xcd\x4f\x32\ \x11\x63\x00\xfa\x1e\xc3\xe0\x1f\x7f\xfe\x81\x83\xfc\x3b\x30\xfe\ \x7f\xfd\xfd\x07\x16\xfb\x0d\x8c\x7f\x76\x66\x46\x06\x6e\x76\x66\ \x06\x21\x4e\x16\xb8\xda\xdf\xc0\xf8\x39\xf7\xf4\x2b\xc3\xe5\x27\ \x5f\x18\xf6\x9e\x7a\xc5\xf0\xf3\xe7\xbf\xc4\x5f\x53\x0c\x51\xa2\ \x04\x20\x80\x18\xd1\x7d\x0e\xb4\x7c\x3d\x36\xcb\xbf\x01\x2d\xfd\ \x0c\x0c\xde\x07\xef\x7e\x30\xdc\x04\xc6\xf3\xcb\x8f\xbf\x18\xbe\ \xfd\xfc\xc3\xc0\xc2\xc4\xc4\xf0\x17\x68\x91\x00\x27\x33\x83\x08\ \x2f\x1b\x83\x2c\x30\x9d\x48\x01\xa3\x4b\x59\x88\x03\xae\xf7\xd6\ \x9b\x1f\x0c\xbb\xae\xbd\x63\x38\x70\xf2\x35\xc3\x8f\x9f\x7f\x02\ \x19\x66\x99\xc0\x43\x02\x20\x80\x18\x91\xe3\x1c\x18\xec\x17\x12\ \x8d\xc5\xf8\x91\x2d\x07\x19\xfe\x19\x18\xb7\x57\x81\x09\x6b\xdf\ \xcd\xf7\x0c\x1f\xbe\xfd\xb9\x00\x4c\xe5\x1b\x81\x29\xff\x00\x28\ \xf5\x83\x72\xc2\x7f\x70\x2e\xf8\xe7\xf0\xf7\xcf\x7f\x7f\x4e\x36\ \x66\x03\x03\x25\x3e\x06\x55\x69\x6e\x06\x43\x29\x6e\x06\x01\x0e\ \x66\xb0\x39\x57\x81\x8e\xde\x76\xe5\x2d\xc3\xb1\x33\xaf\x3f\xfe\ \xfb\xf1\xdd\xe0\xef\x5c\x6b\x70\x9a\x00\x08\x20\x16\x24\x4f\xce\ \x07\xc5\x39\xba\xe5\xaf\xbe\xfc\x66\xd8\x73\xeb\x23\xc3\xa5\xa7\ \x5f\x2e\x00\x2d\x2c\xbc\x99\xaf\x7c\x00\x47\xb4\x83\xc4\x1b\x04\ \x2a\x2e\x3b\xec\x3f\xff\xa6\xff\xee\xb3\xaf\x06\x2f\xd5\x05\x18\ \xdc\x81\x58\x10\x18\x2d\xda\xe2\x9c\x0c\x0f\x3f\x70\x33\xbc\x78\ \xfd\x95\xff\xee\x8d\xaf\xf3\x81\x6a\x1d\x41\x9a\x00\x02\x88\x19\ \x16\xef\x40\x8b\x0b\x82\xb4\x85\x31\x2c\x5f\x76\xf6\x35\xc3\xdd\ \x37\xdf\x17\x00\x2d\x8f\x04\x5a\x7e\x83\x50\xe2\xfb\x71\x64\xfa\ \x03\x56\x8b\x8c\x95\x6f\x3f\xfe\x94\x78\xfc\xea\xbb\xc1\x0f\x16\ \x26\x06\x59\x41\x76\x06\x2e\x56\x26\x06\x39\x01\x76\x86\xbb\x5f\ \xff\x32\xbc\x79\xfe\x41\x81\x51\x3d\xe2\xe1\x9f\x4b\x8b\x2f\x00\ \x04\x10\x2c\x04\xf2\x41\x59\x0d\x39\xb5\x83\x82\x1d\xe4\x73\x60\ \xde\x5e\x70\x3d\x57\x29\x91\x94\x1c\x00\x4c\xed\x1f\x80\x54\xe2\ \xef\xcc\x73\x0c\x27\x2f\xbf\x4b\xe0\x64\x67\x62\x08\xd7\x13\x61\ \x60\x07\x3a\xc6\x41\x91\x8f\xe1\xc9\x33\x61\x86\x87\xa7\xdf\xe7\ \x03\xd5\x2c\x00\x08\x20\x26\x50\x09\x07\x2a\x64\x90\xf3\x39\x28\ \xc1\x81\xe2\x1c\x14\xec\xa4\x5a\x8e\x0c\xfe\x4e\x37\x4a\x7c\xfc\ \xec\xcb\x85\x4b\xf7\x3e\x32\x1c\x7f\xf4\x19\x2c\xa6\x2b\xc1\xc5\ \x20\x20\xcc\xc3\xc0\xce\xc6\x64\x20\x18\xba\xca\x00\x20\x80\x98\ \x40\xc5\x2b\xa8\x84\x43\xce\xe7\xa0\xd4\x0e\x4a\x70\xa0\x38\x67\ \xa0\x10\x30\xff\xfd\x55\x78\xf7\xc6\x2b\x86\x13\x8f\xbf\xc0\xc5\ \x40\x8e\xe0\x04\x3a\x82\xf1\xff\xdf\x00\x80\x00\x02\x39\xc0\x1e\ \x54\xbc\x22\xe7\xf3\x9b\xaf\xbe\x83\x53\x3b\x9e\x04\x47\x7c\x28\ \xcc\xb5\x3e\xf0\xfb\xeb\x8f\x0b\x2f\x5e\x7c\x62\xb8\x01\x2c\x98\ \x40\x40\x01\x98\x26\x58\x84\xf9\x19\x98\xfe\xfd\xb6\x07\x08\x20\ \x50\x1a\x70\x00\x95\xed\xa0\xe2\x15\xec\x00\x60\xf0\x3f\x78\xfb\ \x03\x54\xb9\x6c\xc4\x69\xea\x4c\x06\x01\x20\xb9\x9e\x8b\x91\xcd\ \xe1\xff\x4f\x06\x86\xef\x9f\x7f\x1d\x60\xf8\xc5\x10\xc8\xd0\xc0\ \xf0\x01\x47\x28\x6c\xfc\xf4\xe2\x83\xc1\xdd\xb7\x62\x0c\x1a\xa2\ \x9c\xe0\x32\xe2\x3f\x17\x27\x03\xcb\x9f\x5f\x0e\x00\x01\xc4\x04\ \xaa\xd5\x40\x15\x0b\x2c\x06\x40\x25\x1c\xa8\x90\x01\xe5\x73\x3c\ \x1e\x5b\xef\x6b\x64\xec\xd0\x16\x13\xce\x50\x12\xe0\xc2\x60\xaa\ \x2c\xe3\xc0\xf0\x9b\x61\x3d\x2e\xc5\x2c\x7f\x7e\x1e\xf8\xf9\xf1\ \x0b\xc3\x23\xa0\xb9\x20\x00\x2c\x6f\x18\xfe\x30\x32\x03\x43\xe0\ \x0f\x03\x40\x00\x31\x81\x0a\x12\x50\x51\x0a\x03\xa0\x1a\xee\xef\ \xbf\x7f\xe0\x2a\x16\x17\x00\xf9\xdc\x59\x5b\x8b\xe1\xed\xdb\xb7\ \x0c\x6f\x80\x58\x42\x8c\x0b\xe8\x4b\x26\x07\x5c\xea\x99\xfe\xff\ \x65\x60\x04\x5a\xf6\x17\xc9\x4c\x36\x60\xd1\xcd\xfc\xef\x37\x03\ \x40\x00\x31\x81\xea\x73\x58\xb5\x0a\xa9\xd1\xfe\x32\x3c\x7e\xfb\ \x13\x54\xc2\x3d\xc0\x65\x20\x28\xd8\x61\x96\x3f\x79\xff\x9e\xe1\ \x2e\x10\xff\xff\x89\xdb\xc1\x20\xcb\x19\x40\x0e\xf8\x8f\x50\xf3\ \x01\x68\x0f\xd3\xdf\x3f\x0c\x00\x01\xc4\x04\x8c\xeb\x03\xdb\xaf\ \xbe\x63\xb8\x0b\x8c\xf7\x9b\xc0\x2a\xf4\xc4\xbd\x4f\xa0\xf8\x3f\ \xf0\xa4\x4a\x1d\xa7\x03\x40\x71\xbe\x7a\xcf\x69\xb8\xe5\xb7\xaf\ \xbf\x65\xf8\xf7\x0d\x77\x94\x31\xff\x05\xba\xf8\xdf\x5f\x06\x68\ \xdd\x05\x09\x69\xa0\xc7\x99\xfe\xfd\x62\x00\x08\x20\x16\x60\x1a\ \x08\xbc\xfa\xf4\xeb\xfa\x4b\x8f\x3f\x3b\x00\x43\x1e\x6c\x39\x50\ \x3e\x10\x6f\xd2\x06\x26\xb8\x1b\x77\x5e\xaf\xbf\x71\xf5\xb5\x03\ \xc3\x4f\x30\xff\x00\xc3\x7f\xdc\x7a\x80\x51\xe0\xc0\xc4\xc9\xc1\ \x20\x0d\x2c\x6b\xc0\x05\xd5\xaf\x7f\x0c\x7f\x7f\xfd\x04\xa7\x01\ \x80\x00\x62\xb9\x91\xa7\xf4\x01\x56\x2e\x83\x83\x8b\x98\x8a\x1f\ \x92\xda\xe1\x7a\x40\x09\x99\x23\x61\xdf\x7a\xe6\x98\x3f\x0f\xbe\ \x2d\x71\xc7\x28\x3b\x80\x41\xed\xff\x57\x58\x90\x41\x55\x04\x92\ \xdd\xaf\xbe\xfa\xc6\xc0\xfc\xf1\x03\xc8\x01\x07\x00\x02\x88\x09\ \x9c\x03\x90\x30\xb9\x00\x68\x58\x80\xa0\x04\x4f\x01\x7f\xf8\x86\ \xf9\xc8\xe2\x12\x7e\x73\x1c\x18\xd9\x58\x0c\xd8\x44\x84\x19\x8c\ \x80\xb5\x23\x08\x5c\x7a\xfe\x8d\x81\xe3\xe5\x13\x60\x22\xfc\x73\ \x10\x20\x80\x98\x18\xa8\x04\x58\xfe\xfe\x66\x10\x56\x97\x61\xe0\ \x16\xe7\x4b\x10\x0e\x5e\x36\x1f\x6a\xb9\x00\xb0\xb0\xe9\xff\xad\ \xac\xc2\xe0\xaa\x22\x00\x57\xbb\xfb\xce\x47\x06\xbe\x97\x0f\x80\ \x89\xf3\xef\x06\x80\x00\x62\xa1\x96\x03\x40\x29\xfa\x17\x30\x61\ \x09\xeb\x2a\x33\xbc\xf9\xf3\x3b\x41\xc2\x6f\x2e\x38\xf1\xfd\x11\ \x97\x30\x90\x50\x91\x65\x08\xd6\x11\x02\xab\xdb\x0b\xb4\xfc\xff\ \xcb\x67\x0c\xec\x5f\x3f\x5d\xb8\x76\xa4\xfd\x02\x40\x00\x51\xcf\ \x01\xc0\x14\x0d\xca\xce\x05\x36\x92\x0c\xbd\xa0\xd6\xd3\xef\x9f\ \x09\xff\x3f\xbe\x63\x60\xd4\xd4\x64\xc8\x34\x17\x87\x27\xbe\x59\ \xa7\x5f\x31\x48\x5c\x3f\x05\x2a\x86\x27\x82\xc4\x00\x02\x88\x8a\ \x0e\xf8\x03\x76\x00\xa8\x56\x2d\x04\x3a\xa2\x15\x58\xa7\xfc\xfd\ \xf9\x8b\xa1\xd6\x5d\x91\x41\x1e\xd8\x0e\x00\x81\xfe\xa3\xcf\x19\ \xd8\x6f\x5f\x66\xe0\xfa\xf8\xea\xc0\x95\x63\x3d\xe0\xb6\x21\x40\ \x00\x51\xd5\x01\xb0\x12\x15\xd4\xf0\xa8\x72\x90\x06\xb3\x61\x96\ \x6f\xbc\xf6\x9e\xe1\xc2\xd5\x87\x0c\x8a\xb7\xcf\x7d\x04\xb5\x15\ \x60\xfa\x00\x02\x88\x6a\x0e\x00\x56\x38\xe0\x10\x80\x01\x98\xc5\ \xb0\x78\x5f\xbc\xef\x3a\x83\xe2\xc9\xad\x0c\xac\x3f\xbf\x27\x5c\ \x3a\xd1\x0f\x2f\xe4\x00\x02\x88\x89\x9a\x21\xf0\x0b\x4b\xfd\x01\ \x8b\x77\xc1\x27\xb7\x18\xd8\x7e\x7c\xbd\x00\xb4\x1c\xa5\x6f\x00\ \x10\x40\x54\x73\x00\xa8\x62\xf9\xf3\x17\xd3\x01\xdc\x6c\x4c\x0c\ \xed\xee\x72\x0c\x9f\xf4\xad\x19\x3e\x48\x2b\x1b\x18\x1b\xa7\xa1\ \x94\x13\x00\x01\xc4\x44\xcd\x6c\xf8\xfb\xdf\x3f\xac\x72\x4a\x42\ \xec\x60\x47\xbc\x31\xf7\x60\x78\x2b\xa7\x9d\x80\xec\x08\x80\x00\ \xa2\x72\x36\x64\x60\xf0\x59\x88\xbf\xe1\xfc\xd5\xc8\x0d\x44\x25\ \x18\x33\xa4\x7d\x38\x7b\x76\x56\x21\x40\x00\x51\x33\x17\x7c\x50\ \xdc\xbd\x52\x00\x94\x18\x81\x75\x3c\x38\x4d\x80\xd8\xcc\xc0\x12\ \x12\xd8\xf6\xc3\xa6\x05\xd4\xf9\x65\x00\x08\x30\x00\x8e\xdc\x6f\ \x30\x01\x62\x8c\x52\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\ \x82\ \x00\x00\x05\xd9\ \x89\ \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ \x00\x00\x30\x00\x00\x00\x30\x08\x02\x00\x00\x00\xd8\x60\x6e\xd0\ \x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\x05\ \x00\x00\x05\x90\x49\x44\x41\x54\x58\x47\xed\x56\x7d\x4c\xd4\x75\ \x1c\xa6\x94\x3f\x32\x47\x1a\x4e\x4a\x32\x88\x64\x82\x7c\x81\xe3\ \xee\x38\xee\x80\xe3\x0e\x0e\x8f\x97\x83\x3b\x5e\x94\x40\x10\xce\ \x93\xb7\xe3\x55\xde\x04\x81\x9b\x63\xa4\x4b\xdc\xc8\x55\x86\x2d\ \x59\x2d\x57\xda\xab\xad\x74\xa1\x63\xad\x5a\xfd\xa1\x36\x01\x11\ \x08\x45\x79\x55\x40\x42\xe2\x25\x94\xca\xe8\xa1\x5b\x74\xdf\xe3\ \xb8\x37\x91\x58\xe3\xf6\x19\xe3\xf7\xbc\x7d\x1e\x3e\xfc\xfe\xb8\ \xc7\xa6\xa7\xa7\x2d\x96\xd4\x07\x85\x96\xd4\xc7\x62\x49\xb5\x99\ \xf9\x77\x2d\x17\x32\x70\x81\xff\xd7\x85\x46\xef\x8d\x56\x7e\x55\ \xa9\xf9\x27\xe3\x11\xe0\xc3\xbc\x06\x0f\x75\xa1\x8a\xb3\x15\x1b\ \xf6\x6d\xd0\x5c\x8f\x47\x80\xff\x4d\xa1\x81\xb1\x01\xab\x7c\xab\ \x4d\xfb\x37\x69\xae\xc7\x23\x40\x50\x66\x77\x32\xff\x42\xaa\x2f\ \x55\x16\x69\x16\x2e\x95\x2e\x9a\xbb\xf1\x08\x10\xd4\x62\x17\x6a\ \xea\x6b\x5a\x53\xf8\x94\xed\xcb\x4f\x93\x4a\xa2\xb9\x1b\x8f\x00\ \x41\x41\x60\x5e\x27\x33\x2f\x24\xaf\x95\x3b\x54\xd9\xc8\xea\x38\ \x44\x45\x17\x52\x11\x80\xa0\x20\x58\xbc\x42\x17\x3b\x2f\x3e\x91\ \xbe\x2a\xb5\x51\x1c\xfb\xad\x2f\x29\xa3\x0b\x95\x11\x80\xa0\x20\ \x80\xcc\x8c\x4e\x26\x5f\xe8\xc1\x9f\x0f\xf8\x07\xf8\xce\x47\xec\ \xde\x9a\x4e\x97\xd5\x71\x49\x29\x5d\xa8\x14\x17\xe2\x82\x82\x00\ \x32\x88\x4d\xed\x64\x72\xa1\x73\x57\xcf\x5b\xec\x5a\x91\xdc\x20\ \x3e\x36\x9d\x2e\x39\xcb\x21\x25\x74\xa1\x12\x02\x10\x14\x04\x90\ \x41\xfc\x68\x0b\x8d\xdd\x1b\x63\xab\x38\x8c\x1a\xc7\x57\xa6\x12\ \xab\xa7\x15\x21\x67\x38\xa4\xd8\x8d\x7a\xa9\x8b\xdd\x00\x82\x82\ \x00\x32\x88\x61\x31\xa9\x93\x69\x17\x3a\x5a\x5f\x63\x99\xf6\x64\ \xce\x4d\xe9\xc1\xa9\x9d\x87\xfe\x48\x0a\xfe\x82\x43\xf6\xba\x53\ \x85\xf6\xba\x03\x04\x05\x01\x64\x10\xc3\xf2\xa8\x0a\xdd\x9d\x18\ \x71\xc8\x71\xe4\xbc\xe3\x52\x79\x3f\x5e\x35\x1a\x7b\xe0\xb7\x9d\ \xe2\xcf\x3d\x49\x11\x83\x2a\x54\xc4\x00\x08\x0a\x02\xc8\x20\x86\ \x05\x46\xe3\x3b\x99\x70\xa1\xe2\x53\x65\x56\xb9\xd6\x7b\x7a\x23\ \xca\xc7\x62\xf7\x8d\xc4\x54\xdc\x8f\x0f\x3c\xcd\x26\x85\x1e\x54\ \xa1\x42\x0f\x80\xa0\x20\x80\x0c\x62\x58\x60\x5c\xf8\x42\x5d\x43\ \xdd\x6b\xe5\xcf\x08\x3e\x61\x95\x4f\xc6\x16\x0d\x6f\xc3\x94\x4f\ \xc6\xf9\x7f\xca\x22\x05\x2c\xaa\x50\x01\x0b\x20\xa8\x7f\x34\xb1\ \xb0\xc0\x08\xbb\x91\x9d\x8c\xbd\x90\xf2\x78\xee\xda\x7c\x9b\xcc\ \x3e\x59\xc1\xdd\xe8\xbc\xa1\x28\x4c\xc9\x44\x8c\xe0\x63\x16\xc9\ \xa7\x0b\xe5\xb3\x00\x82\x52\x6b\x20\x86\x05\x46\xd8\x17\xb2\xd0\ \x85\x8e\x1f\x57\xc6\xad\x09\x3e\xe7\x5d\x38\xba\x2d\x7b\x30\x22\ \xfb\x4e\x24\xa6\x70\x7c\x3b\xff\x23\x16\xc9\x63\x53\x17\xca\x63\ \x03\x04\xa5\xd6\x40\x0c\x0b\x8c\xb0\x23\xc4\x98\x4e\x46\x5d\x28\ \xb2\x6a\x87\x4d\xc9\x46\xe5\x80\x34\x73\x50\xa6\xec\x97\x29\x07\ \x66\x66\xcf\x68\xb4\xf7\x29\x16\xc9\xe5\x50\x85\x72\x39\x00\x41\ \xa9\x35\x10\xcf\x58\x06\xa4\xb0\x23\x64\x61\x0a\xd5\x35\xd6\x5b\ \xc6\xad\x0b\xf9\xda\x37\xe3\x67\x59\xea\xad\xb0\xd4\xdb\xe1\xea\ \xc9\x1a\x89\xe4\x9d\x64\x92\x1c\x2e\x55\x28\x87\x0b\x10\xd4\xac\ \x0c\x16\x18\x61\x47\x08\xa2\x0c\x76\x32\x70\xa1\xa9\xdf\xa7\xd8\ \x05\x42\xfb\x83\x8e\xa9\x83\x61\x8a\x3e\x89\xa2\x57\x32\xf3\xf3\ \xef\x49\x1f\x96\x7a\xbd\xcf\x24\xd9\x74\xa1\x6c\x2e\x40\x50\xb3\ \x32\xb5\x05\x76\x84\x20\x0a\x81\xfa\x3b\x19\x28\xf4\xe1\x0f\xa7\ \x1f\x8f\xb1\x0e\xfd\x9e\xaf\x18\x90\x24\x76\x07\x27\xf6\x84\xcc\ \x4e\xf2\x90\x84\x7d\xc2\x83\x64\xf3\xa8\x0b\x65\xf3\x00\x82\xd2\ \x54\xc2\x08\x3b\x42\x10\x85\x40\xf3\x0b\x8d\x4c\xfc\xe2\xa4\xf4\ \x72\xac\x76\x4e\xbc\x1d\xb2\xa3\x2b\x48\x6b\xe4\x83\xa1\xcc\xf7\ \x18\x24\xcb\x9b\x2a\x94\xe5\x0d\x10\xd4\x5c\x3d\x42\x10\x85\x40\ \xc4\xea\xe9\xa4\xef\x42\xfb\x4f\x56\x59\xc6\x3f\x1b\xde\x20\x8c\ \xeb\x11\xc7\xdc\x08\x8c\xb9\xb9\x55\x73\x12\xfa\x83\xdd\xdf\x65\ \x90\x0c\x5f\xaa\x50\x86\x2f\x40\x50\x5a\x62\xd8\x11\x82\x28\x04\ \x22\xd6\x9c\x42\x57\xba\x5a\x57\x47\xdb\x3b\xbd\xe9\x1a\xd3\xb3\ \x35\xaa\x23\x20\xaa\x43\xa4\x35\x2f\xdd\x12\xbb\xd5\x32\x88\x92\ \x4f\x15\x52\xf2\x01\x82\x9a\xab\x47\x08\xa2\x10\x88\x58\x84\xcf\ \xd7\x69\xde\x0b\xed\x7a\x35\x77\x75\x8a\x5d\x58\xab\x30\xa2\xc3\ \x5f\xda\x2e\x94\x5e\xf3\xd7\x9a\xe8\x5e\x11\x39\xee\x4e\xd2\xfd\ \xa8\x42\xe9\x7e\x00\x41\xcd\xd5\x23\x04\x51\x08\x44\x2c\xc2\x4d\ \x2b\x74\xe9\x7a\xe3\xaa\x08\x7b\xc6\x07\x1e\xd2\x4e\xff\xd0\x36\ \xbf\xd0\x9f\x04\x73\x47\xd6\x2d\x74\x7e\xdb\x8d\xa4\x09\xa9\x42\ \x69\x33\x20\x28\x9d\x16\x44\x21\x10\xb1\x08\xc7\x0a\x9d\x9d\x74\ \x5c\x08\x5f\xf3\x04\x85\x51\xeb\x8a\x1c\x43\xda\xfd\x82\xda\xf8\ \xe2\x16\xbe\xb8\x55\xc7\x48\x3a\x05\x9b\x8f\xb9\x92\x54\xba\x50\ \xaa\x10\x20\x28\x9d\x16\x44\x21\x10\xb1\x08\xc7\x0a\x9d\xdf\x27\ \x75\x14\x3a\x7f\xf9\x3b\x8b\x60\x5b\xc6\x67\x4c\xf1\x75\x5f\x51\ \xb3\xb7\xe8\xaa\x8f\xce\x09\xba\xc1\x77\xac\x71\x25\x29\x01\xd4\ \x85\x52\x02\x00\x82\x9a\xcf\x85\x40\xc4\x22\x1c\x2b\xb0\x68\xee\ \x91\xb4\x0b\x8d\x4d\x8e\x7b\x66\x4a\xd6\x97\x6e\x16\xb6\xf0\x04\ \x57\x78\x82\x26\xee\x7c\x23\xba\xe6\xf3\xe2\x51\x57\x92\x2c\xa2\ \x0a\x25\x8b\x00\x82\xd2\x63\x44\x2c\xc2\xb1\x02\x8b\xb0\x4e\xab\ \x93\x76\xa1\x9a\x33\x27\x56\x84\xdb\x31\xeb\xd9\xfc\x16\xae\x4f\ \x83\x97\x4f\xe3\xbc\x23\x68\xe7\xbd\xf0\x06\x21\xbb\x03\xa9\x42\ \xbb\x03\x01\x82\xd2\x63\x44\x2c\xc2\xb1\x02\x8b\xb0\x4e\x5f\xa1\ \xf1\xc9\x5f\x5d\xe4\x81\xeb\x55\x4e\xbc\x66\x8e\x57\x83\xa7\xd7\ \x65\x7d\xe3\xd3\xc6\x79\xfe\x35\x42\x14\x62\xaa\x90\x42\x0c\x10\ \x94\x7e\x2f\xc2\xb1\x02\x8b\xb0\x0e\x4b\x35\x13\xa8\x0b\x95\xd6\ \x1e\x5e\xb9\xdd\xc1\xf5\x1b\x06\xab\x81\xe9\x71\xc9\x43\xff\xb0\ \x9b\x99\xcf\x1d\xd9\x42\xe4\x74\x21\xb9\x18\x20\x28\x83\x76\xac\ \xc0\x22\xac\xc3\x52\xdd\x85\xfa\x87\xef\x58\x4b\xdc\x6d\x0e\x6d\ \x61\x35\x79\x32\x2e\xb0\x0d\x0e\x64\xb6\xd5\x84\x24\x05\x51\x17\ \x4a\x0a\x02\x68\x7c\x02\xd6\x61\x29\x56\xcf\x86\xfc\x7b\xa1\xbc\ \xd7\x2b\x36\x26\xfa\x7a\x46\x45\xe9\x1c\x56\x64\x24\x09\x0f\x57\ \x8f\xe6\xef\x24\x81\x7e\xa9\x13\x44\x3a\x65\xb0\xcc\x97\x8c\xa5\ \x58\xad\xa3\x90\xc1\x6f\x2a\x8b\x23\x30\xea\x1b\xe3\xe2\x54\x51\ \x6f\x59\x2e\x64\xe8\xda\xcb\x17\x5a\xbe\x90\xa1\x0b\x18\xe2\x97\ \xdc\x3b\xf4\x17\xad\xc1\xc2\xaa\xe0\x57\x31\x22\x00\x00\x00\x00\ \x49\x45\x4e\x44\xae\x42\x60\x82\ \x00\x00\x09\x89\ \x89\ \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ \x00\x00\x30\x00\x00\x00\x30\x08\x06\x00\x00\x00\x57\x02\xf9\x87\ \x00\x00\x00\x2b\x74\x45\x58\x74\x43\x72\x65\x61\x74\x69\x6f\x6e\ \x20\x54\x69\x6d\x65\x00\x46\x72\x20\x31\x36\x20\x4d\x61\x69\x20\ \x32\x30\x30\x33\x20\x31\x32\x3a\x31\x31\x3a\x33\x32\x20\x2b\x30\ \x31\x30\x30\x47\xeb\x88\x5e\x00\x00\x00\x07\x74\x49\x4d\x45\x07\ \xd3\x0a\x06\x14\x18\x07\x30\xf5\x85\x0a\x00\x00\x00\x09\x70\x48\ \x59\x73\x00\x00\x0a\xf0\x00\x00\x0a\xf0\x01\x42\xac\x34\x98\x00\ \x00\x00\x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\x05\x00\ \x00\x08\xe1\x49\x44\x41\x54\x78\xda\xcd\x5a\x5d\x8c\x5d\x55\x15\ \x5e\x7b\x9f\x7b\xef\xdc\xf9\xe9\x70\x67\x4a\xa1\xa3\x32\x4c\x7f\ \x80\x00\x21\x44\x52\x5f\x7c\x20\x24\x44\x8d\x18\x89\x0f\xb6\xa5\ \x2f\x0a\x09\xc6\x08\x84\x80\x96\x98\x68\x7c\x23\x24\x3c\x00\xc3\ \x8b\x31\xd1\x67\x62\xa3\x89\x21\x31\x31\x68\xe2\x8b\x86\x2a\x3a\ \x0d\x24\x6d\x83\xb6\xb4\xb1\xd3\x0b\x73\xa1\x99\xce\x4f\x67\xe6\ \xfe\x9d\xb3\x5d\x6b\x9f\xbd\xf6\x59\xfb\xdc\x73\xef\x2d\xf4\x8f\ \x0d\x8b\xbd\xcf\xcf\x3d\xfb\xfb\xd6\xdf\x5e\x7b\x0f\x0a\xa8\x1d\ \x7a\x33\x82\x89\x99\xef\x81\x56\x87\xc0\xc0\x2e\x50\x46\x83\x6b\ \xf3\x5f\x8b\x77\xde\x3e\x99\x54\x68\xac\x94\xb2\xc2\x2d\x49\x12\ \x30\xc6\xd8\x71\x37\x8e\xed\xd8\xe0\xbd\x18\xc7\xb1\xbb\xa6\x77\ \xec\xf3\x6e\x17\xc7\xf8\xdc\xc8\xeb\x74\x4c\xef\x7d\xb8\x51\x69\ \xbf\xfc\xef\x1d\x4b\xd0\xe9\x00\xc4\x78\x3f\xee\x1a\xe8\x34\xcf\ \xc2\xfa\x47\x7f\x80\x77\x5f\xfe\x2d\xac\xfc\x6f\x8d\x7e\x06\xb9\ \x56\x82\x43\x26\x82\xa9\x63\x6f\x40\xab\xbb\x5f\xd5\xeb\x4a\x37\ \xb7\x90\x07\x7e\xd4\x81\xad\xc1\x4e\xf8\xea\xfd\x77\xc3\xd8\xd8\ \x98\xfd\x81\xd6\x1a\xa2\x28\xb2\xcf\x68\x62\x26\x64\xc1\x3b\xc0\ \x0c\x4e\x0a\x11\x2a\xba\x47\xbf\xd9\xdc\xdc\x84\xb7\xfe\xf1\x9f\ \xd2\xec\x4d\x66\xb7\x52\x65\x37\x4f\x15\x9a\xcd\xd1\x3d\x1f\x37\ \x2a\x0f\xc7\x0f\xfc\xfc\xeb\xf0\xd7\x17\x0e\x03\xac\x2e\xe2\xa3\ \x56\x48\x60\xf2\xe8\x8f\x60\xcb\xec\xd7\x27\x4f\x20\x16\x0d\x16\ \x4f\xa4\x90\x04\x12\xd0\x08\x14\x4d\x52\x2a\x95\x3c\x68\x26\x40\ \x92\x6f\x4c\x80\x9e\x31\x48\x26\x43\xf7\xd8\x32\xfc\x8c\x95\x40\ \xdf\xc4\x5f\xc3\x08\x7e\x52\xe1\xdc\x2a\xd2\x38\xbf\x46\xa5\x95\ \x61\x7a\x7b\x55\xfd\xf7\x44\xe7\xd1\xce\x3d\xfb\x4f\xc3\xc9\xdf\ \xfc\x12\x5f\x3c\x27\x2d\x51\x02\x28\x3f\xa9\xcf\x9f\x51\xd6\x3d\ \x34\xbb\x88\x02\x10\x9a\x65\xf7\xa1\x89\x58\x08\x58\xa3\xd1\xf0\ \x16\xa0\x9e\x5d\x8a\xfb\xfc\x98\xa4\x5c\x2e\x5b\xe1\xef\x06\x56\ \xb4\xdf\xd1\xd0\x5e\x3e\x67\xe7\xd7\xa5\x0a\x54\xb7\x7f\x11\x66\ \xbe\x54\x53\xe7\x3e\xba\xe7\x1b\xf8\xf8\xef\x28\xcb\x28\x2b\x19\ \x01\x03\x73\xaa\xd9\x44\xf0\x3a\xfd\x90\x73\x9d\x54\x32\xe0\x12\ \x28\x49\xbb\xdd\x86\xc5\xc5\xc5\x42\x4b\xc8\x38\xc9\x5b\x68\x72\ \x72\x12\x46\x46\x46\xac\x25\xe4\xbb\x96\x90\xd5\x5d\x04\x5b\x8b\ \xef\xe2\x75\x07\x4a\xd5\x9b\x60\xa4\x36\x03\x63\x13\x18\x82\x6a\ \xf2\x36\x7c\x7a\x27\xca\x42\x48\x80\x5c\x83\x00\x9a\x54\xf3\x0c\ \x3c\xfd\x18\x6a\xd5\x69\xaa\x08\x98\x11\xcf\x8a\xee\x0f\x22\xd2\ \x9f\xb4\x81\x68\x74\x12\x4c\xdc\x05\x5d\x19\x4d\xdd\x0c\x83\x1f\ \xe2\x0e\xbd\x30\x8d\x32\x12\xc6\x00\x11\xd7\x68\xc6\x84\xb5\x0f\ \x39\x2b\x28\x9f\x2d\x64\x23\x2d\xee\xdd\xbb\x37\x00\xc9\x6e\x22\ \x33\x90\x74\x25\x8e\x85\x42\x52\x14\x13\x16\x7e\x02\x95\xed\xbb\ \x71\x14\x83\x8e\x2a\xd6\xad\x50\xbb\x78\x69\x47\xfc\x63\xe5\x3c\ \x8e\x62\x00\x6c\xc0\xda\xd4\x03\x21\x01\x7a\x2d\x41\x30\x45\x99\ \x86\x80\xec\xd8\xb1\xa3\x10\x4c\x07\x53\x21\x07\xab\x0c\x5a\x8a\ \x1b\xba\xa6\xbe\xb8\xe1\xbc\xa8\xed\x91\x9b\xe7\xc0\xc7\x24\x2a\ \xd7\x86\x6c\xd2\x05\x01\x5e\x58\x00\x89\x18\x45\x51\x9f\xf8\xc0\ \x55\x82\x80\x11\xc0\xa5\xf9\x09\xc4\xca\xca\x4a\x4f\x10\x4b\x91\ \x56\xe0\x7b\x9c\xd1\xf2\x56\xcb\xa0\xd1\x5a\x12\xa7\x0a\x4d\x94\ \x0d\x6a\x7b\xbb\x1b\x17\x52\xb6\x16\xb0\x4c\x79\xed\x72\x81\xcb\ \xbd\x11\x6e\x40\x8d\xd3\xdf\xd6\xd6\x16\x9c\x3a\x75\xca\x02\xea\ \xd7\x8a\x62\x86\x82\x78\x7c\x7c\x3c\x04\x9e\xbe\xdc\xab\x5f\x1f\ \x8c\xfd\x9b\x77\x21\x06\xed\x27\x76\x04\x12\xa1\x3d\xce\x48\xac\ \x55\x99\x9d\x2e\x87\x00\x93\xc8\xbb\xa4\x5c\xb1\x7b\x80\x53\xa7\ \xfb\x4e\xe1\x2c\xe0\xfc\x2d\xb0\x00\x03\x10\x93\xe4\xb3\x47\xad\ \x56\x0b\x40\xca\xb5\x80\x17\x29\xe9\x7a\xec\x42\xb2\x04\xc9\xa7\ \xe7\xf4\x9f\x94\x83\xa7\x61\x86\x11\xa0\x95\xd7\xae\xb9\x99\x06\ \x94\x4f\xa3\x99\x4f\x07\x3f\x44\x20\xbb\x76\xed\x0a\x80\x73\x5f\ \x14\xc0\x89\xa8\x91\x38\x4b\x15\x5a\x40\x7a\xcd\x10\xed\xa7\x04\ \xd2\x3c\xe5\x6a\x1f\x41\xc0\xf5\x32\x00\xa5\x26\xa9\x5f\x5e\x5e\ \x0e\xb4\xc8\x24\x8a\x00\xb2\x90\xdb\x11\x79\xd3\x63\x59\x53\xec\ \xff\x46\xd9\x75\x6a\xa8\x05\xd8\x74\xfc\x1f\x6f\x81\x24\x24\xc0\ \x71\xd0\xc4\xd5\xbb\x5e\xaf\xbb\x3a\x66\xb0\xdf\xcb\x46\x45\x21\ \x65\xa1\x3c\x01\xef\x3e\xb2\xe2\xf5\x16\xe8\xef\x43\x59\x0c\xf4\ \xb1\x40\x92\xc4\x3d\x04\x24\xd8\xfc\xf5\xa0\x26\xe3\xa1\x57\x42\ \xf7\xf1\x31\x60\xd4\xc0\x44\x14\x04\xb1\xb4\x40\xfa\x6f\x1a\x17\ \xec\xbf\x72\x65\xa6\x49\xb7\x6d\xdb\xd6\xb7\xbc\x28\xea\xd9\x85\ \x64\x5c\xf0\xb3\x98\x72\x7f\x50\x48\xaa\x8c\x05\x0c\x73\x21\x2d\ \x5c\xc8\xfb\x9f\x5b\x07\x72\x41\xcc\x24\x08\x88\x5c\x89\xf3\xd9\ \x46\x6a\x97\x0b\x37\x0e\xea\x22\x0b\x70\x08\x28\x15\x4a\x3a\xa7\ \xe9\xeb\x46\xce\x02\x94\xcf\x13\xef\x36\xec\x7f\xd6\x02\x49\x6f\ \x0a\x95\xab\x6e\xfe\x5e\x3e\x88\xc1\x59\x30\xdf\xe7\x53\xad\x92\ \xe8\x85\x15\x86\xb9\x65\xba\x90\x45\xa9\x03\xaa\x0c\x79\x66\x01\ \x2c\xae\x2e\x5d\xba\x64\xeb\x1b\xfb\x2e\x6a\x9e\x81\x71\x00\xcb\ \x14\x5a\x94\x85\x58\xfb\x45\x3d\xfd\x86\x56\x75\x4e\x1c\xde\x8d\ \x59\xb4\x75\x91\x01\x04\x68\x12\x48\x77\x60\xac\x75\x69\x81\x0f\ \x2e\x68\x58\xfd\xdb\x19\xaa\x50\x32\x92\x81\x52\x5c\xcd\xe4\x2d\ \xe4\x80\x43\x56\x32\x72\x9a\x4c\x9c\xab\xf0\x75\xf6\x0c\x37\x8b\ \xdd\x31\x6f\x81\x20\x23\x19\x35\x70\x29\x48\x2d\x50\x8a\x40\x27\ \xd0\x0b\x10\x3f\xf0\xbb\xf7\x32\x32\xec\xa4\xd9\x9e\xa1\xb7\xfc\ \xa6\x77\xac\x65\x6c\x62\x10\x99\x4a\x8b\x12\x5d\x8c\xfd\xfd\x01\ \xbd\xd1\x6a\x30\x81\xf4\x63\x5a\x7a\x4f\xb8\x1e\x80\x00\x0b\x79\ \xd0\xd9\x38\x2b\x04\xb3\xdd\x5c\xef\x2e\x4f\x6e\x98\x0a\x82\x36\ \x2f\x1a\x2e\xc3\x02\x5a\xc9\x08\x08\x2c\x50\xb4\xb8\x65\x44\x32\ \xd0\xe1\x18\xb2\xfd\x75\x21\xf0\x90\x90\x64\xe0\x5d\x87\xbf\x6f\ \xd2\x2a\x61\xb8\x05\xb4\x20\x70\xd9\x16\xc8\x69\xdf\xa9\xb4\x17\ \xfc\x60\xe0\xd9\xfe\xbb\xd7\x0a\x7e\xaf\x35\x94\x00\x5b\x40\x32\ \x90\xe5\x35\x3f\x0b\xaa\x47\x10\x20\x20\x00\x1d\x80\xd7\x45\xc0\ \xf3\xf9\x3e\x4f\x28\x7b\xd7\xf0\xce\xaa\x1f\x01\x3b\x81\x91\x25\ \x81\xb0\x85\x0c\x60\x26\x93\x2f\xb9\x73\xbe\xdf\x0f\x7c\xaa\x4e\ \xf0\x64\x7b\xad\x90\x73\x29\x10\x16\xe9\x6b\x01\x23\x2c\x10\x6c\ \x8a\xb2\xeb\x87\x6f\x3e\x0d\xb3\xb5\x18\x22\xda\x0e\xba\x73\x21\ \xbf\x98\x61\x1a\xec\x76\x3b\xe9\x3e\x18\xb7\x7d\x6d\xec\xf9\x9a\ \xb6\x9d\xdd\x56\x6c\xaf\x69\x9c\xde\x8b\xed\xea\x7e\xb1\x33\x02\ \xcb\x77\x3d\x3e\x24\xb0\xdd\xaa\x7f\x59\x31\xa0\xfa\x5b\x60\xb4\ \xd4\x86\x17\x9e\x79\xd2\x2e\x38\x54\x85\x52\x4f\xc7\x81\xd4\x6f\ \x6c\x6c\xd8\x7b\x24\x34\xa6\x46\x15\x27\x9d\x5a\x50\x3f\x3a\x3a\ \xea\x85\xae\xab\xd5\x2a\x4c\x4f\x4f\xc3\xb7\x0e\xfd\x10\x56\x4f\ \x9e\xc9\xb9\x5e\x3a\x9e\xba\xff\x8e\xc0\xbf\xcc\xe0\x1d\x99\xf1\ \xb5\x50\xe6\xfd\xb9\x0a\x10\xad\xb4\xbe\xbe\x0e\x0b\x0b\x0b\x70\ \xf6\x7c\x03\xc6\x26\x26\xa1\x14\x95\x6c\x01\xd6\x6e\xb5\xa1\xd5\ \x6a\xe2\xf3\x35\x18\x2f\x1b\x98\x99\x99\xb1\xf5\x3e\x9d\xbe\x51\ \xd9\x2c\xb7\x9d\x72\x27\x16\xc7\x5d\xa8\xdd\xbb\xdb\x9d\x3c\xe8\ \x20\xf0\xef\xf8\xc2\x34\x9c\x5e\xba\xe8\x39\x68\x33\xd4\x02\x62\ \x3f\x26\x57\x63\x77\x4d\x6b\x26\x69\x9c\xb4\x3c\x7f\x62\x8f\xaf\ \x99\xb2\xe0\x4b\x35\xf7\xf4\xdc\x31\xab\xe5\x4a\xa5\x62\x35\x2d\ \x85\x2c\xc2\x3d\x3d\x4f\x57\xbc\x30\xe8\xc3\x42\x54\x58\x60\x58\ \x16\xa2\x83\xa3\xb0\x68\x12\xe9\xd3\x5d\x13\x78\xf2\x63\x55\x00\ \x9c\x49\x93\xb6\x89\x00\x69\x3f\x0f\x9c\x84\xdc\x88\xae\xad\x51\ \x4d\x92\x5b\x3f\x72\xae\x2c\x82\x7a\x78\x0c\x68\xd5\x9b\xff\x45\ \x18\xd0\x64\xe4\xef\x74\x1e\xca\xef\x3e\xf2\xc0\x2d\xa1\xbb\xa1\ \x3c\x78\xdf\x83\x16\x28\xb9\x0e\x1f\xe2\x92\xb6\xc9\xa5\xa8\xe7\ \x31\xb5\x5f\x1c\x7e\x06\xfe\xb4\xb4\x1d\xfc\xfc\x02\xf8\xcc\xd4\ \x38\xec\x99\x76\xc4\x68\xff\xd0\x89\xe1\xa7\xaf\x3c\x32\xfa\xd8\ \x37\x7f\xec\xf7\x68\x0e\x9d\xa1\x23\x02\xd0\x65\xf4\xd5\x28\x81\ \xbc\xad\x58\xd3\x31\xbe\x43\x2e\xd4\x6a\xb5\x02\x8d\xbf\xfe\xf8\ \xdd\xc1\xfb\xaf\xc3\x35\x6d\xf4\x87\x83\x9f\x38\xa1\x36\x87\xd2\ \xb0\x04\xd2\x32\x48\x07\x5b\xba\xcc\x18\xe9\xb6\x92\x08\xb0\x05\ \x6c\x73\x7a\x38\x72\xe4\xc8\xb5\x85\x5d\xd0\x0e\x1e\x3c\x48\xdd\ \x77\x51\x7e\x5f\x42\xc7\xb6\xb5\x10\x15\x90\xc1\xb1\x8f\x4f\x44\ \x48\x20\x2e\xb6\x00\xb7\x03\x07\x0e\x78\x17\xc8\x1f\x5c\x5d\x43\ \x02\x74\xdc\x5e\xd5\x98\xcf\x96\x2f\x6e\x19\x4c\x8b\xb8\x40\x45\ \x7c\xa0\xca\xa5\x6c\x9a\xde\xd8\x85\x7c\x0c\x88\xda\x89\x9b\x3c\ \x5d\x28\x3a\x04\xbb\x06\x4d\xa7\xff\x39\xfb\xe7\xef\x5f\xfc\x64\ \xed\x4c\xfd\x42\x3b\xcd\xdb\x3d\x24\x94\x5d\x49\xe5\x1f\x24\x2c\ \x78\x75\x45\x93\x5f\x45\x16\x47\x5f\x3a\x06\xef\xbc\xf8\xf4\xda\ \xd2\xd2\xf1\x7a\xfd\x92\x5b\x7c\xdc\x61\x92\x23\x41\xe0\x29\x3d\ \x66\x47\xde\x62\xc7\x7d\xc3\x09\x00\x6c\xc2\x87\xef\xbc\x0d\xc7\ \xe6\x9f\x5b\x6b\x34\xde\xaf\x2f\xae\x42\x54\xa6\x23\x70\x74\xa9\ \x12\xb9\x95\xb6\xf5\x0b\xe5\xf0\x89\x89\x09\xf8\xb6\xfa\x23\x7c\ \xa7\xf4\x16\x3c\x71\x5f\xfb\x46\x63\xb7\x8d\x92\x32\x39\xeb\x3a\ \x7c\xf2\xaf\x7f\xc2\xf1\x5f\x3d\xbb\xda\x7e\xe2\xb5\xce\x66\xfb\ \xde\x5b\x6f\xab\xa1\x01\xd2\xfd\x72\x07\x7d\x9f\xc0\xef\xdb\xb7\ \x0f\x1e\x7a\x68\xc2\x92\x99\x9a\x9a\xba\xd1\xd8\x3d\x01\x70\x24\ \x36\xa0\xf1\xf6\x51\xd8\xfa\xf8\xa9\xcd\xd9\x47\x9f\x3a\x7b\x7e\ \xf6\x2b\xd0\xe9\x62\x90\x77\x61\x6a\x67\x6b\xfa\xa5\xf9\x37\xec\ \x1f\x70\x79\x6d\xf8\xd9\xe1\x1f\x50\x3d\x10\x7d\xc6\x79\xaf\x3a\ \x81\x8c\xc4\xda\xe9\x05\x38\xfe\xea\x8b\x38\xfe\x32\xca\x2c\x4a\ \x75\xe1\xb8\x75\xb5\xb2\x03\x6c\x29\xfc\xe5\xcd\x5f\x53\xf7\xfc\ \xe7\x89\x00\x93\xd8\x44\x39\x85\xd2\x40\x19\x13\xa0\xe5\x32\x0e\ \xee\xda\x13\xb8\x9e\xeb\xc0\x20\x02\x4c\x82\xfe\x9c\x7f\xe1\xd3\ \x7c\x48\x82\xbd\x1e\xc0\xaf\x56\x33\x37\x50\xe6\x51\xee\x2a\x0d\ \xc7\x38\xb0\xcd\x41\x5a\x93\xd0\xb2\xae\xaf\xec\x53\x9f\xaa\xd1\ \x31\x1c\xfd\x8f\x1f\xcd\x2b\x5d\x8d\xaa\x28\xb7\xba\xfe\x7a\xb7\ \x26\x4a\xe3\xff\x19\xf5\x4b\xa6\x3e\x14\x68\xc8\x00\x00\x00\x00\ \x49\x45\x4e\x44\xae\x42\x60\x82\ \x00\x00\x05\xb8\ \x89\ \x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\ \x00\x00\x30\x00\x00\x00\x30\x08\x06\x00\x00\x00\x57\x02\xf9\x87\ \x00\x00\x00\x2b\x74\x45\x58\x74\x43\x72\x65\x61\x74\x69\x6f\x6e\ \x20\x54\x69\x6d\x65\x00\x4d\x69\x20\x32\x31\x20\x4d\x61\x69\x20\ \x32\x30\x30\x33\x20\x30\x30\x3a\x34\x37\x3a\x35\x36\x20\x2b\x30\ \x31\x30\x30\xd7\x2c\xac\x73\x00\x00\x00\x07\x74\x49\x4d\x45\x07\ \xd4\x0a\x08\x0e\x31\x16\xf2\x68\x5b\x3e\x00\x00\x00\x09\x70\x48\ \x59\x73\x00\x00\x0a\xf0\x00\x00\x0a\xf0\x01\x42\xac\x34\x98\x00\ \x00\x00\x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\x05\x00\ \x00\x05\x10\x49\x44\x41\x54\x78\xda\xed\x59\x5d\x6c\x14\x55\x14\ \x3e\xbb\xb5\x02\xaf\xc6\xe8\x8b\x8a\xd8\x7d\x37\x29\x85\xc6\x06\ \x96\x84\xf8\x00\x0f\xd6\x28\x5a\x94\xd4\x07\x5d\x74\x13\x02\x0d\ \x41\xb2\x31\x80\xc4\x07\x63\x48\x43\x22\x31\x11\x53\x10\x7c\xd0\ \xb4\xd2\x6a\x49\xf9\x49\x8c\x7f\xb1\x84\x97\x15\x76\x13\x13\x89\ \x52\xb7\x44\x0a\xa5\x74\xbb\xdd\xb5\xdd\xdf\xd9\xbf\xf1\x9c\x99\ \xbb\xcb\xec\x64\x67\xe7\xce\xcc\xdd\xb6\x0f\x7c\xc9\xcd\xbd\xf3\ \x73\xef\x39\xdf\xbd\xe7\x9e\x73\x66\x2e\xc0\x43\x3c\x44\xf3\xe0\ \xe9\xf9\x5e\x86\xf5\x03\x32\x36\x9f\xc1\xb2\x7a\x25\xca\x77\x37\ \xe8\xef\xd2\xb4\x5f\xc7\xf2\xa4\xee\x5e\xb3\xc1\x25\xdf\xcd\x39\ \xd8\xd3\xb0\x0c\x2b\xc0\x23\xff\x11\x1b\xb3\xb1\x94\xab\x60\x2a\ \xb3\xe6\x81\x62\x73\x3a\x44\x26\x63\xe0\x69\x7b\x7c\x19\x74\x36\ \x96\x1f\x19\xde\xb1\x16\xab\x28\x96\x9c\x76\x05\x5c\xf4\xb2\xd1\ \x20\x76\x70\xba\xfb\xb8\x52\xbf\x7b\xe1\xa0\x63\x12\x3a\xd0\x9e\ \x18\xc1\x72\xa7\xd6\x84\x42\xfe\xb5\xec\x21\xd9\x9c\x0b\x57\xa4\ \x4f\xe9\x1c\xf2\x5f\xc0\xeb\xfb\xc4\x98\x57\xe8\xb7\x47\xa1\x6b\ \xe7\x81\x40\x07\xb5\x93\xd3\xfe\xf0\x81\x53\x70\x0b\x9b\xf3\x58\ \x24\xde\x31\x0c\xe4\xd7\x58\x89\x96\x00\x3d\x88\x32\x66\xb4\x61\ \xc8\xbc\xfa\xd8\x33\xea\xfc\x1d\x96\x29\x1e\xc1\xe3\x27\xe0\xac\ \xd7\x17\xe8\x28\x45\x7f\x51\xae\x77\xf5\x7a\xda\x57\xb7\x46\x4a\ \x7b\x3e\x87\x21\x9a\x50\x0b\x24\xea\xc9\x97\x19\x11\xd2\x55\xd6\ \x6f\xe2\x9c\x46\x49\x57\x9d\xfb\x13\x66\x12\x7f\xff\x02\xc6\x37\ \xf4\x06\xba\x48\xf9\xcc\x62\x0e\x8a\x85\x92\x72\xff\xd5\x9d\x9e\ \x0d\xab\x5a\x23\x01\xdf\x09\xd8\x8d\x97\xb7\xad\xac\x84\x4e\x7e\ \xcd\x0a\xf0\xba\x51\x2d\x64\xa3\xc2\x94\xdf\x4c\xca\x2f\xce\xa7\ \x21\x93\x94\x20\x99\xc8\x42\x26\x95\x57\xea\xf6\xf6\xc7\x3a\xcf\ \xec\x87\x2f\xf1\xdd\x36\x2c\x8f\x36\x1a\x8b\x57\x19\x3b\x04\x1a\ \xcd\xfc\xe6\xff\x26\x2e\xc1\xec\x54\x02\xe2\xb3\x49\x48\x44\x53\ \x90\x5a\xc8\xc2\x42\x4c\xad\x09\x8c\xc4\x19\x6c\x7a\xb0\xac\x72\ \x2a\x97\x37\x0e\x98\xc1\xe5\x76\x83\x77\xe8\xa3\x7e\xae\x97\xd7\ \xb4\x40\x27\x56\x5e\x2c\x71\x50\xed\x9b\x7b\xc6\x9b\x45\x00\x3a\ \xfc\x8a\xe7\x7a\x05\xcb\x3a\xcd\xb8\xfa\x00\x54\x51\xb4\xc8\xde\ \x69\x71\x2a\x57\x14\x01\x52\x8c\x9c\xf5\x18\x3c\xf0\x60\x66\xef\ \xe7\x58\x1f\xdb\xb3\x6f\x9b\x40\x10\xed\xbd\x05\x4d\x86\xcd\x7a\ \x8c\x29\x63\xe4\xc1\x8c\x08\x54\x71\x7d\x00\xe4\xb9\x79\xb8\xba\ \xfd\x10\xf4\x80\x6a\x56\xdc\x1e\xca\xf2\x26\x0e\x9e\x84\x2b\x1b\ \x7b\x03\xde\x09\xd5\xa1\x92\xc9\xd4\xcb\x12\x65\xe0\xf7\x30\x4a\ \xdf\x6d\xfb\x02\x9b\x06\x0f\xc1\x79\x50\x3d\x14\xf7\xe6\xb6\x44\ \x00\x95\x1f\xdf\xf8\x96\xea\x69\x18\x9e\x03\x81\x59\xea\x8e\xbd\ \x6f\x77\x7e\xf3\x01\x9c\x05\xd5\x43\x71\x8d\xcb\x4d\xe0\x37\x8c\ \xae\xa4\x7c\x25\x40\x31\x38\xde\x84\x5a\xc8\xc5\x24\xbc\xb9\x67\ \x2b\x91\x20\x37\xdb\x26\x8c\xc0\xd0\x87\xd0\xb5\xc5\xa7\x46\x57\ \x0a\x50\xd9\x54\xd5\x44\xc5\xa6\xd6\xc5\x14\x64\x12\x51\x78\xb1\ \xfb\xf9\x4a\xc0\x73\x4e\xe0\xd4\x4b\xc7\xe1\x8d\x80\x9a\xd7\xd0\ \xcc\xe7\x73\x45\x28\x48\x25\xa1\x7a\x13\x64\x29\x0a\xd2\xe2\x1c\ \x23\x92\x86\x17\xbc\x4f\x75\xf6\xad\x3b\x62\x3a\x51\x96\xf6\x00\ \xe5\x35\x52\xb6\x00\xe5\x72\x59\x38\x01\xc8\x27\xa0\x5c\xcc\x43\ \x7a\x41\x35\x4f\x29\x95\x81\x6c\xb6\xfa\xd4\x3e\x81\xf7\x2e\x1e\ \x84\x4f\xdf\xef\x0f\xc7\xa6\x17\x94\xd9\x2f\x95\x64\xa5\x16\x0d\ \xb9\x94\xae\xb6\x67\xfe\x8d\xc3\xc5\x1f\xe2\xe1\xd3\xf7\x3f\x36\ \xed\xc7\xb5\x02\x94\xcb\x8f\x9e\x8b\x5c\xa3\x76\xa9\x20\xde\x7c\ \x2a\x28\xbb\xd7\x54\x95\x3f\x3a\x08\x37\xb5\xfc\x1c\x11\x40\xcc\ \x63\x2e\x7f\xec\xf2\x68\x24\x58\x49\xca\x44\x23\x9d\x72\xc1\xcc\ \x3f\xb7\x2a\xca\xff\x8d\xb7\xae\x8b\x24\x40\x6e\x27\x42\xb9\x7c\ \x38\x1c\x0f\xf2\x0c\x6c\x15\x89\xdb\x37\x60\xec\x52\x2c\xc4\x94\ \xa7\xd5\xfe\x91\xa7\x9f\x95\x4d\x4c\x24\x26\x91\x84\x4f\x43\x42\ \x98\x3d\x8d\x0c\xdf\xbb\x76\xf8\x6b\xf8\x8b\x29\xff\x13\xc9\xe2\ \xe9\x67\x35\x17\x22\x17\x41\x2b\xf1\x0e\xd6\x5b\x58\x7f\xee\xef\ \x64\x23\x60\x4e\xf5\x2c\x56\xdd\xa0\x66\xa9\xe3\x4c\xf9\x7c\x33\ \x08\x10\x24\x26\x20\x01\x6a\x24\x76\x9a\x51\x52\xdf\x59\x2c\x94\ \x07\xd1\x8a\x56\x92\x39\xae\x20\x69\x37\x9d\x26\x01\x33\x0e\x94\ \xd6\x83\x56\xf1\xae\x9d\x8e\xc2\x3e\x68\x74\xb0\x94\x4e\x3b\x81\ \x30\x02\x94\xd3\x5b\x79\x1f\xed\xbe\xfa\x77\x6d\x25\x10\x70\xcd\ \xc5\xe0\xea\xb6\xbe\xc0\x26\xed\x4d\xca\x6f\x28\x45\xa8\x44\x59\ \xf2\xf5\xe4\x2e\x47\xce\xdd\x23\x4f\xf3\x32\xa8\x76\x3f\x0d\x2b\ \xe1\x9b\x78\xfb\x61\xe8\x19\x4c\xf7\x9f\xa7\x9c\x9e\xd2\x62\xca\ \x2c\x29\x39\xa3\xfc\x86\xa0\x44\x59\x0c\x54\xe4\xeb\xd1\x5d\x52\ \x94\x25\x8f\xe3\xd8\x0d\x8b\xfa\xad\x42\x33\x18\xdf\xf5\x09\xf8\ \x46\x3e\xfb\x2a\xd8\x8a\x8e\xa4\x90\xbc\x0b\x6e\x97\x04\x52\x26\ \xab\x94\xa9\x3f\x23\x30\x3a\x16\x0b\x33\xe5\x43\x58\xae\x80\xea\ \x71\x1c\xed\x07\x61\xff\x85\x80\x45\xeb\xde\x63\xe0\x1b\x3a\xf9\ \x6b\x30\x9d\x6e\xa9\x66\x96\x9a\xfc\xa6\x12\x65\x29\x50\x59\xf9\ \xc5\x28\x94\x80\xab\x41\x21\x7b\x99\x44\x12\xbb\x2f\x0f\xff\x11\ \x8c\xc7\x72\xfa\xe4\x8c\x66\xfe\x67\x78\x10\xa8\x1a\x8d\xc5\xad\ \x4c\x15\xa2\xcf\x07\xe8\x83\x84\x72\x7a\x9e\xb4\xd8\x08\x66\xe7\ \x03\xb5\x27\x2f\xeb\x07\x9a\xf0\xa5\xd2\x04\x84\xfc\x74\xe0\xa0\ \x9c\x0f\xe8\x8f\x8e\xe8\x3f\x8f\x90\xf3\x01\xcd\x98\x5a\x58\xda\ \xb0\x0d\xce\x07\xee\x40\x9d\x03\x0e\x61\xe7\x03\x02\xb1\xf4\xe7\ \x03\x4d\x82\xe1\xf9\x00\x6f\x20\x93\x0d\xda\xcd\x84\x76\x02\x65\ \x9e\x97\xea\x3d\xa3\x13\xf2\xd7\xd8\xb5\x76\x09\x97\x8a\x80\xa9\ \x7c\x33\x7f\x4b\x7b\xe1\x09\xd6\x76\x9c\x78\xd9\xc0\x72\xcb\x6f\ \x3e\xfe\x07\x44\x59\x76\x36\x1e\xee\x54\x0f\x00\x00\x00\x00\x49\ \x45\x4e\x44\xae\x42\x60\x82\ " qt_resource_name = "\ \x00\x06\ \x07\x03\x7d\xc3\ \x00\x69\ \x00\x6d\x00\x61\x00\x67\x00\x65\x00\x73\ \x00\x0a\ \x08\xab\x7a\x07\ \x00\x72\ \x00\x6f\x00\x74\x00\x61\x00\x74\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\ \x00\x08\ \x03\x03\x5a\xe7\ \x00\x66\ \x00\x6c\x00\x69\x00\x70\x00\x2e\x00\x70\x00\x6e\x00\x67\ \x00\x08\ \x08\xc8\x58\x67\ \x00\x73\ \x00\x61\x00\x76\x00\x65\x00\x2e\x00\x70\x00\x6e\x00\x67\ \x00\x0d\ \x02\x38\x3d\xc7\ \x00\x66\ \x00\x69\x00\x74\x00\x74\x00\x6f\x00\x63\x00\x65\x00\x6c\x00\x6c\x00\x2e\x00\x70\x00\x6e\x00\x67\ " qt_resource_struct = "\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\ \x00\x00\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x02\ \x00\x00\x00\x58\x00\x00\x00\x00\x00\x01\x00\x00\x17\x30\ \x00\x00\x00\x2c\x00\x00\x00\x00\x00\x01\x00\x00\x07\xc6\ \x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ \x00\x00\x00\x42\x00\x00\x00\x00\x00\x01\x00\x00\x0d\xa3\ " def qInitResources(): QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) def qCleanupResources(): QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data) qInitResources()
bsd-3-clause
[ 11490, 199, 309, 199, 309, 1898, 334, 35, 9, 8315, 13, 8128, 12, 15904, 402, 738, 502, 72, 14, 221, 199, 309, 2900, 4481, 4644, 14, 199, 309, 18684, 26, 8966, 32, 433, 14183, 17841, 14, 1308, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 812, 374, 2437, 17841, 14, 199, 309, 199, 309, 298, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 221, 199, 309, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 309, 199, 309, 221, 446, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 221, 199, 309, 259, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 309, 221, 446, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 221, 199, 309, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 221, 199, 309, 259, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 309, 221, 446, 11443, 314, 536, 402, 314, 15904, 402, 738, 502, 72, 6590, 314, 1561, 402, 2399, 221, 199, 309, 259, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 221, 199, 309, 259, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 309, 199, 309, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 221, 199, 309, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 221, 199, 309, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 221, 199, 309, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 221, 199, 309, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 221, 199, 309, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 221, 199, 309, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 221, 199, 309, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 221, 199, 309, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 221, 199, 309, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 221, 199, 309, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 2122, 199, 309, 199, 11490, 199, 3, 7337, 909, 1233, 199, 3, 199, 3, 18208, 26, 3868, 85, 428, 1545, 7829, 8733, 26, 1081, 26, 1216, 8315, 199, 3, 420, 701, 26, 710, 7337, 27154, 367, 14084, 334, 4238, 373, 20, 14, 17, 14, 19, 9, 199, 3, 199, 3, 14750, 1, 2900, 4493, 6326, 315, 642, 570, 911, 506, 14669, 1, 199, 199, 504, 14084, 20, 492, 10565, 199, 199, 8440, 63, 1927, 63, 576, 275, 1867, 199, 60, 88, 383, 60, 88, 383, 60, 88, 1780, 60, 1812, 18, 60, 199, 60, 88, 1407, 60, 199, 60, 88, 1400, 60, 88, 20, 69, 60, 88, 2417, 60, 88, 16, 68, 60, 88, 16, 65, 60, 88, 17, 65, 60, 88, 16, 65, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 16, 68, 60, 88, 1887, 60, 88, 2006, 60, 88, 1602, 60, 88, 2528, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 1165, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 1165, 60, 88, 2036, 60, 88, 1690, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 2898, 60, 88, 23, 65, 60, 88, 23, 65, 60, 1949, 20, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 1643, 60, 88, 2760, 60, 88, 2006, 60, 88, 1427, 60, 88, 2898, 60, 88, 383, 60, 88, 383, 60, 88, 16, 66, 60, 88, 969, 60, 88, 383, 60, 88, 383, 60, 88, 16, 66, 60, 88, 969, 60, 199, 60, 88, 614, 60, 88, 383, 60, 88, 25, 65, 60, 88, 25, 67, 60, 88, 1085, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 966, 60, 88, 1822, 60, 88, 2953, 60, 88, 20, 68, 60, 88, 2953, 60, 88, 383, 60, 88, 383, 60, 2207, 24, 60, 199, 60, 10145, 60, 1949, 21, 60, 88, 17, 67, 60, 88, 1079, 60, 10117, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 1165, 60, 88, 2766, 60, 88, 2006, 60, 88, 2528, 60, 88, 20, 68, 60, 88, 383, 60, 88, 383, 60, 88, 22, 69, 60, 199, 60, 88, 1465, 60, 88, 383, 60, 88, 383, 60, 88, 2898, 60, 10850, 60, 88, 383, 60, 88, 383, 60, 1949, 22, 60, 88, 1401, 60, 88, 383, 60, 88, 383, 60, 88, 1257, 60, 1800, 21, 60, 88, 383, 60, 88, 383, 60, 88, 2760, 60, 199, 60, 88, 1789, 60, 88, 383, 60, 88, 383, 60, 11110, 60, 88, 996, 60, 88, 383, 60, 88, 383, 60, 88, 1216, 60, 88, 19, 69, 60, 88, 383, 60, 88, 383, 60, 88, 975, 60, 1774, 18, 60, 10489, 60, 88, 21, 68, 60, 88, 1138, 60, 199, 60, 88, 16, 65, 60, 88, 383, 60, 88, 383, 60, 88, 1780, 60, 88, 1703, 60, 88, 1887, 60, 88, 1602, 60, 88, 2953, 60, 88, 1477, 60, 88, 2277, 60, 11078, 60, 88, 2789, 60, 88, 772, 60, 88, 1165, 60, 88, 713, 60, 88, 1085, 60, 199, 60, 10879, 60, 88, 23, 68, 60, 88, 772, 60, 88, 383, 60, 1800, 20, 60, 88, 996, 60, 88, 1257, 60, 2207, 24, 60, 88, 17, 69, 60, 88, 1299, 60, 88, 17, 68, 60, 8371, 60, 3581, 60, 3581, 60, 10493, 60, 1949, 16, 60, 199, 60, 1845, 23, 60, 10493, 60, 88, 23, 70, 60, 88, 1184, 60, 88, 23, 70, 60, 88, 23, 70, 60, 88, 2835, 60, 1949, 24, 60, 10418, 60, 88, 23, 70, 60, 88, 1184, 60, 9566, 60, 88, 23, 70, 60, 1812, 17, 60, 9542, 60, 88, 1644, 60, 199, 60, 88, 23, 70, 60, 8371, 60, 8371, 60, 88, 19, 66, 60, 88, 2036, 60, 88, 772, 60, 88, 22, 70, 60, 88, 2277, 60, 88, 21, 67, 60, 1800, 25, 60, 88, 23 ]
[ 199, 309, 199, 309, 1898, 334, 35, 9, 8315, 13, 8128, 12, 15904, 402, 738, 502, 72, 14, 221, 199, 309, 2900, 4481, 4644, 14, 199, 309, 18684, 26, 8966, 32, 433, 14183, 17841, 14, 1308, 199, 309, 199, 309, 961, 570, 365, 1777, 402, 812, 374, 2437, 17841, 14, 199, 309, 199, 309, 298, 497, 4972, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 221, 199, 309, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 309, 199, 309, 221, 446, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 4245, 12, 221, 199, 309, 259, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 309, 221, 446, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 221, 199, 309, 259, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 221, 199, 309, 259, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 309, 221, 446, 11443, 314, 536, 402, 314, 15904, 402, 738, 502, 72, 6590, 314, 1561, 402, 2399, 221, 199, 309, 259, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 221, 199, 309, 259, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 309, 199, 309, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 221, 199, 309, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 221, 199, 309, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 221, 199, 309, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 221, 199, 309, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 221, 199, 309, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 221, 199, 309, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 221, 199, 309, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 221, 199, 309, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 221, 199, 309, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 221, 199, 309, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 2122, 199, 309, 199, 11490, 199, 3, 7337, 909, 1233, 199, 3, 199, 3, 18208, 26, 3868, 85, 428, 1545, 7829, 8733, 26, 1081, 26, 1216, 8315, 199, 3, 420, 701, 26, 710, 7337, 27154, 367, 14084, 334, 4238, 373, 20, 14, 17, 14, 19, 9, 199, 3, 199, 3, 14750, 1, 2900, 4493, 6326, 315, 642, 570, 911, 506, 14669, 1, 199, 199, 504, 14084, 20, 492, 10565, 199, 199, 8440, 63, 1927, 63, 576, 275, 1867, 199, 60, 88, 383, 60, 88, 383, 60, 88, 1780, 60, 1812, 18, 60, 199, 60, 88, 1407, 60, 199, 60, 88, 1400, 60, 88, 20, 69, 60, 88, 2417, 60, 88, 16, 68, 60, 88, 16, 65, 60, 88, 17, 65, 60, 88, 16, 65, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 16, 68, 60, 88, 1887, 60, 88, 2006, 60, 88, 1602, 60, 88, 2528, 60, 88, 383, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 1165, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 1165, 60, 88, 2036, 60, 88, 1690, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 2898, 60, 88, 23, 65, 60, 88, 23, 65, 60, 1949, 20, 60, 199, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 1643, 60, 88, 2760, 60, 88, 2006, 60, 88, 1427, 60, 88, 2898, 60, 88, 383, 60, 88, 383, 60, 88, 16, 66, 60, 88, 969, 60, 88, 383, 60, 88, 383, 60, 88, 16, 66, 60, 88, 969, 60, 199, 60, 88, 614, 60, 88, 383, 60, 88, 25, 65, 60, 88, 25, 67, 60, 88, 1085, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 966, 60, 88, 1822, 60, 88, 2953, 60, 88, 20, 68, 60, 88, 2953, 60, 88, 383, 60, 88, 383, 60, 2207, 24, 60, 199, 60, 10145, 60, 1949, 21, 60, 88, 17, 67, 60, 88, 1079, 60, 10117, 60, 88, 383, 60, 88, 383, 60, 88, 383, 60, 88, 1165, 60, 88, 2766, 60, 88, 2006, 60, 88, 2528, 60, 88, 20, 68, 60, 88, 383, 60, 88, 383, 60, 88, 22, 69, 60, 199, 60, 88, 1465, 60, 88, 383, 60, 88, 383, 60, 88, 2898, 60, 10850, 60, 88, 383, 60, 88, 383, 60, 1949, 22, 60, 88, 1401, 60, 88, 383, 60, 88, 383, 60, 88, 1257, 60, 1800, 21, 60, 88, 383, 60, 88, 383, 60, 88, 2760, 60, 199, 60, 88, 1789, 60, 88, 383, 60, 88, 383, 60, 11110, 60, 88, 996, 60, 88, 383, 60, 88, 383, 60, 88, 1216, 60, 88, 19, 69, 60, 88, 383, 60, 88, 383, 60, 88, 975, 60, 1774, 18, 60, 10489, 60, 88, 21, 68, 60, 88, 1138, 60, 199, 60, 88, 16, 65, 60, 88, 383, 60, 88, 383, 60, 88, 1780, 60, 88, 1703, 60, 88, 1887, 60, 88, 1602, 60, 88, 2953, 60, 88, 1477, 60, 88, 2277, 60, 11078, 60, 88, 2789, 60, 88, 772, 60, 88, 1165, 60, 88, 713, 60, 88, 1085, 60, 199, 60, 10879, 60, 88, 23, 68, 60, 88, 772, 60, 88, 383, 60, 1800, 20, 60, 88, 996, 60, 88, 1257, 60, 2207, 24, 60, 88, 17, 69, 60, 88, 1299, 60, 88, 17, 68, 60, 8371, 60, 3581, 60, 3581, 60, 10493, 60, 1949, 16, 60, 199, 60, 1845, 23, 60, 10493, 60, 88, 23, 70, 60, 88, 1184, 60, 88, 23, 70, 60, 88, 23, 70, 60, 88, 2835, 60, 1949, 24, 60, 10418, 60, 88, 23, 70, 60, 88, 1184, 60, 9566, 60, 88, 23, 70, 60, 1812, 17, 60, 9542, 60, 88, 1644, 60, 199, 60, 88, 23, 70, 60, 8371, 60, 8371, 60, 88, 19, 66, 60, 88, 2036, 60, 88, 772, 60, 88, 22, 70, 60, 88, 2277, 60, 88, 21, 67, 60, 1800, 25, 60, 88, 23, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
wrouesnel/ansible
test/units/modules/network/f5/test_bigip_monitor_https.py
24
13803
# -*- coding: utf-8 -*- # # Copyright (c) 2017 F5 Networks Inc. # 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 os import json import sys import pytest from nose.plugins.skip import SkipTest if sys.version_info < (2, 7): raise SkipTest("F5 Ansible modules require Python >= 2.7") from ansible.compat.tests import unittest from ansible.compat.tests.mock import Mock from ansible.compat.tests.mock import patch from ansible.module_utils.basic import AnsibleModule try: from library.bigip_monitor_https import Parameters from library.bigip_monitor_https import ModuleManager from library.bigip_monitor_https import ArgumentSpec from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import iControlUnexpectedHTTPError from test.unit.modules.utils import set_module_args except ImportError: try: from ansible.modules.network.f5.bigip_monitor_https import Parameters from ansible.modules.network.f5.bigip_monitor_https import ModuleManager from ansible.modules.network.f5.bigip_monitor_https import ArgumentSpec from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from units.modules.utils import set_module_args except ImportError: raise SkipTest("F5 Ansible modules require the f5-sdk Python library") fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_data = {} def load_fixture(name): path = os.path.join(fixture_path, name) if path in fixture_data: return fixture_data[path] with open(path) as f: data = f.read() try: data = json.loads(data) except Exception: pass fixture_data[path] = data return data class TestParameters(unittest.TestCase): def test_module_parameters(self): args = dict( name='foo', parent='parent', send='this is a send string', receive='this is a receive string', ip='10.10.10.10', port=80, interval=20, timeout=30, time_until_up=60, partition='Common' ) p = Parameters(params=args) assert p.name == 'foo' assert p.parent == '/Common/parent' assert p.send == 'this is a send string' assert p.receive == 'this is a receive string' assert p.ip == '10.10.10.10' assert p.type == 'https' assert p.port == 80 assert p.destination == '10.10.10.10:80' assert p.interval == 20 assert p.timeout == 30 assert p.time_until_up == 60 def test_module_parameters_ints_as_strings(self): args = dict( name='foo', parent='parent', send='this is a send string', receive='this is a receive string', ip='10.10.10.10', port='80', interval='20', timeout='30', time_until_up='60', partition='Common' ) p = Parameters(params=args) assert p.name == 'foo' assert p.parent == '/Common/parent' assert p.send == 'this is a send string' assert p.receive == 'this is a receive string' assert p.ip == '10.10.10.10' assert p.type == 'https' assert p.port == 80 assert p.destination == '10.10.10.10:80' assert p.interval == 20 assert p.timeout == 30 assert p.time_until_up == 60 def test_api_parameters(self): args = dict( name='foo', defaultsFrom='/Common/parent', send='this is a send string', recv='this is a receive string', destination='10.10.10.10:80', interval=20, timeout=30, timeUntilUp=60 ) p = Parameters(params=args) assert p.name == 'foo' assert p.parent == '/Common/parent' assert p.send == 'this is a send string' assert p.receive == 'this is a receive string' assert p.ip == '10.10.10.10' assert p.type == 'https' assert p.port == 80 assert p.destination == '10.10.10.10:80' assert p.interval == 20 assert p.timeout == 30 assert p.time_until_up == 60 class TestManager(unittest.TestCase): def setUp(self): self.spec = ArgumentSpec() def test_create_monitor(self, *args): set_module_args(dict( name='foo', parent='parent', send='this is a send string', receive='this is a receive string', ip='10.10.10.10', port=80, interval=20, timeout=30, time_until_up=60, partition='Common', server='localhost', password='password', user='admin' )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(side_effect=[False, True]) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['parent'] == '/Common/parent' def test_create_monitor_idempotent(self, *args): set_module_args(dict( name='asdf', parent='https', send='GET /\\r\\n', receive='hello world', ip='1.1.1.1', port=389, interval=5, timeout=16, time_until_up=0, partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) results = mm.exec_module() assert results['changed'] is False def test_update_port(self, *args): set_module_args(dict( name='asdf', port=800, partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['port'] == 800 def test_update_interval(self, *args): set_module_args(dict( name='foo', interval=10, partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['interval'] == 10 def test_update_interval_larger_than_existing_timeout(self, *args): set_module_args(dict( name='asdf', interval=30, partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) with pytest.raises(F5ModuleError) as ex: mm.exec_module() assert "must be less than" in str(ex) def test_update_interval_larger_than_new_timeout(self, *args): set_module_args(dict( name='asdf', interval=10, timeout=5, partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) with pytest.raises(F5ModuleError) as ex: mm.exec_module() assert "must be less than" in str(ex) def test_update_send(self, *args): set_module_args(dict( name='asdf', send='this is another send string', partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['send'] == 'this is another send string' def test_update_receive(self, *args): set_module_args(dict( name='asdf', receive='this is another receive string', partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['receive'] == 'this is another receive string' def test_update_timeout(self, *args): set_module_args(dict( name='asdf', timeout=300, partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['timeout'] == 300 def test_update_time_until_up(self, *args): set_module_args(dict( name='asdf', time_until_up=300, partition='Common', server='localhost', password='password', user='admin' )) current = Parameters(params=load_fixture('load_ltm_monitor_https.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['time_until_up'] == 300
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 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, 646, 747, 199, 646, 2022, 199, 646, 984, 199, 646, 4613, 199, 199, 504, 11354, 14, 5265, 14, 2759, 492, 18795, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 1520, 304, 272, 746, 18795, 480, 38, 21, 2622, 4621, 4409, 2018, 2356, 499, 14, 23, 531, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 4420, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 893, 26, 272, 687, 3555, 14, 17833, 63, 7157, 63, 2859, 492, 3897, 272, 687, 3555, 14, 17833, 63, 7157, 63, 2859, 492, 24118, 272, 687, 3555, 14, 17833, 63, 7157, 63, 2859, 492, 28405, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 284, 3717, 8708, 12815, 272, 687, 511, 14, 3248, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 7157, 63, 2859, 492, 3897, 267, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 7157, 63, 2859, 492, 24118, 267, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 7157, 63, 2859, 492, 28405, 267, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 267, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 284, 3717, 8708, 12815, 267, 687, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 272, 871, 3545, 26, 267, 746, 18795, 480, 38, 21, 2622, 4621, 4409, 314, 289, 21, 13, 9277, 2018, 3555, 531, 199, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 339, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 666, 275, 289, 14, 739, 342, 339, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 26, 267, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 1379, 5976, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 578, 63, 3214, 8, 277, 304, 267, 1249, 275, 1211, 8, 288, 536, 534, 1421, 297, 288, 1676, 534, 1708, 297, 288, 3222, 534, 3749, 365, 282, 3222, 1059, 297, 288, 9128, 534, 3749, 365, 282, 9128, 1059, 297, 288, 3384, 534, 709, 14, 709, 14, 709, 14, 709, 297, 288, 1844, 29, 1257, 12, 288, 6252, 29, 1165, 12, 288, 2653, 29, 1216, 12, 288, 900, 63, 8111, 63, 384, 29, 2259, 12, 288, 6484, 534, 7844, 7, 267, 776, 398, 299, 275, 3897, 8, 1162, 29, 589, 9, 267, 702, 299, 14, 354, 508, 283, 1421, 7, 267, 702, 299, 14, 1708, 508, 1994, 7844, 15, 1708, 7, 267, 702, 299, 14, 2254, 508, 283, 3749, 365, 282, 3222, 1059, 7, 267, 702, 299, 14, 9391, 508, 283, 3749, 365, 282, 9128, 1059, 7, 267, 702, 299, 14, 711, 508, 283, 709, 14, 709, 14, 709, 14, 709, 7, 267, 702, 299, 14, 466, 508, 283, 2859, 7, 267, 702, 299, 14, 719, 508, 5939, 267, 702, 299, 14, 6881, 508, 283, 709, 14, 709, 14, 709, 14, 709, 26, 1257, 7, 267, 702, 299, 14, 4284, 508, 3388, 267, 702, 299, 14, 2593, 508, 4233, 267, 702, 299, 14, 521, 63, 8111, 63, 384, 508, 5212, 339, 347, 511, 63, 578, 63, 3214, 63, 13141, 63, 305, 63, 5465, 8, 277, 304, 267, 1249, 275, 1211, 8, 288, 536, 534, 1421, 297, 288, 1676, 534, 1708, 297, 288, 3222, 534, 3749, 365, 282, 3222, 1059, 297, 288, 9128, 534, 3749, 365, 282, 9128, 1059, 297, 288, 3384, 534, 709, 14, 709, 14, 709, 14, 709, 297, 288, 1844, 534, 1257, 297, 288, 6252, 534, 1165, 297, 288, 2653, 534, 1216, 297, 288, 900, 63, 8111, 63, 384, 534, 2259, 297, 288, 6484, 534, 7844, 7, 267, 776, 398, 299, 275, 3897, 8, 1162, 29, 589, 9, 267, 702, 299, 14, 354, 508, 283, 1421, 7, 267, 702, 299, 14, 1708, 508, 1994, 7844, 15, 1708, 7, 267, 702, 299, 14, 2254, 508, 283, 3749, 365, 282, 3222, 1059, 7, 267, 702, 299, 14, 9391, 508, 283, 3749, 365, 282, 9128, 1059, 7, 267, 702, 299, 14, 711, 508, 283, 709, 14, 709, 14, 709, 14, 709, 7, 267, 702, 299, 14, 466, 508, 283, 2859, 7, 267, 702, 299, 14, 719, 508, 5939, 267, 702, 299, 14, 6881, 508, 283, 709, 14, 709, 14, 709, 14, 709, 26, 1257, 7, 267, 702, 299, 14, 4284, 508, 3388, 267, 702, 299, 14, 2593, 508, 4233, 267, 702, 299, 14, 521, 63, 8111, 63, 384, 508, 5212, 339, 347, 511, 63, 1246, 63, 3214, 8, 277, 304, 267, 1249, 275, 1211, 8, 288, 536, 534, 1421, 297, 288, 4243, 2532, 8805, 7844, 15, 1708, 297, 288, 3222, 534, 3749, 365, 282, 3222, 1059, 297, 288, 11904, 534, 3749, 365, 282, 9128, 1059, 297, 288, 5724, 534, 709, 14, 709, 14, 709, 14, 709, 26, 1257, 297, 288, 6252, 29, 1165, 12, 288, 2653, 29, 1216, 12, 288, 900, 18667, 1721, 29 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 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, 646, 747, 199, 646, 2022, 199, 646, 984, 199, 646, 4613, 199, 199, 504, 11354, 14, 5265, 14, 2759, 492, 18795, 199, 692, 984, 14, 1023, 63, 815, 665, 334, 18, 12, 1520, 304, 272, 746, 18795, 480, 38, 21, 2622, 4621, 4409, 2018, 2356, 499, 14, 23, 531, 199, 199, 504, 3242, 14, 5819, 14, 2219, 492, 2882, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 4420, 199, 504, 3242, 14, 5819, 14, 2219, 14, 1805, 492, 3371, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 893, 26, 272, 687, 3555, 14, 17833, 63, 7157, 63, 2859, 492, 3897, 272, 687, 3555, 14, 17833, 63, 7157, 63, 2859, 492, 24118, 272, 687, 3555, 14, 17833, 63, 7157, 63, 2859, 492, 28405, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 284, 3717, 8708, 12815, 272, 687, 511, 14, 3248, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 7157, 63, 2859, 492, 3897, 267, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 7157, 63, 2859, 492, 24118, 267, 687, 3242, 14, 3112, 14, 1200, 14, 70, 21, 14, 17833, 63, 7157, 63, 2859, 492, 28405, 267, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 267, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 284, 3717, 8708, 12815, 267, 687, 6204, 14, 3112, 14, 1208, 492, 663, 63, 578, 63, 589, 272, 871, 3545, 26, 267, 746, 18795, 480, 38, 21, 2622, 4621, 4409, 314, 289, 21, 13, 9277, 2018, 3555, 531, 199, 199, 5997, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 358, 199, 5997, 63, 576, 275, 1052, 421, 199, 318, 2248, 63, 5997, 8, 354, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 5997, 63, 515, 12, 536, 9, 339, 340, 931, 315, 10949, 63, 576, 26, 267, 372, 10949, 63, 576, 59, 515, 61, 339, 543, 1551, 8, 515, 9, 465, 289, 26, 267, 666, 275, 289, 14, 739, 342, 339, 862, 26, 267, 666, 275, 2022, 14, 3640, 8, 576, 9, 272, 871, 2186, 26, 267, 986, 339, 10949, 63, 576, 59, 515, 61, 275, 666, 272, 372, 666, 421, 199, 533, 1379, 5976, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 578, 63, 3214, 8, 277, 304, 267, 1249, 275, 1211, 8, 288, 536, 534, 1421, 297, 288, 1676, 534, 1708, 297, 288, 3222, 534, 3749, 365, 282, 3222, 1059, 297, 288, 9128, 534, 3749, 365, 282, 9128, 1059, 297, 288, 3384, 534, 709, 14, 709, 14, 709, 14, 709, 297, 288, 1844, 29, 1257, 12, 288, 6252, 29, 1165, 12, 288, 2653, 29, 1216, 12, 288, 900, 63, 8111, 63, 384, 29, 2259, 12, 288, 6484, 534, 7844, 7, 267, 776, 398, 299, 275, 3897, 8, 1162, 29, 589, 9, 267, 702, 299, 14, 354, 508, 283, 1421, 7, 267, 702, 299, 14, 1708, 508, 1994, 7844, 15, 1708, 7, 267, 702, 299, 14, 2254, 508, 283, 3749, 365, 282, 3222, 1059, 7, 267, 702, 299, 14, 9391, 508, 283, 3749, 365, 282, 9128, 1059, 7, 267, 702, 299, 14, 711, 508, 283, 709, 14, 709, 14, 709, 14, 709, 7, 267, 702, 299, 14, 466, 508, 283, 2859, 7, 267, 702, 299, 14, 719, 508, 5939, 267, 702, 299, 14, 6881, 508, 283, 709, 14, 709, 14, 709, 14, 709, 26, 1257, 7, 267, 702, 299, 14, 4284, 508, 3388, 267, 702, 299, 14, 2593, 508, 4233, 267, 702, 299, 14, 521, 63, 8111, 63, 384, 508, 5212, 339, 347, 511, 63, 578, 63, 3214, 63, 13141, 63, 305, 63, 5465, 8, 277, 304, 267, 1249, 275, 1211, 8, 288, 536, 534, 1421, 297, 288, 1676, 534, 1708, 297, 288, 3222, 534, 3749, 365, 282, 3222, 1059, 297, 288, 9128, 534, 3749, 365, 282, 9128, 1059, 297, 288, 3384, 534, 709, 14, 709, 14, 709, 14, 709, 297, 288, 1844, 534, 1257, 297, 288, 6252, 534, 1165, 297, 288, 2653, 534, 1216, 297, 288, 900, 63, 8111, 63, 384, 534, 2259, 297, 288, 6484, 534, 7844, 7, 267, 776, 398, 299, 275, 3897, 8, 1162, 29, 589, 9, 267, 702, 299, 14, 354, 508, 283, 1421, 7, 267, 702, 299, 14, 1708, 508, 1994, 7844, 15, 1708, 7, 267, 702, 299, 14, 2254, 508, 283, 3749, 365, 282, 3222, 1059, 7, 267, 702, 299, 14, 9391, 508, 283, 3749, 365, 282, 9128, 1059, 7, 267, 702, 299, 14, 711, 508, 283, 709, 14, 709, 14, 709, 14, 709, 7, 267, 702, 299, 14, 466, 508, 283, 2859, 7, 267, 702, 299, 14, 719, 508, 5939, 267, 702, 299, 14, 6881, 508, 283, 709, 14, 709, 14, 709, 14, 709, 26, 1257, 7, 267, 702, 299, 14, 4284, 508, 3388, 267, 702, 299, 14, 2593, 508, 4233, 267, 702, 299, 14, 521, 63, 8111, 63, 384, 508, 5212, 339, 347, 511, 63, 1246, 63, 3214, 8, 277, 304, 267, 1249, 275, 1211, 8, 288, 536, 534, 1421, 297, 288, 4243, 2532, 8805, 7844, 15, 1708, 297, 288, 3222, 534, 3749, 365, 282, 3222, 1059, 297, 288, 11904, 534, 3749, 365, 282, 9128, 1059, 297, 288, 5724, 534, 709, 14, 709, 14, 709, 14, 709, 26, 1257, 297, 288, 6252, 29, 1165, 12, 288, 2653, 29, 1216, 12, 288, 900, 18667, 1721, 29, 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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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 ]
rtucker-mozilla/inventory
scripts/seamicro_warranty_fixes.py
2
2640
__import__('inventory_context') from systems.models import System import datetime updates = [ #["management.seamicro.phx1.mozilla.com", "3410NU000302000034", "1/6/2014"], # noqa 512 atom nodes ["seamicro-a.r101-7.console.phx1.mozilla.com", "0112NU003401000632", "2/14/2015", '1/1/2013'], # noqa 64 xeon nodes ["seamicro-b.r101-7.console.phx1.mozilla.com", "1012NU003401000646", "6/28/2015", '1/1/2013'], # noqa 64 xeon nodes ["seamicro-a.r301-3.console.phx1.mozilla.com", "1012NU003401000649", "9/27/2015", '1/1/2013'], # noqa 64 xeon nodes ["seamicro-a1.r101-3.console.scl3.mozilla.com", "4811NU003201000621", "2/1/2015", '1/1/2013'], # noqa 64 xeon nodes ["seamicro-b1.r101-3.console.scl3.mozilla.com", "4811NU003201000622", "2/1/2015", '1/1/2013'], # noqa 64 xeon nodes ["seamicro-a1.r102-3.console.scl3.mozilla.com", "1012NU003401000658", "9/27/2015", '1/1/2013'], # noqa 64 xeon nodes ["seamicro-c1.r101-3.console.scl3.mozilla.com", "1012NU003401000651", "6/28/2015", '1/1/2013'], # noqa 64 xeon nodes # 4210NU000303000047? 1/6/2014 # 512 atom nodes ] def n(name): return name.replace('console.', '') def d(date): return datetime.datetime.strptime(date, '%m/%d/%Y') s_count = 0 def set_warranty_for_chassis(chassis, warranty): ss = chassis.system_rack.systems().filter( oob_ip__icontains=chassis.oob_ip.strip('ssh').strip() ) print "Systems belonging to this chassis...." for s in ss: if not s.warranty_end: global s_count s_count += 1 print "\t%s" % s.hostname s.warranty_start, s.warranty_end = warranty s.save() def main(): for update in updates: hn, serial, warranty_end, warranty_start = ( update[0], update[1], d(update[2]), d(update[3]) ) try: s = None s = System.objects.get(hostname=hn) hostname = hn except System.DoesNotExist: pass if not s: try: s = None s = System.objects.get(hostname=n(hn)) hostname = n(hn) except System.DoesNotExist: print "No system in Inventory with hostname '%s' or '%s'" % ( hostname, n(hostname) ) continue print "Updating warranty info for %s chassis -- expires %s" % ( hostname, update[2] ) set_warranty_for_chassis(s, [warranty_start, warranty_end]) global s_count print "%s had their warranty end date set" % s_count if __name__ == '__main__': main()
bsd-3-clause
[ 363, 646, 19734, 7212, 63, 1100, 358, 199, 504, 10460, 14, 992, 492, 6187, 199, 199, 646, 2197, 199, 199, 7618, 275, 359, 272, 327, 905, 8110, 14, 261, 455, 3884, 14, 838, 88, 17, 14, 12102, 14, 957, 401, 298, 1082, 709, 1440, 1493, 8551, 993, 1082, 401, 298, 17, 15, 22, 15, 7280, 2255, 221, 327, 8151, 10574, 6222, 3380, 272, 2097, 261, 455, 3884, 13, 65, 14, 82, 4893, 13, 23, 14, 6614, 14, 838, 88, 17, 14, 12102, 14, 957, 401, 298, 614, 713, 1440, 383, 1082, 614, 20965, 708, 401, 298, 18, 15, 1079, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 66, 14, 82, 4893, 13, 23, 14, 6614, 14, 838, 88, 17, 14, 12102, 14, 957, 401, 298, 4893, 18, 1440, 383, 1082, 614, 1493, 11387, 401, 298, 22, 15, 1651, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 65, 14, 82, 8507, 13, 19, 14, 6614, 14, 838, 88, 17, 14, 12102, 14, 957, 401, 298, 4893, 18, 1440, 383, 1082, 614, 1493, 11228, 401, 298, 25, 15, 1465, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 65, 17, 14, 82, 4893, 13, 19, 14, 6614, 14, 83, 429, 19, 14, 12102, 14, 957, 401, 298, 2006, 845, 1440, 30867, 614, 20965, 2025, 401, 298, 18, 15, 17, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 66, 17, 14, 82, 4893, 13, 19, 14, 6614, 14, 83, 429, 19, 14, 12102, 14, 957, 401, 298, 2006, 845, 1440, 30867, 614, 20965, 1081, 401, 298, 18, 15, 17, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 65, 17, 14, 82, 7759, 13, 19, 14, 6614, 14, 83, 429, 19, 14, 12102, 14, 957, 401, 298, 4893, 18, 1440, 383, 1082, 614, 20965, 2010, 401, 298, 25, 15, 1465, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 67, 17, 14, 82, 4893, 13, 19, 14, 6614, 14, 83, 429, 19, 14, 12102, 14, 957, 401, 298, 4893, 18, 1440, 383, 1082, 614, 1493, 25459, 401, 298, 22, 15, 1651, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 327, 5685, 709, 1440, 1493, 11810, 993, 2417, 31, 413, 15, 22, 15, 7280, 221, 327, 10574, 6222, 3380, 199, 61, 421, 199, 318, 302, 8, 354, 304, 272, 372, 536, 14, 1814, 360, 6614, 3130, 4074, 421, 199, 318, 366, 8, 602, 304, 272, 372, 2197, 14, 2083, 14, 9866, 8, 602, 12, 1543, 77, 3149, 68, 3149, 57, 358, 199, 199, 83, 63, 835, 275, 378, 421, 199, 318, 663, 63, 3281, 1312, 369, 63, 509, 63, 31187, 8, 31187, 12, 3750, 304, 272, 10110, 275, 682, 20743, 14, 2253, 63, 8085, 14, 19135, 1252, 1541, 8, 267, 312, 2873, 63, 711, 363, 30314, 29, 31187, 14, 25189, 63, 711, 14, 1913, 360, 5510, 1959, 1913, 342, 272, 776, 272, 870, 298, 3989, 83, 30226, 370, 642, 682, 20743, 4496, 2, 272, 367, 308, 315, 10110, 26, 267, 340, 440, 308, 14, 3281, 1312, 369, 63, 500, 26, 288, 2288, 308, 63, 835, 288, 308, 63, 835, 847, 413, 398, 870, 1867, 84, 5, 83, 2, 450, 308, 14, 4269, 267, 308, 14, 3281, 1312, 369, 63, 928, 12, 308, 14, 3281, 1312, 369, 63, 500, 275, 3750, 267, 308, 14, 2117, 342, 421, 199, 318, 2446, 837, 272, 367, 1678, 315, 7029, 26, 267, 394, 78, 12, 3012, 12, 3750, 63, 500, 12, 3750, 63, 928, 275, 334, 288, 1678, 59, 16, 467, 1678, 59, 17, 467, 366, 8, 873, 59, 18, 2522, 366, 8, 873, 59, 19, 566, 267, 776, 398, 862, 26, 288, 308, 275, 488, 288, 308, 275, 6187, 14, 1462, 14, 362, 8, 4269, 29, 6164, 9, 288, 6246, 275, 394, 78, 267, 871, 6187, 14, 7400, 26, 288, 986, 398, 340, 440, 308, 26, 288, 862, 26, 355, 308, 275, 488, 355, 308, 275, 6187, 14, 1462, 14, 362, 8, 4269, 29, 78, 8, 6164, 430, 355, 6246, 275, 302, 8, 6164, 9, 288, 871, 6187, 14, 7400, 26, 355, 870, 298, 1944, 2656, 315, 19337, 543, 6246, 1543, 83, 7, 503, 1543, 83, 4065, 450, 334, 490, 6246, 12, 302, 8, 4269, 9, 355, 776, 355, 1980, 398, 870, 298, 24993, 3750, 2256, 367, 450, 83, 682, 20743, 1553, 12261, 450, 83, 2, 450, 334, 288, 6246, 12, 1678, 59, 18, 61, 267, 776, 267, 663, 63, 3281, 1312, 369, 63, 509, 63, 31187, 8, 83, 12, 359, 3281, 1312, 369, 63, 928, 12, 3750, 63, 500, 566, 272, 2288, 308, 63, 835, 272, 870, 2071, 83, 10530, 3932, 3750, 1284, 1434, 663, 2, 450, 308, 63, 835, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 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 ]
[ 646, 19734, 7212, 63, 1100, 358, 199, 504, 10460, 14, 992, 492, 6187, 199, 199, 646, 2197, 199, 199, 7618, 275, 359, 272, 327, 905, 8110, 14, 261, 455, 3884, 14, 838, 88, 17, 14, 12102, 14, 957, 401, 298, 1082, 709, 1440, 1493, 8551, 993, 1082, 401, 298, 17, 15, 22, 15, 7280, 2255, 221, 327, 8151, 10574, 6222, 3380, 272, 2097, 261, 455, 3884, 13, 65, 14, 82, 4893, 13, 23, 14, 6614, 14, 838, 88, 17, 14, 12102, 14, 957, 401, 298, 614, 713, 1440, 383, 1082, 614, 20965, 708, 401, 298, 18, 15, 1079, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 66, 14, 82, 4893, 13, 23, 14, 6614, 14, 838, 88, 17, 14, 12102, 14, 957, 401, 298, 4893, 18, 1440, 383, 1082, 614, 1493, 11387, 401, 298, 22, 15, 1651, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 65, 14, 82, 8507, 13, 19, 14, 6614, 14, 838, 88, 17, 14, 12102, 14, 957, 401, 298, 4893, 18, 1440, 383, 1082, 614, 1493, 11228, 401, 298, 25, 15, 1465, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 65, 17, 14, 82, 4893, 13, 19, 14, 6614, 14, 83, 429, 19, 14, 12102, 14, 957, 401, 298, 2006, 845, 1440, 30867, 614, 20965, 2025, 401, 298, 18, 15, 17, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 66, 17, 14, 82, 4893, 13, 19, 14, 6614, 14, 83, 429, 19, 14, 12102, 14, 957, 401, 298, 2006, 845, 1440, 30867, 614, 20965, 1081, 401, 298, 18, 15, 17, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 65, 17, 14, 82, 7759, 13, 19, 14, 6614, 14, 83, 429, 19, 14, 12102, 14, 957, 401, 298, 4893, 18, 1440, 383, 1082, 614, 20965, 2010, 401, 298, 25, 15, 1465, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 2097, 261, 455, 3884, 13, 67, 17, 14, 82, 4893, 13, 19, 14, 6614, 14, 83, 429, 19, 14, 12102, 14, 957, 401, 298, 4893, 18, 1440, 383, 1082, 614, 1493, 25459, 401, 298, 22, 15, 1651, 15, 7806, 401, 283, 17, 15, 17, 15, 6965, 995, 221, 327, 8151, 5049, 671, 69, 265, 3380, 272, 327, 5685, 709, 1440, 1493, 11810, 993, 2417, 31, 413, 15, 22, 15, 7280, 221, 327, 10574, 6222, 3380, 199, 61, 421, 199, 318, 302, 8, 354, 304, 272, 372, 536, 14, 1814, 360, 6614, 3130, 4074, 421, 199, 318, 366, 8, 602, 304, 272, 372, 2197, 14, 2083, 14, 9866, 8, 602, 12, 1543, 77, 3149, 68, 3149, 57, 358, 199, 199, 83, 63, 835, 275, 378, 421, 199, 318, 663, 63, 3281, 1312, 369, 63, 509, 63, 31187, 8, 31187, 12, 3750, 304, 272, 10110, 275, 682, 20743, 14, 2253, 63, 8085, 14, 19135, 1252, 1541, 8, 267, 312, 2873, 63, 711, 363, 30314, 29, 31187, 14, 25189, 63, 711, 14, 1913, 360, 5510, 1959, 1913, 342, 272, 776, 272, 870, 298, 3989, 83, 30226, 370, 642, 682, 20743, 4496, 2, 272, 367, 308, 315, 10110, 26, 267, 340, 440, 308, 14, 3281, 1312, 369, 63, 500, 26, 288, 2288, 308, 63, 835, 288, 308, 63, 835, 847, 413, 398, 870, 1867, 84, 5, 83, 2, 450, 308, 14, 4269, 267, 308, 14, 3281, 1312, 369, 63, 928, 12, 308, 14, 3281, 1312, 369, 63, 500, 275, 3750, 267, 308, 14, 2117, 342, 421, 199, 318, 2446, 837, 272, 367, 1678, 315, 7029, 26, 267, 394, 78, 12, 3012, 12, 3750, 63, 500, 12, 3750, 63, 928, 275, 334, 288, 1678, 59, 16, 467, 1678, 59, 17, 467, 366, 8, 873, 59, 18, 2522, 366, 8, 873, 59, 19, 566, 267, 776, 398, 862, 26, 288, 308, 275, 488, 288, 308, 275, 6187, 14, 1462, 14, 362, 8, 4269, 29, 6164, 9, 288, 6246, 275, 394, 78, 267, 871, 6187, 14, 7400, 26, 288, 986, 398, 340, 440, 308, 26, 288, 862, 26, 355, 308, 275, 488, 355, 308, 275, 6187, 14, 1462, 14, 362, 8, 4269, 29, 78, 8, 6164, 430, 355, 6246, 275, 302, 8, 6164, 9, 288, 871, 6187, 14, 7400, 26, 355, 870, 298, 1944, 2656, 315, 19337, 543, 6246, 1543, 83, 7, 503, 1543, 83, 4065, 450, 334, 490, 6246, 12, 302, 8, 4269, 9, 355, 776, 355, 1980, 398, 870, 298, 24993, 3750, 2256, 367, 450, 83, 682, 20743, 1553, 12261, 450, 83, 2, 450, 334, 288, 6246, 12, 1678, 59, 18, 61, 267, 776, 267, 663, 63, 3281, 1312, 369, 63, 509, 63, 31187, 8, 83, 12, 359, 3281, 1312, 369, 63, 928, 12, 3750, 63, 500, 566, 272, 2288, 308, 63, 835, 272, 870, 2071, 83, 10530, 3932, 3750, 1284, 1434, 663, 2, 450, 308, 63, 835, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 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,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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 ]
hfaran/ubc-timetabler
timetabler/schedule.py
1
4430
import tempfile import os from uuid import uuid4 from prettytable import PrettyTable from timetabler.util import iter_time, DAY_LIST class Schedule(object): def __init__(self, sched): """Schedule e.g. for ``sched``: ((Lab<status='Restricted', section='EECE 381 L2A', term='2', days='[u'Tue', u'Thu']', start_time='16:00', end_time='19:00'>, Lecture<status='Restricted', section='EECE 381 201', term='2', days='[u'Mon']', start_time='9:00', end_time='11:00'>), (Lab<status='Restricted', section='EECE 353 L2C', term='2', days='[u'Thu']', start_time='14:00', end_time='16:00'>, Lecture<status='', section='EECE 353 201', term='2', days='[u'Tue', u'Thu']', start_time='14:00', end_time='15:30'>), (Lecture<status='', section='CPSC 304 201', term='2', days='[u'Tue', u'Thu']', start_time='11:00', end_time='12:30'>, Tutorial<status='', section='CPSC 304 T2A', term='2', days='[u'Fri']', start_time='14:00', end_time='15:00'>)) """ self._sched = sched self.activities = [act for crs in sched for act in crs] def activities_for_day(self, day): return [a for a in self.activities if day in a.days] def activity_at_time(self, time="09:00", day="Mon", term=1): res = [a for a in self.activities if all([ a.start_time <= time, a.end_time > time, day in a.days, term == a.term ])] assert len(res) in [0, 1], ("More than one activity found at specified time. " "This likely means the code is wrong.") if res: return res[0] else: return None def _draw(self, term=1): t = PrettyTable(["Time"] + DAY_LIST) earliest_start_time = min(a.start_time for a in self.activities) latest_end_time = max(a.end_time for a in self.activities) time_iter = iter_time(earliest_start_time, latest_end_time) for time in time_iter: t.add_row([time] + [getattr(self.activity_at_time(time, day, term), 'section', "") for day in DAY_LIST]) return t def _create_table_div(self, table): return "\n{}\n{}\n{}\n".format( '<div class="CSSTableGenerator">', table.get_html_string(), '</div>' ) def draw(self, terms=(1,), draw_location="browser", title_format="code"): """Draw schedule :type terms: tuple or list :param term: Terms for which you would like to draw the schedule :param draw_location: "browser"|"terminal" :param title_format: "title"|"code" :returns: List of tables :rtype: list """ assert draw_location in ["browser", "terminal"] tables = {term: self._draw(term) for term in terms} if draw_location=="browser": tempdir = tempfile.gettempdir() tempfile_loc = os.path.join(tempdir, "ubc-timetabler_{}.html".format(uuid4().hex)) with open(tempfile_loc, 'w+') as f: html = "{}{}{}".format( """<html> <head> <!-- Bring to you by http://www.CSSTableGenerator.com --> <link rel="stylesheet" \ href="https://raw.githubusercontent.com/hfaran/ubc-timetabler/master/css/table.css" \ type="text/css"/> </head> <body> """, "</br></br></br>\n".join(map(self._create_table_div, tables.itervalues())), """ </body> </html>""" ) f.write(html) import webbrowser webbrowser.open('file://' + os.path.realpath(tempfile_loc)) elif draw_location=="terminal": for term, table in tables.iteritems(): title_formatters = { "title": lambda act: act.course.title, "code": lambda act: "{} {}".format(act.course.dept, act.course.number) } print("Courses for Term {}: {}".format( term, ", ".join({title_formatters[title_format](act) for act in self.activities if act.term == term}) )) print(table) return tables
mit
[ 646, 5549, 199, 646, 747, 199, 504, 5377, 492, 5377, 20, 199, 199, 504, 7268, 1224, 492, 31651, 3186, 199, 199, 504, 900, 1224, 82, 14, 1974, 492, 2740, 63, 521, 12, 577, 3448, 63, 4924, 421, 199, 533, 24317, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10286, 304, 267, 408, 15535, 398, 325, 14, 71, 14, 367, 1124, 10487, 18983, 267, 3666, 22511, 28, 1205, 534, 28850, 297, 3420, 534, 8699, 2089, 650, 2835, 491, 18, 33, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 52, 310, 297, 399, 7, 2719, 85, 418, 297, 1343, 63, 521, 534, 975, 26, 383, 297, 1284, 63, 521, 534, 1167, 26, 383, 7, 6244, 881, 491, 449, 608, 28, 1205, 534, 28850, 297, 3420, 534, 8699, 2089, 650, 2835, 1784, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 6671, 418, 297, 1343, 63, 521, 534, 25, 26, 383, 297, 1284, 63, 521, 534, 845, 26, 383, 8423, 395, 268, 334, 22511, 28, 1205, 534, 28850, 297, 3420, 534, 8699, 2089, 650, 2481, 491, 18, 35, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 2719, 85, 418, 297, 1343, 63, 521, 534, 1079, 26, 383, 297, 1284, 63, 521, 534, 975, 26, 383, 7, 6244, 881, 491, 449, 608, 28, 1205, 4581, 3420, 534, 8699, 2089, 650, 2481, 1784, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 52, 310, 297, 399, 7, 2719, 85, 418, 297, 1343, 63, 521, 534, 1079, 26, 383, 297, 1284, 63, 521, 534, 1046, 26, 1216, 8423, 395, 268, 334, 44, 449, 608, 28, 1205, 4581, 3420, 534, 2890, 5153, 20398, 1784, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 52, 310, 297, 399, 7, 2719, 85, 418, 297, 1343, 63, 521, 534, 845, 26, 383, 297, 1284, 63, 521, 534, 713, 26, 1216, 7, 6244, 881, 377, 15888, 28, 1205, 4581, 3420, 534, 2890, 5153, 20398, 377, 18, 33, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 22533, 418, 297, 1343, 63, 521, 534, 1079, 26, 383, 297, 1284, 63, 521, 534, 1046, 26, 383, 8423, 430, 267, 408, 267, 291, 423, 10487, 275, 10286, 267, 291, 14, 27442, 275, 359, 2442, 367, 32313, 315, 10286, 367, 2454, 315, 32313, 61, 339, 347, 30744, 63, 509, 63, 2977, 8, 277, 12, 5382, 304, 267, 372, 359, 65, 367, 282, 315, 291, 14, 27442, 340, 5382, 315, 282, 14, 4899, 61, 339, 347, 10679, 63, 292, 63, 521, 8, 277, 12, 900, 628, 1643, 26, 383, 401, 5382, 628, 6671, 401, 6707, 29, 17, 304, 267, 522, 275, 359, 65, 367, 282, 315, 291, 14, 27442, 340, 1006, 779, 288, 282, 14, 928, 63, 521, 2695, 900, 12, 288, 282, 14, 500, 63, 521, 690, 900, 12, 288, 5382, 315, 282, 14, 4899, 12, 288, 6707, 508, 282, 14, 5125, 267, 4794, 61, 267, 702, 822, 8, 470, 9, 315, 359, 16, 12, 413, 467, 1689, 11053, 2419, 1373, 10679, 1911, 737, 2013, 900, 14, 298, 2511, 298, 2765, 12060, 4910, 314, 1233, 365, 6835, 2685, 267, 340, 522, 26, 288, 372, 522, 59, 16, 61, 267, 587, 26, 288, 372, 488, 339, 347, 485, 5485, 8, 277, 12, 6707, 29, 17, 304, 267, 307, 275, 31651, 3186, 5234, 1366, 937, 435, 577, 3448, 63, 4924, 9, 267, 8413, 24951, 63, 928, 63, 521, 275, 1748, 8, 65, 14, 928, 63, 521, 367, 282, 315, 291, 14, 27442, 9, 267, 8839, 63, 500, 63, 521, 275, 1390, 8, 65, 14, 500, 63, 521, 367, 282, 315, 291, 14, 27442, 9, 267, 900, 63, 1661, 275, 2740, 63, 521, 8, 2210, 24951, 63, 928, 63, 521, 12, 8839, 63, 500, 63, 521, 9, 267, 367, 900, 315, 900, 63, 1661, 26, 288, 307, 14, 525, 63, 1143, 779, 521, 61, 435, 359, 5675, 8, 277, 14, 8240, 63, 292, 63, 521, 8, 521, 12, 5382, 12, 6707, 395, 283, 2792, 297, 6899, 367, 5382, 315, 577, 3448, 63, 4924, 566, 267, 372, 307, 339, 347, 485, 981, 63, 1224, 63, 3015, 8, 277, 12, 1817, 304, 267, 372, 1867, 78, 24423, 78, 24423, 78, 24423, 78, 1674, 908, 8, 288, 2650, 3015, 1021, 628, 3298, 840, 461, 7599, 1743, 297, 288, 1817, 14, 362, 63, 1360, 63, 875, 1062, 288, 11936, 3015, 3524, 267, 776, 339, 347, 5954, 8, 277, 12, 2895, 2687, 17, 4706, 5954, 63, 1985, 628, 5750, 401, 2538, 63, 908, 628, 600, 2349, 267, 408, 9654, 8732, 398, 520, 466, 2895, 26, 2008, 503, 769, 267, 520, 635, 6707, 26, 13861, 706, 367, 1314, 1265, 3955, 2839, 370, 5954, 314, 8732, 267, 520, 635, 5954, 63, 1985, 26, 298, 5750, 2, 25576, 12010, 2, 267, 520, 635, 2538, 63, 908, 26, 298, 1213, 2, 25576, 600, 2, 267, 520, 5808, 26, 3820, 402, 6716, 267, 520, 4500, 26, 769, 267, 408, 267, 702, 5954, 63, 1985, 315, 2097, 5750, 401, 298, 12010, 937, 267, 6716, 275, 469, 5125, 26, 291, 423, 5485, 8, 5125, 9, 367, 6707, 315, 2895, 93, 267, 340, 5954, 63, 1985, 11800, 5750, 582, 288, 21628, 275, 5549, 14, 31572, 342, 288, 5549, 63, 2102, 275, 747, 14, 515, 14, 904, 8, 11567, 12, 298, 9870, 13, 521, 1224, 82, 24306, 14, 1360, 1674, 908, 8, 2580, 20, 1252, 4097, 430, 288, 543, 1551, 8, 17336, 63, 2102, 12, 283, 87, 13854, 465, 289, 26, 355, 3517, 275, 11491, 2440, 13536, 908, 8, 355, 8894, 1360, 30, 4951, 665, 2993, 30, 717, 28253, 699, 5985, 370, 1265, 701, 1455, 921, 1544, 14, 3298, 840, 461, 7599, 14, 957, 10541, 717, 665, 1073, 4668, 628, 15479, 2, 971, 717, 4369, 628, 2859, 921, 1773, 14, 5031, 751, 1317, 14, 957, 15, 9188, 285, 290, 15, 9870, 13, 521, 1224, 82, 15, 4133, 15, 3919, 15, 1224, 14, 3919, 2, 971, 717, 730, 628, 505, 15, 3919, 7897, 490, 3068, 2993, 30, 4951, 665, 2030, 30, 490, 10327, 355, 15683, 3289, 2957, 3289, 2957, 3289, 3072, 78, 1674, 904, 8, 1130, 8, 277, 423, 981, 63, 1224, 63, 3015, 12, 6716, 14, 13012, 22606, 355, 408, 490, 3068, 2030, 30, 2234, 3068, 1360, 11193, 355, 776, 355, 289 ]
[ 5549, 199, 646, 747, 199, 504, 5377, 492, 5377, 20, 199, 199, 504, 7268, 1224, 492, 31651, 3186, 199, 199, 504, 900, 1224, 82, 14, 1974, 492, 2740, 63, 521, 12, 577, 3448, 63, 4924, 421, 199, 533, 24317, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10286, 304, 267, 408, 15535, 398, 325, 14, 71, 14, 367, 1124, 10487, 18983, 267, 3666, 22511, 28, 1205, 534, 28850, 297, 3420, 534, 8699, 2089, 650, 2835, 491, 18, 33, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 52, 310, 297, 399, 7, 2719, 85, 418, 297, 1343, 63, 521, 534, 975, 26, 383, 297, 1284, 63, 521, 534, 1167, 26, 383, 7, 6244, 881, 491, 449, 608, 28, 1205, 534, 28850, 297, 3420, 534, 8699, 2089, 650, 2835, 1784, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 6671, 418, 297, 1343, 63, 521, 534, 25, 26, 383, 297, 1284, 63, 521, 534, 845, 26, 383, 8423, 395, 268, 334, 22511, 28, 1205, 534, 28850, 297, 3420, 534, 8699, 2089, 650, 2481, 491, 18, 35, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 2719, 85, 418, 297, 1343, 63, 521, 534, 1079, 26, 383, 297, 1284, 63, 521, 534, 975, 26, 383, 7, 6244, 881, 491, 449, 608, 28, 1205, 4581, 3420, 534, 8699, 2089, 650, 2481, 1784, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 52, 310, 297, 399, 7, 2719, 85, 418, 297, 1343, 63, 521, 534, 1079, 26, 383, 297, 1284, 63, 521, 534, 1046, 26, 1216, 8423, 395, 268, 334, 44, 449, 608, 28, 1205, 4581, 3420, 534, 2890, 5153, 20398, 1784, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 52, 310, 297, 399, 7, 2719, 85, 418, 297, 1343, 63, 521, 534, 845, 26, 383, 297, 1284, 63, 521, 534, 713, 26, 1216, 7, 6244, 881, 377, 15888, 28, 1205, 4581, 3420, 534, 2890, 5153, 20398, 377, 18, 33, 297, 6707, 534, 18, 297, 7609, 30845, 85, 7, 22533, 418, 297, 1343, 63, 521, 534, 1079, 26, 383, 297, 1284, 63, 521, 534, 1046, 26, 383, 8423, 430, 267, 408, 267, 291, 423, 10487, 275, 10286, 267, 291, 14, 27442, 275, 359, 2442, 367, 32313, 315, 10286, 367, 2454, 315, 32313, 61, 339, 347, 30744, 63, 509, 63, 2977, 8, 277, 12, 5382, 304, 267, 372, 359, 65, 367, 282, 315, 291, 14, 27442, 340, 5382, 315, 282, 14, 4899, 61, 339, 347, 10679, 63, 292, 63, 521, 8, 277, 12, 900, 628, 1643, 26, 383, 401, 5382, 628, 6671, 401, 6707, 29, 17, 304, 267, 522, 275, 359, 65, 367, 282, 315, 291, 14, 27442, 340, 1006, 779, 288, 282, 14, 928, 63, 521, 2695, 900, 12, 288, 282, 14, 500, 63, 521, 690, 900, 12, 288, 5382, 315, 282, 14, 4899, 12, 288, 6707, 508, 282, 14, 5125, 267, 4794, 61, 267, 702, 822, 8, 470, 9, 315, 359, 16, 12, 413, 467, 1689, 11053, 2419, 1373, 10679, 1911, 737, 2013, 900, 14, 298, 2511, 298, 2765, 12060, 4910, 314, 1233, 365, 6835, 2685, 267, 340, 522, 26, 288, 372, 522, 59, 16, 61, 267, 587, 26, 288, 372, 488, 339, 347, 485, 5485, 8, 277, 12, 6707, 29, 17, 304, 267, 307, 275, 31651, 3186, 5234, 1366, 937, 435, 577, 3448, 63, 4924, 9, 267, 8413, 24951, 63, 928, 63, 521, 275, 1748, 8, 65, 14, 928, 63, 521, 367, 282, 315, 291, 14, 27442, 9, 267, 8839, 63, 500, 63, 521, 275, 1390, 8, 65, 14, 500, 63, 521, 367, 282, 315, 291, 14, 27442, 9, 267, 900, 63, 1661, 275, 2740, 63, 521, 8, 2210, 24951, 63, 928, 63, 521, 12, 8839, 63, 500, 63, 521, 9, 267, 367, 900, 315, 900, 63, 1661, 26, 288, 307, 14, 525, 63, 1143, 779, 521, 61, 435, 359, 5675, 8, 277, 14, 8240, 63, 292, 63, 521, 8, 521, 12, 5382, 12, 6707, 395, 283, 2792, 297, 6899, 367, 5382, 315, 577, 3448, 63, 4924, 566, 267, 372, 307, 339, 347, 485, 981, 63, 1224, 63, 3015, 8, 277, 12, 1817, 304, 267, 372, 1867, 78, 24423, 78, 24423, 78, 24423, 78, 1674, 908, 8, 288, 2650, 3015, 1021, 628, 3298, 840, 461, 7599, 1743, 297, 288, 1817, 14, 362, 63, 1360, 63, 875, 1062, 288, 11936, 3015, 3524, 267, 776, 339, 347, 5954, 8, 277, 12, 2895, 2687, 17, 4706, 5954, 63, 1985, 628, 5750, 401, 2538, 63, 908, 628, 600, 2349, 267, 408, 9654, 8732, 398, 520, 466, 2895, 26, 2008, 503, 769, 267, 520, 635, 6707, 26, 13861, 706, 367, 1314, 1265, 3955, 2839, 370, 5954, 314, 8732, 267, 520, 635, 5954, 63, 1985, 26, 298, 5750, 2, 25576, 12010, 2, 267, 520, 635, 2538, 63, 908, 26, 298, 1213, 2, 25576, 600, 2, 267, 520, 5808, 26, 3820, 402, 6716, 267, 520, 4500, 26, 769, 267, 408, 267, 702, 5954, 63, 1985, 315, 2097, 5750, 401, 298, 12010, 937, 267, 6716, 275, 469, 5125, 26, 291, 423, 5485, 8, 5125, 9, 367, 6707, 315, 2895, 93, 267, 340, 5954, 63, 1985, 11800, 5750, 582, 288, 21628, 275, 5549, 14, 31572, 342, 288, 5549, 63, 2102, 275, 747, 14, 515, 14, 904, 8, 11567, 12, 298, 9870, 13, 521, 1224, 82, 24306, 14, 1360, 1674, 908, 8, 2580, 20, 1252, 4097, 430, 288, 543, 1551, 8, 17336, 63, 2102, 12, 283, 87, 13854, 465, 289, 26, 355, 3517, 275, 11491, 2440, 13536, 908, 8, 355, 8894, 1360, 30, 4951, 665, 2993, 30, 717, 28253, 699, 5985, 370, 1265, 701, 1455, 921, 1544, 14, 3298, 840, 461, 7599, 14, 957, 10541, 717, 665, 1073, 4668, 628, 15479, 2, 971, 717, 4369, 628, 2859, 921, 1773, 14, 5031, 751, 1317, 14, 957, 15, 9188, 285, 290, 15, 9870, 13, 521, 1224, 82, 15, 4133, 15, 3919, 15, 1224, 14, 3919, 2, 971, 717, 730, 628, 505, 15, 3919, 7897, 490, 3068, 2993, 30, 4951, 665, 2030, 30, 490, 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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 ]
agry/NGECore2
scripts/mobiles/naboo/plains_hunter.py
2
1623
import sys from services.spawn import MobileTemplate from services.spawn import WeaponTemplate from resources.datatables import WeaponType from resources.datatables import Difficulty from resources.datatables import Options from java.util import Vector def addTemplate(core): mobileTemplate = MobileTemplate() mobileTemplate.setCreatureName('plains_hunter') mobileTemplate.setLevel(31) mobileTemplate.setDifficulty(Difficulty.NORMAL) mobileTemplate.setMinSpawnDistance(4) mobileTemplate.setMaxSpawnDistance(8) mobileTemplate.setDeathblow(False) mobileTemplate.setScale(1) mobileTemplate.setMeatType("Carnivore Meat") mobileTemplate.setMeatAmount(65) mobileTemplate.setHideType("Bristly Hide") mobileTemplate.setHideAmount(35) mobileTemplate.setBoneType("Animal Bones") mobileTemplate.setBoneAmount(30) mobileTemplate.setSocialGroup("self") mobileTemplate.setAssistRange(2) mobileTemplate.setStalker(False) mobileTemplate.setOptionsBitmask(Options.AGGRESSIVE | Options.ATTACKABLE) templates = Vector() templates.add('object/mobile/shared_tusk_cat_hue.iff') mobileTemplate.setTemplates(templates) weaponTemplates = Vector() weapontemplate = WeaponTemplate('object/weapon/melee/unarmed/shared_unarmed_default.iff', WeaponType.UNARMED, 1.0, 6, 'kinetic') weaponTemplates.add(weapontemplate) mobileTemplate.setWeaponTemplateVector(weaponTemplates) attacks = Vector() attacks.add('bm_claw_2') attacks.add('bm_slash_2') mobileTemplate.setDefaultAttack('creatureMeleeAttack') mobileTemplate.setAttacks(attacks) core.spawnService.addMobileTemplate('plains_hunter', mobileTemplate) return
lgpl-3.0
[ 646, 984, 199, 504, 8500, 14, 10212, 492, 29724, 4231, 199, 504, 8500, 14, 10212, 492, 2136, 21921, 4231, 199, 504, 5944, 14, 4616, 292, 5921, 492, 2136, 21921, 804, 199, 504, 5944, 14, 4616, 292, 5921, 492, 577, 692, 24161, 199, 504, 5944, 14, 4616, 292, 5921, 492, 8394, 199, 504, 12120, 14, 1974, 492, 11388, 421, 199, 318, 1050, 4231, 8, 1018, 304, 199, 198, 27339, 275, 29724, 4231, 342, 8299, 198, 27339, 14, 409, 5482, 1463, 985, 360, 80, 416, 3617, 63, 72, 7867, 358, 199, 198, 27339, 14, 13548, 8, 2192, 9, 199, 198, 27339, 14, 409, 36, 692, 24161, 8, 36, 692, 24161, 14, 10765, 9, 421, 198, 27339, 14, 409, 4649, 12739, 3501, 10076, 8, 20, 9, 199, 198, 27339, 14, 409, 4261, 12739, 3501, 10076, 8, 24, 9, 199, 198, 27339, 14, 409, 31577, 66, 674, 8, 797, 9, 199, 198, 27339, 14, 409, 9944, 8, 17, 9, 199, 198, 27339, 14, 409, 1352, 292, 804, 480, 35, 1060, 1003, 720, 3194, 292, 531, 199, 198, 27339, 14, 409, 1352, 292, 18785, 8, 2182, 9, 199, 198, 27339, 14, 409, 18224, 804, 480, 34, 18824, 590, 869, 2655, 531, 199, 198, 27339, 14, 409, 18224, 18785, 8, 1276, 9, 199, 198, 27339, 14, 409, 34, 368, 804, 480, 2493, 7265, 699, 4548, 531, 199, 198, 27339, 14, 409, 34, 368, 18785, 8, 1216, 9, 199, 198, 27339, 14, 409, 31356, 2448, 480, 277, 531, 199, 198, 27339, 14, 409, 2822, 11734, 4709, 8, 18, 9, 199, 198, 27339, 14, 409, 933, 14976, 8, 797, 9, 199, 198, 27339, 14, 409, 4558, 4734, 2629, 8, 4558, 14, 1254, 19568, 5399, 1204, 8394, 14, 11712, 3099, 2617, 9, 8299, 198, 5876, 275, 11388, 342, 199, 198, 5876, 14, 525, 360, 785, 15, 11375, 15, 5555, 63, 84, 527, 75, 63, 3385, 63, 25016, 14, 15126, 358, 199, 198, 27339, 14, 409, 17969, 8, 5876, 9, 8299, 198, 30804, 17969, 275, 11388, 342, 199, 198, 30804, 1160, 275, 2136, 21921, 4231, 360, 785, 15, 30804, 15, 278, 18387, 15, 324, 285, 3594, 15, 5555, 63, 324, 285, 3594, 63, 885, 14, 15126, 297, 2136, 21921, 804, 14, 1734, 12482, 1149, 12, 413, 14, 16, 12, 1227, 12, 283, 75, 1132, 764, 358, 199, 198, 30804, 17969, 14, 525, 8, 30804, 1160, 9, 199, 198, 27339, 14, 409, 6004, 21921, 4231, 3646, 8, 30804, 17969, 9, 8299, 198, 292, 21807, 275, 11388, 342, 199, 198, 292, 21807, 14, 525, 360, 12648, 63, 3995, 87, 63, 18, 358, 199, 198, 292, 21807, 14, 525, 360, 12648, 63, 7001, 63, 18, 358, 199, 198, 27339, 14, 409, 2698, 1271, 13058, 360, 1353, 1463, 1352, 18387, 1271, 13058, 358, 199, 198, 27339, 14, 409, 1271, 21807, 8, 292, 21807, 9, 8299, 198, 1018, 14, 10212, 3167, 14, 525, 27245, 4231, 360, 80, 416, 3617, 63, 72, 7867, 297, 21305, 4231, 9, 199, 198, 1107, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 984, 199, 504, 8500, 14, 10212, 492, 29724, 4231, 199, 504, 8500, 14, 10212, 492, 2136, 21921, 4231, 199, 504, 5944, 14, 4616, 292, 5921, 492, 2136, 21921, 804, 199, 504, 5944, 14, 4616, 292, 5921, 492, 577, 692, 24161, 199, 504, 5944, 14, 4616, 292, 5921, 492, 8394, 199, 504, 12120, 14, 1974, 492, 11388, 421, 199, 318, 1050, 4231, 8, 1018, 304, 199, 198, 27339, 275, 29724, 4231, 342, 8299, 198, 27339, 14, 409, 5482, 1463, 985, 360, 80, 416, 3617, 63, 72, 7867, 358, 199, 198, 27339, 14, 13548, 8, 2192, 9, 199, 198, 27339, 14, 409, 36, 692, 24161, 8, 36, 692, 24161, 14, 10765, 9, 421, 198, 27339, 14, 409, 4649, 12739, 3501, 10076, 8, 20, 9, 199, 198, 27339, 14, 409, 4261, 12739, 3501, 10076, 8, 24, 9, 199, 198, 27339, 14, 409, 31577, 66, 674, 8, 797, 9, 199, 198, 27339, 14, 409, 9944, 8, 17, 9, 199, 198, 27339, 14, 409, 1352, 292, 804, 480, 35, 1060, 1003, 720, 3194, 292, 531, 199, 198, 27339, 14, 409, 1352, 292, 18785, 8, 2182, 9, 199, 198, 27339, 14, 409, 18224, 804, 480, 34, 18824, 590, 869, 2655, 531, 199, 198, 27339, 14, 409, 18224, 18785, 8, 1276, 9, 199, 198, 27339, 14, 409, 34, 368, 804, 480, 2493, 7265, 699, 4548, 531, 199, 198, 27339, 14, 409, 34, 368, 18785, 8, 1216, 9, 199, 198, 27339, 14, 409, 31356, 2448, 480, 277, 531, 199, 198, 27339, 14, 409, 2822, 11734, 4709, 8, 18, 9, 199, 198, 27339, 14, 409, 933, 14976, 8, 797, 9, 199, 198, 27339, 14, 409, 4558, 4734, 2629, 8, 4558, 14, 1254, 19568, 5399, 1204, 8394, 14, 11712, 3099, 2617, 9, 8299, 198, 5876, 275, 11388, 342, 199, 198, 5876, 14, 525, 360, 785, 15, 11375, 15, 5555, 63, 84, 527, 75, 63, 3385, 63, 25016, 14, 15126, 358, 199, 198, 27339, 14, 409, 17969, 8, 5876, 9, 8299, 198, 30804, 17969, 275, 11388, 342, 199, 198, 30804, 1160, 275, 2136, 21921, 4231, 360, 785, 15, 30804, 15, 278, 18387, 15, 324, 285, 3594, 15, 5555, 63, 324, 285, 3594, 63, 885, 14, 15126, 297, 2136, 21921, 804, 14, 1734, 12482, 1149, 12, 413, 14, 16, 12, 1227, 12, 283, 75, 1132, 764, 358, 199, 198, 30804, 17969, 14, 525, 8, 30804, 1160, 9, 199, 198, 27339, 14, 409, 6004, 21921, 4231, 3646, 8, 30804, 17969, 9, 8299, 198, 292, 21807, 275, 11388, 342, 199, 198, 292, 21807, 14, 525, 360, 12648, 63, 3995, 87, 63, 18, 358, 199, 198, 292, 21807, 14, 525, 360, 12648, 63, 7001, 63, 18, 358, 199, 198, 27339, 14, 409, 2698, 1271, 13058, 360, 1353, 1463, 1352, 18387, 1271, 13058, 358, 199, 198, 27339, 14, 409, 1271, 21807, 8, 292, 21807, 9, 8299, 198, 1018, 14, 10212, 3167, 14, 525, 27245, 4231, 360, 80, 416, 3617, 63, 72, 7867, 297, 21305, 4231, 9, 199, 198, 1107, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
fernandojunior/searching-techniques
python/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/fields.py
1007
5833
import email.utils import mimetypes from .packages import six def guess_content_type(filename, default='application/octet-stream'): """ Guess the "Content-Type" of a file. :param filename: The filename to guess the "Content-Type" of using :mod:`mimetypes`. :param default: If no "Content-Type" can be guessed, default to `default`. """ if filename: return mimetypes.guess_type(filename)[0] or default return default def format_header_param(name, value): """ Helper function to format and quote a single header parameter. Particularly useful for header parameters which might contain non-ASCII values, like file names. This follows RFC 2231, as suggested by RFC 2388 Section 4.4. :param name: The name of the parameter, a string expected to be ASCII only. :param value: The value of the parameter, provided as a unicode string. """ if not any(ch in value for ch in '"\\\r\n'): result = '%s="%s"' % (name, value) try: result.encode('ascii') except UnicodeEncodeError: pass else: return result if not six.PY3: # Python 2: value = value.encode('utf-8') value = email.utils.encode_rfc2231(value, 'utf-8') value = '%s*=%s' % (name, value) return value class RequestField(object): """ A data container for request body parameters. :param name: The name of this request field. :param data: The data/value body. :param filename: An optional filename of the request field. :param headers: An optional dict-like object of headers to initially use for the field. """ def __init__(self, name, data, filename=None, headers=None): self._name = name self._filename = filename self.data = data self.headers = {} if headers: self.headers = dict(headers) @classmethod def from_tuples(cls, fieldname, value): """ A :class:`~urllib3.fields.RequestField` factory from old-style tuple parameters. Supports constructing :class:`~urllib3.fields.RequestField` from parameter of key/value strings AND key/filetuple. A filetuple is a (filename, data, MIME type) tuple where the MIME type is optional. For example:: 'foo': 'bar', 'fakefile': ('foofile.txt', 'contents of foofile'), 'realfile': ('barfile.txt', open('realfile').read()), 'typedfile': ('bazfile.bin', open('bazfile').read(), 'image/jpeg'), 'nonamefile': 'contents of nonamefile field', Field names and filenames must be unicode. """ if isinstance(value, tuple): if len(value) == 3: filename, data, content_type = value else: filename, data = value content_type = guess_content_type(filename) else: filename = None content_type = None data = value request_param = cls(fieldname, data, filename=filename) request_param.make_multipart(content_type=content_type) return request_param def _render_part(self, name, value): """ Overridable helper function to format a single header parameter. :param name: The name of the parameter, a string expected to be ASCII only. :param value: The value of the parameter, provided as a unicode string. """ return format_header_param(name, value) def _render_parts(self, header_parts): """ Helper function to format and quote a single header. Useful for single headers that are composed of multiple items. E.g., 'Content-Disposition' fields. :param header_parts: A sequence of (k, v) typles or a :class:`dict` of (k, v) to format as `k1="v1"; k2="v2"; ...`. """ parts = [] iterable = header_parts if isinstance(header_parts, dict): iterable = header_parts.items() for name, value in iterable: if value: parts.append(self._render_part(name, value)) return '; '.join(parts) def render_headers(self): """ Renders the headers for this request field. """ lines = [] sort_keys = ['Content-Disposition', 'Content-Type', 'Content-Location'] for sort_key in sort_keys: if self.headers.get(sort_key, False): lines.append('%s: %s' % (sort_key, self.headers[sort_key])) for header_name, header_value in self.headers.items(): if header_name not in sort_keys: if header_value: lines.append('%s: %s' % (header_name, header_value)) lines.append('\r\n') return '\r\n'.join(lines) def make_multipart(self, content_disposition=None, content_type=None, content_location=None): """ Makes this request field into a multipart request field. This method overrides "Content-Disposition", "Content-Type" and "Content-Location" headers to the request parameter. :param content_type: The 'Content-Type' of the request body. :param content_location: The 'Content-Location' of the request body. """ self.headers['Content-Disposition'] = content_disposition or 'form-data' self.headers['Content-Disposition'] += '; '.join([ '', self._render_parts( (('name', self._name), ('filename', self._filename)) ) ]) self.headers['Content-Type'] = content_type self.headers['Content-Location'] = content_location
mit
[ 646, 3031, 14, 1208, 199, 646, 13290, 199, 199, 504, 1275, 5154, 492, 3816, 421, 199, 318, 9519, 63, 1317, 63, 466, 8, 1501, 12, 849, 534, 3578, 15, 18162, 13, 1745, 735, 272, 408, 272, 24570, 314, 298, 2714, 13, 804, 2, 402, 282, 570, 14, 339, 520, 635, 1788, 26, 267, 710, 1788, 370, 9519, 314, 298, 2714, 13, 804, 2, 402, 1808, 520, 1494, 1705, 7626, 1313, 2313, 272, 520, 635, 849, 26, 267, 982, 949, 298, 2714, 13, 804, 2, 883, 506, 29950, 12, 849, 370, 658, 885, 2313, 272, 408, 272, 340, 1788, 26, 267, 372, 13290, 14, 11636, 63, 466, 8, 1501, 2788, 16, 61, 503, 849, 272, 372, 849, 421, 199, 318, 1475, 63, 1291, 63, 635, 8, 354, 12, 574, 304, 272, 408, 272, 11642, 805, 370, 1475, 436, 6313, 282, 2849, 1406, 2725, 14, 339, 2235, 6628, 590, 2997, 367, 1406, 2633, 1314, 5594, 1395, 272, 2222, 13, 12292, 1338, 12, 2839, 570, 1561, 14, 961, 11924, 7329, 499, 11921, 12, 465, 272, 25697, 701, 7329, 6546, 1299, 15247, 841, 14, 20, 14, 339, 520, 635, 536, 26, 267, 710, 536, 402, 314, 2725, 12, 282, 1059, 1420, 370, 506, 10485, 1454, 14, 272, 520, 635, 574, 26, 267, 710, 574, 402, 314, 2725, 12, 2741, 465, 282, 2649, 1059, 14, 272, 408, 272, 340, 440, 1263, 8, 335, 315, 574, 367, 682, 315, 5522, 9780, 82, 60, 78, 735, 267, 754, 275, 1543, 83, 5961, 83, 4507, 450, 334, 354, 12, 574, 9, 267, 862, 26, 288, 754, 14, 2143, 360, 4371, 358, 267, 871, 24094, 26, 288, 986, 267, 587, 26, 288, 372, 754, 272, 340, 440, 3816, 14, 4521, 19, 26, 221, 327, 2018, 499, 26, 267, 574, 275, 574, 14, 2143, 360, 1624, 13, 24, 358, 272, 574, 275, 3031, 14, 1208, 14, 2143, 63, 8973, 27475, 8, 585, 12, 283, 1624, 13, 24, 358, 272, 574, 275, 1543, 83, 10, 2458, 83, 7, 450, 334, 354, 12, 574, 9, 272, 372, 574, 421, 199, 533, 4784, 792, 8, 785, 304, 272, 408, 272, 437, 666, 3970, 367, 1056, 2396, 2633, 14, 339, 520, 635, 536, 26, 267, 710, 536, 402, 642, 1056, 901, 14, 272, 520, 635, 666, 26, 267, 710, 666, 15, 585, 2396, 14, 272, 520, 635, 1788, 26, 267, 1626, 2716, 1788, 402, 314, 1056, 901, 14, 272, 520, 635, 2323, 26, 267, 1626, 2716, 1211, 13, 2930, 909, 402, 2323, 370, 22801, 675, 367, 314, 901, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 12, 666, 12, 1788, 29, 403, 12, 2323, 29, 403, 304, 267, 291, 423, 354, 275, 536, 267, 291, 423, 1501, 275, 1788, 267, 291, 14, 576, 275, 666, 267, 291, 14, 2139, 275, 1052, 267, 340, 2323, 26, 288, 291, 14, 2139, 275, 1211, 8, 2139, 9, 339, 768, 3744, 272, 347, 687, 63, 11760, 8, 1886, 12, 18887, 12, 574, 304, 267, 408, 267, 437, 520, 533, 6054, 4078, 19, 14, 955, 14, 2017, 792, 64, 6434, 687, 2269, 13, 2487, 2008, 2633, 14, 398, 32090, 22048, 520, 533, 6054, 4078, 19, 14, 955, 14, 2017, 792, 64, 687, 267, 2725, 402, 790, 15, 585, 3326, 2401, 790, 15, 493, 2960, 14, 437, 570, 2960, 365, 282, 267, 334, 1501, 12, 666, 12, 14735, 730, 9, 2008, 2382, 314, 14735, 730, 365, 2716, 14, 267, 2104, 2893, 447, 953, 283, 1421, 356, 283, 1700, 297, 288, 283, 3183, 493, 356, 661, 1421, 493, 14, 2424, 297, 283, 4407, 402, 3925, 493, 659, 288, 283, 264, 7411, 441, 356, 661, 1700, 493, 14, 2424, 297, 1551, 360, 264, 7411, 441, 1959, 739, 4000, 288, 283, 22033, 493, 356, 661, 6185, 493, 14, 1393, 297, 1551, 360, 6185, 493, 1959, 739, 1062, 283, 1569, 15, 14230, 659, 288, 283, 2865, 313, 493, 356, 283, 4407, 402, 2222, 313, 493, 901, 297, 398, 5024, 1561, 436, 6203, 1471, 506, 2649, 14, 267, 408, 267, 340, 1228, 8, 585, 12, 2008, 304, 288, 340, 822, 8, 585, 9, 508, 650, 26, 355, 1788, 12, 666, 12, 1564, 63, 466, 275, 574, 288, 587, 26, 355, 1788, 12, 666, 275, 574, 355, 1564, 63, 466, 275, 9519, 63, 1317, 63, 466, 8, 1501, 9, 267, 587, 26, 288, 1788, 275, 488, 288, 1564, 63, 466, 275, 488, 288, 666, 275, 574, 398, 1056, 63, 635, 275, 843, 8, 13646, 12, 666, 12, 1788, 29, 1501, 9, 267, 1056, 63, 635, 14, 1875, 63, 10123, 8, 1317, 63, 466, 29, 1317, 63, 466, 9, 398, 372, 1056, 63, 635, 339, 347, 485, 3352, 63, 2064, 8, 277, 12, 536, 12, 574, 304, 267, 408, 267, 7259, 1677, 461, 5922, 805, 370, 1475, 282, 2849, 1406, 2725, 14, 398, 520, 635, 536, 26, 288, 710, 536, 402, 314, 2725, 12, 282, 1059, 1420, 370, 506, 10485, 1454, 14, 267, 520, 635, 574, 26, 288, 710, 574, 402, 314, 2725, 12, 2741, 465, 282, 2649, 1059, 14, 267, 408, 267, 372, 1475, 63, 1291, 63, 635, 8, 354, 12, 574, 9, 339, 347, 485, 3352, 63, 4181, 8, 277, 12, 1406, 63, 4181, 304, 267, 408, 267, 11642, 805, 370, 1475, 436, 6313, 282, 2849, 1406, 14, 398, 18491, 367, 2849, 2323, 626, 787, 26356, 402, 3663, 2974, 14, 662, 14, 71, 2020, 267, 283, 2714, 13, 15954, 7, 1504, 14, 398, 520, 635, 1406, 63, 4181, 26, 288, 437, 3414, 402, 334, 75, 12, 373, 9, 6211, 2978, 503, 282, 520, 533, 1705, 807, 64, 402, 334, 75, 12, 373, 9, 370, 1475, 288, 465, 658, 75, 17, 628, 86, 17, 11436, 1022, 18, 628, 86, 18, 11436, 2263, 2313, 267, 408, 267, 4184, 275, 942, 267, 6076, 275, 1406, 63, 4181, 267, 340, 1228, 8, 1291, 63, 4181, 12, 1211, 304, 288, 6076, 275, 1406, 63, 4181, 14, 1744, 342, 398, 367, 536, 12, 574, 315, 6076, 26, 288, 340, 574, 26, 355, 4184, 14, 740, 8, 277, 423, 3352, 63, 2064, 8, 354, 12, 574, 430, 398, 372, 14289, 1987, 904, 8, 4181, 9, 339, 347, 3795, 63, 2139, 8, 277, 304, 267, 408, 267, 10055, 7735, 314, 2323, 367, 642, 1056 ]
[ 3031, 14, 1208, 199, 646, 13290, 199, 199, 504, 1275, 5154, 492, 3816, 421, 199, 318, 9519, 63, 1317, 63, 466, 8, 1501, 12, 849, 534, 3578, 15, 18162, 13, 1745, 735, 272, 408, 272, 24570, 314, 298, 2714, 13, 804, 2, 402, 282, 570, 14, 339, 520, 635, 1788, 26, 267, 710, 1788, 370, 9519, 314, 298, 2714, 13, 804, 2, 402, 1808, 520, 1494, 1705, 7626, 1313, 2313, 272, 520, 635, 849, 26, 267, 982, 949, 298, 2714, 13, 804, 2, 883, 506, 29950, 12, 849, 370, 658, 885, 2313, 272, 408, 272, 340, 1788, 26, 267, 372, 13290, 14, 11636, 63, 466, 8, 1501, 2788, 16, 61, 503, 849, 272, 372, 849, 421, 199, 318, 1475, 63, 1291, 63, 635, 8, 354, 12, 574, 304, 272, 408, 272, 11642, 805, 370, 1475, 436, 6313, 282, 2849, 1406, 2725, 14, 339, 2235, 6628, 590, 2997, 367, 1406, 2633, 1314, 5594, 1395, 272, 2222, 13, 12292, 1338, 12, 2839, 570, 1561, 14, 961, 11924, 7329, 499, 11921, 12, 465, 272, 25697, 701, 7329, 6546, 1299, 15247, 841, 14, 20, 14, 339, 520, 635, 536, 26, 267, 710, 536, 402, 314, 2725, 12, 282, 1059, 1420, 370, 506, 10485, 1454, 14, 272, 520, 635, 574, 26, 267, 710, 574, 402, 314, 2725, 12, 2741, 465, 282, 2649, 1059, 14, 272, 408, 272, 340, 440, 1263, 8, 335, 315, 574, 367, 682, 315, 5522, 9780, 82, 60, 78, 735, 267, 754, 275, 1543, 83, 5961, 83, 4507, 450, 334, 354, 12, 574, 9, 267, 862, 26, 288, 754, 14, 2143, 360, 4371, 358, 267, 871, 24094, 26, 288, 986, 267, 587, 26, 288, 372, 754, 272, 340, 440, 3816, 14, 4521, 19, 26, 221, 327, 2018, 499, 26, 267, 574, 275, 574, 14, 2143, 360, 1624, 13, 24, 358, 272, 574, 275, 3031, 14, 1208, 14, 2143, 63, 8973, 27475, 8, 585, 12, 283, 1624, 13, 24, 358, 272, 574, 275, 1543, 83, 10, 2458, 83, 7, 450, 334, 354, 12, 574, 9, 272, 372, 574, 421, 199, 533, 4784, 792, 8, 785, 304, 272, 408, 272, 437, 666, 3970, 367, 1056, 2396, 2633, 14, 339, 520, 635, 536, 26, 267, 710, 536, 402, 642, 1056, 901, 14, 272, 520, 635, 666, 26, 267, 710, 666, 15, 585, 2396, 14, 272, 520, 635, 1788, 26, 267, 1626, 2716, 1788, 402, 314, 1056, 901, 14, 272, 520, 635, 2323, 26, 267, 1626, 2716, 1211, 13, 2930, 909, 402, 2323, 370, 22801, 675, 367, 314, 901, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 12, 666, 12, 1788, 29, 403, 12, 2323, 29, 403, 304, 267, 291, 423, 354, 275, 536, 267, 291, 423, 1501, 275, 1788, 267, 291, 14, 576, 275, 666, 267, 291, 14, 2139, 275, 1052, 267, 340, 2323, 26, 288, 291, 14, 2139, 275, 1211, 8, 2139, 9, 339, 768, 3744, 272, 347, 687, 63, 11760, 8, 1886, 12, 18887, 12, 574, 304, 267, 408, 267, 437, 520, 533, 6054, 4078, 19, 14, 955, 14, 2017, 792, 64, 6434, 687, 2269, 13, 2487, 2008, 2633, 14, 398, 32090, 22048, 520, 533, 6054, 4078, 19, 14, 955, 14, 2017, 792, 64, 687, 267, 2725, 402, 790, 15, 585, 3326, 2401, 790, 15, 493, 2960, 14, 437, 570, 2960, 365, 282, 267, 334, 1501, 12, 666, 12, 14735, 730, 9, 2008, 2382, 314, 14735, 730, 365, 2716, 14, 267, 2104, 2893, 447, 953, 283, 1421, 356, 283, 1700, 297, 288, 283, 3183, 493, 356, 661, 1421, 493, 14, 2424, 297, 283, 4407, 402, 3925, 493, 659, 288, 283, 264, 7411, 441, 356, 661, 1700, 493, 14, 2424, 297, 1551, 360, 264, 7411, 441, 1959, 739, 4000, 288, 283, 22033, 493, 356, 661, 6185, 493, 14, 1393, 297, 1551, 360, 6185, 493, 1959, 739, 1062, 283, 1569, 15, 14230, 659, 288, 283, 2865, 313, 493, 356, 283, 4407, 402, 2222, 313, 493, 901, 297, 398, 5024, 1561, 436, 6203, 1471, 506, 2649, 14, 267, 408, 267, 340, 1228, 8, 585, 12, 2008, 304, 288, 340, 822, 8, 585, 9, 508, 650, 26, 355, 1788, 12, 666, 12, 1564, 63, 466, 275, 574, 288, 587, 26, 355, 1788, 12, 666, 275, 574, 355, 1564, 63, 466, 275, 9519, 63, 1317, 63, 466, 8, 1501, 9, 267, 587, 26, 288, 1788, 275, 488, 288, 1564, 63, 466, 275, 488, 288, 666, 275, 574, 398, 1056, 63, 635, 275, 843, 8, 13646, 12, 666, 12, 1788, 29, 1501, 9, 267, 1056, 63, 635, 14, 1875, 63, 10123, 8, 1317, 63, 466, 29, 1317, 63, 466, 9, 398, 372, 1056, 63, 635, 339, 347, 485, 3352, 63, 2064, 8, 277, 12, 536, 12, 574, 304, 267, 408, 267, 7259, 1677, 461, 5922, 805, 370, 1475, 282, 2849, 1406, 2725, 14, 398, 520, 635, 536, 26, 288, 710, 536, 402, 314, 2725, 12, 282, 1059, 1420, 370, 506, 10485, 1454, 14, 267, 520, 635, 574, 26, 288, 710, 574, 402, 314, 2725, 12, 2741, 465, 282, 2649, 1059, 14, 267, 408, 267, 372, 1475, 63, 1291, 63, 635, 8, 354, 12, 574, 9, 339, 347, 485, 3352, 63, 4181, 8, 277, 12, 1406, 63, 4181, 304, 267, 408, 267, 11642, 805, 370, 1475, 436, 6313, 282, 2849, 1406, 14, 398, 18491, 367, 2849, 2323, 626, 787, 26356, 402, 3663, 2974, 14, 662, 14, 71, 2020, 267, 283, 2714, 13, 15954, 7, 1504, 14, 398, 520, 635, 1406, 63, 4181, 26, 288, 437, 3414, 402, 334, 75, 12, 373, 9, 6211, 2978, 503, 282, 520, 533, 1705, 807, 64, 402, 334, 75, 12, 373, 9, 370, 1475, 288, 465, 658, 75, 17, 628, 86, 17, 11436, 1022, 18, 628, 86, 18, 11436, 2263, 2313, 267, 408, 267, 4184, 275, 942, 267, 6076, 275, 1406, 63, 4181, 267, 340, 1228, 8, 1291, 63, 4181, 12, 1211, 304, 288, 6076, 275, 1406, 63, 4181, 14, 1744, 342, 398, 367, 536, 12, 574, 315, 6076, 26, 288, 340, 574, 26, 355, 4184, 14, 740, 8, 277, 423, 3352, 63, 2064, 8, 354, 12, 574, 430, 398, 372, 14289, 1987, 904, 8, 4181, 9, 339, 347, 3795, 63, 2139, 8, 277, 304, 267, 408, 267, 10055, 7735, 314, 2323, 367, 642, 1056, 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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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 ]
alexmogavero/home-assistant
homeassistant/components/cover/mysensors.py
6
3857
""" Support for MySensors covers. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/cover.mysensors/ """ import logging from homeassistant.components import mysensors from homeassistant.components.cover import CoverDevice, ATTR_POSITION from homeassistant.const import STATE_ON, STATE_OFF _LOGGER = logging.getLogger(__name__) DEPENDENCIES = [] def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the MySensors platform for covers.""" if discovery_info is None: return gateways = hass.data.get(mysensors.MYSENSORS_GATEWAYS) if not gateways: return for gateway in gateways: pres = gateway.const.Presentation set_req = gateway.const.SetReq map_sv_types = { pres.S_COVER: [set_req.V_DIMMER, set_req.V_LIGHT], } if float(gateway.protocol_version) >= 1.5: map_sv_types.update({ pres.S_COVER: [set_req.V_PERCENTAGE, set_req.V_STATUS], }) devices = {} gateway.platform_callbacks.append(mysensors.pf_callback_factory( map_sv_types, devices, MySensorsCover, add_devices)) class MySensorsCover(mysensors.MySensorsDeviceEntity, CoverDevice): """Representation of the value of a MySensors Cover child node.""" @property def assumed_state(self): """Return True if unable to access real state of entity.""" return self.gateway.optimistic @property def is_closed(self): """Return True if cover is closed.""" set_req = self.gateway.const.SetReq if set_req.V_DIMMER in self._values: return self._values.get(set_req.V_DIMMER) == 0 else: return self._values.get(set_req.V_LIGHT) == STATE_OFF @property def current_cover_position(self): """Return current position of cover. None is unknown, 0 is closed, 100 is fully open. """ set_req = self.gateway.const.SetReq return self._values.get(set_req.V_DIMMER) def open_cover(self, **kwargs): """Move the cover up.""" set_req = self.gateway.const.SetReq self.gateway.set_child_value( self.node_id, self.child_id, set_req.V_UP, 1) if self.gateway.optimistic: # Optimistically assume that cover has changed state. if set_req.V_DIMMER in self._values: self._values[set_req.V_DIMMER] = 100 else: self._values[set_req.V_LIGHT] = STATE_ON self.schedule_update_ha_state() def close_cover(self, **kwargs): """Move the cover down.""" set_req = self.gateway.const.SetReq self.gateway.set_child_value( self.node_id, self.child_id, set_req.V_DOWN, 1) if self.gateway.optimistic: # Optimistically assume that cover has changed state. if set_req.V_DIMMER in self._values: self._values[set_req.V_DIMMER] = 0 else: self._values[set_req.V_LIGHT] = STATE_OFF self.schedule_update_ha_state() def set_cover_position(self, **kwargs): """Move the cover to a specific position.""" position = kwargs.get(ATTR_POSITION) set_req = self.gateway.const.SetReq self.gateway.set_child_value( self.node_id, self.child_id, set_req.V_DIMMER, position) if self.gateway.optimistic: # Optimistically assume that cover has changed state. self._values[set_req.V_DIMMER] = position self.schedule_update_ha_state() def stop_cover(self, **kwargs): """Stop the device.""" set_req = self.gateway.const.SetReq self.gateway.set_child_value( self.node_id, self.child_id, set_req.V_STOP, 1)
apache-2.0
[ 624, 199, 11532, 367, 4932, 51, 17564, 25858, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 5899, 14, 1662, 22675, 15, 199, 624, 199, 646, 2050, 199, 199, 504, 8846, 14, 4608, 492, 3002, 22675, 199, 504, 8846, 14, 4608, 14, 5899, 492, 1849, 422, 2510, 12, 10762, 63, 15717, 199, 504, 8846, 14, 1297, 492, 11377, 63, 615, 12, 11377, 63, 7517, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 25743, 9415, 2563, 275, 942, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 4932, 51, 17564, 4298, 367, 25858, 1041, 272, 340, 13172, 63, 815, 365, 488, 26, 267, 372, 339, 17036, 2885, 275, 6298, 14, 576, 14, 362, 8, 1662, 22675, 14, 12339, 51, 8456, 4149, 63, 26624, 26194, 9, 272, 340, 440, 17036, 2885, 26, 267, 372, 339, 367, 10391, 315, 17036, 2885, 26, 267, 25210, 275, 10391, 14, 1297, 14, 19794, 425, 267, 663, 63, 2103, 275, 10391, 14, 1297, 14, 1084, 11981, 267, 2341, 63, 2772, 63, 1313, 275, 469, 288, 25210, 14, 51, 63, 19052, 26, 359, 409, 63, 2103, 14, 54, 63, 19080, 20263, 12, 663, 63, 2103, 14, 54, 63, 21613, 467, 267, 789, 267, 340, 2069, 8, 7019, 14, 3922, 63, 1023, 9, 2356, 413, 14, 21, 26, 288, 2341, 63, 2772, 63, 1313, 14, 873, 2561, 355, 25210, 14, 51, 63, 19052, 26, 359, 409, 63, 2103, 14, 54, 63, 4227, 17349, 2962, 12, 663, 63, 2103, 14, 54, 63, 6305, 467, 288, 3828, 267, 7256, 275, 1052, 267, 10391, 14, 3246, 63, 11948, 14, 740, 8, 1662, 22675, 14, 9928, 63, 3058, 63, 3702, 8, 288, 2341, 63, 2772, 63, 1313, 12, 7256, 12, 4932, 51, 17564, 31048, 12, 1050, 63, 6410, 430, 421, 199, 533, 4932, 51, 17564, 31048, 8, 1662, 22675, 14, 5713, 51, 17564, 2510, 7302, 12, 1849, 422, 2510, 304, 272, 408, 20609, 402, 314, 574, 402, 282, 4932, 51, 17564, 1849, 422, 1982, 1031, 1041, 339, 768, 1829, 272, 347, 10826, 63, 929, 8, 277, 304, 267, 408, 1767, 715, 340, 17329, 370, 2879, 3363, 1174, 402, 4642, 1041, 267, 372, 291, 14, 7019, 14, 6433, 6937, 339, 768, 1829, 272, 347, 365, 63, 5938, 8, 277, 304, 267, 408, 1767, 715, 340, 8486, 365, 6876, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 340, 663, 63, 2103, 14, 54, 63, 19080, 20263, 315, 291, 423, 1459, 26, 288, 372, 291, 423, 1459, 14, 362, 8, 409, 63, 2103, 14, 54, 63, 19080, 20263, 9, 508, 378, 267, 587, 26, 288, 372, 291, 423, 1459, 14, 362, 8, 409, 63, 2103, 14, 54, 63, 21613, 9, 508, 11377, 63, 7517, 339, 768, 1829, 272, 347, 1453, 63, 5899, 63, 3124, 8, 277, 304, 267, 408, 1767, 1453, 3421, 402, 8486, 14, 398, 488, 365, 5809, 12, 378, 365, 6876, 12, 2948, 365, 9999, 1551, 14, 267, 408, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 372, 291, 423, 1459, 14, 362, 8, 409, 63, 2103, 14, 54, 63, 19080, 20263, 9, 339, 347, 1551, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 10370, 314, 8486, 1536, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 2160, 12, 413, 9, 267, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 19246, 6937, 1183, 5534, 626, 8486, 965, 2896, 1174, 14, 288, 340, 663, 63, 2103, 14, 54, 63, 19080, 20263, 315, 291, 423, 1459, 26, 355, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 19080, 20263, 61, 275, 2948, 288, 587, 26, 355, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 21613, 61, 275, 11377, 63, 615, 288, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 347, 4002, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 10370, 314, 8486, 3224, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 8819, 12, 413, 9, 267, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 19246, 6937, 1183, 5534, 626, 8486, 965, 2896, 1174, 14, 288, 340, 663, 63, 2103, 14, 54, 63, 19080, 20263, 315, 291, 423, 1459, 26, 355, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 19080, 20263, 61, 275, 378, 288, 587, 26, 355, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 21613, 61, 275, 11377, 63, 7517, 288, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 347, 663, 63, 5899, 63, 3124, 8, 277, 12, 1011, 958, 304, 267, 408, 10370, 314, 8486, 370, 282, 2488, 3421, 1041, 267, 3421, 275, 2074, 14, 362, 8, 5280, 63, 15717, 9, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 19080, 20263, 12, 3421, 9, 267, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 19246, 6937, 1183, 5534, 626, 8486, 965, 2896, 1174, 14, 288, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 19080, 20263, 61, 275, 3421, 288, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 347, 3631, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 6293, 314, 2243, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63 ]
[ 199, 11532, 367, 4932, 51, 17564, 25858, 14, 199, 199, 1858, 1655, 2436, 3595, 642, 4298, 12, 8749, 10618, 370, 314, 3794, 737, 199, 2859, 921, 4219, 13, 7310, 14, 2308, 15, 4608, 15, 5899, 14, 1662, 22675, 15, 199, 624, 199, 646, 2050, 199, 199, 504, 8846, 14, 4608, 492, 3002, 22675, 199, 504, 8846, 14, 4608, 14, 5899, 492, 1849, 422, 2510, 12, 10762, 63, 15717, 199, 504, 8846, 14, 1297, 492, 11377, 63, 615, 12, 11377, 63, 7517, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 25743, 9415, 2563, 275, 942, 421, 199, 318, 3272, 63, 3246, 8, 5387, 12, 1101, 12, 1050, 63, 6410, 12, 13172, 63, 815, 29, 403, 304, 272, 408, 1084, 1536, 314, 4932, 51, 17564, 4298, 367, 25858, 1041, 272, 340, 13172, 63, 815, 365, 488, 26, 267, 372, 339, 17036, 2885, 275, 6298, 14, 576, 14, 362, 8, 1662, 22675, 14, 12339, 51, 8456, 4149, 63, 26624, 26194, 9, 272, 340, 440, 17036, 2885, 26, 267, 372, 339, 367, 10391, 315, 17036, 2885, 26, 267, 25210, 275, 10391, 14, 1297, 14, 19794, 425, 267, 663, 63, 2103, 275, 10391, 14, 1297, 14, 1084, 11981, 267, 2341, 63, 2772, 63, 1313, 275, 469, 288, 25210, 14, 51, 63, 19052, 26, 359, 409, 63, 2103, 14, 54, 63, 19080, 20263, 12, 663, 63, 2103, 14, 54, 63, 21613, 467, 267, 789, 267, 340, 2069, 8, 7019, 14, 3922, 63, 1023, 9, 2356, 413, 14, 21, 26, 288, 2341, 63, 2772, 63, 1313, 14, 873, 2561, 355, 25210, 14, 51, 63, 19052, 26, 359, 409, 63, 2103, 14, 54, 63, 4227, 17349, 2962, 12, 663, 63, 2103, 14, 54, 63, 6305, 467, 288, 3828, 267, 7256, 275, 1052, 267, 10391, 14, 3246, 63, 11948, 14, 740, 8, 1662, 22675, 14, 9928, 63, 3058, 63, 3702, 8, 288, 2341, 63, 2772, 63, 1313, 12, 7256, 12, 4932, 51, 17564, 31048, 12, 1050, 63, 6410, 430, 421, 199, 533, 4932, 51, 17564, 31048, 8, 1662, 22675, 14, 5713, 51, 17564, 2510, 7302, 12, 1849, 422, 2510, 304, 272, 408, 20609, 402, 314, 574, 402, 282, 4932, 51, 17564, 1849, 422, 1982, 1031, 1041, 339, 768, 1829, 272, 347, 10826, 63, 929, 8, 277, 304, 267, 408, 1767, 715, 340, 17329, 370, 2879, 3363, 1174, 402, 4642, 1041, 267, 372, 291, 14, 7019, 14, 6433, 6937, 339, 768, 1829, 272, 347, 365, 63, 5938, 8, 277, 304, 267, 408, 1767, 715, 340, 8486, 365, 6876, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 340, 663, 63, 2103, 14, 54, 63, 19080, 20263, 315, 291, 423, 1459, 26, 288, 372, 291, 423, 1459, 14, 362, 8, 409, 63, 2103, 14, 54, 63, 19080, 20263, 9, 508, 378, 267, 587, 26, 288, 372, 291, 423, 1459, 14, 362, 8, 409, 63, 2103, 14, 54, 63, 21613, 9, 508, 11377, 63, 7517, 339, 768, 1829, 272, 347, 1453, 63, 5899, 63, 3124, 8, 277, 304, 267, 408, 1767, 1453, 3421, 402, 8486, 14, 398, 488, 365, 5809, 12, 378, 365, 6876, 12, 2948, 365, 9999, 1551, 14, 267, 408, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 372, 291, 423, 1459, 14, 362, 8, 409, 63, 2103, 14, 54, 63, 19080, 20263, 9, 339, 347, 1551, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 10370, 314, 8486, 1536, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 2160, 12, 413, 9, 267, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 19246, 6937, 1183, 5534, 626, 8486, 965, 2896, 1174, 14, 288, 340, 663, 63, 2103, 14, 54, 63, 19080, 20263, 315, 291, 423, 1459, 26, 355, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 19080, 20263, 61, 275, 2948, 288, 587, 26, 355, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 21613, 61, 275, 11377, 63, 615, 288, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 347, 4002, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 10370, 314, 8486, 3224, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 8819, 12, 413, 9, 267, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 19246, 6937, 1183, 5534, 626, 8486, 965, 2896, 1174, 14, 288, 340, 663, 63, 2103, 14, 54, 63, 19080, 20263, 315, 291, 423, 1459, 26, 355, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 19080, 20263, 61, 275, 378, 288, 587, 26, 355, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 21613, 61, 275, 11377, 63, 7517, 288, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 347, 663, 63, 5899, 63, 3124, 8, 277, 12, 1011, 958, 304, 267, 408, 10370, 314, 8486, 370, 282, 2488, 3421, 1041, 267, 3421, 275, 2074, 14, 362, 8, 5280, 63, 15717, 9, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 63, 344, 12, 291, 14, 1739, 63, 344, 12, 663, 63, 2103, 14, 54, 63, 19080, 20263, 12, 3421, 9, 267, 340, 291, 14, 7019, 14, 6433, 6937, 26, 288, 327, 19246, 6937, 1183, 5534, 626, 8486, 965, 2896, 1174, 14, 288, 291, 423, 1459, 59, 409, 63, 2103, 14, 54, 63, 19080, 20263, 61, 275, 3421, 288, 291, 14, 7211, 63, 873, 63, 2411, 63, 929, 342, 339, 347, 3631, 63, 5899, 8, 277, 12, 1011, 958, 304, 267, 408, 6293, 314, 2243, 1041, 267, 663, 63, 2103, 275, 291, 14, 7019, 14, 1297, 14, 1084, 11981, 267, 291, 14, 7019, 14, 409, 63, 1739, 63, 585, 8, 288, 291, 14, 932, 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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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 ]
kamilion/customizer
src/actions/rebuild.py
1
16706
#!/usr/bin/python2.7 import sys, os, glob, shutil, re import lib.misc as misc import lib.config as config import lib.message as message import actions.common as common def detect_boot(): global initrd, vmlinuz, mt86plus, xen_kernel, xen_efi, ipxe_kernel, ipxe_efi initrd = None vmlinuz = None mt86plus = None xen_kernel = None xen_efi = None ipxe_kernel = None ipxe_efi = None for sfile in sorted(misc.list_files(misc.join_paths(config.FILESYSTEM_DIR, 'boot'))): if 'initrd.img' in sfile: initrd = sfile message.sub_debug('Initrd detected', sfile) elif 'vmlinuz' in sfile: vmlinuz = sfile message.sub_debug('Vmlinuz detected', sfile) elif 'memtest86' in sfile: if '+.bin' in sfile: # In theory, We want memtest86+.bin, not memtest86+_multiboot.bin # But in actual practice, they're often the same file. Let's be picky. mt86plus = sfile message.sub_debug('Memtest86+ kernel detected', sfile) elif 'xen' in sfile: if 'gz' in sfile: xen_kernel = sfile message.sub_debug('Xen Hypervisor kernel detected', sfile) if 'efi' in sfile: xen_efi = sfile message.sub_debug('Xen Hypervisor EFI kernel detected', sfile) elif 'ipxe' in sfile: if 'lkrn' in sfile: ipxe_kernel = sfile message.sub_debug('iPXE kernel detected', sfile) if 'efi' in sfile: ipxe_efi = sfile message.sub_debug('iPXE EFI kernel detected', sfile) def main(): common.check_filesystem() # Basic sanity checks of files and paths that absolutely need to exist. message.sub_info('Doing sanity checks') lsb_file = misc.join_paths(config.FILESYSTEM_DIR, 'etc/lsb-release') if not os.path.isfile(lsb_file): raise(message.exception(lsb_file + ' does not exist')) isolinux_dir = misc.join_paths(config.ISO_DIR, 'isolinux') if not os.path.isdir(isolinux_dir): raise(message.exception(isolinux_dir + ' does not exist')) if misc.search_file('999:999', misc.join_paths(config.FILESYSTEM_DIR, 'etc/passwd')): raise(message.exception('User with UID 999 exists, this means automatic login will fail')) elif misc.search_file('999:999', misc.join_paths(config.FILESYSTEM_DIR, 'etc/group')): raise(message.exception('Group with GID 999 exists, this means automatic login will fail')) casper_dir = misc.join_paths(config.ISO_DIR, 'casper') if not os.path.isdir(casper_dir): message.sub_debug('Creating', casper_dir) os.makedirs(casper_dir) base_file = misc.join_paths(config.ISO_DIR, '.disk/base_installable') if os.path.isfile(misc.join_paths(config.FILESYSTEM_DIR, 'usr/bin/ubiquity')): if not os.path.isfile(base_file): message.sub_debug('Creating', base_file) misc.write_file(base_file, '') elif os.path.isfile(base_file): message.sub_debug('Removing', base_file) os.unlink(base_file) # Acquire distribution information from the FileSystem message.sub_info('Gathering information') arch = misc.chroot_exec(('dpkg', '--print-architecture'), prepare=False, \ mount=False, output=True) distrib = common.get_value(config.FILESYSTEM_DIR + '/etc/lsb-release', \ 'DISTRIB_ID=') release = common.get_value(config.FILESYSTEM_DIR + '/etc/lsb-release', \ 'DISTRIB_RELEASE=') if isinstance(arch, bytes): # For some reason this is of type 'bytes'. if int(sys.version_info[0]) >= 3: # If we're running under python3 arch = str(arch, 'utf-8') else: # Otherwise just cast it to a str without the 'utf-8' option. arch = str(arch) # It's really annoying to override the output filename other ways. # If you actually try to change lsb-release, you end up breaking apt. livecd_file = misc.join_paths(config.FILESYSTEM_DIR, 'etc/livecd-release') if os.path.isfile(livecd_file): distrib = common.get_value(config.FILESYSTEM_DIR + '/etc/livecd-release', \ 'DISTRIB_ID=') release = common.get_value(config.FILESYSTEM_DIR + '/etc/livecd-release', \ 'DISTRIB_RELEASE=') message.sub_debug('Distribution and Release overriden by /etc/livecd-release') # Just overwrite the variables if the file actually exists, it's cleaner. message.sub_debug('Architecture', arch) message.sub_debug('Distribution (DISTRIB_ID)', distrib) message.sub_debug('Release (DISTRIB_RELEASE)', release) # Remove files, by name, that we know we must repopulate if they exist. message.sub_info('Cleaning up') cleanup_files = ['casper/filesystem.squashfs', 'casper/initrd.lz', \ 'casper/vmlinuz', 'casper/vmlinuz.efi', 'casper/filesystem.manifest', \ 'casper/filesystem.size'] cleanup_files.extend(glob.glob('.disk/casper-uuid-*')) for sfile in cleanup_files: full_file = misc.join_paths(config.ISO_DIR, sfile) if os.path.exists(full_file): message.sub_debug('Removing', full_file) os.unlink(full_file) # Define the checksum files, and the ISO filename. md5sum_iso_file = misc.join_paths(config.WORK_DIR, 'md5sum') sha1sum_iso_file = misc.join_paths(config.WORK_DIR, 'sha1sum') sha256sum_iso_file = misc.join_paths(config.WORK_DIR, 'sha256sum') iso_file = '%s/%s-%s-%s.iso' % (config.WORK_DIR, distrib, arch, release) if os.path.exists(iso_file): message.sub_debug('Removing', iso_file) os.unlink(iso_file) if os.path.exists(md5sum_iso_file): message.sub_debug('Removing', md5sum_iso_file) os.unlink(md5sum_iso_file) if os.path.exists(sha1sum_iso_file): message.sub_debug('Removing', sha1sum_iso_file) os.unlink(sha1sum_iso_file) if os.path.exists(sha256sum_iso_file): message.sub_debug('Removing', sha256sum_iso_file) os.unlink(sha256sum_iso_file) # Detect files needed for booting, the kernel, initramfs, xen and anything else. detect_boot() if not vmlinuz: if config.PURGE_KERNEL: message.sub_info('Re-installing kernel') misc.chroot_exec(('apt-get', 'purge', '--yes', 'linux-image*', '-q')) message.sub_debug("Kernel Selection Debug: {0}, {1}".format(type(config.KERNEL), config.KERNEL)) if config.KERNEL != "default" or None: misc.chroot_exec(('apt-get', 'install', '--yes', \ config.KERNEL, '-q')) else: # use the kernel the user specified in the config. if arch != "amd64": # then use the 32bit 'linux-image-generic' misc.chroot_exec(('apt-get', 'install', '--yes', \ 'linux-image-generic', '-q')) else: # use the amd64 'linux-signed-generic' for uEFI misc.chroot_exec(('apt-get', 'install', '--yes', \ 'linux-signed-generic', '-q')) misc.chroot_exec(('apt-get', 'clean')) else: message.sub_info('Updating initramfs') misc.chroot_exec(('update-initramfs', '-k', 'all', '-t', '-u')) detect_boot() if not initrd or not vmlinuz: raise(message.exception('Missing boot file (initrd or vmlinuz)')) else: message.sub_info('Copying boot files') message.sub_debug('Initrd', initrd) message.sub_debug('Vmlinuz', vmlinuz) misc.copy_file(initrd, misc.join_paths(config.ISO_DIR, 'casper/initrd.lz')) # FIXME: extend to support grub efi_boot_entry = False isolinux_dir = config.ISO_DIR + '/isolinux' if os.path.isdir(isolinux_dir): for sfile in os.listdir(isolinux_dir): if sfile.endswith('.cfg') and misc.search_file('vmlinuz.efi', isolinux_dir + '/' + sfile): message.sub_debug('Found EFI entry in isolinux conf', sfile) efi_boot_entry = True if os.path.isdir(misc.join_paths(config.ISO_DIR, 'efi/boot')) or \ efi_boot_entry: message.sub_debug('Copying EFI vmlinuz') misc.copy_file(vmlinuz, misc.join_paths(config.ISO_DIR, \ 'casper/vmlinuz.efi')) os.link(misc.join_paths(config.ISO_DIR, \ 'casper/vmlinuz.efi'), misc.join_paths(config.ISO_DIR, \ 'casper/vmlinuz')) # EFI Kernels are still loadable by grub, modern ISOs lack a bare vmlinuz. # mkisofs/genisoimage -cache-inodes reuses hard linked inodes. else: misc.copy_file(vmlinuz, misc.join_paths(config.ISO_DIR, 'casper/vmlinuz')) # We only need to copy the bare kernel if we're not using EFI at all. # Copy optional boot-enablement packages onto the ISO, if found. if mt86plus: message.sub_debug('Memtest86+ kernel', mt86plus) misc.copy_file(mt86plus, misc.join_paths(config.ISO_DIR, 'install/mt86plus')) if xen_kernel: message.sub_debug('Xen kernel', xen_kernel) misc.copy_file(xen_kernel, \ misc.join_paths(config.ISO_DIR, 'casper/' + os.path.basename(xen_kernel))) if xen_efi: message.sub_debug('Xen EFI kernel', xen_efi) misc.copy_file(xen_efi, \ misc.join_paths(config.ISO_DIR, 'casper/' + os.path.basename(xen_efi))) if ipxe_kernel: message.sub_debug('iPXE kernel', ipxe_kernel) misc.copy_file(ipxe_kernel, \ misc.join_paths(config.ISO_DIR, 'casper/' + os.path.basename(ipxe_kernel))) if ipxe_efi: message.sub_debug('iPXE EFI kernel', ipxe_efi) misc.copy_file(ipxe_efi, \ misc.join_paths(config.ISO_DIR, 'casper/' + os.path.basename(ipxe_efi))) kernel_type = re.search('initrd.img-*.*.*-*-(.*)', initrd).group(1) message.sub_debug('Kernel Variant Type', kernel_type) message.sub_info('Extracting casper UUID') confdir = config.FILESYSTEM_DIR + '/conf' if os.path.isdir(confdir): shutil.rmtree(confdir) os.makedirs(confdir) if common.is_gz_file(initrd): message.sub_debug('Kernel Compression', "gzip without early microcode") try: misc.chroot_exec('zcat ' + initrd.replace(config.FILESYSTEM_DIR, '') + ' | cpio --quiet -id conf/uuid.conf', \ shell=True, cwd=config.FILESYSTEM_DIR) misc.copy_file(confdir + '/uuid.conf', misc.join_paths(config.ISO_DIR, \ '.disk/casper-uuid-' + kernel_type)) finally: shutil.rmtree(confdir) else: message.sub_debug('Kernel Compression', "gzip with early microcode") try: misc.chroot_exec('unmkinitramfs ' + initrd.replace(config.FILESYSTEM_DIR, '') + ' conf/', \ shell=True, cwd=config.FILESYSTEM_DIR) misc.copy_file(confdir + '/main/conf/uuid.conf', misc.join_paths(config.ISO_DIR, \ '.disk/casper-uuid-' + kernel_type)) finally: shutil.rmtree(confdir) # Define some default compression parameters, including a 1MB blocksize for all compressors. compression_parameters = ('-b', '1048576', '-comp', config.COMPRESSION) if config.COMPRESSION == 'xz': # Append additional compression parameters for xz. # Using the branch-call-jump filter provides a compression boost with executable code. # This can save a hundred megabytes easily, on an 800MB ISO. The dictionary size must # match the block size, and it's advisable to use larger block sizes, like 1MB or 4MB. compression_parameters += ('-Xbcj', 'x86', '-Xdict-size', '100%') message.sub_info('SquashFS Compression parameters', compression_parameters) # Create the compressed filesystem message.sub_info('Creating SquashFS compressed filesystem') make_squash_fs = ('mksquashfs', config.FILESYSTEM_DIR, \ misc.join_paths(config.ISO_DIR, 'casper/filesystem.squashfs'), \ '-wildcards', '-no-recovery', '-noappend', \ '-ef', os.path.join(sys.prefix, 'share/customizer/exclude.list')) misc.system_command(make_squash_fs + compression_parameters) message.sub_info('Checking SquashFS filesystem size') sfs_size = os.path.getsize(misc.join_paths(config.ISO_DIR, \ 'casper/filesystem.squashfs')) message.sub_debug('SquashFS filesystem size', sfs_size) if sfs_size > 4000000000: raise(message.exception('The SquashFS filesystem size is greater than 4GB')) message.sub_info('Creating filesystem.size') fs_size = 0 for root, subdirs, files in os.walk(config.FILESYSTEM_DIR): for sfile in files: sfull = os.path.join(root, sfile) if os.path.islink(sfull): continue # FIXME: respect ignored files from exclude.list fs_size += os.path.getsize(sfull) message.sub_debug('Root filesystem size', fs_size) misc.write_file(misc.join_paths(config.ISO_DIR, \ 'casper/filesystem.size'), str(fs_size)) message.sub_info('Creating filesystem.manifest') lpackages = misc.chroot_exec(('dpkg-query', '-W', \ '--showformat=${Package} ${Version}\\n'), prepare=False, mount=False, \ output=True) if isinstance(lpackages, bytes): # For some reason this is of type 'bytes'. if int(sys.version_info[0]) >= 3: # If we're running under python3 lpackages = str(lpackages, 'utf-8') else: # Otherwise just cast it to a str without the 'utf-8' option. lpackages = str(lpackages) message.sub_debug('Packages', lpackages) misc.write_file(misc.join_paths(config.ISO_DIR, \ 'casper/filesystem.manifest'), lpackages) # FIXME: do some kung-fu to check if packages are installed # and remove them from filesystem.manifest-remove if they are not # Creating a md5sum.txt file fixes lubuntu's integrity check. md5sums_file = misc.join_paths(config.ISO_DIR, 'md5sum.txt') if os.path.isfile(md5sums_file): message.sub_info('Creating md5sum.txt') misc.write_file(md5sums_file, '') for sfile in misc.list_files(config.ISO_DIR): if sfile.endswith('md5sum.txt'): continue if sfile.endswith('SHA256SUMS'): continue message.sub_debug('MD5 Checksumming', sfile) checksum = misc.generate_hash_for_file('md5', sfile) misc.append_file(md5sums_file, checksum + ' .' + \ sfile.replace(config.ISO_DIR, '') +'\n') # Creating a SHA256SUMS file fixes ubuntu-mini-remix's integrity check. shasums_file = misc.join_paths(config.ISO_DIR, 'SHA256SUMS') if os.path.isfile(shasums_file): message.sub_info('Creating SHA256SUMS') misc.write_file(shasums_file, '') for sfile in misc.list_files(config.ISO_DIR): if sfile.endswith('md5sum.txt'): continue if sfile.endswith('SHA256SUMS'): continue message.sub_debug('SHA256 Checksumming', sfile) checksum = misc.generate_hash_for_file('sha256', sfile) misc.append_file(shasums_file, checksum + ' .' + \ sfile.replace(config.ISO_DIR, '') +'\n') # Create the ISO filesystem message.sub_info('Creating ISO') os.chdir(config.ISO_DIR) misc.system_command(('xorriso', '-as', 'mkisofs', '-r', '-V', \ distrib + '-' + arch + '-' + release, '-isohybrid-mbr',\ '/usr/lib/ISOLINUX/isohdpfx.bin', '-b', 'isolinux/isolinux.bin', \ '-c', 'isolinux/boot.cat', '-J', '-l', '-no-emul-boot', \ '-boot-load-size', '4', '-boot-info-table', '-o', iso_file, \ '-cache-inodes', '-input-charset', 'utf-8', '.')) message.sub_info('Creating ISO checksums') md5checksum = misc.generate_hash_for_file('md5', iso_file) message.sub_info('ISO md5 checksum', md5checksum) misc.append_file(md5sum_iso_file, md5checksum + ' .' + \ iso_file.replace(config.WORK_DIR, '') +'\n') sha1checksum = misc.generate_hash_for_file('sha1', iso_file) message.sub_info('ISO sha1 checksum', sha1checksum) misc.append_file(sha1sum_iso_file, sha1checksum + ' .' + \ iso_file.replace(config.WORK_DIR, '') +'\n') sha256checksum = misc.generate_hash_for_file('sha256', iso_file) message.sub_info('ISO sha256 checksum', sha256checksum) misc.append_file(sha256sum_iso_file, sha256checksum + ' .' + \ iso_file.replace(config.WORK_DIR, '') +'\n') message.sub_info('Successfuly created ISO image', iso_file)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 18, 14, 23, 199, 199, 646, 984, 12, 747, 12, 5739, 12, 5145, 12, 295, 199, 199, 646, 1973, 14, 9923, 465, 18576, 199, 646, 1973, 14, 888, 465, 1101, 199, 646, 1973, 14, 1188, 465, 1245, 199, 646, 5445, 14, 2330, 465, 2863, 199, 199, 318, 9696, 63, 4930, 837, 272, 2288, 4205, 6883, 12, 4169, 472, 9494, 12, 19592, 1184, 6666, 12, 20388, 63, 4989, 12, 20388, 63, 69, 329, 12, 3384, 1845, 63, 4989, 12, 3384, 1845, 63, 69, 329, 272, 4205, 6883, 275, 488, 272, 4169, 472, 9494, 275, 488, 272, 19592, 1184, 6666, 275, 488, 272, 20388, 63, 4989, 275, 488, 272, 20388, 63, 69, 329, 275, 488, 272, 3384, 1845, 63, 4989, 275, 488, 272, 3384, 1845, 63, 69, 329, 275, 488, 339, 367, 308, 493, 315, 3355, 8, 9923, 14, 513, 63, 1725, 8, 9923, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 4930, 1333, 304, 267, 340, 283, 826, 6883, 14, 4060, 7, 315, 308, 493, 26, 288, 4205, 6883, 275, 308, 493, 288, 1245, 14, 954, 63, 1757, 360, 9346, 6883, 10501, 297, 308, 493, 9, 267, 916, 283, 2611, 472, 9494, 7, 315, 308, 493, 26, 288, 4169, 472, 9494, 275, 308, 493, 288, 1245, 14, 954, 63, 1757, 360, 17402, 472, 9494, 10501, 297, 308, 493, 9, 267, 916, 283, 5286, 396, 1184, 7, 315, 308, 493, 26, 288, 340, 6681, 14, 1393, 7, 315, 308, 493, 26, 355, 327, 1010, 30629, 12, 2136, 2934, 7573, 396, 1184, 26240, 1393, 12, 440, 7573, 396, 1184, 6416, 3029, 4930, 14, 1393, 355, 327, 11017, 315, 3503, 24471, 12, 2985, 3984, 14115, 314, 2011, 570, 14, 12230, 1159, 506, 3732, 89, 14, 355, 19592, 1184, 6666, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 14169, 396, 1184, 11, 5114, 10501, 297, 308, 493, 9, 267, 916, 283, 13615, 7, 315, 308, 493, 26, 288, 340, 283, 6838, 7, 315, 308, 493, 26, 355, 20388, 63, 4989, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 30643, 21344, 8286, 5114, 10501, 297, 308, 493, 9, 288, 340, 283, 69, 329, 7, 315, 308, 493, 26, 355, 20388, 63, 69, 329, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 30643, 21344, 8286, 662, 1976, 5114, 10501, 297, 308, 493, 9, 267, 916, 283, 711, 1845, 7, 315, 308, 493, 26, 288, 340, 283, 23333, 11641, 7, 315, 308, 493, 26, 355, 3384, 1845, 63, 4989, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 73, 25941, 37, 5114, 10501, 297, 308, 493, 9, 288, 340, 283, 69, 329, 7, 315, 308, 493, 26, 355, 3384, 1845, 63, 69, 329, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 73, 25941, 37, 662, 1976, 5114, 10501, 297, 308, 493, 9, 199, 199, 318, 2446, 837, 272, 2863, 14, 1074, 63, 11381, 342, 339, 327, 10082, 16740, 5920, 402, 1584, 436, 3792, 626, 3679, 590, 1929, 370, 2187, 14, 272, 1245, 14, 954, 63, 815, 360, 2585, 316, 16740, 5920, 358, 272, 9100, 66, 63, 493, 275, 18576, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 6839, 15, 30740, 13, 3221, 358, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 30740, 63, 493, 304, 267, 746, 8, 1188, 14, 1971, 8, 30740, 63, 493, 435, 283, 1630, 440, 2187, 1333, 339, 365, 393, 7226, 63, 694, 275, 18576, 14, 904, 63, 3771, 8, 888, 14, 7336, 63, 3022, 12, 283, 374, 393, 7226, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 374, 393, 7226, 63, 694, 304, 267, 746, 8, 1188, 14, 1971, 8, 374, 393, 7226, 63, 694, 435, 283, 1630, 440, 2187, 1333, 339, 340, 18576, 14, 1733, 63, 493, 360, 5637, 26, 5637, 297, 18576, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 6839, 15, 12671, 8109, 267, 746, 8, 1188, 14, 1971, 360, 1899, 543, 20746, 22291, 3495, 12, 642, 4910, 4834, 4676, 911, 2449, 1333, 272, 916, 18576, 14, 1733, 63, 493, 360, 5637, 26, 5637, 297, 18576, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 6839, 15, 923, 8109, 267, 746, 8, 1188, 14, 1971, 360, 2448, 543, 598, 998, 22291, 3495, 12, 642, 4910, 4834, 4676, 911, 2449, 1333, 339, 14984, 529, 63, 694, 275, 18576, 14, 904, 63, 3771, 8, 888, 14, 7336, 63, 3022, 12, 283, 9765, 529, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 9765, 529, 63, 694, 304, 267, 1245, 14, 954, 63, 1757, 360, 14380, 297, 14984, 529, 63, 694, 9, 267, 747, 14, 8347, 8, 9765, 529, 63, 694, 9, 339, 1300, 63, 493, 275, 18576, 14, 904, 63, 3771, 8, 888, 14, 7336, 63, 3022, 12, 1987, 4032, 15, 1095, 63, 21762, 358, 272, 340, 747, 14, 515, 14, 6292, 8, 9923, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 2647, 15, 1393, 15, 456, 73, 783, 369, 8109, 267, 340, 440, 747, 14, 515, 14, 6292, 8, 1095, 63, 493, 304, 288, 1245, 14, 954, 63, 1757, 360, 14380, 297, 1300, 63, 493, 9, 288, 18576, 14, 952, 63, 493, 8, 1095, 63, 493, 12, 4074, 272, 916, 747, 14, 515, 14, 6292, 8, 1095, 63, 493, 304, 267, 1245, 14, 954, 63, 1757, 360, 23420, 297, 1300, 63, 493, 9, 267, 747, 14, 7162, 8, 1095, 63, 493, 9, 339, 327, 4473, 2272, 4084, 2556, 687, 314, 23754, 272, 1245, 14, 954, 63, 815, 360, 39, 7404, 316, 2556, 358, 272, 3819, 275, 18576, 14, 24769, 63, 1628, 4725, 68, 4600, 297, 2850, 1361, 13, 19134, 659, 9275, 29, 797, 12, 971, 267, 10760, 29, 797, 12, 1072, 29, 549, 9, 272, 29573, 275, 2863, 14, 362, 63, 585, 8, 888, 14, 9472, 57, 9757, 63, 3022, 435, 1994, 6839, 15, 30740, 13, 3221, 297, 971, 267, 283, 24580, 2100, 63, 998, 14619, 272, 4683, 275, 2863, 14, 362, 63, 585, 8, 888, 14, 9472, 57, 9757, 63, 3022, 435, 1994, 6839, 15, 30740 ]
[ 2647, 15, 1393, 15, 1548, 18, 14, 23, 199, 199, 646, 984, 12, 747, 12, 5739, 12, 5145, 12, 295, 199, 199, 646, 1973, 14, 9923, 465, 18576, 199, 646, 1973, 14, 888, 465, 1101, 199, 646, 1973, 14, 1188, 465, 1245, 199, 646, 5445, 14, 2330, 465, 2863, 199, 199, 318, 9696, 63, 4930, 837, 272, 2288, 4205, 6883, 12, 4169, 472, 9494, 12, 19592, 1184, 6666, 12, 20388, 63, 4989, 12, 20388, 63, 69, 329, 12, 3384, 1845, 63, 4989, 12, 3384, 1845, 63, 69, 329, 272, 4205, 6883, 275, 488, 272, 4169, 472, 9494, 275, 488, 272, 19592, 1184, 6666, 275, 488, 272, 20388, 63, 4989, 275, 488, 272, 20388, 63, 69, 329, 275, 488, 272, 3384, 1845, 63, 4989, 275, 488, 272, 3384, 1845, 63, 69, 329, 275, 488, 339, 367, 308, 493, 315, 3355, 8, 9923, 14, 513, 63, 1725, 8, 9923, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 4930, 1333, 304, 267, 340, 283, 826, 6883, 14, 4060, 7, 315, 308, 493, 26, 288, 4205, 6883, 275, 308, 493, 288, 1245, 14, 954, 63, 1757, 360, 9346, 6883, 10501, 297, 308, 493, 9, 267, 916, 283, 2611, 472, 9494, 7, 315, 308, 493, 26, 288, 4169, 472, 9494, 275, 308, 493, 288, 1245, 14, 954, 63, 1757, 360, 17402, 472, 9494, 10501, 297, 308, 493, 9, 267, 916, 283, 5286, 396, 1184, 7, 315, 308, 493, 26, 288, 340, 6681, 14, 1393, 7, 315, 308, 493, 26, 355, 327, 1010, 30629, 12, 2136, 2934, 7573, 396, 1184, 26240, 1393, 12, 440, 7573, 396, 1184, 6416, 3029, 4930, 14, 1393, 355, 327, 11017, 315, 3503, 24471, 12, 2985, 3984, 14115, 314, 2011, 570, 14, 12230, 1159, 506, 3732, 89, 14, 355, 19592, 1184, 6666, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 14169, 396, 1184, 11, 5114, 10501, 297, 308, 493, 9, 267, 916, 283, 13615, 7, 315, 308, 493, 26, 288, 340, 283, 6838, 7, 315, 308, 493, 26, 355, 20388, 63, 4989, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 30643, 21344, 8286, 5114, 10501, 297, 308, 493, 9, 288, 340, 283, 69, 329, 7, 315, 308, 493, 26, 355, 20388, 63, 69, 329, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 30643, 21344, 8286, 662, 1976, 5114, 10501, 297, 308, 493, 9, 267, 916, 283, 711, 1845, 7, 315, 308, 493, 26, 288, 340, 283, 23333, 11641, 7, 315, 308, 493, 26, 355, 3384, 1845, 63, 4989, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 73, 25941, 37, 5114, 10501, 297, 308, 493, 9, 288, 340, 283, 69, 329, 7, 315, 308, 493, 26, 355, 3384, 1845, 63, 69, 329, 275, 308, 493, 355, 1245, 14, 954, 63, 1757, 360, 73, 25941, 37, 662, 1976, 5114, 10501, 297, 308, 493, 9, 199, 199, 318, 2446, 837, 272, 2863, 14, 1074, 63, 11381, 342, 339, 327, 10082, 16740, 5920, 402, 1584, 436, 3792, 626, 3679, 590, 1929, 370, 2187, 14, 272, 1245, 14, 954, 63, 815, 360, 2585, 316, 16740, 5920, 358, 272, 9100, 66, 63, 493, 275, 18576, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 6839, 15, 30740, 13, 3221, 358, 272, 340, 440, 747, 14, 515, 14, 6292, 8, 30740, 63, 493, 304, 267, 746, 8, 1188, 14, 1971, 8, 30740, 63, 493, 435, 283, 1630, 440, 2187, 1333, 339, 365, 393, 7226, 63, 694, 275, 18576, 14, 904, 63, 3771, 8, 888, 14, 7336, 63, 3022, 12, 283, 374, 393, 7226, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 374, 393, 7226, 63, 694, 304, 267, 746, 8, 1188, 14, 1971, 8, 374, 393, 7226, 63, 694, 435, 283, 1630, 440, 2187, 1333, 339, 340, 18576, 14, 1733, 63, 493, 360, 5637, 26, 5637, 297, 18576, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 6839, 15, 12671, 8109, 267, 746, 8, 1188, 14, 1971, 360, 1899, 543, 20746, 22291, 3495, 12, 642, 4910, 4834, 4676, 911, 2449, 1333, 272, 916, 18576, 14, 1733, 63, 493, 360, 5637, 26, 5637, 297, 18576, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 6839, 15, 923, 8109, 267, 746, 8, 1188, 14, 1971, 360, 2448, 543, 598, 998, 22291, 3495, 12, 642, 4910, 4834, 4676, 911, 2449, 1333, 339, 14984, 529, 63, 694, 275, 18576, 14, 904, 63, 3771, 8, 888, 14, 7336, 63, 3022, 12, 283, 9765, 529, 358, 272, 340, 440, 747, 14, 515, 14, 6027, 8, 9765, 529, 63, 694, 304, 267, 1245, 14, 954, 63, 1757, 360, 14380, 297, 14984, 529, 63, 694, 9, 267, 747, 14, 8347, 8, 9765, 529, 63, 694, 9, 339, 1300, 63, 493, 275, 18576, 14, 904, 63, 3771, 8, 888, 14, 7336, 63, 3022, 12, 1987, 4032, 15, 1095, 63, 21762, 358, 272, 340, 747, 14, 515, 14, 6292, 8, 9923, 14, 904, 63, 3771, 8, 888, 14, 9472, 57, 9757, 63, 3022, 12, 283, 2647, 15, 1393, 15, 456, 73, 783, 369, 8109, 267, 340, 440, 747, 14, 515, 14, 6292, 8, 1095, 63, 493, 304, 288, 1245, 14, 954, 63, 1757, 360, 14380, 297, 1300, 63, 493, 9, 288, 18576, 14, 952, 63, 493, 8, 1095, 63, 493, 12, 4074, 272, 916, 747, 14, 515, 14, 6292, 8, 1095, 63, 493, 304, 267, 1245, 14, 954, 63, 1757, 360, 23420, 297, 1300, 63, 493, 9, 267, 747, 14, 7162, 8, 1095, 63, 493, 9, 339, 327, 4473, 2272, 4084, 2556, 687, 314, 23754, 272, 1245, 14, 954, 63, 815, 360, 39, 7404, 316, 2556, 358, 272, 3819, 275, 18576, 14, 24769, 63, 1628, 4725, 68, 4600, 297, 2850, 1361, 13, 19134, 659, 9275, 29, 797, 12, 971, 267, 10760, 29, 797, 12, 1072, 29, 549, 9, 272, 29573, 275, 2863, 14, 362, 63, 585, 8, 888, 14, 9472, 57, 9757, 63, 3022, 435, 1994, 6839, 15, 30740, 13, 3221, 297, 971, 267, 283, 24580, 2100, 63, 998, 14619, 272, 4683, 275, 2863, 14, 362, 63, 585, 8, 888, 14, 9472, 57, 9757, 63, 3022, 435, 1994, 6839, 15, 30740, 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, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dhruvagarwal/django
tests/get_object_or_404/models.py
409
1133
""" DB-API Shortcuts ``get_object_or_404()`` is a shortcut function to be used in view functions for performing a ``get()`` lookup and raising a ``Http404`` exception if a ``DoesNotExist`` exception was raised during the ``get()`` call. ``get_list_or_404()`` is a shortcut function to be used in view functions for performing a ``filter()`` lookup and raising a ``Http404`` exception if a ``DoesNotExist`` exception was raised during the ``filter()`` call. """ from django.db import models from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=50) def __str__(self): return self.name class ArticleManager(models.Manager): def get_queryset(self): return super(ArticleManager, self).get_queryset().filter(authors__name__icontains='sir') @python_2_unicode_compatible class Article(models.Model): authors = models.ManyToManyField(Author) title = models.CharField(max_length=50) objects = models.Manager() by_a_sir = ArticleManager() def __str__(self): return self.title
bsd-3-clause
[ 624, 199, 2846, 13, 3735, 20124, 12946, 199, 199, 1040, 362, 63, 785, 63, 269, 63, 5188, 8497, 365, 282, 17522, 805, 370, 506, 1202, 315, 2455, 3423, 367, 199, 15795, 316, 282, 1124, 362, 8497, 4237, 436, 17026, 282, 1124, 5779, 5188, 1040, 1919, 340, 282, 199, 1040, 7400, 1040, 1919, 1990, 4915, 5309, 314, 1124, 362, 8497, 1240, 14, 199, 199, 1040, 362, 63, 513, 63, 269, 63, 5188, 8497, 365, 282, 17522, 805, 370, 506, 1202, 315, 2455, 3423, 367, 199, 15795, 316, 282, 1124, 1541, 8497, 4237, 436, 17026, 282, 1124, 5779, 5188, 1040, 1919, 340, 282, 199, 1040, 7400, 1040, 1919, 1990, 4915, 5309, 314, 1124, 1541, 8497, 1240, 14, 199, 624, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 6529, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 8281, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 7221, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1541, 8, 8149, 363, 354, 363, 30314, 534, 338, 82, 358, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8281, 8, 992, 14, 1685, 304, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 2251, 275, 1709, 14, 2988, 342, 272, 701, 63, 65, 63, 338, 82, 275, 8281, 2988, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 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 ]
[ 199, 2846, 13, 3735, 20124, 12946, 199, 199, 1040, 362, 63, 785, 63, 269, 63, 5188, 8497, 365, 282, 17522, 805, 370, 506, 1202, 315, 2455, 3423, 367, 199, 15795, 316, 282, 1124, 362, 8497, 4237, 436, 17026, 282, 1124, 5779, 5188, 1040, 1919, 340, 282, 199, 1040, 7400, 1040, 1919, 1990, 4915, 5309, 314, 1124, 362, 8497, 1240, 14, 199, 199, 1040, 362, 63, 513, 63, 269, 63, 5188, 8497, 365, 282, 17522, 805, 370, 506, 1202, 315, 2455, 3423, 367, 199, 15795, 316, 282, 1124, 1541, 8497, 4237, 436, 17026, 282, 1124, 5779, 5188, 1040, 1919, 340, 282, 199, 1040, 7400, 1040, 1919, 1990, 4915, 5309, 314, 1124, 1541, 8497, 1240, 14, 199, 624, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 6529, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 8281, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 8, 7221, 2988, 12, 291, 680, 362, 63, 7924, 1252, 1541, 8, 8149, 363, 354, 363, 30314, 534, 338, 82, 358, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8281, 8, 992, 14, 1685, 304, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 2251, 275, 1709, 14, 2988, 342, 272, 701, 63, 65, 63, 338, 82, 275, 8281, 2988, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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Windows API functions implemented as ctypes functions and classes as found in jaraco.windows (2.10). If you encounter issues with this module, please consider reporting the issues in jaraco.windows and asking the author to port the fixes back here. """ import ctypes import ctypes.wintypes from paramiko.py3compat import u try: import builtins except ImportError: import __builtin__ as builtins try: USHORT = ctypes.wintypes.USHORT except AttributeError: USHORT = ctypes.c_ushort ###################### # jaraco.windows.error def format_system_message(errno): """ Call FormatMessage with a system error number to retrieve the descriptive error message. """ # first some flags used by FormatMessageW ALLOCATE_BUFFER = 0x100 ARGUMENT_ARRAY = 0x2000 FROM_HMODULE = 0x800 FROM_STRING = 0x400 FROM_SYSTEM = 0x1000 IGNORE_INSERTS = 0x200 # Let FormatMessageW allocate the buffer (we'll free it below) # Also, let it know we want a system error message. flags = ALLOCATE_BUFFER | FROM_SYSTEM source = None message_id = errno language_id = 0 result_buffer = ctypes.wintypes.LPWSTR() buffer_size = 0 arguments = None format_bytes = ctypes.windll.kernel32.FormatMessageW( flags, source, message_id, language_id, ctypes.byref(result_buffer), buffer_size, arguments, ) # note the following will cause an infinite loop if GetLastError # repeatedly returns an error that cannot be formatted, although # this should not happen. handle_nonzero_success(format_bytes) message = result_buffer.value ctypes.windll.kernel32.LocalFree(result_buffer) return message class WindowsError(builtins.WindowsError): "more info about errors at http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx" def __init__(self, value=None): if value is None: value = ctypes.windll.kernel32.GetLastError() strerror = format_system_message(value) super(WindowsError, self).__init__(value, strerror) @property def message(self): return self.strerror @property def code(self): return self.winerror def __str__(self): return self.message def __repr__(self): return '{self.__class__.__name__}({self.winerror})'.format(**vars()) def handle_nonzero_success(result): if result == 0: raise WindowsError() CreateFileMapping = ctypes.windll.kernel32.CreateFileMappingW CreateFileMapping.argtypes = [ ctypes.wintypes.HANDLE, ctypes.c_void_p, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD, ctypes.wintypes.LPWSTR, ] CreateFileMapping.restype = ctypes.wintypes.HANDLE MapViewOfFile = ctypes.windll.kernel32.MapViewOfFile MapViewOfFile.restype = ctypes.wintypes.HANDLE class MemoryMap(object): """ A memory map object which can have security attributes overridden. """ def __init__(self, name, length, security_attributes=None): self.name = name self.length = length self.security_attributes = security_attributes self.pos = 0 def __enter__(self): p_SA = ( ctypes.byref(self.security_attributes) if self.security_attributes else None ) INVALID_HANDLE_VALUE = -1 PAGE_READWRITE = 0x4 FILE_MAP_WRITE = 0x2 filemap = ctypes.windll.kernel32.CreateFileMappingW( INVALID_HANDLE_VALUE, p_SA, PAGE_READWRITE, 0, self.length, u(self.name)) handle_nonzero_success(filemap) if filemap == INVALID_HANDLE_VALUE: raise Exception("Failed to create file mapping") self.filemap = filemap self.view = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, 0) return self def seek(self, pos): self.pos = pos def write(self, msg): n = len(msg) if self.pos + n >= self.length: # A little safety. raise ValueError("Refusing to write %d bytes" % n) ctypes.windll.kernel32.RtlMoveMemory(self.view + self.pos, msg, n) self.pos += n def read(self, n): """ Read n bytes from mapped view. """ out = ctypes.create_string_buffer(n) ctypes.windll.kernel32.RtlMoveMemory(out, self.view + self.pos, n) self.pos += n return out.raw def __exit__(self, exc_type, exc_val, tb): ctypes.windll.kernel32.UnmapViewOfFile(self.view) ctypes.windll.kernel32.CloseHandle(self.filemap) ######################### # jaraco.windows.security class TokenInformationClass: TokenUser = 1 class TOKEN_USER(ctypes.Structure): num = 1 _fields_ = [ ('SID', ctypes.c_void_p), ('ATTRIBUTES', ctypes.wintypes.DWORD), ] class SECURITY_DESCRIPTOR(ctypes.Structure): """ typedef struct _SECURITY_DESCRIPTOR { UCHAR Revision; UCHAR Sbz1; SECURITY_DESCRIPTOR_CONTROL Control; PSID Owner; PSID Group; PACL Sacl; PACL Dacl; } SECURITY_DESCRIPTOR; """ SECURITY_DESCRIPTOR_CONTROL = USHORT REVISION = 1 _fields_ = [ ('Revision', ctypes.c_ubyte), ('Sbz1', ctypes.c_ubyte), ('Control', SECURITY_DESCRIPTOR_CONTROL), ('Owner', ctypes.c_void_p), ('Group', ctypes.c_void_p), ('Sacl', ctypes.c_void_p), ('Dacl', ctypes.c_void_p), ] class SECURITY_ATTRIBUTES(ctypes.Structure): """ typedef struct _SECURITY_ATTRIBUTES { DWORD nLength; LPVOID lpSecurityDescriptor; BOOL bInheritHandle; } SECURITY_ATTRIBUTES; """ _fields_ = [ ('nLength', ctypes.wintypes.DWORD), ('lpSecurityDescriptor', ctypes.c_void_p), ('bInheritHandle', ctypes.wintypes.BOOL), ] def __init__(self, *args, **kwargs): super(SECURITY_ATTRIBUTES, self).__init__(*args, **kwargs) self.nLength = ctypes.sizeof(SECURITY_ATTRIBUTES) @property def descriptor(self): return self._descriptor @descriptor.setter def descriptor(self, value): self._descriptor = value self.lpSecurityDescriptor = ctypes.addressof(value) def GetTokenInformation(token, information_class): """ Given a token, get the token information for it. """ data_size = ctypes.wintypes.DWORD() ctypes.windll.advapi32.GetTokenInformation(token, information_class.num, 0, 0, ctypes.byref(data_size)) data = ctypes.create_string_buffer(data_size.value) handle_nonzero_success(ctypes.windll.advapi32.GetTokenInformation(token, information_class.num, ctypes.byref(data), ctypes.sizeof(data), ctypes.byref(data_size))) return ctypes.cast(data, ctypes.POINTER(TOKEN_USER)).contents class TokenAccess: TOKEN_QUERY = 0x8 def OpenProcessToken(proc_handle, access): result = ctypes.wintypes.HANDLE() proc_handle = ctypes.wintypes.HANDLE(proc_handle) handle_nonzero_success(ctypes.windll.advapi32.OpenProcessToken( proc_handle, access, ctypes.byref(result))) return result def get_current_user(): """ Return a TOKEN_USER for the owner of this process. """ process = OpenProcessToken( ctypes.windll.kernel32.GetCurrentProcess(), TokenAccess.TOKEN_QUERY, ) return GetTokenInformation(process, TOKEN_USER) def get_security_attributes_for_user(user=None): """ Return a SECURITY_ATTRIBUTES structure with the SID set to the specified user (uses current user if none is specified). """ if user is None: user = get_current_user() assert isinstance(user, TOKEN_USER), "user must be TOKEN_USER instance" SD = SECURITY_DESCRIPTOR() SA = SECURITY_ATTRIBUTES() # by attaching the actual security descriptor, it will be garbage- # collected with the security attributes SA.descriptor = SD SA.bInheritHandle = 1 ctypes.windll.advapi32.InitializeSecurityDescriptor(ctypes.byref(SD), SECURITY_DESCRIPTOR.REVISION) ctypes.windll.advapi32.SetSecurityDescriptorOwner(ctypes.byref(SD), user.SID, 0) return SA
lgpl-2.1
[ 624, 199, 8647, 3261, 3423, 6366, 465, 5577, 3423, 436, 3992, 465, 1911, 199, 262, 16290, 13286, 14, 8258, 334, 18, 14, 709, 680, 199, 199, 3917, 1265, 655, 5337, 10876, 543, 642, 859, 12, 8749, 11201, 17290, 314, 10876, 199, 262, 16290, 13286, 14, 8258, 436, 7198, 316, 314, 4132, 370, 1844, 314, 25079, 1771, 2348, 14, 199, 624, 199, 199, 646, 5577, 199, 646, 5577, 14, 27171, 199, 504, 26162, 14, 647, 19, 5819, 492, 399, 199, 893, 26, 272, 492, 12963, 199, 2590, 3545, 26, 272, 492, 636, 5351, 363, 465, 12963, 199, 199, 893, 26, 272, 738, 13003, 275, 5577, 14, 27171, 14, 14527, 2596, 199, 2590, 4281, 26, 272, 738, 13003, 275, 5577, 14, 67, 63, 27170, 199, 199, 749, 3726, 199, 3, 16290, 13286, 14, 8258, 14, 705, 199, 199, 318, 1475, 63, 2253, 63, 1188, 8, 7931, 304, 272, 408, 272, 6523, 9701, 2209, 543, 282, 2656, 1125, 1329, 370, 8044, 272, 314, 30262, 1125, 1245, 14, 272, 408, 272, 327, 1642, 2005, 3285, 1202, 701, 9701, 2209, 55, 272, 12112, 5752, 1951, 63, 10960, 275, 378, 88, 1960, 272, 4160, 39, 18272, 63, 12322, 275, 378, 88, 8269, 272, 4442, 63, 40, 10001, 275, 378, 88, 6718, 272, 4442, 63, 5353, 275, 378, 88, 5303, 272, 4442, 63, 12711, 275, 378, 88, 5279, 272, 27499, 5788, 63, 10258, 51, 275, 378, 88, 1840, 339, 327, 12230, 9701, 2209, 55, 18310, 314, 3335, 334, 1129, 7171, 2867, 652, 5084, 9, 272, 327, 6121, 12, 4691, 652, 5715, 781, 2934, 282, 2656, 1125, 1245, 14, 272, 3285, 275, 12112, 5752, 1951, 63, 10960, 1204, 4442, 63, 12711, 272, 1350, 275, 488, 272, 1245, 63, 344, 275, 7554, 272, 2637, 63, 344, 275, 378, 272, 754, 63, 2738, 275, 5577, 14, 27171, 14, 9257, 55, 3027, 342, 272, 3335, 63, 890, 275, 378, 272, 2368, 275, 488, 272, 1475, 63, 2394, 275, 5577, 14, 25522, 14, 4989, 708, 14, 3484, 2209, 55, 8, 267, 3285, 12, 267, 1350, 12, 267, 1245, 63, 344, 12, 267, 2637, 63, 344, 12, 267, 5577, 14, 20447, 8, 1099, 63, 2738, 395, 267, 3335, 63, 890, 12, 267, 2368, 12, 272, 776, 272, 327, 5317, 314, 2569, 911, 7675, 376, 15258, 4438, 340, 2372, 6090, 547, 272, 327, 221, 27714, 2529, 376, 1125, 626, 3913, 506, 7871, 12, 22160, 272, 327, 221, 642, 1077, 440, 5992, 14, 272, 2429, 63, 10262, 63, 3742, 8, 908, 63, 2394, 9, 272, 1245, 275, 754, 63, 2738, 14, 585, 272, 5577, 14, 25522, 14, 4989, 708, 14, 5339, 10146, 8, 1099, 63, 2738, 9, 272, 372, 1245, 421, 199, 533, 23950, 8, 10372, 14, 8647, 547, 304, 272, 298, 6878, 2256, 3595, 2552, 737, 1455, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 706, 2333, 969, 2835, 8, 7428, 14, 2426, 680, 26146, 2, 339, 347, 636, 826, 721, 277, 12, 574, 29, 403, 304, 267, 340, 574, 365, 488, 26, 288, 574, 275, 5577, 14, 25522, 14, 4989, 708, 14, 1002, 6090, 547, 342, 267, 410, 17844, 275, 1475, 63, 2253, 63, 1188, 8, 585, 9, 267, 1613, 8, 8647, 547, 12, 291, 2843, 826, 721, 585, 12, 410, 17844, 9, 339, 768, 1829, 272, 347, 1245, 8, 277, 304, 267, 372, 291, 14, 20395, 339, 768, 1829, 272, 347, 1233, 8, 277, 304, 267, 372, 291, 14, 2676, 705, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1188, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 5041, 277, 855, 533, 4914, 354, 363, 93, 2561, 277, 14, 2676, 705, 25885, 908, 3682, 2936, 1012, 199, 199, 318, 2429, 63, 10262, 63, 3742, 8, 1099, 304, 272, 340, 754, 508, 378, 26, 267, 746, 23950, 342, 421, 199, 2499, 1173, 7674, 275, 5577, 14, 25522, 14, 4989, 708, 14, 2499, 1173, 7674, 55, 199, 2499, 1173, 7674, 14, 10025, 275, 359, 272, 5577, 14, 27171, 14, 15885, 12, 272, 5577, 14, 67, 63, 1647, 63, 80, 12, 272, 5577, 14, 27171, 14, 24754, 12, 272, 5577, 14, 27171, 14, 24754, 12, 272, 5577, 14, 27171, 14, 24754, 12, 272, 5577, 14, 27171, 14, 9257, 55, 3027, 12, 199, 61, 199, 2499, 1173, 7674, 14, 9990, 275, 5577, 14, 27171, 14, 15885, 199, 199, 2956, 2768, 3466, 1173, 275, 5577, 14, 25522, 14, 4989, 708, 14, 2956, 2768, 3466, 1173, 199, 2956, 2768, 3466, 1173, 14, 9990, 275, 5577, 14, 27171, 14, 15885, 199, 199, 533, 15825, 2956, 8, 785, 304, 272, 408, 272, 437, 4402, 2341, 909, 1314, 883, 1172, 6391, 3004, 10087, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 12, 2582, 12, 6391, 63, 2987, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1267, 275, 2582, 267, 291, 14, 4416, 63, 2987, 275, 6391, 63, 2987, 267, 291, 14, 1712, 275, 378, 339, 347, 636, 4200, 721, 277, 304, 267, 299, 63, 4251, 275, 334, 288, 5577, 14, 20447, 8, 277, 14, 4416, 63, 2987, 9, 288, 340, 291, 14, 4416, 63, 2987, 587, 488, 267, 776, 267, 29901, 63, 15885, 63, 7041, 275, 446, 17, 267, 510, 2962, 63, 5670, 10387, 275, 378, 88, 20, 267, 13024, 63, 5443, 63, 10387, 275, 378, 88, 18, 267, 570, 1130, 275, 5577, 14, 25522, 14, 4989, 708, 14, 2499, 1173, 7674, 55, 8, 288, 29901, 63, 15885, 63, 7041, 12, 299, 63, 4251, 12, 510, 2962, 63, 5670, 10387, 12, 378, 12, 291, 14, 1267, 12, 288, 399, 8, 277, 14, 354, 430, 267, 2429, 63, 10262, 63, 3742, 8, 493, 1130, 9, 267, 340, 570, 1130, 508, 29901, 63, 15885, 63, 7041, 26, 288, 746, 2186, 480, 4276, 370, 1218, 570, 4412, 531, 267, 291, 14, 493, 1130, 275, 570, 1130, 267, 291, 14, 1345, 275, 9672, 2768, 3466, 1173, 8, 493, 1130, 12, 13024, 63, 5443, 63, 10387, 12, 378, 12, 378, 12, 378, 9, 267, 372, 291, 339, 347, 12005, 8, 277, 12, 2086, 304, 267, 291, 14, 1712, 275, 2086, 339, 347, 2218, 8, 277, 12, 1499, 304, 267, 302, 275, 822, 8, 1328, 9, 267, 340, 291, 14, 1712, 435, 302, 2356 ]
[ 199, 8647, 3261, 3423, 6366, 465, 5577, 3423, 436, 3992, 465, 1911, 199, 262, 16290, 13286, 14, 8258, 334, 18, 14, 709, 680, 199, 199, 3917, 1265, 655, 5337, 10876, 543, 642, 859, 12, 8749, 11201, 17290, 314, 10876, 199, 262, 16290, 13286, 14, 8258, 436, 7198, 316, 314, 4132, 370, 1844, 314, 25079, 1771, 2348, 14, 199, 624, 199, 199, 646, 5577, 199, 646, 5577, 14, 27171, 199, 504, 26162, 14, 647, 19, 5819, 492, 399, 199, 893, 26, 272, 492, 12963, 199, 2590, 3545, 26, 272, 492, 636, 5351, 363, 465, 12963, 199, 199, 893, 26, 272, 738, 13003, 275, 5577, 14, 27171, 14, 14527, 2596, 199, 2590, 4281, 26, 272, 738, 13003, 275, 5577, 14, 67, 63, 27170, 199, 199, 749, 3726, 199, 3, 16290, 13286, 14, 8258, 14, 705, 199, 199, 318, 1475, 63, 2253, 63, 1188, 8, 7931, 304, 272, 408, 272, 6523, 9701, 2209, 543, 282, 2656, 1125, 1329, 370, 8044, 272, 314, 30262, 1125, 1245, 14, 272, 408, 272, 327, 1642, 2005, 3285, 1202, 701, 9701, 2209, 55, 272, 12112, 5752, 1951, 63, 10960, 275, 378, 88, 1960, 272, 4160, 39, 18272, 63, 12322, 275, 378, 88, 8269, 272, 4442, 63, 40, 10001, 275, 378, 88, 6718, 272, 4442, 63, 5353, 275, 378, 88, 5303, 272, 4442, 63, 12711, 275, 378, 88, 5279, 272, 27499, 5788, 63, 10258, 51, 275, 378, 88, 1840, 339, 327, 12230, 9701, 2209, 55, 18310, 314, 3335, 334, 1129, 7171, 2867, 652, 5084, 9, 272, 327, 6121, 12, 4691, 652, 5715, 781, 2934, 282, 2656, 1125, 1245, 14, 272, 3285, 275, 12112, 5752, 1951, 63, 10960, 1204, 4442, 63, 12711, 272, 1350, 275, 488, 272, 1245, 63, 344, 275, 7554, 272, 2637, 63, 344, 275, 378, 272, 754, 63, 2738, 275, 5577, 14, 27171, 14, 9257, 55, 3027, 342, 272, 3335, 63, 890, 275, 378, 272, 2368, 275, 488, 272, 1475, 63, 2394, 275, 5577, 14, 25522, 14, 4989, 708, 14, 3484, 2209, 55, 8, 267, 3285, 12, 267, 1350, 12, 267, 1245, 63, 344, 12, 267, 2637, 63, 344, 12, 267, 5577, 14, 20447, 8, 1099, 63, 2738, 395, 267, 3335, 63, 890, 12, 267, 2368, 12, 272, 776, 272, 327, 5317, 314, 2569, 911, 7675, 376, 15258, 4438, 340, 2372, 6090, 547, 272, 327, 221, 27714, 2529, 376, 1125, 626, 3913, 506, 7871, 12, 22160, 272, 327, 221, 642, 1077, 440, 5992, 14, 272, 2429, 63, 10262, 63, 3742, 8, 908, 63, 2394, 9, 272, 1245, 275, 754, 63, 2738, 14, 585, 272, 5577, 14, 25522, 14, 4989, 708, 14, 5339, 10146, 8, 1099, 63, 2738, 9, 272, 372, 1245, 421, 199, 533, 23950, 8, 10372, 14, 8647, 547, 304, 272, 298, 6878, 2256, 3595, 2552, 737, 1455, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 706, 2333, 969, 2835, 8, 7428, 14, 2426, 680, 26146, 2, 339, 347, 636, 826, 721, 277, 12, 574, 29, 403, 304, 267, 340, 574, 365, 488, 26, 288, 574, 275, 5577, 14, 25522, 14, 4989, 708, 14, 1002, 6090, 547, 342, 267, 410, 17844, 275, 1475, 63, 2253, 63, 1188, 8, 585, 9, 267, 1613, 8, 8647, 547, 12, 291, 2843, 826, 721, 585, 12, 410, 17844, 9, 339, 768, 1829, 272, 347, 1245, 8, 277, 304, 267, 372, 291, 14, 20395, 339, 768, 1829, 272, 347, 1233, 8, 277, 304, 267, 372, 291, 14, 2676, 705, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1188, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 5041, 277, 855, 533, 4914, 354, 363, 93, 2561, 277, 14, 2676, 705, 25885, 908, 3682, 2936, 1012, 199, 199, 318, 2429, 63, 10262, 63, 3742, 8, 1099, 304, 272, 340, 754, 508, 378, 26, 267, 746, 23950, 342, 421, 199, 2499, 1173, 7674, 275, 5577, 14, 25522, 14, 4989, 708, 14, 2499, 1173, 7674, 55, 199, 2499, 1173, 7674, 14, 10025, 275, 359, 272, 5577, 14, 27171, 14, 15885, 12, 272, 5577, 14, 67, 63, 1647, 63, 80, 12, 272, 5577, 14, 27171, 14, 24754, 12, 272, 5577, 14, 27171, 14, 24754, 12, 272, 5577, 14, 27171, 14, 24754, 12, 272, 5577, 14, 27171, 14, 9257, 55, 3027, 12, 199, 61, 199, 2499, 1173, 7674, 14, 9990, 275, 5577, 14, 27171, 14, 15885, 199, 199, 2956, 2768, 3466, 1173, 275, 5577, 14, 25522, 14, 4989, 708, 14, 2956, 2768, 3466, 1173, 199, 2956, 2768, 3466, 1173, 14, 9990, 275, 5577, 14, 27171, 14, 15885, 199, 199, 533, 15825, 2956, 8, 785, 304, 272, 408, 272, 437, 4402, 2341, 909, 1314, 883, 1172, 6391, 3004, 10087, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 536, 12, 2582, 12, 6391, 63, 2987, 29, 403, 304, 267, 291, 14, 354, 275, 536, 267, 291, 14, 1267, 275, 2582, 267, 291, 14, 4416, 63, 2987, 275, 6391, 63, 2987, 267, 291, 14, 1712, 275, 378, 339, 347, 636, 4200, 721, 277, 304, 267, 299, 63, 4251, 275, 334, 288, 5577, 14, 20447, 8, 277, 14, 4416, 63, 2987, 9, 288, 340, 291, 14, 4416, 63, 2987, 587, 488, 267, 776, 267, 29901, 63, 15885, 63, 7041, 275, 446, 17, 267, 510, 2962, 63, 5670, 10387, 275, 378, 88, 20, 267, 13024, 63, 5443, 63, 10387, 275, 378, 88, 18, 267, 570, 1130, 275, 5577, 14, 25522, 14, 4989, 708, 14, 2499, 1173, 7674, 55, 8, 288, 29901, 63, 15885, 63, 7041, 12, 299, 63, 4251, 12, 510, 2962, 63, 5670, 10387, 12, 378, 12, 291, 14, 1267, 12, 288, 399, 8, 277, 14, 354, 430, 267, 2429, 63, 10262, 63, 3742, 8, 493, 1130, 9, 267, 340, 570, 1130, 508, 29901, 63, 15885, 63, 7041, 26, 288, 746, 2186, 480, 4276, 370, 1218, 570, 4412, 531, 267, 291, 14, 493, 1130, 275, 570, 1130, 267, 291, 14, 1345, 275, 9672, 2768, 3466, 1173, 8, 493, 1130, 12, 13024, 63, 5443, 63, 10387, 12, 378, 12, 378, 12, 378, 9, 267, 372, 291, 339, 347, 12005, 8, 277, 12, 2086, 304, 267, 291, 14, 1712, 275, 2086, 339, 347, 2218, 8, 277, 12, 1499, 304, 267, 302, 275, 822, 8, 1328, 9, 267, 340, 291, 14, 1712, 435, 302, 2356, 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,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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
esparta/logilab_common3
test/unittest_graph.py
14
3196
# unit tests for the cache module # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of logilab-common. # # logilab-common is free software: you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 2.1 of the License, or (at your option) any # later version. # # logilab-common is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License along # with logilab-common. If not, see <http://www.gnu.org/licenses/>. from logilab.common.testlib import TestCase, unittest_main from logilab.common.graph import get_cycles, has_path, ordered_nodes, UnorderableGraph class getCyclesTC(TestCase): def test_known0(self): self.assertEqual(get_cycles({1:[2], 2:[3], 3:[1]}), [[1, 2, 3]]) def test_known1(self): self.assertEqual(get_cycles({1:[2], 2:[3], 3:[1, 4], 4:[3]}), [[1, 2, 3], [3, 4]]) def test_known2(self): self.assertEqual(get_cycles({1:[2], 2:[3], 3:[0], 0:[]}), []) class hasPathTC(TestCase): def test_direct_connection(self): self.assertEqual(has_path({'A': ['B'], 'B': ['A']}, 'A', 'B'), ['B']) def test_indirect_connection(self): self.assertEqual(has_path({'A': ['B'], 'B': ['A', 'C'], 'C': ['B']}, 'A', 'C'), ['B', 'C']) def test_no_connection(self): self.assertEqual(has_path({'A': ['B'], 'B': ['A']}, 'A', 'C'), None) def test_cycle(self): self.assertEqual(has_path({'A': ['A']}, 'A', 'B'), None) class ordered_nodesTC(TestCase): def test_one_item(self): graph = {'a':[]} ordered = ordered_nodes(graph) self.assertEqual(ordered, ('a',)) def test_single_dependency(self): graph = {'a':['b'], 'b':[]} ordered = ordered_nodes(graph) self.assertEqual(ordered, ('a','b')) graph = {'a':[], 'b':['a']} ordered = ordered_nodes(graph) self.assertEqual(ordered, ('b','a')) def test_two_items_no_dependency(self): graph = {'a':[], 'b':[]} ordered = ordered_nodes(graph) self.assertEqual(ordered, ('a','b')) def test_three_items_no_dependency(self): graph = {'a':[], 'b':[], 'c':[]} ordered = ordered_nodes(graph) self.assertEqual(ordered, ('a', 'b', 'c')) def test_three_items_one_dependency(self): graph = {'a': ['c'], 'b': [], 'c':[]} ordered = ordered_nodes(graph) self.assertEqual(ordered, ('a', 'b', 'c')) def test_three_items_two_dependencies(self): graph = {'a': ['b'], 'b': ['c'], 'c':[]} ordered = ordered_nodes(graph) self.assertEqual(ordered, ('a', 'b', 'c')) def test_bad_graph(self): graph = {'a':['b']} self.assertRaises(UnorderableGraph, ordered_nodes, graph) if __name__ == "__main__": unittest_main()
gpl-2.0
[ 3, 4137, 2295, 367, 314, 2581, 859, 199, 3, 4248, 13004, 13, 8128, 5051, 1193, 1217, 428, 14, 33, 14, 334, 1262, 374, 12, 28671, 7140, 395, 1006, 4481, 4644, 14, 199, 3, 8966, 1455, 921, 1544, 14, 793, 24142, 14, 4391, 15, 1553, 6016, 475, 26, 7811, 32, 793, 24142, 14, 4391, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 943, 24142, 13, 2330, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 12, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 199, 3, 543, 943, 24142, 13, 2330, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 943, 24142, 14, 2330, 14, 396, 773, 492, 7640, 12, 2882, 63, 973, 199, 504, 943, 24142, 14, 2330, 14, 2180, 492, 664, 63, 23356, 12, 965, 63, 515, 12, 7741, 63, 2415, 12, 1910, 27788, 6842, 4578, 199, 199, 533, 664, 28016, 5708, 8, 1746, 304, 339, 347, 511, 63, 3159, 16, 8, 277, 304, 267, 291, 14, 629, 8, 362, 63, 23356, 2561, 17, 7766, 18, 467, 499, 7766, 19, 467, 650, 7766, 17, 61, 8688, 3474, 17, 12, 499, 12, 650, 3934, 339, 347, 511, 63, 3159, 17, 8, 277, 304, 267, 291, 14, 629, 8, 362, 63, 23356, 2561, 17, 7766, 18, 467, 499, 7766, 19, 467, 650, 7766, 17, 12, 841, 467, 841, 7766, 19, 61, 8688, 3474, 17, 12, 499, 12, 650, 467, 359, 19, 12, 841, 3934, 339, 347, 511, 63, 3159, 18, 8, 277, 304, 267, 291, 14, 629, 8, 362, 63, 23356, 2561, 17, 7766, 18, 467, 499, 7766, 19, 467, 650, 7766, 16, 467, 378, 7766, 61, 8688, 3073, 421, 199, 533, 965, 2042, 5708, 8, 1746, 304, 339, 347, 511, 63, 2275, 63, 2105, 8, 277, 304, 267, 291, 14, 629, 8, 1989, 63, 515, 3252, 33, 356, 788, 34, 995, 283, 34, 356, 788, 33, 14949, 283, 33, 297, 283, 34, 659, 788, 34, 1105, 339, 347, 511, 63, 29306, 63, 2105, 8, 277, 304, 267, 291, 14, 629, 8, 1989, 63, 515, 3252, 33, 356, 788, 34, 995, 283, 34, 356, 788, 33, 297, 283, 35, 995, 283, 35, 356, 788, 34, 14949, 283, 33, 297, 283, 35, 659, 788, 34, 297, 283, 35, 1105, 339, 347, 511, 63, 889, 63, 2105, 8, 277, 304, 267, 291, 14, 629, 8, 1989, 63, 515, 3252, 33, 356, 788, 34, 995, 283, 34, 356, 788, 33, 14949, 283, 33, 297, 283, 35, 659, 488, 9, 339, 347, 511, 63, 7612, 8, 277, 304, 267, 291, 14, 629, 8, 1989, 63, 515, 3252, 33, 356, 788, 33, 14949, 283, 33, 297, 283, 34, 659, 488, 9, 199, 199, 533, 7741, 63, 2415, 5708, 8, 1746, 304, 339, 347, 511, 63, 368, 63, 1053, 8, 277, 304, 267, 3343, 275, 791, 65, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 16829, 339, 347, 511, 63, 4780, 63, 8575, 8, 277, 304, 267, 3343, 275, 791, 65, 21662, 66, 995, 283, 66, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 1673, 66, 1333, 267, 3343, 275, 791, 65, 15211, 467, 283, 66, 21662, 65, 12074, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 66, 1673, 65, 1333, 339, 347, 511, 63, 5601, 63, 1744, 63, 889, 63, 8575, 8, 277, 304, 267, 3343, 275, 791, 65, 15211, 467, 283, 66, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 1673, 66, 1333, 339, 347, 511, 63, 10480, 63, 1744, 63, 889, 63, 8575, 8, 277, 304, 267, 3343, 275, 791, 65, 15211, 467, 283, 66, 15211, 467, 283, 67, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 297, 283, 66, 297, 283, 67, 1333, 339, 347, 511, 63, 10480, 63, 1744, 63, 368, 63, 8575, 8, 277, 304, 267, 3343, 275, 791, 65, 356, 788, 67, 995, 283, 66, 356, 990, 283, 67, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 297, 283, 66, 297, 283, 67, 1333, 339, 347, 511, 63, 10480, 63, 1744, 63, 5601, 63, 5714, 8, 277, 304, 267, 3343, 275, 791, 65, 356, 788, 66, 995, 283, 66, 356, 788, 67, 995, 283, 67, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 297, 283, 66, 297, 283, 67, 1333, 339, 347, 511, 63, 4087, 63, 2180, 8, 277, 304, 267, 3343, 275, 791, 65, 21662, 66, 12074, 267, 291, 14, 1855, 8, 1358, 27788, 6842, 4578, 12, 7741, 63, 2415, 12, 3343, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 63, 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 ]
[ 4137, 2295, 367, 314, 2581, 859, 199, 3, 4248, 13004, 13, 8128, 5051, 1193, 1217, 428, 14, 33, 14, 334, 1262, 374, 12, 28671, 7140, 395, 1006, 4481, 4644, 14, 199, 3, 8966, 1455, 921, 1544, 14, 793, 24142, 14, 4391, 15, 1553, 6016, 475, 26, 7811, 32, 793, 24142, 14, 4391, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 943, 24142, 13, 2330, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 199, 3, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 199, 3, 2290, 2752, 12, 1902, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 199, 3, 2945, 1015, 14, 199, 3, 199, 3, 943, 24142, 13, 2330, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 199, 3, 543, 943, 24142, 13, 2330, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 943, 24142, 14, 2330, 14, 396, 773, 492, 7640, 12, 2882, 63, 973, 199, 504, 943, 24142, 14, 2330, 14, 2180, 492, 664, 63, 23356, 12, 965, 63, 515, 12, 7741, 63, 2415, 12, 1910, 27788, 6842, 4578, 199, 199, 533, 664, 28016, 5708, 8, 1746, 304, 339, 347, 511, 63, 3159, 16, 8, 277, 304, 267, 291, 14, 629, 8, 362, 63, 23356, 2561, 17, 7766, 18, 467, 499, 7766, 19, 467, 650, 7766, 17, 61, 8688, 3474, 17, 12, 499, 12, 650, 3934, 339, 347, 511, 63, 3159, 17, 8, 277, 304, 267, 291, 14, 629, 8, 362, 63, 23356, 2561, 17, 7766, 18, 467, 499, 7766, 19, 467, 650, 7766, 17, 12, 841, 467, 841, 7766, 19, 61, 8688, 3474, 17, 12, 499, 12, 650, 467, 359, 19, 12, 841, 3934, 339, 347, 511, 63, 3159, 18, 8, 277, 304, 267, 291, 14, 629, 8, 362, 63, 23356, 2561, 17, 7766, 18, 467, 499, 7766, 19, 467, 650, 7766, 16, 467, 378, 7766, 61, 8688, 3073, 421, 199, 533, 965, 2042, 5708, 8, 1746, 304, 339, 347, 511, 63, 2275, 63, 2105, 8, 277, 304, 267, 291, 14, 629, 8, 1989, 63, 515, 3252, 33, 356, 788, 34, 995, 283, 34, 356, 788, 33, 14949, 283, 33, 297, 283, 34, 659, 788, 34, 1105, 339, 347, 511, 63, 29306, 63, 2105, 8, 277, 304, 267, 291, 14, 629, 8, 1989, 63, 515, 3252, 33, 356, 788, 34, 995, 283, 34, 356, 788, 33, 297, 283, 35, 995, 283, 35, 356, 788, 34, 14949, 283, 33, 297, 283, 35, 659, 788, 34, 297, 283, 35, 1105, 339, 347, 511, 63, 889, 63, 2105, 8, 277, 304, 267, 291, 14, 629, 8, 1989, 63, 515, 3252, 33, 356, 788, 34, 995, 283, 34, 356, 788, 33, 14949, 283, 33, 297, 283, 35, 659, 488, 9, 339, 347, 511, 63, 7612, 8, 277, 304, 267, 291, 14, 629, 8, 1989, 63, 515, 3252, 33, 356, 788, 33, 14949, 283, 33, 297, 283, 34, 659, 488, 9, 199, 199, 533, 7741, 63, 2415, 5708, 8, 1746, 304, 339, 347, 511, 63, 368, 63, 1053, 8, 277, 304, 267, 3343, 275, 791, 65, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 16829, 339, 347, 511, 63, 4780, 63, 8575, 8, 277, 304, 267, 3343, 275, 791, 65, 21662, 66, 995, 283, 66, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 1673, 66, 1333, 267, 3343, 275, 791, 65, 15211, 467, 283, 66, 21662, 65, 12074, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 66, 1673, 65, 1333, 339, 347, 511, 63, 5601, 63, 1744, 63, 889, 63, 8575, 8, 277, 304, 267, 3343, 275, 791, 65, 15211, 467, 283, 66, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 1673, 66, 1333, 339, 347, 511, 63, 10480, 63, 1744, 63, 889, 63, 8575, 8, 277, 304, 267, 3343, 275, 791, 65, 15211, 467, 283, 66, 15211, 467, 283, 67, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 297, 283, 66, 297, 283, 67, 1333, 339, 347, 511, 63, 10480, 63, 1744, 63, 368, 63, 8575, 8, 277, 304, 267, 3343, 275, 791, 65, 356, 788, 67, 995, 283, 66, 356, 990, 283, 67, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 297, 283, 66, 297, 283, 67, 1333, 339, 347, 511, 63, 10480, 63, 1744, 63, 5601, 63, 5714, 8, 277, 304, 267, 3343, 275, 791, 65, 356, 788, 66, 995, 283, 66, 356, 788, 67, 995, 283, 67, 356, 8607, 93, 267, 7741, 275, 7741, 63, 2415, 8, 2180, 9, 267, 291, 14, 629, 8, 8235, 12, 661, 65, 297, 283, 66, 297, 283, 67, 1333, 339, 347, 511, 63, 4087, 63, 2180, 8, 277, 304, 267, 3343, 275, 791, 65, 21662, 66, 12074, 267, 291, 14, 1855, 8, 1358, 27788, 6842, 4578, 12, 7741, 63, 2415, 12, 3343, 9, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 2882, 63, 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, 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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license that can be # found in the LICENSE file. # Notes: # # This is all roughly based on the Makefile system used by the Linux # kernel, but is a non-recursive make -- we put the entire dependency # graph in front of make and let it figure it out. # # The code below generates a separate .mk file for each target, but # all are sourced by the top-level Makefile. This means that all # variables in .mk-files clobber one another. Be careful to use := # where appropriate for immediate evaluation, and similarly to watch # that you're not relying on a variable value to last beween different # .mk files. # # TODOs: # # Global settings and utility functions are currently stuffed in the # toplevel Makefile. It may make sense to generate some .mk files on # the side to keep the the files readable. import os import re import sys import subprocess import gyp import gyp.common import gyp.xcode_emulation from gyp.common import GetEnvironFallback from gyp.common import GypError generator_default_variables = { 'EXECUTABLE_PREFIX': '', 'EXECUTABLE_SUFFIX': '', 'STATIC_LIB_PREFIX': 'lib', 'SHARED_LIB_PREFIX': 'lib', 'STATIC_LIB_SUFFIX': '.a', 'INTERMEDIATE_DIR': '$(obj).$(TOOLSET)/$(TARGET)/geni', 'SHARED_INTERMEDIATE_DIR': '$(obj)/gen', 'PRODUCT_DIR': '$(builddir)', 'RULE_INPUT_ROOT': '%(INPUT_ROOT)s', # This gets expanded by Python. 'RULE_INPUT_DIRNAME': '%(INPUT_DIRNAME)s', # This gets expanded by Python. 'RULE_INPUT_PATH': '$(abspath $<)', 'RULE_INPUT_EXT': '$(suffix $<)', 'RULE_INPUT_NAME': '$(notdir $<)', 'CONFIGURATION_NAME': '$(BUILDTYPE)', } # Make supports multiple toolsets generator_supports_multiple_toolsets = True # Request sorted dependencies in the order from dependents to dependencies. generator_wants_sorted_dependencies = False # Placates pylint. generator_additional_non_configuration_keys = [] generator_additional_path_sections = [] generator_extra_sources_for_rules = [] generator_filelist_paths = None def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" flavor = gyp.common.GetFlavor(params) if flavor == 'mac': default_variables.setdefault('OS', 'mac') default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') default_variables.setdefault('SHARED_LIB_DIR', generator_default_variables['PRODUCT_DIR']) default_variables.setdefault('LIB_DIR', generator_default_variables['PRODUCT_DIR']) # Copy additional generator configuration data from Xcode, which is shared # by the Mac Make generator. import gyp.generator.xcode as xcode_generator global generator_additional_non_configuration_keys generator_additional_non_configuration_keys = getattr(xcode_generator, 'generator_additional_non_configuration_keys', []) global generator_additional_path_sections generator_additional_path_sections = getattr(xcode_generator, 'generator_additional_path_sections', []) global generator_extra_sources_for_rules generator_extra_sources_for_rules = getattr(xcode_generator, 'generator_extra_sources_for_rules', []) COMPILABLE_EXTENSIONS.update({'.m': 'objc', '.mm' : 'objcxx'}) else: operating_system = flavor if flavor == 'android': operating_system = 'linux' # Keep this legacy behavior for now. default_variables.setdefault('OS', operating_system) default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') default_variables.setdefault('SHARED_LIB_DIR','$(builddir)/lib.$(TOOLSET)') default_variables.setdefault('LIB_DIR', '$(obj).$(TOOLSET)') def CalculateGeneratorInputInfo(params): """Calculate the generator specific info that gets fed to input (called by gyp).""" generator_flags = params.get('generator_flags', {}) android_ndk_version = generator_flags.get('android_ndk_version', None) # Android NDK requires a strict link order. if android_ndk_version: global generator_wants_sorted_dependencies generator_wants_sorted_dependencies = True output_dir = params['options'].generator_output or \ params['options'].toplevel_dir builddir_name = generator_flags.get('output_dir', 'out') qualified_out_dir = os.path.normpath(os.path.join( output_dir, builddir_name, 'gypfiles')) global generator_filelist_paths generator_filelist_paths = { 'toplevel': params['options'].toplevel_dir, 'qualified_out_dir': qualified_out_dir, } # The .d checking code below uses these functions: # wildcard, sort, foreach, shell, wordlist # wildcard can handle spaces, the rest can't. # Since I could find no way to make foreach work with spaces in filenames # correctly, the .d files have spaces replaced with another character. The .d # file for # Chromium\ Framework.framework/foo # is for example # out/Release/.deps/out/Release/Chromium?Framework.framework/foo # This is the replacement character. SPACE_REPLACEMENT = '?' LINK_COMMANDS_LINUX = """\ quiet_cmd_alink = AR($(TOOLSET)) $@ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) quiet_cmd_alink_thin = AR($(TOOLSET)) $@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) # Due to circular dependencies between libraries :(, we wrap the # special "figure out circular dependencies" flags around the entire # input list during linking. quiet_cmd_link = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) # We support two kinds of shared objects (.so): # 1) shared_library, which is just bundling together many dependent libraries # into a link line. # 2) loadable_module, which is generating a module intended for dlopen(). # # They differ only slightly: # In the former case, we want to package all dependent code into the .so. # In the latter case, we want to package just the API exposed by the # outermost module. # This means shared_library uses --whole-archive, while loadable_module doesn't. # (Note that --whole-archive is incompatible with the --start-group used in # normal linking.) # Other shared-object link notes: # - Set SONAME to the library filename so our binaries don't reference # the local, absolute paths used on the link command-line. quiet_cmd_solink = SOLINK($(TOOLSET)) $@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) """ LINK_COMMANDS_MAC = """\ quiet_cmd_alink = LIBTOOL-STATIC $@ cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) quiet_cmd_link = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) quiet_cmd_solink = SOLINK($(TOOLSET)) $@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) """ LINK_COMMANDS_ANDROID = """\ quiet_cmd_alink = AR($(TOOLSET)) $@ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) quiet_cmd_alink_thin = AR($(TOOLSET)) $@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) # Due to circular dependencies between libraries :(, we wrap the # special "figure out circular dependencies" flags around the entire # input list during linking. quiet_cmd_link = LINK($(TOOLSET)) $@ quiet_cmd_link_host = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) # Other shared-object link notes: # - Set SONAME to the library filename so our binaries don't reference # the local, absolute paths used on the link command-line. quiet_cmd_solink = SOLINK($(TOOLSET)) $@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) quiet_cmd_solink_module_host = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module_host = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) """ LINK_COMMANDS_AIX = """\ quiet_cmd_alink = AR($(TOOLSET)) $@ cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) quiet_cmd_alink_thin = AR($(TOOLSET)) $@ cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) quiet_cmd_link = LINK($(TOOLSET)) $@ cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) quiet_cmd_solink = SOLINK($(TOOLSET)) $@ cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) """ # Header of toplevel Makefile. # This should go into the build tree, but it's easier to keep it here for now. SHARED_HEADER = ("""\ # We borrow heavily from the kernel build setup, though we are simpler since # we don't have Kconfig tweaking settings on us. # The implicit make rules have it looking for RCS files, among other things. # We instead explicitly write all the rules we care about. # It's even quicker (saves ~200ms) to pass -r on the command line. MAKEFLAGS=-r # The source directory tree. srcdir := %(srcdir)s abs_srcdir := $(abspath $(srcdir)) # The name of the builddir. builddir_name ?= %(builddir)s # The V=1 flag on command line makes us verbosely print command lines. ifdef V quiet= else quiet=quiet_ endif # Specify BUILDTYPE=Release on the command line for a release build. BUILDTYPE ?= %(default_configuration)s # Directory all our build output goes into. # Note that this must be two directories beneath src/ for unit tests to pass, # as they reach into the src/ directory for data with relative paths. builddir ?= $(builddir_name)/$(BUILDTYPE) abs_builddir := $(abspath $(builddir)) depsdir := $(builddir)/.deps # Object output directory. obj := $(builddir)/obj abs_obj := $(abspath $(obj)) # We build up a list of every single one of the targets so we can slurp in the # generated dependency rule Makefiles in one pass. all_deps := %(make_global_settings)s CC.target ?= %(CC.target)s CFLAGS.target ?= $(CFLAGS) CXX.target ?= %(CXX.target)s CXXFLAGS.target ?= $(CXXFLAGS) LINK.target ?= %(LINK.target)s LDFLAGS.target ?= $(LDFLAGS) AR.target ?= $(AR) # C++ apps need to be linked with g++. # # Note: flock is used to seralize linking. Linking is a memory-intensive # process so running parallel links can often lead to thrashing. To disable # the serialization, override LINK via an envrionment variable as follows: # # export LINK=g++ # # This will allow make to invoke N linker processes as specified in -jN. LINK ?= %(flock)s $(builddir)/linker.lock $(CXX.target) # TODO(evan): move all cross-compilation logic to gyp-time so we don't need # to replicate this environment fallback in make as well. CC.host ?= %(CC.host)s CFLAGS.host ?= CXX.host ?= %(CXX.host)s CXXFLAGS.host ?= LINK.host ?= %(LINK.host)s LDFLAGS.host ?= AR.host ?= %(AR.host)s # Define a dir function that can handle spaces. # http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions # "leading spaces cannot appear in the text of the first argument as written. # These characters can be put into the argument value by variable substitution." empty := space := $(empty) $(empty) # http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces replace_spaces = $(subst $(space),""" + SPACE_REPLACEMENT + """,$1) unreplace_spaces = $(subst """ + SPACE_REPLACEMENT + """,$(space),$1) dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) # Flags to make gcc output dependency info. Note that you need to be # careful here to use the flags that ccache and distcc can understand. # We write to a dep file on the side first and then rename at the end # so we can't end up with a broken dep file. depfile = $(depsdir)/$(call replace_spaces,$@).d DEPFLAGS = -MMD -MF $(depfile).raw # We have to fixup the deps output in a few ways. # (1) the file output should mention the proper .o file. # ccache or distcc lose the path to the target, so we convert a rule of # the form: # foobar.o: DEP1 DEP2 # into # path/to/foobar.o: DEP1 DEP2 # (2) we want missing files not to cause us to fail to build. # We want to rewrite # foobar.o: DEP1 DEP2 \\ # DEP3 # to # DEP1: # DEP2: # DEP3: # so if the files are missing, they're just considered phony rules. # We have to do some pretty insane escaping to get those backslashes # and dollar signs past make, the shell, and sed at the same time. # Doesn't work with spaces, but that's fine: .d files have spaces in # their names replaced with other characters.""" r""" define fixup_dep # The depfile may not exist if the input file didn't have any #includes. touch $(depfile).raw # Fixup path as in (1). sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) # Add extra rules as in (2). # We remove slashes and replace spaces with new lines; # remove blank lines; # delete the first line and append a colon to the remaining lines. sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ grep -v '^$$' |\ sed -e 1d -e 's|$$|:|' \ >> $(depfile) rm $(depfile).raw endef """ """ # Command definitions: # - cmd_foo is the actual command to run; # - quiet_cmd_foo is the brief-output summary of the command. quiet_cmd_cc = CC($(TOOLSET)) $@ cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< quiet_cmd_cxx = CXX($(TOOLSET)) $@ cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< %(extra_commands)s quiet_cmd_touch = TOUCH $@ cmd_touch = touch $@ quiet_cmd_copy = COPY $@ # send stderr to /dev/null to ignore messages when linking directories. cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") %(link_commands)s """ r""" # Define an escape_quotes function to escape single quotes. # This allows us to handle quotes properly as long as we always use # use single quotes and escape_quotes. escape_quotes = $(subst ','\'',$(1)) # This comment is here just to include a ' to unconfuse syntax highlighting. # Define an escape_vars function to escape '$' variable syntax. # This allows us to read/write command lines with shell variables (e.g. # $LD_LIBRARY_PATH), without triggering make substitution. escape_vars = $(subst $$,$$$$,$(1)) # Helper that expands to a shell command to echo a string exactly as it is in # make. This uses printf instead of echo because printf's behaviour with respect # to escape sequences is more portable than echo's across different shells # (e.g., dash, bash). exact_echo = printf '%%s\n' '$(call escape_quotes,$(1))' """ """ # Helper to compare the command we're about to run against the command # we logged the last time we ran the command. Produces an empty # string (false) when the commands match. # Tricky point: Make has no string-equality test function. # The kernel uses the following, but it seems like it would have false # positives, where one string reordered its arguments. # arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \\ # $(filter-out $(cmd_$@), $(cmd_$(1)))) # We instead substitute each for the empty string into the other, and # say they're equal if both substitutions produce the empty string. # .d files contain """ + SPACE_REPLACEMENT + \ """ instead of spaces, take that into account. command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\\ $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) # Helper that is non-empty when a prerequisite changes. # Normally make does this implicitly, but we force rules to always run # so we can check their command lines. # $? -- new prerequisites # $| -- order-only dependencies prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) # Helper that executes all postbuilds until one fails. define do_postbuilds @E=0;\\ for p in $(POSTBUILDS); do\\ eval $$p;\\ E=$$?;\\ if [ $$E -ne 0 ]; then\\ break;\\ fi;\\ done;\\ if [ $$E -ne 0 ]; then\\ rm -rf "$@";\\ exit $$E;\\ fi endef # do_cmd: run a command via the above cmd_foo names, if necessary. # Should always run for a given target to handle command-line changes. # Second argument, if non-zero, makes it do asm/C/C++ dependency munging. # Third argument, if non-zero, makes it do POSTBUILDS processing. # Note: We intentionally do NOT call dirx for depfile, since it contains """ + \ SPACE_REPLACEMENT + """ for # spaces already and dirx strips the """ + SPACE_REPLACEMENT + \ """ characters. define do_cmd $(if $(or $(command_changed),$(prereq_changed)), @$(call exact_echo, $($(quiet)cmd_$(1))) @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" $(if $(findstring flock,$(word %(flock_index)d,$(cmd_$1))), @$(cmd_$(1)) @echo " $(quiet_cmd_$(1)): Finished", @$(cmd_$(1)) ) @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) @$(if $(2),$(fixup_dep)) $(if $(and $(3), $(POSTBUILDS)), $(call do_postbuilds) ) ) endef # Declare the "%(default_target)s" target first so it is the default, # even though we don't have the deps yet. .PHONY: %(default_target)s %(default_target)s: # make looks for ways to re-generate included makefiles, but in our case, we # don't have a direct way. Explicitly telling make that it has nothing to do # for them makes it go faster. %%.d: ; # Use FORCE_DO_CMD to force a target to run. Should be coupled with # do_cmd. .PHONY: FORCE_DO_CMD FORCE_DO_CMD: """) SHARED_HEADER_MAC_COMMANDS = """ quiet_cmd_objc = CXX($(TOOLSET)) $@ cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< quiet_cmd_objcxx = CXX($(TOOLSET)) $@ cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< # Commands for precompiled header files. quiet_cmd_pch_c = CXX($(TOOLSET)) $@ cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< quiet_cmd_pch_m = CXX($(TOOLSET)) $@ cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< # gyp-mac-tool is written next to the root Makefile by gyp. # Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd # already. quiet_cmd_mac_tool = MACTOOL $(4) $< cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) quiet_cmd_infoplist = INFOPLIST $@ cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" """ def WriteRootHeaderSuffixRules(writer): extensions = sorted(COMPILABLE_EXTENSIONS.keys(), key=str.lower) writer.write('# Suffix rules, putting all outputs into $(obj).\n') for ext in extensions: writer.write('$(obj).$(TOOLSET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD\n' % ext) writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) writer.write('\n# Try building from generated source, too.\n') for ext in extensions: writer.write( '$(obj).$(TOOLSET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD\n' % ext) writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) writer.write('\n') for ext in extensions: writer.write('$(obj).$(TOOLSET)/%%.o: $(obj)/%%%s FORCE_DO_CMD\n' % ext) writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) writer.write('\n') SHARED_HEADER_SUFFIX_RULES_COMMENT1 = ("""\ # Suffix rules, putting all outputs into $(obj). """) SHARED_HEADER_SUFFIX_RULES_COMMENT2 = ("""\ # Try building from generated source, too. """) SHARED_FOOTER = """\ # "all" is a concatenation of the "all" targets from all the included # sub-makefiles. This is just here to clarify. all: # Add in dependency-tracking rules. $(all_deps) is the list of every single # target in our tree. Only consider the ones with .d (dependency) info: d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) ifneq ($(d_files),) include $(d_files) endif """ header = """\ # This file is generated by gyp; do not edit. """ # Maps every compilable file extension to the do_cmd that compiles it. COMPILABLE_EXTENSIONS = { '.c': 'cc', '.cc': 'cxx', '.cpp': 'cxx', '.cxx': 'cxx', '.s': 'cc', '.S': 'cc', } def Compilable(filename): """Return true if the file is compilable (should be in OBJS).""" for res in (filename.endswith(e) for e in COMPILABLE_EXTENSIONS): if res: return True return False def Linkable(filename): """Return true if the file is linkable (should be on the link line).""" return filename.endswith('.o') def Target(filename): """Translate a compilable filename to its .o target.""" return os.path.splitext(filename)[0] + '.o' def EscapeShellArgument(s): """Quotes an argument so that it will be interpreted literally by a POSIX shell. Taken from http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python """ return "'" + s.replace("'", "'\\''") + "'" def EscapeMakeVariableExpansion(s): """Make has its own variable expansion syntax using $. We must escape it for string to be interpreted literally.""" return s.replace('$', '$$') def EscapeCppDefine(s): """Escapes a CPP define so that it will reach the compiler unaltered.""" s = EscapeShellArgument(s) s = EscapeMakeVariableExpansion(s) # '#' characters must be escaped even embedded in a string, else Make will # treat it as the start of a comment. return s.replace('#', r'\#') def QuoteIfNecessary(string): """TODO: Should this ideally be replaced with one or more of the above functions?""" if '"' in string: string = '"' + string.replace('"', '\\"') + '"' return string def StringToMakefileVariable(string): """Convert a string to a value that is acceptable as a make variable name.""" return re.sub('[^a-zA-Z0-9_]', '_', string) srcdir_prefix = '' def Sourceify(path): """Convert a path to its source directory form.""" if '$(' in path: return path if os.path.isabs(path): return path return srcdir_prefix + path def QuoteSpaces(s, quote=r'\ '): return s.replace(' ', quote) # TODO: Avoid code duplication with _ValidateSourcesForMSVSProject in msvs.py. def _ValidateSourcesForOSX(spec, all_sources): """Makes sure if duplicate basenames are not specified in the source list. Arguments: spec: The target dictionary containing the properties of the target. """ if spec.get('type', None) != 'static_library': return basenames = {} for source in all_sources: name, ext = os.path.splitext(source) is_compiled_file = ext in [ '.c', '.cc', '.cpp', '.cxx', '.m', '.mm', '.s', '.S'] if not is_compiled_file: continue basename = os.path.basename(name) # Don't include extension. basenames.setdefault(basename, []).append(source) error = '' for basename, files in basenames.iteritems(): if len(files) > 1: error += ' %s: %s\n' % (basename, ' '.join(files)) if error: print('static library %s has several files with the same basename:\n' % spec['target_name'] + error + 'libtool on OS X will generate' + ' warnings for them.') raise GypError('Duplicate basenames in sources section, see list above') # Map from qualified target to path to output. target_outputs = {} # Map from qualified target to any linkable output. A subset # of target_outputs. E.g. when mybinary depends on liba, we want to # include liba in the linker line; when otherbinary depends on # mybinary, we just want to build mybinary first. target_link_deps = {} class MakefileWriter: """MakefileWriter packages up the writing of one target-specific foobar.mk. Its only real entry point is Write(), and is mostly used for namespacing. """ def __init__(self, generator_flags, flavor): self.generator_flags = generator_flags self.flavor = flavor self.suffix_rules_srcdir = {} self.suffix_rules_objdir1 = {} self.suffix_rules_objdir2 = {} # Generate suffix rules for all compilable extensions. for ext in COMPILABLE_EXTENSIONS.keys(): # Suffix rules for source folder. self.suffix_rules_srcdir.update({ext: ("""\ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD @$(call do_cmd,%s,1) """ % (ext, COMPILABLE_EXTENSIONS[ext]))}) # Suffix rules for generated source files. self.suffix_rules_objdir1.update({ext: ("""\ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD @$(call do_cmd,%s,1) """ % (ext, COMPILABLE_EXTENSIONS[ext]))}) self.suffix_rules_objdir2.update({ext: ("""\ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD @$(call do_cmd,%s,1) """ % (ext, COMPILABLE_EXTENSIONS[ext]))}) def Write(self, qualified_target, base_path, output_filename, spec, configs, part_of_all): """The main entry point: writes a .mk file for a single target. Arguments: qualified_target: target we're generating base_path: path relative to source root we're building in, used to resolve target-relative paths output_filename: output .mk file name to write spec, configs: gyp info part_of_all: flag indicating this target is part of 'all' """ gyp.common.EnsureDirExists(output_filename) self.fp = open(output_filename, 'w') self.fp.write(header) self.qualified_target = qualified_target self.path = base_path self.target = spec['target_name'] self.type = spec['type'] self.toolset = spec['toolset'] self.is_mac_bundle = gyp.xcode_emulation.IsMacBundle(self.flavor, spec) if self.flavor == 'mac': self.xcode_settings = gyp.xcode_emulation.XcodeSettings(spec) else: self.xcode_settings = None deps, link_deps = self.ComputeDeps(spec) # Some of the generation below can add extra output, sources, or # link dependencies. All of the out params of the functions that # follow use names like extra_foo. extra_outputs = [] extra_sources = [] extra_link_deps = [] extra_mac_bundle_resources = [] mac_bundle_deps = [] if self.is_mac_bundle: self.output = self.ComputeMacBundleOutput(spec) self.output_binary = self.ComputeMacBundleBinaryOutput(spec) else: self.output = self.output_binary = self.ComputeOutput(spec) self.is_standalone_static_library = bool( spec.get('standalone_static_library', 0)) self._INSTALLABLE_TARGETS = ('executable', 'loadable_module', 'shared_library') if (self.is_standalone_static_library or self.type in self._INSTALLABLE_TARGETS): self.alias = os.path.basename(self.output) install_path = self._InstallableTargetInstallPath() else: self.alias = self.output install_path = self.output self.WriteLn("TOOLSET := " + self.toolset) self.WriteLn("TARGET := " + self.target) # Actions must come first, since they can generate more OBJs for use below. if 'actions' in spec: self.WriteActions(spec['actions'], extra_sources, extra_outputs, extra_mac_bundle_resources, part_of_all) # Rules must be early like actions. if 'rules' in spec: self.WriteRules(spec['rules'], extra_sources, extra_outputs, extra_mac_bundle_resources, part_of_all) if 'copies' in spec: self.WriteCopies(spec['copies'], extra_outputs, part_of_all) # Bundle resources. if self.is_mac_bundle: all_mac_bundle_resources = ( spec.get('mac_bundle_resources', []) + extra_mac_bundle_resources) self.WriteMacBundleResources(all_mac_bundle_resources, mac_bundle_deps) self.WriteMacInfoPlist(mac_bundle_deps) # Sources. all_sources = spec.get('sources', []) + extra_sources if all_sources: if self.flavor == 'mac': # libtool on OS X generates warnings for duplicate basenames in the same # target. _ValidateSourcesForOSX(spec, all_sources) self.WriteSources( configs, deps, all_sources, extra_outputs, extra_link_deps, part_of_all, gyp.xcode_emulation.MacPrefixHeader( self.xcode_settings, lambda p: Sourceify(self.Absolutify(p)), self.Pchify)) sources = filter(Compilable, all_sources) if sources: self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT1) extensions = set([os.path.splitext(s)[1] for s in sources]) for ext in extensions: if ext in self.suffix_rules_srcdir: self.WriteLn(self.suffix_rules_srcdir[ext]) self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT2) for ext in extensions: if ext in self.suffix_rules_objdir1: self.WriteLn(self.suffix_rules_objdir1[ext]) for ext in extensions: if ext in self.suffix_rules_objdir2: self.WriteLn(self.suffix_rules_objdir2[ext]) self.WriteLn('# End of this set of suffix rules') # Add dependency from bundle to bundle binary. if self.is_mac_bundle: mac_bundle_deps.append(self.output_binary) self.WriteTarget(spec, configs, deps, extra_link_deps + link_deps, mac_bundle_deps, extra_outputs, part_of_all) # Update global list of target outputs, used in dependency tracking. target_outputs[qualified_target] = install_path # Update global list of link dependencies. if self.type in ('static_library', 'shared_library'): target_link_deps[qualified_target] = self.output_binary # Currently any versions have the same effect, but in future the behavior # could be different. if self.generator_flags.get('android_ndk_version', None): self.WriteAndroidNdkModuleRule(self.target, all_sources, link_deps) self.fp.close() def WriteSubMake(self, output_filename, makefile_path, targets, build_dir): """Write a "sub-project" Makefile. This is a small, wrapper Makefile that calls the top-level Makefile to build the targets from a single gyp file (i.e. a sub-project). Arguments: output_filename: sub-project Makefile name to write makefile_path: path to the top-level Makefile targets: list of "all" targets for this sub-project build_dir: build output directory, relative to the sub-project """ gyp.common.EnsureDirExists(output_filename) self.fp = open(output_filename, 'w') self.fp.write(header) # For consistency with other builders, put sub-project build output in the # sub-project dir (see test/subdirectory/gyptest-subdir-all.py). self.WriteLn('export builddir_name ?= %s' % os.path.join(os.path.dirname(output_filename), build_dir)) self.WriteLn('.PHONY: all') self.WriteLn('all:') if makefile_path: makefile_path = ' -C ' + makefile_path self.WriteLn('\t$(MAKE)%s %s' % (makefile_path, ' '.join(targets))) self.fp.close() def WriteActions(self, actions, extra_sources, extra_outputs, extra_mac_bundle_resources, part_of_all): """Write Makefile code for any 'actions' from the gyp input. extra_sources: a list that will be filled in with newly generated source files, if any extra_outputs: a list that will be filled in with any outputs of these actions (used to make other pieces dependent on these actions) part_of_all: flag indicating this target is part of 'all' """ env = self.GetSortedXcodeEnv() for action in actions: name = StringToMakefileVariable('%s_%s' % (self.qualified_target, action['action_name'])) self.WriteLn('### Rules for action "%s":' % action['action_name']) inputs = action['inputs'] outputs = action['outputs'] # Build up a list of outputs. # Collect the output dirs we'll need. dirs = set() for out in outputs: dir = os.path.split(out)[0] if dir: dirs.add(dir) if int(action.get('process_outputs_as_sources', False)): extra_sources += outputs if int(action.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += outputs # Write the actual command. action_commands = action['action'] if self.flavor == 'mac': action_commands = [gyp.xcode_emulation.ExpandEnvVars(command, env) for command in action_commands] command = gyp.common.EncodePOSIXShellList(action_commands) if 'message' in action: self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, action['message'])) else: self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, name)) if len(dirs) > 0: command = 'mkdir -p %s' % ' '.join(dirs) + '; ' + command cd_action = 'cd %s; ' % Sourceify(self.path or '.') # command and cd_action get written to a toplevel variable called # cmd_foo. Toplevel variables can't handle things that change per # makefile like $(TARGET), so hardcode the target. command = command.replace('$(TARGET)', self.target) cd_action = cd_action.replace('$(TARGET)', self.target) # Set LD_LIBRARY_PATH in case the action runs an executable from this # build which links to shared libs from this build. # actions run on the host, so they should in theory only use host # libraries, but until everything is made cross-compile safe, also use # target libraries. # TODO(piman): when everything is cross-compile safe, remove lib.target self.WriteLn('cmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:' '$(builddir)/lib.target:$$LD_LIBRARY_PATH; ' 'export LD_LIBRARY_PATH; ' '%s%s' % (name, cd_action, command)) self.WriteLn() outputs = map(self.Absolutify, outputs) # The makefile rules are all relative to the top dir, but the gyp actions # are defined relative to their containing dir. This replaces the obj # variable for the action rule with an absolute version so that the output # goes in the right place. # Only write the 'obj' and 'builddir' rules for the "primary" output (:1); # it's superfluous for the "extra outputs", and this avoids accidentally # writing duplicate dummy rules for those outputs. # Same for environment. self.WriteLn("%s: obj := $(abs_obj)" % QuoteSpaces(outputs[0])) self.WriteLn("%s: builddir := $(abs_builddir)" % QuoteSpaces(outputs[0])) self.WriteSortedXcodeEnv(outputs[0], self.GetSortedXcodeEnv()) for input in inputs: assert ' ' not in input, ( "Spaces in action input filenames not supported (%s)" % input) for output in outputs: assert ' ' not in output, ( "Spaces in action output filenames not supported (%s)" % output) # See the comment in WriteCopies about expanding env vars. outputs = [gyp.xcode_emulation.ExpandEnvVars(o, env) for o in outputs] inputs = [gyp.xcode_emulation.ExpandEnvVars(i, env) for i in inputs] self.WriteDoCmd(outputs, map(Sourceify, map(self.Absolutify, inputs)), part_of_all=part_of_all, command=name) # Stuff the outputs in a variable so we can refer to them later. outputs_variable = 'action_%s_outputs' % name self.WriteLn('%s := %s' % (outputs_variable, ' '.join(outputs))) extra_outputs.append('$(%s)' % outputs_variable) self.WriteLn() self.WriteLn() def WriteRules(self, rules, extra_sources, extra_outputs, extra_mac_bundle_resources, part_of_all): """Write Makefile code for any 'rules' from the gyp input. extra_sources: a list that will be filled in with newly generated source files, if any extra_outputs: a list that will be filled in with any outputs of these rules (used to make other pieces dependent on these rules) part_of_all: flag indicating this target is part of 'all' """ env = self.GetSortedXcodeEnv() for rule in rules: name = StringToMakefileVariable('%s_%s' % (self.qualified_target, rule['rule_name'])) count = 0 self.WriteLn('### Generated for rule %s:' % name) all_outputs = [] for rule_source in rule.get('rule_sources', []): dirs = set() (rule_source_dirname, rule_source_basename) = os.path.split(rule_source) (rule_source_root, rule_source_ext) = \ os.path.splitext(rule_source_basename) outputs = [self.ExpandInputRoot(out, rule_source_root, rule_source_dirname) for out in rule['outputs']] for out in outputs: dir = os.path.dirname(out) if dir: dirs.add(dir) if int(rule.get('process_outputs_as_sources', False)): extra_sources += outputs if int(rule.get('process_outputs_as_mac_bundle_resources', False)): extra_mac_bundle_resources += outputs inputs = map(Sourceify, map(self.Absolutify, [rule_source] + rule.get('inputs', []))) actions = ['$(call do_cmd,%s_%d)' % (name, count)] if name == 'resources_grit': # HACK: This is ugly. Grit intentionally doesn't touch the # timestamp of its output file when the file doesn't change, # which is fine in hash-based dependency systems like scons # and forge, but not kosher in the make world. After some # discussion, hacking around it here seems like the least # amount of pain. actions += ['@touch --no-create $@'] # See the comment in WriteCopies about expanding env vars. outputs = [gyp.xcode_emulation.ExpandEnvVars(o, env) for o in outputs] inputs = [gyp.xcode_emulation.ExpandEnvVars(i, env) for i in inputs] outputs = map(self.Absolutify, outputs) all_outputs += outputs # Only write the 'obj' and 'builddir' rules for the "primary" output # (:1); it's superfluous for the "extra outputs", and this avoids # accidentally writing duplicate dummy rules for those outputs. self.WriteLn('%s: obj := $(abs_obj)' % outputs[0]) self.WriteLn('%s: builddir := $(abs_builddir)' % outputs[0]) self.WriteMakeRule(outputs, inputs + ['FORCE_DO_CMD'], actions) # Spaces in rule filenames are not supported, but rule variables have # spaces in them (e.g. RULE_INPUT_PATH expands to '$(abspath $<)'). # The spaces within the variables are valid, so remove the variables # before checking. variables_with_spaces = re.compile(r'\$\([^ ]* \$<\)') for output in outputs: output = re.sub(variables_with_spaces, '', output) assert ' ' not in output, ( "Spaces in rule filenames not yet supported (%s)" % output) self.WriteLn('all_deps += %s' % ' '.join(outputs)) action = [self.ExpandInputRoot(ac, rule_source_root, rule_source_dirname) for ac in rule['action']] mkdirs = '' if len(dirs) > 0: mkdirs = 'mkdir -p %s; ' % ' '.join(dirs) cd_action = 'cd %s; ' % Sourceify(self.path or '.') # action, cd_action, and mkdirs get written to a toplevel variable # called cmd_foo. Toplevel variables can't handle things that change # per makefile like $(TARGET), so hardcode the target. if self.flavor == 'mac': action = [gyp.xcode_emulation.ExpandEnvVars(command, env) for command in action] action = gyp.common.EncodePOSIXShellList(action) action = action.replace('$(TARGET)', self.target) cd_action = cd_action.replace('$(TARGET)', self.target) mkdirs = mkdirs.replace('$(TARGET)', self.target) # Set LD_LIBRARY_PATH in case the rule runs an executable from this # build which links to shared libs from this build. # rules run on the host, so they should in theory only use host # libraries, but until everything is made cross-compile safe, also use # target libraries. # TODO(piman): when everything is cross-compile safe, remove lib.target self.WriteLn( "cmd_%(name)s_%(count)d = LD_LIBRARY_PATH=" "$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; " "export LD_LIBRARY_PATH; " "%(cd_action)s%(mkdirs)s%(action)s" % { 'action': action, 'cd_action': cd_action, 'count': count, 'mkdirs': mkdirs, 'name': name, }) self.WriteLn( 'quiet_cmd_%(name)s_%(count)d = RULE %(name)s_%(count)d $@' % { 'count': count, 'name': name, }) self.WriteLn() count += 1 outputs_variable = 'rule_%s_outputs' % name self.WriteList(all_outputs, outputs_variable) extra_outputs.append('$(%s)' % outputs_variable) self.WriteLn('### Finished generating for rule: %s' % name) self.WriteLn() self.WriteLn('### Finished generating for all rules') self.WriteLn('') def WriteCopies(self, copies, extra_outputs, part_of_all): """Write Makefile code for any 'copies' from the gyp input. extra_outputs: a list that will be filled in with any outputs of this action (used to make other pieces dependent on this action) part_of_all: flag indicating this target is part of 'all' """ self.WriteLn('### Generated for copy rule.') variable = StringToMakefileVariable(self.qualified_target + '_copies') outputs = [] for copy in copies: for path in copy['files']: # Absolutify() may call normpath, and will strip trailing slashes. path = Sourceify(self.Absolutify(path)) filename = os.path.split(path)[1] output = Sourceify(self.Absolutify(os.path.join(copy['destination'], filename))) # If the output path has variables in it, which happens in practice for # 'copies', writing the environment as target-local doesn't work, # because the variables are already needed for the target name. # Copying the environment variables into global make variables doesn't # work either, because then the .d files will potentially contain spaces # after variable expansion, and .d file handling cannot handle spaces. # As a workaround, manually expand variables at gyp time. Since 'copies' # can't run scripts, there's no need to write the env then. # WriteDoCmd() will escape spaces for .d files. env = self.GetSortedXcodeEnv() output = gyp.xcode_emulation.ExpandEnvVars(output, env) path = gyp.xcode_emulation.ExpandEnvVars(path, env) self.WriteDoCmd([output], [path], 'copy', part_of_all) outputs.append(output) self.WriteLn('%s = %s' % (variable, ' '.join(map(QuoteSpaces, outputs)))) extra_outputs.append('$(%s)' % variable) self.WriteLn() def WriteMacBundleResources(self, resources, bundle_deps): """Writes Makefile code for 'mac_bundle_resources'.""" self.WriteLn('### Generated for mac_bundle_resources') for output, res in gyp.xcode_emulation.GetMacBundleResources( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, map(Sourceify, map(self.Absolutify, resources))): self.WriteDoCmd([output], [res], 'mac_tool,,,copy-bundle-resource', part_of_all=True) bundle_deps.append(output) def WriteMacInfoPlist(self, bundle_deps): """Write Makefile code for bundle Info.plist files.""" info_plist, out, defines, extra_env = gyp.xcode_emulation.GetMacInfoPlist( generator_default_variables['PRODUCT_DIR'], self.xcode_settings, lambda p: Sourceify(self.Absolutify(p))) if not info_plist: return if defines: # Create an intermediate file to store preprocessed results. intermediate_plist = ('$(obj).$(TOOLSET)/$(TARGET)/' + os.path.basename(info_plist)) self.WriteList(defines, intermediate_plist + ': INFOPLIST_DEFINES', '-D', quoter=EscapeCppDefine) self.WriteMakeRule([intermediate_plist], [info_plist], ['$(call do_cmd,infoplist)', # "Convert" the plist so that any weird whitespace changes from the # preprocessor do not affect the XML parser in mac_tool. '@plutil -convert xml1 $@ $@']) info_plist = intermediate_plist # plists can contain envvars and substitute them into the file. self.WriteSortedXcodeEnv( out, self.GetSortedXcodeEnv(additional_settings=extra_env)) self.WriteDoCmd([out], [info_plist], 'mac_tool,,,copy-info-plist', part_of_all=True) bundle_deps.append(out) def WriteSources(self, configs, deps, sources, extra_outputs, extra_link_deps, part_of_all, precompiled_header): """Write Makefile code for any 'sources' from the gyp input. These are source files necessary to build the current target. configs, deps, sources: input from gyp. extra_outputs: a list of extra outputs this action should be dependent on; used to serialize action/rules before compilation extra_link_deps: a list that will be filled in with any outputs of compilation (to be used in link lines) part_of_all: flag indicating this target is part of 'all' """ # Write configuration-specific variables for CFLAGS, etc. for configname in sorted(configs.keys()): config = configs[configname] self.WriteList(config.get('defines'), 'DEFS_%s' % configname, prefix='-D', quoter=EscapeCppDefine) if self.flavor == 'mac': cflags = self.xcode_settings.GetCflags(configname) cflags_c = self.xcode_settings.GetCflagsC(configname) cflags_cc = self.xcode_settings.GetCflagsCC(configname) cflags_objc = self.xcode_settings.GetCflagsObjC(configname) cflags_objcc = self.xcode_settings.GetCflagsObjCC(configname) else: cflags = config.get('cflags') cflags_c = config.get('cflags_c') cflags_cc = config.get('cflags_cc') self.WriteLn("# Flags passed to all source files."); self.WriteList(cflags, 'CFLAGS_%s' % configname) self.WriteLn("# Flags passed to only C files."); self.WriteList(cflags_c, 'CFLAGS_C_%s' % configname) self.WriteLn("# Flags passed to only C++ files."); self.WriteList(cflags_cc, 'CFLAGS_CC_%s' % configname) if self.flavor == 'mac': self.WriteLn("# Flags passed to only ObjC files."); self.WriteList(cflags_objc, 'CFLAGS_OBJC_%s' % configname) self.WriteLn("# Flags passed to only ObjC++ files."); self.WriteList(cflags_objcc, 'CFLAGS_OBJCC_%s' % configname) includes = config.get('include_dirs') if includes: includes = map(Sourceify, map(self.Absolutify, includes)) self.WriteList(includes, 'INCS_%s' % configname, prefix='-I') compilable = filter(Compilable, sources) objs = map(self.Objectify, map(self.Absolutify, map(Target, compilable))) self.WriteList(objs, 'OBJS') for obj in objs: assert ' ' not in obj, ( "Spaces in object filenames not supported (%s)" % obj) self.WriteLn('# Add to the list of files we specially track ' 'dependencies for.') self.WriteLn('all_deps += $(OBJS)') self.WriteLn() # Make sure our dependencies are built first. if deps: self.WriteMakeRule(['$(OBJS)'], deps, comment = 'Make sure our dependencies are built ' 'before any of us.', order_only = True) # Make sure the actions and rules run first. # If they generate any extra headers etc., the per-.o file dep tracking # will catch the proper rebuilds, so order only is still ok here. if extra_outputs: self.WriteMakeRule(['$(OBJS)'], extra_outputs, comment = 'Make sure our actions/rules run ' 'before any of us.', order_only = True) pchdeps = precompiled_header.GetObjDependencies(compilable, objs ) if pchdeps: self.WriteLn('# Dependencies from obj files to their precompiled headers') for source, obj, gch in pchdeps: self.WriteLn('%s: %s' % (obj, gch)) self.WriteLn('# End precompiled header dependencies') if objs: extra_link_deps.append('$(OBJS)') self.WriteLn("""\ # CFLAGS et al overrides must be target-local. # See "Target-specific Variable Values" in the GNU Make manual.""") self.WriteLn("$(OBJS): TOOLSET := $(TOOLSET)") self.WriteLn("$(OBJS): GYP_CFLAGS := " "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "%s " % precompiled_header.GetInclude('c') + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_C_$(BUILDTYPE))") self.WriteLn("$(OBJS): GYP_CXXFLAGS := " "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "%s " % precompiled_header.GetInclude('cc') + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_CC_$(BUILDTYPE))") if self.flavor == 'mac': self.WriteLn("$(OBJS): GYP_OBJCFLAGS := " "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "%s " % precompiled_header.GetInclude('m') + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_C_$(BUILDTYPE)) " "$(CFLAGS_OBJC_$(BUILDTYPE))") self.WriteLn("$(OBJS): GYP_OBJCXXFLAGS := " "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "%s " % precompiled_header.GetInclude('mm') + "$(CFLAGS_$(BUILDTYPE)) " "$(CFLAGS_CC_$(BUILDTYPE)) " "$(CFLAGS_OBJCC_$(BUILDTYPE))") self.WritePchTargets(precompiled_header.GetPchBuildCommands()) # If there are any object files in our input file list, link them into our # output. extra_link_deps += filter(Linkable, sources) self.WriteLn() def WritePchTargets(self, pch_commands): """Writes make rules to compile prefix headers.""" if not pch_commands: return for gch, lang_flag, lang, input in pch_commands: extra_flags = { 'c': '$(CFLAGS_C_$(BUILDTYPE))', 'cc': '$(CFLAGS_CC_$(BUILDTYPE))', 'm': '$(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))', 'mm': '$(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))', }[lang] var_name = { 'c': 'GYP_PCH_CFLAGS', 'cc': 'GYP_PCH_CXXFLAGS', 'm': 'GYP_PCH_OBJCFLAGS', 'mm': 'GYP_PCH_OBJCXXFLAGS', }[lang] self.WriteLn("%s: %s := %s " % (gch, var_name, lang_flag) + "$(DEFS_$(BUILDTYPE)) " "$(INCS_$(BUILDTYPE)) " "$(CFLAGS_$(BUILDTYPE)) " + extra_flags) self.WriteLn('%s: %s FORCE_DO_CMD' % (gch, input)) self.WriteLn('\t@$(call do_cmd,pch_%s,1)' % lang) self.WriteLn('') assert ' ' not in gch, ( "Spaces in gch filenames not supported (%s)" % gch) self.WriteLn('all_deps += %s' % gch) self.WriteLn('') def ComputeOutputBasename(self, spec): """Return the 'output basename' of a gyp spec. E.g., the loadable module 'foobar' in directory 'baz' will produce 'libfoobar.so' """ assert not self.is_mac_bundle if self.flavor == 'mac' and self.type in ( 'static_library', 'executable', 'shared_library', 'loadable_module'): return self.xcode_settings.GetExecutablePath() target = spec['target_name'] target_prefix = '' target_ext = '' if self.type == 'static_library': if target[:3] == 'lib': target = target[3:] target_prefix = 'lib' target_ext = '.a' elif self.type in ('loadable_module', 'shared_library'): if target[:3] == 'lib': target = target[3:] target_prefix = 'lib' target_ext = '.so' elif self.type == 'none': target = '%s.stamp' % target elif self.type != 'executable': print ("ERROR: What output file should be generated?", "type", self.type, "target", target) target_prefix = spec.get('product_prefix', target_prefix) target = spec.get('product_name', target) product_ext = spec.get('product_extension') if product_ext: target_ext = '.' + product_ext return target_prefix + target + target_ext def _InstallImmediately(self): return self.toolset == 'target' and self.flavor == 'mac' and self.type in ( 'static_library', 'executable', 'shared_library', 'loadable_module') def ComputeOutput(self, spec): """Return the 'output' (full output path) of a gyp spec. E.g., the loadable module 'foobar' in directory 'baz' will produce '$(obj)/baz/libfoobar.so' """ assert not self.is_mac_bundle path = os.path.join('$(obj).' + self.toolset, self.path) if self.type == 'executable' or self._InstallImmediately(): path = '$(builddir)' path = spec.get('product_dir', path) return os.path.join(path, self.ComputeOutputBasename(spec)) def ComputeMacBundleOutput(self, spec): """Return the 'output' (full output path) to a bundle output directory.""" assert self.is_mac_bundle path = generator_default_variables['PRODUCT_DIR'] return os.path.join(path, self.xcode_settings.GetWrapperName()) def ComputeMacBundleBinaryOutput(self, spec): """Return the 'output' (full output path) to the binary in a bundle.""" path = generator_default_variables['PRODUCT_DIR'] return os.path.join(path, self.xcode_settings.GetExecutablePath()) def ComputeDeps(self, spec): """Compute the dependencies of a gyp spec. Returns a tuple (deps, link_deps), where each is a list of filenames that will need to be put in front of make for either building (deps) or linking (link_deps). """ deps = [] link_deps = [] if 'dependencies' in spec: deps.extend([target_outputs[dep] for dep in spec['dependencies'] if target_outputs[dep]]) for dep in spec['dependencies']: if dep in target_link_deps: link_deps.append(target_link_deps[dep]) deps.extend(link_deps) # TODO: It seems we need to transitively link in libraries (e.g. -lfoo)? # This hack makes it work: # link_deps.extend(spec.get('libraries', [])) return (gyp.common.uniquer(deps), gyp.common.uniquer(link_deps)) def WriteDependencyOnExtraOutputs(self, target, extra_outputs): self.WriteMakeRule([self.output_binary], extra_outputs, comment = 'Build our special outputs first.', order_only = True) def WriteTarget(self, spec, configs, deps, link_deps, bundle_deps, extra_outputs, part_of_all): """Write Makefile code to produce the final target of the gyp spec. spec, configs: input from gyp. deps, link_deps: dependency lists; see ComputeDeps() extra_outputs: any extra outputs that our target should depend on part_of_all: flag indicating this target is part of 'all' """ self.WriteLn('### Rules for final target.') if extra_outputs: self.WriteDependencyOnExtraOutputs(self.output_binary, extra_outputs) self.WriteMakeRule(extra_outputs, deps, comment=('Preserve order dependency of ' 'special output on deps.'), order_only = True) target_postbuilds = {} if self.type != 'none': for configname in sorted(configs.keys()): config = configs[configname] if self.flavor == 'mac': ldflags = self.xcode_settings.GetLdflags(configname, generator_default_variables['PRODUCT_DIR'], lambda p: Sourceify(self.Absolutify(p))) # TARGET_POSTBUILDS_$(BUILDTYPE) is added to postbuilds later on. gyp_to_build = gyp.common.InvertRelativePath(self.path) target_postbuild = self.xcode_settings.AddImplicitPostbuilds( configname, QuoteSpaces(os.path.normpath(os.path.join(gyp_to_build, self.output))), QuoteSpaces(os.path.normpath(os.path.join(gyp_to_build, self.output_binary)))) if target_postbuild: target_postbuilds[configname] = target_postbuild else: ldflags = config.get('ldflags', []) # Compute an rpath for this output if needed. if any(dep.endswith('.so') or '.so.' in dep for dep in deps): # We want to get the literal string "$ORIGIN" into the link command, # so we need lots of escaping. ldflags.append(r'-Wl,-rpath=\$$ORIGIN/lib.%s/' % self.toolset) ldflags.append(r'-Wl,-rpath-link=\$(builddir)/lib.%s/' % self.toolset) library_dirs = config.get('library_dirs', []) ldflags += [('-L%s' % library_dir) for library_dir in library_dirs] self.WriteList(ldflags, 'LDFLAGS_%s' % configname) if self.flavor == 'mac': self.WriteList(self.xcode_settings.GetLibtoolflags(configname), 'LIBTOOLFLAGS_%s' % configname) libraries = spec.get('libraries') if libraries: # Remove duplicate entries libraries = gyp.common.uniquer(libraries) if self.flavor == 'mac': libraries = self.xcode_settings.AdjustLibraries(libraries) self.WriteList(libraries, 'LIBS') self.WriteLn('%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))' % QuoteSpaces(self.output_binary)) self.WriteLn('%s: LIBS := $(LIBS)' % QuoteSpaces(self.output_binary)) if self.flavor == 'mac': self.WriteLn('%s: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))' % QuoteSpaces(self.output_binary)) # Postbuild actions. Like actions, but implicitly depend on the target's # output. postbuilds = [] if self.flavor == 'mac': if target_postbuilds: postbuilds.append('$(TARGET_POSTBUILDS_$(BUILDTYPE))') postbuilds.extend( gyp.xcode_emulation.GetSpecPostbuildCommands(spec)) if postbuilds: # Envvars may be referenced by TARGET_POSTBUILDS_$(BUILDTYPE), # so we must output its definition first, since we declare variables # using ":=". self.WriteSortedXcodeEnv(self.output, self.GetSortedXcodePostbuildEnv()) for configname in target_postbuilds: self.WriteLn('%s: TARGET_POSTBUILDS_%s := %s' % (QuoteSpaces(self.output), configname, gyp.common.EncodePOSIXShellList(target_postbuilds[configname]))) # Postbuilds expect to be run in the gyp file's directory, so insert an # implicit postbuild to cd to there. postbuilds.insert(0, gyp.common.EncodePOSIXShellList(['cd', self.path])) for i in xrange(len(postbuilds)): if not postbuilds[i].startswith('$'): postbuilds[i] = EscapeShellArgument(postbuilds[i]) self.WriteLn('%s: builddir := $(abs_builddir)' % QuoteSpaces(self.output)) self.WriteLn('%s: POSTBUILDS := %s' % ( QuoteSpaces(self.output), ' '.join(postbuilds))) # A bundle directory depends on its dependencies such as bundle resources # and bundle binary. When all dependencies have been built, the bundle # needs to be packaged. if self.is_mac_bundle: # If the framework doesn't contain a binary, then nothing depends # on the actions -- make the framework depend on them directly too. self.WriteDependencyOnExtraOutputs(self.output, extra_outputs) # Bundle dependencies. Note that the code below adds actions to this # target, so if you move these two lines, move the lines below as well. self.WriteList(map(QuoteSpaces, bundle_deps), 'BUNDLE_DEPS') self.WriteLn('%s: $(BUNDLE_DEPS)' % QuoteSpaces(self.output)) # After the framework is built, package it. Needs to happen before # postbuilds, since postbuilds depend on this. if self.type in ('shared_library', 'loadable_module'): self.WriteLn('\t@$(call do_cmd,mac_package_framework,,,%s)' % self.xcode_settings.GetFrameworkVersion()) # Bundle postbuilds can depend on the whole bundle, so run them after # the bundle is packaged, not already after the bundle binary is done. if postbuilds: self.WriteLn('\t@$(call do_postbuilds)') postbuilds = [] # Don't write postbuilds for target's output. # Needed by test/mac/gyptest-rebuild.py. self.WriteLn('\t@true # No-op, used by tests') # Since this target depends on binary and resources which are in # nested subfolders, the framework directory will be older than # its dependencies usually. To prevent this rule from executing # on every build (expensive, especially with postbuilds), expliclity # update the time on the framework directory. self.WriteLn('\t@touch -c %s' % QuoteSpaces(self.output)) if postbuilds: assert not self.is_mac_bundle, ('Postbuilds for bundles should be done ' 'on the bundle, not the binary (target \'%s\')' % self.target) assert 'product_dir' not in spec, ('Postbuilds do not work with ' 'custom product_dir') if self.type == 'executable': self.WriteLn('%s: LD_INPUTS := %s' % ( QuoteSpaces(self.output_binary), ' '.join(map(QuoteSpaces, link_deps)))) if self.toolset == 'host' and self.flavor == 'android': self.WriteDoCmd([self.output_binary], link_deps, 'link_host', part_of_all, postbuilds=postbuilds) else: self.WriteDoCmd([self.output_binary], link_deps, 'link', part_of_all, postbuilds=postbuilds) elif self.type == 'static_library': for link_dep in link_deps: assert ' ' not in link_dep, ( "Spaces in alink input filenames not supported (%s)" % link_dep) if (self.flavor not in ('mac', 'openbsd', 'win') and not self.is_standalone_static_library): self.WriteDoCmd([self.output_binary], link_deps, 'alink_thin', part_of_all, postbuilds=postbuilds) else: self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all, postbuilds=postbuilds) elif self.type == 'shared_library': self.WriteLn('%s: LD_INPUTS := %s' % ( QuoteSpaces(self.output_binary), ' '.join(map(QuoteSpaces, link_deps)))) self.WriteDoCmd([self.output_binary], link_deps, 'solink', part_of_all, postbuilds=postbuilds) elif self.type == 'loadable_module': for link_dep in link_deps: assert ' ' not in link_dep, ( "Spaces in module input filenames not supported (%s)" % link_dep) if self.toolset == 'host' and self.flavor == 'android': self.WriteDoCmd([self.output_binary], link_deps, 'solink_module_host', part_of_all, postbuilds=postbuilds) else: self.WriteDoCmd( [self.output_binary], link_deps, 'solink_module', part_of_all, postbuilds=postbuilds) elif self.type == 'none': # Write a stamp line. self.WriteDoCmd([self.output_binary], deps, 'touch', part_of_all, postbuilds=postbuilds) else: print "WARNING: no output for", self.type, target # Add an alias for each target (if there are any outputs). # Installable target aliases are created below. if ((self.output and self.output != self.target) and (self.type not in self._INSTALLABLE_TARGETS)): self.WriteMakeRule([self.target], [self.output], comment='Add target alias', phony = True) if part_of_all: self.WriteMakeRule(['all'], [self.target], comment = 'Add target alias to "all" target.', phony = True) # Add special-case rules for our installable targets. # 1) They need to install to the build dir or "product" dir. # 2) They get shortcuts for building (e.g. "make chrome"). # 3) They are part of "make all". if (self.type in self._INSTALLABLE_TARGETS or self.is_standalone_static_library): if self.type == 'shared_library': file_desc = 'shared library' elif self.type == 'static_library': file_desc = 'static library' else: file_desc = 'executable' install_path = self._InstallableTargetInstallPath() installable_deps = [self.output] if (self.flavor == 'mac' and not 'product_dir' in spec and self.toolset == 'target'): # On mac, products are created in install_path immediately. assert install_path == self.output, '%s != %s' % ( install_path, self.output) # Point the target alias to the final binary output. self.WriteMakeRule([self.target], [install_path], comment='Add target alias', phony = True) if install_path != self.output: assert not self.is_mac_bundle # See comment a few lines above. self.WriteDoCmd([install_path], [self.output], 'copy', comment = 'Copy this to the %s output path.' % file_desc, part_of_all=part_of_all) installable_deps.append(install_path) if self.output != self.alias and self.alias != self.target: self.WriteMakeRule([self.alias], installable_deps, comment = 'Short alias for building this %s.' % file_desc, phony = True) if part_of_all: self.WriteMakeRule(['all'], [install_path], comment = 'Add %s to "all" target.' % file_desc, phony = True) def WriteList(self, value_list, variable=None, prefix='', quoter=QuoteIfNecessary): """Write a variable definition that is a list of values. E.g. WriteList(['a','b'], 'foo', prefix='blah') writes out foo = blaha blahb but in a pretty-printed style. """ values = '' if value_list: value_list = [quoter(prefix + l) for l in value_list] values = ' \\\n\t' + ' \\\n\t'.join(value_list) self.fp.write('%s :=%s\n\n' % (variable, values)) def WriteDoCmd(self, outputs, inputs, command, part_of_all, comment=None, postbuilds=False): """Write a Makefile rule that uses do_cmd. This makes the outputs dependent on the command line that was run, as well as support the V= make command line flag. """ suffix = '' if postbuilds: assert ',' not in command suffix = ',,1' # Tell do_cmd to honor $POSTBUILDS self.WriteMakeRule(outputs, inputs, actions = ['$(call do_cmd,%s%s)' % (command, suffix)], comment = comment, force = True) # Add our outputs to the list of targets we read depfiles from. # all_deps is only used for deps file reading, and for deps files we replace # spaces with ? because escaping doesn't work with make's $(sort) and # other functions. outputs = [QuoteSpaces(o, SPACE_REPLACEMENT) for o in outputs] self.WriteLn('all_deps += %s' % ' '.join(outputs)) def WriteMakeRule(self, outputs, inputs, actions=None, comment=None, order_only=False, force=False, phony=False): """Write a Makefile rule, with some extra tricks. outputs: a list of outputs for the rule (note: this is not directly supported by make; see comments below) inputs: a list of inputs for the rule actions: a list of shell commands to run for the rule comment: a comment to put in the Makefile above the rule (also useful for making this Python script's code self-documenting) order_only: if true, makes the dependency order-only force: if true, include FORCE_DO_CMD as an order-only dep phony: if true, the rule does not actually generate the named output, the output is just a name to run the rule """ outputs = map(QuoteSpaces, outputs) inputs = map(QuoteSpaces, inputs) if comment: self.WriteLn('# ' + comment) if phony: self.WriteLn('.PHONY: ' + ' '.join(outputs)) # TODO(evanm): just make order_only a list of deps instead of these hacks. if order_only: order_insert = '| ' pick_output = ' '.join(outputs) else: order_insert = '' pick_output = outputs[0] if force: force_append = ' FORCE_DO_CMD' else: force_append = '' if actions: self.WriteLn("%s: TOOLSET := $(TOOLSET)" % outputs[0]) self.WriteLn('%s: %s%s%s' % (pick_output, order_insert, ' '.join(inputs), force_append)) if actions: for action in actions: self.WriteLn('\t%s' % action) if not order_only and len(outputs) > 1: # If we have more than one output, a rule like # foo bar: baz # that for *each* output we must run the action, potentially # in parallel. That is not what we're trying to write -- what # we want is that we run the action once and it generates all # the files. # http://www.gnu.org/software/hello/manual/automake/Multiple-Outputs.html # discusses this problem and has this solution: # 1) Write the naive rule that would produce parallel runs of # the action. # 2) Make the outputs seralized on each other, so we won't start # a parallel run until the first run finishes, at which point # we'll have generated all the outputs and we're done. self.WriteLn('%s: %s' % (' '.join(outputs[1:]), outputs[0])) # Add a dummy command to the "extra outputs" rule, otherwise make seems to # think these outputs haven't (couldn't have?) changed, and thus doesn't # flag them as changed (i.e. include in '$?') when evaluating dependent # rules, which in turn causes do_cmd() to skip running dependent commands. self.WriteLn('%s: ;' % (' '.join(outputs[1:]))) self.WriteLn() def WriteAndroidNdkModuleRule(self, module_name, all_sources, link_deps): """Write a set of LOCAL_XXX definitions for Android NDK. These variable definitions will be used by Android NDK but do nothing for non-Android applications. Arguments: module_name: Android NDK module name, which must be unique among all module names. all_sources: A list of source files (will be filtered by Compilable). link_deps: A list of link dependencies, which must be sorted in the order from dependencies to dependents. """ if self.type not in ('executable', 'shared_library', 'static_library'): return self.WriteLn('# Variable definitions for Android applications') self.WriteLn('include $(CLEAR_VARS)') self.WriteLn('LOCAL_MODULE := ' + module_name) self.WriteLn('LOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) ' '$(DEFS_$(BUILDTYPE)) ' # LOCAL_CFLAGS is applied to both of C and C++. There is # no way to specify $(CFLAGS_C_$(BUILDTYPE)) only for C # sources. '$(CFLAGS_C_$(BUILDTYPE)) ' # $(INCS_$(BUILDTYPE)) includes the prefix '-I' while # LOCAL_C_INCLUDES does not expect it. So put it in # LOCAL_CFLAGS. '$(INCS_$(BUILDTYPE))') # LOCAL_CXXFLAGS is obsolete and LOCAL_CPPFLAGS is preferred. self.WriteLn('LOCAL_CPPFLAGS := $(CFLAGS_CC_$(BUILDTYPE))') self.WriteLn('LOCAL_C_INCLUDES :=') self.WriteLn('LOCAL_LDLIBS := $(LDFLAGS_$(BUILDTYPE)) $(LIBS)') # Detect the C++ extension. cpp_ext = {'.cc': 0, '.cpp': 0, '.cxx': 0} default_cpp_ext = '.cpp' for filename in all_sources: ext = os.path.splitext(filename)[1] if ext in cpp_ext: cpp_ext[ext] += 1 if cpp_ext[ext] > cpp_ext[default_cpp_ext]: default_cpp_ext = ext self.WriteLn('LOCAL_CPP_EXTENSION := ' + default_cpp_ext) self.WriteList(map(self.Absolutify, filter(Compilable, all_sources)), 'LOCAL_SRC_FILES') # Filter out those which do not match prefix and suffix and produce # the resulting list without prefix and suffix. def DepsToModules(deps, prefix, suffix): modules = [] for filepath in deps: filename = os.path.basename(filepath) if filename.startswith(prefix) and filename.endswith(suffix): modules.append(filename[len(prefix):-len(suffix)]) return modules # Retrieve the default value of 'SHARED_LIB_SUFFIX' params = {'flavor': 'linux'} default_variables = {} CalculateVariables(default_variables, params) self.WriteList( DepsToModules(link_deps, generator_default_variables['SHARED_LIB_PREFIX'], default_variables['SHARED_LIB_SUFFIX']), 'LOCAL_SHARED_LIBRARIES') self.WriteList( DepsToModules(link_deps, generator_default_variables['STATIC_LIB_PREFIX'], generator_default_variables['STATIC_LIB_SUFFIX']), 'LOCAL_STATIC_LIBRARIES') if self.type == 'executable': self.WriteLn('include $(BUILD_EXECUTABLE)') elif self.type == 'shared_library': self.WriteLn('include $(BUILD_SHARED_LIBRARY)') elif self.type == 'static_library': self.WriteLn('include $(BUILD_STATIC_LIBRARY)') self.WriteLn() def WriteLn(self, text=''): self.fp.write(text + '\n') def GetSortedXcodeEnv(self, additional_settings=None): return gyp.xcode_emulation.GetSortedXcodeEnv( self.xcode_settings, "$(abs_builddir)", os.path.join("$(abs_srcdir)", self.path), "$(BUILDTYPE)", additional_settings) def GetSortedXcodePostbuildEnv(self): # CHROMIUM_STRIP_SAVE_FILE is a chromium-specific hack. # TODO(thakis): It would be nice to have some general mechanism instead. strip_save_file = self.xcode_settings.GetPerTargetSetting( 'CHROMIUM_STRIP_SAVE_FILE', '') # Even if strip_save_file is empty, explicitly write it. Else a postbuild # might pick up an export from an earlier target. return self.GetSortedXcodeEnv( additional_settings={'CHROMIUM_STRIP_SAVE_FILE': strip_save_file}) def WriteSortedXcodeEnv(self, target, env): for k, v in env: # For # foo := a\ b # the escaped space does the right thing. For # export foo := a\ b # it does not -- the backslash is written to the env as literal character. # So don't escape spaces in |env[k]|. self.WriteLn('%s: export %s := %s' % (QuoteSpaces(target), k, v)) def Objectify(self, path): """Convert a path to its output directory form.""" if '$(' in path: path = path.replace('$(obj)/', '$(obj).%s/$(TARGET)/' % self.toolset) if not '$(obj)' in path: path = '$(obj).%s/$(TARGET)/%s' % (self.toolset, path) return path def Pchify(self, path, lang): """Convert a prefix header path to its output directory form.""" path = self.Absolutify(path) if '$(' in path: path = path.replace('$(obj)/', '$(obj).%s/$(TARGET)/pch-%s' % (self.toolset, lang)) return path return '$(obj).%s/$(TARGET)/pch-%s/%s' % (self.toolset, lang, path) def Absolutify(self, path): """Convert a subdirectory-relative path into a base-relative path. Skips over paths that contain variables.""" if '$(' in path: # Don't call normpath in this case, as it might collapse the # path too aggressively if it features '..'. However it's still # important to strip trailing slashes. return path.rstrip('/') return os.path.normpath(os.path.join(self.path, path)) def ExpandInputRoot(self, template, expansion, dirname): if '%(INPUT_ROOT)s' not in template and '%(INPUT_DIRNAME)s' not in template: return template path = template % { 'INPUT_ROOT': expansion, 'INPUT_DIRNAME': dirname, } return path def _InstallableTargetInstallPath(self): """Returns the location of the final output for an installable target.""" # Xcode puts shared_library results into PRODUCT_DIR, and some gyp files # rely on this. Emulate this behavior for mac. if (self.type == 'shared_library' and (self.flavor != 'mac' or self.toolset != 'target')): # Install all shared libs into a common directory (per toolset) for # convenient access with LD_LIBRARY_PATH. return '$(builddir)/lib.%s/%s' % (self.toolset, self.alias) return '$(builddir)/' + self.alias def WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files): """Write the target to regenerate the Makefile.""" options = params['options'] build_files_args = [gyp.common.RelativePath(filename, options.toplevel_dir) for filename in params['build_files_arg']] gyp_binary = gyp.common.FixIfRelativePath(params['gyp_binary'], options.toplevel_dir) if not gyp_binary.startswith(os.sep): gyp_binary = os.path.join('.', gyp_binary) root_makefile.write( "quiet_cmd_regen_makefile = ACTION Regenerating $@\n" "cmd_regen_makefile = cd $(srcdir); %(cmd)s\n" "%(makefile_name)s: %(deps)s\n" "\t$(call do_cmd,regen_makefile)\n\n" % { 'makefile_name': makefile_name, 'deps': ' '.join(map(Sourceify, build_files)), 'cmd': gyp.common.EncodePOSIXShellList( [gyp_binary, '-fmake'] + gyp.RegenerateFlags(options) + build_files_args)}) def PerformBuild(data, configurations, params): options = params['options'] for config in configurations: arguments = ['make'] if options.toplevel_dir and options.toplevel_dir != '.': arguments += '-C', options.toplevel_dir arguments.append('BUILDTYPE=' + config) print 'Building [%s]: %s' % (config, arguments) subprocess.check_call(arguments) def GenerateOutput(target_list, target_dicts, data, params): options = params['options'] flavor = gyp.common.GetFlavor(params) generator_flags = params.get('generator_flags', {}) builddir_name = generator_flags.get('output_dir', 'out') android_ndk_version = generator_flags.get('android_ndk_version', None) default_target = generator_flags.get('default_target', 'all') def CalculateMakefilePath(build_file, base_name): """Determine where to write a Makefile for a given gyp file.""" # Paths in gyp files are relative to the .gyp file, but we want # paths relative to the source root for the master makefile. Grab # the path of the .gyp file as the base to relativize against. # E.g. "foo/bar" when we're constructing targets for "foo/bar/baz.gyp". base_path = gyp.common.RelativePath(os.path.dirname(build_file), options.depth) # We write the file in the base_path directory. output_file = os.path.join(options.depth, base_path, base_name) if options.generator_output: output_file = os.path.join( options.depth, options.generator_output, base_path, base_name) base_path = gyp.common.RelativePath(os.path.dirname(build_file), options.toplevel_dir) return base_path, output_file # TODO: search for the first non-'Default' target. This can go # away when we add verification that all targets have the # necessary configurations. default_configuration = None toolsets = set([target_dicts[target]['toolset'] for target in target_list]) for target in target_list: spec = target_dicts[target] if spec['default_configuration'] != 'Default': default_configuration = spec['default_configuration'] break if not default_configuration: default_configuration = 'Default' srcdir = '.' makefile_name = 'Makefile' + options.suffix makefile_path = os.path.join(options.toplevel_dir, makefile_name) if options.generator_output: global srcdir_prefix makefile_path = os.path.join( options.toplevel_dir, options.generator_output, makefile_name) srcdir = gyp.common.RelativePath(srcdir, options.generator_output) srcdir_prefix = '$(srcdir)/' flock_command= 'flock' header_params = { 'default_target': default_target, 'builddir': builddir_name, 'default_configuration': default_configuration, 'flock': flock_command, 'flock_index': 1, 'link_commands': LINK_COMMANDS_LINUX, 'extra_commands': '', 'srcdir': srcdir, } if flavor == 'mac': flock_command = './gyp-mac-tool flock' header_params.update({ 'flock': flock_command, 'flock_index': 2, 'link_commands': LINK_COMMANDS_MAC, 'extra_commands': SHARED_HEADER_MAC_COMMANDS, }) elif flavor == 'android': header_params.update({ 'link_commands': LINK_COMMANDS_ANDROID, }) elif flavor == 'solaris': header_params.update({ 'flock': './gyp-flock-tool flock', 'flock_index': 2, }) elif flavor == 'freebsd': # Note: OpenBSD has sysutils/flock. lockf seems to be FreeBSD specific. header_params.update({ 'flock': 'lockf', }) elif flavor == 'aix': header_params.update({ 'link_commands': LINK_COMMANDS_AIX, 'flock': './gyp-flock-tool flock', 'flock_index': 2, }) header_params.update({ 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'), 'AR.target': GetEnvironFallback(('AR_target', 'AR'), '$(AR)'), 'CXX.target': GetEnvironFallback(('CXX_target', 'CXX'), '$(CXX)'), 'LINK.target': GetEnvironFallback(('LINK_target', 'LINK'), '$(LINK)'), 'CC.host': GetEnvironFallback(('CC_host',), 'gcc'), 'AR.host': GetEnvironFallback(('AR_host',), 'ar'), 'CXX.host': GetEnvironFallback(('CXX_host',), 'g++'), 'LINK.host': GetEnvironFallback(('LINK_host',), '$(CXX.host)'), }) build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) make_global_settings_array = data[build_file].get('make_global_settings', []) wrappers = {} wrappers['LINK'] = '%s $(builddir)/linker.lock' % flock_command for key, value in make_global_settings_array: if key.endswith('_wrapper'): wrappers[key[:-len('_wrapper')]] = '$(abspath %s)' % value make_global_settings = '' for key, value in make_global_settings_array: if re.match('.*_wrapper', key): continue if value[0] != '$': value = '$(abspath %s)' % value wrapper = wrappers.get(key) if wrapper: value = '%s %s' % (wrapper, value) del wrappers[key] if key in ('CC', 'CC.host', 'CXX', 'CXX.host'): make_global_settings += ( 'ifneq (,$(filter $(origin %s), undefined default))\n' % key) # Let gyp-time envvars win over global settings. env_key = key.replace('.', '_') # CC.host -> CC_host if env_key in os.environ: value = os.environ[env_key] make_global_settings += ' %s = %s\n' % (key, value) make_global_settings += 'endif\n' else: make_global_settings += '%s ?= %s\n' % (key, value) # TODO(ukai): define cmd when only wrapper is specified in # make_global_settings. header_params['make_global_settings'] = make_global_settings gyp.common.EnsureDirExists(makefile_path) root_makefile = open(makefile_path, 'w') root_makefile.write(SHARED_HEADER % header_params) # Currently any versions have the same effect, but in future the behavior # could be different. if android_ndk_version: root_makefile.write( '# Define LOCAL_PATH for build of Android applications.\n' 'LOCAL_PATH := $(call my-dir)\n' '\n') for toolset in toolsets: root_makefile.write('TOOLSET := %s\n' % toolset) WriteRootHeaderSuffixRules(root_makefile) # Put build-time support tools next to the root Makefile. dest_path = os.path.dirname(makefile_path) gyp.common.CopyTool(flavor, dest_path) # Find the list of targets that derive from the gyp file(s) being built. needed_targets = set() for build_file in params['build_files']: for target in gyp.common.AllTargets(target_list, target_dicts, build_file): needed_targets.add(target) build_files = set() include_list = set() for qualified_target in target_list: build_file, target, toolset = gyp.common.ParseQualifiedTarget( qualified_target) this_make_global_settings = data[build_file].get('make_global_settings', []) assert make_global_settings_array == this_make_global_settings, ( "make_global_settings needs to be the same for all targets. %s vs. %s" % (this_make_global_settings, make_global_settings)) build_files.add(gyp.common.RelativePath(build_file, options.toplevel_dir)) included_files = data[build_file]['included_files'] for included_file in included_files: # The included_files entries are relative to the dir of the build file # that included them, so we have to undo that and then make them relative # to the root dir. relative_include_file = gyp.common.RelativePath( gyp.common.UnrelativePath(included_file, build_file), options.toplevel_dir) abs_include_file = os.path.abspath(relative_include_file) # If the include file is from the ~/.gyp dir, we should use absolute path # so that relocating the src dir doesn't break the path. if (params['home_dot_gyp'] and abs_include_file.startswith(params['home_dot_gyp'])): build_files.add(abs_include_file) else: build_files.add(relative_include_file) base_path, output_file = CalculateMakefilePath(build_file, target + '.' + toolset + options.suffix + '.mk') spec = target_dicts[qualified_target] configs = spec['configurations'] if flavor == 'mac': gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(data[build_file], spec) writer = MakefileWriter(generator_flags, flavor) writer.Write(qualified_target, base_path, output_file, spec, configs, part_of_all=qualified_target in needed_targets) # Our root_makefile lives at the source root. Compute the relative path # from there to the output_file for including. mkfile_rel_path = gyp.common.RelativePath(output_file, os.path.dirname(makefile_path)) include_list.add(mkfile_rel_path) # Write out per-gyp (sub-project) Makefiles. depth_rel_path = gyp.common.RelativePath(options.depth, os.getcwd()) for build_file in build_files: # The paths in build_files were relativized above, so undo that before # testing against the non-relativized items in target_list and before # calculating the Makefile path. build_file = os.path.join(depth_rel_path, build_file) gyp_targets = [target_dicts[target]['target_name'] for target in target_list if target.startswith(build_file) and target in needed_targets] # Only generate Makefiles for gyp files with targets. if not gyp_targets: continue base_path, output_file = CalculateMakefilePath(build_file, os.path.splitext(os.path.basename(build_file))[0] + '.Makefile') makefile_rel_path = gyp.common.RelativePath(os.path.dirname(makefile_path), os.path.dirname(output_file)) writer.WriteSubMake(output_file, makefile_rel_path, gyp_targets, builddir_name) # Write out the sorted list of includes. root_makefile.write('\n') for include_file in sorted(include_list): # We wrap each .mk include in an if statement so users can tell make to # not load a file by setting NO_LOAD. The below make code says, only # load the .mk file if the .mk filename doesn't start with a token in # NO_LOAD. root_makefile.write( "ifeq ($(strip $(foreach prefix,$(NO_LOAD),\\\n" " $(findstring $(join ^,$(prefix)),\\\n" " $(join ^," + include_file + ")))),)\n") root_makefile.write(" include " + include_file + "\n") root_makefile.write("endif\n") root_makefile.write('\n') if (not generator_flags.get('standalone') and generator_flags.get('auto_regeneration', True)): WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) root_makefile.write(SHARED_FOOTER) root_makefile.close()
gpl-3.0
[ 3, 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 3, 8144, 26, 199, 3, 199, 3, 961, 365, 1006, 28568, 590, 4079, 641, 314, 20618, 2656, 1202, 701, 314, 10130, 199, 3, 5114, 12, 1325, 365, 282, 2222, 13, 9931, 1852, 1553, 781, 5324, 314, 8039, 5936, 199, 3, 3343, 315, 13738, 402, 1852, 436, 4691, 652, 9658, 652, 734, 14, 199, 3, 199, 3, 710, 1233, 5084, 12821, 282, 7396, 1275, 3880, 570, 367, 1924, 1347, 12, 1325, 199, 3, 1006, 787, 1350, 68, 701, 314, 2746, 13, 1896, 20618, 14, 221, 961, 4910, 626, 1006, 199, 3, 2860, 315, 1275, 3880, 13, 1725, 286, 22669, 1373, 4573, 14, 221, 6423, 25082, 370, 675, 12952, 199, 3, 2382, 5827, 367, 8569, 11735, 12, 436, 8545, 590, 370, 9626, 199, 3, 626, 1265, 3984, 440, 295, 6670, 641, 282, 1750, 574, 370, 2061, 506, 3109, 3365, 199, 3, 1275, 3880, 1584, 14, 199, 3, 199, 3, 3254, 83, 26, 199, 3, 199, 3, 13641, 2202, 436, 11420, 3423, 787, 5544, 8292, 379, 315, 314, 199, 3, 13836, 20618, 14, 221, 2779, 1443, 1852, 12249, 370, 3550, 2005, 1275, 3880, 1584, 641, 199, 3, 314, 5366, 370, 4215, 314, 314, 1584, 12701, 14, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 3873, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 8701, 63, 20526, 199, 504, 4902, 14, 2330, 492, 2372, 23027, 21860, 199, 504, 4902, 14, 2330, 492, 18151, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 23227, 63, 3022, 356, 9774, 1113, 680, 6629, 16892, 2447, 6629, 9268, 2447, 2268, 73, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 9774, 1113, 2447, 2268, 297, 523, 283, 14853, 63, 3022, 356, 9774, 21728, 3196, 523, 283, 13578, 63, 7321, 63, 5441, 356, 9487, 7321, 63, 5441, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 9487, 7321, 63, 3022, 2339, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3243, 356, 9774, 4832, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2472, 356, 9774, 4511, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2339, 356, 9774, 1397, 694, 2672, 28, 3196, 523, 283, 22212, 63, 2339, 356, 9774, 25682, 3196, 199, 93, 199, 199, 3, 4155, 5171, 3663, 4744, 2193, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 199, 3, 4784, 3355, 5124, 315, 314, 1865, 687, 11410, 83, 370, 5124, 14, 199, 4679, 63, 28789, 63, 5917, 63, 5714, 275, 756, 199, 199, 3, 510, 416, 1411, 83, 4287, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 942, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 199, 4679, 63, 14964, 63, 3771, 275, 488, 421, 199, 318, 12707, 11458, 8, 885, 63, 3669, 12, 1862, 304, 523, 408, 14860, 4722, 2860, 367, 675, 315, 314, 1900, 334, 3527, 701, 4902, 10477, 523, 8541, 275, 4902, 14, 2330, 14, 1002, 16739, 8, 1162, 9, 523, 340, 8541, 508, 283, 3088, 356, 272, 849, 63, 3669, 14, 5486, 360, 3100, 297, 283, 3088, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 12273, 297, 1987, 22305, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 3022, 297, 639, 4306, 63, 885, 63, 3669, 459, 14853, 63, 3022, 1105, 272, 849, 63, 3669, 14, 5486, 360, 5617, 63, 3022, 297, 639, 4306, 63, 885, 63, 3669, 459, 14853, 63, 3022, 1105, 339, 327, 11247, 4722, 4306, 2897, 666, 687, 10602, 12, 1314, 365, 5709, 272, 327, 701, 314, 10444, 4155, 4306, 14, 272, 492, 4902, 14, 4679, 14, 8701, 465, 13592, 63, 4679, 272, 2288, 4306, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 272, 4306, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 297, 3073, 272, 2288, 4306, 63, 8460, 63, 515, 63, 7786, 272, 4306, 63, 8460, 63, 515, 63, 7786, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 8460, 63, 515, 63, 7786, 297, 3073, 272, 2288, 4306, 63, 2911, 63, 4553, 63, 509, 63, 4423, 272, 4306, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 297, 3073, 272, 16503, 1193, 2617, 63, 18451, 14, 873, 2561, 1370, 77, 356, 283, 27148, 297, 1987, 596, 7, 520, 283, 1113, 9634, 3071, 523, 587, 26, 272, 17406, 63, 2253, 275, 8541, 272, 340, 8541, 508, 283, 6238, 356, 489, 17406, 63, 2253, 275, 283, 5135, 7, 221, 327, 14797, 642, 12139, 5953, 367, 3063, 14, 272, 849, 63, 3669, 14, 5486, 360, 3100, 297, 17406, 63, 2253, 9, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 12273, 297, 1987, 1152, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 3022, 1673, 6629, 21728, 2447, 773, 24752, 16892, 5942, 272, 849, 63, 3669, 14, 5486, 360, 5617, 63, 3022, 297, 9774, 1113, 680, 6629, 16892, 5942, 421, 199, 318, 12707, 7599, 3205, 2354, 8, 1162, 304, 523, 408, 14860, 314, 4306, 2488, 2256, 626, 7545, 23036, 370, 1324, 334, 3527, 701, 523, 4902, 10477, 523, 4306, 63, 2469, 275, 1862, 14, 362, 360, 4679, 63, 2469, 297, 5009, 523, 15516, 63, 977, 75, 63, 1023, 275, 4306, 63, 2469, 14, 362, 360, 6238, 63, 977, 75, 63, 1023, 297, 488, 9, 523 ]
[ 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 3, 8144, 26, 199, 3, 199, 3, 961, 365, 1006, 28568, 590, 4079, 641, 314, 20618, 2656, 1202, 701, 314, 10130, 199, 3, 5114, 12, 1325, 365, 282, 2222, 13, 9931, 1852, 1553, 781, 5324, 314, 8039, 5936, 199, 3, 3343, 315, 13738, 402, 1852, 436, 4691, 652, 9658, 652, 734, 14, 199, 3, 199, 3, 710, 1233, 5084, 12821, 282, 7396, 1275, 3880, 570, 367, 1924, 1347, 12, 1325, 199, 3, 1006, 787, 1350, 68, 701, 314, 2746, 13, 1896, 20618, 14, 221, 961, 4910, 626, 1006, 199, 3, 2860, 315, 1275, 3880, 13, 1725, 286, 22669, 1373, 4573, 14, 221, 6423, 25082, 370, 675, 12952, 199, 3, 2382, 5827, 367, 8569, 11735, 12, 436, 8545, 590, 370, 9626, 199, 3, 626, 1265, 3984, 440, 295, 6670, 641, 282, 1750, 574, 370, 2061, 506, 3109, 3365, 199, 3, 1275, 3880, 1584, 14, 199, 3, 199, 3, 3254, 83, 26, 199, 3, 199, 3, 13641, 2202, 436, 11420, 3423, 787, 5544, 8292, 379, 315, 314, 199, 3, 13836, 20618, 14, 221, 2779, 1443, 1852, 12249, 370, 3550, 2005, 1275, 3880, 1584, 641, 199, 3, 314, 5366, 370, 4215, 314, 314, 1584, 12701, 14, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 3873, 199, 646, 4902, 199, 646, 4902, 14, 2330, 199, 646, 4902, 14, 8701, 63, 20526, 199, 504, 4902, 14, 2330, 492, 2372, 23027, 21860, 199, 504, 4902, 14, 2330, 492, 18151, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 23227, 63, 3022, 356, 9774, 1113, 680, 6629, 16892, 2447, 6629, 9268, 2447, 2268, 73, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 9774, 1113, 2447, 2268, 297, 523, 283, 14853, 63, 3022, 356, 9774, 21728, 3196, 523, 283, 13578, 63, 7321, 63, 5441, 356, 9487, 7321, 63, 5441, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 9487, 7321, 63, 3022, 2339, 9, 83, 297, 221, 327, 961, 7545, 11507, 701, 2018, 14, 523, 283, 13578, 63, 7321, 63, 3243, 356, 9774, 4832, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2472, 356, 9774, 4511, 2672, 28, 3196, 523, 283, 13578, 63, 7321, 63, 2339, 356, 9774, 1397, 694, 2672, 28, 3196, 523, 283, 22212, 63, 2339, 356, 9774, 25682, 3196, 199, 93, 199, 199, 3, 4155, 5171, 3663, 4744, 2193, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 199, 3, 4784, 3355, 5124, 315, 314, 1865, 687, 11410, 83, 370, 5124, 14, 199, 4679, 63, 28789, 63, 5917, 63, 5714, 275, 756, 199, 199, 3, 510, 416, 1411, 83, 4287, 14, 199, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 942, 199, 4679, 63, 8460, 63, 515, 63, 7786, 275, 942, 199, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 942, 199, 4679, 63, 14964, 63, 3771, 275, 488, 421, 199, 318, 12707, 11458, 8, 885, 63, 3669, 12, 1862, 304, 523, 408, 14860, 4722, 2860, 367, 675, 315, 314, 1900, 334, 3527, 701, 4902, 10477, 523, 8541, 275, 4902, 14, 2330, 14, 1002, 16739, 8, 1162, 9, 523, 340, 8541, 508, 283, 3088, 356, 272, 849, 63, 3669, 14, 5486, 360, 3100, 297, 283, 3088, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 12273, 297, 1987, 22305, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 3022, 297, 639, 4306, 63, 885, 63, 3669, 459, 14853, 63, 3022, 1105, 272, 849, 63, 3669, 14, 5486, 360, 5617, 63, 3022, 297, 639, 4306, 63, 885, 63, 3669, 459, 14853, 63, 3022, 1105, 339, 327, 11247, 4722, 4306, 2897, 666, 687, 10602, 12, 1314, 365, 5709, 272, 327, 701, 314, 10444, 4155, 4306, 14, 272, 492, 4902, 14, 4679, 14, 8701, 465, 13592, 63, 4679, 272, 2288, 4306, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 272, 4306, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 297, 3073, 272, 2288, 4306, 63, 8460, 63, 515, 63, 7786, 272, 4306, 63, 8460, 63, 515, 63, 7786, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 8460, 63, 515, 63, 7786, 297, 3073, 272, 2288, 4306, 63, 2911, 63, 4553, 63, 509, 63, 4423, 272, 4306, 63, 2911, 63, 4553, 63, 509, 63, 4423, 275, 2519, 8, 8701, 63, 4679, 12, 267, 283, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 297, 3073, 272, 16503, 1193, 2617, 63, 18451, 14, 873, 2561, 1370, 77, 356, 283, 27148, 297, 1987, 596, 7, 520, 283, 1113, 9634, 3071, 523, 587, 26, 272, 17406, 63, 2253, 275, 8541, 272, 340, 8541, 508, 283, 6238, 356, 489, 17406, 63, 2253, 275, 283, 5135, 7, 221, 327, 14797, 642, 12139, 5953, 367, 3063, 14, 272, 849, 63, 3669, 14, 5486, 360, 3100, 297, 17406, 63, 2253, 9, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 12273, 297, 1987, 1152, 358, 272, 849, 63, 3669, 14, 5486, 360, 13772, 63, 5617, 63, 3022, 1673, 6629, 21728, 2447, 773, 24752, 16892, 5942, 272, 849, 63, 3669, 14, 5486, 360, 5617, 63, 3022, 297, 9774, 1113, 680, 6629, 16892, 5942, 421, 199, 318, 12707, 7599, 3205, 2354, 8, 1162, 304, 523, 408, 14860, 314, 4306, 2488, 2256, 626, 7545, 23036, 370, 1324, 334, 3527, 701, 523, 4902, 10477, 523, 4306, 63, 2469, 275, 1862, 14, 362, 360, 4679, 63, 2469, 297, 5009, 523, 15516, 63, 977, 75, 63, 1023, 275, 4306, 63, 2469, 14, 362, 360, 6238, 63, 977, 75, 63, 1023, 297, 488, 9, 523, 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, 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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 ]
okanasik/JdeRobot
src/tools/visualStates/samples/goforward/goforward.py
2
4201
#!/usr/bin/python # -*- coding: utf-8 -*- import easyiceconfig as EasyIce import jderobotComm as comm import sys, signal sys.path.append('/usr/local/share/jderobot/python/visualHFSM_py') import traceback, threading, time from automatagui import AutomataGui, QtGui, GuiSubautomata from jderobot import MotorsPrx from jderobot import LaserPrx class Automata(): def __init__(self): self.lock = threading.Lock() self.displayGui = False self.StatesSub1 = [ "GoForward", "GoBack", ] self.sub1 = "GoForward" self.run1 = True def calculate_obstacle(self): self.laserData = self.KobukiLaser.getLaserData() min_dist = 1000 for i in range(len(self.laserData.values)): if self.laserData.values[i] < min_dist: min_dist = self.laserData.values[i] if min_dist < 1.0: return True else: return False def startThreads(self): self.t1 = threading.Thread(target=self.subautomata1) self.t1.start() def createAutomata(self): guiSubautomataList = [] # Creating subAutomata1 guiSubautomata1 = GuiSubautomata(1,0, self.automataGui) guiSubautomata1.newGuiNode(1, 0, 69, 163, 1, 'GoForward') guiSubautomata1.newGuiNode(2, 0, 255, 117, 0, 'GoBack') guiSubautomata1.newGuiTransition((69, 163), (255, 117), (139, 78), 1, 1, 2) guiSubautomata1.newGuiTransition((255, 117), (69, 163), (189, 196), 2, 2, 1) guiSubautomataList.append(guiSubautomata1) return guiSubautomataList def shutDown(self): self.run1 = False def runGui(self): app = QtGui.QApplication(sys.argv) self.automataGui = AutomataGui() self.automataGui.setAutomata(self.createAutomata()) self.automataGui.loadAutomata() self.startThreads() self.automataGui.show() app.exec_() def subautomata1(self): self.run1 = True cycle = 100 t_activated = False t_fin = 0 while(self.run1): totala = time.time() * 1000000 # Evaluation if if(self.sub1 == "GoForward"): if(self.calculate_obstacle()): self.sub1 = "GoBack" if self.displayGui: self.automataGui.notifySetNodeAsActive('GoBack') elif(self.sub1 == "GoBack"): if(not self.calculate_obstacle()): self.sub1 = "GoForward" if self.displayGui: self.automataGui.notifySetNodeAsActive('GoForward') # Actuation if if(self.sub1 == "GoForward"): self.KobukiMotors.sendV(0.5) self.KobukiMotors.sendW(0.0) elif(self.sub1 == "GoBack"): self.KobukiMotors.sendV(-0.3) self.KobukiMotors.sendW(0.2) totalb = time.time() * 1000000 msecs = (totalb - totala) / 1000; if(msecs < 0 or msecs > cycle): msecs = cycle else: msecs = cycle - msecs time.sleep(msecs / 1000) if(msecs < 33 ): time.sleep(33 / 1000); def connectToProxys(self): self.ic = EasyIce.initialize(sys.argv) self.ic,self.node = comm.init(self.ic) # Contact to KobukiMotors self.KobukiMotors = comm.getMotorsClient(self.ic, 'automata.KobukiMotors') if(not self.KobukiMotors): raise Exception('could not create client with KobukiMotors') print('KobukiMotors connected') # Contact to KobukiLaser self.KobukiLaser = comm.getLaserClient(self.ic, 'automata.KobukiLaser') if(not self.KobukiLaser): raise Exception('could not create client with KobukiLaser') print('KobukiLaser connected') def destroyIc(self): self.KobukiMotors.stop() self.KobukiLaser.stop() comm.destroy(self.ic, self.node) def start(self): if self.displayGui: self.guiThread = threading.Thread(target=self.runGui) self.guiThread.start() else: self.startThreads() def join(self): if self.displayGui: self.guiThread.join() self.t1.join() def readArgs(self): for arg in sys.argv: splitedArg = arg.split('=') if splitedArg[0] == '--displaygui': if splitedArg[1] == 'True' or splitedArg[1] == 'true': self.displayGui = True print('runtime gui enabled') else: self.displayGui = False print('runtime gui disabled') if __name__ == '__main__': signal.signal(signal.SIGINT, signal.SIG_DFL) automata = Automata() try: automata.connectToProxys() automata.readArgs() automata.start() automata.join() sys.exit(0) except: traceback.print_exc() automata.destroyIc() sys.exit(-1)
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 8837, 1885, 888, 465, 18951, 41, 301, 199, 646, 1335, 271, 9751, 5150, 465, 1923, 199, 646, 984, 12, 4673, 199, 1274, 14, 515, 14, 740, 2336, 2647, 15, 1832, 15, 6251, 15, 74, 271, 9751, 15, 1548, 15, 16948, 25500, 4029, 63, 647, 358, 199, 646, 5190, 12, 5796, 12, 900, 199, 504, 6384, 676, 419, 5885, 492, 27722, 676, 419, 4324, 12, 5928, 12, 14425, 2610, 6898, 676, 419, 199, 199, 504, 1335, 271, 9751, 492, 603, 357, 1384, 48, 6872, 199, 504, 1335, 271, 9751, 492, 7964, 332, 48, 6872, 199, 199, 533, 27722, 676, 419, 837, 421, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 831, 275, 5796, 14, 6432, 342, 507, 198, 277, 14, 2918, 4324, 275, 756, 507, 198, 277, 14, 18010, 2610, 17, 275, 359, 686, 198, 2, 7250, 12984, 401, 686, 198, 2, 7250, 4540, 401, 507, 198, 61, 2742, 198, 277, 14, 954, 17, 275, 298, 7250, 12984, 2, 507, 198, 277, 14, 1065, 17, 275, 715, 421, 198, 318, 8671, 63, 2873, 270, 12550, 8, 277, 304, 507, 198, 277, 14, 416, 332, 1451, 275, 291, 14, 31305, 464, 8810, 7833, 332, 14, 362, 7833, 332, 1451, 342, 507, 198, 827, 63, 2686, 275, 5198, 507, 198, 509, 284, 315, 1425, 8, 552, 8, 277, 14, 416, 332, 1451, 14, 1459, 2298, 686, 198, 692, 291, 14, 416, 332, 1451, 14, 1459, 59, 73, 61, 665, 1748, 63, 2686, 26, 1585, 198, 827, 63, 2686, 275, 291, 14, 416, 332, 1451, 14, 1459, 59, 73, 61, 28550, 198, 692, 1748, 63, 2686, 665, 413, 14, 16, 26, 686, 198, 1107, 715, 507, 198, 2836, 26, 686, 198, 1107, 756, 8299, 198, 318, 1343, 22785, 8, 277, 304, 507, 198, 277, 14, 84, 17, 275, 5796, 14, 4436, 8, 1375, 29, 277, 14, 954, 6898, 676, 419, 17, 9, 507, 198, 277, 14, 84, 17, 14, 928, 342, 421, 198, 318, 1218, 23570, 676, 419, 8, 277, 304, 507, 198, 5885, 2610, 6898, 676, 419, 1296, 275, 942, 2742, 198, 3, 20507, 1007, 23570, 676, 419, 17, 507, 198, 5885, 2610, 6898, 676, 419, 17, 275, 14425, 2610, 6898, 676, 419, 8, 17, 12, 16, 12, 291, 14, 6898, 676, 419, 4324, 9, 2742, 198, 5885, 2610, 6898, 676, 419, 17, 14, 1222, 4324, 1716, 8, 17, 12, 378, 12, 14610, 12, 24619, 12, 413, 12, 283, 7250, 12984, 358, 507, 198, 5885, 2610, 6898, 676, 419, 17, 14, 1222, 4324, 1716, 8, 18, 12, 378, 12, 5450, 12, 26189, 12, 378, 12, 283, 7250, 4540, 358, 2742, 198, 5885, 2610, 6898, 676, 419, 17, 14, 1222, 4324, 21881, 1332, 1876, 12, 24619, 395, 334, 2299, 12, 26189, 395, 334, 7491, 12, 14679, 395, 413, 12, 413, 12, 499, 9, 507, 198, 5885, 2610, 6898, 676, 419, 17, 14, 1222, 4324, 21881, 1332, 2299, 12, 26189, 395, 334, 1876, 12, 24619, 395, 334, 11370, 12, 32132, 395, 499, 12, 499, 12, 413, 9, 507, 198, 5885, 2610, 6898, 676, 419, 1296, 14, 740, 8, 5885, 2610, 6898, 676, 419, 17, 9, 421, 507, 198, 1107, 11621, 2610, 6898, 676, 419, 1296, 421, 198, 318, 24761, 3514, 8, 277, 304, 507, 198, 277, 14, 1065, 17, 275, 756, 421, 198, 318, 1255, 4324, 8, 277, 304, 507, 198, 571, 275, 5928, 14, 12757, 8, 1274, 14, 3020, 9, 507, 198, 277, 14, 6898, 676, 419, 4324, 275, 27722, 676, 419, 4324, 342, 507, 198, 277, 14, 6898, 676, 419, 4324, 14, 409, 23570, 676, 419, 8, 277, 14, 981, 23570, 676, 419, 1012, 507, 198, 277, 14, 6898, 676, 419, 4324, 14, 912, 23570, 676, 419, 342, 507, 198, 277, 14, 928, 22785, 342, 507, 198, 277, 14, 6898, 676, 419, 4324, 14, 2384, 342, 507, 198, 571, 14, 1628, 12798, 421, 198, 318, 1007, 6898, 676, 419, 17, 8, 277, 304, 507, 198, 277, 14, 1065, 17, 275, 715, 507, 198, 7612, 275, 2948, 507, 198, 84, 63, 18218, 275, 756, 507, 198, 84, 63, 2408, 275, 378, 421, 507, 198, 6710, 8, 277, 14, 1065, 17, 304, 686, 198, 2923, 65, 275, 900, 14, 521, 342, 627, 19492, 6319, 198, 3, 16494, 4086, 340, 686, 198, 692, 8, 277, 14, 954, 17, 508, 298, 7250, 12984, 2349, 1585, 198, 692, 8, 277, 14, 12063, 63, 2873, 270, 12550, 5109, 1871, 198, 277, 14, 954, 17, 275, 298, 7250, 4540, 2, 1871, 198, 692, 291, 14, 2918, 4324, 26, 4671, 198, 277, 14, 6898, 676, 419, 4324, 14, 6814, 31599, 2822, 7472, 360, 7250, 4540, 358, 6319, 198, 4164, 8, 277, 14, 954, 17, 508, 298, 7250, 4540, 2349, 1585, 198, 692, 8, 1397, 291, 14, 12063, 63, 2873, 270, 12550, 5109, 1871, 198, 277, 14, 954, 17, 275, 298, 7250, 12984, 2, 1871, 198, 692, 291, 14, 2918, 4324, 26, 4671, 198, 277, 14, 6898, 676, 419, 4324, 14, 6814, 31599, 2822, 7472, 360, 7250, 12984, 358, 421, 686, 198, 3, 18982, 4086, 340, 686, 198, 692, 8, 277, 14, 954, 17, 508, 298, 7250, 12984, 2349, 1585, 198, 277, 14, 31305, 464, 8810, 45, 357, 1384, 14, 2254, 54, 8, 16, 14, 21, 9, 1585, 198, 277, 14, 31305, 464, 8810, 45, 357, 1384, 14, 2254, 55, 8, 16, 14, 16, 9, 686, 198, 4164, 8, 277, 14, 954, 17, 508, 298, 7250, 4540, 2349, 1585, 198, 277, 14, 31305, 464, 8810, 45, 357, 1384, 14, 2254, 54, 2801, 16, 14, 19, 9, 1585, 198, 277, 14, 31305, 464, 8810, 45, 357, 1384, 14, 2254, 55, 8, 16, 14, 18, 9, 6319, 198, 2923, 66, 275, 900, 14, 521, 342, 627, 19492, 686, 198, 77, 4855, 275, 334, 2923, 66, 446, 3141, 65, 9, 1182, 5198, 27, 686, 198, 692, 8, 77, 4855, 665, 378, 503, 333, 4855, 690, 8643, 304, 1585, 198, 77, 4855, 275, 8643, 686, 198, 2836, 26, 1585, 198, 77, 4855, 275, 8643, 446, 333, 4855, 6319, 198, 521, 14, 4532, 8, 77, 4855, 1182, 5198, 9, 686, 198, 692, 8, 77, 4855, 665, 9404, 3461, 1585, 198 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 646, 8837, 1885, 888, 465, 18951, 41, 301, 199, 646, 1335, 271, 9751, 5150, 465, 1923, 199, 646, 984, 12, 4673, 199, 1274, 14, 515, 14, 740, 2336, 2647, 15, 1832, 15, 6251, 15, 74, 271, 9751, 15, 1548, 15, 16948, 25500, 4029, 63, 647, 358, 199, 646, 5190, 12, 5796, 12, 900, 199, 504, 6384, 676, 419, 5885, 492, 27722, 676, 419, 4324, 12, 5928, 12, 14425, 2610, 6898, 676, 419, 199, 199, 504, 1335, 271, 9751, 492, 603, 357, 1384, 48, 6872, 199, 504, 1335, 271, 9751, 492, 7964, 332, 48, 6872, 199, 199, 533, 27722, 676, 419, 837, 421, 198, 318, 636, 826, 721, 277, 304, 507, 198, 277, 14, 831, 275, 5796, 14, 6432, 342, 507, 198, 277, 14, 2918, 4324, 275, 756, 507, 198, 277, 14, 18010, 2610, 17, 275, 359, 686, 198, 2, 7250, 12984, 401, 686, 198, 2, 7250, 4540, 401, 507, 198, 61, 2742, 198, 277, 14, 954, 17, 275, 298, 7250, 12984, 2, 507, 198, 277, 14, 1065, 17, 275, 715, 421, 198, 318, 8671, 63, 2873, 270, 12550, 8, 277, 304, 507, 198, 277, 14, 416, 332, 1451, 275, 291, 14, 31305, 464, 8810, 7833, 332, 14, 362, 7833, 332, 1451, 342, 507, 198, 827, 63, 2686, 275, 5198, 507, 198, 509, 284, 315, 1425, 8, 552, 8, 277, 14, 416, 332, 1451, 14, 1459, 2298, 686, 198, 692, 291, 14, 416, 332, 1451, 14, 1459, 59, 73, 61, 665, 1748, 63, 2686, 26, 1585, 198, 827, 63, 2686, 275, 291, 14, 416, 332, 1451, 14, 1459, 59, 73, 61, 28550, 198, 692, 1748, 63, 2686, 665, 413, 14, 16, 26, 686, 198, 1107, 715, 507, 198, 2836, 26, 686, 198, 1107, 756, 8299, 198, 318, 1343, 22785, 8, 277, 304, 507, 198, 277, 14, 84, 17, 275, 5796, 14, 4436, 8, 1375, 29, 277, 14, 954, 6898, 676, 419, 17, 9, 507, 198, 277, 14, 84, 17, 14, 928, 342, 421, 198, 318, 1218, 23570, 676, 419, 8, 277, 304, 507, 198, 5885, 2610, 6898, 676, 419, 1296, 275, 942, 2742, 198, 3, 20507, 1007, 23570, 676, 419, 17, 507, 198, 5885, 2610, 6898, 676, 419, 17, 275, 14425, 2610, 6898, 676, 419, 8, 17, 12, 16, 12, 291, 14, 6898, 676, 419, 4324, 9, 2742, 198, 5885, 2610, 6898, 676, 419, 17, 14, 1222, 4324, 1716, 8, 17, 12, 378, 12, 14610, 12, 24619, 12, 413, 12, 283, 7250, 12984, 358, 507, 198, 5885, 2610, 6898, 676, 419, 17, 14, 1222, 4324, 1716, 8, 18, 12, 378, 12, 5450, 12, 26189, 12, 378, 12, 283, 7250, 4540, 358, 2742, 198, 5885, 2610, 6898, 676, 419, 17, 14, 1222, 4324, 21881, 1332, 1876, 12, 24619, 395, 334, 2299, 12, 26189, 395, 334, 7491, 12, 14679, 395, 413, 12, 413, 12, 499, 9, 507, 198, 5885, 2610, 6898, 676, 419, 17, 14, 1222, 4324, 21881, 1332, 2299, 12, 26189, 395, 334, 1876, 12, 24619, 395, 334, 11370, 12, 32132, 395, 499, 12, 499, 12, 413, 9, 507, 198, 5885, 2610, 6898, 676, 419, 1296, 14, 740, 8, 5885, 2610, 6898, 676, 419, 17, 9, 421, 507, 198, 1107, 11621, 2610, 6898, 676, 419, 1296, 421, 198, 318, 24761, 3514, 8, 277, 304, 507, 198, 277, 14, 1065, 17, 275, 756, 421, 198, 318, 1255, 4324, 8, 277, 304, 507, 198, 571, 275, 5928, 14, 12757, 8, 1274, 14, 3020, 9, 507, 198, 277, 14, 6898, 676, 419, 4324, 275, 27722, 676, 419, 4324, 342, 507, 198, 277, 14, 6898, 676, 419, 4324, 14, 409, 23570, 676, 419, 8, 277, 14, 981, 23570, 676, 419, 1012, 507, 198, 277, 14, 6898, 676, 419, 4324, 14, 912, 23570, 676, 419, 342, 507, 198, 277, 14, 928, 22785, 342, 507, 198, 277, 14, 6898, 676, 419, 4324, 14, 2384, 342, 507, 198, 571, 14, 1628, 12798, 421, 198, 318, 1007, 6898, 676, 419, 17, 8, 277, 304, 507, 198, 277, 14, 1065, 17, 275, 715, 507, 198, 7612, 275, 2948, 507, 198, 84, 63, 18218, 275, 756, 507, 198, 84, 63, 2408, 275, 378, 421, 507, 198, 6710, 8, 277, 14, 1065, 17, 304, 686, 198, 2923, 65, 275, 900, 14, 521, 342, 627, 19492, 6319, 198, 3, 16494, 4086, 340, 686, 198, 692, 8, 277, 14, 954, 17, 508, 298, 7250, 12984, 2349, 1585, 198, 692, 8, 277, 14, 12063, 63, 2873, 270, 12550, 5109, 1871, 198, 277, 14, 954, 17, 275, 298, 7250, 4540, 2, 1871, 198, 692, 291, 14, 2918, 4324, 26, 4671, 198, 277, 14, 6898, 676, 419, 4324, 14, 6814, 31599, 2822, 7472, 360, 7250, 4540, 358, 6319, 198, 4164, 8, 277, 14, 954, 17, 508, 298, 7250, 4540, 2349, 1585, 198, 692, 8, 1397, 291, 14, 12063, 63, 2873, 270, 12550, 5109, 1871, 198, 277, 14, 954, 17, 275, 298, 7250, 12984, 2, 1871, 198, 692, 291, 14, 2918, 4324, 26, 4671, 198, 277, 14, 6898, 676, 419, 4324, 14, 6814, 31599, 2822, 7472, 360, 7250, 12984, 358, 421, 686, 198, 3, 18982, 4086, 340, 686, 198, 692, 8, 277, 14, 954, 17, 508, 298, 7250, 12984, 2349, 1585, 198, 277, 14, 31305, 464, 8810, 45, 357, 1384, 14, 2254, 54, 8, 16, 14, 21, 9, 1585, 198, 277, 14, 31305, 464, 8810, 45, 357, 1384, 14, 2254, 55, 8, 16, 14, 16, 9, 686, 198, 4164, 8, 277, 14, 954, 17, 508, 298, 7250, 4540, 2349, 1585, 198, 277, 14, 31305, 464, 8810, 45, 357, 1384, 14, 2254, 54, 2801, 16, 14, 19, 9, 1585, 198, 277, 14, 31305, 464, 8810, 45, 357, 1384, 14, 2254, 55, 8, 16, 14, 18, 9, 6319, 198, 2923, 66, 275, 900, 14, 521, 342, 627, 19492, 686, 198, 77, 4855, 275, 334, 2923, 66, 446, 3141, 65, 9, 1182, 5198, 27, 686, 198, 692, 8, 77, 4855, 665, 378, 503, 333, 4855, 690, 8643, 304, 1585, 198, 77, 4855, 275, 8643, 686, 198, 2836, 26, 1585, 198, 77, 4855, 275, 8643, 446, 333, 4855, 6319, 198, 521, 14, 4532, 8,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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 ]
kelle/astropy
astropy/table/tests/test_index.py
1
16394
# Licensed under a 3-clause BSD style license - see LICENSE.rst import pytest import numpy as np from .test_table import SetupData from ..bst import BST, FastRBT from ..sorted_array import SortedArray from ..table import QTable, Row from ... import units as u from ...time import Time from ..column import BaseColumn from ...extern.six.moves import range @pytest.fixture(params=[BST, FastRBT, SortedArray]) def engine(request): return request.param _col = [1, 2, 3, 4, 5] @pytest.fixture(params=[ _col, u.Quantity(_col), Time(_col, format='jyear'), ]) def main_col(request): return request.param def assert_col_equal(col, array): if isinstance(col, Time): assert np.all(col == Time(array, format='jyear')) else: assert np.all(col == col.__class__(array)) @pytest.mark.usefixtures('table_types') class TestIndex(SetupData): def _setup(self, main_col, table_types): super(TestIndex, self)._setup(table_types) self.main_col = main_col if isinstance(main_col, u.Quantity): self._table_type = QTable if not isinstance(main_col, list): self._column_type = lambda x: x # don't change mixin type self.mutable = isinstance(main_col, (list, u.Quantity)) def make_col(self, name, lst): return self._column_type(lst, name=name) def make_val(self, val): if isinstance(self.main_col, Time): return Time(val, format='jyear') return val @property def t(self): if not hasattr(self, '_t'): self._t = self._table_type() self._t['a'] = self._column_type(self.main_col) self._t['b'] = self._column_type([4.0, 5.1, 6.2, 7.0, 1.1]) self._t['c'] = self._column_type(['7', '8', '9', '10', '11']) return self._t @pytest.mark.parametrize("composite", [False, True]) def test_table_index(self, main_col, table_types, composite, engine): self._setup(main_col, table_types) t = self.t t.add_index(('a', 'b') if composite else 'a', engine=engine) assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) if not self.mutable: return # test altering table columns t['a'][0] = 4 t.add_row((6, 6.0, '7')) t['a'][3] = 10 t.remove_row(2) t.add_row((4, 5.0, '9')) assert_col_equal(t['a'], np.array([4, 2, 10, 5, 6, 4])) assert np.allclose(t['b'], np.array([4.0, 5.1, 7.0, 1.1, 6.0, 5.0])) assert np.all(t['c'].data == np.array(['7', '8', '10', '11', '7', '9'])) index = t.indices[0] l = list(index.data.items()) if composite: assert np.all(l == [((2, 5.1), [1]), ((4, 4.0), [0]), ((4, 5.0), [5]), ((5, 1.1), [3]), ((6, 6.0), [4]), ((10, 7.0), [2])]) else: assert np.all(l == [((2,), [1]), ((4,), [0, 5]), ((5,), [3]), ((6,), [4]), ((10,), [2])]) t.remove_indices('a') assert len(t.indices) == 0 def test_table_slicing(self, main_col, table_types, engine): self._setup(main_col, table_types) t = self.t t.add_index('a', engine=engine) assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) for slice_ in ([0, 2], np.array([0, 2])): t2 = t[slice_] # t2 should retain an index on column 'a' assert len(t2.indices) == 1 assert_col_equal(t2['a'], [1, 3]) # the index in t2 should reorder row numbers after slicing assert np.all(t2.indices[0].sorted_data() == [0, 1]) # however, this index should be a deep copy of t1's index assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) def test_remove_rows(self, main_col, table_types, engine): self._setup(main_col, table_types) if not self.mutable: return t = self.t t.add_index('a', engine=engine) # remove individual row t2 = t.copy() t2.remove_rows(2) assert_col_equal(t2['a'], [1, 2, 4, 5]) assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3]) # remove by list, ndarray, or slice for cut in ([0, 2, 4], np.array([0, 2, 4]), slice(0, 5, 2)): t2 = t.copy() t2.remove_rows(cut) assert_col_equal(t2['a'], [2, 4]) assert np.all(t2.indices[0].sorted_data() == [0, 1]) with pytest.raises(ValueError): t.remove_rows((0, 2, 4)) def test_col_get_slice(self, main_col, table_types, engine): self._setup(main_col, table_types) t = self.t t.add_index('a', engine=engine) # get slice t2 = t[1:3] # table slice assert_col_equal(t2['a'], [2, 3]) assert np.all(t2.indices[0].sorted_data() == [0, 1]) col_slice = t['a'][1:3] assert_col_equal(col_slice, [2, 3]) # true column slices discard indices if isinstance(t['a'], BaseColumn): assert len(col_slice.info.indices) == 0 # take slice of slice t2 = t[::2] assert_col_equal(t2['a'], np.array([1, 3, 5])) t3 = t2[::-1] assert_col_equal(t3['a'], np.array([5, 3, 1])) assert np.all(t3.indices[0].sorted_data() == [2, 1, 0]) t3 = t2[:2] assert_col_equal(t3['a'], np.array([1, 3])) assert np.all(t3.indices[0].sorted_data() == [0, 1]) # out-of-bound slices for t_empty in (t2[3:], t2[2:1], t3[2:]): assert len(t_empty['a']) == 0 assert np.all(t_empty.indices[0].sorted_data() == []) if self.mutable: # get boolean mask mask = t['a'] % 2 == 1 t2 = t[mask] assert_col_equal(t2['a'], [1, 3, 5]) assert np.all(t2.indices[0].sorted_data() == [0, 1, 2]) def test_col_set_slice(self, main_col, table_types, engine): self._setup(main_col, table_types) if not self.mutable: return t = self.t t.add_index('a', engine=engine) # set slice t2 = t.copy() t2['a'][1:3] = np.array([6, 7]) assert_col_equal(t2['a'], np.array([1, 6, 7, 4, 5])) assert np.all(t2.indices[0].sorted_data() == [0, 3, 4, 1, 2]) # change original table via slice reference t2 = t.copy() t3 = t2[1:3] assert_col_equal(t3['a'], np.array([2, 3])) assert np.all(t3.indices[0].sorted_data() == [0, 1]) t3['a'][0] = 5 assert_col_equal(t3['a'], np.array([5, 3])) assert_col_equal(t2['a'], np.array([1, 5, 3, 4, 5])) assert np.all(t3.indices[0].sorted_data() == [1, 0]) assert np.all(t2.indices[0].sorted_data() == [0, 2, 3, 1, 4]) # set boolean mask t2 = t.copy() mask = t['a'] % 2 == 1 t2['a'][mask] = 0. assert_col_equal(t2['a'], [0, 2, 0, 4, 0]) assert np.all(t2.indices[0].sorted_data() == [0, 2, 4, 1, 3]) def test_multiple_slices(self, main_col, table_types, engine): self._setup(main_col, table_types) if not self.mutable: return t = self.t t.add_index('a', engine=engine) for i in range(6, 51): t.add_row((i, 1.0, 'A')) assert_col_equal(t['a'], [i for i in range(1, 51)]) assert np.all(t.indices[0].sorted_data() == [i for i in range(50)]) evens = t[::2] assert np.all(evens.indices[0].sorted_data() == [i for i in range(25)]) reverse = evens[::-1] index = reverse.indices[0] assert (index.start, index.stop, index.step) == (48, -2, -2) assert np.all(index.sorted_data() == [i for i in range(24, -1, -1)]) # modify slice of slice reverse[-10:] = 0 expected = np.array([i for i in range(1, 51)]) expected[:20][expected[:20] % 2 == 1] = 0 assert_col_equal(t['a'], expected) assert_col_equal(evens['a'], expected[::2]) assert_col_equal(reverse['a'], expected[::2][::-1]) # first ten evens are now zero assert np.all(t.indices[0].sorted_data() == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19] + [i for i in range(20, 50)]) assert np.all(evens.indices[0].sorted_data() == [i for i in range(25)]) assert np.all(reverse.indices[0].sorted_data() == [i for i in range(24, -1, -1)]) # try different step sizes of slice t2 = t[1:20:2] assert_col_equal(t2['a'], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) assert np.all(t2.indices[0].sorted_data() == [i for i in range(10)]) t3 = t2[::3] assert_col_equal(t3['a'], [2, 8, 14, 20]) assert np.all(t3.indices[0].sorted_data() == [0, 1, 2, 3]) t4 = t3[2::-1] assert_col_equal(t4['a'], [14, 8, 2]) assert np.all(t4.indices[0].sorted_data() == [2, 1, 0]) def test_sort(self, main_col, table_types, engine): self._setup(main_col, table_types) t = self.t[::-1] # reverse table assert_col_equal(t['a'], [5, 4, 3, 2, 1]) t.add_index('a', engine=engine) assert np.all(t.indices[0].sorted_data() == [4, 3, 2, 1, 0]) if not self.mutable: return # sort table by column a t2 = t.copy() t2.sort('a') assert_col_equal(t2['a'], [1, 2, 3, 4, 5]) assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) # sort table by primary key t2 = t.copy() t2.sort() assert_col_equal(t2['a'], [1, 2, 3, 4, 5]) assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) def test_insert_row(self, main_col, table_types, engine): self._setup(main_col, table_types) if not self.mutable: return t = self.t t.add_index('a', engine=engine) t.insert_row(2, (6, 1.0, '12')) assert_col_equal(t['a'], [1, 2, 6, 3, 4, 5]) assert np.all(t.indices[0].sorted_data() == [0, 1, 3, 4, 5, 2]) t.insert_row(1, (0, 4.0, '13')) assert_col_equal(t['a'], [1, 0, 2, 6, 3, 4, 5]) assert np.all(t.indices[0].sorted_data() == [1, 0, 2, 4, 5, 6, 3]) def test_index_modes(self, main_col, table_types, engine): self._setup(main_col, table_types) t = self.t t.add_index('a', engine=engine) # first, no special mode assert len(t[[1, 3]].indices) == 1 assert len(t[::-1].indices) == 1 assert len(self._table_type(t).indices) == 1 assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) t2 = t.copy() # non-copy mode with t.index_mode('discard_on_copy'): assert len(t[[1, 3]].indices) == 0 assert len(t[::-1].indices) == 0 assert len(self._table_type(t).indices) == 0 assert len(t2.copy().indices) == 1 # mode should only affect t # make sure non-copy mode is exited correctly assert len(t[[1, 3]].indices) == 1 if not self.mutable: return # non-modify mode with t.index_mode('freeze'): assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) t['a'][0] = 6 assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) t.add_row((2, 1.5, '12')) assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) t.remove_rows([1, 3]) assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) assert_col_equal(t['a'], [6, 3, 5, 2]) # mode should only affect t assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) t2['a'][0] = 6 assert np.all(t2.indices[0].sorted_data() == [1, 2, 3, 4, 0]) # make sure non-modify mode is exited correctly assert np.all(t.indices[0].sorted_data() == [3, 1, 2, 0]) if isinstance(t['a'], BaseColumn): assert len(t['a'][::-1].info.indices) == 0 with t.index_mode('copy_on_getitem'): assert len(t['a'][[1, 2]].info.indices) == 1 # mode should only affect t assert len(t2['a'][[1, 2]].info.indices) == 0 assert len(t['a'][::-1].info.indices) == 0 assert len(t2['a'][::-1].info.indices) == 0 def test_index_retrieval(self, main_col, table_types, engine): self._setup(main_col, table_types) t = self.t t.add_index('a', engine=engine) t.add_index(['a', 'c'], engine=engine) assert len(t.indices) == 2 assert len(t.indices['a'].columns) == 1 assert len(t.indices['a', 'c'].columns) == 2 with pytest.raises(IndexError): t.indices['b'] def test_col_rename(self, main_col, table_types, engine): ''' Checks for a previous bug in which copying a Table with different column names raised an exception. ''' self._setup(main_col, table_types) t = self.t t.add_index('a', engine=engine) t2 = self._table_type(self.t, names=['d', 'e', 'f']) assert len(t2.indices) == 1 def test_table_loc(self, main_col, table_types, engine): self._setup(main_col, table_types) t = self.t t.add_index('a', engine=engine) t.add_index('b', engine=engine) t2 = t.loc[self.make_val(3)] # single label, with primary key 'a' assert_col_equal(t2['a'], [3]) assert isinstance(t2, Row) # list search t2 = t.loc[[self.make_val(1), self.make_val(4), self.make_val(2)]] assert_col_equal(t2['a'], [1, 4, 2]) # same order as input list if not isinstance(main_col, Time): # ndarray search t2 = t.loc[np.array([1, 4, 2])] assert_col_equal(t2['a'], [1, 4, 2]) assert_col_equal(t2['a'], [1, 4, 2]) t2 = t.loc[self.make_val(3): self.make_val(5)] # range search assert_col_equal(t2['a'], [3, 4, 5]) t2 = t.loc['b', 5.0:7.0] assert_col_equal(t2['b'], [5.1, 6.2, 7.0]) # search by sorted index t2 = t.iloc[0:2] # two smallest rows by column 'a' assert_col_equal(t2['a'], [1, 2]) t2 = t.iloc['b', 2:] # exclude two smallest rows in column 'b' assert_col_equal(t2['b'], [5.1, 6.2, 7.0]) for t2 in (t.loc[:], t.iloc[:]): assert_col_equal(t2['a'], [1, 2, 3, 4, 5]) def test_invalid_search(self, main_col, table_types, engine): # using .loc with a value not present should raise an exception self._setup(main_col, table_types) t = self.t t.add_index('a') with pytest.raises(KeyError): t.loc[self.make_val(6)] def test_copy_index_references(self, main_col, table_types, engine): # check against a bug in which indices were given an incorrect # column reference when copied self._setup(main_col, table_types) t = self.t t.add_index('a') t.add_index('b') t2 = t.copy() assert t2.indices['a'].columns[0] is t2['a'] assert t2.indices['b'].columns[0] is t2['b'] def test_unique_index(self, main_col, table_types, engine): self._setup(main_col, table_types) t = self.t t.add_index('a', engine=engine, unique=True) assert np.all(t.indices['a'].sorted_data() == [0, 1, 2, 3, 4]) if self.mutable: with pytest.raises(ValueError): t.add_row((5, 5.0, '9')) def test_copy_indexed_table(self, table_types): self._setup(_col, table_types) t = self.t t.add_index('a') t.add_index(['a', 'b']) for tp in (self._table_type(t), t.copy()): assert len(t.indices) == len(tp.indices) for index, indexp in zip(t.indices, tp.indices): assert np.all(index.data.data == indexp.data.data) assert index.data.data.colnames == indexp.data.data.colnames
bsd-3-clause
[ 3, 3909, 1334, 282, 650, 13, 8501, 6289, 3449, 4190, 446, 1937, 5113, 14, 8332, 199, 199, 646, 4613, 199, 646, 2680, 465, 980, 199, 199, 504, 1275, 396, 63, 1224, 492, 12439, 1451, 199, 504, 2508, 66, 270, 492, 699, 840, 12, 22613, 16567, 52, 199, 504, 2508, 5917, 63, 1144, 492, 27432, 3836, 199, 504, 2508, 1224, 492, 1413, 3186, 12, 15231, 199, 504, 2263, 492, 6204, 465, 399, 199, 504, 2263, 521, 492, 4703, 199, 504, 2508, 2301, 492, 3523, 4547, 199, 504, 2263, 18587, 14, 4174, 14, 4912, 492, 1425, 199, 199, 32, 4462, 14, 5997, 8, 1162, 1524, 34, 840, 12, 22613, 16567, 52, 12, 27432, 3836, 566, 199, 318, 6869, 8, 1069, 304, 272, 372, 1056, 14, 635, 199, 199, 63, 761, 275, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 61, 199, 199, 32, 4462, 14, 5997, 8, 1162, 1524, 272, 485, 761, 12, 272, 399, 14, 19703, 1547, 761, 395, 272, 4703, 1547, 761, 12, 1475, 534, 74, 3403, 659, 199, 566, 199, 318, 2446, 63, 761, 8, 1069, 304, 272, 372, 1056, 14, 635, 199, 199, 318, 702, 63, 761, 63, 1452, 8, 761, 12, 1625, 304, 272, 340, 1228, 8, 761, 12, 4703, 304, 267, 702, 980, 14, 452, 8, 761, 508, 4703, 8, 1144, 12, 1475, 534, 74, 3403, 1333, 272, 587, 26, 267, 702, 980, 14, 452, 8, 761, 508, 1048, 855, 533, 721, 1144, 430, 199, 199, 32, 4462, 14, 1657, 14, 1180, 8769, 360, 1224, 63, 1313, 358, 199, 533, 1379, 2681, 8, 8555, 1451, 304, 272, 347, 485, 2758, 8, 277, 12, 2446, 63, 761, 12, 1817, 63, 1313, 304, 267, 1613, 8, 774, 2681, 12, 291, 10445, 2758, 8, 1224, 63, 1313, 9, 267, 291, 14, 973, 63, 761, 275, 2446, 63, 761, 267, 340, 1228, 8, 973, 63, 761, 12, 399, 14, 19703, 304, 288, 291, 423, 1224, 63, 466, 275, 1413, 3186, 267, 340, 440, 1228, 8, 973, 63, 761, 12, 769, 304, 288, 291, 423, 2301, 63, 466, 275, 2400, 671, 26, 671, 327, 2793, 1133, 1570, 20048, 730, 267, 291, 14, 17404, 275, 1228, 8, 973, 63, 761, 12, 334, 513, 12, 399, 14, 19703, 430, 339, 347, 1852, 63, 761, 8, 277, 12, 536, 12, 9877, 304, 267, 372, 291, 423, 2301, 63, 466, 8, 6916, 12, 536, 29, 354, 9, 339, 347, 1852, 63, 637, 8, 277, 12, 1139, 304, 267, 340, 1228, 8, 277, 14, 973, 63, 761, 12, 4703, 304, 288, 372, 4703, 8, 637, 12, 1475, 534, 74, 3403, 358, 267, 372, 1139, 339, 768, 1829, 272, 347, 307, 8, 277, 304, 267, 340, 440, 2688, 8, 277, 12, 2513, 84, 735, 288, 291, 423, 84, 275, 291, 423, 1224, 63, 466, 342, 288, 291, 423, 84, 459, 65, 418, 275, 291, 423, 2301, 63, 466, 8, 277, 14, 973, 63, 761, 9, 288, 291, 423, 84, 459, 66, 418, 275, 291, 423, 2301, 63, 466, 779, 20, 14, 16, 12, 959, 14, 17, 12, 1227, 14, 18, 12, 1520, 14, 16, 12, 413, 14, 17, 566, 288, 291, 423, 84, 459, 67, 418, 275, 291, 423, 2301, 63, 466, 2941, 23, 297, 283, 24, 297, 283, 25, 297, 283, 709, 297, 283, 845, 1105, 267, 372, 291, 423, 84, 339, 768, 4462, 14, 1657, 14, 10396, 480, 16907, 401, 359, 797, 12, 715, 566, 272, 347, 511, 63, 1224, 63, 1080, 8, 277, 12, 2446, 63, 761, 12, 1817, 63, 1313, 12, 19306, 12, 6869, 304, 267, 291, 423, 2758, 8, 973, 63, 761, 12, 1817, 63, 1313, 9, 267, 307, 275, 291, 14, 84, 267, 307, 14, 525, 63, 1080, 4725, 65, 297, 283, 66, 358, 340, 19306, 587, 283, 65, 297, 6869, 29, 3908, 9, 267, 702, 980, 14, 452, 8, 84, 14, 4108, 59, 16, 1055, 5917, 63, 576, 342, 508, 359, 16, 12, 413, 12, 499, 12, 650, 12, 841, 566, 398, 340, 440, 291, 14, 17404, 26, 288, 372, 398, 327, 511, 17355, 316, 1817, 4362, 267, 307, 459, 65, 3488, 16, 61, 275, 841, 267, 307, 14, 525, 63, 1143, 1332, 22, 12, 1227, 14, 16, 12, 283, 23, 1333, 267, 307, 459, 65, 3488, 19, 61, 275, 1616, 267, 307, 14, 2168, 63, 1143, 8, 18, 9, 267, 307, 14, 525, 63, 1143, 1332, 20, 12, 959, 14, 16, 12, 283, 25, 1333, 398, 702, 63, 761, 63, 1452, 8, 84, 459, 65, 995, 980, 14, 1144, 779, 20, 12, 499, 12, 1616, 12, 959, 12, 1227, 12, 841, 2459, 267, 702, 980, 14, 7520, 8, 84, 459, 66, 995, 980, 14, 1144, 779, 20, 14, 16, 12, 959, 14, 17, 12, 1520, 14, 16, 12, 413, 14, 17, 12, 1227, 14, 16, 12, 959, 14, 16, 2459, 267, 702, 980, 14, 452, 8, 84, 459, 67, 2278, 576, 508, 980, 14, 1144, 2941, 23, 297, 283, 24, 297, 283, 709, 297, 283, 845, 297, 283, 23, 297, 283, 25, 5156, 267, 1478, 275, 307, 14, 4108, 59, 16, 61, 267, 634, 275, 769, 8, 1080, 14, 576, 14, 1744, 1012, 398, 340, 19306, 26, 288, 702, 980, 14, 452, 8, 76, 508, 359, 1332, 18, 12, 959, 14, 17, 395, 359, 17, 2522, 1816, 3666, 20, 12, 841, 14, 16, 395, 359, 16, 2522, 1816, 3666, 20, 12, 959, 14, 16, 395, 359, 21, 2522, 1816, 3666, 21, 12, 413, 14, 17, 395, 359, 19, 2522, 1816, 3666, 22, 12, 1227, 14, 16, 395, 359, 20, 2522, 1816, 3666, 709, 12, 1520, 14, 16, 395, 359, 18, 24310, 267, 587, 26, 288, 702, 980, 14, 452, 8, 76, 508, 359, 1332, 18, 4706, 359, 17, 2522, 1816, 3666, 20, 4706, 359, 16, 12, 959, 2522, 1816, 3666, 21, 4706, 359, 19, 2522, 1816, 3666, 22, 4706, 359, 20, 2522, 1816, 3666, 709, 4706, 359, 18, 24310, 267, 307, 14, 2168, 63, 4108, 360, 65, 358, 267, 702, 822, 8, 84, 14, 4108, 9, 508, 378, 339, 347, 511, 63, 1224, 63, 83, 17463, 8, 277, 12, 2446, 63, 761, 12, 1817, 63, 1313, 12, 6869, 304, 267, 291, 423, 2758, 8, 973, 63, 761, 12, 1817, 63, 1313 ]
[ 3909, 1334, 282, 650, 13, 8501, 6289, 3449, 4190, 446, 1937, 5113, 14, 8332, 199, 199, 646, 4613, 199, 646, 2680, 465, 980, 199, 199, 504, 1275, 396, 63, 1224, 492, 12439, 1451, 199, 504, 2508, 66, 270, 492, 699, 840, 12, 22613, 16567, 52, 199, 504, 2508, 5917, 63, 1144, 492, 27432, 3836, 199, 504, 2508, 1224, 492, 1413, 3186, 12, 15231, 199, 504, 2263, 492, 6204, 465, 399, 199, 504, 2263, 521, 492, 4703, 199, 504, 2508, 2301, 492, 3523, 4547, 199, 504, 2263, 18587, 14, 4174, 14, 4912, 492, 1425, 199, 199, 32, 4462, 14, 5997, 8, 1162, 1524, 34, 840, 12, 22613, 16567, 52, 12, 27432, 3836, 566, 199, 318, 6869, 8, 1069, 304, 272, 372, 1056, 14, 635, 199, 199, 63, 761, 275, 359, 17, 12, 499, 12, 650, 12, 841, 12, 959, 61, 199, 199, 32, 4462, 14, 5997, 8, 1162, 1524, 272, 485, 761, 12, 272, 399, 14, 19703, 1547, 761, 395, 272, 4703, 1547, 761, 12, 1475, 534, 74, 3403, 659, 199, 566, 199, 318, 2446, 63, 761, 8, 1069, 304, 272, 372, 1056, 14, 635, 199, 199, 318, 702, 63, 761, 63, 1452, 8, 761, 12, 1625, 304, 272, 340, 1228, 8, 761, 12, 4703, 304, 267, 702, 980, 14, 452, 8, 761, 508, 4703, 8, 1144, 12, 1475, 534, 74, 3403, 1333, 272, 587, 26, 267, 702, 980, 14, 452, 8, 761, 508, 1048, 855, 533, 721, 1144, 430, 199, 199, 32, 4462, 14, 1657, 14, 1180, 8769, 360, 1224, 63, 1313, 358, 199, 533, 1379, 2681, 8, 8555, 1451, 304, 272, 347, 485, 2758, 8, 277, 12, 2446, 63, 761, 12, 1817, 63, 1313, 304, 267, 1613, 8, 774, 2681, 12, 291, 10445, 2758, 8, 1224, 63, 1313, 9, 267, 291, 14, 973, 63, 761, 275, 2446, 63, 761, 267, 340, 1228, 8, 973, 63, 761, 12, 399, 14, 19703, 304, 288, 291, 423, 1224, 63, 466, 275, 1413, 3186, 267, 340, 440, 1228, 8, 973, 63, 761, 12, 769, 304, 288, 291, 423, 2301, 63, 466, 275, 2400, 671, 26, 671, 327, 2793, 1133, 1570, 20048, 730, 267, 291, 14, 17404, 275, 1228, 8, 973, 63, 761, 12, 334, 513, 12, 399, 14, 19703, 430, 339, 347, 1852, 63, 761, 8, 277, 12, 536, 12, 9877, 304, 267, 372, 291, 423, 2301, 63, 466, 8, 6916, 12, 536, 29, 354, 9, 339, 347, 1852, 63, 637, 8, 277, 12, 1139, 304, 267, 340, 1228, 8, 277, 14, 973, 63, 761, 12, 4703, 304, 288, 372, 4703, 8, 637, 12, 1475, 534, 74, 3403, 358, 267, 372, 1139, 339, 768, 1829, 272, 347, 307, 8, 277, 304, 267, 340, 440, 2688, 8, 277, 12, 2513, 84, 735, 288, 291, 423, 84, 275, 291, 423, 1224, 63, 466, 342, 288, 291, 423, 84, 459, 65, 418, 275, 291, 423, 2301, 63, 466, 8, 277, 14, 973, 63, 761, 9, 288, 291, 423, 84, 459, 66, 418, 275, 291, 423, 2301, 63, 466, 779, 20, 14, 16, 12, 959, 14, 17, 12, 1227, 14, 18, 12, 1520, 14, 16, 12, 413, 14, 17, 566, 288, 291, 423, 84, 459, 67, 418, 275, 291, 423, 2301, 63, 466, 2941, 23, 297, 283, 24, 297, 283, 25, 297, 283, 709, 297, 283, 845, 1105, 267, 372, 291, 423, 84, 339, 768, 4462, 14, 1657, 14, 10396, 480, 16907, 401, 359, 797, 12, 715, 566, 272, 347, 511, 63, 1224, 63, 1080, 8, 277, 12, 2446, 63, 761, 12, 1817, 63, 1313, 12, 19306, 12, 6869, 304, 267, 291, 423, 2758, 8, 973, 63, 761, 12, 1817, 63, 1313, 9, 267, 307, 275, 291, 14, 84, 267, 307, 14, 525, 63, 1080, 4725, 65, 297, 283, 66, 358, 340, 19306, 587, 283, 65, 297, 6869, 29, 3908, 9, 267, 702, 980, 14, 452, 8, 84, 14, 4108, 59, 16, 1055, 5917, 63, 576, 342, 508, 359, 16, 12, 413, 12, 499, 12, 650, 12, 841, 566, 398, 340, 440, 291, 14, 17404, 26, 288, 372, 398, 327, 511, 17355, 316, 1817, 4362, 267, 307, 459, 65, 3488, 16, 61, 275, 841, 267, 307, 14, 525, 63, 1143, 1332, 22, 12, 1227, 14, 16, 12, 283, 23, 1333, 267, 307, 459, 65, 3488, 19, 61, 275, 1616, 267, 307, 14, 2168, 63, 1143, 8, 18, 9, 267, 307, 14, 525, 63, 1143, 1332, 20, 12, 959, 14, 16, 12, 283, 25, 1333, 398, 702, 63, 761, 63, 1452, 8, 84, 459, 65, 995, 980, 14, 1144, 779, 20, 12, 499, 12, 1616, 12, 959, 12, 1227, 12, 841, 2459, 267, 702, 980, 14, 7520, 8, 84, 459, 66, 995, 980, 14, 1144, 779, 20, 14, 16, 12, 959, 14, 17, 12, 1520, 14, 16, 12, 413, 14, 17, 12, 1227, 14, 16, 12, 959, 14, 16, 2459, 267, 702, 980, 14, 452, 8, 84, 459, 67, 2278, 576, 508, 980, 14, 1144, 2941, 23, 297, 283, 24, 297, 283, 709, 297, 283, 845, 297, 283, 23, 297, 283, 25, 5156, 267, 1478, 275, 307, 14, 4108, 59, 16, 61, 267, 634, 275, 769, 8, 1080, 14, 576, 14, 1744, 1012, 398, 340, 19306, 26, 288, 702, 980, 14, 452, 8, 76, 508, 359, 1332, 18, 12, 959, 14, 17, 395, 359, 17, 2522, 1816, 3666, 20, 12, 841, 14, 16, 395, 359, 16, 2522, 1816, 3666, 20, 12, 959, 14, 16, 395, 359, 21, 2522, 1816, 3666, 21, 12, 413, 14, 17, 395, 359, 19, 2522, 1816, 3666, 22, 12, 1227, 14, 16, 395, 359, 20, 2522, 1816, 3666, 709, 12, 1520, 14, 16, 395, 359, 18, 24310, 267, 587, 26, 288, 702, 980, 14, 452, 8, 76, 508, 359, 1332, 18, 4706, 359, 17, 2522, 1816, 3666, 20, 4706, 359, 16, 12, 959, 2522, 1816, 3666, 21, 4706, 359, 19, 2522, 1816, 3666, 22, 4706, 359, 20, 2522, 1816, 3666, 709, 4706, 359, 18, 24310, 267, 307, 14, 2168, 63, 4108, 360, 65, 358, 267, 702, 822, 8, 84, 14, 4108, 9, 508, 378, 339, 347, 511, 63, 1224, 63, 83, 17463, 8, 277, 12, 2446, 63, 761, 12, 1817, 63, 1313, 12, 6869, 304, 267, 291, 423, 2758, 8, 973, 63, 761, 12, 1817, 63, 1313, 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,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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 ]
lzambella/Qyoutube-dl
youtube_dl/extractor/npo.py
19
18401
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( fix_xml_ampersands, parse_duration, qualities, strip_jsonp, unified_strdate, ) class NPOBaseIE(InfoExtractor): def _get_token(self, video_id): token_page = self._download_webpage( 'http://ida.omroep.nl/npoplayer/i.js', video_id, note='Downloading token') token = self._search_regex( r'npoplayer\.token = "(.+?)"', token_page, 'token') # Decryption algorithm extracted from http://npoplayer.omroep.nl/csjs/npoplayer-min.js token_l = list(token) first = second = None for i in range(5, len(token_l) - 4): if token_l[i].isdigit(): if first is None: first = i elif second is None: second = i if first is None or second is None: first = 12 second = 13 token_l[first], token_l[second] = token_l[second], token_l[first] return ''.join(token_l) class NPOIE(NPOBaseIE): IE_NAME = 'npo' IE_DESC = 'npo.nl and ntr.nl' _VALID_URL = r'''(?x) (?: npo:| https?:// (?:www\.)? (?: npo\.nl/(?!live|radio)(?:[^/]+/){2}| ntr\.nl/(?:[^/]+/){2,}| omroepwnl\.nl/video/fragment/[^/]+__ ) ) (?P<id>[^/?#]+) ''' _TESTS = [ { 'url': 'http://www.npo.nl/nieuwsuur/22-06-2014/VPWON_1220719', 'md5': '4b3f9c429157ec4775f2c9cb7b911016', 'info_dict': { 'id': 'VPWON_1220719', 'ext': 'm4v', 'title': 'Nieuwsuur', 'description': 'Dagelijks tussen tien en elf: nieuws, sport en achtergronden.', 'upload_date': '20140622', }, }, { 'url': 'http://www.npo.nl/de-mega-mike-mega-thomas-show/27-02-2009/VARA_101191800', 'md5': 'da50a5787dbfc1603c4ad80f31c5120b', 'info_dict': { 'id': 'VARA_101191800', 'ext': 'm4v', 'title': 'De Mega Mike & Mega Thomas show: The best of.', 'description': 'md5:3b74c97fc9d6901d5a665aac0e5400f4', 'upload_date': '20090227', 'duration': 2400, }, }, { 'url': 'http://www.npo.nl/tegenlicht/25-02-2013/VPWON_1169289', 'md5': 'f8065e4e5a7824068ed3c7e783178f2c', 'info_dict': { 'id': 'VPWON_1169289', 'ext': 'm4v', 'title': 'Tegenlicht: De toekomst komt uit Afrika', 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea', 'upload_date': '20130225', 'duration': 3000, }, }, { 'url': 'http://www.npo.nl/de-nieuwe-mens-deel-1/21-07-2010/WO_VPRO_043706', 'info_dict': { 'id': 'WO_VPRO_043706', 'ext': 'wmv', 'title': 'De nieuwe mens - Deel 1', 'description': 'md5:518ae51ba1293ffb80d8d8ce90b74e4b', 'duration': 4680, }, 'params': { # mplayer mms download 'skip_download': True, } }, # non asf in streams { 'url': 'http://www.npo.nl/hoe-gaat-europa-verder-na-parijs/10-01-2015/WO_NOS_762771', 'md5': 'b3da13de374cbe2d5332a7e910bef97f', 'info_dict': { 'id': 'WO_NOS_762771', 'ext': 'mp4', 'title': 'Hoe gaat Europa verder na Parijs?', }, }, { 'url': 'http://www.ntr.nl/Aap-Poot-Pies/27/detail/Aap-poot-pies/VPWON_1233944#content', 'md5': '01c6a2841675995da1f0cf776f03a9c3', 'info_dict': { 'id': 'VPWON_1233944', 'ext': 'm4v', 'title': 'Aap, poot, pies', 'description': 'md5:c9c8005d1869ae65b858e82c01a91fde', 'upload_date': '20150508', 'duration': 599, }, }, { 'url': 'http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698', 'md5': 'd30cd8417b8b9bca1fdff27428860d08', 'info_dict': { 'id': 'POW_00996502', 'ext': 'm4v', 'title': '''"Dit is wel een 'landslide'..."''', 'description': 'md5:f8d66d537dfb641380226e31ca57b8e8', 'upload_date': '20150508', 'duration': 462, }, } ] def _real_extract(self, url): video_id = self._match_id(url) return self._get_info(video_id) def _get_info(self, video_id): metadata = self._download_json( 'http://e.omroep.nl/metadata/%s' % video_id, video_id, # We have to remove the javascript callback transform_source=strip_jsonp, ) # For some videos actual video id (prid) is different (e.g. for # http://www.omroepwnl.nl/video/fragment/vandaag-de-dag-verkiezingen__POMS_WNL_853698 # video id is POMS_WNL_853698 but prid is POW_00996502) video_id = metadata.get('prid') or video_id # titel is too generic in some cases so utilize aflevering_titel as well # when available (e.g. http://tegenlicht.vpro.nl/afleveringen/2014-2015/access-to-africa.html) title = metadata['titel'] sub_title = metadata.get('aflevering_titel') if sub_title and sub_title != title: title += ': %s' % sub_title token = self._get_token(video_id) formats = [] pubopties = metadata.get('pubopties') if pubopties: quality = qualities(['adaptive', 'wmv_sb', 'h264_sb', 'wmv_bb', 'h264_bb', 'wvc1_std', 'h264_std']) for format_id in pubopties: format_info = self._download_json( 'http://ida.omroep.nl/odi/?prid=%s&puboptions=%s&adaptive=yes&token=%s' % (video_id, format_id, token), video_id, 'Downloading %s JSON' % format_id) if format_info.get('error_code', 0) or format_info.get('errorcode', 0): continue streams = format_info.get('streams') if streams: video_info = self._download_json( streams[0] + '&type=json', video_id, 'Downloading %s stream JSON' % format_id) else: video_info = format_info video_url = video_info.get('url') if not video_url: continue if format_id == 'adaptive': formats.extend(self._extract_m3u8_formats(video_url, video_id, 'mp4')) else: formats.append({ 'url': video_url, 'format_id': format_id, 'quality': quality(format_id), }) streams = metadata.get('streams') if streams: for i, stream in enumerate(streams): stream_url = stream.get('url') if not stream_url: continue if '.asf' not in stream_url: formats.append({ 'url': stream_url, 'quality': stream.get('kwaliteit'), }) continue asx = self._download_xml( stream_url, video_id, 'Downloading stream %d ASX playlist' % i, transform_source=fix_xml_ampersands) ref = asx.find('./ENTRY/Ref') if ref is None: continue video_url = ref.get('href') if not video_url: continue formats.append({ 'url': video_url, 'ext': stream.get('formaat', 'asf'), 'quality': stream.get('kwaliteit'), }) self._sort_formats(formats) subtitles = {} if metadata.get('tt888') == 'ja': subtitles['nl'] = [{ 'ext': 'vtt', 'url': 'http://e.omroep.nl/tt888/%s' % video_id, }] return { 'id': video_id, 'title': title, 'description': metadata.get('info'), 'thumbnail': metadata.get('images', [{'url': None}])[-1]['url'], 'upload_date': unified_strdate(metadata.get('gidsdatum')), 'duration': parse_duration(metadata.get('tijdsduur')), 'formats': formats, 'subtitles': subtitles, } class NPOLiveIE(NPOBaseIE): IE_NAME = 'npo.nl:live' _VALID_URL = r'https?://(?:www\.)?npo\.nl/live/(?P<id>.+)' _TEST = { 'url': 'http://www.npo.nl/live/npo-1', 'info_dict': { 'id': 'LI_NEDERLAND1_136692', 'display_id': 'npo-1', 'ext': 'mp4', 'title': 're:^Nederland 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', 'description': 'Livestream', 'is_live': True, }, 'params': { 'skip_download': True, } } def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) live_id = self._search_regex( r'data-prid="([^"]+)"', webpage, 'live id') metadata = self._download_json( 'http://e.omroep.nl/metadata/%s' % live_id, display_id, transform_source=strip_jsonp) token = self._get_token(display_id) formats = [] streams = metadata.get('streams') if streams: for stream in streams: stream_type = stream.get('type').lower() # smooth streaming is not supported if stream_type in ['ss', 'ms']: continue stream_info = self._download_json( 'http://ida.omroep.nl/aapi/?stream=%s&token=%s&type=jsonp' % (stream.get('url'), token), display_id, 'Downloading %s JSON' % stream_type) if stream_info.get('error_code', 0) or stream_info.get('errorcode', 0): continue stream_url = self._download_json( stream_info['stream'], display_id, 'Downloading %s URL' % stream_type, 'Unable to download %s URL' % stream_type, transform_source=strip_jsonp, fatal=False) if not stream_url: continue if stream_type == 'hds': f4m_formats = self._extract_f4m_formats(stream_url, display_id) # f4m downloader downloads only piece of live stream for f4m_format in f4m_formats: f4m_format['preference'] = -1 formats.extend(f4m_formats) elif stream_type == 'hls': formats.extend(self._extract_m3u8_formats(stream_url, display_id, 'mp4')) else: formats.append({ 'url': stream_url, 'preference': -10, }) self._sort_formats(formats) return { 'id': live_id, 'display_id': display_id, 'title': self._live_title(metadata['titel']), 'description': metadata['info'], 'thumbnail': metadata.get('images', [{'url': None}])[-1]['url'], 'formats': formats, 'is_live': True, } class NPORadioIE(InfoExtractor): IE_NAME = 'npo.nl:radio' _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/(?P<id>[^/]+)/?$' _TEST = { 'url': 'http://www.npo.nl/radio/radio-1', 'info_dict': { 'id': 'radio-1', 'ext': 'mp3', 'title': 're:^NPO Radio 1 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$', 'is_live': True, }, 'params': { 'skip_download': True, } } @staticmethod def _html_get_attribute_regex(attribute): return r'{0}\s*=\s*\'([^\']+)\''.format(attribute) def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) title = self._html_search_regex( self._html_get_attribute_regex('data-channel'), webpage, 'title') stream = self._parse_json( self._html_search_regex(self._html_get_attribute_regex('data-streams'), webpage, 'data-streams'), video_id) codec = stream.get('codec') return { 'id': video_id, 'url': stream['url'], 'title': self._live_title(title), 'acodec': codec, 'ext': codec, 'is_live': True, } class NPORadioFragmentIE(InfoExtractor): IE_NAME = 'npo.nl:radio:fragment' _VALID_URL = r'https?://(?:www\.)?npo\.nl/radio/[^/]+/fragment/(?P<id>\d+)' _TEST = { 'url': 'http://www.npo.nl/radio/radio-5/fragment/174356', 'md5': 'dd8cc470dad764d0fdc70a9a1e2d18c2', 'info_dict': { 'id': '174356', 'ext': 'mp3', 'title': 'Jubileumconcert Willeke Alberti', }, } def _real_extract(self, url): audio_id = self._match_id(url) webpage = self._download_webpage(url, audio_id) title = self._html_search_regex( r'href="/radio/[^/]+/fragment/%s" title="([^"]+)"' % audio_id, webpage, 'title') audio_url = self._search_regex( r"data-streams='([^']+)'", webpage, 'audio url') return { 'id': audio_id, 'url': audio_url, 'title': title, } class SchoolTVIE(InfoExtractor): IE_NAME = 'schooltv' _VALID_URL = r'https?://(?:www\.)?schooltv\.nl/video/(?P<id>[^/?#&]+)' _TEST = { 'url': 'http://www.schooltv.nl/video/ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam/', 'info_dict': { 'id': 'WO_NTR_429477', 'display_id': 'ademhaling-de-hele-dag-haal-je-adem-maar-wat-gebeurt-er-dan-eigenlijk-in-je-lichaam', 'title': 'Ademhaling: De hele dag haal je adem. Maar wat gebeurt er dan eigenlijk in je lichaam?', 'ext': 'mp4', 'description': 'md5:abfa0ff690adb73fd0297fd033aaa631' }, 'params': { # Skip because of m3u8 download 'skip_download': True } } def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) video_id = self._search_regex( r'data-mid=(["\'])(?P<id>.+?)\1', webpage, 'video_id', group='id') return { '_type': 'url_transparent', 'ie_key': 'NPO', 'url': 'npo:%s' % video_id, 'display_id': display_id } class VPROIE(NPOIE): IE_NAME = 'vpro' _VALID_URL = r'https?://(?:www\.)?(?:tegenlicht\.)?vpro\.nl/(?:[^/]+/){2,}(?P<id>[^/]+)\.html' _TESTS = [ { 'url': 'http://tegenlicht.vpro.nl/afleveringen/2012-2013/de-toekomst-komt-uit-afrika.html', 'md5': 'f8065e4e5a7824068ed3c7e783178f2c', 'info_dict': { 'id': 'VPWON_1169289', 'ext': 'm4v', 'title': 'De toekomst komt uit Afrika', 'description': 'md5:52cf4eefbc96fffcbdc06d024147abea', 'upload_date': '20130225', }, }, { 'url': 'http://www.vpro.nl/programmas/2doc/2015/sergio-herman.html', 'info_dict': { 'id': 'sergio-herman', 'title': 'Sergio Herman: Fucking perfect', }, 'playlist_count': 2, }, { # playlist with youtube embed 'url': 'http://www.vpro.nl/programmas/2doc/2015/education-education.html', 'info_dict': { 'id': 'education-education', 'title': '2Doc', }, 'playlist_count': 2, } ] def _real_extract(self, url): playlist_id = self._match_id(url) webpage = self._download_webpage(url, playlist_id) entries = [ self.url_result('npo:%s' % video_id if not video_id.startswith('http') else video_id) for video_id in re.findall(r'data-media-id="([^"]+)"', webpage) ] playlist_title = self._search_regex( r'<title>\s*([^>]+?)\s*-\s*Teledoc\s*-\s*VPRO\s*</title>', webpage, 'playlist title', default=None) or self._og_search_title(webpage) return self.playlist_result(entries, playlist_id, playlist_title) class WNLIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?omroepwnl\.nl/video/detail/(?P<id>[^/]+)__\d+' _TEST = { 'url': 'http://www.omroepwnl.nl/video/detail/vandaag-de-dag-6-mei__060515', 'info_dict': { 'id': 'vandaag-de-dag-6-mei', 'title': 'Vandaag de Dag 6 mei', }, 'playlist_count': 4, } def _real_extract(self, url): playlist_id = self._match_id(url) webpage = self._download_webpage(url, playlist_id) entries = [ self.url_result('npo:%s' % video_id, 'NPO') for video_id, part in re.findall( r'<a[^>]+href="([^"]+)"[^>]+class="js-mid"[^>]*>(Deel \d+)', webpage) ] playlist_title = self._html_search_regex( r'(?s)<h1[^>]+class="subject"[^>]*>(.+?)</h1>', webpage, 'playlist title') return self.playlist_result(entries, playlist_id, playlist_title)
gpl-3.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 5325, 63, 1652, 63, 5282, 1192, 5915, 12, 272, 2198, 63, 5553, 12, 272, 6420, 12107, 12, 272, 6202, 63, 1001, 80, 12, 272, 25344, 63, 495, 602, 12, 199, 9, 421, 199, 533, 653, 1512, 1563, 4332, 8, 18283, 304, 272, 347, 485, 362, 63, 1418, 8, 277, 12, 3991, 63, 344, 304, 267, 1526, 63, 1606, 275, 291, 423, 4249, 63, 12022, 8, 288, 283, 1014, 921, 29132, 14, 676, 293, 1545, 14, 7530, 15, 1590, 411, 1897, 15, 73, 14, 3596, 297, 288, 3991, 63, 344, 12, 5317, 534, 18085, 1526, 358, 267, 1526, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7, 1590, 411, 1897, 4537, 1418, 275, 7340, 11198, 32691, 1526, 63, 1606, 12, 283, 1418, 358, 267, 327, 13966, 651, 494, 5563, 12509, 687, 1455, 921, 1590, 411, 1897, 14, 676, 293, 1545, 14, 7530, 15, 1259, 3596, 15, 1590, 411, 1897, 13, 827, 14, 3596, 267, 1526, 63, 76, 275, 769, 8, 1418, 9, 267, 1642, 275, 3499, 275, 488, 267, 367, 284, 315, 1425, 8, 21, 12, 822, 8, 1418, 63, 76, 9, 446, 841, 304, 288, 340, 1526, 63, 76, 59, 73, 1055, 13896, 837, 355, 340, 1642, 365, 488, 26, 490, 1642, 275, 284, 355, 916, 3499, 365, 488, 26, 490, 3499, 275, 284, 267, 340, 1642, 365, 488, 503, 3499, 365, 488, 26, 288, 1642, 275, 3144, 288, 3499, 275, 4944, 398, 1526, 63, 76, 59, 2246, 467, 1526, 63, 76, 59, 4375, 61, 275, 1526, 63, 76, 59, 4375, 467, 1526, 63, 76, 59, 2246, 61, 398, 372, 6522, 904, 8, 1418, 63, 76, 9, 421, 199, 533, 653, 1512, 4332, 8, 46, 1512, 1563, 4332, 304, 272, 15292, 63, 2339, 275, 283, 78, 555, 7, 272, 15292, 63, 15119, 275, 283, 78, 555, 14, 7530, 436, 302, 454, 14, 7530, 7, 272, 485, 5600, 63, 2632, 275, 519, 2344, 2229, 88, 9, 490, 16697, 717, 302, 555, 26, 92, 717, 4178, 14144, 1169, 16697, 1544, 20316, 1169, 16697, 1816, 302, 555, 4537, 7530, 9448, 1, 6442, 92, 11905, 9, 5169, 26285, 15, 11224, 18, 22441, 1816, 302, 454, 4537, 7530, 32576, 26285, 15, 11224, 18, 12, 22441, 1816, 312, 17335, 1545, 3501, 76, 4537, 7530, 15, 3722, 15, 7677, 15, 26285, 363, 1169, 776, 717, 776, 717, 7558, 48, 28, 344, 13489, 10197, 3, 11896, 355, 1449, 339, 485, 7569, 275, 359, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 78, 555, 14, 7530, 15, 78, 29364, 3569, 85, 300, 15, 1081, 13, 1690, 13, 7280, 15, 54, 10780, 615, 63, 713, 10744, 1167, 297, 288, 283, 1064, 21, 356, 283, 20, 66, 19, 70, 25, 67, 14372, 10823, 825, 20, 12710, 70, 18, 67, 25, 2894, 23, 66, 25, 845, 10882, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 54, 10780, 615, 63, 713, 10744, 1167, 297, 355, 283, 832, 356, 283, 77, 20, 86, 297, 355, 283, 1213, 356, 283, 46, 29364, 3569, 85, 300, 297, 355, 283, 1802, 356, 283, 36, 474, 317, 74, 6080, 307, 527, 2464, 3367, 287, 655, 325, 276, 26, 302, 29364, 3569, 12, 308, 719, 655, 282, 335, 351, 2587, 265, 848, 3130, 355, 283, 5064, 63, 602, 356, 283, 7280, 1690, 1081, 297, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 78, 555, 14, 7530, 15, 271, 13, 29073, 13, 2664, 415, 13, 29073, 13, 273, 676, 305, 13, 2384, 15, 1465, 13, 996, 13, 8664, 15, 5568, 33, 63, 4893, 1167, 1085, 383, 297, 288, 283, 1064, 21, 356, 283, 983, 1400, 65, 1641, 1555, 697, 3003, 975, 1644, 67, 20, 350, 1257, 70, 2192, 67, 21, 6708, 66, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 5568, 33, 63, 4893, 1167, 1085, 383, 297, 355, 283, 832, 356, 283, 77, 20, 86, 297, 355, 283, 1213, 356, 283, 872, 3194, 5294, 603, 7455, 1253, 3194, 5294, 27864, 2498, 26, 710, 5526, 402, 3130, 355, 283, 1802, 356, 283, 1064, 21, 26, 19, 66, 1342, 67, 2576, 3003, 25, 68, 1876, 614, 68, 21, 65, 16373, 27538, 16, 69, 1477, 383, 70, 20, 297, 355, 283, 5064, 63, 602, 356, 283, 8664, 996, 1465, 297, 355, 283, 5553, 356, 499, 5303, 12, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 78, 555, 14, 7530, 15, 266, 2268, 317, 335, 84, 15, 821, 13, 996, 13, 6965, 15, 54, 10780, 615, 63, 845, 1876, 20919, 297, 288, 283, 1064, 21, 356, 283, 70, 1257, 2182, 69, 20, 69, 21, 65, 2277, 1194, 19846, 379, 19, 67, 23, 69, 22585, 11175, 70, 18, 67, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 54, 10780, 615, 63, 845, 1876, 20919, 297, 355, 283, 832, 356, 283, 77, 20, 86, 297, 355, 283, 1213, 356, 283, 6301, 2268, 317, 335, 84, 26, 1487, 370, 5711, 676, 270, 1022, 676, 84, 399, 390, 437, 25876, 7351, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 2528, 2177, 20, 1024, 70, 3776, 2534, 18190, 2894, 3833, 1690, 68, 5284, 11160, 371, 4489, 297, 355, 283, 5064, 63, 602, 356, 283, 6965, 996, 821, 297, 355, 283, 5553, 356, 29664, 12, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 78, 555, 14, 7530, 15, 271, 13, 78, 29364, 1129, 13, 278, 561, 13, 271, 352, 13, 17, 15, 2025, 13, 1780, 13, 6542, 15, 11325, 63, 54, 2514, 63, 31013, 1690, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 11325, 63, 54, 2514, 63, 31013, 1690, 297, 355, 283, 832, 356, 283, 87, 12393, 297, 355, 283, 1213, 356, 283, 872, 302, 29364, 1129, 562, 561, 446, 1487, 352, 413, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 27015, 3624, 2869, 2470, 713, 3129, 31311, 1257, 68, 24, 68, 24, 301, 2710, 66, 1342, 69, 20 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 5325, 63, 1652, 63, 5282, 1192, 5915, 12, 272, 2198, 63, 5553, 12, 272, 6420, 12107, 12, 272, 6202, 63, 1001, 80, 12, 272, 25344, 63, 495, 602, 12, 199, 9, 421, 199, 533, 653, 1512, 1563, 4332, 8, 18283, 304, 272, 347, 485, 362, 63, 1418, 8, 277, 12, 3991, 63, 344, 304, 267, 1526, 63, 1606, 275, 291, 423, 4249, 63, 12022, 8, 288, 283, 1014, 921, 29132, 14, 676, 293, 1545, 14, 7530, 15, 1590, 411, 1897, 15, 73, 14, 3596, 297, 288, 3991, 63, 344, 12, 5317, 534, 18085, 1526, 358, 267, 1526, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 7, 1590, 411, 1897, 4537, 1418, 275, 7340, 11198, 32691, 1526, 63, 1606, 12, 283, 1418, 358, 267, 327, 13966, 651, 494, 5563, 12509, 687, 1455, 921, 1590, 411, 1897, 14, 676, 293, 1545, 14, 7530, 15, 1259, 3596, 15, 1590, 411, 1897, 13, 827, 14, 3596, 267, 1526, 63, 76, 275, 769, 8, 1418, 9, 267, 1642, 275, 3499, 275, 488, 267, 367, 284, 315, 1425, 8, 21, 12, 822, 8, 1418, 63, 76, 9, 446, 841, 304, 288, 340, 1526, 63, 76, 59, 73, 1055, 13896, 837, 355, 340, 1642, 365, 488, 26, 490, 1642, 275, 284, 355, 916, 3499, 365, 488, 26, 490, 3499, 275, 284, 267, 340, 1642, 365, 488, 503, 3499, 365, 488, 26, 288, 1642, 275, 3144, 288, 3499, 275, 4944, 398, 1526, 63, 76, 59, 2246, 467, 1526, 63, 76, 59, 4375, 61, 275, 1526, 63, 76, 59, 4375, 467, 1526, 63, 76, 59, 2246, 61, 398, 372, 6522, 904, 8, 1418, 63, 76, 9, 421, 199, 533, 653, 1512, 4332, 8, 46, 1512, 1563, 4332, 304, 272, 15292, 63, 2339, 275, 283, 78, 555, 7, 272, 15292, 63, 15119, 275, 283, 78, 555, 14, 7530, 436, 302, 454, 14, 7530, 7, 272, 485, 5600, 63, 2632, 275, 519, 2344, 2229, 88, 9, 490, 16697, 717, 302, 555, 26, 92, 717, 4178, 14144, 1169, 16697, 1544, 20316, 1169, 16697, 1816, 302, 555, 4537, 7530, 9448, 1, 6442, 92, 11905, 9, 5169, 26285, 15, 11224, 18, 22441, 1816, 302, 454, 4537, 7530, 32576, 26285, 15, 11224, 18, 12, 22441, 1816, 312, 17335, 1545, 3501, 76, 4537, 7530, 15, 3722, 15, 7677, 15, 26285, 363, 1169, 776, 717, 776, 717, 7558, 48, 28, 344, 13489, 10197, 3, 11896, 355, 1449, 339, 485, 7569, 275, 359, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 78, 555, 14, 7530, 15, 78, 29364, 3569, 85, 300, 15, 1081, 13, 1690, 13, 7280, 15, 54, 10780, 615, 63, 713, 10744, 1167, 297, 288, 283, 1064, 21, 356, 283, 20, 66, 19, 70, 25, 67, 14372, 10823, 825, 20, 12710, 70, 18, 67, 25, 2894, 23, 66, 25, 845, 10882, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 54, 10780, 615, 63, 713, 10744, 1167, 297, 355, 283, 832, 356, 283, 77, 20, 86, 297, 355, 283, 1213, 356, 283, 46, 29364, 3569, 85, 300, 297, 355, 283, 1802, 356, 283, 36, 474, 317, 74, 6080, 307, 527, 2464, 3367, 287, 655, 325, 276, 26, 302, 29364, 3569, 12, 308, 719, 655, 282, 335, 351, 2587, 265, 848, 3130, 355, 283, 5064, 63, 602, 356, 283, 7280, 1690, 1081, 297, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 78, 555, 14, 7530, 15, 271, 13, 29073, 13, 2664, 415, 13, 29073, 13, 273, 676, 305, 13, 2384, 15, 1465, 13, 996, 13, 8664, 15, 5568, 33, 63, 4893, 1167, 1085, 383, 297, 288, 283, 1064, 21, 356, 283, 983, 1400, 65, 1641, 1555, 697, 3003, 975, 1644, 67, 20, 350, 1257, 70, 2192, 67, 21, 6708, 66, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 5568, 33, 63, 4893, 1167, 1085, 383, 297, 355, 283, 832, 356, 283, 77, 20, 86, 297, 355, 283, 1213, 356, 283, 872, 3194, 5294, 603, 7455, 1253, 3194, 5294, 27864, 2498, 26, 710, 5526, 402, 3130, 355, 283, 1802, 356, 283, 1064, 21, 26, 19, 66, 1342, 67, 2576, 3003, 25, 68, 1876, 614, 68, 21, 65, 16373, 27538, 16, 69, 1477, 383, 70, 20, 297, 355, 283, 5064, 63, 602, 356, 283, 8664, 996, 1465, 297, 355, 283, 5553, 356, 499, 5303, 12, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 78, 555, 14, 7530, 15, 266, 2268, 317, 335, 84, 15, 821, 13, 996, 13, 6965, 15, 54, 10780, 615, 63, 845, 1876, 20919, 297, 288, 283, 1064, 21, 356, 283, 70, 1257, 2182, 69, 20, 69, 21, 65, 2277, 1194, 19846, 379, 19, 67, 23, 69, 22585, 11175, 70, 18, 67, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 54, 10780, 615, 63, 845, 1876, 20919, 297, 355, 283, 832, 356, 283, 77, 20, 86, 297, 355, 283, 1213, 356, 283, 6301, 2268, 317, 335, 84, 26, 1487, 370, 5711, 676, 270, 1022, 676, 84, 399, 390, 437, 25876, 7351, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 2528, 2177, 20, 1024, 70, 3776, 2534, 18190, 2894, 3833, 1690, 68, 5284, 11160, 371, 4489, 297, 355, 283, 5064, 63, 602, 356, 283, 6965, 996, 821, 297, 355, 283, 5553, 356, 29664, 12, 288, 1660, 267, 1660, 267, 469, 288, 283, 633, 356, 283, 1014, 921, 1544, 14, 78, 555, 14, 7530, 15, 271, 13, 78, 29364, 1129, 13, 278, 561, 13, 271, 352, 13, 17, 15, 2025, 13, 1780, 13, 6542, 15, 11325, 63, 54, 2514, 63, 31013, 1690, 297, 288, 283, 815, 63, 807, 356, 469, 355, 283, 344, 356, 283, 11325, 63, 54, 2514, 63, 31013, 1690, 297, 355, 283, 832, 356, 283, 87, 12393, 297, 355, 283, 1213, 356, 283, 872, 302, 29364, 1129, 562, 561, 446, 1487, 352, 413, 297, 355, 283, 1802, 356, 283, 1064, 21, 26, 27015, 3624, 2869, 2470, 713, 3129, 31311, 1257, 68, 24, 68, 24, 301, 2710, 66, 1342, 69, 20, 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, 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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 ]
alex/warehouse
tests/unit/test_raven.py
3
4219
# 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 pretend import pytest import raven as real_raven from pyramid.tweens import EXCVIEW, INGRESS from raven.middleware import Sentry as SentryMiddleware from unittest import mock from warehouse import raven def test_invalid_serializer(): s = raven.InvalidSessionSerializer(pretend.stub()) assert s.serialize(pretend.stub()) == "<InvalidSession>" class TestRavenTween: def test_with_error(self): request = pretend.stub( raven=pretend.stub( captureException=pretend.call_recorder(lambda: None), ), ) class TestException(Exception): pass @pretend.call_recorder def handler(request): raise TestException tween = raven.raven_tween_factory(handler, pretend.stub()) with pytest.raises(TestException): tween(request) assert handler.calls == [pretend.call(request)] assert request.raven.captureException.calls == [pretend.call()] def test_without_error(self): request = pretend.stub( raven=pretend.stub( captureException=pretend.call_recorder(lambda: None), ), ) response = pretend.stub() @pretend.call_recorder def handler(request): return response tween = raven.raven_tween_factory(handler, pretend.stub()) assert tween(request) is response assert handler.calls == [pretend.call(request)] assert request.raven.captureException.calls == [] def test_raven_request_method(): client = pretend.stub( context=pretend.stub( clear=pretend.call_recorder(lambda: None), ), ) request = pretend.stub( add_finished_callback=pretend.call_recorder(lambda cb: None), registry={"raven.client": client}, raven=client, ) assert raven._raven(request) is client assert request.add_finished_callback.calls == [pretend.call(mock.ANY)] assert client.context.clear.calls == [] cb = request.add_finished_callback.calls[0].args[0] cb(request) assert client.context.clear.calls == [pretend.call()] def test_includeme(monkeypatch): class Registry(dict): def __init__(self): self.settings = {} client_obj = pretend.stub() client_cls = pretend.call_recorder(lambda **kw: client_obj) monkeypatch.setattr(real_raven, "Client", client_cls) config = pretend.stub( registry=Registry(), add_request_method=pretend.call_recorder(lambda *a, **kw: None), add_wsgi_middleware=pretend.call_recorder(lambda *a, **kw: None), add_tween=pretend.call_recorder(lambda *a, **kw: None), ) config.registry.settings.update({ "warehouse.commit": "blargh", "sentry.dsn": "the dsn", "sentry.transport": "the transport", }) raven.includeme(config) assert client_cls.calls == [ pretend.call( dsn="the dsn", include_paths=["warehouse"], release="blargh", transport="the transport", ), ] assert config.registry["raven.client"] is client_obj assert config.add_request_method.calls == [ pretend.call(raven._raven, name="raven", reify=True), ] assert config.add_tween.calls == [ pretend.call( "warehouse.raven.raven_tween_factory", over=EXCVIEW, under=[ "pyramid_debugtoolbar.toolbar_tween_factory", INGRESS, ], ), ] assert config.add_wsgi_middleware.calls == [ pretend.call(SentryMiddleware, client=client_obj), ]
apache-2.0
[ 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, 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, 27830, 199, 646, 4613, 199, 646, 660, 1856, 465, 3363, 63, 345, 1856, 199, 199, 504, 30704, 14, 84, 3109, 83, 492, 3651, 35, 12058, 12, 1621, 19568, 199, 504, 660, 1856, 14, 5754, 492, 428, 2373, 465, 428, 2373, 6608, 199, 504, 2882, 492, 1683, 199, 199, 504, 13782, 492, 660, 1856, 421, 199, 318, 511, 63, 3197, 63, 8349, 837, 272, 308, 275, 660, 1856, 14, 3364, 4434, 7299, 8, 657, 7169, 14, 5811, 1012, 272, 702, 308, 14, 3549, 8, 657, 7169, 14, 5811, 1012, 508, 3886, 3364, 4434, 4335, 421, 199, 533, 1379, 50, 15556, 52, 3109, 26, 339, 347, 511, 63, 1045, 63, 705, 8, 277, 304, 267, 1056, 275, 27830, 14, 5811, 8, 288, 660, 1856, 29, 657, 7169, 14, 5811, 8, 355, 12296, 1726, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 26, 488, 395, 288, 2318, 267, 776, 398, 1021, 1379, 1726, 8, 1726, 304, 288, 986, 398, 768, 657, 7169, 14, 1250, 63, 27733, 267, 347, 3016, 8, 1069, 304, 288, 746, 1379, 1726, 398, 307, 3109, 275, 660, 1856, 14, 345, 1856, 63, 84, 3109, 63, 3702, 8, 2232, 12, 27830, 14, 5811, 1012, 398, 543, 4613, 14, 3536, 8, 774, 1726, 304, 288, 307, 3109, 8, 1069, 9, 398, 702, 3016, 14, 5352, 508, 359, 657, 7169, 14, 1250, 8, 1069, 1874, 267, 702, 1056, 14, 345, 1856, 14, 12685, 1726, 14, 5352, 508, 359, 657, 7169, 14, 1250, 5106, 339, 347, 511, 63, 7395, 63, 705, 8, 277, 304, 267, 1056, 275, 27830, 14, 5811, 8, 288, 660, 1856, 29, 657, 7169, 14, 5811, 8, 355, 12296, 1726, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 26, 488, 395, 288, 2318, 267, 776, 267, 1177, 275, 27830, 14, 5811, 342, 398, 768, 657, 7169, 14, 1250, 63, 27733, 267, 347, 3016, 8, 1069, 304, 288, 372, 1177, 398, 307, 3109, 275, 660, 1856, 14, 345, 1856, 63, 84, 3109, 63, 3702, 8, 2232, 12, 27830, 14, 5811, 1012, 398, 702, 307, 3109, 8, 1069, 9, 365, 1177, 267, 702, 3016, 14, 5352, 508, 359, 657, 7169, 14, 1250, 8, 1069, 1874, 267, 702, 1056, 14, 345, 1856, 14, 12685, 1726, 14, 5352, 508, 942, 421, 199, 318, 511, 63, 345, 1856, 63, 1069, 63, 765, 837, 272, 1890, 275, 27830, 14, 5811, 8, 267, 1067, 29, 657, 7169, 14, 5811, 8, 288, 5436, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 26, 488, 395, 267, 2318, 272, 776, 272, 1056, 275, 27830, 14, 5811, 8, 267, 1050, 63, 8669, 63, 3058, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 7434, 26, 488, 395, 267, 7086, 8871, 345, 1856, 14, 1258, 582, 1890, 1386, 267, 660, 1856, 29, 1258, 12, 272, 776, 272, 702, 660, 1856, 423, 345, 1856, 8, 1069, 9, 365, 1890, 272, 702, 1056, 14, 525, 63, 8669, 63, 3058, 14, 5352, 508, 359, 657, 7169, 14, 1250, 8, 1805, 14, 8974, 1874, 272, 702, 1890, 14, 1100, 14, 3584, 14, 5352, 508, 942, 272, 7434, 275, 1056, 14, 525, 63, 8669, 63, 3058, 14, 5352, 59, 16, 1055, 589, 59, 16, 61, 272, 7434, 8, 1069, 9, 272, 702, 1890, 14, 1100, 14, 3584, 14, 5352, 508, 359, 657, 7169, 14, 1250, 5106, 421, 199, 318, 511, 63, 2613, 278, 8, 20372, 2068, 304, 272, 1021, 20738, 8, 807, 304, 398, 347, 636, 826, 721, 277, 304, 288, 291, 14, 1751, 275, 1052, 339, 1890, 63, 1113, 275, 27830, 14, 5811, 342, 272, 1890, 63, 1886, 275, 27830, 14, 1250, 63, 27733, 8, 2734, 1011, 829, 26, 1890, 63, 1113, 9, 272, 17309, 14, 10202, 8, 3093, 63, 345, 1856, 12, 298, 3041, 401, 1890, 63, 1886, 9, 339, 1101, 275, 27830, 14, 5811, 8, 267, 7086, 29, 10899, 1062, 267, 1050, 63, 1069, 63, 765, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 627, 65, 12, 1011, 829, 26, 488, 395, 267, 1050, 63, 6508, 63, 5754, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 627, 65, 12, 1011, 829, 26, 488, 395, 267, 1050, 63, 84, 3109, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 627, 65, 12, 1011, 829, 26, 488, 395, 272, 776, 272, 1101, 14, 5189, 14, 1751, 14, 873, 2561, 267, 298, 12806, 14, 3543, 582, 298, 3345, 1273, 72, 401, 267, 298, 3870, 14, 32510, 582, 298, 1589, 366, 5167, 401, 267, 298, 3870, 14, 5545, 582, 298, 1589, 7773, 401, 272, 3828, 339, 660, 1856, 14, 2613, 278, 8, 888, 9, 339, 702, 1890, 63, 1886, 14, 5352, 508, 359, 267, 27830, 14, 1250, 8, 288, 366, 5167, 628, 1589, 366, 5167, 401, 288, 2387, 63, 3771, 6270, 12806, 2255, 288, 4683, 628, 3345, 1273, 72, 401, 288, 7773, 628, 1589, 7773, 401, 267, 2318, 272, 1622, 272, 702, 1101, 14, 5189, 905, 345, 1856, 14, 1258, 937, 365, 1890, 63, 1113, 272, 702, 1101, 14, 525, 63, 1069, 63, 765, 14, 5352, 508, 359, 267, 27830, 14, 1250, 8, 345, 1856, 423, 345, 1856, 12, 536, 628, 345, 1856, 401, 295, 2021, 29, 549, 395, 272, 1622, 272, 702, 1101, 14, 525, 63, 84, 3109, 14, 5352, 508, 359, 267, 27830, 14, 1250, 8, 288, 298, 12806, 14, 345, 1856, 14, 345, 1856, 63, 84, 3109, 63, 3702, 401, 288, 1806, 29, 1438, 35, 12058, 12, 288, 1334, 1524, 355, 298, 647, 20785 ]
[ 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, 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, 27830, 199, 646, 4613, 199, 646, 660, 1856, 465, 3363, 63, 345, 1856, 199, 199, 504, 30704, 14, 84, 3109, 83, 492, 3651, 35, 12058, 12, 1621, 19568, 199, 504, 660, 1856, 14, 5754, 492, 428, 2373, 465, 428, 2373, 6608, 199, 504, 2882, 492, 1683, 199, 199, 504, 13782, 492, 660, 1856, 421, 199, 318, 511, 63, 3197, 63, 8349, 837, 272, 308, 275, 660, 1856, 14, 3364, 4434, 7299, 8, 657, 7169, 14, 5811, 1012, 272, 702, 308, 14, 3549, 8, 657, 7169, 14, 5811, 1012, 508, 3886, 3364, 4434, 4335, 421, 199, 533, 1379, 50, 15556, 52, 3109, 26, 339, 347, 511, 63, 1045, 63, 705, 8, 277, 304, 267, 1056, 275, 27830, 14, 5811, 8, 288, 660, 1856, 29, 657, 7169, 14, 5811, 8, 355, 12296, 1726, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 26, 488, 395, 288, 2318, 267, 776, 398, 1021, 1379, 1726, 8, 1726, 304, 288, 986, 398, 768, 657, 7169, 14, 1250, 63, 27733, 267, 347, 3016, 8, 1069, 304, 288, 746, 1379, 1726, 398, 307, 3109, 275, 660, 1856, 14, 345, 1856, 63, 84, 3109, 63, 3702, 8, 2232, 12, 27830, 14, 5811, 1012, 398, 543, 4613, 14, 3536, 8, 774, 1726, 304, 288, 307, 3109, 8, 1069, 9, 398, 702, 3016, 14, 5352, 508, 359, 657, 7169, 14, 1250, 8, 1069, 1874, 267, 702, 1056, 14, 345, 1856, 14, 12685, 1726, 14, 5352, 508, 359, 657, 7169, 14, 1250, 5106, 339, 347, 511, 63, 7395, 63, 705, 8, 277, 304, 267, 1056, 275, 27830, 14, 5811, 8, 288, 660, 1856, 29, 657, 7169, 14, 5811, 8, 355, 12296, 1726, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 26, 488, 395, 288, 2318, 267, 776, 267, 1177, 275, 27830, 14, 5811, 342, 398, 768, 657, 7169, 14, 1250, 63, 27733, 267, 347, 3016, 8, 1069, 304, 288, 372, 1177, 398, 307, 3109, 275, 660, 1856, 14, 345, 1856, 63, 84, 3109, 63, 3702, 8, 2232, 12, 27830, 14, 5811, 1012, 398, 702, 307, 3109, 8, 1069, 9, 365, 1177, 267, 702, 3016, 14, 5352, 508, 359, 657, 7169, 14, 1250, 8, 1069, 1874, 267, 702, 1056, 14, 345, 1856, 14, 12685, 1726, 14, 5352, 508, 942, 421, 199, 318, 511, 63, 345, 1856, 63, 1069, 63, 765, 837, 272, 1890, 275, 27830, 14, 5811, 8, 267, 1067, 29, 657, 7169, 14, 5811, 8, 288, 5436, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 26, 488, 395, 267, 2318, 272, 776, 272, 1056, 275, 27830, 14, 5811, 8, 267, 1050, 63, 8669, 63, 3058, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 7434, 26, 488, 395, 267, 7086, 8871, 345, 1856, 14, 1258, 582, 1890, 1386, 267, 660, 1856, 29, 1258, 12, 272, 776, 272, 702, 660, 1856, 423, 345, 1856, 8, 1069, 9, 365, 1890, 272, 702, 1056, 14, 525, 63, 8669, 63, 3058, 14, 5352, 508, 359, 657, 7169, 14, 1250, 8, 1805, 14, 8974, 1874, 272, 702, 1890, 14, 1100, 14, 3584, 14, 5352, 508, 942, 272, 7434, 275, 1056, 14, 525, 63, 8669, 63, 3058, 14, 5352, 59, 16, 1055, 589, 59, 16, 61, 272, 7434, 8, 1069, 9, 272, 702, 1890, 14, 1100, 14, 3584, 14, 5352, 508, 359, 657, 7169, 14, 1250, 5106, 421, 199, 318, 511, 63, 2613, 278, 8, 20372, 2068, 304, 272, 1021, 20738, 8, 807, 304, 398, 347, 636, 826, 721, 277, 304, 288, 291, 14, 1751, 275, 1052, 339, 1890, 63, 1113, 275, 27830, 14, 5811, 342, 272, 1890, 63, 1886, 275, 27830, 14, 1250, 63, 27733, 8, 2734, 1011, 829, 26, 1890, 63, 1113, 9, 272, 17309, 14, 10202, 8, 3093, 63, 345, 1856, 12, 298, 3041, 401, 1890, 63, 1886, 9, 339, 1101, 275, 27830, 14, 5811, 8, 267, 7086, 29, 10899, 1062, 267, 1050, 63, 1069, 63, 765, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 627, 65, 12, 1011, 829, 26, 488, 395, 267, 1050, 63, 6508, 63, 5754, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 627, 65, 12, 1011, 829, 26, 488, 395, 267, 1050, 63, 84, 3109, 29, 657, 7169, 14, 1250, 63, 27733, 8, 2734, 627, 65, 12, 1011, 829, 26, 488, 395, 272, 776, 272, 1101, 14, 5189, 14, 1751, 14, 873, 2561, 267, 298, 12806, 14, 3543, 582, 298, 3345, 1273, 72, 401, 267, 298, 3870, 14, 32510, 582, 298, 1589, 366, 5167, 401, 267, 298, 3870, 14, 5545, 582, 298, 1589, 7773, 401, 272, 3828, 339, 660, 1856, 14, 2613, 278, 8, 888, 9, 339, 702, 1890, 63, 1886, 14, 5352, 508, 359, 267, 27830, 14, 1250, 8, 288, 366, 5167, 628, 1589, 366, 5167, 401, 288, 2387, 63, 3771, 6270, 12806, 2255, 288, 4683, 628, 3345, 1273, 72, 401, 288, 7773, 628, 1589, 7773, 401, 267, 2318, 272, 1622, 272, 702, 1101, 14, 5189, 905, 345, 1856, 14, 1258, 937, 365, 1890, 63, 1113, 272, 702, 1101, 14, 525, 63, 1069, 63, 765, 14, 5352, 508, 359, 267, 27830, 14, 1250, 8, 345, 1856, 423, 345, 1856, 12, 536, 628, 345, 1856, 401, 295, 2021, 29, 549, 395, 272, 1622, 272, 702, 1101, 14, 525, 63, 84, 3109, 14, 5352, 508, 359, 267, 27830, 14, 1250, 8, 288, 298, 12806, 14, 345, 1856, 14, 345, 1856, 63, 84, 3109, 63, 3702, 401, 288, 1806, 29, 1438, 35, 12058, 12, 288, 1334, 1524, 355, 298, 647, 20785, 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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estDisallowUnknownProperties(TestCase): def setUp(self): self.data_simple = {"name": "john doe", "age": 42} self.schema_simple = { "type": "object", "properties": { "name": {"type": "string"}, "age": {"type": "integer"} }, } self.data_complex = { "inv_number": "123", "rows": [ { "sku": "ab-456", "desc": "a description", "price": 100.45 }, { "sku": "xy-123", "desc": "another description", "price": 999.00 } ] } self.schema_complex = { "type": "object", "properties": { "inv_number": {"type": "string"}, "rows": { "type": "array", "items": { "type": "object", "properties": { "sku": {"type": "string"}, "desc": {"type": "string"}, "price": {"type": "number"} } }, } } } def test_disallow_unknown_properties_pass(self): try: validictory.validate(self.data_simple, self.schema_simple, disallow_unknown_properties=True) except ValueError as e: self.fail("Unexpected failure: %s" % e) def test_disallow_unknown_properties_fail(self): self.data_simple["sex"] = "male" self.assertRaises(validictory.SchemaError, validictory.validate, self.data_simple, self.schema_simple, disallow_unknown_properties=True) def test_disallow_unknown_properties_complex_pass(self): try: validictory.validate(self.data_complex, self.schema_complex, disallow_unknown_properties=True) except ValueError as e: self.fail("Unexpected failure: %s" % e) def test_disallow_unknown_properties_complex_fail(self): newrow = {"sku": "789", "desc": "catch me if you can", "price": 1, "rice": 666} self.data_complex["rows"].append(newrow) self.assertRaises(validictory.SchemaError, validictory.validate, self.data_complex, self.schema_complex, disallow_unknown_properties=True)
agpl-3.0
[ 504, 2882, 492, 7640, 199, 199, 646, 1139, 9897, 1076, 421, 199, 533, 1379, 2825, 3306, 5912, 8516, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 576, 63, 4129, 275, 2420, 354, 582, 298, 20216, 886, 69, 401, 298, 474, 582, 5685, 93, 267, 291, 14, 3629, 63, 4129, 275, 469, 288, 298, 466, 582, 298, 785, 401, 288, 298, 3282, 582, 469, 355, 298, 354, 582, 2420, 466, 582, 298, 875, 6018, 355, 298, 474, 582, 2420, 466, 582, 298, 4115, 3570, 288, 1660, 267, 789, 398, 291, 14, 576, 63, 5254, 275, 469, 288, 298, 5350, 63, 1955, 582, 298, 4288, 401, 288, 298, 3838, 582, 359, 355, 469, 490, 298, 27772, 582, 298, 371, 13, 11419, 401, 490, 298, 3257, 582, 298, 65, 1369, 401, 490, 298, 4777, 582, 2948, 14, 2322, 355, 1660, 355, 469, 490, 298, 27772, 582, 298, 1702, 13, 4288, 401, 490, 298, 3257, 582, 298, 13565, 1369, 401, 490, 298, 4777, 582, 22291, 14, 383, 355, 789, 288, 1622, 267, 789, 267, 291, 14, 3629, 63, 5254, 275, 469, 288, 298, 466, 582, 298, 785, 401, 288, 298, 3282, 582, 469, 355, 298, 5350, 63, 1955, 582, 2420, 466, 582, 298, 875, 6018, 355, 298, 3838, 582, 469, 490, 298, 466, 582, 298, 1144, 401, 490, 298, 1744, 582, 469, 717, 298, 466, 582, 298, 785, 401, 717, 298, 3282, 582, 469, 1169, 298, 27772, 582, 2420, 466, 582, 298, 875, 6018, 1169, 298, 3257, 582, 2420, 466, 582, 298, 875, 6018, 1169, 298, 4777, 582, 2420, 466, 582, 298, 1955, 3570, 717, 789, 490, 1660, 355, 789, 288, 789, 267, 789, 339, 347, 511, 63, 2297, 3306, 63, 5187, 63, 3282, 63, 1529, 8, 277, 304, 267, 862, 26, 288, 1139, 9897, 1076, 14, 3502, 8, 277, 14, 576, 63, 4129, 12, 291, 14, 3629, 63, 4129, 12, 639, 2153, 3306, 63, 5187, 63, 3282, 29, 549, 9, 267, 871, 1722, 465, 325, 26, 288, 291, 14, 1633, 480, 8708, 5988, 26, 450, 83, 2, 450, 325, 9, 339, 347, 511, 63, 2297, 3306, 63, 5187, 63, 3282, 63, 1633, 8, 277, 304, 267, 291, 14, 576, 63, 4129, 905, 20160, 937, 275, 298, 17667, 2, 267, 291, 14, 1855, 8, 637, 9897, 1076, 14, 6700, 547, 12, 1139, 9897, 1076, 14, 3502, 12, 2079, 291, 14, 576, 63, 4129, 12, 291, 14, 3629, 63, 4129, 12, 2079, 2153, 3306, 63, 5187, 63, 3282, 29, 549, 9, 339, 347, 511, 63, 2297, 3306, 63, 5187, 63, 3282, 63, 5254, 63, 1529, 8, 277, 304, 267, 862, 26, 288, 1139, 9897, 1076, 14, 3502, 8, 277, 14, 576, 63, 5254, 12, 291, 14, 3629, 63, 5254, 12, 639, 2153, 3306, 63, 5187, 63, 3282, 29, 549, 9, 267, 871, 1722, 465, 325, 26, 288, 291, 14, 1633, 480, 8708, 5988, 26, 450, 83, 2, 450, 325, 9, 339, 347, 511, 63, 2297, 3306, 63, 5187, 63, 3282, 63, 5254, 63, 1633, 8, 277, 304, 267, 892, 1143, 275, 2420, 27772, 582, 298, 24407, 401, 298, 3257, 582, 298, 9341, 562, 340, 1265, 883, 401, 298, 4777, 582, 413, 12, 2116, 298, 322, 301, 582, 1227, 1272, 93, 267, 291, 14, 576, 63, 5254, 905, 3838, 4140, 740, 8, 1222, 1143, 9, 267, 291, 14, 1855, 8, 637, 9897, 1076, 14, 6700, 547, 12, 1139, 9897, 1076, 14, 3502, 12, 2079, 291, 14, 576, 63, 5254, 12, 291, 14, 3629, 63, 5254, 12, 2079, 2153, 3306, 63, 5187, 63, 3282, 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 ]
[ 2882, 492, 7640, 199, 199, 646, 1139, 9897, 1076, 421, 199, 533, 1379, 2825, 3306, 5912, 8516, 8, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 576, 63, 4129, 275, 2420, 354, 582, 298, 20216, 886, 69, 401, 298, 474, 582, 5685, 93, 267, 291, 14, 3629, 63, 4129, 275, 469, 288, 298, 466, 582, 298, 785, 401, 288, 298, 3282, 582, 469, 355, 298, 354, 582, 2420, 466, 582, 298, 875, 6018, 355, 298, 474, 582, 2420, 466, 582, 298, 4115, 3570, 288, 1660, 267, 789, 398, 291, 14, 576, 63, 5254, 275, 469, 288, 298, 5350, 63, 1955, 582, 298, 4288, 401, 288, 298, 3838, 582, 359, 355, 469, 490, 298, 27772, 582, 298, 371, 13, 11419, 401, 490, 298, 3257, 582, 298, 65, 1369, 401, 490, 298, 4777, 582, 2948, 14, 2322, 355, 1660, 355, 469, 490, 298, 27772, 582, 298, 1702, 13, 4288, 401, 490, 298, 3257, 582, 298, 13565, 1369, 401, 490, 298, 4777, 582, 22291, 14, 383, 355, 789, 288, 1622, 267, 789, 267, 291, 14, 3629, 63, 5254, 275, 469, 288, 298, 466, 582, 298, 785, 401, 288, 298, 3282, 582, 469, 355, 298, 5350, 63, 1955, 582, 2420, 466, 582, 298, 875, 6018, 355, 298, 3838, 582, 469, 490, 298, 466, 582, 298, 1144, 401, 490, 298, 1744, 582, 469, 717, 298, 466, 582, 298, 785, 401, 717, 298, 3282, 582, 469, 1169, 298, 27772, 582, 2420, 466, 582, 298, 875, 6018, 1169, 298, 3257, 582, 2420, 466, 582, 298, 875, 6018, 1169, 298, 4777, 582, 2420, 466, 582, 298, 1955, 3570, 717, 789, 490, 1660, 355, 789, 288, 789, 267, 789, 339, 347, 511, 63, 2297, 3306, 63, 5187, 63, 3282, 63, 1529, 8, 277, 304, 267, 862, 26, 288, 1139, 9897, 1076, 14, 3502, 8, 277, 14, 576, 63, 4129, 12, 291, 14, 3629, 63, 4129, 12, 639, 2153, 3306, 63, 5187, 63, 3282, 29, 549, 9, 267, 871, 1722, 465, 325, 26, 288, 291, 14, 1633, 480, 8708, 5988, 26, 450, 83, 2, 450, 325, 9, 339, 347, 511, 63, 2297, 3306, 63, 5187, 63, 3282, 63, 1633, 8, 277, 304, 267, 291, 14, 576, 63, 4129, 905, 20160, 937, 275, 298, 17667, 2, 267, 291, 14, 1855, 8, 637, 9897, 1076, 14, 6700, 547, 12, 1139, 9897, 1076, 14, 3502, 12, 2079, 291, 14, 576, 63, 4129, 12, 291, 14, 3629, 63, 4129, 12, 2079, 2153, 3306, 63, 5187, 63, 3282, 29, 549, 9, 339, 347, 511, 63, 2297, 3306, 63, 5187, 63, 3282, 63, 5254, 63, 1529, 8, 277, 304, 267, 862, 26, 288, 1139, 9897, 1076, 14, 3502, 8, 277, 14, 576, 63, 5254, 12, 291, 14, 3629, 63, 5254, 12, 639, 2153, 3306, 63, 5187, 63, 3282, 29, 549, 9, 267, 871, 1722, 465, 325, 26, 288, 291, 14, 1633, 480, 8708, 5988, 26, 450, 83, 2, 450, 325, 9, 339, 347, 511, 63, 2297, 3306, 63, 5187, 63, 3282, 63, 5254, 63, 1633, 8, 277, 304, 267, 892, 1143, 275, 2420, 27772, 582, 298, 24407, 401, 298, 3257, 582, 298, 9341, 562, 340, 1265, 883, 401, 298, 4777, 582, 413, 12, 2116, 298, 322, 301, 582, 1227, 1272, 93, 267, 291, 14, 576, 63, 5254, 905, 3838, 4140, 740, 8, 1222, 1143, 9, 267, 291, 14, 1855, 8, 637, 9897, 1076, 14, 6700, 547, 12, 1139, 9897, 1076, 14, 3502, 12, 2079, 291, 14, 576, 63, 5254, 12, 291, 14, 3629, 63, 5254, 12, 2079, 2153, 3306, 63, 5187, 63, 3282, 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, 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 ]
Jorge-Rodriguez/ansible
lib/ansible/modules/cloud/openstack/os_router.py
52
17853
#!/usr/bin/python # # Copyright: 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 ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: os_router short_description: Create or delete routers from OpenStack extends_documentation_fragment: openstack version_added: "2.0" author: "David Shrewsbury (@Shrews)" description: - Create or Delete routers from OpenStack. Although Neutron allows routers to share the same name, this module enforces name uniqueness to be more user friendly. options: state: description: - Indicate desired state of the resource choices: ['present', 'absent'] default: present name: description: - Name to be give to the router required: true admin_state_up: description: - Desired admin state of the created or existing router. type: bool default: 'yes' enable_snat: description: - Enable Source NAT (SNAT) attribute. type: bool network: description: - Unique name or ID of the external gateway network. - required I(interfaces) or I(enable_snat) are provided. project: description: - Unique name or ID of the project. version_added: "2.2" external_fixed_ips: description: - The IP address parameters for the external gateway network. Each is a dictionary with the subnet name or ID (subnet) and the IP address to assign on the subnet (ip). If no IP is specified, one is automatically assigned from that subnet. interfaces: description: - List of subnets to attach to the router internal interface. Default gateway associated with the subnet will be automatically attached with the router's internal interface. In order to provide an ip address different from the default gateway,parameters are passed as dictionary with keys as network name or ID(net), subnet name or ID (subnet) and the IP of port (portip) from the network. User defined portip is often required when a multiple router need to be connected to a single subnet for which the default gateway has been already used. availability_zone: description: - Ignored. Present for backwards compatibility requirements: ["openstacksdk"] ''' EXAMPLES = ''' # Create a simple router, not attached to a gateway or subnets. - os_router: cloud: mycloud state: present name: simple_router # Create a simple router, not attached to a gateway or subnets for a given project. - os_router: cloud: mycloud state: present name: simple_router project: myproj # Creates a router attached to ext_network1 on an IPv4 subnet and one # internal subnet interface. - os_router: cloud: mycloud state: present name: router1 network: ext_network1 external_fixed_ips: - subnet: public-subnet ip: 172.24.4.2 interfaces: - private-subnet # Create another router with two internal subnet interfaces.One with user defined port # ip and another with default gateway. - os_router: cloud: mycloud state: present name: router2 network: ext_network1 interfaces: - net: private-net subnet: private-subnet portip: 10.1.1.10 - project-subnet # Create another router with two internal subnet interface.One with user defined port # ip and and another with default gateway. - os_router: cloud: mycloud state: present name: router2 network: ext_network1 interfaces: - net: private-net subnet: private-subnet portip: 10.1.1.10 - project-subnet # Create another router with two internal subnet interface. one with user defined port # ip and and another with default gateway. - os_router: cloud: mycloud state: present name: router2 network: ext_network1 interfaces: - net: private-net subnet: private-subnet portip: 10.1.1.10 - project-subnet # Update existing router1 external gateway to include the IPv6 subnet. # Note that since 'interfaces' is not provided, any existing internal # interfaces on an existing router will be left intact. - os_router: cloud: mycloud state: present name: router1 network: ext_network1 external_fixed_ips: - subnet: public-subnet ip: 172.24.4.2 - subnet: ipv6-public-subnet ip: 2001:db8::3 # Delete router1 - os_router: cloud: mycloud state: absent name: router1 ''' RETURN = ''' router: description: Dictionary describing the router. returned: On success when I(state) is 'present' type: complex contains: id: description: Router ID. type: str sample: "474acfe5-be34-494c-b339-50f06aa143e4" name: description: Router name. type: str sample: "router1" admin_state_up: description: Administrative state of the router. type: bool sample: true status: description: The router status. type: str sample: "ACTIVE" tenant_id: description: The tenant ID. type: str sample: "861174b82b43463c9edc5202aadc60ef" external_gateway_info: description: The external gateway parameters. type: dict sample: { "enable_snat": true, "external_fixed_ips": [ { "ip_address": "10.6.6.99", "subnet_id": "4272cb52-a456-4c20-8f3c-c26024ecfa81" } ] } routes: description: The extra routes configuration for L3 router. type: list ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs, openstack_cloud_from_module ROUTER_INTERFACE_OWNERS = set([ 'network:router_interface', 'network:router_interface_distributed', 'network:ha_router_replicated_interface' ]) def _router_internal_interfaces(cloud, router): for port in cloud.list_router_interfaces(router, 'internal'): if port['device_owner'] in ROUTER_INTERFACE_OWNERS: yield port def _needs_update(cloud, module, router, network, internal_subnet_ids, internal_port_ids, filters=None): """Decide if the given router needs an update. """ if router['admin_state_up'] != module.params['admin_state_up']: return True if router['external_gateway_info']: # check if enable_snat is set in module params if module.params['enable_snat'] is not None: if router['external_gateway_info'].get('enable_snat', True) != module.params['enable_snat']: return True if network: if not router['external_gateway_info']: return True elif router['external_gateway_info']['network_id'] != network['id']: return True # check external interfaces if module.params['external_fixed_ips']: for new_iface in module.params['external_fixed_ips']: subnet = cloud.get_subnet(new_iface['subnet'], filters) exists = False # compare the requested interface with existing, looking for an existing match for existing_iface in router['external_gateway_info']['external_fixed_ips']: if existing_iface['subnet_id'] == subnet['id']: if 'ip' in new_iface: if existing_iface['ip_address'] == new_iface['ip']: # both subnet id and ip address match exists = True break else: # only the subnet was given, so ip doesn't matter exists = True break # this interface isn't present on the existing router if not exists: return True # check internal interfaces if module.params['interfaces']: existing_subnet_ids = [] for port in _router_internal_interfaces(cloud, router): if 'fixed_ips' in port: for fixed_ip in port['fixed_ips']: existing_subnet_ids.append(fixed_ip['subnet_id']) for iface in module.params['interfaces']: if isinstance(iface, dict): for p_id in internal_port_ids: p = cloud.get_port(name_or_id=p_id) if 'fixed_ips' in p: for fip in p['fixed_ips']: internal_subnet_ids.append(fip['subnet_id']) if set(internal_subnet_ids) != set(existing_subnet_ids): internal_subnet_ids = [] return True return False def _system_state_change(cloud, module, router, network, internal_ids, internal_portids, filters=None): """Check if the system state would be changed.""" state = module.params['state'] if state == 'absent' and router: return True if state == 'present': if not router: return True return _needs_update(cloud, module, router, network, internal_ids, internal_portids, filters) return False def _build_kwargs(cloud, module, router, network): kwargs = { 'admin_state_up': module.params['admin_state_up'], } if router: kwargs['name_or_id'] = router['id'] else: kwargs['name'] = module.params['name'] if network: kwargs['ext_gateway_net_id'] = network['id'] # can't send enable_snat unless we have a network if module.params.get('enable_snat') is not None: kwargs['enable_snat'] = module.params['enable_snat'] if module.params['external_fixed_ips']: kwargs['ext_fixed_ips'] = [] for iface in module.params['external_fixed_ips']: subnet = cloud.get_subnet(iface['subnet']) d = {'subnet_id': subnet['id']} if 'ip' in iface: d['ip_address'] = iface['ip'] kwargs['ext_fixed_ips'].append(d) return kwargs def _validate_subnets(module, cloud, filters=None): external_subnet_ids = [] internal_subnet_ids = [] internal_port_ids = [] existing_port_ips = [] existing_port_ids = [] if module.params['external_fixed_ips']: for iface in module.params['external_fixed_ips']: subnet = cloud.get_subnet(iface['subnet']) if not subnet: module.fail_json(msg='subnet %s not found' % iface['subnet']) external_subnet_ids.append(subnet['id']) if module.params['interfaces']: for iface in module.params['interfaces']: if isinstance(iface, str): subnet = cloud.get_subnet(iface, filters) if not subnet: module.fail_json(msg='subnet %s not found' % iface) internal_subnet_ids.append(subnet['id']) elif isinstance(iface, dict): subnet = cloud.get_subnet(iface['subnet'], filters) if not subnet: module.fail_json(msg='subnet %s not found' % iface['subnet']) net = cloud.get_network(iface['net']) if not net: module.fail_json(msg='net %s not found' % iface['net']) if "portip" not in iface: internal_subnet_ids.append(subnet['id']) elif not iface['portip']: module.fail_json(msg='put an ip in portip or remove it from list to assign default port to router') else: for existing_port in cloud.list_ports(filters={'network_id': net.id}): for fixed_ip in existing_port['fixed_ips']: if iface['portip'] == fixed_ip['ip_address']: internal_port_ids.append(existing_port.id) existing_port_ips.append(fixed_ip['ip_address']) if iface['portip'] not in existing_port_ips: p = cloud.create_port(network_id=net.id, fixed_ips=[{'ip_address': iface['portip'], 'subnet_id': subnet.id}]) if p: internal_port_ids.append(p.id) return external_subnet_ids, internal_subnet_ids, internal_port_ids def main(): argument_spec = openstack_full_argument_spec( state=dict(default='present', choices=['absent', 'present']), name=dict(required=True), admin_state_up=dict(type='bool', default=True), enable_snat=dict(type='bool'), network=dict(default=None), interfaces=dict(type='list', default=None), external_fixed_ips=dict(type='list', default=None), project=dict(default=None) ) module_kwargs = openstack_module_kwargs() module = AnsibleModule(argument_spec, supports_check_mode=True, **module_kwargs) state = module.params['state'] name = module.params['name'] network = module.params['network'] project = module.params['project'] if module.params['external_fixed_ips'] and not network: module.fail_json(msg='network is required when supplying external_fixed_ips') sdk, cloud = openstack_cloud_from_module(module) try: if project is not None: proj = cloud.get_project(project) if proj is None: module.fail_json(msg='Project %s could not be found' % project) project_id = proj['id'] filters = {'tenant_id': project_id} else: project_id = None filters = None router = cloud.get_router(name, filters=filters) net = None if network: net = cloud.get_network(network) if not net: module.fail_json(msg='network %s not found' % network) # Validate and cache the subnet IDs so we can avoid duplicate checks # and expensive API calls. external_ids, subnet_internal_ids, internal_portids = _validate_subnets(module, cloud, filters) if module.check_mode: module.exit_json( changed=_system_state_change(cloud, module, router, net, subnet_internal_ids, internal_portids, filters) ) if state == 'present': changed = False if not router: kwargs = _build_kwargs(cloud, module, router, net) if project_id: kwargs['project_id'] = project_id router = cloud.create_router(**kwargs) for int_s_id in subnet_internal_ids: cloud.add_router_interface(router, subnet_id=int_s_id) changed = True # add interface by port id as well for int_p_id in internal_portids: cloud.add_router_interface(router, port_id=int_p_id) changed = True else: if _needs_update(cloud, module, router, net, subnet_internal_ids, internal_portids, filters): kwargs = _build_kwargs(cloud, module, router, net) updated_router = cloud.update_router(**kwargs) # Protect against update_router() not actually # updating the router. if not updated_router: changed = False # On a router update, if any internal interfaces were supplied, # just detach all existing internal interfaces and attach the new. if internal_portids or subnet_internal_ids: router = updated_router ports = _router_internal_interfaces(cloud, router) for port in ports: cloud.remove_router_interface(router, port_id=port['id']) if internal_portids: external_ids, subnet_internal_ids, internal_portids = _validate_subnets(module, cloud, filters) for int_p_id in internal_portids: cloud.add_router_interface(router, port_id=int_p_id) changed = True if subnet_internal_ids: for s_id in subnet_internal_ids: cloud.add_router_interface(router, subnet_id=s_id) changed = True module.exit_json(changed=changed, router=router, id=router['id']) elif state == 'absent': if not router: module.exit_json(changed=False) else: # We need to detach all internal interfaces on a router before # we will be allowed to delete it. ports = _router_internal_interfaces(cloud, router) router_id = router['id'] for port in ports: cloud.remove_router_interface(router, port_id=port['id']) cloud.delete_router(router_id) module.exit_json(changed=True) except sdk.exceptions.OpenStackCloudException as e: module.fail_json(msg=str(e)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 26, 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, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 4995, 199, 3612, 63, 1802, 26, 2790, 503, 3145, 24464, 687, 14260, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 36, 17204, 5244, 264, 3569, 66, 18359, 8593, 2662, 264, 3569, 2924, 199, 1802, 26, 2043, 446, 2790, 503, 8496, 24464, 687, 14260, 14, 4580, 15401, 30422, 6127, 1362, 24464, 370, 8663, 314, 2011, 536, 12, 642, 859, 655, 509, 823, 536, 15439, 31820, 1362, 370, 506, 1655, 922, 21428, 14, 199, 1419, 26, 2043, 1174, 26, 1362, 1369, 26, 267, 446, 1010, 10188, 6387, 1174, 402, 314, 2073, 1362, 3415, 26, 788, 1881, 297, 283, 5575, 418, 1362, 849, 26, 3451, 2043, 536, 26, 1362, 1369, 26, 267, 446, 2812, 370, 506, 8120, 370, 314, 6197, 1362, 1415, 26, 2549, 2043, 4628, 63, 929, 63, 384, 26, 1362, 1369, 26, 267, 446, 1487, 5381, 4628, 1174, 402, 314, 2737, 503, 3411, 6197, 14, 1362, 730, 26, 2155, 1362, 849, 26, 283, 5066, 7, 2043, 4756, 63, 23774, 26, 1362, 1369, 26, 267, 446, 12030, 5800, 31363, 334, 8199, 619, 9, 2225, 14, 1362, 730, 26, 2155, 2043, 2784, 26, 1362, 1369, 26, 267, 446, 18276, 536, 503, 2870, 402, 314, 5957, 10391, 2784, 14, 267, 446, 1415, 473, 8, 7436, 9, 503, 473, 8, 4296, 63, 23774, 9, 787, 2741, 14, 2043, 2199, 26, 1362, 1369, 26, 267, 446, 18276, 536, 503, 2870, 402, 314, 2199, 14, 1362, 1015, 63, 3270, 26, 298, 18, 14, 18, 2, 2043, 5957, 63, 5964, 63, 6142, 26, 1362, 1369, 26, 267, 446, 710, 3531, 2287, 2633, 367, 314, 5957, 10391, 2784, 14, 7048, 881, 365, 282, 2600, 543, 314, 6303, 536, 503, 2870, 334, 5327, 9, 436, 314, 3531, 881, 2287, 370, 5090, 641, 314, 6303, 334, 711, 680, 982, 949, 3531, 365, 2013, 12, 881, 1373, 365, 5847, 7943, 687, 626, 6303, 14, 2043, 8386, 26, 1362, 1369, 26, 267, 446, 3820, 402, 18709, 370, 6554, 370, 314, 6197, 5007, 3217, 14, 3758, 881, 10391, 4568, 543, 314, 6303, 911, 506, 5847, 10102, 881, 543, 314, 6197, 1159, 5007, 3217, 14, 881, 1010, 1865, 370, 5647, 376, 3384, 2287, 3365, 687, 314, 849, 881, 10391, 12, 3214, 787, 3032, 465, 2600, 543, 2883, 465, 2784, 881, 536, 503, 2870, 8, 846, 395, 6303, 536, 503, 2870, 334, 5327, 9, 436, 314, 3531, 402, 881, 1844, 334, 7314, 8996, 9, 687, 314, 2784, 14, 881, 2876, 3247, 8706, 8996, 365, 14115, 1415, 1380, 282, 3663, 6197, 1929, 881, 370, 506, 8539, 370, 282, 2849, 6303, 367, 1314, 314, 849, 10391, 965, 881, 2757, 2575, 1202, 14, 2043, 14962, 63, 2619, 26, 1362, 1369, 26, 2126, 446, 27662, 14, 5543, 1150, 367, 8552, 7163, 199, 7538, 26, 2097, 8512, 9277, 937, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 282, 3486, 6197, 12, 440, 10102, 370, 282, 10391, 503, 18709, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 3486, 63, 4995, 199, 199, 3, 2790, 282, 3486, 6197, 12, 440, 10102, 370, 282, 10391, 503, 18709, 367, 282, 1627, 2199, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 3486, 63, 4995, 272, 2199, 26, 3002, 5468, 199, 199, 3, 10560, 282, 6197, 10102, 370, 1599, 63, 1200, 17, 641, 376, 6509, 20, 6303, 436, 1373, 199, 3, 5007, 6303, 3217, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 6197, 17, 272, 2784, 26, 1599, 63, 1200, 17, 272, 5957, 63, 5964, 63, 6142, 26, 489, 446, 6303, 26, 4575, 13, 5327, 267, 3384, 26, 24911, 14, 1194, 14, 20, 14, 18, 272, 8386, 26, 489, 446, 5726, 13, 5327, 199, 199, 3, 2790, 4573, 6197, 543, 2877, 5007, 6303, 8386, 14, 4395, 543, 922, 3247, 1844, 199, 3, 3384, 436, 4573, 543, 849, 10391, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 6197, 18, 272, 2784, 26, 1599, 63, 1200, 17, 272, 8386, 26, 489, 446, 1851, 26, 5726, 13, 846, 267, 6303, 26, 5726, 13, 5327, 267, 8706, 8996, 26, 1616, 14, 17, 14, 17, 14, 709, 489, 446, 2199, 13, 5327, 199, 199, 3, 2790, 4573, 6197, 543, 2877, 5007, 6303, 3217, 14, 4395, 543, 922, 3247, 1844, 199, 3, 3384, 436, 436, 4573, 543, 849, 10391, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 6197, 18, 272, 2784, 26, 1599, 63, 1200, 17, 272, 8386, 26, 489, 446, 1851, 26, 5726, 13, 846, 267, 6303, 26, 5726, 13, 5327, 267, 8706, 8996, 26, 1616, 14, 17, 14, 17, 14, 709, 489, 446, 2199, 13, 5327, 199, 199, 3, 2790, 4573, 6197, 543, 2877, 5007, 6303, 3217, 14, 1373, 543, 221, 922, 3247, 1844, 199, 3, 3384, 436, 436, 4573, 221, 543, 849, 10391, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 6197, 18, 272, 2784, 26, 1599, 63, 1200, 17, 272, 8386, 26, 489, 446, 1851, 26, 5726, 13, 846, 267, 6303, 26, 5726, 13, 5327, 267, 8706, 8996, 26, 1616, 14, 17, 14, 17, 14, 709, 489, 446, 2199, 13, 5327, 199, 199, 3, 6162, 3411, 6197, 17, 5957, 10391, 370, 2387, 314, 6509, 22, 6303, 14, 199 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 26, 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, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 747, 63, 4995, 199, 3612, 63, 1802, 26, 2790, 503, 3145, 24464, 687, 14260, 199, 11036, 63, 9970, 63, 7677, 26, 13869, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 2502, 26, 298, 36, 17204, 5244, 264, 3569, 66, 18359, 8593, 2662, 264, 3569, 2924, 199, 1802, 26, 2043, 446, 2790, 503, 8496, 24464, 687, 14260, 14, 4580, 15401, 30422, 6127, 1362, 24464, 370, 8663, 314, 2011, 536, 12, 642, 859, 655, 509, 823, 536, 15439, 31820, 1362, 370, 506, 1655, 922, 21428, 14, 199, 1419, 26, 2043, 1174, 26, 1362, 1369, 26, 267, 446, 1010, 10188, 6387, 1174, 402, 314, 2073, 1362, 3415, 26, 788, 1881, 297, 283, 5575, 418, 1362, 849, 26, 3451, 2043, 536, 26, 1362, 1369, 26, 267, 446, 2812, 370, 506, 8120, 370, 314, 6197, 1362, 1415, 26, 2549, 2043, 4628, 63, 929, 63, 384, 26, 1362, 1369, 26, 267, 446, 1487, 5381, 4628, 1174, 402, 314, 2737, 503, 3411, 6197, 14, 1362, 730, 26, 2155, 1362, 849, 26, 283, 5066, 7, 2043, 4756, 63, 23774, 26, 1362, 1369, 26, 267, 446, 12030, 5800, 31363, 334, 8199, 619, 9, 2225, 14, 1362, 730, 26, 2155, 2043, 2784, 26, 1362, 1369, 26, 267, 446, 18276, 536, 503, 2870, 402, 314, 5957, 10391, 2784, 14, 267, 446, 1415, 473, 8, 7436, 9, 503, 473, 8, 4296, 63, 23774, 9, 787, 2741, 14, 2043, 2199, 26, 1362, 1369, 26, 267, 446, 18276, 536, 503, 2870, 402, 314, 2199, 14, 1362, 1015, 63, 3270, 26, 298, 18, 14, 18, 2, 2043, 5957, 63, 5964, 63, 6142, 26, 1362, 1369, 26, 267, 446, 710, 3531, 2287, 2633, 367, 314, 5957, 10391, 2784, 14, 7048, 881, 365, 282, 2600, 543, 314, 6303, 536, 503, 2870, 334, 5327, 9, 436, 314, 3531, 881, 2287, 370, 5090, 641, 314, 6303, 334, 711, 680, 982, 949, 3531, 365, 2013, 12, 881, 1373, 365, 5847, 7943, 687, 626, 6303, 14, 2043, 8386, 26, 1362, 1369, 26, 267, 446, 3820, 402, 18709, 370, 6554, 370, 314, 6197, 5007, 3217, 14, 3758, 881, 10391, 4568, 543, 314, 6303, 911, 506, 5847, 10102, 881, 543, 314, 6197, 1159, 5007, 3217, 14, 881, 1010, 1865, 370, 5647, 376, 3384, 2287, 3365, 687, 314, 849, 881, 10391, 12, 3214, 787, 3032, 465, 2600, 543, 2883, 465, 2784, 881, 536, 503, 2870, 8, 846, 395, 6303, 536, 503, 2870, 334, 5327, 9, 436, 314, 3531, 402, 881, 1844, 334, 7314, 8996, 9, 687, 314, 2784, 14, 881, 2876, 3247, 8706, 8996, 365, 14115, 1415, 1380, 282, 3663, 6197, 1929, 881, 370, 506, 8539, 370, 282, 2849, 6303, 367, 1314, 314, 849, 10391, 965, 881, 2757, 2575, 1202, 14, 2043, 14962, 63, 2619, 26, 1362, 1369, 26, 2126, 446, 27662, 14, 5543, 1150, 367, 8552, 7163, 199, 7538, 26, 2097, 8512, 9277, 937, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 282, 3486, 6197, 12, 440, 10102, 370, 282, 10391, 503, 18709, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 3486, 63, 4995, 199, 199, 3, 2790, 282, 3486, 6197, 12, 440, 10102, 370, 282, 10391, 503, 18709, 367, 282, 1627, 2199, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 3486, 63, 4995, 272, 2199, 26, 3002, 5468, 199, 199, 3, 10560, 282, 6197, 10102, 370, 1599, 63, 1200, 17, 641, 376, 6509, 20, 6303, 436, 1373, 199, 3, 5007, 6303, 3217, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 6197, 17, 272, 2784, 26, 1599, 63, 1200, 17, 272, 5957, 63, 5964, 63, 6142, 26, 489, 446, 6303, 26, 4575, 13, 5327, 267, 3384, 26, 24911, 14, 1194, 14, 20, 14, 18, 272, 8386, 26, 489, 446, 5726, 13, 5327, 199, 199, 3, 2790, 4573, 6197, 543, 2877, 5007, 6303, 8386, 14, 4395, 543, 922, 3247, 1844, 199, 3, 3384, 436, 4573, 543, 849, 10391, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 6197, 18, 272, 2784, 26, 1599, 63, 1200, 17, 272, 8386, 26, 489, 446, 1851, 26, 5726, 13, 846, 267, 6303, 26, 5726, 13, 5327, 267, 8706, 8996, 26, 1616, 14, 17, 14, 17, 14, 709, 489, 446, 2199, 13, 5327, 199, 199, 3, 2790, 4573, 6197, 543, 2877, 5007, 6303, 3217, 14, 4395, 543, 922, 3247, 1844, 199, 3, 3384, 436, 436, 4573, 543, 849, 10391, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 6197, 18, 272, 2784, 26, 1599, 63, 1200, 17, 272, 8386, 26, 489, 446, 1851, 26, 5726, 13, 846, 267, 6303, 26, 5726, 13, 5327, 267, 8706, 8996, 26, 1616, 14, 17, 14, 17, 14, 709, 489, 446, 2199, 13, 5327, 199, 199, 3, 2790, 4573, 6197, 543, 2877, 5007, 6303, 3217, 14, 1373, 543, 221, 922, 3247, 1844, 199, 3, 3384, 436, 436, 4573, 221, 543, 849, 10391, 14, 199, 13, 747, 63, 4995, 26, 272, 8002, 26, 3002, 4091, 272, 1174, 26, 3451, 272, 536, 26, 6197, 18, 272, 2784, 26, 1599, 63, 1200, 17, 272, 8386, 26, 489, 446, 1851, 26, 5726, 13, 846, 267, 6303, 26, 5726, 13, 5327, 267, 8706, 8996, 26, 1616, 14, 17, 14, 17, 14, 709, 489, 446, 2199, 13, 5327, 199, 199, 3, 6162, 3411, 6197, 17, 5957, 10391, 370, 2387, 314, 6509, 22, 6303, 14, 199, 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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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 ]
AlanZatarain/pysal
pysal/weights/Distance.py
5
14395
""" Distance based spatial weights """ __author__ = "Sergio J. Rey <srey@asu.edu> " import pysal import scipy.spatial from pysal.common import * from pysal.weights import W from scipy import sparse __all__ = ["knnW", "Kernel", "DistanceBand"] def knnW(data, k=2, p=2, ids=None): """ Creates nearest neighbor weights matrix based on k nearest neighbors. Parameters ---------- data : array (n,k) or KDTree where KDtree.data is array (n,k) n observations on k characteristics used to measure distances between the n objects k : int number of nearest neighbors p : float Minkowski p-norm distance metric parameter: 1<=p<=infinity 2: Euclidean distance 1: Manhattan distance ids : list identifiers to attach to each observation Returns ------- w : W instance Weights object with binary weights Examples -------- >>> x,y=np.indices((5,5)) >>> x.shape=(25,1) >>> y.shape=(25,1) >>> data=np.hstack([x,y]) >>> wnn2=knnW(data,k=2) >>> wnn4=knnW(data,k=4) >>> wnn4.neighbors[0] [1, 5, 6, 2] >>> wnn4.neighbors[5] [0, 6, 10, 1] >>> wnn2.neighbors[0] [1, 5] >>> wnn2.neighbors[5] [0, 6] >>> wnn2.pct_nonzero 0.080000000000000002 >>> wnn4.pct_nonzero 0.16 >>> wnn3e=knnW(data,p=2,k=3) >>> wnn3e.neighbors[0] [1, 5, 6] >>> wnn3m=knnW(data,p=1,k=3) >>> wnn3m.neighbors[0] [1, 5, 2] Notes ----- Ties between neighbors of equal distance are arbitrarily broken. See Also -------- pysal.weights.W """ # handle data if issubclass(type(data), scipy.spatial.KDTree): kd = data data = kd.data elif type(data).__name__ == 'ndarray': kd = KDTree(data) else: print 'Unsupported type' # calculate nnq = kd.query(data, k=k + 1, p=p) info = nnq[1] neighbors = {} weights = {} if ids: idset = np.array(ids) else: idset = np.arange(len(info)) for i, row in enumerate(info): row = row.tolist() row.remove(i) neighbors[idset[i]] = list(idset[row]) weights[idset[i]] = [1] * len(neighbors[idset[i]]) return pysal.weights.W(neighbors, weights=weights, id_order=ids) class Kernel(W): """Spatial weights based on kernel functions Parameters ---------- data : array (n,k) or KDTree where KDtree.data is array (n,k) n observations on k characteristics used to measure distances between the n objects bandwidth : float or array-like (optional) the bandwidth :math:`h_i` for the kernel. fixed : binary If true then :math:`h_i=h \\forall i`. If false then bandwidth is adaptive across observations. k : int the number of nearest neighbors to use for determining bandwidth. For fixed bandwidth, :math:`h_i=max(dknn) \\forall i` where :math:`dknn` is a vector of k-nearest neighbor distances (the distance to the kth nearest neighbor for each observation). For adaptive bandwidths, :math:`h_i=dknn_i` function : string {'triangular','uniform','quadratic','quartic','gaussian'} kernel function defined as follows with .. math:: z_{i,j} = d_{i,j}/h_i triangular .. math:: K(z) = (1 - |z|) \ if |z| \le 1 uniform .. math:: K(z) = 1/2 \ if |z| \le 1 quadratic .. math:: K(z) = (3/4)(1-z^2) \ if |z| \le 1 quartic .. math:: K(z) = (15/16)(1-z^2)^2 \ if |z| \le 1 gaussian .. math:: K(z) = (2\pi)^{(-1/2)} exp(-z^2 / 2) eps : float adjustment to ensure knn distance range is closed on the knnth observations Examples -------- >>> points=[(10, 10), (20, 10), (40, 10), (15, 20), (30, 20), (30, 30)] >>> kw=Kernel(points) >>> kw.weights[0] [1.0, 0.500000049999995, 0.4409830615267465] >>> kw.neighbors[0] [0, 1, 3] >>> kw.bandwidth array([[ 20.000002], [ 20.000002], [ 20.000002], [ 20.000002], [ 20.000002], [ 20.000002]]) >>> kw15=Kernel(points,bandwidth=15.0) >>> kw15[0] {0: 1.0, 1: 0.33333333333333337, 3: 0.2546440075000701} >>> kw15.neighbors[0] [0, 1, 3] >>> kw15.bandwidth array([[ 15.], [ 15.], [ 15.], [ 15.], [ 15.], [ 15.]]) Adaptive bandwidths user specified >>> bw=[25.0,15.0,25.0,16.0,14.5,25.0] >>> kwa=Kernel(points,bandwidth=bw) >>> kwa.weights[0] [1.0, 0.6, 0.552786404500042, 0.10557280900008403] >>> kwa.neighbors[0] [0, 1, 3, 4] >>> kwa.bandwidth array([[ 25. ], [ 15. ], [ 25. ], [ 16. ], [ 14.5], [ 25. ]]) Endogenous adaptive bandwidths >>> kwea=Kernel(points,fixed=False) >>> kwea.weights[0] [1.0, 0.10557289844279438, 9.99999900663795e-08] >>> kwea.neighbors[0] [0, 1, 3] >>> kwea.bandwidth array([[ 11.18034101], [ 11.18034101], [ 20.000002 ], [ 11.18034101], [ 14.14213704], [ 18.02775818]]) Endogenous adaptive bandwidths with Gaussian kernel >>> kweag=Kernel(points,fixed=False,function='gaussian') >>> kweag.weights[0] [0.3989422804014327, 0.2674190291577696, 0.2419707487162134] >>> kweag.bandwidth array([[ 11.18034101], [ 11.18034101], [ 20.000002 ], [ 11.18034101], [ 14.14213704], [ 18.02775818]]) """ def __init__(self, data, bandwidth=None, fixed=True, k=2, function='triangular', eps=1.0000001, ids=None): if issubclass(type(data), scipy.spatial.KDTree): self.kdt = data self.data = self.kdt.data data = self.data else: self.data = data self.kdt = KDTree(self.data) self.k = k + 1 self.function = function.lower() self.fixed = fixed self.eps = eps if bandwidth: try: bandwidth = np.array(bandwidth) bandwidth.shape = (len(bandwidth), 1) except: bandwidth = np.ones((len(data), 1), 'float') * bandwidth self.bandwidth = bandwidth else: self._set_bw() self._eval_kernel() neighbors, weights = self._k_to_W(ids) W.__init__(self, neighbors, weights, ids) def _k_to_W(self, ids=None): allneighbors = {} weights = {} if ids: ids = np.array(ids) else: ids = np.arange(len(self.data)) for i, neighbors in enumerate(self.kernel): if len(self.neigh[i]) == 0: allneighbors[ids[i]] = [] weights[ids[i]] = [] else: allneighbors[ids[i]] = list(ids[self.neigh[i]]) weights[ids[i]] = self.kernel[i].tolist() return allneighbors, weights def _set_bw(self): dmat, neigh = self.kdt.query(self.data, k=self.k) if self.fixed: # use max knn distance as bandwidth bandwidth = dmat.max() * self.eps n = len(dmat) self.bandwidth = np.ones((n, 1), 'float') * bandwidth else: # use local max knn distance self.bandwidth = dmat.max(axis=1) * self.eps self.bandwidth.shape = (self.bandwidth.size, 1) # identify knn neighbors for each point nnq = self.kdt.query(self.data, k=self.k) self.neigh = nnq[1] def _eval_kernel(self): # get points within bandwidth distance of each point if not hasattr(self, 'neigh'): kdtq = self.kdt.query_ball_point neighbors = [kdtq(self.data[i], r=bwi[0]) for i, bwi in enumerate(self.bandwidth)] self.neigh = neighbors # get distances for neighbors data = np.array(self.data) bw = self.bandwidth kdtq = self.kdt.query z = [] for i, nids in enumerate(self.neigh): di, ni = kdtq(self.data[i], k=len(nids)) zi = np.array([dict(zip(ni, di))[nid] for nid in nids]) / bw[i] z.append(zi) zs = z # functions follow Anselin and Rey (2010) table 5.4 if self.function == 'triangular': self.kernel = [1 - z for z in zs] elif self.function == 'uniform': self.kernel = [np.ones(z.shape) * 0.5 for z in zs] elif self.function == 'quadratic': self.kernel = [(3. / 4) * (1 - z ** 2) for z in zs] elif self.function == 'quartic': self.kernel = [(15. / 16) * (1 - z ** 2) ** 2 for z in zs] elif self.function == 'gaussian': c = np.pi * 2 c = c ** (-0.5) self.kernel = [c * np.exp(-(z ** 2) / 2.) for z in zs] else: print 'Unsupported kernel function', self.function class DistanceBand(W): """Spatial weights based on distance band Parameters ---------- data : array (n,k) or KDTree where KDtree.data is array (n,k) n observations on k characteristics used to measure distances between the n objects threshold : float distance band p : float Minkowski p-norm distance metric parameter: 1<=p<=infinity 2: Euclidean distance 1: Manhattan distance binary : binary If true w_{ij}=1 if d_{i,j}<=threshold, otherwise w_{i,j}=0 If false wij=dij^{alpha} alpha : float distance decay parameter for weight (default -1.0) if alpha is positive the weights will not decline with distance. If binary is True, alpha is ignored Examples -------- >>> points=[(10, 10), (20, 10), (40, 10), (15, 20), (30, 20), (30, 30)] >>> w=DistanceBand(points,threshold=11.2) >>> w.weights {0: [1, 1], 1: [1, 1], 2: [], 3: [1, 1], 4: [1], 5: [1]} >>> w.neighbors {0: [1, 3], 1: [0, 3], 2: [], 3: [0, 1], 4: [5], 5: [4]} inverse distance weights >>> w=DistanceBand(points,threshold=11.2,binary=False) >>> w.weights[0] [0.10000000000000001, 0.089442719099991588] >>> w.neighbors[0] [1, 3] >>> gravity weights >>> w=DistanceBand(points,threshold=11.2,binary=False,alpha=-2.) >>> w.weights[0] [0.01, 0.0079999999999999984] Notes ----- this was initially implemented running scipy 0.8.0dev (in epd 6.1). earlier versions of scipy (0.7.0) have a logic bug in scipy/sparse/dok.py so serge changed line 221 of that file on sal-dev to fix the logic bug """ def __init__(self, data, threshold, p=2, alpha=-1.0, binary=True, ids=None): """ Casting to floats is a work around for a bug in scipy.spatial. See detail in pysal issue #126 """ if issubclass(type(data), scipy.spatial.KDTree): self.kd = data self.data = self.kd.data else: try: data = np.asarray(data) if data.dtype.kind != 'f': data = data.astype(float) self.data = data self.kd = KDTree(self.data) except: raise ValueError("Could not make array from data") self.p = p self.threshold = threshold self.binary = binary self.alpha = alpha self._band() neighbors, weights = self._distance_to_W(ids) W.__init__(self, neighbors, weights, ids) def _band(self): """ find all pairs within threshold """ kd = self.kd #ns=[kd.query_ball_point(point,self.threshold) for point in self.data] ns = kd.query_ball_tree(kd, self.threshold) self._nmat = ns def _distance_to_W(self, ids=None): allneighbors = {} weights = {} if ids: ids = np.array(ids) else: ids = np.arange(len(self._nmat)) if self.binary: for i, neighbors in enumerate(self._nmat): ns = [ni for ni in neighbors if ni != i] neigh = list(ids[ns]) if len(neigh) == 0: allneighbors[ids[i]] = [] weights[ids[i]] = [] else: allneighbors[ids[i]] = neigh weights[ids[i]] = [1] * len(ns) else: self.dmat = self.kd.sparse_distance_matrix( self.kd, max_distance=self.threshold) for i, neighbors in enumerate(self._nmat): ns = [ni for ni in neighbors if ni != i] neigh = list(ids[ns]) if len(neigh) == 0: allneighbors[ids[i]] = [] weights[ids[i]] = [] else: allneighbors[ids[i]] = neigh weights[ids[i]] = [self.dmat[( i, j)] ** self.alpha for j in ns] return allneighbors, weights if __name__ == "__main__": x = np.arange(1, 5) n = len(x) data = [] row = [] col = [] rdata = [] for i in range(n - 1): data.extend(x[i + 1:]) rdata.extend((x[i] * np.ones((1, n - i - 1))).tolist()[0] ) row.extend([i] * (n - i - 1)) col.extend(range(i + 1, n)) L = sparse.csr_matrix((data, (row, col)), shape=(n, n)) R = sparse.csr_matrix((rdata, (row, col)), shape=(n, n)) dlr = L - R D = dlr.multiply(dlr)
bsd-3-clause
[ 624, 199, 10076, 4079, 11469, 4931, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 1505, 71, 2308, 1603, 14, 799, 89, 665, 83, 17885, 32, 305, 85, 14, 8654, 30, 298, 199, 199, 646, 10382, 279, 199, 646, 7026, 14, 11679, 199, 504, 10382, 279, 14, 2330, 492, 627, 199, 504, 10382, 279, 14, 4916, 492, 644, 199, 199, 504, 7026, 492, 5178, 199, 199, 363, 452, 363, 275, 2097, 75, 4411, 55, 401, 298, 14127, 401, 298, 10076, 11675, 937, 421, 199, 318, 1022, 4411, 55, 8, 576, 12, 1022, 29, 18, 12, 299, 29, 18, 12, 2762, 29, 403, 304, 272, 408, 272, 10560, 17173, 15503, 4931, 3634, 4079, 641, 1022, 17173, 272, 15845, 14, 339, 3897, 272, 4143, 339, 666, 755, 520, 1625, 334, 78, 12, 75, 9, 503, 31368, 3987, 2382, 31368, 2350, 14, 576, 365, 1625, 334, 78, 12, 75, 9, 326, 302, 19739, 641, 1022, 2735, 6236, 8323, 1202, 370, 9775, 326, 15108, 3382, 314, 302, 2251, 272, 1022, 3515, 520, 1109, 326, 1329, 402, 17173, 15845, 272, 299, 3515, 520, 2069, 326, 603, 2292, 19844, 299, 13, 4791, 6033, 6370, 2725, 26, 326, 413, 12932, 80, 12932, 262, 9693, 326, 499, 26, 662, 24941, 6033, 326, 413, 26, 4688, 72, 6796, 290, 6033, 272, 2762, 263, 520, 769, 326, 14154, 370, 6554, 370, 1924, 20038, 272, 1803, 272, 5514, 339, 336, 260, 520, 644, 1256, 355, 2136, 2492, 909, 543, 3366, 4931, 2378, 6058, 272, 3001, 339, 1306, 671, 12, 89, 29, 1590, 14, 4108, 1332, 21, 12, 21, 430, 272, 1306, 671, 14, 1392, 2687, 821, 12, 17, 9, 272, 1306, 612, 14, 1392, 2687, 821, 12, 17, 9, 272, 1306, 666, 29, 1590, 14, 20949, 779, 88, 12, 89, 566, 272, 1306, 336, 4411, 18, 29, 75, 4411, 55, 8, 576, 12, 75, 29, 18, 9, 272, 1306, 336, 4411, 20, 29, 75, 4411, 55, 8, 576, 12, 75, 29, 20, 9, 272, 1306, 336, 4411, 20, 14, 11113, 59, 16, 61, 272, 359, 17, 12, 959, 12, 1227, 12, 499, 61, 272, 1306, 336, 4411, 20, 14, 11113, 59, 21, 61, 272, 359, 16, 12, 1227, 12, 1616, 12, 413, 61, 272, 1306, 336, 4411, 18, 14, 11113, 59, 16, 61, 272, 359, 17, 12, 959, 61, 272, 1306, 336, 4411, 18, 14, 11113, 59, 21, 61, 272, 359, 16, 12, 1227, 61, 272, 1306, 336, 4411, 18, 14, 20778, 63, 10262, 272, 378, 14, 2036, 17994, 996, 272, 1306, 336, 4411, 20, 14, 20778, 63, 10262, 272, 378, 14, 975, 272, 1306, 336, 4411, 19, 69, 29, 75, 4411, 55, 8, 576, 12, 80, 29, 18, 12, 75, 29, 19, 9, 272, 1306, 336, 4411, 19, 69, 14, 11113, 59, 16, 61, 272, 359, 17, 12, 959, 12, 1227, 61, 272, 1306, 336, 4411, 19, 77, 29, 75, 4411, 55, 8, 576, 12, 80, 29, 17, 12, 75, 29, 19, 9, 272, 1306, 336, 4411, 19, 77, 14, 11113, 59, 16, 61, 272, 359, 17, 12, 959, 12, 499, 61, 2378, 8144, 272, 9063, 339, 377, 1500, 3382, 15845, 402, 4472, 6033, 787, 601, 2075, 82, 11406, 10529, 14, 339, 1666, 6121, 272, 3001, 272, 10382, 279, 14, 4916, 14, 55, 272, 408, 272, 327, 2429, 666, 272, 340, 11602, 8, 466, 8, 576, 395, 7026, 14, 11679, 14, 13368, 3987, 304, 267, 1022, 68, 275, 666, 267, 666, 275, 1022, 68, 14, 576, 272, 916, 730, 8, 576, 2843, 354, 363, 508, 283, 8237, 356, 267, 1022, 68, 275, 31368, 3987, 8, 576, 9, 272, 587, 26, 267, 870, 283, 12647, 221, 730, 7, 339, 327, 8671, 272, 11542, 81, 275, 1022, 68, 14, 1131, 8, 576, 12, 1022, 29, 75, 435, 413, 12, 299, 29, 80, 9, 272, 2256, 275, 11542, 81, 59, 17, 61, 272, 15845, 275, 1052, 272, 4931, 275, 1052, 272, 340, 2762, 26, 267, 1305, 409, 275, 980, 14, 1144, 8, 1580, 9, 272, 587, 26, 267, 1305, 409, 275, 980, 14, 5605, 8, 552, 8, 815, 430, 272, 367, 284, 12, 1962, 315, 3874, 8, 815, 304, 267, 1962, 275, 1962, 14, 13633, 342, 267, 1962, 14, 2168, 8, 73, 9, 267, 15845, 59, 344, 409, 59, 73, 2677, 275, 769, 8, 344, 409, 59, 1143, 566, 267, 4931, 59, 344, 409, 59, 73, 2677, 275, 359, 17, 61, 627, 822, 8, 11113, 59, 344, 409, 59, 73, 3934, 339, 372, 10382, 279, 14, 4916, 14, 55, 8, 11113, 12, 4931, 29, 4916, 12, 1305, 63, 1648, 29, 1580, 9, 421, 199, 533, 24901, 8, 55, 304, 272, 408, 18075, 4931, 4079, 641, 5114, 3423, 2378, 3897, 272, 4143, 339, 666, 263, 520, 1625, 334, 78, 12, 75, 9, 503, 31368, 3987, 2382, 31368, 2350, 14, 576, 365, 1625, 334, 78, 12, 75, 9, 2116, 302, 19739, 641, 1022, 2735, 6236, 8323, 1202, 370, 9775, 2116, 15108, 3382, 314, 302, 2251, 272, 20434, 257, 520, 2069, 503, 1625, 13, 2930, 334, 4144, 9, 2116, 314, 20434, 520, 3442, 1705, 72, 63, 73, 64, 367, 314, 5114, 14, 272, 6317, 755, 520, 3366, 2116, 982, 2549, 2066, 520, 3442, 1705, 72, 63, 73, 29, 72, 8522, 509, 452, 284, 2313, 982, 3055, 2066, 2116, 20434, 365, 1503, 22430, 9371, 19739, 14, 272, 1022, 3698, 520, 1109, 2116, 314, 1329, 402, 17173, 15845, 370, 675, 367, 26638, 2116, 20434, 14, 2104, 6317, 20434, 12, 520, 3442, 1705, 72, 63, 73, 29, 988, 8, 6341, 4411, 9, 8522, 509, 452, 284, 64, 2116, 2382, 520, 3442, 1705, 6341, 4411, 64, 365, 282, 5477, 402, 1022, 13, 16615, 15503, 2116, 15108, 334, 1589, 6033, 370, 314, 1022, 273, 17173, 15503, 367, 1924, 2116, 20038, 680, 221, 2104, 1503, 22430, 20434, 83, 12, 520, 3442, 1705, 72, 63, 73, 29, 6341, 4411, 63, 73, 64, 272, 805, 259, 520, 1059, 791, 29663, 1673, 8830, 1673, 14567, 19826, 1673, 30438, 764, 1673, 22911, 936, 2116, 5114, 805, 3247, 465, 11924, 543, 199, 2116, 2508, 3473, 447, 199, 1993, 1315, 7348, 73, 12, 74, 93, 275, 366, 7348, 73, 12, 74, 5995, 72, 63, 73, 199, 2116, 3229, 11572, 199, 2116, 2508, 3473, 447, 199, 1993, 1804, 8, 90, 9, 275, 334 ]
[ 199, 10076, 4079, 11469, 4931, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 1505, 71, 2308, 1603, 14, 799, 89, 665, 83, 17885, 32, 305, 85, 14, 8654, 30, 298, 199, 199, 646, 10382, 279, 199, 646, 7026, 14, 11679, 199, 504, 10382, 279, 14, 2330, 492, 627, 199, 504, 10382, 279, 14, 4916, 492, 644, 199, 199, 504, 7026, 492, 5178, 199, 199, 363, 452, 363, 275, 2097, 75, 4411, 55, 401, 298, 14127, 401, 298, 10076, 11675, 937, 421, 199, 318, 1022, 4411, 55, 8, 576, 12, 1022, 29, 18, 12, 299, 29, 18, 12, 2762, 29, 403, 304, 272, 408, 272, 10560, 17173, 15503, 4931, 3634, 4079, 641, 1022, 17173, 272, 15845, 14, 339, 3897, 272, 4143, 339, 666, 755, 520, 1625, 334, 78, 12, 75, 9, 503, 31368, 3987, 2382, 31368, 2350, 14, 576, 365, 1625, 334, 78, 12, 75, 9, 326, 302, 19739, 641, 1022, 2735, 6236, 8323, 1202, 370, 9775, 326, 15108, 3382, 314, 302, 2251, 272, 1022, 3515, 520, 1109, 326, 1329, 402, 17173, 15845, 272, 299, 3515, 520, 2069, 326, 603, 2292, 19844, 299, 13, 4791, 6033, 6370, 2725, 26, 326, 413, 12932, 80, 12932, 262, 9693, 326, 499, 26, 662, 24941, 6033, 326, 413, 26, 4688, 72, 6796, 290, 6033, 272, 2762, 263, 520, 769, 326, 14154, 370, 6554, 370, 1924, 20038, 272, 1803, 272, 5514, 339, 336, 260, 520, 644, 1256, 355, 2136, 2492, 909, 543, 3366, 4931, 2378, 6058, 272, 3001, 339, 1306, 671, 12, 89, 29, 1590, 14, 4108, 1332, 21, 12, 21, 430, 272, 1306, 671, 14, 1392, 2687, 821, 12, 17, 9, 272, 1306, 612, 14, 1392, 2687, 821, 12, 17, 9, 272, 1306, 666, 29, 1590, 14, 20949, 779, 88, 12, 89, 566, 272, 1306, 336, 4411, 18, 29, 75, 4411, 55, 8, 576, 12, 75, 29, 18, 9, 272, 1306, 336, 4411, 20, 29, 75, 4411, 55, 8, 576, 12, 75, 29, 20, 9, 272, 1306, 336, 4411, 20, 14, 11113, 59, 16, 61, 272, 359, 17, 12, 959, 12, 1227, 12, 499, 61, 272, 1306, 336, 4411, 20, 14, 11113, 59, 21, 61, 272, 359, 16, 12, 1227, 12, 1616, 12, 413, 61, 272, 1306, 336, 4411, 18, 14, 11113, 59, 16, 61, 272, 359, 17, 12, 959, 61, 272, 1306, 336, 4411, 18, 14, 11113, 59, 21, 61, 272, 359, 16, 12, 1227, 61, 272, 1306, 336, 4411, 18, 14, 20778, 63, 10262, 272, 378, 14, 2036, 17994, 996, 272, 1306, 336, 4411, 20, 14, 20778, 63, 10262, 272, 378, 14, 975, 272, 1306, 336, 4411, 19, 69, 29, 75, 4411, 55, 8, 576, 12, 80, 29, 18, 12, 75, 29, 19, 9, 272, 1306, 336, 4411, 19, 69, 14, 11113, 59, 16, 61, 272, 359, 17, 12, 959, 12, 1227, 61, 272, 1306, 336, 4411, 19, 77, 29, 75, 4411, 55, 8, 576, 12, 80, 29, 17, 12, 75, 29, 19, 9, 272, 1306, 336, 4411, 19, 77, 14, 11113, 59, 16, 61, 272, 359, 17, 12, 959, 12, 499, 61, 2378, 8144, 272, 9063, 339, 377, 1500, 3382, 15845, 402, 4472, 6033, 787, 601, 2075, 82, 11406, 10529, 14, 339, 1666, 6121, 272, 3001, 272, 10382, 279, 14, 4916, 14, 55, 272, 408, 272, 327, 2429, 666, 272, 340, 11602, 8, 466, 8, 576, 395, 7026, 14, 11679, 14, 13368, 3987, 304, 267, 1022, 68, 275, 666, 267, 666, 275, 1022, 68, 14, 576, 272, 916, 730, 8, 576, 2843, 354, 363, 508, 283, 8237, 356, 267, 1022, 68, 275, 31368, 3987, 8, 576, 9, 272, 587, 26, 267, 870, 283, 12647, 221, 730, 7, 339, 327, 8671, 272, 11542, 81, 275, 1022, 68, 14, 1131, 8, 576, 12, 1022, 29, 75, 435, 413, 12, 299, 29, 80, 9, 272, 2256, 275, 11542, 81, 59, 17, 61, 272, 15845, 275, 1052, 272, 4931, 275, 1052, 272, 340, 2762, 26, 267, 1305, 409, 275, 980, 14, 1144, 8, 1580, 9, 272, 587, 26, 267, 1305, 409, 275, 980, 14, 5605, 8, 552, 8, 815, 430, 272, 367, 284, 12, 1962, 315, 3874, 8, 815, 304, 267, 1962, 275, 1962, 14, 13633, 342, 267, 1962, 14, 2168, 8, 73, 9, 267, 15845, 59, 344, 409, 59, 73, 2677, 275, 769, 8, 344, 409, 59, 1143, 566, 267, 4931, 59, 344, 409, 59, 73, 2677, 275, 359, 17, 61, 627, 822, 8, 11113, 59, 344, 409, 59, 73, 3934, 339, 372, 10382, 279, 14, 4916, 14, 55, 8, 11113, 12, 4931, 29, 4916, 12, 1305, 63, 1648, 29, 1580, 9, 421, 199, 533, 24901, 8, 55, 304, 272, 408, 18075, 4931, 4079, 641, 5114, 3423, 2378, 3897, 272, 4143, 339, 666, 263, 520, 1625, 334, 78, 12, 75, 9, 503, 31368, 3987, 2382, 31368, 2350, 14, 576, 365, 1625, 334, 78, 12, 75, 9, 2116, 302, 19739, 641, 1022, 2735, 6236, 8323, 1202, 370, 9775, 2116, 15108, 3382, 314, 302, 2251, 272, 20434, 257, 520, 2069, 503, 1625, 13, 2930, 334, 4144, 9, 2116, 314, 20434, 520, 3442, 1705, 72, 63, 73, 64, 367, 314, 5114, 14, 272, 6317, 755, 520, 3366, 2116, 982, 2549, 2066, 520, 3442, 1705, 72, 63, 73, 29, 72, 8522, 509, 452, 284, 2313, 982, 3055, 2066, 2116, 20434, 365, 1503, 22430, 9371, 19739, 14, 272, 1022, 3698, 520, 1109, 2116, 314, 1329, 402, 17173, 15845, 370, 675, 367, 26638, 2116, 20434, 14, 2104, 6317, 20434, 12, 520, 3442, 1705, 72, 63, 73, 29, 988, 8, 6341, 4411, 9, 8522, 509, 452, 284, 64, 2116, 2382, 520, 3442, 1705, 6341, 4411, 64, 365, 282, 5477, 402, 1022, 13, 16615, 15503, 2116, 15108, 334, 1589, 6033, 370, 314, 1022, 273, 17173, 15503, 367, 1924, 2116, 20038, 680, 221, 2104, 1503, 22430, 20434, 83, 12, 520, 3442, 1705, 72, 63, 73, 29, 6341, 4411, 63, 73, 64, 272, 805, 259, 520, 1059, 791, 29663, 1673, 8830, 1673, 14567, 19826, 1673, 30438, 764, 1673, 22911, 936, 2116, 5114, 805, 3247, 465, 11924, 543, 199, 2116, 2508, 3473, 447, 199, 1993, 1315, 7348, 73, 12, 74, 93, 275, 366, 7348, 73, 12, 74, 5995, 72, 63, 73, 199, 2116, 3229, 11572, 199, 2116, 2508, 3473, 447, 199, 1993, 1804, 8, 90, 9, 275, 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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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 ]
gingi99/research_dr
python/MLEM2/discrimination.py
1
12551
# coding: utf-8 # python 3.5 import sys import os sys.path.append('/Users/ooki/git/research_dr/python/MLEM2') sys.path.append(os.path.dirname(os.path.abspath("__file__"))+'/../MLEM2') from sklearn.metrics import accuracy_score import copy import importlib import mlem2 import LERS importlib.reload(mlem2) importlib.reload(LERS) from rules_stat import getNumRulesClass from rules_stat import getRulesValueCount # ===================================== # 公正配慮すべき属性list_sをdecision_tableから削除する # ===================================== def delDiscriminativeAttributes(decision_table, list_s): return(decision_table.drop(list_s, axis=1)) # ===================================== # Rules のうち 属性attr / 基本条件 e(属性attrの値v) を含むルールセットの数を返す # ===================================== def getNumRulesIncludeAttr(list_rules, attr) : rules = [r for r in list_rules if attr in r.getKey()] return(len(rules)) def getNumRulesIncludeE(list_rules, attr, v) : rules = [r for r in list_rules if r.getValue(attr) == v] return(len(rules)) def getNumRulesClassIncludeAttr(list_rules, attr, cls) : rules = [r for r in list_rules if (attr in r.getKey()) and r.getConsequent() == cls] return(len(rules)) def getNumRulesClassIncludeE(list_rules, attr, v, cls) : rules = [r for r in list_rules if r.getValue(attr) == v and r.getConsequent() == cls] return(len(rules)) def getNumRulesIncludeMultipleE(list_rules, dict_attribute_value): tmp_rules = list_rules for attr in dict_attribute_value.keys(): for v in dict_attribute_value[attr] : tmp_rules = [r for r in tmp_rules if r.getValue(attr) == v] return(len(tmp_rules)) def getNumRulesClassIncludeMultipleE(list_rules, dict_attribute_value, cls): tmp_rules = list_rules for attr in dict_attribute_value.keys(): for v in dict_attribute_value[attr] : tmp_rules = [r for r in tmp_rules if r.getValue(attr) == v and r.getConsequent() == cls] return(len(tmp_rules)) # ====================================== # 分割表a, b, c, d を返す # ====================================== def getContingencyTable(list_rules, dict_attribute_value, CLASSES): N = len(list_rules) n1 = getNumRulesClass(list_rules, CLASSES["bad"]) n2 = getNumRulesClass(list_rules, CLASSES["good"]) a = getNumRulesClassIncludeMultipleE(list_rules, dict_attribute_value, CLASSES["bad"]) b = n1 - a c = getNumRulesClassIncludeMultipleE(list_rules, dict_attribute_value, CLASSES["good"]) d = n2 - c return(a,b,c,d) # ===================================== # Rules のうち 属性attr / 基本条件 e(属性attrの値v) を含むルールセットを返す # ===================================== def getRulesIncludeAttr(list_rules, attr) : rules = [r for r in list_rules if attr in r.getKey()] return(rules) def getRulesIncludeE(list_rules, attr, v) : rules = [r for r in list_rules if r.getValue(attr) == v] return(rules) # ===================================== # Rules のうち 属性attr / 基本条件e を 含まないルールセットを返す # ===================================== def getRulesExcludeAttr(list_rules, attr) : rules = [r for r in list_rules if not attr in r.getKey()] return(rules) def getRulesExcludeE(list_rules, attr, v) : rules = [r for r in list_rules if r.getValue(attr) != v] return(rules) # ===================================== # Rules のうち 属性attr / 基本条件e を 削除したルールセットを返す # Rule の 属性attr / 基本条件 e を削除したルールを返す # ===================================== def getRulesDelAttr(list_rules, attr) : rules = [delAttrFromRule(r, attr) for r in list_rules] return(rules) def getRulesDelE(list_rules, attr, v) : rules = [delEFromRule(r, attr, v) for r in list_rules] return(rules) def delAttrFromRule(rule, attr) : rule_new = copy.deepcopy(rule) rule_new.delKey(attr) return(rule_new) def delEFromRule(rule, attr, v) : if rule.getValue(attr) == v : return(delAttrFromRule(rule, attr)) else : return(rule) # ===================================== # alpha差別的な Rule を含まないルールセットを返す # alpha差別的な Rule の 基本条件 e を削除したルールを返す # ===================================== def getAlphaRulesExcludeE(list_rules, attr, v, decision_table, list_judgeNominal, alpha = 0) : rules = [r for r in list_rules if getElift(r, attr, v, decision_table, list_judgeNominal) <= alpha ] return(rules) def getAlphaRulesDelE(list_rules, attr, v, decision_table, list_judgeNominal, alpha = 0) : rules = [delEFromAlphaRule(r, attr, v, decision_table, list_judgeNominal, alpha = 0) for r in list_rules] return(rules) def delEFromAlphaRule(rule, attr, v, decision_table, list_judgeNominal, alpha = 0): if rule.getValue(attr) == v : elift = getElift(rule, attr, v, decision_table, list_judgeNominal) if elift > alpha : return(delAttrFromRule(rule, attr)) else : return(rule) else : return(rule) # ===================================== # M差別的な Rule の を含まない / 基本条件 e を削除したルールセットを返す # ===================================== def getMRulesFUN(list_rules, attr, v, target_cls, DELFUN, m = 0) : num_target_cls, num_other_cls, list_num_other_cls = 0, 0, [] classes = mlem2.getEstimatedClass(list_rules) for cls in classes : if cls == target_cls : num_target_cls = getNumRulesClassIncludeE(list_rules, attr, v, cls) else : list_num_other_cls.append(getNumRulesClassIncludeE(list_rules, attr, v, cls)) num_other_cls = sum(list_num_other_cls) / len(list_num_other_cls) #複数クラスの場合を考慮 if (num_target_cls / (num_target_cls + num_other_cls)) > m : #m保護なら return(list_rules) else : return(DELFUN(list_rules, attr, v)) # ===================================== # 配慮変数sをもつ対象だけの決定表を作る # ===================================== def createDTSuppoterdbyRule(list_rules, attr, v, cls, decision_table): target_indice = [] target_rules = [r for r in list_rules if r.getValue(attr) == v and r.getConsequent() == cls] for rule in target_rules: target_indice.extend(rule.getSupport()) target_indice = list(set(target_indice)) target_indice = sorted(target_indice) new_decision_table = decision_table_train.ix[target_indice] new_decision_class = new_decision_table[new_decision_table.columns[-1]].values.tolist() return(new_decision_table, new_decision_class) # 有利な決定クラスのルールを減らす関数 配慮変数sを # ===================================== # Rule の 配慮変数s での decision_tableにおける elift # ===================================== def getElift(rule, attr, v, decision_table, list_judgeNominal): supp, conf = LERS.getSupportConfidence(rule, decision_table, list_judgeNominal) rule_s = delEFromRule(rule, attr, v) supp_s, conf_s = LERS.getSupportConfidence(rule_s, decision_table, list_judgeNominal) if conf_s == 0: elift = 999 else : elift = conf / conf_s return(elift) # ===================================== # Rule の 配慮変数s での decision_tableにおける slift # ===================================== def getSlift(rule, s, decision_table, operator): conditions = mlem2.getConditionValues(decision_table, s) clifts = [getClift(rule, s, c, decision_table) for c in conditions] slift = operator(clifts) return(slift) # ===================================== # Rule の 配慮変数s と 代替する変数c での decision_tableにおける clift # ===================================== def getClift(rule, s, c, decision_table, list_judgeNominal): supp, conf = LERS.getSupportConfidence(rule, decision_table,list_judgeNominal) rule_c = mlem2.delEfromRule(rule,s) rule_c = rule_c.setValue(s,c) supp_c, conf_c = LERS.getSupportConfidence(rule_c, decision_table, list_judgeNominal) clift = conf / conf_c return(clift) # ==================================== # Attribute Value dict を stringにして返す # ==================================== def strAttributeValue(ATTRIBUTE_VALUE) : list_string = [] for i in ATTRIBUTE_VALUE : list_string.append(i+"-".join(ATTRIBUTE_VALUE[i])) return("+".join(list_string)) # ==================================== # Attribute Value dict を stringにして返す # ==================================== def getItemSet(rule_value) : itemset = set() for attr in rule_value : itemset.add(attr+"-".join(rule_value[attr])) return(itemset) def jaccard(set1, set2): set_and = set1 & set2 set_or = set1 | set2 if len(set_or) == 0 : return(0) else : return(len(set_and)/len(set_or)) # ======================================== # main # ======================================== if __name__ == "__main__": # 設定 DIR_UCI = '/mnt/data/uci/' FILENAME = 'german_credit_categorical' iter1 = 1 iter2 = 1 # rule induction rules = mlem2.getRulesByMLEM2(FILENAME, iter1, iter2) # test data filepath = DIR_UCI+FILENAME+'/'+FILENAME+'-test'+str(iter1)+'-'+str(iter2)+'.tsv' decision_table_test = mlem2.getDecisionTable(filepath) decision_table_test = decision_table_test.dropna() decision_class = decision_table_test[decision_table_test.columns[-1]].values.tolist() # nominal data filepath = DIR_UCI+FILENAME+'/'+FILENAME+'.nominal' list_nominal = mlem2.getNominalList(filepath) list_judgeNominal = mlem2.getJudgeNominal(decision_table_test, list_nominal) # predict by LERS predictions = LERS.predictByLERS(rules, decision_table_test, list_judgeNominal) # 正答率を求める accuracy_score(decision_class, predictions) # rules の数を求める num = len(rules) # 平均の長さを求める mean_length = mlem2.getMeanLength(rules) # train data setup decision_table_train, decision_class = getData(FILENAME, iter1, iter2, T = "train") list_judgeNominal = getJudgeNominal(decision_table_train, FILENAME) # 平均支持度と平均確信度を求める mean_support, mean_conf = LERS.getSupportConfidenceRules(rules, decision_table_train, list_judgeNominal) # AccとRecallを求める acc_recall = LERS.getAccurayRecall(rules, decision_table_train, list_judgeNominal) for i,c in enumerate(mlem2.getEstimatedClass(rules)): print(str(acc_recall[i][0])+","+str(acc_recall[i][1])) ###### 公正配慮のテスト # 基本条件を含むルールセット rules_sex_2 = mlem2.getRulesIncludeE(rules, "Sex_Marital_Status", "2.0") rules_sex_4 = mlem2.getRulesIncludeE(rules, "Sex_Marital_Status", "4.0") # 条件を含まないルールセット rules_exclude_sex = mlem2.getRulesExcludeAttr(rules, "Sex_Marital_Status") # 基本条件を含まないルールセット rules_exclude_sex_1 = mlem2.getRulesExcludeE(rules, "Sex_Marital_Status", "1.0") # 条件を削除したルールセット rules_del_value = mlem2.getRulesDelAttr(rules, "Value_Savings_Stocks") # 基本条件を削除したルールセット rules_del_value_1 = mlem2.getRulesDelE(rules, "Value_Savings_Stocks", "1.0") # 条件を1つ削除する例 rule = mlem2.delAttrFromRule(rules[12],'No_of_dependents') rule = mlem2.delAttrFromRule(rules[12],'Concurrent_Credits') # ==== # read data filepath = '/mnt/data/uci/'+FILENAME+'/'+FILENAME+'-train'+str(iter1)+'-'+str(iter2)+'.tsv' decision_table = mlem2.getDecisionTable(filepath) decision_table = decision_table.dropna() decision_table.index = range(decision_table.shape[0]) # read nominal filepath = '/mnt/data/uci/'+'/'+FILENAME+'/'+FILENAME+'.nominal' list_nominal = mlem2.getNominalList(filepath) # ルールを満たすやつ ほとんどないな。。 match_objects = decision_table.apply(lambda obj: isExplainRule(obj, rules[12], list_judgeNominal), axis=1) # confidence getConfidence(rule, decision_table, list_judgeNominal) rules_sex_2 = mlem2.getRulesIncludeE(rules, "Sex_Marital_Status","2.0")
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 3, 2366, 650, 14, 21, 199, 646, 984, 199, 646, 747, 199, 1274, 14, 515, 14, 740, 2336, 12117, 15, 6992, 73, 15, 3187, 15, 31788, 63, 5012, 15, 1548, 15, 45, 25847, 18, 358, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 16232, 493, 363, 2237, 23164, 5093, 45, 25847, 18, 358, 199, 504, 6357, 14, 6759, 492, 12862, 63, 3397, 199, 646, 1331, 199, 646, 14802, 199, 646, 333, 3701, 18, 199, 646, 491, 3960, 199, 25893, 14, 9233, 8, 77, 3701, 18, 9, 257, 199, 25893, 14, 9233, 8, 28778, 9, 257, 199, 504, 4713, 63, 3736, 492, 664, 5667, 12920, 2543, 199, 504, 4713, 63, 3736, 492, 664, 12920, 1110, 2353, 1362, 199, 3, 19469, 532, 199, 3, 7094, 228, 106, 17627, 97, 166, 228, 236, 163, 228, 107, 24549, 4197, 118, 4197, 236, 27289, 253, 17182, 101, 513, 63, 83, 17593, 16622, 63, 1224, 4197, 234, 5573, 232, 19642, 233, 31459, 24549, 25871, 199, 3, 19469, 532, 199, 318, 2150, 2825, 1408, 827, 1905, 5379, 8, 16622, 63, 1224, 12, 769, 63, 83, 304, 272, 372, 8, 16622, 63, 1224, 14, 4824, 8, 513, 63, 83, 12, 3114, 29, 17, 430, 199, 199, 3, 19469, 532, 199, 3, 24259, 221, 14741, 28075, 4197, 95, 7094, 110, 253, 17182, 101, 962, 1182, 7094, 254, 119, 26304, 15771, 95, 15054, 325, 8, 27289, 253, 17182, 101, 962, 14741, 20757, 98, 86, 9, 221, 17593, 8197, 105, 5573, 223, 29910, 17670, 29910, 5573, 120, 5692, 226, 23869, 14741, 12211, 17593, 13201, 243, 24549, 199, 3, 19469, 532, 199, 318, 664, 5667, 12920, 7826, 7144, 8, 513, 63, 4423, 12, 1921, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 1921, 315, 519, 14, 362, 1197, 5106, 272, 372, 8, 552, 8, 4423, 430, 199, 199, 318, 664, 5667, 12920, 7826, 37, 8, 513, 63, 4423, 12, 1921, 12, 373, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 61, 272, 372, 8, 552, 8, 4423, 430, 199, 199, 318, 664, 5667, 12920, 2543, 7826, 7144, 8, 513, 63, 4423, 12, 1921, 12, 843, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 334, 962, 315, 519, 14, 362, 1197, 1012, 436, 519, 14, 362, 714, 11277, 342, 508, 843, 61, 272, 372, 8, 552, 8, 4423, 430, 199, 199, 318, 664, 5667, 12920, 2543, 7826, 37, 8, 513, 63, 4423, 12, 1921, 12, 373, 12, 843, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 436, 519, 14, 362, 714, 11277, 342, 508, 843, 61, 272, 372, 8, 552, 8, 4423, 430, 199, 199, 318, 664, 5667, 12920, 7826, 8433, 37, 8, 513, 63, 4423, 12, 221, 1211, 63, 3215, 63, 585, 304, 272, 3529, 63, 4423, 275, 769, 63, 4423, 272, 367, 1921, 315, 1211, 63, 3215, 63, 585, 14, 1612, 837, 267, 367, 373, 315, 1211, 63, 3215, 63, 585, 59, 962, 61, 520, 7205, 3529, 63, 4423, 275, 359, 82, 367, 519, 315, 3529, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 61, 272, 372, 8, 552, 8, 2791, 63, 4423, 430, 199, 199, 318, 664, 5667, 12920, 2543, 7826, 8433, 37, 8, 513, 63, 4423, 12, 221, 1211, 63, 3215, 63, 585, 12, 843, 304, 272, 3529, 63, 4423, 275, 769, 63, 4423, 272, 367, 1921, 315, 1211, 63, 3215, 63, 585, 14, 1612, 837, 267, 367, 373, 315, 1211, 63, 3215, 63, 585, 59, 962, 61, 520, 7205, 3529, 63, 4423, 275, 359, 82, 367, 519, 315, 3529, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 436, 519, 14, 362, 714, 11277, 342, 508, 843, 61, 272, 372, 8, 552, 8, 2791, 63, 4423, 430, 199, 199, 3, 19469, 19989, 199, 3, 7094, 231, 229, 19642, 111, 23243, 65, 12, 330, 12, 286, 12, 366, 221, 17593, 13201, 243, 24549, 199, 3, 19469, 19989, 199, 318, 664, 714, 1337, 9501, 3186, 8, 513, 63, 4423, 12, 1211, 63, 3215, 63, 585, 12, 24221, 654, 304, 272, 653, 275, 822, 8, 513, 63, 4423, 9, 272, 302, 17, 275, 664, 5667, 12920, 2543, 8, 513, 63, 4423, 12, 24221, 654, 905, 4087, 3135, 272, 302, 18, 275, 664, 5667, 12920, 2543, 8, 513, 63, 4423, 12, 24221, 654, 905, 8302, 3135, 272, 282, 275, 664, 5667, 12920, 2543, 7826, 8433, 37, 8, 513, 63, 4423, 12, 1211, 63, 3215, 63, 585, 12, 24221, 654, 905, 4087, 3135, 272, 330, 275, 302, 17, 446, 282, 272, 286, 275, 664, 5667, 12920, 2543, 7826, 8433, 37, 8, 513, 63, 4423, 12, 1211, 63, 3215, 63, 585, 12, 24221, 654, 905, 8302, 3135, 272, 366, 275, 302, 18, 446, 286, 272, 372, 8, 65, 12, 66, 12, 67, 12, 68, 9, 4483, 523, 199, 3, 19469, 532, 199, 3, 24259, 221, 14741, 28075, 4197, 95, 7094, 110, 253, 17182, 101, 962, 1182, 7094, 254, 119, 26304, 15771, 95, 15054, 325, 8, 27289, 253, 17182, 101, 962, 14741, 20757, 98, 86, 9, 221, 17593, 8197, 105, 5573, 223, 29910, 17670, 29910, 5573, 120, 5692, 226, 23869, 17593, 13201, 243, 24549, 199, 3, 19469, 532, 258, 199, 318, 664, 12920, 7826, 7144, 8, 513, 63, 4423, 12, 1921, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 1921, 315, 519, 14, 362, 1197, 5106, 272, 372, 8, 4423, 9, 199, 199, 318, 664, 12920, 7826, 37, 8, 513, 63, 4423, 12, 1921, 12, 373, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 61, 272, 372, 8, 4423, 9, 1362, 199, 3, 19469, 532, 199, 3, 24259, 221, 14741, 28075, 4197, 95, 7094, 110, 253, 17182, 101, 962, 1182, 7094, 254, 119, 26304, 15771, 95, 15054, 69, 221, 17593, 7094, 239, 105, 31138, 4197, 104, 20724, 29910, 17670, 29910, 5573, 120, 5692, 226, 23869, 17593, 13201 ]
[ 2803, 26, 2774, 13, 24, 199, 3, 2366, 650, 14, 21, 199, 646, 984, 199, 646, 747, 199, 1274, 14, 515, 14, 740, 2336, 12117, 15, 6992, 73, 15, 3187, 15, 31788, 63, 5012, 15, 1548, 15, 45, 25847, 18, 358, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 16232, 493, 363, 2237, 23164, 5093, 45, 25847, 18, 358, 199, 504, 6357, 14, 6759, 492, 12862, 63, 3397, 199, 646, 1331, 199, 646, 14802, 199, 646, 333, 3701, 18, 199, 646, 491, 3960, 199, 25893, 14, 9233, 8, 77, 3701, 18, 9, 257, 199, 25893, 14, 9233, 8, 28778, 9, 257, 199, 504, 4713, 63, 3736, 492, 664, 5667, 12920, 2543, 199, 504, 4713, 63, 3736, 492, 664, 12920, 1110, 2353, 1362, 199, 3, 19469, 532, 199, 3, 7094, 228, 106, 17627, 97, 166, 228, 236, 163, 228, 107, 24549, 4197, 118, 4197, 236, 27289, 253, 17182, 101, 513, 63, 83, 17593, 16622, 63, 1224, 4197, 234, 5573, 232, 19642, 233, 31459, 24549, 25871, 199, 3, 19469, 532, 199, 318, 2150, 2825, 1408, 827, 1905, 5379, 8, 16622, 63, 1224, 12, 769, 63, 83, 304, 272, 372, 8, 16622, 63, 1224, 14, 4824, 8, 513, 63, 83, 12, 3114, 29, 17, 430, 199, 199, 3, 19469, 532, 199, 3, 24259, 221, 14741, 28075, 4197, 95, 7094, 110, 253, 17182, 101, 962, 1182, 7094, 254, 119, 26304, 15771, 95, 15054, 325, 8, 27289, 253, 17182, 101, 962, 14741, 20757, 98, 86, 9, 221, 17593, 8197, 105, 5573, 223, 29910, 17670, 29910, 5573, 120, 5692, 226, 23869, 14741, 12211, 17593, 13201, 243, 24549, 199, 3, 19469, 532, 199, 318, 664, 5667, 12920, 7826, 7144, 8, 513, 63, 4423, 12, 1921, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 1921, 315, 519, 14, 362, 1197, 5106, 272, 372, 8, 552, 8, 4423, 430, 199, 199, 318, 664, 5667, 12920, 7826, 37, 8, 513, 63, 4423, 12, 1921, 12, 373, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 61, 272, 372, 8, 552, 8, 4423, 430, 199, 199, 318, 664, 5667, 12920, 2543, 7826, 7144, 8, 513, 63, 4423, 12, 1921, 12, 843, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 334, 962, 315, 519, 14, 362, 1197, 1012, 436, 519, 14, 362, 714, 11277, 342, 508, 843, 61, 272, 372, 8, 552, 8, 4423, 430, 199, 199, 318, 664, 5667, 12920, 2543, 7826, 37, 8, 513, 63, 4423, 12, 1921, 12, 373, 12, 843, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 436, 519, 14, 362, 714, 11277, 342, 508, 843, 61, 272, 372, 8, 552, 8, 4423, 430, 199, 199, 318, 664, 5667, 12920, 7826, 8433, 37, 8, 513, 63, 4423, 12, 221, 1211, 63, 3215, 63, 585, 304, 272, 3529, 63, 4423, 275, 769, 63, 4423, 272, 367, 1921, 315, 1211, 63, 3215, 63, 585, 14, 1612, 837, 267, 367, 373, 315, 1211, 63, 3215, 63, 585, 59, 962, 61, 520, 7205, 3529, 63, 4423, 275, 359, 82, 367, 519, 315, 3529, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 61, 272, 372, 8, 552, 8, 2791, 63, 4423, 430, 199, 199, 318, 664, 5667, 12920, 2543, 7826, 8433, 37, 8, 513, 63, 4423, 12, 221, 1211, 63, 3215, 63, 585, 12, 843, 304, 272, 3529, 63, 4423, 275, 769, 63, 4423, 272, 367, 1921, 315, 1211, 63, 3215, 63, 585, 14, 1612, 837, 267, 367, 373, 315, 1211, 63, 3215, 63, 585, 59, 962, 61, 520, 7205, 3529, 63, 4423, 275, 359, 82, 367, 519, 315, 3529, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 436, 519, 14, 362, 714, 11277, 342, 508, 843, 61, 272, 372, 8, 552, 8, 2791, 63, 4423, 430, 199, 199, 3, 19469, 19989, 199, 3, 7094, 231, 229, 19642, 111, 23243, 65, 12, 330, 12, 286, 12, 366, 221, 17593, 13201, 243, 24549, 199, 3, 19469, 19989, 199, 318, 664, 714, 1337, 9501, 3186, 8, 513, 63, 4423, 12, 1211, 63, 3215, 63, 585, 12, 24221, 654, 304, 272, 653, 275, 822, 8, 513, 63, 4423, 9, 272, 302, 17, 275, 664, 5667, 12920, 2543, 8, 513, 63, 4423, 12, 24221, 654, 905, 4087, 3135, 272, 302, 18, 275, 664, 5667, 12920, 2543, 8, 513, 63, 4423, 12, 24221, 654, 905, 8302, 3135, 272, 282, 275, 664, 5667, 12920, 2543, 7826, 8433, 37, 8, 513, 63, 4423, 12, 1211, 63, 3215, 63, 585, 12, 24221, 654, 905, 4087, 3135, 272, 330, 275, 302, 17, 446, 282, 272, 286, 275, 664, 5667, 12920, 2543, 7826, 8433, 37, 8, 513, 63, 4423, 12, 1211, 63, 3215, 63, 585, 12, 24221, 654, 905, 8302, 3135, 272, 366, 275, 302, 18, 446, 286, 272, 372, 8, 65, 12, 66, 12, 67, 12, 68, 9, 4483, 523, 199, 3, 19469, 532, 199, 3, 24259, 221, 14741, 28075, 4197, 95, 7094, 110, 253, 17182, 101, 962, 1182, 7094, 254, 119, 26304, 15771, 95, 15054, 325, 8, 27289, 253, 17182, 101, 962, 14741, 20757, 98, 86, 9, 221, 17593, 8197, 105, 5573, 223, 29910, 17670, 29910, 5573, 120, 5692, 226, 23869, 17593, 13201, 243, 24549, 199, 3, 19469, 532, 258, 199, 318, 664, 12920, 7826, 7144, 8, 513, 63, 4423, 12, 1921, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 1921, 315, 519, 14, 362, 1197, 5106, 272, 372, 8, 4423, 9, 199, 199, 318, 664, 12920, 7826, 37, 8, 513, 63, 4423, 12, 1921, 12, 373, 9, 520, 272, 4713, 275, 359, 82, 367, 519, 315, 769, 63, 4423, 340, 519, 14, 17186, 8, 962, 9, 508, 373, 61, 272, 372, 8, 4423, 9, 1362, 199, 3, 19469, 532, 199, 3, 24259, 221, 14741, 28075, 4197, 95, 7094, 110, 253, 17182, 101, 962, 1182, 7094, 254, 119, 26304, 15771, 95, 15054, 69, 221, 17593, 7094, 239, 105, 31138, 4197, 104, 20724, 29910, 17670, 29910, 5573, 120, 5692, 226, 23869, 17593, 13201, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 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
63759
from __future__ import unicode_literals, absolute_import import re from collections import defaultdict from datetime import date, time from datetime import datetime from decimal import Decimal from tri_form.compat import ( ValidationError, field_defaults_factory, ) from bs4 import BeautifulSoup import pytest from tri_form.compat import Template, smart_str from tri_declarative import ( getattr_path, setattr_path, Namespace, class_shortcut, Shortcut, ) from tri_struct import Struct from tri_form import ( AVOID_EMPTY_FORM, Form, Field, register_field_factory, bool_parse, render_attrs, decimal_parse, url_parse, render_template, Link, datetime_parse, datetime_iso_formats, int_parse, create_members_from_model, member_from_model, Action, float_parse, get_name_field, ) from .compat import RequestFactory def assert_one_error_and_matches_reg_exp(errors, reg_exp): error = list(errors)[0] assert len(errors) == 1 assert re.search(reg_exp, error) def test_declaration_merge(): class MyForm(Form): class Meta: fields = [Field(name='foo')] bar = Field() assert {'foo', 'bar'} == set(MyForm().fields_by_name.keys()) class MyTestForm(Form): party = Field.choice(choices=['ABC'], required=False) username = Field( is_valid=lambda form, field, parsed_data: ( parsed_data.startswith(form.fields_by_name['party'].parsed_data.lower() + '_') if parsed_data is not None else None, 'Username must begin with "%s_"' % form.fields_by_name['party'].parsed_data) ) joined = Field.datetime(attr='contact__joined') a_date = Field.date() a_time = Field.time() staff = Field.boolean() admin = Field.boolean() manages = Field.multi_choice(choices=['DEF', 'KTH', 'LIU'], required=False) not_editable = Field.text(initial='Some non-editable text', editable=False) multi_choice_field = Field.multi_choice(choices=['a', 'b', 'c', 'd'], required=False) # TODO: tests for all shortcuts with required=False def test_repr(): assert '<tri_form.Field foo>' == repr(Field(name='foo')) assert '<tri_form.Field foo>' == str(Field(name='foo')) def test_required_choice(): class Required(Form): c = Field.choice(choices=[1, 2, 3]) form = Required(request=RequestFactory().post('/', {'/': ''})) assert form.is_valid() is False assert form.fields_by_name['c'].errors == {'This field is required'} class NotRequired(Form): c = Field.choice(choices=[1, 2, 3], required=False) form = NotRequired(request=RequestFactory().post('/', {'/': '', 'c': ''})) assert form.is_valid() assert form.fields_by_name['c'].errors == set() def test_required(): form = MyTestForm(request=RequestFactory().post('/', {'/': ''})) assert form.fields_by_name['a_date'].value is None assert form.fields_by_name['a_date'].errors == {'This field is required'} def test_required_with_falsy_option(): class MyForm(Form): foo = Field.choice( choices=[0, 1], parse=lambda string_value, **_: int(string_value) ) form = MyForm(request=RequestFactory().post('/', {'foo': '0', '/': ''})) assert form.fields_by_name.foo.value == 0 assert form.fields_by_name.foo.errors == set() def test_custom_raw_data(): def my_form_raw_data(form, field, **_): del form del field return 'this is custom raw data' class MyForm(Form): foo = Field(raw_data=my_form_raw_data) form = MyForm(request=RequestFactory().post('/', {'/': ''})) assert form.fields_by_name.foo.value == 'this is custom raw data' def test_custom_raw_data_list(): def my_form_raw_data_list(form, field, **_): del form del field return ['this is custom raw data list'] class MyForm(Form): foo = Field( raw_data_list=my_form_raw_data_list, is_list=True, ) form = MyForm(request=RequestFactory().post('/', {'/': ''})) assert form.fields_by_name.foo.value_list == ['this is custom raw data list'] def test_parse(): # The spaces in the data are there to check that we strip input form = MyTestForm( request=RequestFactory().post('/', { 'party': 'ABC ', 'username': 'abc_foo ', 'joined': ' 2014-12-12 01:02:03 ', 'staff': ' true', 'admin': 'false ', 'manages': ['DEF ', 'KTH '], 'a_date': ' 2014-02-12 ', 'a_time': ' 01:02:03 ', 'multi_choice_field': ['a', 'b'], '/': '', })) assert [x.errors for x in form.fields] == [set() for _ in form.fields] assert form.is_valid() is True assert form.fields_by_name['party'].parsed_data == 'ABC' assert form.fields_by_name['party'].value == 'ABC' assert form.fields_by_name['username'].parsed_data == 'abc_foo' assert form.fields_by_name['username'].value == 'abc_foo' assert form.fields_by_name['joined'].raw_data == '2014-12-12 01:02:03' assert form.fields_by_name['joined'].parsed_data == datetime(2014, 12, 12, 1, 2, 3) assert form.fields_by_name['joined'].value == datetime(2014, 12, 12, 1, 2, 3) assert form.fields_by_name['staff'].raw_data == 'true' assert form.fields_by_name['staff'].parsed_data is True assert form.fields_by_name['staff'].value is True assert form.fields_by_name['admin'].raw_data == 'false' assert form.fields_by_name['admin'].parsed_data is False assert form.fields_by_name['admin'].value is False assert form.fields_by_name['manages'].raw_data_list == ['DEF', 'KTH'] assert form.fields_by_name['manages'].parsed_data_list == ['DEF', 'KTH'] assert form.fields_by_name['manages'].value_list == ['DEF', 'KTH'] assert form.fields_by_name['a_date'].raw_data == '2014-02-12' assert form.fields_by_name['a_date'].parsed_data == date(2014, 2, 12) assert form.fields_by_name['a_date'].value == date(2014, 2, 12) assert form.fields_by_name['a_time'].raw_data == '01:02:03' assert form.fields_by_name['a_time'].parsed_data == time(1, 2, 3) assert form.fields_by_name['a_time'].value == time(1, 2, 3) assert form.fields_by_name['multi_choice_field'].raw_data_list == ['a', 'b'] assert form.fields_by_name['multi_choice_field'].parsed_data_list == ['a', 'b'] assert form.fields_by_name['multi_choice_field'].value_list == ['a', 'b'] assert form.fields_by_name['multi_choice_field'].is_list assert not form.fields_by_name['multi_choice_field'].errors assert form.fields_by_name['multi_choice_field'].rendered_value == 'a, b' instance = Struct(contact=Struct()) form.apply(instance) assert instance == Struct( contact=Struct(joined=datetime(2014, 12, 12, 1, 2, 3)), party='ABC', staff=True, admin=False, username='abc_foo', manages=['DEF', 'KTH'], a_date=date(2014, 2, 12), a_time=time(1, 2, 3), not_editable='Some non-editable text', multi_choice_field=['a', 'b'], ) def test_parse_errors(): def post_validation(form): form.add_error('General snafu') form = MyTestForm( data=dict( party='foo', username='bar_foo', joined='foo', staff='foo', admin='foo', a_date='fooasd', a_time='asdasd', multi_choice_field=['q'], **{'-': ''} ), post_validation=post_validation) assert form.is_valid() is False assert form.errors == {'General snafu'} assert form.fields_by_name['party'].parsed_data == 'foo' assert form.fields_by_name['party'].errors == {'foo not in available choices'} assert form.fields_by_name['party'].value is None assert form.fields_by_name['username'].parsed_data == 'bar_foo' assert form.fields_by_name['username'].errors == {'Username must begin with "foo_"'} assert form.fields_by_name['username'].value is None assert form.fields_by_name['joined'].raw_data == 'foo' assert_one_error_and_matches_reg_exp(form.fields_by_name['joined'].errors, 'Time data "foo" does not match any of the formats .*') assert form.fields_by_name['joined'].parsed_data is None assert form.fields_by_name['joined'].value is None assert form.fields_by_name['staff'].raw_data == 'foo' assert form.fields_by_name['staff'].parsed_data is None assert form.fields_by_name['staff'].value is None assert form.fields_by_name['admin'].raw_data == 'foo' assert form.fields_by_name['admin'].parsed_data is None assert form.fields_by_name['admin'].value is None assert form.fields_by_name['a_date'].raw_data == 'fooasd' assert_one_error_and_matches_reg_exp(form.fields_by_name['a_date'].errors, "time data u?'fooasd' does not match format u?'%Y-%m-%d'") assert form.fields_by_name['a_date'].parsed_data is None assert form.fields_by_name['a_date'].value is None assert form.fields_by_name['a_date'].rendered_value == form.fields_by_name['a_date'].raw_data assert form.fields_by_name['a_time'].raw_data == 'asdasd' assert_one_error_and_matches_reg_exp(form.fields_by_name['a_time'].errors, "time data u?'asdasd' does not match format u?'%H:%M:%S'") assert form.fields_by_name['a_time'].parsed_data is None assert form.fields_by_name['a_time'].value is None assert form.fields_by_name['multi_choice_field'].raw_data_list == ['q'] assert_one_error_and_matches_reg_exp(form.fields_by_name['multi_choice_field'].errors, "q not in available choices") assert form.fields_by_name['multi_choice_field'].parsed_data_list == ['q'] assert form.fields_by_name['multi_choice_field'].value_list is None with pytest.raises(AssertionError): form.apply(Struct()) def test_initial_from_instance(): assert Form(instance=Struct(a=Struct(b=7)), fields=[Field(name='a__b')]).fields[0].initial == 7 def test_initial_list_from_instance(): assert Form(instance=Struct(a=Struct(b=[7])), fields=[Field(name='a__b', is_list=True)]).fields[0].initial_list == [7] def test_non_editable_from_initial(): class MyForm(Form): foo = Field(editable=False, initial=':bar:') assert ':bar:' in MyForm(request=RequestFactory().get('/')).render() assert ':bar:' in MyForm(request=RequestFactory().post('/', {'/': ''})).render() def test_apply(): form = Form(fields=[Field(name='foo', initial=17, editable=False)]) assert Struct(foo=17) == form.apply(Struct()) def test_show(): assert list(Form(data={}, fields=[Field(name='foo', show=True)]).fields_by_name.keys()) == ['foo'] assert list(Form(data={}, fields=[Field(name='foo', show=False)]).fields_by_name.keys()) == [] assert list(Form(data={}, fields=[Field(name='foo', show=lambda form, field: False)]).fields_by_name.keys()) == [] def test_declared_fields(): form = Form(data={}, fields=[ Field(name='foo', show=True), Field(name='bar', show=False), ]) assert [f.name for f in form.declared_fields] == ['foo', 'bar'] assert [f.name for f in form.fields] == ['foo'] def test_non_editable(): assert Form(data={}, fields=[Field(name='foo', editable=False)]).fields[0].input_template == 'tri_form/non_editable.html' def test_non_editable_form(): form = Form( editable=False, data=Struct(foo='1', bar='2'), instance=Struct(foo=3, bar=4), fields=[ Field.integer(name='foo'), Field.integer(name='bar', editable=False), ] ) assert 3 == form.fields_by_name.foo.value assert 4 == form.fields_by_name.bar.value assert False is form.fields_by_name.foo.editable assert False is form.fields_by_name.bar.editable def test_text_fields(): assert '<input type="text" ' in Form(data={}, fields=[Field.text(name='foo')]).compact() assert '<textarea' in Form(data={}, fields=[Field.textarea(name='foo')]).compact() def test_integer_field(): assert Form(data=dict(foo=' 7 '), fields=[Field.integer(name='foo')]).fields[0].parsed_data == 7 actual_errors = Form(data=dict(foo=' foo '), fields=[Field.integer(name='foo')]).fields[0].errors assert_one_error_and_matches_reg_exp(actual_errors, r"invalid literal for int\(\) with base 10: u?'foo'") def test_float_field(): assert Form(data=dict(foo=' 7.3 '), fields=[Field.float(name='foo')]).fields[0].parsed_data == 7.3 assert Form(data=dict(foo=' foo '), fields=[Field.float(name='foo')]).fields[0].errors == {"could not convert string to float: foo"} def test_email_field(): assert Form(data=dict(foo=' 5 '), fields=[Field.email(name='foo')]).fields[0].errors == {u'Enter a valid email address.'} assert Form(data=dict(foo='foo@example.com'), fields=[Field.email(name='foo')]).is_valid() def test_phone_field(): assert Form(data=dict(foo=' asdasd '), fields=[Field.phone_number(name='foo')]).fields[0].errors == {u'Please use format +<country code> (XX) XX XX. Example of US number: +1 (212) 123 4567 or +1 212 123 4567'} assert Form(data=dict(foo='+1 (212) 123 4567'), fields=[Field.phone_number(name='foo')]).is_valid() assert Form(data=dict(foo='+46 70 123 123'), fields=[Field.phone_number(name='foo')]).is_valid() def test_render_template_string(): assert Form(data=dict(foo='7'), fields=[Field(name='foo', template=None, template_string='{{ field.value }} {{ form.style }}')]).compact() == '7 compact\n' + AVOID_EMPTY_FORM.format('') + '\n' def test_render_template(): assert '<form' in Form(request=RequestFactory().get('/'), data=dict(foo='7'), fields=[Field(name='foo')]).render() def test_render_on_dunder_html(): form = Form(request=RequestFactory().get('/'), data=dict(foo='7'), fields=[Field(name='foo')]) assert form.table() == form.__html__() # used by jinja2 def test_render_attrs(): assert Form(data=dict(foo='7'), fields=[Field(name='foo', attrs={'foo': '1'})]).fields[0].render_attrs() == ' foo="1"' assert Form(data=dict(foo='7'), fields=[Field(name='foo')]).fields[0].render_attrs() == ' ' assert render_attrs(dict(foo='"foo"')) == ' foo="&quot;foo&quot;"' def test_render_attrs_new_style(): assert Form(data=dict(foo='7'), fields=[Field(name='foo', attrs__foo='1')]).fields[0].render_attrs() == ' foo="1"' assert Form(data=dict(foo='7'), fields=[Field(name='foo')]).fields[0].render_attrs() == ' ' def test_render_attrs_bug_with_curly_brace(): assert render_attrs(dict(foo='{foo}')) == ' foo="{foo}"' def test_getattr_path(): assert getattr_path(Struct(a=1), 'a') == 1 assert getattr_path(Struct(a=Struct(b=2)), 'a__b') == 2 with pytest.raises(AttributeError): getattr_path(Struct(a=2), 'b') assert getattr_path(Struct(a=None), 'a__b__c__d') is None def test_setattr_path(): assert getattr_path(setattr_path(Struct(a=0), 'a', 1), 'a') == 1 assert getattr_path(setattr_path(Struct(a=Struct(b=0)), 'a__b', 2), 'a__b') == 2 with pytest.raises(AttributeError): setattr_path(Struct(a=1), 'a__b', 1) def test_multi_select_with_one_value_only(): assert ['a'] == Form(data=dict(foo=['a']), fields=[Field.multi_choice(name='foo', choices=['a', 'b'])]).fields[0].value_list def test_render_table(): class MyForm(Form): class Meta: data = dict(foo='!!!7!!!') foo = Field( input_container__attrs__class=dict(**{'###5###': True}), label_container__attrs__class=dict(**{'$$$11$$$': True}), help_text='^^^13^^^', display_name='***17***', id='$$$$5$$$$$' ) table = MyForm().table() assert '!!!7!!!' in table assert '###5###' in table assert '$$$11$$$' in table assert '^^^13^^^' in table assert '***17***' in table assert 'id="$$$$5$$$$$"' in table assert '<tr' in table # Assert that table is the default assert table == "%s" % MyForm() def test_heading(): assert '<th colspan="2">#foo#</th>' in Form(data={}, fields=[Field.heading(display_name='#foo#')]).table() def test_info(): form = Form(data={}, fields=[Field.info(value='#foo#')]) assert form.is_valid() is True assert '#foo#' in form.table() def test_radio(): choices = [ 'a', 'b', 'c', ] RequestFactory().get('/') soup = BeautifulSoup(Form(data=dict(foo='a'), fields=[Field.radio(name='foo', choices=choices)]).table(), 'html.parser') assert len(soup.find_all('input')) == len(choices) + 1 # +1 for AVOID_EMPTY_FORM assert [x.attrs['value'] for x in soup.find_all('input') if 'checked' in x.attrs] == ['a'] def test_hidden(): soup = BeautifulSoup(Form(data=dict(foo='1'), fields=[Field.hidden(name='foo')]).table(), 'html.parser') assert [(x.attrs['type'], x.attrs['name'], x.attrs['value']) for x in soup.find_all('input')] == [('hidden', 'foo', '1'), ('hidden', '-', '')] def test_hidden_with_name(): soup = BeautifulSoup(Form(name='baz', endpoint_dispatch_prefix='baz', data={'baz/foo': '1'}, fields=[Field.hidden(name='foo')]).table(), 'html.parser') assert [(x.attrs['type'], x.attrs['name'], x.attrs['value']) for x in soup.find_all('input')] == [('hidden', 'baz/foo', '1'), ('hidden', '-baz', '')] def test_password(): assert ' type="password" ' in Form(data=dict(foo='1'), fields=[Field.password(name='foo')]).table() def test_choice_not_required(): class MyForm(Form): foo = Field.choice(required=False, choices=['bar']) assert MyForm(request=RequestFactory().post('/', {'foo': 'bar', '/': ''})).fields[0].value == 'bar' assert MyForm(request=RequestFactory().post('/', {'foo': '', '/': ''})).fields[0].value is None # def test_choice_default_parser(): # # class MyThing(object): # def __init__(self, name): # self.name = name # # def __str__(self): # return self.name # # a, b, c = MyThing('a'), MyThing('b'), MyThing('c') # # class MyForm(Form): # foo = Field.choice(choices=[a, b, c]) # # assert MyForm(request=RequestFactory().post('/', {'foo': 'b', '/': ''})).fields_by_name.foo.value is b # assert MyForm(request=RequestFactory().post('/', {'foo': 'fisk', '/': ''})).fields_by_name.foo.errors == {'fisk not in available choices'} def test_multi_choice(): soup = BeautifulSoup(Form(data=dict(foo=['0']), fields=[Field.multi_choice(name='foo', choices=['a'])]).table(), 'html.parser') assert [x.attrs['multiple'] for x in soup.find_all('select')] == [''] @pytest.mark.django def test_help_text_from_model(): from tests.models import Foo assert Form(data=dict(foo='1'), fields=[Field.from_model(model=Foo, field_name='foo')], model=Foo).fields[0].help_text == 'foo_help_text' @pytest.mark.django_db def test_help_text_from_model2(): from .models import Foo, Bar # simple integer field assert Form.from_model(data=dict(foo='1'), include=['foo'], model=Foo).fields[0].help_text == 'foo_help_text' # foreign key field Bar.objects.create(foo=Foo.objects.create(foo=1)) form = Form.from_model(data={}, include=['foo'], model=Bar) assert form.fields[0].help_text == 'bar_help_text' assert form.fields_by_name.foo.model is Foo @pytest.mark.django_db def test_multi_choice_queryset(): from django.contrib.auth.models import User user = User.objects.create(username='foo') user2 = User.objects.create(username='foo2') user3 = User.objects.create(username='foo3') class MyForm(Form): foo = Field.multi_choice_queryset(attr=None, choices=User.objects.filter(username=user.username)) assert [x.pk for x in MyForm().fields[0].choices] == [user.pk] assert MyForm(RequestFactory().get('/', {'foo': smart_str(user2.pk)})).fields[0].errors == {'%s not in available choices' % user2.pk} assert MyForm(RequestFactory().get('/', {'foo': [smart_str(user2.pk), smart_str(user3.pk)]})).fields[0].errors == {'%s, %s not in available choices' % (user2.pk, user3.pk)} form = MyForm(RequestFactory().get('/', {'foo': [smart_str(user.pk)]})) assert form.fields[0].errors == set() result = form.render() assert str(BeautifulSoup(result, "html.parser").select('#id_foo')[0]) == '<input id="id_foo" multiple="" name="foo" type="hidden"/>' assert f'var data = [{{"id": {user.pk}, "text": "{user}"}}];' in result @pytest.mark.django_db def test_choice_queryset(): from django.contrib.auth.models import User user = User.objects.create(username='foo') user2 = User.objects.create(username='foo2') User.objects.create(username='foo3') class MyForm(Form): foo = Field.choice_queryset(attr=None, choices=User.objects.filter(username=user.username)) assert [x.pk for x in MyForm().fields[0].choices] == [user.pk] assert MyForm(RequestFactory().get('/', {'foo': smart_str(user2.pk)})).fields[0].errors == {'%s not in available choices' % user2.pk} form = MyForm(RequestFactory().get('/', {'foo': [smart_str(user.pk)]})) assert form.fields[0].errors == set() result = form.render() assert str(BeautifulSoup(result, "html.parser").select('#id_foo')[0]) == '<input id="id_foo" name="foo" type="hidden"/>' assert f'var data = {{"id": {user.pk}, "text": "{user}"}};' in result @pytest.mark.django_db def test_choice_queryset_do_not_cache(): from django.contrib.auth.models import User User.objects.create(username='foo') class MyForm(Form): foo = Field.choice_queryset(attr=None, choices=User.objects.all(), template='tri_form/choice.html') # There is just one user, check that we get it form = MyForm(RequestFactory().get('/')) assert form.fields[0].errors == set() assert str(BeautifulSoup(form.render(), "html.parser").select('select')[0]) == '<select id="id_foo" name="foo">\n<option value="1">foo</option>\n</select>' # Now create a new queryset, check that we get two! User.objects.create(username='foo2') form = MyForm(RequestFactory().get('/')) assert form.fields[0].errors == set() assert str(BeautifulSoup(form.render(), "html.parser").select('select')[0]) == '<select id="id_foo" name="foo">\n<option value="1">foo</option>\n<option value="2">foo2</option>\n</select>' @pytest.mark.django def test_field_from_model(): from tests.models import Foo class FooForm(Form): foo = Field.from_model(Foo, 'foo') class Meta: model = Foo assert FooForm(data=dict(foo='1')).fields[0].value == 1 assert not FooForm(data=dict(foo='asd')).is_valid() @pytest.mark.django_db def test_field_from_model_foreign_key_choices(): from tests.models import Foo, Bar foo = Foo.objects.create(foo=1) foo2 = Foo.objects.create(foo=2) Bar.objects.create(foo=foo) Bar.objects.create(foo=foo2) class FooForm(Form): # Choices is a lambda here to avoid Field.field_choice_queryset grabbing the model from the queryset object foo = Field.from_model(Bar, 'foo', choices=lambda form, field, **_: Foo.objects.all()) assert list(FooForm().fields_by_name['foo'].choices) == list(Foo.objects.all()) form = FooForm(request=RequestFactory().post('/', data=dict(foo=foo2.pk))) bar = Bar() form.apply(bar) bar.save() assert bar.foo == foo2 assert Bar.objects.get(pk=bar.pk).foo == foo2 @pytest.mark.django_db def test_field_validate_foreign_key_does_not_exist(): from tests.models import Foo, FieldFromModelForeignKeyTest foo = Foo.objects.create(foo=17) assert Foo.objects.count() == 1 class MyForm(Form): class Meta: model = FieldFromModelForeignKeyTest fields = Form.fields_from_model assert MyForm(request=RequestFactory().post('/', data=dict(foo_fk=foo.pk))).is_valid() is True assert MyForm(request=RequestFactory().post('/', data=dict(foo_fk=foo.pk + 1))).is_valid() is False @pytest.mark.django def test_form_default_fields_from_model(): from tests.models import Foo class FooForm(Form): class Meta: model = Foo fields = Form.fields_from_model fields__extra = [Field.text(attr=None, name='bar')] assert set(FooForm().fields_by_name.keys()) == {'foo', 'bar'} assert FooForm(data=dict(foo='1')).fields[0].value == 1 assert not FooForm(data=dict(foo='asd')).is_valid() @pytest.mark.django @pytest.mark.filterwarnings("ignore:Model 'tests.foomodel' was already registered") def test_field_from_model_factory_error_message(): from django.db.models import Field as DjangoField, Model class CustomField(DjangoField): pass class FooModel(Model): foo = CustomField() with pytest.raises(AssertionError) as error: Field.from_model(FooModel, 'foo') acceptable_error_messages = [ "No factory for <class 'tests.test_forms.CustomField'>. Register a factory with register_field_factory, you can also register one that returns None to not handle this field type", "No factory for <class 'tests.test_forms.test_field_from_model_factory_error_message.<locals>.CustomField'>. Register a factory with register_field_factory, you can also register one that returns None to not handle this field type", ] assert str(error.value) in acceptable_error_messages @pytest.mark.django @pytest.mark.filterwarnings("ignore:Model 'tests.foomodel' was already registered") def test_field_from_model_required(): from django.db.models import TextField, Model class FooModel(Model): a = TextField(blank=True, null=True) b = TextField(blank=True, null=False) c = TextField(blank=False, null=True) d = TextField(blank=False, null=False) assert not Field.from_model(FooModel, 'a').required assert not Field.from_model(FooModel, 'b').required assert not Field.from_model(FooModel, 'c').required assert Field.from_model(FooModel, 'd').required @pytest.mark.django @pytest.mark.filterwarnings("ignore:Model 'tests.foomodel' was already registered") def test_field_from_model_label(): from django.db.models import TextField, Model class FooModel(Model): a = TextField(verbose_name='FOOO bar FOO') assert Field.from_model(FooModel, 'a').display_name == 'FOOO bar FOO' @pytest.mark.django_db def test_form_from_model_valid_form(): from tests.models import FormFromModelTest assert [x.value for x in Form.from_model( model=FormFromModelTest, include=['f_int', 'f_float', 'f_bool'], data=dict(f_int='1', f_float='1.1', f_bool='true') ).fields] == [ 1, 1.1, True ] @pytest.mark.django_db def test_form_from_model_error_message_include(): from tests.models import FormFromModelTest with pytest.raises(AssertionError) as e: Form.from_model(model=FormFromModelTest, include=['does_not_exist', 'another_non_existant__sub', 'f_float'], data=None) assert 'You can only include fields that exist on the model: another_non_existant__sub, does_not_exist specified but does not exist' == str(e.value) @pytest.mark.django_db def test_form_from_model_error_message_exclude(): from tests.models import FormFromModelTest with pytest.raises(AssertionError) as e: Form.from_model(model=FormFromModelTest, exclude=['does_not_exist', 'does_not_exist_2', 'f_float'], data=None) assert 'You can only exclude fields that exist on the model: does_not_exist, does_not_exist_2 specified but does not exist' == str(e.value) @pytest.mark.django def test_form_from_model_invalid_form(): from tests.models import FormFromModelTest actual_errors = [x.errors for x in Form.from_model( model=FormFromModelTest, exclude=['f_int_excluded'], data=dict(f_int='1.1', f_float='true', f_bool='asd', f_file='foo') ).fields] assert len(actual_errors) == 4 assert {'could not convert string to float: true'} in actual_errors assert {u'asd is not a valid boolean value'} in actual_errors assert {"invalid literal for int() with base 10: '1.1'"} in actual_errors or {"invalid literal for int() with base 10: u'1.1'"} in actual_errors @pytest.mark.django def test_field_from_model_supports_all_types(): from tests.models import Foo from django.db.models import fields not_supported = [] blacklist = { 'Field', 'BinaryField', 'FilePathField', 'GenericIPAddressField', 'IPAddressField', 'NullBooleanField', 'SlugField', 'DurationField', 'UUIDField' } field_type_names = [x for x in dir(fields) if x.endswith('Field') and x not in blacklist] for name in field_type_names: field_type = getattr(fields, name) try: Field.from_model(model=Foo, model_field=field_type()) except AssertionError: # pragma: no cover not_supported.append(name) assert not_supported == [] @pytest.mark.django def test_field_from_model_blank_handling(): from tests.models import Foo from django.db.models import CharField subject = Field.from_model(model=Foo, model_field=CharField(null=True, blank=False)) assert True is subject.parse_empty_string_as_none subject = Field.from_model(model=Foo, model_field=CharField(null=False, blank=True)) assert False is subject.parse_empty_string_as_none @pytest.mark.django def test_overriding_parse_empty_string_as_none_in_shortcut(): from tests.models import Foo from django.db.models import CharField s = Shortcut( call_target=Field.text, parse_empty_string_as_none='foo', ) # test overriding parse_empty_string_as_none x = member_from_model( cls=Field, model=Foo, model_field=CharField(blank=True), factory_lookup={CharField: s}, factory_lookup_register_function=register_field_factory, defaults_factory=field_defaults_factory, ) assert 'foo' == x.parse_empty_string_as_none @pytest.mark.django_db def test_field_from_model_foreign_key(): from django.db.models import QuerySet from tests.models import Foo, FieldFromModelForeignKeyTest Foo.objects.create(foo=2) Foo.objects.create(foo=3) Foo.objects.create(foo=5) class MyForm(Form): c = Field.from_model(FieldFromModelForeignKeyTest, 'foo_fk') form = MyForm(request=RequestFactory().get('/')) choices = form.fields_by_name.c.choices assert isinstance(choices, QuerySet) assert set(choices) == set(Foo.objects.all()) @pytest.mark.django_db def test_field_from_model_many_to_many(): from django.db.models import QuerySet from tests.models import Foo, FieldFromModelManyToManyTest Foo.objects.create(foo=2) b = Foo.objects.create(foo=3) c = Foo.objects.create(foo=5) class MyForm(Form): foo_many_to_many = Field.from_model(FieldFromModelManyToManyTest, 'foo_many_to_many') form = MyForm(request=RequestFactory().get('/')) field = form.fields_by_name.foo_many_to_many choices = form.fields_by_name.foo_many_to_many.choices assert isinstance(choices, QuerySet) assert set(choices) == set(Foo.objects.all()) m2m = FieldFromModelManyToManyTest.objects.create() assert set(Form(fields=[field], instance=m2m).fields_by_name.foo_many_to_many.initial_list) == set() m2m.foo_many_to_many.add(b) assert set(Form(fields=[field], instance=m2m).fields_by_name.foo_many_to_many.initial_list) == {b} m2m.foo_many_to_many.add(c) assert set(Form(fields=[field], instance=m2m).fields_by_name.foo_many_to_many.initial_list) == {b, c} @pytest.mark.django_db def test_field_from_model_foreign_key2(): from tests.models import FieldFromModelOneToOneTest form = Form.from_model( data={}, model=FieldFromModelOneToOneTest, field__foo_one_to_one__call_target=Field.from_model_expand, field__foo_one_to_one__field__foo__display_name='blaha', field__foo_one_to_one__field__foo__extra__stuff='blahada', ) assert set(form.fields_by_name.keys()) == {'foo_one_to_one__foo'} assert form.fields_by_name['foo_one_to_one__foo'].display_name == 'blaha' assert form.fields_by_name['foo_one_to_one__foo'].extra.stuff == 'blahada' @pytest.mark.django_db def test_field_from_model_many_to_one_foreign_key(): from tests.models import Bar assert set(Form.from_model( data={}, model=Bar, field__foo__call_target=Field.from_model ).fields_by_name.keys()) == {'foo'} @pytest.mark.django def test_register_field_factory(): from tests.models import FooField, RegisterFieldFactoryTest register_field_factory(FooField, lambda **kwargs: 7) assert Field.from_model(RegisterFieldFactoryTest, 'foo') == 7 def shortcut_test(shortcut, raw_and_parsed_data_tuples, normalizing=None, is_list=False): if normalizing is None: normalizing = [] SENTINEL = object() def test_empty_string_data(): f = Form(fields=[shortcut(required=False, name='foo')], data={'foo': ''}) assert not f.get_errors() assert f.fields_by_name['foo'].value is None assert f.fields_by_name['foo'].value_list is None or f.fields_by_name['foo'].value_list == [] assert f.fields_by_name['foo'].rendered_value == '' def test_empty_data(): f = Form(fields=[shortcut(required=False, name='foo')], data={}) assert not f.get_errors() assert f.fields_by_name['foo'].value is None assert f.fields_by_name['foo'].value_list is None def test_editable_false(): f = Form(fields=[shortcut(required=False, name='foo', initial=SENTINEL, editable=False)], data={'foo': 'asdasasd'}) assert not f.get_errors() assert f.fields_by_name['foo'].value is SENTINEL def test_editable_false_list(): f = Form(fields=[shortcut(required=False, name='foo', initial_list=[SENTINEL], editable=False)], data={'foo': 'asdasasd'}) assert not f.get_errors() assert f.fields_by_name['foo'].value_list == [SENTINEL] def test_roundtrip_from_initial_to_raw_string(): for raw, initial in raw_and_parsed_data_tuples: form = Form(fields=[shortcut(required=True, name='foo', initial=initial)], data={}) assert not form.get_errors() f = form.fields_by_name['foo'] assert not f.is_list assert initial == f.value assert raw == f.rendered_value, 'Roundtrip failed' def test_roundtrip_from_initial_to_raw_string_list(): for raw, initial_list in raw_and_parsed_data_tuples: form = Form(fields=[shortcut(required=True, name='foo', initial_list=initial_list)], data={}) assert not form.get_errors() f = form.fields_by_name['foo'] assert f.is_list assert initial_list == f.value_list assert ', '.join([str(x) for x in raw]) == f.rendered_value, 'Roundtrip failed' def test_roundtrip_from_raw_string_to_initial(): for raw, initial in raw_and_parsed_data_tuples: form = Form(fields=[shortcut(required=True, name='foo')], data={'foo': raw}) assert not form.get_errors(), 'input: %s' % raw f = form.fields_by_name['foo'] if f.is_list: assert f.raw_data_list == raw assert f.value_list == initial if initial: assert [type(x) for x in f.value_list] == [type(x) for x in initial] else: assert f.raw_data == raw assert f.value == initial assert type(f.value) == type(initial) def test_normalizing(): for non_normalized, normalized in normalizing: form = Form(fields=[shortcut(required=True, name='foo')], data={'foo': non_normalized}) assert not form.get_errors() assert form.fields_by_name['foo'].rendered_value == normalized test_empty_string_data() test_empty_data() test_roundtrip_from_raw_string_to_initial() test_normalizing() if is_list: test_roundtrip_from_initial_to_raw_string_list() test_editable_false_list() else: test_roundtrip_from_initial_to_raw_string() test_editable_false() def test_datetime(): shortcut_test( Field.datetime, raw_and_parsed_data_tuples=[ ('2001-02-03 12:13:14', datetime(2001, 2, 3, 12, 13, 14)), ], normalizing=[ ('2001-02-03 12:13', '2001-02-03 12:13:00'), ('2001-02-03 12', '2001-02-03 12:00:00'), ], ) def test_date(): shortcut_test( Field.date, raw_and_parsed_data_tuples=[ ('2001-02-03', date(2001, 2, 3)), ], ) def test_time(): shortcut_test( Field.time, raw_and_parsed_data_tuples=[ ('12:34:56', time(12, 34, 56)), ], normalizing=[ ('2:34:56', '02:34:56'), ], ) def test_integer(): shortcut_test( Field.integer, raw_and_parsed_data_tuples=[ ('123', 123), ], normalizing=[ ('00123', '123'), ], ) def test_float(): shortcut_test( Field.float, raw_and_parsed_data_tuples=[ ('123.0', 123.0), ('123.123', 123.123), ], normalizing=[ ('123', '123.0'), ('00123', '123.0'), ('00123.123', '123.123'), ], ) def test_multi_choice_shortcut(): shortcut_test( Namespace( call_target=Field.multi_choice, choices=['a', 'b', 'c'], ), is_list=True, raw_and_parsed_data_tuples=[ (['b', 'c'], ['b', 'c']), ([], []), ], ) def test_choice_shortcut(): shortcut_test( Namespace( call_target=Field.choice, choices=[1, 2, 3], ), raw_and_parsed_data_tuples=[ ('1', 1), ], ) def test_render_custom(): sentinel = '!!custom!!' assert sentinel in Form(fields=[ Field( name='foo', initial='not sentinel value', render_value=lambda form, field, value: sentinel), ]).table() def test_boolean_initial_true(): fields = [Field.boolean(name='foo', initial=True), Field(name='bar', required=False)] form = Form(request=RequestFactory().get('/'), fields=fields) assert form.fields_by_name['foo'].value is True # If there are arguments, but not for key foo it means checkbox for foo has been unchecked. # Field foo should therefore be false. form = Form(request=RequestFactory().get('/', dict(bar='baz', **{'/': ''})), fields=fields) assert form.fields_by_name['foo'].value is False form = Form(request=RequestFactory().get('/', dict(foo='on', bar='baz', **{'/': ''})), fields=fields) assert form.fields_by_name['foo'].value is True def test_file(): class FooForm(Form): foo = Field.file(required=False) form = FooForm(data=dict(foo='1')) instance = Struct(foo=None) assert form.is_valid() is True form.apply(instance) assert instance.foo == '1' # Non-existent form entry should not overwrite data form = FooForm(data=dict(foo='')) assert form.is_valid(), {x.name: x.errors for x in form.fields} form.apply(instance) assert instance.foo == '1' form = FooForm(data={}) assert form.is_valid(), {x.name: x.errors for x in form.fields} form.apply(instance) assert instance.foo == '1' @pytest.mark.django def test_file_no_roundtrip(): class FooForm(Form): foo = Field.file(is_valid=lambda form, field, parsed_data: (False, 'invalid!')) form = FooForm(data=dict(foo=b'binary_content_here')) assert form.is_valid() is False assert 'binary_content_here' not in form.render() @pytest.mark.django def test_mode_full_form_from_request(): class FooForm(Form): foo = Field(required=True) bar = Field(required=True) baz = Field.boolean(initial=True) # empty POST form = FooForm(request=RequestFactory().post('/', {'/': ''})) assert form.is_valid() is False assert form.errors == set() assert form.fields_by_name['foo'].errors == {'This field is required'} assert form.fields_by_name['bar'].errors == {'This field is required'} assert form.fields_by_name['baz'].errors == set() # not present in POST request means false form = FooForm(request=RequestFactory().post('/', { 'foo': 'x', 'bar': 'y', 'baz': 'false', '/': '', })) assert form.is_valid() is True assert form.fields_by_name['baz'].value is False # all params in GET form = FooForm(request=RequestFactory().get('/', {'/': ''})) assert form.is_valid() is False assert form.fields_by_name['foo'].errors == {'This field is required'} assert form.fields_by_name['bar'].errors == {'This field is required'} assert form.fields_by_name['baz'].errors == set() # not present in POST request means false form = FooForm(request=RequestFactory().get('/', { 'foo': 'x', 'bar': 'y', 'baz': 'on', '/': '', })) assert not form.errors assert not form.fields[0].errors assert form.is_valid() is True def test_mode_initials_from_get(): class FooForm(Form): foo = Field(required=True) bar = Field(required=True) baz = Field.boolean(initial=True) # empty GET form = FooForm(request=RequestFactory().get('/')) assert form.is_valid() is True # initials from GET form = FooForm(request=RequestFactory().get('/', {'foo': 'foo_initial'})) assert form.is_valid() is True assert form.fields_by_name['foo'].value == 'foo_initial' assert form.fields_by_name['foo'].errors == set() assert form.fields_by_name['bar'].errors == set() assert form.fields_by_name['baz'].errors == set() def test_form_errors_function(): class MyForm(Form): foo = Field(is_valid=lambda **_: (False, 'field error')) def post_validation(form): form.add_error('global error') assert MyForm(request=RequestFactory().post('/', {'/': '', 'foo': 'asd'}), post_validation=post_validation).get_errors() == {'global': {'global error'}, 'fields': {'foo': {'field error'}}} @pytest.mark.django @pytest.mark.filterwarnings("ignore:Model 'tests.foomodel' was already registered") def test_null_field_factory(): from django.db import models class ShouldBeNullField(models.Field): pass class FooModel(models.Model): should_be_null = ShouldBeNullField() foo = models.IntegerField() register_field_factory(ShouldBeNullField, None) form = Form.from_model(data=None, model=FooModel) assert list(form.fields_by_name.keys()) == ['foo'] @pytest.mark.django_db @pytest.mark.filterwarnings("ignore:Model 'tests.foomodel' was already registered") @pytest.mark.parametrize( 'kwargs', [ dict(extra__endpoint_attrs=['username']), dict(extra__endpoint_attr='username'), dict(), ] ) def test_choice_queryset_ajax_attrs_direct(kwargs): from django.contrib.auth.models import User User.objects.create(username='foo') user2 = User.objects.create(username='bar') class MyForm(Form): class Meta: name = 'form_name' username = Field.choice_queryset(choices=User.objects.all().order_by('username'), **kwargs) not_returning_anything = Field.integer() form = MyForm(request=RequestFactory().get('/')) assert form.endpoint_dispatch(key='field/username', value='ar') == dict(results=[{'id': user2.pk, 'text': smart_str(user2)}], more=False, page=1) assert form.endpoint_dispatch(key='field/not_returning_anything', value='ar') is None @pytest.mark.django_db @pytest.mark.filterwarnings("ignore:Model 'tests.foomodel' was already registered") @pytest.mark.filterwarnings("ignore:Pagination may yield inconsistent results") @pytest.mark.parametrize( 'kwargs', [ dict(), dict(field__user__extra__endpoint_attrs=['username']), dict(field__user__extra__endpoint_attr='username'), ] ) def test_choice_queryset_ajax_attrs_foreign_key(kwargs): from django.contrib.auth.models import User from django.db import models from django.db.models import CASCADE class FooModel(models.Model): user = models.ForeignKey(User, on_delete=CASCADE) User.objects.create(username='foo') user2 = User.objects.create(username='bar') form = Form.from_model(model=FooModel, data={}, **kwargs) form.request = RequestFactory().get('/') assert form.endpoint_dispatch(key='field/user', value='ar') == dict(results=[{'id': user2.pk, 'text': smart_str(user2)}], more=False, page=1) def test_ajax_namespacing(): class MyForm(Form): foo = Field( endpoint__=lambda **_: 'default', endpoint__bar=lambda **_: 'bar', endpoint__baaz=lambda **_: 'baaz', ) form = MyForm(request=RequestFactory().get('/')) assert 'default' == form.endpoint_dispatch(key='field/foo', value=None) assert 'bar' == form.endpoint_dispatch(key='field/foo/bar', value=None) assert 'baaz' == form.endpoint_dispatch(key='field/foo/baaz', value=None) def test_ajax_config_and_validate(): class MyForm(Form): foo = Field() bar = Field(post_validation=lambda field, **_: field.errors.add('FAIL')) form = MyForm(request=RequestFactory().get('/')) assert dict( name='foo', ) == form.endpoint_dispatch(key='field/foo/config', value=None) assert dict( valid=True, errors=[] ) == form.endpoint_dispatch(key='field/foo/validate', value='new value') assert dict( valid=False, errors=['FAIL'] ) == form.endpoint_dispatch(key='field/bar/validate', value='new value') def test_is_empty_form_marker(): request = RequestFactory().get('/') assert AVOID_EMPTY_FORM.format('') in Form(request=request).render() assert AVOID_EMPTY_FORM.format('') not in Form(request=request, is_full_form=False).render() def test_json_parsing(): # NOTE: Parsing json input requires that any numbers that come in must avoid the string strip f = Form(data={'foo': 1}, fields=[Field.integer(name='foo', strip_input=False)]) assert f.is_valid() assert f.fields_by_name['foo'].value == 1 def test_custom_endpoint(): class MyForm(Form): class Meta: endpoint__foo = lambda key, value, **_: 'foo' + value form = MyForm(data={}) assert 'foobar' == form.endpoint_dispatch(key='foo', value='bar') def reindent(s, before=" ", after=" "): def reindent_line(line): m = re.match(r'^((' + re.escape(before) + r')*)(.*)', line) return after * (len(m.group(1)) // len(before)) + m.group(3) return "\n".join(reindent_line(line) for line in s.splitlines()) def remove_csrf(html_code): csrf_regex = r'<input[^>]+csrfmiddlewaretoken[^>]+>' return re.sub(csrf_regex, '', html_code) def test_render(): class MyForm(Form): bar = Field() expected_html = """ <form action="" method="post"> <div> <tr class="required"> <td class="description_container"> <div class="formlabel"> <label for="id_bar"> Bar </label> </div> <div class="formdescr"> </div> </td> <td> <input id="id_bar" name="bar" type="text" value=""> </td> </tr> <input name="-" type="hidden" value=""/> </div> <div class="form_buttons clear"> <div class="links"> <input accesskey="s" class="button" type="submit" value="Submit"></input> </div> </div> </form> """ actual_html = remove_csrf(MyForm(request=RequestFactory().get('/')).render()) prettified_expected = reindent(BeautifulSoup(expected_html, 'html.parser').prettify()).strip() prettified_actual = reindent(BeautifulSoup(actual_html, 'html.parser').prettify()).strip() assert prettified_expected == prettified_actual, "{}\n !=\n {}".format(prettified_expected, prettified_actual) def test_bool_parse(): for t in ['1', 'true', 't', 'yes', 'y', 'on']: assert bool_parse(t) is True for f in ['0', 'false', 'f', 'no', 'n', 'off']: assert bool_parse(f) is False def test_decimal_parse(): assert decimal_parse(string_value='1') == Decimal(1) with pytest.raises(ValidationError) as e: decimal_parse(string_value='asdasd') assert e.value.messages == ["Invalid literal for Decimal: u'asdasd'"] or e.value.messages == ["Invalid literal for Decimal: 'asdasd'"] def test_url_parse(): assert url_parse(string_value='https://foo.example') == 'https://foo.example' with pytest.raises(ValidationError) as e: url_parse(string_value='asdasd') assert e.value.messages == ['Enter a valid URL.'] def test_render_temlate_none(): # noinspection PyTypeChecker assert render_template(request=None, template=None, context=None) == '' def test_render_template_template_object(): assert render_template( request=RequestFactory().get('/'), context=dict(a='1'), template=Template(template_string='foo {{a}} bar') ) == 'foo 1 bar' @pytest.mark.django def test_link_render(): with pytest.deprecated_call(): import os RequestFactory().get('/', params={}, root_path=os.path.dirname(__file__)) link = Link('Title', template='test_link_render.html') assert link.render() == 'tag=a title=Title' assert link.render() == link.__html__() # used by jinja2 @pytest.mark.django def test_action_render(): import os RequestFactory().get('/', params={}, root_path=os.path.dirname(__file__)) action = Action(display_name='Title', template='test_action_render.html') assert action.render() == 'tag=a display_name=Title' assert action.render() == action.__html__() # used by jinja2 def test_action_repr(): assert repr(Action(display_name='Title', template='test_link_render.html')) == '<Action: Title>' def test_deprecated_link_shortcut_icon(): with pytest.deprecated_call(): assert Link.icon('foo', title='title').render() == '<a ><i class="fa fa-foo"></i> title</a>' def test_action_shortcut_icon(): assert Action.icon('foo', display_name='title').render() == '<a ><i class="fa fa-foo"></i> title</a>' def test_deprecated_render_grouped_links(): with pytest.deprecated_call(): RequestFactory().get('/') # needed when running in flask mode to have an app present form = Form(links=[ Link('a'), Link('b', show=lambda form: False), Link('q', show=lambda form: True), Link('c', group='group'), Link('d', group='group'), Link('f', group='group'), ]) actual_html = form.render_links() expected_html = """ <div class="links"> <div class="dropdown"> <a id="id_dropdown_group" role="button" data-toggle="dropdown" data-target="#" href="/page.html" class="button button-primary"> group <i class="fa fa-lg fa-caret-down"></i> </a> <ul class="dropdown-menu" role="menu" aria-labelledby="id_dropdown_group"> <li role="presentation"> <a role="menuitem">c</a> </li> <li role="presentation"> <a role="menuitem">d</a> </li> <li role="presentation"> <a role="menuitem">f</a> </li> </ul> </div> <a>a</a> <a>q</a> </div>""" prettified_expected = reindent(BeautifulSoup(expected_html, 'html.parser').prettify()).strip() prettified_actual = reindent(BeautifulSoup(actual_html, 'html.parser').prettify()).strip() assert prettified_expected == prettified_actual, "{}\n !=\n {}".format(prettified_expected, prettified_actual) def test_render_grouped_actions(): RequestFactory().get('/') # needed when running in flask mode to have an app present form = Form(actions=dict( a=Action(display_name='a'), b=Action(display_name='b', show=lambda form, **_: False), q=Action(display_name='q', show=lambda form, **_: True), c=Action(display_name='c', group='group'), d=Action(display_name='d', group='group'), f=Action(display_name='f', group='group'), submit__show=False, )) actual_html = form.render_actions() expected_html = """ <div class="links"> <div class="dropdown"> <a id="id_dropdown_group" role="button" data-toggle="dropdown" data-target="#" href="/page.html" class="button button-primary"> group <i class="fa fa-lg fa-caret-down"></i> </a> <ul class="dropdown-menu" role="menu" aria-labelledby="id_dropdown_group"> <li role="presentation"> <a role="menuitem">c</a> </li> <li role="presentation"> <a role="menuitem">d</a> </li> <li role="presentation"> <a role="menuitem">f</a> </li> </ul> </div> <a>a</a> <a>q</a> </div>""" prettified_expected = reindent(BeautifulSoup(expected_html, 'html.parser').prettify()).strip() prettified_actual = reindent(BeautifulSoup(actual_html, 'html.parser').prettify()).strip() assert prettified_expected == prettified_actual, "{}\n !=\n {}".format(prettified_expected, prettified_actual) def test_show_prevents_read_from_instance(): class MyForm(Form): foo = Field(show=False) MyForm(data=Struct(), instance=object()) def test_choice_post_validation_not_overwritten(): def my_post_validation(field, **_): del field raise Exception('foobar') class MyForm(Form): foo = Field.choice(post_validation=my_post_validation, choices=[1, 2, 3]) with pytest.raises(Exception) as e: MyForm() assert str(e.value) == 'foobar' def test_choice_post_validation_chains_empty_choice_when_required_false(): class MyForm(Form): foo = Field.choice(required=False, choices=[1, 2, 3]) form = MyForm() assert list(form.fields_by_name.foo.choice_tuples()) == [ form.fields_by_name.foo.empty_choice_tuple, (1, '1', '1', False), (2, '2', '2', False), (3, '3', '3', False), ] def test_instance_set_earlier_than_evaluate_is_called(): class MyForm(Form): foo = Field(initial=lambda form, **_: form.instance) MyForm() @pytest.mark.django_db def test_auto_field(): from tests.models import Foo form = Form.from_model(data={}, model=Foo) assert 'id' not in form.fields_by_name form = Form.from_model(data={}, model=Foo, field__id__show=True) assert 'id' in form.fields_by_name def test_initial_set_earlier_than_evaluate_is_called(): class MyForm(Form): foo = Field( extra__bar=lambda form, field, **_: field.initial ) assert 17 == MyForm(instance=Struct(foo=17)).fields_by_name.foo.extra.bar @pytest.mark.django_db def test_field_from_model_path(): from .models import Bar class FooForm(Form): baz = Field.from_model(Bar, 'foo__foo', help_text='another help text') class Meta: model = Bar assert FooForm(data=dict(baz='1')).fields[0].attr == 'foo__foo' assert FooForm(data=dict(baz='1')).fields[0].name == 'baz' assert FooForm(data=dict(baz='1')).fields[0].value == 1 assert FooForm(data=dict(baz='1')).fields[0].help_text == 'another help text' assert not FooForm(data=dict(baz='asd')).is_valid() fake = Struct(foo=Struct(foo='1')) assert FooForm(instance=fake).fields[0].initial == '1' assert FooForm(instance=fake).fields[0].parse is int_parse @pytest.mark.django_db def test_field_from_model_subtype(): from django.db import models class Foo(models.IntegerField): pass class FromModelSubtype(models.Model): foo = Foo() result = Field.from_model(model=FromModelSubtype, field_name='foo') assert result.parse is int_parse @pytest.mark.django_db def test_create_members_from_model_path(): from .models import Foo, Bar class BarForm(Form): class Meta: fields = Form.fields_from_model(model=Bar, include=['foo__foo']) bar = Bar.objects.create(foo=Foo.objects.create(foo=7)) form = BarForm(instance=bar) assert len(form.fields) == 1 assert form.fields[0].name == 'foo__foo' assert form.fields[0].help_text == 'foo_help_text' @pytest.mark.django_db def test_create_members_from_model_reject_extra_arguments_to_member_params_by_member_name(): from .models import Foo with pytest.raises(TypeError): create_members_from_model(default_factory=None, model=Foo, member_params_by_member_name=dict(foo=1), include=[]) @pytest.mark.django def test_namespaces_do_not_call_in_templates(): from django.template import RequestContext def raise_always(): assert False assert Template('{{ foo }}').render(RequestContext(None, dict(foo=Namespace(call_target=raise_always)))) @pytest.mark.django def test_choice_queryset_error_message_for_automatic_model_extraction(): with pytest.raises(AssertionError) as e: Field.choice_queryset(choices=[]) assert 'The convenience feature to automatically get the parameter model set only works for QuerySet instances or if you specify model_field' == str(e.value) def test_datetime_parse(): assert datetime_parse('2001-02-03 12') == datetime(2001, 2, 3, 12) bad_date = '091223' with pytest.raises(ValidationError) as e: datetime_parse(bad_date) expected = 'Time data "%s" does not match any of the formats %s' % (bad_date, ', '.join('"%s"' % x for x in datetime_iso_formats)) assert expected == str(e.value) or [expected] == [str(x) for x in e.value] @pytest.mark.django_db def test_from_model_with_inheritance(): from tests.models import FromModelWithInheritanceTest was_called = defaultdict(int) class MyField(Field): @classmethod @class_shortcut def float(cls, call_target=None, **kwargs): was_called['MyField.float'] += 1 return call_target(**kwargs) class MyForm(Form): class Meta: member_class = MyField MyForm.from_model( data=FromModelWithInheritanceTest.objects.all(), model=FromModelWithInheritanceTest, request=RequestFactory().get('/'), ) assert was_called == { 'MyField.float': 1, } def test_deprecated_rendered_property(): with pytest.deprecated_call(): link = Link('foo') assert link.render() == link.rendered def test_rendered_property(): action = Action(display_name='foo') assert action.render() == action.rendered @pytest.mark.django_db def test_expand_member_test(): from tests.models import ExpandModelTestB form = Form.from_model( data={}, model=ExpandModelTestB, field__link__call_target=Field.from_model_expand, ) assert set(form.fields_by_name.keys()) == {'link__f_int', 'link__f_float', 'link__f_bool'} @pytest.mark.django_db def test_expand_member_test_2(): from tests.models import ExpandModelTestB class MyForm(Form): class Meta: fields = Field.from_model_expand(ExpandModelTestB, name='some_thing', field_name='link') form = MyForm( data={}, ) assert set(form.fields_by_name.keys()) == {'some_thing__f_int', 'some_thing__f_float', 'some_thing__f_bool'} assert {x.attr for x in form.fields_by_name.values()} == {'link__f_int', 'link__f_float', 'link__f_bool'} @pytest.mark.django_db def test_expand_member_test_error(): from tests.models import ExpandModelTestB with pytest.raises(TypeError): Form.from_model( data={}, model=ExpandModelTestB, field__doesnotexist__call_target=Field.from_model_expand, ) @pytest.mark.django_db def test_expand_member_test_error_2(): from tests.models import ExpandModelTestB with pytest.raises(TypeError): class MyForm(Form): class Meta: fields = Field.from_model_expand(ExpandModelTestB, name='some_thing', field_name='link', field__doesnotexist=1) @pytest.mark.django_db def test_from_model_override_field(): from tests.models import FormFromModelTest form = Form.from_model(data={}, model=FormFromModelTest, field__f_float=Field(name='f_float')) assert form.fields_by_name.f_float.parse is not float_parse @pytest.mark.django_db def test_get_name_field(): from django.db.models import ( Model, IntegerField, CharField, ForeignKey, CASCADE, ) class Foo1(Model): a = IntegerField() name = CharField(max_length=255) class Bar1(Model): foo = ForeignKey(Foo1, on_delete=CASCADE) class Foo2(Model): a = IntegerField() fooname = CharField(max_length=255) name = CharField(max_length=255) class Bar2(Model): foo = ForeignKey(Foo2, on_delete=CASCADE) class Foo3(Model): name = IntegerField() fooname = CharField(max_length=255) class Bar3(Model): foo = ForeignKey(Foo3, on_delete=CASCADE) class Foo4(Model): fooname = CharField(max_length=255) barname = CharField(max_length=255) class Bar4(Model): foo = ForeignKey(Foo4, on_delete=CASCADE) class Foo5(Model): blabla = CharField(max_length=255) class Bar5(Model): foo = ForeignKey(Foo5, on_delete=CASCADE) class Foo6(Model): a = IntegerField() class Bar6(Model): foo = ForeignKey(Foo6, on_delete=CASCADE) assert get_name_field(Form.from_model(model=Bar1, data={}).fields_by_name.foo) == 'name' assert get_name_field(Form.from_model(model=Bar2, data={}).fields_by_name.foo) == 'name' assert get_name_field(Form.from_model(model=Bar3, data={}).fields_by_name.foo) == 'fooname' assert get_name_field(Form.from_model(model=Bar4, data={}).fields_by_name.foo) == 'fooname' assert get_name_field(Form.from_model(model=Bar5, data={}).fields_by_name.foo) == 'blabla' with pytest.raises(AssertionError): get_name_field(Form.from_model(model=Bar6, data={}).fields_by_name.foo) def test_field_merge(): form = Form( field__foo={}, instance=Struct(foo=1) ) assert len(form.fields) == 1 assert form.fields[0].name == 'foo' assert form.fields_by_name.foo.value == 1 def test_override_doesnt_stick(): class MyForm(Form): foo = Field() form = MyForm(field__foo__show=False) assert len(form.fields_by_name) == 0 form2 = MyForm() assert len(form2.fields_by_name) == 1
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 3679, 63, 646, 199, 199, 646, 295, 199, 504, 5055, 492, 10018, 199, 504, 2197, 492, 1434, 12, 900, 199, 504, 2197, 492, 2197, 199, 199, 504, 6107, 492, 6345, 199, 199, 504, 3229, 63, 964, 14, 5819, 492, 334, 272, 8505, 12, 272, 901, 63, 4322, 63, 3702, 12, 199, 9, 199, 504, 9922, 20, 492, 17132, 199, 646, 4613, 199, 504, 3229, 63, 964, 14, 5819, 492, 5458, 12, 11179, 63, 495, 199, 199, 504, 3229, 63, 12164, 1905, 492, 334, 272, 2519, 63, 515, 12, 272, 5371, 63, 515, 12, 272, 19317, 12, 272, 1021, 63, 24231, 12, 272, 20124, 5919, 12, 199, 9, 199, 504, 3229, 63, 1820, 492, 13039, 199, 504, 3229, 63, 964, 492, 334, 272, 437, 17510, 63, 13993, 63, 3516, 12, 272, 8204, 12, 272, 5024, 12, 272, 2274, 63, 698, 63, 3702, 12, 272, 2155, 63, 1122, 12, 272, 3795, 63, 3288, 12, 272, 6107, 63, 1122, 12, 272, 1166, 63, 1122, 12, 272, 3795, 63, 1160, 12, 272, 10967, 12, 272, 2197, 63, 1122, 12, 272, 2197, 63, 4595, 63, 6321, 12, 272, 1109, 63, 1122, 12, 272, 1218, 63, 6334, 63, 504, 63, 1238, 12, 272, 3653, 63, 504, 63, 1238, 12, 272, 10033, 12, 272, 2069, 63, 1122, 12, 272, 664, 63, 354, 63, 698, 12, 199, 9, 199, 199, 504, 1275, 5819, 492, 18638, 421, 199, 318, 702, 63, 368, 63, 705, 63, 460, 63, 6742, 63, 1135, 63, 1474, 8, 2550, 12, 1295, 63, 1474, 304, 272, 1125, 275, 769, 8, 2550, 2788, 16, 61, 272, 702, 822, 8, 2550, 9, 508, 413, 272, 702, 295, 14, 1733, 8, 1135, 63, 1474, 12, 1125, 9, 421, 199, 318, 511, 63, 15477, 63, 5628, 837, 339, 1021, 4932, 2821, 8, 2821, 304, 267, 1021, 6288, 26, 288, 1504, 275, 359, 792, 8, 354, 534, 1421, 5440, 398, 4681, 275, 5024, 342, 339, 702, 791, 1421, 297, 283, 1700, 936, 508, 663, 8, 5713, 2821, 1252, 955, 63, 991, 63, 354, 14, 1612, 1012, 421, 199, 533, 4932, 774, 2821, 8, 2821, 304, 272, 17135, 275, 5024, 14, 5095, 8, 4577, 2968, 8390, 995, 1415, 29, 797, 9, 272, 3434, 275, 5024, 8, 267, 365, 63, 1078, 29, 2734, 1824, 12, 901, 12, 4565, 63, 576, 26, 334, 288, 4565, 63, 576, 14, 2460, 8, 964, 14, 955, 63, 991, 63, 354, 459, 7522, 2278, 6751, 63, 576, 14, 2325, 342, 435, 18962, 340, 4565, 63, 576, 365, 440, 488, 587, 488, 12, 288, 283, 13355, 1471, 5386, 543, 2071, 83, 63, 4507, 450, 1824, 14, 955, 63, 991, 63, 354, 459, 7522, 2278, 6751, 63, 576, 9, 272, 776, 272, 16538, 275, 5024, 14, 2083, 8, 962, 534, 7811, 363, 11806, 358, 272, 282, 63, 602, 275, 5024, 14, 602, 342, 272, 282, 63, 521, 275, 5024, 14, 521, 342, 272, 12622, 275, 5024, 14, 4871, 342, 272, 4628, 275, 5024, 14, 4871, 342, 272, 31965, 275, 5024, 14, 3029, 63, 5095, 8, 4577, 2968, 5638, 297, 283, 43, 2080, 297, 283, 2673, 53, 995, 1415, 29, 797, 9, 272, 440, 63, 10820, 275, 5024, 14, 505, 8, 2747, 534, 7700, 2222, 13, 10820, 1318, 297, 14783, 29, 797, 9, 272, 3510, 63, 5095, 63, 698, 275, 5024, 14, 3029, 63, 5095, 8, 4577, 2968, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 995, 1415, 29, 797, 9, 339, 327, 3254, 26, 2295, 367, 1006, 3974, 12946, 543, 1415, 29, 797, 421, 199, 318, 511, 63, 2722, 837, 272, 702, 2650, 599, 63, 964, 14, 792, 3925, 3524, 508, 4700, 8, 792, 8, 354, 534, 1421, 1333, 272, 702, 2650, 599, 63, 964, 14, 792, 3925, 3524, 508, 620, 8, 792, 8, 354, 534, 1421, 1333, 421, 199, 318, 511, 63, 2427, 63, 5095, 837, 272, 1021, 11105, 8, 2821, 304, 267, 286, 275, 5024, 14, 5095, 8, 4577, 1524, 17, 12, 499, 12, 650, 566, 339, 1824, 275, 11105, 8, 1069, 29, 2017, 2927, 1252, 1932, 10998, 791, 25772, 283, 20219, 272, 702, 1824, 14, 374, 63, 1078, 342, 365, 756, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 459, 67, 2278, 2550, 508, 791, 2765, 901, 365, 1415, 936, 339, 1021, 2832, 8030, 8, 2821, 304, 267, 286, 275, 5024, 14, 5095, 8, 4577, 1524, 17, 12, 499, 12, 650, 467, 1415, 29, 797, 9, 339, 1824, 275, 2832, 8030, 8, 1069, 29, 2017, 2927, 1252, 1932, 10998, 791, 25772, 3260, 283, 67, 356, 283, 20219, 272, 702, 1824, 14, 374, 63, 1078, 342, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 459, 67, 2278, 2550, 508, 663, 342, 421, 199, 318, 511, 63, 2427, 837, 272, 1824, 275, 4932, 774, 2821, 8, 1069, 29, 2017, 2927, 1252, 1932, 10998, 791, 25772, 283, 20219, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 459, 65, 63, 602, 2278, 585, 365, 488, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 459, 65, 63, 602, 2278, 2550, 508, 791, 2765, 901, 365, 1415, 936, 421, 199, 318, 511, 63, 2427, 63, 1045, 63, 70, 279, 1786, 63, 1422, 837, 272, 1021, 4932, 2821, 8, 2821, 304, 267, 3925, 275, 5024, 14, 5095, 8, 288, 3415, 1524, 16, 12, 413, 467, 288, 2198, 29, 2734, 1059, 63, 585, 12, 1011, 10388, 1109, 8, 875, 63, 585, 9, 267, 776, 272, 1824, 275, 4932, 2821, 8, 1069, 29, 2017, 2927, 1252, 1932, 10998, 791, 1421, 356, 283, 16, 297, 20549, 283, 20219, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 14, 1421, 14, 585, 508, 378, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 14, 1421, 14, 2550, 508, 663, 342, 421, 199, 318, 511, 63, 4229, 63, 1773, 63, 576, 837, 272, 347, 3002, 63, 964, 63, 1773, 63, 576, 8, 964, 12, 901, 12, 1011, 7822, 267, 2150, 1824, 267, 2150, 901, 267, 372, 283, 3749, 365, 3537, 3066, 666, 7, 339, 1021, 4932, 2821, 8, 2821, 304, 267, 3925, 275, 5024, 8, 1773, 63, 576, 29, 1662, 63, 964, 63, 1773, 63, 576, 9, 339, 1824, 275, 4932, 2821, 8, 1069, 29, 2017, 2927 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 12, 3679, 63, 646, 199, 199, 646, 295, 199, 504, 5055, 492, 10018, 199, 504, 2197, 492, 1434, 12, 900, 199, 504, 2197, 492, 2197, 199, 199, 504, 6107, 492, 6345, 199, 199, 504, 3229, 63, 964, 14, 5819, 492, 334, 272, 8505, 12, 272, 901, 63, 4322, 63, 3702, 12, 199, 9, 199, 504, 9922, 20, 492, 17132, 199, 646, 4613, 199, 504, 3229, 63, 964, 14, 5819, 492, 5458, 12, 11179, 63, 495, 199, 199, 504, 3229, 63, 12164, 1905, 492, 334, 272, 2519, 63, 515, 12, 272, 5371, 63, 515, 12, 272, 19317, 12, 272, 1021, 63, 24231, 12, 272, 20124, 5919, 12, 199, 9, 199, 504, 3229, 63, 1820, 492, 13039, 199, 504, 3229, 63, 964, 492, 334, 272, 437, 17510, 63, 13993, 63, 3516, 12, 272, 8204, 12, 272, 5024, 12, 272, 2274, 63, 698, 63, 3702, 12, 272, 2155, 63, 1122, 12, 272, 3795, 63, 3288, 12, 272, 6107, 63, 1122, 12, 272, 1166, 63, 1122, 12, 272, 3795, 63, 1160, 12, 272, 10967, 12, 272, 2197, 63, 1122, 12, 272, 2197, 63, 4595, 63, 6321, 12, 272, 1109, 63, 1122, 12, 272, 1218, 63, 6334, 63, 504, 63, 1238, 12, 272, 3653, 63, 504, 63, 1238, 12, 272, 10033, 12, 272, 2069, 63, 1122, 12, 272, 664, 63, 354, 63, 698, 12, 199, 9, 199, 199, 504, 1275, 5819, 492, 18638, 421, 199, 318, 702, 63, 368, 63, 705, 63, 460, 63, 6742, 63, 1135, 63, 1474, 8, 2550, 12, 1295, 63, 1474, 304, 272, 1125, 275, 769, 8, 2550, 2788, 16, 61, 272, 702, 822, 8, 2550, 9, 508, 413, 272, 702, 295, 14, 1733, 8, 1135, 63, 1474, 12, 1125, 9, 421, 199, 318, 511, 63, 15477, 63, 5628, 837, 339, 1021, 4932, 2821, 8, 2821, 304, 267, 1021, 6288, 26, 288, 1504, 275, 359, 792, 8, 354, 534, 1421, 5440, 398, 4681, 275, 5024, 342, 339, 702, 791, 1421, 297, 283, 1700, 936, 508, 663, 8, 5713, 2821, 1252, 955, 63, 991, 63, 354, 14, 1612, 1012, 421, 199, 533, 4932, 774, 2821, 8, 2821, 304, 272, 17135, 275, 5024, 14, 5095, 8, 4577, 2968, 8390, 995, 1415, 29, 797, 9, 272, 3434, 275, 5024, 8, 267, 365, 63, 1078, 29, 2734, 1824, 12, 901, 12, 4565, 63, 576, 26, 334, 288, 4565, 63, 576, 14, 2460, 8, 964, 14, 955, 63, 991, 63, 354, 459, 7522, 2278, 6751, 63, 576, 14, 2325, 342, 435, 18962, 340, 4565, 63, 576, 365, 440, 488, 587, 488, 12, 288, 283, 13355, 1471, 5386, 543, 2071, 83, 63, 4507, 450, 1824, 14, 955, 63, 991, 63, 354, 459, 7522, 2278, 6751, 63, 576, 9, 272, 776, 272, 16538, 275, 5024, 14, 2083, 8, 962, 534, 7811, 363, 11806, 358, 272, 282, 63, 602, 275, 5024, 14, 602, 342, 272, 282, 63, 521, 275, 5024, 14, 521, 342, 272, 12622, 275, 5024, 14, 4871, 342, 272, 4628, 275, 5024, 14, 4871, 342, 272, 31965, 275, 5024, 14, 3029, 63, 5095, 8, 4577, 2968, 5638, 297, 283, 43, 2080, 297, 283, 2673, 53, 995, 1415, 29, 797, 9, 272, 440, 63, 10820, 275, 5024, 14, 505, 8, 2747, 534, 7700, 2222, 13, 10820, 1318, 297, 14783, 29, 797, 9, 272, 3510, 63, 5095, 63, 698, 275, 5024, 14, 3029, 63, 5095, 8, 4577, 2968, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 995, 1415, 29, 797, 9, 339, 327, 3254, 26, 2295, 367, 1006, 3974, 12946, 543, 1415, 29, 797, 421, 199, 318, 511, 63, 2722, 837, 272, 702, 2650, 599, 63, 964, 14, 792, 3925, 3524, 508, 4700, 8, 792, 8, 354, 534, 1421, 1333, 272, 702, 2650, 599, 63, 964, 14, 792, 3925, 3524, 508, 620, 8, 792, 8, 354, 534, 1421, 1333, 421, 199, 318, 511, 63, 2427, 63, 5095, 837, 272, 1021, 11105, 8, 2821, 304, 267, 286, 275, 5024, 14, 5095, 8, 4577, 1524, 17, 12, 499, 12, 650, 566, 339, 1824, 275, 11105, 8, 1069, 29, 2017, 2927, 1252, 1932, 10998, 791, 25772, 283, 20219, 272, 702, 1824, 14, 374, 63, 1078, 342, 365, 756, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 459, 67, 2278, 2550, 508, 791, 2765, 901, 365, 1415, 936, 339, 1021, 2832, 8030, 8, 2821, 304, 267, 286, 275, 5024, 14, 5095, 8, 4577, 1524, 17, 12, 499, 12, 650, 467, 1415, 29, 797, 9, 339, 1824, 275, 2832, 8030, 8, 1069, 29, 2017, 2927, 1252, 1932, 10998, 791, 25772, 3260, 283, 67, 356, 283, 20219, 272, 702, 1824, 14, 374, 63, 1078, 342, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 459, 67, 2278, 2550, 508, 663, 342, 421, 199, 318, 511, 63, 2427, 837, 272, 1824, 275, 4932, 774, 2821, 8, 1069, 29, 2017, 2927, 1252, 1932, 10998, 791, 25772, 283, 20219, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 459, 65, 63, 602, 2278, 585, 365, 488, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 459, 65, 63, 602, 2278, 2550, 508, 791, 2765, 901, 365, 1415, 936, 421, 199, 318, 511, 63, 2427, 63, 1045, 63, 70, 279, 1786, 63, 1422, 837, 272, 1021, 4932, 2821, 8, 2821, 304, 267, 3925, 275, 5024, 14, 5095, 8, 288, 3415, 1524, 16, 12, 413, 467, 288, 2198, 29, 2734, 1059, 63, 585, 12, 1011, 10388, 1109, 8, 875, 63, 585, 9, 267, 776, 272, 1824, 275, 4932, 2821, 8, 1069, 29, 2017, 2927, 1252, 1932, 10998, 791, 1421, 356, 283, 16, 297, 20549, 283, 20219, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 14, 1421, 14, 585, 508, 378, 272, 702, 1824, 14, 955, 63, 991, 63, 354, 14, 1421, 14, 2550, 508, 663, 342, 421, 199, 318, 511, 63, 4229, 63, 1773, 63, 576, 837, 272, 347, 3002, 63, 964, 63, 1773, 63, 576, 8, 964, 12, 901, 12, 1011, 7822, 267, 2150, 1824, 267, 2150, 901, 267, 372, 283, 3749, 365, 3537, 3066, 666, 7, 339, 1021, 4932, 2821, 8, 2821, 304, 267, 3925, 275, 5024, 8, 1773, 63, 576, 29, 1662, 63, 964, 63, 1773, 63, 576, 9, 339, 1824, 275, 4932, 2821, 8, 1069, 29, 2017, 2927, 0 ]
[ 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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ink.rotmat import Vector3, Matrix3 from numpy import linspace from visual import * class Quat: def __init__(self,w=1.0,x=0.0,y=0.0,z=0.0): self.w = w self.x = x self.y = y self.z = z def to_euler(self): roll = (atan2(2.0*(self.w*self.x + self.y*self.z), 1 - 2.0*(self.x*self.x + self.y*self.y))) pitch = asin(2.0*(self.w*self.y - self.z*self.x)) yaw = atan2(2.0*(self.w*self.z + self.x*self.y), 1 - 2.0*(self.y*self.y + self.z*self.z)) return Vector3(roll,pitch,yaw) def from_euler(self,euler): #(roll,pitch,yaw) cr2 = cos(euler[0]*0.5) cp2 = cos(euler[1]*0.5) cy2 = cos(euler[2]*0.5) sr2 = sin(euler[0]*0.5) sp2 = sin(euler[1]*0.5) sy2 = sin(euler[2]*0.5) self.w = cr2*cp2*cy2 + sr2*sp2*sy2 self.x = sr2*cp2*cy2 - cr2*sp2*sy2 self.y = cr2*sp2*cy2 + sr2*cp2*sy2 self.z = cr2*cp2*sy2 - sr2*sp2*cy2 return self def from_axis_angle(self, vec): theta = vec.length() if theta == 0: self.w = 1.0 self.x = 0.0 self.y = 0.0 self.z = 0.0 return vec_normalized = vec.normalized() st2 = sin(theta/2.0) self.w = cos(theta/2.0) self.x = vec_normalized.x * st2 self.y = vec_normalized.y * st2 self.z = vec_normalized.z * st2 def rotate(self, vec): r = Quat() r.from_axis_angle(vec) q = self * r self.w = q.w self.x = q.x self.y = q.y self.z = q.z def to_axis_angle(self): l = sqrt(self.x**2+self.y**2+self.z**2) (x,y,z) = (self.x,self.y,self.z) if l != 0: temp = 2.0*atan2(l,self.w) if temp > pi: temp -= 2*pi elif temp < -pi: temp += 2*pi (x,y,z) = (temp*x/l,temp*y/l,temp*z/l) return Vector3(x,y,z) def to_rotation_matrix(self): m = Matrix3() yy = self.y**2 yz = self.y * self.z xx = self.x**2 xy = self.x * self.y xz = self.x * self.z wx = self.w * self.x wy = self.w * self.y wz = self.w * self.z zz = self.z**2 m.a.x = 1.0-2.0*(yy + zz) m.a.y = 2.0*(xy - wz) m.a.z = 2.0*(xz + wy) m.b.x = 2.0*(xy + wz) m.b.y = 1.0-2.0*(xx + zz) m.b.z = 2.0*(yz - wx) m.c.x = 2.0*(xz - wy) m.c.y = 2.0*(yz + wx) m.c.z = 1.0-2.0*(xx + yy) return m def inverse(self): return Quat(self.w,-self.x,-self.y,-self.z) def __mul__(self,operand): ret = Quat() w1=self.w x1=self.x y1=self.y z1=self.z w2=operand.w x2=operand.x y2=operand.y z2=operand.z ret.w = w1*w2 - x1*x2 - y1*y2 - z1*z2 ret.x = w1*x2 + x1*w2 + y1*z2 - z1*y2 ret.y = w1*y2 - x1*z2 + y1*w2 + z1*x2 ret.z = w1*z2 + x1*y2 - y1*x2 + z1*w2 return ret def __str__(self): return "Quat(%f, %f, %f, %f)" % (self.w,self.x,self.y,self.z) def vpy_vec(vec): return vector(vec.y, -vec.z, -vec.x) def update_arrows(q,x,y,z): m = q.to_rotation_matrix().transposed() x.axis = vpy_vec(m*Vector3(1,0,0)) x.up = vpy_vec(m*Vector3(0,1,0)) y.axis = vpy_vec(m*Vector3(0,1,0)) y.up = vpy_vec(m*Vector3(1,0,0)) z.axis = vpy_vec(m*Vector3(0,0,1)) z.up = vpy_vec(m*Vector3(1,0,0)) class Attitude: def __init__(self,reference=False): self.labels = [] self.xarrows = [] self.yarrows = [] self.zarrows = [] self.q = Quat() self.reference = reference self.update_arrows() def add_arrows(self, arrowpos = Vector3(0,0,0), labeltext=None): if labeltext is not None: self.labels.append(label(pos = vpy_vec(arrowpos), text=labeltext)) sw = .005 if self.reference else .05 self.xarrows.append(arrow(pos=vpy_vec(arrowpos),color=color.red,opacity=1,shaftwidth=sw)) self.yarrows.append(arrow(pos=vpy_vec(arrowpos),color=color.green,opacity=1,shaftwidth=sw)) self.zarrows.append(arrow(pos=vpy_vec(arrowpos),color=color.blue,opacity=1,shaftwidth=sw)) self.update_arrows() def rotate(self, vec): self.q.rotate(vec) def update_arrows(self): m = self.q.to_rotation_matrix().transposed() sl = 1.1 if self.reference else 1.0 for i in self.xarrows: i.axis = vpy_vec(m*Vector3(sl,0,0)) i.up = vpy_vec(m*Vector3(0,1,0)) for i in self.yarrows: i.axis = vpy_vec(m*Vector3(0,sl,0)) i.up = vpy_vec(m*Vector3(1,0,0)) for i in self.zarrows: i.axis = vpy_vec(m*Vector3(0,0,sl)) i.up = vpy_vec(m*Vector3(1,0,0)) for i in self.labels: i.xoffset = scene.width*0.07 i.yoffset = scene.width*0.1 class Tian_integrator: def __init__(self, integrate_separately=True): self.alpha = Vector3(0,0,0) self.beta = Vector3(0,0,0) self.last_alpha = Vector3(0,0,0) self.last_delta_alpha = Vector3(0,0,0) self.last_sample = Vector3(0,0,0) self.integrate_separately = integrate_separately def add_sample(self, sample, dt): delta_alpha = (self.last_sample+sample)*0.5*dt self.alpha += delta_alpha delta_beta = 0.5 * (self.last_alpha + (1.0/6.0)*self.last_delta_alpha)%delta_alpha if self.integrate_separately: self.beta += delta_beta else: self.alpha += delta_beta self.last_alpha = self.alpha self.last_delta_alpha = delta_alpha self.last_sample = sample def pop_delta_angles(self): ret = self.alpha + self.beta self.alpha.zero() self.beta.zero() return ret filter2p_1khz_30hz_data = {} def filter2p_1khz_30hz(sample, key): global filter2p_1khz_30hz_data if not key in filter2p_1khz_30hz_data: filter2p_1khz_30hz_data[key] = (0.0,0.0) (delay_element_1, delay_element_2) = filter2p_1khz_30hz_data[key] sample_freq = 1000 cutoff_freq = 30 fr = sample_freq // cutoff_freq ohm = tan(pi/fr) c = 1.0+2.0*cos(pi/4.0)*ohm + ohm**2 b0 = ohm**2/c b1 = 2.0*b0 b2 = b0 a1 = 2.0*(ohm**2-1.0)/c a2 = (1.0-2.0*cos(pi/4.0)*ohm+ohm**2)/c delay_element_0 = sample - delay_element_1 * a1 - delay_element_2 * a2 output = delay_element_0 * b0 + delay_element_1 * b1 + delay_element_2 * b2 filter2p_1khz_30hz_data[key] = (delay_element_0, delay_element_1) return output def filter2p_1khz_30hz_vector3(sample, key): ret = Vector3() ret.x = filter2p_1khz_30hz(sample.x, "vec3f"+key+"x") ret.y = filter2p_1khz_30hz(sample.y, "vec3f"+key+"y") ret.z = filter2p_1khz_30hz(sample.z, "vec3f"+key+"z") return ret reference_attitude = Attitude(True) uncorrected_attitude_low = Attitude() uncorrected_attitude_high = Attitude() corrected_attitude = Attitude() corrected_attitude_combined = Attitude() corrected_attitude_integrator = Tian_integrator() corrected_attitude_integrator_combined = Tian_integrator(integrate_separately = False) reference_attitude.add_arrows(Vector3(0,-3,0)) uncorrected_attitude_low.add_arrows(Vector3(0,-3,0), "no correction\nlow rate integration\n30hz software LPF @ 1khz\n(ardupilot 2015-02-18)") reference_attitude.add_arrows(Vector3(0,-1,0)) uncorrected_attitude_high.add_arrows(Vector3(0,-1,0), "no correction\nhigh rate integration") reference_attitude.add_arrows(Vector3(0,1,0)) corrected_attitude.add_arrows(Vector3(0,1,0), "Tian et al\nseparate integration") reference_attitude.add_arrows(Vector3(0,3,0)) corrected_attitude_combined.add_arrows(Vector3(0,3,0), "Tian et al\ncombined_integration\n(proposed patch)") #scene.scale = (0.3,0.3,0.3) scene.fov = 0.001 scene.forward = (-0.5, -0.5, -1) coning_frequency_hz = 50 coning_magnitude_rad_s = 2 label_text = ( "coning motion frequency %f hz\n" "coning motion peak amplitude %f deg/s\n" "thin arrows are reference attitude" ) % (coning_frequency_hz, degrees(coning_magnitude_rad_s)) label(pos = vpy_vec(Vector3(0,0,2)), text=label_text) t = 0.0 dt_10000 = 0.0001 dt_1000 = 0.001 dt_333 = 0.003 accumulated_delta_angle = Vector3(0,0,0) last_gyro_10000 = Vector3(0,0,0) last_gyro_1000 = Vector3(0,0,0) last_filtered_gyro_333 = Vector3(0,0,0) filtered_gyro = Vector3(0,0,0) while True: rate(66) for i in range(5): for j in range(3): for k in range(10): #vvvvvvvvvv 10 kHz vvvvvvvvvv# #compute angular rate at current time gyro = Vector3(sin(t*coning_frequency_hz*2*pi), cos(t*coning_frequency_hz*2*pi),0)*coning_magnitude_rad_s #integrate reference attitude reference_attitude.rotate((gyro+last_gyro_10000) * dt_10000 * 0.5) #increment time t += dt_10000 last_gyro_10000 = gyro #vvvvvvvvvv 1 kHz vvvvvvvvvv# #update filter for sim 1 filtered_gyro = filter2p_1khz_30hz_vector3(gyro, "1") #update integrator for sim 2 accumulated_delta_angle += (gyro+last_gyro_1000) * dt_1000 * 0.5 #update integrator for sim 3 corrected_attitude_integrator.add_sample(gyro, dt_1000) #update integrator for sim 4 corrected_attitude_integrator_combined.add_sample(gyro, dt_1000) last_gyro_1000 = gyro #vvvvvvvvvv 333 Hz vvvvvvvvvv# #update sim 1 (leftmost) uncorrected_attitude_low.rotate((filtered_gyro+last_filtered_gyro_333) * dt_333 * 0.5) #update sim 2 uncorrected_attitude_high.rotate(accumulated_delta_angle) accumulated_delta_angle.zero() #update sim 3 corrected_attitude.rotate(corrected_attitude_integrator.pop_delta_angles()) #update sim 4 (rightmost) corrected_attitude_combined.rotate(corrected_attitude_integrator_combined.pop_delta_angles()) last_filtered_gyro_333 = filtered_gyro #vvvvvvvvvv 66 Hz vvvvvvvvvv# reference_attitude.update_arrows() corrected_attitude.update_arrows() corrected_attitude_combined.update_arrows() uncorrected_attitude_low.update_arrows() uncorrected_attitude_high.update_arrows()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 3473, 492, 627, 199, 504, 1134, 24610, 14, 4571, 569, 492, 11388, 19, 12, 8449, 19, 199, 504, 2680, 492, 7403, 2638, 199, 504, 13104, 492, 627, 199, 199, 533, 5843, 292, 26, 272, 347, 636, 826, 721, 277, 12, 87, 29, 17, 14, 16, 12, 88, 29, 16, 14, 16, 12, 89, 29, 16, 14, 16, 12, 90, 29, 16, 14, 16, 304, 267, 291, 14, 87, 275, 336, 267, 291, 14, 88, 275, 671, 267, 291, 14, 89, 275, 612, 267, 291, 14, 90, 275, 1315, 339, 347, 370, 63, 69, 19345, 8, 277, 304, 267, 11848, 275, 334, 16080, 18, 8, 18, 14, 16, 5830, 277, 14, 87, 10, 277, 14, 88, 435, 291, 14, 89, 10, 277, 14, 90, 395, 413, 446, 499, 14, 16, 5830, 277, 14, 88, 10, 277, 14, 88, 435, 291, 14, 89, 10, 277, 14, 89, 1724, 267, 20031, 275, 465, 262, 8, 18, 14, 16, 5830, 277, 14, 87, 10, 277, 14, 89, 446, 291, 14, 90, 10, 277, 14, 88, 430, 267, 612, 10084, 275, 31393, 18, 8, 18, 14, 16, 5830, 277, 14, 87, 10, 277, 14, 90, 435, 291, 14, 88, 10, 277, 14, 89, 395, 413, 446, 499, 14, 16, 5830, 277, 14, 89, 10, 277, 14, 89, 435, 291, 14, 90, 10, 277, 14, 90, 430, 267, 372, 11388, 19, 8, 2827, 12, 16966, 12, 89, 10084, 9, 339, 347, 687, 63, 69, 19345, 8, 277, 12, 69, 19345, 304, 267, 21571, 2827, 12, 16966, 12, 89, 10084, 9, 267, 2467, 18, 275, 9794, 8, 69, 19345, 59, 16, 3672, 16, 14, 21, 9, 267, 7667, 18, 275, 9794, 8, 69, 19345, 59, 17, 3672, 16, 14, 21, 9, 267, 6325, 18, 275, 9794, 8, 69, 19345, 59, 18, 3672, 16, 14, 21, 9, 267, 11483, 18, 275, 9829, 8, 69, 19345, 59, 16, 3672, 16, 14, 21, 9, 267, 2249, 18, 275, 9829, 8, 69, 19345, 59, 17, 3672, 16, 14, 21, 9, 267, 1847, 18, 275, 9829, 8, 69, 19345, 59, 18, 3672, 16, 14, 21, 9, 398, 291, 14, 87, 275, 2467, 18, 10, 1850, 18, 10, 1480, 18, 435, 11483, 18, 10, 681, 18, 10, 1786, 18, 267, 291, 14, 88, 275, 11483, 18, 10, 1850, 18, 10, 1480, 18, 446, 2467, 18, 10, 681, 18, 10, 1786, 18, 267, 291, 14, 89, 275, 2467, 18, 10, 681, 18, 10, 1480, 18, 435, 11483, 18, 10, 1850, 18, 10, 1786, 18, 267, 291, 14, 90, 275, 2467, 18, 10, 1850, 18, 10, 1786, 18, 446, 11483, 18, 10, 681, 18, 10, 1480, 18, 267, 372, 291, 339, 347, 687, 63, 3127, 63, 4593, 8, 277, 12, 10782, 304, 267, 12724, 275, 10782, 14, 1267, 342, 267, 340, 12724, 508, 378, 26, 288, 291, 14, 87, 275, 413, 14, 16, 288, 291, 14, 88, 275, 378, 14, 16, 288, 291, 14, 89, 275, 378, 14, 16, 288, 291, 14, 90, 275, 378, 14, 16, 288, 372, 398, 10782, 63, 12916, 275, 10782, 14, 12916, 342, 398, 410, 18, 275, 9829, 8, 9337, 15, 18, 14, 16, 9, 267, 291, 14, 87, 275, 9794, 8, 9337, 15, 18, 14, 16, 9, 267, 291, 14, 88, 275, 10782, 63, 12916, 14, 88, 627, 410, 18, 267, 291, 14, 89, 275, 10782, 63, 12916, 14, 89, 627, 410, 18, 267, 291, 14, 90, 275, 10782, 63, 12916, 14, 90, 627, 410, 18, 339, 347, 20071, 8, 277, 12, 10782, 304, 267, 519, 275, 5843, 292, 342, 267, 519, 14, 504, 63, 3127, 63, 4593, 8, 6046, 9, 267, 1894, 275, 291, 627, 519, 267, 291, 14, 87, 275, 1894, 14, 87, 267, 291, 14, 88, 275, 1894, 14, 88, 267, 291, 14, 89, 275, 1894, 14, 89, 267, 291, 14, 90, 275, 1894, 14, 90, 339, 347, 370, 63, 3127, 63, 4593, 8, 277, 304, 267, 634, 275, 7452, 8, 277, 14, 88, 538, 18, 11, 277, 14, 89, 538, 18, 11, 277, 14, 90, 538, 18, 9, 398, 334, 88, 12, 89, 12, 90, 9, 275, 334, 277, 14, 88, 12, 277, 14, 89, 12, 277, 14, 90, 9, 267, 340, 634, 1137, 378, 26, 288, 2388, 275, 499, 14, 16, 10, 16080, 18, 8, 76, 12, 277, 14, 87, 9, 288, 340, 2388, 690, 6682, 26, 355, 2388, 4862, 499, 10, 1038, 288, 916, 2388, 665, 446, 1038, 26, 355, 2388, 847, 499, 10, 1038, 288, 334, 88, 12, 89, 12, 90, 9, 275, 334, 808, 10, 88, 15, 76, 12, 808, 10, 89, 15, 76, 12, 808, 10, 90, 15, 76, 9, 267, 372, 11388, 19, 8, 88, 12, 89, 12, 90, 9, 339, 347, 370, 63, 15362, 63, 3642, 8, 277, 304, 267, 333, 275, 8449, 19, 342, 267, 20435, 275, 291, 14, 89, 538, 18, 267, 612, 90, 275, 291, 14, 89, 627, 291, 14, 90, 267, 19379, 275, 291, 14, 88, 538, 18, 267, 13222, 275, 291, 14, 88, 627, 291, 14, 89, 267, 671, 90, 275, 291, 14, 88, 627, 291, 14, 90, 267, 4818, 275, 291, 14, 87, 627, 291, 14, 88, 267, 336, 89, 275, 291, 14, 87, 627, 291, 14, 89, 267, 336, 90, 275, 291, 14, 87, 627, 291, 14, 90, 267, 1315, 90, 275, 291, 14, 90, 538, 18, 398, 333, 14, 65, 14, 88, 275, 413, 14, 16, 13, 18, 14, 16, 5830, 7566, 435, 1315, 90, 9, 267, 333, 14, 65, 14, 89, 275, 257, 499, 14, 16, 5830, 1702, 446, 336, 90, 9, 267, 333, 14, 65, 14, 90, 275, 257, 499, 14, 16, 5830, 19196, 435, 336, 89, 9, 267, 333, 14, 66, 14, 88, 275, 257, 499, 14, 16, 5830, 1702, 435, 336, 90, 9, 267, 333, 14, 66, 14, 89, 275, 413, 14, 16, 13, 18, 14, 16, 5830, 2154, 435, 1315, 90, 9, 267, 333, 14, 66, 14, 90, 275, 257, 499, 14, 16, 5830, 19873, 446, 4818, 9, 267, 333, 14, 67, 14, 88, 275, 257, 499, 14, 16, 5830, 19196, 446, 336, 89, 9, 267, 333, 14, 67, 14, 89, 275, 257, 499, 14, 16, 5830, 19873, 435 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 3473, 492, 627, 199, 504, 1134, 24610, 14, 4571, 569, 492, 11388, 19, 12, 8449, 19, 199, 504, 2680, 492, 7403, 2638, 199, 504, 13104, 492, 627, 199, 199, 533, 5843, 292, 26, 272, 347, 636, 826, 721, 277, 12, 87, 29, 17, 14, 16, 12, 88, 29, 16, 14, 16, 12, 89, 29, 16, 14, 16, 12, 90, 29, 16, 14, 16, 304, 267, 291, 14, 87, 275, 336, 267, 291, 14, 88, 275, 671, 267, 291, 14, 89, 275, 612, 267, 291, 14, 90, 275, 1315, 339, 347, 370, 63, 69, 19345, 8, 277, 304, 267, 11848, 275, 334, 16080, 18, 8, 18, 14, 16, 5830, 277, 14, 87, 10, 277, 14, 88, 435, 291, 14, 89, 10, 277, 14, 90, 395, 413, 446, 499, 14, 16, 5830, 277, 14, 88, 10, 277, 14, 88, 435, 291, 14, 89, 10, 277, 14, 89, 1724, 267, 20031, 275, 465, 262, 8, 18, 14, 16, 5830, 277, 14, 87, 10, 277, 14, 89, 446, 291, 14, 90, 10, 277, 14, 88, 430, 267, 612, 10084, 275, 31393, 18, 8, 18, 14, 16, 5830, 277, 14, 87, 10, 277, 14, 90, 435, 291, 14, 88, 10, 277, 14, 89, 395, 413, 446, 499, 14, 16, 5830, 277, 14, 89, 10, 277, 14, 89, 435, 291, 14, 90, 10, 277, 14, 90, 430, 267, 372, 11388, 19, 8, 2827, 12, 16966, 12, 89, 10084, 9, 339, 347, 687, 63, 69, 19345, 8, 277, 12, 69, 19345, 304, 267, 21571, 2827, 12, 16966, 12, 89, 10084, 9, 267, 2467, 18, 275, 9794, 8, 69, 19345, 59, 16, 3672, 16, 14, 21, 9, 267, 7667, 18, 275, 9794, 8, 69, 19345, 59, 17, 3672, 16, 14, 21, 9, 267, 6325, 18, 275, 9794, 8, 69, 19345, 59, 18, 3672, 16, 14, 21, 9, 267, 11483, 18, 275, 9829, 8, 69, 19345, 59, 16, 3672, 16, 14, 21, 9, 267, 2249, 18, 275, 9829, 8, 69, 19345, 59, 17, 3672, 16, 14, 21, 9, 267, 1847, 18, 275, 9829, 8, 69, 19345, 59, 18, 3672, 16, 14, 21, 9, 398, 291, 14, 87, 275, 2467, 18, 10, 1850, 18, 10, 1480, 18, 435, 11483, 18, 10, 681, 18, 10, 1786, 18, 267, 291, 14, 88, 275, 11483, 18, 10, 1850, 18, 10, 1480, 18, 446, 2467, 18, 10, 681, 18, 10, 1786, 18, 267, 291, 14, 89, 275, 2467, 18, 10, 681, 18, 10, 1480, 18, 435, 11483, 18, 10, 1850, 18, 10, 1786, 18, 267, 291, 14, 90, 275, 2467, 18, 10, 1850, 18, 10, 1786, 18, 446, 11483, 18, 10, 681, 18, 10, 1480, 18, 267, 372, 291, 339, 347, 687, 63, 3127, 63, 4593, 8, 277, 12, 10782, 304, 267, 12724, 275, 10782, 14, 1267, 342, 267, 340, 12724, 508, 378, 26, 288, 291, 14, 87, 275, 413, 14, 16, 288, 291, 14, 88, 275, 378, 14, 16, 288, 291, 14, 89, 275, 378, 14, 16, 288, 291, 14, 90, 275, 378, 14, 16, 288, 372, 398, 10782, 63, 12916, 275, 10782, 14, 12916, 342, 398, 410, 18, 275, 9829, 8, 9337, 15, 18, 14, 16, 9, 267, 291, 14, 87, 275, 9794, 8, 9337, 15, 18, 14, 16, 9, 267, 291, 14, 88, 275, 10782, 63, 12916, 14, 88, 627, 410, 18, 267, 291, 14, 89, 275, 10782, 63, 12916, 14, 89, 627, 410, 18, 267, 291, 14, 90, 275, 10782, 63, 12916, 14, 90, 627, 410, 18, 339, 347, 20071, 8, 277, 12, 10782, 304, 267, 519, 275, 5843, 292, 342, 267, 519, 14, 504, 63, 3127, 63, 4593, 8, 6046, 9, 267, 1894, 275, 291, 627, 519, 267, 291, 14, 87, 275, 1894, 14, 87, 267, 291, 14, 88, 275, 1894, 14, 88, 267, 291, 14, 89, 275, 1894, 14, 89, 267, 291, 14, 90, 275, 1894, 14, 90, 339, 347, 370, 63, 3127, 63, 4593, 8, 277, 304, 267, 634, 275, 7452, 8, 277, 14, 88, 538, 18, 11, 277, 14, 89, 538, 18, 11, 277, 14, 90, 538, 18, 9, 398, 334, 88, 12, 89, 12, 90, 9, 275, 334, 277, 14, 88, 12, 277, 14, 89, 12, 277, 14, 90, 9, 267, 340, 634, 1137, 378, 26, 288, 2388, 275, 499, 14, 16, 10, 16080, 18, 8, 76, 12, 277, 14, 87, 9, 288, 340, 2388, 690, 6682, 26, 355, 2388, 4862, 499, 10, 1038, 288, 916, 2388, 665, 446, 1038, 26, 355, 2388, 847, 499, 10, 1038, 288, 334, 88, 12, 89, 12, 90, 9, 275, 334, 808, 10, 88, 15, 76, 12, 808, 10, 89, 15, 76, 12, 808, 10, 90, 15, 76, 9, 267, 372, 11388, 19, 8, 88, 12, 89, 12, 90, 9, 339, 347, 370, 63, 15362, 63, 3642, 8, 277, 304, 267, 333, 275, 8449, 19, 342, 267, 20435, 275, 291, 14, 89, 538, 18, 267, 612, 90, 275, 291, 14, 89, 627, 291, 14, 90, 267, 19379, 275, 291, 14, 88, 538, 18, 267, 13222, 275, 291, 14, 88, 627, 291, 14, 89, 267, 671, 90, 275, 291, 14, 88, 627, 291, 14, 90, 267, 4818, 275, 291, 14, 87, 627, 291, 14, 88, 267, 336, 89, 275, 291, 14, 87, 627, 291, 14, 89, 267, 336, 90, 275, 291, 14, 87, 627, 291, 14, 90, 267, 1315, 90, 275, 291, 14, 90, 538, 18, 398, 333, 14, 65, 14, 88, 275, 413, 14, 16, 13, 18, 14, 16, 5830, 7566, 435, 1315, 90, 9, 267, 333, 14, 65, 14, 89, 275, 257, 499, 14, 16, 5830, 1702, 446, 336, 90, 9, 267, 333, 14, 65, 14, 90, 275, 257, 499, 14, 16, 5830, 19196, 435, 336, 89, 9, 267, 333, 14, 66, 14, 88, 275, 257, 499, 14, 16, 5830, 1702, 435, 336, 90, 9, 267, 333, 14, 66, 14, 89, 275, 413, 14, 16, 13, 18, 14, 16, 5830, 2154, 435, 1315, 90, 9, 267, 333, 14, 66, 14, 90, 275, 257, 499, 14, 16, 5830, 19873, 446, 4818, 9, 267, 333, 14, 67, 14, 88, 275, 257, 499, 14, 16, 5830, 19196, 446, 336, 89, 9, 267, 333, 14, 67, 14, 89, 275, 257, 499, 14, 16, 5830, 19873, 435, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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request, response): origin = request.GET.first("origin", request.headers.get('origin')) if "check" in request.GET: token = request.GET.first("token") value = request.server.stash.take(token) if value is not None: if request.GET.first("check", None) == "keep": request.server.stash.put(token, value) body = "1" else: body = "0" return [("Content-Type", "text/plain")], body if origin != 'none': response.headers.set("Access-Control-Allow-Origin", origin) if 'origin2' in request.GET: response.headers.append("Access-Control-Allow-Origin", request.GET.first('origin2')) #Preflight if 'headers' in request.GET: response.headers.set("Access-Control-Allow-Headers", request.GET.first('headers')) if 'credentials' in request.GET: response.headers.set("Access-Control-Allow-Credentials", request.GET.first('credentials')) if 'methods' in request.GET: response.headers.set("Access-Control-Allow-Methods", request.GET.first('methods')) code = request.GET.first('code', None) if request.method == 'OPTIONS': #Override the response code if we're in a preflight and it's asked if 'preflight' in request.GET: code = int(request.GET.first('preflight')) #Log that the preflight actually happened if we have an ident if 'token' in request.GET: request.server.stash.put(request.GET['token']) if 'location' in request.GET: if code is None: code = 302 if code >= 300 and code < 400: response.headers.set("Location", request.GET.first('location')) headers = {} for name, values in request.headers.iteritems(): if len(values) == 1: headers[name] = values[0] else: #I have no idea, really headers[name] = values headers['get_value'] = request.GET.first('get_value', '') body = json.dumps(headers) if code: return (code, "StatusText"), [], body else: return body
mpl-2.0
[ 646, 2022, 199, 199, 318, 2446, 8, 1069, 12, 1177, 304, 272, 6330, 275, 1056, 14, 2970, 14, 2246, 480, 6493, 401, 1056, 14, 2139, 14, 362, 360, 6493, 1333, 339, 340, 298, 1074, 2, 315, 1056, 14, 2970, 26, 267, 1526, 275, 1056, 14, 2970, 14, 2246, 480, 1418, 531, 267, 574, 275, 1056, 14, 1000, 14, 27145, 14, 11066, 8, 1418, 9, 267, 340, 574, 365, 440, 488, 26, 288, 340, 1056, 14, 2970, 14, 2246, 480, 1074, 401, 488, 9, 508, 298, 3250, 582, 355, 1056, 14, 1000, 14, 27145, 14, 524, 8, 1418, 12, 574, 9, 288, 2396, 275, 298, 17, 2, 267, 587, 26, 288, 2396, 275, 298, 16, 2, 267, 372, 10003, 2714, 13, 804, 401, 298, 505, 15, 6104, 17857, 2396, 2378, 340, 6330, 1137, 283, 3592, 356, 267, 1177, 14, 2139, 14, 409, 480, 3946, 13, 3717, 13, 7852, 13, 12834, 401, 6330, 9, 272, 340, 283, 6493, 18, 7, 315, 1056, 14, 2970, 26, 267, 1177, 14, 2139, 14, 740, 480, 3946, 13, 3717, 13, 7852, 13, 12834, 401, 1056, 14, 2970, 14, 2246, 360, 6493, 18, 1333, 339, 327, 18441, 4040, 272, 340, 283, 2139, 7, 315, 1056, 14, 2970, 26, 267, 1177, 14, 2139, 14, 409, 480, 3946, 13, 3717, 13, 7852, 13, 9883, 401, 1056, 14, 2970, 14, 2246, 360, 2139, 1333, 272, 340, 283, 6942, 7, 315, 1056, 14, 2970, 26, 267, 1177, 14, 2139, 14, 409, 480, 3946, 13, 3717, 13, 7852, 13, 13428, 401, 1056, 14, 2970, 14, 2246, 360, 6942, 1333, 272, 340, 283, 2474, 7, 315, 1056, 14, 2970, 26, 267, 1177, 14, 2139, 14, 409, 480, 3946, 13, 3717, 13, 7852, 13, 10385, 401, 1056, 14, 2970, 14, 2246, 360, 2474, 1333, 339, 1233, 275, 1056, 14, 2970, 14, 2246, 360, 600, 297, 488, 9, 272, 340, 1056, 14, 765, 508, 283, 8808, 356, 267, 327, 11954, 314, 1177, 1233, 340, 781, 3984, 315, 282, 20491, 4040, 436, 652, 1159, 20864, 267, 340, 283, 13829, 4040, 7, 315, 1056, 14, 2970, 26, 288, 1233, 275, 1109, 8, 1069, 14, 2970, 14, 2246, 360, 13829, 4040, 1333, 398, 327, 2445, 626, 314, 20491, 4040, 5965, 21056, 340, 781, 1172, 376, 12893, 267, 340, 283, 1418, 7, 315, 1056, 14, 2970, 26, 288, 1056, 14, 1000, 14, 27145, 14, 524, 8, 1069, 14, 2970, 459, 1418, 1105, 339, 340, 283, 1985, 7, 315, 1056, 14, 2970, 26, 267, 340, 1233, 365, 488, 26, 288, 1233, 275, 11485, 398, 340, 1233, 2356, 9601, 436, 1233, 665, 8290, 26, 288, 1177, 14, 2139, 14, 409, 480, 6592, 401, 1056, 14, 2970, 14, 2246, 360, 1985, 1333, 339, 2323, 275, 1052, 272, 367, 536, 12, 1338, 315, 1056, 14, 2139, 14, 4611, 837, 267, 340, 822, 8, 1459, 9, 508, 413, 26, 288, 2323, 59, 354, 61, 275, 1338, 59, 16, 61, 267, 587, 26, 288, 327, 41, 1172, 949, 16819, 12, 7710, 288, 2323, 59, 354, 61, 275, 1338, 339, 2323, 459, 362, 63, 585, 418, 275, 1056, 14, 2970, 14, 2246, 360, 362, 63, 585, 297, 4074, 339, 2396, 275, 2022, 14, 4180, 8, 2139, 9, 339, 340, 1233, 26, 267, 372, 334, 600, 12, 298, 3694, 1872, 1288, 990, 2396, 272, 587, 26, 267, 372, 2396, 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 ]
[ 2022, 199, 199, 318, 2446, 8, 1069, 12, 1177, 304, 272, 6330, 275, 1056, 14, 2970, 14, 2246, 480, 6493, 401, 1056, 14, 2139, 14, 362, 360, 6493, 1333, 339, 340, 298, 1074, 2, 315, 1056, 14, 2970, 26, 267, 1526, 275, 1056, 14, 2970, 14, 2246, 480, 1418, 531, 267, 574, 275, 1056, 14, 1000, 14, 27145, 14, 11066, 8, 1418, 9, 267, 340, 574, 365, 440, 488, 26, 288, 340, 1056, 14, 2970, 14, 2246, 480, 1074, 401, 488, 9, 508, 298, 3250, 582, 355, 1056, 14, 1000, 14, 27145, 14, 524, 8, 1418, 12, 574, 9, 288, 2396, 275, 298, 17, 2, 267, 587, 26, 288, 2396, 275, 298, 16, 2, 267, 372, 10003, 2714, 13, 804, 401, 298, 505, 15, 6104, 17857, 2396, 2378, 340, 6330, 1137, 283, 3592, 356, 267, 1177, 14, 2139, 14, 409, 480, 3946, 13, 3717, 13, 7852, 13, 12834, 401, 6330, 9, 272, 340, 283, 6493, 18, 7, 315, 1056, 14, 2970, 26, 267, 1177, 14, 2139, 14, 740, 480, 3946, 13, 3717, 13, 7852, 13, 12834, 401, 1056, 14, 2970, 14, 2246, 360, 6493, 18, 1333, 339, 327, 18441, 4040, 272, 340, 283, 2139, 7, 315, 1056, 14, 2970, 26, 267, 1177, 14, 2139, 14, 409, 480, 3946, 13, 3717, 13, 7852, 13, 9883, 401, 1056, 14, 2970, 14, 2246, 360, 2139, 1333, 272, 340, 283, 6942, 7, 315, 1056, 14, 2970, 26, 267, 1177, 14, 2139, 14, 409, 480, 3946, 13, 3717, 13, 7852, 13, 13428, 401, 1056, 14, 2970, 14, 2246, 360, 6942, 1333, 272, 340, 283, 2474, 7, 315, 1056, 14, 2970, 26, 267, 1177, 14, 2139, 14, 409, 480, 3946, 13, 3717, 13, 7852, 13, 10385, 401, 1056, 14, 2970, 14, 2246, 360, 2474, 1333, 339, 1233, 275, 1056, 14, 2970, 14, 2246, 360, 600, 297, 488, 9, 272, 340, 1056, 14, 765, 508, 283, 8808, 356, 267, 327, 11954, 314, 1177, 1233, 340, 781, 3984, 315, 282, 20491, 4040, 436, 652, 1159, 20864, 267, 340, 283, 13829, 4040, 7, 315, 1056, 14, 2970, 26, 288, 1233, 275, 1109, 8, 1069, 14, 2970, 14, 2246, 360, 13829, 4040, 1333, 398, 327, 2445, 626, 314, 20491, 4040, 5965, 21056, 340, 781, 1172, 376, 12893, 267, 340, 283, 1418, 7, 315, 1056, 14, 2970, 26, 288, 1056, 14, 1000, 14, 27145, 14, 524, 8, 1069, 14, 2970, 459, 1418, 1105, 339, 340, 283, 1985, 7, 315, 1056, 14, 2970, 26, 267, 340, 1233, 365, 488, 26, 288, 1233, 275, 11485, 398, 340, 1233, 2356, 9601, 436, 1233, 665, 8290, 26, 288, 1177, 14, 2139, 14, 409, 480, 6592, 401, 1056, 14, 2970, 14, 2246, 360, 1985, 1333, 339, 2323, 275, 1052, 272, 367, 536, 12, 1338, 315, 1056, 14, 2139, 14, 4611, 837, 267, 340, 822, 8, 1459, 9, 508, 413, 26, 288, 2323, 59, 354, 61, 275, 1338, 59, 16, 61, 267, 587, 26, 288, 327, 41, 1172, 949, 16819, 12, 7710, 288, 2323, 59, 354, 61, 275, 1338, 339, 2323, 459, 362, 63, 585, 418, 275, 1056, 14, 2970, 14, 2246, 360, 362, 63, 585, 297, 4074, 339, 2396, 275, 2022, 14, 4180, 8, 2139, 9, 339, 340, 1233, 26, 267, 372, 334, 600, 12, 298, 3694, 1872, 1288, 990, 2396, 272, 587, 26, 267, 372, 2396, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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route53_zone.py
25
7289
#!/usr/bin/python # 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/>. ANSIBLE_METADATA = {'status': ['stableinterface'], 'supported_by': 'community', 'version': '1.0'} DOCUMENTATION = ''' module: route53_zone short_description: add or delete Route53 zones description: - Creates and deletes Route53 private and public zones version_added: "2.0" options: zone: description: - "The DNS zone record (eg: foo.com.)" required: true state: description: - whether or not the zone should exist or not required: false default: true choices: [ "present", "absent" ] vpc_id: description: - The VPC ID the zone should be a part of (if this is going to be a private zone) required: false default: null vpc_region: description: - The VPC Region the zone should be a part of (if this is going to be a private zone) required: false default: null comment: description: - Comment associated with the zone required: false default: '' extends_documentation_fragment: - aws - ec2 author: "Christopher Troup (@minichate)" ''' EXAMPLES = ''' # create a public zone - route53_zone: zone: example.com state: present comment: this is an example # delete a public zone - route53_zone: zone: example.com state: absent - name: private zone for devel route53_zone: zone: devel.example.com state: present vpc_id: '{{ myvpc_id }}' comment: developer domain # more complex example - name: register output after creating zone in parameterized region route53_zone: vpc_id: '{{ vpc.vpc_id }}' vpc_region: '{{ ec2_region }}' zone: '{{ vpc_dns_zone }}' state: present register: zone_out - debug: var: zone_out ''' RETURN=''' comment: description: optional hosted zone comment returned: when hosted zone exists type: string sample: "Private zone" name: description: hosted zone name returned: when hosted zone exists type: string sample: "private.local." private_zone: description: whether hosted zone is private or public returned: when hosted zone exists type: bool sample: true vpc_id: description: id of vpc attached to private hosted zone returned: for private hosted zone type: string sample: "vpc-1d36c84f" vpc_region: description: region of vpc attached to private hosted zone returned: for private hosted zone type: string sample: "eu-west-1" zone_id: description: hosted zone id returned: when hosted zone exists type: string sample: "Z6JQG9820BEFMW" ''' try: import boto import boto.ec2 from boto import route53 from boto.route53 import Route53Connection from boto.route53.zone import Zone HAS_BOTO = True except ImportError: HAS_BOTO = False from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.ec2 import ec2_argument_spec, get_aws_connection_info def main(): argument_spec = ec2_argument_spec() argument_spec.update(dict( zone=dict(required=True), state=dict(default='present', choices=['present', 'absent']), vpc_id=dict(default=None), vpc_region=dict(default=None), comment=dict(default=''))) module = AnsibleModule(argument_spec=argument_spec) if not HAS_BOTO: module.fail_json(msg='boto required for this module') zone_in = module.params.get('zone').lower() state = module.params.get('state').lower() vpc_id = module.params.get('vpc_id') vpc_region = module.params.get('vpc_region') comment = module.params.get('comment') if zone_in[-1:] != '.': zone_in += "." private_zone = vpc_id is not None and vpc_region is not None _, _, aws_connect_kwargs = get_aws_connection_info(module) # connect to the route53 endpoint try: conn = Route53Connection(**aws_connect_kwargs) except boto.exception.BotoServerError as e: module.fail_json(msg=e.error_message) results = conn.get_all_hosted_zones() zones = {} for r53zone in results['ListHostedZonesResponse']['HostedZones']: zone_id = r53zone['Id'].replace('/hostedzone/', '') zone_details = conn.get_hosted_zone(zone_id)['GetHostedZoneResponse'] if vpc_id and 'VPCs' in zone_details: # this is to deal with this boto bug: https://github.com/boto/boto/pull/2882 if isinstance(zone_details['VPCs'], dict): if zone_details['VPCs']['VPC']['VPCId'] == vpc_id: zones[r53zone['Name']] = zone_id else: # Forward compatibility for when boto fixes that bug if vpc_id in [v['VPCId'] for v in zone_details['VPCs']]: zones[r53zone['Name']] = zone_id else: zones[r53zone['Name']] = zone_id record = { 'private_zone': private_zone, 'vpc_id': vpc_id, 'vpc_region': vpc_region, 'comment': comment, } if state == 'present' and zone_in in zones: if private_zone: details = conn.get_hosted_zone(zones[zone_in]) if 'VPCs' not in details['GetHostedZoneResponse']: module.fail_json( msg="Can't change VPC from public to private" ) vpc_details = details['GetHostedZoneResponse']['VPCs']['VPC'] current_vpc_id = vpc_details['VPCId'] current_vpc_region = vpc_details['VPCRegion'] if current_vpc_id != vpc_id: module.fail_json( msg="Can't change VPC ID once a zone has been created" ) if current_vpc_region != vpc_region: module.fail_json( msg="Can't change VPC Region once a zone has been created" ) record['zone_id'] = zones[zone_in] record['name'] = zone_in module.exit_json(changed=False, set=record) elif state == 'present': result = conn.create_hosted_zone(zone_in, **record) hosted_zone = result['CreateHostedZoneResponse']['HostedZone'] zone_id = hosted_zone['Id'].replace('/hostedzone/', '') record['zone_id'] = zone_id record['name'] = zone_in module.exit_json(changed=True, set=record) elif state == 'absent' and zone_in in zones: conn.delete_hosted_zone(zones[zone_in]) module.exit_json(changed=True) elif state == 'absent': module.exit_json(changed=False) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 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, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 578, 26, 7475, 2481, 63, 2619, 199, 3612, 63, 1802, 26, 1050, 503, 3145, 24244, 2481, 18666, 199, 1802, 26, 272, 446, 10560, 436, 21812, 24244, 2481, 5726, 436, 4575, 18666, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1419, 26, 272, 5718, 26, 267, 1369, 26, 288, 446, 298, 1918, 10237, 5718, 2777, 334, 5902, 26, 3925, 14, 957, 14, 2924, 267, 1415, 26, 2549, 272, 1174, 26, 267, 1369, 26, 288, 446, 3775, 503, 440, 314, 5718, 1077, 2187, 503, 440, 267, 1415, 26, 3055, 267, 849, 26, 2549, 267, 3415, 26, 359, 298, 1881, 401, 298, 5575, 2, 1622, 272, 12830, 63, 344, 26, 267, 1369, 26, 288, 446, 710, 19209, 2870, 314, 5718, 1077, 506, 282, 1777, 402, 334, 692, 642, 365, 9995, 370, 506, 282, 5726, 5718, 9, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 12830, 63, 4551, 26, 267, 1369, 26, 288, 446, 710, 19209, 22240, 314, 5718, 1077, 506, 282, 1777, 402, 334, 692, 642, 365, 9995, 370, 506, 282, 5726, 5718, 9, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 3721, 26, 267, 1369, 26, 288, 446, 6819, 4568, 543, 314, 5718, 267, 1415, 26, 3055, 267, 849, 26, 2125, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 11488, 272, 446, 7062, 18, 199, 2502, 26, 298, 1049, 322, 2379, 2523, 377, 684, 8593, 827, 1158, 323, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 1218, 282, 4575, 5718, 199, 13, 7475, 2481, 63, 2619, 26, 272, 5718, 26, 2893, 14, 957, 272, 1174, 26, 3451, 272, 3721, 26, 642, 365, 376, 2893, 199, 199, 3, 3145, 282, 4575, 5718, 199, 13, 7475, 2481, 63, 2619, 26, 272, 5718, 26, 2893, 14, 957, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 5726, 5718, 367, 477, 1090, 523, 7475, 2481, 63, 2619, 26, 272, 5718, 26, 477, 1090, 14, 2694, 14, 957, 272, 1174, 26, 3451, 272, 12830, 63, 344, 26, 11400, 3002, 11742, 63, 344, 16339, 272, 3721, 26, 15030, 2881, 199, 199, 3, 1655, 6114, 2893, 199, 13, 536, 26, 2274, 1072, 2410, 6425, 5718, 315, 29526, 4897, 523, 7475, 2481, 63, 2619, 26, 272, 12830, 63, 344, 26, 11400, 12830, 14, 11742, 63, 344, 16339, 272, 12830, 63, 4551, 26, 11400, 7062, 18, 63, 4551, 16339, 272, 5718, 26, 11400, 12830, 63, 5797, 63, 2619, 16339, 272, 1174, 26, 3451, 523, 2274, 26, 5718, 63, 548, 199, 199, 13, 3105, 26, 272, 2729, 26, 5718, 63, 548, 199, 2344, 199, 199, 9677, 19938, 199, 3349, 26, 272, 1369, 26, 2716, 28311, 5718, 3721, 272, 2138, 26, 1380, 28311, 5718, 3495, 272, 730, 26, 1059, 272, 2690, 26, 298, 12185, 5718, 2, 199, 354, 26, 272, 1369, 26, 28311, 5718, 536, 272, 2138, 26, 1380, 28311, 5718, 3495, 272, 730, 26, 1059, 272, 2690, 26, 298, 4239, 14, 1832, 2122, 199, 4239, 63, 2619, 26, 272, 1369, 26, 3775, 28311, 5718, 365, 5726, 503, 4575, 272, 2138, 26, 1380, 28311, 5718, 3495, 272, 730, 26, 2155, 272, 2690, 26, 2549, 199, 11742, 63, 344, 26, 272, 1369, 26, 1305, 402, 12830, 10102, 370, 5726, 28311, 5718, 272, 2138, 26, 367, 5726, 28311, 5718, 272, 730, 26, 1059, 272, 2690, 26, 298, 11742, 13, 17, 68, 1344, 67, 1349, 70, 2, 199, 11742, 63, 4551, 26, 272, 1369, 26, 4897, 402, 12830, 10102, 370, 5726, 28311, 5718, 272, 2138, 26, 367, 5726, 28311, 5718, 272, 730, 26, 1059, 272, 2690, 26, 298, 16913, 13, 19082, 13, 17, 2, 199, 2619, 63, 344, 26, 272, 1369, 26, 28311, 5718, 1305, 272, 2138, 26, 1380, 28311, 5718, 3495, 272, 730, 26, 1059, 272, 2690, 26, 298, 58, 22, 42, 49, 39, 2905, 1165, 6773, 22367, 55, 2, 199, 2344, 199, 199, 893, 26, 272, 492, 6055, 272, 492, 6055, 14, 825, 18, 272, 687, 6055, 492, 7475, 2481, 272, 687, 6055, 14, 4449, 2481, 492, 24244, 2481, 3225, 272, 687, 6055, 14, 4449, 2481, 14, 2619, 492, 22518, 272, 7509, 63, 21373, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 21373, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 7062, 18, 63, 2094, 63, 1650, 12, 664, 63, 7231, 63, 2105, 63, 815, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 7062, 18, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 807, 8, 267, 5718, 29, 807, 8, 2427, 29, 549, 395, 267, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 3815, 267, 12830, 63, 344, 29, 807, 8, 885, 29, 403, 395, 267, 12830, 63, 4551, 29, 807, 8, 885, 29, 403, 395, 267, 3721, 29, 807, 8, 885, 534, 7058, 272, 859, 275, 6953, 8, 2094, 63, 1650, 29, 2094, 63, 1650, 9, 339, 340, 440, 7509, 63, 21373, 26, 267, 859, 14, 1633, 63, 1001, 8 ]
[ 2647, 15, 1393, 15, 1548, 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, 199, 8490, 63, 8314, 275, 791, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 297, 490, 283, 1023, 356, 283, 17, 14, 16, 936, 199, 199, 8948, 275, 1449, 199, 578, 26, 7475, 2481, 63, 2619, 199, 3612, 63, 1802, 26, 1050, 503, 3145, 24244, 2481, 18666, 199, 1802, 26, 272, 446, 10560, 436, 21812, 24244, 2481, 5726, 436, 4575, 18666, 199, 1023, 63, 3270, 26, 298, 18, 14, 16, 2, 199, 1419, 26, 272, 5718, 26, 267, 1369, 26, 288, 446, 298, 1918, 10237, 5718, 2777, 334, 5902, 26, 3925, 14, 957, 14, 2924, 267, 1415, 26, 2549, 272, 1174, 26, 267, 1369, 26, 288, 446, 3775, 503, 440, 314, 5718, 1077, 2187, 503, 440, 267, 1415, 26, 3055, 267, 849, 26, 2549, 267, 3415, 26, 359, 298, 1881, 401, 298, 5575, 2, 1622, 272, 12830, 63, 344, 26, 267, 1369, 26, 288, 446, 710, 19209, 2870, 314, 5718, 1077, 506, 282, 1777, 402, 334, 692, 642, 365, 9995, 370, 506, 282, 5726, 5718, 9, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 12830, 63, 4551, 26, 267, 1369, 26, 288, 446, 710, 19209, 22240, 314, 5718, 1077, 506, 282, 1777, 402, 334, 692, 642, 365, 9995, 370, 506, 282, 5726, 5718, 9, 267, 1415, 26, 3055, 267, 849, 26, 2973, 272, 3721, 26, 267, 1369, 26, 288, 446, 6819, 4568, 543, 314, 5718, 267, 1415, 26, 3055, 267, 849, 26, 2125, 199, 11036, 63, 9970, 63, 7677, 26, 272, 446, 11488, 272, 446, 7062, 18, 199, 2502, 26, 298, 1049, 322, 2379, 2523, 377, 684, 8593, 827, 1158, 323, 2924, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 1218, 282, 4575, 5718, 199, 13, 7475, 2481, 63, 2619, 26, 272, 5718, 26, 2893, 14, 957, 272, 1174, 26, 3451, 272, 3721, 26, 642, 365, 376, 2893, 199, 199, 3, 3145, 282, 4575, 5718, 199, 13, 7475, 2481, 63, 2619, 26, 272, 5718, 26, 2893, 14, 957, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 5726, 5718, 367, 477, 1090, 523, 7475, 2481, 63, 2619, 26, 272, 5718, 26, 477, 1090, 14, 2694, 14, 957, 272, 1174, 26, 3451, 272, 12830, 63, 344, 26, 11400, 3002, 11742, 63, 344, 16339, 272, 3721, 26, 15030, 2881, 199, 199, 3, 1655, 6114, 2893, 199, 13, 536, 26, 2274, 1072, 2410, 6425, 5718, 315, 29526, 4897, 523, 7475, 2481, 63, 2619, 26, 272, 12830, 63, 344, 26, 11400, 12830, 14, 11742, 63, 344, 16339, 272, 12830, 63, 4551, 26, 11400, 7062, 18, 63, 4551, 16339, 272, 5718, 26, 11400, 12830, 63, 5797, 63, 2619, 16339, 272, 1174, 26, 3451, 523, 2274, 26, 5718, 63, 548, 199, 199, 13, 3105, 26, 272, 2729, 26, 5718, 63, 548, 199, 2344, 199, 199, 9677, 19938, 199, 3349, 26, 272, 1369, 26, 2716, 28311, 5718, 3721, 272, 2138, 26, 1380, 28311, 5718, 3495, 272, 730, 26, 1059, 272, 2690, 26, 298, 12185, 5718, 2, 199, 354, 26, 272, 1369, 26, 28311, 5718, 536, 272, 2138, 26, 1380, 28311, 5718, 3495, 272, 730, 26, 1059, 272, 2690, 26, 298, 4239, 14, 1832, 2122, 199, 4239, 63, 2619, 26, 272, 1369, 26, 3775, 28311, 5718, 365, 5726, 503, 4575, 272, 2138, 26, 1380, 28311, 5718, 3495, 272, 730, 26, 2155, 272, 2690, 26, 2549, 199, 11742, 63, 344, 26, 272, 1369, 26, 1305, 402, 12830, 10102, 370, 5726, 28311, 5718, 272, 2138, 26, 367, 5726, 28311, 5718, 272, 730, 26, 1059, 272, 2690, 26, 298, 11742, 13, 17, 68, 1344, 67, 1349, 70, 2, 199, 11742, 63, 4551, 26, 272, 1369, 26, 4897, 402, 12830, 10102, 370, 5726, 28311, 5718, 272, 2138, 26, 367, 5726, 28311, 5718, 272, 730, 26, 1059, 272, 2690, 26, 298, 16913, 13, 19082, 13, 17, 2, 199, 2619, 63, 344, 26, 272, 1369, 26, 28311, 5718, 1305, 272, 2138, 26, 1380, 28311, 5718, 3495, 272, 730, 26, 1059, 272, 2690, 26, 298, 58, 22, 42, 49, 39, 2905, 1165, 6773, 22367, 55, 2, 199, 2344, 199, 199, 893, 26, 272, 492, 6055, 272, 492, 6055, 14, 825, 18, 272, 687, 6055, 492, 7475, 2481, 272, 687, 6055, 14, 4449, 2481, 492, 24244, 2481, 3225, 272, 687, 6055, 14, 4449, 2481, 14, 2619, 492, 22518, 272, 7509, 63, 21373, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 21373, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 825, 18, 492, 7062, 18, 63, 2094, 63, 1650, 12, 664, 63, 7231, 63, 2105, 63, 815, 421, 199, 318, 2446, 837, 272, 1423, 63, 1650, 275, 7062, 18, 63, 2094, 63, 1650, 342, 272, 1423, 63, 1650, 14, 873, 8, 807, 8, 267, 5718, 29, 807, 8, 2427, 29, 549, 395, 267, 1174, 29, 807, 8, 885, 534, 1881, 297, 3415, 2968, 1881, 297, 283, 5575, 3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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 ]
CarlosCondor/pelisalacarta-xbmc-plus
pelisalacarta/channels/peliculasmx.py
3
17288
# -*- coding: utf-8 -*- #------------------------------------------------------------ # pelisalacarta - XBMC Plugin # Canal para peliculasmx # http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/ #------------------------------------------------------------ import urlparse,urllib2,urllib,re import os, sys from core import logger from core import config from core import scrapertools from core.item import Item from servers import servertools __channel__ = "peliculasmx" __category__ = "F" __type__ = "generic" __title__ = "peliculasmx" __language__ = "ES" __creationdate__ = "20130528" DEBUG = config.get_setting("debug") def isGeneric(): return True def mainlist(item): logger.info("[peliculasmx.py] mainlist") itemlist = [] itemlist.append( Item(channel=__channel__, title="Ultimas Agregadas", action="listado2" , url="http://www.peliculasmx.net/" , extra="http://www.peliculasmx.net/")) itemlist.append( Item(channel=__channel__, title="Por Genero" , action="generos" , url="http://www.peliculasmx.net/")) itemlist.append( Item(channel=__channel__, title="Por Orden Alfabetico" , action="alfabetico" , url="http://www.peliculasmx.net/")) itemlist.append( Item(channel=__channel__, title="Buscar" , action="search" , url="http://www.peliculasmx.net/")) return itemlist def listarpeliculas(item): logger.info("[peliculasmx.py] listarpeliculas") # Descarga la página data = scrapertools.cachePage(item.url) extra = item.extra # Extrae las entradas de la pagina seleccionada '''<td class="DarkText" align="center" valign="top" width="100px" height="160px" style="background-color:#1e1e1e;" onmouseover="this.style.backgroundColor='#000000'" onmouseout="this.style.backgroundColor='#1e1e1e'"><p style="margin-bottom: 3px;border-bottom:#ABABAB 1px solid"> <a href="http://www.peliculasaudiolatino.com/movies/Larry_Crowne.html"><img src="http://www.peliculasaudiolatino.com/poster/85x115/peliculas/movieimg/movie1317696842.jpg" alt="Larry Crowne" border="0" height="115" width="85"></a>''' patron = '<td class=.*?<a ' patron += 'href="([^"]+)"><img src="([^"]+)" alt="([^"]+)"' matches = re.compile(patron,re.DOTALL).findall(data) if DEBUG: scrapertools.printMatches(matches) itemlist = [] for match in matches: scrapedurl = match[0] scrapedtitle = match[2] scrapedthumbnail = match[1] scrapedplot = "" logger.info(scrapedtitle) # Añade al listado itemlist.append( Item(channel=__channel__, action="findvideos", title=scrapedtitle , fulltitle=scrapedtitle, url=scrapedurl , thumbnail=scrapedthumbnail , plot=scrapedplot , extra=extra , folder=True) ) # Extrae la marca de siguiente página patron = 'Anterior.*? :: <a href="/../../.*?/page/([^"]+)">Siguiente ' matches = re.compile(patron,re.DOTALL).findall(data) if DEBUG: scrapertools.printMatches(matches) for match in matches: if len(matches)>0: scrapedurl = extra+match scrapedtitle = "!Pagina Siguiente" scrapedthumbnail = "" scrapedplot = "" itemlist.append( Item(channel=__channel__, action="listarpeliculas", title=scrapedtitle , fulltitle=scrapedtitle , url=scrapedurl , thumbnail=scrapedthumbnail , plot=scrapedplot , extra=extra , folder=True) ) return itemlist def findvideos(item): logger.info("[peliculasmx.py] videos") # Descarga la página data = scrapertools.cachePage(item.url) title = item.title scrapedthumbnail = item.thumbnail itemlist = [] patron = '<li><a href="#ms.*?">([^"]+)</a></li>.*?<iframe src="(.*?)"' matches = re.compile(patron,re.DOTALL).findall(data) #itemlist.append( Item(channel=__channel__, action="play", title=title , fulltitle=item.fulltitle, url=item.url , thumbnail=scrapedthumbnail , folder=False) ) if (DEBUG): scrapertools.printMatches(matches) for match in matches: url = match[1] title = "SERVIDOR: " + match[0] itemlist.append( Item(channel=__channel__, action="play", title=title , fulltitle=item.fulltitle, url=url , thumbnail=scrapedthumbnail , folder=False) ) return itemlist def play(item): logger.info("[peliculasmx.py] play") itemlist=[] from servers import servertools itemlist = servertools.find_video_items(data=item.url) for videoitem in itemlist: videoitem.channel=__channel__ videoitem.action="play" videoitem.folder=False return itemlist #data2 = scrapertools.cache_page(item.url) #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/mv.php?url=","http://www.megavideo.com/?v=") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/videobb.php?url=","http://www.videobb.com/watch_video.php?v=") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/vidbux.php?url=","http://www.vidbux.com/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/vidxden.php?url=","http://www.vidxden.com/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/videozer.php?url=","http://www.videozer.com/video/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/v/pl/play.php?url=","http://www.putlocker.com/embed/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/v/mv/play.php?url=","http://www.modovideo.com/frame.php?v=") #data2 = data2.replace("http://www.peliculasaudiolatino.com/v/ss/play.php?url=","http://www.sockshare.com/embed/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/v/vb/play.php?url=","http://vidbull.com/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/sockshare.php?url=","http://www.sockshare.com/embed/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/moevide.php?url=","http://moevideo.net/?page=video&uid=") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/novamov.php?url=","http://www.novamov.com/video/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/movshare.php?url=","http://www.movshare.net/video/") #data2 = data2.replace("http://www.peliculasaudiolatino.com/show/divxstage.php?url=","http://www.divxstage.net/video/") #listavideos = servertools.findvideos(data2) #for video in listavideos: # invalid = video[1] # invalid = invalid[0:8] # if invalid!= "FN3WE43K" and invalid!="9CC3F8&e": # scrapedtitle = item.title+video[0] # videourl = item.url # server = video[2] # if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+videourl+"]") #logger.info("url=" + item.url) # Añade al listado de XBMC #itemlist.append( Item(channel=__channel__, action="play", title=scrapedtitle , fulltitle=item.fulltitle, url=videourl , server=server , folder=False) ) # itemlist.append( Item(channel=__channel__, action="play" , title=item.title , url=item.url, thumbnail="", plot="", server=item.url)) # return itemlist def generos(item): logger.info("[peliculasmx.py] generos") itemlist = [] # Descarga la página data = scrapertools.cachePage(item.url) patron = '>.*?<li><a title="(.*?)" href="(.*?)"' matches = re.compile(patron,re.DOTALL).findall(data) if (DEBUG): scrapertools.printMatches(matches) for match in matches: scrapedurl = urlparse.urljoin("",match[1]) scrapedurl = scrapedurl.replace(".html","/page/0.html") extra = scrapedurl.replace ("/page/0.html","/page/") scrapedtitle = match[0] #scrapedtitle = scrapedtitle.replace("","") scrapedthumbnail = "" scrapedplot = "" logger.info(scrapedtitle) if scrapedtitle=="Eroticas +18": if config.get_setting("enableadultmode") == "true": itemlist.append( Item(channel=__channel__, action="listado2", title="Eroticas +18" , url="http://www.myhotamateurvideos.com" , thumbnail=scrapedthumbnail , plot=scrapedplot , extra="" , folder=True) ) else: if scrapedtitle <> "" and len(scrapedtitle) < 20 and scrapedtitle <> "Iniciar Sesion": itemlist.append( Item(channel=__channel__, action="listado2", title=scrapedtitle , url=scrapedurl , thumbnail=scrapedthumbnail , plot=scrapedplot , extra=extra, folder=True) ) itemlist = sorted(itemlist, key=lambda Item: Item.title) return itemlist def alfabetico(item): logger.info("[cinewow.py] listalfabetico") extra = item.url itemlist = [] itemlist.append( Item(channel=__channel__, action="listado2" , title="0-9", url="http://www.peliculasmx.net/letra/09.html", extra="http://www.peliculasmx.net/letra/09.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="A" , url="http://www.peliculasmx.net/letra/a.html", extra="http://www.peliculasmx.net/letra/a.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="B" , url="http://www.peliculasmx.net/letra/b.html", extra="http://www.peliculasmx.net/letra/b.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="C" , url="http://www.peliculasmx.net/letra/c.html", extra="http://www.peliculasmx.net/letra/c.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="D" , url="http://www.peliculasmx.net/letra/d.html", extra="http://www.peliculasmx.net/letra/d.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="E" , url="http://www.peliculasmx.net/letra/e.html", extra="http://www.peliculasmx.net/letra/e.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="F" , url="http://www.peliculasmx.net/letra/f.html", extra="http://www.peliculasmx.net/letra/f.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="G" , url="http://www.peliculasmx.net/letra/g.html", extra="http://www.peliculasmx.net/letra/g.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="H" , url="http://www.peliculasmx.net/letra/h.html", extra="http://www.peliculasmx.net/letra/h.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="I" , url="http://www.peliculasmx.net/letra/i.html", extra="http://www.peliculasmx.net/letra/i.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="J" , url="http://www.peliculasmx.net/letra/j.html", extra="http://www.peliculasmx.net/letra/j.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="K" , url="http://www.peliculasmx.net/letra/k.html", extra="http://www.peliculasmx.net/letra/k.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="L" , url="http://www.peliculasmx.net/letra/l.html", extra="http://www.peliculasmx.net/letra/l.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="M" , url="http://www.peliculasmx.net/letra/m.html", extra="http://www.peliculasmx.net/letra/m.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="N" , url="http://www.peliculasmx.net/letra/n.html", extra="http://www.peliculasmx.net/letra/n.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="O" , url="http://www.peliculasmx.net/letra/o.html", extra="http://www.peliculasmx.net/letra/o.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="P" , url="http://www.peliculasmx.net/letra/p.html", extra="http://www.peliculasmx.net/letra/p.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="Q" , url="http://www.peliculasmx.net/letra/q.html", extra="http://www.peliculasmx.net/letra/q.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="R" , url="http://www.peliculasmx.net/letra/r.html", extra="http://www.peliculasmx.net/letra/r.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="S" , url="http://www.peliculasmx.net/letra/s.html", extra="http://www.peliculasmx.net/letra/s.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="T" , url="http://www.peliculasmx.net/letra/t.html", extra="http://www.peliculasmx.net/letra/t.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="U" , url="http://www.peliculasmx.net/letra/u.html", extra="http://www.peliculasmx.net/letra/u.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="V" , url="http://www.peliculasmx.net/letra/v.html", extra="http://www.peliculasmx.net/letra/v.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="W" , url="http://www.peliculasmx.net/letra/w.html", extra="http://www.peliculasmx.net/letra/w.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="X" , url="http://www.peliculasmx.net/letra/x.html", extra="http://www.peliculasmx.net/letra/x.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="Y" , url="http://www.peliculasmx.net/letra/y.html", extra="http://www.peliculasmx.net/letra/y.html")) itemlist.append( Item(channel=__channel__, action="listado2" , title="Z" , url="http://www.peliculasmx.net/letra/z.html", extra="http://www.peliculasmx.net/letra/z.html")) return itemlist def listado2(item): logger.info("[peliculasmx.py] listado2") extra = item.extra itemlist = [] # Descarga la página data = scrapertools.cachePage(item.url) patron = '<h2 class="titpeli.*?<a href="([^"]+)" title="([^"]+)".*?peli_img_img">.*?<img src="([^"]+)".*?<strong>Idioma</strong>:.*?/>([^"]+)</div>.*?<strong>Calidad</strong>: ([^"]+)</div>' matches = re.compile(patron,re.DOTALL).findall(data) if (DEBUG): scrapertools.printMatches(matches) for match in matches: scrapedurl = match[0] #urlparse.urljoin("",match[0]) scrapedtitle = match[1] + ' - ' + match[4] scrapedthumbnail = match[2] #scrapedplot = match[0] #itemlist.append( Item(channel=__channel__, action="findvideos", title=scrapedtitle , fulltitle=scrapedtitle, url=scrapedurl , thumbnail=scrapedthumbnail , plot=scrapedplot , folder=True) ) itemlist.append( Item(channel=__channel__, action="findvideos", title=scrapedtitle, fulltitle=scrapedtitle, url=scrapedurl , thumbnail=scrapedthumbnail , folder=True) ) #if extra<>"": # Extrae la marca de siguiente página #patron = 'page=(.*?)"><span><b>' patron = '<span><b>(.*?)</b></span>' matches = re.compile(patron,re.DOTALL).findall(data) #if DEBUG: scrapertools.printMatches(matches) for match in matches: #if len(matches)>0: nu = int(match[0]) + 1 scrapedurl = extra + "?page=" + str(nu) scrapedtitle = "!Pagina Siguiente ->" scrapedthumbnail = "" scrapedplot = "" itemlist.append( Item(channel=__channel__, action="listado2", title=scrapedtitle , fulltitle=scrapedtitle, url=scrapedurl , thumbnail=scrapedthumbnail , extra=extra , folder=True) ) return itemlist def search(item,texto): logger.info("[peliculasmx.py] search") itemlist = [] texto = texto.replace(" ","+") try: # Series item.url="http://www.peliculasmx.net/buscar/?q=%s" item.url = item.url % texto item.extra = "" itemlist.extend(listado2(item)) itemlist = sorted(itemlist, key=lambda Item: Item.title) return itemlist # Se captura la excepción, para no interrumpir al buscador global si un canal falla except: import sys for line in sys.exc_info(): logger.error( "%s" % line ) return [] '''url = "http://www.peliculasaudiolatino.com/series-anime" data = scrapertools.cachePage(url) # Extrae las entradas de todas series patronvideos = '<li>[^<]+' patronvideos += '<a.+?href="([\D]+)([\d]+)">[^<]+' patronvideos += '.*?/>(.*?)</a>' matches = re.compile(patronvideos,re.DOTALL).findall(data) for match in matches: scrapedtitle = match[2].strip() # Realiza la busqueda if scrapedtitle.lower()==texto.lower() or texto.lower() in scrapedtitle.lower(): logger.info(scrapedtitle) scrapedurl = urlparse.urljoin(url,(match[0]+match[1])) scrapedthumbnail = urlparse.urljoin("http://www.peliculasaudiolatino.com/images/series/",(match[1]+".png")) scrapedplot = "" # Añade al listado itemlist.append( Item(channel=__channel__, action="listacapitulos", title=scrapedtitle , url=scrapedurl , thumbnail=scrapedthumbnail , plot=scrapedplot , folder=True) ) return itemlist''' # Verificación automática de canales: Esta función debe devolver "True" si está ok el canal. def test(): from servers import servertools mainlist_items = mainlist(Item()) novedades_items = listado2(mainlist_items[0]) for novedades_item in novedades_items: mirrors = findvideos( item=novedades_item ) if len(mirrors)>0: return True return False
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 17807, 4559, 199, 3, 4837, 317, 6327, 645, 29549, 446, 1323, 28994, 11349, 199, 3, 6855, 279, 12665, 4837, 606, 32646, 9457, 199, 3, 1455, 921, 11486, 14, 84, 637, 645, 29549, 14, 815, 15, 2718, 13, 21382, 15, 321, 317, 6327, 645, 29549, 15, 199, 17807, 4559, 199, 199, 646, 7097, 12, 4078, 18, 12, 4078, 12, 264, 199, 646, 747, 12, 984, 199, 199, 504, 6170, 492, 2512, 199, 504, 6170, 492, 1101, 199, 504, 6170, 492, 28348, 199, 504, 6170, 14, 1053, 492, 7020, 199, 504, 8037, 492, 1654, 2537, 199, 199, 363, 2775, 363, 275, 298, 321, 606, 32646, 9457, 2, 199, 363, 3710, 363, 275, 298, 38, 2, 199, 363, 466, 363, 275, 298, 6767, 2, 199, 363, 1213, 363, 275, 298, 321, 606, 32646, 9457, 2, 199, 363, 3671, 363, 275, 298, 654, 2, 199, 363, 8782, 602, 363, 275, 298, 1797, 11565, 1651, 2, 199, 199, 5287, 275, 1101, 14, 362, 63, 6031, 480, 1757, 531, 1362, 199, 318, 365, 9417, 837, 272, 372, 715, 199, 199, 318, 2446, 513, 8, 1053, 304, 272, 2512, 14, 815, 10994, 321, 606, 32646, 9457, 14, 647, 61, 2446, 513, 531, 339, 22921, 275, 942, 272, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 2538, 628, 18505, 2906, 305, 437, 3939, 350, 305, 401, 1595, 628, 513, 5129, 18, 2, 2360, 1166, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 6687, 2360, 2402, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 15, 2237, 272, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 2538, 628, 48, 269, 1464, 79, 2, 2360, 1595, 628, 2038, 736, 2, 2360, 1166, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 15, 2237, 272, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 2538, 628, 48, 269, 4236, 848, 437, 276, 7570, 280, 331, 2, 2360, 1595, 628, 7411, 7570, 280, 331, 2, 2360, 1166, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 15, 2237, 272, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 2538, 628, 12106, 7007, 2, 2360, 1595, 628, 1733, 2, 2360, 1166, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 15, 2237, 272, 372, 22921, 199, 199, 318, 769, 285, 321, 606, 32646, 8, 1053, 304, 272, 2512, 14, 815, 10994, 321, 606, 32646, 9457, 14, 647, 61, 769, 285, 321, 606, 32646, 531, 339, 327, 8055, 67, 1273, 65, 1127, 299, 11302, 903, 65, 272, 666, 275, 28348, 14, 1637, 3276, 8, 1053, 14, 633, 9, 272, 2402, 275, 1242, 14, 2911, 339, 327, 11177, 69, 23325, 15992, 9525, 305, 477, 1127, 9881, 13765, 542, 10251, 9718, 10641, 272, 28827, 2076, 1021, 628, 36, 1096, 1872, 2, 6998, 628, 4218, 2, 27554, 628, 2119, 2, 3462, 628, 1960, 5326, 2, 4569, 628, 8488, 5326, 2, 3449, 628, 7451, 13, 2326, 15596, 17, 69, 17, 69, 17, 69, 9426, 641, 10544, 1883, 628, 3749, 14, 2487, 14, 7451, 4117, 26431, 3273, 4065, 641, 10544, 548, 628, 3749, 14, 2487, 14, 7451, 4117, 26431, 17, 69, 17, 69, 17, 69, 7, 8186, 80, 3449, 628, 9650, 13, 8305, 26, 650, 5326, 27, 8665, 13, 8305, 15596, 1217, 1217, 1217, 413, 5326, 18609, 1743, 221, 2151, 198, 28, 65, 4369, 628, 1014, 921, 1544, 14, 321, 606, 32646, 23577, 393, 292, 10175, 14, 957, 15, 20888, 15, 44, 285, 651, 63, 35, 1143, 685, 14, 1360, 8186, 4060, 2928, 628, 1014, 921, 1544, 14, 321, 606, 32646, 23577, 393, 292, 10175, 14, 957, 15, 20801, 15, 2426, 88, 7680, 15, 321, 606, 32646, 15, 10888, 4060, 15, 10888, 969, 1196, 15154, 18931, 14, 8476, 2, 8791, 628, 44, 285, 651, 445, 1143, 685, 2, 9162, 628, 16, 2, 4569, 628, 7680, 2, 3462, 628, 2426, 10070, 65, 26934, 272, 32500, 275, 2650, 2076, 1021, 29, 6697, 28, 65, 283, 272, 32500, 847, 283, 6399, 24296, 8771, 8186, 4060, 2928, 32391, 8791, 32391, 7, 272, 4450, 275, 295, 14, 2014, 8, 10853, 2641, 12, 264, 14, 16504, 680, 6452, 8, 576, 9, 272, 340, 10990, 26, 28348, 14, 1361, 12962, 8, 6742, 9, 272, 22921, 275, 942, 272, 367, 1336, 315, 4450, 26, 267, 24514, 633, 275, 1336, 59, 16, 61, 267, 24514, 1213, 275, 1336, 59, 18, 61, 267, 24514, 8311, 275, 1336, 59, 17, 61, 267, 24514, 2798, 275, 3087, 267, 2512, 14, 815, 8, 26478, 1213, 9, 398, 327, 437, 22692, 9587, 741, 769, 5129, 267, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 1595, 628, 1623, 11418, 401, 2538, 29, 26478, 1213, 2360, 2615, 1213, 29, 26478, 1213, 12, 1166, 29, 26478, 633, 2360, 10062, 29, 26478, 8311, 2360, 5137, 29, 26478, 2798, 2360, 2402, 29, 2911, 2360, 4922, 29, 549, 9, 776, 288, 272, 327, 11177, 69, 1127, 7557, 696, 477, 5259, 1907, 27036, 299, 11302, 903, 65, 272, 32500, 275, 283, 2493, 17514, 6697, 221, 3800, 665, 65, 4369, 9555, 9707, 6697, 15, 1606, 15, 15710, 8771, 1743, 11575, 1907, 27036, 283, 272, 4450, 275, 295, 14, 2014, 8, 10853, 2641, 12, 264, 14, 16504, 680, 6452, 8, 576, 9, 272, 340, 10990, 26, 28348, 14, 1361, 12962, 8, 6742, 9, 272, 367, 1336, 315, 4450, 26, 267, 340, 822, 8, 6742, 13032, 16, 26, 288, 24514, 633, 275, 2402, 11, 1431, 288, 24514, 1213, 275, 19724, 23862, 13765, 14625, 1907, 27036, 2, 288, 24514, 8311, 275, 3087, 288, 24514, 2798, 275, 3087, 1362, 288, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 1595, 628, 513, 285, 321, 606, 32646, 401, 2538, 29, 26478, 1213, 2360, 2615, 1213, 29, 26478, 1213, 2360, 1166, 29, 26478, 633, 2360, 10062, 29, 26478, 8311, 2360, 5137, 29, 26478, 2798, 2360, 2402, 29, 2911, 2360, 4922, 29, 549, 9, 776, 339, 372, 22921, 199, 199, 318, 2342, 11418, 8, 1053, 304, 272, 2512, 14, 815, 10994, 321, 606, 32646, 9457, 14, 647, 61, 22010, 531, 272, 327, 8055, 67, 1273, 65, 1127, 299, 11302, 903, 65, 272, 666, 275, 28348, 14, 1637, 3276, 8, 1053, 14, 633, 9 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 17807, 4559, 199, 3, 4837, 317, 6327, 645, 29549, 446, 1323, 28994, 11349, 199, 3, 6855, 279, 12665, 4837, 606, 32646, 9457, 199, 3, 1455, 921, 11486, 14, 84, 637, 645, 29549, 14, 815, 15, 2718, 13, 21382, 15, 321, 317, 6327, 645, 29549, 15, 199, 17807, 4559, 199, 199, 646, 7097, 12, 4078, 18, 12, 4078, 12, 264, 199, 646, 747, 12, 984, 199, 199, 504, 6170, 492, 2512, 199, 504, 6170, 492, 1101, 199, 504, 6170, 492, 28348, 199, 504, 6170, 14, 1053, 492, 7020, 199, 504, 8037, 492, 1654, 2537, 199, 199, 363, 2775, 363, 275, 298, 321, 606, 32646, 9457, 2, 199, 363, 3710, 363, 275, 298, 38, 2, 199, 363, 466, 363, 275, 298, 6767, 2, 199, 363, 1213, 363, 275, 298, 321, 606, 32646, 9457, 2, 199, 363, 3671, 363, 275, 298, 654, 2, 199, 363, 8782, 602, 363, 275, 298, 1797, 11565, 1651, 2, 199, 199, 5287, 275, 1101, 14, 362, 63, 6031, 480, 1757, 531, 1362, 199, 318, 365, 9417, 837, 272, 372, 715, 199, 199, 318, 2446, 513, 8, 1053, 304, 272, 2512, 14, 815, 10994, 321, 606, 32646, 9457, 14, 647, 61, 2446, 513, 531, 339, 22921, 275, 942, 272, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 2538, 628, 18505, 2906, 305, 437, 3939, 350, 305, 401, 1595, 628, 513, 5129, 18, 2, 2360, 1166, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 6687, 2360, 2402, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 15, 2237, 272, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 2538, 628, 48, 269, 1464, 79, 2, 2360, 1595, 628, 2038, 736, 2, 2360, 1166, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 15, 2237, 272, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 2538, 628, 48, 269, 4236, 848, 437, 276, 7570, 280, 331, 2, 2360, 1595, 628, 7411, 7570, 280, 331, 2, 2360, 1166, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 15, 2237, 272, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 2538, 628, 12106, 7007, 2, 2360, 1595, 628, 1733, 2, 2360, 1166, 628, 1014, 921, 1544, 14, 321, 606, 32646, 9457, 14, 846, 15, 2237, 272, 372, 22921, 199, 199, 318, 769, 285, 321, 606, 32646, 8, 1053, 304, 272, 2512, 14, 815, 10994, 321, 606, 32646, 9457, 14, 647, 61, 769, 285, 321, 606, 32646, 531, 339, 327, 8055, 67, 1273, 65, 1127, 299, 11302, 903, 65, 272, 666, 275, 28348, 14, 1637, 3276, 8, 1053, 14, 633, 9, 272, 2402, 275, 1242, 14, 2911, 339, 327, 11177, 69, 23325, 15992, 9525, 305, 477, 1127, 9881, 13765, 542, 10251, 9718, 10641, 272, 28827, 2076, 1021, 628, 36, 1096, 1872, 2, 6998, 628, 4218, 2, 27554, 628, 2119, 2, 3462, 628, 1960, 5326, 2, 4569, 628, 8488, 5326, 2, 3449, 628, 7451, 13, 2326, 15596, 17, 69, 17, 69, 17, 69, 9426, 641, 10544, 1883, 628, 3749, 14, 2487, 14, 7451, 4117, 26431, 3273, 4065, 641, 10544, 548, 628, 3749, 14, 2487, 14, 7451, 4117, 26431, 17, 69, 17, 69, 17, 69, 7, 8186, 80, 3449, 628, 9650, 13, 8305, 26, 650, 5326, 27, 8665, 13, 8305, 15596, 1217, 1217, 1217, 413, 5326, 18609, 1743, 221, 2151, 198, 28, 65, 4369, 628, 1014, 921, 1544, 14, 321, 606, 32646, 23577, 393, 292, 10175, 14, 957, 15, 20888, 15, 44, 285, 651, 63, 35, 1143, 685, 14, 1360, 8186, 4060, 2928, 628, 1014, 921, 1544, 14, 321, 606, 32646, 23577, 393, 292, 10175, 14, 957, 15, 20801, 15, 2426, 88, 7680, 15, 321, 606, 32646, 15, 10888, 4060, 15, 10888, 969, 1196, 15154, 18931, 14, 8476, 2, 8791, 628, 44, 285, 651, 445, 1143, 685, 2, 9162, 628, 16, 2, 4569, 628, 7680, 2, 3462, 628, 2426, 10070, 65, 26934, 272, 32500, 275, 2650, 2076, 1021, 29, 6697, 28, 65, 283, 272, 32500, 847, 283, 6399, 24296, 8771, 8186, 4060, 2928, 32391, 8791, 32391, 7, 272, 4450, 275, 295, 14, 2014, 8, 10853, 2641, 12, 264, 14, 16504, 680, 6452, 8, 576, 9, 272, 340, 10990, 26, 28348, 14, 1361, 12962, 8, 6742, 9, 272, 22921, 275, 942, 272, 367, 1336, 315, 4450, 26, 267, 24514, 633, 275, 1336, 59, 16, 61, 267, 24514, 1213, 275, 1336, 59, 18, 61, 267, 24514, 8311, 275, 1336, 59, 17, 61, 267, 24514, 2798, 275, 3087, 267, 2512, 14, 815, 8, 26478, 1213, 9, 398, 327, 437, 22692, 9587, 741, 769, 5129, 267, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 1595, 628, 1623, 11418, 401, 2538, 29, 26478, 1213, 2360, 2615, 1213, 29, 26478, 1213, 12, 1166, 29, 26478, 633, 2360, 10062, 29, 26478, 8311, 2360, 5137, 29, 26478, 2798, 2360, 2402, 29, 2911, 2360, 4922, 29, 549, 9, 776, 288, 272, 327, 11177, 69, 1127, 7557, 696, 477, 5259, 1907, 27036, 299, 11302, 903, 65, 272, 32500, 275, 283, 2493, 17514, 6697, 221, 3800, 665, 65, 4369, 9555, 9707, 6697, 15, 1606, 15, 15710, 8771, 1743, 11575, 1907, 27036, 283, 272, 4450, 275, 295, 14, 2014, 8, 10853, 2641, 12, 264, 14, 16504, 680, 6452, 8, 576, 9, 272, 340, 10990, 26, 28348, 14, 1361, 12962, 8, 6742, 9, 272, 367, 1336, 315, 4450, 26, 267, 340, 822, 8, 6742, 13032, 16, 26, 288, 24514, 633, 275, 2402, 11, 1431, 288, 24514, 1213, 275, 19724, 23862, 13765, 14625, 1907, 27036, 2, 288, 24514, 8311, 275, 3087, 288, 24514, 2798, 275, 3087, 1362, 288, 22921, 14, 740, 8, 7020, 8, 2775, 18971, 2775, 3108, 1595, 628, 513, 285, 321, 606, 32646, 401, 2538, 29, 26478, 1213, 2360, 2615, 1213, 29, 26478, 1213, 2360, 1166, 29, 26478, 633, 2360, 10062, 29, 26478, 8311, 2360, 5137, 29, 26478, 2798, 2360, 2402, 29, 2911, 2360, 4922, 29, 549, 9, 776, 339, 372, 22921, 199, 199, 318, 2342, 11418, 8, 1053, 304, 272, 2512, 14, 815, 10994, 321, 606, 32646, 9457, 14, 647, 61, 22010, 531, 272, 327, 8055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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 ]
DESHRAJ/fjord
vendor/packages/translate-toolkit/translate/convert/test_po2php.py
3
6856
#!/usr/bin/env python # -*- coding: utf-8 -*- from pytest import mark from translate.convert import po2php from translate.convert import test_convert from translate.misc import wStringIO from translate.storage import po class TestPO2Php: def po2php(self, posource): """helper that converts po source to .php source without requiring files""" inputfile = wStringIO.StringIO(posource) inputpo = po.pofile(inputfile) convertor = po2php.po2php() outputphp = convertor.convertstore(inputpo) return outputphp def merge2php(self, phpsource, posource): """helper that merges po translations to .php source without requiring files""" inputfile = wStringIO.StringIO(posource) inputpo = po.pofile(inputfile) templatefile = wStringIO.StringIO(phpsource) #templatephp = php.phpfile(templatefile) convertor = po2php.rephp(templatefile, inputpo) outputphp = convertor.convertstore() print outputphp return outputphp def test_merging_simple(self): """check the simplest case of merging a translation""" posource = '''#: $lang['name']\nmsgid "value"\nmsgstr "waarde"\n''' phptemplate = '''$lang['name'] = 'value';\n''' phpexpected = '''$lang['name'] = 'waarde';\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert phpfile == [phpexpected] def test_space_preservation(self): """check that we preserve any spacing in php files when merging""" posource = '''#: $lang['name']\nmsgid "value"\nmsgstr "waarde"\n''' phptemplate = '''$lang['name'] = 'value';\n''' phpexpected = '''$lang['name'] = 'waarde';\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert phpfile == [phpexpected] def test_merging_blank_entries(self): """check that we can correctly merge entries that are blank in the template""" posource = r'''#: accesskey-accept msgid "" "_: accesskey-accept\n" "" msgstr ""''' phptemplate = '''$lang['accesskey-accept'] = '';\n''' phpexpected = '''$lang['accesskey-accept'] = '';\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert phpfile == [phpexpected] def test_merging_fuzzy(self): """check merging a fuzzy translation""" posource = '''#: %24lang%5B+%27name%27+%5D\n#, fuzzy\nmsgid "value"\nmsgstr "waarde"\n''' phptemplate = '''$lang['name'] = 'value';\n''' phpexpected = '''$lang['name'] = 'value';\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert phpfile == [phpexpected] def test_locations_with_spaces(self): """check that a location with spaces in php but spaces removed in PO is used correctly""" posource = '''#: %24lang%5B+%27name%27+%5D\nmsgid "value"\nmsgstr "waarde"\n''' phptemplate = '''$lang[ 'name' ] = 'value';\n''' phpexpected = '''$lang[ 'name' ] = 'waarde';\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert phpfile == [phpexpected] def test_inline_comments(self): """check that we include inline comments from the template. Bug 590""" posource = '''#: %24lang%5B+%27name%27+%5D\nmsgid "value"\nmsgstr "waarde"\n''' phptemplate = '''$lang[ 'name' ] = 'value'; //inline comment\n''' phpexpected = '''$lang[ 'name' ] = 'waarde'; //inline comment\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert phpfile == [phpexpected] def test_named_variables(self): """check that we convert correctly if using named variables.""" posource = '''#: $dictYear msgid "Year" msgstr "Jaar" ''' phptemplate = '''$dictYear = 'Year';\n''' phpexpected = '''$dictYear = 'Jaar';\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert phpfile == [phpexpected] def test_multiline(self): """Check that we convert multiline strings correctly. Bug 1296.""" posource = r'''#: $string['upgradesure'] msgid "" "Your Moodle files have been changed, and you are\n" "about to automatically upgrade your server to this version:\n" "<p><b>$a</b></p>\n" "<p>Once you do this you can not go back again.</p>\n" "<p>Are you sure you want to upgrade this server to this version?</p>" msgstr "" ''' phptemplate = '''$string['upgradesure'] = 'Your Moodle files have been changed, and you are about to automatically upgrade your server to this version: <p><b>$a</b></p> <p>Once you do this you can not go back again.</p> <p>Are you sure you want to upgrade this server to this version?</p>';\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile[0] assert phpfile[0] == phptemplate def test_hash_comment(self): """check that we convert # comments correctly.""" posource = '''#: $variable msgid "stringy" msgstr "stringetjie" ''' phptemplate = '''# inside alt= stuffies\n$variable = 'stringy';\n''' phpexpected = '''# inside alt= stuffies\n$variable = 'stringetjie';\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert "".join(phpfile) == phpexpected def test_arrays(self): """check that we can handle arrays""" posource = '''#: $lang->'name'\nmsgid "value"\nmsgstr "waarde"\n''' phptemplate = '''$lang = array(\n 'name' => 'value',\n);\n''' phpexpected = '''$lang = array(\n 'name' => 'waarde',\n);\n''' phpfile = self.merge2php(phptemplate, posource) print phpfile assert "".join(phpfile) == phpexpected @mark.xfail(reason="Need to review if we want this behaviour") def test_merging_propertyless_template(self): """check that when merging with a template with no property values that we copy the template""" posource = "" proptemplate = "# A comment\n" propexpected = proptemplate propfile = self.merge2prop(proptemplate, posource) print propfile assert propfile == [propexpected] class TestPO2PhpCommand(test_convert.TestConvertCommand, TestPO2Php): """Tests running actual po2php commands on files""" convertmodule = po2php defaultoptions = {"progress": "none"} def test_help(self): """tests getting help""" options = test_convert.TestConvertCommand.test_help(self) options = self.help_check(options, "-t TEMPLATE, --template=TEMPLATE") options = self.help_check(options, "--threshold=PERCENT") options = self.help_check(options, "--fuzzy") options = self.help_check(options, "--nofuzzy", last=True)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 4613, 492, 2216, 199, 199, 504, 9028, 14, 3916, 492, 1115, 18, 8624, 199, 504, 9028, 14, 3916, 492, 511, 63, 3916, 199, 504, 9028, 14, 9923, 492, 336, 6424, 199, 504, 9028, 14, 3494, 492, 1115, 421, 199, 533, 1379, 1512, 18, 5663, 80, 26, 339, 347, 1115, 18, 8624, 8, 277, 12, 2086, 616, 304, 267, 408, 3676, 626, 15373, 1115, 1350, 370, 1275, 8624, 1350, 1928, 29963, 1584, 624, 267, 1324, 493, 275, 336, 6424, 14, 6424, 8, 555, 1365, 9, 267, 1324, 555, 275, 1115, 14, 555, 493, 8, 1210, 493, 9, 267, 3957, 269, 275, 1115, 18, 8624, 14, 555, 18, 8624, 342, 267, 1072, 8624, 275, 3957, 269, 14, 3916, 1617, 8, 1210, 555, 9, 267, 372, 1072, 8624, 339, 347, 5389, 18, 8624, 8, 277, 12, 3945, 1190, 616, 12, 2086, 616, 304, 267, 408, 3676, 626, 32716, 1115, 15547, 370, 1275, 8624, 1350, 1928, 29963, 1584, 624, 267, 1324, 493, 275, 336, 6424, 14, 6424, 8, 555, 1365, 9, 267, 1324, 555, 275, 1115, 14, 555, 493, 8, 1210, 493, 9, 267, 1978, 493, 275, 336, 6424, 14, 6424, 8, 838, 1190, 616, 9, 267, 327, 1160, 8624, 275, 3945, 80, 14, 8624, 493, 8, 1160, 493, 9, 267, 3957, 269, 275, 1115, 18, 8624, 14, 264, 8624, 8, 1160, 493, 12, 1324, 555, 9, 267, 1072, 8624, 275, 3957, 269, 14, 3916, 1617, 342, 267, 870, 1072, 8624, 267, 372, 1072, 8624, 339, 347, 511, 63, 2626, 1540, 63, 4129, 8, 277, 304, 267, 408, 1074, 314, 3486, 270, 1930, 402, 22537, 282, 7761, 624, 267, 2086, 616, 275, 1449, 12573, 2672, 4159, 459, 354, 418, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 459, 354, 418, 275, 283, 585, 7, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 459, 354, 418, 275, 283, 758, 285, 271, 7, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 2638, 63, 657, 8213, 8, 277, 304, 267, 408, 1074, 626, 781, 11211, 1263, 19621, 315, 3945, 80, 1584, 1380, 22537, 624, 267, 2086, 616, 275, 1449, 12573, 2672, 4159, 459, 354, 418, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 459, 354, 418, 221, 275, 221, 283, 585, 7, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 459, 354, 418, 221, 275, 221, 283, 758, 285, 271, 7, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 2626, 1540, 63, 2500, 63, 3189, 8, 277, 304, 267, 408, 1074, 626, 781, 883, 6657, 5389, 4811, 626, 787, 4596, 315, 314, 1978, 624, 267, 2086, 616, 275, 519, 2344, 12573, 2879, 498, 13, 5694, 199, 15245, 3087, 199, 2, 10388, 2879, 498, 13, 5694, 60, 78, 2, 199, 341, 199, 23367, 3087, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 459, 2732, 498, 13, 5694, 418, 275, 2125, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 459, 2732, 498, 13, 5694, 418, 275, 2125, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 2626, 1540, 63, 24529, 8, 277, 304, 267, 408, 1074, 22537, 282, 24101, 7761, 624, 267, 2086, 616, 275, 1449, 12573, 450, 1194, 4159, 5, 21, 34, 25389, 1465, 354, 5, 1465, 25389, 21, 36, 60, 78, 3, 12, 24101, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 459, 354, 418, 221, 275, 221, 283, 585, 7, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 459, 354, 418, 221, 275, 221, 283, 585, 7, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 8022, 63, 1045, 63, 10749, 8, 277, 304, 267, 408, 1074, 626, 282, 2909, 543, 7883, 315, 3945, 80, 1325, 7883, 4829, 315, 3625, 365, 1202, 6657, 624, 267, 2086, 616, 275, 1449, 12573, 450, 1194, 4159, 5, 21, 34, 25389, 1465, 354, 5, 1465, 25389, 21, 36, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 59, 283, 354, 7, 1622, 221, 275, 221, 283, 585, 7, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 59, 283, 354, 7, 1622, 221, 275, 221, 283, 758, 285, 271, 7, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 6460, 63, 6223, 8, 277, 304, 267, 408, 1074, 626, 781, 2387, 8308, 6786, 687, 314, 1978, 14, 221, 21605, 959, 2710, 624, 267, 2086, 616, 275, 1449, 12573, 450, 1194, 4159, 5, 21, 34, 25389, 1465, 354, 5, 1465, 25389, 21, 36, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 59, 283, 354, 7, 1622, 221, 275, 221, 283, 585, 13619, 5001, 6460, 3721, 60, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 59, 283, 354, 7, 1622, 221, 275, 221, 283, 758, 285, 271, 13619, 5001 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 4613, 492, 2216, 199, 199, 504, 9028, 14, 3916, 492, 1115, 18, 8624, 199, 504, 9028, 14, 3916, 492, 511, 63, 3916, 199, 504, 9028, 14, 9923, 492, 336, 6424, 199, 504, 9028, 14, 3494, 492, 1115, 421, 199, 533, 1379, 1512, 18, 5663, 80, 26, 339, 347, 1115, 18, 8624, 8, 277, 12, 2086, 616, 304, 267, 408, 3676, 626, 15373, 1115, 1350, 370, 1275, 8624, 1350, 1928, 29963, 1584, 624, 267, 1324, 493, 275, 336, 6424, 14, 6424, 8, 555, 1365, 9, 267, 1324, 555, 275, 1115, 14, 555, 493, 8, 1210, 493, 9, 267, 3957, 269, 275, 1115, 18, 8624, 14, 555, 18, 8624, 342, 267, 1072, 8624, 275, 3957, 269, 14, 3916, 1617, 8, 1210, 555, 9, 267, 372, 1072, 8624, 339, 347, 5389, 18, 8624, 8, 277, 12, 3945, 1190, 616, 12, 2086, 616, 304, 267, 408, 3676, 626, 32716, 1115, 15547, 370, 1275, 8624, 1350, 1928, 29963, 1584, 624, 267, 1324, 493, 275, 336, 6424, 14, 6424, 8, 555, 1365, 9, 267, 1324, 555, 275, 1115, 14, 555, 493, 8, 1210, 493, 9, 267, 1978, 493, 275, 336, 6424, 14, 6424, 8, 838, 1190, 616, 9, 267, 327, 1160, 8624, 275, 3945, 80, 14, 8624, 493, 8, 1160, 493, 9, 267, 3957, 269, 275, 1115, 18, 8624, 14, 264, 8624, 8, 1160, 493, 12, 1324, 555, 9, 267, 1072, 8624, 275, 3957, 269, 14, 3916, 1617, 342, 267, 870, 1072, 8624, 267, 372, 1072, 8624, 339, 347, 511, 63, 2626, 1540, 63, 4129, 8, 277, 304, 267, 408, 1074, 314, 3486, 270, 1930, 402, 22537, 282, 7761, 624, 267, 2086, 616, 275, 1449, 12573, 2672, 4159, 459, 354, 418, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 459, 354, 418, 275, 283, 585, 7, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 459, 354, 418, 275, 283, 758, 285, 271, 7, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 2638, 63, 657, 8213, 8, 277, 304, 267, 408, 1074, 626, 781, 11211, 1263, 19621, 315, 3945, 80, 1584, 1380, 22537, 624, 267, 2086, 616, 275, 1449, 12573, 2672, 4159, 459, 354, 418, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 459, 354, 418, 221, 275, 221, 283, 585, 7, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 459, 354, 418, 221, 275, 221, 283, 758, 285, 271, 7, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 2626, 1540, 63, 2500, 63, 3189, 8, 277, 304, 267, 408, 1074, 626, 781, 883, 6657, 5389, 4811, 626, 787, 4596, 315, 314, 1978, 624, 267, 2086, 616, 275, 519, 2344, 12573, 2879, 498, 13, 5694, 199, 15245, 3087, 199, 2, 10388, 2879, 498, 13, 5694, 60, 78, 2, 199, 341, 199, 23367, 3087, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 459, 2732, 498, 13, 5694, 418, 275, 2125, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 459, 2732, 498, 13, 5694, 418, 275, 2125, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 2626, 1540, 63, 24529, 8, 277, 304, 267, 408, 1074, 22537, 282, 24101, 7761, 624, 267, 2086, 616, 275, 1449, 12573, 450, 1194, 4159, 5, 21, 34, 25389, 1465, 354, 5, 1465, 25389, 21, 36, 60, 78, 3, 12, 24101, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 459, 354, 418, 221, 275, 221, 283, 585, 7, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 459, 354, 418, 221, 275, 221, 283, 585, 7, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 8022, 63, 1045, 63, 10749, 8, 277, 304, 267, 408, 1074, 626, 282, 2909, 543, 7883, 315, 3945, 80, 1325, 7883, 4829, 315, 3625, 365, 1202, 6657, 624, 267, 2086, 616, 275, 1449, 12573, 450, 1194, 4159, 5, 21, 34, 25389, 1465, 354, 5, 1465, 25389, 21, 36, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 59, 283, 354, 7, 1622, 221, 275, 221, 283, 585, 7, 3779, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 59, 283, 354, 7, 1622, 221, 275, 221, 283, 758, 285, 271, 7, 3779, 78, 2344, 267, 3945, 80, 493, 275, 291, 14, 5628, 18, 8624, 8, 8624, 1160, 12, 2086, 616, 9, 267, 870, 3945, 80, 493, 267, 702, 3945, 80, 493, 508, 359, 838, 16531, 1043, 61, 339, 347, 511, 63, 6460, 63, 6223, 8, 277, 304, 267, 408, 1074, 626, 781, 2387, 8308, 6786, 687, 314, 1978, 14, 221, 21605, 959, 2710, 624, 267, 2086, 616, 275, 1449, 12573, 450, 1194, 4159, 5, 21, 34, 25389, 1465, 354, 5, 1465, 25389, 21, 36, 60, 78, 15245, 298, 585, 3212, 78, 23367, 298, 758, 285, 271, 3212, 78, 2344, 267, 3945, 80, 1160, 275, 1449, 4, 4159, 59, 283, 354, 7, 1622, 221, 275, 221, 283, 585, 13619, 5001, 6460, 3721, 60, 78, 2344, 267, 3945, 16531, 1043, 275, 1449, 4, 4159, 59, 283, 354, 7, 1622, 221, 275, 221, 283, 758, 285, 271, 13619, 5001, 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,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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 ]
nikchu/hello-world
repo/pager.py
34
2008
# # Copyright (C) 2008 The Android Open Source Project # # 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 select import sys active = False def RunPager(globalConfig): global active if not os.isatty(0) or not os.isatty(1): return pager = _SelectPager(globalConfig) if pager == '' or pager == 'cat': return # This process turns into the pager; a child it forks will # do the real processing and output back to the pager. This # is necessary to keep the pager in control of the tty. # try: r, w = os.pipe() pid = os.fork() if not pid: os.dup2(w, 1) os.dup2(w, 2) os.close(r) os.close(w) active = True return os.dup2(r, 0) os.close(r) os.close(w) _BecomePager(pager) except Exception: print >>sys.stderr, "fatal: cannot start pager '%s'" % pager os.exit(255) def _SelectPager(globalConfig): try: return os.environ['GIT_PAGER'] except KeyError: pass pager = globalConfig.GetString('core.pager') if pager: return pager try: return os.environ['PAGER'] except KeyError: pass return 'less' def _BecomePager(pager): # Delaying execution of the pager until we have output # ready works around a long-standing bug in popularly # available versions of 'less', a better 'more'. # a, b, c = select.select([0], [], [0]) os.environ['LESS'] = 'FRSX' try: os.execvp(pager, [pager]) except OSError, e: os.execv('/bin/sh', ['sh', '-c', pager])
apache-2.0
[ 3, 199, 3, 1898, 334, 35, 9, 9079, 710, 14694, 3232, 5800, 7290, 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, 646, 747, 199, 646, 3504, 199, 646, 984, 199, 199, 2682, 275, 756, 199, 199, 318, 3378, 48, 1456, 8, 2966, 2028, 304, 523, 2288, 4702, 819, 340, 440, 747, 14, 21122, 8, 16, 9, 503, 440, 747, 14, 21122, 8, 17, 304, 272, 372, 523, 26581, 275, 485, 5446, 48, 1456, 8, 2966, 2028, 9, 523, 340, 26581, 508, 2125, 503, 26581, 508, 283, 3385, 356, 272, 372, 819, 327, 961, 2112, 25449, 1901, 314, 26581, 27, 282, 1982, 652, 367, 6080, 911, 523, 327, 886, 314, 3363, 6661, 436, 1072, 1771, 370, 314, 26581, 14, 961, 523, 327, 365, 5784, 370, 4215, 314, 26581, 315, 3304, 402, 314, 21862, 14, 523, 327, 523, 862, 26, 272, 519, 12, 336, 275, 747, 14, 4990, 342, 272, 4422, 275, 747, 14, 11796, 342, 272, 340, 440, 4422, 26, 489, 747, 14, 11048, 18, 8, 87, 12, 413, 9, 489, 747, 14, 11048, 18, 8, 87, 12, 499, 9, 489, 747, 14, 1600, 8, 82, 9, 489, 747, 14, 1600, 8, 87, 9, 489, 4702, 275, 715, 489, 372, 339, 747, 14, 11048, 18, 8, 82, 12, 378, 9, 272, 747, 14, 1600, 8, 82, 9, 272, 747, 14, 1600, 8, 87, 9, 339, 485, 3655, 4352, 48, 1456, 8, 21219, 9, 523, 871, 2186, 26, 272, 870, 4331, 1274, 14, 3083, 12, 298, 16208, 26, 3913, 1343, 26581, 1543, 83, 4065, 450, 26581, 272, 747, 14, 2224, 8, 2299, 9, 199, 199, 318, 485, 5446, 48, 1456, 8, 2966, 2028, 304, 523, 862, 26, 272, 372, 747, 14, 2314, 459, 20072, 63, 48, 1254, 540, 418, 523, 871, 4067, 26, 272, 986, 819, 26581, 275, 2288, 2028, 14, 1002, 1558, 360, 1018, 14, 21219, 358, 523, 340, 26581, 26, 272, 372, 26581, 819, 862, 26, 272, 372, 747, 14, 2314, 459, 48, 1254, 540, 418, 523, 871, 4067, 26, 272, 986, 819, 372, 283, 2003, 7, 199, 199, 318, 485, 3655, 4352, 48, 1456, 8, 21219, 304, 523, 327, 18464, 1187, 316, 6451, 402, 314, 26581, 5133, 781, 1172, 1072, 523, 327, 10144, 5419, 6818, 282, 1846, 13, 18126, 6519, 315, 4560, 2238, 590, 523, 327, 2808, 5459, 402, 283, 2003, 297, 282, 8034, 283, 6878, 1370, 523, 327, 523, 282, 12, 330, 12, 286, 275, 3504, 14, 2416, 779, 16, 467, 990, 359, 16, 566, 819, 747, 14, 2314, 459, 30928, 418, 275, 283, 5372, 29768, 7, 819, 862, 26, 272, 747, 14, 1628, 11702, 8, 21219, 12, 359, 21219, 566, 523, 871, 6440, 12, 325, 26, 272, 747, 14, 1628, 86, 2336, 1393, 15, 609, 297, 788, 609, 297, 2475, 67, 297, 26581, 566, 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 ]
[ 199, 3, 1898, 334, 35, 9, 9079, 710, 14694, 3232, 5800, 7290, 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, 646, 747, 199, 646, 3504, 199, 646, 984, 199, 199, 2682, 275, 756, 199, 199, 318, 3378, 48, 1456, 8, 2966, 2028, 304, 523, 2288, 4702, 819, 340, 440, 747, 14, 21122, 8, 16, 9, 503, 440, 747, 14, 21122, 8, 17, 304, 272, 372, 523, 26581, 275, 485, 5446, 48, 1456, 8, 2966, 2028, 9, 523, 340, 26581, 508, 2125, 503, 26581, 508, 283, 3385, 356, 272, 372, 819, 327, 961, 2112, 25449, 1901, 314, 26581, 27, 282, 1982, 652, 367, 6080, 911, 523, 327, 886, 314, 3363, 6661, 436, 1072, 1771, 370, 314, 26581, 14, 961, 523, 327, 365, 5784, 370, 4215, 314, 26581, 315, 3304, 402, 314, 21862, 14, 523, 327, 523, 862, 26, 272, 519, 12, 336, 275, 747, 14, 4990, 342, 272, 4422, 275, 747, 14, 11796, 342, 272, 340, 440, 4422, 26, 489, 747, 14, 11048, 18, 8, 87, 12, 413, 9, 489, 747, 14, 11048, 18, 8, 87, 12, 499, 9, 489, 747, 14, 1600, 8, 82, 9, 489, 747, 14, 1600, 8, 87, 9, 489, 4702, 275, 715, 489, 372, 339, 747, 14, 11048, 18, 8, 82, 12, 378, 9, 272, 747, 14, 1600, 8, 82, 9, 272, 747, 14, 1600, 8, 87, 9, 339, 485, 3655, 4352, 48, 1456, 8, 21219, 9, 523, 871, 2186, 26, 272, 870, 4331, 1274, 14, 3083, 12, 298, 16208, 26, 3913, 1343, 26581, 1543, 83, 4065, 450, 26581, 272, 747, 14, 2224, 8, 2299, 9, 199, 199, 318, 485, 5446, 48, 1456, 8, 2966, 2028, 304, 523, 862, 26, 272, 372, 747, 14, 2314, 459, 20072, 63, 48, 1254, 540, 418, 523, 871, 4067, 26, 272, 986, 819, 26581, 275, 2288, 2028, 14, 1002, 1558, 360, 1018, 14, 21219, 358, 523, 340, 26581, 26, 272, 372, 26581, 819, 862, 26, 272, 372, 747, 14, 2314, 459, 48, 1254, 540, 418, 523, 871, 4067, 26, 272, 986, 819, 372, 283, 2003, 7, 199, 199, 318, 485, 3655, 4352, 48, 1456, 8, 21219, 304, 523, 327, 18464, 1187, 316, 6451, 402, 314, 26581, 5133, 781, 1172, 1072, 523, 327, 10144, 5419, 6818, 282, 1846, 13, 18126, 6519, 315, 4560, 2238, 590, 523, 327, 2808, 5459, 402, 283, 2003, 297, 282, 8034, 283, 6878, 1370, 523, 327, 523, 282, 12, 330, 12, 286, 275, 3504, 14, 2416, 779, 16, 467, 990, 359, 16, 566, 819, 747, 14, 2314, 459, 30928, 418, 275, 283, 5372, 29768, 7, 819, 862, 26, 272, 747, 14, 1628, 11702, 8, 21219, 12, 359, 21219, 566, 523, 871, 6440, 12, 325, 26, 272, 747, 14, 1628, 86, 2336, 1393, 15, 609, 297, 788, 609, 297, 2475, 67, 297, 26581, 566, 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, 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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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 ]
michael-berlin/vitess
py/vtdb/db_object_lookup.py
6
1698
"""Module containing base class for lookup database tables. LookupDBObject defines the base class for lookup tables and defines relevant methods. LookupDBObject inherits from DBObjectUnsharded and extends the functionality for getting, creating, updating and deleting the lookup relationship. """ import functools import struct from vtdb import db_object from vtdb import db_object_unsharded from vtdb import dbexceptions from vtdb import keyrange from vtdb import keyrange_constants from vtdb import shard_constants from vtdb import vtgate_cursor class LookupDBObject(db_object_unsharded.DBObjectUnsharded): """This is an example implementation of lookup class where it is stored in unsharded db. """ @classmethod def get(class_, cursor, entity_id_column, entity_id): where_column_value_pairs = [(entity_id_column, entity_id),] rows = class_.select_by_columns(cursor, where_column_value_pairs) return [row.__dict__ for row in rows] @classmethod def create(class_, cursor, **bind_vars): return class_.insert(cursor, **bind_vars) @classmethod def update(class_, cursor, sharding_key_column_name, sharding_key, entity_id_column, new_entity_id): where_column_value_pairs = [(sharding_key_column_name, sharding_key),] update_column_value_pairs = [(entity_id_column,new_entity_id),] return class_.update_columns(cursor, where_column_value_pairs, update_column_value_pairs) @classmethod def delete(class_, cursor, sharding_key_column_name, sharding_key): where_column_value_pairs = [(sharding_key_column_name, sharding_key),] return class_.delete_by_columns(cursor, where_column_value_pairs)
bsd-3-clause
[ 624, 2377, 3035, 1300, 1021, 367, 4237, 3050, 6716, 14, 199, 199, 7521, 2846, 1692, 7890, 314, 1300, 1021, 367, 4237, 6716, 436, 7890, 199, 21906, 3102, 14, 12785, 2846, 1692, 21592, 687, 6249, 1692, 9251, 8210, 770, 436, 199, 11036, 314, 9330, 367, 10232, 12, 6425, 12, 12928, 436, 13794, 199, 1589, 4237, 8931, 14, 199, 624, 199, 646, 9143, 199, 646, 2702, 199, 199, 504, 18585, 697, 492, 1592, 63, 785, 199, 504, 18585, 697, 492, 1592, 63, 785, 63, 324, 609, 12910, 199, 504, 18585, 697, 492, 1592, 3924, 199, 504, 18585, 697, 492, 790, 1842, 199, 504, 18585, 697, 492, 790, 1842, 63, 5559, 199, 504, 18585, 697, 492, 11814, 63, 5559, 199, 504, 18585, 697, 492, 18585, 3237, 63, 3937, 421, 199, 533, 12785, 2846, 1692, 8, 697, 63, 785, 63, 324, 609, 12910, 14, 2846, 1692, 9251, 8210, 770, 304, 523, 408, 2765, 365, 376, 2893, 4514, 402, 4237, 1021, 2382, 652, 365, 5489, 523, 315, 625, 609, 12910, 1592, 14, 523, 408, 523, 768, 3744, 523, 347, 664, 8, 533, 3131, 3920, 12, 4642, 63, 344, 63, 2301, 12, 4642, 63, 344, 304, 272, 2382, 63, 2301, 63, 585, 63, 7322, 275, 3842, 4502, 63, 344, 63, 2301, 12, 4642, 63, 344, 395, 61, 272, 4730, 275, 221, 1021, 3754, 2416, 63, 991, 63, 3406, 8, 3937, 12, 2382, 63, 2301, 63, 585, 63, 7322, 9, 272, 372, 359, 1143, 855, 807, 363, 367, 1962, 315, 4730, 61, 819, 768, 3744, 523, 347, 1218, 8, 533, 3131, 3920, 12, 1011, 3409, 63, 2936, 304, 272, 372, 1021, 3754, 3176, 8, 3937, 12, 1011, 3409, 63, 2936, 9, 819, 768, 3744, 523, 347, 1678, 8, 533, 3131, 3920, 12, 11814, 316, 63, 498, 63, 2301, 63, 354, 12, 11814, 316, 63, 498, 12, 1467, 4642, 63, 344, 63, 2301, 12, 892, 63, 4502, 63, 344, 304, 272, 2382, 63, 2301, 63, 585, 63, 7322, 275, 3842, 10810, 316, 63, 498, 63, 2301, 63, 354, 12, 11814, 316, 63, 498, 395, 61, 272, 1678, 63, 2301, 63, 585, 63, 7322, 275, 3842, 4502, 63, 344, 63, 2301, 12, 1222, 63, 4502, 63, 344, 395, 61, 272, 372, 1021, 3754, 873, 63, 3406, 8, 3937, 12, 2382, 63, 2301, 63, 585, 63, 7322, 12, 639, 1678, 63, 2301, 63, 585, 63, 7322, 9, 819, 768, 3744, 523, 347, 3145, 8, 533, 3131, 3920, 12, 11814, 316, 63, 498, 63, 2301, 63, 354, 12, 11814, 316, 63, 498, 304, 272, 2382, 63, 2301, 63, 585, 63, 7322, 275, 3842, 10810, 316, 63, 498, 63, 2301, 63, 354, 12, 11814, 316, 63, 498, 395, 61, 272, 372, 1021, 3754, 1807, 63, 991, 63, 3406, 8, 3937, 12, 2382, 63, 2301, 63, 585, 63, 7322, 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 ]
[ 2377, 3035, 1300, 1021, 367, 4237, 3050, 6716, 14, 199, 199, 7521, 2846, 1692, 7890, 314, 1300, 1021, 367, 4237, 6716, 436, 7890, 199, 21906, 3102, 14, 12785, 2846, 1692, 21592, 687, 6249, 1692, 9251, 8210, 770, 436, 199, 11036, 314, 9330, 367, 10232, 12, 6425, 12, 12928, 436, 13794, 199, 1589, 4237, 8931, 14, 199, 624, 199, 646, 9143, 199, 646, 2702, 199, 199, 504, 18585, 697, 492, 1592, 63, 785, 199, 504, 18585, 697, 492, 1592, 63, 785, 63, 324, 609, 12910, 199, 504, 18585, 697, 492, 1592, 3924, 199, 504, 18585, 697, 492, 790, 1842, 199, 504, 18585, 697, 492, 790, 1842, 63, 5559, 199, 504, 18585, 697, 492, 11814, 63, 5559, 199, 504, 18585, 697, 492, 18585, 3237, 63, 3937, 421, 199, 533, 12785, 2846, 1692, 8, 697, 63, 785, 63, 324, 609, 12910, 14, 2846, 1692, 9251, 8210, 770, 304, 523, 408, 2765, 365, 376, 2893, 4514, 402, 4237, 1021, 2382, 652, 365, 5489, 523, 315, 625, 609, 12910, 1592, 14, 523, 408, 523, 768, 3744, 523, 347, 664, 8, 533, 3131, 3920, 12, 4642, 63, 344, 63, 2301, 12, 4642, 63, 344, 304, 272, 2382, 63, 2301, 63, 585, 63, 7322, 275, 3842, 4502, 63, 344, 63, 2301, 12, 4642, 63, 344, 395, 61, 272, 4730, 275, 221, 1021, 3754, 2416, 63, 991, 63, 3406, 8, 3937, 12, 2382, 63, 2301, 63, 585, 63, 7322, 9, 272, 372, 359, 1143, 855, 807, 363, 367, 1962, 315, 4730, 61, 819, 768, 3744, 523, 347, 1218, 8, 533, 3131, 3920, 12, 1011, 3409, 63, 2936, 304, 272, 372, 1021, 3754, 3176, 8, 3937, 12, 1011, 3409, 63, 2936, 9, 819, 768, 3744, 523, 347, 1678, 8, 533, 3131, 3920, 12, 11814, 316, 63, 498, 63, 2301, 63, 354, 12, 11814, 316, 63, 498, 12, 1467, 4642, 63, 344, 63, 2301, 12, 892, 63, 4502, 63, 344, 304, 272, 2382, 63, 2301, 63, 585, 63, 7322, 275, 3842, 10810, 316, 63, 498, 63, 2301, 63, 354, 12, 11814, 316, 63, 498, 395, 61, 272, 1678, 63, 2301, 63, 585, 63, 7322, 275, 3842, 4502, 63, 344, 63, 2301, 12, 1222, 63, 4502, 63, 344, 395, 61, 272, 372, 1021, 3754, 873, 63, 3406, 8, 3937, 12, 2382, 63, 2301, 63, 585, 63, 7322, 12, 639, 1678, 63, 2301, 63, 585, 63, 7322, 9, 819, 768, 3744, 523, 347, 3145, 8, 533, 3131, 3920, 12, 11814, 316, 63, 498, 63, 2301, 63, 354, 12, 11814, 316, 63, 498, 304, 272, 2382, 63, 2301, 63, 585, 63, 7322, 275, 3842, 10810, 316, 63, 498, 63, 2301, 63, 354, 12, 11814, 316, 63, 498, 395, 61, 272, 372, 1021, 3754, 1807, 63, 991, 63, 3406, 8, 3937, 12, 2382, 63, 2301, 63, 585, 63, 7322, 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, 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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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 ]
catapult-project/catapult
third_party/gsutil/gslib/vendored/boto/tests/integration/route53/domains/test_route53domains.py
113
1887
# Copyright (c) 2014 Amazon.com, Inc. or its affiliates. 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. # import boto from boto.route53.domains.exceptions import InvalidInput from tests.compat import unittest class TestRoute53Domains(unittest.TestCase): def setUp(self): self.route53domains = boto.connect_route53domains() def test_check_domain_availability(self): response = self.route53domains.check_domain_availability( domain_name='amazon.com', idn_lang_code='eng' ) self.assertEqual(response, {'Availability': 'UNAVAILABLE'}) def test_handle_invalid_input_error(self): with self.assertRaises(InvalidInput): # Note the invalid character in the domain name. self.route53domains.check_domain_availability( domain_name='!amazon.com', )
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6927, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 221, 2900, 5924, 5702, 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, 3, 199, 199, 646, 6055, 199, 504, 6055, 14, 4449, 2481, 14, 9756, 14, 3924, 492, 6378, 3205, 199, 504, 2295, 14, 5819, 492, 2882, 421, 199, 533, 1379, 7161, 2481, 7705, 83, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 4449, 2481, 9756, 275, 6055, 14, 2242, 63, 4449, 2481, 9756, 342, 339, 347, 511, 63, 1074, 63, 2261, 63, 11856, 8, 277, 304, 267, 1177, 275, 291, 14, 4449, 2481, 9756, 14, 1074, 63, 2261, 63, 11856, 8, 288, 2881, 63, 354, 534, 15144, 14, 957, 297, 288, 1305, 78, 63, 4159, 63, 600, 534, 7420, 7, 267, 776, 267, 291, 14, 629, 8, 1310, 12, 791, 26462, 356, 283, 1734, 17377, 3071, 339, 347, 511, 63, 2479, 63, 3197, 63, 1210, 63, 705, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 3364, 3205, 304, 288, 327, 3390, 314, 3866, 4528, 315, 314, 2881, 536, 14, 288, 291, 14, 4449, 2481, 9756, 14, 1074, 63, 2261, 63, 11856, 8, 355, 2881, 63, 354, 534, 1, 15144, 14, 957, 297, 288, 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 ]
[ 1898, 334, 67, 9, 6927, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 221, 2900, 5924, 5702, 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, 3, 199, 199, 646, 6055, 199, 504, 6055, 14, 4449, 2481, 14, 9756, 14, 3924, 492, 6378, 3205, 199, 504, 2295, 14, 5819, 492, 2882, 421, 199, 533, 1379, 7161, 2481, 7705, 83, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 4449, 2481, 9756, 275, 6055, 14, 2242, 63, 4449, 2481, 9756, 342, 339, 347, 511, 63, 1074, 63, 2261, 63, 11856, 8, 277, 304, 267, 1177, 275, 291, 14, 4449, 2481, 9756, 14, 1074, 63, 2261, 63, 11856, 8, 288, 2881, 63, 354, 534, 15144, 14, 957, 297, 288, 1305, 78, 63, 4159, 63, 600, 534, 7420, 7, 267, 776, 267, 291, 14, 629, 8, 1310, 12, 791, 26462, 356, 283, 1734, 17377, 3071, 339, 347, 511, 63, 2479, 63, 3197, 63, 1210, 63, 705, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 3364, 3205, 304, 288, 327, 3390, 314, 3866, 4528, 315, 314, 2881, 536, 14, 288, 291, 14, 4449, 2481, 9756, 14, 1074, 63, 2261, 63, 11856, 8, 355, 2881, 63, 354, 534, 1, 15144, 14, 957, 297, 288, 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, 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, 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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 ]
sebrandon1/bitcoin
test/functional/wallet_resendwallettransactions.py
45
1328
#!/usr/bin/env python3 # Copyright (c) 2017 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 resendwallettransactions RPC.""" from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_raises_rpc_error class ResendWalletTransactionsTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 self.extra_args = [['--walletbroadcast=false']] def run_test(self): # Should raise RPC_WALLET_ERROR (-4) if walletbroadcast is disabled. assert_raises_rpc_error(-4, "Error: Wallet transaction broadcasting is disabled with -walletbroadcast", self.nodes[0].resendwallettransactions) # Should return an empty array if there aren't unconfirmed wallet transactions. self.stop_node(0) self.start_node(0, extra_args=[]) assert_equal(self.nodes[0].resendwallettransactions(), []) # Should return an array with the unconfirmed wallet transaction. txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) assert_equal(self.nodes[0].resendwallettransactions(), [txid]) if __name__ == '__main__': ResendWalletTransactionsTest().main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 3, 1898, 334, 67, 9, 9708, 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, 295, 2254, 13892, 13754, 11785, 1041, 199, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 702, 63, 1452, 12, 702, 63, 3536, 63, 4354, 63, 705, 199, 199, 533, 799, 2254, 55, 9478, 3188, 3723, 774, 8, 4734, 9061, 26203, 304, 272, 347, 663, 63, 396, 63, 1162, 8, 277, 304, 267, 291, 14, 1507, 63, 2415, 275, 413, 267, 291, 14, 2911, 63, 589, 275, 11194, 306, 13892, 10786, 29, 3910, 6538, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 327, 7719, 746, 11785, 63, 55, 1761, 775, 63, 3170, 5868, 20, 9, 340, 20534, 10786, 365, 6980, 14, 267, 702, 63, 3536, 63, 4354, 63, 705, 2801, 20, 12, 298, 547, 26, 644, 9478, 6008, 32001, 365, 6980, 543, 446, 13892, 10786, 401, 291, 14, 2415, 59, 16, 1055, 264, 2254, 13892, 13754, 9, 398, 327, 7719, 372, 376, 2701, 1625, 340, 2337, 10621, 1133, 625, 16391, 20534, 15809, 14, 267, 291, 14, 2379, 63, 932, 8, 16, 9, 267, 291, 14, 928, 63, 932, 8, 16, 12, 2402, 63, 589, 14285, 267, 702, 63, 1452, 8, 277, 14, 2415, 59, 16, 1055, 264, 2254, 13892, 13754, 1062, 3073, 398, 327, 7719, 372, 376, 1625, 543, 314, 625, 16391, 20534, 6008, 14, 267, 22083, 275, 291, 14, 2415, 59, 16, 1055, 23267, 1562, 8, 277, 14, 2415, 59, 16, 1055, 21102, 1062, 413, 9, 267, 702, 63, 1452, 8, 277, 14, 2415, 59, 16, 1055, 264, 2254, 13892, 13754, 1062, 359, 14113, 566, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 799, 2254, 55, 9478, 3188, 3723, 774, 1252, 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, 32768, 32768, 32768, 32768, 32768, 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, 19, 199, 3, 1898, 334, 67, 9, 9708, 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, 295, 2254, 13892, 13754, 11785, 1041, 199, 199, 504, 511, 63, 4857, 14, 396, 63, 4857, 492, 21158, 26203, 199, 504, 511, 63, 4857, 14, 1974, 492, 702, 63, 1452, 12, 702, 63, 3536, 63, 4354, 63, 705, 199, 199, 533, 799, 2254, 55, 9478, 3188, 3723, 774, 8, 4734, 9061, 26203, 304, 272, 347, 663, 63, 396, 63, 1162, 8, 277, 304, 267, 291, 14, 1507, 63, 2415, 275, 413, 267, 291, 14, 2911, 63, 589, 275, 11194, 306, 13892, 10786, 29, 3910, 6538, 339, 347, 1255, 63, 396, 8, 277, 304, 267, 327, 7719, 746, 11785, 63, 55, 1761, 775, 63, 3170, 5868, 20, 9, 340, 20534, 10786, 365, 6980, 14, 267, 702, 63, 3536, 63, 4354, 63, 705, 2801, 20, 12, 298, 547, 26, 644, 9478, 6008, 32001, 365, 6980, 543, 446, 13892, 10786, 401, 291, 14, 2415, 59, 16, 1055, 264, 2254, 13892, 13754, 9, 398, 327, 7719, 372, 376, 2701, 1625, 340, 2337, 10621, 1133, 625, 16391, 20534, 15809, 14, 267, 291, 14, 2379, 63, 932, 8, 16, 9, 267, 291, 14, 928, 63, 932, 8, 16, 12, 2402, 63, 589, 14285, 267, 702, 63, 1452, 8, 277, 14, 2415, 59, 16, 1055, 264, 2254, 13892, 13754, 1062, 3073, 398, 327, 7719, 372, 376, 1625, 543, 314, 625, 16391, 20534, 6008, 14, 267, 22083, 275, 291, 14, 2415, 59, 16, 1055, 23267, 1562, 8, 277, 14, 2415, 59, 16, 1055, 21102, 1062, 413, 9, 267, 702, 63, 1452, 8, 277, 14, 2415, 59, 16, 1055, 264, 2254, 13892, 13754, 1062, 359, 14113, 566, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 799, 2254, 55, 9478, 3188, 3723, 774, 1252, 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, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
major/supernova
supernova/executable.py
2
12789
# # Copyright 2014 Major Hayden # # 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. # """ Contains the functions needed for supernova and supernova-keyring commands to run """ import re import sys import webbrowser import click from . import config from . import credentials from . import supernova from . import utils def print_env_list(ctx, param, value): if not value or ctx.resilient_parsing: return conf = ctx.params.get('conf') # Retrieve our credentials from the configuration file try: nova_creds = config.run_config(config_file_override=conf) except Exception as e: msg = ("\n There's an error in your configuration file:\n\n" " {0}\n").format(e) click.echo(msg) ctx.exit(1) for env in nova_creds.keys(): nova_env = dict(nova_creds.get('DEFAULT', {}), **nova_creds[env]) envheader = '__ %s ' % click.style(env, fg='green') click.echo(envheader.ljust(86, '_')) for param, value in sorted(nova_env.items()): click.echo(' %s: %s' % (param.upper().ljust(25), value)) ctx.exit() def print_env_short_list(ctx, param, value): if not value or ctx.resilient_parsing: return conf = ctx.params.get('conf') # Retrieve our credentials from the configuration file try: nova_creds = config.run_config(config_file_override=conf) except Exception as e: msg = ("\n There's an error in your configuration file:\n\n" " {0}\n").format(e) click.echo(msg) ctx.exit(1) row = 1 for nova_env in nova_creds.keys(): executable = "nova" auth_url = "" for param, value in sorted(nova_creds[nova_env].items()): if param.upper() == 'OS_EXECUTABLE': executable = value if param.upper() == 'OS_AUTH_URL' and 'inova' in value: executable = 'inova' if param.upper() == 'OS_AUTH_URL': auth_url = value color = 'green' if row % 2 == 0: color = 'red' env = click.style(nova_env, fg=color) click.echo("%s (%s) @ %s" % (env, executable, auth_url)) row += 1 ctx.exit() # NOTE(major): This tells click to allow us to put arguments/options after # the environment is specified. See the note just before the # supernova.run_command() call below for more clarity. command_settings = { 'ignore_unknown_options': True, } @click.command(context_settings=command_settings) # This is a little hacky, but we cannot directly set the default to nova # because then we have no way of determining if the option was supplied on the # command line, or simply set to the default. We need that information so that # we can properly set the executable to run in this order: # 1. executable provided on command line # 2. executable from environment variable # 3. fallback to nova as a default if neither 1 nor 2 are set @click.option('--executable', '-x', default='default', help='Command to run [default: nova]', show_default=False) @click.option('--debug', '-d', default=False, is_flag=True, help="Enable debugging", show_default=True) @click.option('--conf', '-c', default=None, is_flag=False, help="Manually specify a supernova configuration file") @click.option('--quiet', '-q', default=False, show_default=False, is_flag=True, help="Display the least amount of output possible") @click.option('--echo', '-e', default=None, is_flag=True, help="Print the specified environment and exit") @click.option('--dashboard', '-D', default=None, is_flag=True, help="Open dashboard in browser for specified environment") @click.argument('environment', nargs=1) @click.argument('command', nargs=-1) @click.version_option() @click.option('--list', '-l', is_flag=True, callback=print_env_list, expose_value=False, is_eager=False, default=False, help="List all configured environments") @click.option('--shortlist', '-s', is_flag=True, callback=print_env_short_list, expose_value=False, is_eager=False, default=False, help="List all configured environments in shorter format") @click.pass_context def run_supernova(ctx, executable, debug, quiet, environment, command, conf, echo, dashboard): """ You can use supernova with many OpenStack clients and avoid the pain of managing multiple sets of environment variables. Getting started is easy and there's some documentation that can help: http://supernova.readthedocs.org/ The first step is to get your environment variables packed into a configuration file, usually in ~/.supernova. The docs (linked above) have some good examples that you can fill in via copy/paste. Once you have a configuration ready to go, replace 'prod' below with one of your configured environments and try some of these commands: supernova prod list (Lists instances via novaclient) supernova prod image-list (Lists images via novaclient) supernova prod boot ... (Boots an instance via novaclient) Have questions, bugs, or comments? Head on over to Github and open an issue or submit a pull request! https://github.com/major/supernova """ # Retrieve our credentials from the configuration file try: nova_creds = config.run_config(config_file_override=conf) except Exception as e: msg = ("\n There's an error in your configuration file:\n\n" " {0}\n").format(e) click.echo(msg) ctx.exit(1) # Warn the user if there are potentially conflicting environment variables # already set in the user's environment. utils.check_environment_presets() # Is our environment argument a single environment or a supernova group? if utils.is_valid_group(environment, nova_creds): envs = utils.get_envs_in_group(environment, nova_creds) elif ',' in environment: envs = [] for env in environment.split(','): if utils.is_valid_group(env, nova_creds): envs.extend(utils.get_envs_in_group(env, nova_creds)) else: envs.append(env) elif environment.startswith('/') and environment.endswith('/'): envs = [nova_env for nova_env in nova_creds.keys() if re.search(environment[1:-1], nova_env)] else: envs = [environment] # These are arguments for supernova and not the executable that supernova # will eventually call. supernova_args = { 'debug': debug, 'executable': executable, 'quiet': quiet, 'echo': echo, 'dashboard': dashboard, } # If the user specified a single environment, we need to verify that the # environment actually exists in their configuration file. if len(envs) == 1 and not utils.is_valid_environment(envs[0], nova_creds): msg = ("\nCouldn't find an environment called '{0}' in your " "configuration file.\nTry supernova --list to see all " "configured environments.\n".format(envs[0])) click.echo(msg) ctx.exit(1) if supernova_args['echo']: if len(envs) > 1: msg = ("\nCan't echo a group of environments.\nSpecify a single " "environment when using --echo.") click.echo(msg) ctx.exit(1) env = credentials.prep_shell_environment(envs[0], nova_creds) for k in env: click.echo('{0}={1}'.format(k, env[k])) ctx.exit(0) if supernova_args['dashboard']: if len(envs) > 1: msg = ("\nCan't open dashboard for a group of environments.\n" "Specify a single environment when using --dashboard.") click.echo(msg) ctx.exit(1) url = nova_creds[envs[0]].get('SUPERNOVA_DASHBOARD_URL') if url is None: msg = ("\nNo SUPERNOVA_DASHBOARD_URL specified " "for environment: %s" % envs[0]) click.echo(msg) ctx.exit(1) webbrowser.open(url) ctx.exit(0) if len(command) == 0: msg = ("\nMissing arguments to pass to executable Run supernova " "--help for examples.\n".format(envs[0])) click.echo(msg) ctx.exit(1) nova_args = list(command) # Loop through the single environment (if the user specified one) or all # of the environments in a supernova group (if the user specified a group). for env in envs: supernova_args['nova_env'] = env returncode = supernova.run_command(nova_creds, nova_args, supernova_args) # NOTE(major): The return code here is the one that comes back from the # OS_EXECUTABLE that supernova runs (by default, 'nova'). When using # supernova groups, the return code is the one returned by the executable # for the last environment in the group. # # It's not ideal, but it's all I can think of for now. ;) sys.exit(returncode) @click.command() @click.option('--get', '-g', 'action', flag_value='get_credential', help='retrieve a credential from keyring storage') @click.option('--set', '-s', 'action', flag_value='set_credential', help='store a credential in keyring storage',) @click.argument('environment', nargs=1) @click.argument('parameter', nargs=1) @click.pass_context def run_supernova_keyring(ctx, action, environment, parameter): """ Sets or retrieves credentials stored in your system's keyring using the python-keyring module. Global credentials can be shared between multiple configuration sections: \b [prod] OS_PASSWORD=USE_KEYRING['sso_password'] ... \b [staging] OS_PASSWORD=USE_KEYRING['my sso_password'] ... You could retrieve or set the global credential using these commands: \b supernova -g global sso_password <= get the credential supernova -s global sso_password <= set the credential Local credentials are intended for use with only one configuration section: \b [prod] OS_PASSWORD=USE_KEYRING ... \b [staging] OS_PASSWORD=USE_KEYRING ... You could retrieve or set the local credential using these commands: \b supernova -g prod OS_PASSWORD <= get the credential for prod supernova -s prod OS_PASSWORD <= set the credential for prod \b supernova -g staging OS_PASSWORD <= get the credential for staging supernova -s staging OS_PASSWORD <= set the credential for staging Full documentation: \b http://supernova.readthedocs.org/en/latest/configuring/ """ if action == 'get_credential': result = credentials.get_user_password(env=environment, param=parameter) if not result: click.echo("\nUnable to find a credential matching the data " "provided.") ctx.exit(1) else: click.echo("\nFound credential for {0}: {1}".format(*result)) ctx.exit() elif action == 'set_credential': msg = """ Preparing to set a credential in the keyring for: - Environment : {0} - Parameter : {1} If this is correct, enter the corresponding credential to store in your keyring or press CTRL-C to abort""".format(environment, parameter) credential = click.prompt(text=msg, hide_input=True) result = credentials.set_user_password(environment=environment, parameter=parameter, password=credential) if result: click.echo("\nSuccessfully stored.") ctx.exit() else: click.echo("\nUnable to store your credential.") ctx.exit(1) else: click.secho("ERROR: must specify --get or --set", bold=True) click.echo(ctx.get_help()) ctx.exit()
apache-2.0
[ 3, 199, 3, 1898, 6927, 16593, 5857, 869, 1187, 848, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 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, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 3, 199, 624, 199, 6906, 314, 3423, 4346, 367, 1613, 6765, 436, 1613, 6765, 13, 30591, 3718, 199, 475, 1255, 199, 624, 199, 646, 295, 199, 646, 984, 199, 646, 781, 29063, 421, 199, 646, 8968, 421, 199, 504, 1275, 492, 1101, 199, 504, 1275, 492, 6235, 199, 504, 1275, 492, 1613, 6765, 199, 504, 1275, 492, 3778, 421, 199, 318, 870, 63, 1813, 63, 513, 8, 3799, 12, 1215, 12, 574, 304, 272, 340, 440, 574, 503, 4027, 14, 20807, 864, 63, 11059, 26, 267, 372, 339, 3743, 275, 4027, 14, 1162, 14, 362, 360, 2190, 358, 339, 327, 13939, 4154, 6235, 687, 314, 2897, 570, 272, 862, 26, 267, 5913, 63, 15226, 275, 1101, 14, 1065, 63, 888, 8, 888, 63, 493, 63, 4415, 29, 2190, 9, 272, 871, 2186, 465, 325, 26, 267, 1499, 275, 25381, 78, 221, 6006, 1159, 376, 1125, 315, 2195, 2897, 570, 3427, 78, 60, 78, 2, 2049, 298, 259, 469, 16, 4988, 78, 3471, 908, 8, 69, 9, 267, 8968, 14, 7878, 8, 1328, 9, 267, 4027, 14, 2224, 8, 17, 9, 339, 367, 2589, 315, 5913, 63, 15226, 14, 1612, 837, 267, 5913, 63, 1813, 275, 1211, 8, 6765, 63, 15226, 14, 362, 360, 3472, 297, 8613, 1011, 6765, 63, 15226, 59, 1813, 566, 267, 2589, 1291, 275, 2560, 450, 83, 283, 450, 8968, 14, 2487, 8, 1813, 12, 16587, 534, 7731, 358, 267, 8968, 14, 7878, 8, 1813, 1291, 14, 19996, 8, 1184, 12, 2513, 1333, 267, 367, 1215, 12, 574, 315, 3355, 8, 6765, 63, 1813, 14, 1744, 5109, 288, 8968, 14, 7878, 360, 221, 450, 83, 26, 450, 83, 7, 450, 334, 635, 14, 4142, 1252, 19996, 8, 821, 395, 574, 430, 272, 4027, 14, 2224, 342, 421, 199, 318, 870, 63, 1813, 63, 3612, 63, 513, 8, 3799, 12, 1215, 12, 574, 304, 272, 340, 440, 574, 503, 4027, 14, 20807, 864, 63, 11059, 26, 267, 372, 339, 3743, 275, 4027, 14, 1162, 14, 362, 360, 2190, 358, 339, 327, 13939, 4154, 6235, 687, 314, 2897, 570, 272, 862, 26, 267, 5913, 63, 15226, 275, 1101, 14, 1065, 63, 888, 8, 888, 63, 493, 63, 4415, 29, 2190, 9, 272, 871, 2186, 465, 325, 26, 267, 1499, 275, 25381, 78, 221, 6006, 1159, 376, 1125, 315, 2195, 2897, 570, 3427, 78, 60, 78, 2, 2049, 298, 259, 469, 16, 4988, 78, 3471, 908, 8, 69, 9, 267, 8968, 14, 7878, 8, 1328, 9, 267, 4027, 14, 2224, 8, 17, 9, 339, 1962, 275, 413, 272, 367, 5913, 63, 1813, 315, 5913, 63, 15226, 14, 1612, 837, 267, 7286, 275, 298, 6765, 2, 267, 1790, 63, 633, 275, 3087, 267, 367, 1215, 12, 574, 315, 3355, 8, 6765, 63, 15226, 59, 6765, 63, 1813, 1055, 1744, 5109, 288, 340, 1215, 14, 4142, 342, 508, 283, 3100, 63, 21623, 356, 355, 7286, 275, 574, 288, 340, 1215, 14, 4142, 342, 508, 283, 3100, 63, 5580, 63, 2632, 7, 436, 283, 10175, 3042, 7, 315, 574, 26, 355, 7286, 275, 283, 10175, 3042, 7, 288, 340, 1215, 14, 4142, 342, 508, 283, 3100, 63, 5580, 63, 2632, 356, 355, 1790, 63, 633, 275, 574, 267, 3164, 275, 283, 7731, 7, 267, 340, 1962, 450, 499, 508, 378, 26, 288, 3164, 275, 283, 581, 7, 267, 2589, 275, 8968, 14, 2487, 8, 6765, 63, 1813, 12, 16587, 29, 2326, 9, 267, 8968, 14, 7878, 3647, 83, 4366, 83, 9, 768, 450, 83, 2, 450, 334, 1813, 12, 7286, 12, 1790, 63, 633, 430, 267, 1962, 847, 413, 272, 4027, 14, 2224, 342, 421, 199, 3, 6944, 8, 8452, 304, 961, 26544, 8968, 370, 2040, 2739, 370, 5324, 2368, 15, 1419, 2410, 199, 3, 314, 3734, 365, 2013, 14, 221, 1666, 314, 5317, 2951, 2544, 314, 199, 3, 1613, 6765, 14, 1065, 63, 1531, 342, 1240, 5084, 367, 1655, 824, 7945, 14, 199, 1531, 63, 1751, 275, 469, 272, 283, 4247, 63, 5187, 63, 1419, 356, 715, 12, 199, 93, 421, 199, 32, 4891, 14, 1531, 8, 1100, 63, 1751, 29, 1531, 63, 1751, 9, 199, 3, 961, 365, 282, 12050, 11176, 89, 12, 1325, 781, 3913, 5370, 663, 314, 849, 370, 5913, 199, 3, 2952, 2066, 781, 1172, 949, 4340, 402, 26638, 340, 314, 945, 1990, 6841, 641, 314, 199, 3, 1414, 1004, 12, 503, 9329, 663, 370, 314, 849, 14, 221, 2136, 1929, 626, 2556, 880, 626, 199, 3, 781, 883, 7684, 663, 314, 7286, 370, 1255, 315, 642, 1865, 26, 199, 3, 413, 14, 7286, 2741, 641, 1414, 1004, 199, 3, 499, 14, 7286, 687, 3734, 1750, 199, 3, 650, 14, 9567, 370, 5913, 465, 282, 849, 340, 15564, 413, 6590, 499, 787, 663, 199, 32, 4891, 14, 1422, 4517, 5904, 297, 2475, 88, 297, 849, 534, 885, 297, 1598, 1720, 534, 3110, 370, 1255, 221, 359, 885, 26, 5913, 4300, 2498, 63, 885, 29, 797, 9, 199, 32, 4891, 14, 1422, 4517, 1757, 297, 2475, 68, 297, 849, 29, 797, 12, 365, 63, 4173, 29, 549, 12, 1598, 1720, 628, 6476, 10201, 401, 2498, 63, 885, 29, 549, 9, 199, 32, 4891, 14, 1422, 4517, 2190, 297, 2475, 67, 297, 849, 29, 403, 12, 365, 63, 4173, 29, 797, 12, 1598, 1720, 628, 2395, 3163, 4165, 282, 1613, 6765, 2897, 570, 531 ]
[ 199, 3, 1898, 6927, 16593, 5857, 869, 1187, 848, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 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, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 3, 199, 624, 199, 6906, 314, 3423, 4346, 367, 1613, 6765, 436, 1613, 6765, 13, 30591, 3718, 199, 475, 1255, 199, 624, 199, 646, 295, 199, 646, 984, 199, 646, 781, 29063, 421, 199, 646, 8968, 421, 199, 504, 1275, 492, 1101, 199, 504, 1275, 492, 6235, 199, 504, 1275, 492, 1613, 6765, 199, 504, 1275, 492, 3778, 421, 199, 318, 870, 63, 1813, 63, 513, 8, 3799, 12, 1215, 12, 574, 304, 272, 340, 440, 574, 503, 4027, 14, 20807, 864, 63, 11059, 26, 267, 372, 339, 3743, 275, 4027, 14, 1162, 14, 362, 360, 2190, 358, 339, 327, 13939, 4154, 6235, 687, 314, 2897, 570, 272, 862, 26, 267, 5913, 63, 15226, 275, 1101, 14, 1065, 63, 888, 8, 888, 63, 493, 63, 4415, 29, 2190, 9, 272, 871, 2186, 465, 325, 26, 267, 1499, 275, 25381, 78, 221, 6006, 1159, 376, 1125, 315, 2195, 2897, 570, 3427, 78, 60, 78, 2, 2049, 298, 259, 469, 16, 4988, 78, 3471, 908, 8, 69, 9, 267, 8968, 14, 7878, 8, 1328, 9, 267, 4027, 14, 2224, 8, 17, 9, 339, 367, 2589, 315, 5913, 63, 15226, 14, 1612, 837, 267, 5913, 63, 1813, 275, 1211, 8, 6765, 63, 15226, 14, 362, 360, 3472, 297, 8613, 1011, 6765, 63, 15226, 59, 1813, 566, 267, 2589, 1291, 275, 2560, 450, 83, 283, 450, 8968, 14, 2487, 8, 1813, 12, 16587, 534, 7731, 358, 267, 8968, 14, 7878, 8, 1813, 1291, 14, 19996, 8, 1184, 12, 2513, 1333, 267, 367, 1215, 12, 574, 315, 3355, 8, 6765, 63, 1813, 14, 1744, 5109, 288, 8968, 14, 7878, 360, 221, 450, 83, 26, 450, 83, 7, 450, 334, 635, 14, 4142, 1252, 19996, 8, 821, 395, 574, 430, 272, 4027, 14, 2224, 342, 421, 199, 318, 870, 63, 1813, 63, 3612, 63, 513, 8, 3799, 12, 1215, 12, 574, 304, 272, 340, 440, 574, 503, 4027, 14, 20807, 864, 63, 11059, 26, 267, 372, 339, 3743, 275, 4027, 14, 1162, 14, 362, 360, 2190, 358, 339, 327, 13939, 4154, 6235, 687, 314, 2897, 570, 272, 862, 26, 267, 5913, 63, 15226, 275, 1101, 14, 1065, 63, 888, 8, 888, 63, 493, 63, 4415, 29, 2190, 9, 272, 871, 2186, 465, 325, 26, 267, 1499, 275, 25381, 78, 221, 6006, 1159, 376, 1125, 315, 2195, 2897, 570, 3427, 78, 60, 78, 2, 2049, 298, 259, 469, 16, 4988, 78, 3471, 908, 8, 69, 9, 267, 8968, 14, 7878, 8, 1328, 9, 267, 4027, 14, 2224, 8, 17, 9, 339, 1962, 275, 413, 272, 367, 5913, 63, 1813, 315, 5913, 63, 15226, 14, 1612, 837, 267, 7286, 275, 298, 6765, 2, 267, 1790, 63, 633, 275, 3087, 267, 367, 1215, 12, 574, 315, 3355, 8, 6765, 63, 15226, 59, 6765, 63, 1813, 1055, 1744, 5109, 288, 340, 1215, 14, 4142, 342, 508, 283, 3100, 63, 21623, 356, 355, 7286, 275, 574, 288, 340, 1215, 14, 4142, 342, 508, 283, 3100, 63, 5580, 63, 2632, 7, 436, 283, 10175, 3042, 7, 315, 574, 26, 355, 7286, 275, 283, 10175, 3042, 7, 288, 340, 1215, 14, 4142, 342, 508, 283, 3100, 63, 5580, 63, 2632, 356, 355, 1790, 63, 633, 275, 574, 267, 3164, 275, 283, 7731, 7, 267, 340, 1962, 450, 499, 508, 378, 26, 288, 3164, 275, 283, 581, 7, 267, 2589, 275, 8968, 14, 2487, 8, 6765, 63, 1813, 12, 16587, 29, 2326, 9, 267, 8968, 14, 7878, 3647, 83, 4366, 83, 9, 768, 450, 83, 2, 450, 334, 1813, 12, 7286, 12, 1790, 63, 633, 430, 267, 1962, 847, 413, 272, 4027, 14, 2224, 342, 421, 199, 3, 6944, 8, 8452, 304, 961, 26544, 8968, 370, 2040, 2739, 370, 5324, 2368, 15, 1419, 2410, 199, 3, 314, 3734, 365, 2013, 14, 221, 1666, 314, 5317, 2951, 2544, 314, 199, 3, 1613, 6765, 14, 1065, 63, 1531, 342, 1240, 5084, 367, 1655, 824, 7945, 14, 199, 1531, 63, 1751, 275, 469, 272, 283, 4247, 63, 5187, 63, 1419, 356, 715, 12, 199, 93, 421, 199, 32, 4891, 14, 1531, 8, 1100, 63, 1751, 29, 1531, 63, 1751, 9, 199, 3, 961, 365, 282, 12050, 11176, 89, 12, 1325, 781, 3913, 5370, 663, 314, 849, 370, 5913, 199, 3, 2952, 2066, 781, 1172, 949, 4340, 402, 26638, 340, 314, 945, 1990, 6841, 641, 314, 199, 3, 1414, 1004, 12, 503, 9329, 663, 370, 314, 849, 14, 221, 2136, 1929, 626, 2556, 880, 626, 199, 3, 781, 883, 7684, 663, 314, 7286, 370, 1255, 315, 642, 1865, 26, 199, 3, 413, 14, 7286, 2741, 641, 1414, 1004, 199, 3, 499, 14, 7286, 687, 3734, 1750, 199, 3, 650, 14, 9567, 370, 5913, 465, 282, 849, 340, 15564, 413, 6590, 499, 787, 663, 199, 32, 4891, 14, 1422, 4517, 5904, 297, 2475, 88, 297, 849, 534, 885, 297, 1598, 1720, 534, 3110, 370, 1255, 221, 359, 885, 26, 5913, 4300, 2498, 63, 885, 29, 797, 9, 199, 32, 4891, 14, 1422, 4517, 1757, 297, 2475, 68, 297, 849, 29, 797, 12, 365, 63, 4173, 29, 549, 12, 1598, 1720, 628, 6476, 10201, 401, 2498, 63, 885, 29, 549, 9, 199, 32, 4891, 14, 1422, 4517, 2190, 297, 2475, 67, 297, 849, 29, 403, 12, 365, 63, 4173, 29, 797, 12, 1598, 1720, 628, 2395, 3163, 4165, 282, 1613, 6765, 2897, 570, 531, 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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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 ]
CYBAI/servo
tests/wpt/web-platform-tests/tools/third_party/pytest/src/_pytest/reports.py
11
19104
from io import StringIO from pprint import pprint from typing import Any from typing import cast from typing import Dict from typing import Iterable from typing import Iterator from typing import List from typing import Optional from typing import Tuple from typing import TypeVar from typing import Union import attr import py from _pytest._code.code import ExceptionChainRepr from _pytest._code.code import ExceptionInfo from _pytest._code.code import ExceptionRepr from _pytest._code.code import ReprEntry from _pytest._code.code import ReprEntryNative from _pytest._code.code import ReprExceptionInfo from _pytest._code.code import ReprFileLocation from _pytest._code.code import ReprFuncArgs from _pytest._code.code import ReprLocals from _pytest._code.code import ReprTraceback from _pytest._code.code import TerminalRepr from _pytest._io import TerminalWriter from _pytest.compat import final from _pytest.compat import TYPE_CHECKING from _pytest.config import Config from _pytest.nodes import Collector from _pytest.nodes import Item from _pytest.outcomes import skip from _pytest.pathlib import Path if TYPE_CHECKING: from typing import NoReturn from typing_extensions import Type from typing_extensions import Literal from _pytest.runner import CallInfo def getworkerinfoline(node): try: return node._workerinfocache except AttributeError: d = node.workerinfo ver = "%s.%s.%s" % d["version_info"][:3] node._workerinfocache = s = "[{}] {} -- Python {} {}".format( d["id"], d["sysplatform"], ver, d["executable"] ) return s _R = TypeVar("_R", bound="BaseReport") class BaseReport: when = None # type: Optional[str] location = None # type: Optional[Tuple[str, Optional[int], str]] longrepr = ( None ) # type: Union[None, ExceptionInfo[BaseException], Tuple[str, int, str], str, TerminalRepr] sections = [] # type: List[Tuple[str, str]] nodeid = None # type: str def __init__(self, **kw: Any) -> None: self.__dict__.update(kw) if TYPE_CHECKING: # Can have arbitrary fields given to __init__(). def __getattr__(self, key: str) -> Any: ... def toterminal(self, out: TerminalWriter) -> None: if hasattr(self, "node"): out.line(getworkerinfoline(self.node)) longrepr = self.longrepr if longrepr is None: return if hasattr(longrepr, "toterminal"): longrepr_terminal = cast(TerminalRepr, longrepr) longrepr_terminal.toterminal(out) else: try: s = str(longrepr) except UnicodeEncodeError: s = "<unprintable longrepr>" out.line(s) def get_sections(self, prefix: str) -> Iterator[Tuple[str, str]]: for name, content in self.sections: if name.startswith(prefix): yield prefix, content @property def longreprtext(self) -> str: """Read-only property that returns the full string representation of ``longrepr``. .. versionadded:: 3.0 """ file = StringIO() tw = TerminalWriter(file) tw.hasmarkup = False self.toterminal(tw) exc = file.getvalue() return exc.strip() @property def caplog(self) -> str: """Return captured log lines, if log capturing is enabled. .. versionadded:: 3.5 """ return "\n".join( content for (prefix, content) in self.get_sections("Captured log") ) @property def capstdout(self) -> str: """Return captured text from stdout, if capturing is enabled. .. versionadded:: 3.0 """ return "".join( content for (prefix, content) in self.get_sections("Captured stdout") ) @property def capstderr(self) -> str: """Return captured text from stderr, if capturing is enabled. .. versionadded:: 3.0 """ return "".join( content for (prefix, content) in self.get_sections("Captured stderr") ) passed = property(lambda x: x.outcome == "passed") failed = property(lambda x: x.outcome == "failed") skipped = property(lambda x: x.outcome == "skipped") @property def fspath(self) -> str: return self.nodeid.split("::")[0] @property def count_towards_summary(self) -> bool: """**Experimental** Whether this report should be counted towards the totals shown at the end of the test session: "1 passed, 1 failure, etc". .. note:: This function is considered **experimental**, so beware that it is subject to changes even in patch releases. """ return True @property def head_line(self) -> Optional[str]: """**Experimental** The head line shown with longrepr output for this report, more commonly during traceback representation during failures:: ________ Test.foo ________ In the example above, the head_line is "Test.foo". .. note:: This function is considered **experimental**, so beware that it is subject to changes even in patch releases. """ if self.location is not None: fspath, lineno, domain = self.location return domain return None def _get_verbose_word(self, config: Config): _category, _short, verbose = config.hook.pytest_report_teststatus( report=self, config=config ) return verbose def _to_json(self) -> Dict[str, Any]: """Return the contents of this report as a dict of builtin entries, suitable for serialization. This was originally the serialize_report() function from xdist (ca03269). Experimental method. """ return _report_to_json(self) @classmethod def _from_json(cls: "Type[_R]", reportdict: Dict[str, object]) -> _R: """Create either a TestReport or CollectReport, depending on the calling class. It is the callers responsibility to know which class to pass here. This was originally the serialize_report() function from xdist (ca03269). Experimental method. """ kwargs = _report_kwargs_from_json(reportdict) return cls(**kwargs) def _report_unserialization_failure( type_name: str, report_class: "Type[BaseReport]", reportdict ) -> "NoReturn": url = "https://github.com/pytest-dev/pytest/issues" stream = StringIO() pprint("-" * 100, stream=stream) pprint("INTERNALERROR: Unknown entry type returned: %s" % type_name, stream=stream) pprint("report_name: %s" % report_class, stream=stream) pprint(reportdict, stream=stream) pprint("Please report this bug at %s" % url, stream=stream) pprint("-" * 100, stream=stream) raise RuntimeError(stream.getvalue()) @final class TestReport(BaseReport): """Basic test report object (also used for setup and teardown calls if they fail).""" __test__ = False def __init__( self, nodeid: str, location: Tuple[str, Optional[int], str], keywords, outcome: "Literal['passed', 'failed', 'skipped']", longrepr: Union[ None, ExceptionInfo[BaseException], Tuple[str, int, str], str, TerminalRepr ], when: "Literal['setup', 'call', 'teardown']", sections: Iterable[Tuple[str, str]] = (), duration: float = 0, user_properties: Optional[Iterable[Tuple[str, object]]] = None, **extra ) -> None: #: Normalized collection nodeid. self.nodeid = nodeid #: A (filesystempath, lineno, domaininfo) tuple indicating the #: actual location of a test item - it might be different from the #: collected one e.g. if a method is inherited from a different module. self.location = location # type: Tuple[str, Optional[int], str] #: A name -> value dictionary containing all keywords and #: markers associated with a test invocation. self.keywords = keywords #: Test outcome, always one of "passed", "failed", "skipped". self.outcome = outcome #: None or a failure representation. self.longrepr = longrepr #: One of 'setup', 'call', 'teardown' to indicate runtest phase. self.when = when #: User properties is a list of tuples (name, value) that holds user #: defined properties of the test. self.user_properties = list(user_properties or []) #: List of pairs ``(str, str)`` of extra information which needs to #: marshallable. Used by pytest to add captured text #: from ``stdout`` and ``stderr``, but may be used by other plugins #: to add arbitrary information to reports. self.sections = list(sections) #: Time it took to run just the test. self.duration = duration self.__dict__.update(extra) def __repr__(self) -> str: return "<{} {!r} when={!r} outcome={!r}>".format( self.__class__.__name__, self.nodeid, self.when, self.outcome ) @classmethod def from_item_and_call(cls, item: Item, call: "CallInfo[None]") -> "TestReport": """Create and fill a TestReport with standard item and call info.""" when = call.when # Remove "collect" from the Literal type -- only for collection calls. assert when != "collect" duration = call.duration keywords = {x: 1 for x in item.keywords} excinfo = call.excinfo sections = [] if not call.excinfo: outcome = "passed" # type: Literal["passed", "failed", "skipped"] longrepr = ( None ) # type: Union[None, ExceptionInfo[BaseException], Tuple[str, int, str], str, TerminalRepr] else: if not isinstance(excinfo, ExceptionInfo): outcome = "failed" longrepr = excinfo elif isinstance(excinfo.value, skip.Exception): outcome = "skipped" r = excinfo._getreprcrash() longrepr = (str(r.path), r.lineno, r.message) else: outcome = "failed" if call.when == "call": longrepr = item.repr_failure(excinfo) else: # exception in setup or teardown longrepr = item._repr_failure_py( excinfo, style=item.config.getoption("tbstyle", "auto") ) for rwhen, key, content in item._report_sections: sections.append(("Captured {} {}".format(key, rwhen), content)) return cls( item.nodeid, item.location, keywords, outcome, longrepr, when, sections, duration, user_properties=item.user_properties, ) @final class CollectReport(BaseReport): """Collection report object.""" when = "collect" def __init__( self, nodeid: str, outcome: "Literal['passed', 'skipped', 'failed']", longrepr, result: Optional[List[Union[Item, Collector]]], sections: Iterable[Tuple[str, str]] = (), **extra ) -> None: #: Normalized collection nodeid. self.nodeid = nodeid #: Test outcome, always one of "passed", "failed", "skipped". self.outcome = outcome #: None or a failure representation. self.longrepr = longrepr #: The collected items and collection nodes. self.result = result or [] #: List of pairs ``(str, str)`` of extra information which needs to #: marshallable. # Used by pytest to add captured text : from ``stdout`` and ``stderr``, # but may be used by other plugins : to add arbitrary information to # reports. self.sections = list(sections) self.__dict__.update(extra) @property def location(self): return (self.fspath, None, self.fspath) def __repr__(self) -> str: return "<CollectReport {!r} lenresult={} outcome={!r}>".format( self.nodeid, len(self.result), self.outcome ) class CollectErrorRepr(TerminalRepr): def __init__(self, msg: str) -> None: self.longrepr = msg def toterminal(self, out: TerminalWriter) -> None: out.line(self.longrepr, red=True) def pytest_report_to_serializable( report: Union[CollectReport, TestReport] ) -> Optional[Dict[str, Any]]: if isinstance(report, (TestReport, CollectReport)): data = report._to_json() data["$report_type"] = report.__class__.__name__ return data # TODO: Check if this is actually reachable. return None # type: ignore[unreachable] def pytest_report_from_serializable( data: Dict[str, Any], ) -> Optional[Union[CollectReport, TestReport]]: if "$report_type" in data: if data["$report_type"] == "TestReport": return TestReport._from_json(data) elif data["$report_type"] == "CollectReport": return CollectReport._from_json(data) assert False, "Unknown report_type unserialize data: {}".format( data["$report_type"] ) return None def _report_to_json(report: BaseReport) -> Dict[str, Any]: """Return the contents of this report as a dict of builtin entries, suitable for serialization. This was originally the serialize_report() function from xdist (ca03269). """ def serialize_repr_entry( entry: Union[ReprEntry, ReprEntryNative] ) -> Dict[str, Any]: data = attr.asdict(entry) for key, value in data.items(): if hasattr(value, "__dict__"): data[key] = attr.asdict(value) entry_data = {"type": type(entry).__name__, "data": data} return entry_data def serialize_repr_traceback(reprtraceback: ReprTraceback) -> Dict[str, Any]: result = attr.asdict(reprtraceback) result["reprentries"] = [ serialize_repr_entry(x) for x in reprtraceback.reprentries ] return result def serialize_repr_crash( reprcrash: Optional[ReprFileLocation], ) -> Optional[Dict[str, Any]]: if reprcrash is not None: return attr.asdict(reprcrash) else: return None def serialize_exception_longrepr(rep: BaseReport) -> Dict[str, Any]: assert rep.longrepr is not None # TODO: Investigate whether the duck typing is really necessary here. longrepr = cast(ExceptionRepr, rep.longrepr) result = { "reprcrash": serialize_repr_crash(longrepr.reprcrash), "reprtraceback": serialize_repr_traceback(longrepr.reprtraceback), "sections": longrepr.sections, } # type: Dict[str, Any] if isinstance(longrepr, ExceptionChainRepr): result["chain"] = [] for repr_traceback, repr_crash, description in longrepr.chain: result["chain"].append( ( serialize_repr_traceback(repr_traceback), serialize_repr_crash(repr_crash), description, ) ) else: result["chain"] = None return result d = report.__dict__.copy() if hasattr(report.longrepr, "toterminal"): if hasattr(report.longrepr, "reprtraceback") and hasattr( report.longrepr, "reprcrash" ): d["longrepr"] = serialize_exception_longrepr(report) else: d["longrepr"] = str(report.longrepr) else: d["longrepr"] = report.longrepr for name in d: if isinstance(d[name], (py.path.local, Path)): d[name] = str(d[name]) elif name == "result": d[name] = None # for now return d def _report_kwargs_from_json(reportdict: Dict[str, Any]) -> Dict[str, Any]: """Return **kwargs that can be used to construct a TestReport or CollectReport instance. This was originally the serialize_report() function from xdist (ca03269). """ def deserialize_repr_entry(entry_data): data = entry_data["data"] entry_type = entry_data["type"] if entry_type == "ReprEntry": reprfuncargs = None reprfileloc = None reprlocals = None if data["reprfuncargs"]: reprfuncargs = ReprFuncArgs(**data["reprfuncargs"]) if data["reprfileloc"]: reprfileloc = ReprFileLocation(**data["reprfileloc"]) if data["reprlocals"]: reprlocals = ReprLocals(data["reprlocals"]["lines"]) reprentry = ReprEntry( lines=data["lines"], reprfuncargs=reprfuncargs, reprlocals=reprlocals, reprfileloc=reprfileloc, style=data["style"], ) # type: Union[ReprEntry, ReprEntryNative] elif entry_type == "ReprEntryNative": reprentry = ReprEntryNative(data["lines"]) else: _report_unserialization_failure(entry_type, TestReport, reportdict) return reprentry def deserialize_repr_traceback(repr_traceback_dict): repr_traceback_dict["reprentries"] = [ deserialize_repr_entry(x) for x in repr_traceback_dict["reprentries"] ] return ReprTraceback(**repr_traceback_dict) def deserialize_repr_crash(repr_crash_dict: Optional[Dict[str, Any]]): if repr_crash_dict is not None: return ReprFileLocation(**repr_crash_dict) else: return None if ( reportdict["longrepr"] and "reprcrash" in reportdict["longrepr"] and "reprtraceback" in reportdict["longrepr"] ): reprtraceback = deserialize_repr_traceback( reportdict["longrepr"]["reprtraceback"] ) reprcrash = deserialize_repr_crash(reportdict["longrepr"]["reprcrash"]) if reportdict["longrepr"]["chain"]: chain = [] for repr_traceback_data, repr_crash_data, description in reportdict[ "longrepr" ]["chain"]: chain.append( ( deserialize_repr_traceback(repr_traceback_data), deserialize_repr_crash(repr_crash_data), description, ) ) exception_info = ExceptionChainRepr( chain ) # type: Union[ExceptionChainRepr,ReprExceptionInfo] else: exception_info = ReprExceptionInfo(reprtraceback, reprcrash) for section in reportdict["longrepr"]["sections"]: exception_info.addsection(*section) reportdict["longrepr"] = exception_info return reportdict
mpl-2.0
[ 504, 5890, 492, 5228, 199, 504, 10933, 492, 10933, 199, 504, 14090, 492, 6184, 199, 504, 14090, 492, 9106, 199, 504, 14090, 492, 7448, 199, 504, 14090, 492, 19937, 199, 504, 14090, 492, 25769, 199, 504, 14090, 492, 3820, 199, 504, 14090, 492, 4879, 199, 504, 14090, 492, 11634, 199, 504, 14090, 492, 2434, 5894, 199, 504, 14090, 492, 15961, 199, 199, 646, 1921, 199, 646, 1134, 199, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 2186, 10720, 15713, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 2186, 2354, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 2186, 15713, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 3900, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 3900, 19675, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 1726, 2354, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 1173, 6592, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 7465, 6213, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 3040, 2551, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 15905, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 20429, 279, 15713, 199, 504, 485, 4462, 423, 2308, 492, 20429, 279, 6261, 199, 504, 485, 4462, 14, 5819, 492, 4242, 199, 504, 485, 4462, 14, 5819, 492, 11511, 63, 8936, 1206, 199, 504, 485, 4462, 14, 888, 492, 4094, 199, 504, 485, 4462, 14, 2415, 492, 3626, 3283, 199, 504, 485, 4462, 14, 2415, 492, 7020, 199, 504, 485, 4462, 14, 17502, 83, 492, 3372, 199, 504, 485, 4462, 14, 515, 773, 492, 6912, 199, 199, 692, 11511, 63, 8936, 1206, 26, 272, 687, 14090, 492, 3091, 1767, 272, 687, 14090, 63, 5359, 492, 2434, 272, 687, 14090, 63, 5359, 492, 18271, 339, 687, 485, 4462, 14, 5933, 492, 6523, 2354, 421, 199, 318, 664, 6599, 4904, 393, 1132, 8, 932, 304, 272, 862, 26, 267, 372, 1031, 423, 6599, 815, 1637, 272, 871, 4281, 26, 267, 366, 275, 1031, 14, 6599, 815, 267, 809, 275, 2071, 83, 4111, 83, 4111, 83, 2, 450, 366, 905, 1023, 63, 815, 937, 1491, 19, 61, 267, 1031, 423, 6599, 815, 1637, 275, 308, 275, 7369, 27922, 1052, 1553, 2018, 1052, 8352, 908, 8, 288, 366, 905, 344, 2255, 366, 905, 1274, 3246, 2255, 809, 12, 366, 905, 5904, 937, 267, 776, 267, 372, 308, 421, 199, 63, 50, 275, 2434, 5894, 11008, 50, 401, 3914, 628, 1563, 7457, 531, 421, 199, 533, 3523, 7457, 26, 272, 1380, 275, 488, 221, 327, 730, 26, 4879, 59, 495, 61, 272, 2909, 275, 488, 221, 327, 730, 26, 4879, 59, 7075, 59, 495, 12, 4879, 59, 442, 467, 620, 2677, 272, 1846, 2722, 275, 334, 267, 488, 272, 776, 221, 327, 730, 26, 15961, 59, 403, 12, 2186, 2354, 59, 29900, 467, 11634, 59, 495, 12, 1109, 12, 620, 467, 620, 12, 20429, 279, 15713, 61, 272, 10189, 275, 942, 221, 327, 730, 26, 3820, 59, 7075, 59, 495, 12, 620, 2677, 272, 1031, 344, 275, 488, 221, 327, 730, 26, 620, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 26, 6184, 9, 1035, 488, 26, 267, 291, 855, 807, 4343, 873, 8, 829, 9, 339, 340, 11511, 63, 8936, 1206, 26, 267, 327, 6855, 1172, 9697, 1504, 1627, 370, 636, 826, 31261, 267, 347, 636, 5675, 721, 277, 12, 790, 26, 620, 9, 1035, 6184, 26, 288, 2263, 339, 347, 370, 12010, 8, 277, 12, 734, 26, 20429, 279, 6261, 9, 1035, 488, 26, 267, 340, 2688, 8, 277, 12, 298, 932, 2349, 288, 734, 14, 604, 8, 362, 6599, 4904, 393, 1132, 8, 277, 14, 932, 430, 398, 1846, 2722, 275, 291, 14, 2809, 2722, 267, 340, 1846, 2722, 365, 488, 26, 288, 372, 398, 340, 2688, 8, 2809, 2722, 12, 298, 475, 12010, 2349, 288, 1846, 2722, 63, 12010, 275, 9106, 8, 22015, 15713, 12, 1846, 2722, 9, 288, 1846, 2722, 63, 12010, 14, 475, 12010, 8, 548, 9, 267, 587, 26, 288, 862, 26, 355, 308, 275, 620, 8, 2809, 2722, 9, 288, 871, 24094, 26, 355, 308, 275, 3886, 324, 20557, 1846, 2722, 4335, 288, 734, 14, 604, 8, 83, 9, 339, 347, 664, 63, 7786, 8, 277, 12, 2403, 26, 620, 9, 1035, 25769, 59, 7075, 59, 495, 12, 620, 27589, 267, 367, 536, 12, 1564, 315, 291, 14, 7786, 26, 288, 340, 536, 14, 2460, 8, 1861, 304, 355, 1995, 2403, 12, 1564, 339, 768, 1829, 272, 347, 1846, 2722, 505, 8, 277, 9, 1035, 620, 26, 267, 408, 3284, 13, 2118, 3324, 626, 2529, 314, 2615, 1059, 6025, 402, 267, 1124, 2809, 2722, 4345, 398, 2508, 7445, 447, 650, 14, 16, 267, 408, 267, 570, 275, 5228, 342, 267, 8900, 275, 20429, 279, 6261, 8, 493, 9, 267, 8900, 14, 1989, 10131, 275, 756, 267, 291, 14, 475, 12010, 8, 8122, 9, 267, 3178, 275, 570, 14, 7150, 342, 267, 372, 3178, 14, 1913, 342, 339, 768, 1829, 272, 347, 32297, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 17487, 943, 2385, 12, 340, 943, 12162, 4039, 365, 5223, 14, 398, 2508, 7445, 447, 650, 14, 21, 267, 408, 267, 372, 1867, 78, 1674, 904, 8, 288, 1564, 367, 334, 1861, 12, 1564, 9, 315, 291, 14, 362, 63, 7786, 480, 13519, 3297, 943, 531, 267, 776, 339, 768, 1829, 272, 347, 4021, 2703, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 17487, 1318, 687, 3839, 12, 340, 12162, 4039, 365, 5223, 14, 398, 2508, 7445, 447, 650, 14, 16, 267, 408, 267, 372, 10587, 904, 8, 288, 1564, 367, 334, 1861, 12, 1564, 9, 315, 291, 14, 362, 63, 7786, 480, 13519, 3297, 3839, 531, 267, 776, 339, 768, 1829, 272, 347, 4021, 3083, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 17487, 1318, 687, 4635, 12, 340, 12162, 4039, 365, 5223, 14, 398, 2508, 7445, 447, 650, 14, 16, 267, 408, 267, 372, 10587, 904, 8, 288, 1564, 367, 334, 1861, 12, 1564, 9, 315, 291, 14, 362, 63, 7786, 480, 13519, 3297, 4635, 531, 267, 776, 339, 3032, 275, 3324, 8, 2734, 671 ]
[ 5890, 492, 5228, 199, 504, 10933, 492, 10933, 199, 504, 14090, 492, 6184, 199, 504, 14090, 492, 9106, 199, 504, 14090, 492, 7448, 199, 504, 14090, 492, 19937, 199, 504, 14090, 492, 25769, 199, 504, 14090, 492, 3820, 199, 504, 14090, 492, 4879, 199, 504, 14090, 492, 11634, 199, 504, 14090, 492, 2434, 5894, 199, 504, 14090, 492, 15961, 199, 199, 646, 1921, 199, 646, 1134, 199, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 2186, 10720, 15713, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 2186, 2354, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 2186, 15713, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 3900, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 3900, 19675, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 1726, 2354, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 1173, 6592, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 7465, 6213, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 3040, 2551, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 799, 2700, 15905, 199, 504, 485, 4462, 423, 600, 14, 600, 492, 20429, 279, 15713, 199, 504, 485, 4462, 423, 2308, 492, 20429, 279, 6261, 199, 504, 485, 4462, 14, 5819, 492, 4242, 199, 504, 485, 4462, 14, 5819, 492, 11511, 63, 8936, 1206, 199, 504, 485, 4462, 14, 888, 492, 4094, 199, 504, 485, 4462, 14, 2415, 492, 3626, 3283, 199, 504, 485, 4462, 14, 2415, 492, 7020, 199, 504, 485, 4462, 14, 17502, 83, 492, 3372, 199, 504, 485, 4462, 14, 515, 773, 492, 6912, 199, 199, 692, 11511, 63, 8936, 1206, 26, 272, 687, 14090, 492, 3091, 1767, 272, 687, 14090, 63, 5359, 492, 2434, 272, 687, 14090, 63, 5359, 492, 18271, 339, 687, 485, 4462, 14, 5933, 492, 6523, 2354, 421, 199, 318, 664, 6599, 4904, 393, 1132, 8, 932, 304, 272, 862, 26, 267, 372, 1031, 423, 6599, 815, 1637, 272, 871, 4281, 26, 267, 366, 275, 1031, 14, 6599, 815, 267, 809, 275, 2071, 83, 4111, 83, 4111, 83, 2, 450, 366, 905, 1023, 63, 815, 937, 1491, 19, 61, 267, 1031, 423, 6599, 815, 1637, 275, 308, 275, 7369, 27922, 1052, 1553, 2018, 1052, 8352, 908, 8, 288, 366, 905, 344, 2255, 366, 905, 1274, 3246, 2255, 809, 12, 366, 905, 5904, 937, 267, 776, 267, 372, 308, 421, 199, 63, 50, 275, 2434, 5894, 11008, 50, 401, 3914, 628, 1563, 7457, 531, 421, 199, 533, 3523, 7457, 26, 272, 1380, 275, 488, 221, 327, 730, 26, 4879, 59, 495, 61, 272, 2909, 275, 488, 221, 327, 730, 26, 4879, 59, 7075, 59, 495, 12, 4879, 59, 442, 467, 620, 2677, 272, 1846, 2722, 275, 334, 267, 488, 272, 776, 221, 327, 730, 26, 15961, 59, 403, 12, 2186, 2354, 59, 29900, 467, 11634, 59, 495, 12, 1109, 12, 620, 467, 620, 12, 20429, 279, 15713, 61, 272, 10189, 275, 942, 221, 327, 730, 26, 3820, 59, 7075, 59, 495, 12, 620, 2677, 272, 1031, 344, 275, 488, 221, 327, 730, 26, 620, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 26, 6184, 9, 1035, 488, 26, 267, 291, 855, 807, 4343, 873, 8, 829, 9, 339, 340, 11511, 63, 8936, 1206, 26, 267, 327, 6855, 1172, 9697, 1504, 1627, 370, 636, 826, 31261, 267, 347, 636, 5675, 721, 277, 12, 790, 26, 620, 9, 1035, 6184, 26, 288, 2263, 339, 347, 370, 12010, 8, 277, 12, 734, 26, 20429, 279, 6261, 9, 1035, 488, 26, 267, 340, 2688, 8, 277, 12, 298, 932, 2349, 288, 734, 14, 604, 8, 362, 6599, 4904, 393, 1132, 8, 277, 14, 932, 430, 398, 1846, 2722, 275, 291, 14, 2809, 2722, 267, 340, 1846, 2722, 365, 488, 26, 288, 372, 398, 340, 2688, 8, 2809, 2722, 12, 298, 475, 12010, 2349, 288, 1846, 2722, 63, 12010, 275, 9106, 8, 22015, 15713, 12, 1846, 2722, 9, 288, 1846, 2722, 63, 12010, 14, 475, 12010, 8, 548, 9, 267, 587, 26, 288, 862, 26, 355, 308, 275, 620, 8, 2809, 2722, 9, 288, 871, 24094, 26, 355, 308, 275, 3886, 324, 20557, 1846, 2722, 4335, 288, 734, 14, 604, 8, 83, 9, 339, 347, 664, 63, 7786, 8, 277, 12, 2403, 26, 620, 9, 1035, 25769, 59, 7075, 59, 495, 12, 620, 27589, 267, 367, 536, 12, 1564, 315, 291, 14, 7786, 26, 288, 340, 536, 14, 2460, 8, 1861, 304, 355, 1995, 2403, 12, 1564, 339, 768, 1829, 272, 347, 1846, 2722, 505, 8, 277, 9, 1035, 620, 26, 267, 408, 3284, 13, 2118, 3324, 626, 2529, 314, 2615, 1059, 6025, 402, 267, 1124, 2809, 2722, 4345, 398, 2508, 7445, 447, 650, 14, 16, 267, 408, 267, 570, 275, 5228, 342, 267, 8900, 275, 20429, 279, 6261, 8, 493, 9, 267, 8900, 14, 1989, 10131, 275, 756, 267, 291, 14, 475, 12010, 8, 8122, 9, 267, 3178, 275, 570, 14, 7150, 342, 267, 372, 3178, 14, 1913, 342, 339, 768, 1829, 272, 347, 32297, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 17487, 943, 2385, 12, 340, 943, 12162, 4039, 365, 5223, 14, 398, 2508, 7445, 447, 650, 14, 21, 267, 408, 267, 372, 1867, 78, 1674, 904, 8, 288, 1564, 367, 334, 1861, 12, 1564, 9, 315, 291, 14, 362, 63, 7786, 480, 13519, 3297, 943, 531, 267, 776, 339, 768, 1829, 272, 347, 4021, 2703, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 17487, 1318, 687, 3839, 12, 340, 12162, 4039, 365, 5223, 14, 398, 2508, 7445, 447, 650, 14, 16, 267, 408, 267, 372, 10587, 904, 8, 288, 1564, 367, 334, 1861, 12, 1564, 9, 315, 291, 14, 362, 63, 7786, 480, 13519, 3297, 3839, 531, 267, 776, 339, 768, 1829, 272, 347, 4021, 3083, 8, 277, 9, 1035, 620, 26, 267, 408, 1767, 17487, 1318, 687,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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 ]
flyher/pymo
android/pgs4a-0.9.6/python-install/lib/python2.7/json/__init__.py
40
13818
r"""JSON (JavaScript Object Notation) <http://json.org> is a subset of JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data interchange format. :mod:`json` exposes an API familiar to users of the standard library :mod:`marshal` and :mod:`pickle` modules. It is the externally maintained version of the :mod:`json` library contained in Python 2.6, but maintains compatibility with Python 2.4 and Python 2.5 and (currently) has significant performance advantages, even without using the optional C extension for speedups. Encoding basic Python object hierarchies:: >>> import json >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]) '["foo", {"bar": ["baz", null, 1.0, 2]}]' >>> print json.dumps("\"foo\bar") "\"foo\bar" >>> print json.dumps(u'\u1234') "\u1234" >>> print json.dumps('\\') "\\" >>> print json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True) {"a": 0, "b": 0, "c": 0} >>> from StringIO import StringIO >>> io = StringIO() >>> json.dump(['streaming API'], io) >>> io.getvalue() '["streaming API"]' Compact encoding:: >>> import json >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':')) '[1,2,3,{"4":5,"6":7}]' Pretty printing:: >>> import json >>> s = json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4) >>> print '\n'.join([l.rstrip() for l in s.splitlines()]) { "4": 5, "6": 7 } Decoding JSON:: >>> import json >>> obj = [u'foo', {u'bar': [u'baz', None, 1.0, 2]}] >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') == obj True >>> json.loads('"\\"foo\\bar"') == u'"foo\x08ar' True >>> from StringIO import StringIO >>> io = StringIO('["streaming API"]') >>> json.load(io)[0] == 'streaming API' True Specializing JSON object decoding:: >>> import json >>> def as_complex(dct): ... if '__complex__' in dct: ... return complex(dct['real'], dct['imag']) ... return dct ... >>> json.loads('{"__complex__": true, "real": 1, "imag": 2}', ... object_hook=as_complex) (1+2j) >>> from decimal import Decimal >>> json.loads('1.1', parse_float=Decimal) == Decimal('1.1') True Specializing JSON object encoding:: >>> import json >>> def encode_complex(obj): ... if isinstance(obj, complex): ... return [obj.real, obj.imag] ... raise TypeError(repr(o) + " is not JSON serializable") ... >>> json.dumps(2 + 1j, default=encode_complex) '[2.0, 1.0]' >>> json.JSONEncoder(default=encode_complex).encode(2 + 1j) '[2.0, 1.0]' >>> ''.join(json.JSONEncoder(default=encode_complex).iterencode(2 + 1j)) '[2.0, 1.0]' Using json.tool from the shell to validate and pretty-print:: $ echo '{"json":"obj"}' | python -m json.tool { "json": "obj" } $ echo '{ 1.2:3.4}' | python -m json.tool Expecting property name: line 1 column 2 (char 2) """ __version__ = '2.0.9' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONEncoder', ] __author__ = 'Bob Ippolito <bob@redivi.com>' from .decoder import JSONDecoder from .encoder import JSONEncoder _default_encoder = JSONEncoder( skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, indent=None, separators=None, encoding='utf-8', default=None, ) def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', default=None, **kw): """Serialize ``obj`` as a JSON formatted stream to ``fp`` (a ``.write()``-supporting file-like object). If ``skipkeys`` is true then ``dict`` keys that are not basic types (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) will be skipped instead of raising a ``TypeError``. If ``ensure_ascii`` is false, then the some chunks written to ``fp`` may be ``unicode`` instances, subject to normal Python ``str`` to ``unicode`` coercion rules. Unless ``fp.write()`` explicitly understands ``unicode`` (as in ``codecs.getwriter()``) this is likely to cause an error. If ``check_circular`` is false, then the circular reference check for container types will be skipped and a circular reference will result in an ``OverflowError`` (or worse). If ``allow_nan`` is false, then it will be a ``ValueError`` to serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``). If ``indent`` is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. ``None`` is the most compact representation. If ``separators`` is an ``(item_separator, dict_separator)`` tuple then it will be used instead of the default ``(', ', ': ')`` separators. ``(',', ':')`` is the most compact JSON representation. ``encoding`` is the character encoding for str instances, default is UTF-8. ``default(obj)`` is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError. To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the ``.default()`` method to serialize additional types), specify it with the ``cls`` kwarg; otherwise ``JSONEncoder`` is used. """ # cached encoder if (not skipkeys and ensure_ascii and check_circular and allow_nan and cls is None and indent is None and separators is None and encoding == 'utf-8' and default is None and not kw): iterable = _default_encoder.iterencode(obj) else: if cls is None: cls = JSONEncoder iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii, check_circular=check_circular, allow_nan=allow_nan, indent=indent, separators=separators, encoding=encoding, default=default, **kw).iterencode(obj) # could accelerate with writelines in some versions of Python, at # a debuggability cost for chunk in iterable: fp.write(chunk) def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', default=None, **kw): """Serialize ``obj`` to a JSON formatted ``str``. If ``skipkeys`` is false then ``dict`` keys that are not basic types (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) will be skipped instead of raising a ``TypeError``. If ``ensure_ascii`` is false, then the return value will be a ``unicode`` instance subject to normal Python ``str`` to ``unicode`` coercion rules instead of being escaped to an ASCII ``str``. If ``check_circular`` is false, then the circular reference check for container types will be skipped and a circular reference will result in an ``OverflowError`` (or worse). If ``allow_nan`` is false, then it will be a ``ValueError`` to serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``). If ``indent`` is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. ``None`` is the most compact representation. If ``separators`` is an ``(item_separator, dict_separator)`` tuple then it will be used instead of the default ``(', ', ': ')`` separators. ``(',', ':')`` is the most compact JSON representation. ``encoding`` is the character encoding for str instances, default is UTF-8. ``default(obj)`` is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError. To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the ``.default()`` method to serialize additional types), specify it with the ``cls`` kwarg; otherwise ``JSONEncoder`` is used. """ # cached encoder if (not skipkeys and ensure_ascii and check_circular and allow_nan and cls is None and indent is None and separators is None and encoding == 'utf-8' and default is None and not kw): return _default_encoder.encode(obj) if cls is None: cls = JSONEncoder return cls( skipkeys=skipkeys, ensure_ascii=ensure_ascii, check_circular=check_circular, allow_nan=allow_nan, indent=indent, separators=separators, encoding=encoding, default=default, **kw).encode(obj) _default_decoder = JSONDecoder(encoding=None, object_hook=None, object_pairs_hook=None) def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw): """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing a JSON document) to a Python object. If the contents of ``fp`` is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1), then an appropriate ``encoding`` name must be specified. Encodings that are not ASCII based (such as UCS-2) are not allowed, and should be wrapped with ``codecs.getreader(fp)(encoding)``, or simply decoded to a ``unicode`` object and passed to ``loads()`` ``object_hook`` is an optional function that will be called with the result of any object literal decode (a ``dict``). The return value of ``object_hook`` will be used instead of the ``dict``. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting). ``object_pairs_hook`` is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of ``object_pairs_hook`` will be used instead of the ``dict``. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority. To use a custom ``JSONDecoder`` subclass, specify it with the ``cls`` kwarg; otherwise ``JSONDecoder`` is used. """ return loads(fp.read(), encoding=encoding, cls=cls, object_hook=object_hook, parse_float=parse_float, parse_int=parse_int, parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw): """Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) to a Python object. If ``s`` is a ``str`` instance and is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1) then an appropriate ``encoding`` name must be specified. Encodings that are not ASCII based (such as UCS-2) are not allowed and should be decoded to ``unicode`` first. ``object_hook`` is an optional function that will be called with the result of any object literal decode (a ``dict``). The return value of ``object_hook`` will be used instead of the ``dict``. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting). ``object_pairs_hook`` is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of ``object_pairs_hook`` will be used instead of the ``dict``. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If ``object_hook`` is also defined, the ``object_pairs_hook`` takes priority. ``parse_float``, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal). ``parse_int``, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float). ``parse_constant``, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN, null, true, false. This can be used to raise an exception if invalid JSON numbers are encountered. To use a custom ``JSONDecoder`` subclass, specify it with the ``cls`` kwarg; otherwise ``JSONDecoder`` is used. """ if (cls is None and encoding is None and object_hook is None and parse_int is None and parse_float is None and parse_constant is None and object_pairs_hook is None and not kw): return _default_decoder.decode(s) if cls is None: cls = JSONDecoder if object_hook is not None: kw['object_hook'] = object_hook if object_pairs_hook is not None: kw['object_pairs_hook'] = object_pairs_hook if parse_float is not None: kw['parse_float'] = parse_float if parse_int is not None: kw['parse_int'] = parse_int if parse_constant is not None: kw['parse_constant'] = parse_constant return cls(encoding=encoding, **kw).decode(s)
mit
[ 82, 624, 6243, 334, 21986, 6935, 2832, 425, 9, 665, 1014, 921, 1001, 14, 1308, 30, 365, 282, 10026, 402, 199, 21986, 6302, 334, 4220, 2054, 13, 14820, 650, 6883, 325, 1671, 9, 1202, 465, 282, 10540, 3463, 666, 199, 1058, 1461, 1475, 14, 199, 199, 26, 1494, 1705, 1001, 64, 444, 10553, 376, 3261, 21450, 1638, 285, 370, 4390, 402, 314, 4465, 3555, 199, 26, 1494, 1705, 18376, 64, 436, 520, 1494, 1705, 8092, 64, 4621, 14, 2779, 365, 314, 21815, 1183, 26391, 199, 1023, 402, 314, 520, 1494, 1705, 1001, 64, 3555, 10470, 315, 2018, 499, 14, 22, 12, 1325, 11075, 83, 199, 15390, 543, 2018, 499, 14, 20, 436, 2018, 499, 14, 21, 436, 334, 19767, 9, 965, 199, 1037, 14266, 10238, 19396, 867, 7441, 12, 2755, 1928, 1808, 314, 2716, 445, 199, 3435, 367, 8112, 15203, 14, 199, 199, 7630, 5678, 2018, 909, 394, 7081, 1500, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 4180, 2941, 1421, 297, 791, 1700, 356, 661, 6185, 297, 488, 12, 413, 14, 16, 12, 499, 6769, 566, 272, 283, 905, 1421, 401, 2420, 1700, 582, 2097, 6185, 401, 2973, 12, 413, 14, 16, 12, 499, 9420, 6616, 272, 1306, 870, 2022, 14, 4180, 480, 4451, 1421, 60, 1700, 531, 272, 30768, 1421, 60, 1700, 2, 272, 1306, 870, 2022, 14, 4180, 8, 85, 1154, 85, 4321, 358, 272, 1867, 85, 4321, 2, 272, 1306, 870, 2022, 14, 4180, 11671, 358, 272, 9926, 2, 272, 1306, 870, 2022, 14, 4180, 6333, 67, 582, 378, 12, 298, 66, 582, 378, 12, 298, 65, 582, 378, 1386, 4069, 63, 1612, 29, 549, 9, 272, 2420, 65, 582, 378, 12, 298, 66, 582, 378, 12, 298, 67, 582, 378, 93, 272, 1306, 687, 5228, 492, 5228, 272, 1306, 5890, 275, 5228, 342, 272, 1306, 2022, 14, 2724, 2941, 12076, 3261, 995, 5890, 9, 272, 1306, 5890, 14, 7150, 342, 272, 283, 905, 12076, 3261, 937, 7, 199, 199, 2404, 2442, 2644, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 4180, 779, 17, 12, 18, 12, 19, 12, 1445, 20, 356, 959, 12, 283, 22, 356, 1520, 22140, 17658, 2687, 23324, 356, 1333, 272, 6730, 17, 12, 18, 12, 19, 12, 6641, 20, 582, 21, 4589, 22, 582, 23, 93, 6616, 199, 199, 27153, 16116, 447, 339, 1306, 492, 2022, 272, 1306, 308, 275, 2022, 14, 4180, 3252, 20, 356, 959, 12, 283, 22, 356, 1520, 1386, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 9, 272, 1306, 870, 1557, 78, 1370, 904, 779, 76, 14, 6735, 342, 367, 634, 315, 221, 308, 14, 7644, 9383, 272, 469, 267, 298, 20, 582, 959, 12, 267, 298, 22, 582, 1520, 272, 789, 199, 199, 872, 1523, 4840, 447, 339, 1306, 492, 2022, 272, 1306, 1559, 275, 359, 85, 7, 1421, 297, 469, 85, 7, 1700, 356, 359, 85, 7, 6185, 297, 488, 12, 413, 14, 16, 12, 499, 9420, 61, 272, 1306, 2022, 14, 3640, 360, 905, 1421, 401, 2420, 1700, 582, 905, 6185, 401, 2973, 12, 413, 14, 16, 12, 499, 9420, 10374, 508, 1559, 272, 715, 272, 1306, 2022, 14, 3640, 14088, 15022, 1421, 1103, 1700, 9008, 508, 399, 4065, 1421, 60, 88, 2036, 285, 7, 272, 715, 272, 1306, 687, 5228, 492, 5228, 272, 1306, 5890, 275, 5228, 360, 905, 12076, 3261, 937, 358, 272, 1306, 2022, 14, 912, 8, 2308, 2788, 16, 61, 508, 283, 12076, 3261, 7, 272, 715, 199, 199, 12246, 9147, 4840, 909, 15952, 447, 339, 1306, 492, 2022, 272, 1306, 347, 465, 63, 5254, 8, 20660, 304, 272, 2263, 258, 340, 2560, 5254, 12217, 315, 16354, 26, 272, 2263, 260, 372, 6114, 8, 20660, 459, 3093, 995, 16354, 459, 14688, 1105, 272, 2263, 258, 372, 16354, 272, 2263, 272, 1306, 2022, 14, 3640, 360, 6641, 363, 5254, 5727, 2549, 12, 298, 3093, 582, 413, 12, 298, 14688, 582, 499, 7293, 272, 2263, 258, 909, 63, 3664, 29, 305, 63, 5254, 9, 272, 334, 17, 11, 18, 74, 9, 272, 1306, 687, 6107, 492, 6345, 272, 1306, 2022, 14, 3640, 360, 17, 14, 17, 297, 2198, 63, 1609, 29, 6745, 9, 508, 6345, 360, 17, 14, 17, 358, 272, 715, 199, 199, 12246, 9147, 4840, 909, 2644, 447, 339, 1306, 492, 2022, 272, 1306, 347, 3752, 63, 5254, 8, 1113, 304, 272, 2263, 258, 340, 1228, 8, 1113, 12, 6114, 304, 272, 2263, 260, 372, 359, 1113, 14, 3093, 12, 1559, 14, 14688, 61, 272, 2263, 258, 746, 3146, 8, 2722, 8, 79, 9, 435, 298, 365, 440, 4840, 31244, 531, 272, 2263, 272, 1306, 2022, 14, 4180, 8, 18, 435, 413, 74, 12, 849, 29, 2143, 63, 5254, 9, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 272, 1306, 2022, 14, 23069, 8, 885, 29, 2143, 63, 5254, 680, 2143, 8, 18, 435, 413, 74, 9, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 272, 1306, 6522, 904, 8, 1001, 14, 23069, 8, 885, 29, 2143, 63, 5254, 680, 27895, 8, 18, 435, 413, 74, 430, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 421, 199, 10369, 2022, 14, 3557, 687, 314, 5218, 370, 4107, 436, 7268, 13, 1361, 447, 339, 2672, 11343, 17137, 1001, 5122, 1113, 3570, 7, 1204, 2366, 446, 77, 2022, 14, 3557, 272, 469, 267, 298, 1001, 582, 298, 1113, 2, 272, 789, 272, 2672, 11343, 5041, 413, 14, 18, 26, 19, 14, 20, 6834, 1204, 2366, 446, 77, 2022, 14, 3557, 272, 15100, 316, 3324, 536, 26, 1004, 413, 2763, 499, 334, 1560, 499, 9, 199, 624, 199, 363, 1023, 363, 275, 283, 18, 14, 16, 14, 25, 7, 199, 363, 452, 363, 275, 359, 272, 283, 2724, 297, 283, 4180, 297, 283, 912, 297, 283, 3640, 297, 272, 283, 6243, 8326, 297, 283, 23069, 297, 199, 61, 199, 199, 363, 2502, 363, 275, 283, 22593, 31045, 555, 317, 475, 665, 7913, 32, 264, 328, 433, 14, 957, 3524, 199, 199, 504, 1275, 8813, 492, 4840, 8326, 199, 504, 1275, 9347, 492, 4840, 6679, 199, 199, 63, 885, 63, 9347, 275, 4840, 6679, 8, 272, 3372, 1612, 29, 797, 12, 272, 4868, 63, 4371, 29, 549, 12, 272 ]
[ 624, 6243, 334, 21986, 6935, 2832, 425, 9, 665, 1014, 921, 1001, 14, 1308, 30, 365, 282, 10026, 402, 199, 21986, 6302, 334, 4220, 2054, 13, 14820, 650, 6883, 325, 1671, 9, 1202, 465, 282, 10540, 3463, 666, 199, 1058, 1461, 1475, 14, 199, 199, 26, 1494, 1705, 1001, 64, 444, 10553, 376, 3261, 21450, 1638, 285, 370, 4390, 402, 314, 4465, 3555, 199, 26, 1494, 1705, 18376, 64, 436, 520, 1494, 1705, 8092, 64, 4621, 14, 2779, 365, 314, 21815, 1183, 26391, 199, 1023, 402, 314, 520, 1494, 1705, 1001, 64, 3555, 10470, 315, 2018, 499, 14, 22, 12, 1325, 11075, 83, 199, 15390, 543, 2018, 499, 14, 20, 436, 2018, 499, 14, 21, 436, 334, 19767, 9, 965, 199, 1037, 14266, 10238, 19396, 867, 7441, 12, 2755, 1928, 1808, 314, 2716, 445, 199, 3435, 367, 8112, 15203, 14, 199, 199, 7630, 5678, 2018, 909, 394, 7081, 1500, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 4180, 2941, 1421, 297, 791, 1700, 356, 661, 6185, 297, 488, 12, 413, 14, 16, 12, 499, 6769, 566, 272, 283, 905, 1421, 401, 2420, 1700, 582, 2097, 6185, 401, 2973, 12, 413, 14, 16, 12, 499, 9420, 6616, 272, 1306, 870, 2022, 14, 4180, 480, 4451, 1421, 60, 1700, 531, 272, 30768, 1421, 60, 1700, 2, 272, 1306, 870, 2022, 14, 4180, 8, 85, 1154, 85, 4321, 358, 272, 1867, 85, 4321, 2, 272, 1306, 870, 2022, 14, 4180, 11671, 358, 272, 9926, 2, 272, 1306, 870, 2022, 14, 4180, 6333, 67, 582, 378, 12, 298, 66, 582, 378, 12, 298, 65, 582, 378, 1386, 4069, 63, 1612, 29, 549, 9, 272, 2420, 65, 582, 378, 12, 298, 66, 582, 378, 12, 298, 67, 582, 378, 93, 272, 1306, 687, 5228, 492, 5228, 272, 1306, 5890, 275, 5228, 342, 272, 1306, 2022, 14, 2724, 2941, 12076, 3261, 995, 5890, 9, 272, 1306, 5890, 14, 7150, 342, 272, 283, 905, 12076, 3261, 937, 7, 199, 199, 2404, 2442, 2644, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 4180, 779, 17, 12, 18, 12, 19, 12, 1445, 20, 356, 959, 12, 283, 22, 356, 1520, 22140, 17658, 2687, 23324, 356, 1333, 272, 6730, 17, 12, 18, 12, 19, 12, 6641, 20, 582, 21, 4589, 22, 582, 23, 93, 6616, 199, 199, 27153, 16116, 447, 339, 1306, 492, 2022, 272, 1306, 308, 275, 2022, 14, 4180, 3252, 20, 356, 959, 12, 283, 22, 356, 1520, 1386, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 9, 272, 1306, 870, 1557, 78, 1370, 904, 779, 76, 14, 6735, 342, 367, 634, 315, 221, 308, 14, 7644, 9383, 272, 469, 267, 298, 20, 582, 959, 12, 267, 298, 22, 582, 1520, 272, 789, 199, 199, 872, 1523, 4840, 447, 339, 1306, 492, 2022, 272, 1306, 1559, 275, 359, 85, 7, 1421, 297, 469, 85, 7, 1700, 356, 359, 85, 7, 6185, 297, 488, 12, 413, 14, 16, 12, 499, 9420, 61, 272, 1306, 2022, 14, 3640, 360, 905, 1421, 401, 2420, 1700, 582, 905, 6185, 401, 2973, 12, 413, 14, 16, 12, 499, 9420, 10374, 508, 1559, 272, 715, 272, 1306, 2022, 14, 3640, 14088, 15022, 1421, 1103, 1700, 9008, 508, 399, 4065, 1421, 60, 88, 2036, 285, 7, 272, 715, 272, 1306, 687, 5228, 492, 5228, 272, 1306, 5890, 275, 5228, 360, 905, 12076, 3261, 937, 358, 272, 1306, 2022, 14, 912, 8, 2308, 2788, 16, 61, 508, 283, 12076, 3261, 7, 272, 715, 199, 199, 12246, 9147, 4840, 909, 15952, 447, 339, 1306, 492, 2022, 272, 1306, 347, 465, 63, 5254, 8, 20660, 304, 272, 2263, 258, 340, 2560, 5254, 12217, 315, 16354, 26, 272, 2263, 260, 372, 6114, 8, 20660, 459, 3093, 995, 16354, 459, 14688, 1105, 272, 2263, 258, 372, 16354, 272, 2263, 272, 1306, 2022, 14, 3640, 360, 6641, 363, 5254, 5727, 2549, 12, 298, 3093, 582, 413, 12, 298, 14688, 582, 499, 7293, 272, 2263, 258, 909, 63, 3664, 29, 305, 63, 5254, 9, 272, 334, 17, 11, 18, 74, 9, 272, 1306, 687, 6107, 492, 6345, 272, 1306, 2022, 14, 3640, 360, 17, 14, 17, 297, 2198, 63, 1609, 29, 6745, 9, 508, 6345, 360, 17, 14, 17, 358, 272, 715, 199, 199, 12246, 9147, 4840, 909, 2644, 447, 339, 1306, 492, 2022, 272, 1306, 347, 3752, 63, 5254, 8, 1113, 304, 272, 2263, 258, 340, 1228, 8, 1113, 12, 6114, 304, 272, 2263, 260, 372, 359, 1113, 14, 3093, 12, 1559, 14, 14688, 61, 272, 2263, 258, 746, 3146, 8, 2722, 8, 79, 9, 435, 298, 365, 440, 4840, 31244, 531, 272, 2263, 272, 1306, 2022, 14, 4180, 8, 18, 435, 413, 74, 12, 849, 29, 2143, 63, 5254, 9, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 272, 1306, 2022, 14, 23069, 8, 885, 29, 2143, 63, 5254, 680, 2143, 8, 18, 435, 413, 74, 9, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 272, 1306, 6522, 904, 8, 1001, 14, 23069, 8, 885, 29, 2143, 63, 5254, 680, 27895, 8, 18, 435, 413, 74, 430, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 421, 199, 10369, 2022, 14, 3557, 687, 314, 5218, 370, 4107, 436, 7268, 13, 1361, 447, 339, 2672, 11343, 17137, 1001, 5122, 1113, 3570, 7, 1204, 2366, 446, 77, 2022, 14, 3557, 272, 469, 267, 298, 1001, 582, 298, 1113, 2, 272, 789, 272, 2672, 11343, 5041, 413, 14, 18, 26, 19, 14, 20, 6834, 1204, 2366, 446, 77, 2022, 14, 3557, 272, 15100, 316, 3324, 536, 26, 1004, 413, 2763, 499, 334, 1560, 499, 9, 199, 624, 199, 363, 1023, 363, 275, 283, 18, 14, 16, 14, 25, 7, 199, 363, 452, 363, 275, 359, 272, 283, 2724, 297, 283, 4180, 297, 283, 912, 297, 283, 3640, 297, 272, 283, 6243, 8326, 297, 283, 23069, 297, 199, 61, 199, 199, 363, 2502, 363, 275, 283, 22593, 31045, 555, 317, 475, 665, 7913, 32, 264, 328, 433, 14, 957, 3524, 199, 199, 504, 1275, 8813, 492, 4840, 8326, 199, 504, 1275, 9347, 492, 4840, 6679, 199, 199, 63, 885, 63, 9347, 275, 4840, 6679, 8, 272, 3372, 1612, 29, 797, 12, 272, 4868, 63, 4371, 29, 549, 12, 272, 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, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
knabar/openmicroscopy
components/tools/OmeroPy/src/omero/install/versions.py
15
3456
#!/usr/bin/env python # -*- coding: utf-8 -*- # # $Id$ # # Copyright 2009 Glencoe Software, Inc. All rights reserved. # Use is subject to license terms supplied in LICENSE.txt # # Version comparison functionality import re import logging # Regex copied from ome.api.IConfig.VERSION_REGEX REGEX = re.compile("^.*?[-]?(\\d+[.]\\d+([.]\\d+)?)[-]?.*?$") LOG = logging.getLogger("omero.version") def needs_upgrade(client_version, server_version, verbose=False): """ Tests whether the client version is behind the server version. For example:: import omero from omero_version import omero_version as client_version client = omero.client() session = client.createSession() config = session.getConfigService() server_version = config.getVersion() upgrade = needs_upgrade(client_version, server_version) if upgrade: # Inform client Alternatively, from the command-line:: ./versions.py --quiet 4.1.0 4.2.0-DEV || echo upgrade """ try: client_cleaned = REGEX.match(client_version).group(1) client_split = client_cleaned.split(".") server_cleaned = REGEX.match(server_version).group(1) server_split = server_cleaned.split(".") rv = (client_split < server_split) if verbose: LOG.info("Client=%20s (%-5s) v. Server=%20s (%-5s) Upgrade? %s", client_version, ".".join(client_split), server_version, ".".join(server_split), rv) return rv except: LOG.warn("Bad versions: client=%s server=%s", client_version, server_version, exc_info=1) return True if __name__ == "__main__": import sys args = list(sys.argv[1:]) if "--quiet" in args: args.remove("--quiet") logging.basicConfig(level=logging.WARN) else: logging.basicConfig(level=logging.DEBUG) if "--test" in args: print "="*10, "Test", "="*72 needs_upgrade("4.0", "4.1.1", True) needs_upgrade("4.1", "4.1.1", True) needs_upgrade("4.1.0", "4.1.1", True) needs_upgrade("4.1.0", "4.1.1-Dev", True) needs_upgrade("4.1.0-Dev", "4.1.1", True) needs_upgrade("4.1.1", "4.1.1", True) needs_upgrade("Beta-4.1", "4.1.1", True) needs_upgrade("Beta-4.1.0", "4.1.1", True) needs_upgrade("Beta-4.1.1", "4.1.1", True) needs_upgrade("4.1.1", "Beta-4.1.1", True) needs_upgrade("Beta-4.1.0", "Beta-4.1.1", True) needs_upgrade("4.1.1-Foo", "4.1.1", True) needs_upgrade("4.1.1-Foo", "4.1.1-Dev", True) needs_upgrade("4.1.1-Foo", "4.1.2-Dev", True) needs_upgrade("4.1.1-Foo", "4.2.0-Dev", True) needs_upgrade("4.1.1-Foo", "4.2", True) needs_upgrade("4.1.1-Foo", "5.0", True) needs_upgrade("v.4.1.1-Foo", "5.0", True) # Additions post git-describe needs_upgrade("v.4.1.1-Foo", "5.0", True) needs_upgrade("v4.1.1-Foo", "5.0", True) needs_upgrade("Beta-v4.1.1-Foo", "5.0", True) needs_upgrade("A1-4.1.1-Foo", "5.0", True) needs_upgrade("A1-v4.1.1-Foo", "5.0", True) else: try: rv = int(needs_upgrade(args[0], args[1], True)) except: rv = 2 print """ %s [--quiet] client_version server_version or: %s [--quiet] --test """ % (sys.argv[0], sys.argv[0]) sys.exit(rv)
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 1898, 8937, 598, 552, 331, 69, 2290, 12, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 365, 5420, 370, 4190, 2895, 6841, 315, 5113, 14, 2424, 199, 3, 199, 3, 3394, 9132, 9330, 199, 199, 646, 295, 199, 646, 2050, 199, 199, 3, 12939, 8876, 687, 17959, 14, 1246, 14, 41, 2028, 14, 4612, 63, 10710, 199, 10710, 275, 295, 14, 2014, 18523, 6697, 1988, 11843, 27910, 68, 21324, 19784, 1103, 68, 11, 779, 19784, 1103, 68, 19544, 15786, 11843, 6697, 22550, 199, 4947, 275, 2050, 14, 5572, 480, 1377, 293, 14, 1023, 531, 421, 199, 318, 4839, 63, 9375, 8, 1258, 63, 1023, 12, 1654, 63, 1023, 12, 3376, 29, 797, 304, 272, 408, 272, 6496, 3775, 314, 1890, 1015, 365, 22172, 314, 1654, 1015, 14, 272, 2104, 2893, 447, 398, 492, 27122, 267, 687, 27122, 63, 1023, 492, 27122, 63, 1023, 465, 1890, 63, 1023, 398, 1890, 275, 27122, 14, 1258, 342, 267, 2351, 275, 1890, 14, 981, 4434, 342, 267, 1101, 275, 2351, 14, 27988, 3167, 342, 267, 1654, 63, 1023, 275, 1101, 14, 362, 3353, 342, 398, 10754, 275, 4839, 63, 9375, 8, 1258, 63, 1023, 12, 1654, 63, 1023, 9, 267, 340, 10754, 26, 1779, 327, 1010, 964, 1890, 339, 26776, 12, 687, 314, 1414, 13, 604, 447, 398, 16605, 6234, 14, 647, 1553, 10243, 841, 14, 17, 14, 16, 841, 14, 18, 14, 16, 13, 13260, 12208, 11343, 10754, 339, 408, 272, 862, 26, 267, 1890, 63, 8275, 275, 14142, 1438, 14, 1431, 8, 1258, 63, 1023, 680, 923, 8, 17, 9, 267, 1890, 63, 1294, 275, 1890, 63, 8275, 14, 1294, 15857, 398, 1654, 63, 8275, 275, 14142, 1438, 14, 1431, 8, 1000, 63, 1023, 680, 923, 8, 17, 9, 267, 1654, 63, 1294, 275, 1654, 63, 8275, 14, 1294, 15857, 398, 4336, 275, 334, 1258, 63, 1294, 665, 1654, 63, 1294, 9, 267, 340, 3376, 26, 288, 5051, 14, 815, 480, 3041, 2458, 1165, 83, 4366, 13, 21, 83, 9, 221, 373, 14, 221, 7146, 2458, 1165, 83, 4366, 13, 21, 83, 9, 4949, 4523, 31, 450, 83, 401, 2151, 1890, 63, 1023, 12, 32443, 904, 8, 1258, 63, 1294, 395, 2151, 1654, 63, 1023, 12, 32443, 904, 8, 1000, 63, 1294, 395, 4336, 9, 267, 372, 4336, 339, 871, 26, 267, 5051, 14, 4050, 480, 5725, 5459, 26, 1890, 2458, 83, 1654, 2458, 83, 401, 1890, 63, 1023, 12, 326, 1654, 63, 1023, 12, 3178, 63, 815, 29, 17, 9, 267, 372, 715, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 492, 984, 272, 1249, 275, 769, 8, 1274, 14, 3020, 59, 17, 5728, 339, 340, 4320, 10243, 2, 315, 1249, 26, 267, 1249, 14, 2168, 6739, 10243, 531, 267, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 17449, 9, 272, 587, 26, 267, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 339, 340, 4320, 396, 2, 315, 1249, 26, 267, 870, 22250, 10, 709, 12, 298, 774, 401, 22250, 10, 2819, 267, 4839, 63, 9375, 480, 20, 14, 16, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 16, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 16, 401, 298, 20, 14, 17, 14, 17, 13, 12680, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 16, 13, 12680, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 20, 14, 17, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 20, 14, 17, 14, 16, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 20, 14, 17, 14, 17, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 401, 298, 21732, 13, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 20, 14, 17, 14, 16, 401, 298, 21732, 13, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 17, 14, 17, 13, 12680, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 17, 14, 18, 13, 12680, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 18, 14, 16, 13, 12680, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 18, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 86, 14, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 327, 4431, 3138, 2963, 6135, 13, 11935, 267, 4839, 63, 9375, 480, 86, 14, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 86, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 86, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 33, 17, 13, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 33, 17, 13, 86, 20, 14, 17, 14, 17, 13, 5686, 401 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 2672, 1304, 4, 199, 3, 199, 3, 1898, 8937, 598, 552, 331, 69, 2290, 12, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 365, 5420, 370, 4190, 2895, 6841, 315, 5113, 14, 2424, 199, 3, 199, 3, 3394, 9132, 9330, 199, 199, 646, 295, 199, 646, 2050, 199, 199, 3, 12939, 8876, 687, 17959, 14, 1246, 14, 41, 2028, 14, 4612, 63, 10710, 199, 10710, 275, 295, 14, 2014, 18523, 6697, 1988, 11843, 27910, 68, 21324, 19784, 1103, 68, 11, 779, 19784, 1103, 68, 19544, 15786, 11843, 6697, 22550, 199, 4947, 275, 2050, 14, 5572, 480, 1377, 293, 14, 1023, 531, 421, 199, 318, 4839, 63, 9375, 8, 1258, 63, 1023, 12, 1654, 63, 1023, 12, 3376, 29, 797, 304, 272, 408, 272, 6496, 3775, 314, 1890, 1015, 365, 22172, 314, 1654, 1015, 14, 272, 2104, 2893, 447, 398, 492, 27122, 267, 687, 27122, 63, 1023, 492, 27122, 63, 1023, 465, 1890, 63, 1023, 398, 1890, 275, 27122, 14, 1258, 342, 267, 2351, 275, 1890, 14, 981, 4434, 342, 267, 1101, 275, 2351, 14, 27988, 3167, 342, 267, 1654, 63, 1023, 275, 1101, 14, 362, 3353, 342, 398, 10754, 275, 4839, 63, 9375, 8, 1258, 63, 1023, 12, 1654, 63, 1023, 9, 267, 340, 10754, 26, 1779, 327, 1010, 964, 1890, 339, 26776, 12, 687, 314, 1414, 13, 604, 447, 398, 16605, 6234, 14, 647, 1553, 10243, 841, 14, 17, 14, 16, 841, 14, 18, 14, 16, 13, 13260, 12208, 11343, 10754, 339, 408, 272, 862, 26, 267, 1890, 63, 8275, 275, 14142, 1438, 14, 1431, 8, 1258, 63, 1023, 680, 923, 8, 17, 9, 267, 1890, 63, 1294, 275, 1890, 63, 8275, 14, 1294, 15857, 398, 1654, 63, 8275, 275, 14142, 1438, 14, 1431, 8, 1000, 63, 1023, 680, 923, 8, 17, 9, 267, 1654, 63, 1294, 275, 1654, 63, 8275, 14, 1294, 15857, 398, 4336, 275, 334, 1258, 63, 1294, 665, 1654, 63, 1294, 9, 267, 340, 3376, 26, 288, 5051, 14, 815, 480, 3041, 2458, 1165, 83, 4366, 13, 21, 83, 9, 221, 373, 14, 221, 7146, 2458, 1165, 83, 4366, 13, 21, 83, 9, 4949, 4523, 31, 450, 83, 401, 2151, 1890, 63, 1023, 12, 32443, 904, 8, 1258, 63, 1294, 395, 2151, 1654, 63, 1023, 12, 32443, 904, 8, 1000, 63, 1294, 395, 4336, 9, 267, 372, 4336, 339, 871, 26, 267, 5051, 14, 4050, 480, 5725, 5459, 26, 1890, 2458, 83, 1654, 2458, 83, 401, 1890, 63, 1023, 12, 326, 1654, 63, 1023, 12, 3178, 63, 815, 29, 17, 9, 267, 372, 715, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 339, 492, 984, 272, 1249, 275, 769, 8, 1274, 14, 3020, 59, 17, 5728, 339, 340, 4320, 10243, 2, 315, 1249, 26, 267, 1249, 14, 2168, 6739, 10243, 531, 267, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 17449, 9, 272, 587, 26, 267, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 339, 340, 4320, 396, 2, 315, 1249, 26, 267, 870, 22250, 10, 709, 12, 298, 774, 401, 22250, 10, 2819, 267, 4839, 63, 9375, 480, 20, 14, 16, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 16, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 16, 401, 298, 20, 14, 17, 14, 17, 13, 12680, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 16, 13, 12680, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 20, 14, 17, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 20, 14, 17, 14, 16, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 20, 14, 17, 14, 17, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 401, 298, 21732, 13, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 20, 14, 17, 14, 16, 401, 298, 21732, 13, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 17, 14, 17, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 17, 14, 17, 13, 12680, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 17, 14, 18, 13, 12680, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 18, 14, 16, 13, 12680, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 20, 14, 18, 401, 715, 9, 267, 4839, 63, 9375, 480, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 86, 14, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 327, 4431, 3138, 2963, 6135, 13, 11935, 267, 4839, 63, 9375, 480, 86, 14, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 86, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 21732, 13, 86, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 33, 17, 13, 20, 14, 17, 14, 17, 13, 5686, 401, 298, 21, 14, 16, 401, 715, 9, 267, 4839, 63, 9375, 480, 33, 17, 13, 86, 20, 14, 17, 14, 17, 13, 5686, 401, 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, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tobspr/panda3d
direct/src/p3d/ppatcher.py
10
3172
#! /usr/bin/env python usageText = """ This script generates the patches required to support incremental download of Panda3D packages. It can be run as a post-process on a directory hierarchy created by ppackage; it will examine the directory hierarchy, and create any patches that appear to be missing. You may run ppackage on the same directory hierarchy as many times as you like, without creating patches. You may then download and test the resulting files--users connecting to the tree without fresh patches will be forced to download the entire file, instead of making an incremental download, but the entire process will work otherwise. When you are satisfied that all of the files are ready to be released, you may run ppackage on the directory hierarchy to generate the required patches. Generating the patches just before final release is a good idea to limit the number of trivially small patches that are created. Each time this script is run, a patch is created from the previous version, and these patches daisy-chain together to define a complete update sequence. If you run this script on internal releases, you will generate a long chain of small patches that your users must download; this is pointless if there is no possibility of anyone having downloaded one of the intervening versions. You can also generate patches with the -p option to ppackage, but that only generates patches for the specific packages built by that invocation of ppackage. If you use the ppatcher script instead, it will generate patches for all packages (or the set of packages that you name specifically). This script is actually a wrapper around Panda's PatchMaker.py. Usage: %(prog)s [opts] [packageName1 .. packageNameN] Parameters: packageName1 .. packageNameN Specify the names of the package(s) you wish to generate patches for. This allows you to build patches for only a subset of the packages found in the tree. If you omit these parameters, patches are built for all packages that require them. Options: -i install_dir The full path to the install directory. This should be the same directory named by the -i parameter to ppackage. -h Display this help """ import sys import getopt import os from direct.p3d.PatchMaker import PatchMaker from panda3d.core import Filename def usage(code, msg = ''): sys.stderr.write(usageText % {'prog' : os.path.split(sys.argv[0])[1]}) sys.stderr.write(msg + '\n') sys.exit(code) try: opts, args = getopt.getopt(sys.argv[1:], 'i:h') except getopt.error as msg: usage(1, msg) installDir = None for opt, arg in opts: if opt == '-i': installDir = Filename.fromOsSpecific(arg) elif opt == '-h': usage(0) else: print('illegal option: ' + arg) sys.exit(1) packageNames = args if not installDir: installDir = Filename('install') if not packageNames: # "None" means all packages. packageNames = None pm = PatchMaker(installDir) pm.buildPatches(packageNames = packageNames) # An explicit call to exit() is required to exit the program, when # this module is packaged in a p3d file. sys.exit(0)
bsd-3-clause
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3807, 1872, 275, 408, 199, 199, 2765, 2884, 12821, 314, 12385, 1415, 370, 2291, 16316, 199, 4249, 402, 510, 18328, 19, 36, 6117, 14, 221, 2779, 883, 506, 1255, 465, 282, 2963, 13, 1412, 641, 282, 199, 3619, 14446, 2737, 701, 299, 2491, 27, 652, 911, 31758, 314, 2082, 199, 14861, 12, 436, 1218, 1263, 12385, 626, 7468, 370, 506, 4124, 14, 199, 199, 5556, 1443, 1255, 299, 2491, 641, 314, 2011, 2082, 14446, 465, 5002, 5431, 465, 199, 13297, 2839, 12, 1928, 6425, 12385, 14, 221, 2047, 1443, 2066, 5235, 436, 511, 199, 1589, 9183, 1584, 306, 3707, 18170, 370, 314, 3123, 1928, 17480, 199, 11350, 911, 506, 19565, 370, 5235, 314, 8039, 570, 12, 3140, 402, 10663, 199, 290, 16316, 5235, 12, 1325, 314, 8039, 2112, 911, 1736, 4257, 14, 199, 11423, 1265, 787, 23233, 626, 1006, 402, 314, 1584, 787, 10144, 370, 506, 14286, 12, 199, 13297, 1443, 1255, 299, 2491, 641, 314, 2082, 14446, 370, 3550, 314, 199, 2427, 12385, 14, 199, 199, 29244, 314, 12385, 2951, 2544, 4242, 4683, 365, 282, 6954, 16819, 370, 199, 3097, 314, 1329, 402, 3229, 433, 1183, 7425, 12385, 626, 787, 2737, 14, 221, 7048, 199, 521, 642, 2884, 365, 1255, 12, 282, 3371, 365, 2737, 687, 314, 4136, 1015, 12, 199, 460, 3520, 12385, 12927, 19765, 13, 4429, 10451, 370, 5627, 282, 4890, 1678, 199, 4041, 14, 221, 982, 1265, 1255, 642, 2884, 641, 5007, 19015, 12, 1265, 911, 199, 4208, 282, 1846, 6036, 402, 7425, 12385, 626, 2195, 4390, 1471, 5235, 27, 199, 3749, 365, 2376, 2003, 340, 2337, 365, 949, 31077, 402, 29165, 9445, 199, 19385, 1373, 402, 314, 1640, 1856, 316, 5459, 14, 199, 199, 5556, 883, 2597, 3550, 12385, 543, 314, 446, 80, 945, 370, 299, 2491, 12, 1325, 626, 199, 2118, 12821, 12385, 367, 314, 2488, 6117, 6137, 701, 626, 199, 30158, 402, 299, 2491, 14, 221, 982, 1265, 675, 314, 299, 11238, 2884, 3140, 12, 652, 199, 14117, 3550, 12385, 367, 1006, 6117, 334, 269, 314, 663, 402, 6117, 626, 199, 13297, 536, 22543, 680, 199, 199, 2765, 2884, 365, 5965, 282, 4975, 6818, 510, 18328, 1159, 19292, 23560, 14, 647, 14, 199, 199, 7692, 26, 819, 2818, 6595, 9, 83, 359, 3291, 61, 359, 2491, 985, 17, 2508, 2559, 985, 46, 61, 199, 199, 5976, 26, 819, 2559, 985, 17, 2508, 2559, 985, 46, 272, 13327, 314, 1561, 402, 314, 2559, 8, 83, 9, 1265, 13809, 370, 3550, 12385, 272, 367, 14, 221, 961, 6127, 1265, 370, 1900, 12385, 367, 1454, 282, 10026, 402, 314, 272, 6117, 1911, 315, 314, 3123, 14, 221, 982, 1265, 19413, 3520, 2633, 12, 12385, 272, 787, 6137, 367, 1006, 6117, 626, 4409, 3062, 14, 199, 199, 4558, 26, 819, 446, 73, 3907, 63, 694, 1362, 710, 2615, 931, 370, 314, 3907, 2082, 14, 221, 961, 1077, 506, 314, 2011, 1362, 2082, 4310, 701, 314, 446, 73, 2725, 370, 299, 2491, 14, 819, 446, 72, 1362, 12175, 642, 1720, 199, 199, 624, 199, 199, 646, 984, 199, 646, 12733, 199, 646, 747, 199, 199, 504, 4125, 14, 80, 19, 68, 14, 11173, 23560, 492, 19292, 23560, 199, 504, 299, 18328, 19, 68, 14, 1018, 492, 31167, 199, 199, 318, 4503, 8, 600, 12, 1499, 275, 21019, 272, 984, 14, 3083, 14, 952, 8, 3807, 1872, 450, 791, 6595, 7, 520, 747, 14, 515, 14, 1294, 8, 1274, 14, 3020, 59, 16, 11057, 17, 13412, 272, 984, 14, 3083, 14, 952, 8, 1328, 435, 1557, 78, 358, 272, 984, 14, 2224, 8, 600, 9, 199, 199, 893, 26, 272, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 283, 73, 26, 72, 358, 199, 2590, 12733, 14, 705, 465, 1499, 26, 272, 4503, 8, 17, 12, 1499, 9, 199, 199, 3174, 3567, 275, 488, 199, 509, 2450, 12, 1680, 315, 3999, 26, 272, 340, 2450, 508, 2475, 73, 356, 267, 3907, 3567, 275, 31167, 14, 504, 24351, 16786, 8, 1273, 9, 339, 916, 2450, 508, 2475, 72, 356, 267, 4503, 8, 16, 9, 272, 587, 26, 267, 870, 360, 23375, 945, 26, 283, 435, 1680, 9, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 2491, 5866, 275, 1249, 199, 199, 692, 440, 3907, 3567, 26, 272, 3907, 3567, 275, 31167, 360, 3174, 358, 199, 199, 692, 440, 2559, 5866, 26, 272, 327, 298, 403, 2, 4910, 1006, 6117, 14, 272, 2559, 5866, 275, 488, 199, 199, 7073, 275, 19292, 23560, 8, 3174, 3567, 9, 199, 7073, 14, 1506, 11173, 397, 8, 2491, 5866, 275, 2559, 5866, 9, 199, 199, 3, 1626, 5027, 1240, 370, 4458, 342, 365, 1415, 370, 4458, 314, 2240, 12, 1380, 199, 3, 642, 859, 365, 2559, 68, 315, 282, 299, 19, 68, 570, 14, 199, 1274, 14, 2224, 8, 16, 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 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3807, 1872, 275, 408, 199, 199, 2765, 2884, 12821, 314, 12385, 1415, 370, 2291, 16316, 199, 4249, 402, 510, 18328, 19, 36, 6117, 14, 221, 2779, 883, 506, 1255, 465, 282, 2963, 13, 1412, 641, 282, 199, 3619, 14446, 2737, 701, 299, 2491, 27, 652, 911, 31758, 314, 2082, 199, 14861, 12, 436, 1218, 1263, 12385, 626, 7468, 370, 506, 4124, 14, 199, 199, 5556, 1443, 1255, 299, 2491, 641, 314, 2011, 2082, 14446, 465, 5002, 5431, 465, 199, 13297, 2839, 12, 1928, 6425, 12385, 14, 221, 2047, 1443, 2066, 5235, 436, 511, 199, 1589, 9183, 1584, 306, 3707, 18170, 370, 314, 3123, 1928, 17480, 199, 11350, 911, 506, 19565, 370, 5235, 314, 8039, 570, 12, 3140, 402, 10663, 199, 290, 16316, 5235, 12, 1325, 314, 8039, 2112, 911, 1736, 4257, 14, 199, 11423, 1265, 787, 23233, 626, 1006, 402, 314, 1584, 787, 10144, 370, 506, 14286, 12, 199, 13297, 1443, 1255, 299, 2491, 641, 314, 2082, 14446, 370, 3550, 314, 199, 2427, 12385, 14, 199, 199, 29244, 314, 12385, 2951, 2544, 4242, 4683, 365, 282, 6954, 16819, 370, 199, 3097, 314, 1329, 402, 3229, 433, 1183, 7425, 12385, 626, 787, 2737, 14, 221, 7048, 199, 521, 642, 2884, 365, 1255, 12, 282, 3371, 365, 2737, 687, 314, 4136, 1015, 12, 199, 460, 3520, 12385, 12927, 19765, 13, 4429, 10451, 370, 5627, 282, 4890, 1678, 199, 4041, 14, 221, 982, 1265, 1255, 642, 2884, 641, 5007, 19015, 12, 1265, 911, 199, 4208, 282, 1846, 6036, 402, 7425, 12385, 626, 2195, 4390, 1471, 5235, 27, 199, 3749, 365, 2376, 2003, 340, 2337, 365, 949, 31077, 402, 29165, 9445, 199, 19385, 1373, 402, 314, 1640, 1856, 316, 5459, 14, 199, 199, 5556, 883, 2597, 3550, 12385, 543, 314, 446, 80, 945, 370, 299, 2491, 12, 1325, 626, 199, 2118, 12821, 12385, 367, 314, 2488, 6117, 6137, 701, 626, 199, 30158, 402, 299, 2491, 14, 221, 982, 1265, 675, 314, 299, 11238, 2884, 3140, 12, 652, 199, 14117, 3550, 12385, 367, 1006, 6117, 334, 269, 314, 663, 402, 6117, 626, 199, 13297, 536, 22543, 680, 199, 199, 2765, 2884, 365, 5965, 282, 4975, 6818, 510, 18328, 1159, 19292, 23560, 14, 647, 14, 199, 199, 7692, 26, 819, 2818, 6595, 9, 83, 359, 3291, 61, 359, 2491, 985, 17, 2508, 2559, 985, 46, 61, 199, 199, 5976, 26, 819, 2559, 985, 17, 2508, 2559, 985, 46, 272, 13327, 314, 1561, 402, 314, 2559, 8, 83, 9, 1265, 13809, 370, 3550, 12385, 272, 367, 14, 221, 961, 6127, 1265, 370, 1900, 12385, 367, 1454, 282, 10026, 402, 314, 272, 6117, 1911, 315, 314, 3123, 14, 221, 982, 1265, 19413, 3520, 2633, 12, 12385, 272, 787, 6137, 367, 1006, 6117, 626, 4409, 3062, 14, 199, 199, 4558, 26, 819, 446, 73, 3907, 63, 694, 1362, 710, 2615, 931, 370, 314, 3907, 2082, 14, 221, 961, 1077, 506, 314, 2011, 1362, 2082, 4310, 701, 314, 446, 73, 2725, 370, 299, 2491, 14, 819, 446, 72, 1362, 12175, 642, 1720, 199, 199, 624, 199, 199, 646, 984, 199, 646, 12733, 199, 646, 747, 199, 199, 504, 4125, 14, 80, 19, 68, 14, 11173, 23560, 492, 19292, 23560, 199, 504, 299, 18328, 19, 68, 14, 1018, 492, 31167, 199, 199, 318, 4503, 8, 600, 12, 1499, 275, 21019, 272, 984, 14, 3083, 14, 952, 8, 3807, 1872, 450, 791, 6595, 7, 520, 747, 14, 515, 14, 1294, 8, 1274, 14, 3020, 59, 16, 11057, 17, 13412, 272, 984, 14, 3083, 14, 952, 8, 1328, 435, 1557, 78, 358, 272, 984, 14, 2224, 8, 600, 9, 199, 199, 893, 26, 272, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 283, 73, 26, 72, 358, 199, 2590, 12733, 14, 705, 465, 1499, 26, 272, 4503, 8, 17, 12, 1499, 9, 199, 199, 3174, 3567, 275, 488, 199, 509, 2450, 12, 1680, 315, 3999, 26, 272, 340, 2450, 508, 2475, 73, 356, 267, 3907, 3567, 275, 31167, 14, 504, 24351, 16786, 8, 1273, 9, 339, 916, 2450, 508, 2475, 72, 356, 267, 4503, 8, 16, 9, 272, 587, 26, 267, 870, 360, 23375, 945, 26, 283, 435, 1680, 9, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 2491, 5866, 275, 1249, 199, 199, 692, 440, 3907, 3567, 26, 272, 3907, 3567, 275, 31167, 360, 3174, 358, 199, 199, 692, 440, 2559, 5866, 26, 272, 327, 298, 403, 2, 4910, 1006, 6117, 14, 272, 2559, 5866, 275, 488, 199, 199, 7073, 275, 19292, 23560, 8, 3174, 3567, 9, 199, 7073, 14, 1506, 11173, 397, 8, 2491, 5866, 275, 2559, 5866, 9, 199, 199, 3, 1626, 5027, 1240, 370, 4458, 342, 365, 1415, 370, 4458, 314, 2240, 12, 1380, 199, 3, 642, 859, 365, 2559, 68, 315, 282, 299, 19, 68, 570, 14, 199, 1274, 14, 2224, 8, 16, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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for_paraview/lib152/__init__.py
9
6568
#!/usr/bin/env python """ PyVTK provides tools for manipulating VTK files in Python. VtkData - create VTK files from Python objects. """ """ Copyright 2001 Pearu Peterson all rights reserved, Pearu Peterson <pearu@ioc.ee> Permission to use, modify, and distribute this software is given under the terms of the LGPL. See http://www.fsf.org NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. $Revision: 1.1 $ $Date: 2001-05-20 12:51:29 $ Pearu Peterson """ __author__ = "Pearu Peterson <pearu@cens.ioc.ee>" __license__ = "LGPL (see http://www.fsf.org)" from __version__ import __version__ __all__ = ['StructuredPoints','StructuredGrid','UnstructuredGrid','RectilinearGrid', 'RectilinearGrid','PolyData', 'Scalars','ColorScalars','LookupTable','Vectors','Normals', 'TextureCoordinates','Tensors','Field', 'PointData','CellData', 'VtkData'] import common import string from StructuredPoints import StructuredPoints from StructuredGrid import StructuredGrid from UnstructuredGrid import UnstructuredGrid from RectilinearGrid import RectilinearGrid from PolyData import PolyData from Scalars import Scalars from ColorScalars import ColorScalars from LookupTable import LookupTable from Vectors import Vectors from Normals import Normals from TextureCoordinates import TextureCoordinates from Tensors import Tensors from Field import Field from Data import PointData,CellData class VtkData(common.Common): """ VtkData ======= Represents VTK file that has four relevant parts: header - string up to length 256 format - string: ascii | binary DataSet - StructuredPoints | StructuredGrid | UnstructuredGrid | RectilinearGrid | PolyData Data - PointData | CellData Usage: ------ v = VtkData(<DataSet instance> [,<header string>,<Data instances>,..]) v.tofile(filename, format = 'ascii') - save VTK data to file. DataSet ======= StructuredPoints(<3-sequence of dimensions> [,<3-sequence of origin> [, <3-sequence of spacing>]]) StructuredGrid(<3-sequence of dimensions>, <sequence of 3-sequences of points>) UnstructuredGrid(<sequence of 3-sequences of points> [,<cell> = <sequence of (sequences of) integers>]) cell - vertex | poly_vertex | line | poly_line | triangle | triangle_strip | polygon | pixel | quad | tetra | voxel | hexahedron | wedge | pyramid RectilinearGrid([x = <sequence of x-coordinates>], [y = <sequence of y-coordinates>], [z = <sequence of z-coordinates>]) PolyData(<sequence of 3-sequences of points>, [vertices = <sequence of (sequences of) integers>], [lines = <sequence of (sequences of) integers>], [polygons = <sequence of (sequences of) integers>], [triangle_strips = <sequence of (sequences of) integers>]) Data ==== PointData | CellData ([<DataSetAttr instances>]) - construct Data instance DataSetAttr =========== DataSetAttr - Scalars | ColorScalars | LookupTable | Vectors | Normals | TextureCoordinates | Tensors | Field Scalars(<sequence of scalars> [,name[, lookup_table]]) ColorScalars(<sequence of scalar sequences> [,name]) LookupTable(<sequence of 4-sequences> [,name]) Vectors(<sequence of 3-sequences> [,name]) Normals(<sequence of 3-sequences> [,name]) TextureCoordinates(<sequence of (1,2, or 3)-sequences> [,name]) Tensors(<sequence of (3x3)-sequences> [,name]) Field([name,] [arrayname_1 = sequence of n_1-sequences, ... arrayname_m = sequence of n_m-sequences,]) where len(array_1) == .. == len(array_m) must hold. """ header = None point_data = None cell_data = None def __init__(self,structure,*args): if not common.is_dataset(structure): raise TypeError,'argument structure must be StructuredPoints|StructuredGrid|UnstructuredGrid|RectilinearGrid|PolyData but got %s'%(type(structure)) self.structure = structure for a in args: if common.is_string(a): if len(a)>255: self.skipping('striping header string to length 256') self.header = a[:256] elif common.is_pointdata(a): self.point_data = a elif common.is_celldata(a): self.cell_data = a else: self.skipping('unexpexted argument %s'%(type(a))) if self.header is None: self.header = 'Really cool data' self.warning('Using header=%s'%(`self.header`)) if self.point_data is None and self.cell_data is None: self.warning('No data defined') if self.point_data is not None: s = self.structure.get_size() s1 = self.point_data.get_size() if s1 != s: raise ValueError,'DataSet (size=%s) and PointData (size=%s) have different sizes'%(s,s1) if self.cell_data is not None: s = self.structure.get_cell_size() s1 = self.cell_data.get_size() if s1 != s: raise ValueError,'DataSet (cell_size=%s) and CellData (size=%s) have different sizes'%(s,s1) def tofile(self, filename, format = 'ascii'): if not common.is_string(filename): raise TypeError,'argument filename must be string but got %s'%(type(filename)) if format not in ['ascii','binary']: raise TypeError,'argument format must be ascii | binary' filename = string.strip(filename) if not filename: raise ValueError,'filename must be non-empty string' if filename[-4:]!='.vtk': filename = filename + '.vtk' f = open(filename,'wb') f.write('# vtk DataFile Version 2.0\n') f.write(self.header+'\n') f.write(string.upper(format)+'\n') f.write(self.structure.to_string(format)+'\n') if self.cell_data: f.write(self.cell_data.to_string(format)+'\n') if self.point_data: f.write(self.point_data.to_string(format)) f.close() if __name__ == "__main__": vtk = VtkData(StructuredPoints((3,1,1)), 'This is title', PointData(Scalars([3,4,5])) ) vtk.tofile('test')
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 624, 199, 2713, 8156, 43, 6571, 7249, 367, 13335, 20529, 812, 15263, 1584, 315, 2018, 14, 199, 199, 54, 2663, 1451, 446, 1218, 812, 15263, 1584, 687, 2018, 2251, 14, 199, 199, 624, 199, 624, 199, 7384, 12521, 510, 2210, 85, 22912, 834, 1006, 4481, 4644, 12, 199, 48, 2210, 85, 22912, 834, 665, 16343, 85, 32, 73, 679, 14, 1024, 30, 3698, 199, 7980, 370, 675, 12, 2811, 12, 436, 11207, 642, 2032, 365, 1627, 1334, 314, 199, 9187, 402, 314, 32426, 14, 221, 1666, 1455, 921, 1544, 14, 2319, 70, 14, 1308, 199, 199, 2826, 3408, 2281, 3651, 14956, 10934, 1549, 5292, 14, 221, 4815, 15059, 1488, 11237, 593, 3705, 820, 22481, 14, 199, 4, 12714, 26, 413, 14, 17, 2672, 199, 4, 2506, 26, 12521, 13, 1717, 13, 1165, 3144, 26, 2869, 26, 1398, 2672, 199, 48, 2210, 85, 22912, 834, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 48, 2210, 85, 22912, 834, 665, 16343, 85, 32, 2497, 83, 14, 73, 679, 14, 1024, 4335, 199, 363, 1682, 363, 275, 298, 44, 12006, 334, 3239, 1455, 921, 1544, 14, 2319, 70, 14, 1308, 2924, 199, 504, 636, 1023, 363, 492, 636, 1023, 363, 199, 199, 363, 452, 363, 275, 788, 27486, 10225, 1673, 27486, 7900, 1673, 1358, 15774, 7900, 1673, 21561, 280, 6676, 7900, 297, 1779, 283, 21561, 280, 6676, 7900, 1673, 12747, 1451, 297, 1779, 283, 10249, 4291, 1673, 4117, 10249, 4291, 1673, 7521, 3186, 1673, 31465, 1673, 6241, 83, 297, 1779, 283, 17165, 13940, 2335, 1673, 29212, 1673, 792, 297, 1779, 283, 3428, 1451, 1673, 8108, 1451, 297, 1779, 283, 54, 2663, 1451, 418, 199, 199, 646, 2863, 199, 646, 1059, 199, 199, 504, 13039, 3297, 10225, 492, 13039, 3297, 10225, 199, 504, 13039, 3297, 7900, 492, 13039, 3297, 7900, 199, 504, 1910, 15774, 7900, 492, 1910, 15774, 7900, 199, 504, 799, 67, 280, 6676, 7900, 492, 799, 67, 280, 6676, 7900, 199, 504, 16869, 1451, 492, 16869, 1451, 199, 199, 504, 17619, 4291, 492, 17619, 4291, 199, 504, 11581, 10249, 4291, 492, 11581, 10249, 4291, 199, 504, 12785, 3186, 492, 12785, 3186, 199, 504, 812, 9177, 492, 812, 9177, 199, 504, 11514, 83, 492, 11514, 83, 199, 504, 4516, 608, 13940, 2335, 492, 4516, 608, 13940, 2335, 199, 504, 28373, 492, 28373, 199, 504, 5024, 492, 5024, 199, 199, 504, 3918, 492, 7584, 1451, 12, 8108, 1451, 199, 199, 533, 812, 2663, 1451, 8, 2330, 14, 7844, 304, 272, 408, 272, 812, 2663, 1451, 272, 9310, 389, 339, 21591, 812, 15263, 570, 626, 965, 11648, 12082, 4184, 26, 489, 1406, 259, 446, 1059, 1536, 370, 2582, 7633, 489, 1475, 259, 446, 1059, 26, 13294, 1204, 3366, 489, 3918, 1084, 257, 446, 13039, 3297, 10225, 1204, 13039, 3297, 7900, 1204, 1910, 15774, 7900, 2116, 1204, 799, 67, 280, 6676, 7900, 1204, 16869, 1451, 489, 3918, 420, 446, 7584, 1451, 1204, 24834, 1451, 2126, 272, 11028, 26, 272, 21397, 489, 373, 275, 812, 2663, 1451, 27530, 30720, 1256, 30, 359, 30027, 1291, 1059, 32659, 1451, 4454, 6244, 703, 566, 489, 373, 14, 475, 493, 8, 1501, 12, 1475, 275, 283, 4371, 358, 446, 3354, 812, 15263, 666, 370, 570, 14, 339, 3918, 1084, 272, 9310, 389, 1362, 489, 13039, 3297, 10225, 27530, 19, 13, 4041, 402, 7365, 30, 2432, 359, 30027, 19, 13, 4041, 402, 6330, 30, 359, 12, 665, 19, 13, 4041, 402, 19621, 30, 3934, 489, 13039, 3297, 7900, 27530, 19, 13, 4041, 402, 7365, 6244, 2151, 665, 4041, 402, 650, 13, 13436, 402, 4501, 18956, 489, 1910, 15774, 7900, 27530, 4041, 402, 650, 13, 13436, 402, 4501, 30, 2432, 359, 30027, 3890, 30, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 566, 267, 4917, 446, 12759, 1204, 8446, 63, 11417, 1204, 1004, 1204, 8446, 63, 604, 1204, 26268, 2049, 1204, 26268, 63, 1913, 1204, 17248, 1204, 7148, 1204, 16744, 1204, 1565, 1239, 2049, 1204, 14164, 31418, 1204, 6318, 11326, 379, 2641, 1204, 336, 5173, 1204, 30704, 489, 799, 67, 280, 6676, 7900, 779, 88, 275, 665, 4041, 402, 671, 13, 12924, 30, 467, 1993, 359, 89, 275, 665, 4041, 402, 612, 13, 12924, 30, 467, 1993, 359, 90, 275, 665, 4041, 402, 1315, 13, 12924, 30, 566, 489, 16869, 1451, 27530, 4041, 402, 650, 13, 13436, 402, 4501, 6244, 2049, 359, 12637, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 467, 2049, 359, 1278, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 467, 2049, 359, 2515, 18067, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 467, 2049, 359, 21584, 63, 816, 1190, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 566, 339, 3918, 272, 275, 5918, 2541, 7584, 1451, 1204, 24834, 1451, 7287, 28, 30720, 7144, 4454, 30, 566, 446, 6982, 3918, 1256, 339, 3918, 1084, 7144, 272, 275, 17575, 2541, 3918, 1084, 7144, 446, 17619, 4291, 1204, 11581, 10249, 4291, 1204, 12785, 3186, 1204, 812, 9177, 490, 1204, 11514, 83, 1204, 4516, 608, 13940, 2335, 1204, 28373, 1204, 5024, 489, 17619, 4291, 27530, 4041, 402, 19945, 30, 359, 12, 354, 14675, 4237, 63, 1224, 3934, 489, 11581, 10249, 4291, 27530, 4041, 402, 6917, 8013, 30, 359, 12, 354, 566, 489, 12785, 3186, 27530, 4041, 402, 841, 13, 13436, 30, 359, 12, 354, 566, 489, 812, 9177, 27530, 4041, 402, 650, 13, 13436, 30, 359, 12, 354, 566, 489, 11514, 83, 27530, 4041, 402, 650, 13, 13436, 30, 359, 12, 354, 566, 489, 4516, 608, 13940, 2335, 27530, 4041, 402, 334, 17, 12, 18, 12, 503, 650, 7216, 13436, 30, 359, 12, 354, 566, 489, 28373, 27530, 4041, 402, 334, 19, 88, 19, 7216, 13436, 30, 359, 12, 354, 566, 489, 5024, 779, 354, 12, 61, 359, 1144, 354, 63, 17, 275, 3414, 402, 302, 63, 17, 13, 13436, 12, 2263, 2151, 1625, 354, 63, 77, 275, 3414, 402, 302, 63, 77, 13, 13436, 30453, 267, 2382, 822, 8, 1144, 63, 17, 9, 508, 2508, 508, 822, 8, 1144, 63, 77, 9, 1471, 10266, 14, 272, 408, 272, 1406, 275, 488, 272, 2376, 63, 576, 275, 488, 272, 4917, 63, 576, 275, 488, 272, 347, 636, 826 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 624, 199, 2713, 8156, 43, 6571, 7249, 367, 13335, 20529, 812, 15263, 1584, 315, 2018, 14, 199, 199, 54, 2663, 1451, 446, 1218, 812, 15263, 1584, 687, 2018, 2251, 14, 199, 199, 624, 199, 624, 199, 7384, 12521, 510, 2210, 85, 22912, 834, 1006, 4481, 4644, 12, 199, 48, 2210, 85, 22912, 834, 665, 16343, 85, 32, 73, 679, 14, 1024, 30, 3698, 199, 7980, 370, 675, 12, 2811, 12, 436, 11207, 642, 2032, 365, 1627, 1334, 314, 199, 9187, 402, 314, 32426, 14, 221, 1666, 1455, 921, 1544, 14, 2319, 70, 14, 1308, 199, 199, 2826, 3408, 2281, 3651, 14956, 10934, 1549, 5292, 14, 221, 4815, 15059, 1488, 11237, 593, 3705, 820, 22481, 14, 199, 4, 12714, 26, 413, 14, 17, 2672, 199, 4, 2506, 26, 12521, 13, 1717, 13, 1165, 3144, 26, 2869, 26, 1398, 2672, 199, 48, 2210, 85, 22912, 834, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 48, 2210, 85, 22912, 834, 665, 16343, 85, 32, 2497, 83, 14, 73, 679, 14, 1024, 4335, 199, 363, 1682, 363, 275, 298, 44, 12006, 334, 3239, 1455, 921, 1544, 14, 2319, 70, 14, 1308, 2924, 199, 504, 636, 1023, 363, 492, 636, 1023, 363, 199, 199, 363, 452, 363, 275, 788, 27486, 10225, 1673, 27486, 7900, 1673, 1358, 15774, 7900, 1673, 21561, 280, 6676, 7900, 297, 1779, 283, 21561, 280, 6676, 7900, 1673, 12747, 1451, 297, 1779, 283, 10249, 4291, 1673, 4117, 10249, 4291, 1673, 7521, 3186, 1673, 31465, 1673, 6241, 83, 297, 1779, 283, 17165, 13940, 2335, 1673, 29212, 1673, 792, 297, 1779, 283, 3428, 1451, 1673, 8108, 1451, 297, 1779, 283, 54, 2663, 1451, 418, 199, 199, 646, 2863, 199, 646, 1059, 199, 199, 504, 13039, 3297, 10225, 492, 13039, 3297, 10225, 199, 504, 13039, 3297, 7900, 492, 13039, 3297, 7900, 199, 504, 1910, 15774, 7900, 492, 1910, 15774, 7900, 199, 504, 799, 67, 280, 6676, 7900, 492, 799, 67, 280, 6676, 7900, 199, 504, 16869, 1451, 492, 16869, 1451, 199, 199, 504, 17619, 4291, 492, 17619, 4291, 199, 504, 11581, 10249, 4291, 492, 11581, 10249, 4291, 199, 504, 12785, 3186, 492, 12785, 3186, 199, 504, 812, 9177, 492, 812, 9177, 199, 504, 11514, 83, 492, 11514, 83, 199, 504, 4516, 608, 13940, 2335, 492, 4516, 608, 13940, 2335, 199, 504, 28373, 492, 28373, 199, 504, 5024, 492, 5024, 199, 199, 504, 3918, 492, 7584, 1451, 12, 8108, 1451, 199, 199, 533, 812, 2663, 1451, 8, 2330, 14, 7844, 304, 272, 408, 272, 812, 2663, 1451, 272, 9310, 389, 339, 21591, 812, 15263, 570, 626, 965, 11648, 12082, 4184, 26, 489, 1406, 259, 446, 1059, 1536, 370, 2582, 7633, 489, 1475, 259, 446, 1059, 26, 13294, 1204, 3366, 489, 3918, 1084, 257, 446, 13039, 3297, 10225, 1204, 13039, 3297, 7900, 1204, 1910, 15774, 7900, 2116, 1204, 799, 67, 280, 6676, 7900, 1204, 16869, 1451, 489, 3918, 420, 446, 7584, 1451, 1204, 24834, 1451, 2126, 272, 11028, 26, 272, 21397, 489, 373, 275, 812, 2663, 1451, 27530, 30720, 1256, 30, 359, 30027, 1291, 1059, 32659, 1451, 4454, 6244, 703, 566, 489, 373, 14, 475, 493, 8, 1501, 12, 1475, 275, 283, 4371, 358, 446, 3354, 812, 15263, 666, 370, 570, 14, 339, 3918, 1084, 272, 9310, 389, 1362, 489, 13039, 3297, 10225, 27530, 19, 13, 4041, 402, 7365, 30, 2432, 359, 30027, 19, 13, 4041, 402, 6330, 30, 359, 12, 665, 19, 13, 4041, 402, 19621, 30, 3934, 489, 13039, 3297, 7900, 27530, 19, 13, 4041, 402, 7365, 6244, 2151, 665, 4041, 402, 650, 13, 13436, 402, 4501, 18956, 489, 1910, 15774, 7900, 27530, 4041, 402, 650, 13, 13436, 402, 4501, 30, 2432, 359, 30027, 3890, 30, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 566, 267, 4917, 446, 12759, 1204, 8446, 63, 11417, 1204, 1004, 1204, 8446, 63, 604, 1204, 26268, 2049, 1204, 26268, 63, 1913, 1204, 17248, 1204, 7148, 1204, 16744, 1204, 1565, 1239, 2049, 1204, 14164, 31418, 1204, 6318, 11326, 379, 2641, 1204, 336, 5173, 1204, 30704, 489, 799, 67, 280, 6676, 7900, 779, 88, 275, 665, 4041, 402, 671, 13, 12924, 30, 467, 1993, 359, 89, 275, 665, 4041, 402, 612, 13, 12924, 30, 467, 1993, 359, 90, 275, 665, 4041, 402, 1315, 13, 12924, 30, 566, 489, 16869, 1451, 27530, 4041, 402, 650, 13, 13436, 402, 4501, 6244, 2049, 359, 12637, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 467, 2049, 359, 1278, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 467, 2049, 359, 2515, 18067, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 467, 2049, 359, 21584, 63, 816, 1190, 275, 665, 4041, 402, 334, 13436, 402, 9, 9446, 30, 566, 339, 3918, 272, 275, 5918, 2541, 7584, 1451, 1204, 24834, 1451, 7287, 28, 30720, 7144, 4454, 30, 566, 446, 6982, 3918, 1256, 339, 3918, 1084, 7144, 272, 275, 17575, 2541, 3918, 1084, 7144, 446, 17619, 4291, 1204, 11581, 10249, 4291, 1204, 12785, 3186, 1204, 812, 9177, 490, 1204, 11514, 83, 1204, 4516, 608, 13940, 2335, 1204, 28373, 1204, 5024, 489, 17619, 4291, 27530, 4041, 402, 19945, 30, 359, 12, 354, 14675, 4237, 63, 1224, 3934, 489, 11581, 10249, 4291, 27530, 4041, 402, 6917, 8013, 30, 359, 12, 354, 566, 489, 12785, 3186, 27530, 4041, 402, 841, 13, 13436, 30, 359, 12, 354, 566, 489, 812, 9177, 27530, 4041, 402, 650, 13, 13436, 30, 359, 12, 354, 566, 489, 11514, 83, 27530, 4041, 402, 650, 13, 13436, 30, 359, 12, 354, 566, 489, 4516, 608, 13940, 2335, 27530, 4041, 402, 334, 17, 12, 18, 12, 503, 650, 7216, 13436, 30, 359, 12, 354, 566, 489, 28373, 27530, 4041, 402, 334, 19, 88, 19, 7216, 13436, 30, 359, 12, 354, 566, 489, 5024, 779, 354, 12, 61, 359, 1144, 354, 63, 17, 275, 3414, 402, 302, 63, 17, 13, 13436, 12, 2263, 2151, 1625, 354, 63, 77, 275, 3414, 402, 302, 63, 77, 13, 13436, 30453, 267, 2382, 822, 8, 1144, 63, 17, 9, 508, 2508, 508, 822, 8, 1144, 63, 77, 9, 1471, 10266, 14, 272, 408, 272, 1406, 275, 488, 272, 2376, 63, 576, 275, 488, 272, 4917, 63, 576, 275, 488, 272, 347, 636, 826, 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,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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 ]
lildadou/Flexget
flexget/plugins/output/rapidpush.py
16
6376
from __future__ import unicode_literals, division, absolute_import import logging from requests import RequestException from flexget import plugin from flexget.event import event from flexget.utils import json from flexget.utils.template import RenderError from flexget.config_schema import one_or_more log = logging.getLogger('rapidpush') url = 'https://rapidpush.net/api' class OutputRapidPush(object): """ Example:: rapidpush: apikey: xxxxxxx (can also be a list of api keys) [category: category, default FlexGet] [title: title, default New release] [group: device group, default no group] [message: the message, default {{title}}] [channel: the broadcast notification channel, if provided it will be send to the channel subscribers instead of your devices, default no channel] [priority: 0 - 6 (6 = highest), default 2 (normal)] [notify_accepted: boolean true or false, default true] [notify_rejected: boolean true or false, default false] [notify_failed: boolean true or false, default false] [notify_undecided: boolean true or false, default false] Configuration parameters are also supported from entries (eg. through set). """ schema = { 'type': 'object', 'properties': { 'apikey': one_or_more({'type': 'string'}), 'category': {'type': 'string', 'default': 'Flexget'}, 'title': {'type': 'string', 'default': 'New Release'}, 'group': {'type': 'string', 'default': ''}, 'channel': {'type': 'string', 'default': ''}, 'priority': {'type': 'integer', 'default': 2}, 'message': {'type': 'string', 'default': '{{title}}'}, 'notify_accepted': {'type': 'boolean', 'default': True}, 'notify_rejected': {'type': 'boolean', 'default': False}, 'notify_failed': {'type': 'boolean', 'default': False}, 'notify_undecided': {'type': 'boolean', 'default': False} }, 'additionalProperties': False, 'required': ['apikey'] } # Run last to make sure other outputs are successful before sending notification @plugin.priority(0) def on_task_output(self, task, config): # get the parameters if config['notify_accepted']: log.debug("Notify accepted entries") self.process_notifications(task, task.accepted, config) if config['notify_rejected']: log.debug("Notify rejected entries") self.process_notifications(task, task.rejected, config) if config['notify_failed']: log.debug("Notify failed entries") self.process_notifications(task, task.failed, config) if config['notify_undecided']: log.debug("Notify undecided entries") self.process_notifications(task, task.undecided, config) # Process the given events. def process_notifications(self, task, entries, config): for entry in entries: if task.options.test: log.info("Would send RapidPush notification about: %s", entry['title']) continue log.info("Send RapidPush notification about: %s", entry['title']) apikey = entry.get('apikey', config['apikey']) if isinstance(apikey, list): apikey = ','.join(apikey) title = config['title'] try: title = entry.render(title) except RenderError as e: log.error('Error setting RapidPush title: %s' % e) message = config['message'] try: message = entry.render(message) except RenderError as e: log.error('Error setting RapidPush message: %s' % e) # Check if we have to send a normal or a broadcast notification. if not config['channel']: priority = entry.get('priority', config['priority']) category = entry.get('category', config['category']) try: category = entry.render(category) except RenderError as e: log.error('Error setting RapidPush category: %s' % e) group = entry.get('group', config['group']) try: group = entry.render(group) except RenderError as e: log.error('Error setting RapidPush group: %s' % e) # Send the request data_string = json.dumps({ 'title': title, 'message': message, 'priority': priority, 'category': category, 'group': group}) data = {'apikey': apikey, 'command': 'notify', 'data': data_string} else: channel = config['channel'] try: channel = entry.render(channel) except RenderError as e: log.error('Error setting RapidPush channel: %s' % e) # Send the broadcast request data_string = json.dumps({ 'title': title, 'message': message, 'channel': channel}) data = {'apikey': apikey, 'command': 'broadcast', 'data': data_string} try: response = task.requests.post(url, data=data, raise_status=False) except RequestException as e: log.error('Error sending data to rapidpush: %s' % e) continue json_data = response.json() if 'code' in json_data: if json_data['code'] == 200: log.debug("RapidPush message sent") else: log.error(json_data['desc'] + " (" + str(json_data['code']) + ")") else: for item in json_data: if json_data[item]['code'] == 200: log.debug(item + ": RapidPush message sent") else: log.error(item + ": " + json_data[item]['desc'] + " (" + str(json_data[item]['code']) + ")") @event('plugin.register') def register_plugin(): plugin.register(OutputRapidPush, 'rapidpush', api_ver=2)
mit
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 4629, 12, 3679, 63, 646, 199, 646, 2050, 199, 199, 504, 4145, 492, 4784, 1726, 199, 199, 504, 20758, 362, 492, 3589, 199, 504, 20758, 362, 14, 1430, 492, 1566, 199, 504, 20758, 362, 14, 1208, 492, 2022, 199, 504, 20758, 362, 14, 1208, 14, 1160, 492, 17769, 547, 199, 504, 20758, 362, 14, 888, 63, 3629, 492, 1373, 63, 269, 63, 6878, 199, 199, 793, 275, 2050, 14, 5572, 360, 1330, 344, 5335, 358, 199, 199, 633, 275, 283, 2859, 921, 1330, 344, 5335, 14, 846, 15, 1246, 7, 421, 199, 533, 7242, 50, 27703, 10731, 8, 785, 304, 272, 408, 272, 5679, 447, 2541, 660, 3150, 5335, 26, 267, 2986, 498, 26, 671, 5336, 2154, 334, 2425, 2597, 506, 282, 769, 402, 2986, 2883, 9, 267, 359, 3710, 26, 4637, 12, 849, 481, 3113, 1002, 61, 267, 359, 1213, 26, 2538, 12, 849, 7053, 4683, 61, 267, 359, 923, 26, 2243, 1572, 12, 849, 949, 1572, 61, 267, 359, 1188, 26, 314, 1245, 12, 849, 8448, 1213, 4863, 61, 267, 359, 2775, 26, 314, 11180, 6955, 3623, 12, 340, 2741, 652, 911, 506, 3222, 370, 314, 3623, 22148, 83, 3140, 402, 288, 2195, 7256, 12, 849, 949, 3623, 61, 267, 359, 6693, 26, 378, 446, 1227, 334, 22, 275, 15356, 395, 849, 499, 334, 3302, 1874, 267, 359, 6814, 63, 16121, 26, 5046, 2549, 503, 3055, 12, 849, 2549, 61, 267, 359, 6814, 63, 24054, 26, 5046, 2549, 503, 3055, 12, 849, 3055, 61, 267, 359, 6814, 63, 4892, 26, 5046, 2549, 503, 3055, 12, 849, 3055, 61, 267, 359, 6814, 63, 324, 22612, 770, 26, 5046, 2549, 503, 3055, 12, 849, 3055, 61, 339, 11595, 2633, 787, 2597, 3748, 687, 4811, 334, 5902, 14, 4012, 663, 680, 272, 408, 272, 4177, 275, 469, 267, 283, 466, 356, 283, 785, 297, 267, 283, 3282, 356, 469, 288, 283, 28181, 356, 1373, 63, 269, 63, 6878, 3252, 466, 356, 283, 875, 1604, 288, 283, 3710, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 283, 38, 3113, 362, 2267, 288, 283, 1213, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 283, 4665, 17646, 2267, 288, 283, 923, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 28599, 288, 283, 2775, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 28599, 288, 283, 6693, 356, 791, 466, 356, 283, 4115, 297, 283, 885, 356, 499, 1386, 288, 283, 1188, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 11400, 1213, 4863, 2267, 288, 283, 6814, 63, 16121, 356, 791, 466, 356, 283, 4871, 297, 283, 885, 356, 715, 1386, 288, 283, 6814, 63, 24054, 356, 791, 466, 356, 283, 4871, 297, 283, 885, 356, 756, 1386, 288, 283, 6814, 63, 4892, 356, 791, 466, 356, 283, 4871, 297, 283, 885, 356, 756, 1386, 288, 283, 6814, 63, 324, 22612, 770, 356, 791, 466, 356, 283, 4871, 297, 283, 885, 356, 756, 93, 267, 1660, 267, 283, 8460, 8516, 356, 756, 12, 267, 283, 2427, 356, 788, 28181, 418, 272, 789, 339, 327, 3378, 2061, 370, 1852, 3238, 1163, 4704, 787, 9512, 2544, 10209, 6955, 272, 768, 2718, 14, 6693, 8, 16, 9, 272, 347, 641, 63, 1765, 63, 1199, 8, 277, 12, 2120, 12, 1101, 304, 267, 327, 664, 314, 2633, 398, 340, 1101, 459, 6814, 63, 16121, 2565, 288, 943, 14, 1757, 480, 8645, 10226, 4811, 531, 288, 291, 14, 1412, 63, 12782, 8, 1765, 12, 2120, 14, 16121, 12, 1101, 9, 267, 340, 1101, 459, 6814, 63, 24054, 2565, 288, 943, 14, 1757, 480, 8645, 18935, 4811, 531, 288, 291, 14, 1412, 63, 12782, 8, 1765, 12, 2120, 14, 24054, 12, 1101, 9, 267, 340, 1101, 459, 6814, 63, 4892, 2565, 288, 943, 14, 1757, 480, 8645, 3405, 4811, 531, 288, 291, 14, 1412, 63, 12782, 8, 1765, 12, 2120, 14, 4892, 12, 1101, 9, 267, 340, 1101, 459, 6814, 63, 324, 22612, 770, 2565, 288, 943, 14, 1757, 480, 8645, 625, 22612, 770, 4811, 531, 288, 291, 14, 1412, 63, 12782, 8, 1765, 12, 2120, 14, 324, 22612, 770, 12, 1101, 9, 339, 327, 7132, 314, 1627, 4474, 14, 272, 347, 2112, 63, 12782, 8, 277, 12, 2120, 12, 4811, 12, 1101, 304, 267, 367, 2397, 315, 4811, 26, 288, 340, 2120, 14, 1419, 14, 396, 26, 355, 943, 14, 815, 480, 55, 3857, 3222, 820, 27703, 10731, 6955, 3595, 26, 450, 83, 401, 2397, 459, 1213, 1105, 355, 1980, 953, 943, 14, 815, 480, 6795, 820, 27703, 10731, 6955, 3595, 26, 450, 83, 401, 2397, 459, 1213, 1105, 288, 2986, 498, 275, 2397, 14, 362, 360, 28181, 297, 1101, 459, 28181, 1105, 288, 340, 1228, 8, 28181, 12, 769, 304, 355, 2986, 498, 275, 12814, 904, 8, 28181, 9, 953, 2538, 275, 1101, 459, 1213, 418, 288, 862, 26, 355, 2538, 275, 2397, 14, 3352, 8, 1213, 9, 288, 871, 17769, 547, 465, 325, 26, 355, 943, 14, 705, 360, 547, 4260, 820, 27703, 10731, 2538, 26, 450, 83, 7, 450, 325, 9, 953, 1245, 275, 1101, 459, 1188, 418, 288, 862, 26, 355, 1245, 275, 2397, 14, 3352, 8, 1188, 9, 288, 871, 17769, 547, 465, 325, 26, 355, 943, 14, 705, 360, 547, 4260, 820, 27703, 10731, 1245, 26, 450, 83, 7, 450, 325, 9, 953, 327, 2670, 340, 781, 1172, 370, 3222, 282, 3293, 503, 282, 11180, 6955, 14, 288, 340, 440, 1101, 459, 2775, 2565, 355, 7464, 275, 2397, 14, 362, 360, 6693, 297, 1101, 459, 6693, 1105, 2234, 4637, 275, 2397, 14, 362, 360, 3710, 297, 1101, 459, 3710, 1105, 355, 862, 26, 490, 4637, 275, 2397, 14, 3352, 8, 3710, 9, 355, 871, 17769, 547, 465, 325, 26, 490, 943, 14, 705, 360, 547, 4260, 820, 27703, 10731, 4637, 26, 450, 83, 7, 450, 325, 9, 2234, 1572, 275, 2397, 14, 362, 360, 923, 297, 1101, 459, 923, 1105, 355, 862, 26, 490, 1572, 275, 2397, 14, 3352, 8, 923, 9, 355, 871, 17769, 547, 465, 325, 26, 490, 943, 14, 705, 360, 547, 4260, 820, 27703, 10731, 1572, 26, 450, 83, 7, 450, 325, 9, 2234, 327, 10217 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 12, 4629, 12, 3679, 63, 646, 199, 646, 2050, 199, 199, 504, 4145, 492, 4784, 1726, 199, 199, 504, 20758, 362, 492, 3589, 199, 504, 20758, 362, 14, 1430, 492, 1566, 199, 504, 20758, 362, 14, 1208, 492, 2022, 199, 504, 20758, 362, 14, 1208, 14, 1160, 492, 17769, 547, 199, 504, 20758, 362, 14, 888, 63, 3629, 492, 1373, 63, 269, 63, 6878, 199, 199, 793, 275, 2050, 14, 5572, 360, 1330, 344, 5335, 358, 199, 199, 633, 275, 283, 2859, 921, 1330, 344, 5335, 14, 846, 15, 1246, 7, 421, 199, 533, 7242, 50, 27703, 10731, 8, 785, 304, 272, 408, 272, 5679, 447, 2541, 660, 3150, 5335, 26, 267, 2986, 498, 26, 671, 5336, 2154, 334, 2425, 2597, 506, 282, 769, 402, 2986, 2883, 9, 267, 359, 3710, 26, 4637, 12, 849, 481, 3113, 1002, 61, 267, 359, 1213, 26, 2538, 12, 849, 7053, 4683, 61, 267, 359, 923, 26, 2243, 1572, 12, 849, 949, 1572, 61, 267, 359, 1188, 26, 314, 1245, 12, 849, 8448, 1213, 4863, 61, 267, 359, 2775, 26, 314, 11180, 6955, 3623, 12, 340, 2741, 652, 911, 506, 3222, 370, 314, 3623, 22148, 83, 3140, 402, 288, 2195, 7256, 12, 849, 949, 3623, 61, 267, 359, 6693, 26, 378, 446, 1227, 334, 22, 275, 15356, 395, 849, 499, 334, 3302, 1874, 267, 359, 6814, 63, 16121, 26, 5046, 2549, 503, 3055, 12, 849, 2549, 61, 267, 359, 6814, 63, 24054, 26, 5046, 2549, 503, 3055, 12, 849, 3055, 61, 267, 359, 6814, 63, 4892, 26, 5046, 2549, 503, 3055, 12, 849, 3055, 61, 267, 359, 6814, 63, 324, 22612, 770, 26, 5046, 2549, 503, 3055, 12, 849, 3055, 61, 339, 11595, 2633, 787, 2597, 3748, 687, 4811, 334, 5902, 14, 4012, 663, 680, 272, 408, 272, 4177, 275, 469, 267, 283, 466, 356, 283, 785, 297, 267, 283, 3282, 356, 469, 288, 283, 28181, 356, 1373, 63, 269, 63, 6878, 3252, 466, 356, 283, 875, 1604, 288, 283, 3710, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 283, 38, 3113, 362, 2267, 288, 283, 1213, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 283, 4665, 17646, 2267, 288, 283, 923, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 28599, 288, 283, 2775, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 28599, 288, 283, 6693, 356, 791, 466, 356, 283, 4115, 297, 283, 885, 356, 499, 1386, 288, 283, 1188, 356, 791, 466, 356, 283, 875, 297, 283, 885, 356, 11400, 1213, 4863, 2267, 288, 283, 6814, 63, 16121, 356, 791, 466, 356, 283, 4871, 297, 283, 885, 356, 715, 1386, 288, 283, 6814, 63, 24054, 356, 791, 466, 356, 283, 4871, 297, 283, 885, 356, 756, 1386, 288, 283, 6814, 63, 4892, 356, 791, 466, 356, 283, 4871, 297, 283, 885, 356, 756, 1386, 288, 283, 6814, 63, 324, 22612, 770, 356, 791, 466, 356, 283, 4871, 297, 283, 885, 356, 756, 93, 267, 1660, 267, 283, 8460, 8516, 356, 756, 12, 267, 283, 2427, 356, 788, 28181, 418, 272, 789, 339, 327, 3378, 2061, 370, 1852, 3238, 1163, 4704, 787, 9512, 2544, 10209, 6955, 272, 768, 2718, 14, 6693, 8, 16, 9, 272, 347, 641, 63, 1765, 63, 1199, 8, 277, 12, 2120, 12, 1101, 304, 267, 327, 664, 314, 2633, 398, 340, 1101, 459, 6814, 63, 16121, 2565, 288, 943, 14, 1757, 480, 8645, 10226, 4811, 531, 288, 291, 14, 1412, 63, 12782, 8, 1765, 12, 2120, 14, 16121, 12, 1101, 9, 267, 340, 1101, 459, 6814, 63, 24054, 2565, 288, 943, 14, 1757, 480, 8645, 18935, 4811, 531, 288, 291, 14, 1412, 63, 12782, 8, 1765, 12, 2120, 14, 24054, 12, 1101, 9, 267, 340, 1101, 459, 6814, 63, 4892, 2565, 288, 943, 14, 1757, 480, 8645, 3405, 4811, 531, 288, 291, 14, 1412, 63, 12782, 8, 1765, 12, 2120, 14, 4892, 12, 1101, 9, 267, 340, 1101, 459, 6814, 63, 324, 22612, 770, 2565, 288, 943, 14, 1757, 480, 8645, 625, 22612, 770, 4811, 531, 288, 291, 14, 1412, 63, 12782, 8, 1765, 12, 2120, 14, 324, 22612, 770, 12, 1101, 9, 339, 327, 7132, 314, 1627, 4474, 14, 272, 347, 2112, 63, 12782, 8, 277, 12, 2120, 12, 4811, 12, 1101, 304, 267, 367, 2397, 315, 4811, 26, 288, 340, 2120, 14, 1419, 14, 396, 26, 355, 943, 14, 815, 480, 55, 3857, 3222, 820, 27703, 10731, 6955, 3595, 26, 450, 83, 401, 2397, 459, 1213, 1105, 355, 1980, 953, 943, 14, 815, 480, 6795, 820, 27703, 10731, 6955, 3595, 26, 450, 83, 401, 2397, 459, 1213, 1105, 288, 2986, 498, 275, 2397, 14, 362, 360, 28181, 297, 1101, 459, 28181, 1105, 288, 340, 1228, 8, 28181, 12, 769, 304, 355, 2986, 498, 275, 12814, 904, 8, 28181, 9, 953, 2538, 275, 1101, 459, 1213, 418, 288, 862, 26, 355, 2538, 275, 2397, 14, 3352, 8, 1213, 9, 288, 871, 17769, 547, 465, 325, 26, 355, 943, 14, 705, 360, 547, 4260, 820, 27703, 10731, 2538, 26, 450, 83, 7, 450, 325, 9, 953, 1245, 275, 1101, 459, 1188, 418, 288, 862, 26, 355, 1245, 275, 2397, 14, 3352, 8, 1188, 9, 288, 871, 17769, 547, 465, 325, 26, 355, 943, 14, 705, 360, 547, 4260, 820, 27703, 10731, 1245, 26, 450, 83, 7, 450, 325, 9, 953, 327, 2670, 340, 781, 1172, 370, 3222, 282, 3293, 503, 282, 11180, 6955, 14, 288, 340, 440, 1101, 459, 2775, 2565, 355, 7464, 275, 2397, 14, 362, 360, 6693, 297, 1101, 459, 6693, 1105, 2234, 4637, 275, 2397, 14, 362, 360, 3710, 297, 1101, 459, 3710, 1105, 355, 862, 26, 490, 4637, 275, 2397, 14, 3352, 8, 3710, 9, 355, 871, 17769, 547, 465, 325, 26, 490, 943, 14, 705, 360, 547, 4260, 820, 27703, 10731, 4637, 26, 450, 83, 7, 450, 325, 9, 2234, 1572, 275, 2397, 14, 362, 360, 923, 297, 1101, 459, 923, 1105, 355, 862, 26, 490, 1572, 275, 2397, 14, 3352, 8, 923, 9, 355, 871, 17769, 547, 465, 325, 26, 490, 943, 14, 705, 360, 547, 4260, 820, 27703, 10731, 1572, 26, 450, 83, 7, 450, 325, 9, 2234, 327, 10217, 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,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