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
|
|---|---|---|---|---|---|---|---|---|
ibank/node-gyp
|
gyp/tools/graphviz.py
|
2679
|
2878
|
#!/usr/bin/env python
# Copyright (c) 2011 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.
"""Using the JSON dumped by the dump-dependency-json generator,
generate input suitable for graphviz to render a dependency graph of
targets."""
import collections
import json
import sys
def ParseTarget(target):
target, _, suffix = target.partition('#')
filename, _, target = target.partition(':')
return filename, target, suffix
def LoadEdges(filename, targets):
"""Load the edges map from the dump file, and filter it to only
show targets in |targets| and their depedendents."""
file = open('dump.json')
edges = json.load(file)
file.close()
# Copy out only the edges we're interested in from the full edge list.
target_edges = {}
to_visit = targets[:]
while to_visit:
src = to_visit.pop()
if src in target_edges:
continue
target_edges[src] = edges[src]
to_visit.extend(edges[src])
return target_edges
def WriteGraph(edges):
"""Print a graphviz graph to stdout.
|edges| is a map of target to a list of other targets it depends on."""
# Bucket targets by file.
files = collections.defaultdict(list)
for src, dst in edges.items():
build_file, target_name, toolset = ParseTarget(src)
files[build_file].append(src)
print 'digraph D {'
print ' fontsize=8' # Used by subgraphs.
print ' node [fontsize=8]'
# Output nodes by file. We must first write out each node within
# its file grouping before writing out any edges that may refer
# to those nodes.
for filename, targets in files.items():
if len(targets) == 1:
# If there's only one node for this file, simplify
# the display by making it a box without an internal node.
target = targets[0]
build_file, target_name, toolset = ParseTarget(target)
print ' "%s" [shape=box, label="%s\\n%s"]' % (target, filename,
target_name)
else:
# Group multiple nodes together in a subgraph.
print ' subgraph "cluster_%s" {' % filename
print ' label = "%s"' % filename
for target in targets:
build_file, target_name, toolset = ParseTarget(target)
print ' "%s" [label="%s"]' % (target, target_name)
print ' }'
# Now that we've placed all the nodes within subgraphs, output all
# the edges between nodes.
for src, dsts in edges.items():
for dst in dsts:
print ' "%s" -> "%s"' % (src, dst)
print '}'
def main():
if len(sys.argv) < 2:
print >>sys.stderr, __doc__
print >>sys.stderr
print >>sys.stderr, 'usage: %s target1 target2...' % (sys.argv[0])
return 1
edges = LoadEdges('dump.json', sys.argv[1:])
WriteGraph(edges)
return 0
if __name__ == '__main__':
sys.exit(main())
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
7760,
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,
10369,
314,
4840,
31374,
701,
314,
5461,
13,
8575,
13,
1001,
4306,
12,
199,
4208,
1324,
11233,
367,
3343,
17249,
370,
3795,
282,
5936,
3343,
402,
199,
4684,
1041,
199,
199,
646,
5055,
199,
646,
2022,
199,
646,
984,
421,
199,
318,
6077,
4277,
8,
1375,
304,
523,
1347,
12,
5501,
4739,
275,
1347,
14,
5312,
7863,
358,
523,
1788,
12,
5501,
1347,
275,
1347,
14,
5312,
11633,
523,
372,
1788,
12,
1347,
12,
4739,
421,
199,
318,
7190,
24121,
8,
1501,
12,
4545,
304,
523,
408,
6200,
314,
8207,
2341,
687,
314,
5461,
570,
12,
436,
2457,
652,
370,
1454,
523,
2498,
4545,
315,
1204,
4684,
92,
436,
3932,
477,
321,
848,
1326,
83,
1041,
819,
570,
275,
1551,
360,
2724,
14,
1001,
358,
523,
8207,
275,
2022,
14,
912,
8,
493,
9,
523,
570,
14,
1600,
342,
819,
327,
11247,
734,
1454,
314,
8207,
781,
3984,
22201,
315,
687,
314,
2615,
6275,
769,
14,
523,
1347,
63,
6929,
275,
1052,
523,
370,
63,
5427,
275,
4545,
5873,
523,
1830,
370,
63,
5427,
26,
272,
2928,
275,
370,
63,
5427,
14,
1935,
342,
272,
340,
2928,
315,
1347,
63,
6929,
26,
489,
1980,
272,
1347,
63,
6929,
59,
2164,
61,
275,
8207,
59,
2164,
61,
272,
370,
63,
5427,
14,
2880,
8,
6929,
59,
2164,
566,
819,
372,
1347,
63,
6929,
421,
199,
318,
6990,
4578,
8,
6929,
304,
523,
408,
5375,
282,
3343,
17249,
3343,
370,
3839,
14,
523,
1204,
6929,
92,
365,
282,
2341,
402,
1347,
370,
282,
769,
402,
1163,
4545,
652,
8350,
641,
1041,
819,
327,
31479,
4545,
701,
570,
14,
523,
1584,
275,
5055,
14,
21501,
8,
513,
9,
523,
367,
2928,
12,
5042,
315,
8207,
14,
1744,
837,
272,
1900,
63,
493,
12,
1347,
63,
354,
12,
20070,
275,
6077,
4277,
8,
2164,
9,
272,
1584,
59,
1506,
63,
493,
1055,
740,
8,
2164,
9,
819,
870,
283,
328,
2180,
577,
791,
523,
870,
283,
221,
19740,
29,
24,
7,
221,
327,
8051,
701,
1007,
16670,
14,
523,
870,
283,
221,
1031,
359,
22124,
29,
24,
6616,
819,
327,
7242,
3380,
701,
570,
14,
221,
2136,
1471,
1642,
2218,
734,
1924,
1031,
4453,
523,
327,
2399,
570,
17786,
2544,
3575,
734,
1263,
8207,
626,
1443,
10618,
523,
327,
370,
5204,
3380,
14,
523,
367,
1788,
12,
4545,
315,
1584,
14,
1744,
837,
272,
340,
822,
8,
4684,
9,
508,
413,
26,
489,
327,
982,
2337,
1159,
1454,
1373,
1031,
367,
642,
570,
12,
15037,
489,
327,
314,
2929,
701,
10663,
652,
282,
5689,
1928,
376,
5007,
1031,
14,
489,
1347,
275,
4545,
59,
16,
61,
489,
1900,
63,
493,
12,
1347,
63,
354,
12,
20070,
275,
6077,
4277,
8,
1375,
9,
489,
870,
283,
221,
2071,
83,
2,
359,
1392,
29,
1977,
12,
1768,
5961,
83,
1103,
78,
5,
83,
937,
7,
450,
334,
1375,
12,
1788,
12,
9349,
1347,
63,
354,
9,
272,
587,
26,
489,
327,
5611,
3663,
3380,
10451,
315,
282,
23649,
14,
489,
870,
283,
221,
23649,
298,
4201,
4970,
83,
2,
791,
450,
1788,
489,
870,
283,
259,
1768,
275,
2071,
83,
4507,
450,
1788,
489,
367,
1347,
315,
4545,
26,
267,
1900,
63,
493,
12,
1347,
63,
354,
12,
20070,
275,
6077,
4277,
8,
1375,
9,
267,
870,
283,
259,
2071,
83,
2,
359,
1302,
5961,
83,
937,
7,
450,
334,
1375,
12,
1347,
63,
354,
9,
489,
870,
283,
221,
789,
7,
819,
327,
7356,
626,
781,
9064,
15090,
1006,
314,
3380,
4453,
1007,
16670,
12,
1072,
1006,
523,
327,
314,
8207,
3382,
3380,
14,
523,
367,
2928,
12,
5042,
83,
315,
8207,
14,
1744,
837,
272,
367,
5042,
315,
5042,
83,
26,
489,
870,
283,
221,
2071,
83,
2,
1035,
2071,
83,
4507,
450,
334,
2164,
12,
5042,
9,
819,
870,
23618,
421,
199,
318,
2446,
837,
523,
340,
822,
8,
1274,
14,
3020,
9,
665,
499,
26,
272,
870,
4331,
1274,
14,
3083,
12,
636,
1301,
363,
272,
870,
4331,
1274,
14,
3083,
272,
870,
4331,
1274,
14,
3083,
12,
283,
3807,
26,
450,
83,
1347,
17,
1347,
18,
13698,
450,
334,
1274,
14,
3020,
59,
16,
566,
272,
372,
413,
819,
8207,
275,
7190,
24121,
360,
2724,
14,
1001,
297,
984,
14,
3020,
59,
17,
5728,
819,
6990,
4578,
8,
6929,
9,
523,
372,
378,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
984,
14,
2224,
8,
973,
1012,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
1898,
334,
67,
9,
7760,
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,
10369,
314,
4840,
31374,
701,
314,
5461,
13,
8575,
13,
1001,
4306,
12,
199,
4208,
1324,
11233,
367,
3343,
17249,
370,
3795,
282,
5936,
3343,
402,
199,
4684,
1041,
199,
199,
646,
5055,
199,
646,
2022,
199,
646,
984,
421,
199,
318,
6077,
4277,
8,
1375,
304,
523,
1347,
12,
5501,
4739,
275,
1347,
14,
5312,
7863,
358,
523,
1788,
12,
5501,
1347,
275,
1347,
14,
5312,
11633,
523,
372,
1788,
12,
1347,
12,
4739,
421,
199,
318,
7190,
24121,
8,
1501,
12,
4545,
304,
523,
408,
6200,
314,
8207,
2341,
687,
314,
5461,
570,
12,
436,
2457,
652,
370,
1454,
523,
2498,
4545,
315,
1204,
4684,
92,
436,
3932,
477,
321,
848,
1326,
83,
1041,
819,
570,
275,
1551,
360,
2724,
14,
1001,
358,
523,
8207,
275,
2022,
14,
912,
8,
493,
9,
523,
570,
14,
1600,
342,
819,
327,
11247,
734,
1454,
314,
8207,
781,
3984,
22201,
315,
687,
314,
2615,
6275,
769,
14,
523,
1347,
63,
6929,
275,
1052,
523,
370,
63,
5427,
275,
4545,
5873,
523,
1830,
370,
63,
5427,
26,
272,
2928,
275,
370,
63,
5427,
14,
1935,
342,
272,
340,
2928,
315,
1347,
63,
6929,
26,
489,
1980,
272,
1347,
63,
6929,
59,
2164,
61,
275,
8207,
59,
2164,
61,
272,
370,
63,
5427,
14,
2880,
8,
6929,
59,
2164,
566,
819,
372,
1347,
63,
6929,
421,
199,
318,
6990,
4578,
8,
6929,
304,
523,
408,
5375,
282,
3343,
17249,
3343,
370,
3839,
14,
523,
1204,
6929,
92,
365,
282,
2341,
402,
1347,
370,
282,
769,
402,
1163,
4545,
652,
8350,
641,
1041,
819,
327,
31479,
4545,
701,
570,
14,
523,
1584,
275,
5055,
14,
21501,
8,
513,
9,
523,
367,
2928,
12,
5042,
315,
8207,
14,
1744,
837,
272,
1900,
63,
493,
12,
1347,
63,
354,
12,
20070,
275,
6077,
4277,
8,
2164,
9,
272,
1584,
59,
1506,
63,
493,
1055,
740,
8,
2164,
9,
819,
870,
283,
328,
2180,
577,
791,
523,
870,
283,
221,
19740,
29,
24,
7,
221,
327,
8051,
701,
1007,
16670,
14,
523,
870,
283,
221,
1031,
359,
22124,
29,
24,
6616,
819,
327,
7242,
3380,
701,
570,
14,
221,
2136,
1471,
1642,
2218,
734,
1924,
1031,
4453,
523,
327,
2399,
570,
17786,
2544,
3575,
734,
1263,
8207,
626,
1443,
10618,
523,
327,
370,
5204,
3380,
14,
523,
367,
1788,
12,
4545,
315,
1584,
14,
1744,
837,
272,
340,
822,
8,
4684,
9,
508,
413,
26,
489,
327,
982,
2337,
1159,
1454,
1373,
1031,
367,
642,
570,
12,
15037,
489,
327,
314,
2929,
701,
10663,
652,
282,
5689,
1928,
376,
5007,
1031,
14,
489,
1347,
275,
4545,
59,
16,
61,
489,
1900,
63,
493,
12,
1347,
63,
354,
12,
20070,
275,
6077,
4277,
8,
1375,
9,
489,
870,
283,
221,
2071,
83,
2,
359,
1392,
29,
1977,
12,
1768,
5961,
83,
1103,
78,
5,
83,
937,
7,
450,
334,
1375,
12,
1788,
12,
9349,
1347,
63,
354,
9,
272,
587,
26,
489,
327,
5611,
3663,
3380,
10451,
315,
282,
23649,
14,
489,
870,
283,
221,
23649,
298,
4201,
4970,
83,
2,
791,
450,
1788,
489,
870,
283,
259,
1768,
275,
2071,
83,
4507,
450,
1788,
489,
367,
1347,
315,
4545,
26,
267,
1900,
63,
493,
12,
1347,
63,
354,
12,
20070,
275,
6077,
4277,
8,
1375,
9,
267,
870,
283,
259,
2071,
83,
2,
359,
1302,
5961,
83,
937,
7,
450,
334,
1375,
12,
1347,
63,
354,
9,
489,
870,
283,
221,
789,
7,
819,
327,
7356,
626,
781,
9064,
15090,
1006,
314,
3380,
4453,
1007,
16670,
12,
1072,
1006,
523,
327,
314,
8207,
3382,
3380,
14,
523,
367,
2928,
12,
5042,
83,
315,
8207,
14,
1744,
837,
272,
367,
5042,
315,
5042,
83,
26,
489,
870,
283,
221,
2071,
83,
2,
1035,
2071,
83,
4507,
450,
334,
2164,
12,
5042,
9,
819,
870,
23618,
421,
199,
318,
2446,
837,
523,
340,
822,
8,
1274,
14,
3020,
9,
665,
499,
26,
272,
870,
4331,
1274,
14,
3083,
12,
636,
1301,
363,
272,
870,
4331,
1274,
14,
3083,
272,
870,
4331,
1274,
14,
3083,
12,
283,
3807,
26,
450,
83,
1347,
17,
1347,
18,
13698,
450,
334,
1274,
14,
3020,
59,
16,
566,
272,
372,
413,
819,
8207,
275,
7190,
24121,
360,
2724,
14,
1001,
297,
984,
14,
3020,
59,
17,
5728,
819,
6990,
4578,
8,
6929,
9,
523,
372,
378,
421,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
984,
14,
2224,
8,
973,
1012,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
chungjjang80/FRETBursts
|
fretbursts/ph_sel.py
|
2
|
4514
|
#
# FRETBursts - A single-molecule FRET burst analysis toolkit.
#
# Copyright (C) 2014-2016 The Regents of the University of California,
# Antonino Ingargiola <tritemio@gmail.com>
#
"""
In this module we define the class :class:`Ph_sel` used to specify a
"selection" of a sub-set of photons/timestamps (i.e. all-photons,
Donor-excitation-period photons, etc...).
A photon selection is one of the base *photon streams* or a combination of
them. Base *photon streams* are photon from the donor (or acceptor) emission
channel detected during the donor (or acceptor) excitation period. For
non-ALEX data there is only the donor excitation period.
The following table shows base *photon streams* for smFRET data (non-ALEX):
================= =====================
Photon selection Syntax
================= =====================
D-emission `Ph_sel(Dex='Dem')`
A-emission `Ph_sel(Dex='Aem')`
================= =====================
and for ALEX data:
============================== =====================
Photon selection Syntax
============================== =====================
D-emission during D-excitation `Ph_sel(Dex='Dem')`
A-emission during D-excitation `Ph_sel(Dex='Aem')`
D-emission during A-excitation `Ph_sel(Aex='Dem')`
A-emission during A-excitation `Ph_sel(Aex='Aem')`
============================== =====================
Additionally, all the photons can be selected with `Ph_sel('all')` (that is a
shortcut for `Ph_sel(Dex='DAem', Aex='DAem')`.
Examples:
- `Ph_sel(Dex='DAem', Aex='DAem')` or `Ph_sel('all')` select all photons.
- `Ph_sel(Dex='DAem')` selects only donor and acceptor photons
emitted during donor excitation. These are all the photons for
non-ALEX data.
- `Ph_sel(Dex='Aem', Aex='Aem')` selects all the photons detected from
the acceptor-emission channel.
The documentation for the :class:`Ph_sel` class follows.
"""
from collections import namedtuple
# Implementation Rationale:
#
# This class is implemented as a named tuple that is an immutable object.
# This means the Ph_sel objects can be used as dictionary keys. This would
# not be possible if Ph_sel were a dict. The __new__ method is just a nicety
# to allow only valid arguments values and to throw meaningful exceptions
# otherwise.
#
class Ph_sel(namedtuple('Ph_sel', ['Dex', 'Aex'])):
"""Class that describes a selection of photons.
This class takes two arguments `Dex` and `Aex`.
Valid values for the arguments are the strings 'DAem', 'Dem', 'Aem' or
`None`. These values select, respectively, donor+acceptor, donor-only,
acceptor-only or no photons during an excitation period (`Dex` or `Aex`).
The class must be called with at least one keyword argument or using
the string 'all' as the only argument. Calling `Ph_sel('all')` is
equivalent to `Ph_sel(Dex='DAem', Aex='DAem')`.
Not specifying a keyword argument is equivalent to setting it to None.
"""
valid_values = ('DAem', 'Dem', 'Aem', None)
def __new__(cls, Dex=None, Aex=None):
if Dex is None and Aex is None:
raise ValueError("You need to specify at least one argument "
"(Dex, Aex or 'all').")
if Dex == 'all':
return super(Ph_sel, cls).__new__(cls, 'DAem', 'DAem')
if Dex not in cls.valid_values or Aex not in cls.valid_values:
raise ValueError("Invalid value %s. Valid values are "
"'DAem', 'Dem' or 'Aem' (or None)." %
str((Dex, Aex)))
return super(Ph_sel, cls).__new__(cls, Dex, Aex)
@classmethod
def _get_str_mapping(cls, invert=False):
mapping = {cls('all'): 'all',
cls(Dex='Dem'): 'DexDem', cls(Dex='Aem'): 'DexAem',
cls(Aex='Aem'): 'AexAem', cls(Aex='Dem'): 'AexDem',
cls(Dex='DAem'): 'Dex', cls(Aex='DAem'): 'Aex',
cls(Dex='Dem', Aex='Dem'): 'Dem',
cls(Dex='Aem', Aex='Aem'): 'Aem',
cls(Dex='DAem', Aex='Aem'): 'DexDAem_AexAem'}
if invert:
mapping = {v: k for k, v in mapping.items()}
return mapping
@classmethod
def from_str(cls, ph_sel_str):
str_to_ph_sel = cls._get_str_mapping(invert=True)
return str_to_ph_sel[ph_sel_str]
def __str__(self):
labels = self._get_str_mapping()
return labels.get(self, repr(self))
|
gpl-2.0
|
[
3,
199,
3,
481,
7341,
34,
300,
10329,
446,
437,
2849,
13,
26310,
481,
7341,
330,
13305,
11284,
4744,
6065,
14,
199,
3,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
710,
5044,
24871,
402,
314,
15904,
402,
8256,
73,
509,
22042,
12,
199,
3,
5185,
437,
343,
265,
10175,
1010,
71,
1273,
73,
22205,
665,
599,
563,
2308,
32,
6799,
14,
957,
30,
199,
3,
199,
624,
199,
607,
642,
859,
781,
5627,
314,
1021,
520,
533,
1705,
5663,
63,
5891,
64,
1202,
370,
4165,
282,
199,
2,
5592,
2,
402,
282,
1007,
13,
409,
402,
3945,
357,
4654,
15,
25430,
221,
334,
73,
14,
69,
14,
1006,
13,
838,
357,
4654,
12,
199,
36,
15034,
13,
2804,
5314,
13,
5191,
3945,
357,
4654,
12,
5423,
1396,
680,
199,
199,
33,
3945,
357,
265,
7267,
365,
1373,
402,
314,
1300,
627,
838,
357,
265,
13788,
10,
503,
282,
14665,
402,
199,
1589,
77,
14,
3523,
627,
838,
357,
265,
13788,
10,
787,
3945,
357,
265,
687,
314,
2793,
269,
334,
269,
4729,
269,
9,
325,
2250,
199,
2775,
10501,
5309,
314,
2793,
269,
334,
269,
4729,
269,
9,
3178,
5314,
6247,
14,
2104,
199,
2865,
13,
748,
1438,
666,
2337,
365,
1454,
314,
2793,
269,
3178,
5314,
6247,
14,
199,
199,
1918,
2569,
1817,
13703,
1300,
627,
838,
357,
265,
13788,
10,
367,
4383,
5372,
775,
666,
334,
2865,
13,
748,
1438,
304,
199,
199,
1280,
29,
257,
16248,
532,
199,
5663,
357,
265,
7267,
259,
18377,
199,
1280,
29,
257,
16248,
532,
199,
36,
13,
69,
2250,
3515,
658,
5663,
63,
5891,
8,
36,
476,
534,
872,
77,
358,
64,
199,
33,
13,
69,
2250,
3515,
658,
5663,
63,
5891,
8,
36,
476,
534,
33,
5633,
358,
64,
199,
1280,
29,
257,
16248,
532,
199,
199,
460,
367,
437,
8066,
666,
26,
199,
199,
1280,
17224,
257,
16248,
532,
199,
5663,
357,
265,
7267,
463,
18377,
199,
1280,
17224,
257,
16248,
532,
199,
36,
13,
69,
2250,
5309,
577,
13,
2804,
5314,
257,
658,
5663,
63,
5891,
8,
36,
476,
534,
872,
77,
358,
64,
199,
33,
13,
69,
2250,
5309,
577,
13,
2804,
5314,
257,
658,
5663,
63,
5891,
8,
36,
476,
534,
33,
5633,
358,
64,
199,
36,
13,
69,
2250,
5309,
437,
13,
2804,
5314,
257,
658,
5663,
63,
5891,
8,
33,
476,
534,
872,
77,
358,
64,
199,
33,
13,
69,
2250,
5309,
437,
13,
2804,
5314,
257,
658,
5663,
63,
5891,
8,
33,
476,
534,
33,
5633,
358,
64,
199,
1280,
17224,
257,
16248,
532,
199,
199,
2767,
22565,
12,
1006,
314,
3945,
357,
4654,
883,
506,
4895,
543,
658,
5663,
63,
5891,
360,
452,
358,
64,
334,
9099,
365,
282,
199,
24231,
367,
221,
658,
5663,
63,
5891,
8,
36,
476,
534,
8980,
5633,
297,
437,
476,
534,
8980,
5633,
358,
2313,
199,
199,
22787,
26,
339,
446,
658,
5663,
63,
5891,
8,
36,
476,
534,
8980,
5633,
297,
437,
476,
534,
8980,
5633,
358,
64,
503,
658,
5663,
63,
5891,
360,
452,
358,
64,
3504,
1006,
3945,
357,
4654,
14,
272,
446,
658,
5663,
63,
5891,
8,
36,
476,
534,
8980,
5633,
358,
64,
24750,
1454,
2793,
269,
436,
4729,
269,
3945,
357,
4654,
489,
19515,
5309,
2793,
269,
3178,
5314,
14,
5723,
787,
1006,
314,
3945,
357,
4654,
367,
489,
2222,
13,
748,
1438,
666,
14,
272,
446,
658,
5663,
63,
5891,
8,
36,
476,
534,
33,
5633,
297,
437,
476,
534,
33,
5633,
358,
64,
24750,
1006,
314,
3945,
357,
4654,
10501,
687,
489,
314,
4729,
269,
13,
69,
2250,
3623,
14,
199,
199,
1918,
3794,
367,
314,
520,
533,
1705,
5663,
63,
5891,
64,
1021,
11924,
14,
199,
199,
624,
199,
199,
504,
5055,
492,
12863,
421,
199,
3,
24425,
820,
425,
1895,
26,
199,
3,
199,
3,
257,
961,
1021,
365,
6366,
465,
282,
4310,
2008,
626,
365,
376,
17092,
909,
14,
199,
3,
257,
961,
4910,
314,
11308,
63,
5891,
2251,
883,
506,
1202,
465,
2600,
2883,
14,
961,
3955,
199,
3,
257,
440,
506,
3962,
340,
11308,
63,
5891,
4898,
282,
1211,
14,
710,
636,
1222,
363,
1083,
365,
2951,
282,
14213,
369,
199,
3,
257,
370,
2040,
1454,
1686,
2368,
1338,
436,
370,
7978,
26562,
4967,
199,
3,
257,
4257,
14,
199,
3,
199,
533,
11308,
63,
5891,
8,
18921,
360,
5663,
63,
5891,
297,
788,
36,
476,
297,
283,
33,
476,
26536,
272,
408,
2543,
626,
23369,
282,
7267,
402,
3945,
357,
4654,
14,
339,
961,
1021,
6181,
2877,
2368,
658,
36,
476,
64,
436,
658,
33,
476,
2313,
272,
4821,
1338,
367,
314,
2368,
787,
314,
3326,
283,
8980,
5633,
297,
283,
872,
77,
297,
283,
33,
5633,
7,
503,
272,
658,
403,
2313,
5723,
1338,
3504,
12,
17342,
12,
2793,
269,
11,
5694,
269,
12,
2793,
269,
13,
2118,
12,
272,
4729,
269,
13,
2118,
503,
949,
3945,
357,
4654,
5309,
376,
3178,
5314,
6247,
13493,
36,
476,
64,
503,
658,
33,
476,
14963,
339,
710,
1021,
1471,
506,
2797,
543,
737,
5210,
1373,
4252,
1423,
503,
1808,
272,
314,
1059,
283,
452,
7,
465,
314,
1454,
1423,
14,
23892,
658,
5663,
63,
5891,
360,
452,
358,
64,
365,
272,
7353,
370,
658,
5663,
63,
5891,
8,
36,
476,
534,
8980,
5633,
297,
437,
476,
534,
8980,
5633,
358,
2313,
272,
2832,
9176,
282,
4252,
1423,
365,
7353,
370,
4260,
652,
370,
488,
14,
339,
408,
272,
1686,
63,
1459,
275,
661,
8980,
5633,
297,
283,
872,
77,
297,
283,
33,
5633,
297,
488,
9,
339,
347,
636,
1222,
721,
1886,
12,
577,
476,
29,
403,
12,
437,
476,
29,
403,
304,
267,
340,
577,
476,
365,
488,
436,
437,
476,
365,
488,
26,
288,
746,
1722,
480,
5556,
1929,
370,
4165,
737,
5210,
1373,
1423,
298,
2490,
7340,
36,
476,
12,
437,
476,
503,
283,
452,
1959,
531,
267,
340,
577,
476,
508,
283,
452,
356,
288,
372,
1613,
8,
5663,
63,
5891,
12,
843,
2843,
1222,
721,
1886,
12,
283,
8980,
5633,
297,
283,
8980,
5633,
358,
267,
340,
577,
476,
440,
315,
843,
14,
1078,
63,
1459,
503,
437,
476,
440,
315,
843,
14,
1078,
63,
1459,
26,
288,
746,
1722
] |
[
199,
3,
481,
7341,
34,
300,
10329,
446,
437,
2849,
13,
26310,
481,
7341,
330,
13305,
11284,
4744,
6065,
14,
199,
3,
199,
3,
1898,
334,
35,
9,
6927,
13,
9261,
710,
5044,
24871,
402,
314,
15904,
402,
8256,
73,
509,
22042,
12,
199,
3,
5185,
437,
343,
265,
10175,
1010,
71,
1273,
73,
22205,
665,
599,
563,
2308,
32,
6799,
14,
957,
30,
199,
3,
199,
624,
199,
607,
642,
859,
781,
5627,
314,
1021,
520,
533,
1705,
5663,
63,
5891,
64,
1202,
370,
4165,
282,
199,
2,
5592,
2,
402,
282,
1007,
13,
409,
402,
3945,
357,
4654,
15,
25430,
221,
334,
73,
14,
69,
14,
1006,
13,
838,
357,
4654,
12,
199,
36,
15034,
13,
2804,
5314,
13,
5191,
3945,
357,
4654,
12,
5423,
1396,
680,
199,
199,
33,
3945,
357,
265,
7267,
365,
1373,
402,
314,
1300,
627,
838,
357,
265,
13788,
10,
503,
282,
14665,
402,
199,
1589,
77,
14,
3523,
627,
838,
357,
265,
13788,
10,
787,
3945,
357,
265,
687,
314,
2793,
269,
334,
269,
4729,
269,
9,
325,
2250,
199,
2775,
10501,
5309,
314,
2793,
269,
334,
269,
4729,
269,
9,
3178,
5314,
6247,
14,
2104,
199,
2865,
13,
748,
1438,
666,
2337,
365,
1454,
314,
2793,
269,
3178,
5314,
6247,
14,
199,
199,
1918,
2569,
1817,
13703,
1300,
627,
838,
357,
265,
13788,
10,
367,
4383,
5372,
775,
666,
334,
2865,
13,
748,
1438,
304,
199,
199,
1280,
29,
257,
16248,
532,
199,
5663,
357,
265,
7267,
259,
18377,
199,
1280,
29,
257,
16248,
532,
199,
36,
13,
69,
2250,
3515,
658,
5663,
63,
5891,
8,
36,
476,
534,
872,
77,
358,
64,
199,
33,
13,
69,
2250,
3515,
658,
5663,
63,
5891,
8,
36,
476,
534,
33,
5633,
358,
64,
199,
1280,
29,
257,
16248,
532,
199,
199,
460,
367,
437,
8066,
666,
26,
199,
199,
1280,
17224,
257,
16248,
532,
199,
5663,
357,
265,
7267,
463,
18377,
199,
1280,
17224,
257,
16248,
532,
199,
36,
13,
69,
2250,
5309,
577,
13,
2804,
5314,
257,
658,
5663,
63,
5891,
8,
36,
476,
534,
872,
77,
358,
64,
199,
33,
13,
69,
2250,
5309,
577,
13,
2804,
5314,
257,
658,
5663,
63,
5891,
8,
36,
476,
534,
33,
5633,
358,
64,
199,
36,
13,
69,
2250,
5309,
437,
13,
2804,
5314,
257,
658,
5663,
63,
5891,
8,
33,
476,
534,
872,
77,
358,
64,
199,
33,
13,
69,
2250,
5309,
437,
13,
2804,
5314,
257,
658,
5663,
63,
5891,
8,
33,
476,
534,
33,
5633,
358,
64,
199,
1280,
17224,
257,
16248,
532,
199,
199,
2767,
22565,
12,
1006,
314,
3945,
357,
4654,
883,
506,
4895,
543,
658,
5663,
63,
5891,
360,
452,
358,
64,
334,
9099,
365,
282,
199,
24231,
367,
221,
658,
5663,
63,
5891,
8,
36,
476,
534,
8980,
5633,
297,
437,
476,
534,
8980,
5633,
358,
2313,
199,
199,
22787,
26,
339,
446,
658,
5663,
63,
5891,
8,
36,
476,
534,
8980,
5633,
297,
437,
476,
534,
8980,
5633,
358,
64,
503,
658,
5663,
63,
5891,
360,
452,
358,
64,
3504,
1006,
3945,
357,
4654,
14,
272,
446,
658,
5663,
63,
5891,
8,
36,
476,
534,
8980,
5633,
358,
64,
24750,
1454,
2793,
269,
436,
4729,
269,
3945,
357,
4654,
489,
19515,
5309,
2793,
269,
3178,
5314,
14,
5723,
787,
1006,
314,
3945,
357,
4654,
367,
489,
2222,
13,
748,
1438,
666,
14,
272,
446,
658,
5663,
63,
5891,
8,
36,
476,
534,
33,
5633,
297,
437,
476,
534,
33,
5633,
358,
64,
24750,
1006,
314,
3945,
357,
4654,
10501,
687,
489,
314,
4729,
269,
13,
69,
2250,
3623,
14,
199,
199,
1918,
3794,
367,
314,
520,
533,
1705,
5663,
63,
5891,
64,
1021,
11924,
14,
199,
199,
624,
199,
199,
504,
5055,
492,
12863,
421,
199,
3,
24425,
820,
425,
1895,
26,
199,
3,
199,
3,
257,
961,
1021,
365,
6366,
465,
282,
4310,
2008,
626,
365,
376,
17092,
909,
14,
199,
3,
257,
961,
4910,
314,
11308,
63,
5891,
2251,
883,
506,
1202,
465,
2600,
2883,
14,
961,
3955,
199,
3,
257,
440,
506,
3962,
340,
11308,
63,
5891,
4898,
282,
1211,
14,
710,
636,
1222,
363,
1083,
365,
2951,
282,
14213,
369,
199,
3,
257,
370,
2040,
1454,
1686,
2368,
1338,
436,
370,
7978,
26562,
4967,
199,
3,
257,
4257,
14,
199,
3,
199,
533,
11308,
63,
5891,
8,
18921,
360,
5663,
63,
5891,
297,
788,
36,
476,
297,
283,
33,
476,
26536,
272,
408,
2543,
626,
23369,
282,
7267,
402,
3945,
357,
4654,
14,
339,
961,
1021,
6181,
2877,
2368,
658,
36,
476,
64,
436,
658,
33,
476,
2313,
272,
4821,
1338,
367,
314,
2368,
787,
314,
3326,
283,
8980,
5633,
297,
283,
872,
77,
297,
283,
33,
5633,
7,
503,
272,
658,
403,
2313,
5723,
1338,
3504,
12,
17342,
12,
2793,
269,
11,
5694,
269,
12,
2793,
269,
13,
2118,
12,
272,
4729,
269,
13,
2118,
503,
949,
3945,
357,
4654,
5309,
376,
3178,
5314,
6247,
13493,
36,
476,
64,
503,
658,
33,
476,
14963,
339,
710,
1021,
1471,
506,
2797,
543,
737,
5210,
1373,
4252,
1423,
503,
1808,
272,
314,
1059,
283,
452,
7,
465,
314,
1454,
1423,
14,
23892,
658,
5663,
63,
5891,
360,
452,
358,
64,
365,
272,
7353,
370,
658,
5663,
63,
5891,
8,
36,
476,
534,
8980,
5633,
297,
437,
476,
534,
8980,
5633,
358,
2313,
272,
2832,
9176,
282,
4252,
1423,
365,
7353,
370,
4260,
652,
370,
488,
14,
339,
408,
272,
1686,
63,
1459,
275,
661,
8980,
5633,
297,
283,
872,
77,
297,
283,
33,
5633,
297,
488,
9,
339,
347,
636,
1222,
721,
1886,
12,
577,
476,
29,
403,
12,
437,
476,
29,
403,
304,
267,
340,
577,
476,
365,
488,
436,
437,
476,
365,
488,
26,
288,
746,
1722,
480,
5556,
1929,
370,
4165,
737,
5210,
1373,
1423,
298,
2490,
7340,
36,
476,
12,
437,
476,
503,
283,
452,
1959,
531,
267,
340,
577,
476,
508,
283,
452,
356,
288,
372,
1613,
8,
5663,
63,
5891,
12,
843,
2843,
1222,
721,
1886,
12,
283,
8980,
5633,
297,
283,
8980,
5633,
358,
267,
340,
577,
476,
440,
315,
843,
14,
1078,
63,
1459,
503,
437,
476,
440,
315,
843,
14,
1078,
63,
1459,
26,
288,
746,
1722,
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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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
] |
wemake-services/wemake-django-template
|
{{cookiecutter.project_name}}/server/urls.py
|
1
|
1772
|
"""
Main URL mapping configuration file.
Include other URLConfs from external apps using method `include()`.
It is also a good practice to keep a single URL to the root index page.
This examples uses Django's default media
files serving technique in development.
"""
from django.conf import settings
from django.contrib import admin
from django.contrib.admindocs import urls as admindocs_urls
from django.urls import include, path
from django.views.generic import TemplateView
from health_check import urls as health_urls
from server.apps.main import urls as main_urls
from server.apps.main.views import index
admin.autodiscover()
urlpatterns = [
# Apps:
path('main/', include(main_urls, namespace='main')),
# Health checks:
path('health/', include(health_urls)), # noqa: DJ05
# django-admin:
path('admin/doc/', include(admindocs_urls)), # noqa: DJ05
path('admin/', admin.site.urls),
# Text and xml static files:
path('robots.txt', TemplateView.as_view(
template_name='txt/robots.txt',
content_type='text/plain',
)),
path('humans.txt', TemplateView.as_view(
template_name='txt/humans.txt',
content_type='text/plain',
)),
# It is a good practice to have explicit index view:
path('', index, name='index'),
]
if settings.DEBUG: # pragma: no cover
import debug_toolbar # noqa: WPS433
from django.conf.urls.static import static # noqa: WPS433
urlpatterns = [
# URLs specific only to django-debug-toolbar:
path('__debug__/', include(debug_toolbar.urls)), # noqa: DJ05
] + urlpatterns + static( # type: ignore
# Serving media files in development only:
settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT,
)
|
mit
|
[
624,
199,
6756,
2851,
4412,
2897,
570,
14,
199,
199,
7826,
1163,
2851,
714,
2319,
687,
5957,
8686,
1808,
1083,
658,
2613,
25593,
199,
199,
7940,
365,
2597,
282,
6954,
24471,
370,
4215,
282,
2849,
2851,
370,
314,
1738,
1478,
2034,
14,
199,
199,
2765,
7251,
4440,
5634,
1159,
849,
5898,
199,
1725,
22701,
32414,
315,
16367,
14,
199,
624,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
14464,
688,
14851,
492,
8187,
465,
1503,
77,
688,
14851,
63,
3603,
199,
504,
1639,
14,
3603,
492,
2387,
12,
931,
199,
504,
1639,
14,
4196,
14,
6767,
492,
5458,
2768,
199,
504,
13822,
63,
1074,
492,
8187,
465,
13822,
63,
3603,
199,
199,
504,
1654,
14,
5181,
14,
973,
492,
8187,
465,
2446,
63,
3603,
199,
504,
1654,
14,
5181,
14,
973,
14,
4196,
492,
1478,
199,
199,
2113,
14,
2495,
18861,
342,
199,
199,
20050,
275,
359,
272,
327,
4693,
83,
26,
272,
931,
360,
973,
3678,
2387,
8,
973,
63,
3603,
12,
3231,
534,
973,
3855,
339,
327,
5311,
6130,
5920,
26,
272,
931,
360,
9665,
3678,
2387,
8,
9665,
63,
3603,
1826,
221,
327,
8151,
26,
577,
42,
1717,
339,
327,
1639,
13,
2113,
26,
272,
931,
360,
2113,
15,
1301,
3678,
2387,
8,
14464,
688,
14851,
63,
3603,
1826,
221,
327,
8151,
26,
577,
42,
1717,
272,
931,
360,
2113,
3678,
4628,
14,
2124,
14,
3603,
395,
339,
327,
4516,
436,
2748,
2955,
1584,
26,
272,
931,
360,
28889,
14,
2424,
297,
5458,
2768,
14,
305,
63,
1345,
8,
267,
1978,
63,
354,
534,
2424,
15,
28889,
14,
2424,
297,
267,
1564,
63,
466,
534,
505,
15,
6104,
297,
272,
22583,
272,
931,
360,
72,
453,
796,
14,
2424,
297,
5458,
2768,
14,
305,
63,
1345,
8,
267,
1978,
63,
354,
534,
2424,
15,
72,
453,
796,
14,
2424,
297,
267,
1564,
63,
466,
534,
505,
15,
6104,
297,
272,
22583,
339,
327,
2779,
365,
282,
6954,
24471,
370,
1172,
5027,
1478,
2455,
26,
272,
931,
8594,
1478,
12,
536,
534,
1080,
659,
199,
61,
199,
199,
692,
2202,
14,
5287,
26,
221,
327,
11942,
26,
949,
8486,
272,
492,
3105,
63,
13951,
221,
327,
8151,
26,
644,
5067,
23404,
272,
687,
1639,
14,
2190,
14,
3603,
14,
1986,
492,
2955,
221,
327,
8151,
26,
644,
5067,
23404,
339,
26177,
275,
359,
267,
327,
10867,
2488,
1454,
370,
1639,
13,
1757,
13,
13951,
26,
267,
931,
10714,
1757,
363,
3678,
2387,
8,
1757,
63,
13951,
14,
3603,
1826,
221,
327,
8151,
26,
577,
42,
1717,
272,
1622,
435,
26177,
435,
2955,
8,
221,
327,
730,
26,
3686,
267,
327,
3739,
4007,
5898,
1584,
315,
16367,
1454,
26,
267,
2202,
14,
13669,
63,
2632,
12,
267,
2213,
63,
1231,
29,
1751,
14,
13669,
63,
5441,
12,
272,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
199,
6756,
2851,
4412,
2897,
570,
14,
199,
199,
7826,
1163,
2851,
714,
2319,
687,
5957,
8686,
1808,
1083,
658,
2613,
25593,
199,
199,
7940,
365,
2597,
282,
6954,
24471,
370,
4215,
282,
2849,
2851,
370,
314,
1738,
1478,
2034,
14,
199,
199,
2765,
7251,
4440,
5634,
1159,
849,
5898,
199,
1725,
22701,
32414,
315,
16367,
14,
199,
624,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
492,
4628,
199,
504,
1639,
14,
2828,
14,
14464,
688,
14851,
492,
8187,
465,
1503,
77,
688,
14851,
63,
3603,
199,
504,
1639,
14,
3603,
492,
2387,
12,
931,
199,
504,
1639,
14,
4196,
14,
6767,
492,
5458,
2768,
199,
504,
13822,
63,
1074,
492,
8187,
465,
13822,
63,
3603,
199,
199,
504,
1654,
14,
5181,
14,
973,
492,
8187,
465,
2446,
63,
3603,
199,
504,
1654,
14,
5181,
14,
973,
14,
4196,
492,
1478,
199,
199,
2113,
14,
2495,
18861,
342,
199,
199,
20050,
275,
359,
272,
327,
4693,
83,
26,
272,
931,
360,
973,
3678,
2387,
8,
973,
63,
3603,
12,
3231,
534,
973,
3855,
339,
327,
5311,
6130,
5920,
26,
272,
931,
360,
9665,
3678,
2387,
8,
9665,
63,
3603,
1826,
221,
327,
8151,
26,
577,
42,
1717,
339,
327,
1639,
13,
2113,
26,
272,
931,
360,
2113,
15,
1301,
3678,
2387,
8,
14464,
688,
14851,
63,
3603,
1826,
221,
327,
8151,
26,
577,
42,
1717,
272,
931,
360,
2113,
3678,
4628,
14,
2124,
14,
3603,
395,
339,
327,
4516,
436,
2748,
2955,
1584,
26,
272,
931,
360,
28889,
14,
2424,
297,
5458,
2768,
14,
305,
63,
1345,
8,
267,
1978,
63,
354,
534,
2424,
15,
28889,
14,
2424,
297,
267,
1564,
63,
466,
534,
505,
15,
6104,
297,
272,
22583,
272,
931,
360,
72,
453,
796,
14,
2424,
297,
5458,
2768,
14,
305,
63,
1345,
8,
267,
1978,
63,
354,
534,
2424,
15,
72,
453,
796,
14,
2424,
297,
267,
1564,
63,
466,
534,
505,
15,
6104,
297,
272,
22583,
339,
327,
2779,
365,
282,
6954,
24471,
370,
1172,
5027,
1478,
2455,
26,
272,
931,
8594,
1478,
12,
536,
534,
1080,
659,
199,
61,
199,
199,
692,
2202,
14,
5287,
26,
221,
327,
11942,
26,
949,
8486,
272,
492,
3105,
63,
13951,
221,
327,
8151,
26,
644,
5067,
23404,
272,
687,
1639,
14,
2190,
14,
3603,
14,
1986,
492,
2955,
221,
327,
8151,
26,
644,
5067,
23404,
339,
26177,
275,
359,
267,
327,
10867,
2488,
1454,
370,
1639,
13,
1757,
13,
13951,
26,
267,
931,
10714,
1757,
363,
3678,
2387,
8,
1757,
63,
13951,
14,
3603,
1826,
221,
327,
8151,
26,
577,
42,
1717,
272,
1622,
435,
26177,
435,
2955,
8,
221,
327,
730,
26,
3686,
267,
327,
3739,
4007,
5898,
1584,
315,
16367,
1454,
26,
267,
2202,
14,
13669,
63,
2632,
12,
267,
2213,
63,
1231,
29,
1751,
14,
13669,
63,
5441,
12,
272,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
wweiradio/django
|
django/contrib/gis/gdal/raster/band.py
|
308
|
5382
|
from ctypes import byref, c_int
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.prototypes import raster as capi
from django.contrib.gis.shortcuts import numpy
from django.utils import six
from django.utils.encoding import force_text
from django.utils.six.moves import range
from .const import GDAL_INTEGER_TYPES, GDAL_PIXEL_TYPES, GDAL_TO_CTYPES
class GDALBand(GDALBase):
"""
Wraps a GDAL raster band, needs to be obtained from a GDALRaster object.
"""
def __init__(self, source, index):
self.source = source
self._ptr = capi.get_ds_raster_band(source._ptr, index)
@property
def description(self):
"""
Returns the description string of the band.
"""
return force_text(capi.get_band_description(self._ptr))
@property
def width(self):
"""
Width (X axis) in pixels of the band.
"""
return capi.get_band_xsize(self._ptr)
@property
def height(self):
"""
Height (Y axis) in pixels of the band.
"""
return capi.get_band_ysize(self._ptr)
@property
def pixel_count(self):
"""
Returns the total number of pixels in this band.
"""
return self.width * self.height
@property
def min(self):
"""
Returns the minimum pixel value for this band.
"""
return capi.get_band_minimum(self._ptr, byref(c_int()))
@property
def max(self):
"""
Returns the maximum pixel value for this band.
"""
return capi.get_band_maximum(self._ptr, byref(c_int()))
@property
def nodata_value(self):
"""
Returns the nodata value for this band, or None if it isn't set.
"""
# Get value and nodata exists flag
nodata_exists = c_int()
value = capi.get_band_nodata_value(self._ptr, nodata_exists)
if not nodata_exists:
value = None
# If the pixeltype is an integer, convert to int
elif self.datatype() in GDAL_INTEGER_TYPES:
value = int(value)
return value
@nodata_value.setter
def nodata_value(self, value):
"""
Sets the nodata value for this band.
"""
if not isinstance(value, (int, float)):
raise ValueError('Nodata value must be numeric.')
capi.set_band_nodata_value(self._ptr, value)
self.source._flush()
def datatype(self, as_string=False):
"""
Returns the GDAL Pixel Datatype for this band.
"""
dtype = capi.get_band_datatype(self._ptr)
if as_string:
dtype = GDAL_PIXEL_TYPES[dtype]
return dtype
def data(self, data=None, offset=None, size=None, as_memoryview=False):
"""
Reads or writes pixel values for this band. Blocks of data can
be accessed by specifying the width, height and offset of the
desired block. The same specification can be used to update
parts of a raster by providing an array of values.
Allowed input data types are bytes, memoryview, list, tuple, and array.
"""
if not offset:
offset = (0, 0)
if not size:
size = (self.width - offset[0], self.height - offset[1])
if any(x <= 0 for x in size):
raise ValueError('Offset too big for this raster.')
if size[0] > self.width or size[1] > self.height:
raise ValueError('Size is larger than raster.')
# Create ctypes type array generator
ctypes_array = GDAL_TO_CTYPES[self.datatype()] * (size[0] * size[1])
if data is None:
# Set read mode
access_flag = 0
# Prepare empty ctypes array
data_array = ctypes_array()
else:
# Set write mode
access_flag = 1
# Instantiate ctypes array holding the input data
if isinstance(data, (bytes, six.memoryview)) or (numpy and isinstance(data, numpy.ndarray)):
data_array = ctypes_array.from_buffer_copy(data)
else:
data_array = ctypes_array(*data)
# Access band
capi.band_io(self._ptr, access_flag, offset[0], offset[1],
size[0], size[1], byref(data_array), size[0],
size[1], self.datatype(), 0, 0)
# Return data as numpy array if possible, otherwise as list
if data is None:
if as_memoryview:
return memoryview(data_array)
elif numpy:
return numpy.frombuffer(
data_array, dtype=numpy.dtype(data_array)).reshape(size)
else:
return list(data_array)
else:
self.source._flush()
class BandList(list):
def __init__(self, source):
self.source = source
list.__init__(self)
def __iter__(self):
for idx in range(1, len(self) + 1):
yield GDALBand(self.source, idx)
def __len__(self):
return capi.get_ds_raster_count(self.source._ptr)
def __getitem__(self, index):
try:
return GDALBand(self.source, index + 1)
except GDALException:
raise GDALException('Unable to get band index %d' % index)
|
bsd-3-clause
|
[
504,
5577,
492,
15968,
12,
286,
63,
442,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1095,
492,
15801,
1563,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
705,
492,
15801,
1726,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
16141,
83,
492,
19775,
465,
13648,
199,
504,
1639,
14,
2828,
14,
5668,
14,
17469,
492,
2680,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
199,
199,
504,
1275,
1297,
492,
15801,
63,
9596,
63,
7893,
12,
15801,
63,
23357,
63,
7893,
12,
15801,
63,
2566,
63,
1028,
24583,
421,
199,
533,
15801,
11675,
8,
17835,
1563,
304,
272,
408,
272,
644,
8146,
282,
15801,
19775,
10981,
12,
4839,
370,
506,
15884,
687,
282,
15801,
13284,
909,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1350,
12,
1478,
304,
267,
291,
14,
1365,
275,
1350,
267,
291,
423,
4695,
275,
13648,
14,
362,
63,
795,
63,
20876,
63,
7877,
8,
1365,
423,
4695,
12,
1478,
9,
339,
768,
1829,
272,
347,
1369,
8,
277,
304,
267,
408,
267,
1803,
314,
1369,
1059,
402,
314,
10981,
14,
267,
408,
267,
372,
3542,
63,
505,
8,
14145,
14,
362,
63,
7877,
63,
1802,
8,
277,
423,
4695,
430,
339,
768,
1829,
272,
347,
3462,
8,
277,
304,
267,
408,
267,
644,
1466,
334,
56,
3114,
9,
315,
11094,
402,
314,
10981,
14,
267,
408,
267,
372,
13648,
14,
362,
63,
7877,
63,
88,
890,
8,
277,
423,
4695,
9,
339,
768,
1829,
272,
347,
4569,
8,
277,
304,
267,
408,
267,
5311,
1070,
334,
57,
3114,
9,
315,
11094,
402,
314,
10981,
14,
267,
408,
267,
372,
13648,
14,
362,
63,
7877,
63,
89,
890,
8,
277,
423,
4695,
9,
339,
768,
1829,
272,
347,
7148,
63,
835,
8,
277,
304,
267,
408,
267,
1803,
314,
3141,
1329,
402,
11094,
315,
642,
10981,
14,
267,
408,
267,
372,
291,
14,
2063,
627,
291,
14,
3333,
339,
768,
1829,
272,
347,
1748,
8,
277,
304,
267,
408,
267,
1803,
314,
7481,
7148,
574,
367,
642,
10981,
14,
267,
408,
267,
372,
13648,
14,
362,
63,
7877,
63,
10700,
8,
277,
423,
4695,
12,
15968,
8,
67,
63,
442,
4059,
339,
768,
1829,
272,
347,
1390,
8,
277,
304,
267,
408,
267,
1803,
314,
5696,
7148,
574,
367,
642,
10981,
14,
267,
408,
267,
372,
13648,
14,
362,
63,
7877,
63,
11555,
8,
277,
423,
4695,
12,
15968,
8,
67,
63,
442,
4059,
339,
768,
1829,
272,
347,
302,
22971,
63,
585,
8,
277,
304,
267,
408,
267,
1803,
314,
302,
22971,
574,
367,
642,
10981,
12,
503,
488,
340,
652,
5712,
1133,
663,
14,
267,
408,
267,
327,
2372,
574,
436,
302,
22971,
3495,
3305,
267,
302,
22971,
63,
2444,
275,
286,
63,
442,
342,
267,
574,
275,
13648,
14,
362,
63,
7877,
63,
18950,
419,
63,
585,
8,
277,
423,
4695,
12,
302,
22971,
63,
2444,
9,
267,
340,
440,
302,
22971,
63,
2444,
26,
288,
574,
275,
488,
267,
327,
982,
314,
7148,
466,
365,
376,
3000,
12,
3957,
370,
1109,
267,
916,
291,
14,
14184,
342,
315,
15801,
63,
9596,
63,
7893,
26,
288,
574,
275,
1109,
8,
585,
9,
267,
372,
574,
339,
768,
18950,
419,
63,
585,
14,
8345,
272,
347,
302,
22971,
63,
585,
8,
277,
12,
574,
304,
267,
408,
267,
10729,
314,
302,
22971,
574,
367,
642,
10981,
14,
267,
408,
267,
340,
440,
1228,
8,
585,
12,
334,
442,
12,
2069,
2298,
288,
746,
1722,
360,
46,
22971,
574,
1471,
506,
8950,
2659,
267,
13648,
14,
409,
63,
7877,
63,
18950,
419,
63,
585,
8,
277,
423,
4695,
12,
574,
9,
267,
291,
14,
1365,
423,
4939,
342,
339,
347,
16048,
8,
277,
12,
465,
63,
875,
29,
797,
304,
267,
408,
267,
1803,
314,
15801,
510,
5887,
577,
292,
8588,
367,
642,
10981,
14,
267,
408,
267,
2152,
275,
13648,
14,
362,
63,
7877,
63,
14184,
8,
277,
423,
4695,
9,
267,
340,
465,
63,
875,
26,
288,
2152,
275,
15801,
63,
23357,
63,
7893,
59,
2271,
61,
267,
372,
2152,
339,
347,
666,
8,
277,
12,
666,
29,
403,
12,
3268,
29,
403,
12,
1568,
29,
403,
12,
465,
63,
31519,
29,
797,
304,
267,
408,
267,
26129,
503,
14511,
7148,
1338,
367,
642,
10981,
14,
8651,
83,
402,
666,
883,
267,
506,
13810,
701,
9176,
314,
3462,
12,
4569,
436,
3268,
402,
314,
267,
6387,
1853,
14,
710,
2011,
8929,
883,
506,
1202,
370,
1678,
267,
4184,
402,
282,
19775,
701,
13070,
376,
1625,
402,
1338,
14,
398,
27301,
1324,
666,
2943,
787,
2783,
12,
20228,
12,
769,
12,
2008,
12,
436,
1625,
14,
267,
408,
267,
340,
440,
3268,
26,
288,
3268,
275,
334,
16,
12,
378,
9,
398,
340,
440,
1568,
26,
288,
1568,
275,
334,
277,
14,
2063,
446,
3268,
59,
16,
467,
291,
14,
3333,
446,
3268,
59,
17,
566,
398,
340,
1263,
8,
88,
2695,
378,
367,
671,
315,
1568,
304,
288,
746,
1722,
360,
6397,
4634,
7282,
367,
642,
19775,
2659,
398,
340,
1568,
59,
16,
61,
690,
291,
14,
2063,
503,
1568,
59,
17,
61,
690,
291,
14,
3333,
26,
288,
746,
1722,
360,
2320,
365,
12142,
2419,
19775,
2659,
398,
327,
2790,
5577,
730,
1625,
4306,
267,
5577,
63,
1144,
275,
15801,
63,
2566,
63,
1028,
24583,
59,
277,
14,
14184,
5106,
627,
334,
890,
59,
16,
61,
627,
1568,
59,
17,
566,
398,
340,
666,
365,
488,
26,
288,
327,
2494,
1586,
818,
288,
2879,
63,
4173,
275,
378,
288,
327,
17008,
2701,
5577,
1625,
288,
666,
63,
1144,
275,
5577,
63,
1144,
342,
267,
587,
26,
288,
327,
2494,
2218,
818,
288,
2879,
63,
4173,
275,
413,
953,
327,
32092,
5577,
1625,
17573,
314,
1324,
666,
288,
340,
1228,
8,
576,
12,
334,
2394,
12,
3816,
14,
31519,
430,
503,
334,
4714,
436,
1228,
8,
576,
12,
2680,
14,
8237,
2298,
355,
666,
63,
1144,
275,
5577,
63,
1144,
14,
504,
63,
2738,
63,
1574,
8,
576,
9,
288,
587,
26,
355,
666,
63,
1144
] |
[
5577,
492,
15968,
12,
286,
63,
442,
199,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
1095,
492,
15801,
1563,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
705,
492,
15801,
1726,
199,
504,
1639,
14,
2828,
14,
5668,
14,
11600,
14,
16141,
83,
492,
19775,
465,
13648,
199,
504,
1639,
14,
2828,
14,
5668,
14,
17469,
492,
2680,
199,
504,
1639,
14,
1208,
492,
3816,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
505,
199,
504,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
1425,
199,
199,
504,
1275,
1297,
492,
15801,
63,
9596,
63,
7893,
12,
15801,
63,
23357,
63,
7893,
12,
15801,
63,
2566,
63,
1028,
24583,
421,
199,
533,
15801,
11675,
8,
17835,
1563,
304,
272,
408,
272,
644,
8146,
282,
15801,
19775,
10981,
12,
4839,
370,
506,
15884,
687,
282,
15801,
13284,
909,
14,
272,
408,
272,
347,
636,
826,
721,
277,
12,
1350,
12,
1478,
304,
267,
291,
14,
1365,
275,
1350,
267,
291,
423,
4695,
275,
13648,
14,
362,
63,
795,
63,
20876,
63,
7877,
8,
1365,
423,
4695,
12,
1478,
9,
339,
768,
1829,
272,
347,
1369,
8,
277,
304,
267,
408,
267,
1803,
314,
1369,
1059,
402,
314,
10981,
14,
267,
408,
267,
372,
3542,
63,
505,
8,
14145,
14,
362,
63,
7877,
63,
1802,
8,
277,
423,
4695,
430,
339,
768,
1829,
272,
347,
3462,
8,
277,
304,
267,
408,
267,
644,
1466,
334,
56,
3114,
9,
315,
11094,
402,
314,
10981,
14,
267,
408,
267,
372,
13648,
14,
362,
63,
7877,
63,
88,
890,
8,
277,
423,
4695,
9,
339,
768,
1829,
272,
347,
4569,
8,
277,
304,
267,
408,
267,
5311,
1070,
334,
57,
3114,
9,
315,
11094,
402,
314,
10981,
14,
267,
408,
267,
372,
13648,
14,
362,
63,
7877,
63,
89,
890,
8,
277,
423,
4695,
9,
339,
768,
1829,
272,
347,
7148,
63,
835,
8,
277,
304,
267,
408,
267,
1803,
314,
3141,
1329,
402,
11094,
315,
642,
10981,
14,
267,
408,
267,
372,
291,
14,
2063,
627,
291,
14,
3333,
339,
768,
1829,
272,
347,
1748,
8,
277,
304,
267,
408,
267,
1803,
314,
7481,
7148,
574,
367,
642,
10981,
14,
267,
408,
267,
372,
13648,
14,
362,
63,
7877,
63,
10700,
8,
277,
423,
4695,
12,
15968,
8,
67,
63,
442,
4059,
339,
768,
1829,
272,
347,
1390,
8,
277,
304,
267,
408,
267,
1803,
314,
5696,
7148,
574,
367,
642,
10981,
14,
267,
408,
267,
372,
13648,
14,
362,
63,
7877,
63,
11555,
8,
277,
423,
4695,
12,
15968,
8,
67,
63,
442,
4059,
339,
768,
1829,
272,
347,
302,
22971,
63,
585,
8,
277,
304,
267,
408,
267,
1803,
314,
302,
22971,
574,
367,
642,
10981,
12,
503,
488,
340,
652,
5712,
1133,
663,
14,
267,
408,
267,
327,
2372,
574,
436,
302,
22971,
3495,
3305,
267,
302,
22971,
63,
2444,
275,
286,
63,
442,
342,
267,
574,
275,
13648,
14,
362,
63,
7877,
63,
18950,
419,
63,
585,
8,
277,
423,
4695,
12,
302,
22971,
63,
2444,
9,
267,
340,
440,
302,
22971,
63,
2444,
26,
288,
574,
275,
488,
267,
327,
982,
314,
7148,
466,
365,
376,
3000,
12,
3957,
370,
1109,
267,
916,
291,
14,
14184,
342,
315,
15801,
63,
9596,
63,
7893,
26,
288,
574,
275,
1109,
8,
585,
9,
267,
372,
574,
339,
768,
18950,
419,
63,
585,
14,
8345,
272,
347,
302,
22971,
63,
585,
8,
277,
12,
574,
304,
267,
408,
267,
10729,
314,
302,
22971,
574,
367,
642,
10981,
14,
267,
408,
267,
340,
440,
1228,
8,
585,
12,
334,
442,
12,
2069,
2298,
288,
746,
1722,
360,
46,
22971,
574,
1471,
506,
8950,
2659,
267,
13648,
14,
409,
63,
7877,
63,
18950,
419,
63,
585,
8,
277,
423,
4695,
12,
574,
9,
267,
291,
14,
1365,
423,
4939,
342,
339,
347,
16048,
8,
277,
12,
465,
63,
875,
29,
797,
304,
267,
408,
267,
1803,
314,
15801,
510,
5887,
577,
292,
8588,
367,
642,
10981,
14,
267,
408,
267,
2152,
275,
13648,
14,
362,
63,
7877,
63,
14184,
8,
277,
423,
4695,
9,
267,
340,
465,
63,
875,
26,
288,
2152,
275,
15801,
63,
23357,
63,
7893,
59,
2271,
61,
267,
372,
2152,
339,
347,
666,
8,
277,
12,
666,
29,
403,
12,
3268,
29,
403,
12,
1568,
29,
403,
12,
465,
63,
31519,
29,
797,
304,
267,
408,
267,
26129,
503,
14511,
7148,
1338,
367,
642,
10981,
14,
8651,
83,
402,
666,
883,
267,
506,
13810,
701,
9176,
314,
3462,
12,
4569,
436,
3268,
402,
314,
267,
6387,
1853,
14,
710,
2011,
8929,
883,
506,
1202,
370,
1678,
267,
4184,
402,
282,
19775,
701,
13070,
376,
1625,
402,
1338,
14,
398,
27301,
1324,
666,
2943,
787,
2783,
12,
20228,
12,
769,
12,
2008,
12,
436,
1625,
14,
267,
408,
267,
340,
440,
3268,
26,
288,
3268,
275,
334,
16,
12,
378,
9,
398,
340,
440,
1568,
26,
288,
1568,
275,
334,
277,
14,
2063,
446,
3268,
59,
16,
467,
291,
14,
3333,
446,
3268,
59,
17,
566,
398,
340,
1263,
8,
88,
2695,
378,
367,
671,
315,
1568,
304,
288,
746,
1722,
360,
6397,
4634,
7282,
367,
642,
19775,
2659,
398,
340,
1568,
59,
16,
61,
690,
291,
14,
2063,
503,
1568,
59,
17,
61,
690,
291,
14,
3333,
26,
288,
746,
1722,
360,
2320,
365,
12142,
2419,
19775,
2659,
398,
327,
2790,
5577,
730,
1625,
4306,
267,
5577,
63,
1144,
275,
15801,
63,
2566,
63,
1028,
24583,
59,
277,
14,
14184,
5106,
627,
334,
890,
59,
16,
61,
627,
1568,
59,
17,
566,
398,
340,
666,
365,
488,
26,
288,
327,
2494,
1586,
818,
288,
2879,
63,
4173,
275,
378,
288,
327,
17008,
2701,
5577,
1625,
288,
666,
63,
1144,
275,
5577,
63,
1144,
342,
267,
587,
26,
288,
327,
2494,
2218,
818,
288,
2879,
63,
4173,
275,
413,
953,
327,
32092,
5577,
1625,
17573,
314,
1324,
666,
288,
340,
1228,
8,
576,
12,
334,
2394,
12,
3816,
14,
31519,
430,
503,
334,
4714,
436,
1228,
8,
576,
12,
2680,
14,
8237,
2298,
355,
666,
63,
1144,
275,
5577,
63,
1144,
14,
504,
63,
2738,
63,
1574,
8,
576,
9,
288,
587,
26,
355,
666,
63,
1144,
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,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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
] |
ax003d/openerp
|
openerp/addons/mail/report/__init__.py
|
438
|
1057
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2009-Today 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/>.
#
##############################################################################
# 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,
8937,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
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,
421,
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,
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,
8937,
13,
31982,
7653,
13950,
8642,
1014,
921,
1544,
14,
11267,
14,
957,
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,
421,
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,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
BIT-SYS/gem5-spm-module
|
src/arch/x86/isa/insts/simd128/integer/data_reordering/extract_and_insert.py
|
91
|
2838
|
# Copyright (c) 2007 The Hewlett-Packard Development Company
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual
# property including but not limited to intellectual property relating
# to a hardware implementation of the functionality of the software
# licensed hereunder. You may use the software subject to the license
# terms below provided that you ensure that this notice is replicated
# unmodified and in its entirety in all distributions of the software,
# modified or unmodified, in source code or in binary form.
#
# 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 copyright holders 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.
#
# Authors: Gabe Black
microcode = '''
def macroop PEXTRW_R_XMM_I {
mov2int reg, xmmlm, "IMMEDIATE & mask(3)", size=2, ext=1
mov2int reg, xmmhm, "IMMEDIATE & mask(3)", size=2, ext=1
};
def macroop PINSRW_XMM_R_I {
mov2fp xmml, regm, "IMMEDIATE & mask(3)", size=2, ext=1
mov2fp xmmh, regm, "IMMEDIATE & mask(3)", size=2, ext=1
};
def macroop PINSRW_XMM_M_I {
ld t1, seg, sib, disp, dataSize=2
mov2fp xmml, t1, "IMMEDIATE & mask(3)", size=2, ext=1
mov2fp xmmh, t1, "IMMEDIATE & mask(3)", size=2, ext=1
};
def macroop PINSRW_XMM_P_I {
rdip t7
ld t1, seg, riprel, disp, dataSize=2
mov2fp xmml, t1, "IMMEDIATE & mask(3)", size=2, ext=1
mov2fp xmmh, t1, "IMMEDIATE & mask(3)", size=2, ext=1
};
'''
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
10219,
710,
27849,
13,
29471,
15290,
15878,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
710,
4190,
5084,
16879,
1454,
370,
4248,
315,
314,
2032,
436,
10989,
199,
3,
440,
506,
950,
431,
68,
465,
16085,
316,
282,
4190,
370,
1263,
1163,
27925,
1264,
1061,
199,
3,
3324,
5893,
1325,
440,
13988,
370,
27925,
1264,
1061,
3324,
4668,
1958,
199,
3,
370,
282,
14991,
4514,
402,
314,
9330,
402,
314,
2032,
199,
3,
18233,
2348,
7138,
14,
221,
2047,
1443,
675,
314,
2032,
5420,
370,
314,
4190,
199,
3,
2895,
5084,
2741,
626,
1265,
4868,
626,
642,
4245,
365,
32436,
199,
3,
24214,
436,
315,
2399,
8039,
369,
315,
1006,
10208,
402,
314,
2032,
12,
199,
3,
6042,
503,
24214,
12,
315,
1350,
1233,
503,
315,
3366,
1824,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
26771,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
27,
199,
3,
26771,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
27,
199,
3,
15564,
314,
536,
402,
314,
4248,
31976,
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,
3,
199,
3,
6642,
26,
598,
7570,
30593,
199,
199,
6453,
600,
275,
1449,
199,
318,
21308,
510,
1438,
1766,
55,
63,
50,
63,
19439,
63,
41,
469,
272,
26524,
18,
442,
1295,
12,
18286,
14344,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
272,
26524,
18,
442,
1295,
12,
18286,
14038,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
199,
12084,
199,
199,
318,
21308,
510,
568,
5943,
55,
63,
19439,
63,
50,
63,
41,
469,
272,
26524,
18,
3997,
18286,
76,
12,
1295,
77,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
272,
26524,
18,
3997,
18286,
72,
12,
1295,
77,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
199,
12084,
199,
199,
318,
21308,
510,
568,
5943,
55,
63,
19439,
63,
45,
63,
41,
469,
272,
8827,
307,
17,
12,
8812,
12,
20417,
12,
9628,
12,
18252,
29,
18,
272,
26524,
18,
3997,
18286,
76,
12,
307,
17,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
272,
26524,
18,
3997,
18286,
72,
12,
307,
17,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
199,
12084,
199,
199,
318,
21308,
510,
568,
5943,
55,
63,
19439,
63,
48,
63,
41,
469,
272,
519,
21846,
307,
23,
272,
8827,
307,
17,
12,
8812,
12,
8012,
30788,
12,
9628,
12,
18252,
29,
18,
272,
26524,
18,
3997,
18286,
76,
12,
307,
17,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
272,
26524,
18,
3997,
18286,
72,
12,
307,
17,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
199,
12084,
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
] |
[
1898,
334,
67,
9,
10219,
710,
27849,
13,
29471,
15290,
15878,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
710,
4190,
5084,
16879,
1454,
370,
4248,
315,
314,
2032,
436,
10989,
199,
3,
440,
506,
950,
431,
68,
465,
16085,
316,
282,
4190,
370,
1263,
1163,
27925,
1264,
1061,
199,
3,
3324,
5893,
1325,
440,
13988,
370,
27925,
1264,
1061,
3324,
4668,
1958,
199,
3,
370,
282,
14991,
4514,
402,
314,
9330,
402,
314,
2032,
199,
3,
18233,
2348,
7138,
14,
221,
2047,
1443,
675,
314,
2032,
5420,
370,
314,
4190,
199,
3,
2895,
5084,
2741,
626,
1265,
4868,
626,
642,
4245,
365,
32436,
199,
3,
24214,
436,
315,
2399,
8039,
369,
315,
1006,
10208,
402,
314,
2032,
12,
199,
3,
6042,
503,
24214,
12,
315,
1350,
1233,
503,
315,
3366,
1824,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
26771,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
27,
199,
3,
26771,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
27,
199,
3,
15564,
314,
536,
402,
314,
4248,
31976,
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,
3,
199,
3,
6642,
26,
598,
7570,
30593,
199,
199,
6453,
600,
275,
1449,
199,
318,
21308,
510,
1438,
1766,
55,
63,
50,
63,
19439,
63,
41,
469,
272,
26524,
18,
442,
1295,
12,
18286,
14344,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
272,
26524,
18,
442,
1295,
12,
18286,
14038,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
199,
12084,
199,
199,
318,
21308,
510,
568,
5943,
55,
63,
19439,
63,
50,
63,
41,
469,
272,
26524,
18,
3997,
18286,
76,
12,
1295,
77,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
272,
26524,
18,
3997,
18286,
72,
12,
1295,
77,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
199,
12084,
199,
199,
318,
21308,
510,
568,
5943,
55,
63,
19439,
63,
45,
63,
41,
469,
272,
8827,
307,
17,
12,
8812,
12,
20417,
12,
9628,
12,
18252,
29,
18,
272,
26524,
18,
3997,
18286,
76,
12,
307,
17,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
272,
26524,
18,
3997,
18286,
72,
12,
307,
17,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
199,
12084,
199,
199,
318,
21308,
510,
568,
5943,
55,
63,
19439,
63,
48,
63,
41,
469,
272,
519,
21846,
307,
23,
272,
8827,
307,
17,
12,
8812,
12,
8012,
30788,
12,
9628,
12,
18252,
29,
18,
272,
26524,
18,
3997,
18286,
76,
12,
307,
17,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
272,
26524,
18,
3997,
18286,
72,
12,
307,
17,
12,
298,
1469,
19464,
1253,
3656,
8,
19,
4186,
1568,
29,
18,
12,
1599,
29,
17,
199,
12084,
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,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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
] |
andrius-preimantas/odoo
|
openerp/addons/base/res/res_config.py
|
69
|
30886
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 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 logging
from operator import attrgetter
import re
import openerp
from openerp import SUPERUSER_ID
from openerp.osv import osv, fields
from openerp.tools import ustr
from openerp.tools.translate import _
from openerp import exceptions
from lxml import etree
_logger = logging.getLogger(__name__)
class res_config_module_installation_mixin(object):
def _install_modules(self, cr, uid, modules, context):
"""Install the requested modules.
return the next action to execute
modules is a list of tuples
(mod_name, browse_record | None)
"""
ir_module = self.pool.get('ir.module.module')
to_install_ids = []
to_install_missing_names = []
for name, module in modules:
if not module:
to_install_missing_names.append(name)
elif module.state == 'uninstalled':
to_install_ids.append(module.id)
result = None
if to_install_ids:
result = ir_module.button_immediate_install(cr, uid, to_install_ids, context=context)
#FIXME: if result is not none, the corresponding todo will be skipped because it was just marked done
if to_install_missing_names:
return {
'type': 'ir.actions.client',
'tag': 'apps',
'params': {'modules': to_install_missing_names},
}
return result
class res_config_configurable(osv.osv_memory):
''' Base classes for new-style configuration items
Configuration items should inherit from this class, implement
the execute method (and optionally the cancel one) and have
their view inherit from the related res_config_view_base view.
'''
_name = 'res.config'
def _next_action(self, cr, uid, context=None):
Todos = self.pool['ir.actions.todo']
_logger.info('getting next %s', Todos)
active_todos = Todos.browse(cr, uid,
Todos.search(cr, uid, ['&', ('type', '=', 'automatic'), ('state','=','open')]),
context=context)
user_groups = set(map(
lambda g: g.id,
self.pool['res.users'].browse(cr, uid, [uid], context=context)[0].groups_id))
valid_todos_for_user = [
todo for todo in active_todos
if not todo.groups_id or bool(user_groups.intersection((
group.id for group in todo.groups_id)))
]
if valid_todos_for_user:
return valid_todos_for_user[0]
return None
def _next(self, cr, uid, context=None):
_logger.info('getting next operation')
next = self._next_action(cr, uid, context=context)
_logger.info('next action is %s', next)
if next:
res = next.action_launch(context=context)
res['nodestroy'] = False
return res
return {
'type': 'ir.actions.client',
'tag': 'reload',
}
def start(self, cr, uid, ids, context=None):
return self.next(cr, uid, ids, context)
def next(self, cr, uid, ids, context=None):
""" Returns the next todo action to execute (using the default
sort order)
"""
return self._next(cr, uid, context=context)
def execute(self, cr, uid, ids, context=None):
""" Method called when the user clicks on the ``Next`` button.
Execute *must* be overloaded unless ``action_next`` is overloaded
(which is something you generally don't need to do).
If ``execute`` returns an action dictionary, that action is executed
rather than just going to the next configuration item.
"""
raise NotImplementedError(
'Configuration items need to implement execute')
def cancel(self, cr, uid, ids, context=None):
""" Method called when the user click on the ``Skip`` button.
``cancel`` should be overloaded instead of ``action_skip``. As with
``execute``, if it returns an action dictionary that action is
executed in stead of the default (going to the next configuration item)
The default implementation is a NOOP.
``cancel`` is also called by the default implementation of
``action_cancel``.
"""
pass
def action_next(self, cr, uid, ids, context=None):
""" Action handler for the ``next`` event.
Sets the status of the todo the event was sent from to
``done``, calls ``execute`` and -- unless ``execute`` returned
an action dictionary -- executes the action provided by calling
``next``.
"""
next = self.execute(cr, uid, ids, context=context)
if next: return next
return self.next(cr, uid, ids, context=context)
def action_skip(self, cr, uid, ids, context=None):
""" Action handler for the ``skip`` event.
Sets the status of the todo the event was sent from to
``skip``, calls ``cancel`` and -- unless ``cancel`` returned
an action dictionary -- executes the action provided by calling
``next``.
"""
next = self.cancel(cr, uid, ids, context=context)
if next: return next
return self.next(cr, uid, ids, context=context)
def action_cancel(self, cr, uid, ids, context=None):
""" Action handler for the ``cancel`` event. That event isn't
generated by the res.config.view.base inheritable view, the
inherited view has to overload one of the buttons (or add one
more).
Sets the status of the todo the event was sent from to
``cancel``, calls ``cancel`` and -- unless ``cancel`` returned
an action dictionary -- executes the action provided by calling
``next``.
"""
next = self.cancel(cr, uid, ids, context=context)
if next: return next
return self.next(cr, uid, ids, context=context)
class res_config_installer(osv.osv_memory, res_config_module_installation_mixin):
""" New-style configuration base specialized for addons selection
and installation.
Basic usage
-----------
Subclasses can simply define a number of _columns as
fields.boolean objects. The keys (column names) should be the
names of the addons to install (when selected). Upon action
execution, selected boolean fields (and those only) will be
interpreted as addons to install, and batch-installed.
Additional addons
-----------------
It is also possible to require the installation of an additional
addon set when a specific preset of addons has been marked for
installation (in the basic usage only, additionals can't depend on
one another).
These additionals are defined through the ``_install_if``
property. This property is a mapping of a collection of addons (by
name) to a collection of addons (by name) [#]_, and if all the *key*
addons are selected for installation, then the *value* ones will
be selected as well. For example::
_install_if = {
('sale','crm'): ['sale_crm'],
}
This will install the ``sale_crm`` addon if and only if both the
``sale`` and ``crm`` addons are selected for installation.
You can define as many additionals as you wish, and additionals
can overlap in key and value. For instance::
_install_if = {
('sale','crm'): ['sale_crm'],
('sale','project'): ['sale_service'],
}
will install both ``sale_crm`` and ``sale_service`` if all of
``sale``, ``crm`` and ``project`` are selected for installation.
Hook methods
------------
Subclasses might also need to express dependencies more complex
than that provided by additionals. In this case, it's possible to
define methods of the form ``_if_%(name)s`` where ``name`` is the
name of a boolean field. If the field is selected, then the
corresponding module will be marked for installation *and* the
hook method will be executed.
Hook methods take the usual set of parameters (cr, uid, ids,
context) and can return a collection of additional addons to
install (if they return anything, otherwise they should not return
anything, though returning any "falsy" value such as None or an
empty collection will have the same effect).
Complete control
----------------
The last hook is to simply overload the ``modules_to_install``
method, which implements all the mechanisms above. This method
takes the usual set of parameters (cr, uid, ids, context) and
returns a ``set`` of addons to install (addons selected by the
above methods minus addons from the *basic* set which are already
installed) [#]_ so an overloader can simply manipulate the ``set``
returned by ``res_config_installer.modules_to_install`` to add or
remove addons.
Skipping the installer
----------------------
Unless it is removed from the view, installers have a *skip*
button which invokes ``action_skip`` (and the ``cancel`` hook from
``res.config``). Hooks and additionals *are not run* when skipping
installation, even for already installed addons.
Again, setup your hooks accordingly.
.. [#] note that since a mapping key needs to be hashable, it's
possible to use a tuple or a frozenset, but not a list or a
regular set
.. [#] because the already-installed modules are only pruned at
the very end of ``modules_to_install``, additionals and
hooks depending on them *are guaranteed to execute*. Setup
your hooks accordingly.
"""
_name = 'res.config.installer'
_inherit = 'res.config'
_install_if = {}
def already_installed(self, cr, uid, context=None):
""" For each module, check if it's already installed and if it
is return its name
:returns: a list of the already installed modules in this
installer
:rtype: [str]
"""
return map(attrgetter('name'),
self._already_installed(cr, uid, context=context))
def _already_installed(self, cr, uid, context=None):
""" For each module (boolean fields in a res.config.installer),
check if it's already installed (either 'to install', 'to upgrade'
or 'installed') and if it is return the module's record
:returns: a list of all installed modules in this installer
:rtype: recordset (collection of Record)
"""
modules = self.pool['ir.module.module']
selectable = [field for field in self._columns
if type(self._columns[field]) is fields.boolean]
return modules.browse(
cr, uid,
modules.search(cr, uid,
[('name','in',selectable),
('state','in',['to install', 'installed', 'to upgrade'])],
context=context),
context=context)
def modules_to_install(self, cr, uid, ids, context=None):
""" selects all modules to install:
* checked boolean fields
* return values of hook methods. Hook methods are of the form
``_if_%(addon_name)s``, and are called if the corresponding
addon is marked for installation. They take the arguments
cr, uid, ids and context, and return an iterable of addon
names
* additionals, additionals are setup through the ``_install_if``
class variable. ``_install_if`` is a dict of {iterable:iterable}
where key and value are iterables of addon names.
If all the addons in the key are selected for installation
(warning: addons added through hooks don't count), then the
addons in the value are added to the set of modules to install
* not already installed
"""
base = set(module_name
for installer in self.read(cr, uid, ids, context=context)
for module_name, to_install in installer.iteritems()
if module_name != 'id'
if type(self._columns.get(module_name)) is fields.boolean
if to_install)
hooks_results = set()
for module in base:
hook = getattr(self, '_if_%s'% module, None)
if hook:
hooks_results.update(hook(cr, uid, ids, context=None) or set())
additionals = set(
module for requirements, consequences \
in self._install_if.iteritems()
if base.issuperset(requirements)
for module in consequences)
return (base | hooks_results | additionals).difference(
self.already_installed(cr, uid, context))
def default_get(self, cr, uid, fields_list, context=None):
''' If an addon is already installed, check it by default
'''
defaults = super(res_config_installer, self).default_get(
cr, uid, fields_list, context=context)
return dict(defaults,
**dict.fromkeys(
self.already_installed(cr, uid, context=context),
True))
def fields_get(self, cr, uid, fields=None, context=None, write_access=True):
""" If an addon is already installed, set it to readonly as
res.config.installer doesn't handle uninstallations of already
installed addons
"""
fields = super(res_config_installer, self).fields_get(
cr, uid, fields, context, write_access)
for name in self.already_installed(cr, uid, context=context):
if name not in fields:
continue
fields[name].update(
readonly=True,
help= ustr(fields[name].get('help', '')) +
_('\n\nThis addon is already installed on your system'))
return fields
def execute(self, cr, uid, ids, context=None):
to_install = list(self.modules_to_install(
cr, uid, ids, context=context))
_logger.info('Selecting addons %s to install', to_install)
ir_module = self.pool.get('ir.module.module')
modules = []
for name in to_install:
mod_ids = ir_module.search(cr, uid, [('name', '=', name)])
record = ir_module.browse(cr, uid, mod_ids[0], context) if mod_ids else None
modules.append((name, record))
return self._install_modules(cr, uid, modules, context=context)
class res_config_settings(osv.osv_memory, res_config_module_installation_mixin):
""" Base configuration wizard for application settings. It provides support for setting
default values, assigning groups to employee users, and installing modules.
To make such a 'settings' wizard, define a model like::
class my_config_wizard(osv.osv_memory):
_name = 'my.settings'
_inherit = 'res.config.settings'
_columns = {
'default_foo': fields.type(..., default_model='my.model'),
'group_bar': fields.boolean(..., group='base.group_user', implied_group='my.group'),
'module_baz': fields.boolean(...),
'other_field': fields.type(...),
}
The method ``execute`` provides some support based on a naming convention:
* For a field like 'default_XXX', ``execute`` sets the (global) default value of
the field 'XXX' in the model named by ``default_model`` to the field's value.
* For a boolean field like 'group_XXX', ``execute`` adds/removes 'implied_group'
to/from the implied groups of 'group', depending on the field's value.
By default 'group' is the group Employee. Groups are given by their xml id.
The attribute 'group' may contain several xml ids, separated by commas.
* For a boolean field like 'module_XXX', ``execute`` triggers the immediate
installation of the module named 'XXX' if the field has value ``True``.
* For the other fields, the method ``execute`` invokes all methods with a name
that starts with 'set_'; such methods can be defined to implement the effect
of those fields.
The method ``default_get`` retrieves values that reflect the current status of the
fields like 'default_XXX', 'group_XXX' and 'module_XXX'. It also invokes all methods
with a name that starts with 'get_default_'; such methods can be defined to provide
current values for other fields.
"""
_name = 'res.config.settings'
def copy(self, cr, uid, id, values, context=None):
raise osv.except_osv(_("Cannot duplicate configuration!"), "")
def fields_view_get(self, cr, user, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
ret_val = super(res_config_settings, self).fields_view_get(
cr, user, view_id=view_id, view_type=view_type, context=context,
toolbar=toolbar, submenu=submenu)
doc = etree.XML(ret_val['arch'])
for field in ret_val['fields']:
if not field.startswith("module_"):
continue
for node in doc.xpath("//field[@name='%s']" % field):
if 'on_change' not in node.attrib:
node.set("on_change",
"onchange_module(%s, '%s')" % (field, field))
ret_val['arch'] = etree.tostring(doc)
return ret_val
def onchange_module(self, cr, uid, ids, field_value, module_name, context={}):
module_pool = self.pool.get('ir.module.module')
module_ids = module_pool.search(
cr, uid, [('name', '=', module_name.replace("module_", '')),
('state','in', ['to install', 'installed', 'to upgrade'])],
context=context)
if module_ids and not field_value:
dep_ids = module_pool.downstream_dependencies(cr, uid, module_ids, context=context)
dep_name = [x.shortdesc for x in module_pool.browse(
cr, uid, dep_ids + module_ids, context=context)]
message = '\n'.join(dep_name)
return {'warning': {'title': _('Warning!'),
'message':
_('Disabling this option will also uninstall the following modules \n%s' % message)
}}
return {}
def _get_classified_fields(self, cr, uid, context=None):
""" return a dictionary with the fields classified by category::
{ 'default': [('default_foo', 'model', 'foo'), ...],
'group': [('group_bar', [browse_group], browse_implied_group), ...],
'module': [('module_baz', browse_module), ...],
'other': ['other_field', ...],
}
"""
ir_model_data = self.pool['ir.model.data']
ir_module = self.pool['ir.module.module']
def ref(xml_id):
mod, xml = xml_id.split('.', 1)
return ir_model_data.get_object(cr, uid, mod, xml, context=context)
defaults, groups, modules, others = [], [], [], []
for name, field in self._columns.items():
if name.startswith('default_') and hasattr(field, 'default_model'):
defaults.append((name, field.default_model, name[8:]))
elif name.startswith('group_') and isinstance(field, fields.boolean) and hasattr(field, 'implied_group'):
field_groups = getattr(field, 'group', 'base.group_user').split(',')
groups.append((name, map(ref, field_groups), ref(field.implied_group)))
elif name.startswith('module_') and isinstance(field, fields.boolean):
mod_ids = ir_module.search(cr, uid, [('name', '=', name[7:])])
record = ir_module.browse(cr, uid, mod_ids[0], context) if mod_ids else None
modules.append((name, record))
else:
others.append(name)
return {'default': defaults, 'group': groups, 'module': modules, 'other': others}
def default_get(self, cr, uid, fields, context=None):
ir_values = self.pool['ir.values']
classified = self._get_classified_fields(cr, uid, context)
res = super(res_config_settings, self).default_get(cr, uid, fields, context)
# defaults: take the corresponding default value they set
for name, model, field in classified['default']:
value = ir_values.get_default(cr, uid, model, field)
if value is not None:
res[name] = value
# groups: which groups are implied by the group Employee
for name, groups, implied_group in classified['group']:
res[name] = all(implied_group in group.implied_ids for group in groups)
# modules: which modules are installed/to install
for name, module in classified['module']:
res[name] = module and module.state in ('installed', 'to install', 'to upgrade')
# other fields: call all methods that start with 'get_default_'
for method in dir(self):
if method.startswith('get_default_'):
res.update(getattr(self, method)(cr, uid, fields, context))
return res
def execute(self, cr, uid, ids, context=None):
if context is None:
context = {}
context = dict(context, active_test=False)
if uid != SUPERUSER_ID and not self.pool['res.users'].has_group(cr, uid, 'base.group_erp_manager'):
raise openerp.exceptions.AccessError(_("Only administrators can change the settings"))
ir_values = self.pool['ir.values']
ir_module = self.pool['ir.module.module']
res_groups = self.pool['res.groups']
classified = self._get_classified_fields(cr, uid, context=context)
config = self.browse(cr, uid, ids[0], context)
# default values fields
for name, model, field in classified['default']:
ir_values.set_default(cr, SUPERUSER_ID, model, field, config[name])
# group fields: modify group / implied groups
for name, groups, implied_group in classified['group']:
gids = map(int, groups)
if config[name]:
res_groups.write(cr, uid, gids, {'implied_ids': [(4, implied_group.id)]}, context=context)
else:
res_groups.write(cr, uid, gids, {'implied_ids': [(3, implied_group.id)]}, context=context)
uids = set()
for group in groups:
uids.update(map(int, group.users))
implied_group.write({'users': [(3, u) for u in uids]})
# other fields: execute all methods that start with 'set_'
for method in dir(self):
if method.startswith('set_'):
getattr(self, method)(cr, uid, ids, context)
# module fields: install/uninstall the selected modules
to_install = []
to_uninstall_ids = []
lm = len('module_')
for name, module in classified['module']:
if config[name]:
to_install.append((name[lm:], module))
else:
if module and module.state in ('installed', 'to upgrade'):
to_uninstall_ids.append(module.id)
if to_uninstall_ids:
ir_module.button_immediate_uninstall(cr, uid, to_uninstall_ids, context=context)
action = self._install_modules(cr, uid, to_install, context=context)
if action:
return action
# After the uninstall/install calls, the self.pool is no longer valid.
# So we reach into the RegistryManager directly.
res_config = openerp.modules.registry.RegistryManager.get(cr.dbname)['res.config']
config = res_config.next(cr, uid, [], context=context) or {}
if config.get('type') not in ('ir.actions.act_window_close',):
return config
# force client-side reload (update user menu and current view)
return {
'type': 'ir.actions.client',
'tag': 'reload',
}
def cancel(self, cr, uid, ids, context=None):
# ignore the current record, and send the action to reopen the view
act_window = self.pool['ir.actions.act_window']
action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)])
if action_ids:
return act_window.read(cr, uid, action_ids[0], [], context=context)
return {}
def name_get(self, cr, uid, ids, context=None):
""" Override name_get method to return an appropriate configuration wizard
name, and not the generated name."""
if not ids:
return []
# name_get may receive int id instead of an id list
if isinstance(ids, (int, long)):
ids = [ids]
act_window = self.pool['ir.actions.act_window']
action_ids = act_window.search(cr, uid, [('res_model', '=', self._name)], context=context)
name = self._name
if action_ids:
name = act_window.read(cr, uid, action_ids[0], ['name'], context=context)['name']
return [(record.id, name) for record in self.browse(cr, uid , ids, context=context)]
def get_option_path(self, cr, uid, menu_xml_id, context=None):
"""
Fetch the path to a specified configuration view and the action id to access it.
:param string menu_xml_id: the xml id of the menuitem where the view is located,
structured as follows: module_name.menuitem_xml_id (e.g.: "base.menu_sale_config")
:return tuple:
- t[0]: string: full path to the menuitem (e.g.: "Settings/Configuration/Sales")
- t[1]: int or long: id of the menuitem's action
"""
module_name, menu_xml_id = menu_xml_id.split('.')
dummy, menu_id = self.pool['ir.model.data'].get_object_reference(cr, uid, module_name, menu_xml_id)
ir_ui_menu = self.pool['ir.ui.menu'].browse(cr, uid, menu_id, context=context)
return (ir_ui_menu.complete_name, ir_ui_menu.action.id)
def get_option_name(self, cr, uid, full_field_name, context=None):
"""
Fetch the human readable name of a specified configuration option.
:param string full_field_name: the full name of the field, structured as follows:
model_name.field_name (e.g.: "sale.config.settings.fetchmail_lead")
:return string: human readable name of the field (e.g.: "Create leads from incoming mails")
"""
model_name, field_name = full_field_name.rsplit('.', 1)
return self.pool[model_name].fields_get(cr, uid, allfields=[field_name], context=context)[field_name]['string']
def get_config_warning(self, cr, msg, context=None):
"""
Helper: return a Warning exception with the given message where the %(field:xxx)s
and/or %(menu:yyy)s are replaced by the human readable field's name and/or menuitem's
full path.
Usage:
------
Just include in your error message %(field:model_name.field_name)s to obtain the human
readable field's name, and/or %(menu:module_name.menuitem_xml_id)s to obtain the menuitem's
full path.
Example of use:
---------------
from openerp.addons.base.res.res_config import get_warning_config
raise get_warning_config(cr, _("Error: this action is prohibited. You should check the field %(field:sale.config.settings.fetchmail_lead)s in %(menu:base.menu_sale_config)s."), context=context)
This will return an exception containing the following message:
Error: this action is prohibited. You should check the field Create leads from incoming mails in Settings/Configuration/Sales.
What if there is another substitution in the message already?
-------------------------------------------------------------
You could have a situation where the error message you want to upgrade already contains a substitution. Example:
Cannot find any account journal of %s type for this company.\n\nYou can create one in the menu: \nConfiguration\Journals\Journals.
What you want to do here is simply to replace the path by %menu:account.menu_account_config)s, and leave the rest alone.
In order to do that, you can use the double percent (%%) to escape your new substitution, like so:
Cannot find any account journal of %s type for this company.\n\nYou can create one in the %%(menu:account.menu_account_config)s.
"""
res_config_obj = openerp.registry(cr.dbname)['res.config.settings']
regex_path = r'%\(((?:menu|field):[a-z_\.]*)\)s'
# Process the message
# 1/ find the menu and/or field references, put them in a list
references = re.findall(regex_path, msg, flags=re.I)
# 2/ fetch the menu and/or field replacement values (full path and
# human readable field's name) and the action_id if any
values = {}
action_id = None
for item in references:
ref_type, ref = item.split(':')
if ref_type == 'menu':
values[item], action_id = res_config_obj.get_option_path(cr, SUPERUSER_ID, ref, context=context)
elif ref_type == 'field':
values[item] = res_config_obj.get_option_name(cr, SUPERUSER_ID, ref, context=context)
# 3/ substitute and return the result
if (action_id):
return exceptions.RedirectWarning(msg % values, action_id, _('Go to the configuration panel'))
return exceptions.Warning(msg % values)
# 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,
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,
646,
2050,
199,
504,
4182,
492,
21829,
199,
646,
295,
199,
199,
646,
5166,
199,
504,
5166,
492,
12824,
63,
998,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
14,
2537,
492,
399,
495,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
492,
4967,
199,
504,
14490,
492,
7559,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
522,
63,
888,
63,
578,
63,
23048,
63,
20406,
8,
785,
304,
272,
347,
485,
3174,
63,
3112,
8,
277,
12,
2467,
12,
1747,
12,
4621,
12,
1067,
304,
267,
408,
8154,
314,
5839,
4621,
14,
288,
372,
314,
2163,
1595,
370,
5341,
8592,
4621,
365,
282,
769,
402,
6346,
288,
334,
1494,
63,
354,
12,
19249,
63,
3059,
1204,
488,
9,
267,
408,
267,
8190,
63,
578,
275,
291,
14,
2293,
14,
362,
360,
723,
14,
578,
14,
578,
358,
267,
370,
63,
3174,
63,
1580,
275,
942,
267,
370,
63,
3174,
63,
4752,
63,
1247,
275,
942,
398,
367,
536,
12,
859,
315,
4621,
26,
288,
340,
440,
859,
26,
355,
370,
63,
3174,
63,
4752,
63,
1247,
14,
740,
8,
354,
9,
288,
916,
859,
14,
929,
508,
283,
324,
7657,
356,
355,
370,
63,
3174,
63,
1580,
14,
740,
8,
578,
14,
344,
9,
267,
754,
275,
488,
267,
340,
370,
63,
3174,
63,
1580,
26,
288,
754,
275,
8190,
63,
578,
14,
3887,
63,
20250,
63,
3174,
8,
1556,
12,
1747,
12,
370,
63,
3174,
63,
1580,
12,
1067,
29,
1100,
9,
267,
327,
31779,
26,
340,
754,
365,
440,
7179,
12,
314,
5226,
11386,
911,
506,
9645,
2952,
652,
1990,
2951,
11584,
4224,
267,
340,
370,
63,
3174,
63,
4752,
63,
1247,
26,
288,
372,
469,
355,
283,
466,
356,
283,
723,
14,
3723,
14,
1258,
297,
355,
283,
1450,
356,
283,
5181,
297,
355,
283,
1162,
356,
791,
3112,
356,
370,
63,
3174,
63,
4752,
63,
1247,
1386,
288,
789,
398,
372,
754,
199,
199,
533,
522,
63,
888,
63,
888,
15684,
8,
4795,
14,
4795,
63,
4844,
304,
272,
1449,
3523,
3992,
367,
892,
13,
2487,
2897,
2974,
339,
11595,
2974,
1077,
8287,
687,
642,
1021,
12,
5669,
272,
314,
5341,
1083,
334,
460,
14190,
314,
9311,
1373,
9,
436,
1172,
272,
3932,
2455,
8287,
687,
314,
4048,
522,
63,
888,
63,
1345,
63,
1095,
2455,
14,
272,
1449,
272,
485,
354,
275,
283,
470,
14,
888,
7,
339,
347,
485,
2184,
63,
1287,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
377,
364,
736,
275,
291,
14,
2293,
459,
723,
14,
3723,
14,
11396,
418,
267,
485,
2921,
14,
815,
360,
362,
1337,
2163,
450,
83,
297,
377,
364,
736,
9,
398,
4702,
63,
5766,
736,
275,
377,
364,
736,
14,
4570,
8,
1556,
12,
1747,
12,
288,
377,
364,
736,
14,
1733,
8,
1556,
12,
1747,
12,
788,
16749,
661,
466,
297,
6291,
283,
23292,
659,
661,
929,
1673,
29511,
1490,
22864,
2511,
1067,
29,
1100,
9,
398,
922,
63,
2634,
275,
663,
8,
1130,
8,
288,
2400,
486,
26,
486,
14,
344,
12,
288,
291,
14,
2293,
459,
470,
14,
3707,
2278,
4570,
8,
1556,
12,
1747,
12,
359,
1535,
467,
1067,
29,
1100,
2788,
16,
1055,
2634,
63,
344,
430,
398,
1686,
63,
5766,
736,
63,
509,
63,
751,
275,
359,
288,
11386,
367,
11386,
315,
4702,
63,
5766,
736,
288,
340,
440,
11386,
14,
2634,
63,
344,
503,
2155,
8,
751,
63,
2634,
14,
12569,
1332,
355,
1572,
14,
344,
367,
1572,
315,
11386,
14,
2634,
63,
344,
1724,
267,
1622,
398,
340,
1686,
63,
5766,
736,
63,
509,
63,
751,
26,
288,
372,
1686,
63,
5766,
736,
63,
509,
63,
751,
59,
16,
61,
398,
372,
488,
339,
347,
485,
2184,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
485,
2921,
14,
815,
360,
362,
1337,
2163,
3439,
358,
267,
2163,
275,
291,
423,
2184,
63,
1287,
8,
1556,
12,
1747,
12,
1067,
29,
1100,
9,
267,
485,
2921,
14,
815,
360,
2184,
1595,
365,
450,
83,
297,
2163,
9,
267,
340,
2163,
26,
288,
522,
275,
2163,
14,
1287,
63,
9850,
8,
1100,
29,
1100,
9,
288,
522,
459,
932,
270,
4813,
418,
275,
756,
288,
372,
522,
398,
372,
469,
288,
283,
466,
356,
283,
723,
14,
3723,
14,
1258,
297,
288,
283,
1450,
356,
283,
9233,
297,
267,
789,
339,
347,
1343,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
2184,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
9,
339,
347,
2163,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
408,
1803,
314,
2163,
11386,
1595,
370,
5341,
334,
4941,
314,
849,
267,
4069,
1865,
9,
267,
408,
267,
372,
291,
423,
2184,
8,
1556,
12,
1747,
12,
1067,
29,
1100,
9,
339
] |
[
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,
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,
646,
2050,
199,
504,
4182,
492,
21829,
199,
646,
295,
199,
199,
646,
5166,
199,
504,
5166,
492,
12824,
63,
998,
199,
504,
5166,
14,
4795,
492,
9506,
12,
1504,
199,
504,
5166,
14,
2537,
492,
399,
495,
199,
504,
5166,
14,
2537,
14,
5275,
492,
485,
199,
504,
5166,
492,
4967,
199,
504,
14490,
492,
7559,
199,
199,
63,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
522,
63,
888,
63,
578,
63,
23048,
63,
20406,
8,
785,
304,
272,
347,
485,
3174,
63,
3112,
8,
277,
12,
2467,
12,
1747,
12,
4621,
12,
1067,
304,
267,
408,
8154,
314,
5839,
4621,
14,
288,
372,
314,
2163,
1595,
370,
5341,
8592,
4621,
365,
282,
769,
402,
6346,
288,
334,
1494,
63,
354,
12,
19249,
63,
3059,
1204,
488,
9,
267,
408,
267,
8190,
63,
578,
275,
291,
14,
2293,
14,
362,
360,
723,
14,
578,
14,
578,
358,
267,
370,
63,
3174,
63,
1580,
275,
942,
267,
370,
63,
3174,
63,
4752,
63,
1247,
275,
942,
398,
367,
536,
12,
859,
315,
4621,
26,
288,
340,
440,
859,
26,
355,
370,
63,
3174,
63,
4752,
63,
1247,
14,
740,
8,
354,
9,
288,
916,
859,
14,
929,
508,
283,
324,
7657,
356,
355,
370,
63,
3174,
63,
1580,
14,
740,
8,
578,
14,
344,
9,
267,
754,
275,
488,
267,
340,
370,
63,
3174,
63,
1580,
26,
288,
754,
275,
8190,
63,
578,
14,
3887,
63,
20250,
63,
3174,
8,
1556,
12,
1747,
12,
370,
63,
3174,
63,
1580,
12,
1067,
29,
1100,
9,
267,
327,
31779,
26,
340,
754,
365,
440,
7179,
12,
314,
5226,
11386,
911,
506,
9645,
2952,
652,
1990,
2951,
11584,
4224,
267,
340,
370,
63,
3174,
63,
4752,
63,
1247,
26,
288,
372,
469,
355,
283,
466,
356,
283,
723,
14,
3723,
14,
1258,
297,
355,
283,
1450,
356,
283,
5181,
297,
355,
283,
1162,
356,
791,
3112,
356,
370,
63,
3174,
63,
4752,
63,
1247,
1386,
288,
789,
398,
372,
754,
199,
199,
533,
522,
63,
888,
63,
888,
15684,
8,
4795,
14,
4795,
63,
4844,
304,
272,
1449,
3523,
3992,
367,
892,
13,
2487,
2897,
2974,
339,
11595,
2974,
1077,
8287,
687,
642,
1021,
12,
5669,
272,
314,
5341,
1083,
334,
460,
14190,
314,
9311,
1373,
9,
436,
1172,
272,
3932,
2455,
8287,
687,
314,
4048,
522,
63,
888,
63,
1345,
63,
1095,
2455,
14,
272,
1449,
272,
485,
354,
275,
283,
470,
14,
888,
7,
339,
347,
485,
2184,
63,
1287,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
377,
364,
736,
275,
291,
14,
2293,
459,
723,
14,
3723,
14,
11396,
418,
267,
485,
2921,
14,
815,
360,
362,
1337,
2163,
450,
83,
297,
377,
364,
736,
9,
398,
4702,
63,
5766,
736,
275,
377,
364,
736,
14,
4570,
8,
1556,
12,
1747,
12,
288,
377,
364,
736,
14,
1733,
8,
1556,
12,
1747,
12,
788,
16749,
661,
466,
297,
6291,
283,
23292,
659,
661,
929,
1673,
29511,
1490,
22864,
2511,
1067,
29,
1100,
9,
398,
922,
63,
2634,
275,
663,
8,
1130,
8,
288,
2400,
486,
26,
486,
14,
344,
12,
288,
291,
14,
2293,
459,
470,
14,
3707,
2278,
4570,
8,
1556,
12,
1747,
12,
359,
1535,
467,
1067,
29,
1100,
2788,
16,
1055,
2634,
63,
344,
430,
398,
1686,
63,
5766,
736,
63,
509,
63,
751,
275,
359,
288,
11386,
367,
11386,
315,
4702,
63,
5766,
736,
288,
340,
440,
11386,
14,
2634,
63,
344,
503,
2155,
8,
751,
63,
2634,
14,
12569,
1332,
355,
1572,
14,
344,
367,
1572,
315,
11386,
14,
2634,
63,
344,
1724,
267,
1622,
398,
340,
1686,
63,
5766,
736,
63,
509,
63,
751,
26,
288,
372,
1686,
63,
5766,
736,
63,
509,
63,
751,
59,
16,
61,
398,
372,
488,
339,
347,
485,
2184,
8,
277,
12,
2467,
12,
1747,
12,
1067,
29,
403,
304,
267,
485,
2921,
14,
815,
360,
362,
1337,
2163,
3439,
358,
267,
2163,
275,
291,
423,
2184,
63,
1287,
8,
1556,
12,
1747,
12,
1067,
29,
1100,
9,
267,
485,
2921,
14,
815,
360,
2184,
1595,
365,
450,
83,
297,
2163,
9,
267,
340,
2163,
26,
288,
522,
275,
2163,
14,
1287,
63,
9850,
8,
1100,
29,
1100,
9,
288,
522,
459,
932,
270,
4813,
418,
275,
756,
288,
372,
522,
398,
372,
469,
288,
283,
466,
356,
283,
723,
14,
3723,
14,
1258,
297,
288,
283,
1450,
356,
283,
9233,
297,
267,
789,
339,
347,
1343,
8,
277,
12,
2467,
12,
1747,
12,
2762,
12,
1067,
29,
403,
304,
267,
372,
291,
14,
2184,
8,
1556,
12,
1747,
12,
2762,
12,
1067,
9,
339,
347,
2163,
8,
277,
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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
] |
jmesteve/openerp
|
openerp/addons/account_report_company/__init__.py
|
52
|
1091
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Business Applications
# Copyright (c) 2013 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/>.
#
##############################################################################
import account_report_company
import report
# 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,
6171,
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,
199,
646,
2933,
63,
3070,
63,
4627,
199,
646,
3622,
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,
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,
6171,
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,
199,
646,
2933,
63,
3070,
63,
4627,
199,
646,
3622,
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,
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,
0,
0,
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
] |
molecular/electrum
|
gui/kivy/uix/dialogs/question.py
|
1
|
1361
|
from kivy.app import App
from kivy.factory import Factory
from kivy.properties import ObjectProperty
from kivy.lang import Builder
from kivy.uix.checkbox import CheckBox
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from electroncash_gui.kivy.i18n import _
Builder.load_string('''
<Question@Popup>
id: popup
title: ''
message: ''
size_hint: 0.8, 0.5
pos_hint: {'top':0.9}
BoxLayout:
orientation: 'vertical'
Label:
id: label
text: root.message
text_size: self.width, None
Widget:
size_hint: 1, 0.1
BoxLayout:
orientation: 'horizontal'
size_hint: 1, 0.2
Button:
text: _('No')
size_hint: 0.5, None
height: '48dp'
on_release:
root.callback(False)
popup.dismiss()
Button:
text: _('Yes')
size_hint: 0.5, None
height: '48dp'
on_release:
root.callback(True)
popup.dismiss()
''')
class Question(Factory.Popup):
def __init__(self, msg, callback):
Factory.Popup.__init__(self)
self.title = _('Question')
self.message = msg
self.callback = callback
|
mit
|
[
504,
17227,
14,
571,
492,
4693,
199,
504,
17227,
14,
3702,
492,
23616,
199,
504,
17227,
14,
3282,
492,
6935,
3697,
199,
504,
17227,
14,
4159,
492,
19286,
199,
504,
17227,
14,
24263,
14,
13456,
492,
2670,
3532,
199,
504,
17227,
14,
24263,
14,
1302,
492,
10354,
199,
504,
17227,
14,
24263,
14,
3440,
492,
16905,
199,
199,
504,
325,
16728,
20084,
63,
5885,
14,
16941,
14,
73,
1085,
78,
492,
485,
199,
199,
6437,
14,
912,
63,
875,
10505,
199,
28,
16778,
32,
26168,
30,
272,
1305,
26,
22365,
272,
2538,
26,
2125,
272,
1245,
26,
2125,
272,
1568,
63,
6479,
26,
378,
14,
24,
12,
378,
14,
21,
272,
2086,
63,
6479,
26,
791,
2119,
356,
16,
14,
25,
93,
272,
20783,
4798,
26,
267,
16774,
26,
283,
7870,
7,
267,
10354,
26,
288,
1305,
26,
1768,
288,
1318,
26,
1738,
14,
1188,
288,
1318,
63,
890,
26,
291,
14,
2063,
12,
488,
267,
16905,
26,
288,
1568,
63,
6479,
26,
413,
12,
378,
14,
17,
267,
20783,
4798,
26,
288,
16774,
26,
283,
11392,
7,
288,
1568,
63,
6479,
26,
413,
12,
378,
14,
18,
288,
16005,
26,
355,
1318,
26,
4018,
1944,
358,
355,
1568,
63,
6479,
26,
378,
14,
21,
12,
488,
355,
4569,
26,
283,
2006,
5780,
7,
355,
641,
63,
3221,
26,
490,
1738,
14,
3058,
8,
797,
9,
490,
22365,
14,
32439,
342,
288,
16005,
26,
355,
1318,
26,
4018,
12555,
358,
355,
1568,
63,
6479,
26,
378,
14,
21,
12,
488,
355,
4569,
26,
283,
2006,
5780,
7,
355,
641,
63,
3221,
26,
490,
1738,
14,
3058,
8,
549,
9,
490,
22365,
14,
32439,
342,
199,
12310,
4388,
199,
533,
21421,
8,
2927,
14,
26168,
304,
339,
347,
636,
826,
721,
277,
12,
1499,
12,
3233,
304,
267,
23616,
14,
26168,
855,
826,
721,
277,
9,
267,
291,
14,
1213,
275,
4018,
16778,
358,
267,
291,
14,
1188,
275,
1499,
267,
291,
14,
3058,
275,
3233,
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
] |
[
17227,
14,
571,
492,
4693,
199,
504,
17227,
14,
3702,
492,
23616,
199,
504,
17227,
14,
3282,
492,
6935,
3697,
199,
504,
17227,
14,
4159,
492,
19286,
199,
504,
17227,
14,
24263,
14,
13456,
492,
2670,
3532,
199,
504,
17227,
14,
24263,
14,
1302,
492,
10354,
199,
504,
17227,
14,
24263,
14,
3440,
492,
16905,
199,
199,
504,
325,
16728,
20084,
63,
5885,
14,
16941,
14,
73,
1085,
78,
492,
485,
199,
199,
6437,
14,
912,
63,
875,
10505,
199,
28,
16778,
32,
26168,
30,
272,
1305,
26,
22365,
272,
2538,
26,
2125,
272,
1245,
26,
2125,
272,
1568,
63,
6479,
26,
378,
14,
24,
12,
378,
14,
21,
272,
2086,
63,
6479,
26,
791,
2119,
356,
16,
14,
25,
93,
272,
20783,
4798,
26,
267,
16774,
26,
283,
7870,
7,
267,
10354,
26,
288,
1305,
26,
1768,
288,
1318,
26,
1738,
14,
1188,
288,
1318,
63,
890,
26,
291,
14,
2063,
12,
488,
267,
16905,
26,
288,
1568,
63,
6479,
26,
413,
12,
378,
14,
17,
267,
20783,
4798,
26,
288,
16774,
26,
283,
11392,
7,
288,
1568,
63,
6479,
26,
413,
12,
378,
14,
18,
288,
16005,
26,
355,
1318,
26,
4018,
1944,
358,
355,
1568,
63,
6479,
26,
378,
14,
21,
12,
488,
355,
4569,
26,
283,
2006,
5780,
7,
355,
641,
63,
3221,
26,
490,
1738,
14,
3058,
8,
797,
9,
490,
22365,
14,
32439,
342,
288,
16005,
26,
355,
1318,
26,
4018,
12555,
358,
355,
1568,
63,
6479,
26,
378,
14,
21,
12,
488,
355,
4569,
26,
283,
2006,
5780,
7,
355,
641,
63,
3221,
26,
490,
1738,
14,
3058,
8,
549,
9,
490,
22365,
14,
32439,
342,
199,
12310,
4388,
199,
533,
21421,
8,
2927,
14,
26168,
304,
339,
347,
636,
826,
721,
277,
12,
1499,
12,
3233,
304,
267,
23616,
14,
26168,
855,
826,
721,
277,
9,
267,
291,
14,
1213,
275,
4018,
16778,
358,
267,
291,
14,
1188,
275,
1499,
267,
291,
14,
3058,
275,
3233,
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,
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
] |
ychen820/microblog
|
y/google-cloud-sdk/platform/google_appengine/lib/requests/requests/packages/chardet/constants.py
|
3008
|
1335
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
# Shy Shalom - original C code
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
_debug = 0
eDetecting = 0
eFoundIt = 1
eNotMe = 2
eStart = 0
eError = 1
eItsMe = 2
SHORTCUT_THRESHOLD = 0.95
|
bsd-3-clause
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
29347,
5960,
17842,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
12521,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
257,
428,
3577,
5244,
279,
676,
446,
3379,
445,
1233,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
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,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
63,
1757,
275,
378,
199,
199,
69,
20064,
316,
275,
378,
199,
69,
3601,
7940,
275,
413,
199,
69,
1763,
1352,
275,
499,
199,
199,
11724,
275,
378,
199,
6259,
275,
413,
199,
13241,
275,
499,
199,
199,
13003,
24678,
63,
19307,
275,
378,
14,
2720,
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
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
29347,
5960,
17842,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
12521,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
257,
428,
3577,
5244,
279,
676,
446,
3379,
445,
1233,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
221,
199,
3,
961,
3555,
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,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
221,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
63,
1757,
275,
378,
199,
199,
69,
20064,
316,
275,
378,
199,
69,
3601,
7940,
275,
413,
199,
69,
1763,
1352,
275,
499,
199,
199,
11724,
275,
378,
199,
6259,
275,
413,
199,
13241,
275,
499,
199,
199,
13003,
24678,
63,
19307,
275,
378,
14,
2720,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
roadmapper/ansible
|
test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/restconf/restconf.py
|
47
|
2617
|
# This code is part of Ansible, but is an independent component.
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete work.
#
# (c) 2018 Red Hat Inc.
#
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
from ansible.module_utils.connection import Connection
def get(module, path=None, content=None, fields=None, output="json"):
if path is None:
raise ValueError("path value must be provided")
if content:
path += "?" + "content=%s" % content
if fields:
path += "?" + "field=%s" % fields
accept = None
if output == "xml":
accept = "application/yang-data+xml"
connection = Connection(module._socket_path)
return connection.send_request(
None, path=path, method="GET", accept=accept
)
def edit_config(module, path=None, content=None, method="GET", format="json"):
if path is None:
raise ValueError("path value must be provided")
content_type = None
if format == "xml":
content_type = "application/yang-data+xml"
connection = Connection(module._socket_path)
return connection.send_request(
content, path=path, method=method, content_type=content_type
)
|
gpl-3.0
|
[
3,
961,
1233,
365,
1777,
402,
2622,
12,
1325,
365,
376,
12717,
3931,
14,
199,
3,
961,
6770,
570,
17440,
12,
436,
642,
570,
17440,
1454,
12,
365,
6289,
18233,
14,
199,
3,
18167,
1265,
2218,
1808,
642,
17440,
12,
1314,
365,
12169,
18774,
701,
2622,
199,
3,
5139,
13511,
370,
314,
4132,
402,
314,
859,
12,
436,
1443,
5090,
3932,
5705,
4190,
199,
3,
370,
314,
4890,
1736,
14,
199,
3,
199,
3,
334,
67,
9,
14894,
9572,
13002,
3277,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
7100,
12,
199,
3,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
199,
3,
259,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
420,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
259,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
420,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
420,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
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,
9706,
14,
199,
3,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
199,
3,
9716,
12,
8820,
12,
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,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
199,
3,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
199,
3,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
2105,
492,
8113,
421,
199,
318,
664,
8,
578,
12,
931,
29,
403,
12,
1564,
29,
403,
12,
1504,
29,
403,
12,
1072,
628,
1001,
2349,
272,
340,
931,
365,
488,
26,
267,
746,
1722,
480,
515,
574,
1471,
506,
2741,
531,
272,
340,
1564,
26,
267,
931,
847,
29325,
435,
298,
1317,
2458,
83,
2,
450,
1564,
272,
340,
1504,
26,
267,
931,
847,
29325,
435,
298,
698,
2458,
83,
2,
450,
1504,
339,
4729,
275,
488,
272,
340,
1072,
508,
298,
1652,
582,
267,
4729,
275,
298,
3578,
15,
11912,
13,
576,
11,
1652,
2,
339,
1950,
275,
8113,
8,
578,
423,
3450,
63,
515,
9,
272,
372,
1950,
14,
2254,
63,
1069,
8,
267,
488,
12,
931,
29,
515,
12,
1083,
628,
2970,
401,
4729,
29,
5694,
272,
776,
421,
199,
318,
5283,
63,
888,
8,
578,
12,
931,
29,
403,
12,
1564,
29,
403,
12,
1083,
628,
2970,
401,
1475,
628,
1001,
2349,
272,
340,
931,
365,
488,
26,
267,
746,
1722,
480,
515,
574,
1471,
506,
2741,
531,
339,
1564,
63,
466,
275,
488,
272,
340,
1475,
508,
298,
1652,
582,
267,
1564,
63,
466,
275,
298,
3578,
15,
11912,
13,
576,
11,
1652,
2,
339,
1950,
275,
8113,
8,
578,
423,
3450,
63,
515,
9,
272,
372,
1950,
14,
2254,
63,
1069,
8,
267,
1564,
12,
931,
29,
515,
12,
1083,
29,
765,
12,
1564,
63,
466,
29,
1317,
63,
466,
272,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
961,
1233,
365,
1777,
402,
2622,
12,
1325,
365,
376,
12717,
3931,
14,
199,
3,
961,
6770,
570,
17440,
12,
436,
642,
570,
17440,
1454,
12,
365,
6289,
18233,
14,
199,
3,
18167,
1265,
2218,
1808,
642,
17440,
12,
1314,
365,
12169,
18774,
701,
2622,
199,
3,
5139,
13511,
370,
314,
4132,
402,
314,
859,
12,
436,
1443,
5090,
3932,
5705,
4190,
199,
3,
370,
314,
4890,
1736,
14,
199,
3,
199,
3,
334,
67,
9,
14894,
9572,
13002,
3277,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
7100,
12,
199,
3,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
7647,
26,
199,
3,
199,
3,
259,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
420,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
259,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
4245,
12,
199,
3,
420,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
3794,
199,
3,
420,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
298,
1179,
2281,
2,
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,
9706,
14,
199,
3,
1621,
4825,
6461,
7000,
2334,
5877,
29785,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
199,
3,
9716,
12,
8820,
12,
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,
1549,
9748,
199,
3,
9831,
9,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
199,
3,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
199,
3,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
2105,
492,
8113,
421,
199,
318,
664,
8,
578,
12,
931,
29,
403,
12,
1564,
29,
403,
12,
1504,
29,
403,
12,
1072,
628,
1001,
2349,
272,
340,
931,
365,
488,
26,
267,
746,
1722,
480,
515,
574,
1471,
506,
2741,
531,
272,
340,
1564,
26,
267,
931,
847,
29325,
435,
298,
1317,
2458,
83,
2,
450,
1564,
272,
340,
1504,
26,
267,
931,
847,
29325,
435,
298,
698,
2458,
83,
2,
450,
1504,
339,
4729,
275,
488,
272,
340,
1072,
508,
298,
1652,
582,
267,
4729,
275,
298,
3578,
15,
11912,
13,
576,
11,
1652,
2,
339,
1950,
275,
8113,
8,
578,
423,
3450,
63,
515,
9,
272,
372,
1950,
14,
2254,
63,
1069,
8,
267,
488,
12,
931,
29,
515,
12,
1083,
628,
2970,
401,
4729,
29,
5694,
272,
776,
421,
199,
318,
5283,
63,
888,
8,
578,
12,
931,
29,
403,
12,
1564,
29,
403,
12,
1083,
628,
2970,
401,
1475,
628,
1001,
2349,
272,
340,
931,
365,
488,
26,
267,
746,
1722,
480,
515,
574,
1471,
506,
2741,
531,
339,
1564,
63,
466,
275,
488,
272,
340,
1475,
508,
298,
1652,
582,
267,
1564,
63,
466,
275,
298,
3578,
15,
11912,
13,
576,
11,
1652,
2,
339,
1950,
275,
8113,
8,
578,
423,
3450,
63,
515,
9,
272,
372,
1950,
14,
2254,
63,
1069,
8,
267,
1564,
12,
931,
29,
515,
12,
1083,
29,
765,
12,
1564,
63,
466,
29,
1317,
63,
466,
272,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768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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
] |
VielSoft/odoo
|
addons/hr_contract/__init__.py
|
381
|
1107
|
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-Today 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/>.
#
##############################################################################
import hr_contract
import base_action_rule
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
258,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
31982,
7653,
13950,
8642,
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,
420,
199,
3,
199,
4605,
199,
199,
646,
16140,
63,
14624,
199,
646,
1300,
63,
1287,
63,
2200,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
4605,
199,
3,
258,
199,
3,
259,
7653,
12,
3232,
5800,
8259,
9274,
199,
3,
259,
1898,
334,
35,
9,
8353,
13,
31982,
7653,
13950,
8642,
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,
420,
199,
3,
199,
4605,
199,
199,
646,
16140,
63,
14624,
199,
646,
1300,
63,
1287,
63,
2200,
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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
] |
acercado/jd-ph-cms
|
jd-ph-cms/accounts/models.py
|
1
|
3986
|
from decimal import Decimal
from django.db import models
from django.core.validators import MinValueValidator
from ..notifications.models import NotificationMessage
from ..users.models import User
class Answer(models.Model):
question = models.ForeignKey('contests.contest', related_name='answer',
on_delete=models.CASCADE)
answer_text = models.CharField(max_length=200)
correct_answer = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
def __str__(self):
return self.answer_text
class Meta:
db_table = 'cms_answer'
class Account(models.Model):
billingpostalcode = models.CharField(max_length=20, null=True, blank=True)
isdeleted = models.BooleanField(default=False)
id = models.IntegerField(primary_key=True, unique=True)
billinglatitude = models.DecimalField(
max_digits=11,
decimal_places=8,
null=True,
blank=True)
_hc_lastop = models.CharField(max_length=32, null=True, blank=True)
createddate = models.DateTimeField(null=True, blank=True)
billingcountry = models.CharField(max_length=80, null=True, blank=True)
geolocation_longitude_s = models.DecimalField(
max_digits=11,
decimal_places=8,
db_column='geolocation__longitude__s',
null=True,
blank=True)
geolocation_latitude_s = models.DecimalField(
max_digits=11,
decimal_places=8,
db_column='geolocation__latitude__s',
null=True,
blank=True)
billingstate = models.CharField(max_length=80, null=True, blank=True)
billingstreet = models.CharField(max_length=255, null=True, blank=True)
billinglongitude = models.DecimalField(
max_digits=11,
decimal_places=8,
null=True,
blank=True)
billingcity = models.CharField(max_length=40, null=True, blank=True)
systemmodstamp = models.DateTimeField(null=True, blank=True)
name = models.CharField(max_length=255, null=True, blank=True)
_hc_err = models.TextField(null=True, blank=True, max_length=1024)
sfid = models.CharField(max_length=18, null=True, blank=True)
# these three should be on a separate model
# schedule = models.CharField(max_length=200,null=True,blank=True)
# timestamp = models.DateTimeField(auto_now_add=True)
# is_featured = models.BooleanField(default=False)
def __str__(self):
return self.name
class Meta:
# managed = False
db_table = 'salesforce\".\"account'
verbose_name = 'Salesforce Account'
verbose_name_plural = 'Salesforce Accounts'
class AccountAddon(models.Model):
account = models.OneToOneField(Account,
related_name='accountaddons',
on_delete=models.CASCADE)
schedule = models.CharField(max_length=200, null=True, blank=True)
timestamp = models.DateTimeField(auto_now_add=True)
is_featured = models.BooleanField(default=False)
avg_consumer_spending = models.DecimalField(null=True, blank=True, max_digits=7, decimal_places=2, validators=[MinValueValidator(Decimal('0.00'))])
menu_best_sellers = models.TextField(null=True, blank=True)
promotions = models.TextField(null=True, blank=True)
author = models.ForeignKey(User, null=True, blank=True)
last_update_datetime = models.DateTimeField(null=True, blank=True)
category = models.CharField(max_length=50, null=True, blank=True)
is_type = models.CharField(default='Account', max_length=50)
def __str__(self):
return str(self.account)
@property
def has_notif(self):
try:
notif_obj = NotificationMessage.objects.get(linkback = 'new_account_' + str(self.account.id))
return True
except NotificationMessage.DoesNotExist:
return False
class Meta:
verbose_name_plural = 'Account Addons'
db_table = 'cms_account_addon'
|
bsd-3-clause
|
[
504,
6107,
492,
6345,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1018,
14,
11346,
492,
10195,
1110,
8640,
199,
504,
2508,
12782,
14,
992,
492,
23362,
2209,
199,
504,
2508,
3707,
14,
992,
492,
2876,
199,
199,
533,
30675,
8,
992,
14,
1685,
304,
272,
7894,
275,
1709,
14,
3190,
360,
388,
2219,
14,
388,
396,
297,
4048,
63,
354,
534,
5934,
297,
639,
641,
63,
1807,
29,
992,
14,
10855,
9,
272,
6385,
63,
505,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
9,
272,
3211,
63,
5934,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
365,
63,
2682,
275,
1709,
14,
5036,
8,
885,
29,
549,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
5934,
63,
505,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
283,
10781,
63,
5934,
7,
421,
199,
533,
9973,
8,
992,
14,
1685,
304,
272,
32663,
31580,
600,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1165,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
365,
6062,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
1305,
275,
1709,
14,
3901,
8,
3327,
63,
498,
29,
549,
12,
3747,
29,
549,
9,
272,
32663,
13331,
275,
1709,
14,
15975,
8,
267,
1390,
63,
7022,
29,
845,
12,
267,
6107,
63,
10696,
29,
24,
12,
267,
2973,
29,
549,
12,
267,
4596,
29,
549,
9,
272,
485,
15907,
63,
2019,
411,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
2737,
602,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
32663,
6063,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1257,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
8509,
1985,
63,
13803,
63,
83,
275,
1709,
14,
15975,
8,
267,
1390,
63,
7022,
29,
845,
12,
267,
6107,
63,
10696,
29,
24,
12,
267,
1592,
63,
2301,
534,
6721,
1985,
363,
13803,
363,
83,
297,
267,
2973,
29,
549,
12,
267,
4596,
29,
549,
9,
272,
8509,
1985,
63,
13331,
63,
83,
275,
1709,
14,
15975,
8,
267,
1390,
63,
7022,
29,
845,
12,
267,
6107,
63,
10696,
29,
24,
12,
267,
1592,
63,
2301,
534,
6721,
1985,
363,
13331,
363,
83,
297,
267,
2973,
29,
549,
12,
267,
4596,
29,
549,
9,
272,
32663,
929,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1257,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
32663,
20451,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
32663,
13803,
275,
1709,
14,
15975,
8,
267,
1390,
63,
7022,
29,
845,
12,
267,
6107,
63,
10696,
29,
24,
12,
267,
2973,
29,
549,
12,
267,
4596,
29,
549,
9,
272,
32663,
3690,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2167,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
2656,
1494,
2359,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
485,
15907,
63,
1508,
275,
1709,
14,
6254,
8,
2307,
29,
549,
12,
4596,
29,
549,
12,
1390,
63,
1267,
29,
7727,
9,
272,
308,
9430,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1085,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
339,
327,
3520,
7795,
1077,
506,
641,
282,
7396,
1402,
272,
327,
8732,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
12,
2307,
29,
549,
12,
2500,
29,
549,
9,
272,
327,
4913,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
63,
525,
29,
549,
9,
272,
327,
365,
63,
30779,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
339,
1021,
6288,
26,
267,
327,
12883,
275,
756,
267,
1592,
63,
1224,
275,
283,
16175,
3990,
60,
1674,
4451,
2048,
7,
267,
3376,
63,
354,
275,
283,
18220,
3990,
9973,
7,
267,
3376,
63,
354,
63,
10019,
275,
283,
18220,
3990,
4473,
6851,
7,
421,
199,
533,
9973,
19654,
8,
992,
14,
1685,
304,
272,
2933,
275,
1709,
14,
14298,
8,
6009,
12,
3521,
4048,
63,
354,
534,
2048,
10788,
297,
3521,
641,
63,
1807,
29,
992,
14,
10855,
9,
272,
8732,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
4913,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
63,
525,
29,
549,
9,
272,
365,
63,
30779,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
12402,
63,
8542,
63,
681,
3219,
275,
1709,
14,
15975,
8,
2307,
29,
549,
12,
4596,
29,
549,
12,
1390,
63,
7022,
29,
23,
12,
6107,
63,
10696,
29,
18,
12,
14370,
1524,
4649,
1110,
8640,
8,
6745,
360,
16,
14,
383,
1333,
566,
272,
6269,
63,
7010,
63,
5891,
29099,
275,
1709,
14,
6254,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
8023,
79,
852,
275,
1709,
14,
6254,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
4132,
275,
1709,
14,
3190,
8,
1899,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
2061,
63,
873,
63,
2083,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
4637,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1400,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
365,
63,
466,
275,
1709,
14,
2183,
8,
885,
534,
6009,
297,
1390,
63,
1267,
29,
1400,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
620,
8,
277,
14,
2048,
9,
339,
768,
1829,
272,
347,
965,
63,
27795,
8,
277,
304,
267,
862,
26,
288,
32081,
63,
1113,
275,
23362,
2209,
14,
1462,
14,
362,
8,
1073,
894,
275,
283,
1222,
63,
2048,
8650,
435,
620,
8,
277,
14,
2048,
14,
344,
430,
288,
372,
715,
267,
871,
23362,
2209,
14,
7400,
26,
288,
372,
756,
339,
1021,
6288,
26,
267,
3376,
63,
354,
63,
10019,
275,
283
] |
[
6107,
492,
6345,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
1018,
14,
11346,
492,
10195,
1110,
8640,
199,
504,
2508,
12782,
14,
992,
492,
23362,
2209,
199,
504,
2508,
3707,
14,
992,
492,
2876,
199,
199,
533,
30675,
8,
992,
14,
1685,
304,
272,
7894,
275,
1709,
14,
3190,
360,
388,
2219,
14,
388,
396,
297,
4048,
63,
354,
534,
5934,
297,
639,
641,
63,
1807,
29,
992,
14,
10855,
9,
272,
6385,
63,
505,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
9,
272,
3211,
63,
5934,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
365,
63,
2682,
275,
1709,
14,
5036,
8,
885,
29,
549,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
5934,
63,
505,
339,
1021,
6288,
26,
267,
1592,
63,
1224,
275,
283,
10781,
63,
5934,
7,
421,
199,
533,
9973,
8,
992,
14,
1685,
304,
272,
32663,
31580,
600,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1165,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
365,
6062,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
1305,
275,
1709,
14,
3901,
8,
3327,
63,
498,
29,
549,
12,
3747,
29,
549,
9,
272,
32663,
13331,
275,
1709,
14,
15975,
8,
267,
1390,
63,
7022,
29,
845,
12,
267,
6107,
63,
10696,
29,
24,
12,
267,
2973,
29,
549,
12,
267,
4596,
29,
549,
9,
272,
485,
15907,
63,
2019,
411,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
708,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
2737,
602,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
32663,
6063,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1257,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
8509,
1985,
63,
13803,
63,
83,
275,
1709,
14,
15975,
8,
267,
1390,
63,
7022,
29,
845,
12,
267,
6107,
63,
10696,
29,
24,
12,
267,
1592,
63,
2301,
534,
6721,
1985,
363,
13803,
363,
83,
297,
267,
2973,
29,
549,
12,
267,
4596,
29,
549,
9,
272,
8509,
1985,
63,
13331,
63,
83,
275,
1709,
14,
15975,
8,
267,
1390,
63,
7022,
29,
845,
12,
267,
6107,
63,
10696,
29,
24,
12,
267,
1592,
63,
2301,
534,
6721,
1985,
363,
13331,
363,
83,
297,
267,
2973,
29,
549,
12,
267,
4596,
29,
549,
9,
272,
32663,
929,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1257,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
32663,
20451,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
32663,
13803,
275,
1709,
14,
15975,
8,
267,
1390,
63,
7022,
29,
845,
12,
267,
6107,
63,
10696,
29,
24,
12,
267,
2973,
29,
549,
12,
267,
4596,
29,
549,
9,
272,
32663,
3690,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2167,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
2656,
1494,
2359,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
536,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
2299,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
485,
15907,
63,
1508,
275,
1709,
14,
6254,
8,
2307,
29,
549,
12,
4596,
29,
549,
12,
1390,
63,
1267,
29,
7727,
9,
272,
308,
9430,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1085,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
339,
327,
3520,
7795,
1077,
506,
641,
282,
7396,
1402,
272,
327,
8732,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
12,
2307,
29,
549,
12,
2500,
29,
549,
9,
272,
327,
4913,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
63,
525,
29,
549,
9,
272,
327,
365,
63,
30779,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
291,
14,
354,
339,
1021,
6288,
26,
267,
327,
12883,
275,
756,
267,
1592,
63,
1224,
275,
283,
16175,
3990,
60,
1674,
4451,
2048,
7,
267,
3376,
63,
354,
275,
283,
18220,
3990,
9973,
7,
267,
3376,
63,
354,
63,
10019,
275,
283,
18220,
3990,
4473,
6851,
7,
421,
199,
533,
9973,
19654,
8,
992,
14,
1685,
304,
272,
2933,
275,
1709,
14,
14298,
8,
6009,
12,
3521,
4048,
63,
354,
534,
2048,
10788,
297,
3521,
641,
63,
1807,
29,
992,
14,
10855,
9,
272,
8732,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1840,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
4913,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
63,
525,
29,
549,
9,
272,
365,
63,
30779,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
272,
12402,
63,
8542,
63,
681,
3219,
275,
1709,
14,
15975,
8,
2307,
29,
549,
12,
4596,
29,
549,
12,
1390,
63,
7022,
29,
23,
12,
6107,
63,
10696,
29,
18,
12,
14370,
1524,
4649,
1110,
8640,
8,
6745,
360,
16,
14,
383,
1333,
566,
272,
6269,
63,
7010,
63,
5891,
29099,
275,
1709,
14,
6254,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
8023,
79,
852,
275,
1709,
14,
6254,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
4132,
275,
1709,
14,
3190,
8,
1899,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
2061,
63,
873,
63,
2083,
275,
1709,
14,
4626,
8,
2307,
29,
549,
12,
4596,
29,
549,
9,
272,
4637,
275,
1709,
14,
2183,
8,
988,
63,
1267,
29,
1400,
12,
2973,
29,
549,
12,
4596,
29,
549,
9,
272,
365,
63,
466,
275,
1709,
14,
2183,
8,
885,
534,
6009,
297,
1390,
63,
1267,
29,
1400,
9,
339,
347,
636,
495,
721,
277,
304,
267,
372,
620,
8,
277,
14,
2048,
9,
339,
768,
1829,
272,
347,
965,
63,
27795,
8,
277,
304,
267,
862,
26,
288,
32081,
63,
1113,
275,
23362,
2209,
14,
1462,
14,
362,
8,
1073,
894,
275,
283,
1222,
63,
2048,
8650,
435,
620,
8,
277,
14,
2048,
14,
344,
430,
288,
372,
715,
267,
871,
23362,
2209,
14,
7400,
26,
288,
372,
756,
339,
1021,
6288,
26,
267,
3376,
63,
354,
63,
10019,
275,
283,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
keshr3106/ThinkStats2
|
code/chap08soln.py
|
65
|
6172
|
"""This file contains code used in "Think Stats",
by Allen B. Downey, available from greenteapress.com
Copyright 2014 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
from __future__ import print_function
import thinkstats2
import thinkplot
import math
import random
import numpy as np
from scipy import stats
from estimation import RMSE, MeanError
"""This file contains a solution to exercises in Think Stats:
Exercise 8.1
In this chapter we used $\xbar$ and median to estimate $\mu$, and
found that $\xbar$ yields lower MSE.
Also, we used $S^2$ and $S_{n-1}^2$ to estimate $\sigma$, and found that
$S^2$ is biased and $S_{n-1}^2$ unbiased.
Run similar experiments to see if $\xbar$ and median are biased estimates
of $\mu$.
Also check whether $S^2$ or $S_{n-1}^2$ yields a lower MSE.
My conclusions:
1) xbar and median yield lower mean error as m increases, so neither
one is obviously biased, as far as we can tell from the experiment.
2) The biased estimator of variance yields lower RMSE than the unbiased
estimator, by about 10%. And the difference holds up as m increases.
Exercise 8.2
Suppose you draw a sample with size $n=10$ from a population
with an exponential disrtribution with $\lambda=2$. Simulate
this experiment 1000 times and plot the sampling distribution of
the estimate $\lamhat$. Compute the standard error of the estimate
and the 90\% confidence interval.
Repeat the experiment with a few different values of $n$ and make
a plot of standard error versus $n$.
1) With sample size 10:
standard error 0.896717911545
confidence interval (1.2901330772324622, 3.8692334892427911)
2) As sample size increases, standard error and the width of
the CI decrease:
10 0.90 (1.3, 3.9)
100 0.21 (1.7, 2.4)
1000 0.06 (1.9, 2.1)
All three confidence intervals contain the actual value, 2.
Exercise 8.3
In games like hockey and soccer, the time between goals is
roughly exponential. So you could estimate a team's goal-scoring rate
by observing the number of goals they score in a game. This
estimation process is a little different from sampling the time
between goals, so let's see how it works.
Write a function that takes a goal-scoring rate, {\tt lam}, in goals
per game, and simulates a game by generating the time between goals
until the total time exceeds 1 game, then returns the number of goals
scored.
Write another function that simulates many games, stores the
estimates of {\tt lam}, then computes their mean error and RMSE.
Is this way of making an estimate biased? Plot the sampling
distribution of the estimates and the 90\% confidence interval. What
is the standard error? What happens to sampling error for increasing
values of {\tt lam}?
My conclusions:
1) RMSE for this way of estimating lambda is 1.4
2) The mean error is small and decreases with m, so this estimator
appears to be unbiased.
One note: If the time between goals is exponential, the distribution
of goals scored in a game is Poisson.
See https://en.wikipedia.org/wiki/Poisson_distribution
"""
def Estimate1(n=7, m=100000):
"""Mean error for xbar and median as estimators of population mean.
n: sample size
m: number of iterations
"""
mu = 0
sigma = 1
means = []
medians = []
for _ in range(m):
xs = [random.gauss(mu, sigma) for i in range(n)]
xbar = np.mean(xs)
median = np.median(xs)
means.append(xbar)
medians.append(median)
print('Experiment 1')
print('mean error xbar', MeanError(means, mu))
print('mean error median', MeanError(medians, mu))
def Estimate2(n=7, m=100000):
"""RMSE for biased and unbiased estimators of population variance.
n: sample size
m: number of iterations
"""
mu = 0
sigma = 1
estimates1 = []
estimates2 = []
for _ in range(m):
xs = [random.gauss(mu, sigma) for i in range(n)]
biased = np.var(xs)
unbiased = np.var(xs, ddof=1)
estimates1.append(biased)
estimates2.append(unbiased)
print('Experiment 2')
print('RMSE biased', RMSE(estimates1, sigma**2))
print('RMSE unbiased', RMSE(estimates2, sigma**2))
def SimulateSample(lam=2, n=10, m=1000):
"""Sampling distribution of L as an estimator of exponential parameter.
lam: parameter of an exponential distribution
n: sample size
m: number of iterations
"""
def VertLine(x, y=1):
thinkplot.Plot([x, x], [0, y], color='0.8', linewidth=3)
estimates = []
for j in range(m):
xs = np.random.exponential(1.0/lam, n)
lamhat = 1.0 / np.mean(xs)
estimates.append(lamhat)
stderr = RMSE(estimates, lam)
print('standard error', stderr)
cdf = thinkstats2.Cdf(estimates)
ci = cdf.Percentile(5), cdf.Percentile(95)
print('confidence interval', ci)
VertLine(ci[0])
VertLine(ci[1])
# plot the CDF
thinkplot.Cdf(cdf)
thinkplot.Save(root='estimation2',
xlabel='estimate',
ylabel='CDF',
title='Sampling distribution')
return stderr
def SimulateGame(lam):
"""Simulates a game and returns the estimated goal-scoring rate.
lam: actual goal scoring rate in goals per game
"""
goals = 0
t = 0
while True:
time_between_goals = random.expovariate(lam)
t += time_between_goals
if t > 1:
break
goals += 1
# estimated goal-scoring rate is the actual number of goals scored
L = goals
return L
def Estimate4(lam=2, m=1000000):
estimates = []
for i in range(m):
L = SimulateGame(lam)
estimates.append(L)
print('Experiment 4')
print('rmse L', RMSE(estimates, lam))
print('mean error L', MeanError(estimates, lam))
pmf = thinkstats2.Pmf(estimates)
thinkplot.Hist(pmf)
thinkplot.Show()
def main():
thinkstats2.RandomSeed(17)
Estimate1()
Estimate2()
print('Experiment 3')
for n in [10, 100, 1000]:
stderr = SimulateSample(n=n)
print(n, stderr)
Estimate4()
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
624,
2765,
570,
3509,
1233,
1202,
315,
298,
2719,
2292,
29062,
401,
199,
991,
4580,
552,
699,
14,
577,
583,
23263,
12,
2808,
687,
12431,
266,
439,
753,
14,
957,
199,
199,
7384,
6927,
4580,
552,
699,
14,
577,
583,
23263,
199,
3761,
26,
1664,
14629,
86,
19,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
14,
1360,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
13516,
3200,
18,
199,
646,
13516,
2798,
199,
199,
646,
3473,
199,
646,
2196,
199,
646,
2680,
465,
980,
199,
199,
504,
7026,
492,
5020,
199,
504,
27156,
492,
820,
45,
899,
12,
25136,
547,
421,
199,
624,
2765,
570,
3509,
282,
8744,
370,
444,
281,
559,
874,
315,
3868,
2292,
29062,
26,
199,
199,
920,
20616,
1695,
14,
17,
199,
199,
607,
642,
17044,
781,
1202,
2672,
60,
88,
1700,
4,
436,
17312,
370,
14497,
2672,
60,
6553,
4,
12,
436,
199,
4214,
626,
2672,
60,
88,
1700,
4,
221,
14801,
5117,
603,
899,
14,
199,
31892,
12,
781,
1202,
2672,
51,
62,
18,
4,
436,
2672,
51,
7348,
78,
13,
17,
93,
62,
18,
4,
370,
14497,
2672,
60,
9412,
4,
12,
436,
1911,
626,
199,
4,
51,
62,
18,
4,
365,
12111,
11185,
436,
2672,
51,
7348,
78,
13,
17,
93,
62,
18,
4,
625,
4492,
11185,
14,
199,
199,
2540,
8545,
444,
22263,
370,
1937,
340,
2672,
60,
88,
1700,
4,
436,
17312,
787,
12111,
11185,
23505,
199,
1618,
2672,
60,
6553,
4,
14,
199,
31892,
1104,
3775,
2672,
51,
62,
18,
4,
503,
2672,
51,
7348,
78,
13,
17,
93,
62,
18,
4,
14801,
282,
5117,
603,
899,
14,
199,
199,
5713,
406,
18540,
26,
199,
199,
17,
9,
671,
1700,
436,
17312,
1995,
5117,
4615,
1125,
465,
333,
10035,
3274,
12,
880,
15564,
199,
368,
365,
25259,
590,
12111,
11185,
12,
465,
12474,
465,
781,
883,
11480,
687,
314,
11805,
14,
199,
199,
18,
9,
710,
12111,
11185,
8943,
402,
11773,
14801,
5117,
820,
45,
899,
2419,
314,
625,
4492,
11185,
199,
8627,
12,
701,
3595,
1616,
17229,
221,
6061,
314,
8865,
15164,
1536,
465,
333,
10035,
3274,
14,
421,
199,
920,
20616,
1695,
14,
18,
199,
199,
4710,
4070,
1265,
5954,
282,
2690,
543,
1568,
2672,
78,
29,
709,
4,
687,
282,
16423,
221,
199,
1045,
376,
23160,
2153,
82,
15980,
543,
2672,
60,
2734,
29,
18,
4,
14,
221,
10751,
5434,
199,
3749,
11805,
5198,
5431,
436,
5137,
314,
15877,
4084,
402,
199,
1589,
14497,
2672,
60,
17984,
8554,
4,
14,
221,
8354,
314,
4465,
1125,
402,
314,
14497,
199,
460,
314,
9137,
60,
5,
15197,
6252,
14,
199,
199,
27600,
314,
11805,
543,
282,
9284,
3365,
1338,
402,
2672,
78,
4,
436,
1852,
199,
65,
5137,
402,
4465,
1125,
809,
25253,
2672,
78,
4,
14,
199,
199,
17,
9,
8777,
2690,
1568,
1616,
26,
199,
199,
6807,
1125,
378,
14,
1407,
1822,
10699,
845,
16981,
199,
13969,
6252,
334,
17,
14,
1398,
614,
14137,
1138,
8001,
2466,
1081,
12,
650,
14,
13254,
1789,
1082,
1407,
1194,
12987,
845,
9,
199,
199,
18,
9,
3709,
2690,
1568,
10035,
3274,
12,
4465,
1125,
436,
314,
3462,
402,
199,
1589,
445,
41,
477,
16772,
26,
199,
199,
709,
420,
378,
14,
2710,
259,
334,
17,
14,
19,
12,
650,
14,
25,
9,
199,
1960,
258,
378,
14,
2025,
259,
334,
17,
14,
23,
12,
499,
14,
20,
9,
199,
5279,
259,
378,
14,
1690,
259,
334,
17,
14,
25,
12,
499,
14,
17,
9,
199,
199,
2422,
7795,
15197,
15802,
1395,
314,
3503,
574,
12,
499,
14,
421,
199,
920,
20616,
1695,
14,
19,
199,
199,
607,
9219,
83,
2839,
394,
766,
14655,
436,
308,
679,
2247,
12,
314,
900,
3382,
2621,
2551,
365,
199,
3202,
590,
23160,
14,
221,
2002,
1265,
4293,
14497,
282,
8099,
1159,
14850,
13,
27128,
6634,
199,
991,
2607,
14717,
314,
1329,
402,
2621,
2551,
2985,
5396,
315,
282,
9219,
14,
221,
961,
199,
597,
8182,
2112,
365,
282,
12050,
3365,
687,
15877,
314,
900,
199,
13007,
2621,
2551,
12,
880,
4691,
1159,
1937,
4212,
652,
5419,
14,
199,
199,
3534,
282,
805,
626,
6181,
282,
14850,
13,
27128,
6634,
12,
9459,
6215,
25917,
1386,
315,
2621,
2551,
199,
529,
9219,
12,
436,
4389,
15409,
282,
9219,
701,
12999,
314,
900,
3382,
2621,
2551,
199,
8111,
314,
3141,
900,
22338,
413,
9219,
12,
2066,
2529,
314,
1329,
402,
2621,
2551,
199,
20845,
581,
14,
199,
199,
3534,
4573,
805,
626,
4389,
15409,
5002,
9219,
83,
12,
14086,
314,
199,
597,
18187,
402,
9459,
6215,
25917,
1386,
2066,
21445,
3932,
4615,
1125,
436,
820,
45,
899,
14,
199,
199,
1831,
642,
4340,
402,
10663,
376,
14497,
12111,
11185,
31,
221,
14794,
314,
15877,
199,
4972,
402,
314,
23505,
436,
314,
9137,
60,
5,
15197,
6252,
14,
221,
14791,
199,
374,
314,
4465,
1125,
31,
221,
14791,
10986,
370,
15877,
1125,
367,
22255,
199,
1459,
402,
9459,
6215,
25917,
93,
31,
199,
199,
5713,
406,
18540,
26,
199,
199,
17,
9,
820,
45,
899,
367,
642,
4340,
402,
4347,
3969,
316,
2400,
365,
413,
14,
20,
199,
199,
18,
9,
710,
4615,
1125,
365,
7425,
436,
477,
1353,
3274,
543,
333,
12,
880,
642,
8943,
199,
31711,
4291,
370,
506,
625,
4492,
11185,
14,
199,
199,
4395,
5317,
26,
982,
314,
900,
3382,
2621,
2551,
365,
23160,
12,
314,
4084,
199,
1618,
2621,
2551,
27748,
581,
315,
282,
9219,
365,
4376,
18571,
14,
199,
199,
9295,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1575,
18571,
63,
4972,
199,
199,
624,
199,
199,
318,
15896,
6897,
17,
8,
78,
29,
23,
12,
333,
29,
15274,
304,
272,
408,
14825,
1125,
367,
671,
1700,
436,
17312,
465,
23155,
402,
16423,
4615,
14,
339,
302,
26,
2690,
1568,
272,
333,
26,
1329,
402,
10615,
272,
408,
272,
8504,
275,
378,
272,
10819,
275,
413,
339,
4910,
275,
942,
272,
25796,
796,
275,
942,
272,
367,
485,
315,
1425,
8,
77,
304,
267,
12965,
275,
359,
2355,
14,
25898,
8,
6553,
12,
10819,
9,
367,
284,
315,
1425,
8,
78,
1874,
267,
671,
1700,
275,
980,
14,
3670,
8,
7977
] |
[
2765,
570,
3509,
1233,
1202,
315,
298,
2719,
2292,
29062,
401,
199,
991,
4580,
552,
699,
14,
577,
583,
23263,
12,
2808,
687,
12431,
266,
439,
753,
14,
957,
199,
199,
7384,
6927,
4580,
552,
699,
14,
577,
583,
23263,
199,
3761,
26,
1664,
14629,
86,
19,
1455,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
14,
1360,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
13516,
3200,
18,
199,
646,
13516,
2798,
199,
199,
646,
3473,
199,
646,
2196,
199,
646,
2680,
465,
980,
199,
199,
504,
7026,
492,
5020,
199,
504,
27156,
492,
820,
45,
899,
12,
25136,
547,
421,
199,
624,
2765,
570,
3509,
282,
8744,
370,
444,
281,
559,
874,
315,
3868,
2292,
29062,
26,
199,
199,
920,
20616,
1695,
14,
17,
199,
199,
607,
642,
17044,
781,
1202,
2672,
60,
88,
1700,
4,
436,
17312,
370,
14497,
2672,
60,
6553,
4,
12,
436,
199,
4214,
626,
2672,
60,
88,
1700,
4,
221,
14801,
5117,
603,
899,
14,
199,
31892,
12,
781,
1202,
2672,
51,
62,
18,
4,
436,
2672,
51,
7348,
78,
13,
17,
93,
62,
18,
4,
370,
14497,
2672,
60,
9412,
4,
12,
436,
1911,
626,
199,
4,
51,
62,
18,
4,
365,
12111,
11185,
436,
2672,
51,
7348,
78,
13,
17,
93,
62,
18,
4,
625,
4492,
11185,
14,
199,
199,
2540,
8545,
444,
22263,
370,
1937,
340,
2672,
60,
88,
1700,
4,
436,
17312,
787,
12111,
11185,
23505,
199,
1618,
2672,
60,
6553,
4,
14,
199,
31892,
1104,
3775,
2672,
51,
62,
18,
4,
503,
2672,
51,
7348,
78,
13,
17,
93,
62,
18,
4,
14801,
282,
5117,
603,
899,
14,
199,
199,
5713,
406,
18540,
26,
199,
199,
17,
9,
671,
1700,
436,
17312,
1995,
5117,
4615,
1125,
465,
333,
10035,
3274,
12,
880,
15564,
199,
368,
365,
25259,
590,
12111,
11185,
12,
465,
12474,
465,
781,
883,
11480,
687,
314,
11805,
14,
199,
199,
18,
9,
710,
12111,
11185,
8943,
402,
11773,
14801,
5117,
820,
45,
899,
2419,
314,
625,
4492,
11185,
199,
8627,
12,
701,
3595,
1616,
17229,
221,
6061,
314,
8865,
15164,
1536,
465,
333,
10035,
3274,
14,
421,
199,
920,
20616,
1695,
14,
18,
199,
199,
4710,
4070,
1265,
5954,
282,
2690,
543,
1568,
2672,
78,
29,
709,
4,
687,
282,
16423,
221,
199,
1045,
376,
23160,
2153,
82,
15980,
543,
2672,
60,
2734,
29,
18,
4,
14,
221,
10751,
5434,
199,
3749,
11805,
5198,
5431,
436,
5137,
314,
15877,
4084,
402,
199,
1589,
14497,
2672,
60,
17984,
8554,
4,
14,
221,
8354,
314,
4465,
1125,
402,
314,
14497,
199,
460,
314,
9137,
60,
5,
15197,
6252,
14,
199,
199,
27600,
314,
11805,
543,
282,
9284,
3365,
1338,
402,
2672,
78,
4,
436,
1852,
199,
65,
5137,
402,
4465,
1125,
809,
25253,
2672,
78,
4,
14,
199,
199,
17,
9,
8777,
2690,
1568,
1616,
26,
199,
199,
6807,
1125,
378,
14,
1407,
1822,
10699,
845,
16981,
199,
13969,
6252,
334,
17,
14,
1398,
614,
14137,
1138,
8001,
2466,
1081,
12,
650,
14,
13254,
1789,
1082,
1407,
1194,
12987,
845,
9,
199,
199,
18,
9,
3709,
2690,
1568,
10035,
3274,
12,
4465,
1125,
436,
314,
3462,
402,
199,
1589,
445,
41,
477,
16772,
26,
199,
199,
709,
420,
378,
14,
2710,
259,
334,
17,
14,
19,
12,
650,
14,
25,
9,
199,
1960,
258,
378,
14,
2025,
259,
334,
17,
14,
23,
12,
499,
14,
20,
9,
199,
5279,
259,
378,
14,
1690,
259,
334,
17,
14,
25,
12,
499,
14,
17,
9,
199,
199,
2422,
7795,
15197,
15802,
1395,
314,
3503,
574,
12,
499,
14,
421,
199,
920,
20616,
1695,
14,
19,
199,
199,
607,
9219,
83,
2839,
394,
766,
14655,
436,
308,
679,
2247,
12,
314,
900,
3382,
2621,
2551,
365,
199,
3202,
590,
23160,
14,
221,
2002,
1265,
4293,
14497,
282,
8099,
1159,
14850,
13,
27128,
6634,
199,
991,
2607,
14717,
314,
1329,
402,
2621,
2551,
2985,
5396,
315,
282,
9219,
14,
221,
961,
199,
597,
8182,
2112,
365,
282,
12050,
3365,
687,
15877,
314,
900,
199,
13007,
2621,
2551,
12,
880,
4691,
1159,
1937,
4212,
652,
5419,
14,
199,
199,
3534,
282,
805,
626,
6181,
282,
14850,
13,
27128,
6634,
12,
9459,
6215,
25917,
1386,
315,
2621,
2551,
199,
529,
9219,
12,
436,
4389,
15409,
282,
9219,
701,
12999,
314,
900,
3382,
2621,
2551,
199,
8111,
314,
3141,
900,
22338,
413,
9219,
12,
2066,
2529,
314,
1329,
402,
2621,
2551,
199,
20845,
581,
14,
199,
199,
3534,
4573,
805,
626,
4389,
15409,
5002,
9219,
83,
12,
14086,
314,
199,
597,
18187,
402,
9459,
6215,
25917,
1386,
2066,
21445,
3932,
4615,
1125,
436,
820,
45,
899,
14,
199,
199,
1831,
642,
4340,
402,
10663,
376,
14497,
12111,
11185,
31,
221,
14794,
314,
15877,
199,
4972,
402,
314,
23505,
436,
314,
9137,
60,
5,
15197,
6252,
14,
221,
14791,
199,
374,
314,
4465,
1125,
31,
221,
14791,
10986,
370,
15877,
1125,
367,
22255,
199,
1459,
402,
9459,
6215,
25917,
93,
31,
199,
199,
5713,
406,
18540,
26,
199,
199,
17,
9,
820,
45,
899,
367,
642,
4340,
402,
4347,
3969,
316,
2400,
365,
413,
14,
20,
199,
199,
18,
9,
710,
4615,
1125,
365,
7425,
436,
477,
1353,
3274,
543,
333,
12,
880,
642,
8943,
199,
31711,
4291,
370,
506,
625,
4492,
11185,
14,
199,
199,
4395,
5317,
26,
982,
314,
900,
3382,
2621,
2551,
365,
23160,
12,
314,
4084,
199,
1618,
2621,
2551,
27748,
581,
315,
282,
9219,
365,
4376,
18571,
14,
199,
199,
9295,
4178,
921,
287,
14,
13961,
14,
1308,
15,
6797,
15,
1575,
18571,
63,
4972,
199,
199,
624,
199,
199,
318,
15896,
6897,
17,
8,
78,
29,
23,
12,
333,
29,
15274,
304,
272,
408,
14825,
1125,
367,
671,
1700,
436,
17312,
465,
23155,
402,
16423,
4615,
14,
339,
302,
26,
2690,
1568,
272,
333,
26,
1329,
402,
10615,
272,
408,
272,
8504,
275,
378,
272,
10819,
275,
413,
339,
4910,
275,
942,
272,
25796,
796,
275,
942,
272,
367,
485,
315,
1425,
8,
77,
304,
267,
12965,
275,
359,
2355,
14,
25898,
8,
6553,
12,
10819,
9,
367,
284,
315,
1425,
8,
78,
1874,
267,
671,
1700,
275,
980,
14,
3670,
8,
7977,
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,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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
] |
cchurch/ansible
|
lib/ansible/modules/cloud/amazon/ec2_vol.py
|
39
|
20083
|
#!/usr/bin/python
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = '''
---
module: ec2_vol
short_description: create and attach a volume, return volume id and device map
description:
- creates an EBS volume and optionally attaches it to an instance.
If both an instance ID and a device name is given and the instance has a device at the device name, then no volume is created and no attachment is made.
This module has a dependency on python-boto.
version_added: "1.1"
options:
instance:
description:
- instance ID if you wish to attach the volume. Since 1.9 you can set to None to detach.
name:
description:
- volume Name tag if you wish to attach an existing volume (requires instance)
version_added: "1.6"
id:
description:
- volume id if you wish to attach an existing volume (requires instance) or remove an existing volume
version_added: "1.6"
volume_size:
description:
- size of volume (in GiB) to create.
volume_type:
description:
- Type of EBS volume; standard (magnetic), gp2 (SSD), io1 (Provisioned IOPS), st1 (Throughput Optimized HDD), sc1 (Cold HDD).
"Standard" is the old EBS default and continues to remain the Ansible default for backwards compatibility.
default: standard
version_added: "1.9"
iops:
description:
- the provisioned IOPs you want to associate with this volume (integer).
default: 100
version_added: "1.3"
encrypted:
description:
- Enable encryption at rest for this volume.
default: 'no'
type: bool
version_added: "1.8"
kms_key_id:
description:
- Specify the id of the KMS key to use.
version_added: "2.3"
device_name:
description:
- device id to override device mapping. Assumes /dev/sdf for Linux/UNIX and /dev/xvdf for Windows.
delete_on_termination:
description:
- When set to "yes", the volume will be deleted upon instance termination.
type: bool
default: 'no'
version_added: "2.1"
zone:
description:
- zone in which to create the volume, if unset uses the zone the instance is in (if set)
aliases: ['aws_zone', 'ec2_zone']
snapshot:
description:
- snapshot ID on which to base the volume
version_added: "1.5"
validate_certs:
description:
- When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0.
type: bool
default: 'yes'
version_added: "1.5"
state:
description:
- whether to ensure the volume is present or absent, or to list existing volumes (The C(list) option was added in version 1.8).
default: present
choices: ['absent', 'present', 'list']
version_added: "1.6"
tags:
description:
- tag:value pairs to add to the volume after creation
default: {}
version_added: "2.3"
author: "Lester Wade (@lwade)"
extends_documentation_fragment:
- aws
- ec2
'''
EXAMPLES = '''
# Simple attachment action
- ec2_vol:
instance: XXXXXX
volume_size: 5
device_name: sdd
# Example using custom iops params
- ec2_vol:
instance: XXXXXX
volume_size: 5
iops: 100
device_name: sdd
# Example using snapshot id
- ec2_vol:
instance: XXXXXX
snapshot: "{{ snapshot }}"
# Playbook example combined with instance launch
- ec2:
keypair: "{{ keypair }}"
image: "{{ image }}"
wait: yes
count: 3
register: ec2
- ec2_vol:
instance: "{{ item.id }}"
volume_size: 5
loop: "{{ ec2.instances }}"
register: ec2_vol
# Example: Launch an instance and then add a volume if not already attached
# * Volume will be created with the given name if not already created.
# * Nothing will happen if the volume is already attached.
# * Requires Ansible 2.0
- ec2:
keypair: "{{ keypair }}"
image: "{{ image }}"
zone: YYYYYY
id: my_instance
wait: yes
count: 1
register: ec2
- ec2_vol:
instance: "{{ item.id }}"
name: my_existing_volume_Name_tag
device_name: /dev/xvdf
loop: "{{ ec2.instances }}"
register: ec2_vol
# Remove a volume
- ec2_vol:
id: vol-XXXXXXXX
state: absent
# Detach a volume (since 1.9)
- ec2_vol:
id: vol-XXXXXXXX
instance: None
# List volumes for an instance
- ec2_vol:
instance: i-XXXXXX
state: list
# Create new volume using SSD storage
- ec2_vol:
instance: XXXXXX
volume_size: 50
volume_type: gp2
device_name: /dev/xvdf
# Attach an existing volume to instance. The volume will be deleted upon instance termination.
- ec2_vol:
instance: XXXXXX
id: XXXXXX
device_name: /dev/sdf
delete_on_termination: yes
'''
RETURN = '''
device:
description: device name of attached volume
returned: when success
type: str
sample: "/def/sdf"
volume_id:
description: the id of volume
returned: when success
type: str
sample: "vol-35b333d9"
volume_type:
description: the volume type
returned: when success
type: str
sample: "standard"
volume:
description: a dictionary containing detailed attributes of the volume
returned: when success
type: str
sample: {
"attachment_set": {
"attach_time": "2015-10-23T00:22:29.000Z",
"deleteOnTermination": "false",
"device": "/dev/sdf",
"instance_id": "i-8356263c",
"status": "attached"
},
"create_time": "2015-10-21T14:36:08.870Z",
"encrypted": false,
"id": "vol-35b333d9",
"iops": null,
"size": 1,
"snapshot_id": "",
"status": "in-use",
"tags": {
"env": "dev"
},
"type": "standard",
"zone": "us-east-1b"
}
'''
import time
from distutils.version import LooseVersion
try:
import boto
import boto.ec2
import boto.exception
from boto.exception import BotoServerError
from boto.ec2.blockdevicemapping import BlockDeviceType, BlockDeviceMapping
except ImportError:
pass # Taken care of by ec2.HAS_BOTO
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import (HAS_BOTO, AnsibleAWSError, connect_to_aws, ec2_argument_spec,
get_aws_connection_info)
def get_volume(module, ec2):
name = module.params.get('name')
id = module.params.get('id')
zone = module.params.get('zone')
filters = {}
volume_ids = None
# If no name or id supplied, just try volume creation based on module parameters
if id is None and name is None:
return None
if zone:
filters['availability_zone'] = zone
if name:
filters = {'tag:Name': name}
if id:
volume_ids = [id]
try:
vols = ec2.get_all_volumes(volume_ids=volume_ids, filters=filters)
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
if not vols:
if id:
msg = "Could not find the volume with id: %s" % id
if name:
msg += (" and name: %s" % name)
module.fail_json(msg=msg)
else:
return None
if len(vols) > 1:
module.fail_json(msg="Found more than one volume in zone (if specified) with name: %s" % name)
return vols[0]
def get_volumes(module, ec2):
instance = module.params.get('instance')
try:
if not instance:
vols = ec2.get_all_volumes()
else:
vols = ec2.get_all_volumes(filters={'attachment.instance-id': instance})
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
return vols
def delete_volume(module, ec2):
volume_id = module.params['id']
try:
ec2.delete_volume(volume_id)
module.exit_json(changed=True)
except boto.exception.EC2ResponseError as ec2_error:
if ec2_error.code == 'InvalidVolume.NotFound':
module.exit_json(changed=False)
module.fail_json(msg=ec2_error.message)
def boto_supports_volume_encryption():
"""
Check if Boto library supports encryption of EBS volumes (added in 2.29.0)
Returns:
True if boto library has the named param as an argument on the request_spot_instances method, else False
"""
return hasattr(boto, 'Version') and LooseVersion(boto.Version) >= LooseVersion('2.29.0')
def boto_supports_kms_key_id():
"""
Check if Boto library supports kms_key_ids (added in 2.39.0)
Returns:
True if version is equal to or higher then the version needed, else False
"""
return hasattr(boto, 'Version') and LooseVersion(boto.Version) >= LooseVersion('2.39.0')
def create_volume(module, ec2, zone):
changed = False
name = module.params.get('name')
iops = module.params.get('iops')
encrypted = module.params.get('encrypted')
kms_key_id = module.params.get('kms_key_id')
volume_size = module.params.get('volume_size')
volume_type = module.params.get('volume_type')
snapshot = module.params.get('snapshot')
tags = module.params.get('tags')
# If custom iops is defined we use volume_type "io1" rather than the default of "standard"
if iops:
volume_type = 'io1'
volume = get_volume(module, ec2)
if volume is None:
try:
if boto_supports_volume_encryption():
if kms_key_id is not None:
volume = ec2.create_volume(volume_size, zone, snapshot, volume_type, iops, encrypted, kms_key_id)
else:
volume = ec2.create_volume(volume_size, zone, snapshot, volume_type, iops, encrypted)
changed = True
else:
volume = ec2.create_volume(volume_size, zone, snapshot, volume_type, iops)
changed = True
while volume.status != 'available':
time.sleep(3)
volume.update()
if name:
tags["Name"] = name
if tags:
ec2.create_tags([volume.id], tags)
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
return volume, changed
def attach_volume(module, ec2, volume, instance):
device_name = module.params.get('device_name')
delete_on_termination = module.params.get('delete_on_termination')
changed = False
# If device_name isn't set, make a choice based on best practices here:
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html
# In future this needs to be more dynamic but combining block device mapping best practices
# (bounds for devices, as above) with instance.block_device_mapping data would be tricky. For me ;)
# Use password data attribute to tell whether the instance is Windows or Linux
if device_name is None:
try:
if not ec2.get_password_data(instance.id):
device_name = '/dev/sdf'
else:
device_name = '/dev/xvdf'
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
if volume.attachment_state() is not None:
adata = volume.attach_data
if adata.instance_id != instance.id:
module.fail_json(msg="Volume %s is already attached to another instance: %s"
% (volume.id, adata.instance_id))
else:
# Volume is already attached to right instance
changed = modify_dot_attribute(module, ec2, instance, device_name)
else:
try:
volume.attach(instance.id, device_name)
while volume.attachment_state() != 'attached':
time.sleep(3)
volume.update()
changed = True
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
modify_dot_attribute(module, ec2, instance, device_name)
return volume, changed
def modify_dot_attribute(module, ec2, instance, device_name):
""" Modify delete_on_termination attribute """
delete_on_termination = module.params.get('delete_on_termination')
changed = False
try:
instance.update()
dot = instance.block_device_mapping[device_name].delete_on_termination
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
if delete_on_termination != dot:
try:
bdt = BlockDeviceType(delete_on_termination=delete_on_termination)
bdm = BlockDeviceMapping()
bdm[device_name] = bdt
ec2.modify_instance_attribute(instance_id=instance.id, attribute='blockDeviceMapping', value=bdm)
while instance.block_device_mapping[device_name].delete_on_termination != delete_on_termination:
time.sleep(3)
instance.update()
changed = True
except boto.exception.BotoServerError as e:
module.fail_json(msg="%s: %s" % (e.error_code, e.error_message))
return changed
def detach_volume(module, ec2, volume):
changed = False
if volume.attachment_state() is not None:
adata = volume.attach_data
volume.detach()
while volume.attachment_state() is not None:
time.sleep(3)
volume.update()
changed = True
return volume, changed
def get_volume_info(volume, state):
# If we're just listing volumes then do nothing, else get the latest update for the volume
if state != 'list':
volume.update()
volume_info = {}
attachment = volume.attach_data
volume_info = {
'create_time': volume.create_time,
'encrypted': volume.encrypted,
'id': volume.id,
'iops': volume.iops,
'size': volume.size,
'snapshot_id': volume.snapshot_id,
'status': volume.status,
'type': volume.type,
'zone': volume.zone,
'attachment_set': {
'attach_time': attachment.attach_time,
'device': attachment.device,
'instance_id': attachment.instance_id,
'status': attachment.status
},
'tags': volume.tags
}
if hasattr(attachment, 'deleteOnTermination'):
volume_info['attachment_set']['deleteOnTermination'] = attachment.deleteOnTermination
return volume_info
def main():
argument_spec = ec2_argument_spec()
argument_spec.update(dict(
instance=dict(),
id=dict(),
name=dict(),
volume_size=dict(),
volume_type=dict(choices=['standard', 'gp2', 'io1', 'st1', 'sc1'], default='standard'),
iops=dict(),
encrypted=dict(type='bool', default=False),
kms_key_id=dict(),
device_name=dict(),
delete_on_termination=dict(type='bool', default=False),
zone=dict(aliases=['availability_zone', 'aws_zone', 'ec2_zone']),
snapshot=dict(),
state=dict(choices=['absent', 'present', 'list'], default='present'),
tags=dict(type='dict', default={})
)
)
module = AnsibleModule(argument_spec=argument_spec)
if not HAS_BOTO:
module.fail_json(msg='boto required for this module')
id = module.params.get('id')
name = module.params.get('name')
instance = module.params.get('instance')
volume_size = module.params.get('volume_size')
encrypted = module.params.get('encrypted')
kms_key_id = module.params.get('kms_key_id')
device_name = module.params.get('device_name')
zone = module.params.get('zone')
snapshot = module.params.get('snapshot')
state = module.params.get('state')
tags = module.params.get('tags')
# Ensure we have the zone or can get the zone
if instance is None and zone is None and state == 'present':
module.fail_json(msg="You must specify either instance or zone")
# Set volume detach flag
if instance == 'None' or instance == '':
instance = None
detach_vol_flag = True
else:
detach_vol_flag = False
# Set changed flag
changed = False
region, ec2_url, aws_connect_params = get_aws_connection_info(module)
if region:
try:
ec2 = connect_to_aws(boto.ec2, region, **aws_connect_params)
except (boto.exception.NoAuthHandlerFound, AnsibleAWSError) as e:
module.fail_json(msg=str(e))
else:
module.fail_json(msg="region must be specified")
if state == 'list':
returned_volumes = []
vols = get_volumes(module, ec2)
for v in vols:
attachment = v.attach_data
returned_volumes.append(get_volume_info(v, state))
module.exit_json(changed=False, volumes=returned_volumes)
if encrypted and not boto_supports_volume_encryption():
module.fail_json(msg="You must use boto >= v2.29.0 to use encrypted volumes")
if kms_key_id is not None and not boto_supports_kms_key_id():
module.fail_json(msg="You must use boto >= v2.39.0 to use kms_key_id")
# Here we need to get the zone info for the instance. This covers situation where
# instance is specified but zone isn't.
# Useful for playbooks chaining instance launch with volume create + attach and where the
# zone doesn't matter to the user.
inst = None
if instance:
try:
reservation = ec2.get_all_instances(instance_ids=instance)
except BotoServerError as e:
module.fail_json(msg=e.message)
inst = reservation[0].instances[0]
zone = inst.placement
# Check if there is a volume already mounted there.
if device_name:
if device_name in inst.block_device_mapping:
module.exit_json(msg="Volume mapping for %s already exists on instance %s" % (device_name, instance),
volume_id=inst.block_device_mapping[device_name].volume_id,
device=device_name,
changed=False)
# Delaying the checks until after the instance check allows us to get volume ids for existing volumes
# without needing to pass an unused volume_size
if not volume_size and not (id or name or snapshot):
module.fail_json(msg="You must specify volume_size or identify an existing volume by id, name, or snapshot")
if volume_size and id:
module.fail_json(msg="Cannot specify volume_size together with id")
if state == 'present':
volume, changed = create_volume(module, ec2, zone)
if detach_vol_flag:
volume, changed = detach_volume(module, ec2, volume)
elif inst is not None:
volume, changed = attach_volume(module, ec2, volume, inst)
# Add device, volume_id and volume_type parameters separately to maintain backward compatibility
volume_info = get_volume_info(volume, state)
# deleteOnTermination is not correctly reflected on attachment
if module.params.get('delete_on_termination'):
for attempt in range(0, 8):
if volume_info['attachment_set'].get('deleteOnTermination') == 'true':
break
time.sleep(5)
volume = ec2.get_all_volumes(volume_ids=volume.id)[0]
volume_info = get_volume_info(volume, state)
module.exit_json(changed=changed, volume=volume_info, device=volume_info['attachment_set']['device'],
volume_id=volume_info['id'], volume_type=volume_info['type'])
elif state == 'absent':
delete_volume(module, ec2)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
11989,
3266,
995,
490,
283,
4946,
63,
991,
356,
283,
1018,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
7062,
18,
63,
5650,
199,
3612,
63,
1802,
26,
1218,
436,
6554,
282,
3301,
12,
372,
3301,
1305,
436,
2243,
2341,
199,
1802,
26,
272,
446,
8491,
376,
662,
11087,
3301,
436,
14190,
6554,
397,
652,
370,
376,
1256,
14,
489,
982,
3865,
376,
1256,
2870,
436,
282,
2243,
536,
365,
1627,
436,
314,
1256,
965,
282,
2243,
737,
314,
2243,
536,
12,
2066,
949,
3301,
365,
2737,
436,
949,
12193,
365,
6326,
14,
489,
961,
859,
965,
282,
5936,
641,
2366,
13,
10914,
14,
199,
1023,
63,
3270,
26,
298,
17,
14,
17,
2,
199,
1419,
26,
523,
1256,
26,
272,
1369,
26,
489,
446,
1256,
2870,
340,
1265,
13809,
370,
6554,
314,
3301,
14,
9336,
413,
14,
25,
1265,
883,
663,
370,
488,
370,
21236,
14,
523,
536,
26,
272,
1369,
26,
489,
446,
3301,
2812,
1947,
340,
1265,
13809,
370,
6554,
376,
3411,
3301,
334,
6537,
1256,
9,
272,
1015,
63,
3270,
26,
298,
17,
14,
22,
2,
523,
1305,
26,
272,
1369,
26,
489,
446,
3301,
1305,
340,
1265,
13809,
370,
6554,
376,
3411,
3301,
334,
6537,
1256,
9,
503,
2813,
376,
3411,
3301,
272,
1015,
63,
3270,
26,
298,
17,
14,
22,
2,
523,
3301,
63,
890,
26,
272,
1369,
26,
489,
446,
1568,
402,
3301,
334,
262,
598,
17587,
9,
370,
1218,
14,
523,
3301,
63,
466,
26,
272,
1369,
26,
489,
446,
2434,
402,
662,
11087,
3301,
27,
4465,
334,
5615,
685,
764,
395,
15852,
18,
334,
2300,
36,
395,
5890,
17,
334,
919,
31310,
473,
21665,
395,
410,
17,
334,
26732,
524,
19246,
1759,
869,
5745,
395,
4061,
17,
334,
35,
1753,
869,
5745,
680,
267,
298,
9232,
2,
365,
314,
2269,
662,
11087,
849,
436,
32438,
370,
5706,
314,
2622,
849,
367,
8552,
7163,
14,
272,
849,
26,
4465,
272,
1015,
63,
3270,
26,
298,
17,
14,
25,
2,
523,
284,
1483,
26,
272,
1369,
26,
489,
446,
314,
1727,
12308,
473,
1938,
83,
1265,
2934,
370,
20133,
543,
642,
3301,
334,
4115,
680,
272,
849,
26,
2948,
272,
1015,
63,
3270,
26,
298,
17,
14,
19,
2,
523,
14862,
26,
272,
1369,
26,
489,
446,
12030,
14396,
737,
4618,
367,
642,
3301,
14,
272,
849,
26,
283,
889,
7,
272,
730,
26,
2155,
272,
1015,
63,
3270,
26,
298,
17,
14,
24,
2,
523,
1022,
706,
63,
498,
63,
344,
26,
272,
1369,
26,
489,
446,
13327,
314,
1305,
402,
314,
1804,
3053,
790,
370,
675,
14,
272,
1015,
63,
3270,
26,
298,
18,
14,
19,
2,
523,
2243,
63,
354,
26,
272,
1369,
26,
489,
446,
2243,
1305,
370,
4278,
2243,
4412,
14,
30451,
1182,
2374,
15,
83,
1587,
367,
10130,
15,
19584,
436,
1182,
2374,
15,
25466,
1587,
367,
5417,
14,
523,
3145,
63,
265,
63,
20667,
26,
272,
1369,
26,
489,
446,
3979,
663,
370,
298,
5066,
401,
314,
3301,
911,
506,
5463,
12188,
1256,
23868,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
272,
1015,
63,
3270,
26,
298,
18,
14,
17,
2,
523,
5718,
26,
272,
1369,
26,
489,
446,
5718,
315,
1314,
370,
1218,
314,
3301,
12,
340,
15376,
4440,
314,
5718,
314,
1256,
365,
315,
334,
692,
663,
9,
272,
5481,
26,
788,
7231,
63,
2619,
297,
283,
825,
18,
63,
2619,
418,
523,
5740,
26,
272,
1369,
26,
489,
446,
5740,
2870,
641,
1314,
370,
1300,
314,
3301,
272,
1015,
63,
3270,
26,
298,
17,
14,
21,
2,
523,
4107,
63,
8356,
26,
272,
1369,
26,
489,
446,
3979,
663,
370,
298,
889,
401,
7799,
14512,
911,
440,
506,
16468,
367,
6055,
5459,
2356,
499,
14,
22,
14,
16,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
5066,
7,
272,
1015,
63,
3270,
26,
298,
17,
14,
21,
2,
523,
1174,
26,
272,
1369,
26,
489,
446,
3775,
370,
4868,
314,
3301,
365,
3451,
503,
9552,
12,
503,
370,
769,
3411,
12158,
334,
1918,
445,
8,
513,
9,
945,
1990,
3483,
315,
1015,
413,
14,
24,
680,
272,
849,
26,
3451,
272,
3415,
26,
788,
5575,
297,
283,
1881,
297,
283,
513,
418,
272,
1015,
63,
3270,
26,
298,
17,
14,
22,
2,
523,
3762,
26,
272,
1369,
26,
489,
446,
1947,
26,
585,
6342,
370,
1050,
370,
314,
3301,
2410,
7143,
272,
849,
26,
1052,
272,
1015,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
2502,
26,
298,
44,
17338,
644,
9587,
8593,
76,
758,
271,
2924,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
11488,
272,
446,
7062,
18,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5870,
12193,
1595,
199,
13,
7062,
18,
63,
5650,
26,
272,
1256,
26,
5787,
13933,
272,
3301,
63,
890,
26,
959,
272,
2243,
63,
354,
26,
308,
617,
199,
199,
3,
5679,
1808,
3537,
284,
1483,
1862,
199,
13,
7062,
18,
63,
5650,
26,
272,
1256,
26,
5787,
13933,
272,
3301,
63,
890,
26,
959,
272,
284,
1483,
26,
2948,
272,
2243,
63,
354,
26,
308,
617,
199,
199,
3,
5679,
1808,
5740,
1305,
199,
13,
7062,
18,
63,
5650,
26,
272,
1256,
26,
5787,
13933,
272,
5740,
26,
7370,
5740,
7820,
199,
199,
3,
16527,
2706,
2893,
12149,
543,
1256,
10623,
199,
13,
7062,
18,
26,
272,
23911,
26,
7370,
23911,
7820,
272,
1834,
26,
7370,
1834,
7820,
272,
3618,
26,
9456,
272,
2338,
26,
650,
523,
2274,
26,
7062,
18,
199,
13,
7062,
18,
63,
5650,
26,
272,
1256,
26,
7370,
1242,
14,
344,
7820,
272,
3301,
63,
890,
26,
959,
523,
4438,
26,
7370,
7062,
18,
14
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1898,
26,
2622,
7290,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
421,
199,
8490,
63,
8314,
275,
791,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
490,
283,
1205,
356,
788,
11989,
3266,
995,
490,
283,
4946,
63,
991,
356,
283,
1018,
936,
421,
199,
8948,
275,
1449,
199,
2595,
199,
578,
26,
7062,
18,
63,
5650,
199,
3612,
63,
1802,
26,
1218,
436,
6554,
282,
3301,
12,
372,
3301,
1305,
436,
2243,
2341,
199,
1802,
26,
272,
446,
8491,
376,
662,
11087,
3301,
436,
14190,
6554,
397,
652,
370,
376,
1256,
14,
489,
982,
3865,
376,
1256,
2870,
436,
282,
2243,
536,
365,
1627,
436,
314,
1256,
965,
282,
2243,
737,
314,
2243,
536,
12,
2066,
949,
3301,
365,
2737,
436,
949,
12193,
365,
6326,
14,
489,
961,
859,
965,
282,
5936,
641,
2366,
13,
10914,
14,
199,
1023,
63,
3270,
26,
298,
17,
14,
17,
2,
199,
1419,
26,
523,
1256,
26,
272,
1369,
26,
489,
446,
1256,
2870,
340,
1265,
13809,
370,
6554,
314,
3301,
14,
9336,
413,
14,
25,
1265,
883,
663,
370,
488,
370,
21236,
14,
523,
536,
26,
272,
1369,
26,
489,
446,
3301,
2812,
1947,
340,
1265,
13809,
370,
6554,
376,
3411,
3301,
334,
6537,
1256,
9,
272,
1015,
63,
3270,
26,
298,
17,
14,
22,
2,
523,
1305,
26,
272,
1369,
26,
489,
446,
3301,
1305,
340,
1265,
13809,
370,
6554,
376,
3411,
3301,
334,
6537,
1256,
9,
503,
2813,
376,
3411,
3301,
272,
1015,
63,
3270,
26,
298,
17,
14,
22,
2,
523,
3301,
63,
890,
26,
272,
1369,
26,
489,
446,
1568,
402,
3301,
334,
262,
598,
17587,
9,
370,
1218,
14,
523,
3301,
63,
466,
26,
272,
1369,
26,
489,
446,
2434,
402,
662,
11087,
3301,
27,
4465,
334,
5615,
685,
764,
395,
15852,
18,
334,
2300,
36,
395,
5890,
17,
334,
919,
31310,
473,
21665,
395,
410,
17,
334,
26732,
524,
19246,
1759,
869,
5745,
395,
4061,
17,
334,
35,
1753,
869,
5745,
680,
267,
298,
9232,
2,
365,
314,
2269,
662,
11087,
849,
436,
32438,
370,
5706,
314,
2622,
849,
367,
8552,
7163,
14,
272,
849,
26,
4465,
272,
1015,
63,
3270,
26,
298,
17,
14,
25,
2,
523,
284,
1483,
26,
272,
1369,
26,
489,
446,
314,
1727,
12308,
473,
1938,
83,
1265,
2934,
370,
20133,
543,
642,
3301,
334,
4115,
680,
272,
849,
26,
2948,
272,
1015,
63,
3270,
26,
298,
17,
14,
19,
2,
523,
14862,
26,
272,
1369,
26,
489,
446,
12030,
14396,
737,
4618,
367,
642,
3301,
14,
272,
849,
26,
283,
889,
7,
272,
730,
26,
2155,
272,
1015,
63,
3270,
26,
298,
17,
14,
24,
2,
523,
1022,
706,
63,
498,
63,
344,
26,
272,
1369,
26,
489,
446,
13327,
314,
1305,
402,
314,
1804,
3053,
790,
370,
675,
14,
272,
1015,
63,
3270,
26,
298,
18,
14,
19,
2,
523,
2243,
63,
354,
26,
272,
1369,
26,
489,
446,
2243,
1305,
370,
4278,
2243,
4412,
14,
30451,
1182,
2374,
15,
83,
1587,
367,
10130,
15,
19584,
436,
1182,
2374,
15,
25466,
1587,
367,
5417,
14,
523,
3145,
63,
265,
63,
20667,
26,
272,
1369,
26,
489,
446,
3979,
663,
370,
298,
5066,
401,
314,
3301,
911,
506,
5463,
12188,
1256,
23868,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
889,
7,
272,
1015,
63,
3270,
26,
298,
18,
14,
17,
2,
523,
5718,
26,
272,
1369,
26,
489,
446,
5718,
315,
1314,
370,
1218,
314,
3301,
12,
340,
15376,
4440,
314,
5718,
314,
1256,
365,
315,
334,
692,
663,
9,
272,
5481,
26,
788,
7231,
63,
2619,
297,
283,
825,
18,
63,
2619,
418,
523,
5740,
26,
272,
1369,
26,
489,
446,
5740,
2870,
641,
1314,
370,
1300,
314,
3301,
272,
1015,
63,
3270,
26,
298,
17,
14,
21,
2,
523,
4107,
63,
8356,
26,
272,
1369,
26,
489,
446,
3979,
663,
370,
298,
889,
401,
7799,
14512,
911,
440,
506,
16468,
367,
6055,
5459,
2356,
499,
14,
22,
14,
16,
14,
272,
730,
26,
2155,
272,
849,
26,
283,
5066,
7,
272,
1015,
63,
3270,
26,
298,
17,
14,
21,
2,
523,
1174,
26,
272,
1369,
26,
489,
446,
3775,
370,
4868,
314,
3301,
365,
3451,
503,
9552,
12,
503,
370,
769,
3411,
12158,
334,
1918,
445,
8,
513,
9,
945,
1990,
3483,
315,
1015,
413,
14,
24,
680,
272,
849,
26,
3451,
272,
3415,
26,
788,
5575,
297,
283,
1881,
297,
283,
513,
418,
272,
1015,
63,
3270,
26,
298,
17,
14,
22,
2,
523,
3762,
26,
272,
1369,
26,
489,
446,
1947,
26,
585,
6342,
370,
1050,
370,
314,
3301,
2410,
7143,
272,
849,
26,
1052,
272,
1015,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
2502,
26,
298,
44,
17338,
644,
9587,
8593,
76,
758,
271,
2924,
199,
11036,
63,
9970,
63,
7677,
26,
272,
446,
11488,
272,
446,
7062,
18,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5870,
12193,
1595,
199,
13,
7062,
18,
63,
5650,
26,
272,
1256,
26,
5787,
13933,
272,
3301,
63,
890,
26,
959,
272,
2243,
63,
354,
26,
308,
617,
199,
199,
3,
5679,
1808,
3537,
284,
1483,
1862,
199,
13,
7062,
18,
63,
5650,
26,
272,
1256,
26,
5787,
13933,
272,
3301,
63,
890,
26,
959,
272,
284,
1483,
26,
2948,
272,
2243,
63,
354,
26,
308,
617,
199,
199,
3,
5679,
1808,
5740,
1305,
199,
13,
7062,
18,
63,
5650,
26,
272,
1256,
26,
5787,
13933,
272,
5740,
26,
7370,
5740,
7820,
199,
199,
3,
16527,
2706,
2893,
12149,
543,
1256,
10623,
199,
13,
7062,
18,
26,
272,
23911,
26,
7370,
23911,
7820,
272,
1834,
26,
7370,
1834,
7820,
272,
3618,
26,
9456,
272,
2338,
26,
650,
523,
2274,
26,
7062,
18,
199,
13,
7062,
18,
63,
5650,
26,
272,
1256,
26,
7370,
1242,
14,
344,
7820,
272,
3301,
63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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
scality/cinder
|
cinder/tests/unit/test_volume.py
|
1
|
348716
|
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# 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 Volume Code."""
import datetime
import os
import shutil
import socket
import sys
import tempfile
import time
import enum
import eventlet
import mock
from mox3 import mox
import os_brick
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_utils import importutils
from oslo_utils import timeutils
from oslo_utils import units
import six
from stevedore import extension
from taskflow.engines.action_engine import engine
from cinder.api import common
from cinder.brick.local_dev import lvm as brick_lvm
from cinder import context
from cinder import db
from cinder import exception
from cinder.image import image_utils
from cinder import keymgr
from cinder import objects
import cinder.policy
from cinder import quota
from cinder import test
from cinder.tests.unit.api import fakes
from cinder.tests.unit.brick import fake_lvm
from cinder.tests.unit import conf_fixture
from cinder.tests.unit import fake_driver
from cinder.tests.unit import fake_snapshot
from cinder.tests.unit import fake_volume
from cinder.tests.unit.image import fake as fake_image
from cinder.tests.unit.keymgr import fake as fake_keymgr
from cinder.tests.unit import utils as tests_utils
from cinder import utils
import cinder.volume
from cinder.volume import configuration as conf
from cinder.volume import driver
from cinder.volume.drivers import lvm
from cinder.volume import manager as vol_manager
from cinder.volume import rpcapi as volume_rpcapi
import cinder.volume.targets.tgt
from cinder.volume import utils as volutils
from cinder.volume import volume_types
QUOTAS = quota.QUOTAS
CGQUOTAS = quota.CGQUOTAS
CONF = cfg.CONF
ENCRYPTION_PROVIDER = 'nova.volume.encryptors.cryptsetup.CryptsetupEncryptor'
fake_opt = [
cfg.StrOpt('fake_opt1', default='fake', help='fake opts')
]
class FakeImageService(object):
def __init__(self, db_driver=None, image_service=None):
pass
def show(self, context, image_id):
return {'size': 2 * units.Gi,
'disk_format': 'raw',
'container_format': 'bare',
'status': 'active'}
class BaseVolumeTestCase(test.TestCase):
"""Test Case for volumes."""
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa'
def setUp(self):
super(BaseVolumeTestCase, self).setUp()
self.extension_manager = extension.ExtensionManager(
"BaseVolumeTestCase")
vol_tmpdir = tempfile.mkdtemp()
self.flags(volumes_dir=vol_tmpdir,
notification_driver=["test"])
self.addCleanup(self._cleanup)
self.volume = importutils.import_object(CONF.volume_manager)
self.configuration = mock.Mock(conf.Configuration)
self.context = context.get_admin_context()
self.context.user_id = 'fake'
# NOTE(mriedem): The id is hard-coded here for tracking race fail
# assertions with the notification code, it's part of an
# elastic-recheck query so don't remove it or change it.
self.project_id = '7f265bd4-3a85-465e-a899-5dc4854a86d3'
self.context.project_id = self.project_id
self.volume_params = {
'status': 'creating',
'host': CONF.host,
'size': 1}
self.stubs.Set(brick_lvm.LVM,
'get_all_volume_groups',
self.fake_get_all_volume_groups)
fake_image.stub_out_image_service(self.stubs)
self.stubs.Set(brick_lvm.LVM, '_vg_exists', lambda x: True)
self.stubs.Set(os.path, 'exists', lambda x: True)
self.volume.driver.set_initialized()
self.volume.stats = {'allocated_capacity_gb': 0,
'pools': {}}
# keep ordered record of what we execute
self.called = []
def _cleanup(self):
try:
shutil.rmtree(CONF.volumes_dir)
except OSError:
pass
def fake_get_all_volume_groups(obj, vg_name=None, no_suffix=True):
return [{'name': 'cinder-volumes',
'size': '5.00',
'available': '2.50',
'lv_count': '2',
'uuid': 'vR1JU3-FAKE-C4A9-PQFh-Mctm-9FwA-Xwzc1m'}]
class AvailabilityZoneTestCase(BaseVolumeTestCase):
def test_list_availability_zones_cached(self):
volume_api = cinder.volume.api.API()
with mock.patch.object(volume_api.db,
'service_get_all_by_topic') as get_all:
get_all.return_value = [
{
'availability_zone': 'a',
'disabled': False,
},
]
azs = volume_api.list_availability_zones(enable_cache=True)
self.assertEqual([{"name": 'a', 'available': True}], list(azs))
self.assertIsNotNone(volume_api.availability_zones_last_fetched)
self.assertTrue(get_all.called)
volume_api.list_availability_zones(enable_cache=True)
self.assertEqual(1, get_all.call_count)
def test_list_availability_zones_no_cached(self):
volume_api = cinder.volume.api.API()
with mock.patch.object(volume_api.db,
'service_get_all_by_topic') as get_all:
get_all.return_value = [
{
'availability_zone': 'a',
'disabled': False,
},
]
azs = volume_api.list_availability_zones(enable_cache=False)
self.assertEqual([{"name": 'a', 'available': True}], list(azs))
self.assertIsNone(volume_api.availability_zones_last_fetched)
with mock.patch.object(volume_api.db,
'service_get_all_by_topic') as get_all:
get_all.return_value = [
{
'availability_zone': 'a',
'disabled': True,
},
]
azs = volume_api.list_availability_zones(enable_cache=False)
self.assertEqual([{"name": 'a', 'available': False}], list(azs))
self.assertIsNone(volume_api.availability_zones_last_fetched)
def test_list_availability_zones_refetched(self):
timeutils.set_time_override()
volume_api = cinder.volume.api.API()
with mock.patch.object(volume_api.db,
'service_get_all_by_topic') as get_all:
get_all.return_value = [
{
'availability_zone': 'a',
'disabled': False,
},
]
azs = volume_api.list_availability_zones(enable_cache=True)
self.assertEqual([{"name": 'a', 'available': True}], list(azs))
self.assertIsNotNone(volume_api.availability_zones_last_fetched)
last_fetched = volume_api.availability_zones_last_fetched
self.assertTrue(get_all.called)
volume_api.list_availability_zones(enable_cache=True)
self.assertEqual(1, get_all.call_count)
# The default cache time is 3600, push past that...
timeutils.advance_time_seconds(3800)
get_all.return_value = [
{
'availability_zone': 'a',
'disabled': False,
},
{
'availability_zone': 'b',
'disabled': False,
},
]
azs = volume_api.list_availability_zones(enable_cache=True)
azs = sorted([n['name'] for n in azs])
self.assertEqual(['a', 'b'], azs)
self.assertEqual(2, get_all.call_count)
self.assertGreater(volume_api.availability_zones_last_fetched,
last_fetched)
def test_list_availability_zones_enabled_service(self):
services = [
{'availability_zone': 'ping', 'disabled': 0},
{'availability_zone': 'ping', 'disabled': 1},
{'availability_zone': 'pong', 'disabled': 0},
{'availability_zone': 'pung', 'disabled': 1},
]
def stub_service_get_all_by_topic(*args, **kwargs):
return services
self.stubs.Set(db, 'service_get_all_by_topic',
stub_service_get_all_by_topic)
def sort_func(obj):
return obj['name']
volume_api = cinder.volume.api.API()
azs = volume_api.list_availability_zones()
azs = sorted(azs, key=sort_func)
expected = sorted([
{'name': 'pung', 'available': False},
{'name': 'pong', 'available': True},
{'name': 'ping', 'available': True},
], key=sort_func)
self.assertEqual(expected, azs)
class VolumeTestCase(BaseVolumeTestCase):
def setUp(self):
super(VolumeTestCase, self).setUp()
self._clear_patch = mock.patch('cinder.volume.utils.clear_volume',
autospec=True)
self._clear_patch.start()
self.expected_status = 'available'
def tearDown(self):
super(VolumeTestCase, self).tearDown()
self._clear_patch.stop()
def test_init_host_clears_downloads(self):
"""Test that init_host will unwedge a volume stuck in downloading."""
volume = tests_utils.create_volume(self.context, status='downloading',
size=0, host=CONF.host)
volume_id = volume['id']
self.volume.init_host()
volume = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual("error", volume['status'])
self.volume.delete_volume(self.context, volume_id)
def test_init_host_resumes_deletes(self):
"""init_host will resume deleting volume in deleting status."""
volume = tests_utils.create_volume(self.context, status='deleting',
size=0, host=CONF.host)
volume_id = volume['id']
self.volume.init_host()
self.assertRaises(exception.VolumeNotFound, db.volume_get,
context.get_admin_context(), volume_id)
def test_init_host_count_allocated_capacity(self):
vol0 = tests_utils.create_volume(
self.context, size=100, host=CONF.host)
vol1 = tests_utils.create_volume(
self.context, size=128,
host=volutils.append_host(CONF.host, 'pool0'))
vol2 = tests_utils.create_volume(
self.context, size=256,
host=volutils.append_host(CONF.host, 'pool0'))
vol3 = tests_utils.create_volume(
self.context, size=512,
host=volutils.append_host(CONF.host, 'pool1'))
vol4 = tests_utils.create_volume(
self.context, size=1024,
host=volutils.append_host(CONF.host, 'pool2'))
self.volume.init_host()
stats = self.volume.stats
self.assertEqual(2020, stats['allocated_capacity_gb'])
self.assertEqual(
384, stats['pools']['pool0']['allocated_capacity_gb'])
self.assertEqual(
512, stats['pools']['pool1']['allocated_capacity_gb'])
self.assertEqual(
1024, stats['pools']['pool2']['allocated_capacity_gb'])
# NOTE(jdg): On the create we have host='xyz', BUT
# here we do a db.volume_get, and now the host has
# been updated to xyz#pool-name. Note this is
# done via the managers init, which calls the drivers
# get_pool method, which in the legacy case is going
# to be volume_backend_name or None
vol0 = db.volume_get(context.get_admin_context(), vol0['id'])
self.assertEqual(volutils.append_host(CONF.host, 'LVM'),
vol0['host'])
self.volume.delete_volume(self.context, vol0['id'])
self.volume.delete_volume(self.context, vol1['id'])
self.volume.delete_volume(self.context, vol2['id'])
self.volume.delete_volume(self.context, vol3['id'])
self.volume.delete_volume(self.context, vol4['id'])
@mock.patch.object(vol_manager.VolumeManager, 'add_periodic_task')
def test_init_host_repl_enabled_periodic_task(self, mock_add_p_task):
manager = vol_manager.VolumeManager()
with mock.patch.object(manager.driver,
'get_volume_stats') as m_get_stats:
m_get_stats.return_value = {'replication': True}
manager.init_host()
mock_add_p_task.assert_called_once_with(mock.ANY)
@mock.patch.object(vol_manager.VolumeManager, 'add_periodic_task')
def test_init_host_repl_disabled_periodic_task(self, mock_add_p_task):
manager = vol_manager.VolumeManager()
with mock.patch.object(manager.driver,
'get_volume_stats') as m_get_stats:
m_get_stats.return_value = {'replication': False}
manager.init_host()
self.assertEqual(0, mock_add_p_task.call_count)
@mock.patch.object(vol_manager.VolumeManager,
'update_service_capabilities')
def test_report_filter_goodness_function(self, mock_update):
manager = vol_manager.VolumeManager()
manager.driver.set_initialized()
myfilterfunction = "myFilterFunction"
mygoodnessfunction = "myGoodnessFunction"
expected = {'name': 'cinder-volumes',
'filter_function': myfilterfunction,
'goodness_function': mygoodnessfunction,
}
with mock.patch.object(manager.driver,
'get_volume_stats') as m_get_stats:
with mock.patch.object(manager.driver,
'get_goodness_function') as m_get_goodness:
with mock.patch.object(manager.driver,
'get_filter_function') as m_get_filter:
m_get_stats.return_value = {'name': 'cinder-volumes'}
m_get_filter.return_value = myfilterfunction
m_get_goodness.return_value = mygoodnessfunction
manager._report_driver_status(1)
self.assertTrue(m_get_stats.called)
mock_update.assert_called_once_with(expected)
def test_is_working(self):
# By default we have driver mocked to be initialized...
self.assertTrue(self.volume.is_working())
# ...lets switch it and check again!
self.volume.driver._initialized = False
self.assertFalse(self.volume.is_working())
def test_create_volume_fails_with_creating_and_downloading_status(self):
"""Test init_host in case of volume.
While the status of volume is 'creating' or 'downloading',
volume process down.
After process restarting this 'creating' status is changed to 'error'.
"""
for status in ['creating', 'downloading']:
volume = tests_utils.create_volume(self.context, status=status,
size=0, host=CONF.host)
volume_id = volume['id']
self.volume.init_host()
volume = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('error', volume['status'])
self.volume.delete_volume(self.context, volume_id)
def test_create_snapshot_fails_with_creating_status(self):
"""Test init_host in case of snapshot.
While the status of snapshot is 'creating', volume process
down. After process restarting this 'creating' status is
changed to 'error'.
"""
volume = tests_utils.create_volume(self.context,
**self.volume_params)
snapshot = tests_utils.create_snapshot(self.context,
volume['id'],
status='creating')
snap_id = snapshot['id']
self.volume.init_host()
snapshot_obj = objects.Snapshot.get_by_id(self.context, snap_id)
self.assertEqual('error', snapshot_obj.status)
self.volume.delete_snapshot(self.context, snapshot_obj)
self.volume.delete_volume(self.context, volume['id'])
@mock.patch.object(QUOTAS, 'reserve')
@mock.patch.object(QUOTAS, 'commit')
@mock.patch.object(QUOTAS, 'rollback')
def test_create_driver_not_initialized(self, reserve, commit, rollback):
self.volume.driver._initialized = False
def fake_reserve(context, expire=None, project_id=None, **deltas):
return ["RESERVATION"]
def fake_commit_and_rollback(context, reservations, project_id=None):
pass
reserve.return_value = fake_reserve
commit.return_value = fake_commit_and_rollback
rollback.return_value = fake_commit_and_rollback
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
volume_id = volume['id']
self.assertIsNone(volume['encryption_key_id'])
self.assertEqual(0, len(self.notifier.notifications),
self.notifier.notifications)
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_volume,
self.context, volume_id)
volume = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual("error", volume.status)
db.volume_destroy(context.get_admin_context(), volume_id)
def test_create_driver_not_initialized_rescheduling(self):
self.volume.driver._initialized = False
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
volume_id = volume['id']
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_volume,
self.context, volume_id,
{'volume_properties': self.volume_params},
{'retry': {'num_attempts': 1, 'host': []}})
# NOTE(dulek): Volume should be rescheduled as we passed request_spec
# and filter_properties, assert that it wasn't counted in
# allocated_capacity tracking.
self.assertEqual({}, self.volume.stats['pools'])
db.volume_destroy(context.get_admin_context(), volume_id)
def test_create_non_cinder_exception_rescheduling(self):
params = self.volume_params
del params['host']
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**params)
volume_id = volume['id']
with mock.patch.object(self.volume.driver, 'create_volume',
side_effect=processutils.ProcessExecutionError):
self.assertRaises(processutils.ProcessExecutionError,
self.volume.create_volume,
self.context, volume_id,
{'volume_properties': params},
{'retry': {'num_attempts': 1, 'host': []}})
# NOTE(dulek): Volume should be rescheduled as we passed request_spec
# and filter_properties, assert that it wasn't counted in
# allocated_capacity tracking.
self.assertEqual({}, self.volume.stats['pools'])
db.volume_destroy(context.get_admin_context(), volume_id)
@mock.patch.object(QUOTAS, 'rollback')
@mock.patch.object(QUOTAS, 'commit')
@mock.patch.object(QUOTAS, 'reserve')
def test_delete_driver_not_initialized(self, reserve, commit, rollback):
self.volume.driver._initialized = False
def fake_reserve(context, expire=None, project_id=None, **deltas):
return ["RESERVATION"]
def fake_commit_and_rollback(context, reservations, project_id=None):
pass
reserve.return_value = fake_reserve
commit.return_value = fake_commit_and_rollback
rollback.return_value = fake_commit_and_rollback
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
self.assertIsNone(volume['encryption_key_id'])
self.assertEqual(0, len(self.notifier.notifications),
self.notifier.notifications)
self.assertRaises(exception.DriverNotInitialized,
self.volume.delete_volume,
self.context, volume.id)
volume = objects.Volume.get_by_id(self.context, volume.id)
self.assertEqual("error_deleting", volume.status)
volume.destroy()
@mock.patch('cinder.quota.QUOTAS.rollback', new=mock.Mock())
@mock.patch('cinder.quota.QUOTAS.commit', new=mock.Mock())
@mock.patch('cinder.quota.QUOTAS.reserve', return_value=['RESERVATION'])
def test_create_delete_volume(self, _mock_reserve):
"""Test volume can be created and deleted."""
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
volume_id = volume['id']
self.assertIsNone(volume['encryption_key_id'])
self.assertEqual(0, len(self.notifier.notifications),
self.notifier.notifications)
self.volume.create_volume(self.context, volume_id)
self.assertEqual(2, len(self.notifier.notifications),
self.notifier.notifications)
msg = self.notifier.notifications[0]
self.assertEqual('volume.create.start', msg['event_type'])
expected = {
'status': 'creating',
'host': socket.gethostname(),
'display_name': 'test_volume',
'availability_zone': 'nova',
'tenant_id': self.context.project_id,
'created_at': 'DONTCARE',
'volume_id': volume_id,
'volume_type': None,
'snapshot_id': None,
'user_id': 'fake',
'launched_at': 'DONTCARE',
'size': 1,
'replication_status': 'disabled',
'replication_extended_status': None,
'replication_driver_data': None,
'metadata': None,
'volume_attachment': [],
}
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[1]
self.assertEqual('volume.create.end', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
self.assertEqual(volume_id, db.volume_get(context.get_admin_context(),
volume_id).id)
self.volume.delete_volume(self.context, volume_id)
vol = db.volume_get(context.get_admin_context(read_deleted='yes'),
volume_id)
self.assertEqual('deleted', vol['status'])
self.assertEqual(4, len(self.notifier.notifications),
self.notifier.notifications)
msg = self.notifier.notifications[2]
self.assertEqual('volume.delete.start', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[3]
self.assertEqual('volume.delete.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
self.assertRaises(exception.NotFound,
db.volume_get,
self.context,
volume_id)
def test_create_delete_volume_with_metadata(self):
"""Test volume can be created with metadata and deleted."""
test_meta = {'fake_key': 'fake_value'}
volume = tests_utils.create_volume(self.context, metadata=test_meta,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
self.assertEqual(test_meta, volume.metadata)
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.NotFound,
db.volume_get,
self.context,
volume_id)
def test_create_volume_with_invalid_metadata(self):
"""Test volume create with too much metadata fails."""
volume_api = cinder.volume.api.API()
test_meta = {'fake_key': 'fake_value' * 256}
self.assertRaises(exception.InvalidVolumeMetadataSize,
volume_api.create,
self.context,
1,
'name',
'description',
None,
None,
None,
test_meta)
def test_update_volume_metadata_with_metatype(self):
"""Test update volume metadata with different metadata type."""
test_meta1 = {'fake_key1': 'fake_value1'}
test_meta2 = {'fake_key1': 'fake_value2'}
FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
self.volume.create_volume(self.context, volume.id, volume=volume)
volume_api = cinder.volume.api.API()
# update user metadata associated with the volume.
result_meta = volume_api.update_volume_metadata(
self.context,
volume,
test_meta2,
False,
common.METADATA_TYPES.user)
self.assertEqual(test_meta2, result_meta)
# create image metadata associated with the volume.
result_meta = volume_api.update_volume_metadata(
self.context,
volume,
test_meta1,
False,
common.METADATA_TYPES.image)
self.assertEqual(test_meta1, result_meta)
# update image metadata associated with the volume.
result_meta = volume_api.update_volume_metadata(
self.context,
volume,
test_meta2,
False,
common.METADATA_TYPES.image)
self.assertEqual(test_meta2, result_meta)
# update volume metadata with invalid metadta type.
self.assertRaises(exception.InvalidMetadataType,
volume_api.update_volume_metadata,
self.context,
volume,
test_meta1,
False,
FAKE_METADATA_TYPE.fake_type)
def test_update_volume_metadata_maintenance(self):
"""Test update volume metadata with different metadata type."""
test_meta1 = {'fake_key1': 'fake_value1'}
FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.update_volume_metadata,
self.context,
volume,
test_meta1,
False,
FAKE_METADATA_TYPE.fake_type)
@mock.patch('cinder.db.volume_update')
def test_update_with_ovo(self, volume_update):
"""Test update volume using oslo_versionedobject."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_api = cinder.volume.api.API()
updates = {'display_name': 'foobbar'}
volume_api.update(self.context, volume, updates)
volume_update.assert_called_once_with(self.context, volume.id,
updates)
self.assertEqual('foobbar', volume.display_name)
def test_delete_volume_metadata_with_metatype(self):
"""Test delete volume metadata with different metadata type."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
test_meta2 = {'fake_key1': 'fake_value1'}
FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
volume_api = cinder.volume.api.API()
# delete user metadata associated with the volume.
volume_api.delete_volume_metadata(
self.context,
volume,
'fake_key2',
common.METADATA_TYPES.user)
self.assertEqual(test_meta2,
db.volume_metadata_get(self.context, volume_id))
# create image metadata associated with the volume.
result_meta = volume_api.update_volume_metadata(
self.context,
volume,
test_meta1,
False,
common.METADATA_TYPES.image)
self.assertEqual(test_meta1, result_meta)
# delete image metadata associated with the volume.
volume_api.delete_volume_metadata(
self.context,
volume,
'fake_key2',
common.METADATA_TYPES.image)
# parse the result to build the dict.
rows = db.volume_glance_metadata_get(self.context, volume_id)
result = {}
for row in rows:
result[row['key']] = row['value']
self.assertEqual(test_meta2, result)
# delete volume metadata with invalid metadta type.
self.assertRaises(exception.InvalidMetadataType,
volume_api.delete_volume_metadata,
self.context,
volume,
'fake_key1',
FAKE_METADATA_TYPE.fake_type)
def test_delete_volume_metadata_maintenance(self):
"""Test delete volume metadata in maintenance."""
FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.delete_volume_metadata,
self.context,
volume,
'fake_key1',
FAKE_METADATA_TYPE.fake_type)
def test_volume_attach_in_maintenance(self):
"""Test attach the volume in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.attach,
self.context,
volume, None, None, None, None)
def test_volume_detach_in_maintenance(self):
"""Test detach the volume in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.detach,
self.context,
volume, None)
def test_initialize_connection_maintenance(self):
"""Test initialize connection in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.initialize_connection,
self.context,
volume,
None)
def test_accept_transfer_maintenance(self):
"""Test accept transfer in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.accept_transfer,
self.context,
volume,
None, None)
def test_copy_volume_to_image_maintenance(self):
"""Test copy volume to image in maintenance."""
test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
volume = tests_utils.create_volume(self.context, metadata=test_meta1,
**self.volume_params)
volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.copy_volume_to_image,
self.context,
volume,
test_meta1,
force=True)
@mock.patch.object(cinder.volume.api.API, 'list_availability_zones')
def test_create_volume_uses_default_availability_zone(self, mock_list_az):
"""Test setting availability_zone correctly during volume create."""
mock_list_az.return_value = ({'name': 'az1', 'available': True},
{'name': 'az2', 'available': True},
{'name': 'default-az', 'available': True})
volume_api = cinder.volume.api.API()
# Test backwards compatibility, default_availability_zone not set
self.override_config('storage_availability_zone', 'az2')
volume = volume_api.create(self.context,
1,
'name',
'description')
self.assertEqual('az2', volume['availability_zone'])
self.override_config('default_availability_zone', 'default-az')
volume = volume_api.create(self.context,
1,
'name',
'description')
self.assertEqual('default-az', volume['availability_zone'])
@mock.patch('cinder.quota.QUOTAS.rollback', new=mock.MagicMock())
@mock.patch('cinder.quota.QUOTAS.commit', new=mock.MagicMock())
@mock.patch('cinder.quota.QUOTAS.reserve', return_value=["RESERVATION"])
def test_create_volume_with_volume_type(self, _mock_reserve):
"""Test volume creation with default volume type."""
volume_api = cinder.volume.api.API()
# Create volume with default volume type while default
# volume type doesn't exist, volume_type_id should be NULL
volume = volume_api.create(self.context,
1,
'name',
'description')
self.assertIsNone(volume['volume_type_id'])
self.assertIsNone(volume['encryption_key_id'])
# Create default volume type
vol_type = conf_fixture.def_vol_type
db.volume_type_create(context.get_admin_context(),
{'name': vol_type, 'extra_specs': {}})
db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
vol_type)
# Create volume with default volume type
volume = volume_api.create(self.context,
1,
'name',
'description')
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
self.assertIsNone(volume['encryption_key_id'])
# Create volume with specific volume type
vol_type = 'test'
db.volume_type_create(context.get_admin_context(),
{'name': vol_type, 'extra_specs': {}})
db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
vol_type)
volume = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
@mock.patch.object(keymgr, 'API', fake_keymgr.fake_api)
def test_create_volume_with_encrypted_volume_type(self):
ctxt = context.get_admin_context()
db.volume_type_create(ctxt,
{'id': '61298380-0c12-11e3-bfd6-4b48424183be',
'name': 'LUKS'})
db.volume_type_encryption_create(
ctxt,
'61298380-0c12-11e3-bfd6-4b48424183be',
{'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER})
volume_api = cinder.volume.api.API()
db_vol_type = db.volume_type_get_by_name(ctxt, 'LUKS')
volume = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
self.assertIsNotNone(volume['encryption_key_id'])
def test_create_volume_with_provider_id(self):
volume_params_with_provider_id = dict(provider_id='1111-aaaa',
**self.volume_params)
volume = tests_utils.create_volume(self.context,
**volume_params_with_provider_id)
self.volume.create_volume(self.context, volume['id'])
self.assertEqual('1111-aaaa', volume['provider_id'])
@mock.patch.object(keymgr, 'API', new=fake_keymgr.fake_api)
def test_create_delete_volume_with_encrypted_volume_type(self):
ctxt = context.get_admin_context()
db.volume_type_create(ctxt,
{'id': '61298380-0c12-11e3-bfd6-4b48424183be',
'name': 'LUKS'})
db.volume_type_encryption_create(
ctxt,
'61298380-0c12-11e3-bfd6-4b48424183be',
{'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER})
volume_api = cinder.volume.api.API()
db_vol_type = db.volume_type_get_by_name(ctxt, 'LUKS')
volume = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
self.assertIsNotNone(volume.get('encryption_key_id', None))
self.assertEqual(db_vol_type.get('id'), volume['volume_type_id'])
self.assertIsNotNone(volume['encryption_key_id'])
volume['host'] = 'fake_host'
volume['status'] = 'available'
volume_api.delete(self.context, volume)
volume = db.volume_get(self.context, volume['id'])
self.assertEqual('deleting', volume['status'])
db.volume_destroy(self.context, volume['id'])
self.assertRaises(exception.NotFound,
db.volume_get,
self.context,
volume['id'])
def test_extra_capabilities(self):
# Test valid extra_capabilities.
fake_capabilities = {'key1': 1, 'key2': 2}
with mock.patch.object(jsonutils, 'loads') as mock_loads:
mock_loads.return_value = fake_capabilities
manager = vol_manager.VolumeManager()
manager.stats = {'pools': {}}
manager.driver.set_initialized()
manager.publish_service_capabilities(self.context)
self.assertTrue(mock_loads.called)
volume_stats = manager.last_capabilities
self.assertEqual(fake_capabilities['key1'],
volume_stats['key1'])
self.assertEqual(fake_capabilities['key2'],
volume_stats['key2'])
def test_extra_capabilities_fail(self):
with mock.patch.object(jsonutils, 'loads') as mock_loads:
mock_loads.side_effect = exception.CinderException('test')
self.assertRaises(exception.CinderException,
vol_manager.VolumeManager)
@mock.patch.object(db, 'volume_get_all_by_host')
def test_update_replication_rel_status(self, m_get_by_host):
m_get_by_host.return_value = [mock.sentinel.vol]
ctxt = context.get_admin_context()
manager = vol_manager.VolumeManager()
with mock.patch.object(manager.driver,
'get_replication_status') as m_get_rep_status:
m_get_rep_status.return_value = None
manager._update_replication_relationship_status(ctxt)
m_get_rep_status.assert_called_once_with(ctxt, mock.sentinel.vol)
exp_filters = {
'replication_status':
['active', 'copying', 'error', 'active-stopped', 'inactive']}
m_get_by_host.assert_called_once_with(ctxt, manager.host,
filters=exp_filters)
@mock.patch.object(db, 'volume_get_all_by_host',
mock.Mock(return_value=[{'id': 'foo'}]))
@mock.patch.object(db, 'volume_update')
def test_update_replication_rel_status_update_vol(self, mock_update):
"""Volume is updated with replication update data."""
ctxt = context.get_admin_context()
manager = vol_manager.VolumeManager()
with mock.patch.object(manager.driver,
'get_replication_status') as m_get_rep_status:
m_get_rep_status.return_value = mock.sentinel.model_update
manager._update_replication_relationship_status(ctxt)
mock_update.assert_called_once_with(ctxt, 'foo',
mock.sentinel.model_update)
@mock.patch.object(db, 'volume_get_all_by_host',
mock.Mock(return_value=[{'id': 'foo'}]))
def test_update_replication_rel_status_with_repl_support_exc(self):
"""Exception handled when raised getting replication status."""
ctxt = context.get_admin_context()
manager = vol_manager.VolumeManager()
manager.driver._initialized = True
manager.driver._stats['replication'] = True
with mock.patch.object(manager.driver,
'get_replication_status') as m_get_rep_status:
m_get_rep_status.side_effect = Exception()
manager._update_replication_relationship_status(ctxt)
def test_delete_busy_volume(self):
"""Test volume survives deletion if driver reports it as busy."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
self.mox.StubOutWithMock(self.volume.driver, 'delete_volume')
self.volume.driver.delete_volume(
mox.IgnoreArg()).AndRaise(exception.VolumeIsBusy(
volume_name='fake'))
self.mox.ReplayAll()
res = self.volume.delete_volume(self.context, volume_id)
self.assertTrue(res)
volume_ref = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual(volume_id, volume_ref.id)
self.assertEqual("available", volume_ref.status)
def test_get_volume_different_tenant(self):
"""Test can't get volume of another tenant when viewable_admin_meta."""
volume = tests_utils.create_volume(self.context,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
another_context = context.RequestContext('another_user_id',
'another_project_id',
is_admin=False)
self.assertNotEqual(another_context.project_id,
self.context.project_id)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.VolumeNotFound, volume_api.get,
another_context, volume_id, viewable_admin_meta=True)
self.assertEqual(volume_id,
volume_api.get(self.context, volume_id)['id'])
self.volume.delete_volume(self.context, volume_id)
def test_get_all_limit_bad_value(self):
"""Test value of 'limit' is numeric and >= 0"""
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.get_all,
self.context,
limit="A")
self.assertRaises(exception.InvalidInput,
volume_api.get_all,
self.context,
limit="-1")
def test_get_all_tenants_volume_list(self):
"""Validate when the volume list for all tenants is returned"""
volume_api = cinder.volume.api.API()
with mock.patch.object(volume_api.db,
'volume_get_all_by_project') as by_project:
with mock.patch.object(volume_api.db,
'volume_get_all') as get_all:
db_volume = {'volume_type_id': 'fake_type_id',
'name': 'fake_name',
'host': 'fake_host',
'id': 'fake_volume_id'}
volume = fake_volume.fake_db_volume(**db_volume)
by_project.return_value = [volume]
get_all.return_value = [volume]
volume_api.get_all(self.context, filters={'all_tenants': '0'})
self.assertTrue(by_project.called)
by_project.called = False
self.context.is_admin = False
volume_api.get_all(self.context, filters={'all_tenants': '1'})
self.assertTrue(by_project.called)
# check for volume list of all tenants
self.context.is_admin = True
volume_api.get_all(self.context, filters={'all_tenants': '1'})
self.assertTrue(get_all.called)
def test_delete_volume_in_error_extending(self):
"""Test volume can be deleted in error_extending stats."""
# create a volume
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume['id'])
# delete 'error_extending' volume
db.volume_update(self.context, volume['id'],
{'status': 'error_extending'})
self.volume.delete_volume(self.context, volume['id'])
self.assertRaises(exception.NotFound, db.volume_get,
self.context, volume['id'])
@mock.patch.object(db.sqlalchemy.api, 'volume_get',
side_effect=exception.VolumeNotFound(
volume_id='12345678-1234-5678-1234-567812345678'))
def test_delete_volume_not_found(self, mock_get_volume):
"""Test delete volume moves on if the volume does not exist."""
volume_id = '12345678-1234-5678-1234-567812345678'
self.assertTrue(self.volume.delete_volume(self.context, volume_id))
self.assertTrue(mock_get_volume.called)
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'create_volume_from_snapshot')
def test_create_volume_from_snapshot(self, mock_create_from_snap):
"""Test volume can be created from a snapshot."""
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src['id'])
snapshot_id = self._create_snapshot(volume_src['id'],
size=volume_src['size'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.volume.create_snapshot(self.context, volume_src['id'],
snapshot_obj)
volume_dst = tests_utils.create_volume(self.context,
snapshot_id=snapshot_id,
**self.volume_params)
self.volume.create_volume(self.context, volume_dst['id'])
self.assertEqual(volume_dst['id'],
db.volume_get(
context.get_admin_context(),
volume_dst['id']).id)
self.assertEqual(snapshot_id,
db.volume_get(context.get_admin_context(),
volume_dst['id']).snapshot_id)
self.volume.delete_volume(self.context, volume_dst['id'])
self.volume.delete_snapshot(self.context, snapshot_obj)
self.volume.delete_volume(self.context, volume_src['id'])
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_snapshot_with_types(self, _get_flow):
"""Test volume create from snapshot with types including mistmatch."""
volume_api = cinder.volume.api.API()
db.volume_type_create(
context.get_admin_context(),
{'name': 'foo',
'extra_specs': {'volume_backend_name': 'dev_1'}})
db.volume_type_create(
context.get_admin_context(),
{'name': 'biz', 'extra_specs': {'volume_backend_name': 'dev_2'}})
foo_type = db.volume_type_get_by_name(context.get_admin_context(),
'foo')
biz_type = db.volume_type_get_by_name(context.get_admin_context(),
'biz')
snapshot = {'id': 1234,
'status': 'available',
'volume_size': 10,
'volume_type_id': biz_type['id']}
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context,
**snapshot)
# Make sure the case of specifying a type that
# doesn't match the snapshots type fails
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
snapshot=snapshot_obj)
# Make sure that trying to specify a type
# when the snapshots type is None fails
snapshot_obj.volume_type_id = None
self.assertRaises(exception.InvalidVolumeType,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
snapshot=snapshot_obj)
with mock.patch.object(cinder.volume.volume_types,
'get_volume_type') as mock_get_type:
mock_get_type.return_value = biz_type
snapshot_obj.volume_type_id = foo_type['id']
volume_api.create(self.context, size=1, name='fake_name',
description='fake_desc', volume_type=foo_type,
snapshot=snapshot_obj)
db.volume_type_destroy(context.get_admin_context(),
foo_type['id'])
db.volume_type_destroy(context.get_admin_context(),
biz_type['id'])
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_source_with_types(self, _get_flow):
"""Test volume create from source with types including mistmatch."""
volume_api = cinder.volume.api.API()
db.volume_type_create(
context.get_admin_context(),
{'name': 'foo',
'extra_specs': {'volume_backend_name': 'dev_1'}})
db.volume_type_create(
context.get_admin_context(),
{'name': 'biz', 'extra_specs': {'volume_backend_name': 'dev_2'}})
foo_type = db.volume_type_get_by_name(context.get_admin_context(),
'foo')
biz_type = db.volume_type_get_by_name(context.get_admin_context(),
'biz')
source_vol = {'id': 1234,
'status': 'available',
'volume_size': 10,
'volume_type': biz_type,
'volume_type_id': biz_type['id']}
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=source_vol)
# Make sure that trying to specify a type
# when the source type is None fails
source_vol['volume_type_id'] = None
source_vol['volume_type'] = None
self.assertRaises(exception.InvalidVolumeType,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=source_vol)
with mock.patch.object(cinder.volume.volume_types,
'get_volume_type') as mock_get_type:
mock_get_type.return_value = biz_type
source_vol['volume_type_id'] = biz_type['id']
source_vol['volume_type'] = biz_type
volume_api.create(self.context, size=1, name='fake_name',
description='fake_desc', volume_type=biz_type,
source_volume=source_vol)
db.volume_type_destroy(context.get_admin_context(),
foo_type['id'])
db.volume_type_destroy(context.get_admin_context(),
biz_type['id'])
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_source_with_same_backend(self, _get_flow):
"""Test volume create from source with type mismatch same backend."""
volume_api = cinder.volume.api.API()
foo_type = {
'name': 'foo',
'qos_specs_id': None,
'deleted': False,
'created_at': datetime.datetime(2015, 5, 8, 0, 40, 5, 408232),
'updated_at': None,
'extra_specs': {'volume_backend_name': 'dev_1'},
'is_public': True,
'deleted_at': None,
'id': '29e43b50-2cd7-4d0c-8ddd-2119daab3a38',
'description': None}
biz_type = {
'name': 'biz',
'qos_specs_id': None,
'deleted': False,
'created_at': datetime.datetime(2015, 5, 8, 0, 20, 5, 408232),
'updated_at': None,
'extra_specs': {'volume_backend_name': 'dev_1'},
'is_public': True,
'deleted_at': None,
'id': '34e54c31-3bc8-5c1d-9fff-2225bcce4b59',
'description': None}
source_vol = {'id': 1234,
'status': 'available',
'volume_size': 10,
'volume_type': biz_type,
'volume_type_id': biz_type['id']}
with mock.patch.object(cinder.volume.volume_types,
'get_volume_type') as mock_get_type:
mock_get_type.return_value = biz_type
volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=source_vol)
@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_from_source_and_snap_only_one_backend(self, _get_flow):
"""Test create from source and snap with type mismatch one backend."""
volume_api = cinder.volume.api.API()
foo_type = {
'name': 'foo',
'qos_specs_id': None,
'deleted': False,
'created_at': datetime.datetime(2015, 5, 8, 0, 40, 5, 408232),
'updated_at': None,
'extra_specs': {'some_key': 3},
'is_public': True,
'deleted_at': None,
'id': '29e43b50-2cd7-4d0c-8ddd-2119daab3a38',
'description': None}
biz_type = {
'name': 'biz',
'qos_specs_id': None,
'deleted': False,
'created_at': datetime.datetime(2015, 5, 8, 0, 20, 5, 408232),
'updated_at': None,
'extra_specs': {'some_other_key': 4},
'is_public': True,
'deleted_at': None,
'id': '34e54c31-3bc8-5c1d-9fff-2225bcce4b59',
'description': None}
source_vol = {'id': 1234,
'status': 'available',
'volume_size': 10,
'volume_type': biz_type,
'volume_type_id': biz_type['id']}
snapshot = {'id': 1234,
'status': 'available',
'volume_size': 10,
'volume_type_id': biz_type['id']}
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context,
**snapshot)
with mock.patch.object(db,
'service_get_all_by_topic') as mock_get_service, \
mock.patch.object(volume_api,
'list_availability_zones') as mock_get_azs:
mock_get_service.return_value = [{'host': 'foo'}]
mock_get_azs.return_value = {}
volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
source_volume=source_vol)
volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
volume_type=foo_type,
snapshot=snapshot_obj)
def test_create_snapshot_driver_not_initialized(self):
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src['id'])
snapshot_id = self._create_snapshot(volume_src['id'],
size=volume_src['size'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.volume.driver._initialized = False
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_snapshot,
self.context, volume_src['id'], snapshot_obj)
# NOTE(flaper87): The volume status should be error.
self.assertEqual("error", snapshot_obj.status)
# lets cleanup the mess
self.volume.driver._initialized = True
self.volume.delete_snapshot(self.context, snapshot_obj)
self.volume.delete_volume(self.context, volume_src['id'])
def _mock_synchronized(self, name, *s_args, **s_kwargs):
def inner_sync1(f):
def inner_sync2(*args, **kwargs):
self.called.append('lock-%s' % (name))
ret = f(*args, **kwargs)
self.called.append('unlock-%s' % (name))
return ret
return inner_sync2
return inner_sync1
def _fake_execute(self, *cmd, **kwargs):
pass
@mock.patch.object(cinder.volume.drivers.lvm.LVMISCSIDriver,
'create_volume_from_snapshot')
def test_create_volume_from_snapshot_check_locks(
self, mock_lvm_create):
# mock the synchroniser so we can record events
self.stubs.Set(utils, 'synchronized', self._mock_synchronized)
orig_flow = engine.ActionEngine.run
def mock_flow_run(*args, **kwargs):
# ensure the lock has been taken
self.assertEqual(1, len(self.called))
# now proceed with the flow.
ret = orig_flow(*args, **kwargs)
return ret
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
# no lock
self.volume.create_volume(self.context, src_vol_id)
snap_id = self._create_snapshot(src_vol_id,
size=src_vol['size'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snap_id)
# no lock
self.volume.create_snapshot(self.context, src_vol_id, snapshot_obj)
dst_vol = tests_utils.create_volume(self.context,
snapshot_id=snap_id,
**self.volume_params)
dst_vol_id = dst_vol['id']
admin_ctxt = context.get_admin_context()
# mock the flow runner so we can do some checks
self.stubs.Set(engine.ActionEngine, 'run', mock_flow_run)
# locked
self.volume.create_volume(self.context, volume_id=dst_vol_id,
request_spec={'snapshot_id': snap_id})
self.assertEqual(2, len(self.called))
self.assertEqual(dst_vol_id, db.volume_get(admin_ctxt, dst_vol_id).id)
self.assertEqual(snap_id,
db.volume_get(admin_ctxt, dst_vol_id).snapshot_id)
# locked
self.volume.delete_volume(self.context, dst_vol_id)
self.assertEqual(4, len(self.called))
# locked
self.volume.delete_snapshot(self.context, snapshot_obj)
self.assertEqual(6, len(self.called))
# locked
self.volume.delete_volume(self.context, src_vol_id)
self.assertEqual(8, len(self.called))
self.assertEqual(['lock-%s' % ('%s-delete_snapshot' % (snap_id)),
'unlock-%s' % ('%s-delete_snapshot' % (snap_id)),
'lock-%s' % ('%s-delete_volume' % (dst_vol_id)),
'unlock-%s' % ('%s-delete_volume' % (dst_vol_id)),
'lock-%s' % ('%s-delete_snapshot' % (snap_id)),
'unlock-%s' % ('%s-delete_snapshot' % (snap_id)),
'lock-%s' % ('%s-delete_volume' % (src_vol_id)),
'unlock-%s' % ('%s-delete_volume' % (src_vol_id))],
self.called)
self.assertTrue(mock_lvm_create.called)
def test_create_volume_from_volume_check_locks(self):
# mock the synchroniser so we can record events
self.stubs.Set(utils, 'synchronized', self._mock_synchronized)
self.stubs.Set(utils, 'execute', self._fake_execute)
orig_flow = engine.ActionEngine.run
def mock_flow_run(*args, **kwargs):
# ensure the lock has been taken
self.assertEqual(1, len(self.called))
# now proceed with the flow.
ret = orig_flow(*args, **kwargs)
return ret
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
# no lock
self.volume.create_volume(self.context, src_vol_id)
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
dst_vol_id = dst_vol['id']
admin_ctxt = context.get_admin_context()
# mock the flow runner so we can do some checks
self.stubs.Set(engine.ActionEngine, 'run', mock_flow_run)
# locked
self.volume.create_volume(self.context, volume_id=dst_vol_id,
request_spec={'source_volid': src_vol_id})
self.assertEqual(2, len(self.called))
self.assertEqual(dst_vol_id, db.volume_get(admin_ctxt, dst_vol_id).id)
self.assertEqual(src_vol_id,
db.volume_get(admin_ctxt, dst_vol_id).source_volid)
# locked
self.volume.delete_volume(self.context, dst_vol_id)
self.assertEqual(4, len(self.called))
# locked
self.volume.delete_volume(self.context, src_vol_id)
self.assertEqual(6, len(self.called))
self.assertEqual(['lock-%s' % ('%s-delete_volume' % (src_vol_id)),
'unlock-%s' % ('%s-delete_volume' % (src_vol_id)),
'lock-%s' % ('%s-delete_volume' % (dst_vol_id)),
'unlock-%s' % ('%s-delete_volume' % (dst_vol_id)),
'lock-%s' % ('%s-delete_volume' % (src_vol_id)),
'unlock-%s' % ('%s-delete_volume' % (src_vol_id))],
self.called)
def test_create_volume_from_volume_delete_lock_taken(self):
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
# no lock
self.volume.create_volume(self.context, src_vol_id)
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
orig_elevated = self.context.elevated
gthreads = []
def mock_elevated(*args, **kwargs):
# unset mock so it is only called once
self.stubs.Set(self.context, 'elevated', orig_elevated)
# we expect this to block and then fail
t = eventlet.spawn(self.volume.create_volume,
self.context,
volume_id=dst_vol.id,
request_spec={'source_volid': src_vol_id})
gthreads.append(t)
return orig_elevated(*args, **kwargs)
# mock something from early on in the delete operation and within the
# lock so that when we do the create we expect it to block.
self.stubs.Set(self.context, 'elevated', mock_elevated)
# locked
self.volume.delete_volume(self.context, src_vol_id)
# we expect the volume create to fail with the following err since the
# source volume was deleted while the create was locked. Note that the
# volume is still in the db since it was created by the test prior to
# calling manager.create_volume.
with mock.patch('sys.stderr', new=six.StringIO()):
self.assertRaises(exception.VolumeNotFound, gthreads[0].wait)
def _raise_metadata_copy_failure(self, method, dst_vol_id, **kwargs):
# MetadataCopyFailure exception will be raised if DB service is Down
# while copying the volume glance metadata
with mock.patch.object(db, method) as mock_db:
mock_db.side_effect = exception.MetadataCopyFailure(
reason="Because of DB service down.")
self.assertRaises(exception.MetadataCopyFailure,
self.volume.create_volume,
self.context,
dst_vol_id,
**kwargs)
# ensure that status of volume is 'error'
vol = db.volume_get(self.context, dst_vol_id)
self.assertEqual('error', vol['status'])
# cleanup resource
db.volume_destroy(self.context, dst_vol_id)
@mock.patch('cinder.utils.execute')
def test_create_volume_from_volume_with_glance_volume_metadata_none(
self, mock_execute):
# create source volume
mock_execute.return_value = None
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol_id)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
# create volume from source volume
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
self.volume.create_volume(self.context,
dst_vol['id'])
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_glance_metadata_copy_from_volume_to_volume,
self.context, src_vol_id, dst_vol['id'])
# ensure that status of volume is 'available'
vol = db.volume_get(self.context, dst_vol['id'])
self.assertEqual('available', vol['status'])
# cleanup resource
db.volume_destroy(self.context, src_vol_id)
db.volume_destroy(self.context, dst_vol['id'])
@mock.patch('cinder.utils.execute')
def test_create_volume_from_volume_raise_metadata_copy_failure(
self, mock_execute):
# create source volume
mock_execute.return_value = None
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol_id)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
# create volume from source volume
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
self._raise_metadata_copy_failure(
'volume_glance_metadata_copy_from_volume_to_volume',
dst_vol['id'])
# cleanup resource
db.volume_destroy(self.context, src_vol_id)
@mock.patch('cinder.utils.execute')
def test_create_volume_from_snapshot_raise_metadata_copy_failure(
self, mock_execute):
# create source volume
mock_execute.return_value = None
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol_id)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
# create volume from snapshot
snapshot_id = self._create_snapshot(src_vol['id'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.volume.create_snapshot(self.context, src_vol['id'], snapshot_obj)
# ensure that status of snapshot is 'available'
self.assertEqual('available', snapshot_obj.status)
dst_vol = tests_utils.create_volume(self.context,
snapshot_id=snapshot_id,
**self.volume_params)
self._raise_metadata_copy_failure(
'volume_glance_metadata_copy_to_volume',
dst_vol['id'])
# cleanup resource
snapshot_obj.destroy()
db.volume_destroy(self.context, src_vol_id)
@mock.patch(
'cinder.volume.driver.VolumeDriver.create_replica_test_volume')
@mock.patch('cinder.utils.execute')
def test_create_volume_from_srcreplica_raise_metadata_copy_failure(
self, mock_execute, _create_replica_test):
mock_execute.return_value = None
_create_replica_test.return_value = None
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol_id)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
# create volume from source volume
dst_vol = tests_utils.create_volume(self.context,
source_volid=src_vol_id,
**self.volume_params)
self._raise_metadata_copy_failure(
'volume_glance_metadata_copy_from_volume_to_volume',
dst_vol['id'])
# cleanup resource
db.volume_destroy(self.context, src_vol_id)
@mock.patch('cinder.utils.execute')
def test_create_volume_from_snapshot_with_glance_volume_metadata_none(
self, mock_execute):
# create source volume
mock_execute.return_value = None
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
self.volume.create_volume(self.context, src_vol_id)
# set bootable flag of volume to True
db.volume_update(self.context, src_vol['id'], {'bootable': True})
volume = db.volume_get(self.context, src_vol_id)
# create snapshot of volume
snapshot_id = self._create_snapshot(volume['id'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.volume.create_snapshot(self.context, volume['id'], snapshot_obj)
# ensure that status of snapshot is 'available'
self.assertEqual('available', snapshot_obj.status)
# create volume from snapshot
dst_vol = tests_utils.create_volume(self.context,
snapshot_id=snapshot_id,
**self.volume_params)
self.volume.create_volume(self.context, dst_vol.id, volume=dst_vol)
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_glance_metadata_copy_to_volume,
self.context, dst_vol['id'], snapshot_id)
# ensure that status of volume is 'available'
vol = db.volume_get(self.context, dst_vol['id'])
self.assertEqual('available', vol['status'])
# cleanup resource
snapshot_obj.destroy()
db.volume_destroy(self.context, src_vol_id)
db.volume_destroy(self.context, dst_vol['id'])
@mock.patch(
'cinder.volume.driver.VolumeDriver.create_replica_test_volume')
def test_create_volume_from_srcreplica_with_glance_volume_metadata_none(
self, _create_replica_test):
"""Test volume can be created from a volume replica."""
_create_replica_test.return_value = None
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src['id'])
db.volume_update(self.context, volume_src['id'], {'bootable': True})
volume = db.volume_get(self.context, volume_src['id'])
volume_dst = tests_utils.create_volume(
self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_dst['id'],
{'source_replicaid': volume['id']})
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_glance_metadata_copy_from_volume_to_volume,
self.context, volume_src['id'], volume_dst['id'])
self.assertEqual('available',
db.volume_get(self.context,
volume_dst['id']).status)
self.assertTrue(_create_replica_test.called)
# cleanup resource
db.volume_destroy(self.context, volume_dst['id'])
db.volume_destroy(self.context, volume_src['id'])
def test_create_volume_from_snapshot_delete_lock_taken(self):
# create source volume
src_vol = tests_utils.create_volume(self.context, **self.volume_params)
src_vol_id = src_vol['id']
# no lock
self.volume.create_volume(self.context, src_vol_id)
# create snapshot
snap_id = self._create_snapshot(src_vol_id,
size=src_vol['size'])['id']
snapshot_obj = objects.Snapshot.get_by_id(self.context, snap_id)
# no lock
self.volume.create_snapshot(self.context, src_vol_id, snapshot_obj)
# create vol from snapshot...
dst_vol = tests_utils.create_volume(self.context,
snapshot_id=snap_id,
source_volid=src_vol_id,
**self.volume_params)
dst_vol_id = dst_vol['id']
orig_elevated = self.context.elevated
gthreads = []
def mock_elevated(*args, **kwargs):
# unset mock so it is only called once
self.stubs.Set(self.context, 'elevated', orig_elevated)
# We expect this to block and then fail
t = eventlet.spawn(self.volume.create_volume, self.context,
volume_id=dst_vol_id,
request_spec={'snapshot_id': snap_id})
gthreads.append(t)
return orig_elevated(*args, **kwargs)
# mock something from early on in the delete operation and within the
# lock so that when we do the create we expect it to block.
self.stubs.Set(self.context, 'elevated', mock_elevated)
# locked
self.volume.delete_snapshot(self.context, snapshot_obj)
# we expect the volume create to fail with the following err since the
# snapshot was deleted while the create was locked. Note that the
# volume is still in the db since it was created by the test prior to
# calling manager.create_volume.
with mock.patch('sys.stderr', new=six.StringIO()):
self.assertRaises(exception.SnapshotNotFound, gthreads[0].wait)
# locked
self.volume.delete_volume(self.context, src_vol_id)
# make sure it is gone
self.assertRaises(exception.VolumeNotFound, db.volume_get,
self.context, src_vol_id)
@mock.patch.object(keymgr, 'API', fake_keymgr.fake_api)
def test_create_volume_from_snapshot_with_encryption(self):
"""Test volume can be created from a snapshot of an encrypted volume"""
ctxt = context.get_admin_context()
db.volume_type_create(ctxt,
{'id': '61298380-0c12-11e3-bfd6-4b48424183be',
'name': 'LUKS'})
db.volume_type_encryption_create(
ctxt,
'61298380-0c12-11e3-bfd6-4b48424183be',
{'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER})
volume_api = cinder.volume.api.API()
db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
'LUKS')
volume_src = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
volume_src['host'] = 'fake_host'
snapshot_ref = volume_api.create_snapshot_force(self.context,
volume_src,
'name',
'description')
snapshot_ref['status'] = 'available' # status must be available
volume_dst = volume_api.create(self.context,
1,
'name',
'description',
snapshot=snapshot_ref)
self.assertEqual(volume_dst['id'],
db.volume_get(
context.get_admin_context(),
volume_dst['id']).id)
self.assertEqual(snapshot_ref['id'],
db.volume_get(context.get_admin_context(),
volume_dst['id']).snapshot_id)
# ensure encryption keys match
self.assertIsNotNone(volume_src['encryption_key_id'])
self.assertIsNotNone(volume_dst['encryption_key_id'])
key_manager = volume_api.key_manager # must use *same* key manager
volume_src_key = key_manager.get_key(self.context,
volume_src['encryption_key_id'])
volume_dst_key = key_manager.get_key(self.context,
volume_dst['encryption_key_id'])
self.assertEqual(volume_src_key, volume_dst_key)
def test_create_volume_from_encrypted_volume(self):
"""Test volume can be created from an encrypted volume."""
self.stubs.Set(keymgr, 'API', fake_keymgr.fake_api)
volume_api = cinder.volume.api.API()
ctxt = context.get_admin_context()
db.volume_type_create(ctxt,
{'id': '61298380-0c12-11e3-bfd6-4b48424183be',
'name': 'LUKS'})
db.volume_type_encryption_create(
ctxt,
'61298380-0c12-11e3-bfd6-4b48424183be',
{'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER})
db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
'LUKS')
volume_src = volume_api.create(self.context,
1,
'name',
'description',
volume_type=db_vol_type)
volume_src['status'] = 'available' # status must be available
volume_dst = volume_api.create(self.context,
1,
'name',
'description',
source_volume=volume_src)
self.assertEqual(volume_dst['id'],
db.volume_get(context.get_admin_context(),
volume_dst['id']).id)
self.assertEqual(volume_src['id'],
db.volume_get(context.get_admin_context(),
volume_dst['id']).source_volid)
# ensure encryption keys match
self.assertIsNotNone(volume_src['encryption_key_id'])
self.assertIsNotNone(volume_dst['encryption_key_id'])
key_manager = volume_api.key_manager # must use *same* key manager
volume_src_key = key_manager.get_key(self.context,
volume_src['encryption_key_id'])
volume_dst_key = key_manager.get_key(self.context,
volume_dst['encryption_key_id'])
self.assertEqual(volume_src_key, volume_dst_key)
def test_create_volume_from_snapshot_fail_bad_size(self):
"""Test volume can't be created from snapshot with bad volume size."""
volume_api = cinder.volume.api.API()
snapshot = {'id': 1234,
'status': 'available',
'volume_size': 10}
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context,
**snapshot)
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
snapshot=snapshot_obj)
def test_create_volume_from_snapshot_fail_wrong_az(self):
"""Test volume can't be created from snapshot in a different az."""
volume_api = cinder.volume.api.API()
def fake_list_availability_zones(enable_cache=False):
return ({'name': 'nova', 'available': True},
{'name': 'az2', 'available': True})
self.stubs.Set(volume_api,
'list_availability_zones',
fake_list_availability_zones)
volume_src = tests_utils.create_volume(self.context,
availability_zone='az2',
**self.volume_params)
self.volume.create_volume(self.context, volume_src['id'])
snapshot = self._create_snapshot(volume_src['id'])
self.volume.create_snapshot(self.context, volume_src['id'],
snapshot)
volume_dst = volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
snapshot=snapshot)
self.assertEqual('az2', volume_dst['availability_zone'])
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
snapshot=snapshot,
availability_zone='nova')
def test_create_volume_with_invalid_exclusive_options(self):
"""Test volume create with multiple exclusive options fails."""
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
1,
'name',
'description',
snapshot='fake_id',
image_id='fake_id',
source_volume='fake_id')
@mock.patch.object(cinder.volume.targets.iscsi.ISCSITarget,
'_get_target_chap_auth')
@mock.patch.object(db, 'volume_admin_metadata_get')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
@mock.patch.object(db, 'volume_update')
def test_initialize_connection_fetchqos(self,
_mock_volume_update,
_mock_volume_get,
_mock_volume_admin_metadata_get,
mock_get_target):
"""Make sure initialize_connection returns correct information."""
_fake_admin_meta = {'fake-key': 'fake-value'}
_fake_volume = {'volume_type_id': 'fake_type_id',
'name': 'fake_name',
'host': 'fake_host',
'id': 'fake_volume_id',
'volume_admin_metadata': _fake_admin_meta}
_mock_volume_get.return_value = _fake_volume
_mock_volume_update.return_value = _fake_volume
_mock_volume_admin_metadata_get.return_value = _fake_admin_meta
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
qos_values = {'consumer': 'front-end',
'specs': {
'key1': 'value1',
'key2': 'value2'}
}
with mock.patch.object(cinder.volume.volume_types,
'get_volume_type_qos_specs') as type_qos, \
mock.patch.object(cinder.tests.unit.fake_driver.FakeISCSIDriver,
'initialize_connection') as driver_init:
type_qos.return_value = dict(qos_specs=qos_values)
driver_init.return_value = {'data': {}}
mock_get_target.return_value = None
qos_specs_expected = {'key1': 'value1',
'key2': 'value2'}
# initialize_connection() passes qos_specs that is designated to
# be consumed by front-end or both front-end and back-end
conn_info = self.volume.initialize_connection(self.context,
'fake_volume_id',
connector)
self.assertDictMatch(qos_specs_expected,
conn_info['data']['qos_specs'])
qos_values.update({'consumer': 'both'})
conn_info = self.volume.initialize_connection(self.context,
'fake_volume_id',
connector)
self.assertDictMatch(qos_specs_expected,
conn_info['data']['qos_specs'])
# initialize_connection() skips qos_specs that is designated to be
# consumed by back-end only
qos_values.update({'consumer': 'back-end'})
type_qos.return_value = dict(qos_specs=qos_values)
conn_info = self.volume.initialize_connection(self.context,
'fake_volume_id',
connector)
self.assertIsNone(conn_info['data']['qos_specs'])
@mock.patch.object(fake_driver.FakeISCSIDriver, 'create_export')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
@mock.patch.object(db, 'volume_update')
def test_initialize_connection_export_failure(self,
_mock_volume_update,
_mock_volume_get,
_mock_create_export):
"""Test exception path for create_export failure."""
_fake_admin_meta = {'fake-key': 'fake-value'}
_fake_volume = {'volume_type_id': 'fake_type_id',
'name': 'fake_name',
'host': 'fake_host',
'id': 'fake_volume_id',
'volume_admin_metadata': _fake_admin_meta}
_mock_volume_get.return_value = _fake_volume
_mock_volume_update.return_value = _fake_volume
_mock_create_export.side_effect = exception.CinderException
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.initialize_connection,
self.context,
'fake_volume_id',
connector)
@mock.patch.object(cinder.volume.targets.iscsi.ISCSITarget,
'_get_target_chap_auth')
@mock.patch.object(db, 'volume_admin_metadata_get')
@mock.patch.object(db, 'volume_update')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
@mock.patch.object(fake_driver.FakeISCSIDriver, 'initialize_connection')
@mock.patch.object(db, 'driver_initiator_data_get')
@mock.patch.object(db, 'driver_initiator_data_update')
def test_initialize_connection_initiator_data(self, mock_data_update,
mock_data_get,
mock_driver_init,
mock_volume_get,
mock_volume_update,
mock_metadata_get,
mock_get_target):
fake_admin_meta = {'fake-key': 'fake-value'}
fake_volume = {'volume_type_id': None,
'name': 'fake_name',
'host': 'fake_host',
'id': 'fake_volume_id',
'volume_admin_metadata': fake_admin_meta,
'encryption_key_id': ('d371e7bb-7392-4c27-'
'ac0b-ebd9f5d16078')}
mock_volume_get.return_value = fake_volume
mock_volume_update.return_value = fake_volume
mock_get_target.return_value = None
connector = {'ip': 'IP', 'initiator': 'INITIATOR'}
mock_driver_init.return_value = {
'driver_volume_type': 'iscsi',
'data': {'access_mode': 'rw',
'encrypted': False}
}
mock_data_get.return_value = []
conn_info = self.volume.initialize_connection(self.context, 'id',
connector)
# Asserts that if the driver sets the encrypted flag then the
# VolumeManager doesn't overwrite it regardless of what's in the
# volume for the encryption_key_id field.
self.assertFalse(conn_info['data']['encrypted'])
mock_driver_init.assert_called_with(fake_volume, connector)
data = [{'key': 'key1', 'value': 'value1'}]
mock_data_get.return_value = data
self.volume.initialize_connection(self.context, 'id', connector)
mock_driver_init.assert_called_with(fake_volume, connector, data)
update = {
'set_values': {
'foo': 'bar'
},
'remove_values': [
'foo',
'foo2'
]
}
mock_driver_init.return_value['initiator_update'] = update
self.volume.initialize_connection(self.context, 'id', connector)
mock_driver_init.assert_called_with(fake_volume, connector, data)
mock_data_update.assert_called_with(self.context, 'INITIATOR',
'FakeISCSIDriver', update)
connector['initiator'] = None
mock_data_update.reset_mock()
mock_data_get.reset_mock()
mock_driver_init.return_value['data'].pop('encrypted')
conn_info = self.volume.initialize_connection(self.context, 'id',
connector)
# Asserts that VolumeManager sets the encrypted flag if the driver
# doesn't set it.
self.assertTrue(conn_info['data']['encrypted'])
mock_driver_init.assert_called_with(fake_volume, connector)
self.assertFalse(mock_data_get.called)
self.assertFalse(mock_data_update.called)
def test_run_attach_detach_volume_for_instance(self):
"""Make sure volume can be attached and detached from instance."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual("in-use", vol['status'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_detach_invalid_attachment_id(self):
"""Make sure if the attachment id isn't found we raise."""
attachment_id = "notfoundid"
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=False,
**self.volume_params)
self.volume.detach_volume(self.context, volume['id'],
attachment_id)
volume = db.volume_get(self.context, volume['id'])
self.assertEqual('available', volume['status'])
instance_uuid = '12345678-1234-5678-1234-567812345678'
attached_host = 'fake_host'
mountpoint = '/dev/fake'
tests_utils.attach_volume(self.context, volume['id'],
instance_uuid, attached_host,
mountpoint)
self.volume.detach_volume(self.context, volume['id'],
attachment_id)
volume = db.volume_get(self.context, volume['id'])
self.assertEqual('in-use', volume['status'])
def test_detach_no_attachments(self):
self.volume_params['status'] = 'detaching'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=False,
**self.volume_params)
self.volume.detach_volume(self.context, volume['id'])
volume = db.volume_get(self.context, volume['id'])
self.assertEqual('available', volume['status'])
def test_run_attach_detach_volume_for_instance_no_attachment_id(self):
"""Make sure volume can be attached and detached from instance."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345678'
instance_uuid_2 = '12345678-4321-8765-4321-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
attachment2 = self.volume.attach_volume(self.context, volume_id,
instance_uuid_2, None,
mountpoint, 'ro')
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
self.assertRaises(exception.InvalidVolume,
self.volume.detach_volume,
self.context, volume_id)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('in-use', vol['status'])
self.volume.detach_volume(self.context, volume_id, attachment2['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(self.context, volume_id)
self.assertEqual('in-use', vol['status'])
self.volume.detach_volume(self.context, volume_id)
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_multiattach_volume_for_instances(self):
"""Make sure volume can be attached to multiple instances."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
instance2_uuid = '12345678-1234-5678-1234-567812345000'
mountpoint2 = "/dev/sdx"
attachment2 = self.volume.attach_volume(self.context, volume_id,
instance2_uuid, None,
mountpoint2, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual('attached', attachment2['attach_status'])
self.assertEqual(mountpoint2, attachment2['mountpoint'])
self.assertEqual(instance2_uuid, attachment2['instance_uuid'])
self.assertIsNone(attachment2['attached_host'])
self.assertNotEqual(attachment, attachment2)
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('in-use', vol['status'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
self.volume.detach_volume(self.context, volume_id, attachment2['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_twice_multiattach_volume_for_instances(self):
"""Make sure volume can be attached to multiple instances."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345699'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
mountpoint2 = "/dev/sdx"
attachment2 = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint2, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertIsNone(attachment2)
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
def test_attach_detach_not_multiattach_volume_for_instances(self):
"""Make sure volume can't be attached to more than one instance."""
mountpoint = "/dev/sdf"
# attach volume to the instance then to detach
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
multiattach=False,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id,
instance_uuid, None,
mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertFalse(vol['multiattach'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
instance2_uuid = '12345678-1234-5678-1234-567812345000'
mountpoint2 = "/dev/sdx"
self.assertRaises(exception.InvalidVolume,
self.volume.attach_volume,
self.context,
volume_id,
instance2_uuid,
None,
mountpoint2, 'ro')
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_volume_for_host(self):
"""Make sure volume can be attached and detached from host."""
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(
self.context,
admin_metadata={'readonly': 'False'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual("available", vol['status'])
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_multiattach_volume_for_hosts(self):
"""Make sure volume can be attached and detached from hosts."""
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(
self.context,
admin_metadata={'readonly': 'False'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
mountpoint2 = "/dev/sdx"
attachment2 = self.volume.attach_volume(self.context, volume_id, None,
'fake_host2', mountpoint2,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual('attached', attachment2['attach_status'])
self.assertEqual(mountpoint2, attachment2['mountpoint'])
self.assertIsNone(attachment2['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host2', attachment2['attached_host'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual("in-use", vol['status'])
self.volume.detach_volume(self.context, volume_id, attachment2['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual("available", vol['status'])
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_twice_multiattach_volume_for_hosts(self):
"""Make sure volume can be attached and detached from hosts."""
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(
self.context,
admin_metadata={'readonly': 'False'},
multiattach=True,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertTrue(vol['multiattach'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
mountpoint2 = "/dev/sdx"
attachment2 = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint2,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertIsNone(attachment2)
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
def test_run_attach_detach_not_multiattach_volume_for_hosts(self):
"""Make sure volume can't be attached to more than one host."""
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(
self.context,
admin_metadata={'readonly': 'False'},
multiattach=False,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
attachment = self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertFalse(vol['multiattach'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='False', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('rw', conn_info['data']['access_mode'])
mountpoint2 = "/dev/sdx"
self.assertRaises(exception.InvalidVolume,
self.volume.attach_volume,
self.context,
volume_id,
None,
'fake_host2',
mountpoint2,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual('attached', attachment['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
# sanitized, conforms to RFC-952 and RFC-1123 specs.
self.assertEqual('fake-host', attachment['attached_host'])
self.assertRaises(exception.VolumeAttached,
self.volume.delete_volume,
self.context,
volume_id)
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
self.assertEqual('available', vol['status'])
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_attach_detach_volume_with_attach_mode(self):
instance_uuid = '12345678-1234-5678-1234-567812345678'
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
db.volume_update(self.context, volume_id, {'status': 'available', })
self.volume.attach_volume(self.context, volume_id, instance_uuid,
None, mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
attachment = vol['volume_attachment'][0]
self.assertEqual('in-use', vol['status'])
self.assertEqual('attached', vol['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
self.assertIsNone(attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.volume.detach_volume(self.context, volume_id, attachment['id'])
vol = db.volume_get(self.context, volume_id)
attachment = vol['volume_attachment']
self.assertEqual('available', vol['status'])
self.assertEqual('detached', vol['attach_status'])
self.assertEqual([], attachment)
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('True', admin_metadata[0]['value'])
self.volume.attach_volume(self.context, volume_id, None,
'fake_host', mountpoint, 'ro')
vol = db.volume_get(context.get_admin_context(), volume_id)
attachment = vol['volume_attachment'][0]
self.assertEqual('in-use', vol['status'])
self.assertEqual('attached', vol['attach_status'])
self.assertEqual(mountpoint, attachment['mountpoint'])
self.assertIsNone(attachment['instance_uuid'])
self.assertEqual('fake-host', attachment['attached_host'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='ro')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
connector = {'initiator': 'iqn.2012-07.org.fake:01'}
conn_info = self.volume.initialize_connection(self.context,
volume_id, connector)
self.assertEqual('ro', conn_info['data']['access_mode'])
self.volume.detach_volume(self.context, volume_id,
attachment['id'])
vol = db.volume_get(self.context, volume_id)
attachment = vol['volume_attachment']
self.assertEqual('available', vol['status'])
self.assertEqual('detached', vol['attach_status'])
self.assertEqual([], attachment)
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('True', admin_metadata[0]['value'])
self.volume.delete_volume(self.context, volume_id)
self.assertRaises(exception.VolumeNotFound,
db.volume_get,
self.context,
volume_id)
def test_run_manager_attach_detach_volume_with_wrong_attach_mode(self):
# Not allow using 'read-write' mode attach readonly volume
instance_uuid = '12345678-1234-5678-1234-567812345678'
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
self.assertRaises(exception.InvalidVolumeAttachMode,
self.volume.attach_volume,
self.context,
volume_id,
instance_uuid,
None,
mountpoint,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('error_attaching', vol['status'])
self.assertEqual('detached', vol['attach_status'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
db.volume_update(self.context, volume_id, {'status': 'available'})
self.assertRaises(exception.InvalidVolumeAttachMode,
self.volume.attach_volume,
self.context,
volume_id,
None,
'fake_host',
mountpoint,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('error_attaching', vol['status'])
self.assertEqual('detached', vol['attach_status'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(2, len(admin_metadata))
expected = dict(readonly='True', attached_mode='rw')
ret = {}
for item in admin_metadata:
ret.update({item['key']: item['value']})
self.assertDictMatch(expected, ret)
def test_run_api_attach_detach_volume_with_wrong_attach_mode(self):
# Not allow using 'read-write' mode attach readonly volume
instance_uuid = '12345678-1234-5678-1234-567812345678'
mountpoint = "/dev/sdf"
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolumeAttachMode,
volume_api.attach,
self.context,
volume,
instance_uuid,
None,
mountpoint,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('detached', vol['attach_status'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('True', admin_metadata[0]['value'])
db.volume_update(self.context, volume_id, {'status': 'available'})
self.assertRaises(exception.InvalidVolumeAttachMode,
volume_api.attach,
self.context,
volume,
None,
'fake_host',
mountpoint,
'rw')
vol = db.volume_get(context.get_admin_context(), volume_id)
self.assertEqual('detached', vol['attach_status'])
admin_metadata = vol['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('True', admin_metadata[0]['value'])
def test_detach_volume_while_uploading_to_image_is_in_progress(self):
# If instance is booted from volume with 'Terminate on Delete' flag
# set, and when we delete instance then it tries to delete volume
# even it is in 'uploading' state.
# It is happening because detach call is setting volume status to
# 'available'.
mountpoint = "/dev/sdf"
# Attach volume to the instance
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
self.volume.attach_volume(self.context, volume_id, instance_uuid,
None, mountpoint, 'ro')
# Change volume status to 'uploading'
db.volume_update(self.context, volume_id, {'status': 'uploading'})
# Call detach api
self.volume.detach_volume(self.context, volume_id)
vol = db.volume_get(self.context, volume_id)
# Check that volume status is 'uploading'
self.assertEqual("uploading", vol['status'])
self.assertEqual("detached", vol['attach_status'])
@mock.patch.object(cinder.volume.api.API, 'update')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_reserve_volume_success(self, volume_get, volume_update):
fake_volume = {
'id': self.FAKE_UUID,
'status': 'available'
}
volume_get.return_value = fake_volume
volume_update.return_value = fake_volume
self.assertIsNone(cinder.volume.api.API().reserve_volume(
self.context,
fake_volume,
))
self.assertTrue(volume_get.called)
self.assertTrue(volume_update.called)
def test_reserve_volume_in_attaching(self):
self._test_reserve_volume_bad_status('attaching')
def test_reserve_volume_in_maintenance(self):
self._test_reserve_volume_bad_status('maintenance')
def _test_reserve_volume_bad_status(self, status):
fake_volume = {
'id': self.FAKE_UUID,
'status': status
}
with mock.patch.object(db.sqlalchemy.api, 'volume_get') as mock_get:
mock_get.return_value = fake_volume
self.assertRaises(exception.InvalidVolume,
cinder.volume.api.API().reserve_volume,
self.context,
fake_volume)
self.assertTrue(mock_get.called)
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
@mock.patch.object(db, 'volume_attachment_get_used_by_volume_id')
@mock.patch.object(cinder.volume.api.API, 'update')
def test_unreserve_volume_success(self, volume_get,
volume_attachment_get_used_by_volume_id,
volume_update):
fake_volume = {
'id': self.FAKE_UUID,
'status': 'attaching'
}
fake_attachments = [{'volume_id': self.FAKE_UUID,
'instance_uuid': 'fake_instance_uuid'}]
volume_get.return_value = fake_volume
volume_attachment_get_used_by_volume_id.return_value = fake_attachments
volume_update.return_value = fake_volume
self.assertIsNone(cinder.volume.api.API().unreserve_volume(
self.context,
fake_volume
))
self.assertTrue(volume_get.called)
self.assertTrue(volume_attachment_get_used_by_volume_id.called)
self.assertTrue(volume_update.called)
def test_concurrent_volumes_get_different_targets(self):
"""Ensure multiple concurrent volumes get different targets."""
volume_ids = []
targets = []
def _check(volume_id):
"""Make sure targets aren't duplicated."""
volume_ids.append(volume_id)
admin_context = context.get_admin_context()
iscsi_target = db.volume_get_iscsi_target_num(admin_context,
volume_id)
self.assertNotIn(iscsi_target, targets)
targets.append(iscsi_target)
# FIXME(jdg): What is this actually testing?
# We never call the internal _check method?
for _index in range(100):
tests_utils.create_volume(self.context, **self.volume_params)
for volume_id in volume_ids:
self.volume.delete_volume(self.context, volume_id)
def test_multi_node(self):
# TODO(termie): Figure out how to test with two nodes,
# each of them having a different FLAG for storage_node
# This will allow us to test cross-node interactions
pass
@staticmethod
def _create_snapshot(volume_id, size=1, metadata=None):
"""Create a snapshot object."""
metadata = metadata or {}
snap = objects.Snapshot(context.get_admin_context())
snap.volume_size = size
snap.user_id = 'fake'
snap.project_id = 'fake'
snap.volume_id = volume_id
snap.status = "creating"
if metadata is not None:
snap.metadata = metadata
snap.create()
return snap
def test_create_delete_snapshot(self):
"""Test snapshot can be created and deleted."""
volume = tests_utils.create_volume(
self.context,
availability_zone=CONF.storage_availability_zone,
**self.volume_params)
self.assertEqual(0, len(self.notifier.notifications),
self.notifier.notifications)
self.volume.create_volume(self.context, volume['id'])
msg = self.notifier.notifications[0]
self.assertEqual('volume.create.start', msg['event_type'])
self.assertEqual('creating', msg['payload']['status'])
self.assertEqual('INFO', msg['priority'])
msg = self.notifier.notifications[1]
self.assertEqual('volume.create.end', msg['event_type'])
self.assertEqual('available', msg['payload']['status'])
self.assertEqual('INFO', msg['priority'])
if len(self.notifier.notifications) > 2:
# Cause an assert to print the unexpected item
# and all of the notifications.
self.assertFalse(self.notifier.notifications[2],
self.notifier.notifications)
self.assertEqual(2, len(self.notifier.notifications),
self.notifier.notifications)
snapshot = self._create_snapshot(volume['id'], size=volume['size'])
snapshot_id = snapshot.id
self.volume.create_snapshot(self.context, volume['id'], snapshot)
self.assertEqual(
snapshot_id, objects.Snapshot.get_by_id(self.context,
snapshot_id).id)
msg = self.notifier.notifications[2]
self.assertEqual('snapshot.create.start', msg['event_type'])
expected = {
'created_at': 'DONTCARE',
'deleted': '',
'display_name': None,
'snapshot_id': snapshot_id,
'status': 'creating',
'tenant_id': 'fake',
'user_id': 'fake',
'volume_id': volume['id'],
'volume_size': 1,
'availability_zone': 'nova',
'metadata': '',
}
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[3]
self.assertEqual('snapshot.create.end', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
if len(self.notifier.notifications) > 4:
# Cause an assert to print the unexpected item
# and all of the notifications.
self.assertFalse(self.notifier.notifications[4],
self.notifier.notifications)
self.assertEqual(4, len(self.notifier.notifications),
self.notifier.notifications)
self.volume.delete_snapshot(self.context, snapshot)
msg = self.notifier.notifications[4]
self.assertEqual('snapshot.delete.start', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[5]
self.assertEqual('snapshot.delete.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
if len(self.notifier.notifications) > 6:
# Cause an assert to print the unexpected item
# and all of the notifications.
self.assertFalse(self.notifier.notifications[6],
self.notifier.notifications)
self.assertEqual(6, len(self.notifier.notifications),
self.notifier.notifications)
snap = objects.Snapshot.get_by_id(context.get_admin_context(
read_deleted='yes'), snapshot_id)
self.assertEqual('deleted', snap.status)
self.assertRaises(exception.NotFound,
db.snapshot_get,
self.context,
snapshot_id)
self.volume.delete_volume(self.context, volume['id'])
def test_create_delete_snapshot_with_metadata(self):
"""Test snapshot can be created with metadata and deleted."""
test_meta = {'fake_key': 'fake_value'}
volume = tests_utils.create_volume(self.context, **self.volume_params)
snapshot = self._create_snapshot(volume['id'], size=volume['size'],
metadata=test_meta)
snapshot_id = snapshot.id
result_dict = snapshot.metadata
self.assertEqual(test_meta, result_dict)
self.volume.delete_snapshot(self.context, snapshot)
self.assertRaises(exception.NotFound,
db.snapshot_get,
self.context,
snapshot_id)
@mock.patch.object(db, 'snapshot_create',
side_effect=exception.InvalidSnapshot(
'Create snapshot in db failed!'))
def test_create_snapshot_failed_db_snapshot(self, mock_snapshot):
"""Test exception handling when create snapshot in db failed."""
test_volume = tests_utils.create_volume(
self.context,
**self.volume_params)
self.volume.create_volume(self.context, test_volume['id'])
test_volume['status'] = 'available'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidSnapshot,
volume_api.create_snapshot,
self.context,
test_volume,
'fake_name',
'fake_description')
def test_create_snapshot_failed_maintenance(self):
"""Test exception handling when create snapshot in maintenance."""
test_volume = tests_utils.create_volume(
self.context,
**self.volume_params)
self.volume.create_volume(self.context, test_volume['id'])
test_volume['status'] = 'maintenance'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.create_snapshot,
self.context,
test_volume,
'fake_name',
'fake_description')
@mock.patch.object(QUOTAS, 'commit',
side_effect=exception.QuotaError(
'Snapshot quota commit failed!'))
def test_create_snapshot_failed_quota_commit(self, mock_snapshot):
"""Test exception handling when snapshot quota commit failed."""
test_volume = tests_utils.create_volume(
self.context,
**self.volume_params)
self.volume.create_volume(self.context, test_volume['id'],
request_spec={})
test_volume['status'] = 'available'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.QuotaError,
volume_api.create_snapshot,
self.context,
test_volume,
'fake_name',
'fake_description')
def test_cannot_delete_volume_in_use(self):
"""Test volume can't be deleted in in-use status."""
self._test_cannot_delete_volume('in-use')
def test_cannot_delete_volume_maintenance(self):
"""Test volume can't be deleted in maintenance status."""
self._test_cannot_delete_volume('maintenance')
def _test_cannot_delete_volume(self, status):
"""Test volume can't be deleted in invalid stats."""
# create a volume and assign to host
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume['id'])
volume['status'] = status
volume['host'] = 'fakehost'
volume_api = cinder.volume.api.API()
# 'in-use' status raises InvalidVolume
self.assertRaises(exception.InvalidVolume,
volume_api.delete,
self.context,
volume)
# clean up
self.volume.delete_volume(self.context, volume['id'])
def test_force_delete_volume(self):
"""Test volume can be forced to delete."""
# create a volume and assign to host
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume['id'])
volume['status'] = 'error_deleting'
volume_api = cinder.volume.api.API()
# 'error_deleting' volumes can't be deleted
self.assertRaises(exception.InvalidVolume,
volume_api.delete,
self.context,
volume)
# delete with force
volume_api.delete(self.context, volume, force=True)
# status is deleting
volume = objects.Volume.get_by_id(context.get_admin_context(),
volume.id)
self.assertEqual('deleting', volume.status)
# clean up
self.volume.delete_volume(self.context, volume.id)
def test_cannot_force_delete_attached_volume(self):
"""Test volume can't be force delete in attached state."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume['id'])
volume['status'] = 'in-use'
volume['attach_status'] = 'attached'
volume['host'] = 'fakehost'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.VolumeAttached,
volume_api.delete,
self.context,
volume,
force=True)
self.volume.delete_volume(self.context, volume['id'])
def test_cannot_delete_volume_with_snapshots(self):
"""Test volume can't be deleted with dependent snapshots."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume['id'])
snapshot = self._create_snapshot(volume['id'], size=volume['size'])
self.volume.create_snapshot(self.context, volume['id'], snapshot)
self.assertEqual(
snapshot.id, objects.Snapshot.get_by_id(self.context,
snapshot.id).id)
volume['status'] = 'available'
volume['host'] = 'fakehost'
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidVolume,
volume_api.delete,
self.context,
volume)
self.volume.delete_snapshot(self.context, snapshot)
self.volume.delete_volume(self.context, volume['id'])
def test_can_delete_errored_snapshot(self):
"""Test snapshot can be created and deleted."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume['id'])
snapshot = self._create_snapshot(volume['id'], size=volume['size'])
self.volume.create_snapshot(self.context, volume['id'], snapshot)
volume_api = cinder.volume.api.API()
snapshot.status = 'badstatus'
self.assertRaises(exception.InvalidSnapshot,
volume_api.delete_snapshot,
self.context,
snapshot)
snapshot.status = 'error'
self.volume.delete_snapshot(self.context, snapshot)
self.volume.delete_volume(self.context, volume['id'])
def test_create_snapshot_force(self):
"""Test snapshot in use can be created forcibly."""
instance_uuid = '12345678-1234-5678-1234-567812345678'
# create volume and attach to the instance
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume['id'])
values = {'volume_id': volume['id'],
'instance_uuid': instance_uuid,
'attach_status': 'attaching', }
attachment = db.volume_attach(self.context, values)
db.volume_attached(self.context, attachment['id'], instance_uuid,
None, '/dev/sda1')
volume_api = cinder.volume.api.API()
volume = volume_api.get(self.context, volume['id'])
self.assertRaises(exception.InvalidVolume,
volume_api.create_snapshot,
self.context, volume,
'fake_name', 'fake_description')
snapshot_ref = volume_api.create_snapshot_force(self.context,
volume,
'fake_name',
'fake_description')
snapshot_ref.destroy()
db.volume_destroy(self.context, volume['id'])
# create volume and attach to the host
volume = tests_utils.create_volume(self.context, **self.volume_params)
self.volume.create_volume(self.context, volume['id'])
values = {'volume_id': volume['id'],
'attached_host': 'fake_host',
'attach_status': 'attaching', }
attachment = db.volume_attach(self.context, values)
db.volume_attached(self.context, attachment['id'], None,
'fake_host', '/dev/sda1')
volume_api = cinder.volume.api.API()
volume = volume_api.get(self.context, volume['id'])
self.assertRaises(exception.InvalidVolume,
volume_api.create_snapshot,
self.context, volume,
'fake_name', 'fake_description')
snapshot_ref = volume_api.create_snapshot_force(self.context,
volume,
'fake_name',
'fake_description')
snapshot_ref.destroy()
db.volume_destroy(self.context, volume['id'])
def test_create_snapshot_from_bootable_volume(self):
"""Test create snapshot from bootable volume."""
# create bootable volume from image
volume = self._create_volume_from_image()
volume_id = volume['id']
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
# get volume's volume_glance_metadata
ctxt = context.get_admin_context()
vol_glance_meta = db.volume_glance_metadata_get(ctxt, volume_id)
self.assertTrue(vol_glance_meta)
# create snapshot from bootable volume
snap = self._create_snapshot(volume_id)
self.volume.create_snapshot(ctxt, volume_id, snap)
# get snapshot's volume_glance_metadata
snap_glance_meta = db.volume_snapshot_glance_metadata_get(
ctxt, snap.id)
self.assertTrue(snap_glance_meta)
# ensure that volume's glance metadata is copied
# to snapshot's glance metadata
self.assertEqual(len(vol_glance_meta), len(snap_glance_meta))
vol_glance_dict = {x.key: x.value for x in vol_glance_meta}
snap_glance_dict = {x.key: x.value for x in snap_glance_meta}
self.assertDictMatch(vol_glance_dict, snap_glance_dict)
# ensure that snapshot's status is changed to 'available'
self.assertEqual('available', snap.status)
# cleanup resource
snap.destroy()
db.volume_destroy(ctxt, volume_id)
def test_create_snapshot_from_bootable_volume_fail(self):
"""Test create snapshot from bootable volume.
But it fails to volume_glance_metadata_copy_to_snapshot.
As a result, status of snapshot is changed to ERROR.
"""
# create bootable volume from image
volume = self._create_volume_from_image()
volume_id = volume['id']
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
# get volume's volume_glance_metadata
ctxt = context.get_admin_context()
vol_glance_meta = db.volume_glance_metadata_get(ctxt, volume_id)
self.assertTrue(vol_glance_meta)
snap = self._create_snapshot(volume_id)
snap_stat = snap.status
self.assertTrue(snap.id)
self.assertTrue(snap_stat)
# set to return DB exception
with mock.patch.object(db, 'volume_glance_metadata_copy_to_snapshot')\
as mock_db:
mock_db.side_effect = exception.MetadataCopyFailure(
reason="Because of DB service down.")
# create snapshot from bootable volume
self.assertRaises(exception.MetadataCopyFailure,
self.volume.create_snapshot,
ctxt,
volume_id,
snap)
# get snapshot's volume_glance_metadata
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_snapshot_glance_metadata_get,
ctxt, snap.id)
# ensure that status of snapshot is 'error'
self.assertEqual('error', snap.status)
# cleanup resource
snap.destroy()
db.volume_destroy(ctxt, volume_id)
def test_create_snapshot_from_bootable_volume_with_volume_metadata_none(
self):
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
# set bootable flag of volume to True
db.volume_update(self.context, volume_id, {'bootable': True})
snapshot = self._create_snapshot(volume['id'])
self.volume.create_snapshot(self.context, volume['id'], snapshot)
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_snapshot_glance_metadata_get,
self.context, snapshot.id)
# ensure that status of snapshot is 'available'
self.assertEqual('available', snapshot.status)
# cleanup resource
snapshot.destroy()
db.volume_destroy(self.context, volume_id)
def test_delete_busy_snapshot(self):
"""Test snapshot can be created and deleted."""
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
snapshot = self._create_snapshot(volume_id, size=volume['size'])
self.volume.create_snapshot(self.context, volume_id, snapshot)
self.mox.StubOutWithMock(self.volume.driver, 'delete_snapshot')
self.volume.driver.delete_snapshot(
mox.IgnoreArg()).AndRaise(
exception.SnapshotIsBusy(snapshot_name='fake'))
self.mox.ReplayAll()
snapshot_id = snapshot.id
self.volume.delete_snapshot(self.context, snapshot)
snapshot_ref = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.assertEqual(snapshot_id, snapshot_ref.id)
self.assertEqual("available", snapshot_ref.status)
@test.testtools.skipIf(sys.platform == "darwin", "SKIP on OSX")
def test_delete_no_dev_fails(self):
"""Test delete snapshot with no dev file fails."""
self.stubs.Set(os.path, 'exists', lambda x: False)
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
snapshot = self._create_snapshot(volume_id)
snapshot_id = snapshot.id
self.volume.create_snapshot(self.context, volume_id, snapshot)
self.mox.StubOutWithMock(self.volume.driver, 'delete_snapshot')
self.volume.driver.delete_snapshot(
mox.IgnoreArg()).AndRaise(
exception.SnapshotIsBusy(snapshot_name='fake'))
self.mox.ReplayAll()
self.volume.delete_snapshot(self.context, snapshot)
snapshot_ref = objects.Snapshot.get_by_id(self.context, snapshot_id)
self.assertEqual(snapshot_id, snapshot_ref.id)
self.assertEqual("available", snapshot_ref.status)
self.mox.UnsetStubs()
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.delete_snapshot,
self.context,
snapshot)
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.delete_volume,
self.context,
volume_id)
@mock.patch('cinder.image.image_utils.TemporaryImages.fetch')
@mock.patch('cinder.volume.flows.manager.create_volume.'
'CreateVolumeFromSpecTask._clone_image_volume')
def _create_volume_from_image(self, mock_clone_image_volume,
mock_fetch_img,
fakeout_copy_image_to_volume=False,
fakeout_clone_image=False,
clone_image_volume=False):
"""Test function of create_volume_from_image.
Test cases call this function to create a volume from image, caller
can choose whether to fake out copy_image_to_volume and clone_image,
after calling this, test cases should check status of the volume.
"""
def fake_local_path(volume):
return dst_path
def fake_copy_image_to_volume(context, volume,
image_service, image_id):
pass
def fake_fetch_to_raw(ctx, image_service, image_id, path, blocksize,
size=None, throttle=None):
pass
def fake_clone_image(ctx, volume_ref,
image_location, image_meta,
image_service):
return {'provider_location': None}, True
dst_fd, dst_path = tempfile.mkstemp()
os.close(dst_fd)
self.stubs.Set(self.volume.driver, 'local_path', fake_local_path)
if fakeout_clone_image:
self.stubs.Set(self.volume.driver, 'clone_image', fake_clone_image)
self.stubs.Set(image_utils, 'fetch_to_raw', fake_fetch_to_raw)
if fakeout_copy_image_to_volume:
self.stubs.Set(self.volume.driver, 'copy_image_to_volume',
fake_copy_image_to_volume)
mock_clone_image_volume.return_value = ({}, clone_image_volume)
mock_fetch_img.return_value = mock.MagicMock(
spec=tests_utils.get_file_spec())
image_id = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'
volume = tests_utils.create_volume(self.context, **self.volume_params)
# creating volume testdata
try:
request_spec = {
'volume_properties': self.volume_params,
'image_id': image_id,
}
self.volume.create_volume(self.context,
volume.id,
request_spec,
volume=volume)
finally:
# cleanup
os.unlink(dst_path)
volume = objects.Volume.get_by_id(self.context, volume.id)
return volume
def test_create_volume_from_image_cloned_status_available(self):
"""Test create volume from image via cloning.
Verify that after cloning image to volume, it is in available
state and is bootable.
"""
volume = self._create_volume_from_image()
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
self.volume.delete_volume(self.context, volume['id'])
def test_create_volume_from_image_not_cloned_status_available(self):
"""Test create volume from image via full copy.
Verify that after copying image to volume, it is in available
state and is bootable.
"""
volume = self._create_volume_from_image(fakeout_clone_image=True)
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
self.volume.delete_volume(self.context, volume['id'])
def test_create_volume_from_image_exception(self):
"""Test create volume from a non-existing image.
Verify that create volume from a non-existing image, the volume
status is 'error' and is not bootable.
"""
dst_fd, dst_path = tempfile.mkstemp()
os.close(dst_fd)
self.stubs.Set(self.volume.driver, 'local_path', lambda x: dst_path)
# creating volume testdata
kwargs = {'display_description': 'Test Desc',
'size': 20,
'availability_zone': 'fake_availability_zone',
'status': 'creating',
'attach_status': 'detached',
'host': 'dummy'}
volume = objects.Volume(context=self.context, **kwargs)
volume.create()
self.assertRaises(exception.ImageNotFound,
self.volume.create_volume,
self.context,
volume.id,
{'image_id': self.FAKE_UUID})
volume = objects.Volume.get_by_id(self.context, volume.id)
self.assertEqual("error", volume['status'])
self.assertFalse(volume['bootable'])
# cleanup
volume.destroy()
os.unlink(dst_path)
def test_create_volume_from_image_copy_exception_rescheduling(self):
"""Test create volume with ImageCopyFailure
This exception should not trigger rescheduling and allocated_capacity
should be incremented so we're having assert for that here.
"""
def fake_copy_image_to_volume(context, volume, image_service,
image_id):
raise exception.ImageCopyFailure()
self.stubs.Set(self.volume.driver, 'copy_image_to_volume',
fake_copy_image_to_volume)
self.assertRaises(exception.ImageCopyFailure,
self._create_volume_from_image)
# NOTE(dulek): Rescheduling should not occur, so lets assert that
# allocated_capacity is incremented.
self.assertDictEqual(self.volume.stats['pools'],
{'_pool0': {'allocated_capacity_gb': 1}})
@mock.patch('cinder.utils.brick_get_connector_properties')
@mock.patch('cinder.utils.brick_get_connector')
@mock.patch('cinder.volume.driver.BaseVD.secure_file_operations_enabled')
@mock.patch('cinder.volume.driver.BaseVD._detach_volume')
def test_create_volume_from_image_unavailable(self, mock_detach,
mock_secure, *args):
"""Test create volume with ImageCopyFailure
We'll raise an exception inside _connect_device after volume has
already been attached to confirm that it detaches the volume.
"""
mock_secure.side_effect = NameError
# We want to test BaseVD copy_image_to_volume and since FakeISCSIDriver
# inherits from LVM it overwrites it, so we'll mock it to use the
# BaseVD implementation.
unbound_copy_method = cinder.volume.driver.BaseVD.copy_image_to_volume
bound_copy_method = unbound_copy_method.__get__(self.volume.driver)
with mock.patch.object(self.volume.driver, 'copy_image_to_volume',
side_effect=bound_copy_method):
self.assertRaises(exception.ImageCopyFailure,
self._create_volume_from_image,
fakeout_copy_image_to_volume=False)
# We must have called detach method.
self.assertEqual(1, mock_detach.call_count)
def test_create_volume_from_image_clone_image_volume(self):
"""Test create volume from image via image volume.
Verify that after cloning image to volume, it is in available
state and is bootable.
"""
volume = self._create_volume_from_image(clone_image_volume=True)
self.assertEqual('available', volume['status'])
self.assertTrue(volume['bootable'])
self.volume.delete_volume(self.context, volume['id'])
def test_create_volume_from_exact_sized_image(self):
"""Test create volume from an image of the same size.
Verify that an image which is exactly the same size as the
volume, will work correctly.
"""
try:
volume_id = None
volume_api = cinder.volume.api.API(
image_service=FakeImageService())
volume = volume_api.create(self.context, 2, 'name', 'description',
image_id=1)
volume_id = volume['id']
self.assertEqual('creating', volume['status'])
finally:
# cleanup
db.volume_destroy(self.context, volume_id)
def test_create_volume_from_oversized_image(self):
"""Verify that an image which is too big will fail correctly."""
class _ModifiedFakeImageService(FakeImageService):
def show(self, context, image_id):
return {'size': 2 * units.Gi + 1,
'disk_format': 'raw',
'container_format': 'bare',
'status': 'active'}
volume_api = cinder.volume.api.API(
image_service=_ModifiedFakeImageService())
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context, 2,
'name', 'description', image_id=1)
def test_create_volume_with_mindisk_error(self):
"""Verify volumes smaller than image minDisk will cause an error."""
class _ModifiedFakeImageService(FakeImageService):
def show(self, context, image_id):
return {'size': 2 * units.Gi,
'disk_format': 'raw',
'container_format': 'bare',
'min_disk': 5,
'status': 'active'}
volume_api = cinder.volume.api.API(
image_service=_ModifiedFakeImageService())
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context, 2,
'name', 'description', image_id=1)
def test_create_volume_with_deleted_imaged(self):
"""Verify create volume from image will cause an error."""
class _ModifiedFakeImageService(FakeImageService):
def show(self, context, image_id):
return {'size': 2 * units.Gi,
'disk_format': 'raw',
'container_format': 'bare',
'min_disk': 5,
'status': 'deleted'}
volume_api = cinder.volume.api.API(
image_service=_ModifiedFakeImageService())
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context, 2,
'name', 'description', image_id=1)
@mock.patch.object(QUOTAS, "rollback")
@mock.patch.object(QUOTAS, "commit")
@mock.patch.object(QUOTAS, "reserve", return_value=["RESERVATION"])
def _do_test_create_volume_with_size(self, size, *_unused_quota_mocks):
volume_api = cinder.volume.api.API()
volume = volume_api.create(self.context,
size,
'name',
'description')
self.assertEqual(int(size), volume['size'])
def test_create_volume_int_size(self):
"""Test volume creation with int size."""
self._do_test_create_volume_with_size(2)
def test_create_volume_string_size(self):
"""Test volume creation with string size."""
self._do_test_create_volume_with_size('2')
@mock.patch.object(QUOTAS, "rollback")
@mock.patch.object(QUOTAS, "commit")
@mock.patch.object(QUOTAS, "reserve", return_value=["RESERVATION"])
def test_create_volume_with_bad_size(self, *_unused_quota_mocks):
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
'2Gb',
'name',
'description')
def test_create_volume_with_float_fails(self):
"""Test volume creation with invalid float size."""
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
'1.5',
'name',
'description')
def test_create_volume_with_zero_size_fails(self):
"""Test volume creation with string size."""
volume_api = cinder.volume.api.API()
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
'0',
'name',
'description')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_begin_detaching_fails_available(self, volume_get):
volume_api = cinder.volume.api.API()
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume_get.return_value = volume
# Volume status is 'available'.
self.assertRaises(exception.InvalidVolume, volume_api.begin_detaching,
self.context, volume)
volume_get.assert_called_once_with(self.context, volume['id'])
volume_get.reset_mock()
volume['status'] = "in-use"
volume['attach_status'] = "detached"
# Should raise an error since not attached
self.assertRaises(exception.InvalidVolume, volume_api.begin_detaching,
self.context, volume)
volume_get.assert_called_once_with(self.context, volume['id'])
volume_get.reset_mock()
volume['attach_status'] = "attached"
# Ensure when attached no exception raised
volume_api.begin_detaching(self.context, volume)
volume_get.assert_called_once_with(self.context, volume['id'])
volume_get.reset_mock()
volume['status'] = "maintenance"
self.assertRaises(exception.InvalidVolume, volume_api.begin_detaching,
self.context, volume)
volume_get.assert_called_once_with(self.context, volume['id'])
def test_begin_roll_detaching_volume(self):
"""Test begin_detaching and roll_detaching functions."""
instance_uuid = '12345678-1234-5678-1234-567812345678'
volume = tests_utils.create_volume(self.context, **self.volume_params)
attachment = db.volume_attach(self.context,
{'volume_id': volume['id'],
'attached_host': 'fake-host'})
volume = db.volume_attached(
self.context, attachment['id'], instance_uuid, 'fake-host', 'vdb')
volume_api = cinder.volume.api.API()
volume_api.begin_detaching(self.context, volume)
volume = db.volume_get(self.context, volume['id'])
self.assertEqual("detaching", volume['status'])
volume_api.roll_detaching(self.context, volume)
volume = db.volume_get(self.context, volume['id'])
self.assertEqual("in-use", volume['status'])
def test_volume_api_update(self):
# create a raw vol
volume = tests_utils.create_volume(self.context, **self.volume_params)
# use volume.api to update name
volume_api = cinder.volume.api.API()
update_dict = {'display_name': 'test update name'}
volume_api.update(self.context, volume, update_dict)
# read changes from db
vol = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('test update name', vol['display_name'])
def test_volume_api_update_maintenance(self):
# create a raw vol
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume['status'] = 'maintenance'
# use volume.api to update name
volume_api = cinder.volume.api.API()
update_dict = {'display_name': 'test update name'}
self.assertRaises(exception.InvalidVolume, volume_api.update,
self.context, volume, update_dict)
def test_volume_api_update_snapshot(self):
# create raw snapshot
volume = tests_utils.create_volume(self.context, **self.volume_params)
snapshot = self._create_snapshot(volume['id'])
snapshot_id = snapshot.id
self.assertIsNone(snapshot.display_name)
# use volume.api to update name
volume_api = cinder.volume.api.API()
update_dict = {'display_name': 'test update name'}
volume_api.update_snapshot(self.context, snapshot, update_dict)
# read changes from db
snap = objects.Snapshot.get_by_id(context.get_admin_context(),
snapshot_id)
self.assertEqual('test update name', snap.display_name)
def test_volume_api_get_list_volumes_image_metadata(self):
"""Test get_list_volumes_image_metadata in volume API."""
ctxt = context.get_admin_context()
db.volume_create(ctxt, {'id': 'fake1', 'status': 'available',
'host': 'test', 'provider_location': '',
'size': 1})
db.volume_glance_metadata_create(ctxt, 'fake1', 'key1', 'value1')
db.volume_glance_metadata_create(ctxt, 'fake1', 'key2', 'value2')
db.volume_create(ctxt, {'id': 'fake2', 'status': 'available',
'host': 'test', 'provider_location': '',
'size': 1})
db.volume_glance_metadata_create(ctxt, 'fake2', 'key3', 'value3')
db.volume_glance_metadata_create(ctxt, 'fake2', 'key4', 'value4')
volume_api = cinder.volume.api.API()
results = volume_api.get_list_volumes_image_metadata(ctxt, ['fake1',
'fake2'])
expect_results = {'fake1': {'key1': 'value1', 'key2': 'value2'},
'fake2': {'key3': 'value3', 'key4': 'value4'}}
self.assertEqual(expect_results, results)
@mock.patch.object(QUOTAS, 'reserve')
def test_extend_volume(self, reserve):
"""Test volume can be extended at API level."""
# create a volume and assign to host
volume = tests_utils.create_volume(self.context, size=2,
status='creating', host=CONF.host)
self.volume.create_volume(self.context, volume['id'])
volume['status'] = 'in-use'
volume_api = cinder.volume.api.API()
# Extend fails when status != available
self.assertRaises(exception.InvalidVolume,
volume_api.extend,
self.context,
volume,
3)
volume['status'] = 'available'
# Extend fails when new_size < orig_size
self.assertRaises(exception.InvalidInput,
volume_api.extend,
self.context,
volume,
1)
# Extend fails when new_size == orig_size
self.assertRaises(exception.InvalidInput,
volume_api.extend,
self.context,
volume,
2)
# works when new_size > orig_size
reserve.return_value = ["RESERVATION"]
volume_api.extend(self.context, volume, 3)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('extending', volume['status'])
reserve.assert_called_once_with(self.context, gigabytes=1,
project_id=volume['project_id'])
# Test the quota exceeded
volume['status'] = 'available'
reserve.side_effect = exception.OverQuota(overs=['gigabytes'],
quotas={'gigabytes': 20},
usages={'gigabytes':
{'reserved': 5,
'in_use': 15}})
self.assertRaises(exception.VolumeSizeExceedsAvailableQuota,
volume_api.extend, self.context,
volume, 3)
# clean up
self.volume.delete_volume(self.context, volume['id'])
def test_extend_volume_driver_not_initialized(self):
"""Test volume can be extended at API level."""
# create a volume and assign to host
fake_reservations = ['RESERVATION']
volume = tests_utils.create_volume(self.context, size=2,
status='available',
host=CONF.host)
self.volume.create_volume(self.context, volume['id'])
self.volume.driver._initialized = False
self.assertRaises(exception.DriverNotInitialized,
self.volume.extend_volume,
self.context, volume['id'], 3,
fake_reservations)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error_extending', volume.status)
# lets cleanup the mess.
self.volume.driver._initialized = True
self.volume.delete_volume(self.context, volume['id'])
def test_extend_volume_manager(self):
"""Test volume can be extended at the manager level."""
def fake_extend(volume, new_size):
volume['size'] = new_size
fake_reservations = ['RESERVATION']
volume = tests_utils.create_volume(self.context, size=2,
status='creating', host=CONF.host)
self.volume.create_volume(self.context, volume['id'])
# Test driver exception
with mock.patch.object(self.volume.driver,
'extend_volume') as extend_volume:
extend_volume.side_effect =\
exception.CinderException('fake exception')
volume['status'] = 'extending'
self.volume.extend_volume(self.context, volume['id'], '4',
fake_reservations)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual(2, volume['size'])
self.assertEqual('error_extending', volume['status'])
# Test driver success
with mock.patch.object(self.volume.driver,
'extend_volume') as extend_volume:
with mock.patch.object(QUOTAS, 'commit') as quotas_commit:
extend_volume.return_value = fake_extend
volume['status'] = 'extending'
self.volume.extend_volume(self.context, volume['id'], '4',
fake_reservations)
volume = db.volume_get(context.get_admin_context(),
volume['id'])
self.assertEqual(4, volume['size'])
self.assertEqual('available', volume['status'])
quotas_commit.assert_called_with(
self.context,
['RESERVATION'],
project_id=volume['project_id'])
# clean up
self.volume.delete_volume(self.context, volume['id'])
def test_extend_volume_with_volume_type(self):
elevated = context.get_admin_context()
project_id = self.context.project_id
db.volume_type_create(elevated, {'name': 'type', 'extra_specs': {}})
vol_type = db.volume_type_get_by_name(elevated, 'type')
volume_api = cinder.volume.api.API()
volume = volume_api.create(self.context, 100, 'name', 'description',
volume_type=vol_type)
try:
usage = db.quota_usage_get(elevated, project_id, 'gigabytes_type')
volumes_in_use = usage.in_use
except exception.QuotaUsageNotFound:
volumes_in_use = 0
self.assertEqual(100, volumes_in_use)
volume['status'] = 'available'
volume['host'] = 'fakehost'
volume['volume_type_id'] = vol_type.get('id')
volume_api.extend(self.context, volume, 200)
try:
usage = db.quota_usage_get(elevated, project_id, 'gigabytes_type')
volumes_reserved = usage.reserved
except exception.QuotaUsageNotFound:
volumes_reserved = 0
self.assertEqual(100, volumes_reserved)
@mock.patch(
'cinder.volume.driver.VolumeDriver.create_replica_test_volume')
def test_create_volume_from_sourcereplica(self, _create_replica_test):
"""Test volume can be created from a volume replica."""
_create_replica_test.return_value = None
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src['id'])
volume_dst = tests_utils.create_volume(
self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_dst['id'],
{'source_replicaid': volume_src['id']})
self.assertEqual('available',
db.volume_get(context.get_admin_context(),
volume_dst['id']).status)
self.assertTrue(_create_replica_test.called)
self.volume.delete_volume(self.context, volume_dst['id'])
self.volume.delete_volume(self.context, volume_src['id'])
def test_create_volume_from_sourcevol(self):
"""Test volume can be created from a source volume."""
def fake_create_cloned_volume(volume, src_vref):
pass
self.stubs.Set(self.volume.driver, 'create_cloned_volume',
fake_create_cloned_volume)
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src['id'])
volume_dst = tests_utils.create_volume(self.context,
source_volid=volume_src['id'],
**self.volume_params)
self.volume.create_volume(self.context, volume_dst['id'])
self.assertEqual('available',
db.volume_get(context.get_admin_context(),
volume_dst['id']).status)
self.volume.delete_volume(self.context, volume_dst['id'])
self.volume.delete_volume(self.context, volume_src['id'])
@mock.patch('cinder.volume.api.API.list_availability_zones',
return_value=({'name': 'nova', 'available': True},
{'name': 'az2', 'available': True}))
def test_create_volume_from_sourcevol_fail_wrong_az(self, _mock_laz):
"""Test volume can't be cloned from an other volume in different az."""
volume_api = cinder.volume.api.API()
volume_src = tests_utils.create_volume(self.context,
availability_zone='az2',
**self.volume_params)
self.volume.create_volume(self.context, volume_src['id'])
volume_src = db.volume_get(self.context, volume_src['id'])
volume_dst = volume_api.create(self.context,
size=1,
name='fake_name',
description='fake_desc',
source_volume=volume_src)
self.assertEqual('az2', volume_dst['availability_zone'])
self.assertRaises(exception.InvalidInput,
volume_api.create,
self.context,
size=1,
name='fake_name',
description='fake_desc',
source_volume=volume_src,
availability_zone='nova')
def test_create_volume_from_sourcevol_with_glance_metadata(self):
"""Test glance metadata can be correctly copied to new volume."""
def fake_create_cloned_volume(volume, src_vref):
pass
self.stubs.Set(self.volume.driver, 'create_cloned_volume',
fake_create_cloned_volume)
volume_src = self._create_volume_from_image()
self.volume.create_volume(self.context, volume_src['id'])
volume_dst = tests_utils.create_volume(self.context,
source_volid=volume_src['id'],
**self.volume_params)
self.volume.create_volume(self.context, volume_dst['id'])
self.assertEqual('available',
db.volume_get(context.get_admin_context(),
volume_dst['id']).status)
src_glancemeta = db.volume_get(context.get_admin_context(),
volume_src['id']).volume_glance_metadata
dst_glancemeta = db.volume_get(context.get_admin_context(),
volume_dst['id']).volume_glance_metadata
for meta_src in src_glancemeta:
for meta_dst in dst_glancemeta:
if meta_dst.key == meta_src.key:
self.assertEqual(meta_src.value, meta_dst.value)
self.volume.delete_volume(self.context, volume_src['id'])
self.volume.delete_volume(self.context, volume_dst['id'])
def test_create_volume_from_sourcevol_failed_clone(self):
"""Test src vol status will be restore by error handling code."""
def fake_error_create_cloned_volume(volume, src_vref):
db.volume_update(self.context, src_vref['id'], {'status': 'error'})
raise exception.CinderException('fake exception')
self.stubs.Set(self.volume.driver, 'create_cloned_volume',
fake_error_create_cloned_volume)
volume_src = tests_utils.create_volume(self.context,
**self.volume_params)
self.volume.create_volume(self.context, volume_src['id'])
volume_dst = tests_utils.create_volume(self.context,
source_volid=volume_src['id'],
**self.volume_params)
self.assertRaises(exception.CinderException,
self.volume.create_volume,
self.context,
volume_dst['id'])
self.assertEqual('creating', volume_src['status'])
self.volume.delete_volume(self.context, volume_dst['id'])
self.volume.delete_volume(self.context, volume_src['id'])
def test_clean_temporary_volume(self):
def fake_delete_volume(ctxt, volume):
db.volume_destroy(ctxt, volume['id'])
fake_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
fake_new_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
# Check when the migrated volume is in migration
db.volume_update(self.context, fake_volume['id'],
{'migration_status': 'migrating'})
# 1. Only clean the db
self.volume._clean_temporary_volume(self.context, fake_volume['id'],
fake_new_volume['id'],
clean_db_only=True)
self.assertRaises(exception.VolumeNotFound,
db.volume_get, self.context,
fake_new_volume['id'])
# 2. Delete the backend storage
fake_new_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
with mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume') as \
mock_delete_volume:
mock_delete_volume.side_effect = fake_delete_volume
self.volume._clean_temporary_volume(self.context,
fake_volume['id'],
fake_new_volume['id'],
clean_db_only=False)
self.assertRaises(exception.VolumeNotFound,
db.volume_get, self.context,
fake_new_volume['id'])
# Check when the migrated volume is not in migration
fake_new_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
db.volume_update(self.context, fake_volume['id'],
{'migration_status': 'non-migrating'})
self.volume._clean_temporary_volume(self.context, fake_volume['id'],
fake_new_volume['id'])
volume = db.volume_get(context.get_admin_context(),
fake_new_volume['id'])
self.assertIsNone(volume['migration_status'])
def test_update_volume_readonly_flag(self):
"""Test volume readonly flag can be updated at API level."""
# create a volume and assign to host
volume = tests_utils.create_volume(self.context,
admin_metadata={'readonly': 'True'},
**self.volume_params)
self.volume.create_volume(self.context, volume['id'])
volume['status'] = 'in-use'
def sort_func(obj):
return obj['name']
volume_api = cinder.volume.api.API()
# Update fails when status != available
self.assertRaises(exception.InvalidVolume,
volume_api.update_readonly_flag,
self.context,
volume,
False)
volume['status'] = 'available'
# works when volume in 'available' status
volume_api.update_readonly_flag(self.context, volume, False)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('available', volume['status'])
admin_metadata = volume['volume_admin_metadata']
self.assertEqual(1, len(admin_metadata))
self.assertEqual('readonly', admin_metadata[0]['key'])
self.assertEqual('False', admin_metadata[0]['value'])
# clean up
self.volume.delete_volume(self.context, volume['id'])
def test_secure_file_operations_enabled(self):
"""Test secure file operations setting for base driver.
General, non network file system based drivers do not have
anything to do with "secure_file_operations". This test verifies that
calling the method always returns False.
"""
ret_flag = self.volume.driver.secure_file_operations_enabled()
self.assertFalse(ret_flag)
@mock.patch('cinder.volume.flows.common.make_pretty_name',
new=mock.MagicMock())
@mock.patch('cinder.scheduler.rpcapi.SchedulerAPI.create_volume',
return_value=None)
@mock.patch('cinder.volume.flows.manager.create_volume.'
'CreateVolumeFromSpecTask.execute',
side_effect=exception.DriverNotInitialized())
def test_create_volume_raise_rescheduled_exception(self, mock_execute,
mock_reschedule):
# Create source volume
test_vol = tests_utils.create_volume(self.context,
**self.volume_params)
test_vol_id = test_vol['id']
self.assertRaises(exception.DriverNotInitialized,
self.volume.create_volume,
self.context, test_vol_id,
{'volume_properties': self.volume_params},
{'retry': {'num_attempts': 1, 'host': []}})
self.assertTrue(mock_reschedule.called)
volume = db.volume_get(context.get_admin_context(), test_vol_id)
self.assertEqual('creating', volume['status'])
@mock.patch('cinder.volume.flows.manager.create_volume.'
'CreateVolumeFromSpecTask.execute')
def test_create_volume_raise_unrescheduled_exception(self, mock_execute):
# create source volume
test_vol = tests_utils.create_volume(self.context,
**self.volume_params)
test_vol_id = test_vol['id']
mock_execute.side_effect = exception.VolumeNotFound(
volume_id=test_vol_id)
self.assertRaises(exception.VolumeNotFound,
self.volume.create_volume,
self.context, test_vol_id,
{'volume_properties': self.volume_params},
{'retry': {'num_attempts': 1, 'host': []}})
volume = db.volume_get(context.get_admin_context(), test_vol_id)
self.assertEqual('error', volume['status'])
class VolumeMigrationTestCase(VolumeTestCase):
def test_migrate_volume_driver(self):
"""Test volume migration done by driver."""
# stub out driver and rpc functions
self.stubs.Set(self.volume.driver, 'migrate_volume',
lambda x, y, z, new_type_id=None: (True,
{'user_id': 'foo'}))
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host,
migration_status='migrating')
host_obj = {'host': 'newhost', 'capabilities': {}}
self.volume.migrate_volume(self.context, volume['id'],
host_obj, False)
# check volume properties
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('newhost', volume['host'])
self.assertEqual('success', volume['migration_status'])
def _fake_create_volume(self, ctxt, volume, host, req_spec, filters,
allow_reschedule=True):
return db.volume_update(ctxt, volume['id'],
{'status': self.expected_status})
def test_migrate_volume_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume') as \
mock_migrate,\
mock.patch.object(self.volume.driver, 'create_export') as \
mock_create_export:
# Exception case at self.driver.migrate_volume and create_export
mock_migrate.side_effect = processutils.ProcessExecutionError
mock_create_export.side_effect = processutils.ProcessExecutionError
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(processutils.ProcessExecutionError,
self.volume.migrate_volume,
self.context,
volume['id'],
host_obj,
False)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
@mock.patch('cinder.compute.API')
@mock.patch('cinder.volume.manager.VolumeManager.'
'migrate_volume_completion')
@mock.patch('cinder.db.sqlalchemy.api.volume_get')
def test_migrate_volume_generic(self, volume_get,
migrate_volume_completion,
nova_api):
fake_volume_id = 'fake_volume_id'
fake_new_volume = {'status': 'available', 'id': fake_volume_id}
host_obj = {'host': 'newhost', 'capabilities': {}}
volume_get.return_value = fake_new_volume
update_server_volume = nova_api.return_value.update_server_volume
volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
with mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume:
self.volume._migrate_volume_generic(self.context, volume,
host_obj, None)
mock_copy_volume.assert_called_with(self.context, volume,
fake_new_volume,
remote='dest')
migrate_volume_completion.assert_called_with(self.context,
volume['id'],
fake_new_volume['id'],
error=False)
self.assertFalse(update_server_volume.called)
@mock.patch('cinder.compute.API')
@mock.patch('cinder.volume.manager.VolumeManager.'
'migrate_volume_completion')
@mock.patch('cinder.db.sqlalchemy.api.volume_get')
def test_migrate_volume_generic_attached_volume(self, volume_get,
migrate_volume_completion,
nova_api):
attached_host = 'some-host'
fake_volume_id = 'fake_volume_id'
fake_db_new_volume = {'status': 'available', 'id': fake_volume_id}
fake_new_volume = fake_volume.fake_db_volume(**fake_db_new_volume)
host_obj = {'host': 'newhost', 'capabilities': {}}
fake_uuid = fakes.get_fake_uuid()
update_server_volume = nova_api.return_value.update_server_volume
volume_get.return_value = fake_new_volume
volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
volume_attach = tests_utils.attach_volume(
self.context, volume['id'], fake_uuid, attached_host, '/dev/vda')
self.assertIsNotNone(volume_attach['volume_attachment'][0]['id'])
self.assertEqual(
fake_uuid, volume_attach['volume_attachment'][0]['instance_uuid'])
self.assertEqual('in-use', volume_attach['status'])
self.volume._migrate_volume_generic(self.context, volume,
host_obj, None)
self.assertFalse(migrate_volume_completion.called)
update_server_volume.assert_called_with(self.context, fake_uuid,
volume['id'], fake_volume_id)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'update_migrated_volume')
@mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume')
@mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')
def test_migrate_volume_for_volume_generic(self, create_volume,
rpc_delete_volume,
update_migrated_volume):
fake_volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
with mock.patch.object(self.volume.driver, 'migrate_volume') as \
mock_migrate_volume,\
mock.patch.object(self.volume, '_copy_volume_data'),\
mock.patch.object(self.volume.driver, 'delete_volume') as \
delete_volume:
create_volume.side_effect = self._fake_create_volume
self.volume.migrate_volume(self.context, fake_volume['id'],
host_obj, True)
volume = db.volume_get(context.get_admin_context(),
fake_volume['id'])
self.assertEqual('newhost', volume['host'])
self.assertEqual('success', volume['migration_status'])
self.assertFalse(mock_migrate_volume.called)
self.assertFalse(delete_volume.called)
self.assertTrue(rpc_delete_volume.called)
self.assertTrue(update_migrated_volume.called)
def test_migrate_volume_generic_copy_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
mock.patch.object(self.volume, 'migrate_volume_completion'),\
mock.patch.object(self.volume.driver, 'create_export'):
# Exception case at migrate_volume_generic
# source_volume['migration_status'] is 'migrating'
mock_create_volume.side_effect = self._fake_create_volume
mock_copy_volume.side_effect = processutils.ProcessExecutionError
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(processutils.ProcessExecutionError,
self.volume.migrate_volume,
self.context,
volume['id'],
host_obj,
True)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
@mock.patch('cinder.db.volume_update')
def test_update_migrated_volume(self, volume_update):
fake_host = 'fake_host'
fake_new_host = 'fake_new_host'
fake_update = {'_name_id': 'updated_id',
'provider_location': 'updated_location'}
fake_elevated = 'fake_elevated'
volume = tests_utils.create_volume(self.context, size=1,
status='available',
host=fake_host)
new_volume = tests_utils.create_volume(
self.context, size=1,
status='available',
provider_location='fake_provider_location',
_name_id='fake_name_id',
host=fake_new_host)
new_volume['_name_id'] = 'fake_name_id'
new_volume['provider_location'] = 'fake_provider_location'
fake_update_error = {'_name_id': new_volume['_name_id'],
'provider_location':
new_volume['provider_location']}
expected_update = {'_name_id': volume['_name_id'],
'provider_location': volume['provider_location']}
with mock.patch.object(self.volume.driver,
'update_migrated_volume') as migrate_update,\
mock.patch.object(self.context, 'elevated') as elevated:
migrate_update.return_value = fake_update
elevated.return_value = fake_elevated
self.volume.update_migrated_volume(self.context, volume,
new_volume, 'available')
volume_update.assert_has_calls((
mock.call(fake_elevated, new_volume['id'], expected_update),
mock.call(fake_elevated, volume['id'], fake_update)))
# Test the case for update_migrated_volume not implemented
# for the driver.
migrate_update.reset_mock()
volume_update.reset_mock()
migrate_update.side_effect = NotImplementedError
self.volume.update_migrated_volume(self.context, volume,
new_volume, 'available')
volume_update.assert_has_calls((
mock.call(fake_elevated, new_volume['id'], expected_update),
mock.call(fake_elevated, volume['id'], fake_update_error)))
def test_migrate_volume_generic_create_volume_error(self):
self.expected_status = 'error'
with mock.patch.object(self.volume.driver, 'migrate_volume'), \
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume') as \
mock_create_volume, \
mock.patch.object(self.volume, '_clean_temporary_volume') as \
clean_temporary_volume:
# Exception case at the creation of the new temporary volume
mock_create_volume.side_effect = self._fake_create_volume
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(exception.VolumeMigrationFailed,
self.volume.migrate_volume,
self.context,
volume['id'],
host_obj,
True)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
self.assertTrue(clean_temporary_volume.called)
self.expected_status = 'available'
def test_migrate_volume_generic_timeout_error(self):
CONF.set_override("migration_create_volume_timeout_secs", 2)
with mock.patch.object(self.volume.driver, 'migrate_volume'), \
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume') as \
mock_create_volume, \
mock.patch.object(self.volume, '_clean_temporary_volume') as \
clean_temporary_volume, \
mock.patch.object(time, 'sleep'):
# Exception case at the timeout of the volume creation
self.expected_status = 'creating'
mock_create_volume.side_effect = self._fake_create_volume
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(exception.VolumeMigrationFailed,
self.volume.migrate_volume,
self.context,
volume['id'],
host_obj,
True)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
self.assertTrue(clean_temporary_volume.called)
self.expected_status = 'available'
def test_migrate_volume_generic_create_export_error(self):
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
mock.patch.object(self.volume, '_copy_volume_data') as \
mock_copy_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
mock.patch.object(self.volume, 'migrate_volume_completion'),\
mock.patch.object(self.volume.driver, 'create_export') as \
mock_create_export:
# Exception case at create_export
mock_create_volume.side_effect = self._fake_create_volume
mock_copy_volume.side_effect = processutils.ProcessExecutionError
mock_create_export.side_effect = processutils.ProcessExecutionError
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(processutils.ProcessExecutionError,
self.volume.migrate_volume,
self.context,
volume['id'],
host_obj,
True)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
def test_migrate_volume_generic_migrate_volume_completion_error(self):
def fake_migrate_volume_completion(ctxt, volume_id, new_volume_id,
error=False):
db.volume_update(ctxt, volume['id'],
{'migration_status': 'completing'})
raise processutils.ProcessExecutionError
with mock.patch.object(self.volume.driver, 'migrate_volume'),\
mock.patch.object(volume_rpcapi.VolumeAPI, 'create_volume')\
as mock_create_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume'),\
mock.patch.object(self.volume, 'migrate_volume_completion')\
as mock_migrate_compl,\
mock.patch.object(self.volume.driver, 'create_export'), \
mock.patch.object(self.volume, '_attach_volume') \
as mock_attach, \
mock.patch.object(self.volume, '_detach_volume'), \
mock.patch.object(os_brick.initiator.connector,
'get_connector_properties') \
as mock_get_connector_properties, \
mock.patch.object(volutils, 'copy_volume') as mock_copy, \
mock.patch.object(volume_rpcapi.VolumeAPI,
'get_capabilities') \
as mock_get_capabilities:
# Exception case at delete_volume
# source_volume['migration_status'] is 'completing'
mock_create_volume.side_effect = self._fake_create_volume
mock_migrate_compl.side_effect = fake_migrate_volume_completion
mock_get_connector_properties.return_value = {}
mock_attach.side_effect = [{'device': {'path': 'bar'}},
{'device': {'path': 'foo'}}]
mock_get_capabilities.return_value = {'sparse_copy_volume': True}
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.assertRaises(processutils.ProcessExecutionError,
self.volume.migrate_volume,
self.context,
volume['id'],
host_obj,
True)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error', volume['migration_status'])
self.assertEqual('available', volume['status'])
mock_copy.assert_called_once_with('foo', 'bar', 0, '1M',
sparse=True)
def _test_migrate_volume_completion(self, status='available',
instance_uuid=None, attached_host=None,
retyping=False,
previous_status='available'):
def fake_attach_volume(ctxt, volume, instance_uuid, host_name,
mountpoint, mode):
tests_utils.attach_volume(ctxt, volume['id'],
instance_uuid, host_name,
'/dev/vda')
initial_status = retyping and 'retyping' or status
old_volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host,
status=initial_status,
migration_status='migrating',
previous_status=previous_status)
attachment_id = None
if status == 'in-use':
vol = tests_utils.attach_volume(self.context, old_volume['id'],
instance_uuid, attached_host,
'/dev/vda')
self.assertEqual('in-use', vol['status'])
attachment_id = vol['volume_attachment'][0]['id']
target_status = 'target:%s' % old_volume['id']
new_host = CONF.host + 'new'
new_volume = tests_utils.create_volume(self.context, size=0,
host=new_host,
migration_status=target_status)
with mock.patch.object(self.volume, 'detach_volume') as \
mock_detach_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI, 'delete_volume') as \
mock_delete_volume, \
mock.patch.object(volume_rpcapi.VolumeAPI, 'attach_volume') as \
mock_attach_volume,\
mock.patch.object(volume_rpcapi.VolumeAPI,
'update_migrated_volume'),\
mock.patch.object(self.volume.driver, 'attach_volume'):
mock_attach_volume.side_effect = fake_attach_volume
self.volume.migrate_volume_completion(self.context, old_volume[
'id'], new_volume['id'])
after_new_volume = db.volume_get(self.context, new_volume.id)
after_old_volume = db.volume_get(self.context, old_volume.id)
if status == 'in-use':
mock_detach_volume.assert_called_with(self.context,
old_volume['id'],
attachment_id)
attachment = db.volume_attachment_get_by_instance_uuid(
self.context, old_volume['id'], instance_uuid)
self.assertIsNotNone(attachment)
self.assertEqual(attached_host, attachment['attached_host'])
self.assertEqual(instance_uuid, attachment['instance_uuid'])
else:
self.assertFalse(mock_detach_volume.called)
self.assertTrue(mock_delete_volume.called)
self.assertEqual(old_volume.host, after_new_volume.host)
self.assertEqual(new_volume.host, after_old_volume.host)
def test_migrate_volume_completion_retype_available(self):
self._test_migrate_volume_completion('available', retyping=True)
def test_migrate_volume_completion_retype_in_use(self):
self._test_migrate_volume_completion(
'in-use',
'83c969d5-065e-4c9c-907d-5394bc2e98e2',
'some-host',
retyping=True,
previous_status='in-use')
def test_migrate_volume_completion_migrate_available(self):
self._test_migrate_volume_completion()
def test_migrate_volume_completion_migrate_in_use(self):
self._test_migrate_volume_completion(
'in-use',
'83c969d5-065e-4c9c-907d-5394bc2e98e2',
'some-host',
retyping=False,
previous_status='in-use')
def test_retype_setup_fail_volume_is_available(self):
"""Verify volume is still available if retype prepare failed."""
elevated = context.get_admin_context()
project_id = self.context.project_id
db.volume_type_create(elevated, {'name': 'old', 'extra_specs': {}})
old_vol_type = db.volume_type_get_by_name(elevated, 'old')
db.volume_type_create(elevated, {'name': 'new', 'extra_specs': {}})
new_vol_type = db.volume_type_get_by_name(elevated, 'new')
db.quota_create(elevated, project_id, 'volumes_new', 0)
volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host, status='available',
volume_type_id=old_vol_type['id'])
api = cinder.volume.api.API()
self.assertRaises(exception.VolumeLimitExceeded, api.retype,
self.context, volume, new_vol_type['id'])
volume = db.volume_get(elevated, volume.id)
self.assertEqual('available', volume['status'])
def _retype_volume_exec(self, driver, snap=False, policy='on-demand',
migrate_exc=False, exc=None, diff_equal=False,
replica=False):
elevated = context.get_admin_context()
project_id = self.context.project_id
db.volume_type_create(elevated, {'name': 'old', 'extra_specs': {}})
old_vol_type = db.volume_type_get_by_name(elevated, 'old')
db.volume_type_create(elevated, {'name': 'new', 'extra_specs': {}})
vol_type = db.volume_type_get_by_name(elevated, 'new')
db.quota_create(elevated, project_id, 'volumes_new', 10)
if replica:
rep_status = 'active'
else:
rep_status = 'disabled'
volume = tests_utils.create_volume(self.context, size=1,
host=CONF.host, status='retyping',
volume_type_id=old_vol_type['id'],
replication_status=rep_status)
volume.previous_status = 'available'
volume.save()
if snap:
self._create_snapshot(volume.id, size=volume.size)
if driver or diff_equal:
host_obj = {'host': CONF.host, 'capabilities': {}}
else:
host_obj = {'host': 'newhost', 'capabilities': {}}
reserve_opts = {'volumes': 1, 'gigabytes': volume.size}
QUOTAS.add_volume_type_opts(self.context,
reserve_opts,
vol_type['id'])
reservations = QUOTAS.reserve(self.context,
project_id=project_id,
**reserve_opts)
with mock.patch.object(self.volume.driver, 'retype') as _retype,\
mock.patch.object(volume_types, 'volume_types_diff') as _diff,\
mock.patch.object(self.volume, 'migrate_volume') as _mig,\
mock.patch.object(db.sqlalchemy.api, 'volume_get') as mock_get:
mock_get.return_value = volume
_retype.return_value = driver
_diff.return_value = ({}, diff_equal)
if migrate_exc:
_mig.side_effect = KeyError
else:
_mig.return_value = True
if not exc:
self.volume.retype(self.context, volume.id,
vol_type['id'], host_obj,
migration_policy=policy,
reservations=reservations,
volume=volume)
else:
self.assertRaises(exc, self.volume.retype,
self.context, volume.id,
vol_type['id'], host_obj,
migration_policy=policy,
reservations=reservations,
volume=volume)
# get volume/quota properties
volume = objects.Volume.get_by_id(elevated, volume.id)
try:
usage = db.quota_usage_get(elevated, project_id, 'volumes_new')
volumes_in_use = usage.in_use
except exception.QuotaUsageNotFound:
volumes_in_use = 0
# check properties
if driver or diff_equal:
self.assertEqual(vol_type['id'], volume.volume_type_id)
self.assertEqual('available', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(1, volumes_in_use)
elif not exc:
self.assertEqual(old_vol_type['id'], volume.volume_type_id)
self.assertEqual('retyping', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(1, volumes_in_use)
else:
self.assertEqual(old_vol_type['id'], volume.volume_type_id)
self.assertEqual('available', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(0, volumes_in_use)
def test_retype_volume_driver_success(self):
self._retype_volume_exec(True)
def test_retype_volume_migration_bad_policy(self):
# Test volume retype that requires migration by not allowed
self._retype_volume_exec(False, policy='never',
exc=exception.VolumeMigrationFailed)
def test_retype_volume_migration_with_replica(self):
self._retype_volume_exec(False,
replica=True,
exc=exception.InvalidVolume)
def test_retype_volume_migration_with_snaps(self):
self._retype_volume_exec(False, snap=True, exc=exception.InvalidVolume)
def test_retype_volume_migration_failed(self):
self._retype_volume_exec(False, migrate_exc=True, exc=KeyError)
def test_retype_volume_migration_success(self):
self._retype_volume_exec(False, migrate_exc=False, exc=None)
def test_retype_volume_migration_equal_types(self):
self._retype_volume_exec(False, diff_equal=True)
def test_migrate_driver_not_initialized(self):
volume = tests_utils.create_volume(self.context, size=0,
host=CONF.host)
host_obj = {'host': 'newhost', 'capabilities': {}}
self.volume.driver._initialized = False
self.assertRaises(exception.DriverNotInitialized,
self.volume.migrate_volume,
self.context, volume['id'],
host_obj, True)
volume = db.volume_get(context.get_admin_context(), volume['id'])
self.assertEqual('error', volume.migration_status)
# lets cleanup the mess.
self.volume.driver._initialized = True
self.volume.delete_volume(self.context, volume['id'])
def test_delete_source_volume_in_migration(self):
"""Test deleting a source volume that is in migration."""
self._test_delete_volume_in_migration('migrating')
def test_delete_destination_volume_in_migration(self):
"""Test deleting a destination volume that is in migration."""
self._test_delete_volume_in_migration('target:vol-id')
def _test_delete_volume_in_migration(self, migration_status):
"""Test deleting a volume that is in migration."""
volume = tests_utils.create_volume(self.context, **self.volume_params)
volume = db.volume_update(self.context, volume['id'],
{'status': 'available',
'migration_status': migration_status})
self.volume.delete_volume(self.context, volume['id'])
# The volume is successfully removed during the volume delete
# and won't exist in the database any more.
self.assertRaises(exception.VolumeNotFound, db.volume_get,
self.context, volume['id'])
class ConsistencyGroupTestCase(BaseVolumeTestCase):
def test_delete_volume_in_consistency_group(self):
"""Test deleting a volume that's tied to a consistency group fails."""
volume_api = cinder.volume.api.API()
volume = tests_utils.create_volume(self.context, **self.volume_params)
consistencygroup_id = '12345678-1234-5678-1234-567812345678'
volume = db.volume_update(self.context, volume['id'],
{'status': 'available',
'consistencygroup_id': consistencygroup_id})
self.assertRaises(exception.InvalidVolume,
volume_api.delete, self.context, volume)
@mock.patch.object(CGQUOTAS, "reserve",
return_value=["RESERVATION"])
@mock.patch.object(CGQUOTAS, "commit")
@mock.patch.object(CGQUOTAS, "rollback")
@mock.patch.object(driver.VolumeDriver,
"delete_consistencygroup",
return_value=({'status': 'deleted'}, []))
def test_create_delete_consistencygroup(self, fake_delete_cg,
fake_rollback,
fake_commit, fake_reserve):
"""Test consistencygroup can be created and deleted."""
def fake_driver_create_cg(context, group):
"""Make sure that the pool is part of the host."""
self.assertIn('host', group)
host = group.host
pool = volutils.extract_host(host, level='pool')
self.assertEqual('fakepool', pool)
return {'status': 'available'}
self.stubs.Set(self.volume.driver, 'create_consistencygroup',
fake_driver_create_cg)
group = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2',
host='fakehost@fakedrv#fakepool')
group = objects.ConsistencyGroup.get_by_id(self.context, group.id)
self.assertEqual(0, len(self.notifier.notifications),
self.notifier.notifications)
self.volume.create_consistencygroup(self.context, group)
self.assertEqual(2, len(self.notifier.notifications),
self.notifier.notifications)
msg = self.notifier.notifications[0]
self.assertEqual('consistencygroup.create.start', msg['event_type'])
expected = {
'status': 'available',
'name': 'test_cg',
'availability_zone': 'nova',
'tenant_id': self.context.project_id,
'created_at': 'DONTCARE',
'user_id': 'fake',
'consistencygroup_id': group.id
}
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[1]
self.assertEqual('consistencygroup.create.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
self.assertEqual(
group.id,
objects.ConsistencyGroup.get_by_id(context.get_admin_context(),
group.id).id)
self.volume.delete_consistencygroup(self.context, group)
cg = objects.ConsistencyGroup.get_by_id(
context.get_admin_context(read_deleted='yes'), group.id)
self.assertEqual('deleted', cg.status)
self.assertEqual(4, len(self.notifier.notifications),
self.notifier.notifications)
msg = self.notifier.notifications[2]
self.assertEqual('consistencygroup.delete.start', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[3]
self.assertEqual('consistencygroup.delete.end', msg['event_type'])
expected['status'] = 'deleted'
self.assertDictMatch(expected, msg['payload'])
self.assertRaises(exception.NotFound,
objects.ConsistencyGroup.get_by_id,
self.context,
group.id)
@mock.patch.object(CGQUOTAS, "reserve",
return_value=["RESERVATION"])
@mock.patch.object(CGQUOTAS, "commit")
@mock.patch.object(CGQUOTAS, "rollback")
@mock.patch.object(driver.VolumeDriver,
"create_consistencygroup",
return_value={'status': 'available'})
@mock.patch.object(driver.VolumeDriver,
"update_consistencygroup")
def test_update_consistencygroup(self, fake_update_cg,
fake_create_cg, fake_rollback,
fake_commit, fake_reserve):
"""Test consistencygroup can be updated."""
group = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2')
self.volume.create_consistencygroup(self.context, group)
volume = tests_utils.create_volume(
self.context,
consistencygroup_id=group.id,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
volume2 = tests_utils.create_volume(
self.context,
consistencygroup_id=None,
**self.volume_params)
volume_id2 = volume2['id']
self.volume.create_volume(self.context, volume_id2)
fake_update_cg.return_value = (
{'status': 'available'},
[{'id': volume_id2, 'status': 'available'}],
[{'id': volume_id, 'status': 'available'}])
self.volume.update_consistencygroup(self.context, group,
add_volumes=volume_id2,
remove_volumes=volume_id)
cg = objects.ConsistencyGroup.get_by_id(self.context, group.id)
expected = {
'status': 'available',
'name': 'test_cg',
'availability_zone': 'nova',
'tenant_id': self.context.project_id,
'created_at': 'DONTCARE',
'user_id': 'fake',
'consistencygroup_id': group.id
}
self.assertEqual('available', cg.status)
self.assertEqual(10, len(self.notifier.notifications),
self.notifier.notifications)
msg = self.notifier.notifications[6]
self.assertEqual('consistencygroup.update.start', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[8]
self.assertEqual('consistencygroup.update.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
cgvolumes = db.volume_get_all_by_group(self.context, group.id)
cgvol_ids = [cgvol['id'] for cgvol in cgvolumes]
# Verify volume is removed.
self.assertNotIn(volume_id, cgvol_ids)
# Verify volume is added.
self.assertIn(volume_id2, cgvol_ids)
self.volume_params['status'] = 'wrong-status'
volume3 = tests_utils.create_volume(
self.context,
consistencygroup_id=None,
**self.volume_params)
volume_id3 = volume3['id']
volume_get_orig = self.volume.db.volume_get
self.volume.db.volume_get = mock.Mock(
return_value={'status': 'wrong_status',
'id': volume_id3})
# Try to add a volume in wrong status
self.assertRaises(exception.InvalidVolume,
self.volume.update_consistencygroup,
self.context,
group,
add_volumes=volume_id3,
remove_volumes=None)
self.volume.db.volume_get.reset_mock()
self.volume.db.volume_get = volume_get_orig
@mock.patch.object(driver.VolumeDriver,
"create_consistencygroup",
return_value={'status': 'available'})
@mock.patch.object(driver.VolumeDriver,
"delete_consistencygroup",
return_value=({'status': 'deleted'}, []))
@mock.patch.object(driver.VolumeDriver,
"create_cgsnapshot",
return_value={'status': 'available'})
@mock.patch.object(driver.VolumeDriver,
"delete_cgsnapshot",
return_value=({'status': 'deleted'}, []))
@mock.patch.object(driver.VolumeDriver,
"create_consistencygroup_from_src",
return_value=(None, None))
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'create_volume_from_snapshot')
@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.'
'create_cloned_volume')
def test_create_consistencygroup_from_src(self,
mock_create_cloned_vol,
mock_create_vol_from_snap,
mock_create_from_src,
mock_delete_cgsnap,
mock_create_cgsnap,
mock_delete_cg,
mock_create_cg):
"""Test consistencygroup can be created and deleted."""
group = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2',
status='available')
volume = tests_utils.create_volume(
self.context,
consistencygroup_id=group.id,
status='available',
host=CONF.host,
size=1)
volume_id = volume['id']
cgsnapshot_returns = self._create_cgsnapshot(group.id, volume_id)
cgsnapshot = cgsnapshot_returns[0]
snapshot_id = cgsnapshot_returns[1]['id']
# Create CG from source CG snapshot.
group2 = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2',
cgsnapshot_id=cgsnapshot.id)
group2 = objects.ConsistencyGroup.get_by_id(self.context, group2.id)
volume2 = tests_utils.create_volume(
self.context,
consistencygroup_id=group2.id,
snapshot_id=snapshot_id,
**self.volume_params)
self.volume.create_volume(self.context, volume2.id, volume=volume2)
self.volume.create_consistencygroup_from_src(
self.context, group2, cgsnapshot=cgsnapshot)
cg2 = objects.ConsistencyGroup.get_by_id(self.context, group2.id)
expected = {
'status': 'available',
'name': 'test_cg',
'availability_zone': 'nova',
'tenant_id': self.context.project_id,
'created_at': 'DONTCARE',
'user_id': 'fake',
'consistencygroup_id': group2.id,
}
self.assertEqual('available', cg2.status)
self.assertEqual(group2.id, cg2['id'])
self.assertEqual(cgsnapshot.id, cg2['cgsnapshot_id'])
self.assertIsNone(cg2['source_cgid'])
msg = self.notifier.notifications[2]
self.assertEqual('consistencygroup.create.start', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[4]
self.assertEqual('consistencygroup.create.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
if len(self.notifier.notifications) > 6:
self.assertFalse(self.notifier.notifications[6],
self.notifier.notifications)
self.assertEqual(6, len(self.notifier.notifications),
self.notifier.notifications)
self.volume.delete_consistencygroup(self.context, group2)
if len(self.notifier.notifications) > 10:
self.assertFalse(self.notifier.notifications[10],
self.notifier.notifications)
self.assertEqual(10, len(self.notifier.notifications),
self.notifier.notifications)
msg = self.notifier.notifications[6]
self.assertEqual('consistencygroup.delete.start', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[8]
self.assertEqual('consistencygroup.delete.end', msg['event_type'])
expected['status'] = 'deleted'
self.assertDictMatch(expected, msg['payload'])
cg2 = objects.ConsistencyGroup.get_by_id(
context.get_admin_context(read_deleted='yes'), group2.id)
self.assertEqual('deleted', cg2.status)
self.assertRaises(exception.NotFound,
objects.ConsistencyGroup.get_by_id,
self.context,
group2.id)
# Create CG from source CG.
group3 = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2',
source_cgid=group.id)
volume3 = tests_utils.create_volume(
self.context,
consistencygroup_id=group3.id,
source_volid=volume_id,
**self.volume_params)
self.volume.create_volume(self.context, volume3.id, volume=volume3)
self.volume.create_consistencygroup_from_src(
self.context, group3, source_cg=group)
cg3 = objects.ConsistencyGroup.get_by_id(self.context, group3.id)
self.assertEqual('available', cg3.status)
self.assertEqual(group3.id, cg3.id)
self.assertEqual(group.id, cg3.source_cgid)
self.assertIsNone(cg3.cgsnapshot_id)
self.volume.delete_cgsnapshot(self.context, cgsnapshot)
self.volume.delete_consistencygroup(self.context, group)
def test_sort_snapshots(self):
vol1 = {'id': '1', 'name': 'volume 1',
'snapshot_id': '1',
'consistencygroup_id': '1'}
vol2 = {'id': '2', 'name': 'volume 2',
'snapshot_id': '2',
'consistencygroup_id': '1'}
vol3 = {'id': '3', 'name': 'volume 3',
'snapshot_id': '3',
'consistencygroup_id': '1'}
snp1 = {'id': '1', 'name': 'snap 1',
'cgsnapshot_id': '1'}
snp2 = {'id': '2', 'name': 'snap 2',
'cgsnapshot_id': '1'}
snp3 = {'id': '3', 'name': 'snap 3',
'cgsnapshot_id': '1'}
snp1_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp1)
snp2_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp2)
snp3_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp3)
volumes = []
snapshots = []
volumes.append(vol1)
volumes.append(vol2)
volumes.append(vol3)
snapshots.append(snp2_obj)
snapshots.append(snp3_obj)
snapshots.append(snp1_obj)
i = 0
for vol in volumes:
snap = snapshots[i]
i += 1
self.assertNotEqual(vol['snapshot_id'], snap.id)
sorted_snaps = self.volume._sort_snapshots(volumes, snapshots)
i = 0
for vol in volumes:
snap = sorted_snaps[i]
i += 1
self.assertEqual(vol['snapshot_id'], snap.id)
snapshots[2]['id'] = '9999'
self.assertRaises(exception.SnapshotNotFound,
self.volume._sort_snapshots,
volumes, snapshots)
self.assertRaises(exception.InvalidInput,
self.volume._sort_snapshots,
volumes, [])
def test_sort_source_vols(self):
vol1 = {'id': '1', 'name': 'volume 1',
'source_volid': '1',
'consistencygroup_id': '2'}
vol2 = {'id': '2', 'name': 'volume 2',
'source_volid': '2',
'consistencygroup_id': '2'}
vol3 = {'id': '3', 'name': 'volume 3',
'source_volid': '3',
'consistencygroup_id': '2'}
src_vol1 = {'id': '1', 'name': 'source vol 1',
'consistencygroup_id': '1'}
src_vol2 = {'id': '2', 'name': 'source vol 2',
'consistencygroup_id': '1'}
src_vol3 = {'id': '3', 'name': 'source vol 3',
'consistencygroup_id': '1'}
volumes = []
src_vols = []
volumes.append(vol1)
volumes.append(vol2)
volumes.append(vol3)
src_vols.append(src_vol2)
src_vols.append(src_vol3)
src_vols.append(src_vol1)
i = 0
for vol in volumes:
src_vol = src_vols[i]
i += 1
self.assertNotEqual(vol['source_volid'], src_vol['id'])
sorted_src_vols = self.volume._sort_source_vols(volumes, src_vols)
i = 0
for vol in volumes:
src_vol = sorted_src_vols[i]
i += 1
self.assertEqual(vol['source_volid'], src_vol['id'])
src_vols[2]['id'] = '9999'
self.assertRaises(exception.VolumeNotFound,
self.volume._sort_source_vols,
volumes, src_vols)
self.assertRaises(exception.InvalidInput,
self.volume._sort_source_vols,
volumes, [])
def _create_cgsnapshot(self, group_id, volume_id, size='0'):
"""Create a cgsnapshot object."""
cgsnap = objects.CGSnapshot(self.context)
cgsnap.user_id = 'fake'
cgsnap.project_id = 'fake'
cgsnap.consistencygroup_id = group_id
cgsnap.status = "creating"
cgsnap.create()
# Create a snapshot object
snap = objects.Snapshot(context.get_admin_context())
snap.volume_size = size
snap.user_id = 'fake'
snap.project_id = 'fake'
snap.volume_id = volume_id
snap.status = "available"
snap.cgsnapshot_id = cgsnap.id
snap.create()
return cgsnap, snap
@mock.patch('cinder.volume.driver.VolumeDriver.create_consistencygroup',
autospec=True,
return_value={'status': 'available'})
@mock.patch('cinder.volume.driver.VolumeDriver.delete_consistencygroup',
autospec=True,
return_value=({'status': 'deleted'}, []))
@mock.patch('cinder.volume.driver.VolumeDriver.create_cgsnapshot',
autospec=True,
return_value=({'status': 'available'}, []))
@mock.patch('cinder.volume.driver.VolumeDriver.delete_cgsnapshot',
autospec=True,
return_value=({'status': 'deleted'}, []))
def test_create_delete_cgsnapshot(self,
mock_del_cgsnap, mock_create_cgsnap,
mock_del_cg, _mock_create_cg):
"""Test cgsnapshot can be created and deleted."""
group = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2')
volume = tests_utils.create_volume(
self.context,
consistencygroup_id=group.id,
**self.volume_params)
volume_id = volume['id']
self.volume.create_volume(self.context, volume_id)
if len(self.notifier.notifications) > 2:
self.assertFalse(self.notifier.notifications[2],
self.notifier.notifications)
self.assertEqual(2, len(self.notifier.notifications),
self.notifier.notifications)
cgsnapshot_returns = self._create_cgsnapshot(group.id, volume_id)
cgsnapshot = cgsnapshot_returns[0]
self.volume.create_cgsnapshot(self.context, cgsnapshot)
self.assertEqual(cgsnapshot.id,
objects.CGSnapshot.get_by_id(
context.get_admin_context(),
cgsnapshot.id).id)
if len(self.notifier.notifications) > 6:
self.assertFalse(self.notifier.notifications[6],
self.notifier.notifications)
msg = self.notifier.notifications[2]
self.assertEqual('cgsnapshot.create.start', msg['event_type'])
expected = {
'created_at': 'DONTCARE',
'name': None,
'cgsnapshot_id': cgsnapshot.id,
'status': 'creating',
'tenant_id': 'fake',
'user_id': 'fake',
'consistencygroup_id': group.id
}
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[3]
self.assertEqual('snapshot.create.start', msg['event_type'])
msg = self.notifier.notifications[4]
expected['status'] = 'available'
self.assertEqual('cgsnapshot.create.end', msg['event_type'])
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[5]
self.assertEqual('snapshot.create.end', msg['event_type'])
self.assertEqual(6, len(self.notifier.notifications),
self.notifier.notifications)
self.volume.delete_cgsnapshot(self.context, cgsnapshot)
if len(self.notifier.notifications) > 10:
self.assertFalse(self.notifier.notifications[10],
self.notifier.notifications)
msg = self.notifier.notifications[6]
self.assertEqual('cgsnapshot.delete.start', msg['event_type'])
expected['status'] = 'available'
self.assertDictMatch(expected, msg['payload'])
msg = self.notifier.notifications[8]
self.assertEqual('cgsnapshot.delete.end', msg['event_type'])
expected['status'] = 'deleted'
self.assertDictMatch(expected, msg['payload'])
self.assertEqual(10, len(self.notifier.notifications),
self.notifier.notifications)
cgsnap = objects.CGSnapshot.get_by_id(
context.get_admin_context(read_deleted='yes'),
cgsnapshot.id)
self.assertEqual('deleted', cgsnap.status)
self.assertRaises(exception.NotFound,
objects.CGSnapshot.get_by_id,
self.context,
cgsnapshot.id)
self.volume.delete_consistencygroup(self.context, group)
self.assertTrue(mock_create_cgsnap.called)
self.assertTrue(mock_del_cgsnap.called)
self.assertTrue(mock_del_cg.called)
@mock.patch('cinder.volume.driver.VolumeDriver.create_consistencygroup',
return_value={'status': 'available'})
@mock.patch('cinder.volume.driver.VolumeDriver.delete_consistencygroup',
return_value=({'status': 'deleted'}, []))
def test_delete_consistencygroup_correct_host(self,
mock_del_cg,
_mock_create_cg):
"""Test consistencygroup can be deleted.
Test consistencygroup can be deleted when volumes are on
the correct volume node.
"""
group = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2')
volume = tests_utils.create_volume(
self.context,
consistencygroup_id=group.id,
host='host1@backend1#pool1',
status='creating',
size=1)
self.volume.host = 'host1@backend1'
self.volume.create_volume(self.context, volume.id, volume=volume)
self.volume.delete_consistencygroup(self.context, group)
cg = objects.ConsistencyGroup.get_by_id(
context.get_admin_context(read_deleted='yes'),
group.id)
self.assertEqual('deleted', cg.status)
self.assertRaises(exception.NotFound,
objects.ConsistencyGroup.get_by_id,
self.context,
group.id)
self.assertTrue(mock_del_cg.called)
@mock.patch('cinder.volume.driver.VolumeDriver.create_consistencygroup',
return_value={'status': 'available'})
def test_delete_consistencygroup_wrong_host(self, *_mock_create_cg):
"""Test consistencygroup cannot be deleted.
Test consistencygroup cannot be deleted when volumes in the
group are not local to the volume node.
"""
group = tests_utils.create_consistencygroup(
self.context,
availability_zone=CONF.storage_availability_zone,
volume_type='type1,type2')
volume = tests_utils.create_volume(
self.context,
consistencygroup_id=group.id,
host='host1@backend1#pool1',
status='creating',
size=1)
self.volume.host = 'host1@backend2'
self.volume.create_volume(self.context, volume.id, volume=volume)
self.assertRaises(exception.InvalidVolume,
self.volume.delete_consistencygroup,
self.context,
group)
cg = objects.ConsistencyGroup.get_by_id(self.context, group.id)
# Group is not deleted
self.assertEqual('available', cg.status)
def test_create_volume_with_consistencygroup_invalid_type(self):
"""Test volume creation with ConsistencyGroup & invalid volume type."""
vol_type = db.volume_type_create(
context.get_admin_context(),
dict(name=conf_fixture.def_vol_type, extra_specs={})
)
db_vol_type = db.volume_type_get(context.get_admin_context(),
vol_type.id)
cg = {
'id': '1',
'name': 'cg1',
'volume_type_id': db_vol_type['id'],
}
fake_type = {
'id': '9999',
'name': 'fake',
}
vol_api = cinder.volume.api.API()
# Volume type must be provided when creating a volume in a
# consistency group.
self.assertRaises(exception.InvalidInput,
vol_api.create,
self.context, 1, 'vol1', 'volume 1',
consistencygroup=cg)
# Volume type must be valid.
self.assertRaises(exception.InvalidInput,
vol_api.create,
self.context, 1, 'vol1', 'volume 1',
volume_type=fake_type,
consistencygroup=cg)
@mock.patch.object(fake_driver.FakeISCSIDriver, 'get_volume_stats')
@mock.patch.object(driver.BaseVD, '_init_vendor_properties')
def test_get_capabilities(self, mock_init_vendor, mock_get_volume_stats):
stats = {
'volume_backend_name': 'lvm',
'vendor_name': 'Open Source',
'storage_protocol': 'iSCSI',
'vendor_prefix': 'abcd'
}
expected = stats.copy()
expected['properties'] = {
'compression': {
'title': 'Compression',
'description': 'Enables compression.',
'type': 'boolean'},
'qos': {
'title': 'QoS',
'description': 'Enables QoS.',
'type': 'boolean'},
'replication': {
'title': 'Replication',
'description': 'Enables replication.',
'type': 'boolean'},
'thin_provisioning': {
'title': 'Thin Provisioning',
'description': 'Sets thin provisioning.',
'type': 'boolean'},
}
# Test to get updated capabilities
discover = True
mock_get_volume_stats.return_value = stats
mock_init_vendor.return_value = ({}, None)
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities)
mock_get_volume_stats.assert_called_once_with(True)
# Test to get existing original capabilities
mock_get_volume_stats.reset_mock()
discover = False
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities)
self.assertFalse(mock_get_volume_stats.called)
# Normal test case to get vendor unique capabilities
def init_vendor_properties(self):
properties = {}
self._set_property(
properties,
"abcd:minIOPS",
"Minimum IOPS QoS",
"Sets minimum IOPS if QoS is enabled.",
"integer",
minimum=10,
default=100)
return properties, 'abcd'
expected['properties'].update(
{'abcd:minIOPS': {
'title': 'Minimum IOPS QoS',
'description': 'Sets minimum IOPS if QoS is enabled.',
'type': 'integer',
'minimum': 10,
'default': 100}})
mock_get_volume_stats.reset_mock()
mock_init_vendor.reset_mock()
discover = True
mock_init_vendor.return_value = (
init_vendor_properties(self.volume.driver))
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities)
self.assertTrue(mock_get_volume_stats.called)
@mock.patch.object(fake_driver.FakeISCSIDriver, 'get_volume_stats')
@mock.patch.object(driver.BaseVD, '_init_vendor_properties')
@mock.patch.object(driver.BaseVD, '_init_standard_capabilities')
def test_get_capabilities_prefix_error(self, mock_init_standard,
mock_init_vendor,
mock_get_volume_stats):
# Error test case: propety does not match vendor prefix
def init_vendor_properties(self):
properties = {}
self._set_property(
properties,
"aaa:minIOPS",
"Minimum IOPS QoS",
"Sets minimum IOPS if QoS is enabled.",
"integer")
self._set_property(
properties,
"abcd:compression_type",
"Compression type",
"Specifies compression type.",
"string")
return properties, 'abcd'
expected = {
'abcd:compression_type': {
'title': 'Compression type',
'description': 'Specifies compression type.',
'type': 'string'}}
discover = True
mock_get_volume_stats.return_value = {}
mock_init_standard.return_value = {}
mock_init_vendor.return_value = (
init_vendor_properties(self.volume.driver))
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities['properties'])
@mock.patch.object(fake_driver.FakeISCSIDriver, 'get_volume_stats')
@mock.patch.object(driver.BaseVD, '_init_vendor_properties')
@mock.patch.object(driver.BaseVD, '_init_standard_capabilities')
def test_get_capabilities_fail_override(self, mock_init_standard,
mock_init_vendor,
mock_get_volume_stats):
# Error test case: propety cannot override any standard capabilities
def init_vendor_properties(self):
properties = {}
self._set_property(
properties,
"qos",
"Minimum IOPS QoS",
"Sets minimum IOPS if QoS is enabled.",
"integer")
self._set_property(
properties,
"ab::cd:compression_type",
"Compression type",
"Specifies compression type.",
"string")
return properties, 'ab::cd'
expected = {
'ab__cd:compression_type': {
'title': 'Compression type',
'description': 'Specifies compression type.',
'type': 'string'}}
discover = True
mock_get_volume_stats.return_value = {}
mock_init_standard.return_value = {}
mock_init_vendor.return_value = (
init_vendor_properties(self.volume.driver))
capabilities = self.volume.get_capabilities(self.context,
discover)
self.assertEqual(expected, capabilities['properties'])
def test_delete_encryptied_volume(self):
self.volume_params['status'] = 'active'
volume = tests_utils.create_volume(self.context,
**self.volume_params)
vol_api = cinder.volume.api.API()
with mock.patch.object(
vol_api.key_manager,
'delete_key',
side_effect=Exception):
self.assertRaises(exception.InvalidVolume,
vol_api.delete,
self.context, volume)
class CopyVolumeToImageTestCase(BaseVolumeTestCase):
def fake_local_path(self, volume):
return self.dst_path
def setUp(self):
super(CopyVolumeToImageTestCase, self).setUp()
self.dst_fd, self.dst_path = tempfile.mkstemp()
self.addCleanup(os.unlink, self.dst_path)
os.close(self.dst_fd)
self.stubs.Set(self.volume.driver, 'local_path', self.fake_local_path)
self.image_id = '70a599e0-31e7-49b7-b260-868f441e862b'
self.image_meta = {
'id': self.image_id,
'container_format': 'bare',
'disk_format': 'raw'
}
self.volume_id = 1
self.addCleanup(db.volume_destroy, self.context, self.volume_id)
self.volume_attrs = {
'id': self.volume_id,
'updated_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'display_description': 'Test Desc',
'size': 20,
'status': 'uploading',
'host': 'dummy'
}
def test_copy_volume_to_image_status_available(self):
# creating volume testdata
self.volume_attrs['instance_uuid'] = None
db.volume_create(self.context, self.volume_attrs)
# start test
self.volume.copy_volume_to_image(self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
def test_copy_volume_to_image_instance_deleted(self):
# During uploading volume to image if instance is deleted,
# volume should be in available status.
self.image_meta['id'] = 'a440c04b-79fa-479c-bed1-0b816eaec379'
# Creating volume testdata
self.volume_attrs['instance_uuid'] = 'b21f957d-a72f-4b93-b5a5-' \
'45b1161abb02'
db.volume_create(self.context, self.volume_attrs)
# Storing unmocked db api function reference here, because we have to
# update volume status (set instance_uuid to None) before calling the
# 'volume_update_status_based_on_attached_instance_id' db api.
unmocked_db_api = db.volume_update_status_based_on_attachment
def mock_volume_update_after_upload(context, volume_id):
# First update volume and set 'instance_uuid' to None
# because after deleting instance, instance_uuid of volume is
# set to None
db.volume_update(context, volume_id, {'instance_uuid': None})
# Calling unmocked db api
unmocked_db_api(context, volume_id)
with mock.patch.object(
db,
'volume_update_status_based_on_attachment',
side_effect=mock_volume_update_after_upload) as mock_update:
# Start test
self.volume.copy_volume_to_image(self.context,
self.volume_id,
self.image_meta)
# Check 'volume_update_status_after_copy_volume_to_image'
# is called 1 time
self.assertEqual(1, mock_update.call_count)
# Check volume status has changed to available because
# instance is deleted
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
def test_copy_volume_to_image_status_use(self):
self.image_meta['id'] = 'a440c04b-79fa-479c-bed1-0b816eaec379'
# creating volume testdata
db.volume_create(self.context, self.volume_attrs)
# start test
self.volume.copy_volume_to_image(self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
def test_copy_volume_to_image_exception(self):
self.image_meta['id'] = self.FAKE_UUID
# creating volume testdata
self.volume_attrs['status'] = 'in-use'
db.volume_create(self.context, self.volume_attrs)
# start test
self.assertRaises(exception.ImageNotFound,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
def test_copy_volume_to_image_driver_not_initialized(self):
# creating volume testdata
db.volume_create(self.context, self.volume_attrs)
# set initialized to False
self.volume.driver._initialized = False
# start test
self.assertRaises(exception.DriverNotInitialized,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume.status)
def test_copy_volume_to_image_driver_exception(self):
self.image_meta['id'] = self.image_id
image_service = fake_image.FakeImageService()
# create new image in queued state
queued_image_id = 'd5133f15-f753-41bd-920a-06b8c49275d9'
queued_image_meta = image_service.show(self.context, self.image_id)
queued_image_meta['id'] = queued_image_id
queued_image_meta['status'] = 'queued'
image_service.create(self.context, queued_image_meta)
# create new image in saving state
saving_image_id = '5c6eec33-bab4-4e7d-b2c9-88e2d0a5f6f2'
saving_image_meta = image_service.show(self.context, self.image_id)
saving_image_meta['id'] = saving_image_id
saving_image_meta['status'] = 'saving'
image_service.create(self.context, saving_image_meta)
# create volume
self.volume_attrs['status'] = 'available'
self.volume_attrs['instance_uuid'] = None
db.volume_create(self.context, self.volume_attrs)
with mock.patch.object(self.volume.driver,
'copy_volume_to_image') as driver_copy_mock:
driver_copy_mock.side_effect = exception.VolumeDriverException(
"Error")
# test with image not in queued state
self.assertRaises(exception.VolumeDriverException,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
# image shouldn't be deleted if it is not in queued state
image_service.show(self.context, self.image_id)
# test with image in queued state
self.assertRaises(exception.VolumeDriverException,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
queued_image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
# queued image should be deleted
self.assertRaises(exception.ImageNotFound,
image_service.show,
self.context,
queued_image_id)
# test with image in saving state
self.assertRaises(exception.VolumeDriverException,
self.volume.copy_volume_to_image,
self.context,
self.volume_id,
saving_image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
# image in saving state should be deleted
self.assertRaises(exception.ImageNotFound,
image_service.show,
self.context,
saving_image_id)
@mock.patch.object(QUOTAS, 'reserve')
@mock.patch.object(QUOTAS, 'commit')
@mock.patch.object(vol_manager.VolumeManager, 'create_volume')
@mock.patch.object(fake_driver.FakeISCSIDriver, 'copy_volume_to_image')
def _test_copy_volume_to_image_with_image_volume(
self, mock_copy, mock_create, mock_quota_commit,
mock_quota_reserve):
self.flags(glance_api_version=2)
self.volume.driver.configuration.image_upload_use_cinder_backend = True
image_service = fake_image.FakeImageService()
image_id = '5c6eec33-bab4-4e7d-b2c9-88e2d0a5f6f2'
self.image_meta['id'] = image_id
self.image_meta['status'] = 'queued'
image_service.create(self.context, self.image_meta)
# creating volume testdata
self.volume_attrs['instance_uuid'] = None
db.volume_create(self.context, self.volume_attrs)
def fake_create(context, volume_id, **kwargs):
db.volume_update(context, volume_id, {'status': 'available'})
mock_create.side_effect = fake_create
# start test
self.volume.copy_volume_to_image(self.context,
self.volume_id,
self.image_meta)
volume = db.volume_get(self.context, self.volume_id)
self.assertEqual('available', volume['status'])
# return create image
image = image_service.show(self.context, image_id)
image_service.delete(self.context, image_id)
return image
def test_copy_volume_to_image_with_image_volume(self):
image = self._test_copy_volume_to_image_with_image_volume()
self.assertTrue(image['locations'][0]['url'].startswith('cinder://'))
def test_copy_volume_to_image_with_image_volume_qcow2(self):
self.image_meta['disk_format'] = 'qcow2'
image = self._test_copy_volume_to_image_with_image_volume()
self.assertIsNone(image.get('locations'))
@mock.patch.object(vol_manager.VolumeManager, 'delete_volume')
@mock.patch.object(fake_image._FakeImageService, 'add_location',
side_effect=exception.Invalid)
def test_copy_volume_to_image_with_image_volume_failure(
self, mock_add_location, mock_delete):
image = self._test_copy_volume_to_image_with_image_volume()
self.assertIsNone(image.get('locations'))
self.assertTrue(mock_delete.called)
class GetActiveByWindowTestCase(BaseVolumeTestCase):
def setUp(self):
super(GetActiveByWindowTestCase, self).setUp()
self.ctx = context.get_admin_context(read_deleted="yes")
self.db_attrs = [
{
'id': 1,
'host': 'devstack',
'project_id': 'p1',
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True, 'status': 'deleted',
'deleted_at': datetime.datetime(1, 2, 1, 1, 1, 1),
},
{
'id': 2,
'host': 'devstack',
'project_id': 'p1',
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True, 'status': 'deleted',
'deleted_at': datetime.datetime(1, 3, 10, 1, 1, 1),
},
{
'id': 3,
'host': 'devstack',
'project_id': 'p1',
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
'deleted': True, 'status': 'deleted',
'deleted_at': datetime.datetime(1, 5, 1, 1, 1, 1),
},
{
'id': 4,
'host': 'devstack',
'project_id': 'p1',
'created_at': datetime.datetime(1, 3, 10, 1, 1, 1),
},
{
'id': 5,
'host': 'devstack',
'project_id': 'p1',
'created_at': datetime.datetime(1, 5, 1, 1, 1, 1),
}
]
def test_volume_get_active_by_window(self):
# Find all all volumes valid within a timeframe window.
# Not in window
db.volume_create(self.ctx, self.db_attrs[0])
# In - deleted in window
db.volume_create(self.ctx, self.db_attrs[1])
# In - deleted after window
db.volume_create(self.ctx, self.db_attrs[2])
# In - created in window
db.volume_create(self.context, self.db_attrs[3])
# Not of window.
db.volume_create(self.context, self.db_attrs[4])
volumes = db.volume_get_active_by_window(
self.context,
datetime.datetime(1, 3, 1, 1, 1, 1),
datetime.datetime(1, 4, 1, 1, 1, 1),
project_id='p1')
self.assertEqual(3, len(volumes))
self.assertEqual(u'2', volumes[0].id)
self.assertEqual(u'3', volumes[1].id)
self.assertEqual(u'4', volumes[2].id)
def test_snapshot_get_active_by_window(self):
# Find all all snapshots valid within a timeframe window.
db.volume_create(self.context, {'id': 1})
for i in range(5):
self.db_attrs[i]['volume_id'] = 1
# Not in window
del self.db_attrs[0]['id']
snap1 = objects.Snapshot(self.ctx, **self.db_attrs[0])
snap1.create()
# In - deleted in window
del self.db_attrs[1]['id']
snap2 = objects.Snapshot(self.ctx, **self.db_attrs[1])
snap2.create()
# In - deleted after window
del self.db_attrs[2]['id']
snap3 = objects.Snapshot(self.ctx, **self.db_attrs[2])
snap3.create()
# In - created in window
del self.db_attrs[3]['id']
snap4 = objects.Snapshot(self.ctx, **self.db_attrs[3])
snap4.create()
# Not of window.
del self.db_attrs[4]['id']
snap5 = objects.Snapshot(self.ctx, **self.db_attrs[4])
snap5.create()
snapshots = objects.SnapshotList.get_active_by_window(
self.context,
datetime.datetime(1, 3, 1, 1, 1, 1),
datetime.datetime(1, 4, 1, 1, 1, 1)).objects
self.assertEqual(3, len(snapshots))
self.assertEqual(snap2.id, snapshots[0].id)
self.assertEqual(u'1', snapshots[0].volume_id)
self.assertEqual(snap3.id, snapshots[1].id)
self.assertEqual(u'1', snapshots[1].volume_id)
self.assertEqual(snap4.id, snapshots[2].id)
self.assertEqual(u'1', snapshots[2].volume_id)
class DriverTestCase(test.TestCase):
"""Base Test class for Drivers."""
driver_name = "cinder.volume.driver.FakeBaseDriver"
def setUp(self):
super(DriverTestCase, self).setUp()
vol_tmpdir = tempfile.mkdtemp()
self.flags(volume_driver=self.driver_name,
volumes_dir=vol_tmpdir)
self.volume = importutils.import_object(CONF.volume_manager)
self.context = context.get_admin_context()
self.output = ""
self.configuration = conf.Configuration(None)
self.stubs.Set(brick_lvm.LVM, '_vg_exists', lambda x: True)
def _fake_execute(_command, *_args, **_kwargs):
"""Fake _execute."""
return self.output, None
exec_patcher = mock.patch.object(self.volume.driver, '_execute',
_fake_execute)
exec_patcher.start()
self.addCleanup(exec_patcher.stop)
self.volume.driver.set_initialized()
self.addCleanup(self._cleanup)
def _cleanup(self):
try:
shutil.rmtree(CONF.volumes_dir)
except OSError:
pass
def _attach_volume(self):
"""Attach volumes to an instance."""
return []
def _detach_volume(self, volume_id_list):
"""Detach volumes from an instance."""
for volume_id in volume_id_list:
db.volume_detached(self.context, volume_id)
self.volume.delete_volume(self.context, volume_id)
class GenericVolumeDriverTestCase(DriverTestCase):
"""Test case for VolumeDriver."""
driver_name = "cinder.tests.unit.fake_driver.LoggingVolumeDriver"
@mock.patch.object(utils, 'temporary_chown')
@mock.patch('six.moves.builtins.open')
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_backup_volume_available(self, mock_volume_get,
mock_get_connector_properties,
mock_file_open,
mock_temporary_chown):
vol = tests_utils.create_volume(self.context)
self.context.user_id = 'fake'
self.context.project_id = 'fake'
backup = tests_utils.create_backup(self.context,
vol['id'])
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
properties = {}
attach_info = {'device': {'path': '/dev/null'}}
backup_service = mock.Mock()
self.volume.driver._attach_volume = mock.MagicMock()
self.volume.driver._detach_volume = mock.MagicMock()
self.volume.driver.terminate_connection = mock.MagicMock()
self.volume.driver.create_snapshot = mock.MagicMock()
self.volume.driver.delete_snapshot = mock.MagicMock()
mock_volume_get.return_value = vol
mock_get_connector_properties.return_value = properties
f = mock_file_open.return_value = open('/dev/null', 'rb')
backup_service.backup(backup_obj, f, None)
self.volume.driver._attach_volume.return_value = attach_info, vol
self.volume.driver.backup_volume(self.context, backup_obj,
backup_service)
mock_volume_get.assert_called_with(self.context, vol['id'])
@mock.patch.object(utils, 'temporary_chown')
@mock.patch('six.moves.builtins.open')
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_backup_volume_inuse_temp_volume(self, mock_volume_get,
mock_get_connector_properties,
mock_file_open,
mock_temporary_chown):
vol = tests_utils.create_volume(self.context,
status='backing-up',
previous_status='in-use')
temp_vol = tests_utils.create_volume(self.context)
self.context.user_id = 'fake'
self.context.project_id = 'fake'
backup = tests_utils.create_backup(self.context,
vol['id'])
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
properties = {}
attach_info = {'device': {'path': '/dev/null'}}
backup_service = mock.Mock()
self.volume.driver._attach_volume = mock.MagicMock()
self.volume.driver._detach_volume = mock.MagicMock()
self.volume.driver.terminate_connection = mock.MagicMock()
self.volume.driver._create_temp_cloned_volume = mock.MagicMock()
self.volume.driver._delete_temp_volume = mock.MagicMock()
mock_volume_get.return_value = vol
self.volume.driver._create_temp_cloned_volume.return_value = temp_vol
mock_get_connector_properties.return_value = properties
f = mock_file_open.return_value = open('/dev/null', 'rb')
backup_service.backup(backup_obj, f, None)
self.volume.driver._attach_volume.return_value = attach_info, vol
self.volume.driver.backup_volume(self.context, backup_obj,
backup_service)
mock_volume_get.assert_called_with(self.context, vol['id'])
self.volume.driver._create_temp_cloned_volume.assert_called_once_with(
self.context, vol)
self.volume.driver._delete_temp_volume.assert_called_once_with(
self.context, temp_vol)
@mock.patch.object(cinder.volume.driver.VolumeDriver,
'backup_use_temp_snapshot',
return_value=True)
@mock.patch.object(utils, 'temporary_chown')
@mock.patch('six.moves.builtins.open')
@mock.patch.object(os_brick.initiator.connector.LocalConnector,
'connect_volume')
@mock.patch.object(os_brick.initiator.connector.LocalConnector,
'check_valid_device',
return_value=True)
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties',
return_value={})
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_backup_volume_inuse_temp_snapshot(self, mock_volume_get,
mock_get_connector_properties,
mock_check_device,
mock_connect_volume,
mock_file_open,
mock_temporary_chown,
mock_temp_snapshot):
vol = tests_utils.create_volume(self.context,
status='backing-up',
previous_status='in-use')
self.context.user_id = 'fake'
self.context.project_id = 'fake'
backup = tests_utils.create_backup(self.context,
vol['id'])
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
attach_info = {'device': {'path': '/dev/null'},
'driver_volume_type': 'LOCAL',
'data': {}}
backup_service = mock.Mock()
self.volume.driver.terminate_connection_snapshot = mock.MagicMock()
self.volume.driver.initialize_connection_snapshot = mock.MagicMock()
self.volume.driver.create_snapshot = mock.MagicMock()
self.volume.driver.delete_snapshot = mock.MagicMock()
self.volume.driver.create_export_snapshot = mock.MagicMock()
self.volume.driver.remove_export_snapshot = mock.MagicMock()
mock_volume_get.return_value = vol
mock_connect_volume.return_value = {'type': 'local',
'path': '/dev/null'}
f = mock_file_open.return_value = open('/dev/null', 'rb')
self.volume.driver._connect_device
backup_service.backup(backup_obj, f, None)
self.volume.driver.initialize_connection_snapshot.return_value = (
attach_info)
self.volume.driver.create_export_snapshot.return_value = (
{'provider_location': '/dev/null',
'provider_auth': 'xxxxxxxx'})
self.volume.driver.backup_volume(self.context, backup_obj,
backup_service)
mock_volume_get.assert_called_with(self.context, vol['id'])
self.assertTrue(self.volume.driver.create_snapshot.called)
self.assertTrue(self.volume.driver.create_export_snapshot.called)
self.assertTrue(
self.volume.driver.initialize_connection_snapshot.called)
self.assertTrue(
self.volume.driver.terminate_connection_snapshot.called)
self.assertTrue(self.volume.driver.remove_export_snapshot.called)
self.assertTrue(self.volume.driver.delete_snapshot.called)
@mock.patch.object(utils, 'temporary_chown')
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch('six.moves.builtins.open')
def test_restore_backup(self,
mock_open,
mock_get_connector_properties,
mock_temporary_chown):
dev_null = '/dev/null'
vol = tests_utils.create_volume(self.context)
backup = {'volume_id': vol['id'], 'id': 'backup-for-%s' % vol['id']}
properties = {}
attach_info = {'device': {'path': dev_null}}
root_helper = 'sudo cinder-rootwrap /etc/cinder/rootwrap.conf'
volume_file = mock.MagicMock()
mock_open.return_value.__enter__.return_value = volume_file
mock_get_connector_properties.return_value = properties
self.volume.driver._attach_volume = mock.MagicMock()
self.volume.driver._attach_volume.return_value = attach_info, vol
self.volume.driver._detach_volume = mock.MagicMock()
self.volume.driver.terminate_connection = mock.MagicMock()
self.volume.driver.secure_file_operations_enabled = mock.MagicMock()
self.volume.driver.secure_file_operations_enabled.side_effect = (False,
True)
backup_service = mock.MagicMock()
for i in (1, 2):
self.volume.driver.restore_backup(self.context, backup, vol,
backup_service)
mock_get_connector_properties.assert_called_with(root_helper,
CONF.my_ip,
False, False)
self.volume.driver._attach_volume.assert_called_with(
self.context, vol, properties)
self.assertEqual(i, self.volume.driver._attach_volume.call_count)
self.volume.driver._detach_volume.assert_called_with(
self.context, attach_info, vol, properties)
self.assertEqual(i, self.volume.driver._detach_volume.call_count)
self.volume.driver.secure_file_operations_enabled.\
assert_called_with()
self.assertEqual(
i,
self.volume.driver.secure_file_operations_enabled.call_count
)
mock_temporary_chown.assert_called_once_with(dev_null)
mock_open.assert_called_with(dev_null, 'wb')
self.assertEqual(i, mock_open.call_count)
backup_service.restore.assert_called_with(backup, vol['id'],
volume_file)
self.assertEqual(i, backup_service.restore.call_count)
def test_enable_replication_invalid_state(self):
volume_api = cinder.volume.api.API()
ctxt = context.get_admin_context()
volume = tests_utils.create_volume(ctxt,
size=1,
host=CONF.host,
replication_status='enabled')
self.assertRaises(exception.InvalidVolume,
volume_api.enable_replication,
ctxt, volume)
def test_enable_replication_invalid_type(self):
volume_api = cinder.volume.api.API()
ctxt = context.get_admin_context()
volume = tests_utils.create_volume(self.context,
size=1,
host=CONF.host,
replication_status='disabled')
volume['volume_type_id'] = 'dab02f01-b50f-4ed6-8d42-2b5b9680996e'
fake_specs = {}
with mock.patch.object(volume_types,
'get_volume_type_extra_specs',
return_value = fake_specs):
self.assertRaises(exception.InvalidVolume,
volume_api.enable_replication,
ctxt,
volume)
def test_enable_replication(self):
volume_api = cinder.volume.api.API()
ctxt = context.get_admin_context()
volume = tests_utils.create_volume(self.context,
size=1,
host=CONF.host,
replication_status='disabled')
volume['volume_type_id'] = 'dab02f01-b50f-4ed6-8d42-2b5b9680996e'
fake_specs = {'replication_enabled': '<is> True'}
with mock.patch.object(volume_rpcapi.VolumeAPI,
'enable_replication') as mock_enable_rep,\
mock.patch.object(volume_types,
'get_volume_type_extra_specs',
return_value = fake_specs):
volume_api.enable_replication(ctxt, volume)
self.assertTrue(mock_enable_rep.called)
def test_enable_replication_driver_initialized(self):
volume = tests_utils.create_volume(self.context,
size=1,
host=CONF.host,
replication_status='enabling')
# set initialized to False
self.volume.driver._initialized = False
# start test
self.assertRaises(exception.DriverNotInitialized,
self.volume.enable_replication,
self.context,
volume)
def test_disable_replication_invalid_state(self):
volume_api = cinder.volume.api.API()
ctxt = context.get_admin_context()
volume = tests_utils.create_volume(ctxt,
size=1,
host=CONF.host,
replication_status='invalid-state')
self.assertRaises(exception.InvalidVolume,
volume_api.disable_replication,
ctxt, volume)
def test_disable_replication(self):
volume_api = cinder.volume.api.API()
ctxt = context.get_admin_context()
volume = tests_utils.create_volume(self.context,
size=1,
host=CONF.host,
replication_status='disabled')
volume['volume_type_id'] = 'dab02f01-b50f-4ed6-8d42-2b5b9680996e'
fake_specs = {'replication_enabled': '<is> True'}
with mock.patch.object(volume_rpcapi.VolumeAPI,
'disable_replication') as mock_disable_rep,\
mock.patch.object(volume_types,
'get_volume_type_extra_specs',
return_value = fake_specs):
volume_api.disable_replication(ctxt, volume)
self.assertTrue(mock_disable_rep.called)
volume['replication_status'] = 'enabled'
volume_api.disable_replication(ctxt, volume)
self.assertTrue(mock_disable_rep.called)
def test_disable_replication_driver_initialized(self):
volume = tests_utils.create_volume(self.context,
size=1,
host=CONF.host,
replication_status='disabling')
# set initialized to False
self.volume.driver._initialized = False
# start test
self.assertRaises(exception.DriverNotInitialized,
self.volume.disable_replication,
self.context,
volume)
@mock.patch.object(utils, 'brick_get_connector_properties')
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_attach_volume')
@mock.patch.object(cinder.volume.driver.VolumeDriver, '_detach_volume')
@mock.patch.object(volutils, 'copy_volume')
@mock.patch.object(volume_rpcapi.VolumeAPI, 'get_capabilities')
def test_copy_volume_data(self,
mock_get_capabilities,
mock_copy,
mock_detach,
mock_attach,
mock_get_connector):
src_vol = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
dest_vol = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
mock_get_connector.return_value = {}
self.volume.driver._throttle = mock.MagicMock()
attach_expected = [
mock.call(self.context, dest_vol, {}, remote=False),
mock.call(self.context, src_vol, {}, remote=False)]
detach_expected = [
mock.call(self.context, {'device': {'path': 'bar'}},
dest_vol, {}, force=False, remote=False),
mock.call(self.context, {'device': {'path': 'foo'}},
src_vol, {}, force=False, remote=False)]
attach_volume_returns = [
({'device': {'path': 'bar'}}, dest_vol),
({'device': {'path': 'foo'}}, src_vol),
]
# Test case for sparse_copy_volume = False
mock_attach.side_effect = attach_volume_returns
mock_get_capabilities.return_value = {}
self.volume.driver.copy_volume_data(self.context,
src_vol,
dest_vol)
self.assertEqual(attach_expected, mock_attach.mock_calls)
mock_copy.assert_called_with(
'foo', 'bar', 1024, '1M',
throttle=self.volume.driver._throttle,
sparse=False)
self.assertEqual(detach_expected, mock_detach.mock_calls)
# Test case for sparse_copy_volume = True
mock_attach.reset_mock()
mock_detach.reset_mock()
mock_attach.side_effect = attach_volume_returns
mock_get_capabilities.return_value = {'sparse_copy_volume': True}
self.volume.driver.copy_volume_data(self.context,
src_vol,
dest_vol)
self.assertEqual(attach_expected, mock_attach.mock_calls)
mock_copy.assert_called_with(
'foo', 'bar', 1024, '1M',
throttle=self.volume.driver._throttle,
sparse=True)
self.assertEqual(detach_expected, mock_detach.mock_calls)
# cleanup resource
db.volume_destroy(self.context, src_vol['id'])
db.volume_destroy(self.context, dest_vol['id'])
@mock.patch.object(utils, 'brick_get_connector_properties')
@mock.patch.object(cinder.volume.manager.VolumeManager, '_attach_volume')
@mock.patch.object(cinder.volume.manager.VolumeManager, '_detach_volume')
@mock.patch.object(volutils, 'copy_volume')
@mock.patch.object(volume_rpcapi.VolumeAPI, 'get_capabilities')
def test_copy_volume_data_mgr(self,
mock_get_capabilities,
mock_copy,
mock_detach,
mock_attach,
mock_get_connector):
"""Test function of _copy_volume_data."""
src_vol = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
dest_vol = tests_utils.create_volume(self.context, size=1,
host=CONF.host)
mock_get_connector.return_value = {}
self.volume.driver._throttle = mock.MagicMock()
attach_expected = [
mock.call(self.context, dest_vol, {}, remote=False),
mock.call(self.context, src_vol, {}, remote=False)]
detach_expected = [
mock.call(self.context, {'device': {'path': 'bar'}},
dest_vol, {}, force=False, remote=False),
mock.call(self.context, {'device': {'path': 'foo'}},
src_vol, {}, force=False, remote=False)]
attach_volume_returns = [
{'device': {'path': 'bar'}},
{'device': {'path': 'foo'}}
]
# Test case for sparse_copy_volume = False
mock_attach.side_effect = attach_volume_returns
mock_get_capabilities.return_value = {}
self.volume._copy_volume_data(self.context,
src_vol,
dest_vol)
self.assertEqual(attach_expected, mock_attach.mock_calls)
mock_copy.assert_called_with('foo', 'bar', 1024, '1M', sparse=False)
self.assertEqual(detach_expected, mock_detach.mock_calls)
# Test case for sparse_copy_volume = True
mock_attach.reset_mock()
mock_detach.reset_mock()
mock_attach.side_effect = attach_volume_returns
mock_get_capabilities.return_value = {'sparse_copy_volume': True}
self.volume._copy_volume_data(self.context,
src_vol,
dest_vol)
self.assertEqual(attach_expected, mock_attach.mock_calls)
mock_copy.assert_called_with('foo', 'bar', 1024, '1M', sparse=True)
self.assertEqual(detach_expected, mock_detach.mock_calls)
# cleanup resource
db.volume_destroy(self.context, src_vol['id'])
db.volume_destroy(self.context, dest_vol['id'])
class LVMISCSIVolumeDriverTestCase(DriverTestCase):
"""Test case for VolumeDriver"""
driver_name = "cinder.volume.drivers.lvm.LVMISCSIDriver"
def test_delete_busy_volume(self):
"""Test deleting a busy volume."""
self.stubs.Set(self.volume.driver, '_volume_not_present',
lambda x: False)
self.stubs.Set(self.volume.driver, '_delete_volume',
lambda x: False)
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
self.stubs.Set(self.volume.driver.vg, 'lv_has_snapshot',
lambda x: True)
self.assertRaises(exception.VolumeIsBusy,
self.volume.driver.delete_volume,
{'name': 'test1', 'size': 1024})
self.stubs.Set(self.volume.driver.vg, 'lv_has_snapshot',
lambda x: False)
self.output = 'x'
self.volume.driver.delete_volume(
{'name': 'test1',
'size': 1024,
'id': '478e14bc-a6a9-11e4-89d3-123b93f75cba'})
def test_lvm_migrate_volume_no_loc_info(self):
host = {'capabilities': {}}
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
moved, model_update = self.volume.driver.migrate_volume(self.context,
vol, host)
self.assertFalse(moved)
self.assertIsNone(model_update)
def test_lvm_migrate_volume_bad_loc_info(self):
capabilities = {'location_info': 'foo'}
host = {'capabilities': capabilities}
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
moved, model_update = self.volume.driver.migrate_volume(self.context,
vol, host)
self.assertFalse(moved)
self.assertIsNone(model_update)
def test_lvm_migrate_volume_diff_driver(self):
capabilities = {'location_info': 'FooDriver:foo:bar:default:0'}
host = {'capabilities': capabilities}
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
moved, model_update = self.volume.driver.migrate_volume(self.context,
vol, host)
self.assertFalse(moved)
self.assertIsNone(model_update)
def test_lvm_migrate_volume_diff_host(self):
capabilities = {'location_info': 'LVMVolumeDriver:foo:bar:default:0'}
host = {'capabilities': capabilities}
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
moved, model_update = self.volume.driver.migrate_volume(self.context,
vol, host)
self.assertFalse(moved)
self.assertIsNone(model_update)
def test_lvm_migrate_volume_in_use(self):
hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:bar' % hostname}
host = {'capabilities': capabilities}
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'in-use'}
moved, model_update = self.volume.driver.migrate_volume(self.context,
vol, host)
self.assertFalse(moved)
self.assertIsNone(model_update)
@mock.patch.object(volutils, 'get_all_volume_groups',
return_value=[{'name': 'cinder-volumes'}])
def test_lvm_migrate_volume_same_volume_group(self, vgs):
hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
'cinder-volumes:default:0' % hostname}
host = {'capabilities': capabilities}
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.driver.migrate_volume, self.context,
vol, host)
@mock.patch.object(lvm.LVMVolumeDriver, '_create_volume')
@mock.patch.object(brick_lvm.LVM, 'get_all_physical_volumes')
@mock.patch.object(brick_lvm.LVM, 'delete')
@mock.patch.object(volutils, 'copy_volume',
side_effect=processutils.ProcessExecutionError)
@mock.patch.object(volutils, 'get_all_volume_groups',
return_value=[{'name': 'cinder-volumes'}])
def test_lvm_migrate_volume_volume_copy_error(self, vgs, copy_volume,
mock_delete, mock_pvs,
mock_create):
hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
'cinder-volumes:default:0' % hostname}
host = {'capabilities': capabilities}
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes-old',
False, None, 'default')
self.assertRaises(processutils.ProcessExecutionError,
self.volume.driver.migrate_volume, self.context,
vol, host)
mock_delete.assert_called_once_with(vol)
def test_lvm_volume_group_missing(self):
hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
'cinder-volumes-3:default:0' % hostname}
host = {'capabilities': capabilities}
vol = {'name': 'test', 'id': 1, 'size': 1, 'status': 'available'}
def get_all_volume_groups():
return [{'name': 'cinder-volumes-2'}]
self.stubs.Set(volutils, 'get_all_volume_groups',
get_all_volume_groups)
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
moved, model_update = self.volume.driver.migrate_volume(self.context,
vol, host)
self.assertFalse(moved)
self.assertIsNone(model_update)
def test_lvm_migrate_volume_proceed(self):
hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
'cinder-volumes-2:default:0' % hostname}
host = {'capabilities': capabilities}
vol = {'name': 'testvol', 'id': 1, 'size': 2, 'status': 'available'}
def fake_execute(*args, **kwargs):
pass
def get_all_volume_groups():
# NOTE(flaper87) Return just the destination
# host to test the check of dest VG existence.
return [{'name': 'cinder-volumes-2'}]
def _fake_get_all_physical_volumes(obj, root_helper, vg_name):
return [{}]
with mock.patch.object(brick_lvm.LVM, 'get_all_physical_volumes',
return_value = [{}]), \
mock.patch.object(self.volume.driver, '_execute') \
as mock_execute, \
mock.patch.object(volutils, 'copy_volume') as mock_copy, \
mock.patch.object(volutils, 'get_all_volume_groups',
side_effect = get_all_volume_groups), \
mock.patch.object(self.volume.driver, '_delete_volume'):
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
moved, model_update = \
self.volume.driver.migrate_volume(self.context, vol, host)
self.assertTrue(moved)
self.assertIsNone(model_update)
mock_copy.assert_called_once_with(
'/dev/mapper/cinder--volumes-testvol',
'/dev/mapper/cinder--volumes--2-testvol',
2048,
'1M',
execute=mock_execute,
sparse=False)
def test_lvm_migrate_volume_proceed_with_thin(self):
hostname = socket.gethostname()
capabilities = {'location_info': 'LVMVolumeDriver:%s:'
'cinder-volumes-2:default:0' % hostname}
host = {'capabilities': capabilities}
vol = {'name': 'testvol', 'id': 1, 'size': 2, 'status': 'available'}
def fake_execute(*args, **kwargs):
pass
def get_all_volume_groups():
# NOTE(flaper87) Return just the destination
# host to test the check of dest VG existence.
return [{'name': 'cinder-volumes-2'}]
def _fake_get_all_physical_volumes(obj, root_helper, vg_name):
return [{}]
self.configuration.lvm_type = 'thin'
lvm_driver = lvm.LVMVolumeDriver(configuration=self.configuration,
db=db)
with mock.patch.object(brick_lvm.LVM, 'get_all_physical_volumes',
return_value = [{}]), \
mock.patch.object(lvm_driver, '_execute') \
as mock_execute, \
mock.patch.object(volutils, 'copy_volume') as mock_copy, \
mock.patch.object(volutils, 'get_all_volume_groups',
side_effect = get_all_volume_groups), \
mock.patch.object(lvm_driver, '_delete_volume'):
lvm_driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
lvm_driver._sparse_copy_volume = True
moved, model_update = \
lvm_driver.migrate_volume(self.context, vol, host)
self.assertTrue(moved)
self.assertIsNone(model_update)
mock_copy.assert_called_once_with(
'/dev/mapper/cinder--volumes-testvol',
'/dev/mapper/cinder--volumes--2-testvol',
2048,
'1M',
execute=mock_execute,
sparse=True)
@staticmethod
def _get_manage_existing_lvs(name):
"""Helper method used by the manage_existing tests below."""
lvs = [{'name': 'fake_lv', 'size': '1.75'},
{'name': 'fake_lv_bad_size', 'size': 'Not a float'}]
for lv in lvs:
if lv['name'] == name:
return lv
def _setup_stubs_for_manage_existing(self):
"""Helper to set up common stubs for the manage_existing tests."""
self.volume.driver.vg = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
self.stubs.Set(self.volume.driver.vg, 'get_volume',
self._get_manage_existing_lvs)
@mock.patch.object(db.sqlalchemy.api, 'volume_get',
side_effect=exception.VolumeNotFound(
volume_id='d8cd1feb-2dcc-404d-9b15-b86fe3bec0a1'))
def test_lvm_manage_existing_not_found(self, mock_vol_get):
self._setup_stubs_for_manage_existing()
vol_name = 'volume-d8cd1feb-2dcc-404d-9b15-b86fe3bec0a1'
ref = {'source-name': 'fake_lv'}
vol = {'name': vol_name, 'id': 1, 'size': 0}
with mock.patch.object(self.volume.driver.vg, 'rename_volume'):
model_update = self.volume.driver.manage_existing(vol, ref)
self.assertIsNone(model_update)
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_lvm_manage_existing_already_managed(self, mock_conf):
self._setup_stubs_for_manage_existing()
mock_conf.volume_name_template = 'volume-%s'
vol_name = 'volume-d8cd1feb-2dcc-404d-9b15-b86fe3bec0a1'
ref = {'source-name': vol_name}
vol = {'name': 'test', 'id': 1, 'size': 0}
with mock.patch.object(self.volume.driver.vg, 'rename_volume'):
self.assertRaises(exception.ManageExistingAlreadyManaged,
self.volume.driver.manage_existing,
vol, ref)
def test_lvm_manage_existing(self):
"""Good pass on managing an LVM volume.
This test case ensures that, when a logical volume with the
specified name exists, and the size is as expected, no error is
returned from driver.manage_existing, and that the rename_volume
function is called in the Brick LVM code with the correct arguments.
"""
self._setup_stubs_for_manage_existing()
ref = {'source-name': 'fake_lv'}
vol = {'name': 'test', 'id': 1, 'size': 0}
def _rename_volume(old_name, new_name):
self.assertEqual(ref['source-name'], old_name)
self.assertEqual(vol['name'], new_name)
self.stubs.Set(self.volume.driver.vg, 'rename_volume',
_rename_volume)
size = self.volume.driver.manage_existing_get_size(vol, ref)
self.assertEqual(2, size)
model_update = self.volume.driver.manage_existing(vol, ref)
self.assertIsNone(model_update)
def test_lvm_manage_existing_bad_size(self):
"""Make sure correct exception on bad size returned from LVM.
This test case ensures that the correct exception is raised when
the information returned for the existing LVs is not in the format
that the manage_existing code expects.
"""
self._setup_stubs_for_manage_existing()
ref = {'source-name': 'fake_lv_bad_size'}
vol = {'name': 'test', 'id': 1, 'size': 2}
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.driver.manage_existing_get_size,
vol, ref)
def test_lvm_manage_existing_bad_ref(self):
"""Error case where specified LV doesn't exist.
This test case ensures that the correct exception is raised when
the caller attempts to manage a volume that does not exist.
"""
self._setup_stubs_for_manage_existing()
ref = {'source-name': 'fake_nonexistent_lv'}
vol = {'name': 'test', 'id': 1, 'size': 0, 'status': 'available'}
self.assertRaises(exception.ManageExistingInvalidReference,
self.volume.driver.manage_existing_get_size,
vol, ref)
def test_lvm_manage_existing_snapshot(self):
"""Good pass on managing an LVM snapshot.
This test case ensures that, when a logical volume's snapshot with the
specified name exists, and the size is as expected, no error is
returned from driver.manage_existing_snapshot, and that the
rename_volume function is called in the Brick LVM code with the correct
arguments.
"""
self._setup_stubs_for_manage_existing()
ref = {'source-name': 'fake_lv'}
snp = {'name': 'test', 'id': 1, 'size': 0}
def _rename_volume(old_name, new_name):
self.assertEqual(ref['source-name'], old_name)
self.assertEqual(snp['name'], new_name)
with mock.patch.object(self.volume.driver.vg, 'rename_volume') as \
mock_rename_volume:
mock_rename_volume.return_value = _rename_volume
size = self.volume.driver.manage_existing_snapshot_get_size(snp,
ref)
self.assertEqual(2, size)
model_update = self.volume.driver.manage_existing_snapshot(snp,
ref)
self.assertIsNone(model_update)
def test_lvm_manage_existing_snapshot_bad_ref(self):
"""Error case where specified LV snapshot doesn't exist.
This test case ensures that the correct exception is raised when
the caller attempts to manage a snapshot that does not exist.
"""
self._setup_stubs_for_manage_existing()
ref = {'source-name': 'fake_nonexistent_lv'}
snp = {'name': 'test', 'id': 1, 'size': 0, 'status': 'available'}
self.assertRaises(exception.ManageExistingInvalidReference,
self.volume.driver.manage_existing_snapshot_get_size,
snp, ref)
def test_lvm_manage_existing_snapshot_bad_size(self):
"""Make sure correct exception on bad size returned from LVM.
This test case ensures that the correct exception is raised when
the information returned for the existing LVs is not in the format
that the manage_existing_snapshot code expects.
"""
self._setup_stubs_for_manage_existing()
ref = {'source-name': 'fake_lv_bad_size'}
snp = {'name': 'test', 'id': 1, 'size': 2}
self.assertRaises(exception.VolumeBackendAPIException,
self.volume.driver.manage_existing_snapshot_get_size,
snp, ref)
def test_lvm_unmanage(self):
volume = tests_utils.create_volume(self.context, status='available',
size=1, host=CONF.host)
ret = self.volume.driver.unmanage(volume)
self.assertEqual(ret, None)
class LVMVolumeDriverTestCase(DriverTestCase):
"""Test case for VolumeDriver"""
driver_name = "cinder.volume.drivers.lvm.LVMVolumeDriver"
FAKE_VOLUME = {'name': 'test1',
'id': 'test1'}
@mock.patch.object(fake_driver.FakeISCSIDriver, 'create_export')
def test_delete_volume_invalid_parameter(self, _mock_create_export):
self.configuration.volume_clear = 'zero'
self.configuration.volume_clear_size = 0
lvm_driver = lvm.LVMVolumeDriver(configuration=self.configuration,
db=db)
self.mox.StubOutWithMock(os.path, 'exists')
os.path.exists(mox.IgnoreArg()).AndReturn(True)
self.mox.ReplayAll()
# Test volume without 'size' field and 'volume_size' field
self.assertRaises(exception.InvalidParameterValue,
lvm_driver._delete_volume,
self.FAKE_VOLUME)
@mock.patch.object(fake_driver.FakeISCSIDriver, 'create_export')
def test_delete_volume_bad_path(self, _mock_create_export):
self.configuration.volume_clear = 'zero'
self.configuration.volume_clear_size = 0
self.configuration.volume_type = 'default'
volume = dict(self.FAKE_VOLUME, size=1)
lvm_driver = lvm.LVMVolumeDriver(configuration=self.configuration,
db=db)
self.mox.StubOutWithMock(os.path, 'exists')
os.path.exists(mox.IgnoreArg()).AndReturn(False)
self.mox.ReplayAll()
self.assertRaises(exception.VolumeBackendAPIException,
lvm_driver._delete_volume, volume)
@mock.patch.object(fake_driver.FakeISCSIDriver, 'create_export')
def test_delete_volume_thinlvm_snap(self, _mock_create_export):
self.configuration.volume_clear = 'zero'
self.configuration.volume_clear_size = 0
self.configuration.lvm_type = 'thin'
self.configuration.iscsi_helper = 'tgtadm'
lvm_driver = lvm.LVMISCSIDriver(configuration=self.configuration,
vg_obj=mox.MockAnything(),
db=db)
# Ensures that copy_volume is not called for ThinLVM
self.mox.StubOutWithMock(volutils, 'copy_volume')
self.mox.StubOutWithMock(volutils, 'clear_volume')
self.mox.StubOutWithMock(lvm_driver, '_execute')
self.mox.ReplayAll()
uuid = '00000000-0000-0000-0000-c3aa7ee01536'
fake_snapshot = {'name': 'volume-' + uuid,
'id': uuid,
'size': 123}
lvm_driver._delete_volume(fake_snapshot, is_snapshot=True)
def test_check_for_setup_error(self):
def get_all_volume_groups(vg):
return [{'name': 'cinder-volumes'}]
self.stubs.Set(volutils, 'get_all_volume_groups',
get_all_volume_groups)
vg_obj = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
configuration = conf.Configuration(fake_opt, 'fake_group')
lvm_driver = lvm.LVMVolumeDriver(configuration=configuration,
vg_obj=vg_obj, db=db)
lvm_driver.delete_snapshot = mock.Mock()
self.stubs.Set(volutils, 'get_all_volume_groups',
get_all_volume_groups)
volume = tests_utils.create_volume(self.context,
host=socket.gethostname())
volume_id = volume['id']
backup = {}
backup['volume_id'] = volume_id
backup['user_id'] = 'fake'
backup['project_id'] = 'fake'
backup['host'] = socket.gethostname()
backup['availability_zone'] = '1'
backup['display_name'] = 'test_check_for_setup_error'
backup['display_description'] = 'test_check_for_setup_error'
backup['container'] = 'fake'
backup['status'] = 'creating'
backup['fail_reason'] = ''
backup['service'] = 'fake'
backup['parent_id'] = None
backup['size'] = 5 * 1024 * 1024
backup['object_count'] = 22
db.backup_create(self.context, backup)
lvm_driver.check_for_setup_error()
@mock.patch.object(utils, 'temporary_chown')
@mock.patch('six.moves.builtins.open')
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_backup_volume(self, mock_volume_get,
mock_get_connector_properties,
mock_file_open,
mock_temporary_chown):
vol = tests_utils.create_volume(self.context)
self.context.user_id = 'fake'
self.context.project_id = 'fake'
backup = tests_utils.create_backup(self.context,
vol['id'])
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
properties = {}
attach_info = {'device': {'path': '/dev/null'}}
backup_service = mock.Mock()
self.volume.driver._detach_volume = mock.MagicMock()
self.volume.driver._attach_volume = mock.MagicMock()
self.volume.driver.terminate_connection = mock.MagicMock()
mock_volume_get.return_value = vol
mock_get_connector_properties.return_value = properties
f = mock_file_open.return_value = open('/dev/null', 'rb')
backup_service.backup(backup_obj, f, None)
self.volume.driver._attach_volume.return_value = attach_info
self.volume.driver.backup_volume(self.context, backup_obj,
backup_service)
mock_volume_get.assert_called_with(self.context, vol['id'])
def test_update_migrated_volume(self):
fake_volume_id = 'vol1'
fake_new_volume_id = 'vol2'
fake_provider = 'fake_provider'
original_volume_name = CONF.volume_name_template % fake_volume_id
current_name = CONF.volume_name_template % fake_new_volume_id
fake_volume = tests_utils.create_volume(self.context)
fake_volume['id'] = fake_volume_id
fake_new_volume = tests_utils.create_volume(self.context)
fake_new_volume['id'] = fake_new_volume_id
fake_new_volume['provider_location'] = fake_provider
fake_vg = fake_lvm.FakeBrickLVM('cinder-volumes', False,
None, 'default')
with mock.patch.object(self.volume.driver, 'vg') as vg:
vg.return_value = fake_vg
vg.rename_volume.return_value = None
update = self.volume.driver.update_migrated_volume(self.context,
fake_volume,
fake_new_volume,
'available')
vg.rename_volume.assert_called_once_with(current_name,
original_volume_name)
self.assertEqual({'_name_id': None,
'provider_location': None}, update)
vg.rename_volume.reset_mock()
vg.rename_volume.side_effect = processutils.ProcessExecutionError
update = self.volume.driver.update_migrated_volume(self.context,
fake_volume,
fake_new_volume,
'available')
vg.rename_volume.assert_called_once_with(current_name,
original_volume_name)
self.assertEqual({'_name_id': fake_new_volume_id,
'provider_location': fake_provider},
update)
@mock.patch.object(utils, 'temporary_chown')
@mock.patch('six.moves.builtins.open')
@mock.patch.object(os_brick.initiator.connector,
'get_connector_properties')
@mock.patch.object(db.sqlalchemy.api, 'volume_get')
def test_backup_volume_inuse(self, mock_volume_get,
mock_get_connector_properties,
mock_file_open,
mock_temporary_chown):
vol = tests_utils.create_volume(self.context,
status='backing-up',
previous_status='in-use')
self.context.user_id = 'fake'
self.context.project_id = 'fake'
mock_volume_get.return_value = vol
temp_snapshot = tests_utils.create_snapshot(self.context, vol['id'])
backup = tests_utils.create_backup(self.context,
vol['id'])
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
properties = {}
attach_info = {'device': {'path': '/dev/null'}}
backup_service = mock.Mock()
self.volume.driver._detach_volume = mock.MagicMock()
self.volume.driver._attach_volume = mock.MagicMock()
self.volume.driver.terminate_connection = mock.MagicMock()
self.volume.driver._create_temp_snapshot = mock.MagicMock()
self.volume.driver._delete_temp_snapshot = mock.MagicMock()
mock_get_connector_properties.return_value = properties
f = mock_file_open.return_value = open('/dev/null', 'rb')
backup_service.backup(backup_obj, f, None)
self.volume.driver._attach_volume.return_value = attach_info
self.volume.driver._create_temp_snapshot.return_value = temp_snapshot
self.volume.driver.backup_volume(self.context, backup_obj,
backup_service)
mock_volume_get.assert_called_with(self.context, vol['id'])
self.volume.driver._create_temp_snapshot.assert_called_once_with(
self.context, vol)
self.volume.driver._delete_temp_snapshot.assert_called_once_with(
self.context, temp_snapshot)
def test_create_volume_from_snapshot_none_sparse(self):
with mock.patch.object(self.volume.driver, 'vg'), \
mock.patch.object(self.volume.driver, '_create_volume'), \
mock.patch.object(volutils, 'copy_volume') as mock_copy:
# Test case for thick LVM
src_volume = tests_utils.create_volume(self.context)
snapshot_ref = tests_utils.create_snapshot(self.context,
src_volume['id'])
dst_volume = tests_utils.create_volume(self.context)
self.volume.driver.create_volume_from_snapshot(dst_volume,
snapshot_ref)
volume_path = self.volume.driver.local_path(dst_volume)
snapshot_path = self.volume.driver.local_path(snapshot_ref)
volume_size = 1024
block_size = '1M'
mock_copy.assert_called_with(snapshot_path,
volume_path,
volume_size,
block_size,
execute=self.volume.driver._execute,
sparse=False)
def test_create_volume_from_snapshot_sparse(self):
self.configuration.lvm_type = 'thin'
lvm_driver = lvm.LVMVolumeDriver(configuration=self.configuration,
db=db)
with mock.patch.object(lvm_driver, 'vg'), \
mock.patch.object(lvm_driver, '_create_volume'), \
mock.patch.object(volutils, 'copy_volume') as mock_copy:
# Test case for thin LVM
lvm_driver._sparse_copy_volume = True
src_volume = tests_utils.create_volume(self.context)
snapshot_ref = tests_utils.create_snapshot(self.context,
src_volume['id'])
dst_volume = tests_utils.create_volume(self.context)
lvm_driver.create_volume_from_snapshot(dst_volume,
snapshot_ref)
volume_path = lvm_driver.local_path(dst_volume)
snapshot_path = lvm_driver.local_path(snapshot_ref)
volume_size = 1024
block_size = '1M'
mock_copy.assert_called_with(snapshot_path,
volume_path,
volume_size,
block_size,
execute=lvm_driver._execute,
sparse=True)
@mock.patch.object(cinder.volume.utils, 'get_all_volume_groups',
return_value=[{'name': 'cinder-volumes'}])
@mock.patch('cinder.brick.local_dev.lvm.LVM.update_volume_group_info')
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_all_physical_volumes')
@mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning',
return_value=True)
def test_lvm_type_auto_thin_pool_exists(self, *_unused_mocks):
configuration = conf.Configuration(fake_opt, 'fake_group')
configuration.lvm_type = 'auto'
vg_obj = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
lvm_driver = lvm.LVMVolumeDriver(configuration=configuration,
vg_obj=vg_obj)
lvm_driver.check_for_setup_error()
self.assertEqual('thin', lvm_driver.configuration.lvm_type)
@mock.patch.object(cinder.volume.utils, 'get_all_volume_groups',
return_value=[{'name': 'cinder-volumes'}])
@mock.patch.object(cinder.brick.local_dev.lvm.LVM, 'get_volumes',
return_value=[])
@mock.patch('cinder.brick.local_dev.lvm.LVM.update_volume_group_info')
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_all_physical_volumes')
@mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning',
return_value=True)
def test_lvm_type_auto_no_lvs(self, *_unused_mocks):
configuration = conf.Configuration(fake_opt, 'fake_group')
configuration.lvm_type = 'auto'
vg_obj = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
lvm_driver = lvm.LVMVolumeDriver(configuration=configuration,
vg_obj=vg_obj)
lvm_driver.check_for_setup_error()
self.assertEqual('thin', lvm_driver.configuration.lvm_type)
@mock.patch.object(cinder.volume.utils, 'get_all_volume_groups',
return_value=[{'name': 'cinder-volumes'}])
@mock.patch('cinder.brick.local_dev.lvm.LVM.update_volume_group_info')
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_all_physical_volumes')
@mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning',
return_value=False)
def test_lvm_type_auto_no_thin_support(self, *_unused_mocks):
configuration = conf.Configuration(fake_opt, 'fake_group')
configuration.lvm_type = 'auto'
lvm_driver = lvm.LVMVolumeDriver(configuration=configuration)
lvm_driver.check_for_setup_error()
self.assertEqual('default', lvm_driver.configuration.lvm_type)
@mock.patch.object(cinder.volume.utils, 'get_all_volume_groups',
return_value=[{'name': 'cinder-volumes'}])
@mock.patch('cinder.brick.local_dev.lvm.LVM.update_volume_group_info')
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_all_physical_volumes')
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_volume')
@mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning',
return_value=False)
def test_lvm_type_auto_no_thin_pool(self, *_unused_mocks):
configuration = conf.Configuration(fake_opt, 'fake_group')
configuration.lvm_type = 'auto'
lvm_driver = lvm.LVMVolumeDriver(configuration=configuration)
lvm_driver.check_for_setup_error()
self.assertEqual('default', lvm_driver.configuration.lvm_type)
@mock.patch.object(lvm.LVMISCSIDriver, 'extend_volume')
def test_create_cloned_volume_by_thin_snapshot(self, mock_extend):
self.configuration.lvm_type = 'thin'
fake_vg = mock.Mock(fake_lvm.FakeBrickLVM('cinder-volumes', False,
None, 'default'))
lvm_driver = lvm.LVMISCSIDriver(configuration=self.configuration,
vg_obj=fake_vg,
db=db)
fake_volume = tests_utils.create_volume(self.context, size=1)
fake_new_volume = tests_utils.create_volume(self.context, size=2)
lvm_driver.create_cloned_volume(fake_new_volume, fake_volume)
fake_vg.create_lv_snapshot.assert_called_once_with(
fake_new_volume['name'], fake_volume['name'], 'thin')
mock_extend.assert_called_once_with(fake_new_volume, 2)
fake_vg.activate_lv.assert_called_once_with(
fake_new_volume['name'], is_snapshot=True, permanent=True)
class ISCSITestCase(DriverTestCase):
"""Test Case for ISCSIDriver"""
driver_name = "cinder.volume.drivers.lvm.LVMISCSIDriver"
def setUp(self):
super(ISCSITestCase, self).setUp()
self.configuration = mox.MockObject(conf.Configuration)
self.configuration.iscsi_target_prefix = 'iqn.2010-10.org.openstack:'
self.configuration.iscsi_ip_address = '0.0.0.0'
self.configuration.iscsi_port = 3260
def _attach_volume(self):
"""Attach volumes to an instance."""
volume_id_list = []
for index in range(3):
vol = {}
vol['size'] = 0
vol_ref = db.volume_create(self.context, vol)
self.volume.create_volume(self.context, vol_ref['id'])
vol_ref = db.volume_get(self.context, vol_ref['id'])
# each volume has a different mountpoint
mountpoint = "/dev/sd" + chr((ord('b') + index))
instance_uuid = '12345678-1234-5678-1234-567812345678'
db.volume_attached(self.context, vol_ref['id'], instance_uuid,
mountpoint)
volume_id_list.append(vol_ref['id'])
return volume_id_list
def test_do_iscsi_discovery(self):
self.configuration = conf.Configuration(None)
iscsi_driver = \
cinder.volume.targets.tgt.TgtAdm(
configuration=self.configuration)
utils.execute = lambda *a, **kw: \
("%s dummy" % CONF.iscsi_ip_address, '')
volume = {"name": "dummy",
"host": "0.0.0.0",
"id": "12345678-1234-5678-1234-567812345678"}
iscsi_driver._do_iscsi_discovery(volume)
def test_get_iscsi_properties(self):
volume = {"provider_location": '',
"id": "0",
"provider_auth": "a b c",
"attached_mode": "rw"}
iscsi_driver = \
cinder.volume.targets.tgt.TgtAdm(configuration=self.configuration)
iscsi_driver._do_iscsi_discovery = lambda v: "0.0.0.0:0000,0 iqn:iqn 0"
result = iscsi_driver._get_iscsi_properties(volume)
self.assertEqual("0.0.0.0:0000", result["target_portal"])
self.assertEqual("iqn:iqn", result["target_iqn"])
self.assertEqual(0, result["target_lun"])
def test_get_iscsi_properties_multiple_portals(self):
volume = {"provider_location": '1.1.1.1:3260;2.2.2.2:3261,1 iqn:iqn 0',
"id": "0",
"provider_auth": "a b c",
"attached_mode": "rw"}
iscsi_driver = \
cinder.volume.targets.tgt.TgtAdm(configuration=self.configuration)
result = iscsi_driver._get_iscsi_properties(volume)
self.assertEqual("1.1.1.1:3260", result["target_portal"])
self.assertEqual("iqn:iqn", result["target_iqn"])
self.assertEqual(0, result["target_lun"])
self.assertEqual(["1.1.1.1:3260", "2.2.2.2:3261"],
result["target_portals"])
self.assertEqual(["iqn:iqn", "iqn:iqn"], result["target_iqns"])
self.assertEqual([0, 0], result["target_luns"])
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_lvm_version',
return_value=(2, 2, 100))
def test_get_volume_stats(self, _mock_get_version):
def _fake_get_all_physical_volumes(obj, root_helper, vg_name):
return [{}]
@staticmethod
def _fake_get_all_volume_groups(root_helper, vg_name=None):
return [{'name': 'cinder-volumes',
'size': '5.52',
'available': '0.52',
'lv_count': '2',
'uuid': 'vR1JU3-FAKE-C4A9-PQFh-Mctm-9FwA-Xwzc1m'}]
def _fake_get_volumes(obj, lv_name=None):
return [{'vg': 'fake_vg', 'name': 'fake_vol', 'size': '1000'}]
self.stubs.Set(brick_lvm.LVM,
'get_all_volume_groups',
_fake_get_all_volume_groups)
self.stubs.Set(brick_lvm.LVM,
'get_all_physical_volumes',
_fake_get_all_physical_volumes)
self.stubs.Set(brick_lvm.LVM,
'get_volumes',
_fake_get_volumes)
self.volume.driver.vg = brick_lvm.LVM('cinder-volumes', 'sudo')
self.volume.driver._update_volume_stats()
stats = self.volume.driver._stats
self.assertEqual(
float('5.52'), stats['pools'][0]['total_capacity_gb'])
self.assertEqual(
float('0.52'), stats['pools'][0]['free_capacity_gb'])
self.assertEqual(
float('5.0'), stats['pools'][0]['provisioned_capacity_gb'])
self.assertEqual(
int('1'), stats['pools'][0]['total_volumes'])
self.assertFalse(stats['sparse_copy_volume'])
# Check value of sparse_copy_volume for thin enabled case.
# This value is set in check_for_setup_error.
self.configuration = conf.Configuration(None)
self.configuration.lvm_type = 'thin'
vg_obj = fake_lvm.FakeBrickLVM('cinder-volumes',
False,
None,
'default')
lvm_driver = lvm.LVMVolumeDriver(configuration=self.configuration,
db=db,
vg_obj=vg_obj)
lvm_driver.check_for_setup_error()
lvm_driver.vg = brick_lvm.LVM('cinder-volumes', 'sudo')
lvm_driver._update_volume_stats()
stats = lvm_driver._stats
self.assertTrue(stats['sparse_copy_volume'])
def test_validate_connector(self):
iscsi_driver =\
cinder.volume.targets.tgt.TgtAdm(
configuration=self.configuration)
# Validate a valid connector
connector = {'ip': '10.0.0.2',
'host': 'fakehost',
'initiator': 'iqn.2012-07.org.fake:01'}
iscsi_driver.validate_connector(connector)
# Validate a connector without the initiator
connector = {'ip': '10.0.0.2', 'host': 'fakehost'}
self.assertRaises(exception.InvalidConnectorException,
iscsi_driver.validate_connector, connector)
class ISERTestCase(DriverTestCase):
"""Test Case for ISERDriver."""
driver_name = "cinder.volume.drivers.lvm.LVMISERDriver"
def setUp(self):
super(ISERTestCase, self).setUp()
self.configuration = mock.Mock(conf.Configuration)
self.configuration.safe_get.return_value = None
self.configuration.num_iser_scan_tries = 3
self.configuration.iser_target_prefix = 'iqn.2010-10.org.openstack:'
self.configuration.iser_ip_address = '0.0.0.0'
self.configuration.iser_port = 3260
self.configuration.target_driver = \
'cinder.volume.targets.iser.ISERTgtAdm'
@test.testtools.skip("SKIP until ISER driver is removed or fixed")
def test_get_volume_stats(self):
def _fake_get_all_physical_volumes(obj, root_helper, vg_name):
return [{}]
def _fake_get_all_volume_groups(obj, vg_name=None, no_suffix=True):
return [{'name': 'cinder-volumes',
'size': '5.52',
'available': '0.52',
'lv_count': '2',
'uuid': 'vR1JU3-FAKE-C4A9-PQFh-Mctm-9FwA-Xwzc1m'}]
self.stubs.Set(brick_lvm.LVM,
'get_all_physical_volumes',
_fake_get_all_physical_volumes)
self.stubs.Set(brick_lvm.LVM,
'get_all_volume_groups',
_fake_get_all_volume_groups)
self.volume_driver = \
lvm.LVMISERDriver(configuration=self.configuration)
self.volume.driver.vg = brick_lvm.LVM('cinder-volumes', 'sudo')
stats = self.volume.driver.get_volume_stats(refresh=True)
self.assertEqual(
float('5.52'), stats['pools'][0]['total_capacity_gb'])
self.assertEqual(
float('0.52'), stats['pools'][0]['free_capacity_gb'])
self.assertEqual(
float('5.0'), stats['pools'][0]['provisioned_capacity_gb'])
self.assertEqual('iSER', stats['storage_protocol'])
@test.testtools.skip("SKIP until ISER driver is removed or fixed")
def test_get_volume_stats2(self):
iser_driver = lvm.LVMISERDriver(configuration=self.configuration)
stats = iser_driver.get_volume_stats(refresh=True)
self.assertEqual(
0, stats['pools'][0]['total_capacity_gb'])
self.assertEqual(
0, stats['pools'][0]['free_capacity_gb'])
self.assertEqual(
float('5.0'), stats['pools'][0]['provisioned_capacity_gb'])
self.assertEqual('iSER', stats['storage_protocol'])
class FibreChannelTestCase(DriverTestCase):
"""Test Case for FibreChannelDriver."""
driver_name = "cinder.volume.driver.FibreChannelDriver"
def test_initialize_connection(self):
self.assertRaises(NotImplementedError,
self.volume.driver.initialize_connection, {}, {})
def test_validate_connector(self):
"""validate_connector() successful use case.
validate_connector() does not throw an exception when
wwpns and wwnns are both set and both are not empty.
"""
connector = {'wwpns': ["not empty"],
'wwnns': ["not empty"]}
self.volume.driver.validate_connector(connector)
def test_validate_connector_no_wwpns(self):
"""validate_connector() throws exception when it has no wwpns."""
connector = {'wwnns': ["not empty"]}
self.assertRaises(exception.InvalidConnectorException,
self.volume.driver.validate_connector, connector)
def test_validate_connector_empty_wwpns(self):
"""validate_connector() throws exception when it has empty wwpns."""
connector = {'wwpns': [],
'wwnns': ["not empty"]}
self.assertRaises(exception.InvalidConnectorException,
self.volume.driver.validate_connector, connector)
def test_validate_connector_no_wwnns(self):
"""validate_connector() throws exception when it has no wwnns."""
connector = {'wwpns': ["not empty"]}
self.assertRaises(exception.InvalidConnectorException,
self.volume.driver.validate_connector, connector)
def test_validate_connector_empty_wwnns(self):
"""validate_connector() throws exception when it has empty wwnns."""
connector = {'wwnns': [],
'wwpns': ["not empty"]}
self.assertRaises(exception.InvalidConnectorException,
self.volume.driver.validate_connector, connector)
class VolumePolicyTestCase(test.TestCase):
def setUp(self):
super(VolumePolicyTestCase, self).setUp()
cinder.policy.init()
self.context = context.get_admin_context()
def test_check_policy(self):
self.mox.StubOutWithMock(cinder.policy, 'enforce')
target = {
'project_id': self.context.project_id,
'user_id': self.context.user_id,
}
cinder.policy.enforce(self.context, 'volume:attach', target)
self.mox.ReplayAll()
cinder.volume.api.check_policy(self.context, 'attach')
def test_check_policy_with_target(self):
self.mox.StubOutWithMock(cinder.policy, 'enforce')
target = {
'project_id': self.context.project_id,
'user_id': self.context.user_id,
'id': 2,
}
cinder.policy.enforce(self.context, 'volume:attach', target)
self.mox.ReplayAll()
cinder.volume.api.check_policy(self.context, 'attach', {'id': 2})
class ImageVolumeCacheTestCase(BaseVolumeTestCase):
def setUp(self):
super(ImageVolumeCacheTestCase, self).setUp()
self.volume.driver.set_initialized()
@mock.patch('oslo_utils.importutils.import_object')
def test_cache_configs(self, mock_import_object):
opts = {
'image_volume_cache_enabled': True,
'image_volume_cache_max_size_gb': 100,
'image_volume_cache_max_count': 20
}
def conf_get(option):
if option in opts:
return opts[option]
else:
return None
mock_driver = mock.Mock()
mock_driver.configuration.safe_get.side_effect = conf_get
mock_driver.configuration.extra_capabilities = 'null'
def import_obj(*args, **kwargs):
return mock_driver
mock_import_object.side_effect = import_obj
manager = vol_manager.VolumeManager(volume_driver=mock_driver)
self.assertIsNotNone(manager)
self.assertIsNotNone(manager.image_volume_cache)
self.assertEqual(100, manager.image_volume_cache.max_cache_size_gb)
self.assertEqual(20, manager.image_volume_cache.max_cache_size_count)
def test_delete_image_volume(self):
volume_params = {
'status': 'creating',
'host': 'some_host',
'size': 1
}
volume_api = cinder.volume.api.API()
volume = tests_utils.create_volume(self.context, **volume_params)
volume.status = 'available'
volume.save()
image_id = '70a599e0-31e7-49b7-b260-868f441e862b'
db.image_volume_cache_create(self.context,
volume['host'],
image_id,
datetime.datetime.utcnow(),
volume['id'],
volume['size'])
volume_api.delete(self.context, volume)
entry = db.image_volume_cache_get_by_volume_id(self.context,
volume['id'])
self.assertIsNone(entry)
|
apache-2.0
|
[
3,
1898,
7129,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
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,
624,
2925,
367,
15018,
5495,
1041,
199,
199,
646,
2197,
199,
646,
747,
199,
646,
5145,
199,
646,
2838,
199,
646,
984,
199,
646,
5549,
199,
646,
900,
199,
199,
646,
4952,
199,
646,
21819,
199,
646,
1683,
199,
504,
18610,
19,
492,
18610,
199,
646,
747,
63,
29541,
199,
504,
11258,
63,
27518,
492,
2112,
1208,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
12161,
492,
18705,
199,
504,
11258,
63,
1208,
492,
492,
1208,
199,
504,
11258,
63,
1208,
492,
23011,
199,
504,
11258,
63,
1208,
492,
6204,
199,
646,
3816,
199,
504,
20345,
1354,
720,
492,
3329,
199,
504,
2120,
1659,
14,
30378,
14,
1287,
63,
3908,
492,
6869,
199,
199,
504,
13069,
14,
1246,
492,
2863,
199,
504,
13069,
14,
29541,
14,
1832,
63,
2374,
492,
634,
2611,
465,
20611,
346,
63,
31283,
199,
504,
13069,
492,
1067,
199,
504,
13069,
492,
1592,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
1569,
492,
1834,
63,
1208,
199,
504,
13069,
492,
790,
7755,
199,
504,
13069,
492,
2251,
199,
646,
13069,
14,
3185,
199,
504,
13069,
492,
12132,
199,
504,
13069,
492,
511,
199,
504,
13069,
14,
2219,
14,
3248,
14,
1246,
492,
14063,
199,
504,
13069,
14,
2219,
14,
3248,
14,
29541,
492,
4026,
63,
31283,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3743,
63,
5997,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
3090,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
4753,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
2405,
199,
504,
13069,
14,
2219,
14,
3248,
14,
1569,
492,
4026,
465,
4026,
63,
1569,
199,
504,
13069,
14,
2219,
14,
3248,
14,
498,
7755,
492,
4026,
465,
4026,
63,
498,
7755,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3778,
465,
2295,
63,
1208,
199,
504,
13069,
492,
3778,
199,
646,
13069,
14,
2405,
199,
504,
13069,
14,
2405,
492,
2897,
465,
3743,
199,
504,
13069,
14,
2405,
492,
5253,
199,
504,
13069,
14,
2405,
14,
13337,
492,
634,
2611,
199,
504,
13069,
14,
2405,
492,
5256,
465,
5236,
63,
2609,
199,
504,
13069,
14,
2405,
492,
8985,
1246,
465,
3301,
63,
20776,
199,
646,
13069,
14,
2405,
14,
4684,
14,
15328,
199,
504,
13069,
14,
2405,
492,
3778,
465,
5236,
1208,
199,
504,
13069,
14,
2405,
492,
3301,
63,
1313,
421,
199,
18654,
1179,
275,
12132,
14,
18654,
1179,
199,
4064,
18654,
1179,
275,
12132,
14,
4064,
18654,
1179,
199,
199,
3103,
275,
4810,
14,
3103,
199,
199,
742,
19079,
1075,
63,
30600,
275,
283,
6765,
14,
2405,
14,
11929,
1384,
14,
4997,
2758,
14,
35,
13656,
2758,
1327,
4997,
269,
7,
199,
199,
3183,
63,
2992,
275,
359,
272,
4810,
14,
19340,
360,
3183,
63,
2992,
17,
297,
849,
534,
3183,
297,
1720,
534,
3183,
3999,
358,
199,
61,
421,
199,
533,
7777,
3491,
3167,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1592,
63,
3090,
29,
403,
12,
1834,
63,
1364,
29,
403,
304,
267,
986,
339,
347,
2498,
8,
277,
12,
1067,
12,
1834,
63,
344,
304,
267,
372,
791,
890,
356,
499,
627,
6204,
14,
30815,
12,
355,
283,
4032,
63,
908,
356,
283,
1773,
297,
355,
283,
3600,
63,
908,
356,
283,
14890,
297,
355,
283,
1205,
356,
283,
2682,
936,
421,
199,
533,
3523,
6464,
1746,
8,
396,
14,
1746,
304,
272,
408,
774,
12425,
367,
12158,
1041,
339,
25699,
63,
8757,
275,
283,
10980,
13,
6000,
13,
6000,
13,
6000,
13,
10980,
11629,
7,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
1563,
6464,
1746,
12,
291,
680,
5996,
342,
267,
291,
14,
3435,
63,
2609,
275,
3329,
14,
6382,
2988,
8,
288,
298,
1563,
6464,
1746,
531,
267,
5236,
63,
8616,
275,
5549,
14,
11983,
342,
267,
291,
14,
2469,
8,
8838,
63,
694,
29,
5650,
63,
8616,
12,
673,
6955,
63,
3090,
6270,
396,
3135,
267,
291,
14,
12808,
8,
277,
423,
7661,
9,
267,
291,
14,
2405,
275,
492,
1208,
14,
646,
63,
785,
8,
3103,
14,
2405,
63,
2609,
9,
267,
291,
14,
4758,
275,
1683,
14,
3346,
8,
2190,
14,
5688,
9,
267,
291,
14,
1100,
275,
1067,
14,
362,
63,
2113,
63,
1100,
342,
267,
291,
14,
1100,
14,
751,
63,
344,
275,
283,
3183,
7,
267,
327,
6944,
8,
77,
11317,
23522,
304,
710,
1305,
365,
7508,
13,
15282,
2348,
367,
15161,
21209,
2449,
267,
327,
22835,
543,
314,
6955,
1233,
12,
652,
1159,
1777,
402,
376,
267,
327,
24380,
13,
264,
1074,
1827,
880,
2793,
1133,
2813,
652,
503,
1570,
652,
14,
267,
291,
14,
1715,
63,
344,
275,
283,
23,
70,
13730,
3691,
20,
13,
19,
65,
2426,
13,
22474,
69,
13,
65,
31063,
13,
21,
3833,
2006,
1477,
65,
1184,
68,
19,
7,
267,
291,
14,
1100,
14,
1715,
63,
344,
275,
291,
14,
1715,
63,
344,
267,
291,
14,
2405,
63,
1162,
275,
469,
288,
283,
1205,
356,
283,
20358,
297,
288,
283,
1102,
356,
6392,
14,
1102,
12,
288,
283,
890,
356,
413,
93,
267,
291,
14,
8957,
14,
1084,
8,
29541,
63,
31283,
14,
28631,
12,
2432
] |
[
1898,
7129,
1910,
5703,
24230,
598,
27639,
465,
11159,
701,
314,
199,
3,
30660,
402,
314,
20548,
437,
281,
265,
3844,
7769,
436,
19326,
9516,
4633,
14,
199,
3,
2900,
5924,
5702,
14,
199,
3,
199,
3,
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,
624,
2925,
367,
15018,
5495,
1041,
199,
199,
646,
2197,
199,
646,
747,
199,
646,
5145,
199,
646,
2838,
199,
646,
984,
199,
646,
5549,
199,
646,
900,
199,
199,
646,
4952,
199,
646,
21819,
199,
646,
1683,
199,
504,
18610,
19,
492,
18610,
199,
646,
747,
63,
29541,
199,
504,
11258,
63,
27518,
492,
2112,
1208,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
11258,
63,
12161,
492,
18705,
199,
504,
11258,
63,
1208,
492,
492,
1208,
199,
504,
11258,
63,
1208,
492,
23011,
199,
504,
11258,
63,
1208,
492,
6204,
199,
646,
3816,
199,
504,
20345,
1354,
720,
492,
3329,
199,
504,
2120,
1659,
14,
30378,
14,
1287,
63,
3908,
492,
6869,
199,
199,
504,
13069,
14,
1246,
492,
2863,
199,
504,
13069,
14,
29541,
14,
1832,
63,
2374,
492,
634,
2611,
465,
20611,
346,
63,
31283,
199,
504,
13069,
492,
1067,
199,
504,
13069,
492,
1592,
199,
504,
13069,
492,
1919,
199,
504,
13069,
14,
1569,
492,
1834,
63,
1208,
199,
504,
13069,
492,
790,
7755,
199,
504,
13069,
492,
2251,
199,
646,
13069,
14,
3185,
199,
504,
13069,
492,
12132,
199,
504,
13069,
492,
511,
199,
504,
13069,
14,
2219,
14,
3248,
14,
1246,
492,
14063,
199,
504,
13069,
14,
2219,
14,
3248,
14,
29541,
492,
4026,
63,
31283,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3743,
63,
5997,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
3090,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
4753,
199,
504,
13069,
14,
2219,
14,
3248,
492,
4026,
63,
2405,
199,
504,
13069,
14,
2219,
14,
3248,
14,
1569,
492,
4026,
465,
4026,
63,
1569,
199,
504,
13069,
14,
2219,
14,
3248,
14,
498,
7755,
492,
4026,
465,
4026,
63,
498,
7755,
199,
504,
13069,
14,
2219,
14,
3248,
492,
3778,
465,
2295,
63,
1208,
199,
504,
13069,
492,
3778,
199,
646,
13069,
14,
2405,
199,
504,
13069,
14,
2405,
492,
2897,
465,
3743,
199,
504,
13069,
14,
2405,
492,
5253,
199,
504,
13069,
14,
2405,
14,
13337,
492,
634,
2611,
199,
504,
13069,
14,
2405,
492,
5256,
465,
5236,
63,
2609,
199,
504,
13069,
14,
2405,
492,
8985,
1246,
465,
3301,
63,
20776,
199,
646,
13069,
14,
2405,
14,
4684,
14,
15328,
199,
504,
13069,
14,
2405,
492,
3778,
465,
5236,
1208,
199,
504,
13069,
14,
2405,
492,
3301,
63,
1313,
421,
199,
18654,
1179,
275,
12132,
14,
18654,
1179,
199,
4064,
18654,
1179,
275,
12132,
14,
4064,
18654,
1179,
199,
199,
3103,
275,
4810,
14,
3103,
199,
199,
742,
19079,
1075,
63,
30600,
275,
283,
6765,
14,
2405,
14,
11929,
1384,
14,
4997,
2758,
14,
35,
13656,
2758,
1327,
4997,
269,
7,
199,
199,
3183,
63,
2992,
275,
359,
272,
4810,
14,
19340,
360,
3183,
63,
2992,
17,
297,
849,
534,
3183,
297,
1720,
534,
3183,
3999,
358,
199,
61,
421,
199,
533,
7777,
3491,
3167,
8,
785,
304,
272,
347,
636,
826,
721,
277,
12,
1592,
63,
3090,
29,
403,
12,
1834,
63,
1364,
29,
403,
304,
267,
986,
339,
347,
2498,
8,
277,
12,
1067,
12,
1834,
63,
344,
304,
267,
372,
791,
890,
356,
499,
627,
6204,
14,
30815,
12,
355,
283,
4032,
63,
908,
356,
283,
1773,
297,
355,
283,
3600,
63,
908,
356,
283,
14890,
297,
355,
283,
1205,
356,
283,
2682,
936,
421,
199,
533,
3523,
6464,
1746,
8,
396,
14,
1746,
304,
272,
408,
774,
12425,
367,
12158,
1041,
339,
25699,
63,
8757,
275,
283,
10980,
13,
6000,
13,
6000,
13,
6000,
13,
10980,
11629,
7,
339,
347,
3613,
8,
277,
304,
267,
1613,
8,
1563,
6464,
1746,
12,
291,
680,
5996,
342,
267,
291,
14,
3435,
63,
2609,
275,
3329,
14,
6382,
2988,
8,
288,
298,
1563,
6464,
1746,
531,
267,
5236,
63,
8616,
275,
5549,
14,
11983,
342,
267,
291,
14,
2469,
8,
8838,
63,
694,
29,
5650,
63,
8616,
12,
673,
6955,
63,
3090,
6270,
396,
3135,
267,
291,
14,
12808,
8,
277,
423,
7661,
9,
267,
291,
14,
2405,
275,
492,
1208,
14,
646,
63,
785,
8,
3103,
14,
2405,
63,
2609,
9,
267,
291,
14,
4758,
275,
1683,
14,
3346,
8,
2190,
14,
5688,
9,
267,
291,
14,
1100,
275,
1067,
14,
362,
63,
2113,
63,
1100,
342,
267,
291,
14,
1100,
14,
751,
63,
344,
275,
283,
3183,
7,
267,
327,
6944,
8,
77,
11317,
23522,
304,
710,
1305,
365,
7508,
13,
15282,
2348,
367,
15161,
21209,
2449,
267,
327,
22835,
543,
314,
6955,
1233,
12,
652,
1159,
1777,
402,
376,
267,
327,
24380,
13,
264,
1074,
1827,
880,
2793,
1133,
2813,
652,
503,
1570,
652,
14,
267,
291,
14,
1715,
63,
344,
275,
283,
23,
70,
13730,
3691,
20,
13,
19,
65,
2426,
13,
22474,
69,
13,
65,
31063,
13,
21,
3833,
2006,
1477,
65,
1184,
68,
19,
7,
267,
291,
14,
1100,
14,
1715,
63,
344,
275,
291,
14,
1715,
63,
344,
267,
291,
14,
2405,
63,
1162,
275,
469,
288,
283,
1205,
356,
283,
20358,
297,
288,
283,
1102,
356,
6392,
14,
1102,
12,
288,
283,
890,
356,
413,
93,
267,
291,
14,
8957,
14,
1084,
8,
29541,
63,
31283,
14,
28631,
12,
2432,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
40223143/cda-w15
|
static/Brython3.1.3-20150514-095342/Lib/contextlib.py
|
737
|
8788
|
"""Utilities for with-statement contexts. See PEP 343."""
import sys
from collections import deque
from functools import wraps
__all__ = ["contextmanager", "closing", "ContextDecorator", "ExitStack"]
class ContextDecorator(object):
"A base class or mixin that enables context managers to work as decorators."
def _recreate_cm(self):
"""Return a recreated instance of self.
Allows an otherwise one-shot context manager like
_GeneratorContextManager to support use as
a decorator via implicit recreation.
This is a private interface just for _GeneratorContextManager.
See issue #11647 for details.
"""
return self
def __call__(self, func):
@wraps(func)
def inner(*args, **kwds):
with self._recreate_cm():
return func(*args, **kwds)
return inner
class _GeneratorContextManager(ContextDecorator):
"""Helper for @contextmanager decorator."""
def __init__(self, func, *args, **kwds):
self.gen = func(*args, **kwds)
self.func, self.args, self.kwds = func, args, kwds
def _recreate_cm(self):
# _GCM instances are one-shot context managers, so the
# CM must be recreated each time a decorated function is
# called
return self.__class__(self.func, *self.args, **self.kwds)
def __enter__(self):
try:
return next(self.gen)
except StopIteration:
raise RuntimeError("generator didn't yield")
def __exit__(self, type, value, traceback):
if type is None:
try:
next(self.gen)
except StopIteration:
return
else:
raise RuntimeError("generator didn't stop")
else:
if value is None:
# Need to force instantiation so we can reliably
# tell if we get the same exception back
value = type()
try:
self.gen.throw(type, value, traceback)
raise RuntimeError("generator didn't stop after throw()")
except StopIteration as exc:
# Suppress the exception *unless* it's the same exception that
# was passed to throw(). This prevents a StopIteration
# raised inside the "with" statement from being suppressed
return exc is not value
except:
# only re-raise if it's *not* the exception that was
# passed to throw(), because __exit__() must not raise
# an exception unless __exit__() itself failed. But throw()
# has to raise the exception to signal propagation, so this
# fixes the impedance mismatch between the throw() protocol
# and the __exit__() protocol.
#
if sys.exc_info()[1] is not value:
raise
def contextmanager(func):
"""@contextmanager decorator.
Typical usage:
@contextmanager
def some_generator(<arguments>):
<setup>
try:
yield <value>
finally:
<cleanup>
This makes this:
with some_generator(<arguments>) as <variable>:
<body>
equivalent to this:
<setup>
try:
<variable> = <value>
<body>
finally:
<cleanup>
"""
@wraps(func)
def helper(*args, **kwds):
return _GeneratorContextManager(func, *args, **kwds)
return helper
class closing(object):
"""Context to automatically close something at the end of a block.
Code like this:
with closing(<module>.open(<arguments>)) as f:
<block>
is equivalent to this:
f = <module>.open(<arguments>)
try:
<block>
finally:
f.close()
"""
def __init__(self, thing):
self.thing = thing
def __enter__(self):
return self.thing
def __exit__(self, *exc_info):
self.thing.close()
# Inspired by discussions on http://bugs.python.org/issue13585
class ExitStack(object):
"""Context manager for dynamic management of a stack of exit callbacks
For example:
with ExitStack() as stack:
files = [stack.enter_context(open(fname)) for fname in filenames]
# All opened files will automatically be closed at the end of
# the with statement, even if attempts to open files later
# in the list raise an exception
"""
def __init__(self):
self._exit_callbacks = deque()
def pop_all(self):
"""Preserve the context stack by transferring it to a new instance"""
new_stack = type(self)()
new_stack._exit_callbacks = self._exit_callbacks
self._exit_callbacks = deque()
return new_stack
def _push_cm_exit(self, cm, cm_exit):
"""Helper to correctly register callbacks to __exit__ methods"""
def _exit_wrapper(*exc_details):
return cm_exit(cm, *exc_details)
_exit_wrapper.__self__ = cm
self.push(_exit_wrapper)
def push(self, exit):
"""Registers a callback with the standard __exit__ method signature
Can suppress exceptions the same way __exit__ methods can.
Also accepts any object with an __exit__ method (registering a call
to the method instead of the object itself)
"""
# We use an unbound method rather than a bound method to follow
# the standard lookup behaviour for special methods
_cb_type = type(exit)
try:
exit_method = _cb_type.__exit__
except AttributeError:
# Not a context manager, so assume its a callable
self._exit_callbacks.append(exit)
else:
self._push_cm_exit(exit, exit_method)
return exit # Allow use as a decorator
def callback(self, callback, *args, **kwds):
"""Registers an arbitrary callback and arguments.
Cannot suppress exceptions.
"""
def _exit_wrapper(exc_type, exc, tb):
callback(*args, **kwds)
# We changed the signature, so using @wraps is not appropriate, but
# setting __wrapped__ may still help with introspection
_exit_wrapper.__wrapped__ = callback
self.push(_exit_wrapper)
return callback # Allow use as a decorator
def enter_context(self, cm):
"""Enters the supplied context manager
If successful, also pushes its __exit__ method as a callback and
returns the result of the __enter__ method.
"""
# We look up the special methods on the type to match the with statement
_cm_type = type(cm)
_exit = _cm_type.__exit__
result = _cm_type.__enter__(cm)
self._push_cm_exit(cm, _exit)
return result
def close(self):
"""Immediately unwind the context stack"""
self.__exit__(None, None, None)
def __enter__(self):
return self
def __exit__(self, *exc_details):
received_exc = exc_details[0] is not None
# We manipulate the exception state so it behaves as though
# we were actually nesting multiple with statements
frame_exc = sys.exc_info()[1]
def _fix_exception_context(new_exc, old_exc):
while 1:
exc_context = new_exc.__context__
if exc_context in (None, frame_exc):
break
new_exc = exc_context
new_exc.__context__ = old_exc
# Callbacks are invoked in LIFO order to match the behaviour of
# nested context managers
suppressed_exc = False
pending_raise = False
while self._exit_callbacks:
cb = self._exit_callbacks.pop()
try:
if cb(*exc_details):
suppressed_exc = True
pending_raise = False
exc_details = (None, None, None)
except:
new_exc_details = sys.exc_info()
# simulate the stack of exceptions by setting the context
_fix_exception_context(new_exc_details[1], exc_details[1])
pending_raise = True
exc_details = new_exc_details
if pending_raise:
try:
# bare "raise exc_details[1]" replaces our carefully
# set-up context
fixed_ctx = exc_details[1].__context__
raise exc_details[1]
except BaseException:
exc_details[1].__context__ = fixed_ctx
raise
return received_exc and suppressed_exc
|
agpl-3.0
|
[
624,
22905,
367,
543,
13,
6242,
18191,
14,
221,
1666,
13663,
650,
2824,
1041,
199,
199,
646,
984,
199,
504,
5055,
492,
15782,
199,
504,
9143,
492,
14018,
199,
199,
363,
452,
363,
275,
2097,
14237,
401,
298,
11707,
401,
298,
2998,
14946,
401,
298,
6699,
4851,
937,
421,
199,
533,
9470,
14946,
8,
785,
304,
272,
298,
33,
1300,
1021,
503,
20048,
626,
22741,
1067,
19680,
370,
1736,
465,
20419,
2122,
339,
347,
485,
264,
981,
63,
4400,
8,
277,
304,
267,
408,
1767,
282,
295,
3966,
1256,
402,
291,
14,
398,
22819,
376,
4257,
1373,
13,
2782,
1067,
5256,
2839,
267,
485,
7599,
2998,
2988,
370,
2291,
675,
465,
267,
282,
7531,
4799,
9227,
295,
8782,
14,
398,
961,
365,
282,
5726,
3217,
2951,
367,
485,
7599,
2998,
2988,
14,
267,
1666,
4976,
327,
845,
8557,
367,
2436,
14,
267,
408,
267,
372,
291,
339,
347,
636,
1250,
721,
277,
12,
2562,
304,
267,
768,
13582,
8,
1532,
9,
267,
347,
6506,
2031,
589,
12,
1011,
10340,
304,
288,
543,
291,
423,
264,
981,
63,
4400,
837,
355,
372,
2562,
2031,
589,
12,
1011,
10340,
9,
267,
372,
6506,
421,
199,
533,
485,
7599,
2998,
2988,
8,
2998,
14946,
304,
272,
408,
4433,
367,
768,
14237,
7531,
1041,
339,
347,
636,
826,
721,
277,
12,
2562,
12,
627,
589,
12,
1011,
10340,
304,
267,
291,
14,
2268,
275,
2562,
2031,
589,
12,
1011,
10340,
9,
267,
291,
14,
1532,
12,
291,
14,
589,
12,
291,
14,
10340,
275,
2562,
12,
1249,
12,
16286,
339,
347,
485,
264,
981,
63,
4400,
8,
277,
304,
267,
327,
485,
29009,
4454,
787,
1373,
13,
2782,
1067,
19680,
12,
880,
314,
267,
327,
445,
45,
1471,
506,
295,
3966,
1924,
900,
282,
16225,
805,
365,
267,
327,
2797,
267,
372,
291,
855,
533,
721,
277,
14,
1532,
12,
627,
277,
14,
589,
12,
1011,
277,
14,
10340,
9,
339,
347,
636,
4200,
721,
277,
304,
267,
862,
26,
288,
372,
2163,
8,
277,
14,
2268,
9,
267,
871,
10852,
26,
288,
746,
6064,
480,
4679,
9980,
1133,
1995,
531,
339,
347,
636,
2224,
721,
277,
12,
730,
12,
574,
12,
5190,
304,
267,
340,
730,
365,
488,
26,
288,
862,
26,
355,
2163,
8,
277,
14,
2268,
9,
288,
871,
10852,
26,
355,
372,
288,
587,
26,
355,
746,
6064,
480,
4679,
9980,
1133,
3631,
531,
267,
587,
26,
288,
340,
574,
365,
488,
26,
355,
327,
14012,
370,
3542,
26621,
880,
781,
883,
16492,
6665,
355,
327,
11480,
340,
781,
664,
314,
2011,
1919,
1771,
355,
574,
275,
730,
342,
288,
862,
26,
355,
291,
14,
2268,
14,
11964,
8,
466,
12,
574,
12,
5190,
9,
355,
746,
6064,
480,
4679,
9980,
1133,
3631,
2410,
7978,
16060,
288,
871,
10852,
465,
3178,
26,
355,
327,
26602,
314,
1919,
627,
18447,
10,
652,
1159,
314,
2011,
1919,
626,
355,
327,
1990,
3032,
370,
7978,
1252,
221,
961,
21925,
282,
10852,
355,
327,
4915,
6272,
314,
298,
1045,
2,
5164,
687,
3769,
30581,
355,
372,
3178,
365,
440,
574,
288,
871,
26,
355,
327,
1454,
295,
13,
3730,
340,
652,
1159,
627,
1397,
10,
314,
1919,
626,
1990,
355,
327,
3032,
370,
7978,
1062,
2952,
636,
2224,
4533,
1471,
440,
746,
355,
327,
376,
1919,
7444,
636,
2224,
4533,
6337,
3405,
14,
221,
11017,
7978,
342,
355,
327,
965,
370,
746,
314,
1919,
370,
4673,
17012,
12,
880,
642,
355,
327,
25079,
314,
1742,
379,
554,
15015,
3382,
314,
7978,
342,
4113,
355,
327,
436,
314,
636,
2224,
4533,
4113,
14,
355,
327,
355,
340,
984,
14,
2804,
63,
815,
3430,
17,
61,
365,
440,
574,
26,
490,
746,
421,
199,
318,
27608,
8,
1532,
304,
272,
408,
32,
14237,
7531,
14,
339,
29267,
4503,
26,
398,
768,
14237,
267,
347,
2005,
63,
4679,
27530,
4958,
30,
304,
288,
665,
2758,
30,
288,
862,
26,
355,
1995,
665,
585,
30,
288,
3753,
26,
355,
665,
7661,
30,
339,
961,
7704,
642,
26,
398,
543,
2005,
63,
4679,
27530,
4958,
18956,
465,
665,
1975,
20020,
288,
665,
2030,
30,
339,
7353,
370,
642,
26,
398,
665,
2758,
30,
267,
862,
26,
288,
665,
1975,
30,
275,
665,
585,
30,
288,
665,
2030,
30,
267,
3753,
26,
288,
665,
7661,
30,
339,
408,
272,
768,
13582,
8,
1532,
9,
272,
347,
5922,
2031,
589,
12,
1011,
10340,
304,
267,
372,
485,
7599,
2998,
2988,
8,
1532,
12,
627,
589,
12,
1011,
10340,
9,
272,
372,
5922,
421,
199,
533,
11261,
8,
785,
304,
272,
408,
2998,
370,
5847,
4002,
6020,
737,
314,
1284,
402,
282,
1853,
14,
339,
5495,
2839,
642,
26,
398,
543,
11261,
27530,
578,
10827,
1490,
27530,
4958,
30,
430,
465,
289,
26,
288,
665,
1457,
30,
339,
365,
7353,
370,
642,
26,
398,
289,
275,
665,
578,
10827,
1490,
27530,
4958,
18956,
267,
862,
26,
288,
665,
1457,
30,
267,
3753,
26,
288,
289,
14,
1600,
342,
339,
408,
272,
347,
636,
826,
721,
277,
12,
8377,
304,
267,
291,
14,
2127,
275,
8377,
272,
347,
636,
4200,
721,
277,
304,
267,
372,
291,
14,
2127,
272,
347,
636,
2224,
721,
277,
12,
627,
2804,
63,
815,
304,
267,
291,
14,
2127,
14,
1600,
342,
421,
199,
3,
12062,
1038,
581,
701,
4339,
527,
1356,
641,
1455,
921,
13017,
14,
1548,
14,
1308,
15,
5237,
969,
15959,
199,
533,
18704,
4851,
8,
785,
304,
272,
408,
2998,
5256,
367,
8336,
10041,
402,
282,
3464,
402,
4458,
13484,
339,
2104,
2893,
26,
398,
543,
18704,
4851,
342,
465,
3464,
26,
288,
1584,
275,
359,
2340,
14,
4200,
63,
1100,
8,
1490,
8,
5252,
430,
367,
6748,
315,
6203,
61,
288,
327,
2900,
12123,
1584,
911,
5847,
506,
6876,
737,
314,
1284,
402,
288,
327,
314,
543,
5164,
12,
2755,
340,
12454,
370,
1551,
1584,
2945,
288,
327,
315,
314,
769,
746,
376,
1919,
339,
408,
272,
347,
636,
826,
721,
277,
304,
267,
291,
423,
2224,
63,
11948,
275,
15782,
342,
339,
347,
4560,
63,
452,
8,
277,
304,
267,
408,
2398,
4909,
314,
1067,
3464,
701,
28183,
17756,
652,
370,
282,
892,
1256,
624,
267,
892,
63,
2340,
275,
730,
8,
277,
16315,
267,
892
] |
[
22905,
367,
543,
13,
6242,
18191,
14,
221,
1666,
13663,
650,
2824,
1041,
199,
199,
646,
984,
199,
504,
5055,
492,
15782,
199,
504,
9143,
492,
14018,
199,
199,
363,
452,
363,
275,
2097,
14237,
401,
298,
11707,
401,
298,
2998,
14946,
401,
298,
6699,
4851,
937,
421,
199,
533,
9470,
14946,
8,
785,
304,
272,
298,
33,
1300,
1021,
503,
20048,
626,
22741,
1067,
19680,
370,
1736,
465,
20419,
2122,
339,
347,
485,
264,
981,
63,
4400,
8,
277,
304,
267,
408,
1767,
282,
295,
3966,
1256,
402,
291,
14,
398,
22819,
376,
4257,
1373,
13,
2782,
1067,
5256,
2839,
267,
485,
7599,
2998,
2988,
370,
2291,
675,
465,
267,
282,
7531,
4799,
9227,
295,
8782,
14,
398,
961,
365,
282,
5726,
3217,
2951,
367,
485,
7599,
2998,
2988,
14,
267,
1666,
4976,
327,
845,
8557,
367,
2436,
14,
267,
408,
267,
372,
291,
339,
347,
636,
1250,
721,
277,
12,
2562,
304,
267,
768,
13582,
8,
1532,
9,
267,
347,
6506,
2031,
589,
12,
1011,
10340,
304,
288,
543,
291,
423,
264,
981,
63,
4400,
837,
355,
372,
2562,
2031,
589,
12,
1011,
10340,
9,
267,
372,
6506,
421,
199,
533,
485,
7599,
2998,
2988,
8,
2998,
14946,
304,
272,
408,
4433,
367,
768,
14237,
7531,
1041,
339,
347,
636,
826,
721,
277,
12,
2562,
12,
627,
589,
12,
1011,
10340,
304,
267,
291,
14,
2268,
275,
2562,
2031,
589,
12,
1011,
10340,
9,
267,
291,
14,
1532,
12,
291,
14,
589,
12,
291,
14,
10340,
275,
2562,
12,
1249,
12,
16286,
339,
347,
485,
264,
981,
63,
4400,
8,
277,
304,
267,
327,
485,
29009,
4454,
787,
1373,
13,
2782,
1067,
19680,
12,
880,
314,
267,
327,
445,
45,
1471,
506,
295,
3966,
1924,
900,
282,
16225,
805,
365,
267,
327,
2797,
267,
372,
291,
855,
533,
721,
277,
14,
1532,
12,
627,
277,
14,
589,
12,
1011,
277,
14,
10340,
9,
339,
347,
636,
4200,
721,
277,
304,
267,
862,
26,
288,
372,
2163,
8,
277,
14,
2268,
9,
267,
871,
10852,
26,
288,
746,
6064,
480,
4679,
9980,
1133,
1995,
531,
339,
347,
636,
2224,
721,
277,
12,
730,
12,
574,
12,
5190,
304,
267,
340,
730,
365,
488,
26,
288,
862,
26,
355,
2163,
8,
277,
14,
2268,
9,
288,
871,
10852,
26,
355,
372,
288,
587,
26,
355,
746,
6064,
480,
4679,
9980,
1133,
3631,
531,
267,
587,
26,
288,
340,
574,
365,
488,
26,
355,
327,
14012,
370,
3542,
26621,
880,
781,
883,
16492,
6665,
355,
327,
11480,
340,
781,
664,
314,
2011,
1919,
1771,
355,
574,
275,
730,
342,
288,
862,
26,
355,
291,
14,
2268,
14,
11964,
8,
466,
12,
574,
12,
5190,
9,
355,
746,
6064,
480,
4679,
9980,
1133,
3631,
2410,
7978,
16060,
288,
871,
10852,
465,
3178,
26,
355,
327,
26602,
314,
1919,
627,
18447,
10,
652,
1159,
314,
2011,
1919,
626,
355,
327,
1990,
3032,
370,
7978,
1252,
221,
961,
21925,
282,
10852,
355,
327,
4915,
6272,
314,
298,
1045,
2,
5164,
687,
3769,
30581,
355,
372,
3178,
365,
440,
574,
288,
871,
26,
355,
327,
1454,
295,
13,
3730,
340,
652,
1159,
627,
1397,
10,
314,
1919,
626,
1990,
355,
327,
3032,
370,
7978,
1062,
2952,
636,
2224,
4533,
1471,
440,
746,
355,
327,
376,
1919,
7444,
636,
2224,
4533,
6337,
3405,
14,
221,
11017,
7978,
342,
355,
327,
965,
370,
746,
314,
1919,
370,
4673,
17012,
12,
880,
642,
355,
327,
25079,
314,
1742,
379,
554,
15015,
3382,
314,
7978,
342,
4113,
355,
327,
436,
314,
636,
2224,
4533,
4113,
14,
355,
327,
355,
340,
984,
14,
2804,
63,
815,
3430,
17,
61,
365,
440,
574,
26,
490,
746,
421,
199,
318,
27608,
8,
1532,
304,
272,
408,
32,
14237,
7531,
14,
339,
29267,
4503,
26,
398,
768,
14237,
267,
347,
2005,
63,
4679,
27530,
4958,
30,
304,
288,
665,
2758,
30,
288,
862,
26,
355,
1995,
665,
585,
30,
288,
3753,
26,
355,
665,
7661,
30,
339,
961,
7704,
642,
26,
398,
543,
2005,
63,
4679,
27530,
4958,
18956,
465,
665,
1975,
20020,
288,
665,
2030,
30,
339,
7353,
370,
642,
26,
398,
665,
2758,
30,
267,
862,
26,
288,
665,
1975,
30,
275,
665,
585,
30,
288,
665,
2030,
30,
267,
3753,
26,
288,
665,
7661,
30,
339,
408,
272,
768,
13582,
8,
1532,
9,
272,
347,
5922,
2031,
589,
12,
1011,
10340,
304,
267,
372,
485,
7599,
2998,
2988,
8,
1532,
12,
627,
589,
12,
1011,
10340,
9,
272,
372,
5922,
421,
199,
533,
11261,
8,
785,
304,
272,
408,
2998,
370,
5847,
4002,
6020,
737,
314,
1284,
402,
282,
1853,
14,
339,
5495,
2839,
642,
26,
398,
543,
11261,
27530,
578,
10827,
1490,
27530,
4958,
30,
430,
465,
289,
26,
288,
665,
1457,
30,
339,
365,
7353,
370,
642,
26,
398,
289,
275,
665,
578,
10827,
1490,
27530,
4958,
18956,
267,
862,
26,
288,
665,
1457,
30,
267,
3753,
26,
288,
289,
14,
1600,
342,
339,
408,
272,
347,
636,
826,
721,
277,
12,
8377,
304,
267,
291,
14,
2127,
275,
8377,
272,
347,
636,
4200,
721,
277,
304,
267,
372,
291,
14,
2127,
272,
347,
636,
2224,
721,
277,
12,
627,
2804,
63,
815,
304,
267,
291,
14,
2127,
14,
1600,
342,
421,
199,
3,
12062,
1038,
581,
701,
4339,
527,
1356,
641,
1455,
921,
13017,
14,
1548,
14,
1308,
15,
5237,
969,
15959,
199,
533,
18704,
4851,
8,
785,
304,
272,
408,
2998,
5256,
367,
8336,
10041,
402,
282,
3464,
402,
4458,
13484,
339,
2104,
2893,
26,
398,
543,
18704,
4851,
342,
465,
3464,
26,
288,
1584,
275,
359,
2340,
14,
4200,
63,
1100,
8,
1490,
8,
5252,
430,
367,
6748,
315,
6203,
61,
288,
327,
2900,
12123,
1584,
911,
5847,
506,
6876,
737,
314,
1284,
402,
288,
327,
314,
543,
5164,
12,
2755,
340,
12454,
370,
1551,
1584,
2945,
288,
327,
315,
314,
769,
746,
376,
1919,
339,
408,
272,
347,
636,
826,
721,
277,
304,
267,
291,
423,
2224,
63,
11948,
275,
15782,
342,
339,
347,
4560,
63,
452,
8,
277,
304,
267,
408,
2398,
4909,
314,
1067,
3464,
701,
28183,
17756,
652,
370,
282,
892,
1256,
624,
267,
892,
63,
2340,
275,
730,
8,
277,
16315,
267,
892,
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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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
] |
homme/ansible-modules-core
|
utilities/logic/debug.py
|
132
|
1915
|
#!/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/>.
DOCUMENTATION = '''
---
module: debug
short_description: Print statements during execution
description:
- This module prints statements during execution and can be useful
for debugging variables or expressions without necessarily halting
the playbook. Useful for debugging together with the 'when:' directive.
version_added: "0.8"
options:
msg:
description:
- The customized message that is printed. If omitted, prints a generic
message.
required: false
default: "Hello world!"
var:
description:
- A variable name to debug. Mutually exclusive with the 'msg' option.
author:
- "Dag Wieers (@dagwieers)"
- "Michael DeHaan"
'''
EXAMPLES = '''
# Example that prints the loopback address and gateway for each host
- debug: msg="System {{ inventory_hostname }} has uuid {{ ansible_product_uuid }}"
- debug: msg="System {{ inventory_hostname }} has gateway {{ ansible_default_ipv4.gateway }}"
when: ansible_default_ipv4.gateway is defined
- shell: /usr/bin/uptime
register: result
- debug: var=result
- name: Display all variables/facts known for a host
debug: var=hostvars[inventory_hostname]
'''
|
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,
8948,
275,
1449,
199,
2595,
199,
578,
26,
3105,
199,
3612,
63,
1802,
26,
9101,
9834,
5309,
6451,
199,
1802,
26,
1362,
446,
961,
859,
14767,
9834,
5309,
6451,
436,
883,
506,
2997,
2126,
367,
10201,
2860,
503,
8455,
1928,
20513,
22939,
1337,
2126,
314,
15695,
14,
18491,
367,
10201,
10451,
543,
314,
283,
6526,
4881,
13613,
14,
199,
199,
1023,
63,
3270,
26,
298,
16,
14,
24,
2,
199,
1419,
26,
523,
1499,
26,
272,
1369,
26,
489,
446,
710,
26707,
1245,
626,
365,
12487,
14,
982,
11684,
12,
14767,
282,
7809,
267,
1245,
14,
272,
1415,
26,
3055,
272,
849,
26,
298,
6257,
6701,
9539,
523,
2729,
26,
272,
1369,
26,
489,
446,
437,
1750,
536,
370,
3105,
14,
221,
26550,
3163,
13914,
543,
314,
283,
1328,
7,
945,
14,
199,
2502,
26,
5591,
446,
298,
27234,
644,
1873,
1192,
8593,
7406,
87,
1873,
1192,
2924,
272,
446,
298,
45,
11781,
22453,
2,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5679,
626,
14767,
314,
4438,
894,
2287,
436,
10391,
367,
1924,
1591,
199,
13,
3105,
26,
1499,
628,
3989,
8448,
8200,
63,
4269,
3586,
965,
5377,
8448,
3242,
63,
2558,
63,
2580,
7820,
199,
199,
13,
3105,
26,
1499,
628,
3989,
8448,
8200,
63,
4269,
3586,
965,
10391,
8448,
3242,
63,
885,
63,
4774,
20,
14,
7019,
7820,
523,
1380,
26,
3242,
63,
885,
63,
4774,
20,
14,
7019,
365,
3247,
199,
199,
13,
5218,
26,
1182,
2647,
15,
1393,
15,
24853,
523,
2274,
26,
754,
199,
199,
13,
3105,
26,
2729,
29,
1099,
199,
199,
13,
536,
26,
12175,
1006,
2860,
15,
5047,
6040,
367,
282,
1591,
523,
3105,
26,
2729,
29,
23265,
59,
7212,
63,
4269,
61,
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
] |
[
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,
8948,
275,
1449,
199,
2595,
199,
578,
26,
3105,
199,
3612,
63,
1802,
26,
9101,
9834,
5309,
6451,
199,
1802,
26,
1362,
446,
961,
859,
14767,
9834,
5309,
6451,
436,
883,
506,
2997,
2126,
367,
10201,
2860,
503,
8455,
1928,
20513,
22939,
1337,
2126,
314,
15695,
14,
18491,
367,
10201,
10451,
543,
314,
283,
6526,
4881,
13613,
14,
199,
199,
1023,
63,
3270,
26,
298,
16,
14,
24,
2,
199,
1419,
26,
523,
1499,
26,
272,
1369,
26,
489,
446,
710,
26707,
1245,
626,
365,
12487,
14,
982,
11684,
12,
14767,
282,
7809,
267,
1245,
14,
272,
1415,
26,
3055,
272,
849,
26,
298,
6257,
6701,
9539,
523,
2729,
26,
272,
1369,
26,
489,
446,
437,
1750,
536,
370,
3105,
14,
221,
26550,
3163,
13914,
543,
314,
283,
1328,
7,
945,
14,
199,
2502,
26,
5591,
446,
298,
27234,
644,
1873,
1192,
8593,
7406,
87,
1873,
1192,
2924,
272,
446,
298,
45,
11781,
22453,
2,
199,
2344,
199,
199,
8918,
275,
1449,
199,
3,
5679,
626,
14767,
314,
4438,
894,
2287,
436,
10391,
367,
1924,
1591,
199,
13,
3105,
26,
1499,
628,
3989,
8448,
8200,
63,
4269,
3586,
965,
5377,
8448,
3242,
63,
2558,
63,
2580,
7820,
199,
199,
13,
3105,
26,
1499,
628,
3989,
8448,
8200,
63,
4269,
3586,
965,
10391,
8448,
3242,
63,
885,
63,
4774,
20,
14,
7019,
7820,
523,
1380,
26,
3242,
63,
885,
63,
4774,
20,
14,
7019,
365,
3247,
199,
199,
13,
5218,
26,
1182,
2647,
15,
1393,
15,
24853,
523,
2274,
26,
754,
199,
199,
13,
3105,
26,
2729,
29,
1099,
199,
199,
13,
536,
26,
12175,
1006,
2860,
15,
5047,
6040,
367,
282,
1591,
523,
3105,
26,
2729,
29,
23265,
59,
7212,
63,
4269,
61,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
nolanliou/tensorflow
|
tensorflow/contrib/learn/python/learn/estimators/kmeans.py
|
15
|
10904
|
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Implementation of k-means clustering on top of `Estimator` API.
This module is deprecated. Please use
@{tf.contrib.factorization.KMeansClustering} instead of
@{tf.contrib.learn.KMeansClustering}. It has a similar interface, but uses the
@{tf.estimator.Estimator} API instead of @{tf.contrib.learn.Estimator}.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import time
import numpy as np
from tensorflow.contrib.factorization.python.ops import clustering_ops
from tensorflow.python.training import training_util
from tensorflow.contrib.learn.python.learn.estimators import estimator
from tensorflow.contrib.learn.python.learn.estimators.model_fn import ModelFnOps
from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import state_ops
from tensorflow.python.ops.control_flow_ops import with_dependencies
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.summary import summary
from tensorflow.python.training import session_run_hook
from tensorflow.python.training.session_run_hook import SessionRunArgs
from tensorflow.python.util.deprecation import deprecated
_USE_TF_CONTRIB_FACTORIZATION = (
'Please use tf.contrib.factorization.KMeansClustering instead of'
' tf.contrib.learn.KMeansClustering. It has a similar interface, but uses'
' the tf.estimator.Estimator API instead of tf.contrib.learn.Estimator.')
class _LossRelativeChangeHook(session_run_hook.SessionRunHook):
"""Stops when the change in loss goes below a tolerance."""
def __init__(self, tolerance):
"""Initializes _LossRelativeChangeHook.
Args:
tolerance: A relative tolerance of change between iterations.
"""
self._tolerance = tolerance
self._prev_loss = None
def begin(self):
self._loss_tensor = ops.get_default_graph().get_tensor_by_name(
KMeansClustering.LOSS_OP_NAME + ':0')
assert self._loss_tensor is not None
def before_run(self, run_context):
del run_context
return SessionRunArgs(
fetches={KMeansClustering.LOSS_OP_NAME: self._loss_tensor})
def after_run(self, run_context, run_values):
loss = run_values.results[KMeansClustering.LOSS_OP_NAME]
assert loss is not None
if self._prev_loss is not None:
relative_change = (abs(loss - self._prev_loss) /
(1 + abs(self._prev_loss)))
if relative_change < self._tolerance:
run_context.request_stop()
self._prev_loss = loss
class _InitializeClustersHook(session_run_hook.SessionRunHook):
"""Initializes clusters or waits for cluster initialization."""
def __init__(self, init_op, is_initialized_op, is_chief):
self._init_op = init_op
self._is_chief = is_chief
self._is_initialized_op = is_initialized_op
def after_create_session(self, session, _):
assert self._init_op.graph == ops.get_default_graph()
assert self._is_initialized_op.graph == self._init_op.graph
while True:
try:
if session.run(self._is_initialized_op):
break
elif self._is_chief:
session.run(self._init_op)
else:
time.sleep(1)
except RuntimeError as e:
logging.info(e)
def _parse_tensor_or_dict(features):
"""Helper function to parse features."""
if isinstance(features, dict):
keys = sorted(features.keys())
with ops.colocate_with(features[keys[0]]):
features = array_ops.concat([features[k] for k in keys], 1)
return features
def _kmeans_clustering_model_fn(features, labels, mode, params, config):
"""Model function for KMeansClustering estimator."""
assert labels is None, labels
(all_scores, model_predictions, losses,
is_initialized, init_op, training_op) = clustering_ops.KMeans(
_parse_tensor_or_dict(features),
params.get('num_clusters'),
initial_clusters=params.get('training_initial_clusters'),
distance_metric=params.get('distance_metric'),
use_mini_batch=params.get('use_mini_batch'),
mini_batch_steps_per_iteration=params.get(
'mini_batch_steps_per_iteration'),
random_seed=params.get('random_seed'),
kmeans_plus_plus_num_retries=params.get(
'kmeans_plus_plus_num_retries')).training_graph()
incr_step = state_ops.assign_add(training_util.get_global_step(), 1)
loss = math_ops.reduce_sum(losses, name=KMeansClustering.LOSS_OP_NAME)
summary.scalar('loss/raw', loss)
training_op = with_dependencies([training_op, incr_step], loss)
predictions = {
KMeansClustering.ALL_SCORES: all_scores[0],
KMeansClustering.CLUSTER_IDX: model_predictions[0],
}
eval_metric_ops = {KMeansClustering.SCORES: loss}
training_hooks = [_InitializeClustersHook(
init_op, is_initialized, config.is_chief)]
relative_tolerance = params.get('relative_tolerance')
if relative_tolerance is not None:
training_hooks.append(_LossRelativeChangeHook(relative_tolerance))
return ModelFnOps(
mode=mode,
predictions=predictions,
eval_metric_ops=eval_metric_ops,
loss=loss,
train_op=training_op,
training_hooks=training_hooks)
# TODO(agarwal,ands): support sharded input.
class KMeansClustering(estimator.Estimator):
"""An Estimator for K-Means clustering."""
SQUARED_EUCLIDEAN_DISTANCE = clustering_ops.SQUARED_EUCLIDEAN_DISTANCE
COSINE_DISTANCE = clustering_ops.COSINE_DISTANCE
RANDOM_INIT = clustering_ops.RANDOM_INIT
KMEANS_PLUS_PLUS_INIT = clustering_ops.KMEANS_PLUS_PLUS_INIT
SCORES = 'scores'
CLUSTER_IDX = 'cluster_idx'
CLUSTERS = 'clusters'
ALL_SCORES = 'all_scores'
LOSS_OP_NAME = 'kmeans_loss'
@deprecated(None, _USE_TF_CONTRIB_FACTORIZATION)
def __init__(self,
num_clusters,
model_dir=None,
initial_clusters=RANDOM_INIT,
distance_metric=SQUARED_EUCLIDEAN_DISTANCE,
random_seed=0,
use_mini_batch=True,
mini_batch_steps_per_iteration=1,
kmeans_plus_plus_num_retries=2,
relative_tolerance=None,
config=None):
"""Creates a model for running KMeans training and inference.
Args:
num_clusters: number of clusters to train.
model_dir: the directory to save the model results and log files.
initial_clusters: specifies how to initialize the clusters for training.
See clustering_ops.kmeans for the possible values.
distance_metric: the distance metric used for clustering.
See clustering_ops.kmeans for the possible values.
random_seed: Python integer. Seed for PRNG used to initialize centers.
use_mini_batch: If true, use the mini-batch k-means algorithm. Else assume
full batch.
mini_batch_steps_per_iteration: number of steps after which the updated
cluster centers are synced back to a master copy. See clustering_ops.py
for more details.
kmeans_plus_plus_num_retries: For each point that is sampled during
kmeans++ initialization, this parameter specifies the number of
additional points to draw from the current distribution before selecting
the best. If a negative value is specified, a heuristic is used to
sample O(log(num_to_sample)) additional points.
relative_tolerance: A relative tolerance of change in the loss between
iterations. Stops learning if the loss changes less than this amount.
Note that this may not work correctly if use_mini_batch=True.
config: See Estimator
"""
params = {}
params['num_clusters'] = num_clusters
params['training_initial_clusters'] = initial_clusters
params['distance_metric'] = distance_metric
params['random_seed'] = random_seed
params['use_mini_batch'] = use_mini_batch
params['mini_batch_steps_per_iteration'] = mini_batch_steps_per_iteration
params['kmeans_plus_plus_num_retries'] = kmeans_plus_plus_num_retries
params['relative_tolerance'] = relative_tolerance
super(KMeansClustering, self).__init__(
model_fn=_kmeans_clustering_model_fn,
params=params,
model_dir=model_dir,
config=config)
@deprecated(None, _USE_TF_CONTRIB_FACTORIZATION)
def predict_cluster_idx(self, input_fn=None):
"""Yields predicted cluster indices."""
key = KMeansClustering.CLUSTER_IDX
results = super(KMeansClustering, self).predict(
input_fn=input_fn, outputs=[key])
for result in results:
yield result[key]
@deprecated(None, _USE_TF_CONTRIB_FACTORIZATION)
def score(self, input_fn=None, steps=None):
"""Predict total sum of distances to nearest clusters.
Note that this function is different from the corresponding one in sklearn
which returns the negative of the sum of distances.
Args:
input_fn: see predict.
steps: see predict.
Returns:
Total sum of distances to nearest clusters.
"""
return np.sum(
self.evaluate(
input_fn=input_fn, steps=steps)[KMeansClustering.SCORES])
@deprecated(None, _USE_TF_CONTRIB_FACTORIZATION)
def transform(self, input_fn=None, as_iterable=False):
"""Transforms each element to distances to cluster centers.
Note that this function is different from the corresponding one in sklearn.
For SQUARED_EUCLIDEAN distance metric, sklearn transform returns the
EUCLIDEAN distance, while this function returns the SQUARED_EUCLIDEAN
distance.
Args:
input_fn: see predict.
as_iterable: see predict
Returns:
Array with same number of rows as x, and num_clusters columns, containing
distances to the cluster centers.
"""
key = KMeansClustering.ALL_SCORES
results = super(KMeansClustering, self).predict(
input_fn=input_fn,
outputs=[key],
as_iterable=as_iterable)
if not as_iterable:
return results[key]
else:
return results
@deprecated(None, _USE_TF_CONTRIB_FACTORIZATION)
def clusters(self):
"""Returns cluster centers."""
return super(KMeansClustering, self).get_variable_value(self.CLUSTERS)
|
apache-2.0
|
[
3,
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
7921,
402,
1022,
13,
11579,
19454,
641,
2746,
402,
658,
13183,
64,
3261,
14,
199,
199,
2765,
859,
365,
5906,
14,
7754,
675,
199,
32,
91,
3249,
14,
2828,
14,
4778,
2072,
14,
43,
21190,
31174,
93,
3140,
402,
199,
32,
91,
3249,
14,
2828,
14,
4643,
14,
43,
21190,
31174,
5565,
2779,
965,
282,
8545,
3217,
12,
1325,
4440,
314,
199,
32,
91,
3249,
14,
8627,
14,
13183,
93,
3261,
3140,
402,
768,
91,
3249,
14,
2828,
14,
4643,
14,
13183,
5565,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
900,
199,
646,
2680,
465,
980,
199,
199,
504,
3228,
14,
2828,
14,
4778,
2072,
14,
1548,
14,
1483,
492,
19454,
63,
1483,
199,
504,
3228,
14,
1548,
14,
7588,
492,
6093,
63,
1974,
199,
504,
3228,
14,
2828,
14,
4643,
14,
1548,
14,
4643,
14,
10646,
492,
8943,
199,
504,
3228,
14,
2828,
14,
4643,
14,
1548,
14,
4643,
14,
10646,
14,
1238,
63,
2324,
492,
5822,
9656,
16452,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3473,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1174,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
2785,
63,
1659,
63,
1483,
492,
543,
63,
5714,
199,
504,
3228,
14,
1548,
14,
3246,
492,
2833,
63,
4806,
465,
2050,
199,
504,
3228,
14,
1548,
14,
4705,
492,
6212,
199,
504,
3228,
14,
1548,
14,
7588,
492,
2351,
63,
1065,
63,
3664,
199,
504,
3228,
14,
1548,
14,
7588,
14,
1730,
63,
1065,
63,
3664,
492,
8596,
2540,
6213,
199,
504,
3228,
14,
1548,
14,
1974,
14,
15383,
492,
5906,
199,
199,
63,
4701,
63,
6145,
63,
1864,
1766,
2100,
63,
18164,
7123,
2594,
275,
334,
272,
283,
8254,
675,
2833,
14,
2828,
14,
4778,
2072,
14,
43,
21190,
31174,
3140,
402,
7,
272,
283,
2833,
14,
2828,
14,
4643,
14,
43,
21190,
31174,
14,
2779,
965,
282,
8545,
3217,
12,
1325,
4440,
7,
272,
283,
314,
2833,
14,
8627,
14,
13183,
3261,
3140,
402,
2833,
14,
2828,
14,
4643,
14,
13183,
2659,
421,
199,
533,
485,
8610,
15277,
4001,
8481,
8,
1730,
63,
1065,
63,
3664,
14,
4434,
2540,
8481,
304,
523,
408,
933,
1483,
1380,
314,
1570,
315,
5621,
13538,
5084,
282,
13464,
1041,
819,
347,
636,
826,
721,
277,
12,
13464,
304,
272,
408,
23489,
485,
8610,
15277,
4001,
8481,
14,
339,
3033,
26,
489,
13464,
26,
437,
3847,
13464,
402,
1570,
3382,
10615,
14,
272,
408,
272,
291,
423,
16312,
275,
13464,
272,
291,
423,
5701,
63,
4358,
275,
488,
819,
347,
5386,
8,
277,
304,
272,
291,
423,
4358,
63,
3128,
275,
4156,
14,
362,
63,
885,
63,
2180,
1252,
362,
63,
3128,
63,
991,
63,
354,
8,
267,
1804,
21190,
31174,
14,
28010,
63,
1938,
63,
2339,
435,
7596,
16,
358,
272,
702,
291,
423,
4358,
63,
3128,
365,
440,
488,
819,
347,
2544,
63,
1065,
8,
277,
12,
1255,
63,
1100,
304,
272,
2150,
1255,
63,
1100,
272,
372,
8596,
2540,
6213,
8,
267,
28053,
3126,
43,
21190,
31174,
14,
28010,
63,
1938,
63,
2339,
26,
291,
423,
4358,
63,
3128,
1552,
819,
347,
2410,
63,
1065,
8,
277,
12,
1255,
63,
1100,
12,
1255,
63,
1459,
304,
272,
5621,
275,
1255,
63,
1459,
14,
2604,
59,
43,
21190,
31174,
14,
28010,
63,
1938,
63,
2339,
61,
272,
702,
5621,
365,
440,
488,
272,
340,
291,
423,
5701,
63,
4358,
365,
440,
488,
26,
489,
3847,
63,
1461,
275,
334,
2101,
8,
4358,
446,
291,
423,
5701,
63,
4358,
9,
1182,
586,
334,
17,
435,
2853,
8,
277,
423,
5701,
63,
4358,
1724,
489,
340,
3847,
63,
1461,
665,
291,
423,
16312,
26,
267,
1255,
63,
1100,
14,
1069,
63,
2379,
342,
272,
291,
423,
5701,
63,
4358,
275,
5621,
421,
199,
533,
485,
9345,
1968,
6811,
8481,
8,
1730,
63,
1065,
63,
3664,
14,
4434,
2540,
8481,
304,
523,
408,
23489,
13865,
503,
14442,
1405,
367,
4350,
11097,
1041,
819,
347,
636,
826,
721,
277,
12,
4205,
63,
411,
12,
365,
63,
12486,
63,
411,
12,
365,
63,
30556,
304,
272,
291,
423,
826,
63,
411,
275,
4205,
63,
411,
272,
291,
423,
374,
63,
30556,
275,
365,
63,
30556,
272,
291,
423,
374,
63,
12486,
63,
411,
275,
365,
63,
12486,
63,
411,
819,
347,
2410,
63,
981,
63,
1730,
8,
277,
12,
2351,
12,
27574,
272,
702,
291,
423,
826,
63,
411,
14,
2180,
508,
4156,
14,
362,
63,
885,
63,
2180,
342,
272,
702,
291,
423,
374,
63,
12486,
63,
411,
14,
2180,
508,
291,
423,
826,
63,
411,
14,
2180,
272,
1830,
715,
26,
489,
862,
26,
267,
340,
2351,
14,
1065,
8,
277,
423,
374,
63,
12486,
63,
411,
304,
881,
2059,
267,
916,
291,
423,
374,
63,
30556,
26,
881,
2351,
14,
1065,
8,
277,
423,
826,
63,
411,
9,
267,
587,
26,
881,
900,
14,
4532,
8,
17,
9,
489,
871,
6064,
465,
325,
26,
267,
2050,
14,
815,
8,
69,
9,
421,
199,
318,
485,
1122,
63,
3128,
63,
269,
63,
807,
8,
3179,
304
] |
[
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
7921,
402,
1022,
13,
11579,
19454,
641,
2746,
402,
658,
13183,
64,
3261,
14,
199,
199,
2765,
859,
365,
5906,
14,
7754,
675,
199,
32,
91,
3249,
14,
2828,
14,
4778,
2072,
14,
43,
21190,
31174,
93,
3140,
402,
199,
32,
91,
3249,
14,
2828,
14,
4643,
14,
43,
21190,
31174,
5565,
2779,
965,
282,
8545,
3217,
12,
1325,
4440,
314,
199,
32,
91,
3249,
14,
8627,
14,
13183,
93,
3261,
3140,
402,
768,
91,
3249,
14,
2828,
14,
4643,
14,
13183,
5565,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
199,
504,
636,
2443,
363,
492,
4629,
199,
504,
636,
2443,
363,
492,
870,
63,
1593,
199,
199,
646,
900,
199,
646,
2680,
465,
980,
199,
199,
504,
3228,
14,
2828,
14,
4778,
2072,
14,
1548,
14,
1483,
492,
19454,
63,
1483,
199,
504,
3228,
14,
1548,
14,
7588,
492,
6093,
63,
1974,
199,
504,
3228,
14,
2828,
14,
4643,
14,
1548,
14,
4643,
14,
10646,
492,
8943,
199,
504,
3228,
14,
2828,
14,
4643,
14,
1548,
14,
4643,
14,
10646,
14,
1238,
63,
2324,
492,
5822,
9656,
16452,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4156,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1625,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
3473,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
492,
1174,
63,
1483,
199,
504,
3228,
14,
1548,
14,
1483,
14,
2785,
63,
1659,
63,
1483,
492,
543,
63,
5714,
199,
504,
3228,
14,
1548,
14,
3246,
492,
2833,
63,
4806,
465,
2050,
199,
504,
3228,
14,
1548,
14,
4705,
492,
6212,
199,
504,
3228,
14,
1548,
14,
7588,
492,
2351,
63,
1065,
63,
3664,
199,
504,
3228,
14,
1548,
14,
7588,
14,
1730,
63,
1065,
63,
3664,
492,
8596,
2540,
6213,
199,
504,
3228,
14,
1548,
14,
1974,
14,
15383,
492,
5906,
199,
199,
63,
4701,
63,
6145,
63,
1864,
1766,
2100,
63,
18164,
7123,
2594,
275,
334,
272,
283,
8254,
675,
2833,
14,
2828,
14,
4778,
2072,
14,
43,
21190,
31174,
3140,
402,
7,
272,
283,
2833,
14,
2828,
14,
4643,
14,
43,
21190,
31174,
14,
2779,
965,
282,
8545,
3217,
12,
1325,
4440,
7,
272,
283,
314,
2833,
14,
8627,
14,
13183,
3261,
3140,
402,
2833,
14,
2828,
14,
4643,
14,
13183,
2659,
421,
199,
533,
485,
8610,
15277,
4001,
8481,
8,
1730,
63,
1065,
63,
3664,
14,
4434,
2540,
8481,
304,
523,
408,
933,
1483,
1380,
314,
1570,
315,
5621,
13538,
5084,
282,
13464,
1041,
819,
347,
636,
826,
721,
277,
12,
13464,
304,
272,
408,
23489,
485,
8610,
15277,
4001,
8481,
14,
339,
3033,
26,
489,
13464,
26,
437,
3847,
13464,
402,
1570,
3382,
10615,
14,
272,
408,
272,
291,
423,
16312,
275,
13464,
272,
291,
423,
5701,
63,
4358,
275,
488,
819,
347,
5386,
8,
277,
304,
272,
291,
423,
4358,
63,
3128,
275,
4156,
14,
362,
63,
885,
63,
2180,
1252,
362,
63,
3128,
63,
991,
63,
354,
8,
267,
1804,
21190,
31174,
14,
28010,
63,
1938,
63,
2339,
435,
7596,
16,
358,
272,
702,
291,
423,
4358,
63,
3128,
365,
440,
488,
819,
347,
2544,
63,
1065,
8,
277,
12,
1255,
63,
1100,
304,
272,
2150,
1255,
63,
1100,
272,
372,
8596,
2540,
6213,
8,
267,
28053,
3126,
43,
21190,
31174,
14,
28010,
63,
1938,
63,
2339,
26,
291,
423,
4358,
63,
3128,
1552,
819,
347,
2410,
63,
1065,
8,
277,
12,
1255,
63,
1100,
12,
1255,
63,
1459,
304,
272,
5621,
275,
1255,
63,
1459,
14,
2604,
59,
43,
21190,
31174,
14,
28010,
63,
1938,
63,
2339,
61,
272,
702,
5621,
365,
440,
488,
272,
340,
291,
423,
5701,
63,
4358,
365,
440,
488,
26,
489,
3847,
63,
1461,
275,
334,
2101,
8,
4358,
446,
291,
423,
5701,
63,
4358,
9,
1182,
586,
334,
17,
435,
2853,
8,
277,
423,
5701,
63,
4358,
1724,
489,
340,
3847,
63,
1461,
665,
291,
423,
16312,
26,
267,
1255,
63,
1100,
14,
1069,
63,
2379,
342,
272,
291,
423,
5701,
63,
4358,
275,
5621,
421,
199,
533,
485,
9345,
1968,
6811,
8481,
8,
1730,
63,
1065,
63,
3664,
14,
4434,
2540,
8481,
304,
523,
408,
23489,
13865,
503,
14442,
1405,
367,
4350,
11097,
1041,
819,
347,
636,
826,
721,
277,
12,
4205,
63,
411,
12,
365,
63,
12486,
63,
411,
12,
365,
63,
30556,
304,
272,
291,
423,
826,
63,
411,
275,
4205,
63,
411,
272,
291,
423,
374,
63,
30556,
275,
365,
63,
30556,
272,
291,
423,
374,
63,
12486,
63,
411,
275,
365,
63,
12486,
63,
411,
819,
347,
2410,
63,
981,
63,
1730,
8,
277,
12,
2351,
12,
27574,
272,
702,
291,
423,
826,
63,
411,
14,
2180,
508,
4156,
14,
362,
63,
885,
63,
2180,
342,
272,
702,
291,
423,
374,
63,
12486,
63,
411,
14,
2180,
508,
291,
423,
826,
63,
411,
14,
2180,
272,
1830,
715,
26,
489,
862,
26,
267,
340,
2351,
14,
1065,
8,
277,
423,
374,
63,
12486,
63,
411,
304,
881,
2059,
267,
916,
291,
423,
374,
63,
30556,
26,
881,
2351,
14,
1065,
8,
277,
423,
826,
63,
411,
9,
267,
587,
26,
881,
900,
14,
4532,
8,
17,
9,
489,
871,
6064,
465,
325,
26,
267,
2050,
14,
815,
8,
69,
9,
421,
199,
318,
485,
1122,
63,
3128,
63,
269,
63,
807,
8,
3179,
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,
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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
] |
roadmapper/ansible
|
lib/ansible/modules/network/meraki/meraki_nat.py
|
6
|
29958
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2019, Kevin Breit (@kbreit) <kevin.breit@kevinbreit.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {
'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'
}
DOCUMENTATION = r'''
---
module: meraki_nat
short_description: Manage NAT rules in Meraki cloud
version_added: "2.9"
description:
- Allows for creation, management, and visibility of NAT rules (1:1, 1:many, port forwarding) within Meraki.
options:
state:
description:
- Create or modify an organization.
choices: [present, query]
default: present
type: str
net_name:
description:
- Name of a network.
aliases: [name, network]
type: str
net_id:
description:
- ID number of a network.
type: str
org_id:
description:
- ID of organization associated to a network.
type: str
subset:
description:
- Specifies which NAT components to query.
choices: ['1:1', '1:many', all, port_forwarding]
default: all
type: list
one_to_one:
description:
- List of 1:1 NAT rules.
type: list
suboptions:
name:
description:
- A descriptive name for the rule.
type: str
public_ip:
description:
- The IP address that will be used to access the internal resource from the WAN.
type: str
lan_ip:
description:
- The IP address of the server or device that hosts the internal resource that you wish to make available on the WAN.
type: str
uplink:
description:
- The physical WAN interface on which the traffic will arrive.
choices: [both, internet1, internet2]
type: str
allowed_inbound:
description:
- The ports this mapping will provide access on, and the remote IPs that will be allowed access to the resource.
type: list
suboptions:
protocol:
description:
- Protocol to apply NAT rule to.
choices: [any, icmp-ping, tcp, udp]
type: str
default: any
destination_ports:
description:
- List of ports or port ranges that will be forwarded to the host on the LAN.
type: list
allowed_ips:
description:
- ranges of WAN IP addresses that are allowed to make inbound connections on the specified ports or port ranges, or 'any'.
type: list
one_to_many:
description:
- List of 1:many NAT rules.
type: list
suboptions:
public_ip:
description:
- The IP address that will be used to access the internal resource from the WAN.
type: str
uplink:
description:
- The physical WAN interface on which the traffic will arrive.
choices: [both, internet1, internet2]
type: str
port_rules:
description:
- List of associated port rules.
type: list
suboptions:
name:
description:
- A description of the rule.
type: str
protocol:
description:
- Protocol to apply NAT rule to.
choices: [tcp, udp]
type: str
public_port:
description:
- Destination port of the traffic that is arriving on the WAN.
type: str
local_ip:
description:
- Local IP address to which traffic will be forwarded.
type: str
local_port:
description:
- Destination port of the forwarded traffic that will be sent from the MX to the specified host on the LAN.
- If you simply wish to forward the traffic without translating the port, this should be the same as the Public port.
type: str
allowed_ips:
description:
- Remote IP addresses or ranges that are permitted to access the internal resource via this port forwarding rule, or 'any'.
type: list
port_forwarding:
description:
- List of port forwarding rules.
type: list
suboptions:
name:
description:
- A descriptive name for the rule.
type: str
lan_ip:
description:
- The IP address of the server or device that hosts the internal resource that you wish to make available on the WAN.
type: str
uplink:
description:
- The physical WAN interface on which the traffic will arrive.
choices: [both, internet1, internet2]
type: str
public_port:
description:
- A port or port ranges that will be forwarded to the host on the LAN.
type: int
local_port:
description:
- A port or port ranges that will receive the forwarded traffic from the WAN.
type: int
allowed_ips:
description:
- List of ranges of WAN IP addresses that are allowed to make inbound connections on the specified ports or port ranges (or any).
type: list
protocol:
description:
- Protocol to forward traffic for.
choices: [tcp, udp]
type: str
author:
- Kevin Breit (@kbreit)
extends_documentation_fragment: meraki
'''
EXAMPLES = r'''
- name: Query all NAT rules
meraki_nat:
auth_key: abc123
org_name: YourOrg
net_name: YourNet
state: query
subset: all
delegate_to: localhost
- name: Query 1:1 NAT rules
meraki_nat:
auth_key: abc123
org_name: YourOrg
net_name: YourNet
state: query
subset: '1:1'
delegate_to: localhost
- name: Create 1:1 rule
meraki_nat:
auth_key: abc123
org_name: YourOrg
net_name: YourNet
state: present
one_to_one:
- name: Service behind NAT
public_ip: 1.2.1.2
lan_ip: 192.168.128.1
uplink: internet1
allowed_inbound:
- protocol: tcp
destination_ports:
- 80
allowed_ips:
- 10.10.10.10
delegate_to: localhost
- name: Create 1:many rule
meraki_nat:
auth_key: abc123
org_name: YourOrg
net_name: YourNet
state: present
one_to_many:
- public_ip: 1.1.1.1
uplink: internet1
port_rules:
- name: Test rule
protocol: tcp
public_port: 10
local_ip: 192.168.128.1
local_port: 11
allowed_ips:
- any
delegate_to: localhost
- name: Create port forwarding rule
meraki_nat:
auth_key: abc123
org_name: YourOrg
net_name: YourNet
state: present
port_forwarding:
- name: Test map
lan_ip: 192.168.128.1
uplink: both
protocol: tcp
allowed_ips:
- 1.1.1.1
public_port: 10
local_port: 11
delegate_to: localhost
'''
RETURN = r'''
data:
description: Information about the created or manipulated object.
returned: success
type: complex
contains:
one_to_one:
description: Information about 1:1 NAT object.
returned: success, when 1:1 NAT object is in task
type: complex
contains:
rules:
description: List of 1:1 NAT rules.
returned: success, when 1:1 NAT object is in task
type: complex
contains:
name:
description: Name of NAT object.
returned: success, when 1:1 NAT object is in task
type: str
example: Web server behind NAT
lanIp:
description: Local IP address to be mapped.
returned: success, when 1:1 NAT object is in task
type: str
example: 192.168.128.22
publicIp:
description: Public IP address to be mapped.
returned: success, when 1:1 NAT object is in task
type: str
example: 148.2.5.100
uplink:
description: Internet port where rule is applied.
returned: success, when 1:1 NAT object is in task
type: str
example: internet1
allowedInbound:
description: List of inbound forwarding rules.
returned: success, when 1:1 NAT object is in task
type: complex
contains:
protocol:
description: Protocol to apply NAT rule to.
returned: success, when 1:1 NAT object is in task
type: str
example: tcp
destinationPorts:
description: Ports to apply NAT rule to.
returned: success, when 1:1 NAT object is in task
type: str
example: 80
allowedIps:
description: List of IP addresses to be forwarded.
returned: success, when 1:1 NAT object is in task
type: list
example: 10.80.100.0/24
one_to_many:
description: Information about 1:many NAT object.
returned: success, when 1:many NAT object is in task
type: complex
contains:
rules:
description: List of 1:many NAT rules.
returned: success, when 1:many NAT object is in task
type: complex
contains:
publicIp:
description: Public IP address to be mapped.
returned: success, when 1:many NAT object is in task
type: str
example: 148.2.5.100
uplink:
description: Internet port where rule is applied.
returned: success, when 1:many NAT object is in task
type: str
example: internet1
portRules:
description: List of NAT port rules.
returned: success, when 1:many NAT object is in task
type: complex
contains:
name:
description: Name of NAT object.
returned: success, when 1:many NAT object is in task
type: str
example: Web server behind NAT
protocol:
description: Protocol to apply NAT rule to.
returned: success, when 1:1 NAT object is in task
type: str
example: tcp
publicPort:
description: Destination port of the traffic that is arriving on WAN.
returned: success, when 1:1 NAT object is in task
type: int
example: 9443
localIp:
description: Local IP address traffic will be forwarded.
returned: success, when 1:1 NAT object is in task
type: str
example: 192.0.2.10
localPort:
description: Destination port to be forwarded to.
returned: success, when 1:1 NAT object is in task
type: int
example: 443
allowedIps:
description: List of IP addresses to be forwarded.
returned: success, when 1:1 NAT object is in task
type: list
example: 10.80.100.0/24
port_forwarding:
description: Information about port forwarding rules.
returned: success, when port forwarding is in task
type: complex
contains:
rules:
description: List of port forwarding rules.
returned: success, when port forwarding is in task
type: complex
contains:
lanIp:
description: Local IP address to be mapped.
returned: success, when port forwarding is in task
type: str
example: 192.168.128.22
allowedIps:
description: List of IP addresses to be forwarded.
returned: success, when port forwarding is in task
type: list
example: 10.80.100.0/24
name:
description: Name of NAT object.
returned: success, when port forwarding is in task
type: str
example: Web server behind NAT
protocol:
description: Protocol to apply NAT rule to.
returned: success, when port forwarding is in task
type: str
example: tcp
publicPort:
description: Destination port of the traffic that is arriving on WAN.
returned: success, when port forwarding is in task
type: int
example: 9443
localPort:
description: Destination port to be forwarded to.
returned: success, when port forwarding is in task
type: int
example: 443
uplink:
description: Internet port where rule is applied.
returned: success, when port forwarding is in task
type: str
example: internet1
'''
import os
from ansible.module_utils.basic import AnsibleModule, json, env_fallback
from ansible.module_utils.urls import fetch_url
from ansible.module_utils._text import to_native
from ansible.module_utils.common.dict_transformations import recursive_diff
from ansible.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
key_map = {'name': 'name',
'public_ip': 'publicIp',
'lan_ip': 'lanIp',
'uplink': 'uplink',
'allowed_inbound': 'allowedInbound',
'protocol': 'protocol',
'destination_ports': 'destinationPorts',
'allowed_ips': 'allowedIps',
'port_rules': 'portRules',
'public_port': 'publicPort',
'local_ip': 'localIp',
'local_port': 'localPort',
}
def construct_payload(params):
if isinstance(params, list):
items = []
for item in params:
items.append(construct_payload(item))
return items
elif isinstance(params, dict):
info = {}
for param in params:
info[key_map[param]] = construct_payload(params[param])
return info
elif isinstance(params, str) or isinstance(params, int):
return params
def list_int_to_str(data):
return [str(item) for item in data]
def main():
# define the available arguments/parameters that a user can pass to
# the module
one_to_one_allowed_inbound_spec = dict(protocol=dict(type='str', choices=['tcp', 'udp', 'icmp-ping', 'any'], default='any'),
destination_ports=dict(type='list', element='str'),
allowed_ips=dict(type='list'),
)
one_to_many_port_inbound_spec = dict(protocol=dict(type='str', choices=['tcp', 'udp']),
name=dict(type='str'),
local_ip=dict(type='str'),
local_port=dict(type='str'),
allowed_ips=dict(type='list'),
public_port=dict(type='str'),
)
one_to_one_spec = dict(name=dict(type='str'),
public_ip=dict(type='str'),
lan_ip=dict(type='str'),
uplink=dict(type='str', choices=['internet1', 'internet2', 'both']),
allowed_inbound=dict(type='list', element='dict', options=one_to_one_allowed_inbound_spec),
)
one_to_many_spec = dict(public_ip=dict(type='str'),
uplink=dict(type='str', choices=['internet1', 'internet2', 'both']),
port_rules=dict(type='list', element='dict', options=one_to_many_port_inbound_spec),
)
port_forwarding_spec = dict(name=dict(type='str'),
lan_ip=dict(type='str'),
uplink=dict(type='str', choices=['internet1', 'internet2', 'both']),
protocol=dict(type='str', choices=['tcp', 'udp']),
public_port=dict(type='int'),
local_port=dict(type='int'),
allowed_ips=dict(type='list'),
)
argument_spec = meraki_argument_spec()
argument_spec.update(
net_id=dict(type='str'),
net_name=dict(type='str', aliases=['name', 'network']),
state=dict(type='str', choices=['present', 'query'], default='present'),
subset=dict(type='list', choices=['1:1', '1:many', 'all', 'port_forwarding'], default='all'),
one_to_one=dict(type='list', elements='dict', options=one_to_one_spec),
one_to_many=dict(type='list', elements='dict', options=one_to_many_spec),
port_forwarding=dict(type='list', elements='dict', options=port_forwarding_spec),
)
# the AnsibleModule object will be our abstraction working with Ansible
# this includes instantiation, a couple of common attr would be the
# args/params passed to the execution, as well as if the module
# supports check mode
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True,
)
meraki = MerakiModule(module, function='nat')
module.params['follow_redirects'] = 'all'
one_to_one_payload = None
one_to_many_payload = None
port_forwarding_payload = None
if meraki.params['state'] == 'present':
if meraki.params['one_to_one'] is not None:
rules = []
for i in meraki.params['one_to_one']:
data = {'name': i['name'],
'publicIp': i['public_ip'],
'uplink': i['uplink'],
'lanIp': i['lan_ip'],
'allowedInbound': construct_payload(i['allowed_inbound'])
}
for inbound in data['allowedInbound']:
inbound['destinationPorts'] = list_int_to_str(inbound['destinationPorts'])
rules.append(data)
one_to_one_payload = {'rules': rules}
if meraki.params['one_to_many'] is not None:
rules = []
for i in meraki.params['one_to_many']:
data = {'publicIp': i['public_ip'],
'uplink': i['uplink'],
}
port_rules = []
for port_rule in i['port_rules']:
rule = {'name': port_rule['name'],
'protocol': port_rule['protocol'],
'publicPort': str(port_rule['public_port']),
'localIp': port_rule['local_ip'],
'localPort': str(port_rule['local_port']),
'allowedIps': port_rule['allowed_ips'],
}
port_rules.append(rule)
data['portRules'] = port_rules
rules.append(data)
one_to_many_payload = {'rules': rules}
if meraki.params['port_forwarding'] is not None:
port_forwarding_payload = {'rules': construct_payload(meraki.params['port_forwarding'])}
for rule in port_forwarding_payload['rules']:
rule['localPort'] = str(rule['localPort'])
rule['publicPort'] = str(rule['publicPort'])
onetomany_urls = {'nat': '/networks/{net_id}/oneToManyNatRules'}
onetoone_urls = {'nat': '/networks/{net_id}/oneToOneNatRules'}
port_forwarding_urls = {'nat': '/networks/{net_id}/portForwardingRules'}
meraki.url_catalog['1:many'] = onetomany_urls
meraki.url_catalog['1:1'] = onetoone_urls
meraki.url_catalog['port_forwarding'] = port_forwarding_urls
if meraki.params['net_name'] and meraki.params['net_id']:
meraki.fail_json(msg='net_name and net_id are mutually exclusive')
org_id = meraki.params['org_id']
if not org_id:
org_id = meraki.get_org_id(meraki.params['org_name'])
net_id = meraki.params['net_id']
if net_id is None:
nets = meraki.get_nets(org_id=org_id)
net_id = meraki.get_net_id(org_id, meraki.params['net_name'], data=nets)
if meraki.params['state'] == 'query':
if meraki.params['subset'][0] == 'all':
path = meraki.construct_path('1:many', net_id=net_id)
data = {'1:many': meraki.request(path, method='GET')}
path = meraki.construct_path('1:1', net_id=net_id)
data['1:1'] = meraki.request(path, method='GET')
path = meraki.construct_path('port_forwarding', net_id=net_id)
data['port_forwarding'] = meraki.request(path, method='GET')
meraki.result['data'] = data
else:
for subset in meraki.params['subset']:
path = meraki.construct_path(subset, net_id=net_id)
data = {subset: meraki.request(path, method='GET')}
try:
meraki.result['data'][subset] = data
except KeyError:
meraki.result['data'] = {subset: data}
elif meraki.params['state'] == 'present':
meraki.result['data'] = dict()
if one_to_one_payload is not None:
path = meraki.construct_path('1:1', net_id=net_id)
current = meraki.request(path, method='GET')
if meraki.is_update_required(current, one_to_one_payload):
if meraki.module.check_mode is True:
diff = recursive_diff(current, one_to_one_payload)
current.update(one_to_one_payload)
if 'diff' not in meraki.result:
meraki.result['diff'] = {'before': {}, 'after': {}}
meraki.result['diff']['before'].update({'one_to_one': diff[0]})
meraki.result['diff']['after'].update({'one_to_one': diff[1]})
meraki.result['data'] = {'one_to_one': current}
meraki.result['changed'] = True
else:
r = meraki.request(path, method='PUT', payload=json.dumps(one_to_one_payload))
if meraki.status == 200:
diff = recursive_diff(current, one_to_one_payload)
if 'diff' not in meraki.result:
meraki.result['diff'] = {'before': {}, 'after': {}}
meraki.result['diff']['before'].update({'one_to_one': diff[0]})
meraki.result['diff']['after'].update({'one_to_one': diff[1]})
meraki.result['data'] = {'one_to_one': r}
meraki.result['changed'] = True
else:
meraki.result['data']['one_to_one'] = current
if one_to_many_payload is not None:
path = meraki.construct_path('1:many', net_id=net_id)
current = meraki.request(path, method='GET')
if meraki.is_update_required(current, one_to_many_payload):
if meraki.module.check_mode is True:
diff = recursive_diff(current, one_to_many_payload)
current.update(one_to_many_payload)
if 'diff' not in meraki.result:
meraki.result['diff'] = {'before': {}, 'after': {}}
meraki.result['diff']['before'].update({'one_to_many': diff[0]})
meraki.result['diff']['after'].update({'one_to_many': diff[1]})
meraki.result['data']['one_to_many'] = current
meraki.result['changed'] = True
else:
r = meraki.request(path, method='PUT', payload=json.dumps(one_to_many_payload))
if meraki.status == 200:
diff = recursive_diff(current, one_to_many_payload)
if 'diff' not in meraki.result:
meraki.result['diff'] = {'before': {}, 'after': {}}
meraki.result['diff']['before'].update({'one_to_many': diff[0]})
meraki.result['diff']['after'].update({'one_to_many': diff[1]})
meraki.result['data'].update({'one_to_many': r})
meraki.result['changed'] = True
else:
meraki.result['data']['one_to_many'] = current
if port_forwarding_payload is not None:
path = meraki.construct_path('port_forwarding', net_id=net_id)
current = meraki.request(path, method='GET')
if meraki.is_update_required(current, port_forwarding_payload):
if meraki.module.check_mode is True:
diff = recursive_diff(current, port_forwarding_payload)
current.update(port_forwarding_payload)
if 'diff' not in meraki.result:
meraki.result['diff'] = {'before': {}, 'after': {}}
meraki.result['diff']['before'].update({'port_forwarding': diff[0]})
meraki.result['diff']['after'].update({'port_forwarding': diff[1]})
meraki.result['data']['port_forwarding'] = current
meraki.result['changed'] = True
else:
r = meraki.request(path, method='PUT', payload=json.dumps(port_forwarding_payload))
if meraki.status == 200:
if 'diff' not in meraki.result:
meraki.result['diff'] = {'before': {}, 'after': {}}
diff = recursive_diff(current, port_forwarding_payload)
meraki.result['diff']['before'].update({'port_forwarding': diff[0]})
meraki.result['diff']['after'].update({'port_forwarding': diff[1]})
meraki.result['data'].update({'port_forwarding': r})
meraki.result['changed'] = True
else:
meraki.result['data']['port_forwarding'] = current
# in the event of a successful module execution, you will want to
# simple AnsibleModule.exit_json(), passing the key/value results
meraki.exit_json(**meraki.result)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
26,
334,
67,
9,
20312,
12,
25645,
11908,
699,
264,
390,
8593,
7862,
264,
390,
9,
665,
415,
11908,
14,
10205,
390,
32,
415,
11908,
10205,
390,
14,
846,
30,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
199,
199,
8490,
63,
8314,
275,
469,
272,
283,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
272,
283,
1205,
356,
788,
7780,
995,
272,
283,
4946,
63,
991,
356,
283,
9387,
7,
199,
93,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
23477,
63,
9468,
199,
3612,
63,
1802,
26,
14944,
31363,
4713,
315,
18880,
27387,
8002,
199,
1023,
63,
3270,
26,
298,
18,
14,
25,
2,
199,
1802,
26,
199,
13,
22819,
367,
7143,
12,
10041,
12,
436,
6887,
402,
31363,
4713,
334,
17,
26,
17,
12,
413,
26,
3479,
12,
1844,
24119,
9,
4453,
18880,
27387,
14,
199,
199,
1419,
26,
272,
1174,
26,
267,
1369,
26,
267,
446,
2790,
503,
2811,
376,
13237,
14,
267,
3415,
26,
359,
1881,
12,
1827,
61,
267,
849,
26,
3451,
267,
730,
26,
620,
272,
1851,
63,
354,
26,
267,
1369,
26,
267,
446,
2812,
402,
282,
2784,
14,
267,
5481,
26,
359,
354,
12,
2784,
61,
267,
730,
26,
620,
272,
1851,
63,
344,
26,
267,
1369,
26,
267,
446,
2870,
1329,
402,
282,
2784,
14,
267,
730,
26,
620,
272,
5981,
63,
344,
26,
267,
1369,
26,
267,
446,
2870,
402,
13237,
4568,
370,
282,
2784,
14,
267,
730,
26,
620,
272,
10026,
26,
267,
1369,
26,
267,
446,
11015,
1314,
31363,
7323,
370,
1827,
14,
267,
3415,
26,
788,
17,
26,
17,
297,
283,
17,
26,
3479,
297,
1006,
12,
1844,
63,
21513,
61,
267,
849,
26,
1006,
267,
730,
26,
769,
272,
1373,
63,
475,
63,
368,
26,
267,
1369,
26,
267,
446,
3820,
402,
413,
26,
17,
31363,
4713,
14,
267,
730,
26,
769,
267,
26265,
26,
288,
536,
26,
355,
1369,
26,
355,
446,
437,
30262,
536,
367,
314,
2332,
14,
355,
730,
26,
620,
288,
4575,
63,
711,
26,
355,
1369,
26,
355,
446,
710,
3531,
2287,
626,
911,
506,
1202,
370,
2879,
314,
5007,
2073,
687,
314,
644,
879,
14,
355,
730,
26,
620,
288,
634,
290,
63,
711,
26,
355,
1369,
26,
355,
446,
710,
3531,
2287,
402,
314,
1654,
503,
2243,
626,
7057,
314,
5007,
2073,
626,
1265,
13809,
370,
1852,
2808,
641,
314,
644,
879,
14,
355,
730,
26,
620,
288,
1536,
1073,
26,
355,
1369,
26,
355,
446,
710,
14095,
644,
879,
3217,
641,
1314,
314,
15602,
911,
601,
6053,
14,
355,
3415,
26,
359,
10727,
12,
21408,
17,
12,
21408,
18,
61,
355,
730,
26,
620,
288,
4370,
63,
26108,
26,
355,
1369,
26,
355,
446,
710,
8873,
642,
4412,
911,
5647,
2879,
641,
12,
436,
314,
3982,
30657,
626,
911,
506,
4370,
2879,
370,
314,
2073,
14,
355,
730,
26,
769,
355,
26265,
26,
490,
4113,
26,
717,
1369,
26,
717,
446,
11557,
370,
4838,
31363,
2332,
370,
14,
717,
3415,
26,
359,
1629,
12,
20663,
13,
4073,
12,
14719,
12,
18419,
61,
717,
730,
26,
620,
717,
849,
26,
1263,
490,
5724,
63,
5203,
26,
717,
1369,
26,
717,
446,
3820,
402,
8873,
503,
1844,
12271,
626,
911,
506,
24172,
370,
314,
1591,
641,
314,
491,
879,
14,
717,
730,
26,
769,
490,
4370,
63,
6142,
26,
717,
1369,
26,
717,
446,
12271,
402,
644,
879,
3531,
7149,
626,
787,
4370,
370,
1852,
30819,
6947,
641,
314,
2013,
8873,
503,
1844,
12271,
12,
503,
283,
1629,
1370,
717,
730,
26,
769,
272,
1373,
63,
475,
63,
3479,
26,
267,
1369,
26,
267,
446,
3820,
402,
413,
26,
3479,
31363,
4713,
14,
267,
730,
26,
769,
267,
26265,
26,
288,
4575,
63,
711,
26,
355,
1369,
26,
355,
446,
710,
3531,
2287,
626,
911,
506,
1202,
370,
2879,
314,
5007,
2073,
687,
314,
644,
879,
14,
355,
730,
26,
620,
288,
1536,
1073,
26,
355,
1369,
26,
355,
446,
710,
14095,
644,
879,
3217,
641,
1314,
314,
15602,
911,
601,
6053,
14,
355,
3415,
26,
359,
10727,
12,
21408,
17,
12,
21408,
18,
61,
355,
730,
26,
620,
288,
1844,
63,
4423,
26,
355,
1369,
26,
355,
446,
3820,
402,
4568,
1844,
4713,
14,
355,
730,
26,
769,
355,
26265,
26,
490,
536,
26,
717,
1369,
26,
717,
446,
437,
1369,
402,
314,
2332,
14,
717,
730,
26,
620,
490,
4113,
26,
717,
1369,
26,
717,
446,
11557,
370,
4838,
31363,
2332,
370,
14,
717,
3415,
26,
359,
8815,
12,
18419,
61,
717,
730,
26,
620,
490,
4575,
63,
719,
26,
717,
1369,
26,
717,
446,
28505,
1844,
402,
314,
15602,
626,
365,
601,
322,
4007,
641,
314,
644,
879,
14,
717,
730,
26,
620,
490,
2257,
63,
711,
26,
717,
1369,
26,
717,
446,
10111,
3531,
2287,
370,
1314,
15602,
911,
506,
24172,
14,
717,
730,
26,
620,
490,
2257,
63,
719,
26,
717,
1369,
26,
717,
446,
28505,
1844,
402,
314,
24172,
15602,
626,
911,
506,
4847,
687,
314,
603,
56,
370,
314,
2013,
1591,
641,
314,
491,
879,
14,
717,
446,
982,
1265,
9329,
13809,
370,
7568,
314,
15602,
1928,
1752,
24615,
314,
1844,
12,
642,
1077,
506,
314,
2011,
465,
314,
1684,
1844,
14,
717,
730,
26,
620,
490,
4370,
63,
6142,
26,
717,
1369,
26,
717,
446,
17283,
3531,
7149,
503,
12271,
626,
787,
8211,
370,
2879,
314,
5007,
2073,
4799,
642,
1844,
24119,
2332,
12,
503,
283,
1629,
1370,
717,
730,
26,
769,
272,
1844,
63,
21513,
26,
267,
1369,
26,
267,
446,
3820,
402,
1844,
24119,
4713,
14,
267,
730,
26,
769,
267,
26265,
26,
288,
536,
26,
355,
1369,
26,
355,
446,
437,
30262,
536,
367,
314,
2332,
14,
355,
730,
26,
620,
288,
634,
290,
63,
711,
26,
355,
1369,
26,
355,
446
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
1898,
26,
334,
67,
9,
20312,
12,
25645,
11908,
699,
264,
390,
8593,
7862,
264,
390,
9,
665,
415,
11908,
14,
10205,
390,
32,
415,
11908,
10205,
390,
14,
846,
30,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
11,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
199,
363,
6577,
363,
275,
730,
199,
199,
8490,
63,
8314,
275,
469,
272,
283,
2343,
63,
1023,
356,
283,
17,
14,
17,
297,
272,
283,
1205,
356,
788,
7780,
995,
272,
283,
4946,
63,
991,
356,
283,
9387,
7,
199,
93,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
578,
26,
23477,
63,
9468,
199,
3612,
63,
1802,
26,
14944,
31363,
4713,
315,
18880,
27387,
8002,
199,
1023,
63,
3270,
26,
298,
18,
14,
25,
2,
199,
1802,
26,
199,
13,
22819,
367,
7143,
12,
10041,
12,
436,
6887,
402,
31363,
4713,
334,
17,
26,
17,
12,
413,
26,
3479,
12,
1844,
24119,
9,
4453,
18880,
27387,
14,
199,
199,
1419,
26,
272,
1174,
26,
267,
1369,
26,
267,
446,
2790,
503,
2811,
376,
13237,
14,
267,
3415,
26,
359,
1881,
12,
1827,
61,
267,
849,
26,
3451,
267,
730,
26,
620,
272,
1851,
63,
354,
26,
267,
1369,
26,
267,
446,
2812,
402,
282,
2784,
14,
267,
5481,
26,
359,
354,
12,
2784,
61,
267,
730,
26,
620,
272,
1851,
63,
344,
26,
267,
1369,
26,
267,
446,
2870,
1329,
402,
282,
2784,
14,
267,
730,
26,
620,
272,
5981,
63,
344,
26,
267,
1369,
26,
267,
446,
2870,
402,
13237,
4568,
370,
282,
2784,
14,
267,
730,
26,
620,
272,
10026,
26,
267,
1369,
26,
267,
446,
11015,
1314,
31363,
7323,
370,
1827,
14,
267,
3415,
26,
788,
17,
26,
17,
297,
283,
17,
26,
3479,
297,
1006,
12,
1844,
63,
21513,
61,
267,
849,
26,
1006,
267,
730,
26,
769,
272,
1373,
63,
475,
63,
368,
26,
267,
1369,
26,
267,
446,
3820,
402,
413,
26,
17,
31363,
4713,
14,
267,
730,
26,
769,
267,
26265,
26,
288,
536,
26,
355,
1369,
26,
355,
446,
437,
30262,
536,
367,
314,
2332,
14,
355,
730,
26,
620,
288,
4575,
63,
711,
26,
355,
1369,
26,
355,
446,
710,
3531,
2287,
626,
911,
506,
1202,
370,
2879,
314,
5007,
2073,
687,
314,
644,
879,
14,
355,
730,
26,
620,
288,
634,
290,
63,
711,
26,
355,
1369,
26,
355,
446,
710,
3531,
2287,
402,
314,
1654,
503,
2243,
626,
7057,
314,
5007,
2073,
626,
1265,
13809,
370,
1852,
2808,
641,
314,
644,
879,
14,
355,
730,
26,
620,
288,
1536,
1073,
26,
355,
1369,
26,
355,
446,
710,
14095,
644,
879,
3217,
641,
1314,
314,
15602,
911,
601,
6053,
14,
355,
3415,
26,
359,
10727,
12,
21408,
17,
12,
21408,
18,
61,
355,
730,
26,
620,
288,
4370,
63,
26108,
26,
355,
1369,
26,
355,
446,
710,
8873,
642,
4412,
911,
5647,
2879,
641,
12,
436,
314,
3982,
30657,
626,
911,
506,
4370,
2879,
370,
314,
2073,
14,
355,
730,
26,
769,
355,
26265,
26,
490,
4113,
26,
717,
1369,
26,
717,
446,
11557,
370,
4838,
31363,
2332,
370,
14,
717,
3415,
26,
359,
1629,
12,
20663,
13,
4073,
12,
14719,
12,
18419,
61,
717,
730,
26,
620,
717,
849,
26,
1263,
490,
5724,
63,
5203,
26,
717,
1369,
26,
717,
446,
3820,
402,
8873,
503,
1844,
12271,
626,
911,
506,
24172,
370,
314,
1591,
641,
314,
491,
879,
14,
717,
730,
26,
769,
490,
4370,
63,
6142,
26,
717,
1369,
26,
717,
446,
12271,
402,
644,
879,
3531,
7149,
626,
787,
4370,
370,
1852,
30819,
6947,
641,
314,
2013,
8873,
503,
1844,
12271,
12,
503,
283,
1629,
1370,
717,
730,
26,
769,
272,
1373,
63,
475,
63,
3479,
26,
267,
1369,
26,
267,
446,
3820,
402,
413,
26,
3479,
31363,
4713,
14,
267,
730,
26,
769,
267,
26265,
26,
288,
4575,
63,
711,
26,
355,
1369,
26,
355,
446,
710,
3531,
2287,
626,
911,
506,
1202,
370,
2879,
314,
5007,
2073,
687,
314,
644,
879,
14,
355,
730,
26,
620,
288,
1536,
1073,
26,
355,
1369,
26,
355,
446,
710,
14095,
644,
879,
3217,
641,
1314,
314,
15602,
911,
601,
6053,
14,
355,
3415,
26,
359,
10727,
12,
21408,
17,
12,
21408,
18,
61,
355,
730,
26,
620,
288,
1844,
63,
4423,
26,
355,
1369,
26,
355,
446,
3820,
402,
4568,
1844,
4713,
14,
355,
730,
26,
769,
355,
26265,
26,
490,
536,
26,
717,
1369,
26,
717,
446,
437,
1369,
402,
314,
2332,
14,
717,
730,
26,
620,
490,
4113,
26,
717,
1369,
26,
717,
446,
11557,
370,
4838,
31363,
2332,
370,
14,
717,
3415,
26,
359,
8815,
12,
18419,
61,
717,
730,
26,
620,
490,
4575,
63,
719,
26,
717,
1369,
26,
717,
446,
28505,
1844,
402,
314,
15602,
626,
365,
601,
322,
4007,
641,
314,
644,
879,
14,
717,
730,
26,
620,
490,
2257,
63,
711,
26,
717,
1369,
26,
717,
446,
10111,
3531,
2287,
370,
1314,
15602,
911,
506,
24172,
14,
717,
730,
26,
620,
490,
2257,
63,
719,
26,
717,
1369,
26,
717,
446,
28505,
1844,
402,
314,
24172,
15602,
626,
911,
506,
4847,
687,
314,
603,
56,
370,
314,
2013,
1591,
641,
314,
491,
879,
14,
717,
446,
982,
1265,
9329,
13809,
370,
7568,
314,
15602,
1928,
1752,
24615,
314,
1844,
12,
642,
1077,
506,
314,
2011,
465,
314,
1684,
1844,
14,
717,
730,
26,
620,
490,
4370,
63,
6142,
26,
717,
1369,
26,
717,
446,
17283,
3531,
7149,
503,
12271,
626,
787,
8211,
370,
2879,
314,
5007,
2073,
4799,
642,
1844,
24119,
2332,
12,
503,
283,
1629,
1370,
717,
730,
26,
769,
272,
1844,
63,
21513,
26,
267,
1369,
26,
267,
446,
3820,
402,
1844,
24119,
4713,
14,
267,
730,
26,
769,
267,
26265,
26,
288,
536,
26,
355,
1369,
26,
355,
446,
437,
30262,
536,
367,
314,
2332,
14,
355,
730,
26,
620,
288,
634,
290,
63,
711,
26,
355,
1369,
26,
355,
446,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
aristanetworks/neutron
|
neutron/tests/unit/_test_extension_portbindings.py
|
7
|
17495
|
# Copyright 2013 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.
import contextlib
import httplib
from oslo_config import cfg
from webob import exc
from neutron import context
from neutron.extensions import portbindings
from neutron import manager
from neutron.tests.unit.db import test_db_base_plugin_v2
class PortBindingsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
# VIF_TYPE must be overridden according to plugin vif_type
VIF_TYPE = portbindings.VIF_TYPE_OTHER
# VIF_DETAILS must be overridden according to plugin vif_details
VIF_DETAILS = None
def _check_response_portbindings(self, port):
self.assertEqual(port[portbindings.VIF_TYPE], self.VIF_TYPE)
# REVISIT(rkukura): Consider reworking tests to enable ML2 to bind
if self.VIF_TYPE not in [portbindings.VIF_TYPE_UNBOUND,
portbindings.VIF_TYPE_BINDING_FAILED]:
# NOTE(r-mibu): The following six lines are just for backward
# compatibility. In this class, HAS_PORT_FILTER has been replaced
# by VIF_DETAILS which can be set expected vif_details to check,
# but all replacement of HAS_PORT_FILTER in successor has not been
# completed.
if self.VIF_DETAILS is None:
expected = getattr(self, 'HAS_PORT_FILTER', False)
vif_details = port[portbindings.VIF_DETAILS]
port_filter = vif_details[portbindings.CAP_PORT_FILTER]
self.assertEqual(expected, port_filter)
return
self.assertEqual(self.VIF_DETAILS, port[portbindings.VIF_DETAILS])
def _check_response_no_portbindings(self, port):
self.assertIn('status', port)
self.assertNotIn(portbindings.VIF_TYPE, port)
self.assertNotIn(portbindings.VIF_DETAILS, port)
def _get_non_admin_context(self):
return context.Context(user_id=None,
tenant_id=self._tenant_id,
is_admin=False,
read_deleted="no")
def test_port_vif_details(self):
with self.port(name='name') as port:
port_id = port['port']['id']
# Check a response of create_port
self._check_response_portbindings(port['port'])
# Check a response of get_port
ctx = context.get_admin_context()
port = self._show('ports', port_id, neutron_context=ctx)['port']
self._check_response_portbindings(port)
# By default user is admin - now test non admin user
ctx = self._get_non_admin_context()
non_admin_port = self._show(
'ports', port_id, neutron_context=ctx)['port']
self._check_response_no_portbindings(non_admin_port)
def test_ports_vif_details(self):
plugin = manager.NeutronManager.get_plugin()
cfg.CONF.set_default('allow_overlapping_ips', True)
with contextlib.nested(self.port(), self.port()):
ctx = context.get_admin_context()
ports = plugin.get_ports(ctx)
self.assertEqual(len(ports), 2)
for port in ports:
self._check_response_portbindings(port)
# By default user is admin - now test non admin user
ctx = self._get_non_admin_context()
ports = self._list('ports', neutron_context=ctx)['ports']
self.assertEqual(len(ports), 2)
for non_admin_port in ports:
self._check_response_no_portbindings(non_admin_port)
def _check_port_binding_profile(self, port, profile=None):
# For plugins which does not use binding:profile attr
# we just check an operation for the port succeed.
self.assertIn('id', port)
def _test_create_port_binding_profile(self, profile):
profile_arg = {portbindings.PROFILE: profile}
with self.port(arg_list=(portbindings.PROFILE,),
**profile_arg) as port:
port_id = port['port']['id']
self._check_port_binding_profile(port['port'], profile)
port = self._show('ports', port_id)
self._check_port_binding_profile(port['port'], profile)
def test_create_port_binding_profile_none(self):
self._test_create_port_binding_profile(None)
def test_create_port_binding_profile_with_empty_dict(self):
self._test_create_port_binding_profile({})
def _test_update_port_binding_profile(self, profile):
profile_arg = {portbindings.PROFILE: profile}
with self.port() as port:
self._check_port_binding_profile(port['port'])
port_id = port['port']['id']
ctx = context.get_admin_context()
port = self._update('ports', port_id, {'port': profile_arg},
neutron_context=ctx)['port']
self._check_port_binding_profile(port, profile)
port = self._show('ports', port_id)['port']
self._check_port_binding_profile(port, profile)
def test_update_port_binding_profile_none(self):
self._test_update_port_binding_profile(None)
def test_update_port_binding_profile_with_empty_dict(self):
self._test_update_port_binding_profile({})
def test_port_create_portinfo_non_admin(self):
profile_arg = {portbindings.PROFILE: {'dummy': 'dummy'}}
with self.network(set_context=True, tenant_id='test') as net1:
with self.subnet(network=net1) as subnet1:
# succeed without binding:profile
with self.port(subnet=subnet1,
set_context=True, tenant_id='test'):
pass
# fail with binding:profile
try:
with self.port(subnet=subnet1,
expected_res_status=403,
arg_list=(portbindings.PROFILE,),
set_context=True, tenant_id='test',
**profile_arg):
pass
except exc.HTTPClientError:
pass
def test_port_update_portinfo_non_admin(self):
profile_arg = {portbindings.PROFILE: {'dummy': 'dummy'}}
with self.network() as net1:
with self.subnet(network=net1) as subnet1:
with self.port(subnet=subnet1) as port:
# By default user is admin - now test non admin user
port_id = port['port']['id']
ctx = self._get_non_admin_context()
port = self._update('ports', port_id,
{'port': profile_arg},
expected_code=exc.HTTPForbidden.code,
neutron_context=ctx)
class PortBindingsHostTestCaseMixin(object):
fmt = 'json'
hostname = 'testhost'
def _check_response_portbindings_host(self, port):
self.assertEqual(port[portbindings.HOST_ID], self.hostname)
def _check_response_no_portbindings_host(self, port):
self.assertIn('status', port)
self.assertNotIn(portbindings.HOST_ID, port)
def test_port_vif_non_admin(self):
with self.network(set_context=True,
tenant_id='test') as net1:
with self.subnet(network=net1) as subnet1:
host_arg = {portbindings.HOST_ID: self.hostname}
try:
with self.port(subnet=subnet1,
expected_res_status=403,
arg_list=(portbindings.HOST_ID,),
set_context=True,
tenant_id='test',
**host_arg):
pass
except exc.HTTPClientError:
pass
def test_port_vif_host(self):
host_arg = {portbindings.HOST_ID: self.hostname}
with self.port(name='name', arg_list=(portbindings.HOST_ID,),
**host_arg) as port:
port_id = port['port']['id']
# Check a response of create_port
self._check_response_portbindings_host(port['port'])
# Check a response of get_port
ctx = context.get_admin_context()
port = self._show('ports', port_id, neutron_context=ctx)['port']
self._check_response_portbindings_host(port)
# By default user is admin - now test non admin user
ctx = context.Context(user_id=None,
tenant_id=self._tenant_id,
is_admin=False,
read_deleted="no")
non_admin_port = self._show(
'ports', port_id, neutron_context=ctx)['port']
self._check_response_no_portbindings_host(non_admin_port)
def test_ports_vif_host(self):
cfg.CONF.set_default('allow_overlapping_ips', True)
host_arg = {portbindings.HOST_ID: self.hostname}
with contextlib.nested(
self.port(name='name1',
arg_list=(portbindings.HOST_ID,),
**host_arg),
self.port(name='name2')):
ctx = context.get_admin_context()
ports = self._list('ports', neutron_context=ctx)['ports']
self.assertEqual(2, len(ports))
for port in ports:
if port['name'] == 'name1':
self._check_response_portbindings_host(port)
else:
self.assertFalse(port[portbindings.HOST_ID])
# By default user is admin - now test non admin user
ctx = context.Context(user_id=None,
tenant_id=self._tenant_id,
is_admin=False,
read_deleted="no")
ports = self._list('ports', neutron_context=ctx)['ports']
self.assertEqual(2, len(ports))
for non_admin_port in ports:
self._check_response_no_portbindings_host(non_admin_port)
def test_ports_vif_host_update(self):
cfg.CONF.set_default('allow_overlapping_ips', True)
host_arg = {portbindings.HOST_ID: self.hostname}
with contextlib.nested(
self.port(name='name1',
arg_list=(portbindings.HOST_ID,),
**host_arg),
self.port(name='name2')) as (port1, port2):
data = {'port': {portbindings.HOST_ID: 'testhosttemp'}}
req = self.new_update_request('ports', data, port1['port']['id'])
req.get_response(self.api)
req = self.new_update_request('ports', data, port2['port']['id'])
ctx = context.get_admin_context()
req.get_response(self.api)
ports = self._list('ports', neutron_context=ctx)['ports']
self.assertEqual(2, len(ports))
for port in ports:
self.assertEqual('testhosttemp', port[portbindings.HOST_ID])
def test_ports_vif_non_host_update(self):
host_arg = {portbindings.HOST_ID: self.hostname}
with self.port(name='name', arg_list=(portbindings.HOST_ID,),
**host_arg) as port:
data = {'port': {'admin_state_up': False}}
req = self.new_update_request('ports', data, port['port']['id'])
res = self.deserialize(self.fmt, req.get_response(self.api))
self.assertEqual(port['port'][portbindings.HOST_ID],
res['port'][portbindings.HOST_ID])
def test_ports_vif_non_host_update_when_host_null(self):
with self.port() as port:
data = {'port': {'admin_state_up': False}}
req = self.new_update_request('ports', data, port['port']['id'])
res = self.deserialize(self.fmt, req.get_response(self.api))
self.assertEqual(port['port'][portbindings.HOST_ID],
res['port'][portbindings.HOST_ID])
def test_ports_vif_host_list(self):
cfg.CONF.set_default('allow_overlapping_ips', True)
host_arg = {portbindings.HOST_ID: self.hostname}
with contextlib.nested(
self.port(name='name1',
arg_list=(portbindings.HOST_ID,),
**host_arg),
self.port(name='name2'),
self.port(name='name3',
arg_list=(portbindings.HOST_ID,),
**host_arg),) as (port1, _port2, port3):
self._test_list_resources(
'port', (port1, port3),
query_params='%s=%s' % (portbindings.HOST_ID, self.hostname))
class PortBindingsVnicTestCaseMixin(object):
fmt = 'json'
vnic_type = portbindings.VNIC_NORMAL
def _check_response_portbindings_vnic_type(self, port):
self.assertIn('status', port)
self.assertEqual(port[portbindings.VNIC_TYPE], self.vnic_type)
def test_port_vnic_type_non_admin(self):
with self.network(set_context=True,
tenant_id='test') as net1:
with self.subnet(network=net1) as subnet1:
vnic_arg = {portbindings.VNIC_TYPE: self.vnic_type}
with self.port(subnet=subnet1,
expected_res_status=httplib.CREATED,
arg_list=(portbindings.VNIC_TYPE,),
set_context=True,
tenant_id='test',
**vnic_arg) as port:
# Check a response of create_port
self._check_response_portbindings_vnic_type(port['port'])
def test_port_vnic_type(self):
vnic_arg = {portbindings.VNIC_TYPE: self.vnic_type}
with self.port(name='name', arg_list=(portbindings.VNIC_TYPE,),
**vnic_arg) as port:
port_id = port['port']['id']
# Check a response of create_port
self._check_response_portbindings_vnic_type(port['port'])
# Check a response of get_port
ctx = context.get_admin_context()
port = self._show('ports', port_id, neutron_context=ctx)['port']
self._check_response_portbindings_vnic_type(port)
# By default user is admin - now test non admin user
ctx = context.Context(user_id=None,
tenant_id=self._tenant_id,
is_admin=False,
read_deleted="no")
non_admin_port = self._show(
'ports', port_id, neutron_context=ctx)['port']
self._check_response_portbindings_vnic_type(non_admin_port)
def test_ports_vnic_type(self):
cfg.CONF.set_default('allow_overlapping_ips', True)
vnic_arg = {portbindings.VNIC_TYPE: self.vnic_type}
with contextlib.nested(
self.port(name='name1',
arg_list=(portbindings.VNIC_TYPE,),
**vnic_arg),
self.port(name='name2')):
ctx = context.get_admin_context()
ports = self._list('ports', neutron_context=ctx)['ports']
self.assertEqual(2, len(ports))
for port in ports:
if port['name'] == 'name1':
self._check_response_portbindings_vnic_type(port)
else:
self.assertEqual(portbindings.VNIC_NORMAL,
port[portbindings.VNIC_TYPE])
# By default user is admin - now test non admin user
ctx = context.Context(user_id=None,
tenant_id=self._tenant_id,
is_admin=False,
read_deleted="no")
ports = self._list('ports', neutron_context=ctx)['ports']
self.assertEqual(2, len(ports))
for non_admin_port in ports:
self._check_response_portbindings_vnic_type(non_admin_port)
def test_ports_vnic_type_list(self):
cfg.CONF.set_default('allow_overlapping_ips', True)
vnic_arg = {portbindings.VNIC_TYPE: self.vnic_type}
with contextlib.nested(
self.port(name='name1',
arg_list=(portbindings.VNIC_TYPE,),
**vnic_arg),
self.port(name='name2'),
self.port(name='name3',
arg_list=(portbindings.VNIC_TYPE,),
**vnic_arg),) as (port1, port2, port3):
self._test_list_resources(
'port', (port1, port2, port3),
query_params='%s=%s' % (portbindings.VNIC_TYPE,
self.vnic_type))
|
apache-2.0
|
[
3,
1898,
6171,
653,
4220,
11098,
199,
3,
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,
646,
15502,
199,
646,
8809,
199,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
14568,
492,
3178,
199,
199,
504,
8224,
492,
1067,
199,
504,
8224,
14,
5359,
492,
1844,
10880,
199,
504,
8224,
492,
5256,
199,
504,
8224,
14,
2219,
14,
3248,
14,
697,
492,
511,
63,
697,
63,
1095,
63,
2718,
63,
86,
18,
421,
199,
533,
10977,
8198,
780,
1746,
8,
396,
63,
697,
63,
1095,
63,
2718,
63,
86,
18,
14,
20915,
8882,
5061,
54,
18,
1746,
304,
339,
327,
812,
4656,
63,
2711,
1471,
506,
10087,
7182,
370,
3589,
15205,
63,
466,
272,
812,
4656,
63,
2711,
275,
1844,
10880,
14,
27890,
63,
2711,
63,
18400,
272,
327,
812,
4656,
63,
25081,
51,
1471,
506,
10087,
7182,
370,
3589,
15205,
63,
5087,
272,
812,
4656,
63,
25081,
51,
275,
488,
339,
347,
485,
1074,
63,
1310,
63,
719,
10880,
8,
277,
12,
1844,
304,
267,
291,
14,
629,
8,
719,
59,
719,
10880,
14,
27890,
63,
2711,
467,
291,
14,
27890,
63,
2711,
9,
267,
327,
5363,
11793,
649,
8,
23992,
3210,
12417,
304,
24413,
295,
9818,
2295,
370,
4756,
28007,
18,
370,
5398,
398,
340,
291,
14,
27890,
63,
2711,
440,
315,
359,
719,
10880,
14,
27890,
63,
2711,
63,
1734,
17882,
12,
639,
1844,
10880,
14,
27890,
63,
2711,
63,
28347,
63,
12299,
2189,
288,
327,
6944,
8,
82,
13,
2664,
464,
304,
710,
2569,
3816,
2385,
787,
2951,
367,
13388,
288,
327,
7163,
14,
221,
1010,
642,
1021,
12,
7509,
63,
3657,
63,
9905,
965,
2757,
8717,
288,
327,
701,
812,
4656,
63,
25081,
51,
1314,
883,
506,
663,
1420,
15205,
63,
5087,
370,
1104,
12,
288,
327,
1325,
1006,
8343,
402,
7509,
63,
3657,
63,
9905,
315,
3182,
269,
965,
440,
2757,
288,
327,
9709,
14,
288,
340,
291,
14,
27890,
63,
25081,
51,
365,
488,
26,
355,
1420,
275,
2519,
8,
277,
12,
283,
13533,
63,
3657,
63,
9905,
297,
756,
9,
355,
15205,
63,
5087,
275,
1844,
59,
719,
10880,
14,
27890,
63,
25081,
51,
61,
355,
1844,
63,
1541,
275,
15205,
63,
5087,
59,
719,
10880,
14,
8549,
63,
3657,
63,
9905,
61,
355,
291,
14,
629,
8,
2062,
12,
1844,
63,
1541,
9,
355,
372,
288,
291,
14,
629,
8,
277,
14,
27890,
63,
25081,
51,
12,
1844,
59,
719,
10880,
14,
27890,
63,
25081,
51,
566,
339,
347,
485,
1074,
63,
1310,
63,
889,
63,
719,
10880,
8,
277,
12,
1844,
304,
267,
291,
14,
4080,
360,
1205,
297,
1844,
9,
267,
291,
14,
8795,
8,
719,
10880,
14,
27890,
63,
2711,
12,
1844,
9,
267,
291,
14,
8795,
8,
719,
10880,
14,
27890,
63,
25081,
51,
12,
1844,
9,
339,
347,
485,
362,
63,
2865,
63,
2113,
63,
1100,
8,
277,
304,
267,
372,
1067,
14,
2998,
8,
751,
63,
344,
29,
403,
12,
3044,
8261,
63,
344,
29,
277,
423,
4647,
63,
344,
12,
3044,
365,
63,
2113,
29,
797,
12,
3044,
1586,
63,
6062,
628,
889,
531,
339,
347,
511,
63,
719,
63,
14430,
63,
5087,
8,
277,
304,
267,
543,
291,
14,
719,
8,
354,
534,
354,
358,
465,
1844,
26,
288,
1844,
63,
344,
275,
1844,
459,
719,
2545,
344,
418,
288,
327,
2670,
282,
1177,
402,
1218,
63,
719,
288,
291,
423,
1074,
63,
1310,
63,
719,
10880,
8,
719,
459,
719,
1105,
288,
327,
2670,
282,
1177,
402,
664,
63,
719,
288,
4027,
275,
1067,
14,
362,
63,
2113,
63,
1100,
342,
288,
1844,
275,
291,
423,
2384,
360,
5203,
297,
1844,
63,
344,
12,
8224,
63,
1100,
29,
3799,
11820,
719,
418,
288,
291,
423,
1074,
63,
1310,
63,
719,
10880,
8,
719,
9,
288,
327,
4885,
849,
922,
365,
4628,
446,
3063,
511,
2222,
4628,
922,
288,
4027,
275,
291,
423,
362,
63,
2865,
63,
2113,
63,
1100,
342,
288,
2222,
63,
2113,
63,
719,
275,
291,
423,
2384,
8,
355,
283,
5203,
297,
1844,
63,
344,
12,
8224,
63,
1100,
29,
3799,
11820,
719,
418,
288,
291,
423,
1074,
63,
1310,
63,
889,
63,
719,
10880,
8,
2865,
63,
2113,
63,
719,
9,
339,
347,
511,
63,
5203,
63,
14430,
63,
5087,
8,
277,
304,
267,
3589,
275,
5256,
14,
20915,
2988,
14,
362,
63,
2718,
342,
267,
4810,
14,
3103,
14,
409,
63,
885,
360,
3306,
63,
31034,
63,
6142,
297,
715,
9,
267,
543,
15502,
14,
6376,
8,
277,
14,
719,
1062,
291,
14,
719,
5109,
288,
4027,
275,
1067,
14,
362,
63,
2113,
63,
1100,
342,
288,
8873,
275,
3589,
14,
362,
63,
5203,
8,
3799,
9,
288,
291,
14,
629,
8,
552,
8,
5203,
395,
499,
9,
288,
367,
1844,
315,
8873,
26,
355,
291,
423,
1074,
63,
1310,
63,
719,
10880,
8,
719,
9,
288,
327,
4885,
849,
922,
365,
4628,
446,
3063,
511,
2222,
4628,
922,
288,
4027,
275,
291,
423,
362,
63,
2865,
63,
2113,
63,
1100,
342,
288,
8873,
275,
291,
423,
513,
360,
5203,
297,
8224,
63,
1100,
29,
3799,
11820,
5203,
418,
288,
291,
14,
629,
8,
552,
8,
5203,
395,
499,
9,
288,
367,
2222,
63,
2113,
63,
719,
315,
8873,
26,
355,
291,
423,
1074,
63,
1310,
63,
889,
63,
719,
10880,
8,
2865,
63,
2113,
63,
719,
9,
339,
347,
485,
1074,
63
] |
[
1898,
6171,
653,
4220,
11098,
199,
3,
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,
646,
15502,
199,
646,
8809,
199,
199,
504,
11258,
63,
888,
492,
4810,
199,
504,
14568,
492,
3178,
199,
199,
504,
8224,
492,
1067,
199,
504,
8224,
14,
5359,
492,
1844,
10880,
199,
504,
8224,
492,
5256,
199,
504,
8224,
14,
2219,
14,
3248,
14,
697,
492,
511,
63,
697,
63,
1095,
63,
2718,
63,
86,
18,
421,
199,
533,
10977,
8198,
780,
1746,
8,
396,
63,
697,
63,
1095,
63,
2718,
63,
86,
18,
14,
20915,
8882,
5061,
54,
18,
1746,
304,
339,
327,
812,
4656,
63,
2711,
1471,
506,
10087,
7182,
370,
3589,
15205,
63,
466,
272,
812,
4656,
63,
2711,
275,
1844,
10880,
14,
27890,
63,
2711,
63,
18400,
272,
327,
812,
4656,
63,
25081,
51,
1471,
506,
10087,
7182,
370,
3589,
15205,
63,
5087,
272,
812,
4656,
63,
25081,
51,
275,
488,
339,
347,
485,
1074,
63,
1310,
63,
719,
10880,
8,
277,
12,
1844,
304,
267,
291,
14,
629,
8,
719,
59,
719,
10880,
14,
27890,
63,
2711,
467,
291,
14,
27890,
63,
2711,
9,
267,
327,
5363,
11793,
649,
8,
23992,
3210,
12417,
304,
24413,
295,
9818,
2295,
370,
4756,
28007,
18,
370,
5398,
398,
340,
291,
14,
27890,
63,
2711,
440,
315,
359,
719,
10880,
14,
27890,
63,
2711,
63,
1734,
17882,
12,
639,
1844,
10880,
14,
27890,
63,
2711,
63,
28347,
63,
12299,
2189,
288,
327,
6944,
8,
82,
13,
2664,
464,
304,
710,
2569,
3816,
2385,
787,
2951,
367,
13388,
288,
327,
7163,
14,
221,
1010,
642,
1021,
12,
7509,
63,
3657,
63,
9905,
965,
2757,
8717,
288,
327,
701,
812,
4656,
63,
25081,
51,
1314,
883,
506,
663,
1420,
15205,
63,
5087,
370,
1104,
12,
288,
327,
1325,
1006,
8343,
402,
7509,
63,
3657,
63,
9905,
315,
3182,
269,
965,
440,
2757,
288,
327,
9709,
14,
288,
340,
291,
14,
27890,
63,
25081,
51,
365,
488,
26,
355,
1420,
275,
2519,
8,
277,
12,
283,
13533,
63,
3657,
63,
9905,
297,
756,
9,
355,
15205,
63,
5087,
275,
1844,
59,
719,
10880,
14,
27890,
63,
25081,
51,
61,
355,
1844,
63,
1541,
275,
15205,
63,
5087,
59,
719,
10880,
14,
8549,
63,
3657,
63,
9905,
61,
355,
291,
14,
629,
8,
2062,
12,
1844,
63,
1541,
9,
355,
372,
288,
291,
14,
629,
8,
277,
14,
27890,
63,
25081,
51,
12,
1844,
59,
719,
10880,
14,
27890,
63,
25081,
51,
566,
339,
347,
485,
1074,
63,
1310,
63,
889,
63,
719,
10880,
8,
277,
12,
1844,
304,
267,
291,
14,
4080,
360,
1205,
297,
1844,
9,
267,
291,
14,
8795,
8,
719,
10880,
14,
27890,
63,
2711,
12,
1844,
9,
267,
291,
14,
8795,
8,
719,
10880,
14,
27890,
63,
25081,
51,
12,
1844,
9,
339,
347,
485,
362,
63,
2865,
63,
2113,
63,
1100,
8,
277,
304,
267,
372,
1067,
14,
2998,
8,
751,
63,
344,
29,
403,
12,
3044,
8261,
63,
344,
29,
277,
423,
4647,
63,
344,
12,
3044,
365,
63,
2113,
29,
797,
12,
3044,
1586,
63,
6062,
628,
889,
531,
339,
347,
511,
63,
719,
63,
14430,
63,
5087,
8,
277,
304,
267,
543,
291,
14,
719,
8,
354,
534,
354,
358,
465,
1844,
26,
288,
1844,
63,
344,
275,
1844,
459,
719,
2545,
344,
418,
288,
327,
2670,
282,
1177,
402,
1218,
63,
719,
288,
291,
423,
1074,
63,
1310,
63,
719,
10880,
8,
719,
459,
719,
1105,
288,
327,
2670,
282,
1177,
402,
664,
63,
719,
288,
4027,
275,
1067,
14,
362,
63,
2113,
63,
1100,
342,
288,
1844,
275,
291,
423,
2384,
360,
5203,
297,
1844,
63,
344,
12,
8224,
63,
1100,
29,
3799,
11820,
719,
418,
288,
291,
423,
1074,
63,
1310,
63,
719,
10880,
8,
719,
9,
288,
327,
4885,
849,
922,
365,
4628,
446,
3063,
511,
2222,
4628,
922,
288,
4027,
275,
291,
423,
362,
63,
2865,
63,
2113,
63,
1100,
342,
288,
2222,
63,
2113,
63,
719,
275,
291,
423,
2384,
8,
355,
283,
5203,
297,
1844,
63,
344,
12,
8224,
63,
1100,
29,
3799,
11820,
719,
418,
288,
291,
423,
1074,
63,
1310,
63,
889,
63,
719,
10880,
8,
2865,
63,
2113,
63,
719,
9,
339,
347,
511,
63,
5203,
63,
14430,
63,
5087,
8,
277,
304,
267,
3589,
275,
5256,
14,
20915,
2988,
14,
362,
63,
2718,
342,
267,
4810,
14,
3103,
14,
409,
63,
885,
360,
3306,
63,
31034,
63,
6142,
297,
715,
9,
267,
543,
15502,
14,
6376,
8,
277,
14,
719,
1062,
291,
14,
719,
5109,
288,
4027,
275,
1067,
14,
362,
63,
2113,
63,
1100,
342,
288,
8873,
275,
3589,
14,
362,
63,
5203,
8,
3799,
9,
288,
291,
14,
629,
8,
552,
8,
5203,
395,
499,
9,
288,
367,
1844,
315,
8873,
26,
355,
291,
423,
1074,
63,
1310,
63,
719,
10880,
8,
719,
9,
288,
327,
4885,
849,
922,
365,
4628,
446,
3063,
511,
2222,
4628,
922,
288,
4027,
275,
291,
423,
362,
63,
2865,
63,
2113,
63,
1100,
342,
288,
8873,
275,
291,
423,
513,
360,
5203,
297,
8224,
63,
1100,
29,
3799,
11820,
5203,
418,
288,
291,
14,
629,
8,
552,
8,
5203,
395,
499,
9,
288,
367,
2222,
63,
2113,
63,
719,
315,
8873,
26,
355,
291,
423,
1074,
63,
1310,
63,
889,
63,
719,
10880,
8,
2865,
63,
2113,
63,
719,
9,
339,
347,
485,
1074,
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,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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
] |
sklnet/openatv-enigma2
|
lib/python/Screens/TaskView.py
|
55
|
5653
|
from Screens.Screen import Screen
from Components.ConfigList import ConfigListScreen
from Components.config import ConfigSubsection, ConfigSelection, getConfigListEntry
from Components.SystemInfo import SystemInfo
from Components.Task import job_manager
from InfoBarGenerics import InfoBarNotifications
import Screens.Standby
from Tools import Notifications
from boxbranding import getMachineBrand, getMachineName
class JobView(InfoBarNotifications, Screen, ConfigListScreen):
def __init__(self, session, job, parent=None, cancelable = True, backgroundable = True, afterEventChangeable = True , afterEvent="nothing"):
from Components.Sources.StaticText import StaticText
from Components.Sources.Progress import Progress
from Components.Sources.Boolean import Boolean
from Components.ActionMap import ActionMap
Screen.__init__(self, session, parent)
Screen.setTitle(self, _("Job View"))
InfoBarNotifications.__init__(self)
ConfigListScreen.__init__(self, [])
self.parent = parent
self.job = job
if afterEvent:
self.job.afterEvent = afterEvent
self["job_name"] = StaticText(job.name)
self["job_progress"] = Progress()
self["job_task"] = StaticText()
self["summary_job_name"] = StaticText(job.name)
self["summary_job_progress"] = Progress()
self["summary_job_task"] = StaticText()
self["job_status"] = StaticText()
self["finished"] = Boolean()
self["cancelable"] = Boolean(cancelable)
self["backgroundable"] = Boolean(backgroundable)
self["key_blue"] = StaticText(_("Background"))
self.onShow.append(self.windowShow)
self.onHide.append(self.windowHide)
self["setupActions"] = ActionMap(["ColorActions", "SetupActions"],
{
"green": self.ok,
"red": self.abort,
"blue": self.background,
"cancel": self.ok,
"ok": self.ok,
}, -2)
self.settings = ConfigSubsection()
if SystemInfo["DeepstandbySupport"]:
shutdownString = _("go to deep standby")
else:
shutdownString = _("shut down")
self.settings.afterEvent = ConfigSelection(choices = [("nothing", _("do nothing")), ("close", _("Close")), ("standby", _("go to standby")), ("deepstandby", shutdownString)], default = self.job.afterEvent or "nothing")
self.job.afterEvent = self.settings.afterEvent.value
self.afterEventChangeable = afterEventChangeable
self.setupList()
self.state_changed()
def setupList(self):
if self.afterEventChangeable:
self["config"].setList( [ getConfigListEntry(_("After event"), self.settings.afterEvent) ])
else:
self["config"].hide()
self.job.afterEvent = self.settings.afterEvent.value
def keyLeft(self):
ConfigListScreen.keyLeft(self)
self.setupList()
def keyRight(self):
ConfigListScreen.keyRight(self)
self.setupList()
def windowShow(self):
job_manager.visible = True
self.job.state_changed.append(self.state_changed)
def windowHide(self):
job_manager.visible = False
if len(self.job.state_changed) > 0:
self.job.state_changed.remove(self.state_changed)
def state_changed(self):
j = self.job
self["job_progress"].range = j.end
self["summary_job_progress"].range = j.end
self["job_progress"].value = j.progress
self["summary_job_progress"].value = j.progress
#print "JobView::state_changed:", j.end, j.progress
self["job_status"].text = j.getStatustext()
if j.status == j.IN_PROGRESS:
self["job_task"].text = j.tasks[j.current_task].name
self["summary_job_task"].text = j.tasks[j.current_task].name
else:
self["job_task"].text = ""
self["summary_job_task"].text = j.getStatustext()
if j.status in (j.FINISHED, j.FAILED):
self.performAfterEvent()
self["backgroundable"].boolean = False
if j.status == j.FINISHED:
self["finished"].boolean = True
self["cancelable"].boolean = False
elif j.status == j.FAILED:
self["cancelable"].boolean = True
def background(self):
if self["backgroundable"].boolean:
self.close(True)
def ok(self):
if self.job.status in (self.job.FINISHED, self.job.FAILED):
self.close(False)
else:
self.background()
def abort(self):
if self.job.status == self.job.NOT_STARTED:
job_manager.active_jobs.remove(self.job)
self.close(False)
elif self.job.status == self.job.IN_PROGRESS and self["cancelable"].boolean == True:
self.job.cancel()
else:
self.close(False)
def performAfterEvent(self):
self["config"].hide()
if self.settings.afterEvent.value == "nothing":
return
elif self.settings.afterEvent.value == "close" and self.job.status == self.job.FINISHED:
self.close(False)
from Screens.MessageBox import MessageBox
if self.settings.afterEvent.value == "deepstandby":
if not Screens.Standby.inTryQuitMainloop:
Notifications.AddNotificationWithCallback(self.sendTryQuitMainloopNotification, MessageBox, _("A sleep timer wants to shut down\nyour %s %s. Shutdown now?") % (getMachineBrand(), getMachineName()), timeout = 20)
elif self.settings.afterEvent.value == "standby":
if not Screens.Standby.inStandby:
Notifications.AddNotificationWithCallback(self.sendStandbyNotification, MessageBox, _("A sleep timer wants to set your\n%s %s to standby. Do that now?") % (getMachineBrand(), getMachineName()), timeout = 20)
def checkNotifications(self):
InfoBarNotifications.checkNotifications(self)
if not Notifications.notifications:
if self.settings.afterEvent.value == "close" and self.job.status == self.job.FAILED:
self.close(False)
def sendStandbyNotification(self, answer):
if answer:
Notifications.AddNotification(Screens.Standby.Standby)
def sendTryQuitMainloopNotification(self, answer):
if answer:
Notifications.AddNotification(Screens.Standby.TryQuitMainloop, 1)
|
gpl-2.0
|
[
504,
29372,
14,
9616,
492,
17804,
199,
504,
17823,
14,
2028,
1296,
492,
4094,
1296,
9616,
199,
504,
17823,
14,
888,
492,
4094,
31839,
12,
32245,
12,
664,
2028,
16934,
199,
504,
17823,
14,
3989,
2354,
492,
6187,
2354,
199,
504,
17823,
14,
4476,
492,
3906,
63,
2609,
199,
504,
32767,
3139,
2932,
492,
32767,
30620,
199,
646,
29372,
14,
31060,
199,
504,
23228,
492,
23362,
83,
199,
504,
1234,
1774,
3759,
316,
492,
664,
8412,
34,
3759,
12,
664,
8412,
985,
199,
199,
533,
15057,
2768,
8,
2354,
5281,
30620,
12,
17804,
12,
4094,
1296,
9616,
304,
199,
198,
318,
636,
826,
721,
277,
12,
2351,
12,
3906,
12,
1676,
29,
403,
12,
9311,
461,
275,
715,
12,
8020,
461,
275,
715,
12,
2410,
2390,
4001,
461,
275,
715,
2360,
2410,
2390,
628,
16323,
2349,
507,
198,
504,
17823,
14,
13959,
14,
25289,
492,
13599,
1872,
507,
198,
504,
17823,
14,
13959,
14,
11504,
492,
21211,
507,
198,
504,
17823,
14,
13959,
14,
4082,
492,
9411,
507,
198,
504,
17823,
14,
3310,
2956,
492,
10033,
2956,
507,
198,
9616,
855,
826,
721,
277,
12,
2351,
12,
1676,
9,
507,
198,
9616,
14,
31675,
8,
277,
12,
3824,
6694,
10935,
2237,
507,
198,
2354,
5281,
30620,
855,
826,
721,
277,
9,
507,
198,
2028,
1296,
9616,
855,
826,
721,
277,
12,
3073,
507,
198,
277,
14,
1708,
275,
1676,
507,
198,
277,
14,
2423,
275,
3906,
507,
198,
692,
2410,
2390,
26,
686,
198,
277,
14,
2423,
14,
4399,
2390,
275,
2410,
2390,
2742,
198,
277,
905,
2423,
63,
354,
937,
275,
13599,
1872,
8,
2423,
14,
354,
9,
507,
198,
277,
905,
2423,
63,
5734,
937,
275,
21211,
342,
507,
198,
277,
905,
2423,
63,
1765,
937,
275,
13599,
1872,
342,
507,
198,
277,
905,
4705,
63,
2423,
63,
354,
937,
275,
13599,
1872,
8,
2423,
14,
354,
9,
507,
198,
277,
905,
4705,
63,
2423,
63,
5734,
937,
275,
21211,
342,
507,
198,
277,
905,
4705,
63,
2423,
63,
1765,
937,
275,
13599,
1872,
342,
507,
198,
277,
905,
2423,
63,
1205,
937,
275,
13599,
1872,
342,
507,
198,
277,
905,
8669,
937,
275,
9411,
342,
507,
198,
277,
905,
6406,
461,
937,
275,
9411,
8,
6406,
461,
9,
507,
198,
277,
905,
7451,
461,
937,
275,
9411,
8,
7451,
461,
9,
2742,
198,
277,
905,
498,
63,
6304,
937,
275,
13599,
1872,
6115,
14148,
2237,
2742,
198,
277,
14,
265,
6824,
14,
740,
8,
277,
14,
3806,
6824,
9,
507,
198,
277,
14,
265,
18224,
14,
740,
8,
277,
14,
3806,
18224,
9,
2742,
198,
277,
905,
2758,
9303,
937,
275,
10033,
2956,
5234,
4117,
9303,
401,
298,
8555,
9303,
2255,
507,
198,
91,
686,
198,
2,
7731,
582,
291,
14,
745,
12,
686,
198,
2,
581,
582,
291,
14,
13845,
12,
686,
198,
2,
6304,
582,
291,
14,
7451,
12,
686,
198,
2,
6406,
582,
291,
14,
745,
12,
686,
198,
2,
745,
582,
291,
14,
745,
12,
507,
198,
1386,
446,
18,
9,
2742,
198,
277,
14,
1751,
275,
4094,
31839,
342,
507,
198,
692,
6187,
2354,
905,
27753,
26071,
11532,
6229,
686,
198,
8831,
1558,
275,
3824,
1939,
370,
13217,
10584,
991,
531,
507,
198,
2836,
26,
686,
198,
8831,
1558,
275,
3824,
609,
337,
3224,
531,
507,
198,
277,
14,
1751,
14,
4399,
2390,
275,
32245,
8,
4577,
275,
10003,
16323,
401,
3824,
1117,
6548,
8150,
1689,
1600,
401,
3824,
4724,
8150,
1689,
26071,
401,
3824,
1939,
370,
10584,
991,
8150,
1689,
16131,
26071,
401,
12842,
1558,
4360,
849,
275,
291,
14,
2423,
14,
4399,
2390,
503,
298,
16323,
531,
507,
198,
277,
14,
2423,
14,
4399,
2390,
275,
291,
14,
1751,
14,
4399,
2390,
14,
585,
507,
198,
277,
14,
4399,
2390,
4001,
461,
275,
2410,
2390,
4001,
461,
507,
198,
277,
14,
2758,
1296,
342,
507,
198,
277,
14,
929,
63,
2489,
342,
421,
198,
318,
3272,
1296,
8,
277,
304,
507,
198,
692,
291,
14,
4399,
2390,
4001,
461,
26,
686,
198,
277,
905,
888,
4140,
409,
1296,
8,
359,
664,
2028,
16934,
6115,
10881,
1566,
1288,
291,
14,
1751,
14,
4399,
2390,
9,
4794,
507,
198,
2836,
26,
686,
198,
277,
905,
888,
4140,
8191,
342,
507,
198,
277,
14,
2423,
14,
4399,
2390,
275,
291,
14,
1751,
14,
4399,
2390,
14,
585,
421,
198,
318,
790,
8185,
8,
277,
304,
507,
198,
2028,
1296,
9616,
14,
498,
8185,
8,
277,
9,
507,
198,
277,
14,
2758,
1296,
342,
421,
198,
318,
790,
9121,
8,
277,
304,
507,
198,
2028,
1296,
9616,
14,
498,
9121,
8,
277,
9,
507,
198,
277,
14,
2758,
1296,
342,
421,
198,
318,
4353,
6824,
8,
277,
304,
507,
198,
2423,
63,
2609,
14,
6604,
275,
715,
507,
198,
277,
14,
2423,
14,
929,
63,
2489,
14,
740,
8,
277,
14,
929,
63,
2489,
9,
421,
198,
318,
4353,
18224,
8,
277,
304,
507,
198,
2423,
63,
2609,
14,
6604,
275,
756,
507,
198,
692,
822,
8,
277,
14,
2423,
14,
929,
63,
2489,
9,
690,
378,
26,
686,
198,
277,
14,
2423,
14,
929,
63,
2489,
14,
2168,
8,
277,
14,
929,
63,
2489,
9,
421,
198,
318,
1174,
63,
2489,
8,
277,
304,
507,
198,
74,
275,
291,
14,
2423,
507,
198,
277,
905,
2423,
63,
5734,
4140,
1842,
275,
1335,
14,
500,
507,
198,
277,
905,
4705,
63,
2423,
63,
5734,
4140,
1842,
275,
1335,
14,
500,
507,
198,
277,
905,
2423,
63,
5734,
4140,
585,
275,
1335,
14,
5734,
507,
198,
277,
905,
4705,
63,
2423,
63,
5734,
4140,
585,
275,
1335,
14,
5734,
507,
198,
3,
1361,
298,
6694,
2768,
447,
929,
63,
2489,
6783,
1335,
14,
500,
12,
1335,
14,
5734,
507,
198,
277,
905,
2423,
63,
1205,
4140,
505,
275,
1335,
14,
362,
3694,
505,
342,
507,
198,
692,
1335,
14,
1205,
508,
1335,
14,
568,
63,
24547,
26,
686,
198,
277,
905,
2423,
63,
1765,
4140,
505,
275,
1335,
14,
5054,
59,
74,
14,
1818,
63,
1765,
1055,
354,
686,
198,
277,
905,
4705,
63,
2423,
63,
1765,
4140,
505,
275,
1335,
14,
5054,
59,
74,
14,
1818,
63,
1765,
1055,
354,
507,
198,
2836,
26,
686,
198,
277,
905
] |
[
29372,
14,
9616,
492,
17804,
199,
504,
17823,
14,
2028,
1296,
492,
4094,
1296,
9616,
199,
504,
17823,
14,
888,
492,
4094,
31839,
12,
32245,
12,
664,
2028,
16934,
199,
504,
17823,
14,
3989,
2354,
492,
6187,
2354,
199,
504,
17823,
14,
4476,
492,
3906,
63,
2609,
199,
504,
32767,
3139,
2932,
492,
32767,
30620,
199,
646,
29372,
14,
31060,
199,
504,
23228,
492,
23362,
83,
199,
504,
1234,
1774,
3759,
316,
492,
664,
8412,
34,
3759,
12,
664,
8412,
985,
199,
199,
533,
15057,
2768,
8,
2354,
5281,
30620,
12,
17804,
12,
4094,
1296,
9616,
304,
199,
198,
318,
636,
826,
721,
277,
12,
2351,
12,
3906,
12,
1676,
29,
403,
12,
9311,
461,
275,
715,
12,
8020,
461,
275,
715,
12,
2410,
2390,
4001,
461,
275,
715,
2360,
2410,
2390,
628,
16323,
2349,
507,
198,
504,
17823,
14,
13959,
14,
25289,
492,
13599,
1872,
507,
198,
504,
17823,
14,
13959,
14,
11504,
492,
21211,
507,
198,
504,
17823,
14,
13959,
14,
4082,
492,
9411,
507,
198,
504,
17823,
14,
3310,
2956,
492,
10033,
2956,
507,
198,
9616,
855,
826,
721,
277,
12,
2351,
12,
1676,
9,
507,
198,
9616,
14,
31675,
8,
277,
12,
3824,
6694,
10935,
2237,
507,
198,
2354,
5281,
30620,
855,
826,
721,
277,
9,
507,
198,
2028,
1296,
9616,
855,
826,
721,
277,
12,
3073,
507,
198,
277,
14,
1708,
275,
1676,
507,
198,
277,
14,
2423,
275,
3906,
507,
198,
692,
2410,
2390,
26,
686,
198,
277,
14,
2423,
14,
4399,
2390,
275,
2410,
2390,
2742,
198,
277,
905,
2423,
63,
354,
937,
275,
13599,
1872,
8,
2423,
14,
354,
9,
507,
198,
277,
905,
2423,
63,
5734,
937,
275,
21211,
342,
507,
198,
277,
905,
2423,
63,
1765,
937,
275,
13599,
1872,
342,
507,
198,
277,
905,
4705,
63,
2423,
63,
354,
937,
275,
13599,
1872,
8,
2423,
14,
354,
9,
507,
198,
277,
905,
4705,
63,
2423,
63,
5734,
937,
275,
21211,
342,
507,
198,
277,
905,
4705,
63,
2423,
63,
1765,
937,
275,
13599,
1872,
342,
507,
198,
277,
905,
2423,
63,
1205,
937,
275,
13599,
1872,
342,
507,
198,
277,
905,
8669,
937,
275,
9411,
342,
507,
198,
277,
905,
6406,
461,
937,
275,
9411,
8,
6406,
461,
9,
507,
198,
277,
905,
7451,
461,
937,
275,
9411,
8,
7451,
461,
9,
2742,
198,
277,
905,
498,
63,
6304,
937,
275,
13599,
1872,
6115,
14148,
2237,
2742,
198,
277,
14,
265,
6824,
14,
740,
8,
277,
14,
3806,
6824,
9,
507,
198,
277,
14,
265,
18224,
14,
740,
8,
277,
14,
3806,
18224,
9,
2742,
198,
277,
905,
2758,
9303,
937,
275,
10033,
2956,
5234,
4117,
9303,
401,
298,
8555,
9303,
2255,
507,
198,
91,
686,
198,
2,
7731,
582,
291,
14,
745,
12,
686,
198,
2,
581,
582,
291,
14,
13845,
12,
686,
198,
2,
6304,
582,
291,
14,
7451,
12,
686,
198,
2,
6406,
582,
291,
14,
745,
12,
686,
198,
2,
745,
582,
291,
14,
745,
12,
507,
198,
1386,
446,
18,
9,
2742,
198,
277,
14,
1751,
275,
4094,
31839,
342,
507,
198,
692,
6187,
2354,
905,
27753,
26071,
11532,
6229,
686,
198,
8831,
1558,
275,
3824,
1939,
370,
13217,
10584,
991,
531,
507,
198,
2836,
26,
686,
198,
8831,
1558,
275,
3824,
609,
337,
3224,
531,
507,
198,
277,
14,
1751,
14,
4399,
2390,
275,
32245,
8,
4577,
275,
10003,
16323,
401,
3824,
1117,
6548,
8150,
1689,
1600,
401,
3824,
4724,
8150,
1689,
26071,
401,
3824,
1939,
370,
10584,
991,
8150,
1689,
16131,
26071,
401,
12842,
1558,
4360,
849,
275,
291,
14,
2423,
14,
4399,
2390,
503,
298,
16323,
531,
507,
198,
277,
14,
2423,
14,
4399,
2390,
275,
291,
14,
1751,
14,
4399,
2390,
14,
585,
507,
198,
277,
14,
4399,
2390,
4001,
461,
275,
2410,
2390,
4001,
461,
507,
198,
277,
14,
2758,
1296,
342,
507,
198,
277,
14,
929,
63,
2489,
342,
421,
198,
318,
3272,
1296,
8,
277,
304,
507,
198,
692,
291,
14,
4399,
2390,
4001,
461,
26,
686,
198,
277,
905,
888,
4140,
409,
1296,
8,
359,
664,
2028,
16934,
6115,
10881,
1566,
1288,
291,
14,
1751,
14,
4399,
2390,
9,
4794,
507,
198,
2836,
26,
686,
198,
277,
905,
888,
4140,
8191,
342,
507,
198,
277,
14,
2423,
14,
4399,
2390,
275,
291,
14,
1751,
14,
4399,
2390,
14,
585,
421,
198,
318,
790,
8185,
8,
277,
304,
507,
198,
2028,
1296,
9616,
14,
498,
8185,
8,
277,
9,
507,
198,
277,
14,
2758,
1296,
342,
421,
198,
318,
790,
9121,
8,
277,
304,
507,
198,
2028,
1296,
9616,
14,
498,
9121,
8,
277,
9,
507,
198,
277,
14,
2758,
1296,
342,
421,
198,
318,
4353,
6824,
8,
277,
304,
507,
198,
2423,
63,
2609,
14,
6604,
275,
715,
507,
198,
277,
14,
2423,
14,
929,
63,
2489,
14,
740,
8,
277,
14,
929,
63,
2489,
9,
421,
198,
318,
4353,
18224,
8,
277,
304,
507,
198,
2423,
63,
2609,
14,
6604,
275,
756,
507,
198,
692,
822,
8,
277,
14,
2423,
14,
929,
63,
2489,
9,
690,
378,
26,
686,
198,
277,
14,
2423,
14,
929,
63,
2489,
14,
2168,
8,
277,
14,
929,
63,
2489,
9,
421,
198,
318,
1174,
63,
2489,
8,
277,
304,
507,
198,
74,
275,
291,
14,
2423,
507,
198,
277,
905,
2423,
63,
5734,
4140,
1842,
275,
1335,
14,
500,
507,
198,
277,
905,
4705,
63,
2423,
63,
5734,
4140,
1842,
275,
1335,
14,
500,
507,
198,
277,
905,
2423,
63,
5734,
4140,
585,
275,
1335,
14,
5734,
507,
198,
277,
905,
4705,
63,
2423,
63,
5734,
4140,
585,
275,
1335,
14,
5734,
507,
198,
3,
1361,
298,
6694,
2768,
447,
929,
63,
2489,
6783,
1335,
14,
500,
12,
1335,
14,
5734,
507,
198,
277,
905,
2423,
63,
1205,
4140,
505,
275,
1335,
14,
362,
3694,
505,
342,
507,
198,
692,
1335,
14,
1205,
508,
1335,
14,
568,
63,
24547,
26,
686,
198,
277,
905,
2423,
63,
1765,
4140,
505,
275,
1335,
14,
5054,
59,
74,
14,
1818,
63,
1765,
1055,
354,
686,
198,
277,
905,
4705,
63,
2423,
63,
1765,
4140,
505,
275,
1335,
14,
5054,
59,
74,
14,
1818,
63,
1765,
1055,
354,
507,
198,
2836,
26,
686,
198,
277,
905,
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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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
] |
darkerego/learning-python
|
pygoogle.py
|
1
|
8928
|
#!/usr/bin/python
"""
Google AJAX Search Module
http://code.google.com/apis/ajaxsearch/documentation/reference.html
Needs Python 2.6 or later
"""
try:
import json
except ImportError, e:
print e
exit()
import sys
import urllib
import logging
import argparse
__author__ = "Nikhil. R"
__version__ = "0.2"
URL = 'http://ajax.googleapis.com/ajax/services/search/web?'
# Web Search Specific Arguments
#http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_web
#SAFE,FILTER
"""
SAFE
This optional argument supplies the search safety level which may be one of:
* safe=active - enables the highest level of safe search filtering
* safe=moderate - enables moderate safe search filtering (default)
* safe=off - disables safe search filtering
"""
SAFE_ACTIVE = "active"
SAFE_MODERATE = "moderate"
SAFE_OFF = "off"
"""
FILTER
This optional argument controls turning on or off the duplicate content filter:
* filter=0 - Turns off the duplicate content filter
* filter=1 - Turns on the duplicate content filter (default)
"""
FILTER_OFF = 0
FILTER_ON = 1
#Standard URL Arguments
#http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_args
"""
RSZ
This optional argument supplies the number of results that the application would like to recieve.
A value of small indicates a small result set size or 4 results.
A value of large indicates a large result set or 8 results. If this argument is not supplied, a value of small is assumed.
"""
RSZ_SMALL = "small"
RSZ_LARGE = "large"
"""
HL
This optional argument supplies the host language of the application making the request.
If this argument is not present then the system will choose a value based on the value of the Accept-Language http header.
If this header is not present, a value of en is assumed.
"""
class pygoogle:
def __init__(self, query, pages=10, hl='en', log_level=logging.INFO):
self.pages = int(pages) #Number of pages. default 10
self.query = query
self.filter = FILTER_ON #Controls turning on or off the duplicate content filter. On = 1.
self.rsz = RSZ_LARGE #Results per page. small = 4 /large = 8
self.safe = SAFE_OFF #SafeBrowsing - active/moderate/off
self.hl = hl #Defaults to English (en)
self.__setup_logging(level=log_level)
def __setup_logging(self, level):
logger = logging.getLogger('pygoogle')
logger.setLevel(level)
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(logging.Formatter('%(module)s %(levelname)s %(funcName)s| %(message)s'))
logger.addHandler(handler)
self.logger = logger
def __search__(self, print_results=False):
'''
returns list of results if successful or False otherwise
'''
results = []
for page in range(0, self.pages):
rsz = 8
if self.rsz == RSZ_SMALL:
rsz = 4
args = {'q': self.query,
'v': '1.0',
'start': page * rsz,
'rsz': self.rsz,
'safe': self.safe,
'filter': self.filter,
'hl': self.hl
}
self.logger.debug('search: "%s" page# : %s' % (self.query, page))
q = urllib.urlencode(args)
search_results = urllib.urlopen(URL + q)
data = json.loads(search_results.read())
if not data.has_key('responseStatus'):
self.logger.error('response does not have a responseStatus key')
continue
if data.get('responseStatus') != 200:
self.logger.debug('responseStatus is not 200')
self.logger.error('responseDetails : %s' % (data.get('responseDetails', None)))
continue
if print_results:
if data.has_key('responseData') and data['responseData'].has_key('results'):
for result in data['responseData']['results']:
if result:
print '[%s]' % (urllib.unquote(result['titleNoFormatting']))
print result['content'].strip("<b>...</b>").replace("<b>", '').replace("</b>", '').replace(
"'", "'").strip()
print urllib.unquote(result['unescapedUrl']) + '\n'
else:
# no responseData key was found in 'data'
self.logger.error('no responseData key found in response. very unusal')
results.append(data)
return results
def search(self):
"""Returns a dict of Title/URLs"""
results = {}
search_results = self.__search__()
if not search_results:
self.logger.info('No results returned')
return results
for data in search_results:
if data.has_key('responseData') and data['responseData'].has_key('results'):
for result in data['responseData']['results']:
if result and result.has_key('titleNoFormatting'):
title = urllib.unquote(result['titleNoFormatting'])
results[title] = urllib.unquote(result['unescapedUrl'])
else:
self.logger.error('no responseData key found in response')
self.logger.error(data)
return results
def search_page_wise(self):
"""Returns a dict of page-wise urls"""
results = {}
for page in range(0, self.pages):
args = {'q': self.query,
'v': '1.0',
'start': page,
'rsz': RSZ_LARGE,
'safe': SAFE_OFF,
'filter': FILTER_ON,
}
q = urllib.urlencode(args)
search_results = urllib.urlopen(URL + q)
data = json.loads(search_results.read())
urls = []
if data.has_key('responseData') and data['responseData'].has_key('results'):
for result in data['responseData']['results']:
if result and result.has_key('unescapedUrl'):
url = urllib.unquote(result['unescapedUrl'])
urls.append(url)
else:
self.logger.error('no responseData key found in response')
results[page] = urls
return results
def get_urls(self):
"""Returns list of result URLs"""
results = []
search_results = self.__search__()
if not search_results:
self.logger.info('No results returned')
return results
for data in search_results:
if data and data.has_key('responseData') and data['responseData']['results']:
for result in data['responseData']['results']:
if result:
results.append(urllib.unquote(result['unescapedUrl']))
return results
def get_result_count(self):
"""Returns the number of results"""
temp = self.pages
self.pages = 1
result_count = 0
search_results = self.__search__()
if not search_results:
return 0
try:
result_count = search_results[0]
if not isinstance(result_count, dict):
return 0
result_count = result_count.get('responseData', None)
if result_count:
if result_count.has_key('cursor') and result_count['cursor'].has_key('estimatedResultCount'):
return result_count['cursor']['estimatedResultCount']
return 0
except Exception, e:
self.logger.error(e)
finally:
self.pages = temp
return result_count
def display_results(self):
"""Prints results (for command line)"""
self.__search__(True)
def main():
parser = argparse.ArgumentParser(description='A simple Google search module for Python')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False, help='Verbose mode')
parser.add_argument('-p', '--pages', dest='pages', action='store', default=1,
help='Number of pages to return. Max 10')
parser.add_argument('-hl', '--language', dest='language', action='store', default='en',
help="language. default is 'en'")
parser.add_argument('query', nargs='*', default=None)
args = parser.parse_args()
query = ' '.join(args.query)
log_level = logging.INFO
if args.verbose:
log_level = logging.DEBUG
if not query:
parser.print_help()
exit()
search = pygoogle(log_level=log_level, query=query, pages=args.pages, hl=args.language)
search.display_results()
if __name__ == "__main__":
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
624,
199,
13266,
437,
42,
9839,
8730,
5673,
199,
1014,
921,
600,
14,
3098,
14,
957,
15,
12662,
15,
12774,
1733,
15,
9970,
15,
4443,
14,
1360,
199,
28390,
2018,
499,
14,
22,
503,
2945,
199,
624,
199,
893,
26,
272,
492,
2022,
199,
2590,
3545,
12,
325,
26,
272,
870,
325,
272,
4458,
342,
199,
199,
646,
984,
199,
646,
4011,
199,
646,
2050,
199,
646,
7534,
199,
199,
363,
2502,
363,
275,
298,
46,
3258,
72,
382,
14,
820,
2,
199,
363,
1023,
363,
275,
298,
16,
14,
18,
2,
199,
2632,
275,
283,
1014,
921,
12774,
14,
17533,
14,
957,
15,
12774,
15,
5950,
15,
1733,
15,
2520,
14069,
199,
199,
3,
6001,
8730,
20411,
7628,
199,
3,
1014,
921,
600,
14,
3098,
14,
957,
15,
12662,
15,
12774,
1733,
15,
9970,
15,
4443,
14,
1360,
20930,
70,
265,
6532,
63,
2520,
199,
3,
27657,
12,
9905,
199,
624,
199,
27657,
199,
2765,
2716,
1423,
4973,
6528,
314,
2754,
30261,
2166,
1314,
1443,
506,
1373,
402,
26,
272,
627,
5048,
29,
2682,
446,
22741,
314,
15356,
2166,
402,
5048,
2754,
14545,
272,
627,
5048,
29,
632,
1866,
446,
22741,
818,
1866,
5048,
2754,
14545,
334,
885,
9,
272,
627,
5048,
29,
1997,
446,
28421,
5048,
2754,
14545,
199,
624,
199,
27657,
63,
10401,
275,
298,
2682,
2,
199,
27657,
63,
8816,
540,
1951,
275,
298,
632,
1866,
2,
199,
27657,
63,
7517,
275,
298,
1997,
2,
199,
199,
624,
199,
9905,
199,
2765,
2716,
1423,
13467,
7485,
316,
641,
503,
2331,
314,
9250,
1564,
2457,
26,
339,
627,
2457,
29,
16,
446,
16147,
83,
2331,
314,
9250,
1564,
2457,
272,
627,
2457,
29,
17,
446,
16147,
83,
641,
314,
9250,
1564,
2457,
334,
885,
9,
199,
199,
624,
199,
9905,
63,
7517,
275,
378,
199,
9905,
63,
615,
275,
413,
199,
199,
3,
9232,
2851,
7628,
199,
3,
1014,
921,
600,
14,
3098,
14,
957,
15,
12662,
15,
12774,
1733,
15,
9970,
15,
4443,
14,
1360,
20930,
70,
265,
6532,
63,
589,
199,
624,
199,
15062,
58,
199,
2765,
2716,
1423,
4973,
6528,
314,
1329,
402,
2058,
626,
314,
4223,
3955,
2839,
370,
295,
559,
4754,
14,
221,
199,
33,
574,
402,
7425,
9126,
282,
7425,
754,
663,
1568,
503,
841,
2058,
14,
221,
199,
33,
574,
402,
7031,
9126,
282,
7031,
754,
663,
503,
1695,
2058,
14,
982,
642,
1423,
365,
440,
6841,
12,
282,
574,
402,
7425,
365,
10826,
14,
221,
199,
624,
199,
15062,
58,
63,
28570,
275,
298,
7241,
2,
199,
15062,
58,
63,
15806,
275,
298,
9629,
2,
199,
199,
624,
199,
29210,
199,
2765,
2716,
1423,
4973,
6528,
314,
1591,
2637,
402,
314,
4223,
10663,
314,
1056,
14,
221,
199,
3917,
642,
1423,
365,
440,
3451,
2066,
314,
2656,
911,
11496,
282,
574,
4079,
641,
314,
574,
402,
314,
15506,
13,
8493,
1455,
1406,
14,
221,
199,
3917,
642,
1406,
365,
440,
3451,
12,
282,
574,
402,
655,
365,
10826,
14,
199,
624,
421,
199,
533,
1134,
3098,
26,
272,
347,
636,
826,
721,
277,
12,
1827,
12,
6497,
29,
709,
12,
27768,
534,
287,
297,
943,
63,
1896,
29,
4806,
14,
4531,
304,
267,
291,
14,
5856,
275,
1109,
8,
5856,
9,
221,
327,
3259,
402,
6497,
14,
849,
1616,
267,
291,
14,
1131,
275,
1827,
267,
291,
14,
1541,
275,
23244,
63,
615,
221,
327,
25457,
7485,
316,
641,
503,
2331,
314,
9250,
1564,
2457,
14,
4068,
275,
413,
14,
267,
291,
14,
2393,
90,
275,
820,
18101,
63,
15806,
221,
327,
6579,
1126,
2034,
14,
7425,
275,
841,
1182,
9629,
275,
1695,
267,
291,
14,
3489,
275,
13950,
5100,
63,
7517,
221,
327,
11090,
34,
1143,
1044,
446,
221,
4702,
15,
632,
1866,
15,
1997,
267,
291,
14,
15544,
275,
27768,
221,
327,
16986,
370,
20144,
334,
287,
9,
267,
291,
855,
2758,
63,
4806,
8,
1896,
29,
793,
63,
1896,
9,
339,
347,
636,
2758,
63,
4806,
8,
277,
12,
2166,
304,
267,
2512,
275,
2050,
14,
5572,
360,
647,
3098,
358,
267,
2512,
14,
13548,
8,
1896,
9,
267,
3016,
275,
2050,
14,
22482,
8,
1274,
14,
2703,
9,
267,
3016,
14,
26076,
8,
4806,
14,
7772,
24713,
578,
9,
83,
2818,
20056,
9,
83,
2818,
1532,
985,
9,
83,
92,
2818,
1188,
9,
83,
1333,
267,
2512,
14,
18826,
8,
2232,
9,
267,
291,
14,
2921,
275,
2512,
339,
347,
636,
1733,
721,
277,
12,
870,
63,
2604,
29,
797,
304,
267,
1449,
267,
2529,
769,
402,
2058,
340,
9512,
503,
756,
4257,
267,
1449,
267,
2058,
275,
942,
267,
367,
2034,
315,
1425,
8,
16,
12,
291,
14,
5856,
304,
288,
10717,
90,
275,
1695,
288,
340,
291,
14,
2393,
90,
508,
820,
18101,
63,
28570,
26,
355,
10717,
90,
275,
841,
288,
1249,
275,
791,
81,
356,
291,
14,
1131,
12,
490,
283,
86,
356,
283,
17,
14,
16,
297,
490,
283,
928,
356,
2034,
627,
10717,
90,
12,
490,
283,
2393,
90,
356,
291,
14,
2393,
90,
12,
490,
283,
3489,
356,
291,
14,
3489,
12,
490,
283,
1541,
356,
291,
14,
1541,
12,
490,
283,
15544,
356,
291,
14,
15544,
288,
789,
288,
291,
14,
2921,
14,
1757,
360,
1733,
26,
2071,
83,
2,
2034,
3,
520,
450,
83,
7,
450,
334,
277,
14,
1131,
12,
2034,
430,
288,
1894,
275,
4011,
14,
10738,
8,
589,
9,
288,
2754,
63,
2604,
275,
4011,
14,
10890,
8,
2632,
435,
1894,
9,
288,
666,
275,
2022,
14,
3640,
8,
1733,
63,
2604,
14,
739,
1012,
288,
340,
440,
666,
14,
1989,
63,
498,
360,
1310,
3694,
735,
355,
291,
14,
2921,
14,
705,
360,
1310,
1630,
440,
1172,
282,
1177,
3694,
790,
358,
355,
1980,
288,
340,
666,
14,
362,
360,
1310,
3694,
358,
1137,
1926,
26,
355,
291,
14,
2921,
14,
1757,
360,
1310,
3694,
365,
440,
1926,
358,
355,
291,
14,
2921,
14,
705,
360,
1310,
11347,
520,
450,
83,
7,
450,
334,
576,
14,
362,
360,
1310,
11347,
297,
488,
1724,
355,
1980,
288,
340,
870,
63,
2604,
26,
355,
340,
666,
14,
1989,
63,
498,
360,
1310,
1451,
358,
436,
666,
459,
1310,
1451,
2278,
1989
] |
[
2647,
15,
1393,
15,
1548,
199,
624,
199,
13266,
437,
42,
9839,
8730,
5673,
199,
1014,
921,
600,
14,
3098,
14,
957,
15,
12662,
15,
12774,
1733,
15,
9970,
15,
4443,
14,
1360,
199,
28390,
2018,
499,
14,
22,
503,
2945,
199,
624,
199,
893,
26,
272,
492,
2022,
199,
2590,
3545,
12,
325,
26,
272,
870,
325,
272,
4458,
342,
199,
199,
646,
984,
199,
646,
4011,
199,
646,
2050,
199,
646,
7534,
199,
199,
363,
2502,
363,
275,
298,
46,
3258,
72,
382,
14,
820,
2,
199,
363,
1023,
363,
275,
298,
16,
14,
18,
2,
199,
2632,
275,
283,
1014,
921,
12774,
14,
17533,
14,
957,
15,
12774,
15,
5950,
15,
1733,
15,
2520,
14069,
199,
199,
3,
6001,
8730,
20411,
7628,
199,
3,
1014,
921,
600,
14,
3098,
14,
957,
15,
12662,
15,
12774,
1733,
15,
9970,
15,
4443,
14,
1360,
20930,
70,
265,
6532,
63,
2520,
199,
3,
27657,
12,
9905,
199,
624,
199,
27657,
199,
2765,
2716,
1423,
4973,
6528,
314,
2754,
30261,
2166,
1314,
1443,
506,
1373,
402,
26,
272,
627,
5048,
29,
2682,
446,
22741,
314,
15356,
2166,
402,
5048,
2754,
14545,
272,
627,
5048,
29,
632,
1866,
446,
22741,
818,
1866,
5048,
2754,
14545,
334,
885,
9,
272,
627,
5048,
29,
1997,
446,
28421,
5048,
2754,
14545,
199,
624,
199,
27657,
63,
10401,
275,
298,
2682,
2,
199,
27657,
63,
8816,
540,
1951,
275,
298,
632,
1866,
2,
199,
27657,
63,
7517,
275,
298,
1997,
2,
199,
199,
624,
199,
9905,
199,
2765,
2716,
1423,
13467,
7485,
316,
641,
503,
2331,
314,
9250,
1564,
2457,
26,
339,
627,
2457,
29,
16,
446,
16147,
83,
2331,
314,
9250,
1564,
2457,
272,
627,
2457,
29,
17,
446,
16147,
83,
641,
314,
9250,
1564,
2457,
334,
885,
9,
199,
199,
624,
199,
9905,
63,
7517,
275,
378,
199,
9905,
63,
615,
275,
413,
199,
199,
3,
9232,
2851,
7628,
199,
3,
1014,
921,
600,
14,
3098,
14,
957,
15,
12662,
15,
12774,
1733,
15,
9970,
15,
4443,
14,
1360,
20930,
70,
265,
6532,
63,
589,
199,
624,
199,
15062,
58,
199,
2765,
2716,
1423,
4973,
6528,
314,
1329,
402,
2058,
626,
314,
4223,
3955,
2839,
370,
295,
559,
4754,
14,
221,
199,
33,
574,
402,
7425,
9126,
282,
7425,
754,
663,
1568,
503,
841,
2058,
14,
221,
199,
33,
574,
402,
7031,
9126,
282,
7031,
754,
663,
503,
1695,
2058,
14,
982,
642,
1423,
365,
440,
6841,
12,
282,
574,
402,
7425,
365,
10826,
14,
221,
199,
624,
199,
15062,
58,
63,
28570,
275,
298,
7241,
2,
199,
15062,
58,
63,
15806,
275,
298,
9629,
2,
199,
199,
624,
199,
29210,
199,
2765,
2716,
1423,
4973,
6528,
314,
1591,
2637,
402,
314,
4223,
10663,
314,
1056,
14,
221,
199,
3917,
642,
1423,
365,
440,
3451,
2066,
314,
2656,
911,
11496,
282,
574,
4079,
641,
314,
574,
402,
314,
15506,
13,
8493,
1455,
1406,
14,
221,
199,
3917,
642,
1406,
365,
440,
3451,
12,
282,
574,
402,
655,
365,
10826,
14,
199,
624,
421,
199,
533,
1134,
3098,
26,
272,
347,
636,
826,
721,
277,
12,
1827,
12,
6497,
29,
709,
12,
27768,
534,
287,
297,
943,
63,
1896,
29,
4806,
14,
4531,
304,
267,
291,
14,
5856,
275,
1109,
8,
5856,
9,
221,
327,
3259,
402,
6497,
14,
849,
1616,
267,
291,
14,
1131,
275,
1827,
267,
291,
14,
1541,
275,
23244,
63,
615,
221,
327,
25457,
7485,
316,
641,
503,
2331,
314,
9250,
1564,
2457,
14,
4068,
275,
413,
14,
267,
291,
14,
2393,
90,
275,
820,
18101,
63,
15806,
221,
327,
6579,
1126,
2034,
14,
7425,
275,
841,
1182,
9629,
275,
1695,
267,
291,
14,
3489,
275,
13950,
5100,
63,
7517,
221,
327,
11090,
34,
1143,
1044,
446,
221,
4702,
15,
632,
1866,
15,
1997,
267,
291,
14,
15544,
275,
27768,
221,
327,
16986,
370,
20144,
334,
287,
9,
267,
291,
855,
2758,
63,
4806,
8,
1896,
29,
793,
63,
1896,
9,
339,
347,
636,
2758,
63,
4806,
8,
277,
12,
2166,
304,
267,
2512,
275,
2050,
14,
5572,
360,
647,
3098,
358,
267,
2512,
14,
13548,
8,
1896,
9,
267,
3016,
275,
2050,
14,
22482,
8,
1274,
14,
2703,
9,
267,
3016,
14,
26076,
8,
4806,
14,
7772,
24713,
578,
9,
83,
2818,
20056,
9,
83,
2818,
1532,
985,
9,
83,
92,
2818,
1188,
9,
83,
1333,
267,
2512,
14,
18826,
8,
2232,
9,
267,
291,
14,
2921,
275,
2512,
339,
347,
636,
1733,
721,
277,
12,
870,
63,
2604,
29,
797,
304,
267,
1449,
267,
2529,
769,
402,
2058,
340,
9512,
503,
756,
4257,
267,
1449,
267,
2058,
275,
942,
267,
367,
2034,
315,
1425,
8,
16,
12,
291,
14,
5856,
304,
288,
10717,
90,
275,
1695,
288,
340,
291,
14,
2393,
90,
508,
820,
18101,
63,
28570,
26,
355,
10717,
90,
275,
841,
288,
1249,
275,
791,
81,
356,
291,
14,
1131,
12,
490,
283,
86,
356,
283,
17,
14,
16,
297,
490,
283,
928,
356,
2034,
627,
10717,
90,
12,
490,
283,
2393,
90,
356,
291,
14,
2393,
90,
12,
490,
283,
3489,
356,
291,
14,
3489,
12,
490,
283,
1541,
356,
291,
14,
1541,
12,
490,
283,
15544,
356,
291,
14,
15544,
288,
789,
288,
291,
14,
2921,
14,
1757,
360,
1733,
26,
2071,
83,
2,
2034,
3,
520,
450,
83,
7,
450,
334,
277,
14,
1131,
12,
2034,
430,
288,
1894,
275,
4011,
14,
10738,
8,
589,
9,
288,
2754,
63,
2604,
275,
4011,
14,
10890,
8,
2632,
435,
1894,
9,
288,
666,
275,
2022,
14,
3640,
8,
1733,
63,
2604,
14,
739,
1012,
288,
340,
440,
666,
14,
1989,
63,
498,
360,
1310,
3694,
735,
355,
291,
14,
2921,
14,
705,
360,
1310,
1630,
440,
1172,
282,
1177,
3694,
790,
358,
355,
1980,
288,
340,
666,
14,
362,
360,
1310,
3694,
358,
1137,
1926,
26,
355,
291,
14,
2921,
14,
1757,
360,
1310,
3694,
365,
440,
1926,
358,
355,
291,
14,
2921,
14,
705,
360,
1310,
11347,
520,
450,
83,
7,
450,
334,
576,
14,
362,
360,
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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
] |
ayust/evelink
|
evelink/parsing/orders.py
|
9
|
1045
|
from evelink import api
from evelink import constants
def parse_market_orders(api_result):
rowset = api_result.find('rowset')
rows = rowset.findall('row')
result = {}
for row in rows:
a = row.attrib
id = int(a['orderID'])
result[id] = {
'id': id,
'char_id': int(a['charID']),
'station_id': int(a['stationID']),
'amount': int(a['volEntered']),
'amount_left': int(a['volRemaining']),
'status': constants.Market().order_status[int(a['orderState'])],
'type_id': int(a['typeID']),
'range': int(a['range']),
'account_key': int(a['accountKey']),
'duration': int(a['duration']),
'escrow': float(a['escrow']),
'price': float(a['price']),
'type': 'buy' if a['bid'] == '1' else 'sell',
'timestamp': api.parse_ts(a['issued']),
}
return result
|
mit
|
[
504,
325,
1090,
2292,
492,
2986,
199,
504,
325,
1090,
2292,
492,
5262,
199,
199,
318,
2198,
63,
22270,
63,
14387,
8,
1246,
63,
1099,
304,
267,
1962,
409,
275,
2986,
63,
1099,
14,
1623,
360,
1143,
409,
358,
267,
4730,
275,
1962,
409,
14,
6452,
360,
1143,
358,
267,
754,
275,
1052,
267,
367,
1962,
315,
4730,
26,
288,
282,
275,
1962,
14,
6640,
288,
1305,
275,
1109,
8,
65,
459,
1648,
998,
1105,
288,
754,
59,
344,
61,
275,
469,
355,
283,
344,
356,
1305,
12,
355,
283,
1560,
63,
344,
356,
1109,
8,
65,
459,
1560,
998,
3815,
355,
283,
10600,
63,
344,
356,
1109,
8,
65,
459,
10600,
998,
3815,
355,
283,
4606,
356,
1109,
8,
65,
459,
5650,
1327,
3014,
3815,
355,
283,
4606,
63,
3039,
356,
1109,
8,
65,
459,
5650,
31109,
3815,
355,
283,
1205,
356,
5262,
14,
21667,
1252,
1648,
63,
1205,
59,
442,
8,
65,
459,
1648,
2223,
1105,
467,
355,
283,
466,
63,
344,
356,
1109,
8,
65,
459,
466,
998,
3815,
355,
283,
1842,
356,
1109,
8,
65,
459,
1842,
3815,
355,
283,
2048,
63,
498,
356,
1109,
8,
65,
459,
2048,
1197,
3815,
355,
283,
5553,
356,
1109,
8,
65,
459,
5553,
3815,
355,
283,
19303,
1143,
356,
2069,
8,
65,
459,
19303,
1143,
3815,
355,
283,
4777,
356,
2069,
8,
65,
459,
4777,
3815,
355,
283,
466,
356,
283,
31240,
7,
340,
282,
459,
17949,
418,
508,
283,
17,
7,
587,
283,
23235,
297,
355,
283,
3954,
356,
2986,
14,
1122,
63,
1086,
8,
65,
459,
5237,
68,
3815,
288,
789,
398,
372,
754,
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
] |
[
325,
1090,
2292,
492,
2986,
199,
504,
325,
1090,
2292,
492,
5262,
199,
199,
318,
2198,
63,
22270,
63,
14387,
8,
1246,
63,
1099,
304,
267,
1962,
409,
275,
2986,
63,
1099,
14,
1623,
360,
1143,
409,
358,
267,
4730,
275,
1962,
409,
14,
6452,
360,
1143,
358,
267,
754,
275,
1052,
267,
367,
1962,
315,
4730,
26,
288,
282,
275,
1962,
14,
6640,
288,
1305,
275,
1109,
8,
65,
459,
1648,
998,
1105,
288,
754,
59,
344,
61,
275,
469,
355,
283,
344,
356,
1305,
12,
355,
283,
1560,
63,
344,
356,
1109,
8,
65,
459,
1560,
998,
3815,
355,
283,
10600,
63,
344,
356,
1109,
8,
65,
459,
10600,
998,
3815,
355,
283,
4606,
356,
1109,
8,
65,
459,
5650,
1327,
3014,
3815,
355,
283,
4606,
63,
3039,
356,
1109,
8,
65,
459,
5650,
31109,
3815,
355,
283,
1205,
356,
5262,
14,
21667,
1252,
1648,
63,
1205,
59,
442,
8,
65,
459,
1648,
2223,
1105,
467,
355,
283,
466,
63,
344,
356,
1109,
8,
65,
459,
466,
998,
3815,
355,
283,
1842,
356,
1109,
8,
65,
459,
1842,
3815,
355,
283,
2048,
63,
498,
356,
1109,
8,
65,
459,
2048,
1197,
3815,
355,
283,
5553,
356,
1109,
8,
65,
459,
5553,
3815,
355,
283,
19303,
1143,
356,
2069,
8,
65,
459,
19303,
1143,
3815,
355,
283,
4777,
356,
2069,
8,
65,
459,
4777,
3815,
355,
283,
466,
356,
283,
31240,
7,
340,
282,
459,
17949,
418,
508,
283,
17,
7,
587,
283,
23235,
297,
355,
283,
3954,
356,
2986,
14,
1122,
63,
1086,
8,
65,
459,
5237,
68,
3815,
288,
789,
398,
372,
754,
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,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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
] |
dya2/python-for-android
|
python-modules/twisted/twisted/persisted/crefutil.py
|
61
|
4644
|
# -*- test-case-name: twisted.test.test_persisted -*-
# Copyright (c) 2001-2008 Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Utility classes for dealing with circular references.
"""
from twisted.python import log, reflect
try:
from new import instancemethod
except:
from org.python.core import PyMethod
instancemethod = PyMethod
class NotKnown:
def __init__(self):
self.dependants = []
self.resolved = 0
def addDependant(self, mutableObject, key):
assert not self.resolved
self.dependants.append( (mutableObject, key) )
resolvedObject = None
def resolveDependants(self, newObject):
self.resolved = 1
self.resolvedObject = newObject
for mut, key in self.dependants:
mut[key] = newObject
if isinstance(newObject, NotKnown):
newObject.addDependant(mut, key)
def __hash__(self):
assert 0, "I am not to be used as a dictionary key."
class _Container(NotKnown):
"""
Helper class to resolve circular references on container objects.
"""
def __init__(self, l, containerType):
"""
@param l: The list of object which may contain some not yet referenced
objects.
@param containerType: A type of container objects (e.g., C{tuple} or
C{set}).
"""
NotKnown.__init__(self)
self.containerType = containerType
self.l = l
self.locs = range(len(l))
for idx in xrange(len(l)):
if not isinstance(l[idx], NotKnown):
self.locs.remove(idx)
else:
l[idx].addDependant(self, idx)
if not self.locs:
self.resolveDependants(self.containerType(self.l))
def __setitem__(self, n, obj):
"""
Change the value of one contained objects, and resolve references if
all objects have been referenced.
"""
self.l[n] = obj
if not isinstance(obj, NotKnown):
self.locs.remove(n)
if not self.locs:
self.resolveDependants(self.containerType(self.l))
class _Tuple(_Container):
"""
Manage tuple containing circular references. Deprecated: use C{_Container}
instead.
"""
def __init__(self, l):
"""
@param l: The list of object which may contain some not yet referenced
objects.
"""
_Container.__init__(self, l, tuple)
class _InstanceMethod(NotKnown):
def __init__(self, im_name, im_self, im_class):
NotKnown.__init__(self)
self.my_class = im_class
self.name = im_name
# im_self _must_ be a
im_self.addDependant(self, 0)
def __call__(self, *args, **kw):
import traceback
log.msg('instance method %s.%s' % (reflect.qual(self.my_class), self.name))
log.msg('being called with %r %r' % (args, kw))
traceback.print_stack(file=log.logfile)
assert 0
def __setitem__(self, n, obj):
assert n == 0, "only zero index allowed"
if not isinstance(obj, NotKnown):
self.resolveDependants(instancemethod(self.my_class.__dict__[self.name],
obj,
self.my_class))
class _DictKeyAndValue:
def __init__(self, dict):
self.dict = dict
def __setitem__(self, n, obj):
if n not in (1, 0):
raise RuntimeError("DictKeyAndValue should only ever be called with 0 or 1")
if n: # value
self.value = obj
else:
self.key = obj
if hasattr(self, "key") and hasattr(self, "value"):
self.dict[self.key] = self.value
class _Dereference(NotKnown):
def __init__(self, id):
NotKnown.__init__(self)
self.id = id
from twisted.internet.defer import Deferred
class _Catcher:
def catch(self, value):
self.value = value
class _Defer(Deferred, NotKnown):
def __init__(self):
Deferred.__init__(self)
NotKnown.__init__(self)
self.pause()
wasset = 0
def __setitem__(self, n, obj):
if self.wasset:
raise RuntimeError('setitem should only be called once, setting %r to %r' % (n, obj))
else:
self.wasset = 1
self.callback(obj)
def addDependant(self, dep, key):
# by the time I'm adding a dependant, I'm *not* adding any more
# callbacks
NotKnown.addDependant(self, dep, key)
self.unpause()
resovd = self.result
self.resolveDependants(resovd)
|
apache-2.0
|
[
3,
1882,
511,
13,
2546,
13,
354,
26,
7390,
14,
396,
14,
396,
63,
529,
24925,
1882,
199,
199,
3,
1898,
334,
67,
9,
12521,
13,
9300,
17078,
8449,
26640,
14,
199,
3,
1666,
5113,
367,
2436,
14,
421,
199,
624,
199,
17505,
3992,
367,
23654,
543,
15032,
6941,
14,
199,
624,
199,
199,
504,
7390,
14,
1548,
492,
943,
12,
16806,
199,
199,
893,
26,
272,
687,
892,
492,
1256,
765,
199,
2590,
26,
272,
687,
5981,
14,
1548,
14,
1018,
492,
1611,
3767,
272,
1256,
765,
275,
1611,
3767,
421,
199,
533,
2832,
24574,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
26434,
2285,
275,
942,
267,
291,
14,
13697,
275,
378,
339,
347,
1050,
872,
6643,
867,
8,
277,
12,
17194,
1692,
12,
790,
304,
267,
702,
440,
291,
14,
13697,
267,
291,
14,
26434,
2285,
14,
740,
8,
334,
17404,
1692,
12,
790,
9,
776,
339,
12152,
1692,
275,
488,
339,
347,
7512,
872,
6643,
2285,
8,
277,
12,
892,
1692,
304,
267,
291,
14,
13697,
275,
413,
267,
291,
14,
13697,
1692,
275,
892,
1692,
267,
367,
8567,
12,
790,
315,
291,
14,
26434,
2285,
26,
288,
8567,
59,
498,
61,
275,
892,
1692,
288,
340,
1228,
8,
1222,
1692,
12,
2832,
24574,
304,
355,
892,
1692,
14,
525,
872,
6643,
867,
8,
6552,
12,
790,
9,
339,
347,
636,
2227,
721,
277,
304,
267,
702,
378,
12,
298,
41,
8140,
440,
370,
506,
1202,
465,
282,
2600,
790,
2122,
4388,
199,
533,
485,
4076,
8,
1763,
24574,
304,
272,
408,
272,
11642,
1021,
370,
7512,
15032,
6941,
641,
3970,
2251,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
634,
12,
3970,
804,
304,
267,
408,
267,
768,
635,
634,
26,
710,
769,
402,
909,
1314,
1443,
1395,
2005,
440,
5966,
11812,
267,
2251,
14,
398,
768,
635,
3970,
804,
26,
437,
730,
402,
3970,
2251,
334,
69,
14,
71,
2020,
445,
91,
2960,
93,
503,
288,
445,
91,
409,
21385,
267,
408,
267,
2832,
24574,
855,
826,
721,
277,
9,
267,
291,
14,
3600,
804,
275,
3970,
804,
267,
291,
14,
76,
275,
634,
267,
291,
14,
15781,
275,
1425,
8,
552,
8,
76,
430,
267,
367,
4280,
315,
4945,
8,
552,
8,
76,
2298,
288,
340,
440,
1228,
8,
76,
59,
2996,
467,
2832,
24574,
304,
355,
291,
14,
15781,
14,
2168,
8,
2996,
9,
288,
587,
26,
355,
634,
59,
2996,
1055,
525,
872,
6643,
867,
8,
277,
12,
4280,
9,
267,
340,
440,
291,
14,
15781,
26,
288,
291,
14,
6983,
872,
6643,
2285,
8,
277,
14,
3600,
804,
8,
277,
14,
76,
430,
2378,
347,
636,
8617,
721,
277,
12,
302,
12,
1559,
304,
267,
408,
267,
7743,
314,
574,
402,
1373,
10470,
2251,
12,
436,
7512,
6941,
340,
267,
1006,
2251,
1172,
2757,
11812,
14,
267,
408,
267,
291,
14,
76,
59,
78,
61,
275,
1559,
267,
340,
440,
1228,
8,
1113,
12,
2832,
24574,
304,
288,
291,
14,
15781,
14,
2168,
8,
78,
9,
288,
340,
440,
291,
14,
15781,
26,
355,
291,
14,
6983,
872,
6643,
2285,
8,
277,
14,
3600,
804,
8,
277,
14,
76,
430,
4388,
199,
533,
485,
7075,
1547,
4076,
304,
272,
408,
272,
14944,
2008,
3035,
15032,
6941,
14,
17993,
26,
675,
445,
26975,
4076,
93,
272,
3140,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
634,
304,
267,
408,
267,
768,
635,
634,
26,
710,
769,
402,
909,
1314,
1443,
1395,
2005,
440,
5966,
11812,
267,
2251,
14,
267,
408,
267,
485,
4076,
855,
826,
721,
277,
12,
634,
12,
2008,
9,
4388,
199,
533,
485,
3244,
3767,
8,
1763,
24574,
304,
272,
347,
636,
826,
721,
277,
12,
3416,
63,
354,
12,
3416,
63,
277,
12,
3416,
63,
533,
304,
267,
2832,
24574,
855,
826,
721,
277,
9,
267,
291,
14,
1662,
63,
533,
275,
3416,
63,
533,
267,
291,
14,
354,
275,
3416,
63,
354,
267,
327,
3416,
63,
277,
485,
7790,
63,
506,
282,
267,
3416,
63,
277,
14,
525,
872,
6643,
867,
8,
277,
12,
378,
9,
339,
347,
636,
1250,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
492,
5190,
267,
943,
14,
1328,
360,
842,
1083,
450,
83,
4111,
83,
7,
450,
334,
21963,
14,
537,
8,
277,
14,
1662,
63,
533,
395,
291,
14,
354,
430,
267,
943,
14,
1328,
360,
1235,
316,
2797,
543,
450,
82,
450,
82,
7,
450,
334,
589,
12,
4775,
430,
267,
5190,
14,
1361,
63,
2340,
8,
493,
29,
793,
14,
12804,
9,
267,
702,
378,
339,
347,
636,
8617,
721,
277,
12,
302,
12,
1559,
304,
267,
702,
302,
508,
378,
12,
298,
2118,
4697,
1478,
4370,
2,
267,
340,
440,
1228,
8,
1113,
12,
2832,
24574,
304,
288,
291,
14,
6983,
872,
6643,
2285,
8,
842,
765,
8,
277,
14,
1662,
63,
533,
855,
807,
12298,
277,
14,
354,
467,
8179,
1559,
12,
8179,
291,
14,
1662,
63,
533,
430,
199,
199,
533,
485,
2141,
1197,
3325,
1110,
26,
272,
347,
636,
826,
721,
277,
12,
1211,
304,
267,
291,
14,
807,
275,
1211,
272,
347,
636,
8617,
721,
277,
12,
302,
12,
1559,
304,
267,
340,
302,
440,
315,
334,
17,
12,
378,
304,
288,
746,
6064,
480,
2141,
1197,
3325,
1110,
1077,
1454,
14433,
506,
2797,
543,
378,
503,
413,
531,
267,
340,
302,
26,
327,
574,
288,
291,
14,
585,
275,
1559,
267,
587,
26,
288,
291,
14,
498,
275,
1559,
267,
340,
2688,
8,
277,
12,
298,
498,
531,
436,
2688,
8,
277,
12,
298,
585,
2349,
288,
291,
14,
807,
59,
277,
14,
498,
61,
275,
291,
14,
585,
421,
199,
533,
485,
872,
4443,
8,
1763,
24574,
304,
272,
347,
636,
826,
721,
277,
12,
1305,
304,
267,
2832,
24574,
855,
826,
721,
277,
9,
267,
291,
14,
344,
275,
1305,
421,
199,
504,
7390,
14,
4901,
14,
11610,
492,
17448,
199,
199,
533,
485,
26096,
281,
26,
272,
347,
8579,
8,
277,
12,
574,
304,
267,
291,
14,
585,
275,
574,
199,
199,
533,
485,
872,
2412,
8,
9937,
12,
2832,
24574,
304,
272,
347,
636,
826,
721,
277,
304,
267,
17448,
855,
826
] |
[
1882,
511,
13,
2546,
13,
354,
26,
7390,
14,
396,
14,
396,
63,
529,
24925,
1882,
199,
199,
3,
1898,
334,
67,
9,
12521,
13,
9300,
17078,
8449,
26640,
14,
199,
3,
1666,
5113,
367,
2436,
14,
421,
199,
624,
199,
17505,
3992,
367,
23654,
543,
15032,
6941,
14,
199,
624,
199,
199,
504,
7390,
14,
1548,
492,
943,
12,
16806,
199,
199,
893,
26,
272,
687,
892,
492,
1256,
765,
199,
2590,
26,
272,
687,
5981,
14,
1548,
14,
1018,
492,
1611,
3767,
272,
1256,
765,
275,
1611,
3767,
421,
199,
533,
2832,
24574,
26,
272,
347,
636,
826,
721,
277,
304,
267,
291,
14,
26434,
2285,
275,
942,
267,
291,
14,
13697,
275,
378,
339,
347,
1050,
872,
6643,
867,
8,
277,
12,
17194,
1692,
12,
790,
304,
267,
702,
440,
291,
14,
13697,
267,
291,
14,
26434,
2285,
14,
740,
8,
334,
17404,
1692,
12,
790,
9,
776,
339,
12152,
1692,
275,
488,
339,
347,
7512,
872,
6643,
2285,
8,
277,
12,
892,
1692,
304,
267,
291,
14,
13697,
275,
413,
267,
291,
14,
13697,
1692,
275,
892,
1692,
267,
367,
8567,
12,
790,
315,
291,
14,
26434,
2285,
26,
288,
8567,
59,
498,
61,
275,
892,
1692,
288,
340,
1228,
8,
1222,
1692,
12,
2832,
24574,
304,
355,
892,
1692,
14,
525,
872,
6643,
867,
8,
6552,
12,
790,
9,
339,
347,
636,
2227,
721,
277,
304,
267,
702,
378,
12,
298,
41,
8140,
440,
370,
506,
1202,
465,
282,
2600,
790,
2122,
4388,
199,
533,
485,
4076,
8,
1763,
24574,
304,
272,
408,
272,
11642,
1021,
370,
7512,
15032,
6941,
641,
3970,
2251,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
634,
12,
3970,
804,
304,
267,
408,
267,
768,
635,
634,
26,
710,
769,
402,
909,
1314,
1443,
1395,
2005,
440,
5966,
11812,
267,
2251,
14,
398,
768,
635,
3970,
804,
26,
437,
730,
402,
3970,
2251,
334,
69,
14,
71,
2020,
445,
91,
2960,
93,
503,
288,
445,
91,
409,
21385,
267,
408,
267,
2832,
24574,
855,
826,
721,
277,
9,
267,
291,
14,
3600,
804,
275,
3970,
804,
267,
291,
14,
76,
275,
634,
267,
291,
14,
15781,
275,
1425,
8,
552,
8,
76,
430,
267,
367,
4280,
315,
4945,
8,
552,
8,
76,
2298,
288,
340,
440,
1228,
8,
76,
59,
2996,
467,
2832,
24574,
304,
355,
291,
14,
15781,
14,
2168,
8,
2996,
9,
288,
587,
26,
355,
634,
59,
2996,
1055,
525,
872,
6643,
867,
8,
277,
12,
4280,
9,
267,
340,
440,
291,
14,
15781,
26,
288,
291,
14,
6983,
872,
6643,
2285,
8,
277,
14,
3600,
804,
8,
277,
14,
76,
430,
2378,
347,
636,
8617,
721,
277,
12,
302,
12,
1559,
304,
267,
408,
267,
7743,
314,
574,
402,
1373,
10470,
2251,
12,
436,
7512,
6941,
340,
267,
1006,
2251,
1172,
2757,
11812,
14,
267,
408,
267,
291,
14,
76,
59,
78,
61,
275,
1559,
267,
340,
440,
1228,
8,
1113,
12,
2832,
24574,
304,
288,
291,
14,
15781,
14,
2168,
8,
78,
9,
288,
340,
440,
291,
14,
15781,
26,
355,
291,
14,
6983,
872,
6643,
2285,
8,
277,
14,
3600,
804,
8,
277,
14,
76,
430,
4388,
199,
533,
485,
7075,
1547,
4076,
304,
272,
408,
272,
14944,
2008,
3035,
15032,
6941,
14,
17993,
26,
675,
445,
26975,
4076,
93,
272,
3140,
14,
272,
408,
339,
347,
636,
826,
721,
277,
12,
634,
304,
267,
408,
267,
768,
635,
634,
26,
710,
769,
402,
909,
1314,
1443,
1395,
2005,
440,
5966,
11812,
267,
2251,
14,
267,
408,
267,
485,
4076,
855,
826,
721,
277,
12,
634,
12,
2008,
9,
4388,
199,
533,
485,
3244,
3767,
8,
1763,
24574,
304,
272,
347,
636,
826,
721,
277,
12,
3416,
63,
354,
12,
3416,
63,
277,
12,
3416,
63,
533,
304,
267,
2832,
24574,
855,
826,
721,
277,
9,
267,
291,
14,
1662,
63,
533,
275,
3416,
63,
533,
267,
291,
14,
354,
275,
3416,
63,
354,
267,
327,
3416,
63,
277,
485,
7790,
63,
506,
282,
267,
3416,
63,
277,
14,
525,
872,
6643,
867,
8,
277,
12,
378,
9,
339,
347,
636,
1250,
721,
277,
12,
627,
589,
12,
1011,
829,
304,
267,
492,
5190,
267,
943,
14,
1328,
360,
842,
1083,
450,
83,
4111,
83,
7,
450,
334,
21963,
14,
537,
8,
277,
14,
1662,
63,
533,
395,
291,
14,
354,
430,
267,
943,
14,
1328,
360,
1235,
316,
2797,
543,
450,
82,
450,
82,
7,
450,
334,
589,
12,
4775,
430,
267,
5190,
14,
1361,
63,
2340,
8,
493,
29,
793,
14,
12804,
9,
267,
702,
378,
339,
347,
636,
8617,
721,
277,
12,
302,
12,
1559,
304,
267,
702,
302,
508,
378,
12,
298,
2118,
4697,
1478,
4370,
2,
267,
340,
440,
1228,
8,
1113,
12,
2832,
24574,
304,
288,
291,
14,
6983,
872,
6643,
2285,
8,
842,
765,
8,
277,
14,
1662,
63,
533,
855,
807,
12298,
277,
14,
354,
467,
8179,
1559,
12,
8179,
291,
14,
1662,
63,
533,
430,
199,
199,
533,
485,
2141,
1197,
3325,
1110,
26,
272,
347,
636,
826,
721,
277,
12,
1211,
304,
267,
291,
14,
807,
275,
1211,
272,
347,
636,
8617,
721,
277,
12,
302,
12,
1559,
304,
267,
340,
302,
440,
315,
334,
17,
12,
378,
304,
288,
746,
6064,
480,
2141,
1197,
3325,
1110,
1077,
1454,
14433,
506,
2797,
543,
378,
503,
413,
531,
267,
340,
302,
26,
327,
574,
288,
291,
14,
585,
275,
1559,
267,
587,
26,
288,
291,
14,
498,
275,
1559,
267,
340,
2688,
8,
277,
12,
298,
498,
531,
436,
2688,
8,
277,
12,
298,
585,
2349,
288,
291,
14,
807,
59,
277,
14,
498,
61,
275,
291,
14,
585,
421,
199,
533,
485,
872,
4443,
8,
1763,
24574,
304,
272,
347,
636,
826,
721,
277,
12,
1305,
304,
267,
2832,
24574,
855,
826,
721,
277,
9,
267,
291,
14,
344,
275,
1305,
421,
199,
504,
7390,
14,
4901,
14,
11610,
492,
17448,
199,
199,
533,
485,
26096,
281,
26,
272,
347,
8579,
8,
277,
12,
574,
304,
267,
291,
14,
585,
275,
574,
199,
199,
533,
485,
872,
2412,
8,
9937,
12,
2832,
24574,
304,
272,
347,
636,
826,
721,
277,
304,
267,
17448,
855,
826,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
StevenBlack/phantomjs
|
src/qt/qtwebkit/Tools/Scripts/webkitpy/layout_tests/servers/http_server_unittest.py
|
117
|
4727
|
# Copyright (C) 2012 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import re
import sys
import unittest2 as unittest
from webkitpy.common.host_mock import MockHost
from webkitpy.port import test
from webkitpy.layout_tests.servers.http_server import Lighttpd
from webkitpy.layout_tests.servers.http_server_base import ServerError
class TestHttpServer(unittest.TestCase):
def test_start_cmd(self):
# Fails on win - see https://bugs.webkit.org/show_bug.cgi?id=84726
if sys.platform in ('cygwin', 'win32'):
return
host = MockHost()
test_port = test.TestPort(host)
host.filesystem.write_text_file(
"/mock-checkout/Tools/Scripts/webkitpy/layout_tests/servers/lighttpd.conf", "Mock Config\n")
host.filesystem.write_text_file(
"/usr/lib/lighttpd/liblightcomp.dylib", "Mock dylib")
server = Lighttpd(test_port, "/mock/output_dir",
additional_dirs={
"/mock/one-additional-dir": "/mock-checkout/one-additional-dir",
"/mock/another-additional-dir": "/mock-checkout/one-additional-dir"})
self.assertRaises(ServerError, server.start)
config_file = host.filesystem.read_text_file("/mock/output_dir/lighttpd.conf")
self.assertEqual(re.findall(r"alias.url.+", config_file), [
'alias.url = ( "/js-test-resources" => "/test.checkout/LayoutTests/fast/js/resources" )',
'alias.url += ( "/mock/one-additional-dir" => "/mock-checkout/one-additional-dir" )',
'alias.url += ( "/mock/another-additional-dir" => "/mock-checkout/one-additional-dir" )',
'alias.url += ( "/media-resources" => "/test.checkout/LayoutTests/media" )',
])
def test_win32_start_and_stop(self):
host = MockHost()
test_port = test.TestPort(host)
host.filesystem.write_text_file(
"/mock-checkout/Tools/Scripts/webkitpy/layout_tests/servers/lighttpd.conf", "Mock Config\n")
host.filesystem.write_text_file(
"/usr/lib/lighttpd/liblightcomp.dylib", "Mock dylib")
host.platform.is_win = lambda: True
host.platform.is_cygwin = lambda: False
server = Lighttpd(test_port, "/mock/output_dir",
additional_dirs={
"/mock/one-additional-dir": "/mock-checkout/one-additional-dir",
"/mock/another-additional-dir": "/mock-checkout/one-additional-dir"})
server._check_that_all_ports_are_available = lambda: True
server._is_server_running_on_all_ports = lambda: True
server.start()
self.assertNotEquals(host.executive.calls, [])
def wait_for_action(action):
if action():
return True
return action()
def mock_returns(return_values):
def return_value_thunk(*args, **kwargs):
return return_values.pop(0)
return return_value_thunk
host.executive.check_running_pid = mock_returns([True, False])
server._wait_for_action = wait_for_action
server.stop()
self.assertEqual(['taskkill.exe', '/f', '/t', '/pid', 42], host.executive.calls[1])
|
bsd-3-clause
|
[
3,
1898,
334,
35,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
295,
199,
646,
984,
199,
646,
2882,
18,
465,
2882,
199,
199,
504,
18007,
14,
2330,
14,
1102,
63,
1805,
492,
4420,
4965,
199,
504,
18007,
14,
719,
492,
511,
199,
504,
18007,
14,
4209,
63,
2219,
14,
5871,
14,
1014,
63,
1000,
492,
491,
528,
21594,
199,
504,
18007,
14,
4209,
63,
2219,
14,
5871,
14,
1014,
63,
1000,
63,
1095,
492,
7146,
547,
421,
199,
533,
1379,
5779,
3120,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
928,
63,
1760,
8,
277,
304,
267,
327,
12176,
83,
641,
4747,
446,
1937,
4178,
921,
13017,
14,
12554,
14,
1308,
15,
2384,
63,
1266,
14,
13814,
31,
344,
29,
15883,
1479,
267,
340,
984,
14,
3246,
315,
661,
16680,
297,
283,
2676,
708,
735,
288,
372,
398,
1591,
275,
4420,
4965,
342,
267,
511,
63,
719,
275,
511,
14,
774,
4313,
8,
1102,
9,
267,
1591,
14,
11381,
14,
952,
63,
505,
63,
493,
8,
288,
3286,
1805,
13,
12891,
15,
11654,
15,
25681,
15,
12554,
647,
15,
4209,
63,
2219,
15,
5871,
15,
4040,
683,
68,
14,
2190,
401,
298,
3346,
4094,
60,
78,
531,
267,
1591,
14,
11381,
14,
952,
63,
505,
63,
493,
8,
288,
3286,
2647,
15,
773,
15,
4040,
683,
68,
15,
773,
4040,
863,
14,
22305,
401,
298,
3346,
13119,
773,
531,
398,
1654,
275,
491,
528,
21594,
8,
396,
63,
719,
12,
3286,
1805,
15,
1199,
63,
694,
401,
2079,
4722,
63,
3220,
3126,
2892,
3286,
1805,
15,
368,
13,
8460,
13,
694,
582,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
401,
2892,
3286,
1805,
15,
13565,
13,
8460,
13,
694,
582,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
5984,
267,
291,
14,
1855,
8,
17692,
12,
1654,
14,
928,
9,
398,
1101,
63,
493,
275,
1591,
14,
11381,
14,
739,
63,
505,
63,
493,
4769,
1805,
15,
1199,
63,
694,
15,
4040,
683,
68,
14,
2190,
531,
267,
291,
14,
629,
8,
264,
14,
6452,
8,
82,
2,
3620,
14,
633,
6977,
401,
1101,
63,
493,
395,
359,
288,
283,
3620,
14,
633,
275,
334,
3286,
3596,
13,
396,
13,
4435,
2,
9265,
3286,
396,
14,
12891,
15,
4798,
2925,
15,
7015,
15,
3596,
15,
4435,
2,
776,
297,
288,
283,
3620,
14,
633,
847,
334,
3286,
1805,
15,
368,
13,
8460,
13,
694,
2,
9265,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
2,
776,
297,
288,
283,
3620,
14,
633,
847,
334,
3286,
1805,
15,
13565,
13,
8460,
13,
694,
2,
9265,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
2,
776,
297,
288,
283,
3620,
14,
633,
847,
334,
3286,
4603,
13,
4435,
2,
9265,
3286,
396,
14,
12891,
15,
4798,
2925,
15,
4603,
2,
776,
297,
267,
4794,
339,
347,
511,
63,
2676,
708,
63,
928,
63,
460,
63,
2379,
8,
277,
304,
267,
1591,
275,
4420,
4965,
342,
267,
511,
63,
719,
275,
511,
14,
774,
4313,
8,
1102,
9,
267,
1591,
14,
11381,
14,
952,
63,
505,
63,
493,
8,
288,
3286,
1805,
13,
12891,
15,
11654,
15,
25681,
15,
12554,
647,
15,
4209,
63,
2219,
15,
5871,
15,
4040,
683,
68,
14,
2190,
401,
298,
3346,
4094,
60,
78,
531,
267,
1591,
14,
11381,
14,
952,
63,
505,
63,
493,
8,
288,
3286,
2647,
15,
773,
15,
4040,
683,
68,
15,
773,
4040,
863,
14,
22305,
401,
298,
3346,
13119,
773,
531,
398,
1591,
14,
3246,
14,
374,
63,
2676,
275,
2400,
26,
715,
267,
1591,
14,
3246,
14,
374,
63,
16680,
275,
2400,
26,
756,
398,
1654,
275,
491,
528,
21594,
8,
396,
63,
719,
12,
3286,
1805,
15,
1199,
63,
694,
401,
2079,
4722,
63,
3220,
3126,
2892,
3286,
1805,
15,
368,
13,
8460,
13,
694,
582,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
401,
2892,
3286,
1805,
15,
13565,
13,
8460,
13,
694,
582,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
5984,
267,
1654,
423,
1074,
63,
9099,
63,
452,
63,
5203,
63,
1530,
63,
4561,
275,
2400,
26,
715,
267,
1654,
423,
374,
63,
1000,
63,
5720,
63,
265,
63,
452,
63,
5203,
275,
2400,
26,
715,
398,
1654,
14,
928,
342,
267,
291,
14
] |
[
1898,
334,
35,
9,
6029,
4475,
3277,
14,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
199,
3,
199,
3,
258,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
258,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
199,
3,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
4084,
14,
199,
3,
258,
627,
11443,
314,
536,
402,
4475,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
687,
199,
3,
642,
2032,
1928,
2488,
6791,
5313,
4983,
14,
199,
3,
199,
3,
5749,
4141,
2281,
7049,
6515,
2334,
5877,
8164,
2401,
6483,
199,
3,
298,
1179,
2281,
2,
2401,
1821,
7168,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
2334,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
199,
3,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
5877,
199,
3,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
2845,
199,
3,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
9102,
1634,
4815,
12,
199,
3,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
9802,
9817,
2401,
5258,
1821,
199,
3,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
9644,
5603,
12,
1549,
7056,
199,
3,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
199,
3,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
9726,
1634,
9712,
9784,
14,
199,
199,
646,
295,
199,
646,
984,
199,
646,
2882,
18,
465,
2882,
199,
199,
504,
18007,
14,
2330,
14,
1102,
63,
1805,
492,
4420,
4965,
199,
504,
18007,
14,
719,
492,
511,
199,
504,
18007,
14,
4209,
63,
2219,
14,
5871,
14,
1014,
63,
1000,
492,
491,
528,
21594,
199,
504,
18007,
14,
4209,
63,
2219,
14,
5871,
14,
1014,
63,
1000,
63,
1095,
492,
7146,
547,
421,
199,
533,
1379,
5779,
3120,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
928,
63,
1760,
8,
277,
304,
267,
327,
12176,
83,
641,
4747,
446,
1937,
4178,
921,
13017,
14,
12554,
14,
1308,
15,
2384,
63,
1266,
14,
13814,
31,
344,
29,
15883,
1479,
267,
340,
984,
14,
3246,
315,
661,
16680,
297,
283,
2676,
708,
735,
288,
372,
398,
1591,
275,
4420,
4965,
342,
267,
511,
63,
719,
275,
511,
14,
774,
4313,
8,
1102,
9,
267,
1591,
14,
11381,
14,
952,
63,
505,
63,
493,
8,
288,
3286,
1805,
13,
12891,
15,
11654,
15,
25681,
15,
12554,
647,
15,
4209,
63,
2219,
15,
5871,
15,
4040,
683,
68,
14,
2190,
401,
298,
3346,
4094,
60,
78,
531,
267,
1591,
14,
11381,
14,
952,
63,
505,
63,
493,
8,
288,
3286,
2647,
15,
773,
15,
4040,
683,
68,
15,
773,
4040,
863,
14,
22305,
401,
298,
3346,
13119,
773,
531,
398,
1654,
275,
491,
528,
21594,
8,
396,
63,
719,
12,
3286,
1805,
15,
1199,
63,
694,
401,
2079,
4722,
63,
3220,
3126,
2892,
3286,
1805,
15,
368,
13,
8460,
13,
694,
582,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
401,
2892,
3286,
1805,
15,
13565,
13,
8460,
13,
694,
582,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
5984,
267,
291,
14,
1855,
8,
17692,
12,
1654,
14,
928,
9,
398,
1101,
63,
493,
275,
1591,
14,
11381,
14,
739,
63,
505,
63,
493,
4769,
1805,
15,
1199,
63,
694,
15,
4040,
683,
68,
14,
2190,
531,
267,
291,
14,
629,
8,
264,
14,
6452,
8,
82,
2,
3620,
14,
633,
6977,
401,
1101,
63,
493,
395,
359,
288,
283,
3620,
14,
633,
275,
334,
3286,
3596,
13,
396,
13,
4435,
2,
9265,
3286,
396,
14,
12891,
15,
4798,
2925,
15,
7015,
15,
3596,
15,
4435,
2,
776,
297,
288,
283,
3620,
14,
633,
847,
334,
3286,
1805,
15,
368,
13,
8460,
13,
694,
2,
9265,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
2,
776,
297,
288,
283,
3620,
14,
633,
847,
334,
3286,
1805,
15,
13565,
13,
8460,
13,
694,
2,
9265,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
2,
776,
297,
288,
283,
3620,
14,
633,
847,
334,
3286,
4603,
13,
4435,
2,
9265,
3286,
396,
14,
12891,
15,
4798,
2925,
15,
4603,
2,
776,
297,
267,
4794,
339,
347,
511,
63,
2676,
708,
63,
928,
63,
460,
63,
2379,
8,
277,
304,
267,
1591,
275,
4420,
4965,
342,
267,
511,
63,
719,
275,
511,
14,
774,
4313,
8,
1102,
9,
267,
1591,
14,
11381,
14,
952,
63,
505,
63,
493,
8,
288,
3286,
1805,
13,
12891,
15,
11654,
15,
25681,
15,
12554,
647,
15,
4209,
63,
2219,
15,
5871,
15,
4040,
683,
68,
14,
2190,
401,
298,
3346,
4094,
60,
78,
531,
267,
1591,
14,
11381,
14,
952,
63,
505,
63,
493,
8,
288,
3286,
2647,
15,
773,
15,
4040,
683,
68,
15,
773,
4040,
863,
14,
22305,
401,
298,
3346,
13119,
773,
531,
398,
1591,
14,
3246,
14,
374,
63,
2676,
275,
2400,
26,
715,
267,
1591,
14,
3246,
14,
374,
63,
16680,
275,
2400,
26,
756,
398,
1654,
275,
491,
528,
21594,
8,
396,
63,
719,
12,
3286,
1805,
15,
1199,
63,
694,
401,
2079,
4722,
63,
3220,
3126,
2892,
3286,
1805,
15,
368,
13,
8460,
13,
694,
582,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
401,
2892,
3286,
1805,
15,
13565,
13,
8460,
13,
694,
582,
3286,
1805,
13,
12891,
15,
368,
13,
8460,
13,
694,
5984,
267,
1654,
423,
1074,
63,
9099,
63,
452,
63,
5203,
63,
1530,
63,
4561,
275,
2400,
26,
715,
267,
1654,
423,
374,
63,
1000,
63,
5720,
63,
265,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
HybridF5/tempest_debug
|
tempest/api/compute/servers/test_server_personality.py
|
5
|
6324
|
# Copyright 2012 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 base64
from tempest.api.compute import base
from tempest.common.utils.linux import remote_client
from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
from tempest import test
CONF = config.CONF
class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
@classmethod
def setup_credentials(cls):
cls.prepare_instance_network()
super(ServerPersonalityTestJSON, cls).setup_credentials()
@classmethod
def resource_setup(cls):
cls.set_validation_resources()
super(ServerPersonalityTestJSON, cls).resource_setup()
@classmethod
def skip_checks(cls):
super(ServerPersonalityTestJSON, cls).skip_checks()
if not CONF.compute_feature_enabled.personality:
raise cls.skipException("Nova personality feature disabled")
@classmethod
def setup_clients(cls):
super(ServerPersonalityTestJSON, cls).setup_clients()
cls.client = cls.servers_client
cls.user_client = cls.limits_client
@test.idempotent_id('3cfe87fd-115b-4a02-b942-7dc36a337fdf')
def test_create_server_with_personality(self):
file_contents = 'This is a test file.'
file_path = '/test.txt'
personality = [{'path': file_path,
'contents': base64.b64encode(file_contents)}]
password = data_utils.rand_password()
created_server = self.create_test_server(personality=personality,
adminPass=password,
wait_until='ACTIVE',
validatable=True)
server = self.client.show_server(created_server['id'])['server']
if CONF.validation.run_validation:
linux_client = remote_client.RemoteClient(
self.get_server_ip(server),
self.ssh_user, password,
self.validation_resources['keypair']['private_key'])
self.assertEqual(file_contents,
linux_client.exec_command(
'sudo cat %s' % file_path))
@test.idempotent_id('128966d8-71fc-443c-8cab-08e24114ecc9')
def test_rebuild_server_with_personality(self):
server = self.create_test_server(wait_until='ACTIVE', validatable=True)
server_id = server['id']
file_contents = 'Test server rebuild.'
personality = [{'path': 'rebuild.txt',
'contents': base64.b64encode(file_contents)}]
rebuilt_server = self.client.rebuild_server(server_id,
self.image_ref_alt,
personality=personality)
waiters.wait_for_server_status(self.client, server_id, 'ACTIVE')
self.assertEqual(self.image_ref_alt,
rebuilt_server['server']['image']['id'])
@test.idempotent_id('176cd8c9-b9e8-48ee-a480-180beab292bf')
def test_personality_files_exceed_limit(self):
# Server creation should fail if greater than the maximum allowed
# number of files are injected into the server.
file_contents = 'This is a test file.'
personality = []
limits = self.user_client.show_limits()['limits']
max_file_limit = limits['absolute']['maxPersonality']
if max_file_limit == -1:
raise self.skipException("No limit for personality files")
for i in range(0, int(max_file_limit) + 1):
path = 'etc/test' + str(i) + '.txt'
personality.append({'path': path,
'contents': base64.b64encode(file_contents)})
# A 403 Forbidden or 413 Overlimit (old behaviour) exception
# will be raised when out of quota
self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),
self.create_test_server, personality=personality)
@test.idempotent_id('52f12ee8-5180-40cc-b417-31572ea3d555')
def test_can_create_server_with_max_number_personality_files(self):
# Server should be created successfully if maximum allowed number of
# files is injected into the server during creation.
file_contents = 'This is a test file.'
limits = self.user_client.show_limits()['limits']
max_file_limit = limits['absolute']['maxPersonality']
if max_file_limit == -1:
raise self.skipException("No limit for personality files")
person = []
for i in range(0, int(max_file_limit)):
path = '/etc/test' + str(i) + '.txt'
person.append({
'path': path,
'contents': base64.b64encode(file_contents),
})
password = data_utils.rand_password()
created_server = self.create_test_server(personality=person,
adminPass=password,
wait_until='ACTIVE',
validatable=True)
server = self.client.show_server(created_server['id'])['server']
if CONF.validation.run_validation:
linux_client = remote_client.RemoteClient(
self.get_server_ip(server),
self.ssh_user, password,
self.validation_resources['keypair']['private_key'])
for i in person:
self.assertEqual(base64.b64decode(i['contents']),
linux_client.exec_command(
'sudo cat %s' % i['path']))
|
apache-2.0
|
[
3,
1898,
6029,
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,
1300,
772,
199,
199,
504,
24076,
14,
1246,
14,
3357,
492,
1300,
199,
504,
24076,
14,
2330,
14,
1208,
14,
5135,
492,
3982,
63,
1258,
199,
504,
24076,
14,
2330,
492,
336,
5789,
878,
199,
504,
24076,
492,
1101,
199,
504,
24076,
14,
773,
14,
2330,
14,
1208,
492,
666,
63,
1208,
199,
504,
24076,
14,
773,
492,
4967,
465,
1973,
63,
2804,
199,
504,
24076,
492,
511,
199,
199,
3103,
275,
1101,
14,
3103,
421,
199,
533,
7146,
7344,
6712,
774,
6243,
8,
1095,
14,
1563,
54,
18,
8564,
774,
304,
339,
768,
3744,
272,
347,
3272,
63,
6942,
8,
1886,
304,
267,
843,
14,
6726,
63,
842,
63,
1200,
342,
267,
1613,
8,
3120,
7344,
6712,
774,
6243,
12,
843,
680,
2758,
63,
6942,
342,
339,
768,
3744,
272,
347,
2073,
63,
2758,
8,
1886,
304,
267,
843,
14,
409,
63,
6136,
63,
4435,
342,
267,
1613,
8,
3120,
7344,
6712,
774,
6243,
12,
843,
680,
1927,
63,
2758,
342,
339,
768,
3744,
272,
347,
3372,
63,
8625,
8,
1886,
304,
267,
1613,
8,
3120,
7344,
6712,
774,
6243,
12,
843,
680,
2759,
63,
8625,
342,
267,
340,
440,
6392,
14,
3357,
63,
4445,
63,
3827,
14,
5484,
6712,
26,
288,
746,
843,
14,
2759,
1726,
480,
19884,
4954,
6712,
3878,
6980,
531,
339,
768,
3744,
272,
347,
3272,
63,
14555,
8,
1886,
304,
267,
1613,
8,
3120,
7344,
6712,
774,
6243,
12,
843,
680,
2758,
63,
14555,
342,
267,
843,
14,
1258,
275,
843,
14,
5871,
63,
1258,
267,
843,
14,
751,
63,
1258,
275,
843,
14,
9368,
63,
1258,
339,
768,
396,
14,
21307,
63,
344,
360,
19,
67,
771,
1555,
2592,
13,
7680,
66,
13,
20,
65,
996,
13,
66,
25,
2260,
13,
23,
3833,
1344,
65,
11062,
24864,
358,
272,
347,
511,
63,
981,
63,
1000,
63,
1045,
63,
5484,
6712,
8,
277,
304,
267,
570,
63,
4407,
275,
283,
2765,
365,
282,
511,
570,
3530,
267,
570,
63,
515,
275,
1994,
396,
14,
2424,
7,
267,
4954,
6712,
275,
9016,
515,
356,
570,
63,
515,
12,
717,
283,
4407,
356,
1300,
772,
14,
66,
772,
2143,
8,
493,
63,
4407,
6769,
61,
267,
2505,
275,
666,
63,
1208,
14,
3759,
63,
2060,
342,
267,
2737,
63,
1000,
275,
291,
14,
981,
63,
396,
63,
1000,
8,
5484,
6712,
29,
5484,
6712,
12,
1740,
4628,
4986,
29,
2060,
12,
1740,
3618,
63,
8111,
534,
10401,
297,
1740,
1686,
15511,
29,
549,
9,
267,
1654,
275,
291,
14,
1258,
14,
2384,
63,
1000,
8,
3966,
63,
1000,
459,
344,
1105,
459,
1000,
418,
267,
340,
6392,
14,
6136,
14,
1065,
63,
6136,
26,
288,
18369,
63,
1258,
275,
3982,
63,
1258,
14,
6713,
3041,
8,
355,
291,
14,
362,
63,
1000,
63,
711,
8,
1000,
395,
355,
291,
14,
5510,
63,
751,
12,
2505,
12,
355,
291,
14,
6136,
63,
4435,
459,
19263,
2545,
4239,
63,
498,
1105,
288,
291,
14,
629,
8,
493,
63,
4407,
12,
2490,
18369,
63,
1258,
14,
1628,
63,
1531,
8,
639,
283,
12095,
6230,
450,
83,
7,
450,
570,
63,
515,
430,
339,
768,
396,
14,
21307,
63,
344,
360,
713,
1407,
1272,
68,
24,
13,
3172,
3003,
13,
16284,
67,
13,
24,
26481,
13,
2036,
69,
1194,
7636,
825,
67,
25,
358,
272,
347,
511,
63,
19278,
63,
1000,
63,
1045,
63,
5484,
6712,
8,
277,
304,
267,
1654,
275,
291,
14,
981,
63,
396,
63,
1000,
8,
2573,
63,
8111,
534,
10401,
297,
1686,
15511,
29,
549,
9,
267,
1654,
63,
344,
275,
1654,
459,
344,
418,
267,
570,
63,
4407,
275,
283,
774,
1654,
22110,
3530,
267,
4954,
6712,
275,
9016,
515,
356,
283,
19278,
14,
2424,
297,
717,
283,
4407,
356,
1300,
772,
14,
66,
772,
2143,
8,
493,
63,
4407,
6769,
61,
267,
295,
11730,
63,
1000,
275,
291,
14,
1258,
14,
19278,
63,
1000,
8,
1000,
63,
344,
12,
8105,
291,
14,
1569,
63,
1121,
63,
4478,
12,
8105,
4954,
6712,
29,
5484,
6712,
9,
267,
336,
5789,
878,
14,
2573,
63,
509,
63,
1000,
63,
1205,
8,
277,
14,
1258,
12,
1654,
63,
344,
12,
283,
10401,
358,
267,
291,
14,
629,
8,
277,
14,
1569,
63,
1121,
63,
4478,
12,
586,
295,
11730,
63,
1000,
459,
1000,
2545,
1569,
2545,
344,
1105,
339,
768,
396,
14,
21307,
63,
344,
360,
10216,
2866,
24,
67,
25,
13,
66,
25,
69,
24,
13,
2006,
1024,
13,
65,
21853,
13,
7663,
1235,
371,
17027,
4361,
358,
272,
347,
511,
63,
5484,
6712,
63,
1725,
63,
476,
15648,
63,
3097,
8,
277,
304,
267,
327,
7146,
7143,
1077,
2449,
340,
8932,
2419,
314,
5696,
4370,
267,
327,
1329,
402,
1584,
787,
26121,
1901,
314,
1654,
14,
267,
570,
63,
4407,
275,
283,
2765,
365,
282,
511,
570,
3530,
267,
4954,
6712,
275,
942,
267,
10976,
275,
291,
14,
751,
63,
1258,
14,
2384,
63,
9368,
12047,
9368,
418,
267,
1390,
63,
493,
63,
3097,
275,
10976,
459,
6116,
2545,
988,
7344,
6712,
418,
267,
340,
1390,
63,
493,
63,
3097,
508,
446,
17,
26,
288,
746,
291,
14,
2759,
1726,
480,
1944,
2304,
367,
4954,
6712,
1584,
531,
267,
367,
284,
315,
1425,
8,
16,
12,
1109,
8,
988,
63,
493,
63,
3097,
9,
435,
413
] |
[
1898,
6029,
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,
1300,
772,
199,
199,
504,
24076,
14,
1246,
14,
3357,
492,
1300,
199,
504,
24076,
14,
2330,
14,
1208,
14,
5135,
492,
3982,
63,
1258,
199,
504,
24076,
14,
2330,
492,
336,
5789,
878,
199,
504,
24076,
492,
1101,
199,
504,
24076,
14,
773,
14,
2330,
14,
1208,
492,
666,
63,
1208,
199,
504,
24076,
14,
773,
492,
4967,
465,
1973,
63,
2804,
199,
504,
24076,
492,
511,
199,
199,
3103,
275,
1101,
14,
3103,
421,
199,
533,
7146,
7344,
6712,
774,
6243,
8,
1095,
14,
1563,
54,
18,
8564,
774,
304,
339,
768,
3744,
272,
347,
3272,
63,
6942,
8,
1886,
304,
267,
843,
14,
6726,
63,
842,
63,
1200,
342,
267,
1613,
8,
3120,
7344,
6712,
774,
6243,
12,
843,
680,
2758,
63,
6942,
342,
339,
768,
3744,
272,
347,
2073,
63,
2758,
8,
1886,
304,
267,
843,
14,
409,
63,
6136,
63,
4435,
342,
267,
1613,
8,
3120,
7344,
6712,
774,
6243,
12,
843,
680,
1927,
63,
2758,
342,
339,
768,
3744,
272,
347,
3372,
63,
8625,
8,
1886,
304,
267,
1613,
8,
3120,
7344,
6712,
774,
6243,
12,
843,
680,
2759,
63,
8625,
342,
267,
340,
440,
6392,
14,
3357,
63,
4445,
63,
3827,
14,
5484,
6712,
26,
288,
746,
843,
14,
2759,
1726,
480,
19884,
4954,
6712,
3878,
6980,
531,
339,
768,
3744,
272,
347,
3272,
63,
14555,
8,
1886,
304,
267,
1613,
8,
3120,
7344,
6712,
774,
6243,
12,
843,
680,
2758,
63,
14555,
342,
267,
843,
14,
1258,
275,
843,
14,
5871,
63,
1258,
267,
843,
14,
751,
63,
1258,
275,
843,
14,
9368,
63,
1258,
339,
768,
396,
14,
21307,
63,
344,
360,
19,
67,
771,
1555,
2592,
13,
7680,
66,
13,
20,
65,
996,
13,
66,
25,
2260,
13,
23,
3833,
1344,
65,
11062,
24864,
358,
272,
347,
511,
63,
981,
63,
1000,
63,
1045,
63,
5484,
6712,
8,
277,
304,
267,
570,
63,
4407,
275,
283,
2765,
365,
282,
511,
570,
3530,
267,
570,
63,
515,
275,
1994,
396,
14,
2424,
7,
267,
4954,
6712,
275,
9016,
515,
356,
570,
63,
515,
12,
717,
283,
4407,
356,
1300,
772,
14,
66,
772,
2143,
8,
493,
63,
4407,
6769,
61,
267,
2505,
275,
666,
63,
1208,
14,
3759,
63,
2060,
342,
267,
2737,
63,
1000,
275,
291,
14,
981,
63,
396,
63,
1000,
8,
5484,
6712,
29,
5484,
6712,
12,
1740,
4628,
4986,
29,
2060,
12,
1740,
3618,
63,
8111,
534,
10401,
297,
1740,
1686,
15511,
29,
549,
9,
267,
1654,
275,
291,
14,
1258,
14,
2384,
63,
1000,
8,
3966,
63,
1000,
459,
344,
1105,
459,
1000,
418,
267,
340,
6392,
14,
6136,
14,
1065,
63,
6136,
26,
288,
18369,
63,
1258,
275,
3982,
63,
1258,
14,
6713,
3041,
8,
355,
291,
14,
362,
63,
1000,
63,
711,
8,
1000,
395,
355,
291,
14,
5510,
63,
751,
12,
2505,
12,
355,
291,
14,
6136,
63,
4435,
459,
19263,
2545,
4239,
63,
498,
1105,
288,
291,
14,
629,
8,
493,
63,
4407,
12,
2490,
18369,
63,
1258,
14,
1628,
63,
1531,
8,
639,
283,
12095,
6230,
450,
83,
7,
450,
570,
63,
515,
430,
339,
768,
396,
14,
21307,
63,
344,
360,
713,
1407,
1272,
68,
24,
13,
3172,
3003,
13,
16284,
67,
13,
24,
26481,
13,
2036,
69,
1194,
7636,
825,
67,
25,
358,
272,
347,
511,
63,
19278,
63,
1000,
63,
1045,
63,
5484,
6712,
8,
277,
304,
267,
1654,
275,
291,
14,
981,
63,
396,
63,
1000,
8,
2573,
63,
8111,
534,
10401,
297,
1686,
15511,
29,
549,
9,
267,
1654,
63,
344,
275,
1654,
459,
344,
418,
267,
570,
63,
4407,
275,
283,
774,
1654,
22110,
3530,
267,
4954,
6712,
275,
9016,
515,
356,
283,
19278,
14,
2424,
297,
717,
283,
4407,
356,
1300,
772,
14,
66,
772,
2143,
8,
493,
63,
4407,
6769,
61,
267,
295,
11730,
63,
1000,
275,
291,
14,
1258,
14,
19278,
63,
1000,
8,
1000,
63,
344,
12,
8105,
291,
14,
1569,
63,
1121,
63,
4478,
12,
8105,
4954,
6712,
29,
5484,
6712,
9,
267,
336,
5789,
878,
14,
2573,
63,
509,
63,
1000,
63,
1205,
8,
277,
14,
1258,
12,
1654,
63,
344,
12,
283,
10401,
358,
267,
291,
14,
629,
8,
277,
14,
1569,
63,
1121,
63,
4478,
12,
586,
295,
11730,
63,
1000,
459,
1000,
2545,
1569,
2545,
344,
1105,
339,
768,
396,
14,
21307,
63,
344,
360,
10216,
2866,
24,
67,
25,
13,
66,
25,
69,
24,
13,
2006,
1024,
13,
65,
21853,
13,
7663,
1235,
371,
17027,
4361,
358,
272,
347,
511,
63,
5484,
6712,
63,
1725,
63,
476,
15648,
63,
3097,
8,
277,
304,
267,
327,
7146,
7143,
1077,
2449,
340,
8932,
2419,
314,
5696,
4370,
267,
327,
1329,
402,
1584,
787,
26121,
1901,
314,
1654,
14,
267,
570,
63,
4407,
275,
283,
2765,
365,
282,
511,
570,
3530,
267,
4954,
6712,
275,
942,
267,
10976,
275,
291,
14,
751,
63,
1258,
14,
2384,
63,
9368,
12047,
9368,
418,
267,
1390,
63,
493,
63,
3097,
275,
10976,
459,
6116,
2545,
988,
7344,
6712,
418,
267,
340,
1390,
63,
493,
63,
3097,
508,
446,
17,
26,
288,
746,
291,
14,
2759,
1726,
480,
1944,
2304,
367,
4954,
6712,
1584,
531,
267,
367,
284,
315,
1425,
8,
16,
12,
1109,
8,
988,
63,
493,
63,
3097,
9,
435,
413,
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,
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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
] |
andreadean5/python-hpOneView
|
hpOneView/resources/facilities/racks.py
|
1
|
6758
|
# -*- coding: utf-8 -*-
###
# (C) Copyright (2012-2016) Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from future import standard_library
standard_library.install_aliases()
__title__ = 'Racks'
__version__ = '0.0.1'
__copyright__ = '(C) Copyright (2012-2016) Hewlett Packard Enterprise ' \
' Development LP'
__license__ = 'MIT'
__status__ = 'Development'
from hpOneView.resources.resource import ResourceClient
class Racks(object):
URI = '/rest/racks'
def __init__(self, con):
self._connection = con
self._client = ResourceClient(con, self.URI)
def get_all(self, start=0, count=-1, filter='', query='', sort=''):
"""
Gets a set of rack resources according to the specified parameters. Filters can be used to get a specific set
of racks. With no filters specified, the API returns a potentially paginated list of all the racks
subject to start/count/sort parameters.
Args:
start:
The first item to return, using 0-based indexing.
If not specified, the default is 0 - start with the first available item.
count:
The number of resources to return. A count of -1 requests all the items.
The actual number of items in the response may differ from the requested
count if the sum of start and count exceed the total number of items, or
if returning the requested number of items would take too long.
filter:
A general filter/query string to narrow the list of items returned. The
default is no filter - all resources are returned.
query:
A general query string to narrow the list of resources returned. The default
is no query - all resources are returned.
sort:
The sort order of the returned data set. By default, the sort order is based
on create time, with the oldest entry first.
Returns: list of racks
"""
return self._client.get_all(start, count, filter=filter, sort=sort, query=query)
def get(self, id_or_uri):
"""
Gets a rack with the specified ID or URI
Args:
id_or_uri:
Could be either the rack id or the rack uri
Returns:
dict: The rack
"""
return self._client.get(id_or_uri)
def get_device_topology(self, id_or_uri):
"""
Retrieves the topology information for the rack resource specified by id or uri.
Args:
id_or_uri: Could be either the resource id or the resource uri
Return:
dict: device topology
"""
uri = self._client.build_uri(id_or_uri) + "/deviceTopology"
return self._client.get(uri)
def get_by(self, field, value):
"""
Get all racks that match the filter
The search is case insensitive
Args:
field: field name to filter
value: value to filter
Returns:
dict: rack
"""
return self._client.get_by(field, value)
def remove(self, resource, force=False, timeout=-1):
"""
Removes the specified rack.
Args:
resource: dict object to remove
force:
If set to true the operation completes despite any problems with
network connectivity or errors on the resource itself. The default is false.
timeout: Timeout in seconds. Wait task completion by default. The timeout does not abort the operation
in OneView, just stops waiting for its completion.
Returns: Result status
"""
return self._client.delete(resource, force=force, timeout=timeout)
def add(self, information, timeout=-1):
"""
Adds a rack resource based upon the attributes specified. All attributes without default values must be
specified in the POST body. The response contains the rack resource as added to the appliance with default and
assigned properties expanded. The id and uri are assigned by the management appliance and are used to uniquely
identify this particular resource.
Args:
resource: rack information
timeout: Timeout in seconds. Wait task completion by default. The timeout does not abort the operation
in OneView, just stops waiting for its completion.
Returns:
dict: added rack.
"""
return self._client.create(information, timeout=timeout)
def update(self, resource, timeout=-1):
"""
Updates the specified rack resource. The properties that are omitted (not included as part of the request body)
are reset to their respective default values. The id and uuid properties are required and cannot be changed.
To update existing racks first perform a get() request to retrieve the current properties, update the desired
properties, and then update() the request body containing the new representation of the resource.
Args:
resource (dict): Object to update
timeout:
Timeout in seconds. Wait task completion by default. The timeout does not abort the operation
in OneView, just stops waiting for its completion.
Returns:
dict: Updated rack
"""
return self._client.update(resource, timeout=timeout)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
5680,
199,
3,
334,
35,
9,
1898,
334,
7409,
13,
9261,
9,
27849,
9954,
1005,
29949,
15290,
21738,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
3,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
3,
315,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
3,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
3,
6866,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
3,
13985,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
3,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
3,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
10610,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
3,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
3,
2334,
4141,
14,
199,
5680,
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,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
6466,
492,
4465,
63,
4342,
199,
199,
6807,
63,
4342,
14,
3174,
63,
8602,
342,
199,
199,
363,
1213,
363,
275,
283,
50,
564,
83,
7,
199,
363,
1023,
363,
275,
283,
16,
14,
16,
14,
17,
7,
199,
363,
7307,
363,
275,
8189,
35,
9,
1898,
334,
7409,
13,
9261,
9,
27849,
9954,
1005,
29949,
283,
971,
355,
283,
15290,
21738,
7,
199,
363,
1682,
363,
275,
283,
13965,
7,
199,
363,
1205,
363,
275,
283,
23753,
7,
199,
199,
504,
20962,
4395,
2768,
14,
4435,
14,
1927,
492,
7337,
3041,
421,
199,
533,
29522,
83,
8,
785,
304,
272,
9022,
275,
1994,
3911,
15,
345,
5618,
7,
339,
347,
636,
826,
721,
277,
12,
406,
304,
267,
291,
423,
2105,
275,
406,
267,
291,
423,
1258,
275,
7337,
3041,
8,
388,
12,
291,
14,
7639,
9,
339,
347,
664,
63,
452,
8,
277,
12,
1343,
29,
16,
12,
2338,
4022,
17,
12,
2457,
4581,
1827,
4581,
4069,
9280,
267,
408,
267,
14509,
282,
663,
402,
660,
346,
5944,
7182,
370,
314,
2013,
2633,
14,
21240,
883,
506,
1202,
370,
664,
282,
2488,
663,
267,
402,
660,
5618,
14,
8777,
949,
4766,
2013,
12,
314,
3261,
2529,
282,
18994,
9881,
23831,
769,
402,
1006,
314,
660,
5618,
267,
5420,
370,
1343,
15,
835,
15,
3191,
2633,
14,
398,
3033,
26,
288,
1343,
26,
355,
710,
1642,
1242,
370,
372,
12,
1808,
378,
13,
6788,
16356,
14,
355,
982,
440,
2013,
12,
314,
849,
365,
378,
446,
1343,
543,
314,
1642,
2808,
1242,
14,
288,
2338,
26,
355,
710,
1329,
402,
5944,
370,
372,
14,
437,
2338,
402,
446,
17,
4145,
1006,
314,
2974,
14,
355,
710,
3503,
1329,
402,
2974,
315,
314,
1177,
1443,
14460,
687,
314,
5839,
355,
2338,
340,
314,
3089,
402,
1343,
436,
2338,
24068,
314,
3141,
1329,
402,
2974,
12,
503,
355,
340,
8152,
314,
5839,
1329,
402,
2974,
3955,
5452,
4634,
1846,
14,
288,
2457,
26,
355,
437,
8605,
2457,
15,
1131,
1059,
370,
31530,
314,
769,
402,
2974,
2138,
14,
710,
355,
849,
365,
949,
2457,
446,
1006,
5944,
787,
2138,
14,
288,
1827,
26,
326,
437,
8605,
1827,
1059,
370,
31530,
314,
769,
402,
5944,
2138,
14,
710,
849,
326,
365,
949,
1827,
446,
1006,
5944,
787,
2138,
14,
288,
4069,
26,
355,
710,
4069,
1865,
402,
314,
2138,
666,
663,
14,
4885,
849,
12,
314,
4069,
1865,
365,
4079,
355,
641,
1218,
900,
12,
543,
314,
29493,
2397,
1642,
14,
398,
1803,
26,
769,
402,
660,
5618,
267,
408,
267,
372,
291,
423,
1258,
14,
362,
63,
452,
8,
928,
12,
2338,
12,
2457,
29,
1541,
12,
4069,
29,
3191,
12,
1827,
29,
1131,
9,
339,
347,
664,
8,
277,
12,
1305,
63,
269,
63,
2302,
304,
267,
408,
267,
14509,
282,
660,
346,
543,
314,
2013,
2870,
503,
9022,
267,
3033,
26,
288,
1305,
63,
269,
63,
2302,
26,
355,
18615,
506,
1902,
314,
660,
346,
1305,
503,
314,
660,
346,
5108,
398,
1803,
26,
288,
1211,
26,
710,
660,
346,
267,
408,
267,
372,
291,
423,
1258,
14,
362,
8,
344,
63,
269,
63,
2302,
9,
339,
347,
664,
63,
1782,
63,
10775,
8,
277,
12,
1305,
63,
269,
63,
2302,
304,
267,
408,
267,
27940,
314,
14611,
2556,
367,
314,
660,
346,
2073,
2013,
701,
1305,
503,
5108,
14,
398,
3033,
26,
288,
1305,
63,
269,
63,
2302,
26,
18615,
506,
1902,
314,
2073,
1305,
503,
314,
2073,
5108,
398,
1432,
26,
288,
1211,
26,
2243,
14611,
267,
408,
267,
5108,
275,
291,
423,
1258,
14,
1506,
63,
2302,
8,
344,
63,
269,
63,
2302,
9,
435,
3286,
1782,
15696,
2,
267,
372,
291,
423,
1258,
14,
362,
8,
2302,
9,
339,
347,
664,
63,
991,
8,
277,
12,
901,
12,
574,
304,
267,
408,
267,
2372,
1006,
660,
5618,
626,
1336,
314,
2457,
267,
710,
2754,
365,
1930,
27845,
398,
3033,
26,
288,
901,
26,
901,
536,
370,
2457,
288,
574,
26,
574,
370,
2457,
398,
1803,
26,
288,
1211,
26,
660,
346,
398,
408,
267,
372,
291,
423,
1258,
14,
362,
63,
991,
8,
698,
12,
574,
9,
339,
347,
2813,
8,
277,
12,
2073,
12,
3542,
29,
797,
12,
2653,
4022,
17,
304,
267,
408,
267,
23169,
314,
2013,
660,
346,
14,
398,
3033,
26,
288,
2073,
26,
1211,
909,
370,
2813,
288,
3542,
26,
326,
982,
663,
370,
2549,
314,
3439,
29672
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
5680,
199,
3,
334,
35,
9,
1898,
334,
7409,
13,
9261,
9,
27849,
9954,
1005,
29949,
15290,
21738,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
3,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
3,
315,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
3,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
3,
6866,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
3,
13985,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
3,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
3,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
10610,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
3,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
3,
2334,
4141,
14,
199,
5680,
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,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
6466,
492,
4465,
63,
4342,
199,
199,
6807,
63,
4342,
14,
3174,
63,
8602,
342,
199,
199,
363,
1213,
363,
275,
283,
50,
564,
83,
7,
199,
363,
1023,
363,
275,
283,
16,
14,
16,
14,
17,
7,
199,
363,
7307,
363,
275,
8189,
35,
9,
1898,
334,
7409,
13,
9261,
9,
27849,
9954,
1005,
29949,
283,
971,
355,
283,
15290,
21738,
7,
199,
363,
1682,
363,
275,
283,
13965,
7,
199,
363,
1205,
363,
275,
283,
23753,
7,
199,
199,
504,
20962,
4395,
2768,
14,
4435,
14,
1927,
492,
7337,
3041,
421,
199,
533,
29522,
83,
8,
785,
304,
272,
9022,
275,
1994,
3911,
15,
345,
5618,
7,
339,
347,
636,
826,
721,
277,
12,
406,
304,
267,
291,
423,
2105,
275,
406,
267,
291,
423,
1258,
275,
7337,
3041,
8,
388,
12,
291,
14,
7639,
9,
339,
347,
664,
63,
452,
8,
277,
12,
1343,
29,
16,
12,
2338,
4022,
17,
12,
2457,
4581,
1827,
4581,
4069,
9280,
267,
408,
267,
14509,
282,
663,
402,
660,
346,
5944,
7182,
370,
314,
2013,
2633,
14,
21240,
883,
506,
1202,
370,
664,
282,
2488,
663,
267,
402,
660,
5618,
14,
8777,
949,
4766,
2013,
12,
314,
3261,
2529,
282,
18994,
9881,
23831,
769,
402,
1006,
314,
660,
5618,
267,
5420,
370,
1343,
15,
835,
15,
3191,
2633,
14,
398,
3033,
26,
288,
1343,
26,
355,
710,
1642,
1242,
370,
372,
12,
1808,
378,
13,
6788,
16356,
14,
355,
982,
440,
2013,
12,
314,
849,
365,
378,
446,
1343,
543,
314,
1642,
2808,
1242,
14,
288,
2338,
26,
355,
710,
1329,
402,
5944,
370,
372,
14,
437,
2338,
402,
446,
17,
4145,
1006,
314,
2974,
14,
355,
710,
3503,
1329,
402,
2974,
315,
314,
1177,
1443,
14460,
687,
314,
5839,
355,
2338,
340,
314,
3089,
402,
1343,
436,
2338,
24068,
314,
3141,
1329,
402,
2974,
12,
503,
355,
340,
8152,
314,
5839,
1329,
402,
2974,
3955,
5452,
4634,
1846,
14,
288,
2457,
26,
355,
437,
8605,
2457,
15,
1131,
1059,
370,
31530,
314,
769,
402,
2974,
2138,
14,
710,
355,
849,
365,
949,
2457,
446,
1006,
5944,
787,
2138,
14,
288,
1827,
26,
326,
437,
8605,
1827,
1059,
370,
31530,
314,
769,
402,
5944,
2138,
14,
710,
849,
326,
365,
949,
1827,
446,
1006,
5944,
787,
2138,
14,
288,
4069,
26,
355,
710,
4069,
1865,
402,
314,
2138,
666,
663,
14,
4885,
849,
12,
314,
4069,
1865,
365,
4079,
355,
641,
1218,
900,
12,
543,
314,
29493,
2397,
1642,
14,
398,
1803,
26,
769,
402,
660,
5618,
267,
408,
267,
372,
291,
423,
1258,
14,
362,
63,
452,
8,
928,
12,
2338,
12,
2457,
29,
1541,
12,
4069,
29,
3191,
12,
1827,
29,
1131,
9,
339,
347,
664,
8,
277,
12,
1305,
63,
269,
63,
2302,
304,
267,
408,
267,
14509,
282,
660,
346,
543,
314,
2013,
2870,
503,
9022,
267,
3033,
26,
288,
1305,
63,
269,
63,
2302,
26,
355,
18615,
506,
1902,
314,
660,
346,
1305,
503,
314,
660,
346,
5108,
398,
1803,
26,
288,
1211,
26,
710,
660,
346,
267,
408,
267,
372,
291,
423,
1258,
14,
362,
8,
344,
63,
269,
63,
2302,
9,
339,
347,
664,
63,
1782,
63,
10775,
8,
277,
12,
1305,
63,
269,
63,
2302,
304,
267,
408,
267,
27940,
314,
14611,
2556,
367,
314,
660,
346,
2073,
2013,
701,
1305,
503,
5108,
14,
398,
3033,
26,
288,
1305,
63,
269,
63,
2302,
26,
18615,
506,
1902,
314,
2073,
1305,
503,
314,
2073,
5108,
398,
1432,
26,
288,
1211,
26,
2243,
14611,
267,
408,
267,
5108,
275,
291,
423,
1258,
14,
1506,
63,
2302,
8,
344,
63,
269,
63,
2302,
9,
435,
3286,
1782,
15696,
2,
267,
372,
291,
423,
1258,
14,
362,
8,
2302,
9,
339,
347,
664,
63,
991,
8,
277,
12,
901,
12,
574,
304,
267,
408,
267,
2372,
1006,
660,
5618,
626,
1336,
314,
2457,
267,
710,
2754,
365,
1930,
27845,
398,
3033,
26,
288,
901,
26,
901,
536,
370,
2457,
288,
574,
26,
574,
370,
2457,
398,
1803,
26,
288,
1211,
26,
660,
346,
398,
408,
267,
372,
291,
423,
1258,
14,
362,
63,
991,
8,
698,
12,
574,
9,
339,
347,
2813,
8,
277,
12,
2073,
12,
3542,
29,
797,
12,
2653,
4022,
17,
304,
267,
408,
267,
23169,
314,
2013,
660,
346,
14,
398,
3033,
26,
288,
2073,
26,
1211,
909,
370,
2813,
288,
3542,
26,
326,
982,
663,
370,
2549,
314,
3439,
29672,
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,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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
] |
codepython/CollectorCity-Market-Place
|
stores/apps/blog_pages/migrations/0006_auto__add_field_home_meta_content__add_field_about_meta_content.py
|
2
|
10124
|
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Home.meta_content'
db.add_column('blog_pages_home', 'meta_content', self.gf('django.db.models.fields.TextField')(null=True, blank=True), keep_default=False)
# Adding field 'About.meta_content'
db.add_column('blog_pages_about', 'meta_content', self.gf('django.db.models.fields.TextField')(null=True, blank=True), keep_default=False)
def backwards(self, orm):
# Deleting field 'Home.meta_content'
db.delete_column('blog_pages_home', 'meta_content')
# Deleting field 'About.meta_content'
db.delete_column('blog_pages_about', 'meta_content')
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
'auth.permission': {
'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'})
},
'blog_pages.about': {
'Meta': {'object_name': 'About'},
'body': ('django.db.models.fields.TextField', [], {'default': "'This is where you may put a little description about you and your activity.'"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'meta_content': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'shop': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shops.Shop']", 'unique': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'default': "'About Us'", 'max_length': '60'})
},
'blog_pages.home': {
'Meta': {'object_name': 'Home'},
'body': ('django.db.models.fields.TextField', [], {'default': '"This text will be shown in the home page as a \'Welcome Text\'. Also you can add a picture to accompany the text."'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'blank': 'True'}),
'last_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'meta_content': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'shop': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['shops.Shop']", 'unique': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'default': "'Welcome to My Store'", 'max_length': '60'})
},
'blog_pages.link': {
'Meta': {'object_name': 'Link'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'menu': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['blog_pages.Menu']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'order': ('django.db.models.fields.PositiveIntegerField', [], {}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'to': ('django.db.models.fields.CharField', [], {'max_length': '120'})
},
'blog_pages.menu': {
'Meta': {'object_name': 'Menu'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'shop': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shops.Shop']"})
},
'blog_pages.page': {
'Meta': {'object_name': 'Page'},
'body': ('django.db.models.fields.TextField', [], {}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'last_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
'meta_content': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'name_link': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'shop': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shops.Shop']"}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'visible': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'})
},
'blog_pages.post': {
'Meta': {'object_name': 'Post'},
'body': ('django.db.models.fields.TextField', [], {}),
'date_time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'shop': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shops.Shop']"}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'views': ('django.db.models.fields.IntegerField', [], {'default': '0'})
},
'contenttypes.contenttype': {
'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
'market.marketplace': {
'Meta': {'object_name': 'MarketPlace'},
'base_domain': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}),
'charge_on_card_as': ('django.db.models.fields.CharField', [], {'default': "''", 'unique': 'True', 'max_length': '255'}),
'contact_email': ('django.db.models.fields.EmailField', [], {'default': "'contact@yourstore.com'", 'max_length': '75'}),
'contact_phone': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '92'}),
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '92', 'db_index': 'True'}),
'template_prefix': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '92', 'db_index': 'True'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '92'})
},
'shops.shop': {
'Meta': {'object_name': 'Shop'},
'admin': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
'bids': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'date_time': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'location': ('django.db.models.fields.CharField', [], {'default': "'39.29038,-76.61219'", 'max_length': '255'}),
'marketplace': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['market.MarketPlace']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '60'}),
'views': ('django.db.models.fields.IntegerField', [], {'default': '0'})
}
}
complete_apps = ['blog_pages']
|
apache-2.0
|
[
3,
2644,
26,
2774,
13,
24,
199,
646,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
2728,
327,
12934,
901,
283,
12054,
14,
2024,
63,
1317,
7,
267,
1592,
14,
525,
63,
2301,
360,
11486,
63,
5856,
63,
4219,
297,
283,
2024,
63,
1317,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
18816,
14,
2024,
63,
1317,
7,
267,
1592,
14,
525,
63,
2301,
360,
11486,
63,
5856,
63,
10254,
297,
283,
2024,
63,
1317,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
2378,
347,
8552,
8,
277,
12,
9813,
304,
2728,
327,
15920,
901,
283,
12054,
14,
2024,
63,
1317,
7,
267,
1592,
14,
1807,
63,
2301,
360,
11486,
63,
5856,
63,
4219,
297,
283,
2024,
63,
1317,
358,
398,
327,
15920,
901,
283,
18816,
14,
2024,
63,
1317,
7,
267,
1592,
14,
1807,
63,
2301,
360,
11486,
63,
5856,
63,
10254,
297,
283,
2024,
63,
1317,
358,
2378,
1709,
275,
469,
267,
283,
1178,
14,
923,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
2448,
2267,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1257,
1604,
288,
283,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
3071,
267,
1660,
267,
283,
1178,
14,
5693,
356,
469,
288,
283,
3396,
356,
791,
3235,
63,
6314,
356,
9510,
1317,
63,
466,
297,
283,
11879,
9878,
283,
785,
63,
354,
356,
283,
7980,
2267,
288,
283,
11879,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1960,
1604,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
3071,
267,
1660,
267,
283,
1178,
14,
751,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1899,
2267,
288,
283,
602,
63,
11806,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2123,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
16577,
297,
990,
791,
988,
63,
1267,
356,
283,
2194,
1604,
288,
283,
2246,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2634,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
2448,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
374,
63,
2682,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
374,
63,
7018,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
374,
63,
11434,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2019,
63,
2886,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2019,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
3933,
1604,
288,
283,
751,
63,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2473,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
708,
3071,
267,
1660,
267,
283,
11486,
63,
5856,
14,
10254,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
18816,
2267,
288,
283,
2030,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
791,
885,
356,
3546,
2765,
365,
2382,
1265,
1443,
5324,
282,
12050,
1369,
3595,
1265,
436,
2195,
10679,
3530,
5593,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
2019,
63,
5334,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
2495,
63,
2131,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2024,
63,
1317,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14
] |
[
2644,
26,
2774,
13,
24,
199,
646,
2197,
199,
504,
12919,
14,
697,
492,
1592,
199,
504,
12919,
14,
86,
18,
492,
24765,
199,
504,
1639,
14,
697,
492,
1709,
199,
199,
533,
12090,
8,
24822,
304,
339,
347,
17465,
8,
277,
12,
9813,
304,
2728,
327,
12934,
901,
283,
12054,
14,
2024,
63,
1317,
7,
267,
1592,
14,
525,
63,
2301,
360,
11486,
63,
5856,
63,
4219,
297,
283,
2024,
63,
1317,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
398,
327,
12934,
901,
283,
18816,
14,
2024,
63,
1317,
7,
267,
1592,
14,
525,
63,
2301,
360,
11486,
63,
5856,
63,
10254,
297,
283,
2024,
63,
1317,
297,
291,
14,
7102,
360,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
7533,
2307,
29,
549,
12,
4596,
29,
549,
395,
4215,
63,
885,
29,
797,
9,
2378,
347,
8552,
8,
277,
12,
9813,
304,
2728,
327,
15920,
901,
283,
12054,
14,
2024,
63,
1317,
7,
267,
1592,
14,
1807,
63,
2301,
360,
11486,
63,
5856,
63,
4219,
297,
283,
2024,
63,
1317,
358,
398,
327,
15920,
901,
283,
18816,
14,
2024,
63,
1317,
7,
267,
1592,
14,
1807,
63,
2301,
360,
11486,
63,
5856,
63,
10254,
297,
283,
2024,
63,
1317,
358,
2378,
1709,
275,
469,
267,
283,
1178,
14,
923,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
2448,
2267,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
1257,
1604,
288,
283,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
3071,
267,
1660,
267,
283,
1178,
14,
5693,
356,
469,
288,
283,
3396,
356,
791,
3235,
63,
6314,
356,
9510,
1317,
63,
466,
297,
283,
11879,
9878,
283,
785,
63,
354,
356,
283,
7980,
2267,
288,
283,
11879,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1960,
1604,
288,
283,
1317,
63,
466,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
3190,
297,
990,
791,
475,
356,
298,
1025,
459,
10778,
14,
11282,
6097,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1400,
3071,
267,
1660,
267,
283,
1178,
14,
751,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
1899,
2267,
288,
283,
602,
63,
11806,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2123,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
16577,
297,
990,
791,
988,
63,
1267,
356,
283,
2194,
1604,
288,
283,
2246,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2634,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
2448,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
498,
356,
283,
549,
1604,
288,
283,
374,
63,
2682,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
549,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
374,
63,
7018,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
374,
63,
11434,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
5036,
297,
990,
791,
885,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2019,
63,
2886,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4626,
297,
990,
791,
885,
356,
283,
2083,
14,
2083,
14,
2131,
1604,
288,
283,
2019,
63,
354,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
1216,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
988,
63,
1267,
356,
283,
3933,
1604,
288,
283,
751,
63,
6060,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2407,
14,
7624,
297,
990,
791,
475,
356,
298,
1025,
459,
1178,
14,
7980,
6256,
283,
10247,
356,
283,
797,
297,
283,
2500,
356,
283,
549,
1604,
288,
283,
2473,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
2183,
297,
990,
791,
3235,
356,
283,
549,
297,
283,
988,
63,
1267,
356,
283,
708,
3071,
267,
1660,
267,
283,
11486,
63,
5856,
14,
10254,
356,
469,
288,
283,
3396,
356,
791,
785,
63,
354,
356,
283,
18816,
2267,
288,
283,
2030,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
6254,
297,
990,
791,
885,
356,
3546,
2765,
365,
2382,
1265,
1443,
5324,
282,
12050,
1369,
3595,
1265,
436,
2195,
10679,
3530,
5593,
288,
283,
344,
356,
661,
1176,
14,
697,
14,
992,
14,
955,
14,
4378,
297,
990,
791,
3327,
63,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
eahneahn/free
|
lib/python2.7/site-packages/pygments/lexers/_phpbuiltins.py
|
274
|
122046
|
# -*- coding: utf-8 -*-
"""
pygments.lexers._phpbuiltins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This file loads the function names and their modules from the
php webpage and generates itself.
Do not alter the MODULES dict by hand!
WARNING: the generation transfers quite much data over your
internet connection. don't run that at home, use
a server ;-)
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
MODULES = {'.NET': ['dotnet_load'],
'APC': ['apc_add',
'apc_bin_dump',
'apc_bin_dumpfile',
'apc_bin_load',
'apc_bin_loadfile',
'apc_cache_info',
'apc_cas',
'apc_clear_cache',
'apc_compile_file',
'apc_dec',
'apc_define_constants',
'apc_delete_file',
'apc_delete',
'apc_exists',
'apc_fetch',
'apc_inc',
'apc_load_constants',
'apc_sma_info',
'apc_store'],
'APD': ['apd_breakpoint',
'apd_callstack',
'apd_clunk',
'apd_continue',
'apd_croak',
'apd_dump_function_table',
'apd_dump_persistent_resources',
'apd_dump_regular_resources',
'apd_echo',
'apd_get_active_symbols',
'apd_set_pprof_trace',
'apd_set_session_trace_socket',
'apd_set_session_trace',
'apd_set_session',
'override_function',
'rename_function'],
'Aliases and deprecated Mysqli': ['mysqli_bind_param',
'mysqli_bind_result',
'mysqli_client_encoding',
'mysqli_connect',
'mysqli_disable_reads_from_master',
'mysqli_disable_rpl_parse',
'mysqli_enable_reads_from_master',
'mysqli_enable_rpl_parse',
'mysqli_escape_string',
'mysqli_execute',
'mysqli_fetch',
'mysqli_get_metadata',
'mysqli_master_query',
'mysqli_param_count',
'mysqli_report',
'mysqli_rpl_parse_enabled',
'mysqli_rpl_probe',
'mysqli_rpl_query_type',
'mysqli_send_long_data',
'mysqli_send_query',
'mysqli_set_opt',
'mysqli_slave_query'],
'Apache': ['apache_child_terminate',
'apache_get_modules',
'apache_get_version',
'apache_getenv',
'apache_lookup_uri',
'apache_note',
'apache_request_headers',
'apache_reset_timeout',
'apache_response_headers',
'apache_setenv',
'getallheaders',
'virtual'],
'Array': ['array_change_key_case',
'array_chunk',
'array_combine',
'array_count_values',
'array_diff_assoc',
'array_diff_key',
'array_diff_uassoc',
'array_diff_ukey',
'array_diff',
'array_fill_keys',
'array_fill',
'array_filter',
'array_flip',
'array_intersect_assoc',
'array_intersect_key',
'array_intersect_uassoc',
'array_intersect_ukey',
'array_intersect',
'array_key_exists',
'array_keys',
'array_map',
'array_merge_recursive',
'array_merge',
'array_multisort',
'array_pad',
'array_pop',
'array_product',
'array_push',
'array_rand',
'array_reduce',
'array_replace_recursive',
'array_replace',
'array_reverse',
'array_search',
'array_shift',
'array_slice',
'array_splice',
'array_sum',
'array_udiff_assoc',
'array_udiff_uassoc',
'array_udiff',
'array_uintersect_assoc',
'array_uintersect_uassoc',
'array_uintersect',
'array_unique',
'array_unshift',
'array_values',
'array_walk_recursive',
'array_walk',
'array',
'arsort',
'asort',
'compact',
'count',
'current',
'each',
'end',
'extract',
'in_array',
'key',
'krsort',
'ksort',
'list',
'natcasesort',
'natsort',
'next',
'pos',
'prev',
'range',
'reset',
'rsort',
'shuffle',
'sizeof',
'sort',
'uasort',
'uksort',
'usort'],
'BBCode': ['bbcode_add_element',
'bbcode_add_smiley',
'bbcode_create',
'bbcode_destroy',
'bbcode_parse',
'bbcode_set_arg_parser',
'bbcode_set_flags'],
'BC Math': ['bcadd',
'bccomp',
'bcdiv',
'bcmod',
'bcmul',
'bcpow',
'bcpowmod',
'bcscale',
'bcsqrt',
'bcsub'],
'Bzip2': ['bzclose',
'bzcompress',
'bzdecompress',
'bzerrno',
'bzerror',
'bzerrstr',
'bzflush',
'bzopen',
'bzread',
'bzwrite'],
'COM': ['com_addref',
'com_create_guid',
'com_event_sink',
'com_get_active_object',
'com_get',
'com_invoke',
'com_isenum',
'com_load_typelib',
'com_load',
'com_message_pump',
'com_print_typeinfo',
'com_propget',
'com_propput',
'com_propset',
'com_release',
'com_set',
'variant_abs',
'variant_add',
'variant_and',
'variant_cast',
'variant_cat',
'variant_cmp',
'variant_date_from_timestamp',
'variant_date_to_timestamp',
'variant_div',
'variant_eqv',
'variant_fix',
'variant_get_type',
'variant_idiv',
'variant_imp',
'variant_int',
'variant_mod',
'variant_mul',
'variant_neg',
'variant_not',
'variant_or',
'variant_pow',
'variant_round',
'variant_set_type',
'variant_set',
'variant_sub',
'variant_xor'],
'CUBRID': ['cubrid_affected_rows',
'cubrid_bind',
'cubrid_close_prepare',
'cubrid_close_request',
'cubrid_col_get',
'cubrid_col_size',
'cubrid_column_names',
'cubrid_column_types',
'cubrid_commit',
'cubrid_connect_with_url',
'cubrid_connect',
'cubrid_current_oid',
'cubrid_disconnect',
'cubrid_drop',
'cubrid_error_code_facility',
'cubrid_error_code',
'cubrid_error_msg',
'cubrid_execute',
'cubrid_fetch',
'cubrid_free_result',
'cubrid_get_charset',
'cubrid_get_class_name',
'cubrid_get_client_info',
'cubrid_get_db_parameter',
'cubrid_get_server_info',
'cubrid_get',
'cubrid_insert_id',
'cubrid_is_instance',
'cubrid_lob_close',
'cubrid_lob_export',
'cubrid_lob_get',
'cubrid_lob_send',
'cubrid_lob_size',
'cubrid_lock_read',
'cubrid_lock_write',
'cubrid_move_cursor',
'cubrid_num_cols',
'cubrid_num_rows',
'cubrid_prepare',
'cubrid_put',
'cubrid_rollback',
'cubrid_schema',
'cubrid_seq_drop',
'cubrid_seq_insert',
'cubrid_seq_put',
'cubrid_set_add',
'cubrid_set_drop',
'cubrid_version'],
'Cairo': ['cairo_create',
'cairo_font_face_get_type',
'cairo_font_face_status',
'cairo_font_options_create',
'cairo_font_options_equal',
'cairo_font_options_get_antialias',
'cairo_font_options_get_hint_metrics',
'cairo_font_options_get_hint_style',
'cairo_font_options_get_subpixel_order',
'cairo_font_options_hash',
'cairo_font_options_merge',
'cairo_font_options_set_antialias',
'cairo_font_options_set_hint_metrics',
'cairo_font_options_set_hint_style',
'cairo_font_options_set_subpixel_order',
'cairo_font_options_status',
'cairo_format_stride_for_width',
'cairo_image_surface_create_for_data',
'cairo_image_surface_create_from_png',
'cairo_image_surface_create',
'cairo_image_surface_get_data',
'cairo_image_surface_get_format',
'cairo_image_surface_get_height',
'cairo_image_surface_get_stride',
'cairo_image_surface_get_width',
'cairo_matrix_create_scale',
'cairo_matrix_create_translate',
'cairo_matrix_invert',
'cairo_matrix_multiply',
'cairo_matrix_rotate',
'cairo_matrix_transform_distance',
'cairo_matrix_transform_point',
'cairo_matrix_translate',
'cairo_pattern_add_color_stop_rgb',
'cairo_pattern_add_color_stop_rgba',
'cairo_pattern_create_for_surface',
'cairo_pattern_create_linear',
'cairo_pattern_create_radial',
'cairo_pattern_create_rgb',
'cairo_pattern_create_rgba',
'cairo_pattern_get_color_stop_count',
'cairo_pattern_get_color_stop_rgba',
'cairo_pattern_get_extend',
'cairo_pattern_get_filter',
'cairo_pattern_get_linear_points',
'cairo_pattern_get_matrix',
'cairo_pattern_get_radial_circles',
'cairo_pattern_get_rgba',
'cairo_pattern_get_surface',
'cairo_pattern_get_type',
'cairo_pattern_set_extend',
'cairo_pattern_set_filter',
'cairo_pattern_set_matrix',
'cairo_pattern_status',
'cairo_pdf_surface_create',
'cairo_pdf_surface_set_size',
'cairo_ps_get_levels',
'cairo_ps_level_to_string',
'cairo_ps_surface_create',
'cairo_ps_surface_dsc_begin_page_setup',
'cairo_ps_surface_dsc_begin_setup',
'cairo_ps_surface_dsc_comment',
'cairo_ps_surface_get_eps',
'cairo_ps_surface_restrict_to_level',
'cairo_ps_surface_set_eps',
'cairo_ps_surface_set_size',
'cairo_scaled_font_create',
'cairo_scaled_font_extents',
'cairo_scaled_font_get_ctm',
'cairo_scaled_font_get_font_face',
'cairo_scaled_font_get_font_matrix',
'cairo_scaled_font_get_font_options',
'cairo_scaled_font_get_scale_matrix',
'cairo_scaled_font_get_type',
'cairo_scaled_font_glyph_extents',
'cairo_scaled_font_status',
'cairo_scaled_font_text_extents',
'cairo_surface_copy_page',
'cairo_surface_create_similar',
'cairo_surface_finish',
'cairo_surface_flush',
'cairo_surface_get_content',
'cairo_surface_get_device_offset',
'cairo_surface_get_font_options',
'cairo_surface_get_type',
'cairo_surface_mark_dirty_rectangle',
'cairo_surface_mark_dirty',
'cairo_surface_set_device_offset',
'cairo_surface_set_fallback_resolution',
'cairo_surface_show_page',
'cairo_surface_status',
'cairo_surface_write_to_png',
'cairo_svg_surface_create',
'cairo_svg_surface_restrict_to_version',
'cairo_svg_version_to_string'],
'Calendar': ['cal_days_in_month',
'cal_from_jd',
'cal_info',
'cal_to_jd',
'easter_date',
'easter_days',
'FrenchToJD',
'GregorianToJD',
'JDDayOfWeek',
'JDMonthName',
'JDToFrench',
'JDToGregorian',
'jdtojewish',
'JDToJulian',
'jdtounix',
'JewishToJD',
'JulianToJD',
'unixtojd'],
'Classes/Object': ['call_user_method_array',
'call_user_method',
'class_alias',
'class_exists',
'get_called_class',
'get_class_methods',
'get_class_vars',
'get_class',
'get_declared_classes',
'get_declared_interfaces',
'get_object_vars',
'get_parent_class',
'interface_exists',
'is_a',
'is_subclass_of',
'method_exists',
'property_exists'],
'Classkit': ['classkit_import',
'classkit_method_add',
'classkit_method_copy',
'classkit_method_redefine',
'classkit_method_remove',
'classkit_method_rename'],
'Crack': ['crack_check',
'crack_closedict',
'crack_getlastmessage',
'crack_opendict'],
'Ctype': ['ctype_alnum',
'ctype_alpha',
'ctype_cntrl',
'ctype_digit',
'ctype_graph',
'ctype_lower',
'ctype_print',
'ctype_punct'],
'Cyrus': ['cyrus_authenticate',
'cyrus_bind',
'cyrus_close',
'cyrus_connect',
'cyrus_query',
'cyrus_unbind'],
'DB++': ['dbplus_add',
'dbplus_aql',
'dbplus_chdir',
'dbplus_close',
'dbplus_curr',
'dbplus_errcode',
'dbplus_errno',
'dbplus_find',
'dbplus_first',
'dbplus_flush',
'dbplus_freealllocks',
'dbplus_freelock',
'dbplus_freerlocks',
'dbplus_getlock',
'dbplus_getunique',
'dbplus_info',
'dbplus_last',
'dbplus_lockrel',
'dbplus_next',
'dbplus_open',
'dbplus_prev',
'dbplus_rchperm',
'dbplus_rcreate',
'dbplus_rcrtexact',
'dbplus_rcrtlike',
'dbplus_resolve',
'dbplus_restorepos',
'dbplus_rkeys',
'dbplus_ropen',
'dbplus_rquery',
'dbplus_rrename',
'dbplus_rsecindex',
'dbplus_runlink',
'dbplus_rzap',
'dbplus_savepos',
'dbplus_setindex',
'dbplus_setindexbynumber',
'dbplus_sql',
'dbplus_tcl',
'dbplus_tremove',
'dbplus_undo',
'dbplus_undoprepare',
'dbplus_unlockrel',
'dbplus_unselect',
'dbplus_update',
'dbplus_xlockrel',
'dbplus_xunlockrel'],
'DBA': ['dba_close',
'dba_delete',
'dba_exists',
'dba_fetch',
'dba_firstkey',
'dba_handlers',
'dba_insert',
'dba_key_split',
'dba_list',
'dba_nextkey',
'dba_open',
'dba_optimize',
'dba_popen',
'dba_replace',
'dba_sync'],
'DOM': ['dom_import_simplexml'],
'DOM XML (PHP 4)': ['domxml_new_doc',
'domxml_open_file',
'domxml_open_mem',
'domxml_version',
'domxml_xmltree',
'domxml_xslt_stylesheet_doc',
'domxml_xslt_stylesheet_file',
'domxml_xslt_stylesheet',
'domxml_xslt_version',
'xpath_eval_expression',
'xpath_eval',
'xpath_new_context',
'xpath_register_ns_auto',
'xpath_register_ns',
'xptr_eval',
'xptr_new_context'],
'Date/Time': ['checkdate',
'date_add',
'date_create_from_format',
'date_create',
'date_date_set',
'date_default_timezone_get',
'date_default_timezone_set',
'date_diff',
'date_format',
'date_get_last_errors',
'date_interval_create_from_date_string',
'date_interval_format',
'date_isodate_set',
'date_modify',
'date_offset_get',
'date_parse_from_format',
'date_parse',
'date_sub',
'date_sun_info',
'date_sunrise',
'date_sunset',
'date_time_set',
'date_timestamp_get',
'date_timestamp_set',
'date_timezone_get',
'date_timezone_set',
'date',
'getdate',
'gettimeofday',
'gmdate',
'gmmktime',
'gmstrftime',
'idate',
'localtime',
'microtime',
'mktime',
'strftime',
'strptime',
'strtotime',
'time',
'timezone_abbreviations_list',
'timezone_identifiers_list',
'timezone_location_get',
'timezone_name_from_abbr',
'timezone_name_get',
'timezone_offset_get',
'timezone_open',
'timezone_transitions_get',
'timezone_version_get'],
'Direct IO': ['dio_close', 'dio_fcntl', 'dio_open'],
'Directory': ['chdir',
'chroot',
'closedir',
'getcwd',
'opendir',
'readdir',
'rewinddir',
'scandir'],
'Enchant': ['enchant_broker_describe',
'enchant_broker_dict_exists',
'enchant_broker_free_dict',
'enchant_broker_free',
'enchant_broker_get_error',
'enchant_broker_init',
'enchant_broker_list_dicts',
'enchant_broker_request_dict',
'enchant_broker_request_pwl_dict',
'enchant_broker_set_ordering',
'enchant_dict_add_to_personal',
'enchant_dict_add_to_session',
'enchant_dict_check',
'enchant_dict_describe',
'enchant_dict_get_error',
'enchant_dict_is_in_session',
'enchant_dict_quick_check',
'enchant_dict_store_replacement',
'enchant_dict_suggest'],
'Error Handling': ['debug_backtrace',
'debug_print_backtrace',
'error_get_last',
'error_log',
'error_reporting',
'restore_error_handler',
'restore_exception_handler',
'set_error_handler',
'set_exception_handler',
'trigger_error',
'user_error'],
'Exif': ['exif_imagetype',
'exif_read_data',
'exif_tagname',
'exif_thumbnail',
'read_exif_data'],
'Expect': ['expect_expectl'],
'FAM': ['fam_cancel_monitor',
'fam_close',
'fam_monitor_collection',
'fam_monitor_directory',
'fam_monitor_file',
'fam_next_event',
'fam_open',
'fam_pending',
'fam_resume_monitor',
'fam_suspend_monitor'],
'FDF': ['fdf_add_doc_javascript',
'fdf_add_template',
'fdf_close',
'fdf_create',
'fdf_enum_values',
'fdf_errno',
'fdf_error',
'fdf_get_ap',
'fdf_get_attachment',
'fdf_get_encoding',
'fdf_get_file',
'fdf_get_flags',
'fdf_get_opt',
'fdf_get_status',
'fdf_get_value',
'fdf_get_version',
'fdf_header',
'fdf_next_field_name',
'fdf_open_string',
'fdf_open',
'fdf_remove_item',
'fdf_save_string',
'fdf_save',
'fdf_set_ap',
'fdf_set_encoding',
'fdf_set_file',
'fdf_set_flags',
'fdf_set_javascript_action',
'fdf_set_on_import_javascript',
'fdf_set_opt',
'fdf_set_status',
'fdf_set_submit_form_action',
'fdf_set_target_frame',
'fdf_set_value',
'fdf_set_version'],
'FTP': ['ftp_alloc',
'ftp_cdup',
'ftp_chdir',
'ftp_chmod',
'ftp_close',
'ftp_connect',
'ftp_delete',
'ftp_exec',
'ftp_fget',
'ftp_fput',
'ftp_get_option',
'ftp_get',
'ftp_login',
'ftp_mdtm',
'ftp_mkdir',
'ftp_nb_continue',
'ftp_nb_fget',
'ftp_nb_fput',
'ftp_nb_get',
'ftp_nb_put',
'ftp_nlist',
'ftp_pasv',
'ftp_put',
'ftp_pwd',
'ftp_quit',
'ftp_raw',
'ftp_rawlist',
'ftp_rename',
'ftp_rmdir',
'ftp_set_option',
'ftp_site',
'ftp_size',
'ftp_ssl_connect',
'ftp_systype'],
'Fileinfo': ['finfo_buffer',
'finfo_close',
'finfo_file',
'finfo_open',
'finfo_set_flags',
'mime_content_type'],
'Filesystem': ['basename',
'chgrp',
'chmod',
'chown',
'clearstatcache',
'copy',
'dirname',
'disk_free_space',
'disk_total_space',
'diskfreespace',
'fclose',
'feof',
'fflush',
'fgetc',
'fgetcsv',
'fgets',
'fgetss',
'file_exists',
'file_get_contents',
'file_put_contents',
'file',
'fileatime',
'filectime',
'filegroup',
'fileinode',
'filemtime',
'fileowner',
'fileperms',
'filesize',
'filetype',
'flock',
'fnmatch',
'fopen',
'fpassthru',
'fputcsv',
'fputs',
'fread',
'fscanf',
'fseek',
'fstat',
'ftell',
'ftruncate',
'fwrite',
'glob',
'is_dir',
'is_executable',
'is_file',
'is_link',
'is_readable',
'is_uploaded_file',
'is_writable',
'is_writeable',
'lchgrp',
'lchown',
'link',
'linkinfo',
'lstat',
'mkdir',
'move_uploaded_file',
'parse_ini_file',
'parse_ini_string',
'pathinfo',
'pclose',
'popen',
'readfile',
'readlink',
'realpath_cache_get',
'realpath_cache_size',
'realpath',
'rename',
'rewind',
'rmdir',
'set_file_buffer',
'stat',
'symlink',
'tempnam',
'tmpfile',
'touch',
'umask',
'unlink'],
'Filter': ['filter_has_var',
'filter_id',
'filter_input_array',
'filter_input',
'filter_list',
'filter_var_array',
'filter_var'],
'Firebird/InterBase': ['ibase_add_user',
'ibase_affected_rows',
'ibase_backup',
'ibase_blob_add',
'ibase_blob_cancel',
'ibase_blob_close',
'ibase_blob_create',
'ibase_blob_echo',
'ibase_blob_get',
'ibase_blob_import',
'ibase_blob_info',
'ibase_blob_open',
'ibase_close',
'ibase_commit_ret',
'ibase_commit',
'ibase_connect',
'ibase_db_info',
'ibase_delete_user',
'ibase_drop_db',
'ibase_errcode',
'ibase_errmsg',
'ibase_execute',
'ibase_fetch_assoc',
'ibase_fetch_object',
'ibase_fetch_row',
'ibase_field_info',
'ibase_free_event_handler',
'ibase_free_query',
'ibase_free_result',
'ibase_gen_id',
'ibase_maintain_db',
'ibase_modify_user',
'ibase_name_result',
'ibase_num_fields',
'ibase_num_params',
'ibase_param_info',
'ibase_pconnect',
'ibase_prepare',
'ibase_query',
'ibase_restore',
'ibase_rollback_ret',
'ibase_rollback',
'ibase_server_info',
'ibase_service_attach',
'ibase_service_detach',
'ibase_set_event_handler',
'ibase_timefmt',
'ibase_trans',
'ibase_wait_event'],
'FriBiDi': ['fribidi_log2vis'],
'FrontBase': ['fbsql_affected_rows',
'fbsql_autocommit',
'fbsql_blob_size',
'fbsql_change_user',
'fbsql_clob_size',
'fbsql_close',
'fbsql_commit',
'fbsql_connect',
'fbsql_create_blob',
'fbsql_create_clob',
'fbsql_create_db',
'fbsql_data_seek',
'fbsql_database_password',
'fbsql_database',
'fbsql_db_query',
'fbsql_db_status',
'fbsql_drop_db',
'fbsql_errno',
'fbsql_error',
'fbsql_fetch_array',
'fbsql_fetch_assoc',
'fbsql_fetch_field',
'fbsql_fetch_lengths',
'fbsql_fetch_object',
'fbsql_fetch_row',
'fbsql_field_flags',
'fbsql_field_len',
'fbsql_field_name',
'fbsql_field_seek',
'fbsql_field_table',
'fbsql_field_type',
'fbsql_free_result',
'fbsql_get_autostart_info',
'fbsql_hostname',
'fbsql_insert_id',
'fbsql_list_dbs',
'fbsql_list_fields',
'fbsql_list_tables',
'fbsql_next_result',
'fbsql_num_fields',
'fbsql_num_rows',
'fbsql_password',
'fbsql_pconnect',
'fbsql_query',
'fbsql_read_blob',
'fbsql_read_clob',
'fbsql_result',
'fbsql_rollback',
'fbsql_rows_fetched',
'fbsql_select_db',
'fbsql_set_characterset',
'fbsql_set_lob_mode',
'fbsql_set_password',
'fbsql_set_transaction',
'fbsql_start_db',
'fbsql_stop_db',
'fbsql_table_name',
'fbsql_tablename',
'fbsql_username',
'fbsql_warnings'],
'Function handling': ['call_user_func_array',
'call_user_func',
'create_function',
'forward_static_call_array',
'forward_static_call',
'func_get_arg',
'func_get_args',
'func_num_args',
'function_exists',
'get_defined_functions',
'register_shutdown_function',
'register_tick_function',
'unregister_tick_function'],
'GD and Image': ['gd_info',
'getimagesize',
'image_type_to_extension',
'image_type_to_mime_type'],
'GMP': ['gmp_abs',
'gmp_add',
'gmp_and',
'gmp_clrbit',
'gmp_cmp',
'gmp_com',
'gmp_div_q',
'gmp_div_qr',
'gmp_div_r',
'gmp_div',
'gmp_divexact',
'gmp_fact',
'gmp_gcd',
'gmp_gcdext',
'gmp_hamdist',
'gmp_init',
'gmp_intval',
'gmp_invert',
'gmp_jacobi',
'gmp_legendre',
'gmp_mod',
'gmp_mul',
'gmp_neg',
'gmp_nextprime',
'gmp_or',
'gmp_perfect_square',
'gmp_popcount',
'gmp_pow',
'gmp_powm',
'gmp_prob_prime',
'gmp_random',
'gmp_scan0',
'gmp_scan1',
'gmp_setbit',
'gmp_sign',
'gmp_sqrt',
'gmp_sqrtrem',
'gmp_strval',
'gmp_sub',
'gmp_testbit',
'gmp_xor'],
'GeoIP': ['geoip_continent_code_by_name',
'geoip_country_code_by_name',
'geoip_country_code3_by_name',
'geoip_country_name_by_name',
'geoip_database_info',
'geoip_db_avail',
'geoip_db_filename',
'geoip_db_get_all_info',
'geoip_id_by_name',
'geoip_isp_by_name',
'geoip_org_by_name',
'geoip_record_by_name',
'geoip_region_by_name',
'geoip_region_name_by_code',
'geoip_time_zone_by_country_and_region'],
'Gettext': ['bind_textdomain_codeset',
'bindtextdomain',
'dcgettext',
'dcngettext',
'dgettext',
'dngettext',
'gettext',
'ngettext',
'textdomain'],
'GnuPG': ['gnupg_adddecryptkey',
'gnupg_addencryptkey',
'gnupg_addsignkey',
'gnupg_cleardecryptkeys',
'gnupg_clearencryptkeys',
'gnupg_clearsignkeys',
'gnupg_decrypt',
'gnupg_decryptverify',
'gnupg_encrypt',
'gnupg_encryptsign',
'gnupg_export',
'gnupg_geterror',
'gnupg_getprotocol',
'gnupg_import',
'gnupg_init',
'gnupg_keyinfo',
'gnupg_setarmor',
'gnupg_seterrormode',
'gnupg_setsignmode',
'gnupg_sign',
'gnupg_verify'],
'Gopher': ['gopher_parsedir'],
'Grapheme': ['grapheme_extract',
'grapheme_stripos',
'grapheme_stristr',
'grapheme_strlen',
'grapheme_strpos',
'grapheme_strripos',
'grapheme_strrpos',
'grapheme_strstr',
'grapheme_substr'],
'Gupnp': ['gupnp_context_get_host_ip',
'gupnp_context_get_port',
'gupnp_context_get_subscription_timeout',
'gupnp_context_host_path',
'gupnp_context_new',
'gupnp_context_set_subscription_timeout',
'gupnp_context_timeout_add',
'gupnp_context_unhost_path',
'gupnp_control_point_browse_start',
'gupnp_control_point_browse_stop',
'gupnp_control_point_callback_set',
'gupnp_control_point_new',
'gupnp_device_action_callback_set',
'gupnp_device_info_get_service',
'gupnp_device_info_get',
'gupnp_root_device_get_available',
'gupnp_root_device_get_relative_location',
'gupnp_root_device_new',
'gupnp_root_device_set_available',
'gupnp_root_device_start',
'gupnp_root_device_stop',
'gupnp_service_action_get',
'gupnp_service_action_return_error',
'gupnp_service_action_return',
'gupnp_service_action_set',
'gupnp_service_freeze_notify',
'gupnp_service_info_get_introspection',
'gupnp_service_info_get',
'gupnp_service_introspection_get_state_variable',
'gupnp_service_notify',
'gupnp_service_proxy_action_get',
'gupnp_service_proxy_action_set',
'gupnp_service_proxy_add_notify',
'gupnp_service_proxy_callback_set',
'gupnp_service_proxy_get_subscribed',
'gupnp_service_proxy_remove_notify',
'gupnp_service_proxy_set_subscribed',
'gupnp_service_thaw_notify'],
'HTTP': ['http_cache_etag',
'http_cache_last_modified',
'http_chunked_decode',
'http_deflate',
'http_inflate',
'http_build_cookie',
'http_date',
'http_get_request_body_stream',
'http_get_request_body',
'http_get_request_headers',
'http_match_etag',
'http_match_modified',
'http_match_request_header',
'http_support',
'http_negotiate_charset',
'http_negotiate_content_type',
'http_negotiate_language',
'ob_deflatehandler',
'ob_etaghandler',
'ob_inflatehandler',
'http_parse_cookie',
'http_parse_headers',
'http_parse_message',
'http_parse_params',
'http_persistent_handles_clean',
'http_persistent_handles_count',
'http_persistent_handles_ident',
'http_get',
'http_head',
'http_post_data',
'http_post_fields',
'http_put_data',
'http_put_file',
'http_put_stream',
'http_request_body_encode',
'http_request_method_exists',
'http_request_method_name',
'http_request_method_register',
'http_request_method_unregister',
'http_request',
'http_redirect',
'http_send_content_disposition',
'http_send_content_type',
'http_send_data',
'http_send_file',
'http_send_last_modified',
'http_send_status',
'http_send_stream',
'http_throttle',
'http_build_str',
'http_build_url'],
'Hash': ['hash_algos',
'hash_copy',
'hash_file',
'hash_final',
'hash_hmac_file',
'hash_hmac',
'hash_init',
'hash_update_file',
'hash_update_stream',
'hash_update',
'hash'],
'Hyperwave': ['hw_Array2Objrec',
'hw_changeobject',
'hw_Children',
'hw_ChildrenObj',
'hw_Close',
'hw_Connect',
'hw_connection_info',
'hw_cp',
'hw_Deleteobject',
'hw_DocByAnchor',
'hw_DocByAnchorObj',
'hw_Document_Attributes',
'hw_Document_BodyTag',
'hw_Document_Content',
'hw_Document_SetContent',
'hw_Document_Size',
'hw_dummy',
'hw_EditText',
'hw_Error',
'hw_ErrorMsg',
'hw_Free_Document',
'hw_GetAnchors',
'hw_GetAnchorsObj',
'hw_GetAndLock',
'hw_GetChildColl',
'hw_GetChildCollObj',
'hw_GetChildDocColl',
'hw_GetChildDocCollObj',
'hw_GetObject',
'hw_GetObjectByQuery',
'hw_GetObjectByQueryColl',
'hw_GetObjectByQueryCollObj',
'hw_GetObjectByQueryObj',
'hw_GetParents',
'hw_GetParentsObj',
'hw_getrellink',
'hw_GetRemote',
'hw_getremotechildren',
'hw_GetSrcByDestObj',
'hw_GetText',
'hw_getusername',
'hw_Identify',
'hw_InCollections',
'hw_Info',
'hw_InsColl',
'hw_InsDoc',
'hw_insertanchors',
'hw_InsertDocument',
'hw_InsertObject',
'hw_mapid',
'hw_Modifyobject',
'hw_mv',
'hw_New_Document',
'hw_objrec2array',
'hw_Output_Document',
'hw_pConnect',
'hw_PipeDocument',
'hw_Root',
'hw_setlinkroot',
'hw_stat',
'hw_Unlock',
'hw_Who'],
'Hyperwave API': ['hw_api_attribute',
'hwapi_hgcsp',
'hw_api_content',
'hw_api_object'],
'IBM DB2': ['db2_autocommit',
'db2_bind_param',
'db2_client_info',
'db2_close',
'db2_column_privileges',
'db2_columns',
'db2_commit',
'db2_conn_error',
'db2_conn_errormsg',
'db2_connect',
'db2_cursor_type',
'db2_escape_string',
'db2_exec',
'db2_execute',
'db2_fetch_array',
'db2_fetch_assoc',
'db2_fetch_both',
'db2_fetch_object',
'db2_fetch_row',
'db2_field_display_size',
'db2_field_name',
'db2_field_num',
'db2_field_precision',
'db2_field_scale',
'db2_field_type',
'db2_field_width',
'db2_foreign_keys',
'db2_free_result',
'db2_free_stmt',
'db2_get_option',
'db2_last_insert_id'],
'ID3': ['id3_get_frame_long_name',
'id3_get_frame_short_name',
'id3_get_genre_id',
'id3_get_genre_list',
'id3_get_genre_name',
'id3_get_tag',
'id3_get_version',
'id3_remove_tag',
'id3_set_tag'],
'IDN': ['idn_to_ascii', 'idn_to_unicode', 'idn_to_utf8'],
'IIS': ['iis_add_server',
'iis_get_dir_security',
'iis_get_script_map',
'iis_get_server_by_comment',
'iis_get_server_by_path',
'iis_get_server_rights',
'iis_get_service_state',
'iis_remove_server',
'iis_set_app_settings',
'iis_set_dir_security',
'iis_set_script_map',
'iis_set_server_rights',
'iis_start_server',
'iis_start_service',
'iis_stop_server',
'iis_stop_service'],
'IMAP': ['imap_8bit',
'imap_alerts',
'imap_append',
'imap_base64',
'imap_binary',
'imap_body',
'imap_bodystruct',
'imap_check',
'imap_clearflag_full',
'imap_close',
'imap_createmailbox',
'imap_delete',
'imap_deletemailbox',
'imap_errors',
'imap_expunge',
'imap_fetch_overview',
'imap_fetchbody',
'imap_fetchheader',
'imap_fetchmime',
'imap_fetchstructure',
'imap_gc',
'imap_get_quota',
'imap_get_quotaroot',
'imap_getacl',
'imap_getmailboxes',
'imap_getsubscribed',
'imap_header',
'imap_headerinfo',
'imap_headers',
'imap_last_error',
'imap_list',
'imap_listmailbox',
'imap_listscan',
'imap_listsubscribed',
'imap_lsub',
'imap_mail_compose',
'imap_mail_copy',
'imap_mail_move',
'imap_mail',
'imap_mailboxmsginfo',
'imap_mime_header_decode',
'imap_msgno',
'imap_num_msg',
'imap_num_recent',
'imap_open',
'imap_ping',
'imap_qprint',
'imap_renamemailbox',
'imap_reopen',
'imap_rfc822_parse_adrlist',
'imap_rfc822_parse_headers',
'imap_rfc822_write_address',
'imap_savebody',
'imap_scanmailbox',
'imap_search',
'imap_set_quota',
'imap_setacl',
'imap_setflag_full',
'imap_sort',
'imap_status',
'imap_subscribe',
'imap_thread',
'imap_timeout',
'imap_uid',
'imap_undelete',
'imap_unsubscribe',
'imap_utf7_decode',
'imap_utf7_encode',
'imap_utf8'],
'Informix': ['ifx_affected_rows',
'ifx_blobinfile_mode',
'ifx_byteasvarchar',
'ifx_close',
'ifx_connect',
'ifx_copy_blob',
'ifx_create_blob',
'ifx_create_char',
'ifx_do',
'ifx_error',
'ifx_errormsg',
'ifx_fetch_row',
'ifx_fieldproperties',
'ifx_fieldtypes',
'ifx_free_blob',
'ifx_free_char',
'ifx_free_result',
'ifx_get_blob',
'ifx_get_char',
'ifx_getsqlca',
'ifx_htmltbl_result',
'ifx_nullformat',
'ifx_num_fields',
'ifx_num_rows',
'ifx_pconnect',
'ifx_prepare',
'ifx_query',
'ifx_textasvarchar',
'ifx_update_blob',
'ifx_update_char',
'ifxus_close_slob',
'ifxus_create_slob',
'ifxus_free_slob',
'ifxus_open_slob',
'ifxus_read_slob',
'ifxus_seek_slob',
'ifxus_tell_slob',
'ifxus_write_slob'],
'Ingres': ['ingres_autocommit_state',
'ingres_autocommit',
'ingres_charset',
'ingres_close',
'ingres_commit',
'ingres_connect',
'ingres_cursor',
'ingres_errno',
'ingres_error',
'ingres_errsqlstate',
'ingres_escape_string',
'ingres_execute',
'ingres_fetch_array',
'ingres_fetch_assoc',
'ingres_fetch_object',
'ingres_fetch_proc_return',
'ingres_fetch_row',
'ingres_field_length',
'ingres_field_name',
'ingres_field_nullable',
'ingres_field_precision',
'ingres_field_scale',
'ingres_field_type',
'ingres_free_result',
'ingres_next_error',
'ingres_num_fields',
'ingres_num_rows',
'ingres_pconnect',
'ingres_prepare',
'ingres_query',
'ingres_result_seek',
'ingres_rollback',
'ingres_set_environment',
'ingres_unbuffered_query'],
'Inotify': ['inotify_add_watch',
'inotify_init',
'inotify_queue_len',
'inotify_read',
'inotify_rm_watch'],
'JSON': ['json_decode', 'json_encode', 'json_last_error'],
'Java': ['java_last_exception_clear', 'java_last_exception_get'],
'Judy': ['judy_type', 'judy_version'],
'KADM5': ['kadm5_chpass_principal',
'kadm5_create_principal',
'kadm5_delete_principal',
'kadm5_destroy',
'kadm5_flush',
'kadm5_get_policies',
'kadm5_get_principal',
'kadm5_get_principals',
'kadm5_init_with_password',
'kadm5_modify_principal'],
'LDAP': ['ldap_8859_to_t61',
'ldap_add',
'ldap_bind',
'ldap_close',
'ldap_compare',
'ldap_connect',
'ldap_count_entries',
'ldap_delete',
'ldap_dn2ufn',
'ldap_err2str',
'ldap_errno',
'ldap_error',
'ldap_explode_dn',
'ldap_first_attribute',
'ldap_first_entry',
'ldap_first_reference',
'ldap_free_result',
'ldap_get_attributes',
'ldap_get_dn',
'ldap_get_entries',
'ldap_get_option',
'ldap_get_values_len',
'ldap_get_values',
'ldap_list',
'ldap_mod_add',
'ldap_mod_del',
'ldap_mod_replace',
'ldap_modify',
'ldap_next_attribute',
'ldap_next_entry',
'ldap_next_reference',
'ldap_parse_reference',
'ldap_parse_result',
'ldap_read',
'ldap_rename',
'ldap_sasl_bind',
'ldap_search',
'ldap_set_option',
'ldap_set_rebind_proc',
'ldap_sort',
'ldap_start_tls',
'ldap_t61_to_8859',
'ldap_unbind'],
'LZF': ['lzf_compress', 'lzf_decompress', 'lzf_optimized_for'],
'Libevent': ['event_add',
'event_base_free',
'event_base_loop',
'event_base_loopbreak',
'event_base_loopexit',
'event_base_new',
'event_base_priority_init',
'event_base_set',
'event_buffer_base_set',
'event_buffer_disable',
'event_buffer_enable',
'event_buffer_fd_set',
'event_buffer_free',
'event_buffer_new',
'event_buffer_priority_set',
'event_buffer_read',
'event_buffer_set_callback',
'event_buffer_timeout_set',
'event_buffer_watermark_set',
'event_buffer_write',
'event_del',
'event_free',
'event_new',
'event_set'],
'Lotus Notes': ['notes_body',
'notes_copy_db',
'notes_create_db',
'notes_create_note',
'notes_drop_db',
'notes_find_note',
'notes_header_info',
'notes_list_msgs',
'notes_mark_read',
'notes_mark_unread',
'notes_nav_create',
'notes_search',
'notes_unread',
'notes_version'],
'MCVE': ['m_checkstatus',
'm_completeauthorizations',
'm_connect',
'm_connectionerror',
'm_deletetrans',
'm_destroyconn',
'm_destroyengine',
'm_getcell',
'm_getcellbynum',
'm_getcommadelimited',
'm_getheader',
'm_initconn',
'm_initengine',
'm_iscommadelimited',
'm_maxconntimeout',
'm_monitor',
'm_numcolumns',
'm_numrows',
'm_parsecommadelimited',
'm_responsekeys'],
'Mail': ['ezmlm_hash', 'mail'],
'Mailparse': ['mailparse_determine_best_xfer_encoding',
'mailparse_msg_create',
'mailparse_msg_extract_part_file',
'mailparse_msg_extract_part',
'mailparse_msg_extract_whole_part_file',
'mailparse_msg_free',
'mailparse_msg_get_part_data',
'mailparse_msg_get_part',
'mailparse_msg_get_structure',
'mailparse_msg_parse_file',
'mailparse_msg_parse',
'mailparse_rfc822_parse_addresses',
'mailparse_stream_encode',
'mailparse_uudecode_all'],
'Math': ['abs',
'acos',
'acosh',
'asin',
'asinh',
'atan2',
'atan',
'atanh',
'base_convert',
'bindec',
'ceil',
'cos',
'cosh',
'decbin',
'dechex',
'decoct',
'deg2rad',
'exp',
'expm1'],
'MaxDB': ['maxdb_affected_rows',
'maxdb_autocommit',
'maxdb_bind_param',
'maxdb_bind_result',
'maxdb_change_user',
'maxdb_character_set_name',
'maxdb_client_encoding',
'maxdb_close_long_data',
'maxdb_close',
'maxdb_commit',
'maxdb_connect_errno',
'maxdb_connect_error',
'maxdb_connect',
'maxdb_data_seek',
'maxdb_debug',
'maxdb_disable_reads_from_master',
'maxdb_disable_rpl_parse',
'maxdb_dump_debug_info',
'maxdb_embedded_connect',
'maxdb_enable_reads_from_master',
'maxdb_enable_rpl_parse',
'maxdb_errno',
'maxdb_error',
'maxdb_escape_string',
'maxdb_execute',
'maxdb_fetch_array',
'maxdb_fetch_assoc',
'maxdb_fetch_field_direct',
'maxdb_fetch_field',
'maxdb_fetch_fields',
'maxdb_fetch_lengths',
'maxdb_fetch_object',
'maxdb_fetch_row',
'maxdb_fetch',
'maxdb_field_count',
'maxdb_field_seek',
'maxdb_field_tell',
'maxdb_free_result',
'maxdb_get_client_info',
'maxdb_get_client_version',
'maxdb_get_host_info',
'maxdb_get_metadata',
'maxdb_get_proto_info',
'maxdb_get_server_info',
'maxdb_get_server_version',
'maxdb_info',
'maxdb_init',
'maxdb_insert_id',
'maxdb_kill',
'maxdb_master_query',
'maxdb_more_results',
'maxdb_multi_query',
'maxdb_next_result',
'maxdb_num_fields',
'maxdb_num_rows',
'maxdb_options',
'maxdb_param_count',
'maxdb_ping',
'maxdb_prepare',
'maxdb_query',
'maxdb_real_connect',
'maxdb_real_escape_string',
'maxdb_real_query',
'maxdb_report',
'maxdb_rollback',
'maxdb_rpl_parse_enabled',
'maxdb_rpl_probe',
'maxdb_rpl_query_type',
'maxdb_select_db',
'maxdb_send_long_data',
'maxdb_send_query',
'maxdb_server_end',
'maxdb_server_init',
'maxdb_set_opt',
'maxdb_sqlstate',
'maxdb_ssl_set',
'maxdb_stat',
'maxdb_stmt_affected_rows'],
'Mcrypt': ['mcrypt_cbc',
'mcrypt_cfb',
'mcrypt_create_iv',
'mcrypt_decrypt',
'mcrypt_ecb',
'mcrypt_enc_get_algorithms_name',
'mcrypt_enc_get_block_size',
'mcrypt_enc_get_iv_size',
'mcrypt_enc_get_key_size',
'mcrypt_enc_get_modes_name',
'mcrypt_enc_get_supported_key_sizes',
'mcrypt_enc_is_block_algorithm_mode',
'mcrypt_enc_is_block_algorithm',
'mcrypt_enc_is_block_mode',
'mcrypt_enc_self_test',
'mcrypt_encrypt',
'mcrypt_generic_deinit',
'mcrypt_generic_end',
'mcrypt_generic_init',
'mcrypt_generic',
'mcrypt_get_block_size',
'mcrypt_get_cipher_name',
'mcrypt_get_iv_size',
'mcrypt_get_key_size',
'mcrypt_list_algorithms',
'mcrypt_list_modes',
'mcrypt_module_close',
'mcrypt_module_get_algo_block_size',
'mcrypt_module_get_algo_key_size',
'mcrypt_module_get_supported_key_sizes',
'mcrypt_module_is_block_algorithm_mode',
'mcrypt_module_is_block_algorithm',
'mcrypt_module_is_block_mode',
'mcrypt_module_open',
'mcrypt_module_self_test',
'mcrypt_ofb',
'mdecrypt_generic'],
'Memcache': ['memcache_debug'],
'Mhash': ['mhash_count',
'mhash_get_block_size',
'mhash_get_hash_name',
'mhash_keygen_s2k',
'mhash'],
'Ming': ['ming_keypress',
'ming_setcubicthreshold',
'ming_setscale',
'ming_setswfcompression',
'ming_useconstants',
'ming_useswfversion'],
'Misc.': ['connection_aborted',
'connection_status',
'connection_timeout',
'constant',
'define',
'defined',
'die',
'eval',
'exit',
'get_browser',
'__halt_compiler',
'highlight_file',
'highlight_string',
'ignore_user_abort',
'pack',
'php_check_syntax',
'php_strip_whitespace',
'show_source',
'sleep',
'sys_getloadavg',
'time_nanosleep',
'time_sleep_until',
'uniqid',
'unpack',
'usleep'],
'Mongo': ['bson_decode', 'bson_encode'],
'Msession': ['msession_connect',
'msession_count',
'msession_create',
'msession_destroy',
'msession_disconnect',
'msession_find',
'msession_get_array',
'msession_get_data',
'msession_get',
'msession_inc',
'msession_list',
'msession_listvar',
'msession_lock',
'msession_plugin',
'msession_randstr',
'msession_set_array',
'msession_set_data',
'msession_set',
'msession_timeout',
'msession_uniq',
'msession_unlock'],
'Mssql': ['mssql_bind',
'mssql_close',
'mssql_connect',
'mssql_data_seek',
'mssql_execute',
'mssql_fetch_array',
'mssql_fetch_assoc',
'mssql_fetch_batch',
'mssql_fetch_field',
'mssql_fetch_object',
'mssql_fetch_row',
'mssql_field_length',
'mssql_field_name',
'mssql_field_seek',
'mssql_field_type',
'mssql_free_result',
'mssql_free_statement',
'mssql_get_last_message',
'mssql_guid_string',
'mssql_init',
'mssql_min_error_severity',
'mssql_min_message_severity',
'mssql_next_result',
'mssql_num_fields',
'mssql_num_rows',
'mssql_pconnect',
'mssql_query',
'mssql_result',
'mssql_rows_affected',
'mssql_select_db'],
'Multibyte String': ['mb_check_encoding',
'mb_convert_case',
'mb_convert_encoding',
'mb_convert_kana',
'mb_convert_variables',
'mb_decode_mimeheader',
'mb_decode_numericentity',
'mb_detect_encoding',
'mb_detect_order',
'mb_encode_mimeheader',
'mb_encode_numericentity',
'mb_encoding_aliases',
'mb_ereg_match',
'mb_ereg_replace',
'mb_ereg_search_getpos',
'mb_ereg_search_getregs',
'mb_ereg_search_init',
'mb_ereg_search_pos',
'mb_ereg_search_regs',
'mb_ereg_search_setpos',
'mb_ereg_search',
'mb_ereg',
'mb_eregi_replace',
'mb_eregi',
'mb_get_info',
'mb_http_input',
'mb_http_output',
'mb_internal_encoding',
'mb_language',
'mb_list_encodings',
'mb_output_handler',
'mb_parse_str',
'mb_preferred_mime_name',
'mb_regex_encoding',
'mb_regex_set_options',
'mb_send_mail',
'mb_split',
'mb_strcut',
'mb_strimwidth',
'mb_stripos',
'mb_stristr',
'mb_strlen',
'mb_strpos',
'mb_strrchr',
'mb_strrichr',
'mb_strripos',
'mb_strrpos',
'mb_strstr',
'mb_strtolower',
'mb_strtoupper',
'mb_strwidth',
'mb_substitute_character',
'mb_substr_count',
'mb_substr'],
'MySQL': ['mysql_affected_rows',
'mysql_client_encoding',
'mysql_close',
'mysql_connect',
'mysql_create_db',
'mysql_data_seek',
'mysql_db_name',
'mysql_db_query',
'mysql_drop_db',
'mysql_errno',
'mysql_error',
'mysql_escape_string',
'mysql_fetch_array',
'mysql_fetch_assoc',
'mysql_fetch_field',
'mysql_fetch_lengths',
'mysql_fetch_object',
'mysql_fetch_row',
'mysql_field_flags',
'mysql_field_len',
'mysql_field_name',
'mysql_field_seek',
'mysql_field_table',
'mysql_field_type',
'mysql_free_result',
'mysql_get_client_info',
'mysql_get_host_info',
'mysql_get_proto_info',
'mysql_get_server_info',
'mysql_info',
'mysql_insert_id',
'mysql_list_dbs',
'mysql_list_fields',
'mysql_list_processes',
'mysql_list_tables',
'mysql_num_fields',
'mysql_num_rows',
'mysql_pconnect',
'mysql_ping',
'mysql_query',
'mysql_real_escape_string',
'mysql_result',
'mysql_select_db',
'mysql_set_charset',
'mysql_stat',
'mysql_tablename',
'mysql_thread_id',
'mysql_unbuffered_query'],
'NSAPI': ['nsapi_request_headers', 'nsapi_response_headers', 'nsapi_virtual'],
'Ncurses': ['ncurses_addch',
'ncurses_addchnstr',
'ncurses_addchstr',
'ncurses_addnstr',
'ncurses_addstr',
'ncurses_assume_default_colors',
'ncurses_attroff',
'ncurses_attron',
'ncurses_attrset',
'ncurses_baudrate',
'ncurses_beep',
'ncurses_bkgd',
'ncurses_bkgdset',
'ncurses_border',
'ncurses_bottom_panel',
'ncurses_can_change_color',
'ncurses_cbreak',
'ncurses_clear',
'ncurses_clrtobot',
'ncurses_clrtoeol',
'ncurses_color_content',
'ncurses_color_set',
'ncurses_curs_set',
'ncurses_def_prog_mode',
'ncurses_def_shell_mode',
'ncurses_define_key',
'ncurses_del_panel',
'ncurses_delay_output',
'ncurses_delch',
'ncurses_deleteln',
'ncurses_delwin',
'ncurses_doupdate',
'ncurses_echo',
'ncurses_echochar',
'ncurses_end',
'ncurses_erase',
'ncurses_erasechar',
'ncurses_filter',
'ncurses_flash',
'ncurses_flushinp',
'ncurses_getch',
'ncurses_getmaxyx',
'ncurses_getmouse',
'ncurses_getyx',
'ncurses_halfdelay',
'ncurses_has_colors',
'ncurses_has_ic',
'ncurses_has_il',
'ncurses_has_key',
'ncurses_hide_panel',
'ncurses_hline',
'ncurses_inch',
'ncurses_init_color',
'ncurses_init_pair',
'ncurses_init',
'ncurses_insch',
'ncurses_insdelln',
'ncurses_insertln',
'ncurses_insstr',
'ncurses_instr',
'ncurses_isendwin',
'ncurses_keyok',
'ncurses_keypad',
'ncurses_killchar',
'ncurses_longname',
'ncurses_meta',
'ncurses_mouse_trafo',
'ncurses_mouseinterval',
'ncurses_mousemask',
'ncurses_move_panel',
'ncurses_move',
'ncurses_mvaddch',
'ncurses_mvaddchnstr',
'ncurses_mvaddchstr',
'ncurses_mvaddnstr',
'ncurses_mvaddstr',
'ncurses_mvcur',
'ncurses_mvdelch',
'ncurses_mvgetch',
'ncurses_mvhline',
'ncurses_mvinch',
'ncurses_mvvline',
'ncurses_mvwaddstr',
'ncurses_napms',
'ncurses_new_panel',
'ncurses_newpad',
'ncurses_newwin',
'ncurses_nl',
'ncurses_nocbreak',
'ncurses_noecho',
'ncurses_nonl',
'ncurses_noqiflush',
'ncurses_noraw',
'ncurses_pair_content',
'ncurses_panel_above',
'ncurses_panel_below',
'ncurses_panel_window',
'ncurses_pnoutrefresh',
'ncurses_prefresh',
'ncurses_putp',
'ncurses_qiflush',
'ncurses_raw',
'ncurses_refresh',
'ncurses_replace_panel',
'ncurses_reset_prog_mode',
'ncurses_reset_shell_mode',
'ncurses_resetty',
'ncurses_savetty',
'ncurses_scr_dump',
'ncurses_scr_init',
'ncurses_scr_restore',
'ncurses_scr_set',
'ncurses_scrl',
'ncurses_show_panel',
'ncurses_slk_attr',
'ncurses_slk_attroff',
'ncurses_slk_attron',
'ncurses_slk_attrset',
'ncurses_slk_clear',
'ncurses_slk_color',
'ncurses_slk_init',
'ncurses_slk_noutrefresh',
'ncurses_slk_refresh',
'ncurses_slk_restore',
'ncurses_slk_set',
'ncurses_slk_touch',
'ncurses_standend',
'ncurses_standout',
'ncurses_start_color',
'ncurses_termattrs',
'ncurses_termname',
'ncurses_timeout',
'ncurses_top_panel',
'ncurses_typeahead',
'ncurses_ungetch',
'ncurses_ungetmouse',
'ncurses_update_panels',
'ncurses_use_default_colors',
'ncurses_use_env',
'ncurses_use_extended_names',
'ncurses_vidattr',
'ncurses_vline',
'ncurses_waddch',
'ncurses_waddstr',
'ncurses_wattroff',
'ncurses_wattron',
'ncurses_wattrset',
'ncurses_wborder',
'ncurses_wclear',
'ncurses_wcolor_set',
'ncurses_werase',
'ncurses_wgetch',
'ncurses_whline',
'ncurses_wmouse_trafo',
'ncurses_wmove',
'ncurses_wnoutrefresh',
'ncurses_wrefresh',
'ncurses_wstandend',
'ncurses_wstandout',
'ncurses_wvline'],
'Network': ['checkdnsrr',
'closelog',
'define_syslog_variables',
'dns_check_record',
'dns_get_mx',
'dns_get_record',
'fsockopen',
'gethostbyaddr',
'gethostbyname',
'gethostbynamel'],
'Newt': ['newt_bell',
'newt_button_bar',
'newt_button',
'newt_centered_window',
'newt_checkbox_get_value',
'newt_checkbox_set_flags',
'newt_checkbox_set_value',
'newt_checkbox_tree_add_item',
'newt_checkbox_tree_find_item',
'newt_checkbox_tree_get_current',
'newt_checkbox_tree_get_entry_value',
'newt_checkbox_tree_get_multi_selection',
'newt_checkbox_tree_get_selection',
'newt_checkbox_tree_multi',
'newt_checkbox_tree_set_current',
'newt_checkbox_tree_set_entry_value',
'newt_checkbox_tree_set_entry',
'newt_checkbox_tree_set_width',
'newt_checkbox_tree',
'newt_checkbox',
'newt_clear_key_buffer'],
'OAuth': ['oauth_get_sbs', 'oauth_urlencode'],
'OCI8': ['oci_bind_array_by_name',
'oci_bind_by_name',
'oci_cancel',
'oci_close',
'oci_commit',
'oci_connect',
'oci_define_by_name',
'oci_error',
'oci_execute',
'oci_fetch_all',
'oci_fetch_array',
'oci_fetch_assoc',
'oci_fetch_object',
'oci_fetch_row',
'oci_fetch',
'oci_field_is_null',
'oci_field_name',
'oci_field_precision',
'oci_field_scale',
'oci_field_size',
'oci_field_type_raw',
'oci_field_type',
'oci_free_statement',
'oci_internal_debug',
'oci_lob_copy',
'oci_lob_is_equal',
'oci_new_collection',
'oci_new_connect',
'oci_new_cursor',
'oci_new_descriptor',
'oci_num_fields',
'oci_num_rows',
'oci_parse',
'oci_password_change',
'oci_pconnect',
'oci_result',
'oci_rollback',
'oci_server_version',
'oci_set_action',
'oci_set_client_identifier',
'oci_set_client_info',
'oci_set_edition',
'oci_set_module_name',
'oci_set_prefetch',
'oci_statement_type'],
'ODBC': ['odbc_autocommit',
'odbc_binmode',
'odbc_close_all',
'odbc_close',
'odbc_columnprivileges',
'odbc_columns',
'odbc_commit',
'odbc_connect',
'odbc_cursor',
'odbc_data_source',
'odbc_do',
'odbc_error',
'odbc_errormsg',
'odbc_exec',
'odbc_execute',
'odbc_fetch_array',
'odbc_fetch_into',
'odbc_fetch_object',
'odbc_fetch_row',
'odbc_field_len',
'odbc_field_name',
'odbc_field_num',
'odbc_field_precision',
'odbc_field_scale',
'odbc_field_type',
'odbc_foreignkeys',
'odbc_free_result',
'odbc_gettypeinfo',
'odbc_longreadlen',
'odbc_next_result',
'odbc_num_fields',
'odbc_num_rows',
'odbc_pconnect',
'odbc_prepare',
'odbc_primarykeys',
'odbc_procedurecolumns',
'odbc_procedures',
'odbc_result_all',
'odbc_result',
'odbc_rollback',
'odbc_setoption',
'odbc_specialcolumns',
'odbc_statistics',
'odbc_tableprivileges',
'odbc_tables'],
'Object Aggregation': ['aggregate_info',
'aggregate_methods_by_list',
'aggregate_methods_by_regexp'],
'Object overloading': ['overload'],
'OpenAL': ['openal_buffer_create',
'openal_buffer_data',
'openal_buffer_destroy',
'openal_buffer_get',
'openal_buffer_loadwav',
'openal_context_create',
'openal_context_current',
'openal_context_destroy',
'openal_context_process',
'openal_context_suspend',
'openal_device_close',
'openal_device_open',
'openal_listener_get',
'openal_listener_set',
'openal_source_create',
'openal_source_destroy',
'openal_source_get',
'openal_source_pause',
'openal_source_play',
'openal_source_rewind',
'openal_source_set',
'openal_source_stop',
'openal_stream'],
'OpenSSL': ['openssl_csr_export_to_file',
'openssl_csr_export',
'openssl_csr_get_public_key',
'openssl_csr_get_subject',
'openssl_csr_new',
'openssl_csr_sign',
'openssl_decrypt',
'openssl_dh_compute_key',
'openssl_digest',
'openssl_encrypt',
'openssl_error_string',
'openssl_free_key',
'openssl_get_cipher_methods',
'openssl_get_md_methods',
'openssl_get_privatekey',
'openssl_get_publickey',
'openssl_open',
'openssl_pkcs12_export_to_file',
'openssl_pkcs12_export',
'openssl_pkcs12_read',
'openssl_pkcs7_decrypt',
'openssl_pkcs7_encrypt',
'openssl_pkcs7_sign',
'openssl_pkcs7_verify',
'openssl_pkey_export_to_file',
'openssl_pkey_export',
'openssl_pkey_free',
'openssl_pkey_get_details',
'openssl_pkey_get_private',
'openssl_pkey_get_public',
'openssl_pkey_new',
'openssl_private_decrypt',
'openssl_private_encrypt',
'openssl_public_decrypt',
'openssl_public_encrypt',
'openssl_random_pseudo_bytes',
'openssl_seal',
'openssl_sign',
'openssl_verify',
'openssl_x509_check_private_key',
'openssl_x509_checkpurpose',
'openssl_x509_export_to_file',
'openssl_x509_export',
'openssl_x509_free',
'openssl_x509_parse',
'openssl_x509_read'],
'Output Control': ['flush',
'ob_clean',
'ob_end_clean',
'ob_end_flush',
'ob_flush',
'ob_get_clean',
'ob_get_contents',
'ob_get_flush',
'ob_get_length',
'ob_get_level',
'ob_get_status',
'ob_gzhandler',
'ob_implicit_flush',
'ob_list_handlers',
'ob_start',
'output_add_rewrite_var',
'output_reset_rewrite_vars'],
'Ovrimos SQL': ['ovrimos_close',
'ovrimos_commit',
'ovrimos_connect',
'ovrimos_cursor',
'ovrimos_exec',
'ovrimos_execute',
'ovrimos_fetch_into',
'ovrimos_fetch_row',
'ovrimos_field_len',
'ovrimos_field_name',
'ovrimos_field_num',
'ovrimos_field_type',
'ovrimos_free_result',
'ovrimos_longreadlen',
'ovrimos_num_fields',
'ovrimos_num_rows',
'ovrimos_prepare',
'ovrimos_result_all',
'ovrimos_result',
'ovrimos_rollback'],
'PCNTL': ['pcntl_alarm',
'pcntl_exec',
'pcntl_fork',
'pcntl_getpriority',
'pcntl_setpriority',
'pcntl_signal_dispatch',
'pcntl_signal',
'pcntl_sigprocmask',
'pcntl_sigtimedwait',
'pcntl_sigwaitinfo',
'pcntl_wait',
'pcntl_waitpid',
'pcntl_wexitstatus',
'pcntl_wifexited',
'pcntl_wifsignaled',
'pcntl_wifstopped',
'pcntl_wstopsig',
'pcntl_wtermsig'],
'PCRE': ['preg_filter',
'preg_grep',
'preg_last_error',
'preg_match_all',
'preg_match',
'preg_quote',
'preg_replace_callback',
'preg_replace',
'preg_split'],
'PDF': ['PDF_activate_item',
'PDF_add_annotation',
'PDF_add_bookmark',
'PDF_add_launchlink',
'PDF_add_locallink',
'PDF_add_nameddest',
'PDF_add_note',
'PDF_add_outline',
'PDF_add_pdflink',
'PDF_add_table_cell',
'PDF_add_textflow',
'PDF_add_thumbnail',
'PDF_add_weblink',
'PDF_arc',
'PDF_arcn',
'PDF_attach_file',
'PDF_begin_document',
'PDF_begin_font',
'PDF_begin_glyph',
'PDF_begin_item',
'PDF_begin_layer',
'PDF_begin_page_ext',
'PDF_begin_page',
'PDF_begin_pattern',
'PDF_begin_template_ext',
'PDF_begin_template',
'PDF_circle',
'PDF_clip',
'PDF_close_image',
'PDF_close_pdi_page',
'PDF_close_pdi',
'PDF_close',
'PDF_closepath_fill_stroke',
'PDF_closepath_stroke',
'PDF_closepath',
'PDF_concat',
'PDF_continue_text',
'PDF_create_3dview',
'PDF_create_action',
'PDF_create_annotation',
'PDF_create_bookmark',
'PDF_create_field',
'PDF_create_fieldgroup',
'PDF_create_gstate',
'PDF_create_pvf',
'PDF_create_textflow',
'PDF_curveto',
'PDF_define_layer',
'PDF_delete_pvf',
'PDF_delete_table',
'PDF_delete_textflow',
'PDF_delete',
'PDF_encoding_set_char',
'PDF_end_document',
'PDF_end_font',
'PDF_end_glyph',
'PDF_end_item',
'PDF_end_layer',
'PDF_end_page_ext',
'PDF_end_page',
'PDF_end_pattern',
'PDF_end_template',
'PDF_endpath',
'PDF_fill_imageblock',
'PDF_fill_pdfblock',
'PDF_fill_stroke',
'PDF_fill_textblock',
'PDF_fill',
'PDF_findfont',
'PDF_fit_image',
'PDF_fit_pdi_page',
'PDF_fit_table',
'PDF_fit_textflow',
'PDF_fit_textline',
'PDF_get_apiname',
'PDF_get_buffer',
'PDF_get_errmsg',
'PDF_get_errnum',
'PDF_get_font',
'PDF_get_fontname',
'PDF_get_fontsize',
'PDF_get_image_height',
'PDF_get_image_width',
'PDF_get_majorversion',
'PDF_get_minorversion',
'PDF_get_parameter',
'PDF_get_pdi_parameter',
'PDF_get_pdi_value',
'PDF_get_value',
'PDF_info_font',
'PDF_info_matchbox',
'PDF_info_table',
'PDF_info_textflow',
'PDF_info_textline',
'PDF_initgraphics',
'PDF_lineto',
'PDF_load_3ddata',
'PDF_load_font',
'PDF_load_iccprofile',
'PDF_load_image',
'PDF_makespotcolor',
'PDF_moveto',
'PDF_new',
'PDF_open_ccitt',
'PDF_open_file',
'PDF_open_gif',
'PDF_open_image_file',
'PDF_open_image',
'PDF_open_jpeg',
'PDF_open_memory_image',
'PDF_open_pdi_document',
'PDF_open_pdi_page',
'PDF_open_pdi',
'PDF_open_tiff',
'PDF_pcos_get_number',
'PDF_pcos_get_stream',
'PDF_pcos_get_string',
'PDF_place_image',
'PDF_place_pdi_page',
'PDF_process_pdi',
'PDF_rect',
'PDF_restore',
'PDF_resume_page',
'PDF_rotate',
'PDF_save',
'PDF_scale',
'PDF_set_border_color',
'PDF_set_border_dash',
'PDF_set_border_style',
'PDF_set_char_spacing',
'PDF_set_duration',
'PDF_set_gstate',
'PDF_set_horiz_scaling',
'PDF_set_info_author',
'PDF_set_info_creator',
'PDF_set_info_keywords',
'PDF_set_info_subject',
'PDF_set_info_title',
'PDF_set_info',
'PDF_set_layer_dependency',
'PDF_set_leading',
'PDF_set_parameter',
'PDF_set_text_matrix',
'PDF_set_text_pos',
'PDF_set_text_rendering',
'PDF_set_text_rise',
'PDF_set_value',
'PDF_set_word_spacing',
'PDF_setcolor',
'PDF_setdash',
'PDF_setdashpattern',
'PDF_setflat',
'PDF_setfont',
'PDF_setgray_fill',
'PDF_setgray_stroke',
'PDF_setgray',
'PDF_setlinecap',
'PDF_setlinejoin',
'PDF_setlinewidth',
'PDF_setmatrix',
'PDF_setmiterlimit',
'PDF_setpolydash',
'PDF_setrgbcolor_fill',
'PDF_setrgbcolor_stroke',
'PDF_setrgbcolor',
'PDF_shading_pattern',
'PDF_shading',
'PDF_shfill',
'PDF_show_boxed',
'PDF_show_xy',
'PDF_show',
'PDF_skew',
'PDF_stringwidth',
'PDF_stroke',
'PDF_suspend_page',
'PDF_translate',
'PDF_utf16_to_utf8',
'PDF_utf32_to_utf16',
'PDF_utf8_to_utf16'],
'PHP Options/Info': ['assert_options',
'assert',
'dl',
'extension_loaded',
'gc_collect_cycles',
'gc_disable',
'gc_enable',
'gc_enabled',
'get_cfg_var',
'get_current_user',
'get_defined_constants',
'get_extension_funcs',
'get_include_path',
'get_included_files',
'get_loaded_extensions',
'get_magic_quotes_gpc',
'get_magic_quotes_runtime',
'get_required_files',
'getenv',
'getlastmod',
'getmygid',
'getmyinode',
'getmypid',
'getmyuid',
'getopt',
'getrusage',
'ini_alter',
'ini_get_all',
'ini_get',
'ini_restore',
'ini_set',
'magic_quotes_runtime',
'memory_get_peak_usage',
'memory_get_usage',
'php_ini_loaded_file',
'php_ini_scanned_files',
'php_logo_guid',
'php_sapi_name',
'php_uname',
'phpcredits',
'phpinfo',
'phpversion',
'putenv',
'restore_include_path',
'set_include_path',
'set_magic_quotes_runtime',
'set_time_limit',
'sys_get_temp_dir',
'version_compare',
'zend_logo_guid',
'zend_thread_id',
'zend_version'],
'POSIX': ['posix_access',
'posix_ctermid',
'posix_errno',
'posix_get_last_error',
'posix_getcwd',
'posix_getegid',
'posix_geteuid',
'posix_getgid',
'posix_getgrgid',
'posix_getgrnam',
'posix_getgroups',
'posix_getlogin',
'posix_getpgid',
'posix_getpgrp',
'posix_getpid',
'posix_getppid',
'posix_getpwnam',
'posix_getpwuid',
'posix_getrlimit',
'posix_getsid',
'posix_getuid',
'posix_initgroups',
'posix_isatty',
'posix_kill',
'posix_mkfifo',
'posix_mknod',
'posix_setegid',
'posix_seteuid',
'posix_setgid',
'posix_setpgid',
'posix_setsid',
'posix_setuid',
'posix_strerror',
'posix_times',
'posix_ttyname',
'posix_uname'],
'POSIX Regex': ['ereg_replace',
'ereg',
'eregi_replace',
'eregi',
'split',
'spliti',
'sql_regcase'],
'PS': ['ps_add_bookmark',
'ps_add_launchlink',
'ps_add_locallink',
'ps_add_note',
'ps_add_pdflink',
'ps_add_weblink',
'ps_arc',
'ps_arcn',
'ps_begin_page',
'ps_begin_pattern',
'ps_begin_template',
'ps_circle',
'ps_clip',
'ps_close_image',
'ps_close',
'ps_closepath_stroke',
'ps_closepath',
'ps_continue_text',
'ps_curveto',
'ps_delete',
'ps_end_page',
'ps_end_pattern',
'ps_end_template',
'ps_fill_stroke',
'ps_fill',
'ps_findfont',
'ps_get_buffer',
'ps_get_parameter',
'ps_get_value',
'ps_hyphenate',
'ps_include_file',
'ps_lineto',
'ps_makespotcolor',
'ps_moveto',
'ps_new',
'ps_open_file',
'ps_open_image_file',
'ps_open_image',
'ps_open_memory_image',
'ps_place_image',
'ps_rect',
'ps_restore',
'ps_rotate',
'ps_save',
'ps_scale',
'ps_set_border_color',
'ps_set_border_dash',
'ps_set_border_style',
'ps_set_info',
'ps_set_parameter',
'ps_set_text_pos',
'ps_set_value',
'ps_setcolor',
'ps_setdash',
'ps_setflat',
'ps_setfont',
'ps_setgray',
'ps_setlinecap',
'ps_setlinejoin',
'ps_setlinewidth',
'ps_setmiterlimit',
'ps_setoverprintmode',
'ps_setpolydash',
'ps_shading_pattern',
'ps_shading',
'ps_shfill',
'ps_show_boxed',
'ps_show_xy2',
'ps_show_xy',
'ps_show2',
'ps_show',
'ps_string_geometry',
'ps_stringwidth',
'ps_stroke',
'ps_symbol_name',
'ps_symbol_width',
'ps_symbol',
'ps_translate'],
'Paradox': ['px_close',
'px_create_fp',
'px_date2string',
'px_delete_record',
'px_delete',
'px_get_field',
'px_get_info',
'px_get_parameter',
'px_get_record',
'px_get_schema',
'px_get_value',
'px_insert_record',
'px_new',
'px_numfields',
'px_numrecords',
'px_open_fp',
'px_put_record',
'px_retrieve_record',
'px_set_blob_file',
'px_set_parameter',
'px_set_tablename',
'px_set_targetencoding',
'px_set_value',
'px_timestamp2string',
'px_update_record'],
'Parsekit': ['parsekit_compile_file',
'parsekit_compile_string',
'parsekit_func_arginfo'],
'PostgreSQL': ['pg_affected_rows',
'pg_cancel_query',
'pg_client_encoding',
'pg_close',
'pg_connect',
'pg_connection_busy',
'pg_connection_reset',
'pg_connection_status',
'pg_convert',
'pg_copy_from',
'pg_copy_to',
'pg_dbname',
'pg_delete',
'pg_end_copy',
'pg_escape_bytea',
'pg_escape_string',
'pg_execute',
'pg_fetch_all_columns',
'pg_fetch_all',
'pg_fetch_array',
'pg_fetch_assoc',
'pg_fetch_object',
'pg_fetch_result',
'pg_fetch_row',
'pg_field_is_null',
'pg_field_name',
'pg_field_num',
'pg_field_prtlen',
'pg_field_size',
'pg_field_table',
'pg_field_type_oid',
'pg_field_type',
'pg_free_result',
'pg_get_notify',
'pg_get_pid',
'pg_get_result',
'pg_host',
'pg_insert',
'pg_last_error',
'pg_last_notice',
'pg_last_oid',
'pg_lo_close',
'pg_lo_create',
'pg_lo_export',
'pg_lo_import',
'pg_lo_open',
'pg_lo_read_all',
'pg_lo_read',
'pg_lo_seek',
'pg_lo_tell',
'pg_lo_unlink',
'pg_lo_write',
'pg_meta_data',
'pg_num_fields',
'pg_num_rows',
'pg_options',
'pg_parameter_status',
'pg_pconnect',
'pg_ping',
'pg_port',
'pg_prepare'],
'Printer': ['printer_abort',
'printer_close',
'printer_create_brush',
'printer_create_dc',
'printer_create_font',
'printer_create_pen',
'printer_delete_brush',
'printer_delete_dc',
'printer_delete_font',
'printer_delete_pen',
'printer_draw_bmp',
'printer_draw_chord',
'printer_draw_elipse',
'printer_draw_line',
'printer_draw_pie',
'printer_draw_rectangle',
'printer_draw_roundrect',
'printer_draw_text',
'printer_end_doc',
'printer_end_page',
'printer_get_option',
'printer_list',
'printer_logical_fontheight',
'printer_open',
'printer_select_brush',
'printer_select_font',
'printer_select_pen',
'printer_set_option',
'printer_start_doc',
'printer_start_page',
'printer_write'],
'Program execution': ['escapeshellarg',
'escapeshellcmd',
'exec',
'passthru',
'proc_close',
'proc_get_status',
'proc_nice',
'proc_open',
'proc_terminate',
'shell_exec',
'system'],
'Pspell': ['pspell_add_to_personal',
'pspell_add_to_session',
'pspell_check',
'pspell_clear_session',
'pspell_config_create',
'pspell_config_data_dir',
'pspell_config_dict_dir',
'pspell_config_ignore',
'pspell_config_mode',
'pspell_config_personal',
'pspell_config_repl',
'pspell_config_runtogether',
'pspell_config_save_repl'],
'RPM Reader': ['rpm_close',
'rpm_get_tag',
'rpm_is_valid',
'rpm_open',
'rpm_version'],
'RRD': ['rrd_create',
'rrd_error',
'rrd_fetch',
'rrd_first',
'rrd_graph',
'rrd_info',
'rrd_last',
'rrd_lastupdate',
'rrd_restore',
'rrd_tune',
'rrd_update',
'rrd_xport'],
'Radius': ['radius_acct_open',
'radius_add_server',
'radius_auth_open',
'radius_close',
'radius_config',
'radius_create_request',
'radius_cvt_addr',
'radius_cvt_int',
'radius_cvt_string',
'radius_demangle_mppe_key',
'radius_demangle',
'radius_get_attr',
'radius_get_vendor_attr',
'radius_put_addr',
'radius_put_attr',
'radius_put_int',
'radius_put_string',
'radius_put_vendor_addr',
'radius_put_vendor_attr',
'radius_put_vendor_int',
'radius_put_vendor_string',
'radius_request_authenticator',
'radius_send_request',
'radius_server_secret',
'radius_strerror'],
'Rar': ['rar_wrapper_cache_stats'],
'Readline': ['readline_add_history',
'readline_callback_handler_install',
'readline_callback_handler_remove',
'readline_callback_read_char',
'readline_clear_history',
'readline_completion_function',
'readline_info',
'readline_list_history',
'readline_on_new_line',
'readline_read_history',
'readline_redisplay',
'readline_write_history',
'readline'],
'Recode': ['recode_file', 'recode_string', 'recode'],
'SNMP': ['snmp_get_quick_print',
'snmp_get_valueretrieval',
'snmp_read_mib',
'snmp_set_enum_print',
'snmp_set_oid_numeric_print',
'snmp_set_oid_output_format',
'snmp_set_quick_print',
'snmp_set_valueretrieval',
'snmp2_get',
'snmp2_getnext',
'snmp2_real_walk',
'snmp2_set',
'snmp2_walk',
'snmp3_get',
'snmp3_getnext',
'snmp3_real_walk',
'snmp3_set',
'snmp3_walk',
'snmpget',
'snmpgetnext',
'snmprealwalk',
'snmpset',
'snmpwalk',
'snmpwalkoid'],
'SOAP': ['is_soap_fault', 'use_soap_error_handler'],
'SPL': ['class_implements',
'class_parents',
'iterator_apply',
'iterator_count',
'iterator_to_array',
'spl_autoload_call',
'spl_autoload_extensions',
'spl_autoload_functions',
'spl_autoload_register',
'spl_autoload_unregister',
'spl_autoload',
'spl_classes',
'spl_object_hash'],
'SPPLUS': ['calcul_hmac', 'calculhmac', 'nthmac', 'signeurlpaiement'],
'SQLite': ['sqlite_array_query', 'sqlite_busy_timeout', 'sqlite_changes'],
'SSH2': ['ssh2_auth_hostbased_file',
'ssh2_auth_none',
'ssh2_auth_password',
'ssh2_auth_pubkey_file',
'ssh2_connect',
'ssh2_exec',
'ssh2_fetch_stream',
'ssh2_fingerprint',
'ssh2_methods_negotiated',
'ssh2_publickey_add',
'ssh2_publickey_init',
'ssh2_publickey_list',
'ssh2_publickey_remove',
'ssh2_scp_recv',
'ssh2_scp_send',
'ssh2_sftp_lstat',
'ssh2_sftp_mkdir',
'ssh2_sftp_readlink',
'ssh2_sftp_realpath',
'ssh2_sftp_rename',
'ssh2_sftp_rmdir',
'ssh2_sftp_stat',
'ssh2_sftp_symlink',
'ssh2_sftp_unlink',
'ssh2_sftp',
'ssh2_shell',
'ssh2_tunnel'],
'SVN': ['svn_add',
'svn_auth_get_parameter',
'svn_auth_set_parameter',
'svn_blame',
'svn_cat',
'svn_checkout',
'svn_cleanup',
'svn_client_version',
'svn_commit',
'svn_delete',
'svn_diff',
'svn_export',
'svn_fs_abort_txn',
'svn_fs_apply_text',
'svn_fs_begin_txn2',
'svn_fs_change_node_prop',
'svn_fs_check_path',
'svn_fs_contents_changed',
'svn_fs_copy',
'svn_fs_delete',
'svn_fs_dir_entries',
'svn_fs_file_contents',
'svn_fs_file_length',
'svn_fs_is_dir',
'svn_fs_is_file',
'svn_fs_make_dir',
'svn_fs_make_file',
'svn_fs_node_created_rev',
'svn_fs_node_prop',
'svn_fs_props_changed',
'svn_fs_revision_prop',
'svn_fs_revision_root',
'svn_fs_txn_root',
'svn_fs_youngest_rev',
'svn_import',
'svn_log',
'svn_ls',
'svn_mkdir',
'svn_repos_create',
'svn_repos_fs_begin_txn_for_commit',
'svn_repos_fs_commit_txn',
'svn_repos_fs',
'svn_repos_hotcopy',
'svn_repos_open',
'svn_repos_recover',
'svn_revert',
'svn_status',
'svn_update'],
'SWF': ['swf_actiongeturl',
'swf_actiongotoframe',
'swf_actiongotolabel',
'swf_actionnextframe',
'swf_actionplay',
'swf_actionprevframe',
'swf_actionsettarget',
'swf_actionstop',
'swf_actiontogglequality',
'swf_actionwaitforframe',
'swf_addbuttonrecord',
'swf_addcolor',
'swf_closefile',
'swf_definebitmap',
'swf_definefont',
'swf_defineline',
'swf_definepoly',
'swf_definerect',
'swf_definetext',
'swf_endbutton',
'swf_enddoaction',
'swf_endshape',
'swf_endsymbol',
'swf_fontsize',
'swf_fontslant',
'swf_fonttracking',
'swf_getbitmapinfo',
'swf_getfontinfo',
'swf_getframe',
'swf_labelframe',
'swf_lookat',
'swf_modifyobject',
'swf_mulcolor',
'swf_nextid',
'swf_oncondition',
'swf_openfile',
'swf_ortho2',
'swf_ortho',
'swf_perspective',
'swf_placeobject',
'swf_polarview',
'swf_popmatrix',
'swf_posround',
'swf_pushmatrix',
'swf_removeobject',
'swf_rotate',
'swf_scale',
'swf_setfont',
'swf_setframe',
'swf_shapearc',
'swf_shapecurveto3',
'swf_shapecurveto',
'swf_shapefillbitmapclip',
'swf_shapefillbitmaptile',
'swf_shapefilloff',
'swf_shapefillsolid',
'swf_shapelinesolid',
'swf_shapelineto',
'swf_shapemoveto',
'swf_showframe',
'swf_startbutton',
'swf_startdoaction',
'swf_startshape',
'swf_startsymbol',
'swf_textwidth',
'swf_translate',
'swf_viewport'],
'Semaphore': ['ftok',
'msg_get_queue',
'msg_queue_exists',
'msg_receive',
'msg_remove_queue',
'msg_send',
'msg_set_queue',
'msg_stat_queue',
'sem_acquire',
'sem_get',
'sem_release',
'sem_remove',
'shm_attach',
'shm_detach',
'shm_get_var',
'shm_has_var',
'shm_put_var',
'shm_remove_var',
'shm_remove'],
'Session': ['session_cache_expire',
'session_cache_limiter',
'session_commit',
'session_decode',
'session_destroy',
'session_encode',
'session_get_cookie_params',
'session_id',
'session_is_registered',
'session_module_name',
'session_name',
'session_regenerate_id',
'session_register',
'session_save_path',
'session_set_cookie_params',
'session_set_save_handler',
'session_start',
'session_unregister',
'session_unset',
'session_write_close'],
'Session PgSQL': ['session_pgsql_add_error',
'session_pgsql_get_error',
'session_pgsql_get_field',
'session_pgsql_reset',
'session_pgsql_set_field',
'session_pgsql_status'],
'Shared Memory': ['shmop_close',
'shmop_delete',
'shmop_open',
'shmop_read',
'shmop_size',
'shmop_write'],
'SimpleXML': ['simplexml_import_dom',
'simplexml_load_file',
'simplexml_load_string'],
'Socket': ['socket_accept',
'socket_bind',
'socket_clear_error',
'socket_close',
'socket_connect',
'socket_create_listen',
'socket_create_pair',
'socket_create',
'socket_get_option',
'socket_getpeername',
'socket_getsockname',
'socket_last_error',
'socket_listen',
'socket_read',
'socket_recv',
'socket_recvfrom',
'socket_select',
'socket_send',
'socket_sendto',
'socket_set_block',
'socket_set_nonblock',
'socket_set_option',
'socket_shutdown',
'socket_strerror',
'socket_write'],
'Solr': ['solr_get_version'],
'Statistic': ['stats_absolute_deviation',
'stats_cdf_beta',
'stats_cdf_binomial',
'stats_cdf_cauchy',
'stats_cdf_chisquare',
'stats_cdf_exponential',
'stats_cdf_f',
'stats_cdf_gamma',
'stats_cdf_laplace',
'stats_cdf_logistic',
'stats_cdf_negative_binomial',
'stats_cdf_noncentral_chisquare',
'stats_cdf_noncentral_f',
'stats_cdf_poisson',
'stats_cdf_t',
'stats_cdf_uniform',
'stats_cdf_weibull',
'stats_covariance',
'stats_den_uniform',
'stats_dens_beta',
'stats_dens_cauchy',
'stats_dens_chisquare',
'stats_dens_exponential',
'stats_dens_f',
'stats_dens_gamma',
'stats_dens_laplace',
'stats_dens_logistic',
'stats_dens_negative_binomial',
'stats_dens_normal',
'stats_dens_pmf_binomial',
'stats_dens_pmf_hypergeometric',
'stats_dens_pmf_poisson',
'stats_dens_t',
'stats_dens_weibull',
'stats_harmonic_mean',
'stats_kurtosis',
'stats_rand_gen_beta',
'stats_rand_gen_chisquare',
'stats_rand_gen_exponential',
'stats_rand_gen_f',
'stats_rand_gen_funiform',
'stats_rand_gen_gamma',
'stats_rand_gen_ibinomial_negative',
'stats_rand_gen_ibinomial',
'stats_rand_gen_int',
'stats_rand_gen_ipoisson',
'stats_rand_gen_iuniform',
'stats_rand_gen_noncenral_chisquare',
'stats_rand_gen_noncentral_f',
'stats_rand_gen_noncentral_t',
'stats_rand_gen_normal',
'stats_rand_gen_t',
'stats_rand_get_seeds',
'stats_rand_phrase_to_seeds',
'stats_rand_ranf',
'stats_rand_setall',
'stats_skew',
'stats_standard_deviation',
'stats_stat_binomial_coef',
'stats_stat_correlation',
'stats_stat_gennch',
'stats_stat_independent_t',
'stats_stat_innerproduct',
'stats_stat_noncentral_t',
'stats_stat_paired_t',
'stats_stat_percentile',
'stats_stat_powersum',
'stats_variance'],
'Stomp': ['stomp_connect_error', 'stomp_version'],
'Stream': ['set_socket_blocking',
'stream_bucket_append',
'stream_bucket_make_writeable',
'stream_bucket_new',
'stream_bucket_prepend',
'stream_context_create',
'stream_context_get_default',
'stream_context_get_options',
'stream_context_get_params',
'stream_context_set_default',
'stream_context_set_option',
'stream_context_set_params',
'stream_copy_to_stream',
'stream_encoding',
'stream_filter_append',
'stream_filter_prepend',
'stream_filter_register',
'stream_filter_remove',
'stream_get_contents',
'stream_get_filters',
'stream_get_line',
'stream_get_meta_data',
'stream_get_transports',
'stream_get_wrappers',
'stream_is_local',
'stream_notification_callback',
'stream_register_wrapper',
'stream_resolve_include_path',
'stream_select'],
'String': ['addcslashes',
'addslashes',
'bin2hex',
'chop',
'chr',
'chunk_split',
'convert_cyr_string',
'convert_uudecode',
'convert_uuencode',
'count_chars',
'crc32',
'crypt',
'echo',
'explode',
'fprintf',
'get_html_translation_table',
'hebrev',
'hebrevc',
'html_entity_decode',
'htmlentities',
'htmlspecialchars_decode',
'htmlspecialchars',
'implode',
'join',
'lcfirst',
'levenshtein',
'localeconv',
'ltrim',
'md5_file',
'md5',
'metaphone',
'money_format',
'nl_langinfo',
'nl2br',
'number_format',
'ord',
'parse_str',
'print',
'printf',
'quoted_printable_decode',
'quoted_printable_encode',
'quotemeta',
'rtrim',
'setlocale',
'sha1_file',
'sha1',
'similar_text',
'soundex',
'sprintf',
'sscanf',
'str_getcsv',
'str_ireplace',
'str_pad',
'str_repeat',
'str_replace',
'str_rot13',
'str_shuffle',
'str_split',
'str_word_count',
'strcasecmp',
'strchr',
'strcmp',
'strcoll',
'strcspn',
'strip_tags',
'stripcslashes',
'stripos',
'stripslashes',
'stristr',
'strlen',
'strnatcasecmp',
'strnatcmp',
'strncasecmp',
'strncmp',
'strpbrk',
'strpos',
'strrchr',
'strrev',
'strripos',
'strrpos',
'strspn'],
'Sybase': ['sybase_affected_rows',
'sybase_close',
'sybase_connect',
'sybase_data_seek',
'sybase_deadlock_retry_count',
'sybase_fetch_array',
'sybase_fetch_assoc',
'sybase_fetch_field',
'sybase_fetch_object',
'sybase_fetch_row',
'sybase_field_seek',
'sybase_free_result',
'sybase_get_last_message',
'sybase_min_client_severity',
'sybase_min_error_severity',
'sybase_min_message_severity',
'sybase_min_server_severity',
'sybase_num_fields',
'sybase_num_rows',
'sybase_pconnect',
'sybase_query',
'sybase_result',
'sybase_select_db',
'sybase_set_message_handler',
'sybase_unbuffered_query'],
'TCP': ['tcpwrap_check'],
'Tidy': ['ob_tidyhandler',
'tidy_access_count',
'tidy_config_count',
'tidy_error_count',
'tidy_get_error_buffer',
'tidy_get_output',
'tidy_load_config',
'tidy_reset_config',
'tidy_save_config',
'tidy_set_encoding',
'tidy_setopt',
'tidy_warning_count'],
'Tokenizer': ['token_get_all', 'token_name'],
'URL': ['base64_decode',
'base64_encode',
'get_headers',
'get_meta_tags',
'http_build_query',
'parse_url',
'rawurldecode',
'rawurlencode',
'urldecode',
'urlencode'],
'Variable handling': ['debug_zval_dump',
'doubleval',
'empty',
'floatval',
'get_defined_vars',
'get_resource_type',
'gettype',
'import_request_variables',
'intval',
'is_array',
'is_bool',
'is_callable',
'is_double',
'is_float',
'is_int',
'is_integer',
'is_long',
'is_null',
'is_numeric',
'is_object',
'is_real',
'is_resource',
'is_scalar',
'is_string',
'isset',
'print_r',
'serialize',
'settype',
'strval',
'unserialize',
'unset',
'var_dump',
'var_export'],
'W32api': ['w32api_deftype',
'w32api_init_dtype',
'w32api_invoke_function',
'w32api_register_function',
'w32api_set_call_method'],
'WDDX': ['wddx_add_vars',
'wddx_deserialize',
'wddx_packet_end',
'wddx_packet_start',
'wddx_serialize_value',
'wddx_serialize_vars',
'wddx_unserialize'],
'WinCache': ['wincache_fcache_fileinfo',
'wincache_fcache_meminfo',
'wincache_lock',
'wincache_ocache_fileinfo',
'wincache_ocache_meminfo',
'wincache_refresh_if_changed',
'wincache_rplist_fileinfo',
'wincache_rplist_meminfo',
'wincache_scache_info',
'wincache_scache_meminfo',
'wincache_ucache_add',
'wincache_ucache_cas',
'wincache_ucache_clear',
'wincache_ucache_dec',
'wincache_ucache_delete',
'wincache_ucache_exists',
'wincache_ucache_get',
'wincache_ucache_inc',
'wincache_ucache_info',
'wincache_ucache_meminfo',
'wincache_ucache_set',
'wincache_unlock'],
'XML Parser': ['utf8_decode'],
'XML-RPC': ['xmlrpc_decode_request',
'xmlrpc_decode',
'xmlrpc_encode_request',
'xmlrpc_encode',
'xmlrpc_get_type',
'xmlrpc_is_fault',
'xmlrpc_parse_method_descriptions',
'xmlrpc_server_add_introspection_data',
'xmlrpc_server_call_method',
'xmlrpc_server_create',
'xmlrpc_server_destroy',
'xmlrpc_server_register_introspection_callback',
'xmlrpc_server_register_method',
'xmlrpc_set_type'],
'XSLT (PHP4)': ['xslt_backend_info',
'xslt_backend_name',
'xslt_backend_version',
'xslt_create',
'xslt_errno',
'xslt_error',
'xslt_free',
'xslt_getopt',
'xslt_process',
'xslt_set_base',
'xslt_set_encoding',
'xslt_set_error_handler',
'xslt_set_log',
'xslt_set_object',
'xslt_set_sax_handler',
'xslt_set_sax_handlers',
'xslt_set_scheme_handler',
'xslt_set_scheme_handlers',
'xslt_setopt'],
'YAZ': ['yaz_addinfo',
'yaz_ccl_conf',
'yaz_ccl_parse',
'yaz_close',
'yaz_connect',
'yaz_database',
'yaz_element',
'yaz_errno',
'yaz_error',
'yaz_es_result',
'yaz_es',
'yaz_get_option',
'yaz_hits',
'yaz_itemorder',
'yaz_present',
'yaz_range',
'yaz_record',
'yaz_scan_result',
'yaz_scan',
'yaz_schema',
'yaz_search',
'yaz_set_option',
'yaz_sort',
'yaz_syntax',
'yaz_wait'],
'YP/NIS': ['yp_all',
'yp_cat',
'yp_err_string',
'yp_errno',
'yp_first',
'yp_get_default_domain',
'yp_master',
'yp_match',
'yp_next',
'yp_order'],
'Yaml': ['yaml_emit_file',
'yaml_emit',
'yaml_parse_file',
'yaml_parse_url',
'yaml_parse'],
'Zip': ['zip_close',
'zip_entry_close',
'zip_entry_compressedsize',
'zip_entry_compressionmethod',
'zip_entry_filesize',
'zip_entry_name',
'zip_entry_open',
'zip_entry_read',
'zip_open',
'zip_read'],
'Zlib': ['gzclose',
'gzcompress',
'gzdecode',
'gzdeflate',
'gzencode',
'gzeof',
'gzfile',
'gzgetc',
'gzgets',
'gzgetss',
'gzinflate',
'gzopen',
'gzpassthru',
'gzputs',
'gzread',
'gzrewind',
'gzseek',
'gztell',
'gzuncompress',
'gzwrite',
'readgzfile',
'zlib_get_coding_type'],
'bcompiler': ['bcompiler_load_exe',
'bcompiler_load',
'bcompiler_parse_class',
'bcompiler_read',
'bcompiler_write_class',
'bcompiler_write_constant',
'bcompiler_write_exe_footer',
'bcompiler_write_file',
'bcompiler_write_footer',
'bcompiler_write_function',
'bcompiler_write_functions_from_file',
'bcompiler_write_header',
'bcompiler_write_included_filename'],
'cURL': ['curl_close',
'curl_copy_handle',
'curl_errno',
'curl_error',
'curl_exec',
'curl_getinfo',
'curl_init',
'curl_multi_add_handle',
'curl_multi_close',
'curl_multi_exec',
'curl_multi_getcontent',
'curl_multi_info_read',
'curl_multi_init',
'curl_multi_remove_handle',
'curl_multi_select',
'curl_setopt_array',
'curl_setopt',
'curl_version'],
'chdb': ['chdb_create'],
'dBase': ['dbase_add_record',
'dbase_close',
'dbase_create',
'dbase_delete_record',
'dbase_get_header_info',
'dbase_get_record_with_names',
'dbase_get_record',
'dbase_numfields',
'dbase_numrecords',
'dbase_open',
'dbase_pack',
'dbase_replace_record'],
'dbx': ['dbx_close',
'dbx_compare',
'dbx_connect',
'dbx_error',
'dbx_escape_string',
'dbx_fetch_row'],
'filePro': ['filepro_fieldcount',
'filepro_fieldname',
'filepro_fieldtype',
'filepro_fieldwidth',
'filepro_retrieve',
'filepro_rowcount',
'filepro'],
'iconv': ['iconv_get_encoding',
'iconv_mime_decode_headers',
'iconv_mime_decode',
'iconv_mime_encode',
'iconv_set_encoding',
'iconv_strlen',
'iconv_strpos',
'iconv_strrpos',
'iconv_substr',
'iconv',
'ob_iconv_handler'],
'inclued': ['inclued_get_data'],
'intl': ['intl_error_name',
'intl_get_error_code',
'intl_get_error_message',
'intl_is_failure'],
'libxml': ['libxml_clear_errors',
'libxml_disable_entity_loader',
'libxml_get_errors',
'libxml_get_last_error',
'libxml_set_streams_context',
'libxml_use_internal_errors'],
'mSQL': ['msql_affected_rows',
'msql_close',
'msql_connect',
'msql_create_db',
'msql_createdb',
'msql_data_seek',
'msql_db_query',
'msql_dbname',
'msql_drop_db',
'msql_error',
'msql_fetch_array',
'msql_fetch_field',
'msql_fetch_object',
'msql_fetch_row',
'msql_field_flags',
'msql_field_len',
'msql_field_name',
'msql_field_seek',
'msql_field_table',
'msql_field_type',
'msql_fieldflags',
'msql_fieldlen',
'msql_fieldname',
'msql_fieldtable',
'msql_fieldtype',
'msql_free_result',
'msql_list_dbs',
'msql_list_fields',
'msql_list_tables',
'msql_num_fields',
'msql_num_rows',
'msql_numfields',
'msql_numrows',
'msql_pconnect',
'msql_query',
'msql_regcase',
'msql_result',
'msql_select_db',
'msql_tablename',
'msql'],
'mnoGoSearch': ['udm_add_search_limit',
'udm_alloc_agent_array',
'udm_alloc_agent',
'udm_api_version',
'udm_cat_list',
'udm_cat_path',
'udm_check_charset',
'udm_check_stored',
'udm_clear_search_limits',
'udm_close_stored',
'udm_crc32',
'udm_errno',
'udm_error',
'udm_find',
'udm_free_agent',
'udm_free_ispell_data',
'udm_free_res',
'udm_get_doc_count',
'udm_get_res_field',
'udm_get_res_param',
'udm_hash32',
'udm_load_ispell_data',
'udm_open_stored',
'udm_set_agent_param'],
'mqseries': ['mqseries_back',
'mqseries_begin',
'mqseries_close',
'mqseries_cmit',
'mqseries_conn',
'mqseries_connx',
'mqseries_disc',
'mqseries_get',
'mqseries_inq',
'mqseries_open',
'mqseries_put1',
'mqseries_put',
'mqseries_set',
'mqseries_strerror'],
'mysqlnd_qc': ['mysqlnd_qc_change_handler',
'mysqlnd_qc_clear_cache',
'mysqlnd_qc_get_cache_info',
'mysqlnd_qc_get_core_stats',
'mysqlnd_qc_get_handler',
'mysqlnd_qc_get_query_trace_log',
'mysqlnd_qc_set_user_handlers'],
'qtdom': ['qdom_error', 'qdom_tree'],
'runkit': ['runkit_class_adopt',
'runkit_class_emancipate',
'runkit_constant_add',
'runkit_constant_redefine',
'runkit_constant_remove',
'runkit_function_add',
'runkit_function_copy',
'runkit_function_redefine',
'runkit_function_remove',
'runkit_function_rename',
'runkit_import',
'runkit_lint_file',
'runkit_lint',
'runkit_method_add',
'runkit_method_copy',
'runkit_method_redefine',
'runkit_method_remove',
'runkit_method_rename',
'runkit_return_value_used',
'runkit_sandbox_output_handler',
'runkit_superglobals'],
'ssdeep': ['ssdeep_fuzzy_compare',
'ssdeep_fuzzy_hash_filename',
'ssdeep_fuzzy_hash'],
'vpopmail': ['vpopmail_add_alias_domain_ex',
'vpopmail_add_alias_domain',
'vpopmail_add_domain_ex',
'vpopmail_add_domain',
'vpopmail_add_user',
'vpopmail_alias_add',
'vpopmail_alias_del_domain',
'vpopmail_alias_del',
'vpopmail_alias_get_all',
'vpopmail_alias_get',
'vpopmail_auth_user',
'vpopmail_del_domain_ex',
'vpopmail_del_domain',
'vpopmail_del_user',
'vpopmail_error',
'vpopmail_passwd',
'vpopmail_set_user_quota'],
'win32ps': ['win32_ps_list_procs', 'win32_ps_stat_mem', 'win32_ps_stat_proc'],
'win32service': ['win32_continue_service',
'win32_create_service',
'win32_delete_service',
'win32_get_last_control_message',
'win32_pause_service',
'win32_query_service_status',
'win32_set_service_status',
'win32_start_service_ctrl_dispatcher',
'win32_start_service',
'win32_stop_service'],
'xattr': ['xattr_get',
'xattr_list',
'xattr_remove',
'xattr_set',
'xattr_supported'],
'xdiff': ['xdiff_file_bdiff_size',
'xdiff_file_bdiff',
'xdiff_file_bpatch',
'xdiff_file_diff_binary',
'xdiff_file_diff',
'xdiff_file_merge3',
'xdiff_file_patch_binary',
'xdiff_file_patch',
'xdiff_file_rabdiff',
'xdiff_string_bdiff_size',
'xdiff_string_bdiff',
'xdiff_string_bpatch',
'xdiff_string_diff_binary',
'xdiff_string_diff',
'xdiff_string_merge3',
'xdiff_string_patch_binary',
'xdiff_string_patch',
'xdiff_string_rabdiff']}
if __name__ == '__main__':
import glob
import os
import pprint
import re
import shutil
import tarfile
import urllib
PHP_MANUAL_URL = 'http://us3.php.net/distributions/manual/php_manual_en.tar.gz'
PHP_MANUAL_DIR = './php-chunked-xhtml/'
PHP_REFERENCE_GLOB = 'ref.*'
PHP_FUNCTION_RE = '<a href="function\..*?\.html">(.*?)</a>'
PHP_MODULE_RE = '<title>(.*?) Functions</title>'
def get_php_functions():
function_re = re.compile(PHP_FUNCTION_RE)
module_re = re.compile(PHP_MODULE_RE)
modules = {}
for file in get_php_references():
module = ''
for line in open(file):
if not module:
search = module_re.search(line)
if search:
module = search.group(1)
modules[module] = []
elif '<h2>Table of Contents</h2>' in line:
for match in function_re.finditer(line):
fn = match.group(1)
if '->' not in fn and '::' not in fn:
modules[module].append(fn)
# These are dummy manual pages, not actual functions
if module == 'PHP Options/Info':
modules[module].remove('main')
elif module == 'Filesystem':
modules[module].remove('delete')
if not modules[module]:
del modules[module]
break
return modules
def get_php_references():
download = urllib.urlretrieve(PHP_MANUAL_URL)
tar = tarfile.open(download[0])
tar.extractall()
tar.close()
for file in glob.glob("%s%s" % (PHP_MANUAL_DIR, PHP_REFERENCE_GLOB)):
yield file
os.remove(download[0])
def regenerate(filename, modules):
f = open(filename)
try:
content = f.read()
finally:
f.close()
header = content[:content.find('MODULES = {')]
footer = content[content.find("if __name__ == '__main__':"):]
f = open(filename, 'w')
f.write(header)
f.write('MODULES = %s\n\n' % pprint.pformat(modules))
f.write(footer)
f.close()
def run():
print '>> Downloading Function Index'
modules = get_php_functions()
total = sum(len(v) for v in modules.itervalues())
print '%d functions found' % total
regenerate(__file__, modules)
shutil.rmtree(PHP_MANUAL_DIR)
run()
|
agpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
423,
8624,
10372,
272,
18294,
22935,
339,
961,
570,
14404,
314,
805,
1561,
436,
3932,
4621,
687,
314,
272,
3945,
80,
9248,
436,
12821,
6337,
14,
339,
4226,
440,
17355,
314,
30920,
24392,
1211,
701,
4926,
1,
339,
14750,
26,
314,
10152,
28183,
1192,
18794,
8298,
666,
1806,
2195,
1467,
21408,
1950,
14,
2793,
1133,
1255,
626,
737,
5629,
12,
675,
1467,
282,
1654,
8700,
13,
9,
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,
21194,
275,
791,
14,
7278,
356,
788,
3287,
846,
63,
912,
995,
199,
283,
1282,
35,
356,
788,
439,
67,
63,
525,
297,
268,
283,
439,
67,
63,
1393,
63,
2724,
297,
268,
283,
439,
67,
63,
1393,
63,
2724,
493,
297,
268,
283,
439,
67,
63,
1393,
63,
912,
297,
268,
283,
439,
67,
63,
1393,
63,
912,
493,
297,
268,
283,
439,
67,
63,
1637,
63,
815,
297,
268,
283,
439,
67,
63,
9765,
297,
268,
283,
439,
67,
63,
3584,
63,
1637,
297,
268,
283,
439,
67,
63,
2014,
63,
493,
297,
268,
283,
439,
67,
63,
7778,
297,
268,
283,
439,
67,
63,
4640,
63,
5559,
297,
268,
283,
439,
67,
63,
1807,
63,
493,
297,
268,
283,
439,
67,
63,
1807,
297,
268,
283,
439,
67,
63,
2444,
297,
268,
283,
439,
67,
63,
3535,
297,
268,
283,
439,
67,
63,
6559,
297,
268,
283,
439,
67,
63,
912,
63,
5559,
297,
268,
283,
439,
67,
63,
83,
391,
63,
815,
297,
268,
283,
439,
67,
63,
1617,
995,
199,
283,
1282,
36,
356,
788,
439,
68,
63,
20081,
297,
268,
283,
439,
68,
63,
1250,
2340,
297,
268,
283,
439,
68,
63,
429,
1778,
297,
268,
283,
439,
68,
63,
6958,
297,
268,
283,
439,
68,
63,
67,
293,
1151,
297,
268,
283,
439,
68,
63,
2724,
63,
1593,
63,
1224,
297,
268,
283,
439,
68,
63,
2724,
63,
18539,
63,
4435,
297,
268,
283,
439,
68,
63,
2724,
63,
7898,
63,
4435,
297,
268,
283,
439,
68,
63,
7878,
297,
268,
283,
439,
68,
63,
362,
63,
2682,
63,
7450,
297,
268,
283,
439,
68,
63,
409,
63,
80,
14979,
63,
3446,
297,
268,
283,
439,
68,
63,
409,
63,
1730,
63,
3446,
63,
3450,
297,
268,
283,
439,
68,
63,
409,
63,
1730,
63,
3446,
297,
268,
283,
439,
68,
63,
409,
63,
1730,
297,
268,
283,
4415,
63,
1593,
297,
268,
283,
8165,
63,
1593,
995,
199,
283,
6985,
3274,
436,
5906,
603,
588,
81,
317,
356,
788,
23726,
81,
317,
63,
3409,
63,
635,
297,
3521,
283,
23726,
81,
317,
63,
3409,
63,
1099,
297,
3521,
283,
23726,
81,
317,
63,
1258,
63,
2991,
297,
3521,
283,
23726,
81,
317,
63,
2242,
297,
3521,
283,
23726,
81,
317,
63,
5993,
63,
15656,
63,
504,
63,
4133,
297,
3521,
283,
23726,
81,
317,
63,
5993,
63,
82,
1168,
63,
1122,
297,
3521,
283,
23726,
81,
317,
63,
4296,
63,
15656,
63,
504,
63,
4133,
297,
3521,
283,
23726,
81,
317,
63,
4296,
63,
82,
1168,
63,
1122,
297,
3521,
283,
23726,
81,
317,
63,
3765,
63,
875,
297,
3521,
283,
23726,
81,
317,
63,
2526,
297,
3521,
283,
23726,
81,
317,
63,
3535,
297,
3521,
283,
23726,
81,
317,
63,
362,
63,
2343,
297,
3521,
283,
23726,
81,
317,
63,
4133,
63,
1131,
297,
3521,
283,
23726,
81,
317,
63,
635,
63,
835,
297,
3521,
283,
23726,
81,
317,
63,
3070,
297,
3521,
283,
23726,
81,
317,
63,
82,
1168,
63,
1122,
63,
3827,
297,
3521,
283,
23726,
81,
317,
63,
82,
1168,
63,
15944,
297,
3521,
283,
23726,
81,
317,
63,
82,
1168,
63,
1131,
63,
466,
297,
3521,
283,
23726,
81,
317,
63,
2254,
63,
2809,
63,
576,
297,
3521,
283,
23726,
81,
317,
63,
2254,
63,
1131,
297,
3521,
283,
23726,
81,
317,
63,
409,
63,
2992,
297,
3521,
283,
23726,
81,
317,
63,
12384,
63,
1131,
995,
199,
283,
28993,
356,
788,
3796,
63,
1739,
63,
14478,
297,
288,
283,
3796,
63,
362,
63,
3112,
297,
288,
283,
3796,
63,
362,
63,
1023,
297,
288,
283,
3796,
63,
12959,
297,
288,
283,
3796,
63,
3892,
63,
2302,
297,
288,
283,
3796,
63,
4610,
297,
288,
283,
3796,
63,
1069,
63,
2139,
297,
288,
283,
3796,
63,
3958,
63,
2593,
297,
288,
283,
3796,
63,
1310,
63,
2139,
297,
288,
283,
3796,
63,
261,
9072,
297,
288,
283,
362,
452,
2139,
297,
288,
283,
2065,
995,
199,
283,
3836,
356,
788,
1144,
63,
1461,
63,
498,
63,
2546,
297,
1779,
283,
1144,
63,
4604,
297,
1779,
283,
1144,
63,
13307,
297,
1779,
283,
1144,
63,
835,
63,
1459,
297,
1779,
283,
1144,
63,
3028,
63,
16824,
297,
1779,
283,
1144,
63,
3028,
63,
498,
297,
1779,
283,
1144,
63,
3028,
63,
85,
16824,
297,
1779,
283,
1144,
63,
3028,
63,
85,
498,
297,
1779,
283,
1144,
63,
3028,
297,
1779,
283,
1144,
63,
4498,
63,
1612,
297,
1779,
283,
1144,
63,
4498,
297,
1779,
283,
1144,
63,
1541,
297,
1779,
283,
1144,
63,
16114,
297,
1779,
283,
1144,
63,
23149,
63,
16824,
297,
1779,
283,
1144,
63,
23149,
63,
498,
297,
1779,
283,
1144,
63,
23149,
63,
85,
16824,
297,
1779,
283,
1144,
63,
23149,
63,
85,
498,
297,
1779,
283,
1144,
63,
23149,
297,
1779,
283,
1144,
63,
498,
63,
2444,
297,
1779,
283,
1144,
63,
1612,
297,
1779,
283,
1144,
63,
1130,
297,
1779,
283,
1144,
63,
5628,
63,
9931,
297,
1779,
283,
1144,
63,
5628,
297,
1779,
283,
1144,
63,
3029,
3191,
297,
1779,
283,
1144,
63,
6226,
297,
1779,
283,
1144,
63,
1935,
297,
1779,
283,
1144,
63,
2558,
297,
1779,
283,
1144,
63,
5335,
297,
1779,
283,
1144,
63,
3759,
297,
1779,
283,
1144,
63,
5270,
297,
1779,
283,
1144,
63,
1814,
63,
9931,
297,
1779,
283,
1144,
63,
1814,
297,
1779,
283,
1144,
63,
4471,
297,
1779,
283,
1144,
63,
1733,
297,
1779,
283,
1144,
63,
4723,
297,
1779,
283,
1144,
63,
5224,
297
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
423,
8624,
10372,
272,
18294,
22935,
339,
961,
570,
14404,
314,
805,
1561,
436,
3932,
4621,
687,
314,
272,
3945,
80,
9248,
436,
12821,
6337,
14,
339,
4226,
440,
17355,
314,
30920,
24392,
1211,
701,
4926,
1,
339,
14750,
26,
314,
10152,
28183,
1192,
18794,
8298,
666,
1806,
2195,
1467,
21408,
1950,
14,
2793,
1133,
1255,
626,
737,
5629,
12,
675,
1467,
282,
1654,
8700,
13,
9,
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,
21194,
275,
791,
14,
7278,
356,
788,
3287,
846,
63,
912,
995,
199,
283,
1282,
35,
356,
788,
439,
67,
63,
525,
297,
268,
283,
439,
67,
63,
1393,
63,
2724,
297,
268,
283,
439,
67,
63,
1393,
63,
2724,
493,
297,
268,
283,
439,
67,
63,
1393,
63,
912,
297,
268,
283,
439,
67,
63,
1393,
63,
912,
493,
297,
268,
283,
439,
67,
63,
1637,
63,
815,
297,
268,
283,
439,
67,
63,
9765,
297,
268,
283,
439,
67,
63,
3584,
63,
1637,
297,
268,
283,
439,
67,
63,
2014,
63,
493,
297,
268,
283,
439,
67,
63,
7778,
297,
268,
283,
439,
67,
63,
4640,
63,
5559,
297,
268,
283,
439,
67,
63,
1807,
63,
493,
297,
268,
283,
439,
67,
63,
1807,
297,
268,
283,
439,
67,
63,
2444,
297,
268,
283,
439,
67,
63,
3535,
297,
268,
283,
439,
67,
63,
6559,
297,
268,
283,
439,
67,
63,
912,
63,
5559,
297,
268,
283,
439,
67,
63,
83,
391,
63,
815,
297,
268,
283,
439,
67,
63,
1617,
995,
199,
283,
1282,
36,
356,
788,
439,
68,
63,
20081,
297,
268,
283,
439,
68,
63,
1250,
2340,
297,
268,
283,
439,
68,
63,
429,
1778,
297,
268,
283,
439,
68,
63,
6958,
297,
268,
283,
439,
68,
63,
67,
293,
1151,
297,
268,
283,
439,
68,
63,
2724,
63,
1593,
63,
1224,
297,
268,
283,
439,
68,
63,
2724,
63,
18539,
63,
4435,
297,
268,
283,
439,
68,
63,
2724,
63,
7898,
63,
4435,
297,
268,
283,
439,
68,
63,
7878,
297,
268,
283,
439,
68,
63,
362,
63,
2682,
63,
7450,
297,
268,
283,
439,
68,
63,
409,
63,
80,
14979,
63,
3446,
297,
268,
283,
439,
68,
63,
409,
63,
1730,
63,
3446,
63,
3450,
297,
268,
283,
439,
68,
63,
409,
63,
1730,
63,
3446,
297,
268,
283,
439,
68,
63,
409,
63,
1730,
297,
268,
283,
4415,
63,
1593,
297,
268,
283,
8165,
63,
1593,
995,
199,
283,
6985,
3274,
436,
5906,
603,
588,
81,
317,
356,
788,
23726,
81,
317,
63,
3409,
63,
635,
297,
3521,
283,
23726,
81,
317,
63,
3409,
63,
1099,
297,
3521,
283,
23726,
81,
317,
63,
1258,
63,
2991,
297,
3521,
283,
23726,
81,
317,
63,
2242,
297,
3521,
283,
23726,
81,
317,
63,
5993,
63,
15656,
63,
504,
63,
4133,
297,
3521,
283,
23726,
81,
317,
63,
5993,
63,
82,
1168,
63,
1122,
297,
3521,
283,
23726,
81,
317,
63,
4296,
63,
15656,
63,
504,
63,
4133,
297,
3521,
283,
23726,
81,
317,
63,
4296,
63,
82,
1168,
63,
1122,
297,
3521,
283,
23726,
81,
317,
63,
3765,
63,
875,
297,
3521,
283,
23726,
81,
317,
63,
2526,
297,
3521,
283,
23726,
81,
317,
63,
3535,
297,
3521,
283,
23726,
81,
317,
63,
362,
63,
2343,
297,
3521,
283,
23726,
81,
317,
63,
4133,
63,
1131,
297,
3521,
283,
23726,
81,
317,
63,
635,
63,
835,
297,
3521,
283,
23726,
81,
317,
63,
3070,
297,
3521,
283,
23726,
81,
317,
63,
82,
1168,
63,
1122,
63,
3827,
297,
3521,
283,
23726,
81,
317,
63,
82,
1168,
63,
15944,
297,
3521,
283,
23726,
81,
317,
63,
82,
1168,
63,
1131,
63,
466,
297,
3521,
283,
23726,
81,
317,
63,
2254,
63,
2809,
63,
576,
297,
3521,
283,
23726,
81,
317,
63,
2254,
63,
1131,
297,
3521,
283,
23726,
81,
317,
63,
409,
63,
2992,
297,
3521,
283,
23726,
81,
317,
63,
12384,
63,
1131,
995,
199,
283,
28993,
356,
788,
3796,
63,
1739,
63,
14478,
297,
288,
283,
3796,
63,
362,
63,
3112,
297,
288,
283,
3796,
63,
362,
63,
1023,
297,
288,
283,
3796,
63,
12959,
297,
288,
283,
3796,
63,
3892,
63,
2302,
297,
288,
283,
3796,
63,
4610,
297,
288,
283,
3796,
63,
1069,
63,
2139,
297,
288,
283,
3796,
63,
3958,
63,
2593,
297,
288,
283,
3796,
63,
1310,
63,
2139,
297,
288,
283,
3796,
63,
261,
9072,
297,
288,
283,
362,
452,
2139,
297,
288,
283,
2065,
995,
199,
283,
3836,
356,
788,
1144,
63,
1461,
63,
498,
63,
2546,
297,
1779,
283,
1144,
63,
4604,
297,
1779,
283,
1144,
63,
13307,
297,
1779,
283,
1144,
63,
835,
63,
1459,
297,
1779,
283,
1144,
63,
3028,
63,
16824,
297,
1779,
283,
1144,
63,
3028,
63,
498,
297,
1779,
283,
1144,
63,
3028,
63,
85,
16824,
297,
1779,
283,
1144,
63,
3028,
63,
85,
498,
297,
1779,
283,
1144,
63,
3028,
297,
1779,
283,
1144,
63,
4498,
63,
1612,
297,
1779,
283,
1144,
63,
4498,
297,
1779,
283,
1144,
63,
1541,
297,
1779,
283,
1144,
63,
16114,
297,
1779,
283,
1144,
63,
23149,
63,
16824,
297,
1779,
283,
1144,
63,
23149,
63,
498,
297,
1779,
283,
1144,
63,
23149,
63,
85,
16824,
297,
1779,
283,
1144,
63,
23149,
63,
85,
498,
297,
1779,
283,
1144,
63,
23149,
297,
1779,
283,
1144,
63,
498,
63,
2444,
297,
1779,
283,
1144,
63,
1612,
297,
1779,
283,
1144,
63,
1130,
297,
1779,
283,
1144,
63,
5628,
63,
9931,
297,
1779,
283,
1144,
63,
5628,
297,
1779,
283,
1144,
63,
3029,
3191,
297,
1779,
283,
1144,
63,
6226,
297,
1779,
283,
1144,
63,
1935,
297,
1779,
283,
1144,
63,
2558,
297,
1779,
283,
1144,
63,
5335,
297,
1779,
283,
1144,
63,
3759,
297,
1779,
283,
1144,
63,
5270,
297,
1779,
283,
1144,
63,
1814,
63,
9931,
297,
1779,
283,
1144,
63,
1814,
297,
1779,
283,
1144,
63,
4471,
297,
1779,
283,
1144,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
ColaLightOriginal/GraphV
|
Source/Graph_Class.py
|
1
|
17088
|
# -*- coding: utf-8 -*-
from graph_tool.all import *
from Queue_Class import *
from Visitor_Example_Class import *
from Graph_Window_Main_Class import *
from gi.repository import Gtk, Gdk, GdkPixbuf, GObject, Pango
import numpy as np
from numpy.random import random
import sys
class Graph():
g = Graph()
g.set_directed(False)
#Property for name and surname
vpropSurname = g.new_vertex_property("string")
g.vertex_properties["Surname"] = vpropSurname
vpropNeighbours = g.new_vertex_property("float")
g.vertex_properties["Neighbours"] = vpropNeighbours
vpropSpecializations = g.new_vertex_property("object")
# g.vertex_properties["Specializations"] = vpropSpecializations
#Mail
vpropMail = g.new_vertex_property("string")
g.vertex_properties["Section"] = vpropMail
#Property for counter of cooperations
epropCounter = g.new_edge_property("float")
g.edge_properties["Counter"] = epropCounter
#Proprty maps for magazines
epropMagazines = g.new_edge_property("object")
edgeCounter = g.new_edge_property("int")
# g.edge_properties["Counter2"] = edgeCounter
#Filter property
epropFilter = g.new_edge_property("bool")
vpropFilter = g.new_vertex_property("bool")
#Property for vertex colour
vcolor = g.new_vertex_property("vector<double>")
#Property for edge colour
ecolor = g.new_edge_property("vector<double>")
orange = 1
#Predefined colors, maroon, yellow,olive,lime,green,aqua,teal,blue, navy, fuchsia, purple, black, grey, less grey, more grey, strange, strange2
colors = [[0.7, 0, 0, 0.9],[1,1,0,.9],[.5,.5,0,.9],
[0,1,0,.9],[0,.5,0,.9],[0,1,1,.9],
[0,.5,.5,.9],[0,0,1,.9],[0,0,.5,.9],
[1,0,1,.9],[.5,0,.5,.9],[0,0,0,.9],
[.5,.5,.5,.9],[.7,.7,.7,.9],[.2,.2,.2,.9],
[.5,.7,.7,.9],[.7,.7,.2,.9]]
#Mails to num
colorNumList = []
#FR positioning
ebet = None
GlobalPos = None
GlobalPosFR = None
deg = None
#Specializations positioning
GlobalPosSpecialities = None
GlobalWidgetPosSpecialities = None
#Arf positioning
ebetWidget = None
degWidget = None
#Pos for specs/Mags
GlobalWidgetPosSpecs = None
#Pos for All
GlobalWidgetPosAll = None
ebetWidgetAll = None
degWidgetAll = None
#Adding a vertex to graph
def addVertex(self):
self.g.add_vertex()
#Adding an edge to graph
def addEdge(self, vertex1, vertex2):
self.g.add_edge(self.g.vertex(vertex1), self.g.vertex(vertex2))
#Arf Layout of drawing a graph
def drawGraphArfLayout(self, imageName):
if self.GlobalPos == None:
self.createPos()
graph_draw(self.g,
pos=self.GlobalPos,
#vertex_text=self.vpropSurname,
#vertex_font_size = 10,
vorder=self.deg,
eorder=None,
edge_pen_width=self.ebet,
edge_color=self.ebet,
vertex_size=self.deg,
vertex_fill_color=self.vcolor,
output_size=(1920, 1680),
output=imageName+".png")
#fruchterman Reingold of drawing a graph
def drawGraphFruchtermanReingoldLayout(self, imageName):
if self.GlobalPosFR == None:
self.createPosFr()
graph_draw(self.g,
pos=self.GlobalPosFR,
vorder=self.deg,
eorder=None,
edge_pen_width=self.ebet,
edge_color=self.ebet,
vertex_size=self.deg,
vertex_fill_color=self.vcolor,
output_size=(1920, 1680),
output=imageName+".png")
#Create Interactive Window
def interactiveWindow(self):
graph_tool.draw.interactive_window(self.g,
pos=self.GlobalPos,
vertex_text=self.vpropSurname,
vertex_font_size=10,
edge_text=self.edgeCounter,
nodesfirst=True,
geometry=(800,600),
edge_pen_width=1,
update_layout=False,
async=False,
no_main=False)
#Create Widget
def graphWidget(self, choose, specMag):
#self.createPosWidget()
#Magazines
# self.createPosWidgetMags()
#Specializations
#self.createPosWidgetSpecs()
g2 = self.g.copy()
vNeighbours = None
#All Graph
if choose == 0:
if self.GlobalWidgetPosAll == None:
self.createPosWidgetAll(g2)
self.widgetDef(g2, self.GlobalWidgetPosAll,self.degWidgetAll, self.ebetWidgetAll)
#Specs Graph
elif choose == 1:
g2, vNeighbours = self.createPosWidgetSpecs(specMag,g2)
self.createPosWidget(g2,vNeighbours)
self.widgetDef(g2, self.GlobalWidgetPos,self.degWidget,self.ebetWidget)
#Mags Graph
elif choose == 2:
g2 = self.createPosWidgetMags(specMag,g2)
self.widgetDef(g2, self.GlobalWidgetPos,self.degWidget,self.ebetWidget)
def widgetDef(self, graph,pos,deg,ebet):
s = Gdk.Screen.get_default()
win = GraphWindowMain(
self,
graph,
pos,
geometry=(s.get_width()-240, s.get_height()-200),
vprops=None,
eprops=None,
vorder=deg,
eorder=None,
edge_pen_width=ebet,
edge_color=ebet,
vertex_size=deg,
# #edge_pen_width=1,
# #vertex_font_size = 10,
vertex_fill_color=self.vcolor,
display_props_size=16
#edge_text=self.epropCounter
)
win.connect("delete_event", Gtk.main_quit)
win.show_all()
Gtk.main()
def findPath(self,source,destination):
q = Queue()
sourceV = None
destinationV = None
parent = None
paths = []
pathsC = 0
for v in self.g.vertices():
if(self.vpropSurname[v] == source):
sourceV = int(v)
elif(self.vpropSurname[v] == destination):
destinationV = int(v)
if sourceV == None or destinationV == None:
return False
tempPath = [sourceV]
q.add(tempPath)
visited = []
validPaths = []
counter = 1
try:
while bool(q) == True:
tmpPath = q.remove()
lastNode = tmpPath[len(tmpPath)-1]
if lastNode == destinationV and counter >= 0:
validPaths.append(tmpPath)
counter -= 1
elif counter == 0:
return validPaths
for n in self.g.vertex(lastNode).out_neighbours():
if int(n) not in tmpPath:
newPath = tmpPath + [int(n)]
q.add(newPath)
except:
if(bool(validPaths) == False):
return False
else:
return validPaths
#Find path with A* algorithm
def findPathA(self,source,destination):
if self.GlobalWidgetPosAll == None:
self.createPosWidgetAll(self.g)
sourceV = None
destinationV = None
for v in self.g.vertices():
if(self.vpropSurname[v] == source):
sourceV = int(v)
elif(self.vpropSurname[v] == destination):
destinationV = int(v)
if sourceV == None or destinationV == None:
return False
# weight = self.g.new_edge_property("double")
weight2 = self.epropCounter.copy()
# weight2.a = 1/weight2.a*10
for e in self.g.edges():
weight2[e] = np.sqrt(sum((self.GlobalWidgetPosAll[e.source()].a - self.GlobalWidgetPosAll[e.target()].a) ** 2))
touch_v = self.g.new_vertex_property("bool")
touch_e = self.g.new_edge_property("bool")
target = self.g.vertex(sourceV)
dist, pred = astar_search(self.g, self.g.vertex(destinationV), weight2,
VisitorExample(touch_v, touch_e, target),
heuristic=lambda v: self.h(v, target, self.GlobalWidgetPosAll))
return dist, pred, destinationV, touch_v, touch_e, target
def createPos(self):
if self.deg == None:
self.deg = self.vpropNeighbours.copy()
self.deg.a = 20 * (np.sqrt(self.deg.a) * 0.5 + 0.4)
if self.ebet == None:
self.ebet = self.epropCounter.copy()
self.ebet.a = 4 * (np.sqrt(self.ebet.a) * 0.5 + 0.4)
self.GlobalPos = arf_layout(self.g, weight=self.ebet, d=0.5, a=2, max_iter=2000)
def createPosFr(self):
if self.deg == None:
self.deg = self.vpropNeighbours.copy()
self.deg.a = 20 * (np.sqrt(self.deg.a) * 0.5 + 0.4)
if self.ebet == None:
self.ebet = self.epropCounter.copy()
self.ebet.a = 4 * (np.sqrt(self.ebet.a) * 0.5 + 0.4)
self.GlobalPosFR = fruchterman_reingold_layout(self.g,weight=self.ebet, n_iter=200,r=1900)
def createPosWidget(self,graph,vNeighbours):
#self.degWidget = self.vpropNeighbours.copy()
self.degWidget = vNeighbours
self.degWidget.a = 10 * (np.sqrt(self.degWidget.a) * 0.5 + 0.4)
self.ebetWidget = self.epropCounter.copy()
self.ebetWidget.a = 2 * (np.sqrt(self.ebetWidget.a) * 0.5 + 0.4)
#self.GlobalWidgetPos = arf_layout(self.g, weight=self.ebetWidget, d=0.5, a=2, max_iter=10000)
self.GlobalWidgetPos = arf_layout(graph, weight=self.ebetWidget, d=0.5, a=2, max_iter=2000)
def createPosWidgetAll(self,graph):
self.degWidgetAll = self.vpropNeighbours.copy()
#self.degWidgetAll.a = self.degWidgetAll.a
self.degWidgetAll.a = 5 * (np.sqrt(self.degWidgetAll.a) + 0.4)
self.ebetWidgetAll = self.epropCounter.copy()
self.ebetWidgetAll.a = 0.5 * (np.sqrt(self.ebetWidgetAll.a)*0.5 + 0.4)
# self.GlobalWidgetPosAll = fruchterman_reingold_layout(self.g,weight=self.ebetWidgetAll, n_iter=500)
self.GlobalWidgetPosAll = arf_layout(graph, weight=self.ebetWidgetAll, d = 0.5, a = 10, max_iter=1000)
# self.GlobalWidgetPosAll = sfdp_layout(graph, eweight=self.ebetWidgetAll)
#self.GlobalWidgetPosAll = arf_layout(graph, weight=self.ebetWidgetAll, d = 0.5, a = 50, max_iter=2000)
#self.GlobalWidgetPosAll = fruchterman_reingold_layout(graph, weight=self.ebetWidget, n_iter=100, r = 1000 )
def h(self, v, target, pos):
return np.sqrt(sum((pos[v].a - pos[target].a) ** 2))
def printVerticies(self):
iterator = 0
for v in self.g.vertices():
print v
print self.vpropSurname[self.g.vertex(iterator)]
iterator+=1
def printEdges(self):
for e in self.g.edges():
print e
print self.epropCounter[self.g.edge( e.source(), e.target() )]
def addEmp(self, cursorResult):
iterator = 0
for emp in cursorResult:
#Add surnames
self.addVertex()
self.vpropSurname[self.g.vertex(iterator)] = cursorResult[iterator][1] + " " + cursorResult[iterator][2]
#Add color
for color in self.colorNumList:
if cursorResult[iterator][4] == color[1]:
self.vcolor[self.g.vertex(iterator)] = self.colors[color[0]]
#self.vcolor[self.g.vertex(iterator)] = self.colors[0]
self.vpropMail[self.g.vertex(iterator)] = cursorResult[iterator][4]
#Add specializations
self.vpropSpecializations[self.g.vertex(iterator)] = []
try:
for i in cursorResult[iterator][3].split(" "):
self.vpropSpecializations[self.g.vertex(iterator)].append(i)
except:
pass
iterator += 1
def addCoauthors(self, cursorResult):
iterator = 0
for co in cursorResult:
#Increment
if self.g.edge(cursorResult[iterator][1]-1, cursorResult[iterator][2]-1) is not None:
self.epropCounter[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1 ] += 1
self.edgeCounter[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1 ] += 1
#Add magazine
#For magazines in actual edge
magsSemafor = 0
for enum, magazines in enumerate(self.epropMagazines[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1]):
if magazines[0] == cursorResult[iterator][4]:
self.epropMagazines[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1][enum][1] += 1
magsSemafor = 1
break
if magsSemafor == 0:
self.epropMagazines[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1].append([cursorResult[iterator][4],1])
#Create new
else:
#Add edge counter
self.addEdge(cursorResult[iterator][1]-1, cursorResult[iterator][2]-1)
self.epropCounter[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1] = 1
self.edgeCounter[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1 ] = 1
#Add magazine to edge
self.epropMagazines[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1] = []
self.epropMagazines[cursorResult[iterator][1]-1, cursorResult[iterator][2]-1].append([cursorResult[iterator][4],1])
iterator += 1
self.removeUnused()
#remove unusede vertices
def removeUnused(self):
iterator = 0
delList = []
for v in self.g.vertices():
if (self.vpropSurname[v] == "Agnieszka Rosa") or (self.vpropSurname[v] == "Maciej Grochowski") or (self.vpropSurname[v] == "Małgorzata Kowalska") or (self.vpropSurname[v] == "Karolina Zawada"):
delList.append(v)
continue
iterator2 = 0
for n in v.out_neighbours():
if (self.vpropSurname[n] == "Agnieszka Rosa") or (self.vpropSurname[n] == "Maciej Grochowski") or (self.vpropSurname[n] == "Małgorzata Kowalska") or (self.vpropSurname[n] == "Karolina Zawada"):
continue
iterator2 +=1
else:
self.vpropNeighbours[v] = iterator2
iterator += 1
for v in reversed(sorted(delList)):
self.g.remove_vertex(v)
def mailToColor(self,cursorResult):
for i, cursor in enumerate(cursorResult):
self.colorNumList.append([i,str(cursor[0])])
def printMagazines(self):
for e in self.g.edges():
print e.source()
print e.target()
print self.epropMagazines[e]
def createPosWidgetSpecs(self,spec,graph):
eFilter = self.epropFilter.copy()
vFilter = self.vpropFilter.copy()
vNeighbours = graph.new_vertex_property("int")
for v in graph.vertices():
if spec in self.vpropSpecializations[v]:
vFilter[v] = 1
else:
vFilter[v] = 0
for e in graph.edges():
specials = ""
if (spec in self.vpropSpecializations[e.source()]) and (spec in self.vpropSpecializations[e.target()]):
eFilter[e] = 1
else:
eFilter[e] = 0
graph.set_edge_filter(eFilter)
graph.set_vertex_filter(vFilter)
for v in graph.vertices():
neighboursCount = 0
for neighbours in v.out_neighbours():
neighboursCount += 1
vNeighbours[v] = neighboursCount
return graph, vNeighbours
def createPosWidgetMags(self,mag, graph):
eFilter = self.epropFilter.copy()
vFilter = self.vpropFilter.copy()
for v in vFilter:
v = 0
self.ebetWidget = self.epropCounter.copy()
for e in eFilter:
e = 0
for e in graph.edges():
for mags in self.epropMagazines[e]:
if mags[0] == mag:
eFilter[e] = 1
vFilter[e.source()] = 1
vFilter[e.target()] = 1
self.ebetWidget[e] = 2 * (np.sqrt(mags[1]) * 0.5 + 0.4)
self.GlobalWidgetPos = arf_layout(graph, weight=self.ebetWidget, d=0.5, a=2, max_iter=100)
graph.set_edge_filter(eFilter)
graph.set_vertex_filter(vFilter)
vNeighbours = graph.new_vertex_property("int")
for v in graph.vertices():
neighboursCount = 0
for neighbours in v.out_neighbours():
neighboursCount += 1
vNeighbours[v] = neighboursCount
self.degWidget = vNeighbours.copy()
self.degWidget.a = 10 * (np.sqrt(self.degWidget.a) * 0.5 + 0.4)
return graph
|
unlicense
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
3343,
63,
3557,
14,
452,
492,
627,
199,
504,
10703,
63,
2543,
492,
627,
199,
504,
29614,
269,
63,
9846,
63,
2543,
492,
627,
199,
504,
11513,
63,
4301,
63,
6756,
63,
2543,
492,
627,
199,
199,
504,
18895,
14,
8421,
492,
11424,
12,
31392,
12,
31392,
25747,
1436,
12,
31264,
12,
510,
17771,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
2355,
492,
2196,
199,
646,
984,
199,
199,
533,
11513,
837,
339,
486,
275,
11513,
342,
272,
486,
14,
409,
63,
12080,
8,
797,
9,
339,
327,
3697,
367,
536,
436,
308,
21121,
272,
373,
4469,
51,
21121,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
875,
531,
272,
486,
14,
11417,
63,
3282,
905,
51,
21121,
937,
275,
373,
4469,
51,
21121,
339,
373,
4469,
4698,
4594,
16363,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
1609,
531,
272,
486,
14,
11417,
63,
3282,
905,
4698,
4594,
16363,
937,
275,
373,
4469,
4698,
4594,
16363,
339,
373,
4469,
12246,
12270,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
785,
531,
272,
327,
486,
14,
11417,
63,
3282,
905,
12246,
12270,
937,
275,
373,
4469,
12246,
12270,
339,
327,
13681,
272,
373,
4469,
13681,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
875,
531,
272,
486,
14,
11417,
63,
3282,
905,
8660,
937,
275,
373,
4469,
13681,
339,
327,
3697,
367,
7055,
402,
512,
8170,
272,
325,
4469,
11348,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
1609,
531,
272,
486,
14,
5173,
63,
3282,
905,
11348,
937,
275,
325,
4469,
11348,
339,
327,
919,
2700,
369,
9033,
367,
8127,
4651,
3746,
272,
325,
4469,
22745,
4651,
3746,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
785,
531,
339,
6275,
11348,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
442,
531,
272,
327,
486,
14,
5173,
63,
3282,
905,
11348,
18,
937,
275,
6275,
11348,
339,
327,
4131,
3324,
272,
325,
4469,
4131,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
2245,
531,
272,
373,
4469,
4131,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
2245,
531,
339,
327,
3697,
367,
12759,
15706,
272,
373,
2326,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
4106,
28,
3157,
9579,
339,
327,
3697,
367,
6275,
15706,
272,
325,
2326,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
4106,
28,
3157,
9579,
272,
29713,
275,
413,
339,
327,
2398,
4037,
9229,
12,
7557,
79,
265,
12,
31194,
12,
79,
6442,
12,
18687,
12,
7731,
12,
65,
27164,
12,
266,
279,
12,
6304,
12,
16681,
89,
12,
289,
2133,
10971,
12,
5861,
11045,
12,
12136,
12,
30357,
12,
6656,
30357,
12,
1655,
30357,
12,
620,
618,
12,
620,
618,
18,
272,
9229,
275,
3474,
16,
14,
23,
12,
378,
12,
378,
12,
378,
14,
25,
6922,
17,
12,
17,
12,
16,
18485,
25,
6922,
14,
21,
18485,
21,
12,
16,
18485,
25,
467,
288,
359,
16,
12,
17,
12,
16,
18485,
25,
6922,
16,
18485,
21,
12,
16,
18485,
25,
6922,
16,
12,
17,
12,
17,
18485,
25,
467,
288,
359,
16,
18485,
21,
18485,
21,
18485,
25,
6922,
16,
12,
16,
12,
17,
18485,
25,
6922,
16,
12,
16,
18485,
21,
18485,
25,
467,
288,
359,
17,
12,
16,
12,
17,
18485,
25,
6922,
14,
21,
12,
16,
18485,
21,
18485,
25,
6922,
16,
12,
16,
12,
16,
18485,
25,
467,
288,
26496,
21,
18485,
21,
18485,
21,
18485,
25,
6922,
14,
23,
18485,
23,
18485,
23,
18485,
25,
6922,
14,
18,
18485,
18,
18485,
18,
18485,
25,
467,
288,
26496,
21,
18485,
23,
18485,
23,
18485,
25,
6922,
14,
23,
18485,
23,
18485,
18,
18485,
25,
2677,
2378,
327,
13681,
83,
370,
1967,
272,
3164,
5667,
1296,
275,
942,
339,
327,
5372,
3421,
316,
272,
325,
9549,
275,
488,
272,
13641,
6981,
275,
488,
272,
13641,
6981,
5372,
275,
488,
272,
7926,
275,
488,
339,
327,
12246,
12270,
3421,
316,
272,
13641,
6981,
6154,
10874,
1417,
275,
488,
272,
13641,
3339,
6981,
6154,
10874,
1417,
275,
488,
339,
327,
1596,
70,
3421,
316,
272,
325,
9549,
3339,
275,
488,
272,
7926,
3339,
275,
488,
339,
327,
6981,
367,
15941,
15,
45,
7391,
272,
13641,
3339,
6981,
28834,
275,
488,
339,
327,
6981,
367,
2900,
272,
13641,
3339,
6981,
2422,
275,
488,
272,
325,
9549,
3339,
2422,
275,
488,
272,
7926,
3339,
2422,
275,
488,
339,
327,
20897,
282,
12759,
370,
3343,
272,
347,
1050,
9787,
8,
277,
304,
267,
291,
14,
71,
14,
525,
63,
11417,
342,
339,
327,
20897,
376,
6275,
370,
3343,
272,
347,
1050,
12886,
8,
277,
12,
12759,
17,
12,
12759,
18,
304,
267,
291,
14,
71,
14,
525,
63,
5173,
8,
277,
14,
71,
14,
11417,
8,
11417,
17,
395,
291,
14,
71,
14,
11417,
8,
11417,
18,
430,
339,
327,
1596,
70,
25604,
402,
17455,
282,
3343,
272,
347,
5954,
4578,
1596,
70,
4798,
8,
277,
12,
1834,
985,
304,
398,
340,
291,
14,
7025,
6981,
508,
488,
26,
288,
291,
14,
981,
6981,
342,
398,
3343,
63,
5485,
8,
277,
14,
71,
12,
355,
2086,
29,
277,
14,
7025,
6981,
12,
355,
327,
11417,
63,
505,
29,
277,
14,
86,
4469,
51,
21121,
12,
355,
327,
11417,
63,
4246,
63,
890,
275,
1616,
12,
355,
373,
1648,
29,
277,
14,
6458,
12,
355,
325,
1648,
29,
403,
12,
355,
6275,
63,
897,
63,
2063,
29,
277,
14,
2871,
386,
12,
355,
6275,
63,
2326,
29,
277,
14,
2871,
386,
12,
355,
12759,
63,
890,
29,
277,
14,
6458,
12,
355,
12759,
63,
4498,
63,
2326,
29,
277,
14,
86,
2326,
12,
355,
1072,
63,
890,
2687,
1167,
1165,
12,
3193,
1257,
395,
355,
1072,
29,
1569,
985,
24878,
4524,
531,
339,
327,
4391,
2133,
351,
1237,
799,
316,
1753,
402,
17455,
282,
3343,
272,
347,
5954,
4578,
13848,
2133,
351,
1237,
497,
316,
1753,
4798,
8,
277,
12,
1834,
985,
304,
267,
340,
291,
14,
7025,
6981,
5372,
508,
488,
26,
288,
291,
14,
981,
6981,
13848,
342,
398,
3343,
63,
5485,
8,
277,
14,
71,
12,
355,
2086,
29,
277,
14,
7025,
6981
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
3343,
63,
3557,
14,
452,
492,
627,
199,
504,
10703,
63,
2543,
492,
627,
199,
504,
29614,
269,
63,
9846,
63,
2543,
492,
627,
199,
504,
11513,
63,
4301,
63,
6756,
63,
2543,
492,
627,
199,
199,
504,
18895,
14,
8421,
492,
11424,
12,
31392,
12,
31392,
25747,
1436,
12,
31264,
12,
510,
17771,
199,
646,
2680,
465,
980,
199,
504,
2680,
14,
2355,
492,
2196,
199,
646,
984,
199,
199,
533,
11513,
837,
339,
486,
275,
11513,
342,
272,
486,
14,
409,
63,
12080,
8,
797,
9,
339,
327,
3697,
367,
536,
436,
308,
21121,
272,
373,
4469,
51,
21121,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
875,
531,
272,
486,
14,
11417,
63,
3282,
905,
51,
21121,
937,
275,
373,
4469,
51,
21121,
339,
373,
4469,
4698,
4594,
16363,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
1609,
531,
272,
486,
14,
11417,
63,
3282,
905,
4698,
4594,
16363,
937,
275,
373,
4469,
4698,
4594,
16363,
339,
373,
4469,
12246,
12270,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
785,
531,
272,
327,
486,
14,
11417,
63,
3282,
905,
12246,
12270,
937,
275,
373,
4469,
12246,
12270,
339,
327,
13681,
272,
373,
4469,
13681,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
875,
531,
272,
486,
14,
11417,
63,
3282,
905,
8660,
937,
275,
373,
4469,
13681,
339,
327,
3697,
367,
7055,
402,
512,
8170,
272,
325,
4469,
11348,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
1609,
531,
272,
486,
14,
5173,
63,
3282,
905,
11348,
937,
275,
325,
4469,
11348,
339,
327,
919,
2700,
369,
9033,
367,
8127,
4651,
3746,
272,
325,
4469,
22745,
4651,
3746,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
785,
531,
339,
6275,
11348,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
442,
531,
272,
327,
486,
14,
5173,
63,
3282,
905,
11348,
18,
937,
275,
6275,
11348,
339,
327,
4131,
3324,
272,
325,
4469,
4131,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
2245,
531,
272,
373,
4469,
4131,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
2245,
531,
339,
327,
3697,
367,
12759,
15706,
272,
373,
2326,
275,
486,
14,
1222,
63,
11417,
63,
1829,
480,
4106,
28,
3157,
9579,
339,
327,
3697,
367,
6275,
15706,
272,
325,
2326,
275,
486,
14,
1222,
63,
5173,
63,
1829,
480,
4106,
28,
3157,
9579,
272,
29713,
275,
413,
339,
327,
2398,
4037,
9229,
12,
7557,
79,
265,
12,
31194,
12,
79,
6442,
12,
18687,
12,
7731,
12,
65,
27164,
12,
266,
279,
12,
6304,
12,
16681,
89,
12,
289,
2133,
10971,
12,
5861,
11045,
12,
12136,
12,
30357,
12,
6656,
30357,
12,
1655,
30357,
12,
620,
618,
12,
620,
618,
18,
272,
9229,
275,
3474,
16,
14,
23,
12,
378,
12,
378,
12,
378,
14,
25,
6922,
17,
12,
17,
12,
16,
18485,
25,
6922,
14,
21,
18485,
21,
12,
16,
18485,
25,
467,
288,
359,
16,
12,
17,
12,
16,
18485,
25,
6922,
16,
18485,
21,
12,
16,
18485,
25,
6922,
16,
12,
17,
12,
17,
18485,
25,
467,
288,
359,
16,
18485,
21,
18485,
21,
18485,
25,
6922,
16,
12,
16,
12,
17,
18485,
25,
6922,
16,
12,
16,
18485,
21,
18485,
25,
467,
288,
359,
17,
12,
16,
12,
17,
18485,
25,
6922,
14,
21,
12,
16,
18485,
21,
18485,
25,
6922,
16,
12,
16,
12,
16,
18485,
25,
467,
288,
26496,
21,
18485,
21,
18485,
21,
18485,
25,
6922,
14,
23,
18485,
23,
18485,
23,
18485,
25,
6922,
14,
18,
18485,
18,
18485,
18,
18485,
25,
467,
288,
26496,
21,
18485,
23,
18485,
23,
18485,
25,
6922,
14,
23,
18485,
23,
18485,
18,
18485,
25,
2677,
2378,
327,
13681,
83,
370,
1967,
272,
3164,
5667,
1296,
275,
942,
339,
327,
5372,
3421,
316,
272,
325,
9549,
275,
488,
272,
13641,
6981,
275,
488,
272,
13641,
6981,
5372,
275,
488,
272,
7926,
275,
488,
339,
327,
12246,
12270,
3421,
316,
272,
13641,
6981,
6154,
10874,
1417,
275,
488,
272,
13641,
3339,
6981,
6154,
10874,
1417,
275,
488,
339,
327,
1596,
70,
3421,
316,
272,
325,
9549,
3339,
275,
488,
272,
7926,
3339,
275,
488,
339,
327,
6981,
367,
15941,
15,
45,
7391,
272,
13641,
3339,
6981,
28834,
275,
488,
339,
327,
6981,
367,
2900,
272,
13641,
3339,
6981,
2422,
275,
488,
272,
325,
9549,
3339,
2422,
275,
488,
272,
7926,
3339,
2422,
275,
488,
339,
327,
20897,
282,
12759,
370,
3343,
272,
347,
1050,
9787,
8,
277,
304,
267,
291,
14,
71,
14,
525,
63,
11417,
342,
339,
327,
20897,
376,
6275,
370,
3343,
272,
347,
1050,
12886,
8,
277,
12,
12759,
17,
12,
12759,
18,
304,
267,
291,
14,
71,
14,
525,
63,
5173,
8,
277,
14,
71,
14,
11417,
8,
11417,
17,
395,
291,
14,
71,
14,
11417,
8,
11417,
18,
430,
339,
327,
1596,
70,
25604,
402,
17455,
282,
3343,
272,
347,
5954,
4578,
1596,
70,
4798,
8,
277,
12,
1834,
985,
304,
398,
340,
291,
14,
7025,
6981,
508,
488,
26,
288,
291,
14,
981,
6981,
342,
398,
3343,
63,
5485,
8,
277,
14,
71,
12,
355,
2086,
29,
277,
14,
7025,
6981,
12,
355,
327,
11417,
63,
505,
29,
277,
14,
86,
4469,
51,
21121,
12,
355,
327,
11417,
63,
4246,
63,
890,
275,
1616,
12,
355,
373,
1648,
29,
277,
14,
6458,
12,
355,
325,
1648,
29,
403,
12,
355,
6275,
63,
897,
63,
2063,
29,
277,
14,
2871,
386,
12,
355,
6275,
63,
2326,
29,
277,
14,
2871,
386,
12,
355,
12759,
63,
890,
29,
277,
14,
6458,
12,
355,
12759,
63,
4498,
63,
2326,
29,
277,
14,
86,
2326,
12,
355,
1072,
63,
890,
2687,
1167,
1165,
12,
3193,
1257,
395,
355,
1072,
29,
1569,
985,
24878,
4524,
531,
339,
327,
4391,
2133,
351,
1237,
799,
316,
1753,
402,
17455,
282,
3343,
272,
347,
5954,
4578,
13848,
2133,
351,
1237,
497,
316,
1753,
4798,
8,
277,
12,
1834,
985,
304,
267,
340,
291,
14,
7025,
6981,
5372,
508,
488,
26,
288,
291,
14,
981,
6981,
13848,
342,
398,
3343,
63,
5485,
8,
277,
14,
71,
12,
355,
2086,
29,
277,
14,
7025,
6981,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
wnt-zhp/hufce
|
django/contrib/comments/forms.py
|
92
|
8086
|
import time
from django import forms
from django.forms.util import ErrorDict
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib.comments.models import Comment
from django.utils.crypto import salted_hmac, constant_time_compare
from django.utils.encoding import force_unicode
from django.utils.text import get_text_list
from django.utils import timezone
from django.utils.translation import ungettext, ugettext, ugettext_lazy as _
COMMENT_MAX_LENGTH = getattr(settings,'COMMENT_MAX_LENGTH', 3000)
class CommentSecurityForm(forms.Form):
"""
Handles the security aspects (anti-spoofing) for comment forms.
"""
content_type = forms.CharField(widget=forms.HiddenInput)
object_pk = forms.CharField(widget=forms.HiddenInput)
timestamp = forms.IntegerField(widget=forms.HiddenInput)
security_hash = forms.CharField(min_length=40, max_length=40, widget=forms.HiddenInput)
def __init__(self, target_object, data=None, initial=None):
self.target_object = target_object
if initial is None:
initial = {}
initial.update(self.generate_security_data())
super(CommentSecurityForm, self).__init__(data=data, initial=initial)
def security_errors(self):
"""Return just those errors associated with security"""
errors = ErrorDict()
for f in ["honeypot", "timestamp", "security_hash"]:
if f in self.errors:
errors[f] = self.errors[f]
return errors
def clean_security_hash(self):
"""Check the security hash."""
security_hash_dict = {
'content_type' : self.data.get("content_type", ""),
'object_pk' : self.data.get("object_pk", ""),
'timestamp' : self.data.get("timestamp", ""),
}
expected_hash = self.generate_security_hash(**security_hash_dict)
actual_hash = self.cleaned_data["security_hash"]
if not constant_time_compare(expected_hash, actual_hash):
raise forms.ValidationError("Security hash check failed.")
return actual_hash
def clean_timestamp(self):
"""Make sure the timestamp isn't too far (> 2 hours) in the past."""
ts = self.cleaned_data["timestamp"]
if time.time() - ts > (2 * 60 * 60):
raise forms.ValidationError("Timestamp check failed")
return ts
def generate_security_data(self):
"""Generate a dict of security data for "initial" data."""
timestamp = int(time.time())
security_dict = {
'content_type' : str(self.target_object._meta),
'object_pk' : str(self.target_object._get_pk_val()),
'timestamp' : str(timestamp),
'security_hash' : self.initial_security_hash(timestamp),
}
return security_dict
def initial_security_hash(self, timestamp):
"""
Generate the initial security hash from self.content_object
and a (unix) timestamp.
"""
initial_security_dict = {
'content_type' : str(self.target_object._meta),
'object_pk' : str(self.target_object._get_pk_val()),
'timestamp' : str(timestamp),
}
return self.generate_security_hash(**initial_security_dict)
def generate_security_hash(self, content_type, object_pk, timestamp):
"""
Generate a HMAC security hash from the provided info.
"""
info = (content_type, object_pk, timestamp)
key_salt = "django.contrib.forms.CommentSecurityForm"
value = "-".join(info)
return salted_hmac(key_salt, value).hexdigest()
class CommentDetailsForm(CommentSecurityForm):
"""
Handles the specific details of the comment (name, comment, etc.).
"""
name = forms.CharField(label=_("Name"), max_length=50)
email = forms.EmailField(label=_("Email address"))
url = forms.URLField(label=_("URL"), required=False)
comment = forms.CharField(label=_('Comment'), widget=forms.Textarea,
max_length=COMMENT_MAX_LENGTH)
def get_comment_object(self):
"""
Return a new (unsaved) comment object based on the information in this
form. Assumes that the form is already validated and will throw a
ValueError if not.
Does not set any of the fields that would come from a Request object
(i.e. ``user`` or ``ip_address``).
"""
if not self.is_valid():
raise ValueError("get_comment_object may only be called on valid forms")
CommentModel = self.get_comment_model()
new = CommentModel(**self.get_comment_create_data())
new = self.check_for_duplicate_comment(new)
return new
def get_comment_model(self):
"""
Get the comment model to create with this form. Subclasses in custom
comment apps should override this, get_comment_create_data, and perhaps
check_for_duplicate_comment to provide custom comment models.
"""
return Comment
def get_comment_create_data(self):
"""
Returns the dict of data to be used to create a comment. Subclasses in
custom comment apps that override get_comment_model can override this
method to add extra fields onto a custom comment model.
"""
return dict(
content_type = ContentType.objects.get_for_model(self.target_object),
object_pk = force_unicode(self.target_object._get_pk_val()),
user_name = self.cleaned_data["name"],
user_email = self.cleaned_data["email"],
user_url = self.cleaned_data["url"],
comment = self.cleaned_data["comment"],
submit_date = timezone.now(),
site_id = settings.SITE_ID,
is_public = True,
is_removed = False,
)
def check_for_duplicate_comment(self, new):
"""
Check that a submitted comment isn't a duplicate. This might be caused
by someone posting a comment twice. If it is a dup, silently return the *previous* comment.
"""
possible_duplicates = self.get_comment_model()._default_manager.using(
self.target_object._state.db
).filter(
content_type = new.content_type,
object_pk = new.object_pk,
user_name = new.user_name,
user_email = new.user_email,
user_url = new.user_url,
)
for old in possible_duplicates:
if old.submit_date.date() == new.submit_date.date() and old.comment == new.comment:
return old
return new
def clean_comment(self):
"""
If COMMENTS_ALLOW_PROFANITIES is False, check that the comment doesn't
contain anything in PROFANITIES_LIST.
"""
comment = self.cleaned_data["comment"]
if settings.COMMENTS_ALLOW_PROFANITIES == False:
bad_words = [w for w in settings.PROFANITIES_LIST if w in comment.lower()]
if bad_words:
raise forms.ValidationError(ungettext(
"Watch your mouth! The word %s is not allowed here.",
"Watch your mouth! The words %s are not allowed here.",
len(bad_words)) % get_text_list(
['"%s%s%s"' % (i[0], '-'*(len(i)-2), i[-1])
for i in bad_words], ugettext('and')))
return comment
class CommentForm(CommentDetailsForm):
honeypot = forms.CharField(required=False,
label=_('If you enter anything in this field '\
'your comment will be treated as spam'))
def clean_honeypot(self):
"""Check that nothing's been entered into the honeypot."""
value = self.cleaned_data["honeypot"]
if value:
raise forms.ValidationError(self.fields["honeypot"].label)
return value
|
gpl-3.0
|
[
646,
900,
199,
504,
1639,
492,
4513,
199,
504,
1639,
14,
3351,
14,
1974,
492,
4520,
2141,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
2828,
14,
6223,
14,
992,
492,
6819,
199,
504,
1639,
14,
1208,
14,
10316,
492,
18641,
471,
63,
18537,
12,
4413,
63,
521,
63,
5785,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2975,
199,
504,
1639,
14,
1208,
14,
505,
492,
664,
63,
505,
63,
513,
199,
504,
1639,
14,
1208,
492,
7137,
199,
504,
1639,
14,
1208,
14,
6893,
492,
26843,
12,
10366,
12,
10366,
63,
6395,
465,
485,
199,
199,
10973,
63,
4283,
63,
9127,
275,
2519,
8,
1751,
2584,
10973,
63,
4283,
63,
9127,
297,
29664,
9,
199,
199,
533,
6819,
7676,
2821,
8,
3351,
14,
2821,
304,
272,
408,
272,
23873,
314,
6391,
17435,
83,
334,
4466,
13,
22522,
1618,
316,
9,
367,
3721,
4513,
14,
272,
408,
272,
1564,
63,
466,
221,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
25419,
9,
272,
909,
63,
2051,
258,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
25419,
9,
272,
4913,
258,
275,
4513,
14,
3901,
8,
3440,
29,
3351,
14,
25419,
9,
272,
6391,
63,
2227,
275,
4513,
14,
2183,
8,
827,
63,
1267,
29,
2167,
12,
1390,
63,
1267,
29,
2167,
12,
3938,
29,
3351,
14,
25419,
9,
339,
347,
636,
826,
721,
277,
12,
1347,
63,
785,
12,
666,
29,
403,
12,
2536,
29,
403,
304,
267,
291,
14,
1375,
63,
785,
275,
1347,
63,
785,
267,
340,
2536,
365,
488,
26,
288,
2536,
275,
1052,
267,
2536,
14,
873,
8,
277,
14,
4208,
63,
4416,
63,
576,
1012,
267,
1613,
8,
7488,
7676,
2821,
12,
291,
2843,
826,
721,
576,
29,
576,
12,
2536,
29,
2747,
9,
339,
347,
6391,
63,
2550,
8,
277,
304,
267,
408,
1767,
2951,
5204,
2552,
4568,
543,
6391,
624,
267,
2552,
275,
4520,
2141,
342,
267,
367,
289,
315,
2097,
72,
368,
2279,
357,
401,
298,
3954,
401,
298,
4416,
63,
2227,
6229,
288,
340,
289,
315,
291,
14,
2550,
26,
355,
2552,
59,
70,
61,
275,
291,
14,
2550,
59,
70,
61,
267,
372,
2552,
339,
347,
3633,
63,
4416,
63,
2227,
8,
277,
304,
267,
408,
1799,
314,
6391,
2631,
1041,
267,
6391,
63,
2227,
63,
807,
275,
469,
288,
283,
1317,
63,
466,
7,
520,
291,
14,
576,
14,
362,
480,
1317,
63,
466,
401,
16241,
288,
283,
785,
63,
2051,
7,
520,
291,
14,
576,
14,
362,
480,
785,
63,
2051,
401,
16241,
288,
283,
3954,
7,
520,
291,
14,
576,
14,
362,
480,
3954,
401,
16241,
267,
789,
267,
1420,
63,
2227,
275,
291,
14,
4208,
63,
4416,
63,
2227,
3682,
4416,
63,
2227,
63,
807,
9,
267,
3503,
63,
2227,
275,
291,
14,
8275,
63,
576,
905,
4416,
63,
2227,
937,
267,
340,
440,
4413,
63,
521,
63,
5785,
8,
2062,
63,
2227,
12,
3503,
63,
2227,
304,
288,
746,
4513,
14,
8172,
480,
7676,
2631,
1104,
3405,
2685,
267,
372,
3503,
63,
2227,
339,
347,
3633,
63,
3954,
8,
277,
304,
267,
408,
5483,
3238,
314,
4913,
5712,
1133,
4634,
12474,
334,
30,
499,
10857,
9,
315,
314,
13541,
1041,
267,
6714,
275,
291,
14,
8275,
63,
576,
905,
3954,
937,
267,
340,
900,
14,
521,
342,
446,
6714,
690,
334,
18,
627,
5212,
627,
5212,
304,
288,
746,
4513,
14,
8172,
480,
10239,
1104,
3405,
531,
267,
372,
6714,
339,
347,
3550,
63,
4416,
63,
576,
8,
277,
304,
267,
408,
6864,
282,
1211,
402,
6391,
666,
367,
298,
2747,
2,
666,
1041,
267,
4913,
275,
1109,
8,
521,
14,
521,
1012,
267,
6391,
63,
807,
275,
257,
469,
288,
283,
1317,
63,
466,
7,
221,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
2024,
395,
288,
283,
785,
63,
2051,
7,
258,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
362,
63,
2051,
63,
637,
4000,
288,
283,
3954,
7,
258,
520,
620,
8,
3954,
395,
288,
283,
4416,
63,
2227,
7,
520,
291,
14,
2747,
63,
4416,
63,
2227,
8,
3954,
395,
267,
789,
267,
372,
6391,
63,
807,
339,
347,
2536,
63,
4416,
63,
2227,
8,
277,
12,
4913,
304,
267,
408,
267,
7958,
314,
2536,
6391,
2631,
687,
291,
14,
1317,
63,
785,
267,
436,
282,
334,
11864,
9,
4913,
14,
267,
408,
398,
2536,
63,
4416,
63,
807,
275,
469,
288,
283,
1317,
63,
466,
7,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
2024,
395,
288,
283,
785,
63,
2051,
7,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
362,
63,
2051,
63,
637,
4000,
288,
283,
3954,
7,
520,
620,
8,
3954,
395,
881,
789,
267,
372,
291,
14,
4208,
63,
4416,
63,
2227,
3682,
2747,
63,
4416,
63,
807,
9,
339,
347,
3550,
63,
4416,
63,
2227,
8,
277,
12,
1564,
63,
466,
12,
909,
63,
2051,
12,
4913,
304,
267,
408,
267,
7958,
282,
29817,
6391,
2631,
687,
314,
2741,
2256,
14,
267,
408,
267,
2256,
275,
334,
1317,
63,
466,
12,
909,
63,
2051,
12,
4913,
9,
267,
790,
63,
12597,
275,
298,
1176,
14,
2828,
14,
3351,
14,
7488,
7676,
2821,
2,
267,
574,
275,
3905,
1674,
904,
8,
815,
9,
267,
372,
18641,
471,
63,
18537,
8,
498,
63,
12597,
12,
574,
680,
11453,
342,
199,
199,
533,
6819,
11347,
2821,
8,
7488,
7676,
2821,
304,
272,
408,
272,
23873,
314,
2488,
2436,
402,
314,
3721,
334,
354,
12,
3721,
12,
5423,
25860,
272,
408,
272,
536,
3515,
275,
4513,
14,
2183,
8,
1302,
9384,
985,
1288,
1390,
63,
1267,
29,
1400,
9,
272,
3031,
260,
275,
4513,
14,
16577,
8,
1302,
9384,
7035,
2287,
2237,
272,
1166,
3698,
275,
4513,
14,
17363,
8,
1302,
9384,
2632,
1288,
1415,
29,
797,
9,
272,
3721,
755,
275,
4513,
14,
2183,
8,
1302,
12397,
7488,
659,
3938,
29,
3351,
14,
1872,
6789,
12,
2511,
1390,
63,
1267,
29,
10973,
63,
4283,
63,
9127,
9,
339,
347,
664,
63,
3349,
63,
785,
8,
277,
304,
267,
408,
267,
1432,
282,
892,
334,
324,
8420,
9,
3721
] |
[
900,
199,
504,
1639,
492,
4513,
199,
504,
1639,
14,
3351,
14,
1974,
492,
4520,
2141,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
2828,
14,
10778,
14,
992,
492,
14501,
199,
504,
1639,
14,
2828,
14,
6223,
14,
992,
492,
6819,
199,
504,
1639,
14,
1208,
14,
10316,
492,
18641,
471,
63,
18537,
12,
4413,
63,
521,
63,
5785,
199,
504,
1639,
14,
1208,
14,
2991,
492,
3542,
63,
2975,
199,
504,
1639,
14,
1208,
14,
505,
492,
664,
63,
505,
63,
513,
199,
504,
1639,
14,
1208,
492,
7137,
199,
504,
1639,
14,
1208,
14,
6893,
492,
26843,
12,
10366,
12,
10366,
63,
6395,
465,
485,
199,
199,
10973,
63,
4283,
63,
9127,
275,
2519,
8,
1751,
2584,
10973,
63,
4283,
63,
9127,
297,
29664,
9,
199,
199,
533,
6819,
7676,
2821,
8,
3351,
14,
2821,
304,
272,
408,
272,
23873,
314,
6391,
17435,
83,
334,
4466,
13,
22522,
1618,
316,
9,
367,
3721,
4513,
14,
272,
408,
272,
1564,
63,
466,
221,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
25419,
9,
272,
909,
63,
2051,
258,
275,
4513,
14,
2183,
8,
3440,
29,
3351,
14,
25419,
9,
272,
4913,
258,
275,
4513,
14,
3901,
8,
3440,
29,
3351,
14,
25419,
9,
272,
6391,
63,
2227,
275,
4513,
14,
2183,
8,
827,
63,
1267,
29,
2167,
12,
1390,
63,
1267,
29,
2167,
12,
3938,
29,
3351,
14,
25419,
9,
339,
347,
636,
826,
721,
277,
12,
1347,
63,
785,
12,
666,
29,
403,
12,
2536,
29,
403,
304,
267,
291,
14,
1375,
63,
785,
275,
1347,
63,
785,
267,
340,
2536,
365,
488,
26,
288,
2536,
275,
1052,
267,
2536,
14,
873,
8,
277,
14,
4208,
63,
4416,
63,
576,
1012,
267,
1613,
8,
7488,
7676,
2821,
12,
291,
2843,
826,
721,
576,
29,
576,
12,
2536,
29,
2747,
9,
339,
347,
6391,
63,
2550,
8,
277,
304,
267,
408,
1767,
2951,
5204,
2552,
4568,
543,
6391,
624,
267,
2552,
275,
4520,
2141,
342,
267,
367,
289,
315,
2097,
72,
368,
2279,
357,
401,
298,
3954,
401,
298,
4416,
63,
2227,
6229,
288,
340,
289,
315,
291,
14,
2550,
26,
355,
2552,
59,
70,
61,
275,
291,
14,
2550,
59,
70,
61,
267,
372,
2552,
339,
347,
3633,
63,
4416,
63,
2227,
8,
277,
304,
267,
408,
1799,
314,
6391,
2631,
1041,
267,
6391,
63,
2227,
63,
807,
275,
469,
288,
283,
1317,
63,
466,
7,
520,
291,
14,
576,
14,
362,
480,
1317,
63,
466,
401,
16241,
288,
283,
785,
63,
2051,
7,
520,
291,
14,
576,
14,
362,
480,
785,
63,
2051,
401,
16241,
288,
283,
3954,
7,
520,
291,
14,
576,
14,
362,
480,
3954,
401,
16241,
267,
789,
267,
1420,
63,
2227,
275,
291,
14,
4208,
63,
4416,
63,
2227,
3682,
4416,
63,
2227,
63,
807,
9,
267,
3503,
63,
2227,
275,
291,
14,
8275,
63,
576,
905,
4416,
63,
2227,
937,
267,
340,
440,
4413,
63,
521,
63,
5785,
8,
2062,
63,
2227,
12,
3503,
63,
2227,
304,
288,
746,
4513,
14,
8172,
480,
7676,
2631,
1104,
3405,
2685,
267,
372,
3503,
63,
2227,
339,
347,
3633,
63,
3954,
8,
277,
304,
267,
408,
5483,
3238,
314,
4913,
5712,
1133,
4634,
12474,
334,
30,
499,
10857,
9,
315,
314,
13541,
1041,
267,
6714,
275,
291,
14,
8275,
63,
576,
905,
3954,
937,
267,
340,
900,
14,
521,
342,
446,
6714,
690,
334,
18,
627,
5212,
627,
5212,
304,
288,
746,
4513,
14,
8172,
480,
10239,
1104,
3405,
531,
267,
372,
6714,
339,
347,
3550,
63,
4416,
63,
576,
8,
277,
304,
267,
408,
6864,
282,
1211,
402,
6391,
666,
367,
298,
2747,
2,
666,
1041,
267,
4913,
275,
1109,
8,
521,
14,
521,
1012,
267,
6391,
63,
807,
275,
257,
469,
288,
283,
1317,
63,
466,
7,
221,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
2024,
395,
288,
283,
785,
63,
2051,
7,
258,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
362,
63,
2051,
63,
637,
4000,
288,
283,
3954,
7,
258,
520,
620,
8,
3954,
395,
288,
283,
4416,
63,
2227,
7,
520,
291,
14,
2747,
63,
4416,
63,
2227,
8,
3954,
395,
267,
789,
267,
372,
6391,
63,
807,
339,
347,
2536,
63,
4416,
63,
2227,
8,
277,
12,
4913,
304,
267,
408,
267,
7958,
314,
2536,
6391,
2631,
687,
291,
14,
1317,
63,
785,
267,
436,
282,
334,
11864,
9,
4913,
14,
267,
408,
398,
2536,
63,
4416,
63,
807,
275,
469,
288,
283,
1317,
63,
466,
7,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
2024,
395,
288,
283,
785,
63,
2051,
7,
520,
620,
8,
277,
14,
1375,
63,
785,
423,
362,
63,
2051,
63,
637,
4000,
288,
283,
3954,
7,
520,
620,
8,
3954,
395,
881,
789,
267,
372,
291,
14,
4208,
63,
4416,
63,
2227,
3682,
2747,
63,
4416,
63,
807,
9,
339,
347,
3550,
63,
4416,
63,
2227,
8,
277,
12,
1564,
63,
466,
12,
909,
63,
2051,
12,
4913,
304,
267,
408,
267,
7958,
282,
29817,
6391,
2631,
687,
314,
2741,
2256,
14,
267,
408,
267,
2256,
275,
334,
1317,
63,
466,
12,
909,
63,
2051,
12,
4913,
9,
267,
790,
63,
12597,
275,
298,
1176,
14,
2828,
14,
3351,
14,
7488,
7676,
2821,
2,
267,
574,
275,
3905,
1674,
904,
8,
815,
9,
267,
372,
18641,
471,
63,
18537,
8,
498,
63,
12597,
12,
574,
680,
11453,
342,
199,
199,
533,
6819,
11347,
2821,
8,
7488,
7676,
2821,
304,
272,
408,
272,
23873,
314,
2488,
2436,
402,
314,
3721,
334,
354,
12,
3721,
12,
5423,
25860,
272,
408,
272,
536,
3515,
275,
4513,
14,
2183,
8,
1302,
9384,
985,
1288,
1390,
63,
1267,
29,
1400,
9,
272,
3031,
260,
275,
4513,
14,
16577,
8,
1302,
9384,
7035,
2287,
2237,
272,
1166,
3698,
275,
4513,
14,
17363,
8,
1302,
9384,
2632,
1288,
1415,
29,
797,
9,
272,
3721,
755,
275,
4513,
14,
2183,
8,
1302,
12397,
7488,
659,
3938,
29,
3351,
14,
1872,
6789,
12,
2511,
1390,
63,
1267,
29,
10973,
63,
4283,
63,
9127,
9,
339,
347,
664,
63,
3349,
63,
785,
8,
277,
304,
267,
408,
267,
1432,
282,
892,
334,
324,
8420,
9,
3721,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
igemsoftware/SYSU-Software2013
|
project/Python27_32/Lib/ssl.py
|
74
|
15611
|
# Wrapper module for _ssl, providing some additional facilities
# implemented in Python. Written by Bill Janssen.
"""\
This module provides some more Pythonic support for SSL.
Object types:
SSLSocket -- subtype of socket.socket which does SSL over the socket
Exceptions:
SSLError -- exception raised for I/O errors
Functions:
cert_time_to_seconds -- convert time string used for certificate
notBefore and notAfter functions to integer
seconds past the Epoch (the time values
returned from time.time())
fetch_server_certificate (HOST, PORT) -- fetch the certificate provided
by the server running on HOST at port PORT. No
validation of the certificate is performed.
Integer constants:
SSL_ERROR_ZERO_RETURN
SSL_ERROR_WANT_READ
SSL_ERROR_WANT_WRITE
SSL_ERROR_WANT_X509_LOOKUP
SSL_ERROR_SYSCALL
SSL_ERROR_SSL
SSL_ERROR_WANT_CONNECT
SSL_ERROR_EOF
SSL_ERROR_INVALID_ERROR_CODE
The following group define certificate requirements that one side is
allowing/requiring from the other side:
CERT_NONE - no certificates from the other side are required (or will
be looked at if provided)
CERT_OPTIONAL - certificates are not required, but if provided will be
validated, and if validation fails, the connection will
also fail
CERT_REQUIRED - certificates are required, and will be validated, and
if validation fails, the connection will also fail
The following constants identify various SSL protocol variants:
PROTOCOL_SSLv2
PROTOCOL_SSLv3
PROTOCOL_SSLv23
PROTOCOL_TLSv1
"""
import textwrap
import _ssl # if we can't import it, let the error propagate
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
from _ssl import SSLError
from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
from _ssl import RAND_status, RAND_egd, RAND_add
from _ssl import \
SSL_ERROR_ZERO_RETURN, \
SSL_ERROR_WANT_READ, \
SSL_ERROR_WANT_WRITE, \
SSL_ERROR_WANT_X509_LOOKUP, \
SSL_ERROR_SYSCALL, \
SSL_ERROR_SSL, \
SSL_ERROR_WANT_CONNECT, \
SSL_ERROR_EOF, \
SSL_ERROR_INVALID_ERROR_CODE
from _ssl import PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1
_PROTOCOL_NAMES = {
PROTOCOL_TLSv1: "TLSv1",
PROTOCOL_SSLv23: "SSLv23",
PROTOCOL_SSLv3: "SSLv3",
}
try:
from _ssl import PROTOCOL_SSLv2
except ImportError:
pass
else:
_PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2"
from socket import socket, _fileobject, _delegate_methods, error as socket_error
from socket import getnameinfo as _getnameinfo
import base64 # for DER-to-PEM translation
import errno
class SSLSocket(socket):
"""This class implements a subtype of socket.socket that wraps
the underlying OS socket in an SSL context when necessary, and
provides read and write methods over that channel."""
def __init__(self, sock, keyfile=None, certfile=None,
server_side=False, cert_reqs=CERT_NONE,
ssl_version=PROTOCOL_SSLv23, ca_certs=None,
do_handshake_on_connect=True,
suppress_ragged_eofs=True, ciphers=None):
socket.__init__(self, _sock=sock._sock)
# The initializer for socket overrides the methods send(), recv(), etc.
# in the instancce, which we don't need -- but we want to provide the
# methods defined in SSLSocket.
for attr in _delegate_methods:
try:
delattr(self, attr)
except AttributeError:
pass
if certfile and not keyfile:
keyfile = certfile
# see if it's connected
try:
socket.getpeername(self)
except socket_error, e:
if e.errno != errno.ENOTCONN:
raise
# no, no connection yet
self._connected = False
self._sslobj = None
else:
# yes, create the SSL object
self._connected = True
self._sslobj = _ssl.sslwrap(self._sock, server_side,
keyfile, certfile,
cert_reqs, ssl_version, ca_certs,
ciphers)
if do_handshake_on_connect:
self.do_handshake()
self.keyfile = keyfile
self.certfile = certfile
self.cert_reqs = cert_reqs
self.ssl_version = ssl_version
self.ca_certs = ca_certs
self.ciphers = ciphers
self.do_handshake_on_connect = do_handshake_on_connect
self.suppress_ragged_eofs = suppress_ragged_eofs
self._makefile_refs = 0
def read(self, len=1024):
"""Read up to LEN bytes and return them.
Return zero-length string on EOF."""
try:
return self._sslobj.read(len)
except SSLError, x:
if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
return ''
else:
raise
def write(self, data):
"""Write DATA to the underlying SSL channel. Returns
number of bytes of DATA actually transmitted."""
return self._sslobj.write(data)
def getpeercert(self, binary_form=False):
"""Returns a formatted version of the data in the
certificate provided by the other end of the SSL channel.
Return None if no certificate was provided, {} if a
certificate was provided, but not validated."""
return self._sslobj.peer_certificate(binary_form)
def cipher(self):
if not self._sslobj:
return None
else:
return self._sslobj.cipher()
def send(self, data, flags=0):
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to send() on %s" %
self.__class__)
while True:
try:
v = self._sslobj.write(data)
except SSLError, x:
if x.args[0] == SSL_ERROR_WANT_READ:
return 0
elif x.args[0] == SSL_ERROR_WANT_WRITE:
return 0
else:
raise
else:
return v
else:
return self._sock.send(data, flags)
def sendto(self, data, flags_or_addr, addr=None):
if self._sslobj:
raise ValueError("sendto not allowed on instances of %s" %
self.__class__)
elif addr is None:
return self._sock.sendto(data, flags_or_addr)
else:
return self._sock.sendto(data, flags_or_addr, addr)
def sendall(self, data, flags=0):
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to sendall() on %s" %
self.__class__)
amount = len(data)
count = 0
while (count < amount):
v = self.send(data[count:])
count += v
return amount
else:
return socket.sendall(self, data, flags)
def recv(self, buflen=1024, flags=0):
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to recv() on %s" %
self.__class__)
return self.read(buflen)
else:
return self._sock.recv(buflen, flags)
def recv_into(self, buffer, nbytes=None, flags=0):
if buffer and (nbytes is None):
nbytes = len(buffer)
elif nbytes is None:
nbytes = 1024
if self._sslobj:
if flags != 0:
raise ValueError(
"non-zero flags not allowed in calls to recv_into() on %s" %
self.__class__)
tmp_buffer = self.read(nbytes)
v = len(tmp_buffer)
buffer[:v] = tmp_buffer
return v
else:
return self._sock.recv_into(buffer, nbytes, flags)
def recvfrom(self, buflen=1024, flags=0):
if self._sslobj:
raise ValueError("recvfrom not allowed on instances of %s" %
self.__class__)
else:
return self._sock.recvfrom(buflen, flags)
def recvfrom_into(self, buffer, nbytes=None, flags=0):
if self._sslobj:
raise ValueError("recvfrom_into not allowed on instances of %s" %
self.__class__)
else:
return self._sock.recvfrom_into(buffer, nbytes, flags)
def pending(self):
if self._sslobj:
return self._sslobj.pending()
else:
return 0
def unwrap(self):
if self._sslobj:
s = self._sslobj.shutdown()
self._sslobj = None
return s
else:
raise ValueError("No SSL wrapper around " + str(self))
def shutdown(self, how):
self._sslobj = None
socket.shutdown(self, how)
def close(self):
if self._makefile_refs < 1:
self._sslobj = None
socket.close(self)
else:
self._makefile_refs -= 1
def do_handshake(self):
"""Perform a TLS/SSL handshake."""
self._sslobj.do_handshake()
def _real_connect(self, addr, return_errno):
# Here we assume that the socket is client-side, and not
# connected at the time of the call. We connect it, then wrap it.
if self._connected:
raise ValueError("attempt to connect already-connected SSLSocket!")
self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile,
self.cert_reqs, self.ssl_version,
self.ca_certs, self.ciphers)
try:
socket.connect(self, addr)
if self.do_handshake_on_connect:
self.do_handshake()
except socket_error as e:
if return_errno:
return e.errno
else:
self._sslobj = None
raise e
self._connected = True
return 0
def connect(self, addr):
"""Connects to remote ADDR, and then wraps the connection in
an SSL channel."""
self._real_connect(addr, False)
def connect_ex(self, addr):
"""Connects to remote ADDR, and then wraps the connection in
an SSL channel."""
return self._real_connect(addr, True)
def accept(self):
"""Accepts a new connection from a remote client, and returns
a tuple containing that new connection wrapped with a server-side
SSL channel, and the address of the remote client."""
newsock, addr = socket.accept(self)
return (SSLSocket(newsock,
keyfile=self.keyfile,
certfile=self.certfile,
server_side=True,
cert_reqs=self.cert_reqs,
ssl_version=self.ssl_version,
ca_certs=self.ca_certs,
ciphers=self.ciphers,
do_handshake_on_connect=self.do_handshake_on_connect,
suppress_ragged_eofs=self.suppress_ragged_eofs),
addr)
def makefile(self, mode='r', bufsize=-1):
"""Make and return a file-like object that
works with the SSL connection. Just use the code
from the socket module."""
self._makefile_refs += 1
# close=True so as to decrement the reference count when done with
# the file-like object.
return _fileobject(self, mode, bufsize, close=True)
def wrap_socket(sock, keyfile=None, certfile=None,
server_side=False, cert_reqs=CERT_NONE,
ssl_version=PROTOCOL_SSLv23, ca_certs=None,
do_handshake_on_connect=True,
suppress_ragged_eofs=True, ciphers=None):
return SSLSocket(sock, keyfile=keyfile, certfile=certfile,
server_side=server_side, cert_reqs=cert_reqs,
ssl_version=ssl_version, ca_certs=ca_certs,
do_handshake_on_connect=do_handshake_on_connect,
suppress_ragged_eofs=suppress_ragged_eofs,
ciphers=ciphers)
# some utility functions
def cert_time_to_seconds(cert_time):
"""Takes a date-time string in standard ASN1_print form
("MON DAY 24HOUR:MINUTE:SEC YEAR TIMEZONE") and return
a Python time value in seconds past the epoch."""
import time
return time.mktime(time.strptime(cert_time, "%b %d %H:%M:%S %Y GMT"))
PEM_HEADER = "-----BEGIN CERTIFICATE-----"
PEM_FOOTER = "-----END CERTIFICATE-----"
def DER_cert_to_PEM_cert(der_cert_bytes):
"""Takes a certificate in binary DER format and returns the
PEM version of it as a string."""
if hasattr(base64, 'standard_b64encode'):
# preferred because older API gets line-length wrong
f = base64.standard_b64encode(der_cert_bytes)
return (PEM_HEADER + '\n' +
textwrap.fill(f, 64) + '\n' +
PEM_FOOTER + '\n')
else:
return (PEM_HEADER + '\n' +
base64.encodestring(der_cert_bytes) +
PEM_FOOTER + '\n')
def PEM_cert_to_DER_cert(pem_cert_string):
"""Takes a certificate in ASCII PEM format and returns the
DER-encoded version of it as a byte sequence"""
if not pem_cert_string.startswith(PEM_HEADER):
raise ValueError("Invalid PEM encoding; must start with %s"
% PEM_HEADER)
if not pem_cert_string.strip().endswith(PEM_FOOTER):
raise ValueError("Invalid PEM encoding; must end with %s"
% PEM_FOOTER)
d = pem_cert_string.strip()[len(PEM_HEADER):-len(PEM_FOOTER)]
return base64.decodestring(d)
def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
"""Retrieve the certificate from the server at the specified address,
and return it as a PEM-encoded string.
If 'ca_certs' is specified, validate the server cert against it.
If 'ssl_version' is specified, use it in the connection attempt."""
host, port = addr
if (ca_certs is not None):
cert_reqs = CERT_REQUIRED
else:
cert_reqs = CERT_NONE
s = wrap_socket(socket(), ssl_version=ssl_version,
cert_reqs=cert_reqs, ca_certs=ca_certs)
s.connect(addr)
dercert = s.getpeercert(True)
s.close()
return DER_cert_to_PEM_cert(dercert)
def get_protocol_name(protocol_code):
return _PROTOCOL_NAMES.get(protocol_code, '<unknown>')
# a replacement for the old socket.ssl function
def sslwrap_simple(sock, keyfile=None, certfile=None):
"""A replacement for the old socket.ssl function. Designed
for compability with Python 2.5 and earlier. Will disappear in
Python 3.0."""
if hasattr(sock, "_sock"):
sock = sock._sock
ssl_sock = _ssl.sslwrap(sock, 0, keyfile, certfile, CERT_NONE,
PROTOCOL_SSLv23, None)
try:
sock.getpeername()
except socket_error:
# no, no connection yet
pass
else:
# yes, do the handshake
ssl_sock.do_handshake()
return ssl_sock
|
mit
|
[
3,
21947,
859,
367,
485,
4266,
12,
13070,
2005,
4722,
30242,
7999,
199,
3,
6366,
315,
2018,
14,
221,
27694,
701,
699,
778,
1603,
796,
2464,
14,
199,
199,
19659,
199,
2765,
859,
6571,
2005,
1655,
2018,
530,
2291,
367,
7799,
14,
199,
199,
1692,
2943,
26,
819,
7799,
3869,
1553,
15686,
402,
2838,
14,
3450,
1314,
1630,
7799,
1806,
314,
2838,
199,
199,
16836,
26,
819,
7799,
547,
1553,
1919,
4915,
367,
473,
15,
47,
2552,
199,
199,
13967,
26,
819,
6250,
63,
521,
63,
475,
63,
4515,
1553,
3957,
900,
1059,
1202,
367,
5897,
2079,
440,
13569,
436,
440,
10881,
3423,
370,
3000,
2079,
4696,
13541,
314,
662,
5132,
334,
1589,
900,
1338,
2079,
2138,
687,
900,
14,
521,
1012,
819,
5267,
63,
1000,
63,
6999,
334,
5449,
12,
25562,
9,
1553,
5267,
314,
5897,
2741,
2079,
701,
314,
1654,
3879,
641,
25741,
737,
1844,
25562,
14,
221,
3091,
2079,
6411,
402,
314,
5897,
365,
10585,
14,
199,
199,
2674,
5262,
26,
199,
199,
5413,
63,
3170,
63,
24655,
63,
9677,
199,
5413,
63,
3170,
63,
55,
1441,
63,
5670,
199,
5413,
63,
3170,
63,
55,
1441,
63,
10387,
199,
5413,
63,
3170,
63,
55,
1441,
63,
56,
6576,
63,
29149,
199,
5413,
63,
3170,
63,
4669,
5153,
1761,
199,
5413,
63,
3170,
63,
5413,
199,
5413,
63,
3170,
63,
55,
1441,
63,
14657,
199,
199,
5413,
63,
3170,
63,
13178,
199,
5413,
63,
3170,
63,
9692,
63,
3170,
63,
6012,
199,
199,
1918,
2569,
1572,
5627,
5897,
9760,
626,
1373,
5366,
365,
199,
3306,
316,
15,
264,
23729,
687,
314,
1163,
5366,
26,
199,
199,
11163,
63,
9185,
446,
949,
14512,
687,
314,
1163,
5366,
787,
1415,
334,
269,
911,
288,
506,
21182,
737,
340,
2741,
9,
199,
11163,
63,
21008,
446,
14512,
787,
440,
1415,
12,
1325,
340,
2741,
911,
506,
355,
16468,
12,
436,
340,
6411,
6918,
12,
314,
1950,
911,
355,
2597,
2449,
199,
11163,
63,
12496,
446,
14512,
787,
1415,
12,
436,
911,
506,
16468,
12,
436,
355,
340,
6411,
6918,
12,
314,
1950,
911,
2597,
2449,
199,
199,
1918,
2569,
5262,
10405,
7750,
7799,
4113,
21169,
26,
199,
199,
9583,
63,
21082,
18,
199,
9583,
63,
21082,
19,
199,
9583,
63,
21082,
1789,
199,
9583,
63,
10224,
86,
17,
199,
624,
199,
199,
646,
13390,
199,
199,
646,
485,
4266,
3777,
327,
340,
781,
883,
1133,
492,
652,
12,
4691,
314,
1125,
19843,
199,
199,
504,
485,
4266,
492,
24164,
5413,
63,
4612,
63,
9190,
12,
24164,
5413,
63,
4612,
63,
4531,
12,
24164,
5413,
63,
4612,
199,
504,
485,
4266,
492,
7799,
547,
199,
504,
485,
4266,
492,
28313,
63,
9185,
12,
28313,
63,
21008,
12,
28313,
63,
12496,
199,
504,
485,
4266,
492,
820,
3649,
63,
1205,
12,
820,
3649,
63,
5902,
68,
12,
820,
3649,
63,
525,
199,
504,
485,
4266,
492,
971,
1362,
7799,
63,
3170,
63,
24655,
63,
9677,
12,
971,
1362,
7799,
63,
3170,
63,
55,
1441,
63,
5670,
12,
971,
1362,
7799,
63,
3170,
63,
55,
1441,
63,
10387,
12,
971,
1362,
7799,
63,
3170,
63,
55,
1441,
63,
56,
6576,
63,
29149,
12,
971,
1362,
7799,
63,
3170,
63,
4669,
5153,
1761,
12,
971,
1362,
7799,
63,
3170,
63,
5413,
12,
971,
1362,
7799,
63,
3170,
63,
55,
1441,
63,
14657,
12,
971,
1362,
7799,
63,
3170,
63,
13178,
12,
971,
1362,
7799,
63,
3170,
63,
9692,
63,
3170,
63,
6012,
199,
504,
485,
4266,
492,
3611,
2566,
3978,
63,
21082,
19,
12,
3611,
2566,
3978,
63,
21082,
1789,
12,
3611,
2566,
3978,
63,
10224,
86,
17,
199,
63,
9583,
63,
14546,
275,
469,
272,
3611,
2566,
3978,
63,
10224,
86,
17,
26,
298,
10224,
86,
17,
401,
272,
3611,
2566,
3978,
63,
21082,
1789,
26,
298,
21082,
1789,
401,
272,
3611,
2566,
3978,
63,
21082,
19,
26,
298,
21082,
19,
401,
199,
93,
199,
893,
26,
272,
687,
485,
4266,
492,
3611,
2566,
3978,
63,
21082,
18,
199,
2590,
3545,
26,
272,
986,
199,
2836,
26,
272,
485,
9583,
63,
14546,
59,
9583,
63,
21082,
18,
61,
275,
298,
21082,
18,
2,
199,
199,
504,
2838,
492,
2838,
12,
485,
493,
785,
12,
485,
15286,
63,
2474,
12,
1125,
465,
2838,
63,
705,
199,
504,
2838,
492,
664,
354,
815,
465,
485,
362,
354,
815,
199,
646,
1300,
772,
263,
327,
367,
577,
540,
13,
475,
13,
24160,
7761,
199,
646,
7554,
199,
199,
533,
7799,
3869,
8,
3450,
304,
339,
408,
2765,
1021,
9031,
282,
15686,
402,
2838,
14,
3450,
626,
14018,
272,
314,
8793,
4403,
2838,
315,
376,
7799,
1067,
1380,
5784,
12,
436,
272,
6571,
1586,
436,
2218,
3102,
1806,
626,
3623,
1041,
339,
347,
636,
826,
721,
277,
12,
6771,
12,
25776,
29,
403,
12,
27660,
29,
403,
12,
326,
1654,
63,
2441,
29,
797,
12,
6250,
63,
12720,
29,
11163,
63,
9185,
12,
326,
6149,
63,
1023,
29,
9583,
63,
21082,
1789,
12,
1704,
63,
8356,
29,
403,
12,
326,
886,
63,
11913,
63,
265,
63,
2242,
29,
549,
12,
326,
15678,
63,
24359,
63,
11670,
83,
29,
549,
12,
30377,
29,
403,
304,
267,
2838,
855,
826,
721,
277,
12,
485,
5096,
29,
5096,
423,
5096,
9,
267,
327,
710,
11130,
367,
2838,
10580,
314,
3102,
3222,
1062,
11904,
1062,
5423,
14,
267,
327,
315,
314,
2727,
18595,
301,
12,
1314,
781,
2793,
1133,
1929,
1553,
1325,
781,
2934,
370,
5647,
314,
267,
327,
3102,
3247,
315,
7799,
3869,
14,
267,
367,
1921,
315,
485,
15286,
63,
2474,
26,
288,
862,
26,
355,
24358,
8,
277,
12,
1921,
9,
288,
871,
4281,
26,
355,
986,
398,
340,
27660,
436,
440,
25776,
26,
288,
25776,
275,
27660,
267,
327,
1937,
340,
652,
1159,
8539,
267,
862,
26,
288,
2838,
14,
362,
7866,
354,
8,
277,
9,
267,
871,
2838,
63,
705,
12,
325,
26,
288,
340,
325,
14,
7931,
1137,
7554,
14,
32710,
17489,
26,
355,
746,
288,
327,
949,
12,
949,
1950,
5966,
288,
291,
423,
7113,
275,
756,
288,
291,
423,
385,
25678,
275,
488,
267,
587,
26,
288,
327,
9456,
12,
1218,
314,
7799,
909,
288,
291,
423,
7113,
275,
715,
288,
291,
423,
385,
25678,
275,
485,
4266
] |
[
21947,
859,
367,
485,
4266,
12,
13070,
2005,
4722,
30242,
7999,
199,
3,
6366,
315,
2018,
14,
221,
27694,
701,
699,
778,
1603,
796,
2464,
14,
199,
199,
19659,
199,
2765,
859,
6571,
2005,
1655,
2018,
530,
2291,
367,
7799,
14,
199,
199,
1692,
2943,
26,
819,
7799,
3869,
1553,
15686,
402,
2838,
14,
3450,
1314,
1630,
7799,
1806,
314,
2838,
199,
199,
16836,
26,
819,
7799,
547,
1553,
1919,
4915,
367,
473,
15,
47,
2552,
199,
199,
13967,
26,
819,
6250,
63,
521,
63,
475,
63,
4515,
1553,
3957,
900,
1059,
1202,
367,
5897,
2079,
440,
13569,
436,
440,
10881,
3423,
370,
3000,
2079,
4696,
13541,
314,
662,
5132,
334,
1589,
900,
1338,
2079,
2138,
687,
900,
14,
521,
1012,
819,
5267,
63,
1000,
63,
6999,
334,
5449,
12,
25562,
9,
1553,
5267,
314,
5897,
2741,
2079,
701,
314,
1654,
3879,
641,
25741,
737,
1844,
25562,
14,
221,
3091,
2079,
6411,
402,
314,
5897,
365,
10585,
14,
199,
199,
2674,
5262,
26,
199,
199,
5413,
63,
3170,
63,
24655,
63,
9677,
199,
5413,
63,
3170,
63,
55,
1441,
63,
5670,
199,
5413,
63,
3170,
63,
55,
1441,
63,
10387,
199,
5413,
63,
3170,
63,
55,
1441,
63,
56,
6576,
63,
29149,
199,
5413,
63,
3170,
63,
4669,
5153,
1761,
199,
5413,
63,
3170,
63,
5413,
199,
5413,
63,
3170,
63,
55,
1441,
63,
14657,
199,
199,
5413,
63,
3170,
63,
13178,
199,
5413,
63,
3170,
63,
9692,
63,
3170,
63,
6012,
199,
199,
1918,
2569,
1572,
5627,
5897,
9760,
626,
1373,
5366,
365,
199,
3306,
316,
15,
264,
23729,
687,
314,
1163,
5366,
26,
199,
199,
11163,
63,
9185,
446,
949,
14512,
687,
314,
1163,
5366,
787,
1415,
334,
269,
911,
288,
506,
21182,
737,
340,
2741,
9,
199,
11163,
63,
21008,
446,
14512,
787,
440,
1415,
12,
1325,
340,
2741,
911,
506,
355,
16468,
12,
436,
340,
6411,
6918,
12,
314,
1950,
911,
355,
2597,
2449,
199,
11163,
63,
12496,
446,
14512,
787,
1415,
12,
436,
911,
506,
16468,
12,
436,
355,
340,
6411,
6918,
12,
314,
1950,
911,
2597,
2449,
199,
199,
1918,
2569,
5262,
10405,
7750,
7799,
4113,
21169,
26,
199,
199,
9583,
63,
21082,
18,
199,
9583,
63,
21082,
19,
199,
9583,
63,
21082,
1789,
199,
9583,
63,
10224,
86,
17,
199,
624,
199,
199,
646,
13390,
199,
199,
646,
485,
4266,
3777,
327,
340,
781,
883,
1133,
492,
652,
12,
4691,
314,
1125,
19843,
199,
199,
504,
485,
4266,
492,
24164,
5413,
63,
4612,
63,
9190,
12,
24164,
5413,
63,
4612,
63,
4531,
12,
24164,
5413,
63,
4612,
199,
504,
485,
4266,
492,
7799,
547,
199,
504,
485,
4266,
492,
28313,
63,
9185,
12,
28313,
63,
21008,
12,
28313,
63,
12496,
199,
504,
485,
4266,
492,
820,
3649,
63,
1205,
12,
820,
3649,
63,
5902,
68,
12,
820,
3649,
63,
525,
199,
504,
485,
4266,
492,
971,
1362,
7799,
63,
3170,
63,
24655,
63,
9677,
12,
971,
1362,
7799,
63,
3170,
63,
55,
1441,
63,
5670,
12,
971,
1362,
7799,
63,
3170,
63,
55,
1441,
63,
10387,
12,
971,
1362,
7799,
63,
3170,
63,
55,
1441,
63,
56,
6576,
63,
29149,
12,
971,
1362,
7799,
63,
3170,
63,
4669,
5153,
1761,
12,
971,
1362,
7799,
63,
3170,
63,
5413,
12,
971,
1362,
7799,
63,
3170,
63,
55,
1441,
63,
14657,
12,
971,
1362,
7799,
63,
3170,
63,
13178,
12,
971,
1362,
7799,
63,
3170,
63,
9692,
63,
3170,
63,
6012,
199,
504,
485,
4266,
492,
3611,
2566,
3978,
63,
21082,
19,
12,
3611,
2566,
3978,
63,
21082,
1789,
12,
3611,
2566,
3978,
63,
10224,
86,
17,
199,
63,
9583,
63,
14546,
275,
469,
272,
3611,
2566,
3978,
63,
10224,
86,
17,
26,
298,
10224,
86,
17,
401,
272,
3611,
2566,
3978,
63,
21082,
1789,
26,
298,
21082,
1789,
401,
272,
3611,
2566,
3978,
63,
21082,
19,
26,
298,
21082,
19,
401,
199,
93,
199,
893,
26,
272,
687,
485,
4266,
492,
3611,
2566,
3978,
63,
21082,
18,
199,
2590,
3545,
26,
272,
986,
199,
2836,
26,
272,
485,
9583,
63,
14546,
59,
9583,
63,
21082,
18,
61,
275,
298,
21082,
18,
2,
199,
199,
504,
2838,
492,
2838,
12,
485,
493,
785,
12,
485,
15286,
63,
2474,
12,
1125,
465,
2838,
63,
705,
199,
504,
2838,
492,
664,
354,
815,
465,
485,
362,
354,
815,
199,
646,
1300,
772,
263,
327,
367,
577,
540,
13,
475,
13,
24160,
7761,
199,
646,
7554,
199,
199,
533,
7799,
3869,
8,
3450,
304,
339,
408,
2765,
1021,
9031,
282,
15686,
402,
2838,
14,
3450,
626,
14018,
272,
314,
8793,
4403,
2838,
315,
376,
7799,
1067,
1380,
5784,
12,
436,
272,
6571,
1586,
436,
2218,
3102,
1806,
626,
3623,
1041,
339,
347,
636,
826,
721,
277,
12,
6771,
12,
25776,
29,
403,
12,
27660,
29,
403,
12,
326,
1654,
63,
2441,
29,
797,
12,
6250,
63,
12720,
29,
11163,
63,
9185,
12,
326,
6149,
63,
1023,
29,
9583,
63,
21082,
1789,
12,
1704,
63,
8356,
29,
403,
12,
326,
886,
63,
11913,
63,
265,
63,
2242,
29,
549,
12,
326,
15678,
63,
24359,
63,
11670,
83,
29,
549,
12,
30377,
29,
403,
304,
267,
2838,
855,
826,
721,
277,
12,
485,
5096,
29,
5096,
423,
5096,
9,
267,
327,
710,
11130,
367,
2838,
10580,
314,
3102,
3222,
1062,
11904,
1062,
5423,
14,
267,
327,
315,
314,
2727,
18595,
301,
12,
1314,
781,
2793,
1133,
1929,
1553,
1325,
781,
2934,
370,
5647,
314,
267,
327,
3102,
3247,
315,
7799,
3869,
14,
267,
367,
1921,
315,
485,
15286,
63,
2474,
26,
288,
862,
26,
355,
24358,
8,
277,
12,
1921,
9,
288,
871,
4281,
26,
355,
986,
398,
340,
27660,
436,
440,
25776,
26,
288,
25776,
275,
27660,
267,
327,
1937,
340,
652,
1159,
8539,
267,
862,
26,
288,
2838,
14,
362,
7866,
354,
8,
277,
9,
267,
871,
2838,
63,
705,
12,
325,
26,
288,
340,
325,
14,
7931,
1137,
7554,
14,
32710,
17489,
26,
355,
746,
288,
327,
949,
12,
949,
1950,
5966,
288,
291,
423,
7113,
275,
756,
288,
291,
423,
385,
25678,
275,
488,
267,
587,
26,
288,
327,
9456,
12,
1218,
314,
7799,
909,
288,
291,
423,
7113,
275,
715,
288,
291,
423,
385,
25678,
275,
485,
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,
1,
1,
1
] |
moazzemi/HAMEX
|
cpu/gem5/src/cpu/TimingExpr.py
|
56
|
5954
|
# Copyright (c) 2013-2014 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual
# property including but not limited to intellectual property relating
# to a hardware implementation of the functionality of the software
# licensed hereunder. You may use the software subject to the license
# terms below provided that you ensure that this notice is replicated
# unmodified and in its entirety in all distributions of the software,
# modified or unmodified, in source code or in binary form.
#
# 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 copyright holders 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.
#
# Authors: Andrew Bardsley
from m5.params import *
from m5.SimObject import SimObject
# These classes define an expression language over uint64_t with only
# a few operators. This can be used to form expressions for the extra
# delay required in variable execution time instructions.
#
# Expressions, in evaluation, will have access to the ThreadContext and
# a StaticInst
class TimingExpr(SimObject):
type = 'TimingExpr'
cxx_header = 'cpu/timing_expr.hh'
abstract = True;
class TimingExprLiteral(TimingExpr):
"""Literal 64 bit unsigned value"""
type = 'TimingExprLiteral'
cxx_header = 'cpu/timing_expr.hh'
value = Param.UInt64("literal value")
def set_params(self, value):
self.value = value
return self
class TimingExpr0(TimingExprLiteral):
"""Convenient 0"""
value = 0
class TimingExprSrcReg(TimingExpr):
"""Find the source register number from the current inst"""
type = 'TimingExprSrcReg'
cxx_header = 'cpu/timing_expr.hh'
# index = Param.Unsigned("index into inst src regs")
index = Param.Unsigned("index into inst src regs")
def set_params(self, index):
self.index = index
return self
class TimingExprReadIntReg(TimingExpr):
"""Read an architectural register"""
type = 'TimingExprReadIntReg'
cxx_header = 'cpu/timing_expr.hh'
reg = Param.TimingExpr("register raw index to read")
def set_params(self, reg):
self.reg = reg
return self
class TimingExprLet(TimingExpr):
"""Block of declarations"""
type = 'TimingExprLet'
cxx_header = 'cpu/timing_expr.hh'
defns = VectorParam.TimingExpr("expressions for bindings")
expr = Param.TimingExpr("body expression")
def set_params(self, defns, expr):
self.defns = defns
self.expr = expr
return self
class TimingExprRef(TimingExpr):
"""Value of a bound sub-expression"""
type = 'TimingExprRef'
cxx_header = 'cpu/timing_expr.hh'
index = Param.Unsigned("expression index")
def set_params(self, index):
self.index = index
return self
class TimingExprOp(Enum):
vals = [
'timingExprAdd', 'timingExprSub',
'timingExprUMul', 'timingExprUDiv',
'timingExprSMul', 'timingExprSDiv',
'timingExprUCeilDiv', # Unsigned divide rounding up
'timingExprEqual', 'timingExprNotEqual',
'timingExprULessThan',
'timingExprUGreaterThan',
'timingExprSLessThan',
'timingExprSGreaterThan',
'timingExprInvert',
'timingExprNot',
'timingExprAnd',
'timingExprOr',
'timingExprSizeInBits',
'timingExprSignExtend32To64',
'timingExprAbs'
]
class TimingExprUn(TimingExpr):
"""Unary operator"""
type = 'TimingExprUn'
cxx_header = 'cpu/timing_expr.hh'
op = Param.TimingExprOp("operator")
arg = Param.TimingExpr("expression")
def set_params(self, op, arg):
self.op = op
self.arg = arg
return self
class TimingExprBin(TimingExpr):
"""Binary operator"""
type = 'TimingExprBin'
cxx_header = 'cpu/timing_expr.hh'
op = Param.TimingExprOp("operator")
left = Param.TimingExpr("LHS expression")
right = Param.TimingExpr("RHS expression")
def set_params(self, op, left, right):
self.op = op
self.left = left
self.right = right
return self
class TimingExprIf(TimingExpr):
"""If-then-else operator"""
type = 'TimingExprIf'
cxx_header = 'cpu/timing_expr.hh'
cond = Param.TimingExpr("condition expression")
trueExpr = Param.TimingExpr("true expression")
falseExpr = Param.TimingExpr("false expression")
def set_params(self, cond, trueExpr, falseExpr):
self.cond = cond
self.trueExpr = trueExpr
self.falseExpr = falseExpr
return self
|
mit
|
[
3,
1898,
334,
67,
9,
6171,
13,
7280,
27155,
23954,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
710,
4190,
5084,
16879,
1454,
370,
4248,
315,
314,
2032,
436,
10989,
199,
3,
440,
506,
950,
431,
68,
465,
16085,
316,
282,
4190,
370,
1263,
1163,
27925,
1264,
1061,
199,
3,
3324,
5893,
1325,
440,
13988,
370,
27925,
1264,
1061,
3324,
4668,
1958,
199,
3,
370,
282,
14991,
4514,
402,
314,
9330,
402,
314,
2032,
199,
3,
18233,
2348,
7138,
14,
221,
2047,
1443,
675,
314,
2032,
5420,
370,
314,
4190,
199,
3,
2895,
5084,
2741,
626,
1265,
4868,
626,
642,
4245,
365,
32436,
199,
3,
24214,
436,
315,
2399,
8039,
369,
315,
1006,
10208,
402,
314,
2032,
12,
199,
3,
6042,
503,
24214,
12,
315,
1350,
1233,
503,
315,
3366,
1824,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
26771,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
27,
199,
3,
26771,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
27,
199,
3,
15564,
314,
536,
402,
314,
4248,
31976,
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,
3,
199,
3,
6642,
26,
6061,
5257,
699,
5596,
15515,
199,
199,
504,
333,
21,
14,
1162,
492,
627,
199,
504,
333,
21,
14,
7467,
1692,
492,
10751,
1692,
199,
199,
3,
5723,
3992,
5627,
376,
3965,
2637,
1806,
3152,
772,
63,
84,
543,
1454,
199,
3,
282,
9284,
10211,
14,
221,
961,
883,
506,
1202,
370,
1824,
8455,
367,
314,
2402,
199,
3,
7339,
1415,
315,
1750,
6451,
900,
15794,
14,
199,
3,
199,
3,
7910,
6274,
12,
315,
11735,
12,
911,
1172,
2879,
370,
314,
11086,
2998,
436,
199,
3,
282,
13599,
10083,
199,
199,
533,
26244,
316,
8561,
8,
7467,
1692,
304,
272,
730,
275,
283,
30101,
8561,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
272,
9006,
275,
715,
27,
199,
199,
533,
26244,
316,
8561,
7621,
8,
30101,
8561,
304,
272,
408,
7621,
5049,
4546,
7381,
574,
624,
272,
730,
275,
283,
30101,
8561,
7621,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
574,
275,
12608,
14,
13304,
772,
480,
8939,
574,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
574,
304,
267,
291,
14,
585,
275,
574,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
16,
8,
30101,
8561,
7621,
304,
272,
408,
714,
1856,
6792,
378,
624,
272,
574,
275,
378,
199,
199,
533,
26244,
316,
8561,
21261,
2872,
8,
30101,
8561,
304,
272,
408,
6591,
314,
1350,
2274,
1329,
687,
314,
1453,
2727,
624,
272,
730,
275,
283,
30101,
8561,
21261,
2872,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
327,
1478,
275,
12608,
14,
25269,
480,
1080,
1901,
2727,
2928,
295,
458,
531,
272,
1478,
275,
12608,
14,
25269,
480,
1080,
1901,
2727,
2928,
295,
458,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
1478,
304,
267,
291,
14,
1080,
275,
1478,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
3284,
3241,
2872,
8,
30101,
8561,
304,
272,
408,
3284,
376,
3819,
1175,
319,
4889,
2274,
624,
272,
730,
275,
283,
30101,
8561,
3284,
3241,
2872,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
1295,
275,
12608,
14,
30101,
8561,
480,
2683,
3066,
1478,
370,
1586,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
1295,
304,
267,
291,
14,
1135,
275,
1295,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
15314,
8,
30101,
8561,
304,
272,
408,
3142,
402,
18707,
624,
272,
730,
275,
283,
30101,
8561,
15314,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
347,
561,
275,
11388,
4098,
14,
30101,
8561,
480,
15264,
367,
17792,
531,
272,
5348,
275,
12608,
14,
30101,
8561,
480,
2030,
3965,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
347,
561,
12,
5348,
304,
267,
291,
14,
318,
561,
275,
347,
561,
267,
291,
14,
3684,
275,
5348,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
2891,
8,
30101,
8561,
304,
272,
408,
1110,
402,
282,
3914,
1007,
13,
5599,
624,
272,
730,
275,
283,
30101,
8561,
2891,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
1478,
275,
12608,
14,
25269,
480,
5599,
1478,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
1478,
304,
267,
291,
14,
1080,
275,
1478,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
4619,
8,
5081,
304,
272,
5322,
275,
359,
267,
283,
14639,
8561,
1123,
297,
283,
14639,
8561,
2610,
297,
267,
283,
14639
] |
[
1898,
334,
67,
9,
6171,
13,
7280,
27155,
23954,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
710,
4190,
5084,
16879,
1454,
370,
4248,
315,
314,
2032,
436,
10989,
199,
3,
440,
506,
950,
431,
68,
465,
16085,
316,
282,
4190,
370,
1263,
1163,
27925,
1264,
1061,
199,
3,
3324,
5893,
1325,
440,
13988,
370,
27925,
1264,
1061,
3324,
4668,
1958,
199,
3,
370,
282,
14991,
4514,
402,
314,
9330,
402,
314,
2032,
199,
3,
18233,
2348,
7138,
14,
221,
2047,
1443,
675,
314,
2032,
5420,
370,
314,
4190,
199,
3,
2895,
5084,
2741,
626,
1265,
4868,
626,
642,
4245,
365,
32436,
199,
3,
24214,
436,
315,
2399,
8039,
369,
315,
1006,
10208,
402,
314,
2032,
12,
199,
3,
6042,
503,
24214,
12,
315,
1350,
1233,
503,
315,
3366,
1824,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
787,
199,
3,
7647,
26,
26771,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
27,
199,
3,
26771,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
314,
199,
3,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
4084,
27,
199,
3,
15564,
314,
536,
402,
314,
4248,
31976,
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,
3,
199,
3,
6642,
26,
6061,
5257,
699,
5596,
15515,
199,
199,
504,
333,
21,
14,
1162,
492,
627,
199,
504,
333,
21,
14,
7467,
1692,
492,
10751,
1692,
199,
199,
3,
5723,
3992,
5627,
376,
3965,
2637,
1806,
3152,
772,
63,
84,
543,
1454,
199,
3,
282,
9284,
10211,
14,
221,
961,
883,
506,
1202,
370,
1824,
8455,
367,
314,
2402,
199,
3,
7339,
1415,
315,
1750,
6451,
900,
15794,
14,
199,
3,
199,
3,
7910,
6274,
12,
315,
11735,
12,
911,
1172,
2879,
370,
314,
11086,
2998,
436,
199,
3,
282,
13599,
10083,
199,
199,
533,
26244,
316,
8561,
8,
7467,
1692,
304,
272,
730,
275,
283,
30101,
8561,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
272,
9006,
275,
715,
27,
199,
199,
533,
26244,
316,
8561,
7621,
8,
30101,
8561,
304,
272,
408,
7621,
5049,
4546,
7381,
574,
624,
272,
730,
275,
283,
30101,
8561,
7621,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
574,
275,
12608,
14,
13304,
772,
480,
8939,
574,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
574,
304,
267,
291,
14,
585,
275,
574,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
16,
8,
30101,
8561,
7621,
304,
272,
408,
714,
1856,
6792,
378,
624,
272,
574,
275,
378,
199,
199,
533,
26244,
316,
8561,
21261,
2872,
8,
30101,
8561,
304,
272,
408,
6591,
314,
1350,
2274,
1329,
687,
314,
1453,
2727,
624,
272,
730,
275,
283,
30101,
8561,
21261,
2872,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
327,
1478,
275,
12608,
14,
25269,
480,
1080,
1901,
2727,
2928,
295,
458,
531,
272,
1478,
275,
12608,
14,
25269,
480,
1080,
1901,
2727,
2928,
295,
458,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
1478,
304,
267,
291,
14,
1080,
275,
1478,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
3284,
3241,
2872,
8,
30101,
8561,
304,
272,
408,
3284,
376,
3819,
1175,
319,
4889,
2274,
624,
272,
730,
275,
283,
30101,
8561,
3284,
3241,
2872,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
1295,
275,
12608,
14,
30101,
8561,
480,
2683,
3066,
1478,
370,
1586,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
1295,
304,
267,
291,
14,
1135,
275,
1295,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
15314,
8,
30101,
8561,
304,
272,
408,
3142,
402,
18707,
624,
272,
730,
275,
283,
30101,
8561,
15314,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
347,
561,
275,
11388,
4098,
14,
30101,
8561,
480,
15264,
367,
17792,
531,
272,
5348,
275,
12608,
14,
30101,
8561,
480,
2030,
3965,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
347,
561,
12,
5348,
304,
267,
291,
14,
318,
561,
275,
347,
561,
267,
291,
14,
3684,
275,
5348,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
2891,
8,
30101,
8561,
304,
272,
408,
1110,
402,
282,
3914,
1007,
13,
5599,
624,
272,
730,
275,
283,
30101,
8561,
2891,
7,
272,
17327,
63,
1291,
275,
283,
3541,
15,
14639,
63,
3684,
14,
12156,
7,
339,
1478,
275,
12608,
14,
25269,
480,
5599,
1478,
531,
339,
347,
663,
63,
1162,
8,
277,
12,
1478,
304,
267,
291,
14,
1080,
275,
1478,
267,
372,
291,
199,
199,
533,
26244,
316,
8561,
4619,
8,
5081,
304,
272,
5322,
275,
359,
267,
283,
14639,
8561,
1123,
297,
283,
14639,
8561,
2610,
297,
267,
283,
14639,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
takeflight/wagtail
|
wagtail/tests/utils/page_tests.py
|
24
|
5122
|
from django.test import TestCase
from django.urls import reverse
from django.utils.text import slugify
from .wagtail_tests import WagtailTestUtils
class WagtailPageTests(WagtailTestUtils, TestCase):
"""
A set of asserts to help write tests for your own Wagtail site.
"""
def setUp(self):
super().setUp()
self.login()
def _testCanCreateAt(self, parent_model, child_model):
return child_model in parent_model.allowed_subpage_models()
def assertCanCreateAt(self, parent_model, child_model, msg=None):
"""
Assert a particular child Page type can be created under a parent
Page type. ``parent_model`` and ``child_model`` should be the Page
classes being tested.
"""
if not self._testCanCreateAt(parent_model, child_model):
msg = self._formatMessage(msg, "Can not create a %s.%s under a %s.%s" % (
child_model._meta.app_label, child_model._meta.model_name,
parent_model._meta.app_label, parent_model._meta.model_name))
raise self.failureException(msg)
def assertCanNotCreateAt(self, parent_model, child_model, msg=None):
"""
Assert a particular child Page type can not be created under a parent
Page type. ``parent_model`` and ``child_model`` should be the Page
classes being tested.
"""
if self._testCanCreateAt(parent_model, child_model):
msg = self._formatMessage(msg, "Can create a %s.%s under a %s.%s" % (
child_model._meta.app_label, child_model._meta.model_name,
parent_model._meta.app_label, parent_model._meta.model_name))
raise self.failureException(msg)
def assertCanCreate(self, parent, child_model, data, msg=None):
"""
Assert that a child of the given Page type can be created under the
parent, using the supplied POST data.
``parent`` should be a Page instance, and ``child_model`` should be a
Page subclass. ``data`` should be a dict that will be POSTed at the
Wagtail admin Page creation method.
"""
self.assertCanCreateAt(parent.specific_class, child_model)
if 'slug' not in data and 'title' in data:
data['slug'] = slugify(data['title'])
data['action-publish'] = 'action-publish'
add_url = reverse('wagtailadmin_pages:add', args=[
child_model._meta.app_label, child_model._meta.model_name, parent.pk])
response = self.client.post(add_url, data, follow=True)
if response.status_code != 200:
msg = self._formatMessage(msg, 'Creating a %s.%s returned a %d' % (
child_model._meta.app_label, child_model._meta.model_name, response.status_code))
raise self.failureException(msg)
if response.redirect_chain == []:
if 'form' not in response.context:
msg = self._formatMessage(msg, 'Creating a page failed unusually')
raise self.failureException(msg)
form = response.context['form']
if not form.errors:
msg = self._formatMessage(msg, 'Creating a page failed for an unknown reason')
raise self.failureException(msg)
errors = '\n'.join(' %s:\n %s' % (field, '\n '.join(errors))
for field, errors in sorted(form.errors.items()))
msg = self._formatMessage(msg, 'Validation errors found when creating a %s.%s:\n%s' % (
child_model._meta.app_label, child_model._meta.model_name, errors))
raise self.failureException(msg)
explore_url = reverse('wagtailadmin_explore', args=[parent.pk])
if response.redirect_chain != [(explore_url, 302)]:
msg = self._formatMessage(msg, 'Creating a page %s.%s didnt redirect the user to the explorer, but to %s' % (
child_model._meta.app_label, child_model._meta.model_name,
response.redirect_chain))
raise self.failureException(msg)
def assertAllowedSubpageTypes(self, parent_model, child_models, msg=None):
"""
Test that the only page types that can be created under
``parent_model`` are ``child_models``.
The list of allowed child models may differ from those set in
``Page.subpage_types``, if the child models have set
``Page.parent_page_types``.
"""
self.assertEqual(
set(parent_model.allowed_subpage_models()),
set(child_models),
msg=msg)
def assertAllowedParentPageTypes(self, child_model, parent_models, msg=None):
"""
Test that the only page types that ``child_model`` can be created under
are ``parent_models``.
The list of allowed parent models may differ from those set in
``Page.parent_page_types``, if the parent models have set
``Page.subpage_types``.
"""
self.assertEqual(
set(child_model.allowed_parent_page_models()),
set(parent_models),
msg=msg)
|
bsd-3-clause
|
[
504,
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
3603,
492,
3837,
199,
504,
1639,
14,
1208,
14,
505,
492,
29864,
199,
199,
504,
1275,
17296,
63,
2219,
492,
644,
6396,
774,
7535,
421,
199,
533,
644,
6396,
3276,
2925,
8,
55,
6396,
774,
7535,
12,
7640,
304,
272,
408,
272,
437,
663,
402,
702,
83,
370,
1720,
2218,
2295,
367,
2195,
5705,
644,
6396,
4770,
14,
272,
408,
272,
347,
3613,
8,
277,
304,
267,
1613,
1252,
5996,
342,
267,
291,
14,
2886,
342,
339,
347,
485,
396,
6049,
2499,
1271,
8,
277,
12,
1676,
63,
1238,
12,
1982,
63,
1238,
304,
267,
372,
1982,
63,
1238,
315,
1676,
63,
1238,
14,
6541,
63,
954,
1606,
63,
992,
342,
339,
347,
702,
6049,
2499,
1271,
8,
277,
12,
1676,
63,
1238,
12,
1982,
63,
1238,
12,
1499,
29,
403,
304,
267,
408,
267,
10716,
282,
6770,
1982,
10331,
730,
883,
506,
2737,
1334,
282,
1676,
267,
10331,
730,
14,
1124,
1708,
63,
1238,
1040,
436,
1124,
1739,
63,
1238,
1040,
1077,
506,
314,
10331,
267,
3992,
3769,
12470,
14,
267,
408,
267,
340,
440,
291,
423,
396,
6049,
2499,
1271,
8,
1708,
63,
1238,
12,
1982,
63,
1238,
304,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
298,
6049,
440,
1218,
282,
450,
83,
4111,
83,
1334,
282,
450,
83,
4111,
83,
2,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
355,
1676,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1676,
63,
1238,
423,
2024,
14,
1238,
63,
354,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
339,
347,
702,
6049,
1763,
2499,
1271,
8,
277,
12,
1676,
63,
1238,
12,
1982,
63,
1238,
12,
1499,
29,
403,
304,
267,
408,
267,
10716,
282,
6770,
1982,
10331,
730,
883,
440,
506,
2737,
1334,
282,
1676,
267,
10331,
730,
14,
1124,
1708,
63,
1238,
1040,
436,
1124,
1739,
63,
1238,
1040,
1077,
506,
314,
10331,
267,
3992,
3769,
12470,
14,
267,
408,
267,
340,
291,
423,
396,
6049,
2499,
1271,
8,
1708,
63,
1238,
12,
1982,
63,
1238,
304,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
298,
6049,
1218,
282,
450,
83,
4111,
83,
1334,
282,
450,
83,
4111,
83,
2,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
355,
1676,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1676,
63,
1238,
423,
2024,
14,
1238,
63,
354,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
339,
347,
702,
6049,
2499,
8,
277,
12,
1676,
12,
1982,
63,
1238,
12,
666,
12,
1499,
29,
403,
304,
267,
408,
267,
10716,
626,
282,
1982,
402,
314,
1627,
10331,
730,
883,
506,
2737,
1334,
314,
267,
1676,
12,
1808,
314,
6841,
8761,
666,
14,
398,
1124,
1708,
1040,
1077,
506,
282,
10331,
1256,
12,
436,
1124,
1739,
63,
1238,
1040,
1077,
506,
282,
267,
10331,
5516,
14,
1124,
576,
1040,
1077,
506,
282,
1211,
626,
911,
506,
8761,
379,
737,
314,
267,
644,
6396,
4628,
10331,
7143,
1083,
14,
267,
408,
267,
291,
14,
479,
6049,
2499,
1271,
8,
1708,
14,
6100,
63,
533,
12,
1982,
63,
1238,
9,
398,
340,
283,
5464,
7,
440,
315,
666,
436,
283,
1213,
7,
315,
666,
26,
288,
666,
459,
5464,
418,
275,
29864,
8,
576,
459,
1213,
1105,
267,
666,
459,
1287,
13,
4763,
418,
275,
283,
1287,
13,
4763,
7,
398,
1050,
63,
633,
275,
3837,
360,
30874,
63,
5856,
26,
525,
297,
1249,
1524,
288,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
1676,
14,
2051,
566,
267,
1177,
275,
291,
14,
1258,
14,
1932,
8,
525,
63,
633,
12,
666,
12,
2035,
29,
549,
9,
398,
340,
1177,
14,
1205,
63,
600,
1137,
1926,
26,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
14380,
282,
450,
83,
4111,
83,
2138,
282,
450,
68,
7,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
1177,
14,
1205,
63,
600,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
398,
340,
1177,
14,
4876,
63,
4429,
508,
18410,
288,
340,
283,
964,
7,
440,
315,
1177,
14,
1100,
26,
355,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
14380,
282,
2034,
3405,
625,
25118,
358,
355,
746,
291,
14,
15935,
8,
1328,
9,
288,
1824,
275,
1177,
14,
1100,
459,
964,
418,
288,
340,
440,
1824,
14,
2550,
26,
355,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
14380,
282,
2034,
3405,
367,
376,
5809,
4499,
358,
355,
746,
291,
14,
15935,
8,
1328,
9,
953,
2552,
275,
1557,
78,
1370,
904,
360,
221,
450,
83,
3427,
78,
259,
450,
83,
7,
450,
334,
698,
12,
1557,
78,
259,
1987,
904,
8,
2550,
430,
3044,
367,
901,
12,
2552,
315,
3355,
8,
964,
14,
2550,
14,
1744,
4059,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
13816,
2552,
1911,
1380,
6425,
282,
450,
83,
4111,
83,
3427,
78,
5,
83,
7,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
2552,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
398,
15868,
264,
63,
633,
275,
3837,
360,
30874,
63,
16971,
264,
297,
1249,
1524,
1708,
14,
2051,
566,
267,
340,
1177,
14,
4876,
63,
4429,
1137,
3842,
16971,
264,
63,
633,
12,
11485,
19532,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
14380,
282,
2034,
450,
83,
4111,
83,
8103,
343,
4660,
314,
922,
370,
314,
15868,
3859,
12,
1325,
370,
450,
83,
7,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
355,
1177,
14,
4876,
63,
4429,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
339,
347,
702,
16070,
2610,
1606,
4100,
8,
277,
12,
1676,
63,
1238,
12,
1982,
63,
992
] |
[
1639,
14,
396,
492,
7640,
199,
504,
1639,
14,
3603,
492,
3837,
199,
504,
1639,
14,
1208,
14,
505,
492,
29864,
199,
199,
504,
1275,
17296,
63,
2219,
492,
644,
6396,
774,
7535,
421,
199,
533,
644,
6396,
3276,
2925,
8,
55,
6396,
774,
7535,
12,
7640,
304,
272,
408,
272,
437,
663,
402,
702,
83,
370,
1720,
2218,
2295,
367,
2195,
5705,
644,
6396,
4770,
14,
272,
408,
272,
347,
3613,
8,
277,
304,
267,
1613,
1252,
5996,
342,
267,
291,
14,
2886,
342,
339,
347,
485,
396,
6049,
2499,
1271,
8,
277,
12,
1676,
63,
1238,
12,
1982,
63,
1238,
304,
267,
372,
1982,
63,
1238,
315,
1676,
63,
1238,
14,
6541,
63,
954,
1606,
63,
992,
342,
339,
347,
702,
6049,
2499,
1271,
8,
277,
12,
1676,
63,
1238,
12,
1982,
63,
1238,
12,
1499,
29,
403,
304,
267,
408,
267,
10716,
282,
6770,
1982,
10331,
730,
883,
506,
2737,
1334,
282,
1676,
267,
10331,
730,
14,
1124,
1708,
63,
1238,
1040,
436,
1124,
1739,
63,
1238,
1040,
1077,
506,
314,
10331,
267,
3992,
3769,
12470,
14,
267,
408,
267,
340,
440,
291,
423,
396,
6049,
2499,
1271,
8,
1708,
63,
1238,
12,
1982,
63,
1238,
304,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
298,
6049,
440,
1218,
282,
450,
83,
4111,
83,
1334,
282,
450,
83,
4111,
83,
2,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
355,
1676,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1676,
63,
1238,
423,
2024,
14,
1238,
63,
354,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
339,
347,
702,
6049,
1763,
2499,
1271,
8,
277,
12,
1676,
63,
1238,
12,
1982,
63,
1238,
12,
1499,
29,
403,
304,
267,
408,
267,
10716,
282,
6770,
1982,
10331,
730,
883,
440,
506,
2737,
1334,
282,
1676,
267,
10331,
730,
14,
1124,
1708,
63,
1238,
1040,
436,
1124,
1739,
63,
1238,
1040,
1077,
506,
314,
10331,
267,
3992,
3769,
12470,
14,
267,
408,
267,
340,
291,
423,
396,
6049,
2499,
1271,
8,
1708,
63,
1238,
12,
1982,
63,
1238,
304,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
298,
6049,
1218,
282,
450,
83,
4111,
83,
1334,
282,
450,
83,
4111,
83,
2,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
355,
1676,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1676,
63,
1238,
423,
2024,
14,
1238,
63,
354,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
339,
347,
702,
6049,
2499,
8,
277,
12,
1676,
12,
1982,
63,
1238,
12,
666,
12,
1499,
29,
403,
304,
267,
408,
267,
10716,
626,
282,
1982,
402,
314,
1627,
10331,
730,
883,
506,
2737,
1334,
314,
267,
1676,
12,
1808,
314,
6841,
8761,
666,
14,
398,
1124,
1708,
1040,
1077,
506,
282,
10331,
1256,
12,
436,
1124,
1739,
63,
1238,
1040,
1077,
506,
282,
267,
10331,
5516,
14,
1124,
576,
1040,
1077,
506,
282,
1211,
626,
911,
506,
8761,
379,
737,
314,
267,
644,
6396,
4628,
10331,
7143,
1083,
14,
267,
408,
267,
291,
14,
479,
6049,
2499,
1271,
8,
1708,
14,
6100,
63,
533,
12,
1982,
63,
1238,
9,
398,
340,
283,
5464,
7,
440,
315,
666,
436,
283,
1213,
7,
315,
666,
26,
288,
666,
459,
5464,
418,
275,
29864,
8,
576,
459,
1213,
1105,
267,
666,
459,
1287,
13,
4763,
418,
275,
283,
1287,
13,
4763,
7,
398,
1050,
63,
633,
275,
3837,
360,
30874,
63,
5856,
26,
525,
297,
1249,
1524,
288,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
1676,
14,
2051,
566,
267,
1177,
275,
291,
14,
1258,
14,
1932,
8,
525,
63,
633,
12,
666,
12,
2035,
29,
549,
9,
398,
340,
1177,
14,
1205,
63,
600,
1137,
1926,
26,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
14380,
282,
450,
83,
4111,
83,
2138,
282,
450,
68,
7,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
1177,
14,
1205,
63,
600,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
398,
340,
1177,
14,
4876,
63,
4429,
508,
18410,
288,
340,
283,
964,
7,
440,
315,
1177,
14,
1100,
26,
355,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
14380,
282,
2034,
3405,
625,
25118,
358,
355,
746,
291,
14,
15935,
8,
1328,
9,
288,
1824,
275,
1177,
14,
1100,
459,
964,
418,
288,
340,
440,
1824,
14,
2550,
26,
355,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
14380,
282,
2034,
3405,
367,
376,
5809,
4499,
358,
355,
746,
291,
14,
15935,
8,
1328,
9,
953,
2552,
275,
1557,
78,
1370,
904,
360,
221,
450,
83,
3427,
78,
259,
450,
83,
7,
450,
334,
698,
12,
1557,
78,
259,
1987,
904,
8,
2550,
430,
3044,
367,
901,
12,
2552,
315,
3355,
8,
964,
14,
2550,
14,
1744,
4059,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
13816,
2552,
1911,
1380,
6425,
282,
450,
83,
4111,
83,
3427,
78,
5,
83,
7,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
2552,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
398,
15868,
264,
63,
633,
275,
3837,
360,
30874,
63,
16971,
264,
297,
1249,
1524,
1708,
14,
2051,
566,
267,
340,
1177,
14,
4876,
63,
4429,
1137,
3842,
16971,
264,
63,
633,
12,
11485,
19532,
288,
1499,
275,
291,
423,
29097,
8,
1328,
12,
283,
14380,
282,
2034,
450,
83,
4111,
83,
8103,
343,
4660,
314,
922,
370,
314,
15868,
3859,
12,
1325,
370,
450,
83,
7,
450,
334,
355,
1982,
63,
1238,
423,
2024,
14,
571,
63,
1302,
12,
1982,
63,
1238,
423,
2024,
14,
1238,
63,
354,
12,
355,
1177,
14,
4876,
63,
4429,
430,
288,
746,
291,
14,
15935,
8,
1328,
9,
339,
347,
702,
16070,
2610,
1606,
4100,
8,
277,
12,
1676,
63,
1238,
12,
1982,
63,
992,
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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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
] |
felliott/scrapi
|
scrapi/base/helpers.py
|
3
|
9854
|
from __future__ import unicode_literals
import re
import logging
import functools
from copy import deepcopy
import six
import pytz
from lxml import etree
from dateutil import parser
from pycountry import languages
from nameparser import HumanName
from scrapi import requests
URL_REGEX = re.compile(r'(https?:\/\/\S*\.[^\s\[\]\<\>\}\{\^]*)')
DOI_REGEX = re.compile(r'(doi:10\.\S*)')
def CONSTANT(x):
''' Takes a value, returns a function that always returns that value
Useful inside schemas for defining constants
>>> CONSTANT(7)('my', 'name', verb='is')
7
>>> CONSTANT([123, 456])()
[123, 456]
'''
def inner(*y, **z):
return x
return inner
def build_properties(*args):
ret = []
for arg in args:
name, expr = arg[0], arg[1]
kwargs = arg[2] if len(arg) > 2 else {}
description, uri = kwargs.get('description'), kwargs.get('uri')
ret.append(build_property(name, expr, description=description, uri=uri))
return ret
def build_property(name, expr, description=None, uri=None):
property = {
'name': CONSTANT(name),
'properties': {
name: expr
},
}
if description:
property['description'] = CONSTANT(description)
if uri:
property['uri'] = CONSTANT(uri)
return property
def single_result(l, default=''):
''' A function that will return the first element of a list if it exists
>>> print(single_result(['hello', None]))
hello
>>> print(single_result([], default='hello'))
hello
>>> print(single_result([]))
<BLANKLINE>
'''
return l[0] if l else default
def compose(*functions):
''' evaluates functions from right to left.
>>> add = lambda x, y: x + y
>>> add3 = lambda x: x + 3
>>> divide2 = lambda x: x/2
>>> subtract4 = lambda x: x - 4
>>> subtract1 = compose(add3, subtract4)
>>> subtract1(1)
0
>>> compose(subtract1, add3)(4)
6
>>> compose(int, add3, add3, divide2)(4)
8
>>> compose(int, divide2, add3, add3)(4)
5
>>> compose(int, divide2, compose(add3, add3), add)(7, 3)
8
'''
def inner(func1, func2):
return lambda *x, **y: func1(func2(*x, **y))
return functools.reduce(inner, functions)
def updated_schema(old, new):
''' Creates a dictionary resulting from adding all keys/values of the second to the first
The second dictionary will overwrite the first.
>>> old, new = {'name': 'ric', 'job': None}, {'name': 'Rick'}
>>> updated = updated_schema(old, new)
>>> len(updated.keys())
2
>>> print(updated['name'])
Rick
>>> updated['job'] is None
True
'''
d = deepcopy(old)
for key, value in new.items():
if isinstance(value, dict) and old.get(key) and isinstance(old[key], dict):
d[key] = updated_schema(old[key], new[key])
else:
d[key] = value
return d
def default_name_parser(names):
''' Takes a list of names, and attempts to parse them
'''
return list(map(maybe_parse_name, names))
def maybe_parse_name(name):
''' Tries to parse a name. If the parsing fails, returns a dictionary
with just the unparsed name (as per the SHARE schema)
'''
return null_on_error(parse_name)(name) or {'name': name}
def parse_name(name):
''' Takes a human name, parses it into given/middle/last names
'''
person = HumanName(name)
return {
'name': name,
'givenName': person.first,
'additionalName': person.middle,
'familyName': person.last
}
def format_tags(all_tags, sep=','):
tags = []
if isinstance(all_tags, six.string_types):
tags = all_tags.split(sep)
elif isinstance(all_tags, list):
for tag in all_tags:
if sep in tag:
tags.extend(tag.split(sep))
else:
tags.append(tag)
return list(set([six.text_type(tag.lower().strip()) for tag in tags if tag.strip()]))
def format_doi_as_url(doi):
if doi:
plain_doi = doi.replace('doi:', '').replace('DOI:', '').strip()
return 'http://dx.doi.org/{}'.format(plain_doi)
def gather_identifiers(args):
identifiers = []
for arg in args:
if isinstance(arg, list):
for identifier in arg:
identifiers.append(identifier)
elif arg:
identifiers.append(arg)
return identifiers
def maybe_group(match):
'''
evaluates an regular expression match object, returns the group or none
'''
return match.group() if match else None
def gather_object_uris(identifiers):
'''
Gathers object URIs if there are any
>>> gathered = gather_object_uris(['nopenope', 'doi:10.10.gettables', 'http://dx.doi.org/yep'])
>>> print(gathered[0])
http://dx.doi.org/10.10.gettables
>>> print(gathered[1])
http://dx.doi.org/yep
'''
object_uris = []
for item in identifiers:
if 'doi' in item.lower():
url_doi, just_doi = URL_REGEX.search(item), DOI_REGEX.search(item)
url_doi = maybe_group(url_doi)
just_doi = maybe_group(just_doi)
if url_doi or just_doi:
object_uris.append(url_doi or format_doi_as_url(just_doi))
return object_uris
def seperate_provider_object_uris(identifiers):
object_uris = gather_object_uris(identifiers)
provider_uris = []
for item in identifiers:
found_url = maybe_group(URL_REGEX.search(item))
if found_url:
if 'viewcontent' in found_url:
object_uris.append(found_url)
else:
if 'dx.doi.org' not in found_url:
provider_uris.append(found_url)
return provider_uris, object_uris
def oai_process_uris(*args, **kwargs):
use_doi = kwargs.get('use_doi', False)
identifiers = gather_identifiers(args)
provider_uris, object_uris = seperate_provider_object_uris(identifiers)
potential_uris = (provider_uris + object_uris)
if use_doi:
for uri in object_uris:
if 'dx.doi.org' in uri:
potential_uris = [uri]
try:
canonical_uri = potential_uris[0]
except IndexError:
raise ValueError('No Canonical URI was returned for this record.')
return {
'canonicalUri': canonical_uri,
'objectUris': object_uris,
'providerUris': provider_uris
}
def oai_extract_dois(*args):
identifiers = gather_identifiers(args)
dois = []
for item in identifiers:
if 'doi' in item.lower():
doi = item.replace('doi:', '').replace('DOI:', '').strip()
if 'http://dx.doi.org/' in doi:
dois.append(doi)
else:
dois.append('http://dx.doi.org/{}'.format(doi))
return dois
def oai_process_contributors(*args):
names = gather_identifiers(args)
return default_name_parser(names)
def pack(*args, **kwargs):
return args, kwargs
def language_codes(langs):
'''Given an array of language names, returns an array of ISO 639-3 codes
e.g. ['English', 'Russian'] -> ['eng', 'rus']
'''
return list(filter(lambda x: x, map(get_code, langs)))
def get_code(language):
try:
return languages.get(name=language).bibliographic
except KeyError:
return None
def oai_get_records_and_token(url, throttle, force, namespaces, verify):
""" Helper function to get the records and any resumptionToken
from an OAI request.
Takes a url and any request parameters and returns the records
along with the resumptionToken if there is one.
"""
data = requests.get(url, throttle=throttle, force=force, verify=verify)
doc = etree.XML(data.content)
records = doc.xpath(
'//ns0:record',
namespaces=namespaces
)
token = doc.xpath(
'//ns0:resumptionToken/node()',
namespaces=namespaces
)
return records, token
def extract_doi_from_text(identifiers):
identifiers = [identifiers] if not isinstance(identifiers, list) else identifiers
for item in identifiers:
try:
found_url = DOI_REGEX.search(item).group()
return 'http://dx.doi.org/{}'.format(found_url.replace('doi:', ''))
except AttributeError:
continue
def null_on_error(task):
'''Decorator that makes a function return None on exception'''
def inner(*args, **kwargs):
try:
return task(*args, **kwargs)
except Exception as e:
logger = logging.getLogger('scrapi.base.helpers.null_on_error')
logger.warn(e)
return None
return inner
def coerce_to_list(thing):
''' If a value is not already a list or tuple, puts that value in a length 1 list
>>> niceties = coerce_to_list('hello')
>>> len(niceties)
1
>>> print(niceties[0])
hello
>>> niceties2 = coerce_to_list(['hello'])
>>> niceties2 == niceties
True
>>> niceties3 = (coerce_to_list(('hello', 'goodbye')))
>>> len(niceties3)
2
>>> print(niceties3[0])
hello
>>> print(niceties3[1])
goodbye
'''
if not (isinstance(thing, list) or isinstance(thing, tuple)):
return [thing]
return list(thing)
def datetime_formatter(datetime_string):
'''Takes an arbitrary date/time string and parses it, adds time
zone information and returns a valid ISO-8601 datetime string
'''
date_time = parser.parse(datetime_string)
if not date_time.tzinfo:
date_time = date_time.replace(tzinfo=pytz.UTC)
return date_time.isoformat()
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
295,
199,
646,
2050,
199,
646,
9143,
199,
504,
1331,
492,
14800,
199,
199,
646,
3816,
199,
646,
15444,
199,
504,
14490,
492,
7559,
199,
504,
22208,
492,
1798,
199,
504,
1134,
6063,
492,
10815,
199,
504,
536,
2087,
492,
869,
7652,
985,
199,
199,
504,
10328,
1038,
492,
4145,
421,
199,
2632,
63,
10710,
275,
295,
14,
2014,
8,
82,
6774,
2859,
31,
3427,
6307,
6307,
51,
10,
4537,
16045,
83,
60,
7023,
7272,
31873,
3072,
4988,
12911,
62,
3672,
5942,
199,
1649,
41,
63,
10710,
275,
295,
14,
2014,
8,
82,
6774,
27334,
26,
709,
60,
3134,
51,
10,
5942,
421,
199,
318,
21803,
1441,
8,
88,
304,
272,
1449,
17415,
282,
574,
12,
2529,
282,
805,
626,
3544,
2529,
626,
574,
267,
18491,
6272,
32536,
367,
12669,
5262,
398,
1306,
21803,
1441,
8,
23,
9,
360,
1662,
297,
283,
354,
297,
16041,
534,
374,
358,
267,
1520,
267,
1306,
21803,
1441,
779,
4288,
12,
31944,
566,
342,
267,
359,
4288,
12,
31944,
61,
272,
1449,
272,
347,
6506,
2031,
89,
12,
1011,
90,
304,
267,
372,
671,
272,
372,
6506,
421,
199,
318,
1900,
63,
3282,
2031,
589,
304,
272,
2203,
275,
942,
272,
367,
1680,
315,
1249,
26,
267,
536,
12,
5348,
275,
1680,
59,
16,
467,
1680,
59,
17,
61,
267,
2074,
275,
1680,
59,
18,
61,
340,
822,
8,
1273,
9,
690,
499,
587,
1052,
267,
1369,
12,
5108,
275,
2074,
14,
362,
360,
1802,
659,
2074,
14,
362,
360,
2302,
358,
267,
2203,
14,
740,
8,
1506,
63,
1829,
8,
354,
12,
5348,
12,
1369,
29,
1802,
12,
5108,
29,
2302,
430,
272,
372,
2203,
421,
199,
318,
1900,
63,
1829,
8,
354,
12,
5348,
12,
1369,
29,
403,
12,
5108,
29,
403,
304,
272,
3324,
275,
469,
267,
283,
354,
356,
21803,
1441,
8,
354,
395,
267,
283,
3282,
356,
469,
288,
536,
26,
5348,
267,
1660,
272,
789,
272,
340,
1369,
26,
267,
3324,
459,
1802,
418,
275,
21803,
1441,
8,
1802,
9,
272,
340,
5108,
26,
267,
3324,
459,
2302,
418,
275,
21803,
1441,
8,
2302,
9,
272,
372,
3324,
421,
199,
318,
2849,
63,
1099,
8,
76,
12,
849,
9280,
272,
1449,
437,
805,
626,
911,
372,
314,
1642,
1819,
402,
282,
769,
340,
652,
3495,
398,
1306,
870,
8,
4780,
63,
1099,
2941,
5006,
297,
488,
2459,
267,
16509,
267,
1306,
870,
8,
4780,
63,
1099,
8798,
849,
534,
5006,
1333,
267,
16509,
267,
1306,
870,
8,
4780,
63,
1099,
26064,
267,
665,
29353,
30,
339,
1449,
272,
372,
634,
59,
16,
61,
340,
634,
587,
849,
421,
199,
318,
23366,
2031,
5777,
304,
272,
1449,
22014,
3423,
687,
2451,
370,
3602,
14,
398,
1306,
1050,
275,
2400,
671,
12,
612,
26,
671,
435,
612,
267,
1306,
1050,
19,
275,
2400,
671,
26,
671,
435,
650,
267,
1306,
23003,
18,
275,
2400,
671,
26,
671,
15,
18,
267,
1306,
24129,
20,
275,
2400,
671,
26,
671,
446,
841,
267,
1306,
24129,
17,
275,
23366,
8,
525,
19,
12,
24129,
20,
9,
267,
1306,
24129,
17,
8,
17,
9,
267,
378,
267,
1306,
23366,
8,
25719,
17,
12,
1050,
19,
5130,
20,
9,
267,
1227,
267,
1306,
23366,
8,
442,
12,
1050,
19,
12,
1050,
19,
12,
23003,
18,
5130,
20,
9,
267,
1695,
267,
1306,
23366,
8,
442,
12,
23003,
18,
12,
1050,
19,
12,
1050,
19,
5130,
20,
9,
267,
959,
267,
1306,
23366,
8,
442,
12,
23003,
18,
12,
23366,
8,
525,
19,
12,
1050,
19,
395,
1050,
5130,
23,
12,
650,
9,
267,
1695,
272,
1449,
272,
347,
6506,
8,
1532,
17,
12,
2562,
18,
304,
267,
372,
2400,
627,
88,
12,
1011,
89,
26,
2562,
17,
8,
1532,
18,
2031,
88,
12,
1011,
89,
430,
272,
372,
9143,
14,
5270,
8,
5216,
12,
3423,
9,
421,
199,
318,
4588,
63,
3629,
8,
1753,
12,
892,
304,
272,
1449,
10560,
282,
2600,
9183,
687,
7791,
1006,
2883,
15,
1459,
402,
314,
3499,
370,
314,
1642,
267,
710,
3499,
2600,
911,
8970,
314,
1642,
14,
398,
1306,
2269,
12,
892,
275,
791,
354,
356,
283,
1567,
297,
283,
2423,
356,
488,
1386,
791,
354,
356,
283,
50,
2000,
936,
267,
1306,
4588,
275,
4588,
63,
3629,
8,
1753,
12,
892,
9,
267,
1306,
822,
8,
5334,
14,
1612,
1012,
267,
499,
267,
1306,
870,
8,
5334,
459,
354,
1105,
267,
820,
2000,
267,
1306,
4588,
459,
2423,
418,
365,
488,
267,
715,
339,
1449,
272,
366,
275,
14800,
8,
1753,
9,
272,
367,
790,
12,
574,
315,
892,
14,
1744,
837,
267,
340,
1228,
8,
585,
12,
1211,
9,
436,
2269,
14,
362,
8,
498,
9,
436,
1228,
8,
1753,
59,
498,
467,
1211,
304,
288,
366,
59,
498,
61,
275,
4588,
63,
3629,
8,
1753,
59,
498,
467,
892,
59,
498,
566,
267,
587,
26,
288,
366,
59,
498,
61,
275,
574,
272,
372,
366,
421,
199,
318,
849,
63,
354,
63,
2087,
8,
1247,
304,
272,
1449,
17415,
282,
769,
402,
1561,
12,
436,
12454,
370,
2198,
3062,
272,
1449,
272,
372,
769,
8,
1130,
8,
11853,
63,
1122,
63,
354,
12,
1561,
430,
421,
199,
318,
11703,
63,
1122,
63,
354,
8,
354,
304,
272,
1449,
377,
1996,
370,
2198,
282,
536,
14,
982,
314,
6057,
6918,
12,
2529,
282,
2600,
267,
543,
2951,
314,
31857,
536,
334,
305,
1126,
314,
4410,
8693,
4177,
9,
272,
1449,
272,
372,
2973,
63,
265,
63,
705,
8,
1122,
63,
354,
5130,
354,
9,
503,
791,
354,
356,
536,
93,
421,
199,
318,
2198,
63,
354,
8,
354,
304,
272,
1449,
17415,
282,
11779,
536,
12,
19953,
652,
1901,
1627,
15,
14885,
15,
2019,
1561,
272,
1449,
272,
4954,
275,
869,
7652,
985,
8,
354,
9,
272,
372,
469,
267,
283,
354,
356,
536,
12,
267,
283,
11809,
985,
356,
4954,
14,
2246,
12,
267,
283,
8460,
985,
356,
4954,
14,
14885,
12,
267,
283,
6606,
985,
356,
4954,
14,
2019,
272,
789,
421,
199,
318,
1475,
63,
2969,
8,
452,
63,
2969,
12,
7375,
4009,
735,
272,
3762,
275,
942,
272,
340,
1228,
8,
452,
63,
2969,
12
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
646,
295,
199,
646,
2050,
199,
646,
9143,
199,
504,
1331,
492,
14800,
199,
199,
646,
3816,
199,
646,
15444,
199,
504,
14490,
492,
7559,
199,
504,
22208,
492,
1798,
199,
504,
1134,
6063,
492,
10815,
199,
504,
536,
2087,
492,
869,
7652,
985,
199,
199,
504,
10328,
1038,
492,
4145,
421,
199,
2632,
63,
10710,
275,
295,
14,
2014,
8,
82,
6774,
2859,
31,
3427,
6307,
6307,
51,
10,
4537,
16045,
83,
60,
7023,
7272,
31873,
3072,
4988,
12911,
62,
3672,
5942,
199,
1649,
41,
63,
10710,
275,
295,
14,
2014,
8,
82,
6774,
27334,
26,
709,
60,
3134,
51,
10,
5942,
421,
199,
318,
21803,
1441,
8,
88,
304,
272,
1449,
17415,
282,
574,
12,
2529,
282,
805,
626,
3544,
2529,
626,
574,
267,
18491,
6272,
32536,
367,
12669,
5262,
398,
1306,
21803,
1441,
8,
23,
9,
360,
1662,
297,
283,
354,
297,
16041,
534,
374,
358,
267,
1520,
267,
1306,
21803,
1441,
779,
4288,
12,
31944,
566,
342,
267,
359,
4288,
12,
31944,
61,
272,
1449,
272,
347,
6506,
2031,
89,
12,
1011,
90,
304,
267,
372,
671,
272,
372,
6506,
421,
199,
318,
1900,
63,
3282,
2031,
589,
304,
272,
2203,
275,
942,
272,
367,
1680,
315,
1249,
26,
267,
536,
12,
5348,
275,
1680,
59,
16,
467,
1680,
59,
17,
61,
267,
2074,
275,
1680,
59,
18,
61,
340,
822,
8,
1273,
9,
690,
499,
587,
1052,
267,
1369,
12,
5108,
275,
2074,
14,
362,
360,
1802,
659,
2074,
14,
362,
360,
2302,
358,
267,
2203,
14,
740,
8,
1506,
63,
1829,
8,
354,
12,
5348,
12,
1369,
29,
1802,
12,
5108,
29,
2302,
430,
272,
372,
2203,
421,
199,
318,
1900,
63,
1829,
8,
354,
12,
5348,
12,
1369,
29,
403,
12,
5108,
29,
403,
304,
272,
3324,
275,
469,
267,
283,
354,
356,
21803,
1441,
8,
354,
395,
267,
283,
3282,
356,
469,
288,
536,
26,
5348,
267,
1660,
272,
789,
272,
340,
1369,
26,
267,
3324,
459,
1802,
418,
275,
21803,
1441,
8,
1802,
9,
272,
340,
5108,
26,
267,
3324,
459,
2302,
418,
275,
21803,
1441,
8,
2302,
9,
272,
372,
3324,
421,
199,
318,
2849,
63,
1099,
8,
76,
12,
849,
9280,
272,
1449,
437,
805,
626,
911,
372,
314,
1642,
1819,
402,
282,
769,
340,
652,
3495,
398,
1306,
870,
8,
4780,
63,
1099,
2941,
5006,
297,
488,
2459,
267,
16509,
267,
1306,
870,
8,
4780,
63,
1099,
8798,
849,
534,
5006,
1333,
267,
16509,
267,
1306,
870,
8,
4780,
63,
1099,
26064,
267,
665,
29353,
30,
339,
1449,
272,
372,
634,
59,
16,
61,
340,
634,
587,
849,
421,
199,
318,
23366,
2031,
5777,
304,
272,
1449,
22014,
3423,
687,
2451,
370,
3602,
14,
398,
1306,
1050,
275,
2400,
671,
12,
612,
26,
671,
435,
612,
267,
1306,
1050,
19,
275,
2400,
671,
26,
671,
435,
650,
267,
1306,
23003,
18,
275,
2400,
671,
26,
671,
15,
18,
267,
1306,
24129,
20,
275,
2400,
671,
26,
671,
446,
841,
267,
1306,
24129,
17,
275,
23366,
8,
525,
19,
12,
24129,
20,
9,
267,
1306,
24129,
17,
8,
17,
9,
267,
378,
267,
1306,
23366,
8,
25719,
17,
12,
1050,
19,
5130,
20,
9,
267,
1227,
267,
1306,
23366,
8,
442,
12,
1050,
19,
12,
1050,
19,
12,
23003,
18,
5130,
20,
9,
267,
1695,
267,
1306,
23366,
8,
442,
12,
23003,
18,
12,
1050,
19,
12,
1050,
19,
5130,
20,
9,
267,
959,
267,
1306,
23366,
8,
442,
12,
23003,
18,
12,
23366,
8,
525,
19,
12,
1050,
19,
395,
1050,
5130,
23,
12,
650,
9,
267,
1695,
272,
1449,
272,
347,
6506,
8,
1532,
17,
12,
2562,
18,
304,
267,
372,
2400,
627,
88,
12,
1011,
89,
26,
2562,
17,
8,
1532,
18,
2031,
88,
12,
1011,
89,
430,
272,
372,
9143,
14,
5270,
8,
5216,
12,
3423,
9,
421,
199,
318,
4588,
63,
3629,
8,
1753,
12,
892,
304,
272,
1449,
10560,
282,
2600,
9183,
687,
7791,
1006,
2883,
15,
1459,
402,
314,
3499,
370,
314,
1642,
267,
710,
3499,
2600,
911,
8970,
314,
1642,
14,
398,
1306,
2269,
12,
892,
275,
791,
354,
356,
283,
1567,
297,
283,
2423,
356,
488,
1386,
791,
354,
356,
283,
50,
2000,
936,
267,
1306,
4588,
275,
4588,
63,
3629,
8,
1753,
12,
892,
9,
267,
1306,
822,
8,
5334,
14,
1612,
1012,
267,
499,
267,
1306,
870,
8,
5334,
459,
354,
1105,
267,
820,
2000,
267,
1306,
4588,
459,
2423,
418,
365,
488,
267,
715,
339,
1449,
272,
366,
275,
14800,
8,
1753,
9,
272,
367,
790,
12,
574,
315,
892,
14,
1744,
837,
267,
340,
1228,
8,
585,
12,
1211,
9,
436,
2269,
14,
362,
8,
498,
9,
436,
1228,
8,
1753,
59,
498,
467,
1211,
304,
288,
366,
59,
498,
61,
275,
4588,
63,
3629,
8,
1753,
59,
498,
467,
892,
59,
498,
566,
267,
587,
26,
288,
366,
59,
498,
61,
275,
574,
272,
372,
366,
421,
199,
318,
849,
63,
354,
63,
2087,
8,
1247,
304,
272,
1449,
17415,
282,
769,
402,
1561,
12,
436,
12454,
370,
2198,
3062,
272,
1449,
272,
372,
769,
8,
1130,
8,
11853,
63,
1122,
63,
354,
12,
1561,
430,
421,
199,
318,
11703,
63,
1122,
63,
354,
8,
354,
304,
272,
1449,
377,
1996,
370,
2198,
282,
536,
14,
982,
314,
6057,
6918,
12,
2529,
282,
2600,
267,
543,
2951,
314,
31857,
536,
334,
305,
1126,
314,
4410,
8693,
4177,
9,
272,
1449,
272,
372,
2973,
63,
265,
63,
705,
8,
1122,
63,
354,
5130,
354,
9,
503,
791,
354,
356,
536,
93,
421,
199,
318,
2198,
63,
354,
8,
354,
304,
272,
1449,
17415,
282,
11779,
536,
12,
19953,
652,
1901,
1627,
15,
14885,
15,
2019,
1561,
272,
1449,
272,
4954,
275,
869,
7652,
985,
8,
354,
9,
272,
372,
469,
267,
283,
354,
356,
536,
12,
267,
283,
11809,
985,
356,
4954,
14,
2246,
12,
267,
283,
8460,
985,
356,
4954,
14,
14885,
12,
267,
283,
6606,
985,
356,
4954,
14,
2019,
272,
789,
421,
199,
318,
1475,
63,
2969,
8,
452,
63,
2969,
12,
7375,
4009,
735,
272,
3762,
275,
942,
272,
340,
1228,
8,
452,
63,
2969,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
|
import copy
import datetime
from django.conf import settings
from django.core.exceptions import FieldError
from django.db.backends import utils as backend_utils
from django.db.models import fields
from django.db.models.constants import LOOKUP_SEP
from django.db.models.query_utils import Q, refs_aggregate
from django.utils import six, timezone
from django.utils.functional import cached_property
class Combinable(object):
"""
Provides the ability to combine one or two objects with
some connector. For example F('foo') + F('bar').
"""
# Arithmetic connectors
ADD = '+'
SUB = '-'
MUL = '*'
DIV = '/'
POW = '^'
# The following is a quoted % operator - it is quoted because it can be
# used in strings that also have parameter substitution.
MOD = '%%'
# Bitwise operators - note that these are generated by .bitand()
# and .bitor(), the '&' and '|' are reserved for boolean operator
# usage.
BITAND = '&'
BITOR = '|'
def _combine(self, other, connector, reversed, node=None):
if not hasattr(other, 'resolve_expression'):
# everything must be resolvable to an expression
if isinstance(other, datetime.timedelta):
other = DurationValue(other, output_field=fields.DurationField())
else:
other = Value(other)
if reversed:
return CombinedExpression(other, connector, self)
return CombinedExpression(self, connector, other)
#############
# OPERATORS #
#############
def __add__(self, other):
return self._combine(other, self.ADD, False)
def __sub__(self, other):
return self._combine(other, self.SUB, False)
def __mul__(self, other):
return self._combine(other, self.MUL, False)
def __truediv__(self, other):
return self._combine(other, self.DIV, False)
def __div__(self, other): # Python 2 compatibility
return type(self).__truediv__(self, other)
def __mod__(self, other):
return self._combine(other, self.MOD, False)
def __pow__(self, other):
return self._combine(other, self.POW, False)
def __and__(self, other):
raise NotImplementedError(
"Use .bitand() and .bitor() for bitwise logical operations."
)
def bitand(self, other):
return self._combine(other, self.BITAND, False)
def __or__(self, other):
raise NotImplementedError(
"Use .bitand() and .bitor() for bitwise logical operations."
)
def bitor(self, other):
return self._combine(other, self.BITOR, False)
def __radd__(self, other):
return self._combine(other, self.ADD, True)
def __rsub__(self, other):
return self._combine(other, self.SUB, True)
def __rmul__(self, other):
return self._combine(other, self.MUL, True)
def __rtruediv__(self, other):
return self._combine(other, self.DIV, True)
def __rdiv__(self, other): # Python 2 compatibility
return type(self).__rtruediv__(self, other)
def __rmod__(self, other):
return self._combine(other, self.MOD, True)
def __rpow__(self, other):
return self._combine(other, self.POW, True)
def __rand__(self, other):
raise NotImplementedError(
"Use .bitand() and .bitor() for bitwise logical operations."
)
def __ror__(self, other):
raise NotImplementedError(
"Use .bitand() and .bitor() for bitwise logical operations."
)
class BaseExpression(object):
"""
Base class for all query expressions.
"""
# aggregate specific fields
is_summary = False
def __init__(self, output_field=None):
self._output_field = output_field
def get_db_converters(self, connection):
return [self.convert_value] + self.output_field.get_db_converters(connection)
def get_source_expressions(self):
return []
def set_source_expressions(self, exprs):
assert len(exprs) == 0
def _parse_expressions(self, *expressions):
return [
arg if hasattr(arg, 'resolve_expression') else (
F(arg) if isinstance(arg, six.string_types) else Value(arg)
) for arg in expressions
]
def as_sql(self, compiler, connection):
"""
Responsible for returning a (sql, [params]) tuple to be included
in the current query.
Different backends can provide their own implementation, by
providing an `as_{vendor}` method and patching the Expression:
```
def override_as_sql(self, compiler, connection):
# custom logic
return super(Expression, self).as_sql(compiler, connection)
setattr(Expression, 'as_' + connection.vendor, override_as_sql)
```
Arguments:
* compiler: the query compiler responsible for generating the query.
Must have a compile method, returning a (sql, [params]) tuple.
Calling compiler(value) will return a quoted `value`.
* connection: the database connection used for the current query.
Returns: (sql, params)
Where `sql` is a string containing ordered sql parameters to be
replaced with the elements of the list `params`.
"""
raise NotImplementedError("Subclasses must implement as_sql()")
@cached_property
def contains_aggregate(self):
for expr in self.get_source_expressions():
if expr and expr.contains_aggregate:
return True
return False
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
"""
Provides the chance to do any preprocessing or validation before being
added to the query.
Arguments:
* query: the backend query implementation
* allow_joins: boolean allowing or denying use of joins
in this query
* reuse: a set of reusable joins for multijoins
* summarize: a terminal aggregate clause
* for_save: whether this expression about to be used in a save or update
Returns: an Expression to be added to the query.
"""
c = self.copy()
c.is_summary = summarize
c.set_source_expressions([
expr.resolve_expression(query, allow_joins, reuse, summarize)
for expr in c.get_source_expressions()
])
return c
def _prepare(self):
"""
Hook used by Field.get_prep_lookup() to do custom preparation.
"""
return self
@property
def field(self):
return self.output_field
@cached_property
def output_field(self):
"""
Returns the output type of this expressions.
"""
if self._output_field_or_none is None:
raise FieldError("Cannot resolve expression type, unknown output_field")
return self._output_field_or_none
@cached_property
def _output_field_or_none(self):
"""
Returns the output field of this expression, or None if no output type
can be resolved. Note that the 'output_field' property will raise
FieldError if no type can be resolved, but this attribute allows for
None values.
"""
if self._output_field is None:
self._resolve_output_field()
return self._output_field
def _resolve_output_field(self):
"""
Attempts to infer the output type of the expression. If the output
fields of all source fields match then we can simply infer the same
type here. This isn't always correct, but it makes sense most of the
time.
Consider the difference between `2 + 2` and `2 / 3`. Inferring
the type here is a convenience for the common case. The user should
supply their own output_field with more complex computations.
If a source does not have an `_output_field` then we exclude it from
this check. If all sources are `None`, then an error will be thrown
higher up the stack in the `output_field` property.
"""
if self._output_field is None:
sources = self.get_source_fields()
num_sources = len(sources)
if num_sources == 0:
self._output_field = None
else:
for source in sources:
if self._output_field is None:
self._output_field = source
if source is not None and not isinstance(self._output_field, source.__class__):
raise FieldError(
"Expression contains mixed types. You must set output_field")
def convert_value(self, value, expression, connection, context):
"""
Expressions provide their own converters because users have the option
of manually specifying the output_field which may be a different type
from the one the database returns.
"""
field = self.output_field
internal_type = field.get_internal_type()
if value is None:
return value
elif internal_type == 'FloatField':
return float(value)
elif internal_type.endswith('IntegerField'):
return int(value)
elif internal_type == 'DecimalField':
return backend_utils.typecast_decimal(value)
return value
def get_lookup(self, lookup):
return self.output_field.get_lookup(lookup)
def get_transform(self, name):
return self.output_field.get_transform(name)
def relabeled_clone(self, change_map):
clone = self.copy()
clone.set_source_expressions(
[e.relabeled_clone(change_map) for e in self.get_source_expressions()])
return clone
def copy(self):
c = copy.copy(self)
c.copied = True
return c
def refs_aggregate(self, existing_aggregates):
"""
Does this expression contain a reference to some of the
existing aggregates? If so, returns the aggregate and also
the lookup parts that *weren't* found. So, if
exsiting_aggregates = {'max_id': Max('id')}
self.name = 'max_id'
queryset.filter(max_id__range=[10,100])
then this method will return Max('id') and those parts of the
name that weren't found. In this case `max_id` is found and the range
portion is returned as ('range',).
"""
for node in self.get_source_expressions():
agg, lookup = node.refs_aggregate(existing_aggregates)
if agg:
return agg, lookup
return False, ()
def get_group_by_cols(self):
if not self.contains_aggregate:
return [self]
cols = []
for source in self.get_source_expressions():
cols.extend(source.get_group_by_cols())
return cols
def get_source_fields(self):
"""
Returns the underlying field types used by this
aggregate.
"""
return [e._output_field_or_none for e in self.get_source_expressions()]
def asc(self):
return OrderBy(self)
def desc(self):
return OrderBy(self, descending=True)
def reverse_ordering(self):
return self
class Expression(BaseExpression, Combinable):
"""
An expression that can be combined with other expressions.
"""
pass
class CombinedExpression(Expression):
def __init__(self, lhs, connector, rhs, output_field=None):
super(CombinedExpression, self).__init__(output_field=output_field)
self.connector = connector
self.lhs = lhs
self.rhs = rhs
def __repr__(self):
return "<{}: {}>".format(self.__class__.__name__, self)
def __str__(self):
return "{} {} {}".format(self.lhs, self.connector, self.rhs)
def get_source_expressions(self):
return [self.lhs, self.rhs]
def set_source_expressions(self, exprs):
self.lhs, self.rhs = exprs
def as_sql(self, compiler, connection):
try:
lhs_output = self.lhs.output_field
except FieldError:
lhs_output = None
try:
rhs_output = self.rhs.output_field
except FieldError:
rhs_output = None
if (not connection.features.has_native_duration_field and
((lhs_output and lhs_output.get_internal_type() == 'DurationField')
or (rhs_output and rhs_output.get_internal_type() == 'DurationField'))):
return DurationExpression(self.lhs, self.connector, self.rhs).as_sql(compiler, connection)
expressions = []
expression_params = []
sql, params = compiler.compile(self.lhs)
expressions.append(sql)
expression_params.extend(params)
sql, params = compiler.compile(self.rhs)
expressions.append(sql)
expression_params.extend(params)
# order of precedence
expression_wrapper = '(%s)'
sql = connection.ops.combine_expression(self.connector, expressions)
return expression_wrapper % sql, expression_params
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
c = self.copy()
c.is_summary = summarize
c.lhs = c.lhs.resolve_expression(query, allow_joins, reuse, summarize, for_save)
c.rhs = c.rhs.resolve_expression(query, allow_joins, reuse, summarize, for_save)
return c
class DurationExpression(CombinedExpression):
def compile(self, side, compiler, connection):
if not isinstance(side, DurationValue):
try:
output = side.output_field
except FieldError:
pass
else:
if output.get_internal_type() == 'DurationField':
sql, params = compiler.compile(side)
return connection.ops.format_for_duration_arithmetic(sql), params
return compiler.compile(side)
def as_sql(self, compiler, connection):
connection.ops.check_expression_support(self)
expressions = []
expression_params = []
sql, params = self.compile(self.lhs, compiler, connection)
expressions.append(sql)
expression_params.extend(params)
sql, params = self.compile(self.rhs, compiler, connection)
expressions.append(sql)
expression_params.extend(params)
# order of precedence
expression_wrapper = '(%s)'
sql = connection.ops.combine_duration_expression(self.connector, expressions)
return expression_wrapper % sql, expression_params
class F(Combinable):
"""
An object capable of resolving references to existing query objects.
"""
def __init__(self, name):
"""
Arguments:
* name: the name of the field this expression references
"""
self.name = name
def __repr__(self):
return "{}({})".format(self.__class__.__name__, self.name)
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
return query.resolve_ref(self.name, allow_joins, reuse, summarize)
def refs_aggregate(self, existing_aggregates):
return refs_aggregate(self.name.split(LOOKUP_SEP), existing_aggregates)
def asc(self):
return OrderBy(self)
def desc(self):
return OrderBy(self, descending=True)
class Func(Expression):
"""
A SQL function call.
"""
function = None
template = '%(function)s(%(expressions)s)'
arg_joiner = ', '
def __init__(self, *expressions, **extra):
output_field = extra.pop('output_field', None)
super(Func, self).__init__(output_field=output_field)
self.source_expressions = self._parse_expressions(*expressions)
self.extra = extra
def __repr__(self):
args = self.arg_joiner.join(str(arg) for arg in self.source_expressions)
extra = ', '.join(str(key) + '=' + str(val) for key, val in self.extra.items())
if extra:
return "{}({}, {})".format(self.__class__.__name__, args, extra)
return "{}({})".format(self.__class__.__name__, args)
def get_source_expressions(self):
return self.source_expressions
def set_source_expressions(self, exprs):
self.source_expressions = exprs
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
c = self.copy()
c.is_summary = summarize
for pos, arg in enumerate(c.source_expressions):
c.source_expressions[pos] = arg.resolve_expression(query, allow_joins, reuse, summarize, for_save)
return c
def as_sql(self, compiler, connection, function=None, template=None):
connection.ops.check_expression_support(self)
sql_parts = []
params = []
for arg in self.source_expressions:
arg_sql, arg_params = compiler.compile(arg)
sql_parts.append(arg_sql)
params.extend(arg_params)
if function is None:
self.extra['function'] = self.extra.get('function', self.function)
else:
self.extra['function'] = function
self.extra['expressions'] = self.extra['field'] = self.arg_joiner.join(sql_parts)
template = template or self.extra.get('template', self.template)
return template % self.extra, params
def as_sqlite(self, *args, **kwargs):
sql, params = self.as_sql(*args, **kwargs)
try:
if self.output_field.get_internal_type() == 'DecimalField':
sql = 'CAST(%s AS NUMERIC)' % sql
except FieldError:
pass
return sql, params
def copy(self):
copy = super(Func, self).copy()
copy.source_expressions = self.source_expressions[:]
copy.extra = self.extra.copy()
return copy
class Value(Expression):
"""
Represents a wrapped value as a node within an expression
"""
def __init__(self, value, output_field=None):
"""
Arguments:
* value: the value this expression represents. The value will be
added into the sql parameter list and properly quoted.
* output_field: an instance of the model field type that this
expression will return, such as IntegerField() or CharField().
"""
super(Value, self).__init__(output_field=output_field)
self.value = value
def __repr__(self):
return "{}({})".format(self.__class__.__name__, self.value)
def as_sql(self, compiler, connection):
connection.ops.check_expression_support(self)
val = self.value
# check _output_field to avoid triggering an exception
if self._output_field is not None:
if self.for_save:
val = self.output_field.get_db_prep_save(val, connection=connection)
else:
val = self.output_field.get_db_prep_value(val, connection=connection)
if val is None:
# cx_Oracle does not always convert None to the appropriate
# NULL type (like in case expressions using numbers), so we
# use a literal SQL NULL
return 'NULL', []
return '%s', [val]
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
c = super(Value, self).resolve_expression(query, allow_joins, reuse, summarize, for_save)
c.for_save = for_save
return c
def get_group_by_cols(self):
return []
class DurationValue(Value):
def as_sql(self, compiler, connection):
connection.ops.check_expression_support(self)
if (connection.features.has_native_duration_field and
connection.features.driver_supports_timedelta_args):
return super(DurationValue, self).as_sql(compiler, connection)
return connection.ops.date_interval_sql(self.value)
class RawSQL(Expression):
def __init__(self, sql, params, output_field=None):
if output_field is None:
output_field = fields.Field()
self.sql, self.params = sql, params
super(RawSQL, self).__init__(output_field=output_field)
def __repr__(self):
return "{}({}, {})".format(self.__class__.__name__, self.sql, self.params)
def as_sql(self, compiler, connection):
return '(%s)' % self.sql, self.params
def get_group_by_cols(self):
return [self]
class Random(Expression):
def __init__(self):
super(Random, self).__init__(output_field=fields.FloatField())
def __repr__(self):
return "Random()"
def as_sql(self, compiler, connection):
return connection.ops.random_function_sql(), []
class Col(Expression):
def __init__(self, alias, target, output_field=None):
if output_field is None:
output_field = target
super(Col, self).__init__(output_field=output_field)
self.alias, self.target = alias, target
def __repr__(self):
return "{}({}, {})".format(
self.__class__.__name__, self.alias, self.target)
def as_sql(self, compiler, connection):
qn = compiler.quote_name_unless_alias
return "%s.%s" % (qn(self.alias), qn(self.target.column)), []
def relabeled_clone(self, relabels):
return self.__class__(relabels.get(self.alias, self.alias), self.target, self.output_field)
def get_group_by_cols(self):
return [self]
def get_db_converters(self, connection):
if self.target == self.output_field:
return self.output_field.get_db_converters(connection)
return (self.output_field.get_db_converters(connection) +
self.target.get_db_converters(connection))
class Ref(Expression):
"""
Reference to column alias of the query. For example, Ref('sum_cost') in
qs.annotate(sum_cost=Sum('cost')) query.
"""
def __init__(self, refs, source):
super(Ref, self).__init__()
self.refs, self.source = refs, source
def __repr__(self):
return "{}({}, {})".format(self.__class__.__name__, self.refs, self.source)
def get_source_expressions(self):
return [self.source]
def set_source_expressions(self, exprs):
self.source, = exprs
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
# The sub-expression `source` has already been resolved, as this is
# just a reference to the name of `source`.
return self
def relabeled_clone(self, relabels):
return self
def as_sql(self, compiler, connection):
return "%s" % connection.ops.quote_name(self.refs), []
def get_group_by_cols(self):
return [self]
class ExpressionWrapper(Expression):
"""
An expression that can wrap another expression so that it can provide
extra context to the inner expression, such as the output_field.
"""
def __init__(self, expression, output_field):
super(ExpressionWrapper, self).__init__(output_field=output_field)
self.expression = expression
def set_source_expressions(self, exprs):
self.expression = exprs[0]
def get_source_expressions(self):
return [self.expression]
def as_sql(self, compiler, connection):
return self.expression.as_sql(compiler, connection)
def __repr__(self):
return "{}({})".format(self.__class__.__name__, self.expression)
class When(Expression):
template = 'WHEN %(condition)s THEN %(result)s'
def __init__(self, condition=None, then=None, **lookups):
if lookups and condition is None:
condition, lookups = Q(**lookups), None
if condition is None or not isinstance(condition, Q) or lookups:
raise TypeError("__init__() takes either a Q object or lookups as keyword arguments")
super(When, self).__init__(output_field=None)
self.condition = condition
self.result = self._parse_expressions(then)[0]
def __str__(self):
return "WHEN %r THEN %r" % (self.condition, self.result)
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self)
def get_source_expressions(self):
return [self.condition, self.result]
def set_source_expressions(self, exprs):
self.condition, self.result = exprs
def get_source_fields(self):
# We're only interested in the fields of the result expressions.
return [self.result._output_field_or_none]
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
c = self.copy()
c.is_summary = summarize
c.condition = c.condition.resolve_expression(query, allow_joins, reuse, summarize, False)
c.result = c.result.resolve_expression(query, allow_joins, reuse, summarize, for_save)
return c
def as_sql(self, compiler, connection, template=None):
connection.ops.check_expression_support(self)
template_params = {}
sql_params = []
condition_sql, condition_params = compiler.compile(self.condition)
template_params['condition'] = condition_sql
sql_params.extend(condition_params)
result_sql, result_params = compiler.compile(self.result)
template_params['result'] = result_sql
sql_params.extend(result_params)
template = template or self.template
return template % template_params, sql_params
def get_group_by_cols(self):
# This is not a complete expression and cannot be used in GROUP BY.
cols = []
for source in self.get_source_expressions():
cols.extend(source.get_group_by_cols())
return cols
class Case(Expression):
"""
An SQL searched CASE expression:
CASE
WHEN n > 0
THEN 'positive'
WHEN n < 0
THEN 'negative'
ELSE 'zero'
END
"""
template = 'CASE %(cases)s ELSE %(default)s END'
case_joiner = ' '
def __init__(self, *cases, **extra):
if not all(isinstance(case, When) for case in cases):
raise TypeError("Positional arguments must all be When objects.")
default = extra.pop('default', None)
output_field = extra.pop('output_field', None)
super(Case, self).__init__(output_field)
self.cases = list(cases)
self.default = self._parse_expressions(default)[0]
def __str__(self):
return "CASE %s, ELSE %r" % (', '.join(str(c) for c in self.cases), self.default)
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self)
def get_source_expressions(self):
return self.cases + [self.default]
def set_source_expressions(self, exprs):
self.cases = exprs[:-1]
self.default = exprs[-1]
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
c = self.copy()
c.is_summary = summarize
for pos, case in enumerate(c.cases):
c.cases[pos] = case.resolve_expression(query, allow_joins, reuse, summarize, for_save)
c.default = c.default.resolve_expression(query, allow_joins, reuse, summarize, for_save)
return c
def copy(self):
c = super(Case, self).copy()
c.cases = c.cases[:]
return c
def as_sql(self, compiler, connection, template=None, extra=None):
connection.ops.check_expression_support(self)
if not self.cases:
return compiler.compile(self.default)
template_params = dict(extra) if extra else {}
case_parts = []
sql_params = []
for case in self.cases:
case_sql, case_params = compiler.compile(case)
case_parts.append(case_sql)
sql_params.extend(case_params)
template_params['cases'] = self.case_joiner.join(case_parts)
default_sql, default_params = compiler.compile(self.default)
template_params['default'] = default_sql
sql_params.extend(default_params)
template = template or self.template
sql = template % template_params
if self._output_field_or_none is not None:
sql = connection.ops.unification_cast_sql(self.output_field) % sql
return sql, sql_params
class Date(Expression):
"""
Add a date selection column.
"""
def __init__(self, lookup, lookup_type):
super(Date, self).__init__(output_field=fields.DateField())
self.lookup = lookup
self.col = None
self.lookup_type = lookup_type
def __repr__(self):
return "{}({}, {})".format(self.__class__.__name__, self.lookup, self.lookup_type)
def get_source_expressions(self):
return [self.col]
def set_source_expressions(self, exprs):
self.col, = exprs
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
copy = self.copy()
copy.col = query.resolve_ref(self.lookup, allow_joins, reuse, summarize)
field = copy.col.output_field
assert isinstance(field, fields.DateField), "%r isn't a DateField." % field.name
if settings.USE_TZ:
assert not isinstance(field, fields.DateTimeField), (
"%r is a DateTimeField, not a DateField." % field.name
)
return copy
def as_sql(self, compiler, connection):
sql, params = self.col.as_sql(compiler, connection)
assert not(params)
return connection.ops.date_trunc_sql(self.lookup_type, sql), []
def copy(self):
copy = super(Date, self).copy()
copy.lookup = self.lookup
copy.lookup_type = self.lookup_type
return copy
def convert_value(self, value, expression, connection, context):
if isinstance(value, datetime.datetime):
value = value.date()
return value
class DateTime(Expression):
"""
Add a datetime selection column.
"""
def __init__(self, lookup, lookup_type, tzinfo):
super(DateTime, self).__init__(output_field=fields.DateTimeField())
self.lookup = lookup
self.col = None
self.lookup_type = lookup_type
if tzinfo is None:
self.tzname = None
else:
self.tzname = timezone._get_timezone_name(tzinfo)
self.tzinfo = tzinfo
def __repr__(self):
return "{}({}, {}, {})".format(
self.__class__.__name__, self.lookup, self.lookup_type, self.tzinfo)
def get_source_expressions(self):
return [self.col]
def set_source_expressions(self, exprs):
self.col, = exprs
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
copy = self.copy()
copy.col = query.resolve_ref(self.lookup, allow_joins, reuse, summarize)
field = copy.col.output_field
assert isinstance(field, fields.DateTimeField), (
"%r isn't a DateTimeField." % field.name
)
return copy
def as_sql(self, compiler, connection):
sql, params = self.col.as_sql(compiler, connection)
assert not(params)
return connection.ops.datetime_trunc_sql(self.lookup_type, sql, self.tzname)
def copy(self):
copy = super(DateTime, self).copy()
copy.lookup = self.lookup
copy.lookup_type = self.lookup_type
copy.tzname = self.tzname
return copy
def convert_value(self, value, expression, connection, context):
if settings.USE_TZ:
if value is None:
raise ValueError(
"Database returned an invalid value in QuerySet.datetimes(). "
"Are time zone definitions for your database and pytz installed?"
)
value = value.replace(tzinfo=None)
value = timezone.make_aware(value, self.tzinfo)
return value
class OrderBy(BaseExpression):
template = '%(expression)s %(ordering)s'
def __init__(self, expression, descending=False):
self.descending = descending
if not hasattr(expression, 'resolve_expression'):
raise ValueError('expression must be an expression type')
self.expression = expression
def __repr__(self):
return "{}({}, descending={})".format(
self.__class__.__name__, self.expression, self.descending)
def set_source_expressions(self, exprs):
self.expression = exprs[0]
def get_source_expressions(self):
return [self.expression]
def as_sql(self, compiler, connection):
connection.ops.check_expression_support(self)
expression_sql, params = compiler.compile(self.expression)
placeholders = {'expression': expression_sql}
placeholders['ordering'] = 'DESC' if self.descending else 'ASC'
return (self.template % placeholders).rstrip(), params
def get_group_by_cols(self):
cols = []
for source in self.get_source_expressions():
cols.extend(source.get_group_by_cols())
return cols
def reverse_ordering(self):
self.descending = not self.descending
return self
def asc(self):
self.descending = False
def desc(self):
self.descending = True
|
bsd-3-clause
|
[
646,
1331,
199,
646,
2197,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
3924,
492,
27691,
199,
504,
1639,
14,
697,
14,
7765,
492,
3778,
465,
4865,
63,
1208,
199,
504,
1639,
14,
697,
14,
992,
492,
1504,
199,
504,
1639,
14,
697,
14,
992,
14,
5559,
492,
3412,
3593,
2160,
63,
20848,
199,
504,
1639,
14,
697,
14,
992,
14,
1131,
63,
1208,
492,
1413,
12,
15749,
63,
7516,
199,
504,
1639,
14,
1208,
492,
3816,
12,
7137,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
421,
199,
533,
22170,
461,
8,
785,
304,
272,
408,
272,
21552,
314,
21255,
370,
13323,
1373,
503,
2877,
2251,
543,
272,
2005,
13252,
14,
2104,
2893,
481,
360,
1421,
358,
435,
481,
360,
1700,
1959,
272,
408,
339,
327,
31153,
18764,
4907,
1384,
272,
21380,
275,
20246,
272,
7605,
275,
10791,
272,
603,
1293,
275,
13626,
272,
5266,
54,
275,
7324,
272,
3625,
55,
275,
14452,
7,
272,
327,
710,
2569,
365,
282,
10999,
450,
4182,
446,
652,
365,
10999,
2952,
652,
883,
506,
272,
327,
1202,
315,
3326,
626,
2597,
1172,
2725,
20584,
14,
272,
30920,
275,
23100,
7,
339,
327,
10199,
2605,
10211,
446,
5317,
626,
3520,
787,
4046,
701,
1275,
2075,
460,
342,
272,
327,
436,
1275,
2075,
269,
1062,
314,
29285,
436,
24628,
787,
4644,
367,
5046,
4182,
272,
327,
4503,
14,
272,
699,
649,
3649,
275,
29285,
272,
699,
649,
726,
275,
24628,
339,
347,
485,
13307,
8,
277,
12,
1163,
12,
13252,
12,
10822,
12,
1031,
29,
403,
304,
267,
340,
440,
2688,
8,
1848,
12,
283,
6983,
63,
5599,
735,
288,
327,
8137,
1471,
506,
17416,
30456,
370,
376,
3965,
288,
340,
1228,
8,
1848,
12,
2197,
14,
7473,
304,
355,
1163,
275,
31836,
1110,
8,
1848,
12,
1072,
63,
698,
29,
955,
14,
13283,
792,
1012,
288,
587,
26,
355,
1163,
275,
1594,
8,
1848,
9,
398,
340,
10822,
26,
288,
372,
22170,
379,
9093,
8,
1848,
12,
13252,
12,
291,
9,
267,
372,
22170,
379,
9093,
8,
277,
12,
13252,
12,
1163,
9,
339,
21937,
8776,
272,
327,
29771,
19033,
327,
272,
21937,
8776,
339,
347,
636,
525,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
9732,
12,
756,
9,
339,
347,
636,
954,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
6348,
12,
756,
9,
339,
347,
636,
3703,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
45,
1293,
12,
756,
9,
339,
347,
636,
22062,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
27051,
12,
756,
9,
339,
347,
636,
3015,
721,
277,
12,
1163,
304,
221,
327,
2018,
499,
7163,
267,
372,
730,
8,
277,
2843,
22062,
721,
277,
12,
1163,
9,
339,
347,
636,
1494,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
8816,
12,
756,
9,
339,
347,
636,
8278,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
1512,
55,
12,
756,
9,
339,
347,
636,
460,
721,
277,
12,
1163,
304,
267,
746,
4279,
8,
288,
298,
6119,
1275,
2075,
460,
342,
436,
1275,
2075,
269,
342,
367,
31927,
11461,
5331,
2122,
267,
776,
339,
347,
4546,
460,
8,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
11970,
3649,
12,
756,
9,
339,
347,
636,
269,
721,
277,
12,
1163,
304,
267,
746,
4279,
8,
288,
298,
6119,
1275,
2075,
460,
342,
436,
1275,
2075,
269,
342,
367,
31927,
11461,
5331,
2122,
267,
776,
339,
347,
330,
4330,
8,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
11970,
726,
12,
756,
9,
339,
347,
636,
22958,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
9732,
12,
715,
9,
339,
347,
636,
82,
954,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
6348,
12,
715,
9,
339,
347,
636,
27968,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
45,
1293,
12,
715,
9,
339,
347,
636,
82,
22062,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
27051,
12,
715,
9,
339,
347,
636,
82,
3015,
721,
277,
12,
1163,
304,
221,
327,
2018,
499,
7163,
267,
372,
730,
8,
277,
2843,
82,
22062,
721,
277,
12,
1163,
9,
339,
347,
636,
82,
1494,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
8816,
12,
715,
9,
339,
347,
636,
82,
8278,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
1512,
55,
12,
715,
9,
339,
347,
636,
3759,
721,
277,
12,
1163,
304,
267,
746,
4279,
8,
288,
298,
6119,
1275,
2075,
460,
342,
436,
1275,
2075,
269,
342,
367,
31927,
11461,
5331,
2122,
267,
776,
339,
347,
636,
451,
721,
277,
12,
1163,
304,
267,
746,
4279,
8,
288,
298,
6119,
1275,
2075,
460,
342,
436,
1275,
2075,
269,
342,
367,
31927,
11461,
5331,
2122,
267,
776,
421,
199,
533,
3523,
9093,
8,
785,
304,
272,
408,
272,
3523,
1021,
367,
1006,
1827,
8455,
14,
272,
408,
339,
327,
9531,
2488,
1504,
272,
365,
63,
4705,
275,
756,
339,
347,
636,
826,
721,
277,
12,
1072,
63,
698,
29,
403,
304,
267,
291,
423,
1199,
63,
698,
275,
1072,
63,
698,
339,
347,
664,
63,
697,
63,
17911,
8,
277,
12,
1950,
304,
267,
372,
359,
277,
14,
3916,
63,
585,
61,
435,
291,
14,
1199,
63,
698,
14,
362,
63,
697,
63,
17911,
8,
2105,
9,
339,
347,
664,
63,
1365,
63,
15264,
8,
277,
304,
267,
372,
942,
339,
347,
663,
63,
1365,
63,
15264,
8,
277,
12,
23770,
304,
267,
702,
822,
8,
16006,
9,
508,
378,
339,
347,
485,
1122,
63,
15264,
8,
277,
12,
627,
15264,
304,
267,
372,
359,
288,
1680,
340,
2688,
8,
1273,
12,
283,
6983,
63,
5599,
358
] |
[
1331,
199,
646,
2197,
199,
199,
504,
1639,
14,
2190,
492,
2202,
199,
504,
1639,
14,
1018,
14,
3924,
492,
27691,
199,
504,
1639,
14,
697,
14,
7765,
492,
3778,
465,
4865,
63,
1208,
199,
504,
1639,
14,
697,
14,
992,
492,
1504,
199,
504,
1639,
14,
697,
14,
992,
14,
5559,
492,
3412,
3593,
2160,
63,
20848,
199,
504,
1639,
14,
697,
14,
992,
14,
1131,
63,
1208,
492,
1413,
12,
15749,
63,
7516,
199,
504,
1639,
14,
1208,
492,
3816,
12,
7137,
199,
504,
1639,
14,
1208,
14,
15481,
492,
6328,
63,
1829,
421,
199,
533,
22170,
461,
8,
785,
304,
272,
408,
272,
21552,
314,
21255,
370,
13323,
1373,
503,
2877,
2251,
543,
272,
2005,
13252,
14,
2104,
2893,
481,
360,
1421,
358,
435,
481,
360,
1700,
1959,
272,
408,
339,
327,
31153,
18764,
4907,
1384,
272,
21380,
275,
20246,
272,
7605,
275,
10791,
272,
603,
1293,
275,
13626,
272,
5266,
54,
275,
7324,
272,
3625,
55,
275,
14452,
7,
272,
327,
710,
2569,
365,
282,
10999,
450,
4182,
446,
652,
365,
10999,
2952,
652,
883,
506,
272,
327,
1202,
315,
3326,
626,
2597,
1172,
2725,
20584,
14,
272,
30920,
275,
23100,
7,
339,
327,
10199,
2605,
10211,
446,
5317,
626,
3520,
787,
4046,
701,
1275,
2075,
460,
342,
272,
327,
436,
1275,
2075,
269,
1062,
314,
29285,
436,
24628,
787,
4644,
367,
5046,
4182,
272,
327,
4503,
14,
272,
699,
649,
3649,
275,
29285,
272,
699,
649,
726,
275,
24628,
339,
347,
485,
13307,
8,
277,
12,
1163,
12,
13252,
12,
10822,
12,
1031,
29,
403,
304,
267,
340,
440,
2688,
8,
1848,
12,
283,
6983,
63,
5599,
735,
288,
327,
8137,
1471,
506,
17416,
30456,
370,
376,
3965,
288,
340,
1228,
8,
1848,
12,
2197,
14,
7473,
304,
355,
1163,
275,
31836,
1110,
8,
1848,
12,
1072,
63,
698,
29,
955,
14,
13283,
792,
1012,
288,
587,
26,
355,
1163,
275,
1594,
8,
1848,
9,
398,
340,
10822,
26,
288,
372,
22170,
379,
9093,
8,
1848,
12,
13252,
12,
291,
9,
267,
372,
22170,
379,
9093,
8,
277,
12,
13252,
12,
1163,
9,
339,
21937,
8776,
272,
327,
29771,
19033,
327,
272,
21937,
8776,
339,
347,
636,
525,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
9732,
12,
756,
9,
339,
347,
636,
954,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
6348,
12,
756,
9,
339,
347,
636,
3703,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
45,
1293,
12,
756,
9,
339,
347,
636,
22062,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
27051,
12,
756,
9,
339,
347,
636,
3015,
721,
277,
12,
1163,
304,
221,
327,
2018,
499,
7163,
267,
372,
730,
8,
277,
2843,
22062,
721,
277,
12,
1163,
9,
339,
347,
636,
1494,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
8816,
12,
756,
9,
339,
347,
636,
8278,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
1512,
55,
12,
756,
9,
339,
347,
636,
460,
721,
277,
12,
1163,
304,
267,
746,
4279,
8,
288,
298,
6119,
1275,
2075,
460,
342,
436,
1275,
2075,
269,
342,
367,
31927,
11461,
5331,
2122,
267,
776,
339,
347,
4546,
460,
8,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
11970,
3649,
12,
756,
9,
339,
347,
636,
269,
721,
277,
12,
1163,
304,
267,
746,
4279,
8,
288,
298,
6119,
1275,
2075,
460,
342,
436,
1275,
2075,
269,
342,
367,
31927,
11461,
5331,
2122,
267,
776,
339,
347,
330,
4330,
8,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
11970,
726,
12,
756,
9,
339,
347,
636,
22958,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
9732,
12,
715,
9,
339,
347,
636,
82,
954,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
6348,
12,
715,
9,
339,
347,
636,
27968,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
45,
1293,
12,
715,
9,
339,
347,
636,
82,
22062,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
27051,
12,
715,
9,
339,
347,
636,
82,
3015,
721,
277,
12,
1163,
304,
221,
327,
2018,
499,
7163,
267,
372,
730,
8,
277,
2843,
82,
22062,
721,
277,
12,
1163,
9,
339,
347,
636,
82,
1494,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
8816,
12,
715,
9,
339,
347,
636,
82,
8278,
721,
277,
12,
1163,
304,
267,
372,
291,
423,
13307,
8,
1848,
12,
291,
14,
1512,
55,
12,
715,
9,
339,
347,
636,
3759,
721,
277,
12,
1163,
304,
267,
746,
4279,
8,
288,
298,
6119,
1275,
2075,
460,
342,
436,
1275,
2075,
269,
342,
367,
31927,
11461,
5331,
2122,
267,
776,
339,
347,
636,
451,
721,
277,
12,
1163,
304,
267,
746,
4279,
8,
288,
298,
6119,
1275,
2075,
460,
342,
436,
1275,
2075,
269,
342,
367,
31927,
11461,
5331,
2122,
267,
776,
421,
199,
533,
3523,
9093,
8,
785,
304,
272,
408,
272,
3523,
1021,
367,
1006,
1827,
8455,
14,
272,
408,
339,
327,
9531,
2488,
1504,
272,
365,
63,
4705,
275,
756,
339,
347,
636,
826,
721,
277,
12,
1072,
63,
698,
29,
403,
304,
267,
291,
423,
1199,
63,
698,
275,
1072,
63,
698,
339,
347,
664,
63,
697,
63,
17911,
8,
277,
12,
1950,
304,
267,
372,
359,
277,
14,
3916,
63,
585,
61,
435,
291,
14,
1199,
63,
698,
14,
362,
63,
697,
63,
17911,
8,
2105,
9,
339,
347,
664,
63,
1365,
63,
15264,
8,
277,
304,
267,
372,
942,
339,
347,
663,
63,
1365,
63,
15264,
8,
277,
12,
23770,
304,
267,
702,
822,
8,
16006,
9,
508,
378,
339,
347,
485,
1122,
63,
15264,
8,
277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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
] |
Bumpybox/pyblish-bumpybox
|
pyblish_bumpybox/plugins/hiero/extract_ftrack_components.py
|
1
|
3223
|
from pyblish import api
from pyblish_bumpybox import inventory
class ExtractFtrackComponents(api.InstancePlugin):
""" Extracting data to ftrack components.
Offset to get shot data from "extract_ftrack_shot"
"""
families = ["ftrack"]
label = "Ftrack Components"
hosts = ["hiero"]
order = inventory.get_order(__file__, "ExtractFtrackComponents")
hosts = ["hiero"]
def process(self, instance):
instance.data["ftrackComponentsList"] = instance.data.get(
"ftrackComponentsList", []
)
session = instance.context.data["ftrackSession"]
# Audio component
if "audio" in instance.data:
instance.data["ftrackComponentsList"].append({
"assettype_data": {
"short": "audio",
},
"asset_data": {
"name": instance.data["name"],
"parent": session.get(
"Shot", instance.data["ftrackShotId"]
),
},
"assetversion_data": {
"version": instance.context.data["version"],
},
"component_overwrite": True,
"component_path": instance.data["audio"]
})
# Nuke scene component
if ("nuke" in instance.data.get("families", []) and
"collection" in instance.data):
instance.data["ftrackComponentsList"].append({
"assettype_data": {
"short": "scene",
},
"asset_data": {
"name": instance.data["name"],
"parent": session.get(
"Shot", instance.data["ftrackShotId"]
),
},
"assetversion_data": {
"version": instance.context.data["version"],
},
"component_data": {
"name": "nuke",
},
"component_overwrite": True,
"component_path": instance.data["collection"].format()
})
# Transcodes components
if "transcodes" in instance.data:
for collection in instance.data["transcodes"]:
assettype = "img"
if list(collection)[0].endswith(".mov"):
assettype = "mov"
instance.data["ftrackComponentsList"].append({
"assettype_data": {
"short": assettype,
},
"asset_data": {
"name": instance.data["name"],
"parent": session.get(
"Shot", instance.data["ftrackShotId"]
),
},
"assetversion_data": {
"version": instance.context.data["version"],
},
"component_data": {
"name": collection.tag_type,
},
"component_overwrite": True,
"component_path": collection.format()
})
|
lgpl-3.0
|
[
504,
1134,
66,
1891,
492,
2986,
199,
504,
1134,
66,
1891,
63,
464,
5086,
1977,
492,
8200,
421,
199,
533,
12892,
38,
3885,
22714,
8,
1246,
14,
3244,
5061,
304,
272,
408,
12892,
316,
666,
370,
289,
3885,
7323,
14,
339,
29432,
370,
664,
1033,
357,
666,
687,
298,
5005,
63,
856,
8085,
63,
2782,
2,
272,
408,
339,
21450,
20111,
275,
2097,
856,
8085,
937,
272,
1768,
275,
298,
38,
3885,
17823,
2,
272,
7057,
275,
2097,
5812,
3478,
937,
272,
1865,
275,
8200,
14,
362,
63,
1648,
3460,
493,
3108,
298,
12147,
38,
3885,
22714,
531,
272,
7057,
275,
2097,
5812,
3478,
937,
339,
347,
2112,
8,
277,
12,
1256,
304,
398,
1256,
14,
576,
905,
856,
8085,
22714,
1296,
937,
275,
1256,
14,
576,
14,
362,
8,
288,
298,
856,
8085,
22714,
1296,
401,
942,
267,
776,
267,
2351,
275,
1256,
14,
1100,
14,
576,
905,
856,
8085,
4434,
937,
398,
327,
30885,
3931,
267,
340,
298,
8130,
2,
315,
1256,
14,
576,
26,
953,
1256,
14,
576,
905,
856,
8085,
22714,
1296,
4140,
740,
2561,
355,
298,
6562,
466,
63,
576,
582,
469,
490,
298,
3612,
582,
298,
8130,
401,
355,
1660,
355,
298,
6562,
63,
576,
582,
469,
490,
298,
354,
582,
1256,
14,
576,
905,
354,
2255,
490,
298,
1708,
582,
2351,
14,
362,
8,
717,
298,
2662,
357,
401,
1256,
14,
576,
905,
856,
8085,
2662,
357,
1304,
937,
490,
2318,
355,
1660,
355,
298,
6562,
1023,
63,
576,
582,
469,
490,
298,
1023,
582,
1256,
14,
1100,
14,
576,
905,
1023,
2255,
355,
1660,
355,
298,
3173,
63,
14658,
582,
715,
12,
355,
298,
3173,
63,
515,
582,
1256,
14,
576,
905,
8130,
937,
288,
3828,
398,
327,
653,
85,
415,
13856,
3931,
267,
340,
1689,
4850,
415,
2,
315,
1256,
14,
576,
14,
362,
480,
32337,
401,
3073,
436,
1779,
298,
3627,
2,
315,
1256,
14,
576,
304,
953,
1256,
14,
576,
905,
856,
8085,
22714,
1296,
4140,
740,
2561,
355,
298,
6562,
466,
63,
576,
582,
469,
490,
298,
3612,
582,
298,
10436,
401,
355,
1660,
355,
298,
6562,
63,
576,
582,
469,
490,
298,
354,
582,
1256,
14,
576,
905,
354,
2255,
490,
298,
1708,
582,
2351,
14,
362,
8,
717,
298,
2662,
357,
401,
1256,
14,
576,
905,
856,
8085,
2662,
357,
1304,
937,
490,
2318,
355,
1660,
355,
298,
6562,
1023,
63,
576,
582,
469,
490,
298,
1023,
582,
1256,
14,
1100,
14,
576,
905,
1023,
2255,
355,
1660,
355,
298,
3173,
63,
576,
582,
469,
490,
298,
354,
582,
298,
4850,
415,
401,
355,
1660,
355,
298,
3173,
63,
14658,
582,
715,
12,
355,
298,
3173,
63,
515,
582,
1256,
14,
576,
905,
3627,
4140,
908,
342,
288,
3828,
398,
327,
6266,
6021,
7323,
267,
340,
298,
1515,
6021,
2,
315,
1256,
14,
576,
26,
953,
367,
3245,
315,
1256,
14,
576,
905,
1515,
6021,
6229,
2234,
8977,
466,
275,
298,
4060,
2,
355,
340,
769,
8,
3627,
2788,
16,
1055,
4130,
9520,
14469,
2349,
490,
8977,
466,
275,
298,
14469,
2,
2234,
1256,
14,
576,
905,
856,
8085,
22714,
1296,
4140,
740,
2561,
490,
298,
6562,
466,
63,
576,
582,
469,
717,
298,
3612,
582,
8977,
466,
12,
490,
1660,
490,
298,
6562,
63,
576,
582,
469,
717,
298,
354,
582,
1256,
14,
576,
905,
354,
2255,
717,
298,
1708,
582,
2351,
14,
362,
8,
1169,
298,
2662,
357,
401,
1256,
14,
576,
905,
856,
8085,
2662,
357,
1304,
937,
717,
2318,
490,
1660,
490,
298,
6562,
1023,
63,
576,
582,
469,
717,
298,
1023,
582,
1256,
14,
1100,
14,
576,
905,
1023,
2255,
490,
1660,
490,
298,
3173,
63,
576,
582,
469,
717,
298,
354,
582,
3245,
14,
1450,
63,
466,
12,
490,
1660,
490,
298,
3173,
63,
14658,
582,
715,
12,
490,
298,
3173,
63,
515,
582,
3245,
14,
908,
342,
355,
3828,
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
] |
[
1134,
66,
1891,
492,
2986,
199,
504,
1134,
66,
1891,
63,
464,
5086,
1977,
492,
8200,
421,
199,
533,
12892,
38,
3885,
22714,
8,
1246,
14,
3244,
5061,
304,
272,
408,
12892,
316,
666,
370,
289,
3885,
7323,
14,
339,
29432,
370,
664,
1033,
357,
666,
687,
298,
5005,
63,
856,
8085,
63,
2782,
2,
272,
408,
339,
21450,
20111,
275,
2097,
856,
8085,
937,
272,
1768,
275,
298,
38,
3885,
17823,
2,
272,
7057,
275,
2097,
5812,
3478,
937,
272,
1865,
275,
8200,
14,
362,
63,
1648,
3460,
493,
3108,
298,
12147,
38,
3885,
22714,
531,
272,
7057,
275,
2097,
5812,
3478,
937,
339,
347,
2112,
8,
277,
12,
1256,
304,
398,
1256,
14,
576,
905,
856,
8085,
22714,
1296,
937,
275,
1256,
14,
576,
14,
362,
8,
288,
298,
856,
8085,
22714,
1296,
401,
942,
267,
776,
267,
2351,
275,
1256,
14,
1100,
14,
576,
905,
856,
8085,
4434,
937,
398,
327,
30885,
3931,
267,
340,
298,
8130,
2,
315,
1256,
14,
576,
26,
953,
1256,
14,
576,
905,
856,
8085,
22714,
1296,
4140,
740,
2561,
355,
298,
6562,
466,
63,
576,
582,
469,
490,
298,
3612,
582,
298,
8130,
401,
355,
1660,
355,
298,
6562,
63,
576,
582,
469,
490,
298,
354,
582,
1256,
14,
576,
905,
354,
2255,
490,
298,
1708,
582,
2351,
14,
362,
8,
717,
298,
2662,
357,
401,
1256,
14,
576,
905,
856,
8085,
2662,
357,
1304,
937,
490,
2318,
355,
1660,
355,
298,
6562,
1023,
63,
576,
582,
469,
490,
298,
1023,
582,
1256,
14,
1100,
14,
576,
905,
1023,
2255,
355,
1660,
355,
298,
3173,
63,
14658,
582,
715,
12,
355,
298,
3173,
63,
515,
582,
1256,
14,
576,
905,
8130,
937,
288,
3828,
398,
327,
653,
85,
415,
13856,
3931,
267,
340,
1689,
4850,
415,
2,
315,
1256,
14,
576,
14,
362,
480,
32337,
401,
3073,
436,
1779,
298,
3627,
2,
315,
1256,
14,
576,
304,
953,
1256,
14,
576,
905,
856,
8085,
22714,
1296,
4140,
740,
2561,
355,
298,
6562,
466,
63,
576,
582,
469,
490,
298,
3612,
582,
298,
10436,
401,
355,
1660,
355,
298,
6562,
63,
576,
582,
469,
490,
298,
354,
582,
1256,
14,
576,
905,
354,
2255,
490,
298,
1708,
582,
2351,
14,
362,
8,
717,
298,
2662,
357,
401,
1256,
14,
576,
905,
856,
8085,
2662,
357,
1304,
937,
490,
2318,
355,
1660,
355,
298,
6562,
1023,
63,
576,
582,
469,
490,
298,
1023,
582,
1256,
14,
1100,
14,
576,
905,
1023,
2255,
355,
1660,
355,
298,
3173,
63,
576,
582,
469,
490,
298,
354,
582,
298,
4850,
415,
401,
355,
1660,
355,
298,
3173,
63,
14658,
582,
715,
12,
355,
298,
3173,
63,
515,
582,
1256,
14,
576,
905,
3627,
4140,
908,
342,
288,
3828,
398,
327,
6266,
6021,
7323,
267,
340,
298,
1515,
6021,
2,
315,
1256,
14,
576,
26,
953,
367,
3245,
315,
1256,
14,
576,
905,
1515,
6021,
6229,
2234,
8977,
466,
275,
298,
4060,
2,
355,
340,
769,
8,
3627,
2788,
16,
1055,
4130,
9520,
14469,
2349,
490,
8977,
466,
275,
298,
14469,
2,
2234,
1256,
14,
576,
905,
856,
8085,
22714,
1296,
4140,
740,
2561,
490,
298,
6562,
466,
63,
576,
582,
469,
717,
298,
3612,
582,
8977,
466,
12,
490,
1660,
490,
298,
6562,
63,
576,
582,
469,
717,
298,
354,
582,
1256,
14,
576,
905,
354,
2255,
717,
298,
1708,
582,
2351,
14,
362,
8,
1169,
298,
2662,
357,
401,
1256,
14,
576,
905,
856,
8085,
2662,
357,
1304,
937,
717,
2318,
490,
1660,
490,
298,
6562,
1023,
63,
576,
582,
469,
717,
298,
1023,
582,
1256,
14,
1100,
14,
576,
905,
1023,
2255,
490,
1660,
490,
298,
3173,
63,
576,
582,
469,
717,
298,
354,
582,
3245,
14,
1450,
63,
466,
12,
490,
1660,
490,
298,
3173,
63,
14658,
582,
715,
12,
490,
298,
3173,
63,
515,
582,
3245,
14,
908,
342,
355,
3828,
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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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
] |
ff94315/hiwifi-openwrt-HC5661-HC5761
|
staging_dir/target-mipsel_r2_uClibc-0.9.33.2/usr/lib/python2.7/test/test_import.py
|
16
|
18210
|
import errno
import imp
import marshal
import os
import py_compile
import random
import stat
import sys
import unittest
from test.test_support import (unlink, TESTFN, unload, run_unittest, rmtree,
is_jython, check_warnings, EnvironmentVarGuard)
import textwrap
from test import script_helper
def remove_files(name):
for f in (name + os.extsep + "py",
name + os.extsep + "pyc",
name + os.extsep + "pyo",
name + os.extsep + "pyw",
name + "$py.class"):
unlink(f)
class ImportTests(unittest.TestCase):
def tearDown(self):
unload(TESTFN)
setUp = tearDown
def test_case_sensitivity(self):
# Brief digression to test that import is case-sensitive: if we got
# this far, we know for sure that "random" exists.
try:
import RAnDoM
except ImportError:
pass
else:
self.fail("import of RAnDoM should have failed (case mismatch)")
def test_double_const(self):
# Another brief digression to test the accuracy of manifest float
# constants.
from test import double_const # don't blink -- that *was* the test
def test_import(self):
def test_with_extension(ext):
# The extension is normally ".py", perhaps ".pyw".
source = TESTFN + ext
pyo = TESTFN + os.extsep + "pyo"
if is_jython:
pyc = TESTFN + "$py.class"
else:
pyc = TESTFN + os.extsep + "pyc"
with open(source, "w") as f:
print >> f, ("# This tests Python's ability to import a", ext,
"file.")
a = random.randrange(1000)
b = random.randrange(1000)
print >> f, "a =", a
print >> f, "b =", b
try:
mod = __import__(TESTFN)
except ImportError, err:
self.fail("import from %s failed: %s" % (ext, err))
else:
self.assertEqual(mod.a, a,
"module loaded (%s) but contents invalid" % mod)
self.assertEqual(mod.b, b,
"module loaded (%s) but contents invalid" % mod)
finally:
unlink(source)
try:
imp.reload(mod)
except ImportError, err:
self.fail("import from .pyc/.pyo failed: %s" % err)
finally:
unlink(pyc)
unlink(pyo)
unload(TESTFN)
sys.path.insert(0, os.curdir)
try:
test_with_extension(os.extsep + "py")
if sys.platform.startswith("win"):
for ext in [".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw"]:
test_with_extension(ext)
finally:
del sys.path[0]
@unittest.skipUnless(os.name == 'posix', "test meaningful only on posix systems")
def test_execute_bit_not_copied(self):
# Issue 6070: under posix .pyc files got their execute bit set if
# the .py file had the execute bit set, but they aren't executable.
oldmask = os.umask(022)
sys.path.insert(0, os.curdir)
try:
fname = TESTFN + os.extsep + "py"
f = open(fname, 'w').close()
os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
__import__(TESTFN)
fn = fname + 'c'
if not os.path.exists(fn):
fn = fname + 'o'
if not os.path.exists(fn):
self.fail("__import__ did not result in creation of "
"either a .pyc or .pyo file")
s = os.stat(fn)
self.assertEqual(stat.S_IMODE(s.st_mode),
stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
finally:
os.umask(oldmask)
remove_files(TESTFN)
unload(TESTFN)
del sys.path[0]
def test_imp_module(self):
# Verify that the imp module can correctly load and find .py files
# XXX (ncoghlan): It would be nice to use test_support.CleanImport
# here, but that breaks because the os module registers some
# handlers in copy_reg on import. Since CleanImport doesn't
# revert that registration, the module is left in a broken
# state after reversion. Reinitialising the module contents
# and just reverting os.environ to its previous state is an OK
# workaround
orig_path = os.path
orig_getenv = os.getenv
with EnvironmentVarGuard():
x = imp.find_module("os")
new_os = imp.load_module("os", *x)
self.assertIs(os, new_os)
self.assertIs(orig_path, new_os.path)
self.assertIsNot(orig_getenv, new_os.getenv)
def test_module_with_large_stack(self, module='longlist'):
# Regression test for http://bugs.python.org/issue561858.
filename = module + os.extsep + 'py'
# Create a file with a list of 65000 elements.
with open(filename, 'w+') as f:
f.write('d = [\n')
for i in range(65000):
f.write('"",\n')
f.write(']')
# Compile & remove .py file, we only need .pyc (or .pyo).
with open(filename, 'r') as f:
py_compile.compile(filename)
unlink(filename)
# Need to be able to load from current dir.
sys.path.append('')
# This used to crash.
exec 'import ' + module
# Cleanup.
del sys.path[-1]
unlink(filename + 'c')
unlink(filename + 'o')
def test_failing_import_sticks(self):
source = TESTFN + os.extsep + "py"
with open(source, "w") as f:
print >> f, "a = 1 // 0"
# New in 2.4, we shouldn't be able to import that no matter how often
# we try.
sys.path.insert(0, os.curdir)
try:
for i in [1, 2, 3]:
self.assertRaises(ZeroDivisionError, __import__, TESTFN)
self.assertNotIn(TESTFN, sys.modules,
"damaged module in sys.modules on %i try" % i)
finally:
del sys.path[0]
remove_files(TESTFN)
def test_failing_reload(self):
# A failing reload should leave the module object in sys.modules.
source = TESTFN + os.extsep + "py"
with open(source, "w") as f:
print >> f, "a = 1"
print >> f, "b = 2"
sys.path.insert(0, os.curdir)
try:
mod = __import__(TESTFN)
self.assertIn(TESTFN, sys.modules)
self.assertEqual(mod.a, 1, "module has wrong attribute values")
self.assertEqual(mod.b, 2, "module has wrong attribute values")
# On WinXP, just replacing the .py file wasn't enough to
# convince reload() to reparse it. Maybe the timestamp didn't
# move enough. We force it to get reparsed by removing the
# compiled file too.
remove_files(TESTFN)
# Now damage the module.
with open(source, "w") as f:
print >> f, "a = 10"
print >> f, "b = 20//0"
self.assertRaises(ZeroDivisionError, imp.reload, mod)
# But we still expect the module to be in sys.modules.
mod = sys.modules.get(TESTFN)
self.assertIsNot(mod, None, "expected module to be in sys.modules")
# We should have replaced a w/ 10, but the old b value should
# stick.
self.assertEqual(mod.a, 10, "module has wrong attribute values")
self.assertEqual(mod.b, 2, "module has wrong attribute values")
finally:
del sys.path[0]
remove_files(TESTFN)
unload(TESTFN)
def test_infinite_reload(self):
# http://bugs.python.org/issue742342 reports that Python segfaults
# (infinite recursion in C) when faced with self-recursive reload()ing.
sys.path.insert(0, os.path.dirname(__file__))
try:
import infinite_reload
finally:
del sys.path[0]
def test_import_name_binding(self):
# import x.y.z binds x in the current namespace.
import test as x
import test.test_support
self.assertIs(x, test, x.__name__)
self.assertTrue(hasattr(test.test_support, "__file__"))
# import x.y.z as w binds z as w.
import test.test_support as y
self.assertIs(y, test.test_support, y.__name__)
def test_import_initless_directory_warning(self):
with check_warnings(('', ImportWarning)):
# Just a random non-package directory we always expect to be
# somewhere in sys.path...
self.assertRaises(ImportError, __import__, "site-packages")
def test_import_by_filename(self):
path = os.path.abspath(TESTFN)
with self.assertRaises(ImportError) as c:
__import__(path)
self.assertEqual("Import by filename is not supported.",
c.exception.args[0])
def test_import_in_del_does_not_crash(self):
# Issue 4236
testfn = script_helper.make_script('', TESTFN, textwrap.dedent("""\
import sys
class C:
def __del__(self):
import imp
sys.argv.insert(0, C())
"""))
try:
script_helper.assert_python_ok(testfn)
finally:
unlink(testfn)
def test_bug7732(self):
source = TESTFN + '.py'
os.mkdir(source)
try:
self.assertRaises((ImportError, IOError),
imp.find_module, TESTFN, ["."])
finally:
os.rmdir(source)
def test_timestamp_overflow(self):
# A modification timestamp larger than 2**32 should not be a problem
# when importing a module (issue #11235).
sys.path.insert(0, os.curdir)
try:
source = TESTFN + ".py"
compiled = source + ('c' if __debug__ else 'o')
with open(source, 'w') as f:
pass
try:
os.utime(source, (2 ** 33 - 5, 2 ** 33 - 5))
except OverflowError:
self.skipTest("cannot set modification time to large integer")
except OSError as e:
if e.errno != getattr(errno, 'EOVERFLOW', None):
raise
self.skipTest("cannot set modification time to large integer ({})".format(e))
__import__(TESTFN)
# The pyc file was created.
os.stat(compiled)
finally:
del sys.path[0]
remove_files(TESTFN)
class PycRewritingTests(unittest.TestCase):
# Test that the `co_filename` attribute on code objects always points
# to the right file, even when various things happen (e.g. both the .py
# and the .pyc file are renamed).
module_name = "unlikely_module_name"
module_source = """
import sys
code_filename = sys._getframe().f_code.co_filename
module_filename = __file__
constant = 1
def func():
pass
func_filename = func.func_code.co_filename
"""
dir_name = os.path.abspath(TESTFN)
file_name = os.path.join(dir_name, module_name) + os.extsep + "py"
compiled_name = file_name + ("c" if __debug__ else "o")
def setUp(self):
self.sys_path = sys.path[:]
self.orig_module = sys.modules.pop(self.module_name, None)
os.mkdir(self.dir_name)
with open(self.file_name, "w") as f:
f.write(self.module_source)
sys.path.insert(0, self.dir_name)
def tearDown(self):
sys.path[:] = self.sys_path
if self.orig_module is not None:
sys.modules[self.module_name] = self.orig_module
else:
unload(self.module_name)
unlink(self.file_name)
unlink(self.compiled_name)
rmtree(self.dir_name)
def import_module(self):
ns = globals()
__import__(self.module_name, ns, ns)
return sys.modules[self.module_name]
def test_basics(self):
mod = self.import_module()
self.assertEqual(mod.module_filename, self.file_name)
self.assertEqual(mod.code_filename, self.file_name)
self.assertEqual(mod.func_filename, self.file_name)
del sys.modules[self.module_name]
mod = self.import_module()
self.assertEqual(mod.module_filename, self.compiled_name)
self.assertEqual(mod.code_filename, self.file_name)
self.assertEqual(mod.func_filename, self.file_name)
def test_incorrect_code_name(self):
py_compile.compile(self.file_name, dfile="another_module.py")
mod = self.import_module()
self.assertEqual(mod.module_filename, self.compiled_name)
self.assertEqual(mod.code_filename, self.file_name)
self.assertEqual(mod.func_filename, self.file_name)
def test_module_without_source(self):
target = "another_module.py"
py_compile.compile(self.file_name, dfile=target)
os.remove(self.file_name)
mod = self.import_module()
self.assertEqual(mod.module_filename, self.compiled_name)
self.assertEqual(mod.code_filename, target)
self.assertEqual(mod.func_filename, target)
def test_foreign_code(self):
py_compile.compile(self.file_name)
with open(self.compiled_name, "rb") as f:
header = f.read(8)
code = marshal.load(f)
constants = list(code.co_consts)
foreign_code = test_main.func_code
pos = constants.index(1)
constants[pos] = foreign_code
code = type(code)(code.co_argcount, code.co_nlocals, code.co_stacksize,
code.co_flags, code.co_code, tuple(constants),
code.co_names, code.co_varnames, code.co_filename,
code.co_name, code.co_firstlineno, code.co_lnotab,
code.co_freevars, code.co_cellvars)
with open(self.compiled_name, "wb") as f:
f.write(header)
marshal.dump(code, f)
mod = self.import_module()
self.assertEqual(mod.constant.co_filename, foreign_code.co_filename)
class PathsTests(unittest.TestCase):
path = TESTFN
def setUp(self):
os.mkdir(self.path)
self.syspath = sys.path[:]
def tearDown(self):
rmtree(self.path)
sys.path[:] = self.syspath
# Regression test for http://bugs.python.org/issue1293.
def test_trailing_slash(self):
with open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') as f:
f.write("testdata = 'test_trailing_slash'")
sys.path.append(self.path+'/')
mod = __import__("test_trailing_slash")
self.assertEqual(mod.testdata, 'test_trailing_slash')
unload("test_trailing_slash")
# Regression test for http://bugs.python.org/issue3677.
def _test_UNC_path(self):
with open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') as f:
f.write("testdata = 'test_trailing_slash'")
# Create the UNC path, like \\myhost\c$\foo\bar.
path = os.path.abspath(self.path)
import socket
hn = socket.gethostname()
drive = path[0]
unc = "\\\\%s\\%s$"%(hn, drive)
unc += path[2:]
sys.path.append(path)
mod = __import__("test_trailing_slash")
self.assertEqual(mod.testdata, 'test_trailing_slash')
unload("test_trailing_slash")
if sys.platform == "win32":
test_UNC_path = _test_UNC_path
class RelativeImportTests(unittest.TestCase):
def tearDown(self):
unload("test.relimport")
setUp = tearDown
def test_relimport_star(self):
# This will import * from .test_import.
from . import relimport
self.assertTrue(hasattr(relimport, "RelativeImportTests"))
def test_issue3221(self):
# Regression test for http://bugs.python.org/issue3221.
def check_absolute():
exec "from os import path" in ns
def check_relative():
exec "from . import relimport" in ns
# Check both OK with __package__ and __name__ correct
ns = dict(__package__='test', __name__='test.notarealmodule')
check_absolute()
check_relative()
# Check both OK with only __name__ wrong
ns = dict(__package__='test', __name__='notarealpkg.notarealmodule')
check_absolute()
check_relative()
# Check relative fails with only __package__ wrong
ns = dict(__package__='foo', __name__='test.notarealmodule')
with check_warnings(('.+foo', RuntimeWarning)):
check_absolute()
self.assertRaises(SystemError, check_relative)
# Check relative fails with __package__ and __name__ wrong
ns = dict(__package__='foo', __name__='notarealpkg.notarealmodule')
with check_warnings(('.+foo', RuntimeWarning)):
check_absolute()
self.assertRaises(SystemError, check_relative)
# Check both fail with package set to a non-string
ns = dict(__package__=object())
self.assertRaises(ValueError, check_absolute)
self.assertRaises(ValueError, check_relative)
def test_absolute_import_without_future(self):
# If explicit relative import syntax is used, then do not try
# to perform an absolute import in the face of failure.
# Issue #7902.
with self.assertRaises(ImportError):
from .os import sep
self.fail("explicit relative import triggered an "
"implicit absolute import")
def test_main(verbose=None):
run_unittest(ImportTests, PycRewritingTests, PathsTests, RelativeImportTests)
if __name__ == '__main__':
# Test needs to be a package, so we can do relative imports.
from test.test_import import test_main
test_main()
|
gpl-2.0
|
[
646,
7554,
199,
646,
1742,
199,
646,
21985,
199,
646,
747,
199,
646,
1134,
63,
2014,
199,
646,
2196,
199,
646,
5672,
199,
646,
984,
199,
646,
2882,
199,
504,
511,
14,
396,
63,
4058,
492,
334,
7162,
12,
25788,
12,
625,
912,
12,
1255,
63,
2796,
12,
20978,
12,
3044,
365,
63,
27179,
12,
1104,
63,
5451,
12,
9711,
5894,
18183,
9,
199,
646,
13390,
199,
504,
511,
492,
2884,
63,
3676,
199,
199,
318,
2813,
63,
1725,
8,
354,
304,
272,
367,
289,
315,
334,
354,
435,
747,
14,
832,
4127,
435,
298,
647,
401,
1598,
536,
435,
747,
14,
832,
4127,
435,
298,
11357,
401,
1598,
536,
435,
747,
14,
832,
4127,
435,
298,
22345,
401,
1598,
536,
435,
747,
14,
832,
4127,
435,
298,
647,
87,
401,
1598,
536,
435,
7880,
647,
14,
533,
2349,
267,
17002,
8,
70,
9,
421,
199,
533,
3161,
2925,
8,
2796,
14,
1746,
304,
339,
347,
6766,
8,
277,
304,
267,
625,
912,
8,
10179,
9,
272,
3613,
275,
6766,
339,
347,
511,
63,
2546,
63,
2464,
20635,
8,
277,
304,
267,
327,
699,
322,
2829,
31190,
1941,
370,
511,
626,
492,
365,
1930,
13,
7361,
26,
221,
340,
781,
4788,
267,
327,
642,
12474,
12,
781,
5715,
367,
3238,
626,
298,
2355,
2,
3495,
14,
267,
862,
26,
288,
492,
820,
2493,
2585,
45,
267,
871,
3545,
26,
288,
986,
267,
587,
26,
288,
291,
14,
1633,
480,
646,
402,
820,
2493,
2585,
45,
1077,
1172,
3405,
334,
2546,
15015,
6320,
339,
347,
511,
63,
3157,
63,
1297,
8,
277,
304,
267,
327,
22604,
29226,
31190,
1941,
370,
511,
314,
12862,
402,
7712,
2069,
267,
327,
5262,
14,
267,
687,
511,
492,
4270,
63,
1297,
221,
327,
2793,
1133,
330,
1073,
1553,
626,
627,
10274,
10,
314,
511,
339,
347,
511,
63,
646,
8,
277,
304,
267,
347,
511,
63,
1045,
63,
3435,
8,
832,
304,
288,
327,
710,
3329,
365,
12252,
3680,
647,
401,
25358,
3680,
647,
87,
1674,
288,
1350,
275,
25788,
435,
1599,
288,
1134,
79,
275,
25788,
435,
747,
14,
832,
4127,
435,
298,
22345,
2,
288,
340,
365,
63,
27179,
26,
355,
28968,
275,
25788,
435,
7880,
647,
14,
533,
2,
288,
587,
26,
355,
28968,
275,
25788,
435,
747,
14,
832,
4127,
435,
298,
11357,
2,
953,
543,
1551,
8,
1365,
12,
298,
87,
531,
465,
289,
26,
355,
870,
4331,
289,
12,
1689,
3,
961,
2295,
2018,
1159,
21255,
370,
492,
282,
401,
1599,
12,
2490,
298,
493,
2685,
355,
282,
275,
2196,
14,
20539,
8,
5279,
9,
355,
330,
275,
2196,
14,
20539,
8,
5279,
9,
355,
870,
4331,
289,
12,
298,
65,
20815,
282,
355,
870,
4331,
289,
12,
298,
66,
20815,
330,
953,
862,
26,
355,
3413,
275,
636,
646,
721,
10179,
9,
288,
871,
3545,
12,
2329,
26,
355,
291,
14,
1633,
480,
646,
687,
450,
83,
3405,
26,
450,
83,
2,
450,
334,
832,
12,
2329,
430,
288,
587,
26,
355,
291,
14,
629,
8,
1494,
14,
65,
12,
282,
12,
490,
298,
578,
6511,
4366,
83,
9,
1325,
4072,
3866,
2,
450,
3413,
9,
355,
291,
14,
629,
8,
1494,
14,
66,
12,
330,
12,
490,
298,
578,
6511,
4366,
83,
9,
1325,
4072,
3866,
2,
450,
3413,
9,
288,
3753,
26,
355,
17002,
8,
1365,
9,
953,
862,
26,
355,
1742,
14,
9233,
8,
1494,
9,
288,
871,
3545,
12,
2329,
26,
355,
291,
14,
1633,
480,
646,
687,
1275,
11357,
8083,
22345,
3405,
26,
450,
83,
2,
450,
2329,
9,
288,
3753,
26,
355,
17002,
8,
11357,
9,
355,
17002,
8,
22345,
9,
355,
625,
912,
8,
10179,
9,
398,
984,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
15594,
9,
267,
862,
26,
288,
511,
63,
1045,
63,
3435,
8,
736,
14,
832,
4127,
435,
298,
647,
531,
288,
340,
984,
14,
3246,
14,
2460,
480,
2676,
2349,
355,
367,
1599,
315,
359,
1674,
4521,
401,
3680,
2713,
401,
3680,
80,
57,
401,
3680,
647,
87,
401,
3680,
4521,
55,
401,
3680,
80,
57,
87,
6229,
490,
511,
63,
1045,
63,
3435,
8,
832,
9,
267,
3753,
26,
288,
2150,
984,
14,
515,
59,
16,
61,
339,
768,
2796,
14,
11278,
8,
736,
14,
354,
508,
283,
9228,
297,
298,
396,
26562,
1454,
641,
10694,
10460,
531,
272,
347,
511,
63,
2526,
63,
2075,
63,
1397,
63,
23581,
8,
277,
304,
267,
327,
13383,
1227,
19235,
26,
1334,
10694,
1275,
11357,
1584,
4788,
3932,
5341,
4546,
663,
340,
267,
327,
314,
1275,
647,
570,
10530,
314,
5341,
4546,
663,
12,
1325,
2985,
10621,
1133,
7286,
14,
267,
2269,
2629,
275,
747,
14,
18315,
8,
16348,
9,
267,
984,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
15594,
9,
267,
862,
26,
288,
6748,
275,
25788,
435,
747,
14,
832,
4127,
435,
298,
647,
2,
288,
289,
275,
1551,
8,
5252,
12,
283,
87,
1959,
1600,
342,
288,
747,
14,
11693,
8,
5252,
12,
334,
3736,
14,
51,
63,
3927,
22592,
1204,
5672,
14,
51,
63,
3927,
3975,
48,
1204,
5672,
14,
51,
63,
41,
1092,
2080,
1204,
2490,
5672,
14,
51,
63,
3867,
22592,
1204,
5672,
14,
51,
63,
3867,
3975,
48,
1204,
5672,
14,
51,
63,
3867,
22949,
430,
288,
636,
646,
721,
10179,
9,
288,
4325,
275,
6748,
435,
283,
67,
7,
288,
340,
440,
747,
14,
515,
14,
2444,
8,
2324,
304,
355,
4325,
275,
6748,
435,
283,
79,
7,
355,
340,
440,
747,
14,
515,
14,
2444,
8,
2324,
304,
490,
291,
14,
1633,
16232,
646,
363,
8103,
440,
754,
315,
7143,
402,
298,
2892,
298,
22051,
282,
1275,
11357,
503,
1275,
22345,
570,
531,
288,
308,
275,
747,
14,
3736,
8,
2324,
9,
288,
291,
14,
629,
8,
3736,
14,
51,
63,
1469,
9125,
8,
83,
14,
270,
63,
632,
395,
2490,
5672,
14,
51,
63,
3927,
22592,
1204,
5672,
14,
51,
63,
3927,
3975,
48,
1204,
5672,
14,
51,
63,
41,
1092,
2080,
9,
267,
3753,
26,
288,
747,
14,
18315,
8,
1753,
2629,
9,
288,
2813,
63,
1725,
8,
10179,
9,
288,
625,
912,
8,
10179,
9,
288,
2150,
984,
14,
515,
59,
16,
61,
339,
347,
511
] |
[
7554,
199,
646,
1742,
199,
646,
21985,
199,
646,
747,
199,
646,
1134,
63,
2014,
199,
646,
2196,
199,
646,
5672,
199,
646,
984,
199,
646,
2882,
199,
504,
511,
14,
396,
63,
4058,
492,
334,
7162,
12,
25788,
12,
625,
912,
12,
1255,
63,
2796,
12,
20978,
12,
3044,
365,
63,
27179,
12,
1104,
63,
5451,
12,
9711,
5894,
18183,
9,
199,
646,
13390,
199,
504,
511,
492,
2884,
63,
3676,
199,
199,
318,
2813,
63,
1725,
8,
354,
304,
272,
367,
289,
315,
334,
354,
435,
747,
14,
832,
4127,
435,
298,
647,
401,
1598,
536,
435,
747,
14,
832,
4127,
435,
298,
11357,
401,
1598,
536,
435,
747,
14,
832,
4127,
435,
298,
22345,
401,
1598,
536,
435,
747,
14,
832,
4127,
435,
298,
647,
87,
401,
1598,
536,
435,
7880,
647,
14,
533,
2349,
267,
17002,
8,
70,
9,
421,
199,
533,
3161,
2925,
8,
2796,
14,
1746,
304,
339,
347,
6766,
8,
277,
304,
267,
625,
912,
8,
10179,
9,
272,
3613,
275,
6766,
339,
347,
511,
63,
2546,
63,
2464,
20635,
8,
277,
304,
267,
327,
699,
322,
2829,
31190,
1941,
370,
511,
626,
492,
365,
1930,
13,
7361,
26,
221,
340,
781,
4788,
267,
327,
642,
12474,
12,
781,
5715,
367,
3238,
626,
298,
2355,
2,
3495,
14,
267,
862,
26,
288,
492,
820,
2493,
2585,
45,
267,
871,
3545,
26,
288,
986,
267,
587,
26,
288,
291,
14,
1633,
480,
646,
402,
820,
2493,
2585,
45,
1077,
1172,
3405,
334,
2546,
15015,
6320,
339,
347,
511,
63,
3157,
63,
1297,
8,
277,
304,
267,
327,
22604,
29226,
31190,
1941,
370,
511,
314,
12862,
402,
7712,
2069,
267,
327,
5262,
14,
267,
687,
511,
492,
4270,
63,
1297,
221,
327,
2793,
1133,
330,
1073,
1553,
626,
627,
10274,
10,
314,
511,
339,
347,
511,
63,
646,
8,
277,
304,
267,
347,
511,
63,
1045,
63,
3435,
8,
832,
304,
288,
327,
710,
3329,
365,
12252,
3680,
647,
401,
25358,
3680,
647,
87,
1674,
288,
1350,
275,
25788,
435,
1599,
288,
1134,
79,
275,
25788,
435,
747,
14,
832,
4127,
435,
298,
22345,
2,
288,
340,
365,
63,
27179,
26,
355,
28968,
275,
25788,
435,
7880,
647,
14,
533,
2,
288,
587,
26,
355,
28968,
275,
25788,
435,
747,
14,
832,
4127,
435,
298,
11357,
2,
953,
543,
1551,
8,
1365,
12,
298,
87,
531,
465,
289,
26,
355,
870,
4331,
289,
12,
1689,
3,
961,
2295,
2018,
1159,
21255,
370,
492,
282,
401,
1599,
12,
2490,
298,
493,
2685,
355,
282,
275,
2196,
14,
20539,
8,
5279,
9,
355,
330,
275,
2196,
14,
20539,
8,
5279,
9,
355,
870,
4331,
289,
12,
298,
65,
20815,
282,
355,
870,
4331,
289,
12,
298,
66,
20815,
330,
953,
862,
26,
355,
3413,
275,
636,
646,
721,
10179,
9,
288,
871,
3545,
12,
2329,
26,
355,
291,
14,
1633,
480,
646,
687,
450,
83,
3405,
26,
450,
83,
2,
450,
334,
832,
12,
2329,
430,
288,
587,
26,
355,
291,
14,
629,
8,
1494,
14,
65,
12,
282,
12,
490,
298,
578,
6511,
4366,
83,
9,
1325,
4072,
3866,
2,
450,
3413,
9,
355,
291,
14,
629,
8,
1494,
14,
66,
12,
330,
12,
490,
298,
578,
6511,
4366,
83,
9,
1325,
4072,
3866,
2,
450,
3413,
9,
288,
3753,
26,
355,
17002,
8,
1365,
9,
953,
862,
26,
355,
1742,
14,
9233,
8,
1494,
9,
288,
871,
3545,
12,
2329,
26,
355,
291,
14,
1633,
480,
646,
687,
1275,
11357,
8083,
22345,
3405,
26,
450,
83,
2,
450,
2329,
9,
288,
3753,
26,
355,
17002,
8,
11357,
9,
355,
17002,
8,
22345,
9,
355,
625,
912,
8,
10179,
9,
398,
984,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
15594,
9,
267,
862,
26,
288,
511,
63,
1045,
63,
3435,
8,
736,
14,
832,
4127,
435,
298,
647,
531,
288,
340,
984,
14,
3246,
14,
2460,
480,
2676,
2349,
355,
367,
1599,
315,
359,
1674,
4521,
401,
3680,
2713,
401,
3680,
80,
57,
401,
3680,
647,
87,
401,
3680,
4521,
55,
401,
3680,
80,
57,
87,
6229,
490,
511,
63,
1045,
63,
3435,
8,
832,
9,
267,
3753,
26,
288,
2150,
984,
14,
515,
59,
16,
61,
339,
768,
2796,
14,
11278,
8,
736,
14,
354,
508,
283,
9228,
297,
298,
396,
26562,
1454,
641,
10694,
10460,
531,
272,
347,
511,
63,
2526,
63,
2075,
63,
1397,
63,
23581,
8,
277,
304,
267,
327,
13383,
1227,
19235,
26,
1334,
10694,
1275,
11357,
1584,
4788,
3932,
5341,
4546,
663,
340,
267,
327,
314,
1275,
647,
570,
10530,
314,
5341,
4546,
663,
12,
1325,
2985,
10621,
1133,
7286,
14,
267,
2269,
2629,
275,
747,
14,
18315,
8,
16348,
9,
267,
984,
14,
515,
14,
3176,
8,
16,
12,
747,
14,
15594,
9,
267,
862,
26,
288,
6748,
275,
25788,
435,
747,
14,
832,
4127,
435,
298,
647,
2,
288,
289,
275,
1551,
8,
5252,
12,
283,
87,
1959,
1600,
342,
288,
747,
14,
11693,
8,
5252,
12,
334,
3736,
14,
51,
63,
3927,
22592,
1204,
5672,
14,
51,
63,
3927,
3975,
48,
1204,
5672,
14,
51,
63,
41,
1092,
2080,
1204,
2490,
5672,
14,
51,
63,
3867,
22592,
1204,
5672,
14,
51,
63,
3867,
3975,
48,
1204,
5672,
14,
51,
63,
3867,
22949,
430,
288,
636,
646,
721,
10179,
9,
288,
4325,
275,
6748,
435,
283,
67,
7,
288,
340,
440,
747,
14,
515,
14,
2444,
8,
2324,
304,
355,
4325,
275,
6748,
435,
283,
79,
7,
355,
340,
440,
747,
14,
515,
14,
2444,
8,
2324,
304,
490,
291,
14,
1633,
16232,
646,
363,
8103,
440,
754,
315,
7143,
402,
298,
2892,
298,
22051,
282,
1275,
11357,
503,
1275,
22345,
570,
531,
288,
308,
275,
747,
14,
3736,
8,
2324,
9,
288,
291,
14,
629,
8,
3736,
14,
51,
63,
1469,
9125,
8,
83,
14,
270,
63,
632,
395,
2490,
5672,
14,
51,
63,
3927,
22592,
1204,
5672,
14,
51,
63,
3927,
3975,
48,
1204,
5672,
14,
51,
63,
41,
1092,
2080,
9,
267,
3753,
26,
288,
747,
14,
18315,
8,
1753,
2629,
9,
288,
2813,
63,
1725,
8,
10179,
9,
288,
625,
912,
8,
10179,
9,
288,
2150,
984,
14,
515,
59,
16,
61,
339,
347,
511,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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utf-8 -*-
###############################################################################
# Copyright (c) 2015, Julius Sky
#
# 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.
###############################################################################
'''
File: detect.py
Author: julius.skye@gmail.com
Date: 1.05.2015
File Description:
This program uses opencv's cascade function: detectMuliScale
to perfom detection with a given detector on a given image.
The image can be preprocessed for diff color spaces:
grayscale, YUV, HSV, HLS, CIELAB, CIELUV
Note: by default, im.read outputs in BGR order not RGB
For more info about convesion algorithms see:
http://docs.opencv.org/master/de/d25/
imgproc_color_conversions.html#color_convert_rgb_hls
For good default values see:
http://www.searchalleasy.com/q/20801015/2589776
Means checking scales 10percent of size increments
scaleFactor=1.1
Higher value results in less detections but with higher quality
minNeighbors=5
minSize=(30, 30)
flags = cv2.cv.CV_HAAR_SCALE_IMAGE
maxSize by default assumed size of image but can be set.
use like this:
python cardetect.py image/path/image.extension cascade/path/cascade.xml colorspace
'''
import glob
import cv2
import sys
from scipy import misc
# Get user supplied values
if len(sys.argv) == 4:
imageDir = sys.argv[1]
cascadePath = sys.argv[2]
colorspace = sys.argv[3]
elif len(sys.argv) == 3:
imageDir = sys.argv[1]
cascadePath = sys.argv[2]
colorspace = "rgb"
else:
print("check arguments!")
# Create the haar cascade
trainedCascade = cv2.CascadeClassifier(cascadePath)
totalobjects = 0
with open('Output.txt', 'w') as results:
results.write("*********************************\n")
results.write("Batch Detection results \n")
results.write("*********************************\n")
results.close()
# for imagePath in imageDir:
colorspace = "lab"
images = glob.glob('*.jpg')
for imagePath in images:
# Read the image
image = cv2.imread(imagePath)
# convert to grayscale (default algorithm)
if colorspace == "gray":
colorCVT = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
elif colorspace == "hsv":
colorCVT = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
elif colorspace == "hls":
colorCVT = cv2.cvtColor(image, cv2.COLOR_BGR2HLS)
elif colorspace == "lab":
colorCVT = cv2.cvtColor(image, cv2.COLOR_BGR2LAB)
elif colorspace == "luv":
colorCVT = cv2.cvtColor(image, cv2.COLOR_BGR2LUV)
elif colorspace == "yuv":
colorCVT = cv2.cvtColor(image, cv2.COLOR_BGR2YUV)
else:
colorCVT = image
print('using color mode: '+colorspace)
with open('Output.txt', 'a') as results:
results.write("Running detection on image: "+imagePath +"\n")
results.write("Detecting using trained classifier: "+cascadePath +"\n")
# results.close()
# training PARAMS
SCALE_FACTOR = 1.02
MIN_NEIGHBORS = 5
MIN_SIZE = (10,10)
MAX_SIZE = (100,100)
# Detect objects in the image
objects = trainedCascade.detectMultiScale(
colorCVT,
scaleFactor=SCALE_FACTOR,
minNeighbors=MIN_NEIGHBORS,
minSize=MIN_SIZE,
maxSize=MAX_SIZE,
flags = cv2.cv.CV_HAAR_SCALE_IMAGE
)
# Draw a rectangle around the faces
for (x, y, w, h) in objects:
#cv2.rectangle(colorCVT, (x, y), (x+w, y+h), (0, 255, 0), 2)
cv2.rectangle(colorCVT, (x, y), (x+w, y+h), (0, 255, 0), 2)
print("Found {0} objects!".format(len(objects)), colorCVT)
# append to end of file
with open('Output.txt', 'a') as results:
results.write("Objects found: {0}".format(len(objects)))
results.write("\n")
results.close()
# if we found objects, create image with detections drawn on
if len(objects)>0:
misc.imsave(imagePath+'-detected.jpg', colorCVT)
totalobjects = totalobjects+len(objects)
# print("Total objects detected: {0}".format(len(objects)))
with open('Output.txt', 'a') as results:
results.write("Total objects detected: {0}".format(totalobjects))
results.write("\n")
results.close()
# print('total objects deteced: '+totalobjects)
# cv2.imshow("Found {0} objects!".format(len(objects)), colorCVT)
# cv2.waitKey(0)
|
mit
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
11490,
199,
3,
1898,
334,
67,
9,
6900,
12,
1603,
13987,
527,
428,
10562,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
3,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
3,
315,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
3,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
3,
6866,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
3,
13985,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
3,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
3,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
10610,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
3,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
3,
2334,
4141,
14,
199,
11490,
421,
199,
2344,
199,
1173,
26,
9696,
14,
647,
199,
5949,
26,
1335,
13987,
527,
14,
1339,
8048,
32,
6799,
14,
957,
199,
2506,
26,
413,
14,
1717,
14,
7806,
199,
1173,
11994,
26,
199,
2765,
2240,
4440,
1551,
5107,
1159,
22809,
805,
26,
9696,
45,
13987,
9944,
199,
475,
1126,
545,
77,
15212,
543,
282,
1627,
17842,
641,
282,
1627,
1834,
14,
199,
1918,
1834,
883,
506,
876,
7292,
367,
3915,
3164,
7883,
26,
199,
12150,
3467,
12,
1488,
15110,
12,
869,
4985,
12,
869,
5296,
12,
445,
41,
2901,
1217,
12,
445,
41,
2901,
15110,
199,
7443,
26,
701,
849,
12,
3416,
14,
739,
4704,
315,
699,
3975,
1865,
440,
19013,
199,
199,
1858,
1655,
2256,
3595,
406,
432,
438,
18036,
1937,
26,
199,
1014,
921,
4757,
14,
1490,
5107,
14,
1308,
15,
4133,
15,
271,
15,
68,
821,
15,
199,
4060,
4687,
63,
2326,
63,
388,
6234,
14,
1360,
3,
2326,
63,
3916,
63,
10090,
63,
30252,
199,
199,
1858,
6954,
849,
1338,
1937,
26,
199,
1014,
921,
1544,
14,
1733,
4598,
5660,
14,
957,
15,
81,
15,
10630,
614,
11164,
15,
821,
1407,
14626,
272,
3194,
796,
7907,
29823,
1616,
7045,
402,
1568,
10035,
1470,
272,
4666,
12666,
29,
17,
14,
17,
272,
16332,
281,
574,
2058,
315,
6656,
477,
266,
2452,
1325,
543,
10948,
11030,
272,
1748,
20011,
29,
21,
339,
1748,
2320,
2687,
1216,
12,
4233,
9,
272,
3285,
275,
6277,
18,
14,
5107,
14,
12847,
63,
6294,
689,
63,
24333,
63,
9438,
339,
32494,
701,
849,
10826,
1568,
402,
1834,
1325,
883,
506,
663,
14,
339,
675,
2839,
642,
26,
339,
2366,
9590,
13552,
14,
647,
1834,
15,
515,
15,
1569,
14,
3435,
22809,
15,
515,
15,
15377,
14,
1652,
9229,
1142,
199,
199,
2344,
199,
646,
5739,
199,
646,
6277,
18,
199,
646,
984,
199,
504,
7026,
492,
18576,
421,
199,
3,
2372,
922,
6841,
1338,
199,
692,
822,
8,
1274,
14,
3020,
9,
508,
841,
26,
272,
1834,
3567,
275,
984,
14,
3020,
59,
17,
61,
272,
22809,
2042,
275,
984,
14,
3020,
59,
18,
61,
272,
9229,
1142,
275,
984,
14,
3020,
59,
19,
61,
199,
4164,
822,
8,
1274,
14,
3020,
9,
508,
650,
26,
272,
1834,
3567,
275,
984,
14,
3020,
59,
17,
61,
272,
22809,
2042,
275,
984,
14,
3020,
59,
18,
61,
272,
9229,
1142,
275,
298,
10090,
2,
199,
2836,
26,
272,
870,
480,
1074,
2368,
9124,
421,
199,
3,
2790,
314,
18251,
285,
22809,
199,
23782,
35,
305,
9490,
275,
6277,
18,
14,
35,
305,
9490,
8508,
8,
15377,
2042,
9,
199,
2923,
1462,
275,
378,
199,
1045,
1551,
360,
2959,
14,
2424,
297,
283,
87,
358,
465,
2058,
26,
272,
2058,
14,
952,
480,
5815,
7590,
78,
531,
272,
2058,
14,
952,
480,
8842,
1487,
5860,
2058,
971,
78,
531,
272,
2058,
14,
952,
480,
5815,
7590,
78,
531,
199,
2604,
14,
1600,
342,
199,
199,
3,
367,
1834,
2042,
315,
1834,
3567,
26,
421,
199,
7120,
1142,
275,
298,
5561,
2,
199,
199,
4782,
275,
5739,
14,
6463,
360,
4856,
8476,
358,
199,
509,
1834,
2042,
315,
5935,
26,
339,
327,
5574,
314,
1834,
272,
1834,
275,
6277,
18,
14,
1017,
739,
8,
1569,
2042,
9,
2378,
327,
3957,
370,
21977,
3467,
334,
885,
5563,
9,
272,
340,
9229,
1142,
508,
298,
12150,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
18583,
57,
9,
272,
916,
9229,
1142,
508,
298,
72,
2772,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
40,
4985,
9,
272,
916,
9229,
1142,
508,
298,
30252,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
40,
5296,
9,
272,
916,
9229,
1142,
508,
298,
5561,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
12019,
9,
272,
916,
9229,
1142,
508,
298,
76,
9154,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
44,
15110,
9,
272,
916,
9229,
1142,
508,
298,
89,
9154,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
57,
15110,
9,
272,
587,
26,
267,
3164,
35,
8156,
275,
1834,
339,
870,
360,
4941,
3164,
818,
26,
6681,
7120,
1142
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
11490,
199,
3,
1898,
334,
67,
9,
6900,
12,
1603,
13987,
527,
428,
10562,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
1331,
199,
3,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
298,
10337,
1288,
370,
7962,
199,
3,
315,
314,
2290,
1928,
10588,
12,
5893,
1928,
12305,
314,
4481,
199,
3,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
11207,
12,
13473,
12,
436,
15,
269,
12743,
199,
3,
6866,
402,
314,
2290,
12,
436,
370,
11291,
12103,
370,
12676,
314,
2290,
365,
199,
3,
13985,
370,
886,
880,
12,
5420,
370,
314,
2569,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
315,
199,
3,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
1549,
199,
3,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
3169,
12,
199,
3,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
10610,
1549,
5877,
8164,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
199,
3,
5603,
12,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
199,
3,
2334,
4141,
14,
199,
11490,
421,
199,
2344,
199,
1173,
26,
9696,
14,
647,
199,
5949,
26,
1335,
13987,
527,
14,
1339,
8048,
32,
6799,
14,
957,
199,
2506,
26,
413,
14,
1717,
14,
7806,
199,
1173,
11994,
26,
199,
2765,
2240,
4440,
1551,
5107,
1159,
22809,
805,
26,
9696,
45,
13987,
9944,
199,
475,
1126,
545,
77,
15212,
543,
282,
1627,
17842,
641,
282,
1627,
1834,
14,
199,
1918,
1834,
883,
506,
876,
7292,
367,
3915,
3164,
7883,
26,
199,
12150,
3467,
12,
1488,
15110,
12,
869,
4985,
12,
869,
5296,
12,
445,
41,
2901,
1217,
12,
445,
41,
2901,
15110,
199,
7443,
26,
701,
849,
12,
3416,
14,
739,
4704,
315,
699,
3975,
1865,
440,
19013,
199,
199,
1858,
1655,
2256,
3595,
406,
432,
438,
18036,
1937,
26,
199,
1014,
921,
4757,
14,
1490,
5107,
14,
1308,
15,
4133,
15,
271,
15,
68,
821,
15,
199,
4060,
4687,
63,
2326,
63,
388,
6234,
14,
1360,
3,
2326,
63,
3916,
63,
10090,
63,
30252,
199,
199,
1858,
6954,
849,
1338,
1937,
26,
199,
1014,
921,
1544,
14,
1733,
4598,
5660,
14,
957,
15,
81,
15,
10630,
614,
11164,
15,
821,
1407,
14626,
272,
3194,
796,
7907,
29823,
1616,
7045,
402,
1568,
10035,
1470,
272,
4666,
12666,
29,
17,
14,
17,
272,
16332,
281,
574,
2058,
315,
6656,
477,
266,
2452,
1325,
543,
10948,
11030,
272,
1748,
20011,
29,
21,
339,
1748,
2320,
2687,
1216,
12,
4233,
9,
272,
3285,
275,
6277,
18,
14,
5107,
14,
12847,
63,
6294,
689,
63,
24333,
63,
9438,
339,
32494,
701,
849,
10826,
1568,
402,
1834,
1325,
883,
506,
663,
14,
339,
675,
2839,
642,
26,
339,
2366,
9590,
13552,
14,
647,
1834,
15,
515,
15,
1569,
14,
3435,
22809,
15,
515,
15,
15377,
14,
1652,
9229,
1142,
199,
199,
2344,
199,
646,
5739,
199,
646,
6277,
18,
199,
646,
984,
199,
504,
7026,
492,
18576,
421,
199,
3,
2372,
922,
6841,
1338,
199,
692,
822,
8,
1274,
14,
3020,
9,
508,
841,
26,
272,
1834,
3567,
275,
984,
14,
3020,
59,
17,
61,
272,
22809,
2042,
275,
984,
14,
3020,
59,
18,
61,
272,
9229,
1142,
275,
984,
14,
3020,
59,
19,
61,
199,
4164,
822,
8,
1274,
14,
3020,
9,
508,
650,
26,
272,
1834,
3567,
275,
984,
14,
3020,
59,
17,
61,
272,
22809,
2042,
275,
984,
14,
3020,
59,
18,
61,
272,
9229,
1142,
275,
298,
10090,
2,
199,
2836,
26,
272,
870,
480,
1074,
2368,
9124,
421,
199,
3,
2790,
314,
18251,
285,
22809,
199,
23782,
35,
305,
9490,
275,
6277,
18,
14,
35,
305,
9490,
8508,
8,
15377,
2042,
9,
199,
2923,
1462,
275,
378,
199,
1045,
1551,
360,
2959,
14,
2424,
297,
283,
87,
358,
465,
2058,
26,
272,
2058,
14,
952,
480,
5815,
7590,
78,
531,
272,
2058,
14,
952,
480,
8842,
1487,
5860,
2058,
971,
78,
531,
272,
2058,
14,
952,
480,
5815,
7590,
78,
531,
199,
2604,
14,
1600,
342,
199,
199,
3,
367,
1834,
2042,
315,
1834,
3567,
26,
421,
199,
7120,
1142,
275,
298,
5561,
2,
199,
199,
4782,
275,
5739,
14,
6463,
360,
4856,
8476,
358,
199,
509,
1834,
2042,
315,
5935,
26,
339,
327,
5574,
314,
1834,
272,
1834,
275,
6277,
18,
14,
1017,
739,
8,
1569,
2042,
9,
2378,
327,
3957,
370,
21977,
3467,
334,
885,
5563,
9,
272,
340,
9229,
1142,
508,
298,
12150,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
18583,
57,
9,
272,
916,
9229,
1142,
508,
298,
72,
2772,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
40,
4985,
9,
272,
916,
9229,
1142,
508,
298,
30252,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
40,
5296,
9,
272,
916,
9229,
1142,
508,
298,
5561,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
12019,
9,
272,
916,
9229,
1142,
508,
298,
76,
9154,
582,
267,
3164,
35,
8156,
275,
6277,
18,
14,
5107,
84,
4117,
8,
1569,
12,
6277,
18,
14,
7134,
63,
34,
3975,
18,
44,
15110,
9,
272,
916,
9229,
1142,
508,
298,
89,
9154,
582,
267,
3164,
35,
8156,
275,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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
] |
rawdlite/mopidy
|
mopidy/core/history.py
|
17
|
1532
|
from __future__ import absolute_import, unicode_literals
import copy
import logging
import time
from mopidy import models
logger = logging.getLogger(__name__)
class HistoryController(object):
pykka_traversable = True
def __init__(self):
self._history = []
def _add_track(self, track):
"""Add track to the playback history.
Internal method for :class:`mopidy.core.PlaybackController`.
:param track: track to add
:type track: :class:`mopidy.models.Track`
"""
if not isinstance(track, models.Track):
raise TypeError('Only Track objects can be added to the history')
timestamp = int(time.time() * 1000)
name_parts = []
if track.artists:
name_parts.append(
', '.join([artist.name for artist in track.artists]))
if track.name is not None:
name_parts.append(track.name)
name = ' - '.join(name_parts)
ref = models.Ref.track(uri=track.uri, name=name)
self._history.insert(0, (timestamp, ref))
def get_length(self):
"""Get the number of tracks in the history.
:returns: the history length
:rtype: int
"""
return len(self._history)
def get_history(self):
"""Get the track history.
The timestamps are milliseconds since epoch.
:returns: the track history
:rtype: list of (timestamp, :class:`mopidy.models.Ref`) tuples
"""
return copy.copy(self._history)
|
apache-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
199,
199,
646,
1331,
199,
646,
2050,
199,
646,
900,
199,
199,
504,
333,
411,
344,
89,
492,
1709,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
27829,
7506,
8,
785,
304,
272,
1134,
75,
7351,
63,
1239,
14895,
461,
275,
715,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
5570,
275,
942,
339,
347,
485,
525,
63,
3885,
8,
277,
12,
4426,
304,
267,
408,
1123,
4426,
370,
314,
5232,
894,
7994,
14,
398,
12624,
1083,
367,
520,
533,
1705,
77,
411,
344,
89,
14,
1018,
14,
9651,
894,
7506,
2313,
398,
520,
635,
4426,
26,
4426,
370,
1050,
267,
520,
466,
4426,
26,
520,
533,
1705,
77,
411,
344,
89,
14,
992,
14,
7927,
64,
267,
408,
267,
340,
440,
1228,
8,
3885,
12,
1709,
14,
7927,
304,
288,
746,
3146,
360,
5903,
17507,
2251,
883,
506,
3483,
370,
314,
7994,
358,
398,
4913,
275,
1109,
8,
521,
14,
521,
342,
627,
5198,
9,
398,
536,
63,
4181,
275,
942,
267,
340,
4426,
14,
11215,
83,
26,
288,
536,
63,
4181,
14,
740,
8,
355,
1656,
1987,
904,
779,
11215,
14,
354,
367,
16459,
315,
4426,
14,
11215,
83,
2459,
267,
340,
4426,
14,
354,
365,
440,
488,
26,
288,
536,
63,
4181,
14,
740,
8,
3885,
14,
354,
9,
267,
536,
275,
283,
446,
1987,
904,
8,
354,
63,
4181,
9,
267,
2984,
275,
1709,
14,
2891,
14,
3885,
8,
2302,
29,
3885,
14,
2302,
12,
536,
29,
354,
9,
398,
291,
423,
5570,
14,
3176,
8,
16,
12,
334,
3954,
12,
2984,
430,
339,
347,
664,
63,
1267,
8,
277,
304,
267,
408,
1002,
314,
1329,
402,
18917,
315,
314,
7994,
14,
398,
520,
5808,
26,
314,
7994,
2582,
267,
520,
4500,
26,
1109,
267,
408,
267,
372,
822,
8,
277,
423,
5570,
9,
339,
347,
664,
63,
5570,
8,
277,
304,
267,
408,
1002,
314,
4426,
7994,
14,
398,
710,
22496,
787,
21131,
3967,
9463,
14,
398,
520,
5808,
26,
314,
4426,
7994,
267,
520,
4500,
26,
769,
402,
334,
3954,
12,
520,
533,
1705,
77,
411,
344,
89,
14,
992,
14,
2891,
10522,
6346,
267,
408,
267,
372,
1331,
14,
1574,
8,
277,
423,
5570,
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
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
2649,
63,
5955,
199,
199,
646,
1331,
199,
646,
2050,
199,
646,
900,
199,
199,
504,
333,
411,
344,
89,
492,
1709,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
27829,
7506,
8,
785,
304,
272,
1134,
75,
7351,
63,
1239,
14895,
461,
275,
715,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
5570,
275,
942,
339,
347,
485,
525,
63,
3885,
8,
277,
12,
4426,
304,
267,
408,
1123,
4426,
370,
314,
5232,
894,
7994,
14,
398,
12624,
1083,
367,
520,
533,
1705,
77,
411,
344,
89,
14,
1018,
14,
9651,
894,
7506,
2313,
398,
520,
635,
4426,
26,
4426,
370,
1050,
267,
520,
466,
4426,
26,
520,
533,
1705,
77,
411,
344,
89,
14,
992,
14,
7927,
64,
267,
408,
267,
340,
440,
1228,
8,
3885,
12,
1709,
14,
7927,
304,
288,
746,
3146,
360,
5903,
17507,
2251,
883,
506,
3483,
370,
314,
7994,
358,
398,
4913,
275,
1109,
8,
521,
14,
521,
342,
627,
5198,
9,
398,
536,
63,
4181,
275,
942,
267,
340,
4426,
14,
11215,
83,
26,
288,
536,
63,
4181,
14,
740,
8,
355,
1656,
1987,
904,
779,
11215,
14,
354,
367,
16459,
315,
4426,
14,
11215,
83,
2459,
267,
340,
4426,
14,
354,
365,
440,
488,
26,
288,
536,
63,
4181,
14,
740,
8,
3885,
14,
354,
9,
267,
536,
275,
283,
446,
1987,
904,
8,
354,
63,
4181,
9,
267,
2984,
275,
1709,
14,
2891,
14,
3885,
8,
2302,
29,
3885,
14,
2302,
12,
536,
29,
354,
9,
398,
291,
423,
5570,
14,
3176,
8,
16,
12,
334,
3954,
12,
2984,
430,
339,
347,
664,
63,
1267,
8,
277,
304,
267,
408,
1002,
314,
1329,
402,
18917,
315,
314,
7994,
14,
398,
520,
5808,
26,
314,
7994,
2582,
267,
520,
4500,
26,
1109,
267,
408,
267,
372,
822,
8,
277,
423,
5570,
9,
339,
347,
664,
63,
5570,
8,
277,
304,
267,
408,
1002,
314,
4426,
7994,
14,
398,
710,
22496,
787,
21131,
3967,
9463,
14,
398,
520,
5808,
26,
314,
4426,
7994,
267,
520,
4500,
26,
769,
402,
334,
3954,
12,
520,
533,
1705,
77,
411,
344,
89,
14,
992,
14,
2891,
10522,
6346,
267,
408,
267,
372,
1331,
14,
1574,
8,
277,
423,
5570,
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,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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
] |
embeddedarm/android_external_chromium_org
|
tools/telemetry/telemetry/core/platform/profiler/tcmalloc_heap_profiler.py
|
23
|
4759
|
# Copyright (c) 2013 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.
import logging
import os
import sys
from telemetry.core.backends.chrome import android_browser_finder
from telemetry.core.platform import profiler
# Enviroment variables to (android properties, default value) mapping.
_ENV_VARIABLES = {
'HEAP_PROFILE_TIME_INTERVAL': ('heapprof.time_interval', 20),
'HEAP_PROFILE_MMAP': ('heapprof.mmap', 1),
'DEEP_HEAP_PROFILE': ('heapprof.deep_heap_profile', 1),
}
class _TCMallocHeapProfilerAndroid(object):
"""An internal class to set android properties and fetch dumps from device."""
_DEFAULT_DEVICE_DIR = '/data/local/tmp/heap'
def __init__(self, browser_backend, output_path):
self._browser_backend = browser_backend
self._output_path = output_path
_ENV_VARIABLES['HEAPPROFILE'] = ('heapprof',
os.path.join(self._DEFAULT_DEVICE_DIR, 'dmprof'))
self._SetDeviceProperties(_ENV_VARIABLES)
def _SetDeviceProperties(self, properties):
device_configured = False
# This profiler requires adb root to set properties.
self._browser_backend.adb.Adb().EnableAdbRoot()
for values in properties.itervalues():
device_property = self._browser_backend.adb.system_properties[values[0]]
if not device_property or not device_property.strip():
self._browser_backend.adb.system_properties[values[0]] = values[1]
device_configured = True
if not self._browser_backend.adb.Adb().FileExistsOnDevice(
self._DEFAULT_DEVICE_DIR):
self._browser_backend.adb.RunShellCommand(
'mkdir -p ' + self._DEFAULT_DEVICE_DIR)
self._browser_backend.adb.RunShellCommand(
'chmod 777 ' + self._DEFAULT_DEVICE_DIR)
device_configured = True
if device_configured:
raise Exception('Device required special config, run again.')
def CollectProfile(self):
self._browser_backend.adb.Adb().Adb().Pull(
self._DEFAULT_DEVICE_DIR, self._output_path)
self._browser_backend.adb.RunShellCommand(
'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*'))
if os.path.exists(self._output_path):
logging.info('TCMalloc dumps pulled to %s', self._output_path)
with file(os.path.join(self._output_path,
'browser.pid'), 'w') as pid_file:
pid_file.write(str(self._browser_backend.pid).rjust(5, '0'))
return [self._output_path]
class _TCMallocHeapProfilerLinux(object):
"""An internal class to set environment variables and fetch dumps."""
_DEFAULT_DIR = '/tmp/tcmalloc/'
def __init__(self, browser_backend):
self._browser_backend = browser_backend
_ENV_VARIABLES['HEAPPROFILE'] = ('heapprof', self._DEFAULT_DIR + 'dmprof')
self._CheckEnvironmentVariables(_ENV_VARIABLES)
def _CheckEnvironmentVariables(self, env_vars):
msg = ''
for key, values in env_vars.iteritems():
if key not in os.environ:
msg += '%s=%s ' % (key, str(values[1]))
if msg:
raise Exception('Need enviroment variables, try again with:\n %s' % msg)
if not os.path.exists(os.environ['HEAPPROFILE']):
os.makedirs(os.environ['HEAPPROFILE'])
assert os.path.isdir(os.environ['HEAPPROFILE']), 'HEAPPROFILE is not a dir'
def CollectProfile(self):
with file(os.path.join(os.path.dirname(os.environ['HEAPPROFILE']),
'browser.pid'), 'w') as pid_file:
pid_file.write(str(self._browser_backend.pid))
print 'TCMalloc dumps available ', os.environ['HEAPPROFILE']
return [os.environ['HEAPPROFILE']]
class TCMallocHeapProfiler(profiler.Profiler):
"""A Factory to instantiate the platform-specific profiler."""
def __init__(self, browser_backend, platform_backend, output_path, state):
super(TCMallocHeapProfiler, self).__init__(
browser_backend, platform_backend, output_path, state)
if platform_backend.GetOSName() == 'android':
self._platform_profiler = _TCMallocHeapProfilerAndroid(
browser_backend, output_path)
else:
self._platform_profiler = _TCMallocHeapProfilerLinux(browser_backend)
@classmethod
def name(cls):
return 'tcmalloc-heap'
@classmethod
def is_supported(cls, browser_type):
if browser_type.startswith('cros'):
return False
if sys.platform.startswith('linux'):
return True
if browser_type == 'any':
return android_browser_finder.CanFindAvailableBrowsers()
return browser_type.startswith('android')
@classmethod
def CustomizeBrowserOptions(cls, browser_type, options):
options.AppendExtraBrowserArgs('--no-sandbox')
def CollectProfile(self):
return self._platform_profiler.CollectProfile()
|
bsd-3-clause
|
[
3,
1898,
334,
67,
9,
6171,
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,
646,
2050,
199,
646,
747,
199,
646,
984,
199,
199,
504,
17298,
14,
1018,
14,
7765,
14,
9887,
492,
15516,
63,
5750,
63,
11681,
199,
504,
17298,
14,
1018,
14,
3246,
492,
23173,
199,
199,
3,
3447,
433,
293,
434,
2860,
370,
334,
6238,
4382,
12,
849,
574,
9,
4412,
14,
199,
63,
9984,
63,
21161,
275,
469,
523,
283,
23707,
63,
16632,
63,
4961,
63,
17359,
356,
661,
426,
11227,
70,
14,
521,
63,
4284,
297,
3388,
395,
523,
283,
23707,
63,
16632,
63,
3218,
1282,
356,
661,
426,
11227,
70,
14,
20671,
297,
413,
395,
523,
283,
1093,
6102,
63,
23707,
63,
16632,
356,
661,
426,
11227,
70,
14,
16131,
63,
12492,
63,
2913,
297,
413,
395,
199,
93,
421,
199,
533,
485,
5708,
45,
9373,
19777,
5736,
82,
20762,
8,
785,
304,
523,
408,
2493,
5007,
1021,
370,
663,
15516,
4382,
436,
5267,
16864,
687,
2243,
1041,
819,
485,
3472,
63,
10555,
63,
3022,
275,
1994,
576,
15,
1832,
15,
2791,
15,
12492,
7,
819,
347,
636,
826,
721,
277,
12,
7042,
63,
4620,
12,
1072,
63,
515,
304,
272,
291,
423,
5750,
63,
4620,
275,
7042,
63,
4620,
272,
291,
423,
1199,
63,
515,
275,
1072,
63,
515,
339,
485,
9984,
63,
21161,
459,
23707,
16632,
418,
275,
661,
426,
11227,
70,
297,
267,
747,
14,
515,
14,
904,
8,
277,
423,
3472,
63,
10555,
63,
3022,
12,
283,
10930,
293,
70,
1333,
339,
291,
423,
1084,
2510,
8516,
1547,
9984,
63,
21161,
9,
819,
347,
485,
1084,
2510,
8516,
8,
277,
12,
4382,
304,
272,
2243,
63,
11786,
275,
756,
272,
327,
961,
23173,
5074,
28173,
1738,
370,
663,
4382,
14,
272,
291,
423,
5750,
63,
4620,
14,
13741,
14,
33,
697,
1252,
6476,
33,
697,
6405,
342,
272,
367,
1338,
315,
4382,
14,
13012,
837,
489,
2243,
63,
1829,
275,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2253,
63,
3282,
59,
1459,
59,
16,
2677,
489,
340,
440,
2243,
63,
1829,
503,
440,
2243,
63,
1829,
14,
1913,
837,
267,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2253,
63,
3282,
59,
1459,
59,
16,
2677,
275,
1338,
59,
17,
61,
267,
2243,
63,
11786,
275,
715,
272,
340,
440,
291,
423,
5750,
63,
4620,
14,
13741,
14,
33,
697,
1252,
1173,
7965,
3314,
2510,
8,
267,
291,
423,
3472,
63,
10555,
63,
3022,
304,
489,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2540,
8529,
3110,
8,
881,
283,
8215,
446,
80,
283,
435,
291,
423,
3472,
63,
10555,
63,
3022,
9,
489,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2540,
8529,
3110,
8,
881,
283,
11693,
8375,
23,
283,
435,
291,
423,
3472,
63,
10555,
63,
3022,
9,
489,
2243,
63,
11786,
275,
715,
272,
340,
2243,
63,
11786,
26,
489,
746,
2186,
360,
2510,
1415,
4539,
1101,
12,
1255,
4020,
2659,
819,
347,
19649,
5736,
8,
277,
304,
272,
291,
423,
5750,
63,
4620,
14,
13741,
14,
33,
697,
1252,
33,
697,
1252,
27318,
8,
267,
291,
423,
3472,
63,
10555,
63,
3022,
12,
291,
423,
1199,
63,
515,
9,
272,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2540,
8529,
3110,
8,
267,
283,
5682,
283,
435,
747,
14,
515,
14,
904,
8,
277,
423,
3472,
63,
10555,
63,
3022,
12,
6438,
1333,
272,
340,
747,
14,
515,
14,
2444,
8,
277,
423,
1199,
63,
515,
304,
489,
2050,
14,
815,
360,
5708,
45,
9373,
16864,
25239,
1146,
370,
450,
83,
297,
291,
423,
1199,
63,
515,
9,
489,
543,
570,
8,
736,
14,
515,
14,
904,
8,
277,
423,
1199,
63,
515,
12,
2490,
283,
5750,
14,
3150,
659,
283,
87,
358,
465,
4422,
63,
493,
26,
267,
4422,
63,
493,
14,
952,
8,
495,
8,
277,
423,
5750,
63,
4620,
14,
3150,
680,
24473,
8,
21,
12,
283,
16,
1333,
272,
372,
359,
277,
423,
1199,
63,
515,
61,
421,
199,
533,
485,
5708,
45,
9373,
19777,
5736,
82,
14091,
8,
785,
304,
523,
408,
2493,
5007,
1021,
370,
663,
3734,
2860,
436,
5267,
16864,
1041,
819,
485,
3472,
63,
3022,
275,
1994,
2791,
15,
3641,
23981,
4805,
819,
347,
636,
826,
721,
277,
12,
7042,
63,
4620,
304,
272,
291,
423,
5750,
63,
4620,
275,
7042,
63,
4620,
272,
485,
9984,
63,
21161,
459,
23707,
16632,
418,
275,
661,
426,
11227,
70,
297,
291,
423,
3472,
63,
3022,
435,
283,
10930,
293,
70,
358,
272,
291,
423,
1799,
8263,
11458,
1547,
9984,
63,
21161,
9,
819,
347,
485,
1799,
8263,
11458,
8,
277,
12,
2589,
63,
2936,
304,
272,
1499,
275,
2125,
272,
367,
790,
12,
1338,
315,
2589,
63,
2936,
14,
4611,
837,
489,
340,
790,
440,
315,
747,
14,
2314,
26,
267,
1499,
847,
1543,
83,
2458,
83,
283,
450,
334,
498,
12,
620,
8,
1459,
59,
17,
2459,
272,
340,
1499,
26,
489,
746,
2186,
360,
17809,
655,
433,
293,
434,
2860,
12,
862,
4020,
543,
3427,
78,
450,
83,
7,
450,
1499,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
736,
14,
2314,
459,
23707,
16632,
9090,
489,
747,
14,
8347,
8,
736,
14,
2314,
459,
23707,
16632,
1105,
272,
702,
747,
14,
515,
14,
6027,
8,
736,
14,
2314,
459,
23707,
16632,
3815,
283,
23707,
16632,
365,
440,
282,
2935,
7,
819,
347,
19649,
5736,
8,
277,
304,
272,
543,
570,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
2314,
459,
23707,
16632,
3815,
2574,
283,
5750,
14,
3150,
659,
283,
87,
358,
465,
4422,
63,
493,
26,
489,
4422,
63,
493,
14,
952,
8,
495,
8,
277,
423,
5750,
63,
4620,
14,
3150,
430,
272,
870,
283,
5708,
45,
9373,
16864,
2808,
1656,
747,
14,
2314,
459,
23707,
16632,
418,
272,
372,
359,
736,
14,
2314,
459,
23707,
16632,
6538,
421,
199,
533,
28526,
9373,
19777,
5736,
82,
8,
20132,
14,
5736,
82,
304,
523,
408,
33,
23616,
370,
17321,
314,
4298
] |
[
1898,
334,
67,
9,
6171,
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,
646,
2050,
199,
646,
747,
199,
646,
984,
199,
199,
504,
17298,
14,
1018,
14,
7765,
14,
9887,
492,
15516,
63,
5750,
63,
11681,
199,
504,
17298,
14,
1018,
14,
3246,
492,
23173,
199,
199,
3,
3447,
433,
293,
434,
2860,
370,
334,
6238,
4382,
12,
849,
574,
9,
4412,
14,
199,
63,
9984,
63,
21161,
275,
469,
523,
283,
23707,
63,
16632,
63,
4961,
63,
17359,
356,
661,
426,
11227,
70,
14,
521,
63,
4284,
297,
3388,
395,
523,
283,
23707,
63,
16632,
63,
3218,
1282,
356,
661,
426,
11227,
70,
14,
20671,
297,
413,
395,
523,
283,
1093,
6102,
63,
23707,
63,
16632,
356,
661,
426,
11227,
70,
14,
16131,
63,
12492,
63,
2913,
297,
413,
395,
199,
93,
421,
199,
533,
485,
5708,
45,
9373,
19777,
5736,
82,
20762,
8,
785,
304,
523,
408,
2493,
5007,
1021,
370,
663,
15516,
4382,
436,
5267,
16864,
687,
2243,
1041,
819,
485,
3472,
63,
10555,
63,
3022,
275,
1994,
576,
15,
1832,
15,
2791,
15,
12492,
7,
819,
347,
636,
826,
721,
277,
12,
7042,
63,
4620,
12,
1072,
63,
515,
304,
272,
291,
423,
5750,
63,
4620,
275,
7042,
63,
4620,
272,
291,
423,
1199,
63,
515,
275,
1072,
63,
515,
339,
485,
9984,
63,
21161,
459,
23707,
16632,
418,
275,
661,
426,
11227,
70,
297,
267,
747,
14,
515,
14,
904,
8,
277,
423,
3472,
63,
10555,
63,
3022,
12,
283,
10930,
293,
70,
1333,
339,
291,
423,
1084,
2510,
8516,
1547,
9984,
63,
21161,
9,
819,
347,
485,
1084,
2510,
8516,
8,
277,
12,
4382,
304,
272,
2243,
63,
11786,
275,
756,
272,
327,
961,
23173,
5074,
28173,
1738,
370,
663,
4382,
14,
272,
291,
423,
5750,
63,
4620,
14,
13741,
14,
33,
697,
1252,
6476,
33,
697,
6405,
342,
272,
367,
1338,
315,
4382,
14,
13012,
837,
489,
2243,
63,
1829,
275,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2253,
63,
3282,
59,
1459,
59,
16,
2677,
489,
340,
440,
2243,
63,
1829,
503,
440,
2243,
63,
1829,
14,
1913,
837,
267,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2253,
63,
3282,
59,
1459,
59,
16,
2677,
275,
1338,
59,
17,
61,
267,
2243,
63,
11786,
275,
715,
272,
340,
440,
291,
423,
5750,
63,
4620,
14,
13741,
14,
33,
697,
1252,
1173,
7965,
3314,
2510,
8,
267,
291,
423,
3472,
63,
10555,
63,
3022,
304,
489,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2540,
8529,
3110,
8,
881,
283,
8215,
446,
80,
283,
435,
291,
423,
3472,
63,
10555,
63,
3022,
9,
489,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2540,
8529,
3110,
8,
881,
283,
11693,
8375,
23,
283,
435,
291,
423,
3472,
63,
10555,
63,
3022,
9,
489,
2243,
63,
11786,
275,
715,
272,
340,
2243,
63,
11786,
26,
489,
746,
2186,
360,
2510,
1415,
4539,
1101,
12,
1255,
4020,
2659,
819,
347,
19649,
5736,
8,
277,
304,
272,
291,
423,
5750,
63,
4620,
14,
13741,
14,
33,
697,
1252,
33,
697,
1252,
27318,
8,
267,
291,
423,
3472,
63,
10555,
63,
3022,
12,
291,
423,
1199,
63,
515,
9,
272,
291,
423,
5750,
63,
4620,
14,
13741,
14,
2540,
8529,
3110,
8,
267,
283,
5682,
283,
435,
747,
14,
515,
14,
904,
8,
277,
423,
3472,
63,
10555,
63,
3022,
12,
6438,
1333,
272,
340,
747,
14,
515,
14,
2444,
8,
277,
423,
1199,
63,
515,
304,
489,
2050,
14,
815,
360,
5708,
45,
9373,
16864,
25239,
1146,
370,
450,
83,
297,
291,
423,
1199,
63,
515,
9,
489,
543,
570,
8,
736,
14,
515,
14,
904,
8,
277,
423,
1199,
63,
515,
12,
2490,
283,
5750,
14,
3150,
659,
283,
87,
358,
465,
4422,
63,
493,
26,
267,
4422,
63,
493,
14,
952,
8,
495,
8,
277,
423,
5750,
63,
4620,
14,
3150,
680,
24473,
8,
21,
12,
283,
16,
1333,
272,
372,
359,
277,
423,
1199,
63,
515,
61,
421,
199,
533,
485,
5708,
45,
9373,
19777,
5736,
82,
14091,
8,
785,
304,
523,
408,
2493,
5007,
1021,
370,
663,
3734,
2860,
436,
5267,
16864,
1041,
819,
485,
3472,
63,
3022,
275,
1994,
2791,
15,
3641,
23981,
4805,
819,
347,
636,
826,
721,
277,
12,
7042,
63,
4620,
304,
272,
291,
423,
5750,
63,
4620,
275,
7042,
63,
4620,
272,
485,
9984,
63,
21161,
459,
23707,
16632,
418,
275,
661,
426,
11227,
70,
297,
291,
423,
3472,
63,
3022,
435,
283,
10930,
293,
70,
358,
272,
291,
423,
1799,
8263,
11458,
1547,
9984,
63,
21161,
9,
819,
347,
485,
1799,
8263,
11458,
8,
277,
12,
2589,
63,
2936,
304,
272,
1499,
275,
2125,
272,
367,
790,
12,
1338,
315,
2589,
63,
2936,
14,
4611,
837,
489,
340,
790,
440,
315,
747,
14,
2314,
26,
267,
1499,
847,
1543,
83,
2458,
83,
283,
450,
334,
498,
12,
620,
8,
1459,
59,
17,
2459,
272,
340,
1499,
26,
489,
746,
2186,
360,
17809,
655,
433,
293,
434,
2860,
12,
862,
4020,
543,
3427,
78,
450,
83,
7,
450,
1499,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
736,
14,
2314,
459,
23707,
16632,
9090,
489,
747,
14,
8347,
8,
736,
14,
2314,
459,
23707,
16632,
1105,
272,
702,
747,
14,
515,
14,
6027,
8,
736,
14,
2314,
459,
23707,
16632,
3815,
283,
23707,
16632,
365,
440,
282,
2935,
7,
819,
347,
19649,
5736,
8,
277,
304,
272,
543,
570,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
2314,
459,
23707,
16632,
3815,
2574,
283,
5750,
14,
3150,
659,
283,
87,
358,
465,
4422,
63,
493,
26,
489,
4422,
63,
493,
14,
952,
8,
495,
8,
277,
423,
5750,
63,
4620,
14,
3150,
430,
272,
870,
283,
5708,
45,
9373,
16864,
2808,
1656,
747,
14,
2314,
459,
23707,
16632,
418,
272,
372,
359,
736,
14,
2314,
459,
23707,
16632,
6538,
421,
199,
533,
28526,
9373,
19777,
5736,
82,
8,
20132,
14,
5736,
82,
304,
523,
408,
33,
23616,
370,
17321,
314,
4298,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
qt-haiku/LibreOffice
|
wizards/com/sun/star/wizards/ui/WizardDialog.py
|
11
|
18866
|
#
# This file is part of the LibreOffice project.
#
# 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/.
#
# This file incorporates work covered by the following license notice:
#
# 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 .
#
import uno
import traceback
from abc import ABCMeta, abstractmethod
from .UnoDialog2 import UnoDialog2, Desktop, PropertyNames, UIConsts, \
ItemListenerProcAdapter
from ..common.Resource import Resource
from ..common.HelpIds import HelpIds
from ..common.FileAccess import FileAccess
from com.sun.star.lang import NoSuchMethodException
from com.sun.star.frame import TerminationVetoException
from com.sun.star.awt.PushButtonType import HELP, STANDARD
from com.sun.star.awt.FontWeight import BOLD
class WizardDialog(UnoDialog2):
__metaclass__ = ABCMeta
__NEXT_ACTION_PERFORMED = "gotoNextAvailableStep"
__BACK_ACTION_PERFORMED = "gotoPreviousAvailableStep"
__FINISH_ACTION_PERFORMED = "finishWizard_1"
__CANCEL_ACTION_PERFORMED = "cancelWizard_1"
__HELP_ACTION_PERFORMED = None
'''
Creates a new instance of WizardDialog
the hid is used as following :
"HID:(hid)" - the dialog
"HID:(hid+1) - the help button
"HID:(hid+2)" - the back button
"HID:(hid+3)" - the next button
"HID:(hid+4)" - the create button
"HID:(hid+5)" - the cancel button
@param xMSF
@param hid_
'''
def __init__(self, xMSF, hid_):
super(WizardDialog,self).__init__(xMSF)
self.__hid = hid_
self.iButtonWidth = 50
self.nNewStep = 1
self.nOldStep = 1
self.nMaxStep = 1
self.bTerminateListenermustberemoved = True
self.oWizardResource = Resource(xMSF, "dbw")
self.oRoadmap = None
self.terminateListener = None
def activate(self):
try:
self.xUnoDialog.toFront()
except Exception:
pass
# do nothing;
def itemStateChanged(self, itemEvent):
try:
self.nNewStep = itemEvent.ItemId
self.nOldStep = int(self.xDialogModel.Step)
if self.nNewStep != self.nOldStep:
self.switchToStep()
except Exception:
traceback.print_exc()
def setDialogProperties(self, closeable, height, moveable, position_x,
position_Y, step, tabIndex, title, width):
uno.invoke(self.xDialogModel, "setPropertyValues",
((PropertyNames.PROPERTY_CLOSEABLE,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_MOVEABLE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_TITLE,
PropertyNames.PROPERTY_WIDTH),
(closeable, height, moveable, position_x, position_Y, step,
tabIndex, title, width)))
def setRoadmapInteractive(self, _bInteractive):
self.oRoadmap.Activated = _bInteractive
def setRoadmapComplete(self, bComplete):
self.oRoadmap.Complete = bComplete
def isRoadmapComplete(self):
try:
return bool(self.oRoadmap.Complete)
except Exception:
traceback.print_exc()
return False
def setCurrentRoadmapItemID(self, ID):
if self.oRoadmap is not None:
nCurItemID = self.getCurrentRoadmapItemID()
if nCurItemID != ID:
self.oRoadmap.CurrentItemID = ID
def getCurrentRoadmapItemID(self):
try:
return int(self.oRoadmap.CurrentItemID)
except Exception:
traceback.print_exc()
return -1
def initializePaths(self):
xPropertySet = \
self.xMSF.createInstance("com.sun.star.util.PathSettings")
self.sUserTemplatePath = \
xPropertySet.getPropertyValue("Template_writable")
myFA = FileAccess(self.xMSF)
aInternalPaths = xPropertySet.getPropertyValue("Template_internal")
self.sTemplatePath = ""
for path in aInternalPaths:
if myFA.exists(path + "/wizard", False):
self.sTemplatePath = path
break
if self.sTemplatePath == "":
raise Exception("could not find wizard templates")
def addRoadmap(self):
try:
iDialogHeight = self.xDialogModel.Height
# the roadmap control has got no real TabIndex ever
# that is not correct, but changing this would need time,
# so it is used without TabIndex as before
xRoadmapControl = self.insertControlModel(
"com.sun.star.awt.UnoControlRoadmapModel",
"rdmNavi",
(PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX, "Tabstop",
PropertyNames.PROPERTY_WIDTH),
((iDialogHeight - 26), 0, 0, 0,
0, True, 85))
self.oRoadmap = xRoadmapControl.Model
method = getattr(self, "itemStateChanged")
xRoadmapControl.addItemListener(
ItemListenerProcAdapter(method))
self.oRoadmap.Text = \
self.oWizardResource.getResText(UIConsts.RID_COMMON + 16)
except NoSuchMethodException:
Resource.showCommonResourceError(xMSF)
except Exception:
traceback.print_exc()
def getRoadmapItemByID(self, _ID):
try:
getByIndex = self.oRoadmap.getByIndex
for i in list(range(self.oRoadmap.Count)):
CurRoadmapItem = getByIndex(i)
CurID = int(CurRoadmapItem.ID)
if CurID == _ID:
return CurRoadmapItem
return None
except Exception:
traceback.print_exc()
return None
def switchToStep(self,_nOldStep=None, _nNewStep=None):
if _nOldStep is not None and _nNewStep is not None:
self.nOldStep = _nOldStep
self.nNewStep = _nNewStep
self.leaveStep(self.nOldStep, self.nNewStep)
if self.nNewStep != self.nOldStep:
if self.nNewStep == self.nMaxStep:
self.xDialogModel.btnWizardNext.DefaultButton = False
self.xDialogModel.btnWizardFinish.DefaultButton = True
else:
self.xDialogModel.btnWizardNext.DefaultButton = True
self.xDialogModel.btnWizardFinish.DefaultButton = False
self.changeToStep(self.nNewStep)
self.enterStep(self.nOldStep, self.nNewStep)
return True
return False
@abstractmethod
def leaveStep(self, nOldStep, nNewStep):
pass
@abstractmethod
def enterStep(self, nOldStep, nNewStep):
pass
def changeToStep(self, nNewStep):
self.xDialogModel.Step = nNewStep
self.setCurrentRoadmapItemID(nNewStep)
self.enableNextButton(self.getNextAvailableStep() > 0)
self.enableBackButton(nNewStep != 1)
def drawNaviBar(self):
try:
curtabindex = UIConsts.SOFIRSTWIZARDNAVITABINDEX
iButtonWidth = self.iButtonWidth
iButtonHeight = 14
iCurStep = 0
iDialogHeight = self.xDialogModel.Height
iDialogWidth = self.xDialogModel.Width
iHelpPosX = 8
iBtnPosY = iDialogHeight - iButtonHeight - 6
iCancelPosX = iDialogWidth - self.iButtonWidth - 6
iFinishPosX = iCancelPosX - 6 - self.iButtonWidth
iNextPosX = iFinishPosX - 6 - self.iButtonWidth
iBackPosX = iNextPosX - 3 - self.iButtonWidth
self.insertControlModel(
"com.sun.star.awt.UnoControlFixedLineModel",
"lnNaviSep",
(PropertyNames.PROPERTY_HEIGHT, "Orientation",
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_WIDTH),
(1, 0, 0, iDialogHeight - 26, iCurStep, iDialogWidth))
self.insertControlModel(
"com.sun.star.awt.UnoControlFixedLineModel",
"lnRoadSep",
(PropertyNames.PROPERTY_HEIGHT,
"Orientation",
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_WIDTH),
(iBtnPosY - 6, 1, 85, 0, iCurStep, 1))
propNames = (PropertyNames.PROPERTY_ENABLED,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
"PushButtonType",
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH)
self.xDialogModel.HelpURL = HelpIds.getHelpIdString(self.__hid)
self.insertButton("btnWizardHelp",
WizardDialog.__HELP_ACTION_PERFORMED,
(PropertyNames.PROPERTY_ENABLED,
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
"PushButtonType",
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),
(True, iButtonHeight,
self.oWizardResource.getResText(UIConsts.RID_COMMON + 15),
iHelpPosX, iBtnPosY,
uno.Any("short",HELP), iCurStep,
uno.Any("short",(curtabindex + 1)), iButtonWidth), self)
self.insertButton("btnWizardBack",
WizardDialog.__BACK_ACTION_PERFORMED, propNames,
(False, iButtonHeight, HelpIds.getHelpIdString(self.__hid + 2),
self.oWizardResource.getResText(UIConsts.RID_COMMON + 13),
iBackPosX, iBtnPosY, uno.Any("short",STANDARD), iCurStep,
uno.Any("short",(curtabindex + 1)), iButtonWidth), self)
self.insertButton("btnWizardNext",
WizardDialog.__NEXT_ACTION_PERFORMED, propNames,
(True, iButtonHeight, HelpIds.getHelpIdString(self.__hid + 3),
self.oWizardResource.getResText(UIConsts.RID_COMMON + 14),
iNextPosX, iBtnPosY, uno.Any("short",STANDARD), iCurStep,
uno.Any("short",(curtabindex + 1)), iButtonWidth), self)
self.insertButton("btnWizardFinish",
WizardDialog.__FINISH_ACTION_PERFORMED, propNames,
(True, iButtonHeight, HelpIds.getHelpIdString(self.__hid + 4),
self.oWizardResource.getResText(UIConsts.RID_COMMON + 12),
iFinishPosX, iBtnPosY, uno.Any("short",STANDARD),
iCurStep,
uno.Any("short",(curtabindex + 1)),
iButtonWidth), self)
self.insertButton("btnWizardCancel",
WizardDialog.__CANCEL_ACTION_PERFORMED, propNames,
(True, iButtonHeight, HelpIds.getHelpIdString(self.__hid + 5),
self.oWizardResource.getResText(UIConsts.RID_COMMON + 11),
iCancelPosX, iBtnPosY, uno.Any("short",STANDARD), iCurStep,
uno.Any("short",(curtabindex + 1)),
iButtonWidth), self)
self.xDialogModel.btnWizardNext.DefaultButton = True
except Exception:
traceback.print_exc()
def insertRoadMapItems(self, items, enabled):
for index, item in enumerate(items):
try:
oRoadmapItem = self.oRoadmap.createInstance()
oRoadmapItem.Label = item
oRoadmapItem.Enabled = enabled[index]
oRoadmapItem.ID = index + 1
self.oRoadmap.insertByIndex(index, oRoadmapItem)
except Exception:
traceback.print_exc()
def setStepEnabled(self, _nStep, bEnabled, enableNextButton=None):
xRoadmapItem = self.getRoadmapItemByID(_nStep)
if xRoadmapItem is not None:
xRoadmapItem.Enabled = bEnabled
if enableNextButton is not None:
if self.getNextAvailableStep() > 0:
self.enableNextButton(bEnabled)
def enableNavigationButtons(
self, _bEnableBack, _bEnableNext, _bEnableFinish):
self.enableBackButton(_bEnableBack)
self.enableNextButton(_bEnableNext)
self.enableFinishButton(_bEnableFinish)
def enableBackButton(self, enabled):
self.xDialogModel.btnWizardBack.Enabled = enabled
def enableNextButton(self, enabled):
self.xDialogModel.btnWizardNext.Enabled = enabled
def enableFinishButton(self, enabled):
self.xDialogModel.btnWizardFinish.Enabled = enabled
def enablefromStep(self, _iStep, _bDoEnable):
if _iStep <= self.nMaxStep:
for i in list(range(_iStep, self.nMaxStep)):
self.setStepEnabled(i, _bDoEnable)
enableFinishButton(_bDoEnable)
if not _bDoEnable:
enableNextButton(_iStep > getCurrentStep() + 1)
else:
enableNextButton(not (getCurrentStep() == self.nMaxStep))
def isStepEnabled(self, _nStep):
try:
xRoadmapItem = self.getRoadmapItemByID(_nStep)
# Todo: In this case an exception should be thrown
if xRoadmapItem is None:
return False
bIsEnabled = bool(xRoadmapItem.Enabled)
return bIsEnabled
except Exception:
traceback.print_exc()
return False
def gotoPreviousAvailableStep(self):
try:
if self.nNewStep > 1:
self.nOldStep = self.nNewStep
self.nNewStep -= 1
while self.nNewStep > 0:
bIsEnabled = self.isStepEnabled(self.nNewStep)
if bIsEnabled:
break;
self.nNewStep -= 1
if (self.nNewStep == 0):
self.nNewStep = self.nOldStep
self.switchToStep()
except Exception:
traceback.print_exc()
def getNextAvailableStep(self):
if self.isRoadmapComplete():
i = self.nNewStep + 1
while i <= self.nMaxStep:
if self.isStepEnabled(i):
return i
i += 1
return -1
def gotoNextAvailableStep(self):
try:
self.nOldStep = self.nNewStep
self.nNewStep = self.getNextAvailableStep()
if self.nNewStep > -1:
self.switchToStep()
except Exception:
traceback.print_exc()
@abstractmethod
def finishWizard(self):
pass
def finishWizard_1(self):
'''This function will call
if the finish button is pressed on the UI'''
try:
self.enableFinishButton(False)
success = False
try:
success = self.finishWizard()
finally:
if not success:
self.enableFinishButton(True)
if success:
self.removeTerminateListener()
except Exception:
traceback.print_exc()
def getMaximalStep(self):
return self.nMaxStep
def getCurrentStep(self):
try:
return int(self.xDialogModel.Step)
except Exception:
traceback.print_exc()
return -1
def setCurrentStep(self, _nNewstep):
self.nNewStep = _nNewstep
changeToStep(self.nNewStep)
def setRightPaneHeaders(self, _sRightPaneHeaders):
self.nMaxStep = len(_sRightPaneHeaders)
self.sRightPaneHeaders = _sRightPaneHeaders
oFontDesc = uno.createUnoStruct('com.sun.star.awt.FontDescriptor')
oFontDesc.Weight = BOLD
for i in range(self.nMaxStep):
self.insertLabel("lblQueryTitle" + str(i),
("FontDescriptor",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),(
oFontDesc, 16, _sRightPaneHeaders[i],
True, 91, 8, i + 1, 12, 212))
def cancelWizard(self):
#can be overwritten by extending class
self.xUnoDialog.endExecute()
def removeTerminateListener(self):
if self.bTerminateListenermustberemoved:
Desktop.getDesktop(self.xMSF).removeTerminateListener(self.terminateListener)
self.bTerminateListenermustberemoved = False
'''
called by the cancel button and
by the window hidden event.
if this method was not called before,
perform a cancel.
'''
def cancelWizard_1(self):
try:
self.cancelWizard()
self.removeTerminateListener()
except Exception:
traceback.print_exc()
def windowHidden():
self.cancelWizard_1()
def queryTermination(self):
self.activate()
raise TerminationVetoException()
def disposing(arg0):
self.cancelWizard_1()
def optCreateFromTemplateItemChanged(self):
self.bEditTemplate = False
def optMakeChangesItemChanged(self):
self.bEditTemplate = True
|
gpl-3.0
|
[
3,
199,
3,
961,
570,
365,
1777,
402,
314,
8003,
264,
31166,
2199,
14,
199,
3,
199,
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,
3,
199,
3,
961,
570,
30147,
2335,
1736,
24295,
701,
314,
2569,
4190,
4245,
26,
199,
3,
199,
3,
257,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
257,
11615,
4190,
14024,
14,
1666,
314,
12840,
570,
1854,
199,
3,
257,
543,
642,
1736,
367,
4722,
2556,
12602,
4248,
199,
3,
257,
12715,
14,
710,
14857,
12378,
642,
570,
370,
1265,
1334,
314,
3668,
199,
3,
257,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
199,
3,
257,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
282,
1331,
402,
199,
3,
257,
314,
844,
737,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
1275,
199,
3,
199,
646,
625,
79,
199,
646,
5190,
199,
504,
13022,
492,
29565,
12,
9006,
765,
199,
504,
1275,
53,
889,
5619,
18,
492,
738,
889,
5619,
18,
12,
8055,
17827,
12,
16158,
5866,
12,
14041,
6361,
83,
12,
971,
272,
7020,
10464,
15019,
10200,
199,
504,
2508,
2330,
14,
4031,
492,
7337,
199,
504,
2508,
2330,
14,
8673,
11506,
492,
15456,
11506,
199,
504,
2508,
2330,
14,
1173,
3946,
492,
3814,
3946,
199,
199,
504,
2414,
14,
11846,
14,
7848,
14,
4159,
492,
23798,
3767,
1726,
199,
504,
2414,
14,
11846,
14,
7848,
14,
1943,
492,
20429,
425,
54,
16876,
1726,
199,
504,
2414,
14,
11846,
14,
7848,
14,
65,
9115,
14,
20083,
804,
492,
29269,
12,
4384,
16938,
199,
504,
2414,
14,
11846,
14,
7848,
14,
65,
9115,
14,
6986,
16359,
492,
699,
5104,
199,
199,
533,
644,
6281,
5619,
8,
53,
889,
5619,
18,
304,
339,
636,
6577,
363,
275,
29565,
339,
636,
21917,
63,
10052,
63,
4227,
3516,
1149,
275,
298,
14867,
5765,
11464,
7801,
2,
272,
636,
7111,
63,
10052,
63,
4227,
3516,
1149,
275,
298,
14867,
18021,
11464,
7801,
2,
272,
636,
17383,
13898,
63,
10052,
63,
4227,
3516,
1149,
275,
298,
8192,
20120,
63,
17,
2,
272,
636,
20707,
63,
10052,
63,
4227,
3516,
1149,
275,
298,
6406,
20120,
63,
17,
2,
272,
636,
17930,
63,
10052,
63,
4227,
3516,
1149,
275,
488,
339,
1449,
272,
10560,
282,
892,
1256,
402,
644,
6281,
5619,
272,
314,
27276,
365,
1202,
465,
2569,
520,
272,
298,
32577,
20334,
18209,
2924,
257,
446,
314,
9592,
272,
298,
32577,
20334,
18209,
11,
17,
9,
221,
446,
314,
1720,
5528,
272,
298,
32577,
20334,
18209,
11,
18,
2924,
446,
314,
1771,
5528,
272,
298,
32577,
20334,
18209,
11,
19,
2924,
446,
314,
2163,
5528,
272,
298,
32577,
20334,
18209,
11,
20,
2924,
446,
314,
1218,
5528,
272,
298,
32577,
20334,
18209,
11,
21,
2924,
446,
314,
9311,
5528,
272,
768,
635,
671,
3053,
38,
272,
768,
635,
27276,
63,
272,
1449,
339,
347,
636,
826,
721,
277,
12,
671,
3053,
38,
12,
27276,
7822,
267,
1613,
8,
20120,
5619,
12,
277,
2843,
826,
721,
88,
3053,
38,
9,
267,
291,
855,
18209,
275,
27276,
63,
267,
291,
14,
73,
4259,
6216,
275,
5238,
267,
291,
14,
78,
4665,
7801,
275,
413,
267,
291,
14,
78,
16411,
7801,
275,
413,
267,
291,
14,
78,
4261,
7801,
275,
413,
267,
291,
14,
66,
12154,
323,
10464,
7790,
1235,
10649,
275,
715,
267,
291,
14,
79,
20120,
4031,
275,
7337,
8,
88,
3053,
38,
12,
298,
697,
87,
531,
267,
291,
14,
79,
3863,
350,
1130,
275,
488,
267,
291,
14,
14478,
10464,
275,
488,
339,
347,
15422,
8,
277,
304,
267,
862,
26,
288,
291,
14,
88,
53,
889,
5619,
14,
475,
17607,
342,
267,
871,
2186,
26,
288,
986,
288,
327,
886,
6548,
27,
339,
347,
1242,
2223,
6970,
8,
277,
12,
1242,
2390,
304,
267,
862,
26,
288,
291,
14,
78,
4665,
7801,
275,
1242,
2390,
14,
2081,
1304,
288,
291,
14,
78,
16411,
7801,
275,
1109,
8,
277,
14,
88,
5619,
1685,
14,
7801,
9,
288,
340,
291,
14,
78,
4665,
7801,
1137,
291,
14,
78,
16411,
7801,
26,
355,
291,
14,
5656,
1378,
7801,
342,
398,
871,
2186,
26,
288,
5190,
14,
1361,
63,
2804,
342,
339,
347,
663,
5619,
8516,
8,
277,
12,
4002,
461,
12,
4569,
12,
4057,
461,
12,
3421,
63,
88,
12,
267,
3421,
63,
57,
12,
3650,
12,
5174,
2681,
12,
2538,
12,
3462,
304,
267,
625,
79,
14,
15195,
8,
277,
14,
88,
5619,
1685,
12,
298,
21173,
6550,
401,
1467,
3666,
3697,
5866,
14,
25091,
63,
18219,
2617,
12,
8892,
16158,
5866,
14,
25091,
63,
13509,
12,
8892,
16158,
5866,
14,
25091,
63,
16207,
2617,
12,
355,
16158,
5866,
14,
25091,
63,
15717,
63,
56,
12,
355,
16158,
5866,
14,
25091,
63,
15717,
63,
57,
12,
355,
16158,
5866,
14,
25091,
63,
17988,
12,
8892,
16158,
5866,
14,
25091,
63,
10129,
10215,
12,
355,
16158,
5866,
14,
25091,
63,
19091,
12,
355,
16158,
5866,
14,
25091,
63,
11139,
395,
1467,
334,
1600,
461,
12,
4569,
12,
4057,
461,
12,
3421,
63,
88,
12,
3421,
63,
57,
12,
3650,
12,
8892,
5174,
2681,
12,
2538,
12,
3462,
1724,
420,
5493,
347,
663,
3863,
350,
1130,
23879,
8,
277,
12,
485,
66,
23879,
304,
267,
291,
14,
79,
3863,
350,
1130,
14,
13767,
12529,
275,
485,
66,
23879,
339,
347,
663,
3863,
350,
1130,
14175,
8,
277,
12,
330,
14175,
304,
267,
291,
14,
79,
3863,
350,
1130,
14,
14175,
275,
330,
14175,
339,
347,
365,
3863,
350,
1130,
14175,
8,
277,
304,
267,
862,
26,
288,
372,
2155,
8,
277,
14,
79,
3863,
350,
1130,
14,
14175,
9,
267,
871,
2186,
26,
288,
5190,
14,
1361,
63,
2804,
342,
288,
372,
756,
339,
347,
663,
5639,
3863,
350,
1130,
2081,
998,
8,
277,
12,
2870,
304,
267,
340,
291,
14
] |
[
199,
3,
961,
570,
365,
1777,
402,
314,
8003,
264,
31166,
2199,
14,
199,
3,
199,
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,
3,
199,
3,
961,
570,
30147,
2335,
1736,
24295,
701,
314,
2569,
4190,
4245,
26,
199,
3,
199,
3,
257,
3909,
370,
314,
3668,
2290,
2752,
334,
14950,
9,
1334,
1373,
503,
1655,
199,
3,
257,
11615,
4190,
14024,
14,
1666,
314,
12840,
570,
1854,
199,
3,
257,
543,
642,
1736,
367,
4722,
2556,
12602,
4248,
199,
3,
257,
12715,
14,
710,
14857,
12378,
642,
570,
370,
1265,
1334,
314,
3668,
199,
3,
257,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
1265,
1443,
440,
675,
642,
570,
199,
3,
257,
871,
315,
4151,
543,
314,
844,
14,
2047,
1443,
3332,
282,
1331,
402,
199,
3,
257,
314,
844,
737,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
1275,
199,
3,
199,
646,
625,
79,
199,
646,
5190,
199,
504,
13022,
492,
29565,
12,
9006,
765,
199,
504,
1275,
53,
889,
5619,
18,
492,
738,
889,
5619,
18,
12,
8055,
17827,
12,
16158,
5866,
12,
14041,
6361,
83,
12,
971,
272,
7020,
10464,
15019,
10200,
199,
504,
2508,
2330,
14,
4031,
492,
7337,
199,
504,
2508,
2330,
14,
8673,
11506,
492,
15456,
11506,
199,
504,
2508,
2330,
14,
1173,
3946,
492,
3814,
3946,
199,
199,
504,
2414,
14,
11846,
14,
7848,
14,
4159,
492,
23798,
3767,
1726,
199,
504,
2414,
14,
11846,
14,
7848,
14,
1943,
492,
20429,
425,
54,
16876,
1726,
199,
504,
2414,
14,
11846,
14,
7848,
14,
65,
9115,
14,
20083,
804,
492,
29269,
12,
4384,
16938,
199,
504,
2414,
14,
11846,
14,
7848,
14,
65,
9115,
14,
6986,
16359,
492,
699,
5104,
199,
199,
533,
644,
6281,
5619,
8,
53,
889,
5619,
18,
304,
339,
636,
6577,
363,
275,
29565,
339,
636,
21917,
63,
10052,
63,
4227,
3516,
1149,
275,
298,
14867,
5765,
11464,
7801,
2,
272,
636,
7111,
63,
10052,
63,
4227,
3516,
1149,
275,
298,
14867,
18021,
11464,
7801,
2,
272,
636,
17383,
13898,
63,
10052,
63,
4227,
3516,
1149,
275,
298,
8192,
20120,
63,
17,
2,
272,
636,
20707,
63,
10052,
63,
4227,
3516,
1149,
275,
298,
6406,
20120,
63,
17,
2,
272,
636,
17930,
63,
10052,
63,
4227,
3516,
1149,
275,
488,
339,
1449,
272,
10560,
282,
892,
1256,
402,
644,
6281,
5619,
272,
314,
27276,
365,
1202,
465,
2569,
520,
272,
298,
32577,
20334,
18209,
2924,
257,
446,
314,
9592,
272,
298,
32577,
20334,
18209,
11,
17,
9,
221,
446,
314,
1720,
5528,
272,
298,
32577,
20334,
18209,
11,
18,
2924,
446,
314,
1771,
5528,
272,
298,
32577,
20334,
18209,
11,
19,
2924,
446,
314,
2163,
5528,
272,
298,
32577,
20334,
18209,
11,
20,
2924,
446,
314,
1218,
5528,
272,
298,
32577,
20334,
18209,
11,
21,
2924,
446,
314,
9311,
5528,
272,
768,
635,
671,
3053,
38,
272,
768,
635,
27276,
63,
272,
1449,
339,
347,
636,
826,
721,
277,
12,
671,
3053,
38,
12,
27276,
7822,
267,
1613,
8,
20120,
5619,
12,
277,
2843,
826,
721,
88,
3053,
38,
9,
267,
291,
855,
18209,
275,
27276,
63,
267,
291,
14,
73,
4259,
6216,
275,
5238,
267,
291,
14,
78,
4665,
7801,
275,
413,
267,
291,
14,
78,
16411,
7801,
275,
413,
267,
291,
14,
78,
4261,
7801,
275,
413,
267,
291,
14,
66,
12154,
323,
10464,
7790,
1235,
10649,
275,
715,
267,
291,
14,
79,
20120,
4031,
275,
7337,
8,
88,
3053,
38,
12,
298,
697,
87,
531,
267,
291,
14,
79,
3863,
350,
1130,
275,
488,
267,
291,
14,
14478,
10464,
275,
488,
339,
347,
15422,
8,
277,
304,
267,
862,
26,
288,
291,
14,
88,
53,
889,
5619,
14,
475,
17607,
342,
267,
871,
2186,
26,
288,
986,
288,
327,
886,
6548,
27,
339,
347,
1242,
2223,
6970,
8,
277,
12,
1242,
2390,
304,
267,
862,
26,
288,
291,
14,
78,
4665,
7801,
275,
1242,
2390,
14,
2081,
1304,
288,
291,
14,
78,
16411,
7801,
275,
1109,
8,
277,
14,
88,
5619,
1685,
14,
7801,
9,
288,
340,
291,
14,
78,
4665,
7801,
1137,
291,
14,
78,
16411,
7801,
26,
355,
291,
14,
5656,
1378,
7801,
342,
398,
871,
2186,
26,
288,
5190,
14,
1361,
63,
2804,
342,
339,
347,
663,
5619,
8516,
8,
277,
12,
4002,
461,
12,
4569,
12,
4057,
461,
12,
3421,
63,
88,
12,
267,
3421,
63,
57,
12,
3650,
12,
5174,
2681,
12,
2538,
12,
3462,
304,
267,
625,
79,
14,
15195,
8,
277,
14,
88,
5619,
1685,
12,
298,
21173,
6550,
401,
1467,
3666,
3697,
5866,
14,
25091,
63,
18219,
2617,
12,
8892,
16158,
5866,
14,
25091,
63,
13509,
12,
8892,
16158,
5866,
14,
25091,
63,
16207,
2617,
12,
355,
16158,
5866,
14,
25091,
63,
15717,
63,
56,
12,
355,
16158,
5866,
14,
25091,
63,
15717,
63,
57,
12,
355,
16158,
5866,
14,
25091,
63,
17988,
12,
8892,
16158,
5866,
14,
25091,
63,
10129,
10215,
12,
355,
16158,
5866,
14,
25091,
63,
19091,
12,
355,
16158,
5866,
14,
25091,
63,
11139,
395,
1467,
334,
1600,
461,
12,
4569,
12,
4057,
461,
12,
3421,
63,
88,
12,
3421,
63,
57,
12,
3650,
12,
8892,
5174,
2681,
12,
2538,
12,
3462,
1724,
420,
5493,
347,
663,
3863,
350,
1130,
23879,
8,
277,
12,
485,
66,
23879,
304,
267,
291,
14,
79,
3863,
350,
1130,
14,
13767,
12529,
275,
485,
66,
23879,
339,
347,
663,
3863,
350,
1130,
14175,
8,
277,
12,
330,
14175,
304,
267,
291,
14,
79,
3863,
350,
1130,
14,
14175,
275,
330,
14175,
339,
347,
365,
3863,
350,
1130,
14175,
8,
277,
304,
267,
862,
26,
288,
372,
2155,
8,
277,
14,
79,
3863,
350,
1130,
14,
14175,
9,
267,
871,
2186,
26,
288,
5190,
14,
1361,
63,
2804,
342,
288,
372,
756,
339,
347,
663,
5639,
3863,
350,
1130,
2081,
998,
8,
277,
12,
2870,
304,
267,
340,
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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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
] |
puzan/ansible
|
lib/ansible/modules/files/iso_extract.py
|
10
|
3657
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2013, Jeroen Hoekx <jeroen.hoekx@dsquare.be>
# (c) 2016, Matt Robinson <git@nerdoftheherd.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 = {'status': ['preview'],
'supported_by': 'core',
'version': '1.0'}
DOCUMENTATION = r'''
---
author:
- Jeroen Hoekx (@jhoekx)
- Matt Robinson (@ribbons)
module: iso_extract
short_description: Extract files from an ISO image.
description:
- This module mounts an iso image in a temporary directory and extracts
files from there to a given destination.
version_added: "2.3"
options:
image:
description:
- The ISO image to extract files from.
required: true
aliases: ['path', 'src']
dest:
description:
- The destination directory to extract files to.
required: true
files:
description:
- A list of files to extract from the image.
- Extracting directories does not work.
required: true
notes:
- Only the file hash (content) is taken into account for extracting files
from the ISO image.
'''
EXAMPLES = r'''
- name: Extract kernel and ramdisk from a LiveCD
iso_extract:
image: /tmp/rear-test.iso
dest: /tmp/virt-rear/
files:
- isolinux/kernel
- isolinux/initrd.cgz
'''
RETURN = r'''
#
'''
import os
import shutil
import tempfile
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
def main():
module = AnsibleModule(
argument_spec = dict(
image = dict(required=True, type='path', aliases=['path', 'src']),
dest = dict(required=True, type='path'),
files = dict(required=True, type='list'),
),
supports_check_mode = True,
)
image = module.params['image']
dest = module.params['dest']
files = module.params['files']
changed = False
if not os.path.exists(dest):
module.fail_json(msg='Directory "%s" does not exist' % dest)
if not os.path.exists(os.path.dirname(image)):
module.fail_json(msg='ISO image "%s" does not exist' % image)
tmp_dir = tempfile.mkdtemp()
rc, out, err = module.run_command('mount -o loop,ro "%s" "%s"' % (image, tmp_dir))
if rc != 0:
os.rmdir(tmp_dir)
module.fail_json(msg='Failed to mount ISO image "%s"' % image)
e = None
try:
for file in files:
tmp_src = os.path.join(tmp_dir, file)
src_hash = module.sha1(tmp_src)
dest_file = os.path.join(dest, os.path.basename(file))
if os.path.exists(dest_file):
dest_hash = module.sha1(dest_file)
else:
dest_hash = None
if src_hash != dest_hash:
if not module.check_mode:
shutil.copy(tmp_src, dest_file)
changed = True
finally:
module.run_command('umount "%s"' % tmp_dir)
os.rmdir(tmp_dir)
module.exit_json(changed=changed)
if __name__ == '__main__':
main()
|
gpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
3,
334,
67,
9,
6171,
12,
1603,
3478,
287,
28673,
5711,
88,
665,
74,
3478,
287,
14,
526,
5711,
88,
32,
795,
5937,
14,
1235,
30,
199,
3,
334,
67,
9,
7800,
12,
31653,
6848,
1393,
834,
665,
3187,
32,
1372,
16846,
1589,
2523,
68,
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,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
1018,
297,
490,
283,
1023,
356,
283,
17,
14,
16,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
2502,
26,
199,
13,
1603,
3478,
287,
28673,
5711,
88,
8593,
74,
526,
5711,
88,
9,
199,
13,
31653,
6848,
1393,
834,
8593,
322,
2501,
4654,
9,
199,
578,
26,
11601,
63,
5005,
199,
3612,
63,
1802,
26,
12892,
1584,
687,
376,
9055,
1834,
14,
199,
1802,
26,
199,
13,
961,
859,
10760,
83,
376,
11601,
1834,
315,
282,
7937,
2082,
436,
5536,
83,
523,
1584,
687,
2337,
370,
282,
1627,
5724,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
1419,
26,
523,
1834,
26,
272,
1369,
26,
272,
446,
710,
9055,
1834,
370,
5536,
1584,
687,
14,
272,
1415,
26,
2549,
272,
5481,
26,
788,
515,
297,
283,
2164,
418,
523,
2053,
26,
272,
1369,
26,
272,
446,
710,
5724,
2082,
370,
5536,
1584,
370,
14,
272,
1415,
26,
2549,
523,
1584,
26,
272,
1369,
26,
272,
446,
437,
769,
402,
1584,
370,
5536,
687,
314,
1834,
14,
272,
446,
12892,
316,
6602,
1630,
440,
1736,
14,
272,
1415,
26,
2549,
199,
5983,
26,
199,
13,
5972,
314,
570,
2631,
334,
1317,
9,
365,
9394,
1901,
2933,
367,
30137,
1584,
523,
687,
314,
9055,
1834,
14,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
12892,
5114,
436,
21394,
4032,
687,
282,
24683,
7695,
523,
11601,
63,
5005,
26,
272,
1834,
26,
1182,
2791,
15,
264,
285,
13,
396,
14,
4595,
272,
2053,
26,
1182,
2791,
15,
4549,
13,
264,
285,
15,
272,
1584,
26,
272,
446,
365,
393,
7226,
15,
4989,
272,
446,
365,
393,
7226,
15,
826,
6883,
14,
67,
6838,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
3,
199,
2344,
199,
199,
646,
747,
199,
646,
5145,
199,
646,
5549,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
647,
5819,
1194,
492,
664,
63,
1971,
199,
199,
318,
2446,
837,
272,
859,
275,
6953,
8,
267,
1423,
63,
1650,
275,
1211,
8,
288,
1834,
275,
1211,
8,
2427,
29,
549,
12,
730,
534,
515,
297,
5481,
2968,
515,
297,
283,
2164,
3815,
288,
2053,
275,
1211,
8,
2427,
29,
549,
12,
730,
534,
515,
659,
288,
1584,
275,
1211,
8,
2427,
29,
549,
12,
730,
534,
513,
659,
267,
2318,
267,
5171,
63,
1074,
63,
632,
275,
715,
12,
272,
776,
272,
1834,
275,
859,
14,
1162,
459,
1569,
418,
272,
2053,
275,
859,
14,
1162,
459,
2614,
418,
272,
1584,
275,
859,
14,
1162,
459,
1725,
418,
339,
2896,
275,
756,
339,
340,
440,
747,
14,
515,
14,
2444,
8,
2614,
304,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
6231,
2071,
83,
2,
1630,
440,
2187,
7,
450,
2053,
9,
339,
340,
440,
747,
14,
515,
14,
2444,
8,
736,
14,
515,
14,
3475,
8,
1569,
2298,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
7336,
1834,
2071,
83,
2,
1630,
440,
2187,
7,
450,
1834,
9,
339,
3529,
63,
694,
275,
5549,
14,
11983,
342,
272,
4819,
12,
734,
12,
2329,
275,
859,
14,
1065,
63,
1531,
360,
3956,
446,
79,
4438,
12,
293,
2071,
83,
2,
2071,
83,
4507,
450,
334,
1569,
12,
3529,
63,
694,
430,
272,
340,
4819,
1137,
378,
26,
267,
747,
14,
19405,
8,
2791,
63,
694,
9,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
4276,
370,
10760,
9055,
1834,
2071,
83,
4507,
450,
1834,
9,
339,
325,
275,
488,
272,
862,
26,
267,
367,
570,
315,
1584,
26,
288,
3529,
63,
2164,
275,
747,
14,
515,
14,
904,
8,
2791,
63,
694,
12,
570,
9,
288,
2928,
63,
2227,
275,
859,
14,
4835,
17,
8,
2791,
63,
2164,
9,
953,
2053,
63,
493,
275,
747,
14,
515,
14,
904,
8,
2614,
12,
747,
14,
515,
14,
4846,
8,
493,
430,
953,
340,
747,
14,
515,
14,
2444,
8,
2614,
63,
493,
304,
355,
2053,
63,
2227,
275,
859,
14,
4835,
17,
8,
2614,
63,
493,
9,
288,
587,
26,
355,
2053,
63,
2227,
275,
488,
953,
340,
2928,
63,
2227,
1137,
2053,
63,
2227,
26,
355,
340,
440,
859,
14,
1074,
63,
632,
26,
490,
5145,
14,
1574,
8,
2791,
63,
2164,
12,
2053,
63,
493,
9,
2234,
2896,
275,
715,
272,
3753,
26,
267,
859,
14,
1065,
63,
1531,
360,
453,
79,
638,
2071,
83,
4507,
450,
3529,
63,
694,
9,
267,
747,
14,
19405,
8,
2791,
63,
694,
9,
339,
859,
14,
2224,
63,
1001,
8,
2489,
29,
2489,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
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,
334,
67,
9,
6171,
12,
1603,
3478,
287,
28673,
5711,
88,
665,
74,
3478,
287,
14,
526,
5711,
88,
32,
795,
5937,
14,
1235,
30,
199,
3,
334,
67,
9,
7800,
12,
31653,
6848,
1393,
834,
665,
3187,
32,
1372,
16846,
1589,
2523,
68,
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,
1205,
356,
788,
7780,
995,
490,
283,
4946,
63,
991,
356,
283,
1018,
297,
490,
283,
1023,
356,
283,
17,
14,
16,
936,
199,
199,
8948,
275,
519,
2344,
199,
2595,
199,
2502,
26,
199,
13,
1603,
3478,
287,
28673,
5711,
88,
8593,
74,
526,
5711,
88,
9,
199,
13,
31653,
6848,
1393,
834,
8593,
322,
2501,
4654,
9,
199,
578,
26,
11601,
63,
5005,
199,
3612,
63,
1802,
26,
12892,
1584,
687,
376,
9055,
1834,
14,
199,
1802,
26,
199,
13,
961,
859,
10760,
83,
376,
11601,
1834,
315,
282,
7937,
2082,
436,
5536,
83,
523,
1584,
687,
2337,
370,
282,
1627,
5724,
14,
199,
1023,
63,
3270,
26,
298,
18,
14,
19,
2,
199,
1419,
26,
523,
1834,
26,
272,
1369,
26,
272,
446,
710,
9055,
1834,
370,
5536,
1584,
687,
14,
272,
1415,
26,
2549,
272,
5481,
26,
788,
515,
297,
283,
2164,
418,
523,
2053,
26,
272,
1369,
26,
272,
446,
710,
5724,
2082,
370,
5536,
1584,
370,
14,
272,
1415,
26,
2549,
523,
1584,
26,
272,
1369,
26,
272,
446,
437,
769,
402,
1584,
370,
5536,
687,
314,
1834,
14,
272,
446,
12892,
316,
6602,
1630,
440,
1736,
14,
272,
1415,
26,
2549,
199,
5983,
26,
199,
13,
5972,
314,
570,
2631,
334,
1317,
9,
365,
9394,
1901,
2933,
367,
30137,
1584,
523,
687,
314,
9055,
1834,
14,
199,
2344,
199,
199,
8918,
275,
519,
2344,
199,
13,
536,
26,
12892,
5114,
436,
21394,
4032,
687,
282,
24683,
7695,
523,
11601,
63,
5005,
26,
272,
1834,
26,
1182,
2791,
15,
264,
285,
13,
396,
14,
4595,
272,
2053,
26,
1182,
2791,
15,
4549,
13,
264,
285,
15,
272,
1584,
26,
272,
446,
365,
393,
7226,
15,
4989,
272,
446,
365,
393,
7226,
15,
826,
6883,
14,
67,
6838,
199,
2344,
199,
199,
9677,
275,
519,
2344,
199,
3,
199,
2344,
199,
199,
646,
747,
199,
646,
5145,
199,
646,
5549,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
504,
3242,
14,
578,
63,
1208,
14,
647,
5819,
1194,
492,
664,
63,
1971,
199,
199,
318,
2446,
837,
272,
859,
275,
6953,
8,
267,
1423,
63,
1650,
275,
1211,
8,
288,
1834,
275,
1211,
8,
2427,
29,
549,
12,
730,
534,
515,
297,
5481,
2968,
515,
297,
283,
2164,
3815,
288,
2053,
275,
1211,
8,
2427,
29,
549,
12,
730,
534,
515,
659,
288,
1584,
275,
1211,
8,
2427,
29,
549,
12,
730,
534,
513,
659,
267,
2318,
267,
5171,
63,
1074,
63,
632,
275,
715,
12,
272,
776,
272,
1834,
275,
859,
14,
1162,
459,
1569,
418,
272,
2053,
275,
859,
14,
1162,
459,
2614,
418,
272,
1584,
275,
859,
14,
1162,
459,
1725,
418,
339,
2896,
275,
756,
339,
340,
440,
747,
14,
515,
14,
2444,
8,
2614,
304,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
6231,
2071,
83,
2,
1630,
440,
2187,
7,
450,
2053,
9,
339,
340,
440,
747,
14,
515,
14,
2444,
8,
736,
14,
515,
14,
3475,
8,
1569,
2298,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
7336,
1834,
2071,
83,
2,
1630,
440,
2187,
7,
450,
1834,
9,
339,
3529,
63,
694,
275,
5549,
14,
11983,
342,
272,
4819,
12,
734,
12,
2329,
275,
859,
14,
1065,
63,
1531,
360,
3956,
446,
79,
4438,
12,
293,
2071,
83,
2,
2071,
83,
4507,
450,
334,
1569,
12,
3529,
63,
694,
430,
272,
340,
4819,
1137,
378,
26,
267,
747,
14,
19405,
8,
2791,
63,
694,
9,
267,
859,
14,
1633,
63,
1001,
8,
1328,
534,
4276,
370,
10760,
9055,
1834,
2071,
83,
4507,
450,
1834,
9,
339,
325,
275,
488,
272,
862,
26,
267,
367,
570,
315,
1584,
26,
288,
3529,
63,
2164,
275,
747,
14,
515,
14,
904,
8,
2791,
63,
694,
12,
570,
9,
288,
2928,
63,
2227,
275,
859,
14,
4835,
17,
8,
2791,
63,
2164,
9,
953,
2053,
63,
493,
275,
747,
14,
515,
14,
904,
8,
2614,
12,
747,
14,
515,
14,
4846,
8,
493,
430,
953,
340,
747,
14,
515,
14,
2444,
8,
2614,
63,
493,
304,
355,
2053,
63,
2227,
275,
859,
14,
4835,
17,
8,
2614,
63,
493,
9,
288,
587,
26,
355,
2053,
63,
2227,
275,
488,
953,
340,
2928,
63,
2227,
1137,
2053,
63,
2227,
26,
355,
340,
440,
859,
14,
1074,
63,
632,
26,
490,
5145,
14,
1574,
8,
2791,
63,
2164,
12,
2053,
63,
493,
9,
2234,
2896,
275,
715,
272,
3753,
26,
267,
859,
14,
1065,
63,
1531,
360,
453,
79,
638,
2071,
83,
4507,
450,
3529,
63,
694,
9,
267,
747,
14,
19405,
8,
2791,
63,
694,
9,
339,
859,
14,
2224,
63,
1001,
8,
2489,
29,
2489,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2446,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
CollabQ/CollabQ
|
.google_appengine/tools/bulkload_client.py
|
10
|
1938
|
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Convenience wrapper for starting bulkload_client.py"""
import os
import sys
sys.stderr.write("This version of bulkload_client.py has been deprecated; "
"please use the version at the root of your Google App "
"Engine SDK install.")
if not hasattr(sys, 'version_info'):
sys.stderr.write('Very old versions of Python are not supported. Please '
'use version 2.5 or greater.\n')
sys.exit(1)
version_tuple = tuple(sys.version_info[:2])
if version_tuple < (2, 4):
sys.stderr.write('Error: Python %d.%d is not supported. Please use '
'version 2.5 or greater.\n' % version_tuple)
sys.exit(1)
if version_tuple == (2, 4):
sys.stderr.write('Warning: Python 2.4 is not supported; this program may '
'break. Please use version 2.5 or greater.\n')
BULKLOAD_CLIENT_PATH = 'google/appengine/tools/bulkload_client.py'
DIR_PATH = os.path.abspath(os.path.dirname(
os.path.dirname(os.path.realpath(__file__))))
EXTRA_PATHS = [
DIR_PATH,
os.path.join(DIR_PATH, 'lib', 'django'),
os.path.join(DIR_PATH, 'lib', 'webob'),
os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'),
]
if __name__ == '__main__':
sys.path = EXTRA_PATHS + sys.path
script_path = os.path.join(DIR_PATH, BULKLOAD_CLIENT_PATH)
execfile(script_path, globals())
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
10219,
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,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
624,
714,
23329,
4975,
367,
6617,
13137,
912,
63,
1258,
14,
647,
624,
421,
199,
646,
747,
199,
646,
984,
199,
199,
1274,
14,
3083,
14,
952,
480,
2765,
1015,
402,
13137,
912,
63,
1258,
14,
647,
965,
2757,
5906,
27,
298,
326,
298,
27567,
675,
314,
1015,
737,
314,
1738,
402,
2195,
4475,
4693,
298,
326,
298,
8524,
15610,
3907,
2685,
199,
199,
692,
440,
2688,
8,
1274,
12,
283,
1023,
63,
815,
735,
523,
984,
14,
3083,
14,
952,
360,
54,
994,
2269,
5459,
402,
2018,
787,
440,
3748,
14,
7754,
283,
673,
283,
1180,
1015,
499,
14,
21,
503,
8932,
3134,
78,
358,
523,
984,
14,
2224,
8,
17,
9,
199,
1023,
63,
2960,
275,
2008,
8,
1274,
14,
1023,
63,
815,
1491,
18,
566,
199,
692,
1015,
63,
2960,
665,
334,
18,
12,
841,
304,
523,
984,
14,
3083,
14,
952,
360,
547,
26,
2018,
450,
68,
4111,
68,
365,
440,
3748,
14,
7754,
675,
283,
673,
283,
1023,
499,
14,
21,
503,
8932,
3134,
78,
7,
450,
1015,
63,
2960,
9,
523,
984,
14,
2224,
8,
17,
9,
199,
692,
1015,
63,
2960,
508,
334,
18,
12,
841,
304,
523,
984,
14,
3083,
14,
952,
360,
3849,
26,
2018,
499,
14,
20,
365,
440,
3748,
27,
642,
2240,
1443,
283,
673,
283,
4785,
14,
7754,
675,
1015,
499,
14,
21,
503,
8932,
3134,
78,
358,
199,
199,
34,
1293,
43,
7405,
63,
9901,
63,
3243,
275,
283,
3098,
15,
15358,
15,
2537,
15,
9377,
912,
63,
1258,
14,
647,
7,
199,
199,
3022,
63,
3243,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
2049,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
363,
7845,
199,
199,
18555,
63,
20202,
275,
359,
199,
19253,
63,
3243,
12,
199,
747,
14,
515,
14,
904,
8,
3022,
63,
3243,
12,
283,
773,
297,
283,
1176,
659,
199,
747,
14,
515,
14,
904,
8,
3022,
63,
3243,
12,
283,
773,
297,
283,
24057,
659,
199,
747,
14,
515,
14,
904,
8,
3022,
63,
3243,
12,
283,
773,
297,
283,
5963,
297,
283,
773,
659,
199,
61,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
984,
14,
515,
275,
3651,
13954,
63,
20202,
435,
984,
14,
515,
523,
2884,
63,
515,
275,
747,
14,
515,
14,
904,
8,
3022,
63,
3243,
12,
699,
1293,
43,
7405,
63,
9901,
63,
3243,
9,
523,
22711,
8,
1579,
63,
515,
12,
7992,
1012,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
10219,
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,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
199,
624,
714,
23329,
4975,
367,
6617,
13137,
912,
63,
1258,
14,
647,
624,
421,
199,
646,
747,
199,
646,
984,
199,
199,
1274,
14,
3083,
14,
952,
480,
2765,
1015,
402,
13137,
912,
63,
1258,
14,
647,
965,
2757,
5906,
27,
298,
326,
298,
27567,
675,
314,
1015,
737,
314,
1738,
402,
2195,
4475,
4693,
298,
326,
298,
8524,
15610,
3907,
2685,
199,
199,
692,
440,
2688,
8,
1274,
12,
283,
1023,
63,
815,
735,
523,
984,
14,
3083,
14,
952,
360,
54,
994,
2269,
5459,
402,
2018,
787,
440,
3748,
14,
7754,
283,
673,
283,
1180,
1015,
499,
14,
21,
503,
8932,
3134,
78,
358,
523,
984,
14,
2224,
8,
17,
9,
199,
1023,
63,
2960,
275,
2008,
8,
1274,
14,
1023,
63,
815,
1491,
18,
566,
199,
692,
1015,
63,
2960,
665,
334,
18,
12,
841,
304,
523,
984,
14,
3083,
14,
952,
360,
547,
26,
2018,
450,
68,
4111,
68,
365,
440,
3748,
14,
7754,
675,
283,
673,
283,
1023,
499,
14,
21,
503,
8932,
3134,
78,
7,
450,
1015,
63,
2960,
9,
523,
984,
14,
2224,
8,
17,
9,
199,
692,
1015,
63,
2960,
508,
334,
18,
12,
841,
304,
523,
984,
14,
3083,
14,
952,
360,
3849,
26,
2018,
499,
14,
20,
365,
440,
3748,
27,
642,
2240,
1443,
283,
673,
283,
4785,
14,
7754,
675,
1015,
499,
14,
21,
503,
8932,
3134,
78,
358,
199,
199,
34,
1293,
43,
7405,
63,
9901,
63,
3243,
275,
283,
3098,
15,
15358,
15,
2537,
15,
9377,
912,
63,
1258,
14,
647,
7,
199,
199,
3022,
63,
3243,
275,
747,
14,
515,
14,
4832,
8,
736,
14,
515,
14,
3475,
8,
2049,
747,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
363,
7845,
199,
199,
18555,
63,
20202,
275,
359,
199,
19253,
63,
3243,
12,
199,
747,
14,
515,
14,
904,
8,
3022,
63,
3243,
12,
283,
773,
297,
283,
1176,
659,
199,
747,
14,
515,
14,
904,
8,
3022,
63,
3243,
12,
283,
773,
297,
283,
24057,
659,
199,
747,
14,
515,
14,
904,
8,
3022,
63,
3243,
12,
283,
773,
297,
283,
5963,
297,
283,
773,
659,
199,
61,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
523,
984,
14,
515,
275,
3651,
13954,
63,
20202,
435,
984,
14,
515,
523,
2884,
63,
515,
275,
747,
14,
515,
14,
904,
8,
3022,
63,
3243,
12,
699,
1293,
43,
7405,
63,
9901,
63,
3243,
9,
523,
22711,
8,
1579,
63,
515,
12,
7992,
1012,
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,
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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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
Dino0631/RedRain-Bot
|
lib/multidict/__init__.py
|
2
|
1162
|
"""Multidict implementation.
HTTP Headers and URL query string require specific data structure:
multidict. It behaves mostly like a dict but it can have
several values for the same key.
"""
import os
__all__ = ('MultiDictProxy', 'CIMultiDictProxy',
'MultiDict', 'CIMultiDict', 'upstr', 'istr')
__version__ = '3.1.0'
if bool(os.environ.get('MULTIDICT_NO_EXTENSIONS')):
from ._multidict_py import (MultiDictProxy,
CIMultiDictProxy,
MultiDict,
CIMultiDict,
upstr, istr)
else:
try:
from ._multidict import (MultiDictProxy,
CIMultiDictProxy,
MultiDict,
CIMultiDict,
upstr, istr)
except ImportError: # pragma: no cover
from ._multidict_py import (MultiDictProxy,
CIMultiDictProxy,
MultiDict,
CIMultiDict,
upstr, istr)
|
gpl-3.0
|
[
624,
3947,
807,
4514,
14,
199,
199,
2856,
21391,
436,
2851,
1827,
1059,
4409,
2488,
666,
5523,
26,
199,
3029,
807,
14,
2779,
25113,
19762,
2839,
282,
1211,
1325,
652,
883,
1172,
199,
261,
422,
279,
1338,
367,
314,
2011,
790,
14,
199,
624,
199,
199,
646,
747,
199,
199,
363,
452,
363,
275,
661,
21365,
4936,
297,
283,
35,
1469,
1141,
2141,
4936,
297,
1779,
283,
21365,
297,
283,
35,
1469,
1141,
2141,
297,
283,
384,
495,
297,
283,
3075,
358,
199,
199,
363,
1023,
363,
275,
283,
19,
14,
17,
14,
16,
7,
421,
199,
692,
2155,
8,
736,
14,
2314,
14,
362,
360,
8203,
998,
6196,
63,
2826,
63,
18451,
8109,
272,
687,
13653,
3029,
807,
63,
647,
492,
334,
21365,
4936,
12,
1816,
445,
1469,
1141,
2141,
4936,
12,
1816,
29393,
12,
1816,
445,
1469,
1141,
2141,
12,
1816,
1536,
495,
12,
284,
495,
9,
199,
2836,
26,
272,
862,
26,
267,
687,
13653,
3029,
807,
492,
334,
21365,
4936,
12,
639,
445,
1469,
1141,
2141,
4936,
12,
639,
29393,
12,
639,
445,
1469,
1141,
2141,
12,
639,
1536,
495,
12,
284,
495,
9,
272,
871,
3545,
26,
221,
327,
11942,
26,
949,
8486,
267,
687,
13653,
3029,
807,
63,
647,
492,
334,
21365,
4936,
12,
2511,
445,
1469,
1141,
2141,
4936,
12,
2511,
29393,
12,
2511,
445,
1469,
1141,
2141,
12,
2511,
1536,
495,
12,
284,
495,
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
] |
[
3947,
807,
4514,
14,
199,
199,
2856,
21391,
436,
2851,
1827,
1059,
4409,
2488,
666,
5523,
26,
199,
3029,
807,
14,
2779,
25113,
19762,
2839,
282,
1211,
1325,
652,
883,
1172,
199,
261,
422,
279,
1338,
367,
314,
2011,
790,
14,
199,
624,
199,
199,
646,
747,
199,
199,
363,
452,
363,
275,
661,
21365,
4936,
297,
283,
35,
1469,
1141,
2141,
4936,
297,
1779,
283,
21365,
297,
283,
35,
1469,
1141,
2141,
297,
283,
384,
495,
297,
283,
3075,
358,
199,
199,
363,
1023,
363,
275,
283,
19,
14,
17,
14,
16,
7,
421,
199,
692,
2155,
8,
736,
14,
2314,
14,
362,
360,
8203,
998,
6196,
63,
2826,
63,
18451,
8109,
272,
687,
13653,
3029,
807,
63,
647,
492,
334,
21365,
4936,
12,
1816,
445,
1469,
1141,
2141,
4936,
12,
1816,
29393,
12,
1816,
445,
1469,
1141,
2141,
12,
1816,
1536,
495,
12,
284,
495,
9,
199,
2836,
26,
272,
862,
26,
267,
687,
13653,
3029,
807,
492,
334,
21365,
4936,
12,
639,
445,
1469,
1141,
2141,
4936,
12,
639,
29393,
12,
639,
445,
1469,
1141,
2141,
12,
639,
1536,
495,
12,
284,
495,
9,
272,
871,
3545,
26,
221,
327,
11942,
26,
949,
8486,
267,
687,
13653,
3029,
807,
63,
647,
492,
334,
21365,
4936,
12,
2511,
445,
1469,
1141,
2141,
4936,
12,
2511,
29393,
12,
2511,
445,
1469,
1141,
2141,
12,
2511,
1536,
495,
12,
284,
495,
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,
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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
nederhoed/bitstamp-python-client
|
test/trading_client.py
|
1
|
2123
|
__author__ = 'kmadac'
import unittest
import bitstamp.client
import os
class bitstamp_trading_TestCase(unittest.TestCase):
client = bitstamp.client.trading(os.environ['bs_user'], os.environ['bs_key'], os.environ['bs_secret'])
def test_account_ballance(self):
account_balance = self.client.account_balance()
print(account_balance)
self.assertIsInstance(account_balance, dict)
def test_user_transactions(self):
user_transactions = self.client.user_transactions()
print(user_transactions)
self.assertIsInstance(user_transactions, list)
def test_open_orders(self):
open_orders = self.client.open_orders()
print(open_orders)
self.assertIsInstance(open_orders, list)
def test_bitcoin_deposit_address(self):
bitcoin_deposit_address = self.client.bitcoin_deposit_address()
print(bitcoin_deposit_address)
self.assertEquals(bitcoin_deposit_address, u'"1ARfAEqUzAtbnuJLUxm5KKfDJqrGi27hwA"')
def test_buy_cancel_order(self):
order_buy = self.client.buy_limit_order(1, 10)
print(order_buy)
self.assertIn('id', order_buy)
order_id = order_buy['id']
cancel_order = self.client.cancel_order(order_id)
print(cancel_order)
self.assertEquals(cancel_order, True)
def test_sell_cancel_order(self):
order_sell = self.client.sell_limit_order(1, 500)
print (order_sell)
self.assertIn('id', order_sell)
order_id = order_sell['id']
cancel_order = self.client.cancel_order(order_id)
print (cancel_order)
self.assertEquals(cancel_order, True)
def test_withdrawal_requests(self):
withdrawal_requests = self.client.withdrawal_requests()
print(withdrawal_requests)
self.assertIsInstance(withdrawal_requests, list)
def test_unconfirmed_bitcoin_deposits(self):
unconfirmed_deposits = self.client.unconfirmed_bitcoin_deposits()
print(unconfirmed_deposits)
self.assertIsInstance(unconfirmed_deposits, list)
if __name__ == '__main__':
unittest.main()
|
mit
|
[
363,
2502,
363,
275,
283,
14595,
350,
645,
7,
199,
199,
646,
2882,
199,
646,
4546,
2359,
14,
1258,
199,
646,
747,
421,
199,
533,
4546,
2359,
63,
1239,
1098,
63,
1746,
8,
2796,
14,
1746,
304,
272,
1890,
275,
4546,
2359,
14,
1258,
14,
1239,
1098,
8,
736,
14,
2314,
459,
1533,
63,
751,
995,
747,
14,
2314,
459,
1533,
63,
498,
995,
747,
14,
2314,
459,
1533,
63,
4731,
1105,
339,
347,
511,
63,
2048,
63,
8571,
554,
8,
277,
304,
267,
2933,
63,
7358,
275,
291,
14,
1258,
14,
2048,
63,
7358,
342,
267,
870,
8,
2048,
63,
7358,
9,
267,
291,
14,
6926,
8,
2048,
63,
7358,
12,
1211,
9,
339,
347,
511,
63,
751,
63,
13754,
8,
277,
304,
267,
922,
63,
13754,
275,
291,
14,
1258,
14,
751,
63,
13754,
342,
267,
870,
8,
751,
63,
13754,
9,
267,
291,
14,
6926,
8,
751,
63,
13754,
12,
769,
9,
339,
347,
511,
63,
1490,
63,
14387,
8,
277,
304,
267,
1551,
63,
14387,
275,
291,
14,
1258,
14,
1490,
63,
14387,
342,
267,
870,
8,
1490,
63,
14387,
9,
267,
291,
14,
6926,
8,
1490,
63,
14387,
12,
769,
9,
339,
347,
511,
63,
22816,
63,
271,
21759,
63,
1562,
8,
277,
304,
267,
27214,
63,
271,
21759,
63,
1562,
275,
291,
14,
1258,
14,
22816,
63,
271,
21759,
63,
1562,
342,
267,
870,
8,
22816,
63,
271,
21759,
63,
1562,
9,
267,
291,
14,
2947,
8,
22816,
63,
271,
21759,
63,
1562,
12,
399,
4065,
17,
689,
70,
12500,
81,
53,
90,
1271,
66,
4850,
42,
20237,
10198,
21,
43,
26466,
17239,
16596,
30815,
1465,
8090,
33,
9008,
339,
347,
511,
63,
31240,
63,
6406,
63,
1648,
8,
277,
304,
267,
1865,
63,
31240,
275,
291,
14,
1258,
14,
31240,
63,
3097,
63,
1648,
8,
17,
12,
1616,
9,
267,
870,
8,
1648,
63,
31240,
9,
267,
291,
14,
4080,
360,
344,
297,
1865,
63,
31240,
9,
267,
1865,
63,
344,
275,
1865,
63,
31240,
459,
344,
418,
267,
9311,
63,
1648,
275,
291,
14,
1258,
14,
6406,
63,
1648,
8,
1648,
63,
344,
9,
267,
870,
8,
6406,
63,
1648,
9,
267,
291,
14,
2947,
8,
6406,
63,
1648,
12,
715,
9,
339,
347,
511,
63,
23235,
63,
6406,
63,
1648,
8,
277,
304,
267,
1865,
63,
23235,
275,
291,
14,
1258,
14,
23235,
63,
3097,
63,
1648,
8,
17,
12,
6891,
9,
267,
870,
334,
1648,
63,
23235,
9,
267,
291,
14,
4080,
360,
344,
297,
1865,
63,
23235,
9,
267,
1865,
63,
344,
275,
1865,
63,
23235,
459,
344,
418,
267,
9311,
63,
1648,
275,
291,
14,
1258,
14,
6406,
63,
1648,
8,
1648,
63,
344,
9,
267,
870,
334,
6406,
63,
1648,
9,
267,
291,
14,
2947,
8,
6406,
63,
1648,
12,
715,
9,
339,
347,
511,
63,
1045,
5485,
279,
63,
6615,
8,
277,
304,
267,
543,
5485,
279,
63,
6615,
275,
291,
14,
1258,
14,
1045,
5485,
279,
63,
6615,
342,
267,
870,
8,
1045,
5485,
279,
63,
6615,
9,
267,
291,
14,
6926,
8,
1045,
5485,
279,
63,
6615,
12,
769,
9,
339,
347,
511,
63,
324,
16391,
63,
22816,
63,
271,
555,
30066,
8,
277,
304,
267,
625,
16391,
63,
271,
555,
30066,
275,
291,
14,
1258,
14,
324,
16391,
63,
22816,
63,
271,
555,
30066,
342,
267,
870,
8,
324,
16391,
63,
271,
555,
30066,
9,
267,
291,
14,
6926,
8,
324,
16391,
63,
271,
555,
30066,
12,
769,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2502,
363,
275,
283,
14595,
350,
645,
7,
199,
199,
646,
2882,
199,
646,
4546,
2359,
14,
1258,
199,
646,
747,
421,
199,
533,
4546,
2359,
63,
1239,
1098,
63,
1746,
8,
2796,
14,
1746,
304,
272,
1890,
275,
4546,
2359,
14,
1258,
14,
1239,
1098,
8,
736,
14,
2314,
459,
1533,
63,
751,
995,
747,
14,
2314,
459,
1533,
63,
498,
995,
747,
14,
2314,
459,
1533,
63,
4731,
1105,
339,
347,
511,
63,
2048,
63,
8571,
554,
8,
277,
304,
267,
2933,
63,
7358,
275,
291,
14,
1258,
14,
2048,
63,
7358,
342,
267,
870,
8,
2048,
63,
7358,
9,
267,
291,
14,
6926,
8,
2048,
63,
7358,
12,
1211,
9,
339,
347,
511,
63,
751,
63,
13754,
8,
277,
304,
267,
922,
63,
13754,
275,
291,
14,
1258,
14,
751,
63,
13754,
342,
267,
870,
8,
751,
63,
13754,
9,
267,
291,
14,
6926,
8,
751,
63,
13754,
12,
769,
9,
339,
347,
511,
63,
1490,
63,
14387,
8,
277,
304,
267,
1551,
63,
14387,
275,
291,
14,
1258,
14,
1490,
63,
14387,
342,
267,
870,
8,
1490,
63,
14387,
9,
267,
291,
14,
6926,
8,
1490,
63,
14387,
12,
769,
9,
339,
347,
511,
63,
22816,
63,
271,
21759,
63,
1562,
8,
277,
304,
267,
27214,
63,
271,
21759,
63,
1562,
275,
291,
14,
1258,
14,
22816,
63,
271,
21759,
63,
1562,
342,
267,
870,
8,
22816,
63,
271,
21759,
63,
1562,
9,
267,
291,
14,
2947,
8,
22816,
63,
271,
21759,
63,
1562,
12,
399,
4065,
17,
689,
70,
12500,
81,
53,
90,
1271,
66,
4850,
42,
20237,
10198,
21,
43,
26466,
17239,
16596,
30815,
1465,
8090,
33,
9008,
339,
347,
511,
63,
31240,
63,
6406,
63,
1648,
8,
277,
304,
267,
1865,
63,
31240,
275,
291,
14,
1258,
14,
31240,
63,
3097,
63,
1648,
8,
17,
12,
1616,
9,
267,
870,
8,
1648,
63,
31240,
9,
267,
291,
14,
4080,
360,
344,
297,
1865,
63,
31240,
9,
267,
1865,
63,
344,
275,
1865,
63,
31240,
459,
344,
418,
267,
9311,
63,
1648,
275,
291,
14,
1258,
14,
6406,
63,
1648,
8,
1648,
63,
344,
9,
267,
870,
8,
6406,
63,
1648,
9,
267,
291,
14,
2947,
8,
6406,
63,
1648,
12,
715,
9,
339,
347,
511,
63,
23235,
63,
6406,
63,
1648,
8,
277,
304,
267,
1865,
63,
23235,
275,
291,
14,
1258,
14,
23235,
63,
3097,
63,
1648,
8,
17,
12,
6891,
9,
267,
870,
334,
1648,
63,
23235,
9,
267,
291,
14,
4080,
360,
344,
297,
1865,
63,
23235,
9,
267,
1865,
63,
344,
275,
1865,
63,
23235,
459,
344,
418,
267,
9311,
63,
1648,
275,
291,
14,
1258,
14,
6406,
63,
1648,
8,
1648,
63,
344,
9,
267,
870,
334,
6406,
63,
1648,
9,
267,
291,
14,
2947,
8,
6406,
63,
1648,
12,
715,
9,
339,
347,
511,
63,
1045,
5485,
279,
63,
6615,
8,
277,
304,
267,
543,
5485,
279,
63,
6615,
275,
291,
14,
1258,
14,
1045,
5485,
279,
63,
6615,
342,
267,
870,
8,
1045,
5485,
279,
63,
6615,
9,
267,
291,
14,
6926,
8,
1045,
5485,
279,
63,
6615,
12,
769,
9,
339,
347,
511,
63,
324,
16391,
63,
22816,
63,
271,
555,
30066,
8,
277,
304,
267,
625,
16391,
63,
271,
555,
30066,
275,
291,
14,
1258,
14,
324,
16391,
63,
22816,
63,
271,
555,
30066,
342,
267,
870,
8,
324,
16391,
63,
271,
555,
30066,
9,
267,
291,
14,
6926,
8,
324,
16391,
63,
271,
555,
30066,
12,
769,
9,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
2882,
14,
973,
342,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,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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
] |
wayneclancy/creepercoin
|
contrib/bitrpc/bitrpc.py
|
1
|
7844
|
from jsonrpc import ServiceProxy
import sys
import string
# ===== BEGIN USER SETTINGS =====
# if you do not set these you will be prompted for a password for every command
rpcuser = ""
rpcpass = ""
# ====== END USER SETTINGS ======
if rpcpass == "":
access = ServiceProxy("http://127.0.0.1:9451")
else:
access = ServiceProxy("http://"+rpcuser+":"+rpcpass+"@127.0.0.1:9451")
cmd = sys.argv[1].lower()
if cmd == "backupwallet":
try:
path = raw_input("Enter destination path/filename: ")
print access.backupwallet(path)
except:
print "\n---An error occurred---\n"
elif cmd == "getaccount":
try:
addr = raw_input("Enter a Creepercoin address: ")
print access.getaccount(addr)
except:
print "\n---An error occurred---\n"
elif cmd == "getaccountaddress":
try:
acct = raw_input("Enter an account name: ")
print access.getaccountaddress(acct)
except:
print "\n---An error occurred---\n"
elif cmd == "getaddressesbyaccount":
try:
acct = raw_input("Enter an account name: ")
print access.getaddressesbyaccount(acct)
except:
print "\n---An error occurred---\n"
elif cmd == "getbalance":
try:
acct = raw_input("Enter an account (optional): ")
mc = raw_input("Minimum confirmations (optional): ")
try:
print access.getbalance(acct, mc)
except:
print access.getbalance()
except:
print "\n---An error occurred---\n"
elif cmd == "getblockbycount":
try:
height = raw_input("Height: ")
print access.getblockbycount(height)
except:
print "\n---An error occurred---\n"
elif cmd == "getblockcount":
try:
print access.getblockcount()
except:
print "\n---An error occurred---\n"
elif cmd == "getblocknumber":
try:
print access.getblocknumber()
except:
print "\n---An error occurred---\n"
elif cmd == "getconnectioncount":
try:
print access.getconnectioncount()
except:
print "\n---An error occurred---\n"
elif cmd == "getdifficulty":
try:
print access.getdifficulty()
except:
print "\n---An error occurred---\n"
elif cmd == "getgenerate":
try:
print access.getgenerate()
except:
print "\n---An error occurred---\n"
elif cmd == "gethashespersec":
try:
print access.gethashespersec()
except:
print "\n---An error occurred---\n"
elif cmd == "getinfo":
try:
print access.getinfo()
except:
print "\n---An error occurred---\n"
elif cmd == "getnewaddress":
try:
acct = raw_input("Enter an account name: ")
try:
print access.getnewaddress(acct)
except:
print access.getnewaddress()
except:
print "\n---An error occurred---\n"
elif cmd == "getreceivedbyaccount":
try:
acct = raw_input("Enter an account (optional): ")
mc = raw_input("Minimum confirmations (optional): ")
try:
print access.getreceivedbyaccount(acct, mc)
except:
print access.getreceivedbyaccount()
except:
print "\n---An error occurred---\n"
elif cmd == "getreceivedbyaddress":
try:
addr = raw_input("Enter a Creepercoin address (optional): ")
mc = raw_input("Minimum confirmations (optional): ")
try:
print access.getreceivedbyaddress(addr, mc)
except:
print access.getreceivedbyaddress()
except:
print "\n---An error occurred---\n"
elif cmd == "gettransaction":
try:
txid = raw_input("Enter a transaction ID: ")
print access.gettransaction(txid)
except:
print "\n---An error occurred---\n"
elif cmd == "getwork":
try:
data = raw_input("Data (optional): ")
try:
print access.gettransaction(data)
except:
print access.gettransaction()
except:
print "\n---An error occurred---\n"
elif cmd == "help":
try:
cmd = raw_input("Command (optional): ")
try:
print access.help(cmd)
except:
print access.help()
except:
print "\n---An error occurred---\n"
elif cmd == "listaccounts":
try:
mc = raw_input("Minimum confirmations (optional): ")
try:
print access.listaccounts(mc)
except:
print access.listaccounts()
except:
print "\n---An error occurred---\n"
elif cmd == "listreceivedbyaccount":
try:
mc = raw_input("Minimum confirmations (optional): ")
incemp = raw_input("Include empty? (true/false, optional): ")
try:
print access.listreceivedbyaccount(mc, incemp)
except:
print access.listreceivedbyaccount()
except:
print "\n---An error occurred---\n"
elif cmd == "listreceivedbyaddress":
try:
mc = raw_input("Minimum confirmations (optional): ")
incemp = raw_input("Include empty? (true/false, optional): ")
try:
print access.listreceivedbyaddress(mc, incemp)
except:
print access.listreceivedbyaddress()
except:
print "\n---An error occurred---\n"
elif cmd == "listtransactions":
try:
acct = raw_input("Account (optional): ")
count = raw_input("Number of transactions (optional): ")
frm = raw_input("Skip (optional):")
try:
print access.listtransactions(acct, count, frm)
except:
print access.listtransactions()
except:
print "\n---An error occurred---\n"
elif cmd == "move":
try:
frm = raw_input("From: ")
to = raw_input("To: ")
amt = raw_input("Amount:")
mc = raw_input("Minimum confirmations (optional): ")
comment = raw_input("Comment (optional): ")
try:
print access.move(frm, to, amt, mc, comment)
except:
print access.move(frm, to, amt)
except:
print "\n---An error occurred---\n"
elif cmd == "sendfrom":
try:
frm = raw_input("From: ")
to = raw_input("To: ")
amt = raw_input("Amount:")
mc = raw_input("Minimum confirmations (optional): ")
comment = raw_input("Comment (optional): ")
commentto = raw_input("Comment-to (optional): ")
try:
print access.sendfrom(frm, to, amt, mc, comment, commentto)
except:
print access.sendfrom(frm, to, amt)
except:
print "\n---An error occurred---\n"
elif cmd == "sendmany":
try:
frm = raw_input("From: ")
to = raw_input("To (in format address1:amount1,address2:amount2,...): ")
mc = raw_input("Minimum confirmations (optional): ")
comment = raw_input("Comment (optional): ")
try:
print access.sendmany(frm,to,mc,comment)
except:
print access.sendmany(frm,to)
except:
print "\n---An error occurred---\n"
elif cmd == "sendtoaddress":
try:
to = raw_input("To (in format address1:amount1,address2:amount2,...): ")
amt = raw_input("Amount:")
comment = raw_input("Comment (optional): ")
commentto = raw_input("Comment-to (optional): ")
try:
print access.sendtoaddress(to,amt,comment,commentto)
except:
print access.sendtoaddress(to,amt)
except:
print "\n---An error occurred---\n"
elif cmd == "setaccount":
try:
addr = raw_input("Address: ")
acct = raw_input("Account:")
print access.setaccount(addr,acct)
except:
print "\n---An error occurred---\n"
elif cmd == "setgenerate":
try:
gen= raw_input("Generate? (true/false): ")
cpus = raw_input("Max processors/cores (-1 for unlimited, optional):")
try:
print access.setgenerate(gen, cpus)
except:
print access.setgenerate(gen)
except:
print "\n---An error occurred---\n"
elif cmd == "settxfee":
try:
amt = raw_input("Amount:")
print access.settxfee(amt)
except:
print "\n---An error occurred---\n"
elif cmd == "stop":
try:
print access.stop()
except:
print "\n---An error occurred---\n"
elif cmd == "validateaddress":
try:
addr = raw_input("Address: ")
print access.validateaddress(addr)
except:
print "\n---An error occurred---\n"
elif cmd == "walletpassphrase":
try:
pwd = raw_input("Enter wallet passphrase: ")
access.walletpassphrase(pwd, 60)
print "\n---Wallet unlocked---\n"
except:
print "\n---An error occurred---\n"
elif cmd == "walletpassphrasechange":
try:
pwd = raw_input("Enter old wallet passphrase: ")
pwd2 = raw_input("Enter new wallet passphrase: ")
access.walletpassphrasechange(pwd, pwd2)
print
print "\n---Passphrase changed---\n"
except:
print
print "\n---An error occurred---\n"
print
else:
print "Command not found or not supported"
|
mit
|
[
504,
2022,
4354,
492,
7591,
4936,
199,
646,
984,
199,
646,
1059,
199,
199,
3,
9310,
16427,
13044,
11543,
52,
3881,
9310,
199,
3,
340,
1265,
886,
440,
663,
3520,
1265,
911,
506,
21652,
471,
367,
282,
2505,
367,
4036,
1414,
199,
4354,
751,
275,
3087,
199,
4354,
1529,
275,
3087,
199,
3,
9310,
29,
7729,
13044,
11543,
52,
3881,
9310,
29,
421,
199,
692,
8985,
1529,
508,
10812,
199,
198,
2732,
275,
7591,
4936,
480,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
25,
24723,
531,
199,
2836,
26,
199,
198,
2732,
275,
7591,
4936,
480,
1014,
921,
7709,
4354,
751,
11,
5122,
11,
4354,
1529,
5207,
32,
4195,
14,
16,
14,
16,
14,
17,
26,
25,
24723,
531,
199,
1760,
275,
984,
14,
3020,
59,
17,
1055,
2325,
342,
199,
199,
692,
2088,
508,
298,
5751,
13892,
582,
199,
198,
893,
26,
507,
198,
515,
275,
3066,
63,
1210,
480,
8468,
5724,
931,
15,
1501,
26,
6099,
507,
198,
1361,
2879,
14,
5751,
13892,
8,
515,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
2048,
582,
199,
198,
893,
26,
507,
198,
2697,
275,
3066,
63,
1210,
480,
8468,
282,
445,
850,
529,
9061,
2287,
26,
6099,
507,
198,
1361,
2879,
14,
362,
2048,
8,
2697,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
2048,
1562,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
536,
26,
6099,
507,
198,
1361,
2879,
14,
362,
2048,
1562,
8,
23015,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
7423,
991,
2048,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
536,
26,
6099,
507,
198,
1361,
2879,
14,
362,
7423,
991,
2048,
8,
23015,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
29213,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
334,
4144,
304,
6099,
507,
198,
5466,
275,
3066,
63,
1210,
480,
12092,
406,
27389,
334,
4144,
304,
6099,
507,
198,
893,
26,
686,
198,
1361,
2879,
14,
29213,
8,
23015,
12,
16377,
9,
507,
198,
2590,
26,
686,
198,
1361,
2879,
14,
29213,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
17785,
991,
835,
582,
199,
198,
893,
26,
507,
198,
3333,
275,
3066,
63,
1210,
480,
8436,
26,
6099,
507,
198,
1361,
2879,
14,
17785,
991,
835,
8,
3333,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
30710,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
30710,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
17785,
1955,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
17785,
1955,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
2105,
835,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
362,
2105,
835,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
29801,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
362,
29801,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
4208,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
362,
4208,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
303,
273,
9030,
529,
3321,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
303,
273,
9030,
529,
3321,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
32286,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
32286,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
21102,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
536,
26,
6099,
507,
198,
893,
26,
686,
198,
1361,
2879,
14,
21102,
8,
23015,
9,
507,
198,
2590,
26,
686,
198,
1361,
2879,
14,
21102,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
30404,
2048,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
334,
4144,
304,
6099,
507,
198,
5466,
275,
3066,
63,
1210,
480,
12092,
406,
27389,
334,
4144,
304,
6099,
507,
198,
893,
26,
686,
198,
1361,
2879,
14,
362,
30404,
2048,
8,
23015,
12,
16377,
9,
507,
198,
2590,
26,
686,
198,
1361,
2879,
14,
362,
30404,
2048,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
30404,
1562,
582,
199,
198,
893,
26,
507,
198,
2697,
275,
3066,
63,
1210,
480,
8468,
282,
445,
850,
529,
9061,
2287,
334,
4144,
304,
6099,
507,
198,
5466,
275,
3066,
63,
1210,
480,
12092,
406,
27389,
334,
4144,
304,
6099,
507,
198,
893,
26,
686,
198,
1361,
2879,
14,
362,
30404,
1562,
8,
2697,
12,
16377,
9,
507,
198,
2590,
26,
686,
198,
1361,
2879,
14,
362,
30404,
1562,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
5945,
582,
199,
198,
893,
26,
507,
198,
14113,
275,
3066,
63,
1210
] |
[
2022,
4354,
492,
7591,
4936,
199,
646,
984,
199,
646,
1059,
199,
199,
3,
9310,
16427,
13044,
11543,
52,
3881,
9310,
199,
3,
340,
1265,
886,
440,
663,
3520,
1265,
911,
506,
21652,
471,
367,
282,
2505,
367,
4036,
1414,
199,
4354,
751,
275,
3087,
199,
4354,
1529,
275,
3087,
199,
3,
9310,
29,
7729,
13044,
11543,
52,
3881,
9310,
29,
421,
199,
692,
8985,
1529,
508,
10812,
199,
198,
2732,
275,
7591,
4936,
480,
1014,
921,
4195,
14,
16,
14,
16,
14,
17,
26,
25,
24723,
531,
199,
2836,
26,
199,
198,
2732,
275,
7591,
4936,
480,
1014,
921,
7709,
4354,
751,
11,
5122,
11,
4354,
1529,
5207,
32,
4195,
14,
16,
14,
16,
14,
17,
26,
25,
24723,
531,
199,
1760,
275,
984,
14,
3020,
59,
17,
1055,
2325,
342,
199,
199,
692,
2088,
508,
298,
5751,
13892,
582,
199,
198,
893,
26,
507,
198,
515,
275,
3066,
63,
1210,
480,
8468,
5724,
931,
15,
1501,
26,
6099,
507,
198,
1361,
2879,
14,
5751,
13892,
8,
515,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
2048,
582,
199,
198,
893,
26,
507,
198,
2697,
275,
3066,
63,
1210,
480,
8468,
282,
445,
850,
529,
9061,
2287,
26,
6099,
507,
198,
1361,
2879,
14,
362,
2048,
8,
2697,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
2048,
1562,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
536,
26,
6099,
507,
198,
1361,
2879,
14,
362,
2048,
1562,
8,
23015,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
7423,
991,
2048,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
536,
26,
6099,
507,
198,
1361,
2879,
14,
362,
7423,
991,
2048,
8,
23015,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
29213,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
334,
4144,
304,
6099,
507,
198,
5466,
275,
3066,
63,
1210,
480,
12092,
406,
27389,
334,
4144,
304,
6099,
507,
198,
893,
26,
686,
198,
1361,
2879,
14,
29213,
8,
23015,
12,
16377,
9,
507,
198,
2590,
26,
686,
198,
1361,
2879,
14,
29213,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
17785,
991,
835,
582,
199,
198,
893,
26,
507,
198,
3333,
275,
3066,
63,
1210,
480,
8436,
26,
6099,
507,
198,
1361,
2879,
14,
17785,
991,
835,
8,
3333,
9,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
30710,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
30710,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
17785,
1955,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
17785,
1955,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
2105,
835,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
362,
2105,
835,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
29801,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
362,
29801,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
4208,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
362,
4208,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
303,
273,
9030,
529,
3321,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
303,
273,
9030,
529,
3321,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
32286,
582,
199,
198,
893,
26,
507,
198,
1361,
2879,
14,
32286,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
21102,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
536,
26,
6099,
507,
198,
893,
26,
686,
198,
1361,
2879,
14,
21102,
8,
23015,
9,
507,
198,
2590,
26,
686,
198,
1361,
2879,
14,
21102,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
30404,
2048,
582,
199,
198,
893,
26,
507,
198,
23015,
275,
3066,
63,
1210,
480,
8468,
376,
2933,
334,
4144,
304,
6099,
507,
198,
5466,
275,
3066,
63,
1210,
480,
12092,
406,
27389,
334,
4144,
304,
6099,
507,
198,
893,
26,
686,
198,
1361,
2879,
14,
362,
30404,
2048,
8,
23015,
12,
16377,
9,
507,
198,
2590,
26,
686,
198,
1361,
2879,
14,
362,
30404,
2048,
342,
199,
198,
2590,
26,
507,
198,
1361,
1867,
78,
2595,
2493,
1125,
8920,
17791,
78,
2,
199,
199,
4164,
2088,
508,
298,
362,
30404,
1562,
582,
199,
198,
893,
26,
507,
198,
2697,
275,
3066,
63,
1210,
480,
8468,
282,
445,
850,
529,
9061,
2287,
334,
4144,
304,
6099,
507,
198,
5466,
275,
3066,
63,
1210,
480,
12092,
406,
27389,
334,
4144,
304,
6099,
507,
198,
893,
26,
686,
198,
1361,
2879,
14,
362,
30404,
1562,
8,
2697,
12,
16377,
9,
507,
198,
2590,
26,
686,
198,
1361,
2879,
14,
362,
30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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
] |
yuanzhao/gpdb
|
gpMgmt/bin/gppylib/gparray.py
|
4
|
94119
|
#!/usr/bin/env python
#
# Copyright (c) Greenplum Inc 2008. All Rights Reserved.
#
"""
gparray.py:
Contains three classes representing configuration information of a
Greenplum array:
GpArray - The primary interface - collection of all GpDB within an array
GpDB - represents configuration information for a single dbid
Segment - collection of all GpDB with the same content id
"""
# ============================================================================
from datetime import date
import copy
import traceback
from gppylib.utils import checkNotNone, checkIsInt
from gppylib import gplog
from gppylib.db import dbconn
from gppylib.gpversion import GpVersion
from gppylib.commands.unix import *
import os
SYSTEM_FILESPACE = 3052 # oid of the system filespace
logger = gplog.get_default_logger()
DESTINATION_FILE_SPACES_DIRECTORY = "fs_directory"
ROLE_PRIMARY = 'p'
ROLE_MIRROR = 'm'
VALID_ROLES = [ROLE_PRIMARY, ROLE_MIRROR]
# Map gp_segment_configuration role values to values from gp_primarymirror.
ROLE_TO_MODE_MAP = {}
SEG_MODE_PRIMARY = "PrimarySegment"
SEG_MODE_MIRROR = "MirrorSegment"
ROLE_TO_MODE_MAP[ROLE_PRIMARY] = SEG_MODE_PRIMARY
ROLE_TO_MODE_MAP[ROLE_MIRROR] = SEG_MODE_MIRROR
STATUS_UP = 'u'
STATUS_DOWN = 'd'
VALID_STATUS = [STATUS_UP, STATUS_DOWN]
MODE_NOT_INITIALIZED = '' # no mirroring
MODE_CHANGELOGGING = 'c' # filerep logging
MODE_SYNCHRONIZED = 's' # filerep synchronized
MODE_RESYNCHRONIZATION = 'r' #
# Map gp_segment_configuration mode values to values retured from gp_primarymirror.
MODE_TO_DATA_STATE_MAP = {}
SEG_DATA_STATE_NOT_INITIALIZED = "NotInitialized"
SEG_DATA_STATE_IN_CHANGE_TRACKING = "InChangeTracking"
SEG_DATA_STATE_SYNCHRONIZED = "InSync"
SEG_DATA_STATE_IN_RESYNC = "InResync"
MODE_TO_DATA_STATE_MAP[MODE_NOT_INITIALIZED] = SEG_DATA_STATE_NOT_INITIALIZED
MODE_TO_DATA_STATE_MAP[MODE_CHANGELOGGING] = SEG_DATA_STATE_IN_CHANGE_TRACKING
MODE_TO_DATA_STATE_MAP[MODE_SYNCHRONIZED] = SEG_DATA_STATE_SYNCHRONIZED
MODE_TO_DATA_STATE_MAP[MODE_RESYNCHRONIZATION] = SEG_DATA_STATE_IN_RESYNC
# SegmentState values returned from gp_primarymirror.
SEGMENT_STATE_NOT_INITIALIZED = "NotInitialized"
SEGMENT_STATE_INITIALIZATION = "Initialization"
SEGMENT_STATE_IN_CHANGE_TRACKING_TRANSITION = "InChangeTrackingTransition"
SEGMENT_STATE_IN_RESYNCTRANSITION = "InResyncTransition"
SEGMENT_STATE_IN_SYNC_TRANSITION = "InSyncTransition"
SEGMENT_STATE_READY = "Ready"
SEGMENT_STATE_CHANGE_TRACKING_DISABLED = "ChangeTrackingDisabled"
SEGMENT_STATE_FAULT = "Fault"
SEGMENT_STATE_SHUTDOWN_BACKENDS = "ShutdownBackends"
SEGMENT_STATE_SHUTDOWN = "Shutdown"
SEGMENT_STATE_IMMEDIATE_SHUTDOWN = "ImmediateShutdown"
VALID_MODE = [
MODE_SYNCHRONIZED,
MODE_CHANGELOGGING,
MODE_RESYNCHRONIZATION,
]
MODE_LABELS = {
MODE_CHANGELOGGING: "Change Tracking",
MODE_SYNCHRONIZED: "Synchronized",
MODE_RESYNCHRONIZATION: "Resynchronizing"
}
# These are all the valid states primary/mirror pairs can
# be in. Any configuration other than this will cause the
# FTS Prober to bring down the master postmaster until the
# configuration is corrected. Here, primary and mirror refer
# to the segments current role, not the preferred_role.
#
# The format of the tuples are:
# (<primary status>, <prmary mode>, <mirror status>, <mirror_mode>)
VALID_SEGMENT_STATES = [
(STATUS_UP, MODE_CHANGELOGGING, STATUS_DOWN, MODE_SYNCHRONIZED),
(STATUS_UP, MODE_CHANGELOGGING, STATUS_DOWN, MODE_RESYNCHRONIZATION),
(STATUS_UP, MODE_RESYNCHRONIZATION, STATUS_UP, MODE_RESYNCHRONIZATION),
(STATUS_UP, MODE_SYNCHRONIZED, STATUS_UP, MODE_SYNCHRONIZED)
]
def getDataModeLabel(mode):
return MODE_LABELS[mode]
MASTER_CONTENT_ID = -1
class InvalidSegmentConfiguration(Exception):
"""Exception raised when an invalid gparray configuration is
read from gp_segment_configuration or an attempt to save an
invalid gparray configuration is made."""
def __init__(self, array):
self.array = array
def __str__(self):
return "Invalid GpArray: %s" % self.array
# ============================================================================
# ============================================================================
class GpDB:
"""
GpDB class representing configuration information for a single dbid
within a Greenplum Array.
"""
# --------------------------------------------------------------------
def __init__(self, content, preferred_role, dbid, role, mode, status,
hostname, address, port, datadir, replicationPort):
# Todo: replace all these fields with private alternatives:
# e.g. '_content' instead of 'content'.
#
# Other code should go through class interfaces for access, this
# will allow easier modifications in the future.
self.content=content
self.preferred_role=preferred_role
self.dbid=dbid
self.role=role
self.mode=mode
self.status=status
self.hostname=hostname
self.address=address
self.port=port
self.datadir=datadir
self.replicationPort=replicationPort
# Filespace mappings for this segment
# Todo: Handle self.datadir more cleanly
# Todo: Handle initialization more cleanly
self.__filespaces = { SYSTEM_FILESPACE: datadir }
# Pending filespace creation
self.__pending_filespace = None
# Catalog directory for each database in this segment
self.catdirs = None
# Todo: Remove old dead code
self.valid = (status == 'u')
# --------------------------------------------------------------------
def __str__(self):
"""
Construct a printable string representation of a GpDB
"""
return "%s:%s:content=%s:dbid=%s:mode=%s:status=%s" % (
self.hostname,
self.datadir,
self.content,
self.dbid,
self.mode,
self.status
)
#
# Note that this is not an ideal comparison -- it uses the string representation
# for comparison
#
def __cmp__(self,other):
left = repr(self)
right = repr(other)
if left < right: return -1
elif left > right: return 1
else: return 0
#
# Moved here from system/configurationImplGpdb.py
#
def equalIgnoringModeAndStatusAndReplicationPort(self, other):
"""
Return true if none of the "core" attributes (e.g. filespace)
of two segments differ, false otherwise.
This method is used by updateSystemConfig() to know when a catalog
change will cause removing and re-adding a mirror segment.
"""
firstMode = self.getSegmentMode()
firstStatus = self.getSegmentStatus()
firstReplicationPort = self.getSegmentReplicationPort()
try:
# make the elements we don't want to compare match and see if they are then equal
self.setSegmentMode(other.getSegmentMode())
self.setSegmentStatus(other.getSegmentStatus())
self.setSegmentReplicationPort(other.getSegmentReplicationPort())
return self == other
finally:
#
# restore mode and status after comaprison
#
self.setSegmentMode(firstMode)
self.setSegmentStatus(firstStatus)
self.setSegmentReplicationPort(firstReplicationPort)
# --------------------------------------------------------------------
def __repr__(self):
"""
Construct a string representation of class, must be sufficient
information to call initFromString on the result and deterministic
so it can be used for __cmp__ comparison
"""
# Note: this doesn't currently handle "pending filespaces", but
# this is not currently required since gpfilespace is the only code
# that generates pending filespaces and it never serializes a gparray
# object.
fsOids = [oid for oid in self.__filespaces]
fsOids.sort() # sort for determinism
filespaces = []
for fsoid in fsOids:
if fsoid not in [SYSTEM_FILESPACE]:
filespaces.append("%d:%s" % (fsoid, self.__filespaces[fsoid]))
return '%d|%d|%s|%s|%s|%s|%s|%s|%d|%s|%s|%s|%s' % (
self.dbid,
self.content,
self.role,
self.preferred_role,
self.mode,
self.status,
self.hostname,
self.address,
self.port,
self.replicationPort,
self.datadir,
','.join(filespaces), # this is rather ugly
','.join(self.catdirs) if self.catdirs else []
)
# --------------------------------------------------------------------
@staticmethod
def initFromString(s):
"""
Factory method, initializes a GpDB object from string representation.
- Used when importing from file format.
- TODO: Should be compatable with repr() formatting.
"""
tup = s.strip().split('|')
if len(tup) != 13:
raise Exception("GpDB unknown input format: %s" % s)
# This describes the gp_segment_configuration catalog
dbid = int(tup[0])
content = int(tup[1])
role = tup[2]
preferred_role = tup[3]
mode = tup[4]
status = tup[5]
hostname = tup[6]
address = tup[7]
port = int(tup[8])
replicationPort = tup[9]
datadir = tup[10] # from the pg_filespace_entry table
filespaces = tup[11]
catdirs = tup[12]
# Initialize segment without filespace information
gpdb = GpDB(content = content,
preferred_role = preferred_role,
dbid = dbid,
role = role,
mode = mode,
status = status,
hostname = hostname,
address = address,
port = port,
datadir = datadir,
replicationPort = replicationPort)
# Add in filespace information, if present
for fs in filespaces.split(","):
if fs == "":
continue
(fsoid, fselocation) = fs.split(":")
gpdb.addSegmentFilespace(fsoid, fselocation)
# Add Catalog Dir, if present
gpdb.catdirs = []
for d in catdirs.split(","):
if d == "":
continue
gpdb.catdirs.append(d)
# Return the completed segment
return gpdb
# --------------------------------------------------------------------
@staticmethod
def getDataDirPrefix(datadir):
retValue = ""
retValue = datadir[:datadir.rfind('/')]
return retValue
# --------------------------------------------------------------------
@staticmethod
def getFileSpaceDirsWithNewSuffix(fileSpaceDictionary, suffix, includeSystemFilespace = True):
"""
This method will take the a dictionary of file spaces and return the same dictionary with the new sufix.
"""
retValue = {}
for entry in fileSpaceDictionary:
if entry == SYSTEM_FILESPACE and includeSystemFilespace == False:
continue
newDir = GpDB.getDataDirPrefix(fileSpaceDictionary[entry])
newDir = newDir + "/" + suffix
retValue[entry] = newDir
return retValue
# --------------------------------------------------------------------
@staticmethod
def replaceFileSpaceContentID(fileSpaceDictionary, oldContent, newContent):
retValue = {}
for entry in fileSpaceDictionary:
tempDir = fileSpaceDictionary[entry]
tempDir = tempDir[:tempDir.rfind(str(oldContent))]
tempDir += ('%d' % newContent)
retValue[entry] = tempDir
return retValue
# --------------------------------------------------------------------
def copy(self):
"""
Creates a copy of the segment, shallow for everything except the filespaces map
"""
res = copy.copy(self)
res.__filespaces = copy.copy(self.__filespaces)
return res
# --------------------------------------------------------------------
def createTemplate(self, dstDir):
"""
Create a tempate given the information in this GpDB.
"""
# Make sure we have enough room in the dstDir to fit the segment and its filespaces.
duCmd = DiskUsage( name = "srcDir"
, directory = dstDir
)
duCmd.run(validateAfter=True)
requiredSize = duCmd.get_bytes_used()
name = "segcopy filespace get_size"
for oid in self.__filespaces:
if oid == SYSTEM_FILESPACE:
continue
dir = self.__filespaces[oid]
duCmd = DiskUsage(name, dir)
duCmd.run(validateAfter=True)
size = duCmd.get_bytes_used()
requiredSize = requiredSize + size
dstBytesAvail = DiskFree.get_size_local(name = "Check for available free space for segment template", directory = dstDir)
if dstBytesAvail <= requiredSize:
raise Exception("Not enough space on directory: '%s'. Currently %d bytes free but need %d bytes." % (dstDir, int(dstBytesAvail), int(requiredSize)))
logger.info("Starting copy of segment dbid %d to location %s" % (int(self.getSegmentDbId()), dstDir))
cpCmd = LocalDirCopy("Copy system data directory", self.getSegmentDataDirectory(), dstDir)
cpCmd.run(validateAfter = True)
res = cpCmd.get_results()
if len(self.__filespaces) > 1:
""" Make directory to hold file spaces """
fullPathFsDir = dstDir + "/" + DESTINATION_FILE_SPACES_DIRECTORY
cmd = FileDirExists( name = "check for existance of template filespace directory"
, directory = fullPathFsDir
)
cmd.run(validateAfter = True)
MakeDirectory.local("gpexpand make directory to hold file spaces", fullPathFsDir)
for oid in self.__filespaces:
MakeDirectory.local("gpexpand make directory to hold file space oid: " + str(oid), fullPathFsDir)
dir = self.__filespaces[oid]
destDir = fullPathFsDir + "/" + str(oid)
MakeDirectory.local("gpexpand make directory to hold file space: " + destDir, destDir)
name = "GpSegCopy %s to %s" % (dir, destDir)
cpCmd = LocalDirCopy(name, dir, destDir)
cpCmd.run(validateAfter = True)
res = cpCmd.get_results()
# Remove the gp_dbid file from the data dir
RemoveFile.local('Remove gp_dbid file', os.path.normpath(dstDir + '/gp_dbid'))
logger.info("Cleaning up catalog for schema only copy on destination")
# We need 700 permissions or postgres won't start
Chmod.local('set template permissions', dstDir, '0700')
# --------------------------------------------------------------------
# Six simple helper functions to identify what role a segment plays:
# + QD (Query Dispatcher)
# + master
# + standby master
# + QE (Query Executor)
# + primary
# + mirror
# --------------------------------------------------------------------
def isSegmentQD(self):
return self.content < 0
def isSegmentMaster(self, current_role=False):
role = self.role if current_role else self.preferred_role
return self.content < 0 and role == ROLE_PRIMARY
def isSegmentStandby(self, current_role=False):
role = self.role if current_role else self.preferred_role
return self.content < 0 and role == ROLE_MIRROR
def isSegmentQE(self):
return self.content >= 0
def isSegmentPrimary(self, current_role=False):
role = self.role if current_role else self.preferred_role
return self.content >= 0 and role == ROLE_PRIMARY
def isSegmentMirror(self, current_role=False):
role = self.role if current_role else self.preferred_role
return self.content >= 0 and role == ROLE_MIRROR
def isSegmentUp(self):
return self.status == STATUS_UP
def isSegmentDown(self):
return self.status == STATUS_DOWN
def isSegmentModeInChangeLogging(self):
return self.mode == MODE_CHANGELOGGING
def isSegmentModeSynchronized(self):
return self.mode == MODE_SYNCHRONIZED
def isSegmentModeInResynchronization(self):
return self.mode == MODE_RESYNCHRONIZATION
# --------------------------------------------------------------------
# getters
# --------------------------------------------------------------------
def getSegmentDbId(self):
return checkNotNone("dbId", self.dbid)
def getSegmentContentId(self):
return checkNotNone("contentId", self.content)
def getSegmentRole(self):
return checkNotNone("role", self.role)
def getSegmentPreferredRole(self):
return checkNotNone("preferredRole", self.preferred_role)
def getSegmentMode(self):
return checkNotNone("mode", self.mode)
def getSegmentStatus(self):
return checkNotNone("status", self.status)
def getSegmentPort(self):
"""
Returns the listening port for the postmaster for this segment.
Note: With file replication the postmaster will not be active for
mirrors so nothing will be listening on this port, instead the
"replicationPort" is used for primary-mirror communication.
"""
return checkNotNone("port", self.port)
def getSegmentReplicationPort(self):
"""
Returns the replicationPort for the segment, this is the port used for
communication between the primary and mirror for file replication.
Note: is Nullable (so can return None)
"""
return self.replicationPort
def getSegmentHostName(self):
"""
Returns the actual `hostname` for the host
Note: use getSegmentAddress for the network address to use
"""
return self.hostname
def getSegmentAddress(self):
"""
Returns the network address to use to contact the segment (i.e. the NIC address).
"""
return self.address
def getSegmentDataDirectory(self):
"""
Return the primary datadirectory location for the segment.
Note: the datadirectory is just one of the filespace locations
associated with the segment, calling code should be carefull not
to assume that this is the only directory location for this segment.
Todo: evaluate callers of this function to see if they should really
be dealing with a list of filespaces.
"""
return checkNotNone("dataDirectory", self.datadir)
def getSegmentFilespaces(self):
"""
Returns the filespace dictionary of oid->path pairs
"""
return self.__filespaces
# --------------------------------------------------------------------
# setters
# --------------------------------------------------------------------
def setSegmentDbId(self, dbId):
checkNotNone("dbId", dbId)
self.dbid = dbId
def setSegmentContentId(self, contentId):
checkNotNone("contentId", contentId)
if contentId < -1:
raise Exception("Invalid content id %s" % contentId)
self.content = contentId
def setSegmentRole(self, role):
checkNotNone("role", role)
if role not in VALID_ROLES:
raise Exception("Invalid role '%s'" % role)
self.role = role
def setSegmentPreferredRole(self, preferredRole):
checkNotNone("preferredRole", preferredRole)
if preferredRole not in VALID_ROLES:
raise Exception("Invalid preferredRole '%s'" % preferredRole)
self.preferred_role = preferredRole
def setSegmentMode(self, mode):
checkNotNone("mode", mode)
if not mode in VALID_MODE:
raise Exception("Invalid mode '%s'" % mode)
self.mode = mode
def setSegmentStatus(self, status):
checkNotNone("status", status)
if status not in VALID_STATUS:
raise Exception("Invalid status '%s'" % status)
self.status = status
def setSegmentPort(self, port):
checkNotNone("port", port)
checkIsInt("port", port)
self.port = port
def setSegmentReplicationPort(self, replicationPort):
# None is allowed -- don't check nonNone
if replicationPort is not None:
checkIsInt("replicationPort", replicationPort)
self.replicationPort = replicationPort
def setSegmentHostName(self, hostName):
# None is allowed -- don't check
self.hostname = hostName
def setSegmentAddress(self, address):
# None is allowed -- don't check
self.address = address
def setSegmentDataDirectory(self, dataDirectory):
checkNotNone("dataDirectory", dataDirectory)
self.datadir = dataDirectory
def addSegmentFilespace(self, oid, path):
"""
Add a filespace path for this segment.
Throws:
Exception - if a path has already been specified for this segment.
"""
# gpfilespace adds a special filespace with oid=None to indicate
# the filespace that it is currently building, since the filespace
# does not yet exist there is no valid value that could be used.
if oid == None:
if self.__pending_filespace:
raise Exception("Duplicate filespace path for dbid %d" %
self.dbid)
self.__pending_filespace = path
return
# oids should always be integer values > 0
oid = int(oid)
assert(oid > 0)
# The more usual case just sets the filespace in the filespace
# dictionary
if oid in self.__filespaces:
raise Exception("Duplicate filespace path for "
"dbid %d filespace %d" % (self.dbid, oid))
self.__filespaces[oid] = path
def getSegmentPendingFilespace(self):
"""
Returns the pending filespace location for this segment
(called by gpfilespace)
"""
return self.__pending_filespace
# ============================================================================
class Segment:
"""
Used to represent all of the SegmentDBs with the same contentID. Today this
can be at most a primary SegDB and a single mirror SegDB. In the future we
will most likely support multiple mirror segDBs.
Note: This class seems to complicate the implementation of gparray, without
adding much value. Perhaps it should be removed.
"""
primaryDB=None
mirrorDBs=None
# --------------------------------------------------------------------
def __init__(self):
self.mirrorDBs=[]
pass
# --------------------------------------------------------------------
def __str__(self):
return "(Primary: %s, Mirrors: [%s])" % (str(self.primaryDB),
','.join([str(segdb) for segdb in self.mirrorDBs]))
# --------------------------------------------------------------------
def addPrimary(self,segDB):
self.primaryDB=segDB
def addMirror(self,segDB):
self.mirrorDBs.append(segDB)
# --------------------------------------------------------------------
def get_dbs(self):
dbs=[]
if self.primaryDB is not None: # MPP-10886 don't add None to result list
dbs.append(self.primaryDB)
if len(self.mirrorDBs) > 0:
dbs.extend(self.mirrorDBs)
return dbs
# --------------------------------------------------------------------
def get_hosts(self):
hosts=[]
hosts.append(self.primaryDB.hostname)
for m in self.mirrorDBs:
hosts.append(m.hostname)
return hosts
def is_segment_pair_valid(self):
"""Validates that the primary/mirror pair are in a valid state"""
for mirror_db in self.mirrorDBs:
prim_status = self.primaryDB.getSegmentStatus()
prim_mode = self.primaryDB.getSegmentMode()
mirror_status = mirror_db.getSegmentStatus()
mirror_role = mirror_db.getSegmentMode()
if (prim_status, prim_mode, mirror_status, mirror_role) not in VALID_SEGMENT_STATES:
return False
return True
# --------------------------------------------------------------------
# --------------------------------------------------------------------
class SegmentRow():
def __init__(self, content, isprimary, dbid, host, address, port, fulldir, prPort, fileSpaceDictionary = None):
self.content = content
self.isprimary = isprimary
self.dbid = dbid
self.host = host
self.address = address
self.port = port
self.fulldir = fulldir
self.prPort = prPort
self.fileSpaceDictionary = fileSpaceDictionary
def __str__(self):
retVal = "" + \
"content = " + str(self.content) + "\n" + \
"isprimary =" + str(self.isprimary) + "\n" + \
"dbid = " + str(self.dbid) + "\n" + \
"host = " + str(self.host) + "\n" + \
"address = " + str(self.address) + "\n" + \
"port = " + str(self.port) + "\n" + \
"fulldir = " + str(self.fulldir) + "\n" + \
"prPort = " + str(self.prPort) + "\n" + \
"fileSpaceDictionary = " + str(self.fileSpaceDictionary) + "\n" + "\n"
def createSegmentRows( hostlist
, interface_list
, primary_list
, primary_portbase
, mirror_type
, mirror_list
, mirror_portbase
, dir_prefix
, primary_replication_portbase
, mirror_replication_portbase
, primary_fs_list = None
, mirror_fs_list = None
):
"""
This method will return a list of SegmentRow objects that represent new segments on each host.
The "hostlist" parameter contains both existing hosts as well as any new hosts that are
a result of expansion.
"""
rows =[]
dbid = 0
content = 0
for host in hostlist:
isprimary='t'
port=primary_portbase
prPort = primary_replication_portbase
index = 0
for pdir in primary_list:
fulldir = "%s/%s%d" % (pdir,dir_prefix,content)
if len(interface_list) > 0:
interfaceNumber = interface_list[index % len(interface_list)]
address = host + '-' + str(interfaceNumber)
else:
address = host
fsDict = {}
if primary_fs_list != None and len(primary_fs_list) > index:
fsDict = primary_fs_list[index]
fullFsDict = {}
for oid in fsDict:
fullFsDict[oid] = "%s/%s%d" % (fsDict[oid], dir_prefix, content)
rows.append( SegmentRow( content = content
, isprimary = isprimary
, dbid = dbid
, host = host
, address = address
, port = port
, fulldir = fulldir
, prPort = prPort
, fileSpaceDictionary = fullFsDict
) )
port += 1
if prPort != None:
prPort += 1
content += 1
dbid += 1
index = index + 1
#mirrors
if mirror_type is None or mirror_type == 'none':
return rows
elif mirror_type.lower().strip() == 'spread':
#TODO: must be sure to put mirrors on a different subnet than primary.
# this is a general problem for GPDB these days.
# best to have the interface mapping stuff 1st.
content=0
isprimary='f'
num_hosts = len(hostlist)
num_dirs=len(primary_list)
if num_hosts <= num_dirs:
raise Exception("Not enough hosts for spread mirroring. You must have more hosts than primary segments per host")
mirror_port = {}
mirror_replication_port = {}
mirror_host_offset=1
last_mirror_offset=1
for host in hostlist:
mirror_host_offset = last_mirror_offset + 1
last_mirror_offset += 1
index = 0
for mdir in mirror_list:
fulldir = "%s/%s%d" % (mdir,dir_prefix,content)
fsDict = {}
if mirror_fs_list != None and len(mirror_fs_list) > index:
fsDict = mirror_fs_list[index]
fullFsDict = {}
for oid in fsDict:
fullFsDict[oid] = "%s/%s%d" % (fsDict[oid], dir_prefix, content)
mirror_host = hostlist[mirror_host_offset % num_hosts]
if mirror_host == host:
mirror_host_offset += 1
mirror_host = hostlist[mirror_host_offset % num_hosts]
if len(interface_list) > 0:
interfaceNumber = interface_list[mirror_host_offset % len(interface_list)]
address = mirror_host + '-' + str(interfaceNumber)
else:
address = mirror_host
if not mirror_port.has_key(mirror_host):
mirror_port[mirror_host] = mirror_portbase
if not mirror_replication_port.has_key(mirror_host):
mirror_replication_port[mirror_host] = mirror_replication_portbase
rows.append( SegmentRow( content = content
, isprimary = isprimary
, dbid = dbid
, host = mirror_host
, address = address
, port = mirror_port[mirror_host]
, fulldir = fulldir
, prPort = mirror_replication_port[mirror_host]
, fileSpaceDictionary = fullFsDict
) )
mirror_port[mirror_host] += 1
mirror_replication_port[mirror_host] += 1
content += 1
dbid += 1
mirror_host_offset += 1
index = index + 1
elif mirror_type.lower().strip() == 'grouped':
content = 0
num_hosts = len(hostlist)
if num_hosts < 2:
raise Exception("Not enough hosts for grouped mirroring. You must have at least 2")
#we'll pick our mirror host to be 1 host "ahead" of the primary.
mirror_host_offset = 1
isprimary='f'
for host in hostlist:
mirror_host = hostlist[mirror_host_offset % num_hosts]
mirror_host_offset += 1
port = mirror_portbase
mrPort = mirror_replication_portbase
index = 0
for mdir in mirror_list:
fulldir = "%s/%s%d" % (mdir,dir_prefix,content)
if len(interface_list) > 0:
interfaceNumber = interface_list[(index + 1) % len(interface_list)]
address = mirror_host + '-' + str(interfaceNumber)
else:
address = mirror_host
fsDict = {}
if mirror_fs_list != None and len(mirror_fs_list) > index:
fsDict = mirror_fs_list[index]
fullFsDict = {}
for oid in fsDict:
fullFsDict[oid] = "%s/%s%d" % (fsDict[oid], dir_prefix, content)
rows.append( SegmentRow( content = content
, isprimary = isprimary
, dbid = dbid
, host = mirror_host
, address = address
, port = port
, fulldir = fulldir
, prPort = mrPort
, fileSpaceDictionary = fullFsDict
) )
port += 1
mrPort +=1
content += 1
dbid += 1
index = index + 1
else:
raise Exception("Invalid mirror type specified: %s" % mirror_type)
return rows
#========================================================================
def createSegmentRowsFromSegmentList( newHostlist
, interface_list
, primary_segment_list
, primary_portbase
, mirror_type
, mirror_segment_list
, mirror_portbase
, dir_prefix
, primary_replication_portbase
, mirror_replication_portbase
):
"""
This method will return a list of SegmentRow objects that represent an expansion of existing
segments on new hosts.
"""
rows = []
dbid = 0
content = 0
interfaceDict = {}
for host in newHostlist:
isprimary='t'
port=primary_portbase
prPort = primary_replication_portbase
index = 0
for pSeg in primary_segment_list:
if len(interface_list) > 0:
interfaceNumber = interface_list[index % len(interface_list)]
address = host + '-' + str(interfaceNumber)
interfaceDict[content] = index % len(interface_list)
else:
address = host
newFulldir = "%s/%s%d" % (GpDB.getDataDirPrefix(pSeg.getSegmentDataDirectory()), dir_prefix, content)
newFileSpaceDictionary = GpDB.getFileSpaceDirsWithNewSuffix(pSeg.getSegmentFilespaces(), dir_prefix + str(content), includeSystemFilespace = False)
rows.append( SegmentRow( content = content
, isprimary = isprimary
, dbid = dbid
, host = host
, address = address
, port = port
, fulldir = newFulldir
, prPort = prPort
, fileSpaceDictionary = newFileSpaceDictionary
) )
port += 1
if prPort != None:
prPort += 1
content += 1
dbid += 1
index += 1
#mirrors
if mirror_type is None or mirror_type == 'none':
return rows
elif mirror_type.lower().strip() == 'spread':
content=0
isprimary='f'
num_hosts = len(newHostlist)
num_dirs=len(primary_segment_list)
if num_hosts <= num_dirs:
raise Exception("Not enough hosts for spread mirroring. You must have more hosts than primary segments per host")
mirror_port = {}
mirror_replication_port = {}
mirror_host_offset=1
last_mirror_offset=0
for host in newHostlist:
mirror_host_offset = last_mirror_offset + 1
last_mirror_offset += 1
for mSeg in mirror_segment_list:
newFulldir = "%s/%s%d" % (GpDB.getDataDirPrefix(mSeg.getSegmentDataDirectory()), dir_prefix, content)
newFileSpaceDictionary = GpDB.getFileSpaceDirsWithNewSuffix(mSeg.getSegmentFilespaces(), dir_prefix + str(content), includeSystemFilespace = False)
mirror_host = newHostlist[mirror_host_offset % num_hosts]
if mirror_host == host:
mirror_host_offset += 1
mirror_host = newHostlist[mirror_host_offset % num_hosts]
if len(interface_list) > 0:
interfaceNumber = interface_list[(interfaceDict[content] + 1) % len(interface_list)]
address = mirror_host + '-' + str(interfaceNumber)
else:
address = mirror_host
if not mirror_port.has_key(mirror_host):
mirror_port[mirror_host] = mirror_portbase
if not mirror_replication_port.has_key(mirror_host):
mirror_replication_port[mirror_host] = mirror_replication_portbase
rows.append( SegmentRow( content = content
, isprimary = isprimary
, dbid = dbid
, host = mirror_host
, address = address
, port = mirror_port[mirror_host]
, fulldir = newFulldir
, prPort = mirror_replication_port[mirror_host]
, fileSpaceDictionary = newFileSpaceDictionary
) )
mirror_port[mirror_host] += 1
mirror_replication_port[mirror_host] += 1
content += 1
dbid += 1
mirror_host_offset += 1
elif mirror_type.lower().strip() == 'grouped':
content = 0
num_hosts = len(newHostlist)
if num_hosts < 2:
raise Exception("Not enough hosts for grouped mirroring. You must have at least 2")
#we'll pick our mirror host to be 1 host "ahead" of the primary.
mirror_host_offset = 1
isprimary='f'
for host in newHostlist:
mirror_host = newHostlist[mirror_host_offset % num_hosts]
mirror_host_offset += 1
port = mirror_portbase
mrPort = mirror_replication_portbase
index = 0
for mSeg in mirror_segment_list:
if len(interface_list) > 0:
interfaceNumber = interface_list[(interfaceDict[content] + 1) % len(interface_list)]
address = mirror_host + '-' + str(interfaceNumber)
else:
address = mirror_host
newFulldir = "%s/%s%d" % (GpDB.getDataDirPrefix(mSeg.getSegmentDataDirectory()), dir_prefix, content)
newFileSpaceDictionary = GpDB.getFileSpaceDirsWithNewSuffix(mSeg.getSegmentFilespaces(), dir_prefix + str(content), includeSystemFilespace = False)
rows.append( SegmentRow( content = content
, isprimary = isprimary
, dbid = dbid
, host = mirror_host
, address = address
, port = port
, fulldir = newFulldir
, prPort = mrPort
, fileSpaceDictionary = newFileSpaceDictionary
) )
port += 1
mrPort +=1
content += 1
dbid += 1
index = index + 1
else:
raise Exception("Invalid mirror type specified: %s" % mirror_type)
return rows
#========================================================================
def parseTrueFalse(value):
if value.lower() == 'f':
return False
elif value.lower() == 't':
return True
raise Exception('Invalid true/false value')
# TODO: Destroy this (MPP-7686)
# Now that "hostname" is a distinct field in gp_segment_configuration
# attempting to derive hostnames from interaface names should be eliminated.
#
def get_host_interface(full_hostname):
(host_part, inf_num) = ['-'.join(full_hostname.split('-')[:-1]),
full_hostname.split('-')[-1]]
if host_part == '' or not inf_num.isdigit():
return (full_hostname, None)
else:
return (host_part, inf_num)
class GpFilespaceObj:
"""
List information for a filespace, as stored in pg_filespace
"""
def __init__(self, oid, name):
self.__oid = oid
self.__name = name
def getOid(self):
return self.__oid
def getName(self):
return self.__name
def isSystemFilespace(self):
return self.__oid == SYSTEM_FILESPACE
# ============================================================================
class GpArray:
"""
GpArray is a python class that describes a Greenplum array.
A Greenplum array consists of:
master - The primary QD for the array
standby master - The mirror QD for the array [optional]
segment array - an array of segments within the cluster
Each segment is either a single GpDB object, or a primary/mirror pair.
It can be initialized either from a database connection, in which case
it discovers the configuration information by examining the catalog, or
via a configuration file.
"""
# --------------------------------------------------------------------
def __init__(self, segments, segmentsAsLoadedFromDb=None):
"""
segmentsInDb is used only be the configurationImpl* providers; it is used to track the state of the
segments in the database
TODO:
"""
self.master = None
self.standbyMaster = None
self.segments = []
self.expansionSegments=[]
self.numPrimarySegments = 0
self.recoveredSegmentDbids = []
self.__version = None
self.__segmentsAsLoadedFromDb = segmentsAsLoadedFromDb
self.hasMirrors = False
self.setFilespaces([])
for segdb in segments:
# Handle QD nodes
if segdb.isSegmentMaster(True):
if self.master != None:
logger.error("multiple master dbs defined")
raise Exception("GpArray - multiple master dbs defined")
self.master = segdb
elif segdb.isSegmentStandby(True):
if self.standbyMaster != None:
logger.error("multiple standby master dbs defined")
raise Exception("GpArray - multiple standby master dbs defined")
self.standbyMaster = segdb
# Handle regular segments
elif segdb.isSegmentQE():
if segdb.isSegmentMirror():
self.hasMirrors = True
self.addSegmentDb(segdb)
else:
# Not a master, standbymaster, primary, or mirror?
# shouldn't even be possible.
logger.error("FATAL - invalid dbs defined")
raise Exception("Error: GpArray() - invalid dbs defined")
# Make sure we have a master db
if self.master is None:
logger.error("FATAL - no master dbs defined!")
raise Exception("Error: GpArray() - no master dbs defined")
def __str__(self):
return "Master: %s\nStandby: %s\nSegments: %s" % (str(self.master),
str(self.standbyMaster) if self.standbyMaster else 'Not Configured',
"\n".join([str(seg) for seg in self.segments]))
def hasStandbyMaster(self):
return self.standbyMaster is not None
def addSegmentDb(self, segdb):
content = segdb.getSegmentContentId()
while len(self.segments) <= content:
self.segments.insert(content, Segment())
seg = self.segments[content]
if segdb.isSegmentPrimary(True):
seg.addPrimary(segdb)
self.numPrimarySegments += 1
else:
seg.addMirror(segdb)
# --------------------------------------------------------------------
def isStandardArray(self):
"""
This method will check various aspects of the array to see if it looks like a standard
setup. It returns two values:
True or False depending on if the array looks like a standard array.
If message if the array does not look like a standard array.
"""
try:
# Do all the segments contain the same number of primary and mirrors.
firstNumPrimaries = 0
firstNumMirrors = 0
firstHost = ""
first = True
dbList = self.getDbList(includeExpansionSegs = True)
gpdbByHost = self.getSegmentsByHostName(dbList)
for host in gpdbByHost:
gpdbList = gpdbByHost[host]
if len(gpdbList) == 1 and gpdbList[0].isSegmentQD() == True:
# This host has one master segment and nothing else
continue
if len(gpdbList) == 2 and gpdbList[0].isSegmentQD() and gpdbList[1].isSegmentQD():
# This host has the master segment and its mirror and nothing else
continue
numPrimaries = 0
numMirrors = 0
for gpdb in gpdbList:
if gpdb.isSegmentQD() == True:
continue
if gpdb.isSegmentPrimary() == True:
numPrimaries = numPrimaries + 1
else:
numMirrors = numMirrors + 1
if first == True:
firstNumPrimaries = numPrimaries
firstNumMirrors = numMirrors
firstHost = host
first = False
if numPrimaries != firstNumPrimaries:
raise Exception("The number of primary segments is not consistent across all nodes: %s != %s." % (host, firstHost))
elif numMirrors != firstNumMirrors:
raise Exception("The number of mirror segments is not consistent across all nodes. %s != %s." % (host, firstHost))
# Make sure the address all have the same suffix "-<n>" (like -1, -2, -3...)
firstSuffixList = []
first = True
suffixList = []
for host in gpdbByHost:
gpdbList = gpdbByHost[host]
for gpdb in gpdbList:
if gpdb.isSegmentMaster() == True:
continue
address = gpdb.getSegmentAddress()
if address == host:
if len(suffixList) == 0:
continue
else:
raise Exception("The address value for %s is the same as the host name, but other addresses on the host are not." % address)
suffix = address.split('-')[-1]
if suffix.isdigit() == False:
raise Exception("The address value for %s does not correspond to a standard address." % address)
suffixList.append(suffix)
suffixList.sort()
if first == True:
firstSuffixList = suffixList
first = False
if suffixList != firstSuffixList:
raise Exception("The address list for %s doesn't not have the same pattern as %s." % (str(suffixList), str(firstSuffixList)))
except Exception, e:
# Assume any exception implies a non-standard array
return False, str(e)
return True, ""
# --------------------------------------------------------------------
@staticmethod
def initFromCatalog(dbURL, utility=False):
"""
Factory method, initializes a GpArray from provided database URL
"""
hasMirrors = False
conn = dbconn.connect(dbURL, utility)
# Get the version from the database:
version_str = None
for row in dbconn.execSQL(conn, "SELECT version()"):
version_str = row[0]
version = GpVersion(version_str)
config_rows = dbconn.execSQL(conn, '''
SELECT dbid, content, role, preferred_role, mode, status,
hostname, address, port, replication_port, fs.oid,
fselocation
FROM pg_catalog.gp_segment_configuration
JOIN pg_catalog.pg_filespace_entry on (dbid = fsedbid)
JOIN pg_catalog.pg_filespace fs on (fsefsoid = fs.oid)
ORDER BY content, preferred_role DESC, fs.oid
''')
filespaceRows = dbconn.execSQL(conn, '''
SELECT oid, fsname
FROM pg_filespace
ORDER BY fsname;
''')
filespaceArr = [GpFilespaceObj(fsRow[0], fsRow[1]) for fsRow in filespaceRows]
# Todo: add checks that all segments should have the same filespaces?
recoveredSegmentDbids = []
segments = []
seg = None
for row in config_rows:
# Extract fields from the row
(dbid, content, role, preferred_role, mode, status, hostname,
address, port, replicationPort, fsoid, fslocation) = row
# Check if mirrors exist
if preferred_role == ROLE_MIRROR:
hasMirrors = True
# If we have segments which have recovered, record them.
if preferred_role != role and content >= 0:
if mode == MODE_SYNCHRONIZED and status == STATUS_UP:
recoveredSegmentDbids.append(dbid)
# The query returns all the filespaces for a segment on separate
# rows. If this row is the same dbid as the previous row simply
# add this filespace to the existing list, otherwise create a
# new segment.
if seg and seg.getSegmentDbId() == dbid:
seg.addSegmentFilespace(fsoid, fslocation)
else:
seg = GpDB(content, preferred_role, dbid, role, mode, status,
hostname, address, port, fslocation, replicationPort)
segments.append(seg)
datcatloc = dbconn.execSQL(conn, '''
select fsloc.dbid, fsloc.fselocation || '/' ||
case when db.dattablespace = 1663
then 'base'
else db.dattablespace::text
end || '/'||db.oid as catloc
from pg_Database db, pg_tablespace ts,
(SELECT dbid, fs.oid, fselocation
FROM pg_catalog.gp_segment_configuration
JOIN pg_catalog.pg_filespace_entry on (dbid = fsedbid)
JOIN pg_catalog.pg_filespace fs on (fsefsoid = fs.oid)) fsloc
where db.dattablespace = ts.oid
and ts.spcfsoid = fsloc.oid''')
conn.close()
catlocmap = {}
for row in datcatloc:
if catlocmap.has_key(row[0]):
catlocmap[row[0]].append(row[1])
else:
catlocmap[row[0]] = [row[1]]
for seg in segments:
seg.catdirs = catlocmap[seg.dbid]
origSegments = [seg.copy() for seg in segments]
array = GpArray(segments, origSegments)
array.__version = version
array.recoveredSegmentDbids = recoveredSegmentDbids
array.setFilespaces(filespaceArr)
array.hasMirrors = hasMirrors
return array
# --------------------------------------------------------------------
@staticmethod
def initFromFile(filename):
"""
Factory method: creates a GpArray from an input file
(called by gpexpand.)
Note: Currently this is only used by the gpexpand rollback facility,
there is currently NO expectation that this file format is saved
on disk in any long term fashion.
Format changes of the file are acceptable until this assumption is
changed, but initFromFile and dumpToFile must be kept in parity.
"""
segdbs=[]
fp = open(filename, 'r')
for line in fp:
segdbs.append(GpDB.initFromString(line))
fp.close()
return GpArray(segdbs)
# --------------------------------------------------------------------
def is_array_valid(self):
"""Checks that each primary/mirror pair is in a valid state"""
for seg in self.segments:
if not seg.is_segment_pair_valid():
return False
return True
# --------------------------------------------------------------------
def dumpToFile(self, filename):
"""
Dumps a GpArray to a file (called by gpexpand)
Note: See notes above for initFromFile()
"""
fp = open(filename, 'w')
for gpdb in self.getDbList():
fp.write(repr(gpdb) + '\n')
fp.close()
# --------------------------------------------------------------------
def setFilespaces(self, filespaceArr):
"""
@param filespaceArr of GpFilespaceObj objects
"""
self.__filespaceArr = [fs for fs in filespaceArr]
def getFilespaces(self, includeSystemFilespace=True):
"""
@return a newly allocated list of GpFilespaceObj objects, will have been sorted by filespace name
"""
if includeSystemFilespace:
return [fs for fs in self.__filespaceArr]
else:
return [fs for fs in self.__filespaceArr if not fs.isSystemFilespace()]
# --------------------------------------------------------------
def getFileSpaceName(self, filespaceOid):
retValue = None
if self.__filespaceArr != None:
for entry in self.__filespaceArr:
if entry.getOid() == filespaceOid:
retValue = entry.getName()
break
return retValue
# --------------------------------------------------------------
def getFileSpaceOid(self, filespaceName):
retValue = None
if self.__filespaceArr != None:
for entry in self.__filespaceArr:
if entry.getName() == filespaceName:
retValue = entry.getOid()
break
return retValue
# --------------------------------------------------------------------
def getDbList(self, includeExpansionSegs=False):
"""
Return a list of all GpDb objects that make up the array
"""
dbs=[]
dbs.append(self.master)
if self.standbyMaster:
dbs.append(self.standbyMaster)
if includeExpansionSegs:
dbs.extend(self.getSegDbList(True))
else:
dbs.extend(self.getSegDbList())
return dbs
# --------------------------------------------------------------------
def getHostList(self, includeExpansionSegs = False):
"""
Return a list of all Hosts that make up the array
"""
hostList = []
hostList.append(self.master.getSegmentHostName())
if self.standbyMaster:
hostList.append(self.standbyMaster.getSegmentHostName())
dbList = self.getDbList(includeExpansionSegs = includeExpansionSegs)
for db in dbList:
if db.getSegmentHostName() in hostList:
continue
else:
hostList.append(db.getSegmentHostName())
return hostList
def getDbIdToPeerMap(self):
"""
Returns a map that maps a dbid to the peer segment for that dbid
"""
contentIdToSegments = {}
for seg in self.getSegDbList():
arr = contentIdToSegments.get(seg.getSegmentContentId())
if arr is None:
arr = []
contentIdToSegments[seg.getSegmentContentId()] = arr
arr.append(seg)
result = {}
for contentId, arr in contentIdToSegments.iteritems():
if len(arr) == 1:
pass
elif len(arr) != 2:
raise Exception("Content %s has more than two segments"% contentId)
else:
result[arr[0].getSegmentDbId()] = arr[1]
result[arr[1].getSegmentDbId()] = arr[0]
return result
# --------------------------------------------------------------------
def getSegDbList(self, includeExpansionSegs=False):
"""Return a list of all GpDb objects for all segments in the array"""
dbs=[]
for seg in self.segments:
dbs.extend(seg.get_dbs())
if includeExpansionSegs:
for seg in self.expansionSegments:
dbs.extend(seg.get_dbs())
return dbs
# --------------------------------------------------------------------
def getSegmentList(self, includeExpansionSegs=False):
"""Return a list of all GpDb objects for all segments in the array"""
dbs=[]
dbs.extend(self.segments)
if includeExpansionSegs:
dbs.extend(self.expansionSegments)
return dbs
# --------------------------------------------------------------------
def getSegDbMap(self):
"""
Return a map of all GpDb objects that make up the array.
"""
dbsMap = {}
for db in self.getSegDbList():
dbsMap[db.getSegmentDbId()] = db
return dbsMap
# --------------------------------------------------------------------
def getExpansionSegDbList(self):
"""Returns a list of all GpDb objects that make up the new segments
of an expansion"""
dbs=[]
for seg in self.expansionSegments:
dbs.extend(seg.get_dbs())
return dbs
# --------------------------------------------------------------------
def getSegmentContainingDb(self, db):
for seg in self.segments:
for segDb in seg.get_dbs():
if db.getSegmentDbId() == segDb.getSegmentDbId():
return seg
return None
# --------------------------------------------------------------------
def getExpansionSegmentContainingDb(self, db):
for seg in self.expansionSegments:
for segDb in seg.get_dbs():
if db.getSegmentDbId() == segDb.getSegmentDbId():
return seg
return None
# --------------------------------------------------------------------
def get_invalid_segdbs(self):
dbs=[]
for seg in self.segments:
segdb = seg.primaryDB
if not segdb.valid:
dbs.append(segdb)
for db in seg.mirrorDBs:
if not db.valid:
dbs.append(db)
return dbs
# --------------------------------------------------------------------
def get_synchronized_segdbs(self):
dbs=[]
for seg in self.segments:
segdb = seg.primaryDB
if segdb.mode == MODE_SYNCHRONIZED:
dbs.append(segdb)
for segdb in seg.mirrorDBs:
if segdb.mode == MODE_SYNCHRONIZED:
dbs.append(segdb)
return dbs
# --------------------------------------------------------------------
def get_unbalanced_segdbs(self):
dbs=[]
for seg in self.segments:
for segdb in seg.get_dbs():
if segdb.preferred_role != segdb.role:
dbs.append(segdb)
return dbs
# --------------------------------------------------------------------
def get_unbalanced_primary_segdbs(self):
dbs = [seg for seg in self.get_unbalanced_segdbs() if seg.role == ROLE_PRIMARY]
return dbs
# --------------------------------------------------------------------
def get_valid_segdbs(self):
dbs=[]
for seg in self.segments:
db = seg.primaryDB
if db.valid:
dbs.append(db)
for db in seg.mirrorDBs:
if db.valid:
dbs.append(db)
return dbs
# --------------------------------------------------------------------
def get_hostlist(self, includeMaster=True):
hosts=[]
if includeMaster:
hosts.append(self.master.hostname)
if self.standbyMaster is not None:
hosts.append(self.standbyMaster.hostname)
for seg in self.segments:
hosts.extend(seg.get_hosts())
return hosts
# --------------------------------------------------------------------
def get_master_host_names(self):
if self.hasStandbyMaster():
return [self.master.hostname, self.standbyMaster.hostname]
else:
return [self.master.hostname]
# --------------------------------------------------------------------
def get_max_dbid(self,includeExpansionSegs=False):
"""Returns the maximum dbid in the array. If includeExpansionSegs
is True, this includes the expansion segment array in the search"""
dbid = 0
for db in self.getDbList(includeExpansionSegs):
if db.getSegmentDbId() > dbid:
dbid = db.getSegmentDbId()
return dbid
# --------------------------------------------------------------------
def get_max_contentid(self, includeExpansionSegs=False):
"""Returns the maximum contentid in the array. If includeExpansionSegs
is True, this includes the expansion segment array in the search"""
content = 0
for db in self.getDbList(includeExpansionSegs):
if db.content > content:
content = db.content
return content
# --------------------------------------------------------------------
def get_segment_count(self):
return len(self.segments)
# --------------------------------------------------------------------
def get_min_primary_port(self):
"""Returns the minimum primary segment db port"""
min_primary_port = self.segments[0].primaryDB.port
for seg in self.segments:
if seg.primaryDB.port < min_primary_port:
min_primary_port = seg.primaryDB.port
return min_primary_port
# --------------------------------------------------------------------
def get_max_primary_port(self):
"""Returns the maximum primary segment db port"""
max_primary_port = self.segments[0].primaryDB.port
for seg in self.segments:
if seg.primaryDB.port > max_primary_port:
max_primary_port = seg.primaryDB.port
return max_primary_port
# --------------------------------------------------------------------
def get_min_mirror_port(self):
"""Returns the minimum mirror segment db port"""
if self.get_mirroring_enabled() is False:
raise Exception('Mirroring is not enabled')
min_mirror_port = self.segments[0].mirrorDBs[0].port
for seg in self.segments:
for db in seg.mirrorDBs:
if db.port < min_mirror_port:
min_mirror_port = db.port
return min_mirror_port
# --------------------------------------------------------------------
def get_max_mirror_port(self):
"""Returns the maximum mirror segment db port"""
if self.get_mirroring_enabled() is False:
raise Exception('Mirroring is not enabled')
max_mirror_port = self.segments[0].mirrorDBs[0].port
for seg in self.segments:
for db in seg.mirrorDBs:
if db.port > max_mirror_port:
max_mirror_port = db.port
return max_mirror_port
# --------------------------------------------------------------------
def get_min_primary_replication_port(self):
"""Returns the minimum primary segment db replication port"""
if self.get_mirroring_enabled() is False:
raise Exception('Mirroring is not enabled')
min_primary_replication_port = self.segments[0].primaryDB.replicationPort
for seg in self.segments:
if seg.primaryDB.replicationPort < min_primary_replication_port:
min_primary_replication_port = seg.primaryDB.replicationPort
return min_primary_replication_port
# --------------------------------------------------------------------
def get_max_primary_replication_port(self):
"""Returns the maximum primary segment db replication port"""
if self.get_mirroring_enabled() is False:
raise Exception('Mirroring is not enabled')
max_primary_replication_port = self.segments[0].primaryDB.replicationPort
for seg in self.segments:
if seg.primaryDB.replicationPort > max_primary_replication_port:
max_primary_replication_port = seg.primaryDB.replicationPort
return max_primary_replication_port
# --------------------------------------------------------------------
def get_min_mirror_replication_port(self):
"""Returns the minimum mirror segment db replication port"""
if self.get_mirroring_enabled() is False:
raise Exception('Mirroring is not enabled')
min_mirror_replication_port = self.segments[0].mirrorDBs[0].replicationPort
for seg in self.segments:
for db in seg.mirrorDBs:
if db.replicationPort < min_mirror_replication_port:
min_mirror_replication_port = db.replicationPort
return min_mirror_replication_port
# --------------------------------------------------------------------
def get_max_mirror_replication_port(self):
"""Returns the maximum mirror segment db replication port"""
if self.get_mirroring_enabled() is False:
raise Exception('Mirroring is not enabled')
max_mirror_replication_port = self.segments[0].mirrorDBs[0].replicationPort
for seg in self.segments:
for db in seg.mirrorDBs:
if db.replicationPort > max_mirror_replication_port:
max_mirror_replication_port = db.replicationPort
return max_mirror_replication_port
# --------------------------------------------------------------------
def get_interface_numbers(self):
"""Returns interface numbers in the array. Assumes that addresses are named
<hostname>-<int_num>. If the nodes just have <hostname> then an empty
array is returned."""
interface_nums = []
primary_hostname = self.segments[0].primaryDB.hostname
primary_address_list = []
dbList = self.getDbList()
for db in dbList:
if db.isSegmentQD() == True:
continue
if db.getSegmentHostName() == primary_hostname:
if db.getSegmentAddress() not in primary_address_list:
primary_address_list.append(db.getSegmentAddress())
for address in primary_address_list:
if address.startswith(primary_hostname) == False or len(primary_hostname) + 2 > len(address):
return []
suffix = address[len(primary_hostname):]
if len(suffix) < 2 or suffix[0] != '-' or suffix[1:].isdigit() == False:
return []
interface_nums.append(suffix[1:])
return interface_nums
# --------------------------------------------------------------------
def get_primary_count(self):
return self.numPrimarySegments
# --------------------------------------------------------------------
def get_mirroring_enabled(self):
"""Returns True if mirrors are defined"""
return len(self.segments[0].mirrorDBs) != 0
# --------------------------------------------------------------------
def get_list_of_primary_segments_on_host(self, hostname):
retValue = []
for db in self.getDbList():
if db.isSegmentPrimary(False) == True and db.getSegmentHostName() == hostname:
retValue.append(db)
return retValue
# --------------------------------------------------------------------
def get_list_of_mirror_segments_on_host(self, hostname):
retValue = []
for db in self.getDbList():
if db.isSegmentMirror(False) == True and db.getSegmentHostName() == hostname:
retValue.append(db)
return retValue
# --------------------------------------------------------------------
def get_primary_root_datadirs(self):
"""
Returns a list of primary data directories minus the <prefix><contentid>
NOTE 1:
This currently assumes that all segments are configured the same
and gets the results only from the host of segment 0
NOTE 2:
The determination of hostname is based on faulty logic
"""
primary_datadirs = []
seg0_hostname = self.segments[0].primaryDB.getSegmentAddress()
(seg0_hostname, inf_num) = get_host_interface(seg0_hostname)
for db in self.getDbList():
if db.isSegmentPrimary(False) and db.getSegmentAddress().startswith(seg0_hostname):
primary_datadirs.append(db.datadir[:db.datadir.rfind('/')])
return primary_datadirs
# --------------------------------------------------------------------
def get_mirror_root_datadirs(self):
"""
Returns a list of mirror data directories minus the <prefix><contentid>
"""
mirror_datadirs = []
seg0_hostname = self.segments[0].primaryDB.getSegmentAddress()
(seg0_hostname, inf_num) = get_host_interface(seg0_hostname)
for db in self.getDbList():
if db.isSegmentMirror(False) and db.getSegmentAddress().startswith(seg0_hostname):
mirror_datadirs.append(db.datadir[:db.datadir.rfind('/')])
return mirror_datadirs
# --------------------------------------------------------------------
def get_datadir_prefix(self):
"""
Returns the prefix portion of <prefix><contentid>
"""
start_last_dir = self.master.datadir.rfind('/') + 1
start_dir_content = self.master.datadir.rfind('-')
prefix = self.master.datadir[start_last_dir:start_dir_content]
return prefix
# --------------------------------------------------------------------
# If we've got recovered segments, and we have a matched-pair, we
# can update the catalog to "rebalance" back to our original primary.
def updateRoleForRecoveredSegs(self, dbURL):
"""
Marks the segment role to match the configured preferred_role.
"""
# walk our list of segments, checking to make sure that
# both members of the peer-group are in our recovered-list,
# save their content-id.
recovered_contents = []
for seg in self.segments:
if seg.primaryDB:
if seg.primaryDB.dbid in self.recoveredSegmentDbids:
if len(seg.mirrorDBs) > 0 and seg.mirrorDBs[0].dbid in self.recoveredSegmentDbids:
recovered_contents.append((seg.primaryDB.content, seg.primaryDB.dbid, seg.mirrorDBs[0].dbid))
conn = dbconn.connect(dbURL, True, allowSystemTableMods = 'dml')
for (content_id, primary_dbid, mirror_dbid) in recovered_contents:
sql = "UPDATE gp_segment_configuration SET role=preferred_role where content = %d" % content_id
dbconn.executeUpdateOrInsert(conn, sql, 2)
# NOTE: primary-dbid (right now) is the mirror.
sql = "INSERT INTO gp_configuration_history VALUES (now(), %d, 'Reassigned role for content %d to MIRROR')" % (primary_dbid, content_id)
dbconn.executeUpdateOrInsert(conn, sql, 1)
# NOTE: mirror-dbid (right now) is the primary.
sql = "INSERT INTO gp_configuration_history VALUES (now(), %d, 'Reassigned role for content %d to PRIMARY')" % (mirror_dbid, content_id)
dbconn.executeUpdateOrInsert(conn, sql, 1)
# We could attempt to update the segments-array.
# But the caller will re-read the configuration from the catalog.
dbconn.execSQL(conn, "COMMIT")
conn.close()
# --------------------------------------------------------------------
def addExpansionSeg(self, content, preferred_role, dbid, role,
hostname, address, port, datadir, replication_port, fileSpaces = None):
"""
Adds a segment to the gparray as an expansion segment.
Note: may work better to construct the new GpDB in gpexpand and
simply pass it in.
"""
if (content <= self.segments[-1].get_dbs()[0].content):
raise Exception('Invalid content ID for expansion segment')
segdb = GpDB(content = content,
preferred_role = preferred_role,
dbid = dbid,
role = role,
mode = MODE_SYNCHRONIZED,
status = STATUS_UP,
hostname = hostname,
address = address,
port = port,
datadir = datadir,
replicationPort = replication_port) # todo: add to parameters
if fileSpaces != None:
for fsOid in fileSpaces:
segdb.addSegmentFilespace(oid = fsOid, path = fileSpaces[fsOid])
seglen = len(self.segments)
expseglen = len(self.expansionSegments)
expseg_index = content - seglen
logger.debug('New segment index is %d' % expseg_index)
if expseglen < expseg_index + 1:
extendByNum = expseg_index - expseglen + 1
logger.debug('Extending expansion array by %d' % (extendByNum))
self.expansionSegments.extend([None] * (extendByNum))
if self.expansionSegments[expseg_index] == None:
self.expansionSegments[expseg_index] = Segment()
seg = self.expansionSegments[expseg_index]
if preferred_role == ROLE_PRIMARY:
if seg.primaryDB:
raise Exception('Duplicate content id for primary segment')
seg.addPrimary(segdb)
else:
seg.addMirror(segdb)
# --------------------------------------------------------------------
def reOrderExpansionSegs(self):
"""
The expansion segments content ID may have changed during the expansion.
This method will re-order the the segments into their proper positions.
Since there can be no gaps in the content id (see validateExpansionSegs),
the seg.expansionSegments list is the same length.
"""
seglen = len(self.segments)
expseglen = len(self.expansionSegments)
newExpansionSegments = []
newExpansionSegments.extend([None] * expseglen)
for seg in self.expansionSegments:
contentId = seg.primaryDB.getSegmentContentId()
index = contentId - seglen
newExpansionSegments[index] = seg
seg.expansionSegments = newExpansionSegments
# --------------------------------------------------------------------
def validateExpansionSegs(self):
""" Checks the segments added for various inconsistencies and errors.
"""
dbids = []
content = []
expansion_seg_count = 0
# make sure we have added at least one segment
if len(self.expansionSegments) == 0:
raise Exception('No expansion segments defined')
# how many mirrors?
mirrors_per_segment = len(self.segments[0].mirrorDBs)
for seg in self.expansionSegments:
# If a segment is 'None' that means we have a gap in the content ids
if seg is None:
raise Exception('Expansion segments do not have contiguous content ids.')
expansion_seg_count += 1
for segdb in seg.get_dbs():
dbids.append(segdb.getSegmentDbId())
if segdb.getSegmentRole() == ROLE_PRIMARY:
isprimary = True
else:
isprimary = False
content.append((segdb.getSegmentContentId(), isprimary))
# mirror count correct for this content id?
if mirrors_per_segment > 0:
if len(seg.mirrorDBs) != mirrors_per_segment:
raise Exception('Expansion segment has incorrect number of mirrors defined.')
else:
#shouldn't have any mirrors
if len(seg.mirrorDBs) != 0:
raise Exception('Expansion segment has a mirror segment defined but mirroring is not enabled.')
# check that the dbids are what they should be
dbids.sort()
# KAS Is the following really true? dbids don't need to be continuous
if dbids[0] != self.get_max_dbid() + 1:
raise Exception('Expansion segments have incorrect dbids')
for i in range(0, len(dbids) - 1):
if dbids[i] != dbids[i + 1] - 1:
raise Exception('Expansion segments have incorrect dbids')
# check that content ids are ok
valid_content = []
for i in range(self.segments[-1].primaryDB.content + 1,
self.segments[-1].primaryDB.content + 1 + len(self.expansionSegments)):
valid_content.append((i, True))
for j in range(0, mirrors_per_segment):
valid_content.append((i, False))
valid_content.sort(lambda x,y: cmp(x[0], y[0]) or cmp(x[1], y[1]))
content.sort(lambda x,y: cmp(x[0], y[0]) or cmp(x[1], y[1]))
if valid_content != content:
raise Exception('Invalid content ids')
# Check for redefinition data dirs and ports
datadirs = {}
used_ports = {}
used_replication_ports = {}
hostname = ""
for db in self.getDbList(True):
datadir = db.getSegmentDataDirectory()
hostname = db.getSegmentHostName()
port = db.getSegmentPort()
replication_port = db.getSegmentReplicationPort()
if datadirs.has_key(hostname):
if datadir in datadirs[hostname]:
raise Exception('Data directory %s used multiple times on host %s' % (datadir, hostname))
else:
datadirs[hostname].append(datadir)
else:
datadirs[hostname] = []
datadirs[hostname].append(datadir)
# Check ports
if used_ports.has_key(hostname):
if db.port in used_ports[hostname]:
raise Exception('Port %d is used multiple times on host %s' % (port, hostname))
else:
used_ports[hostname].append(db.port)
else:
used_ports[hostname] = []
used_ports[hostname].append(db.port)
# Check replication ports
if replication_port != None:
if used_replication_ports.has_key(hostname):
if replication_port in used_replication_ports[hostname]:
raise Exception('Replication Port %d is used multiple times on host %s' % (replication_port, hostname))
else:
used_replication_ports[hostname].append(replication_port)
else:
used_replication_ports[hostname] = []
used_replication_ports[hostname].append(replication_port)
# Check for redefinition of filespace dirs
dbList = self.getDbList(includeExpansionSegs = True)
hostDict = GpArray.getSegmentsByHostName(dbList)
for host in hostDict:
segList = hostDict[host]
dirList = []
for seg in segList:
dirDict = seg.getSegmentFilespaces()
for oid in dirDict:
if dirDict[oid] in dirList:
raise Exception('Data directory %s used multiple times on host %s' % (datadir, hostname))
else:
dirList.append(dirDict[oid])
# --------------------------------------------------------------------
def addExpansionHosts(self, hosts, mirror_type):
""" Adds a list of hosts to the array, using the same data
directories as the original hosts. Also adds the mirrors
based on mirror_type.
"""
# remove interface numbers if they exist
existing_hosts = []
for host in self.get_hostlist(True):
if host not in existing_hosts:
existing_hosts.append(host)
new_hosts = []
for host in hosts:
# see if we already have the host
if host in existing_hosts or host in new_hosts:
continue
else:
new_hosts.append(host)
if len(new_hosts) == 0:
raise Exception('No new hosts to add')
""" Get the first segment's host name, and use this host's configuration as a prototype """
seg0_hostname = self.segments[0].primaryDB.getSegmentHostName()
primary_list = self.get_list_of_primary_segments_on_host(seg0_hostname)
mirror_list = self.get_list_of_mirror_segments_on_host(seg0_hostname)
interface_list = self.get_interface_numbers()
base_primary_port = self.get_min_primary_port()
base_mirror_port = 0
base_primary_replication_port = None
base_mirror_replication_port = None
if mirror_type != 'none':
base_mirror_port = self.get_min_mirror_port()
base_primary_replication_port = self.get_min_primary_replication_port()
base_mirror_replication_port = self.get_min_mirror_replication_port()
prefix = self.get_datadir_prefix()
interface_list = self.get_interface_numbers()
interface_list.sort()
rows = createSegmentRowsFromSegmentList( newHostlist = new_hosts
, interface_list = interface_list
, primary_segment_list = primary_list
, primary_portbase = base_primary_port
, mirror_type = mirror_type
, mirror_segment_list = mirror_list
, mirror_portbase = base_mirror_port
, dir_prefix = prefix
, primary_replication_portbase = base_primary_replication_port
, mirror_replication_portbase = base_mirror_replication_port
)
self._fixup_and_add_expansion_segments(rows, interface_list)
# --------------------------------------------------------------------
def addExpansionDatadirs(self, datadirs, mirrordirs, mirror_type, fs_dirs = None, fs_mirror_dirs = None):
""" Adds new segments based on new data directories to both original
hosts and hosts that were added by addExpansionHosts.
"""
max_primary_port = self.get_max_primary_port()
max_mirror_port = 0
max_primary_replication_port = None
max_mirror_replication_port = None
if mirror_type != 'none':
max_mirror_port = self.get_max_mirror_port()
max_primary_replication_port = self.get_max_primary_replication_port()
max_mirror_replication_port = self.get_max_mirror_replication_port()
interface_list = self.get_interface_numbers()
interface_list.sort()
prefix = self.get_datadir_prefix()
hosts = []
# Get all the hosts to add the data dirs to
for seg in self.getSegDbList(includeExpansionSegs = True):
host = seg.getSegmentHostName()
if host not in hosts:
hosts.append(host)
# Create the rows
tempPrimaryRP = None
tempMirrorRP = None
if mirror_type != 'none':
tempPrimaryRP = max_primary_replication_port + 1
tempMirrorRP = max_mirror_replication_port + 1
rows = createSegmentRows( hostlist = hosts
, interface_list = interface_list
, primary_list = datadirs
, primary_portbase = max_primary_port + 1
, mirror_type = mirror_type
, mirror_list = mirrordirs
, mirror_portbase = max_mirror_port + 1
, dir_prefix = prefix
, primary_replication_portbase = tempPrimaryRP
, mirror_replication_portbase = tempMirrorRP
, primary_fs_list = fs_dirs
, mirror_fs_list = fs_mirror_dirs
)
self._fixup_and_add_expansion_segments(rows, interface_list)
# --------------------------------------------------------------------
def _fixup_and_add_expansion_segments(self, rows, interface_list):
"""Fixes up expansion segments added to be after the original segdbs
This includes fixing up the dbids, content ids, data directories,
interface part of the hostnames and mirrors. After this is done, it
adds them to the expansion array."""
interface_count = len(interface_list)
mirror_dict = {}
# must be sorted by isprimary, then hostname
rows.sort(lambda a,b: (cmp(b.isprimary, a.isprimary) or cmp(a.host,b.host)))
current_host = rows[0].host
curr_dbid = self.get_max_dbid(True) + 1
curr_content = self.get_max_contentid(True) + 1
# Fix up the rows with correct dbids, contentids, datadirs and interfaces
for row in rows:
hostname = row.host
address = row.address
# Add the new segment to the expansion segments array
# Remove the content id off of the datadir
new_datadir = row.fulldir[:row.fulldir.rfind(str(row.content))]
if row.isprimary == 't':
new_datadir += ('%d' % curr_content)
new_filespaces = GpDB.replaceFileSpaceContentID( fileSpaceDictionary = row.fileSpaceDictionary
, oldContent = row.content
, newContent = curr_content
)
self.addExpansionSeg(curr_content, ROLE_PRIMARY, curr_dbid,
ROLE_PRIMARY, hostname, address, int(row.port), new_datadir, row.prPort, fileSpaces = new_filespaces)
# The content id was adjusted, so we need to save it for the mirror
mirror_dict[int(row.content)] = int(curr_content)
curr_content += 1
else:
new_content = mirror_dict[int(row.content)]
new_datadir += ('%d' % int(new_content))
new_filespaces = GpDB.replaceFileSpaceContentID( fileSpaceDictionary = row.fileSpaceDictionary
, oldContent = row.content
, newContent = new_content
)
self.addExpansionSeg(new_content, ROLE_MIRROR, curr_dbid,
ROLE_MIRROR, hostname, address, int(row.port), new_datadir, row.prPort, fileSpaces = new_filespaces)
curr_dbid += 1
def guessIsMultiHome(self):
"""
Guess whether self is a multi-home (multiple interfaces per node) cluster
"""
segments = self.getSegDbList()
byHost = GpArray.getSegmentsByHostName(segments)
byAddress = GpArray.getSegmentsGroupedByValue(segments, GpDB.getSegmentAddress)
return len(byHost) != len(byAddress)
def guessIsSpreadMirror(self):
"""
Guess whether self is a spread mirroring configuration.
"""
if not self.hasMirrors:
return False
mirrors = [seg for seg in self.getSegDbList() if seg.isSegmentMirror(current_role=False)]
primaries = [seg for seg in self.getSegDbList() if seg.isSegmentPrimary(current_role=False)]
assert len(mirrors) == len(primaries)
primaryHostNameToMirrorHostNameSet = {}
mirrorsByContentId = GpArray.getSegmentsByContentId(mirrors)
for primary in primaries:
mir = mirrorsByContentId[primary.getSegmentContentId()][0]
if primary.getSegmentHostName() not in primaryHostNameToMirrorHostNameSet:
primaryHostNameToMirrorHostNameSet[primary.getSegmentHostName()] = {}
primaryMap = primaryHostNameToMirrorHostNameSet[primary.getSegmentHostName()]
if mir.getSegmentHostName() not in primaryMap:
primaryMap[mir.getSegmentHostName()] = 0
primaryMap[mir.getSegmentHostName()] += 1
"""
This primary host has more than one segment on a single host: assume group mirroring!
"""
if primaryMap[mir.getSegmentHostName()] > 1:
return False
"""
Fall-through -- note that for a 2 host system with 1 segment per host, this will cause the guess to be 'spread'
"""
return True
@staticmethod
def getSegmentsGroupedByValue(segments, segmentMethodToGetValue):
result = {}
for segment in segments:
value = segmentMethodToGetValue(segment)
arr = result.get(value)
if arr is None:
result[value] = arr = []
arr.append(segment)
return result
@staticmethod
def getSegmentsByHostName(segments):
"""
Returns a map from segment host name to an array of segments (GpDB objects)
"""
return GpArray.getSegmentsGroupedByValue(segments, GpDB.getSegmentHostName)
@staticmethod
def getSegmentsByContentId(segments):
"""
Returns a map from segment contentId to an array of segments (GpDB objects)
"""
return GpArray.getSegmentsGroupedByValue(segments, GpDB.getSegmentContentId )
def getNumSegmentContents(self):
return len(GpArray.getSegmentsByContentId(self.getSegDbList()))
def getSegmentsAsLoadedFromDb(self):
"""
To be called by the configuration providers only
"""
return self.__segmentsAsLoadedFromDb
def setSegmentsAsLoadedFromDb(self, segments):
"""
To be called by the configuration providers only
"""
self.__segmentsAsLoadedFromDb = segments
def get_segment_hosts(master_port):
"""
"""
gparray = GpArray.initFromCatalog( dbconn.DbURL(port=master_port), utility=True )
segments = GpArray.getSegmentsByHostName( gparray.getDbList() )
return segments.keys()
def get_session_ids(master_port):
"""
"""
conn = dbconn.connect( dbconn.DbURL(port=master_port), utility=True )
try:
rows = dbconn.execSQL(conn, "SELECT sess_id from pg_stat_activity where sess_id > 0;")
ids = set(row[0] for row in rows)
return ids
finally:
conn.close()
def get_gparray_from_config():
# imports below, when moved to the top, seem to cause an import error in a unit test because of dependency issue
from gppylib.system import configurationInterface
from gppylib.system import configurationImplGpdb
from gppylib.system.environment import GpMasterEnvironment
master_data_dir = os.environ['MASTER_DATA_DIRECTORY']
gpEnv = GpMasterEnvironment(master_data_dir, False)
configurationInterface.registerConfigurationProvider(
configurationImplGpdb.GpConfigurationProviderUsingGpdbCatalog())
confProvider = configurationInterface.getConfigurationProvider().initializeProvider(gpEnv.getMasterPort())
return confProvider.loadSystemConfig(useUtilityMode=True)
# === EOF ====
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
32585,
1168,
453,
3277,
9079,
14,
2900,
5924,
5702,
14,
199,
3,
199,
624,
523,
486,
462,
803,
14,
647,
26,
339,
22493,
7795,
3992,
6144,
2897,
2556,
402,
282,
272,
32585,
1168,
453,
1625,
26,
2541,
598,
80,
3836,
446,
710,
5062,
3217,
446,
3245,
402,
1006,
598,
80,
2846,
4453,
376,
1625,
489,
598,
80,
2846,
259,
446,
8469,
2897,
2556,
367,
282,
2849,
1592,
344,
489,
29858,
446,
3245,
402,
1006,
598,
80,
2846,
543,
314,
2011,
1564,
1305,
199,
624,
199,
199,
3,
7819,
21326,
199,
504,
2197,
492,
1434,
199,
646,
1331,
199,
646,
5190,
199,
199,
504,
15852,
24111,
14,
1208,
492,
1104,
1763,
403,
12,
1104,
1831,
3241,
199,
504,
15852,
24111,
259,
492,
15852,
793,
199,
504,
15852,
24111,
14,
697,
492,
1592,
1631,
199,
504,
15852,
24111,
14,
4927,
1023,
492,
598,
80,
3353,
199,
504,
15852,
24111,
14,
4405,
14,
11864,
492,
627,
199,
646,
747,
199,
199,
12711,
63,
5110,
9136,
275,
650,
19730,
263,
327,
20109,
402,
314,
2656,
1584,
1142,
199,
199,
2921,
275,
15852,
793,
14,
362,
63,
885,
63,
2921,
342,
199,
199,
19374,
568,
2594,
63,
3817,
63,
5763,
21287,
63,
16436,
275,
298,
2319,
63,
3619,
2,
199,
199,
15468,
63,
31035,
275,
283,
80,
7,
199,
15468,
63,
45,
3927,
50,
726,
221,
275,
283,
77,
7,
199,
5600,
63,
6245,
654,
221,
275,
359,
15468,
63,
31035,
12,
9769,
906,
63,
45,
3927,
50,
726,
61,
199,
199,
3,
9672,
15852,
63,
9255,
63,
4758,
4719,
1338,
370,
1338,
687,
15852,
63,
3327,
12324,
14,
199,
15468,
63,
2566,
63,
6963,
63,
5443,
275,
1052,
199,
21981,
63,
6963,
63,
31035,
275,
298,
14908,
12520,
2,
199,
21981,
63,
6963,
63,
45,
3927,
50,
726,
221,
275,
298,
28034,
12520,
2,
199,
15468,
63,
2566,
63,
6963,
63,
5443,
59,
15468,
63,
31035,
61,
275,
428,
4680,
63,
6963,
63,
31035,
199,
15468,
63,
2566,
63,
6963,
63,
5443,
59,
15468,
63,
45,
3927,
50,
726,
61,
221,
275,
428,
4680,
63,
6963,
63,
45,
3927,
50,
726,
421,
199,
6305,
63,
2160,
259,
275,
283,
85,
7,
199,
6305,
63,
8819,
221,
275,
283,
68,
7,
199,
5600,
63,
6305,
275,
359,
6305,
63,
2160,
12,
18460,
63,
8819,
61,
199,
199,
6963,
63,
4609,
63,
13768,
18732,
275,
2125,
5185,
327,
949,
15216,
316,
199,
6963,
63,
16062,
27896,
275,
283,
67,
7,
4483,
327,
570,
1155,
2050,
199,
6963,
63,
4669,
27493,
18732,
275,
283,
83,
7,
463,
327,
570,
1155,
15354,
1759,
199,
6963,
63,
3830,
57,
27493,
22800,
275,
283,
82,
7,
3322,
327,
199,
199,
3,
9672,
15852,
63,
9255,
63,
4758,
818,
1338,
370,
1338,
2203,
3297,
687,
15852,
63,
3327,
12324,
14,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
275,
1052,
199,
21981,
63,
3998,
63,
6689,
63,
4609,
63,
13768,
18732,
259,
275,
298,
1763,
23031,
2,
199,
21981,
63,
3998,
63,
6689,
63,
568,
63,
16062,
63,
19755,
1206,
275,
298,
607,
4001,
23785,
2,
199,
21981,
63,
3998,
63,
6689,
63,
4669,
27493,
18732,
755,
275,
298,
607,
10878,
2,
199,
21981,
63,
3998,
63,
6689,
63,
568,
63,
3830,
57,
6389,
3515,
275,
298,
607,
1322,
1870,
2,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
59,
6963,
63,
4609,
63,
13768,
18732,
61,
257,
275,
428,
4680,
63,
3998,
63,
6689,
63,
4609,
63,
13768,
18732,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
59,
6963,
63,
16062,
27896,
61,
258,
275,
428,
4680,
63,
3998,
63,
6689,
63,
568,
63,
16062,
63,
19755,
1206,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
59,
6963,
63,
4669,
27493,
18732,
61,
420,
275,
428,
4680,
63,
3998,
63,
6689,
63,
4669,
27493,
18732,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
59,
6963,
63,
3830,
57,
27493,
22800,
61,
275,
428,
4680,
63,
3998,
63,
6689,
63,
568,
63,
3830,
57,
6389,
199,
199,
3,
29858,
2223,
1338,
2138,
687,
15852,
63,
3327,
12324,
14,
199,
27001,
63,
6689,
63,
4609,
63,
13768,
18732,
5185,
275,
298,
1763,
23031,
2,
199,
27001,
63,
6689,
63,
13768,
22800,
4483,
275,
298,
5733,
2072,
2,
199,
27001,
63,
6689,
63,
568,
63,
16062,
63,
19755,
1206,
63,
12191,
12039,
275,
298,
607,
4001,
23785,
21881,
2,
199,
27001,
63,
6689,
63,
568,
63,
3830,
30644,
1028,
50,
5622,
12039,
3698,
275,
298,
607,
1322,
1870,
21881,
2,
199,
27001,
63,
6689,
63,
568,
63,
22012,
63,
12191,
12039,
3322,
275,
298,
607,
10878,
21881,
2,
199,
27001,
63,
6689,
63,
22579,
12793,
275,
298,
17960,
2,
199,
27001,
63,
6689,
63,
16062,
63,
19755,
1206,
63,
16205,
420,
275,
298,
4001,
23785,
15049,
2,
199,
27001,
63,
6689,
63,
2794,
12793,
275,
298,
16665,
2,
199,
27001,
63,
6689,
63,
24340,
8819,
63,
28988,
3777,
275,
298,
20043,
4540,
3198,
2,
199,
27001,
63,
6689,
63,
24340,
8819,
10473,
275,
298,
20043,
2,
199,
27001,
63,
6689,
63,
1469,
19464,
63,
24340,
8819,
3322,
275,
298,
24481,
20043,
2,
421,
199,
5600,
63,
6963,
275,
359,
272,
27065,
63,
4669,
27493,
18732,
12,
272,
27065,
63,
16062,
27896,
12,
272,
27065,
63,
3830,
57,
27493,
22800,
12,
199,
61,
199,
6963,
63,
13837,
51,
275,
469,
272,
27065,
63,
16062,
27896,
26,
298,
4001,
17507,
316,
401,
272,
27065,
63,
4669,
27493,
18732,
26,
298,
21814,
1759,
401,
272,
27065,
63,
3830,
57,
27493,
22800,
26,
298,
1322,
6030,
9147,
2,
199,
93,
199,
199,
3,
5723,
787,
1006,
314,
1686,
6363,
5062,
15,
12324,
6342,
883,
199,
3,
506,
315,
14,
221,
6184,
2897,
1163,
2419,
642,
911,
7675,
314,
199,
3,
481,
9730,
2165,
605,
370,
330,
5985,
3224,
314,
5288,
2963,
4133,
5133,
314,
199,
3,
2897,
365,
30156,
14,
221,
11842,
12,
5062,
436,
15216,
10618,
199,
3,
370,
314,
11998,
1453,
4719,
12,
440,
314,
14388,
63,
3756,
14,
199,
3,
199,
3,
710,
1475,
402,
314,
6346,
787,
26,
199,
3,
259,
8642
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
334,
67,
9,
32585,
1168,
453,
3277,
9079,
14,
2900,
5924,
5702,
14,
199,
3,
199,
624,
523,
486,
462,
803,
14,
647,
26,
339,
22493,
7795,
3992,
6144,
2897,
2556,
402,
282,
272,
32585,
1168,
453,
1625,
26,
2541,
598,
80,
3836,
446,
710,
5062,
3217,
446,
3245,
402,
1006,
598,
80,
2846,
4453,
376,
1625,
489,
598,
80,
2846,
259,
446,
8469,
2897,
2556,
367,
282,
2849,
1592,
344,
489,
29858,
446,
3245,
402,
1006,
598,
80,
2846,
543,
314,
2011,
1564,
1305,
199,
624,
199,
199,
3,
7819,
21326,
199,
504,
2197,
492,
1434,
199,
646,
1331,
199,
646,
5190,
199,
199,
504,
15852,
24111,
14,
1208,
492,
1104,
1763,
403,
12,
1104,
1831,
3241,
199,
504,
15852,
24111,
259,
492,
15852,
793,
199,
504,
15852,
24111,
14,
697,
492,
1592,
1631,
199,
504,
15852,
24111,
14,
4927,
1023,
492,
598,
80,
3353,
199,
504,
15852,
24111,
14,
4405,
14,
11864,
492,
627,
199,
646,
747,
199,
199,
12711,
63,
5110,
9136,
275,
650,
19730,
263,
327,
20109,
402,
314,
2656,
1584,
1142,
199,
199,
2921,
275,
15852,
793,
14,
362,
63,
885,
63,
2921,
342,
199,
199,
19374,
568,
2594,
63,
3817,
63,
5763,
21287,
63,
16436,
275,
298,
2319,
63,
3619,
2,
199,
199,
15468,
63,
31035,
275,
283,
80,
7,
199,
15468,
63,
45,
3927,
50,
726,
221,
275,
283,
77,
7,
199,
5600,
63,
6245,
654,
221,
275,
359,
15468,
63,
31035,
12,
9769,
906,
63,
45,
3927,
50,
726,
61,
199,
199,
3,
9672,
15852,
63,
9255,
63,
4758,
4719,
1338,
370,
1338,
687,
15852,
63,
3327,
12324,
14,
199,
15468,
63,
2566,
63,
6963,
63,
5443,
275,
1052,
199,
21981,
63,
6963,
63,
31035,
275,
298,
14908,
12520,
2,
199,
21981,
63,
6963,
63,
45,
3927,
50,
726,
221,
275,
298,
28034,
12520,
2,
199,
15468,
63,
2566,
63,
6963,
63,
5443,
59,
15468,
63,
31035,
61,
275,
428,
4680,
63,
6963,
63,
31035,
199,
15468,
63,
2566,
63,
6963,
63,
5443,
59,
15468,
63,
45,
3927,
50,
726,
61,
221,
275,
428,
4680,
63,
6963,
63,
45,
3927,
50,
726,
421,
199,
6305,
63,
2160,
259,
275,
283,
85,
7,
199,
6305,
63,
8819,
221,
275,
283,
68,
7,
199,
5600,
63,
6305,
275,
359,
6305,
63,
2160,
12,
18460,
63,
8819,
61,
199,
199,
6963,
63,
4609,
63,
13768,
18732,
275,
2125,
5185,
327,
949,
15216,
316,
199,
6963,
63,
16062,
27896,
275,
283,
67,
7,
4483,
327,
570,
1155,
2050,
199,
6963,
63,
4669,
27493,
18732,
275,
283,
83,
7,
463,
327,
570,
1155,
15354,
1759,
199,
6963,
63,
3830,
57,
27493,
22800,
275,
283,
82,
7,
3322,
327,
199,
199,
3,
9672,
15852,
63,
9255,
63,
4758,
818,
1338,
370,
1338,
2203,
3297,
687,
15852,
63,
3327,
12324,
14,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
275,
1052,
199,
21981,
63,
3998,
63,
6689,
63,
4609,
63,
13768,
18732,
259,
275,
298,
1763,
23031,
2,
199,
21981,
63,
3998,
63,
6689,
63,
568,
63,
16062,
63,
19755,
1206,
275,
298,
607,
4001,
23785,
2,
199,
21981,
63,
3998,
63,
6689,
63,
4669,
27493,
18732,
755,
275,
298,
607,
10878,
2,
199,
21981,
63,
3998,
63,
6689,
63,
568,
63,
3830,
57,
6389,
3515,
275,
298,
607,
1322,
1870,
2,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
59,
6963,
63,
4609,
63,
13768,
18732,
61,
257,
275,
428,
4680,
63,
3998,
63,
6689,
63,
4609,
63,
13768,
18732,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
59,
6963,
63,
16062,
27896,
61,
258,
275,
428,
4680,
63,
3998,
63,
6689,
63,
568,
63,
16062,
63,
19755,
1206,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
59,
6963,
63,
4669,
27493,
18732,
61,
420,
275,
428,
4680,
63,
3998,
63,
6689,
63,
4669,
27493,
18732,
199,
6963,
63,
2566,
63,
3998,
63,
6689,
63,
5443,
59,
6963,
63,
3830,
57,
27493,
22800,
61,
275,
428,
4680,
63,
3998,
63,
6689,
63,
568,
63,
3830,
57,
6389,
199,
199,
3,
29858,
2223,
1338,
2138,
687,
15852,
63,
3327,
12324,
14,
199,
27001,
63,
6689,
63,
4609,
63,
13768,
18732,
5185,
275,
298,
1763,
23031,
2,
199,
27001,
63,
6689,
63,
13768,
22800,
4483,
275,
298,
5733,
2072,
2,
199,
27001,
63,
6689,
63,
568,
63,
16062,
63,
19755,
1206,
63,
12191,
12039,
275,
298,
607,
4001,
23785,
21881,
2,
199,
27001,
63,
6689,
63,
568,
63,
3830,
30644,
1028,
50,
5622,
12039,
3698,
275,
298,
607,
1322,
1870,
21881,
2,
199,
27001,
63,
6689,
63,
568,
63,
22012,
63,
12191,
12039,
3322,
275,
298,
607,
10878,
21881,
2,
199,
27001,
63,
6689,
63,
22579,
12793,
275,
298,
17960,
2,
199,
27001,
63,
6689,
63,
16062,
63,
19755,
1206,
63,
16205,
420,
275,
298,
4001,
23785,
15049,
2,
199,
27001,
63,
6689,
63,
2794,
12793,
275,
298,
16665,
2,
199,
27001,
63,
6689,
63,
24340,
8819,
63,
28988,
3777,
275,
298,
20043,
4540,
3198,
2,
199,
27001,
63,
6689,
63,
24340,
8819,
10473,
275,
298,
20043,
2,
199,
27001,
63,
6689,
63,
1469,
19464,
63,
24340,
8819,
3322,
275,
298,
24481,
20043,
2,
421,
199,
5600,
63,
6963,
275,
359,
272,
27065,
63,
4669,
27493,
18732,
12,
272,
27065,
63,
16062,
27896,
12,
272,
27065,
63,
3830,
57,
27493,
22800,
12,
199,
61,
199,
6963,
63,
13837,
51,
275,
469,
272,
27065,
63,
16062,
27896,
26,
298,
4001,
17507,
316,
401,
272,
27065,
63,
4669,
27493,
18732,
26,
298,
21814,
1759,
401,
272,
27065,
63,
3830,
57,
27493,
22800,
26,
298,
1322,
6030,
9147,
2,
199,
93,
199,
199,
3,
5723,
787,
1006,
314,
1686,
6363,
5062,
15,
12324,
6342,
883,
199,
3,
506,
315,
14,
221,
6184,
2897,
1163,
2419,
642,
911,
7675,
314,
199,
3,
481,
9730,
2165,
605,
370,
330,
5985,
3224,
314,
5288,
2963,
4133,
5133,
314,
199,
3,
2897,
365,
30156,
14,
221,
11842,
12,
5062,
436,
15216,
10618,
199,
3,
370,
314,
11998,
1453,
4719,
12,
440,
314,
14388,
63,
3756,
14,
199,
3,
199,
3,
710,
1475,
402,
314,
6346,
787,
26,
199,
3,
259,
8642,
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,
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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
] |
pearltrees/tree-shape-visualization
|
tools/languageSynchronizer/InterLanguage.py
|
2
|
1294
|
import FrenchFile
import EnglishFile
def compareEnFrAux(enFile, frFile):
notUsed = []
while 1:
line = enFile.getNextLine()
token = line.split('=').pop(0).split(' ').pop(0)
if token:
if frFile.findToken(token) == 0:
notUsed.append(line)
else:
return notUsed
def compareFrEnAux(enFile, frFile):
notUsed = []
while 1:
token = frFile.getNextToken()
if token:
if enFile.findToken(token) == 0:
notUsed.append(token)
else:
return notUsed
def compareEnFr():
frFile = FrenchFile.frenchFile()
frFile.openFile()
enFile = EnglishFile.englishFile()
enFile.openFile()
ret = compareEnFrAux(enFile,frFile )
frFile.closeFile()
enFile.closeFile()
return ret
def compareFrEn():
frFile = FrenchFile.frenchFile()
frFile.openFile()
enFile = EnglishFile.englishFile()
enFile.openFile()
ret = compareFrEnAux(enFile,frFile)
frFile.closeFile()
enFile.closeFile()
return ret
#listNotUsed = compareEnFr()
#print " "
#print " "
#print "----------- There is in english file and not in french file -----------"
#for item in listNotUsed:
# print item
|
mit
|
[
646,
481,
15148,
1173,
199,
646,
20144,
1173,
199,
199,
318,
6540,
1327,
13848,
30731,
8,
287,
1173,
12,
9513,
1173,
304,
339,
440,
9167,
275,
942,
2286,
1830,
413,
26,
267,
1004,
275,
655,
1173,
14,
362,
5765,
3049,
342,
267,
1526,
275,
1004,
14,
1294,
26800,
1959,
1935,
8,
16,
680,
1294,
360,
27274,
1935,
8,
16,
9,
267,
340,
1526,
26,
288,
340,
9513,
1173,
14,
1623,
3264,
8,
1418,
9,
508,
378,
26,
355,
440,
9167,
14,
740,
8,
604,
9,
267,
587,
26,
288,
372,
440,
9167,
199,
199,
318,
6540,
13848,
1327,
30731,
8,
287,
1173,
12,
9513,
1173,
304,
258,
339,
440,
9167,
275,
942,
2286,
1830,
413,
26,
267,
1526,
275,
9513,
1173,
14,
362,
5765,
3264,
342,
267,
340,
1526,
26,
288,
340,
655,
1173,
14,
1623,
3264,
8,
1418,
9,
508,
378,
26,
355,
440,
9167,
14,
740,
8,
1418,
9,
267,
587,
26,
288,
372,
440,
9167,
199,
199,
318,
6540,
1327,
13848,
837,
5591,
9513,
1173,
275,
481,
15148,
1173,
14,
20874,
1173,
342,
272,
9513,
1173,
14,
1490,
1173,
342,
339,
655,
1173,
221,
275,
20144,
1173,
14,
17872,
1173,
342,
272,
655,
1173,
14,
1490,
1173,
342,
339,
2203,
275,
6540,
1327,
13848,
30731,
8,
287,
1173,
12,
4391,
1173,
776,
339,
9513,
1173,
14,
1600,
1173,
342,
272,
655,
1173,
14,
1600,
1173,
342,
2286,
372,
2203,
199,
199,
318,
6540,
13848,
1327,
837,
2286,
9513,
1173,
275,
481,
15148,
1173,
14,
20874,
1173,
342,
272,
9513,
1173,
14,
1490,
1173,
342,
339,
655,
1173,
221,
275,
20144,
1173,
14,
17872,
1173,
342,
272,
655,
1173,
14,
1490,
1173,
342,
339,
2203,
275,
6540,
13848,
1327,
30731,
8,
287,
1173,
12,
4391,
1173,
9,
2286,
9513,
1173,
14,
1600,
1173,
342,
272,
655,
1173,
14,
1600,
1173,
342,
2286,
372,
2203,
199,
199,
3,
513,
1763,
9167,
275,
6540,
1327,
13848,
342,
199,
3,
1361,
298,
298,
199,
3,
1361,
298,
298,
199,
3,
1361,
298,
13715,
6006,
365,
315,
20171,
1891,
570,
436,
440,
315,
289,
15148,
570,
3001,
2595,
2,
199,
3,
509,
1242,
315,
769,
1763,
9167,
26,
199,
3,
259,
870,
1242,
260,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
481,
15148,
1173,
199,
646,
20144,
1173,
199,
199,
318,
6540,
1327,
13848,
30731,
8,
287,
1173,
12,
9513,
1173,
304,
339,
440,
9167,
275,
942,
2286,
1830,
413,
26,
267,
1004,
275,
655,
1173,
14,
362,
5765,
3049,
342,
267,
1526,
275,
1004,
14,
1294,
26800,
1959,
1935,
8,
16,
680,
1294,
360,
27274,
1935,
8,
16,
9,
267,
340,
1526,
26,
288,
340,
9513,
1173,
14,
1623,
3264,
8,
1418,
9,
508,
378,
26,
355,
440,
9167,
14,
740,
8,
604,
9,
267,
587,
26,
288,
372,
440,
9167,
199,
199,
318,
6540,
13848,
1327,
30731,
8,
287,
1173,
12,
9513,
1173,
304,
258,
339,
440,
9167,
275,
942,
2286,
1830,
413,
26,
267,
1526,
275,
9513,
1173,
14,
362,
5765,
3264,
342,
267,
340,
1526,
26,
288,
340,
655,
1173,
14,
1623,
3264,
8,
1418,
9,
508,
378,
26,
355,
440,
9167,
14,
740,
8,
1418,
9,
267,
587,
26,
288,
372,
440,
9167,
199,
199,
318,
6540,
1327,
13848,
837,
5591,
9513,
1173,
275,
481,
15148,
1173,
14,
20874,
1173,
342,
272,
9513,
1173,
14,
1490,
1173,
342,
339,
655,
1173,
221,
275,
20144,
1173,
14,
17872,
1173,
342,
272,
655,
1173,
14,
1490,
1173,
342,
339,
2203,
275,
6540,
1327,
13848,
30731,
8,
287,
1173,
12,
4391,
1173,
776,
339,
9513,
1173,
14,
1600,
1173,
342,
272,
655,
1173,
14,
1600,
1173,
342,
2286,
372,
2203,
199,
199,
318,
6540,
13848,
1327,
837,
2286,
9513,
1173,
275,
481,
15148,
1173,
14,
20874,
1173,
342,
272,
9513,
1173,
14,
1490,
1173,
342,
339,
655,
1173,
221,
275,
20144,
1173,
14,
17872,
1173,
342,
272,
655,
1173,
14,
1490,
1173,
342,
339,
2203,
275,
6540,
13848,
1327,
30731,
8,
287,
1173,
12,
4391,
1173,
9,
2286,
9513,
1173,
14,
1600,
1173,
342,
272,
655,
1173,
14,
1600,
1173,
342,
2286,
372,
2203,
199,
199,
3,
513,
1763,
9167,
275,
6540,
1327,
13848,
342,
199,
3,
1361,
298,
298,
199,
3,
1361,
298,
298,
199,
3,
1361,
298,
13715,
6006,
365,
315,
20171,
1891,
570,
436,
440,
315,
289,
15148,
570,
3001,
2595,
2,
199,
3,
509,
1242,
315,
769,
1763,
9167,
26,
199,
3,
259,
870,
1242,
260,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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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
] |
nvoron23/arangodb
|
3rdParty/V8-4.3.61/tools/unittests/run_perf_test.py
|
27
|
15287
|
#!/usr/bin/env python
# Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from collections import namedtuple
import coverage
import json
from mock import DEFAULT
from mock import MagicMock
import os
from os import path, sys
import shutil
import tempfile
import unittest
# Requires python-coverage and python-mock. Native python coverage
# version >= 3.7.1 should be installed to get the best speed.
TEST_WORKSPACE = path.join(tempfile.gettempdir(), "test-v8-run-perf")
V8_JSON = {
"path": ["."],
"binary": "d7",
"flags": ["--flag"],
"main": "run.js",
"run_count": 1,
"results_regexp": "^%s: (.+)$",
"tests": [
{"name": "Richards"},
{"name": "DeltaBlue"},
]
}
V8_NESTED_SUITES_JSON = {
"path": ["."],
"flags": ["--flag"],
"run_count": 1,
"units": "score",
"tests": [
{"name": "Richards",
"path": ["richards"],
"binary": "d7",
"main": "run.js",
"resources": ["file1.js", "file2.js"],
"run_count": 2,
"results_regexp": "^Richards: (.+)$"},
{"name": "Sub",
"path": ["sub"],
"tests": [
{"name": "Leaf",
"path": ["leaf"],
"run_count_x64": 3,
"units": "ms",
"main": "run.js",
"results_regexp": "^Simple: (.+) ms.$"},
]
},
{"name": "DeltaBlue",
"path": ["delta_blue"],
"main": "run.js",
"flags": ["--flag2"],
"results_regexp": "^DeltaBlue: (.+)$"},
{"name": "ShouldntRun",
"path": ["."],
"archs": ["arm"],
"main": "run.js"},
]
}
V8_GENERIC_JSON = {
"path": ["."],
"binary": "cc",
"flags": ["--flag"],
"generic": True,
"run_count": 1,
"units": "ms",
}
Output = namedtuple("Output", "stdout, stderr, timed_out")
class PerfTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.base = path.dirname(path.dirname(path.abspath(__file__)))
sys.path.append(cls.base)
cls._cov = coverage.coverage(
include=([os.path.join(cls.base, "run_perf.py")]))
cls._cov.start()
import run_perf
from testrunner.local import commands
global commands
global run_perf
@classmethod
def tearDownClass(cls):
cls._cov.stop()
print ""
print cls._cov.report()
def setUp(self):
self.maxDiff = None
if path.exists(TEST_WORKSPACE):
shutil.rmtree(TEST_WORKSPACE)
os.makedirs(TEST_WORKSPACE)
def tearDown(self):
if path.exists(TEST_WORKSPACE):
shutil.rmtree(TEST_WORKSPACE)
def _WriteTestInput(self, json_content):
self._test_input = path.join(TEST_WORKSPACE, "test.json")
with open(self._test_input, "w") as f:
f.write(json.dumps(json_content))
def _MockCommand(self, *args, **kwargs):
# Fake output for each test run.
test_outputs = [Output(stdout=arg,
stderr=None,
timed_out=kwargs.get("timed_out", False))
for arg in args[1]]
def execute(*args, **kwargs):
return test_outputs.pop()
commands.Execute = MagicMock(side_effect=execute)
# Check that d8 is called from the correct cwd for each test run.
dirs = [path.join(TEST_WORKSPACE, arg) for arg in args[0]]
def chdir(*args, **kwargs):
self.assertEquals(dirs.pop(), args[0])
os.chdir = MagicMock(side_effect=chdir)
def _CallMain(self, *args):
self._test_output = path.join(TEST_WORKSPACE, "results.json")
all_args=[
"--json-test-results",
self._test_output,
self._test_input,
]
all_args += args
return run_perf.Main(all_args)
def _LoadResults(self):
with open(self._test_output) as f:
return json.load(f)
def _VerifyResults(self, suite, units, traces):
self.assertEquals([
{"units": units,
"graphs": [suite, trace["name"]],
"results": trace["results"],
"stddev": trace["stddev"]} for trace in traces],
self._LoadResults()["traces"])
def _VerifyErrors(self, errors):
self.assertEquals(errors, self._LoadResults()["errors"])
def _VerifyMock(self, binary, *args, **kwargs):
arg = [path.join(path.dirname(self.base), binary)]
arg += args
commands.Execute.assert_called_with(
arg, timeout=kwargs.get("timeout", 60))
def _VerifyMockMultiple(self, *args, **kwargs):
expected = []
for arg in args:
a = [path.join(path.dirname(self.base), arg[0])]
a += arg[1:]
expected.append(((a,), {"timeout": kwargs.get("timeout", 60)}))
self.assertEquals(expected, commands.Execute.call_args_list)
def testOneRun(self):
self._WriteTestInput(V8_JSON)
self._MockCommand(["."], ["x\nRichards: 1.234\nDeltaBlue: 10657567\ny\n"])
self.assertEquals(0, self._CallMain())
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["1.234"], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
])
self._VerifyErrors([])
self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")
def testOneRunWithTestFlags(self):
test_input = dict(V8_JSON)
test_input["test_flags"] = ["2", "test_name"]
self._WriteTestInput(test_input)
self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567"])
self.assertEquals(0, self._CallMain())
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["1.234"], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
])
self._VerifyErrors([])
self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js",
"--", "2", "test_name")
def testTwoRuns_Units_SuiteName(self):
test_input = dict(V8_JSON)
test_input["run_count"] = 2
test_input["name"] = "v8"
test_input["units"] = "ms"
self._WriteTestInput(test_input)
self._MockCommand([".", "."],
["Richards: 100\nDeltaBlue: 200\n",
"Richards: 50\nDeltaBlue: 300\n"])
self.assertEquals(0, self._CallMain())
self._VerifyResults("v8", "ms", [
{"name": "Richards", "results": ["50.0", "100.0"], "stddev": ""},
{"name": "DeltaBlue", "results": ["300.0", "200.0"], "stddev": ""},
])
self._VerifyErrors([])
self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")
def testTwoRuns_SubRegexp(self):
test_input = dict(V8_JSON)
test_input["run_count"] = 2
del test_input["results_regexp"]
test_input["tests"][0]["results_regexp"] = "^Richards: (.+)$"
test_input["tests"][1]["results_regexp"] = "^DeltaBlue: (.+)$"
self._WriteTestInput(test_input)
self._MockCommand([".", "."],
["Richards: 100\nDeltaBlue: 200\n",
"Richards: 50\nDeltaBlue: 300\n"])
self.assertEquals(0, self._CallMain())
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["50.0", "100.0"], "stddev": ""},
{"name": "DeltaBlue", "results": ["300.0", "200.0"], "stddev": ""},
])
self._VerifyErrors([])
self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")
def testNestedSuite(self):
self._WriteTestInput(V8_NESTED_SUITES_JSON)
self._MockCommand(["delta_blue", "sub/leaf", "richards"],
["DeltaBlue: 200\n",
"Simple: 1 ms.\n",
"Simple: 2 ms.\n",
"Simple: 3 ms.\n",
"Richards: 100\n",
"Richards: 50\n"])
self.assertEquals(0, self._CallMain())
self.assertEquals([
{"units": "score",
"graphs": ["test", "Richards"],
"results": ["50.0", "100.0"],
"stddev": ""},
{"units": "ms",
"graphs": ["test", "Sub", "Leaf"],
"results": ["3.0", "2.0", "1.0"],
"stddev": ""},
{"units": "score",
"graphs": ["test", "DeltaBlue"],
"results": ["200.0"],
"stddev": ""},
], self._LoadResults()["traces"])
self._VerifyErrors([])
self._VerifyMockMultiple(
(path.join("out", "x64.release", "d7"), "--flag", "run.js"),
(path.join("out", "x64.release", "d7"), "--flag", "run.js"),
(path.join("out", "x64.release", "d8"), "--flag", "run.js"),
(path.join("out", "x64.release", "d8"), "--flag", "run.js"),
(path.join("out", "x64.release", "d8"), "--flag", "run.js"),
(path.join("out", "x64.release", "d8"), "--flag", "--flag2", "run.js"))
def testOneRunStdDevRegExp(self):
test_input = dict(V8_JSON)
test_input["stddev_regexp"] = "^%s\-stddev: (.+)$"
self._WriteTestInput(test_input)
self._MockCommand(["."], ["Richards: 1.234\nRichards-stddev: 0.23\n"
"DeltaBlue: 10657567\nDeltaBlue-stddev: 106\n"])
self.assertEquals(0, self._CallMain())
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["1.234"], "stddev": "0.23"},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": "106"},
])
self._VerifyErrors([])
self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")
def testTwoRunsStdDevRegExp(self):
test_input = dict(V8_JSON)
test_input["stddev_regexp"] = "^%s\-stddev: (.+)$"
test_input["run_count"] = 2
self._WriteTestInput(test_input)
self._MockCommand(["."], ["Richards: 3\nRichards-stddev: 0.7\n"
"DeltaBlue: 6\nDeltaBlue-boom: 0.9\n",
"Richards: 2\nRichards-stddev: 0.5\n"
"DeltaBlue: 5\nDeltaBlue-stddev: 0.8\n"])
self.assertEquals(1, self._CallMain())
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["2.0", "3.0"], "stddev": "0.7"},
{"name": "DeltaBlue", "results": ["5.0", "6.0"], "stddev": "0.8"},
])
self._VerifyErrors(
["Test Richards should only run once since a stddev is provided "
"by the test.",
"Test DeltaBlue should only run once since a stddev is provided "
"by the test.",
"Regexp \"^DeltaBlue\-stddev: (.+)$\" didn't match for test "
"DeltaBlue."])
self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")
def testBuildbot(self):
self._WriteTestInput(V8_JSON)
self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567\n"])
self.assertEquals(0, self._CallMain("--buildbot"))
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["1.234"], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
])
self._VerifyErrors([])
self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")
def testBuildbotWithTotal(self):
test_input = dict(V8_JSON)
test_input["total"] = True
self._WriteTestInput(test_input)
self._MockCommand(["."], ["Richards: 1.234\nDeltaBlue: 10657567\n"])
self.assertEquals(0, self._CallMain("--buildbot"))
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["1.234"], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
{"name": "Total", "results": ["3626.49109719"], "stddev": ""},
])
self._VerifyErrors([])
self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")
def testBuildbotWithTotalAndErrors(self):
test_input = dict(V8_JSON)
test_input["total"] = True
self._WriteTestInput(test_input)
self._MockCommand(["."], ["x\nRichards: bla\nDeltaBlue: 10657567\ny\n"])
self.assertEquals(1, self._CallMain("--buildbot"))
self._VerifyResults("test", "score", [
{"name": "Richards", "results": [], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
])
self._VerifyErrors(
["Regexp \"^Richards: (.+)$\" "
"returned a non-numeric for test Richards.",
"Not all traces have the same number of results."])
self._VerifyMock(path.join("out", "Release", "d7"), "--flag", "run.js")
def testRegexpNoMatch(self):
self._WriteTestInput(V8_JSON)
self._MockCommand(["."], ["x\nRichaards: 1.234\nDeltaBlue: 10657567\ny\n"])
self.assertEquals(1, self._CallMain())
self._VerifyResults("test", "score", [
{"name": "Richards", "results": [], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
])
self._VerifyErrors(
["Regexp \"^Richards: (.+)$\" didn't match for test Richards."])
self._VerifyMock(path.join("out", "x64.release", "d7"), "--flag", "run.js")
def testOneRunGeneric(self):
test_input = dict(V8_GENERIC_JSON)
self._WriteTestInput(test_input)
self._MockCommand(["."], [
"RESULT Infra: Constant1= 11 count\n"
"RESULT Infra: Constant2= [10,5,10,15] count\n"
"RESULT Infra: Constant3= {12,1.2} count\n"
"RESULT Infra: Constant4= [10,5,error,15] count\n"])
self.assertEquals(1, self._CallMain())
self.assertEquals([
{"units": "count",
"graphs": ["test", "Infra", "Constant1"],
"results": ["11.0"],
"stddev": ""},
{"units": "count",
"graphs": ["test", "Infra", "Constant2"],
"results": ["10.0", "5.0", "10.0", "15.0"],
"stddev": ""},
{"units": "count",
"graphs": ["test", "Infra", "Constant3"],
"results": ["12.0"],
"stddev": "1.2"},
{"units": "count",
"graphs": ["test", "Infra", "Constant4"],
"results": [],
"stddev": ""},
], self._LoadResults()["traces"])
self._VerifyErrors(["Found non-numeric in test/Infra/Constant4"])
self._VerifyMock(path.join("out", "x64.release", "cc"), "--flag", "")
def testOneRunTimingOut(self):
test_input = dict(V8_JSON)
test_input["timeout"] = 70
self._WriteTestInput(test_input)
self._MockCommand(["."], [""], timed_out=True)
self.assertEquals(1, self._CallMain())
self._VerifyResults("test", "score", [
{"name": "Richards", "results": [], "stddev": ""},
{"name": "DeltaBlue", "results": [], "stddev": ""},
])
self._VerifyErrors([
"Regexp \"^Richards: (.+)$\" didn't match for test Richards.",
"Regexp \"^DeltaBlue: (.+)$\" didn't match for test DeltaBlue.",
])
self._VerifyMock(
path.join("out", "x64.release", "d7"), "--flag", "run.js", timeout=70)
# Simple test that mocks out the android platform. Testing the platform would
# require lots of complicated mocks for the android tools.
def testAndroid(self):
self._WriteTestInput(V8_JSON)
platform = run_perf.Platform
platform.PreExecution = MagicMock(return_value=None)
platform.PostExecution = MagicMock(return_value=None)
platform.PreTests = MagicMock(return_value=None)
platform.Run = MagicMock(
return_value="Richards: 1.234\nDeltaBlue: 10657567\n")
run_perf.AndroidPlatform = MagicMock(return_value=platform)
self.assertEquals(
0, self._CallMain("--android-build-tools", "/some/dir",
"--arch", "android_arm"))
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["1.234"], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
])
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
6927,
314,
812,
24,
2199,
11462,
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,
504,
5055,
492,
12863,
199,
646,
11745,
199,
646,
2022,
199,
504,
1683,
492,
6186,
199,
504,
1683,
492,
10079,
199,
646,
747,
199,
504,
747,
492,
931,
12,
984,
199,
646,
5145,
199,
646,
5549,
199,
646,
2882,
199,
199,
3,
15127,
2366,
13,
10828,
436,
2366,
13,
1805,
14,
653,
1905,
2366,
11745,
199,
3,
1015,
2356,
650,
14,
23,
14,
17,
1077,
506,
4903,
370,
664,
314,
5526,
8112,
14,
199,
199,
2864,
63,
8406,
11658,
275,
931,
14,
904,
8,
17336,
14,
31572,
1062,
298,
396,
13,
86,
24,
13,
1065,
13,
9452,
531,
199,
199,
54,
24,
63,
6243,
275,
469,
523,
298,
515,
582,
359,
1674,
2255,
523,
298,
3008,
582,
298,
68,
23,
401,
523,
298,
2469,
582,
22448,
4173,
2255,
523,
298,
973,
582,
298,
1065,
14,
3596,
401,
523,
298,
1065,
63,
835,
582,
413,
12,
523,
298,
2604,
63,
11191,
582,
18129,
5,
83,
26,
334,
6977,
9,
11918,
523,
298,
2219,
582,
359,
272,
2420,
354,
582,
298,
50,
1158,
5596,
6018,
272,
2420,
354,
582,
298,
13411,
15617,
6018,
523,
1622,
199,
93,
199,
199,
54,
24,
63,
46,
18813,
63,
6195,
649,
654,
63,
6243,
275,
469,
523,
298,
515,
582,
359,
1674,
2255,
523,
298,
2469,
582,
22448,
4173,
2255,
523,
298,
1065,
63,
835,
582,
413,
12,
523,
298,
5260,
582,
298,
3397,
401,
523,
298,
2219,
582,
359,
272,
2420,
354,
582,
298,
50,
1158,
5596,
401,
1362,
298,
515,
582,
2097,
322,
1560,
795,
2255,
1362,
298,
3008,
582,
298,
68,
23,
401,
1362,
298,
973,
582,
298,
1065,
14,
3596,
401,
1362,
298,
4435,
582,
2097,
493,
17,
14,
3596,
401,
298,
493,
18,
14,
3596,
2255,
1362,
298,
1065,
63,
835,
582,
499,
12,
1362,
298,
2604,
63,
11191,
582,
18129,
50,
1158,
5596,
26,
334,
6977,
9,
4,
6018,
272,
2420,
354,
582,
298,
2610,
401,
1362,
298,
515,
582,
2097,
954,
2255,
1362,
298,
2219,
582,
359,
2126,
2420,
354,
582,
298,
20475,
401,
267,
298,
515,
582,
2097,
8914,
2255,
267,
298,
1065,
63,
835,
63,
88,
772,
582,
650,
12,
267,
298,
5260,
582,
298,
706,
401,
267,
298,
973,
582,
298,
1065,
14,
3596,
401,
267,
298,
2604,
63,
11191,
582,
18129,
3184,
26,
334,
6977,
9,
6605,
14,
4,
6018,
1362,
1622,
272,
1660,
272,
2420,
354,
582,
298,
13411,
15617,
401,
1362,
298,
515,
582,
2097,
3136,
63,
6304,
2255,
1362,
298,
973,
582,
298,
1065,
14,
3596,
401,
1362,
298,
2469,
582,
22448,
4173,
18,
2255,
1362,
298,
2604,
63,
11191,
582,
18129,
13411,
15617,
26,
334,
6977,
9,
4,
6018,
272,
2420,
354,
582,
298,
11408,
343,
2540,
401,
1362,
298,
515,
582,
359,
1674,
2255,
1362,
298,
24239,
582,
2097,
5362,
2255,
1362,
298,
973,
582,
298,
1065,
14,
3596,
6018,
523,
1622,
199,
93,
199,
199,
54,
24,
63,
29395,
63,
6243,
275,
469,
523,
298,
515,
582,
359,
1674,
2255,
523,
298,
3008,
582,
298,
2055,
401,
523,
298,
2469,
582,
22448,
4173,
2255,
523,
298,
6767,
582,
715,
12,
523,
298,
1065,
63,
835,
582,
413,
12,
523,
298,
5260,
582,
298,
706,
401,
199,
93,
199,
199,
2959,
275,
12863,
480,
2959,
401,
298,
2703,
12,
4635,
12,
18590,
63,
548,
531,
199,
199,
533,
31778,
774,
8,
2796,
14,
1746,
304,
523,
768,
3744,
523,
347,
18561,
8,
1886,
304,
272,
843,
14,
1095,
275,
931,
14,
3475,
8,
515,
14,
3475,
8,
515,
14,
4832,
3460,
493,
29658,
272,
984,
14,
515,
14,
740,
8,
1886,
14,
1095,
9,
272,
843,
423,
8695,
275,
11745,
14,
10828,
8,
267,
2387,
30982,
736,
14,
515,
14,
904,
8,
1886,
14,
1095,
12,
298,
1065,
63,
9452,
14,
647,
531,
2459,
272,
843,
423,
8695,
14,
928,
342,
272,
492,
1255,
63,
9452,
272,
687,
511,
5933,
14,
1832,
492,
3718,
272,
2288,
3718,
272,
2288,
1255,
63,
9452,
819,
768,
3744,
523,
347,
24468,
8,
1886,
304,
272,
843,
423,
8695,
14,
2379,
342,
272,
870,
3087,
272,
870,
843,
423,
8695,
14,
3070,
342,
819,
347,
3613,
8,
277,
304,
272,
291,
14,
988,
10746,
275,
488,
272,
340,
931,
14,
2444,
8,
2864,
63,
8406,
11658,
304,
489,
5145,
14,
9242,
8,
2864,
63,
8406,
11658,
9,
272,
747,
14,
8347,
8,
2864,
63,
8406,
11658,
9,
819,
347,
6766,
8,
277,
304,
272,
340,
931,
14,
2444,
8,
2864,
63,
8406,
11658,
304,
489,
5145,
14,
9242,
8,
2864,
63,
8406,
11658,
9,
819,
347,
485,
3534,
774,
3205,
8,
277,
12,
2022,
63,
1317,
304,
272,
291,
423,
396,
63,
1210,
275,
931,
14,
904,
8,
2864,
63,
8406,
11658,
12,
298,
396,
14,
1001,
531,
272,
543,
1551,
8,
277,
423,
396,
63,
1210,
12,
298,
87,
531,
465,
289,
26,
489,
289,
14,
952,
8,
1001,
14,
4180,
8,
1001,
63,
1317,
430,
819,
347,
485,
3346,
3110,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
272,
327,
7777,
1072,
367,
1924,
511,
1255,
14,
272,
511,
63,
4467,
275,
359,
2959,
8,
2703,
29,
1273,
12,
2574,
4635,
29,
403,
12,
2574,
18590,
63,
548,
29,
958,
14,
362,
480,
26687,
63,
548,
401,
756,
430,
490,
367,
1680,
315,
1249,
59,
17,
2677,
272,
347,
5341,
2031,
589,
12,
1011,
958,
304,
489,
372,
511,
63,
4467,
14,
1935,
342,
272,
3718,
14,
12049,
275,
10079,
8,
2441,
63,
5881,
29,
2526,
9,
339,
327,
2670,
626,
366,
24,
365,
2797,
687,
314,
3211,
8288,
367,
1924,
511,
1255,
14,
272,
7606,
275,
359,
515,
14,
904,
8,
2864,
63,
8406,
11658,
12,
1680,
9,
367,
1680,
315,
1249,
59,
16,
2677,
272,
347,
13097,
2031,
589,
12,
1011,
958,
304,
489,
291,
14,
2947,
8,
3220,
14,
1935,
1062,
1249,
59,
16,
566,
272,
747,
14,
8563,
275,
10079,
8,
2441
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1898,
6927,
314,
812,
24,
2199,
11462,
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,
504,
5055,
492,
12863,
199,
646,
11745,
199,
646,
2022,
199,
504,
1683,
492,
6186,
199,
504,
1683,
492,
10079,
199,
646,
747,
199,
504,
747,
492,
931,
12,
984,
199,
646,
5145,
199,
646,
5549,
199,
646,
2882,
199,
199,
3,
15127,
2366,
13,
10828,
436,
2366,
13,
1805,
14,
653,
1905,
2366,
11745,
199,
3,
1015,
2356,
650,
14,
23,
14,
17,
1077,
506,
4903,
370,
664,
314,
5526,
8112,
14,
199,
199,
2864,
63,
8406,
11658,
275,
931,
14,
904,
8,
17336,
14,
31572,
1062,
298,
396,
13,
86,
24,
13,
1065,
13,
9452,
531,
199,
199,
54,
24,
63,
6243,
275,
469,
523,
298,
515,
582,
359,
1674,
2255,
523,
298,
3008,
582,
298,
68,
23,
401,
523,
298,
2469,
582,
22448,
4173,
2255,
523,
298,
973,
582,
298,
1065,
14,
3596,
401,
523,
298,
1065,
63,
835,
582,
413,
12,
523,
298,
2604,
63,
11191,
582,
18129,
5,
83,
26,
334,
6977,
9,
11918,
523,
298,
2219,
582,
359,
272,
2420,
354,
582,
298,
50,
1158,
5596,
6018,
272,
2420,
354,
582,
298,
13411,
15617,
6018,
523,
1622,
199,
93,
199,
199,
54,
24,
63,
46,
18813,
63,
6195,
649,
654,
63,
6243,
275,
469,
523,
298,
515,
582,
359,
1674,
2255,
523,
298,
2469,
582,
22448,
4173,
2255,
523,
298,
1065,
63,
835,
582,
413,
12,
523,
298,
5260,
582,
298,
3397,
401,
523,
298,
2219,
582,
359,
272,
2420,
354,
582,
298,
50,
1158,
5596,
401,
1362,
298,
515,
582,
2097,
322,
1560,
795,
2255,
1362,
298,
3008,
582,
298,
68,
23,
401,
1362,
298,
973,
582,
298,
1065,
14,
3596,
401,
1362,
298,
4435,
582,
2097,
493,
17,
14,
3596,
401,
298,
493,
18,
14,
3596,
2255,
1362,
298,
1065,
63,
835,
582,
499,
12,
1362,
298,
2604,
63,
11191,
582,
18129,
50,
1158,
5596,
26,
334,
6977,
9,
4,
6018,
272,
2420,
354,
582,
298,
2610,
401,
1362,
298,
515,
582,
2097,
954,
2255,
1362,
298,
2219,
582,
359,
2126,
2420,
354,
582,
298,
20475,
401,
267,
298,
515,
582,
2097,
8914,
2255,
267,
298,
1065,
63,
835,
63,
88,
772,
582,
650,
12,
267,
298,
5260,
582,
298,
706,
401,
267,
298,
973,
582,
298,
1065,
14,
3596,
401,
267,
298,
2604,
63,
11191,
582,
18129,
3184,
26,
334,
6977,
9,
6605,
14,
4,
6018,
1362,
1622,
272,
1660,
272,
2420,
354,
582,
298,
13411,
15617,
401,
1362,
298,
515,
582,
2097,
3136,
63,
6304,
2255,
1362,
298,
973,
582,
298,
1065,
14,
3596,
401,
1362,
298,
2469,
582,
22448,
4173,
18,
2255,
1362,
298,
2604,
63,
11191,
582,
18129,
13411,
15617,
26,
334,
6977,
9,
4,
6018,
272,
2420,
354,
582,
298,
11408,
343,
2540,
401,
1362,
298,
515,
582,
359,
1674,
2255,
1362,
298,
24239,
582,
2097,
5362,
2255,
1362,
298,
973,
582,
298,
1065,
14,
3596,
6018,
523,
1622,
199,
93,
199,
199,
54,
24,
63,
29395,
63,
6243,
275,
469,
523,
298,
515,
582,
359,
1674,
2255,
523,
298,
3008,
582,
298,
2055,
401,
523,
298,
2469,
582,
22448,
4173,
2255,
523,
298,
6767,
582,
715,
12,
523,
298,
1065,
63,
835,
582,
413,
12,
523,
298,
5260,
582,
298,
706,
401,
199,
93,
199,
199,
2959,
275,
12863,
480,
2959,
401,
298,
2703,
12,
4635,
12,
18590,
63,
548,
531,
199,
199,
533,
31778,
774,
8,
2796,
14,
1746,
304,
523,
768,
3744,
523,
347,
18561,
8,
1886,
304,
272,
843,
14,
1095,
275,
931,
14,
3475,
8,
515,
14,
3475,
8,
515,
14,
4832,
3460,
493,
29658,
272,
984,
14,
515,
14,
740,
8,
1886,
14,
1095,
9,
272,
843,
423,
8695,
275,
11745,
14,
10828,
8,
267,
2387,
30982,
736,
14,
515,
14,
904,
8,
1886,
14,
1095,
12,
298,
1065,
63,
9452,
14,
647,
531,
2459,
272,
843,
423,
8695,
14,
928,
342,
272,
492,
1255,
63,
9452,
272,
687,
511,
5933,
14,
1832,
492,
3718,
272,
2288,
3718,
272,
2288,
1255,
63,
9452,
819,
768,
3744,
523,
347,
24468,
8,
1886,
304,
272,
843,
423,
8695,
14,
2379,
342,
272,
870,
3087,
272,
870,
843,
423,
8695,
14,
3070,
342,
819,
347,
3613,
8,
277,
304,
272,
291,
14,
988,
10746,
275,
488,
272,
340,
931,
14,
2444,
8,
2864,
63,
8406,
11658,
304,
489,
5145,
14,
9242,
8,
2864,
63,
8406,
11658,
9,
272,
747,
14,
8347,
8,
2864,
63,
8406,
11658,
9,
819,
347,
6766,
8,
277,
304,
272,
340,
931,
14,
2444,
8,
2864,
63,
8406,
11658,
304,
489,
5145,
14,
9242,
8,
2864,
63,
8406,
11658,
9,
819,
347,
485,
3534,
774,
3205,
8,
277,
12,
2022,
63,
1317,
304,
272,
291,
423,
396,
63,
1210,
275,
931,
14,
904,
8,
2864,
63,
8406,
11658,
12,
298,
396,
14,
1001,
531,
272,
543,
1551,
8,
277,
423,
396,
63,
1210,
12,
298,
87,
531,
465,
289,
26,
489,
289,
14,
952,
8,
1001,
14,
4180,
8,
1001,
63,
1317,
430,
819,
347,
485,
3346,
3110,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
272,
327,
7777,
1072,
367,
1924,
511,
1255,
14,
272,
511,
63,
4467,
275,
359,
2959,
8,
2703,
29,
1273,
12,
2574,
4635,
29,
403,
12,
2574,
18590,
63,
548,
29,
958,
14,
362,
480,
26687,
63,
548,
401,
756,
430,
490,
367,
1680,
315,
1249,
59,
17,
2677,
272,
347,
5341,
2031,
589,
12,
1011,
958,
304,
489,
372,
511,
63,
4467,
14,
1935,
342,
272,
3718,
14,
12049,
275,
10079,
8,
2441,
63,
5881,
29,
2526,
9,
339,
327,
2670,
626,
366,
24,
365,
2797,
687,
314,
3211,
8288,
367,
1924,
511,
1255,
14,
272,
7606,
275,
359,
515,
14,
904,
8,
2864,
63,
8406,
11658,
12,
1680,
9,
367,
1680,
315,
1249,
59,
16,
2677,
272,
347,
13097,
2031,
589,
12,
1011,
958,
304,
489,
291,
14,
2947,
8,
3220,
14,
1935,
1062,
1249,
59,
16,
566,
272,
747,
14,
8563,
275,
10079,
8,
2441,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rtindru/django
|
tests/mail/test_sendtestemail.py
|
327
|
3088
|
from __future__ import unicode_literals
from django.core import mail
from django.core.management import call_command
from django.test import SimpleTestCase, override_settings
@override_settings(
ADMINS=(('Admin', 'admin@example.com'), ('Admin and Manager', 'admin_and_manager@example.com')),
MANAGERS=(('Manager', 'manager@example.com'), ('Admin and Manager', 'admin_and_manager@example.com')),
)
class SendTestEmailManagementCommand(SimpleTestCase):
"""
Test the sending of a test email using the `sendtestemail` command.
"""
def test_single_receiver(self):
"""
The mail is sent with the correct subject and recipient.
"""
recipient = 'joe@example.com'
call_command('sendtestemail', recipient)
self.assertEqual(len(mail.outbox), 1)
mail_message = mail.outbox[0]
self.assertEqual(mail_message.subject[0:15], 'Test email from')
self.assertEqual(mail_message.recipients(), [recipient])
def test_multiple_receivers(self):
"""
The mail may be sent with multiple recipients.
"""
recipients = ['joe@example.com', 'jane@example.com']
call_command('sendtestemail', recipients[0], recipients[1])
self.assertEqual(len(mail.outbox), 1)
mail_message = mail.outbox[0]
self.assertEqual(mail_message.subject[0:15], 'Test email from')
self.assertEqual(sorted(mail_message.recipients()), [
'jane@example.com',
'joe@example.com',
])
def test_manager_receivers(self):
"""
The mail should be sent to the email addresses specified in
settings.MANAGERS.
"""
call_command('sendtestemail', '--managers')
self.assertEqual(len(mail.outbox), 1)
mail_message = mail.outbox[0]
self.assertEqual(sorted(mail_message.recipients()), [
'admin_and_manager@example.com',
'manager@example.com',
])
def test_admin_receivers(self):
"""
The mail should be sent to the email addresses specified in
settings.ADMIN.
"""
call_command('sendtestemail', '--admins')
self.assertEqual(len(mail.outbox), 1)
mail_message = mail.outbox[0]
self.assertEqual(sorted(mail_message.recipients()), [
'admin@example.com',
'admin_and_manager@example.com',
])
def test_manager_and_admin_receivers(self):
"""
The mail should be sent to the email addresses specified in both
settings.MANAGERS and settings.ADMINS.
"""
call_command('sendtestemail', '--managers', '--admins')
self.assertEqual(len(mail.outbox), 2)
manager_mail = mail.outbox[0]
self.assertEqual(sorted(manager_mail.recipients()), [
'admin_and_manager@example.com',
'manager@example.com',
])
admin_mail = mail.outbox[1]
self.assertEqual(sorted(admin_mail.recipients()), [
'admin@example.com',
'admin_and_manager@example.com',
])
|
bsd-3-clause
|
[
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
1018,
492,
6016,
199,
504,
1639,
14,
1018,
14,
8110,
492,
1240,
63,
1531,
199,
504,
1639,
14,
396,
492,
24424,
12,
4278,
63,
1751,
421,
199,
32,
4415,
63,
1751,
8,
272,
29948,
51,
2687,
360,
4880,
297,
283,
2113,
32,
2694,
14,
957,
659,
661,
4880,
436,
13537,
297,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
3855,
272,
26688,
1254,
3960,
2687,
360,
2988,
297,
283,
2609,
32,
2694,
14,
957,
659,
661,
4880,
436,
13537,
297,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
3855,
199,
9,
199,
533,
10217,
774,
7035,
14552,
3110,
8,
17968,
304,
272,
408,
272,
1379,
314,
10209,
402,
282,
511,
3031,
1808,
314,
658,
2254,
744,
266,
1198,
64,
1414,
14,
272,
408,
339,
347,
511,
63,
4780,
63,
10244,
8,
277,
304,
267,
408,
267,
710,
6016,
365,
4847,
543,
314,
3211,
5420,
436,
10318,
14,
267,
408,
267,
10318,
275,
283,
20241,
32,
2694,
14,
957,
7,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
10318,
9,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
413,
9,
267,
6016,
63,
1188,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
1198,
63,
1188,
14,
5875,
59,
16,
26,
1046,
467,
283,
774,
3031,
687,
358,
267,
291,
14,
629,
8,
1198,
63,
1188,
14,
18323,
1062,
359,
10043,
566,
339,
347,
511,
63,
6048,
63,
29494,
8,
277,
304,
267,
408,
267,
710,
6016,
1443,
506,
4847,
543,
3663,
19255,
14,
267,
408,
267,
19255,
275,
788,
20241,
32,
2694,
14,
957,
297,
283,
74,
5865,
32,
2694,
14,
957,
418,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
19255,
59,
16,
467,
19255,
59,
17,
566,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
413,
9,
267,
6016,
63,
1188,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
1198,
63,
1188,
14,
5875,
59,
16,
26,
1046,
467,
283,
774,
3031,
687,
358,
267,
291,
14,
629,
8,
5917,
8,
1198,
63,
1188,
14,
18323,
4000,
359,
288,
283,
74,
5865,
32,
2694,
14,
957,
297,
288,
283,
20241,
32,
2694,
14,
957,
297,
267,
4794,
339,
347,
511,
63,
2609,
63,
29494,
8,
277,
304,
267,
408,
267,
710,
6016,
1077,
506,
4847,
370,
314,
3031,
7149,
2013,
315,
267,
2202,
14,
20600,
3960,
14,
267,
408,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
2850,
16259,
358,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
413,
9,
267,
6016,
63,
1188,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
5917,
8,
1198,
63,
1188,
14,
18323,
4000,
359,
288,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
297,
288,
283,
2609,
32,
2694,
14,
957,
297,
267,
4794,
339,
347,
511,
63,
2113,
63,
29494,
8,
277,
304,
267,
408,
267,
710,
6016,
1077,
506,
4847,
370,
314,
3031,
7149,
2013,
315,
267,
2202,
14,
14288,
14,
267,
408,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
2850,
23121,
358,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
413,
9,
267,
6016,
63,
1188,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
5917,
8,
1198,
63,
1188,
14,
18323,
4000,
359,
288,
283,
2113,
32,
2694,
14,
957,
297,
288,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
297,
267,
4794,
339,
347,
511,
63,
2609,
63,
460,
63,
2113,
63,
29494,
8,
277,
304,
267,
408,
267,
710,
6016,
1077,
506,
4847,
370,
314,
3031,
7149,
2013,
315,
3865,
267,
2202,
14,
20600,
3960,
436,
2202,
14,
14288,
51,
14,
267,
408,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
2850,
16259,
297,
2850,
23121,
358,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
499,
9,
267,
5256,
63,
1198,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
5917,
8,
2609,
63,
1198,
14,
18323,
4000,
359,
288,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
297,
288,
283,
2609,
32,
2694,
14,
957,
297,
267,
4794,
267,
4628,
63,
1198,
275,
6016,
14,
17244,
59,
17,
61,
267,
291,
14,
629,
8,
5917,
8,
2113,
63,
1198,
14,
18323,
4000,
359,
288,
283,
2113,
32,
2694,
14,
957,
297,
288,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
297,
267,
4794,
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
] |
[
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1639,
14,
1018,
492,
6016,
199,
504,
1639,
14,
1018,
14,
8110,
492,
1240,
63,
1531,
199,
504,
1639,
14,
396,
492,
24424,
12,
4278,
63,
1751,
421,
199,
32,
4415,
63,
1751,
8,
272,
29948,
51,
2687,
360,
4880,
297,
283,
2113,
32,
2694,
14,
957,
659,
661,
4880,
436,
13537,
297,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
3855,
272,
26688,
1254,
3960,
2687,
360,
2988,
297,
283,
2609,
32,
2694,
14,
957,
659,
661,
4880,
436,
13537,
297,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
3855,
199,
9,
199,
533,
10217,
774,
7035,
14552,
3110,
8,
17968,
304,
272,
408,
272,
1379,
314,
10209,
402,
282,
511,
3031,
1808,
314,
658,
2254,
744,
266,
1198,
64,
1414,
14,
272,
408,
339,
347,
511,
63,
4780,
63,
10244,
8,
277,
304,
267,
408,
267,
710,
6016,
365,
4847,
543,
314,
3211,
5420,
436,
10318,
14,
267,
408,
267,
10318,
275,
283,
20241,
32,
2694,
14,
957,
7,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
10318,
9,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
413,
9,
267,
6016,
63,
1188,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
1198,
63,
1188,
14,
5875,
59,
16,
26,
1046,
467,
283,
774,
3031,
687,
358,
267,
291,
14,
629,
8,
1198,
63,
1188,
14,
18323,
1062,
359,
10043,
566,
339,
347,
511,
63,
6048,
63,
29494,
8,
277,
304,
267,
408,
267,
710,
6016,
1443,
506,
4847,
543,
3663,
19255,
14,
267,
408,
267,
19255,
275,
788,
20241,
32,
2694,
14,
957,
297,
283,
74,
5865,
32,
2694,
14,
957,
418,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
19255,
59,
16,
467,
19255,
59,
17,
566,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
413,
9,
267,
6016,
63,
1188,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
1198,
63,
1188,
14,
5875,
59,
16,
26,
1046,
467,
283,
774,
3031,
687,
358,
267,
291,
14,
629,
8,
5917,
8,
1198,
63,
1188,
14,
18323,
4000,
359,
288,
283,
74,
5865,
32,
2694,
14,
957,
297,
288,
283,
20241,
32,
2694,
14,
957,
297,
267,
4794,
339,
347,
511,
63,
2609,
63,
29494,
8,
277,
304,
267,
408,
267,
710,
6016,
1077,
506,
4847,
370,
314,
3031,
7149,
2013,
315,
267,
2202,
14,
20600,
3960,
14,
267,
408,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
2850,
16259,
358,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
413,
9,
267,
6016,
63,
1188,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
5917,
8,
1198,
63,
1188,
14,
18323,
4000,
359,
288,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
297,
288,
283,
2609,
32,
2694,
14,
957,
297,
267,
4794,
339,
347,
511,
63,
2113,
63,
29494,
8,
277,
304,
267,
408,
267,
710,
6016,
1077,
506,
4847,
370,
314,
3031,
7149,
2013,
315,
267,
2202,
14,
14288,
14,
267,
408,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
2850,
23121,
358,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
413,
9,
267,
6016,
63,
1188,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
5917,
8,
1198,
63,
1188,
14,
18323,
4000,
359,
288,
283,
2113,
32,
2694,
14,
957,
297,
288,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
297,
267,
4794,
339,
347,
511,
63,
2609,
63,
460,
63,
2113,
63,
29494,
8,
277,
304,
267,
408,
267,
710,
6016,
1077,
506,
4847,
370,
314,
3031,
7149,
2013,
315,
3865,
267,
2202,
14,
20600,
3960,
436,
2202,
14,
14288,
51,
14,
267,
408,
267,
1240,
63,
1531,
360,
2254,
744,
266,
1198,
297,
2850,
16259,
297,
2850,
23121,
358,
267,
291,
14,
629,
8,
552,
8,
1198,
14,
17244,
395,
499,
9,
267,
5256,
63,
1198,
275,
6016,
14,
17244,
59,
16,
61,
267,
291,
14,
629,
8,
5917,
8,
2609,
63,
1198,
14,
18323,
4000,
359,
288,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
297,
288,
283,
2609,
32,
2694,
14,
957,
297,
267,
4794,
267,
4628,
63,
1198,
275,
6016,
14,
17244,
59,
17,
61,
267,
291,
14,
629,
8,
5917,
8,
2113,
63,
1198,
14,
18323,
4000,
359,
288,
283,
2113,
32,
2694,
14,
957,
297,
288,
283,
2113,
63,
460,
63,
2609,
32,
2694,
14,
957,
297,
267,
4794,
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,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0,
0,
0,
0
] |
geerlingguy/ansible
|
test/lib/ansible_test/_internal/coverage/analyze/targets/generate.py
|
31
|
5013
|
"""Analyze code coverage data to determine which integration test targets provide coverage for each arc or line."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
from .... import types as t
from ....encoding import (
to_text,
)
from ....data import (
data_context,
)
from ....util_common import (
ResultType,
)
from ... import (
enumerate_powershell_lines,
enumerate_python_arcs,
get_collection_path_regexes,
get_powershell_coverage_files,
get_python_coverage_files,
get_python_modules,
initialize_coverage,
PathChecker,
)
from . import (
CoverageAnalyzeTargetsConfig,
get_target_index,
make_report,
write_report,
)
if t.TYPE_CHECKING:
from . import (
Arcs,
Lines,
TargetIndexes,
)
class CoverageAnalyzeTargetsGenerateConfig(CoverageAnalyzeTargetsConfig):
"""Configuration for the `coverage analyze targets generate` command."""
def __init__(self, args): # type: (t.Any) -> None
super(CoverageAnalyzeTargetsGenerateConfig, self).__init__(args)
self.input_dir = args.input_dir or ResultType.COVERAGE.path # type: str
self.output_file = args.output_file # type: str
def command_coverage_analyze_targets_generate(args): # type: (CoverageAnalyzeTargetsGenerateConfig) -> None
"""Analyze code coverage data to determine which integration test targets provide coverage for each arc or line."""
root = data_context().content.root
target_indexes = {}
arcs = dict((os.path.relpath(path, root), data) for path, data in analyze_python_coverage(args, args.input_dir, target_indexes).items())
lines = dict((os.path.relpath(path, root), data) for path, data in analyze_powershell_coverage(args, args.input_dir, target_indexes).items())
report = make_report(target_indexes, arcs, lines)
write_report(args, report, args.output_file)
def analyze_python_coverage(
args, # type: CoverageAnalyzeTargetsGenerateConfig
path, # type: str
target_indexes, # type: TargetIndexes
): # type: (...) -> Arcs
"""Analyze Python code coverage."""
results = {} # type: Arcs
collection_search_re, collection_sub_re = get_collection_path_regexes()
modules = get_python_modules()
python_files = get_python_coverage_files(path)
coverage = initialize_coverage(args)
for python_file in python_files:
if not is_integration_coverage_file(python_file):
continue
target_name = get_target_name(python_file)
target_index = get_target_index(target_name, target_indexes)
for filename, covered_arcs in enumerate_python_arcs(python_file, coverage, modules, collection_search_re, collection_sub_re):
arcs = results.setdefault(filename, {})
for covered_arc in covered_arcs:
arc = arcs.setdefault(covered_arc, set())
arc.add(target_index)
prune_invalid_filenames(args, results, collection_search_re=collection_search_re)
return results
def analyze_powershell_coverage(
args, # type: CoverageAnalyzeTargetsGenerateConfig
path, # type: str
target_indexes, # type: TargetIndexes
): # type: (...) -> Lines
"""Analyze PowerShell code coverage"""
results = {} # type: Lines
collection_search_re, collection_sub_re = get_collection_path_regexes()
powershell_files = get_powershell_coverage_files(path)
for powershell_file in powershell_files:
if not is_integration_coverage_file(powershell_file):
continue
target_name = get_target_name(powershell_file)
target_index = get_target_index(target_name, target_indexes)
for filename, hits in enumerate_powershell_lines(powershell_file, collection_search_re, collection_sub_re):
lines = results.setdefault(filename, {})
for covered_line in hits:
line = lines.setdefault(covered_line, set())
line.add(target_index)
prune_invalid_filenames(args, results)
return results
def prune_invalid_filenames(
args, # type: CoverageAnalyzeTargetsGenerateConfig
results, # type: t.Dict[str, t.Any]
collection_search_re=None, # type: t.Optional[str]
): # type: (...) -> None
"""Remove invalid filenames from the given result set."""
path_checker = PathChecker(args, collection_search_re)
for path in list(results.keys()):
if not path_checker.check_path(path):
del results[path]
def get_target_name(path): # type: (str) -> str
"""Extract the test target name from the given coverage path."""
return to_text(os.path.basename(path).split('=')[1])
def is_integration_coverage_file(path): # type: (str) -> bool
"""Returns True if the coverage file came from integration tests, otherwise False."""
return os.path.basename(path).split('=')[0] in ('integration', 'windows-integration', 'network-integration')
|
gpl-3.0
|
[
624,
8014,
806,
1233,
11745,
666,
370,
6705,
1314,
13150,
511,
4545,
5647,
11745,
367,
1924,
14972,
503,
1004,
1041,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
199,
504,
29222,
492,
2943,
465,
307,
199,
199,
504,
29222,
2991,
492,
334,
272,
370,
63,
505,
12,
199,
9,
199,
199,
504,
29222,
576,
492,
334,
272,
666,
63,
1100,
12,
199,
9,
199,
199,
504,
29222,
1974,
63,
2330,
492,
334,
272,
10695,
804,
12,
199,
9,
199,
199,
504,
2263,
492,
334,
272,
3874,
63,
5652,
5641,
63,
1278,
12,
272,
3874,
63,
1548,
63,
20672,
12,
272,
664,
63,
3627,
63,
515,
63,
29283,
12,
272,
664,
63,
5652,
5641,
63,
10828,
63,
1725,
12,
272,
664,
63,
1548,
63,
10828,
63,
1725,
12,
272,
664,
63,
1548,
63,
3112,
12,
272,
8265,
63,
10828,
12,
272,
6912,
3048,
12,
199,
9,
199,
199,
504,
1275,
492,
334,
272,
1849,
3652,
8014,
806,
14126,
2028,
12,
272,
664,
63,
1375,
63,
1080,
12,
272,
1852,
63,
3070,
12,
272,
2218,
63,
3070,
12,
199,
9,
199,
199,
692,
307,
14,
2711,
63,
8936,
1206,
26,
272,
687,
1275,
492,
334,
267,
437,
1195,
83,
12,
267,
29406,
12,
267,
10256,
2681,
397,
12,
272,
776,
421,
199,
533,
1849,
3652,
8014,
806,
14126,
6864,
2028,
8,
27444,
8014,
806,
14126,
2028,
304,
272,
408,
5688,
367,
314,
658,
10828,
19897,
4545,
3550,
64,
1414,
1041,
272,
347,
636,
826,
721,
277,
12,
1249,
304,
221,
327,
730,
26,
334,
84,
14,
9874,
9,
1035,
488,
267,
1613,
8,
27444,
8014,
806,
14126,
6864,
2028,
12,
291,
2843,
826,
721,
589,
9,
398,
291,
14,
1210,
63,
694,
275,
1249,
14,
1210,
63,
694,
503,
10695,
804,
14,
19052,
2962,
14,
515,
221,
327,
730,
26,
620,
267,
291,
14,
1199,
63,
493,
275,
1249,
14,
1199,
63,
493,
221,
327,
730,
26,
620,
421,
199,
318,
1414,
63,
10828,
63,
21184,
63,
4684,
63,
4208,
8,
589,
304,
221,
327,
730,
26,
334,
27444,
8014,
806,
14126,
6864,
2028,
9,
1035,
488,
272,
408,
8014,
806,
1233,
11745,
666,
370,
6705,
1314,
13150,
511,
4545,
5647,
11745,
367,
1924,
14972,
503,
1004,
1041,
272,
1738,
275,
666,
63,
1100,
1252,
1317,
14,
1231,
272,
1347,
63,
10116,
275,
1052,
272,
601,
1259,
275,
1211,
1332,
736,
14,
515,
14,
12405,
8,
515,
12,
1738,
395,
666,
9,
367,
931,
12,
666,
315,
19897,
63,
1548,
63,
10828,
8,
589,
12,
1249,
14,
1210,
63,
694,
12,
1347,
63,
10116,
680,
1744,
1012,
272,
2385,
275,
1211,
1332,
736,
14,
515,
14,
12405,
8,
515,
12,
1738,
395,
666,
9,
367,
931,
12,
666,
315,
19897,
63,
5652,
5641,
63,
10828,
8,
589,
12,
1249,
14,
1210,
63,
694,
12,
1347,
63,
10116,
680,
1744,
1012,
272,
3622,
275,
1852,
63,
3070,
8,
1375,
63,
10116,
12,
601,
1259,
12,
2385,
9,
272,
2218,
63,
3070,
8,
589,
12,
3622,
12,
1249,
14,
1199,
63,
493,
9,
421,
199,
318,
19897,
63,
1548,
63,
10828,
8,
267,
1249,
12,
221,
327,
730,
26,
1849,
3652,
8014,
806,
14126,
6864,
2028,
267,
931,
12,
221,
327,
730,
26,
620,
267,
1347,
63,
10116,
12,
221,
327,
730,
26,
10256,
2681,
397,
199,
304,
221,
327,
730,
26,
30934,
1035,
437,
1195,
83,
272,
408,
8014,
806,
2018,
1233,
11745,
1041,
272,
2058,
275,
1052,
221,
327,
730,
26,
437,
1195,
83,
272,
3245,
63,
1733,
63,
264,
12,
3245,
63,
954,
63,
264,
275,
664,
63,
3627,
63,
515,
63,
29283,
342,
272,
4621,
275,
664,
63,
1548,
63,
3112,
342,
272,
2366,
63,
1725,
275,
664,
63,
1548,
63,
10828,
63,
1725,
8,
515,
9,
272,
11745,
275,
8265,
63,
10828,
8,
589,
9,
339,
367,
2366,
63,
493,
315,
2366,
63,
1725,
26,
267,
340,
440,
365,
63,
15092,
63,
10828,
63,
493,
8,
1548,
63,
493,
304,
288,
1980,
398,
1347,
63,
354,
275,
664,
63,
1375,
63,
354,
8,
1548,
63,
493,
9,
267,
1347,
63,
1080,
275,
664,
63,
1375,
63,
1080,
8,
1375,
63,
354,
12,
1347,
63,
10116,
9,
398,
367,
1788,
12,
24295,
63,
20672,
315,
3874,
63,
1548,
63,
20672,
8,
1548,
63,
493,
12,
11745,
12,
4621,
12,
3245,
63,
1733,
63,
264,
12,
3245,
63,
954,
63,
264,
304,
288,
601,
1259,
275,
2058,
14,
5486,
8,
1501,
12,
5009,
953,
367,
24295,
63,
9912,
315,
24295,
63,
20672,
26,
355,
14972,
275,
601,
1259,
14,
5486,
8,
13560,
63,
9912,
12,
663,
1012,
355,
14972,
14,
525,
8,
1375,
63,
1080,
9,
339,
27619,
63,
3197,
63,
10309,
8,
589,
12,
2058,
12,
3245,
63,
1733,
63,
264,
29,
3627,
63,
1733,
63,
264,
9,
339,
372,
2058,
421,
199,
318,
19897,
63,
5652,
5641,
63,
10828,
8,
267,
1249,
12,
221,
327,
730,
26,
1849,
3652,
8014,
806,
14126,
6864,
2028,
267,
931,
12,
221,
327,
730,
26,
620,
267,
1347,
63,
10116,
12,
221,
327,
730,
26,
10256,
2681,
397,
199,
304,
221,
327,
730,
26,
30934,
1035,
29406,
272,
408,
8014,
806,
18879,
8529,
1233,
11745,
624,
272,
2058,
275,
1052,
221,
327,
730,
26,
29406,
272,
3245,
63,
1733,
63,
264,
12,
3245,
63,
954,
63,
264,
275,
664,
63,
3627,
63,
515,
63,
29283,
342,
272,
7074,
5641,
63,
1725,
275,
664,
63,
5652,
5641,
63,
10828,
63,
1725,
8,
515,
9,
339,
367,
7074,
5641,
63,
493,
315,
7074,
5641,
63,
1725,
26,
267,
340,
440,
365,
63,
15092,
63,
10828,
63,
493,
8,
5652,
5641,
63,
493,
304,
288,
1980,
398,
1347,
63,
354,
275,
664,
63,
1375,
63,
354,
8,
5652,
5641,
63,
493,
9,
267,
1347,
63,
1080,
275,
664,
63,
1375,
63,
1080,
8,
1375,
63,
354,
12,
1347,
63,
10116,
9,
398,
367,
1788,
12,
19745,
315,
3874,
63,
5652,
5641,
63,
1278,
8,
5652,
5641,
63,
493,
12,
3245,
63,
1733,
63,
264,
12,
3245,
63,
954,
63,
264,
304,
288,
2385,
275,
2058,
14,
5486,
8,
1501,
12
] |
[
8014,
806,
1233,
11745,
666,
370,
6705,
1314,
13150,
511,
4545,
5647,
11745,
367,
1924,
14972,
503,
1004,
1041,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
199,
504,
29222,
492,
2943,
465,
307,
199,
199,
504,
29222,
2991,
492,
334,
272,
370,
63,
505,
12,
199,
9,
199,
199,
504,
29222,
576,
492,
334,
272,
666,
63,
1100,
12,
199,
9,
199,
199,
504,
29222,
1974,
63,
2330,
492,
334,
272,
10695,
804,
12,
199,
9,
199,
199,
504,
2263,
492,
334,
272,
3874,
63,
5652,
5641,
63,
1278,
12,
272,
3874,
63,
1548,
63,
20672,
12,
272,
664,
63,
3627,
63,
515,
63,
29283,
12,
272,
664,
63,
5652,
5641,
63,
10828,
63,
1725,
12,
272,
664,
63,
1548,
63,
10828,
63,
1725,
12,
272,
664,
63,
1548,
63,
3112,
12,
272,
8265,
63,
10828,
12,
272,
6912,
3048,
12,
199,
9,
199,
199,
504,
1275,
492,
334,
272,
1849,
3652,
8014,
806,
14126,
2028,
12,
272,
664,
63,
1375,
63,
1080,
12,
272,
1852,
63,
3070,
12,
272,
2218,
63,
3070,
12,
199,
9,
199,
199,
692,
307,
14,
2711,
63,
8936,
1206,
26,
272,
687,
1275,
492,
334,
267,
437,
1195,
83,
12,
267,
29406,
12,
267,
10256,
2681,
397,
12,
272,
776,
421,
199,
533,
1849,
3652,
8014,
806,
14126,
6864,
2028,
8,
27444,
8014,
806,
14126,
2028,
304,
272,
408,
5688,
367,
314,
658,
10828,
19897,
4545,
3550,
64,
1414,
1041,
272,
347,
636,
826,
721,
277,
12,
1249,
304,
221,
327,
730,
26,
334,
84,
14,
9874,
9,
1035,
488,
267,
1613,
8,
27444,
8014,
806,
14126,
6864,
2028,
12,
291,
2843,
826,
721,
589,
9,
398,
291,
14,
1210,
63,
694,
275,
1249,
14,
1210,
63,
694,
503,
10695,
804,
14,
19052,
2962,
14,
515,
221,
327,
730,
26,
620,
267,
291,
14,
1199,
63,
493,
275,
1249,
14,
1199,
63,
493,
221,
327,
730,
26,
620,
421,
199,
318,
1414,
63,
10828,
63,
21184,
63,
4684,
63,
4208,
8,
589,
304,
221,
327,
730,
26,
334,
27444,
8014,
806,
14126,
6864,
2028,
9,
1035,
488,
272,
408,
8014,
806,
1233,
11745,
666,
370,
6705,
1314,
13150,
511,
4545,
5647,
11745,
367,
1924,
14972,
503,
1004,
1041,
272,
1738,
275,
666,
63,
1100,
1252,
1317,
14,
1231,
272,
1347,
63,
10116,
275,
1052,
272,
601,
1259,
275,
1211,
1332,
736,
14,
515,
14,
12405,
8,
515,
12,
1738,
395,
666,
9,
367,
931,
12,
666,
315,
19897,
63,
1548,
63,
10828,
8,
589,
12,
1249,
14,
1210,
63,
694,
12,
1347,
63,
10116,
680,
1744,
1012,
272,
2385,
275,
1211,
1332,
736,
14,
515,
14,
12405,
8,
515,
12,
1738,
395,
666,
9,
367,
931,
12,
666,
315,
19897,
63,
5652,
5641,
63,
10828,
8,
589,
12,
1249,
14,
1210,
63,
694,
12,
1347,
63,
10116,
680,
1744,
1012,
272,
3622,
275,
1852,
63,
3070,
8,
1375,
63,
10116,
12,
601,
1259,
12,
2385,
9,
272,
2218,
63,
3070,
8,
589,
12,
3622,
12,
1249,
14,
1199,
63,
493,
9,
421,
199,
318,
19897,
63,
1548,
63,
10828,
8,
267,
1249,
12,
221,
327,
730,
26,
1849,
3652,
8014,
806,
14126,
6864,
2028,
267,
931,
12,
221,
327,
730,
26,
620,
267,
1347,
63,
10116,
12,
221,
327,
730,
26,
10256,
2681,
397,
199,
304,
221,
327,
730,
26,
30934,
1035,
437,
1195,
83,
272,
408,
8014,
806,
2018,
1233,
11745,
1041,
272,
2058,
275,
1052,
221,
327,
730,
26,
437,
1195,
83,
272,
3245,
63,
1733,
63,
264,
12,
3245,
63,
954,
63,
264,
275,
664,
63,
3627,
63,
515,
63,
29283,
342,
272,
4621,
275,
664,
63,
1548,
63,
3112,
342,
272,
2366,
63,
1725,
275,
664,
63,
1548,
63,
10828,
63,
1725,
8,
515,
9,
272,
11745,
275,
8265,
63,
10828,
8,
589,
9,
339,
367,
2366,
63,
493,
315,
2366,
63,
1725,
26,
267,
340,
440,
365,
63,
15092,
63,
10828,
63,
493,
8,
1548,
63,
493,
304,
288,
1980,
398,
1347,
63,
354,
275,
664,
63,
1375,
63,
354,
8,
1548,
63,
493,
9,
267,
1347,
63,
1080,
275,
664,
63,
1375,
63,
1080,
8,
1375,
63,
354,
12,
1347,
63,
10116,
9,
398,
367,
1788,
12,
24295,
63,
20672,
315,
3874,
63,
1548,
63,
20672,
8,
1548,
63,
493,
12,
11745,
12,
4621,
12,
3245,
63,
1733,
63,
264,
12,
3245,
63,
954,
63,
264,
304,
288,
601,
1259,
275,
2058,
14,
5486,
8,
1501,
12,
5009,
953,
367,
24295,
63,
9912,
315,
24295,
63,
20672,
26,
355,
14972,
275,
601,
1259,
14,
5486,
8,
13560,
63,
9912,
12,
663,
1012,
355,
14972,
14,
525,
8,
1375,
63,
1080,
9,
339,
27619,
63,
3197,
63,
10309,
8,
589,
12,
2058,
12,
3245,
63,
1733,
63,
264,
29,
3627,
63,
1733,
63,
264,
9,
339,
372,
2058,
421,
199,
318,
19897,
63,
5652,
5641,
63,
10828,
8,
267,
1249,
12,
221,
327,
730,
26,
1849,
3652,
8014,
806,
14126,
6864,
2028,
267,
931,
12,
221,
327,
730,
26,
620,
267,
1347,
63,
10116,
12,
221,
327,
730,
26,
10256,
2681,
397,
199,
304,
221,
327,
730,
26,
30934,
1035,
29406,
272,
408,
8014,
806,
18879,
8529,
1233,
11745,
624,
272,
2058,
275,
1052,
221,
327,
730,
26,
29406,
272,
3245,
63,
1733,
63,
264,
12,
3245,
63,
954,
63,
264,
275,
664,
63,
3627,
63,
515,
63,
29283,
342,
272,
7074,
5641,
63,
1725,
275,
664,
63,
5652,
5641,
63,
10828,
63,
1725,
8,
515,
9,
339,
367,
7074,
5641,
63,
493,
315,
7074,
5641,
63,
1725,
26,
267,
340,
440,
365,
63,
15092,
63,
10828,
63,
493,
8,
5652,
5641,
63,
493,
304,
288,
1980,
398,
1347,
63,
354,
275,
664,
63,
1375,
63,
354,
8,
5652,
5641,
63,
493,
9,
267,
1347,
63,
1080,
275,
664,
63,
1375,
63,
1080,
8,
1375,
63,
354,
12,
1347,
63,
10116,
9,
398,
367,
1788,
12,
19745,
315,
3874,
63,
5652,
5641,
63,
1278,
8,
5652,
5641,
63,
493,
12,
3245,
63,
1733,
63,
264,
12,
3245,
63,
954,
63,
264,
304,
288,
2385,
275,
2058,
14,
5486,
8,
1501,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
yufish/youtube-dl
|
youtube_dl/extractor/golem.py
|
186
|
2181
|
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import (
compat_urlparse,
)
from ..utils import (
determine_ext,
)
class GolemIE(InfoExtractor):
_VALID_URL = r'^https?://video\.golem\.de/.+?/(?P<id>.+?)/'
_TEST = {
'url': 'http://video.golem.de/handy/14095/iphone-6-und-6-plus-test.html',
'md5': 'c1a2c0a3c863319651c7c992c5ee29bf',
'info_dict': {
'id': '14095',
'format_id': 'high',
'ext': 'mp4',
'title': 'iPhone 6 und 6 Plus - Test',
'duration': 300.44,
'filesize': 65309548,
}
}
_PREFIX = 'http://video.golem.de'
def _real_extract(self, url):
video_id = self._match_id(url)
config = self._download_xml(
'https://video.golem.de/xml/{0}.xml'.format(video_id), video_id)
info = {
'id': video_id,
'title': config.findtext('./title', 'golem'),
'duration': self._float(config.findtext('./playtime'), 'duration'),
}
formats = []
for e in config:
url = e.findtext('./url')
if not url:
continue
formats.append({
'format_id': e.tag,
'url': compat_urlparse.urljoin(self._PREFIX, url),
'height': self._int(e.get('height'), 'height'),
'width': self._int(e.get('width'), 'width'),
'filesize': self._int(e.findtext('filesize'), 'filesize'),
'ext': determine_ext(e.findtext('./filename')),
})
self._sort_formats(formats)
info['formats'] = formats
thumbnails = []
for e in config.findall('.//teaser'):
url = e.findtext('./url')
if not url:
continue
thumbnails.append({
'url': compat_urlparse.urljoin(self._PREFIX, url),
'width': self._int(e.get('width'), 'thumbnail width'),
'height': self._int(e.get('height'), 'thumbnail height'),
})
info['thumbnails'] = thumbnails
return info
|
unlicense
|
[
3,
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
334,
272,
8434,
63,
10290,
12,
199,
9,
199,
504,
2508,
1208,
492,
334,
272,
6705,
63,
832,
12,
199,
9,
421,
199,
533,
3971,
3701,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
4289,
2859,
14144,
3722,
4537,
1939,
3701,
4537,
271,
15,
11198,
9448,
48,
28,
344,
29587,
2447,
7,
272,
485,
2864,
275,
469,
267,
283,
633,
356,
283,
1014,
921,
3722,
14,
1939,
3701,
14,
271,
15,
6868,
89,
15,
1079,
19113,
15,
28303,
13,
22,
13,
725,
13,
22,
13,
6666,
13,
396,
14,
1360,
297,
267,
283,
1064,
21,
356,
283,
67,
17,
65,
18,
67,
16,
65,
19,
67,
1184,
1153,
1167,
25459,
67,
23,
67,
16544,
67,
21,
1024,
1398,
4361,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
1079,
19113,
297,
288,
283,
908,
63,
344,
356,
283,
6260,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
73,
15199,
1227,
625,
68,
1227,
7497,
527,
446,
1379,
297,
288,
283,
5553,
356,
9601,
14,
1602,
12,
288,
283,
19233,
356,
11738,
10556,
17054,
12,
267,
789,
272,
789,
339,
485,
6351,
275,
283,
1014,
921,
3722,
14,
1939,
3701,
14,
271,
7,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
3991,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
398,
1101,
275,
291,
423,
4249,
63,
1652,
8,
288,
283,
2859,
921,
3722,
14,
1939,
3701,
14,
271,
15,
1652,
5321,
16,
5565,
1652,
1370,
908,
8,
3722,
63,
344,
395,
3991,
63,
344,
9,
398,
2256,
275,
469,
288,
283,
344,
356,
3991,
63,
344,
12,
288,
283,
1213,
356,
1101,
14,
30401,
17371,
1213,
297,
283,
1939,
3701,
659,
288,
283,
5553,
356,
291,
423,
1609,
8,
888,
14,
30401,
17371,
2802,
521,
659,
283,
5553,
659,
267,
789,
398,
6752,
275,
942,
267,
367,
325,
315,
1101,
26,
288,
1166,
275,
325,
14,
30401,
17371,
633,
358,
288,
340,
440,
1166,
26,
355,
1980,
953,
6752,
14,
740,
2561,
355,
283,
908,
63,
344,
356,
325,
14,
1450,
12,
355,
283,
633,
356,
8434,
63,
10290,
14,
17755,
8,
277,
423,
6351,
12,
1166,
395,
355,
283,
3333,
356,
291,
423,
442,
8,
69,
14,
362,
360,
3333,
659,
283,
3333,
659,
355,
283,
2063,
356,
291,
423,
442,
8,
69,
14,
362,
360,
2063,
659,
283,
2063,
659,
355,
283,
19233,
356,
291,
423,
442,
8,
69,
14,
30401,
360,
19233,
659,
283,
19233,
659,
355,
283,
832,
356,
6705,
63,
832,
8,
69,
14,
30401,
17371,
1501,
3855,
288,
3828,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
267,
2256,
459,
6321,
418,
275,
6752,
398,
10062,
83,
275,
942,
267,
367,
325,
315,
1101,
14,
6452,
29995,
266,
65,
332,
735,
288,
1166,
275,
325,
14,
30401,
17371,
633,
358,
288,
340,
440,
1166,
26,
355,
1980,
288,
10062,
83,
14,
740,
2561,
355,
283,
633,
356,
8434,
63,
10290,
14,
17755,
8,
277,
423,
6351,
12,
1166,
395,
355,
283,
2063,
356,
291,
423,
442,
8,
69,
14,
362,
360,
2063,
659,
283,
8311,
3462,
659,
355,
283,
3333,
356,
291,
423,
442,
8,
69,
14,
362,
360,
3333,
659,
283,
8311,
4569,
659,
288,
3828,
267,
2256,
459,
8311,
83,
418,
275,
10062,
83,
398,
372,
2256,
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
] |
[
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
5819,
492,
334,
272,
8434,
63,
10290,
12,
199,
9,
199,
504,
2508,
1208,
492,
334,
272,
6705,
63,
832,
12,
199,
9,
421,
199,
533,
3971,
3701,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
4289,
2859,
14144,
3722,
4537,
1939,
3701,
4537,
271,
15,
11198,
9448,
48,
28,
344,
29587,
2447,
7,
272,
485,
2864,
275,
469,
267,
283,
633,
356,
283,
1014,
921,
3722,
14,
1939,
3701,
14,
271,
15,
6868,
89,
15,
1079,
19113,
15,
28303,
13,
22,
13,
725,
13,
22,
13,
6666,
13,
396,
14,
1360,
297,
267,
283,
1064,
21,
356,
283,
67,
17,
65,
18,
67,
16,
65,
19,
67,
1184,
1153,
1167,
25459,
67,
23,
67,
16544,
67,
21,
1024,
1398,
4361,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
1079,
19113,
297,
288,
283,
908,
63,
344,
356,
283,
6260,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
73,
15199,
1227,
625,
68,
1227,
7497,
527,
446,
1379,
297,
288,
283,
5553,
356,
9601,
14,
1602,
12,
288,
283,
19233,
356,
11738,
10556,
17054,
12,
267,
789,
272,
789,
339,
485,
6351,
275,
283,
1014,
921,
3722,
14,
1939,
3701,
14,
271,
7,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
3991,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
398,
1101,
275,
291,
423,
4249,
63,
1652,
8,
288,
283,
2859,
921,
3722,
14,
1939,
3701,
14,
271,
15,
1652,
5321,
16,
5565,
1652,
1370,
908,
8,
3722,
63,
344,
395,
3991,
63,
344,
9,
398,
2256,
275,
469,
288,
283,
344,
356,
3991,
63,
344,
12,
288,
283,
1213,
356,
1101,
14,
30401,
17371,
1213,
297,
283,
1939,
3701,
659,
288,
283,
5553,
356,
291,
423,
1609,
8,
888,
14,
30401,
17371,
2802,
521,
659,
283,
5553,
659,
267,
789,
398,
6752,
275,
942,
267,
367,
325,
315,
1101,
26,
288,
1166,
275,
325,
14,
30401,
17371,
633,
358,
288,
340,
440,
1166,
26,
355,
1980,
953,
6752,
14,
740,
2561,
355,
283,
908,
63,
344,
356,
325,
14,
1450,
12,
355,
283,
633,
356,
8434,
63,
10290,
14,
17755,
8,
277,
423,
6351,
12,
1166,
395,
355,
283,
3333,
356,
291,
423,
442,
8,
69,
14,
362,
360,
3333,
659,
283,
3333,
659,
355,
283,
2063,
356,
291,
423,
442,
8,
69,
14,
362,
360,
2063,
659,
283,
2063,
659,
355,
283,
19233,
356,
291,
423,
442,
8,
69,
14,
30401,
360,
19233,
659,
283,
19233,
659,
355,
283,
832,
356,
6705,
63,
832,
8,
69,
14,
30401,
17371,
1501,
3855,
288,
3828,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
267,
2256,
459,
6321,
418,
275,
6752,
398,
10062,
83,
275,
942,
267,
367,
325,
315,
1101,
14,
6452,
29995,
266,
65,
332,
735,
288,
1166,
275,
325,
14,
30401,
17371,
633,
358,
288,
340,
440,
1166,
26,
355,
1980,
288,
10062,
83,
14,
740,
2561,
355,
283,
633,
356,
8434,
63,
10290,
14,
17755,
8,
277,
423,
6351,
12,
1166,
395,
355,
283,
2063,
356,
291,
423,
442,
8,
69,
14,
362,
360,
2063,
659,
283,
8311,
3462,
659,
355,
283,
3333,
356,
291,
423,
442,
8,
69,
14,
362,
360,
3333,
659,
283,
8311,
4569,
659,
288,
3828,
267,
2256,
459,
8311,
83,
418,
275,
10062,
83,
398,
372,
2256,
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,
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
] |
PurpleMyst/porcupine
|
porcupine/_session.py
|
1
|
10859
|
import functools
import logging
import traceback
import webbrowser
import pygments.styles
import pygments.token
import porcupine
from porcupine import _dialogs, dirs, filetypes, menubar, settings, tabs, utils
log = logging.getLogger(__name__)
# global state makes some things a lot easier
_main_window = None
_tab_manager = None
def init(window):
"""Set up Porcupine.
Usually :source:`porcupine/__main__.py` calls this function and you
don't need to call it yourself. This function can still be useful if
you want to run Porcupine minimally from another Python program for
some reason.
The *window* argument can be a tkinter root window or a ``Toplevel``
widget.
Example::
import tkinter
import porcupine
root = tkinter.Tk()
porcupine.init(root)
root.protocol('WM_DELETE_WINDOW', porcupine.quit)
root.mainloop()
"""
global _main_window
global _tab_manager
assert [_main_window, _tab_manager].count(None) != 1, (
"porcupine seems to be partially initialized")
if _main_window is not None:
raise RuntimeError("porcupine.init() was called twice")
_main_window = window # get_main_window() works from now on
utils._init_images()
filetypes.init()
dirs.makedirs()
_tab_manager = tabs.TabManager(window)
_tab_manager.pack(fill='both', expand=True)
for binding, callback in _tab_manager.bindings:
window.bind(binding, callback, add=True)
menubar.init()
window['menu'] = menubar.get_menu(None)
_setup_actions()
def quit():
"""
Calling this function is equivalent to clicking the X button in the
corner of the window.
This function makes sure that all tabs can be closed by calling
their :meth:`can_be_closed() <porcupine.tabs.Tab.can_be_closed>`
methods. If they can, all tabs are
:meth:`closed <porcupine.tabs.TabManager.close_tab>` and the main
window is destroyed.
"""
for tab in _tab_manager.tabs:
if not tab.can_be_closed():
return
# the tabs must not be closed here, otherwise some of them
# are closed if not all tabs can be closed
# closing tabs removes them from the tabs list, that's why copying
for tab in _tab_manager.tabs.copy():
_tab_manager.close_tab(tab)
_main_window.destroy()
def get_main_window():
"""Return the widget passed to :func:`~init`."""
if _main_window is None:
raise RuntimeError("porcupine.init() wasn't called")
return _main_window
def get_tab_manager():
"""Return the :class:`porcupine.tabs.TabManager` widget in the main window.
""" # these are on a separate line because pep-8 line length
if _tab_manager is None:
raise RuntimeError("porcupine.init() wasn't called")
return _tab_manager
def _setup_actions():
def new_file():
_tab_manager.add_tab(tabs.FileTab(_tab_manager))
def open_files():
for path in _dialogs.open_files():
try:
tab = tabs.FileTab.open_file(_tab_manager, path)
except (UnicodeError, OSError) as e:
log.exception("opening '%s' failed", path)
utils.errordialog(type(e).__name__, "Opening failed!",
traceback.format_exc())
continue
_tab_manager.add_tab(tab)
def close_current_tab():
if _tab_manager.current_tab.can_be_closed():
_tab_manager.close_tab(_tab_manager.current_tab)
add_action(new_file, "File/New File", ("Ctrl+N", '<Control-n>'))
add_action(open_files, "File/Open", ("Ctrl+O", '<Control-o>'))
add_action((lambda: _tab_manager.current_tab.save()),
"File/Save", ("Ctrl+S", '<Control-s>'), tabtypes=[tabs.FileTab])
add_action((lambda: _tab_manager.current_tab.save_as()),
"File/Save As...", ("Ctrl+Shift+S", '<Control-S>'),
tabtypes=[tabs.FileTab])
menubar.get_menu("File").add_separator()
# TODO: disable File/Quit when there are tabs, it's too easy to hit
# Ctrl+Q accidentally
add_action(close_current_tab, "File/Close", ("Ctrl+W", '<Control-w>'),
tabtypes=[tabs.Tab])
add_action(quit, "File/Quit", ("Ctrl+Q", '<Control-q>'))
def textmethod(attribute):
def result():
textwidget = _tab_manager.current_tab.textwidget
method = getattr(textwidget, attribute)
method()
return result
# FIXME: bind these in a text widget only, not globally
add_action(textmethod('undo'), "Edit/Undo", ("Ctrl+Z", '<Control-z>'),
tabtypes=[tabs.FileTab])
add_action(textmethod('redo'), "Edit/Redo", ("Ctrl+Y", '<Control-y>'),
tabtypes=[tabs.FileTab])
add_action(textmethod('cut'), "Edit/Cut", ("Ctrl+X", '<Control-x>'),
tabtypes=[tabs.FileTab])
add_action(textmethod('copy'), "Edit/Copy", ("Ctrl+C", '<Control-c>'),
tabtypes=[tabs.FileTab])
add_action(textmethod('paste'), "Edit/Paste", ("Ctrl+V", '<Control-v>'),
tabtypes=[tabs.FileTab])
add_action(textmethod('select_all'), "Edit/Select All",
("Ctrl+A", '<Control-a>'), tabtypes=[tabs.FileTab])
menubar.get_menu("Edit").add_separator()
# FIXME: this separator thing is a mess :(
menubar.get_menu("Edit").add_separator()
add_action(
functools.partial(settings.show_dialog, porcupine.get_main_window()),
"Edit/Porcupine Settings...")
menubar.get_menu("Color Themes") # this goes between Edit and View
# the font size stuff are bound by the textwidget itself, that's why
# there are Nones everywhere
add_action(
(lambda: _tab_manager.current_tab.textwidget.on_wheel('up')),
"View/Bigger Font", ("Ctrl+Plus", None), tabtypes=[tabs.FileTab])
add_action(
(lambda: _tab_manager.current_tab.textwidget.on_wheel('down')),
"View/Smaller Font", ("Ctrl+Minus", None), tabtypes=[tabs.FileTab])
add_action(
(lambda: _tab_manager.current_tab.textwidget.on_wheel('reset')),
"View/Reset Font Size", ("Ctrl+Zero", None), tabtypes=[tabs.FileTab])
menubar.get_menu("View").add_separator()
def add_link(menupath, url):
add_action(functools.partial(webbrowser.open, url), menupath)
# TODO: an about dialog that shows porcupine version, Python version
# and where porcupine is installed
# TODO: porcupine starring button
add_link("Help/Free help chat",
"http://webchat.freenode.net/?channels=%23%23learnpython")
add_link("Help/My Python tutorial",
"https://github.com/Akuli/python-tutorial/blob/master/README.md")
add_link("Help/Official Python documentation",
"https://docs.python.org/")
menubar.get_menu("Help").add_separator()
add_link("Help/Porcupine Wiki",
"https://github.com/Akuli/porcupine/wiki")
add_link("Help/Report a problem or request a feature",
"https://github.com/Akuli/porcupine/issues/new")
add_link("Help/Read Porcupine's code on GitHub",
"https://github.com/Akuli/porcupine/tree/master/porcupine")
# TODO: loading the styles takes a long time on startup... try to
# make it asynchronous without writing too complicated code?
config = settings.get_section('General')
for name in sorted(pygments.styles.get_all_styles()):
if name.islower():
label = name.replace('-', ' ').replace('_', ' ').title()
else:
label = name
options = {
'label': label, 'value': name,
'variable': config.get_var('pygments_style'),
}
style = pygments.styles.get_style_by_name(name)
bg = style.background_color
# styles have a style_for_token() method, but only iterating
# is documented :( http://pygments.org/docs/formatterdevelopment/
# i'm using iter() to make sure that dict() really treats
# the style as an iterable of pairs instead of some other
# metaprogramming fanciness
fg = None
style_infos = dict(iter(style))
for token in [pygments.token.String, pygments.token.Text]:
if style_infos[token]['color'] is not None:
fg = '#' + style_infos[token]['color']
break
if fg is None:
# do like textwidget.ThemedText._set_style does
fg = (getattr(style, 'default_style', '') or
utils.invert_color(bg))
options['foreground'] = options['activebackground'] = fg
options['background'] = options['activeforeground'] = bg
menubar.get_menu("Color Themes").add_radiobutton(**options)
def add_action(callback, menupath=None, keyboard_shortcut=(None, None),
tabtypes=(None, tabs.Tab)):
"""Add a keyboard binding and/or a menu item.
If *menupath* is given, it will be split by the last ``/``. The
first part will be used to get a menu with
:meth:`porcupine.menubar.get_menu`, and the end will be used as the
text of the menu item.
Keyboard shortcuts can be added too. If given, *keyboard_shortcut*
should be a two-tuple of a user-readable string and a tkinter
keyboard binding; for example, ``('Ctrl+S', '<Control-s>')``.
If defined, the *tabtypes* argument should be an iterable of
:class:`porcupine.tabs.Tab` subclasses that item can work
with. If you want to allow no tabs at all, add None to this list.
The menuitem will be disabled and the binding won't do anything when
the current tab is not of a compatible type.
"""
tabtypes = tuple((
# isinstance(None, type(None)) is True
type(None) if cls is None else cls
for cls in tabtypes
))
accelerator, binding = keyboard_shortcut
if menupath is not None:
menupath, menulabel = menupath.rsplit('/', 1)
menu = menubar.get_menu(menupath)
menu.add_command(label=menulabel, command=callback,
accelerator=accelerator)
menuindex = menu.index('end')
def tab_changed(event):
enable = isinstance(_tab_manager.current_tab, tabtypes)
menu.entryconfig(
menuindex, state=('normal' if enable else 'disabled'))
tab_changed(_tab_manager.current_tab)
_tab_manager.bind('<<CurrentTabChanged>>', tab_changed, add=True)
if binding is not None:
# TODO: check if it's already bound
def bind_callback(event):
if isinstance(_tab_manager.current_tab, tabtypes):
callback()
# try to allow binding keys that are used for other
# things by default
return 'break'
_main_window.bind(binding, bind_callback)
|
mit
|
[
646,
9143,
199,
646,
2050,
199,
646,
5190,
199,
646,
781,
29063,
199,
199,
646,
13277,
14,
12955,
199,
646,
13277,
14,
1418,
199,
199,
646,
8706,
17500,
1132,
199,
504,
8706,
17500,
1132,
492,
485,
328,
18238,
12,
7606,
12,
570,
1313,
12,
12953,
23863,
12,
2202,
12,
12187,
12,
3778,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
3,
2288,
1174,
7704,
2005,
7645,
282,
13918,
14905,
199,
63,
973,
63,
3806,
275,
488,
199,
63,
2902,
63,
2609,
275,
488,
421,
199,
318,
4205,
8,
3806,
304,
272,
408,
1084,
1536,
510,
269,
17500,
1132,
14,
339,
24612,
520,
1365,
1705,
7314,
17500,
1132,
22128,
973,
4343,
647,
64,
4882,
642,
805,
436,
1265,
272,
2793,
1133,
1929,
370,
1240,
652,
28225,
14,
961,
805,
883,
5139,
506,
2997,
340,
272,
1265,
2934,
370,
1255,
510,
269,
17500,
1132,
18790,
1183,
687,
4573,
2018,
2240,
367,
272,
2005,
4499,
14,
339,
710,
627,
3806,
10,
1423,
883,
506,
282,
22171,
1738,
4353,
503,
282,
1124,
6105,
1896,
1040,
272,
3938,
14,
339,
5679,
447,
398,
492,
22171,
267,
492,
8706,
17500,
1132,
398,
1738,
275,
22171,
14,
15189,
342,
267,
8706,
17500,
1132,
14,
826,
8,
1231,
9,
267,
1738,
14,
3922,
360,
13073,
63,
7014,
63,
15480,
297,
8706,
17500,
1132,
14,
10589,
9,
267,
1738,
14,
22644,
342,
272,
408,
272,
2288,
485,
973,
63,
3806,
272,
2288,
485,
2902,
63,
2609,
339,
702,
15500,
973,
63,
3806,
12,
485,
2902,
63,
2609,
1055,
835,
8,
403,
9,
1137,
413,
12,
334,
267,
298,
7314,
17500,
1132,
12237,
370,
506,
25172,
10038,
531,
272,
340,
485,
973,
63,
3806,
365,
440,
488,
26,
267,
746,
6064,
480,
7314,
17500,
1132,
14,
826,
342,
1990,
2797,
13373,
531,
272,
485,
973,
63,
3806,
275,
4353,
259,
327,
664,
63,
973,
63,
3806,
342,
5419,
687,
3063,
641,
339,
3778,
423,
826,
63,
4782,
342,
272,
570,
1313,
14,
826,
342,
272,
7606,
14,
8347,
342,
339,
485,
2902,
63,
2609,
275,
12187,
14,
7690,
2988,
8,
3806,
9,
272,
485,
2902,
63,
2609,
14,
1389,
8,
4498,
534,
10727,
297,
6544,
29,
549,
9,
272,
367,
11696,
12,
3233,
315,
485,
2902,
63,
2609,
14,
10880,
26,
267,
4353,
14,
3409,
8,
9140,
12,
3233,
12,
1050,
29,
549,
9,
339,
12953,
23863,
14,
826,
342,
272,
4353,
459,
4470,
418,
275,
12953,
23863,
14,
362,
63,
4470,
8,
403,
9,
272,
485,
2758,
63,
3723,
342,
421,
199,
318,
17242,
837,
272,
408,
272,
23892,
642,
805,
365,
7353,
370,
8968,
316,
314,
1323,
5528,
315,
314,
272,
17703,
402,
314,
4353,
14,
339,
961,
805,
7704,
3238,
626,
1006,
12187,
883,
506,
6876,
701,
6358,
272,
3932,
520,
5247,
1705,
2425,
63,
1235,
63,
5938,
342,
665,
7314,
17500,
1132,
14,
8741,
14,
7690,
14,
2425,
63,
1235,
63,
5938,
8637,
272,
3102,
14,
982,
2985,
883,
12,
1006,
12187,
787,
272,
520,
5247,
1705,
5938,
665,
7314,
17500,
1132,
14,
8741,
14,
7690,
2988,
14,
1600,
63,
2902,
8637,
436,
314,
2446,
272,
4353,
365,
28924,
14,
272,
408,
272,
367,
5174,
315,
485,
2902,
63,
2609,
14,
8741,
26,
267,
340,
440,
5174,
14,
2425,
63,
1235,
63,
5938,
837,
288,
372,
267,
327,
314,
12187,
1471,
440,
506,
6876,
2348,
12,
4257,
2005,
402,
3062,
267,
327,
787,
6876,
340,
440,
1006,
12187,
883,
506,
6876,
339,
327,
11261,
12187,
14185,
3062,
687,
314,
12187,
769,
12,
626,
1159,
10842,
16743,
272,
367,
5174,
315,
485,
2902,
63,
2609,
14,
8741,
14,
1574,
837,
267,
485,
2902,
63,
2609,
14,
1600,
63,
2902,
8,
2902,
9,
272,
485,
973,
63,
3806,
14,
7237,
342,
421,
199,
318,
664,
63,
973,
63,
3806,
837,
272,
408,
1767,
314,
3938,
3032,
370,
520,
1532,
6054,
826,
17105,
272,
340,
485,
973,
63,
3806,
365,
488,
26,
267,
746,
6064,
480,
7314,
17500,
1132,
14,
826,
342,
17373,
1133,
2797,
531,
272,
372,
485,
973,
63,
3806,
421,
199,
318,
664,
63,
2902,
63,
2609,
837,
272,
408,
1767,
314,
520,
533,
1705,
7314,
17500,
1132,
14,
8741,
14,
7690,
2988,
64,
3938,
315,
314,
2446,
4353,
14,
272,
408,
221,
327,
3520,
787,
641,
282,
7396,
1004,
2952,
22602,
13,
24,
1004,
2582,
272,
340,
485,
2902,
63,
2609,
365,
488,
26,
267,
746,
6064,
480,
7314,
17500,
1132,
14,
826,
342,
17373,
1133,
2797,
531,
272,
372,
485,
2902,
63,
2609,
421,
199,
318,
485,
2758,
63,
3723,
837,
272,
347,
892,
63,
493,
837,
267,
485,
2902,
63,
2609,
14,
525,
63,
2902,
8,
8741,
14,
1173,
7690,
1547,
2902,
63,
2609,
430,
339,
347,
1551,
63,
1725,
837,
267,
367,
931,
315,
485,
328,
18238,
14,
1490,
63,
1725,
837,
288,
862,
26,
355,
5174,
275,
12187,
14,
1173,
7690,
14,
1490,
63,
493,
1547,
2902,
63,
2609,
12,
931,
9,
288,
871,
334,
7087,
547,
12,
6440,
9,
465,
325,
26,
355,
943,
14,
1971,
480,
21849,
1543,
83,
7,
3405,
401,
931,
9,
355,
3778,
14,
705,
7196,
8,
466,
8,
69,
2843,
354,
3108,
298,
4299,
316,
3405,
17716,
3303,
5190,
14,
908,
63,
2804,
1012,
355,
1980,
953,
485,
2902,
63,
2609,
14,
525,
63,
2902,
8,
2902,
9,
339,
347,
4002,
63,
1818,
63,
2902,
837,
267,
340,
485,
2902,
63,
2609,
14,
1818,
63,
2902,
14,
2425,
63,
1235,
63,
5938,
837,
288,
485,
2902,
63,
2609,
14,
1600,
63,
2902,
1547,
2902,
63,
2609,
14,
1818,
63,
2902,
9,
339,
1050,
63,
1287,
8,
1222,
63,
493,
12,
298,
1173,
15,
4665,
3814,
401,
1689,
9778,
11,
46,
401,
2650,
3717,
13,
78,
30,
1333,
272,
1050,
63,
1287,
8,
1490,
63,
1725,
12,
298,
1173,
15,
4299,
401,
1689,
9778,
11,
47,
401,
2650,
3717,
13,
79,
30,
1333,
272,
1050,
63,
1287,
1332,
2734,
26,
485,
2902,
63,
2609,
14,
1818,
63,
2902,
14,
2117,
4000,
2049,
298,
1173,
15,
8229,
401,
1689,
9778,
11,
51,
401,
2650,
3717,
13,
83,
25642,
5174,
1313,
1524,
8741,
14,
1173,
7690,
566,
272,
1050,
63,
1287,
1332,
2734,
26,
485,
2902,
63,
2609
] |
[
9143,
199,
646,
2050,
199,
646,
5190,
199,
646,
781,
29063,
199,
199,
646,
13277,
14,
12955,
199,
646,
13277,
14,
1418,
199,
199,
646,
8706,
17500,
1132,
199,
504,
8706,
17500,
1132,
492,
485,
328,
18238,
12,
7606,
12,
570,
1313,
12,
12953,
23863,
12,
2202,
12,
12187,
12,
3778,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
199,
199,
3,
2288,
1174,
7704,
2005,
7645,
282,
13918,
14905,
199,
63,
973,
63,
3806,
275,
488,
199,
63,
2902,
63,
2609,
275,
488,
421,
199,
318,
4205,
8,
3806,
304,
272,
408,
1084,
1536,
510,
269,
17500,
1132,
14,
339,
24612,
520,
1365,
1705,
7314,
17500,
1132,
22128,
973,
4343,
647,
64,
4882,
642,
805,
436,
1265,
272,
2793,
1133,
1929,
370,
1240,
652,
28225,
14,
961,
805,
883,
5139,
506,
2997,
340,
272,
1265,
2934,
370,
1255,
510,
269,
17500,
1132,
18790,
1183,
687,
4573,
2018,
2240,
367,
272,
2005,
4499,
14,
339,
710,
627,
3806,
10,
1423,
883,
506,
282,
22171,
1738,
4353,
503,
282,
1124,
6105,
1896,
1040,
272,
3938,
14,
339,
5679,
447,
398,
492,
22171,
267,
492,
8706,
17500,
1132,
398,
1738,
275,
22171,
14,
15189,
342,
267,
8706,
17500,
1132,
14,
826,
8,
1231,
9,
267,
1738,
14,
3922,
360,
13073,
63,
7014,
63,
15480,
297,
8706,
17500,
1132,
14,
10589,
9,
267,
1738,
14,
22644,
342,
272,
408,
272,
2288,
485,
973,
63,
3806,
272,
2288,
485,
2902,
63,
2609,
339,
702,
15500,
973,
63,
3806,
12,
485,
2902,
63,
2609,
1055,
835,
8,
403,
9,
1137,
413,
12,
334,
267,
298,
7314,
17500,
1132,
12237,
370,
506,
25172,
10038,
531,
272,
340,
485,
973,
63,
3806,
365,
440,
488,
26,
267,
746,
6064,
480,
7314,
17500,
1132,
14,
826,
342,
1990,
2797,
13373,
531,
272,
485,
973,
63,
3806,
275,
4353,
259,
327,
664,
63,
973,
63,
3806,
342,
5419,
687,
3063,
641,
339,
3778,
423,
826,
63,
4782,
342,
272,
570,
1313,
14,
826,
342,
272,
7606,
14,
8347,
342,
339,
485,
2902,
63,
2609,
275,
12187,
14,
7690,
2988,
8,
3806,
9,
272,
485,
2902,
63,
2609,
14,
1389,
8,
4498,
534,
10727,
297,
6544,
29,
549,
9,
272,
367,
11696,
12,
3233,
315,
485,
2902,
63,
2609,
14,
10880,
26,
267,
4353,
14,
3409,
8,
9140,
12,
3233,
12,
1050,
29,
549,
9,
339,
12953,
23863,
14,
826,
342,
272,
4353,
459,
4470,
418,
275,
12953,
23863,
14,
362,
63,
4470,
8,
403,
9,
272,
485,
2758,
63,
3723,
342,
421,
199,
318,
17242,
837,
272,
408,
272,
23892,
642,
805,
365,
7353,
370,
8968,
316,
314,
1323,
5528,
315,
314,
272,
17703,
402,
314,
4353,
14,
339,
961,
805,
7704,
3238,
626,
1006,
12187,
883,
506,
6876,
701,
6358,
272,
3932,
520,
5247,
1705,
2425,
63,
1235,
63,
5938,
342,
665,
7314,
17500,
1132,
14,
8741,
14,
7690,
14,
2425,
63,
1235,
63,
5938,
8637,
272,
3102,
14,
982,
2985,
883,
12,
1006,
12187,
787,
272,
520,
5247,
1705,
5938,
665,
7314,
17500,
1132,
14,
8741,
14,
7690,
2988,
14,
1600,
63,
2902,
8637,
436,
314,
2446,
272,
4353,
365,
28924,
14,
272,
408,
272,
367,
5174,
315,
485,
2902,
63,
2609,
14,
8741,
26,
267,
340,
440,
5174,
14,
2425,
63,
1235,
63,
5938,
837,
288,
372,
267,
327,
314,
12187,
1471,
440,
506,
6876,
2348,
12,
4257,
2005,
402,
3062,
267,
327,
787,
6876,
340,
440,
1006,
12187,
883,
506,
6876,
339,
327,
11261,
12187,
14185,
3062,
687,
314,
12187,
769,
12,
626,
1159,
10842,
16743,
272,
367,
5174,
315,
485,
2902,
63,
2609,
14,
8741,
14,
1574,
837,
267,
485,
2902,
63,
2609,
14,
1600,
63,
2902,
8,
2902,
9,
272,
485,
973,
63,
3806,
14,
7237,
342,
421,
199,
318,
664,
63,
973,
63,
3806,
837,
272,
408,
1767,
314,
3938,
3032,
370,
520,
1532,
6054,
826,
17105,
272,
340,
485,
973,
63,
3806,
365,
488,
26,
267,
746,
6064,
480,
7314,
17500,
1132,
14,
826,
342,
17373,
1133,
2797,
531,
272,
372,
485,
973,
63,
3806,
421,
199,
318,
664,
63,
2902,
63,
2609,
837,
272,
408,
1767,
314,
520,
533,
1705,
7314,
17500,
1132,
14,
8741,
14,
7690,
2988,
64,
3938,
315,
314,
2446,
4353,
14,
272,
408,
221,
327,
3520,
787,
641,
282,
7396,
1004,
2952,
22602,
13,
24,
1004,
2582,
272,
340,
485,
2902,
63,
2609,
365,
488,
26,
267,
746,
6064,
480,
7314,
17500,
1132,
14,
826,
342,
17373,
1133,
2797,
531,
272,
372,
485,
2902,
63,
2609,
421,
199,
318,
485,
2758,
63,
3723,
837,
272,
347,
892,
63,
493,
837,
267,
485,
2902,
63,
2609,
14,
525,
63,
2902,
8,
8741,
14,
1173,
7690,
1547,
2902,
63,
2609,
430,
339,
347,
1551,
63,
1725,
837,
267,
367,
931,
315,
485,
328,
18238,
14,
1490,
63,
1725,
837,
288,
862,
26,
355,
5174,
275,
12187,
14,
1173,
7690,
14,
1490,
63,
493,
1547,
2902,
63,
2609,
12,
931,
9,
288,
871,
334,
7087,
547,
12,
6440,
9,
465,
325,
26,
355,
943,
14,
1971,
480,
21849,
1543,
83,
7,
3405,
401,
931,
9,
355,
3778,
14,
705,
7196,
8,
466,
8,
69,
2843,
354,
3108,
298,
4299,
316,
3405,
17716,
3303,
5190,
14,
908,
63,
2804,
1012,
355,
1980,
953,
485,
2902,
63,
2609,
14,
525,
63,
2902,
8,
2902,
9,
339,
347,
4002,
63,
1818,
63,
2902,
837,
267,
340,
485,
2902,
63,
2609,
14,
1818,
63,
2902,
14,
2425,
63,
1235,
63,
5938,
837,
288,
485,
2902,
63,
2609,
14,
1600,
63,
2902,
1547,
2902,
63,
2609,
14,
1818,
63,
2902,
9,
339,
1050,
63,
1287,
8,
1222,
63,
493,
12,
298,
1173,
15,
4665,
3814,
401,
1689,
9778,
11,
46,
401,
2650,
3717,
13,
78,
30,
1333,
272,
1050,
63,
1287,
8,
1490,
63,
1725,
12,
298,
1173,
15,
4299,
401,
1689,
9778,
11,
47,
401,
2650,
3717,
13,
79,
30,
1333,
272,
1050,
63,
1287,
1332,
2734,
26,
485,
2902,
63,
2609,
14,
1818,
63,
2902,
14,
2117,
4000,
2049,
298,
1173,
15,
8229,
401,
1689,
9778,
11,
51,
401,
2650,
3717,
13,
83,
25642,
5174,
1313,
1524,
8741,
14,
1173,
7690,
566,
272,
1050,
63,
1287,
1332,
2734,
26,
485,
2902,
63,
2609,
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,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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
] |
ledvina/zencoin
|
test/util/bitcoin-util-test.py
|
1
|
6594
|
#!/usr/bin/env python3
# Copyright 2014 BitPay Inc.
# Copyright 2016-2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test framework for zencoin utils.
Runs automatically during `make check`.
Can also be run manually."""
import argparse
import binascii
import configparser
import difflib
import json
import logging
import os
import pprint
import subprocess
import sys
def main():
config = configparser.ConfigParser()
config.optionxform = str
config.read_file(open(os.path.join(os.path.dirname(__file__), "../config.ini"), encoding="utf8"))
env_conf = dict(config.items('environment'))
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-v', '--verbose', action='store_true')
args = parser.parse_args()
verbose = args.verbose
if verbose:
level = logging.DEBUG
else:
level = logging.ERROR
formatter = '%(asctime)s - %(levelname)s - %(message)s'
# Add the format/level to the logger
logging.basicConfig(format=formatter, level=level)
bctester(os.path.join(env_conf["SRCDIR"], "test", "util", "data"), "bitcoin-util-test.json", env_conf)
def bctester(testDir, input_basename, buildenv):
""" Loads and parses the input file, runs all tests and reports results"""
input_filename = os.path.join(testDir, input_basename)
raw_data = open(input_filename, encoding="utf8").read()
input_data = json.loads(raw_data)
failed_testcases = []
for testObj in input_data:
try:
bctest(testDir, testObj, buildenv)
logging.info("PASSED: " + testObj["description"])
except:
logging.info("FAILED: " + testObj["description"])
failed_testcases.append(testObj["description"])
if failed_testcases:
error_message = "FAILED_TESTCASES:\n"
error_message += pprint.pformat(failed_testcases, width=400)
logging.error(error_message)
sys.exit(1)
else:
sys.exit(0)
def bctest(testDir, testObj, buildenv):
"""Runs a single test, comparing output and RC to expected output and RC.
Raises an error if input can't be read, executable fails, or output/RC
are not as expected. Error is caught by bctester() and reported.
"""
# Get the exec names and arguments
execprog = os.path.join(buildenv["BUILDDIR"], "src", testObj["exec"] + buildenv["EXEEXT"])
execargs = testObj['args']
execrun = [execprog] + execargs
# Read the input data (if there is any)
stdinCfg = None
inputData = None
if "input" in testObj:
filename = os.path.join(testDir, testObj["input"])
inputData = open(filename, encoding="utf8").read()
stdinCfg = subprocess.PIPE
# Read the expected output data (if there is any)
outputFn = None
outputData = None
outputType = None
if "output_cmp" in testObj:
outputFn = testObj['output_cmp']
outputType = os.path.splitext(outputFn)[1][1:] # output type from file extension (determines how to compare)
try:
outputData = open(os.path.join(testDir, outputFn), encoding="utf8").read()
except:
logging.error("Output file " + outputFn + " can not be opened")
raise
if not outputData:
logging.error("Output data missing for " + outputFn)
raise Exception
if not outputType:
logging.error("Output file %s does not have a file extension" % outputFn)
raise Exception
# Run the test
proc = subprocess.Popen(execrun, stdin=stdinCfg, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
try:
outs = proc.communicate(input=inputData)
except OSError:
logging.error("OSError, Failed to execute " + execprog)
raise
if outputData:
data_mismatch, formatting_mismatch = False, False
# Parse command output and expected output
try:
a_parsed = parse_output(outs[0], outputType)
except Exception as e:
logging.error('Error parsing command output as %s: %s' % (outputType, e))
raise
try:
b_parsed = parse_output(outputData, outputType)
except Exception as e:
logging.error('Error parsing expected output %s as %s: %s' % (outputFn, outputType, e))
raise
# Compare data
if a_parsed != b_parsed:
logging.error("Output data mismatch for " + outputFn + " (format " + outputType + ")")
data_mismatch = True
# Compare formatting
if outs[0] != outputData:
error_message = "Output formatting mismatch for " + outputFn + ":\n"
error_message += "".join(difflib.context_diff(outputData.splitlines(True),
outs[0].splitlines(True),
fromfile=outputFn,
tofile="returned"))
logging.error(error_message)
formatting_mismatch = True
assert not data_mismatch and not formatting_mismatch
# Compare the return code to the expected return code
wantRC = 0
if "return_code" in testObj:
wantRC = testObj['return_code']
if proc.returncode != wantRC:
logging.error("Return code mismatch for " + outputFn)
raise Exception
if "error_txt" in testObj:
want_error = testObj["error_txt"]
# Compare error text
# TODO: ideally, we'd compare the strings exactly and also assert
# That stderr is empty if no errors are expected. However, bitcoin-tx
# emits DISPLAY errors when running as a windows application on
# linux through wine. Just assert that the expected error text appears
# somewhere in stderr.
if want_error not in outs[1]:
logging.error("Error mismatch:\n" + "Expected: " + want_error + "\nReceived: " + outs[1].rstrip())
raise Exception
def parse_output(a, fmt):
"""Parse the output according to specified format.
Raise an error if the output can't be parsed."""
if fmt == 'json': # json: compare parsed data
return json.loads(a)
elif fmt == 'hex': # hex: parse and compare binary data
return binascii.a2b_hex(a.strip())
else:
raise NotImplementedError("Don't know how to compare %s" % fmt)
if __name__ == '__main__':
main()
|
mit
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
6927,
10199,
10517,
3277,
14,
199,
3,
1898,
7800,
13,
10680,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
774,
10059,
367,
1315,
287,
9061,
3778,
14,
199,
199,
16291,
5847,
5309,
658,
1875,
1104,
2313,
199,
199,
6049,
2597,
506,
1255,
10250,
1041,
199,
199,
646,
7534,
199,
646,
14755,
199,
646,
21230,
199,
646,
27070,
199,
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
646,
10933,
199,
646,
3873,
199,
646,
984,
199,
199,
318,
2446,
837,
272,
1101,
275,
21230,
14,
15218,
342,
272,
1101,
14,
1422,
24226,
275,
620,
272,
1101,
14,
739,
63,
493,
8,
1490,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
29024,
888,
14,
2730,
1288,
2644,
628,
1624,
24,
2237,
272,
2589,
63,
2190,
275,
1211,
8,
888,
14,
1744,
360,
5418,
1333,
339,
1798,
275,
7534,
14,
10730,
8,
1802,
18971,
1301,
3368,
272,
1798,
14,
525,
63,
2094,
3654,
86,
297,
2850,
3832,
297,
1595,
534,
1617,
63,
2052,
358,
272,
1249,
275,
1798,
14,
1122,
63,
589,
342,
272,
3376,
275,
1249,
14,
3832,
339,
340,
3376,
26,
267,
2166,
275,
2050,
14,
5287,
272,
587,
26,
267,
2166,
275,
2050,
14,
3170,
272,
9698,
275,
9487,
18331,
9,
83,
446,
2818,
20056,
9,
83,
446,
2818,
1188,
9,
83,
7,
272,
327,
2654,
314,
1475,
15,
1896,
370,
314,
2512,
272,
2050,
14,
19602,
8,
908,
29,
8911,
12,
2166,
29,
1896,
9,
339,
16604,
8234,
8,
736,
14,
515,
14,
904,
8,
1813,
63,
2190,
905,
12447,
3022,
2255,
298,
396,
401,
298,
1974,
401,
298,
576,
1288,
298,
22816,
13,
1974,
13,
396,
14,
1001,
401,
2589,
63,
2190,
9,
199,
199,
318,
16604,
8234,
8,
396,
3567,
12,
1324,
63,
4846,
12,
1032,
382,
848,
86,
304,
272,
408,
30367,
436,
19953,
314,
1324,
570,
12,
7858,
1006,
2295,
436,
13924,
2058,
624,
272,
1324,
63,
1501,
275,
747,
14,
515,
14,
904,
8,
396,
3567,
12,
1324,
63,
4846,
9,
272,
3066,
63,
576,
275,
1551,
8,
1210,
63,
1501,
12,
2644,
628,
1624,
24,
3471,
739,
342,
272,
1324,
63,
576,
275,
2022,
14,
3640,
8,
1773,
63,
576,
9,
339,
3405,
63,
396,
9403,
275,
942,
339,
367,
511,
5665,
315,
1324,
63,
576,
26,
267,
862,
26,
288,
16604,
396,
8,
396,
3567,
12,
511,
5665,
12,
1032,
382,
848,
86,
9,
288,
2050,
14,
815,
480,
48,
32032,
26,
298,
435,
511,
5665,
905,
1802,
3135,
267,
871,
26,
288,
2050,
14,
815,
480,
12299,
26,
298,
435,
511,
5665,
905,
1802,
3135,
288,
3405,
63,
396,
9403,
14,
740,
8,
396,
5665,
905,
1802,
3135,
339,
340,
3405,
63,
396,
9403,
26,
267,
1125,
63,
1188,
275,
298,
12299,
63,
2864,
9777,
654,
3427,
78,
2,
267,
1125,
63,
1188,
847,
10933,
14,
24225,
8,
4892,
63,
396,
9403,
12,
3462,
29,
5303,
9,
267,
2050,
14,
705,
8,
705,
63,
1188,
9,
267,
984,
14,
2224,
8,
17,
9,
272,
587,
26,
267,
984,
14,
2224,
8,
16,
9,
199,
199,
318,
16604,
396,
8,
396,
3567,
12,
511,
5665,
12,
1032,
382,
848,
86,
304,
272,
408,
16291,
282,
2849,
511,
12,
20234,
1072,
436,
29256,
370,
1420,
1072,
436,
29256,
14,
339,
6218,
376,
1125,
340,
1324,
883,
1133,
506,
1586,
12,
7286,
6918,
12,
503,
1072,
15,
8205,
272,
787,
440,
465,
1420,
14,
4520,
365,
15604,
701,
16604,
8234,
342,
436,
14581,
14,
272,
408,
272,
327,
2372,
314,
2146,
1561,
436,
2368,
272,
2146,
6595,
275,
747,
14,
515,
14,
904,
8,
464,
382,
848,
86,
905,
8248,
3022,
2255,
298,
2164,
401,
511,
5665,
905,
1628,
937,
435,
1032,
382,
848,
86,
905,
23017,
2472,
3135,
272,
2146,
589,
275,
511,
5665,
459,
589,
418,
272,
2146,
1065,
275,
359,
1628,
6595,
61,
435,
2146,
589,
339,
327,
5574,
314,
1324,
666,
334,
692,
2337,
365,
1263,
9,
272,
9009,
22457,
275,
488,
272,
1324,
1451,
275,
488,
272,
340,
298,
1210,
2,
315,
511,
5665,
26,
267,
1788,
275,
747,
14,
515,
14,
904,
8,
396,
3567,
12,
511,
5665,
905,
1210,
3135,
267,
1324,
1451,
275,
1551,
8,
1501,
12,
2644,
628,
1624,
24,
3471,
739,
342,
267,
9009,
22457,
275,
3873,
14,
6089,
339,
327,
5574,
314,
1420,
1072,
666,
334,
692,
2337,
365,
1263,
9,
272,
1072,
9656,
275,
488,
272,
1072,
1451,
275,
488,
272,
1072,
804,
275,
488,
272,
340,
298,
1199,
63,
5730,
2,
315,
511,
5665,
26,
267,
1072,
9656,
275,
511,
5665,
459,
1199,
63,
5730,
418,
267,
1072,
804,
275,
747,
14,
515,
14,
7973,
8,
1199,
9656,
2788,
17,
1527,
17,
2938,
221,
327,
1072,
730,
687,
570,
3329,
334,
17061,
397,
4212,
370,
6540,
9,
267,
862,
26,
288,
1072,
1451,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
396,
3567,
12,
1072,
9656,
395,
2644,
628,
1624,
24,
3471,
739,
342,
267,
871,
26,
288,
2050,
14,
705,
480,
2959,
570,
298,
435,
1072,
9656,
435,
298,
883,
440,
506,
12123,
531,
288,
746,
267,
340,
440,
1072,
1451,
26,
288,
2050,
14,
705,
480,
2959,
666,
4124,
367,
298,
435,
1072,
9656,
9,
288,
746,
2186,
267,
340,
440,
1072,
804,
26,
288,
2050,
14,
705,
480,
2959,
570,
450,
83,
1630,
440,
1172,
282,
570,
3329,
2,
450,
1072,
9656,
9,
288,
746,
2186,
339,
327,
3378,
314,
511,
272,
6499,
275,
3873,
14,
7942,
8,
1628,
1065,
12,
9009,
29,
6626,
22457,
12,
3839,
29,
5781,
14,
6089,
12,
4635,
29,
5781,
14,
6089,
12,
17508,
63,
13839,
29,
549,
9,
272,
862,
26,
267,
31557,
275,
6499,
14,
10664,
8,
1210,
29,
1210,
1451,
9,
272,
871,
6440,
26,
267,
2050,
14,
705,
480,
16719,
12,
16277,
370,
5341,
298,
435,
2146,
6595,
9,
267,
746,
339,
340,
1072,
1451,
26,
267,
666,
63,
20759,
12,
10803
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
1898,
6927,
10199,
10517,
3277,
14,
199,
3,
1898,
7800,
13,
10680,
710,
21158,
11672,
19782,
199,
3,
17484,
1334,
314,
10697,
2032,
4190,
12,
1937,
314,
23073,
199,
3,
570,
9685,
503,
1455,
921,
1544,
14,
16374,
14,
1308,
15,
2383,
15,
1147,
13,
1682,
14,
8624,
14,
199,
624,
774,
10059,
367,
1315,
287,
9061,
3778,
14,
199,
199,
16291,
5847,
5309,
658,
1875,
1104,
2313,
199,
199,
6049,
2597,
506,
1255,
10250,
1041,
199,
199,
646,
7534,
199,
646,
14755,
199,
646,
21230,
199,
646,
27070,
199,
646,
2022,
199,
646,
2050,
199,
646,
747,
199,
646,
10933,
199,
646,
3873,
199,
646,
984,
199,
199,
318,
2446,
837,
272,
1101,
275,
21230,
14,
15218,
342,
272,
1101,
14,
1422,
24226,
275,
620,
272,
1101,
14,
739,
63,
493,
8,
1490,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
29024,
888,
14,
2730,
1288,
2644,
628,
1624,
24,
2237,
272,
2589,
63,
2190,
275,
1211,
8,
888,
14,
1744,
360,
5418,
1333,
339,
1798,
275,
7534,
14,
10730,
8,
1802,
18971,
1301,
3368,
272,
1798,
14,
525,
63,
2094,
3654,
86,
297,
2850,
3832,
297,
1595,
534,
1617,
63,
2052,
358,
272,
1249,
275,
1798,
14,
1122,
63,
589,
342,
272,
3376,
275,
1249,
14,
3832,
339,
340,
3376,
26,
267,
2166,
275,
2050,
14,
5287,
272,
587,
26,
267,
2166,
275,
2050,
14,
3170,
272,
9698,
275,
9487,
18331,
9,
83,
446,
2818,
20056,
9,
83,
446,
2818,
1188,
9,
83,
7,
272,
327,
2654,
314,
1475,
15,
1896,
370,
314,
2512,
272,
2050,
14,
19602,
8,
908,
29,
8911,
12,
2166,
29,
1896,
9,
339,
16604,
8234,
8,
736,
14,
515,
14,
904,
8,
1813,
63,
2190,
905,
12447,
3022,
2255,
298,
396,
401,
298,
1974,
401,
298,
576,
1288,
298,
22816,
13,
1974,
13,
396,
14,
1001,
401,
2589,
63,
2190,
9,
199,
199,
318,
16604,
8234,
8,
396,
3567,
12,
1324,
63,
4846,
12,
1032,
382,
848,
86,
304,
272,
408,
30367,
436,
19953,
314,
1324,
570,
12,
7858,
1006,
2295,
436,
13924,
2058,
624,
272,
1324,
63,
1501,
275,
747,
14,
515,
14,
904,
8,
396,
3567,
12,
1324,
63,
4846,
9,
272,
3066,
63,
576,
275,
1551,
8,
1210,
63,
1501,
12,
2644,
628,
1624,
24,
3471,
739,
342,
272,
1324,
63,
576,
275,
2022,
14,
3640,
8,
1773,
63,
576,
9,
339,
3405,
63,
396,
9403,
275,
942,
339,
367,
511,
5665,
315,
1324,
63,
576,
26,
267,
862,
26,
288,
16604,
396,
8,
396,
3567,
12,
511,
5665,
12,
1032,
382,
848,
86,
9,
288,
2050,
14,
815,
480,
48,
32032,
26,
298,
435,
511,
5665,
905,
1802,
3135,
267,
871,
26,
288,
2050,
14,
815,
480,
12299,
26,
298,
435,
511,
5665,
905,
1802,
3135,
288,
3405,
63,
396,
9403,
14,
740,
8,
396,
5665,
905,
1802,
3135,
339,
340,
3405,
63,
396,
9403,
26,
267,
1125,
63,
1188,
275,
298,
12299,
63,
2864,
9777,
654,
3427,
78,
2,
267,
1125,
63,
1188,
847,
10933,
14,
24225,
8,
4892,
63,
396,
9403,
12,
3462,
29,
5303,
9,
267,
2050,
14,
705,
8,
705,
63,
1188,
9,
267,
984,
14,
2224,
8,
17,
9,
272,
587,
26,
267,
984,
14,
2224,
8,
16,
9,
199,
199,
318,
16604,
396,
8,
396,
3567,
12,
511,
5665,
12,
1032,
382,
848,
86,
304,
272,
408,
16291,
282,
2849,
511,
12,
20234,
1072,
436,
29256,
370,
1420,
1072,
436,
29256,
14,
339,
6218,
376,
1125,
340,
1324,
883,
1133,
506,
1586,
12,
7286,
6918,
12,
503,
1072,
15,
8205,
272,
787,
440,
465,
1420,
14,
4520,
365,
15604,
701,
16604,
8234,
342,
436,
14581,
14,
272,
408,
272,
327,
2372,
314,
2146,
1561,
436,
2368,
272,
2146,
6595,
275,
747,
14,
515,
14,
904,
8,
464,
382,
848,
86,
905,
8248,
3022,
2255,
298,
2164,
401,
511,
5665,
905,
1628,
937,
435,
1032,
382,
848,
86,
905,
23017,
2472,
3135,
272,
2146,
589,
275,
511,
5665,
459,
589,
418,
272,
2146,
1065,
275,
359,
1628,
6595,
61,
435,
2146,
589,
339,
327,
5574,
314,
1324,
666,
334,
692,
2337,
365,
1263,
9,
272,
9009,
22457,
275,
488,
272,
1324,
1451,
275,
488,
272,
340,
298,
1210,
2,
315,
511,
5665,
26,
267,
1788,
275,
747,
14,
515,
14,
904,
8,
396,
3567,
12,
511,
5665,
905,
1210,
3135,
267,
1324,
1451,
275,
1551,
8,
1501,
12,
2644,
628,
1624,
24,
3471,
739,
342,
267,
9009,
22457,
275,
3873,
14,
6089,
339,
327,
5574,
314,
1420,
1072,
666,
334,
692,
2337,
365,
1263,
9,
272,
1072,
9656,
275,
488,
272,
1072,
1451,
275,
488,
272,
1072,
804,
275,
488,
272,
340,
298,
1199,
63,
5730,
2,
315,
511,
5665,
26,
267,
1072,
9656,
275,
511,
5665,
459,
1199,
63,
5730,
418,
267,
1072,
804,
275,
747,
14,
515,
14,
7973,
8,
1199,
9656,
2788,
17,
1527,
17,
2938,
221,
327,
1072,
730,
687,
570,
3329,
334,
17061,
397,
4212,
370,
6540,
9,
267,
862,
26,
288,
1072,
1451,
275,
1551,
8,
736,
14,
515,
14,
904,
8,
396,
3567,
12,
1072,
9656,
395,
2644,
628,
1624,
24,
3471,
739,
342,
267,
871,
26,
288,
2050,
14,
705,
480,
2959,
570,
298,
435,
1072,
9656,
435,
298,
883,
440,
506,
12123,
531,
288,
746,
267,
340,
440,
1072,
1451,
26,
288,
2050,
14,
705,
480,
2959,
666,
4124,
367,
298,
435,
1072,
9656,
9,
288,
746,
2186,
267,
340,
440,
1072,
804,
26,
288,
2050,
14,
705,
480,
2959,
570,
450,
83,
1630,
440,
1172,
282,
570,
3329,
2,
450,
1072,
9656,
9,
288,
746,
2186,
339,
327,
3378,
314,
511,
272,
6499,
275,
3873,
14,
7942,
8,
1628,
1065,
12,
9009,
29,
6626,
22457,
12,
3839,
29,
5781,
14,
6089,
12,
4635,
29,
5781,
14,
6089,
12,
17508,
63,
13839,
29,
549,
9,
272,
862,
26,
267,
31557,
275,
6499,
14,
10664,
8,
1210,
29,
1210,
1451,
9,
272,
871,
6440,
26,
267,
2050,
14,
705,
480,
16719,
12,
16277,
370,
5341,
298,
435,
2146,
6595,
9,
267,
746,
339,
340,
1072,
1451,
26,
267,
666,
63,
20759,
12,
10803,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
seem-sky/kbengine
|
kbe/res/scripts/common/Lib/test/test_pwd.py
|
88
|
4229
|
import sys
import unittest
from test import support
pwd = support.import_module('pwd')
class PwdTest(unittest.TestCase):
def test_values(self):
entries = pwd.getpwall()
for e in entries:
self.assertEqual(len(e), 7)
self.assertEqual(e[0], e.pw_name)
self.assertIsInstance(e.pw_name, str)
self.assertEqual(e[1], e.pw_passwd)
self.assertIsInstance(e.pw_passwd, str)
self.assertEqual(e[2], e.pw_uid)
self.assertIsInstance(e.pw_uid, int)
self.assertEqual(e[3], e.pw_gid)
self.assertIsInstance(e.pw_gid, int)
self.assertEqual(e[4], e.pw_gecos)
self.assertIsInstance(e.pw_gecos, str)
self.assertEqual(e[5], e.pw_dir)
self.assertIsInstance(e.pw_dir, str)
self.assertEqual(e[6], e.pw_shell)
self.assertIsInstance(e.pw_shell, str)
# The following won't work, because of duplicate entries
# for one uid
# self.assertEqual(pwd.getpwuid(e.pw_uid), e)
# instead of this collect all entries for one uid
# and check afterwards (done in test_values_extended)
def test_values_extended(self):
entries = pwd.getpwall()
entriesbyname = {}
entriesbyuid = {}
if len(entries) > 1000: # Huge passwd file (NIS?) -- skip this test
self.skipTest('passwd file is huge; extended test skipped')
for e in entries:
entriesbyname.setdefault(e.pw_name, []).append(e)
entriesbyuid.setdefault(e.pw_uid, []).append(e)
# check whether the entry returned by getpwuid()
# for each uid is among those from getpwall() for this uid
for e in entries:
if not e[0] or e[0] == '+':
continue # skip NIS entries etc.
self.assertIn(pwd.getpwnam(e.pw_name), entriesbyname[e.pw_name])
self.assertIn(pwd.getpwuid(e.pw_uid), entriesbyuid[e.pw_uid])
def test_errors(self):
self.assertRaises(TypeError, pwd.getpwuid)
self.assertRaises(TypeError, pwd.getpwuid, 3.14)
self.assertRaises(TypeError, pwd.getpwnam)
self.assertRaises(TypeError, pwd.getpwnam, 42)
self.assertRaises(TypeError, pwd.getpwall, 42)
# try to get some errors
bynames = {}
byuids = {}
for (n, p, u, g, gecos, d, s) in pwd.getpwall():
bynames[n] = u
byuids[u] = n
allnames = list(bynames.keys())
namei = 0
fakename = allnames[namei]
while fakename in bynames:
chars = list(fakename)
for i in range(len(chars)):
if chars[i] == 'z':
chars[i] = 'A'
break
elif chars[i] == 'Z':
continue
else:
chars[i] = chr(ord(chars[i]) + 1)
break
else:
namei = namei + 1
try:
fakename = allnames[namei]
except IndexError:
# should never happen... if so, just forget it
break
fakename = ''.join(chars)
self.assertRaises(KeyError, pwd.getpwnam, fakename)
# In some cases, byuids isn't a complete list of all users in the
# system, so if we try to pick a value not in byuids (via a perturbing
# loop, say), pwd.getpwuid() might still be able to find data for that
# uid. Using sys.maxint may provoke the same problems, but hopefully
# it will be a more repeatable failure.
fakeuid = sys.maxsize
self.assertNotIn(fakeuid, byuids)
self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
# -1 shouldn't be a valid uid because it has a special meaning in many
# uid-related functions
self.assertRaises(KeyError, pwd.getpwuid, -1)
# should be out of uid_t range
self.assertRaises(KeyError, pwd.getpwuid, 2**128)
self.assertRaises(KeyError, pwd.getpwuid, -2**128)
def test_main():
support.run_unittest(PwdTest)
if __name__ == "__main__":
test_main()
|
lgpl-3.0
|
[
646,
984,
199,
646,
2882,
199,
504,
511,
492,
2291,
199,
199,
14258,
275,
2291,
14,
646,
63,
578,
360,
14258,
358,
199,
199,
533,
510,
2989,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1459,
8,
277,
304,
267,
4811,
275,
14374,
14,
362,
80,
7567,
342,
398,
367,
325,
315,
4811,
26,
288,
291,
14,
629,
8,
552,
8,
69,
395,
1520,
9,
288,
291,
14,
629,
8,
69,
59,
16,
467,
325,
14,
8796,
63,
354,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
354,
12,
620,
9,
288,
291,
14,
629,
8,
69,
59,
17,
467,
325,
14,
8796,
63,
12671,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
12671,
12,
620,
9,
288,
291,
14,
629,
8,
69,
59,
18,
467,
325,
14,
8796,
63,
1535,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
1535,
12,
1109,
9,
288,
291,
14,
629,
8,
69,
59,
19,
467,
325,
14,
8796,
63,
8787,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
8787,
12,
1109,
9,
288,
291,
14,
629,
8,
69,
59,
20,
467,
325,
14,
8796,
63,
303,
5197,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
303,
5197,
12,
620,
9,
288,
291,
14,
629,
8,
69,
59,
21,
467,
325,
14,
8796,
63,
694,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
694,
12,
620,
9,
288,
291,
14,
629,
8,
69,
59,
22,
467,
325,
14,
8796,
63,
5641,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
5641,
12,
620,
9,
953,
327,
710,
2569,
7859,
1133,
1736,
12,
2952,
402,
9250,
4811,
288,
327,
367,
1373,
1747,
288,
327,
259,
291,
14,
629,
8,
14258,
14,
362,
8796,
1535,
8,
69,
14,
8796,
63,
1535,
395,
325,
9,
288,
327,
3140,
402,
642,
8775,
1006,
4811,
367,
1373,
1747,
288,
327,
436,
1104,
26982,
334,
4456,
315,
511,
63,
1459,
63,
10525,
9,
339,
347,
511,
63,
1459,
63,
10525,
8,
277,
304,
267,
4811,
275,
14374,
14,
362,
80,
7567,
342,
267,
4811,
24810,
275,
1052,
267,
4811,
991,
1535,
275,
1052,
398,
340,
822,
8,
3189,
9,
690,
5198,
26,
221,
327,
869,
17730,
15081,
570,
334,
46,
1311,
17076,
1553,
3372,
642,
511,
288,
291,
14,
23809,
360,
12671,
570,
365,
27791,
27,
9243,
511,
9645,
358,
398,
367,
325,
315,
4811,
26,
288,
4811,
24810,
14,
5486,
8,
69,
14,
8796,
63,
354,
12,
15364,
740,
8,
69,
9,
288,
4811,
991,
1535,
14,
5486,
8,
69,
14,
8796,
63,
1535,
12,
15364,
740,
8,
69,
9,
398,
327,
1104,
3775,
314,
2397,
2138,
701,
664,
8796,
1535,
342,
267,
327,
367,
1924,
1747,
365,
16885,
5204,
687,
664,
80,
7567,
342,
367,
642,
1747,
267,
367,
325,
315,
4811,
26,
288,
340,
440,
325,
59,
16,
61,
503,
325,
59,
16,
61,
508,
6681,
356,
355,
1980,
327,
3372,
653,
1311,
4811,
5423,
14,
288,
291,
14,
4080,
8,
14258,
14,
362,
80,
3501,
455,
8,
69,
14,
8796,
63,
354,
395,
4811,
24810,
59,
69,
14,
8796,
63,
354,
566,
288,
291,
14,
4080,
8,
14258,
14,
362,
8796,
1535,
8,
69,
14,
8796,
63,
1535,
395,
4811,
991,
1535,
59,
69,
14,
8796,
63,
1535,
566,
339,
347,
511,
63,
2550,
8,
277,
304,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
8796,
1535,
9,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
8796,
1535,
12,
650,
14,
1079,
9,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
80,
3501,
455,
9,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
80,
3501,
455,
12,
5685,
9,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
80,
7567,
12,
5685,
9,
398,
327,
862,
370,
664,
2005,
2552,
267,
701,
1247,
275,
1052,
267,
701,
27637,
275,
1052,
267,
367,
334,
78,
12,
299,
12,
399,
12,
486,
12,
2312,
5197,
12,
366,
12,
308,
9,
315,
14374,
14,
362,
80,
7567,
837,
288,
701,
1247,
59,
78,
61,
275,
399,
288,
701,
27637,
59,
85,
61,
275,
302,
398,
1006,
1247,
275,
769,
8,
991,
1247,
14,
1612,
1012,
267,
536,
73,
275,
378,
267,
1433,
917,
313,
275,
1006,
1247,
59,
354,
73,
61,
267,
1830,
1433,
917,
313,
315,
701,
1247,
26,
288,
8365,
275,
769,
8,
667,
917,
313,
9,
288,
367,
284,
315,
1425,
8,
552,
8,
6574,
2298,
355,
340,
8365,
59,
73,
61,
508,
283,
90,
356,
490,
8365,
59,
73,
61,
275,
283,
33,
7,
490,
2059,
355,
916,
8365,
59,
73,
61,
508,
283,
58,
356,
490,
1980,
355,
587,
26,
490,
8365,
59,
73,
61,
275,
8678,
8,
2181,
8,
6574,
59,
73,
566,
435,
413,
9,
490,
2059,
288,
587,
26,
355,
536,
73,
275,
536,
73,
435,
413,
355,
862,
26,
490,
1433,
917,
313,
275,
1006,
1247,
59,
354,
73,
61,
355,
871,
7888,
26,
490,
327,
1077,
7078,
5992,
1396,
340,
880,
12,
2951,
19459,
652,
490,
2059,
288,
1433,
917,
313,
275,
6522,
904,
8,
6574,
9,
398,
291,
14,
1855,
8,
10230,
12,
14374,
14,
362,
80,
3501,
455,
12,
1433,
917,
313,
9,
398,
327,
1010,
2005,
5560,
12,
701,
27637,
5712,
1133,
282,
4890,
769,
402,
1006,
4390,
315,
314,
267,
327,
2656,
12,
880,
340,
781,
862,
370,
3732,
282,
574,
440,
315,
701,
27637,
334,
12897,
282,
1126,
16218,
10911,
267,
327,
4438,
12,
14722,
395,
14374,
14,
362,
8796,
1535,
342,
5594,
5139,
506,
7688,
370,
2342,
666,
367,
626,
267,
327,
1747,
14,
11719,
984,
14,
21411,
1443,
557,
6720,
314,
2011,
8826,
12,
1325,
3661,
5836,
267,
327,
652,
911,
506,
282,
1655,
11982,
461,
5988,
14,
267,
4026,
1535,
275,
984,
14,
13634,
267,
291,
14,
8795,
8,
3183,
1535,
12,
701,
27637,
9,
267,
291,
14,
1855,
8,
10230,
12,
14374,
14,
362,
8796,
1535,
12,
4026,
1535,
9,
398,
327,
446,
17,
9296,
1133,
506,
282,
1686,
1747,
2952,
652,
965,
282,
4539,
11150,
315,
5002,
267,
327,
1747,
13,
2407,
3423,
267,
291,
14,
1855,
8,
10230
] |
[
984,
199,
646,
2882,
199,
504,
511,
492,
2291,
199,
199,
14258,
275,
2291,
14,
646,
63,
578,
360,
14258,
358,
199,
199,
533,
510,
2989,
774,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
1459,
8,
277,
304,
267,
4811,
275,
14374,
14,
362,
80,
7567,
342,
398,
367,
325,
315,
4811,
26,
288,
291,
14,
629,
8,
552,
8,
69,
395,
1520,
9,
288,
291,
14,
629,
8,
69,
59,
16,
467,
325,
14,
8796,
63,
354,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
354,
12,
620,
9,
288,
291,
14,
629,
8,
69,
59,
17,
467,
325,
14,
8796,
63,
12671,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
12671,
12,
620,
9,
288,
291,
14,
629,
8,
69,
59,
18,
467,
325,
14,
8796,
63,
1535,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
1535,
12,
1109,
9,
288,
291,
14,
629,
8,
69,
59,
19,
467,
325,
14,
8796,
63,
8787,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
8787,
12,
1109,
9,
288,
291,
14,
629,
8,
69,
59,
20,
467,
325,
14,
8796,
63,
303,
5197,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
303,
5197,
12,
620,
9,
288,
291,
14,
629,
8,
69,
59,
21,
467,
325,
14,
8796,
63,
694,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
694,
12,
620,
9,
288,
291,
14,
629,
8,
69,
59,
22,
467,
325,
14,
8796,
63,
5641,
9,
288,
291,
14,
6926,
8,
69,
14,
8796,
63,
5641,
12,
620,
9,
953,
327,
710,
2569,
7859,
1133,
1736,
12,
2952,
402,
9250,
4811,
288,
327,
367,
1373,
1747,
288,
327,
259,
291,
14,
629,
8,
14258,
14,
362,
8796,
1535,
8,
69,
14,
8796,
63,
1535,
395,
325,
9,
288,
327,
3140,
402,
642,
8775,
1006,
4811,
367,
1373,
1747,
288,
327,
436,
1104,
26982,
334,
4456,
315,
511,
63,
1459,
63,
10525,
9,
339,
347,
511,
63,
1459,
63,
10525,
8,
277,
304,
267,
4811,
275,
14374,
14,
362,
80,
7567,
342,
267,
4811,
24810,
275,
1052,
267,
4811,
991,
1535,
275,
1052,
398,
340,
822,
8,
3189,
9,
690,
5198,
26,
221,
327,
869,
17730,
15081,
570,
334,
46,
1311,
17076,
1553,
3372,
642,
511,
288,
291,
14,
23809,
360,
12671,
570,
365,
27791,
27,
9243,
511,
9645,
358,
398,
367,
325,
315,
4811,
26,
288,
4811,
24810,
14,
5486,
8,
69,
14,
8796,
63,
354,
12,
15364,
740,
8,
69,
9,
288,
4811,
991,
1535,
14,
5486,
8,
69,
14,
8796,
63,
1535,
12,
15364,
740,
8,
69,
9,
398,
327,
1104,
3775,
314,
2397,
2138,
701,
664,
8796,
1535,
342,
267,
327,
367,
1924,
1747,
365,
16885,
5204,
687,
664,
80,
7567,
342,
367,
642,
1747,
267,
367,
325,
315,
4811,
26,
288,
340,
440,
325,
59,
16,
61,
503,
325,
59,
16,
61,
508,
6681,
356,
355,
1980,
327,
3372,
653,
1311,
4811,
5423,
14,
288,
291,
14,
4080,
8,
14258,
14,
362,
80,
3501,
455,
8,
69,
14,
8796,
63,
354,
395,
4811,
24810,
59,
69,
14,
8796,
63,
354,
566,
288,
291,
14,
4080,
8,
14258,
14,
362,
8796,
1535,
8,
69,
14,
8796,
63,
1535,
395,
4811,
991,
1535,
59,
69,
14,
8796,
63,
1535,
566,
339,
347,
511,
63,
2550,
8,
277,
304,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
8796,
1535,
9,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
8796,
1535,
12,
650,
14,
1079,
9,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
80,
3501,
455,
9,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
80,
3501,
455,
12,
5685,
9,
267,
291,
14,
1855,
8,
4333,
12,
14374,
14,
362,
80,
7567,
12,
5685,
9,
398,
327,
862,
370,
664,
2005,
2552,
267,
701,
1247,
275,
1052,
267,
701,
27637,
275,
1052,
267,
367,
334,
78,
12,
299,
12,
399,
12,
486,
12,
2312,
5197,
12,
366,
12,
308,
9,
315,
14374,
14,
362,
80,
7567,
837,
288,
701,
1247,
59,
78,
61,
275,
399,
288,
701,
27637,
59,
85,
61,
275,
302,
398,
1006,
1247,
275,
769,
8,
991,
1247,
14,
1612,
1012,
267,
536,
73,
275,
378,
267,
1433,
917,
313,
275,
1006,
1247,
59,
354,
73,
61,
267,
1830,
1433,
917,
313,
315,
701,
1247,
26,
288,
8365,
275,
769,
8,
667,
917,
313,
9,
288,
367,
284,
315,
1425,
8,
552,
8,
6574,
2298,
355,
340,
8365,
59,
73,
61,
508,
283,
90,
356,
490,
8365,
59,
73,
61,
275,
283,
33,
7,
490,
2059,
355,
916,
8365,
59,
73,
61,
508,
283,
58,
356,
490,
1980,
355,
587,
26,
490,
8365,
59,
73,
61,
275,
8678,
8,
2181,
8,
6574,
59,
73,
566,
435,
413,
9,
490,
2059,
288,
587,
26,
355,
536,
73,
275,
536,
73,
435,
413,
355,
862,
26,
490,
1433,
917,
313,
275,
1006,
1247,
59,
354,
73,
61,
355,
871,
7888,
26,
490,
327,
1077,
7078,
5992,
1396,
340,
880,
12,
2951,
19459,
652,
490,
2059,
288,
1433,
917,
313,
275,
6522,
904,
8,
6574,
9,
398,
291,
14,
1855,
8,
10230,
12,
14374,
14,
362,
80,
3501,
455,
12,
1433,
917,
313,
9,
398,
327,
1010,
2005,
5560,
12,
701,
27637,
5712,
1133,
282,
4890,
769,
402,
1006,
4390,
315,
314,
267,
327,
2656,
12,
880,
340,
781,
862,
370,
3732,
282,
574,
440,
315,
701,
27637,
334,
12897,
282,
1126,
16218,
10911,
267,
327,
4438,
12,
14722,
395,
14374,
14,
362,
8796,
1535,
342,
5594,
5139,
506,
7688,
370,
2342,
666,
367,
626,
267,
327,
1747,
14,
11719,
984,
14,
21411,
1443,
557,
6720,
314,
2011,
8826,
12,
1325,
3661,
5836,
267,
327,
652,
911,
506,
282,
1655,
11982,
461,
5988,
14,
267,
4026,
1535,
275,
984,
14,
13634,
267,
291,
14,
8795,
8,
3183,
1535,
12,
701,
27637,
9,
267,
291,
14,
1855,
8,
10230,
12,
14374,
14,
362,
8796,
1535,
12,
4026,
1535,
9,
398,
327,
446,
17,
9296,
1133,
506,
282,
1686,
1747,
2952,
652,
965,
282,
4539,
11150,
315,
5002,
267,
327,
1747,
13,
2407,
3423,
267,
291,
14,
1855,
8,
10230,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
matianfu/barcelona-4.3.3
|
tools/perf/scripts/python/sched-migration.py
|
1910
|
11965
|
#!/usr/bin/python
#
# Cpu task migration overview toy
#
# Copyright (C) 2010 Frederic Weisbecker <fweisbec@gmail.com>
#
# perf script event handlers have been generated by perf script -g python
#
# This software is distributed under the terms of the GNU General
# Public License ("GPL") version 2 as published by the Free Software
# Foundation.
import os
import sys
from collections import defaultdict
from UserList import UserList
sys.path.append(os.environ['PERF_EXEC_PATH'] + \
'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
sys.path.append('scripts/python/Perf-Trace-Util/lib/Perf/Trace')
from perf_trace_context import *
from Core import *
from SchedGui import *
threads = { 0 : "idle"}
def thread_name(pid):
return "%s:%d" % (threads[pid], pid)
class RunqueueEventUnknown:
@staticmethod
def color():
return None
def __repr__(self):
return "unknown"
class RunqueueEventSleep:
@staticmethod
def color():
return (0, 0, 0xff)
def __init__(self, sleeper):
self.sleeper = sleeper
def __repr__(self):
return "%s gone to sleep" % thread_name(self.sleeper)
class RunqueueEventWakeup:
@staticmethod
def color():
return (0xff, 0xff, 0)
def __init__(self, wakee):
self.wakee = wakee
def __repr__(self):
return "%s woke up" % thread_name(self.wakee)
class RunqueueEventFork:
@staticmethod
def color():
return (0, 0xff, 0)
def __init__(self, child):
self.child = child
def __repr__(self):
return "new forked task %s" % thread_name(self.child)
class RunqueueMigrateIn:
@staticmethod
def color():
return (0, 0xf0, 0xff)
def __init__(self, new):
self.new = new
def __repr__(self):
return "task migrated in %s" % thread_name(self.new)
class RunqueueMigrateOut:
@staticmethod
def color():
return (0xff, 0, 0xff)
def __init__(self, old):
self.old = old
def __repr__(self):
return "task migrated out %s" % thread_name(self.old)
class RunqueueSnapshot:
def __init__(self, tasks = [0], event = RunqueueEventUnknown()):
self.tasks = tuple(tasks)
self.event = event
def sched_switch(self, prev, prev_state, next):
event = RunqueueEventUnknown()
if taskState(prev_state) == "R" and next in self.tasks \
and prev in self.tasks:
return self
if taskState(prev_state) != "R":
event = RunqueueEventSleep(prev)
next_tasks = list(self.tasks[:])
if prev in self.tasks:
if taskState(prev_state) != "R":
next_tasks.remove(prev)
elif taskState(prev_state) == "R":
next_tasks.append(prev)
if next not in next_tasks:
next_tasks.append(next)
return RunqueueSnapshot(next_tasks, event)
def migrate_out(self, old):
if old not in self.tasks:
return self
next_tasks = [task for task in self.tasks if task != old]
return RunqueueSnapshot(next_tasks, RunqueueMigrateOut(old))
def __migrate_in(self, new, event):
if new in self.tasks:
self.event = event
return self
next_tasks = self.tasks[:] + tuple([new])
return RunqueueSnapshot(next_tasks, event)
def migrate_in(self, new):
return self.__migrate_in(new, RunqueueMigrateIn(new))
def wake_up(self, new):
return self.__migrate_in(new, RunqueueEventWakeup(new))
def wake_up_new(self, new):
return self.__migrate_in(new, RunqueueEventFork(new))
def load(self):
""" Provide the number of tasks on the runqueue.
Don't count idle"""
return len(self.tasks) - 1
def __repr__(self):
ret = self.tasks.__repr__()
ret += self.origin_tostring()
return ret
class TimeSlice:
def __init__(self, start, prev):
self.start = start
self.prev = prev
self.end = start
# cpus that triggered the event
self.event_cpus = []
if prev is not None:
self.total_load = prev.total_load
self.rqs = prev.rqs.copy()
else:
self.rqs = defaultdict(RunqueueSnapshot)
self.total_load = 0
def __update_total_load(self, old_rq, new_rq):
diff = new_rq.load() - old_rq.load()
self.total_load += diff
def sched_switch(self, ts_list, prev, prev_state, next, cpu):
old_rq = self.prev.rqs[cpu]
new_rq = old_rq.sched_switch(prev, prev_state, next)
if old_rq is new_rq:
return
self.rqs[cpu] = new_rq
self.__update_total_load(old_rq, new_rq)
ts_list.append(self)
self.event_cpus = [cpu]
def migrate(self, ts_list, new, old_cpu, new_cpu):
if old_cpu == new_cpu:
return
old_rq = self.prev.rqs[old_cpu]
out_rq = old_rq.migrate_out(new)
self.rqs[old_cpu] = out_rq
self.__update_total_load(old_rq, out_rq)
new_rq = self.prev.rqs[new_cpu]
in_rq = new_rq.migrate_in(new)
self.rqs[new_cpu] = in_rq
self.__update_total_load(new_rq, in_rq)
ts_list.append(self)
if old_rq is not out_rq:
self.event_cpus.append(old_cpu)
self.event_cpus.append(new_cpu)
def wake_up(self, ts_list, pid, cpu, fork):
old_rq = self.prev.rqs[cpu]
if fork:
new_rq = old_rq.wake_up_new(pid)
else:
new_rq = old_rq.wake_up(pid)
if new_rq is old_rq:
return
self.rqs[cpu] = new_rq
self.__update_total_load(old_rq, new_rq)
ts_list.append(self)
self.event_cpus = [cpu]
def next(self, t):
self.end = t
return TimeSlice(t, self)
class TimeSliceList(UserList):
def __init__(self, arg = []):
self.data = arg
def get_time_slice(self, ts):
if len(self.data) == 0:
slice = TimeSlice(ts, TimeSlice(-1, None))
else:
slice = self.data[-1].next(ts)
return slice
def find_time_slice(self, ts):
start = 0
end = len(self.data)
found = -1
searching = True
while searching:
if start == end or start == end - 1:
searching = False
i = (end + start) / 2
if self.data[i].start <= ts and self.data[i].end >= ts:
found = i
end = i
continue
if self.data[i].end < ts:
start = i
elif self.data[i].start > ts:
end = i
return found
def set_root_win(self, win):
self.root_win = win
def mouse_down(self, cpu, t):
idx = self.find_time_slice(t)
if idx == -1:
return
ts = self[idx]
rq = ts.rqs[cpu]
raw = "CPU: %d\n" % cpu
raw += "Last event : %s\n" % rq.event.__repr__()
raw += "Timestamp : %d.%06d\n" % (ts.start / (10 ** 9), (ts.start % (10 ** 9)) / 1000)
raw += "Duration : %6d us\n" % ((ts.end - ts.start) / (10 ** 6))
raw += "Load = %d\n" % rq.load()
for t in rq.tasks:
raw += "%s \n" % thread_name(t)
self.root_win.update_summary(raw)
def update_rectangle_cpu(self, slice, cpu):
rq = slice.rqs[cpu]
if slice.total_load != 0:
load_rate = rq.load() / float(slice.total_load)
else:
load_rate = 0
red_power = int(0xff - (0xff * load_rate))
color = (0xff, red_power, red_power)
top_color = None
if cpu in slice.event_cpus:
top_color = rq.event.color()
self.root_win.paint_rectangle_zone(cpu, color, top_color, slice.start, slice.end)
def fill_zone(self, start, end):
i = self.find_time_slice(start)
if i == -1:
return
for i in xrange(i, len(self.data)):
timeslice = self.data[i]
if timeslice.start > end:
return
for cpu in timeslice.rqs:
self.update_rectangle_cpu(timeslice, cpu)
def interval(self):
if len(self.data) == 0:
return (0, 0)
return (self.data[0].start, self.data[-1].end)
def nr_rectangles(self):
last_ts = self.data[-1]
max_cpu = 0
for cpu in last_ts.rqs:
if cpu > max_cpu:
max_cpu = cpu
return max_cpu
class SchedEventProxy:
def __init__(self):
self.current_tsk = defaultdict(lambda : -1)
self.timeslices = TimeSliceList()
def sched_switch(self, headers, prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio):
""" Ensure the task we sched out this cpu is really the one
we logged. Otherwise we may have missed traces """
on_cpu_task = self.current_tsk[headers.cpu]
if on_cpu_task != -1 and on_cpu_task != prev_pid:
print "Sched switch event rejected ts: %s cpu: %d prev: %s(%d) next: %s(%d)" % \
(headers.ts_format(), headers.cpu, prev_comm, prev_pid, next_comm, next_pid)
threads[prev_pid] = prev_comm
threads[next_pid] = next_comm
self.current_tsk[headers.cpu] = next_pid
ts = self.timeslices.get_time_slice(headers.ts())
ts.sched_switch(self.timeslices, prev_pid, prev_state, next_pid, headers.cpu)
def migrate(self, headers, pid, prio, orig_cpu, dest_cpu):
ts = self.timeslices.get_time_slice(headers.ts())
ts.migrate(self.timeslices, pid, orig_cpu, dest_cpu)
def wake_up(self, headers, comm, pid, success, target_cpu, fork):
if success == 0:
return
ts = self.timeslices.get_time_slice(headers.ts())
ts.wake_up(self.timeslices, pid, target_cpu, fork)
def trace_begin():
global parser
parser = SchedEventProxy()
def trace_end():
app = wx.App(False)
timeslices = parser.timeslices
frame = RootFrame(timeslices, "Migration")
app.MainLoop()
def sched__sched_stat_runtime(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, runtime, vruntime):
pass
def sched__sched_stat_iowait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, delay):
pass
def sched__sched_stat_sleep(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, delay):
pass
def sched__sched_stat_wait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, delay):
pass
def sched__sched_process_fork(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, parent_comm, parent_pid, child_comm, child_pid):
pass
def sched__sched_process_wait(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, prio):
pass
def sched__sched_process_exit(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, prio):
pass
def sched__sched_process_free(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, prio):
pass
def sched__sched_migrate_task(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, prio, orig_cpu,
dest_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm, common_callchain)
parser.migrate(headers, pid, prio, orig_cpu, dest_cpu)
def sched__sched_switch(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm, common_callchain,
prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm, common_callchain)
parser.sched_switch(headers, prev_comm, prev_pid, prev_prio, prev_state,
next_comm, next_pid, next_prio)
def sched__sched_wakeup_new(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, prio, success,
target_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm, common_callchain)
parser.wake_up(headers, comm, pid, success, target_cpu, 1)
def sched__sched_wakeup(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, prio, success,
target_cpu):
headers = EventHeaders(common_cpu, common_secs, common_nsecs,
common_pid, common_comm, common_callchain)
parser.wake_up(headers, comm, pid, success, target_cpu, 0)
def sched__sched_wait_task(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid, prio):
pass
def sched__sched_kthread_stop_ret(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, ret):
pass
def sched__sched_kthread_stop(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
common_callchain, comm, pid):
pass
def trace_unhandled(event_name, context, event_fields_dict):
pass
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
445,
3165,
2120,
8367,
23503,
31239,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
8582,
2884,
1566,
8297,
1172,
2757,
4046,
701,
8582,
2884,
446,
71,
2366,
199,
3,
199,
3,
961,
2032,
365,
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,
421,
199,
646,
747,
199,
646,
984,
199,
199,
504,
5055,
492,
10018,
199,
504,
28639,
492,
28639,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
199,
198,
9807,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
1274,
14,
515,
14,
740,
360,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
11672,
492,
627,
199,
504,
428,
1809,
4324,
492,
627,
421,
199,
6962,
275,
469,
378,
520,
298,
12000,
3570,
199,
199,
318,
2462,
63,
354,
8,
3150,
304,
199,
198,
1107,
2071,
83,
2689,
68,
2,
450,
334,
6962,
59,
3150,
467,
4422,
9,
199,
199,
533,
25406,
5912,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
488,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
5187,
2,
199,
199,
533,
25406,
17306,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
26220,
15033,
304,
507,
198,
277,
14,
23042,
15033,
275,
26220,
15033,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
21737,
370,
9435,
2,
450,
2462,
63,
354,
8,
277,
14,
23042,
15033,
9,
199,
199,
533,
25406,
23424,
384,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
21560,
69,
304,
507,
198,
277,
14,
15181,
69,
275,
21560,
69,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
336,
79,
415,
1536,
2,
450,
2462,
63,
354,
8,
277,
14,
15181,
69,
9,
199,
199,
533,
25406,
1858,
75,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
1982,
304,
507,
198,
277,
14,
1739,
275,
1982,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1222,
14926,
379,
2120,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1739,
9,
199,
199,
533,
17664,
26641,
607,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
1949,
16,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
892,
304,
507,
198,
277,
14,
1222,
275,
892,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
315,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1222,
9,
199,
199,
533,
17664,
26641,
2204,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
2269,
304,
507,
198,
277,
14,
1753,
275,
2269,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
734,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1753,
9,
199,
199,
533,
17664,
12038,
26,
199,
198,
318,
636,
826,
721,
277,
12,
6527,
275,
359,
16,
467,
1566,
275,
25406,
5912,
5109,
507,
198,
277,
14,
5054,
275,
2008,
8,
5054,
9,
507,
198,
277,
14,
1430,
275,
1566,
421,
198,
318,
10286,
63,
5656,
8,
277,
12,
5071,
12,
5071,
63,
929,
12,
2163,
304,
507,
198,
1430,
275,
25406,
5912,
342,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
2,
436,
2163,
315,
291,
14,
5054,
971,
686,
198,
460,
5071,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
686,
198,
1430,
275,
25406,
17306,
8,
5701,
9,
2742,
198,
2184,
63,
5054,
275,
769,
8,
277,
14,
5054,
1491,
566,
507,
198,
692,
5071,
315,
291,
14,
5054,
26,
686,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
1585,
198,
2184,
63,
5054,
14,
2168,
8,
5701,
9,
507,
198,
4164,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
582,
686,
198,
2184,
63,
5054,
14,
740,
8,
5701,
9,
2742,
198,
692,
2163,
440,
315,
2163,
63,
5054,
26,
686,
198,
2184,
63,
5054,
14,
740,
8,
2184,
9,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
548,
8,
277,
12,
2269,
304,
507,
198,
692,
2269,
440,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
359,
1765,
367,
2120,
315,
291,
14,
5054,
340,
2120,
1137,
2269,
61,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
17664,
26641,
2204,
8,
1753,
430,
421,
198,
318,
636,
8462,
63,
262,
8,
277,
12,
892,
12,
1566,
304,
507,
198,
692,
892,
315,
291,
14,
5054,
26,
686,
198,
277,
14,
1430,
275,
1566,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
291,
14,
5054,
5873,
435,
2008,
779,
1222,
566,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
262,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
17664,
26641,
607,
8,
1222,
430,
421,
198,
318,
21560,
63,
384,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12
] |
[
2647,
15,
1393,
15,
1548,
199,
3,
199,
3,
445,
3165,
2120,
8367,
23503,
31239,
199,
3,
199,
3,
1898,
334,
35,
9,
7129,
481,
21919,
1567,
2136,
374,
1235,
22043,
665,
70,
1129,
374,
24554,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
8582,
2884,
1566,
8297,
1172,
2757,
4046,
701,
8582,
2884,
446,
71,
2366,
199,
3,
199,
3,
961,
2032,
365,
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,
421,
199,
646,
747,
199,
646,
984,
199,
199,
504,
5055,
492,
10018,
199,
504,
28639,
492,
28639,
199,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
2314,
459,
17038,
63,
10276,
63,
3243,
418,
435,
971,
199,
198,
9807,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
1274,
14,
515,
14,
740,
360,
6429,
15,
1548,
15,
12387,
13,
3921,
13,
9562,
15,
773,
15,
12387,
15,
3921,
358,
199,
199,
504,
8582,
63,
3446,
63,
1100,
492,
627,
199,
504,
11672,
492,
627,
199,
504,
428,
1809,
4324,
492,
627,
421,
199,
6962,
275,
469,
378,
520,
298,
12000,
3570,
199,
199,
318,
2462,
63,
354,
8,
3150,
304,
199,
198,
1107,
2071,
83,
2689,
68,
2,
450,
334,
6962,
59,
3150,
467,
4422,
9,
199,
199,
533,
25406,
5912,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
488,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
5187,
2,
199,
199,
533,
25406,
17306,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
26220,
15033,
304,
507,
198,
277,
14,
23042,
15033,
275,
26220,
15033,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
21737,
370,
9435,
2,
450,
2462,
63,
354,
8,
277,
14,
23042,
15033,
9,
199,
199,
533,
25406,
23424,
384,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
21560,
69,
304,
507,
198,
277,
14,
15181,
69,
275,
21560,
69,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
2071,
83,
336,
79,
415,
1536,
2,
450,
2462,
63,
354,
8,
277,
14,
15181,
69,
9,
199,
199,
533,
25406,
1858,
75,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
3581,
12,
378,
9,
421,
198,
318,
636,
826,
721,
277,
12,
1982,
304,
507,
198,
277,
14,
1739,
275,
1982,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1222,
14926,
379,
2120,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1739,
9,
199,
199,
533,
17664,
26641,
607,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
12,
378,
1949,
16,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
892,
304,
507,
198,
277,
14,
1222,
275,
892,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
315,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1222,
9,
199,
199,
533,
17664,
26641,
2204,
26,
199,
198,
32,
4639,
199,
198,
318,
3164,
837,
507,
198,
1107,
334,
16,
3581,
12,
378,
12,
378,
3581,
9,
421,
198,
318,
636,
826,
721,
277,
12,
2269,
304,
507,
198,
277,
14,
1753,
275,
2269,
421,
198,
318,
636,
2722,
721,
277,
304,
507,
198,
1107,
298,
1765,
28322,
734,
450,
83,
2,
450,
2462,
63,
354,
8,
277,
14,
1753,
9,
199,
199,
533,
17664,
12038,
26,
199,
198,
318,
636,
826,
721,
277,
12,
6527,
275,
359,
16,
467,
1566,
275,
25406,
5912,
5109,
507,
198,
277,
14,
5054,
275,
2008,
8,
5054,
9,
507,
198,
277,
14,
1430,
275,
1566,
421,
198,
318,
10286,
63,
5656,
8,
277,
12,
5071,
12,
5071,
63,
929,
12,
2163,
304,
507,
198,
1430,
275,
25406,
5912,
342,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
2,
436,
2163,
315,
291,
14,
5054,
971,
686,
198,
460,
5071,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
2742,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
686,
198,
1430,
275,
25406,
17306,
8,
5701,
9,
2742,
198,
2184,
63,
5054,
275,
769,
8,
277,
14,
5054,
1491,
566,
507,
198,
692,
5071,
315,
291,
14,
5054,
26,
686,
198,
692,
2120,
2223,
8,
5701,
63,
929,
9,
1137,
298,
50,
582,
1585,
198,
2184,
63,
5054,
14,
2168,
8,
5701,
9,
507,
198,
4164,
2120,
2223,
8,
5701,
63,
929,
9,
508,
298,
50,
582,
686,
198,
2184,
63,
5054,
14,
740,
8,
5701,
9,
2742,
198,
692,
2163,
440,
315,
2163,
63,
5054,
26,
686,
198,
2184,
63,
5054,
14,
740,
8,
2184,
9,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
548,
8,
277,
12,
2269,
304,
507,
198,
692,
2269,
440,
315,
291,
14,
5054,
26,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
359,
1765,
367,
2120,
315,
291,
14,
5054,
340,
2120,
1137,
2269,
61,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
17664,
26641,
2204,
8,
1753,
430,
421,
198,
318,
636,
8462,
63,
262,
8,
277,
12,
892,
12,
1566,
304,
507,
198,
692,
892,
315,
291,
14,
5054,
26,
686,
198,
277,
14,
1430,
275,
1566,
686,
198,
1107,
291,
507,
198,
2184,
63,
5054,
275,
291,
14,
5054,
5873,
435,
2008,
779,
1222,
566,
2742,
198,
1107,
17664,
12038,
8,
2184,
63,
5054,
12,
1566,
9,
421,
198,
318,
12810,
63,
262,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
17664,
26641,
607,
8,
1222,
430,
421,
198,
318,
21560,
63,
384,
8,
277,
12,
892,
304,
507,
198,
1107,
291,
855,
8462,
63,
262,
8,
1222,
12,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
deltreey/ansible
|
lib/ansible/plugins/action/assemble.py
|
39
|
6003
|
# (c) 2013-2014, Michael DeHaan <michael.dehaan@gmail.com>
# Stephen Fromm <sfromm@gmail.com>
# Brian Coca <briancoca+dev@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
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import os.path
import pipes
import shutil
import tempfile
import base64
import re
from ansible.plugins.action import ActionBase
from ansible.utils.boolean import boolean
from ansible.utils.hashing import checksum_s
class ActionModule(ActionBase):
TRANSFERS_FILES = True
def _assemble_from_fragments(self, src_path, delimiter=None, compiled_regexp=None, ignore_hidden=False):
''' assemble a file from a directory of fragments '''
tmpfd, temp_path = tempfile.mkstemp()
tmp = os.fdopen(tmpfd,'w')
delimit_me = False
add_newline = False
for f in sorted(os.listdir(src_path)):
if compiled_regexp and not compiled_regexp.search(f):
continue
fragment = "%s/%s" % (src_path, f)
if not os.path.isfile(fragment) or (ignore_hidden and os.path.basename(fragment).startswith('.')):
continue
fragment_content = file(fragment).read()
# always put a newline between fragments if the previous fragment didn't end with a newline.
if add_newline:
tmp.write('\n')
# delimiters should only appear between fragments
if delimit_me:
if delimiter:
# un-escape anything like newlines
delimiter = delimiter.decode('unicode-escape')
tmp.write(delimiter)
# always make sure there's a newline after the
# delimiter, so lines don't run together
if delimiter[-1] != '\n':
tmp.write('\n')
tmp.write(fragment_content)
delimit_me = True
if fragment_content.endswith('\n'):
add_newline = False
else:
add_newline = True
tmp.close()
return temp_path
def run(self, tmp=None, task_vars=dict()):
if self._play_context.check_mode:
return dict(skipped=True, msg=("skipped, this module does not support check_mode."))
src = self._task.args.get('src', None)
dest = self._task.args.get('dest', None)
delimiter = self._task.args.get('delimiter', None)
remote_src = self._task.args.get('remote_src', 'yes')
regexp = self._task.args.get('regexp', None)
ignore_hidden = self._task.args.get('ignore_hidden', False)
if src is None or dest is None:
return dict(failed=True, msg="src and dest are required")
if boolean(remote_src):
return self._execute_module(tmp=tmp, task_vars=task_vars)
elif self._task._role is not None:
src = self._loader.path_dwim_relative(self._task._role._role_path, 'files', src)
else:
# the source is local, so expand it here
src = self._loader.path_dwim(os.path.expanduser(src))
_re = None
if regexp is not None:
_re = re.compile(regexp)
# Does all work assembling the file
path = self._assemble_from_fragments(src, delimiter, _re, ignore_hidden)
path_checksum = checksum_s(path)
dest = self._remote_expand_user(dest, tmp)
remote_checksum = self._remote_checksum(tmp, dest)
if path_checksum != remote_checksum:
resultant = file(path).read()
# FIXME: diff needs to be moved somewhere else
#if self.runner.diff:
# dest_result = self._execute_module(module_name='slurp', module_args=dict(path=dest), task_vars=task_vars, tmp=tmp, persist_files=True)
# if 'content' in dest_result:
# dest_contents = dest_result['content']
# if dest_result['encoding'] == 'base64':
# dest_contents = base64.b64decode(dest_contents)
# else:
# raise Exception("unknown encoding, failed: %s" % dest_result)
xfered = self._transfer_data('src', resultant)
# fix file permissions when the copy is done as a different user
if self._play_context.become and self._play_context.become_user != 'root':
self._remote_chmod('a+r', xfered, tmp)
# run the copy module
new_module_args = self._task.args.copy()
new_module_args.update(
dict(
src=xfered,
dest=dest,
original_basename=os.path.basename(src),
)
)
res = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars, tmp=tmp)
# FIXME: diff stuff
#res.diff = dict(after=resultant)
return res
else:
new_module_args = self._task.args.copy()
new_module_args.update(
dict(
src=xfered,
dest=dest,
original_basename=os.path.basename(src),
)
)
return self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars, tmp=tmp)
|
gpl-3.0
|
[
3,
334,
67,
9,
6171,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
3698,
17854,
17579,
11606,
77,
665,
83,
504,
77,
32,
6799,
14,
957,
30,
199,
3,
3698,
699,
18429,
445,
679,
65,
221,
665,
9660,
290,
331,
696,
11,
2374,
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,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
747,
14,
515,
199,
646,
20988,
199,
646,
5145,
199,
646,
5549,
199,
646,
1300,
772,
199,
646,
295,
199,
199,
504,
3242,
14,
5265,
14,
1287,
492,
10033,
1563,
199,
504,
3242,
14,
1208,
14,
4871,
492,
5046,
199,
504,
3242,
14,
1208,
14,
2227,
316,
492,
9040,
63,
83,
199,
199,
533,
10033,
2377,
8,
3310,
1563,
304,
339,
9074,
5622,
38,
3960,
63,
9472,
275,
715,
339,
347,
485,
21263,
63,
504,
63,
18047,
8,
277,
12,
2928,
63,
515,
12,
11172,
29,
403,
12,
10311,
63,
11191,
29,
403,
12,
3686,
63,
5642,
29,
797,
304,
267,
1449,
22931,
282,
570,
687,
282,
2082,
402,
21495,
1449,
398,
3529,
2592,
12,
2388,
63,
515,
275,
5549,
14,
17721,
342,
267,
3529,
275,
747,
14,
23140,
8,
2791,
2592,
2584,
87,
358,
267,
477,
3097,
63,
278,
275,
756,
267,
1050,
63,
12210,
275,
756,
398,
367,
289,
315,
3355,
8,
736,
14,
7374,
8,
2164,
63,
515,
2298,
288,
340,
10311,
63,
11191,
436,
440,
10311,
63,
11191,
14,
1733,
8,
70,
304,
355,
1980,
288,
7956,
275,
2071,
83,
3149,
83,
2,
450,
334,
2164,
63,
515,
12,
289,
9,
288,
340,
440,
747,
14,
515,
14,
6292,
8,
7677,
9,
503,
334,
4247,
63,
5642,
436,
747,
14,
515,
14,
4846,
8,
7677,
680,
2460,
7563,
304,
355,
1980,
288,
7956,
63,
1317,
275,
570,
8,
7677,
680,
739,
342,
953,
327,
3544,
5324,
282,
8057,
3382,
21495,
340,
314,
4136,
7956,
9980,
1133,
1284,
543,
282,
8057,
14,
288,
340,
1050,
63,
12210,
26,
355,
3529,
14,
952,
2258,
78,
358,
953,
327,
26968,
1077,
1454,
7468,
3382,
21495,
288,
340,
477,
3097,
63,
278,
26,
355,
340,
11172,
26,
490,
327,
625,
13,
3765,
7003,
2839,
14930,
490,
11172,
275,
11172,
14,
2708,
360,
2975,
13,
3765,
358,
490,
3529,
14,
952,
8,
15104,
9,
490,
327,
3544,
1852,
3238,
2337,
1159,
282,
8057,
2410,
314,
490,
327,
11172,
12,
880,
2385,
2793,
1133,
1255,
10451,
490,
340,
11172,
1988,
17,
61,
1137,
1557,
78,
356,
717,
3529,
14,
952,
2258,
78,
358,
953,
3529,
14,
952,
8,
7677,
63,
1317,
9,
288,
477,
3097,
63,
278,
275,
715,
288,
340,
7956,
63,
1317,
14,
4130,
2258,
78,
735,
355,
1050,
63,
12210,
275,
756,
288,
587,
26,
355,
1050,
63,
12210,
275,
715,
398,
3529,
14,
1600,
342,
267,
372,
2388,
63,
515,
339,
347,
1255,
8,
277,
12,
3529,
29,
403,
12,
2120,
63,
2936,
29,
807,
5109,
398,
340,
291,
423,
2802,
63,
1100,
14,
1074,
63,
632,
26,
288,
372,
1211,
8,
11962,
29,
549,
12,
1499,
15387,
11962,
12,
642,
859,
1630,
440,
2291,
1104,
63,
632,
13853,
398,
2928,
263,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
2164,
297,
488,
9,
267,
2053,
755,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
2614,
297,
488,
9,
267,
11172,
221,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
15104,
297,
488,
9,
267,
3982,
63,
2164,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
3846,
63,
2164,
297,
283,
5066,
358,
267,
13156,
258,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
11191,
297,
488,
9,
267,
3686,
63,
5642,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
4247,
63,
5642,
297,
756,
9,
7318,
340,
2928,
365,
488,
503,
2053,
365,
488,
26,
288,
372,
1211,
8,
4892,
29,
549,
12,
1499,
628,
2164,
436,
2053,
787,
1415,
531,
398,
340,
5046,
8,
3846,
63,
2164,
304,
288,
372,
291,
423,
2526,
63,
578,
8,
2791,
29,
2791,
12,
2120,
63,
2936,
29,
1765,
63,
2936,
9,
267,
916,
291,
423,
1765,
423,
3756,
365,
440,
488,
26,
288,
2928,
275,
291,
423,
3422,
14,
515,
63,
10772,
1017,
63,
6188,
8,
277,
423,
1765,
423,
3756,
423,
3756,
63,
515,
12,
283,
1725,
297,
2928,
9,
267,
587,
26,
288,
327,
314,
1350,
365,
2257,
12,
880,
6544,
652,
2348,
288,
2928,
275,
291,
423,
3422,
14,
515,
63,
10772,
1017,
8,
736,
14,
515,
14,
12131,
8,
2164,
430,
398,
485,
264,
275,
488,
267,
340,
13156,
365,
440,
488,
26,
288,
485,
264,
275,
295,
14,
2014,
8,
11191,
9,
398,
327,
12078,
1006,
1736,
465,
8946,
2983,
314,
570,
267,
931,
275,
291,
423,
21263,
63,
504,
63,
18047,
8,
2164,
12,
11172,
12,
485,
264,
12,
3686,
63,
5642,
9,
398,
931,
63,
8928,
275,
9040,
63,
83,
8,
515,
9,
267,
2053,
275,
291,
423,
3846,
63,
4441,
63,
751,
8,
2614,
12,
3529,
9,
267,
3982,
63,
8928,
275,
291,
423,
3846,
63,
8928,
8,
2791,
12,
2053,
9,
398,
340,
931,
63,
8928,
1137,
3982,
63,
8928,
26,
288,
754,
867,
275,
570,
8,
515,
680,
739,
342,
288,
327,
7600,
26,
3915,
4839
] |
[
334,
67,
9,
6171,
13,
7280,
12,
16922,
22453,
665,
22333,
14,
24247,
32,
6799,
14,
957,
30,
199,
3,
3698,
17854,
17579,
11606,
77,
665,
83,
504,
77,
32,
6799,
14,
957,
30,
199,
3,
3698,
699,
18429,
445,
679,
65,
221,
665,
9660,
290,
331,
696,
11,
2374,
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,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
747,
14,
515,
199,
646,
20988,
199,
646,
5145,
199,
646,
5549,
199,
646,
1300,
772,
199,
646,
295,
199,
199,
504,
3242,
14,
5265,
14,
1287,
492,
10033,
1563,
199,
504,
3242,
14,
1208,
14,
4871,
492,
5046,
199,
504,
3242,
14,
1208,
14,
2227,
316,
492,
9040,
63,
83,
199,
199,
533,
10033,
2377,
8,
3310,
1563,
304,
339,
9074,
5622,
38,
3960,
63,
9472,
275,
715,
339,
347,
485,
21263,
63,
504,
63,
18047,
8,
277,
12,
2928,
63,
515,
12,
11172,
29,
403,
12,
10311,
63,
11191,
29,
403,
12,
3686,
63,
5642,
29,
797,
304,
267,
1449,
22931,
282,
570,
687,
282,
2082,
402,
21495,
1449,
398,
3529,
2592,
12,
2388,
63,
515,
275,
5549,
14,
17721,
342,
267,
3529,
275,
747,
14,
23140,
8,
2791,
2592,
2584,
87,
358,
267,
477,
3097,
63,
278,
275,
756,
267,
1050,
63,
12210,
275,
756,
398,
367,
289,
315,
3355,
8,
736,
14,
7374,
8,
2164,
63,
515,
2298,
288,
340,
10311,
63,
11191,
436,
440,
10311,
63,
11191,
14,
1733,
8,
70,
304,
355,
1980,
288,
7956,
275,
2071,
83,
3149,
83,
2,
450,
334,
2164,
63,
515,
12,
289,
9,
288,
340,
440,
747,
14,
515,
14,
6292,
8,
7677,
9,
503,
334,
4247,
63,
5642,
436,
747,
14,
515,
14,
4846,
8,
7677,
680,
2460,
7563,
304,
355,
1980,
288,
7956,
63,
1317,
275,
570,
8,
7677,
680,
739,
342,
953,
327,
3544,
5324,
282,
8057,
3382,
21495,
340,
314,
4136,
7956,
9980,
1133,
1284,
543,
282,
8057,
14,
288,
340,
1050,
63,
12210,
26,
355,
3529,
14,
952,
2258,
78,
358,
953,
327,
26968,
1077,
1454,
7468,
3382,
21495,
288,
340,
477,
3097,
63,
278,
26,
355,
340,
11172,
26,
490,
327,
625,
13,
3765,
7003,
2839,
14930,
490,
11172,
275,
11172,
14,
2708,
360,
2975,
13,
3765,
358,
490,
3529,
14,
952,
8,
15104,
9,
490,
327,
3544,
1852,
3238,
2337,
1159,
282,
8057,
2410,
314,
490,
327,
11172,
12,
880,
2385,
2793,
1133,
1255,
10451,
490,
340,
11172,
1988,
17,
61,
1137,
1557,
78,
356,
717,
3529,
14,
952,
2258,
78,
358,
953,
3529,
14,
952,
8,
7677,
63,
1317,
9,
288,
477,
3097,
63,
278,
275,
715,
288,
340,
7956,
63,
1317,
14,
4130,
2258,
78,
735,
355,
1050,
63,
12210,
275,
756,
288,
587,
26,
355,
1050,
63,
12210,
275,
715,
398,
3529,
14,
1600,
342,
267,
372,
2388,
63,
515,
339,
347,
1255,
8,
277,
12,
3529,
29,
403,
12,
2120,
63,
2936,
29,
807,
5109,
398,
340,
291,
423,
2802,
63,
1100,
14,
1074,
63,
632,
26,
288,
372,
1211,
8,
11962,
29,
549,
12,
1499,
15387,
11962,
12,
642,
859,
1630,
440,
2291,
1104,
63,
632,
13853,
398,
2928,
263,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
2164,
297,
488,
9,
267,
2053,
755,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
2614,
297,
488,
9,
267,
11172,
221,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
15104,
297,
488,
9,
267,
3982,
63,
2164,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
3846,
63,
2164,
297,
283,
5066,
358,
267,
13156,
258,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
11191,
297,
488,
9,
267,
3686,
63,
5642,
275,
291,
423,
1765,
14,
589,
14,
362,
360,
4247,
63,
5642,
297,
756,
9,
7318,
340,
2928,
365,
488,
503,
2053,
365,
488,
26,
288,
372,
1211,
8,
4892,
29,
549,
12,
1499,
628,
2164,
436,
2053,
787,
1415,
531,
398,
340,
5046,
8,
3846,
63,
2164,
304,
288,
372,
291,
423,
2526,
63,
578,
8,
2791,
29,
2791,
12,
2120,
63,
2936,
29,
1765,
63,
2936,
9,
267,
916,
291,
423,
1765,
423,
3756,
365,
440,
488,
26,
288,
2928,
275,
291,
423,
3422,
14,
515,
63,
10772,
1017,
63,
6188,
8,
277,
423,
1765,
423,
3756,
423,
3756,
63,
515,
12,
283,
1725,
297,
2928,
9,
267,
587,
26,
288,
327,
314,
1350,
365,
2257,
12,
880,
6544,
652,
2348,
288,
2928,
275,
291,
423,
3422,
14,
515,
63,
10772,
1017,
8,
736,
14,
515,
14,
12131,
8,
2164,
430,
398,
485,
264,
275,
488,
267,
340,
13156,
365,
440,
488,
26,
288,
485,
264,
275,
295,
14,
2014,
8,
11191,
9,
398,
327,
12078,
1006,
1736,
465,
8946,
2983,
314,
570,
267,
931,
275,
291,
423,
21263,
63,
504,
63,
18047,
8,
2164,
12,
11172,
12,
485,
264,
12,
3686,
63,
5642,
9,
398,
931,
63,
8928,
275,
9040,
63,
83,
8,
515,
9,
267,
2053,
275,
291,
423,
3846,
63,
4441,
63,
751,
8,
2614,
12,
3529,
9,
267,
3982,
63,
8928,
275,
291,
423,
3846,
63,
8928,
8,
2791,
12,
2053,
9,
398,
340,
931,
63,
8928,
1137,
3982,
63,
8928,
26,
288,
754,
867,
275,
570,
8,
515,
680,
739,
342,
288,
327,
7600,
26,
3915,
4839,
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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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
rouault/Quantum-GIS
|
python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
|
1
|
5765
|
# -*- coding: utf-8 -*-
"""
***************************************************************************
SagaAlgorithmProvider.py
---------------------
Date : August 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__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QCoreApplication
from qgis.core import (Qgis,
QgsProcessingProvider,
QgsProcessingUtils,
QgsApplication,
QgsMessageLog)
from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.tools.system import isWindows, isMac
from .SagaAlgorithm import SagaAlgorithm
from .SplitRGBBands import SplitRGBBands
from . import SagaUtils
pluginPath = os.path.normpath(os.path.join(
os.path.split(os.path.dirname(__file__))[0], os.pardir))
REQUIRED_VERSION = '2.3.'
class SagaAlgorithmProvider(QgsProcessingProvider):
def __init__(self):
super().__init__()
self.algs = []
def load(self):
ProcessingConfig.settingIcons[self.name()] = self.icon()
ProcessingConfig.addSetting(Setting("SAGA", 'ACTIVATE_SAGA',
self.tr('Activate'), True))
ProcessingConfig.addSetting(Setting("SAGA",
SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION,
self.tr('Enable SAGA Import/Export optimizations'), False))
ProcessingConfig.addSetting(Setting("SAGA",
SagaUtils.SAGA_LOG_COMMANDS,
self.tr('Log execution commands'), True))
ProcessingConfig.addSetting(Setting("SAGA",
SagaUtils.SAGA_LOG_CONSOLE,
self.tr('Log console output'), True))
ProcessingConfig.readSettings()
self.refreshAlgorithms()
return True
def unload(self):
ProcessingConfig.removeSetting('ACTIVATE_SAGA')
ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_CONSOLE)
ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_COMMANDS)
def isActive(self):
return ProcessingConfig.getSetting('ACTIVATE_SAGA')
def setActive(self, active):
ProcessingConfig.setSettingValue('ACTIVATE_SAGA', active)
def loadAlgorithms(self):
version = SagaUtils.getInstalledVersion(True)
if version is None:
QgsMessageLog.logMessage(self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'),
self.tr('Processing'), Qgis.Critical)
return
if not version.startswith(REQUIRED_VERSION):
QgsMessageLog.logMessage(self.tr('Problem with SAGA installation: unsupported SAGA version (found: {}, required: {}).').format(version, REQUIRED_VERSION),
self.tr('Processing'),
Qgis.Critical)
return
self.algs = []
folder = SagaUtils.sagaDescriptionPath()
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('txt'):
try:
alg = SagaAlgorithm(os.path.join(folder, descriptionFile))
if alg.name().strip() != '':
self.algs.append(alg)
else:
QgsMessageLog.logMessage(self.tr('Could not open SAGA algorithm: {}'.format(descriptionFile)),
self.tr('Processing'), Qgis.Critical)
except Exception as e:
QgsMessageLog.logMessage(self.tr('Could not open SAGA algorithm: {}\n{}'.format(descriptionFile, str(e))),
self.tr('Processing'), Qgis.Critical)
self.algs.append(SplitRGBBands())
for a in self.algs:
self.addAlgorithm(a)
def name(self):
return 'SAGA'
def longName(self):
version = SagaUtils.getInstalledVersion()
return 'SAGA ({})'.format(version) if version is not None else 'SAGA'
def id(self):
return 'saga'
def defaultVectorFileExtension(self, hasGeometry=True):
return 'shp'
def defaultRasterFileExtension(self):
return 'sdat'
def supportedOutputTableExtensions(self):
return ['dbf']
def supportsNonFileBasedOutput(self):
"""
SAGA Provider doesn't support non file based outputs
"""
return False
def icon(self):
return QgsApplication.getThemeIcon("/providerSaga.svg")
def tr(self, string, context=''):
if context == '':
context = 'SagaAlgorithmProvider'
return QCoreApplication.translate(context, string)
|
gpl-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
17623,
272,
428,
643,
65,
11570,
6663,
14,
647,
272,
10652,
9858,
272,
6148,
463,
520,
25298,
833,
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,
21640,
833,
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,
747,
199,
504,
15640,
14,
24107,
14,
10604,
492,
1413,
8954,
199,
504,
15640,
14,
24107,
14,
10901,
492,
1413,
29263,
199,
504,
15640,
14,
1018,
492,
334,
49,
5668,
12,
2432,
17214,
6663,
12,
2432,
17214,
7535,
12,
2432,
4888,
5039,
12,
2432,
4888,
2209,
2445,
9,
199,
504,
6661,
14,
1018,
14,
9589,
2028,
492,
20157,
2028,
12,
13510,
199,
504,
6661,
14,
2537,
14,
2253,
492,
365,
8647,
12,
365,
3399,
199,
199,
504,
1275,
51,
643,
65,
11570,
492,
428,
643,
65,
11570,
199,
504,
1275,
8862,
14058,
5342,
5915,
492,
11740,
14058,
5342,
5915,
199,
504,
1275,
492,
428,
643,
65,
7535,
199,
199,
2718,
2042,
275,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
14,
904,
8,
272,
747,
14,
515,
14,
1294,
8,
736,
14,
515,
14,
3475,
3460,
493,
8964,
59,
16,
467,
747,
14,
21386,
430,
199,
199,
12496,
63,
4612,
275,
283,
18,
14,
19,
3530,
421,
199,
533,
428,
643,
65,
11570,
6663,
8,
28559,
6663,
304,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
11027,
826,
4533,
267,
291,
14,
31128,
275,
942,
339,
347,
2248,
8,
277,
304,
267,
20157,
2028,
14,
6031,
41,
8704,
59,
277,
14,
354,
5106,
275,
291,
14,
4677,
342,
267,
20157,
2028,
14,
525,
7776,
8,
7776,
480,
51,
1254,
33,
401,
283,
20425,
1951,
63,
51,
1254,
33,
297,
4490,
291,
14,
454,
360,
30120,
659,
715,
430,
267,
20157,
2028,
14,
525,
7776,
8,
7776,
480,
51,
1254,
33,
401,
4490,
428,
643,
65,
7535,
14,
51,
1254,
33,
63,
17576,
63,
18341,
63,
5123,
1469,
22800,
12,
4490,
291,
14,
454,
360,
6476,
428,
1254,
33,
3161,
15,
11399,
5323,
12270,
659,
756,
430,
267,
20157,
2028,
14,
525,
7776,
8,
7776,
480,
51,
1254,
33,
401,
4490,
428,
643,
65,
7535,
14,
51,
1254,
33,
63,
4947,
63,
28442,
12,
4490,
291,
14,
454,
360,
2445,
6451,
3718,
659,
715,
430,
267,
20157,
2028,
14,
525,
7776,
8,
7776,
480,
51,
1254,
33,
401,
4490,
428,
643,
65,
7535,
14,
51,
1254,
33,
63,
4947,
63,
31774,
12,
4490,
291,
14,
454,
360,
2445,
8559,
1072,
659,
715,
430,
267,
20157,
2028,
14,
739,
5268,
342,
267,
291,
14,
6635,
2439,
12719,
342,
267,
372,
715,
339,
347,
625,
912,
8,
277,
304,
267,
20157,
2028,
14,
2168,
7776,
360,
20425,
1951,
63,
51,
1254,
33,
358,
267,
20157,
2028,
14,
2168,
7776,
8,
51,
643,
65,
7535,
14,
51,
1254,
33,
63,
4947,
63,
31774,
9,
267,
20157,
2028,
14,
2168,
7776,
8,
51,
643,
65,
7535,
14,
51,
1254,
33,
63,
4947,
63,
28442,
9,
339,
347,
365,
7472,
8,
277,
304,
267,
372,
20157,
2028,
14,
30008,
360,
20425,
1951,
63,
51,
1254,
33,
358,
339,
347,
663,
7472,
8,
277,
12,
4702,
304,
267,
20157,
2028,
14,
409,
7776,
1110,
360,
20425,
1951,
63,
51,
1254,
33,
297,
4702,
9,
339,
347,
2248,
2439,
12719,
8,
277,
304,
267,
1015,
275,
428,
643,
65,
7535,
14,
362,
21268,
3353,
8,
549,
9,
267,
340,
1015,
365,
488,
26,
288,
4888,
2209,
2445,
14,
793,
2209,
8,
277,
14,
454,
360,
16467,
543,
428,
1254,
33,
12096,
26,
428,
1254,
33,
1990,
440,
1911,
503,
365,
440,
6657,
4903,
659,
3660,
291,
14,
454,
360,
9589,
659,
1413,
5668,
14,
27677,
9,
288,
372,
398,
340,
440,
1015,
14,
2460,
8,
12496,
63,
4612,
304,
288,
4888,
2209,
2445,
14,
793,
2209,
8,
277,
14,
454,
360,
16467,
543,
428,
1254,
33,
12096,
26,
16313,
428,
1254,
33,
1015,
334,
4214,
26,
5479,
1415,
26,
13056,
1959,
908,
8,
1023,
12,
25090,
63,
4612,
395,
3660,
291,
14,
454,
360,
9589,
659,
3660,
1413,
5668,
14,
27677,
9,
288,
372,
398,
291,
14,
31128,
275,
942,
267,
4922,
275,
428,
643,
65,
7535,
14,
83,
643,
65,
5831,
2042,
342,
267,
367,
1369,
1173,
315,
747,
14,
7374,
8,
3741,
304,
288,
340,
1369,
1173,
14,
4130,
360,
2424,
735,
355,
862,
26,
490,
15760,
275,
428,
643,
65,
11570,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
1369,
1173,
430,
490,
340,
15760,
14,
354,
1252,
1913,
342,
1137,
8061,
717,
291,
14,
31128,
14,
740,
8,
6731,
9,
490,
587,
26,
717,
4888,
2209,
2445,
14,
793,
2209,
8,
277,
14,
454,
360,
6531,
440,
1551,
428,
1254,
33,
5563,
26,
9499,
908,
8,
1802,
1173,
1826,
1740,
291,
14,
454,
360,
9589,
659,
1413,
5668,
14,
27677,
9,
355,
871,
2186,
465,
325,
26,
490,
4888,
2209,
2445,
14,
793,
2209,
8,
277,
14,
454,
360,
6531,
440,
1551,
428,
1254,
33,
5563,
26,
22902,
78,
11123,
908,
8,
1802,
1173,
12,
620,
8,
69,
11508,
6163,
291,
14,
454,
360,
9589,
659,
1413,
5668,
14,
27677,
9,
398,
291,
14,
31128,
14,
740,
8,
8862,
14058,
5342,
5915,
1012,
267,
367
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
624,
199,
17623,
272,
428,
643,
65,
11570,
6663,
14,
647,
272,
10652,
9858,
272,
6148,
463,
520,
25298,
833,
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,
21640,
833,
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,
747,
199,
504,
15640,
14,
24107,
14,
10604,
492,
1413,
8954,
199,
504,
15640,
14,
24107,
14,
10901,
492,
1413,
29263,
199,
504,
15640,
14,
1018,
492,
334,
49,
5668,
12,
2432,
17214,
6663,
12,
2432,
17214,
7535,
12,
2432,
4888,
5039,
12,
2432,
4888,
2209,
2445,
9,
199,
504,
6661,
14,
1018,
14,
9589,
2028,
492,
20157,
2028,
12,
13510,
199,
504,
6661,
14,
2537,
14,
2253,
492,
365,
8647,
12,
365,
3399,
199,
199,
504,
1275,
51,
643,
65,
11570,
492,
428,
643,
65,
11570,
199,
504,
1275,
8862,
14058,
5342,
5915,
492,
11740,
14058,
5342,
5915,
199,
504,
1275,
492,
428,
643,
65,
7535,
199,
199,
2718,
2042,
275,
747,
14,
515,
14,
9267,
8,
736,
14,
515,
14,
904,
8,
272,
747,
14,
515,
14,
1294,
8,
736,
14,
515,
14,
3475,
3460,
493,
8964,
59,
16,
467,
747,
14,
21386,
430,
199,
199,
12496,
63,
4612,
275,
283,
18,
14,
19,
3530,
421,
199,
533,
428,
643,
65,
11570,
6663,
8,
28559,
6663,
304,
339,
347,
636,
826,
721,
277,
304,
267,
1613,
11027,
826,
4533,
267,
291,
14,
31128,
275,
942,
339,
347,
2248,
8,
277,
304,
267,
20157,
2028,
14,
6031,
41,
8704,
59,
277,
14,
354,
5106,
275,
291,
14,
4677,
342,
267,
20157,
2028,
14,
525,
7776,
8,
7776,
480,
51,
1254,
33,
401,
283,
20425,
1951,
63,
51,
1254,
33,
297,
4490,
291,
14,
454,
360,
30120,
659,
715,
430,
267,
20157,
2028,
14,
525,
7776,
8,
7776,
480,
51,
1254,
33,
401,
4490,
428,
643,
65,
7535,
14,
51,
1254,
33,
63,
17576,
63,
18341,
63,
5123,
1469,
22800,
12,
4490,
291,
14,
454,
360,
6476,
428,
1254,
33,
3161,
15,
11399,
5323,
12270,
659,
756,
430,
267,
20157,
2028,
14,
525,
7776,
8,
7776,
480,
51,
1254,
33,
401,
4490,
428,
643,
65,
7535,
14,
51,
1254,
33,
63,
4947,
63,
28442,
12,
4490,
291,
14,
454,
360,
2445,
6451,
3718,
659,
715,
430,
267,
20157,
2028,
14,
525,
7776,
8,
7776,
480,
51,
1254,
33,
401,
4490,
428,
643,
65,
7535,
14,
51,
1254,
33,
63,
4947,
63,
31774,
12,
4490,
291,
14,
454,
360,
2445,
8559,
1072,
659,
715,
430,
267,
20157,
2028,
14,
739,
5268,
342,
267,
291,
14,
6635,
2439,
12719,
342,
267,
372,
715,
339,
347,
625,
912,
8,
277,
304,
267,
20157,
2028,
14,
2168,
7776,
360,
20425,
1951,
63,
51,
1254,
33,
358,
267,
20157,
2028,
14,
2168,
7776,
8,
51,
643,
65,
7535,
14,
51,
1254,
33,
63,
4947,
63,
31774,
9,
267,
20157,
2028,
14,
2168,
7776,
8,
51,
643,
65,
7535,
14,
51,
1254,
33,
63,
4947,
63,
28442,
9,
339,
347,
365,
7472,
8,
277,
304,
267,
372,
20157,
2028,
14,
30008,
360,
20425,
1951,
63,
51,
1254,
33,
358,
339,
347,
663,
7472,
8,
277,
12,
4702,
304,
267,
20157,
2028,
14,
409,
7776,
1110,
360,
20425,
1951,
63,
51,
1254,
33,
297,
4702,
9,
339,
347,
2248,
2439,
12719,
8,
277,
304,
267,
1015,
275,
428,
643,
65,
7535,
14,
362,
21268,
3353,
8,
549,
9,
267,
340,
1015,
365,
488,
26,
288,
4888,
2209,
2445,
14,
793,
2209,
8,
277,
14,
454,
360,
16467,
543,
428,
1254,
33,
12096,
26,
428,
1254,
33,
1990,
440,
1911,
503,
365,
440,
6657,
4903,
659,
3660,
291,
14,
454,
360,
9589,
659,
1413,
5668,
14,
27677,
9,
288,
372,
398,
340,
440,
1015,
14,
2460,
8,
12496,
63,
4612,
304,
288,
4888,
2209,
2445,
14,
793,
2209,
8,
277,
14,
454,
360,
16467,
543,
428,
1254,
33,
12096,
26,
16313,
428,
1254,
33,
1015,
334,
4214,
26,
5479,
1415,
26,
13056,
1959,
908,
8,
1023,
12,
25090,
63,
4612,
395,
3660,
291,
14,
454,
360,
9589,
659,
3660,
1413,
5668,
14,
27677,
9,
288,
372,
398,
291,
14,
31128,
275,
942,
267,
4922,
275,
428,
643,
65,
7535,
14,
83,
643,
65,
5831,
2042,
342,
267,
367,
1369,
1173,
315,
747,
14,
7374,
8,
3741,
304,
288,
340,
1369,
1173,
14,
4130,
360,
2424,
735,
355,
862,
26,
490,
15760,
275,
428,
643,
65,
11570,
8,
736,
14,
515,
14,
904,
8,
3741,
12,
1369,
1173,
430,
490,
340,
15760,
14,
354,
1252,
1913,
342,
1137,
8061,
717,
291,
14,
31128,
14,
740,
8,
6731,
9,
490,
587,
26,
717,
4888,
2209,
2445,
14,
793,
2209,
8,
277,
14,
454,
360,
6531,
440,
1551,
428,
1254,
33,
5563,
26,
9499,
908,
8,
1802,
1173,
1826,
1740,
291,
14,
454,
360,
9589,
659,
1413,
5668,
14,
27677,
9,
355,
871,
2186,
465,
325,
26,
490,
4888,
2209,
2445,
14,
793,
2209,
8,
277,
14,
454,
360,
6531,
440,
1551,
428,
1254,
33,
5563,
26,
22902,
78,
11123,
908,
8,
1802,
1173,
12,
620,
8,
69,
11508,
6163,
291,
14,
454,
360,
9589,
659,
1413,
5668,
14,
27677,
9,
398,
291,
14,
31128,
14,
740,
8,
8862,
14058,
5342,
5915,
1012,
267,
367,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
yinquan529/people-harigopal.gollamudi-glmark2
|
waflib/Tools/c_preproc.py
|
11
|
16594
|
#! /usr/bin/env python
# encoding: utf-8
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
import sys
if sys.hexversion < 0x020400f0: from sets import Set as set
import re,sys,os,string,traceback
from waflib import Logs,Build,Utils,Errors
from waflib.Logs import debug,error
class PreprocError(Errors.WafError):
pass
POPFILE='-'
recursion_limit=150
go_absolute=False
standard_includes=['/usr/include']
if Utils.is_win32:
standard_includes=[]
use_trigraphs=0
strict_quotes=0
g_optrans={'not':'!','and':'&&','bitand':'&','and_eq':'&=','or':'||','bitor':'|','or_eq':'|=','xor':'^','xor_eq':'^=','compl':'~',}
re_lines=re.compile('^[ \t]*(#|%:)[ \t]*(ifdef|ifndef|if|else|elif|endif|include|import|define|undef|pragma)[ \t]*(.*)\r*$',re.IGNORECASE|re.MULTILINE)
re_mac=re.compile("^[a-zA-Z_]\w*")
re_fun=re.compile('^[a-zA-Z_][a-zA-Z0-9_]*[(]')
re_pragma_once=re.compile('^\s*once\s*',re.IGNORECASE)
re_nl=re.compile('\\\\\r*\n',re.MULTILINE)
re_cpp=re.compile(r"""(/\*[^*]*\*+([^/*][^*]*\*+)*/)|//[^\n]*|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)""",re.MULTILINE)
trig_def=[('??'+a,b)for a,b in zip("=-/!'()<>",r'#~\|^[]{}')]
chr_esc={'0':0,'a':7,'b':8,'t':9,'n':10,'f':11,'v':12,'r':13,'\\':92,"'":39}
NUM='i'
OP='O'
IDENT='T'
STR='s'
CHAR='c'
tok_types=[NUM,STR,IDENT,OP]
exp_types=[r"""0[xX](?P<hex>[a-fA-F0-9]+)(?P<qual1>[uUlL]*)|L*?'(?P<char>(\\.|[^\\'])+)'|(?P<n1>\d+)[Ee](?P<exp0>[+-]*?\d+)(?P<float0>[fFlL]*)|(?P<n2>\d*\.\d+)([Ee](?P<exp1>[+-]*?\d+))?(?P<float1>[fFlL]*)|(?P<n4>\d+\.\d*)([Ee](?P<exp2>[+-]*?\d+))?(?P<float2>[fFlL]*)|(?P<oct>0*)(?P<n0>\d+)(?P<qual2>[uUlL]*)""",r'L?"([^"\\]|\\.)*"',r'[a-zA-Z_]\w*',r'%:%:|<<=|>>=|\.\.\.|<<|<%|<:|<=|>>|>=|\+\+|\+=|--|->|-=|\*=|/=|%:|%=|%>|==|&&|&=|\|\||\|=|\^=|:>|!=|##|[\(\)\{\}\[\]<>\?\|\^\*\+&=:!#;,%/\-\?\~\.]',]
re_clexer=re.compile('|'.join(["(?P<%s>%s)"%(name,part)for name,part in zip(tok_types,exp_types)]),re.M)
accepted='a'
ignored='i'
undefined='u'
skipped='s'
def repl(m):
s=m.group(1)
if s:
return' '
return m.group(3)or''
def filter_comments(filename):
code=Utils.readf(filename)
if use_trigraphs:
for(a,b)in trig_def:code=code.split(a).join(b)
code=re_nl.sub('',code)
code=re_cpp.sub(repl,code)
return[(m.group(2),m.group(3))for m in re.finditer(re_lines,code)]
prec={}
ops=['* / %','+ -','<< >>','< <= >= >','== !=','& | ^','&& ||',',']
for x in range(len(ops)):
syms=ops[x]
for u in syms.split():
prec[u]=x
def trimquotes(s):
if not s:return''
s=s.rstrip()
if s[0]=="'"and s[-1]=="'":return s[1:-1]
return s
def reduce_nums(val_1,val_2,val_op):
try:a=0+val_1
except TypeError:a=int(val_1)
try:b=0+val_2
except TypeError:b=int(val_2)
d=val_op
if d=='%':c=a%b
elif d=='+':c=a+b
elif d=='-':c=a-b
elif d=='*':c=a*b
elif d=='/':c=a/b
elif d=='^':c=a^b
elif d=='|':c=a|b
elif d=='||':c=int(a or b)
elif d=='&':c=a&b
elif d=='&&':c=int(a and b)
elif d=='==':c=int(a==b)
elif d=='!=':c=int(a!=b)
elif d=='<=':c=int(a<=b)
elif d=='<':c=int(a<b)
elif d=='>':c=int(a>b)
elif d=='>=':c=int(a>=b)
elif d=='^':c=int(a^b)
elif d=='<<':c=a<<b
elif d=='>>':c=a>>b
else:c=0
return c
def get_num(lst):
if not lst:raise PreprocError("empty list for get_num")
(p,v)=lst[0]
if p==OP:
if v=='(':
count_par=1
i=1
while i<len(lst):
(p,v)=lst[i]
if p==OP:
if v==')':
count_par-=1
if count_par==0:
break
elif v=='(':
count_par+=1
i+=1
else:
raise PreprocError("rparen expected %r"%lst)
(num,_)=get_term(lst[1:i])
return(num,lst[i+1:])
elif v=='+':
return get_num(lst[1:])
elif v=='-':
num,lst=get_num(lst[1:])
return(reduce_nums('-1',num,'*'),lst)
elif v=='!':
num,lst=get_num(lst[1:])
return(int(not int(num)),lst)
elif v=='~':
return(~int(num),lst)
else:
raise PreprocError("Invalid op token %r for get_num"%lst)
elif p==NUM:
return v,lst[1:]
elif p==IDENT:
return 0,lst[1:]
else:
raise PreprocError("Invalid token %r for get_num"%lst)
def get_term(lst):
if not lst:raise PreprocError("empty list for get_term")
num,lst=get_num(lst)
if not lst:
return(num,[])
(p,v)=lst[0]
if p==OP:
if v=='&&'and not num:
return(num,[])
elif v=='||'and num:
return(num,[])
elif v==',':
return get_term(lst[1:])
elif v=='?':
count_par=0
i=1
while i<len(lst):
(p,v)=lst[i]
if p==OP:
if v==')':
count_par-=1
elif v=='(':
count_par+=1
elif v==':':
if count_par==0:
break
i+=1
else:
raise PreprocError("rparen expected %r"%lst)
if int(num):
return get_term(lst[1:i])
else:
return get_term(lst[i+1:])
else:
num2,lst=get_num(lst[1:])
if not lst:
num2=reduce_nums(num,num2,v)
return get_term([(NUM,num2)]+lst)
p2,v2=lst[0]
if p2!=OP:
raise PreprocError("op expected %r"%lst)
if prec[v2]>=prec[v]:
num2=reduce_nums(num,num2,v)
return get_term([(NUM,num2)]+lst)
else:
num3,lst=get_num(lst[1:])
num3=reduce_nums(num2,num3,v2)
return get_term([(NUM,num),(p,v),(NUM,num3)]+lst)
raise PreprocError("cannot reduce %r"%lst)
def reduce_eval(lst):
num,lst=get_term(lst)
return(NUM,num)
def stringize(lst):
lst=[str(v2)for(p2,v2)in lst]
return"".join(lst)
def paste_tokens(t1,t2):
p1=None
if t1[0]==OP and t2[0]==OP:
p1=OP
elif t1[0]==IDENT and(t2[0]==IDENT or t2[0]==NUM):
p1=IDENT
elif t1[0]==NUM and t2[0]==NUM:
p1=NUM
if not p1:
raise PreprocError('tokens do not make a valid paste %r and %r'%(t1,t2))
return(p1,t1[1]+t2[1])
def reduce_tokens(lst,defs,ban=[]):
i=0
while i<len(lst):
(p,v)=lst[i]
if p==IDENT and v=="defined":
del lst[i]
if i<len(lst):
(p2,v2)=lst[i]
if p2==IDENT:
if v2 in defs:
lst[i]=(NUM,1)
else:
lst[i]=(NUM,0)
elif p2==OP and v2=='(':
del lst[i]
(p2,v2)=lst[i]
del lst[i]
if v2 in defs:
lst[i]=(NUM,1)
else:
lst[i]=(NUM,0)
else:
raise PreprocError("Invalid define expression %r"%lst)
elif p==IDENT and v in defs:
if isinstance(defs[v],str):
a,b=extract_macro(defs[v])
defs[v]=b
macro_def=defs[v]
to_add=macro_def[1]
if isinstance(macro_def[0],list):
del lst[i]
for x in range(len(to_add)):
lst.insert(i,to_add[x])
i+=1
else:
args=[]
del lst[i]
if i>=len(lst):
raise PreprocError("expected '(' after %r (got nothing)"%v)
(p2,v2)=lst[i]
if p2!=OP or v2!='(':
raise PreprocError("expected '(' after %r"%v)
del lst[i]
one_param=[]
count_paren=0
while i<len(lst):
p2,v2=lst[i]
del lst[i]
if p2==OP and count_paren==0:
if v2=='(':
one_param.append((p2,v2))
count_paren+=1
elif v2==')':
if one_param:args.append(one_param)
break
elif v2==',':
if not one_param:raise PreprocError("empty param in funcall %s"%p)
args.append(one_param)
one_param=[]
else:
one_param.append((p2,v2))
else:
one_param.append((p2,v2))
if v2=='(':count_paren+=1
elif v2==')':count_paren-=1
else:
raise PreprocError('malformed macro')
accu=[]
arg_table=macro_def[0]
j=0
while j<len(to_add):
(p2,v2)=to_add[j]
if p2==OP and v2=='#':
if j+1<len(to_add)and to_add[j+1][0]==IDENT and to_add[j+1][1]in arg_table:
toks=args[arg_table[to_add[j+1][1]]]
accu.append((STR,stringize(toks)))
j+=1
else:
accu.append((p2,v2))
elif p2==OP and v2=='##':
if accu and j+1<len(to_add):
t1=accu[-1]
if to_add[j+1][0]==IDENT and to_add[j+1][1]in arg_table:
toks=args[arg_table[to_add[j+1][1]]]
if toks:
accu[-1]=paste_tokens(t1,toks[0])
accu.extend(toks[1:])
else:
accu.append((p2,v2))
accu.extend(toks)
elif to_add[j+1][0]==IDENT and to_add[j+1][1]=='__VA_ARGS__':
va_toks=[]
st=len(macro_def[0])
pt=len(args)
for x in args[pt-st+1:]:
va_toks.extend(x)
va_toks.append((OP,','))
if va_toks:va_toks.pop()
if len(accu)>1:
(p3,v3)=accu[-1]
(p4,v4)=accu[-2]
if v3=='##':
accu.pop()
if v4==','and pt<st:
accu.pop()
accu+=va_toks
else:
accu[-1]=paste_tokens(t1,to_add[j+1])
j+=1
else:
accu.append((p2,v2))
elif p2==IDENT and v2 in arg_table:
toks=args[arg_table[v2]]
reduce_tokens(toks,defs,ban+[v])
accu.extend(toks)
else:
accu.append((p2,v2))
j+=1
reduce_tokens(accu,defs,ban+[v])
for x in range(len(accu)-1,-1,-1):
lst.insert(i,accu[x])
i+=1
def eval_macro(lst,defs):
reduce_tokens(lst,defs,[])
if not lst:raise PreprocError("missing tokens to evaluate")
(p,v)=reduce_eval(lst)
return int(v)!=0
def extract_macro(txt):
t=tokenize(txt)
if re_fun.search(txt):
p,name=t[0]
p,v=t[1]
if p!=OP:raise PreprocError("expected open parenthesis")
i=1
pindex=0
params={}
prev='('
while 1:
i+=1
p,v=t[i]
if prev=='(':
if p==IDENT:
params[v]=pindex
pindex+=1
prev=p
elif p==OP and v==')':
break
else:
raise PreprocError("unexpected token (3)")
elif prev==IDENT:
if p==OP and v==',':
prev=v
elif p==OP and v==')':
break
else:
raise PreprocError("comma or ... expected")
elif prev==',':
if p==IDENT:
params[v]=pindex
pindex+=1
prev=p
elif p==OP and v=='...':
raise PreprocError("not implemented (1)")
else:
raise PreprocError("comma or ... expected (2)")
elif prev=='...':
raise PreprocError("not implemented (2)")
else:
raise PreprocError("unexpected else")
return(name,[params,t[i+1:]])
else:
(p,v)=t[0]
return(v,[[],t[1:]])
re_include=re.compile('^\s*(<(?P<a>.*)>|"(?P<b>.*)")')
def extract_include(txt,defs):
m=re_include.search(txt)
if m:
if m.group('a'):return'<',m.group('a')
if m.group('b'):return'"',m.group('b')
toks=tokenize(txt)
reduce_tokens(toks,defs,['waf_include'])
if not toks:
raise PreprocError("could not parse include %s"%txt)
if len(toks)==1:
if toks[0][0]==STR:
return'"',toks[0][1]
else:
if toks[0][1]=='<'and toks[-1][1]=='>':
return stringize(toks).lstrip('<').rstrip('>')
raise PreprocError("could not parse include %s."%txt)
def parse_char(txt):
if not txt:raise PreprocError("attempted to parse a null char")
if txt[0]!='\\':
return ord(txt)
c=txt[1]
if c=='x':
if len(txt)==4 and txt[3]in string.hexdigits:return int(txt[2:],16)
return int(txt[2:],16)
elif c.isdigit():
if c=='0'and len(txt)==2:return 0
for i in 3,2,1:
if len(txt)>i and txt[1:1+i].isdigit():
return(1+i,int(txt[1:1+i],8))
else:
try:return chr_esc[c]
except KeyError:raise PreprocError("could not parse char literal '%s'"%txt)
def tokenize(s):
ret=[]
for match in re_clexer.finditer(s):
m=match.group
for name in tok_types:
v=m(name)
if v:
if name==IDENT:
try:v=g_optrans[v];name=OP
except KeyError:
if v.lower()=="true":
v=1
name=NUM
elif v.lower()=="false":
v=0
name=NUM
elif name==NUM:
if m('oct'):v=int(v,8)
elif m('hex'):v=int(m('hex'),16)
elif m('n0'):v=m('n0')
else:
v=m('char')
if v:v=parse_char(v)
else:v=m('n2')or m('n4')
elif name==OP:
if v=='%:':v='#'
elif v=='%:%:':v='##'
elif name==STR:
v=v[1:-1]
ret.append((name,v))
break
return ret
def define_name(line):
return re_mac.match(line).group(0)
class c_parser(object):
def __init__(self,nodepaths=None,defines=None):
self.lines=[]
if defines is None:
self.defs={}
else:
self.defs=dict(defines)
self.state=[]
self.count_files=0
self.currentnode_stack=[]
self.nodepaths=nodepaths or[]
self.nodes=[]
self.names=[]
self.curfile=''
self.ban_includes=set([])
def cached_find_resource(self,node,filename):
try:
nd=node.ctx.cache_nd
except:
nd=node.ctx.cache_nd={}
tup=(node,filename)
try:
return nd[tup]
except KeyError:
ret=node.find_resource(filename)
if ret:
if getattr(ret,'children',None):
ret=None
elif ret.is_child_of(node.ctx.bldnode):
tmp=node.ctx.srcnode.search(ret.path_from(node.ctx.bldnode))
if tmp and getattr(tmp,'children',None):
ret=None
nd[tup]=ret
return ret
def tryfind(self,filename):
self.curfile=filename
found=self.cached_find_resource(self.currentnode_stack[-1],filename)
for n in self.nodepaths:
if found:
break
found=self.cached_find_resource(n,filename)
if found:
self.nodes.append(found)
if filename[-4:]!='.moc':
self.addlines(found)
else:
if not filename in self.names:
self.names.append(filename)
return found
def addlines(self,node):
self.currentnode_stack.append(node.parent)
filepath=node.abspath()
self.count_files+=1
if self.count_files>recursion_limit:
raise PreprocError("recursion limit exceeded")
pc=self.parse_cache
debug('preproc: reading file %r',filepath)
try:
lns=pc[filepath]
except KeyError:
pass
else:
self.lines.extend(lns)
return
try:
lines=filter_comments(filepath)
lines.append((POPFILE,''))
lines.reverse()
pc[filepath]=lines
self.lines.extend(lines)
except IOError:
raise PreprocError("could not read the file %s"%filepath)
except Exception:
if Logs.verbose>0:
error("parsing %s failed"%filepath)
traceback.print_exc()
def start(self,node,env):
debug('preproc: scanning %s (in %s)',node.name,node.parent.name)
bld=node.ctx
try:
self.parse_cache=bld.parse_cache
except AttributeError:
bld.parse_cache={}
self.parse_cache=bld.parse_cache
self.addlines(node)
if env['DEFINES']:
try:
lst=['%s %s'%(x[0],trimquotes('='.join(x[1:])))for x in[y.split('=')for y in env['DEFINES']]]
lst.reverse()
self.lines.extend([('define',x)for x in lst])
except AttributeError:
pass
while self.lines:
(token,line)=self.lines.pop()
if token==POPFILE:
self.count_files-=1
self.currentnode_stack.pop()
continue
try:
ve=Logs.verbose
if ve:debug('preproc: line is %s - %s state is %s',token,line,self.state)
state=self.state
if token[:2]=='if':
state.append(undefined)
elif token=='endif':
state.pop()
if token[0]!='e':
if skipped in self.state or ignored in self.state:
continue
if token=='if':
ret=eval_macro(tokenize(line),self.defs)
if ret:state[-1]=accepted
else:state[-1]=ignored
elif token=='ifdef':
m=re_mac.match(line)
if m and m.group(0)in self.defs:state[-1]=accepted
else:state[-1]=ignored
elif token=='ifndef':
m=re_mac.match(line)
if m and m.group(0)in self.defs:state[-1]=ignored
else:state[-1]=accepted
elif token=='include'or token=='import':
(kind,inc)=extract_include(line,self.defs)
if inc in self.ban_includes:
continue
if token=='import':self.ban_includes.add(inc)
if ve:debug('preproc: include found %s (%s) ',inc,kind)
if kind=='"'or not strict_quotes:
self.tryfind(inc)
elif token=='elif':
if state[-1]==accepted:
state[-1]=skipped
elif state[-1]==ignored:
if eval_macro(tokenize(line),self.defs):
state[-1]=accepted
elif token=='else':
if state[-1]==accepted:state[-1]=skipped
elif state[-1]==ignored:state[-1]=accepted
elif token=='define':
try:
self.defs[define_name(line)]=line
except:
raise PreprocError("Invalid define line %s"%line)
elif token=='undef':
m=re_mac.match(line)
if m and m.group(0)in self.defs:
self.defs.__delitem__(m.group(0))
elif token=='pragma':
if re_pragma_once.match(line.lower()):
self.ban_includes.add(self.curfile)
except Exception ,e:
if Logs.verbose:
debug('preproc: line parsing failed (%s): %s %s',e,line,Utils.ex_stack())
def scan(task):
global go_absolute
try:
incn=task.generator.includes_nodes
except AttributeError:
raise Errors.WafError('%r is missing a feature such as "c", "cxx" or "includes": '%task.generator)
if go_absolute:
nodepaths=incn+standard_includes
else:
nodepaths=[x for x in incn if x.is_child_of(x.ctx.srcnode)or x.is_child_of(x.ctx.bldnode)]
tmp=c_parser(nodepaths)
tmp.start(task.inputs[0],task.env)
if Logs.verbose:
debug('deps: deps for %r: %r; unresolved %r'%(task.inputs,tmp.nodes,tmp.names))
return(tmp.nodes,tmp.names)
Utils.run_once(tokenize)
Utils.run_once(define_name)
|
gpl-3.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
2644,
26,
2774,
13,
24,
199,
3,
14750,
1,
4226,
440,
5283,
1,
1455,
921,
21500,
14,
31864,
14,
957,
15,
3187,
15,
4757,
15,
21500,
2706,
15,
4780,
14,
1360,
20930,
2873,
24522,
63,
1589,
63,
21500,
63,
493,
199,
199,
646,
984,
199,
692,
984,
14,
4097,
1023,
665,
378,
88,
996,
27130,
70,
16,
26,
687,
5951,
492,
2494,
465,
663,
199,
646,
295,
12,
1274,
12,
736,
12,
875,
12,
6894,
199,
504,
31380,
492,
3835,
458,
12,
3425,
12,
7535,
12,
9298,
199,
504,
31380,
14,
16333,
492,
3105,
12,
705,
199,
533,
5543,
4687,
547,
8,
9298,
14,
55,
2756,
547,
304,
199,
198,
1529,
199,
13531,
3817,
534,
15668,
199,
21314,
63,
3097,
29,
8251,
199,
1939,
63,
6116,
29,
797,
199,
6807,
63,
9441,
2968,
15,
2647,
15,
2613,
418,
199,
692,
17397,
14,
374,
63,
2676,
708,
26,
199,
198,
6807,
63,
9441,
9811,
199,
1180,
63,
599,
16670,
29,
16,
199,
4768,
63,
14005,
29,
16,
199,
71,
63,
411,
1515,
3713,
1397,
5242,
1,
1673,
460,
5242,
12574,
1673,
2075,
460,
5242,
6,
1673,
460,
63,
4077,
5242,
6,
29511,
269,
5242,
10644,
1673,
2075,
269,
5242,
92,
1673,
269,
63,
4077,
5242,
92,
29511,
15721,
356,
4289,
1673,
15721,
63,
4077,
356,
4289,
29511,
863,
76,
5242,
94,
297,
93,
199,
264,
63,
1278,
29,
264,
14,
2014,
9097,
59,
971,
84,
3672,
27496,
15287,
26,
2788,
971,
84,
3672,
8,
27737,
92,
27708,
92,
692,
92,
2836,
92,
4164,
92,
13739,
92,
2613,
92,
646,
92,
4640,
92,
25878,
92,
25852,
2788,
971,
84,
3672,
19276,
2862,
82,
32125,
264,
14,
15434,
92,
264,
14,
16661,
9,
199,
264,
63,
3088,
29,
264,
14,
2014,
18523,
59,
65,
13,
6353,
13,
58,
29588,
87,
10,
531,
199,
264,
63,
7036,
29,
264,
14,
2014,
9097,
59,
65,
13,
6353,
13,
58,
17900,
65,
13,
6353,
13,
58,
16,
13,
25,
15555,
7528,
10374,
199,
264,
63,
25852,
63,
5089,
29,
264,
14,
2014,
9097,
60,
83,
10,
5089,
60,
83,
7693,
264,
14,
15434,
9,
199,
264,
63,
7530,
29,
264,
14,
2014,
360,
8712,
60,
82,
7590,
78,
297,
264,
14,
16661,
9,
199,
264,
63,
5910,
29,
264,
14,
2014,
8,
82,
624,
8,
6307,
10,
4735,
10,
25739,
10,
11,
7059,
6331,
1527,
62,
10,
25739,
10,
11,
3342,
15,
8636,
501,
16045,
78,
3672,
92,
18353,
20942,
23629,
22996,
566,
12469,
5227,
8,
20942,
23629,
8124,
566,
10223,
18257,
4735,
15,
4507,
1103,
23849,
7208,
264,
14,
16661,
9,
199,
599,
71,
63,
318,
11699,
10674,
6828,
65,
12,
66,
9,
509,
282,
12,
66,
315,
3482,
480,
4022,
15,
11213,
342,
28,
7166,
82,
11525,
94,
60,
92,
62,
8607,
2440,
5440,
199,
10194,
63,
19303,
3713,
16,
356,
16,
2584,
65,
356,
23,
2584,
66,
356,
24,
2584,
84,
356,
25,
2584,
78,
356,
709,
2584,
70,
356,
845,
2584,
86,
356,
713,
2584,
82,
356,
969,
2584,
1103,
356,
2942,
12,
4507,
582,
1355,
93,
199,
7125,
534,
73,
7,
199,
1938,
534,
47,
7,
199,
7466,
534,
52,
7,
199,
3027,
534,
83,
7,
199,
5901,
534,
67,
7,
199,
9305,
63,
1313,
1524,
7125,
12,
3027,
12,
7466,
12,
1938,
61,
199,
1474,
63,
1313,
1524,
82,
624,
16,
59,
24110,
61,
2229,
48,
28,
4097,
9514,
65,
13,
13753,
13,
38,
16,
13,
25,
11896,
2229,
48,
28,
537,
17,
9514,
85,
18505,
44,
3672,
8636,
44,
15279,
10120,
48,
28,
1560,
13661,
20942,
23629,
1103,
1105,
29600,
92,
2229,
48,
28,
78,
17,
3072,
68,
11,
2788,
37,
69,
61,
2229,
48,
28,
1474,
16,
9514,
16341,
3672,
8995,
68,
8771,
2229,
48,
28,
1609,
16,
9514,
70,
7579,
44,
3672,
25963,
48,
28,
78,
18,
3072,
68,
7590,
3134,
68,
8771,
779,
37,
69,
61,
2229,
48,
28,
1474,
17,
9514,
16341,
3672,
8995,
68,
11,
22119,
2229,
48,
28,
1609,
17,
9514,
70,
7579,
44,
3672,
25963,
48,
28,
78,
20,
3072,
68,
23294,
68,
13278,
779,
37,
69,
61,
2229,
48,
28,
1474,
18,
9514,
16341,
3672,
8995,
68,
11,
22119,
2229,
48,
28,
1609,
18,
9514,
70,
7579,
44,
3672,
25963,
48,
28,
15560,
30,
16,
13278,
2229,
48,
28,
78,
16,
3072,
68,
8771,
2229,
48,
28,
537,
18,
9514,
85,
18505,
44,
23849,
7208,
82,
7,
44,
13472,
7059,
22996,
11752,
20942,
3342,
6949,
82,
3894,
65,
13,
6353,
13,
58,
29588,
87,
7693,
82,
5956,
2689,
26,
92,
8999,
26777,
1140,
29,
6113,
3134,
3134,
14,
92,
8999,
92,
21110,
92,
28,
26,
92,
12932,
92,
1140,
92,
8119,
6113,
7896,
11,
6113,
10365,
92,
306,
92,
5118,
28447,
29,
6113,
10,
26777,
15,
29,
15287,
26,
15287,
29,
15287,
21521,
389,
92,
12574,
92,
6,
29,
6113,
6113,
92,
6113,
92,
29,
6113,
62,
29,
25004,
21521,
1111,
92,
309,
92,
7023,
2961,
2862,
12911,
4988,
7023,
61,
28,
3072,
8995,
6113,
12773,
7590,
11,
6,
29,
26,
1,
3,
27,
8719,
6307,
2696,
8995,
94,
4537,
4300,
61,
199,
264,
63,
2265,
32200,
29,
264,
14,
2014,
20137,
1370,
904,
5234,
2229,
48,
21110,
83,
6598,
83,
2924,
2840,
354,
12,
2064,
9,
509,
536,
12,
2064,
315,
3482,
8,
9305,
63,
1313,
12,
1474,
63,
1313,
16636,
264,
14,
45,
9,
199,
16121,
534,
65,
7,
199,
11996,
534,
73,
7,
199,
10705,
534,
85,
7,
199,
11962,
534,
83,
7,
199,
318,
20265,
8,
77,
304,
199,
198,
83,
29,
77,
14,
923,
8,
17,
9,
199,
198,
692,
308,
26,
507,
198,
1107,
7,
283,
199,
198,
1107,
333,
14,
923,
8,
19,
9,
269,
891,
199,
318,
2457,
63,
6223,
8,
1501,
304,
199,
198,
600,
29,
7535,
14,
739,
70,
8,
1501,
9,
199,
198,
692,
675,
63,
599,
16670,
26,
507,
198,
509,
8,
65,
12,
66,
9,
262,
3229,
71,
63,
318,
26,
600,
29,
600,
14,
1294,
8,
65,
680,
904,
8,
66,
9,
199,
198,
600,
29,
264,
63,
7530,
14,
954,
8594,
600,
9,
199,
198,
600,
29,
264,
63,
5910
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
2644,
26,
2774,
13,
24,
199,
3,
14750,
1,
4226,
440,
5283,
1,
1455,
921,
21500,
14,
31864,
14,
957,
15,
3187,
15,
4757,
15,
21500,
2706,
15,
4780,
14,
1360,
20930,
2873,
24522,
63,
1589,
63,
21500,
63,
493,
199,
199,
646,
984,
199,
692,
984,
14,
4097,
1023,
665,
378,
88,
996,
27130,
70,
16,
26,
687,
5951,
492,
2494,
465,
663,
199,
646,
295,
12,
1274,
12,
736,
12,
875,
12,
6894,
199,
504,
31380,
492,
3835,
458,
12,
3425,
12,
7535,
12,
9298,
199,
504,
31380,
14,
16333,
492,
3105,
12,
705,
199,
533,
5543,
4687,
547,
8,
9298,
14,
55,
2756,
547,
304,
199,
198,
1529,
199,
13531,
3817,
534,
15668,
199,
21314,
63,
3097,
29,
8251,
199,
1939,
63,
6116,
29,
797,
199,
6807,
63,
9441,
2968,
15,
2647,
15,
2613,
418,
199,
692,
17397,
14,
374,
63,
2676,
708,
26,
199,
198,
6807,
63,
9441,
9811,
199,
1180,
63,
599,
16670,
29,
16,
199,
4768,
63,
14005,
29,
16,
199,
71,
63,
411,
1515,
3713,
1397,
5242,
1,
1673,
460,
5242,
12574,
1673,
2075,
460,
5242,
6,
1673,
460,
63,
4077,
5242,
6,
29511,
269,
5242,
10644,
1673,
2075,
269,
5242,
92,
1673,
269,
63,
4077,
5242,
92,
29511,
15721,
356,
4289,
1673,
15721,
63,
4077,
356,
4289,
29511,
863,
76,
5242,
94,
297,
93,
199,
264,
63,
1278,
29,
264,
14,
2014,
9097,
59,
971,
84,
3672,
27496,
15287,
26,
2788,
971,
84,
3672,
8,
27737,
92,
27708,
92,
692,
92,
2836,
92,
4164,
92,
13739,
92,
2613,
92,
646,
92,
4640,
92,
25878,
92,
25852,
2788,
971,
84,
3672,
19276,
2862,
82,
32125,
264,
14,
15434,
92,
264,
14,
16661,
9,
199,
264,
63,
3088,
29,
264,
14,
2014,
18523,
59,
65,
13,
6353,
13,
58,
29588,
87,
10,
531,
199,
264,
63,
7036,
29,
264,
14,
2014,
9097,
59,
65,
13,
6353,
13,
58,
17900,
65,
13,
6353,
13,
58,
16,
13,
25,
15555,
7528,
10374,
199,
264,
63,
25852,
63,
5089,
29,
264,
14,
2014,
9097,
60,
83,
10,
5089,
60,
83,
7693,
264,
14,
15434,
9,
199,
264,
63,
7530,
29,
264,
14,
2014,
360,
8712,
60,
82,
7590,
78,
297,
264,
14,
16661,
9,
199,
264,
63,
5910,
29,
264,
14,
2014,
8,
82,
624,
8,
6307,
10,
4735,
10,
25739,
10,
11,
7059,
6331,
1527,
62,
10,
25739,
10,
11,
3342,
15,
8636,
501,
16045,
78,
3672,
92,
18353,
20942,
23629,
22996,
566,
12469,
5227,
8,
20942,
23629,
8124,
566,
10223,
18257,
4735,
15,
4507,
1103,
23849,
7208,
264,
14,
16661,
9,
199,
599,
71,
63,
318,
11699,
10674,
6828,
65,
12,
66,
9,
509,
282,
12,
66,
315,
3482,
480,
4022,
15,
11213,
342,
28,
7166,
82,
11525,
94,
60,
92,
62,
8607,
2440,
5440,
199,
10194,
63,
19303,
3713,
16,
356,
16,
2584,
65,
356,
23,
2584,
66,
356,
24,
2584,
84,
356,
25,
2584,
78,
356,
709,
2584,
70,
356,
845,
2584,
86,
356,
713,
2584,
82,
356,
969,
2584,
1103,
356,
2942,
12,
4507,
582,
1355,
93,
199,
7125,
534,
73,
7,
199,
1938,
534,
47,
7,
199,
7466,
534,
52,
7,
199,
3027,
534,
83,
7,
199,
5901,
534,
67,
7,
199,
9305,
63,
1313,
1524,
7125,
12,
3027,
12,
7466,
12,
1938,
61,
199,
1474,
63,
1313,
1524,
82,
624,
16,
59,
24110,
61,
2229,
48,
28,
4097,
9514,
65,
13,
13753,
13,
38,
16,
13,
25,
11896,
2229,
48,
28,
537,
17,
9514,
85,
18505,
44,
3672,
8636,
44,
15279,
10120,
48,
28,
1560,
13661,
20942,
23629,
1103,
1105,
29600,
92,
2229,
48,
28,
78,
17,
3072,
68,
11,
2788,
37,
69,
61,
2229,
48,
28,
1474,
16,
9514,
16341,
3672,
8995,
68,
8771,
2229,
48,
28,
1609,
16,
9514,
70,
7579,
44,
3672,
25963,
48,
28,
78,
18,
3072,
68,
7590,
3134,
68,
8771,
779,
37,
69,
61,
2229,
48,
28,
1474,
17,
9514,
16341,
3672,
8995,
68,
11,
22119,
2229,
48,
28,
1609,
17,
9514,
70,
7579,
44,
3672,
25963,
48,
28,
78,
20,
3072,
68,
23294,
68,
13278,
779,
37,
69,
61,
2229,
48,
28,
1474,
18,
9514,
16341,
3672,
8995,
68,
11,
22119,
2229,
48,
28,
1609,
18,
9514,
70,
7579,
44,
3672,
25963,
48,
28,
15560,
30,
16,
13278,
2229,
48,
28,
78,
16,
3072,
68,
8771,
2229,
48,
28,
537,
18,
9514,
85,
18505,
44,
23849,
7208,
82,
7,
44,
13472,
7059,
22996,
11752,
20942,
3342,
6949,
82,
3894,
65,
13,
6353,
13,
58,
29588,
87,
7693,
82,
5956,
2689,
26,
92,
8999,
26777,
1140,
29,
6113,
3134,
3134,
14,
92,
8999,
92,
21110,
92,
28,
26,
92,
12932,
92,
1140,
92,
8119,
6113,
7896,
11,
6113,
10365,
92,
306,
92,
5118,
28447,
29,
6113,
10,
26777,
15,
29,
15287,
26,
15287,
29,
15287,
21521,
389,
92,
12574,
92,
6,
29,
6113,
6113,
92,
6113,
92,
29,
6113,
62,
29,
25004,
21521,
1111,
92,
309,
92,
7023,
2961,
2862,
12911,
4988,
7023,
61,
28,
3072,
8995,
6113,
12773,
7590,
11,
6,
29,
26,
1,
3,
27,
8719,
6307,
2696,
8995,
94,
4537,
4300,
61,
199,
264,
63,
2265,
32200,
29,
264,
14,
2014,
20137,
1370,
904,
5234,
2229,
48,
21110,
83,
6598,
83,
2924,
2840,
354,
12,
2064,
9,
509,
536,
12,
2064,
315,
3482,
8,
9305,
63,
1313,
12,
1474,
63,
1313,
16636,
264,
14,
45,
9,
199,
16121,
534,
65,
7,
199,
11996,
534,
73,
7,
199,
10705,
534,
85,
7,
199,
11962,
534,
83,
7,
199,
318,
20265,
8,
77,
304,
199,
198,
83,
29,
77,
14,
923,
8,
17,
9,
199,
198,
692,
308,
26,
507,
198,
1107,
7,
283,
199,
198,
1107,
333,
14,
923,
8,
19,
9,
269,
891,
199,
318,
2457,
63,
6223,
8,
1501,
304,
199,
198,
600,
29,
7535,
14,
739,
70,
8,
1501,
9,
199,
198,
692,
675,
63,
599,
16670,
26,
507,
198,
509,
8,
65,
12,
66,
9,
262,
3229,
71,
63,
318,
26,
600,
29,
600,
14,
1294,
8,
65,
680,
904,
8,
66,
9,
199,
198,
600,
29,
264,
63,
7530,
14,
954,
8594,
600,
9,
199,
198,
600,
29,
264,
63,
5910,
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,
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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
] |
linhdh/SnakeRepellerOnMbed50
|
mbed-os/tools/build_release.py
|
49
|
8381
|
#! /usr/bin/env python
"""
mbed SDK
Copyright (c) 2011-2013 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import sys
from time import time
from os.path import join, abspath, dirname, normpath
from optparse import OptionParser
import json
from shutil import copy
# Be sure that the tools directory is in the search path
ROOT = abspath(join(dirname(__file__), ".."))
sys.path.insert(0, ROOT)
from tools.build_api import build_mbed_libs
from tools.build_api import write_build_report
from tools.build_api import get_mbed_official_release
from tools.options import extract_profile
from tools.targets import TARGET_MAP, TARGET_NAMES
from tools.test_exporters import ReportExporter, ResultExporterType
from tools.test_api import SingleTestRunner
from tools.test_api import singletest_in_cli_mode
from tools.paths import TEST_DIR, MBED_LIBRARIES
from tools.tests import TEST_MAP
OFFICIAL_MBED_LIBRARY_BUILD = get_mbed_official_release('2')
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-o', '--official', dest="official_only", default=False, action="store_true",
help="Build using only the official toolchain for each target")
parser.add_option("-j", "--jobs", type="int", dest="jobs",
default=1, help="Number of concurrent jobs (default 1). Use 0 for auto based on host machine's number of CPUs")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
default=False, help="Verbose diagnostic output")
parser.add_option("-t", "--toolchains", dest="toolchains", help="Use toolchains names separated by comma")
parser.add_option("--profile", dest="profile", action="append", default=[])
parser.add_option("-p", "--platforms", dest="platforms", default="", help="Build only for the platform namesseparated by comma")
parser.add_option("-L", "--list-config", action="store_true", dest="list_config",
default=False, help="List the platforms and toolchains in the release in JSON")
parser.add_option("", "--report-build", dest="report_build_file_name", help="Output the build results to an junit xml file")
parser.add_option("", "--build-tests", dest="build_tests", help="Build all tests in the given directories (relative to /libraries/tests)")
options, args = parser.parse_args()
if options.list_config:
print json.dumps(OFFICIAL_MBED_LIBRARY_BUILD, indent=4)
sys.exit()
start = time()
build_report = {}
build_properties = {}
platforms = None
if options.platforms != "":
platforms = set(options.platforms.split(","))
if options.build_tests:
# Get all paths
directories = options.build_tests.split(',')
for i in range(len(directories)):
directories[i] = normpath(join(TEST_DIR, directories[i]))
test_names = []
for test_id in TEST_MAP.keys():
# Prevents tests with multiple source dirs from being checked
if isinstance( TEST_MAP[test_id].source_dir, basestring):
test_path = normpath(TEST_MAP[test_id].source_dir)
for directory in directories:
if directory in test_path:
test_names.append(test_id)
mut_counter = 1
mut = {}
test_spec = {
"targets": {}
}
if options.toolchains:
print "Only building using the following toolchains: %s" % (options.toolchains)
for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD:
toolchains = None
if platforms is not None and not target_name in platforms:
print("Excluding %s from release" % target_name)
continue
if target_name not in TARGET_NAMES:
print "Target '%s' is not a valid target. Excluding from release"
continue
if options.official_only:
toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),)
else:
toolchains = toolchain_list
if options.toolchains:
toolchainSet = set(toolchains)
toolchains = toolchainSet.intersection(set((options.toolchains).split(',')))
mut[str(mut_counter)] = {
"mcu": target_name
}
mut_counter += 1
test_spec["targets"][target_name] = toolchains
single_test = SingleTestRunner(_muts=mut,
_parser=parser,
_opts=options,
_opts_report_build_file_name=options.report_build_file_name,
_test_spec=test_spec,
_opts_test_by_names=",".join(test_names),
_opts_verbose=options.verbose,
_opts_only_build_tests=True,
_opts_suppress_summary=True,
_opts_jobs=options.jobs,
_opts_include_non_automated=True,
_opts_build_report=build_report,
_opts_build_properties=build_properties)
# Runs test suite in CLI mode
test_summary, shuffle_seed, test_summary_ext, test_suite_properties_ext, new_build_report, new_build_properties = single_test.execute()
else:
for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD:
if platforms is not None and not target_name in platforms:
print("Excluding %s from release" % target_name)
continue
if target_name not in TARGET_NAMES:
print "Target '%s' is not a valid target. Excluding from release"
continue
if options.official_only:
toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),)
else:
toolchains = toolchain_list
if options.toolchains:
print "Only building using the following toolchains: %s" % (options.toolchains)
toolchainSet = set(toolchains)
toolchains = toolchainSet.intersection(set((options.toolchains).split(',')))
for toolchain in toolchains:
id = "%s::%s" % (target_name, toolchain)
profile = extract_profile(parser, options, toolchain)
try:
built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name],
toolchain,
verbose=options.verbose,
jobs=options.jobs,
report=build_report,
properties=build_properties,
build_profile=profile)
except Exception, e:
print str(e)
# copy targets.json file as part of the release
copy(join(dirname(abspath(__file__)), '..', 'targets', 'targets.json'), MBED_LIBRARIES)
# Write summary of the builds
if options.report_build_file_name:
file_report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build")
file_report_exporter.report_to_file(build_report, options.report_build_file_name, test_suite_properties=build_properties)
print "\n\nCompleted in: (%.2f)s" % (time() - start)
print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
status = print_report_exporter.report(build_report)
if not status:
sys.exit(1)
|
gpl-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
624,
199,
3665,
15610,
199,
7384,
334,
67,
9,
7760,
13,
6965,
27155,
23954,
199,
199,
31661,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
13297,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
5556,
1443,
3332,
282,
1331,
402,
314,
844,
737,
339,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
624,
199,
646,
984,
199,
504,
900,
492,
900,
199,
504,
747,
14,
515,
492,
4263,
12,
19529,
12,
9017,
12,
25962,
199,
504,
8691,
492,
13491,
199,
646,
2022,
199,
504,
5145,
492,
1331,
199,
199,
3,
6423,
3238,
626,
314,
7249,
2082,
365,
315,
314,
2754,
931,
199,
5441,
275,
19529,
8,
904,
8,
3475,
3460,
493,
10139,
21777,
2237,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
16547,
9,
199,
199,
504,
7249,
14,
1506,
63,
1246,
492,
1900,
63,
3665,
63,
8450,
199,
504,
7249,
14,
1506,
63,
1246,
492,
2218,
63,
1506,
63,
3070,
199,
504,
7249,
14,
1506,
63,
1246,
492,
664,
63,
3665,
63,
29260,
63,
3221,
199,
504,
7249,
14,
1419,
492,
5536,
63,
2913,
199,
504,
7249,
14,
4684,
492,
26134,
63,
5443,
12,
26134,
63,
14546,
199,
504,
7249,
14,
396,
63,
1474,
27568,
492,
11774,
30341,
12,
10695,
30341,
804,
199,
504,
7249,
14,
396,
63,
1246,
492,
13050,
13649,
199,
504,
7249,
14,
396,
63,
1246,
492,
2849,
396,
63,
262,
63,
2764,
63,
632,
199,
504,
7249,
14,
3771,
492,
7393,
63,
3022,
12,
19487,
1149,
63,
32723,
199,
504,
7249,
14,
2219,
492,
7393,
63,
5443,
199,
199,
28487,
4938,
63,
4567,
1149,
63,
16983,
63,
8248,
275,
664,
63,
3665,
63,
29260,
63,
3221,
360,
18,
358,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1798,
275,
13491,
342,
272,
1798,
14,
525,
63,
1422,
3654,
79,
297,
2850,
29260,
297,
2053,
628,
29260,
63,
2118,
401,
849,
29,
797,
12,
1595,
628,
1617,
63,
2052,
401,
1993,
1720,
628,
3425,
1808,
1454,
314,
25410,
22689,
367,
1924,
1347,
531,
272,
1798,
14,
525,
63,
1422,
6096,
74,
401,
4320,
6920,
401,
730,
628,
442,
401,
2053,
628,
6920,
401,
1993,
849,
29,
17,
12,
1720,
628,
3259,
402,
23002,
9643,
334,
885,
413,
680,
3645,
378,
367,
2599,
4079,
641,
1591,
6844,
1159,
1329,
402,
28504,
531,
272,
1798,
14,
525,
63,
1422,
6096,
86,
401,
4320,
3832,
401,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
3832,
401,
1993,
849,
29,
797,
12,
1720,
628,
21879,
8348,
19075,
1072,
531,
272,
1798,
14,
525,
63,
1422,
6096,
84,
401,
4320,
3557,
17419,
401,
2053,
628,
3557,
17419,
401,
1720,
628,
6119,
4744,
17419,
1561,
11673,
701,
10029,
531,
339,
1798,
14,
525,
63,
1422,
6739,
2913,
401,
2053,
628,
2913,
401,
1595,
628,
740,
401,
849,
14285,
339,
1798,
14,
525,
63,
1422,
6096,
80,
401,
4320,
19601,
401,
2053,
628,
19601,
401,
849,
8772,
1720,
628,
3425,
1454,
367,
314,
4298,
1561,
12794,
701,
10029,
531,
339,
1798,
14,
525,
63,
1422,
6096,
44,
401,
4320,
513,
13,
888,
401,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
513,
63,
888,
401,
1993,
849,
29,
797,
12,
1720,
628,
1296,
314,
10677,
436,
4744,
17419,
315,
314,
4683,
315,
4840,
531,
339,
1798,
14,
525,
63,
1422,
12398,
4320,
3070,
13,
1506,
401,
2053,
628,
3070,
63,
1506,
63,
493,
63,
354,
401,
1720,
628,
2959,
314,
1900,
2058,
370,
376,
1335,
3248,
2748,
570,
531,
339,
1798,
14,
525,
63,
1422,
12398,
4320,
1506,
13,
2219,
401,
2053,
628,
1506,
63,
2219,
401,
1720,
628,
3425,
1006,
2295,
315,
314,
1627,
6602,
334,
6188,
370,
1182,
10159,
15,
2219,
6320,
2378,
1511,
12,
1249,
275,
1798,
14,
1122,
63,
589,
342,
16478,
340,
1511,
14,
513,
63,
888,
26,
267,
870,
2022,
14,
4180,
8,
28487,
4938,
63,
4567,
1149,
63,
16983,
63,
8248,
12,
4363,
29,
20,
9,
267,
984,
14,
2224,
342,
339,
1343,
275,
900,
342,
272,
1900,
63,
3070,
275,
1052,
272,
1900,
63,
3282,
275,
1052,
339,
10677,
275,
488,
272,
340,
1511,
14,
19601,
1137,
10812,
267,
10677,
275,
663,
8,
1419,
14,
19601,
14,
1294,
11854,
2237,
339,
340,
1511,
14,
1506,
63,
2219,
26,
267,
327,
2372,
1006,
3792,
267,
6602,
275,
1511,
14,
1506,
63,
2219,
14,
1294,
11917,
267,
367,
284,
315,
1425,
8,
552,
8,
12629,
2298,
288,
6602,
59,
73,
61,
275,
25962,
8,
904,
8,
2864,
63,
3022,
12,
6602,
59,
73,
2459,
398,
511,
63,
1247,
275,
942,
398,
367,
511,
63,
344,
315,
7393,
63,
5443,
14,
1612,
837,
288,
327,
29861,
83,
2295,
543,
3663,
1350,
7606,
687,
3769,
7923,
288,
340,
1228,
8,
7393,
63,
5443,
59,
396,
63,
344,
1055,
1365,
63,
694,
12,
7116,
304,
355,
511,
63,
515,
275,
25962,
8,
2864,
63,
5443,
59,
396,
63,
344,
1055,
1365,
63,
694,
9,
355,
367,
2082,
315,
6602,
26,
490,
340,
2082,
315,
511,
63,
515,
26,
717,
511,
63,
1247,
14,
740,
8,
396,
63,
344,
9,
398,
8567,
63,
5337,
275,
413,
267,
8567,
275,
1052,
267,
511,
63,
1650,
275,
469,
288,
298,
4684,
582,
1052,
267,
789,
398,
340,
1511,
14,
3557,
17419,
26,
288,
870,
298,
5903,
10015,
1808,
314,
2569,
4744,
17419,
26,
450,
83,
2,
450,
334,
1419,
14,
3557,
17419,
9,
398,
367,
1347,
63,
354,
12,
22689,
63,
513,
315,
1634,
23380,
4938,
63,
4567,
1149,
63,
16983,
63,
8248,
26,
288,
4744,
17419,
275,
488,
288,
340,
10677,
365,
440,
488,
436,
440,
1347,
63,
354,
315,
10677,
26,
355,
870,
480,
920,
4923,
450,
83,
687,
4683,
2
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
624,
199,
3665,
15610,
199,
7384,
334,
67,
9,
7760,
13,
6965,
27155,
23954,
199,
199,
31661,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
13297,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
5556,
1443,
3332,
282,
1331,
402,
314,
844,
737,
339,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
199,
5524,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
16832,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
29946,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
9295,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3097,
1298,
1334,
314,
844,
14,
199,
624,
199,
646,
984,
199,
504,
900,
492,
900,
199,
504,
747,
14,
515,
492,
4263,
12,
19529,
12,
9017,
12,
25962,
199,
504,
8691,
492,
13491,
199,
646,
2022,
199,
504,
5145,
492,
1331,
199,
199,
3,
6423,
3238,
626,
314,
7249,
2082,
365,
315,
314,
2754,
931,
199,
5441,
275,
19529,
8,
904,
8,
3475,
3460,
493,
10139,
21777,
2237,
199,
1274,
14,
515,
14,
3176,
8,
16,
12,
16547,
9,
199,
199,
504,
7249,
14,
1506,
63,
1246,
492,
1900,
63,
3665,
63,
8450,
199,
504,
7249,
14,
1506,
63,
1246,
492,
2218,
63,
1506,
63,
3070,
199,
504,
7249,
14,
1506,
63,
1246,
492,
664,
63,
3665,
63,
29260,
63,
3221,
199,
504,
7249,
14,
1419,
492,
5536,
63,
2913,
199,
504,
7249,
14,
4684,
492,
26134,
63,
5443,
12,
26134,
63,
14546,
199,
504,
7249,
14,
396,
63,
1474,
27568,
492,
11774,
30341,
12,
10695,
30341,
804,
199,
504,
7249,
14,
396,
63,
1246,
492,
13050,
13649,
199,
504,
7249,
14,
396,
63,
1246,
492,
2849,
396,
63,
262,
63,
2764,
63,
632,
199,
504,
7249,
14,
3771,
492,
7393,
63,
3022,
12,
19487,
1149,
63,
32723,
199,
504,
7249,
14,
2219,
492,
7393,
63,
5443,
199,
199,
28487,
4938,
63,
4567,
1149,
63,
16983,
63,
8248,
275,
664,
63,
3665,
63,
29260,
63,
3221,
360,
18,
358,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
1798,
275,
13491,
342,
272,
1798,
14,
525,
63,
1422,
3654,
79,
297,
2850,
29260,
297,
2053,
628,
29260,
63,
2118,
401,
849,
29,
797,
12,
1595,
628,
1617,
63,
2052,
401,
1993,
1720,
628,
3425,
1808,
1454,
314,
25410,
22689,
367,
1924,
1347,
531,
272,
1798,
14,
525,
63,
1422,
6096,
74,
401,
4320,
6920,
401,
730,
628,
442,
401,
2053,
628,
6920,
401,
1993,
849,
29,
17,
12,
1720,
628,
3259,
402,
23002,
9643,
334,
885,
413,
680,
3645,
378,
367,
2599,
4079,
641,
1591,
6844,
1159,
1329,
402,
28504,
531,
272,
1798,
14,
525,
63,
1422,
6096,
86,
401,
4320,
3832,
401,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
3832,
401,
1993,
849,
29,
797,
12,
1720,
628,
21879,
8348,
19075,
1072,
531,
272,
1798,
14,
525,
63,
1422,
6096,
84,
401,
4320,
3557,
17419,
401,
2053,
628,
3557,
17419,
401,
1720,
628,
6119,
4744,
17419,
1561,
11673,
701,
10029,
531,
339,
1798,
14,
525,
63,
1422,
6739,
2913,
401,
2053,
628,
2913,
401,
1595,
628,
740,
401,
849,
14285,
339,
1798,
14,
525,
63,
1422,
6096,
80,
401,
4320,
19601,
401,
2053,
628,
19601,
401,
849,
8772,
1720,
628,
3425,
1454,
367,
314,
4298,
1561,
12794,
701,
10029,
531,
339,
1798,
14,
525,
63,
1422,
6096,
44,
401,
4320,
513,
13,
888,
401,
1595,
628,
1617,
63,
2052,
401,
2053,
628,
513,
63,
888,
401,
1993,
849,
29,
797,
12,
1720,
628,
1296,
314,
10677,
436,
4744,
17419,
315,
314,
4683,
315,
4840,
531,
339,
1798,
14,
525,
63,
1422,
12398,
4320,
3070,
13,
1506,
401,
2053,
628,
3070,
63,
1506,
63,
493,
63,
354,
401,
1720,
628,
2959,
314,
1900,
2058,
370,
376,
1335,
3248,
2748,
570,
531,
339,
1798,
14,
525,
63,
1422,
12398,
4320,
1506,
13,
2219,
401,
2053,
628,
1506,
63,
2219,
401,
1720,
628,
3425,
1006,
2295,
315,
314,
1627,
6602,
334,
6188,
370,
1182,
10159,
15,
2219,
6320,
2378,
1511,
12,
1249,
275,
1798,
14,
1122,
63,
589,
342,
16478,
340,
1511,
14,
513,
63,
888,
26,
267,
870,
2022,
14,
4180,
8,
28487,
4938,
63,
4567,
1149,
63,
16983,
63,
8248,
12,
4363,
29,
20,
9,
267,
984,
14,
2224,
342,
339,
1343,
275,
900,
342,
272,
1900,
63,
3070,
275,
1052,
272,
1900,
63,
3282,
275,
1052,
339,
10677,
275,
488,
272,
340,
1511,
14,
19601,
1137,
10812,
267,
10677,
275,
663,
8,
1419,
14,
19601,
14,
1294,
11854,
2237,
339,
340,
1511,
14,
1506,
63,
2219,
26,
267,
327,
2372,
1006,
3792,
267,
6602,
275,
1511,
14,
1506,
63,
2219,
14,
1294,
11917,
267,
367,
284,
315,
1425,
8,
552,
8,
12629,
2298,
288,
6602,
59,
73,
61,
275,
25962,
8,
904,
8,
2864,
63,
3022,
12,
6602,
59,
73,
2459,
398,
511,
63,
1247,
275,
942,
398,
367,
511,
63,
344,
315,
7393,
63,
5443,
14,
1612,
837,
288,
327,
29861,
83,
2295,
543,
3663,
1350,
7606,
687,
3769,
7923,
288,
340,
1228,
8,
7393,
63,
5443,
59,
396,
63,
344,
1055,
1365,
63,
694,
12,
7116,
304,
355,
511,
63,
515,
275,
25962,
8,
2864,
63,
5443,
59,
396,
63,
344,
1055,
1365,
63,
694,
9,
355,
367,
2082,
315,
6602,
26,
490,
340,
2082,
315,
511,
63,
515,
26,
717,
511,
63,
1247,
14,
740,
8,
396,
63,
344,
9,
398,
8567,
63,
5337,
275,
413,
267,
8567,
275,
1052,
267,
511,
63,
1650,
275,
469,
288,
298,
4684,
582,
1052,
267,
789,
398,
340,
1511,
14,
3557,
17419,
26,
288,
870,
298,
5903,
10015,
1808,
314,
2569,
4744,
17419,
26,
450,
83,
2,
450,
334,
1419,
14,
3557,
17419,
9,
398,
367,
1347,
63,
354,
12,
22689,
63,
513,
315,
1634,
23380,
4938,
63,
4567,
1149,
63,
16983,
63,
8248,
26,
288,
4744,
17419,
275,
488,
288,
340,
10677,
365,
440,
488,
436,
440,
1347,
63,
354,
315,
10677,
26,
355,
870,
480,
920,
4923,
450,
83,
687,
4683,
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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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.
"""Escaping/unescaping methods for HTML, JSON, URLs, and others.
Also includes a few other miscellaneous string manipulation functions that
have crept in over time.
"""
from __future__ import absolute_import, division, print_function, with_statement
import re
import sys
from tornado.util import unicode_type, basestring_type, u
try:
from urllib.parse import parse_qs as _parse_qs # py3
except ImportError:
from urlparse import parse_qs as _parse_qs # Python 2.6+
try:
import htmlentitydefs # py2
except ImportError:
import html.entities as htmlentitydefs # py3
try:
import urllib.parse as urllib_parse # py3
except ImportError:
import urllib as urllib_parse # py2
import json
try:
unichr
except NameError:
unichr = chr
_XHTML_ESCAPE_RE = re.compile('[&<>"\']')
_XHTML_ESCAPE_DICT = {'&': '&', '<': '<', '>': '>', '"': '"',
'\'': '''}
def xhtml_escape(value):
"""Escapes a string so it is valid within HTML or XML.
Escapes the characters ``<``, ``>``, ``"``, ``'``, and ``&``.
When used in attribute values the escaped strings must be enclosed
in quotes.
.. versionchanged:: 3.2
Added the single quote to the list of escaped characters.
"""
return _XHTML_ESCAPE_RE.sub(lambda match: _XHTML_ESCAPE_DICT[match.group(0)],
to_basestring(value))
def xhtml_unescape(value):
"""Un-escapes an XML-escaped string."""
return re.sub(r"&(#?)(\w+?);", _convert_entity, _unicode(value))
# The fact that json_encode wraps json.dumps is an implementation detail.
# Please see https://github.com/tornadoweb/tornado/pull/706
# before sending a pull request that adds **kwargs to this function.
def json_encode(value):
"""JSON-encodes the given Python object."""
# JSON permits but does not require forward slashes to be escaped.
# This is useful when json data is emitted in a <script> tag
# in HTML, as it prevents </script> tags from prematurely terminating
# the javascript. Some json libraries do this escaping by default,
# although python's standard library does not, so we do it here.
# http://stackoverflow.com/questions/1580647/json-why-are-forward-slashes-escaped
return json.dumps(value).replace("</", "<\\/")
def json_decode(value):
"""Returns Python objects for the given JSON string."""
return json.loads(to_basestring(value))
def squeeze(value):
"""Replace all sequences of whitespace chars with a single space."""
return re.sub(r"[\x00-\x20]+", " ", value).strip()
def url_escape(value, plus=True):
"""Returns a URL-encoded version of the given value.
If ``plus`` is true (the default), spaces will be represented
as "+" instead of "%20". This is appropriate for query strings
but not for the path component of a URL. Note that this default
is the reverse of Python's urllib module.
.. versionadded:: 3.1
The ``plus`` argument
"""
quote = urllib_parse.quote_plus if plus else urllib_parse.quote
return quote(utf8(value))
# python 3 changed things around enough that we need two separate
# implementations of url_unescape. We also need our own implementation
# of parse_qs since python 3's version insists on decoding everything.
if sys.version_info[0] < 3:
def url_unescape(value, encoding='utf-8', plus=True):
"""Decodes the given value from a URL.
The argument may be either a byte or unicode string.
If encoding is None, the result will be a byte string. Otherwise,
the result is a unicode string in the specified encoding.
If ``plus`` is true (the default), plus signs will be interpreted
as spaces (literal plus signs must be represented as "%2B"). This
is appropriate for query strings and form-encoded values but not
for the path component of a URL. Note that this default is the
reverse of Python's urllib module.
.. versionadded:: 3.1
The ``plus`` argument
"""
unquote = (urllib_parse.unquote_plus if plus else urllib_parse.unquote)
if encoding is None:
return unquote(utf8(value))
else:
return unicode_type(unquote(utf8(value)), encoding)
parse_qs_bytes = _parse_qs
else:
def url_unescape(value, encoding='utf-8', plus=True):
"""Decodes the given value from a URL.
The argument may be either a byte or unicode string.
If encoding is None, the result will be a byte string. Otherwise,
the result is a unicode string in the specified encoding.
If ``plus`` is true (the default), plus signs will be interpreted
as spaces (literal plus signs must be represented as "%2B"). This
is appropriate for query strings and form-encoded values but not
for the path component of a URL. Note that this default is the
reverse of Python's urllib module.
.. versionadded:: 3.1
The ``plus`` argument
"""
if encoding is None:
if plus:
# unquote_to_bytes doesn't have a _plus variant
value = to_basestring(value).replace('+', ' ')
return urllib_parse.unquote_to_bytes(value)
else:
unquote = (urllib_parse.unquote_plus if plus
else urllib_parse.unquote)
return unquote(to_basestring(value), encoding=encoding)
def parse_qs_bytes(qs, keep_blank_values=False, strict_parsing=False):
"""Parses a query string like urlparse.parse_qs, but returns the
values as byte strings.
Keys still become type str (interpreted as latin1 in python3!)
because it's too painful to keep them as byte strings in
python3 and in practice they're nearly always ascii anyway.
"""
# This is gross, but python3 doesn't give us another way.
# Latin1 is the universal donor of character encodings.
result = _parse_qs(qs, keep_blank_values, strict_parsing,
encoding='latin1', errors='strict')
encoded = {}
for k, v in result.items():
encoded[k] = [i.encode('latin1') for i in v]
return encoded
_UTF8_TYPES = (bytes, type(None))
def utf8(value):
"""Converts a string argument to a byte string.
If the argument is already a byte string or None, it is returned unchanged.
Otherwise it must be a unicode string and is encoded as utf8.
"""
if isinstance(value, _UTF8_TYPES):
return value
if not isinstance(value, unicode_type):
raise TypeError(
"Expected bytes, unicode, or None; got %r" % type(value)
)
return value.encode("utf-8")
_TO_UNICODE_TYPES = (unicode_type, type(None))
def to_unicode(value):
"""Converts a string argument to a unicode string.
If the argument is already a unicode string or None, it is returned
unchanged. Otherwise it must be a byte string and is decoded as utf8.
"""
if isinstance(value, _TO_UNICODE_TYPES):
return value
if not isinstance(value, bytes):
raise TypeError(
"Expected bytes, unicode, or None; got %r" % type(value)
)
return value.decode("utf-8")
# to_unicode was previously named _unicode not because it was private,
# but to avoid conflicts with the built-in unicode() function/type
_unicode = to_unicode
# When dealing with the standard library across python 2 and 3 it is
# sometimes useful to have a direct conversion to the native string type
if str is unicode_type:
native_str = to_unicode
else:
native_str = utf8
_BASESTRING_TYPES = (basestring_type, type(None))
def to_basestring(value):
"""Converts a string argument to a subclass of basestring.
In python2, byte and unicode strings are mostly interchangeable,
so functions that deal with a user-supplied argument in combination
with ascii string constants can use either and should return the type
the user supplied. In python3, the two types are not interchangeable,
so this method is needed to convert byte strings to unicode.
"""
if isinstance(value, _BASESTRING_TYPES):
return value
if not isinstance(value, bytes):
raise TypeError(
"Expected bytes, unicode, or None; got %r" % type(value)
)
return value.decode("utf-8")
def recursive_unicode(obj):
"""Walks a simple data structure, converting byte strings to unicode.
Supports lists, tuples, and dictionaries.
"""
if isinstance(obj, dict):
return dict((recursive_unicode(k), recursive_unicode(v)) for (k, v) in obj.items())
elif isinstance(obj, list):
return list(recursive_unicode(i) for i in obj)
elif isinstance(obj, tuple):
return tuple(recursive_unicode(i) for i in obj)
elif isinstance(obj, bytes):
return to_unicode(obj)
else:
return obj
# I originally used the regex from
# http://daringfireball.net/2010/07/improved_regex_for_matching_urls
# but it gets all exponential on certain patterns (such as too many trailing
# dots), causing the regex matcher to never return.
# This regex should avoid those problems.
# Use to_unicode instead of tornado.util.u - we don't want backslashes getting
# processed as escapes.
_URL_RE = re.compile(to_unicode(r"""\b((?:([\w-]+):(/{1,3})|www[.])(?:(?:(?:[^\s&()]|&|")*(?:[^!"#$%&'()*+,.:;<=>?@\[\]^`{|}~\s]))|(?:\((?:[^\s&()]|&|")*\)))+)"""))
def linkify(text, shorten=False, extra_params="",
require_protocol=False, permitted_protocols=["http", "https"]):
"""Converts plain text into HTML with links.
For example: ``linkify("Hello http://tornadoweb.org!")`` would return
``Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!``
Parameters:
* ``shorten``: Long urls will be shortened for display.
* ``extra_params``: Extra text to include in the link tag, or a callable
taking the link as an argument and returning the extra text
e.g. ``linkify(text, extra_params='rel="nofollow" class="external"')``,
or::
def extra_params_cb(url):
if url.startswith("http://example.com"):
return 'class="internal"'
else:
return 'class="external" rel="nofollow"'
linkify(text, extra_params=extra_params_cb)
* ``require_protocol``: Only linkify urls which include a protocol. If
this is False, urls such as www.facebook.com will also be linkified.
* ``permitted_protocols``: List (or set) of protocols which should be
linkified, e.g. ``linkify(text, permitted_protocols=["http", "ftp",
"mailto"])``. It is very unsafe to include protocols such as
``javascript``.
"""
if extra_params and not callable(extra_params):
extra_params = " " + extra_params.strip()
def make_link(m):
url = m.group(1)
proto = m.group(2)
if require_protocol and not proto:
return url # not protocol, no linkify
if proto and proto not in permitted_protocols:
return url # bad protocol, no linkify
href = m.group(1)
if not proto:
href = "http://" + href # no proto specified, use http
if callable(extra_params):
params = " " + extra_params(href).strip()
else:
params = extra_params
# clip long urls. max_len is just an approximation
max_len = 30
if shorten and len(url) > max_len:
before_clip = url
if proto:
proto_len = len(proto) + 1 + len(m.group(3) or "") # +1 for :
else:
proto_len = 0
parts = url[proto_len:].split("/")
if len(parts) > 1:
# Grab the whole host part plus the first bit of the path
# The path is usually not that interesting once shortened
# (no more slug, etc), so it really just provides a little
# extra indication of shortening.
url = url[:proto_len] + parts[0] + "/" + \
parts[1][:8].split('?')[0].split('.')[0]
if len(url) > max_len * 1.5: # still too long
url = url[:max_len]
if url != before_clip:
amp = url.rfind('&')
# avoid splitting html char entities
if amp > max_len - 5:
url = url[:amp]
url += "..."
if len(url) >= len(before_clip):
url = before_clip
else:
# full url is visible on mouse-over (for those who don't
# have a status bar, such as Safari by default)
params += ' title="%s"' % href
return u('<a href="%s"%s>%s</a>') % (href, params, url)
# First HTML-escape so that our strings are all safe.
# The regex is modified to avoid character entites other than & so
# that we won't pick up ", etc.
text = _unicode(xhtml_escape(text))
return _URL_RE.sub(make_link, text)
def _convert_entity(m):
if m.group(1) == "#":
try:
if m.group(2)[:1].lower() == 'x':
return unichr(int(m.group(2)[1:], 16))
else:
return unichr(int(m.group(2)))
except ValueError:
return "&#%s;" % m.group(2)
try:
return _HTML_UNICODE_MAP[m.group(2)]
except KeyError:
return "&%s;" % m.group(2)
def _build_unicode_map():
unicode_map = {}
for name, value in htmlentitydefs.name2codepoint.items():
unicode_map[name] = unichr(value)
return unicode_map
_HTML_UNICODE_MAP = _build_unicode_map()
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
27107,
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,
624,
37,
551,
17818,
15,
324,
26306,
3102,
367,
4163,
12,
4840,
12,
10867,
12,
436,
11789,
14,
199,
199,
31892,
6952,
282,
9284,
1163,
3201,
19549,
1059,
26212,
3423,
626,
199,
7804,
2837,
541,
315,
1806,
900,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
543,
63,
6242,
199,
199,
646,
295,
199,
646,
984,
199,
199,
504,
12148,
14,
1974,
492,
2649,
63,
466,
12,
7116,
63,
466,
12,
399,
199,
199,
893,
26,
272,
687,
4011,
14,
1122,
492,
2198,
63,
6177,
465,
485,
1122,
63,
6177,
221,
327,
1134,
19,
199,
2590,
3545,
26,
272,
687,
7097,
492,
2198,
63,
6177,
465,
485,
1122,
63,
6177,
221,
327,
2018,
499,
14,
22,
11,
199,
199,
893,
26,
272,
492,
30010,
552,
1701,
8710,
221,
327,
1134,
18,
199,
2590,
3545,
26,
272,
492,
3517,
14,
8327,
465,
30010,
552,
1701,
8710,
221,
327,
1134,
19,
199,
199,
893,
26,
272,
492,
4011,
14,
1122,
465,
4011,
63,
1122,
221,
327,
1134,
19,
199,
2590,
3545,
26,
272,
492,
4011,
465,
4011,
63,
1122,
221,
327,
1134,
18,
199,
199,
646,
2022,
199,
199,
893,
26,
272,
17742,
199,
2590,
12746,
26,
272,
17742,
275,
8678,
199,
199,
63,
56,
4943,
63,
28879,
63,
907,
275,
295,
14,
2014,
11894,
6,
16137,
3212,
418,
358,
199,
63,
56,
4943,
63,
28879,
63,
12511,
275,
791,
6,
356,
7673,
5282,
10805,
2650,
356,
7673,
4116,
10805,
12696,
356,
7673,
3308,
10805,
24536,
7673,
5184,
10805,
1993,
32496,
356,
7673,
3,
1355,
27,
936,
421,
199,
318,
671,
1360,
63,
3765,
8,
585,
304,
272,
408,
10260,
83,
282,
1059,
880,
652,
365,
1686,
4453,
4163,
503,
4692,
14,
339,
21067,
83,
314,
4110,
23696,
4542,
1124,
30,
4542,
25916,
4542,
12692,
4542,
436,
1124,
6,
4345,
272,
3979,
1202,
315,
2225,
1338,
314,
11077,
3326,
1471,
506,
27828,
272,
315,
9344,
14,
339,
2508,
16434,
447,
650,
14,
18,
10817,
16230,
314,
2849,
6313,
370,
314,
769,
402,
11077,
4110,
14,
272,
408,
272,
372,
485,
56,
4943,
63,
28879,
63,
907,
14,
954,
8,
2734,
1336,
26,
485,
56,
4943,
63,
28879,
63,
12511,
59,
1431,
14,
923,
8,
16,
4360,
1816,
370,
63,
17628,
8,
585,
430,
421,
199,
318,
671,
1360,
63,
22726,
8,
585,
304,
272,
408,
1358,
13,
3765,
83,
376,
4692,
13,
13572,
1059,
1041,
272,
372,
295,
14,
954,
8,
82,
2,
6,
27496,
31,
10127,
87,
23778,
2736,
401,
485,
3916,
63,
4502,
12,
485,
2975,
8,
585,
430,
421,
199,
3,
710,
10572,
626,
2022,
63,
2143,
14018,
2022,
14,
4180,
365,
376,
4514,
10093,
14,
199,
3,
7754,
1937,
4178,
921,
5031,
14,
957,
15,
84,
6161,
8369,
2871,
15,
18443,
15,
9302,
15,
16960,
199,
3,
2544,
10209,
282,
10299,
1056,
626,
9584,
1011,
958,
370,
642,
805,
14,
199,
318,
2022,
63,
2143,
8,
585,
304,
272,
408,
6243,
13,
2143,
83,
314,
1627,
2018,
909,
1041,
272,
327,
4840,
11291,
83,
1325,
1630,
440,
4409,
7568,
20275,
370,
506,
11077,
14,
272,
327,
961,
365,
2997,
1380,
2022,
666,
365,
19515,
315,
282,
665,
1579,
30,
1947,
272,
327,
315,
4163,
12,
465,
652,
21925,
3068,
1579,
30,
3762,
687,
876,
19925,
590,
5537,
1958,
272,
327,
314,
18910,
14,
221,
6601,
2022,
8363,
886,
642,
21375,
701,
849,
12,
272,
327,
22160,
2366,
1159,
4465,
3555,
1630,
440,
12,
880,
781,
886,
652,
2348,
14,
272,
327,
1455,
921,
23153,
14,
957,
15,
16069,
15,
1046,
1257,
8557,
15,
1001,
13,
26460,
13,
1530,
13,
6688,
13,
24032,
13,
13572,
272,
372,
2022,
14,
4180,
8,
585,
680,
1814,
23790,
401,
3886,
1103,
13589,
421,
199,
318,
2022,
63,
2708,
8,
585,
304,
272,
408,
3407,
2018,
2251,
367,
314,
1627,
4840,
1059,
1041,
272,
372,
2022,
14,
3640,
8,
475,
63,
17628,
8,
585,
430,
421,
199,
318,
308,
14167,
8,
585,
304,
272,
408,
11328,
1006,
8013,
402,
8139,
8365,
543,
282,
2849,
4601,
1041,
272,
372,
295,
14,
954,
8,
82,
29354,
88,
383,
2696,
88,
1165,
2807,
401,
298,
3872,
574,
680,
1913,
342,
421,
199,
318,
1166,
63,
3765,
8,
585,
12,
12254,
29,
549,
304,
272,
408,
3407,
282,
2851,
13,
8167,
1015,
402,
314,
1627,
574,
14,
339,
982,
1124,
6666,
1040,
365,
2549,
334,
1589,
849,
395,
7883,
911,
506,
11159,
272,
465,
298,
5207,
3140,
402,
2071,
1165,
1674,
221,
961,
365,
5827,
367,
1827,
3326,
272,
1325,
440,
367,
314,
931,
3931,
402,
282,
2851,
14,
221,
3390,
626,
642,
849,
272,
365,
314,
3837,
402,
2018,
1159,
4011,
859,
14,
339,
2508,
7445,
447,
650,
14,
17,
267,
710,
1124,
6666,
1040,
1423,
272,
408,
272,
6313,
275,
4011,
63,
1122,
14,
3513,
63,
6666,
340,
12254,
587,
4011,
63,
1122,
14,
3513,
272,
372,
6313,
8,
1624,
24,
8,
585,
430,
421,
199,
3,
2366,
650,
2896,
7645,
6818,
8321,
626,
781,
1929,
2877,
7396,
199,
3,
12591,
402,
1166,
63,
22726,
14,
221,
2136,
2597,
1929,
4154,
5705,
4514,
199,
3,
402,
2198,
63,
6177,
3967,
2366,
650,
1159,
1015,
315,
338,
10329,
641,
15952,
8137,
14,
199,
692,
984,
14,
1023,
63,
815,
59,
16
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
199,
3,
1898,
8937,
27107,
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,
624,
37,
551,
17818,
15,
324,
26306,
3102,
367,
4163,
12,
4840,
12,
10867,
12,
436,
11789,
14,
199,
199,
31892,
6952,
282,
9284,
1163,
3201,
19549,
1059,
26212,
3423,
626,
199,
7804,
2837,
541,
315,
1806,
900,
14,
199,
624,
199,
199,
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
870,
63,
1593,
12,
543,
63,
6242,
199,
199,
646,
295,
199,
646,
984,
199,
199,
504,
12148,
14,
1974,
492,
2649,
63,
466,
12,
7116,
63,
466,
12,
399,
199,
199,
893,
26,
272,
687,
4011,
14,
1122,
492,
2198,
63,
6177,
465,
485,
1122,
63,
6177,
221,
327,
1134,
19,
199,
2590,
3545,
26,
272,
687,
7097,
492,
2198,
63,
6177,
465,
485,
1122,
63,
6177,
221,
327,
2018,
499,
14,
22,
11,
199,
199,
893,
26,
272,
492,
30010,
552,
1701,
8710,
221,
327,
1134,
18,
199,
2590,
3545,
26,
272,
492,
3517,
14,
8327,
465,
30010,
552,
1701,
8710,
221,
327,
1134,
19,
199,
199,
893,
26,
272,
492,
4011,
14,
1122,
465,
4011,
63,
1122,
221,
327,
1134,
19,
199,
2590,
3545,
26,
272,
492,
4011,
465,
4011,
63,
1122,
221,
327,
1134,
18,
199,
199,
646,
2022,
199,
199,
893,
26,
272,
17742,
199,
2590,
12746,
26,
272,
17742,
275,
8678,
199,
199,
63,
56,
4943,
63,
28879,
63,
907,
275,
295,
14,
2014,
11894,
6,
16137,
3212,
418,
358,
199,
63,
56,
4943,
63,
28879,
63,
12511,
275,
791,
6,
356,
7673,
5282,
10805,
2650,
356,
7673,
4116,
10805,
12696,
356,
7673,
3308,
10805,
24536,
7673,
5184,
10805,
1993,
32496,
356,
7673,
3,
1355,
27,
936,
421,
199,
318,
671,
1360,
63,
3765,
8,
585,
304,
272,
408,
10260,
83,
282,
1059,
880,
652,
365,
1686,
4453,
4163,
503,
4692,
14,
339,
21067,
83,
314,
4110,
23696,
4542,
1124,
30,
4542,
25916,
4542,
12692,
4542,
436,
1124,
6,
4345,
272,
3979,
1202,
315,
2225,
1338,
314,
11077,
3326,
1471,
506,
27828,
272,
315,
9344,
14,
339,
2508,
16434,
447,
650,
14,
18,
10817,
16230,
314,
2849,
6313,
370,
314,
769,
402,
11077,
4110,
14,
272,
408,
272,
372,
485,
56,
4943,
63,
28879,
63,
907,
14,
954,
8,
2734,
1336,
26,
485,
56,
4943,
63,
28879,
63,
12511,
59,
1431,
14,
923,
8,
16,
4360,
1816,
370,
63,
17628,
8,
585,
430,
421,
199,
318,
671,
1360,
63,
22726,
8,
585,
304,
272,
408,
1358,
13,
3765,
83,
376,
4692,
13,
13572,
1059,
1041,
272,
372,
295,
14,
954,
8,
82,
2,
6,
27496,
31,
10127,
87,
23778,
2736,
401,
485,
3916,
63,
4502,
12,
485,
2975,
8,
585,
430,
421,
199,
3,
710,
10572,
626,
2022,
63,
2143,
14018,
2022,
14,
4180,
365,
376,
4514,
10093,
14,
199,
3,
7754,
1937,
4178,
921,
5031,
14,
957,
15,
84,
6161,
8369,
2871,
15,
18443,
15,
9302,
15,
16960,
199,
3,
2544,
10209,
282,
10299,
1056,
626,
9584,
1011,
958,
370,
642,
805,
14,
199,
318,
2022,
63,
2143,
8,
585,
304,
272,
408,
6243,
13,
2143,
83,
314,
1627,
2018,
909,
1041,
272,
327,
4840,
11291,
83,
1325,
1630,
440,
4409,
7568,
20275,
370,
506,
11077,
14,
272,
327,
961,
365,
2997,
1380,
2022,
666,
365,
19515,
315,
282,
665,
1579,
30,
1947,
272,
327,
315,
4163,
12,
465,
652,
21925,
3068,
1579,
30,
3762,
687,
876,
19925,
590,
5537,
1958,
272,
327,
314,
18910,
14,
221,
6601,
2022,
8363,
886,
642,
21375,
701,
849,
12,
272,
327,
22160,
2366,
1159,
4465,
3555,
1630,
440,
12,
880,
781,
886,
652,
2348,
14,
272,
327,
1455,
921,
23153,
14,
957,
15,
16069,
15,
1046,
1257,
8557,
15,
1001,
13,
26460,
13,
1530,
13,
6688,
13,
24032,
13,
13572,
272,
372,
2022,
14,
4180,
8,
585,
680,
1814,
23790,
401,
3886,
1103,
13589,
421,
199,
318,
2022,
63,
2708,
8,
585,
304,
272,
408,
3407,
2018,
2251,
367,
314,
1627,
4840,
1059,
1041,
272,
372,
2022,
14,
3640,
8,
475,
63,
17628,
8,
585,
430,
421,
199,
318,
308,
14167,
8,
585,
304,
272,
408,
11328,
1006,
8013,
402,
8139,
8365,
543,
282,
2849,
4601,
1041,
272,
372,
295,
14,
954,
8,
82,
29354,
88,
383,
2696,
88,
1165,
2807,
401,
298,
3872,
574,
680,
1913,
342,
421,
199,
318,
1166,
63,
3765,
8,
585,
12,
12254,
29,
549,
304,
272,
408,
3407,
282,
2851,
13,
8167,
1015,
402,
314,
1627,
574,
14,
339,
982,
1124,
6666,
1040,
365,
2549,
334,
1589,
849,
395,
7883,
911,
506,
11159,
272,
465,
298,
5207,
3140,
402,
2071,
1165,
1674,
221,
961,
365,
5827,
367,
1827,
3326,
272,
1325,
440,
367,
314,
931,
3931,
402,
282,
2851,
14,
221,
3390,
626,
642,
849,
272,
365,
314,
3837,
402,
2018,
1159,
4011,
859,
14,
339,
2508,
7445,
447,
650,
14,
17,
267,
710,
1124,
6666,
1040,
1423,
272,
408,
272,
6313,
275,
4011,
63,
1122,
14,
3513,
63,
6666,
340,
12254,
587,
4011,
63,
1122,
14,
3513,
272,
372,
6313,
8,
1624,
24,
8,
585,
430,
421,
199,
3,
2366,
650,
2896,
7645,
6818,
8321,
626,
781,
1929,
2877,
7396,
199,
3,
12591,
402,
1166,
63,
22726,
14,
221,
2136,
2597,
1929,
4154,
5705,
4514,
199,
3,
402,
2198,
63,
6177,
3967,
2366,
650,
1159,
1015,
315,
338,
10329,
641,
15952,
8137,
14,
199,
692,
984,
14,
1023,
63,
815,
59,
16,
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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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
] |
dkarakats/edx-platform
|
common/djangoapps/config_models/models.py
|
9
|
2073
|
"""
Django Model baseclass for database-backed configuration.
"""
from django.db import models
from django.contrib.auth.models import User
from django.core.cache import get_cache, InvalidCacheBackendError
try:
cache = get_cache('configuration') # pylint: disable=invalid-name
except InvalidCacheBackendError:
from django.core.cache import cache
class ConfigurationModel(models.Model):
"""
Abstract base class for model-based configuration
Properties:
cache_timeout (int): The number of seconds that this configuration
should be cached
"""
class Meta(object): # pylint: disable=missing-docstring
abstract = True
# The number of seconds
cache_timeout = 600
change_date = models.DateTimeField(auto_now_add=True)
changed_by = models.ForeignKey(User, editable=False, null=True, on_delete=models.PROTECT)
enabled = models.BooleanField(default=False)
def save(self, *args, **kwargs):
"""
Clear the cached value when saving a new configuration entry
"""
super(ConfigurationModel, self).save(*args, **kwargs)
cache.delete(self.cache_key_name())
@classmethod
def cache_key_name(cls):
"""Return the name of the key to use to cache the current configuration"""
return 'configuration/{}/current'.format(cls.__name__)
@classmethod
def current(cls):
"""
Return the active configuration entry, either from cache,
from the database, or by creating a new empty entry (which is not
persisted).
"""
cached = cache.get(cls.cache_key_name())
if cached is not None:
return cached
try:
current = cls.objects.order_by('-change_date')[0]
except IndexError:
current = cls()
cache.set(cls.cache_key_name(), current, cls.cache_timeout)
return current
@classmethod
def is_enabled(cls):
"""Returns True if this feature is configured as enabled, else False."""
return cls.current().enabled
|
agpl-3.0
|
[
624,
199,
9323,
5822,
1300,
533,
367,
3050,
13,
894,
379,
2897,
14,
199,
624,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
1018,
14,
1637,
492,
664,
63,
1637,
12,
6378,
4437,
8447,
547,
199,
199,
893,
26,
272,
2581,
275,
664,
63,
1637,
360,
4758,
358,
221,
327,
4287,
26,
3507,
29,
3197,
13,
354,
199,
2590,
6378,
4437,
8447,
547,
26,
272,
687,
1639,
14,
1018,
14,
1637,
492,
2581,
421,
199,
533,
11595,
1685,
8,
992,
14,
1685,
304,
272,
408,
272,
11836,
1300,
1021,
367,
1402,
13,
6788,
2897,
339,
19329,
26,
267,
2581,
63,
2593,
334,
442,
304,
710,
1329,
402,
4696,
626,
642,
2897,
288,
1077,
506,
6328,
272,
408,
339,
1021,
6288,
8,
785,
304,
221,
327,
4287,
26,
3507,
29,
4752,
13,
12485,
267,
9006,
275,
715,
339,
327,
710,
1329,
402,
4696,
272,
2581,
63,
2593,
275,
11624,
339,
1570,
63,
602,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
63,
525,
29,
549,
9,
272,
2896,
63,
991,
275,
1709,
14,
3190,
8,
1899,
12,
14783,
29,
797,
12,
2973,
29,
549,
12,
641,
63,
1807,
29,
992,
14,
29148,
9,
272,
5223,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
339,
347,
3354,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
14836,
314,
6328,
574,
1380,
13369,
282,
892,
2897,
2397,
267,
408,
267,
1613,
8,
5688,
1685,
12,
291,
680,
2117,
2031,
589,
12,
1011,
958,
9,
267,
2581,
14,
1807,
8,
277,
14,
1637,
63,
498,
63,
354,
1012,
339,
768,
3744,
272,
347,
2581,
63,
498,
63,
354,
8,
1886,
304,
267,
408,
1767,
314,
536,
402,
314,
790,
370,
675,
370,
2581,
314,
1453,
2897,
624,
267,
372,
283,
4758,
19655,
1818,
1370,
908,
8,
1886,
855,
354,
3368,
339,
768,
3744,
272,
347,
1453,
8,
1886,
304,
267,
408,
267,
1432,
314,
4702,
2897,
2397,
12,
1902,
687,
2581,
12,
267,
687,
314,
3050,
12,
503,
701,
6425,
282,
892,
2701,
2397,
334,
6777,
365,
440,
267,
1126,
24925,
680,
267,
408,
267,
6328,
275,
2581,
14,
362,
8,
1886,
14,
1637,
63,
498,
63,
354,
1012,
267,
340,
6328,
365,
440,
488,
26,
288,
372,
6328,
398,
862,
26,
288,
1453,
275,
843,
14,
1462,
14,
1648,
63,
991,
3654,
1461,
63,
602,
5832,
16,
61,
267,
871,
7888,
26,
288,
1453,
275,
843,
342,
398,
2581,
14,
409,
8,
1886,
14,
1637,
63,
498,
63,
354,
1062,
1453,
12,
843,
14,
1637,
63,
2593,
9,
267,
372,
1453,
339,
768,
3744,
272,
347,
365,
63,
3827,
8,
1886,
304,
267,
408,
3407,
715,
340,
642,
3878,
365,
7526,
465,
5223,
12,
587,
756,
1041,
267,
372,
843,
14,
1818,
1252,
3827,
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
] |
[
199,
9323,
5822,
1300,
533,
367,
3050,
13,
894,
379,
2897,
14,
199,
624,
199,
504,
1639,
14,
697,
492,
1709,
199,
504,
1639,
14,
2828,
14,
1178,
14,
992,
492,
2876,
199,
504,
1639,
14,
1018,
14,
1637,
492,
664,
63,
1637,
12,
6378,
4437,
8447,
547,
199,
199,
893,
26,
272,
2581,
275,
664,
63,
1637,
360,
4758,
358,
221,
327,
4287,
26,
3507,
29,
3197,
13,
354,
199,
2590,
6378,
4437,
8447,
547,
26,
272,
687,
1639,
14,
1018,
14,
1637,
492,
2581,
421,
199,
533,
11595,
1685,
8,
992,
14,
1685,
304,
272,
408,
272,
11836,
1300,
1021,
367,
1402,
13,
6788,
2897,
339,
19329,
26,
267,
2581,
63,
2593,
334,
442,
304,
710,
1329,
402,
4696,
626,
642,
2897,
288,
1077,
506,
6328,
272,
408,
339,
1021,
6288,
8,
785,
304,
221,
327,
4287,
26,
3507,
29,
4752,
13,
12485,
267,
9006,
275,
715,
339,
327,
710,
1329,
402,
4696,
272,
2581,
63,
2593,
275,
11624,
339,
1570,
63,
602,
275,
1709,
14,
4626,
8,
2495,
63,
2131,
63,
525,
29,
549,
9,
272,
2896,
63,
991,
275,
1709,
14,
3190,
8,
1899,
12,
14783,
29,
797,
12,
2973,
29,
549,
12,
641,
63,
1807,
29,
992,
14,
29148,
9,
272,
5223,
275,
1709,
14,
5036,
8,
885,
29,
797,
9,
339,
347,
3354,
8,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
408,
267,
14836,
314,
6328,
574,
1380,
13369,
282,
892,
2897,
2397,
267,
408,
267,
1613,
8,
5688,
1685,
12,
291,
680,
2117,
2031,
589,
12,
1011,
958,
9,
267,
2581,
14,
1807,
8,
277,
14,
1637,
63,
498,
63,
354,
1012,
339,
768,
3744,
272,
347,
2581,
63,
498,
63,
354,
8,
1886,
304,
267,
408,
1767,
314,
536,
402,
314,
790,
370,
675,
370,
2581,
314,
1453,
2897,
624,
267,
372,
283,
4758,
19655,
1818,
1370,
908,
8,
1886,
855,
354,
3368,
339,
768,
3744,
272,
347,
1453,
8,
1886,
304,
267,
408,
267,
1432,
314,
4702,
2897,
2397,
12,
1902,
687,
2581,
12,
267,
687,
314,
3050,
12,
503,
701,
6425,
282,
892,
2701,
2397,
334,
6777,
365,
440,
267,
1126,
24925,
680,
267,
408,
267,
6328,
275,
2581,
14,
362,
8,
1886,
14,
1637,
63,
498,
63,
354,
1012,
267,
340,
6328,
365,
440,
488,
26,
288,
372,
6328,
398,
862,
26,
288,
1453,
275,
843,
14,
1462,
14,
1648,
63,
991,
3654,
1461,
63,
602,
5832,
16,
61,
267,
871,
7888,
26,
288,
1453,
275,
843,
342,
398,
2581,
14,
409,
8,
1886,
14,
1637,
63,
498,
63,
354,
1062,
1453,
12,
843,
14,
1637,
63,
2593,
9,
267,
372,
1453,
339,
768,
3744,
272,
347,
365,
63,
3827,
8,
1886,
304,
267,
408,
3407,
715,
340,
642,
3878,
365,
7526,
465,
5223,
12,
587,
756,
1041,
267,
372,
843,
14,
1818,
1252,
3827,
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,
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
] |
thomasdouenne/openfisca-france-indirect-taxation
|
openfisca_france_indirect_taxation/model/consommation/poste_coicop_generator_old.py
|
4
|
19956
|
# -*- coding: utf-8 -*-
# OpenFisca -- A versatile microsimulation software
# By: OpenFisca Team <contact@openfisca.fr>
#
# Copyright (C) 2011, 2012, 2013, 2014, 2015 OpenFisca Team
# https://github.com/openfisca
#
# This file is part of OpenFisca.
#
# OpenFisca 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.
#
# OpenFisca 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 __future__ import division
from openfisca_france_indirect_taxation.model.base import *
class poste_coicop_111(Variable):
column = FloatCol()
entity_class = Menages
label = u"Pain et céréales"
class poste_coicop_112(Variable):
column = FloatCol()
entity_class = Menages
label = u"Viande"
class poste_coicop_113(Variable):
column = FloatCol()
entity_class = Menages
label = u"Poisson et fruits de mer"
class poste_coicop_114(Variable):
column = FloatCol()
entity_class = Menages
label = u"Lait, fromage et œufs"
class poste_coicop_115(Variable):
column = FloatCol()
entity_class = Menages
label = u"Huiles et graisses"
class poste_coicop_1151(Variable):
column = FloatCol()
entity_class = Menages
label = u">>> Margarines et autres graisses végétales"
class poste_coicop_116(Variable):
column = FloatCol()
entity_class = Menages
label = u"Fruits"
class poste_coicop_117(Variable):
column = FloatCol()
entity_class = Menages
label = u"Légumes"
class poste_coicop_118(Variable):
column = FloatCol()
entity_class = Menages
label = u"Sucre, confiture, miel, chocolat et confiserie"
class poste_coicop_1181(Variable):
column = FloatCol()
entity_class = Menages
label = u">>> Confiserie"
class poste_coicop_119(Variable):
column = FloatCol()
entity_class = Menages
label = u"Produits alimentaires non compris ailleurs"
class poste_coicop_121(Variable):
column = FloatCol()
entity_class = Menages
label = u"Café, thé et cacao"
class poste_coicop_122(Variable):
column = FloatCol()
entity_class = Menages
label = u"Eaux minérales, boissons rafraîchissantes, jus de fruits et de légumes"
class poste_coicop_211(Variable):
column = FloatCol()
entity_class = Menages
label = u"Alcools de bouche "
class poste_coicop_212(Variable):
column = FloatCol()
entity_class = Menages
label = u"Vin et boissons fermentées"
class poste_coicop_213(Variable):
column = FloatCol()
entity_class = Menages
label = u"Bière"
class poste_coicop_2201(Variable):
column = FloatCol()
entity_class = Menages
label = u">>> Cigarettes"
class poste_coicop_2202(Variable):
column = FloatCol()
entity_class = Menages
label = u">>> Cigares et cigarillos"
class poste_coicop_2203(Variable):
column = FloatCol()
entity_class = Menages
label = u">>> Tabac sous d'autres formes"
class poste_coicop_230(Variable):
column = FloatCol()
entity_class = Menages
label = u"Stupéfiants"
class poste_coicop_311(Variable):
column = FloatCol()
entity_class = Menages
label = u"Tissus pour habillement"
class poste_coicop_312(Variable):
column = FloatCol()
entity_class = Menages
label = u"Vêtements"
class poste_coicop_313(Variable):
column = FloatCol()
entity_class = Menages
label = u"Autres articles et accessoires d'habillement"
class poste_coicop_314(Variable):
column = FloatCol()
entity_class = Menages
label = u"Nettoyage, réparation et location d'articles d'habillement"
class poste_coicop_321(Variable):
column = FloatCol()
entity_class = Menages
label = u"Chaussures diverses"
class poste_coicop_322(Variable):
column = FloatCol()
entity_class = Menages
label = u"Cordonnerie et location de chaussures"
class poste_coicop_411(Variable):
column = FloatCol()
entity_class = Menages
label = u"Loyers effectivement payés par les locataires"
class poste_coicop_412(Variable):
column = FloatCol()
entity_class = Menages
label = u"Autres loyers effectifs"
class poste_coicop_421(Variable):
column = FloatCol()
entity_class = Menages
label = u"Loyers fictifs des propriétaires occupants"
class poste_coicop_422(Variable):
column = FloatCol()
entity_class = Menages
label = u"Autres loyers fictifs"
class poste_coicop_431(Variable):
column = FloatCol()
entity_class = Menages
label = u"Fournitures pour travaux d'entretien et de réparation des logements"
class poste_coicop_432(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services concernant l'entretien et les réparations du logement"
class poste_coicop_441(Variable):
column = FloatCol()
entity_class = Menages
label = u"Alimentation en eau"
class poste_coicop_442(Variable):
column = FloatCol()
entity_class = Menages
label = u"Collecte des ordures ménagères"
class poste_coicop_443(Variable):
column = FloatCol()
entity_class = Menages
label = u"Reprise des eaux usées"
class poste_coicop_444(Variable):
column = FloatCol()
entity_class = Menages
label = u"Service divers liés au logement non compris ailleurs"
class poste_coicop_451(Variable):
column = FloatCol()
entity_class = Menages
label = u"Electricité"
class poste_coicop_4511(Variable):
column = FloatCol()
entity_class = Menages
label = u"Facture EDF GDF non dissociables"
class poste_coicop_452(Variable):
column = FloatCol()
entity_class = Menages
label = u"Gaz"
class poste_coicop_4522(Variable):
column = FloatCol()
entity_class = Menages
label = u"Achat de butane, propane"
class poste_coicop_453(Variable):
column = FloatCol()
entity_class = Menages
label = u"Combustibles liquides"
class poste_coicop_454(Variable):
column = FloatCol()
entity_class = Menages
label = u"Combustibles solides"
class poste_coicop_455(Variable):
column = FloatCol()
entity_class = Menages
label = u"Energie thermique"
class poste_coicop_511(Variable):
column = FloatCol()
entity_class = Menages
label = u"Meubles et articles d'ameublement"
class poste_coicop_512(Variable):
column = FloatCol()
entity_class = Menages
label = u"Tapis et revêtements de sols divers"
class poste_coicop_513(Variable):
column = FloatCol()
entity_class = Menages
label = u"Réparation de meubles, d'articles d'ameublement et de revêtements souples pour le sol"
class poste_coicop_520(Variable):
column = FloatCol()
entity_class = Menages
label = u"Article de ménage en textiles"
class poste_coicop_531(Variable):
column = FloatCol()
entity_class = Menages
label = u"Gros appareils ménagers, électriques ou non"
class poste_coicop_532(Variable):
column = FloatCol()
entity_class = Menages
label = u"Petits appareils électroméangers"
class poste_coicop_533(Variable):
column = FloatCol()
entity_class = Menages
label = u"Réparation d'appareils ménagers"
class poste_coicop_540(Variable):
column = FloatCol()
entity_class = Menages
label = u"Verrerie, vaisselle et ustensiles de ménage"
class poste_coicop_551(Variable):
column = FloatCol()
entity_class = Menages
label = u"Gros outillage et matériel"
class poste_coicop_552(Variable):
column = FloatCol()
entity_class = Menages
label = u"Petit outillage et accessoires divers"
class poste_coicop_561(Variable):
column = FloatCol()
entity_class = Menages
label = u"Biens d'équipement ménager non durables"
class poste_coicop_562(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services domestiques et services ménagers"
class poste_coicop_611(Variable):
column = FloatCol()
entity_class = Menages
label = u"Produits pharmaceutiques"
class poste_coicop_612(Variable):
column = FloatCol()
entity_class = Menages
label = u"Produits médicaux divers"
class poste_coicop_613(Variable):
column = FloatCol()
entity_class = Menages
label = u"Appareils et matériel thérapeutiques"
class poste_coicop_621(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services médicaux"
class poste_coicop_622(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services dentaires"
class poste_coicop_623(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services paramédicaux"
class poste_coicop_630(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services hospitaliers"
class poste_coicop_711(Variable):
column = FloatCol()
entity_class = Menages
label = u"Voitures automobiles"
class poste_coicop_712(Variable):
column = FloatCol()
entity_class = Menages
label = u"Motocycles"
class poste_coicop_713(Variable):
column = FloatCol()
entity_class = Menages
label = u"Bicyclettes"
class poste_coicop_721(Variable):
column = FloatCol()
entity_class = Menages
label = u"Pièces de rechange et accessoires pour véhicules de tourisme "
class poste_coicop_722(Variable):
column = FloatCol()
entity_class = Menages
label = u"Carburants et lubrifiants pour véhicules de tourisme"
class poste_coicop_723(Variable):
column = FloatCol()
entity_class = Menages
label = u"Entretien et réparation de véhicules particuliers"
class poste_coicop_724(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services divers liés aux véhicules particuliers"
class poste_coicop_731(Variable):
column = FloatCol()
entity_class = Menages
label = u"Transport ferroviaire de passagers"
class poste_coicop_732(Variable):
column = FloatCol()
entity_class = Menages
label = u"Transport routier de passagers"
class poste_coicop_733(Variable):
column = FloatCol()
entity_class = Menages
label = u"Transport aérien de passagers"
class poste_coicop_734(Variable):
column = FloatCol()
entity_class = Menages
label = u"Transport maritime et fluvial de passagers"
class poste_coicop_735(Variable):
column = FloatCol()
entity_class = Menages
label = u"Transport combiné de passagers"
class poste_coicop_736(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services de transport divers"
class poste_coicop_810(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services postaux"
class poste_coicop_831(Variable):
column = FloatCol()
entity_class = Menages
label = u"Matériel de téléphonie et de télécopie"
class poste_coicop_832(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services de téléphonie et de télécopie"
class poste_coicop_911(Variable):
column = FloatCol()
entity_class = Menages
label = u"Matériel de réception, d'enregistrement et de reproduction du son et de l'image"
class poste_coicop_912(Variable):
column = FloatCol()
entity_class = Menages
label = u"Matériel photographique et cinématographique et appareils optiques"
class poste_coicop_913(Variable):
column = FloatCol()
entity_class = Menages
label = u"Matériel de traitement de l'information"
class poste_coicop_914(Variable):
column = FloatCol()
entity_class = Menages
label = u"Supports d'enregistrement"
class poste_coicop_915(Variable):
column = FloatCol()
entity_class = Menages
label = u"Réparation de matériel audiovisuel, photographique et de traitement de l'information"
class poste_coicop_921(Variable):
column = FloatCol()
entity_class = Menages
label = u"Biens durables pour loisirs de plein air"
class poste_coicop_922(Variable):
column = FloatCol()
entity_class = Menages
label = u"Instruments de musique et biens durables destinés aux loisirs d'intérieur"
class poste_coicop_923(Variable):
column = FloatCol()
entity_class = Menages
label = u"Entretien et réparation des autres biens durables à fonction récréatives et culturelles"
class poste_coicop_931(Variable):
column = FloatCol()
entity_class = Menages
label = u"Jeux, jouets et passe-temps"
class poste_coicop_932(Variable):
column = FloatCol()
entity_class = Menages
label = u"Articles de sport, matériel de camping et matériel pour activités de plein air"
class poste_coicop_933(Variable):
column = FloatCol()
entity_class = Menages
label = u"Produits pour jardin, plantes et fleurs"
class poste_coicop_934(Variable):
column = FloatCol()
entity_class = Menages
label = u"Animaux de compagnie et articles connexes"
class poste_coicop_935(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services vétérinaires et autres services pour animaux de compagnie"
class poste_coicop_941(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services récréatifs et sportifs"
class poste_coicop_942(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services culturels"
class poste_coicop_943(Variable):
column = FloatCol()
entity_class = Menages
label = u"Jeux de hasard"
class poste_coicop_951(Variable):
column = FloatCol()
entity_class = Menages
label = u"Livre"
class poste_coicop_952(Variable):
column = FloatCol()
entity_class = Menages
label = u"Journaux et publications périodiques"
class poste_coicop_953(Variable):
column = FloatCol()
entity_class = Menages
label = u"Imprimés divers"
class poste_coicop_954(Variable):
column = FloatCol()
entity_class = Menages
label = u"Papeterie et matériel de dessin"
class poste_coicop_960(Variable):
column = FloatCol()
entity_class = Menages
label = u"Forfaits touristiques "
class poste_coicop_1010(Variable):
column = FloatCol()
entity_class = Menages
label = u"Enseignement préélémentaire et primaire"
class poste_coicop_1020(Variable):
column = FloatCol()
entity_class = Menages
label = u"Enseignement secondaire"
class poste_coicop_1030(Variable):
column = FloatCol()
entity_class = Menages
label = u"Enseignement postsecondaire non supérieur"
class poste_coicop_1040(Variable):
column = FloatCol()
entity_class = Menages
label = u"Enseignement supérieur"
class poste_coicop_1050(Variable):
column = FloatCol()
entity_class = Menages
label = u"Enseignement non défini par niveau"
class poste_coicop_11112(Variable):
column = FloatCol()
entity_class = Menages
label = u">>> Restauration à emporter"
class poste_coicop_11113(Variable):
column = FloatCol()
entity_class = Menages
label = u">>> Restauration sur place"
class poste_coicop_11114(Variable):
column = FloatCol()
entity_class = Menages
label = u">>> Consommation de boissons alcoolisées"
class poste_coicop_1112(Variable):
column = FloatCol()
entity_class = Menages
label = u"Cantines"
class poste_coicop_1120(Variable):
column = FloatCol()
entity_class = Menages
label = u"Services d'hébergement"
class poste_coicop_1211(Variable):
column = FloatCol()
entity_class = Menages
label = u"Salons de coiffure et instituts de soins et de beauté"
class poste_coicop_1212(Variable):
column = FloatCol()
entity_class = Menages
label = u"Appareils électriques pour soins corporels"
class poste_coicop_1213(Variable):
column = FloatCol()
entity_class = Menages
label = u"Autres appareils, articles et produits pour soins corporels"
class poste_coicop_1220(Variable):
column = FloatCol()
entity_class = Menages
label = u"Prostitution"
class poste_coicop_1231(Variable):
column = FloatCol()
entity_class = Menages
label = u"Articles de bijouterie et horlogerie"
class poste_coicop_1232(Variable):
column = FloatCol()
entity_class = Menages
label = u"Autres effets personnels"
class poste_coicop_1240(Variable):
column = FloatCol()
entity_class = Menages
label = u"Protection sociale"
class poste_coicop_1251(Variable):
column = FloatCol()
entity_class = Menages
label = u"Assurance vie"
class poste_coicop_1252(Variable):
column = FloatCol()
entity_class = Menages
label = u"Assurance habitation"
class poste_coicop_1253(Variable):
column = FloatCol()
entity_class = Menages
label = u"Assurance maladie"
class poste_coicop_1254(Variable):
column = FloatCol()
entity_class = Menages
label = u"Assurance transports"
class poste_coicop_1255(Variable):
column = FloatCol()
entity_class = Menages
label = u"Autres assurances"
class poste_coicop_1261(Variable):
column = FloatCol()
entity_class = Menages
label = u"Coûts des services d'intermédiation financière indirectement mesurés"
class poste_coicop_1262(Variable):
column = FloatCol()
entity_class = Menages
label = u"Autres services financiers non compris ailleurs"
class poste_coicop_1270(Variable):
column = FloatCol()
entity_class = Menages
label = u"Autres services non compris ailleurs"
class poste_coicop_9901(Variable):
column = FloatCol()
entity_class = Menages
label = u"caution pour la location d'un logement"
class poste_coicop_9902(Variable):
column = FloatCol()
entity_class = Menages
label = u"achats de logements, garages, parkings, box et terrains"
class poste_coicop_9903(Variable):
column = FloatCol()
entity_class = Menages
label = u"Gros travaux d'entretien dans les logements"
class poste_coicop_9911(Variable):
column = FloatCol()
entity_class = Menages
label = u"impôts et taxes de la résidence principale"
class poste_coicop_9912(Variable):
column = FloatCol()
entity_class = Menages
label = u"impôts et taxes résidence secondaire ou autre logement"
class poste_coicop_9913(Variable):
column = FloatCol()
entity_class = Menages
label = u"impôts sur le revenu"
class poste_coicop_9914(Variable):
column = FloatCol()
entity_class = Menages
label = u"taxes automobile"
class poste_coicop_9915(Variable):
column = FloatCol()
entity_class = Menages
label = u"autres impôts et taxes"
class poste_coicop_9921(Variable):
column = FloatCol()
entity_class = Menages
label = u"remboursements de prêts résidence principale"
class poste_coicop_9922(Variable):
column = FloatCol()
entity_class = Menages
label = u"remboursements de prêts résidence secondaire ou autre logement"
class poste_coicop_9923(Variable):
column = FloatCol()
entity_class = Menages
label = u"autres remboursements de prêts"
class poste_coicop_9931(Variable):
column = FloatCol()
entity_class = Menages
label = u"argent donné au sein du ménage"
class poste_coicop_9932(Variable):
column = FloatCol()
entity_class = Menages
label = u"aides et cadeaux en argent offerts par le ménage (à des membres de la famille ne"
class poste_coicop_9933(Variable):
column = FloatCol()
entity_class = Menages
label = u"cadeaux offerts (argent ou bien) sai"
class poste_coicop_9941(Variable):
column = FloatCol()
entity_class = Menages
label = u"prélèvements de l'employeur"
|
agpl-3.0
|
[
199,
3,
1882,
2803,
26,
2774,
13,
24,
1882,
421,
199,
3,
3232,
38,
374,
696,
1553,
437,
809,
83,
23590,
9967,
22930,
2032,
199,
3,
4885,
26,
3232,
38,
374,
696,
11682,
665,
7811,
32,
1490,
329,
7101,
14,
4391,
30,
199,
3,
199,
3,
1898,
334,
35,
9,
7760,
12,
6029,
12,
6171,
12,
6927,
12,
6900,
3232,
38,
374,
696,
11682,
199,
3,
4178,
921,
5031,
14,
957,
15,
1490,
329,
7101,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
3232,
38,
374,
696,
14,
199,
3,
199,
3,
3232,
38,
374,
696,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
3232,
38,
374,
696,
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,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
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,
421,
199,
504,
636,
2443,
363,
492,
4629,
199,
199,
504,
1551,
329,
7101,
63,
4391,
554,
63,
29306,
63,
5530,
425,
14,
1238,
14,
1095,
492,
627,
421,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
6673,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
48,
1581,
10844,
286,
5741,
82,
5741,
7098,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
6094,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
2201,
290,
271,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
9225,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
1575,
18571,
10844,
289,
6558,
1405,
477,
4004,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7636,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
44,
2781,
12,
26226,
960,
10844,
221,
130,
242,
1286,
83,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7680,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
25542,
22894,
10844,
1999,
374,
874,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
845,
2869,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
6071,
603,
1273,
285,
3746,
10844,
6384,
470,
1999,
374,
874,
373,
5741,
71,
5741,
502,
2978,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7524,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
38,
6558,
1405,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7362,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
44,
5741,
71,
940,
83,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7906,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
51,
947,
264,
12,
406,
3269,
608,
12,
10684,
352,
12,
2468,
761,
292,
10844,
406,
329,
261,
11317,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
845,
2835,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
6071,
1448,
329,
261,
11317,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7119,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
919,
2033,
1405,
21165,
434,
5789,
470,
2222,
1013,
5719,
282,
17142,
21050,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
10753,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
35,
2756,
5741,
12,
294,
5741,
10844,
286,
645,
8035,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7507,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
37,
10962,
1748,
5741,
345,
2978,
12,
1234,
18571,
83,
660,
21844,
128,
107,
30883,
18904,
744,
12,
1335,
527,
477,
289,
6558,
1405,
10844,
221,
477,
634,
5741,
71,
940,
83,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
12832,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
2439,
331,
1446,
477,
330,
810,
595,
298,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
11722,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
54,
262,
10844,
1234,
18571,
83,
289,
281,
434,
5741,
397,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
14271,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
17975,
18631,
264,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
1081,
614,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
6071,
445,
528,
1530,
84,
744,
2,
199
] |
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
421,
199,
3,
3232,
38,
374,
696,
1553,
437,
809,
83,
23590,
9967,
22930,
2032,
199,
3,
4885,
26,
3232,
38,
374,
696,
11682,
665,
7811,
32,
1490,
329,
7101,
14,
4391,
30,
199,
3,
199,
3,
1898,
334,
35,
9,
7760,
12,
6029,
12,
6171,
12,
6927,
12,
6900,
3232,
38,
374,
696,
11682,
199,
3,
4178,
921,
5031,
14,
957,
15,
1490,
329,
7101,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
3232,
38,
374,
696,
14,
199,
3,
199,
3,
3232,
38,
374,
696,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
199,
3,
652,
1334,
314,
2895,
402,
314,
1664,
4265,
1696,
1684,
844,
465,
199,
3,
3267,
701,
314,
2868,
2290,
2752,
12,
1902,
1015,
650,
402,
314,
199,
3,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
3232,
38,
374,
696,
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,
4265,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
4265,
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,
421,
199,
504,
636,
2443,
363,
492,
4629,
199,
199,
504,
1551,
329,
7101,
63,
4391,
554,
63,
29306,
63,
5530,
425,
14,
1238,
14,
1095,
492,
627,
421,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
6673,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
48,
1581,
10844,
286,
5741,
82,
5741,
7098,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
6094,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
2201,
290,
271,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
9225,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
1575,
18571,
10844,
289,
6558,
1405,
477,
4004,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7636,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
44,
2781,
12,
26226,
960,
10844,
221,
130,
242,
1286,
83,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7680,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
25542,
22894,
10844,
1999,
374,
874,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
845,
2869,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
6071,
603,
1273,
285,
3746,
10844,
6384,
470,
1999,
374,
874,
373,
5741,
71,
5741,
502,
2978,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7524,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
38,
6558,
1405,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7362,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
44,
5741,
71,
940,
83,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7906,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
51,
947,
264,
12,
406,
3269,
608,
12,
10684,
352,
12,
2468,
761,
292,
10844,
406,
329,
261,
11317,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
845,
2835,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
6071,
1448,
329,
261,
11317,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7119,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
919,
2033,
1405,
21165,
434,
5789,
470,
2222,
1013,
5719,
282,
17142,
21050,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
10753,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
35,
2756,
5741,
12,
294,
5741,
10844,
286,
645,
8035,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
7507,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
37,
10962,
1748,
5741,
345,
2978,
12,
1234,
18571,
83,
660,
21844,
128,
107,
30883,
18904,
744,
12,
1335,
527,
477,
289,
6558,
1405,
10844,
221,
477,
634,
5741,
71,
940,
83,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
12832,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
2439,
331,
1446,
477,
330,
810,
595,
298,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
11722,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
54,
262,
10844,
1234,
18571,
83,
289,
281,
434,
5741,
397,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
14271,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
17975,
18631,
264,
2,
199,
199,
533,
2086,
266,
63,
331,
12802,
80,
63,
1081,
614,
8,
2773,
304,
272,
2763,
275,
11140,
2001,
342,
272,
4642,
63,
533,
275,
603,
287,
7441,
272,
1768,
275,
399,
2,
6071,
445,
528,
1530,
84,
744,
2,
199,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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import io
import unittest
from test.pickletester import (AbstractPickleTests,
AbstractPickleModuleTests,
AbstractPicklerUnpicklerObjectTests,
BigmemPickleTests)
from test import test_support
class cStringIOMixin:
output = input = cStringIO.StringIO
def close(self, f):
pass
class BytesIOMixin:
output = input = io.BytesIO
def close(self, f):
pass
class FileIOMixin:
def output(self):
return open(test_support.TESTFN, 'wb+')
def input(self, data):
f = open(test_support.TESTFN, 'wb+')
try:
f.write(data)
f.seek(0)
return f
except:
f.close()
raise
def close(self, f):
f.close()
test_support.unlink(test_support.TESTFN)
class cPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
def setUp(self):
self.dumps = cPickle.dumps
self.loads = cPickle.loads
error = cPickle.BadPickleGet
module = cPickle
class cPicklePicklerTests(AbstractPickleTests):
def dumps(self, arg, proto=0):
f = self.output()
try:
p = cPickle.Pickler(f, proto)
p.dump(arg)
f.seek(0)
return f.read()
finally:
self.close(f)
def loads(self, buf):
f = self.input(buf)
try:
p = cPickle.Unpickler(f)
return p.load()
finally:
self.close(f)
error = cPickle.BadPickleGet
class cStringIOCPicklerTests(cStringIOMixin, cPicklePicklerTests):
pass
class BytesIOCPicklerTests(BytesIOMixin, cPicklePicklerTests):
pass
class FileIOCPicklerTests(FileIOMixin, cPicklePicklerTests):
pass
class cPickleListPicklerTests(AbstractPickleTests):
def dumps(self, arg, proto=0):
p = cPickle.Pickler(proto)
p.dump(arg)
return p.getvalue()
def loads(self, *args):
f = self.input(args[0])
try:
p = cPickle.Unpickler(f)
return p.load()
finally:
self.close(f)
error = cPickle.BadPickleGet
class cStringIOCPicklerListTests(cStringIOMixin, cPickleListPicklerTests):
pass
class BytesIOCPicklerListTests(BytesIOMixin, cPickleListPicklerTests):
pass
class FileIOCPicklerListTests(FileIOMixin, cPickleListPicklerTests):
pass
class cPickleFastPicklerTests(AbstractPickleTests):
def dumps(self, arg, proto=0):
f = self.output()
try:
p = cPickle.Pickler(f, proto)
p.fast = 1
p.dump(arg)
f.seek(0)
return f.read()
finally:
self.close(f)
def loads(self, *args):
f = self.input(args[0])
try:
p = cPickle.Unpickler(f)
return p.load()
finally:
self.close(f)
error = cPickle.BadPickleGet
def test_recursive_list(self):
self.assertRaises(ValueError,
AbstractPickleTests.test_recursive_list,
self)
def test_recursive_tuple(self):
self.assertRaises(ValueError,
AbstractPickleTests.test_recursive_tuple,
self)
def test_recursive_inst(self):
self.assertRaises(ValueError,
AbstractPickleTests.test_recursive_inst,
self)
def test_recursive_dict(self):
self.assertRaises(ValueError,
AbstractPickleTests.test_recursive_dict,
self)
def test_recursive_multi(self):
self.assertRaises(ValueError,
AbstractPickleTests.test_recursive_multi,
self)
def test_nonrecursive_deep(self):
# If it's not cyclic, it should pickle OK even if the nesting
# depth exceeds PY_CPICKLE_FAST_LIMIT. That happens to be
# 50 today. Jack Jansen reported stack overflow on Mac OS 9
# at 64.
a = []
for i in range(60):
a = [a]
b = self.loads(self.dumps(a))
self.assertEqual(a, b)
class cStringIOCPicklerFastTests(cStringIOMixin, cPickleFastPicklerTests):
pass
class BytesIOCPicklerFastTests(BytesIOMixin, cPickleFastPicklerTests):
pass
class FileIOCPicklerFastTests(FileIOMixin, cPickleFastPicklerTests):
pass
class cPicklePicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
pickler_class = cPickle.Pickler
unpickler_class = cPickle.Unpickler
class cPickleBigmemPickleTests(BigmemPickleTests):
def dumps(self, arg, proto=0, fast=0):
# Ignore fast
return cPickle.dumps(arg, proto)
def loads(self, buf):
# Ignore fast
return cPickle.loads(buf)
class Node(object):
pass
class cPickleDeepRecursive(unittest.TestCase):
def test_issue2702(self):
# This should raise a RecursionLimit but in some
# platforms (FreeBSD, win32) sometimes raises KeyError instead,
# or just silently terminates the interpreter (=crashes).
nodes = [Node() for i in range(500)]
for n in nodes:
n.connections = list(nodes)
n.connections.remove(n)
self.assertRaises((AttributeError, RuntimeError), cPickle.dumps, n)
def test_issue3179(self):
# Safe test, because I broke this case when fixing the
# behaviour for the previous test.
res=[]
for x in range(1,2000):
res.append(dict(doc=x, similar=[]))
cPickle.dumps(res)
def test_main():
test_support.run_unittest(
cPickleTests,
cStringIOCPicklerTests,
BytesIOCPicklerTests,
FileIOCPicklerTests,
cStringIOCPicklerListTests,
BytesIOCPicklerListTests,
FileIOCPicklerListTests,
cStringIOCPicklerFastTests,
BytesIOCPicklerFastTests,
FileIOCPicklerFastTests,
cPickleDeepRecursive,
cPicklePicklerUnpicklerObjectTests,
cPickleBigmemPickleTests,
)
if __name__ == "__main__":
test_main()
|
gpl-2.0
|
[
646,
17572,
202,
199,
646,
15073,
202,
199,
646,
5890,
202,
199,
646,
2882,
202,
199,
504,
511,
14,
8092,
8234,
492,
334,
8458,
12755,
2925,
12,
202,
3044,
11836,
12755,
2377,
2925,
12,
202,
3044,
11836,
8587,
1435,
1358,
23468,
1692,
2925,
12,
202,
3044,
13123,
5286,
12755,
2925,
9,
202,
199,
504,
511,
492,
511,
63,
4058,
2999,
199,
533,
15073,
4256,
26,
1128,
1072,
275,
1324,
275,
15073,
14,
6424,
2958,
347,
4002,
8,
277,
12,
289,
304,
1039,
986,
2999,
199,
533,
11808,
4256,
26,
1128,
1072,
275,
1324,
275,
5890,
14,
15466,
2958,
347,
4002,
8,
277,
12,
289,
304,
1039,
986,
2999,
199,
533,
3814,
2090,
4256,
26,
2958,
347,
1072,
8,
277,
304,
1039,
372,
1551,
8,
396,
63,
4058,
14,
10179,
12,
283,
6603,
13854,
2958,
347,
1324,
8,
277,
12,
666,
304,
1039,
289,
275,
1551,
8,
396,
63,
4058,
14,
10179,
12,
283,
6603,
13854,
1039,
862,
26,
1675,
289,
14,
952,
8,
576,
9,
1675,
289,
14,
5507,
8,
16,
9,
1675,
372,
289,
1039,
871,
26,
1675,
289,
14,
1600,
342,
1675,
746,
2958,
347,
4002,
8,
277,
12,
289,
304,
1039,
289,
14,
1600,
342,
1039,
511,
63,
4058,
14,
7162,
8,
396,
63,
4058,
14,
10179,
9,
8065,
199,
533,
17572,
2925,
8,
8458,
12755,
2925,
12,
11836,
12755,
2377,
2925,
304,
2958,
347,
3613,
8,
277,
304,
1039,
291,
14,
4180,
275,
17572,
14,
4180,
1039,
291,
14,
3640,
275,
17572,
14,
3640,
2958,
1125,
275,
17572,
14,
5725,
12755,
1002,
1128,
859,
275,
17572,
2999,
199,
533,
17572,
8587,
1435,
2925,
8,
8458,
12755,
2925,
304,
2958,
347,
16864,
8,
277,
12,
1680,
12,
4104,
29,
16,
304,
1039,
289,
275,
291,
14,
1199,
342,
1039,
862,
26,
1675,
299,
275,
17572,
14,
8587,
1435,
8,
70,
12,
4104,
9,
1675,
299,
14,
2724,
8,
1273,
9,
1675,
289,
14,
5507,
8,
16,
9,
1675,
372,
289,
14,
739,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
347,
14404,
8,
277,
12,
4123,
304,
1039,
289,
275,
291,
14,
1210,
8,
1436,
9,
1039,
862,
26,
1675,
299,
275,
17572,
14,
1358,
23468,
8,
70,
9,
1675,
372,
299,
14,
912,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
1125,
275,
17572,
14,
5725,
12755,
1002,
2999,
199,
533,
15073,
2890,
2000,
1435,
2925,
8,
67,
6424,
4256,
12,
17572,
8587,
1435,
2925,
304,
1128,
986,
2999,
199,
533,
11808,
2890,
2000,
1435,
2925,
8,
15466,
4256,
12,
17572,
8587,
1435,
2925,
304,
1128,
986,
2999,
199,
533,
3814,
2090,
2890,
2000,
1435,
2925,
8,
26126,
4256,
12,
17572,
8587,
1435,
2925,
304,
1128,
986,
8065,
199,
533,
17572,
1296,
8587,
1435,
2925,
8,
8458,
12755,
2925,
304,
2958,
347,
16864,
8,
277,
12,
1680,
12,
4104,
29,
16,
304,
1039,
299,
275,
17572,
14,
8587,
1435,
8,
2625,
9,
1039,
299,
14,
2724,
8,
1273,
9,
1039,
372,
299,
14,
7150,
342,
2958,
347,
14404,
8,
277,
12,
627,
589,
304,
1039,
289,
275,
291,
14,
1210,
8,
589,
59,
16,
566,
1039,
862,
26,
1675,
299,
275,
17572,
14,
1358,
23468,
8,
70,
9,
1675,
372,
299,
14,
912,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
1125,
275,
17572,
14,
5725,
12755,
1002,
2999,
199,
533,
15073,
2890,
2000,
1435,
1296,
2925,
8,
67,
6424,
4256,
12,
17572,
1296,
8587,
1435,
2925,
304,
1128,
986,
2999,
199,
533,
11808,
2890,
2000,
1435,
1296,
2925,
8,
15466,
4256,
12,
17572,
1296,
8587,
1435,
2925,
304,
1128,
986,
2999,
199,
533,
3814,
2090,
2890,
2000,
1435,
1296,
2925,
8,
26126,
4256,
12,
17572,
1296,
8587,
1435,
2925,
304,
1128,
986,
8065,
199,
533,
17572,
16976,
8587,
1435,
2925,
8,
8458,
12755,
2925,
304,
2958,
347,
16864,
8,
277,
12,
1680,
12,
4104,
29,
16,
304,
1039,
289,
275,
291,
14,
1199,
342,
1039,
862,
26,
1675,
299,
275,
17572,
14,
8587,
1435,
8,
70,
12,
4104,
9,
1675,
299,
14,
7015,
275,
413,
1675,
299,
14,
2724,
8,
1273,
9,
1675,
289,
14,
5507,
8,
16,
9,
1675,
372,
289,
14,
739,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
347,
14404,
8,
277,
12,
627,
589,
304,
1039,
289,
275,
291,
14,
1210,
8,
589,
59,
16,
566,
1039,
862,
26,
1675,
299,
275,
17572,
14,
1358,
23468,
8,
70,
9,
1675,
372,
299,
14,
912,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
1125,
275,
17572,
14,
5725,
12755,
1002,
2958,
347,
511,
63,
9931,
63,
513,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
513,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
9931,
63,
2960,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
2960,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
9931,
63,
3615,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
3615,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
9931,
63,
807,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
807,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
9931,
63,
3029,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
3029,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
2865,
9931,
63,
16131,
8,
277,
304,
1039,
327,
982,
652,
1159,
440,
32637,
12,
652,
1077,
5927,
9949,
2755,
340,
314,
19500,
1039,
327,
5818,
22338,
7843,
63,
2890,
13884,
906,
63,
24661,
63,
13387,
14,
221,
10314,
10986,
370,
506,
1039,
327,
5238,
11168,
14,
221,
1603,
564,
17474,
2464,
14581,
3464,
15784,
641,
10444,
4403,
1749,
1039,
327,
737,
5049,
14,
1039,
282,
275,
942,
1039,
367,
284,
315,
1425,
8,
2259,
304,
1675,
282,
275,
359,
65,
61,
1039,
330,
275,
291,
14,
3640,
8,
277,
14,
4180,
8,
65,
430,
1039
] |
[
17572,
202,
199,
646,
15073,
202,
199,
646,
5890,
202,
199,
646,
2882,
202,
199,
504,
511,
14,
8092,
8234,
492,
334,
8458,
12755,
2925,
12,
202,
3044,
11836,
12755,
2377,
2925,
12,
202,
3044,
11836,
8587,
1435,
1358,
23468,
1692,
2925,
12,
202,
3044,
13123,
5286,
12755,
2925,
9,
202,
199,
504,
511,
492,
511,
63,
4058,
2999,
199,
533,
15073,
4256,
26,
1128,
1072,
275,
1324,
275,
15073,
14,
6424,
2958,
347,
4002,
8,
277,
12,
289,
304,
1039,
986,
2999,
199,
533,
11808,
4256,
26,
1128,
1072,
275,
1324,
275,
5890,
14,
15466,
2958,
347,
4002,
8,
277,
12,
289,
304,
1039,
986,
2999,
199,
533,
3814,
2090,
4256,
26,
2958,
347,
1072,
8,
277,
304,
1039,
372,
1551,
8,
396,
63,
4058,
14,
10179,
12,
283,
6603,
13854,
2958,
347,
1324,
8,
277,
12,
666,
304,
1039,
289,
275,
1551,
8,
396,
63,
4058,
14,
10179,
12,
283,
6603,
13854,
1039,
862,
26,
1675,
289,
14,
952,
8,
576,
9,
1675,
289,
14,
5507,
8,
16,
9,
1675,
372,
289,
1039,
871,
26,
1675,
289,
14,
1600,
342,
1675,
746,
2958,
347,
4002,
8,
277,
12,
289,
304,
1039,
289,
14,
1600,
342,
1039,
511,
63,
4058,
14,
7162,
8,
396,
63,
4058,
14,
10179,
9,
8065,
199,
533,
17572,
2925,
8,
8458,
12755,
2925,
12,
11836,
12755,
2377,
2925,
304,
2958,
347,
3613,
8,
277,
304,
1039,
291,
14,
4180,
275,
17572,
14,
4180,
1039,
291,
14,
3640,
275,
17572,
14,
3640,
2958,
1125,
275,
17572,
14,
5725,
12755,
1002,
1128,
859,
275,
17572,
2999,
199,
533,
17572,
8587,
1435,
2925,
8,
8458,
12755,
2925,
304,
2958,
347,
16864,
8,
277,
12,
1680,
12,
4104,
29,
16,
304,
1039,
289,
275,
291,
14,
1199,
342,
1039,
862,
26,
1675,
299,
275,
17572,
14,
8587,
1435,
8,
70,
12,
4104,
9,
1675,
299,
14,
2724,
8,
1273,
9,
1675,
289,
14,
5507,
8,
16,
9,
1675,
372,
289,
14,
739,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
347,
14404,
8,
277,
12,
4123,
304,
1039,
289,
275,
291,
14,
1210,
8,
1436,
9,
1039,
862,
26,
1675,
299,
275,
17572,
14,
1358,
23468,
8,
70,
9,
1675,
372,
299,
14,
912,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
1125,
275,
17572,
14,
5725,
12755,
1002,
2999,
199,
533,
15073,
2890,
2000,
1435,
2925,
8,
67,
6424,
4256,
12,
17572,
8587,
1435,
2925,
304,
1128,
986,
2999,
199,
533,
11808,
2890,
2000,
1435,
2925,
8,
15466,
4256,
12,
17572,
8587,
1435,
2925,
304,
1128,
986,
2999,
199,
533,
3814,
2090,
2890,
2000,
1435,
2925,
8,
26126,
4256,
12,
17572,
8587,
1435,
2925,
304,
1128,
986,
8065,
199,
533,
17572,
1296,
8587,
1435,
2925,
8,
8458,
12755,
2925,
304,
2958,
347,
16864,
8,
277,
12,
1680,
12,
4104,
29,
16,
304,
1039,
299,
275,
17572,
14,
8587,
1435,
8,
2625,
9,
1039,
299,
14,
2724,
8,
1273,
9,
1039,
372,
299,
14,
7150,
342,
2958,
347,
14404,
8,
277,
12,
627,
589,
304,
1039,
289,
275,
291,
14,
1210,
8,
589,
59,
16,
566,
1039,
862,
26,
1675,
299,
275,
17572,
14,
1358,
23468,
8,
70,
9,
1675,
372,
299,
14,
912,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
1125,
275,
17572,
14,
5725,
12755,
1002,
2999,
199,
533,
15073,
2890,
2000,
1435,
1296,
2925,
8,
67,
6424,
4256,
12,
17572,
1296,
8587,
1435,
2925,
304,
1128,
986,
2999,
199,
533,
11808,
2890,
2000,
1435,
1296,
2925,
8,
15466,
4256,
12,
17572,
1296,
8587,
1435,
2925,
304,
1128,
986,
2999,
199,
533,
3814,
2090,
2890,
2000,
1435,
1296,
2925,
8,
26126,
4256,
12,
17572,
1296,
8587,
1435,
2925,
304,
1128,
986,
8065,
199,
533,
17572,
16976,
8587,
1435,
2925,
8,
8458,
12755,
2925,
304,
2958,
347,
16864,
8,
277,
12,
1680,
12,
4104,
29,
16,
304,
1039,
289,
275,
291,
14,
1199,
342,
1039,
862,
26,
1675,
299,
275,
17572,
14,
8587,
1435,
8,
70,
12,
4104,
9,
1675,
299,
14,
7015,
275,
413,
1675,
299,
14,
2724,
8,
1273,
9,
1675,
289,
14,
5507,
8,
16,
9,
1675,
372,
289,
14,
739,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
347,
14404,
8,
277,
12,
627,
589,
304,
1039,
289,
275,
291,
14,
1210,
8,
589,
59,
16,
566,
1039,
862,
26,
1675,
299,
275,
17572,
14,
1358,
23468,
8,
70,
9,
1675,
372,
299,
14,
912,
342,
1039,
3753,
26,
1675,
291,
14,
1600,
8,
70,
9,
2958,
1125,
275,
17572,
14,
5725,
12755,
1002,
2958,
347,
511,
63,
9931,
63,
513,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
513,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
9931,
63,
2960,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
2960,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
9931,
63,
3615,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
3615,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
9931,
63,
807,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
807,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
9931,
63,
3029,
8,
277,
304,
1039,
291,
14,
1855,
8,
3393,
12,
202,
2079,
11836,
12755,
2925,
14,
396,
63,
9931,
63,
3029,
12,
202,
2079,
291,
9,
2958,
347,
511,
63,
2865,
9931,
63,
16131,
8,
277,
304,
1039,
327,
982,
652,
1159,
440,
32637,
12,
652,
1077,
5927,
9949,
2755,
340,
314,
19500,
1039,
327,
5818,
22338,
7843,
63,
2890,
13884,
906,
63,
24661,
63,
13387,
14,
221,
10314,
10986,
370,
506,
1039,
327,
5238,
11168,
14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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
] |
pmorie/origin
|
hack/build-local-images.py
|
2
|
7987
|
#!/usr/bin/env python
import sys
from shutil import copy, rmtree
import distutils.dir_util as dir_util
from subprocess import call
from tempfile import mkdtemp
from atexit import register
from os import getenv, mkdir, remove
from os.path import abspath, dirname, isdir, join
if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--h', '-help', '--help']:
print """Quickly re-build images depending on OpenShift Origin build artifacts.
This script re-builds OpenShift Origin images quickly. It is intended
to be used by developers for quick, iterative development of images
that depend on binaries, RPMs, or other artifacts that the Origin build
process generates. The script works by creating a temporary context
directory for a Docker build, adding a simple Dockerfile FROM the image
you wish to rebuild, ADDing in static files to overwrite, and building.
The script supports ADDing binaries from origin/_output/local/bin/linux/amd64/
and ADDing static files from the original context directories under the
origin/images/ directories.
Usage:
[OS_DEBUG=true] [OS_IMAGE_PREFIX=prefix] build-local-images.py [IMAGE...]
Specific images can be specified to be built with either the full name
of the image (e.g. openshift3/ose-haproxy-router) or the name sans prefix
(e.g. haproxy-router).
The following environment veriables are honored by this script:
- $OS_IMAGE_PREFIX: one of [openshift/origin, openshift3/ose]
- $OS_DEBUG: if set, debugging information will be printed
Examples:
# build all images
build-local-images.py
# build only the f5-router image
build-local-images.py f5-router
# build with a different image prefix
OS_IMAGE_PREFIX=openshift3/ose build-local-images.sh
Options:
-h,--h, -help,--help: show this help-text
"""
exit(2)
os_image_prefix = getenv("OS_IMAGE_PREFIX", "openshift/origin")
image_namespace, image_prefix = os_image_prefix.split("/", 2)
image_config = {
image_prefix: {
"directory": "origin",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {}
},
"deployer": {
"directory": "deployer",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {}
},
"recycler": {
"directory": "recycler",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {}
},
"docker-builder": {
"directory": "builder/docker/docker-builder",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {}
},
"sti-builder": {
"directory": "builder/docker/sti-builder",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {}
},
"f5-router": {
"directory": "router/f5",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {}
},
"nginx-router": {
"directory": "router/nginx",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {
".": "/var/lib/nginx"
}
},
"haproxy-router": {
"directory": "router/haproxy",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {
".": "/var/lib/haproxy"
}
},
"keepalived-ipfailover": {
"directory": "ipfailover/keepalived",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {
".": "/var/lib/ipfailover/keepalived"
}
},
"node": {
"directory": "node",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {}
},
"openvswitch": {
"directory": "openvswitch",
"binaries": {
"openshift": "/usr/bin/openshift"
},
"files": {}
},
"service-catalog": {
"directory": "service-catalog",
"vendor_dir": "cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog",
"binaries": {
"controller-manager": "/usr/bin/controller-manager",
"apiserver": "/usr/bin/apiserver",
},
"files": {},
"enable_default": False,
},
}
def image_rebuild_requested(image):
"""
An image rebuild is requested if the
user provides the image name or image
suffix explicitly or does not provide
any explicit requests.
"""
implicitly_triggered = len(sys.argv) == 1 and image_config[image].get("enable_default", True)
explicitly_triggered = len(sys.argv) > 1 and (image in sys.argv or full_name(image) in sys.argv)
return implicitly_triggered or explicitly_triggered
def full_name(image):
"""
The full name of the image will contain
the image namespace as well as the pre-
fix, if applicable.
"""
if image in ["node", "openvswitch", image_prefix]:
return "{}/{}".format(image_namespace, image)
return "{}/{}-{}".format(image_namespace, image_prefix, image)
def add_to_context(context_dir, source, destination, container_destination):
"""
Add a file to the context directory
and add an entry to the Dockerfile
to place it in the container file-
sytem at the correct destination.
"""
debug("Adding file:\n\tfrom {}\n\tto {}\n\tincluding in container at {}".format(
source,
join(context_dir, destination),
container_destination)
)
absolute_destination = abspath(join(context_dir, destination))
if isdir(source):
dir_util.copy_tree(source, absolute_destination)
else:
copy(source, absolute_destination)
with open(join(context_dir, "Dockerfile"), "a") as dockerfile:
dockerfile.write("ADD {} {}\n".format(destination, container_destination))
def debug(message):
if getenv("OS_DEBUG"):
print "[DEBUG] {}".format(message)
os_root = abspath(join(dirname(__file__), ".."))
os_image_path = join(os_root, "images")
context_dir = mkdtemp()
register(rmtree, context_dir)
debug("Created temporary context dir at {}".format(context_dir))
mkdir(join(context_dir, "bin"))
mkdir(join(context_dir, "src"))
build_occurred = False
for image in image_config:
if not image_rebuild_requested(image):
continue
build_occurred = True
print "[INFO] Building {}...".format(image)
with open(join(context_dir, "Dockerfile"), "w+") as dockerfile:
dockerfile.write("FROM {}\n".format(full_name(image)))
binary_dir_args = ["_output", "local", "bin", "linux", "amd64"]
config = image_config[image]
for binary in config.get("binaries", []):
if "vendor_dir" in config:
os_bin_path = join(os_root, config.get("vendor_dir"), *binary_dir_args)
else:
os_bin_path = join(os_root, *binary_dir_args)
add_to_context(
context_dir,
source=join(os_bin_path, binary),
destination=join("bin", binary),
container_destination=config["binaries"][binary]
)
mkdir(join(context_dir, "src", image))
for file in config.get("files", []):
add_to_context(
context_dir,
source=join(os_image_path, config["directory"], file),
destination=join("src", image, file),
container_destination=config["files"][file]
)
debug("Initiating Docker build with Dockerfile:\n{}".format(open(join(context_dir, "Dockerfile")).read()))
call(["docker", "build", "-t", full_name(image), "."], cwd=context_dir)
remove(join(context_dir, "Dockerfile"))
rmtree(join(context_dir, "src", image))
if not build_occurred and len(sys.argv) > 1:
print "[ERROR] The provided image names ({}) did not match any buildable images.".format(
", ".join(sys.argv[1:])
)
print "[ERROR] This script knows how to build:\n\t{}".format(
"\n\t".join(map(full_name, image_config.keys()))
)
exit(1)
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
984,
199,
504,
5145,
492,
1331,
12,
20978,
199,
646,
7065,
14,
694,
63,
1974,
465,
2935,
63,
1974,
199,
504,
3873,
492,
1240,
199,
504,
5549,
492,
31781,
199,
199,
504,
19840,
492,
2274,
199,
504,
747,
492,
29626,
12,
20366,
12,
2813,
199,
504,
747,
14,
515,
492,
19529,
12,
9017,
12,
26004,
12,
4263,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
690,
413,
436,
984,
14,
3020,
59,
17,
61,
315,
11573,
72,
297,
2850,
72,
297,
2475,
3437,
297,
2850,
3437,
2565,
272,
870,
408,
19684,
590,
295,
13,
1506,
5935,
10298,
641,
3232,
14379,
31534,
1900,
27990,
14,
199,
199,
2765,
2884,
295,
13,
10838,
3232,
14379,
31534,
5935,
23661,
14,
2779,
365,
11619,
199,
475,
506,
1202,
701,
19782,
367,
12530,
12,
4826,
857,
16367,
402,
5935,
199,
9099,
11687,
641,
21984,
12,
820,
10793,
83,
12,
503,
1163,
27990,
626,
314,
31534,
1900,
199,
1412,
12821,
14,
710,
2884,
5419,
701,
6425,
282,
7937,
1067,
199,
3619,
367,
282,
22067,
1900,
12,
7791,
282,
3486,
22067,
493,
4442,
314,
1834,
199,
13297,
13809,
370,
22110,
12,
21380,
316,
315,
2955,
1584,
370,
8970,
12,
436,
10015,
14,
199,
199,
1918,
2884,
5171,
21380,
316,
21984,
687,
6330,
15607,
1199,
15,
1832,
15,
1393,
15,
5135,
15,
21778,
772,
15,
199,
460,
21380,
316,
2955,
1584,
687,
314,
3379,
1067,
6602,
1334,
314,
199,
6493,
15,
4782,
15,
6602,
14,
199,
199,
7692,
26,
523,
359,
3100,
63,
5287,
29,
2052,
61,
359,
3100,
63,
9438,
63,
6351,
29,
1861,
61,
1900,
13,
1832,
13,
4782,
14,
647,
359,
9438,
18737,
819,
20411,
5935,
883,
506,
2013,
370,
506,
6137,
543,
1902,
314,
2615,
536,
523,
402,
314,
1834,
334,
69,
14,
71,
14,
1551,
4723,
19,
15,
3362,
13,
72,
30204,
1702,
13,
4995,
9,
503,
314,
536,
308,
796,
2403,
523,
334,
69,
14,
71,
14,
394,
30204,
1702,
13,
4995,
680,
819,
710,
2569,
3734,
809,
73,
5921,
787,
394,
265,
2908,
701,
642,
2884,
26,
2043,
446,
2672,
3100,
63,
9438,
63,
6351,
26,
1373,
402,
359,
22858,
15,
6493,
12,
1551,
4723,
19,
15,
3362,
61,
2043,
446,
2672,
3100,
63,
5287,
26,
340,
663,
12,
10201,
2556,
911,
506,
12487,
199,
199,
22787,
26,
523,
327,
1900,
1006,
5935,
523,
1900,
13,
1832,
13,
4782,
14,
647,
819,
327,
1900,
1454,
314,
289,
21,
13,
4995,
1834,
523,
1900,
13,
1832,
13,
4782,
14,
647,
289,
21,
13,
4995,
819,
327,
1900,
543,
282,
3365,
1834,
2403,
523,
4403,
63,
9438,
63,
6351,
29,
22858,
19,
15,
3362,
1900,
13,
1832,
13,
4782,
14,
609,
199,
199,
4558,
26,
523,
446,
72,
28925,
72,
12,
446,
3437,
28925,
3437,
26,
2498,
642,
1720,
13,
505,
199,
624,
272,
4458,
8,
18,
9,
199,
199,
736,
63,
1569,
63,
1861,
275,
29626,
480,
3100,
63,
9438,
63,
6351,
401,
298,
22858,
15,
6493,
531,
199,
1569,
63,
3251,
12,
1834,
63,
1861,
275,
747,
63,
1569,
63,
1861,
14,
1294,
27374,
499,
9,
199,
199,
1569,
63,
888,
275,
469,
272,
1834,
63,
1861,
26,
469,
267,
298,
3619,
582,
298,
6493,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
11060,
281,
582,
469,
267,
298,
3619,
582,
298,
11060,
281,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
264,
1480,
32046,
582,
469,
267,
298,
3619,
582,
298,
264,
1480,
32046,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
9991,
13,
5649,
582,
469,
267,
298,
3619,
582,
298,
5649,
15,
9991,
15,
9991,
13,
5649,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
270,
73,
13,
5649,
582,
469,
267,
298,
3619,
582,
298,
5649,
15,
9991,
15,
270,
73,
13,
5649,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
70,
21,
13,
4995,
582,
469,
267,
298,
3619,
582,
298,
4995,
15,
70,
21,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
25826,
13,
4995,
582,
469,
267,
298,
3619,
582,
298,
4995,
15,
25826,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
469,
288,
3680,
582,
3286,
1391,
15,
773,
15,
25826,
2,
267,
789,
272,
1660,
272,
298,
72,
30204,
1702,
13,
4995,
582,
469,
267,
298,
3619,
582,
298,
4995,
15,
72,
30204,
1702,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
469,
288,
3680,
582,
3286,
1391,
15,
773,
15,
72,
30204,
1702,
2,
267,
789,
272,
1660,
272,
298,
3250,
279,
12905,
13,
711,
667,
23165,
582,
469,
267,
298,
3619,
582,
298,
711,
667,
23165,
15,
3250,
279,
12905,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
469,
288,
3680,
582,
3286,
1391,
15,
773,
15,
711,
667,
23165,
15,
3250,
279,
12905,
2,
267,
789,
272,
1660,
272,
298,
932,
582,
469,
267,
298,
3619,
582,
298,
932,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
1490,
23201,
582,
469,
267,
298,
3619,
582,
298,
1490,
23201,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
199,
646,
984,
199,
504,
5145,
492,
1331,
12,
20978,
199,
646,
7065,
14,
694,
63,
1974,
465,
2935,
63,
1974,
199,
504,
3873,
492,
1240,
199,
504,
5549,
492,
31781,
199,
199,
504,
19840,
492,
2274,
199,
504,
747,
492,
29626,
12,
20366,
12,
2813,
199,
504,
747,
14,
515,
492,
19529,
12,
9017,
12,
26004,
12,
4263,
199,
199,
692,
822,
8,
1274,
14,
3020,
9,
690,
413,
436,
984,
14,
3020,
59,
17,
61,
315,
11573,
72,
297,
2850,
72,
297,
2475,
3437,
297,
2850,
3437,
2565,
272,
870,
408,
19684,
590,
295,
13,
1506,
5935,
10298,
641,
3232,
14379,
31534,
1900,
27990,
14,
199,
199,
2765,
2884,
295,
13,
10838,
3232,
14379,
31534,
5935,
23661,
14,
2779,
365,
11619,
199,
475,
506,
1202,
701,
19782,
367,
12530,
12,
4826,
857,
16367,
402,
5935,
199,
9099,
11687,
641,
21984,
12,
820,
10793,
83,
12,
503,
1163,
27990,
626,
314,
31534,
1900,
199,
1412,
12821,
14,
710,
2884,
5419,
701,
6425,
282,
7937,
1067,
199,
3619,
367,
282,
22067,
1900,
12,
7791,
282,
3486,
22067,
493,
4442,
314,
1834,
199,
13297,
13809,
370,
22110,
12,
21380,
316,
315,
2955,
1584,
370,
8970,
12,
436,
10015,
14,
199,
199,
1918,
2884,
5171,
21380,
316,
21984,
687,
6330,
15607,
1199,
15,
1832,
15,
1393,
15,
5135,
15,
21778,
772,
15,
199,
460,
21380,
316,
2955,
1584,
687,
314,
3379,
1067,
6602,
1334,
314,
199,
6493,
15,
4782,
15,
6602,
14,
199,
199,
7692,
26,
523,
359,
3100,
63,
5287,
29,
2052,
61,
359,
3100,
63,
9438,
63,
6351,
29,
1861,
61,
1900,
13,
1832,
13,
4782,
14,
647,
359,
9438,
18737,
819,
20411,
5935,
883,
506,
2013,
370,
506,
6137,
543,
1902,
314,
2615,
536,
523,
402,
314,
1834,
334,
69,
14,
71,
14,
1551,
4723,
19,
15,
3362,
13,
72,
30204,
1702,
13,
4995,
9,
503,
314,
536,
308,
796,
2403,
523,
334,
69,
14,
71,
14,
394,
30204,
1702,
13,
4995,
680,
819,
710,
2569,
3734,
809,
73,
5921,
787,
394,
265,
2908,
701,
642,
2884,
26,
2043,
446,
2672,
3100,
63,
9438,
63,
6351,
26,
1373,
402,
359,
22858,
15,
6493,
12,
1551,
4723,
19,
15,
3362,
61,
2043,
446,
2672,
3100,
63,
5287,
26,
340,
663,
12,
10201,
2556,
911,
506,
12487,
199,
199,
22787,
26,
523,
327,
1900,
1006,
5935,
523,
1900,
13,
1832,
13,
4782,
14,
647,
819,
327,
1900,
1454,
314,
289,
21,
13,
4995,
1834,
523,
1900,
13,
1832,
13,
4782,
14,
647,
289,
21,
13,
4995,
819,
327,
1900,
543,
282,
3365,
1834,
2403,
523,
4403,
63,
9438,
63,
6351,
29,
22858,
19,
15,
3362,
1900,
13,
1832,
13,
4782,
14,
609,
199,
199,
4558,
26,
523,
446,
72,
28925,
72,
12,
446,
3437,
28925,
3437,
26,
2498,
642,
1720,
13,
505,
199,
624,
272,
4458,
8,
18,
9,
199,
199,
736,
63,
1569,
63,
1861,
275,
29626,
480,
3100,
63,
9438,
63,
6351,
401,
298,
22858,
15,
6493,
531,
199,
1569,
63,
3251,
12,
1834,
63,
1861,
275,
747,
63,
1569,
63,
1861,
14,
1294,
27374,
499,
9,
199,
199,
1569,
63,
888,
275,
469,
272,
1834,
63,
1861,
26,
469,
267,
298,
3619,
582,
298,
6493,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
11060,
281,
582,
469,
267,
298,
3619,
582,
298,
11060,
281,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
264,
1480,
32046,
582,
469,
267,
298,
3619,
582,
298,
264,
1480,
32046,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
9991,
13,
5649,
582,
469,
267,
298,
3619,
582,
298,
5649,
15,
9991,
15,
9991,
13,
5649,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
270,
73,
13,
5649,
582,
469,
267,
298,
3619,
582,
298,
5649,
15,
9991,
15,
270,
73,
13,
5649,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
70,
21,
13,
4995,
582,
469,
267,
298,
3619,
582,
298,
4995,
15,
70,
21,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
25826,
13,
4995,
582,
469,
267,
298,
3619,
582,
298,
4995,
15,
25826,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
469,
288,
3680,
582,
3286,
1391,
15,
773,
15,
25826,
2,
267,
789,
272,
1660,
272,
298,
72,
30204,
1702,
13,
4995,
582,
469,
267,
298,
3619,
582,
298,
4995,
15,
72,
30204,
1702,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
469,
288,
3680,
582,
3286,
1391,
15,
773,
15,
72,
30204,
1702,
2,
267,
789,
272,
1660,
272,
298,
3250,
279,
12905,
13,
711,
667,
23165,
582,
469,
267,
298,
3619,
582,
298,
711,
667,
23165,
15,
3250,
279,
12905,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
469,
288,
3680,
582,
3286,
1391,
15,
773,
15,
711,
667,
23165,
15,
3250,
279,
12905,
2,
267,
789,
272,
1660,
272,
298,
932,
582,
469,
267,
298,
3619,
582,
298,
932,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
267,
298,
1725,
582,
1052,
272,
1660,
272,
298,
1490,
23201,
582,
469,
267,
298,
3619,
582,
298,
1490,
23201,
401,
267,
298,
27542,
582,
469,
288,
298,
22858,
582,
3286,
2647,
15,
1393,
15,
22858,
2,
267,
1660,
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,
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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
] |
takuya1981/sms-tools
|
software/models_interface/hpsModel_GUI_frame.py
|
21
|
8161
|
# GUI frame for the hprModel_function.py
from Tkinter import *
import tkFileDialog, tkMessageBox
import sys, os
from scipy.io.wavfile import read
import hpsModel_function
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../models/'))
import utilFunctions as UF
class HpsModel_frame:
def __init__(self, parent):
self.parent = parent
self.initUI()
def initUI(self):
choose_label = "Input file (.wav, mono and 44100 sampling rate):"
Label(self.parent, text=choose_label).grid(row=0, column=0, sticky=W, padx=5, pady=(10,2))
#TEXTBOX TO PRINT PATH OF THE SOUND FILE
self.filelocation = Entry(self.parent)
self.filelocation.focus_set()
self.filelocation["width"] = 25
self.filelocation.grid(row=1,column=0, sticky=W, padx=10)
self.filelocation.delete(0, END)
self.filelocation.insert(0, '../../sounds/sax-phrase-short.wav')
#BUTTON TO BROWSE SOUND FILE
self.open_file = Button(self.parent, text="Browse...", command=self.browse_file) #see: def browse_file(self)
self.open_file.grid(row=1, column=0, sticky=W, padx=(220, 6)) #put it beside the filelocation textbox
#BUTTON TO PREVIEW SOUND FILE
self.preview = Button(self.parent, text=">", command=lambda:UF.wavplay(self.filelocation.get()), bg="gray30", fg="white")
self.preview.grid(row=1, column=0, sticky=W, padx=(306,6))
## HARMONIC MODEL
#ANALYSIS WINDOW TYPE
wtype_label = "Window type:"
Label(self.parent, text=wtype_label).grid(row=2, column=0, sticky=W, padx=5, pady=(10,2))
self.w_type = StringVar()
self.w_type.set("blackman") # initial value
window_option = OptionMenu(self.parent, self.w_type, "rectangular", "hanning", "hamming", "blackman", "blackmanharris")
window_option.grid(row=2, column=0, sticky=W, padx=(95,5), pady=(10,2))
#WINDOW SIZE
M_label = "Window size (M):"
Label(self.parent, text=M_label).grid(row=4, column=0, sticky=W, padx=5, pady=(10,2))
self.M = Entry(self.parent, justify=CENTER)
self.M["width"] = 5
self.M.grid(row=4,column=0, sticky=W, padx=(115,5), pady=(10,2))
self.M.delete(0, END)
self.M.insert(0, "601")
#FFT SIZE
N_label = "FFT size (N) (power of two bigger than M):"
Label(self.parent, text=N_label).grid(row=5, column=0, sticky=W, padx=5, pady=(10,2))
self.N = Entry(self.parent, justify=CENTER)
self.N["width"] = 5
self.N.grid(row=5,column=0, sticky=W, padx=(270,5), pady=(10,2))
self.N.delete(0, END)
self.N.insert(0, "1024")
#THRESHOLD MAGNITUDE
t_label = "Magnitude threshold (t) (in dB):"
Label(self.parent, text=t_label).grid(row=6, column=0, sticky=W, padx=5, pady=(10,2))
self.t = Entry(self.parent, justify=CENTER)
self.t["width"] = 5
self.t.grid(row=6, column=0, sticky=W, padx=(205,5), pady=(10,2))
self.t.delete(0, END)
self.t.insert(0, "-100")
#MIN DURATION SINUSOIDAL TRACKS
minSineDur_label = "Minimum duration of sinusoidal tracks:"
Label(self.parent, text=minSineDur_label).grid(row=7, column=0, sticky=W, padx=5, pady=(10,2))
self.minSineDur = Entry(self.parent, justify=CENTER)
self.minSineDur["width"] = 5
self.minSineDur.grid(row=7, column=0, sticky=W, padx=(250,5), pady=(10,2))
self.minSineDur.delete(0, END)
self.minSineDur.insert(0, "0.1")
#MAX NUMBER OF HARMONICS
nH_label = "Maximum number of harmonics:"
Label(self.parent, text=nH_label).grid(row=8, column=0, sticky=W, padx=5, pady=(10,2))
self.nH = Entry(self.parent, justify=CENTER)
self.nH["width"] = 5
self.nH.grid(row=8, column=0, sticky=W, padx=(215,5), pady=(10,2))
self.nH.delete(0, END)
self.nH.insert(0, "100")
#MIN FUNDAMENTAL FREQUENCY
minf0_label = "Minimum fundamental frequency:"
Label(self.parent, text=minf0_label).grid(row=9, column=0, sticky=W, padx=5, pady=(10,2))
self.minf0 = Entry(self.parent, justify=CENTER)
self.minf0["width"] = 5
self.minf0.grid(row=9, column=0, sticky=W, padx=(220,5), pady=(10,2))
self.minf0.delete(0, END)
self.minf0.insert(0, "350")
#MAX FUNDAMENTAL FREQUENCY
maxf0_label = "Maximum fundamental frequency:"
Label(self.parent, text=maxf0_label).grid(row=10, column=0, sticky=W, padx=5, pady=(10,2))
self.maxf0 = Entry(self.parent, justify=CENTER)
self.maxf0["width"] = 5
self.maxf0.grid(row=10, column=0, sticky=W, padx=(220,5), pady=(10,2))
self.maxf0.delete(0, END)
self.maxf0.insert(0, "700")
#MAX ERROR ACCEPTED
f0et_label = "Maximum error in f0 detection algorithm:"
Label(self.parent, text=f0et_label).grid(row=11, column=0, sticky=W, padx=5, pady=(10,2))
self.f0et = Entry(self.parent, justify=CENTER)
self.f0et["width"] = 5
self.f0et.grid(row=11, column=0, sticky=W, padx=(265,5), pady=(10,2))
self.f0et.delete(0, END)
self.f0et.insert(0, "5")
#ALLOWED DEVIATION OF HARMONIC TRACKS
harmDevSlope_label = "Max frequency deviation in harmonic tracks:"
Label(self.parent, text=harmDevSlope_label).grid(row=12, column=0, sticky=W, padx=5, pady=(10,2))
self.harmDevSlope = Entry(self.parent, justify=CENTER)
self.harmDevSlope["width"] = 5
self.harmDevSlope.grid(row=12, column=0, sticky=W, padx=(285,5), pady=(10,2))
self.harmDevSlope.delete(0, END)
self.harmDevSlope.insert(0, "0.01")
#DECIMATION FACTOR
stocf_label = "Stochastic approximation factor:"
Label(self.parent, text=stocf_label).grid(row=13, column=0, sticky=W, padx=5, pady=(10,2))
self.stocf = Entry(self.parent, justify=CENTER)
self.stocf["width"] = 5
self.stocf.grid(row=13, column=0, sticky=W, padx=(210,5), pady=(10,2))
self.stocf.delete(0, END)
self.stocf.insert(0, "0.2")
#BUTTON TO COMPUTE EVERYTHING
self.compute = Button(self.parent, text="Compute", command=self.compute_model, bg="dark red", fg="white")
self.compute.grid(row=14, column=0, padx=5, pady=(10,2), sticky=W)
#BUTTON TO PLAY SINE OUTPUT
output_label = "Sinusoidal:"
Label(self.parent, text=output_label).grid(row=15, column=0, sticky=W, padx=5, pady=(10,0))
self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_hpsModel_sines.wav'), bg="gray30", fg="white")
self.output.grid(row=15, column=0, padx=(80,5), pady=(10,0), sticky=W)
#BUTTON TO PLAY STOCHASTIC OUTPUT
output_label = "Stochastic:"
Label(self.parent, text=output_label).grid(row=16, column=0, sticky=W, padx=5, pady=(5,0))
self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_hpsModel_stochastic.wav'), bg="gray30", fg="white")
self.output.grid(row=16, column=0, padx=(80,5), pady=(5,0), sticky=W)
#BUTTON TO PLAY OUTPUT
output_label = "Output:"
Label(self.parent, text=output_label).grid(row=17, column=0, sticky=W, padx=5, pady=(5,15))
self.output = Button(self.parent, text=">", command=lambda:UF.wavplay('output_sounds/' + os.path.basename(self.filelocation.get())[:-4] + '_hpsModel.wav'), bg="gray30", fg="white")
self.output.grid(row=17, column=0, padx=(80,5), pady=(5,15), sticky=W)
# define options for opening file
self.file_opt = options = {}
options['defaultextension'] = '.wav'
options['filetypes'] = [('All files', '.*'), ('Wav files', '.wav')]
options['initialdir'] = '../../sounds/'
options['title'] = 'Open a mono audio file .wav with sample frequency 44100 Hz'
def browse_file(self):
self.filename = tkFileDialog.askopenfilename(**self.file_opt)
#set the text of the self.filelocation
self.filelocation.delete(0, END)
self.filelocation.insert(0,self.filename)
def compute_model(self):
try:
inputFile = self.filelocation.get()
window = self.w_type.get()
M = int(self.M.get())
N = int(self.N.get())
t = int(self.t.get())
minSineDur = float(self.minSineDur.get())
nH = int(self.nH.get())
minf0 = int(self.minf0.get())
maxf0 = int(self.maxf0.get())
f0et = int(self.f0et.get())
harmDevSlope = float(self.harmDevSlope.get())
stocf = float(self.stocf.get())
hpsModel_function.main(inputFile, window, M, N, t, minSineDur, nH, minf0, maxf0, f0et, harmDevSlope, stocf)
except ValueError as errorMessage:
tkMessageBox.showerror("Input values error", errorMessage)
|
agpl-3.0
|
[
3,
17160,
2787,
367,
314,
394,
2700,
1685,
63,
1593,
14,
647,
199,
199,
504,
16826,
492,
627,
199,
646,
10157,
25213,
12,
10157,
13695,
199,
646,
984,
12,
747,
199,
504,
7026,
14,
2308,
14,
19118,
493,
492,
1586,
199,
646,
394,
1190,
1685,
63,
1593,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
22159,
20644,
992,
15,
1333,
199,
646,
4884,
13967,
465,
738,
38,
523,
199,
533,
869,
1190,
1685,
63,
1943,
26,
2043,
199,
198,
318,
636,
826,
721,
277,
12,
1676,
304,
257,
686,
11083,
198,
277,
14,
1708,
275,
1676,
260,
507,
198,
277,
14,
826,
6379,
342,
421,
198,
318,
4205,
6379,
8,
277,
304,
2742,
198,
16143,
63,
1302,
275,
298,
3205,
570,
17048,
19118,
12,
3485,
79,
436,
10868,
1960,
15877,
6634,
304,
2,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
16143,
63,
1302,
680,
3825,
8,
1143,
29,
16,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
523,
507,
198,
3,
3876,
15694,
2296,
12218,
2919,
15097,
1634,
2334,
3562,
6131,
13024,
507,
198,
277,
14,
493,
1985,
275,
11855,
8,
277,
14,
1708,
9,
507,
198,
277,
14,
493,
1985,
14,
12283,
63,
409,
342,
507,
198,
277,
14,
493,
1985,
905,
2063,
937,
275,
5661,
507,
198,
277,
14,
493,
1985,
14,
3825,
8,
1143,
29,
17,
12,
2301,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
709,
9,
507,
198,
277,
14,
493,
1985,
14,
1807,
8,
16,
12,
7729,
9,
507,
198,
277,
14,
493,
1985,
14,
3176,
8,
16,
12,
283,
9707,
14990,
83,
15,
14338,
13,
10906,
13,
3612,
14,
19118,
358,
2742,
198,
3,
13272,
2296,
699,
11415,
899,
3562,
6131,
13024,
507,
198,
277,
14,
1490,
63,
493,
275,
16005,
8,
277,
14,
1708,
12,
1318,
628,
24149,
23966,
1414,
29,
277,
14,
4570,
63,
493,
9,
327,
3239,
26,
347,
19249,
63,
493,
8,
277,
9,
507,
198,
277,
14,
1490,
63,
493,
14,
3825,
8,
1143,
29,
17,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
11174,
12,
1227,
430,
327,
524,
652,
506,
2441,
314,
570,
1985,
1318,
1977,
523,
507,
198,
3,
13272,
2296,
19924,
12058,
3562,
6131,
13024,
507,
198,
277,
14,
7780,
275,
16005,
8,
277,
14,
1708,
12,
1318,
628,
7166,
1414,
29,
2734,
26,
27363,
14,
19118,
2802,
8,
277,
14,
493,
1985,
14,
362,
4000,
12994,
628,
12150,
1216,
401,
16587,
628,
7510,
531,
507,
198,
277,
14,
7780,
14,
3825,
8,
1143,
29,
17,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
11363,
12,
22,
430,
2742,
198,
309,
869,
689,
11710,
948,
10362,
4424,
2742,
198,
3,
31158,
20238,
1311,
20896,
1649,
55,
11511,
507,
198,
87,
466,
63,
1302,
275,
298,
4301,
730,
5424,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
87,
466,
63,
1302,
680,
3825,
8,
1143,
29,
18,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
87,
63,
466,
275,
2624,
5894,
342,
507,
198,
277,
14,
87,
63,
466,
14,
409,
480,
8399,
1237,
531,
327,
2536,
574,
507,
198,
3806,
63,
1422,
275,
3207,
5977,
8,
277,
14,
1708,
12,
291,
14,
87,
63,
466,
12,
298,
1201,
11572,
401,
298,
72,
11495,
401,
298,
10670,
14566,
401,
298,
8399,
1237,
401,
298,
8399,
1237,
8210,
5719,
531,
507,
198,
3806,
63,
1422,
14,
3825,
8,
1143,
29,
18,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
2720,
12,
21,
395,
22626,
2687,
709,
12,
18,
430,
2742,
198,
3,
15480,
32289,
507,
198,
45,
63,
1302,
275,
298,
4301,
1568,
334,
45,
304,
2,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
45,
63,
1302,
680,
3825,
8,
1143,
29,
20,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
45,
275,
11855,
8,
277,
14,
1708,
12,
2951,
2021,
29,
17611,
9,
507,
198,
277,
14,
45,
905,
2063,
937,
275,
959,
507,
198,
277,
14,
45,
14,
3825,
8,
1143,
29,
20,
12,
2301,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
7680,
12,
21,
395,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
45,
14,
1807,
8,
16,
12,
7729,
9,
507,
198,
277,
14,
45,
14,
3176,
8,
16,
12,
298,
24539,
531,
2742,
198,
3,
1665,
52,
32289,
507,
198,
46,
63,
1302,
275,
298,
1665,
52,
1568,
334,
46,
9,
334,
5652,
402,
2877,
29416,
2419,
603,
304,
2,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
46,
63,
1302,
680,
3825,
8,
1143,
29,
21,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
46,
275,
11855,
8,
277,
14,
1708,
12,
2951,
2021,
29,
17611,
9,
507,
198,
277,
14,
46,
905,
2063,
937,
275,
959,
507,
198,
277,
14,
46,
14,
3825,
8,
1143,
29,
21,
12,
2301,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
13299,
12,
21,
395,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
46,
14,
1807,
8,
16,
12,
7729,
9,
507,
198,
277,
14,
46,
14,
3176,
8,
16,
12,
298,
7727,
531,
2742,
198,
3,
19307,
603,
1254,
46,
28742,
507,
198,
84,
63,
1302,
275,
298,
22745,
78,
7779,
8765,
334,
84,
9,
334,
262,
366,
34,
304,
2,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
84,
63,
1302,
680,
3825,
8,
1143,
29,
22,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
84,
275,
11855,
8,
277,
14,
1708,
12,
2951,
2021,
29,
17611,
9,
507,
198,
277,
14,
84,
905,
2063,
937,
275,
959,
507,
198,
277,
14,
84,
14,
3825,
8,
1143
] |
[
17160,
2787,
367,
314,
394,
2700,
1685,
63,
1593,
14,
647,
199,
199,
504,
16826,
492,
627,
199,
646,
10157,
25213,
12,
10157,
13695,
199,
646,
984,
12,
747,
199,
504,
7026,
14,
2308,
14,
19118,
493,
492,
1586,
199,
646,
394,
1190,
1685,
63,
1593,
199,
1274,
14,
515,
14,
740,
8,
736,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
8,
736,
14,
515,
14,
11091,
3460,
493,
22159,
20644,
992,
15,
1333,
199,
646,
4884,
13967,
465,
738,
38,
523,
199,
533,
869,
1190,
1685,
63,
1943,
26,
2043,
199,
198,
318,
636,
826,
721,
277,
12,
1676,
304,
257,
686,
11083,
198,
277,
14,
1708,
275,
1676,
260,
507,
198,
277,
14,
826,
6379,
342,
421,
198,
318,
4205,
6379,
8,
277,
304,
2742,
198,
16143,
63,
1302,
275,
298,
3205,
570,
17048,
19118,
12,
3485,
79,
436,
10868,
1960,
15877,
6634,
304,
2,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
16143,
63,
1302,
680,
3825,
8,
1143,
29,
16,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
523,
507,
198,
3,
3876,
15694,
2296,
12218,
2919,
15097,
1634,
2334,
3562,
6131,
13024,
507,
198,
277,
14,
493,
1985,
275,
11855,
8,
277,
14,
1708,
9,
507,
198,
277,
14,
493,
1985,
14,
12283,
63,
409,
342,
507,
198,
277,
14,
493,
1985,
905,
2063,
937,
275,
5661,
507,
198,
277,
14,
493,
1985,
14,
3825,
8,
1143,
29,
17,
12,
2301,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
709,
9,
507,
198,
277,
14,
493,
1985,
14,
1807,
8,
16,
12,
7729,
9,
507,
198,
277,
14,
493,
1985,
14,
3176,
8,
16,
12,
283,
9707,
14990,
83,
15,
14338,
13,
10906,
13,
3612,
14,
19118,
358,
2742,
198,
3,
13272,
2296,
699,
11415,
899,
3562,
6131,
13024,
507,
198,
277,
14,
1490,
63,
493,
275,
16005,
8,
277,
14,
1708,
12,
1318,
628,
24149,
23966,
1414,
29,
277,
14,
4570,
63,
493,
9,
327,
3239,
26,
347,
19249,
63,
493,
8,
277,
9,
507,
198,
277,
14,
1490,
63,
493,
14,
3825,
8,
1143,
29,
17,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
11174,
12,
1227,
430,
327,
524,
652,
506,
2441,
314,
570,
1985,
1318,
1977,
523,
507,
198,
3,
13272,
2296,
19924,
12058,
3562,
6131,
13024,
507,
198,
277,
14,
7780,
275,
16005,
8,
277,
14,
1708,
12,
1318,
628,
7166,
1414,
29,
2734,
26,
27363,
14,
19118,
2802,
8,
277,
14,
493,
1985,
14,
362,
4000,
12994,
628,
12150,
1216,
401,
16587,
628,
7510,
531,
507,
198,
277,
14,
7780,
14,
3825,
8,
1143,
29,
17,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
11363,
12,
22,
430,
2742,
198,
309,
869,
689,
11710,
948,
10362,
4424,
2742,
198,
3,
31158,
20238,
1311,
20896,
1649,
55,
11511,
507,
198,
87,
466,
63,
1302,
275,
298,
4301,
730,
5424,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
87,
466,
63,
1302,
680,
3825,
8,
1143,
29,
18,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
87,
63,
466,
275,
2624,
5894,
342,
507,
198,
277,
14,
87,
63,
466,
14,
409,
480,
8399,
1237,
531,
327,
2536,
574,
507,
198,
3806,
63,
1422,
275,
3207,
5977,
8,
277,
14,
1708,
12,
291,
14,
87,
63,
466,
12,
298,
1201,
11572,
401,
298,
72,
11495,
401,
298,
10670,
14566,
401,
298,
8399,
1237,
401,
298,
8399,
1237,
8210,
5719,
531,
507,
198,
3806,
63,
1422,
14,
3825,
8,
1143,
29,
18,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
2720,
12,
21,
395,
22626,
2687,
709,
12,
18,
430,
2742,
198,
3,
15480,
32289,
507,
198,
45,
63,
1302,
275,
298,
4301,
1568,
334,
45,
304,
2,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
45,
63,
1302,
680,
3825,
8,
1143,
29,
20,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
45,
275,
11855,
8,
277,
14,
1708,
12,
2951,
2021,
29,
17611,
9,
507,
198,
277,
14,
45,
905,
2063,
937,
275,
959,
507,
198,
277,
14,
45,
14,
3825,
8,
1143,
29,
20,
12,
2301,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
7680,
12,
21,
395,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
45,
14,
1807,
8,
16,
12,
7729,
9,
507,
198,
277,
14,
45,
14,
3176,
8,
16,
12,
298,
24539,
531,
2742,
198,
3,
1665,
52,
32289,
507,
198,
46,
63,
1302,
275,
298,
1665,
52,
1568,
334,
46,
9,
334,
5652,
402,
2877,
29416,
2419,
603,
304,
2,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
46,
63,
1302,
680,
3825,
8,
1143,
29,
21,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
46,
275,
11855,
8,
277,
14,
1708,
12,
2951,
2021,
29,
17611,
9,
507,
198,
277,
14,
46,
905,
2063,
937,
275,
959,
507,
198,
277,
14,
46,
14,
3825,
8,
1143,
29,
21,
12,
2301,
29,
16,
12,
17870,
29,
55,
12,
21729,
2687,
13299,
12,
21,
395,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
46,
14,
1807,
8,
16,
12,
7729,
9,
507,
198,
277,
14,
46,
14,
3176,
8,
16,
12,
298,
7727,
531,
2742,
198,
3,
19307,
603,
1254,
46,
28742,
507,
198,
84,
63,
1302,
275,
298,
22745,
78,
7779,
8765,
334,
84,
9,
334,
262,
366,
34,
304,
2,
507,
198,
4314,
8,
277,
14,
1708,
12,
1318,
29,
84,
63,
1302,
680,
3825,
8,
1143,
29,
22,
12,
2763,
29,
16,
12,
17870,
29,
55,
12,
21729,
29,
21,
12,
22626,
2687,
709,
12,
18,
430,
507,
198,
277,
14,
84,
275,
11855,
8,
277,
14,
1708,
12,
2951,
2021,
29,
17611,
9,
507,
198,
277,
14,
84,
905,
2063,
937,
275,
959,
507,
198,
277,
14,
84,
14,
3825,
8,
1143,
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
] |
ToonTownInfiniteRepo/ToontownInfinite
|
toontown/catalog/CatalogAccessoryItem.py
|
1
|
16172
|
import CatalogItem
from CatalogAccessoryItemGlobals import *
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import TTLocalizer
from toontown.toon import ToonDNA
import random, types
from direct.showbase import PythonUtil
from direct.gui.DirectGui import *
from pandac.PandaModules import *
class CatalogAccessoryItem(CatalogItem.CatalogItem):
def makeNewItem(self, accessoryType, loyaltyDays = 0):
self.accessoryType = accessoryType
self.loyaltyDays = loyaltyDays
CatalogItem.CatalogItem.makeNewItem(self)
def storedInTrunk(self):
return 1
def notOfferedTo(self, avatar):
article = AccessoryTypes[self.accessoryType][ATArticle]
if article in [AHat,
AGlasses,
ABackpack,
AShoes]:
return 0
forBoys = article in [ABoysHat,
ABoysGlasses,
ABoysBackpack,
ABoysShoes]
if avatar.getStyle().getGender() == 'm':
return not forBoys
else:
return forBoys
def forBoysOnly(self):
article = AccessoryTypes[self.accessoryType][ATArticle]
if article in [ABoysHat,
ABoysGlasses,
ABoysBackpack,
ABoysShoes]:
return 1
else:
return 0
def forGirlsOnly(self):
article = AccessoryTypes[self.accessoryType][ATArticle]
if article in [AGirlsHat,
AGirlsGlasses,
AGirlsBackpack,
AGirlsShoes]:
return 1
else:
return 0
def getPurchaseLimit(self):
return 1
def reachedPurchaseLimit(self, avatar):
if avatar.onOrder.count(self) != 0:
return 1
if avatar.onGiftOrder.count(self) != 0:
return 1
if avatar.mailboxContents.count(self) != 0:
return 1
if self in avatar.awardMailboxContents or self in avatar.onAwardOrder:
return 1
str = AccessoryTypes[self.accessoryType][ATString]
if self.isHat():
defn = ToonDNA.HatStyles[str]
hat = avatar.getHat()
if hat[0] == defn[0] and hat[1] == defn[1] and hat[2] == defn[2]:
return 1
l = avatar.hatList
for i in xrange(0, len(l), 3):
if l[i] == defn[0] and l[i + 1] == defn[1] and l[i + 2] == defn[2]:
return 1
elif self.areGlasses():
defn = ToonDNA.GlassesStyles[str]
glasses = avatar.getGlasses()
if glasses[0] == defn[0] and glasses[1] == defn[1] and glasses[2] == defn[2]:
return 1
l = avatar.glassesList
for i in xrange(0, len(l), 3):
if l[i] == defn[0] and l[i + 1] == defn[1] and l[i + 2] == defn[2]:
return 1
elif self.isBackpack():
defn = ToonDNA.BackpackStyles[str]
backpack = avatar.getBackpack()
if backpack[0] == defn[0] and backpack[1] == defn[1] and backpack[2] == defn[2]:
return 1
l = avatar.backpackList
for i in xrange(0, len(l), 3):
if l[i] == defn[0] and l[i + 1] == defn[1] and l[i + 2] == defn[2]:
return 1
else:
defn = ToonDNA.ShoesStyles[str]
shoes = avatar.getShoes()
if shoes[0] == defn[0] and shoes[1] == defn[1] and shoes[2] == defn[2]:
return 1
l = avatar.shoesList
for i in xrange(0, len(l), 3):
if l[i] == defn[0] and l[i + 1] == defn[1] and l[i + 2] == defn[2]:
return 1
return 0
def getTypeName(self):
return TTLocalizer.AccessoryTypeName
def getName(self):
typeName = TTLocalizer.AccessoryTypeNames.get(self.accessoryType, 0)
if typeName:
return typeName
else:
article = AccessoryTypes[self.accessoryType][ATArticle]
return TTLocalizer.AccessoryArticleNames[article]
def recordPurchase(self, avatar, optional):
if avatar.isTrunkFull():
if avatar.getMaxAccessories() == 0:
return ToontownGlobals.P_NoTrunk
else:
return ToontownGlobals.P_NoRoomForItem
str = AccessoryTypes[self.accessoryType][ATString]
if self.isHat():
defn = ToonDNA.HatStyles[str]
if not avatar.checkAccessorySanity(ToonDNA.HAT, defn[0], defn[1], defn[2]):
self.notify.warning('Avatar %s lost hat %d %d %d; invalid item.' % (avatar.doId,
defn[0],
defn[1],
defn[2]))
return ToontownGlobals.P_ItemAvailable
hat = avatar.getHat()
added = avatar.addToAccessoriesList(ToonDNA.HAT, hat[0], hat[1], hat[2])
if added:
avatar.b_setHatList(avatar.getHatList())
self.notify.info('Avatar %s put hat %d,%d,%d in trunk.' % (avatar.doId,
hat[0],
hat[1],
hat[2]))
else:
self.notify.warning('Avatar %s lost current hat %d %d %d; trunk full.' % (avatar.doId,
hat[0],
hat[1],
hat[2]))
avatar.b_setHat(defn[0], defn[1], defn[2])
elif self.areGlasses():
defn = ToonDNA.GlassesStyles[str]
if not avatar.checkAccessorySanity(ToonDNA.GLASSES, defn[0], defn[1], defn[2]):
self.notify.warning('Avatar %s lost glasses %d %d %d; invalid item.' % (avatar.doId,
defn[0],
defn[1],
defn[2]))
return ToontownGlobals.P_ItemAvailable
glasses = avatar.getGlasses()
added = avatar.addToAccessoriesList(ToonDNA.GLASSES, glasses[0], glasses[1], glasses[2])
if added:
avatar.b_setGlassesList(avatar.getGlassesList())
self.notify.info('Avatar %s put glasses %d,%d,%d in trunk.' % (avatar.doId,
glasses[0],
glasses[1],
glasses[2]))
else:
self.notify.warning('Avatar %s lost current glasses %d %d %d; trunk full.' % (avatar.doId,
glasses[0],
glasses[1],
glasses[2]))
avatar.b_setGlasses(defn[0], defn[1], defn[2])
elif self.isBackpack():
defn = ToonDNA.BackpackStyles[str]
if not avatar.checkAccessorySanity(ToonDNA.BACKPACK, defn[0], defn[1], defn[2]):
self.notify.warning('Avatar %s lost backpack %d %d %d; invalid item.' % (avatar.doId,
defn[0],
defn[1],
defn[2]))
return ToontownGlobals.P_ItemAvailable
backpack = avatar.getBackpack()
added = avatar.addToAccessoriesList(ToonDNA.BACKPACK, backpack[0], backpack[1], backpack[2])
if added:
avatar.b_setBackpackList(avatar.getBackpackList())
self.notify.info('Avatar %s put backpack %d,%d,%d in trunk.' % (avatar.doId,
backpack[0],
backpack[1],
backpack[2]))
else:
self.notify.warning('Avatar %s lost current backpack %d %d %d; trunk full.' % (avatar.doId,
backpack[0],
backpack[1],
backpack[2]))
avatar.b_setBackpack(defn[0], defn[1], defn[2])
else:
defn = ToonDNA.ShoesStyles[str]
if not avatar.checkAccessorySanity(ToonDNA.SHOES, defn[0], defn[1], defn[2]):
self.notify.warning('Avatar %s lost shoes %d %d %d; invalid item.' % (avatar.doId,
defn[0],
defn[1],
defn[2]))
return ToontownGlobals.P_ItemAvailable
shoes = avatar.getShoes()
added = avatar.addToAccessoriesList(ToonDNA.SHOES, shoes[0], shoes[1], shoes[2])
if added:
avatar.b_setShoesList(avatar.getShoesList())
self.notify.info('Avatar %s put shoes %d,%d,%d in trunk.' % (avatar.doId,
shoes[0],
shoes[1],
shoes[2]))
else:
self.notify.warning('Avatar %s lost current shoes %d %d %d; trunk full.' % (avatar.doId,
shoes[0],
shoes[1],
shoes[2]))
avatar.b_setShoes(defn[0], defn[1], defn[2])
avatar.d_catalogGenAccessories()
return ToontownGlobals.P_ItemAvailable
def getDeliveryTime(self):
return 60
def getPicture(self, avatar):
model = self.loadModel()
spin = 1
model.setBin('unsorted', 0, 1)
self.hasPicture = True
return self.makeFrameModel(model, spin)
def applyColor(self, model, color):
if model == None or color == None:
return
if isinstance(color, types.StringType):
tex = loader.loadTexture(color)
tex.setMinfilter(Texture.FTLinearMipmapLinear)
tex.setMagfilter(Texture.FTLinear)
model.setTexture(tex, 1)
else:
needsAlpha = color[3] != 1
color = VBase4(color[0], color[1], color[2], color[3])
model.setColorScale(color, 1)
if needsAlpha:
model.setTransparency(1)
return
def loadModel(self):
modelPath = self.getFilename()
if self.areShoes():
str = AccessoryTypes[self.accessoryType][ATString]
defn = ToonDNA.ShoesStyles[str]
legModel = loader.loadModel('phase_3/models/char/tt_a_chr_dgm_shorts_legs_1000')
model = legModel.find('**/' + modelPath)
else:
model = loader.loadModel(modelPath)
texture = self.getTexture()
if texture:
self.applyColor(model, texture)
colorVec4 = self.getColor()
if colorVec4:
modelColor = (colorVec4.getX(), colorVec4.getY(), colorVec4.getZ())
self.applyColor(model, modelColor)
model.flattenLight()
return model
def requestPurchase(self, phone, callback):
from toontown.toontowngui import TTDialog
avatar = base.localAvatar
accessoriesOnOrder = 0
for item in avatar.onOrder + avatar.mailboxContents:
if item.storedInTrunk():
accessoriesOnOrder += 1
if avatar.isTrunkFull(accessoriesOnOrder):
self.requestPurchaseCleanup()
buttonCallback = PythonUtil.Functor(self.__handleFullPurchaseDialog, phone, callback)
if avatar.getMaxAccessories() == 0:
text = TTLocalizer.CatalogPurchaseNoTrunk
else:
text = TTLocalizer.CatalogPurchaseTrunkFull
self.dialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=text, text_wordwrap=15, command=buttonCallback)
self.dialog.show()
else:
CatalogItem.CatalogItem.requestPurchase(self, phone, callback)
def requestPurchaseCleanup(self):
if hasattr(self, 'dialog'):
self.dialog.cleanup()
del self.dialog
def __handleFullPurchaseDialog(self, phone, callback, buttonValue):
from toontown.toontowngui import TTDialog
self.requestPurchaseCleanup()
if buttonValue == DGG.DIALOG_OK:
CatalogItem.CatalogItem.requestPurchase(self, phone, callback)
else:
callback(ToontownGlobals.P_UserCancelled, self)
def getAcceptItemErrorText(self, retcode):
if retcode == ToontownGlobals.P_ItemAvailable:
if self.isHat():
return TTLocalizer.CatalogAcceptHat
elif self.areGlasses():
return TTLocalizer.CatalogAcceptGlasses
elif self.isBackpack():
return TTLocalizer.CatalogAcceptBackpack
else:
return TTLocalizer.CatalogAcceptShoes
elif retcode == ToontownGlobals.P_NoRoomForItem:
return TTLocalizer.CatalogAcceptTrunkFull
elif retcode == ToontownGlobals.P_NoTrunk:
return TTLocalizer.CatalogAcceptNoTrunk
return CatalogItem.CatalogItem.getAcceptItemErrorText(self, retcode)
def isHat(self):
article = AccessoryTypes[self.accessoryType][ATArticle]
return article in [AHat, ABoysHat, AGirlsHat]
def areGlasses(self):
article = AccessoryTypes[self.accessoryType][ATArticle]
return article in [AGlasses, ABoysGlasses, AGirlsGlasses]
def isBackpack(self):
article = AccessoryTypes[self.accessoryType][ATArticle]
return article in [ABackpack, ABoysBackpack, AGirlsBackpack]
def areShoes(self):
article = AccessoryTypes[self.accessoryType][ATArticle]
return article in [AShoes, ABoysShoes, AGirlsShoes]
def output(self, store = -1):
return 'CatalogAccessoryItem(%s, %s)' % (self.accessoryType, self.formatOptionalData(store))
def getFilename(self):
str = AccessoryTypes[self.accessoryType][ATString]
if self.isHat():
defn = ToonDNA.HatStyles[str]
modelPath = ToonDNA.HatModels[defn[0]]
elif self.areGlasses():
defn = ToonDNA.GlassesStyles[str]
modelPath = ToonDNA.GlassesModels[defn[0]]
elif self.isBackpack():
defn = ToonDNA.BackpackStyles[str]
modelPath = ToonDNA.BackpackModels[defn[0]]
else:
defn = ToonDNA.ShoesStyles[str]
modelPath = ToonDNA.ShoesModels[defn[0]]
return modelPath
def getTexture(self):
str = AccessoryTypes[self.accessoryType][ATString]
if self.isHat():
defn = ToonDNA.HatStyles[str]
modelPath = ToonDNA.HatTextures[defn[1]]
elif self.areGlasses():
defn = ToonDNA.GlassesStyles[str]
modelPath = ToonDNA.GlassesTextures[defn[1]]
elif self.isBackpack():
defn = ToonDNA.BackpackStyles[str]
modelPath = ToonDNA.BackpackTextures[defn[1]]
else:
defn = ToonDNA.ShoesStyles[str]
modelPath = ToonDNA.ShoesTextures[defn[1]]
return modelPath
def getColor(self):
return None
def compareTo(self, other):
return self.accessoryType - other.accessoryType
def getHashContents(self):
return self.accessoryType
def getBasePrice(self):
return AccessoryTypes[self.accessoryType][ATBasePrice]
def getEmblemPrices(self):
result = ()
info = AccessoryTypes[self.accessoryType]
if ATEmblemPrices <= len(info) - 1:
result = info[ATEmblemPrices]
return result
def decodeDatagram(self, di, versionNumber, store):
CatalogItem.CatalogItem.decodeDatagram(self, di, versionNumber, store)
self.accessoryType = di.getUint16()
if versionNumber >= 6:
self.loyaltyDays = di.getUint16()
else:
self.loyaltyDays = 0
str = AccessoryTypes[self.accessoryType][ATString]
if self.isHat():
defn = ToonDNA.HatStyles[str]
elif self.areGlasses():
defn = ToonDNA.GlassesStyles[str]
elif self.isBackpack():
defn = ToonDNA.BackpackStyles[str]
else:
defn = ToonDNA.ShoesStyles[str]
color = ToonDNA.ClothesColors[defn[2]]
def encodeDatagram(self, dg, store):
CatalogItem.CatalogItem.encodeDatagram(self, dg, store)
dg.addUint16(self.accessoryType)
dg.addUint16(self.loyaltyDays)
def isGift(self):
if self.getEmblemPrices():
return 0
if self.loyaltyRequirement() > 0:
return 0
elif self.accessoryType in LoyaltyAccessoryItems:
return 0
else:
return 1
def getAllAccessories(*accessoryTypes):
list = []
for accessoryType in accessoryTypes:
base = CatalogAccessoryItem(accessoryType)
list.append(base)
return list
|
mit
|
[
646,
22881,
2081,
199,
504,
22881,
3946,
1089,
2081,
21675,
492,
627,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
4005,
265,
16231,
21675,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
377,
52,
5339,
1793,
199,
504,
370,
265,
16231,
14,
475,
265,
492,
4005,
265,
23372,
199,
646,
2196,
12,
2943,
199,
504,
4125,
14,
2384,
1095,
492,
2018,
9562,
199,
504,
4125,
14,
5885,
14,
16281,
4324,
492,
627,
199,
504,
299,
460,
645,
14,
48,
18328,
17981,
492,
627,
199,
199,
533,
22881,
3946,
1089,
2081,
8,
17161,
2081,
14,
17161,
2081,
304,
339,
347,
1852,
4665,
2081,
8,
277,
12,
2879,
1089,
804,
12,
560,
89,
13248,
25589,
275,
378,
304,
267,
291,
14,
2732,
1089,
804,
275,
2879,
1089,
804,
267,
291,
14,
3374,
13248,
25589,
275,
560,
89,
13248,
25589,
267,
22881,
2081,
14,
17161,
2081,
14,
1875,
4665,
2081,
8,
277,
9,
339,
347,
5489,
607,
20460,
75,
8,
277,
304,
267,
372,
413,
339,
347,
440,
47,
9224,
1378,
8,
277,
12,
20913,
304,
267,
9772,
275,
11003,
1089,
4100,
59,
277,
14,
2732,
1089,
804,
1527,
619,
7221,
61,
267,
340,
9772,
315,
359,
20755,
292,
12,
268,
437,
17541,
1916,
12,
268,
437,
4540,
1389,
12,
268,
4319,
526,
397,
2189,
288,
372,
378,
267,
367,
2208,
588,
275,
9772,
315,
359,
1217,
79,
588,
40,
292,
12,
268,
437,
2208,
588,
17541,
1916,
12,
268,
437,
2208,
588,
4540,
1389,
12,
268,
437,
2208,
588,
51,
526,
397,
61,
267,
340,
20913,
14,
362,
6609,
1252,
362,
8168,
424,
342,
508,
283,
77,
356,
288,
372,
440,
367,
2208,
588,
267,
587,
26,
288,
372,
367,
2208,
588,
339,
347,
367,
2208,
588,
5903,
8,
277,
304,
267,
9772,
275,
11003,
1089,
4100,
59,
277,
14,
2732,
1089,
804,
1527,
619,
7221,
61,
267,
340,
9772,
315,
359,
1217,
79,
588,
40,
292,
12,
268,
437,
2208,
588,
17541,
1916,
12,
268,
437,
2208,
588,
4540,
1389,
12,
268,
437,
2208,
588,
51,
526,
397,
2189,
288,
372,
413,
267,
587,
26,
288,
372,
378,
339,
347,
367,
39,
723,
478,
5903,
8,
277,
304,
267,
9772,
275,
11003,
1089,
4100,
59,
277,
14,
2732,
1089,
804,
1527,
619,
7221,
61,
267,
340,
9772,
315,
359,
1254,
723,
478,
40,
292,
12,
268,
26787,
723,
478,
17541,
1916,
12,
268,
26787,
723,
478,
4540,
1389,
12,
268,
26787,
723,
478,
51,
526,
397,
2189,
288,
372,
413,
267,
587,
26,
288,
372,
378,
339,
347,
664,
20486,
8407,
8,
277,
304,
267,
372,
413,
339,
347,
13075,
20486,
8407,
8,
277,
12,
20913,
304,
267,
340,
20913,
14,
265,
4738,
14,
835,
8,
277,
9,
1137,
378,
26,
288,
372,
413,
267,
340,
20913,
14,
265,
39,
2949,
4738,
14,
835,
8,
277,
9,
1137,
378,
26,
288,
372,
413,
267,
340,
20913,
14,
21869,
11383,
14,
835,
8,
277,
9,
1137,
378,
26,
288,
372,
413,
267,
340,
291,
315,
20913,
14,
65,
3079,
13681,
1977,
11383,
503,
291,
315,
20913,
14,
265,
33,
3079,
4738,
26,
288,
372,
413,
267,
620,
275,
11003,
1089,
4100,
59,
277,
14,
2732,
1089,
804,
1527,
619,
1558,
61,
267,
340,
291,
14,
374,
40,
292,
837,
288,
347,
78,
275,
4005,
265,
23372,
14,
40,
292,
30349,
59,
495,
61,
288,
394,
292,
275,
20913,
14,
362,
40,
292,
342,
288,
340,
394,
292,
59,
16,
61,
508,
347,
78,
59,
16,
61,
436,
394,
292,
59,
17,
61,
508,
347,
78,
59,
17,
61,
436,
394,
292,
59,
18,
61,
508,
347,
78,
59,
18,
2189,
355,
372,
413,
288,
634,
275,
20913,
14,
8554,
1296,
288,
367,
284,
315,
4945,
8,
16,
12,
822,
8,
76,
395,
650,
304,
355,
340,
634,
59,
73,
61,
508,
347,
78,
59,
16,
61,
436,
634,
59,
73,
435,
413,
61,
508,
347,
78,
59,
17,
61,
436,
634,
59,
73,
435,
499,
61,
508,
347,
78,
59,
18,
2189,
490,
372,
413,
398,
916,
291,
14,
1530,
17541,
1916,
837,
288,
347,
78,
275,
4005,
265,
23372,
14,
17541,
1916,
30349,
59,
495,
61,
288,
6482,
1916,
275,
20913,
14,
362,
17541,
1916,
342,
288,
340,
6482,
1916,
59,
16,
61,
508,
347,
78,
59,
16,
61,
436,
6482,
1916,
59,
17,
61,
508,
347,
78,
59,
17,
61,
436,
6482,
1916,
59,
18,
61,
508,
347,
78,
59,
18,
2189,
355,
372,
413,
288,
634,
275,
20913,
14,
3528,
1916,
1296,
288,
367,
284,
315,
4945,
8,
16,
12,
822,
8,
76,
395,
650,
304,
355,
340,
634,
59,
73,
61,
508,
347,
78,
59,
16,
61,
436,
634,
59,
73,
435,
413,
61,
508,
347,
78,
59,
17,
61,
436,
634,
59,
73,
435,
499,
61,
508,
347,
78,
59,
18,
2189,
490,
372,
413,
398,
916,
291,
14,
374,
4540,
1389,
837,
288,
347,
78,
275,
4005,
265,
23372,
14,
4540,
1389,
30349,
59,
495,
61,
288,
1771,
1389,
275,
20913,
14,
362,
4540,
1389,
342,
288,
340,
1771,
1389,
59,
16,
61,
508,
347,
78,
59,
16,
61,
436,
1771,
1389,
59,
17,
61,
508,
347,
78,
59,
17,
61,
436,
1771,
1389,
59,
18,
61,
508,
347,
78,
59,
18,
2189,
355,
372,
413,
288,
634,
275,
20913,
14,
894,
1389,
1296,
288,
367,
284,
315,
4945,
8,
16,
12,
822,
8,
76,
395,
650,
304,
355,
340,
634,
59,
73,
61,
508,
347,
78,
59,
16,
61,
436,
634,
59,
73,
435,
413,
61,
508,
347,
78,
59,
17,
61,
436,
634,
59,
73,
435,
499,
61,
508,
347,
78,
59,
18,
2189,
490,
372,
413,
398,
587,
26,
288,
347,
78,
275,
4005,
265,
23372,
14,
51,
526,
397,
30349,
59,
495,
61,
288,
930,
397,
275,
20913,
14,
362,
51,
526,
397,
342,
288,
340,
930,
397,
59,
16,
61,
508,
347,
78,
59,
16,
61,
436,
930,
397,
59,
17,
61,
508,
347,
78,
59,
17,
61,
436,
930,
397,
59,
18,
61,
508,
347,
78,
59,
18,
2189,
355,
372,
413,
288,
634,
275,
20913,
14,
13927,
397,
1296,
288,
367,
284,
315,
4945,
8,
16,
12,
822,
8
] |
[
22881,
2081,
199,
504,
22881,
3946,
1089,
2081,
21675,
492,
627,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
4005,
265,
16231,
21675,
199,
504,
370,
265,
16231,
14,
475,
265,
1095,
492,
377,
52,
5339,
1793,
199,
504,
370,
265,
16231,
14,
475,
265,
492,
4005,
265,
23372,
199,
646,
2196,
12,
2943,
199,
504,
4125,
14,
2384,
1095,
492,
2018,
9562,
199,
504,
4125,
14,
5885,
14,
16281,
4324,
492,
627,
199,
504,
299,
460,
645,
14,
48,
18328,
17981,
492,
627,
199,
199,
533,
22881,
3946,
1089,
2081,
8,
17161,
2081,
14,
17161,
2081,
304,
339,
347,
1852,
4665,
2081,
8,
277,
12,
2879,
1089,
804,
12,
560,
89,
13248,
25589,
275,
378,
304,
267,
291,
14,
2732,
1089,
804,
275,
2879,
1089,
804,
267,
291,
14,
3374,
13248,
25589,
275,
560,
89,
13248,
25589,
267,
22881,
2081,
14,
17161,
2081,
14,
1875,
4665,
2081,
8,
277,
9,
339,
347,
5489,
607,
20460,
75,
8,
277,
304,
267,
372,
413,
339,
347,
440,
47,
9224,
1378,
8,
277,
12,
20913,
304,
267,
9772,
275,
11003,
1089,
4100,
59,
277,
14,
2732,
1089,
804,
1527,
619,
7221,
61,
267,
340,
9772,
315,
359,
20755,
292,
12,
268,
437,
17541,
1916,
12,
268,
437,
4540,
1389,
12,
268,
4319,
526,
397,
2189,
288,
372,
378,
267,
367,
2208,
588,
275,
9772,
315,
359,
1217,
79,
588,
40,
292,
12,
268,
437,
2208,
588,
17541,
1916,
12,
268,
437,
2208,
588,
4540,
1389,
12,
268,
437,
2208,
588,
51,
526,
397,
61,
267,
340,
20913,
14,
362,
6609,
1252,
362,
8168,
424,
342,
508,
283,
77,
356,
288,
372,
440,
367,
2208,
588,
267,
587,
26,
288,
372,
367,
2208,
588,
339,
347,
367,
2208,
588,
5903,
8,
277,
304,
267,
9772,
275,
11003,
1089,
4100,
59,
277,
14,
2732,
1089,
804,
1527,
619,
7221,
61,
267,
340,
9772,
315,
359,
1217,
79,
588,
40,
292,
12,
268,
437,
2208,
588,
17541,
1916,
12,
268,
437,
2208,
588,
4540,
1389,
12,
268,
437,
2208,
588,
51,
526,
397,
2189,
288,
372,
413,
267,
587,
26,
288,
372,
378,
339,
347,
367,
39,
723,
478,
5903,
8,
277,
304,
267,
9772,
275,
11003,
1089,
4100,
59,
277,
14,
2732,
1089,
804,
1527,
619,
7221,
61,
267,
340,
9772,
315,
359,
1254,
723,
478,
40,
292,
12,
268,
26787,
723,
478,
17541,
1916,
12,
268,
26787,
723,
478,
4540,
1389,
12,
268,
26787,
723,
478,
51,
526,
397,
2189,
288,
372,
413,
267,
587,
26,
288,
372,
378,
339,
347,
664,
20486,
8407,
8,
277,
304,
267,
372,
413,
339,
347,
13075,
20486,
8407,
8,
277,
12,
20913,
304,
267,
340,
20913,
14,
265,
4738,
14,
835,
8,
277,
9,
1137,
378,
26,
288,
372,
413,
267,
340,
20913,
14,
265,
39,
2949,
4738,
14,
835,
8,
277,
9,
1137,
378,
26,
288,
372,
413,
267,
340,
20913,
14,
21869,
11383,
14,
835,
8,
277,
9,
1137,
378,
26,
288,
372,
413,
267,
340,
291,
315,
20913,
14,
65,
3079,
13681,
1977,
11383,
503,
291,
315,
20913,
14,
265,
33,
3079,
4738,
26,
288,
372,
413,
267,
620,
275,
11003,
1089,
4100,
59,
277,
14,
2732,
1089,
804,
1527,
619,
1558,
61,
267,
340,
291,
14,
374,
40,
292,
837,
288,
347,
78,
275,
4005,
265,
23372,
14,
40,
292,
30349,
59,
495,
61,
288,
394,
292,
275,
20913,
14,
362,
40,
292,
342,
288,
340,
394,
292,
59,
16,
61,
508,
347,
78,
59,
16,
61,
436,
394,
292,
59,
17,
61,
508,
347,
78,
59,
17,
61,
436,
394,
292,
59,
18,
61,
508,
347,
78,
59,
18,
2189,
355,
372,
413,
288,
634,
275,
20913,
14,
8554,
1296,
288,
367,
284,
315,
4945,
8,
16,
12,
822,
8,
76,
395,
650,
304,
355,
340,
634,
59,
73,
61,
508,
347,
78,
59,
16,
61,
436,
634,
59,
73,
435,
413,
61,
508,
347,
78,
59,
17,
61,
436,
634,
59,
73,
435,
499,
61,
508,
347,
78,
59,
18,
2189,
490,
372,
413,
398,
916,
291,
14,
1530,
17541,
1916,
837,
288,
347,
78,
275,
4005,
265,
23372,
14,
17541,
1916,
30349,
59,
495,
61,
288,
6482,
1916,
275,
20913,
14,
362,
17541,
1916,
342,
288,
340,
6482,
1916,
59,
16,
61,
508,
347,
78,
59,
16,
61,
436,
6482,
1916,
59,
17,
61,
508,
347,
78,
59,
17,
61,
436,
6482,
1916,
59,
18,
61,
508,
347,
78,
59,
18,
2189,
355,
372,
413,
288,
634,
275,
20913,
14,
3528,
1916,
1296,
288,
367,
284,
315,
4945,
8,
16,
12,
822,
8,
76,
395,
650,
304,
355,
340,
634,
59,
73,
61,
508,
347,
78,
59,
16,
61,
436,
634,
59,
73,
435,
413,
61,
508,
347,
78,
59,
17,
61,
436,
634,
59,
73,
435,
499,
61,
508,
347,
78,
59,
18,
2189,
490,
372,
413,
398,
916,
291,
14,
374,
4540,
1389,
837,
288,
347,
78,
275,
4005,
265,
23372,
14,
4540,
1389,
30349,
59,
495,
61,
288,
1771,
1389,
275,
20913,
14,
362,
4540,
1389,
342,
288,
340,
1771,
1389,
59,
16,
61,
508,
347,
78,
59,
16,
61,
436,
1771,
1389,
59,
17,
61,
508,
347,
78,
59,
17,
61,
436,
1771,
1389,
59,
18,
61,
508,
347,
78,
59,
18,
2189,
355,
372,
413,
288,
634,
275,
20913,
14,
894,
1389,
1296,
288,
367,
284,
315,
4945,
8,
16,
12,
822,
8,
76,
395,
650,
304,
355,
340,
634,
59,
73,
61,
508,
347,
78,
59,
16,
61,
436,
634,
59,
73,
435,
413,
61,
508,
347,
78,
59,
17,
61,
436,
634,
59,
73,
435,
499,
61,
508,
347,
78,
59,
18,
2189,
490,
372,
413,
398,
587,
26,
288,
347,
78,
275,
4005,
265,
23372,
14,
51,
526,
397,
30349,
59,
495,
61,
288,
930,
397,
275,
20913,
14,
362,
51,
526,
397,
342,
288,
340,
930,
397,
59,
16,
61,
508,
347,
78,
59,
16,
61,
436,
930,
397,
59,
17,
61,
508,
347,
78,
59,
17,
61,
436,
930,
397,
59,
18,
61,
508,
347,
78,
59,
18,
2189,
355,
372,
413,
288,
634,
275,
20913,
14,
13927,
397,
1296,
288,
367,
284,
315,
4945,
8,
16,
12,
822,
8,
0
] |
[
1,
1,
1,
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zbToMedia
|
libs/unidecode/x05d.py
|
252
|
4670
|
data = (
'Lang ', # 0x00
'Kan ', # 0x01
'Lao ', # 0x02
'Lai ', # 0x03
'Xian ', # 0x04
'Que ', # 0x05
'Kong ', # 0x06
'Chong ', # 0x07
'Chong ', # 0x08
'Ta ', # 0x09
'Lin ', # 0x0a
'Hua ', # 0x0b
'Ju ', # 0x0c
'Lai ', # 0x0d
'Qi ', # 0x0e
'Min ', # 0x0f
'Kun ', # 0x10
'Kun ', # 0x11
'Zu ', # 0x12
'Gu ', # 0x13
'Cui ', # 0x14
'Ya ', # 0x15
'Ya ', # 0x16
'Gang ', # 0x17
'Lun ', # 0x18
'Lun ', # 0x19
'Leng ', # 0x1a
'Jue ', # 0x1b
'Duo ', # 0x1c
'Zheng ', # 0x1d
'Guo ', # 0x1e
'Yin ', # 0x1f
'Dong ', # 0x20
'Han ', # 0x21
'Zheng ', # 0x22
'Wei ', # 0x23
'Yao ', # 0x24
'Pi ', # 0x25
'Yan ', # 0x26
'Song ', # 0x27
'Jie ', # 0x28
'Beng ', # 0x29
'Zu ', # 0x2a
'Jue ', # 0x2b
'Dong ', # 0x2c
'Zhan ', # 0x2d
'Gu ', # 0x2e
'Yin ', # 0x2f
'[?] ', # 0x30
'Ze ', # 0x31
'Huang ', # 0x32
'Yu ', # 0x33
'Wei ', # 0x34
'Yang ', # 0x35
'Feng ', # 0x36
'Qiu ', # 0x37
'Dun ', # 0x38
'Ti ', # 0x39
'Yi ', # 0x3a
'Zhi ', # 0x3b
'Shi ', # 0x3c
'Zai ', # 0x3d
'Yao ', # 0x3e
'E ', # 0x3f
'Zhu ', # 0x40
'Kan ', # 0x41
'Lu ', # 0x42
'Yan ', # 0x43
'Mei ', # 0x44
'Gan ', # 0x45
'Ji ', # 0x46
'Ji ', # 0x47
'Huan ', # 0x48
'Ting ', # 0x49
'Sheng ', # 0x4a
'Mei ', # 0x4b
'Qian ', # 0x4c
'Wu ', # 0x4d
'Yu ', # 0x4e
'Zong ', # 0x4f
'Lan ', # 0x50
'Jue ', # 0x51
'Yan ', # 0x52
'Yan ', # 0x53
'Wei ', # 0x54
'Zong ', # 0x55
'Cha ', # 0x56
'Sui ', # 0x57
'Rong ', # 0x58
'Yamashina ', # 0x59
'Qin ', # 0x5a
'Yu ', # 0x5b
'Kewashii ', # 0x5c
'Lou ', # 0x5d
'Tu ', # 0x5e
'Dui ', # 0x5f
'Xi ', # 0x60
'Weng ', # 0x61
'Cang ', # 0x62
'Dang ', # 0x63
'Hong ', # 0x64
'Jie ', # 0x65
'Ai ', # 0x66
'Liu ', # 0x67
'Wu ', # 0x68
'Song ', # 0x69
'Qiao ', # 0x6a
'Zi ', # 0x6b
'Wei ', # 0x6c
'Beng ', # 0x6d
'Dian ', # 0x6e
'Cuo ', # 0x6f
'Qian ', # 0x70
'Yong ', # 0x71
'Nie ', # 0x72
'Cuo ', # 0x73
'Ji ', # 0x74
'[?] ', # 0x75
'Tao ', # 0x76
'Song ', # 0x77
'Zong ', # 0x78
'Jiang ', # 0x79
'Liao ', # 0x7a
'Kang ', # 0x7b
'Chan ', # 0x7c
'Die ', # 0x7d
'Cen ', # 0x7e
'Ding ', # 0x7f
'Tu ', # 0x80
'Lou ', # 0x81
'Zhang ', # 0x82
'Zhan ', # 0x83
'Zhan ', # 0x84
'Ao ', # 0x85
'Cao ', # 0x86
'Qu ', # 0x87
'Qiang ', # 0x88
'Zui ', # 0x89
'Zui ', # 0x8a
'Dao ', # 0x8b
'Dao ', # 0x8c
'Xi ', # 0x8d
'Yu ', # 0x8e
'Bo ', # 0x8f
'Long ', # 0x90
'Xiang ', # 0x91
'Ceng ', # 0x92
'Bo ', # 0x93
'Qin ', # 0x94
'Jiao ', # 0x95
'Yan ', # 0x96
'Lao ', # 0x97
'Zhan ', # 0x98
'Lin ', # 0x99
'Liao ', # 0x9a
'Liao ', # 0x9b
'Jin ', # 0x9c
'Deng ', # 0x9d
'Duo ', # 0x9e
'Zun ', # 0x9f
'Jiao ', # 0xa0
'Gui ', # 0xa1
'Yao ', # 0xa2
'Qiao ', # 0xa3
'Yao ', # 0xa4
'Jue ', # 0xa5
'Zhan ', # 0xa6
'Yi ', # 0xa7
'Xue ', # 0xa8
'Nao ', # 0xa9
'Ye ', # 0xaa
'Ye ', # 0xab
'Yi ', # 0xac
'E ', # 0xad
'Xian ', # 0xae
'Ji ', # 0xaf
'Xie ', # 0xb0
'Ke ', # 0xb1
'Xi ', # 0xb2
'Di ', # 0xb3
'Ao ', # 0xb4
'Zui ', # 0xb5
'[?] ', # 0xb6
'Ni ', # 0xb7
'Rong ', # 0xb8
'Dao ', # 0xb9
'Ling ', # 0xba
'Za ', # 0xbb
'Yu ', # 0xbc
'Yue ', # 0xbd
'Yin ', # 0xbe
'[?] ', # 0xbf
'Jie ', # 0xc0
'Li ', # 0xc1
'Sui ', # 0xc2
'Long ', # 0xc3
'Long ', # 0xc4
'Dian ', # 0xc5
'Ying ', # 0xc6
'Xi ', # 0xc7
'Ju ', # 0xc8
'Chan ', # 0xc9
'Ying ', # 0xca
'Kui ', # 0xcb
'Yan ', # 0xcc
'Wei ', # 0xcd
'Nao ', # 0xce
'Quan ', # 0xcf
'Chao ', # 0xd0
'Cuan ', # 0xd1
'Luan ', # 0xd2
'Dian ', # 0xd3
'Dian ', # 0xd4
'[?] ', # 0xd5
'Yan ', # 0xd6
'Yan ', # 0xd7
'Yan ', # 0xd8
'Nao ', # 0xd9
'Yan ', # 0xda
'Chuan ', # 0xdb
'Gui ', # 0xdc
'Chuan ', # 0xdd
'Zhou ', # 0xde
'Huang ', # 0xdf
'Jing ', # 0xe0
'Xun ', # 0xe1
'Chao ', # 0xe2
'Chao ', # 0xe3
'Lie ', # 0xe4
'Gong ', # 0xe5
'Zuo ', # 0xe6
'Qiao ', # 0xe7
'Ju ', # 0xe8
'Gong ', # 0xe9
'Kek ', # 0xea
'Wu ', # 0xeb
'Pwu ', # 0xec
'Pwu ', # 0xed
'Chai ', # 0xee
'Qiu ', # 0xef
'Qiu ', # 0xf0
'Ji ', # 0xf1
'Yi ', # 0xf2
'Si ', # 0xf3
'Ba ', # 0xf4
'Zhi ', # 0xf5
'Zhao ', # 0xf6
'Xiang ', # 0xf7
'Yi ', # 0xf8
'Jin ', # 0xf9
'Xun ', # 0xfa
'Juan ', # 0xfb
'Phas ', # 0xfc
'Xun ', # 0xfd
'Jin ', # 0xfe
'Fu ', # 0xff
)
|
gpl-3.0
|
[
576,
275,
334,
199,
7,
14654,
1656,
259,
327,
378,
88,
383,
199,
7,
43,
290,
1656,
259,
327,
378,
88,
614,
199,
7,
7833,
79,
1656,
259,
327,
378,
88,
996,
199,
7,
44,
5789,
1656,
259,
327,
378,
88,
1644,
199,
7,
56,
5653,
1656,
259,
327,
378,
88,
966,
199,
7,
49,
310,
1656,
259,
327,
378,
88,
1717,
199,
7,
43,
951,
1656,
259,
327,
378,
88,
1690,
199,
7,
1049,
951,
1656,
259,
327,
378,
88,
1780,
199,
7,
1049,
951,
1656,
259,
327,
378,
88,
2036,
199,
7,
22620,
1656,
259,
327,
378,
88,
1643,
199,
7,
27889,
1656,
259,
327,
378,
88,
16,
65,
199,
7,
40,
1458,
1656,
259,
327,
378,
88,
16,
66,
199,
7,
24783,
1656,
259,
327,
378,
88,
16,
67,
199,
7,
44,
5789,
1656,
259,
327,
378,
88,
16,
68,
199,
7,
19910,
1656,
259,
327,
378,
88,
16,
69,
199,
7,
4649,
1656,
259,
327,
378,
88,
16,
70,
199,
7,
43,
324,
1656,
259,
327,
378,
88,
709,
199,
7,
43,
324,
1656,
259,
327,
378,
88,
845,
199,
7,
58,
85,
1656,
259,
327,
378,
88,
713,
199,
7,
11548,
1656,
259,
327,
378,
88,
969,
199,
7,
35,
1907,
1656,
259,
327,
378,
88,
1079,
199,
7,
28786,
1656,
259,
327,
378,
88,
1046,
199,
7,
28786,
1656,
259,
327,
378,
88,
975,
199,
7,
39,
621,
1656,
259,
327,
378,
88,
1196,
199,
7,
44,
324,
1656,
259,
327,
378,
88,
1085,
199,
7,
44,
324,
1656,
259,
327,
378,
88,
1167,
199,
7,
3166,
71,
1656,
259,
327,
378,
88,
17,
65,
199,
7,
42,
310,
1656,
259,
327,
378,
88,
17,
66,
199,
7,
36,
13780,
1656,
259,
327,
378,
88,
17,
67,
199,
7,
12674,
7420,
1656,
259,
327,
378,
88,
17,
68,
199,
7,
11548,
79,
1656,
259,
327,
378,
88,
17,
69,
199,
7,
57,
262,
1656,
259,
327,
378,
88,
17,
70,
199,
7,
36,
951,
1656,
259,
327,
378,
88,
1165,
199,
7,
40,
290,
1656,
259,
327,
378,
88,
2025,
199,
7,
12674,
7420,
1656,
259,
327,
378,
88,
1081,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
1789,
199,
7,
57,
8035,
1656,
259,
327,
378,
88,
1194,
199,
7,
10542,
1656,
259,
327,
378,
88,
821,
199,
7,
26797,
1656,
259,
327,
378,
88,
1479,
199,
7,
51,
951,
1656,
259,
327,
378,
88,
1465,
199,
7,
42,
1873,
1656,
259,
327,
378,
88,
1651,
199,
7,
34,
7420,
1656,
259,
327,
378,
88,
1398,
199,
7,
58,
85,
1656,
259,
327,
378,
88,
18,
65,
199,
7,
42,
310,
1656,
259,
327,
378,
88,
18,
66,
199,
7,
36,
951,
1656,
259,
327,
378,
88,
18,
67,
199,
7,
12674,
290,
1656,
259,
327,
378,
88,
18,
68,
199,
7,
11548,
1656,
259,
327,
378,
88,
18,
69,
199,
7,
57,
262,
1656,
259,
327,
378,
88,
18,
70,
199,
17892,
1656,
259,
327,
378,
88,
1216,
199,
7,
58,
69,
1656,
259,
327,
378,
88,
2192,
199,
7,
25542,
621,
1656,
259,
327,
378,
88,
708,
199,
7,
24388,
1656,
259,
327,
378,
88,
1153,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
1082,
199,
7,
57,
621,
1656,
259,
327,
378,
88,
1276,
199,
7,
38,
7420,
1656,
259,
327,
378,
88,
1344,
199,
7,
19910,
85,
1656,
259,
327,
378,
88,
1401,
199,
7,
36,
324,
1656,
259,
327,
378,
88,
1703,
199,
7,
22731,
1656,
259,
327,
378,
88,
1355,
199,
7,
21001,
1656,
259,
327,
378,
88,
19,
65,
199,
7,
58,
5812,
1656,
259,
327,
378,
88,
19,
66,
199,
7,
2662,
73,
1656,
259,
327,
378,
88,
19,
67,
199,
7,
58,
5789,
1656,
259,
327,
378,
88,
19,
68,
199,
7,
57,
8035,
1656,
259,
327,
378,
88,
19,
69,
199,
7,
37,
1656,
259,
327,
378,
88,
19,
70,
199,
7,
31183,
1656,
259,
327,
378,
88,
2167,
199,
7,
43,
290,
1656,
259,
327,
378,
88,
2953,
199,
7,
18176,
1656,
259,
327,
378,
88,
2260,
199,
7,
26797,
1656,
259,
327,
378,
88,
2824,
199,
7,
1352,
73,
1656,
259,
327,
378,
88,
1602,
199,
7,
39,
290,
1656,
259,
327,
378,
88,
2322,
199,
7,
16911,
1656,
259,
327,
378,
88,
2466,
199,
7,
16911,
1656,
259,
327,
378,
88,
2417,
199,
7,
40,
7856,
1656,
259,
327,
378,
88,
2006,
199,
7,
52,
316,
1656,
259,
327,
378,
88,
1887,
199,
7,
2662,
7420,
1656,
259,
327,
378,
88,
20,
65,
199,
7,
1352,
73,
1656,
259,
327,
378,
88,
20,
66,
199,
7,
49,
5653,
1656,
259,
327,
378,
88,
20,
67,
199,
7,
25728,
1656,
259,
327,
378,
88,
20,
68,
199,
7,
24388,
1656,
259,
327,
378,
88,
20,
69,
199,
7,
58,
951,
1656,
259,
327,
378,
88,
20,
70,
199,
7,
44,
290,
1656,
259,
327,
378,
88,
1400,
199,
7,
42,
310,
1656,
259,
327,
378,
88,
2869,
199,
7,
26797,
1656,
259,
327,
378,
88,
2528,
199,
7,
26797,
1656,
259,
327,
378,
88,
2481,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
1477,
199,
7,
58,
951,
1656,
259,
327,
378,
88,
1229,
199,
7,
1049,
65,
1656,
259,
327,
378,
88,
1367,
199,
7,
51,
1907,
1656,
259,
327,
378,
88,
1641,
199,
7,
50,
951,
1656,
259,
327,
378,
88,
2010,
199,
7,
57,
455,
1119,
13765,
1656,
259,
327,
378,
88,
1427,
199,
7,
49,
262,
1656,
259,
327,
378,
88,
21,
65,
199,
7,
24388,
1656,
259,
327,
378,
88,
21,
66,
199,
7,
43,
546,
1119,
5908,
1656,
259,
327,
378,
88,
21,
67,
199,
7,
44,
810,
1656,
259,
327,
378,
88,
21,
68,
199,
7,
30669,
1656,
259,
327,
378,
88,
21,
69,
199,
7,
36,
1907,
1656,
259,
327,
378,
88,
21,
70,
199,
7,
14828,
1656,
259,
327,
378,
88,
2259,
199,
7,
55,
7420,
1656,
259,
327,
378,
88,
2976,
199,
7,
35,
621,
1656,
259,
327,
378,
88,
2789,
199,
7,
36,
621,
1656,
259,
327,
378,
88,
2766,
199,
7,
40,
951,
1656,
259,
327,
378,
88,
772,
199
] |
[
275,
334,
199,
7,
14654,
1656,
259,
327,
378,
88,
383,
199,
7,
43,
290,
1656,
259,
327,
378,
88,
614,
199,
7,
7833,
79,
1656,
259,
327,
378,
88,
996,
199,
7,
44,
5789,
1656,
259,
327,
378,
88,
1644,
199,
7,
56,
5653,
1656,
259,
327,
378,
88,
966,
199,
7,
49,
310,
1656,
259,
327,
378,
88,
1717,
199,
7,
43,
951,
1656,
259,
327,
378,
88,
1690,
199,
7,
1049,
951,
1656,
259,
327,
378,
88,
1780,
199,
7,
1049,
951,
1656,
259,
327,
378,
88,
2036,
199,
7,
22620,
1656,
259,
327,
378,
88,
1643,
199,
7,
27889,
1656,
259,
327,
378,
88,
16,
65,
199,
7,
40,
1458,
1656,
259,
327,
378,
88,
16,
66,
199,
7,
24783,
1656,
259,
327,
378,
88,
16,
67,
199,
7,
44,
5789,
1656,
259,
327,
378,
88,
16,
68,
199,
7,
19910,
1656,
259,
327,
378,
88,
16,
69,
199,
7,
4649,
1656,
259,
327,
378,
88,
16,
70,
199,
7,
43,
324,
1656,
259,
327,
378,
88,
709,
199,
7,
43,
324,
1656,
259,
327,
378,
88,
845,
199,
7,
58,
85,
1656,
259,
327,
378,
88,
713,
199,
7,
11548,
1656,
259,
327,
378,
88,
969,
199,
7,
35,
1907,
1656,
259,
327,
378,
88,
1079,
199,
7,
28786,
1656,
259,
327,
378,
88,
1046,
199,
7,
28786,
1656,
259,
327,
378,
88,
975,
199,
7,
39,
621,
1656,
259,
327,
378,
88,
1196,
199,
7,
44,
324,
1656,
259,
327,
378,
88,
1085,
199,
7,
44,
324,
1656,
259,
327,
378,
88,
1167,
199,
7,
3166,
71,
1656,
259,
327,
378,
88,
17,
65,
199,
7,
42,
310,
1656,
259,
327,
378,
88,
17,
66,
199,
7,
36,
13780,
1656,
259,
327,
378,
88,
17,
67,
199,
7,
12674,
7420,
1656,
259,
327,
378,
88,
17,
68,
199,
7,
11548,
79,
1656,
259,
327,
378,
88,
17,
69,
199,
7,
57,
262,
1656,
259,
327,
378,
88,
17,
70,
199,
7,
36,
951,
1656,
259,
327,
378,
88,
1165,
199,
7,
40,
290,
1656,
259,
327,
378,
88,
2025,
199,
7,
12674,
7420,
1656,
259,
327,
378,
88,
1081,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
1789,
199,
7,
57,
8035,
1656,
259,
327,
378,
88,
1194,
199,
7,
10542,
1656,
259,
327,
378,
88,
821,
199,
7,
26797,
1656,
259,
327,
378,
88,
1479,
199,
7,
51,
951,
1656,
259,
327,
378,
88,
1465,
199,
7,
42,
1873,
1656,
259,
327,
378,
88,
1651,
199,
7,
34,
7420,
1656,
259,
327,
378,
88,
1398,
199,
7,
58,
85,
1656,
259,
327,
378,
88,
18,
65,
199,
7,
42,
310,
1656,
259,
327,
378,
88,
18,
66,
199,
7,
36,
951,
1656,
259,
327,
378,
88,
18,
67,
199,
7,
12674,
290,
1656,
259,
327,
378,
88,
18,
68,
199,
7,
11548,
1656,
259,
327,
378,
88,
18,
69,
199,
7,
57,
262,
1656,
259,
327,
378,
88,
18,
70,
199,
17892,
1656,
259,
327,
378,
88,
1216,
199,
7,
58,
69,
1656,
259,
327,
378,
88,
2192,
199,
7,
25542,
621,
1656,
259,
327,
378,
88,
708,
199,
7,
24388,
1656,
259,
327,
378,
88,
1153,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
1082,
199,
7,
57,
621,
1656,
259,
327,
378,
88,
1276,
199,
7,
38,
7420,
1656,
259,
327,
378,
88,
1344,
199,
7,
19910,
85,
1656,
259,
327,
378,
88,
1401,
199,
7,
36,
324,
1656,
259,
327,
378,
88,
1703,
199,
7,
22731,
1656,
259,
327,
378,
88,
1355,
199,
7,
21001,
1656,
259,
327,
378,
88,
19,
65,
199,
7,
58,
5812,
1656,
259,
327,
378,
88,
19,
66,
199,
7,
2662,
73,
1656,
259,
327,
378,
88,
19,
67,
199,
7,
58,
5789,
1656,
259,
327,
378,
88,
19,
68,
199,
7,
57,
8035,
1656,
259,
327,
378,
88,
19,
69,
199,
7,
37,
1656,
259,
327,
378,
88,
19,
70,
199,
7,
31183,
1656,
259,
327,
378,
88,
2167,
199,
7,
43,
290,
1656,
259,
327,
378,
88,
2953,
199,
7,
18176,
1656,
259,
327,
378,
88,
2260,
199,
7,
26797,
1656,
259,
327,
378,
88,
2824,
199,
7,
1352,
73,
1656,
259,
327,
378,
88,
1602,
199,
7,
39,
290,
1656,
259,
327,
378,
88,
2322,
199,
7,
16911,
1656,
259,
327,
378,
88,
2466,
199,
7,
16911,
1656,
259,
327,
378,
88,
2417,
199,
7,
40,
7856,
1656,
259,
327,
378,
88,
2006,
199,
7,
52,
316,
1656,
259,
327,
378,
88,
1887,
199,
7,
2662,
7420,
1656,
259,
327,
378,
88,
20,
65,
199,
7,
1352,
73,
1656,
259,
327,
378,
88,
20,
66,
199,
7,
49,
5653,
1656,
259,
327,
378,
88,
20,
67,
199,
7,
25728,
1656,
259,
327,
378,
88,
20,
68,
199,
7,
24388,
1656,
259,
327,
378,
88,
20,
69,
199,
7,
58,
951,
1656,
259,
327,
378,
88,
20,
70,
199,
7,
44,
290,
1656,
259,
327,
378,
88,
1400,
199,
7,
42,
310,
1656,
259,
327,
378,
88,
2869,
199,
7,
26797,
1656,
259,
327,
378,
88,
2528,
199,
7,
26797,
1656,
259,
327,
378,
88,
2481,
199,
7,
6004,
73,
1656,
259,
327,
378,
88,
1477,
199,
7,
58,
951,
1656,
259,
327,
378,
88,
1229,
199,
7,
1049,
65,
1656,
259,
327,
378,
88,
1367,
199,
7,
51,
1907,
1656,
259,
327,
378,
88,
1641,
199,
7,
50,
951,
1656,
259,
327,
378,
88,
2010,
199,
7,
57,
455,
1119,
13765,
1656,
259,
327,
378,
88,
1427,
199,
7,
49,
262,
1656,
259,
327,
378,
88,
21,
65,
199,
7,
24388,
1656,
259,
327,
378,
88,
21,
66,
199,
7,
43,
546,
1119,
5908,
1656,
259,
327,
378,
88,
21,
67,
199,
7,
44,
810,
1656,
259,
327,
378,
88,
21,
68,
199,
7,
30669,
1656,
259,
327,
378,
88,
21,
69,
199,
7,
36,
1907,
1656,
259,
327,
378,
88,
21,
70,
199,
7,
14828,
1656,
259,
327,
378,
88,
2259,
199,
7,
55,
7420,
1656,
259,
327,
378,
88,
2976,
199,
7,
35,
621,
1656,
259,
327,
378,
88,
2789,
199,
7,
36,
621,
1656,
259,
327,
378,
88,
2766,
199,
7,
40,
951,
1656,
259,
327,
378,
88,
772,
199,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
miguelgrinberg/heat
|
heat/engine/clients/os/heat_plugin.py
|
8
|
2860
|
#
# 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 heatclient import client as hc
from heatclient import exc
from heat.engine.clients import client_plugin
class HeatClientPlugin(client_plugin.ClientPlugin):
exceptions_module = exc
service_types = [ORCHESTRATION,
CLOUDFORMATION] = ['orchestration', 'cloudformation']
def _create(self):
args = {
'auth_url': self.context.auth_url,
'token': self.auth_token,
'username': None,
'password': None,
'ca_file': self._get_client_option('heat', 'ca_file'),
'cert_file': self._get_client_option('heat', 'cert_file'),
'key_file': self._get_client_option('heat', 'key_file'),
'insecure': self._get_client_option('heat', 'insecure')
}
endpoint = self.get_heat_url()
if self._get_client_option('heat', 'url'):
# assume that the heat API URL is manually configured because
# it is not in the keystone catalog, so include the credentials
# for the standalone auth_password middleware
args['username'] = self.context.username
args['password'] = self.context.password
del(args['token'])
return hc.Client('1', endpoint, **args)
def is_not_found(self, ex):
return isinstance(ex, exc.HTTPNotFound)
def is_over_limit(self, ex):
return isinstance(ex, exc.HTTPOverLimit)
def is_conflict(self, ex):
return isinstance(ex, exc.HTTPConflict)
def get_heat_url(self):
heat_url = self._get_client_option('heat', 'url')
if heat_url:
tenant_id = self.context.tenant_id
heat_url = heat_url % {'tenant_id': tenant_id}
else:
endpoint_type = self._get_client_option('heat', 'endpoint_type')
heat_url = self.url_for(service_type=self.ORCHESTRATION,
endpoint_type=endpoint_type)
return heat_url
def get_heat_cfn_url(self):
endpoint_type = self._get_client_option('heat',
'endpoint_type')
heat_cfn_url = self.url_for(service_type=self.CLOUDFORMATION,
endpoint_type=endpoint_type)
return heat_cfn_url
|
apache-2.0
|
[
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,
20408,
1258,
492,
1890,
465,
394,
67,
199,
504,
20408,
1258,
492,
3178,
199,
199,
504,
20408,
14,
3908,
14,
14555,
492,
1890,
63,
2718,
421,
199,
533,
5311,
292,
3041,
5061,
8,
1258,
63,
2718,
14,
3041,
5061,
304,
339,
4967,
63,
578,
275,
3178,
339,
2435,
63,
1313,
275,
359,
726,
1244,
1719,
23743,
12,
2151,
445,
1484,
3383,
18623,
61,
275,
788,
269,
595,
270,
1754,
297,
283,
4091,
1869,
418,
339,
347,
485,
981,
8,
277,
304,
267,
1249,
275,
469,
288,
283,
1178,
63,
633,
356,
291,
14,
1100,
14,
1178,
63,
633,
12,
288,
283,
1418,
356,
291,
14,
1178,
63,
1418,
12,
288,
283,
2473,
356,
488,
12,
288,
283,
2060,
356,
488,
12,
288,
283,
696,
63,
493,
356,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
696,
63,
493,
659,
288,
283,
4736,
63,
493,
356,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
4736,
63,
493,
659,
288,
283,
498,
63,
493,
356,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
498,
63,
493,
659,
288,
283,
24824,
356,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
24824,
358,
267,
789,
398,
6037,
275,
291,
14,
362,
63,
16614,
63,
633,
342,
267,
340,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
633,
735,
288,
327,
5534,
626,
314,
20408,
3261,
2851,
365,
10250,
7526,
2952,
288,
327,
652,
365,
440,
315,
314,
19395,
10594,
12,
880,
2387,
314,
6235,
288,
327,
367,
314,
18042,
1790,
63,
2060,
10816,
288,
1249,
459,
2473,
418,
275,
291,
14,
1100,
14,
2473,
288,
1249,
459,
2060,
418,
275,
291,
14,
1100,
14,
2060,
288,
2150,
8,
589,
459,
1418,
1105,
398,
372,
394,
67,
14,
3041,
360,
17,
297,
6037,
12,
1011,
589,
9,
339,
347,
365,
63,
1397,
63,
4214,
8,
277,
12,
444,
304,
267,
372,
1228,
8,
476,
12,
3178,
14,
26553,
9,
339,
347,
365,
63,
1883,
63,
3097,
8,
277,
12,
444,
304,
267,
372,
1228,
8,
476,
12,
3178,
14,
40,
1481,
1512,
422,
8407,
9,
339,
347,
365,
63,
15207,
8,
277,
12,
444,
304,
267,
372,
1228,
8,
476,
12,
3178,
14,
2856,
15919,
9,
339,
347,
664,
63,
16614,
63,
633,
8,
277,
304,
267,
20408,
63,
633,
275,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
633,
358,
267,
340,
20408,
63,
633,
26,
288,
8261,
63,
344,
275,
291,
14,
1100,
14,
4647,
63,
344,
288,
20408,
63,
633,
275,
20408,
63,
633,
450,
791,
4647,
63,
344,
356,
8261,
63,
344,
93,
267,
587,
26,
288,
6037,
63,
466,
275,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
6520,
63,
466,
358,
288,
20408,
63,
633,
275,
291,
14,
633,
63,
509,
8,
1364,
63,
466,
29,
277,
14,
726,
1244,
1719,
23743,
12,
2511,
6037,
63,
466,
29,
6520,
63,
466,
9,
267,
372,
20408,
63,
633,
339,
347,
664,
63,
16614,
63,
2177,
78,
63,
633,
8,
277,
304,
267,
6037,
63,
466,
275,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
6059,
283,
6520,
63,
466,
358,
267,
20408,
63,
2177,
78,
63,
633,
275,
291,
14,
633,
63,
509,
8,
1364,
63,
466,
29,
277,
14,
29495,
18623,
12,
2511,
6037,
63,
466,
29,
6520,
63,
466,
9,
267,
372,
20408,
63,
2177,
78,
63,
633,
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
] |
[
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,
20408,
1258,
492,
1890,
465,
394,
67,
199,
504,
20408,
1258,
492,
3178,
199,
199,
504,
20408,
14,
3908,
14,
14555,
492,
1890,
63,
2718,
421,
199,
533,
5311,
292,
3041,
5061,
8,
1258,
63,
2718,
14,
3041,
5061,
304,
339,
4967,
63,
578,
275,
3178,
339,
2435,
63,
1313,
275,
359,
726,
1244,
1719,
23743,
12,
2151,
445,
1484,
3383,
18623,
61,
275,
788,
269,
595,
270,
1754,
297,
283,
4091,
1869,
418,
339,
347,
485,
981,
8,
277,
304,
267,
1249,
275,
469,
288,
283,
1178,
63,
633,
356,
291,
14,
1100,
14,
1178,
63,
633,
12,
288,
283,
1418,
356,
291,
14,
1178,
63,
1418,
12,
288,
283,
2473,
356,
488,
12,
288,
283,
2060,
356,
488,
12,
288,
283,
696,
63,
493,
356,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
696,
63,
493,
659,
288,
283,
4736,
63,
493,
356,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
4736,
63,
493,
659,
288,
283,
498,
63,
493,
356,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
498,
63,
493,
659,
288,
283,
24824,
356,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
24824,
358,
267,
789,
398,
6037,
275,
291,
14,
362,
63,
16614,
63,
633,
342,
267,
340,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
633,
735,
288,
327,
5534,
626,
314,
20408,
3261,
2851,
365,
10250,
7526,
2952,
288,
327,
652,
365,
440,
315,
314,
19395,
10594,
12,
880,
2387,
314,
6235,
288,
327,
367,
314,
18042,
1790,
63,
2060,
10816,
288,
1249,
459,
2473,
418,
275,
291,
14,
1100,
14,
2473,
288,
1249,
459,
2060,
418,
275,
291,
14,
1100,
14,
2060,
288,
2150,
8,
589,
459,
1418,
1105,
398,
372,
394,
67,
14,
3041,
360,
17,
297,
6037,
12,
1011,
589,
9,
339,
347,
365,
63,
1397,
63,
4214,
8,
277,
12,
444,
304,
267,
372,
1228,
8,
476,
12,
3178,
14,
26553,
9,
339,
347,
365,
63,
1883,
63,
3097,
8,
277,
12,
444,
304,
267,
372,
1228,
8,
476,
12,
3178,
14,
40,
1481,
1512,
422,
8407,
9,
339,
347,
365,
63,
15207,
8,
277,
12,
444,
304,
267,
372,
1228,
8,
476,
12,
3178,
14,
2856,
15919,
9,
339,
347,
664,
63,
16614,
63,
633,
8,
277,
304,
267,
20408,
63,
633,
275,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
633,
358,
267,
340,
20408,
63,
633,
26,
288,
8261,
63,
344,
275,
291,
14,
1100,
14,
4647,
63,
344,
288,
20408,
63,
633,
275,
20408,
63,
633,
450,
791,
4647,
63,
344,
356,
8261,
63,
344,
93,
267,
587,
26,
288,
6037,
63,
466,
275,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
283,
6520,
63,
466,
358,
288,
20408,
63,
633,
275,
291,
14,
633,
63,
509,
8,
1364,
63,
466,
29,
277,
14,
726,
1244,
1719,
23743,
12,
2511,
6037,
63,
466,
29,
6520,
63,
466,
9,
267,
372,
20408,
63,
633,
339,
347,
664,
63,
16614,
63,
2177,
78,
63,
633,
8,
277,
304,
267,
6037,
63,
466,
275,
291,
423,
362,
63,
1258,
63,
1422,
360,
16614,
297,
6059,
283,
6520,
63,
466,
358,
267,
20408,
63,
2177,
78,
63,
633,
275,
291,
14,
633,
63,
509,
8,
1364,
63,
466,
29,
277,
14,
29495,
18623,
12,
2511,
6037,
63,
466,
29,
6520,
63,
466,
9,
267,
372,
20408,
63,
2177,
78,
63,
633,
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,
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,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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
] |
adamfisk/littleshoot-client
|
server/appengine/boto/pyami/installers/ubuntu/mysql.py
|
1
|
4361
|
# Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
"""
This installer will install mysql-server on an Ubuntu machine.
In addition to the normal installation done by apt-get, it will
also configure the new MySQL server to store it's data files in
a different location. By default, this is /mnt but that can be
configured in the [MySQL] section of the boto config file passed
to the instance.
"""
from boto.pyami.installers.ubuntu.installer import Installer
import os
import boto
from ConfigParser import SafeConfigParser
import time
ConfigSection = """
[MySQL]
root_password = <will be used as MySQL root password, default none>
data_dir = <new data dir for MySQL, default is /mnt>
"""
class MySQL(Installer):
def install(self):
self.run('apt-get update')
self.run('apt-get -y install mysql-server', notify=True, exit_on_error=True)
# def set_root_password(self, password=None):
# if not password:
# password = boto.config.get('MySQL', 'root_password')
# if password:
# self.run('mysqladmin -u root password %s' % password)
# return password
def change_data_dir(self, password=None):
data_dir = boto.config.get('MySQL', 'data_dir', '/mnt')
fresh_install = False;
time.sleep(10) #trying to stop mysql immediately after installing it fails
# We need to wait until mysql creates the root account before we kill it
# or bad things will happen
i = 0
while self.run("echo 'quit' | mysql -u root") != 0 and i<5:
time.sleep(5)
i = i + 1
self.run('/etc/init.d/mysql stop')
self.run("pkill -9 mysql")
mysql_path = os.path.join(data_dir, 'mysql')
if not os.path.exists(mysql_path):
self.run('mkdir %s' % mysql_path)
fresh_install = True;
self.run('chown -R mysql:mysql %s' % mysql_path)
fp = open('/etc/mysql/conf.d/use_mnt.cnf', 'w')
fp.write('# created by pyami\n')
fp.write('# use the %s volume for data\n' % data_dir)
fp.write('[mysqld]\n')
fp.write('datadir = %s\n' % mysql_path)
fp.write('log_bin = %s\n' % os.path.join(mysql_path, 'mysql-bin.log'))
fp.close()
if fresh_install:
self.run('cp -pr /var/lib/mysql/* %s/' % mysql_path)
self.start('mysql')
else:
#get the password ubuntu expects to use:
config_parser = SafeConfigParser()
config_parser.read('/etc/mysql/debian.cnf')
password = config_parser.get('client', 'password')
# start the mysql deamon, then mysql with the required grant statement piped into it:
self.start('mysql')
time.sleep(10) #time for mysql to start
grant_command = "echo \"GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '%s' WITH GRANT OPTION;\" | mysql" % password
while self.run(grant_command) != 0:
time.sleep(5)
# leave mysqld running
def main(self):
self.install()
# change_data_dir runs 'mysql -u root' which assumes there is no mysql password, i
# and changing that is too ugly to be worth it:
#self.set_root_password()
self.change_data_dir()
|
gpl-2.0
|
[
3,
1898,
334,
67,
9,
8315,
13,
8664,
603,
9414,
598,
26272,
1455,
921,
71,
26272,
14,
1308,
15,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
221,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
3,
199,
624,
199,
2765,
18535,
911,
3907,
12896,
13,
1000,
641,
376,
31631,
6844,
14,
199,
607,
10234,
370,
314,
3293,
12096,
4224,
701,
20932,
13,
362,
12,
652,
911,
199,
12344,
7908,
314,
892,
11200,
1654,
370,
3877,
652,
1159,
666,
1584,
315,
199,
65,
3365,
2909,
14,
221,
4885,
849,
12,
642,
365,
1182,
20481,
1325,
626,
883,
506,
199,
11786,
315,
314,
359,
20784,
61,
3420,
402,
314,
6055,
1101,
570,
3032,
199,
475,
314,
1256,
14,
199,
624,
199,
504,
6055,
14,
647,
13496,
14,
17047,
83,
14,
21151,
14,
17047,
492,
14089,
9230,
199,
646,
747,
199,
646,
6055,
199,
504,
14196,
492,
14969,
15218,
199,
646,
900,
199,
199,
2028,
8660,
275,
408,
199,
59,
20784,
61,
199,
1231,
63,
2060,
275,
665,
14117,
506,
1202,
465,
11200,
1738,
2505,
12,
849,
7179,
30,
199,
576,
63,
694,
275,
665,
1222,
666,
2935,
367,
11200,
12,
849,
365,
1182,
20481,
30,
199,
624,
199,
199,
533,
11200,
8,
27598,
304,
339,
347,
3907,
8,
277,
304,
267,
291,
14,
1065,
360,
6182,
13,
362,
1678,
358,
267,
291,
14,
1065,
360,
6182,
13,
362,
446,
89,
3907,
12896,
13,
1000,
297,
11705,
29,
549,
12,
4458,
63,
265,
63,
705,
29,
549,
9,
199,
199,
3,
259,
347,
663,
63,
1231,
63,
2060,
8,
277,
12,
2505,
29,
403,
304,
199,
3,
263,
340,
440,
2505,
26,
199,
3,
3322,
2505,
275,
6055,
14,
888,
14,
362,
360,
20784,
297,
283,
1231,
63,
2060,
358,
199,
3,
263,
340,
2505,
26,
199,
3,
3322,
291,
14,
1065,
360,
8644,
2113,
446,
85,
1738,
2505,
450,
83,
7,
450,
2505,
9,
199,
3,
263,
372,
2505,
339,
347,
1570,
63,
576,
63,
694,
8,
277,
12,
2505,
29,
403,
304,
267,
666,
63,
694,
275,
6055,
14,
888,
14,
362,
360,
20784,
297,
283,
576,
63,
694,
297,
1994,
20481,
358,
267,
17480,
63,
3174,
275,
756,
27,
267,
900,
14,
4532,
8,
709,
9,
327,
893,
316,
370,
3631,
12896,
9939,
2410,
22200,
652,
6918,
267,
327,
2136,
1929,
370,
3618,
5133,
12896,
8491,
314,
1738,
2933,
2544,
781,
14561,
652,
267,
327,
503,
4875,
7645,
911,
5992,
267,
284,
275,
378,
267,
1830,
291,
14,
1065,
480,
7878,
283,
10589,
7,
1204,
12896,
446,
85,
1738,
531,
1137,
378,
436,
284,
28,
21,
26,
288,
900,
14,
4532,
8,
21,
9,
288,
284,
275,
284,
435,
413,
267,
291,
14,
1065,
2336,
6839,
15,
826,
14,
68,
15,
8644,
3631,
358,
267,
291,
14,
1065,
480,
2051,
778,
446,
25,
12896,
531,
398,
12896,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
694,
12,
283,
8644,
358,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
8644,
63,
515,
304,
288,
291,
14,
1065,
360,
8215,
450,
83,
7,
450,
12896,
63,
515,
9,
288,
17480,
63,
3174,
275,
715,
27,
267,
291,
14,
1065,
360,
20933,
446,
50,
12896,
26,
8644,
450,
83,
7,
450,
12896,
63,
515,
9,
267,
4090,
275,
1551,
2336,
6839,
15,
8644,
15,
2190,
14,
68,
15,
1180,
63,
20481,
14,
23600,
297,
283,
87,
358,
267,
4090,
14,
952,
7863,
2737,
701,
1134,
13496,
60,
78,
358,
267,
4090,
14,
952,
7863,
675,
314,
450,
83,
3301,
367,
666,
60,
78,
7,
450,
666,
63,
694,
9,
267,
4090,
14,
952,
11894,
23726,
81,
1447,
7272,
78,
358,
267,
4090,
14,
952,
360,
18259,
275,
450,
83,
60,
78,
7,
450,
12896,
63,
515,
9,
267,
4090,
14,
952,
360,
793,
63,
1393,
275,
450,
83,
60,
78,
7,
450,
747,
14,
515,
14,
904,
8,
8644,
63,
515,
12,
283,
8644,
13,
1393,
14,
793,
1333,
267,
4090,
14,
1600,
342,
267,
340,
17480,
63,
3174,
26,
288,
291,
14,
1065,
360,
1850,
446,
2700,
1182,
1391,
15,
773,
15,
8644,
6331,
450,
83,
4805,
450,
12896,
63,
515,
9,
288,
291,
14,
928,
360,
8644,
358,
267,
587,
26,
288,
327,
362,
314,
2505,
399,
19313,
14292,
370,
675,
26,
288,
1101,
63,
2087,
275,
14969,
15218,
342,
288,
1101,
63,
2087,
14,
739,
2336,
6839,
15,
8644,
15,
23204,
14,
23600,
358,
288,
2505,
275,
1101,
63,
2087,
14,
362,
360,
1258,
297,
283,
2060,
358,
288,
327,
1343,
314,
12896,
477,
455,
265,
12,
2066,
12896,
543,
314,
1415,
16085,
5164,
6682,
1915,
1901,
652,
26,
288,
291,
14,
928,
360,
8644,
358,
288,
900,
14,
4532,
8,
709,
9,
327,
521,
367,
12896,
370,
1343,
288,
16085,
63,
1531,
275,
298,
7878,
8441,
3975,
1441,
11727,
28644,
8453,
39,
654,
5258,
627,
2795,
2296,
283,
23204
] |
[
1898,
334,
67,
9,
8315,
13,
8664,
603,
9414,
598,
26272,
1455,
921,
71,
26272,
14,
1308,
15,
199,
3,
199,
3,
8779,
365,
11882,
10009,
12,
2867,
402,
11204,
12,
370,
1263,
4954,
12408,
282,
199,
3,
1331,
402,
642,
2032,
436,
4568,
3794,
1584,
334,
1589,
199,
3,
298,
10337,
1288,
370,
7962,
315,
314,
2290,
1928,
10588,
12,
5893,
199,
3,
1928,
12305,
314,
4481,
370,
675,
12,
1331,
12,
2811,
12,
5389,
12,
2780,
12,
2153,
13,
199,
3,
28420,
12,
13473,
12,
436,
15,
269,
12743,
6866,
402,
314,
2290,
12,
436,
370,
11291,
199,
3,
12103,
370,
12676,
314,
2290,
365,
13985,
370,
886,
880,
12,
5420,
370,
314,
1699,
13,
199,
3,
28486,
3704,
26,
199,
3,
199,
3,
710,
3432,
4248,
4245,
436,
642,
4983,
4245,
10989,
506,
5120,
199,
3,
315,
1006,
6866,
503,
13393,
12468,
402,
314,
2290,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
7168,
199,
3,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
28471,
13,
199,
3,
28463,
12,
3092,
2381,
437,
3115,
3104,
2401,
13229,
14,
1621,
4825,
6461,
199,
3,
7000,
2334,
17632,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
221,
199,
3,
7061,
1621,
1261,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
199,
3,
5738,
1634,
1549,
1621,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
199,
3,
1621,
2334,
4141,
14,
199,
3,
199,
624,
199,
2765,
18535,
911,
3907,
12896,
13,
1000,
641,
376,
31631,
6844,
14,
199,
607,
10234,
370,
314,
3293,
12096,
4224,
701,
20932,
13,
362,
12,
652,
911,
199,
12344,
7908,
314,
892,
11200,
1654,
370,
3877,
652,
1159,
666,
1584,
315,
199,
65,
3365,
2909,
14,
221,
4885,
849,
12,
642,
365,
1182,
20481,
1325,
626,
883,
506,
199,
11786,
315,
314,
359,
20784,
61,
3420,
402,
314,
6055,
1101,
570,
3032,
199,
475,
314,
1256,
14,
199,
624,
199,
504,
6055,
14,
647,
13496,
14,
17047,
83,
14,
21151,
14,
17047,
492,
14089,
9230,
199,
646,
747,
199,
646,
6055,
199,
504,
14196,
492,
14969,
15218,
199,
646,
900,
199,
199,
2028,
8660,
275,
408,
199,
59,
20784,
61,
199,
1231,
63,
2060,
275,
665,
14117,
506,
1202,
465,
11200,
1738,
2505,
12,
849,
7179,
30,
199,
576,
63,
694,
275,
665,
1222,
666,
2935,
367,
11200,
12,
849,
365,
1182,
20481,
30,
199,
624,
199,
199,
533,
11200,
8,
27598,
304,
339,
347,
3907,
8,
277,
304,
267,
291,
14,
1065,
360,
6182,
13,
362,
1678,
358,
267,
291,
14,
1065,
360,
6182,
13,
362,
446,
89,
3907,
12896,
13,
1000,
297,
11705,
29,
549,
12,
4458,
63,
265,
63,
705,
29,
549,
9,
199,
199,
3,
259,
347,
663,
63,
1231,
63,
2060,
8,
277,
12,
2505,
29,
403,
304,
199,
3,
263,
340,
440,
2505,
26,
199,
3,
3322,
2505,
275,
6055,
14,
888,
14,
362,
360,
20784,
297,
283,
1231,
63,
2060,
358,
199,
3,
263,
340,
2505,
26,
199,
3,
3322,
291,
14,
1065,
360,
8644,
2113,
446,
85,
1738,
2505,
450,
83,
7,
450,
2505,
9,
199,
3,
263,
372,
2505,
339,
347,
1570,
63,
576,
63,
694,
8,
277,
12,
2505,
29,
403,
304,
267,
666,
63,
694,
275,
6055,
14,
888,
14,
362,
360,
20784,
297,
283,
576,
63,
694,
297,
1994,
20481,
358,
267,
17480,
63,
3174,
275,
756,
27,
267,
900,
14,
4532,
8,
709,
9,
327,
893,
316,
370,
3631,
12896,
9939,
2410,
22200,
652,
6918,
267,
327,
2136,
1929,
370,
3618,
5133,
12896,
8491,
314,
1738,
2933,
2544,
781,
14561,
652,
267,
327,
503,
4875,
7645,
911,
5992,
267,
284,
275,
378,
267,
1830,
291,
14,
1065,
480,
7878,
283,
10589,
7,
1204,
12896,
446,
85,
1738,
531,
1137,
378,
436,
284,
28,
21,
26,
288,
900,
14,
4532,
8,
21,
9,
288,
284,
275,
284,
435,
413,
267,
291,
14,
1065,
2336,
6839,
15,
826,
14,
68,
15,
8644,
3631,
358,
267,
291,
14,
1065,
480,
2051,
778,
446,
25,
12896,
531,
398,
12896,
63,
515,
275,
747,
14,
515,
14,
904,
8,
576,
63,
694,
12,
283,
8644,
358,
267,
340,
440,
747,
14,
515,
14,
2444,
8,
8644,
63,
515,
304,
288,
291,
14,
1065,
360,
8215,
450,
83,
7,
450,
12896,
63,
515,
9,
288,
17480,
63,
3174,
275,
715,
27,
267,
291,
14,
1065,
360,
20933,
446,
50,
12896,
26,
8644,
450,
83,
7,
450,
12896,
63,
515,
9,
267,
4090,
275,
1551,
2336,
6839,
15,
8644,
15,
2190,
14,
68,
15,
1180,
63,
20481,
14,
23600,
297,
283,
87,
358,
267,
4090,
14,
952,
7863,
2737,
701,
1134,
13496,
60,
78,
358,
267,
4090,
14,
952,
7863,
675,
314,
450,
83,
3301,
367,
666,
60,
78,
7,
450,
666,
63,
694,
9,
267,
4090,
14,
952,
11894,
23726,
81,
1447,
7272,
78,
358,
267,
4090,
14,
952,
360,
18259,
275,
450,
83,
60,
78,
7,
450,
12896,
63,
515,
9,
267,
4090,
14,
952,
360,
793,
63,
1393,
275,
450,
83,
60,
78,
7,
450,
747,
14,
515,
14,
904,
8,
8644,
63,
515,
12,
283,
8644,
13,
1393,
14,
793,
1333,
267,
4090,
14,
1600,
342,
267,
340,
17480,
63,
3174,
26,
288,
291,
14,
1065,
360,
1850,
446,
2700,
1182,
1391,
15,
773,
15,
8644,
6331,
450,
83,
4805,
450,
12896,
63,
515,
9,
288,
291,
14,
928,
360,
8644,
358,
267,
587,
26,
288,
327,
362,
314,
2505,
399,
19313,
14292,
370,
675,
26,
288,
1101,
63,
2087,
275,
14969,
15218,
342,
288,
1101,
63,
2087,
14,
739,
2336,
6839,
15,
8644,
15,
23204,
14,
23600,
358,
288,
2505,
275,
1101,
63,
2087,
14,
362,
360,
1258,
297,
283,
2060,
358,
288,
327,
1343,
314,
12896,
477,
455,
265,
12,
2066,
12896,
543,
314,
1415,
16085,
5164,
6682,
1915,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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
] |
Eksmo/calibre
|
src/calibre/gui2/store/stores/diesel_ebooks_plugin.py
|
1
|
4624
|
# -*- coding: utf-8 -*-
from __future__ import (unicode_literals, division, absolute_import, print_function)
__license__ = 'GPL 3'
__copyright__ = '2011, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en'
import random
import re
import urllib
from contextlib import closing
from lxml import html
from PyQt4.Qt import QUrl
from calibre import browser, url_slash_cleaner
from calibre.gui2 import open_url
from calibre.gui2.store import StorePlugin
from calibre.gui2.store.basic_config import BasicStoreConfig
from calibre.gui2.store.search_result import SearchResult
from calibre.gui2.store.web_store_dialog import WebStoreDialog
class DieselEbooksStore(BasicStoreConfig, StorePlugin):
def open(self, parent=None, detail_item=None, external=False):
url = 'http://www.diesel-ebooks.com/'
aff_id = '?aid=2049'
# Use Kovid's affiliate id 30% of the time.
if random.randint(1, 10) in (1, 2, 3):
aff_id = '?aid=2053'
detail_url = None
if detail_item:
detail_url = detail_item + aff_id
url = url + aff_id
if external or self.config.get('open_external', False):
open_url(QUrl(url_slash_cleaner(detail_url if detail_url else url)))
else:
d = WebStoreDialog(self.gui, url, parent, detail_url)
d.setWindowTitle(self.name)
d.set_tags(self.config.get('tags', ''))
d.exec_()
def search(self, query, max_results=10, timeout=60):
url = 'http://www.diesel-ebooks.com/index.php?page=seek&id[m]=&id[c]=scope%253Dinventory&id[q]=' + urllib.quote_plus(query)
br = browser()
counter = max_results
with closing(br.open(url, timeout=timeout)) as f:
doc = html.fromstring(f.read())
if doc.xpath('not(boolean(//select[contains(@id, "selection")]))'):
id = ''.join(doc.xpath('//div[@class="price_fat"]//a/@href'))
mo = re.search('(?<=id=).+?(?=&)', id)
if not mo:
yield None
id = mo.group()
cover_url = ''.join(doc.xpath('//div[@class="cover"]/a/@href'))
title = ''.join(doc.xpath('//div[@class="desc_fat"]//h1/text()'))
author = ''.join(doc.xpath('//div[@class="desc_fat"]//span[@itemprop="author"]/text()'))
price = ''.join(doc.xpath('//div[@class="price_fat"]//h1/text()'))
formats = ', '.join(doc.xpath('//div[@class="desc_fat"]//p[contains(text(), "Format")]/text()'))
a, b, formats = formats.partition('Format:')
drm = SearchResult.DRM_LOCKED
if 'drm free' in formats.lower():
drm = SearchResult.DRM_UNLOCKED
s = SearchResult()
s.cover_url = cover_url
s.title = title.strip()
s.author = author.strip()
s.price = price.strip()
s.detail_item = id.strip()
s.formats = formats
s.drm = drm
yield s
else:
for data in doc.xpath('//div[contains(@class, "item")]'):
if counter <= 0:
break
id = ''.join(data.xpath('div[@class="cover"]/a/@href'))
if not id or '/item/' not in id:
continue
cover_url = ''.join(data.xpath('div[@class="cover"]//img/@src'))
title = ''.join(data.xpath('.//div[@class="content"]//h2/a/text()'))
author = ''.join(data.xpath('.//div[@class="content"]/span//a/text()'))
price = ''
price_elem = data.xpath('.//div[@class="price_fat"]//h1/text()')
if price_elem:
price = price_elem[0]
formats = ', '.join(data.xpath('.//div[@class="book-info"]//text()')).strip()
a, b, formats = formats.partition('Format:')
drm = SearchResult.DRM_LOCKED
if 'drm free' in formats.lower():
drm = SearchResult.DRM_UNLOCKED
counter -= 1
s = SearchResult()
s.cover_url = cover_url
s.title = title.strip()
s.author = author.strip()
s.price = price.strip()
s.detail_item = id.strip()
s.formats = formats
s.drm = drm
yield s
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
334,
2975,
63,
5955,
12,
4629,
12,
3679,
63,
646,
12,
870,
63,
1593,
9,
199,
199,
363,
1682,
363,
275,
283,
12006,
650,
7,
199,
363,
7307,
363,
275,
283,
8128,
12,
17815,
428,
595,
976,
665,
20216,
32,
78,
1225,
2906,
20877,
68,
14,
957,
3524,
199,
363,
21841,
363,
275,
283,
26854,
655,
7,
199,
199,
646,
2196,
199,
646,
295,
199,
646,
4011,
199,
504,
15502,
492,
11261,
199,
199,
504,
14490,
492,
3517,
199,
199,
504,
14084,
20,
14,
4238,
492,
1413,
6417,
199,
199,
504,
19238,
492,
7042,
12,
1166,
63,
7001,
63,
3118,
281,
199,
504,
19238,
14,
5885,
18,
492,
1551,
63,
633,
199,
504,
19238,
14,
5885,
18,
14,
1617,
492,
13874,
5061,
199,
504,
19238,
14,
5885,
18,
14,
1617,
14,
4316,
63,
888,
492,
10082,
5502,
2028,
199,
504,
19238,
14,
5885,
18,
14,
1617,
14,
1733,
63,
1099,
492,
8730,
2889,
199,
504,
19238,
14,
5885,
18,
14,
1617,
14,
2520,
63,
1617,
63,
7196,
492,
6001,
5502,
5619,
199,
199,
533,
577,
1873,
5891,
37,
8858,
5502,
8,
6845,
5502,
2028,
12,
13874,
5061,
304,
339,
347,
1551,
8,
277,
12,
1676,
29,
403,
12,
10093,
63,
1053,
29,
403,
12,
5957,
29,
797,
304,
267,
1166,
275,
283,
1014,
921,
1544,
14,
15130,
5891,
13,
69,
8858,
14,
957,
4805,
398,
9876,
63,
344,
275,
8720,
21745,
29,
6686,
25,
7,
267,
327,
3645,
1804,
79,
5017,
1159,
29172,
323,
1305,
4233,
5,
402,
314,
900,
14,
267,
340,
2196,
14,
8393,
8,
17,
12,
1616,
9,
315,
334,
17,
12,
499,
12,
650,
304,
288,
9876,
63,
344,
275,
8720,
21745,
29,
1165,
2481,
7,
398,
10093,
63,
633,
275,
488,
267,
340,
10093,
63,
1053,
26,
288,
10093,
63,
633,
275,
10093,
63,
1053,
435,
9876,
63,
344,
267,
1166,
275,
1166,
435,
9876,
63,
344,
398,
340,
5957,
503,
291,
14,
888,
14,
362,
360,
1490,
63,
5159,
297,
756,
304,
288,
1551,
63,
633,
8,
2328,
4308,
8,
633,
63,
7001,
63,
3118,
281,
8,
5506,
63,
633,
340,
10093,
63,
633,
587,
1166,
1724,
267,
587,
26,
288,
366,
275,
6001,
5502,
5619,
8,
277,
14,
5885,
12,
1166,
12,
1676,
12,
10093,
63,
633,
9,
288,
366,
14,
30601,
8,
277,
14,
354,
9,
288,
366,
14,
409,
63,
2969,
8,
277,
14,
888,
14,
362,
360,
2969,
297,
12381,
288,
366,
14,
1628,
12798,
339,
347,
2754,
8,
277,
12,
1827,
12,
1390,
63,
2604,
29,
709,
12,
2653,
29,
2259,
304,
267,
1166,
275,
283,
1014,
921,
1544,
14,
15130,
5891,
13,
69,
8858,
14,
957,
15,
1080,
14,
8624,
31,
1606,
29,
5507,
6,
344,
59,
77,
10404,
6,
344,
59,
67,
10404,
2645,
5,
3781,
36,
7212,
6,
344,
59,
81,
61,
534,
435,
4011,
14,
3513,
63,
6666,
8,
1131,
9,
398,
11665,
275,
7042,
342,
398,
7055,
275,
1390,
63,
2604,
267,
543,
11261,
8,
3289,
14,
1490,
8,
633,
12,
2653,
29,
2593,
430,
465,
289,
26,
288,
1382,
275,
3517,
14,
13521,
8,
70,
14,
739,
1012,
953,
340,
1382,
14,
8006,
360,
1397,
8,
4871,
8,
501,
2416,
59,
6134,
8,
32,
344,
12,
298,
5592,
531,
2459,
735,
355,
1305,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
4777,
63,
23156,
937,
501,
65,
15,
32,
6399,
1333,
355,
1303,
275,
295,
14,
1733,
28353,
12932,
344,
29,
680,
23778,
2229,
19167,
3196,
1305,
9,
355,
340,
440,
1303,
26,
490,
1995,
488,
355,
1305,
275,
1303,
14,
923,
342,
2234,
8486,
63,
633,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
5899,
937,
15,
65,
15,
32,
6399,
1333,
2234,
2538,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
3257,
63,
23156,
937,
501,
72,
17,
15,
505,
342,
1333,
355,
4132,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
3257,
63,
23156,
937,
501,
3751,
14251,
73,
808,
2675,
628,
2502,
937,
15,
505,
342,
1333,
355,
8033,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
4777,
63,
23156,
937,
501,
72,
17,
15,
505,
342,
1333,
2234,
6752,
275,
1656,
1987,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
3257,
63,
23156,
937,
501,
80,
59,
6134,
8,
505,
1062,
298,
3484,
11323,
15,
505,
342,
1333,
355,
282,
12,
330,
12,
6752,
275,
6752,
14,
5312,
360,
3484,
10993,
2234,
366,
5682,
275,
8730,
2889,
14,
22195,
63,
4406,
1149,
355,
340,
283,
5012,
77,
2867,
7,
315,
6752,
14,
2325,
837,
490,
366,
5682,
275,
8730,
2889,
14,
22195,
63,
1734,
4406,
1149,
2234,
308,
275,
8730,
2889,
342,
355,
308,
14,
5899,
63,
633,
275,
8486,
63,
633,
355,
308,
14,
1213,
275,
2538,
14,
1913,
342,
355,
308,
14,
2502,
275,
4132,
14,
1913,
342,
355,
308,
14,
4777,
275,
8033,
14,
1913,
342,
355,
308,
14,
5506,
63,
1053,
275,
1305,
14,
1913,
342,
355,
308,
14,
6321,
275,
6752,
355,
308,
14,
5012,
77,
275,
366,
5682,
2234,
1995,
308,
288,
587,
26,
355,
367,
666,
315,
1382,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
533,
12,
298,
1053,
11323,
735,
490,
340,
7055,
2695,
378,
26,
717,
2059,
4951,
1305,
275,
6522,
904,
8,
576,
14,
8006,
360,
3015,
14251,
533,
628,
5899,
937,
15,
65,
15,
32,
6399,
1333,
490,
340,
440,
1305,
503,
1994,
1053,
4805,
440,
315,
1305,
26,
717,
1980,
4951,
8486,
63,
633,
275,
6522,
904,
8,
576,
14,
8006,
360,
3015,
14251,
533,
628,
5899,
937,
501,
4060,
15,
32,
2164,
1333,
4951,
2538,
275,
6522,
904,
8,
576,
14,
8006,
29995,
3015,
14251,
533,
628,
1317,
937,
501,
72,
18,
15,
65,
15,
505,
342,
1333,
490,
4132,
275,
6522,
904,
8,
576,
14,
8006,
29995,
3015,
14251,
533,
628,
1317,
937,
15,
3751,
501,
65,
15,
505,
342,
1333,
490,
8033,
275,
2125,
490,
8033,
63,
6086,
275,
666,
14,
8006,
29995,
3015,
14251,
533,
628,
4777,
63
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
199,
504,
636,
2443,
363,
492,
334,
2975,
63,
5955,
12,
4629,
12,
3679,
63,
646,
12,
870,
63,
1593,
9,
199,
199,
363,
1682,
363,
275,
283,
12006,
650,
7,
199,
363,
7307,
363,
275,
283,
8128,
12,
17815,
428,
595,
976,
665,
20216,
32,
78,
1225,
2906,
20877,
68,
14,
957,
3524,
199,
363,
21841,
363,
275,
283,
26854,
655,
7,
199,
199,
646,
2196,
199,
646,
295,
199,
646,
4011,
199,
504,
15502,
492,
11261,
199,
199,
504,
14490,
492,
3517,
199,
199,
504,
14084,
20,
14,
4238,
492,
1413,
6417,
199,
199,
504,
19238,
492,
7042,
12,
1166,
63,
7001,
63,
3118,
281,
199,
504,
19238,
14,
5885,
18,
492,
1551,
63,
633,
199,
504,
19238,
14,
5885,
18,
14,
1617,
492,
13874,
5061,
199,
504,
19238,
14,
5885,
18,
14,
1617,
14,
4316,
63,
888,
492,
10082,
5502,
2028,
199,
504,
19238,
14,
5885,
18,
14,
1617,
14,
1733,
63,
1099,
492,
8730,
2889,
199,
504,
19238,
14,
5885,
18,
14,
1617,
14,
2520,
63,
1617,
63,
7196,
492,
6001,
5502,
5619,
199,
199,
533,
577,
1873,
5891,
37,
8858,
5502,
8,
6845,
5502,
2028,
12,
13874,
5061,
304,
339,
347,
1551,
8,
277,
12,
1676,
29,
403,
12,
10093,
63,
1053,
29,
403,
12,
5957,
29,
797,
304,
267,
1166,
275,
283,
1014,
921,
1544,
14,
15130,
5891,
13,
69,
8858,
14,
957,
4805,
398,
9876,
63,
344,
275,
8720,
21745,
29,
6686,
25,
7,
267,
327,
3645,
1804,
79,
5017,
1159,
29172,
323,
1305,
4233,
5,
402,
314,
900,
14,
267,
340,
2196,
14,
8393,
8,
17,
12,
1616,
9,
315,
334,
17,
12,
499,
12,
650,
304,
288,
9876,
63,
344,
275,
8720,
21745,
29,
1165,
2481,
7,
398,
10093,
63,
633,
275,
488,
267,
340,
10093,
63,
1053,
26,
288,
10093,
63,
633,
275,
10093,
63,
1053,
435,
9876,
63,
344,
267,
1166,
275,
1166,
435,
9876,
63,
344,
398,
340,
5957,
503,
291,
14,
888,
14,
362,
360,
1490,
63,
5159,
297,
756,
304,
288,
1551,
63,
633,
8,
2328,
4308,
8,
633,
63,
7001,
63,
3118,
281,
8,
5506,
63,
633,
340,
10093,
63,
633,
587,
1166,
1724,
267,
587,
26,
288,
366,
275,
6001,
5502,
5619,
8,
277,
14,
5885,
12,
1166,
12,
1676,
12,
10093,
63,
633,
9,
288,
366,
14,
30601,
8,
277,
14,
354,
9,
288,
366,
14,
409,
63,
2969,
8,
277,
14,
888,
14,
362,
360,
2969,
297,
12381,
288,
366,
14,
1628,
12798,
339,
347,
2754,
8,
277,
12,
1827,
12,
1390,
63,
2604,
29,
709,
12,
2653,
29,
2259,
304,
267,
1166,
275,
283,
1014,
921,
1544,
14,
15130,
5891,
13,
69,
8858,
14,
957,
15,
1080,
14,
8624,
31,
1606,
29,
5507,
6,
344,
59,
77,
10404,
6,
344,
59,
67,
10404,
2645,
5,
3781,
36,
7212,
6,
344,
59,
81,
61,
534,
435,
4011,
14,
3513,
63,
6666,
8,
1131,
9,
398,
11665,
275,
7042,
342,
398,
7055,
275,
1390,
63,
2604,
267,
543,
11261,
8,
3289,
14,
1490,
8,
633,
12,
2653,
29,
2593,
430,
465,
289,
26,
288,
1382,
275,
3517,
14,
13521,
8,
70,
14,
739,
1012,
953,
340,
1382,
14,
8006,
360,
1397,
8,
4871,
8,
501,
2416,
59,
6134,
8,
32,
344,
12,
298,
5592,
531,
2459,
735,
355,
1305,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
4777,
63,
23156,
937,
501,
65,
15,
32,
6399,
1333,
355,
1303,
275,
295,
14,
1733,
28353,
12932,
344,
29,
680,
23778,
2229,
19167,
3196,
1305,
9,
355,
340,
440,
1303,
26,
490,
1995,
488,
355,
1305,
275,
1303,
14,
923,
342,
2234,
8486,
63,
633,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
5899,
937,
15,
65,
15,
32,
6399,
1333,
2234,
2538,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
3257,
63,
23156,
937,
501,
72,
17,
15,
505,
342,
1333,
355,
4132,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
3257,
63,
23156,
937,
501,
3751,
14251,
73,
808,
2675,
628,
2502,
937,
15,
505,
342,
1333,
355,
8033,
275,
6522,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
4777,
63,
23156,
937,
501,
72,
17,
15,
505,
342,
1333,
2234,
6752,
275,
1656,
1987,
904,
8,
1301,
14,
8006,
15079,
3015,
14251,
533,
628,
3257,
63,
23156,
937,
501,
80,
59,
6134,
8,
505,
1062,
298,
3484,
11323,
15,
505,
342,
1333,
355,
282,
12,
330,
12,
6752,
275,
6752,
14,
5312,
360,
3484,
10993,
2234,
366,
5682,
275,
8730,
2889,
14,
22195,
63,
4406,
1149,
355,
340,
283,
5012,
77,
2867,
7,
315,
6752,
14,
2325,
837,
490,
366,
5682,
275,
8730,
2889,
14,
22195,
63,
1734,
4406,
1149,
2234,
308,
275,
8730,
2889,
342,
355,
308,
14,
5899,
63,
633,
275,
8486,
63,
633,
355,
308,
14,
1213,
275,
2538,
14,
1913,
342,
355,
308,
14,
2502,
275,
4132,
14,
1913,
342,
355,
308,
14,
4777,
275,
8033,
14,
1913,
342,
355,
308,
14,
5506,
63,
1053,
275,
1305,
14,
1913,
342,
355,
308,
14,
6321,
275,
6752,
355,
308,
14,
5012,
77,
275,
366,
5682,
2234,
1995,
308,
288,
587,
26,
355,
367,
666,
315,
1382,
14,
8006,
15079,
3015,
59,
6134,
8,
32,
533,
12,
298,
1053,
11323,
735,
490,
340,
7055,
2695,
378,
26,
717,
2059,
4951,
1305,
275,
6522,
904,
8,
576,
14,
8006,
360,
3015,
14251,
533,
628,
5899,
937,
15,
65,
15,
32,
6399,
1333,
490,
340,
440,
1305,
503,
1994,
1053,
4805,
440,
315,
1305,
26,
717,
1980,
4951,
8486,
63,
633,
275,
6522,
904,
8,
576,
14,
8006,
360,
3015,
14251,
533,
628,
5899,
937,
501,
4060,
15,
32,
2164,
1333,
4951,
2538,
275,
6522,
904,
8,
576,
14,
8006,
29995,
3015,
14251,
533,
628,
1317,
937,
501,
72,
18,
15,
65,
15,
505,
342,
1333,
490,
4132,
275,
6522,
904,
8,
576,
14,
8006,
29995,
3015,
14251,
533,
628,
1317,
937,
15,
3751,
501,
65,
15,
505,
342,
1333,
490,
8033,
275,
2125,
490,
8033,
63,
6086,
275,
666,
14,
8006,
29995,
3015,
14251,
533,
628,
4777,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
yfried/ansible
|
test/units/modules/network/f5/test_bigip_software_update.py
|
4
|
3711
|
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 F5 Networks Inc.
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import json
import sys
from nose.plugins.skip import SkipTest
if sys.version_info < (2, 7):
raise SkipTest("F5 Ansible modules require Python >= 2.7")
from ansible.module_utils.basic import AnsibleModule
try:
from library.modules.bigip_software_update import ApiParameters
from library.modules.bigip_software_update import ModuleParameters
from library.modules.bigip_software_update import ModuleManager
from library.modules.bigip_software_update import ArgumentSpec
# In Ansible 2.8, Ansible changed import paths.
from test.units.compat import unittest
from test.units.compat.mock import Mock
from test.units.compat.mock import patch
from test.units.modules.utils import set_module_args
except ImportError:
try:
from ansible.modules.network.f5.bigip_software_update import ApiParameters
from ansible.modules.network.f5.bigip_software_update import ModuleParameters
from ansible.modules.network.f5.bigip_software_update import ModuleManager
from ansible.modules.network.f5.bigip_software_update import ArgumentSpec
# Ansible 2.8 imports
from units.compat import unittest
from units.compat.mock import Mock
from units.compat.mock import patch
from units.modules.utils import set_module_args
except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {}
def load_fixture(name):
path = os.path.join(fixture_path, name)
if path in fixture_data:
return fixture_data[path]
with open(path) as f:
data = f.read()
try:
data = json.loads(data)
except Exception:
pass
fixture_data[path] = data
return data
class TestParameters(unittest.TestCase):
def test_module_parameters(self):
args = dict(
auto_check=True,
frequency="daily"
)
p = ModuleParameters(params=args)
assert p.auto_check == 'enabled'
assert p.frequency == 'daily'
def test_api_parameters(self):
args = dict(
autoCheck="enabled",
frequency="daily"
)
p = ApiParameters(params=args)
assert p.auto_check == 'enabled'
assert p.frequency == 'daily'
class TestManager(unittest.TestCase):
def setUp(self):
self.spec = ArgumentSpec()
def test_update(self, *args):
# Configure the arguments that would be sent to the Ansible module
set_module_args(dict(
auto_check='no',
auto_phone_home='no',
password='password',
server='localhost',
user='admin'
))
# Configure the parameters that would be returned by querying the
# remote device
current = ApiParameters(params=load_fixture('load_sys_software_update.json'))
module = AnsibleModule(
argument_spec=self.spec.argument_spec,
supports_check_mode=self.spec.supports_check_mode
)
mm = ModuleManager(module=module)
# Override methods to force specific logic in the module to happen
mm.update_on_device = Mock(return_value=True)
mm.read_current_from_device = Mock(return_value=current)
results = mm.exec_module()
assert results['changed'] is True
assert results['auto_check'] is False
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
9708,
481,
21,
17138,
3277,
14,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
2022,
199,
646,
984,
199,
199,
504,
11354,
14,
5265,
14,
2759,
492,
18795,
199,
692,
984,
14,
1023,
63,
815,
665,
334,
18,
12,
1520,
304,
272,
746,
18795,
480,
38,
21,
2622,
4621,
4409,
2018,
2356,
499,
14,
23,
531,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
199,
893,
26,
272,
687,
3555,
14,
3112,
14,
17833,
63,
15619,
63,
873,
492,
31145,
272,
687,
3555,
14,
3112,
14,
17833,
63,
15619,
63,
873,
492,
5673,
5976,
272,
687,
3555,
14,
3112,
14,
17833,
63,
15619,
63,
873,
492,
24118,
272,
687,
3555,
14,
3112,
14,
17833,
63,
15619,
63,
873,
492,
28405,
339,
327,
1010,
2622,
499,
14,
24,
12,
2622,
2896,
492,
3792,
14,
272,
687,
511,
14,
5260,
14,
5819,
492,
2882,
272,
687,
511,
14,
5260,
14,
5819,
14,
1805,
492,
4420,
272,
687,
511,
14,
5260,
14,
5819,
14,
1805,
492,
3371,
339,
687,
511,
14,
5260,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
199,
2590,
3545,
26,
272,
862,
26,
267,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
15619,
63,
873,
492,
31145,
267,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
15619,
63,
873,
492,
5673,
5976,
267,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
15619,
63,
873,
492,
24118,
267,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
15619,
63,
873,
492,
28405,
398,
327,
2622,
499,
14,
24,
8925,
267,
687,
6204,
14,
5819,
492,
2882,
267,
687,
6204,
14,
5819,
14,
1805,
492,
4420,
267,
687,
6204,
14,
5819,
14,
1805,
492,
3371,
398,
687,
6204,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
272,
871,
3545,
26,
267,
746,
18795,
480,
38,
21,
2622,
4621,
4409,
314,
289,
21,
13,
9277,
2018,
3555,
531,
199,
199,
5997,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
8769,
358,
199,
5997,
63,
576,
275,
1052,
421,
199,
318,
2248,
63,
5997,
8,
354,
304,
272,
931,
275,
747,
14,
515,
14,
904,
8,
5997,
63,
515,
12,
536,
9,
339,
340,
931,
315,
10949,
63,
576,
26,
267,
372,
10949,
63,
576,
59,
515,
61,
339,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
666,
275,
289,
14,
739,
342,
339,
862,
26,
267,
666,
275,
2022,
14,
3640,
8,
576,
9,
272,
871,
2186,
26,
267,
986,
339,
10949,
63,
576,
59,
515,
61,
275,
666,
272,
372,
666,
421,
199,
533,
1379,
5976,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
578,
63,
3214,
8,
277,
304,
267,
1249,
275,
1211,
8,
288,
2599,
63,
1074,
29,
549,
12,
288,
9857,
628,
18621,
2,
267,
776,
267,
299,
275,
5673,
5976,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
2495,
63,
1074,
508,
283,
3827,
7,
267,
702,
299,
14,
11132,
508,
283,
18621,
7,
339,
347,
511,
63,
1246,
63,
3214,
8,
277,
304,
267,
1249,
275,
1211,
8,
288,
2599,
1799,
628,
3827,
401,
288,
9857,
628,
18621,
2,
267,
776,
267,
299,
275,
31145,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
2495,
63,
1074,
508,
283,
3827,
7,
267,
702,
299,
14,
11132,
508,
283,
18621,
7,
421,
199,
533,
1379,
2988,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1650,
275,
28405,
342,
339,
347,
511,
63,
873,
8,
277,
12,
627,
589,
304,
267,
327,
15453,
314,
2368,
626,
3955,
506,
4847,
370,
314,
2622,
859,
267,
663,
63,
578,
63,
589,
8,
807,
8,
288,
2599,
63,
1074,
534,
889,
297,
288,
2599,
63,
9339,
63,
4219,
534,
889,
297,
288,
2505,
534,
2060,
297,
288,
1654,
534,
5967,
297,
288,
922,
534,
2113,
7,
267,
5082,
398,
327,
15453,
314,
2633,
626,
3955,
506,
2138,
701,
27405,
314,
267,
327,
3982,
2243,
267,
1453,
275,
31145,
8,
1162,
29,
912,
63,
5997,
360,
912,
63,
1274,
63,
15619,
63,
873,
14,
1001,
1333,
398,
859,
275,
6953,
8,
288,
1423,
63,
1650,
29,
277,
14,
1650,
14,
2094,
63,
1650,
12,
288,
5171,
63,
1074,
63,
632,
29,
277,
14,
1650,
14,
9823,
63,
1074,
63,
632,
267,
776,
267,
8562,
275,
24118,
8,
578,
29,
578,
9,
398,
327,
11041,
3102,
370,
3542,
2488,
9661,
315,
314,
859,
370,
5992,
267,
8562,
14,
873,
63,
265,
63,
1782,
275,
4420,
8,
1107,
63,
585,
29,
549,
9,
267,
8562,
14,
739,
63,
1818,
63,
504,
63,
1782,
275,
4420,
8,
1107,
63,
585,
29,
1818,
9,
398,
2058,
275,
8562,
14,
1628,
63,
578,
342,
398,
702,
2058,
459,
2489,
418,
365,
715,
267,
702,
2058,
459,
2495,
63,
1074,
418,
365,
756,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
1898,
334,
67,
9,
9708,
481,
21,
17138,
3277,
14,
199,
3,
1664,
1696,
1684,
844,
373,
19,
14,
16,
334,
3239,
9685,
503,
4178,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
15,
11692,
13,
19,
14,
16,
14,
2424,
9,
199,
199,
504,
636,
2443,
363,
492,
334,
6116,
63,
646,
12,
4629,
12,
870,
63,
1593,
9,
199,
363,
6577,
363,
275,
730,
199,
199,
646,
747,
199,
646,
2022,
199,
646,
984,
199,
199,
504,
11354,
14,
5265,
14,
2759,
492,
18795,
199,
692,
984,
14,
1023,
63,
815,
665,
334,
18,
12,
1520,
304,
272,
746,
18795,
480,
38,
21,
2622,
4621,
4409,
2018,
2356,
499,
14,
23,
531,
199,
199,
504,
3242,
14,
578,
63,
1208,
14,
4316,
492,
6953,
199,
199,
893,
26,
272,
687,
3555,
14,
3112,
14,
17833,
63,
15619,
63,
873,
492,
31145,
272,
687,
3555,
14,
3112,
14,
17833,
63,
15619,
63,
873,
492,
5673,
5976,
272,
687,
3555,
14,
3112,
14,
17833,
63,
15619,
63,
873,
492,
24118,
272,
687,
3555,
14,
3112,
14,
17833,
63,
15619,
63,
873,
492,
28405,
339,
327,
1010,
2622,
499,
14,
24,
12,
2622,
2896,
492,
3792,
14,
272,
687,
511,
14,
5260,
14,
5819,
492,
2882,
272,
687,
511,
14,
5260,
14,
5819,
14,
1805,
492,
4420,
272,
687,
511,
14,
5260,
14,
5819,
14,
1805,
492,
3371,
339,
687,
511,
14,
5260,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
199,
2590,
3545,
26,
272,
862,
26,
267,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
15619,
63,
873,
492,
31145,
267,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
15619,
63,
873,
492,
5673,
5976,
267,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
15619,
63,
873,
492,
24118,
267,
687,
3242,
14,
3112,
14,
1200,
14,
70,
21,
14,
17833,
63,
15619,
63,
873,
492,
28405,
398,
327,
2622,
499,
14,
24,
8925,
267,
687,
6204,
14,
5819,
492,
2882,
267,
687,
6204,
14,
5819,
14,
1805,
492,
4420,
267,
687,
6204,
14,
5819,
14,
1805,
492,
3371,
398,
687,
6204,
14,
3112,
14,
1208,
492,
663,
63,
578,
63,
589,
272,
871,
3545,
26,
267,
746,
18795,
480,
38,
21,
2622,
4621,
4409,
314,
289,
21,
13,
9277,
2018,
3555,
531,
199,
199,
5997,
63,
515,
275,
747,
14,
515,
14,
904,
8,
736,
14,
515,
14,
3475,
3460,
493,
10139,
283,
8769,
358,
199,
5997,
63,
576,
275,
1052,
421,
199,
318,
2248,
63,
5997,
8,
354,
304,
272,
931,
275,
747,
14,
515,
14,
904,
8,
5997,
63,
515,
12,
536,
9,
339,
340,
931,
315,
10949,
63,
576,
26,
267,
372,
10949,
63,
576,
59,
515,
61,
339,
543,
1551,
8,
515,
9,
465,
289,
26,
267,
666,
275,
289,
14,
739,
342,
339,
862,
26,
267,
666,
275,
2022,
14,
3640,
8,
576,
9,
272,
871,
2186,
26,
267,
986,
339,
10949,
63,
576,
59,
515,
61,
275,
666,
272,
372,
666,
421,
199,
533,
1379,
5976,
8,
2796,
14,
1746,
304,
272,
347,
511,
63,
578,
63,
3214,
8,
277,
304,
267,
1249,
275,
1211,
8,
288,
2599,
63,
1074,
29,
549,
12,
288,
9857,
628,
18621,
2,
267,
776,
267,
299,
275,
5673,
5976,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
2495,
63,
1074,
508,
283,
3827,
7,
267,
702,
299,
14,
11132,
508,
283,
18621,
7,
339,
347,
511,
63,
1246,
63,
3214,
8,
277,
304,
267,
1249,
275,
1211,
8,
288,
2599,
1799,
628,
3827,
401,
288,
9857,
628,
18621,
2,
267,
776,
267,
299,
275,
31145,
8,
1162,
29,
589,
9,
267,
702,
299,
14,
2495,
63,
1074,
508,
283,
3827,
7,
267,
702,
299,
14,
11132,
508,
283,
18621,
7,
421,
199,
533,
1379,
2988,
8,
2796,
14,
1746,
304,
339,
347,
3613,
8,
277,
304,
267,
291,
14,
1650,
275,
28405,
342,
339,
347,
511,
63,
873,
8,
277,
12,
627,
589,
304,
267,
327,
15453,
314,
2368,
626,
3955,
506,
4847,
370,
314,
2622,
859,
267,
663,
63,
578,
63,
589,
8,
807,
8,
288,
2599,
63,
1074,
534,
889,
297,
288,
2599,
63,
9339,
63,
4219,
534,
889,
297,
288,
2505,
534,
2060,
297,
288,
1654,
534,
5967,
297,
288,
922,
534,
2113,
7,
267,
5082,
398,
327,
15453,
314,
2633,
626,
3955,
506,
2138,
701,
27405,
314,
267,
327,
3982,
2243,
267,
1453,
275,
31145,
8,
1162,
29,
912,
63,
5997,
360,
912,
63,
1274,
63,
15619,
63,
873,
14,
1001,
1333,
398,
859,
275,
6953,
8,
288,
1423,
63,
1650,
29,
277,
14,
1650,
14,
2094,
63,
1650,
12,
288,
5171,
63,
1074,
63,
632,
29,
277,
14,
1650,
14,
9823,
63,
1074,
63,
632,
267,
776,
267,
8562,
275,
24118,
8,
578,
29,
578,
9,
398,
327,
11041,
3102,
370,
3542,
2488,
9661,
315,
314,
859,
370,
5992,
267,
8562,
14,
873,
63,
265,
63,
1782,
275,
4420,
8,
1107,
63,
585,
29,
549,
9,
267,
8562,
14,
739,
63,
1818,
63,
504,
63,
1782,
275,
4420,
8,
1107,
63,
585,
29,
1818,
9,
398,
2058,
275,
8562,
14,
1628,
63,
578,
342,
398,
702,
2058,
459,
2489,
418,
365,
715,
267,
702,
2058,
459,
2495,
63,
1074,
418,
365,
756,
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,
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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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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
adamwwt/chvac
|
venv/lib/python2.7/site-packages/pip/_vendor/requests/packages/charade/langcyrillicmodel.py
|
2762
|
17725
|
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Mark Pilgrim - port to Python
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
######################### END LICENSE BLOCK #########################
# KOI8-R language model
# Character Mapping Table:
KOI8R_CharToOrderMap = (
255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, # 80
207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, # 90
223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, # a0
238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, # b0
27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, # c0
15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, # d0
59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, # e0
35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, # f0
)
win1251_CharToOrderMap = (
255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253,
37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
)
latin5_CharToOrderMap = (
255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,
)
macCyrillic_CharToOrderMap = (
255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16,
3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255,
)
IBM855_CharToOrderMap = (
255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205,
206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70,
3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219,
220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229,
230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243,
8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248,
43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249,
250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255,
)
IBM866_CharToOrderMap = (
255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10
253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20
252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30
253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40
155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50
253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60
67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70
37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,
45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,
3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,
191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,
207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,
223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,
9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,
239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,
)
# Model Table:
# total sequences: 100%
# first 512 sequences: 97.6601%
# first 1024 sequences: 2.3389%
# rest sequences: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0,0,0,0,0,1,0,1,1,0,1,0,0,0,
0,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
)
Koi8rModel = {
'charToOrderMap': KOI8R_CharToOrderMap,
'precedenceMatrix': RussianLangModel,
'mTypicalPositiveRatio': 0.976601,
'keepEnglishLetter': False,
'charsetName': "KOI8-R"
}
Win1251CyrillicModel = {
'charToOrderMap': win1251_CharToOrderMap,
'precedenceMatrix': RussianLangModel,
'mTypicalPositiveRatio': 0.976601,
'keepEnglishLetter': False,
'charsetName': "windows-1251"
}
Latin5CyrillicModel = {
'charToOrderMap': latin5_CharToOrderMap,
'precedenceMatrix': RussianLangModel,
'mTypicalPositiveRatio': 0.976601,
'keepEnglishLetter': False,
'charsetName': "ISO-8859-5"
}
MacCyrillicModel = {
'charToOrderMap': macCyrillic_CharToOrderMap,
'precedenceMatrix': RussianLangModel,
'mTypicalPositiveRatio': 0.976601,
'keepEnglishLetter': False,
'charsetName': "MacCyrillic"
};
Ibm866Model = {
'charToOrderMap': IBM866_CharToOrderMap,
'precedenceMatrix': RussianLangModel,
'mTypicalPositiveRatio': 0.976601,
'keepEnglishLetter': False,
'charsetName': "IBM866"
}
Ibm855Model = {
'charToOrderMap': IBM855_CharToOrderMap,
'precedenceMatrix': RussianLangModel,
'mTypicalPositiveRatio': 0.976601,
'keepEnglishLetter': False,
'charsetName': "IBM855"
}
# flake8: noqa
|
mit
|
[
6565,
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
13338,
707,
1890,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
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,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
3,
1804,
47,
41,
24,
13,
50,
2637,
1402,
199,
3,
17660,
12340,
6957,
26,
199,
24839,
41,
24,
50,
63,
24516,
275,
334,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
221,
327,
8733,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
221,
327,
1616,
199,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
3388,
199,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
4233,
199,
3781,
12,
12199,
12,
12289,
12,
9862,
12,
11731,
12,
11432,
12,
11160,
12,
10834,
12,
10721,
12,
8251,
12,
12768,
12,
11024,
12,
9720,
12,
12034,
12,
13098,
12,
10478,
12,
221,
327,
6335,
199,
11520,
12,
11309,
12,
10823,
12,
11240,
12,
9327,
12,
8488,
12,
12285,
12,
12438,
12,
11931,
12,
8982,
12,
10355,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
5238,
199,
3781,
12,
17245,
12,
10419,
12,
14157,
12,
12478,
12,
11738,
12,
9892,
12,
14646,
12,
10848,
12,
5049,
12,
10216,
12,
8881,
12,
8375,
12,
15323,
12,
11175,
12,
14610,
12,
221,
327,
5212,
199,
13296,
12,
10699,
12,
14679,
12,
18525,
12,
7663,
12,
12851,
12,
13734,
12,
12894,
12,
12363,
12,
10078,
12,
10233,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
10045,
199,
12632,
12,
5756,
12,
13015,
12,
10860,
12,
11874,
12,
10800,
12,
11165,
12,
10905,
12,
7155,
12,
1840,
12,
1797,
12,
4999,
12,
11341,
12,
6686,
12,
10629,
12,
11089,
12,
221,
327,
5939,
199,
10744,
12,
10630,
12,
11303,
12,
12725,
12,
12832,
12,
11722,
12,
14271,
12,
6886,
12,
7842,
12,
9669,
12,
9335,
12,
9252,
12,
8867,
12,
11174,
12,
11564,
12,
9485,
12,
221,
327,
9137,
199,
11583,
12,
8731,
12,
10932,
12,
10851,
12,
11085,
12,
11385,
12,
12048,
12,
11182,
12,
9687,
12,
11921,
12,
8001,
12,
10034,
12,
5533,
12,
8276,
12,
10008,
12,
10638,
12,
221,
327,
282,
16,
199,
12332,
12,
9803,
12,
9873,
12,
13571,
12,
13212,
12,
13440,
12,
11603,
12,
11677,
12,
11440,
12,
11717,
12,
11242,
12,
11032,
12,
7991,
12,
12140,
12,
6390,
12,
3781,
12,
221,
327,
330,
16,
199,
8087,
12,
221,
650,
12,
7829,
12,
7294,
12,
4944,
12,
221,
499,
12,
10551,
12,
5851,
12,
7875,
12,
221,
841,
12,
6546,
12,
4119,
12,
221,
1695,
12,
3144,
12,
221,
959,
12,
221,
413,
12,
221,
327,
286,
16,
199,
4114,
12,
3193,
12,
221,
1749,
12,
221,
1520,
12,
221,
1227,
12,
4329,
12,
5504,
12,
1616,
12,
5557,
12,
6155,
12,
3388,
12,
5661,
12,
4233,
12,
7349,
12,
6928,
12,
13470,
12,
221,
327,
366,
16,
199,
8155,
12,
6877,
12,
10868,
12,
13713,
12,
13385,
12,
9615,
12,
13564,
12,
12426,
12,
12766,
12,
5685,
12,
5212,
12,
8780,
12,
12260,
12,
10448,
12,
7105,
12,
8177,
12,
221,
327,
325,
16,
199,
8685,
12,
11851,
12,
10416,
12,
4337,
12,
6335,
12,
14589,
12,
12001,
12,
9404,
12,
17017,
12,
16202,
12,
8026,
12,
12699,
12,
10954,
12,
13668,
12,
5238,
12,
10045,
12,
221,
327,
289,
16,
199,
9,
199,
199,
2676,
21381,
63,
24516,
275,
334,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
221,
327,
8733,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
221,
327,
1616,
199,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
3388,
199,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
4233
] |
[
16427,
5113,
8068,
11945,
199,
3,
710,
12769,
5495,
365,
17728,
13338,
707,
1890,
1233,
14,
199,
3,
199,
3,
710,
6026,
9607,
402,
314,
12769,
5495,
365,
199,
3,
20433,
18686,
11098,
14,
199,
3,
20825,
2737,
701,
314,
6026,
9607,
787,
1898,
334,
35,
9,
19960,
199,
3,
314,
6026,
9607,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
17636,
8,
83,
304,
199,
3,
257,
7173,
19641,
446,
1844,
370,
2018,
199,
3,
199,
3,
961,
3555,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
199,
3,
2811,
652,
1334,
314,
2895,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
465,
3267,
701,
314,
2868,
2290,
2752,
27,
1902,
199,
3,
1015,
499,
14,
17,
402,
314,
844,
12,
503,
334,
292,
2195,
945,
9,
1263,
2945,
1015,
14,
199,
3,
199,
3,
961,
3555,
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,
1664,
199,
3,
6401,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
199,
3,
844,
3180,
543,
642,
3555,
27,
340,
440,
12,
2218,
370,
314,
2868,
2290,
199,
3,
2752,
12,
3277,
2020,
8026,
11236,
1933,
12,
12066,
11844,
12,
8226,
12,
4828,
199,
3,
11315,
13,
10067,
221,
8217,
199,
19054,
7729,
5113,
8068,
21186,
199,
199,
3,
1804,
47,
41,
24,
13,
50,
2637,
1402,
199,
3,
17660,
12340,
6957,
26,
199,
24839,
41,
24,
50,
63,
24516,
275,
334,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
221,
327,
8733,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
221,
327,
1616,
199,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
3388,
199,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
4233,
199,
3781,
12,
12199,
12,
12289,
12,
9862,
12,
11731,
12,
11432,
12,
11160,
12,
10834,
12,
10721,
12,
8251,
12,
12768,
12,
11024,
12,
9720,
12,
12034,
12,
13098,
12,
10478,
12,
221,
327,
6335,
199,
11520,
12,
11309,
12,
10823,
12,
11240,
12,
9327,
12,
8488,
12,
12285,
12,
12438,
12,
11931,
12,
8982,
12,
10355,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
5238,
199,
3781,
12,
17245,
12,
10419,
12,
14157,
12,
12478,
12,
11738,
12,
9892,
12,
14646,
12,
10848,
12,
5049,
12,
10216,
12,
8881,
12,
8375,
12,
15323,
12,
11175,
12,
14610,
12,
221,
327,
5212,
199,
13296,
12,
10699,
12,
14679,
12,
18525,
12,
7663,
12,
12851,
12,
13734,
12,
12894,
12,
12363,
12,
10078,
12,
10233,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
10045,
199,
12632,
12,
5756,
12,
13015,
12,
10860,
12,
11874,
12,
10800,
12,
11165,
12,
10905,
12,
7155,
12,
1840,
12,
1797,
12,
4999,
12,
11341,
12,
6686,
12,
10629,
12,
11089,
12,
221,
327,
5939,
199,
10744,
12,
10630,
12,
11303,
12,
12725,
12,
12832,
12,
11722,
12,
14271,
12,
6886,
12,
7842,
12,
9669,
12,
9335,
12,
9252,
12,
8867,
12,
11174,
12,
11564,
12,
9485,
12,
221,
327,
9137,
199,
11583,
12,
8731,
12,
10932,
12,
10851,
12,
11085,
12,
11385,
12,
12048,
12,
11182,
12,
9687,
12,
11921,
12,
8001,
12,
10034,
12,
5533,
12,
8276,
12,
10008,
12,
10638,
12,
221,
327,
282,
16,
199,
12332,
12,
9803,
12,
9873,
12,
13571,
12,
13212,
12,
13440,
12,
11603,
12,
11677,
12,
11440,
12,
11717,
12,
11242,
12,
11032,
12,
7991,
12,
12140,
12,
6390,
12,
3781,
12,
221,
327,
330,
16,
199,
8087,
12,
221,
650,
12,
7829,
12,
7294,
12,
4944,
12,
221,
499,
12,
10551,
12,
5851,
12,
7875,
12,
221,
841,
12,
6546,
12,
4119,
12,
221,
1695,
12,
3144,
12,
221,
959,
12,
221,
413,
12,
221,
327,
286,
16,
199,
4114,
12,
3193,
12,
221,
1749,
12,
221,
1520,
12,
221,
1227,
12,
4329,
12,
5504,
12,
1616,
12,
5557,
12,
6155,
12,
3388,
12,
5661,
12,
4233,
12,
7349,
12,
6928,
12,
13470,
12,
221,
327,
366,
16,
199,
8155,
12,
6877,
12,
10868,
12,
13713,
12,
13385,
12,
9615,
12,
13564,
12,
12426,
12,
12766,
12,
5685,
12,
5212,
12,
8780,
12,
12260,
12,
10448,
12,
7105,
12,
8177,
12,
221,
327,
325,
16,
199,
8685,
12,
11851,
12,
10416,
12,
4337,
12,
6335,
12,
14589,
12,
12001,
12,
9404,
12,
17017,
12,
16202,
12,
8026,
12,
12699,
12,
10954,
12,
13668,
12,
5238,
12,
10045,
12,
221,
327,
289,
16,
199,
9,
199,
199,
2676,
21381,
63,
24516,
275,
334,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
8306,
12,
2299,
12,
2299,
12,
221,
327,
8733,
199,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
2299,
12,
221,
327,
1616,
199,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
3388,
199,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
6390,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
3781,
12,
221,
327,
4233,
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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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
] |
ashfaqfarooqui/ROSTutorials
|
basics/001_talker_listener/talker.py
|
15
|
2217
|
#!/usr/bin/env python
# Software License Agreement (BSD License)
#
# Copyright (c) 2008, Willow Garage, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Willow Garage, 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.
#
# Revision $Id$
## Simple talker demo that published std_msgs/Strings messages
## to the 'chatter' topic
import rospy
from std_msgs.msg import String
def talker():
pub = rospy.Publisher('chatter', String, queue_size=10)
rospy.init_node('talker', anonymous=True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
hello_str = "hello world %s" % rospy.get_time()
rospy.loginfo(hello_str)
pub.publish(hello_str)
rate.sleep()
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass
|
gpl-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
2290,
844,
28629,
334,
15400,
844,
9,
199,
3,
199,
3,
1898,
334,
67,
9,
9079,
12,
644,
382,
674,
598,
285,
474,
12,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
199,
3,
787,
7647,
26,
199,
3,
199,
3,
221,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
259,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
221,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
259,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
199,
3,
259,
6450,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
199,
3,
259,
543,
314,
4084,
14,
199,
3,
221,
627,
11443,
314,
536,
402,
644,
382,
674,
598,
285,
474,
12,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
259,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
199,
3,
259,
687,
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,
199,
3,
2381,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
5877,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
199,
3,
9716,
12,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
199,
3,
5400,
2845,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
199,
3,
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,
199,
3,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
199,
3,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
199,
3,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
3,
27095,
2672,
1304,
4,
199,
199,
309,
5870,
307,
14976,
14779,
626,
3267,
2418,
63,
13429,
15,
12672,
3788,
199,
309,
370,
314,
283,
335,
3760,
7,
7482,
199,
199,
646,
21848,
199,
504,
2418,
63,
13429,
14,
1328,
492,
2624,
199,
199,
318,
307,
14976,
837,
272,
7974,
275,
21848,
14,
27341,
360,
335,
3760,
297,
2624,
12,
4126,
63,
890,
29,
709,
9,
272,
21848,
14,
826,
63,
932,
360,
84,
14976,
297,
16535,
29,
549,
9,
272,
6634,
275,
21848,
14,
6621,
8,
709,
9,
327,
1616,
19552,
272,
1830,
440,
21848,
14,
374,
63,
8831,
837,
267,
16509,
63,
495,
275,
298,
5006,
6701,
450,
83,
2,
450,
21848,
14,
362,
63,
521,
342,
267,
21848,
14,
793,
815,
8,
5006,
63,
495,
9,
267,
7974,
14,
4763,
8,
5006,
63,
495,
9,
267,
6634,
14,
4532,
342,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
862,
26,
267,
307,
14976,
342,
272,
871,
21848,
14,
1092,
51,
10647,
1726,
26,
267,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
2290,
844,
28629,
334,
15400,
844,
9,
199,
3,
199,
3,
1898,
334,
67,
9,
9079,
12,
644,
382,
674,
598,
285,
474,
12,
3277,
14,
199,
3,
2900,
4481,
4644,
14,
199,
3,
199,
3,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
199,
3,
787,
7647,
26,
199,
3,
199,
3,
221,
627,
6823,
402,
1350,
1233,
1471,
8074,
314,
3432,
4248,
199,
3,
259,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
14,
199,
3,
221,
627,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
199,
3,
259,
4248,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
199,
3,
259,
6450,
315,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
199,
3,
259,
543,
314,
4084,
14,
199,
3,
221,
627,
11443,
314,
536,
402,
644,
382,
674,
598,
285,
474,
12,
3277,
14,
6590,
314,
1561,
402,
2399,
199,
3,
259,
8417,
1443,
506,
1202,
370,
10692,
503,
10016,
7585,
7131,
199,
3,
259,
687,
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,
199,
3,
2381,
437,
3115,
3104,
9315,
9706,
14,
1621,
4825,
6461,
7000,
2334,
199,
3,
5877,
11489,
1549,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
199,
3,
9716,
12,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
199,
3,
5400,
2845,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
199,
3,
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,
199,
3,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
7043,
1621,
199,
3,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
1634,
2334,
199,
3,
9726,
1634,
9712,
9784,
14,
199,
3,
199,
3,
27095,
2672,
1304,
4,
199,
199,
309,
5870,
307,
14976,
14779,
626,
3267,
2418,
63,
13429,
15,
12672,
3788,
199,
309,
370,
314,
283,
335,
3760,
7,
7482,
199,
199,
646,
21848,
199,
504,
2418,
63,
13429,
14,
1328,
492,
2624,
199,
199,
318,
307,
14976,
837,
272,
7974,
275,
21848,
14,
27341,
360,
335,
3760,
297,
2624,
12,
4126,
63,
890,
29,
709,
9,
272,
21848,
14,
826,
63,
932,
360,
84,
14976,
297,
16535,
29,
549,
9,
272,
6634,
275,
21848,
14,
6621,
8,
709,
9,
327,
1616,
19552,
272,
1830,
440,
21848,
14,
374,
63,
8831,
837,
267,
16509,
63,
495,
275,
298,
5006,
6701,
450,
83,
2,
450,
21848,
14,
362,
63,
521,
342,
267,
21848,
14,
793,
815,
8,
5006,
63,
495,
9,
267,
7974,
14,
4763,
8,
5006,
63,
495,
9,
267,
6634,
14,
4532,
342,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
862,
26,
267,
307,
14976,
342,
272,
871,
21848,
14,
1092,
51,
10647,
1726,
26,
267,
986,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,
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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
] |
smartchicago/chicago-early-learning
|
python/ecep/portal/management/commands/update_ecm.py
|
1
|
9296
|
from geopy.geocoders import GoogleV3
import csv
import logging
import os
import paramiko
import re
import time
from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import NoArgsCommand
from django.conf import settings
from portal.models import Location
class Command(NoArgsCommand):
"""
Import Cleaned Site Name, Address, and ECM Keys
"""
remote_path = 'Exports/'
local_export_dir_path = '/cel/app/python/ecep/portal/management/exports/export.csv'
geolocator = GoogleV3()
def handle(self, *args, **options):
timestr = time.strftime("%Y%m%d_%H%M%S")
logfile = 'portal/management/commands/logs/ecm_import_' + timestr + '.log'
logging.basicConfig(filename=logfile, level=logging.INFO)
self.download_export()
with open(self.local_export_dir_path, 'rb') as master:
reader = csv.DictReader(master, delimiter='|')
for row in reader:
self.process_row(row)
def download_export(self):
host = settings.ECM_SFTP_HOST
port = 22
transport = paramiko.Transport((host, port))
username = settings.ECM_SFTP_USERNAME
password = settings.ECM_SFTP_PASSWORD
transport.connect(username=username, password=password)
sftp = paramiko.SFTPClient.from_transport(transport)
uploads = sftp.listdir('Exports/')
latest_export = uploads[-1]
latest_export_path = self.remote_path + latest_export
sftp.get(remotepath=latest_export_path, localpath=self.local_export_dir_path)
sftp.close()
transport.close()
return latest_export
def process_row(self, row):
try:
key = row['ECMKey']
l = Location.objects.get(ecm_key=key)
logging.info("")
logging.info(key)
logging.info(l.site_name)
# Special handling for address and geolocation
if l.address != row['LocAddress'] and row['LocAddress'] is not None:
location = self.geocode(row['LocAddress'], row['LocCity'], row['LocState'], row['LocZip'])
l.address = row['LocAddress']
logging.info("Updated address to {}".format(row['LocAddress']))
l.geom = 'POINT({} {})'.format(location.longitude, location.latitude)
logging.info('Updated geometry!')
l.site_name = smart_swap(l.site_name, row['Site_Name'], l.verbose_name('site_name'))
l.ages = smart_swap(l.ages, row['Ages_Served'], l.verbose_name('ages'))
l.q_rating = smart_swap(l.q_rating, row['Quality_Rating'], l.verbose_name('q_rating'))
l.is_part_day = smart_swap(l.is_part_day, parse_null_boolean(row['Part_Day_Y_N']), l.verbose_name('is_part_day'))
l.prg_hours = smart_swap(l.prg_hours, row['Operating_Hours'], l.verbose_name('prg_hours'))
l.city = smart_swap(l.city, row['LocCity'], l.verbose_name('city'))
l.zip = smart_swap(l.zip, row['LocZip'], l.verbose_name('zip'))
l.state = smart_swap(l.state, row['LocState'], l.verbose_name('state'))
l.is_age_lt_3 = smart_swap(l.is_age_lt_3, parse_null_boolean(row['Ages_Zero_Three_Y_N']), l.verbose_name('is_age_lt_3'))
l.is_age_gt_3 = smart_swap(l.is_age_gt_3, parse_null_boolean(row['Ages_Three_Five_Y_N']), l.verbose_name('is_age_gt_3'))
l.is_community_based = smart_swap(l.is_community_based, parse_null_boolean(row['Community_Based_Y_N']), l.verbose_name('is_community_based'))
l.is_school_year = smart_swap(l.is_school_year, parse_null_boolean(row['School_Year_Y_N']), l.verbose_name('is_school_year'))
l.accred = smart_swap(l.accred, row['Accreditation'], l.verbose_name('accred'))
# Special processing for languages:
cleaned_languages = clean_languages(row['Languages_other_than_English'])
l.language_1 = smart_swap(l.language_1, cleaned_languages, l.verbose_name('language_1'))
l.language_2 = ''
l.language_3 = ''
l.phone = smart_swap(l.phone, row['Phone_Number'], l.verbose_name('phone'))
l.accept_ccap = smart_swap(l.accept_ccap, parse_null_boolean(row['Accepts_CCAP_Y_N']), l.verbose_name('accept_ccap'))
l.address = smart_swap(l.address, row['LocAddress'], l.verbose_name('address'))
l.is_hs = smart_swap(l.is_hs, parse_null_boolean(row['Head_Start_Y_N']), l.verbose_name('is_hs'))
l.is_full_day = smart_swap(l.is_full_day, parse_null_boolean(row['Full_Day_Y_N']), l.verbose_name('is_full_day'))
l.is_full_year = smart_swap(l.is_full_year, parse_null_boolean(row['Full_Year_Y_N']), l.verbose_name('is_full_year'))
l.url = smart_swap(l.url, row['URL'], l.verbose_name('url'))
l.is_home_visiting = smart_swap(l.is_home_visiting, parse_null_boolean(row['Home_Visiting_Y_N']), l.verbose_name('is_home_visiting'))
l.is_cps_based = smart_swap(l.is_cps_based, parse_null_boolean(row['School_Based_Y_N']), l.verbose_name('is_cps_based'))
# Save results
l.save()
except ObjectDoesNotExist:
self.create_new_school(row)
except:
logging.warning('')
logging.warning('*********')
logging.warning("Whoops! Something went wrong with ")
logging.warning(row['ECMKey'])
logging.warning('*********')
logging.warning('')
def geocode(self, address, city, state, zip):
address_string = " ".join([address, city, state, zip])
point = self.geolocator.geocode(address_string)
return point
def process_location(self, row):
time.sleep(1)
location = self.geocode(row['LocAddress'], row['LocCity'], row['LocState'], row['LocZip'])
try:
x = location.longitude
except:
print ""
print "UH OH"
print row['ECMKey']
print "UH OH"
def create_new_school(self, row):
l = Location(
ecm_key = smart_swap('', row['ECMKey'], None),
site_name = smart_swap('', row['Site_Name'], None),
address = smart_swap('', row['LocAddress'], None),
city = smart_swap('Chicago', row['LocCity'], None), # Yes, a space after city
state = smart_swap('IL', row['LocState'], None),
zip = smart_swap('', row['LocZip'], None),
phone = smart_swap('', row['Phone_Number'], None),
url = smart_swap('', row['URL'], None),
accred = smart_swap('', row['Accreditation'], None),
q_rating = smart_swap('', row['Quality_Rating'], None),
prg_hours = smart_swap('', row['Operating_Hours'], None),
is_full_day = parse_null_boolean(row['Full_Day_Y_N']),
is_part_day = parse_null_boolean(row['Part_Day_Y_N']),
is_school_year = parse_null_boolean(row['School_Year_Y_N']),
is_full_year = parse_null_boolean(row['Full_Year_Y_N']),
ages = smart_swap('', row['Ages_Served'], None),
is_age_lt_3 = parse_null_boolean(row['Ages_Zero_Three_Y_N']),
is_age_gt_3 = parse_null_boolean(row['Ages_Three_Five_Y_N']),
is_community_based = parse_null_boolean(row['Community_Based_Y_N']),
is_cps_based = parse_null_boolean(row['School_Based_Y_N']),
is_home_visiting = parse_null_boolean(row['Home_Visiting_Y_N']),
accept_ccap = parse_null_boolean(row['Accepts_CCAP_Y_N']),
is_hs = parse_null_boolean(row['Head_Start_Y_N']),
availability = smart_swap('', row['Availability_Level'], None)
)
location = self.geocode(row['LocAddress'], row['LocCity'], row['LocState'], row['LocZip'])
l.geom = 'POINT({} {})'.format(location.longitude, location.latitude)
l.languages = clean_languages(row['Languages_other_than_English'])
try:
l.save()
logging.info('')
logging.info(row['ECMKey'])
logging.info('Created new location!')
logging.info('')
except Exception as e:
logging.error('')
logging.error('!!!!!')
logging.error('Could not create new school!')
logging.error(row['ECMKey'])
logging.error(e)
logging.error('!!!!!')
logging.error('')
def parse_null_boolean(boolean):
if boolean == '':
return ''
elif boolean == None:
return None
else:
return boolean == '1'
def smart_swap(current, new, name):
if new and new != '_' and current != new and new != 'n/a':
if name:
logging.info("Updated {} to {}".format(name, str(new)))
return new
else:
return current
def clean_languages(languages):
if languages == "_" or languages == ";;":
return ''
elif languages.endswith(";;"):
return languages.strip(";;")
else:
# Chained replace catches both scenarios like
# a) "Spanish;;French"
# b) "Spanish;French;Latin"
return languages.replace(";;", ", ").replace(";", ", ")
|
mit
|
[
504,
2312,
927,
14,
6721,
2693,
83,
492,
4475,
54,
19,
199,
199,
646,
7392,
199,
646,
2050,
199,
646,
747,
199,
646,
26162,
199,
646,
295,
199,
646,
900,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
24803,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
3091,
6213,
3110,
199,
504,
1639,
14,
2190,
492,
2202,
199,
199,
504,
18428,
14,
992,
492,
12625,
421,
199,
533,
5817,
8,
27099,
3110,
304,
272,
408,
272,
3161,
12762,
379,
11666,
2812,
12,
9906,
12,
436,
662,
9249,
17276,
272,
408,
272,
3982,
63,
515,
275,
283,
920,
5203,
4805,
272,
2257,
63,
3790,
63,
694,
63,
515,
275,
1994,
6067,
15,
571,
15,
1548,
15,
69,
28448,
15,
8707,
15,
8110,
15,
20775,
15,
3790,
14,
4737,
7,
339,
8509,
6354,
275,
4475,
54,
19,
342,
339,
347,
2429,
8,
277,
12,
627,
589,
12,
1011,
1419,
304,
398,
900,
495,
275,
900,
14,
6205,
3647,
57,
5,
77,
5,
68,
4970,
40,
5,
45,
5,
51,
531,
267,
17251,
275,
283,
8707,
15,
8110,
15,
4405,
15,
7270,
15,
825,
77,
63,
646,
8650,
435,
900,
495,
435,
1987,
793,
7,
267,
2050,
14,
19602,
8,
1501,
29,
12804,
12,
2166,
29,
4806,
14,
4531,
9,
398,
291,
14,
4249,
63,
3790,
342,
398,
543,
1551,
8,
277,
14,
1832,
63,
3790,
63,
694,
63,
515,
12,
283,
4848,
358,
465,
5288,
26,
288,
7002,
275,
7392,
14,
2141,
5929,
8,
4133,
12,
11172,
534,
92,
358,
953,
367,
1962,
315,
7002,
26,
355,
291,
14,
1412,
63,
1143,
8,
1143,
9,
2378,
347,
5235,
63,
3790,
8,
277,
304,
398,
1591,
275,
2202,
14,
4220,
45,
63,
51,
15123,
63,
5449,
267,
1844,
275,
6928,
398,
7773,
275,
26162,
14,
7836,
1332,
1102,
12,
1844,
430,
398,
3434,
275,
2202,
14,
4220,
45,
63,
51,
15123,
63,
11958,
267,
2505,
275,
2202,
14,
4220,
45,
63,
51,
15123,
63,
9032,
398,
7773,
14,
2242,
8,
2473,
29,
2473,
12,
2505,
29,
2060,
9,
267,
308,
8915,
275,
26162,
14,
51,
15123,
3041,
14,
504,
63,
5545,
8,
5545,
9,
398,
26598,
275,
308,
8915,
14,
7374,
360,
920,
5203,
6217,
267,
8839,
63,
3790,
275,
26598,
1988,
17,
61,
267,
8839,
63,
3790,
63,
515,
275,
291,
14,
3846,
63,
515,
435,
8839,
63,
3790,
267,
308,
8915,
14,
362,
8,
3846,
515,
29,
7410,
63,
3790,
63,
515,
12,
2257,
515,
29,
277,
14,
1832,
63,
3790,
63,
694,
63,
515,
9,
2728,
308,
8915,
14,
1600,
342,
267,
7773,
14,
1600,
342,
398,
372,
8839,
63,
3790,
2378,
347,
2112,
63,
1143,
8,
277,
12,
1962,
304,
398,
862,
26,
953,
790,
275,
1962,
459,
4220,
45,
1197,
418,
288,
634,
275,
12625,
14,
1462,
14,
362,
8,
825,
77,
63,
498,
29,
498,
9,
953,
2050,
14,
815,
10804,
288,
2050,
14,
815,
8,
498,
9,
288,
2050,
14,
815,
8,
76,
14,
2124,
63,
354,
9,
953,
327,
12568,
7252,
367,
2287,
436,
8509,
1985,
288,
340,
634,
14,
1562,
1137,
1962,
459,
3040,
1476,
418,
436,
1962,
459,
3040,
1476,
418,
365,
440,
488,
26,
2234,
2909,
275,
291,
14,
6721,
600,
8,
1143,
459,
3040,
1476,
995,
1962,
459,
3040,
17024,
995,
1962,
459,
3040,
2223,
995,
1962,
459,
3040,
8674,
1105,
355,
634,
14,
1562,
275,
1962,
459,
3040,
1476,
418,
355,
2050,
14,
815,
480,
19920,
2287,
370,
8352,
908,
8,
1143,
459,
3040,
1476,
5156,
355,
634,
14,
6481,
275,
283,
7217,
24692,
5009,
1370,
908,
8,
1985,
14,
13803,
12,
2909,
14,
13331,
9,
355,
2050,
14,
815,
360,
19920,
3400,
10916,
953,
634,
14,
2124,
63,
354,
275,
11179,
63,
9286,
8,
76,
14,
2124,
63,
354,
12,
1962,
459,
8972,
63,
985,
995,
634,
14,
3832,
63,
354,
360,
2124,
63,
354,
1333,
288,
634,
14,
7441,
275,
11179,
63,
9286,
8,
76,
14,
7441,
12,
1962,
459,
33,
3389,
63,
1505,
1354,
995,
634,
14,
3832,
63,
354,
360,
7441,
1333,
288,
634,
14,
81,
63,
10417,
275,
11179,
63,
9286,
8,
76,
14,
81,
63,
10417,
12,
1962,
459,
19436,
63,
32533,
995,
634,
14,
3832,
63,
354,
360,
81,
63,
10417,
1333,
288,
634,
14,
374,
63,
2064,
63,
2977,
275,
11179,
63,
9286,
8,
76,
14,
374,
63,
2064,
63,
2977,
12,
2198,
63,
2307,
63,
4871,
8,
1143,
459,
8416,
63,
12631,
63,
57,
63,
46,
3815,
634,
14,
3832,
63,
354,
360,
374,
63,
2064,
63,
2977,
1333,
288,
634,
14,
26233,
63,
8419,
275,
11179,
63,
9286,
8,
76,
14,
26233,
63,
8419,
12,
1962,
459,
23699,
63,
30927,
995,
634,
14,
3832,
63,
354,
360,
26233,
63,
8419,
1333,
288,
634,
14,
3690,
275,
11179,
63,
9286,
8,
76,
14,
3690,
12,
1962,
459,
3040,
17024,
995,
634,
14,
3832,
63,
354,
360,
3690,
1333,
288,
634,
14,
3065,
275,
11179,
63,
9286,
8,
76,
14,
3065,
12,
1962,
459,
3040,
8674,
995,
634,
14,
3832,
63,
354,
360,
3065,
1333,
288,
634,
14,
929,
275,
11179,
63,
9286,
8,
76,
14,
929,
12,
1962,
459,
3040,
2223,
995,
634,
14,
3832,
63,
354,
360,
929,
1333,
288,
634,
14,
374,
63,
474,
63,
4116,
63,
19,
275,
11179,
63,
9286,
8,
76,
14,
374,
63,
474,
63,
4116,
63,
19,
12,
2198,
63,
2307,
63,
4871,
8,
1143,
459,
33,
3389,
63,
8681,
63,
21485,
63,
57,
63,
46,
3815,
634,
14,
3832,
63,
354,
360,
374,
63,
474,
63,
4116,
63,
19,
1333,
288,
634,
14,
374,
63,
474,
63,
3308,
63,
19,
275,
11179,
63,
9286,
8,
76,
14,
374,
63,
474,
63,
3308,
63,
19,
12,
2198,
63,
2307,
63,
4871,
8,
1143,
459,
33,
3389,
63,
21485,
63,
38,
1912,
63,
57,
63,
46,
3815,
634,
14,
3832,
63,
354,
360,
374,
63,
474,
63,
3308,
63,
19,
1333,
288,
634,
14,
374,
63,
9387,
63,
6788,
275,
11179,
63,
9286,
8,
76,
14,
374,
63,
9387,
63,
6788,
12,
2198,
63,
2307,
63,
4871,
8,
1143,
459,
29799,
63,
20409,
63,
57,
63,
46,
3815,
634,
14,
3832,
63,
354,
360,
374,
63
] |
[
2312,
927,
14,
6721,
2693,
83,
492,
4475,
54,
19,
199,
199,
646,
7392,
199,
646,
2050,
199,
646,
747,
199,
646,
26162,
199,
646,
295,
199,
646,
900,
199,
199,
504,
1639,
14,
1018,
14,
3924,
492,
24803,
199,
504,
1639,
14,
1018,
14,
8110,
14,
1095,
492,
3091,
6213,
3110,
199,
504,
1639,
14,
2190,
492,
2202,
199,
199,
504,
18428,
14,
992,
492,
12625,
421,
199,
533,
5817,
8,
27099,
3110,
304,
272,
408,
272,
3161,
12762,
379,
11666,
2812,
12,
9906,
12,
436,
662,
9249,
17276,
272,
408,
272,
3982,
63,
515,
275,
283,
920,
5203,
4805,
272,
2257,
63,
3790,
63,
694,
63,
515,
275,
1994,
6067,
15,
571,
15,
1548,
15,
69,
28448,
15,
8707,
15,
8110,
15,
20775,
15,
3790,
14,
4737,
7,
339,
8509,
6354,
275,
4475,
54,
19,
342,
339,
347,
2429,
8,
277,
12,
627,
589,
12,
1011,
1419,
304,
398,
900,
495,
275,
900,
14,
6205,
3647,
57,
5,
77,
5,
68,
4970,
40,
5,
45,
5,
51,
531,
267,
17251,
275,
283,
8707,
15,
8110,
15,
4405,
15,
7270,
15,
825,
77,
63,
646,
8650,
435,
900,
495,
435,
1987,
793,
7,
267,
2050,
14,
19602,
8,
1501,
29,
12804,
12,
2166,
29,
4806,
14,
4531,
9,
398,
291,
14,
4249,
63,
3790,
342,
398,
543,
1551,
8,
277,
14,
1832,
63,
3790,
63,
694,
63,
515,
12,
283,
4848,
358,
465,
5288,
26,
288,
7002,
275,
7392,
14,
2141,
5929,
8,
4133,
12,
11172,
534,
92,
358,
953,
367,
1962,
315,
7002,
26,
355,
291,
14,
1412,
63,
1143,
8,
1143,
9,
2378,
347,
5235,
63,
3790,
8,
277,
304,
398,
1591,
275,
2202,
14,
4220,
45,
63,
51,
15123,
63,
5449,
267,
1844,
275,
6928,
398,
7773,
275,
26162,
14,
7836,
1332,
1102,
12,
1844,
430,
398,
3434,
275,
2202,
14,
4220,
45,
63,
51,
15123,
63,
11958,
267,
2505,
275,
2202,
14,
4220,
45,
63,
51,
15123,
63,
9032,
398,
7773,
14,
2242,
8,
2473,
29,
2473,
12,
2505,
29,
2060,
9,
267,
308,
8915,
275,
26162,
14,
51,
15123,
3041,
14,
504,
63,
5545,
8,
5545,
9,
398,
26598,
275,
308,
8915,
14,
7374,
360,
920,
5203,
6217,
267,
8839,
63,
3790,
275,
26598,
1988,
17,
61,
267,
8839,
63,
3790,
63,
515,
275,
291,
14,
3846,
63,
515,
435,
8839,
63,
3790,
267,
308,
8915,
14,
362,
8,
3846,
515,
29,
7410,
63,
3790,
63,
515,
12,
2257,
515,
29,
277,
14,
1832,
63,
3790,
63,
694,
63,
515,
9,
2728,
308,
8915,
14,
1600,
342,
267,
7773,
14,
1600,
342,
398,
372,
8839,
63,
3790,
2378,
347,
2112,
63,
1143,
8,
277,
12,
1962,
304,
398,
862,
26,
953,
790,
275,
1962,
459,
4220,
45,
1197,
418,
288,
634,
275,
12625,
14,
1462,
14,
362,
8,
825,
77,
63,
498,
29,
498,
9,
953,
2050,
14,
815,
10804,
288,
2050,
14,
815,
8,
498,
9,
288,
2050,
14,
815,
8,
76,
14,
2124,
63,
354,
9,
953,
327,
12568,
7252,
367,
2287,
436,
8509,
1985,
288,
340,
634,
14,
1562,
1137,
1962,
459,
3040,
1476,
418,
436,
1962,
459,
3040,
1476,
418,
365,
440,
488,
26,
2234,
2909,
275,
291,
14,
6721,
600,
8,
1143,
459,
3040,
1476,
995,
1962,
459,
3040,
17024,
995,
1962,
459,
3040,
2223,
995,
1962,
459,
3040,
8674,
1105,
355,
634,
14,
1562,
275,
1962,
459,
3040,
1476,
418,
355,
2050,
14,
815,
480,
19920,
2287,
370,
8352,
908,
8,
1143,
459,
3040,
1476,
5156,
355,
634,
14,
6481,
275,
283,
7217,
24692,
5009,
1370,
908,
8,
1985,
14,
13803,
12,
2909,
14,
13331,
9,
355,
2050,
14,
815,
360,
19920,
3400,
10916,
953,
634,
14,
2124,
63,
354,
275,
11179,
63,
9286,
8,
76,
14,
2124,
63,
354,
12,
1962,
459,
8972,
63,
985,
995,
634,
14,
3832,
63,
354,
360,
2124,
63,
354,
1333,
288,
634,
14,
7441,
275,
11179,
63,
9286,
8,
76,
14,
7441,
12,
1962,
459,
33,
3389,
63,
1505,
1354,
995,
634,
14,
3832,
63,
354,
360,
7441,
1333,
288,
634,
14,
81,
63,
10417,
275,
11179,
63,
9286,
8,
76,
14,
81,
63,
10417,
12,
1962,
459,
19436,
63,
32533,
995,
634,
14,
3832,
63,
354,
360,
81,
63,
10417,
1333,
288,
634,
14,
374,
63,
2064,
63,
2977,
275,
11179,
63,
9286,
8,
76,
14,
374,
63,
2064,
63,
2977,
12,
2198,
63,
2307,
63,
4871,
8,
1143,
459,
8416,
63,
12631,
63,
57,
63,
46,
3815,
634,
14,
3832,
63,
354,
360,
374,
63,
2064,
63,
2977,
1333,
288,
634,
14,
26233,
63,
8419,
275,
11179,
63,
9286,
8,
76,
14,
26233,
63,
8419,
12,
1962,
459,
23699,
63,
30927,
995,
634,
14,
3832,
63,
354,
360,
26233,
63,
8419,
1333,
288,
634,
14,
3690,
275,
11179,
63,
9286,
8,
76,
14,
3690,
12,
1962,
459,
3040,
17024,
995,
634,
14,
3832,
63,
354,
360,
3690,
1333,
288,
634,
14,
3065,
275,
11179,
63,
9286,
8,
76,
14,
3065,
12,
1962,
459,
3040,
8674,
995,
634,
14,
3832,
63,
354,
360,
3065,
1333,
288,
634,
14,
929,
275,
11179,
63,
9286,
8,
76,
14,
929,
12,
1962,
459,
3040,
2223,
995,
634,
14,
3832,
63,
354,
360,
929,
1333,
288,
634,
14,
374,
63,
474,
63,
4116,
63,
19,
275,
11179,
63,
9286,
8,
76,
14,
374,
63,
474,
63,
4116,
63,
19,
12,
2198,
63,
2307,
63,
4871,
8,
1143,
459,
33,
3389,
63,
8681,
63,
21485,
63,
57,
63,
46,
3815,
634,
14,
3832,
63,
354,
360,
374,
63,
474,
63,
4116,
63,
19,
1333,
288,
634,
14,
374,
63,
474,
63,
3308,
63,
19,
275,
11179,
63,
9286,
8,
76,
14,
374,
63,
474,
63,
3308,
63,
19,
12,
2198,
63,
2307,
63,
4871,
8,
1143,
459,
33,
3389,
63,
21485,
63,
38,
1912,
63,
57,
63,
46,
3815,
634,
14,
3832,
63,
354,
360,
374,
63,
474,
63,
3308,
63,
19,
1333,
288,
634,
14,
374,
63,
9387,
63,
6788,
275,
11179,
63,
9286,
8,
76,
14,
374,
63,
9387,
63,
6788,
12,
2198,
63,
2307,
63,
4871,
8,
1143,
459,
29799,
63,
20409,
63,
57,
63,
46,
3815,
634,
14,
3832,
63,
354,
360,
374,
63,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] |
galak/zephyr
|
boards/xtensa/intel_adsp_cavs15/tools/fw_loader.py
|
6
|
2622
|
#!/usr/bin/env python3
#
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
import os
import argparse
import logging
from colorama import Fore, Style
from lib.loader import FirmwareLoader, FirmwareStatus
import lib.platforms as plat_def
def check_args(args):
# Check if firmware exists
firmware_abs = os.path.abspath(args.firmware)
if not os.path.exists(firmware_abs):
raise ValueError("File not found: %s" % firmware_abs)
def parse_args():
arg_parser = argparse.ArgumentParser(description="ADSP firmware loader")
arg_parser.add_argument("-f", "--firmware", required=True,
help="ADSP firmware file to load")
arg_parser.add_argument("-d", "--debug", default=False, action='store_true',
help="Display debug information")
args = arg_parser.parse_args()
check_args(args)
return args
def main():
""" Main Entry Point """
args = parse_args()
log_level = logging.INFO
if args.debug:
log_level = logging.DEBUG
logging.basicConfig(level=log_level, format="%(message)s")
logging.info("Start firmware downloading...")
fw_loader = FirmwareLoader()
# Use Stream #7 for firmware download DMA
fw_loader.init(plat_def.DMA_ID)
logging.info("Reset DSP...")
fw_loader.reset_dsp()
FirmwareStatus(fw_loader.dev.fw_status.value).print()
logging.info(" IPC CMD : %s" % fw_loader.dev.ipc_cmd)
logging.info(" IPC LEN : %s" % fw_loader.dev.ipc_len)
logging.info("Booting up DSP...")
fw_loader.boot_dsp()
FirmwareStatus(fw_loader.dev.fw_status.value).print()
fw_loader.wait_for_fw_boot_status(plat_def.BOOT_STATUS_INIT_DONE)
logging.info("Downloading firmware...")
fw_loader.download_firmware(args.firmware)
logging.info("Checking firmware status...")
if fw_loader.check_fw_boot_status(plat_def.BOOT_STATUS_FW_ENTERED):
logging.info(Fore.LIGHTGREEN_EX +
"Firmware download completed successfully"
+ Style.RESET_ALL)
logging.info("Reading IPC FwReady Message...")
fw_loader.ipc.read_fw_ready()
else:
logging.error(Fore.RED +
"!!!!! Failed to download firmware !!!!!"
+ Style.RESET_ALL)
fw_loader.close()
if __name__ == "__main__":
try:
main()
os._exit(0)
except KeyboardInterrupt: # Ctrl-C
os._exit(14)
except SystemExit:
raise
except BaseException:
import traceback
traceback.print_exc()
os._exit(16)
|
apache-2.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
199,
3,
1898,
334,
67,
9,
20312,
20619,
11098,
199,
3,
199,
3,
6988,
19596,
13,
3761,
13,
7544,
26,
3668,
13,
18,
14,
16,
199,
199,
646,
747,
199,
646,
7534,
199,
646,
2050,
199,
199,
504,
3164,
14541,
492,
21684,
12,
19442,
199,
504,
1973,
14,
3422,
492,
481,
20678,
5455,
12,
481,
20678,
3694,
199,
646,
1973,
14,
19601,
465,
20819,
63,
318,
421,
199,
318,
1104,
63,
589,
8,
589,
304,
272,
327,
2670,
340,
27969,
3495,
272,
27969,
63,
2101,
275,
747,
14,
515,
14,
4832,
8,
589,
14,
26374,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
26374,
63,
2101,
304,
267,
746,
1722,
480,
1173,
440,
1911,
26,
450,
83,
2,
450,
27969,
63,
2101,
9,
421,
199,
318,
2198,
63,
589,
837,
272,
1680,
63,
2087,
275,
7534,
14,
10730,
8,
1802,
628,
1554,
5763,
27969,
5077,
531,
272,
1680,
63,
2087,
14,
525,
63,
2094,
6096,
70,
401,
4320,
26374,
401,
1415,
29,
549,
12,
1169,
1720,
628,
1554,
5763,
27969,
570,
370,
2248,
531,
272,
1680,
63,
2087,
14,
525,
63,
2094,
6096,
68,
401,
4320,
1757,
401,
849,
29,
797,
12,
1595,
534,
1617,
63,
2052,
297,
1169,
1720,
628,
7687,
3105,
2556,
531,
272,
1249,
275,
1680,
63,
2087,
14,
1122,
63,
589,
342,
272,
1104,
63,
589,
8,
589,
9,
272,
372,
1249,
421,
199,
318,
2446,
837,
272,
408,
11298,
11855,
7584,
408,
339,
1249,
275,
2198,
63,
589,
342,
339,
943,
63,
1896,
275,
2050,
14,
4531,
272,
340,
1249,
14,
1757,
26,
267,
943,
63,
1896,
275,
2050,
14,
5287,
272,
2050,
14,
19602,
8,
1896,
29,
793,
63,
1896,
12,
1475,
17662,
1188,
9,
83,
531,
339,
2050,
14,
815,
480,
3162,
27969,
25937,
12594,
272,
13908,
63,
3422,
275,
481,
20678,
5455,
342,
339,
327,
3645,
8271,
327,
23,
367,
27969,
5235,
577,
2054,
272,
13908,
63,
3422,
14,
826,
8,
14156,
63,
318,
14,
36,
2054,
63,
998,
9,
339,
2050,
14,
815,
480,
9637,
577,
5763,
12594,
272,
13908,
63,
3422,
14,
3958,
63,
68,
681,
342,
272,
481,
20678,
3694,
8,
8835,
63,
3422,
14,
2374,
14,
8835,
63,
1205,
14,
585,
680,
1361,
342,
272,
2050,
14,
815,
480,
257,
3531,
35,
25548,
221,
520,
450,
83,
2,
450,
13908,
63,
3422,
14,
2374,
14,
32352,
63,
1760,
9,
272,
2050,
14,
815,
480,
257,
3531,
35,
491,
742,
221,
520,
450,
83,
2,
450,
13908,
63,
3422,
14,
2374,
14,
32352,
63,
552,
9,
339,
2050,
14,
815,
480,
2208,
15866,
1536,
577,
5763,
12594,
272,
13908,
63,
3422,
14,
4930,
63,
68,
681,
342,
272,
481,
20678,
3694,
8,
8835,
63,
3422,
14,
2374,
14,
8835,
63,
1205,
14,
585,
680,
1361,
342,
339,
13908,
63,
3422,
14,
2573,
63,
509,
63,
8835,
63,
4930,
63,
1205,
8,
14156,
63,
318,
14,
22679,
63,
6305,
63,
8727,
63,
22162,
9,
339,
2050,
14,
815,
480,
18085,
27969,
12594,
272,
13908,
63,
3422,
14,
4249,
63,
26374,
8,
589,
14,
26374,
9,
339,
2050,
14,
815,
480,
14740,
27969,
2004,
12594,
272,
340,
13908,
63,
3422,
14,
1074,
63,
8835,
63,
4930,
63,
1205,
8,
14156,
63,
318,
14,
22679,
63,
6305,
63,
19445,
63,
12533,
1149,
304,
267,
2050,
14,
815,
8,
13099,
14,
21613,
22501,
63,
1438,
435,
2151,
298,
38,
20678,
5235,
9709,
8792,
2,
2151,
435,
19442,
14,
18066,
63,
1761,
9,
267,
2050,
14,
815,
480,
20568,
3531,
35,
481,
87,
17960,
6430,
12594,
267,
13908,
63,
3422,
14,
32352,
14,
739,
63,
8835,
63,
2179,
342,
272,
587,
26,
267,
2050,
14,
705,
8,
13099,
14,
7387,
435,
1993,
298,
6386,
1,
16277,
370,
5235,
27969,
221,
6386,
9539,
1993,
435,
19442,
14,
18066,
63,
1761,
9,
272,
13908,
63,
3422,
14,
1600,
342,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
862,
26,
267,
2446,
342,
267,
747,
423,
2224,
8,
16,
9,
272,
871,
13483,
26,
221,
327,
445,
7245,
13,
35,
267,
747,
423,
2224,
8,
1079,
9,
272,
871,
14838,
26,
267,
746,
272,
871,
25416,
26,
267,
492,
5190,
267,
5190,
14,
1361,
63,
2804,
342,
267,
747,
423,
2224,
8,
975,
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
] |
[
2647,
15,
1393,
15,
1813,
2366,
19,
199,
3,
199,
3,
1898,
334,
67,
9,
20312,
20619,
11098,
199,
3,
199,
3,
6988,
19596,
13,
3761,
13,
7544,
26,
3668,
13,
18,
14,
16,
199,
199,
646,
747,
199,
646,
7534,
199,
646,
2050,
199,
199,
504,
3164,
14541,
492,
21684,
12,
19442,
199,
504,
1973,
14,
3422,
492,
481,
20678,
5455,
12,
481,
20678,
3694,
199,
646,
1973,
14,
19601,
465,
20819,
63,
318,
421,
199,
318,
1104,
63,
589,
8,
589,
304,
272,
327,
2670,
340,
27969,
3495,
272,
27969,
63,
2101,
275,
747,
14,
515,
14,
4832,
8,
589,
14,
26374,
9,
272,
340,
440,
747,
14,
515,
14,
2444,
8,
26374,
63,
2101,
304,
267,
746,
1722,
480,
1173,
440,
1911,
26,
450,
83,
2,
450,
27969,
63,
2101,
9,
421,
199,
318,
2198,
63,
589,
837,
272,
1680,
63,
2087,
275,
7534,
14,
10730,
8,
1802,
628,
1554,
5763,
27969,
5077,
531,
272,
1680,
63,
2087,
14,
525,
63,
2094,
6096,
70,
401,
4320,
26374,
401,
1415,
29,
549,
12,
1169,
1720,
628,
1554,
5763,
27969,
570,
370,
2248,
531,
272,
1680,
63,
2087,
14,
525,
63,
2094,
6096,
68,
401,
4320,
1757,
401,
849,
29,
797,
12,
1595,
534,
1617,
63,
2052,
297,
1169,
1720,
628,
7687,
3105,
2556,
531,
272,
1249,
275,
1680,
63,
2087,
14,
1122,
63,
589,
342,
272,
1104,
63,
589,
8,
589,
9,
272,
372,
1249,
421,
199,
318,
2446,
837,
272,
408,
11298,
11855,
7584,
408,
339,
1249,
275,
2198,
63,
589,
342,
339,
943,
63,
1896,
275,
2050,
14,
4531,
272,
340,
1249,
14,
1757,
26,
267,
943,
63,
1896,
275,
2050,
14,
5287,
272,
2050,
14,
19602,
8,
1896,
29,
793,
63,
1896,
12,
1475,
17662,
1188,
9,
83,
531,
339,
2050,
14,
815,
480,
3162,
27969,
25937,
12594,
272,
13908,
63,
3422,
275,
481,
20678,
5455,
342,
339,
327,
3645,
8271,
327,
23,
367,
27969,
5235,
577,
2054,
272,
13908,
63,
3422,
14,
826,
8,
14156,
63,
318,
14,
36,
2054,
63,
998,
9,
339,
2050,
14,
815,
480,
9637,
577,
5763,
12594,
272,
13908,
63,
3422,
14,
3958,
63,
68,
681,
342,
272,
481,
20678,
3694,
8,
8835,
63,
3422,
14,
2374,
14,
8835,
63,
1205,
14,
585,
680,
1361,
342,
272,
2050,
14,
815,
480,
257,
3531,
35,
25548,
221,
520,
450,
83,
2,
450,
13908,
63,
3422,
14,
2374,
14,
32352,
63,
1760,
9,
272,
2050,
14,
815,
480,
257,
3531,
35,
491,
742,
221,
520,
450,
83,
2,
450,
13908,
63,
3422,
14,
2374,
14,
32352,
63,
552,
9,
339,
2050,
14,
815,
480,
2208,
15866,
1536,
577,
5763,
12594,
272,
13908,
63,
3422,
14,
4930,
63,
68,
681,
342,
272,
481,
20678,
3694,
8,
8835,
63,
3422,
14,
2374,
14,
8835,
63,
1205,
14,
585,
680,
1361,
342,
339,
13908,
63,
3422,
14,
2573,
63,
509,
63,
8835,
63,
4930,
63,
1205,
8,
14156,
63,
318,
14,
22679,
63,
6305,
63,
8727,
63,
22162,
9,
339,
2050,
14,
815,
480,
18085,
27969,
12594,
272,
13908,
63,
3422,
14,
4249,
63,
26374,
8,
589,
14,
26374,
9,
339,
2050,
14,
815,
480,
14740,
27969,
2004,
12594,
272,
340,
13908,
63,
3422,
14,
1074,
63,
8835,
63,
4930,
63,
1205,
8,
14156,
63,
318,
14,
22679,
63,
6305,
63,
19445,
63,
12533,
1149,
304,
267,
2050,
14,
815,
8,
13099,
14,
21613,
22501,
63,
1438,
435,
2151,
298,
38,
20678,
5235,
9709,
8792,
2,
2151,
435,
19442,
14,
18066,
63,
1761,
9,
267,
2050,
14,
815,
480,
20568,
3531,
35,
481,
87,
17960,
6430,
12594,
267,
13908,
63,
3422,
14,
32352,
14,
739,
63,
8835,
63,
2179,
342,
272,
587,
26,
267,
2050,
14,
705,
8,
13099,
14,
7387,
435,
1993,
298,
6386,
1,
16277,
370,
5235,
27969,
221,
6386,
9539,
1993,
435,
19442,
14,
18066,
63,
1761,
9,
272,
13908,
63,
3422,
14,
1600,
342,
421,
199,
692,
636,
354,
363,
508,
4396,
973,
5727,
272,
862,
26,
267,
2446,
342,
267,
747,
423,
2224,
8,
16,
9,
272,
871,
13483,
26,
221,
327,
445,
7245,
13,
35,
267,
747,
423,
2224,
8,
1079,
9,
272,
871,
14838,
26,
267,
746,
272,
871,
25416,
26,
267,
492,
5190,
267,
5190,
14,
1361,
63,
2804,
342,
267,
747,
423,
2224,
8,
975,
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,
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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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
nekulin/arangodb
|
3rdParty/V8-4.3.61/third_party/python_26/Tools/scripts/checkappend.py
|
100
|
4658
|
#! /usr/bin/env python
# Released to the public domain, by Tim Peters, 28 February 2000.
"""checkappend.py -- search for multi-argument .append() calls.
Usage: specify one or more file or directory paths:
checkappend [-v] file_or_dir [file_or_dir] ...
Each file_or_dir is checked for multi-argument .append() calls. When
a directory, all .py files in the directory, and recursively in its
subdirectories, are checked.
Use -v for status msgs. Use -vv for more status msgs.
In the absence of -v, the only output is pairs of the form
filename(linenumber):
line containing the suspicious append
Note that this finds multi-argument append calls regardless of whether
they're attached to list objects. If a module defines a class with an
append method that takes more than one argument, calls to that method
will be listed.
Note that this will not find multi-argument list.append calls made via a
bound method object. For example, this is not caught:
somelist = []
push = somelist.append
push(1, 2, 3)
"""
__version__ = 1, 0, 0
import os
import sys
import getopt
import tokenize
verbose = 0
def errprint(*args):
msg = ' '.join(args)
sys.stderr.write(msg)
sys.stderr.write("\n")
def main():
args = sys.argv[1:]
global verbose
try:
opts, args = getopt.getopt(sys.argv[1:], "v")
except getopt.error, msg:
errprint(str(msg) + "\n\n" + __doc__)
return
for opt, optarg in opts:
if opt == '-v':
verbose = verbose + 1
if not args:
errprint(__doc__)
return
for arg in args:
check(arg)
def check(file):
if os.path.isdir(file) and not os.path.islink(file):
if verbose:
print "%r: listing directory" % (file,)
names = os.listdir(file)
for name in names:
fullname = os.path.join(file, name)
if ((os.path.isdir(fullname) and
not os.path.islink(fullname))
or os.path.normcase(name[-3:]) == ".py"):
check(fullname)
return
try:
f = open(file)
except IOError, msg:
errprint("%r: I/O Error: %s" % (file, msg))
return
if verbose > 1:
print "checking %r ..." % (file,)
ok = AppendChecker(file, f).run()
if verbose and ok:
print "%r: Clean bill of health." % (file,)
[FIND_DOT,
FIND_APPEND,
FIND_LPAREN,
FIND_COMMA,
FIND_STMT] = range(5)
class AppendChecker:
def __init__(self, fname, file):
self.fname = fname
self.file = file
self.state = FIND_DOT
self.nerrors = 0
def run(self):
try:
tokenize.tokenize(self.file.readline, self.tokeneater)
except tokenize.TokenError, msg:
errprint("%r: Token Error: %s" % (self.fname, msg))
self.nerrors = self.nerrors + 1
return self.nerrors == 0
def tokeneater(self, type, token, start, end, line,
NEWLINE=tokenize.NEWLINE,
JUNK=(tokenize.COMMENT, tokenize.NL),
OP=tokenize.OP,
NAME=tokenize.NAME):
state = self.state
if type in JUNK:
pass
elif state is FIND_DOT:
if type is OP and token == ".":
state = FIND_APPEND
elif state is FIND_APPEND:
if type is NAME and token == "append":
self.line = line
self.lineno = start[0]
state = FIND_LPAREN
else:
state = FIND_DOT
elif state is FIND_LPAREN:
if type is OP and token == "(":
self.level = 1
state = FIND_COMMA
else:
state = FIND_DOT
elif state is FIND_COMMA:
if type is OP:
if token in ("(", "{", "["):
self.level = self.level + 1
elif token in (")", "}", "]"):
self.level = self.level - 1
if self.level == 0:
state = FIND_DOT
elif token == "," and self.level == 1:
self.nerrors = self.nerrors + 1
print "%s(%d):\n%s" % (self.fname, self.lineno,
self.line)
# don't gripe about this stmt again
state = FIND_STMT
elif state is FIND_STMT:
if type is NEWLINE:
state = FIND_DOT
else:
raise SystemError("unknown internal state '%r'" % (state,))
self.state = state
if __name__ == '__main__':
main()
|
apache-2.0
|
[
3168,
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
17646,
68,
370,
314,
4575,
2881,
12,
701,
26244,
11379,
878,
12,
7294,
21141,
26709,
12293,
14,
199,
199,
624,
1074,
740,
14,
647,
1553,
2754,
367,
3510,
13,
2094,
1275,
740,
342,
4882,
14,
199,
199,
7692,
26,
221,
4165,
1373,
503,
1655,
570,
503,
2082,
3792,
26,
272,
1104,
740,
5243,
86,
61,
570,
63,
269,
63,
694,
359,
493,
63,
269,
63,
694,
61,
2263,
199,
199,
22321,
570,
63,
269,
63,
694,
365,
7923,
367,
3510,
13,
2094,
1275,
740,
342,
4882,
14,
221,
3979,
199,
65,
2082,
12,
1006,
1275,
647,
1584,
315,
314,
2082,
12,
436,
15035,
315,
2399,
199,
954,
12629,
12,
787,
7923,
14,
199,
199,
6119,
446,
86,
367,
2004,
17599,
14,
221,
3645,
446,
8958,
367,
1655,
2004,
17599,
14,
199,
199,
607,
314,
2236,
14073,
402,
446,
86,
12,
314,
1454,
1072,
365,
6342,
402,
314,
1824,
339,
1788,
8,
2950,
884,
304,
272,
1004,
3035,
314,
308,
28651,
5666,
199,
199,
7443,
626,
642,
17651,
3510,
13,
2094,
5666,
4882,
15270,
402,
3775,
199,
29002,
3984,
10102,
370,
769,
2251,
14,
221,
982,
282,
859,
7890,
282,
1021,
543,
376,
199,
740,
1083,
626,
6181,
1655,
2419,
1373,
1423,
12,
4882,
370,
626,
1083,
199,
14117,
506,
10532,
14,
199,
199,
7443,
626,
642,
911,
440,
2342,
3510,
13,
2094,
769,
14,
740,
4882,
6326,
4799,
282,
199,
3556,
1083,
909,
14,
221,
2104,
2893,
12,
642,
365,
440,
15604,
26,
339,
2005,
513,
275,
942,
272,
6675,
275,
2005,
513,
14,
740,
272,
6675,
8,
17,
12,
499,
12,
650,
9,
199,
624,
199,
199,
363,
1023,
363,
275,
413,
12,
378,
12,
378,
199,
199,
646,
747,
199,
646,
984,
199,
646,
12733,
199,
646,
13343,
199,
199,
3832,
275,
378,
199,
199,
318,
2329,
1361,
2031,
589,
304,
272,
1499,
275,
283,
1987,
904,
8,
589,
9,
272,
984,
14,
3083,
14,
952,
8,
1328,
9,
272,
984,
14,
3083,
14,
952,
4582,
78,
531,
199,
199,
318,
2446,
837,
272,
1249,
275,
984,
14,
3020,
59,
17,
2938,
272,
2288,
3376,
272,
862,
26,
267,
3999,
12,
1249,
275,
12733,
14,
18907,
8,
1274,
14,
3020,
59,
17,
8429,
298,
86,
531,
272,
871,
12733,
14,
705,
12,
1499,
26,
267,
2329,
1361,
8,
495,
8,
1328,
9,
435,
1867,
78,
60,
78,
2,
435,
636,
1301,
3368,
267,
372,
272,
367,
2450,
12,
2450,
1273,
315,
3999,
26,
267,
340,
2450,
508,
2475,
86,
356,
288,
3376,
275,
3376,
435,
413,
272,
340,
440,
1249,
26,
267,
2329,
1361,
3460,
1301,
3368,
267,
372,
272,
367,
1680,
315,
1249,
26,
267,
1104,
8,
1273,
9,
199,
199,
318,
1104,
8,
493,
304,
272,
340,
747,
14,
515,
14,
6027,
8,
493,
9,
436,
440,
747,
14,
515,
14,
20719,
8,
493,
304,
267,
340,
3376,
26,
288,
870,
2071,
82,
26,
13778,
2082,
2,
450,
334,
493,
4258,
267,
1561,
275,
747,
14,
7374,
8,
493,
9,
267,
367,
536,
315,
1561,
26,
288,
11064,
275,
747,
14,
515,
14,
904,
8,
493,
12,
536,
9,
288,
340,
3666,
736,
14,
515,
14,
6027,
8,
9930,
9,
436,
326,
440,
747,
14,
515,
14,
20719,
8,
9930,
430,
355,
503,
747,
14,
515,
14,
21288,
8,
354,
1988,
19,
5728,
508,
3680,
647,
2349,
355,
1104,
8,
9930,
9,
267,
372,
339,
862,
26,
267,
289,
275,
1551,
8,
493,
9,
272,
871,
5925,
12,
1499,
26,
267,
2329,
1361,
3647,
82,
26,
473,
15,
47,
4520,
26,
450,
83,
2,
450,
334,
493,
12,
1499,
430,
267,
372,
339,
340,
3376,
690,
413,
26,
267,
870,
298,
19527,
450,
82,
21742,
450,
334,
493,
4258,
339,
4112,
275,
18726,
3048,
8,
493,
12,
289,
680,
1065,
342,
272,
340,
3376,
436,
4112,
26,
267,
870,
2071,
82,
26,
12762,
330,
778,
402,
13822,
2122,
450,
334,
493,
4258,
199,
199,
59,
27087,
63,
13203,
12,
199,
481,
3192,
63,
25248,
12,
199,
481,
3192,
63,
44,
22169,
12,
199,
481,
3192,
63,
11265,
2054,
12,
199,
481,
3192,
63,
840,
5747,
61,
257,
275,
1425,
8,
21,
9,
199,
199,
533,
18726,
3048,
26,
272,
347,
636,
826,
721,
277,
12,
6748,
12,
570,
304,
267,
291,
14,
5252,
275,
6748,
267,
291,
14,
493,
275,
570,
267,
291,
14,
929,
275,
481,
3192,
63,
13203,
267,
291,
14,
78,
2550,
275,
378,
339,
347,
1255,
8,
277,
304,
267,
862,
26,
288,
13343,
14,
15246,
8,
277,
14,
493,
14,
6407,
12,
291,
14,
1418,
69,
6618,
9,
267,
871,
13343,
14,
3264,
547,
12,
1499,
26,
288,
2329,
1361,
3647,
82,
26,
8767,
4520,
26,
450,
83,
2,
450,
334,
277,
14,
5252,
12,
1499,
430,
288,
291,
14,
78,
2550,
275,
291,
14,
78,
2550,
435,
413,
267,
372,
291,
14,
78,
2550,
508,
378,
339,
347,
1526,
69,
6618,
8,
277,
12,
730,
12,
1526,
12,
1343,
12,
1284,
12,
1004,
12,
355,
18689,
6174,
29,
15246,
14,
28758,
12,
355,
1603,
8019,
2687,
15246,
14,
10973,
12,
13343,
14,
14176,
395,
355,
9827,
29,
15246,
14,
1938,
12,
355,
13637,
29,
15246,
14,
2339,
304,
398,
1174,
275,
291,
14,
929,
398,
340,
730,
315,
1603,
8019,
26,
288,
986,
398,
916,
1174,
365,
481,
3192,
63,
13203,
26,
288,
340,
730,
365,
9827,
436,
1526,
508,
3680,
582,
355,
1174,
275,
481,
3192,
63,
25248,
398,
916,
1174,
365,
481,
3192,
63,
25248,
26,
288,
340,
730,
365,
13637,
436,
1526,
508,
298,
740,
582,
355,
291,
14,
604,
275,
1004,
355,
291,
14,
3469,
275,
1343,
59,
16,
61,
355,
1174,
275,
481,
3192,
63,
44,
22169,
288,
587,
26,
355,
1174,
275,
481,
3192,
63,
13203,
398,
916,
1174,
365,
481,
3192,
63,
44,
22169,
26,
288,
340,
730,
365,
9827,
436,
1526,
508,
298,
20308,
355,
291,
14,
1896,
275,
413,
355,
1174,
275,
481,
3192,
63,
11265,
2054,
288,
587,
26,
355,
1174,
275,
481,
3192,
63,
13203,
398,
916,
1174,
365,
481,
3192,
63,
11265,
2054,
26,
288,
340,
730,
365,
9827,
26,
355
] |
[
1182,
2647,
15,
1393,
15,
1813,
2366,
199,
199,
3,
17646,
68,
370,
314,
4575,
2881,
12,
701,
26244,
11379,
878,
12,
7294,
21141,
26709,
12293,
14,
199,
199,
624,
1074,
740,
14,
647,
1553,
2754,
367,
3510,
13,
2094,
1275,
740,
342,
4882,
14,
199,
199,
7692,
26,
221,
4165,
1373,
503,
1655,
570,
503,
2082,
3792,
26,
272,
1104,
740,
5243,
86,
61,
570,
63,
269,
63,
694,
359,
493,
63,
269,
63,
694,
61,
2263,
199,
199,
22321,
570,
63,
269,
63,
694,
365,
7923,
367,
3510,
13,
2094,
1275,
740,
342,
4882,
14,
221,
3979,
199,
65,
2082,
12,
1006,
1275,
647,
1584,
315,
314,
2082,
12,
436,
15035,
315,
2399,
199,
954,
12629,
12,
787,
7923,
14,
199,
199,
6119,
446,
86,
367,
2004,
17599,
14,
221,
3645,
446,
8958,
367,
1655,
2004,
17599,
14,
199,
199,
607,
314,
2236,
14073,
402,
446,
86,
12,
314,
1454,
1072,
365,
6342,
402,
314,
1824,
339,
1788,
8,
2950,
884,
304,
272,
1004,
3035,
314,
308,
28651,
5666,
199,
199,
7443,
626,
642,
17651,
3510,
13,
2094,
5666,
4882,
15270,
402,
3775,
199,
29002,
3984,
10102,
370,
769,
2251,
14,
221,
982,
282,
859,
7890,
282,
1021,
543,
376,
199,
740,
1083,
626,
6181,
1655,
2419,
1373,
1423,
12,
4882,
370,
626,
1083,
199,
14117,
506,
10532,
14,
199,
199,
7443,
626,
642,
911,
440,
2342,
3510,
13,
2094,
769,
14,
740,
4882,
6326,
4799,
282,
199,
3556,
1083,
909,
14,
221,
2104,
2893,
12,
642,
365,
440,
15604,
26,
339,
2005,
513,
275,
942,
272,
6675,
275,
2005,
513,
14,
740,
272,
6675,
8,
17,
12,
499,
12,
650,
9,
199,
624,
199,
199,
363,
1023,
363,
275,
413,
12,
378,
12,
378,
199,
199,
646,
747,
199,
646,
984,
199,
646,
12733,
199,
646,
13343,
199,
199,
3832,
275,
378,
199,
199,
318,
2329,
1361,
2031,
589,
304,
272,
1499,
275,
283,
1987,
904,
8,
589,
9,
272,
984,
14,
3083,
14,
952,
8,
1328,
9,
272,
984,
14,
3083,
14,
952,
4582,
78,
531,
199,
199,
318,
2446,
837,
272,
1249,
275,
984,
14,
3020,
59,
17,
2938,
272,
2288,
3376,
272,
862,
26,
267,
3999,
12,
1249,
275,
12733,
14,
18907,
8,
1274,
14,
3020,
59,
17,
8429,
298,
86,
531,
272,
871,
12733,
14,
705,
12,
1499,
26,
267,
2329,
1361,
8,
495,
8,
1328,
9,
435,
1867,
78,
60,
78,
2,
435,
636,
1301,
3368,
267,
372,
272,
367,
2450,
12,
2450,
1273,
315,
3999,
26,
267,
340,
2450,
508,
2475,
86,
356,
288,
3376,
275,
3376,
435,
413,
272,
340,
440,
1249,
26,
267,
2329,
1361,
3460,
1301,
3368,
267,
372,
272,
367,
1680,
315,
1249,
26,
267,
1104,
8,
1273,
9,
199,
199,
318,
1104,
8,
493,
304,
272,
340,
747,
14,
515,
14,
6027,
8,
493,
9,
436,
440,
747,
14,
515,
14,
20719,
8,
493,
304,
267,
340,
3376,
26,
288,
870,
2071,
82,
26,
13778,
2082,
2,
450,
334,
493,
4258,
267,
1561,
275,
747,
14,
7374,
8,
493,
9,
267,
367,
536,
315,
1561,
26,
288,
11064,
275,
747,
14,
515,
14,
904,
8,
493,
12,
536,
9,
288,
340,
3666,
736,
14,
515,
14,
6027,
8,
9930,
9,
436,
326,
440,
747,
14,
515,
14,
20719,
8,
9930,
430,
355,
503,
747,
14,
515,
14,
21288,
8,
354,
1988,
19,
5728,
508,
3680,
647,
2349,
355,
1104,
8,
9930,
9,
267,
372,
339,
862,
26,
267,
289,
275,
1551,
8,
493,
9,
272,
871,
5925,
12,
1499,
26,
267,
2329,
1361,
3647,
82,
26,
473,
15,
47,
4520,
26,
450,
83,
2,
450,
334,
493,
12,
1499,
430,
267,
372,
339,
340,
3376,
690,
413,
26,
267,
870,
298,
19527,
450,
82,
21742,
450,
334,
493,
4258,
339,
4112,
275,
18726,
3048,
8,
493,
12,
289,
680,
1065,
342,
272,
340,
3376,
436,
4112,
26,
267,
870,
2071,
82,
26,
12762,
330,
778,
402,
13822,
2122,
450,
334,
493,
4258,
199,
199,
59,
27087,
63,
13203,
12,
199,
481,
3192,
63,
25248,
12,
199,
481,
3192,
63,
44,
22169,
12,
199,
481,
3192,
63,
11265,
2054,
12,
199,
481,
3192,
63,
840,
5747,
61,
257,
275,
1425,
8,
21,
9,
199,
199,
533,
18726,
3048,
26,
272,
347,
636,
826,
721,
277,
12,
6748,
12,
570,
304,
267,
291,
14,
5252,
275,
6748,
267,
291,
14,
493,
275,
570,
267,
291,
14,
929,
275,
481,
3192,
63,
13203,
267,
291,
14,
78,
2550,
275,
378,
339,
347,
1255,
8,
277,
304,
267,
862,
26,
288,
13343,
14,
15246,
8,
277,
14,
493,
14,
6407,
12,
291,
14,
1418,
69,
6618,
9,
267,
871,
13343,
14,
3264,
547,
12,
1499,
26,
288,
2329,
1361,
3647,
82,
26,
8767,
4520,
26,
450,
83,
2,
450,
334,
277,
14,
5252,
12,
1499,
430,
288,
291,
14,
78,
2550,
275,
291,
14,
78,
2550,
435,
413,
267,
372,
291,
14,
78,
2550,
508,
378,
339,
347,
1526,
69,
6618,
8,
277,
12,
730,
12,
1526,
12,
1343,
12,
1284,
12,
1004,
12,
355,
18689,
6174,
29,
15246,
14,
28758,
12,
355,
1603,
8019,
2687,
15246,
14,
10973,
12,
13343,
14,
14176,
395,
355,
9827,
29,
15246,
14,
1938,
12,
355,
13637,
29,
15246,
14,
2339,
304,
398,
1174,
275,
291,
14,
929,
398,
340,
730,
315,
1603,
8019,
26,
288,
986,
398,
916,
1174,
365,
481,
3192,
63,
13203,
26,
288,
340,
730,
365,
9827,
436,
1526,
508,
3680,
582,
355,
1174,
275,
481,
3192,
63,
25248,
398,
916,
1174,
365,
481,
3192,
63,
25248,
26,
288,
340,
730,
365,
13637,
436,
1526,
508,
298,
740,
582,
355,
291,
14,
604,
275,
1004,
355,
291,
14,
3469,
275,
1343,
59,
16,
61,
355,
1174,
275,
481,
3192,
63,
44,
22169,
288,
587,
26,
355,
1174,
275,
481,
3192,
63,
13203,
398,
916,
1174,
365,
481,
3192,
63,
44,
22169,
26,
288,
340,
730,
365,
9827,
436,
1526,
508,
298,
20308,
355,
291,
14,
1896,
275,
413,
355,
1174,
275,
481,
3192,
63,
11265,
2054,
288,
587,
26,
355,
1174,
275,
481,
3192,
63,
13203,
398,
916,
1174,
365,
481,
3192,
63,
11265,
2054,
26,
288,
340,
730,
365,
9827,
26,
355,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
] |
pajlada/pajbot
|
pajbot/managers/emote.py
|
1
|
13594
|
from typing import Optional
import logging
import random
from pajbot.managers.redis import RedisManager
from pajbot.managers.schedule import ScheduleManager
from pajbot.models.emote import Emote, EmoteInstance, EmoteInstanceCount
from pajbot.streamhelper import StreamHelper
from pajbot.utils import iterate_split_with_index
from pajbot.apiwrappers.twitchemotesapi import TwitchEmotesAPI
log = logging.getLogger(__name__)
class GenericChannelEmoteManager:
# to be implemented
api = None
friendly_name: Optional[str] = None
def __init__(self):
self._global_emotes = []
self._channel_emotes = []
self.streamer = StreamHelper.get_streamer()
self.streamer_id = StreamHelper.get_streamer_id()
self.global_lookup_table = {}
self.channel_lookup_table = {}
@property
def global_emotes(self):
return self._global_emotes
@global_emotes.setter
def global_emotes(self, value):
self._global_emotes = value
self.global_lookup_table = {emote.code: emote for emote in value} if value is not None else {}
@property
def channel_emotes(self):
return self._channel_emotes
@channel_emotes.setter
def channel_emotes(self, value):
self._channel_emotes = value
self.channel_lookup_table = {emote.code: emote for emote in value} if value is not None else {}
def load_global_emotes(self):
"""Load channel emotes from the cache if available, or else, query the API."""
self.global_emotes = self.api.get_global_emotes()
def update_global_emotes(self):
self.global_emotes = self.api.get_global_emotes(force_fetch=True)
def load_channel_emotes(self):
"""Load channel emotes from the cache if available, or else, query the API."""
self.channel_emotes = self.api.get_channel_emotes(self.streamer)
def update_channel_emotes(self):
self.channel_emotes = self.api.get_channel_emotes(self.streamer, force_fetch=True)
def update_all(self):
self.update_global_emotes()
self.update_channel_emotes()
def load_all(self):
self.load_global_emotes()
self.load_channel_emotes()
def match_channel_emote(self, word):
"""Attempts to find a matching emote equaling the given word from the channel emotes known to this manager.
Returns None if no emote was matched"""
return self.channel_lookup_table.get(word, None)
def match_global_emote(self, word):
"""Attempts to find a matching emote equaling the given word from the global emotes known to this manager.
Returns None if no emote was matched"""
return self.global_lookup_table.get(word, None)
class TwitchEmoteManager(GenericChannelEmoteManager):
friendly_name = "Twitch"
def __init__(self, twitch_v5_api):
self.api = TwitchEmotesAPI(RedisManager.get())
self.twitch_v5_api = twitch_v5_api
self.streamer = StreamHelper.get_streamer()
self.streamer_id = StreamHelper.get_streamer_id()
self.tier_one_emotes = []
self.tier_two_emotes = []
self.tier_three_emotes = []
super().__init__()
@property # type: ignore
def channel_emotes(self):
return self.tier_one_emotes
def load_global_emotes(self):
self.global_emotes = self.twitch_v5_api.get_global_emotes()
def update_global_emotes(self):
self.global_emotes = self.twitch_v5_api.get_global_emotes(force_fetch=True)
def load_channel_emotes(self):
self.tier_one_emotes, self.tier_two_emotes, self.tier_three_emotes = self.api.get_channel_emotes(
self.streamer_id, self.streamer
)
def update_channel_emotes(self):
self.tier_one_emotes, self.tier_two_emotes, self.tier_three_emotes = self.api.get_channel_emotes(
self.streamer_id, self.streamer, force_fetch=True
)
class FFZEmoteManager(GenericChannelEmoteManager):
friendly_name = "FFZ"
def __init__(self):
from pajbot.apiwrappers.ffz import FFZAPI
self.api = FFZAPI(RedisManager.get())
super().__init__()
class BTTVEmoteManager(GenericChannelEmoteManager):
friendly_name = "BTTV"
def __init__(self):
from pajbot.apiwrappers.bttv import BTTVAPI
self.api = BTTVAPI(RedisManager.get())
self.streamer = StreamHelper.get_streamer()
self.streamer_id = StreamHelper.get_streamer_id()
super().__init__()
def load_channel_emotes(self):
"""Load channel emotes from the cache if available, or else, query the API."""
self.channel_emotes = self.api.get_channel_emotes(self.streamer_id)
def update_channel_emotes(self):
self.channel_emotes = self.api.get_channel_emotes(self.streamer_id, force_fetch=True)
class EmoteManager:
def __init__(self, twitch_v5_api, action_queue):
self.action_queue = action_queue
self.streamer = StreamHelper.get_streamer()
self.streamer_id = StreamHelper.get_streamer_id()
self.twitch_emote_manager = TwitchEmoteManager(twitch_v5_api)
self.ffz_emote_manager = FFZEmoteManager()
self.bttv_emote_manager = BTTVEmoteManager()
self.epm = {}
# every 1 hour
# note: whenever emotes are refreshed (cache is saved to redis), the key is additionally set to expire
# in one hour. This is to prevent emotes from never refreshing if the bot restarts in less than an hour.
# (This also means that the bot will never have emotes older than 2 hours)
ScheduleManager.execute_every(1 * 60 * 60, self.update_all_emotes)
self.load_all_emotes()
def update_all_emotes(self):
self.action_queue.submit(self.bttv_emote_manager.update_all)
self.action_queue.submit(self.ffz_emote_manager.update_all)
self.action_queue.submit(self.twitch_emote_manager.update_all)
def load_all_emotes(self):
self.action_queue.submit(self.bttv_emote_manager.load_all)
self.action_queue.submit(self.ffz_emote_manager.load_all)
self.action_queue.submit(self.twitch_emote_manager.load_all)
@staticmethod
def twitch_emote_url(emote_id, size):
return f"https://static-cdn.jtvnw.net/emoticons/v1/{emote_id}/{size}"
@staticmethod
def twitch_emote(emote_id, code):
return Emote(
code=code,
provider="twitch",
id=emote_id,
urls={
"1": EmoteManager.twitch_emote_url(emote_id, "1.0"),
"2": EmoteManager.twitch_emote_url(emote_id, "2.0"),
"4": EmoteManager.twitch_emote_url(emote_id, "3.0"),
},
)
@staticmethod
def twitch_emote_instance(emote_id, code, start, end):
return EmoteInstance(start=start, end=end, emote=EmoteManager.twitch_emote(emote_id, code))
@staticmethod
def parse_twitch_emotes_tag(tag, message):
if len(tag) <= 0:
return []
emote_instances = []
for emote_src in tag.split("/"):
emote_id, emote_instances_src = emote_src.split(":")
for emote_instance_src in emote_instances_src.split(","):
start_src, end_src = emote_instance_src.split("-")
start = int(start_src)
end = int(end_src) + 1
code = message[start:end]
emote_instances.append(EmoteManager.twitch_emote_instance(emote_id, code, start, end))
return emote_instances
def match_word_to_emote(self, word):
emote = self.ffz_emote_manager.match_channel_emote(word)
if emote is not None:
return emote
emote = self.bttv_emote_manager.match_channel_emote(word)
if emote is not None:
return emote
emote = self.ffz_emote_manager.match_global_emote(word)
if emote is not None:
return emote
emote = self.bttv_emote_manager.match_global_emote(word)
if emote is not None:
return emote
return None
def parse_all_emotes(self, message, twitch_emotes_tag=""):
# Twitch Emotes
twitch_emote_instances = self.parse_twitch_emotes_tag(twitch_emotes_tag, message)
twitch_emote_start_indices = {instance.start for instance in twitch_emote_instances}
# for the other providers, split the message by spaces
# and then, if word is not a twitch emote, consider ffz channel -> bttv channel ->
# ffz global -> bttv global in that order.
third_party_emote_instances = []
for current_word_index, word in iterate_split_with_index(message.split(" ")):
# ignore twitch emotes
is_twitch_emote = current_word_index in twitch_emote_start_indices
if is_twitch_emote:
continue
emote = self.match_word_to_emote(word)
if emote is None:
# this word is not an emote
continue
third_party_emote_instances.append(
EmoteInstance(start=current_word_index, end=current_word_index + len(word), emote=emote)
)
all_instances = twitch_emote_instances + third_party_emote_instances
all_instances.sort(key=lambda instance: instance.start)
return all_instances, compute_emote_counts(all_instances)
def random_emote(
self,
twitch_global=False,
twitch_channel_tier1=False,
twitch_channel_tier2=False,
twitch_channel_tier3=False,
ffz_global=False,
ffz_channel=False,
bttv_global=False,
bttv_channel=False,
):
emotes = []
if twitch_global:
emotes += self.twitch_emote_manager.global_emotes
if twitch_channel_tier1:
emotes += self.twitch_emote_manager.tier_one_emotes
if twitch_channel_tier2:
emotes += self.twitch_emote_manager.tier_two_emotes
if twitch_channel_tier3:
emotes += self.twitch_emote_manager.tier_three_emotes
if ffz_global:
emotes += self.ffz_emote_manager.global_emotes
if ffz_channel:
emotes += self.ffz_emote_manager.channel_emotes
if bttv_global:
emotes += self.bttv_emote_manager.global_emotes
if bttv_channel:
emotes += self.bttv_emote_manager.channel_emotes
if len(emotes) <= 0:
return None
return random.choice(emotes)
def compute_emote_counts(emote_instances):
"""Turns a list of emote instances into a map mapping emote code
to count and a list of instances."""
emote_counts = {}
for emote_instance in emote_instances:
emote_code = emote_instance.emote.code
current_value = emote_counts.get(emote_code, None)
if current_value is None:
current_value = EmoteInstanceCount(count=1, emote=emote_instance.emote, emote_instances=[emote_instance])
emote_counts[emote_code] = current_value
else:
current_value.count += 1
current_value.emote_instances.append(emote_instance)
return emote_counts
class EpmManager:
def __init__(self):
self.epm = {}
redis = RedisManager.get()
self.redis_zadd_if_higher = redis.register_script(
"""
local c = tonumber(redis.call('zscore', KEYS[1], ARGV[1]));
if c then
if tonumber(KEYS[2]) > c then
redis.call('zadd', KEYS[1], KEYS[2], ARGV[1])
return tonumber(KEYS[2]) - c
else
return 0
end
else
redis.call('zadd', KEYS[1], KEYS[2], ARGV[1])
return 'OK'
end
"""
)
def handle_emotes(self, emote_counts):
# passed dict maps emote code (e.g. "Kappa") to an EmoteInstanceCount instance
for emote_code, obj in emote_counts.items():
self.epm_incr(emote_code, obj.count)
def epm_incr(self, code, count):
new_epm = self.epm.get(code, 0) + count
self.epm[code] = new_epm
self.save_epm_record(code, new_epm)
ScheduleManager.execute_delayed(60, self.epm_decr, args=[code, count])
def epm_decr(self, code, count):
self.epm[code] -= count
def save_epm_record(self, code, count):
streamer = StreamHelper.get_streamer()
self.redis_zadd_if_higher(keys=[f"{streamer}:emotes:epmrecord", count], args=[code])
def get_emote_epm(self, emote_code):
"""Returns the current "emote per minute" usage of the given emote code,
or None if the emote is unknown to the bot."""
return self.epm.get(emote_code, None)
@staticmethod
def get_emote_epm_record(emote_code):
redis = RedisManager.get()
streamer = StreamHelper.get_streamer()
return redis.zscore(f"{streamer}:emotes:epmrecord", emote_code)
class EcountManager:
@staticmethod
def handle_emotes(emote_counts):
# passed dict maps emote code (e.g. "Kappa") to an EmoteInstanceCount instance
streamer = StreamHelper.get_streamer()
redis_key = f"{streamer}:emotes:count"
with RedisManager.pipeline_context() as redis:
for emote_code, instance_counts in emote_counts.items():
redis.zincrby(redis_key, instance_counts.count, emote_code)
@staticmethod
def get_emote_count(emote_code):
redis = RedisManager.get()
streamer = StreamHelper.get_streamer()
emote_count = redis.zscore(f"{streamer}:emotes:count", emote_code)
if emote_count is None:
return None
return int(emote_count)
|
mit
|
[
504,
14090,
492,
4879,
199,
199,
646,
2050,
199,
199,
646,
2196,
199,
199,
504,
691,
74,
3018,
14,
16259,
14,
15369,
492,
25496,
2988,
199,
504,
691,
74,
3018,
14,
16259,
14,
7211,
492,
24317,
2988,
199,
504,
691,
74,
3018,
14,
992,
14,
69,
2137,
492,
662,
2137,
12,
662,
2137,
3244,
12,
662,
2137,
3244,
2353,
199,
504,
691,
74,
3018,
14,
1745,
3676,
492,
8271,
4433,
199,
504,
691,
74,
3018,
14,
1208,
492,
13974,
63,
1294,
63,
1045,
63,
1080,
199,
504,
691,
74,
3018,
14,
1246,
21148,
14,
84,
2503,
595,
573,
744,
1246,
492,
377,
3111,
37,
573,
744,
3735,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
8307,
5358,
37,
2137,
2988,
26,
272,
327,
370,
506,
6366,
272,
2986,
275,
488,
272,
21428,
63,
354,
26,
4879,
59,
495,
61,
275,
488,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
2966,
63,
69,
573,
744,
275,
942,
267,
291,
423,
2775,
63,
69,
573,
744,
275,
942,
267,
291,
14,
270,
24362,
275,
8271,
4433,
14,
362,
63,
270,
24362,
342,
267,
291,
14,
270,
24362,
63,
344,
275,
8271,
4433,
14,
362,
63,
270,
24362,
63,
344,
342,
267,
291,
14,
2966,
63,
3892,
63,
1224,
275,
1052,
267,
291,
14,
2775,
63,
3892,
63,
1224,
275,
1052,
339,
768,
1829,
272,
347,
2288,
63,
69,
573,
744,
8,
277,
304,
267,
372,
291,
423,
2966,
63,
69,
573,
744,
339,
768,
2966,
63,
69,
573,
744,
14,
8345,
272,
347,
2288,
63,
69,
573,
744,
8,
277,
12,
574,
304,
267,
291,
423,
2966,
63,
69,
573,
744,
275,
574,
267,
291,
14,
2966,
63,
3892,
63,
1224,
275,
469,
69,
2137,
14,
600,
26,
325,
2137,
367,
325,
2137,
315,
574,
93,
340,
574,
365,
440,
488,
587,
1052,
339,
768,
1829,
272,
347,
3623,
63,
69,
573,
744,
8,
277,
304,
267,
372,
291,
423,
2775,
63,
69,
573,
744,
339,
768,
2775,
63,
69,
573,
744,
14,
8345,
272,
347,
3623,
63,
69,
573,
744,
8,
277,
12,
574,
304,
267,
291,
423,
2775,
63,
69,
573,
744,
275,
574,
267,
291,
14,
2775,
63,
3892,
63,
1224,
275,
469,
69,
2137,
14,
600,
26,
325,
2137,
367,
325,
2137,
315,
574,
93,
340,
574,
365,
440,
488,
587,
1052,
339,
347,
2248,
63,
2966,
63,
69,
573,
744,
8,
277,
304,
267,
408,
6200,
3623,
325,
573,
744,
687,
314,
2581,
340,
2808,
12,
503,
587,
12,
1827,
314,
3261,
1041,
267,
291,
14,
2966,
63,
69,
573,
744,
275,
291,
14,
1246,
14,
362,
63,
2966,
63,
69,
573,
744,
342,
339,
347,
1678,
63,
2966,
63,
69,
573,
744,
8,
277,
304,
267,
291,
14,
2966,
63,
69,
573,
744,
275,
291,
14,
1246,
14,
362,
63,
2966,
63,
69,
573,
744,
8,
3990,
63,
3535,
29,
549,
9,
339,
347,
2248,
63,
2775,
63,
69,
573,
744,
8,
277,
304,
267,
408,
6200,
3623,
325,
573,
744,
687,
314,
2581,
340,
2808,
12,
503,
587,
12,
1827,
314,
3261,
1041,
267,
291,
14,
2775,
63,
69,
573,
744,
275,
291,
14,
1246,
14,
362,
63,
2775,
63,
69,
573,
744,
8,
277,
14,
270,
24362,
9,
339,
347,
1678,
63,
2775,
63,
69,
573,
744,
8,
277,
304,
267,
291,
14,
2775,
63,
69,
573,
744,
275,
291,
14,
1246,
14,
362,
63,
2775,
63,
69,
573,
744,
8,
277,
14,
270,
24362,
12,
3542,
63,
3535,
29,
549,
9,
339,
347,
1678,
63,
452,
8,
277,
304,
267,
291,
14,
873,
63,
2966,
63,
69,
573,
744,
342,
267,
291,
14,
873,
63,
2775,
63,
69,
573,
744,
342,
339,
347,
2248,
63,
452,
8,
277,
304,
267,
291,
14,
912,
63,
2966,
63,
69,
573,
744,
342,
267,
291,
14,
912,
63,
2775,
63,
69,
573,
744,
342,
339,
347,
1336,
63,
2775,
63,
69,
2137,
8,
277,
12,
4349,
304,
267,
408,
15322,
1086,
370,
2342,
282,
4877,
325,
2137,
4472,
316,
314,
1627,
4349,
687,
314,
3623,
325,
573,
744,
6040,
370,
642,
5256,
14,
267,
1803,
488,
340,
949,
325,
2137,
1990,
7838,
624,
267,
372,
291,
14,
2775,
63,
3892,
63,
1224,
14,
362,
8,
1027,
12,
488,
9,
339,
347,
1336,
63,
2966,
63,
69,
2137,
8,
277,
12,
4349,
304,
267,
408,
15322,
1086,
370,
2342,
282,
4877,
325,
2137,
4472,
316,
314,
1627,
4349,
687,
314,
2288,
325,
573,
744,
6040,
370,
642,
5256,
14,
267,
1803,
488,
340,
949,
325,
2137,
1990,
7838,
624,
267,
372,
291,
14,
2966,
63,
3892,
63,
1224,
14,
362,
8,
1027,
12,
488,
9,
421,
199,
533,
377,
3111,
37,
2137,
2988,
8,
9417,
5358,
37,
2137,
2988,
304,
272,
21428,
63,
354,
275,
298,
52,
3111,
2,
339,
347,
636,
826,
721,
277,
12,
307,
3111,
63,
86,
21,
63,
1246,
304,
267,
291,
14,
1246,
275,
377,
3111,
37,
573,
744,
3735,
8,
29605,
2988,
14,
362,
1012,
267,
291,
14,
84,
3111,
63,
86,
21,
63,
1246,
275,
307,
3111,
63,
86,
21,
63,
1246,
267,
291,
14,
270,
24362,
275,
8271,
4433,
14,
362,
63,
270,
24362,
342,
267,
291,
14,
270,
24362,
63,
344,
275,
8271,
4433,
14,
362,
63,
270,
24362,
63,
344,
342,
267,
291,
14,
13949,
63,
368,
63,
69,
573,
744,
275,
942,
267,
291,
14,
13949,
63,
5601,
63,
69,
573,
744,
275,
942,
267,
291,
14,
13949,
63,
10480,
63,
69,
573,
744,
275,
942,
398,
1613,
11027,
826,
4533,
339,
768,
1829,
221,
327,
730,
26,
3686,
272,
347,
3623,
63,
69,
573,
744,
8,
277,
304,
267,
372,
291,
14,
13949,
63,
368,
63,
69,
573,
744,
339,
347,
2248,
63,
2966,
63,
69,
573,
744,
8,
277,
304,
267,
291,
14,
2966,
63,
69,
573,
744,
275,
291,
14,
84,
3111,
63,
86,
21,
63,
1246,
14,
362,
63,
2966,
63,
69,
573,
744,
342,
339,
347,
1678,
63,
2966,
63,
69,
573,
744,
8,
277,
304,
267,
291,
14,
2966,
63,
69,
573,
744,
275,
291,
14,
84,
3111,
63,
86,
21,
63,
1246,
14,
362,
63,
2966
] |
[
14090,
492,
4879,
199,
199,
646,
2050,
199,
199,
646,
2196,
199,
199,
504,
691,
74,
3018,
14,
16259,
14,
15369,
492,
25496,
2988,
199,
504,
691,
74,
3018,
14,
16259,
14,
7211,
492,
24317,
2988,
199,
504,
691,
74,
3018,
14,
992,
14,
69,
2137,
492,
662,
2137,
12,
662,
2137,
3244,
12,
662,
2137,
3244,
2353,
199,
504,
691,
74,
3018,
14,
1745,
3676,
492,
8271,
4433,
199,
504,
691,
74,
3018,
14,
1208,
492,
13974,
63,
1294,
63,
1045,
63,
1080,
199,
504,
691,
74,
3018,
14,
1246,
21148,
14,
84,
2503,
595,
573,
744,
1246,
492,
377,
3111,
37,
573,
744,
3735,
199,
199,
793,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
8307,
5358,
37,
2137,
2988,
26,
272,
327,
370,
506,
6366,
272,
2986,
275,
488,
272,
21428,
63,
354,
26,
4879,
59,
495,
61,
275,
488,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
2966,
63,
69,
573,
744,
275,
942,
267,
291,
423,
2775,
63,
69,
573,
744,
275,
942,
267,
291,
14,
270,
24362,
275,
8271,
4433,
14,
362,
63,
270,
24362,
342,
267,
291,
14,
270,
24362,
63,
344,
275,
8271,
4433,
14,
362,
63,
270,
24362,
63,
344,
342,
267,
291,
14,
2966,
63,
3892,
63,
1224,
275,
1052,
267,
291,
14,
2775,
63,
3892,
63,
1224,
275,
1052,
339,
768,
1829,
272,
347,
2288,
63,
69,
573,
744,
8,
277,
304,
267,
372,
291,
423,
2966,
63,
69,
573,
744,
339,
768,
2966,
63,
69,
573,
744,
14,
8345,
272,
347,
2288,
63,
69,
573,
744,
8,
277,
12,
574,
304,
267,
291,
423,
2966,
63,
69,
573,
744,
275,
574,
267,
291,
14,
2966,
63,
3892,
63,
1224,
275,
469,
69,
2137,
14,
600,
26,
325,
2137,
367,
325,
2137,
315,
574,
93,
340,
574,
365,
440,
488,
587,
1052,
339,
768,
1829,
272,
347,
3623,
63,
69,
573,
744,
8,
277,
304,
267,
372,
291,
423,
2775,
63,
69,
573,
744,
339,
768,
2775,
63,
69,
573,
744,
14,
8345,
272,
347,
3623,
63,
69,
573,
744,
8,
277,
12,
574,
304,
267,
291,
423,
2775,
63,
69,
573,
744,
275,
574,
267,
291,
14,
2775,
63,
3892,
63,
1224,
275,
469,
69,
2137,
14,
600,
26,
325,
2137,
367,
325,
2137,
315,
574,
93,
340,
574,
365,
440,
488,
587,
1052,
339,
347,
2248,
63,
2966,
63,
69,
573,
744,
8,
277,
304,
267,
408,
6200,
3623,
325,
573,
744,
687,
314,
2581,
340,
2808,
12,
503,
587,
12,
1827,
314,
3261,
1041,
267,
291,
14,
2966,
63,
69,
573,
744,
275,
291,
14,
1246,
14,
362,
63,
2966,
63,
69,
573,
744,
342,
339,
347,
1678,
63,
2966,
63,
69,
573,
744,
8,
277,
304,
267,
291,
14,
2966,
63,
69,
573,
744,
275,
291,
14,
1246,
14,
362,
63,
2966,
63,
69,
573,
744,
8,
3990,
63,
3535,
29,
549,
9,
339,
347,
2248,
63,
2775,
63,
69,
573,
744,
8,
277,
304,
267,
408,
6200,
3623,
325,
573,
744,
687,
314,
2581,
340,
2808,
12,
503,
587,
12,
1827,
314,
3261,
1041,
267,
291,
14,
2775,
63,
69,
573,
744,
275,
291,
14,
1246,
14,
362,
63,
2775,
63,
69,
573,
744,
8,
277,
14,
270,
24362,
9,
339,
347,
1678,
63,
2775,
63,
69,
573,
744,
8,
277,
304,
267,
291,
14,
2775,
63,
69,
573,
744,
275,
291,
14,
1246,
14,
362,
63,
2775,
63,
69,
573,
744,
8,
277,
14,
270,
24362,
12,
3542,
63,
3535,
29,
549,
9,
339,
347,
1678,
63,
452,
8,
277,
304,
267,
291,
14,
873,
63,
2966,
63,
69,
573,
744,
342,
267,
291,
14,
873,
63,
2775,
63,
69,
573,
744,
342,
339,
347,
2248,
63,
452,
8,
277,
304,
267,
291,
14,
912,
63,
2966,
63,
69,
573,
744,
342,
267,
291,
14,
912,
63,
2775,
63,
69,
573,
744,
342,
339,
347,
1336,
63,
2775,
63,
69,
2137,
8,
277,
12,
4349,
304,
267,
408,
15322,
1086,
370,
2342,
282,
4877,
325,
2137,
4472,
316,
314,
1627,
4349,
687,
314,
3623,
325,
573,
744,
6040,
370,
642,
5256,
14,
267,
1803,
488,
340,
949,
325,
2137,
1990,
7838,
624,
267,
372,
291,
14,
2775,
63,
3892,
63,
1224,
14,
362,
8,
1027,
12,
488,
9,
339,
347,
1336,
63,
2966,
63,
69,
2137,
8,
277,
12,
4349,
304,
267,
408,
15322,
1086,
370,
2342,
282,
4877,
325,
2137,
4472,
316,
314,
1627,
4349,
687,
314,
2288,
325,
573,
744,
6040,
370,
642,
5256,
14,
267,
1803,
488,
340,
949,
325,
2137,
1990,
7838,
624,
267,
372,
291,
14,
2966,
63,
3892,
63,
1224,
14,
362,
8,
1027,
12,
488,
9,
421,
199,
533,
377,
3111,
37,
2137,
2988,
8,
9417,
5358,
37,
2137,
2988,
304,
272,
21428,
63,
354,
275,
298,
52,
3111,
2,
339,
347,
636,
826,
721,
277,
12,
307,
3111,
63,
86,
21,
63,
1246,
304,
267,
291,
14,
1246,
275,
377,
3111,
37,
573,
744,
3735,
8,
29605,
2988,
14,
362,
1012,
267,
291,
14,
84,
3111,
63,
86,
21,
63,
1246,
275,
307,
3111,
63,
86,
21,
63,
1246,
267,
291,
14,
270,
24362,
275,
8271,
4433,
14,
362,
63,
270,
24362,
342,
267,
291,
14,
270,
24362,
63,
344,
275,
8271,
4433,
14,
362,
63,
270,
24362,
63,
344,
342,
267,
291,
14,
13949,
63,
368,
63,
69,
573,
744,
275,
942,
267,
291,
14,
13949,
63,
5601,
63,
69,
573,
744,
275,
942,
267,
291,
14,
13949,
63,
10480,
63,
69,
573,
744,
275,
942,
398,
1613,
11027,
826,
4533,
339,
768,
1829,
221,
327,
730,
26,
3686,
272,
347,
3623,
63,
69,
573,
744,
8,
277,
304,
267,
372,
291,
14,
13949,
63,
368,
63,
69,
573,
744,
339,
347,
2248,
63,
2966,
63,
69,
573,
744,
8,
277,
304,
267,
291,
14,
2966,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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
] |
EasonYi/flask
|
tests/test_templating.py
|
148
|
13057
|
# -*- coding: utf-8 -*-
"""
tests.templating
~~~~~~~~~~~~~~~~
Template functionality
:copyright: (c) 2015 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
import pytest
import flask
import logging
from jinja2 import TemplateNotFound
def test_context_processing():
app = flask.Flask(__name__)
@app.context_processor
def context_processor():
return {'injected_value': 42}
@app.route('/')
def index():
return flask.render_template('context_template.html', value=23)
rv = app.test_client().get('/')
assert rv.data == b'<p>23|42'
def test_original_win():
app = flask.Flask(__name__)
@app.route('/')
def index():
return flask.render_template_string('{{ config }}', config=42)
rv = app.test_client().get('/')
assert rv.data == b'42'
def test_request_less_rendering():
app = flask.Flask(__name__)
app.config['WORLD_NAME'] = 'Special World'
@app.context_processor
def context_processor():
return dict(foo=42)
with app.app_context():
rv = flask.render_template_string('Hello {{ config.WORLD_NAME }} '
'{{ foo }}')
assert rv == 'Hello Special World 42'
def test_standard_context():
app = flask.Flask(__name__)
app.secret_key = 'development key'
@app.route('/')
def index():
flask.g.foo = 23
flask.session['test'] = 'aha'
return flask.render_template_string('''
{{ request.args.foo }}
{{ g.foo }}
{{ config.DEBUG }}
{{ session.test }}
''')
rv = app.test_client().get('/?foo=42')
assert rv.data.split() == [b'42', b'23', b'False', b'aha']
def test_escaping():
text = '<p>Hello World!'
app = flask.Flask(__name__)
@app.route('/')
def index():
return flask.render_template('escaping_template.html', text=text,
html=flask.Markup(text))
lines = app.test_client().get('/').data.splitlines()
assert lines == [
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!'
]
def test_no_escaping():
text = '<p>Hello World!'
app = flask.Flask(__name__)
@app.route('/')
def index():
return flask.render_template('non_escaping_template.txt', text=text,
html=flask.Markup(text))
lines = app.test_client().get('/').data.splitlines()
assert lines == [
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!',
b'<p>Hello World!'
]
def test_escaping_without_template_filename():
app = flask.Flask(__name__)
with app.test_request_context():
assert flask.render_template_string(
'{{ foo }}', foo='<test>') == '<test>'
assert flask.render_template('mail.txt', foo='<test>') == \
'<test> Mail'
def test_macros():
app = flask.Flask(__name__)
with app.test_request_context():
macro = flask.get_template_attribute('_macro.html', 'hello')
assert macro('World') == 'Hello World!'
def test_template_filter():
app = flask.Flask(__name__)
@app.template_filter()
def my_reverse(s):
return s[::-1]
assert 'my_reverse' in app.jinja_env.filters.keys()
assert app.jinja_env.filters['my_reverse'] == my_reverse
assert app.jinja_env.filters['my_reverse']('abcd') == 'dcba'
def test_add_template_filter():
app = flask.Flask(__name__)
def my_reverse(s):
return s[::-1]
app.add_template_filter(my_reverse)
assert 'my_reverse' in app.jinja_env.filters.keys()
assert app.jinja_env.filters['my_reverse'] == my_reverse
assert app.jinja_env.filters['my_reverse']('abcd') == 'dcba'
def test_template_filter_with_name():
app = flask.Flask(__name__)
@app.template_filter('strrev')
def my_reverse(s):
return s[::-1]
assert 'strrev' in app.jinja_env.filters.keys()
assert app.jinja_env.filters['strrev'] == my_reverse
assert app.jinja_env.filters['strrev']('abcd') == 'dcba'
def test_add_template_filter_with_name():
app = flask.Flask(__name__)
def my_reverse(s):
return s[::-1]
app.add_template_filter(my_reverse, 'strrev')
assert 'strrev' in app.jinja_env.filters.keys()
assert app.jinja_env.filters['strrev'] == my_reverse
assert app.jinja_env.filters['strrev']('abcd') == 'dcba'
def test_template_filter_with_template():
app = flask.Flask(__name__)
@app.template_filter()
def super_reverse(s):
return s[::-1]
@app.route('/')
def index():
return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_add_template_filter_with_template():
app = flask.Flask(__name__)
def super_reverse(s):
return s[::-1]
app.add_template_filter(super_reverse)
@app.route('/')
def index():
return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_template_filter_with_name_and_template():
app = flask.Flask(__name__)
@app.template_filter('super_reverse')
def my_reverse(s):
return s[::-1]
@app.route('/')
def index():
return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_add_template_filter_with_name_and_template():
app = flask.Flask(__name__)
def my_reverse(s):
return s[::-1]
app.add_template_filter(my_reverse, 'super_reverse')
@app.route('/')
def index():
return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/')
assert rv.data == b'dcba'
def test_template_test():
app = flask.Flask(__name__)
@app.template_test()
def boolean(value):
return isinstance(value, bool)
assert 'boolean' in app.jinja_env.tests.keys()
assert app.jinja_env.tests['boolean'] == boolean
assert app.jinja_env.tests['boolean'](False)
def test_add_template_test():
app = flask.Flask(__name__)
def boolean(value):
return isinstance(value, bool)
app.add_template_test(boolean)
assert 'boolean' in app.jinja_env.tests.keys()
assert app.jinja_env.tests['boolean'] == boolean
assert app.jinja_env.tests['boolean'](False)
def test_template_test_with_name():
app = flask.Flask(__name__)
@app.template_test('boolean')
def is_boolean(value):
return isinstance(value, bool)
assert 'boolean' in app.jinja_env.tests.keys()
assert app.jinja_env.tests['boolean'] == is_boolean
assert app.jinja_env.tests['boolean'](False)
def test_add_template_test_with_name():
app = flask.Flask(__name__)
def is_boolean(value):
return isinstance(value, bool)
app.add_template_test(is_boolean, 'boolean')
assert 'boolean' in app.jinja_env.tests.keys()
assert app.jinja_env.tests['boolean'] == is_boolean
assert app.jinja_env.tests['boolean'](False)
def test_template_test_with_template():
app = flask.Flask(__name__)
@app.template_test()
def boolean(value):
return isinstance(value, bool)
@app.route('/')
def index():
return flask.render_template('template_test.html', value=False)
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def test_add_template_test_with_template():
app = flask.Flask(__name__)
def boolean(value):
return isinstance(value, bool)
app.add_template_test(boolean)
@app.route('/')
def index():
return flask.render_template('template_test.html', value=False)
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def test_template_test_with_name_and_template():
app = flask.Flask(__name__)
@app.template_test('boolean')
def is_boolean(value):
return isinstance(value, bool)
@app.route('/')
def index():
return flask.render_template('template_test.html', value=False)
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def test_add_template_test_with_name_and_template():
app = flask.Flask(__name__)
def is_boolean(value):
return isinstance(value, bool)
app.add_template_test(is_boolean, 'boolean')
@app.route('/')
def index():
return flask.render_template('template_test.html', value=False)
rv = app.test_client().get('/')
assert b'Success!' in rv.data
def test_add_template_global():
app = flask.Flask(__name__)
@app.template_global()
def get_stuff():
return 42
assert 'get_stuff' in app.jinja_env.globals.keys()
assert app.jinja_env.globals['get_stuff'] == get_stuff
assert app.jinja_env.globals['get_stuff'](), 42
with app.app_context():
rv = flask.render_template_string('{{ get_stuff() }}')
assert rv == '42'
def test_custom_template_loader():
class MyFlask(flask.Flask):
def create_global_jinja_loader(self):
from jinja2 import DictLoader
return DictLoader({'index.html': 'Hello Custom World!'})
app = MyFlask(__name__)
@app.route('/')
def index():
return flask.render_template('index.html')
c = app.test_client()
rv = c.get('/')
assert rv.data == b'Hello Custom World!'
def test_iterable_loader():
app = flask.Flask(__name__)
@app.context_processor
def context_processor():
return {'whiskey': 'Jameson'}
@app.route('/')
def index():
return flask.render_template(
['no_template.xml', # should skip this one
'simple_template.html', # should render this
'context_template.html'],
value=23)
rv = app.test_client().get('/')
assert rv.data == b'<h1>Jameson</h1>'
def test_templates_auto_reload():
# debug is False, config option is None
app = flask.Flask(__name__)
assert app.debug is False
assert app.config['TEMPLATES_AUTO_RELOAD'] is None
assert app.jinja_env.auto_reload is False
# debug is False, config option is False
app = flask.Flask(__name__)
app.config['TEMPLATES_AUTO_RELOAD'] = False
assert app.debug is False
assert app.jinja_env.auto_reload is False
# debug is False, config option is True
app = flask.Flask(__name__)
app.config['TEMPLATES_AUTO_RELOAD'] = True
assert app.debug is False
assert app.jinja_env.auto_reload is True
# debug is True, config option is None
app = flask.Flask(__name__)
app.config['DEBUG'] = True
assert app.config['TEMPLATES_AUTO_RELOAD'] is None
assert app.jinja_env.auto_reload is True
# debug is True, config option is False
app = flask.Flask(__name__)
app.config['DEBUG'] = True
app.config['TEMPLATES_AUTO_RELOAD'] = False
assert app.jinja_env.auto_reload is False
# debug is True, config option is True
app = flask.Flask(__name__)
app.config['DEBUG'] = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
assert app.jinja_env.auto_reload is True
def test_template_loader_debugging(test_apps):
from blueprintapp import app
called = []
class _TestHandler(logging.Handler):
def handle(x, record):
called.append(True)
text = str(record.msg)
assert '1: trying loader of application "blueprintapp"' in text
assert ('2: trying loader of blueprint "admin" '
'(blueprintapp.apps.admin)') in text
assert ('trying loader of blueprint "frontend" '
'(blueprintapp.apps.frontend)') in text
assert 'Error: the template could not be found' in text
assert ('looked up from an endpoint that belongs to '
'the blueprint "frontend"') in text
assert 'See http://flask.pocoo.org/docs/blueprints/#templates' in text
with app.test_client() as c:
try:
old_load_setting = app.config['EXPLAIN_TEMPLATE_LOADING']
old_handlers = app.logger.handlers[:]
app.logger.handlers = [_TestHandler()]
app.config['EXPLAIN_TEMPLATE_LOADING'] = True
with pytest.raises(TemplateNotFound) as excinfo:
c.get('/missing')
assert 'missing_template.html' in str(excinfo.value)
finally:
app.logger.handlers[:] = old_handlers
app.config['EXPLAIN_TEMPLATE_LOADING'] = old_load_setting
assert len(called) == 1
def test_custom_jinja_env():
class CustomEnvironment(flask.templating.Environment):
pass
class CustomFlask(flask.Flask):
jinja_environment = CustomEnvironment
app = CustomFlask(__name__)
assert isinstance(app.jinja_env, CustomEnvironment)
|
bsd-3-clause
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
2295,
14,
808,
24615,
272,
18294,
339,
5458,
9330,
339,
520,
7307,
26,
334,
67,
9,
6900,
701,
1952,
827,
32472,
19728,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
199,
646,
4613,
199,
199,
646,
7209,
199,
646,
2050,
199,
504,
10321,
18,
492,
5458,
4667,
421,
199,
318,
511,
63,
1100,
63,
6338,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
1100,
63,
6459,
272,
347,
1067,
63,
6459,
837,
267,
372,
791,
30785,
63,
585,
356,
5685,
93,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
372,
7209,
14,
3352,
63,
1160,
360,
1100,
63,
1160,
14,
1360,
297,
574,
29,
1789,
9,
272,
4336,
275,
1145,
14,
396,
63,
1258,
1252,
362,
7825,
272,
702,
4336,
14,
576,
508,
330,
7601,
80,
30,
1789,
92,
2260,
7,
199,
199,
318,
511,
63,
5043,
63,
2676,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
372,
7209,
14,
3352,
63,
1160,
63,
875,
18976,
1101,
23688,
1101,
29,
2260,
9,
272,
4336,
275,
1145,
14,
396,
63,
1258,
1252,
362,
7825,
272,
702,
4336,
14,
576,
508,
330,
7,
2260,
7,
199,
199,
318,
511,
63,
1069,
63,
2003,
63,
28228,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
1145,
14,
888,
459,
22125,
63,
2339,
418,
275,
283,
12246,
13064,
7,
272,
768,
571,
14,
1100,
63,
6459,
272,
347,
1067,
63,
6459,
837,
267,
372,
1211,
8,
1421,
29,
2260,
9,
339,
543,
1145,
14,
571,
63,
1100,
837,
267,
4336,
275,
7209,
14,
3352,
63,
1160,
63,
875,
360,
6257,
8448,
1101,
14,
22125,
63,
2339,
3586,
283,
5101,
11400,
3925,
28404,
267,
702,
4336,
508,
283,
6257,
12568,
13064,
5685,
7,
199,
199,
318,
511,
63,
6807,
63,
1100,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
1145,
14,
4731,
63,
498,
275,
283,
31688,
790,
7,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
7209,
14,
71,
14,
1421,
275,
6546,
267,
7209,
14,
1730,
459,
396,
418,
275,
283,
65,
2411,
7,
267,
372,
7209,
14,
3352,
63,
1160,
63,
875,
10505,
288,
8448,
1056,
14,
589,
14,
1421,
3586,
288,
8448,
486,
14,
1421,
3586,
288,
8448,
1101,
14,
5287,
3586,
288,
8448,
2351,
14,
396,
3586,
267,
21464,
272,
4336,
275,
1145,
14,
396,
63,
1258,
1252,
362,
2336,
31,
1421,
29,
2260,
358,
272,
702,
4336,
14,
576,
14,
1294,
342,
508,
359,
66,
7,
2260,
297,
330,
7,
1789,
297,
330,
7,
797,
297,
330,
7,
65,
2411,
418,
199,
199,
318,
511,
63,
26306,
837,
272,
1318,
275,
2650,
80,
30,
6257,
13064,
11213,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
372,
7209,
14,
3352,
63,
1160,
360,
26306,
63,
1160,
14,
1360,
297,
1318,
29,
505,
12,
3660,
3517,
29,
15720,
14,
23393,
8,
505,
430,
272,
2385,
275,
1145,
14,
396,
63,
1258,
1252,
362,
2336,
1959,
576,
14,
7644,
342,
272,
702,
2385,
508,
359,
267,
330,
21840,
4116,
27,
80,
6,
3308,
27,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
21840,
4116,
27,
80,
6,
3308,
27,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
11213,
272,
1622,
199,
199,
318,
511,
63,
889,
63,
26306,
837,
272,
1318,
275,
2650,
80,
30,
6257,
13064,
11213,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
372,
7209,
14,
3352,
63,
1160,
360,
2865,
63,
26306,
63,
1160,
14,
2424,
297,
1318,
29,
505,
12,
3660,
3517,
29,
15720,
14,
23393,
8,
505,
430,
272,
2385,
275,
1145,
14,
396,
63,
1258,
1252,
362,
2336,
1959,
576,
14,
7644,
342,
272,
702,
2385,
508,
359,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
21840,
4116,
27,
80,
6,
3308,
27,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
11213,
272,
1622,
199,
199,
318,
511,
63,
26306,
63,
7395,
63,
1160,
63,
1501,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
267,
702,
7209,
14,
3352,
63,
1160,
63,
875,
8,
288,
11400,
3925,
23688,
3925,
15829,
396,
5971,
508,
7673,
4116,
27,
396,
6,
3308,
8942,
267,
702,
7209,
14,
3352,
63,
1160,
360,
1198,
14,
2424,
297,
3925,
15829,
396,
5971,
508,
971,
288,
2650,
396,
30,
18027,
7,
199,
199,
318,
511,
63,
16358,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
267,
9559,
275,
7209,
14,
362,
63,
1160,
63,
3215,
6412,
11300,
14,
1360,
297,
283,
5006,
358,
267,
702,
9559,
360,
15943,
358,
508,
283,
6257,
13064,
11213,
199,
199,
318,
511,
63,
1160,
63,
1541,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
1160,
63,
1541,
342,
272,
347,
3002,
63,
4471,
8,
83,
304,
267,
372,
308,
14172,
17,
61,
272,
702,
283,
1662,
63,
4471,
7,
315,
1145,
14,
12264,
63,
1813,
14,
4273,
14,
1612,
342,
272,
702,
1145,
14,
12264,
63,
1813,
14,
4273,
459,
1662,
63,
4471,
418,
508,
3002,
63,
4471,
272,
702,
1145,
14,
12264,
63,
1813,
14,
4273,
459,
1662,
63,
4471,
418,
360,
13591,
358,
508,
283,
3833,
2470,
7,
199,
199,
318,
511,
63,
525,
63,
1160,
63,
1541,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
347,
3002,
63,
4471,
8,
83,
304,
267,
372
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
2295,
14,
808,
24615,
272,
18294,
339,
5458,
9330,
339,
520,
7307,
26,
334,
67,
9,
6900,
701,
1952,
827,
32472,
19728,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
1655,
2436,
14,
199,
624,
199,
199,
646,
4613,
199,
199,
646,
7209,
199,
646,
2050,
199,
504,
10321,
18,
492,
5458,
4667,
421,
199,
318,
511,
63,
1100,
63,
6338,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
1100,
63,
6459,
272,
347,
1067,
63,
6459,
837,
267,
372,
791,
30785,
63,
585,
356,
5685,
93,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
372,
7209,
14,
3352,
63,
1160,
360,
1100,
63,
1160,
14,
1360,
297,
574,
29,
1789,
9,
272,
4336,
275,
1145,
14,
396,
63,
1258,
1252,
362,
7825,
272,
702,
4336,
14,
576,
508,
330,
7601,
80,
30,
1789,
92,
2260,
7,
199,
199,
318,
511,
63,
5043,
63,
2676,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
372,
7209,
14,
3352,
63,
1160,
63,
875,
18976,
1101,
23688,
1101,
29,
2260,
9,
272,
4336,
275,
1145,
14,
396,
63,
1258,
1252,
362,
7825,
272,
702,
4336,
14,
576,
508,
330,
7,
2260,
7,
199,
199,
318,
511,
63,
1069,
63,
2003,
63,
28228,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
1145,
14,
888,
459,
22125,
63,
2339,
418,
275,
283,
12246,
13064,
7,
272,
768,
571,
14,
1100,
63,
6459,
272,
347,
1067,
63,
6459,
837,
267,
372,
1211,
8,
1421,
29,
2260,
9,
339,
543,
1145,
14,
571,
63,
1100,
837,
267,
4336,
275,
7209,
14,
3352,
63,
1160,
63,
875,
360,
6257,
8448,
1101,
14,
22125,
63,
2339,
3586,
283,
5101,
11400,
3925,
28404,
267,
702,
4336,
508,
283,
6257,
12568,
13064,
5685,
7,
199,
199,
318,
511,
63,
6807,
63,
1100,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
1145,
14,
4731,
63,
498,
275,
283,
31688,
790,
7,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
7209,
14,
71,
14,
1421,
275,
6546,
267,
7209,
14,
1730,
459,
396,
418,
275,
283,
65,
2411,
7,
267,
372,
7209,
14,
3352,
63,
1160,
63,
875,
10505,
288,
8448,
1056,
14,
589,
14,
1421,
3586,
288,
8448,
486,
14,
1421,
3586,
288,
8448,
1101,
14,
5287,
3586,
288,
8448,
2351,
14,
396,
3586,
267,
21464,
272,
4336,
275,
1145,
14,
396,
63,
1258,
1252,
362,
2336,
31,
1421,
29,
2260,
358,
272,
702,
4336,
14,
576,
14,
1294,
342,
508,
359,
66,
7,
2260,
297,
330,
7,
1789,
297,
330,
7,
797,
297,
330,
7,
65,
2411,
418,
199,
199,
318,
511,
63,
26306,
837,
272,
1318,
275,
2650,
80,
30,
6257,
13064,
11213,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
372,
7209,
14,
3352,
63,
1160,
360,
26306,
63,
1160,
14,
1360,
297,
1318,
29,
505,
12,
3660,
3517,
29,
15720,
14,
23393,
8,
505,
430,
272,
2385,
275,
1145,
14,
396,
63,
1258,
1252,
362,
2336,
1959,
576,
14,
7644,
342,
272,
702,
2385,
508,
359,
267,
330,
21840,
4116,
27,
80,
6,
3308,
27,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
21840,
4116,
27,
80,
6,
3308,
27,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
11213,
272,
1622,
199,
199,
318,
511,
63,
889,
63,
26306,
837,
272,
1318,
275,
2650,
80,
30,
6257,
13064,
11213,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
4449,
7825,
272,
347,
1478,
837,
267,
372,
7209,
14,
3352,
63,
1160,
360,
2865,
63,
26306,
63,
1160,
14,
2424,
297,
1318,
29,
505,
12,
3660,
3517,
29,
15720,
14,
23393,
8,
505,
430,
272,
2385,
275,
1145,
14,
396,
63,
1258,
1252,
362,
2336,
1959,
576,
14,
7644,
342,
272,
702,
2385,
508,
359,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
21840,
4116,
27,
80,
6,
3308,
27,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
12389,
267,
330,
7601,
80,
30,
6257,
13064,
11213,
272,
1622,
199,
199,
318,
511,
63,
26306,
63,
7395,
63,
1160,
63,
1501,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
267,
702,
7209,
14,
3352,
63,
1160,
63,
875,
8,
288,
11400,
3925,
23688,
3925,
15829,
396,
5971,
508,
7673,
4116,
27,
396,
6,
3308,
8942,
267,
702,
7209,
14,
3352,
63,
1160,
360,
1198,
14,
2424,
297,
3925,
15829,
396,
5971,
508,
971,
288,
2650,
396,
30,
18027,
7,
199,
199,
318,
511,
63,
16358,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
543,
1145,
14,
396,
63,
1069,
63,
1100,
837,
267,
9559,
275,
7209,
14,
362,
63,
1160,
63,
3215,
6412,
11300,
14,
1360,
297,
283,
5006,
358,
267,
702,
9559,
360,
15943,
358,
508,
283,
6257,
13064,
11213,
199,
199,
318,
511,
63,
1160,
63,
1541,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
768,
571,
14,
1160,
63,
1541,
342,
272,
347,
3002,
63,
4471,
8,
83,
304,
267,
372,
308,
14172,
17,
61,
272,
702,
283,
1662,
63,
4471,
7,
315,
1145,
14,
12264,
63,
1813,
14,
4273,
14,
1612,
342,
272,
702,
1145,
14,
12264,
63,
1813,
14,
4273,
459,
1662,
63,
4471,
418,
508,
3002,
63,
4471,
272,
702,
1145,
14,
12264,
63,
1813,
14,
4273,
459,
1662,
63,
4471,
418,
360,
13591,
358,
508,
283,
3833,
2470,
7,
199,
199,
318,
511,
63,
525,
63,
1160,
63,
1541,
837,
272,
1145,
275,
7209,
14,
14182,
3460,
354,
3368,
272,
347,
3002,
63,
4471,
8,
83,
304,
267,
372,
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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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
MjAbuz/watchdog
|
vendor/pyExcelerator-0.6.3a/build/lib/pyExcelerator/Cell.py
|
15
|
5886
|
#!/usr/bin/env python
# -*- coding: windows-1251 -*-
# Copyright (C) 2005 Roman V. Kiseliov
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. All advertising materials mentioning features or use of this
# software must display the following acknowledgment:
# "This product includes software developed by
# Roman V. Kiseliov <roman@kiseliov.ru>."
#
# 4. Redistributions of any form whatsoever must retain the following
# acknowledgment:
# "This product includes software developed by
# Roman V. Kiseliov <roman@kiseliov.ru>."
#
# THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY
# EXPRESSED 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 Roman V. Kiseliov 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.
__rev_id__ = """$Id: Cell.py,v 1.3 2005/08/11 08:53:48 rvk Exp $"""
import struct
import BIFFRecords
class StrCell(object):
__slots__ = ["__init__", "get_biff_data",
"__parent", "__idx", "__xf_idx", "__sst_idx"]
def __init__(self, parent, idx, xf_idx, sst_idx):
self.__parent = parent
self.__idx = idx
self.__xf_idx = xf_idx
self.__sst_idx = sst_idx
def get_biff_data(self):
return BIFFRecords.LabelSSTRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, self.__sst_idx).get()
class BlankCell(object):
__slots__ = ["__init__", "get_biff_data",
"__parent", "__idx", "__xf_idx"]
def __init__(self, parent, idx, xf_idx):
self.__parent = parent
self.__idx = idx
self.__xf_idx = xf_idx
def get_biff_data(self):
return BIFFRecords.BlankRecord(self.__parent.get_index(), self.__idx, self.__xf_idx).get()
class MulBlankCell(object):
__slots__ = ["__init__", "get_biff_data",
"__parent", "__col1", "__col2", "__xf_idx"]
def __init__(self, parent, col1, col2, xf_idx):
self.__parent = parent
self.__col1 = col1
self.__col2 = col2
self.__xf_idx = xf_idx
def get_biff_data(self):
return BIFFRecords.MulBlankRecord(self.__parent.get_index(), self.__col1, self.__col2, self.__xf_idx).get()
class NumberCell(object):
__slots__ = ["__init__", "get_biff_data",
"__parent", "__idx", "__xf_idx", "__number"]
def __init__(self, parent, idx, xf_idx, number):
self.__parent = parent
self.__idx = idx
self.__xf_idx = xf_idx
self.__number = float(number)
def get_biff_data(self):
rk_encoded = 0
packed = struct.pack('<d', self.__number)
#print self.__number
w0, w1, w2, w3 = struct.unpack('<4H', packed)
if w0 == 0 and w1 == 0 and w2 & 0xFFFC == w2:
# 34 lsb are 0
#print "float RK"
rk_encoded = (w3 << 16) | w2
return BIFFRecords.RKRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
if abs(self.__number) < 0x40000000 and int(self.__number) == self.__number:
#print "30-bit integer RK"
rk_encoded = 2 | (int(self.__number) << 2)
return BIFFRecords.RKRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
temp = self.__number*100
packed100 = struct.pack('<d', temp)
w0, w1, w2, w3 = struct.unpack('<4H', packed100)
if w0 == 0 and w1 == 0 and w2 & 0xFFFC == w2:
# 34 lsb are 0
#print "float RK*100"
rk_encoded = 1 | (w3 << 16) | w2
return BIFFRecords.RKRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
if abs(temp) < 0x40000000 and int(temp) == temp:
#print "30-bit integer RK*100"
rk_encoded = 3 | (int(temp) << 2)
return BIFFRecords.RKRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, rk_encoded).get()
#print "Number"
#print
return BIFFRecords.NumberRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, self.__number).get()
class MulNumberCell(object):
__slots__ = ["__init__", "get_biff_data"]
def __init__(self, parent, idx, xf_idx, sst_idx):
self.__parent = parent
self.__idx = idx
self.__xf_idx = xf_idx
self.__sst_idx = sst_idx
def get_biff_data(self):
raise Exception
class FormulaCell(object):
__slots__ = ["__init__", "get_biff_data",
"__parent", "__idx", "__xf_idx", "__frmla"]
def __init__(self, parent, idx, xf_idx, frmla):
self.__parent = parent
self.__idx = idx
self.__xf_idx = xf_idx
self.__frmla = frmla
def get_biff_data(self):
return BIFFRecords.FormulaRecord(self.__parent.get_index(), self.__idx, self.__xf_idx, self.__frmla.rpn()).get()
|
agpl-3.0
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
10061,
13,
21381,
1882,
199,
199,
3,
221,
1898,
334,
35,
9,
11811,
820,
21604,
812,
14,
1804,
572,
317,
8822,
199,
3,
221,
2900,
4481,
4644,
14,
199,
3,
221,
199,
3,
221,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
221,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
199,
3,
221,
787,
7647,
26,
199,
3,
221,
199,
3,
221,
413,
14,
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,
221,
199,
3,
221,
499,
14,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
258,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
199,
3,
258,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
258,
4084,
14,
199,
3,
221,
199,
3,
221,
650,
14,
2900,
19613,
1044,
8418,
20811,
316,
4534,
503,
675,
402,
642,
199,
3,
258,
2032,
1471,
2929,
314,
2569,
19807,
28609,
4740,
26,
199,
3,
258,
298,
2765,
3336,
6952,
2032,
477,
27813,
701,
199,
3,
420,
820,
21604,
812,
14,
1804,
572,
317,
8822,
665,
20971,
32,
75,
572,
317,
8822,
14,
6558,
30,
2122,
199,
3,
221,
199,
3,
221,
841,
14,
6823,
402,
1263,
1824,
4052,
1152,
5907,
1471,
8074,
314,
2569,
199,
3,
258,
19807,
28609,
4740,
26,
199,
3,
258,
298,
2765,
3336,
6952,
2032,
477,
27813,
701,
199,
3,
420,
820,
21604,
812,
14,
1804,
572,
317,
8822,
665,
20971,
32,
75,
572,
317,
8822,
14,
6558,
30,
2122,
199,
3,
221,
199,
3,
221,
5749,
4141,
2281,
7049,
6515,
820,
21604,
812,
14,
1804,
572,
317,
8822,
1124,
1179,
2281,
891,
2401,
1821,
199,
3,
221,
3651,
14956,
10934,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
221,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
199,
3,
221,
3104,
9315,
9706,
14,
221,
1621,
4825,
6461,
7000,
820,
21604,
812,
14,
1804,
572,
317,
8822,
1549,
199,
3,
221,
473,
9730,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
221,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
199,
3,
221,
2845,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
199,
3,
221,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
199,
3,
221,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
199,
3,
221,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
199,
3,
221,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
199,
3,
221,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
363,
4964,
63,
344,
363,
275,
408,
4,
1304,
26,
24834,
14,
647,
12,
86,
413,
14,
19,
11811,
15,
2036,
15,
845,
19363,
26,
2481,
26,
2006,
4336,
75,
7910,
2672,
624,
421,
199,
646,
2702,
199,
646,
699,
24150,
14941,
421,
199,
533,
8303,
8108,
8,
785,
304,
272,
636,
7257,
363,
275,
2097,
363,
826,
13915,
298,
362,
63,
4492,
556,
63,
576,
401,
355,
4396,
1708,
401,
4396,
2996,
401,
4396,
1949,
63,
2996,
401,
4396,
83,
270,
63,
2996,
937,
339,
347,
636,
826,
721,
277,
12,
1676,
12,
4280,
12,
27366,
63,
2996,
12,
308,
270,
63,
2996,
304,
267,
291,
855,
1708,
275,
1676,
267,
291,
855,
2996,
275,
4280,
267,
291,
855,
1949,
63,
2996,
275,
27366,
63,
2996,
267,
291,
855,
83,
270,
63,
2996,
275,
308,
270,
63,
2996,
339,
347,
664,
63,
4492,
556,
63,
576,
8,
277,
304,
267,
372,
699,
24150,
14941,
14,
4314,
51,
840,
5433,
8,
277,
855,
1708,
14,
362,
63,
1080,
1062,
291,
855,
2996,
12,
291,
855,
1949,
63,
2996,
12,
291,
855,
83,
270,
63,
2996,
680,
362,
342,
421,
199,
533,
699,
1983,
8108,
8,
785,
304,
272,
636,
7257,
363,
275,
2097,
363,
826,
13915,
298,
362,
63,
4492,
556,
63,
576,
401,
355,
4396,
1708,
401,
4396,
2996,
401,
4396,
1949,
63,
2996,
937,
339,
347,
636,
826,
721,
277,
12,
1676,
12,
4280,
12,
27366,
63,
2996,
304,
267,
291,
855,
1708,
275,
1676,
267,
291,
855,
2996,
275,
4280,
267,
291,
855,
1949,
63,
2996,
275,
27366,
63,
2996,
339,
347,
664,
63,
4492,
556,
63,
576,
8,
277,
304,
267,
372,
699,
24150,
14941,
14,
28083,
5433,
8,
277,
855,
1708,
14,
362,
63,
1080,
1062,
291,
855,
2996,
12,
291,
855,
1949,
63,
2996,
680,
362,
342,
421,
199,
533,
22578,
28083,
8108,
8,
785,
304,
272,
636,
7257,
363,
275,
2097,
363,
826,
13915,
298,
362,
63,
4492,
556,
63,
576,
401,
355,
4396,
1708,
401,
4396,
761,
17,
401,
4396,
761,
18,
401,
4396,
1949,
63,
2996,
937,
339,
347,
636,
826,
721,
277,
12,
1676,
12,
1048,
17,
12,
1048,
18,
12,
27366,
63,
2996,
304,
267,
291,
855,
1708,
275,
1676,
267,
291,
855,
761,
17,
275,
1048,
17,
267,
291,
855,
761,
18,
275,
1048,
18,
267,
291,
855,
1949,
63,
2996,
275,
27366,
63,
2996,
339,
347,
664,
63,
4492,
556,
63,
576,
8,
277,
304,
267,
372,
699,
24150,
14941,
14,
16867,
28083,
5433,
8,
277,
855,
1708,
14,
362,
63,
1080,
1062,
291,
855,
761,
17,
12,
291,
855,
761,
18,
12,
291,
855,
1949,
63,
2996,
680,
362,
342,
421,
199,
533,
4860,
8108,
8,
785,
304,
272,
636,
7257,
363,
275,
2097,
363,
826,
13915,
298,
362,
63,
4492,
556,
63,
576,
401,
355,
4396,
1708,
401,
4396,
2996,
401,
4396,
1949,
63,
2996,
401,
4396,
1955,
937,
2378,
347,
636,
826,
721,
277,
12,
1676,
12,
4280,
12,
27366,
63,
2996,
12,
1329,
304,
267,
291,
855,
1708,
275,
1676,
267,
291,
855,
2996,
275,
4280,
267,
291,
855,
1949,
63,
2996,
275,
27366,
63,
2996,
267,
291,
855,
1955,
275,
2069,
8,
1955,
9,
2378,
347,
664,
63,
4492,
556,
63,
576,
8,
277,
304,
267,
519,
75,
63,
8167,
275
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
3,
1882,
2803,
26,
10061,
13,
21381,
1882,
199,
199,
3,
221,
1898,
334,
35,
9,
11811,
820,
21604,
812,
14,
1804,
572,
317,
8822,
199,
3,
221,
2900,
4481,
4644,
14,
199,
3,
221,
199,
3,
221,
10114,
436,
675,
315,
1350,
436,
3366,
4513,
12,
543,
503,
1928,
199,
3,
221,
7100,
12,
787,
8211,
2741,
626,
314,
2569,
3704,
199,
3,
221,
787,
7647,
26,
199,
3,
221,
199,
3,
221,
413,
14,
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,
221,
199,
3,
221,
499,
14,
6823,
315,
3366,
1824,
1471,
9172,
314,
3432,
4248,
199,
3,
258,
4245,
12,
642,
769,
402,
3704,
436,
314,
2569,
6450,
315,
199,
3,
258,
314,
3794,
436,
15,
269,
1163,
8418,
2741,
543,
314,
199,
3,
258,
4084,
14,
199,
3,
221,
199,
3,
221,
650,
14,
2900,
19613,
1044,
8418,
20811,
316,
4534,
503,
675,
402,
642,
199,
3,
258,
2032,
1471,
2929,
314,
2569,
19807,
28609,
4740,
26,
199,
3,
258,
298,
2765,
3336,
6952,
2032,
477,
27813,
701,
199,
3,
420,
820,
21604,
812,
14,
1804,
572,
317,
8822,
665,
20971,
32,
75,
572,
317,
8822,
14,
6558,
30,
2122,
199,
3,
221,
199,
3,
221,
841,
14,
6823,
402,
1263,
1824,
4052,
1152,
5907,
1471,
8074,
314,
2569,
199,
3,
258,
19807,
28609,
4740,
26,
199,
3,
258,
298,
2765,
3336,
6952,
2032,
477,
27813,
701,
199,
3,
420,
820,
21604,
812,
14,
1804,
572,
317,
8822,
665,
20971,
32,
75,
572,
317,
8822,
14,
6558,
30,
2122,
199,
3,
221,
199,
3,
221,
5749,
4141,
2281,
7049,
6515,
820,
21604,
812,
14,
1804,
572,
317,
8822,
1124,
1179,
2281,
891,
2401,
1821,
199,
3,
221,
3651,
14956,
10934,
1549,
5292,
2990,
12,
6931,
12,
5400,
2845,
5471,
2296,
12,
2334,
199,
3,
221,
5292,
2990,
1634,
3169,
2401,
3092,
2381,
437,
3115,
199,
3,
221,
3104,
9315,
9706,
14,
221,
1621,
4825,
6461,
7000,
820,
21604,
812,
14,
1804,
572,
317,
8822,
1549,
199,
3,
221,
473,
9730,
6483,
6262,
7024,
2381,
1821,
8703,
12,
9168,
12,
9716,
12,
199,
3,
221,
8820,
12,
9836,
12,
1549,
9110,
6736,
334,
6446,
12,
5400,
199,
3,
221,
2845,
5471,
2296,
12,
9838,
1634,
9103,
9764,
1549,
9714,
27,
199,
3,
221,
9102,
1634,
4815,
12,
7126,
12,
1549,
9206,
27,
1549,
9748,
9831,
9,
199,
3,
221,
9802,
9817,
2401,
5258,
1821,
9815,
1634,
5603,
12,
7061,
1621,
7066,
12,
199,
3,
221,
9644,
5603,
12,
1549,
7056,
334,
6446,
9254,
1549,
7334,
9,
199,
3,
221,
7043,
1621,
1821,
9683,
5738,
1634,
2334,
4815,
1634,
5749,
4141,
12,
9704,
8036,
9691,
199,
3,
221,
1634,
2334,
9726,
1634,
9712,
9784,
14,
421,
199,
363,
4964,
63,
344,
363,
275,
408,
4,
1304,
26,
24834,
14,
647,
12,
86,
413,
14,
19,
11811,
15,
2036,
15,
845,
19363,
26,
2481,
26,
2006,
4336,
75,
7910,
2672,
624,
421,
199,
646,
2702,
199,
646,
699,
24150,
14941,
421,
199,
533,
8303,
8108,
8,
785,
304,
272,
636,
7257,
363,
275,
2097,
363,
826,
13915,
298,
362,
63,
4492,
556,
63,
576,
401,
355,
4396,
1708,
401,
4396,
2996,
401,
4396,
1949,
63,
2996,
401,
4396,
83,
270,
63,
2996,
937,
339,
347,
636,
826,
721,
277,
12,
1676,
12,
4280,
12,
27366,
63,
2996,
12,
308,
270,
63,
2996,
304,
267,
291,
855,
1708,
275,
1676,
267,
291,
855,
2996,
275,
4280,
267,
291,
855,
1949,
63,
2996,
275,
27366,
63,
2996,
267,
291,
855,
83,
270,
63,
2996,
275,
308,
270,
63,
2996,
339,
347,
664,
63,
4492,
556,
63,
576,
8,
277,
304,
267,
372,
699,
24150,
14941,
14,
4314,
51,
840,
5433,
8,
277,
855,
1708,
14,
362,
63,
1080,
1062,
291,
855,
2996,
12,
291,
855,
1949,
63,
2996,
12,
291,
855,
83,
270,
63,
2996,
680,
362,
342,
421,
199,
533,
699,
1983,
8108,
8,
785,
304,
272,
636,
7257,
363,
275,
2097,
363,
826,
13915,
298,
362,
63,
4492,
556,
63,
576,
401,
355,
4396,
1708,
401,
4396,
2996,
401,
4396,
1949,
63,
2996,
937,
339,
347,
636,
826,
721,
277,
12,
1676,
12,
4280,
12,
27366,
63,
2996,
304,
267,
291,
855,
1708,
275,
1676,
267,
291,
855,
2996,
275,
4280,
267,
291,
855,
1949,
63,
2996,
275,
27366,
63,
2996,
339,
347,
664,
63,
4492,
556,
63,
576,
8,
277,
304,
267,
372,
699,
24150,
14941,
14,
28083,
5433,
8,
277,
855,
1708,
14,
362,
63,
1080,
1062,
291,
855,
2996,
12,
291,
855,
1949,
63,
2996,
680,
362,
342,
421,
199,
533,
22578,
28083,
8108,
8,
785,
304,
272,
636,
7257,
363,
275,
2097,
363,
826,
13915,
298,
362,
63,
4492,
556,
63,
576,
401,
355,
4396,
1708,
401,
4396,
761,
17,
401,
4396,
761,
18,
401,
4396,
1949,
63,
2996,
937,
339,
347,
636,
826,
721,
277,
12,
1676,
12,
1048,
17,
12,
1048,
18,
12,
27366,
63,
2996,
304,
267,
291,
855,
1708,
275,
1676,
267,
291,
855,
761,
17,
275,
1048,
17,
267,
291,
855,
761,
18,
275,
1048,
18,
267,
291,
855,
1949,
63,
2996,
275,
27366,
63,
2996,
339,
347,
664,
63,
4492,
556,
63,
576,
8,
277,
304,
267,
372,
699,
24150,
14941,
14,
16867,
28083,
5433,
8,
277,
855,
1708,
14,
362,
63,
1080,
1062,
291,
855,
761,
17,
12,
291,
855,
761,
18,
12,
291,
855,
1949,
63,
2996,
680,
362,
342,
421,
199,
533,
4860,
8108,
8,
785,
304,
272,
636,
7257,
363,
275,
2097,
363,
826,
13915,
298,
362,
63,
4492,
556,
63,
576,
401,
355,
4396,
1708,
401,
4396,
2996,
401,
4396,
1949,
63,
2996,
401,
4396,
1955,
937,
2378,
347,
636,
826,
721,
277,
12,
1676,
12,
4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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
] |
NiklasMM/coala
|
coalib/misc/CachingUtilities.py
|
21
|
7156
|
import hashlib
import os
import pickle
from coalib.misc import Constants
def get_data_path(log_printer, identifier):
"""
Get the full path of ``identifier`` present in the user's data directory.
:param log_printer: A LogPrinter object to use for logging.
:param identifier: The file whose path needs to be expanded.
:return: Full path of the file, assuming it's present in the
user's config directory.
Returns ``None`` if there is a ``PermissionError``
in creating the directory.
"""
try:
os.makedirs(Constants.USER_DATA_DIR, exist_ok=True)
return os.path.join(Constants.USER_DATA_DIR, hash_id(identifier))
except PermissionError:
log_printer.err("Unable to create user data directory '{}'. Continuing"
' without caching.'.format(Constants.USER_DATA_DIR))
return None
def delete_files(log_printer, identifiers):
"""
Delete the given identifiers from the user's coala data directory.
:param log_printer: A LogPrinter object to use for logging.
:param identifiers: The list of files to be deleted.
:return: True if all the given files were successfully deleted.
False otherwise.
"""
error_files = []
result = True
for identifier in identifiers:
try:
file_path = get_data_path(log_printer, identifier)
if os.path.isfile(file_path):
os.remove(file_path)
else:
result = False
except (OSError, TypeError) as e:
error_files.append(hash_id(identifier))
if len(error_files) > 0:
error_files = ', '.join(error_files)
log_printer.warn('There was a problem deleting the following '
'files: {}. Please delete them manually from '
"'{}'.".format(error_files, Constants.USER_DATA_DIR))
result = False
return result
def pickle_load(log_printer, identifier, fallback=None):
"""
Get the data stored in ``filename`` present in the user
config directory. Example usage:
>>> from pyprint.NullPrinter import NullPrinter
>>> from coalib.output.printers.LogPrinter import LogPrinter
>>> log_printer = LogPrinter(NullPrinter())
>>> test_data = {"answer": 42}
>>> pickle_dump(log_printer, "test_project", test_data)
True
>>> pickle_load(log_printer, "test_project")
{'answer': 42}
>>> pickle_load(log_printer, "nonexistent_project")
>>> pickle_load(log_printer, "nonexistent_project", fallback=42)
42
:param log_printer: A LogPrinter object to use for logging.
:param identifier: The name of the file present in the user config
directory.
:param fallback: Return value to fallback to in case the file doesn't
exist.
:return: Data that is present in the file, if the file exists.
Otherwise the ``default`` value is returned.
"""
file_path = get_data_path(log_printer, identifier)
if file_path is None or not os.path.isfile(file_path):
return fallback
with open(file_path, 'rb') as f:
try:
return pickle.load(f)
except (pickle.UnpicklingError, EOFError) as e:
log_printer.warn('The given file is corrupted and will be '
'removed.')
delete_files(log_printer, [identifier])
return fallback
def pickle_dump(log_printer, identifier, data):
"""
Write ``data`` into the file ``filename`` present in the user
config directory.
:param log_printer: A LogPrinter object to use for logging.
:param identifier: The name of the file present in the user config
directory.
:param data: Data to be serialized and written to the file using
pickle.
:return: True if the write was successful.
False if there was a permission error in writing.
"""
file_path = get_data_path(log_printer, identifier)
if file_path is None:
# Exit silently since the error has been logged in ``get_data_path``
return False
with open(file_path, 'wb') as f:
pickle.dump(data, f)
return True
def hash_id(text):
"""
Hashes the given text.
:param text: String to to be hashed
:return: A MD5 hash of the given string
"""
return hashlib.md5(text.encode('utf-8')).hexdigest()
def get_settings_hash(sections,
targets=[],
ignore_settings: list=['disable_caching']):
"""
Compute and return a unique hash for the settings.
:param sections: A dict containing the settings for each section.
:param targets: The list of sections that are enabled.
:param ignore_settings: Setting keys to remove from sections before
hashing.
:return: A MD5 hash that is unique to the settings used.
"""
settings = []
for section in sections:
if section in targets or targets == []:
section_copy = sections[section].copy()
for setting in ignore_settings:
try:
section_copy.__getitem__(setting, ignore_defaults=True)
section_copy.delete_setting(setting)
except IndexError:
continue
settings.append(str(section_copy))
return hash_id(str(settings))
def settings_changed(log_printer, settings_hash):
"""
Determine if the settings have changed since the last run with caching.
:param log_printer: A LogPrinter object to use for logging.
:param settings_hash: A MD5 hash that is unique to the settings used.
:return: Return True if the settings hash has changed
Return False otherwise.
"""
project_hash = hash_id(os.getcwd())
settings_hash_db = pickle_load(log_printer, 'settings_hash_db', {})
if project_hash not in settings_hash_db:
# This is the first time coala is run on this project, so the cache
# will be flushed automatically.
return False
result = settings_hash_db[project_hash] != settings_hash
if result:
del settings_hash_db[project_hash]
log_printer.debug('Since the configuration settings have '
'changed since the last run, the '
'cache will be flushed and rebuilt.')
return result
def update_settings_db(log_printer, settings_hash):
"""
Update the config file last modification date.
:param log_printer: A LogPrinter object to use for logging.
:param settings_hash: A MD5 hash that is unique to the settings used.
"""
project_hash = hash_id(os.getcwd())
settings_hash_db = pickle_load(log_printer, 'settings_hash_db', {})
settings_hash_db[project_hash] = settings_hash
pickle_dump(log_printer, 'settings_hash_db', settings_hash_db)
|
agpl-3.0
|
[
646,
8337,
199,
646,
747,
199,
646,
5927,
199,
199,
504,
512,
25530,
14,
9923,
492,
22296,
421,
199,
318,
664,
63,
576,
63,
515,
8,
793,
63,
11835,
12,
5148,
304,
272,
408,
272,
2372,
314,
2615,
931,
402,
1124,
5364,
1040,
3451,
315,
314,
922,
1159,
666,
2082,
14,
339,
520,
635,
943,
63,
11835,
26,
437,
5297,
14131,
909,
370,
675,
367,
2050,
14,
272,
520,
635,
5148,
26,
221,
710,
570,
7447,
931,
4839,
370,
506,
11507,
14,
272,
520,
1107,
26,
3322,
16579,
931,
402,
314,
570,
12,
18002,
652,
1159,
3451,
315,
314,
717,
922,
1159,
1101,
2082,
14,
717,
1803,
1124,
403,
1040,
340,
2337,
365,
282,
1124,
7980,
547,
1040,
717,
315,
6425,
314,
2082,
14,
272,
408,
272,
862,
26,
267,
747,
14,
8347,
8,
22185,
14,
3791,
63,
3998,
63,
3022,
12,
2187,
63,
745,
29,
549,
9,
267,
372,
747,
14,
515,
14,
904,
8,
22185,
14,
3791,
63,
3998,
63,
3022,
12,
2631,
63,
344,
8,
5364,
430,
272,
871,
8779,
547,
26,
267,
943,
63,
11835,
14,
1508,
480,
6005,
370,
1218,
922,
666,
2082,
9005,
1370,
1448,
1346,
23221,
2,
717,
283,
1928,
13627,
17374,
908,
8,
22185,
14,
3791,
63,
3998,
63,
3022,
430,
339,
372,
488,
421,
199,
318,
3145,
63,
1725,
8,
793,
63,
11835,
12,
14154,
304,
272,
408,
272,
8496,
314,
1627,
14154,
687,
314,
922,
1159,
512,
14774,
666,
2082,
14,
339,
520,
635,
943,
63,
11835,
26,
437,
5297,
14131,
909,
370,
675,
367,
2050,
14,
272,
520,
635,
14154,
26,
710,
769,
402,
1584,
370,
506,
5463,
14,
272,
520,
1107,
26,
3322,
715,
340,
1006,
314,
1627,
1584,
4898,
8792,
5463,
14,
717,
756,
4257,
14,
272,
408,
272,
1125,
63,
1725,
275,
942,
272,
754,
275,
715,
272,
367,
5148,
315,
14154,
26,
267,
862,
26,
288,
570,
63,
515,
275,
664,
63,
576,
63,
515,
8,
793,
63,
11835,
12,
5148,
9,
288,
340,
747,
14,
515,
14,
6292,
8,
493,
63,
515,
304,
355,
747,
14,
2168,
8,
493,
63,
515,
9,
288,
587,
26,
355,
754,
275,
756,
267,
871,
334,
16719,
12,
3146,
9,
465,
325,
26,
288,
1125,
63,
1725,
14,
740,
8,
2227,
63,
344,
8,
5364,
430,
339,
340,
822,
8,
705,
63,
1725,
9,
690,
378,
26,
267,
1125,
63,
1725,
275,
1656,
1987,
904,
8,
705,
63,
1725,
9,
267,
943,
63,
11835,
14,
4050,
360,
10924,
1990,
282,
5160,
13794,
314,
2569,
283,
586,
283,
1725,
26,
30332,
7754,
3145,
3062,
10250,
687,
283,
586,
3546,
11123,
1674,
908,
8,
705,
63,
1725,
12,
22296,
14,
3791,
63,
3998,
63,
3022,
430,
267,
754,
275,
756,
339,
372,
754,
421,
199,
318,
5927,
63,
912,
8,
793,
63,
11835,
12,
5148,
12,
9567,
29,
403,
304,
272,
408,
272,
2372,
314,
666,
5489,
315,
1124,
1501,
1040,
3451,
315,
314,
922,
272,
1101,
2082,
14,
5679,
4503,
26,
339,
1306,
687,
1134,
1361,
14,
8849,
14131,
492,
12119,
14131,
272,
1306,
687,
512,
25530,
14,
1199,
14,
24858,
14,
2445,
14131,
492,
5297,
14131,
272,
1306,
943,
63,
11835,
275,
5297,
14131,
8,
8849,
14131,
1012,
272,
1306,
511,
63,
576,
275,
2420,
5934,
582,
5685,
93,
272,
1306,
5927,
63,
2724,
8,
793,
63,
11835,
12,
298,
396,
63,
1715,
401,
511,
63,
576,
9,
272,
715,
272,
1306,
5927,
63,
912,
8,
793,
63,
11835,
12,
298,
396,
63,
1715,
531,
272,
791,
5934,
356,
5685,
93,
272,
1306,
5927,
63,
912,
8,
793,
63,
11835,
12,
298,
21573,
63,
1715,
531,
272,
1306,
5927,
63,
912,
8,
793,
63,
11835,
12,
298,
21573,
63,
1715,
401,
9567,
29,
2260,
9,
272,
5685,
339,
520,
635,
943,
63,
11835,
26,
437,
5297,
14131,
909,
370,
675,
367,
2050,
14,
272,
520,
635,
5148,
26,
221,
710,
536,
402,
314,
570,
3451,
315,
314,
922,
1101,
717,
2082,
14,
272,
520,
635,
9567,
26,
259,
1432,
574,
370,
9567,
370,
315,
1930,
314,
570,
3181,
1133,
717,
2187,
14,
272,
520,
1107,
26,
3322,
3918,
626,
365,
3451,
315,
314,
570,
12,
340,
314,
570,
3495,
14,
717,
6630,
314,
1124,
885,
1040,
574,
365,
2138,
14,
272,
408,
272,
570,
63,
515,
275,
664,
63,
576,
63,
515,
8,
793,
63,
11835,
12,
5148,
9,
272,
340,
570,
63,
515,
365,
488,
503,
440,
747,
14,
515,
14,
6292,
8,
493,
63,
515,
304,
267,
372,
9567,
272,
543,
1551,
8,
493,
63,
515,
12,
283,
4848,
358,
465,
289,
26,
267,
862,
26,
288,
372,
5927,
14,
912,
8,
70,
9,
267,
871,
334,
8092,
14,
1358,
24773,
547,
12,
21157,
9,
465,
325,
26,
288,
943,
63,
11835,
14,
4050,
360,
1918,
1627,
570,
365,
1970,
15692,
436,
911,
506,
283,
2490,
283,
10649,
2659,
288,
3145,
63,
1725,
8,
793,
63,
11835,
12,
359,
5364,
566,
288,
372,
9567,
421,
199,
318,
5927,
63,
2724,
8,
793,
63,
11835,
12,
5148,
12,
666,
304,
272,
408,
272,
6990,
1124,
576,
1040,
1901,
314,
570,
1124,
1501,
1040,
3451,
315,
314,
922,
272,
1101,
2082,
14,
339,
520,
635,
943,
63,
11835,
26,
437,
5297,
14131,
909,
370,
675,
367,
2050,
14,
272,
520,
635,
5148,
26,
221,
710,
536,
402,
314,
570,
3451,
315,
314,
922,
1101,
717,
2082,
14,
272,
520,
635,
666,
26,
263,
3918,
370,
506,
6380,
436,
5313,
370,
314,
570,
1808,
717,
5927,
14,
272,
520,
1107,
26,
3322,
715,
340,
314,
2218,
1990,
9512,
14,
717,
756,
340,
2337,
1990,
282,
4983,
1125,
315,
3575,
14,
272,
408,
272,
570,
63,
515,
275,
664,
63,
576,
63,
515,
8,
793,
63,
11835,
12,
5148,
9,
272,
340,
570,
63,
515,
365,
488,
26,
267,
327,
18704,
18030,
3967,
314,
1125,
965,
2757,
10367,
315,
1124,
362,
63,
576,
63,
515,
1040,
267,
372,
756,
272,
543,
1551,
8,
493,
63,
515,
12,
283,
6603,
358,
465,
289,
26,
267,
5927,
14,
2724,
8,
576,
12,
289,
9,
272,
372,
715,
421,
199,
318,
2631,
63,
344,
8,
505,
304,
272,
408,
272,
869,
9030,
314,
1627,
1318,
14,
339
] |
[
8337,
199,
646,
747,
199,
646,
5927,
199,
199,
504,
512,
25530,
14,
9923,
492,
22296,
421,
199,
318,
664,
63,
576,
63,
515,
8,
793,
63,
11835,
12,
5148,
304,
272,
408,
272,
2372,
314,
2615,
931,
402,
1124,
5364,
1040,
3451,
315,
314,
922,
1159,
666,
2082,
14,
339,
520,
635,
943,
63,
11835,
26,
437,
5297,
14131,
909,
370,
675,
367,
2050,
14,
272,
520,
635,
5148,
26,
221,
710,
570,
7447,
931,
4839,
370,
506,
11507,
14,
272,
520,
1107,
26,
3322,
16579,
931,
402,
314,
570,
12,
18002,
652,
1159,
3451,
315,
314,
717,
922,
1159,
1101,
2082,
14,
717,
1803,
1124,
403,
1040,
340,
2337,
365,
282,
1124,
7980,
547,
1040,
717,
315,
6425,
314,
2082,
14,
272,
408,
272,
862,
26,
267,
747,
14,
8347,
8,
22185,
14,
3791,
63,
3998,
63,
3022,
12,
2187,
63,
745,
29,
549,
9,
267,
372,
747,
14,
515,
14,
904,
8,
22185,
14,
3791,
63,
3998,
63,
3022,
12,
2631,
63,
344,
8,
5364,
430,
272,
871,
8779,
547,
26,
267,
943,
63,
11835,
14,
1508,
480,
6005,
370,
1218,
922,
666,
2082,
9005,
1370,
1448,
1346,
23221,
2,
717,
283,
1928,
13627,
17374,
908,
8,
22185,
14,
3791,
63,
3998,
63,
3022,
430,
339,
372,
488,
421,
199,
318,
3145,
63,
1725,
8,
793,
63,
11835,
12,
14154,
304,
272,
408,
272,
8496,
314,
1627,
14154,
687,
314,
922,
1159,
512,
14774,
666,
2082,
14,
339,
520,
635,
943,
63,
11835,
26,
437,
5297,
14131,
909,
370,
675,
367,
2050,
14,
272,
520,
635,
14154,
26,
710,
769,
402,
1584,
370,
506,
5463,
14,
272,
520,
1107,
26,
3322,
715,
340,
1006,
314,
1627,
1584,
4898,
8792,
5463,
14,
717,
756,
4257,
14,
272,
408,
272,
1125,
63,
1725,
275,
942,
272,
754,
275,
715,
272,
367,
5148,
315,
14154,
26,
267,
862,
26,
288,
570,
63,
515,
275,
664,
63,
576,
63,
515,
8,
793,
63,
11835,
12,
5148,
9,
288,
340,
747,
14,
515,
14,
6292,
8,
493,
63,
515,
304,
355,
747,
14,
2168,
8,
493,
63,
515,
9,
288,
587,
26,
355,
754,
275,
756,
267,
871,
334,
16719,
12,
3146,
9,
465,
325,
26,
288,
1125,
63,
1725,
14,
740,
8,
2227,
63,
344,
8,
5364,
430,
339,
340,
822,
8,
705,
63,
1725,
9,
690,
378,
26,
267,
1125,
63,
1725,
275,
1656,
1987,
904,
8,
705,
63,
1725,
9,
267,
943,
63,
11835,
14,
4050,
360,
10924,
1990,
282,
5160,
13794,
314,
2569,
283,
586,
283,
1725,
26,
30332,
7754,
3145,
3062,
10250,
687,
283,
586,
3546,
11123,
1674,
908,
8,
705,
63,
1725,
12,
22296,
14,
3791,
63,
3998,
63,
3022,
430,
267,
754,
275,
756,
339,
372,
754,
421,
199,
318,
5927,
63,
912,
8,
793,
63,
11835,
12,
5148,
12,
9567,
29,
403,
304,
272,
408,
272,
2372,
314,
666,
5489,
315,
1124,
1501,
1040,
3451,
315,
314,
922,
272,
1101,
2082,
14,
5679,
4503,
26,
339,
1306,
687,
1134,
1361,
14,
8849,
14131,
492,
12119,
14131,
272,
1306,
687,
512,
25530,
14,
1199,
14,
24858,
14,
2445,
14131,
492,
5297,
14131,
272,
1306,
943,
63,
11835,
275,
5297,
14131,
8,
8849,
14131,
1012,
272,
1306,
511,
63,
576,
275,
2420,
5934,
582,
5685,
93,
272,
1306,
5927,
63,
2724,
8,
793,
63,
11835,
12,
298,
396,
63,
1715,
401,
511,
63,
576,
9,
272,
715,
272,
1306,
5927,
63,
912,
8,
793,
63,
11835,
12,
298,
396,
63,
1715,
531,
272,
791,
5934,
356,
5685,
93,
272,
1306,
5927,
63,
912,
8,
793,
63,
11835,
12,
298,
21573,
63,
1715,
531,
272,
1306,
5927,
63,
912,
8,
793,
63,
11835,
12,
298,
21573,
63,
1715,
401,
9567,
29,
2260,
9,
272,
5685,
339,
520,
635,
943,
63,
11835,
26,
437,
5297,
14131,
909,
370,
675,
367,
2050,
14,
272,
520,
635,
5148,
26,
221,
710,
536,
402,
314,
570,
3451,
315,
314,
922,
1101,
717,
2082,
14,
272,
520,
635,
9567,
26,
259,
1432,
574,
370,
9567,
370,
315,
1930,
314,
570,
3181,
1133,
717,
2187,
14,
272,
520,
1107,
26,
3322,
3918,
626,
365,
3451,
315,
314,
570,
12,
340,
314,
570,
3495,
14,
717,
6630,
314,
1124,
885,
1040,
574,
365,
2138,
14,
272,
408,
272,
570,
63,
515,
275,
664,
63,
576,
63,
515,
8,
793,
63,
11835,
12,
5148,
9,
272,
340,
570,
63,
515,
365,
488,
503,
440,
747,
14,
515,
14,
6292,
8,
493,
63,
515,
304,
267,
372,
9567,
272,
543,
1551,
8,
493,
63,
515,
12,
283,
4848,
358,
465,
289,
26,
267,
862,
26,
288,
372,
5927,
14,
912,
8,
70,
9,
267,
871,
334,
8092,
14,
1358,
24773,
547,
12,
21157,
9,
465,
325,
26,
288,
943,
63,
11835,
14,
4050,
360,
1918,
1627,
570,
365,
1970,
15692,
436,
911,
506,
283,
2490,
283,
10649,
2659,
288,
3145,
63,
1725,
8,
793,
63,
11835,
12,
359,
5364,
566,
288,
372,
9567,
421,
199,
318,
5927,
63,
2724,
8,
793,
63,
11835,
12,
5148,
12,
666,
304,
272,
408,
272,
6990,
1124,
576,
1040,
1901,
314,
570,
1124,
1501,
1040,
3451,
315,
314,
922,
272,
1101,
2082,
14,
339,
520,
635,
943,
63,
11835,
26,
437,
5297,
14131,
909,
370,
675,
367,
2050,
14,
272,
520,
635,
5148,
26,
221,
710,
536,
402,
314,
570,
3451,
315,
314,
922,
1101,
717,
2082,
14,
272,
520,
635,
666,
26,
263,
3918,
370,
506,
6380,
436,
5313,
370,
314,
570,
1808,
717,
5927,
14,
272,
520,
1107,
26,
3322,
715,
340,
314,
2218,
1990,
9512,
14,
717,
756,
340,
2337,
1990,
282,
4983,
1125,
315,
3575,
14,
272,
408,
272,
570,
63,
515,
275,
664,
63,
576,
63,
515,
8,
793,
63,
11835,
12,
5148,
9,
272,
340,
570,
63,
515,
365,
488,
26,
267,
327,
18704,
18030,
3967,
314,
1125,
965,
2757,
10367,
315,
1124,
362,
63,
576,
63,
515,
1040,
267,
372,
756,
272,
543,
1551,
8,
493,
63,
515,
12,
283,
6603,
358,
465,
289,
26,
267,
5927,
14,
2724,
8,
576,
12,
289,
9,
272,
372,
715,
421,
199,
318,
2631,
63,
344,
8,
505,
304,
272,
408,
272,
869,
9030,
314,
1627,
1318,
14,
339,
0
] |
[
1,
1,
1,
1,
1,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engadget
|
resources/lib/html5lib/constants.py
|
963
|
87346
|
from __future__ import absolute_import, division, unicode_literals
import string
import gettext
_ = gettext.gettext
EOF = None
E = {
"null-character":
_("Null character in input stream, replaced with U+FFFD."),
"invalid-codepoint":
_("Invalid codepoint in stream."),
"incorrectly-placed-solidus":
_("Solidus (/) incorrectly placed in tag."),
"incorrect-cr-newline-entity":
_("Incorrect CR newline entity, replaced with LF."),
"illegal-windows-1252-entity":
_("Entity used with illegal number (windows-1252 reference)."),
"cant-convert-numeric-entity":
_("Numeric entity couldn't be converted to character "
"(codepoint U+%(charAsInt)08x)."),
"illegal-codepoint-for-numeric-entity":
_("Numeric entity represents an illegal codepoint: "
"U+%(charAsInt)08x."),
"numeric-entity-without-semicolon":
_("Numeric entity didn't end with ';'."),
"expected-numeric-entity-but-got-eof":
_("Numeric entity expected. Got end of file instead."),
"expected-numeric-entity":
_("Numeric entity expected but none found."),
"named-entity-without-semicolon":
_("Named entity didn't end with ';'."),
"expected-named-entity":
_("Named entity expected. Got none."),
"attributes-in-end-tag":
_("End tag contains unexpected attributes."),
'self-closing-flag-on-end-tag':
_("End tag contains unexpected self-closing flag."),
"expected-tag-name-but-got-right-bracket":
_("Expected tag name. Got '>' instead."),
"expected-tag-name-but-got-question-mark":
_("Expected tag name. Got '?' instead. (HTML doesn't "
"support processing instructions.)"),
"expected-tag-name":
_("Expected tag name. Got something else instead"),
"expected-closing-tag-but-got-right-bracket":
_("Expected closing tag. Got '>' instead. Ignoring '</>'."),
"expected-closing-tag-but-got-eof":
_("Expected closing tag. Unexpected end of file."),
"expected-closing-tag-but-got-char":
_("Expected closing tag. Unexpected character '%(data)s' found."),
"eof-in-tag-name":
_("Unexpected end of file in the tag name."),
"expected-attribute-name-but-got-eof":
_("Unexpected end of file. Expected attribute name instead."),
"eof-in-attribute-name":
_("Unexpected end of file in attribute name."),
"invalid-character-in-attribute-name":
_("Invalid character in attribute name"),
"duplicate-attribute":
_("Dropped duplicate attribute on tag."),
"expected-end-of-tag-name-but-got-eof":
_("Unexpected end of file. Expected = or end of tag."),
"expected-attribute-value-but-got-eof":
_("Unexpected end of file. Expected attribute value."),
"expected-attribute-value-but-got-right-bracket":
_("Expected attribute value. Got '>' instead."),
'equals-in-unquoted-attribute-value':
_("Unexpected = in unquoted attribute"),
'unexpected-character-in-unquoted-attribute-value':
_("Unexpected character in unquoted attribute"),
"invalid-character-after-attribute-name":
_("Unexpected character after attribute name."),
"unexpected-character-after-attribute-value":
_("Unexpected character after attribute value."),
"eof-in-attribute-value-double-quote":
_("Unexpected end of file in attribute value (\")."),
"eof-in-attribute-value-single-quote":
_("Unexpected end of file in attribute value (')."),
"eof-in-attribute-value-no-quotes":
_("Unexpected end of file in attribute value."),
"unexpected-EOF-after-solidus-in-tag":
_("Unexpected end of file in tag. Expected >"),
"unexpected-character-after-solidus-in-tag":
_("Unexpected character after / in tag. Expected >"),
"expected-dashes-or-doctype":
_("Expected '--' or 'DOCTYPE'. Not found."),
"unexpected-bang-after-double-dash-in-comment":
_("Unexpected ! after -- in comment"),
"unexpected-space-after-double-dash-in-comment":
_("Unexpected space after -- in comment"),
"incorrect-comment":
_("Incorrect comment."),
"eof-in-comment":
_("Unexpected end of file in comment."),
"eof-in-comment-end-dash":
_("Unexpected end of file in comment (-)"),
"unexpected-dash-after-double-dash-in-comment":
_("Unexpected '-' after '--' found in comment."),
"eof-in-comment-double-dash":
_("Unexpected end of file in comment (--)."),
"eof-in-comment-end-space-state":
_("Unexpected end of file in comment."),
"eof-in-comment-end-bang-state":
_("Unexpected end of file in comment."),
"unexpected-char-in-comment":
_("Unexpected character in comment found."),
"need-space-after-doctype":
_("No space after literal string 'DOCTYPE'."),
"expected-doctype-name-but-got-right-bracket":
_("Unexpected > character. Expected DOCTYPE name."),
"expected-doctype-name-but-got-eof":
_("Unexpected end of file. Expected DOCTYPE name."),
"eof-in-doctype-name":
_("Unexpected end of file in DOCTYPE name."),
"eof-in-doctype":
_("Unexpected end of file in DOCTYPE."),
"expected-space-or-right-bracket-in-doctype":
_("Expected space or '>'. Got '%(data)s'"),
"unexpected-end-of-doctype":
_("Unexpected end of DOCTYPE."),
"unexpected-char-in-doctype":
_("Unexpected character in DOCTYPE."),
"eof-in-innerhtml":
_("XXX innerHTML EOF"),
"unexpected-doctype":
_("Unexpected DOCTYPE. Ignored."),
"non-html-root":
_("html needs to be the first start tag."),
"expected-doctype-but-got-eof":
_("Unexpected End of file. Expected DOCTYPE."),
"unknown-doctype":
_("Erroneous DOCTYPE."),
"expected-doctype-but-got-chars":
_("Unexpected non-space characters. Expected DOCTYPE."),
"expected-doctype-but-got-start-tag":
_("Unexpected start tag (%(name)s). Expected DOCTYPE."),
"expected-doctype-but-got-end-tag":
_("Unexpected end tag (%(name)s). Expected DOCTYPE."),
"end-tag-after-implied-root":
_("Unexpected end tag (%(name)s) after the (implied) root element."),
"expected-named-closing-tag-but-got-eof":
_("Unexpected end of file. Expected end tag (%(name)s)."),
"two-heads-are-not-better-than-one":
_("Unexpected start tag head in existing head. Ignored."),
"unexpected-end-tag":
_("Unexpected end tag (%(name)s). Ignored."),
"unexpected-start-tag-out-of-my-head":
_("Unexpected start tag (%(name)s) that can be in head. Moved."),
"unexpected-start-tag":
_("Unexpected start tag (%(name)s)."),
"missing-end-tag":
_("Missing end tag (%(name)s)."),
"missing-end-tags":
_("Missing end tags (%(name)s)."),
"unexpected-start-tag-implies-end-tag":
_("Unexpected start tag (%(startName)s) "
"implies end tag (%(endName)s)."),
"unexpected-start-tag-treated-as":
_("Unexpected start tag (%(originalName)s). Treated as %(newName)s."),
"deprecated-tag":
_("Unexpected start tag %(name)s. Don't use it!"),
"unexpected-start-tag-ignored":
_("Unexpected start tag %(name)s. Ignored."),
"expected-one-end-tag-but-got-another":
_("Unexpected end tag (%(gotName)s). "
"Missing end tag (%(expectedName)s)."),
"end-tag-too-early":
_("End tag (%(name)s) seen too early. Expected other end tag."),
"end-tag-too-early-named":
_("Unexpected end tag (%(gotName)s). Expected end tag (%(expectedName)s)."),
"end-tag-too-early-ignored":
_("End tag (%(name)s) seen too early. Ignored."),
"adoption-agency-1.1":
_("End tag (%(name)s) violates step 1, "
"paragraph 1 of the adoption agency algorithm."),
"adoption-agency-1.2":
_("End tag (%(name)s) violates step 1, "
"paragraph 2 of the adoption agency algorithm."),
"adoption-agency-1.3":
_("End tag (%(name)s) violates step 1, "
"paragraph 3 of the adoption agency algorithm."),
"adoption-agency-4.4":
_("End tag (%(name)s) violates step 4, "
"paragraph 4 of the adoption agency algorithm."),
"unexpected-end-tag-treated-as":
_("Unexpected end tag (%(originalName)s). Treated as %(newName)s."),
"no-end-tag":
_("This element (%(name)s) has no end tag."),
"unexpected-implied-end-tag-in-table":
_("Unexpected implied end tag (%(name)s) in the table phase."),
"unexpected-implied-end-tag-in-table-body":
_("Unexpected implied end tag (%(name)s) in the table body phase."),
"unexpected-char-implies-table-voodoo":
_("Unexpected non-space characters in "
"table context caused voodoo mode."),
"unexpected-hidden-input-in-table":
_("Unexpected input with type hidden in table context."),
"unexpected-form-in-table":
_("Unexpected form in table context."),
"unexpected-start-tag-implies-table-voodoo":
_("Unexpected start tag (%(name)s) in "
"table context caused voodoo mode."),
"unexpected-end-tag-implies-table-voodoo":
_("Unexpected end tag (%(name)s) in "
"table context caused voodoo mode."),
"unexpected-cell-in-table-body":
_("Unexpected table cell start tag (%(name)s) "
"in the table body phase."),
"unexpected-cell-end-tag":
_("Got table cell end tag (%(name)s) "
"while required end tags are missing."),
"unexpected-end-tag-in-table-body":
_("Unexpected end tag (%(name)s) in the table body phase. Ignored."),
"unexpected-implied-end-tag-in-table-row":
_("Unexpected implied end tag (%(name)s) in the table row phase."),
"unexpected-end-tag-in-table-row":
_("Unexpected end tag (%(name)s) in the table row phase. Ignored."),
"unexpected-select-in-select":
_("Unexpected select start tag in the select phase "
"treated as select end tag."),
"unexpected-input-in-select":
_("Unexpected input start tag in the select phase."),
"unexpected-start-tag-in-select":
_("Unexpected start tag token (%(name)s in the select phase. "
"Ignored."),
"unexpected-end-tag-in-select":
_("Unexpected end tag (%(name)s) in the select phase. Ignored."),
"unexpected-table-element-start-tag-in-select-in-table":
_("Unexpected table element start tag (%(name)s) in the select in table phase."),
"unexpected-table-element-end-tag-in-select-in-table":
_("Unexpected table element end tag (%(name)s) in the select in table phase."),
"unexpected-char-after-body":
_("Unexpected non-space characters in the after body phase."),
"unexpected-start-tag-after-body":
_("Unexpected start tag token (%(name)s)"
" in the after body phase."),
"unexpected-end-tag-after-body":
_("Unexpected end tag token (%(name)s)"
" in the after body phase."),
"unexpected-char-in-frameset":
_("Unexpected characters in the frameset phase. Characters ignored."),
"unexpected-start-tag-in-frameset":
_("Unexpected start tag token (%(name)s)"
" in the frameset phase. Ignored."),
"unexpected-frameset-in-frameset-innerhtml":
_("Unexpected end tag token (frameset) "
"in the frameset phase (innerHTML)."),
"unexpected-end-tag-in-frameset":
_("Unexpected end tag token (%(name)s)"
" in the frameset phase. Ignored."),
"unexpected-char-after-frameset":
_("Unexpected non-space characters in the "
"after frameset phase. Ignored."),
"unexpected-start-tag-after-frameset":
_("Unexpected start tag (%(name)s)"
" in the after frameset phase. Ignored."),
"unexpected-end-tag-after-frameset":
_("Unexpected end tag (%(name)s)"
" in the after frameset phase. Ignored."),
"unexpected-end-tag-after-body-innerhtml":
_("Unexpected end tag after body(innerHtml)"),
"expected-eof-but-got-char":
_("Unexpected non-space characters. Expected end of file."),
"expected-eof-but-got-start-tag":
_("Unexpected start tag (%(name)s)"
". Expected end of file."),
"expected-eof-but-got-end-tag":
_("Unexpected end tag (%(name)s)"
". Expected end of file."),
"eof-in-table":
_("Unexpected end of file. Expected table content."),
"eof-in-select":
_("Unexpected end of file. Expected select content."),
"eof-in-frameset":
_("Unexpected end of file. Expected frameset content."),
"eof-in-script-in-script":
_("Unexpected end of file. Expected script content."),
"eof-in-foreign-lands":
_("Unexpected end of file. Expected foreign content"),
"non-void-element-with-trailing-solidus":
_("Trailing solidus not allowed on element %(name)s"),
"unexpected-html-element-in-foreign-content":
_("Element %(name)s not allowed in a non-html context"),
"unexpected-end-tag-before-html":
_("Unexpected end tag (%(name)s) before html."),
"XXX-undefined-error":
_("Undefined error (this sucks and should be fixed)"),
}
namespaces = {
"html": "http://www.w3.org/1999/xhtml",
"mathml": "http://www.w3.org/1998/Math/MathML",
"svg": "http://www.w3.org/2000/svg",
"xlink": "http://www.w3.org/1999/xlink",
"xml": "http://www.w3.org/XML/1998/namespace",
"xmlns": "http://www.w3.org/2000/xmlns/"
}
scopingElements = frozenset((
(namespaces["html"], "applet"),
(namespaces["html"], "caption"),
(namespaces["html"], "html"),
(namespaces["html"], "marquee"),
(namespaces["html"], "object"),
(namespaces["html"], "table"),
(namespaces["html"], "td"),
(namespaces["html"], "th"),
(namespaces["mathml"], "mi"),
(namespaces["mathml"], "mo"),
(namespaces["mathml"], "mn"),
(namespaces["mathml"], "ms"),
(namespaces["mathml"], "mtext"),
(namespaces["mathml"], "annotation-xml"),
(namespaces["svg"], "foreignObject"),
(namespaces["svg"], "desc"),
(namespaces["svg"], "title"),
))
formattingElements = frozenset((
(namespaces["html"], "a"),
(namespaces["html"], "b"),
(namespaces["html"], "big"),
(namespaces["html"], "code"),
(namespaces["html"], "em"),
(namespaces["html"], "font"),
(namespaces["html"], "i"),
(namespaces["html"], "nobr"),
(namespaces["html"], "s"),
(namespaces["html"], "small"),
(namespaces["html"], "strike"),
(namespaces["html"], "strong"),
(namespaces["html"], "tt"),
(namespaces["html"], "u")
))
specialElements = frozenset((
(namespaces["html"], "address"),
(namespaces["html"], "applet"),
(namespaces["html"], "area"),
(namespaces["html"], "article"),
(namespaces["html"], "aside"),
(namespaces["html"], "base"),
(namespaces["html"], "basefont"),
(namespaces["html"], "bgsound"),
(namespaces["html"], "blockquote"),
(namespaces["html"], "body"),
(namespaces["html"], "br"),
(namespaces["html"], "button"),
(namespaces["html"], "caption"),
(namespaces["html"], "center"),
(namespaces["html"], "col"),
(namespaces["html"], "colgroup"),
(namespaces["html"], "command"),
(namespaces["html"], "dd"),
(namespaces["html"], "details"),
(namespaces["html"], "dir"),
(namespaces["html"], "div"),
(namespaces["html"], "dl"),
(namespaces["html"], "dt"),
(namespaces["html"], "embed"),
(namespaces["html"], "fieldset"),
(namespaces["html"], "figure"),
(namespaces["html"], "footer"),
(namespaces["html"], "form"),
(namespaces["html"], "frame"),
(namespaces["html"], "frameset"),
(namespaces["html"], "h1"),
(namespaces["html"], "h2"),
(namespaces["html"], "h3"),
(namespaces["html"], "h4"),
(namespaces["html"], "h5"),
(namespaces["html"], "h6"),
(namespaces["html"], "head"),
(namespaces["html"], "header"),
(namespaces["html"], "hr"),
(namespaces["html"], "html"),
(namespaces["html"], "iframe"),
# Note that image is commented out in the spec as "this isn't an
# element that can end up on the stack, so it doesn't matter,"
(namespaces["html"], "image"),
(namespaces["html"], "img"),
(namespaces["html"], "input"),
(namespaces["html"], "isindex"),
(namespaces["html"], "li"),
(namespaces["html"], "link"),
(namespaces["html"], "listing"),
(namespaces["html"], "marquee"),
(namespaces["html"], "menu"),
(namespaces["html"], "meta"),
(namespaces["html"], "nav"),
(namespaces["html"], "noembed"),
(namespaces["html"], "noframes"),
(namespaces["html"], "noscript"),
(namespaces["html"], "object"),
(namespaces["html"], "ol"),
(namespaces["html"], "p"),
(namespaces["html"], "param"),
(namespaces["html"], "plaintext"),
(namespaces["html"], "pre"),
(namespaces["html"], "script"),
(namespaces["html"], "section"),
(namespaces["html"], "select"),
(namespaces["html"], "style"),
(namespaces["html"], "table"),
(namespaces["html"], "tbody"),
(namespaces["html"], "td"),
(namespaces["html"], "textarea"),
(namespaces["html"], "tfoot"),
(namespaces["html"], "th"),
(namespaces["html"], "thead"),
(namespaces["html"], "title"),
(namespaces["html"], "tr"),
(namespaces["html"], "ul"),
(namespaces["html"], "wbr"),
(namespaces["html"], "xmp"),
(namespaces["svg"], "foreignObject")
))
htmlIntegrationPointElements = frozenset((
(namespaces["mathml"], "annotaion-xml"),
(namespaces["svg"], "foreignObject"),
(namespaces["svg"], "desc"),
(namespaces["svg"], "title")
))
mathmlTextIntegrationPointElements = frozenset((
(namespaces["mathml"], "mi"),
(namespaces["mathml"], "mo"),
(namespaces["mathml"], "mn"),
(namespaces["mathml"], "ms"),
(namespaces["mathml"], "mtext")
))
adjustForeignAttributes = {
"xlink:actuate": ("xlink", "actuate", namespaces["xlink"]),
"xlink:arcrole": ("xlink", "arcrole", namespaces["xlink"]),
"xlink:href": ("xlink", "href", namespaces["xlink"]),
"xlink:role": ("xlink", "role", namespaces["xlink"]),
"xlink:show": ("xlink", "show", namespaces["xlink"]),
"xlink:title": ("xlink", "title", namespaces["xlink"]),
"xlink:type": ("xlink", "type", namespaces["xlink"]),
"xml:base": ("xml", "base", namespaces["xml"]),
"xml:lang": ("xml", "lang", namespaces["xml"]),
"xml:space": ("xml", "space", namespaces["xml"]),
"xmlns": (None, "xmlns", namespaces["xmlns"]),
"xmlns:xlink": ("xmlns", "xlink", namespaces["xmlns"])
}
unadjustForeignAttributes = dict([((ns, local), qname) for qname, (prefix, local, ns) in
adjustForeignAttributes.items()])
spaceCharacters = frozenset((
"\t",
"\n",
"\u000C",
" ",
"\r"
))
tableInsertModeElements = frozenset((
"table",
"tbody",
"tfoot",
"thead",
"tr"
))
asciiLowercase = frozenset(string.ascii_lowercase)
asciiUppercase = frozenset(string.ascii_uppercase)
asciiLetters = frozenset(string.ascii_letters)
digits = frozenset(string.digits)
hexDigits = frozenset(string.hexdigits)
asciiUpper2Lower = dict([(ord(c), ord(c.lower()))
for c in string.ascii_uppercase])
# Heading elements need to be ordered
headingElements = (
"h1",
"h2",
"h3",
"h4",
"h5",
"h6"
)
voidElements = frozenset((
"base",
"command",
"event-source",
"link",
"meta",
"hr",
"br",
"img",
"embed",
"param",
"area",
"col",
"input",
"source",
"track"
))
cdataElements = frozenset(('title', 'textarea'))
rcdataElements = frozenset((
'style',
'script',
'xmp',
'iframe',
'noembed',
'noframes',
'noscript'
))
booleanAttributes = {
"": frozenset(("irrelevant",)),
"style": frozenset(("scoped",)),
"img": frozenset(("ismap",)),
"audio": frozenset(("autoplay", "controls")),
"video": frozenset(("autoplay", "controls")),
"script": frozenset(("defer", "async")),
"details": frozenset(("open",)),
"datagrid": frozenset(("multiple", "disabled")),
"command": frozenset(("hidden", "disabled", "checked", "default")),
"hr": frozenset(("noshade")),
"menu": frozenset(("autosubmit",)),
"fieldset": frozenset(("disabled", "readonly")),
"option": frozenset(("disabled", "readonly", "selected")),
"optgroup": frozenset(("disabled", "readonly")),
"button": frozenset(("disabled", "autofocus")),
"input": frozenset(("disabled", "readonly", "required", "autofocus", "checked", "ismap")),
"select": frozenset(("disabled", "readonly", "autofocus", "multiple")),
"output": frozenset(("disabled", "readonly")),
}
# entitiesWindows1252 has to be _ordered_ and needs to have an index. It
# therefore can't be a frozenset.
entitiesWindows1252 = (
8364, # 0x80 0x20AC EURO SIGN
65533, # 0x81 UNDEFINED
8218, # 0x82 0x201A SINGLE LOW-9 QUOTATION MARK
402, # 0x83 0x0192 LATIN SMALL LETTER F WITH HOOK
8222, # 0x84 0x201E DOUBLE LOW-9 QUOTATION MARK
8230, # 0x85 0x2026 HORIZONTAL ELLIPSIS
8224, # 0x86 0x2020 DAGGER
8225, # 0x87 0x2021 DOUBLE DAGGER
710, # 0x88 0x02C6 MODIFIER LETTER CIRCUMFLEX ACCENT
8240, # 0x89 0x2030 PER MILLE SIGN
352, # 0x8A 0x0160 LATIN CAPITAL LETTER S WITH CARON
8249, # 0x8B 0x2039 SINGLE LEFT-POINTING ANGLE QUOTATION MARK
338, # 0x8C 0x0152 LATIN CAPITAL LIGATURE OE
65533, # 0x8D UNDEFINED
381, # 0x8E 0x017D LATIN CAPITAL LETTER Z WITH CARON
65533, # 0x8F UNDEFINED
65533, # 0x90 UNDEFINED
8216, # 0x91 0x2018 LEFT SINGLE QUOTATION MARK
8217, # 0x92 0x2019 RIGHT SINGLE QUOTATION MARK
8220, # 0x93 0x201C LEFT DOUBLE QUOTATION MARK
8221, # 0x94 0x201D RIGHT DOUBLE QUOTATION MARK
8226, # 0x95 0x2022 BULLET
8211, # 0x96 0x2013 EN DASH
8212, # 0x97 0x2014 EM DASH
732, # 0x98 0x02DC SMALL TILDE
8482, # 0x99 0x2122 TRADE MARK SIGN
353, # 0x9A 0x0161 LATIN SMALL LETTER S WITH CARON
8250, # 0x9B 0x203A SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
339, # 0x9C 0x0153 LATIN SMALL LIGATURE OE
65533, # 0x9D UNDEFINED
382, # 0x9E 0x017E LATIN SMALL LETTER Z WITH CARON
376 # 0x9F 0x0178 LATIN CAPITAL LETTER Y WITH DIAERESIS
)
xmlEntities = frozenset(('lt;', 'gt;', 'amp;', 'apos;', 'quot;'))
entities = {
"AElig": "\xc6",
"AElig;": "\xc6",
"AMP": "&",
"AMP;": "&",
"Aacute": "\xc1",
"Aacute;": "\xc1",
"Abreve;": "\u0102",
"Acirc": "\xc2",
"Acirc;": "\xc2",
"Acy;": "\u0410",
"Afr;": "\U0001d504",
"Agrave": "\xc0",
"Agrave;": "\xc0",
"Alpha;": "\u0391",
"Amacr;": "\u0100",
"And;": "\u2a53",
"Aogon;": "\u0104",
"Aopf;": "\U0001d538",
"ApplyFunction;": "\u2061",
"Aring": "\xc5",
"Aring;": "\xc5",
"Ascr;": "\U0001d49c",
"Assign;": "\u2254",
"Atilde": "\xc3",
"Atilde;": "\xc3",
"Auml": "\xc4",
"Auml;": "\xc4",
"Backslash;": "\u2216",
"Barv;": "\u2ae7",
"Barwed;": "\u2306",
"Bcy;": "\u0411",
"Because;": "\u2235",
"Bernoullis;": "\u212c",
"Beta;": "\u0392",
"Bfr;": "\U0001d505",
"Bopf;": "\U0001d539",
"Breve;": "\u02d8",
"Bscr;": "\u212c",
"Bumpeq;": "\u224e",
"CHcy;": "\u0427",
"COPY": "\xa9",
"COPY;": "\xa9",
"Cacute;": "\u0106",
"Cap;": "\u22d2",
"CapitalDifferentialD;": "\u2145",
"Cayleys;": "\u212d",
"Ccaron;": "\u010c",
"Ccedil": "\xc7",
"Ccedil;": "\xc7",
"Ccirc;": "\u0108",
"Cconint;": "\u2230",
"Cdot;": "\u010a",
"Cedilla;": "\xb8",
"CenterDot;": "\xb7",
"Cfr;": "\u212d",
"Chi;": "\u03a7",
"CircleDot;": "\u2299",
"CircleMinus;": "\u2296",
"CirclePlus;": "\u2295",
"CircleTimes;": "\u2297",
"ClockwiseContourIntegral;": "\u2232",
"CloseCurlyDoubleQuote;": "\u201d",
"CloseCurlyQuote;": "\u2019",
"Colon;": "\u2237",
"Colone;": "\u2a74",
"Congruent;": "\u2261",
"Conint;": "\u222f",
"ContourIntegral;": "\u222e",
"Copf;": "\u2102",
"Coproduct;": "\u2210",
"CounterClockwiseContourIntegral;": "\u2233",
"Cross;": "\u2a2f",
"Cscr;": "\U0001d49e",
"Cup;": "\u22d3",
"CupCap;": "\u224d",
"DD;": "\u2145",
"DDotrahd;": "\u2911",
"DJcy;": "\u0402",
"DScy;": "\u0405",
"DZcy;": "\u040f",
"Dagger;": "\u2021",
"Darr;": "\u21a1",
"Dashv;": "\u2ae4",
"Dcaron;": "\u010e",
"Dcy;": "\u0414",
"Del;": "\u2207",
"Delta;": "\u0394",
"Dfr;": "\U0001d507",
"DiacriticalAcute;": "\xb4",
"DiacriticalDot;": "\u02d9",
"DiacriticalDoubleAcute;": "\u02dd",
"DiacriticalGrave;": "`",
"DiacriticalTilde;": "\u02dc",
"Diamond;": "\u22c4",
"DifferentialD;": "\u2146",
"Dopf;": "\U0001d53b",
"Dot;": "\xa8",
"DotDot;": "\u20dc",
"DotEqual;": "\u2250",
"DoubleContourIntegral;": "\u222f",
"DoubleDot;": "\xa8",
"DoubleDownArrow;": "\u21d3",
"DoubleLeftArrow;": "\u21d0",
"DoubleLeftRightArrow;": "\u21d4",
"DoubleLeftTee;": "\u2ae4",
"DoubleLongLeftArrow;": "\u27f8",
"DoubleLongLeftRightArrow;": "\u27fa",
"DoubleLongRightArrow;": "\u27f9",
"DoubleRightArrow;": "\u21d2",
"DoubleRightTee;": "\u22a8",
"DoubleUpArrow;": "\u21d1",
"DoubleUpDownArrow;": "\u21d5",
"DoubleVerticalBar;": "\u2225",
"DownArrow;": "\u2193",
"DownArrowBar;": "\u2913",
"DownArrowUpArrow;": "\u21f5",
"DownBreve;": "\u0311",
"DownLeftRightVector;": "\u2950",
"DownLeftTeeVector;": "\u295e",
"DownLeftVector;": "\u21bd",
"DownLeftVectorBar;": "\u2956",
"DownRightTeeVector;": "\u295f",
"DownRightVector;": "\u21c1",
"DownRightVectorBar;": "\u2957",
"DownTee;": "\u22a4",
"DownTeeArrow;": "\u21a7",
"Downarrow;": "\u21d3",
"Dscr;": "\U0001d49f",
"Dstrok;": "\u0110",
"ENG;": "\u014a",
"ETH": "\xd0",
"ETH;": "\xd0",
"Eacute": "\xc9",
"Eacute;": "\xc9",
"Ecaron;": "\u011a",
"Ecirc": "\xca",
"Ecirc;": "\xca",
"Ecy;": "\u042d",
"Edot;": "\u0116",
"Efr;": "\U0001d508",
"Egrave": "\xc8",
"Egrave;": "\xc8",
"Element;": "\u2208",
"Emacr;": "\u0112",
"EmptySmallSquare;": "\u25fb",
"EmptyVerySmallSquare;": "\u25ab",
"Eogon;": "\u0118",
"Eopf;": "\U0001d53c",
"Epsilon;": "\u0395",
"Equal;": "\u2a75",
"EqualTilde;": "\u2242",
"Equilibrium;": "\u21cc",
"Escr;": "\u2130",
"Esim;": "\u2a73",
"Eta;": "\u0397",
"Euml": "\xcb",
"Euml;": "\xcb",
"Exists;": "\u2203",
"ExponentialE;": "\u2147",
"Fcy;": "\u0424",
"Ffr;": "\U0001d509",
"FilledSmallSquare;": "\u25fc",
"FilledVerySmallSquare;": "\u25aa",
"Fopf;": "\U0001d53d",
"ForAll;": "\u2200",
"Fouriertrf;": "\u2131",
"Fscr;": "\u2131",
"GJcy;": "\u0403",
"GT": ">",
"GT;": ">",
"Gamma;": "\u0393",
"Gammad;": "\u03dc",
"Gbreve;": "\u011e",
"Gcedil;": "\u0122",
"Gcirc;": "\u011c",
"Gcy;": "\u0413",
"Gdot;": "\u0120",
"Gfr;": "\U0001d50a",
"Gg;": "\u22d9",
"Gopf;": "\U0001d53e",
"GreaterEqual;": "\u2265",
"GreaterEqualLess;": "\u22db",
"GreaterFullEqual;": "\u2267",
"GreaterGreater;": "\u2aa2",
"GreaterLess;": "\u2277",
"GreaterSlantEqual;": "\u2a7e",
"GreaterTilde;": "\u2273",
"Gscr;": "\U0001d4a2",
"Gt;": "\u226b",
"HARDcy;": "\u042a",
"Hacek;": "\u02c7",
"Hat;": "^",
"Hcirc;": "\u0124",
"Hfr;": "\u210c",
"HilbertSpace;": "\u210b",
"Hopf;": "\u210d",
"HorizontalLine;": "\u2500",
"Hscr;": "\u210b",
"Hstrok;": "\u0126",
"HumpDownHump;": "\u224e",
"HumpEqual;": "\u224f",
"IEcy;": "\u0415",
"IJlig;": "\u0132",
"IOcy;": "\u0401",
"Iacute": "\xcd",
"Iacute;": "\xcd",
"Icirc": "\xce",
"Icirc;": "\xce",
"Icy;": "\u0418",
"Idot;": "\u0130",
"Ifr;": "\u2111",
"Igrave": "\xcc",
"Igrave;": "\xcc",
"Im;": "\u2111",
"Imacr;": "\u012a",
"ImaginaryI;": "\u2148",
"Implies;": "\u21d2",
"Int;": "\u222c",
"Integral;": "\u222b",
"Intersection;": "\u22c2",
"InvisibleComma;": "\u2063",
"InvisibleTimes;": "\u2062",
"Iogon;": "\u012e",
"Iopf;": "\U0001d540",
"Iota;": "\u0399",
"Iscr;": "\u2110",
"Itilde;": "\u0128",
"Iukcy;": "\u0406",
"Iuml": "\xcf",
"Iuml;": "\xcf",
"Jcirc;": "\u0134",
"Jcy;": "\u0419",
"Jfr;": "\U0001d50d",
"Jopf;": "\U0001d541",
"Jscr;": "\U0001d4a5",
"Jsercy;": "\u0408",
"Jukcy;": "\u0404",
"KHcy;": "\u0425",
"KJcy;": "\u040c",
"Kappa;": "\u039a",
"Kcedil;": "\u0136",
"Kcy;": "\u041a",
"Kfr;": "\U0001d50e",
"Kopf;": "\U0001d542",
"Kscr;": "\U0001d4a6",
"LJcy;": "\u0409",
"LT": "<",
"LT;": "<",
"Lacute;": "\u0139",
"Lambda;": "\u039b",
"Lang;": "\u27ea",
"Laplacetrf;": "\u2112",
"Larr;": "\u219e",
"Lcaron;": "\u013d",
"Lcedil;": "\u013b",
"Lcy;": "\u041b",
"LeftAngleBracket;": "\u27e8",
"LeftArrow;": "\u2190",
"LeftArrowBar;": "\u21e4",
"LeftArrowRightArrow;": "\u21c6",
"LeftCeiling;": "\u2308",
"LeftDoubleBracket;": "\u27e6",
"LeftDownTeeVector;": "\u2961",
"LeftDownVector;": "\u21c3",
"LeftDownVectorBar;": "\u2959",
"LeftFloor;": "\u230a",
"LeftRightArrow;": "\u2194",
"LeftRightVector;": "\u294e",
"LeftTee;": "\u22a3",
"LeftTeeArrow;": "\u21a4",
"LeftTeeVector;": "\u295a",
"LeftTriangle;": "\u22b2",
"LeftTriangleBar;": "\u29cf",
"LeftTriangleEqual;": "\u22b4",
"LeftUpDownVector;": "\u2951",
"LeftUpTeeVector;": "\u2960",
"LeftUpVector;": "\u21bf",
"LeftUpVectorBar;": "\u2958",
"LeftVector;": "\u21bc",
"LeftVectorBar;": "\u2952",
"Leftarrow;": "\u21d0",
"Leftrightarrow;": "\u21d4",
"LessEqualGreater;": "\u22da",
"LessFullEqual;": "\u2266",
"LessGreater;": "\u2276",
"LessLess;": "\u2aa1",
"LessSlantEqual;": "\u2a7d",
"LessTilde;": "\u2272",
"Lfr;": "\U0001d50f",
"Ll;": "\u22d8",
"Lleftarrow;": "\u21da",
"Lmidot;": "\u013f",
"LongLeftArrow;": "\u27f5",
"LongLeftRightArrow;": "\u27f7",
"LongRightArrow;": "\u27f6",
"Longleftarrow;": "\u27f8",
"Longleftrightarrow;": "\u27fa",
"Longrightarrow;": "\u27f9",
"Lopf;": "\U0001d543",
"LowerLeftArrow;": "\u2199",
"LowerRightArrow;": "\u2198",
"Lscr;": "\u2112",
"Lsh;": "\u21b0",
"Lstrok;": "\u0141",
"Lt;": "\u226a",
"Map;": "\u2905",
"Mcy;": "\u041c",
"MediumSpace;": "\u205f",
"Mellintrf;": "\u2133",
"Mfr;": "\U0001d510",
"MinusPlus;": "\u2213",
"Mopf;": "\U0001d544",
"Mscr;": "\u2133",
"Mu;": "\u039c",
"NJcy;": "\u040a",
"Nacute;": "\u0143",
"Ncaron;": "\u0147",
"Ncedil;": "\u0145",
"Ncy;": "\u041d",
"NegativeMediumSpace;": "\u200b",
"NegativeThickSpace;": "\u200b",
"NegativeThinSpace;": "\u200b",
"NegativeVeryThinSpace;": "\u200b",
"NestedGreaterGreater;": "\u226b",
"NestedLessLess;": "\u226a",
"NewLine;": "\n",
"Nfr;": "\U0001d511",
"NoBreak;": "\u2060",
"NonBreakingSpace;": "\xa0",
"Nopf;": "\u2115",
"Not;": "\u2aec",
"NotCongruent;": "\u2262",
"NotCupCap;": "\u226d",
"NotDoubleVerticalBar;": "\u2226",
"NotElement;": "\u2209",
"NotEqual;": "\u2260",
"NotEqualTilde;": "\u2242\u0338",
"NotExists;": "\u2204",
"NotGreater;": "\u226f",
"NotGreaterEqual;": "\u2271",
"NotGreaterFullEqual;": "\u2267\u0338",
"NotGreaterGreater;": "\u226b\u0338",
"NotGreaterLess;": "\u2279",
"NotGreaterSlantEqual;": "\u2a7e\u0338",
"NotGreaterTilde;": "\u2275",
"NotHumpDownHump;": "\u224e\u0338",
"NotHumpEqual;": "\u224f\u0338",
"NotLeftTriangle;": "\u22ea",
"NotLeftTriangleBar;": "\u29cf\u0338",
"NotLeftTriangleEqual;": "\u22ec",
"NotLess;": "\u226e",
"NotLessEqual;": "\u2270",
"NotLessGreater;": "\u2278",
"NotLessLess;": "\u226a\u0338",
"NotLessSlantEqual;": "\u2a7d\u0338",
"NotLessTilde;": "\u2274",
"NotNestedGreaterGreater;": "\u2aa2\u0338",
"NotNestedLessLess;": "\u2aa1\u0338",
"NotPrecedes;": "\u2280",
"NotPrecedesEqual;": "\u2aaf\u0338",
"NotPrecedesSlantEqual;": "\u22e0",
"NotReverseElement;": "\u220c",
"NotRightTriangle;": "\u22eb",
"NotRightTriangleBar;": "\u29d0\u0338",
"NotRightTriangleEqual;": "\u22ed",
"NotSquareSubset;": "\u228f\u0338",
"NotSquareSubsetEqual;": "\u22e2",
"NotSquareSuperset;": "\u2290\u0338",
"NotSquareSupersetEqual;": "\u22e3",
"NotSubset;": "\u2282\u20d2",
"NotSubsetEqual;": "\u2288",
"NotSucceeds;": "\u2281",
"NotSucceedsEqual;": "\u2ab0\u0338",
"NotSucceedsSlantEqual;": "\u22e1",
"NotSucceedsTilde;": "\u227f\u0338",
"NotSuperset;": "\u2283\u20d2",
"NotSupersetEqual;": "\u2289",
"NotTilde;": "\u2241",
"NotTildeEqual;": "\u2244",
"NotTildeFullEqual;": "\u2247",
"NotTildeTilde;": "\u2249",
"NotVerticalBar;": "\u2224",
"Nscr;": "\U0001d4a9",
"Ntilde": "\xd1",
"Ntilde;": "\xd1",
"Nu;": "\u039d",
"OElig;": "\u0152",
"Oacute": "\xd3",
"Oacute;": "\xd3",
"Ocirc": "\xd4",
"Ocirc;": "\xd4",
"Ocy;": "\u041e",
"Odblac;": "\u0150",
"Ofr;": "\U0001d512",
"Ograve": "\xd2",
"Ograve;": "\xd2",
"Omacr;": "\u014c",
"Omega;": "\u03a9",
"Omicron;": "\u039f",
"Oopf;": "\U0001d546",
"OpenCurlyDoubleQuote;": "\u201c",
"OpenCurlyQuote;": "\u2018",
"Or;": "\u2a54",
"Oscr;": "\U0001d4aa",
"Oslash": "\xd8",
"Oslash;": "\xd8",
"Otilde": "\xd5",
"Otilde;": "\xd5",
"Otimes;": "\u2a37",
"Ouml": "\xd6",
"Ouml;": "\xd6",
"OverBar;": "\u203e",
"OverBrace;": "\u23de",
"OverBracket;": "\u23b4",
"OverParenthesis;": "\u23dc",
"PartialD;": "\u2202",
"Pcy;": "\u041f",
"Pfr;": "\U0001d513",
"Phi;": "\u03a6",
"Pi;": "\u03a0",
"PlusMinus;": "\xb1",
"Poincareplane;": "\u210c",
"Popf;": "\u2119",
"Pr;": "\u2abb",
"Precedes;": "\u227a",
"PrecedesEqual;": "\u2aaf",
"PrecedesSlantEqual;": "\u227c",
"PrecedesTilde;": "\u227e",
"Prime;": "\u2033",
"Product;": "\u220f",
"Proportion;": "\u2237",
"Proportional;": "\u221d",
"Pscr;": "\U0001d4ab",
"Psi;": "\u03a8",
"QUOT": "\"",
"QUOT;": "\"",
"Qfr;": "\U0001d514",
"Qopf;": "\u211a",
"Qscr;": "\U0001d4ac",
"RBarr;": "\u2910",
"REG": "\xae",
"REG;": "\xae",
"Racute;": "\u0154",
"Rang;": "\u27eb",
"Rarr;": "\u21a0",
"Rarrtl;": "\u2916",
"Rcaron;": "\u0158",
"Rcedil;": "\u0156",
"Rcy;": "\u0420",
"Re;": "\u211c",
"ReverseElement;": "\u220b",
"ReverseEquilibrium;": "\u21cb",
"ReverseUpEquilibrium;": "\u296f",
"Rfr;": "\u211c",
"Rho;": "\u03a1",
"RightAngleBracket;": "\u27e9",
"RightArrow;": "\u2192",
"RightArrowBar;": "\u21e5",
"RightArrowLeftArrow;": "\u21c4",
"RightCeiling;": "\u2309",
"RightDoubleBracket;": "\u27e7",
"RightDownTeeVector;": "\u295d",
"RightDownVector;": "\u21c2",
"RightDownVectorBar;": "\u2955",
"RightFloor;": "\u230b",
"RightTee;": "\u22a2",
"RightTeeArrow;": "\u21a6",
"RightTeeVector;": "\u295b",
"RightTriangle;": "\u22b3",
"RightTriangleBar;": "\u29d0",
"RightTriangleEqual;": "\u22b5",
"RightUpDownVector;": "\u294f",
"RightUpTeeVector;": "\u295c",
"RightUpVector;": "\u21be",
"RightUpVectorBar;": "\u2954",
"RightVector;": "\u21c0",
"RightVectorBar;": "\u2953",
"Rightarrow;": "\u21d2",
"Ropf;": "\u211d",
"RoundImplies;": "\u2970",
"Rrightarrow;": "\u21db",
"Rscr;": "\u211b",
"Rsh;": "\u21b1",
"RuleDelayed;": "\u29f4",
"SHCHcy;": "\u0429",
"SHcy;": "\u0428",
"SOFTcy;": "\u042c",
"Sacute;": "\u015a",
"Sc;": "\u2abc",
"Scaron;": "\u0160",
"Scedil;": "\u015e",
"Scirc;": "\u015c",
"Scy;": "\u0421",
"Sfr;": "\U0001d516",
"ShortDownArrow;": "\u2193",
"ShortLeftArrow;": "\u2190",
"ShortRightArrow;": "\u2192",
"ShortUpArrow;": "\u2191",
"Sigma;": "\u03a3",
"SmallCircle;": "\u2218",
"Sopf;": "\U0001d54a",
"Sqrt;": "\u221a",
"Square;": "\u25a1",
"SquareIntersection;": "\u2293",
"SquareSubset;": "\u228f",
"SquareSubsetEqual;": "\u2291",
"SquareSuperset;": "\u2290",
"SquareSupersetEqual;": "\u2292",
"SquareUnion;": "\u2294",
"Sscr;": "\U0001d4ae",
"Star;": "\u22c6",
"Sub;": "\u22d0",
"Subset;": "\u22d0",
"SubsetEqual;": "\u2286",
"Succeeds;": "\u227b",
"SucceedsEqual;": "\u2ab0",
"SucceedsSlantEqual;": "\u227d",
"SucceedsTilde;": "\u227f",
"SuchThat;": "\u220b",
"Sum;": "\u2211",
"Sup;": "\u22d1",
"Superset;": "\u2283",
"SupersetEqual;": "\u2287",
"Supset;": "\u22d1",
"THORN": "\xde",
"THORN;": "\xde",
"TRADE;": "\u2122",
"TSHcy;": "\u040b",
"TScy;": "\u0426",
"Tab;": "\t",
"Tau;": "\u03a4",
"Tcaron;": "\u0164",
"Tcedil;": "\u0162",
"Tcy;": "\u0422",
"Tfr;": "\U0001d517",
"Therefore;": "\u2234",
"Theta;": "\u0398",
"ThickSpace;": "\u205f\u200a",
"ThinSpace;": "\u2009",
"Tilde;": "\u223c",
"TildeEqual;": "\u2243",
"TildeFullEqual;": "\u2245",
"TildeTilde;": "\u2248",
"Topf;": "\U0001d54b",
"TripleDot;": "\u20db",
"Tscr;": "\U0001d4af",
"Tstrok;": "\u0166",
"Uacute": "\xda",
"Uacute;": "\xda",
"Uarr;": "\u219f",
"Uarrocir;": "\u2949",
"Ubrcy;": "\u040e",
"Ubreve;": "\u016c",
"Ucirc": "\xdb",
"Ucirc;": "\xdb",
"Ucy;": "\u0423",
"Udblac;": "\u0170",
"Ufr;": "\U0001d518",
"Ugrave": "\xd9",
"Ugrave;": "\xd9",
"Umacr;": "\u016a",
"UnderBar;": "_",
"UnderBrace;": "\u23df",
"UnderBracket;": "\u23b5",
"UnderParenthesis;": "\u23dd",
"Union;": "\u22c3",
"UnionPlus;": "\u228e",
"Uogon;": "\u0172",
"Uopf;": "\U0001d54c",
"UpArrow;": "\u2191",
"UpArrowBar;": "\u2912",
"UpArrowDownArrow;": "\u21c5",
"UpDownArrow;": "\u2195",
"UpEquilibrium;": "\u296e",
"UpTee;": "\u22a5",
"UpTeeArrow;": "\u21a5",
"Uparrow;": "\u21d1",
"Updownarrow;": "\u21d5",
"UpperLeftArrow;": "\u2196",
"UpperRightArrow;": "\u2197",
"Upsi;": "\u03d2",
"Upsilon;": "\u03a5",
"Uring;": "\u016e",
"Uscr;": "\U0001d4b0",
"Utilde;": "\u0168",
"Uuml": "\xdc",
"Uuml;": "\xdc",
"VDash;": "\u22ab",
"Vbar;": "\u2aeb",
"Vcy;": "\u0412",
"Vdash;": "\u22a9",
"Vdashl;": "\u2ae6",
"Vee;": "\u22c1",
"Verbar;": "\u2016",
"Vert;": "\u2016",
"VerticalBar;": "\u2223",
"VerticalLine;": "|",
"VerticalSeparator;": "\u2758",
"VerticalTilde;": "\u2240",
"VeryThinSpace;": "\u200a",
"Vfr;": "\U0001d519",
"Vopf;": "\U0001d54d",
"Vscr;": "\U0001d4b1",
"Vvdash;": "\u22aa",
"Wcirc;": "\u0174",
"Wedge;": "\u22c0",
"Wfr;": "\U0001d51a",
"Wopf;": "\U0001d54e",
"Wscr;": "\U0001d4b2",
"Xfr;": "\U0001d51b",
"Xi;": "\u039e",
"Xopf;": "\U0001d54f",
"Xscr;": "\U0001d4b3",
"YAcy;": "\u042f",
"YIcy;": "\u0407",
"YUcy;": "\u042e",
"Yacute": "\xdd",
"Yacute;": "\xdd",
"Ycirc;": "\u0176",
"Ycy;": "\u042b",
"Yfr;": "\U0001d51c",
"Yopf;": "\U0001d550",
"Yscr;": "\U0001d4b4",
"Yuml;": "\u0178",
"ZHcy;": "\u0416",
"Zacute;": "\u0179",
"Zcaron;": "\u017d",
"Zcy;": "\u0417",
"Zdot;": "\u017b",
"ZeroWidthSpace;": "\u200b",
"Zeta;": "\u0396",
"Zfr;": "\u2128",
"Zopf;": "\u2124",
"Zscr;": "\U0001d4b5",
"aacute": "\xe1",
"aacute;": "\xe1",
"abreve;": "\u0103",
"ac;": "\u223e",
"acE;": "\u223e\u0333",
"acd;": "\u223f",
"acirc": "\xe2",
"acirc;": "\xe2",
"acute": "\xb4",
"acute;": "\xb4",
"acy;": "\u0430",
"aelig": "\xe6",
"aelig;": "\xe6",
"af;": "\u2061",
"afr;": "\U0001d51e",
"agrave": "\xe0",
"agrave;": "\xe0",
"alefsym;": "\u2135",
"aleph;": "\u2135",
"alpha;": "\u03b1",
"amacr;": "\u0101",
"amalg;": "\u2a3f",
"amp": "&",
"amp;": "&",
"and;": "\u2227",
"andand;": "\u2a55",
"andd;": "\u2a5c",
"andslope;": "\u2a58",
"andv;": "\u2a5a",
"ang;": "\u2220",
"ange;": "\u29a4",
"angle;": "\u2220",
"angmsd;": "\u2221",
"angmsdaa;": "\u29a8",
"angmsdab;": "\u29a9",
"angmsdac;": "\u29aa",
"angmsdad;": "\u29ab",
"angmsdae;": "\u29ac",
"angmsdaf;": "\u29ad",
"angmsdag;": "\u29ae",
"angmsdah;": "\u29af",
"angrt;": "\u221f",
"angrtvb;": "\u22be",
"angrtvbd;": "\u299d",
"angsph;": "\u2222",
"angst;": "\xc5",
"angzarr;": "\u237c",
"aogon;": "\u0105",
"aopf;": "\U0001d552",
"ap;": "\u2248",
"apE;": "\u2a70",
"apacir;": "\u2a6f",
"ape;": "\u224a",
"apid;": "\u224b",
"apos;": "'",
"approx;": "\u2248",
"approxeq;": "\u224a",
"aring": "\xe5",
"aring;": "\xe5",
"ascr;": "\U0001d4b6",
"ast;": "*",
"asymp;": "\u2248",
"asympeq;": "\u224d",
"atilde": "\xe3",
"atilde;": "\xe3",
"auml": "\xe4",
"auml;": "\xe4",
"awconint;": "\u2233",
"awint;": "\u2a11",
"bNot;": "\u2aed",
"backcong;": "\u224c",
"backepsilon;": "\u03f6",
"backprime;": "\u2035",
"backsim;": "\u223d",
"backsimeq;": "\u22cd",
"barvee;": "\u22bd",
"barwed;": "\u2305",
"barwedge;": "\u2305",
"bbrk;": "\u23b5",
"bbrktbrk;": "\u23b6",
"bcong;": "\u224c",
"bcy;": "\u0431",
"bdquo;": "\u201e",
"becaus;": "\u2235",
"because;": "\u2235",
"bemptyv;": "\u29b0",
"bepsi;": "\u03f6",
"bernou;": "\u212c",
"beta;": "\u03b2",
"beth;": "\u2136",
"between;": "\u226c",
"bfr;": "\U0001d51f",
"bigcap;": "\u22c2",
"bigcirc;": "\u25ef",
"bigcup;": "\u22c3",
"bigodot;": "\u2a00",
"bigoplus;": "\u2a01",
"bigotimes;": "\u2a02",
"bigsqcup;": "\u2a06",
"bigstar;": "\u2605",
"bigtriangledown;": "\u25bd",
"bigtriangleup;": "\u25b3",
"biguplus;": "\u2a04",
"bigvee;": "\u22c1",
"bigwedge;": "\u22c0",
"bkarow;": "\u290d",
"blacklozenge;": "\u29eb",
"blacksquare;": "\u25aa",
"blacktriangle;": "\u25b4",
"blacktriangledown;": "\u25be",
"blacktriangleleft;": "\u25c2",
"blacktriangleright;": "\u25b8",
"blank;": "\u2423",
"blk12;": "\u2592",
"blk14;": "\u2591",
"blk34;": "\u2593",
"block;": "\u2588",
"bne;": "=\u20e5",
"bnequiv;": "\u2261\u20e5",
"bnot;": "\u2310",
"bopf;": "\U0001d553",
"bot;": "\u22a5",
"bottom;": "\u22a5",
"bowtie;": "\u22c8",
"boxDL;": "\u2557",
"boxDR;": "\u2554",
"boxDl;": "\u2556",
"boxDr;": "\u2553",
"boxH;": "\u2550",
"boxHD;": "\u2566",
"boxHU;": "\u2569",
"boxHd;": "\u2564",
"boxHu;": "\u2567",
"boxUL;": "\u255d",
"boxUR;": "\u255a",
"boxUl;": "\u255c",
"boxUr;": "\u2559",
"boxV;": "\u2551",
"boxVH;": "\u256c",
"boxVL;": "\u2563",
"boxVR;": "\u2560",
"boxVh;": "\u256b",
"boxVl;": "\u2562",
"boxVr;": "\u255f",
"boxbox;": "\u29c9",
"boxdL;": "\u2555",
"boxdR;": "\u2552",
"boxdl;": "\u2510",
"boxdr;": "\u250c",
"boxh;": "\u2500",
"boxhD;": "\u2565",
"boxhU;": "\u2568",
"boxhd;": "\u252c",
"boxhu;": "\u2534",
"boxminus;": "\u229f",
"boxplus;": "\u229e",
"boxtimes;": "\u22a0",
"boxuL;": "\u255b",
"boxuR;": "\u2558",
"boxul;": "\u2518",
"boxur;": "\u2514",
"boxv;": "\u2502",
"boxvH;": "\u256a",
"boxvL;": "\u2561",
"boxvR;": "\u255e",
"boxvh;": "\u253c",
"boxvl;": "\u2524",
"boxvr;": "\u251c",
"bprime;": "\u2035",
"breve;": "\u02d8",
"brvbar": "\xa6",
"brvbar;": "\xa6",
"bscr;": "\U0001d4b7",
"bsemi;": "\u204f",
"bsim;": "\u223d",
"bsime;": "\u22cd",
"bsol;": "\\",
"bsolb;": "\u29c5",
"bsolhsub;": "\u27c8",
"bull;": "\u2022",
"bullet;": "\u2022",
"bump;": "\u224e",
"bumpE;": "\u2aae",
"bumpe;": "\u224f",
"bumpeq;": "\u224f",
"cacute;": "\u0107",
"cap;": "\u2229",
"capand;": "\u2a44",
"capbrcup;": "\u2a49",
"capcap;": "\u2a4b",
"capcup;": "\u2a47",
"capdot;": "\u2a40",
"caps;": "\u2229\ufe00",
"caret;": "\u2041",
"caron;": "\u02c7",
"ccaps;": "\u2a4d",
"ccaron;": "\u010d",
"ccedil": "\xe7",
"ccedil;": "\xe7",
"ccirc;": "\u0109",
"ccups;": "\u2a4c",
"ccupssm;": "\u2a50",
"cdot;": "\u010b",
"cedil": "\xb8",
"cedil;": "\xb8",
"cemptyv;": "\u29b2",
"cent": "\xa2",
"cent;": "\xa2",
"centerdot;": "\xb7",
"cfr;": "\U0001d520",
"chcy;": "\u0447",
"check;": "\u2713",
"checkmark;": "\u2713",
"chi;": "\u03c7",
"cir;": "\u25cb",
"cirE;": "\u29c3",
"circ;": "\u02c6",
"circeq;": "\u2257",
"circlearrowleft;": "\u21ba",
"circlearrowright;": "\u21bb",
"circledR;": "\xae",
"circledS;": "\u24c8",
"circledast;": "\u229b",
"circledcirc;": "\u229a",
"circleddash;": "\u229d",
"cire;": "\u2257",
"cirfnint;": "\u2a10",
"cirmid;": "\u2aef",
"cirscir;": "\u29c2",
"clubs;": "\u2663",
"clubsuit;": "\u2663",
"colon;": ":",
"colone;": "\u2254",
"coloneq;": "\u2254",
"comma;": ",",
"commat;": "@",
"comp;": "\u2201",
"compfn;": "\u2218",
"complement;": "\u2201",
"complexes;": "\u2102",
"cong;": "\u2245",
"congdot;": "\u2a6d",
"conint;": "\u222e",
"copf;": "\U0001d554",
"coprod;": "\u2210",
"copy": "\xa9",
"copy;": "\xa9",
"copysr;": "\u2117",
"crarr;": "\u21b5",
"cross;": "\u2717",
"cscr;": "\U0001d4b8",
"csub;": "\u2acf",
"csube;": "\u2ad1",
"csup;": "\u2ad0",
"csupe;": "\u2ad2",
"ctdot;": "\u22ef",
"cudarrl;": "\u2938",
"cudarrr;": "\u2935",
"cuepr;": "\u22de",
"cuesc;": "\u22df",
"cularr;": "\u21b6",
"cularrp;": "\u293d",
"cup;": "\u222a",
"cupbrcap;": "\u2a48",
"cupcap;": "\u2a46",
"cupcup;": "\u2a4a",
"cupdot;": "\u228d",
"cupor;": "\u2a45",
"cups;": "\u222a\ufe00",
"curarr;": "\u21b7",
"curarrm;": "\u293c",
"curlyeqprec;": "\u22de",
"curlyeqsucc;": "\u22df",
"curlyvee;": "\u22ce",
"curlywedge;": "\u22cf",
"curren": "\xa4",
"curren;": "\xa4",
"curvearrowleft;": "\u21b6",
"curvearrowright;": "\u21b7",
"cuvee;": "\u22ce",
"cuwed;": "\u22cf",
"cwconint;": "\u2232",
"cwint;": "\u2231",
"cylcty;": "\u232d",
"dArr;": "\u21d3",
"dHar;": "\u2965",
"dagger;": "\u2020",
"daleth;": "\u2138",
"darr;": "\u2193",
"dash;": "\u2010",
"dashv;": "\u22a3",
"dbkarow;": "\u290f",
"dblac;": "\u02dd",
"dcaron;": "\u010f",
"dcy;": "\u0434",
"dd;": "\u2146",
"ddagger;": "\u2021",
"ddarr;": "\u21ca",
"ddotseq;": "\u2a77",
"deg": "\xb0",
"deg;": "\xb0",
"delta;": "\u03b4",
"demptyv;": "\u29b1",
"dfisht;": "\u297f",
"dfr;": "\U0001d521",
"dharl;": "\u21c3",
"dharr;": "\u21c2",
"diam;": "\u22c4",
"diamond;": "\u22c4",
"diamondsuit;": "\u2666",
"diams;": "\u2666",
"die;": "\xa8",
"digamma;": "\u03dd",
"disin;": "\u22f2",
"div;": "\xf7",
"divide": "\xf7",
"divide;": "\xf7",
"divideontimes;": "\u22c7",
"divonx;": "\u22c7",
"djcy;": "\u0452",
"dlcorn;": "\u231e",
"dlcrop;": "\u230d",
"dollar;": "$",
"dopf;": "\U0001d555",
"dot;": "\u02d9",
"doteq;": "\u2250",
"doteqdot;": "\u2251",
"dotminus;": "\u2238",
"dotplus;": "\u2214",
"dotsquare;": "\u22a1",
"doublebarwedge;": "\u2306",
"downarrow;": "\u2193",
"downdownarrows;": "\u21ca",
"downharpoonleft;": "\u21c3",
"downharpoonright;": "\u21c2",
"drbkarow;": "\u2910",
"drcorn;": "\u231f",
"drcrop;": "\u230c",
"dscr;": "\U0001d4b9",
"dscy;": "\u0455",
"dsol;": "\u29f6",
"dstrok;": "\u0111",
"dtdot;": "\u22f1",
"dtri;": "\u25bf",
"dtrif;": "\u25be",
"duarr;": "\u21f5",
"duhar;": "\u296f",
"dwangle;": "\u29a6",
"dzcy;": "\u045f",
"dzigrarr;": "\u27ff",
"eDDot;": "\u2a77",
"eDot;": "\u2251",
"eacute": "\xe9",
"eacute;": "\xe9",
"easter;": "\u2a6e",
"ecaron;": "\u011b",
"ecir;": "\u2256",
"ecirc": "\xea",
"ecirc;": "\xea",
"ecolon;": "\u2255",
"ecy;": "\u044d",
"edot;": "\u0117",
"ee;": "\u2147",
"efDot;": "\u2252",
"efr;": "\U0001d522",
"eg;": "\u2a9a",
"egrave": "\xe8",
"egrave;": "\xe8",
"egs;": "\u2a96",
"egsdot;": "\u2a98",
"el;": "\u2a99",
"elinters;": "\u23e7",
"ell;": "\u2113",
"els;": "\u2a95",
"elsdot;": "\u2a97",
"emacr;": "\u0113",
"empty;": "\u2205",
"emptyset;": "\u2205",
"emptyv;": "\u2205",
"emsp13;": "\u2004",
"emsp14;": "\u2005",
"emsp;": "\u2003",
"eng;": "\u014b",
"ensp;": "\u2002",
"eogon;": "\u0119",
"eopf;": "\U0001d556",
"epar;": "\u22d5",
"eparsl;": "\u29e3",
"eplus;": "\u2a71",
"epsi;": "\u03b5",
"epsilon;": "\u03b5",
"epsiv;": "\u03f5",
"eqcirc;": "\u2256",
"eqcolon;": "\u2255",
"eqsim;": "\u2242",
"eqslantgtr;": "\u2a96",
"eqslantless;": "\u2a95",
"equals;": "=",
"equest;": "\u225f",
"equiv;": "\u2261",
"equivDD;": "\u2a78",
"eqvparsl;": "\u29e5",
"erDot;": "\u2253",
"erarr;": "\u2971",
"escr;": "\u212f",
"esdot;": "\u2250",
"esim;": "\u2242",
"eta;": "\u03b7",
"eth": "\xf0",
"eth;": "\xf0",
"euml": "\xeb",
"euml;": "\xeb",
"euro;": "\u20ac",
"excl;": "!",
"exist;": "\u2203",
"expectation;": "\u2130",
"exponentiale;": "\u2147",
"fallingdotseq;": "\u2252",
"fcy;": "\u0444",
"female;": "\u2640",
"ffilig;": "\ufb03",
"fflig;": "\ufb00",
"ffllig;": "\ufb04",
"ffr;": "\U0001d523",
"filig;": "\ufb01",
"fjlig;": "fj",
"flat;": "\u266d",
"fllig;": "\ufb02",
"fltns;": "\u25b1",
"fnof;": "\u0192",
"fopf;": "\U0001d557",
"forall;": "\u2200",
"fork;": "\u22d4",
"forkv;": "\u2ad9",
"fpartint;": "\u2a0d",
"frac12": "\xbd",
"frac12;": "\xbd",
"frac13;": "\u2153",
"frac14": "\xbc",
"frac14;": "\xbc",
"frac15;": "\u2155",
"frac16;": "\u2159",
"frac18;": "\u215b",
"frac23;": "\u2154",
"frac25;": "\u2156",
"frac34": "\xbe",
"frac34;": "\xbe",
"frac35;": "\u2157",
"frac38;": "\u215c",
"frac45;": "\u2158",
"frac56;": "\u215a",
"frac58;": "\u215d",
"frac78;": "\u215e",
"frasl;": "\u2044",
"frown;": "\u2322",
"fscr;": "\U0001d4bb",
"gE;": "\u2267",
"gEl;": "\u2a8c",
"gacute;": "\u01f5",
"gamma;": "\u03b3",
"gammad;": "\u03dd",
"gap;": "\u2a86",
"gbreve;": "\u011f",
"gcirc;": "\u011d",
"gcy;": "\u0433",
"gdot;": "\u0121",
"ge;": "\u2265",
"gel;": "\u22db",
"geq;": "\u2265",
"geqq;": "\u2267",
"geqslant;": "\u2a7e",
"ges;": "\u2a7e",
"gescc;": "\u2aa9",
"gesdot;": "\u2a80",
"gesdoto;": "\u2a82",
"gesdotol;": "\u2a84",
"gesl;": "\u22db\ufe00",
"gesles;": "\u2a94",
"gfr;": "\U0001d524",
"gg;": "\u226b",
"ggg;": "\u22d9",
"gimel;": "\u2137",
"gjcy;": "\u0453",
"gl;": "\u2277",
"glE;": "\u2a92",
"gla;": "\u2aa5",
"glj;": "\u2aa4",
"gnE;": "\u2269",
"gnap;": "\u2a8a",
"gnapprox;": "\u2a8a",
"gne;": "\u2a88",
"gneq;": "\u2a88",
"gneqq;": "\u2269",
"gnsim;": "\u22e7",
"gopf;": "\U0001d558",
"grave;": "`",
"gscr;": "\u210a",
"gsim;": "\u2273",
"gsime;": "\u2a8e",
"gsiml;": "\u2a90",
"gt": ">",
"gt;": ">",
"gtcc;": "\u2aa7",
"gtcir;": "\u2a7a",
"gtdot;": "\u22d7",
"gtlPar;": "\u2995",
"gtquest;": "\u2a7c",
"gtrapprox;": "\u2a86",
"gtrarr;": "\u2978",
"gtrdot;": "\u22d7",
"gtreqless;": "\u22db",
"gtreqqless;": "\u2a8c",
"gtrless;": "\u2277",
"gtrsim;": "\u2273",
"gvertneqq;": "\u2269\ufe00",
"gvnE;": "\u2269\ufe00",
"hArr;": "\u21d4",
"hairsp;": "\u200a",
"half;": "\xbd",
"hamilt;": "\u210b",
"hardcy;": "\u044a",
"harr;": "\u2194",
"harrcir;": "\u2948",
"harrw;": "\u21ad",
"hbar;": "\u210f",
"hcirc;": "\u0125",
"hearts;": "\u2665",
"heartsuit;": "\u2665",
"hellip;": "\u2026",
"hercon;": "\u22b9",
"hfr;": "\U0001d525",
"hksearow;": "\u2925",
"hkswarow;": "\u2926",
"hoarr;": "\u21ff",
"homtht;": "\u223b",
"hookleftarrow;": "\u21a9",
"hookrightarrow;": "\u21aa",
"hopf;": "\U0001d559",
"horbar;": "\u2015",
"hscr;": "\U0001d4bd",
"hslash;": "\u210f",
"hstrok;": "\u0127",
"hybull;": "\u2043",
"hyphen;": "\u2010",
"iacute": "\xed",
"iacute;": "\xed",
"ic;": "\u2063",
"icirc": "\xee",
"icirc;": "\xee",
"icy;": "\u0438",
"iecy;": "\u0435",
"iexcl": "\xa1",
"iexcl;": "\xa1",
"iff;": "\u21d4",
"ifr;": "\U0001d526",
"igrave": "\xec",
"igrave;": "\xec",
"ii;": "\u2148",
"iiiint;": "\u2a0c",
"iiint;": "\u222d",
"iinfin;": "\u29dc",
"iiota;": "\u2129",
"ijlig;": "\u0133",
"imacr;": "\u012b",
"image;": "\u2111",
"imagline;": "\u2110",
"imagpart;": "\u2111",
"imath;": "\u0131",
"imof;": "\u22b7",
"imped;": "\u01b5",
"in;": "\u2208",
"incare;": "\u2105",
"infin;": "\u221e",
"infintie;": "\u29dd",
"inodot;": "\u0131",
"int;": "\u222b",
"intcal;": "\u22ba",
"integers;": "\u2124",
"intercal;": "\u22ba",
"intlarhk;": "\u2a17",
"intprod;": "\u2a3c",
"iocy;": "\u0451",
"iogon;": "\u012f",
"iopf;": "\U0001d55a",
"iota;": "\u03b9",
"iprod;": "\u2a3c",
"iquest": "\xbf",
"iquest;": "\xbf",
"iscr;": "\U0001d4be",
"isin;": "\u2208",
"isinE;": "\u22f9",
"isindot;": "\u22f5",
"isins;": "\u22f4",
"isinsv;": "\u22f3",
"isinv;": "\u2208",
"it;": "\u2062",
"itilde;": "\u0129",
"iukcy;": "\u0456",
"iuml": "\xef",
"iuml;": "\xef",
"jcirc;": "\u0135",
"jcy;": "\u0439",
"jfr;": "\U0001d527",
"jmath;": "\u0237",
"jopf;": "\U0001d55b",
"jscr;": "\U0001d4bf",
"jsercy;": "\u0458",
"jukcy;": "\u0454",
"kappa;": "\u03ba",
"kappav;": "\u03f0",
"kcedil;": "\u0137",
"kcy;": "\u043a",
"kfr;": "\U0001d528",
"kgreen;": "\u0138",
"khcy;": "\u0445",
"kjcy;": "\u045c",
"kopf;": "\U0001d55c",
"kscr;": "\U0001d4c0",
"lAarr;": "\u21da",
"lArr;": "\u21d0",
"lAtail;": "\u291b",
"lBarr;": "\u290e",
"lE;": "\u2266",
"lEg;": "\u2a8b",
"lHar;": "\u2962",
"lacute;": "\u013a",
"laemptyv;": "\u29b4",
"lagran;": "\u2112",
"lambda;": "\u03bb",
"lang;": "\u27e8",
"langd;": "\u2991",
"langle;": "\u27e8",
"lap;": "\u2a85",
"laquo": "\xab",
"laquo;": "\xab",
"larr;": "\u2190",
"larrb;": "\u21e4",
"larrbfs;": "\u291f",
"larrfs;": "\u291d",
"larrhk;": "\u21a9",
"larrlp;": "\u21ab",
"larrpl;": "\u2939",
"larrsim;": "\u2973",
"larrtl;": "\u21a2",
"lat;": "\u2aab",
"latail;": "\u2919",
"late;": "\u2aad",
"lates;": "\u2aad\ufe00",
"lbarr;": "\u290c",
"lbbrk;": "\u2772",
"lbrace;": "{",
"lbrack;": "[",
"lbrke;": "\u298b",
"lbrksld;": "\u298f",
"lbrkslu;": "\u298d",
"lcaron;": "\u013e",
"lcedil;": "\u013c",
"lceil;": "\u2308",
"lcub;": "{",
"lcy;": "\u043b",
"ldca;": "\u2936",
"ldquo;": "\u201c",
"ldquor;": "\u201e",
"ldrdhar;": "\u2967",
"ldrushar;": "\u294b",
"ldsh;": "\u21b2",
"le;": "\u2264",
"leftarrow;": "\u2190",
"leftarrowtail;": "\u21a2",
"leftharpoondown;": "\u21bd",
"leftharpoonup;": "\u21bc",
"leftleftarrows;": "\u21c7",
"leftrightarrow;": "\u2194",
"leftrightarrows;": "\u21c6",
"leftrightharpoons;": "\u21cb",
"leftrightsquigarrow;": "\u21ad",
"leftthreetimes;": "\u22cb",
"leg;": "\u22da",
"leq;": "\u2264",
"leqq;": "\u2266",
"leqslant;": "\u2a7d",
"les;": "\u2a7d",
"lescc;": "\u2aa8",
"lesdot;": "\u2a7f",
"lesdoto;": "\u2a81",
"lesdotor;": "\u2a83",
"lesg;": "\u22da\ufe00",
"lesges;": "\u2a93",
"lessapprox;": "\u2a85",
"lessdot;": "\u22d6",
"lesseqgtr;": "\u22da",
"lesseqqgtr;": "\u2a8b",
"lessgtr;": "\u2276",
"lesssim;": "\u2272",
"lfisht;": "\u297c",
"lfloor;": "\u230a",
"lfr;": "\U0001d529",
"lg;": "\u2276",
"lgE;": "\u2a91",
"lhard;": "\u21bd",
"lharu;": "\u21bc",
"lharul;": "\u296a",
"lhblk;": "\u2584",
"ljcy;": "\u0459",
"ll;": "\u226a",
"llarr;": "\u21c7",
"llcorner;": "\u231e",
"llhard;": "\u296b",
"lltri;": "\u25fa",
"lmidot;": "\u0140",
"lmoust;": "\u23b0",
"lmoustache;": "\u23b0",
"lnE;": "\u2268",
"lnap;": "\u2a89",
"lnapprox;": "\u2a89",
"lne;": "\u2a87",
"lneq;": "\u2a87",
"lneqq;": "\u2268",
"lnsim;": "\u22e6",
"loang;": "\u27ec",
"loarr;": "\u21fd",
"lobrk;": "\u27e6",
"longleftarrow;": "\u27f5",
"longleftrightarrow;": "\u27f7",
"longmapsto;": "\u27fc",
"longrightarrow;": "\u27f6",
"looparrowleft;": "\u21ab",
"looparrowright;": "\u21ac",
"lopar;": "\u2985",
"lopf;": "\U0001d55d",
"loplus;": "\u2a2d",
"lotimes;": "\u2a34",
"lowast;": "\u2217",
"lowbar;": "_",
"loz;": "\u25ca",
"lozenge;": "\u25ca",
"lozf;": "\u29eb",
"lpar;": "(",
"lparlt;": "\u2993",
"lrarr;": "\u21c6",
"lrcorner;": "\u231f",
"lrhar;": "\u21cb",
"lrhard;": "\u296d",
"lrm;": "\u200e",
"lrtri;": "\u22bf",
"lsaquo;": "\u2039",
"lscr;": "\U0001d4c1",
"lsh;": "\u21b0",
"lsim;": "\u2272",
"lsime;": "\u2a8d",
"lsimg;": "\u2a8f",
"lsqb;": "[",
"lsquo;": "\u2018",
"lsquor;": "\u201a",
"lstrok;": "\u0142",
"lt": "<",
"lt;": "<",
"ltcc;": "\u2aa6",
"ltcir;": "\u2a79",
"ltdot;": "\u22d6",
"lthree;": "\u22cb",
"ltimes;": "\u22c9",
"ltlarr;": "\u2976",
"ltquest;": "\u2a7b",
"ltrPar;": "\u2996",
"ltri;": "\u25c3",
"ltrie;": "\u22b4",
"ltrif;": "\u25c2",
"lurdshar;": "\u294a",
"luruhar;": "\u2966",
"lvertneqq;": "\u2268\ufe00",
"lvnE;": "\u2268\ufe00",
"mDDot;": "\u223a",
"macr": "\xaf",
"macr;": "\xaf",
"male;": "\u2642",
"malt;": "\u2720",
"maltese;": "\u2720",
"map;": "\u21a6",
"mapsto;": "\u21a6",
"mapstodown;": "\u21a7",
"mapstoleft;": "\u21a4",
"mapstoup;": "\u21a5",
"marker;": "\u25ae",
"mcomma;": "\u2a29",
"mcy;": "\u043c",
"mdash;": "\u2014",
"measuredangle;": "\u2221",
"mfr;": "\U0001d52a",
"mho;": "\u2127",
"micro": "\xb5",
"micro;": "\xb5",
"mid;": "\u2223",
"midast;": "*",
"midcir;": "\u2af0",
"middot": "\xb7",
"middot;": "\xb7",
"minus;": "\u2212",
"minusb;": "\u229f",
"minusd;": "\u2238",
"minusdu;": "\u2a2a",
"mlcp;": "\u2adb",
"mldr;": "\u2026",
"mnplus;": "\u2213",
"models;": "\u22a7",
"mopf;": "\U0001d55e",
"mp;": "\u2213",
"mscr;": "\U0001d4c2",
"mstpos;": "\u223e",
"mu;": "\u03bc",
"multimap;": "\u22b8",
"mumap;": "\u22b8",
"nGg;": "\u22d9\u0338",
"nGt;": "\u226b\u20d2",
"nGtv;": "\u226b\u0338",
"nLeftarrow;": "\u21cd",
"nLeftrightarrow;": "\u21ce",
"nLl;": "\u22d8\u0338",
"nLt;": "\u226a\u20d2",
"nLtv;": "\u226a\u0338",
"nRightarrow;": "\u21cf",
"nVDash;": "\u22af",
"nVdash;": "\u22ae",
"nabla;": "\u2207",
"nacute;": "\u0144",
"nang;": "\u2220\u20d2",
"nap;": "\u2249",
"napE;": "\u2a70\u0338",
"napid;": "\u224b\u0338",
"napos;": "\u0149",
"napprox;": "\u2249",
"natur;": "\u266e",
"natural;": "\u266e",
"naturals;": "\u2115",
"nbsp": "\xa0",
"nbsp;": "\xa0",
"nbump;": "\u224e\u0338",
"nbumpe;": "\u224f\u0338",
"ncap;": "\u2a43",
"ncaron;": "\u0148",
"ncedil;": "\u0146",
"ncong;": "\u2247",
"ncongdot;": "\u2a6d\u0338",
"ncup;": "\u2a42",
"ncy;": "\u043d",
"ndash;": "\u2013",
"ne;": "\u2260",
"neArr;": "\u21d7",
"nearhk;": "\u2924",
"nearr;": "\u2197",
"nearrow;": "\u2197",
"nedot;": "\u2250\u0338",
"nequiv;": "\u2262",
"nesear;": "\u2928",
"nesim;": "\u2242\u0338",
"nexist;": "\u2204",
"nexists;": "\u2204",
"nfr;": "\U0001d52b",
"ngE;": "\u2267\u0338",
"nge;": "\u2271",
"ngeq;": "\u2271",
"ngeqq;": "\u2267\u0338",
"ngeqslant;": "\u2a7e\u0338",
"nges;": "\u2a7e\u0338",
"ngsim;": "\u2275",
"ngt;": "\u226f",
"ngtr;": "\u226f",
"nhArr;": "\u21ce",
"nharr;": "\u21ae",
"nhpar;": "\u2af2",
"ni;": "\u220b",
"nis;": "\u22fc",
"nisd;": "\u22fa",
"niv;": "\u220b",
"njcy;": "\u045a",
"nlArr;": "\u21cd",
"nlE;": "\u2266\u0338",
"nlarr;": "\u219a",
"nldr;": "\u2025",
"nle;": "\u2270",
"nleftarrow;": "\u219a",
"nleftrightarrow;": "\u21ae",
"nleq;": "\u2270",
"nleqq;": "\u2266\u0338",
"nleqslant;": "\u2a7d\u0338",
"nles;": "\u2a7d\u0338",
"nless;": "\u226e",
"nlsim;": "\u2274",
"nlt;": "\u226e",
"nltri;": "\u22ea",
"nltrie;": "\u22ec",
"nmid;": "\u2224",
"nopf;": "\U0001d55f",
"not": "\xac",
"not;": "\xac",
"notin;": "\u2209",
"notinE;": "\u22f9\u0338",
"notindot;": "\u22f5\u0338",
"notinva;": "\u2209",
"notinvb;": "\u22f7",
"notinvc;": "\u22f6",
"notni;": "\u220c",
"notniva;": "\u220c",
"notnivb;": "\u22fe",
"notnivc;": "\u22fd",
"npar;": "\u2226",
"nparallel;": "\u2226",
"nparsl;": "\u2afd\u20e5",
"npart;": "\u2202\u0338",
"npolint;": "\u2a14",
"npr;": "\u2280",
"nprcue;": "\u22e0",
"npre;": "\u2aaf\u0338",
"nprec;": "\u2280",
"npreceq;": "\u2aaf\u0338",
"nrArr;": "\u21cf",
"nrarr;": "\u219b",
"nrarrc;": "\u2933\u0338",
"nrarrw;": "\u219d\u0338",
"nrightarrow;": "\u219b",
"nrtri;": "\u22eb",
"nrtrie;": "\u22ed",
"nsc;": "\u2281",
"nsccue;": "\u22e1",
"nsce;": "\u2ab0\u0338",
"nscr;": "\U0001d4c3",
"nshortmid;": "\u2224",
"nshortparallel;": "\u2226",
"nsim;": "\u2241",
"nsime;": "\u2244",
"nsimeq;": "\u2244",
"nsmid;": "\u2224",
"nspar;": "\u2226",
"nsqsube;": "\u22e2",
"nsqsupe;": "\u22e3",
"nsub;": "\u2284",
"nsubE;": "\u2ac5\u0338",
"nsube;": "\u2288",
"nsubset;": "\u2282\u20d2",
"nsubseteq;": "\u2288",
"nsubseteqq;": "\u2ac5\u0338",
"nsucc;": "\u2281",
"nsucceq;": "\u2ab0\u0338",
"nsup;": "\u2285",
"nsupE;": "\u2ac6\u0338",
"nsupe;": "\u2289",
"nsupset;": "\u2283\u20d2",
"nsupseteq;": "\u2289",
"nsupseteqq;": "\u2ac6\u0338",
"ntgl;": "\u2279",
"ntilde": "\xf1",
"ntilde;": "\xf1",
"ntlg;": "\u2278",
"ntriangleleft;": "\u22ea",
"ntrianglelefteq;": "\u22ec",
"ntriangleright;": "\u22eb",
"ntrianglerighteq;": "\u22ed",
"nu;": "\u03bd",
"num;": "#",
"numero;": "\u2116",
"numsp;": "\u2007",
"nvDash;": "\u22ad",
"nvHarr;": "\u2904",
"nvap;": "\u224d\u20d2",
"nvdash;": "\u22ac",
"nvge;": "\u2265\u20d2",
"nvgt;": ">\u20d2",
"nvinfin;": "\u29de",
"nvlArr;": "\u2902",
"nvle;": "\u2264\u20d2",
"nvlt;": "<\u20d2",
"nvltrie;": "\u22b4\u20d2",
"nvrArr;": "\u2903",
"nvrtrie;": "\u22b5\u20d2",
"nvsim;": "\u223c\u20d2",
"nwArr;": "\u21d6",
"nwarhk;": "\u2923",
"nwarr;": "\u2196",
"nwarrow;": "\u2196",
"nwnear;": "\u2927",
"oS;": "\u24c8",
"oacute": "\xf3",
"oacute;": "\xf3",
"oast;": "\u229b",
"ocir;": "\u229a",
"ocirc": "\xf4",
"ocirc;": "\xf4",
"ocy;": "\u043e",
"odash;": "\u229d",
"odblac;": "\u0151",
"odiv;": "\u2a38",
"odot;": "\u2299",
"odsold;": "\u29bc",
"oelig;": "\u0153",
"ofcir;": "\u29bf",
"ofr;": "\U0001d52c",
"ogon;": "\u02db",
"ograve": "\xf2",
"ograve;": "\xf2",
"ogt;": "\u29c1",
"ohbar;": "\u29b5",
"ohm;": "\u03a9",
"oint;": "\u222e",
"olarr;": "\u21ba",
"olcir;": "\u29be",
"olcross;": "\u29bb",
"oline;": "\u203e",
"olt;": "\u29c0",
"omacr;": "\u014d",
"omega;": "\u03c9",
"omicron;": "\u03bf",
"omid;": "\u29b6",
"ominus;": "\u2296",
"oopf;": "\U0001d560",
"opar;": "\u29b7",
"operp;": "\u29b9",
"oplus;": "\u2295",
"or;": "\u2228",
"orarr;": "\u21bb",
"ord;": "\u2a5d",
"order;": "\u2134",
"orderof;": "\u2134",
"ordf": "\xaa",
"ordf;": "\xaa",
"ordm": "\xba",
"ordm;": "\xba",
"origof;": "\u22b6",
"oror;": "\u2a56",
"orslope;": "\u2a57",
"orv;": "\u2a5b",
"oscr;": "\u2134",
"oslash": "\xf8",
"oslash;": "\xf8",
"osol;": "\u2298",
"otilde": "\xf5",
"otilde;": "\xf5",
"otimes;": "\u2297",
"otimesas;": "\u2a36",
"ouml": "\xf6",
"ouml;": "\xf6",
"ovbar;": "\u233d",
"par;": "\u2225",
"para": "\xb6",
"para;": "\xb6",
"parallel;": "\u2225",
"parsim;": "\u2af3",
"parsl;": "\u2afd",
"part;": "\u2202",
"pcy;": "\u043f",
"percnt;": "%",
"period;": ".",
"permil;": "\u2030",
"perp;": "\u22a5",
"pertenk;": "\u2031",
"pfr;": "\U0001d52d",
"phi;": "\u03c6",
"phiv;": "\u03d5",
"phmmat;": "\u2133",
"phone;": "\u260e",
"pi;": "\u03c0",
"pitchfork;": "\u22d4",
"piv;": "\u03d6",
"planck;": "\u210f",
"planckh;": "\u210e",
"plankv;": "\u210f",
"plus;": "+",
"plusacir;": "\u2a23",
"plusb;": "\u229e",
"pluscir;": "\u2a22",
"plusdo;": "\u2214",
"plusdu;": "\u2a25",
"pluse;": "\u2a72",
"plusmn": "\xb1",
"plusmn;": "\xb1",
"plussim;": "\u2a26",
"plustwo;": "\u2a27",
"pm;": "\xb1",
"pointint;": "\u2a15",
"popf;": "\U0001d561",
"pound": "\xa3",
"pound;": "\xa3",
"pr;": "\u227a",
"prE;": "\u2ab3",
"prap;": "\u2ab7",
"prcue;": "\u227c",
"pre;": "\u2aaf",
"prec;": "\u227a",
"precapprox;": "\u2ab7",
"preccurlyeq;": "\u227c",
"preceq;": "\u2aaf",
"precnapprox;": "\u2ab9",
"precneqq;": "\u2ab5",
"precnsim;": "\u22e8",
"precsim;": "\u227e",
"prime;": "\u2032",
"primes;": "\u2119",
"prnE;": "\u2ab5",
"prnap;": "\u2ab9",
"prnsim;": "\u22e8",
"prod;": "\u220f",
"profalar;": "\u232e",
"profline;": "\u2312",
"profsurf;": "\u2313",
"prop;": "\u221d",
"propto;": "\u221d",
"prsim;": "\u227e",
"prurel;": "\u22b0",
"pscr;": "\U0001d4c5",
"psi;": "\u03c8",
"puncsp;": "\u2008",
"qfr;": "\U0001d52e",
"qint;": "\u2a0c",
"qopf;": "\U0001d562",
"qprime;": "\u2057",
"qscr;": "\U0001d4c6",
"quaternions;": "\u210d",
"quatint;": "\u2a16",
"quest;": "?",
"questeq;": "\u225f",
"quot": "\"",
"quot;": "\"",
"rAarr;": "\u21db",
"rArr;": "\u21d2",
"rAtail;": "\u291c",
"rBarr;": "\u290f",
"rHar;": "\u2964",
"race;": "\u223d\u0331",
"racute;": "\u0155",
"radic;": "\u221a",
"raemptyv;": "\u29b3",
"rang;": "\u27e9",
"rangd;": "\u2992",
"range;": "\u29a5",
"rangle;": "\u27e9",
"raquo": "\xbb",
"raquo;": "\xbb",
"rarr;": "\u2192",
"rarrap;": "\u2975",
"rarrb;": "\u21e5",
"rarrbfs;": "\u2920",
"rarrc;": "\u2933",
"rarrfs;": "\u291e",
"rarrhk;": "\u21aa",
"rarrlp;": "\u21ac",
"rarrpl;": "\u2945",
"rarrsim;": "\u2974",
"rarrtl;": "\u21a3",
"rarrw;": "\u219d",
"ratail;": "\u291a",
"ratio;": "\u2236",
"rationals;": "\u211a",
"rbarr;": "\u290d",
"rbbrk;": "\u2773",
"rbrace;": "}",
"rbrack;": "]",
"rbrke;": "\u298c",
"rbrksld;": "\u298e",
"rbrkslu;": "\u2990",
"rcaron;": "\u0159",
"rcedil;": "\u0157",
"rceil;": "\u2309",
"rcub;": "}",
"rcy;": "\u0440",
"rdca;": "\u2937",
"rdldhar;": "\u2969",
"rdquo;": "\u201d",
"rdquor;": "\u201d",
"rdsh;": "\u21b3",
"real;": "\u211c",
"realine;": "\u211b",
"realpart;": "\u211c",
"reals;": "\u211d",
"rect;": "\u25ad",
"reg": "\xae",
"reg;": "\xae",
"rfisht;": "\u297d",
"rfloor;": "\u230b",
"rfr;": "\U0001d52f",
"rhard;": "\u21c1",
"rharu;": "\u21c0",
"rharul;": "\u296c",
"rho;": "\u03c1",
"rhov;": "\u03f1",
"rightarrow;": "\u2192",
"rightarrowtail;": "\u21a3",
"rightharpoondown;": "\u21c1",
"rightharpoonup;": "\u21c0",
"rightleftarrows;": "\u21c4",
"rightleftharpoons;": "\u21cc",
"rightrightarrows;": "\u21c9",
"rightsquigarrow;": "\u219d",
"rightthreetimes;": "\u22cc",
"ring;": "\u02da",
"risingdotseq;": "\u2253",
"rlarr;": "\u21c4",
"rlhar;": "\u21cc",
"rlm;": "\u200f",
"rmoust;": "\u23b1",
"rmoustache;": "\u23b1",
"rnmid;": "\u2aee",
"roang;": "\u27ed",
"roarr;": "\u21fe",
"robrk;": "\u27e7",
"ropar;": "\u2986",
"ropf;": "\U0001d563",
"roplus;": "\u2a2e",
"rotimes;": "\u2a35",
"rpar;": ")",
"rpargt;": "\u2994",
"rppolint;": "\u2a12",
"rrarr;": "\u21c9",
"rsaquo;": "\u203a",
"rscr;": "\U0001d4c7",
"rsh;": "\u21b1",
"rsqb;": "]",
"rsquo;": "\u2019",
"rsquor;": "\u2019",
"rthree;": "\u22cc",
"rtimes;": "\u22ca",
"rtri;": "\u25b9",
"rtrie;": "\u22b5",
"rtrif;": "\u25b8",
"rtriltri;": "\u29ce",
"ruluhar;": "\u2968",
"rx;": "\u211e",
"sacute;": "\u015b",
"sbquo;": "\u201a",
"sc;": "\u227b",
"scE;": "\u2ab4",
"scap;": "\u2ab8",
"scaron;": "\u0161",
"sccue;": "\u227d",
"sce;": "\u2ab0",
"scedil;": "\u015f",
"scirc;": "\u015d",
"scnE;": "\u2ab6",
"scnap;": "\u2aba",
"scnsim;": "\u22e9",
"scpolint;": "\u2a13",
"scsim;": "\u227f",
"scy;": "\u0441",
"sdot;": "\u22c5",
"sdotb;": "\u22a1",
"sdote;": "\u2a66",
"seArr;": "\u21d8",
"searhk;": "\u2925",
"searr;": "\u2198",
"searrow;": "\u2198",
"sect": "\xa7",
"sect;": "\xa7",
"semi;": ";",
"seswar;": "\u2929",
"setminus;": "\u2216",
"setmn;": "\u2216",
"sext;": "\u2736",
"sfr;": "\U0001d530",
"sfrown;": "\u2322",
"sharp;": "\u266f",
"shchcy;": "\u0449",
"shcy;": "\u0448",
"shortmid;": "\u2223",
"shortparallel;": "\u2225",
"shy": "\xad",
"shy;": "\xad",
"sigma;": "\u03c3",
"sigmaf;": "\u03c2",
"sigmav;": "\u03c2",
"sim;": "\u223c",
"simdot;": "\u2a6a",
"sime;": "\u2243",
"simeq;": "\u2243",
"simg;": "\u2a9e",
"simgE;": "\u2aa0",
"siml;": "\u2a9d",
"simlE;": "\u2a9f",
"simne;": "\u2246",
"simplus;": "\u2a24",
"simrarr;": "\u2972",
"slarr;": "\u2190",
"smallsetminus;": "\u2216",
"smashp;": "\u2a33",
"smeparsl;": "\u29e4",
"smid;": "\u2223",
"smile;": "\u2323",
"smt;": "\u2aaa",
"smte;": "\u2aac",
"smtes;": "\u2aac\ufe00",
"softcy;": "\u044c",
"sol;": "/",
"solb;": "\u29c4",
"solbar;": "\u233f",
"sopf;": "\U0001d564",
"spades;": "\u2660",
"spadesuit;": "\u2660",
"spar;": "\u2225",
"sqcap;": "\u2293",
"sqcaps;": "\u2293\ufe00",
"sqcup;": "\u2294",
"sqcups;": "\u2294\ufe00",
"sqsub;": "\u228f",
"sqsube;": "\u2291",
"sqsubset;": "\u228f",
"sqsubseteq;": "\u2291",
"sqsup;": "\u2290",
"sqsupe;": "\u2292",
"sqsupset;": "\u2290",
"sqsupseteq;": "\u2292",
"squ;": "\u25a1",
"square;": "\u25a1",
"squarf;": "\u25aa",
"squf;": "\u25aa",
"srarr;": "\u2192",
"sscr;": "\U0001d4c8",
"ssetmn;": "\u2216",
"ssmile;": "\u2323",
"sstarf;": "\u22c6",
"star;": "\u2606",
"starf;": "\u2605",
"straightepsilon;": "\u03f5",
"straightphi;": "\u03d5",
"strns;": "\xaf",
"sub;": "\u2282",
"subE;": "\u2ac5",
"subdot;": "\u2abd",
"sube;": "\u2286",
"subedot;": "\u2ac3",
"submult;": "\u2ac1",
"subnE;": "\u2acb",
"subne;": "\u228a",
"subplus;": "\u2abf",
"subrarr;": "\u2979",
"subset;": "\u2282",
"subseteq;": "\u2286",
"subseteqq;": "\u2ac5",
"subsetneq;": "\u228a",
"subsetneqq;": "\u2acb",
"subsim;": "\u2ac7",
"subsub;": "\u2ad5",
"subsup;": "\u2ad3",
"succ;": "\u227b",
"succapprox;": "\u2ab8",
"succcurlyeq;": "\u227d",
"succeq;": "\u2ab0",
"succnapprox;": "\u2aba",
"succneqq;": "\u2ab6",
"succnsim;": "\u22e9",
"succsim;": "\u227f",
"sum;": "\u2211",
"sung;": "\u266a",
"sup1": "\xb9",
"sup1;": "\xb9",
"sup2": "\xb2",
"sup2;": "\xb2",
"sup3": "\xb3",
"sup3;": "\xb3",
"sup;": "\u2283",
"supE;": "\u2ac6",
"supdot;": "\u2abe",
"supdsub;": "\u2ad8",
"supe;": "\u2287",
"supedot;": "\u2ac4",
"suphsol;": "\u27c9",
"suphsub;": "\u2ad7",
"suplarr;": "\u297b",
"supmult;": "\u2ac2",
"supnE;": "\u2acc",
"supne;": "\u228b",
"supplus;": "\u2ac0",
"supset;": "\u2283",
"supseteq;": "\u2287",
"supseteqq;": "\u2ac6",
"supsetneq;": "\u228b",
"supsetneqq;": "\u2acc",
"supsim;": "\u2ac8",
"supsub;": "\u2ad4",
"supsup;": "\u2ad6",
"swArr;": "\u21d9",
"swarhk;": "\u2926",
"swarr;": "\u2199",
"swarrow;": "\u2199",
"swnwar;": "\u292a",
"szlig": "\xdf",
"szlig;": "\xdf",
"target;": "\u2316",
"tau;": "\u03c4",
"tbrk;": "\u23b4",
"tcaron;": "\u0165",
"tcedil;": "\u0163",
"tcy;": "\u0442",
"tdot;": "\u20db",
"telrec;": "\u2315",
"tfr;": "\U0001d531",
"there4;": "\u2234",
"therefore;": "\u2234",
"theta;": "\u03b8",
"thetasym;": "\u03d1",
"thetav;": "\u03d1",
"thickapprox;": "\u2248",
"thicksim;": "\u223c",
"thinsp;": "\u2009",
"thkap;": "\u2248",
"thksim;": "\u223c",
"thorn": "\xfe",
"thorn;": "\xfe",
"tilde;": "\u02dc",
"times": "\xd7",
"times;": "\xd7",
"timesb;": "\u22a0",
"timesbar;": "\u2a31",
"timesd;": "\u2a30",
"tint;": "\u222d",
"toea;": "\u2928",
"top;": "\u22a4",
"topbot;": "\u2336",
"topcir;": "\u2af1",
"topf;": "\U0001d565",
"topfork;": "\u2ada",
"tosa;": "\u2929",
"tprime;": "\u2034",
"trade;": "\u2122",
"triangle;": "\u25b5",
"triangledown;": "\u25bf",
"triangleleft;": "\u25c3",
"trianglelefteq;": "\u22b4",
"triangleq;": "\u225c",
"triangleright;": "\u25b9",
"trianglerighteq;": "\u22b5",
"tridot;": "\u25ec",
"trie;": "\u225c",
"triminus;": "\u2a3a",
"triplus;": "\u2a39",
"trisb;": "\u29cd",
"tritime;": "\u2a3b",
"trpezium;": "\u23e2",
"tscr;": "\U0001d4c9",
"tscy;": "\u0446",
"tshcy;": "\u045b",
"tstrok;": "\u0167",
"twixt;": "\u226c",
"twoheadleftarrow;": "\u219e",
"twoheadrightarrow;": "\u21a0",
"uArr;": "\u21d1",
"uHar;": "\u2963",
"uacute": "\xfa",
"uacute;": "\xfa",
"uarr;": "\u2191",
"ubrcy;": "\u045e",
"ubreve;": "\u016d",
"ucirc": "\xfb",
"ucirc;": "\xfb",
"ucy;": "\u0443",
"udarr;": "\u21c5",
"udblac;": "\u0171",
"udhar;": "\u296e",
"ufisht;": "\u297e",
"ufr;": "\U0001d532",
"ugrave": "\xf9",
"ugrave;": "\xf9",
"uharl;": "\u21bf",
"uharr;": "\u21be",
"uhblk;": "\u2580",
"ulcorn;": "\u231c",
"ulcorner;": "\u231c",
"ulcrop;": "\u230f",
"ultri;": "\u25f8",
"umacr;": "\u016b",
"uml": "\xa8",
"uml;": "\xa8",
"uogon;": "\u0173",
"uopf;": "\U0001d566",
"uparrow;": "\u2191",
"updownarrow;": "\u2195",
"upharpoonleft;": "\u21bf",
"upharpoonright;": "\u21be",
"uplus;": "\u228e",
"upsi;": "\u03c5",
"upsih;": "\u03d2",
"upsilon;": "\u03c5",
"upuparrows;": "\u21c8",
"urcorn;": "\u231d",
"urcorner;": "\u231d",
"urcrop;": "\u230e",
"uring;": "\u016f",
"urtri;": "\u25f9",
"uscr;": "\U0001d4ca",
"utdot;": "\u22f0",
"utilde;": "\u0169",
"utri;": "\u25b5",
"utrif;": "\u25b4",
"uuarr;": "\u21c8",
"uuml": "\xfc",
"uuml;": "\xfc",
"uwangle;": "\u29a7",
"vArr;": "\u21d5",
"vBar;": "\u2ae8",
"vBarv;": "\u2ae9",
"vDash;": "\u22a8",
"vangrt;": "\u299c",
"varepsilon;": "\u03f5",
"varkappa;": "\u03f0",
"varnothing;": "\u2205",
"varphi;": "\u03d5",
"varpi;": "\u03d6",
"varpropto;": "\u221d",
"varr;": "\u2195",
"varrho;": "\u03f1",
"varsigma;": "\u03c2",
"varsubsetneq;": "\u228a\ufe00",
"varsubsetneqq;": "\u2acb\ufe00",
"varsupsetneq;": "\u228b\ufe00",
"varsupsetneqq;": "\u2acc\ufe00",
"vartheta;": "\u03d1",
"vartriangleleft;": "\u22b2",
"vartriangleright;": "\u22b3",
"vcy;": "\u0432",
"vdash;": "\u22a2",
"vee;": "\u2228",
"veebar;": "\u22bb",
"veeeq;": "\u225a",
"vellip;": "\u22ee",
"verbar;": "|",
"vert;": "|",
"vfr;": "\U0001d533",
"vltri;": "\u22b2",
"vnsub;": "\u2282\u20d2",
"vnsup;": "\u2283\u20d2",
"vopf;": "\U0001d567",
"vprop;": "\u221d",
"vrtri;": "\u22b3",
"vscr;": "\U0001d4cb",
"vsubnE;": "\u2acb\ufe00",
"vsubne;": "\u228a\ufe00",
"vsupnE;": "\u2acc\ufe00",
"vsupne;": "\u228b\ufe00",
"vzigzag;": "\u299a",
"wcirc;": "\u0175",
"wedbar;": "\u2a5f",
"wedge;": "\u2227",
"wedgeq;": "\u2259",
"weierp;": "\u2118",
"wfr;": "\U0001d534",
"wopf;": "\U0001d568",
"wp;": "\u2118",
"wr;": "\u2240",
"wreath;": "\u2240",
"wscr;": "\U0001d4cc",
"xcap;": "\u22c2",
"xcirc;": "\u25ef",
"xcup;": "\u22c3",
"xdtri;": "\u25bd",
"xfr;": "\U0001d535",
"xhArr;": "\u27fa",
"xharr;": "\u27f7",
"xi;": "\u03be",
"xlArr;": "\u27f8",
"xlarr;": "\u27f5",
"xmap;": "\u27fc",
"xnis;": "\u22fb",
"xodot;": "\u2a00",
"xopf;": "\U0001d569",
"xoplus;": "\u2a01",
"xotime;": "\u2a02",
"xrArr;": "\u27f9",
"xrarr;": "\u27f6",
"xscr;": "\U0001d4cd",
"xsqcup;": "\u2a06",
"xuplus;": "\u2a04",
"xutri;": "\u25b3",
"xvee;": "\u22c1",
"xwedge;": "\u22c0",
"yacute": "\xfd",
"yacute;": "\xfd",
"yacy;": "\u044f",
"ycirc;": "\u0177",
"ycy;": "\u044b",
"yen": "\xa5",
"yen;": "\xa5",
"yfr;": "\U0001d536",
"yicy;": "\u0457",
"yopf;": "\U0001d56a",
"yscr;": "\U0001d4ce",
"yucy;": "\u044e",
"yuml": "\xff",
"yuml;": "\xff",
"zacute;": "\u017a",
"zcaron;": "\u017e",
"zcy;": "\u0437",
"zdot;": "\u017c",
"zeetrf;": "\u2128",
"zeta;": "\u03b6",
"zfr;": "\U0001d537",
"zhcy;": "\u0436",
"zigrarr;": "\u21dd",
"zopf;": "\U0001d56b",
"zscr;": "\U0001d4cf",
"zwj;": "\u200d",
"zwnj;": "\u200c",
}
replacementCharacters = {
0x0: "\uFFFD",
0x0d: "\u000D",
0x80: "\u20AC",
0x81: "\u0081",
0x81: "\u0081",
0x82: "\u201A",
0x83: "\u0192",
0x84: "\u201E",
0x85: "\u2026",
0x86: "\u2020",
0x87: "\u2021",
0x88: "\u02C6",
0x89: "\u2030",
0x8A: "\u0160",
0x8B: "\u2039",
0x8C: "\u0152",
0x8D: "\u008D",
0x8E: "\u017D",
0x8F: "\u008F",
0x90: "\u0090",
0x91: "\u2018",
0x92: "\u2019",
0x93: "\u201C",
0x94: "\u201D",
0x95: "\u2022",
0x96: "\u2013",
0x97: "\u2014",
0x98: "\u02DC",
0x99: "\u2122",
0x9A: "\u0161",
0x9B: "\u203A",
0x9C: "\u0153",
0x9D: "\u009D",
0x9E: "\u017E",
0x9F: "\u0178",
}
encodings = {
'437': 'cp437',
'850': 'cp850',
'852': 'cp852',
'855': 'cp855',
'857': 'cp857',
'860': 'cp860',
'861': 'cp861',
'862': 'cp862',
'863': 'cp863',
'865': 'cp865',
'866': 'cp866',
'869': 'cp869',
'ansix341968': 'ascii',
'ansix341986': 'ascii',
'arabic': 'iso8859-6',
'ascii': 'ascii',
'asmo708': 'iso8859-6',
'big5': 'big5',
'big5hkscs': 'big5hkscs',
'chinese': 'gbk',
'cp037': 'cp037',
'cp1026': 'cp1026',
'cp154': 'ptcp154',
'cp367': 'ascii',
'cp424': 'cp424',
'cp437': 'cp437',
'cp500': 'cp500',
'cp775': 'cp775',
'cp819': 'windows-1252',
'cp850': 'cp850',
'cp852': 'cp852',
'cp855': 'cp855',
'cp857': 'cp857',
'cp860': 'cp860',
'cp861': 'cp861',
'cp862': 'cp862',
'cp863': 'cp863',
'cp864': 'cp864',
'cp865': 'cp865',
'cp866': 'cp866',
'cp869': 'cp869',
'cp936': 'gbk',
'cpgr': 'cp869',
'cpis': 'cp861',
'csascii': 'ascii',
'csbig5': 'big5',
'cseuckr': 'cp949',
'cseucpkdfmtjapanese': 'euc_jp',
'csgb2312': 'gbk',
'cshproman8': 'hp-roman8',
'csibm037': 'cp037',
'csibm1026': 'cp1026',
'csibm424': 'cp424',
'csibm500': 'cp500',
'csibm855': 'cp855',
'csibm857': 'cp857',
'csibm860': 'cp860',
'csibm861': 'cp861',
'csibm863': 'cp863',
'csibm864': 'cp864',
'csibm865': 'cp865',
'csibm866': 'cp866',
'csibm869': 'cp869',
'csiso2022jp': 'iso2022_jp',
'csiso2022jp2': 'iso2022_jp_2',
'csiso2022kr': 'iso2022_kr',
'csiso58gb231280': 'gbk',
'csisolatin1': 'windows-1252',
'csisolatin2': 'iso8859-2',
'csisolatin3': 'iso8859-3',
'csisolatin4': 'iso8859-4',
'csisolatin5': 'windows-1254',
'csisolatin6': 'iso8859-10',
'csisolatinarabic': 'iso8859-6',
'csisolatincyrillic': 'iso8859-5',
'csisolatingreek': 'iso8859-7',
'csisolatinhebrew': 'iso8859-8',
'cskoi8r': 'koi8-r',
'csksc56011987': 'cp949',
'cspc775baltic': 'cp775',
'cspc850multilingual': 'cp850',
'cspc862latinhebrew': 'cp862',
'cspc8codepage437': 'cp437',
'cspcp852': 'cp852',
'csptcp154': 'ptcp154',
'csshiftjis': 'shift_jis',
'csunicode11utf7': 'utf-7',
'cyrillic': 'iso8859-5',
'cyrillicasian': 'ptcp154',
'ebcdiccpbe': 'cp500',
'ebcdiccpca': 'cp037',
'ebcdiccpch': 'cp500',
'ebcdiccphe': 'cp424',
'ebcdiccpnl': 'cp037',
'ebcdiccpus': 'cp037',
'ebcdiccpwt': 'cp037',
'ecma114': 'iso8859-6',
'ecma118': 'iso8859-7',
'elot928': 'iso8859-7',
'eucjp': 'euc_jp',
'euckr': 'cp949',
'extendedunixcodepackedformatforjapanese': 'euc_jp',
'gb18030': 'gb18030',
'gb2312': 'gbk',
'gb231280': 'gbk',
'gbk': 'gbk',
'greek': 'iso8859-7',
'greek8': 'iso8859-7',
'hebrew': 'iso8859-8',
'hproman8': 'hp-roman8',
'hzgb2312': 'hz',
'ibm037': 'cp037',
'ibm1026': 'cp1026',
'ibm367': 'ascii',
'ibm424': 'cp424',
'ibm437': 'cp437',
'ibm500': 'cp500',
'ibm775': 'cp775',
'ibm819': 'windows-1252',
'ibm850': 'cp850',
'ibm852': 'cp852',
'ibm855': 'cp855',
'ibm857': 'cp857',
'ibm860': 'cp860',
'ibm861': 'cp861',
'ibm862': 'cp862',
'ibm863': 'cp863',
'ibm864': 'cp864',
'ibm865': 'cp865',
'ibm866': 'cp866',
'ibm869': 'cp869',
'iso2022jp': 'iso2022_jp',
'iso2022jp2': 'iso2022_jp_2',
'iso2022kr': 'iso2022_kr',
'iso646irv1991': 'ascii',
'iso646us': 'ascii',
'iso88591': 'windows-1252',
'iso885910': 'iso8859-10',
'iso8859101992': 'iso8859-10',
'iso885911987': 'windows-1252',
'iso885913': 'iso8859-13',
'iso885914': 'iso8859-14',
'iso8859141998': 'iso8859-14',
'iso885915': 'iso8859-15',
'iso885916': 'iso8859-16',
'iso8859162001': 'iso8859-16',
'iso88592': 'iso8859-2',
'iso885921987': 'iso8859-2',
'iso88593': 'iso8859-3',
'iso885931988': 'iso8859-3',
'iso88594': 'iso8859-4',
'iso885941988': 'iso8859-4',
'iso88595': 'iso8859-5',
'iso885951988': 'iso8859-5',
'iso88596': 'iso8859-6',
'iso885961987': 'iso8859-6',
'iso88597': 'iso8859-7',
'iso885971987': 'iso8859-7',
'iso88598': 'iso8859-8',
'iso885981988': 'iso8859-8',
'iso88599': 'windows-1254',
'iso885991989': 'windows-1254',
'isoceltic': 'iso8859-14',
'isoir100': 'windows-1252',
'isoir101': 'iso8859-2',
'isoir109': 'iso8859-3',
'isoir110': 'iso8859-4',
'isoir126': 'iso8859-7',
'isoir127': 'iso8859-6',
'isoir138': 'iso8859-8',
'isoir144': 'iso8859-5',
'isoir148': 'windows-1254',
'isoir149': 'cp949',
'isoir157': 'iso8859-10',
'isoir199': 'iso8859-14',
'isoir226': 'iso8859-16',
'isoir58': 'gbk',
'isoir6': 'ascii',
'koi8r': 'koi8-r',
'koi8u': 'koi8-u',
'korean': 'cp949',
'ksc5601': 'cp949',
'ksc56011987': 'cp949',
'ksc56011989': 'cp949',
'l1': 'windows-1252',
'l10': 'iso8859-16',
'l2': 'iso8859-2',
'l3': 'iso8859-3',
'l4': 'iso8859-4',
'l5': 'windows-1254',
'l6': 'iso8859-10',
'l8': 'iso8859-14',
'latin1': 'windows-1252',
'latin10': 'iso8859-16',
'latin2': 'iso8859-2',
'latin3': 'iso8859-3',
'latin4': 'iso8859-4',
'latin5': 'windows-1254',
'latin6': 'iso8859-10',
'latin8': 'iso8859-14',
'latin9': 'iso8859-15',
'ms936': 'gbk',
'mskanji': 'shift_jis',
'pt154': 'ptcp154',
'ptcp154': 'ptcp154',
'r8': 'hp-roman8',
'roman8': 'hp-roman8',
'shiftjis': 'shift_jis',
'tis620': 'cp874',
'unicode11utf7': 'utf-7',
'us': 'ascii',
'usascii': 'ascii',
'utf16': 'utf-16',
'utf16be': 'utf-16-be',
'utf16le': 'utf-16-le',
'utf8': 'utf-8',
'windows1250': 'cp1250',
'windows1251': 'cp1251',
'windows1252': 'cp1252',
'windows1253': 'cp1253',
'windows1254': 'cp1254',
'windows1255': 'cp1255',
'windows1256': 'cp1256',
'windows1257': 'cp1257',
'windows1258': 'cp1258',
'windows936': 'gbk',
'x-x-big5': 'big5'}
tokenTypes = {
"Doctype": 0,
"Characters": 1,
"SpaceCharacters": 2,
"StartTag": 3,
"EndTag": 4,
"EmptyTag": 5,
"Comment": 6,
"ParseError": 7
}
tagTokenTypes = frozenset((tokenTypes["StartTag"], tokenTypes["EndTag"],
tokenTypes["EmptyTag"]))
prefixes = dict([(v, k) for k, v in namespaces.items()])
prefixes["http://www.w3.org/1998/Math/MathML"] = "math"
class DataLossWarning(UserWarning):
pass
class ReparseException(Exception):
pass
|
gpl-2.0
|
[
504,
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
199,
646,
1059,
199,
646,
9796,
199,
63,
275,
9796,
14,
5152,
199,
199,
13178,
275,
488,
199,
199,
37,
275,
469,
272,
298,
2307,
13,
10856,
582,
267,
3824,
8849,
4528,
315,
1324,
2547,
12,
8717,
543,
738,
11,
28050,
7651,
272,
298,
3197,
13,
19300,
582,
267,
3824,
3364,
1233,
1403,
315,
2547,
7651,
272,
298,
15448,
590,
13,
2778,
68,
13,
18533,
527,
582,
267,
3824,
5158,
7401,
527,
334,
24793,
22743,
15090,
315,
1947,
7651,
272,
298,
15448,
13,
1556,
13,
12210,
13,
4502,
582,
267,
3824,
18298,
17101,
8057,
4642,
12,
8717,
543,
491,
38,
7651,
272,
298,
23375,
13,
8258,
13,
19364,
13,
4502,
582,
267,
3824,
7302,
1202,
543,
20282,
1329,
334,
8258,
13,
19364,
3659,
680,
1288,
272,
298,
67,
867,
13,
3916,
13,
6677,
13,
4502,
582,
267,
3824,
14687,
4642,
21554,
1133,
506,
6702,
370,
4528,
298,
881,
7340,
19300,
738,
11,
2840,
1560,
2822,
3241,
9,
2036,
88,
680,
1288,
272,
298,
23375,
13,
19300,
13,
509,
13,
6677,
13,
4502,
582,
267,
3824,
14687,
4642,
8469,
376,
20282,
1233,
1403,
26,
298,
881,
298,
53,
11,
2840,
1560,
2822,
3241,
9,
2036,
88,
7651,
272,
298,
6677,
13,
4502,
13,
7395,
13,
19290,
12167,
582,
267,
3824,
14687,
4642,
9980,
1133,
1284,
543,
30955,
1288,
272,
298,
2062,
13,
6677,
13,
4502,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
14687,
4642,
1420,
14,
24734,
1284,
402,
570,
3140,
7651,
272,
298,
2062,
13,
6677,
13,
4502,
582,
267,
3824,
14687,
4642,
1420,
1325,
7179,
1911,
7651,
272,
298,
4579,
13,
4502,
13,
7395,
13,
19290,
12167,
582,
267,
3824,
7989,
4642,
9980,
1133,
1284,
543,
30955,
1288,
272,
298,
2062,
13,
4579,
13,
4502,
582,
267,
3824,
7989,
4642,
1420,
14,
24734,
7179,
7651,
272,
298,
2987,
13,
262,
13,
500,
13,
1450,
582,
267,
3824,
3005,
1947,
3509,
10537,
3004,
7651,
272,
283,
277,
13,
11707,
13,
4173,
13,
265,
13,
500,
13,
1450,
356,
267,
3824,
3005,
1947,
3509,
10537,
291,
13,
11707,
3305,
7651,
272,
298,
2062,
13,
1450,
13,
354,
13,
7911,
13,
7808,
13,
1019,
13,
14594,
582,
267,
3824,
6964,
1947,
536,
14,
24734,
21770,
3140,
7651,
272,
298,
2062,
13,
1450,
13,
354,
13,
7911,
13,
7808,
13,
4790,
13,
1657,
582,
267,
3824,
6964,
1947,
536,
14,
24734,
15539,
3140,
14,
334,
4943,
3181,
1133,
298,
881,
298,
4058,
6661,
15794,
4959,
1288,
272,
298,
2062,
13,
1450,
13,
354,
582,
267,
3824,
6964,
1947,
536,
14,
24734,
6020,
587,
3140,
1288,
272,
298,
2062,
13,
11707,
13,
1450,
13,
7911,
13,
7808,
13,
1019,
13,
14594,
582,
267,
3824,
6964,
11261,
1947,
14,
24734,
21770,
3140,
14,
20489,
6854,
11936,
22936,
1288,
272,
298,
2062,
13,
11707,
13,
1450,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
6964,
11261,
1947,
14,
25345,
1284,
402,
570,
7651,
272,
298,
2062,
13,
11707,
13,
1450,
13,
7911,
13,
7808,
13,
1560,
582,
267,
3824,
6964,
11261,
1947,
14,
25345,
4528,
9487,
576,
9,
83,
7,
1911,
7651,
272,
298,
11670,
13,
262,
13,
1450,
13,
354,
582,
267,
3824,
8708,
1284,
402,
570,
315,
314,
1947,
536,
7651,
272,
298,
2062,
13,
3215,
13,
354,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
8708,
1284,
402,
570,
14,
13796,
2225,
536,
3140,
7651,
272,
298,
11670,
13,
262,
13,
3215,
13,
354,
582,
267,
3824,
8708,
1284,
402,
570,
315,
2225,
536,
7651,
272,
298,
3197,
13,
10856,
13,
262,
13,
3215,
13,
354,
582,
267,
3824,
3364,
4528,
315,
2225,
536,
1288,
272,
298,
11081,
13,
3215,
582,
267,
3824,
11070,
1915,
9250,
2225,
641,
1947,
7651,
272,
298,
2062,
13,
500,
13,
1618,
13,
1450,
13,
354,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
8708,
1284,
402,
570,
14,
13796,
275,
503,
1284,
402,
1947,
7651,
272,
298,
2062,
13,
3215,
13,
585,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
8708,
1284,
402,
570,
14,
13796,
2225,
574,
7651,
272,
298,
2062,
13,
3215,
13,
585,
13,
7911,
13,
7808,
13,
1019,
13,
14594,
582,
267,
3824,
6964,
2225,
574,
14,
24734,
21770,
3140,
7651,
272,
283,
11332,
13,
262,
13,
324,
9888,
13,
3215,
13,
585,
356,
267,
3824,
8708,
275,
315,
31791,
2225,
1288,
272,
283,
8953,
13,
10856,
13,
262,
13,
324,
9888,
13,
3215,
13,
585,
356,
267,
3824,
8708,
4528,
315,
31791,
2225,
1288,
272,
298,
3197,
13,
10856,
13,
4399,
13,
3215,
13,
354,
582,
267,
3824,
8708,
4528,
2410,
2225,
536,
7651,
272,
298,
8953,
13,
10856,
13,
4399,
13,
3215,
13,
585,
582,
267,
3824,
8708,
4528,
2410,
2225,
574,
7651,
272,
298,
11670,
13,
262,
13,
3215,
13,
585,
13,
3157,
13,
3513,
582,
267,
3824,
8708,
1284,
402,
570,
315,
2225,
574,
14749,
3471,
1288,
272,
298,
11670,
13,
262,
13,
3215,
13,
585,
13,
4780,
13,
3513,
582,
267,
3824,
8708,
1284,
402,
570,
315,
2225,
574,
334,
1959,
1288,
272,
298,
11670,
13,
262,
13,
3215,
13,
585,
13,
889,
13,
14005,
582,
267,
3824,
8708,
1284,
402,
570,
315,
2225,
574,
7651,
272,
298,
8953,
13,
13178,
13,
4399,
13,
18533,
527,
13,
262,
13,
1450,
582,
267,
3824,
8708,
1284,
402,
570,
315,
1947,
14,
13796,
690,
1288,
272,
298,
8953,
13,
10856,
13,
4399,
13,
18533,
527,
13,
262,
13,
1450,
582,
267,
3824,
8708,
4528,
2410,
1182,
315,
1947,
14,
13796,
690,
1288,
272,
298,
2062,
13,
6760,
397,
13,
269,
13,
6356,
582,
267,
3824,
6964,
2850,
7,
503,
283,
16556,
1370,
2832,
1911,
7651,
272,
298,
8953,
13,
66,
621,
13,
4399,
13,
3157,
13,
6760,
13,
262,
13,
3349,
582,
267,
3824,
8708,
8546,
2410,
1553,
315,
3721,
1288,
272,
298,
8953,
13,
2638,
13,
4399,
13,
3157,
13,
6760,
13,
262,
13,
3349,
582,
267,
3824,
8708,
4601,
2410,
1553,
315,
3721,
1288,
272,
298,
15448,
13,
3349,
582,
267,
3824,
18298,
3721,
7651,
272,
298,
11670,
13,
262,
13,
3349,
582,
267,
3824,
8708,
1284,
402,
570,
315,
3721
] |
[
636,
2443,
363,
492,
3679,
63,
646,
12,
4629,
12,
2649,
63,
5955,
199,
199,
646,
1059,
199,
646,
9796,
199,
63,
275,
9796,
14,
5152,
199,
199,
13178,
275,
488,
199,
199,
37,
275,
469,
272,
298,
2307,
13,
10856,
582,
267,
3824,
8849,
4528,
315,
1324,
2547,
12,
8717,
543,
738,
11,
28050,
7651,
272,
298,
3197,
13,
19300,
582,
267,
3824,
3364,
1233,
1403,
315,
2547,
7651,
272,
298,
15448,
590,
13,
2778,
68,
13,
18533,
527,
582,
267,
3824,
5158,
7401,
527,
334,
24793,
22743,
15090,
315,
1947,
7651,
272,
298,
15448,
13,
1556,
13,
12210,
13,
4502,
582,
267,
3824,
18298,
17101,
8057,
4642,
12,
8717,
543,
491,
38,
7651,
272,
298,
23375,
13,
8258,
13,
19364,
13,
4502,
582,
267,
3824,
7302,
1202,
543,
20282,
1329,
334,
8258,
13,
19364,
3659,
680,
1288,
272,
298,
67,
867,
13,
3916,
13,
6677,
13,
4502,
582,
267,
3824,
14687,
4642,
21554,
1133,
506,
6702,
370,
4528,
298,
881,
7340,
19300,
738,
11,
2840,
1560,
2822,
3241,
9,
2036,
88,
680,
1288,
272,
298,
23375,
13,
19300,
13,
509,
13,
6677,
13,
4502,
582,
267,
3824,
14687,
4642,
8469,
376,
20282,
1233,
1403,
26,
298,
881,
298,
53,
11,
2840,
1560,
2822,
3241,
9,
2036,
88,
7651,
272,
298,
6677,
13,
4502,
13,
7395,
13,
19290,
12167,
582,
267,
3824,
14687,
4642,
9980,
1133,
1284,
543,
30955,
1288,
272,
298,
2062,
13,
6677,
13,
4502,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
14687,
4642,
1420,
14,
24734,
1284,
402,
570,
3140,
7651,
272,
298,
2062,
13,
6677,
13,
4502,
582,
267,
3824,
14687,
4642,
1420,
1325,
7179,
1911,
7651,
272,
298,
4579,
13,
4502,
13,
7395,
13,
19290,
12167,
582,
267,
3824,
7989,
4642,
9980,
1133,
1284,
543,
30955,
1288,
272,
298,
2062,
13,
4579,
13,
4502,
582,
267,
3824,
7989,
4642,
1420,
14,
24734,
7179,
7651,
272,
298,
2987,
13,
262,
13,
500,
13,
1450,
582,
267,
3824,
3005,
1947,
3509,
10537,
3004,
7651,
272,
283,
277,
13,
11707,
13,
4173,
13,
265,
13,
500,
13,
1450,
356,
267,
3824,
3005,
1947,
3509,
10537,
291,
13,
11707,
3305,
7651,
272,
298,
2062,
13,
1450,
13,
354,
13,
7911,
13,
7808,
13,
1019,
13,
14594,
582,
267,
3824,
6964,
1947,
536,
14,
24734,
21770,
3140,
7651,
272,
298,
2062,
13,
1450,
13,
354,
13,
7911,
13,
7808,
13,
4790,
13,
1657,
582,
267,
3824,
6964,
1947,
536,
14,
24734,
15539,
3140,
14,
334,
4943,
3181,
1133,
298,
881,
298,
4058,
6661,
15794,
4959,
1288,
272,
298,
2062,
13,
1450,
13,
354,
582,
267,
3824,
6964,
1947,
536,
14,
24734,
6020,
587,
3140,
1288,
272,
298,
2062,
13,
11707,
13,
1450,
13,
7911,
13,
7808,
13,
1019,
13,
14594,
582,
267,
3824,
6964,
11261,
1947,
14,
24734,
21770,
3140,
14,
20489,
6854,
11936,
22936,
1288,
272,
298,
2062,
13,
11707,
13,
1450,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
6964,
11261,
1947,
14,
25345,
1284,
402,
570,
7651,
272,
298,
2062,
13,
11707,
13,
1450,
13,
7911,
13,
7808,
13,
1560,
582,
267,
3824,
6964,
11261,
1947,
14,
25345,
4528,
9487,
576,
9,
83,
7,
1911,
7651,
272,
298,
11670,
13,
262,
13,
1450,
13,
354,
582,
267,
3824,
8708,
1284,
402,
570,
315,
314,
1947,
536,
7651,
272,
298,
2062,
13,
3215,
13,
354,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
8708,
1284,
402,
570,
14,
13796,
2225,
536,
3140,
7651,
272,
298,
11670,
13,
262,
13,
3215,
13,
354,
582,
267,
3824,
8708,
1284,
402,
570,
315,
2225,
536,
7651,
272,
298,
3197,
13,
10856,
13,
262,
13,
3215,
13,
354,
582,
267,
3824,
3364,
4528,
315,
2225,
536,
1288,
272,
298,
11081,
13,
3215,
582,
267,
3824,
11070,
1915,
9250,
2225,
641,
1947,
7651,
272,
298,
2062,
13,
500,
13,
1618,
13,
1450,
13,
354,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
8708,
1284,
402,
570,
14,
13796,
275,
503,
1284,
402,
1947,
7651,
272,
298,
2062,
13,
3215,
13,
585,
13,
7911,
13,
7808,
13,
11670,
582,
267,
3824,
8708,
1284,
402,
570,
14,
13796,
2225,
574,
7651,
272,
298,
2062,
13,
3215,
13,
585,
13,
7911,
13,
7808,
13,
1019,
13,
14594,
582,
267,
3824,
6964,
2225,
574,
14,
24734,
21770,
3140,
7651,
272,
283,
11332,
13,
262,
13,
324,
9888,
13,
3215,
13,
585,
356,
267,
3824,
8708,
275,
315,
31791,
2225,
1288,
272,
283,
8953,
13,
10856,
13,
262,
13,
324,
9888,
13,
3215,
13,
585,
356,
267,
3824,
8708,
4528,
315,
31791,
2225,
1288,
272,
298,
3197,
13,
10856,
13,
4399,
13,
3215,
13,
354,
582,
267,
3824,
8708,
4528,
2410,
2225,
536,
7651,
272,
298,
8953,
13,
10856,
13,
4399,
13,
3215,
13,
585,
582,
267,
3824,
8708,
4528,
2410,
2225,
574,
7651,
272,
298,
11670,
13,
262,
13,
3215,
13,
585,
13,
3157,
13,
3513,
582,
267,
3824,
8708,
1284,
402,
570,
315,
2225,
574,
14749,
3471,
1288,
272,
298,
11670,
13,
262,
13,
3215,
13,
585,
13,
4780,
13,
3513,
582,
267,
3824,
8708,
1284,
402,
570,
315,
2225,
574,
334,
1959,
1288,
272,
298,
11670,
13,
262,
13,
3215,
13,
585,
13,
889,
13,
14005,
582,
267,
3824,
8708,
1284,
402,
570,
315,
2225,
574,
7651,
272,
298,
8953,
13,
13178,
13,
4399,
13,
18533,
527,
13,
262,
13,
1450,
582,
267,
3824,
8708,
1284,
402,
570,
315,
1947,
14,
13796,
690,
1288,
272,
298,
8953,
13,
10856,
13,
4399,
13,
18533,
527,
13,
262,
13,
1450,
582,
267,
3824,
8708,
4528,
2410,
1182,
315,
1947,
14,
13796,
690,
1288,
272,
298,
2062,
13,
6760,
397,
13,
269,
13,
6356,
582,
267,
3824,
6964,
2850,
7,
503,
283,
16556,
1370,
2832,
1911,
7651,
272,
298,
8953,
13,
66,
621,
13,
4399,
13,
3157,
13,
6760,
13,
262,
13,
3349,
582,
267,
3824,
8708,
8546,
2410,
1553,
315,
3721,
1288,
272,
298,
8953,
13,
2638,
13,
4399,
13,
3157,
13,
6760,
13,
262,
13,
3349,
582,
267,
3824,
8708,
4601,
2410,
1553,
315,
3721,
1288,
272,
298,
15448,
13,
3349,
582,
267,
3824,
18298,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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
] |
jelugbo/ddi
|
lms/djangoapps/instructor/features/bulk_email.py
|
12
|
6758
|
"""
Define steps for bulk email acceptance test.
"""
# pylint: disable=C0111
# pylint: disable=W0621
from lettuce import world, step
from lettuce.django import mail
from nose.tools import assert_in, assert_equal # pylint: disable=E0611
from django.core.management import call_command
from django.conf import settings
from courseware.tests.factories import StaffFactory, InstructorFactory
@step(u'Given there is a course with a staff, instructor and student')
def make_populated_course(step): # pylint: disable=unused-argument
## This is different than the function defined in common.py because it enrolls
## a staff, instructor, and student member regardless of what `role` is, then
## logs `role` in. This is to ensure we have 3 class participants to email.
# Clear existing courses to avoid conflicts
world.clear_courses()
# Create a new course
course = world.CourseFactory.create(
org='edx',
number='888',
display_name='Bulk Email Test Course'
)
world.bulk_email_course_key = course.id
try:
# See if we've defined the instructor & staff user yet
world.bulk_email_instructor
except AttributeError:
# Make & register an instructor for the course
world.bulk_email_instructor = InstructorFactory(course_key=world.bulk_email_course_key)
world.enroll_user(world.bulk_email_instructor, world.bulk_email_course_key)
# Make & register a staff member
world.bulk_email_staff = StaffFactory(course_key=course.id)
world.enroll_user(world.bulk_email_staff, world.bulk_email_course_key)
# Make & register a student
world.register_by_course_key(
course.id,
username='student',
password='test',
is_staff=False
)
# Store the expected recipients
# given each "send to" option
staff_emails = [world.bulk_email_staff.email, world.bulk_email_instructor.email]
world.expected_addresses = {
'course staff': staff_emails,
'students, staff, and instructors': staff_emails + ['student@edx.org']
}
# Dictionary mapping a description of the email recipient
# to the corresponding <option> value in the UI.
SEND_TO_OPTIONS = {
'myself': 'myself',
'course staff': 'staff',
'students, staff, and instructors': 'all'
}
@step(u'I am logged in to the course as "([^"]*)"')
def log_into_the_course(step, role): # pylint: disable=unused-argument
# Store the role
assert_in(role, ['instructor', 'staff'])
# Log in as the an instructor or staff for the course
my_email = world.bulk_email_instructor.email
if role == 'instructor':
world.log_in(
username=world.bulk_email_instructor.username,
password='test',
email=my_email,
name=world.bulk_email_instructor.profile.name
)
else:
my_email = world.bulk_email_staff.email
world.log_in(
username=world.bulk_email_staff.username,
password='test',
email=my_email,
name=world.bulk_email_staff.profile.name
)
# Store the "myself" send to option
world.expected_addresses['myself'] = [my_email]
@step(u'I send email to "([^"]*)"')
def when_i_send_an_email(step, recipient): # pylint: disable=unused-argument
# Check that the recipient is valid
assert_in(
recipient, SEND_TO_OPTIONS,
msg="Invalid recipient: {}".format(recipient)
)
# Clear the queue of existing emails
while not mail.queue.empty(): # pylint: disable=E1101
mail.queue.get() # pylint: disable=E1101
# Because we flush the database before each run,
# we need to ensure that the email template fixture
# is re-loaded into the database
call_command('loaddata', 'course_email_template.json')
# Go to the email section of the instructor dash
url = '/courses/{}'.format(world.bulk_email_course_key)
world.visit(url)
world.css_click('a[href="{}/instructor"]'.format(url))
world.css_click('a[data-section="send_email"]')
# Select the recipient
world.select_option('send_to', SEND_TO_OPTIONS[recipient])
# Enter subject and message
world.css_fill('input#id_subject', 'Hello')
with world.browser.get_iframe('mce_0_ifr') as iframe:
editor = iframe.find_by_id('tinymce')[0]
editor.fill('test message')
# Click send
world.css_click('input[name="send"]', dismiss_alert=True)
# Expect to see a message that the email was sent
expected_msg = "Your email was successfully queued for sending."
world.wait_for_visible('#request-response')
assert_in(
expected_msg, world.css_text('#request-response'),
msg="Could not find email success message."
)
UNSUBSCRIBE_MSG = 'To stop receiving email like this'
@step(u'Email is sent to "([^"]*)"')
def then_the_email_is_sent(step, recipient): # pylint: disable=unused-argument
# Check that the recipient is valid
assert_in(
recipient, SEND_TO_OPTIONS,
msg="Invalid recipient: {}".format(recipient)
)
# Retrieve messages. Because we are using celery in "always eager"
# mode, we expect all messages to be sent by this point.
messages = []
while not mail.queue.empty(): # pylint: disable=E1101
messages.append(mail.queue.get()) # pylint: disable=E1101
# Check that we got the right number of messages
assert_equal(
len(messages), len(world.expected_addresses[recipient]),
msg="Received {0} instead of {1} messages for {2}".format(
len(messages), len(world.expected_addresses[recipient]), recipient
)
)
# Check that the message properties were correct
recipients = []
for msg in messages:
assert_in('Hello', msg.subject)
assert_in(settings.BULK_EMAIL_DEFAULT_FROM_EMAIL, msg.from_email)
# Message body should have the message we sent
# and an unsubscribe message
assert_in('test message', msg.body)
assert_in(UNSUBSCRIBE_MSG, msg.body)
# Should have alternative HTML form
assert_equal(len(msg.alternatives), 1)
content, mime_type = msg.alternatives[0]
assert_equal(mime_type, 'text/html')
assert_in('test message', content)
assert_in(UNSUBSCRIBE_MSG, content)
# Store the recipient address so we can verify later
recipients.extend(msg.recipients())
# Check that the messages were sent to the right people
# Because "myself" can vary based on who sent the message,
# we use the world.expected_addresses dict we configured
# in an earlier step.
for addr in world.expected_addresses[recipient]:
assert_in(addr, recipients)
|
agpl-3.0
|
[
624,
199,
16213,
7124,
367,
13137,
3031,
4729,
554,
511,
14,
199,
624,
199,
199,
3,
4287,
26,
3507,
29,
35,
28107,
199,
3,
4287,
26,
3507,
29,
55,
1690,
2025,
199,
199,
504,
4691,
84,
3683,
492,
6701,
12,
3650,
199,
504,
4691,
84,
3683,
14,
1176,
492,
6016,
199,
504,
11354,
14,
2537,
492,
702,
63,
262,
12,
702,
63,
1452,
221,
327,
4287,
26,
3507,
29,
37,
1690,
845,
199,
504,
1639,
14,
1018,
14,
8110,
492,
1240,
63,
1531,
199,
504,
1639,
14,
2190,
492,
2202,
199,
199,
504,
20736,
14,
2219,
14,
15406,
492,
25910,
2927,
12,
26150,
2927,
421,
199,
32,
2926,
8,
85,
7,
13735,
2337,
365,
282,
2518,
543,
282,
12622,
12,
17724,
436,
6474,
358,
199,
318,
1852,
63,
21440,
63,
1972,
8,
2926,
304,
221,
327,
4287,
26,
3507,
29,
8618,
13,
2094,
272,
925,
961,
365,
3365,
2419,
314,
805,
3247,
315,
2863,
14,
647,
2952,
652,
655,
8459,
478,
272,
925,
282,
12622,
12,
17724,
12,
436,
6474,
3653,
15270,
402,
4052,
658,
3756,
64,
365,
12,
2066,
272,
925,
9610,
658,
3756,
64,
315,
14,
961,
365,
370,
4868,
781,
1172,
650,
1021,
623,
20989,
370,
3031,
14,
339,
327,
14836,
3411,
13588,
370,
5126,
18511,
272,
6701,
14,
3584,
63,
11653,
342,
339,
327,
2790,
282,
892,
2518,
272,
2518,
275,
6701,
14,
6979,
2927,
14,
981,
8,
267,
5981,
534,
8268,
297,
267,
1329,
534,
13997,
297,
267,
2929,
63,
354,
534,
26033,
11426,
1379,
5531,
7,
272,
776,
272,
6701,
14,
9377,
63,
2123,
63,
1972,
63,
498,
275,
2518,
14,
344,
339,
862,
26,
267,
327,
1666,
340,
781,
9064,
3247,
314,
17724,
1253,
12622,
922,
5966,
267,
6701,
14,
9377,
63,
2123,
63,
14891,
272,
871,
4281,
26,
267,
327,
4155,
1253,
2274,
376,
17724,
367,
314,
2518,
267,
6701,
14,
9377,
63,
2123,
63,
14891,
275,
26150,
2927,
8,
1972,
63,
498,
29,
7617,
14,
9377,
63,
2123,
63,
1972,
63,
498,
9,
267,
6701,
14,
14695,
63,
751,
8,
7617,
14,
9377,
63,
2123,
63,
14891,
12,
6701,
14,
9377,
63,
2123,
63,
1972,
63,
498,
9,
398,
327,
4155,
1253,
2274,
282,
12622,
3653,
267,
6701,
14,
9377,
63,
2123,
63,
7018,
275,
25910,
2927,
8,
1972,
63,
498,
29,
1972,
14,
344,
9,
267,
6701,
14,
14695,
63,
751,
8,
7617,
14,
9377,
63,
2123,
63,
7018,
12,
6701,
14,
9377,
63,
2123,
63,
1972,
63,
498,
9,
339,
327,
4155,
1253,
2274,
282,
6474,
272,
6701,
14,
2683,
63,
991,
63,
1972,
63,
498,
8,
267,
2518,
14,
344,
12,
267,
3434,
534,
5500,
297,
267,
2505,
534,
396,
297,
267,
365,
63,
7018,
29,
797,
272,
776,
339,
327,
13874,
314,
1420,
19255,
272,
327,
1627,
1924,
298,
2254,
370,
2,
945,
272,
12622,
63,
14170,
275,
359,
7617,
14,
9377,
63,
2123,
63,
7018,
14,
2123,
12,
6701,
14,
9377,
63,
2123,
63,
14891,
14,
2123,
61,
272,
6701,
14,
2062,
63,
7423,
275,
469,
267,
283,
1972,
12622,
356,
12622,
63,
14170,
12,
267,
283,
17921,
12,
12622,
12,
436,
17724,
83,
356,
12622,
63,
14170,
435,
788,
5500,
32,
8268,
14,
1308,
418,
272,
789,
421,
199,
3,
11932,
4412,
282,
1369,
402,
314,
3031,
10318,
199,
3,
370,
314,
5226,
665,
1422,
30,
574,
315,
314,
14041,
14,
199,
20469,
63,
2566,
63,
8808,
275,
469,
272,
283,
1662,
277,
356,
283,
1662,
277,
297,
272,
283,
1972,
12622,
356,
283,
7018,
297,
272,
283,
17921,
12,
12622,
12,
436,
17724,
83,
356,
283,
452,
7,
199,
93,
421,
199,
32,
2926,
8,
85,
7,
41,
8140,
10367,
315,
370,
314,
2518,
465,
32397,
25952,
358,
199,
318,
943,
63,
9924,
63,
1589,
63,
1972,
8,
2926,
12,
4719,
304,
221,
327,
4287,
26,
3507,
29,
8618,
13,
2094,
272,
327,
13874,
314,
4719,
272,
702,
63,
262,
8,
3756,
12,
788,
14891,
297,
283,
7018,
1105,
339,
327,
5297,
315,
465,
314,
376,
17724,
503,
12622,
367,
314,
2518,
272,
3002,
63,
2123,
275,
6701,
14,
9377,
63,
2123,
63,
14891,
14,
2123,
272,
340,
4719,
508,
283,
14891,
356,
267,
6701,
14,
793,
63,
262,
8,
288,
3434,
29,
7617,
14,
9377,
63,
2123,
63,
14891,
14,
2473,
12,
288,
2505,
534,
396,
297,
288,
3031,
29,
1662,
63,
2123,
12,
288,
536,
29,
7617,
14,
9377,
63,
2123,
63,
14891,
14,
2913,
14,
354,
267,
776,
272,
587,
26,
267,
3002,
63,
2123,
275,
6701,
14,
9377,
63,
2123,
63,
7018,
14,
2123,
267,
6701,
14,
793,
63,
262,
8,
288,
3434,
29,
7617,
14,
9377,
63,
2123,
63,
7018,
14,
2473,
12,
288,
2505,
534,
396,
297,
288,
3031,
29,
1662,
63,
2123,
12,
288,
536,
29,
7617,
14,
9377,
63,
2123,
63,
7018,
14,
2913,
14,
354,
267,
776,
339,
327,
13874,
314,
298,
1662,
277,
2,
3222,
370,
945,
272,
6701,
14,
2062,
63,
7423,
459,
1662,
277,
418,
275,
359,
1662,
63,
2123,
61,
421,
199,
32,
2926,
8,
85,
7,
41,
3222,
3031,
370,
32397,
25952,
358,
199,
318,
1380,
63,
73,
63,
2254,
63,
290,
63,
2123,
8,
2926,
12,
10318,
304,
221,
327,
4287,
26,
3507,
29,
8618,
13,
2094,
339,
327,
2670,
626,
314,
10318,
365,
1686,
272,
702,
63,
262,
8,
267,
10318,
12,
428,
3902,
63,
2566,
63,
8808,
12,
267,
1499,
628,
3364,
10318,
26,
8352,
908,
8,
10043,
9,
272,
776,
339,
327,
14836,
314,
4126,
402,
3411,
14931,
272,
1830,
440,
6016,
14,
1825,
14,
1667,
837,
221,
327,
4287,
26,
3507,
29,
37,
24827,
267,
6016,
14,
1825,
14,
362,
342,
221,
327,
4287,
26,
3507,
29,
37,
24827,
339,
327,
13821,
781,
8976,
314,
3050,
2544,
1924,
1255,
12,
272,
327,
781,
1929,
370,
4868,
626,
314,
3031,
1978,
10949,
272,
327,
365,
295,
13,
4591,
1901,
314,
3050,
272,
1240,
63,
1531,
360,
320,
525,
419,
297,
283,
1972,
63,
2123,
63,
1160,
14,
1001,
358,
339,
327,
3971,
370,
314,
3031,
3420,
402,
314,
17724,
11847,
272,
1166,
275,
1994,
11653,
30837,
908,
8,
7617,
14,
9377,
63,
2123,
63,
1972,
63,
498,
9,
272,
6701
] |
[
199,
16213,
7124,
367,
13137,
3031,
4729,
554,
511,
14,
199,
624,
199,
199,
3,
4287,
26,
3507,
29,
35,
28107,
199,
3,
4287,
26,
3507,
29,
55,
1690,
2025,
199,
199,
504,
4691,
84,
3683,
492,
6701,
12,
3650,
199,
504,
4691,
84,
3683,
14,
1176,
492,
6016,
199,
504,
11354,
14,
2537,
492,
702,
63,
262,
12,
702,
63,
1452,
221,
327,
4287,
26,
3507,
29,
37,
1690,
845,
199,
504,
1639,
14,
1018,
14,
8110,
492,
1240,
63,
1531,
199,
504,
1639,
14,
2190,
492,
2202,
199,
199,
504,
20736,
14,
2219,
14,
15406,
492,
25910,
2927,
12,
26150,
2927,
421,
199,
32,
2926,
8,
85,
7,
13735,
2337,
365,
282,
2518,
543,
282,
12622,
12,
17724,
436,
6474,
358,
199,
318,
1852,
63,
21440,
63,
1972,
8,
2926,
304,
221,
327,
4287,
26,
3507,
29,
8618,
13,
2094,
272,
925,
961,
365,
3365,
2419,
314,
805,
3247,
315,
2863,
14,
647,
2952,
652,
655,
8459,
478,
272,
925,
282,
12622,
12,
17724,
12,
436,
6474,
3653,
15270,
402,
4052,
658,
3756,
64,
365,
12,
2066,
272,
925,
9610,
658,
3756,
64,
315,
14,
961,
365,
370,
4868,
781,
1172,
650,
1021,
623,
20989,
370,
3031,
14,
339,
327,
14836,
3411,
13588,
370,
5126,
18511,
272,
6701,
14,
3584,
63,
11653,
342,
339,
327,
2790,
282,
892,
2518,
272,
2518,
275,
6701,
14,
6979,
2927,
14,
981,
8,
267,
5981,
534,
8268,
297,
267,
1329,
534,
13997,
297,
267,
2929,
63,
354,
534,
26033,
11426,
1379,
5531,
7,
272,
776,
272,
6701,
14,
9377,
63,
2123,
63,
1972,
63,
498,
275,
2518,
14,
344,
339,
862,
26,
267,
327,
1666,
340,
781,
9064,
3247,
314,
17724,
1253,
12622,
922,
5966,
267,
6701,
14,
9377,
63,
2123,
63,
14891,
272,
871,
4281,
26,
267,
327,
4155,
1253,
2274,
376,
17724,
367,
314,
2518,
267,
6701,
14,
9377,
63,
2123,
63,
14891,
275,
26150,
2927,
8,
1972,
63,
498,
29,
7617,
14,
9377,
63,
2123,
63,
1972,
63,
498,
9,
267,
6701,
14,
14695,
63,
751,
8,
7617,
14,
9377,
63,
2123,
63,
14891,
12,
6701,
14,
9377,
63,
2123,
63,
1972,
63,
498,
9,
398,
327,
4155,
1253,
2274,
282,
12622,
3653,
267,
6701,
14,
9377,
63,
2123,
63,
7018,
275,
25910,
2927,
8,
1972,
63,
498,
29,
1972,
14,
344,
9,
267,
6701,
14,
14695,
63,
751,
8,
7617,
14,
9377,
63,
2123,
63,
7018,
12,
6701,
14,
9377,
63,
2123,
63,
1972,
63,
498,
9,
339,
327,
4155,
1253,
2274,
282,
6474,
272,
6701,
14,
2683,
63,
991,
63,
1972,
63,
498,
8,
267,
2518,
14,
344,
12,
267,
3434,
534,
5500,
297,
267,
2505,
534,
396,
297,
267,
365,
63,
7018,
29,
797,
272,
776,
339,
327,
13874,
314,
1420,
19255,
272,
327,
1627,
1924,
298,
2254,
370,
2,
945,
272,
12622,
63,
14170,
275,
359,
7617,
14,
9377,
63,
2123,
63,
7018,
14,
2123,
12,
6701,
14,
9377,
63,
2123,
63,
14891,
14,
2123,
61,
272,
6701,
14,
2062,
63,
7423,
275,
469,
267,
283,
1972,
12622,
356,
12622,
63,
14170,
12,
267,
283,
17921,
12,
12622,
12,
436,
17724,
83,
356,
12622,
63,
14170,
435,
788,
5500,
32,
8268,
14,
1308,
418,
272,
789,
421,
199,
3,
11932,
4412,
282,
1369,
402,
314,
3031,
10318,
199,
3,
370,
314,
5226,
665,
1422,
30,
574,
315,
314,
14041,
14,
199,
20469,
63,
2566,
63,
8808,
275,
469,
272,
283,
1662,
277,
356,
283,
1662,
277,
297,
272,
283,
1972,
12622,
356,
283,
7018,
297,
272,
283,
17921,
12,
12622,
12,
436,
17724,
83,
356,
283,
452,
7,
199,
93,
421,
199,
32,
2926,
8,
85,
7,
41,
8140,
10367,
315,
370,
314,
2518,
465,
32397,
25952,
358,
199,
318,
943,
63,
9924,
63,
1589,
63,
1972,
8,
2926,
12,
4719,
304,
221,
327,
4287,
26,
3507,
29,
8618,
13,
2094,
272,
327,
13874,
314,
4719,
272,
702,
63,
262,
8,
3756,
12,
788,
14891,
297,
283,
7018,
1105,
339,
327,
5297,
315,
465,
314,
376,
17724,
503,
12622,
367,
314,
2518,
272,
3002,
63,
2123,
275,
6701,
14,
9377,
63,
2123,
63,
14891,
14,
2123,
272,
340,
4719,
508,
283,
14891,
356,
267,
6701,
14,
793,
63,
262,
8,
288,
3434,
29,
7617,
14,
9377,
63,
2123,
63,
14891,
14,
2473,
12,
288,
2505,
534,
396,
297,
288,
3031,
29,
1662,
63,
2123,
12,
288,
536,
29,
7617,
14,
9377,
63,
2123,
63,
14891,
14,
2913,
14,
354,
267,
776,
272,
587,
26,
267,
3002,
63,
2123,
275,
6701,
14,
9377,
63,
2123,
63,
7018,
14,
2123,
267,
6701,
14,
793,
63,
262,
8,
288,
3434,
29,
7617,
14,
9377,
63,
2123,
63,
7018,
14,
2473,
12,
288,
2505,
534,
396,
297,
288,
3031,
29,
1662,
63,
2123,
12,
288,
536,
29,
7617,
14,
9377,
63,
2123,
63,
7018,
14,
2913,
14,
354,
267,
776,
339,
327,
13874,
314,
298,
1662,
277,
2,
3222,
370,
945,
272,
6701,
14,
2062,
63,
7423,
459,
1662,
277,
418,
275,
359,
1662,
63,
2123,
61,
421,
199,
32,
2926,
8,
85,
7,
41,
3222,
3031,
370,
32397,
25952,
358,
199,
318,
1380,
63,
73,
63,
2254,
63,
290,
63,
2123,
8,
2926,
12,
10318,
304,
221,
327,
4287,
26,
3507,
29,
8618,
13,
2094,
339,
327,
2670,
626,
314,
10318,
365,
1686,
272,
702,
63,
262,
8,
267,
10318,
12,
428,
3902,
63,
2566,
63,
8808,
12,
267,
1499,
628,
3364,
10318,
26,
8352,
908,
8,
10043,
9,
272,
776,
339,
327,
14836,
314,
4126,
402,
3411,
14931,
272,
1830,
440,
6016,
14,
1825,
14,
1667,
837,
221,
327,
4287,
26,
3507,
29,
37,
24827,
267,
6016,
14,
1825,
14,
362,
342,
221,
327,
4287,
26,
3507,
29,
37,
24827,
339,
327,
13821,
781,
8976,
314,
3050,
2544,
1924,
1255,
12,
272,
327,
781,
1929,
370,
4868,
626,
314,
3031,
1978,
10949,
272,
327,
365,
295,
13,
4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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
] |
michalliu/OpenWrt-Firefly-Libraries
|
staging_dir/host/lib/python2.7/SimpleHTTPServer.py
|
29
|
7745
|
"""Simple HTTP Server.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
__version__ = "0.6"
__all__ = ["SimpleHTTPRequestHandler"]
import os
import posixpath
import BaseHTTPServer
import urllib
import cgi
import sys
import shutil
import mimetypes
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""Simple HTTP request handler with GET and HEAD commands.
This serves files from the current directory and any of its
subdirectories. The MIME type for files is determined by
calling the .guess_type() method.
The GET and HEAD requests are identical except that the HEAD
request omits the actual contents of the file.
"""
server_version = "SimpleHTTP/" + __version__
def do_GET(self):
"""Serve a GET request."""
f = self.send_head()
if f:
try:
self.copyfile(f, self.wfile)
finally:
f.close()
def do_HEAD(self):
"""Serve a HEAD request."""
f = self.send_head()
if f:
f.close()
def send_head(self):
"""Common code for GET and HEAD commands.
This sends the response code and MIME headers.
Return value is either a file object (which has to be copied
to the outputfile by the caller unless the command was HEAD,
and must be closed by the caller under all circumstances), or
None, in which case the caller has nothing further to do.
"""
path = self.translate_path(self.path)
f = None
if os.path.isdir(path):
if not self.path.endswith('/'):
# redirect browser - doing basically what apache does
self.send_response(301)
self.send_header("Location", self.path + "/")
self.end_headers()
return None
for index in "index.html", "index.htm":
index = os.path.join(path, index)
if os.path.exists(index):
path = index
break
else:
return self.list_directory(path)
ctype = self.guess_type(path)
try:
# Always read in binary mode. Opening files in text mode may cause
# newline translations, making the actual size of the content
# transmitted *less* than the content-length!
f = open(path, 'rb')
except IOError:
self.send_error(404, "File not found")
return None
try:
self.send_response(200)
self.send_header("Content-type", ctype)
fs = os.fstat(f.fileno())
self.send_header("Content-Length", str(fs[6]))
self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
self.end_headers()
return f
except:
f.close()
raise
def list_directory(self, path):
"""Helper to produce a directory listing (absent index.html).
Return value is either a file object, or None (indicating an
error). In either case, the headers are sent, making the
interface the same as for send_head().
"""
try:
list = os.listdir(path)
except os.error:
self.send_error(404, "No permission to list directory")
return None
list.sort(key=lambda a: a.lower())
f = StringIO()
displaypath = cgi.escape(urllib.unquote(self.path))
f.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">')
f.write("<html>\n<title>Directory listing for %s</title>\n" % displaypath)
f.write("<body>\n<h2>Directory listing for %s</h2>\n" % displaypath)
f.write("<hr>\n<ul>\n")
for name in list:
fullname = os.path.join(path, name)
displayname = linkname = name
# Append / for directories or @ for symbolic links
if os.path.isdir(fullname):
displayname = name + "/"
linkname = name + "/"
if os.path.islink(fullname):
displayname = name + "@"
# Note: a link to a directory displays with @ and links with /
f.write('<li><a href="%s">%s</a>\n'
% (urllib.quote(linkname), cgi.escape(displayname)))
f.write("</ul>\n<hr>\n</body>\n</html>\n")
length = f.tell()
f.seek(0)
self.send_response(200)
encoding = sys.getfilesystemencoding()
self.send_header("Content-type", "text/html; charset=%s" % encoding)
self.send_header("Content-Length", str(length))
self.end_headers()
return f
def translate_path(self, path):
"""Translate a /-separated PATH to the local filename syntax.
Components that mean special things to the local file system
(e.g. drive or directory names) are ignored. (XXX They should
probably be diagnosed.)
"""
# abandon query parameters
path = path.split('?',1)[0]
path = path.split('#',1)[0]
# Don't forget explicit trailing slash when normalizing. Issue17324
trailing_slash = path.rstrip().endswith('/')
path = posixpath.normpath(urllib.unquote(path))
words = path.split('/')
words = filter(None, words)
path = os.getcwd()
for word in words:
drive, word = os.path.splitdrive(word)
head, word = os.path.split(word)
if word in (os.curdir, os.pardir): continue
path = os.path.join(path, word)
if trailing_slash:
path += '/'
return path
def copyfile(self, source, outputfile):
"""Copy all data between two file objects.
The SOURCE argument is a file object open for reading
(or anything with a read() method) and the DESTINATION
argument is a file object open for writing (or
anything with a write() method).
The only reason for overriding this would be to change
the block size or perhaps to replace newlines by CRLF
-- note however that this the default server uses this
to copy binary data as well.
"""
shutil.copyfileobj(source, outputfile)
def guess_type(self, path):
"""Guess the type of a file.
Argument is a PATH (a filename).
Return value is a string of the form type/subtype,
usable for a MIME Content-type header.
The default implementation looks the file's extension
up in the table self.extensions_map, using application/octet-stream
as a default; however it would be permissible (if
slow) to look inside the data to make a better guess.
"""
base, ext = posixpath.splitext(path)
if ext in self.extensions_map:
return self.extensions_map[ext]
ext = ext.lower()
if ext in self.extensions_map:
return self.extensions_map[ext]
else:
return self.extensions_map['']
if not mimetypes.inited:
mimetypes.init() # try to read system mime.types
extensions_map = mimetypes.types_map.copy()
extensions_map.update({
'': 'application/octet-stream', # Default
'.py': 'text/plain',
'.c': 'text/plain',
'.h': 'text/plain',
})
def test(HandlerClass = SimpleHTTPRequestHandler,
ServerClass = BaseHTTPServer.HTTPServer):
BaseHTTPServer.test(HandlerClass, ServerClass)
if __name__ == '__main__':
test()
|
gpl-2.0
|
[
624,
3184,
3101,
7146,
14,
199,
199,
2765,
859,
14723,
641,
3523,
14938,
701,
18234,
314,
4465,
9576,
199,
460,
13053,
4145,
315,
282,
28092,
590,
23669,
6688,
30800,
14,
199,
199,
624,
421,
199,
363,
1023,
363,
275,
298,
16,
14,
22,
2,
199,
199,
363,
452,
363,
275,
2097,
3184,
23518,
937,
199,
199,
646,
747,
199,
646,
15454,
199,
646,
3523,
14938,
199,
646,
4011,
199,
646,
16004,
199,
646,
984,
199,
646,
5145,
199,
646,
13290,
199,
893,
26,
272,
687,
15073,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5228,
492,
5228,
421,
199,
533,
5870,
23518,
8,
1563,
14938,
14,
1563,
23518,
304,
339,
408,
3184,
3101,
1056,
3016,
543,
9576,
436,
13053,
3718,
14,
339,
961,
23739,
1584,
687,
314,
1453,
2082,
436,
1263,
402,
2399,
272,
24799,
14,
221,
710,
14735,
730,
367,
1584,
365,
12037,
701,
272,
6358,
314,
1275,
11636,
63,
466,
342,
1083,
14,
339,
710,
9576,
436,
13053,
4145,
787,
13130,
871,
626,
314,
13053,
272,
1056,
19413,
83,
314,
3503,
4072,
402,
314,
570,
14,
339,
408,
339,
1654,
63,
1023,
275,
298,
3184,
2856,
6687,
435,
636,
1023,
363,
339,
347,
886,
63,
2970,
8,
277,
304,
267,
408,
1505,
432,
282,
9576,
1056,
1041,
267,
289,
275,
291,
14,
2254,
63,
2993,
342,
267,
340,
289,
26,
288,
862,
26,
355,
291,
14,
21997,
8,
70,
12,
291,
14,
18076,
9,
288,
3753,
26,
355,
289,
14,
1600,
342,
339,
347,
886,
63,
5211,
8,
277,
304,
267,
408,
1505,
432,
282,
13053,
1056,
1041,
267,
289,
275,
291,
14,
2254,
63,
2993,
342,
267,
340,
289,
26,
288,
289,
14,
1600,
342,
339,
347,
3222,
63,
2993,
8,
277,
304,
267,
408,
7844,
1233,
367,
9576,
436,
13053,
3718,
14,
398,
961,
16178,
314,
1177,
1233,
436,
14735,
2323,
14,
398,
1432,
574,
365,
1902,
282,
570,
909,
334,
6777,
965,
370,
506,
8876,
267,
370,
314,
32513,
701,
314,
8025,
7444,
314,
1414,
1990,
13053,
12,
267,
436,
1471,
506,
6876,
701,
314,
8025,
1334,
1006,
27027,
611,
83,
395,
503,
267,
488,
12,
315,
1314,
1930,
314,
8025,
965,
6548,
9848,
370,
886,
14,
398,
408,
267,
931,
275,
291,
14,
5275,
63,
515,
8,
277,
14,
515,
9,
267,
289,
275,
488,
267,
340,
747,
14,
515,
14,
6027,
8,
515,
304,
288,
340,
440,
291,
14,
515,
14,
4130,
18265,
355,
327,
4660,
7042,
446,
9689,
26014,
4052,
17098,
1630,
355,
291,
14,
2254,
63,
1310,
8,
8507,
9,
355,
291,
14,
2254,
63,
1291,
480,
6592,
401,
291,
14,
515,
435,
3286,
531,
355,
291,
14,
500,
63,
2139,
342,
355,
372,
488,
288,
367,
1478,
315,
298,
1080,
14,
1360,
401,
298,
1080,
14,
15575,
582,
355,
1478,
275,
747,
14,
515,
14,
904,
8,
515,
12,
1478,
9,
355,
340,
747,
14,
515,
14,
2444,
8,
1080,
304,
490,
931,
275,
1478,
490,
2059,
288,
587,
26,
355,
372,
291,
14,
513,
63,
3619,
8,
515,
9,
267,
16360,
275,
291,
14,
11636,
63,
466,
8,
515,
9,
267,
862,
26,
288,
327,
16763,
1586,
315,
3366,
818,
14,
3232,
316,
1584,
315,
1318,
818,
1443,
7675,
288,
327,
8057,
15547,
12,
10663,
314,
3503,
1568,
402,
314,
1564,
288,
327,
29818,
627,
2003,
10,
2419,
314,
1564,
13,
1267,
1,
288,
289,
275,
1551,
8,
515,
12,
283,
4848,
358,
267,
871,
5925,
26,
288,
291,
14,
2254,
63,
705,
8,
5188,
12,
298,
1173,
440,
1911,
531,
288,
372,
488,
267,
862,
26,
288,
291,
14,
2254,
63,
1310,
8,
1840,
9,
288,
291,
14,
2254,
63,
1291,
480,
2714,
13,
466,
401,
16360,
9,
288,
7449,
275,
747,
14,
32127,
8,
70,
14,
9843,
1012,
288,
291,
14,
2254,
63,
1291,
480,
2714,
13,
4625,
401,
620,
8,
2319,
59,
22,
2459,
288,
291,
14,
2254,
63,
1291,
480,
6090,
13,
11911,
401,
291,
14,
602,
63,
521,
63,
875,
8,
2319,
14,
270,
63,
8180,
430,
288,
291,
14,
500,
63,
2139,
342,
288,
372,
289,
267,
871,
26,
288,
289,
14,
1600,
342,
288,
746,
339,
347,
769,
63,
3619,
8,
277,
12,
931,
304,
267,
408,
4433,
370,
7389,
282,
2082,
13778,
334,
5575,
1478,
14,
1360,
680,
398,
1432,
574,
365,
1902,
282,
570,
909,
12,
503,
488,
334,
13363,
1958,
376,
267,
1125,
680,
221,
1010,
1902,
1930,
12,
314,
2323,
787,
4847,
12,
10663,
314,
267,
3217,
314,
2011,
465,
367,
3222,
63,
2993,
1252,
398,
408,
267,
862,
26,
288,
769,
275,
747,
14,
7374,
8,
515,
9,
267,
871,
747,
14,
705,
26,
288,
291,
14,
2254,
63,
705,
8,
5188,
12,
298,
1944,
4983,
370,
769,
2082,
531,
288,
372,
488,
267,
769,
14,
3191,
8,
498,
29,
2734,
282,
26,
282,
14,
2325,
1012,
267,
289,
275,
5228,
342,
267,
2929,
515,
275,
16004,
14,
3765,
8,
4078,
14,
12240,
8,
277,
14,
515,
430,
267,
289,
14,
952,
4827,
1,
16556,
3517,
21755,
21486,
55,
19,
35,
501,
21156,
4163,
650,
14,
18,
21789,
501,
742,
1743,
358,
267,
289,
14,
952,
6757,
1360,
3072,
78,
28,
1213,
30,
6231,
13778,
367,
450,
83,
1108,
1213,
3072,
78,
2,
450,
2929,
515,
9,
267,
289,
14,
952,
6757,
2030,
3072,
78,
28,
72,
18,
30,
6231,
13778,
367,
450,
83,
1108,
72,
18,
3072,
78,
2,
450,
2929,
515,
9,
267,
289,
14,
952,
6757,
6271,
3072,
78,
28,
348,
3072,
78,
531,
267,
367,
536,
315,
769,
26,
288,
11064,
275,
747,
14,
515,
14,
904,
8,
515,
12,
536,
9,
288,
2929,
354,
275,
2142,
354,
275,
536,
288,
327,
18726,
1182,
367,
6602,
503,
768,
367,
13673,
6220,
288,
340,
747,
14,
515,
14,
6027,
8,
9930,
304,
355,
2929,
354,
275,
536,
435,
10609,
355,
2142,
354,
275,
536,
435,
10609,
288,
340,
747,
14,
515,
14,
20719,
8,
9930,
304,
355,
2929,
354,
275,
536,
435,
9244,
2,
355,
327,
3390,
26,
282,
2142,
370,
282,
2082,
17561,
543,
768,
436,
6220,
543,
1182,
288,
289,
14,
952,
4827,
317,
2535,
65,
4369,
5961,
83,
14423,
83,
1108,
65,
3072,
78,
7
] |
[
3184,
3101,
7146,
14,
199,
199,
2765,
859,
14723,
641,
3523,
14938,
701,
18234,
314,
4465,
9576,
199,
460,
13053,
4145,
315,
282,
28092,
590,
23669,
6688,
30800,
14,
199,
199,
624,
421,
199,
363,
1023,
363,
275,
298,
16,
14,
22,
2,
199,
199,
363,
452,
363,
275,
2097,
3184,
23518,
937,
199,
199,
646,
747,
199,
646,
15454,
199,
646,
3523,
14938,
199,
646,
4011,
199,
646,
16004,
199,
646,
984,
199,
646,
5145,
199,
646,
13290,
199,
893,
26,
272,
687,
15073,
492,
5228,
199,
2590,
3545,
26,
272,
687,
5228,
492,
5228,
421,
199,
533,
5870,
23518,
8,
1563,
14938,
14,
1563,
23518,
304,
339,
408,
3184,
3101,
1056,
3016,
543,
9576,
436,
13053,
3718,
14,
339,
961,
23739,
1584,
687,
314,
1453,
2082,
436,
1263,
402,
2399,
272,
24799,
14,
221,
710,
14735,
730,
367,
1584,
365,
12037,
701,
272,
6358,
314,
1275,
11636,
63,
466,
342,
1083,
14,
339,
710,
9576,
436,
13053,
4145,
787,
13130,
871,
626,
314,
13053,
272,
1056,
19413,
83,
314,
3503,
4072,
402,
314,
570,
14,
339,
408,
339,
1654,
63,
1023,
275,
298,
3184,
2856,
6687,
435,
636,
1023,
363,
339,
347,
886,
63,
2970,
8,
277,
304,
267,
408,
1505,
432,
282,
9576,
1056,
1041,
267,
289,
275,
291,
14,
2254,
63,
2993,
342,
267,
340,
289,
26,
288,
862,
26,
355,
291,
14,
21997,
8,
70,
12,
291,
14,
18076,
9,
288,
3753,
26,
355,
289,
14,
1600,
342,
339,
347,
886,
63,
5211,
8,
277,
304,
267,
408,
1505,
432,
282,
13053,
1056,
1041,
267,
289,
275,
291,
14,
2254,
63,
2993,
342,
267,
340,
289,
26,
288,
289,
14,
1600,
342,
339,
347,
3222,
63,
2993,
8,
277,
304,
267,
408,
7844,
1233,
367,
9576,
436,
13053,
3718,
14,
398,
961,
16178,
314,
1177,
1233,
436,
14735,
2323,
14,
398,
1432,
574,
365,
1902,
282,
570,
909,
334,
6777,
965,
370,
506,
8876,
267,
370,
314,
32513,
701,
314,
8025,
7444,
314,
1414,
1990,
13053,
12,
267,
436,
1471,
506,
6876,
701,
314,
8025,
1334,
1006,
27027,
611,
83,
395,
503,
267,
488,
12,
315,
1314,
1930,
314,
8025,
965,
6548,
9848,
370,
886,
14,
398,
408,
267,
931,
275,
291,
14,
5275,
63,
515,
8,
277,
14,
515,
9,
267,
289,
275,
488,
267,
340,
747,
14,
515,
14,
6027,
8,
515,
304,
288,
340,
440,
291,
14,
515,
14,
4130,
18265,
355,
327,
4660,
7042,
446,
9689,
26014,
4052,
17098,
1630,
355,
291,
14,
2254,
63,
1310,
8,
8507,
9,
355,
291,
14,
2254,
63,
1291,
480,
6592,
401,
291,
14,
515,
435,
3286,
531,
355,
291,
14,
500,
63,
2139,
342,
355,
372,
488,
288,
367,
1478,
315,
298,
1080,
14,
1360,
401,
298,
1080,
14,
15575,
582,
355,
1478,
275,
747,
14,
515,
14,
904,
8,
515,
12,
1478,
9,
355,
340,
747,
14,
515,
14,
2444,
8,
1080,
304,
490,
931,
275,
1478,
490,
2059,
288,
587,
26,
355,
372,
291,
14,
513,
63,
3619,
8,
515,
9,
267,
16360,
275,
291,
14,
11636,
63,
466,
8,
515,
9,
267,
862,
26,
288,
327,
16763,
1586,
315,
3366,
818,
14,
3232,
316,
1584,
315,
1318,
818,
1443,
7675,
288,
327,
8057,
15547,
12,
10663,
314,
3503,
1568,
402,
314,
1564,
288,
327,
29818,
627,
2003,
10,
2419,
314,
1564,
13,
1267,
1,
288,
289,
275,
1551,
8,
515,
12,
283,
4848,
358,
267,
871,
5925,
26,
288,
291,
14,
2254,
63,
705,
8,
5188,
12,
298,
1173,
440,
1911,
531,
288,
372,
488,
267,
862,
26,
288,
291,
14,
2254,
63,
1310,
8,
1840,
9,
288,
291,
14,
2254,
63,
1291,
480,
2714,
13,
466,
401,
16360,
9,
288,
7449,
275,
747,
14,
32127,
8,
70,
14,
9843,
1012,
288,
291,
14,
2254,
63,
1291,
480,
2714,
13,
4625,
401,
620,
8,
2319,
59,
22,
2459,
288,
291,
14,
2254,
63,
1291,
480,
6090,
13,
11911,
401,
291,
14,
602,
63,
521,
63,
875,
8,
2319,
14,
270,
63,
8180,
430,
288,
291,
14,
500,
63,
2139,
342,
288,
372,
289,
267,
871,
26,
288,
289,
14,
1600,
342,
288,
746,
339,
347,
769,
63,
3619,
8,
277,
12,
931,
304,
267,
408,
4433,
370,
7389,
282,
2082,
13778,
334,
5575,
1478,
14,
1360,
680,
398,
1432,
574,
365,
1902,
282,
570,
909,
12,
503,
488,
334,
13363,
1958,
376,
267,
1125,
680,
221,
1010,
1902,
1930,
12,
314,
2323,
787,
4847,
12,
10663,
314,
267,
3217,
314,
2011,
465,
367,
3222,
63,
2993,
1252,
398,
408,
267,
862,
26,
288,
769,
275,
747,
14,
7374,
8,
515,
9,
267,
871,
747,
14,
705,
26,
288,
291,
14,
2254,
63,
705,
8,
5188,
12,
298,
1944,
4983,
370,
769,
2082,
531,
288,
372,
488,
267,
769,
14,
3191,
8,
498,
29,
2734,
282,
26,
282,
14,
2325,
1012,
267,
289,
275,
5228,
342,
267,
2929,
515,
275,
16004,
14,
3765,
8,
4078,
14,
12240,
8,
277,
14,
515,
430,
267,
289,
14,
952,
4827,
1,
16556,
3517,
21755,
21486,
55,
19,
35,
501,
21156,
4163,
650,
14,
18,
21789,
501,
742,
1743,
358,
267,
289,
14,
952,
6757,
1360,
3072,
78,
28,
1213,
30,
6231,
13778,
367,
450,
83,
1108,
1213,
3072,
78,
2,
450,
2929,
515,
9,
267,
289,
14,
952,
6757,
2030,
3072,
78,
28,
72,
18,
30,
6231,
13778,
367,
450,
83,
1108,
72,
18,
3072,
78,
2,
450,
2929,
515,
9,
267,
289,
14,
952,
6757,
6271,
3072,
78,
28,
348,
3072,
78,
531,
267,
367,
536,
315,
769,
26,
288,
11064,
275,
747,
14,
515,
14,
904,
8,
515,
12,
536,
9,
288,
2929,
354,
275,
2142,
354,
275,
536,
288,
327,
18726,
1182,
367,
6602,
503,
768,
367,
13673,
6220,
288,
340,
747,
14,
515,
14,
6027,
8,
9930,
304,
355,
2929,
354,
275,
536,
435,
10609,
355,
2142,
354,
275,
536,
435,
10609,
288,
340,
747,
14,
515,
14,
20719,
8,
9930,
304,
355,
2929,
354,
275,
536,
435,
9244,
2,
355,
327,
3390,
26,
282,
2142,
370,
282,
2082,
17561,
543,
768,
436,
6220,
543,
1182,
288,
289,
14,
952,
4827,
317,
2535,
65,
4369,
5961,
83,
14423,
83,
1108,
65,
3072,
78,
7,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
fafaman/django
|
tests/template_tests/syntax_tests/test_for.py
|
45
|
8516
|
from django.template import TemplateSyntaxError
from django.test import SimpleTestCase, ignore_warnings
from django.utils.deprecation import RemovedInDjango110Warning
from ..utils import setup
class ForTagTests(SimpleTestCase):
libraries = {'custom': 'template_tests.templatetags.custom'}
@setup({'for-tag01': '{% for val in values %}{{ val }}{% endfor %}'})
def test_for_tag01(self):
output = self.engine.render_to_string('for-tag01', {'values': [1, 2, 3]})
self.assertEqual(output, '123')
@setup({'for-tag02': '{% for val in values reversed %}{{ val }}{% endfor %}'})
def test_for_tag02(self):
output = self.engine.render_to_string('for-tag02', {'values': [1, 2, 3]})
self.assertEqual(output, '321')
@setup({'for-tag-vars01': '{% for val in values %}{{ forloop.counter }}{% endfor %}'})
def test_for_tag_vars01(self):
output = self.engine.render_to_string('for-tag-vars01', {'values': [6, 6, 6]})
self.assertEqual(output, '123')
@setup({'for-tag-vars02': '{% for val in values %}{{ forloop.counter0 }}{% endfor %}'})
def test_for_tag_vars02(self):
output = self.engine.render_to_string('for-tag-vars02', {'values': [6, 6, 6]})
self.assertEqual(output, '012')
@setup({'for-tag-vars03': '{% for val in values %}{{ forloop.revcounter }}{% endfor %}'})
def test_for_tag_vars03(self):
output = self.engine.render_to_string('for-tag-vars03', {'values': [6, 6, 6]})
self.assertEqual(output, '321')
@setup({'for-tag-vars04': '{% for val in values %}{{ forloop.revcounter0 }}{% endfor %}'})
def test_for_tag_vars04(self):
output = self.engine.render_to_string('for-tag-vars04', {'values': [6, 6, 6]})
self.assertEqual(output, '210')
@setup({'for-tag-vars05': '{% for val in values %}'
'{% if forloop.first %}f{% else %}x{% endif %}{% endfor %}'})
def test_for_tag_vars05(self):
output = self.engine.render_to_string('for-tag-vars05', {'values': [6, 6, 6]})
self.assertEqual(output, 'fxx')
@setup({'for-tag-vars06': '{% for val in values %}'
'{% if forloop.last %}l{% else %}x{% endif %}{% endfor %}'})
def test_for_tag_vars06(self):
output = self.engine.render_to_string('for-tag-vars06', {'values': [6, 6, 6]})
self.assertEqual(output, 'xxl')
@setup({'for-tag-unpack01': '{% for key,value in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack01(self):
output = self.engine.render_to_string('for-tag-unpack01', {'items': (('one', 1), ('two', 2))})
self.assertEqual(output, 'one:1/two:2/')
@setup({'for-tag-unpack03': '{% for key, value in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack03(self):
output = self.engine.render_to_string('for-tag-unpack03', {'items': (('one', 1), ('two', 2))})
self.assertEqual(output, 'one:1/two:2/')
@setup({'for-tag-unpack04': '{% for key , value in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack04(self):
output = self.engine.render_to_string('for-tag-unpack04', {'items': (('one', 1), ('two', 2))})
self.assertEqual(output, 'one:1/two:2/')
@setup({'for-tag-unpack05': '{% for key ,value in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack05(self):
output = self.engine.render_to_string('for-tag-unpack05', {'items': (('one', 1), ('two', 2))})
self.assertEqual(output, 'one:1/two:2/')
@setup({'for-tag-unpack06': '{% for key value in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack06(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('for-tag-unpack06', {'items': (('one', 1), ('two', 2))})
@setup({'for-tag-unpack07': '{% for key,,value in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack07(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('for-tag-unpack07', {'items': (('one', 1), ('two', 2))})
@setup({'for-tag-unpack08': '{% for key,value, in items %}{{ key }}:{{ value }}/{% endfor %}'})
def test_for_tag_unpack08(self):
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('for-tag-unpack08', {'items': (('one', 1), ('two', 2))})
@setup({'for-tag-unpack09': '{% for val in items %}{{ val.0 }}:{{ val.1 }}/{% endfor %}'})
def test_for_tag_unpack09(self):
"""
Ensure that a single loopvar doesn't truncate the list in val.
"""
output = self.engine.render_to_string('for-tag-unpack09', {'items': (('one', 1), ('two', 2))})
self.assertEqual(output, 'one:1/two:2/')
@setup({'for-tag-unpack13': '{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}'})
def test_for_tag_unpack13(self):
output = self.engine.render_to_string(
'for-tag-unpack13', {'items': (('one', 1, 'carrot'), ('two', 2, 'cheese'))}
)
if self.engine.string_if_invalid:
self.assertEqual(output, 'one:1,carrot/two:2,cheese/')
else:
self.assertEqual(output, 'one:1,carrot/two:2,cheese/')
@setup({'for-tag-empty01': '{% for val in values %}{{ val }}{% empty %}empty text{% endfor %}'})
def test_for_tag_empty01(self):
output = self.engine.render_to_string('for-tag-empty01', {'values': [1, 2, 3]})
self.assertEqual(output, '123')
@setup({'for-tag-empty02': '{% for val in values %}{{ val }}{% empty %}values array empty{% endfor %}'})
def test_for_tag_empty02(self):
output = self.engine.render_to_string('for-tag-empty02', {'values': []})
self.assertEqual(output, 'values array empty')
@setup({'for-tag-empty03': '{% for val in values %}'
'{{ val }}{% empty %}values array not found{% endfor %}'})
def test_for_tag_empty03(self):
output = self.engine.render_to_string('for-tag-empty03')
self.assertEqual(output, 'values array not found')
@setup({'for-tag-filter-ws': "{% load custom %}{% for x in s|noop:'x y' %}{{ x }}{% endfor %}"})
def test_for_tag_filter_ws(self):
"""
#19882
"""
output = self.engine.render_to_string('for-tag-filter-ws', {'s': 'abc'})
self.assertEqual(output, 'abc')
# These tests raise deprecation warnings and will raise an exception
# in Django 1.10. The existing behavior is silent truncation if the
# length of loopvars differs to the length of each set of items.
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'for-tag-unpack10': '{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}'})
def test_for_tag_unpack10(self):
output = self.engine.render_to_string(
'for-tag-unpack10',
{'items': (('one', 1, 'carrot'), ('two', 2, 'orange'))},
)
self.assertEqual(output, 'one:1/two:2/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'for-tag-unpack11': '{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}'})
def test_for_tag_unpack11(self):
output = self.engine.render_to_string(
'for-tag-unpack11',
{'items': (('one', 1), ('two', 2))},
)
if self.engine.string_if_invalid:
self.assertEqual(output, 'one:1,INVALID/two:2,INVALID/')
else:
self.assertEqual(output, 'one:1,/two:2,/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'for-tag-unpack12': '{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}'})
def test_for_tag_unpack12(self):
output = self.engine.render_to_string(
'for-tag-unpack12',
{'items': (('one', 1, 'carrot'), ('two', 2))}
)
if self.engine.string_if_invalid:
self.assertEqual(output, 'one:1,carrot/two:2,INVALID/')
else:
self.assertEqual(output, 'one:1,carrot/two:2,/')
@ignore_warnings(category=RemovedInDjango110Warning)
@setup({'for-tag-unpack14': '{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}'})
def test_for_tag_unpack14(self):
output = self.engine.render_to_string('for-tag-unpack14', {'items': (1, 2)})
if self.engine.string_if_invalid:
self.assertEqual(output, 'INVALID:INVALID/INVALID:INVALID/')
else:
self.assertEqual(output, ':/:/')
|
bsd-3-clause
|
[
504,
1639,
14,
1160,
492,
17762,
199,
504,
1639,
14,
396,
492,
24424,
12,
3686,
63,
5451,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
199,
504,
2508,
1208,
492,
3272,
421,
199,
533,
2104,
1931,
2925,
8,
17968,
304,
272,
8363,
275,
791,
4229,
356,
283,
1160,
63,
2219,
14,
1160,
2969,
14,
4229,
936,
339,
768,
2758,
3252,
509,
13,
1450,
614,
356,
12100,
367,
1139,
315,
1338,
17337,
1139,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
614,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
614,
297,
791,
1459,
356,
359,
17,
12,
499,
12,
650,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
4288,
358,
339,
768,
2758,
3252,
509,
13,
1450,
996,
356,
12100,
367,
1139,
315,
1338,
10822,
17337,
1139,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
996,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
996,
297,
791,
1459,
356,
359,
17,
12,
499,
12,
650,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
12638,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
614,
356,
12100,
367,
1139,
315,
1338,
17337,
367,
3813,
14,
5337,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
614,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
614,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
4288,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
996,
356,
12100,
367,
1139,
315,
1338,
17337,
367,
3813,
14,
5337,
16,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
996,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
996,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
11533,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
1644,
356,
12100,
367,
1139,
315,
1338,
17337,
367,
3813,
14,
4964,
5337,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
1644,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
1644,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
12638,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
966,
356,
12100,
367,
1139,
315,
1338,
17337,
367,
3813,
14,
4964,
5337,
16,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
966,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
966,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
12725,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
1717,
356,
12100,
367,
1139,
315,
1338,
25509,
2892,
12100,
340,
367,
3813,
14,
2246,
3674,
70,
3996,
587,
3674,
88,
3996,
14454,
12760,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
1717,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
1717,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
70,
2154,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
1690,
356,
12100,
367,
1139,
315,
1338,
25509,
2892,
12100,
340,
367,
3813,
14,
2019,
3674,
76,
3996,
587,
3674,
88,
3996,
14454,
12760,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
1690,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
1690,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
2154,
76,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
5301,
614,
356,
12100,
367,
790,
12,
585,
315,
2974,
17337,
790,
3586,
26,
3638,
574,
3586,
15,
3996,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
5301,
614,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
5301,
614,
297,
791,
1744,
356,
13636,
368,
297,
413,
395,
661,
5601,
297,
499,
430,
1552,
267,
291,
14,
629,
8,
1199,
12,
283,
368,
26,
17,
15,
5601,
26,
18,
6217,
339,
768,
2758,
3252,
509,
13,
1450,
13,
5301,
1644,
356,
12100,
367,
790,
12,
574,
315,
2974,
17337,
790,
3586,
26,
3638,
574,
3586,
15,
3996,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
5301,
1644,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
5301,
1644,
297,
791,
1744,
356,
13636,
368,
297,
413,
395,
661,
5601,
297,
499,
430,
1552,
267,
291,
14,
629,
8,
1199,
12,
283,
368,
26,
17,
15,
5601,
26,
18,
6217,
339,
768,
2758,
3252,
509,
13,
1450,
13,
5301,
966,
356,
12100,
367,
790,
2360,
574,
315,
2974,
17337,
790,
3586,
26,
3638,
574,
3586,
15,
3996,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
5301,
966,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
5301,
966,
297,
791,
1744,
356,
13636,
368,
297,
413,
395,
661,
5601,
297,
499,
430,
1552,
267,
291,
14,
629,
8,
1199,
12,
283,
368,
26,
17,
15,
5601,
26,
18,
6217,
339,
768,
2758,
3252,
509,
13,
1450,
13,
5301,
1717,
356,
12100,
367,
790,
2360,
585,
315,
2974,
17337,
790,
3586,
26,
3638,
574,
3586,
15,
3996,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
5301,
1717,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
5301,
1717
] |
[
1639,
14,
1160,
492,
17762,
199,
504,
1639,
14,
396,
492,
24424,
12,
3686,
63,
5451,
199,
504,
1639,
14,
1208,
14,
15383,
492,
23687,
6019,
3849,
199,
199,
504,
2508,
1208,
492,
3272,
421,
199,
533,
2104,
1931,
2925,
8,
17968,
304,
272,
8363,
275,
791,
4229,
356,
283,
1160,
63,
2219,
14,
1160,
2969,
14,
4229,
936,
339,
768,
2758,
3252,
509,
13,
1450,
614,
356,
12100,
367,
1139,
315,
1338,
17337,
1139,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
614,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
614,
297,
791,
1459,
356,
359,
17,
12,
499,
12,
650,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
4288,
358,
339,
768,
2758,
3252,
509,
13,
1450,
996,
356,
12100,
367,
1139,
315,
1338,
10822,
17337,
1139,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
996,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
996,
297,
791,
1459,
356,
359,
17,
12,
499,
12,
650,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
12638,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
614,
356,
12100,
367,
1139,
315,
1338,
17337,
367,
3813,
14,
5337,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
614,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
614,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
4288,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
996,
356,
12100,
367,
1139,
315,
1338,
17337,
367,
3813,
14,
5337,
16,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
996,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
996,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
11533,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
1644,
356,
12100,
367,
1139,
315,
1338,
17337,
367,
3813,
14,
4964,
5337,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
1644,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
1644,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
12638,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
966,
356,
12100,
367,
1139,
315,
1338,
17337,
367,
3813,
14,
4964,
5337,
16,
20104,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
966,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
966,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
12725,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
1717,
356,
12100,
367,
1139,
315,
1338,
25509,
2892,
12100,
340,
367,
3813,
14,
2246,
3674,
70,
3996,
587,
3674,
88,
3996,
14454,
12760,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
1717,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
1717,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
70,
2154,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
2936,
1690,
356,
12100,
367,
1139,
315,
1338,
25509,
2892,
12100,
340,
367,
3813,
14,
2019,
3674,
76,
3996,
587,
3674,
88,
3996,
14454,
12760,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
2936,
1690,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
2936,
1690,
297,
791,
1459,
356,
359,
22,
12,
1227,
12,
1227,
13412,
267,
291,
14,
629,
8,
1199,
12,
283,
2154,
76,
358,
339,
768,
2758,
3252,
509,
13,
1450,
13,
5301,
614,
356,
12100,
367,
790,
12,
585,
315,
2974,
17337,
790,
3586,
26,
3638,
574,
3586,
15,
3996,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
5301,
614,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
5301,
614,
297,
791,
1744,
356,
13636,
368,
297,
413,
395,
661,
5601,
297,
499,
430,
1552,
267,
291,
14,
629,
8,
1199,
12,
283,
368,
26,
17,
15,
5601,
26,
18,
6217,
339,
768,
2758,
3252,
509,
13,
1450,
13,
5301,
1644,
356,
12100,
367,
790,
12,
574,
315,
2974,
17337,
790,
3586,
26,
3638,
574,
3586,
15,
3996,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
5301,
1644,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
5301,
1644,
297,
791,
1744,
356,
13636,
368,
297,
413,
395,
661,
5601,
297,
499,
430,
1552,
267,
291,
14,
629,
8,
1199,
12,
283,
368,
26,
17,
15,
5601,
26,
18,
6217,
339,
768,
2758,
3252,
509,
13,
1450,
13,
5301,
966,
356,
12100,
367,
790,
2360,
574,
315,
2974,
17337,
790,
3586,
26,
3638,
574,
3586,
15,
3996,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
5301,
966,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
5301,
966,
297,
791,
1744,
356,
13636,
368,
297,
413,
395,
661,
5601,
297,
499,
430,
1552,
267,
291,
14,
629,
8,
1199,
12,
283,
368,
26,
17,
15,
5601,
26,
18,
6217,
339,
768,
2758,
3252,
509,
13,
1450,
13,
5301,
1717,
356,
12100,
367,
790,
2360,
585,
315,
2974,
17337,
790,
3586,
26,
3638,
574,
3586,
15,
3996,
17273,
17776,
272,
347,
511,
63,
509,
63,
1450,
63,
5301,
1717,
8,
277,
304,
267,
1072,
275,
291,
14,
3908,
14,
3352,
63,
475,
63,
875,
360,
509,
13,
1450,
13,
5301,
1717,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
pdonadeo/django-oscar
|
src/oscar/apps/checkout/forms.py
|
27
|
2926
|
from django import forms
from oscar.core.loading import get_model
from django.contrib.auth.forms import AuthenticationForm
from django.utils.translation import ugettext_lazy as _
from oscar.apps.address.forms import AbstractAddressForm
from oscar.apps.customer.utils import normalise_email
from oscar.core.compat import get_user_model
from oscar.views.generic import PhoneNumberMixin
User = get_user_model()
Country = get_model('address', 'Country')
class ShippingAddressForm(PhoneNumberMixin, AbstractAddressForm):
def __init__(self, *args, **kwargs):
super(ShippingAddressForm, self).__init__(*args, **kwargs)
self.adjust_country_field()
def adjust_country_field(self):
countries = Country._default_manager.filter(
is_shipping_country=True)
# No need to show country dropdown if there is only one option
if len(countries) == 1:
self.fields.pop('country', None)
self.instance.country = countries[0]
else:
self.fields['country'].queryset = countries
self.fields['country'].empty_label = None
class Meta:
model = get_model('order', 'shippingaddress')
fields = [
'title', 'first_name', 'last_name',
'line1', 'line2', 'line3', 'line4',
'state', 'postcode', 'country',
'phone_number', 'notes',
]
class GatewayForm(AuthenticationForm):
username = forms.EmailField(label=_("My email address is"))
GUEST, NEW, EXISTING = 'anonymous', 'new', 'existing'
CHOICES = (
(GUEST, _('I am a new customer and want to checkout as a guest')),
(NEW, _('I am a new customer and want to create an account '
'before checking out')),
(EXISTING, _('I am a returning customer, and my password is')))
options = forms.ChoiceField(widget=forms.widgets.RadioSelect,
choices=CHOICES, initial=GUEST)
def clean_username(self):
return normalise_email(self.cleaned_data['username'])
def clean(self):
if self.is_guest_checkout() or self.is_new_account_checkout():
if 'password' in self.errors:
del self.errors['password']
if 'username' in self.cleaned_data:
email = normalise_email(self.cleaned_data['username'])
if User._default_manager.filter(email__iexact=email).exists():
msg = "A user with that email address already exists"
self._errors["username"] = self.error_class([msg])
return self.cleaned_data
return super(GatewayForm, self).clean()
def is_guest_checkout(self):
return self.cleaned_data.get('options', None) == self.GUEST
def is_new_account_checkout(self):
return self.cleaned_data.get('options', None) == self.NEW
# The BillingAddress form is in oscar.apps.payment.forms
|
bsd-3-clause
|
[
504,
1639,
492,
4513,
199,
504,
312,
22707,
14,
1018,
14,
8786,
492,
664,
63,
1238,
199,
504,
1639,
14,
2828,
14,
1178,
14,
3351,
492,
15995,
2821,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
199,
199,
504,
312,
22707,
14,
5181,
14,
1562,
14,
3351,
492,
11836,
1476,
2821,
199,
504,
312,
22707,
14,
5181,
14,
10178,
14,
1208,
492,
3293,
572,
63,
2123,
199,
504,
312,
22707,
14,
1018,
14,
5819,
492,
664,
63,
751,
63,
1238,
199,
199,
504,
312,
22707,
14,
4196,
14,
6767,
492,
27585,
3259,
4256,
199,
199,
1899,
275,
664,
63,
751,
63,
1238,
342,
199,
17393,
275,
664,
63,
1238,
360,
1562,
297,
283,
17393,
358,
421,
199,
533,
5244,
711,
4073,
1476,
2821,
8,
25640,
4256,
12,
11836,
1476,
2821,
304,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
30707,
4073,
1476,
2821,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
14,
10917,
63,
6063,
63,
698,
342,
339,
347,
11311,
63,
6063,
63,
698,
8,
277,
304,
267,
26013,
275,
19453,
423,
885,
63,
2609,
14,
1541,
8,
288,
365,
63,
17801,
63,
6063,
29,
549,
9,
398,
327,
3091,
1929,
370,
2498,
9023,
5978,
2110,
340,
2337,
365,
1454,
1373,
945,
267,
340,
822,
8,
23598,
9,
508,
413,
26,
288,
291,
14,
955,
14,
1935,
360,
6063,
297,
488,
9,
288,
291,
14,
842,
14,
6063,
275,
26013,
59,
16,
61,
267,
587,
26,
288,
291,
14,
955,
459,
6063,
2278,
7924,
275,
26013,
288,
291,
14,
955,
459,
6063,
2278,
1667,
63,
1302,
275,
488,
339,
1021,
6288,
26,
267,
1402,
275,
664,
63,
1238,
360,
1648,
297,
283,
17801,
1562,
358,
267,
1504,
275,
359,
288,
283,
1213,
297,
283,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
288,
283,
604,
17,
297,
283,
604,
18,
297,
283,
604,
19,
297,
283,
604,
20,
297,
288,
283,
929,
297,
283,
1932,
600,
297,
283,
6063,
297,
288,
283,
9339,
63,
1955,
297,
283,
5983,
297,
267,
1622,
421,
199,
533,
27166,
2821,
8,
10348,
2821,
304,
272,
3434,
275,
4513,
14,
16577,
8,
1302,
9384,
5713,
3031,
2287,
365,
2237,
272,
598,
53,
1719,
12,
18689,
12,
22968,
1206,
275,
283,
12628,
297,
283,
1222,
297,
283,
5952,
7,
272,
445,
2979,
7040,
275,
334,
267,
334,
17188,
1719,
12,
4018,
41,
8140,
282,
892,
15229,
436,
2934,
370,
15243,
465,
282,
13980,
3855,
267,
334,
11365,
12,
4018,
41,
8140,
282,
892,
15229,
436,
2934,
370,
1218,
376,
2933,
283,
355,
283,
5182,
7907,
734,
3855,
267,
334,
13301,
1206,
12,
4018,
41,
8140,
282,
8152,
15229,
12,
436,
3002,
2505,
365,
7058,
272,
1511,
275,
4513,
14,
15792,
8,
3440,
29,
3351,
14,
8583,
14,
16065,
5446,
12,
1816,
3415,
29,
16236,
12,
2536,
29,
17188,
1719,
9,
339,
347,
3633,
63,
2473,
8,
277,
304,
267,
372,
3293,
572,
63,
2123,
8,
277,
14,
8275,
63,
576,
459,
2473,
1105,
339,
347,
3633,
8,
277,
304,
267,
340,
291,
14,
374,
63,
10409,
63,
12891,
342,
503,
291,
14,
374,
63,
1222,
63,
2048,
63,
12891,
837,
288,
340,
283,
2060,
7,
315,
291,
14,
2550,
26,
355,
2150,
291,
14,
2550,
459,
2060,
418,
288,
340,
283,
2473,
7,
315,
291,
14,
8275,
63,
576,
26,
355,
3031,
275,
3293,
572,
63,
2123,
8,
277,
14,
8275,
63,
576,
459,
2473,
1105,
355,
340,
2876,
423,
885,
63,
2609,
14,
1541,
8,
2123,
363,
32344,
29,
2123,
680,
2444,
837,
490,
1499,
275,
298,
33,
922,
543,
626,
3031,
2287,
2575,
3495,
2,
490,
291,
423,
2550,
905,
2473,
937,
275,
291,
14,
705,
63,
533,
779,
1328,
566,
288,
372,
291,
14,
8275,
63,
576,
267,
372,
1613,
8,
12455,
2821,
12,
291,
680,
3118,
342,
339,
347,
365,
63,
10409,
63,
12891,
8,
277,
304,
267,
372,
291,
14,
8275,
63,
576,
14,
362,
360,
1419,
297,
488,
9,
508,
291,
14,
17188,
1719,
339,
347,
365,
63,
1222,
63,
2048,
63,
12891,
8,
277,
304,
267,
372,
291,
14,
8275,
63,
576,
14,
362,
360,
1419,
297,
488,
9,
508,
291,
14,
11365,
421,
199,
3,
710,
699,
12687,
1476,
1824,
365,
315,
312,
22707,
14,
5181,
14,
7948,
14,
3351,
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
] |
[
1639,
492,
4513,
199,
504,
312,
22707,
14,
1018,
14,
8786,
492,
664,
63,
1238,
199,
504,
1639,
14,
2828,
14,
1178,
14,
3351,
492,
15995,
2821,
199,
504,
1639,
14,
1208,
14,
6893,
492,
10366,
63,
6395,
465,
485,
199,
199,
504,
312,
22707,
14,
5181,
14,
1562,
14,
3351,
492,
11836,
1476,
2821,
199,
504,
312,
22707,
14,
5181,
14,
10178,
14,
1208,
492,
3293,
572,
63,
2123,
199,
504,
312,
22707,
14,
1018,
14,
5819,
492,
664,
63,
751,
63,
1238,
199,
199,
504,
312,
22707,
14,
4196,
14,
6767,
492,
27585,
3259,
4256,
199,
199,
1899,
275,
664,
63,
751,
63,
1238,
342,
199,
17393,
275,
664,
63,
1238,
360,
1562,
297,
283,
17393,
358,
421,
199,
533,
5244,
711,
4073,
1476,
2821,
8,
25640,
4256,
12,
11836,
1476,
2821,
304,
339,
347,
636,
826,
721,
277,
12,
627,
589,
12,
1011,
958,
304,
267,
1613,
8,
30707,
4073,
1476,
2821,
12,
291,
2843,
826,
9308,
589,
12,
1011,
958,
9,
267,
291,
14,
10917,
63,
6063,
63,
698,
342,
339,
347,
11311,
63,
6063,
63,
698,
8,
277,
304,
267,
26013,
275,
19453,
423,
885,
63,
2609,
14,
1541,
8,
288,
365,
63,
17801,
63,
6063,
29,
549,
9,
398,
327,
3091,
1929,
370,
2498,
9023,
5978,
2110,
340,
2337,
365,
1454,
1373,
945,
267,
340,
822,
8,
23598,
9,
508,
413,
26,
288,
291,
14,
955,
14,
1935,
360,
6063,
297,
488,
9,
288,
291,
14,
842,
14,
6063,
275,
26013,
59,
16,
61,
267,
587,
26,
288,
291,
14,
955,
459,
6063,
2278,
7924,
275,
26013,
288,
291,
14,
955,
459,
6063,
2278,
1667,
63,
1302,
275,
488,
339,
1021,
6288,
26,
267,
1402,
275,
664,
63,
1238,
360,
1648,
297,
283,
17801,
1562,
358,
267,
1504,
275,
359,
288,
283,
1213,
297,
283,
2246,
63,
354,
297,
283,
2019,
63,
354,
297,
288,
283,
604,
17,
297,
283,
604,
18,
297,
283,
604,
19,
297,
283,
604,
20,
297,
288,
283,
929,
297,
283,
1932,
600,
297,
283,
6063,
297,
288,
283,
9339,
63,
1955,
297,
283,
5983,
297,
267,
1622,
421,
199,
533,
27166,
2821,
8,
10348,
2821,
304,
272,
3434,
275,
4513,
14,
16577,
8,
1302,
9384,
5713,
3031,
2287,
365,
2237,
272,
598,
53,
1719,
12,
18689,
12,
22968,
1206,
275,
283,
12628,
297,
283,
1222,
297,
283,
5952,
7,
272,
445,
2979,
7040,
275,
334,
267,
334,
17188,
1719,
12,
4018,
41,
8140,
282,
892,
15229,
436,
2934,
370,
15243,
465,
282,
13980,
3855,
267,
334,
11365,
12,
4018,
41,
8140,
282,
892,
15229,
436,
2934,
370,
1218,
376,
2933,
283,
355,
283,
5182,
7907,
734,
3855,
267,
334,
13301,
1206,
12,
4018,
41,
8140,
282,
8152,
15229,
12,
436,
3002,
2505,
365,
7058,
272,
1511,
275,
4513,
14,
15792,
8,
3440,
29,
3351,
14,
8583,
14,
16065,
5446,
12,
1816,
3415,
29,
16236,
12,
2536,
29,
17188,
1719,
9,
339,
347,
3633,
63,
2473,
8,
277,
304,
267,
372,
3293,
572,
63,
2123,
8,
277,
14,
8275,
63,
576,
459,
2473,
1105,
339,
347,
3633,
8,
277,
304,
267,
340,
291,
14,
374,
63,
10409,
63,
12891,
342,
503,
291,
14,
374,
63,
1222,
63,
2048,
63,
12891,
837,
288,
340,
283,
2060,
7,
315,
291,
14,
2550,
26,
355,
2150,
291,
14,
2550,
459,
2060,
418,
288,
340,
283,
2473,
7,
315,
291,
14,
8275,
63,
576,
26,
355,
3031,
275,
3293,
572,
63,
2123,
8,
277,
14,
8275,
63,
576,
459,
2473,
1105,
355,
340,
2876,
423,
885,
63,
2609,
14,
1541,
8,
2123,
363,
32344,
29,
2123,
680,
2444,
837,
490,
1499,
275,
298,
33,
922,
543,
626,
3031,
2287,
2575,
3495,
2,
490,
291,
423,
2550,
905,
2473,
937,
275,
291,
14,
705,
63,
533,
779,
1328,
566,
288,
372,
291,
14,
8275,
63,
576,
267,
372,
1613,
8,
12455,
2821,
12,
291,
680,
3118,
342,
339,
347,
365,
63,
10409,
63,
12891,
8,
277,
304,
267,
372,
291,
14,
8275,
63,
576,
14,
362,
360,
1419,
297,
488,
9,
508,
291,
14,
17188,
1719,
339,
347,
365,
63,
1222,
63,
2048,
63,
12891,
8,
277,
304,
267,
372,
291,
14,
8275,
63,
576,
14,
362,
360,
1419,
297,
488,
9,
508,
291,
14,
11365,
421,
199,
3,
710,
699,
12687,
1476,
1824,
365,
315,
312,
22707,
14,
5181,
14,
7948,
14,
3351,
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,
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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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
] |
axinging/sky_engine
|
mojo/tools/roll/update_from_chromium.py
|
9
|
3601
|
#!/usr/bin/env python
# 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.
import argparse
import json
import os
import subprocess
import sys
import urllib2
from utils import commit
from utils import mojo_root_dir
from utils import system
import patch
# //base and its dependencies
base_deps = [
"base",
"testing",
"third_party/ashmem",
"third_party/libevent",
"third_party/libxml", # via //base/test
"third_party/modp_b64",
"third_party/tcmalloc",
]
# //build and its dependencies
build_deps = [
"build",
"third_party/android_testrunner",
"third_party/binutils",
"third_party/pymock",
"tools/android",
"tools/clang",
"tools/generate_library_loader",
"tools/gritsettings",
"tools/relocation_packer",
"tools/valgrind",
]
# //sandbox/linux and its dependencies
sandbox_deps = [
"sandbox/linux",
]
# things used from //mojo/public
mojo_sdk_deps = [
"third_party/cython",
]
# These directories are snapshotted from chromium without modifications.
dirs_to_snapshot = base_deps + build_deps + sandbox_deps + mojo_sdk_deps
files_to_copy = [ "sandbox/sandbox_export.h" ]
# The contents of these files before the roll will be preserved after the roll,
# even though they live in directories rolled in from Chromium.
files_not_to_roll = [
"build/config/ui.gni",
"build/ls.py",
"build/module_args/mojo.gni",
]
dirs = dirs_to_snapshot
def chromium_rev_number(src_commit):
base_url = "https://cr-rev.appspot.com/_ah/api/crrev/v1/commit/"
commit_info = json.load(urllib2.urlopen(base_url + src_commit))
return commit_info["numberings"][0]["number"]
def rev(source_dir):
for d in dirs:
print "removing directory %s" % d
try:
system(["git", "rm", "-r", d], cwd=mojo_root_dir)
except subprocess.CalledProcessError:
print "Could not remove %s" % d
print "cloning directory %s" % d
files = system(["git", "ls-files", d], cwd=source_dir)
for f in files.splitlines():
dest_path = os.path.join(mojo_root_dir, f)
system(["mkdir", "-p", os.path.dirname(dest_path)], cwd=source_dir)
system(["cp", os.path.join(source_dir, f), dest_path], cwd=source_dir)
system(["git", "add", d], cwd=mojo_root_dir)
for f in files_to_copy:
system(["cp", os.path.join(source_dir, f), os.path.join(mojo_root_dir, f)])
system(["git", "add", "."], cwd=mojo_root_dir)
src_commit = system(["git", "rev-parse", "HEAD"], cwd=source_dir).strip()
src_rev = chromium_rev_number(src_commit)
commit("Update from https://crrev.com/" + src_rev, cwd=mojo_root_dir)
def main():
parser = argparse.ArgumentParser(description="Update the mojo repo's " +
"snapshot of things imported from chromium.")
parser.add_argument("chromium_dir", help="chromium source dir")
args = parser.parse_args()
pre_roll_commit = system(
["git", "rev-parse", "HEAD"], cwd=mojo_root_dir).strip()
rev(args.chromium_dir)
try:
patch.patch_and_filter()
except subprocess.CalledProcessError:
print "ERROR: Roll failed due to a patch not applying"
print "Fix the patch to apply, commit the result, and re-run this script"
return 1
print "Restoring files whose contents don't track Chromium"
for f in files_not_to_roll:
system(["git", "checkout", pre_roll_commit, "--", f], cwd=mojo_root_dir)
if files_not_to_roll:
commit("Restored pre-roll versions of files that don't get rolled")
return 0
if __name__ == "__main__":
sys.exit(main())
|
bsd-3-clause
|
[
3381,
2647,
15,
1393,
15,
1813,
2366,
199,
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,
646,
7534,
199,
646,
2022,
199,
646,
747,
199,
646,
3873,
199,
646,
984,
199,
646,
4011,
18,
199,
504,
3778,
492,
5532,
199,
504,
3778,
492,
1303,
743,
63,
1231,
63,
694,
199,
504,
3778,
492,
2656,
199,
199,
646,
3371,
199,
199,
3,
5001,
1095,
436,
2399,
5124,
199,
1095,
63,
5846,
275,
359,
272,
298,
1095,
401,
272,
298,
4776,
401,
272,
298,
11470,
63,
7522,
15,
1119,
5286,
401,
272,
298,
11470,
63,
7522,
15,
773,
1430,
401,
272,
298,
11470,
63,
7522,
15,
773,
1652,
401,
327,
4799,
5001,
1095,
15,
396,
272,
298,
11470,
63,
7522,
15,
1494,
80,
63,
66,
772,
401,
272,
298,
11470,
63,
7522,
15,
3641,
23981,
401,
199,
61,
199,
199,
3,
5001,
1506,
436,
2399,
5124,
199,
1506,
63,
5846,
275,
359,
272,
298,
1506,
401,
272,
298,
11470,
63,
7522,
15,
6238,
63,
396,
5933,
401,
272,
298,
11470,
63,
7522,
15,
1393,
1208,
401,
272,
298,
11470,
63,
7522,
15,
647,
1805,
401,
272,
298,
2537,
15,
6238,
401,
272,
298,
2537,
15,
16066,
401,
272,
298,
2537,
15,
4208,
63,
4342,
63,
3422,
401,
272,
298,
2537,
15,
7928,
84,
1751,
401,
272,
298,
2537,
15,
264,
1985,
63,
1389,
281,
401,
272,
298,
2537,
15,
637,
21510,
401,
199,
61,
199,
199,
3,
5001,
16647,
15,
5135,
436,
2399,
5124,
199,
16647,
63,
5846,
275,
359,
272,
298,
16647,
15,
5135,
401,
199,
61,
199,
199,
3,
7645,
1202,
687,
5001,
573,
743,
15,
3455,
199,
573,
743,
63,
9277,
63,
5846,
275,
359,
272,
298,
11470,
63,
7522,
15,
20747,
401,
199,
61,
199,
199,
3,
5723,
6602,
787,
5740,
471,
687,
682,
7419,
1928,
23070,
14,
199,
3220,
63,
475,
63,
4753,
275,
1300,
63,
5846,
435,
1900,
63,
5846,
435,
19699,
63,
5846,
435,
1303,
743,
63,
9277,
63,
5846,
199,
199,
1725,
63,
475,
63,
1574,
275,
359,
298,
16647,
15,
16647,
63,
3790,
14,
72,
2,
1622,
199,
199,
3,
710,
4072,
402,
3520,
1584,
2544,
314,
11848,
911,
506,
17731,
2410,
314,
11848,
12,
199,
3,
2755,
10617,
2985,
12166,
315,
6602,
20182,
1146,
315,
687,
12051,
14,
199,
1725,
63,
1397,
63,
475,
63,
2827,
275,
359,
272,
298,
1506,
15,
888,
15,
1907,
14,
784,
73,
401,
272,
298,
1506,
15,
478,
14,
647,
401,
272,
298,
1506,
15,
578,
63,
589,
15,
573,
743,
14,
784,
73,
401,
199,
61,
199,
199,
3220,
275,
7606,
63,
475,
63,
4753,
199,
199,
318,
682,
7419,
63,
4964,
63,
1955,
8,
2164,
63,
3543,
304,
523,
1300,
63,
633,
275,
298,
2859,
921,
1556,
13,
4964,
14,
571,
15185,
14,
957,
15607,
11326,
15,
1246,
15,
1556,
4964,
15,
86,
17,
15,
3543,
6687,
523,
5532,
63,
815,
275,
2022,
14,
912,
8,
4078,
18,
14,
10890,
8,
1095,
63,
633,
435,
2928,
63,
3543,
430,
523,
372,
5532,
63,
815,
905,
1955,
780,
9210,
16,
7541,
1955,
937,
199,
199,
318,
6822,
8,
1365,
63,
694,
304,
523,
367,
366,
315,
7606,
26,
272,
870,
298,
264,
7665,
2082,
450,
83,
2,
450,
366,
272,
862,
26,
489,
2656,
5234,
3187,
401,
298,
5682,
401,
3905,
82,
401,
366,
467,
8288,
29,
573,
743,
63,
1231,
63,
694,
9,
272,
871,
3873,
14,
24691,
26,
489,
870,
298,
6531,
440,
2813,
450,
83,
2,
450,
366,
272,
870,
298,
429,
19718,
2082,
450,
83,
2,
450,
366,
272,
1584,
275,
2656,
5234,
3187,
401,
298,
478,
13,
1725,
401,
366,
467,
8288,
29,
1365,
63,
694,
9,
272,
367,
289,
315,
1584,
14,
7644,
837,
489,
2053,
63,
515,
275,
747,
14,
515,
14,
904,
8,
573,
743,
63,
1231,
63,
694,
12,
289,
9,
489,
2656,
5234,
8215,
401,
3905,
80,
401,
747,
14,
515,
14,
3475,
8,
2614,
63,
515,
4360,
8288,
29,
1365,
63,
694,
9,
489,
2656,
5234,
1850,
401,
747,
14,
515,
14,
904,
8,
1365,
63,
694,
12,
289,
395,
2053,
63,
515,
467,
8288,
29,
1365,
63,
694,
9,
272,
2656,
5234,
3187,
401,
298,
525,
401,
366,
467,
8288,
29,
573,
743,
63,
1231,
63,
694,
9,
819,
367,
289,
315,
1584,
63,
475,
63,
1574,
26,
272,
2656,
5234,
1850,
401,
747,
14,
515,
14,
904,
8,
1365,
63,
694,
12,
289,
395,
747,
14,
515,
14,
904,
8,
573,
743,
63,
1231,
63,
694,
12,
289,
3948,
819,
2656,
5234,
3187,
401,
298,
525,
401,
14530,
467,
8288,
29,
573,
743,
63,
1231,
63,
694,
9,
523,
2928,
63,
3543,
275,
2656,
5234,
3187,
401,
298,
4964,
13,
1122,
401,
298,
5211,
2255,
8288,
29,
1365,
63,
694,
680,
1913,
342,
523,
2928,
63,
4964,
275,
682,
7419,
63,
4964,
63,
1955,
8,
2164,
63,
3543,
9,
523,
5532,
480,
4152,
687,
4178,
921,
1556,
4964,
14,
957,
6687,
435,
2928,
63,
4964,
12,
8288,
29,
573,
743,
63,
1231,
63,
694,
9,
199,
199,
318,
2446,
837,
523,
1798,
275,
7534,
14,
10730,
8,
1802,
628,
4152,
314,
1303,
743,
3831,
1159,
298,
435,
489,
298,
4753,
402,
7645,
8439,
687,
682,
7419,
2685,
523,
1798,
14,
525,
63,
2094,
480,
13211,
63,
694,
401,
1720,
628,
13211,
1350,
2935,
531,
523,
1249,
275,
1798,
14,
1122,
63,
589,
342,
523,
876,
63,
2827,
63,
3543,
275,
2656,
8,
489,
2097,
3187,
401,
298,
4964,
13,
1122,
401,
298,
5211,
2255,
8288,
29,
573,
743,
63,
1231,
63,
694,
680,
1913,
342,
819,
6822,
8,
589,
14,
13211,
63,
694,
9,
819,
862,
26,
272,
3371,
14,
2068,
63,
460,
63,
1541,
342,
523,
871,
3873,
14,
24691,
26,
272,
870,
298,
3170,
26,
820,
14385,
3405,
7037,
370,
282,
3371,
440,
18876,
2,
272,
870,
298,
11985,
314,
3371,
370,
4838,
12,
5532,
314,
754,
12,
436,
295,
13,
1065,
642,
2884,
2,
272,
372,
413,
819,
870,
298,
13726,
6854
] |
[
2647,
15,
1393,
15,
1813,
2366,
199,
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,
646,
7534,
199,
646,
2022,
199,
646,
747,
199,
646,
3873,
199,
646,
984,
199,
646,
4011,
18,
199,
504,
3778,
492,
5532,
199,
504,
3778,
492,
1303,
743,
63,
1231,
63,
694,
199,
504,
3778,
492,
2656,
199,
199,
646,
3371,
199,
199,
3,
5001,
1095,
436,
2399,
5124,
199,
1095,
63,
5846,
275,
359,
272,
298,
1095,
401,
272,
298,
4776,
401,
272,
298,
11470,
63,
7522,
15,
1119,
5286,
401,
272,
298,
11470,
63,
7522,
15,
773,
1430,
401,
272,
298,
11470,
63,
7522,
15,
773,
1652,
401,
327,
4799,
5001,
1095,
15,
396,
272,
298,
11470,
63,
7522,
15,
1494,
80,
63,
66,
772,
401,
272,
298,
11470,
63,
7522,
15,
3641,
23981,
401,
199,
61,
199,
199,
3,
5001,
1506,
436,
2399,
5124,
199,
1506,
63,
5846,
275,
359,
272,
298,
1506,
401,
272,
298,
11470,
63,
7522,
15,
6238,
63,
396,
5933,
401,
272,
298,
11470,
63,
7522,
15,
1393,
1208,
401,
272,
298,
11470,
63,
7522,
15,
647,
1805,
401,
272,
298,
2537,
15,
6238,
401,
272,
298,
2537,
15,
16066,
401,
272,
298,
2537,
15,
4208,
63,
4342,
63,
3422,
401,
272,
298,
2537,
15,
7928,
84,
1751,
401,
272,
298,
2537,
15,
264,
1985,
63,
1389,
281,
401,
272,
298,
2537,
15,
637,
21510,
401,
199,
61,
199,
199,
3,
5001,
16647,
15,
5135,
436,
2399,
5124,
199,
16647,
63,
5846,
275,
359,
272,
298,
16647,
15,
5135,
401,
199,
61,
199,
199,
3,
7645,
1202,
687,
5001,
573,
743,
15,
3455,
199,
573,
743,
63,
9277,
63,
5846,
275,
359,
272,
298,
11470,
63,
7522,
15,
20747,
401,
199,
61,
199,
199,
3,
5723,
6602,
787,
5740,
471,
687,
682,
7419,
1928,
23070,
14,
199,
3220,
63,
475,
63,
4753,
275,
1300,
63,
5846,
435,
1900,
63,
5846,
435,
19699,
63,
5846,
435,
1303,
743,
63,
9277,
63,
5846,
199,
199,
1725,
63,
475,
63,
1574,
275,
359,
298,
16647,
15,
16647,
63,
3790,
14,
72,
2,
1622,
199,
199,
3,
710,
4072,
402,
3520,
1584,
2544,
314,
11848,
911,
506,
17731,
2410,
314,
11848,
12,
199,
3,
2755,
10617,
2985,
12166,
315,
6602,
20182,
1146,
315,
687,
12051,
14,
199,
1725,
63,
1397,
63,
475,
63,
2827,
275,
359,
272,
298,
1506,
15,
888,
15,
1907,
14,
784,
73,
401,
272,
298,
1506,
15,
478,
14,
647,
401,
272,
298,
1506,
15,
578,
63,
589,
15,
573,
743,
14,
784,
73,
401,
199,
61,
199,
199,
3220,
275,
7606,
63,
475,
63,
4753,
199,
199,
318,
682,
7419,
63,
4964,
63,
1955,
8,
2164,
63,
3543,
304,
523,
1300,
63,
633,
275,
298,
2859,
921,
1556,
13,
4964,
14,
571,
15185,
14,
957,
15607,
11326,
15,
1246,
15,
1556,
4964,
15,
86,
17,
15,
3543,
6687,
523,
5532,
63,
815,
275,
2022,
14,
912,
8,
4078,
18,
14,
10890,
8,
1095,
63,
633,
435,
2928,
63,
3543,
430,
523,
372,
5532,
63,
815,
905,
1955,
780,
9210,
16,
7541,
1955,
937,
199,
199,
318,
6822,
8,
1365,
63,
694,
304,
523,
367,
366,
315,
7606,
26,
272,
870,
298,
264,
7665,
2082,
450,
83,
2,
450,
366,
272,
862,
26,
489,
2656,
5234,
3187,
401,
298,
5682,
401,
3905,
82,
401,
366,
467,
8288,
29,
573,
743,
63,
1231,
63,
694,
9,
272,
871,
3873,
14,
24691,
26,
489,
870,
298,
6531,
440,
2813,
450,
83,
2,
450,
366,
272,
870,
298,
429,
19718,
2082,
450,
83,
2,
450,
366,
272,
1584,
275,
2656,
5234,
3187,
401,
298,
478,
13,
1725,
401,
366,
467,
8288,
29,
1365,
63,
694,
9,
272,
367,
289,
315,
1584,
14,
7644,
837,
489,
2053,
63,
515,
275,
747,
14,
515,
14,
904,
8,
573,
743,
63,
1231,
63,
694,
12,
289,
9,
489,
2656,
5234,
8215,
401,
3905,
80,
401,
747,
14,
515,
14,
3475,
8,
2614,
63,
515,
4360,
8288,
29,
1365,
63,
694,
9,
489,
2656,
5234,
1850,
401,
747,
14,
515,
14,
904,
8,
1365,
63,
694,
12,
289,
395,
2053,
63,
515,
467,
8288,
29,
1365,
63,
694,
9,
272,
2656,
5234,
3187,
401,
298,
525,
401,
366,
467,
8288,
29,
573,
743,
63,
1231,
63,
694,
9,
819,
367,
289,
315,
1584,
63,
475,
63,
1574,
26,
272,
2656,
5234,
1850,
401,
747,
14,
515,
14,
904,
8,
1365,
63,
694,
12,
289,
395,
747,
14,
515,
14,
904,
8,
573,
743,
63,
1231,
63,
694,
12,
289,
3948,
819,
2656,
5234,
3187,
401,
298,
525,
401,
14530,
467,
8288,
29,
573,
743,
63,
1231,
63,
694,
9,
523,
2928,
63,
3543,
275,
2656,
5234,
3187,
401,
298,
4964,
13,
1122,
401,
298,
5211,
2255,
8288,
29,
1365,
63,
694,
680,
1913,
342,
523,
2928,
63,
4964,
275,
682,
7419,
63,
4964,
63,
1955,
8,
2164,
63,
3543,
9,
523,
5532,
480,
4152,
687,
4178,
921,
1556,
4964,
14,
957,
6687,
435,
2928,
63,
4964,
12,
8288,
29,
573,
743,
63,
1231,
63,
694,
9,
199,
199,
318,
2446,
837,
523,
1798,
275,
7534,
14,
10730,
8,
1802,
628,
4152,
314,
1303,
743,
3831,
1159,
298,
435,
489,
298,
4753,
402,
7645,
8439,
687,
682,
7419,
2685,
523,
1798,
14,
525,
63,
2094,
480,
13211,
63,
694,
401,
1720,
628,
13211,
1350,
2935,
531,
523,
1249,
275,
1798,
14,
1122,
63,
589,
342,
523,
876,
63,
2827,
63,
3543,
275,
2656,
8,
489,
2097,
3187,
401,
298,
4964,
13,
1122,
401,
298,
5211,
2255,
8288,
29,
573,
743,
63,
1231,
63,
694,
680,
1913,
342,
819,
6822,
8,
589,
14,
13211,
63,
694,
9,
819,
862,
26,
272,
3371,
14,
2068,
63,
460,
63,
1541,
342,
523,
871,
3873,
14,
24691,
26,
272,
870,
298,
3170,
26,
820,
14385,
3405,
7037,
370,
282,
3371,
440,
18876,
2,
272,
870,
298,
11985,
314,
3371,
370,
4838,
12,
5532,
314,
754,
12,
436,
295,
13,
1065,
642,
2884,
2,
272,
372,
413,
819,
870,
298,
13726,
6854,
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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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
] |
MoamerEncsConcordiaCa/tensorflow
|
tensorflow/python/kernel_tests/conv_ops_3d_test.py
|
2
|
16642
|
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Functional tests for 3d convolutional operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import math
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import test_util
from tensorflow.python.ops import gradient_checker
from tensorflow.python.ops import nn_ops
import tensorflow.python.ops.nn_grad # pylint: disable=unused-import
from tensorflow.python.platform import test
def GetTestConfigs():
"""Get all the valid tests configs to run.
Returns:
all the valid test configs as tuples of data_format and use_gpu.
"""
test_configs = [("NDHWC", False), ("NDHWC", True)]
if test.is_gpu_available(cuda_only=True):
# "NCDHW" format is only supported on CUDA.
test_configs += [("NCDHW", True)]
return test_configs
class Conv3DTest(test.TestCase):
def _SetupValuesForDevice(self, tensor_in_sizes, filter_in_sizes, stride,
padding, data_format, use_gpu):
total_size_1 = 1
total_size_2 = 1
for s in tensor_in_sizes:
total_size_1 *= s
for s in filter_in_sizes:
total_size_2 *= s
# Initializes the input tensor with array containing incrementing
# numbers from 1.
x1 = [f * 1.0 for f in range(1, total_size_1 + 1)]
x2 = [f * 1.0 for f in range(1, total_size_2 + 1)]
with self.test_session(use_gpu=use_gpu):
t1 = constant_op.constant(x1, shape=tensor_in_sizes)
t2 = constant_op.constant(x2, shape=filter_in_sizes)
if isinstance(stride, collections.Iterable):
strides = [1] + list(stride) + [1]
else:
strides = [1, stride, stride, stride, 1]
if data_format == "NCDHW":
t1 = test_util.NHWCToNCHW(t1)
strides = test_util.NHWCToNCHW(strides)
conv = nn_ops.conv3d(t1, t2, strides, padding=padding,
data_format=data_format)
if data_format == "NCDHW":
conv = test_util.NCHWToNHWC(conv)
return conv
def _VerifyValues(self, tensor_in_sizes, filter_in_sizes, stride, padding,
expected):
results = []
for data_format, use_gpu in GetTestConfigs():
result = self._SetupValuesForDevice(
tensor_in_sizes,
filter_in_sizes,
stride,
padding,
data_format,
use_gpu=use_gpu)
results.append(result)
tolerance = 1e-2 if use_gpu else 1e-5
with self.test_session() as sess:
values = sess.run(results)
for value in values:
print("expected = ", expected)
print("actual = ", value)
self.assertAllClose(expected, value.flatten(), atol=tolerance,
rtol=1e-6)
def testConv3D1x1x1Filter(self):
expected_output = [
30.0, 36.0, 42.0, 66.0, 81.0, 96.0, 102.0, 126.0, 150.0, 138.0, 171.0,
204.0, 174.0, 216.0, 258.0, 210.0, 261.0, 312.0
]
# These are equivalent to the Conv2D1x1 case.
self._VerifyValues(
tensor_in_sizes=[1, 2, 3, 1, 3],
filter_in_sizes=[1, 1, 1, 3, 3],
stride=1,
padding="VALID",
expected=expected_output)
self._VerifyValues(
tensor_in_sizes=[1, 2, 1, 3, 3],
filter_in_sizes=[1, 1, 1, 3, 3],
stride=1,
padding="VALID",
expected=expected_output)
self._VerifyValues(
tensor_in_sizes=[1, 1, 2, 3, 3],
filter_in_sizes=[1, 1, 1, 3, 3],
stride=1,
padding="VALID",
expected=expected_output)
# Expected values computed using scipy's correlate function.
def testConv3D2x2x2Filter(self):
expected_output = [
19554., 19962., 20370., 22110., 22590., 23070., 34890., 35730., 36570.,
37446., 38358., 39270., 50226., 51498., 52770., 52782., 54126., 55470.
]
# expected_shape = [1, 3, 1, 2, 5]
self._VerifyValues(
tensor_in_sizes=[1, 4, 2, 3, 3], # b, z, y, x, fin
filter_in_sizes=[2, 2, 2, 3, 3], # z, y, x, fin, fout
stride=1,
padding="VALID",
expected=expected_output)
def testConv3DStrides(self):
expected_output = [
102.,
151.,
172.,
193.,
214.,
235.,
142.,
438.,
592.,
613.,
634.,
655.,
676.,
394.,
774.,
1033.,
1054.,
1075.,
1096.,
1117.,
646.,
1894.,
2503.,
2524.,
2545.,
2566.,
2587.,
1486.,
2230.,
2944.,
2965.,
2986.,
3007.,
3028.,
1738.,
2566.,
3385.,
3406.,
3427.,
3448.,
3469.,
1990.,
3686.,
4855.,
4876.,
4897.,
4918.,
4939.,
2830.,
4022.,
5296.,
5317.,
5338.,
5359.,
5380.,
3082.,
4358.,
5737.,
5758.,
5779.,
5800.,
5821.,
3334.,
]
self._VerifyValues(
tensor_in_sizes=[1, 5, 8, 7, 1],
filter_in_sizes=[1, 2, 3, 1, 1],
stride=[2, 3, 1], # different stride for each spatial dimension
padding="SAME",
expected=expected_output)
def testConv3D2x2x2FilterStride2(self):
expected_output = [19554., 19962., 20370., 50226., 51498., 52770.]
self._VerifyValues(
tensor_in_sizes=[1, 4, 2, 3, 3],
filter_in_sizes=[2, 2, 2, 3, 3],
stride=2,
padding="VALID",
expected=expected_output)
def testConv3DStride3(self):
expected_output = [
36564., 38022., 39480., 37824., 39354., 40884., 39084., 40686., 42288.,
46644., 48678., 50712., 47904., 50010., 52116., 49164., 51342., 53520.,
107124., 112614., 118104., 108384., 113946., 119508., 109644., 115278.,
120912., 117204., 123270., 129336., 118464., 124602., 130740., 119724.,
125934., 132144.
]
self._VerifyValues(
tensor_in_sizes=[1, 6, 7, 8, 2],
filter_in_sizes=[3, 2, 1, 2, 3],
stride=3,
padding="VALID",
expected=expected_output)
def testConv3D2x2x2FilterStride2Same(self):
expected_output = [
19554., 19962., 20370., 10452., 10710., 10968., 50226., 51498., 52770.,
23844., 24534., 25224.
]
self._VerifyValues(
tensor_in_sizes=[1, 4, 2, 3, 3],
filter_in_sizes=[2, 2, 2, 3, 3],
stride=2,
padding="SAME",
expected=expected_output)
def testKernelSmallerThanStride(self):
expected_output = [1., 3., 7., 9., 19., 21., 25., 27.]
self._VerifyValues(
tensor_in_sizes=[1, 3, 3, 3, 1],
filter_in_sizes=[1, 1, 1, 1, 1],
stride=2,
padding="SAME",
expected=expected_output)
self._VerifyValues(
tensor_in_sizes=[1, 3, 3, 3, 1],
filter_in_sizes=[1, 1, 1, 1, 1],
stride=2,
padding="VALID",
expected=expected_output)
expected_output = [
1484., 1592., 770., 2240., 2348., 1106., 1149., 1191., 539., 6776.,
6884., 3122., 7532., 7640., 3458., 3207., 3249., 1421., 3005., 3035.,
1225., 3215., 3245., 1309., 1013., 1022., 343.
]
self._VerifyValues(
tensor_in_sizes=[1, 7, 7, 7, 1],
filter_in_sizes=[2, 2, 2, 1, 1],
stride=3,
padding="SAME",
expected=expected_output)
expected_output = [1484., 1592., 2240., 2348., 6776., 6884., 7532., 7640.]
self._VerifyValues(
tensor_in_sizes=[1, 7, 7, 7, 1],
filter_in_sizes=[2, 2, 2, 1, 1],
stride=3,
padding="VALID",
expected=expected_output)
def testKernelSizeMatchesInputSize(self):
self._VerifyValues(
tensor_in_sizes=[1, 2, 1, 2, 1],
filter_in_sizes=[2, 1, 2, 1, 2],
stride=1,
padding="VALID",
expected=[50, 60])
def _ConstructAndTestGradientForConfig(
self, batch, input_shape, filter_shape, in_depth, out_depth, stride,
padding, test_input, data_format, use_gpu):
input_planes, input_rows, input_cols = input_shape
filter_planes, filter_rows, filter_cols = filter_shape
input_shape = [batch, input_planes, input_rows, input_cols, in_depth]
filter_shape = [
filter_planes, filter_rows, filter_cols, in_depth, out_depth
]
if isinstance(stride, collections.Iterable):
strides = [1] + list(stride) + [1]
else:
strides = [1, stride, stride, stride, 1]
if padding == "VALID":
output_planes = int(
math.ceil((input_planes - filter_planes + 1.0) / strides[1]))
output_rows = int(
math.ceil((input_rows - filter_rows + 1.0) / strides[2]))
output_cols = int(
math.ceil((input_cols - filter_cols + 1.0) / strides[3]))
else:
output_planes = int(math.ceil(float(input_planes) / strides[1]))
output_rows = int(math.ceil(float(input_rows) / strides[2]))
output_cols = int(math.ceil(float(input_cols) / strides[3]))
output_shape = [batch, output_planes, output_rows, output_cols, out_depth]
input_size = 1
for x in input_shape:
input_size *= x
filter_size = 1
for x in filter_shape:
filter_size *= x
input_data = [x * 1.0 / input_size for x in range(0, input_size)]
filter_data = [x * 1.0 / filter_size for x in range(0, filter_size)]
if test.is_gpu_available() and use_gpu:
data_type = dtypes.float32
if test.is_gpu_available():
tolerance = 4e-3
else:
# As of Aug 2016, higher tolerance is needed for some CPU architectures.
# Runs on a single machine can also generate slightly different errors
# because of multithreading.
tolerance = 8e-3
else:
data_type = dtypes.float64
tolerance = 1e-8
with self.test_session(use_gpu=use_gpu):
orig_input_tensor = constant_op.constant(
input_data, shape=input_shape, dtype=data_type, name="input")
filter_tensor = constant_op.constant(
filter_data, shape=filter_shape, dtype=data_type, name="filter")
if data_format == "NCDHW":
input_tensor = test_util.NHWCToNCHW(orig_input_tensor)
strides = test_util.NHWCToNCHW(strides)
else:
input_tensor = orig_input_tensor
conv = nn_ops.conv3d(
input_tensor, filter_tensor, strides, padding,
data_format=data_format, name="conv")
if data_format == "NCDHW":
conv = test_util.NCHWToNHWC(conv)
if test_input:
err = gradient_checker.compute_gradient_error(orig_input_tensor,
input_shape,
conv, output_shape)
else:
err = gradient_checker.compute_gradient_error(filter_tensor,
filter_shape, conv,
output_shape)
print("conv3d gradient error = ", err)
self.assertLess(err, tolerance)
def ConstructAndTestGradient(self, **kwargs):
for data_format, use_gpu in GetTestConfigs():
self._ConstructAndTestGradientForConfig(data_format=data_format,
use_gpu=use_gpu, **kwargs)
def testInputGradientValidPaddingStrideOne(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(3, 5, 4),
filter_shape=(3, 3, 3),
in_depth=2,
out_depth=3,
stride=1,
padding="VALID",
test_input=True)
def testFilterGradientValidPaddingStrideOne(self):
self.ConstructAndTestGradient(
batch=4,
input_shape=(4, 6, 5),
filter_shape=(2, 2, 2),
in_depth=2,
out_depth=3,
stride=1,
padding="VALID",
test_input=False)
def testInputGradientValidPaddingStrideTwo(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(6, 3, 5),
filter_shape=(3, 3, 3),
in_depth=2,
out_depth=3,
stride=2,
padding="VALID",
test_input=True)
def testFilterGradientValidPaddingStrideTwo(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(7, 6, 5),
filter_shape=(2, 2, 2),
in_depth=2,
out_depth=3,
stride=2,
padding="VALID",
test_input=False)
def testInputGradientValidPaddingStrideThree(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(3, 7, 6),
filter_shape=(3, 3, 3),
in_depth=2,
out_depth=3,
stride=3,
padding="VALID",
test_input=True)
def testFilterGradientValidPaddingStrideThree(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(4, 4, 7),
filter_shape=(4, 4, 4),
in_depth=2,
out_depth=3,
stride=3,
padding="VALID",
test_input=False)
def testInputGradientSamePaddingStrideOne(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(3, 2, 2),
filter_shape=(3, 2, 1),
in_depth=2,
out_depth=1,
stride=1,
padding="SAME",
test_input=True)
def testFilterGradientSamePaddingStrideOne(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(3, 6, 5),
filter_shape=(2, 2, 2),
in_depth=2,
out_depth=3,
stride=1,
padding="SAME",
test_input=False)
def testInputGradientSamePaddingStrideTwo(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(6, 3, 4),
filter_shape=(3, 3, 3),
in_depth=2,
out_depth=3,
stride=2,
padding="SAME",
test_input=True)
def testFilterGradientSamePaddingStrideTwo(self):
self.ConstructAndTestGradient(
batch=4,
input_shape=(7, 3, 5),
filter_shape=(2, 2, 2),
in_depth=2,
out_depth=3,
stride=2,
padding="SAME",
test_input=False)
def testInputGradientSamePaddingStrideThree(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(9, 3, 6),
filter_shape=(3, 3, 3),
in_depth=2,
out_depth=3,
stride=3,
padding="SAME",
test_input=True)
def testFilterGradientSamePaddingStrideThree(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(9, 4, 7),
filter_shape=(4, 4, 4),
in_depth=2,
out_depth=3,
stride=3,
padding="SAME",
test_input=False)
def testInputGradientSamePaddingDifferentStrides(self):
self.ConstructAndTestGradient(
batch=1,
input_shape=(5, 8, 7),
filter_shape=(1, 2, 3),
in_depth=2,
out_depth=3,
stride=[2, 3, 1],
padding="SAME",
test_input=True)
def testFilterGradientKernelSizeMatchesInputSize(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(5, 4, 3),
filter_shape=(5, 4, 3),
in_depth=2,
out_depth=3,
stride=1,
padding="VALID",
test_input=False)
def testInputGradientKernelSizeMatchesInputSize(self):
self.ConstructAndTestGradient(
batch=2,
input_shape=(5, 4, 3),
filter_shape=(5, 4, 3),
in_depth=2,
out_depth=3,
stride=1,
padding="VALID",
test_input=True)
def disabledtestFilterGradientSamePaddingDifferentStrides(self):
self.ConstructAndTestGradient(
batch=1,
input_shape=(5, 8, 7),
filter_shape=(1, 2, 3),
in_depth=2,
out_depth=3,
stride=[2, 3, 1],
padding="SAME",
test_input=False)
if __name__ == "__main__":
test.main()
|
apache-2.0
|
[
3,
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
3481,
279,
2295,
367,
650,
68,
17461,
279,
5331,
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,
5055,
199,
646,
3473,
199,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
4857,
492,
511,
63,
1974,
199,
504,
3228,
14,
1548,
14,
1483,
492,
6709,
63,
6743,
199,
504,
3228,
14,
1548,
14,
1483,
492,
11542,
63,
1483,
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,
511,
421,
199,
318,
2372,
774,
29123,
837,
523,
408,
1002,
1006,
314,
1686,
2295,
11585,
370,
1255,
14,
819,
1803,
26,
272,
1006,
314,
1686,
511,
11585,
465,
6346,
402,
666,
63,
908,
436,
675,
63,
6477,
14,
523,
408,
523,
511,
63,
7532,
275,
10003,
8711,
27121,
401,
756,
395,
1689,
8711,
27121,
401,
715,
1874,
523,
340,
511,
14,
374,
63,
6477,
63,
4561,
8,
16309,
63,
2118,
29,
549,
304,
272,
327,
298,
6389,
13860,
55,
2,
1475,
365,
1454,
3748,
641,
445,
3383,
33,
14,
272,
511,
63,
7532,
847,
10003,
6389,
13860,
55,
401,
715,
1874,
523,
372,
511,
63,
7532,
421,
199,
533,
19140,
19,
36,
774,
8,
396,
14,
1746,
304,
819,
347,
485,
8555,
6550,
16775,
8,
277,
12,
2345,
63,
262,
63,
7723,
12,
2457,
63,
262,
63,
7723,
12,
7345,
12,
1169,
6273,
12,
666,
63,
908,
12,
675,
63,
6477,
304,
272,
3141,
63,
890,
63,
17,
275,
413,
272,
3141,
63,
890,
63,
18,
275,
413,
272,
367,
308,
315,
2345,
63,
262,
63,
7723,
26,
489,
3141,
63,
890,
63,
17,
9000,
308,
272,
367,
308,
315,
2457,
63,
262,
63,
7723,
26,
489,
3141,
63,
890,
63,
18,
9000,
308,
339,
327,
6026,
6491,
314,
1324,
2345,
543,
1625,
3035,
11609,
316,
272,
327,
5579,
687,
413,
14,
272,
671,
17,
275,
359,
70,
627,
413,
14,
16,
367,
289,
315,
1425,
8,
17,
12,
3141,
63,
890,
63,
17,
435,
413,
1874,
272,
671,
18,
275,
359,
70,
627,
413,
14,
16,
367,
289,
315,
1425,
8,
17,
12,
3141,
63,
890,
63,
18,
435,
413,
1874,
272,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
1180,
63,
6477,
304,
489,
307,
17,
275,
4413,
63,
411,
14,
4083,
8,
88,
17,
12,
2215,
29,
3128,
63,
262,
63,
7723,
9,
489,
307,
18,
275,
4413,
63,
411,
14,
4083,
8,
88,
18,
12,
2215,
29,
1541,
63,
262,
63,
7723,
9,
2541,
340,
1228,
8,
12318,
12,
5055,
14,
20852,
304,
267,
11883,
275,
359,
17,
61,
435,
769,
8,
12318,
9,
435,
359,
17,
61,
489,
587,
26,
267,
11883,
275,
359,
17,
12,
7345,
12,
7345,
12,
7345,
12,
413,
61,
2541,
340,
666,
63,
908,
508,
298,
6389,
13860,
55,
582,
267,
307,
17,
275,
511,
63,
1974,
14,
46,
15487,
1028,
79,
27086,
8,
84,
17,
9,
267,
11883,
275,
511,
63,
1974,
14,
46,
15487,
1028,
79,
27086,
8,
16759,
9,
489,
8260,
275,
11542,
63,
1483,
14,
5598,
19,
68,
8,
84,
17,
12,
307,
18,
12,
11883,
12,
6273,
29,
8358,
12,
2574,
666,
63,
908,
29,
576,
63,
908,
9,
489,
340,
666,
63,
908,
508,
298,
6389,
13860,
55,
582,
267,
8260,
275,
511,
63,
1974,
14,
27086,
1378,
46,
27121,
8,
5598,
9,
2541,
372,
8260,
819,
347,
485,
7496,
6550,
8,
277,
12,
2345,
63,
262,
63,
7723,
12,
2457,
63,
262,
63,
7723,
12,
7345,
12,
6273,
12,
490,
1420,
304,
272,
2058,
275,
942,
272,
367,
666,
63,
908,
12,
675,
63,
6477,
315,
2372,
774,
29123,
837,
489,
754,
275,
291,
423,
8555,
6550,
16775,
8,
881,
2345,
63,
262,
63,
7723,
12,
881,
2457,
63,
262,
63,
7723,
12,
881,
7345,
12,
881,
6273,
12,
881,
666,
63,
908,
12,
881,
675,
63,
6477,
29,
1180,
63,
6477,
9,
489,
2058,
14,
740,
8,
1099,
9,
489,
13464,
275,
413,
69,
13,
18,
340,
675,
63,
6477,
587,
413,
69,
13,
21,
489,
543,
291,
14,
396,
63,
1730,
342,
465,
4043,
26,
267,
1338,
275,
4043,
14,
1065,
8,
2604,
9,
267,
367,
574,
315,
1338,
26,
881,
870,
480,
2062,
275,
3872,
1420,
9,
881,
870,
480,
6514,
275,
3872,
574,
9,
881,
291,
14,
7260,
8,
2062,
12,
574,
14,
8487,
1062,
9543,
29,
16312,
12,
2892,
10561,
29,
17,
69,
13,
22,
9,
819,
347,
511,
11596,
19,
36,
17,
88,
17,
88,
17,
4131,
8,
277,
304,
272,
1420,
63,
1199,
275,
359,
267,
4233,
14,
16,
12,
8780,
14,
16,
12,
5685,
14,
16,
12,
14157,
14,
16,
12,
19071,
14,
16,
12,
15580,
14,
16,
12,
12996,
14,
16,
12,
21572,
14,
16,
12,
14711,
14,
16,
12,
26309,
14,
16,
12,
413,
3172,
14,
16,
12,
267,
14785,
14,
16,
12,
30698,
14,
16,
12,
30630,
14,
16,
12,
499,
2010,
14,
16,
12,
26160,
14,
16,
12,
499,
2976,
14,
16,
12,
650,
713,
14,
16,
272,
1622
] |
[
1898,
7800,
710,
9134,
6642,
14,
2900,
5924,
5702,
14,
199,
3,
199,
3,
3909,
1334,
314,
3668,
844,
12,
3394,
499,
14,
16,
334,
1589,
298,
3761,
3547,
199,
3,
1265,
1443,
440,
675,
642,
570,
871,
315,
4151,
543,
314,
844,
14,
199,
3,
2047,
1443,
3332,
282,
1331,
402,
314,
844,
737,
199,
3,
199,
3,
258,
1455,
921,
1544,
14,
3796,
14,
1308,
15,
2383,
15,
3961,
13,
18,
14,
16,
199,
3,
199,
3,
4158,
1415,
701,
3964,
4179,
503,
4193,
370,
315,
3575,
12,
2032,
199,
3,
1854,
1334,
314,
844,
365,
1854,
641,
376,
298,
1179,
2281,
2,
4207,
12,
199,
3,
2428,
2990,
1549,
4217,
1634,
1821,
3826,
12,
1902,
4056,
503,
2478,
14,
199,
3,
1666,
314,
844,
367,
314,
2488,
2637,
4210,
3443,
436,
199,
3,
4204,
1334,
314,
844,
14,
199,
3,
11148,
199,
624,
3481,
279,
2295,
367,
650,
68,
17461,
279,
5331,
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,
5055,
199,
646,
3473,
199,
199,
504,
3228,
14,
1548,
14,
4857,
492,
4413,
63,
411,
199,
504,
3228,
14,
1548,
14,
4857,
492,
6674,
199,
504,
3228,
14,
1548,
14,
4857,
492,
511,
63,
1974,
199,
504,
3228,
14,
1548,
14,
1483,
492,
6709,
63,
6743,
199,
504,
3228,
14,
1548,
14,
1483,
492,
11542,
63,
1483,
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,
511,
421,
199,
318,
2372,
774,
29123,
837,
523,
408,
1002,
1006,
314,
1686,
2295,
11585,
370,
1255,
14,
819,
1803,
26,
272,
1006,
314,
1686,
511,
11585,
465,
6346,
402,
666,
63,
908,
436,
675,
63,
6477,
14,
523,
408,
523,
511,
63,
7532,
275,
10003,
8711,
27121,
401,
756,
395,
1689,
8711,
27121,
401,
715,
1874,
523,
340,
511,
14,
374,
63,
6477,
63,
4561,
8,
16309,
63,
2118,
29,
549,
304,
272,
327,
298,
6389,
13860,
55,
2,
1475,
365,
1454,
3748,
641,
445,
3383,
33,
14,
272,
511,
63,
7532,
847,
10003,
6389,
13860,
55,
401,
715,
1874,
523,
372,
511,
63,
7532,
421,
199,
533,
19140,
19,
36,
774,
8,
396,
14,
1746,
304,
819,
347,
485,
8555,
6550,
16775,
8,
277,
12,
2345,
63,
262,
63,
7723,
12,
2457,
63,
262,
63,
7723,
12,
7345,
12,
1169,
6273,
12,
666,
63,
908,
12,
675,
63,
6477,
304,
272,
3141,
63,
890,
63,
17,
275,
413,
272,
3141,
63,
890,
63,
18,
275,
413,
272,
367,
308,
315,
2345,
63,
262,
63,
7723,
26,
489,
3141,
63,
890,
63,
17,
9000,
308,
272,
367,
308,
315,
2457,
63,
262,
63,
7723,
26,
489,
3141,
63,
890,
63,
18,
9000,
308,
339,
327,
6026,
6491,
314,
1324,
2345,
543,
1625,
3035,
11609,
316,
272,
327,
5579,
687,
413,
14,
272,
671,
17,
275,
359,
70,
627,
413,
14,
16,
367,
289,
315,
1425,
8,
17,
12,
3141,
63,
890,
63,
17,
435,
413,
1874,
272,
671,
18,
275,
359,
70,
627,
413,
14,
16,
367,
289,
315,
1425,
8,
17,
12,
3141,
63,
890,
63,
18,
435,
413,
1874,
272,
543,
291,
14,
396,
63,
1730,
8,
1180,
63,
6477,
29,
1180,
63,
6477,
304,
489,
307,
17,
275,
4413,
63,
411,
14,
4083,
8,
88,
17,
12,
2215,
29,
3128,
63,
262,
63,
7723,
9,
489,
307,
18,
275,
4413,
63,
411,
14,
4083,
8,
88,
18,
12,
2215,
29,
1541,
63,
262,
63,
7723,
9,
2541,
340,
1228,
8,
12318,
12,
5055,
14,
20852,
304,
267,
11883,
275,
359,
17,
61,
435,
769,
8,
12318,
9,
435,
359,
17,
61,
489,
587,
26,
267,
11883,
275,
359,
17,
12,
7345,
12,
7345,
12,
7345,
12,
413,
61,
2541,
340,
666,
63,
908,
508,
298,
6389,
13860,
55,
582,
267,
307,
17,
275,
511,
63,
1974,
14,
46,
15487,
1028,
79,
27086,
8,
84,
17,
9,
267,
11883,
275,
511,
63,
1974,
14,
46,
15487,
1028,
79,
27086,
8,
16759,
9,
489,
8260,
275,
11542,
63,
1483,
14,
5598,
19,
68,
8,
84,
17,
12,
307,
18,
12,
11883,
12,
6273,
29,
8358,
12,
2574,
666,
63,
908,
29,
576,
63,
908,
9,
489,
340,
666,
63,
908,
508,
298,
6389,
13860,
55,
582,
267,
8260,
275,
511,
63,
1974,
14,
27086,
1378,
46,
27121,
8,
5598,
9,
2541,
372,
8260,
819,
347,
485,
7496,
6550,
8,
277,
12,
2345,
63,
262,
63,
7723,
12,
2457,
63,
262,
63,
7723,
12,
7345,
12,
6273,
12,
490,
1420,
304,
272,
2058,
275,
942,
272,
367,
666,
63,
908,
12,
675,
63,
6477,
315,
2372,
774,
29123,
837,
489,
754,
275,
291,
423,
8555,
6550,
16775,
8,
881,
2345,
63,
262,
63,
7723,
12,
881,
2457,
63,
262,
63,
7723,
12,
881,
7345,
12,
881,
6273,
12,
881,
666,
63,
908,
12,
881,
675,
63,
6477,
29,
1180,
63,
6477,
9,
489,
2058,
14,
740,
8,
1099,
9,
489,
13464,
275,
413,
69,
13,
18,
340,
675,
63,
6477,
587,
413,
69,
13,
21,
489,
543,
291,
14,
396,
63,
1730,
342,
465,
4043,
26,
267,
1338,
275,
4043,
14,
1065,
8,
2604,
9,
267,
367,
574,
315,
1338,
26,
881,
870,
480,
2062,
275,
3872,
1420,
9,
881,
870,
480,
6514,
275,
3872,
574,
9,
881,
291,
14,
7260,
8,
2062,
12,
574,
14,
8487,
1062,
9543,
29,
16312,
12,
2892,
10561,
29,
17,
69,
13,
22,
9,
819,
347,
511,
11596,
19,
36,
17,
88,
17,
88,
17,
4131,
8,
277,
304,
272,
1420,
63,
1199,
275,
359,
267,
4233,
14,
16,
12,
8780,
14,
16,
12,
5685,
14,
16,
12,
14157,
14,
16,
12,
19071,
14,
16,
12,
15580,
14,
16,
12,
12996,
14,
16,
12,
21572,
14,
16,
12,
14711,
14,
16,
12,
26309,
14,
16,
12,
413,
3172,
14,
16,
12,
267,
14785,
14,
16,
12,
30698,
14,
16,
12,
30630,
14,
16,
12,
499,
2010,
14,
16,
12,
26160,
14,
16,
12,
499,
2976,
14,
16,
12,
650,
713,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1,
1,
1,
1,
1,
1,
1
] |
weiawe/django
|
django/core/cache/backends/locmem.py
|
586
|
4287
|
"Thread-safe in-memory cache backend."
import time
from contextlib import contextmanager
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.utils.synch import RWLock
try:
from django.utils.six.moves import cPickle as pickle
except ImportError:
import pickle
# Global in-memory store of cache data. Keyed by name, to provide
# multiple named local memory caches.
_caches = {}
_expire_info = {}
_locks = {}
@contextmanager
def dummy():
"""A context manager that does nothing special."""
yield
class LocMemCache(BaseCache):
def __init__(self, name, params):
BaseCache.__init__(self, params)
self._cache = _caches.setdefault(name, {})
self._expire_info = _expire_info.setdefault(name, {})
self._lock = _locks.setdefault(name, RWLock())
def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
key = self.make_key(key, version=version)
self.validate_key(key)
pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
with self._lock.writer():
if self._has_expired(key):
self._set(key, pickled, timeout)
return True
return False
def get(self, key, default=None, version=None, acquire_lock=True):
key = self.make_key(key, version=version)
self.validate_key(key)
pickled = None
with (self._lock.reader() if acquire_lock else dummy()):
if not self._has_expired(key):
pickled = self._cache[key]
if pickled is not None:
try:
return pickle.loads(pickled)
except pickle.PickleError:
return default
with (self._lock.writer() if acquire_lock else dummy()):
try:
del self._cache[key]
del self._expire_info[key]
except KeyError:
pass
return default
def _set(self, key, value, timeout=DEFAULT_TIMEOUT):
if len(self._cache) >= self._max_entries:
self._cull()
self._cache[key] = value
self._expire_info[key] = self.get_backend_timeout(timeout)
def set(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
key = self.make_key(key, version=version)
self.validate_key(key)
pickled = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
with self._lock.writer():
self._set(key, pickled, timeout)
def incr(self, key, delta=1, version=None):
with self._lock.writer():
value = self.get(key, version=version, acquire_lock=False)
if value is None:
raise ValueError("Key '%s' not found" % key)
new_value = value + delta
key = self.make_key(key, version=version)
pickled = pickle.dumps(new_value, pickle.HIGHEST_PROTOCOL)
self._cache[key] = pickled
return new_value
def has_key(self, key, version=None):
key = self.make_key(key, version=version)
self.validate_key(key)
with self._lock.reader():
if not self._has_expired(key):
return True
with self._lock.writer():
try:
del self._cache[key]
del self._expire_info[key]
except KeyError:
pass
return False
def _has_expired(self, key):
exp = self._expire_info.get(key, -1)
if exp is None or exp > time.time():
return False
return True
def _cull(self):
if self._cull_frequency == 0:
self.clear()
else:
doomed = [k for (i, k) in enumerate(self._cache) if i % self._cull_frequency == 0]
for k in doomed:
self._delete(k)
def _delete(self, key):
try:
del self._cache[key]
except KeyError:
pass
try:
del self._expire_info[key]
except KeyError:
pass
def delete(self, key, version=None):
key = self.make_key(key, version=version)
self.validate_key(key)
with self._lock.writer():
self._delete(key)
def clear(self):
self._cache.clear()
self._expire_info.clear()
|
bsd-3-clause
|
[
2,
4436,
13,
3489,
315,
13,
4844,
2581,
4865,
2122,
199,
199,
646,
900,
199,
504,
15502,
492,
27608,
199,
199,
504,
1639,
14,
1018,
14,
1637,
14,
7765,
14,
1095,
492,
6186,
63,
8899,
12,
3523,
4437,
199,
504,
1639,
14,
1208,
14,
83,
5654,
492,
820,
55,
6432,
199,
199,
893,
26,
272,
687,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
17572,
465,
5927,
199,
2590,
3545,
26,
272,
492,
5927,
421,
199,
3,
13641,
315,
13,
4844,
3877,
402,
2581,
666,
14,
2606,
379,
701,
536,
12,
370,
5647,
199,
3,
3663,
4310,
2257,
4402,
18014,
14,
199,
63,
17595,
275,
1052,
199,
63,
14691,
63,
815,
275,
1052,
199,
63,
20218,
275,
1052,
421,
199,
32,
14237,
199,
318,
7283,
837,
272,
408,
33,
1067,
5256,
626,
1630,
6548,
4539,
1041,
272,
1995,
421,
199,
533,
6263,
14169,
4437,
8,
1563,
4437,
304,
272,
347,
636,
826,
721,
277,
12,
536,
12,
1862,
304,
267,
3523,
4437,
855,
826,
721,
277,
12,
1862,
9,
267,
291,
423,
1637,
275,
485,
17595,
14,
5486,
8,
354,
12,
5009,
267,
291,
423,
14691,
63,
815,
275,
485,
14691,
63,
815,
14,
5486,
8,
354,
12,
5009,
267,
291,
423,
831,
275,
485,
20218,
14,
5486,
8,
354,
12,
820,
55,
6432,
1012,
339,
347,
1050,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
12,
1015,
29,
403,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14,
3502,
63,
498,
8,
498,
9,
267,
18731,
275,
5927,
14,
4180,
8,
585,
12,
5927,
14,
31977,
63,
9583,
9,
267,
543,
291,
423,
831,
14,
5491,
837,
288,
340,
291,
423,
1989,
63,
16340,
8,
498,
304,
355,
291,
423,
409,
8,
498,
12,
18731,
12,
2653,
9,
355,
372,
715,
288,
372,
756,
339,
347,
664,
8,
277,
12,
790,
12,
849,
29,
403,
12,
1015,
29,
403,
12,
16919,
63,
831,
29,
549,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14,
3502,
63,
498,
8,
498,
9,
267,
18731,
275,
488,
267,
543,
334,
277,
423,
831,
14,
5503,
342,
340,
16919,
63,
831,
587,
7283,
5109,
288,
340,
440,
291,
423,
1989,
63,
16340,
8,
498,
304,
355,
18731,
275,
291,
423,
1637,
59,
498,
61,
267,
340,
18731,
365,
440,
488,
26,
288,
862,
26,
355,
372,
5927,
14,
3640,
8,
20428,
9,
288,
871,
5927,
14,
12755,
547,
26,
355,
372,
849,
398,
543,
334,
277,
423,
831,
14,
5491,
342,
340,
16919,
63,
831,
587,
7283,
5109,
288,
862,
26,
355,
2150,
291,
423,
1637,
59,
498,
61,
355,
2150,
291,
423,
14691,
63,
815,
59,
498,
61,
288,
871,
4067,
26,
355,
986,
288,
372,
849,
339,
347,
485,
409,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
304,
267,
340,
822,
8,
277,
423,
1637,
9,
2356,
291,
423,
988,
63,
3189,
26,
288,
291,
423,
67,
979,
342,
267,
291,
423,
1637,
59,
498,
61,
275,
574,
267,
291,
423,
14691,
63,
815,
59,
498,
61,
275,
291,
14,
362,
63,
4620,
63,
2593,
8,
2593,
9,
339,
347,
663,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
12,
1015,
29,
403,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14,
3502,
63,
498,
8,
498,
9,
267,
18731,
275,
5927,
14,
4180,
8,
585,
12,
5927,
14,
31977,
63,
9583,
9,
267,
543,
291,
423,
831,
14,
5491,
837,
288,
291,
423,
409,
8,
498,
12,
18731,
12,
2653,
9,
339,
347,
315,
1556,
8,
277,
12,
790,
12,
5762,
29,
17,
12,
1015,
29,
403,
304,
267,
543,
291,
423,
831,
14,
5491,
837,
288,
574,
275,
291,
14,
362,
8,
498,
12,
1015,
29,
1023,
12,
16919,
63,
831,
29,
797,
9,
288,
340,
574,
365,
488,
26,
355,
746,
1722,
480,
1197,
1543,
83,
7,
440,
1911,
2,
450,
790,
9,
288,
892,
63,
585,
275,
574,
435,
5762,
288,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
288,
18731,
275,
5927,
14,
4180,
8,
1222,
63,
585,
12,
5927,
14,
31977,
63,
9583,
9,
288,
291,
423,
1637,
59,
498,
61,
275,
18731,
267,
372,
892,
63,
585,
339,
347,
965,
63,
498,
8,
277,
12,
790,
12,
1015,
29,
403,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14,
3502,
63,
498,
8,
498,
9,
267,
543,
291,
423,
831,
14,
5503,
837,
288,
340,
440,
291,
423,
1989,
63,
16340,
8,
498,
304,
355,
372,
715,
398,
543,
291,
423,
831,
14,
5491,
837,
288,
862,
26,
355,
2150,
291,
423,
1637,
59,
498,
61,
355,
2150,
291,
423,
14691,
63,
815,
59,
498,
61,
288,
871,
4067,
26,
355,
986,
288,
372,
756,
339,
347,
485,
1989,
63,
16340,
8,
277,
12,
790,
304,
267,
1437,
275,
291,
423,
14691,
63,
815,
14,
362,
8,
498,
12,
446,
17,
9,
267,
340,
1437,
365,
488,
503,
1437,
690,
900,
14,
521,
837,
288,
372,
756,
267,
372,
715,
339,
347,
485,
67,
979,
8,
277,
304,
267,
340,
291,
423,
67,
979,
63,
11132,
508,
378,
26,
288,
291,
14,
3584,
342,
267,
587,
26,
288,
886,
1377,
68,
275,
359,
75,
367,
334,
73,
12,
1022,
9,
315,
3874,
8,
277,
423,
1637,
9,
340,
284,
450,
291,
423,
67,
979,
63,
11132,
508,
378,
61,
288,
367,
1022,
315,
886,
1377,
68,
26,
355,
291,
423,
1807,
8,
75,
9,
339,
347,
485,
1807,
8,
277,
12,
790,
304,
267,
862,
26,
288,
2150,
291,
423,
1637,
59,
498,
61,
267,
871,
4067,
26,
288,
986,
267,
862,
26,
288,
2150,
291,
423,
14691,
63,
815,
59,
498,
61,
267,
871,
4067,
26,
288,
986,
339,
347,
3145,
8,
277,
12,
790,
12,
1015,
29,
403,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14
] |
[
4436,
13,
3489,
315,
13,
4844,
2581,
4865,
2122,
199,
199,
646,
900,
199,
504,
15502,
492,
27608,
199,
199,
504,
1639,
14,
1018,
14,
1637,
14,
7765,
14,
1095,
492,
6186,
63,
8899,
12,
3523,
4437,
199,
504,
1639,
14,
1208,
14,
83,
5654,
492,
820,
55,
6432,
199,
199,
893,
26,
272,
687,
1639,
14,
1208,
14,
4174,
14,
4912,
492,
17572,
465,
5927,
199,
2590,
3545,
26,
272,
492,
5927,
421,
199,
3,
13641,
315,
13,
4844,
3877,
402,
2581,
666,
14,
2606,
379,
701,
536,
12,
370,
5647,
199,
3,
3663,
4310,
2257,
4402,
18014,
14,
199,
63,
17595,
275,
1052,
199,
63,
14691,
63,
815,
275,
1052,
199,
63,
20218,
275,
1052,
421,
199,
32,
14237,
199,
318,
7283,
837,
272,
408,
33,
1067,
5256,
626,
1630,
6548,
4539,
1041,
272,
1995,
421,
199,
533,
6263,
14169,
4437,
8,
1563,
4437,
304,
272,
347,
636,
826,
721,
277,
12,
536,
12,
1862,
304,
267,
3523,
4437,
855,
826,
721,
277,
12,
1862,
9,
267,
291,
423,
1637,
275,
485,
17595,
14,
5486,
8,
354,
12,
5009,
267,
291,
423,
14691,
63,
815,
275,
485,
14691,
63,
815,
14,
5486,
8,
354,
12,
5009,
267,
291,
423,
831,
275,
485,
20218,
14,
5486,
8,
354,
12,
820,
55,
6432,
1012,
339,
347,
1050,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
12,
1015,
29,
403,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14,
3502,
63,
498,
8,
498,
9,
267,
18731,
275,
5927,
14,
4180,
8,
585,
12,
5927,
14,
31977,
63,
9583,
9,
267,
543,
291,
423,
831,
14,
5491,
837,
288,
340,
291,
423,
1989,
63,
16340,
8,
498,
304,
355,
291,
423,
409,
8,
498,
12,
18731,
12,
2653,
9,
355,
372,
715,
288,
372,
756,
339,
347,
664,
8,
277,
12,
790,
12,
849,
29,
403,
12,
1015,
29,
403,
12,
16919,
63,
831,
29,
549,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14,
3502,
63,
498,
8,
498,
9,
267,
18731,
275,
488,
267,
543,
334,
277,
423,
831,
14,
5503,
342,
340,
16919,
63,
831,
587,
7283,
5109,
288,
340,
440,
291,
423,
1989,
63,
16340,
8,
498,
304,
355,
18731,
275,
291,
423,
1637,
59,
498,
61,
267,
340,
18731,
365,
440,
488,
26,
288,
862,
26,
355,
372,
5927,
14,
3640,
8,
20428,
9,
288,
871,
5927,
14,
12755,
547,
26,
355,
372,
849,
398,
543,
334,
277,
423,
831,
14,
5491,
342,
340,
16919,
63,
831,
587,
7283,
5109,
288,
862,
26,
355,
2150,
291,
423,
1637,
59,
498,
61,
355,
2150,
291,
423,
14691,
63,
815,
59,
498,
61,
288,
871,
4067,
26,
355,
986,
288,
372,
849,
339,
347,
485,
409,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
304,
267,
340,
822,
8,
277,
423,
1637,
9,
2356,
291,
423,
988,
63,
3189,
26,
288,
291,
423,
67,
979,
342,
267,
291,
423,
1637,
59,
498,
61,
275,
574,
267,
291,
423,
14691,
63,
815,
59,
498,
61,
275,
291,
14,
362,
63,
4620,
63,
2593,
8,
2593,
9,
339,
347,
663,
8,
277,
12,
790,
12,
574,
12,
2653,
29,
3472,
63,
8899,
12,
1015,
29,
403,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14,
3502,
63,
498,
8,
498,
9,
267,
18731,
275,
5927,
14,
4180,
8,
585,
12,
5927,
14,
31977,
63,
9583,
9,
267,
543,
291,
423,
831,
14,
5491,
837,
288,
291,
423,
409,
8,
498,
12,
18731,
12,
2653,
9,
339,
347,
315,
1556,
8,
277,
12,
790,
12,
5762,
29,
17,
12,
1015,
29,
403,
304,
267,
543,
291,
423,
831,
14,
5491,
837,
288,
574,
275,
291,
14,
362,
8,
498,
12,
1015,
29,
1023,
12,
16919,
63,
831,
29,
797,
9,
288,
340,
574,
365,
488,
26,
355,
746,
1722,
480,
1197,
1543,
83,
7,
440,
1911,
2,
450,
790,
9,
288,
892,
63,
585,
275,
574,
435,
5762,
288,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
288,
18731,
275,
5927,
14,
4180,
8,
1222,
63,
585,
12,
5927,
14,
31977,
63,
9583,
9,
288,
291,
423,
1637,
59,
498,
61,
275,
18731,
267,
372,
892,
63,
585,
339,
347,
965,
63,
498,
8,
277,
12,
790,
12,
1015,
29,
403,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
291,
14,
3502,
63,
498,
8,
498,
9,
267,
543,
291,
423,
831,
14,
5503,
837,
288,
340,
440,
291,
423,
1989,
63,
16340,
8,
498,
304,
355,
372,
715,
398,
543,
291,
423,
831,
14,
5491,
837,
288,
862,
26,
355,
2150,
291,
423,
1637,
59,
498,
61,
355,
2150,
291,
423,
14691,
63,
815,
59,
498,
61,
288,
871,
4067,
26,
355,
986,
288,
372,
756,
339,
347,
485,
1989,
63,
16340,
8,
277,
12,
790,
304,
267,
1437,
275,
291,
423,
14691,
63,
815,
14,
362,
8,
498,
12,
446,
17,
9,
267,
340,
1437,
365,
488,
503,
1437,
690,
900,
14,
521,
837,
288,
372,
756,
267,
372,
715,
339,
347,
485,
67,
979,
8,
277,
304,
267,
340,
291,
423,
67,
979,
63,
11132,
508,
378,
26,
288,
291,
14,
3584,
342,
267,
587,
26,
288,
886,
1377,
68,
275,
359,
75,
367,
334,
73,
12,
1022,
9,
315,
3874,
8,
277,
423,
1637,
9,
340,
284,
450,
291,
423,
67,
979,
63,
11132,
508,
378,
61,
288,
367,
1022,
315,
886,
1377,
68,
26,
355,
291,
423,
1807,
8,
75,
9,
339,
347,
485,
1807,
8,
277,
12,
790,
304,
267,
862,
26,
288,
2150,
291,
423,
1637,
59,
498,
61,
267,
871,
4067,
26,
288,
986,
267,
862,
26,
288,
2150,
291,
423,
14691,
63,
815,
59,
498,
61,
267,
871,
4067,
26,
288,
986,
339,
347,
3145,
8,
277,
12,
790,
12,
1015,
29,
403,
304,
267,
790,
275,
291,
14,
1875,
63,
498,
8,
498,
12,
1015,
29,
1023,
9,
267,
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,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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
] |
un33k/CouchPotatoServer
|
libs/subliminal/services/subswiki.py
|
105
|
5182
|
# -*- coding: utf-8 -*-
# Copyright 2011-2012 Antoine Bertin <diaoulael@gmail.com>
#
# This file is part of subliminal.
#
# subliminal is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# subliminal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with subliminal. If not, see <http://www.gnu.org/licenses/>.
from . import ServiceBase
from ..exceptions import ServiceError
from ..language import language_set, Language
from ..subtitles import get_subtitle_path, ResultSubtitle
from ..utils import get_keywords, split_keyword
from ..videos import Episode, Movie
from bs4 import BeautifulSoup
import logging
import urllib
logger = logging.getLogger(__name__)
class SubsWiki(ServiceBase):
server_url = 'http://www.subswiki.com'
api_based = False
languages = language_set(['eng-US', 'eng-GB', 'eng', 'fre', 'por-BR', 'por', 'spa-ES', u'spa', u'ita', u'cat'])
language_map = {u'Español': Language('spa'), u'Español (España)': Language('spa'), u'Español (Latinoamérica)': Language('spa'),
u'Català': Language('cat'), u'Brazilian': Language('por-BR'), u'English (US)': Language('eng-US'),
u'English (UK)': Language('eng-GB')}
language_code = 'name'
videos = [Episode, Movie]
require_video = False
required_features = ['permissive']
def list_checked(self, video, languages):
results = []
if isinstance(video, Episode):
results = self.query(video.path or video.release, languages, get_keywords(video.guess), series=video.series, season=video.season, episode=video.episode)
elif isinstance(video, Movie) and video.year:
results = self.query(video.path or video.release, languages, get_keywords(video.guess), movie=video.title, year=video.year)
return results
def query(self, filepath, languages, keywords=None, series=None, season=None, episode=None, movie=None, year=None):
if series and season and episode:
request_series = series.lower().replace(' ', '_')
if isinstance(request_series, unicode):
request_series = request_series.encode('utf-8')
logger.debug(u'Getting subtitles for %s season %d episode %d with languages %r' % (series, season, episode, languages))
r = self.session.get('%s/serie/%s/%s/%s/' % (self.server_url, urllib.quote(request_series), season, episode))
if r.status_code == 404:
logger.debug(u'Could not find subtitles for %s season %d episode %d with languages %r' % (series, season, episode, languages))
return []
elif movie and year:
request_movie = movie.title().replace(' ', '_')
if isinstance(request_movie, unicode):
request_movie = request_movie.encode('utf-8')
logger.debug(u'Getting subtitles for %s (%d) with languages %r' % (movie, year, languages))
r = self.session.get('%s/film/%s_(%d)' % (self.server_url, urllib.quote(request_movie), year))
if r.status_code == 404:
logger.debug(u'Could not find subtitles for %s (%d) with languages %r' % (movie, year, languages))
return []
else:
raise ServiceError('One or more parameter missing')
if r.status_code != 200:
logger.error(u'Request %s returned status code %d' % (r.url, r.status_code))
return []
soup = BeautifulSoup(r.content, self.required_features)
subtitles = []
for sub in soup('td', {'class': 'NewsTitle'}):
sub_keywords = split_keyword(sub.b.string.lower())
if not keywords & sub_keywords:
logger.debug(u'None of subtitle keywords %r in %r' % (sub_keywords, keywords))
continue
for html_language in sub.parent.parent.find_all('td', {'class': 'language'}):
language = self.get_language(html_language.string.strip())
if language not in languages:
logger.debug(u'Language %r not in wanted languages %r' % (language, languages))
continue
html_status = html_language.find_next_sibling('td')
status = html_status.strong.string.strip()
if status != 'Completado':
logger.debug(u'Wrong subtitle status %s' % status)
continue
path = get_subtitle_path(filepath, language, self.config.multi)
subtitle = ResultSubtitle(path, language, self.__class__.__name__.lower(), '%s%s' % (self.server_url, html_status.find_next('td').find('a')['href']))
subtitles.append(subtitle)
return subtitles
Service = SubsWiki
|
gpl-3.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
7760,
13,
7409,
437,
29680,
1132,
23207,
1346,
665,
2391,
79,
7586,
352,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
1007,
13769,
279,
14,
199,
3,
199,
3,
1007,
13769,
279,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
199,
3,
314,
2895,
402,
314,
1664,
6401,
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,
1007,
13769,
279,
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,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
1007,
13769,
279,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
504,
1275,
492,
7591,
1563,
199,
504,
2508,
3924,
492,
7591,
547,
199,
504,
2508,
3671,
492,
2637,
63,
409,
12,
8466,
199,
504,
2508,
16858,
492,
664,
63,
14348,
63,
515,
12,
10695,
29907,
199,
504,
2508,
1208,
492,
664,
63,
7511,
12,
3715,
63,
6691,
199,
504,
2508,
11418,
492,
27255,
6045,
12,
31248,
199,
504,
9922,
20,
492,
17132,
199,
646,
2050,
199,
646,
4011,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
4804,
83,
26198,
8,
3167,
1563,
304,
272,
1654,
63,
633,
275,
283,
1014,
921,
1544,
14,
954,
3519,
11545,
14,
957,
7,
272,
2986,
63,
6788,
275,
756,
272,
10815,
275,
2637,
63,
409,
2941,
7420,
13,
1668,
297,
283,
7420,
13,
6487,
297,
283,
7420,
297,
283,
20153,
297,
283,
7314,
13,
7184,
297,
283,
7314,
297,
283,
3770,
13,
654,
297,
399,
1159,
387,
297,
399,
7,
21492,
297,
399,
7,
3385,
1105,
272,
2637,
63,
1130,
275,
469,
85,
7,
37,
3770,
22692,
393,
356,
8466,
360,
3770,
659,
399,
7,
37,
3770,
22692,
393,
334,
37,
3770,
22692,
65,
11862,
8466,
360,
3770,
659,
399,
7,
37,
3770,
22692,
393,
334,
22510,
10175,
455,
5741,
7127,
11862,
8466,
360,
3770,
659,
490,
399,
7,
35,
7539,
26482,
356,
8466,
360,
3385,
659,
399,
7,
17171,
90,
1638,
290,
356,
8466,
360,
7314,
13,
7184,
659,
399,
7,
19410,
334,
1668,
11862,
8466,
360,
7420,
13,
1668,
659,
490,
399,
7,
19410,
334,
26667,
11862,
8466,
360,
7420,
13,
6487,
21004,
272,
2637,
63,
600,
275,
283,
354,
7,
272,
22010,
275,
359,
22887,
12,
31248,
61,
272,
4409,
63,
3722,
275,
756,
272,
1415,
63,
3179,
275,
788,
529,
32237,
418,
339,
347,
769,
63,
10718,
8,
277,
12,
3991,
12,
10815,
304,
267,
2058,
275,
942,
267,
340,
1228,
8,
3722,
12,
27255,
6045,
304,
288,
2058,
275,
291,
14,
1131,
8,
3722,
14,
515,
503,
3991,
14,
3221,
12,
10815,
12,
664,
63,
7511,
8,
3722,
14,
11636,
395,
6779,
29,
3722,
14,
5602,
12,
14718,
29,
3722,
14,
12605,
12,
11052,
29,
3722,
14,
9544,
9,
267,
916,
1228,
8,
3722,
12,
31248,
9,
436,
3991,
14,
3403,
26,
288,
2058,
275,
291,
14,
1131,
8,
3722,
14,
515,
503,
3991,
14,
3221,
12,
10815,
12,
664,
63,
7511,
8,
3722,
14,
11636,
395,
14360,
29,
3722,
14,
1213,
12,
5361,
29,
3722,
14,
3403,
9,
267,
372,
2058,
339,
347,
1827,
8,
277,
12,
9911,
12,
10815,
12,
7681,
29,
403,
12,
6779,
29,
403,
12,
14718,
29,
403,
12,
11052,
29,
403,
12,
14360,
29,
403,
12,
5361,
29,
403,
304,
267,
340,
6779,
436,
14718,
436,
11052,
26,
288,
1056,
63,
5602,
275,
6779,
14,
2325,
1252,
1814,
360,
1656,
18962,
288,
340,
1228,
8,
1069,
63,
5602,
12,
2649,
304,
355,
1056,
63,
5602,
275,
1056,
63,
5602,
14,
2143,
360,
1624,
13,
24,
358,
288,
2512,
14,
1757,
8,
85,
7,
28277,
19297,
367,
450,
83,
14718,
450,
68,
11052,
450,
68,
543,
10815,
450,
82,
7,
450,
334,
5602,
12,
14718,
12,
11052,
12,
10815,
430,
288,
519,
275,
291,
14,
1730,
14,
362,
3508,
83,
15,
261,
11317,
3149,
83,
3149,
83,
3149,
83,
4805,
450,
334,
277,
14,
1000,
63,
633,
12,
4011,
14,
3513,
8,
1069,
63,
5602,
395,
14718,
12,
11052,
430,
288,
340,
519,
14,
1205,
63,
600,
508,
7901,
26,
355,
2512,
14,
1757,
8,
85,
7,
6531,
440,
2342,
19297,
367,
450,
83,
14718,
450,
68,
11052,
450,
68,
543,
10815,
450,
82,
7,
450,
334,
5602,
12,
14718,
12,
11052,
12,
10815,
430,
355,
372,
942,
267,
916,
14360,
436,
5361,
26,
288,
1056,
63,
10888,
275,
14360,
14,
1213,
1252,
1814,
360,
1656,
18962,
288,
340,
1228,
8,
1069,
63,
10888,
12,
2649,
304,
355,
1056,
63,
10888,
275,
1056,
63,
10888,
14,
2143,
360,
1624,
13,
24,
358,
288,
2512,
14,
1757,
8,
85,
7,
28277,
19297,
367,
450,
83,
4366,
68,
9,
543,
10815,
450,
82,
7,
450,
334,
10888,
12,
5361,
12,
10815,
430,
288,
519,
275,
291,
14,
1730,
14,
362,
3508,
83,
15,
1289,
77,
3149,
83,
2531,
5,
68,
3171,
450,
334,
277,
14,
1000,
63,
633,
12,
4011,
14,
3513,
8,
1069,
63,
10888,
395,
5361,
430,
288,
340,
519,
14,
1205,
63,
600,
508,
7901,
26,
355,
2512,
14,
1757,
8,
85,
7,
6531,
440,
2342,
19297,
367,
450,
83,
4366,
68,
9,
543,
10815,
450,
82,
7,
450,
334,
10888,
12,
5361,
12,
10815,
430,
355,
372,
942,
267,
587,
26,
288,
746,
7591,
547,
360,
4395,
503,
1655,
2725,
4124,
358,
267,
340,
519,
14,
1205,
63,
600,
1137,
1926,
26,
288,
2512,
14,
705,
8,
85,
7,
2017,
450,
83,
2138,
2004,
1233,
450,
68,
7,
450,
334,
82,
14,
633,
12,
519,
14,
1205,
63,
600,
430,
288,
372,
942,
267,
9108,
275,
17132,
8,
82,
14,
1317
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
1898,
7760,
13,
7409,
437,
29680,
1132,
23207,
1346,
665,
2391,
79,
7586,
352,
32,
6799,
14,
957,
30,
199,
3,
199,
3,
961,
570,
365,
1777,
402,
1007,
13769,
279,
14,
199,
3,
199,
3,
1007,
13769,
279,
365,
2867,
2032,
27,
1265,
883,
3604,
652,
436,
15,
269,
2811,
652,
1334,
199,
3,
314,
2895,
402,
314,
1664,
6401,
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,
1007,
13769,
279,
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,
1696,
1684,
844,
367,
1655,
2436,
14,
199,
3,
199,
3,
2047,
1077,
1172,
3086,
282,
1331,
402,
314,
1664,
6401,
1696,
1684,
844,
199,
3,
3180,
543,
1007,
13769,
279,
14,
221,
982,
440,
12,
1937,
665,
1014,
921,
1544,
14,
3689,
14,
1308,
15,
2383,
4743,
199,
504,
1275,
492,
7591,
1563,
199,
504,
2508,
3924,
492,
7591,
547,
199,
504,
2508,
3671,
492,
2637,
63,
409,
12,
8466,
199,
504,
2508,
16858,
492,
664,
63,
14348,
63,
515,
12,
10695,
29907,
199,
504,
2508,
1208,
492,
664,
63,
7511,
12,
3715,
63,
6691,
199,
504,
2508,
11418,
492,
27255,
6045,
12,
31248,
199,
504,
9922,
20,
492,
17132,
199,
646,
2050,
199,
646,
4011,
421,
199,
2921,
275,
2050,
14,
5572,
3460,
354,
3368,
421,
199,
533,
4804,
83,
26198,
8,
3167,
1563,
304,
272,
1654,
63,
633,
275,
283,
1014,
921,
1544,
14,
954,
3519,
11545,
14,
957,
7,
272,
2986,
63,
6788,
275,
756,
272,
10815,
275,
2637,
63,
409,
2941,
7420,
13,
1668,
297,
283,
7420,
13,
6487,
297,
283,
7420,
297,
283,
20153,
297,
283,
7314,
13,
7184,
297,
283,
7314,
297,
283,
3770,
13,
654,
297,
399,
1159,
387,
297,
399,
7,
21492,
297,
399,
7,
3385,
1105,
272,
2637,
63,
1130,
275,
469,
85,
7,
37,
3770,
22692,
393,
356,
8466,
360,
3770,
659,
399,
7,
37,
3770,
22692,
393,
334,
37,
3770,
22692,
65,
11862,
8466,
360,
3770,
659,
399,
7,
37,
3770,
22692,
393,
334,
22510,
10175,
455,
5741,
7127,
11862,
8466,
360,
3770,
659,
490,
399,
7,
35,
7539,
26482,
356,
8466,
360,
3385,
659,
399,
7,
17171,
90,
1638,
290,
356,
8466,
360,
7314,
13,
7184,
659,
399,
7,
19410,
334,
1668,
11862,
8466,
360,
7420,
13,
1668,
659,
490,
399,
7,
19410,
334,
26667,
11862,
8466,
360,
7420,
13,
6487,
21004,
272,
2637,
63,
600,
275,
283,
354,
7,
272,
22010,
275,
359,
22887,
12,
31248,
61,
272,
4409,
63,
3722,
275,
756,
272,
1415,
63,
3179,
275,
788,
529,
32237,
418,
339,
347,
769,
63,
10718,
8,
277,
12,
3991,
12,
10815,
304,
267,
2058,
275,
942,
267,
340,
1228,
8,
3722,
12,
27255,
6045,
304,
288,
2058,
275,
291,
14,
1131,
8,
3722,
14,
515,
503,
3991,
14,
3221,
12,
10815,
12,
664,
63,
7511,
8,
3722,
14,
11636,
395,
6779,
29,
3722,
14,
5602,
12,
14718,
29,
3722,
14,
12605,
12,
11052,
29,
3722,
14,
9544,
9,
267,
916,
1228,
8,
3722,
12,
31248,
9,
436,
3991,
14,
3403,
26,
288,
2058,
275,
291,
14,
1131,
8,
3722,
14,
515,
503,
3991,
14,
3221,
12,
10815,
12,
664,
63,
7511,
8,
3722,
14,
11636,
395,
14360,
29,
3722,
14,
1213,
12,
5361,
29,
3722,
14,
3403,
9,
267,
372,
2058,
339,
347,
1827,
8,
277,
12,
9911,
12,
10815,
12,
7681,
29,
403,
12,
6779,
29,
403,
12,
14718,
29,
403,
12,
11052,
29,
403,
12,
14360,
29,
403,
12,
5361,
29,
403,
304,
267,
340,
6779,
436,
14718,
436,
11052,
26,
288,
1056,
63,
5602,
275,
6779,
14,
2325,
1252,
1814,
360,
1656,
18962,
288,
340,
1228,
8,
1069,
63,
5602,
12,
2649,
304,
355,
1056,
63,
5602,
275,
1056,
63,
5602,
14,
2143,
360,
1624,
13,
24,
358,
288,
2512,
14,
1757,
8,
85,
7,
28277,
19297,
367,
450,
83,
14718,
450,
68,
11052,
450,
68,
543,
10815,
450,
82,
7,
450,
334,
5602,
12,
14718,
12,
11052,
12,
10815,
430,
288,
519,
275,
291,
14,
1730,
14,
362,
3508,
83,
15,
261,
11317,
3149,
83,
3149,
83,
3149,
83,
4805,
450,
334,
277,
14,
1000,
63,
633,
12,
4011,
14,
3513,
8,
1069,
63,
5602,
395,
14718,
12,
11052,
430,
288,
340,
519,
14,
1205,
63,
600,
508,
7901,
26,
355,
2512,
14,
1757,
8,
85,
7,
6531,
440,
2342,
19297,
367,
450,
83,
14718,
450,
68,
11052,
450,
68,
543,
10815,
450,
82,
7,
450,
334,
5602,
12,
14718,
12,
11052,
12,
10815,
430,
355,
372,
942,
267,
916,
14360,
436,
5361,
26,
288,
1056,
63,
10888,
275,
14360,
14,
1213,
1252,
1814,
360,
1656,
18962,
288,
340,
1228,
8,
1069,
63,
10888,
12,
2649,
304,
355,
1056,
63,
10888,
275,
1056,
63,
10888,
14,
2143,
360,
1624,
13,
24,
358,
288,
2512,
14,
1757,
8,
85,
7,
28277,
19297,
367,
450,
83,
4366,
68,
9,
543,
10815,
450,
82,
7,
450,
334,
10888,
12,
5361,
12,
10815,
430,
288,
519,
275,
291,
14,
1730,
14,
362,
3508,
83,
15,
1289,
77,
3149,
83,
2531,
5,
68,
3171,
450,
334,
277,
14,
1000,
63,
633,
12,
4011,
14,
3513,
8,
1069,
63,
10888,
395,
5361,
430,
288,
340,
519,
14,
1205,
63,
600,
508,
7901,
26,
355,
2512,
14,
1757,
8,
85,
7,
6531,
440,
2342,
19297,
367,
450,
83,
4366,
68,
9,
543,
10815,
450,
82,
7,
450,
334,
10888,
12,
5361,
12,
10815,
430,
355,
372,
942,
267,
587,
26,
288,
746,
7591,
547,
360,
4395,
503,
1655,
2725,
4124,
358,
267,
340,
519,
14,
1205,
63,
600,
1137,
1926,
26,
288,
2512,
14,
705,
8,
85,
7,
2017,
450,
83,
2138,
2004,
1233,
450,
68,
7,
450,
334,
82,
14,
633,
12,
519,
14,
1205,
63,
600,
430,
288,
372,
942,
267,
9108,
275,
17132,
8,
82,
14,
1317,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] |
xfournet/intellij-community
|
python/lib/Lib/encodings/unicode_escape.py
|
852
|
1184
|
""" Python 'unicode-escape' Codec
Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""
import codecs
### Codec APIs
class Codec(codecs.Codec):
# Note: Binding these as C functions will result in the class not
# converting them to methods. This is intended.
encode = codecs.unicode_escape_encode
decode = codecs.unicode_escape_decode
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
return codecs.unicode_escape_encode(input, self.errors)[0]
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
return codecs.unicode_escape_decode(input, self.errors)[0]
class StreamWriter(Codec,codecs.StreamWriter):
pass
class StreamReader(Codec,codecs.StreamReader):
pass
### encodings module API
def getregentry():
return codecs.CodecInfo(
name='unicode-escape',
encode=Codec.encode,
decode=Codec.decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamwriter=StreamWriter,
streamreader=StreamReader,
)
|
apache-2.0
|
[
624,
2018,
283,
2975,
13,
3765,
7,
13732,
421,
199,
32329,
701,
603,
9912,
13,
3325,
264,
7005,
32649,
334,
2174,
32,
274,
32649,
14,
957,
680,
199,
199,
8,
67,
9,
1898,
445,
46,
6129,
12,
2900,
5924,
5702,
14,
4825,
3408,
14,
199,
199,
624,
199,
646,
6010,
199,
199,
5680,
13732,
15913,
199,
199,
533,
13732,
8,
8933,
14,
8818,
304,
339,
327,
3390,
26,
22630,
316,
3520,
465,
445,
3423,
911,
754,
315,
314,
1021,
440,
272,
327,
13806,
3062,
370,
3102,
14,
961,
365,
11619,
14,
272,
3752,
275,
6010,
14,
2975,
63,
3765,
63,
2143,
272,
4849,
275,
6010,
14,
2975,
63,
3765,
63,
2708,
199,
199,
533,
24350,
8,
8933,
14,
17016,
304,
272,
347,
3752,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
2975,
63,
3765,
63,
2143,
8,
1210,
12,
291,
14,
2550,
2788,
16,
61,
199,
199,
533,
24385,
8,
8933,
14,
16703,
304,
272,
347,
4849,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
2975,
63,
3765,
63,
2708,
8,
1210,
12,
291,
14,
2550,
2788,
16,
61,
199,
199,
533,
24163,
8,
8818,
12,
8933,
14,
16551,
304,
272,
986,
199,
199,
533,
22970,
8,
8818,
12,
8933,
14,
16132,
304,
272,
986,
199,
199,
5680,
14134,
859,
3261,
199,
199,
318,
26116,
837,
272,
372,
6010,
14,
26375,
8,
267,
536,
534,
2975,
13,
3765,
297,
267,
3752,
29,
8818,
14,
2143,
12,
267,
4849,
29,
8818,
14,
2708,
12,
267,
26329,
29,
17016,
12,
267,
26317,
29,
16703,
12,
267,
26112,
29,
16551,
12,
267,
26101,
29,
16132,
12,
272,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
2018,
283,
2975,
13,
3765,
7,
13732,
421,
199,
32329,
701,
603,
9912,
13,
3325,
264,
7005,
32649,
334,
2174,
32,
274,
32649,
14,
957,
680,
199,
199,
8,
67,
9,
1898,
445,
46,
6129,
12,
2900,
5924,
5702,
14,
4825,
3408,
14,
199,
199,
624,
199,
646,
6010,
199,
199,
5680,
13732,
15913,
199,
199,
533,
13732,
8,
8933,
14,
8818,
304,
339,
327,
3390,
26,
22630,
316,
3520,
465,
445,
3423,
911,
754,
315,
314,
1021,
440,
272,
327,
13806,
3062,
370,
3102,
14,
961,
365,
11619,
14,
272,
3752,
275,
6010,
14,
2975,
63,
3765,
63,
2143,
272,
4849,
275,
6010,
14,
2975,
63,
3765,
63,
2708,
199,
199,
533,
24350,
8,
8933,
14,
17016,
304,
272,
347,
3752,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
2975,
63,
3765,
63,
2143,
8,
1210,
12,
291,
14,
2550,
2788,
16,
61,
199,
199,
533,
24385,
8,
8933,
14,
16703,
304,
272,
347,
4849,
8,
277,
12,
1324,
12,
4242,
29,
797,
304,
267,
372,
6010,
14,
2975,
63,
3765,
63,
2708,
8,
1210,
12,
291,
14,
2550,
2788,
16,
61,
199,
199,
533,
24163,
8,
8818,
12,
8933,
14,
16551,
304,
272,
986,
199,
199,
533,
22970,
8,
8818,
12,
8933,
14,
16132,
304,
272,
986,
199,
199,
5680,
14134,
859,
3261,
199,
199,
318,
26116,
837,
272,
372,
6010,
14,
26375,
8,
267,
536,
534,
2975,
13,
3765,
297,
267,
3752,
29,
8818,
14,
2143,
12,
267,
4849,
29,
8818,
14,
2708,
12,
267,
26329,
29,
17016,
12,
267,
26317,
29,
16703,
12,
267,
26112,
29,
16551,
12,
267,
26101,
29,
16132,
12,
272,
776,
199,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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,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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
] |
40223113/0623-w17
|
static/Brython3.1.1-20150328-091302/Lib/xml/sax/handler.py
|
925
|
13922
|
"""
This module contains the core classes of version 2.0 of SAX for Python.
This file provides only default classes with absolutely minimum
functionality, from which drivers and applications can be subclassed.
Many of these classes are empty and are included only as documentation
of the interfaces.
$Id$
"""
version = '2.0beta'
#============================================================================
#
# HANDLER INTERFACES
#
#============================================================================
# ===== ERRORHANDLER =====
class ErrorHandler:
"""Basic interface for SAX error handlers.
If you create an object that implements this interface, then
register the object with your XMLReader, the parser will call the
methods in your object to report all warnings and errors. There
are three levels of errors available: warnings, (possibly)
recoverable errors, and unrecoverable errors. All methods take a
SAXParseException as the only parameter."""
def error(self, exception):
"Handle a recoverable error."
raise exception
def fatalError(self, exception):
"Handle a non-recoverable error."
raise exception
def warning(self, exception):
"Handle a warning."
print(exception)
# ===== CONTENTHANDLER =====
class ContentHandler:
"""Interface for receiving logical document content events.
This is the main callback interface in SAX, and the one most
important to applications. The order of events in this interface
mirrors the order of the information in the document."""
def __init__(self):
self._locator = None
def setDocumentLocator(self, locator):
"""Called by the parser to give the application a locator for
locating the origin of document events.
SAX parsers are strongly encouraged (though not absolutely
required) to supply a locator: if it does so, it must supply
the locator to the application by invoking this method before
invoking any of the other methods in the DocumentHandler
interface.
The locator allows the application to determine the end
position of any document-related event, even if the parser is
not reporting an error. Typically, the application will use
this information for reporting its own errors (such as
character content that does not match an application's
business rules). The information returned by the locator is
probably not sufficient for use with a search engine.
Note that the locator will return correct information only
during the invocation of the events in this interface. The
application should not attempt to use it at any other time."""
self._locator = locator
def startDocument(self):
"""Receive notification of the beginning of a document.
The SAX parser will invoke this method only once, before any
other methods in this interface or in DTDHandler (except for
setDocumentLocator)."""
def endDocument(self):
"""Receive notification of the end of a document.
The SAX parser will invoke this method only once, and it will
be the last method invoked during the parse. The parser shall
not invoke this method until it has either abandoned parsing
(because of an unrecoverable error) or reached the end of
input."""
def startPrefixMapping(self, prefix, uri):
"""Begin the scope of a prefix-URI Namespace mapping.
The information from this event is not necessary for normal
Namespace processing: the SAX XML reader will automatically
replace prefixes for element and attribute names when the
http://xml.org/sax/features/namespaces feature is true (the
default).
There are cases, however, when applications need to use
prefixes in character data or in attribute values, where they
cannot safely be expanded automatically; the
start/endPrefixMapping event supplies the information to the
application to expand prefixes in those contexts itself, if
necessary.
Note that start/endPrefixMapping events are not guaranteed to
be properly nested relative to each-other: all
startPrefixMapping events will occur before the corresponding
startElement event, and all endPrefixMapping events will occur
after the corresponding endElement event, but their order is
not guaranteed."""
def endPrefixMapping(self, prefix):
"""End the scope of a prefix-URI mapping.
See startPrefixMapping for details. This event will always
occur after the corresponding endElement event, but the order
of endPrefixMapping events is not otherwise guaranteed."""
def startElement(self, name, attrs):
"""Signals the start of an element in non-namespace mode.
The name parameter contains the raw XML 1.0 name of the
element type as a string and the attrs parameter holds an
instance of the Attributes class containing the attributes of
the element."""
def endElement(self, name):
"""Signals the end of an element in non-namespace mode.
The name parameter contains the name of the element type, just
as with the startElement event."""
def startElementNS(self, name, qname, attrs):
"""Signals the start of an element in namespace mode.
The name parameter contains the name of the element type as a
(uri, localname) tuple, the qname parameter the raw XML 1.0
name used in the source document, and the attrs parameter
holds an instance of the Attributes class containing the
attributes of the element.
The uri part of the name tuple is None for elements which have
no namespace."""
def endElementNS(self, name, qname):
"""Signals the end of an element in namespace mode.
The name parameter contains the name of the element type, just
as with the startElementNS event."""
def characters(self, content):
"""Receive notification of character data.
The Parser will call this method to report each chunk of
character data. SAX parsers may return all contiguous
character data in a single chunk, or they may split it into
several chunks; however, all of the characters in any single
event must come from the same external entity so that the
Locator provides useful information."""
def ignorableWhitespace(self, whitespace):
"""Receive notification of ignorable whitespace in element content.
Validating Parsers must use this method to report each chunk
of ignorable whitespace (see the W3C XML 1.0 recommendation,
section 2.10): non-validating parsers may also use this method
if they are capable of parsing and using content models.
SAX parsers may return all contiguous whitespace in a single
chunk, or they may split it into several chunks; however, all
of the characters in any single event must come from the same
external entity, so that the Locator provides useful
information."""
def processingInstruction(self, target, data):
"""Receive notification of a processing instruction.
The Parser will invoke this method once for each processing
instruction found: note that processing instructions may occur
before or after the main document element.
A SAX parser should never report an XML declaration (XML 1.0,
section 2.8) or a text declaration (XML 1.0, section 4.3.1)
using this method."""
def skippedEntity(self, name):
"""Receive notification of a skipped entity.
The Parser will invoke this method once for each entity
skipped. Non-validating processors may skip entities if they
have not seen the declarations (because, for example, the
entity was declared in an external DTD subset). All processors
may skip external entities, depending on the values of the
http://xml.org/sax/features/external-general-entities and the
http://xml.org/sax/features/external-parameter-entities
properties."""
# ===== DTDHandler =====
class DTDHandler:
"""Handle DTD events.
This interface specifies only those DTD events required for basic
parsing (unparsed entities and attributes)."""
def notationDecl(self, name, publicId, systemId):
"Handle a notation declaration event."
def unparsedEntityDecl(self, name, publicId, systemId, ndata):
"Handle an unparsed entity declaration event."
# ===== ENTITYRESOLVER =====
class EntityResolver:
"""Basic interface for resolving entities. If you create an object
implementing this interface, then register the object with your
Parser, the parser will call the method in your object to
resolve all external entities. Note that DefaultHandler implements
this interface with the default behaviour."""
def resolveEntity(self, publicId, systemId):
"""Resolve the system identifier of an entity and return either
the system identifier to read from as a string, or an InputSource
to read from."""
return systemId
#============================================================================
#
# CORE FEATURES
#
#============================================================================
feature_namespaces = "http://xml.org/sax/features/namespaces"
# true: Perform Namespace processing (default).
# false: Optionally do not perform Namespace processing
# (implies namespace-prefixes).
# access: (parsing) read-only; (not parsing) read/write
feature_namespace_prefixes = "http://xml.org/sax/features/namespace-prefixes"
# true: Report the original prefixed names and attributes used for Namespace
# declarations.
# false: Do not report attributes used for Namespace declarations, and
# optionally do not report original prefixed names (default).
# access: (parsing) read-only; (not parsing) read/write
feature_string_interning = "http://xml.org/sax/features/string-interning"
# true: All element names, prefixes, attribute names, Namespace URIs, and
# local names are interned using the built-in intern function.
# false: Names are not necessarily interned, although they may be (default).
# access: (parsing) read-only; (not parsing) read/write
feature_validation = "http://xml.org/sax/features/validation"
# true: Report all validation errors (implies external-general-entities and
# external-parameter-entities).
# false: Do not report validation errors.
# access: (parsing) read-only; (not parsing) read/write
feature_external_ges = "http://xml.org/sax/features/external-general-entities"
# true: Include all external general (text) entities.
# false: Do not include external general entities.
# access: (parsing) read-only; (not parsing) read/write
feature_external_pes = "http://xml.org/sax/features/external-parameter-entities"
# true: Include all external parameter entities, including the external
# DTD subset.
# false: Do not include any external parameter entities, even the external
# DTD subset.
# access: (parsing) read-only; (not parsing) read/write
all_features = [feature_namespaces,
feature_namespace_prefixes,
feature_string_interning,
feature_validation,
feature_external_ges,
feature_external_pes]
#============================================================================
#
# CORE PROPERTIES
#
#============================================================================
property_lexical_handler = "http://xml.org/sax/properties/lexical-handler"
# data type: xml.sax.sax2lib.LexicalHandler
# description: An optional extension handler for lexical events like comments.
# access: read/write
property_declaration_handler = "http://xml.org/sax/properties/declaration-handler"
# data type: xml.sax.sax2lib.DeclHandler
# description: An optional extension handler for DTD-related events other
# than notations and unparsed entities.
# access: read/write
property_dom_node = "http://xml.org/sax/properties/dom-node"
# data type: org.w3c.dom.Node
# description: When parsing, the current DOM node being visited if this is
# a DOM iterator; when not parsing, the root DOM node for
# iteration.
# access: (parsing) read-only; (not parsing) read/write
property_xml_string = "http://xml.org/sax/properties/xml-string"
# data type: String
# description: The literal string of characters that was the source for
# the current event.
# access: read-only
property_encoding = "http://www.python.org/sax/properties/encoding"
# data type: String
# description: The name of the encoding to assume for input data.
# access: write: set the encoding, e.g. established by a higher-level
# protocol. May change during parsing (e.g. after
# processing a META tag)
# read: return the current encoding (possibly established through
# auto-detection.
# initial value: UTF-8
#
property_interning_dict = "http://www.python.org/sax/properties/interning-dict"
# data type: Dictionary
# description: The dictionary used to intern common strings in the document
# access: write: Request that the parser uses a specific dictionary, to
# allow interning across different documents
# read: return the current interning dictionary, or None
#
all_properties = [property_lexical_handler,
property_dom_node,
property_declaration_handler,
property_xml_string,
property_encoding,
property_interning_dict]
|
gpl-3.0
|
[
624,
199,
2765,
859,
3509,
314,
6170,
3992,
402,
1015,
499,
14,
16,
402,
19310,
367,
2018,
14,
199,
2765,
570,
6571,
1454,
849,
3992,
543,
3679,
590,
7481,
199,
1593,
6712,
12,
687,
1314,
19016,
436,
13103,
883,
506,
1007,
28271,
14,
199,
199,
4089,
402,
3520,
3992,
787,
2701,
436,
787,
5120,
1454,
465,
3794,
199,
1618,
314,
8386,
14,
199,
199,
4,
1304,
4,
199,
624,
199,
199,
1023,
275,
283,
18,
14,
16,
5683,
7,
199,
199,
14813,
5769,
199,
3,
199,
3,
23276,
19650,
8729,
38,
21287,
199,
3,
199,
14813,
5769,
199,
199,
3,
9310,
12539,
30872,
9310,
199,
199,
533,
4520,
2461,
26,
272,
408,
6845,
3217,
367,
19310,
1125,
8297,
14,
339,
982,
1265,
1218,
376,
909,
626,
9031,
642,
3217,
12,
2066,
272,
2274,
314,
909,
543,
2195,
4692,
5929,
12,
314,
1798,
911,
1240,
314,
272,
3102,
315,
2195,
909,
370,
3622,
1006,
3598,
436,
2552,
14,
6006,
272,
787,
7795,
11106,
402,
2552,
2808,
26,
3598,
12,
334,
19614,
9,
272,
22803,
461,
2552,
12,
436,
625,
23131,
461,
2552,
14,
2900,
3102,
5452,
282,
272,
19310,
4003,
1726,
465,
314,
1454,
2725,
1041,
339,
347,
1125,
8,
277,
12,
1919,
304,
267,
298,
5940,
282,
22803,
461,
1125,
2122,
267,
746,
1919,
339,
347,
14294,
547,
8,
277,
12,
1919,
304,
267,
298,
5940,
282,
2222,
13,
23131,
461,
1125,
2122,
267,
746,
1919,
339,
347,
5721,
8,
277,
12,
1919,
304,
267,
298,
5940,
282,
5721,
2122,
267,
870,
8,
1971,
9,
421,
199,
3,
9310,
29417,
30872,
9310,
199,
199,
533,
6646,
2461,
26,
272,
408,
4267,
367,
18390,
11461,
2213,
1564,
4474,
14,
339,
961,
365,
314,
2446,
3233,
3217,
315,
19310,
12,
436,
314,
1373,
4750,
272,
11012,
370,
13103,
14,
710,
1865,
402,
4474,
315,
642,
3217,
272,
15216,
83,
314,
1865,
402,
314,
2556,
315,
314,
2213,
1041,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
6354,
275,
488,
339,
347,
663,
5564,
10725,
8,
277,
12,
14067,
304,
267,
408,
10474,
701,
314,
1798,
370,
8120,
314,
4223,
282,
14067,
367,
267,
4355,
1958,
314,
6330,
402,
2213,
4474,
14,
398,
19310,
21295,
787,
30390,
655,
25715,
6028,
334,
15401,
440,
3679,
590,
267,
1415,
9,
370,
17169,
282,
14067,
26,
340,
652,
1630,
880,
12,
652,
1471,
17169,
267,
314,
14067,
370,
314,
4223,
701,
26750,
642,
1083,
2544,
267,
26750,
1263,
402,
314,
1163,
3102,
315,
314,
7543,
2461,
267,
3217,
14,
398,
710,
14067,
6127,
314,
4223,
370,
6705,
314,
1284,
267,
3421,
402,
1263,
2213,
13,
2407,
1566,
12,
2755,
340,
314,
1798,
365,
267,
440,
17290,
376,
1125,
14,
26914,
12,
314,
4223,
911,
675,
267,
642,
2556,
367,
17290,
2399,
5705,
2552,
334,
10180,
465,
267,
4528,
1564,
626,
1630,
440,
1336,
376,
4223,
1159,
267,
26440,
4713,
680,
710,
2556,
2138,
701,
314,
14067,
365,
267,
8646,
440,
19258,
367,
675,
543,
282,
2754,
6869,
14,
398,
3390,
626,
314,
14067,
911,
372,
3211,
2556,
1454,
267,
5309,
314,
19569,
402,
314,
4474,
315,
642,
3217,
14,
710,
267,
4223,
1077,
440,
7427,
370,
675,
652,
737,
1263,
1163,
900,
1041,
267,
291,
423,
6354,
275,
14067,
339,
347,
1343,
5564,
8,
277,
304,
267,
408,
14235,
6955,
402,
314,
9608,
402,
282,
2213,
14,
398,
710,
19310,
1798,
911,
12677,
642,
1083,
1454,
5403,
12,
2544,
1263,
267,
1163,
3102,
315,
642,
3217,
503,
315,
577,
13449,
2461,
334,
2590,
367,
267,
663,
5564,
10725,
10477,
339,
347,
1284,
5564,
8,
277,
304,
267,
408,
14235,
6955,
402,
314,
1284,
402,
282,
2213,
14,
398,
710,
19310,
1798,
911,
12677,
642,
1083,
1454,
5403,
12,
436,
652,
911,
267,
506,
314,
2061,
1083,
10302,
5309,
314,
2198,
14,
710,
1798,
10989,
267,
440,
12677,
642,
1083,
5133,
652,
965,
1902,
2236,
460,
28918,
6057,
267,
334,
20684,
402,
376,
625,
23131,
461,
1125,
9,
503,
13075,
314,
1284,
402,
267,
1324,
1041,
339,
347,
1343,
4793,
7674,
8,
277,
12,
2403,
12,
5108,
304,
267,
408,
5595,
314,
4194,
402,
282,
2403,
13,
7639,
19317,
4412,
14,
398,
710,
2556,
687,
642,
1566,
365,
440,
5784,
367,
3293,
267,
19317,
6661,
26,
314,
19310,
4692,
7002,
911,
5847,
267,
3350,
13158,
367,
1819,
436,
2225,
1561,
1380,
314,
267,
1455,
921,
1652,
14,
1308,
15,
14338,
15,
3179,
15,
9247,
3878,
365,
2549,
334,
1589,
267,
849,
680,
398,
6006,
787,
5560,
12,
13432,
12,
1380,
13103,
1929,
370,
675,
267,
13158,
315,
4528,
666,
503,
315,
2225,
1338,
12,
2382,
2985,
267,
3913,
19353,
506,
11507,
5847,
27,
314,
267,
1343,
15,
500,
4793,
7674,
1566,
4973,
6528,
314,
2556,
370,
314,
267,
4223,
370,
6544,
13158,
315,
5204,
18191,
6337,
12,
340,
267,
5784,
14,
398,
3390,
626,
1343,
15,
500,
4793,
7674,
4474,
787,
440,
17334,
370,
267,
506,
7684,
6032,
3847,
370,
1924,
13,
1848,
26,
1006,
267,
1343,
4793,
7674,
4474,
911,
4781,
2544,
314,
5226,
267,
26325,
1566,
12,
436,
1006,
1284,
4793,
7674,
4474,
911,
4781,
267,
2410,
314,
5226,
28920,
1566,
12,
1325,
3932,
1865,
365,
267,
440,
17334,
1041,
339,
347,
1284,
4793,
7674,
8,
277,
12,
2403,
304,
267,
408,
3005,
314,
4194,
402,
282,
2403,
13,
7639,
4412,
14,
398,
1666,
1343,
4793,
7674,
367,
2436,
14,
961,
1566,
911,
3544,
267,
4781,
2410,
314,
5226,
28920,
1566,
12,
1325,
314,
1865,
267,
402,
1284,
4793,
7674,
4474,
365,
440,
4257,
17334,
1041,
339,
347,
26325,
8,
277,
12,
536,
12,
3290,
304,
267,
408,
28536,
314,
1343,
402,
376,
1819,
315,
2222,
13,
3251,
818,
14,
398,
710,
536,
2725,
3509,
314,
3066,
4692,
413,
14,
16,
536,
402,
314,
267,
1819,
730,
465,
282,
1059,
436,
314,
3290,
2725,
15164,
376,
267,
1256,
402,
314,
9382,
1021,
3035,
314,
3004,
402,
267,
314,
1819,
1041,
339,
347,
28920,
8,
277,
12,
536,
304,
267,
408,
28536,
314,
1284,
402,
376,
1819,
315,
2222,
13,
3251,
818,
14,
398,
710,
536,
2725,
3509,
314,
536,
402,
314,
1819,
730,
12,
2951,
267,
465,
543,
314,
26325,
1566,
1041,
339,
347,
26325,
2709,
8
] |
[
199,
2765,
859,
3509,
314,
6170,
3992,
402,
1015,
499,
14,
16,
402,
19310,
367,
2018,
14,
199,
2765,
570,
6571,
1454,
849,
3992,
543,
3679,
590,
7481,
199,
1593,
6712,
12,
687,
1314,
19016,
436,
13103,
883,
506,
1007,
28271,
14,
199,
199,
4089,
402,
3520,
3992,
787,
2701,
436,
787,
5120,
1454,
465,
3794,
199,
1618,
314,
8386,
14,
199,
199,
4,
1304,
4,
199,
624,
199,
199,
1023,
275,
283,
18,
14,
16,
5683,
7,
199,
199,
14813,
5769,
199,
3,
199,
3,
23276,
19650,
8729,
38,
21287,
199,
3,
199,
14813,
5769,
199,
199,
3,
9310,
12539,
30872,
9310,
199,
199,
533,
4520,
2461,
26,
272,
408,
6845,
3217,
367,
19310,
1125,
8297,
14,
339,
982,
1265,
1218,
376,
909,
626,
9031,
642,
3217,
12,
2066,
272,
2274,
314,
909,
543,
2195,
4692,
5929,
12,
314,
1798,
911,
1240,
314,
272,
3102,
315,
2195,
909,
370,
3622,
1006,
3598,
436,
2552,
14,
6006,
272,
787,
7795,
11106,
402,
2552,
2808,
26,
3598,
12,
334,
19614,
9,
272,
22803,
461,
2552,
12,
436,
625,
23131,
461,
2552,
14,
2900,
3102,
5452,
282,
272,
19310,
4003,
1726,
465,
314,
1454,
2725,
1041,
339,
347,
1125,
8,
277,
12,
1919,
304,
267,
298,
5940,
282,
22803,
461,
1125,
2122,
267,
746,
1919,
339,
347,
14294,
547,
8,
277,
12,
1919,
304,
267,
298,
5940,
282,
2222,
13,
23131,
461,
1125,
2122,
267,
746,
1919,
339,
347,
5721,
8,
277,
12,
1919,
304,
267,
298,
5940,
282,
5721,
2122,
267,
870,
8,
1971,
9,
421,
199,
3,
9310,
29417,
30872,
9310,
199,
199,
533,
6646,
2461,
26,
272,
408,
4267,
367,
18390,
11461,
2213,
1564,
4474,
14,
339,
961,
365,
314,
2446,
3233,
3217,
315,
19310,
12,
436,
314,
1373,
4750,
272,
11012,
370,
13103,
14,
710,
1865,
402,
4474,
315,
642,
3217,
272,
15216,
83,
314,
1865,
402,
314,
2556,
315,
314,
2213,
1041,
339,
347,
636,
826,
721,
277,
304,
267,
291,
423,
6354,
275,
488,
339,
347,
663,
5564,
10725,
8,
277,
12,
14067,
304,
267,
408,
10474,
701,
314,
1798,
370,
8120,
314,
4223,
282,
14067,
367,
267,
4355,
1958,
314,
6330,
402,
2213,
4474,
14,
398,
19310,
21295,
787,
30390,
655,
25715,
6028,
334,
15401,
440,
3679,
590,
267,
1415,
9,
370,
17169,
282,
14067,
26,
340,
652,
1630,
880,
12,
652,
1471,
17169,
267,
314,
14067,
370,
314,
4223,
701,
26750,
642,
1083,
2544,
267,
26750,
1263,
402,
314,
1163,
3102,
315,
314,
7543,
2461,
267,
3217,
14,
398,
710,
14067,
6127,
314,
4223,
370,
6705,
314,
1284,
267,
3421,
402,
1263,
2213,
13,
2407,
1566,
12,
2755,
340,
314,
1798,
365,
267,
440,
17290,
376,
1125,
14,
26914,
12,
314,
4223,
911,
675,
267,
642,
2556,
367,
17290,
2399,
5705,
2552,
334,
10180,
465,
267,
4528,
1564,
626,
1630,
440,
1336,
376,
4223,
1159,
267,
26440,
4713,
680,
710,
2556,
2138,
701,
314,
14067,
365,
267,
8646,
440,
19258,
367,
675,
543,
282,
2754,
6869,
14,
398,
3390,
626,
314,
14067,
911,
372,
3211,
2556,
1454,
267,
5309,
314,
19569,
402,
314,
4474,
315,
642,
3217,
14,
710,
267,
4223,
1077,
440,
7427,
370,
675,
652,
737,
1263,
1163,
900,
1041,
267,
291,
423,
6354,
275,
14067,
339,
347,
1343,
5564,
8,
277,
304,
267,
408,
14235,
6955,
402,
314,
9608,
402,
282,
2213,
14,
398,
710,
19310,
1798,
911,
12677,
642,
1083,
1454,
5403,
12,
2544,
1263,
267,
1163,
3102,
315,
642,
3217,
503,
315,
577,
13449,
2461,
334,
2590,
367,
267,
663,
5564,
10725,
10477,
339,
347,
1284,
5564,
8,
277,
304,
267,
408,
14235,
6955,
402,
314,
1284,
402,
282,
2213,
14,
398,
710,
19310,
1798,
911,
12677,
642,
1083,
1454,
5403,
12,
436,
652,
911,
267,
506,
314,
2061,
1083,
10302,
5309,
314,
2198,
14,
710,
1798,
10989,
267,
440,
12677,
642,
1083,
5133,
652,
965,
1902,
2236,
460,
28918,
6057,
267,
334,
20684,
402,
376,
625,
23131,
461,
1125,
9,
503,
13075,
314,
1284,
402,
267,
1324,
1041,
339,
347,
1343,
4793,
7674,
8,
277,
12,
2403,
12,
5108,
304,
267,
408,
5595,
314,
4194,
402,
282,
2403,
13,
7639,
19317,
4412,
14,
398,
710,
2556,
687,
642,
1566,
365,
440,
5784,
367,
3293,
267,
19317,
6661,
26,
314,
19310,
4692,
7002,
911,
5847,
267,
3350,
13158,
367,
1819,
436,
2225,
1561,
1380,
314,
267,
1455,
921,
1652,
14,
1308,
15,
14338,
15,
3179,
15,
9247,
3878,
365,
2549,
334,
1589,
267,
849,
680,
398,
6006,
787,
5560,
12,
13432,
12,
1380,
13103,
1929,
370,
675,
267,
13158,
315,
4528,
666,
503,
315,
2225,
1338,
12,
2382,
2985,
267,
3913,
19353,
506,
11507,
5847,
27,
314,
267,
1343,
15,
500,
4793,
7674,
1566,
4973,
6528,
314,
2556,
370,
314,
267,
4223,
370,
6544,
13158,
315,
5204,
18191,
6337,
12,
340,
267,
5784,
14,
398,
3390,
626,
1343,
15,
500,
4793,
7674,
4474,
787,
440,
17334,
370,
267,
506,
7684,
6032,
3847,
370,
1924,
13,
1848,
26,
1006,
267,
1343,
4793,
7674,
4474,
911,
4781,
2544,
314,
5226,
267,
26325,
1566,
12,
436,
1006,
1284,
4793,
7674,
4474,
911,
4781,
267,
2410,
314,
5226,
28920,
1566,
12,
1325,
3932,
1865,
365,
267,
440,
17334,
1041,
339,
347,
1284,
4793,
7674,
8,
277,
12,
2403,
304,
267,
408,
3005,
314,
4194,
402,
282,
2403,
13,
7639,
4412,
14,
398,
1666,
1343,
4793,
7674,
367,
2436,
14,
961,
1566,
911,
3544,
267,
4781,
2410,
314,
5226,
28920,
1566,
12,
1325,
314,
1865,
267,
402,
1284,
4793,
7674,
4474,
365,
440,
4257,
17334,
1041,
339,
347,
26325,
8,
277,
12,
536,
12,
3290,
304,
267,
408,
28536,
314,
1343,
402,
376,
1819,
315,
2222,
13,
3251,
818,
14,
398,
710,
536,
2725,
3509,
314,
3066,
4692,
413,
14,
16,
536,
402,
314,
267,
1819,
730,
465,
282,
1059,
436,
314,
3290,
2725,
15164,
376,
267,
1256,
402,
314,
9382,
1021,
3035,
314,
3004,
402,
267,
314,
1819,
1041,
339,
347,
28920,
8,
277,
12,
536,
304,
267,
408,
28536,
314,
1284,
402,
376,
1819,
315,
2222,
13,
3251,
818,
14,
398,
710,
536,
2725,
3509,
314,
536,
402,
314,
1819,
730,
12,
2951,
267,
465,
543,
314,
26325,
1566,
1041,
339,
347,
26325,
2709,
8,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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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
] |
lmregus/Portfolio
|
python/design_patterns/env/lib/python3.7/site-packages/pygments/lexers/_scilab_builtins.py
|
31
|
52405
|
# -*- coding: utf-8 -*-
"""
pygments.lexers._scilab_builtins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Builtin list for the ScilabLexer.
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
# Autogenerated
commands_kw = (
'abort',
'apropos',
'break',
'case',
'catch',
'continue',
'do',
'else',
'elseif',
'end',
'endfunction',
'for',
'function',
'help',
'if',
'pause',
'quit',
'select',
'then',
'try',
'while',
)
functions_kw = (
'!!_invoke_',
'%H5Object_e',
'%H5Object_fieldnames',
'%H5Object_p',
'%XMLAttr_6',
'%XMLAttr_e',
'%XMLAttr_i_XMLElem',
'%XMLAttr_length',
'%XMLAttr_p',
'%XMLAttr_size',
'%XMLDoc_6',
'%XMLDoc_e',
'%XMLDoc_i_XMLList',
'%XMLDoc_p',
'%XMLElem_6',
'%XMLElem_e',
'%XMLElem_i_XMLDoc',
'%XMLElem_i_XMLElem',
'%XMLElem_i_XMLList',
'%XMLElem_p',
'%XMLList_6',
'%XMLList_e',
'%XMLList_i_XMLElem',
'%XMLList_i_XMLList',
'%XMLList_length',
'%XMLList_p',
'%XMLList_size',
'%XMLNs_6',
'%XMLNs_e',
'%XMLNs_i_XMLElem',
'%XMLNs_p',
'%XMLSet_6',
'%XMLSet_e',
'%XMLSet_length',
'%XMLSet_p',
'%XMLSet_size',
'%XMLValid_p',
'%_EClass_6',
'%_EClass_e',
'%_EClass_p',
'%_EObj_0',
'%_EObj_1__EObj',
'%_EObj_1_b',
'%_EObj_1_c',
'%_EObj_1_i',
'%_EObj_1_s',
'%_EObj_2__EObj',
'%_EObj_2_b',
'%_EObj_2_c',
'%_EObj_2_i',
'%_EObj_2_s',
'%_EObj_3__EObj',
'%_EObj_3_b',
'%_EObj_3_c',
'%_EObj_3_i',
'%_EObj_3_s',
'%_EObj_4__EObj',
'%_EObj_4_b',
'%_EObj_4_c',
'%_EObj_4_i',
'%_EObj_4_s',
'%_EObj_5',
'%_EObj_6',
'%_EObj_a__EObj',
'%_EObj_a_b',
'%_EObj_a_c',
'%_EObj_a_i',
'%_EObj_a_s',
'%_EObj_d__EObj',
'%_EObj_d_b',
'%_EObj_d_c',
'%_EObj_d_i',
'%_EObj_d_s',
'%_EObj_disp',
'%_EObj_e',
'%_EObj_g__EObj',
'%_EObj_g_b',
'%_EObj_g_c',
'%_EObj_g_i',
'%_EObj_g_s',
'%_EObj_h__EObj',
'%_EObj_h_b',
'%_EObj_h_c',
'%_EObj_h_i',
'%_EObj_h_s',
'%_EObj_i__EObj',
'%_EObj_j__EObj',
'%_EObj_j_b',
'%_EObj_j_c',
'%_EObj_j_i',
'%_EObj_j_s',
'%_EObj_k__EObj',
'%_EObj_k_b',
'%_EObj_k_c',
'%_EObj_k_i',
'%_EObj_k_s',
'%_EObj_l__EObj',
'%_EObj_l_b',
'%_EObj_l_c',
'%_EObj_l_i',
'%_EObj_l_s',
'%_EObj_m__EObj',
'%_EObj_m_b',
'%_EObj_m_c',
'%_EObj_m_i',
'%_EObj_m_s',
'%_EObj_n__EObj',
'%_EObj_n_b',
'%_EObj_n_c',
'%_EObj_n_i',
'%_EObj_n_s',
'%_EObj_o__EObj',
'%_EObj_o_b',
'%_EObj_o_c',
'%_EObj_o_i',
'%_EObj_o_s',
'%_EObj_p',
'%_EObj_p__EObj',
'%_EObj_p_b',
'%_EObj_p_c',
'%_EObj_p_i',
'%_EObj_p_s',
'%_EObj_q__EObj',
'%_EObj_q_b',
'%_EObj_q_c',
'%_EObj_q_i',
'%_EObj_q_s',
'%_EObj_r__EObj',
'%_EObj_r_b',
'%_EObj_r_c',
'%_EObj_r_i',
'%_EObj_r_s',
'%_EObj_s__EObj',
'%_EObj_s_b',
'%_EObj_s_c',
'%_EObj_s_i',
'%_EObj_s_s',
'%_EObj_t',
'%_EObj_x__EObj',
'%_EObj_x_b',
'%_EObj_x_c',
'%_EObj_x_i',
'%_EObj_x_s',
'%_EObj_y__EObj',
'%_EObj_y_b',
'%_EObj_y_c',
'%_EObj_y_i',
'%_EObj_y_s',
'%_EObj_z__EObj',
'%_EObj_z_b',
'%_EObj_z_c',
'%_EObj_z_i',
'%_EObj_z_s',
'%_eigs',
'%_load',
'%b_1__EObj',
'%b_2__EObj',
'%b_3__EObj',
'%b_4__EObj',
'%b_a__EObj',
'%b_d__EObj',
'%b_g__EObj',
'%b_h__EObj',
'%b_i_XMLList',
'%b_i__EObj',
'%b_j__EObj',
'%b_k__EObj',
'%b_l__EObj',
'%b_m__EObj',
'%b_n__EObj',
'%b_o__EObj',
'%b_p__EObj',
'%b_q__EObj',
'%b_r__EObj',
'%b_s__EObj',
'%b_x__EObj',
'%b_y__EObj',
'%b_z__EObj',
'%c_1__EObj',
'%c_2__EObj',
'%c_3__EObj',
'%c_4__EObj',
'%c_a__EObj',
'%c_d__EObj',
'%c_g__EObj',
'%c_h__EObj',
'%c_i_XMLAttr',
'%c_i_XMLDoc',
'%c_i_XMLElem',
'%c_i_XMLList',
'%c_i__EObj',
'%c_j__EObj',
'%c_k__EObj',
'%c_l__EObj',
'%c_m__EObj',
'%c_n__EObj',
'%c_o__EObj',
'%c_p__EObj',
'%c_q__EObj',
'%c_r__EObj',
'%c_s__EObj',
'%c_x__EObj',
'%c_y__EObj',
'%c_z__EObj',
'%ce_i_XMLList',
'%fptr_i_XMLList',
'%h_i_XMLList',
'%hm_i_XMLList',
'%i_1__EObj',
'%i_2__EObj',
'%i_3__EObj',
'%i_4__EObj',
'%i_a__EObj',
'%i_abs',
'%i_cumprod',
'%i_cumsum',
'%i_d__EObj',
'%i_diag',
'%i_g__EObj',
'%i_h__EObj',
'%i_i_XMLList',
'%i_i__EObj',
'%i_j__EObj',
'%i_k__EObj',
'%i_l__EObj',
'%i_m__EObj',
'%i_matrix',
'%i_max',
'%i_maxi',
'%i_min',
'%i_mini',
'%i_mput',
'%i_n__EObj',
'%i_o__EObj',
'%i_p',
'%i_p__EObj',
'%i_prod',
'%i_q__EObj',
'%i_r__EObj',
'%i_s__EObj',
'%i_sum',
'%i_tril',
'%i_triu',
'%i_x__EObj',
'%i_y__EObj',
'%i_z__EObj',
'%ip_i_XMLList',
'%l_i_XMLList',
'%l_i__EObj',
'%lss_i_XMLList',
'%mc_i_XMLList',
'%msp_full',
'%msp_i_XMLList',
'%msp_spget',
'%p_i_XMLList',
'%ptr_i_XMLList',
'%r_i_XMLList',
'%s_1__EObj',
'%s_2__EObj',
'%s_3__EObj',
'%s_4__EObj',
'%s_a__EObj',
'%s_d__EObj',
'%s_g__EObj',
'%s_h__EObj',
'%s_i_XMLList',
'%s_i__EObj',
'%s_j__EObj',
'%s_k__EObj',
'%s_l__EObj',
'%s_m__EObj',
'%s_n__EObj',
'%s_o__EObj',
'%s_p__EObj',
'%s_q__EObj',
'%s_r__EObj',
'%s_s__EObj',
'%s_x__EObj',
'%s_y__EObj',
'%s_z__EObj',
'%sp_i_XMLList',
'%spb_i_XMLList',
'%st_i_XMLList',
'Calendar',
'ClipBoard',
'Matplot',
'Matplot1',
'PlaySound',
'TCL_DeleteInterp',
'TCL_DoOneEvent',
'TCL_EvalFile',
'TCL_EvalStr',
'TCL_ExistArray',
'TCL_ExistInterp',
'TCL_ExistVar',
'TCL_GetVar',
'TCL_GetVersion',
'TCL_SetVar',
'TCL_UnsetVar',
'TCL_UpVar',
'_',
'_code2str',
'_d',
'_str2code',
'about',
'abs',
'acos',
'addModulePreferences',
'addcolor',
'addf',
'addhistory',
'addinter',
'addlocalizationdomain',
'amell',
'and',
'argn',
'arl2_ius',
'ascii',
'asin',
'atan',
'backslash',
'balanc',
'banner',
'base2dec',
'basename',
'bdiag',
'beep',
'besselh',
'besseli',
'besselj',
'besselk',
'bessely',
'beta',
'bezout',
'bfinit',
'blkfc1i',
'blkslvi',
'bool2s',
'browsehistory',
'browsevar',
'bsplin3val',
'buildDoc',
'buildouttb',
'bvode',
'c_link',
'call',
'callblk',
'captions',
'cd',
'cdfbet',
'cdfbin',
'cdfchi',
'cdfchn',
'cdff',
'cdffnc',
'cdfgam',
'cdfnbn',
'cdfnor',
'cdfpoi',
'cdft',
'ceil',
'champ',
'champ1',
'chdir',
'chol',
'clc',
'clean',
'clear',
'clearfun',
'clearglobal',
'closeEditor',
'closeEditvar',
'closeXcos',
'code2str',
'coeff',
'color',
'comp',
'completion',
'conj',
'contour2di',
'contr',
'conv2',
'convstr',
'copy',
'copyfile',
'corr',
'cos',
'coserror',
'createdir',
'cshep2d',
'csvDefault',
'csvIsnum',
'csvRead',
'csvStringToDouble',
'csvTextScan',
'csvWrite',
'ctree2',
'ctree3',
'ctree4',
'cumprod',
'cumsum',
'curblock',
'curblockc',
'daskr',
'dasrt',
'dassl',
'data2sig',
'datatipCreate',
'datatipManagerMode',
'datatipMove',
'datatipRemove',
'datatipSetDisplay',
'datatipSetInterp',
'datatipSetOrientation',
'datatipSetStyle',
'datatipToggle',
'dawson',
'dct',
'debug',
'dec2base',
'deff',
'definedfields',
'degree',
'delbpt',
'delete',
'deletefile',
'delip',
'delmenu',
'det',
'dgettext',
'dhinf',
'diag',
'diary',
'diffobjs',
'disp',
'dispbpt',
'displayhistory',
'disposefftwlibrary',
'dlgamma',
'dnaupd',
'dneupd',
'double',
'drawaxis',
'drawlater',
'drawnow',
'driver',
'dsaupd',
'dsearch',
'dseupd',
'dst',
'duplicate',
'editvar',
'emptystr',
'end_scicosim',
'ereduc',
'erf',
'erfc',
'erfcx',
'erfi',
'errcatch',
'errclear',
'error',
'eval_cshep2d',
'exec',
'execstr',
'exists',
'exit',
'exp',
'expm',
'exportUI',
'export_to_hdf5',
'eye',
'fadj2sp',
'fec',
'feval',
'fft',
'fftw',
'fftw_flags',
'fftw_forget_wisdom',
'fftwlibraryisloaded',
'figure',
'file',
'filebrowser',
'fileext',
'fileinfo',
'fileparts',
'filesep',
'find',
'findBD',
'findfiles',
'fire_closing_finished',
'floor',
'format',
'fort',
'fprintfMat',
'freq',
'frexp',
'fromc',
'fromjava',
'fscanfMat',
'fsolve',
'fstair',
'full',
'fullpath',
'funcprot',
'funptr',
'gamma',
'gammaln',
'geom3d',
'get',
'getURL',
'get_absolute_file_path',
'get_fftw_wisdom',
'getblocklabel',
'getcallbackobject',
'getdate',
'getdebuginfo',
'getdefaultlanguage',
'getdrives',
'getdynlibext',
'getenv',
'getfield',
'gethistory',
'gethistoryfile',
'getinstalledlookandfeels',
'getio',
'getlanguage',
'getlongpathname',
'getlookandfeel',
'getmd5',
'getmemory',
'getmodules',
'getos',
'getpid',
'getrelativefilename',
'getscicosvars',
'getscilabmode',
'getshortpathname',
'gettext',
'getvariablesonstack',
'getversion',
'glist',
'global',
'glue',
'grand',
'graphicfunction',
'grayplot',
'grep',
'gsort',
'gstacksize',
'h5attr',
'h5close',
'h5cp',
'h5dataset',
'h5dump',
'h5exists',
'h5flush',
'h5get',
'h5group',
'h5isArray',
'h5isAttr',
'h5isCompound',
'h5isFile',
'h5isGroup',
'h5isList',
'h5isRef',
'h5isSet',
'h5isSpace',
'h5isType',
'h5isVlen',
'h5label',
'h5ln',
'h5ls',
'h5mount',
'h5mv',
'h5open',
'h5read',
'h5readattr',
'h5rm',
'h5umount',
'h5write',
'h5writeattr',
'havewindow',
'helpbrowser',
'hess',
'hinf',
'historymanager',
'historysize',
'host',
'htmlDump',
'htmlRead',
'htmlReadStr',
'htmlWrite',
'iconvert',
'ieee',
'ilib_verbose',
'imag',
'impl',
'import_from_hdf5',
'imult',
'inpnvi',
'int',
'int16',
'int2d',
'int32',
'int3d',
'int8',
'interp',
'interp2d',
'interp3d',
'intg',
'intppty',
'inttype',
'inv',
'invoke_lu',
'is_handle_valid',
'is_hdf5_file',
'isalphanum',
'isascii',
'isdef',
'isdigit',
'isdir',
'isequal',
'isequalbitwise',
'iserror',
'isfile',
'isglobal',
'isletter',
'isnum',
'isreal',
'iswaitingforinput',
'jallowClassReloading',
'jarray',
'jautoTranspose',
'jautoUnwrap',
'javaclasspath',
'javalibrarypath',
'jcast',
'jcompile',
'jconvMatrixMethod',
'jcreatejar',
'jdeff',
'jdisableTrace',
'jenableTrace',
'jexists',
'jgetclassname',
'jgetfield',
'jgetfields',
'jgetinfo',
'jgetmethods',
'jimport',
'jinvoke',
'jinvoke_db',
'jnewInstance',
'jremove',
'jsetfield',
'junwrap',
'junwraprem',
'jwrap',
'jwrapinfloat',
'kron',
'lasterror',
'ldiv',
'ldivf',
'legendre',
'length',
'lib',
'librarieslist',
'libraryinfo',
'light',
'linear_interpn',
'lines',
'link',
'linmeq',
'list',
'listvar_in_hdf5',
'load',
'loadGui',
'loadScicos',
'loadXcos',
'loadfftwlibrary',
'loadhistory',
'log',
'log1p',
'lsq',
'lsq_splin',
'lsqrsolve',
'lsslist',
'lstcat',
'lstsize',
'ltitr',
'lu',
'ludel',
'lufact',
'luget',
'lusolve',
'macr2lst',
'macr2tree',
'matfile_close',
'matfile_listvar',
'matfile_open',
'matfile_varreadnext',
'matfile_varwrite',
'matrix',
'max',
'maxfiles',
'mclearerr',
'mclose',
'meof',
'merror',
'messagebox',
'mfprintf',
'mfscanf',
'mget',
'mgeti',
'mgetl',
'mgetstr',
'min',
'mlist',
'mode',
'model2blk',
'mopen',
'move',
'movefile',
'mprintf',
'mput',
'mputl',
'mputstr',
'mscanf',
'mseek',
'msprintf',
'msscanf',
'mtell',
'mtlb_mode',
'mtlb_sparse',
'mucomp',
'mulf',
'name2rgb',
'nearfloat',
'newaxes',
'newest',
'newfun',
'nnz',
'norm',
'notify',
'number_properties',
'ode',
'odedc',
'ones',
'openged',
'opentk',
'optim',
'or',
'ordmmd',
'parallel_concurrency',
'parallel_run',
'param3d',
'param3d1',
'part',
'pathconvert',
'pathsep',
'phase_simulation',
'plot2d',
'plot2d1',
'plot2d2',
'plot2d3',
'plot2d4',
'plot3d',
'plot3d1',
'plotbrowser',
'pointer_xproperty',
'poly',
'ppol',
'pppdiv',
'predef',
'preferences',
'print',
'printf',
'printfigure',
'printsetupbox',
'prod',
'progressionbar',
'prompt',
'pwd',
'qld',
'qp_solve',
'qr',
'raise_window',
'rand',
'rankqr',
'rat',
'rcond',
'rdivf',
'read',
'read4b',
'read_csv',
'readb',
'readgateway',
'readmps',
'real',
'realtime',
'realtimeinit',
'regexp',
'relocate_handle',
'remez',
'removeModulePreferences',
'removedir',
'removelinehistory',
'res_with_prec',
'resethistory',
'residu',
'resume',
'return',
'ricc',
'rlist',
'roots',
'rotate_axes',
'round',
'rpem',
'rtitr',
'rubberbox',
'save',
'saveGui',
'saveafterncommands',
'saveconsecutivecommands',
'savehistory',
'schur',
'sci_haltscicos',
'sci_tree2',
'sci_tree3',
'sci_tree4',
'sciargs',
'scicos_debug',
'scicos_debug_count',
'scicos_time',
'scicosim',
'scinotes',
'sctree',
'semidef',
'set',
'set_blockerror',
'set_fftw_wisdom',
'set_xproperty',
'setbpt',
'setdefaultlanguage',
'setenv',
'setfield',
'sethistoryfile',
'setlanguage',
'setlookandfeel',
'setmenu',
'sfact',
'sfinit',
'show_window',
'sident',
'sig2data',
'sign',
'simp',
'simp_mode',
'sin',
'size',
'slash',
'sleep',
'sorder',
'sparse',
'spchol',
'spcompack',
'spec',
'spget',
'splin',
'splin2d',
'splin3d',
'splitURL',
'spones',
'sprintf',
'sqrt',
'stacksize',
'str2code',
'strcat',
'strchr',
'strcmp',
'strcspn',
'strindex',
'string',
'stringbox',
'stripblanks',
'strncpy',
'strrchr',
'strrev',
'strsplit',
'strspn',
'strstr',
'strsubst',
'strtod',
'strtok',
'subf',
'sum',
'svd',
'swap_handles',
'symfcti',
'syredi',
'system_getproperty',
'system_setproperty',
'ta2lpd',
'tan',
'taucs_chdel',
'taucs_chfact',
'taucs_chget',
'taucs_chinfo',
'taucs_chsolve',
'tempname',
'testmatrix',
'timer',
'tlist',
'tohome',
'tokens',
'toolbar',
'toprint',
'tr_zer',
'tril',
'triu',
'type',
'typename',
'uiDisplayTree',
'uicontextmenu',
'uicontrol',
'uigetcolor',
'uigetdir',
'uigetfile',
'uigetfont',
'uimenu',
'uint16',
'uint32',
'uint8',
'uipopup',
'uiputfile',
'uiwait',
'ulink',
'umf_ludel',
'umf_lufact',
'umf_luget',
'umf_luinfo',
'umf_lusolve',
'umfpack',
'unglue',
'unix',
'unsetmenu',
'unzoom',
'updatebrowsevar',
'usecanvas',
'useeditor',
'user',
'var2vec',
'varn',
'vec2var',
'waitbar',
'warnBlockByUID',
'warning',
'what',
'where',
'whereis',
'who',
'winsid',
'with_module',
'writb',
'write',
'write4b',
'write_csv',
'x_choose',
'x_choose_modeless',
'x_dialog',
'x_mdialog',
'xarc',
'xarcs',
'xarrows',
'xchange',
'xchoicesi',
'xclick',
'xcos',
'xcosAddToolsMenu',
'xcosConfigureXmlFile',
'xcosDiagramToScilab',
'xcosPalCategoryAdd',
'xcosPalDelete',
'xcosPalDisable',
'xcosPalEnable',
'xcosPalGenerateIcon',
'xcosPalGet',
'xcosPalLoad',
'xcosPalMove',
'xcosSimulationStarted',
'xcosUpdateBlock',
'xdel',
'xend',
'xfarc',
'xfarcs',
'xfpoly',
'xfpolys',
'xfrect',
'xget',
'xgetmouse',
'xgraduate',
'xgrid',
'xinit',
'xlfont',
'xls_open',
'xls_read',
'xmlAddNs',
'xmlAppend',
'xmlAsNumber',
'xmlAsText',
'xmlDTD',
'xmlDelete',
'xmlDocument',
'xmlDump',
'xmlElement',
'xmlFormat',
'xmlGetNsByHref',
'xmlGetNsByPrefix',
'xmlGetOpenDocs',
'xmlIsValidObject',
'xmlName',
'xmlNs',
'xmlRead',
'xmlReadStr',
'xmlRelaxNG',
'xmlRemove',
'xmlSchema',
'xmlSetAttributes',
'xmlValidate',
'xmlWrite',
'xmlXPath',
'xname',
'xpause',
'xpoly',
'xpolys',
'xrect',
'xrects',
'xs2bmp',
'xs2emf',
'xs2eps',
'xs2gif',
'xs2jpg',
'xs2pdf',
'xs2png',
'xs2ppm',
'xs2ps',
'xs2svg',
'xsegs',
'xset',
'xstring',
'xstringb',
'xtitle',
'zeros',
'znaupd',
'zneupd',
'zoom_rect',
)
macros_kw = (
'!_deff_wrapper',
'%0_i_st',
'%3d_i_h',
'%Block_xcosUpdateBlock',
'%TNELDER_p',
'%TNELDER_string',
'%TNMPLOT_p',
'%TNMPLOT_string',
'%TOPTIM_p',
'%TOPTIM_string',
'%TSIMPLEX_p',
'%TSIMPLEX_string',
'%_EVoid_p',
'%_gsort',
'%_listvarinfile',
'%_rlist',
'%_save',
'%_sodload',
'%_strsplit',
'%_unwrap',
'%ar_p',
'%asn',
'%b_a_b',
'%b_a_s',
'%b_c_s',
'%b_c_spb',
'%b_cumprod',
'%b_cumsum',
'%b_d_s',
'%b_diag',
'%b_e',
'%b_f_s',
'%b_f_spb',
'%b_g_s',
'%b_g_spb',
'%b_grand',
'%b_h_s',
'%b_h_spb',
'%b_i_b',
'%b_i_ce',
'%b_i_h',
'%b_i_hm',
'%b_i_s',
'%b_i_sp',
'%b_i_spb',
'%b_i_st',
'%b_iconvert',
'%b_l_b',
'%b_l_s',
'%b_m_b',
'%b_m_s',
'%b_matrix',
'%b_n_hm',
'%b_o_hm',
'%b_p_s',
'%b_prod',
'%b_r_b',
'%b_r_s',
'%b_s_b',
'%b_s_s',
'%b_string',
'%b_sum',
'%b_tril',
'%b_triu',
'%b_x_b',
'%b_x_s',
'%bicg',
'%bicgstab',
'%c_a_c',
'%c_b_c',
'%c_b_s',
'%c_diag',
'%c_dsearch',
'%c_e',
'%c_eye',
'%c_f_s',
'%c_grand',
'%c_i_c',
'%c_i_ce',
'%c_i_h',
'%c_i_hm',
'%c_i_lss',
'%c_i_r',
'%c_i_s',
'%c_i_st',
'%c_matrix',
'%c_n_l',
'%c_n_st',
'%c_o_l',
'%c_o_st',
'%c_ones',
'%c_rand',
'%c_tril',
'%c_triu',
'%cblock_c_cblock',
'%cblock_c_s',
'%cblock_e',
'%cblock_f_cblock',
'%cblock_p',
'%cblock_size',
'%ce_6',
'%ce_c_ce',
'%ce_e',
'%ce_f_ce',
'%ce_i_ce',
'%ce_i_s',
'%ce_i_st',
'%ce_matrix',
'%ce_p',
'%ce_size',
'%ce_string',
'%ce_t',
'%cgs',
'%champdat_i_h',
'%choose',
'%diagram_xcos',
'%dir_p',
'%fptr_i_st',
'%grand_perm',
'%grayplot_i_h',
'%h_i_st',
'%hmS_k_hmS_generic',
'%hm_1_hm',
'%hm_1_s',
'%hm_2_hm',
'%hm_2_s',
'%hm_3_hm',
'%hm_3_s',
'%hm_4_hm',
'%hm_4_s',
'%hm_5',
'%hm_a_hm',
'%hm_a_r',
'%hm_a_s',
'%hm_abs',
'%hm_and',
'%hm_bool2s',
'%hm_c_hm',
'%hm_ceil',
'%hm_conj',
'%hm_cos',
'%hm_cumprod',
'%hm_cumsum',
'%hm_d_hm',
'%hm_d_s',
'%hm_degree',
'%hm_dsearch',
'%hm_e',
'%hm_exp',
'%hm_eye',
'%hm_f_hm',
'%hm_find',
'%hm_floor',
'%hm_g_hm',
'%hm_grand',
'%hm_gsort',
'%hm_h_hm',
'%hm_i_b',
'%hm_i_ce',
'%hm_i_h',
'%hm_i_hm',
'%hm_i_i',
'%hm_i_p',
'%hm_i_r',
'%hm_i_s',
'%hm_i_st',
'%hm_iconvert',
'%hm_imag',
'%hm_int',
'%hm_isnan',
'%hm_isreal',
'%hm_j_hm',
'%hm_j_s',
'%hm_k_hm',
'%hm_k_s',
'%hm_log',
'%hm_m_p',
'%hm_m_r',
'%hm_m_s',
'%hm_matrix',
'%hm_max',
'%hm_mean',
'%hm_median',
'%hm_min',
'%hm_n_b',
'%hm_n_c',
'%hm_n_hm',
'%hm_n_i',
'%hm_n_p',
'%hm_n_s',
'%hm_o_b',
'%hm_o_c',
'%hm_o_hm',
'%hm_o_i',
'%hm_o_p',
'%hm_o_s',
'%hm_ones',
'%hm_or',
'%hm_p',
'%hm_prod',
'%hm_q_hm',
'%hm_r_s',
'%hm_rand',
'%hm_real',
'%hm_round',
'%hm_s',
'%hm_s_hm',
'%hm_s_r',
'%hm_s_s',
'%hm_sign',
'%hm_sin',
'%hm_size',
'%hm_sqrt',
'%hm_stdev',
'%hm_string',
'%hm_sum',
'%hm_x_hm',
'%hm_x_p',
'%hm_x_s',
'%hm_zeros',
'%i_1_s',
'%i_2_s',
'%i_3_s',
'%i_4_s',
'%i_Matplot',
'%i_a_i',
'%i_a_s',
'%i_and',
'%i_ascii',
'%i_b_s',
'%i_bezout',
'%i_champ',
'%i_champ1',
'%i_contour',
'%i_contour2d',
'%i_d_i',
'%i_d_s',
'%i_dsearch',
'%i_e',
'%i_fft',
'%i_g_i',
'%i_gcd',
'%i_grand',
'%i_h_i',
'%i_i_ce',
'%i_i_h',
'%i_i_hm',
'%i_i_i',
'%i_i_s',
'%i_i_st',
'%i_j_i',
'%i_j_s',
'%i_l_s',
'%i_lcm',
'%i_length',
'%i_m_i',
'%i_m_s',
'%i_mfprintf',
'%i_mprintf',
'%i_msprintf',
'%i_n_s',
'%i_o_s',
'%i_or',
'%i_p_i',
'%i_p_s',
'%i_plot2d',
'%i_plot2d1',
'%i_plot2d2',
'%i_q_s',
'%i_r_i',
'%i_r_s',
'%i_round',
'%i_s_i',
'%i_s_s',
'%i_sign',
'%i_string',
'%i_x_i',
'%i_x_s',
'%ip_a_s',
'%ip_i_st',
'%ip_m_s',
'%ip_n_ip',
'%ip_o_ip',
'%ip_p',
'%ip_part',
'%ip_s_s',
'%ip_string',
'%k',
'%l_i_h',
'%l_i_s',
'%l_i_st',
'%l_isequal',
'%l_n_c',
'%l_n_l',
'%l_n_m',
'%l_n_p',
'%l_n_s',
'%l_n_st',
'%l_o_c',
'%l_o_l',
'%l_o_m',
'%l_o_p',
'%l_o_s',
'%l_o_st',
'%lss_a_lss',
'%lss_a_p',
'%lss_a_r',
'%lss_a_s',
'%lss_c_lss',
'%lss_c_p',
'%lss_c_r',
'%lss_c_s',
'%lss_e',
'%lss_eye',
'%lss_f_lss',
'%lss_f_p',
'%lss_f_r',
'%lss_f_s',
'%lss_i_ce',
'%lss_i_lss',
'%lss_i_p',
'%lss_i_r',
'%lss_i_s',
'%lss_i_st',
'%lss_inv',
'%lss_l_lss',
'%lss_l_p',
'%lss_l_r',
'%lss_l_s',
'%lss_m_lss',
'%lss_m_p',
'%lss_m_r',
'%lss_m_s',
'%lss_n_lss',
'%lss_n_p',
'%lss_n_r',
'%lss_n_s',
'%lss_norm',
'%lss_o_lss',
'%lss_o_p',
'%lss_o_r',
'%lss_o_s',
'%lss_ones',
'%lss_r_lss',
'%lss_r_p',
'%lss_r_r',
'%lss_r_s',
'%lss_rand',
'%lss_s',
'%lss_s_lss',
'%lss_s_p',
'%lss_s_r',
'%lss_s_s',
'%lss_size',
'%lss_t',
'%lss_v_lss',
'%lss_v_p',
'%lss_v_r',
'%lss_v_s',
'%lt_i_s',
'%m_n_l',
'%m_o_l',
'%mc_i_h',
'%mc_i_s',
'%mc_i_st',
'%mc_n_st',
'%mc_o_st',
'%mc_string',
'%mps_p',
'%mps_string',
'%msp_a_s',
'%msp_abs',
'%msp_e',
'%msp_find',
'%msp_i_s',
'%msp_i_st',
'%msp_length',
'%msp_m_s',
'%msp_maxi',
'%msp_n_msp',
'%msp_nnz',
'%msp_o_msp',
'%msp_p',
'%msp_sparse',
'%msp_spones',
'%msp_t',
'%p_a_lss',
'%p_a_r',
'%p_c_lss',
'%p_c_r',
'%p_cumprod',
'%p_cumsum',
'%p_d_p',
'%p_d_r',
'%p_d_s',
'%p_det',
'%p_e',
'%p_f_lss',
'%p_f_r',
'%p_grand',
'%p_i_ce',
'%p_i_h',
'%p_i_hm',
'%p_i_lss',
'%p_i_p',
'%p_i_r',
'%p_i_s',
'%p_i_st',
'%p_inv',
'%p_j_s',
'%p_k_p',
'%p_k_r',
'%p_k_s',
'%p_l_lss',
'%p_l_p',
'%p_l_r',
'%p_l_s',
'%p_m_hm',
'%p_m_lss',
'%p_m_r',
'%p_matrix',
'%p_n_l',
'%p_n_lss',
'%p_n_r',
'%p_o_l',
'%p_o_lss',
'%p_o_r',
'%p_o_sp',
'%p_p_s',
'%p_part',
'%p_prod',
'%p_q_p',
'%p_q_r',
'%p_q_s',
'%p_r_lss',
'%p_r_p',
'%p_r_r',
'%p_r_s',
'%p_s_lss',
'%p_s_r',
'%p_simp',
'%p_string',
'%p_sum',
'%p_v_lss',
'%p_v_p',
'%p_v_r',
'%p_v_s',
'%p_x_hm',
'%p_x_r',
'%p_y_p',
'%p_y_r',
'%p_y_s',
'%p_z_p',
'%p_z_r',
'%p_z_s',
'%pcg',
'%plist_p',
'%plist_string',
'%r_0',
'%r_a_hm',
'%r_a_lss',
'%r_a_p',
'%r_a_r',
'%r_a_s',
'%r_c_lss',
'%r_c_p',
'%r_c_r',
'%r_c_s',
'%r_clean',
'%r_cumprod',
'%r_cumsum',
'%r_d_p',
'%r_d_r',
'%r_d_s',
'%r_det',
'%r_diag',
'%r_e',
'%r_eye',
'%r_f_lss',
'%r_f_p',
'%r_f_r',
'%r_f_s',
'%r_i_ce',
'%r_i_hm',
'%r_i_lss',
'%r_i_p',
'%r_i_r',
'%r_i_s',
'%r_i_st',
'%r_inv',
'%r_j_s',
'%r_k_p',
'%r_k_r',
'%r_k_s',
'%r_l_lss',
'%r_l_p',
'%r_l_r',
'%r_l_s',
'%r_m_hm',
'%r_m_lss',
'%r_m_p',
'%r_m_r',
'%r_m_s',
'%r_matrix',
'%r_n_lss',
'%r_n_p',
'%r_n_r',
'%r_n_s',
'%r_norm',
'%r_o_lss',
'%r_o_p',
'%r_o_r',
'%r_o_s',
'%r_ones',
'%r_p',
'%r_p_s',
'%r_prod',
'%r_q_p',
'%r_q_r',
'%r_q_s',
'%r_r_lss',
'%r_r_p',
'%r_r_r',
'%r_r_s',
'%r_rand',
'%r_s',
'%r_s_hm',
'%r_s_lss',
'%r_s_p',
'%r_s_r',
'%r_s_s',
'%r_simp',
'%r_size',
'%r_string',
'%r_sum',
'%r_t',
'%r_tril',
'%r_triu',
'%r_v_lss',
'%r_v_p',
'%r_v_r',
'%r_v_s',
'%r_varn',
'%r_x_p',
'%r_x_r',
'%r_x_s',
'%r_y_p',
'%r_y_r',
'%r_y_s',
'%r_z_p',
'%r_z_r',
'%r_z_s',
'%s_1_hm',
'%s_1_i',
'%s_2_hm',
'%s_2_i',
'%s_3_hm',
'%s_3_i',
'%s_4_hm',
'%s_4_i',
'%s_5',
'%s_a_b',
'%s_a_hm',
'%s_a_i',
'%s_a_ip',
'%s_a_lss',
'%s_a_msp',
'%s_a_r',
'%s_a_sp',
'%s_and',
'%s_b_i',
'%s_b_s',
'%s_bezout',
'%s_c_b',
'%s_c_cblock',
'%s_c_lss',
'%s_c_r',
'%s_c_sp',
'%s_d_b',
'%s_d_i',
'%s_d_p',
'%s_d_r',
'%s_d_sp',
'%s_e',
'%s_f_b',
'%s_f_cblock',
'%s_f_lss',
'%s_f_r',
'%s_f_sp',
'%s_g_b',
'%s_g_s',
'%s_gcd',
'%s_grand',
'%s_h_b',
'%s_h_s',
'%s_i_b',
'%s_i_c',
'%s_i_ce',
'%s_i_h',
'%s_i_hm',
'%s_i_i',
'%s_i_lss',
'%s_i_p',
'%s_i_r',
'%s_i_s',
'%s_i_sp',
'%s_i_spb',
'%s_i_st',
'%s_j_i',
'%s_k_hm',
'%s_k_p',
'%s_k_r',
'%s_k_sp',
'%s_l_b',
'%s_l_hm',
'%s_l_i',
'%s_l_lss',
'%s_l_p',
'%s_l_r',
'%s_l_s',
'%s_l_sp',
'%s_lcm',
'%s_m_b',
'%s_m_hm',
'%s_m_i',
'%s_m_ip',
'%s_m_lss',
'%s_m_msp',
'%s_m_r',
'%s_matrix',
'%s_n_hm',
'%s_n_i',
'%s_n_l',
'%s_n_lss',
'%s_n_r',
'%s_n_st',
'%s_o_hm',
'%s_o_i',
'%s_o_l',
'%s_o_lss',
'%s_o_r',
'%s_o_st',
'%s_or',
'%s_p_b',
'%s_p_i',
'%s_pow',
'%s_q_hm',
'%s_q_i',
'%s_q_p',
'%s_q_r',
'%s_q_sp',
'%s_r_b',
'%s_r_i',
'%s_r_lss',
'%s_r_p',
'%s_r_r',
'%s_r_s',
'%s_r_sp',
'%s_s_b',
'%s_s_hm',
'%s_s_i',
'%s_s_ip',
'%s_s_lss',
'%s_s_r',
'%s_s_sp',
'%s_simp',
'%s_v_lss',
'%s_v_p',
'%s_v_r',
'%s_v_s',
'%s_x_b',
'%s_x_hm',
'%s_x_i',
'%s_x_r',
'%s_y_p',
'%s_y_r',
'%s_y_sp',
'%s_z_p',
'%s_z_r',
'%s_z_sp',
'%sn',
'%sp_a_s',
'%sp_a_sp',
'%sp_and',
'%sp_c_s',
'%sp_ceil',
'%sp_conj',
'%sp_cos',
'%sp_cumprod',
'%sp_cumsum',
'%sp_d_s',
'%sp_d_sp',
'%sp_det',
'%sp_diag',
'%sp_e',
'%sp_exp',
'%sp_f_s',
'%sp_floor',
'%sp_grand',
'%sp_gsort',
'%sp_i_ce',
'%sp_i_h',
'%sp_i_s',
'%sp_i_sp',
'%sp_i_st',
'%sp_int',
'%sp_inv',
'%sp_k_s',
'%sp_k_sp',
'%sp_l_s',
'%sp_l_sp',
'%sp_length',
'%sp_max',
'%sp_min',
'%sp_norm',
'%sp_or',
'%sp_p_s',
'%sp_prod',
'%sp_q_s',
'%sp_q_sp',
'%sp_r_s',
'%sp_r_sp',
'%sp_round',
'%sp_s_s',
'%sp_s_sp',
'%sp_sin',
'%sp_sqrt',
'%sp_string',
'%sp_sum',
'%sp_tril',
'%sp_triu',
'%sp_y_s',
'%sp_y_sp',
'%sp_z_s',
'%sp_z_sp',
'%spb_and',
'%spb_c_b',
'%spb_cumprod',
'%spb_cumsum',
'%spb_diag',
'%spb_e',
'%spb_f_b',
'%spb_g_b',
'%spb_g_spb',
'%spb_h_b',
'%spb_h_spb',
'%spb_i_b',
'%spb_i_ce',
'%spb_i_h',
'%spb_i_st',
'%spb_or',
'%spb_prod',
'%spb_sum',
'%spb_tril',
'%spb_triu',
'%st_6',
'%st_c_st',
'%st_e',
'%st_f_st',
'%st_i_b',
'%st_i_c',
'%st_i_fptr',
'%st_i_h',
'%st_i_i',
'%st_i_ip',
'%st_i_lss',
'%st_i_msp',
'%st_i_p',
'%st_i_r',
'%st_i_s',
'%st_i_sp',
'%st_i_spb',
'%st_i_st',
'%st_matrix',
'%st_n_c',
'%st_n_l',
'%st_n_mc',
'%st_n_p',
'%st_n_s',
'%st_o_c',
'%st_o_l',
'%st_o_mc',
'%st_o_p',
'%st_o_s',
'%st_o_tl',
'%st_p',
'%st_size',
'%st_string',
'%st_t',
'%ticks_i_h',
'%xls_e',
'%xls_p',
'%xlssheet_e',
'%xlssheet_p',
'%xlssheet_size',
'%xlssheet_string',
'DominationRank',
'G_make',
'IsAScalar',
'NDcost',
'OS_Version',
'PlotSparse',
'ReadHBSparse',
'TCL_CreateSlave',
'abcd',
'abinv',
'accept_func_default',
'accept_func_vfsa',
'acf',
'acosd',
'acosh',
'acoshm',
'acosm',
'acot',
'acotd',
'acoth',
'acsc',
'acscd',
'acsch',
'add_demo',
'add_help_chapter',
'add_module_help_chapter',
'add_param',
'add_profiling',
'adj2sp',
'aff2ab',
'ana_style',
'analpf',
'analyze',
'aplat',
'arhnk',
'arl2',
'arma2p',
'arma2ss',
'armac',
'armax',
'armax1',
'arobasestring2strings',
'arsimul',
'ascii2string',
'asciimat',
'asec',
'asecd',
'asech',
'asind',
'asinh',
'asinhm',
'asinm',
'assert_checkalmostequal',
'assert_checkequal',
'assert_checkerror',
'assert_checkfalse',
'assert_checkfilesequal',
'assert_checktrue',
'assert_comparecomplex',
'assert_computedigits',
'assert_cond2reltol',
'assert_cond2reqdigits',
'assert_generror',
'atand',
'atanh',
'atanhm',
'atanm',
'atomsAutoload',
'atomsAutoloadAdd',
'atomsAutoloadDel',
'atomsAutoloadList',
'atomsCategoryList',
'atomsCheckModule',
'atomsDepTreeShow',
'atomsGetConfig',
'atomsGetInstalled',
'atomsGetInstalledPath',
'atomsGetLoaded',
'atomsGetLoadedPath',
'atomsInstall',
'atomsIsInstalled',
'atomsIsLoaded',
'atomsList',
'atomsLoad',
'atomsQuit',
'atomsRemove',
'atomsRepositoryAdd',
'atomsRepositoryDel',
'atomsRepositoryList',
'atomsRestoreConfig',
'atomsSaveConfig',
'atomsSearch',
'atomsSetConfig',
'atomsShow',
'atomsSystemInit',
'atomsSystemUpdate',
'atomsTest',
'atomsUpdate',
'atomsVersion',
'augment',
'auread',
'auwrite',
'balreal',
'bench_run',
'bilin',
'bilt',
'bin2dec',
'binomial',
'bitand',
'bitcmp',
'bitget',
'bitor',
'bitset',
'bitxor',
'black',
'blanks',
'bloc2exp',
'bloc2ss',
'block_parameter_error',
'bode',
'bode_asymp',
'bstap',
'buttmag',
'bvodeS',
'bytecode',
'bytecodewalk',
'cainv',
'calendar',
'calerf',
'calfrq',
'canon',
'casc',
'cat',
'cat_code',
'cb_m2sci_gui',
'ccontrg',
'cell',
'cell2mat',
'cellstr',
'center',
'cepstrum',
'cfspec',
'char',
'chart',
'cheb1mag',
'cheb2mag',
'check_gateways',
'check_modules_xml',
'check_versions',
'chepol',
'chfact',
'chsolve',
'classmarkov',
'clean_help',
'clock',
'cls2dls',
'cmb_lin',
'cmndred',
'cmoment',
'coding_ga_binary',
'coding_ga_identity',
'coff',
'coffg',
'colcomp',
'colcompr',
'colinout',
'colregul',
'companion',
'complex',
'compute_initial_temp',
'cond',
'cond2sp',
'condestsp',
'configure_msifort',
'configure_msvc',
'conjgrad',
'cont_frm',
'cont_mat',
'contrss',
'conv',
'convert_to_float',
'convertindex',
'convol',
'convol2d',
'copfac',
'correl',
'cosd',
'cosh',
'coshm',
'cosm',
'cotd',
'cotg',
'coth',
'cothm',
'cov',
'covar',
'createXConfiguration',
'createfun',
'createstruct',
'cross',
'crossover_ga_binary',
'crossover_ga_default',
'csc',
'cscd',
'csch',
'csgn',
'csim',
'cspect',
'ctr_gram',
'czt',
'dae',
'daeoptions',
'damp',
'datafit',
'date',
'datenum',
'datevec',
'dbphi',
'dcf',
'ddp',
'dec2bin',
'dec2hex',
'dec2oct',
'del_help_chapter',
'del_module_help_chapter',
'demo_begin',
'demo_choose',
'demo_compiler',
'demo_end',
'demo_file_choice',
'demo_folder_choice',
'demo_function_choice',
'demo_gui',
'demo_run',
'demo_viewCode',
'denom',
'derivat',
'derivative',
'des2ss',
'des2tf',
'detectmsifort64tools',
'detectmsvc64tools',
'determ',
'detr',
'detrend',
'devtools_run_builder',
'dhnorm',
'diff',
'diophant',
'dir',
'dirname',
'dispfiles',
'dllinfo',
'dscr',
'dsimul',
'dt_ility',
'dtsi',
'edit',
'edit_error',
'editor',
'eigenmarkov',
'eigs',
'ell1mag',
'enlarge_shape',
'entropy',
'eomday',
'epred',
'eqfir',
'eqiir',
'equil',
'equil1',
'erfinv',
'etime',
'eval',
'evans',
'evstr',
'example_run',
'expression2code',
'extract_help_examples',
'factor',
'factorial',
'factors',
'faurre',
'ffilt',
'fft2',
'fftshift',
'fieldnames',
'filt_sinc',
'filter',
'findABCD',
'findAC',
'findBDK',
'findR',
'find_freq',
'find_links',
'find_scicos_version',
'findm',
'findmsifortcompiler',
'findmsvccompiler',
'findx0BD',
'firstnonsingleton',
'fix',
'fixedpointgcd',
'flipdim',
'flts',
'fminsearch',
'formatBlackTip',
'formatBodeMagTip',
'formatBodePhaseTip',
'formatGainplotTip',
'formatHallModuleTip',
'formatHallPhaseTip',
'formatNicholsGainTip',
'formatNicholsPhaseTip',
'formatNyquistTip',
'formatPhaseplotTip',
'formatSgridDampingTip',
'formatSgridFreqTip',
'formatZgridDampingTip',
'formatZgridFreqTip',
'format_txt',
'fourplan',
'frep2tf',
'freson',
'frfit',
'frmag',
'fseek_origin',
'fsfirlin',
'fspec',
'fspecg',
'fstabst',
'ftest',
'ftuneq',
'fullfile',
'fullrf',
'fullrfk',
'fun2string',
'g_margin',
'gainplot',
'gamitg',
'gcare',
'gcd',
'gencompilationflags_unix',
'generateBlockImage',
'generateBlockImages',
'generic_i_ce',
'generic_i_h',
'generic_i_hm',
'generic_i_s',
'generic_i_st',
'genlib',
'genmarkov',
'geomean',
'getDiagramVersion',
'getModelicaPath',
'getPreferencesValue',
'get_file_path',
'get_function_path',
'get_param',
'get_profile',
'get_scicos_version',
'getd',
'getscilabkeywords',
'getshell',
'gettklib',
'gfare',
'gfrancis',
'givens',
'glever',
'gmres',
'group',
'gschur',
'gspec',
'gtild',
'h2norm',
'h_cl',
'h_inf',
'h_inf_st',
'h_norm',
'hallchart',
'halt',
'hank',
'hankelsv',
'harmean',
'haveacompiler',
'head_comments',
'help_from_sci',
'help_skeleton',
'hermit',
'hex2dec',
'hilb',
'hilbert',
'histc',
'horner',
'householder',
'hrmt',
'htrianr',
'hypermat',
'idct',
'idst',
'ifft',
'ifftshift',
'iir',
'iirgroup',
'iirlp',
'iirmod',
'ilib_build',
'ilib_build_jar',
'ilib_compile',
'ilib_for_link',
'ilib_gen_Make',
'ilib_gen_Make_unix',
'ilib_gen_cleaner',
'ilib_gen_gateway',
'ilib_gen_loader',
'ilib_include_flag',
'ilib_mex_build',
'im_inv',
'importScicosDiagram',
'importScicosPal',
'importXcosDiagram',
'imrep2ss',
'ind2sub',
'inistate',
'init_ga_default',
'init_param',
'initial_scicos_tables',
'input',
'instruction2code',
'intc',
'intdec',
'integrate',
'interp1',
'interpln',
'intersect',
'intl',
'intsplin',
'inttrap',
'inv_coeff',
'invr',
'invrs',
'invsyslin',
'iqr',
'isLeapYear',
'is_absolute_path',
'is_param',
'iscell',
'iscellstr',
'iscolumn',
'isempty',
'isfield',
'isinf',
'ismatrix',
'isnan',
'isrow',
'isscalar',
'issparse',
'issquare',
'isstruct',
'isvector',
'jmat',
'justify',
'kalm',
'karmarkar',
'kernel',
'kpure',
'krac2',
'kroneck',
'lattn',
'lattp',
'launchtest',
'lcf',
'lcm',
'lcmdiag',
'leastsq',
'leqe',
'leqr',
'lev',
'levin',
'lex_sort',
'lft',
'lin',
'lin2mu',
'lincos',
'lindquist',
'linf',
'linfn',
'linsolve',
'linspace',
'list2vec',
'list_param',
'listfiles',
'listfunctions',
'listvarinfile',
'lmisolver',
'lmitool',
'loadXcosLibs',
'loadmatfile',
'loadwave',
'log10',
'log2',
'logm',
'logspace',
'lqe',
'lqg',
'lqg2stan',
'lqg_ltr',
'lqr',
'ls',
'lyap',
'm2sci_gui',
'm_circle',
'macglov',
'macrovar',
'mad',
'makecell',
'manedit',
'mapsound',
'markp2ss',
'matfile2sci',
'mdelete',
'mean',
'meanf',
'median',
'members',
'mese',
'meshgrid',
'mfft',
'mfile2sci',
'minreal',
'minss',
'mkdir',
'modulo',
'moment',
'mrfit',
'msd',
'mstr2sci',
'mtlb',
'mtlb_0',
'mtlb_a',
'mtlb_all',
'mtlb_any',
'mtlb_axes',
'mtlb_axis',
'mtlb_beta',
'mtlb_box',
'mtlb_choices',
'mtlb_close',
'mtlb_colordef',
'mtlb_cond',
'mtlb_cov',
'mtlb_cumprod',
'mtlb_cumsum',
'mtlb_dec2hex',
'mtlb_delete',
'mtlb_diag',
'mtlb_diff',
'mtlb_dir',
'mtlb_double',
'mtlb_e',
'mtlb_echo',
'mtlb_error',
'mtlb_eval',
'mtlb_exist',
'mtlb_eye',
'mtlb_false',
'mtlb_fft',
'mtlb_fftshift',
'mtlb_filter',
'mtlb_find',
'mtlb_findstr',
'mtlb_fliplr',
'mtlb_fopen',
'mtlb_format',
'mtlb_fprintf',
'mtlb_fread',
'mtlb_fscanf',
'mtlb_full',
'mtlb_fwrite',
'mtlb_get',
'mtlb_grid',
'mtlb_hold',
'mtlb_i',
'mtlb_ifft',
'mtlb_image',
'mtlb_imp',
'mtlb_int16',
'mtlb_int32',
'mtlb_int8',
'mtlb_is',
'mtlb_isa',
'mtlb_isfield',
'mtlb_isletter',
'mtlb_isspace',
'mtlb_l',
'mtlb_legendre',
'mtlb_linspace',
'mtlb_logic',
'mtlb_logical',
'mtlb_loglog',
'mtlb_lower',
'mtlb_max',
'mtlb_mean',
'mtlb_median',
'mtlb_mesh',
'mtlb_meshdom',
'mtlb_min',
'mtlb_more',
'mtlb_num2str',
'mtlb_ones',
'mtlb_pcolor',
'mtlb_plot',
'mtlb_prod',
'mtlb_qr',
'mtlb_qz',
'mtlb_rand',
'mtlb_randn',
'mtlb_rcond',
'mtlb_realmax',
'mtlb_realmin',
'mtlb_s',
'mtlb_semilogx',
'mtlb_semilogy',
'mtlb_setstr',
'mtlb_size',
'mtlb_sort',
'mtlb_sortrows',
'mtlb_sprintf',
'mtlb_sscanf',
'mtlb_std',
'mtlb_strcmp',
'mtlb_strcmpi',
'mtlb_strfind',
'mtlb_strrep',
'mtlb_subplot',
'mtlb_sum',
'mtlb_t',
'mtlb_toeplitz',
'mtlb_tril',
'mtlb_triu',
'mtlb_true',
'mtlb_type',
'mtlb_uint16',
'mtlb_uint32',
'mtlb_uint8',
'mtlb_upper',
'mtlb_var',
'mtlb_zeros',
'mu2lin',
'mutation_ga_binary',
'mutation_ga_default',
'mvcorrel',
'mvvacov',
'nancumsum',
'nand2mean',
'nanmax',
'nanmean',
'nanmeanf',
'nanmedian',
'nanmin',
'nanreglin',
'nanstdev',
'nansum',
'narsimul',
'ndgrid',
'ndims',
'nehari',
'neigh_func_csa',
'neigh_func_default',
'neigh_func_fsa',
'neigh_func_vfsa',
'neldermead_cget',
'neldermead_configure',
'neldermead_costf',
'neldermead_defaultoutput',
'neldermead_destroy',
'neldermead_function',
'neldermead_get',
'neldermead_log',
'neldermead_new',
'neldermead_restart',
'neldermead_search',
'neldermead_updatesimp',
'nextpow2',
'nfreq',
'nicholschart',
'nlev',
'nmplot_cget',
'nmplot_configure',
'nmplot_contour',
'nmplot_destroy',
'nmplot_function',
'nmplot_get',
'nmplot_historyplot',
'nmplot_log',
'nmplot_new',
'nmplot_outputcmd',
'nmplot_restart',
'nmplot_search',
'nmplot_simplexhistory',
'noisegen',
'nonreg_test_run',
'now',
'nthroot',
'null',
'num2cell',
'numderivative',
'numdiff',
'numer',
'nyquist',
'nyquistfrequencybounds',
'obs_gram',
'obscont',
'observer',
'obsv_mat',
'obsvss',
'oct2dec',
'odeoptions',
'optim_ga',
'optim_moga',
'optim_nsga',
'optim_nsga2',
'optim_sa',
'optimbase_cget',
'optimbase_checkbounds',
'optimbase_checkcostfun',
'optimbase_checkx0',
'optimbase_configure',
'optimbase_destroy',
'optimbase_function',
'optimbase_get',
'optimbase_hasbounds',
'optimbase_hasconstraints',
'optimbase_hasnlcons',
'optimbase_histget',
'optimbase_histset',
'optimbase_incriter',
'optimbase_isfeasible',
'optimbase_isinbounds',
'optimbase_isinnonlincons',
'optimbase_log',
'optimbase_logshutdown',
'optimbase_logstartup',
'optimbase_new',
'optimbase_outputcmd',
'optimbase_outstruct',
'optimbase_proj2bnds',
'optimbase_set',
'optimbase_stoplog',
'optimbase_terminate',
'optimget',
'optimplotfunccount',
'optimplotfval',
'optimplotx',
'optimset',
'optimsimplex_center',
'optimsimplex_check',
'optimsimplex_compsomefv',
'optimsimplex_computefv',
'optimsimplex_deltafv',
'optimsimplex_deltafvmax',
'optimsimplex_destroy',
'optimsimplex_dirmat',
'optimsimplex_fvmean',
'optimsimplex_fvstdev',
'optimsimplex_fvvariance',
'optimsimplex_getall',
'optimsimplex_getallfv',
'optimsimplex_getallx',
'optimsimplex_getfv',
'optimsimplex_getn',
'optimsimplex_getnbve',
'optimsimplex_getve',
'optimsimplex_getx',
'optimsimplex_gradientfv',
'optimsimplex_log',
'optimsimplex_new',
'optimsimplex_reflect',
'optimsimplex_setall',
'optimsimplex_setallfv',
'optimsimplex_setallx',
'optimsimplex_setfv',
'optimsimplex_setn',
'optimsimplex_setnbve',
'optimsimplex_setve',
'optimsimplex_setx',
'optimsimplex_shrink',
'optimsimplex_size',
'optimsimplex_sort',
'optimsimplex_xbar',
'orth',
'output_ga_default',
'output_moga_default',
'output_nsga2_default',
'output_nsga_default',
'p_margin',
'pack',
'pareto_filter',
'parrot',
'pbig',
'pca',
'pcg',
'pdiv',
'pen2ea',
'pencan',
'pencost',
'penlaur',
'perctl',
'perl',
'perms',
'permute',
'pertrans',
'pfactors',
'pfss',
'phasemag',
'phaseplot',
'phc',
'pinv',
'playsnd',
'plotprofile',
'plzr',
'pmodulo',
'pol2des',
'pol2str',
'polar',
'polfact',
'prbs_a',
'prettyprint',
'primes',
'princomp',
'profile',
'proj',
'projsl',
'projspec',
'psmall',
'pspect',
'qmr',
'qpsolve',
'quart',
'quaskro',
'rafiter',
'randpencil',
'range',
'rank',
'readxls',
'recompilefunction',
'recons',
'reglin',
'regress',
'remezb',
'remove_param',
'remove_profiling',
'repfreq',
'replace_Ix_by_Fx',
'repmat',
'reset_profiling',
'resize_matrix',
'returntoscilab',
'rhs2code',
'ric_desc',
'riccati',
'rmdir',
'routh_t',
'rowcomp',
'rowcompr',
'rowinout',
'rowregul',
'rowshuff',
'rref',
'sample',
'samplef',
'samwr',
'savematfile',
'savewave',
'scanf',
'sci2exp',
'sciGUI_init',
'sci_sparse',
'scicos_getvalue',
'scicos_simulate',
'scicos_workspace_init',
'scisptdemo',
'scitest',
'sdiff',
'sec',
'secd',
'sech',
'selection_ga_elitist',
'selection_ga_random',
'sensi',
'setPreferencesValue',
'set_param',
'setdiff',
'sgrid',
'show_margins',
'show_pca',
'showprofile',
'signm',
'sinc',
'sincd',
'sind',
'sinh',
'sinhm',
'sinm',
'sm2des',
'sm2ss',
'smga',
'smooth',
'solve',
'sound',
'soundsec',
'sp2adj',
'spaninter',
'spanplus',
'spantwo',
'specfact',
'speye',
'sprand',
'spzeros',
'sqroot',
'sqrtm',
'squarewave',
'squeeze',
'srfaur',
'srkf',
'ss2des',
'ss2ss',
'ss2tf',
'sskf',
'ssprint',
'ssrand',
'st_deviation',
'st_i_generic',
'st_ility',
'stabil',
'statgain',
'stdev',
'stdevf',
'steadycos',
'strange',
'strcmpi',
'struct',
'sub2ind',
'sva',
'svplot',
'sylm',
'sylv',
'sysconv',
'sysdiag',
'sysfact',
'syslin',
'syssize',
'system',
'systmat',
'tabul',
'tand',
'tanh',
'tanhm',
'tanm',
'tbx_build_blocks',
'tbx_build_cleaner',
'tbx_build_gateway',
'tbx_build_gateway_clean',
'tbx_build_gateway_loader',
'tbx_build_help',
'tbx_build_help_loader',
'tbx_build_loader',
'tbx_build_localization',
'tbx_build_macros',
'tbx_build_pal_loader',
'tbx_build_src',
'tbx_builder',
'tbx_builder_gateway',
'tbx_builder_gateway_lang',
'tbx_builder_help',
'tbx_builder_help_lang',
'tbx_builder_macros',
'tbx_builder_src',
'tbx_builder_src_lang',
'tbx_generate_pofile',
'temp_law_csa',
'temp_law_default',
'temp_law_fsa',
'temp_law_huang',
'temp_law_vfsa',
'test_clean',
'test_on_columns',
'test_run',
'test_run_level',
'testexamples',
'tf2des',
'tf2ss',
'thrownan',
'tic',
'time_id',
'toc',
'toeplitz',
'tokenpos',
'toolboxes',
'trace',
'trans',
'translatepaths',
'tree2code',
'trfmod',
'trianfml',
'trimmean',
'trisolve',
'trzeros',
'typeof',
'ui_observer',
'union',
'unique',
'unit_test_run',
'unix_g',
'unix_s',
'unix_w',
'unix_x',
'unobs',
'unpack',
'unwrap',
'variance',
'variancef',
'vec2list',
'vectorfind',
'ver',
'warnobsolete',
'wavread',
'wavwrite',
'wcenter',
'weekday',
'wfir',
'wfir_gui',
'whereami',
'who_user',
'whos',
'wiener',
'wigner',
'window',
'winlist',
'with_javasci',
'with_macros_source',
'with_modelica_compiler',
'with_tk',
'xcorr',
'xcosBlockEval',
'xcosBlockInterface',
'xcosCodeGeneration',
'xcosConfigureModelica',
'xcosPal',
'xcosPalAdd',
'xcosPalAddBlock',
'xcosPalExport',
'xcosPalGenerateAllIcons',
'xcosShowBlockWarning',
'xcosValidateBlockSet',
'xcosValidateCompareBlock',
'xcos_compile',
'xcos_debug_gui',
'xcos_run',
'xcos_simulate',
'xcov',
'xmltochm',
'xmltoformat',
'xmltohtml',
'xmltojar',
'xmltopdf',
'xmltops',
'xmltoweb',
'yulewalk',
'zeropen',
'zgrid',
'zpbutt',
'zpch1',
'zpch2',
'zpell',
)
variables_kw = (
'$',
'%F',
'%T',
'%e',
'%eps',
'%f',
'%fftw',
'%gui',
'%i',
'%inf',
'%io',
'%modalWarning',
'%nan',
'%pi',
'%s',
'%t',
'%tk',
'%toolboxes',
'%toolboxes_dir',
'%z',
'PWD',
'SCI',
'SCIHOME',
'TMPDIR',
'arnoldilib',
'assertlib',
'atomslib',
'cacsdlib',
'compatibility_functilib',
'corelib',
'data_structureslib',
'demo_toolslib',
'development_toolslib',
'differential_equationlib',
'dynamic_linklib',
'elementary_functionslib',
'enull',
'evoid',
'external_objectslib',
'fd',
'fileiolib',
'functionslib',
'genetic_algorithmslib',
'helptoolslib',
'home',
'integerlib',
'interpolationlib',
'iolib',
'jnull',
'jvoid',
'linear_algebralib',
'm2scilib',
'matiolib',
'modules_managerlib',
'neldermeadlib',
'optimbaselib',
'optimizationlib',
'optimsimplexlib',
'output_streamlib',
'overloadinglib',
'parameterslib',
'polynomialslib',
'preferenceslib',
'randliblib',
'scicos_autolib',
'scicos_utilslib',
'scinoteslib',
'signal_processinglib',
'simulated_annealinglib',
'soundlib',
'sparselib',
'special_functionslib',
'spreadsheetlib',
'statisticslib',
'stringlib',
'tclscilib',
'timelib',
'umfpacklib',
'xcoslib',
)
if __name__ == '__main__': # pragma: no cover
import subprocess
from pygments.util import format_lines, duplicates_removed
mapping = {'variables': 'builtin'}
def extract_completion(var_type):
s = subprocess.Popen(['scilab', '-nwni'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = s.communicate('''\
fd = mopen("/dev/stderr", "wt");
mputl(strcat(completion("", "%s"), "||"), fd);
mclose(fd)\n''' % var_type)
if '||' not in output[1]:
raise Exception(output[0])
# Invalid DISPLAY causes this to be output:
text = output[1].strip()
if text.startswith('Error: unable to open display \n'):
text = text[len('Error: unable to open display \n'):]
return text.split('||')
new_data = {}
seen = set() # only keep first type for a given word
for t in ('functions', 'commands', 'macros', 'variables'):
new_data[t] = duplicates_removed(extract_completion(t), seen)
seen.update(set(new_data[t]))
with open(__file__) as f:
content = f.read()
header = content[:content.find('# Autogenerated')]
footer = content[content.find("if __name__ == '__main__':"):]
with open(__file__, 'w') as f:
f.write(header)
f.write('# Autogenerated\n\n')
for k, v in sorted(new_data.iteritems()):
f.write(format_lines(k + '_kw', v) + '\n\n')
f.write(footer)
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
423,
551,
24142,
63,
10372,
272,
18294,
9753,
339,
22422,
769,
367,
314,
13916,
24142,
5838,
14,
339,
520,
7307,
26,
1898,
8315,
13,
10680,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
3,
27722,
16741,
199,
199,
4405,
63,
829,
275,
334,
272,
283,
13845,
297,
272,
283,
30204,
1712,
297,
272,
283,
4785,
297,
272,
283,
2546,
297,
272,
283,
9341,
297,
272,
283,
6958,
297,
272,
283,
1117,
297,
272,
283,
2836,
297,
272,
283,
2836,
692,
297,
272,
283,
500,
297,
272,
283,
500,
1593,
297,
272,
283,
509,
297,
272,
283,
1593,
297,
272,
283,
3437,
297,
272,
283,
692,
297,
272,
283,
11241,
297,
272,
283,
10589,
297,
272,
283,
2416,
297,
272,
283,
12726,
297,
272,
283,
893,
297,
272,
283,
6710,
297,
199,
9,
199,
199,
5777,
63,
829,
275,
334,
272,
283,
3480,
63,
15195,
14474,
272,
1543,
40,
21,
1692,
63,
69,
297,
272,
1543,
40,
21,
1692,
63,
698,
1247,
297,
272,
1543,
40,
21,
1692,
63,
80,
297,
272,
1543,
4317,
7144,
63,
22,
297,
272,
1543,
4317,
7144,
63,
69,
297,
272,
1543,
4317,
7144,
63,
73,
63,
13901,
906,
3701,
297,
272,
1543,
4317,
7144,
63,
1267,
297,
272,
1543,
4317,
7144,
63,
80,
297,
272,
1543,
4317,
7144,
63,
890,
297,
272,
1543,
4317,
3768,
63,
22,
297,
272,
1543,
4317,
3768,
63,
69,
297,
272,
1543,
4317,
3768,
63,
73,
63,
4317,
1296,
297,
272,
1543,
4317,
3768,
63,
80,
297,
272,
1543,
13901,
906,
3701,
63,
22,
297,
272,
1543,
13901,
906,
3701,
63,
69,
297,
272,
1543,
13901,
906,
3701,
63,
73,
63,
4317,
3768,
297,
272,
1543,
13901,
906,
3701,
63,
73,
63,
13901,
906,
3701,
297,
272,
1543,
13901,
906,
3701,
63,
73,
63,
4317,
1296,
297,
272,
1543,
13901,
906,
3701,
63,
80,
297,
272,
1543,
4317,
1296,
63,
22,
297,
272,
1543,
4317,
1296,
63,
69,
297,
272,
1543,
4317,
1296,
63,
73,
63,
13901,
906,
3701,
297,
272,
1543,
4317,
1296,
63,
73,
63,
4317,
1296,
297,
272,
1543,
4317,
1296,
63,
1267,
297,
272,
1543,
4317,
1296,
63,
80,
297,
272,
1543,
4317,
1296,
63,
890,
297,
272,
1543,
4317,
2438,
63,
22,
297,
272,
1543,
4317,
2438,
63,
69,
297,
272,
1543,
4317,
2438,
63,
73,
63,
13901,
906,
3701,
297,
272,
1543,
4317,
2438,
63,
80,
297,
272,
1543,
4317,
1084,
63,
22,
297,
272,
1543,
4317,
1084,
63,
69,
297,
272,
1543,
4317,
1084,
63,
1267,
297,
272,
1543,
4317,
1084,
63,
80,
297,
272,
1543,
4317,
1084,
63,
890,
297,
272,
1543,
4317,
3490,
63,
80,
297,
272,
1543,
63,
37,
2543,
63,
22,
297,
272,
1543,
63,
37,
2543,
63,
69,
297,
272,
1543,
63,
37,
2543,
63,
80,
297,
272,
1543,
63,
29543,
63,
16,
297,
272,
1543,
63,
29543,
63,
17,
363,
29543,
297,
272,
1543,
63,
29543,
63,
17,
63,
66,
297,
272,
1543,
63,
29543,
63,
17,
63,
67,
297,
272,
1543,
63,
29543,
63,
17,
63,
73,
297,
272,
1543,
63,
29543,
63,
17,
63,
83,
297,
272,
1543,
63,
29543,
63,
18,
363,
29543,
297,
272,
1543,
63,
29543,
63,
18,
63,
66,
297,
272,
1543,
63,
29543,
63,
18,
63,
67,
297,
272,
1543,
63,
29543,
63,
18,
63,
73,
297,
272,
1543,
63,
29543,
63,
18,
63,
83,
297,
272,
1543,
63,
29543,
63,
19,
363,
29543,
297,
272,
1543,
63,
29543,
63,
19,
63,
66,
297,
272,
1543,
63,
29543,
63,
19,
63,
67,
297,
272,
1543,
63,
29543,
63,
19,
63,
73,
297,
272,
1543,
63,
29543,
63,
19,
63,
83,
297,
272,
1543,
63,
29543,
63,
20,
363,
29543,
297,
272,
1543,
63,
29543,
63,
20,
63,
66,
297,
272,
1543,
63,
29543,
63,
20,
63,
67,
297,
272,
1543,
63,
29543,
63,
20,
63,
73,
297,
272,
1543,
63,
29543,
63,
20,
63,
83,
297,
272,
1543,
63,
29543,
63,
21,
297,
272,
1543,
63,
29543,
63,
22,
297,
272,
1543,
63,
29543,
63,
65,
363,
29543,
297,
272,
1543,
63,
29543,
63,
65,
63,
66,
297,
272,
1543,
63,
29543,
63,
65,
63,
67,
297,
272,
1543,
63,
29543,
63,
65,
63,
73,
297,
272,
1543,
63,
29543,
63,
65,
63,
83,
297,
272,
1543,
63,
29543,
63,
68,
363,
29543,
297,
272,
1543,
63,
29543,
63,
68,
63,
66,
297,
272,
1543,
63,
29543,
63,
68,
63,
67,
297,
272,
1543,
63,
29543,
63,
68,
63,
73,
297,
272,
1543,
63,
29543,
63,
68,
63,
83,
297,
272,
1543,
63,
29543,
63,
13654,
297,
272,
1543,
63,
29543,
63,
69,
297,
272,
1543,
63,
29543,
63,
71,
363,
29543,
297,
272,
1543,
63,
29543,
63,
71,
63,
66,
297,
272,
1543,
63,
29543,
63,
71,
63,
67,
297,
272,
1543,
63,
29543,
63,
71,
63,
73,
297,
272,
1543,
63,
29543,
63,
71,
63,
83,
297,
272,
1543,
63,
29543,
63,
72,
363,
29543,
297,
272,
1543,
63,
29543,
63,
72,
63,
66,
297,
272,
1543,
63,
29543,
63,
72,
63,
67,
297,
272,
1543,
63,
29543,
63,
72,
63,
73,
297,
272,
1543,
63,
29543,
63,
72,
63,
83,
297,
272,
1543,
63,
29543,
63,
73,
363,
29543,
297,
272,
1543,
63,
29543,
63,
74,
363,
29543,
297,
272,
1543,
63,
29543,
63,
74,
63,
66,
297,
272,
1543,
63,
29543,
63,
74,
63,
67,
297,
272,
1543,
63,
29543,
63,
74,
63,
73,
297,
272,
1543,
63,
29543,
63,
74,
63,
83,
297,
272,
1543,
63,
29543,
63,
75,
363,
29543,
297,
272,
1543,
63,
29543,
63,
75,
63,
66,
297,
272,
1543,
63,
29543,
63,
75,
63,
67,
297,
272,
1543,
63,
29543,
63,
75,
63,
73,
297,
272,
1543,
63,
29543,
63,
75,
63,
83,
297,
272,
1543,
63,
29543,
63,
76,
363,
29543,
297,
272,
1543,
63,
29543,
63,
76,
63,
66,
297,
272,
1543,
63,
29543,
63,
76,
63,
67,
297,
272,
1543,
63,
29543,
63,
76,
63,
73,
297,
272,
1543,
63,
29543,
63,
76
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
624,
272,
13277,
14,
12245,
423,
551,
24142,
63,
10372,
272,
18294,
9753,
339,
22422,
769,
367,
314,
13916,
24142,
5838,
14,
339,
520,
7307,
26,
1898,
8315,
13,
10680,
701,
314,
14493,
8099,
12,
1937,
10610,
14,
272,
520,
1682,
26,
6289,
12,
1937,
5113,
367,
2436,
14,
199,
624,
199,
199,
3,
27722,
16741,
199,
199,
4405,
63,
829,
275,
334,
272,
283,
13845,
297,
272,
283,
30204,
1712,
297,
272,
283,
4785,
297,
272,
283,
2546,
297,
272,
283,
9341,
297,
272,
283,
6958,
297,
272,
283,
1117,
297,
272,
283,
2836,
297,
272,
283,
2836,
692,
297,
272,
283,
500,
297,
272,
283,
500,
1593,
297,
272,
283,
509,
297,
272,
283,
1593,
297,
272,
283,
3437,
297,
272,
283,
692,
297,
272,
283,
11241,
297,
272,
283,
10589,
297,
272,
283,
2416,
297,
272,
283,
12726,
297,
272,
283,
893,
297,
272,
283,
6710,
297,
199,
9,
199,
199,
5777,
63,
829,
275,
334,
272,
283,
3480,
63,
15195,
14474,
272,
1543,
40,
21,
1692,
63,
69,
297,
272,
1543,
40,
21,
1692,
63,
698,
1247,
297,
272,
1543,
40,
21,
1692,
63,
80,
297,
272,
1543,
4317,
7144,
63,
22,
297,
272,
1543,
4317,
7144,
63,
69,
297,
272,
1543,
4317,
7144,
63,
73,
63,
13901,
906,
3701,
297,
272,
1543,
4317,
7144,
63,
1267,
297,
272,
1543,
4317,
7144,
63,
80,
297,
272,
1543,
4317,
7144,
63,
890,
297,
272,
1543,
4317,
3768,
63,
22,
297,
272,
1543,
4317,
3768,
63,
69,
297,
272,
1543,
4317,
3768,
63,
73,
63,
4317,
1296,
297,
272,
1543,
4317,
3768,
63,
80,
297,
272,
1543,
13901,
906,
3701,
63,
22,
297,
272,
1543,
13901,
906,
3701,
63,
69,
297,
272,
1543,
13901,
906,
3701,
63,
73,
63,
4317,
3768,
297,
272,
1543,
13901,
906,
3701,
63,
73,
63,
13901,
906,
3701,
297,
272,
1543,
13901,
906,
3701,
63,
73,
63,
4317,
1296,
297,
272,
1543,
13901,
906,
3701,
63,
80,
297,
272,
1543,
4317,
1296,
63,
22,
297,
272,
1543,
4317,
1296,
63,
69,
297,
272,
1543,
4317,
1296,
63,
73,
63,
13901,
906,
3701,
297,
272,
1543,
4317,
1296,
63,
73,
63,
4317,
1296,
297,
272,
1543,
4317,
1296,
63,
1267,
297,
272,
1543,
4317,
1296,
63,
80,
297,
272,
1543,
4317,
1296,
63,
890,
297,
272,
1543,
4317,
2438,
63,
22,
297,
272,
1543,
4317,
2438,
63,
69,
297,
272,
1543,
4317,
2438,
63,
73,
63,
13901,
906,
3701,
297,
272,
1543,
4317,
2438,
63,
80,
297,
272,
1543,
4317,
1084,
63,
22,
297,
272,
1543,
4317,
1084,
63,
69,
297,
272,
1543,
4317,
1084,
63,
1267,
297,
272,
1543,
4317,
1084,
63,
80,
297,
272,
1543,
4317,
1084,
63,
890,
297,
272,
1543,
4317,
3490,
63,
80,
297,
272,
1543,
63,
37,
2543,
63,
22,
297,
272,
1543,
63,
37,
2543,
63,
69,
297,
272,
1543,
63,
37,
2543,
63,
80,
297,
272,
1543,
63,
29543,
63,
16,
297,
272,
1543,
63,
29543,
63,
17,
363,
29543,
297,
272,
1543,
63,
29543,
63,
17,
63,
66,
297,
272,
1543,
63,
29543,
63,
17,
63,
67,
297,
272,
1543,
63,
29543,
63,
17,
63,
73,
297,
272,
1543,
63,
29543,
63,
17,
63,
83,
297,
272,
1543,
63,
29543,
63,
18,
363,
29543,
297,
272,
1543,
63,
29543,
63,
18,
63,
66,
297,
272,
1543,
63,
29543,
63,
18,
63,
67,
297,
272,
1543,
63,
29543,
63,
18,
63,
73,
297,
272,
1543,
63,
29543,
63,
18,
63,
83,
297,
272,
1543,
63,
29543,
63,
19,
363,
29543,
297,
272,
1543,
63,
29543,
63,
19,
63,
66,
297,
272,
1543,
63,
29543,
63,
19,
63,
67,
297,
272,
1543,
63,
29543,
63,
19,
63,
73,
297,
272,
1543,
63,
29543,
63,
19,
63,
83,
297,
272,
1543,
63,
29543,
63,
20,
363,
29543,
297,
272,
1543,
63,
29543,
63,
20,
63,
66,
297,
272,
1543,
63,
29543,
63,
20,
63,
67,
297,
272,
1543,
63,
29543,
63,
20,
63,
73,
297,
272,
1543,
63,
29543,
63,
20,
63,
83,
297,
272,
1543,
63,
29543,
63,
21,
297,
272,
1543,
63,
29543,
63,
22,
297,
272,
1543,
63,
29543,
63,
65,
363,
29543,
297,
272,
1543,
63,
29543,
63,
65,
63,
66,
297,
272,
1543,
63,
29543,
63,
65,
63,
67,
297,
272,
1543,
63,
29543,
63,
65,
63,
73,
297,
272,
1543,
63,
29543,
63,
65,
63,
83,
297,
272,
1543,
63,
29543,
63,
68,
363,
29543,
297,
272,
1543,
63,
29543,
63,
68,
63,
66,
297,
272,
1543,
63,
29543,
63,
68,
63,
67,
297,
272,
1543,
63,
29543,
63,
68,
63,
73,
297,
272,
1543,
63,
29543,
63,
68,
63,
83,
297,
272,
1543,
63,
29543,
63,
13654,
297,
272,
1543,
63,
29543,
63,
69,
297,
272,
1543,
63,
29543,
63,
71,
363,
29543,
297,
272,
1543,
63,
29543,
63,
71,
63,
66,
297,
272,
1543,
63,
29543,
63,
71,
63,
67,
297,
272,
1543,
63,
29543,
63,
71,
63,
73,
297,
272,
1543,
63,
29543,
63,
71,
63,
83,
297,
272,
1543,
63,
29543,
63,
72,
363,
29543,
297,
272,
1543,
63,
29543,
63,
72,
63,
66,
297,
272,
1543,
63,
29543,
63,
72,
63,
67,
297,
272,
1543,
63,
29543,
63,
72,
63,
73,
297,
272,
1543,
63,
29543,
63,
72,
63,
83,
297,
272,
1543,
63,
29543,
63,
73,
363,
29543,
297,
272,
1543,
63,
29543,
63,
74,
363,
29543,
297,
272,
1543,
63,
29543,
63,
74,
63,
66,
297,
272,
1543,
63,
29543,
63,
74,
63,
67,
297,
272,
1543,
63,
29543,
63,
74,
63,
73,
297,
272,
1543,
63,
29543,
63,
74,
63,
83,
297,
272,
1543,
63,
29543,
63,
75,
363,
29543,
297,
272,
1543,
63,
29543,
63,
75,
63,
66,
297,
272,
1543,
63,
29543,
63,
75,
63,
67,
297,
272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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
] |
odubno/microblog
|
venv/lib/python2.7/site-packages/babel/localtime/_win32.py
|
82
|
2801
|
try:
import _winreg as winreg
except ImportError:
try:
import winreg
except ImportError:
winreg = None
from babel.core import get_global
import pytz
tz_names = get_global('windows_zone_mapping')
def valuestodict(key):
"""Convert a registry key's values to a dictionary."""
dict = {}
size = winreg.QueryInfoKey(key)[1]
for i in range(size):
data = winreg.EnumValue(key, i)
dict[data[0]] = data[1]
return dict
def get_localzone_name():
# Windows is special. It has unique time zone names (in several
# meanings of the word) available, but unfortunately, they can be
# translated to the language of the operating system, so we need to
# do a backwards lookup, by going through all time zones and see which
# one matches.
handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
TZLOCALKEYNAME = r'SYSTEM\CurrentControlSet\Control\TimeZoneInformation'
localtz = winreg.OpenKey(handle, TZLOCALKEYNAME)
keyvalues = valuestodict(localtz)
localtz.Close()
if 'TimeZoneKeyName' in keyvalues:
# Windows 7 (and Vista?)
# For some reason this returns a string with loads of NUL bytes at
# least on some systems. I don't know if this is a bug somewhere, I
# just work around it.
tzkeyname = keyvalues['TimeZoneKeyName'].split('\x00', 1)[0]
else:
# Windows 2000 or XP
# This is the localized name:
tzwin = keyvalues['StandardName']
# Open the list of timezones to look up the real name:
TZKEYNAME = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones'
tzkey = winreg.OpenKey(handle, TZKEYNAME)
# Now, match this value to Time Zone information
tzkeyname = None
for i in range(winreg.QueryInfoKey(tzkey)[0]):
subkey = winreg.EnumKey(tzkey, i)
sub = winreg.OpenKey(tzkey, subkey)
data = valuestodict(sub)
sub.Close()
if data['Std'] == tzwin:
tzkeyname = subkey
break
tzkey.Close()
handle.Close()
if tzkeyname is None:
raise LookupError('Can not find Windows timezone configuration')
timezone = tz_names.get(tzkeyname)
if timezone is None:
# Nope, that didn't work. Try adding 'Standard Time',
# it seems to work a lot of times:
timezone = tz_names.get(tzkeyname + ' Standard Time')
# Return what we have.
if timezone is None:
raise pytz.UnknownTimeZoneError('Can not find timezone ' + tzkeyname)
return timezone
def _get_localzone():
if winreg is None:
raise pytz.UnknownTimeZoneError(
'Runtime support not available')
return pytz.timezone(get_localzone_name())
|
bsd-3-clause
|
[
893,
26,
272,
492,
485,
15658,
465,
30748,
199,
2590,
3545,
26,
272,
862,
26,
267,
492,
30748,
272,
871,
3545,
26,
267,
30748,
275,
488,
199,
199,
504,
29178,
14,
1018,
492,
664,
63,
2966,
199,
646,
15444,
421,
199,
3903,
63,
1247,
275,
664,
63,
2966,
360,
8258,
63,
2619,
63,
4745,
358,
421,
199,
318,
574,
14308,
807,
8,
498,
304,
272,
408,
7306,
282,
7086,
790,
1159,
1338,
370,
282,
2600,
1041,
272,
1211,
275,
1052,
272,
1568,
275,
30748,
14,
3227,
2354,
1197,
8,
498,
2788,
17,
61,
272,
367,
284,
315,
1425,
8,
890,
304,
267,
666,
275,
30748,
14,
14432,
8,
498,
12,
284,
9,
267,
1211,
59,
576,
59,
16,
2677,
275,
666,
59,
17,
61,
272,
372,
1211,
421,
199,
318,
664,
63,
1832,
2619,
63,
354,
837,
272,
327,
5417,
365,
4539,
14,
2779,
965,
3747,
900,
5718,
1561,
334,
262,
9978,
272,
327,
4615,
780,
402,
314,
4349,
9,
2808,
12,
1325,
625,
21839,
12,
2985,
883,
506,
272,
327,
14598,
370,
314,
2637,
402,
314,
17406,
2656,
12,
880,
781,
1929,
370,
272,
327,
886,
282,
8552,
4237,
12,
701,
9995,
4012,
1006,
900,
18666,
436,
1937,
1314,
272,
327,
1373,
4450,
14,
272,
2429,
275,
30748,
14,
8631,
10899,
8,
403,
12,
30748,
14,
23802,
63,
7486,
63,
20890,
9,
339,
377,
58,
7486,
3078,
2339,
275,
519,
7,
12711,
60,
5639,
3717,
1084,
60,
3717,
60,
32515,
4935,
7,
272,
2257,
3903,
275,
30748,
14,
28144,
8,
2479,
12,
377,
58,
7486,
3078,
2339,
9,
272,
790,
1459,
275,
574,
14308,
807,
8,
1832,
3903,
9,
272,
2257,
3903,
14,
4724,
342,
272,
340,
283,
32515,
1197,
985,
7,
315,
790,
1459,
26,
267,
327,
5417,
1520,
334,
460,
19801,
65,
17076,
398,
327,
2104,
2005,
4499,
642,
2529,
282,
1059,
543,
14404,
402,
653,
1293,
2783,
737,
267,
327,
5210,
641,
2005,
10460,
14,
473,
2793,
1133,
5715,
340,
642,
365,
282,
6519,
23430,
12,
473,
267,
327,
2951,
1736,
6818,
652,
14,
267,
5823,
30499,
275,
790,
1459,
459,
32515,
1197,
985,
2278,
1294,
2258,
88,
383,
297,
413,
2788,
16,
61,
272,
587,
26,
267,
327,
5417,
12293,
503,
1323,
48,
398,
327,
961,
365,
314,
25460,
536,
26,
267,
5823,
2676,
275,
790,
1459,
459,
9232,
985,
418,
398,
327,
3232,
314,
769,
402,
7137,
83,
370,
3648,
1536,
314,
3363,
536,
26,
267,
377,
58,
3078,
2339,
275,
519,
7,
26734,
60,
12940,
60,
8647,
23350,
60,
5639,
3353,
60,
1366,
3107,
4548,
7,
267,
5823,
498,
275,
30748,
14,
28144,
8,
2479,
12,
377,
58,
3078,
2339,
9,
398,
327,
7356,
12,
1336,
642,
574,
370,
4703,
22518,
2556,
267,
5823,
30499,
275,
488,
267,
367,
284,
315,
1425,
8,
15658,
14,
3227,
2354,
1197,
8,
3903,
498,
2788,
16,
4682,
288,
1007,
498,
275,
30748,
14,
5081,
1197,
8,
3903,
498,
12,
284,
9,
288,
1007,
275,
30748,
14,
28144,
8,
3903,
498,
12,
1007,
498,
9,
288,
666,
275,
574,
14308,
807,
8,
954,
9,
288,
1007,
14,
4724,
342,
288,
340,
666,
459,
11976,
418,
508,
5823,
2676,
26,
355,
5823,
30499,
275,
1007,
498,
355,
2059,
398,
5823,
498,
14,
4724,
342,
267,
2429,
14,
4724,
342,
339,
340,
5823,
30499,
365,
488,
26,
267,
746,
19021,
360,
6049,
440,
2342,
5417,
7137,
2897,
358,
339,
7137,
275,
5823,
63,
1247,
14,
362,
8,
3903,
30499,
9,
272,
340,
7137,
365,
488,
26,
267,
327,
3091,
321,
12,
626,
9980,
1133,
1736,
14,
7649,
7791,
283,
9232,
4703,
297,
267,
327,
652,
12237,
370,
1736,
282,
13918,
402,
5431,
26,
267,
7137,
275,
5823,
63,
1247,
14,
362,
8,
3903,
30499,
435,
283,
9739,
4703,
358,
339,
327,
1432,
4052,
781,
1172,
14,
272,
340,
7137,
365,
488,
26,
267,
746,
15444,
14,
5912,
32515,
547,
360,
6049,
440,
2342,
7137,
283,
435,
5823,
30499,
9,
339,
372,
7137,
421,
199,
318,
485,
362,
63,
1832,
2619,
837,
272,
340,
30748,
365,
488,
26,
267,
746,
15444,
14,
5912,
32515,
547,
8,
288,
283,
14357,
2291,
440,
2808,
358,
272,
372,
15444,
14,
7145,
8,
362,
63,
1832,
2619,
63,
354,
1012,
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
] |
[
26,
272,
492,
485,
15658,
465,
30748,
199,
2590,
3545,
26,
272,
862,
26,
267,
492,
30748,
272,
871,
3545,
26,
267,
30748,
275,
488,
199,
199,
504,
29178,
14,
1018,
492,
664,
63,
2966,
199,
646,
15444,
421,
199,
3903,
63,
1247,
275,
664,
63,
2966,
360,
8258,
63,
2619,
63,
4745,
358,
421,
199,
318,
574,
14308,
807,
8,
498,
304,
272,
408,
7306,
282,
7086,
790,
1159,
1338,
370,
282,
2600,
1041,
272,
1211,
275,
1052,
272,
1568,
275,
30748,
14,
3227,
2354,
1197,
8,
498,
2788,
17,
61,
272,
367,
284,
315,
1425,
8,
890,
304,
267,
666,
275,
30748,
14,
14432,
8,
498,
12,
284,
9,
267,
1211,
59,
576,
59,
16,
2677,
275,
666,
59,
17,
61,
272,
372,
1211,
421,
199,
318,
664,
63,
1832,
2619,
63,
354,
837,
272,
327,
5417,
365,
4539,
14,
2779,
965,
3747,
900,
5718,
1561,
334,
262,
9978,
272,
327,
4615,
780,
402,
314,
4349,
9,
2808,
12,
1325,
625,
21839,
12,
2985,
883,
506,
272,
327,
14598,
370,
314,
2637,
402,
314,
17406,
2656,
12,
880,
781,
1929,
370,
272,
327,
886,
282,
8552,
4237,
12,
701,
9995,
4012,
1006,
900,
18666,
436,
1937,
1314,
272,
327,
1373,
4450,
14,
272,
2429,
275,
30748,
14,
8631,
10899,
8,
403,
12,
30748,
14,
23802,
63,
7486,
63,
20890,
9,
339,
377,
58,
7486,
3078,
2339,
275,
519,
7,
12711,
60,
5639,
3717,
1084,
60,
3717,
60,
32515,
4935,
7,
272,
2257,
3903,
275,
30748,
14,
28144,
8,
2479,
12,
377,
58,
7486,
3078,
2339,
9,
272,
790,
1459,
275,
574,
14308,
807,
8,
1832,
3903,
9,
272,
2257,
3903,
14,
4724,
342,
272,
340,
283,
32515,
1197,
985,
7,
315,
790,
1459,
26,
267,
327,
5417,
1520,
334,
460,
19801,
65,
17076,
398,
327,
2104,
2005,
4499,
642,
2529,
282,
1059,
543,
14404,
402,
653,
1293,
2783,
737,
267,
327,
5210,
641,
2005,
10460,
14,
473,
2793,
1133,
5715,
340,
642,
365,
282,
6519,
23430,
12,
473,
267,
327,
2951,
1736,
6818,
652,
14,
267,
5823,
30499,
275,
790,
1459,
459,
32515,
1197,
985,
2278,
1294,
2258,
88,
383,
297,
413,
2788,
16,
61,
272,
587,
26,
267,
327,
5417,
12293,
503,
1323,
48,
398,
327,
961,
365,
314,
25460,
536,
26,
267,
5823,
2676,
275,
790,
1459,
459,
9232,
985,
418,
398,
327,
3232,
314,
769,
402,
7137,
83,
370,
3648,
1536,
314,
3363,
536,
26,
267,
377,
58,
3078,
2339,
275,
519,
7,
26734,
60,
12940,
60,
8647,
23350,
60,
5639,
3353,
60,
1366,
3107,
4548,
7,
267,
5823,
498,
275,
30748,
14,
28144,
8,
2479,
12,
377,
58,
3078,
2339,
9,
398,
327,
7356,
12,
1336,
642,
574,
370,
4703,
22518,
2556,
267,
5823,
30499,
275,
488,
267,
367,
284,
315,
1425,
8,
15658,
14,
3227,
2354,
1197,
8,
3903,
498,
2788,
16,
4682,
288,
1007,
498,
275,
30748,
14,
5081,
1197,
8,
3903,
498,
12,
284,
9,
288,
1007,
275,
30748,
14,
28144,
8,
3903,
498,
12,
1007,
498,
9,
288,
666,
275,
574,
14308,
807,
8,
954,
9,
288,
1007,
14,
4724,
342,
288,
340,
666,
459,
11976,
418,
508,
5823,
2676,
26,
355,
5823,
30499,
275,
1007,
498,
355,
2059,
398,
5823,
498,
14,
4724,
342,
267,
2429,
14,
4724,
342,
339,
340,
5823,
30499,
365,
488,
26,
267,
746,
19021,
360,
6049,
440,
2342,
5417,
7137,
2897,
358,
339,
7137,
275,
5823,
63,
1247,
14,
362,
8,
3903,
30499,
9,
272,
340,
7137,
365,
488,
26,
267,
327,
3091,
321,
12,
626,
9980,
1133,
1736,
14,
7649,
7791,
283,
9232,
4703,
297,
267,
327,
652,
12237,
370,
1736,
282,
13918,
402,
5431,
26,
267,
7137,
275,
5823,
63,
1247,
14,
362,
8,
3903,
30499,
435,
283,
9739,
4703,
358,
339,
327,
1432,
4052,
781,
1172,
14,
272,
340,
7137,
365,
488,
26,
267,
746,
15444,
14,
5912,
32515,
547,
360,
6049,
440,
2342,
7137,
283,
435,
5823,
30499,
9,
339,
372,
7137,
421,
199,
318,
485,
362,
63,
1832,
2619,
837,
272,
340,
30748,
365,
488,
26,
267,
746,
15444,
14,
5912,
32515,
547,
8,
288,
283,
14357,
2291,
440,
2808,
358,
272,
372,
15444,
14,
7145,
8,
362,
63,
1832,
2619,
63,
354,
1012,
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,
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,
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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
] |
mollstam/UnrealPy
|
UnrealPyEmbed/Development/Python/2015.08.07-Python2710-x64-Source-vs2015/Python27/Source/MarkupSafe-0.23/markupsafe/tests.py
|
674
|
6107
|
# -*- coding: utf-8 -*-
import gc
import sys
import unittest
from markupsafe import Markup, escape, escape_silent
from markupsafe._compat import text_type
class MarkupTestCase(unittest.TestCase):
def test_adding(self):
# adding two strings should escape the unsafe one
unsafe = '<script type="application/x-some-script">alert("foo");</script>'
safe = Markup('<em>username</em>')
assert unsafe + safe == text_type(escape(unsafe)) + text_type(safe)
def test_string_interpolation(self):
# string interpolations are safe to use too
assert Markup('<em>%s</em>') % '<bad user>' == \
'<em><bad user></em>'
assert Markup('<em>%(username)s</em>') % {
'username': '<bad user>'
} == '<em><bad user></em>'
assert Markup('%i') % 3.14 == '3'
assert Markup('%.2f') % 3.14 == '3.14'
def test_type_behavior(self):
# an escaped object is markup too
assert type(Markup('foo') + 'bar') is Markup
# and it implements __html__ by returning itself
x = Markup("foo")
assert x.__html__() is x
def test_html_interop(self):
# it also knows how to treat __html__ objects
class Foo(object):
def __html__(self):
return '<em>awesome</em>'
def __unicode__(self):
return 'awesome'
__str__ = __unicode__
assert Markup(Foo()) == '<em>awesome</em>'
assert Markup('<strong>%s</strong>') % Foo() == \
'<strong><em>awesome</em></strong>'
def test_tuple_interpol(self):
self.assertEqual(Markup('<em>%s:%s</em>') % (
'<foo>',
'<bar>',
), Markup(u'<em><foo>:<bar></em>'))
def test_dict_interpol(self):
self.assertEqual(Markup('<em>%(foo)s</em>') % {
'foo': '<foo>',
}, Markup(u'<em><foo></em>'))
self.assertEqual(Markup('<em>%(foo)s:%(bar)s</em>') % {
'foo': '<foo>',
'bar': '<bar>',
}, Markup(u'<em><foo>:<bar></em>'))
def test_escaping(self):
# escaping and unescaping
assert escape('"<>&\'') == '"<>&''
assert Markup("<em>Foo & Bar</em>").striptags() == "Foo & Bar"
assert Markup("<test>").unescape() == "<test>"
def test_formatting(self):
for actual, expected in (
(Markup('%i') % 3.14, '3'),
(Markup('%.2f') % 3.14159, '3.14'),
(Markup('%s %s %s') % ('<', 123, '>'), '< 123 >'),
(Markup('<em>{awesome}</em>').format(awesome='<awesome>'),
'<em><awesome></em>'),
(Markup('{0[1][bar]}').format([0, {'bar': '<bar/>'}]),
'<bar/>'),
(Markup('{0[1][bar]}').format([0, {'bar': Markup('<bar/>')}]),
'<bar/>')):
assert actual == expected, "%r should be %r!" % (actual, expected)
# This is new in 2.7
if sys.version_info >= (2, 7):
def test_formatting_empty(self):
formatted = Markup('{}').format(0)
assert formatted == Markup('0')
def test_custom_formatting(self):
class HasHTMLOnly(object):
def __html__(self):
return Markup('<foo>')
class HasHTMLAndFormat(object):
def __html__(self):
return Markup('<foo>')
def __html_format__(self, spec):
return Markup('<FORMAT>')
assert Markup('{0}').format(HasHTMLOnly()) == Markup('<foo>')
assert Markup('{0}').format(HasHTMLAndFormat()) == Markup('<FORMAT>')
def test_complex_custom_formatting(self):
class User(object):
def __init__(self, id, username):
self.id = id
self.username = username
def __html_format__(self, format_spec):
if format_spec == 'link':
return Markup('<a href="/user/{0}">{1}</a>').format(
self.id,
self.__html__(),
)
elif format_spec:
raise ValueError('Invalid format spec')
return self.__html__()
def __html__(self):
return Markup('<span class=user>{0}</span>').format(self.username)
user = User(1, 'foo')
assert Markup('<p>User: {0:link}').format(user) == \
Markup('<p>User: <a href="/user/1"><span class=user>foo</span></a>')
def test_all_set(self):
import markupsafe as markup
for item in markup.__all__:
getattr(markup, item)
def test_escape_silent(self):
assert escape_silent(None) == Markup()
assert escape(None) == Markup(None)
assert escape_silent('<foo>') == Markup(u'<foo>')
def test_splitting(self):
self.assertEqual(Markup('a b').split(), [
Markup('a'),
Markup('b')
])
self.assertEqual(Markup('a b').rsplit(), [
Markup('a'),
Markup('b')
])
self.assertEqual(Markup('a\nb').splitlines(), [
Markup('a'),
Markup('b')
])
def test_mul(self):
self.assertEqual(Markup('a') * 3, Markup('aaa'))
class MarkupLeakTestCase(unittest.TestCase):
def test_markup_leaks(self):
counts = set()
for count in range(20):
for item in range(1000):
escape("foo")
escape("<foo>")
escape(u"foo")
escape(u"<foo>")
counts.add(len(gc.get_objects()))
assert len(counts) == 1, 'ouch, c extension seems to leak objects'
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MarkupTestCase))
# this test only tests the c extension
if not hasattr(escape, 'func_code'):
suite.addTest(unittest.makeSuite(MarkupLeakTestCase))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')
# vim:sts=4:sw=4:et:
|
mit
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
9486,
199,
646,
984,
199,
646,
2882,
199,
504,
9189,
3489,
492,
17504,
12,
4772,
12,
4772,
63,
14434,
199,
504,
9189,
3489,
423,
5819,
492,
1318,
63,
466,
421,
199,
533,
17504,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
4095,
8,
277,
304,
267,
327,
7791,
2877,
3326,
1077,
4772,
314,
19293,
1373,
267,
19293,
275,
2650,
1579,
730,
628,
3578,
15,
88,
13,
3972,
13,
1579,
1743,
9241,
480,
1421,
3547,
1108,
1579,
3524,
267,
5048,
275,
17504,
4827,
5633,
30,
2473,
1108,
5633,
5971,
267,
702,
19293,
435,
5048,
508,
1318,
63,
466,
8,
3765,
8,
14242,
430,
435,
1318,
63,
466,
8,
3489,
9,
339,
347,
511,
63,
875,
63,
21080,
8,
277,
304,
267,
327,
1059,
23005,
1298,
787,
5048,
370,
675,
4634,
267,
702,
17504,
4827,
5633,
6598,
83,
1108,
5633,
5971,
450,
2650,
4087,
922,
3524,
508,
971,
2049,
2650,
5633,
18181,
4116,
27,
4087,
922,
6,
3308,
12279,
5633,
3524,
267,
702,
17504,
4827,
5633,
19418,
2473,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
2473,
356,
2650,
4087,
922,
3524,
267,
789,
508,
2650,
5633,
18181,
4116,
27,
4087,
922,
6,
3308,
12279,
5633,
3524,
398,
702,
17504,
3508,
73,
358,
450,
650,
14,
1079,
508,
283,
19,
7,
267,
702,
17504,
3508,
14,
18,
70,
358,
450,
650,
14,
1079,
508,
283,
19,
14,
1079,
7,
339,
347,
511,
63,
466,
63,
17537,
8,
277,
304,
267,
327,
376,
11077,
909,
365,
9189,
4634,
267,
702,
730,
8,
23393,
360,
1421,
358,
435,
283,
1700,
358,
365,
17504,
398,
327,
436,
652,
9031,
636,
1360,
363,
701,
8152,
6337,
267,
671,
275,
17504,
480,
1421,
531,
267,
702,
671,
855,
1360,
4533,
365,
671,
339,
347,
511,
63,
1360,
63,
5707,
2675,
8,
277,
304,
267,
327,
652,
2597,
19428,
4212,
370,
14312,
636,
1360,
363,
2251,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
2650,
5633,
30,
10084,
22666,
1108,
5633,
3524,
288,
347,
636,
2975,
721,
277,
304,
355,
372,
283,
10084,
22666,
7,
288,
636,
495,
363,
275,
636,
2975,
363,
267,
702,
17504,
8,
5686,
1012,
508,
2650,
5633,
30,
10084,
22666,
1108,
5633,
3524,
267,
702,
17504,
4827,
9370,
6598,
83,
1108,
9370,
5971,
450,
8024,
342,
508,
971,
288,
2650,
9370,
2535,
5633,
30,
10084,
22666,
1108,
5633,
2957,
9370,
3524,
339,
347,
511,
63,
2960,
63,
29690,
8,
277,
304,
267,
291,
14,
629,
8,
23393,
4827,
5633,
6598,
83,
2689,
83,
1108,
5633,
5971,
450,
334,
288,
2650,
1421,
4206,
288,
2650,
1700,
4206,
267,
2318,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
27,
26,
6,
4116,
27,
1700,
6,
3308,
12279,
5633,
30,
1333,
339,
347,
511,
63,
807,
63,
29690,
8,
277,
304,
267,
291,
14,
629,
8,
23393,
4827,
5633,
19418,
1421,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
1421,
356,
2650,
1421,
4206,
267,
1660,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
12279,
5633,
30,
1333,
267,
291,
14,
629,
8,
23393,
4827,
5633,
19418,
1421,
9,
83,
19648,
1700,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
1421,
356,
2650,
1421,
4206,
288,
283,
1700,
356,
2650,
1700,
4206,
267,
1660,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
27,
26,
6,
4116,
27,
1700,
6,
3308,
12279,
5633,
30,
1333,
339,
347,
511,
63,
26306,
8,
277,
304,
267,
327,
21375,
436,
625,
26306,
267,
702,
4772,
14088,
16137,
6,
3985,
358,
508,
7673,
3,
1082,
15337,
4116,
15337,
3308,
15337,
5282,
14328,
1355,
8942,
267,
702,
17504,
6757,
5633,
30,
5686,
1253,
5282,
27,
12377,
1108,
5633,
30,
3471,
1913,
2969,
342,
508,
298,
5686,
1253,
12377,
2,
267,
702,
17504,
22077,
4116,
27,
396,
6,
3308,
27,
3471,
22726,
342,
508,
3886,
396,
4335,
339,
347,
511,
63,
20034,
8,
277,
304,
267,
367,
3503,
12,
1420,
315,
334,
288,
334,
23393,
3508,
73,
358,
450,
650,
14,
1079,
12,
283,
19,
659,
288,
334,
23393,
3508,
14,
18,
70,
358,
450,
650,
14,
1079,
9327,
12,
283,
19,
14,
1079,
659,
288,
334,
23393,
3508,
83,
450,
83,
450,
83,
358,
450,
19990,
297,
11869,
12,
12696,
659,
7673,
4116,
27,
11869,
1253,
3308,
27,
659,
288,
334,
23393,
4827,
5633,
22266,
10084,
22666,
17890,
5633,
30,
1959,
908,
8,
10084,
22666,
15829,
10084,
22666,
25642,
1467,
2650,
5633,
18181,
4116,
27,
10084,
22666,
6,
3308,
12279,
5633,
25642,
288,
334,
23393,
11117,
16,
59,
17,
1527,
1700,
9420,
1959,
908,
779,
16,
12,
791,
1700,
356,
2650,
1700,
3133,
936,
2522,
1467,
7673,
4116,
27,
1700,
15,
6,
3308,
27,
659,
288,
334,
23393,
11117,
16,
59,
17,
1527,
1700,
9420,
1959,
908,
779,
16,
12,
791,
1700,
356,
17504,
4827,
1700,
3133,
21004,
2522,
1467,
2650,
1700,
3133,
8109,
288,
702,
3503,
508,
1420,
12,
2071,
82,
1077,
506,
450,
82,
9539,
450,
334,
6514,
12,
1420,
9,
339,
327,
961,
365,
892,
315,
499,
14,
23,
272,
340,
984,
14,
1023,
63,
815,
2356,
334,
18,
12,
1520,
304,
267,
347,
511,
63,
20034,
63,
1667,
8,
277,
304,
288,
7871,
275,
17504,
17519,
1959,
908,
8,
16,
9,
288,
702,
7871,
508,
17504,
360,
16,
358,
339,
347,
511,
63,
4229,
63,
20034,
8,
277,
304,
267,
1021,
13481,
2148,
45,
1484,
78,
590,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
17504,
4827,
1421,
5971,
398,
1021,
13481,
4943,
3325,
3484,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
17504,
4827,
1421,
5971,
288,
347,
636,
1360,
63,
908,
721,
277,
12,
3158,
304,
355,
372,
17504,
4827,
4807,
5971,
398,
702,
17504,
11117,
16,
93,
1959,
908,
8,
6362,
2148,
45,
1484,
78,
590,
1012,
508,
17504,
4827,
1421,
5971,
267,
702,
17504,
11117,
16,
93,
1959,
908,
8,
6362,
4943,
3325,
3484,
1012,
508,
17504,
4827,
4807,
5971,
339,
347,
511,
63,
5254,
63,
4229,
63,
20034,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
646,
9486,
199,
646,
984,
199,
646,
2882,
199,
504,
9189,
3489,
492,
17504,
12,
4772,
12,
4772,
63,
14434,
199,
504,
9189,
3489,
423,
5819,
492,
1318,
63,
466,
421,
199,
533,
17504,
1746,
8,
2796,
14,
1746,
304,
339,
347,
511,
63,
4095,
8,
277,
304,
267,
327,
7791,
2877,
3326,
1077,
4772,
314,
19293,
1373,
267,
19293,
275,
2650,
1579,
730,
628,
3578,
15,
88,
13,
3972,
13,
1579,
1743,
9241,
480,
1421,
3547,
1108,
1579,
3524,
267,
5048,
275,
17504,
4827,
5633,
30,
2473,
1108,
5633,
5971,
267,
702,
19293,
435,
5048,
508,
1318,
63,
466,
8,
3765,
8,
14242,
430,
435,
1318,
63,
466,
8,
3489,
9,
339,
347,
511,
63,
875,
63,
21080,
8,
277,
304,
267,
327,
1059,
23005,
1298,
787,
5048,
370,
675,
4634,
267,
702,
17504,
4827,
5633,
6598,
83,
1108,
5633,
5971,
450,
2650,
4087,
922,
3524,
508,
971,
2049,
2650,
5633,
18181,
4116,
27,
4087,
922,
6,
3308,
12279,
5633,
3524,
267,
702,
17504,
4827,
5633,
19418,
2473,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
2473,
356,
2650,
4087,
922,
3524,
267,
789,
508,
2650,
5633,
18181,
4116,
27,
4087,
922,
6,
3308,
12279,
5633,
3524,
398,
702,
17504,
3508,
73,
358,
450,
650,
14,
1079,
508,
283,
19,
7,
267,
702,
17504,
3508,
14,
18,
70,
358,
450,
650,
14,
1079,
508,
283,
19,
14,
1079,
7,
339,
347,
511,
63,
466,
63,
17537,
8,
277,
304,
267,
327,
376,
11077,
909,
365,
9189,
4634,
267,
702,
730,
8,
23393,
360,
1421,
358,
435,
283,
1700,
358,
365,
17504,
398,
327,
436,
652,
9031,
636,
1360,
363,
701,
8152,
6337,
267,
671,
275,
17504,
480,
1421,
531,
267,
702,
671,
855,
1360,
4533,
365,
671,
339,
347,
511,
63,
1360,
63,
5707,
2675,
8,
277,
304,
267,
327,
652,
2597,
19428,
4212,
370,
14312,
636,
1360,
363,
2251,
267,
1021,
8024,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
2650,
5633,
30,
10084,
22666,
1108,
5633,
3524,
288,
347,
636,
2975,
721,
277,
304,
355,
372,
283,
10084,
22666,
7,
288,
636,
495,
363,
275,
636,
2975,
363,
267,
702,
17504,
8,
5686,
1012,
508,
2650,
5633,
30,
10084,
22666,
1108,
5633,
3524,
267,
702,
17504,
4827,
9370,
6598,
83,
1108,
9370,
5971,
450,
8024,
342,
508,
971,
288,
2650,
9370,
2535,
5633,
30,
10084,
22666,
1108,
5633,
2957,
9370,
3524,
339,
347,
511,
63,
2960,
63,
29690,
8,
277,
304,
267,
291,
14,
629,
8,
23393,
4827,
5633,
6598,
83,
2689,
83,
1108,
5633,
5971,
450,
334,
288,
2650,
1421,
4206,
288,
2650,
1700,
4206,
267,
2318,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
27,
26,
6,
4116,
27,
1700,
6,
3308,
12279,
5633,
30,
1333,
339,
347,
511,
63,
807,
63,
29690,
8,
277,
304,
267,
291,
14,
629,
8,
23393,
4827,
5633,
19418,
1421,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
1421,
356,
2650,
1421,
4206,
267,
1660,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
12279,
5633,
30,
1333,
267,
291,
14,
629,
8,
23393,
4827,
5633,
19418,
1421,
9,
83,
19648,
1700,
9,
83,
1108,
5633,
5971,
450,
469,
288,
283,
1421,
356,
2650,
1421,
4206,
288,
283,
1700,
356,
2650,
1700,
4206,
267,
1660,
17504,
8,
85,
7601,
5633,
18181,
4116,
27,
1421,
6,
3308,
27,
26,
6,
4116,
27,
1700,
6,
3308,
12279,
5633,
30,
1333,
339,
347,
511,
63,
26306,
8,
277,
304,
267,
327,
21375,
436,
625,
26306,
267,
702,
4772,
14088,
16137,
6,
3985,
358,
508,
7673,
3,
1082,
15337,
4116,
15337,
3308,
15337,
5282,
14328,
1355,
8942,
267,
702,
17504,
6757,
5633,
30,
5686,
1253,
5282,
27,
12377,
1108,
5633,
30,
3471,
1913,
2969,
342,
508,
298,
5686,
1253,
12377,
2,
267,
702,
17504,
22077,
4116,
27,
396,
6,
3308,
27,
3471,
22726,
342,
508,
3886,
396,
4335,
339,
347,
511,
63,
20034,
8,
277,
304,
267,
367,
3503,
12,
1420,
315,
334,
288,
334,
23393,
3508,
73,
358,
450,
650,
14,
1079,
12,
283,
19,
659,
288,
334,
23393,
3508,
14,
18,
70,
358,
450,
650,
14,
1079,
9327,
12,
283,
19,
14,
1079,
659,
288,
334,
23393,
3508,
83,
450,
83,
450,
83,
358,
450,
19990,
297,
11869,
12,
12696,
659,
7673,
4116,
27,
11869,
1253,
3308,
27,
659,
288,
334,
23393,
4827,
5633,
22266,
10084,
22666,
17890,
5633,
30,
1959,
908,
8,
10084,
22666,
15829,
10084,
22666,
25642,
1467,
2650,
5633,
18181,
4116,
27,
10084,
22666,
6,
3308,
12279,
5633,
25642,
288,
334,
23393,
11117,
16,
59,
17,
1527,
1700,
9420,
1959,
908,
779,
16,
12,
791,
1700,
356,
2650,
1700,
3133,
936,
2522,
1467,
7673,
4116,
27,
1700,
15,
6,
3308,
27,
659,
288,
334,
23393,
11117,
16,
59,
17,
1527,
1700,
9420,
1959,
908,
779,
16,
12,
791,
1700,
356,
17504,
4827,
1700,
3133,
21004,
2522,
1467,
2650,
1700,
3133,
8109,
288,
702,
3503,
508,
1420,
12,
2071,
82,
1077,
506,
450,
82,
9539,
450,
334,
6514,
12,
1420,
9,
339,
327,
961,
365,
892,
315,
499,
14,
23,
272,
340,
984,
14,
1023,
63,
815,
2356,
334,
18,
12,
1520,
304,
267,
347,
511,
63,
20034,
63,
1667,
8,
277,
304,
288,
7871,
275,
17504,
17519,
1959,
908,
8,
16,
9,
288,
702,
7871,
508,
17504,
360,
16,
358,
339,
347,
511,
63,
4229,
63,
20034,
8,
277,
304,
267,
1021,
13481,
2148,
45,
1484,
78,
590,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
17504,
4827,
1421,
5971,
398,
1021,
13481,
4943,
3325,
3484,
8,
785,
304,
288,
347,
636,
1360,
721,
277,
304,
355,
372,
17504,
4827,
1421,
5971,
288,
347,
636,
1360,
63,
908,
721,
277,
12,
3158,
304,
355,
372,
17504,
4827,
4807,
5971,
398,
702,
17504,
11117,
16,
93,
1959,
908,
8,
6362,
2148,
45,
1484,
78,
590,
1012,
508,
17504,
4827,
1421,
5971,
267,
702,
17504,
11117,
16,
93,
1959,
908,
8,
6362,
4943,
3325,
3484,
1012,
508,
17504,
4827,
4807,
5971,
339,
347,
511,
63,
5254,
63,
4229,
63,
20034,
8,
277,
304,
267,
1021,
2876,
8,
785,
304,
288,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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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
] |
chaowyc/youtube-dl
|
youtube_dl/extractor/pladform.py
|
103
|
3156
|
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
xpath_text,
qualities,
)
class PladformIE(InfoExtractor):
_VALID_URL = r'''(?x)
https?://
(?:
(?:
out\.pladform\.ru/player|
static\.pladform\.ru/player\.swf
)
\?.*\bvideoid=|
video\.pladform\.ru/catalog/video/videoid/
)
(?P<id>\d+)
'''
_TESTS = [{
# http://muz-tv.ru/kinozal/view/7400/
'url': 'http://out.pladform.ru/player?pl=24822&videoid=100183293',
'md5': '61f37b575dd27f1bb2e1854777fe31f4',
'info_dict': {
'id': '100183293',
'ext': 'mp4',
'title': 'Тайны перевала Дятлова • 1 серия 2 часть',
'description': 'Документальный сериал-расследование одной из самых жутких тайн ХХ века',
'thumbnail': 're:^https?://.*\.jpg$',
'duration': 694,
'age_limit': 0,
},
}, {
'url': 'http://static.pladform.ru/player.swf?pl=21469&videoid=100183293&vkcid=0',
'only_matching': True,
}, {
'url': 'http://video.pladform.ru/catalog/video/videoid/100183293/vkcid/0',
'only_matching': True,
}]
def _real_extract(self, url):
video_id = self._match_id(url)
video = self._download_xml(
'http://out.pladform.ru/getVideo?pl=1&videoid=%s' % video_id,
video_id)
if video.tag == 'error':
raise ExtractorError(
'%s returned error: %s' % (self.IE_NAME, video.text),
expected=True)
quality = qualities(('ld', 'sd', 'hd'))
formats = [{
'url': src.text,
'format_id': src.get('quality'),
'quality': quality(src.get('quality')),
} for src in video.findall('./src')]
self._sort_formats(formats)
webpage = self._download_webpage(
'http://video.pladform.ru/catalog/video/videoid/%s' % video_id,
video_id)
title = self._og_search_title(webpage, fatal=False) or xpath_text(
video, './/title', 'title', fatal=True)
description = self._search_regex(
r'</h3>\s*<p>([^<]+)</p>', webpage, 'description', fatal=False)
thumbnail = self._og_search_thumbnail(webpage) or xpath_text(
video, './/cover', 'cover')
duration = int_or_none(xpath_text(video, './/time', 'duration'))
age_limit = int_or_none(xpath_text(video, './/age18', 'age limit'))
return {
'id': video_id,
'title': title,
'description': description,
'thumbnail': thumbnail,
'duration': duration,
'age_limit': age_limit,
'formats': formats,
}
|
unlicense
|
[
3,
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
1208,
492,
334,
272,
19783,
12,
272,
1109,
63,
269,
63,
3592,
12,
272,
14462,
63,
505,
12,
272,
6420,
12107,
12,
199,
9,
421,
199,
533,
7497,
350,
964,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
2344,
2229,
88,
9,
490,
4178,
14144,
717,
16697,
1169,
16697,
1816,
734,
4537,
1168,
350,
964,
4537,
6558,
15,
6147,
92,
1816,
2955,
4537,
1168,
350,
964,
4537,
6558,
15,
6147,
4537,
20426,
1169,
776,
1169,
971,
31,
17910,
66,
5624,
1170,
26777,
1169,
3991,
4537,
1168,
350,
964,
4537,
6558,
15,
7959,
15,
3722,
15,
5624,
1170,
15,
717,
776,
717,
7558,
48,
28,
344,
3072,
68,
8771,
490,
1449,
272,
485,
7569,
275,
8910,
267,
327,
1455,
921,
6553,
90,
13,
6993,
14,
6558,
15,
75,
10175,
90,
279,
15,
1345,
15,
1342,
383,
15,
267,
283,
633,
356,
283,
1014,
921,
548,
14,
1168,
350,
964,
14,
6558,
15,
6147,
31,
1168,
29,
1194,
10228,
6,
5624,
1170,
29,
1960,
1085,
708,
3129,
297,
267,
283,
1064,
21,
356,
283,
2976,
70,
1401,
66,
14781,
617,
1465,
70,
17,
2501,
18,
69,
1085,
1477,
11956,
771,
2192,
70,
20,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
1960,
1085,
708,
3129,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
141,
96,
13111,
118,
7592,
17445,
19820,
21273,
15578,
111,
30638,
5657,
7038,
243,
14978,
7413,
10356,
21267,
5657,
27430,
96,
413,
24071,
21273,
6500,
14978,
499,
221,
19277,
5657,
18261,
16961,
297,
288,
283,
1802,
356,
283,
141,
243,
8381,
119,
12195,
23000,
18624,
7413,
30638,
16961,
7592,
17445,
141,
118,
24071,
21273,
6500,
30638,
13,
7753,
5657,
8474,
8474,
10356,
15578,
113,
21267,
21674,
6500,
6286,
221,
28711,
7592,
8381,
118,
221,
16863,
116,
24071,
13111,
121,
17445,
25969,
7038,
115,
12195,
7413,
11487,
6500,
25969,
221,
7413,
13111,
118,
7592,
7038,
99,
141,
99,
22213,
6286,
29352,
297,
288,
283,
8311,
356,
283,
264,
23497,
2859,
32569,
8476,
4268,
288,
283,
5553,
356,
1227,
2635,
12,
288,
283,
474,
63,
3097,
356,
378,
12,
267,
1660,
272,
1660,
469,
267,
283,
633,
356,
283,
1014,
921,
1986,
14,
1168,
350,
964,
14,
6558,
15,
6147,
14,
20426,
31,
1168,
29,
6886,
1876,
6,
5624,
1170,
29,
1960,
1085,
708,
3129,
6,
21405,
7504,
29,
16,
297,
267,
283,
2118,
63,
9467,
356,
715,
12,
272,
1660,
469,
267,
283,
633,
356,
283,
1014,
921,
3722,
14,
1168,
350,
964,
14,
6558,
15,
7959,
15,
3722,
15,
5624,
1170,
15,
1960,
1085,
708,
3129,
15,
21405,
7504,
15,
16,
297,
267,
283,
2118,
63,
9467,
356,
715,
12,
272,
14877,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
3991,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
398,
3991,
275,
291,
423,
4249,
63,
1652,
8,
288,
283,
1014,
921,
548,
14,
1168,
350,
964,
14,
6558,
15,
362,
9166,
31,
1168,
29,
17,
6,
5624,
1170,
2458,
83,
7,
450,
3991,
63,
344,
12,
288,
3991,
63,
344,
9,
398,
340,
3991,
14,
1450,
508,
283,
705,
356,
288,
746,
19783,
8,
355,
1543,
83,
2138,
1125,
26,
450,
83,
7,
450,
334,
277,
14,
4332,
63,
2339,
12,
3991,
14,
505,
395,
355,
1420,
29,
549,
9,
398,
11030,
275,
6420,
12107,
4725,
1447,
297,
283,
3893,
297,
283,
7952,
1333,
398,
6752,
275,
8910,
288,
283,
633,
356,
2928,
14,
505,
12,
288,
283,
908,
63,
344,
356,
2928,
14,
362,
360,
9161,
659,
288,
283,
9161,
356,
11030,
8,
2164,
14,
362,
360,
9161,
3855,
267,
789,
367,
2928,
315,
3991,
14,
6452,
17371,
2164,
5440,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
9248,
275,
291,
423,
4249,
63,
12022,
8,
288,
283,
1014,
921,
3722,
14,
1168,
350,
964,
14,
6558,
15,
7959,
15,
3722,
15,
5624,
1170,
3149,
83,
7,
450,
3991,
63,
344,
12,
288,
3991,
63,
344,
9,
398,
2538,
275,
291,
423,
974,
63,
1733,
63,
1213,
8,
12022,
12,
14294,
29,
797,
9,
503,
14462,
63,
505,
8,
288,
3991,
12,
1987,
501,
1213,
297,
283,
1213,
297,
14294,
29,
549,
9,
267,
1369,
275,
291,
423,
1733,
63,
3821,
8,
288,
519,
29477,
72,
19,
3072,
83,
10,
28,
80,
30,
31204,
11896,
1108,
80,
4206,
9248,
12,
283,
1802,
297,
14294,
29,
797,
9,
267,
10062,
275,
291,
423,
974,
63,
1733,
63,
8311,
8,
12022,
9,
503,
14462,
63,
505,
8,
288,
3991,
12,
1987,
501,
5899,
297,
283,
5899,
358,
398,
7373,
275,
1109,
63,
269,
63,
3592,
8,
8006,
63,
505,
8,
3722,
12,
1987,
501,
521,
297,
283,
5553,
1333,
267,
11437,
63,
3097,
275,
1109,
63,
269,
63,
3592,
8,
8006,
63,
505,
8,
3722,
12,
1987,
501,
474,
1085,
297,
283,
474,
2304,
1333,
398,
372,
469,
288,
283,
344,
356,
3991,
63,
344,
12,
288,
283,
1213,
356,
2538,
12,
288,
283,
1802,
356,
1369,
12,
288,
283,
8311,
356,
10062,
12,
288,
283,
5553,
356,
7373,
12,
288,
283,
474,
63,
3097,
356,
11437,
63,
3097,
12,
288,
283,
6321,
356,
6752,
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
] |
[
2803,
26,
2774,
13,
24,
199,
504,
636,
2443,
363,
492,
2649,
63,
5955,
199,
199,
504,
1275,
2330,
492,
21298,
199,
504,
2508,
1208,
492,
334,
272,
19783,
12,
272,
1109,
63,
269,
63,
3592,
12,
272,
14462,
63,
505,
12,
272,
6420,
12107,
12,
199,
9,
421,
199,
533,
7497,
350,
964,
4332,
8,
18283,
304,
272,
485,
5600,
63,
2632,
275,
519,
2344,
2229,
88,
9,
490,
4178,
14144,
717,
16697,
1169,
16697,
1816,
734,
4537,
1168,
350,
964,
4537,
6558,
15,
6147,
92,
1816,
2955,
4537,
1168,
350,
964,
4537,
6558,
15,
6147,
4537,
20426,
1169,
776,
1169,
971,
31,
17910,
66,
5624,
1170,
26777,
1169,
3991,
4537,
1168,
350,
964,
4537,
6558,
15,
7959,
15,
3722,
15,
5624,
1170,
15,
717,
776,
717,
7558,
48,
28,
344,
3072,
68,
8771,
490,
1449,
272,
485,
7569,
275,
8910,
267,
327,
1455,
921,
6553,
90,
13,
6993,
14,
6558,
15,
75,
10175,
90,
279,
15,
1345,
15,
1342,
383,
15,
267,
283,
633,
356,
283,
1014,
921,
548,
14,
1168,
350,
964,
14,
6558,
15,
6147,
31,
1168,
29,
1194,
10228,
6,
5624,
1170,
29,
1960,
1085,
708,
3129,
297,
267,
283,
1064,
21,
356,
283,
2976,
70,
1401,
66,
14781,
617,
1465,
70,
17,
2501,
18,
69,
1085,
1477,
11956,
771,
2192,
70,
20,
297,
267,
283,
815,
63,
807,
356,
469,
288,
283,
344,
356,
283,
1960,
1085,
708,
3129,
297,
288,
283,
832,
356,
283,
311,
20,
297,
288,
283,
1213,
356,
283,
141,
96,
13111,
118,
7592,
17445,
19820,
21273,
15578,
111,
30638,
5657,
7038,
243,
14978,
7413,
10356,
21267,
5657,
27430,
96,
413,
24071,
21273,
6500,
14978,
499,
221,
19277,
5657,
18261,
16961,
297,
288,
283,
1802,
356,
283,
141,
243,
8381,
119,
12195,
23000,
18624,
7413,
30638,
16961,
7592,
17445,
141,
118,
24071,
21273,
6500,
30638,
13,
7753,
5657,
8474,
8474,
10356,
15578,
113,
21267,
21674,
6500,
6286,
221,
28711,
7592,
8381,
118,
221,
16863,
116,
24071,
13111,
121,
17445,
25969,
7038,
115,
12195,
7413,
11487,
6500,
25969,
221,
7413,
13111,
118,
7592,
7038,
99,
141,
99,
22213,
6286,
29352,
297,
288,
283,
8311,
356,
283,
264,
23497,
2859,
32569,
8476,
4268,
288,
283,
5553,
356,
1227,
2635,
12,
288,
283,
474,
63,
3097,
356,
378,
12,
267,
1660,
272,
1660,
469,
267,
283,
633,
356,
283,
1014,
921,
1986,
14,
1168,
350,
964,
14,
6558,
15,
6147,
14,
20426,
31,
1168,
29,
6886,
1876,
6,
5624,
1170,
29,
1960,
1085,
708,
3129,
6,
21405,
7504,
29,
16,
297,
267,
283,
2118,
63,
9467,
356,
715,
12,
272,
1660,
469,
267,
283,
633,
356,
283,
1014,
921,
3722,
14,
1168,
350,
964,
14,
6558,
15,
7959,
15,
3722,
15,
5624,
1170,
15,
1960,
1085,
708,
3129,
15,
21405,
7504,
15,
16,
297,
267,
283,
2118,
63,
9467,
356,
715,
12,
272,
14877,
339,
347,
485,
3093,
63,
5005,
8,
277,
12,
1166,
304,
267,
3991,
63,
344,
275,
291,
423,
1431,
63,
344,
8,
633,
9,
398,
3991,
275,
291,
423,
4249,
63,
1652,
8,
288,
283,
1014,
921,
548,
14,
1168,
350,
964,
14,
6558,
15,
362,
9166,
31,
1168,
29,
17,
6,
5624,
1170,
2458,
83,
7,
450,
3991,
63,
344,
12,
288,
3991,
63,
344,
9,
398,
340,
3991,
14,
1450,
508,
283,
705,
356,
288,
746,
19783,
8,
355,
1543,
83,
2138,
1125,
26,
450,
83,
7,
450,
334,
277,
14,
4332,
63,
2339,
12,
3991,
14,
505,
395,
355,
1420,
29,
549,
9,
398,
11030,
275,
6420,
12107,
4725,
1447,
297,
283,
3893,
297,
283,
7952,
1333,
398,
6752,
275,
8910,
288,
283,
633,
356,
2928,
14,
505,
12,
288,
283,
908,
63,
344,
356,
2928,
14,
362,
360,
9161,
659,
288,
283,
9161,
356,
11030,
8,
2164,
14,
362,
360,
9161,
3855,
267,
789,
367,
2928,
315,
3991,
14,
6452,
17371,
2164,
5440,
267,
291,
423,
3191,
63,
6321,
8,
6321,
9,
398,
9248,
275,
291,
423,
4249,
63,
12022,
8,
288,
283,
1014,
921,
3722,
14,
1168,
350,
964,
14,
6558,
15,
7959,
15,
3722,
15,
5624,
1170,
3149,
83,
7,
450,
3991,
63,
344,
12,
288,
3991,
63,
344,
9,
398,
2538,
275,
291,
423,
974,
63,
1733,
63,
1213,
8,
12022,
12,
14294,
29,
797,
9,
503,
14462,
63,
505,
8,
288,
3991,
12,
1987,
501,
1213,
297,
283,
1213,
297,
14294,
29,
549,
9,
267,
1369,
275,
291,
423,
1733,
63,
3821,
8,
288,
519,
29477,
72,
19,
3072,
83,
10,
28,
80,
30,
31204,
11896,
1108,
80,
4206,
9248,
12,
283,
1802,
297,
14294,
29,
797,
9,
267,
10062,
275,
291,
423,
974,
63,
1733,
63,
8311,
8,
12022,
9,
503,
14462,
63,
505,
8,
288,
3991,
12,
1987,
501,
5899,
297,
283,
5899,
358,
398,
7373,
275,
1109,
63,
269,
63,
3592,
8,
8006,
63,
505,
8,
3722,
12,
1987,
501,
521,
297,
283,
5553,
1333,
267,
11437,
63,
3097,
275,
1109,
63,
269,
63,
3592,
8,
8006,
63,
505,
8,
3722,
12,
1987,
501,
474,
1085,
297,
283,
474,
2304,
1333,
398,
372,
469,
288,
283,
344,
356,
3991,
63,
344,
12,
288,
283,
1213,
356,
2538,
12,
288,
283,
1802,
356,
1369,
12,
288,
283,
8311,
356,
10062,
12,
288,
283,
5553,
356,
7373,
12,
288,
283,
474,
63,
3097,
356,
11437,
63,
3097,
12,
288,
283,
6321,
356,
6752,
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,
0
] |
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] |
ceelian/Flatty
|
setup.py
|
1
|
1423
|
from setuptools import setup, find_packages
from distutils.cmd import Command
import codecs
import sys, os
import doctest
from glob import glob
sys.path.insert(0,'src/')
init_pyc = 'src/flatty/__init__.pyc'
if os.path.exists(init_pyc):
os.remove(init_pyc)
import flatty
if os.path.exists("doc/source/introduction.rst"):
long_description = codecs.open('doc/source/introduction.rst', "r", "utf-8").read()
else:
long_description = "See " + flatty.__homepage__
setuptools_options = {
'test_suite': 'flatty.tests.suite',
'zip_safe': True,
}
setup(
name = "flatty",
version = flatty.__version__,
packages = find_packages('src'),
package_dir = {'':'src'},
# metadata for upload to PyPI
author = flatty.__author__,
author_email = flatty.__contact__,
description = flatty.__doc__,
long_description=long_description,
keywords = "marshaller schema objectmapper couchdb mongodb orm",
platforms=["any"],
url = flatty.__homepage__,
license = 'BSD',
classifiers=[
"Development Status :: 3 - Alpha",
"Operating System :: OS Independent",
"Programming Language :: Python",
"License :: OSI Approved :: BSD License",
"Intended Audience :: Developers",
"Topic :: Software Development :: Pre-processors",
"Topic :: Software Development :: Libraries :: Python Modules",
],
**setuptools_options
)
|
bsd-3-clause
|
[
504,
9116,
492,
3272,
12,
2342,
63,
5154,
199,
504,
7065,
14,
1760,
492,
5817,
199,
646,
6010,
199,
646,
984,
12,
747,
199,
646,
8868,
199,
504,
5739,
492,
5739,
199,
199,
1274,
14,
515,
14,
3176,
8,
16,
2584,
2164,
6217,
199,
826,
63,
11357,
275,
283,
2164,
15,
7088,
369,
22128,
826,
4343,
11357,
7,
199,
692,
747,
14,
515,
14,
2444,
8,
826,
63,
11357,
304,
272,
747,
14,
2168,
8,
826,
63,
11357,
9,
199,
199,
646,
6829,
369,
421,
199,
692,
747,
14,
515,
14,
2444,
480,
1301,
15,
1365,
15,
18206,
5199,
14,
8332,
2349,
272,
1846,
63,
1802,
275,
6010,
14,
1490,
360,
1301,
15,
1365,
15,
18206,
5199,
14,
8332,
297,
298,
82,
401,
298,
1624,
13,
24,
3471,
739,
342,
199,
2836,
26,
272,
1846,
63,
1802,
275,
298,
9295,
298,
435,
6829,
369,
855,
25539,
363,
421,
199,
13623,
63,
1419,
275,
469,
199,
198,
1133,
597,
63,
5768,
356,
283,
7088,
369,
14,
2219,
14,
5768,
297,
199,
198,
7,
3065,
63,
3489,
356,
715,
12,
199,
93,
199,
199,
2758,
8,
272,
536,
275,
298,
7088,
369,
401,
272,
1015,
275,
6829,
369,
855,
1023,
3108,
272,
6117,
275,
2342,
63,
5154,
360,
2164,
659,
272,
2559,
63,
694,
275,
791,
5242,
2164,
2267,
2043,
272,
327,
3341,
367,
5802,
370,
24330,
272,
4132,
275,
6829,
369,
855,
2502,
3108,
272,
4132,
63,
2123,
275,
6829,
369,
855,
7811,
3108,
272,
1369,
275,
6829,
369,
855,
1301,
3108,
272,
1846,
63,
1802,
29,
2809,
63,
1802,
12,
272,
7681,
275,
298,
28128,
9230,
4177,
909,
7153,
28877,
697,
32315,
13152,
9813,
401,
272,
10677,
6270,
1629,
2255,
272,
1166,
275,
6829,
369,
855,
25539,
3108,
272,
4190,
275,
283,
15400,
297,
272,
19137,
1524,
267,
298,
23753,
9795,
3800,
650,
446,
32657,
401,
267,
298,
23699,
6187,
3800,
4403,
1010,
7106,
401,
267,
298,
11411,
8466,
3800,
2018,
401,
267,
298,
3761,
3800,
25718,
26330,
3800,
6289,
844,
401,
267,
298,
23910,
23975,
3800,
23493,
401,
267,
298,
12157,
3800,
2290,
15290,
3800,
5543,
13,
10547,
401,
267,
298,
12157,
3800,
2290,
15290,
3800,
31454,
3800,
2018,
18167,
401,
272,
2156,
272,
1011,
13623,
63,
1419,
819,
199,
199,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768
] |
[
9116,
492,
3272,
12,
2342,
63,
5154,
199,
504,
7065,
14,
1760,
492,
5817,
199,
646,
6010,
199,
646,
984,
12,
747,
199,
646,
8868,
199,
504,
5739,
492,
5739,
199,
199,
1274,
14,
515,
14,
3176,
8,
16,
2584,
2164,
6217,
199,
826,
63,
11357,
275,
283,
2164,
15,
7088,
369,
22128,
826,
4343,
11357,
7,
199,
692,
747,
14,
515,
14,
2444,
8,
826,
63,
11357,
304,
272,
747,
14,
2168,
8,
826,
63,
11357,
9,
199,
199,
646,
6829,
369,
421,
199,
692,
747,
14,
515,
14,
2444,
480,
1301,
15,
1365,
15,
18206,
5199,
14,
8332,
2349,
272,
1846,
63,
1802,
275,
6010,
14,
1490,
360,
1301,
15,
1365,
15,
18206,
5199,
14,
8332,
297,
298,
82,
401,
298,
1624,
13,
24,
3471,
739,
342,
199,
2836,
26,
272,
1846,
63,
1802,
275,
298,
9295,
298,
435,
6829,
369,
855,
25539,
363,
421,
199,
13623,
63,
1419,
275,
469,
199,
198,
1133,
597,
63,
5768,
356,
283,
7088,
369,
14,
2219,
14,
5768,
297,
199,
198,
7,
3065,
63,
3489,
356,
715,
12,
199,
93,
199,
199,
2758,
8,
272,
536,
275,
298,
7088,
369,
401,
272,
1015,
275,
6829,
369,
855,
1023,
3108,
272,
6117,
275,
2342,
63,
5154,
360,
2164,
659,
272,
2559,
63,
694,
275,
791,
5242,
2164,
2267,
2043,
272,
327,
3341,
367,
5802,
370,
24330,
272,
4132,
275,
6829,
369,
855,
2502,
3108,
272,
4132,
63,
2123,
275,
6829,
369,
855,
7811,
3108,
272,
1369,
275,
6829,
369,
855,
1301,
3108,
272,
1846,
63,
1802,
29,
2809,
63,
1802,
12,
272,
7681,
275,
298,
28128,
9230,
4177,
909,
7153,
28877,
697,
32315,
13152,
9813,
401,
272,
10677,
6270,
1629,
2255,
272,
1166,
275,
6829,
369,
855,
25539,
3108,
272,
4190,
275,
283,
15400,
297,
272,
19137,
1524,
267,
298,
23753,
9795,
3800,
650,
446,
32657,
401,
267,
298,
23699,
6187,
3800,
4403,
1010,
7106,
401,
267,
298,
11411,
8466,
3800,
2018,
401,
267,
298,
3761,
3800,
25718,
26330,
3800,
6289,
844,
401,
267,
298,
23910,
23975,
3800,
23493,
401,
267,
298,
12157,
3800,
2290,
15290,
3800,
5543,
13,
10547,
401,
267,
298,
12157,
3800,
2290,
15290,
3800,
31454,
3800,
2018,
18167,
401,
272,
2156,
272,
1011,
13623,
63,
1419,
819,
199,
199,
9,
421,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
32768,
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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Litzenberger <dlitz@dlitz.net>
#
# ===================================================================
# The contents of this file are dedicated to the public domain. To
# the extent that dedication to the public domain is not available,
# everyone is granted a worldwide, perpetual, royalty-free,
# non-exclusive license to exercise all rights associated with the
# contents of this file for any purpose whatsoever.
# No rights are reserved.
#
# 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.
# ===================================================================
"""Self-test suite for Crypto.Util.winrandom"""
__revision__ = "$Id$"
import unittest
class WinRandomImportTest(unittest.TestCase):
def runTest(self):
"""winrandom: simple test"""
# Import the winrandom module and try to use it
from Crypto.Util import winrandom
randobj = winrandom.new()
x = randobj.get_bytes(16)
y = randobj.get_bytes(16)
self.assertNotEqual(x, y)
def get_tests(config={}):
return [WinRandomImportTest()]
if __name__ == '__main__':
suite = lambda: unittest.TestSuite(get_tests())
unittest.main(defaultTest='suite')
# vim:set ts=4 sw=4 sts=4 expandtab:
|
apache-2.0
|
[
3,
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
221,
23820,
774,
15,
9562,
15,
396,
63,
2676,
2355,
14,
647,
26,
23820,
13,
396,
367,
314,
4747,
2355,
859,
199,
3,
199,
3,
27694,
315,
9079,
701,
577,
3316,
685,
445,
14,
491,
390,
5193,
605,
836,
665,
68,
29382,
32,
68,
29382,
14,
846,
30,
199,
3,
199,
3,
7819,
389,
199,
3,
710,
4072,
402,
642,
570,
787,
29711,
370,
314,
4575,
2881,
14,
221,
4005,
199,
3,
314,
13675,
626,
477,
21171,
370,
314,
4575,
2881,
365,
440,
2808,
12,
199,
3,
4036,
368,
365,
10009,
282,
6701,
13062,
12,
1126,
321,
1688,
12,
882,
89,
13248,
13,
4624,
12,
199,
3,
2222,
13,
12730,
4190,
370,
26511,
1006,
4481,
4568,
543,
314,
199,
3,
4072,
402,
642,
570,
367,
1263,
12016,
4052,
1152,
5907,
14,
199,
3,
3091,
4481,
787,
4644,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
199,
3,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
199,
3,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
5877,
8164,
199,
3,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
1621,
1261,
199,
3,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
199,
3,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
199,
3,
4141,
14,
199,
3,
7819,
389,
199,
199,
624,
12887,
13,
396,
5241,
367,
18855,
14,
9562,
14,
2676,
2355,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
646,
2882,
199,
199,
533,
13036,
3883,
6295,
774,
8,
2796,
14,
1746,
304,
272,
347,
29779,
8,
277,
304,
267,
408,
2676,
2355,
26,
3486,
511,
624,
267,
327,
3161,
314,
4747,
2355,
859,
436,
862,
370,
675,
652,
267,
687,
18855,
14,
9562,
492,
4747,
2355,
267,
10261,
1113,
275,
4747,
2355,
14,
1222,
342,
267,
671,
275,
10261,
1113,
14,
362,
63,
2394,
8,
975,
9,
267,
612,
275,
10261,
1113,
14,
362,
63,
2394,
8,
975,
9,
267,
291,
14,
7418,
8,
88,
12,
612,
9,
199,
199,
318,
664,
63,
2219,
8,
888,
16420,
272,
372,
359,
8886,
3883,
6295,
774,
5106,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
5241,
275,
2400,
26,
2882,
14,
10591,
8,
362,
63,
2219,
1012,
272,
2882,
14,
973,
8,
885,
774,
534,
5768,
358,
199,
199,
3,
6695,
26,
409,
6714,
29,
20,
5584,
29,
20,
23014,
29,
20,
26414,
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
] |
[
1882,
2803,
26,
2774,
13,
24,
1882,
199,
3,
199,
3,
221,
23820,
774,
15,
9562,
15,
396,
63,
2676,
2355,
14,
647,
26,
23820,
13,
396,
367,
314,
4747,
2355,
859,
199,
3,
199,
3,
27694,
315,
9079,
701,
577,
3316,
685,
445,
14,
491,
390,
5193,
605,
836,
665,
68,
29382,
32,
68,
29382,
14,
846,
30,
199,
3,
199,
3,
7819,
389,
199,
3,
710,
4072,
402,
642,
570,
787,
29711,
370,
314,
4575,
2881,
14,
221,
4005,
199,
3,
314,
13675,
626,
477,
21171,
370,
314,
4575,
2881,
365,
440,
2808,
12,
199,
3,
4036,
368,
365,
10009,
282,
6701,
13062,
12,
1126,
321,
1688,
12,
882,
89,
13248,
13,
4624,
12,
199,
3,
2222,
13,
12730,
4190,
370,
26511,
1006,
4481,
4568,
543,
314,
199,
3,
4072,
402,
642,
570,
367,
1263,
12016,
4052,
1152,
5907,
14,
199,
3,
3091,
4481,
787,
4644,
14,
199,
3,
199,
3,
2334,
4141,
2281,
7049,
298,
1179,
2281,
401,
2428,
3408,
1634,
1821,
3826,
12,
199,
3,
7168,
1549,
5292,
12,
6931,
5400,
2845,
5471,
2296,
2334,
2990,
1634,
199,
3,
3169,
12,
3092,
2381,
437,
3115,
3104,
2401,
199,
3,
13229,
14,
1621,
4825,
6461,
7000,
2334,
10610,
1549,
5877,
8164,
199,
3,
6262,
7024,
2381,
1821,
13140,
12,
6736,
1549,
5010,
5603,
12,
7061,
1621,
1261,
199,
3,
9612,
1634,
7066,
12,
7056,
1549,
7334,
12,
7043,
4442,
12,
5738,
1634,
1549,
1621,
199,
3,
11287,
1663,
2334,
4141,
1549,
2334,
4815,
1549,
5010,
13198,
1621,
2334,
199,
3,
4141,
14,
199,
3,
7819,
389,
199,
199,
624,
12887,
13,
396,
5241,
367,
18855,
14,
9562,
14,
2676,
2355,
624,
199,
199,
363,
5792,
363,
275,
7880,
1304,
17351,
199,
199,
646,
2882,
199,
199,
533,
13036,
3883,
6295,
774,
8,
2796,
14,
1746,
304,
272,
347,
29779,
8,
277,
304,
267,
408,
2676,
2355,
26,
3486,
511,
624,
267,
327,
3161,
314,
4747,
2355,
859,
436,
862,
370,
675,
652,
267,
687,
18855,
14,
9562,
492,
4747,
2355,
267,
10261,
1113,
275,
4747,
2355,
14,
1222,
342,
267,
671,
275,
10261,
1113,
14,
362,
63,
2394,
8,
975,
9,
267,
612,
275,
10261,
1113,
14,
362,
63,
2394,
8,
975,
9,
267,
291,
14,
7418,
8,
88,
12,
612,
9,
199,
199,
318,
664,
63,
2219,
8,
888,
16420,
272,
372,
359,
8886,
3883,
6295,
774,
5106,
199,
199,
692,
636,
354,
363,
508,
2560,
973,
3706,
272,
5241,
275,
2400,
26,
2882,
14,
10591,
8,
362,
63,
2219,
1012,
272,
2882,
14,
973,
8,
885,
774,
534,
5768,
358,
199,
199,
3,
6695,
26,
409,
6714,
29,
20,
5584,
29,
20,
23014,
29,
20,
26414,
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,
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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