max_stars_repo_path
stringlengths 4
237
| max_stars_repo_name
stringlengths 6
117
| max_stars_count
int64 0
95.2k
| id
stringlengths 1
7
| content
stringlengths 12
593k
| input_ids
sequencelengths 7
549k
|
---|---|---|---|---|---|
python/dataproc_templates/util/argument_parsing.py | samkenxstream/dataproc-templates | 15 | 136805 | <reponame>samkenxstream/dataproc-templates<filename>python/dataproc_templates/util/argument_parsing.py
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Optional, Sequence
import argparse
from dataproc_templates import TemplateName
def get_template_name(args: Optional[Sequence[str]] = None) -> TemplateName:
"""
Parses the template name option from the program arguments.
This will print the command help and exit if the --template
argument is missing.
Args:
args (Optional[Sequence[str]]): The program arguments.
By default, command line arguments will be used.
Returns:
str: The value of the --template argument
"""
parser: argparse.ArgumentParser = argparse.ArgumentParser(
add_help=False
)
parser.add_argument(
'--template',
dest='template_name',
type=str,
required=False,
default=None,
choices=TemplateName.choices(),
help='The name of the template to run'
)
known_args: argparse.Namespace
known_args, _ = parser.parse_known_args(args=args)
if known_args.template_name is None:
parser.print_help()
parser.exit()
return TemplateName.from_string(known_args.template_name)
| [
1,
529,
276,
1112,
420,
29958,
13445,
1717,
29916,
5461,
29914,
4130,
481,
10198,
29899,
20943,
29966,
9507,
29958,
4691,
29914,
4130,
481,
10198,
29918,
20943,
29914,
4422,
29914,
23516,
29918,
862,
2976,
29889,
2272,
13,
29937,
14187,
1266,
29871,
29906,
29900,
29906,
29906,
5087,
365,
12182,
13,
29937,
13,
29937,
10413,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
29937,
366,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
29937,
887,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
2045,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
29937,
13,
29937,
25870,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
29937,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29937,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
13,
29937,
2823,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
29937,
27028,
1090,
278,
19245,
29889,
13,
13,
3166,
19229,
1053,
28379,
29892,
922,
3910,
13,
5215,
1852,
5510,
13,
13,
3166,
1418,
481,
10198,
29918,
20943,
1053,
25663,
1170,
13,
13,
13,
1753,
679,
29918,
6886,
29918,
978,
29898,
5085,
29901,
28379,
29961,
20529,
29961,
710,
5262,
353,
6213,
29897,
1599,
25663,
1170,
29901,
13,
1678,
9995,
13,
1678,
1459,
29879,
267,
278,
4472,
1024,
2984,
515,
278,
1824,
6273,
29889,
13,
13,
1678,
910,
674,
1596,
278,
1899,
1371,
322,
6876,
565,
278,
1192,
6886,
13,
1678,
2980,
338,
4567,
29889,
13,
13,
1678,
826,
3174,
29901,
13,
4706,
6389,
313,
27636,
29961,
20529,
29961,
710,
5262,
1125,
450,
1824,
6273,
29889,
13,
9651,
2648,
2322,
29892,
1899,
1196,
6273,
674,
367,
1304,
29889,
13,
13,
1678,
16969,
29901,
13,
4706,
851,
29901,
450,
995,
310,
278,
1192,
6886,
2980,
13,
1678,
9995,
13,
13,
1678,
13812,
29901,
1852,
5510,
29889,
15730,
11726,
353,
1852,
5510,
29889,
15730,
11726,
29898,
13,
4706,
788,
29918,
8477,
29922,
8824,
13,
1678,
1723,
13,
13,
1678,
13812,
29889,
1202,
29918,
23516,
29898,
13,
4706,
525,
489,
6886,
742,
13,
4706,
2731,
2433,
6886,
29918,
978,
742,
13,
4706,
1134,
29922,
710,
29892,
13,
4706,
3734,
29922,
8824,
29892,
13,
4706,
2322,
29922,
8516,
29892,
13,
4706,
19995,
29922,
6733,
1170,
29889,
1859,
1575,
3285,
13,
4706,
1371,
2433,
1576,
1024,
310,
278,
4472,
304,
1065,
29915,
13,
1678,
1723,
13,
13,
1678,
2998,
29918,
5085,
29901,
1852,
5510,
29889,
23335,
13,
1678,
2998,
29918,
5085,
29892,
903,
353,
13812,
29889,
5510,
29918,
5203,
29918,
5085,
29898,
5085,
29922,
5085,
29897,
13,
13,
1678,
565,
2998,
29918,
5085,
29889,
6886,
29918,
978,
338,
6213,
29901,
13,
4706,
13812,
29889,
2158,
29918,
8477,
580,
13,
4706,
13812,
29889,
13322,
580,
13,
13,
1678,
736,
25663,
1170,
29889,
3166,
29918,
1807,
29898,
5203,
29918,
5085,
29889,
6886,
29918,
978,
29897,
13,
2
] |
solutions/77.py | pacokwon/leetcode | 2 | 74412 | # Combinations
class Solution:
def combine(self, n, k):
ans = []
def helper(choices, start, count, ans):
if count == k:
# cloning the list here
ans.append(list(choices))
return
for i in range(start, n + 1):
choices[count] = i
helper(choices, i + 1, count + 1, ans)
helper([None] * k, 1, 0, ans)
return ans
if __name__ == "__main__":
sol = Solution()
n = 1
k = 1
print(sol.combine(n, k))
| [
1,
396,
422,
2109,
800,
13,
13,
1990,
24380,
29901,
13,
1678,
822,
14405,
29898,
1311,
29892,
302,
29892,
413,
1125,
13,
4706,
6063,
353,
5159,
13,
13,
4706,
822,
16876,
29898,
1859,
1575,
29892,
1369,
29892,
2302,
29892,
6063,
1125,
13,
9651,
565,
2302,
1275,
413,
29901,
13,
18884,
396,
1067,
28259,
278,
1051,
1244,
13,
18884,
6063,
29889,
4397,
29898,
1761,
29898,
1859,
1575,
876,
13,
18884,
736,
13,
13,
9651,
363,
474,
297,
3464,
29898,
2962,
29892,
302,
718,
29871,
29896,
1125,
13,
18884,
19995,
29961,
2798,
29962,
353,
474,
13,
18884,
16876,
29898,
1859,
1575,
29892,
474,
718,
29871,
29896,
29892,
2302,
718,
29871,
29896,
29892,
6063,
29897,
13,
13,
4706,
16876,
4197,
8516,
29962,
334,
413,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
6063,
29897,
13,
4706,
736,
6063,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
899,
353,
24380,
580,
13,
1678,
302,
353,
29871,
29896,
13,
1678,
413,
353,
29871,
29896,
13,
1678,
1596,
29898,
2929,
29889,
17743,
457,
29898,
29876,
29892,
413,
876,
13,
2
] |
demo.py | jjegg01/abp.spherical2d.pairdistribution | 0 | 24504 | <filename>demo.py<gh_stars>0
#!/usb/bin/env python3
"""Demo script for abp.spherical2d.pairdistribution module."""
__author__ = "<NAME>, <NAME>"
__copyright__ = "Copyright (C) 2019 <NAME>, <NAME>"
__license__ = "MIT"
__version__ = "1.0"
import argparse
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
import abp.spherical2d.pairdistribution as abp2dpd
# -- Parse args --
parser = argparse.ArgumentParser(
description=r"""Display the pair-distribution function for a given particle
distance, Peclet number and packing density. The default values are the
same as in Fig. 3 of the accompanying article by <NAME>,
<NAME> and <NAME>.""")
parser.add_argument(
"-r", metavar="dist", dest="dist", type=float, default=1.0,
help="Particle distance in multiples of sigma (default: 1)")
parser.add_argument(
"-d", metavar="phi0", dest="phi0", type=float, default=0.2,
help="Packing density (default: 0.2)")
parser.add_argument(
"-p", metavar="peclet", dest="peclet", type=float, default=50.0,
help="Peclet number (default: 50)")
args = parser.parse_args()
# Validate args
r_min = 0.7775
r_max = 2**(1/6)
if args.dist < r_min or args.dist > r_max:
print("Warning: Distance is outside of approximation bounds!")
if args.peclet < 0:
print("Warning: Unphysical argument for Peclet number")
if args.phi0 < 0 or args.phi0 > 1:
print("Warning: Unphysical argument for packing density")
# -- Calculate pair-distribution function --
# Generate arrays for r, phi1 and phi2
phi1 = np.linspace(-np.pi,np.pi,180,endpoint=False)
phi2 = np.linspace(0,2*np.pi,180,endpoint=False)
phi1,phi2 = np.meshgrid(phi1, phi2)
r = args.dist # Just take a single distance
# Calculate -gU'_2
gU2 = abp2dpd.reconstruct_mgU2prime(r, phi1, phi2, args.phi0, args.peclet)[0]
# Divide by U'_2 to obtain the pair-distribution function g
g = -gU2/abp2dpd.getU2prime(args.dist)
# -- Plotting code --
fig, ax = plt.subplots(1)
test = np.zeros((11,100))
cax = ax.imshow(g.T, cmap="inferno", origin="lower",
extent=(0,g.shape[0],0,g.shape[0]))
cbar = fig.colorbar(cax)
cbar.set_label("$g$")
ax.set_xlabel(r"$\phi_1$")
ax.set_ylabel(r"$\phi_2$")
ax.set_xticks([0,g.shape[0]//2,g.shape[0]])
ax.set_xticklabels([r"$-\pi$",r"0",r"$\pi$"])
ax.xaxis.set_minor_locator(MultipleLocator(g.shape[0]//4))
ax.set_yticks([0,g.shape[0]//2,g.shape[0]])
ax.set_yticklabels(["0",r"$\pi$",r"$2\pi$"])
ax.yaxis.set_minor_locator(MultipleLocator(g.shape[0]//4))
plt.show()
| [
1,
529,
9507,
29958,
17482,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
14708,
28685,
29914,
2109,
29914,
6272,
3017,
29941,
13,
13,
15945,
29908,
23444,
2471,
363,
633,
29886,
29889,
29879,
8096,
936,
29906,
29881,
29889,
18784,
27691,
3883,
1213,
15945,
13,
13,
1649,
8921,
1649,
353,
9872,
5813,
10202,
529,
5813,
11903,
13,
1649,
8552,
1266,
1649,
353,
376,
11882,
1266,
313,
29907,
29897,
29871,
29906,
29900,
29896,
29929,
529,
5813,
10202,
529,
5813,
11903,
13,
1649,
506,
1947,
1649,
353,
376,
26349,
29908,
13,
1649,
3259,
1649,
353,
376,
29896,
29889,
29900,
29908,
13,
13,
5215,
1852,
5510,
13,
13,
5215,
12655,
408,
7442,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
3166,
22889,
29889,
29873,
6541,
1053,
26905,
3524,
1061,
13,
13,
5215,
633,
29886,
29889,
29879,
8096,
936,
29906,
29881,
29889,
18784,
27691,
408,
633,
29886,
29906,
6099,
29881,
13,
13,
29937,
1192,
20969,
6389,
1192,
13,
13,
16680,
353,
1852,
5510,
29889,
15730,
11726,
29898,
13,
1678,
6139,
29922,
29878,
15945,
29908,
9323,
278,
5101,
29899,
27691,
740,
363,
263,
2183,
16445,
13,
4706,
5418,
29892,
349,
687,
1026,
1353,
322,
4870,
292,
9027,
29889,
450,
2322,
1819,
526,
278,
13,
4706,
1021,
408,
297,
5104,
29889,
29871,
29941,
310,
278,
10259,
1384,
292,
4274,
491,
529,
5813,
10202,
13,
4706,
529,
5813,
29958,
322,
529,
5813,
29958,
1213,
29908,
1159,
13,
16680,
29889,
1202,
29918,
23516,
29898,
13,
1678,
11663,
29878,
613,
1539,
485,
279,
543,
5721,
613,
2731,
543,
5721,
613,
1134,
29922,
7411,
29892,
2322,
29922,
29896,
29889,
29900,
29892,
13,
1678,
1371,
543,
7439,
2512,
5418,
297,
2473,
2701,
310,
269,
2934,
313,
4381,
29901,
29871,
29896,
25760,
13,
16680,
29889,
1202,
29918,
23516,
29898,
13,
1678,
11663,
29881,
613,
1539,
485,
279,
543,
2876,
29900,
613,
2731,
543,
2876,
29900,
613,
1134,
29922,
7411,
29892,
2322,
29922,
29900,
29889,
29906,
29892,
13,
1678,
1371,
543,
16638,
292,
9027,
313,
4381,
29901,
29871,
29900,
29889,
29906,
25760,
13,
16680,
29889,
1202,
29918,
23516,
29898,
13,
1678,
11663,
29886,
613,
1539,
485,
279,
543,
3135,
1026,
613,
2731,
543,
3135,
1026,
613,
1134,
29922,
7411,
29892,
2322,
29922,
29945,
29900,
29889,
29900,
29892,
13,
1678,
1371,
543,
29925,
687,
1026,
1353,
313,
4381,
29901,
29871,
29945,
29900,
25760,
13,
13,
5085,
353,
13812,
29889,
5510,
29918,
5085,
580,
13,
13,
29937,
15758,
403,
6389,
13,
13,
29878,
29918,
1195,
353,
29871,
29900,
29889,
29955,
29955,
29955,
29945,
13,
29878,
29918,
3317,
353,
29871,
29906,
1068,
29898,
29896,
29914,
29953,
29897,
13,
361,
6389,
29889,
5721,
529,
364,
29918,
1195,
470,
6389,
29889,
5721,
1405,
364,
29918,
3317,
29901,
13,
1678,
1596,
703,
22709,
29901,
6652,
749,
338,
5377,
310,
16845,
13451,
29991,
1159,
13,
13,
361,
6389,
29889,
3135,
1026,
529,
29871,
29900,
29901,
13,
1678,
1596,
703,
22709,
29901,
853,
14017,
936,
2980,
363,
349,
687,
1026,
1353,
1159,
13,
361,
6389,
29889,
2876,
29900,
529,
29871,
29900,
470,
6389,
29889,
2876,
29900,
1405,
29871,
29896,
29901,
13,
1678,
1596,
703,
22709,
29901,
853,
14017,
936,
2980,
363,
4870,
292,
9027,
1159,
13,
13,
29937,
1192,
20535,
403,
5101,
29899,
27691,
740,
1192,
13,
13,
29937,
3251,
403,
7049,
363,
364,
29892,
1374,
29875,
29896,
322,
1374,
29875,
29906,
13,
2876,
29896,
353,
7442,
29889,
1915,
3493,
6278,
9302,
29889,
1631,
29892,
9302,
29889,
1631,
29892,
29896,
29947,
29900,
29892,
29734,
29922,
8824,
29897,
13,
2876,
29906,
353,
7442,
29889,
1915,
3493,
29898,
29900,
29892,
29906,
29930,
9302,
29889,
1631,
29892,
29896,
29947,
29900,
29892,
29734,
29922,
8824,
29897,
13,
2876,
29896,
29892,
2876,
29906,
353,
7442,
29889,
4467,
29882,
7720,
29898,
2876,
29896,
29892,
1374,
29875,
29906,
29897,
13,
29878,
353,
6389,
29889,
5721,
396,
3387,
2125,
263,
2323,
5418,
13,
13,
29937,
20535,
403,
448,
29887,
29965,
15972,
29906,
13,
29887,
29965,
29906,
353,
633,
29886,
29906,
6099,
29881,
29889,
276,
11433,
29918,
29885,
29887,
29965,
29906,
10080,
29898,
29878,
29892,
1374,
29875,
29896,
29892,
1374,
29875,
29906,
29892,
6389,
29889,
2876,
29900,
29892,
6389,
29889,
3135,
1026,
9601,
29900,
29962,
13,
13,
29937,
4910,
680,
491,
501,
15972,
29906,
304,
4017,
278,
5101,
29899,
27691,
740,
330,
13,
29887,
353,
448,
29887,
29965,
29906,
29914,
370,
29886,
29906,
6099,
29881,
29889,
657,
29965,
29906,
10080,
29898,
5085,
29889,
5721,
29897,
13,
13,
29937,
1192,
18399,
1259,
775,
1192,
13,
13,
1003,
29892,
4853,
353,
14770,
29889,
1491,
26762,
29898,
29896,
29897,
13,
13,
1688,
353,
7442,
29889,
3298,
359,
3552,
29896,
29896,
29892,
29896,
29900,
29900,
876,
13,
1113,
29916,
353,
4853,
29889,
326,
4294,
29898,
29887,
29889,
29911,
29892,
274,
1958,
543,
262,
571,
1217,
613,
3978,
543,
13609,
613,
13,
1062,
296,
7607,
29900,
29892,
29887,
29889,
12181,
29961,
29900,
1402,
29900,
29892,
29887,
29889,
12181,
29961,
29900,
12622,
13,
29883,
1646,
353,
2537,
29889,
2780,
1646,
29898,
1113,
29916,
29897,
13,
13,
29883,
1646,
29889,
842,
29918,
1643,
703,
29938,
29887,
29938,
1159,
13,
13,
1165,
29889,
842,
29918,
29916,
1643,
29898,
29878,
29908,
4535,
2876,
29918,
29896,
29938,
1159,
13,
1165,
29889,
842,
29918,
29891,
1643,
29898,
29878,
29908,
4535,
2876,
29918,
29906,
29938,
1159,
13,
13,
1165,
29889,
842,
29918,
486,
7358,
4197,
29900,
29892,
29887,
29889,
12181,
29961,
29900,
29962,
458,
29906,
29892,
29887,
29889,
12181,
29961,
29900,
24960,
13,
1165,
29889,
842,
29918,
486,
860,
21134,
4197,
29878,
29908,
29938,
2612,
1631,
29938,
613,
29878,
29908,
29900,
613,
29878,
29908,
4535,
1631,
29938,
20068,
13,
1165,
29889,
29916,
8990,
29889,
842,
29918,
1195,
272,
29918,
2029,
1061,
29898,
15329,
552,
3524,
1061,
29898,
29887,
29889,
12181,
29961,
29900,
29962,
458,
29946,
876,
13,
13,
1165,
29889,
842,
29918,
3637,
7358,
4197,
29900,
29892,
29887,
29889,
12181,
29961,
29900,
29962,
458,
29906,
29892,
29887,
29889,
12181,
29961,
29900,
24960,
13,
1165,
29889,
842,
29918,
3637,
860,
21134,
29898,
3366,
29900,
613,
29878,
29908,
4535,
1631,
29938,
613,
29878,
29908,
29938,
29906,
29905,
1631,
29938,
20068,
13,
1165,
29889,
29891,
8990,
29889,
842,
29918,
1195,
272,
29918,
2029,
1061,
29898,
15329,
552,
3524,
1061,
29898,
29887,
29889,
12181,
29961,
29900,
29962,
458,
29946,
876,
13,
13,
572,
29873,
29889,
4294,
580,
13,
2
] |
contact/urls.py | BobsProgrammingAcademy/Portfolio-Website-Deployment | 0 | 28447 | from django.urls import path
from .views import ContactListView
urlpatterns = [
path('', ContactListView.as_view()),
] | [
1,
515,
9557,
29889,
26045,
1053,
2224,
13,
3166,
869,
7406,
1053,
22387,
15660,
13,
13,
2271,
11037,
29879,
353,
518,
13,
1678,
2224,
877,
742,
22387,
15660,
29889,
294,
29918,
1493,
25739,
13,
29962,
2
] |
difPy/dif.py | ppizarror/Duplicate-Image-Finder | 0 | 20390 | import skimage.color
import matplotlib.pyplot as plt
import numpy as np
import cv2
import os
import imghdr
import time
"""
Duplicate Image Finder (DIF): function that searches a given directory for images and finds duplicate/similar images among them.
Outputs the number of found duplicate/similar image pairs with a list of the filenames having lower resolution.
"""
class dif:
def compare_images(directory, show_imgs=False, similarity="normal", px_size=50, delete=False):
"""
directory (str)......folder path to search for duplicate/similar images
show_imgs (bool).....False = omits the output and doesn't show found images
True = shows duplicate/similar images found in output
similarity (str)....."normal" = searches for duplicates, recommended setting, MSE < 200
"high" = serached for exact duplicates, extremly sensitive to details, MSE < 0.1
"low" = searches for similar images, MSE < 1000
px_size (int)........recommended not to change default value
resize images to px_size height x width (in pixels) before being compared
the higher the pixel size, the more computational ressources and time required
delete (bool)........! please use with care, as this cannot be undone
lower resolution duplicate images that were found are automatically deleted
OUTPUT (set).........a set of the filenames of the lower resolution duplicate images
"""
# list where the found duplicate/similar images are stored
duplicates = []
lower_res = []
imgs_matrix = dif.create_imgs_matrix(directory, px_size)
# search for similar images, MSE < 1000
if similarity == "low":
ref = 1000
# search for exact duplicate images, extremly sensitive, MSE < 0.1
elif similarity == "high":
ref = 0.1
# normal, search for duplicates, recommended, MSE < 200
else:
ref = 200
main_img = 0
compared_img = 1
nrows, ncols = px_size, px_size
srow_A = 0
erow_A = nrows
srow_B = erow_A
erow_B = srow_B + nrows
while erow_B <= imgs_matrix.shape[0]:
while compared_img < (len(image_files)):
# select two images from imgs_matrix
imgA = imgs_matrix[srow_A: erow_A, # rows
0: ncols] # columns
imgB = imgs_matrix[srow_B: erow_B, # rows
0: ncols] # columns
# compare the images
rotations = 0
while image_files[main_img] not in duplicates and rotations <= 3:
if rotations != 0:
imgB = dif.rotate_img(imgB)
err = dif.mse(imgA, imgB)
if err < ref:
if show_imgs:
dif.show_img_figs(imgA, imgB, err)
dif.show_file_info(compared_img, main_img)
dif.add_to_list(image_files[main_img], duplicates)
dif.check_img_quality(directory, image_files[main_img], image_files[compared_img], lower_res)
rotations += 1
srow_B += nrows
erow_B += nrows
compared_img += 1
srow_A += nrows
erow_A += nrows
srow_B = erow_A
erow_B = srow_B + nrows
main_img += 1
compared_img = main_img + 1
msg = "\n***\nFound " + str(len(duplicates)) + " duplicate image pairs in " + str(
len(image_files)) + " total images.\n\nThe following files have lower resolution:"
print(msg)
print(lower_res, "\n")
time.sleep(0.5)
if delete:
usr = input("Are you sure you want to delete all lower resolution duplicate images? (y/n)")
if str(usr) == "y":
dif.delete_imgs(directory, set(lower_res))
else:
print("Image deletion canceled.")
return set(lower_res)
else:
return set(lower_res)
def _process_directory(directory):
directory += os.sep
if not os.path.isdir(directory):
raise FileNotFoundError(f"Directory: " + directory + " does not exist")
return directory
# Function that searches the folder for image files, converts them to a matrix
def create_imgs_matrix(directory, px_size):
directory = dif._process_directory(directory)
global image_files
image_files = []
# create list of all files in directory
folder_files = [filename for filename in os.listdir(directory)]
# create images matrix
counter = 0
for filename in folder_files:
if not os.path.isdir(directory + filename) and imghdr.what(directory + filename):
img = cv2.imdecode(np.fromfile(directory + filename, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
if type(img) == np.ndarray:
img = img[..., 0:3]
img = cv2.resize(img, dsize=(px_size, px_size), interpolation=cv2.INTER_CUBIC)
if len(img.shape) == 2:
img = skimage.color.gray2rgb(img)
if counter == 0:
imgs_matrix = img
image_files.append(filename)
counter += 1
else:
imgs_matrix = np.concatenate((imgs_matrix, img))
image_files.append(filename)
return imgs_matrix
# Function that calulates the mean squared error (mse) between two image matrices
def mse(imageA, imageB):
err = np.sum((imageA.astype("float") - imageB.astype("float")) ** 2)
err /= float(imageA.shape[0] * imageA.shape[1])
return err
# Function that plots two compared image files and their mse
def show_img_figs(imageA, imageB, err):
fig = plt.figure()
plt.suptitle("MSE: %.2f" % (err))
# plot first image
ax = fig.add_subplot(1, 2, 1)
plt.imshow(imageA, cmap=plt.cm.gray)
plt.axis("off")
# plot second image
ax = fig.add_subplot(1, 2, 2)
plt.imshow(imageB, cmap=plt.cm.gray)
plt.axis("off")
# show the images
plt.show()
# Function for rotating an image matrix by a 90 degree angle
def rotate_img(image):
image = np.rot90(image, k=1, axes=(0, 1))
return image
# Function for printing filename info of plotted image files
def show_file_info(compared_img, main_img):
print("Duplicate file: " + image_files[main_img] + " and " + image_files[compared_img])
# Function for appending items to a list
def add_to_list(filename, list):
list.append(filename)
# Function for checking the quality of compared images, appends the lower quality image to the list
def check_img_quality(directory, imageA, imageB, list):
directory = dif._process_directory(directory)
size_imgA = os.stat(directory + imageA).st_size
size_imgB = os.stat(directory + imageB).st_size
if size_imgA > size_imgB:
dif.add_to_list(imageB, list)
else:
dif.add_to_list(imageA, list)
def delete_imgs(directory, filenames_set):
directory = dif._process_directory(directory)
print("\nDeletion in progress...")
deleted = 0
for filename in filenames_set:
try:
os.remove(directory + filename)
print("Deleted file:", filename)
deleted += 1
except:
print("Could not delete file:", filename)
print("\n***\nDeleted", deleted, "duplicates.")
| [
1,
1053,
2071,
3027,
29889,
2780,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
12655,
408,
7442,
13,
5215,
13850,
29906,
13,
5215,
2897,
13,
5215,
10153,
29882,
7707,
13,
5215,
931,
13,
13,
15945,
29908,
29871,
13,
29928,
786,
5926,
7084,
383,
4995,
313,
4571,
29943,
1125,
740,
393,
29645,
263,
2183,
3884,
363,
4558,
322,
14061,
7929,
29914,
29764,
4558,
4249,
963,
29889,
13,
6466,
29879,
278,
1353,
310,
1476,
7929,
29914,
29764,
1967,
11000,
411,
263,
1051,
310,
278,
977,
264,
1280,
2534,
5224,
10104,
29889,
13,
15945,
29908,
13,
13,
13,
1990,
958,
29901,
13,
1678,
822,
7252,
29918,
8346,
29898,
12322,
29892,
1510,
29918,
2492,
29879,
29922,
8824,
29892,
29501,
543,
8945,
613,
282,
29916,
29918,
2311,
29922,
29945,
29900,
29892,
5217,
29922,
8824,
1125,
13,
4706,
9995,
13,
4706,
3884,
313,
710,
467,
18598,
12083,
2224,
304,
2740,
363,
7929,
29914,
29764,
4558,
13,
4706,
1510,
29918,
2492,
29879,
313,
11227,
467,
3045,
8824,
353,
2703,
1169,
278,
1962,
322,
1838,
29915,
29873,
1510,
1476,
4558,
13,
462,
632,
5852,
353,
3697,
7929,
29914,
29764,
4558,
1476,
297,
1962,
13,
4706,
29501,
313,
710,
467,
3045,
29908,
8945,
29908,
353,
29645,
363,
20955,
29892,
13622,
4444,
29892,
341,
1660,
529,
29871,
29906,
29900,
29900,
13,
462,
632,
376,
9812,
29908,
353,
724,
3791,
363,
2684,
20955,
29892,
9413,
368,
20502,
304,
4902,
29892,
341,
1660,
529,
29871,
29900,
29889,
29896,
13,
462,
632,
376,
677,
29908,
353,
29645,
363,
2788,
4558,
29892,
341,
1660,
529,
29871,
29896,
29900,
29900,
29900,
13,
4706,
282,
29916,
29918,
2311,
313,
524,
467,
3045,
856,
276,
2055,
2760,
451,
304,
1735,
2322,
995,
13,
462,
632,
19490,
4558,
304,
282,
29916,
29918,
2311,
3171,
921,
2920,
313,
262,
17036,
29897,
1434,
1641,
9401,
13,
462,
632,
278,
6133,
278,
15526,
2159,
29892,
278,
901,
26845,
18475,
2863,
322,
931,
3734,
29871,
13,
4706,
5217,
313,
11227,
467,
3045,
856,
29991,
3113,
671,
411,
2562,
29892,
408,
445,
2609,
367,
563,
650,
13,
462,
632,
5224,
10104,
7929,
4558,
393,
892,
1476,
526,
6336,
11132,
13,
308,
13,
4706,
19474,
12336,
313,
842,
467,
11296,
29874,
731,
310,
278,
977,
264,
1280,
310,
278,
5224,
10104,
7929,
4558,
13,
4706,
9995,
13,
4706,
396,
1051,
988,
278,
1476,
7929,
29914,
29764,
4558,
526,
6087,
13,
4706,
20955,
353,
5159,
13,
4706,
5224,
29918,
690,
353,
5159,
13,
13,
4706,
527,
3174,
29918,
5344,
353,
958,
29889,
3258,
29918,
2492,
29879,
29918,
5344,
29898,
12322,
29892,
282,
29916,
29918,
2311,
29897,
13,
13,
4706,
396,
2740,
363,
2788,
4558,
29892,
341,
1660,
529,
29871,
29896,
29900,
29900,
29900,
13,
4706,
565,
29501,
1275,
376,
677,
1115,
13,
9651,
2143,
353,
29871,
29896,
29900,
29900,
29900,
13,
4706,
396,
2740,
363,
2684,
7929,
4558,
29892,
9413,
368,
20502,
29892,
341,
1660,
529,
29871,
29900,
29889,
29896,
13,
4706,
25342,
29501,
1275,
376,
9812,
1115,
13,
9651,
2143,
353,
29871,
29900,
29889,
29896,
13,
4706,
396,
4226,
29892,
2740,
363,
20955,
29892,
13622,
29892,
341,
1660,
529,
29871,
29906,
29900,
29900,
13,
4706,
1683,
29901,
13,
9651,
2143,
353,
29871,
29906,
29900,
29900,
13,
13,
4706,
1667,
29918,
2492,
353,
29871,
29900,
13,
4706,
9401,
29918,
2492,
353,
29871,
29896,
13,
4706,
302,
5727,
29892,
302,
22724,
353,
282,
29916,
29918,
2311,
29892,
282,
29916,
29918,
2311,
13,
4706,
269,
798,
29918,
29909,
353,
29871,
29900,
13,
4706,
604,
340,
29918,
29909,
353,
302,
5727,
13,
4706,
269,
798,
29918,
29933,
353,
604,
340,
29918,
29909,
13,
4706,
604,
340,
29918,
29933,
353,
269,
798,
29918,
29933,
718,
302,
5727,
13,
13,
4706,
1550,
604,
340,
29918,
29933,
5277,
527,
3174,
29918,
5344,
29889,
12181,
29961,
29900,
5387,
13,
9651,
1550,
9401,
29918,
2492,
529,
313,
2435,
29898,
3027,
29918,
5325,
22164,
13,
18884,
396,
1831,
1023,
4558,
515,
527,
3174,
29918,
5344,
13,
18884,
10153,
29909,
353,
527,
3174,
29918,
5344,
29961,
29879,
798,
29918,
29909,
29901,
604,
340,
29918,
29909,
29892,
29871,
396,
4206,
13,
462,
4706,
29900,
29901,
302,
22724,
29962,
29871,
396,
4341,
13,
18884,
10153,
29933,
353,
527,
3174,
29918,
5344,
29961,
29879,
798,
29918,
29933,
29901,
604,
340,
29918,
29933,
29892,
29871,
396,
4206,
13,
462,
4706,
29900,
29901,
302,
22724,
29962,
29871,
396,
4341,
13,
18884,
396,
7252,
278,
4558,
13,
18884,
5731,
800,
353,
29871,
29900,
13,
18884,
1550,
1967,
29918,
5325,
29961,
3396,
29918,
2492,
29962,
451,
297,
20955,
322,
5731,
800,
5277,
29871,
29941,
29901,
13,
462,
1678,
565,
5731,
800,
2804,
29871,
29900,
29901,
13,
462,
4706,
10153,
29933,
353,
958,
29889,
23361,
29918,
2492,
29898,
2492,
29933,
29897,
13,
462,
1678,
4589,
353,
958,
29889,
29885,
344,
29898,
2492,
29909,
29892,
10153,
29933,
29897,
13,
462,
1678,
565,
4589,
529,
2143,
29901,
13,
462,
4706,
565,
1510,
29918,
2492,
29879,
29901,
13,
462,
9651,
958,
29889,
4294,
29918,
2492,
29918,
1003,
29879,
29898,
2492,
29909,
29892,
10153,
29933,
29892,
4589,
29897,
13,
462,
9651,
958,
29889,
4294,
29918,
1445,
29918,
3888,
29898,
2388,
1965,
29918,
2492,
29892,
1667,
29918,
2492,
29897,
13,
462,
4706,
958,
29889,
1202,
29918,
517,
29918,
1761,
29898,
3027,
29918,
5325,
29961,
3396,
29918,
2492,
1402,
20955,
29897,
13,
462,
4706,
958,
29889,
3198,
29918,
2492,
29918,
29567,
29898,
12322,
29892,
1967,
29918,
5325,
29961,
3396,
29918,
2492,
1402,
1967,
29918,
5325,
29961,
2388,
1965,
29918,
2492,
1402,
5224,
29918,
690,
29897,
13,
462,
1678,
5731,
800,
4619,
29871,
29896,
13,
18884,
269,
798,
29918,
29933,
4619,
302,
5727,
13,
18884,
604,
340,
29918,
29933,
4619,
302,
5727,
13,
18884,
9401,
29918,
2492,
4619,
29871,
29896,
13,
13,
9651,
269,
798,
29918,
29909,
4619,
302,
5727,
13,
9651,
604,
340,
29918,
29909,
4619,
302,
5727,
13,
9651,
269,
798,
29918,
29933,
353,
604,
340,
29918,
29909,
13,
9651,
604,
340,
29918,
29933,
353,
269,
798,
29918,
29933,
718,
302,
5727,
13,
9651,
1667,
29918,
2492,
4619,
29871,
29896,
13,
9651,
9401,
29918,
2492,
353,
1667,
29918,
2492,
718,
29871,
29896,
13,
13,
4706,
10191,
353,
6634,
29876,
17435,
29905,
29876,
9692,
376,
718,
851,
29898,
2435,
29898,
20908,
15815,
876,
718,
376,
7929,
1967,
11000,
297,
376,
718,
851,
29898,
13,
9651,
7431,
29898,
3027,
29918,
5325,
876,
718,
376,
3001,
4558,
7790,
29876,
29905,
29876,
1576,
1494,
2066,
505,
5224,
10104,
6160,
13,
4706,
1596,
29898,
7645,
29897,
13,
4706,
1596,
29898,
13609,
29918,
690,
29892,
6634,
29876,
1159,
13,
4706,
931,
29889,
17059,
29898,
29900,
29889,
29945,
29897,
13,
13,
4706,
565,
5217,
29901,
13,
9651,
502,
29878,
353,
1881,
703,
17506,
366,
1854,
366,
864,
304,
5217,
599,
5224,
10104,
7929,
4558,
29973,
313,
29891,
29914,
29876,
25760,
13,
9651,
565,
851,
29898,
4855,
29897,
1275,
376,
29891,
1115,
13,
18884,
958,
29889,
8143,
29918,
2492,
29879,
29898,
12322,
29892,
731,
29898,
13609,
29918,
690,
876,
13,
9651,
1683,
29901,
13,
18884,
1596,
703,
2940,
7374,
291,
508,
346,
839,
23157,
13,
18884,
736,
731,
29898,
13609,
29918,
690,
29897,
13,
4706,
1683,
29901,
13,
9651,
736,
731,
29898,
13609,
29918,
690,
29897,
13,
13,
1678,
822,
903,
5014,
29918,
12322,
29898,
12322,
1125,
13,
4706,
3884,
4619,
2897,
29889,
19570,
13,
4706,
565,
451,
2897,
29889,
2084,
29889,
275,
3972,
29898,
12322,
1125,
13,
9651,
12020,
3497,
17413,
2392,
29898,
29888,
29908,
9882,
29901,
376,
718,
3884,
718,
376,
947,
451,
1863,
1159,
13,
4706,
736,
3884,
13,
13,
1678,
396,
6680,
393,
29645,
278,
4138,
363,
1967,
2066,
29892,
29436,
963,
304,
263,
4636,
13,
1678,
822,
1653,
29918,
2492,
29879,
29918,
5344,
29898,
12322,
29892,
282,
29916,
29918,
2311,
1125,
13,
4706,
3884,
353,
958,
3032,
5014,
29918,
12322,
29898,
12322,
29897,
13,
4706,
5534,
1967,
29918,
5325,
13,
4706,
1967,
29918,
5325,
353,
5159,
13,
4706,
396,
1653,
1051,
310,
599,
2066,
297,
3884,
418,
13,
4706,
4138,
29918,
5325,
353,
518,
9507,
363,
10422,
297,
2897,
29889,
1761,
3972,
29898,
12322,
4638,
13,
13,
4706,
396,
1653,
4558,
4636,
1678,
13,
4706,
6795,
353,
29871,
29900,
13,
4706,
363,
10422,
297,
4138,
29918,
5325,
29901,
13,
9651,
565,
451,
2897,
29889,
2084,
29889,
275,
3972,
29898,
12322,
718,
10422,
29897,
322,
10153,
29882,
7707,
29889,
5816,
29898,
12322,
718,
10422,
1125,
13,
18884,
10153,
353,
13850,
29906,
29889,
326,
13808,
29898,
9302,
29889,
3166,
1445,
29898,
12322,
718,
10422,
29892,
26688,
29922,
9302,
29889,
13470,
29947,
511,
13850,
29906,
29889,
7833,
16310,
29918,
3904,
3210,
24336,
29928,
29897,
13,
18884,
565,
1134,
29898,
2492,
29897,
1275,
7442,
29889,
299,
2378,
29901,
13,
462,
1678,
10153,
353,
10153,
29961,
16361,
29871,
29900,
29901,
29941,
29962,
13,
462,
1678,
10153,
353,
13850,
29906,
29889,
21476,
29898,
2492,
29892,
270,
2311,
7607,
1756,
29918,
2311,
29892,
282,
29916,
29918,
2311,
511,
29694,
29922,
11023,
29906,
29889,
23845,
29918,
29907,
7466,
2965,
29897,
13,
462,
1678,
565,
7431,
29898,
2492,
29889,
12181,
29897,
1275,
29871,
29906,
29901,
13,
462,
4706,
10153,
353,
2071,
3027,
29889,
2780,
29889,
21012,
29906,
23973,
29898,
2492,
29897,
13,
462,
1678,
565,
6795,
1275,
29871,
29900,
29901,
13,
462,
4706,
527,
3174,
29918,
5344,
353,
10153,
13,
462,
4706,
1967,
29918,
5325,
29889,
4397,
29898,
9507,
29897,
13,
462,
4706,
6795,
4619,
29871,
29896,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
527,
3174,
29918,
5344,
353,
7442,
29889,
535,
29883,
2579,
403,
3552,
2492,
29879,
29918,
5344,
29892,
10153,
876,
13,
462,
4706,
1967,
29918,
5325,
29889,
4397,
29898,
9507,
29897,
13,
4706,
736,
527,
3174,
29918,
5344,
13,
13,
1678,
396,
6680,
393,
1208,
352,
1078,
278,
2099,
10674,
1965,
1059,
313,
29885,
344,
29897,
1546,
1023,
1967,
13516,
13,
1678,
822,
286,
344,
29898,
3027,
29909,
29892,
1967,
29933,
1125,
13,
4706,
4589,
353,
7442,
29889,
2083,
3552,
3027,
29909,
29889,
579,
668,
703,
7411,
1159,
448,
1967,
29933,
29889,
579,
668,
703,
7411,
5783,
3579,
29871,
29906,
29897,
13,
4706,
4589,
847,
29922,
5785,
29898,
3027,
29909,
29889,
12181,
29961,
29900,
29962,
334,
1967,
29909,
29889,
12181,
29961,
29896,
2314,
13,
4706,
736,
4589,
13,
13,
1678,
396,
6680,
393,
24580,
1023,
9401,
1967,
2066,
322,
1009,
286,
344,
13,
1678,
822,
1510,
29918,
2492,
29918,
1003,
29879,
29898,
3027,
29909,
29892,
1967,
29933,
29892,
4589,
1125,
13,
4706,
2537,
353,
14770,
29889,
4532,
580,
13,
4706,
14770,
29889,
2146,
415,
1740,
703,
29924,
1660,
29901,
18695,
29906,
29888,
29908,
1273,
313,
3127,
876,
13,
4706,
396,
6492,
937,
1967,
13,
4706,
4853,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
29896,
29892,
29871,
29906,
29892,
29871,
29896,
29897,
13,
4706,
14770,
29889,
326,
4294,
29898,
3027,
29909,
29892,
274,
1958,
29922,
572,
29873,
29889,
4912,
29889,
21012,
29897,
13,
4706,
14770,
29889,
8990,
703,
2696,
1159,
13,
4706,
396,
6492,
1473,
1967,
13,
4706,
4853,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
29896,
29892,
29871,
29906,
29892,
29871,
29906,
29897,
13,
4706,
14770,
29889,
326,
4294,
29898,
3027,
29933,
29892,
274,
1958,
29922,
572,
29873,
29889,
4912,
29889,
21012,
29897,
13,
4706,
14770,
29889,
8990,
703,
2696,
1159,
13,
4706,
396,
1510,
278,
4558,
13,
4706,
14770,
29889,
4294,
580,
13,
13,
1678,
396,
6680,
363,
5731,
1218,
385,
1967,
4636,
491,
263,
29871,
29929,
29900,
7426,
10696,
13,
1678,
822,
16734,
29918,
2492,
29898,
3027,
1125,
13,
4706,
1967,
353,
7442,
29889,
5450,
29929,
29900,
29898,
3027,
29892,
413,
29922,
29896,
29892,
27815,
7607,
29900,
29892,
29871,
29896,
876,
13,
4706,
736,
1967,
13,
13,
1678,
396,
6680,
363,
14010,
10422,
5235,
310,
715,
15048,
1967,
2066,
13,
1678,
822,
1510,
29918,
1445,
29918,
3888,
29898,
2388,
1965,
29918,
2492,
29892,
1667,
29918,
2492,
1125,
13,
4706,
1596,
703,
29928,
786,
5926,
934,
29901,
376,
718,
1967,
29918,
5325,
29961,
3396,
29918,
2492,
29962,
718,
376,
322,
376,
718,
1967,
29918,
5325,
29961,
2388,
1965,
29918,
2492,
2314,
13,
13,
1678,
396,
6680,
363,
623,
2548,
4452,
304,
263,
1051,
13,
1678,
822,
788,
29918,
517,
29918,
1761,
29898,
9507,
29892,
1051,
1125,
13,
4706,
1051,
29889,
4397,
29898,
9507,
29897,
13,
13,
1678,
396,
6680,
363,
8454,
278,
11029,
310,
9401,
4558,
29892,
623,
1975,
278,
5224,
11029,
1967,
304,
278,
1051,
13,
1678,
822,
1423,
29918,
2492,
29918,
29567,
29898,
12322,
29892,
1967,
29909,
29892,
1967,
29933,
29892,
1051,
1125,
13,
4706,
3884,
353,
958,
3032,
5014,
29918,
12322,
29898,
12322,
29897,
13,
4706,
2159,
29918,
2492,
29909,
353,
2897,
29889,
6112,
29898,
12322,
718,
1967,
29909,
467,
303,
29918,
2311,
13,
4706,
2159,
29918,
2492,
29933,
353,
2897,
29889,
6112,
29898,
12322,
718,
1967,
29933,
467,
303,
29918,
2311,
13,
4706,
565,
2159,
29918,
2492,
29909,
1405,
2159,
29918,
2492,
29933,
29901,
13,
9651,
958,
29889,
1202,
29918,
517,
29918,
1761,
29898,
3027,
29933,
29892,
1051,
29897,
13,
4706,
1683,
29901,
13,
9651,
958,
29889,
1202,
29918,
517,
29918,
1761,
29898,
3027,
29909,
29892,
1051,
29897,
13,
13,
1678,
822,
5217,
29918,
2492,
29879,
29898,
12322,
29892,
977,
264,
1280,
29918,
842,
1125,
13,
4706,
3884,
353,
958,
3032,
5014,
29918,
12322,
29898,
12322,
29897,
13,
4706,
1596,
14182,
29876,
2772,
1026,
291,
297,
6728,
856,
1159,
13,
4706,
11132,
353,
29871,
29900,
13,
4706,
363,
10422,
297,
977,
264,
1280,
29918,
842,
29901,
13,
9651,
1018,
29901,
13,
18884,
2897,
29889,
5992,
29898,
12322,
718,
10422,
29897,
13,
18884,
1596,
703,
2772,
22742,
934,
29901,
613,
10422,
29897,
13,
18884,
11132,
4619,
29871,
29896,
13,
9651,
5174,
29901,
13,
18884,
1596,
703,
23323,
451,
5217,
934,
29901,
613,
10422,
29897,
13,
4706,
1596,
14182,
29876,
17435,
29905,
29876,
2772,
22742,
613,
11132,
29892,
376,
20908,
15815,
23157,
13,
2
] |
thermof/cli/__init__.py | pzarabadip/thermof | 0 | 1617679 | <reponame>pzarabadip/thermof
"""
Thermof command line interface.
"""
| [
1,
529,
276,
1112,
420,
29958,
29886,
26687,
20143,
666,
29914,
721,
29885,
974,
13,
15945,
29908,
13,
1349,
837,
974,
1899,
1196,
5067,
29889,
13,
15945,
29908,
13,
2
] |
clientlib/utils.py | mesakh123/carla-client | 1 | 90872 | import os
import shutil
from pathlib import Path
def make_dirs(path, clean=True):
if clean and os.path.exists(path):
shutil.rmtree(path)
try:
os.makedirs(path, exist_ok=True)
except FileNotFoundError:
return None
return Path(path) | [
1,
1053,
2897,
13,
5215,
528,
4422,
13,
3166,
2224,
1982,
1053,
10802,
13,
13,
1753,
1207,
29918,
3972,
29879,
29898,
2084,
29892,
5941,
29922,
5574,
1125,
13,
1678,
565,
5941,
322,
2897,
29889,
2084,
29889,
9933,
29898,
2084,
1125,
13,
4706,
528,
4422,
29889,
1758,
8336,
29898,
2084,
29897,
13,
1678,
1018,
29901,
13,
4706,
2897,
29889,
29885,
12535,
12935,
29898,
2084,
29892,
1863,
29918,
554,
29922,
5574,
29897,
13,
1678,
5174,
3497,
17413,
2392,
29901,
13,
4706,
736,
6213,
13,
1678,
736,
10802,
29898,
2084,
29897,
2
] |
config/urls.py | Gabospa/MelodyRest | 0 | 107395 | from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
urlpatterns = [
# Django Admin
path(settings.ADMIN_URL, admin.site.urls),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
| [
1,
515,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
5527,
29889,
26045,
29889,
7959,
1053,
2294,
13,
3166,
9557,
29889,
21570,
1053,
4113,
13,
3166,
9557,
29889,
26045,
1053,
2224,
13,
13,
2271,
11037,
29879,
353,
518,
13,
1678,
396,
15337,
10229,
13,
1678,
2224,
29898,
11027,
29889,
3035,
16173,
29918,
4219,
29892,
4113,
29889,
2746,
29889,
26045,
511,
13,
268,
13,
29962,
718,
2294,
29898,
11027,
29889,
2303,
4571,
29909,
29918,
4219,
29892,
1842,
29918,
4632,
29922,
11027,
29889,
2303,
4571,
29909,
29918,
21289,
29897,
13,
2
] |
mastiff/plugins/analysis/EXE/EXE-singlestring.py | tt1379/mastiff | 164 | 29245 | #!/usr/bin/env python
"""
Copyright 2012-2013 The MASTIFF Project, All Rights Reserved.
This software, having been partly or wholly developed and/or
sponsored by KoreLogic, Inc., is hereby released under the terms
and conditions set forth in the project's "README.LICENSE" file.
For a list of all contributors and sponsors, please refer to the
project's "README.CREDITS" file.
"""
__doc__ = """
Single-byte string plug-in
Plugin Type: EXE
Purpose:
Attackers have begun to obfuscate embedded strings by moving a single byte
at a time into a character array. In assembler, it looks like:
mov mem, 0x68
mov mem+4, 0x69
mov mem+8, 0x21
...
Using a strings program, these strings will not be found. This script looks
for any strings embedded in this way and prints them out. It does this by
looking through the file for C6 opcodes, which are the start of the
"mov mem/reg, imm" instruction. It will then decode it, grab the value and
create a string from it.
Requirements:
- distorm3 (http://code.google.com/p/distorm/)
Output:
None
"""
__version__ = "$Id: 6322146c8d971464c6f726ebdba3a3d7a2540028 $"
import logging
import re
import os
try:
from distorm3 import Decode, Decode32Bits
except ImportError, err:
print "EXE-SingleString: Could not import distorm3: %s" % error
import mastiff.plugins.category.exe as exe
# Change the class name and the base class
class SingleString(exe.EXECat):
"""Extract single-byte strings from an executable."""
def __init__(self):
"""Initialize the plugin."""
exe.EXECat.__init__(self)
self.length = 3
self.raw = False
def activate(self):
"""Activate the plugin."""
exe.EXECat.activate(self)
def deactivate(self):
"""Deactivate the plugin."""
exe.EXECat.deactivate(self)
def findMov(self, filename):
""" look through the file for any c6 opcode (mov reg/mem, imm)
when it finds one, decode it and put it into a dictionary """
#log = logging.getLogger('Mastiff.Plugins.' + self.name + '.findMov')
f = open(filename,'rb')
offset = 0
instructs = {}
mybyte = f.read(1)
while mybyte:
if mybyte == "\xc6":
# found a mov op - decode and record it
f.seek(offset)
mybyte = f.read(16)
# p will come back as list of (offset, size, instruction, hexdump)
p = Decode(offset, mybyte, Decode32Bits)
# break up the mnemonic
ma = re.match('(MOV) ([\S\s]+), ([x0-9a-fA-F]+)', p[0][2])
if ma is not None:
instructs[offset] = [ma.group(1), ma.group(2), ma.group(3), p[0][1]] # mnemonic, size
#log.debug( "MOV instructions detected: %x %s %d" % (offset,p[0][2],p[0][1]) )
f.seek(offset+1)
mybyte = f.read(1)
offset = offset + 1
f.close()
return instructs
def decodeBytes(self, instructs):
""" Take in a dict of instructions - parse through each instruction and grab the strings """
#log = logging.getLogger('Mastiff.Plugins.' + self.name + '.decodeBytes')
curString = ""
curOffset = 0
strList = []
usedBytes = []
for off in sorted(instructs.keys()):
if off not in usedBytes:
# set up the new offset if needed
if curOffset == 0:
curOffset = off
while off in instructs:
usedBytes.append(off)
hexVal = int(instructs[off][2], 16)
opLen = instructs[off][3]
# is hexVal out of range?
if hexVal < 32 or hexVal > 126 and (hexVal != 10 or hexVal != 13 or hexVal != 9):
# end of string
#log.debug("%x non-string char - new string: %d: %s" % (curOffset, hexVal,curString))
strList.append([curOffset, curString])
curOffset = off + opLen
curString = ""
else:
#add to string
if not self.raw and hexVal == 10:
# line feed
curString = curString + "\\r"
elif not self.raw and hexVal == 13:
# return
curString = curString + "\\n"
elif not self.raw and hexVal == 9:
# tab
curString = curString + "\\t"
else:
curString = curString + chr(hexVal)
off = off + opLen
strList.append([curOffset, curString])
curOffset = 0
curString = ""
usedBytes.append(off)
return strList
def analyze(self, config, filename):
"""Analyze the file."""
# sanity check to make sure we can run
if self.is_activated == False:
return False
log = logging.getLogger('Mastiff.Plugins.' + self.name)
log.info('Starting execution.')
self.length = config.get_var(self.name, 'length')
if self.length is None:
self.length = 3
self.raw = config.get_bvar(self.name, 'raw')
# find the bytes in the file
instructs = self.findMov(filename)
# now lets get the strings
strlist = self.decodeBytes(instructs)
self.output_file(config.get_var('Dir','log_dir'), strlist)
return True
def output_file(self, outdir, strlist):
"""Print output from analysis to a file."""
log = logging.getLogger('Mastiff.Plugins.' + self.name + '.output_file')
# if the string is of the right len, print it
outstr = ""
for string in strlist:
if len(string[1]) >= int(self.length):
outstr = outstr + '0x%x: %s\n' % (string[0], string[1])
if len(outstr) > 0:
try:
outfile = open(outdir + os.sep + 'single-string.txt', 'w')
except IOError, err:
log.debug("Cannot open single-string.txt: %s" % err)
return False
outfile.write(outstr)
outfile.close()
else:
log.debug('No single-byte strings found.')
return True
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
15945,
29908,
13,
29871,
14187,
1266,
29871,
29906,
29900,
29896,
29906,
29899,
29906,
29900,
29896,
29941,
450,
14861,
1254,
29902,
4198,
8010,
29892,
2178,
26863,
2538,
9841,
29889,
13,
13,
29871,
910,
7047,
29892,
2534,
1063,
22669,
470,
377,
18368,
8906,
322,
29914,
272,
13,
29871,
21955,
4395,
491,
11354,
3403,
293,
29892,
9266,
1696,
338,
1244,
1609,
5492,
1090,
278,
4958,
13,
29871,
322,
5855,
731,
11483,
297,
278,
2060,
29915,
29879,
376,
16310,
2303,
29889,
27888,
1430,
1660,
29908,
934,
29889,
13,
29871,
1152,
263,
1051,
310,
599,
17737,
29560,
322,
21955,
943,
29892,
3113,
2737,
304,
278,
13,
29871,
2060,
29915,
29879,
376,
16310,
2303,
29889,
29907,
19386,
1806,
29903,
29908,
934,
29889,
13,
15945,
29908,
13,
13,
1649,
1514,
1649,
353,
9995,
13,
15771,
29899,
10389,
1347,
18665,
29899,
262,
13,
13,
16288,
5167,
29901,
8528,
29923,
13,
29925,
332,
4220,
29901,
13,
13,
4165,
547,
414,
505,
23580,
304,
704,
29888,
22142,
403,
15685,
6031,
491,
8401,
263,
2323,
7023,
13,
271,
263,
931,
964,
263,
2931,
1409,
29889,
512,
24367,
1358,
29892,
372,
3430,
763,
29901,
13,
13,
13529,
2626,
29892,
29871,
29900,
29916,
29953,
29947,
13,
13529,
2626,
29974,
29946,
29892,
29871,
29900,
29916,
29953,
29929,
13,
13529,
2626,
29974,
29947,
29892,
29871,
29900,
29916,
29906,
29896,
13,
856,
13,
13,
15156,
263,
6031,
1824,
29892,
1438,
6031,
674,
451,
367,
1476,
29889,
910,
2471,
3430,
13,
1454,
738,
6031,
15685,
297,
445,
982,
322,
14677,
963,
714,
29889,
29871,
739,
947,
445,
491,
13,
23261,
1549,
278,
934,
363,
315,
29953,
1015,
18137,
29892,
607,
526,
278,
1369,
310,
278,
13,
29908,
13529,
2626,
29914,
1727,
29892,
5198,
29908,
15278,
29889,
29871,
739,
674,
769,
21822,
372,
29892,
17229,
278,
995,
322,
13,
3258,
263,
1347,
515,
372,
29889,
13,
13,
1123,
1548,
1860,
29901,
13,
29899,
1320,
555,
29941,
313,
1124,
597,
401,
29889,
3608,
29889,
510,
29914,
29886,
29914,
5721,
555,
4551,
13,
13,
6466,
29901,
13,
259,
6213,
13,
13,
15945,
29908,
13,
13,
1649,
3259,
1649,
353,
3908,
1204,
29901,
29871,
29953,
29941,
29906,
29906,
29896,
29946,
29953,
29883,
29947,
29881,
29929,
29955,
29896,
29946,
29953,
29946,
29883,
29953,
29888,
29955,
29906,
29953,
774,
29881,
2291,
29941,
29874,
29941,
29881,
29955,
29874,
29906,
29945,
29946,
29900,
29900,
29906,
29947,
395,
29908,
13,
13,
5215,
12183,
13,
5215,
337,
13,
5215,
2897,
13,
13,
2202,
29901,
13,
1678,
515,
1320,
555,
29941,
1053,
897,
401,
29892,
897,
401,
29941,
29906,
29933,
1169,
13,
19499,
16032,
2392,
29892,
4589,
29901,
13,
1678,
1596,
376,
5746,
29923,
29899,
15771,
1231,
29901,
6527,
451,
1053,
1320,
555,
29941,
29901,
1273,
29879,
29908,
1273,
1059,
13,
268,
13,
5215,
286,
579,
2593,
29889,
12800,
29889,
7320,
29889,
8097,
408,
429,
29872,
13,
13,
29937,
10726,
278,
770,
1024,
322,
278,
2967,
770,
13,
1990,
16740,
1231,
29898,
8097,
29889,
5746,
29923,
9694,
1125,
13,
1678,
9995,
5647,
1461,
2323,
29899,
10389,
6031,
515,
385,
16813,
1213,
15945,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
9995,
6644,
6646,
278,
7079,
1213,
15945,
13,
4706,
429,
29872,
29889,
5746,
29923,
9694,
17255,
2344,
12035,
1311,
29897,
13,
4706,
1583,
29889,
2848,
353,
29871,
29941,
13,
4706,
1583,
29889,
1610,
353,
7700,
13,
13,
1678,
822,
5039,
403,
29898,
1311,
1125,
13,
4706,
9995,
21786,
403,
278,
7079,
1213,
15945,
13,
4706,
429,
29872,
29889,
5746,
29923,
9694,
29889,
11236,
403,
29898,
1311,
29897,
13,
13,
1678,
822,
316,
11236,
403,
29898,
1311,
1125,
13,
4706,
9995,
2772,
11236,
403,
278,
7079,
1213,
15945,
13,
4706,
429,
29872,
29889,
5746,
29923,
9694,
29889,
311,
11236,
403,
29898,
1311,
29897,
13,
13,
1678,
822,
1284,
29924,
586,
29898,
1311,
29892,
10422,
1125,
13,
4706,
9995,
1106,
1549,
278,
934,
363,
738,
274,
29953,
1015,
401,
313,
13529,
1072,
29914,
6954,
29892,
5198,
29897,
13,
4706,
746,
372,
14061,
697,
29892,
21822,
372,
322,
1925,
372,
964,
263,
8600,
9995,
13,
4706,
396,
1188,
353,
12183,
29889,
657,
16363,
877,
29924,
579,
2593,
29889,
3247,
8385,
6169,
718,
1583,
29889,
978,
718,
15300,
2886,
29924,
586,
1495,
13,
13,
4706,
285,
353,
1722,
29898,
9507,
5501,
6050,
1495,
13,
4706,
9210,
353,
29871,
29900,
308,
13,
4706,
18690,
29879,
353,
6571,
13,
13,
4706,
590,
10389,
353,
285,
29889,
949,
29898,
29896,
29897,
13,
13,
4706,
1550,
590,
10389,
29901,
13,
9651,
565,
590,
10389,
1275,
6634,
21791,
29953,
1115,
13,
18884,
396,
1476,
263,
2351,
1015,
448,
21822,
322,
2407,
372,
13,
18884,
285,
29889,
344,
1416,
29898,
10289,
29897,
13,
18884,
590,
10389,
353,
285,
29889,
949,
29898,
29896,
29953,
29897,
13,
18884,
396,
282,
674,
2041,
1250,
408,
1051,
310,
313,
10289,
29892,
2159,
29892,
15278,
29892,
15090,
15070,
29897,
13,
18884,
282,
353,
897,
401,
29898,
10289,
29892,
590,
10389,
29892,
897,
401,
29941,
29906,
29933,
1169,
29897,
13,
13,
18884,
396,
2867,
701,
278,
286,
15344,
8927,
13,
18884,
611,
353,
337,
29889,
4352,
877,
29898,
6720,
29963,
29897,
313,
7110,
29903,
29905,
29879,
10062,
511,
9310,
29916,
29900,
29899,
29929,
29874,
29899,
29888,
29909,
29899,
29943,
10062,
29897,
742,
282,
29961,
29900,
3816,
29906,
2314,
13,
18884,
565,
611,
338,
451,
6213,
29901,
13,
462,
1678,
18690,
29879,
29961,
10289,
29962,
353,
518,
655,
29889,
2972,
29898,
29896,
511,
611,
29889,
2972,
29898,
29906,
511,
611,
29889,
2972,
29898,
29941,
511,
282,
29961,
29900,
3816,
29896,
5262,
396,
286,
15344,
8927,
29892,
2159,
13,
13,
18884,
396,
1188,
29889,
8382,
29898,
376,
6720,
29963,
11994,
17809,
29901,
1273,
29916,
1273,
29879,
1273,
29881,
29908,
1273,
313,
10289,
29892,
29886,
29961,
29900,
3816,
29906,
1402,
29886,
29961,
29900,
3816,
29896,
2314,
1723,
13,
13,
18884,
285,
29889,
344,
1416,
29898,
10289,
29974,
29896,
29897,
13,
13,
9651,
590,
10389,
353,
285,
29889,
949,
29898,
29896,
29897,
13,
9651,
9210,
353,
9210,
718,
29871,
29896,
13,
13,
4706,
285,
29889,
5358,
580,
13,
4706,
736,
18690,
29879,
13,
13,
1678,
822,
21822,
11207,
29898,
1311,
29892,
18690,
29879,
1125,
13,
4706,
9995,
11190,
297,
263,
9657,
310,
11994,
448,
6088,
1549,
1269,
15278,
322,
17229,
278,
6031,
9995,
13,
4706,
396,
1188,
353,
12183,
29889,
657,
16363,
877,
29924,
579,
2593,
29889,
3247,
8385,
6169,
718,
1583,
29889,
978,
718,
15300,
13808,
11207,
1495,
13,
13,
4706,
3151,
1231,
353,
5124,
13,
4706,
3151,
10302,
353,
29871,
29900,
13,
4706,
851,
1293,
353,
5159,
13,
4706,
1304,
11207,
353,
5159,
13,
13,
4706,
363,
1283,
297,
12705,
29898,
2611,
1247,
29879,
29889,
8149,
580,
1125,
13,
13,
9651,
565,
1283,
451,
297,
1304,
11207,
29901,
13,
18884,
396,
731,
701,
278,
716,
9210,
565,
4312,
13,
18884,
565,
3151,
10302,
1275,
29871,
29900,
29901,
13,
462,
1678,
3151,
10302,
353,
1283,
13,
13,
18884,
1550,
1283,
297,
18690,
29879,
29901,
13,
462,
1678,
1304,
11207,
29889,
4397,
29898,
2696,
29897,
13,
462,
1678,
15090,
1440,
353,
938,
29898,
2611,
1247,
29879,
29961,
2696,
3816,
29906,
1402,
29871,
29896,
29953,
29897,
13,
462,
1678,
1015,
21515,
353,
18690,
29879,
29961,
2696,
3816,
29941,
29962,
13,
13,
462,
1678,
396,
338,
15090,
1440,
714,
310,
3464,
29973,
13,
462,
1678,
565,
15090,
1440,
529,
29871,
29941,
29906,
470,
15090,
1440,
1405,
29871,
29896,
29906,
29953,
322,
313,
20970,
1440,
2804,
29871,
29896,
29900,
470,
15090,
1440,
2804,
29871,
29896,
29941,
470,
15090,
1440,
2804,
29871,
29929,
1125,
13,
462,
4706,
396,
1095,
310,
1347,
13,
462,
4706,
396,
1188,
29889,
8382,
11702,
29916,
1661,
29899,
1807,
1373,
448,
716,
1347,
29901,
1273,
29881,
29901,
1273,
29879,
29908,
1273,
313,
2764,
10302,
29892,
15090,
1440,
29892,
2764,
1231,
876,
13,
462,
4706,
851,
1293,
29889,
4397,
4197,
2764,
10302,
29892,
3151,
1231,
2314,
13,
462,
4706,
3151,
10302,
353,
1283,
718,
1015,
21515,
13,
462,
4706,
3151,
1231,
353,
5124,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
396,
1202,
304,
1347,
13,
462,
4706,
565,
451,
1583,
29889,
1610,
322,
15090,
1440,
1275,
29871,
29896,
29900,
29901,
13,
462,
9651,
396,
1196,
8343,
13,
462,
9651,
3151,
1231,
353,
3151,
1231,
718,
376,
1966,
29878,
29908,
13,
462,
4706,
25342,
451,
1583,
29889,
1610,
322,
15090,
1440,
1275,
29871,
29896,
29941,
29901,
13,
462,
9651,
396,
736,
13,
462,
9651,
3151,
1231,
353,
3151,
1231,
718,
376,
1966,
29876,
29908,
13,
462,
4706,
25342,
451,
1583,
29889,
1610,
322,
15090,
1440,
1275,
29871,
29929,
29901,
13,
462,
9651,
396,
4434,
13,
462,
9651,
3151,
1231,
353,
3151,
1231,
718,
376,
1966,
29873,
29908,
13,
462,
4706,
1683,
29901,
13,
462,
9651,
3151,
1231,
353,
3151,
1231,
718,
18460,
29898,
20970,
1440,
29897,
13,
13,
462,
1678,
1283,
353,
1283,
718,
1015,
21515,
13,
13,
18884,
851,
1293,
29889,
4397,
4197,
2764,
10302,
29892,
3151,
1231,
2314,
13,
18884,
3151,
10302,
353,
29871,
29900,
13,
18884,
3151,
1231,
353,
5124,
13,
13,
9651,
1304,
11207,
29889,
4397,
29898,
2696,
29897,
13,
13,
4706,
736,
851,
1293,
13,
13,
1678,
822,
27599,
29898,
1311,
29892,
2295,
29892,
10422,
1125,
13,
4706,
9995,
2744,
14997,
911,
278,
934,
1213,
15945,
13,
13,
4706,
396,
9753,
537,
1423,
304,
1207,
1854,
591,
508,
1065,
13,
4706,
565,
1583,
29889,
275,
29918,
11236,
630,
1275,
7700,
29901,
13,
9651,
736,
7700,
13,
4706,
1480,
353,
12183,
29889,
657,
16363,
877,
29924,
579,
2593,
29889,
3247,
8385,
6169,
718,
1583,
29889,
978,
29897,
13,
4706,
1480,
29889,
3888,
877,
4763,
292,
8225,
29889,
1495,
13,
13,
4706,
1583,
29889,
2848,
353,
2295,
29889,
657,
29918,
1707,
29898,
1311,
29889,
978,
29892,
525,
2848,
1495,
13,
4706,
565,
1583,
29889,
2848,
338,
6213,
29901,
13,
9651,
1583,
29889,
2848,
353,
29871,
29941,
13,
13,
4706,
1583,
29889,
1610,
353,
2295,
29889,
657,
29918,
29890,
1707,
29898,
1311,
29889,
978,
29892,
525,
1610,
1495,
13,
13,
4706,
396,
1284,
278,
6262,
297,
278,
934,
13,
4706,
18690,
29879,
353,
1583,
29889,
2886,
29924,
586,
29898,
9507,
29897,
13,
13,
4706,
396,
1286,
16869,
679,
278,
6031,
13,
4706,
851,
1761,
353,
1583,
29889,
13808,
11207,
29898,
2611,
1247,
29879,
29897,
13,
13,
4706,
1583,
29889,
4905,
29918,
1445,
29898,
2917,
29889,
657,
29918,
1707,
877,
9170,
3788,
1188,
29918,
3972,
5477,
851,
1761,
29897,
13,
13,
4706,
736,
5852,
13,
13,
1678,
822,
1962,
29918,
1445,
29898,
1311,
29892,
714,
3972,
29892,
851,
1761,
1125,
13,
4706,
9995,
11816,
1962,
515,
7418,
304,
263,
934,
1213,
15945,
13,
4706,
1480,
353,
12183,
29889,
657,
16363,
877,
29924,
579,
2593,
29889,
3247,
8385,
6169,
718,
1583,
29889,
978,
718,
15300,
4905,
29918,
1445,
1495,
13,
13,
4706,
396,
565,
278,
1347,
338,
310,
278,
1492,
7431,
29892,
1596,
372,
13,
4706,
714,
710,
353,
5124,
13,
4706,
363,
1347,
297,
851,
1761,
29901,
13,
9651,
565,
7431,
29898,
1807,
29961,
29896,
2314,
6736,
938,
29898,
1311,
29889,
2848,
1125,
13,
18884,
714,
710,
353,
714,
710,
718,
525,
29900,
29916,
29995,
29916,
29901,
1273,
29879,
29905,
29876,
29915,
1273,
313,
1807,
29961,
29900,
1402,
1347,
29961,
29896,
2314,
13,
13,
4706,
565,
7431,
29898,
449,
710,
29897,
1405,
29871,
29900,
29901,
13,
9651,
1018,
29901,
13,
18884,
714,
1445,
353,
1722,
29898,
449,
3972,
718,
2897,
29889,
19570,
718,
525,
14369,
29899,
1807,
29889,
3945,
742,
525,
29893,
1495,
13,
9651,
5174,
10663,
2392,
29892,
4589,
29901,
13,
18884,
1480,
29889,
8382,
703,
29089,
1722,
2323,
29899,
1807,
29889,
3945,
29901,
1273,
29879,
29908,
1273,
4589,
29897,
13,
18884,
736,
7700,
13,
13,
9651,
714,
1445,
29889,
3539,
29898,
449,
710,
29897,
13,
9651,
714,
1445,
29889,
5358,
580,
13,
4706,
1683,
29901,
13,
9651,
1480,
29889,
8382,
877,
3782,
2323,
29899,
10389,
6031,
1476,
29889,
1495,
13,
13,
4706,
736,
5852,
13,
13,
2
] |
homework/spiny.py | badateverything/python-projects-for-school | 0 | 170415 | <gh_stars>0
import turtle as trtl
trtl.bgcolor("Black")
trtl.pensize(2)
trtl.speed(0)
for i in range(6):
for colors in ["Red", "Green", "Blue", "Purple", ]:
trtl.color(colors)
trtl.circle(100000)
trtl.left(10)
wn = trtl.Screen()
wn.mainloop()
trtl.hideturtle() | [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
260,
4227,
280,
408,
534,
15206,
13,
13,
509,
15206,
29889,
16264,
2780,
703,
18700,
1159,
13,
509,
15206,
29889,
29886,
575,
675,
29898,
29906,
29897,
13,
509,
15206,
29889,
19322,
29898,
29900,
29897,
13,
13,
1454,
474,
297,
3464,
29898,
29953,
1125,
13,
1678,
363,
11955,
297,
6796,
9039,
613,
376,
24599,
613,
376,
21319,
613,
376,
29925,
332,
552,
613,
4514,
29901,
13,
4706,
534,
15206,
29889,
2780,
29898,
27703,
29897,
13,
4706,
534,
15206,
29889,
16622,
29898,
29896,
29900,
29900,
29900,
29900,
29900,
29897,
13,
4706,
534,
15206,
29889,
1563,
29898,
29896,
29900,
29897,
13,
13,
13,
1233,
353,
534,
15206,
29889,
11357,
580,
13,
1233,
29889,
3396,
7888,
580,
13,
13,
13,
509,
15206,
29889,
29882,
333,
300,
4227,
280,
580,
2
] |
test/lexer_test.py | ThomasBollmeier/hackeme-native | 0 | 56190 | <reponame>ThomasBollmeier/hackeme-native
import sys
import unittest
sys.path.insert(0, "../src")
from hackeme.frontend.hackeme_parser import HackemeParser
from komparse.scanner import Scanner
from komparse.char_stream import StringStream
class LexerTest(unittest.TestCase):
def setUp(self):
self.grammar = HackemeParser()._grammar
def tearDown(self):
self.grammar = None
def test_ok(self):
f = open("data/demo.hackeme")
code = f.read()
f.close()
scanner = Scanner(StringStream(code), self.grammar)
while scanner.has_next():
token = scanner.advance()
print(token)
if __name__ == "__main__":
unittest.main() | [
1,
529,
276,
1112,
420,
29958,
1349,
18902,
29933,
3028,
1004,
631,
29914,
29882,
547,
2004,
29899,
11487,
13,
5215,
10876,
13,
5215,
443,
27958,
13,
13,
9675,
29889,
2084,
29889,
7851,
29898,
29900,
29892,
376,
6995,
4351,
1159,
13,
13,
3166,
15833,
2004,
29889,
8862,
355,
29889,
29882,
547,
2004,
29918,
16680,
1053,
379,
547,
2004,
11726,
13,
3166,
4677,
5510,
29889,
1557,
7310,
1053,
23412,
13,
3166,
4677,
5510,
29889,
3090,
29918,
5461,
1053,
1714,
3835,
13,
13,
1990,
15045,
261,
3057,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
268,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
308,
13,
4706,
1583,
29889,
1393,
3034,
353,
379,
547,
2004,
11726,
2141,
29918,
1393,
3034,
13,
308,
13,
1678,
822,
734,
279,
6767,
29898,
1311,
1125,
13,
308,
13,
4706,
1583,
29889,
1393,
3034,
353,
6213,
13,
268,
13,
1678,
822,
1243,
29918,
554,
29898,
1311,
1125,
13,
308,
13,
4706,
285,
353,
1722,
703,
1272,
29914,
17482,
29889,
29882,
547,
2004,
1159,
13,
4706,
775,
353,
285,
29889,
949,
580,
13,
4706,
285,
29889,
5358,
580,
13,
462,
13,
4706,
885,
7310,
353,
23412,
29898,
1231,
3835,
29898,
401,
511,
1583,
29889,
1393,
3034,
29897,
13,
308,
13,
4706,
1550,
885,
7310,
29889,
5349,
29918,
4622,
7295,
13,
9651,
5993,
353,
885,
7310,
29889,
17263,
749,
580,
13,
9651,
1596,
29898,
6979,
29897,
13,
632,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
268,
13,
1678,
443,
27958,
29889,
3396,
580,
2
] |
rl/envs.py | wing3s/pysc2-rl-mini | 25 | 79938 | import yaml
import numpy as np
from os import path
from absl import flags
from pysc2.env import sc2_env
from pysc2.lib import features
from pysc2.lib import actions
sc2_f_path = path.abspath(path.join(path.dirname(__file__), "..", "configs", "sc2_config.yml"))
with open(sc2_f_path, 'r') as ymlfile:
sc2_cfg = yaml.load(ymlfile)
# TODO: update README.md for adding random seed for game env
def create_sc2_minigame_env(map_name, mode, visualize=False):
"""Create sc2 game env with available actions printer
Set screen, minimap same resolution and x, y same pixels for simplicity.
"""
assert mode in ['full', 'lite', 'test']
# workaround for pysc2 flags
FLAGS = flags.FLAGS
FLAGS([__file__])
env_seed = 3 if mode == 'test' else None
env = sc2_env.SC2Env(
map_name=map_name,
step_mul=sc2_cfg[mode]['step_mul'],
screen_size_px=(sc2_cfg[mode]['resl'],) * 2,
minimap_size_px=(sc2_cfg[mode]['resl'],) * 2,
visualize=visualize,
random_seed=env_seed)
return env
# TODO: move preprocess to neuro net embed layer
# TODO: move post process into sc2_env extension
class GameInterfaceHandler(object):
"""Provide game interface info.
Transform observed game image and available actions into CNN input tensors.
- Special Categorial 2d image:
single layer normalized by scalar max
(no same category overlapping)
- Categorial 2d image:
expand to multiple layer
- Scalar 2d image:
single layer normalized by scalar max
NOTE: This class can potentially be a decorator to wrap sc2_env
"""
def __init__(self, mode):
assert mode in ['full', 'lite', 'test']
self.dtype = np.float32
self.minimap_player_id = features.MINIMAP_FEATURES.player_id.index
self.screen_player_id = features.SCREEN_FEATURES.player_id.index
self.screen_unit_type = features.SCREEN_FEATURES.unit_type.index
self.screen_resolution = sc2_cfg[mode]['resl']
self.minimap_resolution = sc2_cfg[mode]['resl']
(self.sub_to_full_acts, self.full_to_sub_acts) = self._get_action_mappings(
sc2_cfg[mode]['action_list'])
self.num_action = len(self.sub_to_full_acts)
self.non_spatial_actions = self._get_non_spatial_actions()
self.screen_imgs = sc2_cfg[mode]['screen_imgs']
self.minimap_imgs = sc2_cfg[mode]['minimap_imgs']
@property
def screen_channels(self):
"""Return number of channels for preprocessed screen image"""
channels = 0
for i, screen_feature in enumerate(features.SCREEN_FEATURES):
if len(self.screen_imgs) > 0 and i not in self.screen_imgs:
continue
if i == self.screen_player_id or i == self.screen_unit_type:
channels += 1
elif screen_feature.type == features.FeatureType.SCALAR:
channels += 1
else:
channels += screen_feature.scale
return channels
def _preprocess_screen(self, screen):
"""Transform screen image into expanded tensor
Args:
screen: obs.observation['screen']
Returns:
ndarray, shape (len(SCREEN_FEATURES), screen_size_px.y, screen_size_px.x)
"""
screen = np.array(screen, dtype=self.dtype)
layers = []
assert screen.shape[0] == len(features.SCREEN_FEATURES)
for i, screen_feature in enumerate(features.SCREEN_FEATURES):
if len(self.screen_imgs) > 0 and i not in self.screen_imgs:
continue
if i == self.screen_player_id or i == self.screen_unit_type:
layers.append(np.log(screen[i:i + 1] + 1.))
elif screen_feature.type == features.FeatureType.SCALAR:
layers.append(np.log(screen[i:i + 1] + 1.))
else:
layer = np.zeros(
(screen_feature.scale, screen.shape[1], screen.shape[2]),
dtype=self.dtype)
for j in range(screen_feature.scale):
indy, indx = (screen[i] == j).nonzero()
layer[j, indy, indx] = 1
layers.append(layer)
return np.concatenate(layers, axis=0)
def get_screen(self, observation):
"""Extract screen variable from observation['minimap']
Args:
observation: Timestep.obervation
Returns:
screen: ndarray, shape (1, len(SCREEN_FEATURES), screen_size_px.y, screen_size_px.x)
"""
screen = self._preprocess_screen(observation['screen'])
return np.expand_dims(screen, 0)
@property
def minimap_channels(self):
"""Return number of channels for preprocessed minimap image"""
channels = 0
for i, minimap_feature in enumerate(features.MINIMAP_FEATURES):
if len(self.minimap_imgs) > 0 and i not in self.minimap_imgs:
continue
if i == self.minimap_player_id:
channels += 1
elif minimap_feature.type == features.FeatureType.SCALAR:
channels += 1
else:
channels += minimap_feature.scale
return channels
def _preprocess_minimap(self, minimap):
"""Transform minimap image into expanded tensor
Args:
minimap: obs.observation['minimap']
Returns:
ndarray, shape (len(MINIMAP_FEATURES), minimap_size_px.y, minimap_size_px.x)
"""
minimap = np.array(minimap, dtype=self.dtype)
layers = []
assert minimap.shape[0] == len(features.MINIMAP_FEATURES)
for i, minimap_feature in enumerate(features.MINIMAP_FEATURES):
if len(self.minimap_imgs) > 0 and i not in self.minimap_imgs:
continue
if i == self.minimap_player_id:
layers.append(np.log(minimap[i:i + 1] + 1.))
elif minimap_feature.type == features.FeatureType.SCALAR:
layers.append(np.log(minimap[i:i + 1] + 1.))
else:
layer = np.zeros(
(minimap_feature.scale, minimap.shape[1], minimap.shape[2]),
dtype=self.dtype)
for j in range(minimap_feature.scale):
indy, indx = (minimap[i] == j).nonzero()
layer[j, indy, indx] = 1
layers.append(layer)
return np.concatenate(layers, axis=0)
def get_minimap(self, observation):
"""Extract minimap variable from observation['minimap']
Args:
observation: Timestep.observation
Returns:
minimap: ndarray, shape (1, len(MINIMAP_FEATURES), minimap_size_px.y, minimap_size_px.x)
"""
minimap = self._preprocess_minimap(observation['minimap'])
return np.expand_dims(minimap, 0)
def _preprocess_available_actions(self, available_actions):
"""Returns ndarray of available_actions from observed['available_actions']
shape (num_actions)
"""
available_actions = np.intersect1d(available_actions, self.sub_to_full_acts)
a_actions = np.zeros((self.num_action), dtype=self.dtype)
a_actions[self.full_to_sub_acts[available_actions]] = 1.
return a_actions
def get_available_actions(self, observation):
"""
Args:
observation: Timestep.observation
Returns:
available_action: ndarray, shape(num_actions)
"""
return self._preprocess_available_actions(
observation['available_actions'])
def get_info(self, observation):
"""Extract available actioins as info from state.observation['available_actioins']
Args:
observation: Timestep.observation
Returns:
info: ndarray, shape (num_actions)
"""
return self.get_available_actions(observation)
def postprocess_action(self, non_spatial_action, spatial_action):
"""Transform selected non_spatial and spatial actions into pysc2 FunctionCall
Args:
non_spatial_action: ndarray, shape (1, 1)
spatial_action: ndarray, shape (1, 1)
Returns:
FunctionCall as action for pysc2_env
"""
act_id = self.sub_to_full_acts[non_spatial_action[0][0]]
target = spatial_action[0][0]
target_point = [
int(target % self.screen_resolution),
int(target // self.screen_resolution)
] # (x, y)
act_args = []
for arg in actions.FUNCTIONS[act_id].args:
if arg.name in ('screen', 'minimap', 'screen2'):
act_args.append(target_point)
else:
act_args.append([0])
return actions.FunctionCall(act_id, act_args)
def _get_non_spatial_actions(self):
non_spatial_actions = [True] * self.num_action
for func_id, func in enumerate(actions.FUNCTIONS):
for arg in func.args:
if arg.name in ('screen', 'minimap', 'screen2'):
non_spatial_actions[self.full_to_sub_acts[func_id]] = False
break
return non_spatial_actions
def is_non_spatial_action(self, action_id):
return self.non_spatial_actions[self.full_to_sub_acts[action_id]]
def _get_action_mappings(self, action_list):
"""Fill actioin list if it's empty
Args:
action_list: list
Returns:
sub_to_full_acts: ndarray
full_to_sub_acts: ndarray
"""
if len(action_list) == 0:
action_list = [i for i in range(len(actions.FUNCTIONS))]
sub_to_full_acts = action_list
full_to_sub_acts = [-1] * len(actions.FUNCTIONS)
for idx, val in enumerate(sub_to_full_acts):
full_to_sub_acts[val] = idx
return (np.asarray(sub_to_full_acts, dtype=np.int32), np.asarray(full_to_sub_acts, dtype=np.int32))
| [
1,
1053,
343,
8807,
13,
5215,
12655,
408,
7442,
13,
3166,
2897,
1053,
2224,
13,
3166,
633,
2536,
1053,
13449,
13,
13,
3166,
282,
952,
29883,
29906,
29889,
6272,
1053,
885,
29906,
29918,
6272,
13,
3166,
282,
952,
29883,
29906,
29889,
1982,
1053,
5680,
13,
3166,
282,
952,
29883,
29906,
29889,
1982,
1053,
8820,
13,
13,
13,
1557,
29906,
29918,
29888,
29918,
2084,
353,
2224,
29889,
370,
1028,
493,
29898,
2084,
29889,
7122,
29898,
2084,
29889,
25721,
22168,
1445,
1649,
511,
376,
636,
613,
376,
2917,
29879,
613,
376,
1557,
29906,
29918,
2917,
29889,
21053,
5783,
13,
2541,
1722,
29898,
1557,
29906,
29918,
29888,
29918,
2084,
29892,
525,
29878,
1495,
408,
343,
828,
1445,
29901,
13,
1678,
885,
29906,
29918,
16859,
353,
343,
8807,
29889,
1359,
29898,
21053,
1445,
29897,
13,
13,
13,
29937,
14402,
29901,
2767,
5195,
3035,
2303,
29889,
3487,
363,
4417,
4036,
16717,
363,
3748,
8829,
13,
1753,
1653,
29918,
1557,
29906,
29918,
1195,
335,
420,
29918,
6272,
29898,
1958,
29918,
978,
29892,
4464,
29892,
7604,
675,
29922,
8824,
1125,
13,
1678,
9995,
4391,
885,
29906,
3748,
8829,
411,
3625,
8820,
23028,
13,
4706,
3789,
4315,
29892,
6260,
481,
1021,
10104,
322,
921,
29892,
343,
1021,
17036,
363,
23205,
29889,
13,
1678,
9995,
13,
1678,
4974,
4464,
297,
6024,
8159,
742,
525,
29880,
568,
742,
525,
1688,
2033,
13,
13,
1678,
396,
14725,
363,
282,
952,
29883,
29906,
13449,
13,
1678,
383,
4375,
10749,
353,
13449,
29889,
18823,
10749,
13,
1678,
383,
4375,
10749,
4197,
1649,
1445,
1649,
2314,
13,
13,
1678,
8829,
29918,
26776,
353,
29871,
29941,
565,
4464,
1275,
525,
1688,
29915,
1683,
6213,
13,
1678,
8829,
353,
885,
29906,
29918,
6272,
29889,
7187,
29906,
21745,
29898,
13,
4706,
2910,
29918,
978,
29922,
1958,
29918,
978,
29892,
13,
4706,
4331,
29918,
16109,
29922,
1557,
29906,
29918,
16859,
29961,
8513,
22322,
10568,
29918,
16109,
7464,
13,
4706,
4315,
29918,
2311,
29918,
1756,
7607,
1557,
29906,
29918,
16859,
29961,
8513,
22322,
690,
29880,
7464,
29897,
334,
29871,
29906,
29892,
13,
4706,
6260,
481,
29918,
2311,
29918,
1756,
7607,
1557,
29906,
29918,
16859,
29961,
8513,
22322,
690,
29880,
7464,
29897,
334,
29871,
29906,
29892,
13,
4706,
7604,
675,
29922,
20119,
675,
29892,
13,
4706,
4036,
29918,
26776,
29922,
6272,
29918,
26776,
29897,
13,
1678,
736,
8829,
13,
13,
13,
29937,
14402,
29901,
4337,
758,
5014,
304,
452,
2192,
7787,
8297,
7546,
13,
29937,
14402,
29901,
4337,
1400,
1889,
964,
885,
29906,
29918,
6272,
6081,
13,
1990,
8448,
10448,
4598,
29898,
3318,
1125,
13,
1678,
9995,
1184,
29894,
680,
3748,
5067,
5235,
29889,
13,
4706,
4103,
689,
8900,
3748,
1967,
322,
3625,
8820,
964,
29696,
1881,
25187,
943,
29889,
13,
13,
4706,
448,
12630,
315,
1845,
9020,
29871,
29906,
29881,
1967,
29901,
13,
9651,
2323,
7546,
4226,
1891,
491,
17336,
4236,
13,
9651,
313,
1217,
1021,
7663,
975,
433,
3262,
29897,
13,
4706,
448,
315,
1845,
9020,
29871,
29906,
29881,
1967,
29901,
13,
9651,
7985,
304,
2999,
7546,
13,
4706,
448,
317,
1052,
279,
29871,
29906,
29881,
1967,
29901,
13,
9651,
2323,
7546,
4226,
1891,
491,
17336,
4236,
13,
13,
4706,
6058,
29923,
29901,
910,
770,
508,
19998,
367,
263,
10200,
1061,
304,
12244,
885,
29906,
29918,
6272,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
4464,
1125,
13,
4706,
4974,
4464,
297,
6024,
8159,
742,
525,
29880,
568,
742,
525,
1688,
2033,
13,
4706,
1583,
29889,
29881,
1853,
353,
7442,
29889,
7411,
29941,
29906,
13,
13,
4706,
1583,
29889,
1195,
326,
481,
29918,
9106,
29918,
333,
353,
5680,
29889,
16173,
2260,
29925,
29918,
16359,
1299,
11499,
29903,
29889,
9106,
29918,
333,
29889,
2248,
13,
4706,
1583,
29889,
10525,
29918,
9106,
29918,
333,
353,
5680,
29889,
7187,
1525,
1430,
29918,
16359,
1299,
11499,
29903,
29889,
9106,
29918,
333,
29889,
2248,
13,
4706,
1583,
29889,
10525,
29918,
5441,
29918,
1853,
353,
5680,
29889,
7187,
1525,
1430,
29918,
16359,
1299,
11499,
29903,
29889,
5441,
29918,
1853,
29889,
2248,
13,
13,
4706,
1583,
29889,
10525,
29918,
9778,
918,
353,
885,
29906,
29918,
16859,
29961,
8513,
22322,
690,
29880,
2033,
13,
4706,
1583,
29889,
1195,
326,
481,
29918,
9778,
918,
353,
885,
29906,
29918,
16859,
29961,
8513,
22322,
690,
29880,
2033,
13,
13,
4706,
313,
1311,
29889,
1491,
29918,
517,
29918,
8159,
29918,
627,
29879,
29892,
1583,
29889,
8159,
29918,
517,
29918,
1491,
29918,
627,
29879,
29897,
353,
1583,
3032,
657,
29918,
2467,
29918,
655,
27775,
29898,
13,
9651,
885,
29906,
29918,
16859,
29961,
8513,
22322,
2467,
29918,
1761,
11287,
13,
4706,
1583,
29889,
1949,
29918,
2467,
353,
7431,
29898,
1311,
29889,
1491,
29918,
517,
29918,
8159,
29918,
627,
29879,
29897,
13,
4706,
1583,
29889,
5464,
29918,
1028,
15238,
29918,
7387,
353,
1583,
3032,
657,
29918,
5464,
29918,
1028,
15238,
29918,
7387,
580,
13,
13,
4706,
1583,
29889,
10525,
29918,
2492,
29879,
353,
885,
29906,
29918,
16859,
29961,
8513,
22322,
10525,
29918,
2492,
29879,
2033,
13,
4706,
1583,
29889,
1195,
326,
481,
29918,
2492,
29879,
353,
885,
29906,
29918,
16859,
29961,
8513,
22322,
1195,
326,
481,
29918,
2492,
29879,
2033,
13,
13,
1678,
732,
6799,
13,
1678,
822,
4315,
29918,
305,
12629,
29898,
1311,
1125,
13,
4706,
9995,
11609,
1353,
310,
18196,
363,
758,
5014,
287,
4315,
1967,
15945,
29908,
13,
4706,
18196,
353,
29871,
29900,
13,
4706,
363,
474,
29892,
4315,
29918,
14394,
297,
26985,
29898,
22100,
29889,
7187,
1525,
1430,
29918,
16359,
1299,
11499,
29903,
1125,
13,
9651,
565,
7431,
29898,
1311,
29889,
10525,
29918,
2492,
29879,
29897,
1405,
29871,
29900,
322,
474,
451,
297,
1583,
29889,
10525,
29918,
2492,
29879,
29901,
13,
18884,
6773,
13,
9651,
565,
474,
1275,
1583,
29889,
10525,
29918,
9106,
29918,
333,
470,
474,
1275,
1583,
29889,
10525,
29918,
5441,
29918,
1853,
29901,
13,
18884,
18196,
4619,
29871,
29896,
13,
9651,
25342,
4315,
29918,
14394,
29889,
1853,
1275,
5680,
29889,
19132,
1542,
29889,
7187,
1964,
1718,
29901,
13,
18884,
18196,
4619,
29871,
29896,
13,
9651,
1683,
29901,
13,
18884,
18196,
4619,
4315,
29918,
14394,
29889,
7052,
13,
4706,
736,
18196,
13,
13,
1678,
822,
903,
1457,
5014,
29918,
10525,
29898,
1311,
29892,
4315,
1125,
13,
4706,
9995,
13372,
4315,
1967,
964,
17832,
12489,
13,
9651,
826,
3174,
29901,
13,
18884,
4315,
29901,
20881,
29889,
26739,
362,
1839,
10525,
2033,
13,
9651,
16969,
29901,
13,
462,
299,
2378,
29892,
8267,
313,
2435,
29898,
7187,
1525,
1430,
29918,
16359,
1299,
11499,
29903,
511,
4315,
29918,
2311,
29918,
1756,
29889,
29891,
29892,
4315,
29918,
2311,
29918,
1756,
29889,
29916,
29897,
13,
4706,
9995,
13,
4706,
4315,
353,
7442,
29889,
2378,
29898,
10525,
29892,
26688,
29922,
1311,
29889,
29881,
1853,
29897,
13,
4706,
15359,
353,
5159,
13,
4706,
4974,
4315,
29889,
12181,
29961,
29900,
29962,
1275,
7431,
29898,
22100,
29889,
7187,
1525,
1430,
29918,
16359,
1299,
11499,
29903,
29897,
13,
4706,
363,
474,
29892,
4315,
29918,
14394,
297,
26985,
29898,
22100,
29889,
7187,
1525,
1430,
29918,
16359,
1299,
11499,
29903,
1125,
13,
9651,
565,
7431,
29898,
1311,
29889,
10525,
29918,
2492,
29879,
29897,
1405,
29871,
29900,
322,
474,
451,
297,
1583,
29889,
10525,
29918,
2492,
29879,
29901,
13,
18884,
6773,
13,
9651,
565,
474,
1275,
1583,
29889,
10525,
29918,
9106,
29918,
333,
470,
474,
1275,
1583,
29889,
10525,
29918,
5441,
29918,
1853,
29901,
13,
18884,
15359,
29889,
4397,
29898,
9302,
29889,
1188,
29898,
10525,
29961,
29875,
29901,
29875,
718,
29871,
29896,
29962,
718,
29871,
29896,
29889,
876,
13,
9651,
25342,
4315,
29918,
14394,
29889,
1853,
1275,
5680,
29889,
19132,
1542,
29889,
7187,
1964,
1718,
29901,
13,
18884,
15359,
29889,
4397,
29898,
9302,
29889,
1188,
29898,
10525,
29961,
29875,
29901,
29875,
718,
29871,
29896,
29962,
718,
29871,
29896,
29889,
876,
13,
9651,
1683,
29901,
13,
18884,
7546,
353,
7442,
29889,
3298,
359,
29898,
13,
462,
1678,
313,
10525,
29918,
14394,
29889,
7052,
29892,
4315,
29889,
12181,
29961,
29896,
1402,
4315,
29889,
12181,
29961,
29906,
11724,
13,
462,
1678,
26688,
29922,
1311,
29889,
29881,
1853,
29897,
13,
18884,
363,
432,
297,
3464,
29898,
10525,
29918,
14394,
29889,
7052,
1125,
13,
462,
1678,
1399,
29891,
29892,
1399,
29916,
353,
313,
10525,
29961,
29875,
29962,
1275,
432,
467,
5464,
9171,
580,
13,
462,
1678,
7546,
29961,
29926,
29892,
1399,
29891,
29892,
1399,
29916,
29962,
353,
29871,
29896,
13,
18884,
15359,
29889,
4397,
29898,
13148,
29897,
13,
4706,
736,
7442,
29889,
535,
29883,
2579,
403,
29898,
29277,
29892,
9685,
29922,
29900,
29897,
13,
13,
1678,
822,
679,
29918,
10525,
29898,
1311,
29892,
15500,
1125,
13,
4706,
9995,
5647,
1461,
4315,
2286,
515,
15500,
1839,
1195,
326,
481,
2033,
13,
9651,
826,
3174,
29901,
13,
18884,
15500,
29901,
7870,
342,
1022,
29889,
4950,
29894,
362,
13,
9651,
16969,
29901,
13,
18884,
4315,
29901,
29871,
299,
2378,
29892,
8267,
313,
29896,
29892,
7431,
29898,
7187,
1525,
1430,
29918,
16359,
1299,
11499,
29903,
511,
4315,
29918,
2311,
29918,
1756,
29889,
29891,
29892,
4315,
29918,
2311,
29918,
1756,
29889,
29916,
29897,
13,
4706,
9995,
13,
4706,
4315,
353,
1583,
3032,
1457,
5014,
29918,
10525,
29898,
26739,
362,
1839,
10525,
11287,
13,
4706,
736,
7442,
29889,
18837,
29918,
6229,
29879,
29898,
10525,
29892,
29871,
29900,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
6260,
481,
29918,
305,
12629,
29898,
1311,
1125,
13,
4706,
9995,
11609,
1353,
310,
18196,
363,
758,
5014,
287,
6260,
481,
1967,
15945,
29908,
13,
4706,
18196,
353,
29871,
29900,
13,
4706,
363,
474,
29892,
6260,
481,
29918,
14394,
297,
26985,
29898,
22100,
29889,
16173,
2260,
29925,
29918,
16359,
1299,
11499,
29903,
1125,
13,
9651,
565,
7431,
29898,
1311,
29889,
1195,
326,
481,
29918,
2492,
29879,
29897,
1405,
29871,
29900,
322,
474,
451,
297,
1583,
29889,
1195,
326,
481,
29918,
2492,
29879,
29901,
13,
18884,
6773,
13,
9651,
565,
474,
1275,
1583,
29889,
1195,
326,
481,
29918,
9106,
29918,
333,
29901,
13,
18884,
18196,
4619,
29871,
29896,
13,
9651,
25342,
6260,
481,
29918,
14394,
29889,
1853,
1275,
5680,
29889,
19132,
1542,
29889,
7187,
1964,
1718,
29901,
13,
18884,
18196,
4619,
29871,
29896,
13,
9651,
1683,
29901,
13,
18884,
18196,
4619,
6260,
481,
29918,
14394,
29889,
7052,
13,
4706,
736,
18196,
13,
13,
1678,
822,
903,
1457,
5014,
29918,
1195,
326,
481,
29898,
1311,
29892,
6260,
481,
1125,
13,
4706,
9995,
13372,
6260,
481,
1967,
964,
17832,
12489,
13,
9651,
826,
3174,
29901,
13,
18884,
6260,
481,
29901,
20881,
29889,
26739,
362,
1839,
1195,
326,
481,
2033,
13,
9651,
16969,
29901,
13,
462,
299,
2378,
29892,
8267,
313,
2435,
29898,
16173,
2260,
29925,
29918,
16359,
1299,
11499,
29903,
511,
6260,
481,
29918,
2311,
29918,
1756,
29889,
29891,
29892,
6260,
481,
29918,
2311,
29918,
1756,
29889,
29916,
29897,
13,
4706,
9995,
13,
4706,
6260,
481,
353,
7442,
29889,
2378,
29898,
1195,
326,
481,
29892,
26688,
29922,
1311,
29889,
29881,
1853,
29897,
13,
4706,
15359,
353,
5159,
13,
4706,
4974,
6260,
481,
29889,
12181,
29961,
29900,
29962,
1275,
7431,
29898,
22100,
29889,
16173,
2260,
29925,
29918,
16359,
1299,
11499,
29903,
29897,
13,
4706,
363,
474,
29892,
6260,
481,
29918,
14394,
297,
26985,
29898,
22100,
29889,
16173,
2260,
29925,
29918,
16359,
1299,
11499,
29903,
1125,
13,
9651,
565,
7431,
29898,
1311,
29889,
1195,
326,
481,
29918,
2492,
29879,
29897,
1405,
29871,
29900,
322,
474,
451,
297,
1583,
29889,
1195,
326,
481,
29918,
2492,
29879,
29901,
13,
18884,
6773,
13,
9651,
565,
474,
1275,
1583,
29889,
1195,
326,
481,
29918,
9106,
29918,
333,
29901,
13,
18884,
15359,
29889,
4397,
29898,
9302,
29889,
1188,
29898,
1195,
326,
481,
29961,
29875,
29901,
29875,
718,
29871,
29896,
29962,
718,
29871,
29896,
29889,
876,
13,
9651,
25342,
6260,
481,
29918,
14394,
29889,
1853,
1275,
5680,
29889,
19132,
1542,
29889,
7187,
1964,
1718,
29901,
13,
18884,
15359,
29889,
4397,
29898,
9302,
29889,
1188,
29898,
1195,
326,
481,
29961,
29875,
29901,
29875,
718,
29871,
29896,
29962,
718,
29871,
29896,
29889,
876,
13,
9651,
1683,
29901,
13,
18884,
7546,
353,
7442,
29889,
3298,
359,
29898,
13,
462,
1678,
313,
1195,
326,
481,
29918,
14394,
29889,
7052,
29892,
6260,
481,
29889,
12181,
29961,
29896,
1402,
6260,
481,
29889,
12181,
29961,
29906,
11724,
13,
462,
1678,
26688,
29922,
1311,
29889,
29881,
1853,
29897,
13,
18884,
363,
432,
297,
3464,
29898,
1195,
326,
481,
29918,
14394,
29889,
7052,
1125,
13,
462,
1678,
1399,
29891,
29892,
1399,
29916,
353,
313,
1195,
326,
481,
29961,
29875,
29962,
1275,
432,
467,
5464,
9171,
580,
13,
462,
1678,
7546,
29961,
29926,
29892,
1399,
29891,
29892,
1399,
29916,
29962,
353,
29871,
29896,
13,
18884,
15359,
29889,
4397,
29898,
13148,
29897,
13,
4706,
736,
7442,
29889,
535,
29883,
2579,
403,
29898,
29277,
29892,
9685,
29922,
29900,
29897,
13,
13,
1678,
822,
679,
29918,
1195,
326,
481,
29898,
1311,
29892,
15500,
1125,
13,
4706,
9995,
5647,
1461,
6260,
481,
2286,
515,
15500,
1839,
1195,
326,
481,
2033,
13,
9651,
826,
3174,
29901,
13,
18884,
15500,
29901,
7870,
342,
1022,
29889,
26739,
362,
13,
9651,
16969,
29901,
13,
18884,
6260,
481,
29901,
29871,
299,
2378,
29892,
8267,
313,
29896,
29892,
7431,
29898,
16173,
2260,
29925,
29918,
16359,
1299,
11499,
29903,
511,
6260,
481,
29918,
2311,
29918,
1756,
29889,
29891,
29892,
6260,
481,
29918,
2311,
29918,
1756,
29889,
29916,
29897,
13,
4706,
9995,
13,
4706,
6260,
481,
353,
1583,
3032,
1457,
5014,
29918,
1195,
326,
481,
29898,
26739,
362,
1839,
1195,
326,
481,
11287,
13,
4706,
736,
7442,
29889,
18837,
29918,
6229,
29879,
29898,
1195,
326,
481,
29892,
29871,
29900,
29897,
13,
13,
1678,
822,
903,
1457,
5014,
29918,
16515,
29918,
7387,
29898,
1311,
29892,
3625,
29918,
7387,
1125,
13,
4706,
9995,
11609,
29879,
29871,
299,
2378,
310,
3625,
29918,
7387,
515,
8900,
1839,
16515,
29918,
7387,
2033,
13,
9651,
8267,
313,
1949,
29918,
7387,
29897,
13,
4706,
9995,
13,
4706,
3625,
29918,
7387,
353,
7442,
29889,
1639,
8803,
29896,
29881,
29898,
16515,
29918,
7387,
29892,
1583,
29889,
1491,
29918,
517,
29918,
8159,
29918,
627,
29879,
29897,
13,
4706,
263,
29918,
7387,
353,
7442,
29889,
3298,
359,
3552,
1311,
29889,
1949,
29918,
2467,
511,
26688,
29922,
1311,
29889,
29881,
1853,
29897,
13,
4706,
263,
29918,
7387,
29961,
1311,
29889,
8159,
29918,
517,
29918,
1491,
29918,
627,
29879,
29961,
16515,
29918,
7387,
5262,
353,
29871,
29896,
29889,
13,
4706,
736,
263,
29918,
7387,
13,
13,
1678,
822,
679,
29918,
16515,
29918,
7387,
29898,
1311,
29892,
15500,
1125,
13,
4706,
9995,
13,
9651,
826,
3174,
29901,
13,
18884,
15500,
29901,
7870,
342,
1022,
29889,
26739,
362,
13,
9651,
16969,
29901,
13,
18884,
3625,
29918,
2467,
29901,
29871,
299,
2378,
29892,
8267,
29898,
1949,
29918,
7387,
29897,
13,
4706,
9995,
13,
4706,
736,
1583,
3032,
1457,
5014,
29918,
16515,
29918,
7387,
29898,
13,
9651,
15500,
1839,
16515,
29918,
7387,
11287,
13,
13,
1678,
822,
679,
29918,
3888,
29898,
1311,
29892,
15500,
1125,
13,
4706,
9995,
5647,
1461,
3625,
1044,
601,
1144,
408,
5235,
515,
2106,
29889,
26739,
362,
1839,
16515,
29918,
627,
601,
1144,
2033,
13,
9651,
826,
3174,
29901,
13,
18884,
15500,
29901,
7870,
342,
1022,
29889,
26739,
362,
13,
9651,
16969,
29901,
13,
18884,
5235,
29901,
29871,
299,
2378,
29892,
8267,
313,
1949,
29918,
7387,
29897,
13,
4706,
9995,
13,
4706,
736,
1583,
29889,
657,
29918,
16515,
29918,
7387,
29898,
26739,
362,
29897,
13,
13,
1678,
822,
1400,
5014,
29918,
2467,
29898,
1311,
29892,
1661,
29918,
1028,
15238,
29918,
2467,
29892,
18652,
29918,
2467,
1125,
13,
4706,
9995,
13372,
4629,
1661,
29918,
1028,
15238,
322,
18652,
8820,
964,
282,
952,
29883,
29906,
6680,
5594,
13,
9651,
826,
3174,
29901,
13,
18884,
1661,
29918,
1028,
15238,
29918,
2467,
29901,
29871,
299,
2378,
29892,
8267,
313,
29896,
29892,
29871,
29896,
29897,
13,
18884,
18652,
29918,
2467,
29901,
29871,
299,
2378,
29892,
8267,
313,
29896,
29892,
29871,
29896,
29897,
13,
9651,
16969,
29901,
13,
18884,
6680,
5594,
408,
3158,
363,
282,
952,
29883,
29906,
29918,
6272,
13,
4706,
9995,
13,
4706,
1044,
29918,
333,
353,
1583,
29889,
1491,
29918,
517,
29918,
8159,
29918,
627,
29879,
29961,
5464,
29918,
1028,
15238,
29918,
2467,
29961,
29900,
3816,
29900,
5262,
13,
4706,
3646,
353,
18652,
29918,
2467,
29961,
29900,
3816,
29900,
29962,
13,
4706,
3646,
29918,
3149,
353,
518,
13,
9651,
938,
29898,
5182,
1273,
1583,
29889,
10525,
29918,
9778,
918,
511,
13,
9651,
938,
29898,
5182,
849,
1583,
29889,
10525,
29918,
9778,
918,
29897,
13,
4706,
4514,
29871,
396,
313,
29916,
29892,
343,
29897,
13,
13,
4706,
1044,
29918,
5085,
353,
5159,
13,
4706,
363,
1852,
297,
8820,
29889,
29943,
28700,
29903,
29961,
627,
29918,
333,
1822,
5085,
29901,
13,
9651,
565,
1852,
29889,
978,
297,
6702,
10525,
742,
525,
1195,
326,
481,
742,
525,
10525,
29906,
29374,
13,
18884,
1044,
29918,
5085,
29889,
4397,
29898,
5182,
29918,
3149,
29897,
13,
9651,
1683,
29901,
13,
18884,
1044,
29918,
5085,
29889,
4397,
4197,
29900,
2314,
13,
4706,
736,
8820,
29889,
6678,
5594,
29898,
627,
29918,
333,
29892,
1044,
29918,
5085,
29897,
13,
13,
1678,
822,
903,
657,
29918,
5464,
29918,
1028,
15238,
29918,
7387,
29898,
1311,
1125,
13,
4706,
1661,
29918,
1028,
15238,
29918,
7387,
353,
518,
5574,
29962,
334,
1583,
29889,
1949,
29918,
2467,
13,
4706,
363,
3653,
29918,
333,
29892,
3653,
297,
26985,
29898,
7387,
29889,
29943,
28700,
29903,
1125,
13,
9651,
363,
1852,
297,
3653,
29889,
5085,
29901,
13,
18884,
565,
1852,
29889,
978,
297,
6702,
10525,
742,
525,
1195,
326,
481,
742,
525,
10525,
29906,
29374,
13,
462,
1678,
1661,
29918,
1028,
15238,
29918,
7387,
29961,
1311,
29889,
8159,
29918,
517,
29918,
1491,
29918,
627,
29879,
29961,
9891,
29918,
333,
5262,
353,
7700,
13,
462,
1678,
2867,
13,
4706,
736,
1661,
29918,
1028,
15238,
29918,
7387,
13,
13,
1678,
822,
338,
29918,
5464,
29918,
1028,
15238,
29918,
2467,
29898,
1311,
29892,
3158,
29918,
333,
1125,
13,
4706,
736,
1583,
29889,
5464,
29918,
1028,
15238,
29918,
7387,
29961,
1311,
29889,
8159,
29918,
517,
29918,
1491,
29918,
627,
29879,
29961,
2467,
29918,
333,
5262,
13,
13,
1678,
822,
903,
657,
29918,
2467,
29918,
655,
27775,
29898,
1311,
29892,
3158,
29918,
1761,
1125,
13,
4706,
9995,
20876,
1044,
601,
262,
1051,
565,
372,
29915,
29879,
4069,
13,
13,
9651,
826,
3174,
29901,
13,
18884,
3158,
29918,
1761,
29901,
1051,
13,
9651,
16969,
29901,
13,
18884,
1014,
29918,
517,
29918,
8159,
29918,
627,
29879,
29901,
29871,
299,
2378,
13,
18884,
2989,
29918,
517,
29918,
1491,
29918,
627,
29879,
29901,
29871,
299,
2378,
13,
4706,
9995,
13,
4706,
565,
7431,
29898,
2467,
29918,
1761,
29897,
1275,
29871,
29900,
29901,
13,
9651,
3158,
29918,
1761,
353,
518,
29875,
363,
474,
297,
3464,
29898,
2435,
29898,
7387,
29889,
29943,
28700,
29903,
28166,
13,
13,
4706,
1014,
29918,
517,
29918,
8159,
29918,
627,
29879,
353,
3158,
29918,
1761,
13,
4706,
2989,
29918,
517,
29918,
1491,
29918,
627,
29879,
353,
21069,
29896,
29962,
334,
7431,
29898,
7387,
29889,
29943,
28700,
29903,
29897,
13,
4706,
363,
22645,
29892,
659,
297,
26985,
29898,
1491,
29918,
517,
29918,
8159,
29918,
627,
29879,
1125,
13,
9651,
2989,
29918,
517,
29918,
1491,
29918,
627,
29879,
29961,
791,
29962,
353,
22645,
13,
4706,
736,
313,
9302,
29889,
294,
2378,
29898,
1491,
29918,
517,
29918,
8159,
29918,
627,
29879,
29892,
26688,
29922,
9302,
29889,
524,
29941,
29906,
511,
7442,
29889,
294,
2378,
29898,
8159,
29918,
517,
29918,
1491,
29918,
627,
29879,
29892,
26688,
29922,
9302,
29889,
524,
29941,
29906,
876,
13,
2
] |
users/views.py | alcibiadesBustillo/twitter_clone | 0 | 198513 | <gh_stars>0
from django.shortcuts import render, redirect
# Create your views here.
from .forms import UserRegisterForm, UserUpdateForm, ProfileUpadteForm
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
def register(request):
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get('username')
messages.success(request, "Account created for {}".format(username))
return redirect('login')
else:
form = UserRegisterForm()
return render(request, 'users/register.html', {'form': form})
@login_required
def profile(request):
if request.method == 'POST':
uform = UserUpdateForm(request.POST, instance=request.user)
pform = ProfileUpadteForm(request.POST, request.FILES, instance=request.user.profile)
if uform.is_valid() and pform.is_valid():
uform.save()
pform.save()
messages.success(request, 'Account has been updated')
return redirect('profile')
else:
uform = UserUpdateForm(instance=request.user)
pform = ProfileUpadteForm(instance=request.user.profile)
return render(request, 'users/profile.html', {'uform': uform, 'pform': pform})
@login_required
def search_view(request):
if request.method == 'POST':
kerko = request.POST.get('search')
print(kerko)
results = User.objects.filter(username__contains=kerko)
context = {
'results': results
}
return render(request, 'users/search_result.html', context)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
9557,
29889,
12759,
7582,
29879,
1053,
4050,
29892,
6684,
13,
13,
29937,
6204,
596,
8386,
1244,
29889,
13,
3166,
869,
9514,
1053,
4911,
15213,
2500,
29892,
4911,
6422,
2500,
29892,
20802,
3373,
328,
371,
2500,
13,
3166,
9557,
29889,
21570,
1053,
7191,
13,
3166,
9557,
29889,
21570,
29889,
5150,
29889,
19557,
4097,
1053,
6464,
29918,
12403,
13,
3166,
9557,
29889,
21570,
29889,
5150,
29889,
9794,
1053,
4911,
13,
13,
1753,
6036,
29898,
3827,
1125,
13,
1678,
565,
2009,
29889,
5696,
1275,
525,
5438,
2396,
13,
4706,
883,
353,
4911,
15213,
2500,
29898,
3827,
29889,
5438,
29897,
13,
4706,
565,
883,
29889,
275,
29918,
3084,
7295,
13,
9651,
883,
29889,
7620,
580,
13,
9651,
8952,
353,
883,
29889,
14941,
287,
29918,
1272,
29889,
657,
877,
6786,
1495,
13,
9651,
7191,
29889,
8698,
29898,
3827,
29892,
376,
10601,
2825,
363,
6571,
1642,
4830,
29898,
6786,
876,
13,
9651,
736,
6684,
877,
7507,
1495,
13,
1678,
1683,
29901,
13,
4706,
883,
353,
4911,
15213,
2500,
580,
13,
1678,
736,
4050,
29898,
3827,
29892,
525,
7193,
29914,
9573,
29889,
1420,
742,
11117,
689,
2396,
883,
1800,
13,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
8722,
29898,
3827,
1125,
13,
1678,
565,
2009,
29889,
5696,
1275,
525,
5438,
2396,
13,
4706,
318,
689,
353,
4911,
6422,
2500,
29898,
3827,
29889,
5438,
29892,
2777,
29922,
3827,
29889,
1792,
29897,
13,
4706,
282,
689,
353,
20802,
3373,
328,
371,
2500,
29898,
3827,
29889,
5438,
29892,
2009,
29889,
24483,
29892,
2777,
29922,
3827,
29889,
1792,
29889,
10185,
29897,
13,
13,
4706,
565,
318,
689,
29889,
275,
29918,
3084,
580,
322,
282,
689,
29889,
275,
29918,
3084,
7295,
13,
9651,
318,
689,
29889,
7620,
580,
13,
9651,
282,
689,
29889,
7620,
580,
13,
9651,
7191,
29889,
8698,
29898,
3827,
29892,
525,
10601,
756,
1063,
4784,
1495,
13,
9651,
736,
6684,
877,
10185,
1495,
13,
1678,
1683,
29901,
13,
4706,
318,
689,
353,
4911,
6422,
2500,
29898,
8758,
29922,
3827,
29889,
1792,
29897,
13,
4706,
282,
689,
353,
20802,
3373,
328,
371,
2500,
29898,
8758,
29922,
3827,
29889,
1792,
29889,
10185,
29897,
13,
1678,
736,
4050,
29898,
3827,
29892,
525,
7193,
29914,
10185,
29889,
1420,
742,
11117,
29884,
689,
2396,
318,
689,
29892,
525,
29886,
689,
2396,
282,
689,
1800,
13,
13,
29992,
7507,
29918,
12403,
13,
1753,
2740,
29918,
1493,
29898,
3827,
1125,
13,
1678,
565,
2009,
29889,
5696,
1275,
525,
5438,
2396,
13,
4706,
13023,
2901,
353,
2009,
29889,
5438,
29889,
657,
877,
4478,
1495,
13,
4706,
1596,
29898,
3946,
2901,
29897,
13,
4706,
2582,
353,
4911,
29889,
12650,
29889,
4572,
29898,
6786,
1649,
11516,
29922,
3946,
2901,
29897,
13,
4706,
3030,
353,
426,
13,
9651,
525,
9902,
2396,
2582,
13,
4706,
500,
13,
4706,
736,
4050,
29898,
3827,
29892,
525,
7193,
29914,
4478,
29918,
2914,
29889,
1420,
742,
3030,
29897,
13,
2
] |
arklibpy/database/ArkDBSQLite.py | fangzhouwang/ArkLibPy | 0 | 124060 | #!/usr/bin/env python3
# Extended from bwDB - CRUD library for sqlite 3 by <NAME> [http://bw.org/]
import sqlite3
import os
__version__ = '1.0.1'
class ArkDBSQLite:
kQUERY_PARAM_PLACE_HOLDER = '?'
def __init__(self, **kwargs):
"""
db = ArkDBSQLite ( [ table = ''] [, filename = ''] )
constructor method
"""
db_config_file = kwargs.get('db_config_file', '')
if db_config_file:
with open(db_config_file) as config:
config.readline().rstrip() # skip host
config.readline().rstrip() # skip user
config.readline().rstrip() # skip password
db_filename = config.readline().rstrip() # use schema name as filename
else:
db_filename = kwargs.get('filename')
self.filepath_ = kwargs.get('db_filepath', '.')
# see filename setter below
self.filename_ = f'{self.filepath_}/{db_filename}'
self.table_ = ''
self.err_ = None
# filename property
@property
def filename_(self):
return self.dbfilename_
@filename_.setter
def filename_(self, fn):
self.dbfilename_ = f'{fn}.sqlite3'
self.con_ = sqlite3.connect(self.dbfilename_)
self.con_.row_factory = sqlite3.Row
@filename_.deleter
def filename_(self):
self.close()
def remove_db_from_disk(self):
os.remove(f'{self.dbfilename_}')
def close(self):
self.con_.close()
del self.dbfilename_
def set_table(self, table_name):
self.table_ = table_name
def get_table(self):
if self.table_ == '' or self.table_ is None:
raise ValueError('no table selected, set_table first')
return self.table_
def set_auto_inc(self, inc):
"""
UPDATE
SQLITE_SEQUENCE
SET
seq = < n > WHERE
name = '<table>'
"""
pass
def get_auto_inc(self):
pass
def run_sql_nocommit(self, sql, params=()):
"""
run_sql_nocommit( sql[, params] )
method for non-select queries *without commit*
sql is string containing SQL
params is list containing parameters
return the cursor of the query
"""
# TODO: Add crash resilient code to recover from a failed query
try:
return self.con_.execute(sql, params)
except sqlite3.Error as err:
self.err_ = err
print('### DB error ###')
print(f'Error msg: {format(err)}')
print('- - - - - - - -')
print(f'SQL: {sql}')
if params:
print('- - - - with params - - - -')
print(params)
print('### END of DB error report ###')
def commit(self):
self.con_.commit()
def get_error(self):
return self.err_
def run_sql(self, sql, params=()):
"""
db.run_sql( sql[, params] )
method for non-select queries
sql is string containing SQL
params is list containing parameters
returns nothing
"""
self.run_sql_nocommit(sql, params)
self.commit()
def run_query_get_all_row(self, query, params=()):
cur = self.run_sql_nocommit(query, params)
return cur.fetchall()
def run_query(self, query, params=()):
"""
db.run_query( query[, params] )
generator method for queries
query is string containing SQL
params is list containing parameters
returns a generator with one row per iteration
each row is a Row factory
"""
cur = self.run_sql_nocommit(query, params)
for row in cur:
yield row
def get_query_row(self, query, params=()):
"""
db.get_query_row( query[, params] )
query for a single row
query is string containing SQL
params is list containing parameters
returns a single row as a Row factory
"""
cur = self.run_sql_nocommit(query, params)
return cur.fetchone()
def get_query_value(self, val_name, query, params=()):
"""
db.get_query_value( query[, params] )
query for a single value
val_name is key to retrieve value
query is string containing SQL
params is list containing parameters
returns a single value
"""
row = self.get_query_row(query, params)
if row is None or val_name not in row.keys():
return None
return row[val_name]
def insert_nocommit(self, rec):
"""
db.insert(rec)
insert a single record into the table
rec is a dict with key/value pairs corresponding to table schema
omit id column to let SQLite generate it
"""
klist = sorted(rec.keys())
values = [rec[v] for v in klist] # a list of values ordered by key
query = 'INSERT INTO {} ({}) VALUES ({})'.format(
self.get_table(),
', '.join(klist),
', '.join(self.kQUERY_PARAM_PLACE_HOLDER * len(values))
)
cur = self.run_sql_nocommit(query, values)
return cur.lastrowid
def insert(self, rec):
lastrowid = self.insert_nocommit(rec)
self.commit()
return lastrowid
def update_nocommit(self, recid, recid_label, rec):
"""
db.update(recid, recid_label, rec)
update a row in the table
recid is the value of the id column for the row to be updated
recid_label is the label of the id column for the row to be updated
rec is a dict with key/value pairs corresponding to table schema
"""
klist = sorted(rec.keys())
values = [rec[v] for v in klist] # a list of values ordered by key
for i, k in enumerate(klist): # don't udpate id
if k == recid_label:
del klist[i]
del values[i]
query = 'UPDATE {} SET {} WHERE {} = {}'.format(
self.get_table(),
', '.join(map(lambda s: '{} = ?'.format(s), klist)),
recid_label,
self.kQUERY_PARAM_PLACE_HOLDER
)
self.run_sql_nocommit(query, values + [recid])
def update(self, recid, recid_label, rec):
self.update_nocommit(recid, recid_label, rec)
self.commit()
def delete_nocommit(self, recid, recid_label):
"""
db.delete(recid, recid_label)
delete a row from the table, by a pair of recid and recid_label
"""
query = f'DELETE FROM {self.get_table()} WHERE {recid_label} = {self.kQUERY_PARAM_PLACE_HOLDER}'
self.run_sql_nocommit(query, [recid])
def delete(self, recid, recid_label):
self.delete_nocommit(recid, recid_label)
self.commit()
def is_table_exist(self, table):
res = self.run_query_get_all_row(f"SELECT name FROM sqlite_master WHERE type = 'table' AND name = '{table}'")
return len(res) != 0
def countrecs(self):
"""
db.countrecs()
count the records in the table
returns a single integer value
"""
query = f'SELECT COUNT(*) AS CNT FROM {self.get_table()}'
return self.get_query_value('CNT', query)
def create_table(self, table_desc_dict, force=False):
if self.is_table_exist(table_desc_dict['table_name']):
if not force:
return False
self.run_sql(f"DROP TABLE {table_desc_dict['table_name']}")
columns_desc_list = [f"`{item['name']}` {item['type']} {item['property']}"
for item in table_desc_dict['table_columns']]
query = f"CREATE TABLE `{table_desc_dict['table_name']}` ("
query += ', '.join(columns_desc_list)
query += ', PRIMARY KEY ('
query += ', '.join([f'`{col}`' for col in table_desc_dict['table_pks']])
query += '))'
self.run_sql(query)
return True
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
29941,
13,
13,
29937,
7338,
2760,
515,
289,
29893,
4051,
448,
15600,
15789,
3489,
363,
21120,
29871,
29941,
491,
529,
5813,
29958,
518,
1124,
597,
29890,
29893,
29889,
990,
29914,
29962,
13,
13,
5215,
21120,
29941,
13,
5215,
2897,
13,
13,
1649,
3259,
1649,
353,
525,
29896,
29889,
29900,
29889,
29896,
29915,
13,
13,
13,
1990,
19444,
4051,
4176,
568,
29901,
13,
1678,
413,
13356,
24422,
29918,
16320,
5194,
29918,
7390,
11538,
29918,
29950,
5607,
8032,
353,
525,
17901,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3579,
19290,
1125,
13,
4706,
9995,
13,
9651,
4833,
353,
19444,
4051,
4176,
568,
313,
518,
1591,
353,
525,
2033,
518,
29892,
10422,
353,
525,
2033,
1723,
13,
9651,
5823,
1158,
13,
4706,
9995,
13,
4706,
4833,
29918,
2917,
29918,
1445,
353,
9049,
5085,
29889,
657,
877,
2585,
29918,
2917,
29918,
1445,
742,
27255,
13,
4706,
565,
4833,
29918,
2917,
29918,
1445,
29901,
13,
9651,
411,
1722,
29898,
2585,
29918,
2917,
29918,
1445,
29897,
408,
2295,
29901,
13,
18884,
2295,
29889,
949,
1220,
2141,
29878,
17010,
580,
29871,
396,
14383,
3495,
13,
18884,
2295,
29889,
949,
1220,
2141,
29878,
17010,
580,
29871,
396,
14383,
1404,
13,
18884,
2295,
29889,
949,
1220,
2141,
29878,
17010,
580,
29871,
396,
14383,
4800,
13,
18884,
4833,
29918,
9507,
353,
2295,
29889,
949,
1220,
2141,
29878,
17010,
580,
396,
671,
10938,
1024,
408,
10422,
13,
4706,
1683,
29901,
13,
9651,
4833,
29918,
9507,
353,
9049,
5085,
29889,
657,
877,
9507,
1495,
13,
13,
4706,
1583,
29889,
1445,
2084,
29918,
353,
9049,
5085,
29889,
657,
877,
2585,
29918,
1445,
2084,
742,
15300,
1495,
13,
4706,
396,
1074,
10422,
731,
357,
2400,
13,
4706,
1583,
29889,
9507,
29918,
353,
285,
29915,
29912,
1311,
29889,
1445,
2084,
29918,
6822,
29912,
2585,
29918,
9507,
10162,
13,
13,
4706,
1583,
29889,
2371,
29918,
353,
6629,
13,
4706,
1583,
29889,
3127,
29918,
353,
6213,
13,
13,
1678,
396,
10422,
2875,
13,
1678,
732,
6799,
13,
1678,
822,
10422,
23538,
1311,
1125,
13,
4706,
736,
1583,
29889,
29881,
1635,
309,
3871,
29918,
13,
13,
1678,
732,
9507,
5396,
842,
357,
13,
1678,
822,
10422,
23538,
1311,
29892,
7876,
1125,
13,
4706,
1583,
29889,
29881,
1635,
309,
3871,
29918,
353,
285,
29915,
29912,
9144,
1836,
22793,
29941,
29915,
13,
4706,
1583,
29889,
535,
29918,
353,
21120,
29941,
29889,
6915,
29898,
1311,
29889,
29881,
1635,
309,
3871,
19925,
13,
4706,
1583,
29889,
535,
5396,
798,
29918,
14399,
353,
21120,
29941,
29889,
4301,
13,
13,
1678,
732,
9507,
5396,
311,
280,
357,
13,
1678,
822,
10422,
23538,
1311,
1125,
13,
4706,
1583,
29889,
5358,
580,
13,
13,
1678,
822,
3349,
29918,
2585,
29918,
3166,
29918,
20960,
29898,
1311,
1125,
13,
4706,
2897,
29889,
5992,
29898,
29888,
29915,
29912,
1311,
29889,
29881,
1635,
309,
3871,
29918,
29913,
1495,
13,
13,
1678,
822,
3802,
29898,
1311,
1125,
13,
4706,
1583,
29889,
535,
5396,
5358,
580,
13,
4706,
628,
1583,
29889,
29881,
1635,
309,
3871,
29918,
13,
13,
1678,
822,
731,
29918,
2371,
29898,
1311,
29892,
1591,
29918,
978,
1125,
13,
4706,
1583,
29889,
2371,
29918,
353,
1591,
29918,
978,
13,
13,
1678,
822,
679,
29918,
2371,
29898,
1311,
1125,
13,
4706,
565,
1583,
29889,
2371,
29918,
1275,
6629,
470,
1583,
29889,
2371,
29918,
338,
6213,
29901,
13,
9651,
12020,
7865,
2392,
877,
1217,
1591,
4629,
29892,
731,
29918,
2371,
937,
1495,
13,
4706,
736,
1583,
29889,
2371,
29918,
13,
13,
1678,
822,
731,
29918,
6921,
29918,
3742,
29898,
1311,
29892,
5528,
1125,
13,
4706,
9995,
13,
4706,
16924,
13,
4706,
3758,
9094,
29918,
1660,
13356,
1430,
4741,
13,
4706,
11368,
13,
4706,
19359,
353,
529,
302,
1405,
5754,
13,
4706,
1024,
353,
12801,
2371,
16299,
13,
4706,
9995,
13,
4706,
1209,
13,
13,
1678,
822,
679,
29918,
6921,
29918,
3742,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
1678,
822,
1065,
29918,
2850,
29918,
1217,
15060,
29898,
1311,
29892,
4576,
29892,
8636,
29922,
580,
1125,
13,
4706,
9995,
13,
9651,
1065,
29918,
2850,
29918,
1217,
15060,
29898,
4576,
21939,
8636,
29962,
1723,
13,
9651,
1158,
363,
1661,
29899,
2622,
9365,
334,
14037,
9063,
29930,
13,
18884,
4576,
338,
1347,
6943,
3758,
13,
18884,
8636,
338,
1051,
6943,
4128,
13,
9651,
736,
278,
10677,
310,
278,
2346,
13,
4706,
9995,
13,
4706,
396,
14402,
29901,
3462,
8095,
620,
309,
993,
775,
304,
9792,
515,
263,
5229,
2346,
13,
4706,
1018,
29901,
13,
9651,
736,
1583,
29889,
535,
5396,
7978,
29898,
2850,
29892,
8636,
29897,
13,
4706,
5174,
21120,
29941,
29889,
2392,
408,
4589,
29901,
13,
9651,
1583,
29889,
3127,
29918,
353,
4589,
13,
9651,
1596,
877,
2277,
29937,
6535,
1059,
835,
1495,
13,
9651,
1596,
29898,
29888,
29915,
2392,
10191,
29901,
426,
4830,
29898,
3127,
2915,
1495,
13,
9651,
1596,
877,
29899,
448,
448,
448,
448,
448,
448,
448,
1495,
13,
9651,
1596,
29898,
29888,
29915,
4176,
29901,
426,
2850,
29913,
1495,
13,
9651,
565,
8636,
29901,
13,
18884,
1596,
877,
29899,
448,
448,
448,
411,
8636,
448,
448,
448,
448,
1495,
13,
18884,
1596,
29898,
7529,
29897,
13,
9651,
1596,
877,
2277,
29937,
11056,
310,
6535,
1059,
3461,
835,
1495,
13,
13,
1678,
822,
9063,
29898,
1311,
1125,
13,
4706,
1583,
29889,
535,
5396,
15060,
580,
13,
13,
1678,
822,
679,
29918,
2704,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
3127,
29918,
13,
13,
1678,
822,
1065,
29918,
2850,
29898,
1311,
29892,
4576,
29892,
8636,
29922,
580,
1125,
13,
4706,
9995,
13,
9651,
4833,
29889,
3389,
29918,
2850,
29898,
4576,
21939,
8636,
29962,
1723,
13,
9651,
1158,
363,
1661,
29899,
2622,
9365,
13,
18884,
4576,
338,
1347,
6943,
3758,
13,
18884,
8636,
338,
1051,
6943,
4128,
13,
9651,
3639,
3078,
13,
4706,
9995,
13,
4706,
1583,
29889,
3389,
29918,
2850,
29918,
1217,
15060,
29898,
2850,
29892,
8636,
29897,
13,
4706,
1583,
29889,
15060,
580,
13,
13,
1678,
822,
1065,
29918,
1972,
29918,
657,
29918,
497,
29918,
798,
29898,
1311,
29892,
2346,
29892,
8636,
29922,
580,
1125,
13,
4706,
3151,
353,
1583,
29889,
3389,
29918,
2850,
29918,
1217,
15060,
29898,
1972,
29892,
8636,
29897,
13,
4706,
736,
3151,
29889,
9155,
497,
580,
13,
13,
1678,
822,
1065,
29918,
1972,
29898,
1311,
29892,
2346,
29892,
8636,
29922,
580,
1125,
13,
4706,
9995,
13,
9651,
4833,
29889,
3389,
29918,
1972,
29898,
2346,
21939,
8636,
29962,
1723,
13,
9651,
15299,
1158,
363,
9365,
13,
18884,
2346,
338,
1347,
6943,
3758,
13,
18884,
8636,
338,
1051,
6943,
4128,
13,
9651,
3639,
263,
15299,
411,
697,
1948,
639,
12541,
13,
9651,
1269,
1948,
338,
263,
11438,
12529,
13,
4706,
9995,
13,
4706,
3151,
353,
1583,
29889,
3389,
29918,
2850,
29918,
1217,
15060,
29898,
1972,
29892,
8636,
29897,
13,
4706,
363,
1948,
297,
3151,
29901,
13,
9651,
7709,
1948,
13,
13,
1678,
822,
679,
29918,
1972,
29918,
798,
29898,
1311,
29892,
2346,
29892,
8636,
29922,
580,
1125,
13,
4706,
9995,
13,
9651,
4833,
29889,
657,
29918,
1972,
29918,
798,
29898,
2346,
21939,
8636,
29962,
1723,
13,
9651,
2346,
363,
263,
2323,
1948,
13,
18884,
2346,
338,
1347,
6943,
3758,
13,
18884,
8636,
338,
1051,
6943,
4128,
13,
9651,
3639,
263,
2323,
1948,
408,
263,
11438,
12529,
13,
4706,
9995,
13,
4706,
3151,
353,
1583,
29889,
3389,
29918,
2850,
29918,
1217,
15060,
29898,
1972,
29892,
8636,
29897,
13,
4706,
736,
3151,
29889,
9155,
650,
580,
13,
13,
1678,
822,
679,
29918,
1972,
29918,
1767,
29898,
1311,
29892,
659,
29918,
978,
29892,
2346,
29892,
8636,
29922,
580,
1125,
13,
4706,
9995,
13,
9651,
4833,
29889,
657,
29918,
1972,
29918,
1767,
29898,
2346,
21939,
8636,
29962,
1723,
13,
9651,
2346,
363,
263,
2323,
995,
13,
18884,
659,
29918,
978,
338,
1820,
304,
10563,
995,
13,
18884,
2346,
338,
1347,
6943,
3758,
13,
18884,
8636,
338,
1051,
6943,
4128,
13,
9651,
3639,
263,
2323,
995,
13,
4706,
9995,
13,
4706,
1948,
353,
1583,
29889,
657,
29918,
1972,
29918,
798,
29898,
1972,
29892,
8636,
29897,
13,
4706,
565,
1948,
338,
6213,
470,
659,
29918,
978,
451,
297,
1948,
29889,
8149,
7295,
13,
9651,
736,
6213,
13,
4706,
736,
1948,
29961,
791,
29918,
978,
29962,
13,
13,
1678,
822,
4635,
29918,
1217,
15060,
29898,
1311,
29892,
1162,
1125,
13,
4706,
9995,
13,
9651,
4833,
29889,
7851,
29898,
3757,
29897,
13,
9651,
4635,
263,
2323,
2407,
964,
278,
1591,
13,
18884,
1162,
338,
263,
9657,
411,
1820,
29914,
1767,
11000,
6590,
304,
1591,
10938,
13,
9651,
288,
2415,
1178,
1897,
304,
1235,
23299,
5706,
372,
13,
4706,
9995,
13,
4706,
413,
1761,
353,
12705,
29898,
3757,
29889,
8149,
3101,
13,
4706,
1819,
353,
518,
3757,
29961,
29894,
29962,
363,
325,
297,
413,
1761,
29962,
29871,
396,
263,
1051,
310,
1819,
10372,
491,
1820,
13,
4706,
2346,
353,
525,
19460,
11646,
6571,
21313,
1800,
15673,
21313,
1800,
4286,
4830,
29898,
13,
9651,
1583,
29889,
657,
29918,
2371,
3285,
13,
9651,
13420,
15300,
7122,
29898,
29895,
1761,
511,
13,
9651,
13420,
15300,
7122,
29898,
1311,
29889,
29895,
13356,
24422,
29918,
16320,
5194,
29918,
7390,
11538,
29918,
29950,
5607,
8032,
334,
7431,
29898,
5975,
876,
13,
4706,
1723,
13,
4706,
3151,
353,
1583,
29889,
3389,
29918,
2850,
29918,
1217,
15060,
29898,
1972,
29892,
1819,
29897,
13,
4706,
736,
3151,
29889,
4230,
798,
333,
13,
13,
1678,
822,
4635,
29898,
1311,
29892,
1162,
1125,
13,
4706,
1833,
798,
333,
353,
1583,
29889,
7851,
29918,
1217,
15060,
29898,
3757,
29897,
13,
4706,
1583,
29889,
15060,
580,
13,
4706,
736,
1833,
798,
333,
13,
13,
1678,
822,
2767,
29918,
1217,
15060,
29898,
1311,
29892,
1162,
333,
29892,
1162,
333,
29918,
1643,
29892,
1162,
1125,
13,
4706,
9995,
13,
9651,
4833,
29889,
5504,
29898,
3757,
333,
29892,
1162,
333,
29918,
1643,
29892,
1162,
29897,
13,
9651,
2767,
263,
1948,
297,
278,
1591,
13,
18884,
1162,
333,
338,
278,
995,
310,
278,
1178,
1897,
363,
278,
1948,
304,
367,
4784,
13,
18884,
1162,
333,
29918,
1643,
338,
278,
3858,
310,
278,
1178,
1897,
363,
278,
1948,
304,
367,
4784,
13,
18884,
1162,
338,
263,
9657,
411,
1820,
29914,
1767,
11000,
6590,
304,
1591,
10938,
13,
4706,
9995,
13,
4706,
413,
1761,
353,
12705,
29898,
3757,
29889,
8149,
3101,
13,
4706,
1819,
353,
518,
3757,
29961,
29894,
29962,
363,
325,
297,
413,
1761,
29962,
29871,
396,
263,
1051,
310,
1819,
10372,
491,
1820,
13,
13,
4706,
363,
474,
29892,
413,
297,
26985,
29898,
29895,
1761,
1125,
29871,
396,
1016,
29915,
29873,
318,
6099,
403,
1178,
13,
9651,
565,
413,
1275,
1162,
333,
29918,
1643,
29901,
13,
18884,
628,
413,
1761,
29961,
29875,
29962,
13,
18884,
628,
1819,
29961,
29875,
29962,
13,
13,
4706,
2346,
353,
525,
14474,
6571,
11368,
6571,
5754,
6571,
353,
6571,
4286,
4830,
29898,
13,
9651,
1583,
29889,
657,
29918,
2371,
3285,
13,
9651,
13420,
29871,
15300,
7122,
29898,
1958,
29898,
2892,
269,
29901,
525,
8875,
353,
1577,
4286,
4830,
29898,
29879,
511,
413,
1761,
8243,
13,
9651,
1162,
333,
29918,
1643,
29892,
13,
9651,
1583,
29889,
29895,
13356,
24422,
29918,
16320,
5194,
29918,
7390,
11538,
29918,
29950,
5607,
8032,
13,
4706,
1723,
13,
4706,
1583,
29889,
3389,
29918,
2850,
29918,
1217,
15060,
29898,
1972,
29892,
1819,
718,
518,
3757,
333,
2314,
13,
13,
1678,
822,
2767,
29898,
1311,
29892,
1162,
333,
29892,
1162,
333,
29918,
1643,
29892,
1162,
1125,
13,
4706,
1583,
29889,
5504,
29918,
1217,
15060,
29898,
3757,
333,
29892,
1162,
333,
29918,
1643,
29892,
1162,
29897,
13,
4706,
1583,
29889,
15060,
580,
13,
13,
1678,
822,
5217,
29918,
1217,
15060,
29898,
1311,
29892,
1162,
333,
29892,
1162,
333,
29918,
1643,
1125,
13,
4706,
9995,
13,
9651,
4833,
29889,
8143,
29898,
3757,
333,
29892,
1162,
333,
29918,
1643,
29897,
13,
9651,
5217,
263,
1948,
515,
278,
1591,
29892,
491,
263,
5101,
310,
1162,
333,
322,
1162,
333,
29918,
1643,
13,
4706,
9995,
13,
4706,
2346,
353,
285,
29915,
2287,
18476,
3895,
426,
1311,
29889,
657,
29918,
2371,
28296,
5754,
426,
3757,
333,
29918,
1643,
29913,
353,
426,
1311,
29889,
29895,
13356,
24422,
29918,
16320,
5194,
29918,
7390,
11538,
29918,
29950,
5607,
8032,
10162,
13,
4706,
1583,
29889,
3389,
29918,
2850,
29918,
1217,
15060,
29898,
1972,
29892,
518,
3757,
333,
2314,
13,
13,
1678,
822,
5217,
29898,
1311,
29892,
1162,
333,
29892,
1162,
333,
29918,
1643,
1125,
13,
4706,
1583,
29889,
8143,
29918,
1217,
15060,
29898,
3757,
333,
29892,
1162,
333,
29918,
1643,
29897,
13,
4706,
1583,
29889,
15060,
580,
13,
13,
1678,
822,
338,
29918,
2371,
29918,
28997,
29898,
1311,
29892,
1591,
1125,
13,
4706,
620,
353,
1583,
29889,
3389,
29918,
1972,
29918,
657,
29918,
497,
29918,
798,
29898,
29888,
29908,
6404,
1024,
3895,
21120,
29918,
6207,
5754,
1134,
353,
525,
2371,
29915,
5300,
1024,
353,
22372,
2371,
10162,
1159,
13,
4706,
736,
7431,
29898,
690,
29897,
2804,
29871,
29900,
13,
13,
1678,
822,
2302,
276,
2395,
29898,
1311,
1125,
13,
4706,
9995,
13,
9651,
4833,
29889,
2798,
276,
2395,
580,
13,
9651,
2302,
278,
6475,
297,
278,
1591,
13,
9651,
3639,
263,
2323,
6043,
995,
13,
4706,
9995,
13,
4706,
2346,
353,
285,
29915,
6404,
21122,
22798,
3339,
315,
20321,
3895,
426,
1311,
29889,
657,
29918,
2371,
580,
10162,
13,
4706,
736,
1583,
29889,
657,
29918,
1972,
29918,
1767,
877,
13778,
29911,
742,
2346,
29897,
13,
13,
1678,
822,
1653,
29918,
2371,
29898,
1311,
29892,
1591,
29918,
14273,
29918,
8977,
29892,
4889,
29922,
8824,
1125,
13,
4706,
565,
1583,
29889,
275,
29918,
2371,
29918,
28997,
29898,
2371,
29918,
14273,
29918,
8977,
1839,
2371,
29918,
978,
2033,
1125,
13,
9651,
565,
451,
4889,
29901,
13,
18884,
736,
7700,
13,
9651,
1583,
29889,
3389,
29918,
2850,
29898,
29888,
29908,
29928,
29366,
10911,
426,
2371,
29918,
14273,
29918,
8977,
1839,
2371,
29918,
978,
2033,
27195,
13,
4706,
4341,
29918,
14273,
29918,
1761,
353,
518,
29888,
6937,
29912,
667,
1839,
978,
2033,
10114,
426,
667,
1839,
1853,
2033,
29913,
426,
667,
1839,
6799,
2033,
5038,
13,
462,
632,
363,
2944,
297,
1591,
29918,
14273,
29918,
8977,
1839,
2371,
29918,
13099,
2033,
29962,
13,
4706,
2346,
353,
285,
29908,
27045,
10911,
23230,
2371,
29918,
14273,
29918,
8977,
1839,
2371,
29918,
978,
2033,
10114,
4852,
13,
4706,
2346,
4619,
13420,
15300,
7122,
29898,
13099,
29918,
14273,
29918,
1761,
29897,
13,
4706,
2346,
4619,
13420,
29778,
14636,
6702,
13,
4706,
2346,
4619,
13420,
15300,
7122,
4197,
29888,
11120,
29912,
1054,
10114,
29915,
363,
784,
297,
1591,
29918,
14273,
29918,
8977,
1839,
2371,
29918,
29886,
2039,
2033,
2314,
13,
4706,
2346,
4619,
525,
876,
29915,
13,
4706,
1583,
29889,
3389,
29918,
2850,
29898,
1972,
29897,
13,
4706,
736,
5852,
13,
2
] |
python/src/nnabla/utils/converter/supported_info.py | daniel-falk/nnabla | 2,792 | 151467 | # Copyright 2018,2019,2020,2021 Sony Corporation.
#
# 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 collections
_SupportedInfo = collections.namedtuple(
'_SupportedInfo', 'import_name export_name')
extensions = _SupportedInfo(import_name=['.nnp', '.onnx', '.ckpt', '.meta', '.pb', 'saved_model', '.tflite'], export_name=[
'.nnp', '.nnb', '.onnx', '.tflite', 'saved_model', '.pb'])
formats = _SupportedInfo(import_name=['NNP', 'ONNX', 'TF_CKPT_V1', 'TF_CKPT_V2', 'TF_PB', 'SAVED_MODEL', 'TFLITE'], export_name=[
'NNP', 'NNB', 'CSRC', 'ONNX', 'SAVED_MODEL', 'TFLITE', 'TF_PB'])
| [
1,
396,
14187,
1266,
29871,
29906,
29900,
29896,
29947,
29892,
29906,
29900,
29896,
29929,
29892,
29906,
29900,
29906,
29900,
29892,
29906,
29900,
29906,
29896,
28465,
15025,
29889,
13,
29937,
13,
29937,
10413,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
29937,
366,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
29937,
887,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
268,
1732,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
29937,
13,
29937,
25870,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
29937,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29937,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
13,
29937,
2823,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
29937,
27028,
1090,
278,
19245,
29889,
13,
13,
5215,
16250,
13,
13,
29918,
14039,
287,
3401,
353,
16250,
29889,
17514,
23583,
29898,
13,
1678,
22868,
14039,
287,
3401,
742,
525,
5215,
29918,
978,
5609,
29918,
978,
1495,
13,
24299,
353,
903,
14039,
287,
3401,
29898,
5215,
29918,
978,
29922,
1839,
29889,
29876,
9302,
742,
15300,
3409,
29916,
742,
15300,
384,
415,
742,
15300,
7299,
742,
15300,
24381,
742,
525,
17314,
29918,
4299,
742,
15300,
29873,
1579,
568,
7464,
5609,
29918,
978,
11759,
13,
462,
9651,
15300,
29876,
9302,
742,
15300,
29876,
9877,
742,
15300,
3409,
29916,
742,
15300,
29873,
1579,
568,
742,
525,
17314,
29918,
4299,
742,
15300,
24381,
11287,
13,
689,
1446,
353,
903,
14039,
287,
3401,
29898,
5215,
29918,
978,
29922,
1839,
10262,
29925,
742,
525,
1164,
29940,
29990,
742,
525,
8969,
29918,
7077,
7982,
29918,
29963,
29896,
742,
525,
8969,
29918,
7077,
7982,
29918,
29963,
29906,
742,
525,
8969,
29918,
29925,
29933,
742,
525,
29903,
7520,
3352,
29918,
20387,
29931,
742,
525,
8969,
29931,
9094,
7464,
5609,
29918,
978,
11759,
13,
462,
308,
525,
10262,
29925,
742,
525,
10262,
29933,
742,
525,
9295,
10363,
742,
525,
1164,
29940,
29990,
742,
525,
29903,
7520,
3352,
29918,
20387,
29931,
742,
525,
8969,
29931,
9094,
742,
525,
8969,
29918,
29925,
29933,
11287,
13,
2
] |
todo/models.py | arthtyagi/gettit | 6 | 162536 | <reponame>arthtyagi/gettit
from django.db import models
from django.urls import reverse
from django.contrib.auth.models import User
class Todo(models.Model):
title = models.CharField(max_length=30)
user = models.ForeignKey(User, on_delete=models.CASCADE)
content= models.CharField(max_length=450,blank=True)
created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('todo:detail', kwargs={'pk': self.pk})
| [
1,
529,
276,
1112,
420,
29958,
28696,
1017,
17698,
29914,
657,
23545,
13,
3166,
9557,
29889,
2585,
1053,
4733,
13,
3166,
9557,
29889,
26045,
1053,
11837,
13,
3166,
9557,
29889,
21570,
29889,
5150,
29889,
9794,
1053,
4911,
13,
13,
1990,
7561,
29877,
29898,
9794,
29889,
3195,
1125,
13,
12,
3257,
353,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29941,
29900,
29897,
13,
12,
1792,
353,
4733,
29889,
27755,
2558,
29898,
2659,
29892,
373,
29918,
8143,
29922,
9794,
29889,
29907,
3289,
5454,
2287,
29897,
13,
12,
3051,
29922,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29946,
29945,
29900,
29892,
19465,
29922,
5574,
29897,
13,
12,
11600,
353,
4733,
29889,
11384,
3073,
29898,
6921,
29918,
3707,
29918,
1202,
29922,
5574,
29897,
13,
13,
12,
1753,
4770,
710,
12035,
1311,
1125,
13,
12,
12,
2457,
1583,
29889,
3257,
13,
13,
12,
1753,
679,
29918,
23552,
29918,
2271,
29898,
1311,
1125,
13,
12,
12,
2457,
11837,
877,
29873,
8144,
29901,
16432,
742,
9049,
5085,
3790,
29915,
20571,
2396,
1583,
29889,
20571,
1800,
13,
2
] |
src/Selenium2Library/__init__.py | tanggai/robotframework_selenium2library | 2 | 71177 | <filename>src/Selenium2Library/__init__.py
import os
from keywords import *
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
execfile(os.path.join(THIS_DIR, 'version.py'))
__version__ = VERSION
class Selenium2Library(
_LoggingKeywords,
_RunOnFailureKeywords,
_BrowserManagementKeywords,
_ElementKeywords,
_TableElementKeywords,
_FormElementKeywords,
_SelectElementKeywords,
_JavaScriptKeywords,
_CookieKeywords,
_ScreenshotKeywords,
_WaitingKeywords
):
"""Selenium2Library is a web testing library for Robot Framework.
It uses the Selenium 2 (WebDriver) libraries internally to control a web browser.
See http://seleniumhq.org/docs/03_webdriver.html for more information on Selenium 2
and WebDriver.
Selenium2Library runs tests in a real browser instance. It should work in
most modern browsers and can be used with both Python and Jython interpreters.
= Before running tests =
Prior to running test cases using Selenium2Library, Selenium2Library must be
imported into your Robot test suite (see `importing` section), and the
`Open Browser` keyword must be used to open a browser to the desired location.
= Locating elements =
All keywords in Selenium2Library that need to find an element on the page
take an argument, `locator`. By default, when a locator value is provided,
it is matched against the key attributes of the particular element type.
For example, `id` and `name` are key attributes to all elements, and
locating elements is easy using just the `id` as a `locator`. For example::
Click Element my_element
It is also possible to specify the approach Selenium2Library should take
to find an element by specifying a lookup strategy with a locator
prefix. Supported strategies are:
| *Strategy* | *Example* | *Description* |
| identifier | Click Element `|` identifier=my_element | Matches by @id or @name attribute |
| id | Click Element `|` id=my_element | Matches by @id attribute |
| name | Click Element `|` name=my_element | Matches by @name attribute |
| xpath | Click Element `|` xpath=//div[@id='my_element'] | Matches with arbitrary XPath expression |
| dom | Click Element `|` dom=document.images[56] | Matches with arbitrary DOM express |
| link | Click Element `|` link=My Link | Matches anchor elements by their link text |
| partial link | Click Element `|` partial link=y Lin | Matches anchor elements by their partial link text |
| css | Click Element `|` css=div.my_class | Matches by CSS selector |
| jquery | Click Element `|` jquery=div.my_class | Matches by jQuery/sizzle selector |
| sizzle | Click Element `|` sizzle=div.my_class | Matches by jQuery/sizzle selector |
| tag | Click Element `|` tag=div | Matches by HTML tag name |
| default* | Click Link `|` default=page?a=b | Matches key attributes with value after first '=' |
* Explicitly specifying the default strategy is only necessary if locating
elements by matching key attributes is desired and an attribute value
contains a '='. The following would fail because it appears as if _page?a_
is the specified lookup strategy:
| Click Link page?a=b
This can be fixed by changing the locator to:
| Click Link default=page?a=b
Table related keywords, such as `Table Should Contain`, work differently.
By default, when a table locator value is provided, it will search for
a table with the specified `id` attribute. For example:
Table Should Contain my_table text
More complex table lookup strategies are also supported:
| *Strategy* | *Example* | *Description* |
| css | Table Should Contain `|` css=table.my_class `|` text | Matches by @id or @name attribute |
| xpath | Table Should Contain `|` xpath=//table/[@name="my_table"] `|` text | Matches by @id or @name attribute |
= Timeouts =
There are several `Wait ...` keywords that take timeout as an
argument. All of these timeout arguments are optional. The timeout
used by all of them can be set globally using the
`Set Selenium Timeout` keyword. The same timeout also applies to
`Execute Async Javascript`.
All timeouts can be given as numbers considered seconds (e.g. 0.5 or 42)
or in Robot Framework's time syntax (e.g. '1.5 seconds' or '1 min 30 s').
For more information about the time syntax see:
http://robotframework.googlecode.com/svn/trunk/doc/userguide/RobotFrameworkUserGuide.html#time-format.
"""
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
ROBOT_LIBRARY_VERSION = VERSION
def __init__(self, timeout=5.0, implicit_wait=0.0, run_on_failure='Capture Page Screenshot'):
"""Selenium2Library can be imported with optional arguments.
`timeout` is the default timeout used to wait for all waiting actions.
It can be later set with `Set Selenium Timeout`.
'implicit_wait' is the implicit timeout that Selenium waits when
looking for elements.
It can be later set with `Set Selenium Implicit Wait`.
See `WebDriver: Advanced Usage`__ section of the SeleniumHQ documentation
for more information about WebDriver's implicit wait functionality.
__ http://seleniumhq.org/docs/04_webdriver_advanced.html#explicit-and-implicit-waits
`run_on_failure` specifies the name of a keyword (from any available
libraries) to execute when a Selenium2Library keyword fails. By default
`Capture Page Screenshot` will be used to take a screenshot of the current page.
Using the value "Nothing" will disable this feature altogether. See
`Register Keyword To Run On Failure` keyword for more information about this
functionality.
Examples:
| Library `|` Selenium2Library `|` 15 | # Sets default timeout to 15 seconds |
| Library `|` Selenium2Library `|` 0 `|` 5 | # Sets default timeout to 0 seconds and default implicit_wait to 5 seconds |
| Library `|` Selenium2Library `|` 5 `|` run_on_failure=Log Source | # Sets default timeout to 5 seconds and runs `Log Source` on failure |
| Library `|` Selenium2Library `|` implicit_wait=5 `|` run_on_failure=Log Source | # Sets default implicit_wait to 5 seconds and runs `Log Source` on failure |
| Library `|` Selenium2Library `|` timeout=10 `|` run_on_failure=Nothing | # Sets default timeout to 10 seconds and does nothing on failure |
"""
for base in Selenium2Library.__bases__:
base.__init__(self)
self.set_selenium_timeout(timeout)
self.set_selenium_implicit_wait(implicit_wait)
self.register_keyword_to_run_on_failure(run_on_failure)
| [
1,
529,
9507,
29958,
4351,
29914,
29903,
13462,
29906,
12284,
29914,
1649,
2344,
26914,
2272,
13,
5215,
2897,
30004,
13,
3166,
29361,
1053,
334,
30004,
13,
30004,
13,
4690,
3235,
29918,
9464,
353,
2897,
29889,
2084,
29889,
25721,
29898,
359,
29889,
2084,
29889,
370,
1028,
493,
22168,
1445,
1649,
876,
30004,
13,
4258,
1445,
29898,
359,
29889,
2084,
29889,
7122,
29898,
4690,
3235,
29918,
9464,
29892,
525,
3259,
29889,
2272,
8785,
30004,
13,
30004,
13,
1649,
3259,
1649,
353,
478,
1001,
13381,
30004,
13,
30004,
13,
1990,
317,
13462,
29906,
12284,
29898,
30004,
13,
1678,
903,
3403,
3460,
2558,
9303,
29892,
6756,
13,
1678,
903,
6558,
2951,
24155,
2558,
9303,
29892,
6756,
13,
1678,
903,
21537,
27107,
2558,
9303,
29892,
6756,
13,
1678,
903,
2642,
2558,
9303,
29892,
6756,
13,
1678,
903,
3562,
2642,
2558,
9303,
11167,
13,
1678,
903,
2500,
2642,
2558,
9303,
11167,
13,
1678,
903,
3549,
2642,
2558,
9303,
11167,
13,
1678,
903,
16963,
2558,
9303,
11167,
13,
1678,
903,
24914,
2558,
9303,
11167,
13,
1678,
903,
29903,
24546,
8711,
2558,
9303,
11167,
13,
1678,
903,
15716,
292,
2558,
9303,
30004,
13,
1125,
30004,
13,
1678,
9995,
29903,
13462,
29906,
12284,
338,
263,
1856,
6724,
3489,
363,
6417,
327,
16657,
22993,
13,
30004,
13,
1678,
739,
3913,
278,
317,
13462,
29871,
29906,
313,
3609,
12376,
29897,
9562,
25106,
304,
2761,
263,
1856,
4714,
22993,
13,
1678,
2823,
1732,
597,
27373,
29882,
29939,
29889,
990,
29914,
2640,
29914,
29900,
29941,
29918,
29813,
29889,
1420,
363,
901,
2472,
373,
317,
13462,
29871,
29906,
30004,
13,
1678,
322,
2563,
12376,
22993,
13,
30004,
13,
1678,
317,
13462,
29906,
12284,
6057,
6987,
297,
263,
1855,
4714,
2777,
29889,
739,
881,
664,
297,
30004,
13,
1678,
1556,
5400,
14376,
322,
508,
367,
1304,
411,
1716,
5132,
322,
435,
1656,
5133,
2153,
22993,
13,
30004,
13,
1678,
353,
10949,
2734,
6987,
353,
30004,
13,
30004,
13,
1678,
22096,
304,
2734,
1243,
4251,
773,
317,
13462,
29906,
12284,
29892,
317,
13462,
29906,
12284,
1818,
367,
30004,
13,
1678,
19673,
964,
596,
6417,
327,
1243,
9460,
313,
4149,
421,
5215,
292,
29952,
4004,
511,
322,
278,
6756,
13,
1678,
421,
6585,
27088,
29952,
13553,
1818,
367,
1304,
304,
1722,
263,
4714,
304,
278,
7429,
4423,
22993,
13,
30004,
13,
1678,
353,
5976,
1218,
3161,
353,
30004,
13,
30004,
13,
1678,
2178,
29361,
297,
317,
13462,
29906,
12284,
393,
817,
304,
1284,
385,
1543,
373,
278,
1813,
30004,
13,
1678,
2125,
385,
2980,
29892,
421,
2029,
1061,
1412,
2648,
2322,
29892,
746,
263,
1180,
1061,
995,
338,
4944,
11167,
13,
1678,
372,
338,
19228,
2750,
278,
1820,
8393,
310,
278,
3153,
1543,
1134,
22993,
13,
1678,
1152,
1342,
29892,
421,
333,
29952,
322,
421,
978,
29952,
526,
1820,
8393,
304,
599,
3161,
29892,
322,
30004,
13,
1678,
1180,
1218,
3161,
338,
4780,
773,
925,
278,
421,
333,
29952,
408,
263,
421,
2029,
1061,
1412,
1152,
1342,
1057,
30004,
13,
30004,
13,
1678,
16297,
10619,
29871,
590,
29918,
5029,
30004,
13,
30004,
13,
1678,
739,
338,
884,
1950,
304,
6084,
278,
2948,
317,
13462,
29906,
12284,
881,
2125,
30004,
13,
1678,
304,
1284,
385,
1543,
491,
22146,
263,
16280,
13705,
411,
263,
1180,
1061,
30004,
13,
1678,
10944,
29889,
18601,
287,
16650,
583,
526,
29901,
30004,
13,
30004,
13,
1678,
891,
334,
26910,
29930,
891,
334,
14023,
29930,
462,
1669,
891,
334,
9868,
29930,
462,
462,
259,
891,
30004,
13,
1678,
891,
15882,
891,
16297,
10619,
21839,
29952,
15882,
29922,
1357,
29918,
5029,
891,
14514,
267,
491,
732,
333,
470,
732,
978,
5352,
1669,
891,
30004,
13,
1678,
891,
1178,
308,
891,
16297,
10619,
21839,
29952,
1178,
29922,
1357,
29918,
5029,
308,
891,
14514,
267,
491,
732,
333,
5352,
462,
4706,
891,
30004,
13,
1678,
891,
1024,
539,
891,
16297,
10619,
21839,
29952,
1024,
29922,
1357,
29918,
5029,
539,
891,
14514,
267,
491,
732,
978,
5352,
462,
418,
891,
30004,
13,
1678,
891,
921,
2084,
418,
891,
16297,
10619,
21839,
29952,
921,
2084,
29922,
458,
4563,
17548,
333,
2433,
1357,
29918,
5029,
2033,
891,
14514,
267,
411,
11472,
1060,
2605,
4603,
891,
30004,
13,
1678,
891,
2432,
4706,
891,
16297,
10619,
21839,
29952,
2432,
29922,
3225,
29889,
8346,
29961,
29945,
29953,
29962,
891,
14514,
267,
411,
11472,
12369,
4653,
9651,
891,
30004,
13,
1678,
891,
1544,
539,
891,
16297,
10619,
21839,
29952,
1544,
29922,
3421,
6645,
3986,
891,
14514,
267,
17360,
3161,
491,
1009,
1544,
1426,
418,
891,
30004,
13,
1678,
891,
7687,
1544,
891,
16297,
10619,
21839,
29952,
7687,
1544,
29922,
29891,
4342,
29871,
891,
14514,
267,
17360,
3161,
491,
1009,
7687,
1544,
1426,
891,
30004,
13,
1678,
891,
5997,
4706,
891,
16297,
10619,
21839,
29952,
5997,
29922,
4563,
29889,
1357,
29918,
1990,
418,
891,
14514,
267,
491,
6783,
11764,
462,
308,
891,
30004,
13,
1678,
891,
5804,
268,
891,
16297,
10619,
21839,
29952,
5804,
29922,
4563,
29889,
1357,
29918,
1990,
259,
891,
14514,
267,
491,
6385,
29914,
29879,
4981,
280,
11764,
462,
308,
891,
30004,
13,
1678,
891,
269,
4981,
280,
268,
891,
16297,
10619,
21839,
29952,
269,
4981,
280,
29922,
4563,
29889,
1357,
29918,
1990,
259,
891,
14514,
267,
491,
6385,
29914,
29879,
4981,
280,
11764,
462,
308,
891,
30004,
13,
1678,
891,
4055,
4706,
891,
16297,
10619,
21839,
29952,
4055,
29922,
4563,
1669,
891,
14514,
267,
491,
4544,
4055,
1024,
462,
4706,
891,
30004,
13,
1678,
891,
2322,
29930,
259,
891,
16297,
6645,
1678,
21839,
29952,
2322,
29922,
3488,
29973,
29874,
29922,
29890,
418,
891,
14514,
267,
1820,
8393,
411,
995,
1156,
937,
525,
2433,
891,
30004,
13,
1678,
334,
12027,
4019,
368,
22146,
278,
2322,
13705,
338,
871,
5181,
565,
1180,
1218,
30004,
13,
1678,
3161,
491,
9686,
1820,
8393,
338,
7429,
322,
385,
5352,
995,
30004,
13,
1678,
3743,
263,
525,
2433,
29889,
450,
1494,
723,
4418,
1363,
372,
5692,
408,
565,
903,
3488,
29973,
29874,
29918,
30004,
13,
1678,
338,
278,
6790,
16280,
13705,
29901,
30004,
13,
1678,
891,
16297,
6645,
1678,
1813,
29973,
29874,
29922,
29890,
30004,
13,
1678,
910,
508,
367,
4343,
491,
6480,
278,
1180,
1061,
304,
29901,
30004,
13,
1678,
891,
16297,
6645,
1678,
2322,
29922,
3488,
29973,
29874,
29922,
29890,
30004,
13,
30004,
13,
1678,
6137,
4475,
29361,
29892,
1316,
408,
421,
3562,
10575,
2866,
475,
1673,
664,
17587,
22993,
13,
1678,
2648,
2322,
29892,
746,
263,
1591,
1180,
1061,
995,
338,
4944,
29892,
372,
674,
2740,
363,
30004,
13,
1678,
263,
1591,
411,
278,
6790,
421,
333,
29952,
5352,
29889,
1152,
1342,
29901,
30004,
13,
30004,
13,
1678,
6137,
10575,
2866,
475,
29871,
590,
29918,
2371,
29871,
1426,
30004,
13,
30004,
13,
1678,
5853,
4280,
1591,
16280,
16650,
583,
526,
884,
6969,
29901,
30004,
13,
30004,
13,
1678,
891,
334,
26910,
29930,
891,
334,
14023,
29930,
462,
462,
462,
3986,
891,
334,
9868,
29930,
462,
268,
891,
30004,
13,
1678,
891,
5997,
4706,
891,
6137,
10575,
2866,
475,
21839,
29952,
5997,
29922,
2371,
29889,
1357,
29918,
1990,
21839,
29952,
1426,
1669,
891,
14514,
267,
491,
732,
333,
470,
732,
978,
5352,
891,
30004,
13,
1678,
891,
921,
2084,
418,
891,
6137,
10575,
2866,
475,
21839,
29952,
921,
2084,
29922,
458,
2371,
29914,
17548,
978,
543,
1357,
29918,
2371,
3108,
21839,
29952,
1426,
891,
14514,
267,
491,
732,
333,
470,
732,
978,
5352,
891,
30004,
13,
30004,
13,
1678,
353,
5974,
17718,
353,
30004,
13,
30004,
13,
1678,
1670,
526,
3196,
421,
15716,
2023,
29952,
29361,
393,
2125,
11815,
408,
385,
30004,
13,
1678,
2980,
29889,
2178,
310,
1438,
11815,
6273,
526,
13136,
29889,
450,
11815,
30004,
13,
1678,
1304,
491,
599,
310,
963,
508,
367,
731,
13149,
635,
773,
278,
30004,
13,
1678,
421,
2697,
317,
13462,
5974,
449,
29952,
13553,
29889,
450,
1021,
11815,
884,
16058,
304,
30004,
13,
1678,
421,
12296,
20688,
12728,
1412,
30004,
13,
30004,
13,
1678,
2178,
11815,
29879,
508,
367,
2183,
408,
3694,
5545,
6923,
313,
29872,
29889,
29887,
29889,
29871,
29900,
29889,
29945,
470,
29871,
29946,
29906,
8443,
13,
1678,
470,
297,
6417,
327,
16657,
29915,
29879,
931,
5877,
313,
29872,
29889,
29887,
29889,
525,
29896,
29889,
29945,
6923,
29915,
470,
525,
29896,
1375,
29871,
29941,
29900,
269,
2824,
30004,
13,
1678,
1152,
901,
2472,
1048,
278,
931,
5877,
1074,
29901,
30004,
13,
1678,
1732,
597,
307,
7451,
4468,
29889,
3608,
401,
29889,
510,
29914,
27517,
29914,
509,
2960,
29914,
1514,
29914,
1792,
13075,
29914,
21860,
327,
16660,
2659,
9485,
680,
29889,
1420,
29937,
2230,
29899,
4830,
22993,
13,
1678,
9995,
30004,
13,
30004,
13,
1678,
390,
14824,
2891,
29918,
5265,
15176,
19926,
29918,
29903,
3217,
4162,
353,
525,
29954,
28902,
1964,
29915,
30004,
13,
1678,
390,
14824,
2891,
29918,
5265,
15176,
19926,
29918,
16358,
353,
478,
1001,
13381,
30004,
13,
30004,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
11815,
29922,
29945,
29889,
29900,
29892,
12235,
29918,
10685,
29922,
29900,
29889,
29900,
29892,
1065,
29918,
265,
29918,
14057,
545,
2433,
21133,
545,
9305,
317,
24546,
8711,
29374,
30004,
13,
4706,
9995,
29903,
13462,
29906,
12284,
508,
367,
19673,
411,
13136,
6273,
22993,
13,
30004,
13,
4706,
421,
15619,
29952,
338,
278,
2322,
11815,
1304,
304,
4480,
363,
599,
10534,
8820,
22993,
13,
4706,
739,
508,
367,
2678,
731,
411,
421,
2697,
317,
13462,
5974,
449,
1412,
30004,
13,
30004,
13,
4706,
525,
6574,
4019,
29918,
10685,
29915,
338,
278,
12235,
11815,
393,
317,
13462,
11324,
1169,
746,
30004,
13,
4706,
3063,
363,
3161,
22993,
13,
4706,
739,
508,
367,
2678,
731,
411,
421,
2697,
317,
13462,
14305,
4019,
20340,
1412,
30004,
13,
4706,
2823,
421,
3609,
12376,
29901,
29287,
10783,
482,
29952,
1649,
4004,
310,
278,
317,
13462,
29950,
29984,
5106,
30004,
13,
4706,
363,
901,
2472,
1048,
2563,
12376,
29915,
29879,
12235,
4480,
9863,
22993,
13,
30004,
13,
4706,
4770,
1732,
597,
27373,
29882,
29939,
29889,
990,
29914,
2640,
29914,
29900,
29946,
29918,
29813,
29918,
328,
16858,
29889,
1420,
29937,
4548,
4019,
29899,
392,
29899,
6574,
4019,
29899,
2766,
1169,
30004,
13,
30004,
13,
4706,
421,
3389,
29918,
265,
29918,
14057,
545,
29952,
1580,
11057,
278,
1024,
310,
263,
13553,
313,
3166,
738,
3625,
30004,
13,
4706,
9562,
29897,
304,
6222,
746,
263,
317,
13462,
29906,
12284,
13553,
8465,
29889,
2648,
2322,
30004,
13,
4706,
421,
21133,
545,
9305,
317,
24546,
8711,
29952,
674,
367,
1304,
304,
2125,
263,
17286,
310,
278,
1857,
1813,
22993,
13,
4706,
5293,
278,
995,
376,
26521,
29908,
674,
11262,
445,
4682,
19148,
29889,
2823,
30004,
13,
4706,
421,
15213,
7670,
1742,
1763,
7525,
1551,
29098,
545,
29952,
13553,
363,
901,
2472,
1048,
445,
30004,
13,
4706,
9863,
22993,
13,
30004,
13,
4706,
1222,
9422,
29901,
30004,
13,
4706,
891,
9538,
21839,
29952,
317,
13462,
29906,
12284,
21839,
29952,
29871,
29896,
29945,
462,
462,
9651,
891,
396,
317,
1691,
2322,
11815,
304,
29871,
29896,
29945,
6923,
462,
462,
539,
891,
30004,
13,
4706,
891,
9538,
21839,
29952,
317,
13462,
29906,
12284,
21839,
29952,
29871,
29900,
21839,
29952,
29871,
29945,
462,
462,
539,
891,
396,
317,
1691,
2322,
11815,
304,
29871,
29900,
6923,
322,
2322,
12235,
29918,
10685,
304,
29871,
29945,
6923,
891,
30004,
13,
4706,
891,
9538,
21839,
29952,
317,
13462,
29906,
12284,
21839,
29952,
29871,
29945,
21839,
29952,
1065,
29918,
265,
29918,
14057,
545,
29922,
3403,
7562,
1669,
891,
396,
317,
1691,
2322,
11815,
304,
29871,
29945,
6923,
322,
6057,
421,
3403,
7562,
29952,
373,
10672,
539,
891,
30004,
13,
4706,
891,
9538,
21839,
29952,
317,
13462,
29906,
12284,
21839,
29952,
12235,
29918,
10685,
29922,
29945,
21839,
29952,
1065,
29918,
265,
29918,
14057,
545,
29922,
3403,
7562,
891,
396,
317,
1691,
2322,
12235,
29918,
10685,
304,
29871,
29945,
6923,
322,
6057,
421,
3403,
7562,
29952,
373,
10672,
891,
30004,
13,
4706,
891,
9538,
21839,
29952,
317,
13462,
29906,
12284,
21839,
29952,
11815,
29922,
29896,
29900,
418,
21839,
29952,
1065,
29918,
265,
29918,
14057,
545,
29922,
26521,
1678,
891,
396,
317,
1691,
2322,
11815,
304,
29871,
29896,
29900,
6923,
322,
947,
3078,
373,
10672,
965,
891,
30004,
13,
4706,
9995,
30004,
13,
4706,
363,
2967,
297,
317,
13462,
29906,
12284,
17255,
29890,
2129,
1649,
29901,
30004,
13,
9651,
2967,
17255,
2344,
12035,
1311,
8443,
13,
4706,
1583,
29889,
842,
29918,
27373,
29918,
15619,
29898,
15619,
8443,
13,
4706,
1583,
29889,
842,
29918,
27373,
29918,
6574,
4019,
29918,
10685,
29898,
6574,
4019,
29918,
10685,
8443,
13,
4706,
1583,
29889,
9573,
29918,
26766,
29918,
517,
29918,
3389,
29918,
265,
29918,
14057,
545,
29898,
3389,
29918,
265,
29918,
14057,
545,
8443,
13,
2
] |
tb_houston_service/application_deployment.py | tranquilitybase-io/tb-houston-service | 1 | 175169 | import json
import logging
import os
import time
from pprint import pformat
import requests
from flask import abort, make_response
from config import db, executor
from config.db_lib import db_session
from models import (
Activator,
ActivatorMetadata,
ActivatorMetadataVariable,
Application,
ApplicationDeployment,
ApplicationDeploymentSchema,
LZEnvironment,
LZLanVpc,
LZLanVpcEnvironment,
Solution,
SolutionEnvironment,
SolutionResource,
)
from tb_houston_service import activator_extension, notification, security
from tb_houston_service.DeploymentStatus import DeploymentStatus
from tb_houston_service.extendedSchemas import (
ExtendedApplicationDeploymentSchema,
ExtendedApplicationForDACSchema,
)
from tb_houston_service.tools import ModelTools
logger = logging.getLogger("tb_houston_service.application_deployment")
deployment_create_url = f"http://{os.environ['GCP_DAC_URL']}/dac/application_async/"
deployment_create_result_url = (
f"http://{os.environ['GCP_DAC_URL']}/dac/application_async/result/create/"
)
headers = {"Content-Type": "application/json"}
def notify_user(applicationId):
"""
Notify the user the application deployment has completed.
Args:
applicationId ([int]): [The application id]
"""
with db_session() as dbs:
user = security.get_valid_user_from_token(dbsession=dbs)
logger.debug("user: %s", user)
if user:
(app, app_deploy) = (
dbs.query(Application, ApplicationDeployment)
.filter(
ApplicationDeployment.applicationId == applicationId,
ApplicationDeployment.applicationId == Application.id,
)
.one_or_none()
)
if app:
deploymentState = app_deploy.deploymentState
if deploymentState == DeploymentStatus.SUCCESS:
message = f"Your Application {applicationId} ({app.name}) deployment has completed successfully"
else:
message = f"Your Application {applicationId} ({app.name}) deployment has failed."
payload = {
"isActive": True,
"toUserId": user.id,
"importance": 1,
"message": message,
"isRead": False,
"applicationId": app.id,
}
notification.create(notification=payload, typeId=3, dbsession=dbs)
else:
logger.warning(
"Cannot send notification, unable to find the application (%s).",
app.id,
)
else:
logger.warning("Cannot send notification, unable to validate the token.")
def start_deployment(applicationId):
logger.info("start_deployment::applicationId: %s", applicationId)
# can only deploy an application if the solution it belong's to has already been
# deployed successfully.
with db_session() as dbs:
deployment_complete = False
while deployment_complete is False:
app_dep = (
dbs.query(ApplicationDeployment)
.filter(
ApplicationDeployment.applicationId == applicationId,
ApplicationDeployment.deploymentState.notin_(
(DeploymentStatus.SUCCESS, DeploymentStatus.FAILURE)
),
)
.first()
)
logger.debug("start_deployment::app_dep *** %s", app_dep)
if app_dep:
app_id = app_dep.applicationId
task_id = app_dep.taskId
logger.debug(
"start_deployment: deploymentState: %s, app_id: %s, workspaceProjectId %s, task_id %s",
app_dep.deploymentState,
app_id,
app_dep.workspaceProjectId,
task_id,
)
if task_id is None or task_id == "":
response = deploy_application(app_dep, dbsession=dbs)
dbs.flush()
logger.debug(
"start_deployment::deploy_application: app_id: %s", app_id
)
logger.debug(pformat(response))
else:
logger.debug(
"start_deployment::polling_results_from_the_DaC: app_id: %s task_id: %s",
app_id,
task_id,
)
get_application_results_from_the_dac(
app_id=app_id,
lzEnvId=app_dep.lzEnvironmentId,
task_id=task_id,
dbsession=dbs,
)
dbs.flush()
print("Sleep 2")
time.sleep(2)
else:
deployment_complete = True
logger.debug(
"start_deployment::deployment complete for Application: %s", applicationId
)
notify_user(applicationId=applicationId)
return True
def deployment_create(applicationDeploymentDetails):
"""
This function queries a application forwards the request to the DaC
:param solution: id
:return: 201 on success
: 404 if application not found
: 500 if other failure
"""
logger.debug("deployment_create: %s", pformat(applicationDeploymentDetails))
app_id = applicationDeploymentDetails["id"]
with db_session() as dbs:
app = dbs.query(Application).filter(Application.id == app_id).one_or_none()
if not app:
abort("This application doesn't exist.", 404)
sol = (
dbs.query(Solution)
.filter(Application.id == app_id, Application.solutionId == Solution.id)
.one_or_none()
)
if sol and sol.deploymentState != DeploymentStatus.SUCCESS:
logger.warning(
"Cannot deploy an application if the solution deployment has not completed successfully."
)
abort(
400,
"Cannot deploy an application if the solution deployment has not completed successfully.",
)
sol_envs = (
dbs.query(LZEnvironment)
.filter(
SolutionEnvironment.environmentId == LZEnvironment.id,
SolutionEnvironment.solutionId == sol.id,
SolutionEnvironment.isActive,
LZEnvironment.isActive,
)
.all()
)
for lzenv in sol_envs:
lzenv_app_deployment(lzenv, dbs, sol, app_id, app)
# above db transaction should be complete before the next steps
executor.submit(start_deployment, app_id)
return make_response(
{"id": app_id, "deploymentState": DeploymentStatus.PENDING}, 200
)
def lzenv_app_deployment(lzenv, dbs, sol, app_id, app):
workspace_resource_key = "project-id-workspace"
workspace_resource = (
dbs.query(SolutionResource)
.filter(
SolutionResource.solutionId == sol.id,
SolutionResource.key == workspace_resource_key,
)
.one_or_none()
)
if not workspace_resource:
logger.error(
"deployment_create: This application deployment %s is missing the workspaceProjectId, resourceKey: %s, skipping...",
app_id,
workspace_resource_key,
)
if workspace_resource:
workspaceProjectId = workspace_resource.value
resource_key = f"project-id-{lzenv.name.lower()}"
solution_resource = (
dbs.query(SolutionResource)
.filter(
SolutionResource.solutionId == sol.id,
SolutionResource.key == resource_key,
)
.one_or_none()
)
if not solution_resource:
logger.error(
"deployment_create: This application deployment %s is missing the projectId, resourceKey: %s, skipping...",
app_id,
resource_key,
)
if solution_resource:
projectId = solution_resource.value
app_deployment = (
dbs.query(ApplicationDeployment)
.filter(
ApplicationDeployment.solutionId == sol.id,
ApplicationDeployment.applicationId == app_id,
ApplicationDeployment.lzEnvironmentId == lzenv.id,
)
.one_or_none()
)
if not app_deployment:
schema = ApplicationDeploymentSchema(many=False)
app_deployment_dict = {}
app_deployment_dict["applicationId"] = app_id
app_deployment_dict["lastUpdated"] = ModelTools.get_utc_timestamp()
app_deployment_dict["deploymentState"] = DeploymentStatus.PENDING
app_deployment_dict["taskId"] = None
app_deployment_dict["solutionId"] = app.solutionId
app_deployment_dict["deploymentProjectId"] = projectId
app_deployment_dict["lzEnvironmentId"] = lzenv.id
app_deployment_dict["workspaceProjectId"] = workspaceProjectId
app_deployment = schema.load(app_deployment_dict, session=db.session)
dbs.add(app_deployment)
else:
# Allow re-deployment of a previously unsuccessful deployment
if app_deployment.deploymentState != DeploymentStatus.SUCCESS:
app_deployment.deploymentState = DeploymentStatus.PENDING
app_deployment.taskId = None
def deployment_read_all():
with db_session() as dbs:
app_deployments = (
dbs.query(ApplicationDeployment)
.filter(ApplicationDeployment.deploymentState != "")
.all()
)
for ad in app_deployments:
ad.lzEnvironment = (
dbs.query(LZEnvironment)
.filter(LZEnvironment.id == ad.lzEnvironmentId)
.one_or_none()
)
schema = ExtendedApplicationDeploymentSchema(many=True)
data = schema.dump(app_deployments)
# logger.debug("deployment_read_all::applications data: %s", data)
return data, 200
def deployment_update(app_id, lzEnvId, applicationDeploymentDetails, dbsession):
"""
Updates an existing applications in the application list with the deployed status.
:param key: id of the application
:param solutionDetails: application details to update
:return: updated application
"""
logger.debug(
"deployment_update::applicationDeploymentDetails: %s",
applicationDeploymentDetails,
)
# Does the application exist in application list?
existing_application_deployment = (
dbsession.query(ApplicationDeployment)
.filter(
ApplicationDeployment.applicationId == app_id,
ApplicationDeployment.lzEnvironmentId == lzEnvId,
)
.one_or_none()
)
# Does the application deployment exist?
if existing_application_deployment:
existing_application_deployment.lastUpdated = ModelTools.get_utc_timestamp()
if "deploymentState" in applicationDeploymentDetails:
existing_application_deployment.deploymentState = (
applicationDeploymentDetails["deploymentState"]
)
if "taskId" in applicationDeploymentDetails:
existing_application_deployment.taskId = applicationDeploymentDetails[
"taskId"
]
dbsession.merge(existing_application_deployment)
else:
logger.debug(
"deployment_update::existing application deployment not found, %s, %s",
app_id,
lzEnvId,
)
def get_variables_from_metadata(actMetadataVariable: ActivatorMetadataVariable):
optional_pairs = list()
mandatory_pairs = list()
for mvar in actMetadataVariable:
key = mvar.name
if mvar.defaultValue is None:
val = mvar.value
else:
val = mvar.defaultValue
key_val_pair = {"key": key, "value": val}
if mvar.isOptional:
optional_pairs.append(key_val_pair)
else:
mandatory_pairs.append(key_val_pair)
return optional_pairs, mandatory_pairs
def deploy_application(app_deployment, dbsession):
logger.debug("deploy_application:: %s", app_deployment)
# expand fields for DaC application deployment
app, act, actMetadata, lzenv = (
dbsession.query(Application, Activator, ActivatorMetadata, LZEnvironment)
.filter(
Activator.id == Application.activatorId,
ActivatorMetadata.activatorId == Application.activatorId,
Application.id == app_deployment.applicationId,
ApplicationDeployment.applicationId == Application.id,
ApplicationDeployment.lzEnvironmentId == LZEnvironment.id,
LZEnvironment.id == app_deployment.lzEnvironmentId,
)
.one_or_none()
)
act = activator_extension.expand_activator(act, dbsession)
actMetadataVariable = (
dbsession.query(ActivatorMetadataVariable)
.filter(
ActivatorMetadataVariable.activatorMetadataId == actMetadata.id,
)
.all()
)
if act:
gitSnapshot = json.loads(act.gitSnapshotJson)
if gitSnapshot and "git_clone_url" in gitSnapshot.keys():
app_deployment.activatorGitUrl = gitSnapshot["git_clone_url"]
else:
raise Exception(
"Error, could not retrieve git_clone_url from gitSnapshot Json"
)
optional_pairs, mandatory_pairs = get_variables_from_metadata(
actMetadataVariable
)
app_deployment.optionalVariables = optional_pairs
app_deployment.mandatoryVariables = mandatory_pairs
app_deployment.workspaceProjectId = app_deployment.workspaceProjectId
app_deployment.deploymentProjectId = app_deployment.deploymentProjectId
app_deployment.id = app.id
app_deployment.name = app.name
app_deployment.description = app.description
environment, lzlanvpc = (
dbsession.query(LZEnvironment, LZLanVpc)
.filter(
LZLanVpcEnvironment.lzlanvpcId == LZLanVpc.id,
LZLanVpcEnvironment.environmentId == lzenv.id,
LZLanVpcEnvironment.environmentId == LZEnvironment.id,
LZLanVpcEnvironment.isActive,
LZEnvironment.isActive,
)
.one_or_none()
)
if lzlanvpc:
environment.sharedVPCProjectId = lzlanvpc.sharedVPCProjectId
else:
environment.sharedVPCProjectId = ""
app_deployment.deploymentEnvironment = environment
return send_application_deployment_to_the_dac(
app_deployment, dbsession=dbsession
)
else:
logger.error("deploy_application::activator not found, %s!", app.activatorId)
# Send the application to the DAC
def send_application_deployment_to_the_dac(app_deployment, dbsession):
app_id = app_deployment.applicationId
lzEnvId = app_deployment.lzEnvironmentId
schema = ExtendedApplicationForDACSchema(many=False)
application_deployment_data = schema.dump(app_deployment)
application_deployment_data = json.dumps(application_deployment_data, indent=4)
logger.debug(
"send_application_deployment_to_the_dac::application_deployment: %s",
application_deployment_data,
)
resp_json = None
try:
response = requests.post(
deployment_create_url, data=application_deployment_data, headers=headers
)
resp_json = response.json()
logger.debug(
"send_application_deployment_to_the_dac::ResponseFromDAC: %s",
pformat(resp_json),
)
except requests.exceptions.RequestException as e:
logger.error(
"send_application_deployment_to_the_dac::Failed during request to DAC %s", e
)
abort(500, "Failed communicating with the DAC")
try:
taskid = resp_json.get("taskid", None)
# update with taskId
deployment_json = {
"id": app_id,
"taskId": taskid,
"deploymentState": DeploymentStatus.PENDING,
}
logger.debug(
"send_application_deployment_to_the_dac::deployment_json: %s",
pformat(deployment_json),
)
logger.debug(pformat(deployment_json))
deployment_update(app_id, lzEnvId, deployment_json, dbsession)
return deployment_json
except requests.exceptions.RequestException as e:
logger.error(
"send_application_deployment_to_the_dac::Failed updating the database with the response from the DAC, %s.",
e,
)
abort(
500,
"send_application_deployment_to_the_dac::Failed updating the database with the response from the DAC.",
)
def validate_json(some_json):
try:
json.loads(some_json)
return True
except ValueError:
return False
def get_application_results_from_the_dac(app_id, lzEnvId, task_id, dbsession):
"""
Get the application deployment results from the DAC.
params: task_id
"""
logger.debug(
"get_application_results_from_the_dac: oid: %s taskId: %s", app_id, task_id
)
resp_json = None
try:
response = requests.get(deployment_create_result_url + task_id, headers=headers)
resp_json = response.json()
logger.debug("Response from Dac: %s", resp_json)
except requests.exceptions.RequestException as e:
logger.debug(
"get_application_results_from_the_dac::Failed during request to DAC, %s", e
)
abort(
500,
"get_application_results_from_the_dac::failed communicating with the DAC",
)
# update ApplicationDeployment with results
deployment_json = {
"applicationId": app_id,
"deploymentState": resp_json.get("status", "ERROR"),
}
logger.debug(
"get_application_results_from_the_dac::deployment_json: %s",
pformat(deployment_json),
)
try:
deployment_update(app_id, lzEnvId, deployment_json, dbsession=dbsession)
except requests.exceptions.RequestException as e:
logger.debug(
"get_application_results_from_the_dac::Failed updating the ApplicationDeployment with the response from the DAC, %s",
e,
)
abort(
500,
"get_application_results_from_the_dac::Failed updating the ApplicationDeployment with the response from the DAC.",
)
if resp_json.get("status", "ERROR") != DeploymentStatus.SUCCESS:
return make_response(deployment_json, 200)
my_json = resp_json.get("payload", "")
is_valid_json = validate_json(my_json)
logger.debug("is_valid_json: %s", is_valid_json)
# TODO
# try:
# # Update Solution Resource JSON
# if (
# is_valid_json
# and resp_json.get("status", "") == DeploymentStatus.SUCCESS
# and len(my_json) > 0
# ):
# tf_json = {"solutionId": oid, "json": my_json}
# # print("tf_json: " + pformat(tf_json))
# # TODO: Need to uncomment and test
# # applicationresourcejson.create(tf_json)
# return deployment_json
# except requests.exceptions.RequestException as e:
# logger.debug(
# "get_application_results_from_the_dac::Failed updating the ApplicationResourceJSON with the response from the DAC, %s",
# e,
# )
# abort(
# "get_application_results_from_the_dac::Failed updating the ApplicationResourceJSON with the response from the DAC.",
# 500,
# )
| [
1,
1053,
4390,
30004,
13,
5215,
12183,
30004,
13,
5215,
2897,
30004,
13,
5215,
931,
30004,
13,
3166,
282,
2158,
1053,
282,
4830,
30004,
13,
30004,
13,
5215,
7274,
30004,
13,
3166,
29784,
1053,
27450,
29892,
1207,
29918,
5327,
30004,
13,
30004,
13,
3166,
2295,
1053,
4833,
29892,
2279,
3406,
30004,
13,
3166,
2295,
29889,
2585,
29918,
1982,
1053,
4833,
29918,
7924,
30004,
13,
3166,
4733,
1053,
313,
30004,
13,
1678,
21775,
1061,
11167,
13,
1678,
21775,
1061,
18417,
11167,
13,
1678,
21775,
1061,
18417,
16174,
11167,
13,
1678,
8427,
11167,
13,
1678,
8427,
8498,
22812,
11167,
13,
1678,
8427,
8498,
22812,
12763,
11167,
13,
1678,
365,
29999,
18649,
11167,
13,
1678,
365,
29999,
29931,
273,
29963,
6739,
11167,
13,
1678,
365,
29999,
29931,
273,
29963,
6739,
18649,
11167,
13,
1678,
24380,
11167,
13,
1678,
24380,
18649,
11167,
13,
1678,
24380,
6848,
11167,
13,
8443,
13,
3166,
260,
29890,
29918,
10774,
7352,
29918,
5509,
1053,
5039,
1061,
29918,
17588,
29892,
12519,
29892,
6993,
30004,
13,
3166,
260,
29890,
29918,
10774,
7352,
29918,
5509,
29889,
8498,
22812,
5709,
1053,
10034,
22812,
5709,
30004,
13,
3166,
260,
29890,
29918,
10774,
7352,
29918,
5509,
29889,
1062,
2760,
4504,
8609,
1053,
313,
30004,
13,
1678,
7338,
2760,
4873,
8498,
22812,
12763,
11167,
13,
1678,
7338,
2760,
4873,
2831,
29928,
2477,
12763,
11167,
13,
8443,
13,
3166,
260,
29890,
29918,
10774,
7352,
29918,
5509,
29889,
8504,
1053,
8125,
24183,
30004,
13,
30004,
13,
21707,
353,
12183,
29889,
657,
16363,
703,
22625,
29918,
10774,
7352,
29918,
5509,
29889,
6214,
29918,
16519,
358,
1159,
30004,
13,
30004,
13,
16519,
358,
29918,
3258,
29918,
2271,
353,
285,
29908,
1124,
597,
29912,
359,
29889,
21813,
1839,
29954,
6271,
29918,
29928,
2477,
29918,
4219,
2033,
6822,
29881,
562,
29914,
6214,
29918,
12674,
12975,
30004,
13,
16519,
358,
29918,
3258,
29918,
2914,
29918,
2271,
353,
313,
30004,
13,
1678,
285,
29908,
1124,
597,
29912,
359,
29889,
21813,
1839,
29954,
6271,
29918,
29928,
2477,
29918,
4219,
2033,
6822,
29881,
562,
29914,
6214,
29918,
12674,
29914,
2914,
29914,
3258,
12975,
30004,
13,
8443,
13,
13662,
353,
8853,
3916,
29899,
1542,
1115,
376,
6214,
29914,
3126,
29908,
8117,
13,
30004,
13,
30004,
13,
1753,
26051,
29918,
1792,
29898,
6214,
1204,
1125,
30004,
13,
1678,
9995,
30004,
13,
1678,
2216,
1598,
278,
1404,
278,
2280,
18209,
756,
8676,
22993,
13,
30004,
13,
1678,
826,
3174,
29901,
30004,
13,
4706,
2280,
1204,
9310,
524,
29962,
1125,
518,
1576,
2280,
1178,
29962,
30004,
13,
1678,
9995,
30004,
13,
1678,
411,
4833,
29918,
7924,
580,
408,
4833,
29879,
29901,
30004,
13,
4706,
1404,
353,
6993,
29889,
657,
29918,
3084,
29918,
1792,
29918,
3166,
29918,
6979,
29898,
2585,
7924,
29922,
2585,
29879,
8443,
13,
4706,
17927,
29889,
8382,
703,
1792,
29901,
1273,
29879,
613,
1404,
8443,
13,
4706,
565,
1404,
29901,
30004,
13,
9651,
313,
932,
29892,
623,
29918,
16519,
29897,
353,
313,
30004,
13,
18884,
4833,
29879,
29889,
1972,
29898,
4873,
29892,
8427,
8498,
22812,
8443,
13,
18884,
869,
4572,
29898,
30004,
13,
462,
1678,
8427,
8498,
22812,
29889,
6214,
1204,
1275,
2280,
1204,
11167,
13,
462,
1678,
8427,
8498,
22812,
29889,
6214,
1204,
1275,
8427,
29889,
333,
11167,
13,
18884,
1723,
30004,
13,
18884,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
9651,
1723,
30004,
13,
9651,
565,
623,
29901,
30004,
13,
18884,
18209,
2792,
353,
623,
29918,
16519,
29889,
16519,
358,
2792,
30004,
13,
18884,
565,
18209,
2792,
1275,
10034,
22812,
5709,
29889,
14605,
26925,
29901,
30004,
13,
462,
1678,
2643,
353,
285,
29908,
10858,
8427,
426,
6214,
1204,
29913,
21313,
932,
29889,
978,
1800,
18209,
756,
8676,
8472,
19451,
13,
18884,
1683,
29901,
30004,
13,
462,
1678,
2643,
353,
285,
29908,
10858,
8427,
426,
6214,
1204,
29913,
21313,
932,
29889,
978,
1800,
18209,
756,
5229,
1213,
30004,
13,
18884,
20092,
353,
3336,
13,
462,
1678,
376,
275,
9966,
1115,
5852,
11167,
13,
462,
1678,
376,
517,
2659,
1204,
1115,
1404,
29889,
333,
11167,
13,
462,
1678,
376,
5215,
749,
1115,
29871,
29896,
11167,
13,
462,
1678,
376,
4906,
1115,
2643,
11167,
13,
462,
1678,
376,
275,
6359,
1115,
7700,
11167,
13,
462,
1678,
376,
6214,
1204,
1115,
623,
29889,
333,
11167,
13,
18884,
4970,
13,
18884,
12519,
29889,
3258,
29898,
24671,
29922,
23813,
29892,
1134,
1204,
29922,
29941,
29892,
4833,
7924,
29922,
2585,
29879,
8443,
13,
9651,
1683,
29901,
30004,
13,
18884,
17927,
29889,
27392,
29898,
30004,
13,
462,
1678,
376,
29089,
3638,
12519,
29892,
9368,
304,
1284,
278,
2280,
313,
29995,
29879,
467,
15231,
13,
462,
1678,
623,
29889,
333,
11167,
13,
18884,
1723,
30004,
13,
4706,
1683,
29901,
30004,
13,
9651,
17927,
29889,
27392,
703,
29089,
3638,
12519,
29892,
9368,
304,
12725,
278,
5993,
23157,
30004,
13,
30004,
13,
30004,
13,
1753,
1369,
29918,
16519,
358,
29898,
6214,
1204,
1125,
30004,
13,
1678,
17927,
29889,
3888,
703,
2962,
29918,
16519,
358,
1057,
6214,
1204,
29901,
1273,
29879,
613,
2280,
1204,
8443,
13,
1678,
396,
508,
871,
7246,
385,
2280,
565,
278,
1650,
372,
6852,
29915,
29879,
304,
756,
2307,
1063,
30004,
13,
1678,
396,
21168,
8472,
22993,
13,
1678,
411,
4833,
29918,
7924,
580,
408,
4833,
29879,
29901,
30004,
13,
4706,
18209,
29918,
8835,
353,
7700,
30004,
13,
4706,
1550,
18209,
29918,
8835,
338,
7700,
29901,
30004,
13,
9651,
623,
29918,
2716,
353,
313,
30004,
13,
18884,
4833,
29879,
29889,
1972,
29898,
4873,
8498,
22812,
8443,
13,
18884,
869,
4572,
29898,
30004,
13,
462,
1678,
8427,
8498,
22812,
29889,
6214,
1204,
1275,
2280,
1204,
11167,
13,
462,
1678,
8427,
8498,
22812,
29889,
16519,
358,
2792,
29889,
29842,
23538,
30004,
13,
462,
4706,
313,
8498,
22812,
5709,
29889,
14605,
26925,
29892,
10034,
22812,
5709,
29889,
4519,
6227,
11499,
8443,
13,
462,
1678,
10353,
30004,
13,
18884,
1723,
30004,
13,
18884,
869,
4102,
26471,
13,
9651,
1723,
30004,
13,
9651,
17927,
29889,
8382,
703,
2962,
29918,
16519,
358,
1057,
932,
29918,
2716,
18610,
1273,
29879,
613,
623,
29918,
2716,
8443,
13,
9651,
565,
623,
29918,
2716,
29901,
30004,
13,
18884,
623,
29918,
333,
353,
623,
29918,
2716,
29889,
6214,
1204,
30004,
13,
18884,
3414,
29918,
333,
353,
623,
29918,
2716,
29889,
7662,
1204,
30004,
13,
18884,
17927,
29889,
8382,
29898,
30004,
13,
462,
1678,
376,
2962,
29918,
16519,
358,
29901,
18209,
2792,
29901,
1273,
29879,
29892,
623,
29918,
333,
29901,
1273,
29879,
29892,
664,
3493,
7653,
1204,
1273,
29879,
29892,
3414,
29918,
333,
1273,
29879,
15231,
13,
462,
1678,
623,
29918,
2716,
29889,
16519,
358,
2792,
11167,
13,
462,
1678,
623,
29918,
333,
11167,
13,
462,
1678,
623,
29918,
2716,
29889,
1287,
3493,
7653,
1204,
11167,
13,
462,
1678,
3414,
29918,
333,
11167,
13,
18884,
1723,
30004,
13,
18884,
565,
3414,
29918,
333,
338,
6213,
470,
3414,
29918,
333,
1275,
376,
1115,
30004,
13,
462,
1678,
2933,
353,
7246,
29918,
6214,
29898,
932,
29918,
2716,
29892,
4833,
7924,
29922,
2585,
29879,
8443,
13,
462,
1678,
4833,
29879,
29889,
23126,
26471,
13,
462,
1678,
17927,
29889,
8382,
29898,
30004,
13,
462,
4706,
376,
2962,
29918,
16519,
358,
1057,
16519,
29918,
6214,
29901,
623,
29918,
333,
29901,
1273,
29879,
613,
623,
29918,
333,
30004,
13,
462,
1678,
1723,
30004,
13,
462,
1678,
17927,
29889,
8382,
29898,
29886,
4830,
29898,
5327,
876,
30004,
13,
18884,
1683,
29901,
30004,
13,
462,
1678,
17927,
29889,
8382,
29898,
30004,
13,
462,
4706,
376,
2962,
29918,
16519,
358,
1057,
3733,
1847,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
27838,
29907,
29901,
623,
29918,
333,
29901,
1273,
29879,
3414,
29918,
333,
29901,
1273,
29879,
15231,
13,
462,
4706,
623,
29918,
333,
11167,
13,
462,
4706,
3414,
29918,
333,
11167,
13,
462,
1678,
1723,
30004,
13,
462,
1678,
679,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
29898,
30004,
13,
462,
4706,
623,
29918,
333,
29922,
932,
29918,
333,
11167,
13,
462,
4706,
301,
29920,
21745,
1204,
29922,
932,
29918,
2716,
29889,
29880,
29920,
18649,
1204,
11167,
13,
462,
4706,
3414,
29918,
333,
29922,
7662,
29918,
333,
11167,
13,
462,
4706,
4833,
7924,
29922,
2585,
29879,
11167,
13,
462,
1678,
1723,
30004,
13,
462,
1678,
4833,
29879,
29889,
23126,
26471,
13,
18884,
1596,
703,
29903,
5436,
29871,
29906,
1159,
30004,
13,
18884,
931,
29889,
17059,
29898,
29906,
8443,
13,
9651,
1683,
29901,
30004,
13,
18884,
18209,
29918,
8835,
353,
5852,
30004,
13,
4706,
17927,
29889,
8382,
29898,
30004,
13,
9651,
376,
2962,
29918,
16519,
358,
1057,
16519,
358,
4866,
363,
8427,
29901,
1273,
29879,
613,
2280,
1204,
30004,
13,
4706,
1723,
30004,
13,
1678,
26051,
29918,
1792,
29898,
6214,
1204,
29922,
6214,
1204,
8443,
13,
1678,
736,
5852,
30004,
13,
30004,
13,
30004,
13,
1753,
18209,
29918,
3258,
29898,
6214,
8498,
22812,
10602,
1125,
30004,
13,
1678,
9995,
30004,
13,
1678,
910,
740,
9365,
263,
2280,
363,
2935,
278,
2009,
304,
278,
7266,
29907,
30004,
13,
30004,
13,
1678,
584,
3207,
1650,
29901,
29871,
1178,
30004,
13,
1678,
584,
2457,
29901,
308,
29906,
29900,
29896,
373,
2551,
30004,
13,
1678,
584,
18884,
29946,
29900,
29946,
565,
2280,
451,
1476,
30004,
13,
1678,
584,
18884,
29945,
29900,
29900,
565,
916,
10672,
30004,
13,
1678,
9995,
30004,
13,
1678,
17927,
29889,
8382,
703,
16519,
358,
29918,
3258,
29901,
1273,
29879,
613,
282,
4830,
29898,
6214,
8498,
22812,
10602,
876,
30004,
13,
1678,
623,
29918,
333,
353,
2280,
8498,
22812,
10602,
3366,
333,
3108,
30004,
13,
30004,
13,
1678,
411,
4833,
29918,
7924,
580,
408,
4833,
29879,
29901,
30004,
13,
4706,
623,
353,
4833,
29879,
29889,
1972,
29898,
4873,
467,
4572,
29898,
4873,
29889,
333,
1275,
623,
29918,
333,
467,
650,
29918,
272,
29918,
9290,
26471,
13,
30004,
13,
4706,
565,
451,
623,
29901,
30004,
13,
9651,
27450,
703,
4013,
2280,
1838,
29915,
29873,
1863,
19602,
29871,
29946,
29900,
29946,
8443,
13,
30004,
13,
4706,
899,
353,
313,
30004,
13,
9651,
4833,
29879,
29889,
1972,
29898,
13296,
918,
8443,
13,
9651,
869,
4572,
29898,
4873,
29889,
333,
1275,
623,
29918,
333,
29892,
8427,
29889,
2929,
918,
1204,
1275,
24380,
29889,
333,
8443,
13,
9651,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
4706,
1723,
30004,
13,
4706,
565,
899,
322,
899,
29889,
16519,
358,
2792,
2804,
10034,
22812,
5709,
29889,
14605,
26925,
29901,
30004,
13,
9651,
17927,
29889,
27392,
29898,
30004,
13,
18884,
376,
29089,
7246,
385,
2280,
565,
278,
1650,
18209,
756,
451,
8676,
8472,
1213,
30004,
13,
9651,
1723,
30004,
13,
9651,
27450,
29898,
30004,
13,
462,
29946,
29900,
29900,
11167,
13,
18884,
376,
29089,
7246,
385,
2280,
565,
278,
1650,
18209,
756,
451,
8676,
8472,
29889,
15231,
13,
9651,
1723,
30004,
13,
30004,
13,
4706,
899,
29918,
264,
4270,
353,
313,
30004,
13,
9651,
4833,
29879,
29889,
1972,
29898,
29931,
29999,
18649,
8443,
13,
9651,
869,
4572,
29898,
30004,
13,
18884,
24380,
18649,
29889,
20944,
1204,
1275,
365,
29999,
18649,
29889,
333,
11167,
13,
18884,
24380,
18649,
29889,
2929,
918,
1204,
1275,
899,
29889,
333,
11167,
13,
18884,
24380,
18649,
29889,
275,
9966,
11167,
13,
18884,
365,
29999,
18649,
29889,
275,
9966,
11167,
13,
9651,
1723,
30004,
13,
9651,
869,
497,
26471,
13,
4706,
1723,
30004,
13,
30004,
13,
4706,
363,
301,
2256,
29894,
297,
899,
29918,
264,
4270,
29901,
30004,
13,
9651,
301,
2256,
29894,
29918,
932,
29918,
16519,
358,
29898,
29880,
2256,
29894,
29892,
4833,
29879,
29892,
899,
29892,
623,
29918,
333,
29892,
623,
8443,
13,
30004,
13,
1678,
396,
2038,
4833,
10804,
881,
367,
4866,
1434,
278,
2446,
6576,
30004,
13,
1678,
2279,
3406,
29889,
7892,
29898,
2962,
29918,
16519,
358,
29892,
623,
29918,
333,
8443,
13,
30004,
13,
1678,
736,
1207,
29918,
5327,
29898,
30004,
13,
4706,
8853,
333,
1115,
623,
29918,
333,
29892,
376,
16519,
358,
2792,
1115,
10034,
22812,
5709,
29889,
29925,
11794,
4214,
1118,
29871,
29906,
29900,
29900,
30004,
13,
1678,
1723,
30004,
13,
30004,
13,
30004,
13,
1753,
301,
2256,
29894,
29918,
932,
29918,
16519,
358,
29898,
29880,
2256,
29894,
29892,
4833,
29879,
29892,
899,
29892,
623,
29918,
333,
29892,
623,
1125,
30004,
13,
1678,
664,
3493,
29918,
10314,
29918,
1989,
353,
376,
4836,
29899,
333,
29899,
1287,
3493,
19451,
13,
1678,
664,
3493,
29918,
10314,
353,
313,
30004,
13,
4706,
4833,
29879,
29889,
1972,
29898,
13296,
918,
6848,
8443,
13,
4706,
869,
4572,
29898,
30004,
13,
9651,
24380,
6848,
29889,
2929,
918,
1204,
1275,
899,
29889,
333,
11167,
13,
9651,
24380,
6848,
29889,
1989,
1275,
664,
3493,
29918,
10314,
29918,
1989,
11167,
13,
4706,
1723,
30004,
13,
4706,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
1678,
1723,
30004,
13,
1678,
565,
451,
664,
3493,
29918,
10314,
29901,
30004,
13,
4706,
17927,
29889,
2704,
29898,
30004,
13,
9651,
376,
16519,
358,
29918,
3258,
29901,
910,
2280,
18209,
1273,
29879,
338,
4567,
278,
664,
3493,
7653,
1204,
29892,
6503,
2558,
29901,
1273,
29879,
29892,
14993,
3262,
856,
15231,
13,
9651,
623,
29918,
333,
11167,
13,
9651,
664,
3493,
29918,
10314,
29918,
1989,
11167,
13,
4706,
1723,
30004,
13,
30004,
13,
1678,
565,
664,
3493,
29918,
10314,
29901,
30004,
13,
4706,
664,
3493,
7653,
1204,
353,
664,
3493,
29918,
10314,
29889,
1767,
30004,
13,
4706,
6503,
29918,
1989,
353,
285,
29908,
4836,
29899,
333,
29899,
29912,
29880,
2256,
29894,
29889,
978,
29889,
13609,
580,
5038,
30004,
13,
30004,
13,
4706,
1650,
29918,
10314,
353,
313,
30004,
13,
9651,
4833,
29879,
29889,
1972,
29898,
13296,
918,
6848,
8443,
13,
9651,
869,
4572,
29898,
30004,
13,
18884,
24380,
6848,
29889,
2929,
918,
1204,
1275,
899,
29889,
333,
11167,
13,
18884,
24380,
6848,
29889,
1989,
1275,
6503,
29918,
1989,
11167,
13,
9651,
1723,
30004,
13,
9651,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
4706,
1723,
30004,
13,
30004,
13,
4706,
565,
451,
1650,
29918,
10314,
29901,
30004,
13,
9651,
17927,
29889,
2704,
29898,
30004,
13,
18884,
376,
16519,
358,
29918,
3258,
29901,
910,
2280,
18209,
1273,
29879,
338,
4567,
278,
2060,
1204,
29892,
6503,
2558,
29901,
1273,
29879,
29892,
14993,
3262,
856,
15231,
13,
18884,
623,
29918,
333,
11167,
13,
18884,
6503,
29918,
1989,
11167,
13,
9651,
1723,
30004,
13,
30004,
13,
4706,
565,
1650,
29918,
10314,
29901,
30004,
13,
9651,
2060,
1204,
353,
1650,
29918,
10314,
29889,
1767,
30004,
13,
9651,
623,
29918,
16519,
358,
353,
313,
30004,
13,
18884,
4833,
29879,
29889,
1972,
29898,
4873,
8498,
22812,
8443,
13,
18884,
869,
4572,
29898,
30004,
13,
462,
1678,
8427,
8498,
22812,
29889,
2929,
918,
1204,
1275,
899,
29889,
333,
11167,
13,
462,
1678,
8427,
8498,
22812,
29889,
6214,
1204,
1275,
623,
29918,
333,
11167,
13,
462,
1678,
8427,
8498,
22812,
29889,
29880,
29920,
18649,
1204,
1275,
301,
2256,
29894,
29889,
333,
11167,
13,
18884,
1723,
30004,
13,
18884,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
9651,
1723,
30004,
13,
4706,
565,
451,
623,
29918,
16519,
358,
29901,
30004,
13,
9651,
10938,
353,
8427,
8498,
22812,
12763,
29898,
13011,
29922,
8824,
8443,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
353,
6571,
30004,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
3366,
6214,
1204,
3108,
353,
623,
29918,
333,
30004,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
3366,
4230,
29248,
3108,
353,
8125,
24183,
29889,
657,
29918,
329,
29883,
29918,
16394,
26471,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
3366,
16519,
358,
2792,
3108,
353,
10034,
22812,
5709,
29889,
29925,
11794,
4214,
30004,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
3366,
7662,
1204,
3108,
353,
6213,
30004,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
3366,
2929,
918,
1204,
3108,
353,
623,
29889,
2929,
918,
1204,
30004,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
3366,
16519,
358,
7653,
1204,
3108,
353,
2060,
1204,
30004,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
3366,
29880,
29920,
18649,
1204,
3108,
353,
301,
2256,
29894,
29889,
333,
30004,
13,
9651,
623,
29918,
16519,
358,
29918,
8977,
3366,
1287,
3493,
7653,
1204,
3108,
353,
664,
3493,
7653,
1204,
30004,
13,
30004,
13,
9651,
623,
29918,
16519,
358,
353,
10938,
29889,
1359,
29898,
932,
29918,
16519,
358,
29918,
8977,
29892,
4867,
29922,
2585,
29889,
7924,
8443,
13,
9651,
4833,
29879,
29889,
1202,
29898,
932,
29918,
16519,
358,
8443,
13,
4706,
1683,
29901,
30004,
13,
9651,
396,
29408,
337,
29899,
16519,
358,
310,
263,
9251,
443,
8698,
1319,
18209,
30004,
13,
9651,
565,
623,
29918,
16519,
358,
29889,
16519,
358,
2792,
2804,
10034,
22812,
5709,
29889,
14605,
26925,
29901,
30004,
13,
18884,
623,
29918,
16519,
358,
29889,
16519,
358,
2792,
353,
10034,
22812,
5709,
29889,
29925,
11794,
4214,
30004,
13,
18884,
623,
29918,
16519,
358,
29889,
7662,
1204,
353,
6213,
30004,
13,
30004,
13,
30004,
13,
1753,
18209,
29918,
949,
29918,
497,
7295,
30004,
13,
1678,
411,
4833,
29918,
7924,
580,
408,
4833,
29879,
29901,
30004,
13,
4706,
623,
29918,
16519,
1860,
353,
313,
30004,
13,
9651,
4833,
29879,
29889,
1972,
29898,
4873,
8498,
22812,
8443,
13,
9651,
869,
4572,
29898,
4873,
8498,
22812,
29889,
16519,
358,
2792,
2804,
20569,
30004,
13,
9651,
869,
497,
26471,
13,
4706,
1723,
30004,
13,
4706,
363,
594,
297,
623,
29918,
16519,
1860,
29901,
30004,
13,
9651,
594,
29889,
29880,
29920,
18649,
353,
313,
30004,
13,
18884,
4833,
29879,
29889,
1972,
29898,
29931,
29999,
18649,
8443,
13,
18884,
869,
4572,
29898,
29931,
29999,
18649,
29889,
333,
1275,
594,
29889,
29880,
29920,
18649,
1204,
8443,
13,
18884,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
9651,
1723,
30004,
13,
30004,
13,
4706,
10938,
353,
7338,
2760,
4873,
8498,
22812,
12763,
29898,
13011,
29922,
5574,
8443,
13,
4706,
848,
353,
10938,
29889,
15070,
29898,
932,
29918,
16519,
1860,
8443,
13,
4706,
396,
17927,
29889,
8382,
703,
16519,
358,
29918,
949,
29918,
497,
1057,
932,
5795,
848,
29901,
1273,
29879,
613,
848,
8443,
13,
4706,
736,
848,
29892,
29871,
29906,
29900,
29900,
30004,
13,
30004,
13,
30004,
13,
1753,
18209,
29918,
5504,
29898,
932,
29918,
333,
29892,
301,
29920,
21745,
1204,
29892,
2280,
8498,
22812,
10602,
29892,
4833,
7924,
1125,
30004,
13,
1678,
9995,
30004,
13,
1678,
5020,
15190,
385,
5923,
8324,
297,
278,
2280,
1051,
411,
278,
21168,
4660,
22993,
13,
30004,
13,
1678,
584,
3207,
1820,
29901,
1678,
1178,
310,
278,
2280,
30004,
13,
1678,
584,
3207,
1650,
10602,
29901,
259,
2280,
4902,
304,
2767,
30004,
13,
1678,
584,
2457,
29901,
539,
4784,
2280,
30004,
13,
1678,
9995,
30004,
13,
1678,
17927,
29889,
8382,
29898,
30004,
13,
4706,
376,
16519,
358,
29918,
5504,
1057,
6214,
8498,
22812,
10602,
29901,
1273,
29879,
15231,
13,
4706,
2280,
8498,
22812,
10602,
11167,
13,
1678,
1723,
30004,
13,
30004,
13,
1678,
396,
5538,
278,
2280,
1863,
297,
2280,
1051,
29973,
30004,
13,
1678,
5923,
29918,
6214,
29918,
16519,
358,
353,
313,
30004,
13,
4706,
4833,
7924,
29889,
1972,
29898,
4873,
8498,
22812,
8443,
13,
4706,
869,
4572,
29898,
30004,
13,
9651,
8427,
8498,
22812,
29889,
6214,
1204,
1275,
623,
29918,
333,
11167,
13,
9651,
8427,
8498,
22812,
29889,
29880,
29920,
18649,
1204,
1275,
301,
29920,
21745,
1204,
11167,
13,
4706,
1723,
30004,
13,
4706,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
1678,
1723,
30004,
13,
30004,
13,
1678,
396,
5538,
278,
2280,
18209,
1863,
29973,
30004,
13,
1678,
565,
5923,
29918,
6214,
29918,
16519,
358,
29901,
30004,
13,
4706,
5923,
29918,
6214,
29918,
16519,
358,
29889,
4230,
29248,
353,
8125,
24183,
29889,
657,
29918,
329,
29883,
29918,
16394,
26471,
13,
4706,
565,
376,
16519,
358,
2792,
29908,
297,
2280,
8498,
22812,
10602,
29901,
30004,
13,
9651,
5923,
29918,
6214,
29918,
16519,
358,
29889,
16519,
358,
2792,
353,
313,
30004,
13,
18884,
2280,
8498,
22812,
10602,
3366,
16519,
358,
2792,
3108,
30004,
13,
9651,
1723,
30004,
13,
4706,
565,
376,
7662,
1204,
29908,
297,
2280,
8498,
22812,
10602,
29901,
30004,
13,
9651,
5923,
29918,
6214,
29918,
16519,
358,
29889,
7662,
1204,
353,
2280,
8498,
22812,
10602,
29961,
30004,
13,
18884,
376,
7662,
1204,
19451,
13,
9651,
4514,
30004,
13,
4706,
4833,
7924,
29889,
14634,
29898,
735,
15423,
29918,
6214,
29918,
16519,
358,
8443,
13,
1678,
1683,
29901,
30004,
13,
4706,
17927,
29889,
8382,
29898,
30004,
13,
9651,
376,
16519,
358,
29918,
5504,
1057,
735,
15423,
2280,
18209,
451,
1476,
29892,
1273,
29879,
29892,
1273,
29879,
15231,
13,
9651,
623,
29918,
333,
11167,
13,
9651,
301,
29920,
21745,
1204,
11167,
13,
4706,
1723,
30004,
13,
30004,
13,
30004,
13,
1753,
679,
29918,
20897,
29918,
3166,
29918,
19635,
29898,
627,
18417,
16174,
29901,
21775,
1061,
18417,
16174,
1125,
30004,
13,
1678,
13136,
29918,
29886,
7121,
353,
1051,
26471,
13,
1678,
9619,
7606,
29918,
29886,
7121,
353,
1051,
26471,
13,
1678,
363,
286,
1707,
297,
1044,
18417,
16174,
29901,
30004,
13,
4706,
1820,
353,
286,
1707,
29889,
978,
30004,
13,
30004,
13,
4706,
565,
286,
1707,
29889,
4381,
1917,
338,
6213,
29901,
30004,
13,
9651,
659,
353,
286,
1707,
29889,
1767,
30004,
13,
4706,
1683,
29901,
30004,
13,
9651,
659,
353,
286,
1707,
29889,
4381,
1917,
30004,
13,
30004,
13,
4706,
1820,
29918,
791,
29918,
18784,
353,
8853,
1989,
1115,
1820,
29892,
376,
1767,
1115,
659,
8117,
13,
30004,
13,
4706,
565,
286,
1707,
29889,
275,
27636,
29901,
30004,
13,
9651,
13136,
29918,
29886,
7121,
29889,
4397,
29898,
1989,
29918,
791,
29918,
18784,
8443,
13,
4706,
1683,
29901,
30004,
13,
9651,
9619,
7606,
29918,
29886,
7121,
29889,
4397,
29898,
1989,
29918,
791,
29918,
18784,
8443,
13,
30004,
13,
1678,
736,
13136,
29918,
29886,
7121,
29892,
9619,
7606,
29918,
29886,
7121,
30004,
13,
30004,
13,
30004,
13,
1753,
7246,
29918,
6214,
29898,
932,
29918,
16519,
358,
29892,
4833,
7924,
1125,
30004,
13,
30004,
13,
1678,
17927,
29889,
8382,
703,
16519,
29918,
6214,
1057,
1273,
29879,
613,
623,
29918,
16519,
358,
8443,
13,
1678,
396,
7985,
4235,
363,
7266,
29907,
2280,
18209,
30004,
13,
1678,
623,
29892,
1044,
29892,
1044,
18417,
29892,
301,
2256,
29894,
353,
313,
30004,
13,
4706,
4833,
7924,
29889,
1972,
29898,
4873,
29892,
21775,
1061,
29892,
21775,
1061,
18417,
29892,
365,
29999,
18649,
8443,
13,
4706,
869,
4572,
29898,
30004,
13,
9651,
21775,
1061,
29889,
333,
1275,
8427,
29889,
11236,
1061,
1204,
11167,
13,
9651,
21775,
1061,
18417,
29889,
11236,
1061,
1204,
1275,
8427,
29889,
11236,
1061,
1204,
11167,
13,
9651,
8427,
29889,
333,
1275,
623,
29918,
16519,
358,
29889,
6214,
1204,
11167,
13,
9651,
8427,
8498,
22812,
29889,
6214,
1204,
1275,
8427,
29889,
333,
11167,
13,
9651,
8427,
8498,
22812,
29889,
29880,
29920,
18649,
1204,
1275,
365,
29999,
18649,
29889,
333,
11167,
13,
9651,
365,
29999,
18649,
29889,
333,
1275,
623,
29918,
16519,
358,
29889,
29880,
29920,
18649,
1204,
11167,
13,
4706,
1723,
30004,
13,
4706,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
1678,
1723,
30004,
13,
30004,
13,
1678,
1044,
353,
5039,
1061,
29918,
17588,
29889,
18837,
29918,
11236,
1061,
29898,
627,
29892,
4833,
7924,
8443,
13,
30004,
13,
1678,
1044,
18417,
16174,
353,
313,
30004,
13,
4706,
4833,
7924,
29889,
1972,
29898,
21786,
1061,
18417,
16174,
8443,
13,
4706,
869,
4572,
29898,
30004,
13,
9651,
21775,
1061,
18417,
16174,
29889,
11236,
1061,
18417,
1204,
1275,
1044,
18417,
29889,
333,
11167,
13,
4706,
1723,
30004,
13,
4706,
869,
497,
26471,
13,
1678,
1723,
30004,
13,
30004,
13,
1678,
565,
1044,
29901,
30004,
13,
4706,
6315,
21913,
353,
4390,
29889,
18132,
29898,
627,
29889,
5559,
21913,
8148,
8443,
13,
4706,
565,
6315,
21913,
322,
376,
5559,
29918,
16513,
29918,
2271,
29908,
297,
6315,
21913,
29889,
8149,
7295,
30004,
13,
9651,
623,
29918,
16519,
358,
29889,
11236,
1061,
28712,
5983,
353,
6315,
21913,
3366,
5559,
29918,
16513,
29918,
2271,
3108,
30004,
13,
4706,
1683,
29901,
30004,
13,
9651,
12020,
8960,
29898,
30004,
13,
18884,
376,
2392,
29892,
1033,
451,
10563,
6315,
29918,
16513,
29918,
2271,
515,
6315,
21913,
14355,
19451,
13,
9651,
1723,
30004,
13,
30004,
13,
4706,
13136,
29918,
29886,
7121,
29892,
9619,
7606,
29918,
29886,
7121,
353,
679,
29918,
20897,
29918,
3166,
29918,
19635,
29898,
30004,
13,
9651,
1044,
18417,
16174,
30004,
13,
4706,
1723,
30004,
13,
4706,
623,
29918,
16519,
358,
29889,
25253,
10444,
1849,
353,
13136,
29918,
29886,
7121,
30004,
13,
4706,
623,
29918,
16519,
358,
29889,
29885,
392,
7606,
10444,
1849,
353,
9619,
7606,
29918,
29886,
7121,
30004,
13,
30004,
13,
4706,
623,
29918,
16519,
358,
29889,
1287,
3493,
7653,
1204,
353,
623,
29918,
16519,
358,
29889,
1287,
3493,
7653,
1204,
30004,
13,
4706,
623,
29918,
16519,
358,
29889,
16519,
358,
7653,
1204,
353,
623,
29918,
16519,
358,
29889,
16519,
358,
7653,
1204,
30004,
13,
30004,
13,
4706,
623,
29918,
16519,
358,
29889,
333,
353,
623,
29889,
333,
30004,
13,
4706,
623,
29918,
16519,
358,
29889,
978,
353,
623,
29889,
978,
30004,
13,
4706,
623,
29918,
16519,
358,
29889,
8216,
353,
623,
29889,
8216,
30004,
13,
30004,
13,
4706,
5177,
29892,
301,
29920,
6468,
29894,
6739,
353,
313,
30004,
13,
9651,
4833,
7924,
29889,
1972,
29898,
29931,
29999,
18649,
29892,
365,
29999,
29931,
273,
29963,
6739,
8443,
13,
9651,
869,
4572,
29898,
30004,
13,
18884,
365,
29999,
29931,
273,
29963,
6739,
18649,
29889,
29880,
29920,
6468,
29894,
6739,
1204,
1275,
365,
29999,
29931,
273,
29963,
6739,
29889,
333,
11167,
13,
18884,
365,
29999,
29931,
273,
29963,
6739,
18649,
29889,
20944,
1204,
1275,
301,
2256,
29894,
29889,
333,
11167,
13,
18884,
365,
29999,
29931,
273,
29963,
6739,
18649,
29889,
20944,
1204,
1275,
365,
29999,
18649,
29889,
333,
11167,
13,
18884,
365,
29999,
29931,
273,
29963,
6739,
18649,
29889,
275,
9966,
11167,
13,
18884,
365,
29999,
18649,
29889,
275,
9966,
11167,
13,
9651,
1723,
30004,
13,
9651,
869,
650,
29918,
272,
29918,
9290,
26471,
13,
4706,
1723,
30004,
13,
4706,
565,
301,
29920,
6468,
29894,
6739,
29901,
30004,
13,
9651,
5177,
29889,
12366,
29963,
9026,
7653,
1204,
353,
301,
29920,
6468,
29894,
6739,
29889,
12366,
29963,
9026,
7653,
1204,
30004,
13,
4706,
1683,
29901,
30004,
13,
9651,
5177,
29889,
12366,
29963,
9026,
7653,
1204,
353,
5124,
30004,
13,
4706,
623,
29918,
16519,
358,
29889,
16519,
358,
18649,
353,
5177,
30004,
13,
30004,
13,
4706,
736,
3638,
29918,
6214,
29918,
16519,
358,
29918,
517,
29918,
1552,
29918,
29881,
562,
29898,
30004,
13,
9651,
623,
29918,
16519,
358,
29892,
4833,
7924,
29922,
2585,
7924,
30004,
13,
4706,
1723,
30004,
13,
1678,
1683,
29901,
30004,
13,
4706,
17927,
29889,
2704,
703,
16519,
29918,
6214,
1057,
11236,
1061,
451,
1476,
29892,
1273,
29879,
29991,
613,
623,
29889,
11236,
1061,
1204,
8443,
13,
30004,
13,
30004,
13,
29937,
15076,
278,
2280,
304,
278,
360,
2477,
30004,
13,
1753,
3638,
29918,
6214,
29918,
16519,
358,
29918,
517,
29918,
1552,
29918,
29881,
562,
29898,
932,
29918,
16519,
358,
29892,
4833,
7924,
1125,
30004,
13,
1678,
623,
29918,
333,
353,
623,
29918,
16519,
358,
29889,
6214,
1204,
30004,
13,
1678,
301,
29920,
21745,
1204,
353,
623,
29918,
16519,
358,
29889,
29880,
29920,
18649,
1204,
30004,
13,
1678,
10938,
353,
7338,
2760,
4873,
2831,
29928,
2477,
12763,
29898,
13011,
29922,
8824,
8443,
13,
1678,
2280,
29918,
16519,
358,
29918,
1272,
353,
10938,
29889,
15070,
29898,
932,
29918,
16519,
358,
8443,
13,
1678,
2280,
29918,
16519,
358,
29918,
1272,
353,
4390,
29889,
29881,
17204,
29898,
6214,
29918,
16519,
358,
29918,
1272,
29892,
29536,
29922,
29946,
8443,
13,
1678,
17927,
29889,
8382,
29898,
30004,
13,
4706,
376,
6717,
29918,
6214,
29918,
16519,
358,
29918,
517,
29918,
1552,
29918,
29881,
562,
1057,
6214,
29918,
16519,
358,
29901,
1273,
29879,
15231,
13,
4706,
2280,
29918,
16519,
358,
29918,
1272,
11167,
13,
1678,
1723,
30004,
13,
1678,
4613,
29918,
3126,
353,
6213,
30004,
13,
1678,
1018,
29901,
30004,
13,
4706,
2933,
353,
7274,
29889,
2490,
29898,
30004,
13,
9651,
18209,
29918,
3258,
29918,
2271,
29892,
848,
29922,
6214,
29918,
16519,
358,
29918,
1272,
29892,
9066,
29922,
13662,
30004,
13,
4706,
1723,
30004,
13,
4706,
4613,
29918,
3126,
353,
2933,
29889,
3126,
26471,
13,
4706,
17927,
29889,
8382,
29898,
30004,
13,
9651,
376,
6717,
29918,
6214,
29918,
16519,
358,
29918,
517,
29918,
1552,
29918,
29881,
562,
1057,
5103,
4591,
29928,
2477,
29901,
1273,
29879,
15231,
13,
9651,
282,
4830,
29898,
13713,
29918,
3126,
511,
30004,
13,
4706,
1723,
30004,
13,
1678,
5174,
7274,
29889,
11739,
29879,
29889,
3089,
2451,
408,
321,
29901,
30004,
13,
4706,
17927,
29889,
2704,
29898,
30004,
13,
9651,
376,
6717,
29918,
6214,
29918,
16519,
358,
29918,
517,
29918,
1552,
29918,
29881,
562,
1057,
17776,
2645,
2009,
304,
360,
2477,
1273,
29879,
613,
321,
30004,
13,
4706,
1723,
30004,
13,
4706,
27450,
29898,
29945,
29900,
29900,
29892,
376,
17776,
7212,
1218,
411,
278,
360,
2477,
1159,
30004,
13,
30004,
13,
1678,
1018,
29901,
30004,
13,
4706,
3414,
333,
353,
4613,
29918,
3126,
29889,
657,
703,
7662,
333,
613,
6213,
8443,
13,
4706,
396,
2767,
411,
3414,
1204,
30004,
13,
4706,
18209,
29918,
3126,
353,
3336,
13,
9651,
376,
333,
1115,
623,
29918,
333,
11167,
13,
9651,
376,
7662,
1204,
1115,
3414,
333,
11167,
13,
9651,
376,
16519,
358,
2792,
1115,
10034,
22812,
5709,
29889,
29925,
11794,
4214,
11167,
13,
4706,
4970,
13,
30004,
13,
4706,
17927,
29889,
8382,
29898,
30004,
13,
9651,
376,
6717,
29918,
6214,
29918,
16519,
358,
29918,
517,
29918,
1552,
29918,
29881,
562,
1057,
16519,
358,
29918,
3126,
29901,
1273,
29879,
15231,
13,
9651,
282,
4830,
29898,
16519,
358,
29918,
3126,
511,
30004,
13,
4706,
1723,
30004,
13,
4706,
17927,
29889,
8382,
29898,
29886,
4830,
29898,
16519,
358,
29918,
3126,
876,
30004,
13,
4706,
18209,
29918,
5504,
29898,
932,
29918,
333,
29892,
301,
29920,
21745,
1204,
29892,
18209,
29918,
3126,
29892,
4833,
7924,
8443,
13,
4706,
736,
18209,
29918,
3126,
30004,
13,
1678,
5174,
7274,
29889,
11739,
29879,
29889,
3089,
2451,
408,
321,
29901,
30004,
13,
4706,
17927,
29889,
2704,
29898,
30004,
13,
9651,
376,
6717,
29918,
6214,
29918,
16519,
358,
29918,
517,
29918,
1552,
29918,
29881,
562,
1057,
17776,
13271,
278,
2566,
411,
278,
2933,
515,
278,
360,
2477,
29892,
1273,
29879,
29889,
15231,
13,
9651,
321,
11167,
13,
4706,
1723,
30004,
13,
4706,
27450,
29898,
30004,
13,
632,
29945,
29900,
29900,
11167,
13,
9651,
376,
6717,
29918,
6214,
29918,
16519,
358,
29918,
517,
29918,
1552,
29918,
29881,
562,
1057,
17776,
13271,
278,
2566,
411,
278,
2933,
515,
278,
360,
2477,
29889,
15231,
13,
4706,
1723,
30004,
13,
30004,
13,
30004,
13,
1753,
12725,
29918,
3126,
29898,
5372,
29918,
3126,
1125,
30004,
13,
1678,
1018,
29901,
30004,
13,
4706,
4390,
29889,
18132,
29898,
5372,
29918,
3126,
8443,
13,
4706,
736,
5852,
30004,
13,
1678,
5174,
7865,
2392,
29901,
30004,
13,
4706,
736,
7700,
30004,
13,
30004,
13,
30004,
13,
1753,
679,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
29898,
932,
29918,
333,
29892,
301,
29920,
21745,
1204,
29892,
3414,
29918,
333,
29892,
4833,
7924,
1125,
30004,
13,
1678,
9995,
30004,
13,
1678,
3617,
278,
2280,
18209,
2582,
515,
278,
360,
2477,
22993,
13,
1678,
8636,
29901,
3414,
29918,
333,
30004,
13,
1678,
9995,
30004,
13,
1678,
17927,
29889,
8382,
29898,
30004,
13,
4706,
376,
657,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
29901,
288,
333,
29901,
1273,
29879,
3414,
1204,
29901,
1273,
29879,
613,
623,
29918,
333,
29892,
3414,
29918,
333,
30004,
13,
1678,
1723,
30004,
13,
1678,
4613,
29918,
3126,
353,
6213,
30004,
13,
1678,
1018,
29901,
30004,
13,
4706,
2933,
353,
7274,
29889,
657,
29898,
16519,
358,
29918,
3258,
29918,
2914,
29918,
2271,
718,
3414,
29918,
333,
29892,
9066,
29922,
13662,
8443,
13,
4706,
4613,
29918,
3126,
353,
2933,
29889,
3126,
26471,
13,
4706,
17927,
29889,
8382,
703,
5103,
515,
360,
562,
29901,
1273,
29879,
613,
4613,
29918,
3126,
8443,
13,
1678,
5174,
7274,
29889,
11739,
29879,
29889,
3089,
2451,
408,
321,
29901,
30004,
13,
4706,
17927,
29889,
8382,
29898,
30004,
13,
9651,
376,
657,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
1057,
17776,
2645,
2009,
304,
360,
2477,
29892,
1273,
29879,
613,
321,
30004,
13,
4706,
1723,
30004,
13,
4706,
27450,
29898,
30004,
13,
632,
29945,
29900,
29900,
11167,
13,
9651,
376,
657,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
1057,
26061,
7212,
1218,
411,
278,
360,
2477,
15231,
13,
4706,
1723,
30004,
13,
30004,
13,
1678,
396,
2767,
8427,
8498,
22812,
411,
2582,
30004,
13,
1678,
18209,
29918,
3126,
353,
3336,
13,
4706,
376,
6214,
1204,
1115,
623,
29918,
333,
11167,
13,
4706,
376,
16519,
358,
2792,
1115,
4613,
29918,
3126,
29889,
657,
703,
4882,
613,
376,
11432,
4968,
30004,
13,
1678,
4970,
13,
1678,
17927,
29889,
8382,
29898,
30004,
13,
4706,
376,
657,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
1057,
16519,
358,
29918,
3126,
29901,
1273,
29879,
15231,
13,
4706,
282,
4830,
29898,
16519,
358,
29918,
3126,
511,
30004,
13,
1678,
1723,
30004,
13,
1678,
1018,
29901,
30004,
13,
4706,
18209,
29918,
5504,
29898,
932,
29918,
333,
29892,
301,
29920,
21745,
1204,
29892,
18209,
29918,
3126,
29892,
4833,
7924,
29922,
2585,
7924,
8443,
13,
1678,
5174,
7274,
29889,
11739,
29879,
29889,
3089,
2451,
408,
321,
29901,
30004,
13,
4706,
17927,
29889,
8382,
29898,
30004,
13,
9651,
376,
657,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
1057,
17776,
13271,
278,
8427,
8498,
22812,
411,
278,
2933,
515,
278,
360,
2477,
29892,
1273,
29879,
15231,
13,
9651,
321,
11167,
13,
4706,
1723,
30004,
13,
4706,
27450,
29898,
30004,
13,
632,
29945,
29900,
29900,
11167,
13,
9651,
376,
657,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
1057,
17776,
13271,
278,
8427,
8498,
22812,
411,
278,
2933,
515,
278,
360,
2477,
29889,
15231,
13,
4706,
1723,
30004,
13,
30004,
13,
1678,
565,
4613,
29918,
3126,
29889,
657,
703,
4882,
613,
376,
11432,
1159,
2804,
10034,
22812,
5709,
29889,
14605,
26925,
29901,
30004,
13,
4706,
736,
1207,
29918,
5327,
29898,
16519,
358,
29918,
3126,
29892,
29871,
29906,
29900,
29900,
8443,
13,
30004,
13,
1678,
590,
29918,
3126,
353,
4613,
29918,
3126,
29889,
657,
703,
23813,
613,
20569,
30004,
13,
1678,
338,
29918,
3084,
29918,
3126,
353,
12725,
29918,
3126,
29898,
1357,
29918,
3126,
8443,
13,
1678,
17927,
29889,
8382,
703,
275,
29918,
3084,
29918,
3126,
29901,
1273,
29879,
613,
338,
29918,
3084,
29918,
3126,
8443,
13,
30004,
13,
1678,
396,
14402,
30004,
13,
1678,
396,
1018,
29901,
30004,
13,
1678,
396,
268,
396,
10318,
24380,
18981,
4663,
30004,
13,
1678,
396,
268,
565,
313,
30004,
13,
1678,
396,
308,
338,
29918,
3084,
29918,
3126,
30004,
13,
1678,
396,
308,
322,
4613,
29918,
3126,
29889,
657,
703,
4882,
613,
20569,
1275,
10034,
22812,
5709,
29889,
14605,
26925,
30004,
13,
1678,
396,
308,
322,
7431,
29898,
1357,
29918,
3126,
29897,
1405,
29871,
29900,
30004,
13,
1678,
396,
418,
1125,
30004,
13,
1678,
396,
308,
15886,
29918,
3126,
353,
8853,
2929,
918,
1204,
1115,
288,
333,
29892,
376,
3126,
1115,
590,
29918,
3126,
8117,
13,
1678,
396,
308,
396,
1596,
703,
13264,
29918,
3126,
29901,
376,
718,
282,
4830,
29898,
13264,
29918,
3126,
876,
30004,
13,
1678,
396,
308,
396,
14402,
29901,
20768,
304,
443,
9342,
322,
1243,
30004,
13,
1678,
396,
308,
396,
2280,
10314,
3126,
29889,
3258,
29898,
13264,
29918,
3126,
8443,
13,
1678,
396,
268,
736,
18209,
29918,
3126,
30004,
13,
1678,
396,
5174,
7274,
29889,
11739,
29879,
29889,
3089,
2451,
408,
321,
29901,
30004,
13,
1678,
396,
268,
17927,
29889,
8382,
29898,
30004,
13,
1678,
396,
308,
376,
657,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
1057,
17776,
13271,
278,
8427,
6848,
7249,
411,
278,
2933,
515,
278,
360,
2477,
29892,
1273,
29879,
15231,
13,
1678,
396,
308,
321,
11167,
13,
1678,
396,
268,
1723,
30004,
13,
1678,
396,
268,
27450,
29898,
30004,
13,
1678,
396,
308,
376,
657,
29918,
6214,
29918,
9902,
29918,
3166,
29918,
1552,
29918,
29881,
562,
1057,
17776,
13271,
278,
8427,
6848,
7249,
411,
278,
2933,
515,
278,
360,
2477,
29889,
15231,
13,
1678,
396,
3986,
29945,
29900,
29900,
11167,
13,
1678,
396,
268,
1723,
30004,
13,
2
] |
crypt/utils/number_theory_algs.py | 5x/cryptography-gui-app | 1 | 1612072 | # Extended Greatest Common Divisor
def extended_gcd(a, b):
a, b = abs(a), abs(b)
A, B, C, D = 1, 0, 0, 1
while b != 0:
q, r = divmod(a, b)
x = A - (q * C)
y = B - (q * D)
a, b, A, C, B, D = b, r, C, x, D, y
return a, A, B
if __name__ == "__main__":
print(extended_gcd(1234, 54)) # 2, -7, 160
print(extended_gcd(654137 ** 112, 550)) # 11, -19, 78214...725
print(extended_gcd(15, 3)) # 3, 0, 1
| [
1,
396,
7338,
2760,
7027,
342,
13103,
4910,
275,
272,
13,
1753,
10410,
29918,
29887,
2252,
29898,
29874,
29892,
289,
1125,
13,
1678,
263,
29892,
289,
353,
6425,
29898,
29874,
511,
6425,
29898,
29890,
29897,
13,
1678,
319,
29892,
350,
29892,
315,
29892,
360,
353,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
13,
13,
1678,
1550,
289,
2804,
29871,
29900,
29901,
13,
4706,
3855,
29892,
364,
353,
1933,
1545,
29898,
29874,
29892,
289,
29897,
13,
4706,
921,
353,
319,
448,
313,
29939,
334,
315,
29897,
13,
4706,
343,
353,
350,
448,
313,
29939,
334,
360,
29897,
13,
4706,
263,
29892,
289,
29892,
319,
29892,
315,
29892,
350,
29892,
360,
353,
289,
29892,
364,
29892,
315,
29892,
921,
29892,
360,
29892,
343,
13,
13,
1678,
736,
263,
29892,
319,
29892,
350,
13,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
1596,
29898,
1062,
2760,
29918,
29887,
2252,
29898,
29896,
29906,
29941,
29946,
29892,
29871,
29945,
29946,
876,
29871,
396,
29871,
29906,
29892,
448,
29955,
29892,
29871,
29896,
29953,
29900,
13,
1678,
1596,
29898,
1062,
2760,
29918,
29887,
2252,
29898,
29953,
29945,
29946,
29896,
29941,
29955,
3579,
29871,
29896,
29896,
29906,
29892,
29871,
29945,
29945,
29900,
876,
29871,
396,
29871,
29896,
29896,
29892,
448,
29896,
29929,
29892,
29871,
29955,
29947,
29906,
29896,
29946,
856,
29955,
29906,
29945,
13,
1678,
1596,
29898,
1062,
2760,
29918,
29887,
2252,
29898,
29896,
29945,
29892,
29871,
29941,
876,
29871,
396,
29871,
29941,
29892,
29871,
29900,
29892,
29871,
29896,
13,
2
] |
main.py | Guest0x0/ipudp | 0 | 113460 |
import sys
import signal
import os
import subprocess
import selectors
import importlib
logger = importlib.import_module("logger")
tun = importlib.import_module("tun")
crypto = importlib.import_module("crypto")
udp = importlib.import_module("udp")
tun_name = ""
mode = None
addr = None
key = None
auth_msg = b"Infinite Socks Auth"
tunnel_type = None
MTU = 1000
padding_threshold = None
padding_range = None
i = 1
while i < len(sys.argv):
if sys.argv[i] == '-tun':
i = i + 1
tun_name = sys.argv[i]
elif sys.argv[i] == '-client':
mode = 'c'
i = i + 1
ip_and_port = sys.argv[i].split(sep=':', maxsplit=2)
addr = (ip_and_port[0], int(ip_and_port[1], 10))
elif sys.argv[i] == '-server':
mode = 's'
i = i + 1
addr = ("", int(sys.argv[i], 10))
elif sys.argv[i] == '-key':
i = i + 1
key = int(sys.argv[i], 16)
elif sys.argv[i] == '-auth':
i = i + 1
auth_msg = bytes(sys.argv[i])
elif sys.argv[i] == '-tunnel':
i = i + 1
tunnel_type = sys.argv[i]
elif sys.argv[i] == '-mtu':
i = i + 1
MTU = int(sys.argv[i], 10)
elif sys.argv[i] == '-padding':
i = i + 1
padding_threshold = int(sys.argv[i], 10)
padding_range = (padding_threshold, padding_threshold + 200)
else:
raise Exception("unknown option " + sys.argv[i])
i = i + 1
if mode is None:
print("no mode specified")
exit(1)
elif key is None:
print("so key specified")
exit(1)
elif tunnel_type is None:
print("no tunnel type specified")
exit(1)
elif tunnel_type == 'udp':
tunnel = udp.UDPTun(
mode, addr,
crypto.Encrypter(key), crypto.Decrypter(key), auth_msg,
MTU,
padding_threshold, padding_range,
logger.Logger(5)
)
else:
print("unknown tunnel type", tunnel_type)
exit(1)
tun = tun.Tun(tun_name)
os.putenv("TUN_NAME", tun.name)
if mode == 'c':
os.putenv("REMOTE_IP", addr[0])
os.putenv("REMOTE_PORT", str(addr[1]))
subprocess.run(["./client.sh"])
else:
os.putenv("LISTEN_PORT", str(addr[1]))
subprocess.run(["./server.sh"])
def cleanup(signal, frame):
if mode == 'c':
subprocess.run(["./client-cleanup.sh"])
else:
subprocess.run(["./server-cleanup.sh"])
exit(0)
for sig in [ signal.SIGHUP, signal.SIGINT, signal.SIGQUIT, signal.SIGTERM ]:
signal.signal(sig, cleanup)
sel = selectors.DefaultSelector()
sel.register(tun.fd, selectors.EVENT_READ, 0)
sel.register(tunnel.socket, selectors.EVENT_READ, 1)
while True:
for (skey, mask) in sel.select():
if skey.data == 0:
data = os.read(tun.fd, MTU)
tunnel.send(data)
elif skey.data == 1:
data = tunnel.recv()
if data is not None:
os.write(tun.fd, data)
| [
1,
29871,
13,
5215,
10876,
13,
5215,
7182,
13,
5215,
2897,
13,
5215,
1014,
5014,
13,
5215,
1831,
943,
13,
13,
5215,
1053,
1982,
13,
21707,
353,
1053,
1982,
29889,
5215,
29918,
5453,
703,
21707,
1159,
13,
29873,
348,
353,
1053,
1982,
29889,
5215,
29918,
5453,
703,
29873,
348,
1159,
13,
29883,
17929,
353,
1053,
1982,
29889,
5215,
29918,
5453,
703,
29883,
17929,
1159,
13,
566,
29886,
353,
1053,
1982,
29889,
5215,
29918,
5453,
703,
566,
29886,
1159,
13,
13,
29873,
348,
29918,
978,
353,
5124,
13,
13,
8513,
353,
6213,
13,
10030,
353,
6213,
13,
13,
1989,
353,
6213,
13,
5150,
29918,
7645,
353,
289,
29908,
797,
18925,
1105,
4684,
13189,
29908,
13,
13,
29873,
16163,
29918,
1853,
353,
6213,
13,
11490,
29965,
353,
29871,
29896,
29900,
29900,
29900,
13,
12791,
29918,
386,
12268,
353,
6213,
13,
12791,
29918,
3881,
353,
6213,
13,
13,
29875,
353,
29871,
29896,
13,
8000,
474,
529,
7431,
29898,
9675,
29889,
19218,
1125,
13,
1678,
565,
10876,
29889,
19218,
29961,
29875,
29962,
1275,
17411,
29873,
348,
2396,
13,
4706,
474,
353,
474,
718,
29871,
29896,
13,
4706,
18515,
29918,
978,
353,
10876,
29889,
19218,
29961,
29875,
29962,
13,
1678,
25342,
10876,
29889,
19218,
29961,
29875,
29962,
1275,
17411,
4645,
2396,
13,
4706,
4464,
353,
525,
29883,
29915,
13,
4706,
474,
353,
474,
718,
29871,
29896,
13,
4706,
10377,
29918,
392,
29918,
637,
353,
10876,
29889,
19218,
29961,
29875,
1822,
5451,
29898,
19570,
29922,
2396,
742,
4236,
5451,
29922,
29906,
29897,
13,
4706,
28915,
353,
313,
666,
29918,
392,
29918,
637,
29961,
29900,
1402,
938,
29898,
666,
29918,
392,
29918,
637,
29961,
29896,
1402,
29871,
29896,
29900,
876,
13,
1678,
25342,
10876,
29889,
19218,
29961,
29875,
29962,
1275,
17411,
2974,
2396,
13,
4706,
4464,
353,
525,
29879,
29915,
13,
4706,
474,
353,
474,
718,
29871,
29896,
13,
4706,
28915,
353,
4852,
613,
938,
29898,
9675,
29889,
19218,
29961,
29875,
1402,
29871,
29896,
29900,
876,
13,
1678,
25342,
10876,
29889,
19218,
29961,
29875,
29962,
1275,
17411,
1989,
2396,
13,
4706,
474,
353,
474,
718,
29871,
29896,
13,
4706,
1820,
353,
938,
29898,
9675,
29889,
19218,
29961,
29875,
1402,
29871,
29896,
29953,
29897,
13,
1678,
25342,
10876,
29889,
19218,
29961,
29875,
29962,
1275,
17411,
5150,
2396,
13,
4706,
474,
353,
474,
718,
29871,
29896,
13,
4706,
4817,
29918,
7645,
353,
6262,
29898,
9675,
29889,
19218,
29961,
29875,
2314,
13,
1678,
25342,
10876,
29889,
19218,
29961,
29875,
29962,
1275,
17411,
29873,
16163,
2396,
13,
4706,
474,
353,
474,
718,
29871,
29896,
13,
4706,
26086,
29918,
1853,
353,
10876,
29889,
19218,
29961,
29875,
29962,
13,
1678,
25342,
10876,
29889,
19218,
29961,
29875,
29962,
1275,
17411,
4378,
29884,
2396,
13,
4706,
474,
353,
474,
718,
29871,
29896,
13,
4706,
341,
29911,
29965,
353,
938,
29898,
9675,
29889,
19218,
29961,
29875,
1402,
29871,
29896,
29900,
29897,
13,
1678,
25342,
10876,
29889,
19218,
29961,
29875,
29962,
1275,
17411,
12791,
2396,
13,
4706,
474,
353,
474,
718,
29871,
29896,
13,
4706,
7164,
29918,
386,
12268,
353,
938,
29898,
9675,
29889,
19218,
29961,
29875,
1402,
29871,
29896,
29900,
29897,
13,
4706,
7164,
29918,
3881,
353,
313,
12791,
29918,
386,
12268,
29892,
7164,
29918,
386,
12268,
718,
29871,
29906,
29900,
29900,
29897,
13,
1678,
1683,
29901,
13,
4706,
12020,
8960,
703,
26690,
2984,
376,
718,
10876,
29889,
19218,
29961,
29875,
2314,
13,
1678,
474,
353,
474,
718,
29871,
29896,
13,
13,
361,
4464,
338,
6213,
29901,
13,
1678,
1596,
703,
1217,
4464,
6790,
1159,
13,
1678,
6876,
29898,
29896,
29897,
13,
23681,
1820,
338,
6213,
29901,
13,
1678,
1596,
703,
578,
1820,
6790,
1159,
13,
1678,
6876,
29898,
29896,
29897,
13,
23681,
26086,
29918,
1853,
338,
6213,
29901,
13,
1678,
1596,
703,
1217,
26086,
1134,
6790,
1159,
13,
1678,
6876,
29898,
29896,
29897,
13,
23681,
26086,
29918,
1853,
1275,
525,
566,
29886,
2396,
13,
1678,
26086,
353,
318,
6099,
29889,
15789,
7982,
348,
29898,
13,
4706,
4464,
29892,
28915,
29892,
13,
4706,
274,
17929,
29889,
8566,
719,
29886,
357,
29898,
1989,
511,
274,
17929,
29889,
6185,
719,
29886,
357,
29898,
1989,
511,
4817,
29918,
7645,
29892,
13,
4706,
341,
29911,
29965,
29892,
13,
4706,
7164,
29918,
386,
12268,
29892,
7164,
29918,
3881,
29892,
13,
4706,
17927,
29889,
16363,
29898,
29945,
29897,
13,
1678,
1723,
13,
2870,
29901,
13,
1678,
1596,
703,
26690,
26086,
1134,
613,
26086,
29918,
1853,
29897,
13,
1678,
6876,
29898,
29896,
29897,
13,
13,
29873,
348,
353,
18515,
29889,
29911,
348,
29898,
29873,
348,
29918,
978,
29897,
13,
359,
29889,
649,
6272,
703,
29911,
3904,
29918,
5813,
613,
18515,
29889,
978,
29897,
13,
361,
4464,
1275,
525,
29883,
2396,
13,
1678,
2897,
29889,
649,
6272,
703,
1525,
29924,
2891,
29923,
29918,
5690,
613,
28915,
29961,
29900,
2314,
13,
1678,
2897,
29889,
649,
6272,
703,
1525,
29924,
2891,
29923,
29918,
15082,
613,
851,
29898,
10030,
29961,
29896,
12622,
13,
1678,
1014,
5014,
29889,
3389,
4197,
1642,
29914,
4645,
29889,
845,
20068,
13,
2870,
29901,
13,
1678,
2897,
29889,
649,
6272,
703,
24360,
1430,
29918,
15082,
613,
851,
29898,
10030,
29961,
29896,
12622,
13,
1678,
1014,
5014,
29889,
3389,
4197,
1642,
29914,
2974,
29889,
845,
20068,
13,
13,
1753,
5941,
786,
29898,
25436,
29892,
3515,
1125,
13,
1678,
565,
4464,
1275,
525,
29883,
2396,
13,
4706,
1014,
5014,
29889,
3389,
4197,
1642,
29914,
4645,
29899,
14941,
786,
29889,
845,
20068,
13,
1678,
1683,
29901,
13,
4706,
1014,
5014,
29889,
3389,
4197,
1642,
29914,
2974,
29899,
14941,
786,
29889,
845,
20068,
13,
1678,
6876,
29898,
29900,
29897,
13,
13,
1454,
4365,
297,
518,
7182,
29889,
5425,
29954,
29950,
4897,
29892,
7182,
29889,
5425,
29954,
10192,
29892,
7182,
29889,
5425,
29954,
13356,
1806,
29892,
7182,
29889,
5425,
29954,
4945,
29924,
4514,
29901,
13,
1678,
7182,
29889,
25436,
29898,
18816,
29892,
5941,
786,
29897,
13,
13,
2838,
353,
1831,
943,
29889,
4592,
10378,
580,
13,
2838,
29889,
9573,
29898,
29873,
348,
29889,
11512,
29892,
1831,
943,
29889,
22240,
3919,
29918,
16310,
29892,
29871,
29900,
29897,
13,
2838,
29889,
9573,
29898,
29873,
16163,
29889,
11514,
29892,
1831,
943,
29889,
22240,
3919,
29918,
16310,
29892,
29871,
29896,
29897,
13,
13,
8000,
5852,
29901,
13,
1678,
363,
313,
29879,
1989,
29892,
11105,
29897,
297,
5535,
29889,
2622,
7295,
13,
4706,
565,
269,
1989,
29889,
1272,
1275,
29871,
29900,
29901,
13,
9651,
848,
353,
2897,
29889,
949,
29898,
29873,
348,
29889,
11512,
29892,
341,
29911,
29965,
29897,
13,
9651,
26086,
29889,
6717,
29898,
1272,
29897,
13,
4706,
25342,
269,
1989,
29889,
1272,
1275,
29871,
29896,
29901,
13,
9651,
848,
353,
26086,
29889,
3757,
29894,
580,
13,
9651,
565,
848,
338,
451,
6213,
29901,
13,
18884,
2897,
29889,
3539,
29898,
29873,
348,
29889,
11512,
29892,
848,
29897,
13,
2
] |
PythonLearning/v0024.py | JoaoG10110/Python | 0 | 187459 | a = int(input('Digite o primeiro número: '))
b = int(input('Digite o segundo número: '))
c = int(input('Digite o terceiro número: '))
menor = a
if b<a and b<c:
menor = b
if c<a and c<b:
menor = c
maior = a
if b>a and b>c:
maior = b
if c>a and c>b:
maior = c
print(f'O maior valor é {maior}.')
print(f'O menor valor é {menor}')
| [
1,
263,
353,
938,
29898,
2080,
877,
14991,
568,
288,
19695,
13831,
29901,
525,
876,
13,
29890,
353,
938,
29898,
2080,
877,
14991,
568,
288,
14729,
13831,
29901,
525,
876,
13,
29883,
353,
938,
29898,
2080,
877,
14991,
568,
288,
1935,
346,
3350,
13831,
29901,
525,
876,
13,
1527,
272,
353,
263,
13,
361,
289,
29966,
29874,
322,
289,
29966,
29883,
29901,
13,
12,
1527,
272,
353,
289,
13,
361,
274,
29966,
29874,
322,
274,
29966,
29890,
29901,
13,
12,
1527,
272,
353,
274,
13,
655,
1611,
353,
263,
13,
361,
289,
29958,
29874,
322,
289,
29958,
29883,
29901,
13,
12,
655,
1611,
353,
289,
13,
361,
274,
29958,
29874,
322,
274,
29958,
29890,
29901,
13,
12,
655,
1611,
353,
274,
13,
2158,
29898,
29888,
29915,
29949,
17136,
16497,
904,
426,
655,
1611,
1836,
1495,
13,
2158,
29898,
29888,
29915,
29949,
26764,
16497,
904,
426,
1527,
272,
29913,
1495,
13,
2
] |
test.py | CiscoBoschetti/PyGame-Learning-Environment | 0 | 140162 | from ple import PLE
from ple.games.pong import Pong
import pygame
import time
import sys
game = Pong(width=300, height=200)
p = PLE(game, fps=30, display_screen=True, force_fps=True)
p.init()
print(p.getActionSet())
nb_frames = 1000
action = None
for f in range(nb_frames):
if p.game_over():
p.reset_game()
obs = p.getScreenRGB()
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key:
action = event.key
print(action)
elif event.type == pygame.KEYUP:
action = None
p.act(action)
time.sleep(.05)
#This is a change | [
1,
515,
5644,
1053,
349,
1307,
13,
3166,
5644,
29889,
29887,
1280,
29889,
29886,
549,
1053,
349,
549,
13,
5215,
22028,
13,
5215,
931,
13,
5215,
10876,
13,
13,
11802,
353,
349,
549,
29898,
2103,
29922,
29941,
29900,
29900,
29892,
3171,
29922,
29906,
29900,
29900,
29897,
13,
13,
29886,
353,
349,
1307,
29898,
11802,
29892,
285,
567,
29922,
29941,
29900,
29892,
2479,
29918,
10525,
29922,
5574,
29892,
4889,
29918,
29888,
567,
29922,
5574,
29897,
13,
29886,
29889,
2344,
580,
13,
13,
2158,
29898,
29886,
29889,
657,
4276,
2697,
3101,
13,
13,
9877,
29918,
19935,
353,
29871,
29896,
29900,
29900,
29900,
13,
2467,
353,
6213,
13,
13,
1454,
285,
297,
3464,
29898,
9877,
29918,
19935,
1125,
13,
1678,
565,
282,
29889,
11802,
29918,
957,
7295,
13,
4706,
282,
29889,
12071,
29918,
11802,
580,
13,
1678,
20881,
353,
282,
29889,
657,
11357,
28212,
580,
13,
1678,
4959,
353,
22028,
29889,
3696,
29889,
657,
580,
13,
1678,
363,
1741,
297,
4959,
29901,
13,
4706,
565,
1741,
29889,
1853,
1275,
22028,
29889,
13356,
1806,
29901,
13,
9651,
10876,
29889,
13322,
580,
13,
4706,
25342,
1741,
29889,
1853,
1275,
22028,
29889,
10818,
3970,
16048,
29901,
13,
9651,
565,
1741,
29889,
1989,
29901,
13,
18884,
3158,
353,
1741,
29889,
1989,
13,
18884,
1596,
29898,
2467,
29897,
13,
4706,
25342,
1741,
29889,
1853,
1275,
22028,
29889,
10818,
4897,
29901,
13,
9651,
3158,
353,
6213,
13,
1678,
282,
29889,
627,
29898,
2467,
29897,
13,
1678,
931,
29889,
17059,
11891,
29900,
29945,
29897,
13,
13,
29937,
4013,
338,
263,
1735,
2
] |
string/komand_string/actions/upper/schema.py | xhennessy-r7/insightconnect-plugins | 0 | 80217 | <gh_stars>0
# GENERATED BY KOMAND SDK - DO NOT EDIT
import komand
import json
class Input:
STRING = "string"
class Output:
UPPER = "upper"
class UpperInput(komand.Input):
schema = json.loads("""
{
"type": "object",
"title": "Variables",
"properties": {
"string": {
"type": "string",
"title": "String Input",
"description": "String to convert e.g. USER=bob",
"order": 1
}
},
"required": [
"string"
]
}
""")
def __init__(self):
super(self.__class__, self).__init__(self.schema)
class UpperOutput(komand.Output):
schema = json.loads("""
{
"type": "object",
"title": "Variables",
"properties": {
"upper": {
"type": "string",
"title": "Uppercase",
"description": "Uppercase string",
"order": 1
}
}
}
""")
def __init__(self):
super(self.__class__, self).__init__(self.schema)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
402,
1430,
1001,
3040,
29928,
6770,
476,
29949,
1529,
2797,
12967,
448,
11662,
6058,
11488,
13,
5215,
4677,
392,
13,
5215,
4390,
13,
13,
13,
1990,
10567,
29901,
13,
1678,
29486,
4214,
353,
376,
1807,
29908,
13,
268,
13,
13,
1990,
10604,
29901,
13,
1678,
11901,
13171,
353,
376,
21064,
29908,
13,
268,
13,
13,
1990,
24929,
4290,
29898,
7218,
392,
29889,
4290,
1125,
13,
1678,
10938,
353,
4390,
29889,
18132,
703,
15945,
13,
259,
426,
13,
29871,
376,
1853,
1115,
376,
3318,
613,
13,
29871,
376,
3257,
1115,
376,
10444,
1849,
613,
13,
29871,
376,
11330,
1115,
426,
13,
1678,
376,
1807,
1115,
426,
13,
418,
376,
1853,
1115,
376,
1807,
613,
13,
418,
376,
3257,
1115,
376,
1231,
10567,
613,
13,
418,
376,
8216,
1115,
376,
1231,
304,
3588,
321,
29889,
29887,
29889,
3148,
1001,
29922,
29890,
711,
613,
13,
418,
376,
2098,
1115,
29871,
29896,
13,
1678,
500,
13,
29871,
2981,
13,
29871,
376,
12403,
1115,
518,
13,
1678,
376,
1807,
29908,
13,
29871,
4514,
13,
29913,
13,
1678,
5124,
1159,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
2428,
29898,
1311,
17255,
1990,
1649,
29892,
1583,
467,
1649,
2344,
12035,
1311,
29889,
11010,
29897,
13,
13,
13,
1990,
24929,
6466,
29898,
7218,
392,
29889,
6466,
1125,
13,
1678,
10938,
353,
4390,
29889,
18132,
703,
15945,
13,
259,
426,
13,
29871,
376,
1853,
1115,
376,
3318,
613,
13,
29871,
376,
3257,
1115,
376,
10444,
1849,
613,
13,
29871,
376,
11330,
1115,
426,
13,
1678,
376,
21064,
1115,
426,
13,
418,
376,
1853,
1115,
376,
1807,
613,
13,
418,
376,
3257,
1115,
376,
26214,
4878,
613,
13,
418,
376,
8216,
1115,
376,
26214,
4878,
1347,
613,
13,
418,
376,
2098,
1115,
29871,
29896,
13,
1678,
500,
13,
29871,
500,
13,
29913,
13,
1678,
5124,
1159,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
2428,
29898,
1311,
17255,
1990,
1649,
29892,
1583,
467,
1649,
2344,
12035,
1311,
29889,
11010,
29897,
13,
2
] |
mitorch/datasets/image_dataset.py | shonohs/mitorch | 0 | 149362 | <gh_stars>0
import os
import pathlib
import zipfile
import PIL.Image
class ImageDataset:
def __init__(self, filename, transform):
filepath = pathlib.Path(filename)
self.transform = transform
self.images = []
self.base_dir = filepath.parent
self.reader = FileReader(self.base_dir)
with open(filename) as f:
for line in f:
image_filepath, target = line.strip().split()
image_filepath = image_filepath.strip()
target = self._load_target(target)
self.images.append((image_filepath, target))
max_label = self._get_max_label()
self._labels = self._load_labels(max_label)
def _load_labels(self, max_label):
"""Load if there is labels.txt. If not, generate dummy labels"""
labels_filepath = self.base_dir / 'labels.txt'
if labels_filepath.exists():
with open(labels_filepath) as f:
labels = [line.strip() for line in f.readlines()]
assert len(labels) > max_label
return labels
else:
return [f'label_{i}' for i in range(max_label + 1)]
@property
def labels(self):
return self._labels
def __len__(self):
return len(self.images)
def __getitem__(self, index):
image_filepath, target = self.images[index]
with self.reader.open(image_filepath, 'rb') as f:
image = PIL.Image.open(f)
image = image.convert('RGB') # Some image might have 1-channel. Also this method makes sure that the image is loaded.
return self.transform(image, target)
def _load_target(self, target):
raise NotImplementedError
def _get_max_label(self):
raise NotImplementedError
@classmethod
def from_file(cls, filename, transform):
dataset_type = cls._detect_type(filename)
if dataset_type == 'multiclass_classification':
return MulticlassClassificationDataset(filename, transform)
elif dataset_type == 'multilabel_classification':
return MultilabelClassificationDataset(filename, transform)
elif dataset_type == 'object_detection':
return ObjectDetectionDataset(filename, transform)
else:
raise NotImplementedError(f"Non supported dataset type: {dataset_type}")
@staticmethod
def _detect_type(filename):
with open(filename) as f:
for line in f:
_, labels = line.split()
if '@' in labels or '.' in labels:
return 'object_detection'
if ',' in labels:
return 'multilabel_classification'
return 'multiclass_classification'
class ThreadSafeZipFile(zipfile.ZipFile):
def __init__(self, zip_filepath):
self.zip_filepath = zip_filepath
self.cache = {}
def open(self, filepath):
if os.getpid() not in self.cache:
self.cache[os.getpid()] = zipfile.ZipFile(self.zip_filepath)
return self.cache[os.getpid()].open(filepath, 'r')
def close(self):
for zip_file in self.cache.values():
zip_file.close()
class FileReader:
def __init__(self, base_dir):
self.base_dir = base_dir
self.zipfile_cache = {}
def open(self, filepath, mode='r'):
if '@' in filepath:
zip_filepath, filepath = filepath.split('@')
if zip_filepath not in self.zipfile_cache:
self.zipfile_cache[zip_filepath] = ThreadSafeZipFile(self.base_dir / zip_filepath)
return self.zipfile_cache[zip_filepath].open(filepath)
else:
return open(self.base_dir / filepath, mode)
def __getstate__(self):
return {'base_dir': self.base_dir}
def __setstate__(self, state):
self.base_dir = state['base_dir']
self.zipfile_cache = {}
class MulticlassClassificationDataset(ImageDataset):
def _get_max_label(self):
return max(i[1] for i in self.images)
@staticmethod
def _load_target(target):
return int(target)
class MultilabelClassificationDataset(ImageDataset):
def _get_max_label(self):
return max(j for i in self.images for j in i[1])
@staticmethod
def _load_target(target):
return [int(t) for t in target.split(',')]
class ObjectDetectionDataset(ImageDataset):
def _get_max_label(self):
return max(j[0] for i in self.images for j in i[1])
def _load_target(self, targetpath):
with self.reader.open(targetpath) as f:
# label, x_min, y_min, x_max, y_max. Those are not normalized.
targets = [line.strip().split() for line in f]
targets = [(int(t[0]), int(float(t[1])), int(float(t[2])), int(float(t[3])), int(float(t[4]))) for t in targets]
return [t for t in targets if t[1] < t[3] and t[2] < t[4]] # Remove invalid bounding boxes.
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
2897,
13,
5215,
2224,
1982,
13,
5215,
14319,
1445,
13,
5215,
349,
6227,
29889,
2940,
13,
13,
13,
1990,
7084,
16390,
24541,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
10422,
29892,
4327,
1125,
13,
4706,
934,
2084,
353,
2224,
1982,
29889,
2605,
29898,
9507,
29897,
13,
4706,
1583,
29889,
9067,
353,
4327,
13,
4706,
1583,
29889,
8346,
353,
5159,
13,
4706,
1583,
29889,
3188,
29918,
3972,
353,
934,
2084,
29889,
3560,
13,
4706,
1583,
29889,
16950,
353,
3497,
6982,
29898,
1311,
29889,
3188,
29918,
3972,
29897,
13,
13,
4706,
411,
1722,
29898,
9507,
29897,
408,
285,
29901,
13,
9651,
363,
1196,
297,
285,
29901,
13,
18884,
1967,
29918,
1445,
2084,
29892,
3646,
353,
1196,
29889,
17010,
2141,
5451,
580,
13,
18884,
1967,
29918,
1445,
2084,
353,
1967,
29918,
1445,
2084,
29889,
17010,
580,
13,
18884,
3646,
353,
1583,
3032,
1359,
29918,
5182,
29898,
5182,
29897,
13,
18884,
1583,
29889,
8346,
29889,
4397,
3552,
3027,
29918,
1445,
2084,
29892,
3646,
876,
13,
13,
4706,
4236,
29918,
1643,
353,
1583,
3032,
657,
29918,
3317,
29918,
1643,
580,
13,
4706,
1583,
3032,
21134,
353,
1583,
3032,
1359,
29918,
21134,
29898,
3317,
29918,
1643,
29897,
13,
13,
1678,
822,
903,
1359,
29918,
21134,
29898,
1311,
29892,
4236,
29918,
1643,
1125,
13,
4706,
9995,
5896,
565,
727,
338,
11073,
29889,
3945,
29889,
960,
451,
29892,
5706,
20254,
11073,
15945,
29908,
13,
4706,
11073,
29918,
1445,
2084,
353,
1583,
29889,
3188,
29918,
3972,
847,
525,
21134,
29889,
3945,
29915,
13,
4706,
565,
11073,
29918,
1445,
2084,
29889,
9933,
7295,
13,
9651,
411,
1722,
29898,
21134,
29918,
1445,
2084,
29897,
408,
285,
29901,
13,
18884,
11073,
353,
518,
1220,
29889,
17010,
580,
363,
1196,
297,
285,
29889,
949,
9012,
580,
29962,
13,
18884,
4974,
7431,
29898,
21134,
29897,
1405,
4236,
29918,
1643,
13,
18884,
736,
11073,
13,
4706,
1683,
29901,
13,
9651,
736,
518,
29888,
29915,
1643,
648,
29875,
10162,
363,
474,
297,
3464,
29898,
3317,
29918,
1643,
718,
29871,
29896,
4638,
13,
13,
1678,
732,
6799,
13,
1678,
822,
11073,
29898,
1311,
1125,
13,
4706,
736,
1583,
3032,
21134,
13,
13,
1678,
822,
4770,
2435,
12035,
1311,
1125,
13,
4706,
736,
7431,
29898,
1311,
29889,
8346,
29897,
13,
13,
1678,
822,
4770,
657,
667,
12035,
1311,
29892,
2380,
1125,
13,
4706,
1967,
29918,
1445,
2084,
29892,
3646,
353,
1583,
29889,
8346,
29961,
2248,
29962,
13,
4706,
411,
1583,
29889,
16950,
29889,
3150,
29898,
3027,
29918,
1445,
2084,
29892,
525,
6050,
1495,
408,
285,
29901,
13,
9651,
1967,
353,
349,
6227,
29889,
2940,
29889,
3150,
29898,
29888,
29897,
13,
9651,
1967,
353,
1967,
29889,
13441,
877,
28212,
1495,
29871,
396,
3834,
1967,
1795,
505,
29871,
29896,
29899,
12719,
29889,
3115,
445,
1158,
3732,
1854,
393,
278,
1967,
338,
7500,
29889,
13,
4706,
736,
1583,
29889,
9067,
29898,
3027,
29892,
3646,
29897,
13,
13,
1678,
822,
903,
1359,
29918,
5182,
29898,
1311,
29892,
3646,
1125,
13,
4706,
12020,
2216,
1888,
2037,
287,
2392,
13,
13,
1678,
822,
903,
657,
29918,
3317,
29918,
1643,
29898,
1311,
1125,
13,
4706,
12020,
2216,
1888,
2037,
287,
2392,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
515,
29918,
1445,
29898,
25932,
29892,
10422,
29892,
4327,
1125,
13,
4706,
8783,
29918,
1853,
353,
1067,
29879,
3032,
4801,
522,
29918,
1853,
29898,
9507,
29897,
13,
4706,
565,
8783,
29918,
1853,
1275,
525,
4713,
293,
605,
29918,
1990,
2450,
2396,
13,
9651,
736,
9683,
293,
605,
2385,
2450,
16390,
24541,
29898,
9507,
29892,
4327,
29897,
13,
4706,
25342,
8783,
29918,
1853,
1275,
525,
4713,
309,
1107,
29918,
1990,
2450,
2396,
13,
9651,
736,
9683,
309,
1107,
2385,
2450,
16390,
24541,
29898,
9507,
29892,
4327,
29897,
13,
4706,
25342,
8783,
29918,
1853,
1275,
525,
3318,
29918,
29881,
2650,
428,
2396,
13,
9651,
736,
4669,
29928,
2650,
428,
16390,
24541,
29898,
9507,
29892,
4327,
29897,
13,
4706,
1683,
29901,
13,
9651,
12020,
2216,
1888,
2037,
287,
2392,
29898,
29888,
29908,
12283,
6969,
8783,
1134,
29901,
426,
24713,
29918,
1853,
27195,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
903,
4801,
522,
29918,
1853,
29898,
9507,
1125,
13,
4706,
411,
1722,
29898,
9507,
29897,
408,
285,
29901,
13,
9651,
363,
1196,
297,
285,
29901,
13,
18884,
17117,
11073,
353,
1196,
29889,
5451,
580,
13,
18884,
565,
18803,
29915,
297,
11073,
470,
525,
6169,
297,
11073,
29901,
13,
462,
1678,
736,
525,
3318,
29918,
29881,
2650,
428,
29915,
13,
18884,
565,
525,
5501,
297,
11073,
29901,
13,
462,
1678,
736,
525,
4713,
309,
1107,
29918,
1990,
2450,
29915,
13,
4706,
736,
525,
4713,
293,
605,
29918,
1990,
2450,
29915,
13,
13,
13,
1990,
10480,
17618,
1725,
26264,
2283,
29898,
7554,
1445,
29889,
26264,
2283,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
14319,
29918,
1445,
2084,
1125,
13,
4706,
1583,
29889,
7554,
29918,
1445,
2084,
353,
14319,
29918,
1445,
2084,
13,
4706,
1583,
29889,
8173,
353,
6571,
13,
13,
1678,
822,
1722,
29898,
1311,
29892,
934,
2084,
1125,
13,
4706,
565,
2897,
29889,
657,
5935,
580,
451,
297,
1583,
29889,
8173,
29901,
13,
9651,
1583,
29889,
8173,
29961,
359,
29889,
657,
5935,
580,
29962,
353,
14319,
1445,
29889,
26264,
2283,
29898,
1311,
29889,
7554,
29918,
1445,
2084,
29897,
13,
4706,
736,
1583,
29889,
8173,
29961,
359,
29889,
657,
5935,
580,
1822,
3150,
29898,
1445,
2084,
29892,
525,
29878,
1495,
13,
13,
1678,
822,
3802,
29898,
1311,
1125,
13,
4706,
363,
14319,
29918,
1445,
297,
1583,
29889,
8173,
29889,
5975,
7295,
13,
9651,
14319,
29918,
1445,
29889,
5358,
580,
13,
13,
13,
1990,
3497,
6982,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
2967,
29918,
3972,
1125,
13,
4706,
1583,
29889,
3188,
29918,
3972,
353,
2967,
29918,
3972,
13,
4706,
1583,
29889,
7554,
1445,
29918,
8173,
353,
6571,
13,
13,
1678,
822,
1722,
29898,
1311,
29892,
934,
2084,
29892,
4464,
2433,
29878,
29374,
13,
4706,
565,
18803,
29915,
297,
934,
2084,
29901,
13,
9651,
14319,
29918,
1445,
2084,
29892,
934,
2084,
353,
934,
2084,
29889,
5451,
877,
29992,
1495,
13,
9651,
565,
14319,
29918,
1445,
2084,
451,
297,
1583,
29889,
7554,
1445,
29918,
8173,
29901,
13,
18884,
1583,
29889,
7554,
1445,
29918,
8173,
29961,
7554,
29918,
1445,
2084,
29962,
353,
10480,
17618,
1725,
26264,
2283,
29898,
1311,
29889,
3188,
29918,
3972,
847,
14319,
29918,
1445,
2084,
29897,
13,
9651,
736,
1583,
29889,
7554,
1445,
29918,
8173,
29961,
7554,
29918,
1445,
2084,
1822,
3150,
29898,
1445,
2084,
29897,
13,
4706,
1683,
29901,
13,
9651,
736,
1722,
29898,
1311,
29889,
3188,
29918,
3972,
847,
934,
2084,
29892,
4464,
29897,
13,
13,
1678,
822,
4770,
657,
3859,
12035,
1311,
1125,
13,
4706,
736,
11117,
3188,
29918,
3972,
2396,
1583,
29889,
3188,
29918,
3972,
29913,
13,
13,
1678,
822,
4770,
842,
3859,
12035,
1311,
29892,
2106,
1125,
13,
4706,
1583,
29889,
3188,
29918,
3972,
353,
2106,
1839,
3188,
29918,
3972,
2033,
13,
4706,
1583,
29889,
7554,
1445,
29918,
8173,
353,
6571,
13,
13,
13,
1990,
9683,
293,
605,
2385,
2450,
16390,
24541,
29898,
2940,
16390,
24541,
1125,
13,
1678,
822,
903,
657,
29918,
3317,
29918,
1643,
29898,
1311,
1125,
13,
4706,
736,
4236,
29898,
29875,
29961,
29896,
29962,
363,
474,
297,
1583,
29889,
8346,
29897,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
903,
1359,
29918,
5182,
29898,
5182,
1125,
13,
4706,
736,
938,
29898,
5182,
29897,
13,
13,
13,
1990,
9683,
309,
1107,
2385,
2450,
16390,
24541,
29898,
2940,
16390,
24541,
1125,
13,
1678,
822,
903,
657,
29918,
3317,
29918,
1643,
29898,
1311,
1125,
13,
4706,
736,
4236,
29898,
29926,
363,
474,
297,
1583,
29889,
8346,
363,
432,
297,
474,
29961,
29896,
2314,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
903,
1359,
29918,
5182,
29898,
5182,
1125,
13,
4706,
736,
518,
524,
29898,
29873,
29897,
363,
260,
297,
3646,
29889,
5451,
29317,
1495,
29962,
13,
13,
13,
1990,
4669,
29928,
2650,
428,
16390,
24541,
29898,
2940,
16390,
24541,
1125,
13,
1678,
822,
903,
657,
29918,
3317,
29918,
1643,
29898,
1311,
1125,
13,
4706,
736,
4236,
29898,
29926,
29961,
29900,
29962,
363,
474,
297,
1583,
29889,
8346,
363,
432,
297,
474,
29961,
29896,
2314,
13,
13,
1678,
822,
903,
1359,
29918,
5182,
29898,
1311,
29892,
3646,
2084,
1125,
13,
4706,
411,
1583,
29889,
16950,
29889,
3150,
29898,
5182,
2084,
29897,
408,
285,
29901,
13,
9651,
396,
3858,
29892,
921,
29918,
1195,
29892,
343,
29918,
1195,
29892,
921,
29918,
3317,
29892,
343,
29918,
3317,
29889,
16025,
526,
451,
4226,
1891,
29889,
13,
9651,
22525,
353,
518,
1220,
29889,
17010,
2141,
5451,
580,
363,
1196,
297,
285,
29962,
13,
9651,
22525,
353,
17288,
524,
29898,
29873,
29961,
29900,
11724,
938,
29898,
7411,
29898,
29873,
29961,
29896,
2314,
511,
938,
29898,
7411,
29898,
29873,
29961,
29906,
2314,
511,
938,
29898,
7411,
29898,
29873,
29961,
29941,
2314,
511,
938,
29898,
7411,
29898,
29873,
29961,
29946,
29962,
4961,
363,
260,
297,
22525,
29962,
13,
9651,
736,
518,
29873,
363,
260,
297,
22525,
565,
260,
29961,
29896,
29962,
529,
260,
29961,
29941,
29962,
322,
260,
29961,
29906,
29962,
529,
260,
29961,
29946,
5262,
29871,
396,
15154,
8340,
3216,
292,
16273,
29889,
13,
2
] |
modules/courses/courses.py | ehiller/mobilecsp-v18 | 0 | 3621 | <reponame>ehiller/mobilecsp-v18<filename>modules/courses/courses.py
# Copyright 2012 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Courses module."""
__author__ = '<NAME> (<EMAIL>)'
from common import resource
from controllers import assessments
from controllers import lessons
from controllers import utils
from models import content
from models import resources_display
from models import custom_modules
from models import roles
from tools import verify
All_LOCALES_PERMISSION = 'can_pick_all_locales'
All_LOCALES_DESCRIPTION = 'Can pick all locales, including unavailable ones.'
SEE_DRAFTS_PERMISSION = 'can_see_draft_content'
SEE_DRAFTS_DESCRIPTION = 'Can see lessons and assessments with draft status.'
custom_module = None
def can_pick_all_locales(app_context):
return roles.Roles.is_user_allowed(
app_context, custom_module, All_LOCALES_PERMISSION)
def can_see_drafts(app_context):
return roles.Roles.is_user_allowed(
app_context, custom_module, SEE_DRAFTS_PERMISSION)
def register_module():
"""Registers this module in the registry."""
def on_module_enabled():
roles.Roles.register_permissions(custom_module, permissions_callback)
resource.Registry.register(resources_display.ResourceCourseSettings)
resource.Registry.register(resources_display.ResourceUnit)
resource.Registry.register(resources_display.ResourceAssessment)
resource.Registry.register(resources_display.ResourceLink)
resource.Registry.register(resources_display.ResourceLesson)
resource.Registry.register(utils.ResourceHtmlHook)
def permissions_callback(unused_app_context):
return [
roles.Permission(All_LOCALES_PERMISSION, All_LOCALES_DESCRIPTION),
roles.Permission(SEE_DRAFTS_PERMISSION, SEE_DRAFTS_DESCRIPTION)
]
# provide parser to verify
verify.parse_content = content.parse_string_in_scope
# setup routes
courses_routes = [
('/', lessons.CourseHandler),
('/activity', lessons.UnitHandler),
('/answer', assessments.AnswerHandler),
('/assessment', lessons.AssessmentHandler),
('/course', lessons.CourseHandler),
('/forum', utils.ForumHandler),
('/preview', utils.PreviewHandler),
('/register', utils.RegisterHandler),
('/resources', utils.ResourcesHandler),
('/rest/locale', utils.StudentLocaleRESTHandler),
('/review', lessons.ReviewHandler),
('/reviewdashboard', lessons.ReviewDashboardHandler),
('/student/editstudent', utils.StudentEditStudentHandler),
('/student/settracks', utils.StudentSetTracksHandler),
('/student/home', utils.StudentProfileHandler),
('/student/unenroll', utils.StudentUnenrollHandler),
('/unit', lessons.UnitHandler)]
global custom_module # pylint: disable=global-statement
custom_module = custom_modules.Module(
'Course',
'A set of pages for delivering an online course.',
[], courses_routes,
notify_module_enabled=on_module_enabled)
return custom_module
| [
1,
529,
276,
1112,
420,
29958,
14797,
5495,
29914,
16769,
29883,
1028,
29899,
29894,
29896,
29947,
29966,
9507,
29958,
7576,
29914,
29883,
29781,
29914,
29883,
29781,
29889,
2272,
13,
29937,
14187,
1266,
29871,
29906,
29900,
29896,
29906,
5087,
9266,
29889,
2178,
26863,
2538,
9841,
29889,
13,
29937,
13,
29937,
10413,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
29937,
366,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
29937,
887,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
418,
1732,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
29937,
13,
29937,
25870,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
29937,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
29899,
3235,
29908,
350,
3289,
3235,
29892,
13,
29937,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
13,
29937,
2823,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
29937,
27028,
1090,
278,
19245,
29889,
13,
13,
15945,
29908,
29907,
29781,
3883,
1213,
15945,
13,
13,
1649,
8921,
1649,
353,
12801,
5813,
29958,
313,
29966,
26862,
6227,
12948,
29915,
13,
13,
3166,
3619,
1053,
6503,
13,
3166,
21385,
1053,
24809,
1860,
13,
3166,
21385,
1053,
3109,
787,
13,
3166,
21385,
1053,
3667,
29879,
13,
3166,
4733,
1053,
2793,
13,
3166,
4733,
1053,
7788,
29918,
4990,
13,
3166,
4733,
1053,
2888,
29918,
7576,
13,
3166,
4733,
1053,
16178,
13,
3166,
8492,
1053,
11539,
13,
13,
13,
3596,
29918,
3927,
5454,
17101,
29918,
13171,
10403,
13507,
353,
525,
3068,
29918,
23945,
29918,
497,
29918,
2997,
267,
29915,
13,
3596,
29918,
3927,
5454,
17101,
29918,
2287,
7187,
24290,
2725,
353,
525,
6028,
5839,
599,
1887,
267,
29892,
3704,
443,
16515,
6743,
6169,
13,
13,
22048,
29918,
29928,
4717,
7818,
29903,
29918,
13171,
10403,
13507,
353,
525,
3068,
29918,
4149,
29918,
29881,
4154,
29918,
3051,
29915,
13,
22048,
29918,
29928,
4717,
7818,
29903,
29918,
2287,
7187,
24290,
2725,
353,
525,
6028,
1074,
3109,
787,
322,
24809,
1860,
411,
18195,
4660,
6169,
13,
13,
13,
6341,
29918,
5453,
353,
6213,
13,
13,
13,
1753,
508,
29918,
23945,
29918,
497,
29918,
2997,
267,
29898,
932,
29918,
4703,
1125,
13,
1678,
736,
16178,
29889,
29934,
6544,
29889,
275,
29918,
1792,
29918,
24622,
29898,
13,
4706,
623,
29918,
4703,
29892,
2888,
29918,
5453,
29892,
2178,
29918,
3927,
5454,
17101,
29918,
13171,
10403,
13507,
29897,
13,
13,
13,
1753,
508,
29918,
4149,
29918,
29881,
4154,
29879,
29898,
932,
29918,
4703,
1125,
13,
1678,
736,
16178,
29889,
29934,
6544,
29889,
275,
29918,
1792,
29918,
24622,
29898,
13,
4706,
623,
29918,
4703,
29892,
2888,
29918,
5453,
29892,
3725,
29923,
29918,
29928,
4717,
7818,
29903,
29918,
13171,
10403,
13507,
29897,
13,
13,
13,
1753,
6036,
29918,
5453,
7295,
13,
1678,
9995,
15213,
29879,
445,
3883,
297,
278,
21235,
1213,
15945,
13,
13,
1678,
822,
373,
29918,
5453,
29918,
17590,
7295,
13,
4706,
16178,
29889,
29934,
6544,
29889,
9573,
29918,
17858,
6847,
29898,
6341,
29918,
5453,
29892,
11239,
29918,
14035,
29897,
13,
4706,
6503,
29889,
22579,
29889,
9573,
29898,
13237,
29918,
4990,
29889,
6848,
29907,
10242,
9585,
29897,
13,
4706,
6503,
29889,
22579,
29889,
9573,
29898,
13237,
29918,
4990,
29889,
6848,
8325,
29897,
13,
4706,
6503,
29889,
22579,
29889,
9573,
29898,
13237,
29918,
4990,
29889,
6848,
7900,
404,
358,
29897,
13,
4706,
6503,
29889,
22579,
29889,
9573,
29898,
13237,
29918,
4990,
29889,
6848,
6595,
29897,
13,
4706,
6503,
29889,
22579,
29889,
9573,
29898,
13237,
29918,
4990,
29889,
6848,
29931,
404,
265,
29897,
13,
4706,
6503,
29889,
22579,
29889,
9573,
29898,
13239,
29889,
6848,
10922,
29950,
2550,
29897,
13,
13,
1678,
822,
11239,
29918,
14035,
29898,
348,
3880,
29918,
932,
29918,
4703,
1125,
13,
4706,
736,
518,
13,
9651,
16178,
29889,
27293,
29898,
3596,
29918,
3927,
5454,
17101,
29918,
13171,
10403,
13507,
29892,
2178,
29918,
3927,
5454,
17101,
29918,
2287,
7187,
24290,
2725,
511,
13,
9651,
16178,
29889,
27293,
29898,
22048,
29918,
29928,
4717,
7818,
29903,
29918,
13171,
10403,
13507,
29892,
3725,
29923,
29918,
29928,
4717,
7818,
29903,
29918,
2287,
7187,
24290,
2725,
29897,
13,
4706,
4514,
13,
13,
1678,
396,
3867,
13812,
304,
11539,
13,
1678,
11539,
29889,
5510,
29918,
3051,
353,
2793,
29889,
5510,
29918,
1807,
29918,
262,
29918,
6078,
13,
13,
1678,
396,
6230,
12049,
13,
1678,
21888,
29918,
27894,
353,
518,
13,
4706,
6702,
29914,
742,
3109,
787,
29889,
29907,
10242,
4598,
511,
13,
4706,
6702,
29914,
10072,
742,
3109,
787,
29889,
8325,
4598,
511,
13,
4706,
6702,
29914,
12011,
742,
24809,
1860,
29889,
22550,
4598,
511,
13,
4706,
6702,
29914,
465,
404,
358,
742,
3109,
787,
29889,
7900,
404,
358,
4598,
511,
13,
4706,
6702,
29914,
15775,
742,
3109,
787,
29889,
29907,
10242,
4598,
511,
13,
4706,
6702,
29914,
23343,
742,
3667,
29879,
29889,
2831,
398,
4598,
511,
13,
4706,
6702,
29914,
25347,
742,
3667,
29879,
29889,
6572,
1493,
4598,
511,
13,
4706,
6702,
29914,
9573,
742,
3667,
29879,
29889,
15213,
4598,
511,
13,
4706,
6702,
29914,
13237,
742,
3667,
29879,
29889,
13770,
4598,
511,
13,
4706,
6702,
29914,
5060,
29914,
23337,
742,
3667,
29879,
29889,
20791,
3524,
744,
1525,
1254,
4598,
511,
13,
4706,
6702,
29914,
27828,
742,
3109,
787,
29889,
1123,
1493,
4598,
511,
13,
4706,
6702,
29914,
27828,
14592,
3377,
742,
3109,
787,
29889,
1123,
1493,
29928,
1161,
3377,
4598,
511,
13,
4706,
6702,
29914,
18945,
29914,
5628,
18945,
742,
3667,
29879,
29889,
20791,
6103,
20791,
4598,
511,
13,
4706,
6702,
29914,
18945,
29914,
842,
3018,
4684,
742,
3667,
29879,
29889,
20791,
2697,
5323,
4684,
4598,
511,
13,
4706,
6702,
29914,
18945,
29914,
5184,
742,
3667,
29879,
29889,
20791,
13909,
4598,
511,
13,
4706,
6702,
29914,
18945,
29914,
348,
264,
1245,
742,
3667,
29879,
29889,
20791,
2525,
264,
1245,
4598,
511,
13,
4706,
6702,
29914,
5441,
742,
3109,
787,
29889,
8325,
4598,
4638,
13,
13,
1678,
5534,
2888,
29918,
5453,
29871,
396,
282,
2904,
524,
29901,
11262,
29922,
10945,
29899,
20788,
13,
1678,
2888,
29918,
5453,
353,
2888,
29918,
7576,
29889,
7355,
29898,
13,
4706,
525,
29907,
10242,
742,
13,
4706,
525,
29909,
731,
310,
6515,
363,
12021,
292,
385,
7395,
3236,
29889,
742,
13,
4706,
19997,
21888,
29918,
27894,
29892,
13,
4706,
26051,
29918,
5453,
29918,
17590,
29922,
265,
29918,
5453,
29918,
17590,
29897,
13,
1678,
736,
2888,
29918,
5453,
13,
2
] |
scripts/study_case/ID_13/torch_geometric/transforms/face_to_edge.py | kzbnb/numerical_bugs | 8 | 132269 | import torch
from scripts.study_case.ID_13.torch_geometric.utils import to_undirected
class FaceToEdge(object):
def __call__(self, data):
face = data.face
edge_index = torch.cat([face[:2], face[1:], face[::2]], dim=1)
edge_index = to_undirected(edge_index, num_nodes=data.num_nodes)
data.edge_index = edge_index
data.face = None
return data
def __repr__(self):
return '{}()'.format(self.__class__.__name__)
| [
1,
1053,
4842,
305,
13,
3166,
12078,
29889,
18082,
29891,
29918,
4878,
29889,
1367,
29918,
29896,
29941,
29889,
7345,
305,
29918,
479,
14066,
29889,
13239,
1053,
304,
29918,
870,
1088,
287,
13,
13,
13,
1990,
10635,
1762,
23894,
29898,
3318,
1125,
13,
1678,
822,
4770,
4804,
12035,
1311,
29892,
848,
1125,
13,
4706,
3700,
353,
848,
29889,
2161,
13,
13,
4706,
7636,
29918,
2248,
353,
4842,
305,
29889,
4117,
4197,
2161,
7503,
29906,
1402,
3700,
29961,
29896,
29901,
1402,
3700,
29961,
1057,
29906,
20526,
3964,
29922,
29896,
29897,
13,
4706,
7636,
29918,
2248,
353,
304,
29918,
870,
1088,
287,
29898,
12864,
29918,
2248,
29892,
954,
29918,
18010,
29922,
1272,
29889,
1949,
29918,
18010,
29897,
13,
13,
4706,
848,
29889,
12864,
29918,
2248,
353,
7636,
29918,
2248,
13,
4706,
848,
29889,
2161,
353,
6213,
13,
4706,
736,
848,
13,
13,
1678,
822,
4770,
276,
558,
12035,
1311,
1125,
13,
4706,
736,
525,
8875,
580,
4286,
4830,
29898,
1311,
17255,
1990,
1649,
17255,
978,
1649,
29897,
13,
2
] |
lib/position.py | ArcosJuan/Get-out-of-my-fucking-maze | 2 | 190626 | <reponame>ArcosJuan/Get-out-of-my-fucking-maze<filename>lib/position.py
class Position:
""" Coordanates system that uses an 'y' and 'x' notation
to represent unequivocally a specific location that goes
universally for every object.
"""
__slots__ = ('y', 'x')
@staticmethod
def create_collection(first_position: tuple, last_position: tuple):
""" Generates the postions between the passed two position index.
"""
assert type(last_position[0]) == int and type(first_position[0]) == int, \
"'y' must be an int."
assert type(first_position[1]) == int and type(last_position[1]) == int, \
"'x' must be an int."
return [[Position(y, x)
for x in range(first_position[1], last_position[1] + 1)]
for y in range(first_position[0], last_position[0] + 1)]
def __init__(self, y:int, x:int):
self.y = y
self.x = x
def get_index(self):
return (self.y, self.x)
def __hash__(self): return hash((self.y, self.x))
def __repr__(self): return f"({self.y}, {self.x})"
def __getitem__(self, i): return list(self.get_index())[i]
def __eq__(self, other):
""" Uses the get_index method to equalize
both instannces of position
"""
try:
other_get_index = other.get_index
except AttributeError:
return False
return self.get_index() == other_get_index()
| [
1,
529,
276,
1112,
420,
29958,
1433,
3944,
29967,
12323,
29914,
2577,
29899,
449,
29899,
974,
29899,
1357,
29899,
29888,
2707,
292,
29899,
655,
911,
29966,
9507,
29958,
1982,
29914,
3283,
29889,
2272,
13,
13,
13,
1990,
20627,
29901,
13,
1678,
9995,
3189,
536,
273,
1078,
1788,
393,
3913,
385,
525,
29891,
29915,
322,
525,
29916,
29915,
12640,
29871,
13,
4706,
304,
2755,
1597,
339,
440,
542,
635,
263,
2702,
4423,
393,
5771,
29871,
13,
4706,
4946,
635,
363,
1432,
1203,
29889,
13,
1678,
9995,
13,
13,
1678,
4770,
2536,
1862,
1649,
353,
6702,
29891,
742,
525,
29916,
1495,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
1653,
29918,
10855,
29898,
4102,
29918,
3283,
29901,
18761,
29892,
1833,
29918,
3283,
29901,
18761,
1125,
13,
4706,
9995,
3251,
1078,
278,
1400,
1080,
1546,
278,
4502,
1023,
2602,
2380,
29889,
13,
4706,
9995,
13,
308,
13,
4706,
4974,
1134,
29898,
4230,
29918,
3283,
29961,
29900,
2314,
1275,
938,
322,
1134,
29898,
4102,
29918,
3283,
29961,
29900,
2314,
1275,
938,
29892,
320,
13,
9651,
13577,
29891,
29915,
1818,
367,
385,
938,
1213,
13,
13,
4706,
4974,
1134,
29898,
4102,
29918,
3283,
29961,
29896,
2314,
1275,
938,
322,
1134,
29898,
4230,
29918,
3283,
29961,
29896,
2314,
1275,
938,
29892,
320,
13,
9651,
13577,
29916,
29915,
1818,
367,
385,
938,
1213,
13,
13,
4706,
736,
5519,
8003,
29898,
29891,
29892,
921,
29897,
29871,
13,
9651,
363,
921,
297,
3464,
29898,
4102,
29918,
3283,
29961,
29896,
1402,
1833,
29918,
3283,
29961,
29896,
29962,
718,
29871,
29896,
4638,
13,
18884,
363,
343,
297,
3464,
29898,
4102,
29918,
3283,
29961,
29900,
1402,
1833,
29918,
3283,
29961,
29900,
29962,
718,
29871,
29896,
4638,
13,
268,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
343,
29901,
524,
29892,
921,
29901,
524,
1125,
13,
4706,
1583,
29889,
29891,
353,
343,
13,
4706,
1583,
29889,
29916,
353,
921,
13,
13,
13,
1678,
822,
679,
29918,
2248,
29898,
1311,
1125,
13,
4706,
736,
313,
1311,
29889,
29891,
29892,
1583,
29889,
29916,
29897,
13,
13,
13,
1678,
822,
4770,
8568,
12035,
1311,
1125,
736,
6608,
3552,
1311,
29889,
29891,
29892,
1583,
29889,
29916,
876,
13,
13,
13,
1678,
822,
4770,
276,
558,
12035,
1311,
1125,
736,
285,
29908,
3319,
1311,
29889,
29891,
1118,
426,
1311,
29889,
29916,
1800,
29908,
13,
13,
13,
1678,
822,
4770,
657,
667,
12035,
1311,
29892,
474,
1125,
736,
1051,
29898,
1311,
29889,
657,
29918,
2248,
3101,
29961,
29875,
29962,
13,
13,
13,
1678,
822,
4770,
1837,
12035,
1311,
29892,
916,
1125,
13,
4706,
9995,
10783,
267,
278,
679,
29918,
2248,
1158,
304,
5186,
675,
29871,
13,
9651,
1716,
832,
812,
778,
310,
2602,
13,
4706,
9995,
13,
13,
4706,
1018,
29901,
13,
9651,
916,
29918,
657,
29918,
2248,
353,
916,
29889,
657,
29918,
2248,
13,
4706,
5174,
23833,
2392,
29901,
13,
9651,
736,
7700,
13,
13,
4706,
736,
1583,
29889,
657,
29918,
2248,
580,
1275,
916,
29918,
657,
29918,
2248,
580,
13,
2
] |
cfy/server.py | buhanec/cloudify-flexiant-plugin | 0 | 10827 | # coding=UTF-8
"""Server stuff."""
from __future__ import print_function
from cfy import (create_server,
create_ssh_key,
attach_ssh_key,
wait_for_state,
wait_for_cond,
create_nic,
attach_nic,
get_resource,
get_server_status,
start_server,
stop_server,
delete_resource)
import socket
import errno
from cloudify import ctx
from cloudify.decorators import operation
from cloudify.exceptions import NonRecoverableError
from cfy.helpers import (with_fco_api, with_exceptions_handled)
from resttypes import enums, cobjects
from paramiko import SSHClient, AutoAddPolicy
import spur
import spur.ssh
from time import sleep
from subprocess import call
from fabric.api import settings, run
import os
RT = enums.ResourceType
PROP_RESOURCE_ID = 'resource_id'
PROP_USE_EXISTING = 'use_existing'
PROP_IMAGE = 'image'
PROP_VDC = 'vdc'
PROP_NET = 'network'
PROP_SERVER_PO = 'server_type'
PROP_CPU_COUNT = 'cpu_count'
PROP_RAM_AMOUNT = 'ram_amount'
PROP_MANAGER_KEY = 'manager_key'
PROP_PRIVATE_KEYS = 'private_keys'
PROP_PUBLIC_KEYS = 'public_keys'
RPROP_UUID = 'uuid'
RPROP_DISKS = 'disks'
RPROP_NIC = 'nic'
RPROP_NICS = 'nics'
RPROP_IP = 'ip'
RPROP_USER = 'username'
RPROP_PASS = 'password'
@operation
@with_fco_api
@with_exceptions_handled
def create(fco_api, *args, **kwargs):
ctx.logger.info('starting server creation')
# Ease of access
_rp = ctx.instance.runtime_properties
_np = ctx.node.properties
# Check if existing server is to be used
if _np[PROP_USE_EXISTING]:
server = get_resource(fco_api, _np[PROP_RESOURCE_ID, RT.SERVER])
if not server.nics:
raise Exception('No NICs attached to server')
_rp[RPROP_UUID] = server.resourceUUID
_rp[RPROP_DISKS] = [d.resourceUUID for d in server.disks]
_rp[RPROP_NIC] = server.nics[0].resourceUUID
_rp[RPROP_NICS] = [n.resourceUUID for n in server.nics]
_rp[RPROP_IP] = server.nics[0].ipAddresses[0].ipAddress
_rp[RPROP_USER] = server.initialUser
_rp[RPROP_PASS] = server.initialPassword
return (_rp[RPROP_UUID], _rp[RPROP_IP], _rp[RPROP_USER],
_rp[RPROP_PASS])
# Get configuration
image = get_resource(fco_api, _np[PROP_IMAGE], RT.IMAGE)
if _np[PROP_IMAGE]:
vdc = get_resource(fco_api, _np[PROP_VDC], RT.VDC)
else:
vdc = None
network = get_resource(fco_api, _np[PROP_NET], RT.NETWORK)
server_po = get_resource(fco_api, _np[PROP_SERVER_PO], RT.PRODUCTOFFER)
manager_key = get_resource(fco_api, _np[PROP_MANAGER_KEY], RT.SSHKEY)
cpu_count = _np[PROP_CPU_COUNT]
ram_amount = _np[PROP_RAM_AMOUNT]
public_keys = _np[PROP_PUBLIC_KEYS] or []
private_keys = _np[PROP_PRIVATE_KEYS] or []
# Verify existence of private keys
missing_keys = set()
bad_permission_keys = set()
key_contents = {}
for key in private_keys:
try:
key_contents[key] = ctx.get_resource(os.path.expanduser(key))
except NonRecoverableError as e:
if 'HttpException: 404' in str(e):
missing_keys.add(key)
elif 'HttpException: 403' in str(e):
bad_permission_keys.add(key)
else:
raise
if missing_keys or bad_permission_keys:
raise Exception('Missing private keys: {}\nBad permission keys: {}'
.format(missing_keys, bad_permission_keys))
# Generate missing configuration
image_uuid = image.resourceUUID
if vdc is not None:
cluster_uuid = vdc.clusterUUID
vdc_uuid = vdc.resourceUUID
else:
cluster_uuid = image.clusterUUID
vdc_uuid = image.vdcUUID
network_uuid = network.resourceUUID
network_type = network.networkType
server_po_uuid = server_po.resourceUUID
manager_key_uuid = manager_key.resourceUUID
# TODO: better way of determining suitable disk
boot_disk_po_uuid = get_resource(fco_api,
'{} GB Storage Disk'.format(image.size),
RT.PRODUCTOFFER).resourceUUID
ctx.logger.info('Configuration: \n'
'image_uuid: %s\n'
'cluster_uuid: %s\n'
'vdc_uuid: %s\n'
'network_uuid: %s\n'
'server_po_uuid: %s\n'
'manager_key_uuid: %s\n'
'boot_disk_po_uuid: %s',
image_uuid, cluster_uuid, vdc_uuid, network_uuid,
server_po_uuid, manager_key_uuid, boot_disk_po_uuid)
# Create server
server_name = '{}{}_{}'.format(ctx.bootstrap_context.resources_prefix,
ctx.deployment.id, ctx.instance.id)
try:
server_uuid = _rp[RPROP_UUID]
except KeyError:
# key_obj = get_resource(fco_api, key_uuid, RT.SSHKEY)
# keys = SSHKey.REQUIRED_ATTRIBS.copy()
# keys.add('resourceUUID')
# submit_key = {}
# for k in keys:
# try:
# submit_key[k] = getattr(manager_key, k)
# except AttributeError:
# submit_key[k] = None
server_uuid = create_server(fco_api, server_po_uuid, image_uuid,
cluster_uuid, vdc_uuid, cpu_count,
ram_amount, boot_disk_po_uuid,
[manager_key], server_name)
_rp[RPROP_UUID] = server_uuid
ctx.logger.info('server_uuid: %s', server_uuid)
server = get_resource(fco_api, server_uuid, RT.SERVER)
server_nics = [nic.resourceUUID for nic in server.nics]
server_keys = [key.resourceUUID for key in server.sshkeys]
# Wait for server to be active
if not wait_for_state(fco_api, server_uuid, enums.ResourceState.ACTIVE,
RT.SERVER):
raise Exception('Server failed to prepare in time!')
ctx.logger.info('Server ACTIVE')
# Add keys
new_keys = set()
for key in public_keys:
if key not in server_keys:
key_uuid = create_ssh_key(fco_api, key, server_name + ' Key')
attach_ssh_key(fco_api, server_uuid, key_uuid)
new_keys.add(key_uuid)
ctx.logger.info('Keys attached: %s', new_keys)
# Create NIC
try:
nic_uuid = _rp[RPROP_NIC]
except KeyError:
nic_uuid = create_nic(fco_api, cluster_uuid, network_type,
network_uuid, vdc_uuid, server_name + ' NIC')
if not wait_for_state(fco_api, nic_uuid, enums.ResourceState.ACTIVE,
RT.NIC):
raise Exception('NIC failed to create in time!')
_rp[RPROP_NIC] = nic_uuid
ctx.logger.info('nic_uuid: %s', nic_uuid)
# Stop server if started
if get_server_status(fco_api, server_uuid) != enums.ServerStatus.STOPPED:
if not stop_server(fco_api, server_uuid):
raise Exception('Stopping server failed to complete in time!')
ctx.logger.info('Server STOPPED')
# Attach NIC
if nic_uuid not in server_nics:
job_uuid = attach_nic(fco_api, server_uuid, nic_uuid, 1).resourceUUID
cond = cobjects.Job.status == enums.JobStatus.SUCCESSFUL
if not wait_for_cond(fco_api, job_uuid, cond, RT.JOB):
raise Exception('Attaching NIC failed to complete in time!')
ctx.logger.info('NICs attached')
else:
ctx.logger.info('NICs already attached')
# Start server if not started
if get_server_status(fco_api, server_uuid) == enums.ServerStatus.STOPPED:
if not start_server(fco_api, server_uuid):
raise Exception('Running server failed to complete in time!')
ctx.logger.info('Server RUNNING')
nic = get_resource(fco_api, nic_uuid, RT.NIC)
server_ip = nic.ipAddresses[0].ipAddress
server_port = 22
ctx.logger.info('Server READY')
username = server.initialUser
password = <PASSWORD>
ssh_attempts = -1
ssh_delay = 3
# Fabric test
while ssh_attempts:
ctx.logger.info('Attempting to SSH ({})'.format(ssh_attempts))
try:
with settings(host_string=server_po_uuid, user=username,
password=password, disable_known_hosts=True,
abort_exception=Exception):
run('mkdir ~/.ssh')
run('chmod 0700 ~/.ssh')
for key, key_content in key_contents.items():
remote = os.path.join('~', '.ssh', os.path.basename(key))
run('echo \'{}\' > {}'.format(key_content, remote))
run('chmod 0600 ' + remote)
ctx.logger.info('Done')
break
except Exception as e:
ctx.logger.info(e)
ssh_attempts -= 1
else:
raise Exception('Failed to provision keys in time')
# # Spur test
# while ssh_attempts:
# ctx.logger.info('Attempting to SSH ({})'.format(ssh_attempts))
# shell = spur.SshShell(
# hostname=server_ip,
# port=server_port,
# username=username,
# password=password,
# shell_type=spur.ssh.ShellTypes.minimal,
# missing_host_key=spur.ssh.MissingHostKey.accept
# )
# with shell:
# try:
# ctx.logger.info('Creating & chmoding .ssh')
# shell.run(['mkdir', '~/.ssh'])
# shell.run(['chmod', '0700', '~/.ssh'])
# for key, key_content in key_contents.items():
# ctx.logger.info('Adding private key: ' + remote)
# remote = os.path.join('~', '.ssh', os.path.basename(key))
# shell.run(['echo', "'{}'".format(key_content), '>',
# remote])
# shell.run(['chmod', '0600', remote])
# except spur.ssh.ConnectionError as e:
# if e.original_error[0] not in {errno.ECONNREFUSED,
# errno.EHOSTUNREACH}:
# raise
# sleep(ssh_delay)
# ssh_attempts -= 1
# else:
# raise Exception('Failed to provision keys in time')
# # Provision private keys
# ssh = SSHClient()
# call(['ssh-keygen', '-R', server_ip])
# ssh.set_missing_host_key_policy(AutoAddPolicy())
#
# while ssh_attempts:
# try:
# ctx.logger.info('Attempting to SSH ({})'.format(ssh_attempts))
# ctx.logger.info('SSH Connection details: {}'.format(
# ((server_ip, server_port, username, password, ssh_delay))))
# ssh.connect(server_ip, server_port, username, password,
# timeout=ssh_delay, look_for_keys=False)
# ctx.logger.info('SSH connection established')
# break
# except socket.timeout:
# ssh_attempts -= 1
# except socket.error as e:
# if e[0] not in {errno.ECONNREFUSED, errno.EHOSTUNREACH}:
# ctx.logger.info('SSH connection failed: %s', e[0])
# raise
# sleep(ssh_delay)
# ssh_attempts -= 1
# else:
# raise Exception('Failed to provision keys in time')
# ssh.exec_command('mkdir ~/.ssh')
# ssh.exec_command('chmod 0700 ~/.ssh')
# for key, key_content in key_contents.items():
# remote = os.path.join('~', '.ssh', os.path.basename(key))
# ssh.exec_command('echo \'{}\' > {}'.format(key_content, remote))
# ssh.exec_command('chmod 0600 ' + remote)
_rp[RPROP_UUID] = server_uuid
_rp[RPROP_IP] = server_ip
_rp[RPROP_USER] = username
_rp[RPROP_PASS] = password
server = get_resource(fco_api, server_uuid, RT.SERVER)
_rp[RPROP_DISKS] = [d.resourceUUID for d in server.disks]
_rp[RPROP_NICS] = [n.resourceUUID for n in server.nics]
ctx.logger.info('Server IP: ' + server_ip)
ctx.logger.info('Server User: ' + username)
ctx.logger.info('Server Password: ' + password)
return server_uuid, server_ip, username, password
@operation
@with_fco_api
@with_exceptions_handled
def delete(fco_api, *args, **kwargs):
server_uuid = ctx.instance.runtime_properties.get(RPROP_UUID)
job_uuid = delete_resource(fco_api, server_uuid, RT.SERVER, True) \
.resourceUUID
cond = cobjects.Job.status == enums.JobStatus.SUCCESSFUL
if not wait_for_cond(fco_api, job_uuid, cond, RT.JOB):
raise Exception('Failed to delete server')
@operation
@with_fco_api
@with_exceptions_handled
def start(fco_api, *args, **kwargs):
server_uuid = ctx.instance.runtime_properties.get(RPROP_UUID)
if get_server_status(fco_api, server_uuid) != enums.ServerStatus.RUNNING:
if not start_server(fco_api, server_uuid):
raise Exception('Could not start server!')
@operation
@with_fco_api
@with_exceptions_handled
def stop(fco_api, *args, **kwargs):
server_uuid = ctx.instance.runtime_properties.get(RPROP_UUID)
if get_server_status(fco_api, server_uuid) != enums.ServerStatus.STOPPED:
if not stop_server(fco_api, server_uuid):
raise Exception('Could not stop server!')
@operation
@with_fco_api
@with_exceptions_handled
def creation_validation(fco_api, *args, **kwargs):
server_uuid = ctx.instance.runtime_properties.get(RPROP_UUID)
try:
get_resource(fco_api, server_uuid, RT.SERVER)
except Exception:
return False
return True
| [
1,
396,
14137,
29922,
10496,
29899,
29947,
13,
13,
15945,
29908,
6004,
6433,
1213,
15945,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
3166,
274,
29888,
29891,
1053,
313,
3258,
29918,
2974,
29892,
13,
462,
1653,
29918,
15269,
29918,
1989,
29892,
13,
462,
10641,
29918,
15269,
29918,
1989,
29892,
13,
462,
4480,
29918,
1454,
29918,
3859,
29892,
13,
462,
4480,
29918,
1454,
29918,
1116,
29892,
13,
462,
1653,
29918,
7823,
29892,
13,
462,
10641,
29918,
7823,
29892,
13,
462,
679,
29918,
10314,
29892,
13,
462,
679,
29918,
2974,
29918,
4882,
29892,
13,
462,
1369,
29918,
2974,
29892,
13,
462,
5040,
29918,
2974,
29892,
13,
462,
5217,
29918,
10314,
29897,
13,
5215,
9909,
13,
5215,
4589,
1217,
13,
3166,
9570,
1598,
1053,
12893,
13,
3166,
9570,
1598,
29889,
19557,
4097,
1053,
5858,
13,
3166,
9570,
1598,
29889,
11739,
29879,
1053,
10050,
4789,
957,
519,
2392,
13,
3166,
274,
29888,
29891,
29889,
3952,
6774,
1053,
313,
2541,
29918,
29888,
1111,
29918,
2754,
29892,
411,
29918,
11739,
29879,
29918,
3179,
839,
29897,
13,
3166,
1791,
8768,
1053,
427,
6762,
29892,
274,
12650,
13,
3166,
1828,
10349,
1053,
22343,
4032,
29892,
11133,
2528,
15644,
13,
5215,
805,
332,
13,
5215,
805,
332,
29889,
15269,
13,
3166,
931,
1053,
8709,
13,
3166,
1014,
5014,
1053,
1246,
13,
3166,
18187,
29889,
2754,
1053,
6055,
29892,
1065,
13,
5215,
2897,
13,
13,
13,
13079,
353,
427,
6762,
29889,
6848,
1542,
13,
13,
8618,
29925,
29918,
1525,
27839,
4741,
29918,
1367,
353,
525,
10314,
29918,
333,
29915,
13,
8618,
29925,
29918,
17171,
29918,
5746,
9047,
4214,
353,
525,
1509,
29918,
735,
15423,
29915,
13,
8618,
29925,
29918,
2382,
353,
525,
3027,
29915,
13,
8618,
29925,
29918,
10699,
29907,
353,
525,
29894,
13891,
29915,
13,
8618,
29925,
29918,
6006,
353,
525,
11618,
29915,
13,
8618,
29925,
29918,
18603,
29918,
13152,
353,
525,
2974,
29918,
1853,
29915,
13,
8618,
29925,
29918,
6271,
29965,
29918,
18736,
353,
525,
21970,
29918,
2798,
29915,
13,
8618,
29925,
29918,
25058,
29918,
5194,
29949,
10356,
353,
525,
2572,
29918,
14506,
29915,
13,
8618,
29925,
29918,
1529,
3521,
17070,
29918,
10818,
353,
525,
12847,
29918,
1989,
29915,
13,
8618,
29925,
29918,
29829,
29963,
3040,
29918,
10818,
29903,
353,
525,
9053,
29918,
8149,
29915,
13,
8618,
29925,
29918,
7056,
13367,
2965,
29918,
10818,
29903,
353,
525,
3597,
29918,
8149,
29915,
13,
13,
29934,
8618,
29925,
29918,
29965,
11150,
353,
525,
25118,
29915,
13,
29934,
8618,
29925,
29918,
23711,
17557,
353,
525,
2218,
2039,
29915,
13,
29934,
8618,
29925,
29918,
29940,
2965,
353,
525,
7823,
29915,
13,
29934,
8618,
29925,
29918,
29940,
2965,
29903,
353,
525,
29876,
1199,
29915,
13,
29934,
8618,
29925,
29918,
5690,
353,
525,
666,
29915,
13,
29934,
8618,
29925,
29918,
11889,
353,
525,
6786,
29915,
13,
29934,
8618,
29925,
29918,
25711,
353,
525,
5630,
29915,
13,
13,
13,
29992,
16453,
13,
29992,
2541,
29918,
29888,
1111,
29918,
2754,
13,
29992,
2541,
29918,
11739,
29879,
29918,
3179,
839,
13,
1753,
1653,
29898,
29888,
1111,
29918,
2754,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
2962,
292,
1923,
11265,
1495,
13,
13,
1678,
396,
382,
559,
310,
2130,
13,
1678,
903,
19080,
353,
12893,
29889,
8758,
29889,
15634,
29918,
11330,
13,
1678,
903,
9302,
353,
12893,
29889,
3177,
29889,
11330,
13,
13,
1678,
396,
5399,
565,
5923,
1923,
338,
304,
367,
1304,
13,
1678,
565,
903,
9302,
29961,
8618,
29925,
29918,
17171,
29918,
5746,
9047,
4214,
5387,
13,
4706,
1923,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
903,
9302,
29961,
8618,
29925,
29918,
1525,
27839,
4741,
29918,
1367,
29892,
390,
29911,
29889,
18603,
2314,
13,
4706,
565,
451,
1923,
29889,
29876,
1199,
29901,
13,
9651,
12020,
8960,
877,
3782,
405,
2965,
29879,
10959,
304,
1923,
1495,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29965,
11150,
29962,
353,
1923,
29889,
10314,
29965,
11150,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
23711,
17557,
29962,
353,
518,
29881,
29889,
10314,
29965,
11150,
363,
270,
297,
1923,
29889,
2218,
2039,
29962,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29940,
2965,
29962,
353,
1923,
29889,
29876,
1199,
29961,
29900,
1822,
10314,
29965,
11150,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29940,
2965,
29903,
29962,
353,
518,
29876,
29889,
10314,
29965,
11150,
363,
302,
297,
1923,
29889,
29876,
1199,
29962,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
5690,
29962,
353,
1923,
29889,
29876,
1199,
29961,
29900,
1822,
666,
7061,
267,
29961,
29900,
1822,
666,
7061,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
11889,
29962,
353,
1923,
29889,
11228,
2659,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
25711,
29962,
353,
1923,
29889,
11228,
10048,
13,
4706,
736,
9423,
19080,
29961,
29934,
8618,
29925,
29918,
29965,
11150,
1402,
903,
19080,
29961,
29934,
8618,
29925,
29918,
5690,
1402,
903,
19080,
29961,
29934,
8618,
29925,
29918,
11889,
1402,
13,
18884,
903,
19080,
29961,
29934,
8618,
29925,
29918,
25711,
2314,
13,
13,
1678,
396,
3617,
5285,
13,
1678,
1967,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
903,
9302,
29961,
8618,
29925,
29918,
2382,
1402,
390,
29911,
29889,
2382,
29897,
13,
1678,
565,
903,
9302,
29961,
8618,
29925,
29918,
2382,
5387,
13,
4706,
325,
13891,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
903,
9302,
29961,
8618,
29925,
29918,
10699,
29907,
1402,
390,
29911,
29889,
10699,
29907,
29897,
13,
1678,
1683,
29901,
13,
4706,
325,
13891,
353,
6213,
13,
1678,
3564,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
903,
9302,
29961,
8618,
29925,
29918,
6006,
1402,
390,
29911,
29889,
6006,
11686,
29968,
29897,
13,
1678,
1923,
29918,
1129,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
903,
9302,
29961,
8618,
29925,
29918,
18603,
29918,
13152,
1402,
390,
29911,
29889,
8618,
14849,
1783,
27681,
1001,
29897,
13,
1678,
8455,
29918,
1989,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
903,
9302,
29961,
8618,
29925,
29918,
1529,
3521,
17070,
29918,
10818,
1402,
390,
29911,
29889,
1799,
29950,
10818,
29897,
13,
1678,
26403,
29918,
2798,
353,
903,
9302,
29961,
8618,
29925,
29918,
6271,
29965,
29918,
18736,
29962,
13,
1678,
13472,
29918,
14506,
353,
903,
9302,
29961,
8618,
29925,
29918,
25058,
29918,
5194,
29949,
10356,
29962,
13,
1678,
970,
29918,
8149,
353,
903,
9302,
29961,
8618,
29925,
29918,
7056,
13367,
2965,
29918,
10818,
29903,
29962,
470,
5159,
13,
1678,
2024,
29918,
8149,
353,
903,
9302,
29961,
8618,
29925,
29918,
29829,
29963,
3040,
29918,
10818,
29903,
29962,
470,
5159,
13,
13,
1678,
396,
1798,
1598,
10379,
310,
2024,
6611,
13,
1678,
4567,
29918,
8149,
353,
731,
580,
13,
1678,
4319,
29918,
16074,
29918,
8149,
353,
731,
580,
13,
1678,
1820,
29918,
10853,
353,
6571,
13,
1678,
363,
1820,
297,
2024,
29918,
8149,
29901,
13,
4706,
1018,
29901,
13,
9651,
1820,
29918,
10853,
29961,
1989,
29962,
353,
12893,
29889,
657,
29918,
10314,
29898,
359,
29889,
2084,
29889,
18837,
1792,
29898,
1989,
876,
13,
4706,
5174,
10050,
4789,
957,
519,
2392,
408,
321,
29901,
13,
9651,
565,
525,
5506,
2451,
29901,
29871,
29946,
29900,
29946,
29915,
297,
851,
29898,
29872,
1125,
13,
18884,
4567,
29918,
8149,
29889,
1202,
29898,
1989,
29897,
13,
9651,
25342,
525,
5506,
2451,
29901,
29871,
29946,
29900,
29941,
29915,
297,
851,
29898,
29872,
1125,
13,
18884,
4319,
29918,
16074,
29918,
8149,
29889,
1202,
29898,
1989,
29897,
13,
9651,
1683,
29901,
13,
18884,
12020,
13,
1678,
565,
4567,
29918,
8149,
470,
4319,
29918,
16074,
29918,
8149,
29901,
13,
4706,
12020,
8960,
877,
18552,
292,
2024,
6611,
29901,
426,
1012,
29876,
22050,
10751,
6611,
29901,
6571,
29915,
13,
462,
4706,
869,
4830,
29898,
27259,
29918,
8149,
29892,
4319,
29918,
16074,
29918,
8149,
876,
13,
13,
1678,
396,
3251,
403,
4567,
5285,
13,
1678,
1967,
29918,
25118,
353,
1967,
29889,
10314,
29965,
11150,
13,
1678,
565,
325,
13891,
338,
451,
6213,
29901,
13,
4706,
9867,
29918,
25118,
353,
325,
13891,
29889,
19594,
29965,
11150,
13,
4706,
325,
13891,
29918,
25118,
353,
325,
13891,
29889,
10314,
29965,
11150,
13,
1678,
1683,
29901,
13,
4706,
9867,
29918,
25118,
353,
1967,
29889,
19594,
29965,
11150,
13,
4706,
325,
13891,
29918,
25118,
353,
1967,
29889,
29894,
13891,
29965,
11150,
13,
1678,
3564,
29918,
25118,
353,
3564,
29889,
10314,
29965,
11150,
13,
1678,
3564,
29918,
1853,
353,
3564,
29889,
11618,
1542,
13,
1678,
1923,
29918,
1129,
29918,
25118,
353,
1923,
29918,
1129,
29889,
10314,
29965,
11150,
13,
1678,
8455,
29918,
1989,
29918,
25118,
353,
8455,
29918,
1989,
29889,
10314,
29965,
11150,
13,
1678,
396,
14402,
29901,
2253,
982,
310,
3683,
2827,
13907,
8086,
13,
1678,
6579,
29918,
20960,
29918,
1129,
29918,
25118,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
13,
462,
462,
268,
525,
8875,
19289,
26162,
20579,
4286,
4830,
29898,
3027,
29889,
2311,
511,
13,
462,
462,
268,
390,
29911,
29889,
8618,
14849,
1783,
27681,
1001,
467,
10314,
29965,
11150,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
8614,
29901,
320,
29876,
29915,
13,
462,
1678,
525,
3027,
29918,
25118,
29901,
1273,
29879,
29905,
29876,
29915,
13,
462,
1678,
525,
19594,
29918,
25118,
29901,
1273,
29879,
29905,
29876,
29915,
13,
462,
1678,
525,
29894,
13891,
29918,
25118,
29901,
1273,
29879,
29905,
29876,
29915,
13,
462,
1678,
525,
11618,
29918,
25118,
29901,
1273,
29879,
29905,
29876,
29915,
13,
462,
1678,
525,
2974,
29918,
1129,
29918,
25118,
29901,
1273,
29879,
29905,
29876,
29915,
13,
462,
1678,
525,
12847,
29918,
1989,
29918,
25118,
29901,
1273,
29879,
29905,
29876,
29915,
13,
462,
1678,
525,
4777,
29918,
20960,
29918,
1129,
29918,
25118,
29901,
1273,
29879,
742,
13,
462,
1678,
1967,
29918,
25118,
29892,
9867,
29918,
25118,
29892,
325,
13891,
29918,
25118,
29892,
3564,
29918,
25118,
29892,
13,
462,
1678,
1923,
29918,
1129,
29918,
25118,
29892,
8455,
29918,
1989,
29918,
25118,
29892,
6579,
29918,
20960,
29918,
1129,
29918,
25118,
29897,
13,
13,
1678,
396,
6204,
1923,
13,
1678,
1923,
29918,
978,
353,
22372,
1157,
3227,
29913,
4286,
4830,
29898,
13073,
29889,
8704,
29918,
4703,
29889,
13237,
29918,
13506,
29892,
13,
462,
462,
259,
12893,
29889,
16519,
358,
29889,
333,
29892,
12893,
29889,
8758,
29889,
333,
29897,
13,
1678,
1018,
29901,
13,
4706,
1923,
29918,
25118,
353,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29965,
11150,
29962,
13,
1678,
5174,
7670,
2392,
29901,
13,
4706,
396,
1820,
29918,
5415,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
1820,
29918,
25118,
29892,
390,
29911,
29889,
1799,
29950,
10818,
29897,
13,
4706,
396,
6611,
353,
22343,
2558,
29889,
1525,
29984,
3120,
19386,
29918,
1299,
29911,
3960,
9851,
29889,
8552,
580,
13,
4706,
396,
6611,
29889,
1202,
877,
10314,
29965,
11150,
1495,
13,
4706,
396,
9752,
29918,
1989,
353,
6571,
13,
4706,
396,
363,
413,
297,
6611,
29901,
13,
4706,
396,
268,
1018,
29901,
13,
4706,
396,
308,
9752,
29918,
1989,
29961,
29895,
29962,
353,
679,
5552,
29898,
12847,
29918,
1989,
29892,
413,
29897,
13,
4706,
396,
268,
5174,
23833,
2392,
29901,
13,
4706,
396,
308,
9752,
29918,
1989,
29961,
29895,
29962,
353,
6213,
13,
4706,
1923,
29918,
25118,
353,
1653,
29918,
2974,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
1129,
29918,
25118,
29892,
1967,
29918,
25118,
29892,
13,
462,
462,
1678,
9867,
29918,
25118,
29892,
325,
13891,
29918,
25118,
29892,
26403,
29918,
2798,
29892,
13,
462,
462,
1678,
13472,
29918,
14506,
29892,
6579,
29918,
20960,
29918,
1129,
29918,
25118,
29892,
13,
462,
462,
1678,
518,
12847,
29918,
1989,
1402,
1923,
29918,
978,
29897,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29965,
11150,
29962,
353,
1923,
29918,
25118,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
2974,
29918,
25118,
29901,
1273,
29879,
742,
1923,
29918,
25118,
29897,
13,
13,
1678,
1923,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29892,
390,
29911,
29889,
18603,
29897,
13,
1678,
1923,
29918,
29876,
1199,
353,
518,
7823,
29889,
10314,
29965,
11150,
363,
16588,
297,
1923,
29889,
29876,
1199,
29962,
13,
1678,
1923,
29918,
8149,
353,
518,
1989,
29889,
10314,
29965,
11150,
363,
1820,
297,
1923,
29889,
15269,
8149,
29962,
13,
13,
1678,
396,
20340,
363,
1923,
304,
367,
6136,
13,
1678,
565,
451,
4480,
29918,
1454,
29918,
3859,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29892,
427,
6762,
29889,
6848,
2792,
29889,
17923,
18474,
29892,
13,
462,
3986,
390,
29911,
29889,
18603,
1125,
13,
4706,
12020,
8960,
877,
6004,
5229,
304,
19012,
297,
931,
29991,
1495,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
6004,
319,
1783,
18474,
1495,
13,
13,
1678,
396,
3462,
6611,
13,
1678,
716,
29918,
8149,
353,
731,
580,
13,
1678,
363,
1820,
297,
970,
29918,
8149,
29901,
13,
4706,
565,
1820,
451,
297,
1923,
29918,
8149,
29901,
13,
9651,
1820,
29918,
25118,
353,
1653,
29918,
15269,
29918,
1989,
29898,
29888,
1111,
29918,
2754,
29892,
1820,
29892,
1923,
29918,
978,
718,
525,
7670,
1495,
13,
9651,
10641,
29918,
15269,
29918,
1989,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29892,
1820,
29918,
25118,
29897,
13,
9651,
716,
29918,
8149,
29889,
1202,
29898,
1989,
29918,
25118,
29897,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
15506,
10959,
29901,
1273,
29879,
742,
716,
29918,
8149,
29897,
13,
13,
1678,
396,
6204,
405,
2965,
13,
1678,
1018,
29901,
13,
4706,
16588,
29918,
25118,
353,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29940,
2965,
29962,
13,
1678,
5174,
7670,
2392,
29901,
13,
4706,
16588,
29918,
25118,
353,
1653,
29918,
7823,
29898,
29888,
1111,
29918,
2754,
29892,
9867,
29918,
25118,
29892,
3564,
29918,
1853,
29892,
13,
462,
795,
3564,
29918,
25118,
29892,
325,
13891,
29918,
25118,
29892,
1923,
29918,
978,
718,
525,
405,
2965,
1495,
13,
4706,
565,
451,
4480,
29918,
1454,
29918,
3859,
29898,
29888,
1111,
29918,
2754,
29892,
16588,
29918,
25118,
29892,
427,
6762,
29889,
6848,
2792,
29889,
17923,
18474,
29892,
13,
462,
795,
390,
29911,
29889,
29940,
2965,
1125,
13,
9651,
12020,
8960,
877,
29940,
2965,
5229,
304,
1653,
297,
931,
29991,
1495,
13,
4706,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29940,
2965,
29962,
353,
16588,
29918,
25118,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
7823,
29918,
25118,
29901,
1273,
29879,
742,
16588,
29918,
25118,
29897,
13,
13,
1678,
396,
22303,
1923,
565,
4687,
13,
1678,
565,
679,
29918,
2974,
29918,
4882,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29897,
2804,
427,
6762,
29889,
6004,
5709,
29889,
1254,
4590,
29925,
3352,
29901,
13,
4706,
565,
451,
5040,
29918,
2974,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
1125,
13,
9651,
12020,
8960,
877,
20754,
3262,
1923,
5229,
304,
4866,
297,
931,
29991,
1495,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
6004,
6850,
4590,
29925,
3352,
1495,
13,
13,
1678,
396,
6212,
496,
405,
2965,
13,
1678,
565,
16588,
29918,
25118,
451,
297,
1923,
29918,
29876,
1199,
29901,
13,
4706,
4982,
29918,
25118,
353,
10641,
29918,
7823,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29892,
16588,
29918,
25118,
29892,
29871,
29896,
467,
10314,
29965,
11150,
13,
4706,
2148,
353,
274,
12650,
29889,
11947,
29889,
4882,
1275,
427,
6762,
29889,
11947,
5709,
29889,
14605,
26925,
29943,
13309,
13,
4706,
565,
451,
4480,
29918,
1454,
29918,
1116,
29898,
29888,
1111,
29918,
2754,
29892,
4982,
29918,
25118,
29892,
2148,
29892,
390,
29911,
29889,
29967,
14824,
1125,
13,
9651,
12020,
8960,
877,
4165,
9733,
405,
2965,
5229,
304,
4866,
297,
931,
29991,
1495,
13,
4706,
12893,
29889,
21707,
29889,
3888,
877,
29940,
2965,
29879,
10959,
1495,
13,
1678,
1683,
29901,
13,
4706,
12893,
29889,
21707,
29889,
3888,
877,
29940,
2965,
29879,
2307,
10959,
1495,
13,
13,
1678,
396,
7370,
1923,
565,
451,
4687,
13,
1678,
565,
679,
29918,
2974,
29918,
4882,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29897,
1275,
427,
6762,
29889,
6004,
5709,
29889,
1254,
4590,
29925,
3352,
29901,
13,
4706,
565,
451,
1369,
29918,
2974,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
1125,
13,
9651,
12020,
8960,
877,
27795,
1923,
5229,
304,
4866,
297,
931,
29991,
1495,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
6004,
27694,
29940,
4214,
1495,
13,
13,
1678,
16588,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
16588,
29918,
25118,
29892,
390,
29911,
29889,
29940,
2965,
29897,
13,
1678,
1923,
29918,
666,
353,
16588,
29889,
666,
7061,
267,
29961,
29900,
1822,
666,
7061,
13,
1678,
1923,
29918,
637,
353,
29871,
29906,
29906,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
6004,
5195,
3035,
29979,
1495,
13,
13,
1678,
8952,
353,
1923,
29889,
11228,
2659,
13,
1678,
4800,
353,
529,
25711,
17013,
29958,
13,
13,
1678,
13927,
29918,
1131,
3456,
29879,
353,
448,
29896,
13,
1678,
13927,
29918,
18829,
353,
29871,
29941,
13,
13,
1678,
396,
10629,
2200,
1243,
13,
13,
1678,
1550,
13927,
29918,
1131,
3456,
29879,
29901,
13,
4706,
12893,
29889,
21707,
29889,
3888,
877,
4165,
3456,
292,
304,
22343,
21313,
1800,
4286,
4830,
29898,
15269,
29918,
1131,
3456,
29879,
876,
13,
4706,
1018,
29901,
13,
9651,
411,
6055,
29898,
3069,
29918,
1807,
29922,
2974,
29918,
1129,
29918,
25118,
29892,
1404,
29922,
6786,
29892,
13,
462,
3986,
4800,
29922,
5630,
29892,
11262,
29918,
5203,
29918,
23525,
29922,
5574,
29892,
13,
462,
3986,
27450,
29918,
11739,
29922,
2451,
1125,
13,
18884,
1065,
877,
11256,
3972,
3695,
6294,
15269,
1495,
13,
18884,
1065,
877,
305,
1545,
29871,
29900,
29955,
29900,
29900,
3695,
6294,
15269,
1495,
13,
18884,
363,
1820,
29892,
1820,
29918,
3051,
297,
1820,
29918,
10853,
29889,
7076,
7295,
13,
462,
1678,
7592,
353,
2897,
29889,
2084,
29889,
7122,
877,
30022,
742,
15300,
15269,
742,
2897,
29889,
2084,
29889,
6500,
3871,
29898,
1989,
876,
13,
462,
1678,
1065,
877,
8057,
320,
29915,
29912,
1012,
29915,
1405,
6571,
4286,
4830,
29898,
1989,
29918,
3051,
29892,
7592,
876,
13,
462,
1678,
1065,
877,
305,
1545,
29871,
29900,
29953,
29900,
29900,
525,
718,
7592,
29897,
13,
18884,
12893,
29889,
21707,
29889,
3888,
877,
25632,
1495,
13,
18884,
2867,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
12893,
29889,
21707,
29889,
3888,
29898,
29872,
29897,
13,
4706,
13927,
29918,
1131,
3456,
29879,
22361,
29871,
29896,
13,
1678,
1683,
29901,
13,
4706,
12020,
8960,
877,
17776,
304,
25161,
6611,
297,
931,
1495,
13,
13,
1678,
396,
396,
1706,
332,
1243,
13,
1678,
396,
1550,
13927,
29918,
1131,
3456,
29879,
29901,
13,
1678,
396,
268,
12893,
29889,
21707,
29889,
3888,
877,
4165,
3456,
292,
304,
22343,
21313,
1800,
4286,
4830,
29898,
15269,
29918,
1131,
3456,
29879,
876,
13,
1678,
396,
268,
6473,
353,
805,
332,
29889,
29903,
845,
16037,
29898,
13,
1678,
396,
308,
3495,
978,
29922,
2974,
29918,
666,
29892,
13,
1678,
396,
308,
2011,
29922,
2974,
29918,
637,
29892,
13,
1678,
396,
308,
8952,
29922,
6786,
29892,
13,
1678,
396,
308,
4800,
29922,
5630,
29892,
13,
1678,
396,
308,
6473,
29918,
1853,
29922,
1028,
332,
29889,
15269,
29889,
16037,
10562,
29889,
1195,
3039,
29892,
13,
1678,
396,
308,
4567,
29918,
3069,
29918,
1989,
29922,
1028,
332,
29889,
15269,
29889,
18552,
292,
8514,
2558,
29889,
16044,
13,
1678,
396,
268,
1723,
13,
1678,
396,
268,
411,
6473,
29901,
13,
1678,
396,
308,
1018,
29901,
13,
1678,
396,
632,
12893,
29889,
21707,
29889,
3888,
877,
9832,
1218,
669,
521,
1545,
292,
869,
15269,
1495,
13,
1678,
396,
632,
6473,
29889,
3389,
18959,
11256,
3972,
742,
525,
30022,
6294,
15269,
11287,
13,
1678,
396,
632,
6473,
29889,
3389,
18959,
305,
1545,
742,
525,
29900,
29955,
29900,
29900,
742,
525,
30022,
6294,
15269,
11287,
13,
1678,
396,
632,
363,
1820,
29892,
1820,
29918,
3051,
297,
1820,
29918,
10853,
29889,
7076,
7295,
13,
1678,
396,
462,
12893,
29889,
21707,
29889,
3888,
877,
2528,
292,
2024,
1820,
29901,
525,
718,
7592,
29897,
13,
1678,
396,
462,
7592,
353,
2897,
29889,
2084,
29889,
7122,
877,
30022,
742,
15300,
15269,
742,
2897,
29889,
2084,
29889,
6500,
3871,
29898,
1989,
876,
13,
1678,
396,
462,
6473,
29889,
3389,
18959,
8057,
742,
13577,
8875,
29915,
1642,
4830,
29898,
1989,
29918,
3051,
511,
525,
29958,
742,
13,
1678,
396,
462,
9651,
7592,
2314,
13,
1678,
396,
462,
6473,
29889,
3389,
18959,
305,
1545,
742,
525,
29900,
29953,
29900,
29900,
742,
7592,
2314,
13,
1678,
396,
308,
5174,
805,
332,
29889,
15269,
29889,
5350,
2392,
408,
321,
29901,
13,
1678,
396,
632,
565,
321,
29889,
13492,
29918,
2704,
29961,
29900,
29962,
451,
297,
426,
3127,
1217,
29889,
29923,
6007,
29940,
25866,
17171,
29928,
29892,
13,
1678,
396,
462,
462,
308,
4589,
1217,
29889,
29923,
20832,
3904,
1525,
2477,
29950,
6177,
13,
1678,
396,
462,
12020,
13,
1678,
396,
632,
8709,
29898,
15269,
29918,
18829,
29897,
13,
1678,
396,
308,
13927,
29918,
1131,
3456,
29879,
22361,
29871,
29896,
13,
1678,
396,
1683,
29901,
13,
1678,
396,
268,
12020,
8960,
877,
17776,
304,
25161,
6611,
297,
931,
1495,
13,
13,
1678,
396,
396,
1019,
4924,
2024,
6611,
13,
1678,
396,
13927,
353,
22343,
4032,
580,
13,
1678,
396,
1246,
18959,
15269,
29899,
1989,
1885,
742,
17411,
29934,
742,
1923,
29918,
666,
2314,
13,
1678,
396,
13927,
29889,
842,
29918,
27259,
29918,
3069,
29918,
1989,
29918,
22197,
29898,
12300,
2528,
15644,
3101,
13,
1678,
396,
13,
1678,
396,
1550,
13927,
29918,
1131,
3456,
29879,
29901,
13,
1678,
396,
268,
1018,
29901,
13,
1678,
396,
308,
12893,
29889,
21707,
29889,
3888,
877,
4165,
3456,
292,
304,
22343,
21313,
1800,
4286,
4830,
29898,
15269,
29918,
1131,
3456,
29879,
876,
13,
1678,
396,
308,
12893,
29889,
21707,
29889,
3888,
877,
1799,
29950,
15160,
4902,
29901,
6571,
4286,
4830,
29898,
13,
1678,
396,
632,
5135,
2974,
29918,
666,
29892,
1923,
29918,
637,
29892,
8952,
29892,
4800,
29892,
13927,
29918,
18829,
13697,
13,
1678,
396,
308,
13927,
29889,
6915,
29898,
2974,
29918,
666,
29892,
1923,
29918,
637,
29892,
8952,
29892,
4800,
29892,
13,
1678,
396,
462,
268,
11815,
29922,
15269,
29918,
18829,
29892,
1106,
29918,
1454,
29918,
8149,
29922,
8824,
29897,
13,
1678,
396,
308,
12893,
29889,
21707,
29889,
3888,
877,
1799,
29950,
3957,
7841,
1495,
13,
1678,
396,
308,
2867,
13,
1678,
396,
268,
5174,
9909,
29889,
15619,
29901,
13,
1678,
396,
308,
13927,
29918,
1131,
3456,
29879,
22361,
29871,
29896,
13,
1678,
396,
268,
5174,
9909,
29889,
2704,
408,
321,
29901,
13,
1678,
396,
308,
565,
321,
29961,
29900,
29962,
451,
297,
426,
3127,
1217,
29889,
29923,
6007,
29940,
25866,
17171,
29928,
29892,
4589,
1217,
29889,
29923,
20832,
3904,
1525,
2477,
29950,
6177,
13,
1678,
396,
632,
12893,
29889,
21707,
29889,
3888,
877,
1799,
29950,
3957,
5229,
29901,
1273,
29879,
742,
321,
29961,
29900,
2314,
13,
1678,
396,
632,
12020,
13,
1678,
396,
308,
8709,
29898,
15269,
29918,
18829,
29897,
13,
1678,
396,
268,
13927,
29918,
1131,
3456,
29879,
22361,
29871,
29896,
13,
1678,
396,
1683,
29901,
13,
1678,
396,
268,
12020,
8960,
877,
17776,
304,
25161,
6611,
297,
931,
1495,
13,
1678,
396,
13927,
29889,
4258,
29918,
6519,
877,
11256,
3972,
3695,
6294,
15269,
1495,
13,
1678,
396,
13927,
29889,
4258,
29918,
6519,
877,
305,
1545,
29871,
29900,
29955,
29900,
29900,
3695,
6294,
15269,
1495,
13,
1678,
396,
363,
1820,
29892,
1820,
29918,
3051,
297,
1820,
29918,
10853,
29889,
7076,
7295,
13,
1678,
396,
268,
7592,
353,
2897,
29889,
2084,
29889,
7122,
877,
30022,
742,
15300,
15269,
742,
2897,
29889,
2084,
29889,
6500,
3871,
29898,
1989,
876,
13,
1678,
396,
268,
13927,
29889,
4258,
29918,
6519,
877,
8057,
320,
29915,
29912,
1012,
29915,
1405,
6571,
4286,
4830,
29898,
1989,
29918,
3051,
29892,
7592,
876,
13,
1678,
396,
268,
13927,
29889,
4258,
29918,
6519,
877,
305,
1545,
29871,
29900,
29953,
29900,
29900,
525,
718,
7592,
29897,
13,
13,
1678,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29965,
11150,
29962,
353,
1923,
29918,
25118,
13,
1678,
903,
19080,
29961,
29934,
8618,
29925,
29918,
5690,
29962,
353,
1923,
29918,
666,
13,
1678,
903,
19080,
29961,
29934,
8618,
29925,
29918,
11889,
29962,
353,
8952,
13,
1678,
903,
19080,
29961,
29934,
8618,
29925,
29918,
25711,
29962,
353,
4800,
13,
13,
1678,
1923,
353,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29892,
390,
29911,
29889,
18603,
29897,
13,
1678,
903,
19080,
29961,
29934,
8618,
29925,
29918,
23711,
17557,
29962,
353,
518,
29881,
29889,
10314,
29965,
11150,
363,
270,
297,
1923,
29889,
2218,
2039,
29962,
13,
1678,
903,
19080,
29961,
29934,
8618,
29925,
29918,
29940,
2965,
29903,
29962,
353,
518,
29876,
29889,
10314,
29965,
11150,
363,
302,
297,
1923,
29889,
29876,
1199,
29962,
13,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
6004,
5641,
29901,
525,
718,
1923,
29918,
666,
29897,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
6004,
4911,
29901,
525,
718,
8952,
29897,
13,
1678,
12893,
29889,
21707,
29889,
3888,
877,
6004,
25280,
29901,
525,
718,
4800,
29897,
13,
13,
1678,
736,
1923,
29918,
25118,
29892,
1923,
29918,
666,
29892,
8952,
29892,
4800,
13,
13,
13,
29992,
16453,
13,
29992,
2541,
29918,
29888,
1111,
29918,
2754,
13,
29992,
2541,
29918,
11739,
29879,
29918,
3179,
839,
13,
1753,
5217,
29898,
29888,
1111,
29918,
2754,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
1678,
1923,
29918,
25118,
353,
12893,
29889,
8758,
29889,
15634,
29918,
11330,
29889,
657,
29898,
29934,
8618,
29925,
29918,
29965,
11150,
29897,
13,
1678,
4982,
29918,
25118,
353,
5217,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29892,
390,
29911,
29889,
18603,
29892,
5852,
29897,
320,
13,
4706,
869,
10314,
29965,
11150,
13,
1678,
2148,
353,
274,
12650,
29889,
11947,
29889,
4882,
1275,
427,
6762,
29889,
11947,
5709,
29889,
14605,
26925,
29943,
13309,
13,
1678,
565,
451,
4480,
29918,
1454,
29918,
1116,
29898,
29888,
1111,
29918,
2754,
29892,
4982,
29918,
25118,
29892,
2148,
29892,
390,
29911,
29889,
29967,
14824,
1125,
13,
4706,
12020,
8960,
877,
17776,
304,
5217,
1923,
1495,
13,
13,
13,
29992,
16453,
13,
29992,
2541,
29918,
29888,
1111,
29918,
2754,
13,
29992,
2541,
29918,
11739,
29879,
29918,
3179,
839,
13,
1753,
1369,
29898,
29888,
1111,
29918,
2754,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
1678,
1923,
29918,
25118,
353,
12893,
29889,
8758,
29889,
15634,
29918,
11330,
29889,
657,
29898,
29934,
8618,
29925,
29918,
29965,
11150,
29897,
13,
1678,
565,
679,
29918,
2974,
29918,
4882,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29897,
2804,
427,
6762,
29889,
6004,
5709,
29889,
29934,
3904,
29940,
4214,
29901,
13,
4706,
565,
451,
1369,
29918,
2974,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
1125,
13,
9651,
12020,
8960,
877,
23323,
451,
1369,
1923,
29991,
1495,
13,
13,
13,
29992,
16453,
13,
29992,
2541,
29918,
29888,
1111,
29918,
2754,
13,
29992,
2541,
29918,
11739,
29879,
29918,
3179,
839,
13,
1753,
5040,
29898,
29888,
1111,
29918,
2754,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
1678,
1923,
29918,
25118,
353,
12893,
29889,
8758,
29889,
15634,
29918,
11330,
29889,
657,
29898,
29934,
8618,
29925,
29918,
29965,
11150,
29897,
13,
1678,
565,
679,
29918,
2974,
29918,
4882,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29897,
2804,
427,
6762,
29889,
6004,
5709,
29889,
1254,
4590,
29925,
3352,
29901,
13,
4706,
565,
451,
5040,
29918,
2974,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
1125,
13,
9651,
12020,
8960,
877,
23323,
451,
5040,
1923,
29991,
1495,
13,
13,
13,
29992,
16453,
13,
29992,
2541,
29918,
29888,
1111,
29918,
2754,
13,
29992,
2541,
29918,
11739,
29879,
29918,
3179,
839,
13,
1753,
11265,
29918,
18157,
29898,
29888,
1111,
29918,
2754,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
1678,
1923,
29918,
25118,
353,
12893,
29889,
8758,
29889,
15634,
29918,
11330,
29889,
657,
29898,
29934,
8618,
29925,
29918,
29965,
11150,
29897,
13,
1678,
1018,
29901,
13,
4706,
679,
29918,
10314,
29898,
29888,
1111,
29918,
2754,
29892,
1923,
29918,
25118,
29892,
390,
29911,
29889,
18603,
29897,
13,
1678,
5174,
8960,
29901,
13,
4706,
736,
7700,
13,
1678,
736,
5852,
13,
2
] |
dialogos/templatetags/dialogos_tags.py | geosolutions-it/geonode-dialogos | 0 | 133645 | from django import template
from django.core.urlresolvers import reverse
from django.contrib.contenttypes.models import ContentType
from dialogos.authorization import load_can_delete, load_can_edit
from dialogos.forms import CommentForm
from dialogos.models import Comment
can_delete = load_can_delete()
can_edit = load_can_edit()
register = template.Library()
@register.filter
def can_edit_comment(comment, user):
return can_edit(user, comment)
@register.filter
def can_delete_comment(comment, user):
return can_delete(user, comment)
class BaseCommentNode(template.Node):
@classmethod
def handle_token(cls, parser, token):
bits = token.split_contents()
if not cls.requires_as_var and len(bits) == 2:
return cls(parser.compile_filter(bits[1]))
elif len(bits) == 4:
if bits[2] != "as":
raise template.TemplateSyntaxError("%r's 2nd argument must be 'as'" % bits[0])
return cls(parser.compile_filter(bits[1]), bits[3])
if cls.requires_as_var:
args = "1 argument"
else:
args = "either 1 or 3 arguments"
raise template.TemplateSyntaxError("%r takes %s" % (bits[0], args))
def __init__(self, obj, varname=None):
self.obj = obj
self.varname = varname
def get_comments(self, context):
obj = self.obj.resolve(context)
comments = Comment.objects.filter(
object_id=obj.pk,
content_type=ContentType.objects.get_for_model(obj)
)
return comments.order_by("submit_date")
class CommentCountNode(BaseCommentNode):
requires_as_var = False
def render(self, context):
comments = self.get_comments(context).count()
if self.varname is not None:
context[self.varname] = comments
return ""
return unicode(comments)
class CommentsNode(BaseCommentNode):
requires_as_var = True
def render(self, context):
context[self.varname] = self.get_comments(context)
return ""
class CommentFormNode(BaseCommentNode):
requires_as_var = False
def render(self, context):
obj = self.obj.resolve(context)
user = context.get("user")
form_class = context.get("form", CommentForm)
form = form_class(obj=obj, user=user)
context[self.varname] = form
return ""
class CommentTargetNode(BaseCommentNode):
requires_as_var = False
def render(self, context):
obj = self.obj.resolve(context)
return reverse("post_comment", kwargs={
"content_type_id": ContentType.objects.get_for_model(obj).pk,
"object_id": obj.pk
})
@register.tag
def comment_count(parser, token):
"""
Usage:
{% comment_count obj %}
or
{% comment_count obj as var %}
"""
return CommentCountNode.handle_token(parser, token)
@register.tag
def comments(parser, token):
"""
Usage:
{% comments obj as var %}
"""
return CommentsNode.handle_token(parser, token)
@register.tag
def comment_form(parser, token):
"""
Usage:
{% comment_form obj as comment_form %}
Will read the `user` var out of the contex to know if the form should be
form an auth'd user or not.
"""
return CommentFormNode.handle_token(parser, token)
@register.tag
def comment_target(parser, token):
"""
Usage:
{% comment_target obj [as varname] %}
"""
return CommentTargetNode.handle_token(parser, token)
| [
1,
515,
9557,
1053,
4472,
13,
3166,
9557,
29889,
3221,
29889,
2271,
9778,
874,
1053,
11837,
13,
13,
3166,
9557,
29889,
21570,
29889,
3051,
8768,
29889,
9794,
1053,
10576,
1542,
13,
13,
3166,
7928,
359,
29889,
8921,
2133,
1053,
2254,
29918,
3068,
29918,
8143,
29892,
2254,
29918,
3068,
29918,
5628,
13,
3166,
7928,
359,
29889,
9514,
1053,
461,
2500,
13,
3166,
7928,
359,
29889,
9794,
1053,
461,
13,
13,
13,
3068,
29918,
8143,
353,
2254,
29918,
3068,
29918,
8143,
580,
13,
3068,
29918,
5628,
353,
2254,
29918,
3068,
29918,
5628,
580,
13,
9573,
353,
4472,
29889,
12284,
580,
13,
13,
13,
29992,
9573,
29889,
4572,
13,
1753,
508,
29918,
5628,
29918,
9342,
29898,
9342,
29892,
1404,
1125,
13,
1678,
736,
508,
29918,
5628,
29898,
1792,
29892,
3440,
29897,
13,
13,
13,
29992,
9573,
29889,
4572,
13,
1753,
508,
29918,
8143,
29918,
9342,
29898,
9342,
29892,
1404,
1125,
13,
1678,
736,
508,
29918,
8143,
29898,
1792,
29892,
3440,
29897,
13,
13,
13,
1990,
7399,
20001,
4247,
29898,
6886,
29889,
4247,
1125,
13,
268,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
4386,
29918,
6979,
29898,
25932,
29892,
13812,
29892,
5993,
1125,
13,
4706,
9978,
353,
5993,
29889,
5451,
29918,
10853,
580,
13,
4706,
565,
451,
1067,
29879,
29889,
276,
339,
2658,
29918,
294,
29918,
1707,
322,
7431,
29898,
14836,
29897,
1275,
29871,
29906,
29901,
13,
9651,
736,
1067,
29879,
29898,
16680,
29889,
12198,
29918,
4572,
29898,
14836,
29961,
29896,
12622,
13,
4706,
25342,
7431,
29898,
14836,
29897,
1275,
29871,
29946,
29901,
13,
9651,
565,
9978,
29961,
29906,
29962,
2804,
376,
294,
1115,
13,
18884,
12020,
4472,
29889,
6733,
16676,
2392,
11702,
29878,
29915,
29879,
29871,
29906,
299,
2980,
1818,
367,
525,
294,
11838,
1273,
9978,
29961,
29900,
2314,
13,
9651,
736,
1067,
29879,
29898,
16680,
29889,
12198,
29918,
4572,
29898,
14836,
29961,
29896,
11724,
9978,
29961,
29941,
2314,
13,
4706,
565,
1067,
29879,
29889,
276,
339,
2658,
29918,
294,
29918,
1707,
29901,
13,
9651,
6389,
353,
376,
29896,
2980,
29908,
13,
4706,
1683,
29901,
13,
9651,
6389,
353,
376,
29872,
2121,
29871,
29896,
470,
29871,
29941,
6273,
29908,
13,
4706,
12020,
4472,
29889,
6733,
16676,
2392,
11702,
29878,
4893,
1273,
29879,
29908,
1273,
313,
14836,
29961,
29900,
1402,
6389,
876,
13,
268,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
5446,
29892,
722,
978,
29922,
8516,
1125,
13,
4706,
1583,
29889,
5415,
353,
5446,
13,
4706,
1583,
29889,
1707,
978,
353,
722,
978,
13,
268,
13,
1678,
822,
679,
29918,
21032,
29898,
1311,
29892,
3030,
1125,
13,
4706,
5446,
353,
1583,
29889,
5415,
29889,
17863,
29898,
4703,
29897,
13,
4706,
6589,
353,
461,
29889,
12650,
29889,
4572,
29898,
13,
9651,
1203,
29918,
333,
29922,
5415,
29889,
20571,
29892,
13,
9651,
2793,
29918,
1853,
29922,
3916,
1542,
29889,
12650,
29889,
657,
29918,
1454,
29918,
4299,
29898,
5415,
29897,
13,
4706,
1723,
13,
4706,
736,
6589,
29889,
2098,
29918,
1609,
703,
7892,
29918,
1256,
1159,
13,
13,
13,
1990,
461,
3981,
4247,
29898,
5160,
20001,
4247,
1125,
13,
268,
13,
1678,
6858,
29918,
294,
29918,
1707,
353,
7700,
13,
268,
13,
1678,
822,
4050,
29898,
1311,
29892,
3030,
1125,
13,
4706,
6589,
353,
1583,
29889,
657,
29918,
21032,
29898,
4703,
467,
2798,
580,
13,
4706,
565,
1583,
29889,
1707,
978,
338,
451,
6213,
29901,
13,
9651,
3030,
29961,
1311,
29889,
1707,
978,
29962,
353,
6589,
13,
9651,
736,
5124,
13,
4706,
736,
29104,
29898,
21032,
29897,
13,
13,
13,
1990,
461,
29879,
4247,
29898,
5160,
20001,
4247,
1125,
13,
268,
13,
1678,
6858,
29918,
294,
29918,
1707,
353,
5852,
13,
268,
13,
1678,
822,
4050,
29898,
1311,
29892,
3030,
1125,
13,
4706,
3030,
29961,
1311,
29889,
1707,
978,
29962,
353,
1583,
29889,
657,
29918,
21032,
29898,
4703,
29897,
13,
4706,
736,
5124,
13,
13,
13,
1990,
461,
2500,
4247,
29898,
5160,
20001,
4247,
1125,
13,
268,
13,
1678,
6858,
29918,
294,
29918,
1707,
353,
7700,
13,
268,
13,
1678,
822,
4050,
29898,
1311,
29892,
3030,
1125,
13,
4706,
5446,
353,
1583,
29889,
5415,
29889,
17863,
29898,
4703,
29897,
13,
4706,
1404,
353,
3030,
29889,
657,
703,
1792,
1159,
13,
4706,
883,
29918,
1990,
353,
3030,
29889,
657,
703,
689,
613,
461,
2500,
29897,
13,
4706,
883,
353,
883,
29918,
1990,
29898,
5415,
29922,
5415,
29892,
1404,
29922,
1792,
29897,
13,
4706,
3030,
29961,
1311,
29889,
1707,
978,
29962,
353,
883,
13,
4706,
736,
5124,
13,
13,
13,
1990,
461,
8667,
4247,
29898,
5160,
20001,
4247,
1125,
13,
268,
13,
1678,
6858,
29918,
294,
29918,
1707,
353,
7700,
13,
268,
13,
1678,
822,
4050,
29898,
1311,
29892,
3030,
1125,
13,
4706,
5446,
353,
1583,
29889,
5415,
29889,
17863,
29898,
4703,
29897,
13,
4706,
736,
11837,
703,
2490,
29918,
9342,
613,
9049,
5085,
3790,
13,
9651,
376,
3051,
29918,
1853,
29918,
333,
1115,
10576,
1542,
29889,
12650,
29889,
657,
29918,
1454,
29918,
4299,
29898,
5415,
467,
20571,
29892,
13,
9651,
376,
3318,
29918,
333,
1115,
5446,
29889,
20571,
13,
4706,
5615,
13,
13,
13,
29992,
9573,
29889,
4039,
13,
1753,
3440,
29918,
2798,
29898,
16680,
29892,
5993,
1125,
13,
1678,
9995,
13,
1678,
10783,
482,
29901,
13,
308,
13,
4706,
18674,
3440,
29918,
2798,
5446,
15493,
13,
1678,
470,
13,
4706,
18674,
3440,
29918,
2798,
5446,
408,
722,
15493,
13,
1678,
9995,
13,
1678,
736,
461,
3981,
4247,
29889,
8411,
29918,
6979,
29898,
16680,
29892,
5993,
29897,
13,
13,
13,
29992,
9573,
29889,
4039,
13,
1753,
6589,
29898,
16680,
29892,
5993,
1125,
13,
1678,
9995,
13,
1678,
10783,
482,
29901,
13,
308,
13,
4706,
18674,
6589,
5446,
408,
722,
15493,
13,
1678,
9995,
13,
1678,
736,
461,
29879,
4247,
29889,
8411,
29918,
6979,
29898,
16680,
29892,
5993,
29897,
13,
13,
13,
29992,
9573,
29889,
4039,
13,
1753,
3440,
29918,
689,
29898,
16680,
29892,
5993,
1125,
13,
1678,
9995,
13,
1678,
10783,
482,
29901,
13,
308,
13,
4706,
18674,
3440,
29918,
689,
5446,
408,
3440,
29918,
689,
15493,
13,
308,
13,
1678,
2811,
1303,
278,
421,
1792,
29952,
722,
714,
310,
278,
378,
4776,
304,
1073,
565,
278,
883,
881,
367,
13,
1678,
883,
385,
4817,
29915,
29881,
1404,
470,
451,
29889,
13,
1678,
9995,
13,
1678,
736,
461,
2500,
4247,
29889,
8411,
29918,
6979,
29898,
16680,
29892,
5993,
29897,
13,
13,
13,
29992,
9573,
29889,
4039,
13,
1753,
3440,
29918,
5182,
29898,
16680,
29892,
5993,
1125,
13,
1678,
9995,
13,
1678,
10783,
482,
29901,
13,
308,
13,
4706,
18674,
3440,
29918,
5182,
5446,
518,
294,
722,
978,
29962,
15493,
13,
1678,
9995,
13,
1678,
736,
461,
8667,
4247,
29889,
8411,
29918,
6979,
29898,
16680,
29892,
5993,
29897,
13,
2
] |
python/tests/test_client.py | liaoyustudent/antchain-openapi-util-sdk | 0 | 49553 | <reponame>liaoyustudent/antchain-openapi-util-sdk
import unittest
from antchain_alipay_util.client import Client
class TestClient(unittest.TestCase):
def test_get_timestamp(self):
timestamp = Client.get_timestamp()
self.assertEqual(20, len(timestamp))
def test_has_error(self):
res = {'test': 'ok'}
resp = Client.has_error(res)
self.assertFalse(resp)
res = {"result_code": "OK"}
resp = Client.has_error(res)
self.assertFalse(resp)
res = {
'response': {
"result_code": "success"
}
}
resp = Client.has_error(res)
self.assertTrue(resp)
def test_get_signature(self):
params = {
'test': 'ok'
}
signature = Client.get_signature(params, 'secret')
self.assertEqual('qlB4B1lFcehlWRelL7Fo4uNHPCs=', signature)
| [
1,
529,
276,
1112,
420,
29958,
4456,
12602,
504,
10385,
29914,
424,
14153,
29899,
3150,
2754,
29899,
4422,
29899,
15348,
13,
5215,
443,
27958,
30004,
13,
3166,
3677,
14153,
29918,
284,
666,
388,
29918,
4422,
29889,
4645,
1053,
12477,
30004,
13,
30004,
13,
30004,
13,
1990,
4321,
4032,
29898,
348,
27958,
29889,
3057,
8259,
1125,
30004,
13,
1678,
822,
1243,
29918,
657,
29918,
16394,
29898,
1311,
1125,
30004,
13,
4706,
14334,
353,
12477,
29889,
657,
29918,
16394,
26471,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29906,
29900,
29892,
7431,
29898,
16394,
876,
30004,
13,
30004,
13,
1678,
822,
1243,
29918,
5349,
29918,
2704,
29898,
1311,
1125,
30004,
13,
4706,
620,
353,
11117,
1688,
2396,
525,
554,
29915,
8117,
13,
4706,
4613,
353,
12477,
29889,
5349,
29918,
2704,
29898,
690,
8443,
13,
4706,
1583,
29889,
9294,
8824,
29898,
13713,
8443,
13,
30004,
13,
4706,
620,
353,
8853,
2914,
29918,
401,
1115,
376,
8949,
29908,
8117,
13,
4706,
4613,
353,
12477,
29889,
5349,
29918,
2704,
29898,
690,
8443,
13,
4706,
1583,
29889,
9294,
8824,
29898,
13713,
8443,
13,
30004,
13,
4706,
620,
353,
3336,
13,
9651,
525,
5327,
2396,
3336,
13,
18884,
376,
2914,
29918,
401,
1115,
376,
8698,
19451,
13,
9651,
4970,
13,
4706,
4970,
13,
4706,
4613,
353,
12477,
29889,
5349,
29918,
2704,
29898,
690,
8443,
13,
4706,
1583,
29889,
9294,
5574,
29898,
13713,
8443,
13,
30004,
13,
1678,
822,
1243,
29918,
657,
29918,
4530,
1535,
29898,
1311,
1125,
30004,
13,
4706,
8636,
353,
3336,
13,
9651,
525,
1688,
2396,
525,
554,
29915,
30004,
13,
4706,
4970,
13,
4706,
12608,
353,
12477,
29889,
657,
29918,
4530,
1535,
29898,
7529,
29892,
525,
19024,
1495,
30004,
13,
4706,
1583,
29889,
9294,
9843,
877,
1519,
29933,
29946,
29933,
29896,
29880,
29943,
346,
4415,
29956,
9662,
29931,
29955,
29943,
29877,
29946,
29884,
29940,
3954,
29907,
29879,
29922,
742,
12608,
8443,
13,
2
] |
net_ip_config.py | musaibnazir/IPnDNS | 0 | 62051 | <reponame>musaibnazir/IPnDNS
#!/usr/bin/env python
import ipaddress as ip
CLASS_C_ADDR = '192.168.0.0'
if __name__ == '__main__':
not_configed = True
while not_configed:
prefix = input("Enter the prefixlen (24-30): ")
prefix = int(prefix)
if prefix not in range(23, 31):
raise Exception("Prefixlen must be between 24 and 30")
net_addr = CLASS_C_ADDR + '/' + str(prefix)
print("Using network address:%s " %net_addr)
try:
network = ip.ip_network(net_addr)
except:
raise Exception("Failed to create network object")
print("This prefix will give %s IP addresses"%(network.num_addresses))
print("The network configuration will be")
print("\t network address: %s"%str(network.network_address))
print("\t netmask: %s" %str(network.netmask))
print("\t broadcast address: %s"%str(network.broadcast_address))
first_ip, last_ip = list(network.hosts())[0],
list(network.hosts())[-1]
print("\t host IP addresses: from %s to %s" %(first_ip,last_ip))
ok = input("Is this configuration OK [y/n]? ")
ok = ok.lower()
if ok.strip() == 'y':
not_configed = False
| [
1,
529,
276,
1112,
420,
29958,
8366,
29874,
747,
29876,
834,
381,
29914,
5690,
29876,
29928,
3059,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
13,
5215,
10377,
7328,
408,
10377,
13,
13875,
1799,
29918,
29907,
29918,
3035,
8353,
353,
525,
29896,
29929,
29906,
29889,
29896,
29953,
29947,
29889,
29900,
29889,
29900,
29915,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
451,
29918,
2917,
287,
353,
5852,
13,
1678,
1550,
451,
29918,
2917,
287,
29901,
13,
4706,
10944,
353,
1881,
703,
10399,
278,
10944,
2435,
313,
29906,
29946,
29899,
29941,
29900,
1125,
16521,
13,
4706,
10944,
353,
938,
29898,
13506,
29897,
13,
4706,
565,
10944,
451,
297,
3464,
29898,
29906,
29941,
29892,
29871,
29941,
29896,
1125,
13,
9651,
12020,
8960,
703,
23095,
2435,
1818,
367,
1546,
29871,
29906,
29946,
322,
29871,
29941,
29900,
1159,
13,
4706,
7787,
29918,
10030,
353,
315,
4375,
1799,
29918,
29907,
29918,
3035,
8353,
718,
8207,
29915,
718,
851,
29898,
13506,
29897,
13,
4706,
1596,
703,
15156,
3564,
3211,
16664,
29879,
376,
1273,
1212,
29918,
10030,
29897,
13,
4706,
1018,
29901,
13,
9651,
3564,
353,
10377,
29889,
666,
29918,
11618,
29898,
1212,
29918,
10030,
29897,
13,
4706,
5174,
29901,
13,
9651,
12020,
8960,
703,
17776,
304,
1653,
3564,
1203,
1159,
13,
4706,
1596,
703,
4013,
10944,
674,
2367,
1273,
29879,
5641,
14157,
29908,
29995,
29898,
11618,
29889,
1949,
29918,
7328,
267,
876,
13,
4706,
1596,
703,
1576,
3564,
5285,
674,
367,
1159,
13,
4706,
1596,
14182,
29873,
3564,
3211,
29901,
1273,
29879,
29908,
29995,
710,
29898,
11618,
29889,
11618,
29918,
7328,
876,
13,
4706,
1596,
14182,
29873,
7787,
13168,
29901,
1273,
29879,
29908,
1273,
710,
29898,
11618,
29889,
1212,
13168,
876,
13,
4706,
1596,
14182,
29873,
12672,
3211,
29901,
1273,
29879,
29908,
29995,
710,
29898,
11618,
29889,
6729,
328,
4384,
29918,
7328,
876,
13,
4706,
937,
29918,
666,
29892,
1833,
29918,
666,
353,
1051,
29898,
11618,
29889,
23525,
3101,
29961,
29900,
1402,
13,
4706,
1051,
29898,
11618,
29889,
23525,
3101,
14352,
29896,
29962,
13,
4706,
1596,
14182,
29873,
3495,
5641,
14157,
29901,
515,
1273,
29879,
304,
1273,
29879,
29908,
1273,
29898,
4102,
29918,
666,
29892,
4230,
29918,
666,
876,
13,
4706,
3431,
353,
1881,
703,
3624,
445,
5285,
9280,
518,
29891,
29914,
29876,
29962,
29973,
16521,
13,
4706,
3431,
353,
3431,
29889,
13609,
580,
13,
4706,
565,
3431,
29889,
17010,
580,
1275,
525,
29891,
2396,
13,
9651,
451,
29918,
2917,
287,
353,
7700,
13,
2
] |
terminal.py | JetStarBlues/Intel-8080-Emulator | 4 | 44888 | <gh_stars>1-10
# ========================================================================================
#
# Description:
#
# Simple Terminal Emulator
#
# Interface:
# Input -> keyboard
# Output -> screen
#
# Attribution:
#
# Code by www.jk-quantized.com
#
# Redistribution and use of this code in source and binary forms must retain
# the above attribution notice and this condition.
#
# ========================================================================================
import tkinter
import threading
class Terminal():
def __init__ ( self, width=400, height=400 ):
self.keyBuffer = []
self.displayBuffer = ''
self.K_CTRL_C = 0x03
self.K_BACKSPACE = 0x08
self.K_LF = 0x0A
self.K_CR = 0x0D # used as end-of-(line,string,input) marker in TB
self.K_RUB_OUT = 0x7F # backspace
self.debugMode = False
self.width = width
self.height = height
self.textColor = '#689497'
self.bgColor = '#fff4dc'
self.tkRoot = None
self.tkTextBox = None
self.tkCanvas = None
self.tkCanvasFrame = None
# self.tkThread = threading.Thread(
# target = self.setupTkinter,
# name = 'tk_thread'
# ).start()
# Communication -----------------------------------
def transmit ( self ):
# Send data to CPU
if len( self.keyBuffer ) > 0:
return self.keyBuffer.pop()
else:
return 0
def receive ( self, data ):
# Receive data from CPU
self.displayCharacter( data )
def sendInterrupt ( self, isrLoc ):
'''
Real procedure,
set INT high
send RST instr
set INT low
ISR code will call IN to get data
'''
self.CPU.jumpToISR( isrLoc )
# Helper ------------------------------------------
def tooLazyToType ( self, filepath ):
with open( filepath, 'r' ) as file:
for line in file:
for char in line:
keyCode = ord( char )
if keyCode == self.K_LF:
keyCode = self.K_CR # tiny basic expects CR as delimiter
# print( char, keyCode )
self.addKeyToBuffer( keyCode )
# Keypress ----------------------------------------
def addKeyToBuffer ( self, key ):
self.keyBuffer.insert( 0, key )
# self.sendInterrupt() # interrupt vs waiting for poll
def handleKeypress ( self, event ):
if event.char: # modifier keys like SHIFT are None?
char = event.char
keyCode = ord( char )
# print( char, keyCode )
if keyCode == self.K_CTRL_C:
self.addKeyToBuffer( keyCode )
elif keyCode == self.K_BACKSPACE:
self.addKeyToBuffer( self.K_RUB_OUT )
elif keyCode == self.K_CR or keyCode == self.K_LF:
self.addKeyToBuffer( self.K_CR )
elif keyCode >= 32 and keyCode <= 126:
self.addKeyToBuffer( keyCode )
else:
# print( 'Key not handled - {}'.format( keyCode ) )
pass
# Display -----------------------------------------
def displayCharacter ( self, keyCode ):
if self.debugMode:
print( 'tkRaw ->', keyCode )
if keyCode == 0:
return
if keyCode >= 32 and keyCode <= 126:
self.displayBuffer += chr( keyCode )
elif keyCode == self.K_CR:
pass
elif keyCode == self.K_LF:
self.displayBuffer += '\n'
elif keyCode == self.K_BACKSPACE:
if len( self.displayBuffer ) > 0:
self.displayBuffer = self.displayBuffer[ : - 1 ] # remove from display buffer
self.updateDisplay()
def tk_onFrameConfigure( self, event ):
# resize canvas
self.tkCanvas.configure( scrollregion = self.tkCanvas.bbox( 'all' ) )
def tk_onCanvasConfigure( self, event ):
# resize frame
self.tkCanvas.itemconfigure( self.tkCanvasFrame, width = event.width )
def setupTkinter( self ):
self.tkRoot = tkinter.Tk()
self.tkRoot.title( '8080 Sim' )
self.tkCanvas = tkinter.Canvas( self.tkRoot )
self.tkCanvas.pack( side = tkinter.LEFT, expand = True, fill = 'both' )
self.tkCanvas.configure(
width = self.width,
height = self.height,
highlightthickness = 0,
bg = self.bgColor
)
scrollbar = tkinter.Scrollbar( self.tkRoot )
scrollbar.pack( side = tkinter.RIGHT, fill = 'y' )
scrollbar.configure(
orient = 'vertical',
command = self.tkCanvas.yview
)
self.tkCanvas.configure( yscrollcommand = scrollbar.set )
frame = tkinter.Frame( self.tkCanvas )
self.tkCanvasFrame = self.tkCanvas.create_window(
( 0, 0 ),
window = frame,
anchor = 'nw'
)
self.tkTextBox = tkinter.Label( frame )
self.tkTextBox.pack( expand = True, fill = 'both' )
self.tkTextBox[ 'text' ] = self.displayBuffer
self.tkTextBox.config(
fg = self.textColor,
bg = self.bgColor,
anchor = 'nw',
justify = tkinter.LEFT,
wraplength = self.width - 5
)
frame.bind( '<Configure>', self.tk_onFrameConfigure )
self.tkCanvas.bind( '<Configure>', self.tk_onCanvasConfigure )
self.tkRoot.bind( '<KeyPress>', self.handleKeypress )
self.tkRoot.protocol( 'WM_DELETE_WINDOW', self.quitTkinter )
self.tkRoot.mainloop()
def quitTkinter( self ):
self.tkRoot.quit()
print( 'Tkinter has exited' )
def updateDisplay( self ):
self.tkTextBox[ 'text' ] = self.displayBuffer
self.tkCanvas.yview_moveto( 1 ) # scroll to bottom (show latest)
# t = Terminal()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
29937,
1275,
9166,
9166,
9166,
9166,
9166,
2751,
1360,
13,
29937,
29871,
13,
29937,
29871,
12953,
29901,
13,
29937,
29871,
13,
29937,
268,
12545,
29175,
2812,
9183,
13,
29937,
13,
29937,
268,
25796,
29901,
13,
29937,
539,
10567,
29871,
1599,
12247,
13,
29937,
539,
10604,
1599,
4315,
13,
29937,
29871,
13,
29937,
29871,
6212,
3224,
29901,
13,
29937,
29871,
13,
29937,
268,
5920,
491,
7821,
29889,
25467,
29899,
12150,
1891,
29889,
510,
13,
29937,
29871,
13,
29937,
29871,
4367,
391,
3224,
322,
671,
310,
445,
775,
297,
2752,
322,
7581,
7190,
1818,
11551,
13,
29937,
29871,
278,
2038,
1098,
3224,
8369,
322,
445,
4195,
29889,
13,
29937,
29871,
13,
29937,
1275,
9166,
9166,
9166,
9166,
9166,
2751,
1360,
13,
13,
5215,
18883,
1639,
13,
5215,
3244,
292,
13,
13,
1990,
29175,
7295,
13,
13,
12,
1753,
4770,
2344,
1649,
313,
1583,
29892,
2920,
29922,
29946,
29900,
29900,
29892,
3171,
29922,
29946,
29900,
29900,
29871,
1125,
13,
13,
12,
12,
1311,
29889,
1989,
7701,
353,
5159,
13,
12,
12,
1311,
29889,
4990,
7701,
353,
6629,
13,
13,
12,
12,
1311,
29889,
29968,
29918,
1783,
2241,
29918,
29907,
1678,
353,
29871,
29900,
29916,
29900,
29941,
13,
12,
12,
1311,
29889,
29968,
29918,
29933,
11375,
5550,
11538,
353,
29871,
29900,
29916,
29900,
29947,
13,
12,
12,
1311,
29889,
29968,
29918,
29931,
29943,
4706,
353,
29871,
29900,
29916,
29900,
29909,
13,
12,
12,
1311,
29889,
29968,
29918,
11341,
4706,
353,
29871,
29900,
29916,
29900,
29928,
29871,
396,
1304,
408,
1095,
29899,
974,
17722,
1220,
29892,
1807,
29892,
2080,
29897,
17456,
297,
323,
29933,
13,
12,
12,
1311,
29889,
29968,
29918,
29934,
7466,
29918,
12015,
259,
353,
29871,
29900,
29916,
29955,
29943,
29871,
396,
1250,
3493,
13,
13,
12,
12,
1311,
29889,
8382,
6818,
353,
7700,
13,
13,
12,
12,
1311,
29889,
2103,
353,
2920,
13,
12,
12,
1311,
29889,
3545,
353,
3171,
13,
12,
12,
1311,
29889,
726,
3306,
353,
16321,
29953,
29947,
29929,
29946,
29929,
29955,
29915,
13,
12,
12,
1311,
29889,
16264,
3306,
353,
16321,
18725,
29946,
13891,
29915,
13,
12,
12,
1311,
29889,
11178,
10303,
353,
6213,
13,
12,
12,
1311,
29889,
11178,
15102,
353,
6213,
13,
12,
12,
1311,
29889,
11178,
21960,
353,
6213,
13,
12,
12,
1311,
29889,
11178,
21960,
4308,
353,
6213,
13,
13,
12,
12,
29937,
1583,
29889,
11178,
4899,
353,
3244,
292,
29889,
4899,
29898,
13,
13,
12,
12,
29937,
29871,
12,
5182,
353,
1583,
29889,
14669,
29911,
29895,
1639,
29892,
13,
12,
12,
29937,
29871,
12,
978,
353,
525,
11178,
29918,
7097,
29915,
13,
13,
12,
12,
29937,
13742,
2962,
580,
13,
13,
13,
12,
29937,
22365,
362,
448,
2683,
2683,
489,
13,
13,
12,
1753,
22649,
313,
1583,
29871,
1125,
13,
13,
12,
12,
29937,
15076,
848,
304,
10808,
13,
13,
12,
12,
361,
7431,
29898,
1583,
29889,
1989,
7701,
1723,
1405,
29871,
29900,
29901,
13,
13,
12,
12,
12,
2457,
1583,
29889,
1989,
7701,
29889,
7323,
580,
13,
13,
12,
12,
2870,
29901,
13,
13,
12,
12,
12,
2457,
29871,
29900,
13,
13,
12,
1753,
7150,
313,
1583,
29892,
848,
29871,
1125,
13,
13,
12,
12,
29937,
24328,
573,
848,
515,
10808,
13,
13,
12,
12,
1311,
29889,
4990,
20755,
29898,
848,
1723,
13,
13,
12,
1753,
3638,
4074,
6685,
313,
1583,
29892,
338,
29878,
3524,
29871,
1125,
13,
13,
12,
12,
12008,
13,
12,
12,
12,
21713,
8792,
29892,
13,
12,
12,
12,
29871,
731,
19578,
1880,
13,
12,
12,
12,
29871,
3638,
390,
1254,
297,
710,
13,
12,
12,
12,
29871,
731,
19578,
4482,
13,
12,
12,
12,
29871,
8519,
29934,
775,
674,
1246,
2672,
304,
679,
848,
13,
12,
12,
12008,
13,
13,
12,
12,
1311,
29889,
6271,
29965,
29889,
29926,
3427,
1762,
3235,
29934,
29898,
338,
29878,
3524,
1723,
13,
13,
13,
12,
29937,
6162,
546,
448,
2683,
2683,
1378,
29899,
13,
13,
12,
1753,
2086,
29931,
24683,
1762,
1542,
313,
1583,
29892,
934,
2084,
29871,
1125,
13,
13,
12,
12,
2541,
1722,
29898,
934,
2084,
29892,
525,
29878,
29915,
1723,
408,
934,
29901,
13,
13,
12,
12,
12,
1454,
1196,
297,
934,
29901,
13,
13,
12,
12,
12,
12,
1454,
1373,
297,
1196,
29901,
13,
13,
12,
12,
12,
12,
12,
1989,
3399,
353,
4356,
29898,
1373,
1723,
13,
13,
12,
12,
12,
12,
12,
361,
1820,
3399,
1275,
1583,
29889,
29968,
29918,
29931,
29943,
29901,
13,
13,
12,
12,
12,
12,
12,
12,
1989,
3399,
353,
1583,
29889,
29968,
29918,
11341,
29871,
396,
21577,
6996,
23347,
15600,
408,
28552,
13,
13,
12,
12,
12,
12,
12,
29937,
1596,
29898,
1373,
29892,
1820,
3399,
1723,
13,
13,
12,
12,
12,
12,
12,
1311,
29889,
1202,
2558,
1762,
7701,
29898,
1820,
3399,
1723,
13,
13,
13,
12,
29937,
7670,
2139,
448,
2683,
2683,
26589,
13,
13,
12,
1753,
788,
2558,
1762,
7701,
313,
1583,
29892,
1820,
29871,
1125,
13,
13,
12,
12,
1311,
29889,
1989,
7701,
29889,
7851,
29898,
29871,
29900,
29892,
1820,
1723,
13,
13,
12,
12,
29937,
1583,
29889,
6717,
4074,
6685,
580,
29871,
396,
23754,
7186,
10534,
363,
21180,
13,
12,
12,
13,
13,
12,
1753,
4386,
2558,
2139,
313,
1583,
29892,
1741,
29871,
1125,
13,
13,
12,
12,
361,
1741,
29889,
3090,
29901,
29871,
396,
878,
3709,
6611,
763,
24972,
6545,
29911,
526,
6213,
29973,
13,
13,
12,
12,
12,
3090,
353,
1741,
29889,
3090,
13,
12,
12,
12,
1989,
3399,
353,
4356,
29898,
1373,
1723,
13,
13,
12,
12,
12,
29937,
1596,
29898,
1373,
29892,
1820,
3399,
1723,
13,
13,
12,
12,
12,
361,
1820,
3399,
1275,
1583,
29889,
29968,
29918,
1783,
2241,
29918,
29907,
29901,
13,
13,
12,
12,
12,
12,
1311,
29889,
1202,
2558,
1762,
7701,
29898,
1820,
3399,
1723,
13,
13,
12,
12,
12,
23681,
1820,
3399,
1275,
1583,
29889,
29968,
29918,
29933,
11375,
5550,
11538,
29901,
259,
13,
13,
12,
12,
12,
12,
1311,
29889,
1202,
2558,
1762,
7701,
29898,
1583,
29889,
29968,
29918,
29934,
7466,
29918,
12015,
1723,
13,
13,
12,
12,
12,
23681,
1820,
3399,
1275,
1583,
29889,
29968,
29918,
11341,
470,
1820,
3399,
1275,
1583,
29889,
29968,
29918,
29931,
29943,
29901,
13,
13,
12,
12,
12,
12,
1311,
29889,
1202,
2558,
1762,
7701,
29898,
1583,
29889,
29968,
29918,
11341,
1723,
13,
13,
12,
12,
12,
23681,
1820,
3399,
6736,
29871,
29941,
29906,
322,
1820,
3399,
5277,
29871,
29896,
29906,
29953,
29901,
13,
13,
12,
12,
12,
12,
1311,
29889,
1202,
2558,
1762,
7701,
29898,
1820,
3399,
1723,
13,
13,
12,
12,
12,
2870,
29901,
13,
13,
12,
12,
12,
12,
29937,
1596,
29898,
525,
2558,
451,
16459,
448,
6571,
4286,
4830,
29898,
1820,
3399,
1723,
1723,
13,
12,
12,
12,
12,
3364,
13,
13,
13,
12,
29937,
17440,
448,
2683,
2683,
1378,
13,
13,
12,
1753,
2479,
20755,
313,
1583,
29892,
1820,
3399,
29871,
1125,
13,
13,
12,
12,
361,
1583,
29889,
8382,
6818,
29901,
13,
13,
12,
12,
12,
2158,
29898,
525,
11178,
22131,
1599,
742,
1820,
3399,
1723,
13,
13,
12,
12,
361,
1820,
3399,
1275,
29871,
29900,
29901,
13,
13,
12,
12,
12,
2457,
13,
13,
12,
12,
361,
1820,
3399,
6736,
29871,
29941,
29906,
322,
1820,
3399,
5277,
29871,
29896,
29906,
29953,
29901,
13,
13,
12,
12,
12,
1311,
29889,
4990,
7701,
4619,
18460,
29898,
1820,
3399,
1723,
13,
13,
12,
12,
23681,
1820,
3399,
1275,
1583,
29889,
29968,
29918,
11341,
29901,
13,
13,
12,
12,
12,
3364,
13,
13,
12,
12,
23681,
1820,
3399,
1275,
1583,
29889,
29968,
29918,
29931,
29943,
29901,
13,
13,
12,
12,
12,
1311,
29889,
4990,
7701,
4619,
11297,
29876,
29915,
13,
13,
12,
12,
23681,
1820,
3399,
1275,
1583,
29889,
29968,
29918,
29933,
11375,
5550,
11538,
29901,
259,
13,
13,
12,
12,
12,
361,
7431,
29898,
1583,
29889,
4990,
7701,
1723,
1405,
29871,
29900,
29901,
13,
13,
12,
12,
12,
12,
1311,
29889,
4990,
7701,
353,
1583,
29889,
4990,
7701,
29961,
584,
448,
29871,
29896,
4514,
29871,
396,
3349,
515,
2479,
6835,
13,
13,
13,
12,
12,
1311,
29889,
5504,
9323,
580,
13,
13,
12,
1753,
18883,
29918,
265,
4308,
3991,
545,
29898,
1583,
29892,
1741,
29871,
1125,
13,
13,
12,
12,
29937,
19490,
10508,
13,
12,
12,
1311,
29889,
11178,
21960,
29889,
17591,
29898,
6355,
12803,
353,
1583,
29889,
11178,
21960,
29889,
29890,
1884,
29898,
525,
497,
29915,
1723,
1723,
13,
13,
12,
1753,
18883,
29918,
265,
21960,
3991,
545,
29898,
1583,
29892,
1741,
29871,
1125,
13,
13,
12,
12,
29937,
19490,
3515,
13,
12,
12,
1311,
29889,
11178,
21960,
29889,
667,
17591,
29898,
1583,
29889,
11178,
21960,
4308,
29892,
2920,
353,
1741,
29889,
2103,
1723,
13,
13,
12,
1753,
6230,
29911,
29895,
1639,
29898,
1583,
29871,
1125,
13,
13,
12,
12,
1311,
29889,
11178,
10303,
353,
18883,
1639,
29889,
29911,
29895,
580,
13,
12,
12,
1311,
29889,
11178,
10303,
29889,
3257,
29898,
525,
29947,
29900,
29947,
29900,
3439,
29915,
1723,
13,
13,
12,
12,
1311,
29889,
11178,
21960,
353,
18883,
1639,
29889,
21960,
29898,
1583,
29889,
11178,
10303,
1723,
13,
12,
12,
1311,
29889,
11178,
21960,
29889,
4058,
29898,
2625,
353,
18883,
1639,
29889,
28024,
29892,
7985,
353,
5852,
29892,
5445,
353,
525,
20313,
29915,
1723,
13,
12,
12,
1311,
29889,
11178,
21960,
29889,
17591,
29898,
13,
13,
12,
12,
12,
2103,
353,
1583,
29889,
2103,
29892,
13,
12,
12,
12,
3545,
353,
1583,
29889,
3545,
29892,
13,
12,
12,
12,
28970,
27996,
2264,
353,
29871,
29900,
29892,
13,
12,
12,
12,
16264,
353,
1583,
29889,
16264,
3306,
13,
12,
12,
29897,
13,
13,
12,
12,
10510,
1646,
353,
18883,
1639,
29889,
10463,
1646,
29898,
1583,
29889,
11178,
10303,
1723,
13,
12,
12,
10510,
1646,
29889,
4058,
29898,
2625,
353,
18883,
1639,
29889,
22789,
3912,
29892,
5445,
353,
525,
29891,
29915,
1723,
13,
12,
12,
10510,
1646,
29889,
17591,
29898,
13,
13,
12,
12,
12,
12236,
353,
525,
18575,
742,
13,
12,
12,
12,
6519,
353,
1583,
29889,
11178,
21960,
29889,
29891,
1493,
13,
12,
12,
29897,
13,
12,
12,
1311,
29889,
11178,
21960,
29889,
17591,
29898,
343,
10510,
6519,
353,
6355,
1646,
29889,
842,
1723,
13,
13,
12,
12,
2557,
353,
18883,
1639,
29889,
4308,
29898,
1583,
29889,
11178,
21960,
1723,
13,
12,
12,
1311,
29889,
11178,
21960,
4308,
353,
1583,
29889,
11178,
21960,
29889,
3258,
29918,
7165,
29898,
13,
13,
12,
12,
12,
29898,
29871,
29900,
29892,
29871,
29900,
10353,
13,
12,
12,
12,
7165,
353,
3515,
29892,
13,
12,
12,
12,
25367,
353,
525,
29876,
29893,
29915,
13,
12,
12,
29897,
13,
13,
12,
12,
1311,
29889,
11178,
15102,
353,
18883,
1639,
29889,
4775,
29898,
3515,
1723,
13,
12,
12,
1311,
29889,
11178,
15102,
29889,
4058,
29898,
7985,
353,
5852,
29892,
5445,
353,
525,
20313,
29915,
1723,
13,
12,
12,
1311,
29889,
11178,
15102,
29961,
525,
726,
29915,
4514,
353,
1583,
29889,
4990,
7701,
13,
12,
12,
1311,
29889,
11178,
15102,
29889,
2917,
29898,
13,
13,
12,
12,
12,
16434,
353,
1583,
29889,
726,
3306,
29892,
13,
12,
12,
12,
16264,
353,
1583,
29889,
16264,
3306,
29892,
13,
12,
12,
12,
25367,
353,
525,
29876,
29893,
742,
13,
12,
12,
12,
5143,
1598,
353,
18883,
1639,
29889,
28024,
29892,
13,
12,
12,
12,
29893,
336,
572,
1477,
353,
1583,
29889,
2103,
448,
29871,
29945,
13,
12,
12,
29897,
13,
13,
12,
12,
2557,
29889,
5355,
29898,
12801,
3991,
545,
29958,
742,
1583,
29889,
11178,
29918,
265,
4308,
3991,
545,
1723,
13,
12,
12,
1311,
29889,
11178,
21960,
29889,
5355,
29898,
12801,
3991,
545,
29958,
742,
1583,
29889,
11178,
29918,
265,
21960,
3991,
545,
1723,
13,
13,
12,
12,
1311,
29889,
11178,
10303,
29889,
5355,
29898,
12801,
2558,
10923,
29958,
742,
1583,
29889,
8411,
2558,
2139,
1723,
13,
13,
12,
12,
1311,
29889,
11178,
10303,
29889,
20464,
29898,
525,
26735,
29918,
2287,
18476,
29918,
25152,
3970,
29956,
742,
1583,
29889,
28358,
29911,
29895,
1639,
1723,
13,
12,
12,
13,
12,
12,
1311,
29889,
11178,
10303,
29889,
3396,
7888,
580,
13,
13,
12,
1753,
23283,
29911,
29895,
1639,
29898,
1583,
29871,
1125,
13,
13,
12,
12,
1311,
29889,
11178,
10303,
29889,
28358,
580,
13,
13,
12,
12,
2158,
29898,
525,
29911,
29895,
1639,
756,
429,
1573,
29915,
1723,
13,
13,
12,
1753,
2767,
9323,
29898,
1583,
29871,
1125,
13,
13,
12,
12,
1311,
29889,
11178,
15102,
29961,
525,
726,
29915,
4514,
353,
1583,
29889,
4990,
7701,
13,
13,
12,
12,
1311,
29889,
11178,
21960,
29889,
29891,
1493,
29918,
13529,
10896,
29898,
29871,
29896,
1723,
29871,
396,
6355,
304,
5970,
313,
4294,
9281,
29897,
13,
13,
13,
29937,
260,
353,
29175,
580,
13,
2
] |
hackerrank/queues-and-stacks/min_max_riddle.py | peoplenarthax/code-challenges | 0 | 70113 | <reponame>peoplenarthax/code-challenges<gh_stars>0
#!/bin/python3
import math
import os
import random
import re
import sys
from collections import defaultdict
def riddle(arr):
stack = []
arr.append(0) # Add 0 at the end of the numbers
map_of_minimums=defaultdict(int)
# Identify the largest window a number is minimum to
for index,current_value in enumerate(arr):
new_index=index
while stack and stack[-1][0]>=current_value:
val,old_index = stack.pop()
map_of_minimums[current_value]=max(map_of_minimums[current_value],index-old_index+1)
map_of_minimums[val]=max(map_of_minimums[val],index-old_index)
new_index=old_index
stack.append([current_value,new_index])
del map_of_minimums[0] # Removed artificial entry
e=defaultdict(int)
# Inverting the saved values to compare the biggest in each window size
for i in map_of_minimums:
e[map_of_minimums[i]]=max(e[map_of_minimums[i]],i)
ans=[e[len(arr)-1]] # First add the global minimum
for i in range(len(arr)-2,0,-1):
# If window does not exist or is smaller than the previous window element, we use the previous
if e[i]<ans[-1]:
ans.append(ans[-1])
else:
ans.append(e[i])
return reversed(ans)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
arr = list(map(int, input().rstrip().split()))
res = riddle(arr)
fptr.write(' '.join(map(str, res)))
fptr.write('\n')
fptr.close()
| [
1,
529,
276,
1112,
420,
29958,
412,
459,
2435,
28696,
1165,
29914,
401,
29899,
305,
16047,
267,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
14708,
2109,
29914,
4691,
29941,
13,
13,
5215,
5844,
13,
5215,
2897,
13,
5215,
4036,
13,
5215,
337,
13,
5215,
10876,
13,
3166,
16250,
1053,
2322,
8977,
13,
13,
1753,
364,
2632,
29898,
2749,
1125,
13,
1678,
5096,
353,
5159,
13,
1678,
3948,
29889,
4397,
29898,
29900,
29897,
396,
3462,
29871,
29900,
472,
278,
1095,
310,
278,
3694,
13,
1678,
2910,
29918,
974,
29918,
1195,
326,
6762,
29922,
4381,
8977,
29898,
524,
29897,
13,
1678,
396,
13355,
1598,
278,
10150,
3474,
263,
1353,
338,
9212,
304,
13,
1678,
363,
2380,
29892,
3784,
29918,
1767,
297,
26985,
29898,
2749,
1125,
9651,
13,
4706,
716,
29918,
2248,
29922,
2248,
13,
13,
4706,
1550,
5096,
322,
5096,
14352,
29896,
3816,
29900,
29962,
18572,
3784,
29918,
1767,
29901,
13,
9651,
659,
29892,
1025,
29918,
2248,
353,
5096,
29889,
7323,
580,
13,
9651,
2910,
29918,
974,
29918,
1195,
326,
6762,
29961,
3784,
29918,
1767,
13192,
3317,
29898,
1958,
29918,
974,
29918,
1195,
326,
6762,
29961,
3784,
29918,
1767,
1402,
2248,
29899,
1025,
29918,
2248,
29974,
29896,
29897,
13,
9651,
2910,
29918,
974,
29918,
1195,
326,
6762,
29961,
791,
13192,
3317,
29898,
1958,
29918,
974,
29918,
1195,
326,
6762,
29961,
791,
1402,
2248,
29899,
1025,
29918,
2248,
29897,
13,
9651,
716,
29918,
2248,
29922,
1025,
29918,
2248,
13,
4706,
5096,
29889,
4397,
4197,
3784,
29918,
1767,
29892,
1482,
29918,
2248,
2314,
13,
1678,
628,
2910,
29918,
974,
29918,
1195,
326,
6762,
29961,
29900,
29962,
396,
5240,
8238,
23116,
6251,
13,
13,
1678,
321,
29922,
4381,
8977,
29898,
524,
29897,
13,
1678,
396,
512,
369,
1259,
278,
7160,
1819,
304,
7252,
278,
24842,
297,
1269,
3474,
2159,
13,
1678,
363,
474,
297,
2910,
29918,
974,
29918,
1195,
326,
6762,
29901,
462,
9651,
13,
4706,
321,
29961,
1958,
29918,
974,
29918,
1195,
326,
6762,
29961,
29875,
5262,
29922,
3317,
29898,
29872,
29961,
1958,
29918,
974,
29918,
1195,
326,
6762,
29961,
29875,
20526,
29875,
29897,
13,
13,
1678,
6063,
11759,
29872,
29961,
2435,
29898,
2749,
6817,
29896,
5262,
396,
3824,
788,
278,
5534,
9212,
13,
1678,
363,
474,
297,
3464,
29898,
2435,
29898,
2749,
6817,
29906,
29892,
29900,
6653,
29896,
1125,
308,
13,
4706,
396,
960,
3474,
947,
451,
1863,
470,
338,
7968,
1135,
278,
3517,
3474,
1543,
29892,
591,
671,
278,
3517,
13,
4706,
565,
321,
29961,
29875,
29962,
29966,
550,
14352,
29896,
5387,
13,
9651,
6063,
29889,
4397,
29898,
550,
14352,
29896,
2314,
13,
4706,
1683,
29901,
13,
9651,
6063,
29889,
4397,
29898,
29872,
29961,
29875,
2314,
13,
1678,
736,
18764,
287,
29898,
550,
29897,
29871,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
285,
7414,
353,
1722,
29898,
359,
29889,
21813,
1839,
12015,
12336,
29918,
10145,
7464,
525,
29893,
1495,
13,
13,
1678,
302,
353,
938,
29898,
2080,
3101,
13,
13,
1678,
3948,
353,
1051,
29898,
1958,
29898,
524,
29892,
1881,
2141,
29878,
17010,
2141,
5451,
22130,
13,
13,
1678,
620,
353,
364,
2632,
29898,
2749,
29897,
13,
13,
1678,
285,
7414,
29889,
3539,
877,
15300,
7122,
29898,
1958,
29898,
710,
29892,
620,
4961,
13,
1678,
285,
7414,
29889,
3539,
28909,
29876,
1495,
13,
13,
1678,
285,
7414,
29889,
5358,
580,
13,
2
] |
server/app/models/Course.py | MozammilKhan/tdsb-project | 12 | 127487 | <filename>server/app/models/Course.py
#!/usr/bin/env python
# coding=utf-8
import datetime
from app.database import DB
class Course(object):
def __init__(self, name, instructor, _id):
self._id = _id
self.name= name
self.instructor = instructor
self.students = []
#add attributes
def insert(self):
if not DB.find_one("Courses", {"_id": self._id}):
DB.insert(collection='Courses', data=self.json())
def json(self):
return {
"_id": self._id,
"name": self.name,
"instructor": self.instructor,
"students": self.students
}
| [
1,
529,
9507,
29958,
2974,
29914,
932,
29914,
9794,
29914,
29907,
10242,
29889,
2272,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
13,
29937,
14137,
29922,
9420,
29899,
29947,
13,
5215,
12865,
13,
13,
3166,
623,
29889,
9803,
1053,
6535,
13,
13,
13,
1990,
6325,
344,
29898,
3318,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1024,
29892,
18690,
272,
29892,
903,
333,
1125,
13,
4706,
1583,
3032,
333,
353,
903,
333,
13,
4706,
1583,
29889,
978,
29922,
1024,
13,
4706,
1583,
29889,
2611,
1247,
272,
353,
18690,
272,
13,
4706,
1583,
29889,
18082,
1237,
353,
5159,
13,
4706,
396,
1202,
8393,
13,
13,
1678,
822,
4635,
29898,
1311,
1125,
13,
4706,
565,
451,
6535,
29889,
2886,
29918,
650,
703,
29907,
29781,
613,
8853,
29918,
333,
1115,
1583,
3032,
333,
29913,
1125,
13,
9651,
6535,
29889,
7851,
29898,
10855,
2433,
29907,
29781,
742,
848,
29922,
1311,
29889,
3126,
3101,
13,
13,
1678,
822,
4390,
29898,
1311,
1125,
13,
4706,
736,
426,
13,
9651,
11119,
333,
1115,
1583,
3032,
333,
29892,
13,
9651,
376,
978,
1115,
1583,
29889,
978,
29892,
13,
9651,
376,
2611,
1247,
272,
1115,
1583,
29889,
2611,
1247,
272,
29892,
13,
9651,
376,
18082,
1237,
1115,
1583,
29889,
18082,
1237,
9651,
13,
4706,
500,
13,
308,
2
] |
run.py | MRWWRN/buke | 0 | 184463 | #!/usr/bin/env python3
# -*- coding: UTF-8 -*-
import time, random, hashlib
from flask import Flask, session, request, abort
from apps.admin import admin
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16M
app.register_blueprint(admin, url_prefix='/admin')
app.secret_key = '<KEY>'
@app.before_request
def set_cookies():
if session.get('login', '') == '':
try:
tempname = request.headers.get('User-Agent')[:120] + str(time.time()) + str(random.random())
except Exception:
abort(401)
tempname = hashlib.md5(tempname.encode('utf-8')).hexdigest()
session['username'] = tempname
session['login'] = 'false'
return None
from views import *
if __name__ == '__main__':
app.run(host='0.0.0.0')
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
29941,
30004,
13,
29937,
448,
29930,
29899,
14137,
29901,
18351,
29899,
29947,
448,
29930,
29899,
30004,
13,
30004,
13,
5215,
931,
29892,
4036,
29892,
6608,
1982,
30004,
13,
30004,
13,
3166,
29784,
1053,
2379,
1278,
29892,
4867,
29892,
2009,
29892,
27450,
30004,
13,
3166,
11446,
29889,
6406,
1053,
4113,
30004,
13,
30004,
13,
30004,
13,
932,
353,
2379,
1278,
22168,
978,
1649,
8443,
13,
30004,
13,
932,
29889,
2917,
1839,
12648,
29918,
22412,
3919,
29918,
19433,
2033,
353,
29871,
29896,
29953,
334,
29871,
29896,
29900,
29906,
29946,
334,
29871,
29896,
29900,
29906,
29946,
29871,
396,
29871,
29896,
29953,
29924,
30004,
13,
932,
29889,
9573,
29918,
9539,
2158,
29898,
6406,
29892,
3142,
29918,
13506,
2433,
29914,
6406,
1495,
30004,
13,
30004,
13,
932,
29889,
19024,
29918,
1989,
353,
12801,
10818,
16299,
30004,
13,
30004,
13,
29992,
932,
29889,
11083,
29918,
3827,
30004,
13,
1753,
731,
29918,
15108,
583,
7295,
30004,
13,
1678,
565,
4867,
29889,
657,
877,
7507,
742,
27255,
1275,
525,
2396,
30004,
13,
4706,
1018,
29901,
30004,
13,
9651,
5694,
978,
353,
2009,
29889,
13662,
29889,
657,
877,
2659,
29899,
19661,
1495,
7503,
29896,
29906,
29900,
29962,
718,
851,
29898,
2230,
29889,
2230,
3101,
718,
851,
29898,
8172,
29889,
8172,
3101,
30004,
13,
4706,
5174,
8960,
29901,
30004,
13,
9651,
27450,
29898,
29946,
29900,
29896,
8443,
13,
4706,
5694,
978,
353,
6608,
1982,
29889,
3487,
29945,
29898,
7382,
978,
29889,
12508,
877,
9420,
29899,
29947,
1495,
467,
20970,
7501,
342,
26471,
13,
4706,
4867,
1839,
6786,
2033,
353,
5694,
978,
30004,
13,
4706,
4867,
1839,
7507,
2033,
353,
525,
4541,
29915,
30004,
13,
1678,
736,
6213,
30004,
13,
30004,
13,
3166,
8386,
1053,
334,
30004,
13,
30004,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
30004,
13,
1678,
623,
29889,
3389,
29898,
3069,
2433,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
1495,
30004,
13,
2
] |
NodeGraphQt/widgets/node_graph.py | jchanvfx/bpNodeGraph | 8 | 137589 | <reponame>jchanvfx/bpNodeGraph
from Qt import QtWidgets, QtGui
from NodeGraphQt.constants import (
NodeEnum, ViewerEnum, ViewerNavEnum
)
from NodeGraphQt.widgets.viewer_nav import NodeNavigationWidget
class NodeGraphWidget(QtWidgets.QTabWidget):
def __init__(self, parent=None):
super(NodeGraphWidget, self).__init__(parent)
self.setTabsClosable(True)
self.setTabBarAutoHide(True)
text_color = self.palette().text().color().getRgb()
bg_color = QtGui.QColor(
*ViewerEnum.BACKGROUND_COLOR.value).darker(120).getRgb()
style_dict = {
'QWidget': {
'background-color': 'rgb({0},{1},{2})'.format(
*ViewerEnum.BACKGROUND_COLOR.value
),
},
'QTabWidget::pane': {
'background': 'rgb({0},{1},{2})'.format(
*ViewerEnum.BACKGROUND_COLOR.value
),
'border': '0px',
'border-top': '0px solid rgb({0},{1},{2})'.format(*bg_color),
},
'QTabBar::tab': {
'background': 'rgb({0},{1},{2})'.format(*bg_color),
'border': '0px solid black',
'color': 'rgba({0},{1},{2},30)'.format(*text_color),
'min-width': '10px',
'padding': '10px 20px',
},
'QTabBar::tab:selected': {
'color': 'rgb({0},{1},{2})'.format(*text_color),
'background': 'rgb({0},{1},{2})'.format(
*ViewerNavEnum.BACKGROUND_COLOR.value
),
'border-top': '1px solid rgb({0},{1},{2})'
.format(*NodeEnum.SELECTED_BORDER_COLOR.value),
},
'QTabBar::tab:hover': {
'color': 'rgb({0},{1},{2})'.format(*text_color),
'border-top': '1px solid rgb({0},{1},{2})'
.format(*NodeEnum.SELECTED_BORDER_COLOR.value),
}
}
stylesheet = ''
for css_class, css in style_dict.items():
style = '{} {{\n'.format(css_class)
for elm_name, elm_val in css.items():
style += ' {}:{};\n'.format(elm_name, elm_val)
style += '}\n'
stylesheet += style
self.setStyleSheet(stylesheet)
def add_viewer(self, viewer, name, node_id):
self.addTab(viewer, name)
index = self.indexOf(viewer)
self.setTabToolTip(index, node_id)
self.setCurrentIndex(index)
def remove_viewer(self, viewer):
index = self.indexOf(viewer)
self.removeTab(index)
class SubGraphWidget(QtWidgets.QWidget):
def __init__(self, parent=None, graph=None):
super(SubGraphWidget, self).__init__(parent)
self._graph = graph
self._navigator = NodeNavigationWidget()
self._layout = QtWidgets.QVBoxLayout(self)
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.setSpacing(1)
self._layout.addWidget(self._navigator)
self._viewer_widgets = {}
self._viewer_current = None
@property
def navigator(self):
return self._navigator
def add_viewer(self, viewer, name, node_id):
if viewer in self._viewer_widgets:
return
if self._viewer_current:
self.hide_viewer(self._viewer_current)
self._navigator.add_label_item(name, node_id)
self._layout.addWidget(viewer)
self._viewer_widgets[viewer] = node_id
self._viewer_current = viewer
self._viewer_current.show()
def remove_viewer(self, viewer=None):
if viewer is None and self._viewer_current:
viewer = self._viewer_current
node_id = self._viewer_widgets.pop(viewer)
self._navigator.remove_label_item(node_id)
self._layout.removeWidget(viewer)
viewer.deleteLater()
def hide_viewer(self, viewer):
self._layout.removeWidget(viewer)
viewer.hide()
def show_viewer(self, viewer):
if viewer == self._viewer_current:
self._viewer_current.show()
return
if viewer in self._viewer_widgets:
if self._viewer_current:
self.hide_viewer(self._viewer_current)
self._layout.addWidget(viewer)
self._viewer_current = viewer
self._viewer_current.show()
| [
1,
529,
276,
1112,
420,
29958,
29926,
5083,
29894,
11093,
29914,
25288,
4247,
9527,
13,
3166,
14705,
1053,
14705,
8801,
29879,
29892,
14705,
28707,
13,
13,
3166,
9071,
9527,
17303,
29889,
3075,
1934,
1053,
313,
13,
1678,
9071,
16854,
29892,
478,
15580,
16854,
29892,
478,
15580,
22107,
16854,
13,
29897,
13,
13,
3166,
9071,
9527,
17303,
29889,
8030,
29879,
29889,
29894,
15580,
29918,
6654,
1053,
9071,
20245,
8801,
13,
13,
13,
1990,
9071,
9527,
8801,
29898,
17303,
8801,
29879,
29889,
29984,
8863,
8801,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3847,
29922,
8516,
1125,
13,
4706,
2428,
29898,
4247,
9527,
8801,
29892,
1583,
467,
1649,
2344,
12035,
3560,
29897,
13,
4706,
1583,
29889,
842,
29911,
6897,
29907,
5409,
519,
29898,
5574,
29897,
13,
4706,
1583,
29889,
842,
8863,
4297,
12300,
29950,
680,
29898,
5574,
29897,
13,
4706,
1426,
29918,
2780,
353,
1583,
29889,
29886,
26456,
2141,
726,
2141,
2780,
2141,
657,
29934,
26300,
580,
13,
4706,
25989,
29918,
2780,
353,
14705,
28707,
29889,
29984,
3306,
29898,
13,
9651,
334,
29963,
15580,
16854,
29889,
29933,
11375,
29954,
1672,
18783,
29918,
15032,
1955,
29889,
1767,
467,
26031,
261,
29898,
29896,
29906,
29900,
467,
657,
29934,
26300,
580,
13,
4706,
3114,
29918,
8977,
353,
426,
13,
9651,
525,
29984,
8801,
2396,
426,
13,
18884,
525,
7042,
29899,
2780,
2396,
525,
23973,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
4286,
4830,
29898,
13,
462,
1678,
334,
29963,
15580,
16854,
29889,
29933,
11375,
29954,
1672,
18783,
29918,
15032,
1955,
29889,
1767,
13,
18884,
10353,
13,
9651,
2981,
13,
9651,
525,
29984,
8863,
8801,
1057,
29886,
1662,
2396,
426,
13,
18884,
525,
7042,
2396,
525,
23973,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
4286,
4830,
29898,
13,
462,
1678,
334,
29963,
15580,
16854,
29889,
29933,
11375,
29954,
1672,
18783,
29918,
15032,
1955,
29889,
1767,
13,
18884,
10353,
13,
18884,
525,
11466,
2396,
525,
29900,
1756,
742,
13,
18884,
525,
11466,
29899,
3332,
2396,
525,
29900,
1756,
7773,
15552,
29890,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
4286,
4830,
10456,
16264,
29918,
2780,
511,
13,
9651,
2981,
13,
9651,
525,
29984,
8863,
4297,
1057,
3891,
2396,
426,
13,
18884,
525,
7042,
2396,
525,
23973,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
4286,
4830,
10456,
16264,
29918,
2780,
511,
13,
18884,
525,
11466,
2396,
525,
29900,
1756,
7773,
4628,
742,
13,
18884,
525,
2780,
2396,
525,
11007,
2291,
3319,
29900,
29087,
29896,
29087,
29906,
1118,
29941,
29900,
29897,
4286,
4830,
10456,
726,
29918,
2780,
511,
13,
18884,
525,
1195,
29899,
2103,
2396,
525,
29896,
29900,
1756,
742,
13,
18884,
525,
12791,
2396,
525,
29896,
29900,
1756,
29871,
29906,
29900,
1756,
742,
13,
9651,
2981,
13,
9651,
525,
29984,
8863,
4297,
1057,
3891,
29901,
8391,
2396,
426,
13,
18884,
525,
2780,
2396,
525,
23973,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
4286,
4830,
10456,
726,
29918,
2780,
511,
13,
18884,
525,
7042,
2396,
525,
23973,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
4286,
4830,
29898,
13,
462,
1678,
334,
29963,
15580,
22107,
16854,
29889,
29933,
11375,
29954,
1672,
18783,
29918,
15032,
1955,
29889,
1767,
13,
18884,
10353,
13,
18884,
525,
11466,
29899,
3332,
2396,
525,
29896,
1756,
7773,
15552,
29890,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
29915,
13,
462,
795,
869,
4830,
10456,
4247,
16854,
29889,
6404,
3352,
29918,
29933,
22364,
29918,
15032,
1955,
29889,
1767,
511,
13,
9651,
2981,
13,
9651,
525,
29984,
8863,
4297,
1057,
3891,
29901,
13194,
2396,
426,
13,
18884,
525,
2780,
2396,
525,
23973,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
4286,
4830,
10456,
726,
29918,
2780,
511,
13,
18884,
525,
11466,
29899,
3332,
2396,
525,
29896,
1756,
7773,
15552,
29890,
3319,
29900,
29087,
29896,
29087,
29906,
1800,
29915,
13,
462,
795,
869,
4830,
10456,
4247,
16854,
29889,
6404,
3352,
29918,
29933,
22364,
29918,
15032,
1955,
29889,
1767,
511,
13,
9651,
500,
13,
4706,
500,
13,
4706,
11949,
4155,
353,
6629,
13,
4706,
363,
5997,
29918,
1990,
29892,
5997,
297,
3114,
29918,
8977,
29889,
7076,
7295,
13,
9651,
3114,
353,
525,
8875,
426,
741,
29876,
4286,
4830,
29898,
4268,
29918,
1990,
29897,
13,
9651,
363,
560,
29885,
29918,
978,
29892,
560,
29885,
29918,
791,
297,
5997,
29889,
7076,
7295,
13,
18884,
3114,
4619,
525,
29871,
426,
6177,
29912,
3400,
29905,
29876,
4286,
4830,
29898,
16422,
29918,
978,
29892,
560,
29885,
29918,
791,
29897,
13,
9651,
3114,
4619,
525,
1012,
29876,
29915,
13,
9651,
11949,
4155,
4619,
3114,
13,
4706,
1583,
29889,
842,
5568,
10654,
29898,
13558,
29897,
13,
13,
1678,
822,
788,
29918,
29894,
15580,
29898,
1311,
29892,
6316,
556,
29892,
1024,
29892,
2943,
29918,
333,
1125,
13,
4706,
1583,
29889,
1202,
8863,
29898,
29894,
15580,
29892,
1024,
29897,
13,
4706,
2380,
353,
1583,
29889,
19402,
29898,
29894,
15580,
29897,
13,
4706,
1583,
29889,
842,
8863,
12229,
29911,
666,
29898,
2248,
29892,
2943,
29918,
333,
29897,
13,
4706,
1583,
29889,
842,
7583,
3220,
29898,
2248,
29897,
13,
13,
1678,
822,
3349,
29918,
29894,
15580,
29898,
1311,
29892,
6316,
556,
1125,
13,
4706,
2380,
353,
1583,
29889,
19402,
29898,
29894,
15580,
29897,
13,
4706,
1583,
29889,
5992,
8863,
29898,
2248,
29897,
13,
13,
13,
1990,
3323,
9527,
8801,
29898,
17303,
8801,
29879,
29889,
29984,
8801,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3847,
29922,
8516,
29892,
3983,
29922,
8516,
1125,
13,
4706,
2428,
29898,
4035,
9527,
8801,
29892,
1583,
467,
1649,
2344,
12035,
3560,
29897,
13,
4706,
1583,
3032,
4262,
353,
3983,
13,
4706,
1583,
3032,
29876,
25521,
353,
9071,
20245,
8801,
580,
13,
4706,
1583,
3032,
2680,
353,
14705,
8801,
29879,
29889,
29984,
29963,
3313,
3453,
29898,
1311,
29897,
13,
4706,
1583,
3032,
2680,
29889,
842,
21002,
29924,
1191,
1144,
29898,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
13,
4706,
1583,
3032,
2680,
29889,
842,
5592,
9390,
29898,
29896,
29897,
13,
4706,
1583,
3032,
2680,
29889,
1202,
8801,
29898,
1311,
3032,
29876,
25521,
29897,
13,
13,
4706,
1583,
3032,
29894,
15580,
29918,
8030,
29879,
353,
6571,
13,
4706,
1583,
3032,
29894,
15580,
29918,
3784,
353,
6213,
13,
13,
1678,
732,
6799,
13,
1678,
822,
12402,
1061,
29898,
1311,
1125,
13,
4706,
736,
1583,
3032,
29876,
25521,
13,
13,
1678,
822,
788,
29918,
29894,
15580,
29898,
1311,
29892,
6316,
556,
29892,
1024,
29892,
2943,
29918,
333,
1125,
13,
4706,
565,
6316,
556,
297,
1583,
3032,
29894,
15580,
29918,
8030,
29879,
29901,
13,
9651,
736,
13,
13,
4706,
565,
1583,
3032,
29894,
15580,
29918,
3784,
29901,
13,
9651,
1583,
29889,
11458,
29918,
29894,
15580,
29898,
1311,
3032,
29894,
15580,
29918,
3784,
29897,
13,
13,
4706,
1583,
3032,
29876,
25521,
29889,
1202,
29918,
1643,
29918,
667,
29898,
978,
29892,
2943,
29918,
333,
29897,
13,
4706,
1583,
3032,
2680,
29889,
1202,
8801,
29898,
29894,
15580,
29897,
13,
4706,
1583,
3032,
29894,
15580,
29918,
8030,
29879,
29961,
29894,
15580,
29962,
353,
2943,
29918,
333,
13,
4706,
1583,
3032,
29894,
15580,
29918,
3784,
353,
6316,
556,
13,
4706,
1583,
3032,
29894,
15580,
29918,
3784,
29889,
4294,
580,
13,
13,
1678,
822,
3349,
29918,
29894,
15580,
29898,
1311,
29892,
6316,
556,
29922,
8516,
1125,
13,
4706,
565,
6316,
556,
338,
6213,
322,
1583,
3032,
29894,
15580,
29918,
3784,
29901,
13,
9651,
6316,
556,
353,
1583,
3032,
29894,
15580,
29918,
3784,
13,
4706,
2943,
29918,
333,
353,
1583,
3032,
29894,
15580,
29918,
8030,
29879,
29889,
7323,
29898,
29894,
15580,
29897,
13,
4706,
1583,
3032,
29876,
25521,
29889,
5992,
29918,
1643,
29918,
667,
29898,
3177,
29918,
333,
29897,
13,
4706,
1583,
3032,
2680,
29889,
5992,
8801,
29898,
29894,
15580,
29897,
13,
4706,
6316,
556,
29889,
8143,
29931,
1008,
580,
13,
13,
1678,
822,
9563,
29918,
29894,
15580,
29898,
1311,
29892,
6316,
556,
1125,
13,
4706,
1583,
3032,
2680,
29889,
5992,
8801,
29898,
29894,
15580,
29897,
13,
4706,
6316,
556,
29889,
11458,
580,
13,
13,
1678,
822,
1510,
29918,
29894,
15580,
29898,
1311,
29892,
6316,
556,
1125,
13,
4706,
565,
6316,
556,
1275,
1583,
3032,
29894,
15580,
29918,
3784,
29901,
13,
9651,
1583,
3032,
29894,
15580,
29918,
3784,
29889,
4294,
580,
13,
9651,
736,
13,
4706,
565,
6316,
556,
297,
1583,
3032,
29894,
15580,
29918,
8030,
29879,
29901,
13,
9651,
565,
1583,
3032,
29894,
15580,
29918,
3784,
29901,
13,
18884,
1583,
29889,
11458,
29918,
29894,
15580,
29898,
1311,
3032,
29894,
15580,
29918,
3784,
29897,
13,
9651,
1583,
3032,
2680,
29889,
1202,
8801,
29898,
29894,
15580,
29897,
13,
9651,
1583,
3032,
29894,
15580,
29918,
3784,
353,
6316,
556,
13,
9651,
1583,
3032,
29894,
15580,
29918,
3784,
29889,
4294,
580,
13,
2
] |
gs1/compress/extract_from_element_strings.py | TrustCodes/gs1-compression | 3 | 117321 | import re
import logging
import traceback
from gs1.utils import AI_BY_LENGTH
from gs1.constants import REGEX_ROUND_BRACKETS, REGEX_BRACKETED
from gs1.constants import AI_REGEX
from gs1.constants import FIXED_LENGTH_TABLE
logger = logging.getLogger('__name__')
def extract_from_element_strings(element_strings: str):
"""
Extract GS1 application identifier from element strings.
This method will convert either a bracketed element string or an unbracketed
element string into an associative array.
Input could be "(01)05412345000013(3103)000189(3923)2172(10)ABC123"
or "3103000189010541234500001339232172"+groupSeparator+"10ABC123"
"""
# remove symbology identifier if present
# remove ]C1 or ]e0 or ]d2 or ]Q3
element_strings = re.sub("^(]C1|]e0|]d2|]Q3)", '', element_strings)
if REGEX_ROUND_BRACKETS.match(element_strings):
ai_keys = AI_REGEX.keys()
obj = {}
k = ''
if REGEX_BRACKETED.match(element_strings):
results = re.findall(REGEX_BRACKETED, element_strings)
for i, result in enumerate(results):
if i % 2 == 0:
k = result[0]
elif k in ai_keys:
if AI_REGEX[k].match(result[1]):
obj[k] = result[1]
else:
logger.error('Stack trace:\n{}'.format(
traceback.format_exc()))
raise ValueError(
"SYNTAX ERROR: invalid syntax for value of (" +
k + ") : " + result[1])
return obj
else:
element_strings_length = len(element_strings)
fixed_length_identifiers = FIXED_LENGTH_TABLE.keys()
group_separator = chr(29)
cursor = 0
buffer = []
while cursor < element_strings_length:
first_two_digits = element_strings[cursor:cursor + 2]
if first_two_digits in fixed_length_identifiers:
# The first two digits are within the array of GS1
# Application Identifiers of defined fixed length
# extract the AI and value to the buffer
length = FIXED_LENGTH_TABLE.get(first_two_digits)
buffer.append(element_strings[cursor:cursor + length])
cursor += length
# If the next character is the group separator, move past
if element_strings[cursor] == group_separator:
cursor += 1
else:
# The first two digits are not within the array of GS1
# Application Identifiers of defined fixed length
# if string contains group separator
if group_separator in element_strings[cursor:]:
group_sep_loc = element_strings[cursor:].index(
group_separator)
buffer.append(element_strings[cursor:][0:group_sep_loc])
cursor += group_sep_loc
cursor += 1
else:
buffer.append(element_strings[cursor:])
cursor = element_strings_length
# Now process the buffer
obj = {}
matched = False
for buffer_item in buffer:
for k in [2, 3, 4]:
ai_candidate = buffer_item[0:k]
ai_sublist = [ai for ai in AI_BY_LENGTH if len(ai) == k]
if ai_candidate in ai_sublist:
obj[ai_candidate] = buffer_item[k:]
matched = True
if not matched:
logger.error('Stack trace:\n{}'.format(traceback.format_exc()))
raise ValueError("No matching GS1 AI found for " + buffer_item)
return obj
| [
1,
1053,
337,
13,
5215,
12183,
13,
5215,
9637,
1627,
13,
13,
3166,
330,
29879,
29896,
29889,
13239,
1053,
319,
29902,
29918,
22716,
29918,
19433,
13,
3166,
330,
29879,
29896,
29889,
3075,
1934,
1053,
5195,
1692,
29990,
29918,
1672,
18783,
29918,
15176,
11375,
2544,
29903,
29892,
5195,
1692,
29990,
29918,
15176,
11375,
2544,
3352,
13,
3166,
330,
29879,
29896,
29889,
3075,
1934,
1053,
319,
29902,
29918,
1525,
1692,
29990,
13,
3166,
330,
29879,
29896,
29889,
3075,
1934,
1053,
383,
6415,
3352,
29918,
19433,
29918,
21009,
13,
13,
21707,
353,
12183,
29889,
657,
16363,
877,
1649,
978,
1649,
1495,
13,
13,
13,
1753,
6597,
29918,
3166,
29918,
5029,
29918,
19651,
29898,
5029,
29918,
19651,
29901,
851,
1125,
13,
1678,
9995,
13,
1678,
7338,
1461,
402,
29903,
29896,
2280,
15882,
515,
1543,
6031,
29889,
13,
13,
1678,
910,
1158,
674,
3588,
2845,
263,
4105,
3522,
287,
1543,
1347,
470,
385,
443,
2634,
3522,
287,
13,
1678,
1543,
1347,
964,
385,
4067,
1230,
1409,
29889,
13,
13,
1678,
10567,
1033,
367,
18227,
29900,
29896,
29897,
29900,
29945,
29946,
29896,
29906,
29941,
29946,
29945,
29900,
29900,
29900,
29900,
29896,
29941,
29898,
29941,
29896,
29900,
29941,
29897,
29900,
29900,
29900,
29896,
29947,
29929,
29898,
29941,
29929,
29906,
29941,
29897,
29906,
29896,
29955,
29906,
29898,
29896,
29900,
29897,
19658,
29896,
29906,
29941,
29908,
13,
1678,
470,
376,
29941,
29896,
29900,
29941,
29900,
29900,
29900,
29896,
29947,
29929,
29900,
29896,
29900,
29945,
29946,
29896,
29906,
29941,
29946,
29945,
29900,
29900,
29900,
29900,
29896,
29941,
29941,
29929,
29906,
29941,
29906,
29896,
29955,
29906,
17969,
2972,
2008,
17954,
13578,
29896,
29900,
19658,
29896,
29906,
29941,
29908,
13,
1678,
9995,
13,
1678,
396,
3349,
5016,
29890,
3002,
15882,
565,
2198,
13,
1678,
396,
3349,
4514,
29907,
29896,
470,
4514,
29872,
29900,
470,
4514,
29881,
29906,
470,
4514,
29984,
29941,
13,
1678,
1543,
29918,
19651,
353,
337,
29889,
1491,
703,
23733,
29962,
29907,
29896,
29989,
29962,
29872,
29900,
29989,
29962,
29881,
29906,
29989,
29962,
29984,
29941,
19123,
15516,
1543,
29918,
19651,
29897,
13,
1678,
565,
5195,
1692,
29990,
29918,
1672,
18783,
29918,
15176,
11375,
2544,
29903,
29889,
4352,
29898,
5029,
29918,
19651,
1125,
13,
4706,
7468,
29918,
8149,
353,
319,
29902,
29918,
1525,
1692,
29990,
29889,
8149,
580,
13,
4706,
5446,
353,
6571,
13,
4706,
413,
353,
6629,
13,
4706,
565,
5195,
1692,
29990,
29918,
15176,
11375,
2544,
3352,
29889,
4352,
29898,
5029,
29918,
19651,
1125,
13,
9651,
2582,
353,
337,
29889,
2886,
497,
29898,
1525,
1692,
29990,
29918,
15176,
11375,
2544,
3352,
29892,
1543,
29918,
19651,
29897,
13,
9651,
363,
474,
29892,
1121,
297,
26985,
29898,
9902,
1125,
13,
18884,
565,
474,
1273,
29871,
29906,
1275,
29871,
29900,
29901,
13,
462,
1678,
413,
353,
1121,
29961,
29900,
29962,
13,
18884,
25342,
413,
297,
7468,
29918,
8149,
29901,
13,
462,
1678,
565,
319,
29902,
29918,
1525,
1692,
29990,
29961,
29895,
1822,
4352,
29898,
2914,
29961,
29896,
29962,
1125,
13,
462,
4706,
5446,
29961,
29895,
29962,
353,
1121,
29961,
29896,
29962,
13,
462,
1678,
1683,
29901,
13,
462,
4706,
17927,
29889,
2704,
877,
7264,
9637,
3583,
29876,
8875,
4286,
4830,
29898,
13,
462,
9651,
9637,
1627,
29889,
4830,
29918,
735,
29883,
22130,
13,
462,
4706,
12020,
7865,
2392,
29898,
13,
462,
9651,
376,
14816,
29940,
6040,
29990,
14431,
29901,
8340,
5877,
363,
995,
310,
4852,
718,
13,
462,
9651,
413,
718,
16521,
584,
376,
718,
1121,
29961,
29896,
2314,
13,
9651,
736,
5446,
13,
1678,
1683,
29901,
13,
4706,
1543,
29918,
19651,
29918,
2848,
353,
7431,
29898,
5029,
29918,
19651,
29897,
13,
4706,
4343,
29918,
2848,
29918,
1693,
14903,
353,
383,
6415,
3352,
29918,
19433,
29918,
21009,
29889,
8149,
580,
13,
4706,
2318,
29918,
344,
17954,
353,
18460,
29898,
29906,
29929,
29897,
13,
4706,
10677,
353,
29871,
29900,
13,
4706,
6835,
353,
5159,
13,
4706,
1550,
10677,
529,
1543,
29918,
19651,
29918,
2848,
29901,
13,
9651,
937,
29918,
10184,
29918,
7501,
1169,
353,
1543,
29918,
19651,
29961,
18127,
29901,
18127,
718,
29871,
29906,
29962,
13,
9651,
565,
937,
29918,
10184,
29918,
7501,
1169,
297,
4343,
29918,
2848,
29918,
1693,
14903,
29901,
13,
18884,
396,
450,
937,
1023,
13340,
526,
2629,
278,
1409,
310,
402,
29903,
29896,
13,
18884,
396,
8427,
13355,
14903,
310,
3342,
4343,
3309,
13,
18884,
396,
6597,
278,
319,
29902,
322,
995,
304,
278,
6835,
13,
18884,
3309,
353,
383,
6415,
3352,
29918,
19433,
29918,
21009,
29889,
657,
29898,
4102,
29918,
10184,
29918,
7501,
1169,
29897,
13,
18884,
6835,
29889,
4397,
29898,
5029,
29918,
19651,
29961,
18127,
29901,
18127,
718,
3309,
2314,
13,
18884,
10677,
4619,
3309,
13,
18884,
396,
960,
278,
2446,
2931,
338,
278,
2318,
28128,
29892,
4337,
4940,
13,
18884,
565,
1543,
29918,
19651,
29961,
18127,
29962,
1275,
2318,
29918,
344,
17954,
29901,
13,
462,
1678,
10677,
4619,
29871,
29896,
13,
9651,
1683,
29901,
13,
18884,
396,
450,
937,
1023,
13340,
526,
451,
2629,
278,
1409,
310,
402,
29903,
29896,
13,
18884,
396,
8427,
13355,
14903,
310,
3342,
4343,
3309,
13,
18884,
396,
565,
1347,
3743,
2318,
28128,
13,
18884,
565,
2318,
29918,
344,
17954,
297,
1543,
29918,
19651,
29961,
18127,
29901,
5387,
13,
462,
1678,
2318,
29918,
19570,
29918,
2029,
353,
1543,
29918,
19651,
29961,
18127,
29901,
1822,
2248,
29898,
13,
462,
4706,
2318,
29918,
344,
17954,
29897,
13,
462,
1678,
6835,
29889,
4397,
29898,
5029,
29918,
19651,
29961,
18127,
29901,
3816,
29900,
29901,
2972,
29918,
19570,
29918,
2029,
2314,
13,
462,
1678,
10677,
4619,
2318,
29918,
19570,
29918,
2029,
13,
462,
1678,
10677,
4619,
29871,
29896,
13,
18884,
1683,
29901,
13,
462,
1678,
6835,
29889,
4397,
29898,
5029,
29918,
19651,
29961,
18127,
29901,
2314,
13,
462,
1678,
10677,
353,
1543,
29918,
19651,
29918,
2848,
13,
4706,
396,
2567,
1889,
278,
6835,
13,
4706,
5446,
353,
6571,
13,
4706,
19228,
353,
7700,
13,
4706,
363,
6835,
29918,
667,
297,
6835,
29901,
13,
9651,
363,
413,
297,
518,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
5387,
13,
18884,
7468,
29918,
29883,
5380,
403,
353,
6835,
29918,
667,
29961,
29900,
29901,
29895,
29962,
13,
18884,
7468,
29918,
1491,
1761,
353,
518,
1794,
363,
7468,
297,
319,
29902,
29918,
22716,
29918,
19433,
565,
7431,
29898,
1794,
29897,
1275,
413,
29962,
13,
18884,
565,
7468,
29918,
29883,
5380,
403,
297,
7468,
29918,
1491,
1761,
29901,
13,
462,
1678,
5446,
29961,
1794,
29918,
29883,
5380,
403,
29962,
353,
6835,
29918,
667,
29961,
29895,
17531,
13,
462,
1678,
19228,
353,
5852,
13,
9651,
565,
451,
19228,
29901,
13,
18884,
17927,
29889,
2704,
877,
7264,
9637,
3583,
29876,
8875,
4286,
4830,
29898,
15003,
1627,
29889,
4830,
29918,
735,
29883,
22130,
13,
18884,
12020,
7865,
2392,
703,
3782,
9686,
402,
29903,
29896,
319,
29902,
1476,
363,
376,
718,
6835,
29918,
667,
29897,
13,
4706,
736,
5446,
13,
2
] |
Cartwheel/lib/Python26/Lib/site-packages/wx-2.8-msw-unicode/wx/lib/filebrowsebutton.py | MontyThibault/centre-of-mass-awareness | 27 | 8902 | #----------------------------------------------------------------------
# Name: wxPython.lib.filebrowsebutton
# Purpose: Composite controls that provide a Browse button next to
# either a wxTextCtrl or a wxComboBox. The Browse button
# launches a wxFileDialog and loads the result into the
# other control.
#
# Author: <NAME>
#
# RCS-ID: $Id: filebrowsebutton.py 59674 2009-03-20 21:00:16Z RD $
# Copyright: (c) 2000 by Total Control Software
# Licence: wxWindows license
#----------------------------------------------------------------------
# 12/02/2003 - <NAME> (<EMAIL>)
#
# o 2.5 Compatability changes
#
import os
import types
import wx
#----------------------------------------------------------------------
class FileBrowseButton(wx.Panel):
"""
A control to allow the user to type in a filename or browse with
the standard file dialog to select file
"""
def __init__ (self, parent, id= -1,
pos = wx.DefaultPosition,
size = wx.DefaultSize,
style = wx.TAB_TRAVERSAL,
labelText= "File Entry:",
buttonText= "Browse",
toolTip= "Type filename or click browse to choose file",
# following are the values for a file dialog box
dialogTitle = "Choose a file",
startDirectory = ".",
initialValue = "",
fileMask = "*.*",
fileMode = wx.OPEN,
# callback for when value changes (optional)
changeCallback= lambda x:x,
labelWidth = 0,
name = 'fileBrowseButton',
):
"""
:param labelText: Text for label to left of text field
:param buttonText: Text for button which launches the file dialog
:param toolTip: Help text
:param dialogTitle: Title used in file dialog
:param startDirectory: Default directory for file dialog startup
:param fileMask: File mask (glob pattern, such as *.*) to use in file dialog
:param fileMode: wx.OPEN or wx.SAVE, indicates type of file dialog to use
:param changeCallback: Optional callback called for all changes in value of the control
:param labelWidth: Width of the label
"""
# store variables
self.labelText = labelText
self.buttonText = buttonText
self.toolTip = toolTip
self.dialogTitle = dialogTitle
self.startDirectory = startDirectory
self.initialValue = initialValue
self.fileMask = fileMask
self.fileMode = fileMode
self.changeCallback = changeCallback
self.callCallback = True
self.labelWidth = labelWidth
# create the dialog
self.createDialog(parent, id, pos, size, style, name )
# Setting a value causes the changeCallback to be called.
# In this case that would be before the return of the
# constructor. Not good. So a default value on
# SetValue is used to disable the callback
self.SetValue( initialValue, 0)
def createDialog( self, parent, id, pos, size, style, name ):
"""Setup the graphic representation of the dialog"""
wx.Panel.__init__ (self, parent, id, pos, size, style, name)
self.SetMinSize(size) # play nice with sizers
box = wx.BoxSizer(wx.HORIZONTAL)
self.label = self.createLabel( )
box.Add( self.label, 0, wx.CENTER )
self.textControl = self.createTextControl()
box.Add( self.textControl, 1, wx.LEFT|wx.CENTER, 5)
self.browseButton = self.createBrowseButton()
box.Add( self.browseButton, 0, wx.LEFT|wx.CENTER, 5)
# add a border around the whole thing and resize the panel to fit
outsidebox = wx.BoxSizer(wx.VERTICAL)
outsidebox.Add(box, 1, wx.EXPAND|wx.ALL, 3)
outsidebox.Fit(self)
self.SetAutoLayout(True)
self.SetSizer( outsidebox )
self.Layout()
if type( size ) == types.TupleType:
size = apply( wx.Size, size)
self.SetDimensions(-1, -1, size.width, size.height, wx.SIZE_USE_EXISTING)
# if size.width != -1 or size.height != -1:
# self.SetSize(size)
def SetBackgroundColour(self,color):
wx.Panel.SetBackgroundColour(self,color)
self.label.SetBackgroundColour(color)
def createLabel( self ):
"""Create the label/caption"""
label = wx.StaticText(self, -1, self.labelText, style =wx.ALIGN_RIGHT )
font = label.GetFont()
w, h, d, e = self.GetFullTextExtent(self.labelText, font)
if self.labelWidth > 0:
label.SetSize((self.labelWidth+5, h))
else:
label.SetSize((w+5, h))
return label
def createTextControl( self):
"""Create the text control"""
textControl = wx.TextCtrl(self, -1)
textControl.SetToolTipString( self.toolTip )
if self.changeCallback:
textControl.Bind(wx.EVT_TEXT, self.OnChanged)
textControl.Bind(wx.EVT_COMBOBOX, self.OnChanged)
return textControl
def OnChanged(self, evt):
if self.callCallback and self.changeCallback:
self.changeCallback(evt)
def createBrowseButton( self):
"""Create the browse-button control"""
button =wx.Button(self, -1, self.buttonText)
button.SetToolTipString( self.toolTip )
button.Bind(wx.EVT_BUTTON, self.OnBrowse)
return button
def OnBrowse (self, event = None):
""" Going to browse for file... """
current = self.GetValue()
directory = os.path.split(current)
if os.path.isdir( current):
directory = current
current = ''
elif directory and os.path.isdir( directory[0] ):
current = directory[1]
directory = directory [0]
else:
directory = self.startDirectory
current = ''
dlg = wx.FileDialog(self, self.dialogTitle, directory, current,
self.fileMask, self.fileMode)
if dlg.ShowModal() == wx.ID_OK:
self.SetValue(dlg.GetPath())
dlg.Destroy()
def GetValue (self):
"""
retrieve current value of text control
"""
return self.textControl.GetValue()
def SetValue (self, value, callBack=1):
"""set current value of text control"""
save = self.callCallback
self.callCallback = callBack
self.textControl.SetValue(value)
self.callCallback = save
def Enable (self, value=True):
""" Convenient enabling/disabling of entire control """
self.label.Enable (value)
self.textControl.Enable (value)
return self.browseButton.Enable (value)
def Disable (self,):
""" Convenient disabling of entire control """
self.Enable(False)
def GetLabel( self ):
""" Retrieve the label's current text """
return self.label.GetLabel()
def SetLabel( self, value ):
""" Set the label's current text """
rvalue = self.label.SetLabel( value )
self.Refresh( True )
return rvalue
class FileBrowseButtonWithHistory( FileBrowseButton ):
"""
with following additions:
__init__(..., history=None)
history -- optional list of paths for initial history drop-down
(must be passed by name, not a positional argument)
If history is callable it will must return a list used
for the history drop-down
changeCallback -- as for FileBrowseButton, but with a work-around
for win32 systems which don't appear to create wx.EVT_COMBOBOX
events properly. There is a (slight) chance that this work-around
will cause some systems to create two events for each Combobox
selection. If you discover this condition, please report it!
As for a FileBrowseButton.__init__ otherwise.
GetHistoryControl()
Return reference to the control which implements interfaces
required for manipulating the history list. See GetHistoryControl
documentation for description of what that interface is.
GetHistory()
Return current history list
SetHistory( value=(), selectionIndex = None )
Set current history list, if selectionIndex is not None, select that index
"""
def __init__( self, *arguments, **namedarguments):
self.history = namedarguments.get( "history" )
if self.history:
del namedarguments["history"]
self.historyCallBack=None
if callable(self.history):
self.historyCallBack=self.history
self.history=None
name = namedarguments.get('name', 'fileBrowseButtonWithHistory')
namedarguments['name'] = name
FileBrowseButton.__init__(self, *arguments, **namedarguments)
def createTextControl( self):
"""Create the text control"""
textControl = wx.ComboBox(self, -1, style = wx.CB_DROPDOWN )
textControl.SetToolTipString( self.toolTip )
textControl.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
if self.changeCallback:
textControl.Bind(wx.EVT_TEXT, self.OnChanged)
textControl.Bind(wx.EVT_COMBOBOX, self.OnChanged)
if self.history:
history=self.history
self.history=None
self.SetHistory( history, control=textControl)
return textControl
def GetHistoryControl( self ):
"""
Return a pointer to the control which provides (at least)
the following methods for manipulating the history list:
Append( item ) -- add item
Clear() -- clear all items
Delete( index ) -- 0-based index to delete from list
SetSelection( index ) -- 0-based index to select in list
Semantics of the methods follow those for the wxComboBox control
"""
return self.textControl
def SetHistory( self, value=(), selectionIndex = None, control=None ):
"""Set the current history list"""
if control is None:
control = self.GetHistoryControl()
if self.history == value:
return
self.history = value
# Clear history values not the selected one.
tempValue=control.GetValue()
# clear previous values
control.Clear()
control.SetValue(tempValue)
# walk through, appending new values
for path in value:
control.Append( path )
if selectionIndex is not None:
control.SetSelection( selectionIndex )
def GetHistory( self ):
"""Return the current history list"""
if self.historyCallBack != None:
return self.historyCallBack()
elif self.history:
return list( self.history )
else:
return []
def OnSetFocus(self, event):
"""When the history scroll is selected, update the history"""
if self.historyCallBack != None:
self.SetHistory( self.historyCallBack(), control=self.textControl)
event.Skip()
if wx.Platform == "__WXMSW__":
def SetValue (self, value, callBack=1):
""" Convenient setting of text control value, works
around limitation of wx.ComboBox """
save = self.callCallback
self.callCallback = callBack
self.textControl.SetValue(value)
self.callCallback = save
# Hack to call an event handler
class LocalEvent:
def __init__(self, string):
self._string=string
def GetString(self):
return self._string
if callBack==1:
# The callback wasn't being called when SetValue was used ??
# So added this explicit call to it
self.changeCallback(LocalEvent(value))
class DirBrowseButton(FileBrowseButton):
def __init__(self, parent, id = -1,
pos = wx.DefaultPosition, size = wx.DefaultSize,
style = wx.TAB_TRAVERSAL,
labelText = 'Select a directory:',
buttonText = 'Browse',
toolTip = 'Type directory name or browse to select',
dialogTitle = '',
startDirectory = '.',
changeCallback = None,
dialogClass = wx.DirDialog,
newDirectory = False,
name = 'dirBrowseButton'):
FileBrowseButton.__init__(self, parent, id, pos, size, style,
labelText, buttonText, toolTip,
dialogTitle, startDirectory,
changeCallback = changeCallback,
name = name)
self.dialogClass = dialogClass
self.newDirectory = newDirectory
#
def OnBrowse(self, ev = None):
style=0
if not self.newDirectory:
style |= wx.DD_DIR_MUST_EXIST
dialog = self.dialogClass(self,
message = self.dialogTitle,
defaultPath = self.startDirectory,
style = style)
if dialog.ShowModal() == wx.ID_OK:
self.SetValue(dialog.GetPath())
dialog.Destroy()
#
#----------------------------------------------------------------------
if __name__ == "__main__":
#from skeletonbuilder import rulesfile
class SimpleCallback:
def __init__( self, tag ):
self.tag = tag
def __call__( self, event ):
print self.tag, event.GetString()
class DemoFrame( wx.Frame ):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "File entry with browse", size=(500,260))
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
panel = wx.Panel (self,-1)
innerbox = wx.BoxSizer(wx.VERTICAL)
control = FileBrowseButton(
panel,
initialValue = "z:\\temp",
)
innerbox.Add( control, 0, wx.EXPAND )
middlecontrol = FileBrowseButtonWithHistory(
panel,
labelText = "With History",
initialValue = "d:\\temp",
history = ["c:\\temp", "c:\\tmp", "r:\\temp","z:\\temp"],
changeCallback= SimpleCallback( "With History" ),
)
innerbox.Add( middlecontrol, 0, wx.EXPAND )
middlecontrol = FileBrowseButtonWithHistory(
panel,
labelText = "History callback",
initialValue = "d:\\temp",
history = self.historyCallBack,
changeCallback= SimpleCallback( "History callback" ),
)
innerbox.Add( middlecontrol, 0, wx.EXPAND )
self.bottomcontrol = control = FileBrowseButton(
panel,
labelText = "With Callback",
style = wx.SUNKEN_BORDER|wx.CLIP_CHILDREN ,
changeCallback= SimpleCallback( "With Callback" ),
)
innerbox.Add( control, 0, wx.EXPAND)
self.bottommostcontrol = control = DirBrowseButton(
panel,
labelText = "Simple dir browse button",
style = wx.SUNKEN_BORDER|wx.CLIP_CHILDREN)
innerbox.Add( control, 0, wx.EXPAND)
ID = wx.NewId()
innerbox.Add( wx.Button( panel, ID,"Change Label", ), 1, wx.EXPAND)
self.Bind(wx.EVT_BUTTON, self.OnChangeLabel , id=ID)
ID = wx.NewId()
innerbox.Add( wx.Button( panel, ID,"Change Value", ), 1, wx.EXPAND)
self.Bind(wx.EVT_BUTTON, self.OnChangeValue, id=ID )
panel.SetAutoLayout(True)
panel.SetSizer( innerbox )
self.history={"c:\\temp":1, "c:\\tmp":1, "r:\\temp":1,"z:\\temp":1}
def historyCallBack(self):
keys=self.history.keys()
keys.sort()
return keys
def OnFileNameChangedHistory (self, event):
self.history[event.GetString ()]=1
def OnCloseMe(self, event):
self.Close(True)
def OnChangeLabel( self, event ):
self.bottomcontrol.SetLabel( "Label Updated" )
def OnChangeValue( self, event ):
self.bottomcontrol.SetValue( "r:\\somewhere\\over\\the\\rainbow.htm" )
def OnCloseWindow(self, event):
self.Destroy()
class DemoApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
frame = DemoFrame(None)
frame.Show(True)
self.SetTopWindow(frame)
return True
def test( ):
app = DemoApp(0)
app.MainLoop()
print 'Creating dialog'
test( )
| [
1,
396,
2683,
2683,
2683,
2683,
22158,
13,
29937,
4408,
29901,
4706,
26437,
11980,
29889,
1982,
29889,
1445,
23721,
344,
3092,
13,
29937,
15247,
4220,
29901,
268,
24497,
568,
11761,
393,
3867,
263,
22415,
344,
2826,
2446,
304,
13,
29937,
795,
2845,
263,
26437,
1626,
18069,
470,
263,
26437,
26628,
29889,
29871,
450,
22415,
344,
2826,
13,
29937,
795,
6826,
267,
263,
26437,
2283,
7647,
322,
15376,
278,
1121,
964,
278,
13,
29937,
795,
916,
2761,
29889,
13,
29937,
13,
29937,
13361,
29901,
418,
529,
5813,
29958,
13,
29937,
13,
29937,
390,
9295,
29899,
1367,
29901,
418,
395,
1204,
29901,
934,
23721,
344,
3092,
29889,
2272,
29871,
29945,
29929,
29953,
29955,
29946,
29871,
29906,
29900,
29900,
29929,
29899,
29900,
29941,
29899,
29906,
29900,
29871,
29906,
29896,
29901,
29900,
29900,
29901,
29896,
29953,
29999,
390,
29928,
395,
13,
29937,
14187,
1266,
29901,
259,
313,
29883,
29897,
29871,
29906,
29900,
29900,
29900,
491,
14990,
11264,
18540,
13,
29937,
10413,
663,
29901,
268,
26437,
7685,
19405,
13,
29937,
2683,
2683,
2683,
2683,
22158,
13,
29937,
29871,
29896,
29906,
29914,
29900,
29906,
29914,
29906,
29900,
29900,
29941,
448,
529,
5813,
29958,
313,
29966,
26862,
6227,
12948,
13,
29937,
13,
29937,
288,
29871,
29906,
29889,
29945,
3831,
271,
3097,
3620,
13,
29937,
13,
13,
5215,
29871,
2897,
13,
5215,
29871,
4072,
13,
13,
5215,
29871,
26437,
13,
13,
29937,
2683,
2683,
2683,
2683,
22158,
13,
13,
1990,
3497,
29933,
798,
344,
3125,
29898,
23310,
29889,
7490,
1125,
13,
1678,
9995,
13,
1678,
319,
2761,
304,
2758,
278,
1404,
304,
1134,
297,
263,
10422,
470,
3347,
344,
411,
13,
1678,
278,
3918,
934,
7928,
304,
1831,
934,
13,
1678,
9995,
13,
1678,
822,
4770,
2344,
1649,
313,
1311,
29892,
3847,
29892,
1178,
29922,
448,
29896,
29892,
13,
462,
29871,
926,
353,
26437,
29889,
4592,
8003,
29892,
13,
462,
29871,
2159,
353,
26437,
29889,
4592,
3505,
29892,
13,
462,
29871,
3114,
353,
26437,
29889,
29911,
2882,
29918,
29911,
4717,
5348,
29903,
1964,
29892,
13,
462,
29871,
3858,
1626,
29922,
376,
2283,
28236,
29901,
613,
13,
462,
29871,
2826,
1626,
29922,
376,
29933,
798,
344,
613,
13,
462,
29871,
5780,
29911,
666,
29922,
376,
1542,
10422,
470,
2828,
3347,
344,
304,
6755,
934,
613,
13,
462,
29871,
396,
1494,
526,
278,
1819,
363,
263,
934,
7928,
3800,
13,
462,
29871,
7928,
7030,
353,
376,
15954,
852,
263,
934,
613,
13,
462,
29871,
1369,
9882,
353,
11393,
613,
13,
462,
29871,
2847,
1917,
353,
12633,
13,
462,
29871,
934,
19832,
353,
26345,
5575,
613,
13,
462,
29871,
934,
6818,
353,
26437,
29889,
4590,
1430,
29892,
13,
462,
29871,
396,
6939,
363,
746,
995,
3620,
313,
25253,
29897,
13,
462,
29871,
1735,
10717,
29922,
14013,
921,
29901,
29916,
29892,
13,
462,
29871,
3858,
6110,
353,
29871,
29900,
29892,
13,
462,
29871,
1024,
353,
525,
1445,
29933,
798,
344,
3125,
742,
13,
308,
1125,
13,
4706,
9995,
13,
4706,
584,
3207,
3858,
1626,
29901,
418,
3992,
363,
3858,
304,
2175,
310,
1426,
1746,
13,
4706,
584,
3207,
2826,
1626,
29901,
268,
3992,
363,
2826,
607,
6826,
267,
278,
934,
7928,
13,
4706,
584,
3207,
5780,
29911,
666,
29901,
4706,
22305,
1426,
13,
4706,
584,
3207,
7928,
7030,
29901,
1678,
18527,
1304,
297,
934,
7928,
13,
4706,
584,
3207,
1369,
9882,
29901,
13109,
3884,
363,
934,
7928,
20234,
13,
4706,
584,
3207,
934,
19832,
29901,
539,
3497,
11105,
313,
23705,
4766,
29892,
1316,
408,
334,
5575,
29897,
304,
671,
297,
934,
7928,
13,
4706,
584,
3207,
934,
6818,
29901,
539,
26437,
29889,
4590,
1430,
470,
26437,
29889,
29903,
7520,
29923,
29892,
14088,
1134,
310,
934,
7928,
304,
671,
13,
4706,
584,
3207,
1735,
10717,
29901,
28379,
6939,
2000,
363,
599,
3620,
297,
995,
310,
278,
2761,
13,
4706,
584,
3207,
3858,
6110,
29901,
268,
21485,
310,
278,
3858,
13,
4706,
9995,
13,
539,
13,
4706,
396,
3787,
3651,
13,
4706,
1583,
29889,
1643,
1626,
353,
3858,
1626,
13,
4706,
1583,
29889,
3092,
1626,
353,
2826,
1626,
13,
4706,
1583,
29889,
10154,
29911,
666,
353,
5780,
29911,
666,
13,
4706,
1583,
29889,
15901,
7030,
353,
7928,
7030,
13,
4706,
1583,
29889,
2962,
9882,
353,
1369,
9882,
13,
4706,
1583,
29889,
11228,
1917,
353,
2847,
1917,
13,
4706,
1583,
29889,
1445,
19832,
353,
934,
19832,
13,
4706,
1583,
29889,
1445,
6818,
353,
934,
6818,
13,
4706,
1583,
29889,
3167,
10717,
353,
1735,
10717,
13,
4706,
1583,
29889,
4804,
10717,
353,
5852,
13,
4706,
1583,
29889,
1643,
6110,
353,
3858,
6110,
13,
13,
4706,
396,
1653,
278,
7928,
13,
4706,
1583,
29889,
3258,
7647,
29898,
3560,
29892,
1178,
29892,
926,
29892,
2159,
29892,
3114,
29892,
1024,
1723,
13,
4706,
396,
21605,
263,
995,
9946,
278,
1735,
10717,
304,
367,
2000,
29889,
13,
4706,
396,
512,
445,
1206,
393,
723,
367,
1434,
278,
736,
310,
278,
13,
4706,
396,
5823,
29889,
2216,
1781,
29889,
1105,
263,
2322,
995,
373,
13,
4706,
396,
3789,
1917,
338,
1304,
304,
11262,
278,
6939,
13,
4706,
1583,
29889,
2697,
1917,
29898,
2847,
1917,
29892,
29871,
29900,
29897,
13,
13,
13,
1678,
822,
1653,
7647,
29898,
1583,
29892,
3847,
29892,
1178,
29892,
926,
29892,
2159,
29892,
3114,
29892,
1024,
29871,
1125,
13,
4706,
9995,
26947,
278,
3983,
293,
8954,
310,
278,
7928,
15945,
29908,
13,
4706,
26437,
29889,
7490,
17255,
2344,
1649,
313,
1311,
29892,
3847,
29892,
1178,
29892,
926,
29892,
2159,
29892,
3114,
29892,
1024,
29897,
13,
4706,
1583,
29889,
2697,
8140,
3505,
29898,
2311,
29897,
396,
1708,
7575,
411,
269,
19427,
13,
13,
4706,
3800,
353,
26437,
29889,
3313,
29903,
3950,
29898,
23310,
29889,
29950,
1955,
26664,
1164,
29911,
1964,
29897,
13,
13,
4706,
1583,
29889,
1643,
353,
1583,
29889,
3258,
4775,
29898,
1723,
13,
4706,
3800,
29889,
2528,
29898,
1583,
29889,
1643,
29892,
29871,
29900,
29892,
26437,
29889,
29907,
3919,
1001,
1723,
13,
13,
4706,
1583,
29889,
726,
4809,
353,
1583,
29889,
3258,
1626,
4809,
580,
13,
4706,
3800,
29889,
2528,
29898,
1583,
29889,
726,
4809,
29892,
29871,
29896,
29892,
26437,
29889,
28024,
29989,
23310,
29889,
29907,
3919,
1001,
29892,
29871,
29945,
29897,
13,
13,
4706,
1583,
29889,
23721,
344,
3125,
353,
1583,
29889,
3258,
29933,
798,
344,
3125,
580,
13,
4706,
3800,
29889,
2528,
29898,
1583,
29889,
23721,
344,
3125,
29892,
29871,
29900,
29892,
26437,
29889,
28024,
29989,
23310,
29889,
29907,
3919,
1001,
29892,
29871,
29945,
29897,
13,
13,
4706,
396,
788,
263,
5139,
2820,
278,
3353,
2655,
322,
19490,
278,
9451,
304,
6216,
13,
4706,
5377,
1884,
353,
26437,
29889,
3313,
29903,
3950,
29898,
23310,
29889,
5348,
29911,
2965,
1964,
29897,
13,
4706,
5377,
1884,
29889,
2528,
29898,
1884,
29892,
29871,
29896,
29892,
26437,
29889,
5746,
29925,
9468,
29989,
23310,
29889,
9818,
29892,
29871,
29941,
29897,
13,
4706,
5377,
1884,
29889,
29943,
277,
29898,
1311,
29897,
13,
13,
4706,
1583,
29889,
2697,
12300,
3453,
29898,
5574,
29897,
13,
4706,
1583,
29889,
2697,
29903,
3950,
29898,
5377,
1884,
1723,
13,
4706,
1583,
29889,
3453,
580,
13,
4706,
565,
1134,
29898,
2159,
1723,
1275,
4072,
29889,
23215,
552,
1542,
29901,
13,
9651,
2159,
353,
3394,
29898,
26437,
29889,
3505,
29892,
2159,
29897,
13,
4706,
1583,
29889,
2697,
16142,
5580,
6278,
29896,
29892,
448,
29896,
29892,
2159,
29889,
2103,
29892,
2159,
29889,
3545,
29892,
26437,
29889,
14226,
29918,
17171,
29918,
5746,
9047,
4214,
29897,
13,
13,
29937,
4706,
565,
2159,
29889,
2103,
2804,
448,
29896,
470,
2159,
29889,
3545,
2804,
448,
29896,
29901,
13,
29937,
9651,
1583,
29889,
2697,
3505,
29898,
2311,
29897,
13,
13,
1678,
822,
3789,
10581,
1625,
473,
29898,
1311,
29892,
2780,
1125,
13,
4706,
26437,
29889,
7490,
29889,
2697,
10581,
1625,
473,
29898,
1311,
29892,
2780,
29897,
13,
4706,
1583,
29889,
1643,
29889,
2697,
10581,
1625,
473,
29898,
2780,
29897,
13,
13,
1678,
822,
1653,
4775,
29898,
1583,
29871,
1125,
13,
4706,
9995,
4391,
278,
3858,
29914,
6671,
15945,
29908,
13,
4706,
3858,
353,
26437,
29889,
17046,
1626,
29898,
1311,
29892,
448,
29896,
29892,
1583,
29889,
1643,
1626,
29892,
3114,
353,
23310,
29889,
1964,
17298,
29918,
22789,
3912,
1723,
13,
4706,
4079,
353,
3858,
29889,
2577,
9824,
580,
13,
4706,
281,
29892,
298,
29892,
270,
29892,
321,
353,
1583,
29889,
2577,
13658,
1626,
5647,
296,
29898,
1311,
29889,
1643,
1626,
29892,
4079,
29897,
13,
4706,
565,
1583,
29889,
1643,
6110,
1405,
29871,
29900,
29901,
13,
9651,
3858,
29889,
2697,
3505,
3552,
1311,
29889,
1643,
6110,
29974,
29945,
29892,
298,
876,
13,
4706,
1683,
29901,
13,
9651,
3858,
29889,
2697,
3505,
3552,
29893,
29974,
29945,
29892,
298,
876,
13,
4706,
736,
3858,
13,
13,
1678,
822,
1653,
1626,
4809,
29898,
1583,
1125,
13,
4706,
9995,
4391,
278,
1426,
2761,
15945,
29908,
13,
4706,
1426,
4809,
353,
26437,
29889,
1626,
18069,
29898,
1311,
29892,
448,
29896,
29897,
13,
4706,
1426,
4809,
29889,
2697,
12229,
29911,
666,
1231,
29898,
1583,
29889,
10154,
29911,
666,
1723,
13,
4706,
565,
1583,
29889,
3167,
10717,
29901,
13,
9651,
1426,
4809,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
16975,
29892,
1583,
29889,
2951,
7590,
29897,
13,
9651,
1426,
4809,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
19795,
8456,
8456,
29990,
29892,
1583,
29889,
2951,
7590,
29897,
13,
4706,
736,
1426,
4809,
13,
13,
1678,
822,
1551,
7590,
29898,
1311,
29892,
3415,
29873,
1125,
13,
4706,
565,
1583,
29889,
4804,
10717,
322,
1583,
29889,
3167,
10717,
29901,
13,
9651,
1583,
29889,
3167,
10717,
29898,
5750,
29873,
29897,
13,
13,
1678,
822,
1653,
29933,
798,
344,
3125,
29898,
1583,
1125,
13,
4706,
9995,
4391,
278,
3347,
344,
29899,
3092,
2761,
15945,
29908,
13,
4706,
2826,
353,
23310,
29889,
3125,
29898,
1311,
29892,
448,
29896,
29892,
1583,
29889,
3092,
1626,
29897,
13,
4706,
2826,
29889,
2697,
12229,
29911,
666,
1231,
29898,
1583,
29889,
10154,
29911,
666,
1723,
13,
4706,
2826,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
29933,
2692,
29911,
1164,
29892,
1583,
29889,
2951,
29933,
798,
344,
29897,
13,
4706,
736,
2826,
13,
13,
13,
1678,
822,
1551,
29933,
798,
344,
313,
1311,
29892,
1741,
353,
6213,
1125,
13,
4706,
9995,
2921,
292,
304,
3347,
344,
363,
934,
856,
9995,
13,
4706,
1857,
353,
1583,
29889,
2577,
1917,
580,
13,
4706,
3884,
353,
2897,
29889,
2084,
29889,
5451,
29898,
3784,
29897,
13,
4706,
565,
2897,
29889,
2084,
29889,
275,
3972,
29898,
1857,
1125,
13,
9651,
3884,
353,
1857,
13,
9651,
1857,
353,
6629,
13,
4706,
25342,
3884,
322,
2897,
29889,
2084,
29889,
275,
3972,
29898,
3884,
29961,
29900,
29962,
29871,
1125,
13,
9651,
1857,
353,
3884,
29961,
29896,
29962,
13,
9651,
3884,
353,
3884,
518,
29900,
29962,
13,
4706,
1683,
29901,
13,
9651,
3884,
353,
1583,
29889,
2962,
9882,
13,
9651,
1857,
353,
6629,
13,
4706,
270,
19920,
353,
26437,
29889,
2283,
7647,
29898,
1311,
29892,
1583,
29889,
15901,
7030,
29892,
3884,
29892,
1857,
29892,
13,
462,
9651,
1583,
29889,
1445,
19832,
29892,
1583,
29889,
1445,
6818,
29897,
13,
13,
4706,
565,
270,
19920,
29889,
8964,
19751,
580,
1275,
26437,
29889,
1367,
29918,
8949,
29901,
13,
9651,
1583,
29889,
2697,
1917,
29898,
11671,
29887,
29889,
2577,
2605,
3101,
13,
4706,
270,
19920,
29889,
14994,
4727,
580,
13,
13,
13,
1678,
822,
3617,
1917,
313,
1311,
1125,
13,
4706,
9995,
13,
4706,
10563,
1857,
995,
310,
1426,
2761,
13,
4706,
9995,
13,
4706,
736,
1583,
29889,
726,
4809,
29889,
2577,
1917,
580,
13,
13,
1678,
822,
3789,
1917,
313,
1311,
29892,
995,
29892,
1246,
5841,
29922,
29896,
1125,
13,
4706,
9995,
842,
1857,
995,
310,
1426,
2761,
15945,
29908,
13,
4706,
4078,
353,
1583,
29889,
4804,
10717,
13,
4706,
1583,
29889,
4804,
10717,
353,
1246,
5841,
13,
4706,
1583,
29889,
726,
4809,
29889,
2697,
1917,
29898,
1767,
29897,
13,
4706,
1583,
29889,
4804,
10717,
353,
29871,
4078,
13,
13,
13,
1678,
822,
1174,
519,
313,
1311,
29892,
995,
29922,
5574,
1125,
13,
4706,
9995,
1281,
854,
993,
427,
17961,
29914,
2218,
17961,
310,
4152,
2761,
9995,
13,
4706,
1583,
29889,
1643,
29889,
20701,
313,
1767,
29897,
13,
4706,
1583,
29889,
726,
4809,
29889,
20701,
313,
1767,
29897,
13,
4706,
736,
1583,
29889,
23721,
344,
3125,
29889,
20701,
313,
1767,
29897,
13,
13,
1678,
822,
3295,
519,
313,
1311,
29892,
1125,
13,
4706,
9995,
1281,
854,
993,
766,
17961,
310,
4152,
2761,
9995,
13,
4706,
1583,
29889,
20701,
29898,
8824,
29897,
13,
13,
1678,
822,
3617,
4775,
29898,
1583,
29871,
1125,
13,
4706,
9995,
4649,
29878,
2418,
278,
3858,
29915,
29879,
1857,
1426,
9995,
13,
4706,
736,
1583,
29889,
1643,
29889,
2577,
4775,
580,
13,
13,
1678,
822,
3789,
4775,
29898,
1583,
29892,
995,
29871,
1125,
13,
4706,
9995,
3789,
278,
3858,
29915,
29879,
1857,
1426,
9995,
13,
4706,
364,
1767,
353,
1583,
29889,
1643,
29889,
2697,
4775,
29898,
995,
1723,
13,
4706,
1583,
29889,
27132,
29898,
5852,
1723,
13,
4706,
736,
364,
1767,
13,
13,
13,
13,
13,
1990,
3497,
29933,
798,
344,
3125,
3047,
20570,
29898,
3497,
29933,
798,
344,
3125,
29871,
1125,
13,
1678,
9995,
13,
1678,
411,
1494,
788,
2187,
29901,
13,
4706,
4770,
2344,
12035,
16361,
4955,
29922,
8516,
29897,
13,
13,
9651,
4955,
1192,
13136,
1051,
310,
10898,
363,
2847,
4955,
5768,
29899,
3204,
13,
18884,
313,
21969,
367,
4502,
491,
1024,
29892,
451,
263,
2602,
284,
2980,
29897,
13,
18884,
960,
4955,
338,
1246,
519,
372,
674,
1818,
736,
263,
1051,
1304,
13,
18884,
363,
278,
4955,
5768,
29899,
3204,
13,
13,
9651,
1735,
10717,
1192,
408,
363,
3497,
29933,
798,
344,
3125,
29892,
541,
411,
263,
664,
29899,
11316,
13,
18884,
363,
5401,
29941,
29906,
6757,
607,
1016,
29915,
29873,
2615,
304,
1653,
26437,
29889,
22240,
29911,
29918,
19795,
8456,
8456,
29990,
13,
18884,
4959,
6284,
29889,
29871,
1670,
338,
263,
313,
2536,
523,
29897,
8825,
393,
445,
664,
29899,
11316,
13,
18884,
674,
4556,
777,
6757,
304,
1653,
1023,
4959,
363,
1269,
422,
29890,
23518,
13,
18884,
9262,
29889,
960,
366,
6523,
445,
4195,
29892,
3113,
3461,
372,
29991,
13,
13,
9651,
1094,
363,
263,
3497,
29933,
798,
344,
3125,
17255,
2344,
1649,
6467,
29889,
13,
632,
13,
4706,
3617,
20570,
4809,
580,
13,
9651,
7106,
3407,
304,
278,
2761,
607,
10703,
19510,
13,
9651,
3734,
363,
11525,
18099,
278,
4955,
1051,
29889,
29871,
2823,
3617,
20570,
4809,
13,
9651,
5106,
363,
6139,
310,
825,
393,
5067,
338,
29889,
13,
632,
13,
4706,
3617,
20570,
580,
13,
9651,
7106,
1857,
4955,
1051,
13,
632,
13,
4706,
3789,
20570,
29898,
995,
29922,
3285,
9262,
3220,
353,
6213,
1723,
13,
9651,
3789,
1857,
4955,
1051,
29892,
565,
9262,
3220,
338,
451,
6213,
29892,
1831,
393,
2380,
13,
632,
13,
4706,
9995,
13,
1678,
822,
4770,
2344,
12035,
1583,
29892,
334,
25699,
29892,
3579,
17514,
25699,
1125,
13,
4706,
1583,
29889,
18434,
353,
4257,
25699,
29889,
657,
29898,
376,
18434,
29908,
1723,
13,
4706,
565,
1583,
29889,
18434,
29901,
13,
9651,
628,
4257,
25699,
3366,
18434,
3108,
13,
13,
4706,
1583,
29889,
18434,
5594,
5841,
29922,
8516,
13,
4706,
565,
1246,
519,
29898,
1311,
29889,
18434,
1125,
13,
9651,
1583,
29889,
18434,
5594,
5841,
29922,
1311,
29889,
18434,
13,
9651,
1583,
29889,
18434,
29922,
8516,
13,
4706,
1024,
353,
4257,
25699,
29889,
657,
877,
978,
742,
525,
1445,
29933,
798,
344,
3125,
3047,
20570,
1495,
13,
4706,
4257,
25699,
1839,
978,
2033,
353,
1024,
13,
4706,
3497,
29933,
798,
344,
3125,
17255,
2344,
12035,
1311,
29892,
334,
25699,
29892,
3579,
17514,
25699,
29897,
13,
13,
13,
1678,
822,
1653,
1626,
4809,
29898,
1583,
1125,
13,
4706,
9995,
4391,
278,
1426,
2761,
15945,
29908,
13,
4706,
1426,
4809,
353,
26437,
29889,
26628,
29898,
1311,
29892,
448,
29896,
29892,
3114,
353,
26437,
29889,
21685,
29918,
29928,
29366,
3970,
16048,
1723,
13,
4706,
1426,
4809,
29889,
2697,
12229,
29911,
666,
1231,
29898,
1583,
29889,
10154,
29911,
666,
1723,
13,
4706,
1426,
4809,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
10490,
29918,
5800,
29907,
3308,
29892,
1583,
29889,
2951,
2697,
20560,
29897,
13,
4706,
565,
1583,
29889,
3167,
10717,
29901,
13,
9651,
1426,
4809,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
16975,
29892,
1583,
29889,
2951,
7590,
29897,
13,
9651,
1426,
4809,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
19795,
8456,
8456,
29990,
29892,
1583,
29889,
2951,
7590,
29897,
13,
4706,
565,
1583,
29889,
18434,
29901,
13,
9651,
4955,
29922,
1311,
29889,
18434,
13,
9651,
1583,
29889,
18434,
29922,
8516,
13,
9651,
1583,
29889,
2697,
20570,
29898,
4955,
29892,
2761,
29922,
726,
4809,
29897,
13,
4706,
736,
1426,
4809,
13,
13,
13,
1678,
822,
3617,
20570,
4809,
29898,
1583,
29871,
1125,
13,
4706,
9995,
13,
4706,
7106,
263,
4879,
304,
278,
2761,
607,
8128,
313,
271,
3203,
29897,
13,
4706,
278,
1494,
3519,
363,
11525,
18099,
278,
4955,
1051,
29901,
13,
308,
13,
9651,
22871,
29898,
2944,
1723,
1192,
788,
2944,
13,
9651,
17732,
580,
1192,
2821,
599,
4452,
13,
9651,
21267,
29898,
2380,
1723,
1192,
29871,
29900,
29899,
6707,
2380,
304,
5217,
515,
1051,
13,
9651,
3789,
15097,
29898,
2380,
1723,
1192,
29871,
29900,
29899,
6707,
2380,
304,
1831,
297,
1051,
13,
632,
13,
4706,
9444,
22614,
310,
278,
3519,
1101,
1906,
363,
278,
26437,
26628,
2761,
13,
4706,
9995,
13,
4706,
736,
1583,
29889,
726,
4809,
13,
13,
13,
1678,
822,
3789,
20570,
29898,
1583,
29892,
995,
29922,
3285,
9262,
3220,
353,
6213,
29892,
2761,
29922,
8516,
29871,
1125,
13,
4706,
9995,
2697,
278,
1857,
4955,
1051,
15945,
29908,
13,
4706,
565,
2761,
338,
6213,
29901,
13,
9651,
2761,
353,
1583,
29889,
2577,
20570,
4809,
580,
13,
4706,
565,
1583,
29889,
18434,
1275,
995,
29901,
13,
9651,
736,
13,
4706,
1583,
29889,
18434,
353,
995,
13,
4706,
396,
17732,
4955,
1819,
451,
278,
4629,
697,
29889,
13,
4706,
5694,
1917,
29922,
6451,
29889,
2577,
1917,
580,
13,
4706,
396,
2821,
3517,
1819,
13,
4706,
2761,
29889,
18759,
580,
13,
4706,
2761,
29889,
2697,
1917,
29898,
7382,
1917,
29897,
13,
4706,
396,
6686,
1549,
29892,
623,
2548,
716,
1819,
13,
4706,
363,
2224,
297,
995,
29901,
13,
9651,
2761,
29889,
18277,
29898,
2224,
1723,
13,
4706,
565,
9262,
3220,
338,
451,
6213,
29901,
13,
9651,
2761,
29889,
2697,
15097,
29898,
9262,
3220,
1723,
13,
13,
13,
1678,
822,
3617,
20570,
29898,
1583,
29871,
1125,
13,
4706,
9995,
11609,
278,
1857,
4955,
1051,
15945,
29908,
13,
4706,
565,
1583,
29889,
18434,
5594,
5841,
2804,
6213,
29901,
13,
9651,
736,
1583,
29889,
18434,
5594,
5841,
580,
13,
4706,
25342,
1583,
29889,
18434,
29901,
13,
9651,
736,
1051,
29898,
1583,
29889,
18434,
1723,
13,
4706,
1683,
29901,
13,
9651,
736,
5159,
13,
13,
13,
1678,
822,
1551,
2697,
20560,
29898,
1311,
29892,
1741,
1125,
13,
4706,
9995,
10401,
278,
4955,
6355,
338,
4629,
29892,
2767,
278,
4955,
15945,
29908,
13,
4706,
565,
1583,
29889,
18434,
5594,
5841,
2804,
6213,
29901,
13,
9651,
1583,
29889,
2697,
20570,
29898,
1583,
29889,
18434,
5594,
5841,
3285,
2761,
29922,
1311,
29889,
726,
4809,
29897,
13,
4706,
1741,
29889,
15797,
666,
580,
13,
13,
13,
1678,
565,
26437,
29889,
21889,
1275,
376,
1649,
29956,
29990,
4345,
29956,
1649,
1115,
13,
4706,
822,
3789,
1917,
313,
1311,
29892,
995,
29892,
1246,
5841,
29922,
29896,
1125,
13,
9651,
9995,
1281,
854,
993,
4444,
310,
1426,
2761,
995,
29892,
1736,
13,
18884,
2820,
29485,
310,
26437,
29889,
26628,
9995,
13,
9651,
4078,
353,
1583,
29889,
4804,
10717,
13,
9651,
1583,
29889,
4804,
10717,
353,
1246,
5841,
13,
9651,
1583,
29889,
726,
4809,
29889,
2697,
1917,
29898,
1767,
29897,
13,
9651,
1583,
29889,
4804,
10717,
353,
29871,
4078,
13,
13,
9651,
396,
379,
547,
304,
1246,
385,
1741,
7834,
13,
9651,
770,
9959,
2624,
29901,
13,
18884,
822,
4770,
2344,
12035,
1311,
29892,
1347,
1125,
13,
462,
1678,
1583,
3032,
1807,
29922,
1807,
13,
18884,
822,
3617,
1231,
29898,
1311,
1125,
13,
462,
1678,
736,
1583,
3032,
1807,
13,
9651,
565,
1246,
5841,
1360,
29896,
29901,
13,
18884,
396,
450,
6939,
9007,
29915,
29873,
1641,
2000,
746,
3789,
1917,
471,
1304,
13626,
13,
18884,
396,
1105,
2715,
445,
6261,
1246,
304,
372,
13,
18884,
1583,
29889,
3167,
10717,
29898,
7717,
2624,
29898,
1767,
876,
13,
13,
13,
1990,
19378,
29933,
798,
344,
3125,
29898,
2283,
29933,
798,
344,
3125,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3847,
29892,
1178,
353,
448,
29896,
29892,
13,
462,
926,
353,
26437,
29889,
4592,
8003,
29892,
2159,
353,
26437,
29889,
4592,
3505,
29892,
13,
462,
3114,
353,
26437,
29889,
29911,
2882,
29918,
29911,
4717,
5348,
29903,
1964,
29892,
13,
462,
3858,
1626,
353,
525,
3549,
263,
3884,
29901,
742,
13,
462,
2826,
1626,
353,
525,
29933,
798,
344,
742,
13,
462,
5780,
29911,
666,
353,
525,
1542,
3884,
1024,
470,
3347,
344,
304,
1831,
742,
13,
462,
7928,
7030,
353,
15516,
13,
462,
1369,
9882,
353,
15300,
742,
13,
462,
1735,
10717,
353,
6213,
29892,
13,
462,
7928,
2385,
353,
26437,
29889,
9170,
7647,
29892,
13,
462,
716,
9882,
353,
7700,
29892,
13,
462,
1024,
353,
525,
3972,
29933,
798,
344,
3125,
29374,
13,
4706,
3497,
29933,
798,
344,
3125,
17255,
2344,
12035,
1311,
29892,
3847,
29892,
1178,
29892,
926,
29892,
2159,
29892,
3114,
29892,
13,
462,
462,
29871,
3858,
1626,
29892,
2826,
1626,
29892,
5780,
29911,
666,
29892,
13,
462,
462,
29871,
7928,
7030,
29892,
1369,
9882,
29892,
13,
462,
462,
29871,
1735,
10717,
353,
1735,
10717,
29892,
13,
462,
462,
29871,
1024,
353,
1024,
29897,
13,
4706,
1583,
29889,
15901,
2385,
353,
7928,
2385,
13,
4706,
1583,
29889,
1482,
9882,
353,
716,
9882,
13,
1678,
396,
13,
13,
1678,
822,
1551,
29933,
798,
344,
29898,
1311,
29892,
3415,
353,
6213,
1125,
13,
4706,
3114,
29922,
29900,
13,
13,
4706,
565,
451,
1583,
29889,
1482,
9882,
29901,
13,
3986,
3114,
891,
29922,
26437,
29889,
7858,
29918,
9464,
29918,
29924,
17321,
29918,
5746,
9047,
13,
13,
4706,
7928,
353,
1583,
29889,
15901,
2385,
29898,
1311,
29892,
13,
462,
462,
29871,
2643,
353,
1583,
29889,
15901,
7030,
29892,
13,
462,
462,
29871,
2322,
2605,
353,
1583,
29889,
2962,
9882,
29892,
13,
462,
462,
29871,
3114,
353,
3114,
29897,
13,
13,
4706,
565,
7928,
29889,
8964,
19751,
580,
1275,
26437,
29889,
1367,
29918,
8949,
29901,
13,
9651,
1583,
29889,
2697,
1917,
29898,
15901,
29889,
2577,
2605,
3101,
13,
4706,
7928,
29889,
14994,
4727,
580,
13,
1678,
396,
13,
13,
13,
29937,
2683,
2683,
2683,
2683,
22158,
13,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
396,
3166,
18109,
11285,
16409,
1053,
6865,
1445,
13,
1678,
770,
12545,
10717,
29901,
13,
4706,
822,
4770,
2344,
12035,
1583,
29892,
4055,
29871,
1125,
13,
9651,
1583,
29889,
4039,
353,
4055,
13,
4706,
822,
4770,
4804,
12035,
1583,
29892,
1741,
29871,
1125,
13,
9651,
1596,
1583,
29889,
4039,
29892,
1741,
29889,
2577,
1231,
580,
13,
1678,
770,
27819,
4308,
29898,
26437,
29889,
4308,
29871,
1125,
13,
4706,
822,
4770,
2344,
12035,
1311,
29892,
3847,
1125,
13,
9651,
26437,
29889,
4308,
17255,
2344,
12035,
1311,
29892,
3847,
29892,
448,
29896,
29892,
376,
2283,
6251,
411,
3347,
344,
613,
2159,
7607,
29945,
29900,
29900,
29892,
29906,
29953,
29900,
876,
13,
9651,
1583,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
29907,
3927,
1660,
29892,
1583,
29889,
2951,
11123,
5907,
29897,
13,
9651,
9451,
353,
26437,
29889,
7490,
313,
1311,
6653,
29896,
29897,
13,
9651,
6426,
1884,
353,
26437,
29889,
3313,
29903,
3950,
29898,
23310,
29889,
5348,
29911,
2965,
1964,
29897,
13,
9651,
2761,
353,
3497,
29933,
798,
344,
3125,
29898,
13,
18884,
9451,
29892,
13,
18884,
2847,
1917,
353,
376,
29920,
22298,
7382,
613,
13,
9651,
1723,
13,
9651,
6426,
1884,
29889,
2528,
29898,
29871,
2761,
29892,
29871,
29900,
29892,
26437,
29889,
5746,
29925,
9468,
1723,
13,
9651,
7256,
6451,
353,
3497,
29933,
798,
344,
3125,
3047,
20570,
29898,
13,
18884,
9451,
29892,
13,
18884,
3858,
1626,
353,
376,
3047,
5298,
613,
13,
18884,
2847,
1917,
353,
376,
29881,
22298,
7382,
613,
13,
18884,
4955,
353,
6796,
29883,
22298,
7382,
613,
376,
29883,
22298,
7050,
613,
376,
29878,
22298,
7382,
3284,
29920,
22298,
7382,
12436,
13,
18884,
1735,
10717,
29922,
12545,
10717,
29898,
376,
3047,
5298,
29908,
10353,
13,
9651,
1723,
13,
9651,
6426,
1884,
29889,
2528,
29898,
7256,
6451,
29892,
29871,
29900,
29892,
26437,
29889,
5746,
29925,
9468,
1723,
13,
9651,
7256,
6451,
353,
3497,
29933,
798,
344,
3125,
3047,
20570,
29898,
13,
18884,
9451,
29892,
13,
18884,
3858,
1626,
353,
376,
20570,
6939,
613,
13,
18884,
2847,
1917,
353,
376,
29881,
22298,
7382,
613,
13,
18884,
4955,
353,
1583,
29889,
18434,
5594,
5841,
29892,
13,
18884,
1735,
10717,
29922,
12545,
10717,
29898,
376,
20570,
6939,
29908,
10353,
13,
9651,
1723,
13,
9651,
6426,
1884,
29889,
2528,
29898,
7256,
6451,
29892,
29871,
29900,
29892,
26437,
29889,
5746,
29925,
9468,
1723,
13,
9651,
1583,
29889,
8968,
6451,
353,
2761,
353,
3497,
29933,
798,
344,
3125,
29898,
13,
18884,
9451,
29892,
13,
18884,
3858,
1626,
353,
376,
3047,
8251,
1627,
613,
13,
18884,
3114,
353,
26437,
29889,
29903,
3904,
29968,
1430,
29918,
29933,
22364,
29989,
23310,
29889,
27205,
29925,
29918,
3210,
6227,
8353,
1430,
1919,
13,
18884,
1735,
10717,
29922,
12545,
10717,
29898,
376,
3047,
8251,
1627,
29908,
10353,
13,
9651,
1723,
13,
9651,
6426,
1884,
29889,
2528,
29898,
29871,
2761,
29892,
29871,
29900,
29892,
26437,
29889,
5746,
29925,
9468,
29897,
13,
9651,
1583,
29889,
29890,
1501,
3011,
520,
6451,
353,
2761,
353,
19378,
29933,
798,
344,
3125,
29898,
13,
18884,
9451,
29892,
13,
18884,
3858,
1626,
353,
376,
15427,
4516,
3347,
344,
2826,
613,
13,
18884,
3114,
353,
26437,
29889,
29903,
3904,
29968,
1430,
29918,
29933,
22364,
29989,
23310,
29889,
27205,
29925,
29918,
3210,
6227,
8353,
1430,
29897,
13,
9651,
6426,
1884,
29889,
2528,
29898,
29871,
2761,
29892,
29871,
29900,
29892,
26437,
29889,
5746,
29925,
9468,
29897,
13,
9651,
3553,
353,
26437,
29889,
4373,
1204,
580,
13,
9651,
6426,
1884,
29889,
2528,
29898,
26437,
29889,
3125,
29898,
9451,
29892,
3553,
1699,
7277,
15796,
613,
29871,
10353,
29871,
29896,
29892,
26437,
29889,
5746,
29925,
9468,
29897,
13,
9651,
1583,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
29933,
2692,
29911,
1164,
29892,
1583,
29889,
2951,
7277,
4775,
1919,
1178,
29922,
1367,
29897,
13,
9651,
3553,
353,
26437,
29889,
4373,
1204,
580,
13,
9651,
6426,
1884,
29889,
2528,
29898,
26437,
29889,
3125,
29898,
9451,
29892,
3553,
1699,
7277,
7865,
613,
29871,
10353,
29871,
29896,
29892,
26437,
29889,
5746,
29925,
9468,
29897,
13,
9651,
1583,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
29933,
2692,
29911,
1164,
29892,
1583,
29889,
2951,
7277,
1917,
29892,
1178,
29922,
1367,
1723,
13,
9651,
9451,
29889,
2697,
12300,
3453,
29898,
5574,
29897,
13,
9651,
9451,
29889,
2697,
29903,
3950,
29898,
6426,
1884,
1723,
13,
9651,
1583,
29889,
18434,
3790,
29908,
29883,
22298,
7382,
1115,
29896,
29892,
376,
29883,
22298,
7050,
1115,
29896,
29892,
376,
29878,
22298,
7382,
1115,
29896,
1699,
29920,
22298,
7382,
1115,
29896,
29913,
13,
13,
4706,
822,
4955,
5594,
5841,
29898,
1311,
1125,
13,
9651,
6611,
29922,
1311,
29889,
18434,
29889,
8149,
580,
13,
9651,
6611,
29889,
6605,
580,
13,
9651,
736,
6611,
13,
13,
4706,
822,
1551,
17020,
7590,
20570,
313,
1311,
29892,
1741,
1125,
13,
9651,
1583,
29889,
18434,
29961,
3696,
29889,
2577,
1231,
3861,
13192,
29896,
13,
13,
4706,
822,
1551,
11123,
6816,
29898,
1311,
29892,
1741,
1125,
13,
9651,
1583,
29889,
11123,
29898,
5574,
29897,
13,
4706,
822,
1551,
7277,
4775,
29898,
1583,
29892,
1741,
29871,
1125,
13,
9651,
1583,
29889,
8968,
6451,
29889,
2697,
4775,
29898,
376,
4775,
25723,
29908,
1723,
13,
4706,
822,
1551,
7277,
1917,
29898,
1583,
29892,
1741,
29871,
1125,
13,
9651,
1583,
29889,
8968,
6451,
29889,
2697,
1917,
29898,
376,
29878,
22298,
5372,
3062,
1966,
957,
1966,
1552,
1966,
6038,
17729,
29889,
13357,
29908,
1723,
13,
13,
4706,
822,
1551,
11123,
5907,
29898,
1311,
29892,
1741,
1125,
13,
9651,
1583,
29889,
14994,
4727,
580,
13,
13,
1678,
770,
27819,
2052,
29898,
23310,
29889,
2052,
1125,
13,
4706,
822,
1551,
6644,
29898,
1311,
1125,
13,
9651,
26437,
29889,
6644,
3596,
2940,
3481,
9306,
580,
13,
9651,
3515,
353,
27819,
4308,
29898,
8516,
29897,
13,
9651,
3515,
29889,
8964,
29898,
5574,
29897,
13,
9651,
1583,
29889,
2697,
7031,
5907,
29898,
2557,
29897,
13,
9651,
736,
5852,
13,
13,
1678,
822,
1243,
29898,
29871,
1125,
13,
4706,
623,
353,
27819,
2052,
29898,
29900,
29897,
13,
4706,
623,
29889,
6330,
18405,
580,
13,
1678,
1596,
525,
9832,
1218,
7928,
29915,
13,
1678,
1243,
29898,
1723,
13,
13,
13,
13,
2
] |
python/tests/test_random.py | mbp28/ecole | 234 | 149997 | <gh_stars>100-1000
import copy
import pickle
import ecole
def test_RandomEngine():
"""Test bindings of the RandomEngine."""
assert ecole.RandomEngine.min_seed < ecole.RandomEngine.max_seed
random_engine = ecole.RandomEngine(42)
rand_val_1 = random_engine()
assert isinstance(rand_val_1, int)
random_engine.seed(42)
rand_val_2 = random_engine()
assert rand_val_1 == rand_val_2
def test_RandomEngine_copy():
"""Copy create a new RandomEngine with same state."""
random_engine = ecole.RandomEngine(42)
random_engine_copy = copy.copy(random_engine)
assert random_engine_copy == random_engine
assert random_engine_copy is not random_engine
random_engine_deepcopy = copy.deepcopy(random_engine)
assert random_engine_deepcopy == random_engine
assert random_engine_deepcopy is not random_engine
def test_RandomEngine_pickle():
"""Pickle preserve the state of the RandomEngine."""
random_engine = ecole.RandomEngine(42)
assert random_engine == pickle.loads(pickle.dumps(random_engine))
def test_same_seed():
"""Same seed give same random engines."""
ecole.seed(0)
random_engine_1 = ecole.spawn_random_engine()
ecole.seed(0)
random_engine_2 = ecole.spawn_random_engine()
assert random_engine_1 == random_engine_2
def test_differen_seed():
"""Different seeds give different random engines."""
ecole.seed(0)
random_engine_1 = ecole.spawn_random_engine()
ecole.seed(2)
random_engine_2 = ecole.spawn_random_engine()
assert random_engine_1 != random_engine_2
def test_spawn_engine():
"""Successive random engines are different"""
random_engine_1 = ecole.spawn_random_engine()
random_engine_2 = ecole.spawn_random_engine()
assert random_engine_1 != random_engine_2
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29900,
29899,
29896,
29900,
29900,
29900,
13,
5215,
3509,
13,
5215,
5839,
280,
13,
13,
5215,
321,
10936,
13,
13,
13,
1753,
1243,
29918,
17875,
12412,
7295,
13,
1678,
9995,
3057,
7868,
886,
310,
278,
16968,
12412,
1213,
15945,
13,
1678,
4974,
321,
10936,
29889,
17875,
12412,
29889,
1195,
29918,
26776,
529,
321,
10936,
29889,
17875,
12412,
29889,
3317,
29918,
26776,
13,
1678,
4036,
29918,
10599,
353,
321,
10936,
29889,
17875,
12412,
29898,
29946,
29906,
29897,
13,
1678,
20088,
29918,
791,
29918,
29896,
353,
4036,
29918,
10599,
580,
13,
1678,
4974,
338,
8758,
29898,
9502,
29918,
791,
29918,
29896,
29892,
938,
29897,
13,
13,
1678,
4036,
29918,
10599,
29889,
26776,
29898,
29946,
29906,
29897,
13,
1678,
20088,
29918,
791,
29918,
29906,
353,
4036,
29918,
10599,
580,
13,
1678,
4974,
20088,
29918,
791,
29918,
29896,
1275,
20088,
29918,
791,
29918,
29906,
13,
13,
13,
1753,
1243,
29918,
17875,
12412,
29918,
8552,
7295,
13,
1678,
9995,
11882,
1653,
263,
716,
16968,
12412,
411,
1021,
2106,
1213,
15945,
13,
1678,
4036,
29918,
10599,
353,
321,
10936,
29889,
17875,
12412,
29898,
29946,
29906,
29897,
13,
13,
1678,
4036,
29918,
10599,
29918,
8552,
353,
3509,
29889,
8552,
29898,
8172,
29918,
10599,
29897,
13,
1678,
4974,
4036,
29918,
10599,
29918,
8552,
1275,
4036,
29918,
10599,
13,
1678,
4974,
4036,
29918,
10599,
29918,
8552,
338,
451,
4036,
29918,
10599,
13,
13,
1678,
4036,
29918,
10599,
29918,
24535,
8552,
353,
3509,
29889,
24535,
8552,
29898,
8172,
29918,
10599,
29897,
13,
1678,
4974,
4036,
29918,
10599,
29918,
24535,
8552,
1275,
4036,
29918,
10599,
13,
1678,
4974,
4036,
29918,
10599,
29918,
24535,
8552,
338,
451,
4036,
29918,
10599,
13,
13,
13,
1753,
1243,
29918,
17875,
12412,
29918,
23945,
280,
7295,
13,
1678,
9995,
29925,
860,
280,
19905,
278,
2106,
310,
278,
16968,
12412,
1213,
15945,
13,
1678,
4036,
29918,
10599,
353,
321,
10936,
29889,
17875,
12412,
29898,
29946,
29906,
29897,
13,
1678,
4974,
4036,
29918,
10599,
1275,
5839,
280,
29889,
18132,
29898,
23945,
280,
29889,
29881,
17204,
29898,
8172,
29918,
10599,
876,
13,
13,
13,
1753,
1243,
29918,
17642,
29918,
26776,
7295,
13,
1678,
9995,
29903,
420,
16717,
2367,
1021,
4036,
24000,
1213,
15945,
13,
1678,
321,
10936,
29889,
26776,
29898,
29900,
29897,
13,
1678,
4036,
29918,
10599,
29918,
29896,
353,
321,
10936,
29889,
1028,
18101,
29918,
8172,
29918,
10599,
580,
13,
1678,
321,
10936,
29889,
26776,
29898,
29900,
29897,
13,
1678,
4036,
29918,
10599,
29918,
29906,
353,
321,
10936,
29889,
1028,
18101,
29918,
8172,
29918,
10599,
580,
13,
1678,
4974,
4036,
29918,
10599,
29918,
29896,
1275,
4036,
29918,
10599,
29918,
29906,
13,
13,
13,
1753,
1243,
29918,
29881,
8349,
264,
29918,
26776,
7295,
13,
1678,
9995,
29928,
15622,
409,
5779,
2367,
1422,
4036,
24000,
1213,
15945,
13,
1678,
321,
10936,
29889,
26776,
29898,
29900,
29897,
13,
1678,
4036,
29918,
10599,
29918,
29896,
353,
321,
10936,
29889,
1028,
18101,
29918,
8172,
29918,
10599,
580,
13,
1678,
321,
10936,
29889,
26776,
29898,
29906,
29897,
13,
1678,
4036,
29918,
10599,
29918,
29906,
353,
321,
10936,
29889,
1028,
18101,
29918,
8172,
29918,
10599,
580,
13,
1678,
4974,
4036,
29918,
10599,
29918,
29896,
2804,
4036,
29918,
10599,
29918,
29906,
13,
13,
13,
1753,
1243,
29918,
1028,
18101,
29918,
10599,
7295,
13,
1678,
9995,
14191,
573,
4036,
24000,
526,
1422,
15945,
29908,
13,
1678,
4036,
29918,
10599,
29918,
29896,
353,
321,
10936,
29889,
1028,
18101,
29918,
8172,
29918,
10599,
580,
13,
1678,
4036,
29918,
10599,
29918,
29906,
353,
321,
10936,
29889,
1028,
18101,
29918,
8172,
29918,
10599,
580,
13,
1678,
4974,
4036,
29918,
10599,
29918,
29896,
2804,
4036,
29918,
10599,
29918,
29906,
13,
2
] |
locale/pot/api/utilities/_autosummary/pyvista-Disc-1.py | tkoyama010/pyvista-doc-translations | 4 | 32534 | <reponame>tkoyama010/pyvista-doc-translations
# Create a disc with 50 points in the circumferential direction.
#
import pyvista
mesh = pyvista.Disc(c_res=50)
mesh.plot(show_edges=True, line_width=5)
| [
1,
529,
276,
1112,
420,
29958,
29873,
2901,
29891,
3304,
29900,
29896,
29900,
29914,
2272,
29894,
2079,
29899,
1514,
29899,
3286,
29880,
800,
13,
29937,
6204,
263,
2313,
411,
29871,
29945,
29900,
3291,
297,
278,
9942,
571,
2556,
5305,
29889,
13,
29937,
13,
5215,
11451,
29894,
2079,
13,
4467,
29882,
353,
11451,
29894,
2079,
29889,
4205,
29883,
29898,
29883,
29918,
690,
29922,
29945,
29900,
29897,
13,
4467,
29882,
29889,
5317,
29898,
4294,
29918,
287,
2710,
29922,
5574,
29892,
1196,
29918,
2103,
29922,
29945,
29897,
13,
2
] |
praetorian_api_client/resources/service.py | Praetorian-Defence/praetorian-api-client | 0 | 150989 | from dataclasses import dataclass
from typing import List
from uuid import UUID
from praetorian_api_client.resources.base import BaseResource
class ServiceResource(BaseResource):
@dataclass
class Service(object):
id: UUID
name: str
type: str
variables: dict
def list(self, remote_id: str = None, name: str = None, service_type: str = None) -> List[Service]:
query = self.fill_content(remote_id=remote_id, name=name, type=service_type)
response = self.requestor.request('GET', 'services/', query=query)['items']
return [
self.Service(
id=item.get('id'),
name=item.get('name'),
type=item.get('type'),
variables=item.get('variables')
) for item in response
]
def get(self, service_id: str) -> Service:
response = self.requestor.request('GET', f'services/{service_id}/')['response']
return self.Service(
id=response.get('id'),
name=response.get('name'),
type=response.get('type'),
variables=response.get('variables')
)
| [
1,
515,
848,
13203,
1053,
848,
1990,
13,
3166,
19229,
1053,
2391,
13,
3166,
318,
5416,
1053,
501,
11150,
13,
13,
3166,
7213,
300,
272,
713,
29918,
2754,
29918,
4645,
29889,
13237,
29889,
3188,
1053,
7399,
6848,
13,
13,
13,
1990,
6692,
6848,
29898,
5160,
6848,
1125,
13,
1678,
732,
1272,
1990,
13,
1678,
770,
6692,
29898,
3318,
1125,
13,
4706,
1178,
29901,
501,
11150,
13,
4706,
1024,
29901,
851,
13,
4706,
1134,
29901,
851,
13,
4706,
3651,
29901,
9657,
13,
13,
1678,
822,
1051,
29898,
1311,
29892,
7592,
29918,
333,
29901,
851,
353,
6213,
29892,
1024,
29901,
851,
353,
6213,
29892,
2669,
29918,
1853,
29901,
851,
353,
6213,
29897,
1599,
2391,
29961,
3170,
5387,
13,
4706,
2346,
353,
1583,
29889,
5589,
29918,
3051,
29898,
16674,
29918,
333,
29922,
16674,
29918,
333,
29892,
1024,
29922,
978,
29892,
1134,
29922,
5509,
29918,
1853,
29897,
13,
4706,
2933,
353,
1583,
29889,
3827,
272,
29889,
3827,
877,
7194,
742,
525,
9916,
29914,
742,
2346,
29922,
1972,
29897,
1839,
7076,
2033,
13,
13,
4706,
736,
518,
13,
9651,
1583,
29889,
3170,
29898,
13,
18884,
1178,
29922,
667,
29889,
657,
877,
333,
5477,
13,
18884,
1024,
29922,
667,
29889,
657,
877,
978,
5477,
13,
18884,
1134,
29922,
667,
29889,
657,
877,
1853,
5477,
13,
18884,
3651,
29922,
667,
29889,
657,
877,
20897,
1495,
13,
9651,
1723,
363,
2944,
297,
2933,
13,
4706,
4514,
13,
13,
1678,
822,
679,
29898,
1311,
29892,
2669,
29918,
333,
29901,
851,
29897,
1599,
6692,
29901,
13,
4706,
2933,
353,
1583,
29889,
3827,
272,
29889,
3827,
877,
7194,
742,
285,
29915,
9916,
19248,
5509,
29918,
333,
6822,
1495,
1839,
5327,
2033,
13,
13,
4706,
736,
1583,
29889,
3170,
29898,
13,
9651,
1178,
29922,
5327,
29889,
657,
877,
333,
5477,
13,
9651,
1024,
29922,
5327,
29889,
657,
877,
978,
5477,
13,
9651,
1134,
29922,
5327,
29889,
657,
877,
1853,
5477,
13,
9651,
3651,
29922,
5327,
29889,
657,
877,
20897,
1495,
13,
4706,
1723,
13,
2
] |
ferminet/utils/system.py | shishaochen/ferminet | 469 | 24304 | <reponame>shishaochen/ferminet
# Lint as: python3
# Copyright 2020 DeepMind Technologies Limited. 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
#
# https://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.
"""Functions to create different kinds of systems."""
from typing import Sequence
import attr
from ferminet.utils import elements
from ferminet.utils import units as unit_conversion
import numpy as np
# Default bond lengths in angstrom for some diatomics.
# Bond lengths from either the G3 dataset:
# 1. http://www.cse.anl.gov/OldCHMwebsiteContent/compmat/comptherm.htm
# 2. <NAME>, <NAME>, <NAME>, and <NAME>,
# J. Chem. Phys, 109, 42 (1998).
# or from NIST (https://cccbdb.nist.gov/diatomicexpbondx.asp).
diatomic_bond_lengths = {
'BeH': 1.348263,
'CN': 1.134797,
'ClF': 1.659091,
'F2': 1.420604,
'H2': 0.737164,
'HCl': 1.2799799,
'Li2': 2.77306,
'LiH': 1.639999,
'N2': 1.129978,
'NH': 1.039428,
'CO': 1.150338,
'BH': 1.2324,
'PN': 1.491,
'AlH': 1.648,
'AlN': 1.786,
}
# Default spin polarisation for a few diatomics of interest.
# Otherwise default to either singlet (doublet) for even (odd) numbers of
# electrons. Units: number of unpaired electrons.
diatomic_spin_polarisation = {
'B2': 2,
'O2': 2,
'NH': 2,
'AlN': 2,
}
@attr.s
class Atom: # pytype: disable=invalid-function-definition
"""Atom information for Hamiltonians.
The nuclear charge is inferred from the symbol if not given, in which case the
symbol must be the IUPAC symbol of the desired element.
Attributes:
symbol: Element symbol.
coords: An iterable of atomic coordinates. Always a list of floats and in
bohr after initialisation. Default: place atom at origin.
charge: Nuclear charge. Default: nuclear charge (atomic number) of atom of
the given name.
atomic_number: Atomic number associated with element. Default: atomic number
of element of the given symbol. Should match charge unless fractional
nuclear charges are being used.
units: String giving units of coords. Either bohr or angstrom. Default:
bohr. If angstrom, coords are converted to be in bohr and units to the
string 'bohr'.
coords_angstrom: list of atomic coordinates in angstrom.
coords_array: Numpy array of atomic coordinates in bohr.
element: elements.Element corresponding to the symbol.
"""
symbol = attr.ib()
coords = attr.ib(
converter=lambda xs: tuple(float(x) for x in xs),
default=(0.0, 0.0, 0.0)) # type: Sequence[float]
charge = attr.ib(converter=float)
atomic_number = attr.ib(converter=int)
units = attr.ib(
default='bohr', validator=attr.validators.in_(['bohr', 'angstrom']))
@charge.default
def _set_default_charge(self):
return self.element.atomic_number
@atomic_number.default
def _set_default_atomic_number(self):
return self.element.atomic_number
def __attrs_post_init__(self):
if self.units == 'angstrom':
self.coords = [unit_conversion.angstrom2bohr(x) for x in self.coords]
self.units = 'bohr'
@property
def coords_angstrom(self):
return [unit_conversion.bohr2angstrom(x) for x in self.coords]
@property
def coords_array(self):
if not hasattr(self, '_coords_arr'):
self._coords_arr = np.array(self.coords)
return self._coords_arr
@property
def element(self):
return elements.SYMBOLS[self.symbol]
def atom(symbol, spins=None, charge=0):
"""Return configuration for a single atom.
Args:
symbol: The atomic symbol from the periodic table
spins (optional): A tuple with the number of spin-up and spin-down electrons
charge (optional): If zero (default), create a neutral atom, otherwise
create an anion if charge is negative or cation if charge is positive.
Returns:
A list with a single Atom object located at zero, and a tuple with the spin
configuration of the electrons.
"""
atomic_number = elements.SYMBOLS[symbol].atomic_number
if charge > atomic_number:
raise ValueError('Cannot have a cation with charge larger than the '
'atomic number. Charge: {}, Atomic Number{}'.format(
charge, atomic_number))
if spins is None:
spin_polarisation = elements.ATOMIC_NUMS[atomic_number-charge].spin_config
nalpha = (atomic_number + spin_polarisation) // 2
spins = (nalpha, atomic_number - charge - nalpha)
return [Atom(symbol=symbol, coords=(0.0, 0.0, 0.0))], spins
def diatomic(symbol1, symbol2, bond_length, spins=None, charge=0, units='bohr'):
"""Return configuration for a diatomic molecule."""
if spins is None:
atomic_number_1 = elements.SYMBOLS[symbol1].atomic_number
atomic_number_2 = elements.SYMBOLS[symbol2].atomic_number
total_charge = atomic_number_1 + atomic_number_2 - charge
if total_charge % 2 == 0:
spins = (total_charge // 2, total_charge // 2)
else:
spins = ((total_charge + 1)// 2, (total_charge - 1) // 2)
return [
Atom(symbol=symbol1, coords=(0.0, 0.0, bond_length/2.0), units=units),
Atom(symbol=symbol2, coords=(0.0, 0.0, -bond_length/2.0), units=units)
], spins
def molecule(symbol, bond_length=0.0, units='bohr'):
"""Hardcoded molecular geometries from the original Fermi Net paper."""
if symbol in diatomic_bond_lengths:
if symbol[-1] == '2':
symbs = [symbol[:-1], symbol[:-1]]
else: # Split a camel-case string on the second capital letter
split_idx = None
for i in range(1, len(symbol)):
if split_idx is None and symbol[i].isupper():
split_idx = i
if split_idx is None:
raise ValueError('Cannot find second atomic symbol: {}'.format(symbol))
symbs = [symbol[:split_idx], symbol[split_idx:]]
atomic_number_1 = elements.SYMBOLS[symbs[0]].atomic_number
atomic_number_2 = elements.SYMBOLS[symbs[1]].atomic_number
total_charge = atomic_number_1 + atomic_number_2
if symbol in diatomic_spin_polarisation:
spin_pol = diatomic_spin_polarisation[symbol]
spins = ((total_charge + spin_pol) // 2, (total_charge + spin_pol) // 2)
elif total_charge % 2 == 0:
spins = (total_charge // 2, total_charge // 2)
else:
spins = ((total_charge + 1)// 2, (total_charge - 1) // 2)
if bond_length == 0.0:
bond_length = diatomic_bond_lengths[symbol]
units = 'angstrom'
return diatomic(symbs[0], symbs[1],
bond_length,
units=units,
spins=spins)
if bond_length != 0.0:
raise ValueError('Bond length argument only appropriate for diatomics.')
if symbol == 'CH4':
return [
Atom(symbol='C', coords=(0.0, 0.0, 0.0), units='bohr'),
Atom(symbol='H', coords=(1.18886, 1.18886, 1.18886), units='bohr'),
Atom(symbol='H', coords=(-1.18886, -1.18886, 1.18886), units='bohr'),
Atom(symbol='H', coords=(1.18886, -1.18886, -1.18886), units='bohr'),
Atom(symbol='H', coords=(-1.18886, 1.18886, -1.18886), units='bohr'),
], (5, 5)
if symbol == 'NH3':
return [
Atom(symbol='N', coords=(0.0, 0.0, 0.22013), units='bohr'),
Atom(symbol='H', coords=(0.0, 1.77583, -0.51364), units='bohr'),
Atom(symbol='H', coords=(1.53791, -0.88791, -0.51364), units='bohr'),
Atom(symbol='H', coords=(-1.53791, -0.88791, -0.51364), units='bohr'),
], (5, 5)
if symbol in ('C2H4', 'ethene', 'ethylene'):
return [
Atom(symbol='C', coords=(0.0, 0.0, 1.26135), units='bohr'),
Atom(symbol='C', coords=(0.0, 0.0, -1.26135), units='bohr'),
Atom(symbol='H', coords=(0.0, 1.74390, 2.33889), units='bohr'),
Atom(symbol='H', coords=(0.0, -1.74390, 2.33889), units='bohr'),
Atom(symbol='H', coords=(0.0, 1.74390, -2.33889), units='bohr'),
Atom(symbol='H', coords=(0.0, -1.74390, -2.33889), units='bohr'),
], (8, 8)
if symbol in ('C4H6', 'bicyclobutane'):
return [
Atom(symbol='C', coords=(0.0, 2.13792, 0.58661), units='bohr'),
Atom(symbol='C', coords=(0.0, -2.13792, 0.58661), units='bohr'),
Atom(symbol='C', coords=(1.41342, 0.0, -0.58924), units='bohr'),
Atom(symbol='C', coords=(-1.41342, 0.0, -0.58924), units='bohr'),
Atom(symbol='H', coords=(0.0, 2.33765, 2.64110), units='bohr'),
Atom(symbol='H', coords=(0.0, 3.92566, -0.43023), units='bohr'),
Atom(symbol='H', coords=(0.0, -2.33765, 2.64110), units='bohr'),
Atom(symbol='H', coords=(0.0, -3.92566, -0.43023), units='bohr'),
Atom(symbol='H', coords=(2.67285, 0.0, -2.19514), units='bohr'),
Atom(symbol='H', coords=(-2.67285, 0.0, -2.19514), units='bohr'),
], (15, 15)
raise ValueError('Not a recognized molecule: {}'.format(symbol))
def hn(n, r, charge=0, units='bohr'):
"""Return a hydrogen chain with n atoms and separation r."""
m = n - charge # number of electrons
if m % 2 == 0:
spins = (m//2, m//2)
else:
spins = ((m+1)//2, (m-1)//2)
lim = r * (n-1) / 2.0
return [Atom(symbol='H', coords=(0.0, 0.0, z), units=units)
for z in np.linspace(-lim, lim, n)], spins
def h4_circle(r, theta, units='bohr'):
"""Return 4 hydrogen atoms arranged in a circle, a failure case of CCSD(T)."""
return [
Atom(symbol='H',
coords=(r*np.cos(theta), r*np.sin(theta), 0.0),
units=units),
Atom(symbol='H',
coords=(-r*np.cos(theta), r*np.sin(theta), 0.0),
units=units),
Atom(symbol='H',
coords=(r*np.cos(theta), -r*np.sin(theta), 0.0),
units=units),
Atom(symbol='H',
coords=(-r*np.cos(theta), -r*np.sin(theta), 0.0),
units=units)
], (2, 2)
| [
1,
529,
276,
1112,
420,
29958,
845,
728,
6241,
2724,
29914,
571,
1195,
300,
13,
29937,
365,
524,
408,
29901,
3017,
29941,
13,
29937,
14187,
1266,
29871,
29906,
29900,
29906,
29900,
21784,
29924,
513,
8364,
11763,
28873,
29889,
2178,
26863,
2538,
9841,
29889,
13,
29937,
13,
29937,
10413,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
29937,
366,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
29937,
887,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
268,
2045,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
29937,
13,
29937,
25870,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
29937,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29937,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
13,
29937,
2823,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
29937,
27028,
1090,
278,
19245,
29889,
13,
13,
15945,
29908,
6678,
29879,
304,
1653,
1422,
17690,
310,
6757,
1213,
15945,
13,
13,
3166,
19229,
1053,
922,
3910,
13,
5215,
12421,
13,
3166,
16895,
10157,
29889,
13239,
1053,
3161,
13,
3166,
16895,
10157,
29889,
13239,
1053,
10340,
408,
5190,
29918,
535,
3259,
13,
5215,
12655,
408,
7442,
13,
13,
13,
29937,
13109,
21224,
27497,
297,
2614,
303,
456,
363,
777,
652,
8678,
1199,
29889,
13,
29937,
26370,
27497,
515,
2845,
278,
402,
29941,
8783,
29901,
13,
29937,
29871,
29896,
29889,
1732,
597,
1636,
29889,
29883,
344,
29889,
273,
29880,
29889,
13513,
29914,
21648,
3210,
29924,
22942,
3916,
29914,
2388,
2922,
29914,
2388,
721,
29885,
29889,
13357,
13,
29937,
29871,
29906,
29889,
529,
5813,
10202,
529,
5813,
10202,
529,
5813,
10202,
322,
529,
5813,
10202,
13,
29937,
1678,
435,
29889,
12677,
29889,
11661,
29892,
29871,
29896,
29900,
29929,
29892,
29871,
29946,
29906,
313,
29896,
29929,
29929,
29947,
467,
13,
29937,
470,
515,
405,
9047,
313,
991,
597,
617,
10702,
2585,
29889,
29876,
391,
29889,
13513,
29914,
6051,
8678,
625,
29916,
24381,
898,
29916,
29889,
4692,
467,
13,
6051,
21641,
29918,
29890,
898,
29918,
2848,
29879,
353,
426,
13,
1678,
525,
3629,
29950,
2396,
29871,
29896,
29889,
29941,
29946,
29947,
29906,
29953,
29941,
29892,
13,
1678,
525,
13778,
2396,
29871,
29896,
29889,
29896,
29941,
29946,
29955,
29929,
29955,
29892,
13,
1678,
525,
6821,
29943,
2396,
29871,
29896,
29889,
29953,
29945,
29929,
29900,
29929,
29896,
29892,
13,
1678,
525,
29943,
29906,
2396,
29871,
29896,
29889,
29946,
29906,
29900,
29953,
29900,
29946,
29892,
13,
1678,
525,
29950,
29906,
2396,
29871,
29900,
29889,
29955,
29941,
29955,
29896,
29953,
29946,
29892,
13,
1678,
525,
29950,
6821,
2396,
29871,
29896,
29889,
29906,
29955,
29929,
29929,
29955,
29929,
29929,
29892,
13,
1678,
525,
23410,
29906,
2396,
29871,
29906,
29889,
29955,
29955,
29941,
29900,
29953,
29892,
13,
1678,
525,
23410,
29950,
2396,
29871,
29896,
29889,
29953,
29941,
29929,
29929,
29929,
29929,
29892,
13,
1678,
525,
29940,
29906,
2396,
29871,
29896,
29889,
29896,
29906,
29929,
29929,
29955,
29947,
29892,
13,
1678,
525,
29940,
29950,
2396,
29871,
29896,
29889,
29900,
29941,
29929,
29946,
29906,
29947,
29892,
13,
1678,
525,
3217,
2396,
29871,
29896,
29889,
29896,
29945,
29900,
29941,
29941,
29947,
29892,
13,
1678,
525,
29933,
29950,
2396,
29871,
29896,
29889,
29906,
29941,
29906,
29946,
29892,
13,
1678,
525,
15695,
2396,
29871,
29896,
29889,
29946,
29929,
29896,
29892,
13,
1678,
525,
2499,
29950,
2396,
29871,
29896,
29889,
29953,
29946,
29947,
29892,
13,
1678,
525,
2499,
29940,
2396,
29871,
29896,
29889,
29955,
29947,
29953,
29892,
13,
29913,
13,
13,
13,
29937,
13109,
10917,
16755,
4371,
363,
263,
2846,
652,
8678,
1199,
310,
4066,
29889,
13,
29937,
13466,
2322,
304,
2845,
1809,
1026,
313,
8896,
29873,
29897,
363,
1584,
313,
22861,
29897,
3694,
310,
13,
29937,
27149,
29889,
28386,
29901,
1353,
310,
443,
3274,
2859,
27149,
29889,
13,
6051,
21641,
29918,
1028,
262,
29918,
3733,
279,
4371,
353,
426,
13,
1678,
525,
29933,
29906,
2396,
29871,
29906,
29892,
13,
1678,
525,
29949,
29906,
2396,
29871,
29906,
29892,
13,
1678,
525,
29940,
29950,
2396,
29871,
29906,
29892,
13,
1678,
525,
2499,
29940,
2396,
29871,
29906,
29892,
13,
29913,
13,
13,
13,
29992,
5552,
29889,
29879,
13,
1990,
2180,
290,
29901,
29871,
396,
11451,
1853,
29901,
11262,
29922,
20965,
29899,
2220,
29899,
16553,
13,
29871,
9995,
4178,
290,
2472,
363,
12372,
5834,
29889,
13,
13,
29871,
450,
20346,
8323,
338,
10115,
1127,
515,
278,
5829,
565,
451,
2183,
29892,
297,
607,
1206,
278,
13,
29871,
5829,
1818,
367,
278,
306,
4897,
2477,
5829,
310,
278,
7429,
1543,
29889,
13,
13,
29871,
6212,
5026,
29901,
13,
1678,
5829,
29901,
10619,
5829,
29889,
13,
1678,
1302,
4339,
29901,
530,
4256,
519,
310,
23489,
10350,
29889,
29849,
263,
1051,
310,
5685,
1446,
322,
297,
13,
418,
1045,
1092,
1156,
2847,
4371,
29889,
13109,
29901,
2058,
12301,
472,
3978,
29889,
13,
1678,
8323,
29901,
405,
1682,
1945,
8323,
29889,
13109,
29901,
20346,
8323,
313,
21641,
1353,
29897,
310,
12301,
310,
13,
418,
278,
2183,
1024,
29889,
13,
1678,
23489,
29918,
4537,
29901,
2180,
25426,
1353,
6942,
411,
1543,
29889,
13109,
29901,
23489,
1353,
13,
418,
310,
1543,
310,
278,
2183,
5829,
29889,
10575,
1993,
8323,
6521,
15958,
284,
13,
418,
20346,
21090,
526,
1641,
1304,
29889,
13,
1678,
10340,
29901,
1714,
6820,
10340,
310,
1302,
4339,
29889,
20370,
1045,
1092,
470,
2614,
303,
456,
29889,
13109,
29901,
13,
418,
1045,
1092,
29889,
960,
2614,
303,
456,
29892,
1302,
4339,
526,
11543,
304,
367,
297,
1045,
1092,
322,
10340,
304,
278,
13,
418,
1347,
525,
833,
1092,
4286,
13,
1678,
1302,
4339,
29918,
574,
303,
456,
29901,
1051,
310,
23489,
10350,
297,
2614,
303,
456,
29889,
13,
1678,
1302,
4339,
29918,
2378,
29901,
11848,
2272,
1409,
310,
23489,
10350,
297,
1045,
1092,
29889,
13,
1678,
1543,
29901,
3161,
29889,
2642,
6590,
304,
278,
5829,
29889,
13,
29871,
9995,
13,
29871,
5829,
353,
12421,
29889,
747,
580,
13,
29871,
1302,
4339,
353,
12421,
29889,
747,
29898,
13,
418,
29105,
29922,
2892,
14492,
29901,
18761,
29898,
7411,
29898,
29916,
29897,
363,
921,
297,
14492,
511,
13,
418,
2322,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
876,
29871,
396,
1134,
29901,
922,
3910,
29961,
7411,
29962,
13,
29871,
8323,
353,
12421,
29889,
747,
29898,
535,
13549,
29922,
7411,
29897,
13,
29871,
23489,
29918,
4537,
353,
12421,
29889,
747,
29898,
535,
13549,
29922,
524,
29897,
13,
29871,
10340,
353,
12421,
29889,
747,
29898,
13,
418,
2322,
2433,
833,
1092,
742,
2854,
1061,
29922,
5552,
29889,
3084,
4097,
29889,
262,
29918,
18959,
833,
1092,
742,
525,
574,
303,
456,
25901,
13,
13,
29871,
732,
23367,
29889,
4381,
13,
29871,
822,
903,
842,
29918,
4381,
29918,
23367,
29898,
1311,
1125,
13,
1678,
736,
1583,
29889,
5029,
29889,
21641,
29918,
4537,
13,
13,
29871,
732,
21641,
29918,
4537,
29889,
4381,
13,
29871,
822,
903,
842,
29918,
4381,
29918,
21641,
29918,
4537,
29898,
1311,
1125,
13,
1678,
736,
1583,
29889,
5029,
29889,
21641,
29918,
4537,
13,
13,
29871,
822,
4770,
5552,
29879,
29918,
2490,
29918,
2344,
12035,
1311,
1125,
13,
1678,
565,
1583,
29889,
348,
1169,
1275,
525,
574,
303,
456,
2396,
13,
418,
1583,
29889,
1111,
4339,
353,
518,
5441,
29918,
535,
3259,
29889,
574,
303,
456,
29906,
833,
1092,
29898,
29916,
29897,
363,
921,
297,
1583,
29889,
1111,
4339,
29962,
13,
418,
1583,
29889,
348,
1169,
353,
525,
833,
1092,
29915,
13,
13,
29871,
732,
6799,
13,
29871,
822,
1302,
4339,
29918,
574,
303,
456,
29898,
1311,
1125,
13,
1678,
736,
518,
5441,
29918,
535,
3259,
29889,
833,
1092,
29906,
574,
303,
456,
29898,
29916,
29897,
363,
921,
297,
1583,
29889,
1111,
4339,
29962,
13,
13,
29871,
732,
6799,
13,
29871,
822,
1302,
4339,
29918,
2378,
29898,
1311,
1125,
13,
1678,
565,
451,
756,
5552,
29898,
1311,
29892,
22868,
1111,
4339,
29918,
2749,
29374,
13,
418,
1583,
3032,
1111,
4339,
29918,
2749,
353,
7442,
29889,
2378,
29898,
1311,
29889,
1111,
4339,
29897,
13,
1678,
736,
1583,
3032,
1111,
4339,
29918,
2749,
13,
13,
29871,
732,
6799,
13,
29871,
822,
1543,
29898,
1311,
1125,
13,
1678,
736,
3161,
29889,
14816,
9486,
5607,
29903,
29961,
1311,
29889,
18098,
29962,
13,
13,
13,
1753,
12301,
29898,
18098,
29892,
805,
1144,
29922,
8516,
29892,
8323,
29922,
29900,
1125,
13,
29871,
9995,
11609,
5285,
363,
263,
2323,
12301,
29889,
13,
13,
29871,
826,
3174,
29901,
13,
1678,
5829,
29901,
450,
23489,
5829,
515,
278,
29591,
1591,
13,
1678,
805,
1144,
313,
25253,
1125,
319,
18761,
411,
278,
1353,
310,
10917,
29899,
786,
322,
10917,
29899,
3204,
27149,
13,
1678,
8323,
313,
25253,
1125,
960,
5225,
313,
4381,
511,
1653,
263,
21104,
12301,
29892,
6467,
13,
418,
1653,
385,
385,
291,
565,
8323,
338,
8178,
470,
274,
362,
565,
8323,
338,
6374,
29889,
13,
29871,
16969,
29901,
13,
1678,
319,
1051,
411,
263,
2323,
2180,
290,
1203,
5982,
472,
5225,
29892,
322,
263,
18761,
411,
278,
10917,
13,
1678,
5285,
310,
278,
27149,
29889,
13,
29871,
9995,
13,
29871,
23489,
29918,
4537,
353,
3161,
29889,
14816,
9486,
5607,
29903,
29961,
18098,
1822,
21641,
29918,
4537,
13,
29871,
565,
8323,
1405,
23489,
29918,
4537,
29901,
13,
1678,
12020,
7865,
2392,
877,
29089,
505,
263,
274,
362,
411,
8323,
7200,
1135,
278,
525,
13,
462,
268,
525,
21641,
1353,
29889,
2896,
479,
29901,
24335,
2180,
25426,
9681,
8875,
4286,
4830,
29898,
13,
462,
308,
8323,
29892,
23489,
29918,
4537,
876,
13,
29871,
565,
805,
1144,
338,
6213,
29901,
13,
1678,
10917,
29918,
3733,
279,
4371,
353,
3161,
29889,
1299,
6488,
2965,
29918,
11601,
4345,
29961,
21641,
29918,
4537,
29899,
23367,
1822,
1028,
262,
29918,
2917,
13,
1678,
302,
2312,
353,
313,
21641,
29918,
4537,
718,
10917,
29918,
3733,
279,
4371,
29897,
849,
29871,
29906,
13,
1678,
805,
1144,
353,
313,
29876,
2312,
29892,
23489,
29918,
4537,
448,
8323,
448,
302,
2312,
29897,
13,
29871,
736,
518,
4178,
290,
29898,
18098,
29922,
18098,
29892,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
876,
1402,
805,
1144,
13,
13,
13,
1753,
652,
21641,
29898,
18098,
29896,
29892,
5829,
29906,
29892,
21224,
29918,
2848,
29892,
805,
1144,
29922,
8516,
29892,
8323,
29922,
29900,
29892,
10340,
2433,
833,
1092,
29374,
13,
29871,
9995,
11609,
5285,
363,
263,
652,
21641,
13206,
29883,
1297,
1213,
15945,
13,
29871,
565,
805,
1144,
338,
6213,
29901,
13,
1678,
23489,
29918,
4537,
29918,
29896,
353,
3161,
29889,
14816,
9486,
5607,
29903,
29961,
18098,
29896,
1822,
21641,
29918,
4537,
13,
1678,
23489,
29918,
4537,
29918,
29906,
353,
3161,
29889,
14816,
9486,
5607,
29903,
29961,
18098,
29906,
1822,
21641,
29918,
4537,
13,
1678,
3001,
29918,
23367,
353,
23489,
29918,
4537,
29918,
29896,
718,
23489,
29918,
4537,
29918,
29906,
448,
8323,
13,
1678,
565,
3001,
29918,
23367,
1273,
29871,
29906,
1275,
29871,
29900,
29901,
13,
418,
805,
1144,
353,
313,
7827,
29918,
23367,
849,
29871,
29906,
29892,
3001,
29918,
23367,
849,
29871,
29906,
29897,
13,
1678,
1683,
29901,
13,
418,
805,
1144,
353,
5135,
7827,
29918,
23367,
718,
29871,
29896,
29897,
458,
29871,
29906,
29892,
313,
7827,
29918,
23367,
448,
29871,
29896,
29897,
849,
29871,
29906,
29897,
13,
13,
29871,
736,
518,
13,
418,
2180,
290,
29898,
18098,
29922,
18098,
29896,
29892,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
21224,
29918,
2848,
29914,
29906,
29889,
29900,
511,
10340,
29922,
348,
1169,
511,
13,
418,
2180,
290,
29898,
18098,
29922,
18098,
29906,
29892,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
448,
29890,
898,
29918,
2848,
29914,
29906,
29889,
29900,
511,
10340,
29922,
348,
1169,
29897,
13,
29871,
21251,
805,
1144,
13,
13,
13,
1753,
13206,
29883,
1297,
29898,
18098,
29892,
21224,
29918,
2848,
29922,
29900,
29889,
29900,
29892,
10340,
2433,
833,
1092,
29374,
13,
29871,
9995,
29950,
538,
29659,
13206,
16637,
28855,
2722,
515,
278,
2441,
383,
837,
29875,
12670,
5650,
1213,
15945,
13,
13,
29871,
565,
5829,
297,
652,
21641,
29918,
29890,
898,
29918,
2848,
29879,
29901,
13,
1678,
565,
5829,
14352,
29896,
29962,
1275,
525,
29906,
2396,
13,
418,
5016,
5824,
353,
518,
18098,
7503,
29899,
29896,
1402,
5829,
7503,
29899,
29896,
5262,
13,
1678,
1683,
29901,
29871,
396,
26178,
263,
3949,
295,
29899,
4878,
1347,
373,
278,
1473,
7483,
5497,
13,
418,
6219,
29918,
13140,
353,
6213,
13,
418,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
18098,
22164,
13,
4706,
565,
6219,
29918,
13140,
338,
6213,
322,
5829,
29961,
29875,
1822,
275,
21064,
7295,
13,
3986,
6219,
29918,
13140,
353,
474,
13,
418,
565,
6219,
29918,
13140,
338,
6213,
29901,
13,
4706,
12020,
7865,
2392,
877,
29089,
1284,
1473,
23489,
5829,
29901,
6571,
4286,
4830,
29898,
18098,
876,
13,
418,
5016,
5824,
353,
518,
18098,
7503,
5451,
29918,
13140,
1402,
5829,
29961,
5451,
29918,
13140,
29901,
5262,
13,
13,
1678,
23489,
29918,
4537,
29918,
29896,
353,
3161,
29889,
14816,
9486,
5607,
29903,
29961,
11967,
5824,
29961,
29900,
29962,
1822,
21641,
29918,
4537,
13,
1678,
23489,
29918,
4537,
29918,
29906,
353,
3161,
29889,
14816,
9486,
5607,
29903,
29961,
11967,
5824,
29961,
29896,
29962,
1822,
21641,
29918,
4537,
13,
1678,
3001,
29918,
23367,
353,
23489,
29918,
4537,
29918,
29896,
718,
23489,
29918,
4537,
29918,
29906,
13,
1678,
565,
5829,
297,
652,
21641,
29918,
1028,
262,
29918,
3733,
279,
4371,
29901,
13,
418,
10917,
29918,
3733,
353,
652,
21641,
29918,
1028,
262,
29918,
3733,
279,
4371,
29961,
18098,
29962,
13,
418,
805,
1144,
353,
5135,
7827,
29918,
23367,
718,
10917,
29918,
3733,
29897,
849,
29871,
29906,
29892,
313,
7827,
29918,
23367,
718,
10917,
29918,
3733,
29897,
849,
29871,
29906,
29897,
13,
1678,
25342,
3001,
29918,
23367,
1273,
29871,
29906,
1275,
29871,
29900,
29901,
13,
418,
805,
1144,
353,
313,
7827,
29918,
23367,
849,
29871,
29906,
29892,
3001,
29918,
23367,
849,
29871,
29906,
29897,
13,
1678,
1683,
29901,
13,
418,
805,
1144,
353,
5135,
7827,
29918,
23367,
718,
29871,
29896,
29897,
458,
29871,
29906,
29892,
313,
7827,
29918,
23367,
448,
29871,
29896,
29897,
849,
29871,
29906,
29897,
13,
13,
1678,
565,
21224,
29918,
2848,
1275,
29871,
29900,
29889,
29900,
29901,
13,
418,
21224,
29918,
2848,
353,
652,
21641,
29918,
29890,
898,
29918,
2848,
29879,
29961,
18098,
29962,
13,
418,
10340,
353,
525,
574,
303,
456,
29915,
13,
1678,
736,
652,
21641,
29898,
11967,
5824,
29961,
29900,
1402,
5016,
5824,
29961,
29896,
1402,
13,
462,
1678,
21224,
29918,
2848,
29892,
13,
462,
1678,
10340,
29922,
348,
1169,
29892,
13,
462,
1678,
805,
1144,
29922,
1028,
1144,
29897,
13,
13,
29871,
565,
21224,
29918,
2848,
2804,
29871,
29900,
29889,
29900,
29901,
13,
1678,
12020,
7865,
2392,
877,
29933,
898,
3309,
2980,
871,
8210,
363,
652,
8678,
1199,
29889,
1495,
13,
13,
29871,
565,
5829,
1275,
525,
3210,
29946,
2396,
13,
1678,
736,
518,
13,
4706,
2180,
290,
29898,
18098,
2433,
29907,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
29892,
29871,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
29892,
29871,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
29922,
6278,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
29892,
448,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
29892,
29871,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
29892,
448,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
29892,
448,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
29922,
6278,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
29892,
29871,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
29892,
448,
29896,
29889,
29896,
29947,
29947,
29947,
29953,
511,
10340,
2433,
833,
1092,
5477,
13,
1678,
21251,
313,
29945,
29892,
29871,
29945,
29897,
13,
13,
29871,
565,
5829,
1275,
525,
29940,
29950,
29941,
2396,
13,
1678,
736,
518,
13,
4706,
2180,
290,
29898,
18098,
2433,
29940,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29906,
29906,
29900,
29896,
29941,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29896,
29889,
29955,
29955,
29945,
29947,
29941,
29892,
448,
29900,
29889,
29945,
29896,
29941,
29953,
29946,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29896,
29889,
29945,
29941,
29955,
29929,
29896,
29892,
448,
29900,
29889,
29947,
29947,
29955,
29929,
29896,
29892,
448,
29900,
29889,
29945,
29896,
29941,
29953,
29946,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
29922,
6278,
29896,
29889,
29945,
29941,
29955,
29929,
29896,
29892,
448,
29900,
29889,
29947,
29947,
29955,
29929,
29896,
29892,
448,
29900,
29889,
29945,
29896,
29941,
29953,
29946,
511,
10340,
2433,
833,
1092,
5477,
13,
1678,
21251,
313,
29945,
29892,
29871,
29945,
29897,
13,
13,
29871,
565,
5829,
297,
6702,
29907,
29906,
29950,
29946,
742,
525,
621,
1600,
742,
525,
621,
2904,
1600,
29374,
13,
1678,
736,
518,
13,
4706,
2180,
290,
29898,
18098,
2433,
29907,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29896,
29889,
29906,
29953,
29896,
29941,
29945,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29907,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
448,
29896,
29889,
29906,
29953,
29896,
29941,
29945,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29896,
29889,
29955,
29946,
29941,
29929,
29900,
29892,
29871,
29906,
29889,
29941,
29941,
29947,
29947,
29929,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
448,
29896,
29889,
29955,
29946,
29941,
29929,
29900,
29892,
29871,
29906,
29889,
29941,
29941,
29947,
29947,
29929,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29896,
29889,
29955,
29946,
29941,
29929,
29900,
29892,
448,
29906,
29889,
29941,
29941,
29947,
29947,
29929,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
448,
29896,
29889,
29955,
29946,
29941,
29929,
29900,
29892,
448,
29906,
29889,
29941,
29941,
29947,
29947,
29929,
511,
10340,
2433,
833,
1092,
5477,
13,
1678,
21251,
313,
29947,
29892,
29871,
29947,
29897,
13,
13,
29871,
565,
5829,
297,
6702,
29907,
29946,
29950,
29953,
742,
525,
29890,
4245,
29883,
2127,
329,
1662,
29374,
13,
1678,
736,
518,
13,
4706,
2180,
290,
29898,
18098,
2433,
29907,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29896,
29941,
29955,
29929,
29906,
29892,
29871,
29900,
29889,
29945,
29947,
29953,
29953,
29896,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29907,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
448,
29906,
29889,
29896,
29941,
29955,
29929,
29906,
29892,
29871,
29900,
29889,
29945,
29947,
29953,
29953,
29896,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29907,
742,
1302,
4339,
7607,
29896,
29889,
29946,
29896,
29941,
29946,
29906,
29892,
29871,
29900,
29889,
29900,
29892,
448,
29900,
29889,
29945,
29947,
29929,
29906,
29946,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29907,
742,
1302,
4339,
29922,
6278,
29896,
29889,
29946,
29896,
29941,
29946,
29906,
29892,
29871,
29900,
29889,
29900,
29892,
448,
29900,
29889,
29945,
29947,
29929,
29906,
29946,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29941,
29941,
29955,
29953,
29945,
29892,
29871,
29906,
29889,
29953,
29946,
29896,
29896,
29900,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29941,
29889,
29929,
29906,
29945,
29953,
29953,
29892,
448,
29900,
29889,
29946,
29941,
29900,
29906,
29941,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
448,
29906,
29889,
29941,
29941,
29955,
29953,
29945,
29892,
29871,
29906,
29889,
29953,
29946,
29896,
29896,
29900,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
448,
29941,
29889,
29929,
29906,
29945,
29953,
29953,
29892,
448,
29900,
29889,
29946,
29941,
29900,
29906,
29941,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29906,
29889,
29953,
29955,
29906,
29947,
29945,
29892,
29871,
29900,
29889,
29900,
29892,
448,
29906,
29889,
29896,
29929,
29945,
29896,
29946,
511,
10340,
2433,
833,
1092,
5477,
13,
4706,
2180,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
29922,
6278,
29906,
29889,
29953,
29955,
29906,
29947,
29945,
29892,
29871,
29900,
29889,
29900,
29892,
448,
29906,
29889,
29896,
29929,
29945,
29896,
29946,
511,
10340,
2433,
833,
1092,
5477,
13,
1678,
21251,
313,
29896,
29945,
29892,
29871,
29896,
29945,
29897,
13,
13,
29871,
12020,
7865,
2392,
877,
3664,
263,
14831,
13206,
29883,
1297,
29901,
6571,
4286,
4830,
29898,
18098,
876,
13,
13,
13,
1753,
298,
29876,
29898,
29876,
29892,
364,
29892,
8323,
29922,
29900,
29892,
10340,
2433,
833,
1092,
29374,
13,
29871,
9995,
11609,
263,
17546,
1885,
9704,
411,
302,
28422,
322,
23683,
364,
1213,
15945,
13,
29871,
286,
353,
302,
448,
8323,
29871,
396,
1353,
310,
27149,
13,
29871,
565,
286,
1273,
29871,
29906,
1275,
29871,
29900,
29901,
13,
1678,
805,
1144,
353,
313,
29885,
458,
29906,
29892,
286,
458,
29906,
29897,
13,
29871,
1683,
29901,
13,
1678,
805,
1144,
353,
5135,
29885,
29974,
29896,
29897,
458,
29906,
29892,
313,
29885,
29899,
29896,
29897,
458,
29906,
29897,
13,
29871,
2485,
353,
364,
334,
313,
29876,
29899,
29896,
29897,
847,
29871,
29906,
29889,
29900,
13,
29871,
736,
518,
4178,
290,
29898,
18098,
2433,
29950,
742,
1302,
4339,
7607,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
503,
511,
10340,
29922,
348,
1169,
29897,
13,
3986,
363,
503,
297,
7442,
29889,
1915,
3493,
6278,
2576,
29892,
2485,
29892,
302,
29897,
1402,
805,
1144,
13,
13,
13,
1753,
298,
29946,
29918,
16622,
29898,
29878,
29892,
278,
941,
29892,
10340,
2433,
833,
1092,
29374,
13,
29871,
9995,
11609,
29871,
29946,
17546,
1885,
28422,
21050,
297,
263,
8607,
29892,
263,
10672,
1206,
310,
19178,
7230,
29898,
29911,
467,
15945,
29908,
13,
29871,
736,
518,
13,
418,
2180,
290,
29898,
18098,
2433,
29950,
742,
13,
965,
1302,
4339,
7607,
29878,
29930,
9302,
29889,
3944,
29898,
3416,
511,
364,
29930,
9302,
29889,
5223,
29898,
3416,
511,
29871,
29900,
29889,
29900,
511,
13,
965,
10340,
29922,
348,
1169,
511,
13,
418,
2180,
290,
29898,
18098,
2433,
29950,
742,
13,
965,
1302,
4339,
29922,
6278,
29878,
29930,
9302,
29889,
3944,
29898,
3416,
511,
364,
29930,
9302,
29889,
5223,
29898,
3416,
511,
29871,
29900,
29889,
29900,
511,
13,
965,
10340,
29922,
348,
1169,
511,
13,
418,
2180,
290,
29898,
18098,
2433,
29950,
742,
13,
965,
1302,
4339,
7607,
29878,
29930,
9302,
29889,
3944,
29898,
3416,
511,
448,
29878,
29930,
9302,
29889,
5223,
29898,
3416,
511,
29871,
29900,
29889,
29900,
511,
13,
965,
10340,
29922,
348,
1169,
511,
13,
418,
2180,
290,
29898,
18098,
2433,
29950,
742,
13,
965,
1302,
4339,
29922,
6278,
29878,
29930,
9302,
29889,
3944,
29898,
3416,
511,
448,
29878,
29930,
9302,
29889,
5223,
29898,
3416,
511,
29871,
29900,
29889,
29900,
511,
13,
965,
10340,
29922,
348,
1169,
29897,
13,
29871,
21251,
313,
29906,
29892,
29871,
29906,
29897,
13,
2
] |
weekly/lambdas/copy-file-to-public-bucket/copy_file_to_public_bucket.py | visual-ds/cities-reports | 0 | 132456 | import json
import boto3
from urllib import parse
s3 = boto3.client('s3')
def get_target_key(source_key):
### defining file key (prefix + filename)
city, year, month, day, query = ['']*5
for s in source_key.split('/'):
city = s if 'city' in s else city
year = s if 'year' in s else year
month = s if 'month' in s else month
day = s if 'day' in s else day
query = s.split('=')[-1] if 'query' in s else query
city = city.replace("ã", "a")
prefix = '/'.join(map(lambda x: x.split('=')[-1].zfill(2), ['exports/reports/weekly',year, month, day, city])) + '/'
if source_key[-3:] == 'csv':
name = '-'.join(map(lambda x: x.split('=')[-1].zfill(2), [year, month, day, 'fgv-bid', city, query+'.csv']))
elif source_key[-3:] == 'pdf':
name = source_key.split('/')[-1]
return prefix + name
def lambda_handler(event, context):
source_bucket = event['Records'][0]['s3']['bucket']['name']
source_key = parse.unquote_plus(event['Records'][0]['s3']['object']['key'])
copy_source = {'Bucket': source_bucket, 'Key': source_key}
waiter = s3.get_waiter('object_exists')
waiter.wait(Bucket=source_bucket, Key=source_key)
target_bucket = 'bd-fgv-public'
target_key = get_target_key(source_key)
### coping files
s3.copy_object(Bucket=target_bucket, Key=target_key,
CopySource=copy_source, ACL='public-read')
| [
1,
1053,
4390,
13,
5215,
29871,
289,
3747,
29941,
13,
3166,
3142,
1982,
1053,
6088,
13,
13,
29879,
29941,
353,
289,
3747,
29941,
29889,
4645,
877,
29879,
29941,
1495,
13,
13,
1753,
679,
29918,
5182,
29918,
1989,
29898,
4993,
29918,
1989,
1125,
13,
268,
13,
1678,
835,
16184,
934,
1820,
313,
13506,
718,
10422,
29897,
13,
1678,
4272,
29892,
1629,
29892,
4098,
29892,
2462,
29892,
2346,
353,
6024,
2033,
29930,
29945,
13,
1678,
363,
269,
297,
2752,
29918,
1989,
29889,
5451,
11219,
29374,
13,
4706,
4272,
353,
269,
565,
525,
12690,
29915,
297,
269,
1683,
4272,
13,
4706,
1629,
353,
269,
565,
525,
6360,
29915,
297,
269,
1683,
1629,
13,
4706,
4098,
353,
269,
565,
525,
10874,
29915,
297,
269,
1683,
4098,
13,
4706,
2462,
353,
269,
565,
525,
3250,
29915,
297,
269,
1683,
2462,
13,
4706,
2346,
353,
269,
29889,
5451,
877,
29922,
1495,
14352,
29896,
29962,
565,
525,
1972,
29915,
297,
269,
1683,
2346,
13,
308,
13,
1678,
4272,
353,
4272,
29889,
6506,
703,
30033,
613,
376,
29874,
1159,
13,
268,
13,
1678,
10944,
353,
8207,
4286,
7122,
29898,
1958,
29898,
2892,
921,
29901,
921,
29889,
5451,
877,
29922,
1495,
14352,
29896,
1822,
29920,
5589,
29898,
29906,
511,
6024,
26500,
29914,
276,
4011,
29914,
18448,
368,
742,
6360,
29892,
4098,
29892,
2462,
29892,
4272,
12622,
718,
8207,
29915,
13,
268,
13,
1678,
565,
2752,
29918,
1989,
14352,
29941,
17531,
1275,
525,
7638,
2396,
13,
4706,
1024,
353,
17411,
4286,
7122,
29898,
1958,
29898,
2892,
921,
29901,
921,
29889,
5451,
877,
29922,
1495,
14352,
29896,
1822,
29920,
5589,
29898,
29906,
511,
518,
6360,
29892,
4098,
29892,
2462,
29892,
525,
16434,
29894,
29899,
23883,
742,
4272,
29892,
2346,
29974,
4286,
7638,
25901,
13,
1678,
25342,
2752,
29918,
1989,
14352,
29941,
17531,
1275,
525,
5140,
2396,
13,
4706,
1024,
353,
2752,
29918,
1989,
29889,
5451,
11219,
1495,
14352,
29896,
29962,
13,
308,
13,
1678,
736,
10944,
718,
1024,
13,
13,
13,
1753,
14013,
29918,
13789,
29898,
3696,
29892,
3030,
1125,
13,
268,
13,
1678,
2752,
29918,
21454,
353,
1741,
1839,
4789,
4339,
2033,
29961,
29900,
22322,
29879,
29941,
16215,
21454,
16215,
978,
2033,
13,
1678,
2752,
29918,
1989,
353,
6088,
29889,
348,
1396,
29918,
11242,
29898,
3696,
1839,
4789,
4339,
2033,
29961,
29900,
22322,
29879,
29941,
16215,
3318,
16215,
1989,
11287,
13,
1678,
3509,
29918,
4993,
353,
11117,
29933,
2707,
300,
2396,
2752,
29918,
21454,
29892,
525,
2558,
2396,
2752,
29918,
1989,
29913,
13,
268,
13,
1678,
4480,
261,
353,
269,
29941,
29889,
657,
29918,
10685,
261,
877,
3318,
29918,
9933,
1495,
13,
1678,
4480,
261,
29889,
10685,
29898,
29933,
2707,
300,
29922,
4993,
29918,
21454,
29892,
7670,
29922,
4993,
29918,
1989,
29897,
13,
268,
13,
1678,
3646,
29918,
21454,
353,
525,
6448,
29899,
16434,
29894,
29899,
3597,
29915,
13,
1678,
3646,
29918,
1989,
353,
679,
29918,
5182,
29918,
1989,
29898,
4993,
29918,
1989,
29897,
13,
268,
13,
1678,
835,
5614,
292,
2066,
13,
1678,
269,
29941,
29889,
8552,
29918,
3318,
29898,
29933,
2707,
300,
29922,
5182,
29918,
21454,
29892,
7670,
29922,
5182,
29918,
1989,
29892,
29871,
13,
462,
1678,
14187,
4435,
29922,
8552,
29918,
4993,
29892,
319,
6154,
2433,
3597,
29899,
949,
1495,
13,
268,
2
] |
dex-net/src/dexnet/database/keys.py | peter0749/PointNetGPD | 193 | 86996 | <gh_stars>100-1000
# -*- coding: utf-8 -*-
"""
Copyright ©2017. The Regents of the University of California (Regents). All Rights Reserved.
Permission to use, copy, modify, and distribute this software and its documentation for educational,
research, and not-for-profit purposes, without fee and without a signed licensing agreement, is
hereby granted, provided that the above copyright notice, this paragraph and the following two
paragraphs appear in all copies, modifications, and distributions. Contact The Office of Technology
Licensing, UC Berkeley, 2150 Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620, (510) 643-
7201, <EMAIL>, http://ipira.berkeley.edu/industry-info for commercial licensing opportunities.
IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF
THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
"""
# Keys for easy lookups in HDF5 databases
METRICS_KEY = 'metrics'
OBJECTS_KEY = 'objects'
MESH_KEY = 'mesh'
SDF_KEY = 'sdf'
GRASPS_KEY = 'grasps'
GRIPPERS_KEY = 'grippers'
NUM_GRASPS_KEY = 'num_grasps'
LOCAL_FEATURES_KEY = 'local_features'
GLOBAL_FEATURES_KEY = 'global_features'
SHOT_FEATURES_KEY = 'shot'
RENDERED_IMAGES_KEY = 'rendered_images'
SENSOR_DATA_KEY = 'sensor_data'
STP_KEY = 'stable_poses'
CATEGORY_KEY = 'category'
MASS_KEY = 'mass'
CONVEX_PIECES_KEY = 'convex_pieces'
CREATION_KEY = 'time_created'
DATASETS_KEY = 'datasets'
DATASET_KEY = 'dataset'
# data keys for easy access
SDF_DATA_KEY = 'data'
SDF_ORIGIN_KEY = 'origin'
SDF_RES_KEY = 'resolution'
SDF_POSE_KEY = 'pose'
SDF_SCALE_KEY = 'scale'
SDF_FRAME_KEY = 'frame'
MESH_VERTICES_KEY = 'vertices'
MESH_TRIANGLES_KEY = 'triangles'
MESH_NORMALS_KEY = 'normals'
MESH_POSE_KEY = 'pose'
MESH_SCALE_KEY = 'scale'
MESH_DENSITY_KEY = 'density'
LOCAL_FEATURE_NUM_FEAT_KEY = 'num_features'
LOCAL_FEATURE_DESC_KEY = 'descriptors'
LOCAL_FEATURE_RF_KEY = 'rfs'
LOCAL_FEATURE_POINT_KEY = 'points'
LOCAL_FEATURE_NORMAL_KEY = 'normals'
SHOT_FEATURES_KEY = 'shot'
FEATURE_KEY = 'feature'
NUM_STP_KEY = 'num_stable_poses'
POSE_KEY = 'pose'
STABLE_POSE_PROB_KEY = 'p'
STABLE_POSE_ROT_KEY = 'r'
STABLE_POSE_PT_KEY = 'x0'
NUM_GRASPS_KEY = 'num_grasps'
GRASP_KEY = 'grasp'
GRASP_ID_KEY = 'id'
GRASP_TYPE_KEY = 'type'
GRASP_CONFIGURATION_KEY = 'configuration'
GRASP_RF_KEY = 'frame'
GRASP_TIMESTAMP_KEY = 'timestamp'
GRASP_METRICS_KEY = 'metrics'
GRASP_FEATURES_KEY = 'features'
GRASP_FEATURE_NAME_KEY = 'name'
GRASP_FEATURE_TYPE_KEY = 'type'
GRASP_FEATURE_VECTOR_KEY = 'vector'
NUM_IMAGES_KEY = 'num_images'
IMAGE_KEY = 'image'
IMAGE_DATA_KEY = 'image_data'
IMAGE_FRAME_KEY = 'image_frame'
CAM_POS_KEY = 'cam_pos'
CAM_ROT_KEY = 'cam_rot'
CAM_INT_PT_KEY = 'cam_int_pt'
CAM_FRAME_KEY = 'cam_frame'
# Extras
RENDERED_IMAGE_TYPES = ['segmask', 'depth', 'scaled_depth']
# Metadata
METADATA_KEY = 'metadata'
METADATA_TYPE_KEY = 'type'
METADATA_DESC_KEY = 'description'
METADATA_FUNC_KEY = 'func'
# Connected components
CONNECTED_COMPONENTS_KEY = 'connected_components'
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29900,
29899,
29896,
29900,
29900,
29900,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
15945,
29908,
13,
11882,
1266,
29871,
30211,
29906,
29900,
29896,
29955,
29889,
450,
2169,
1237,
310,
278,
3014,
310,
8046,
313,
4597,
1237,
467,
2178,
26863,
2538,
9841,
29889,
13,
27293,
304,
671,
29892,
3509,
29892,
6623,
29892,
322,
1320,
2666,
445,
7047,
322,
967,
5106,
363,
28976,
29892,
13,
690,
2842,
29892,
322,
451,
29899,
1454,
29899,
771,
9202,
11976,
29892,
1728,
27684,
322,
1728,
263,
8794,
7794,
575,
292,
17327,
29892,
338,
13,
4150,
1609,
16896,
29892,
4944,
393,
278,
2038,
3509,
1266,
8369,
29892,
445,
14880,
322,
278,
1494,
1023,
13,
26956,
29879,
2615,
297,
599,
14591,
29892,
26278,
29892,
322,
18822,
29889,
22387,
450,
11367,
310,
17968,
13,
29931,
293,
575,
292,
29892,
501,
29907,
2292,
27279,
29892,
29871,
29906,
29896,
29945,
29900,
1383,
1131,
2707,
18874,
29892,
2166,
568,
29871,
29945,
29896,
29900,
29892,
2292,
27279,
29892,
12766,
29871,
29929,
29946,
29955,
29906,
29900,
29899,
29896,
29953,
29906,
29900,
29892,
313,
29945,
29896,
29900,
29897,
29871,
29953,
29946,
29941,
29899,
13,
29955,
29906,
29900,
29896,
29892,
529,
26862,
6227,
10202,
1732,
597,
666,
3055,
29889,
495,
27279,
29889,
6085,
29914,
20041,
719,
29899,
3888,
363,
12128,
7794,
575,
292,
28602,
1907,
29889,
13,
13,
1177,
11698,
382,
29963,
3919,
24972,
9818,
5195,
29954,
3919,
29903,
20700,
17705,
6181,
7495,
13764,
29979,
349,
8322,
29979,
15842,
22471,
26282,
29892,
2672,
4571,
26282,
29892,
317,
4162,
8426,
1964,
29892,
13,
1177,
29907,
1367,
3919,
1964,
29892,
6323,
8707,
1660,
13356,
3919,
25758,
21330,
1529,
1692,
29903,
29892,
2672,
6154,
15789,
4214,
365,
3718,
13756,
29943,
1806,
29903,
29892,
9033,
3235,
4214,
19474,
8079,
13,
28350,
501,
1660,
8079,
3446,
3235,
7791,
7818,
12982,
1525,
5300,
306,
9375,
11662,
29907,
5005,
3919,
8098,
29892,
382,
29963,
1430,
10762,
5195,
29954,
3919,
29903,
379,
3289,
20700,
1430,
13,
3035,
18118,
1660,
29928,
8079,
6093,
21521,
1799,
8979,
6227,
11937,
8079,
20134,
3210,
21330,
1529,
1692,
29889,
13,
13,
18166,
3919,
29903,
317,
4162,
29907,
6545,
2965,
9818,
29979,
28657,
13875,
29902,
4345,
13764,
29979,
399,
1718,
29934,
13566,
29059,
29892,
2672,
6154,
15789,
4214,
29892,
350,
2692,
6058,
27848,
3352,
7495,
29892,
13,
28350,
306,
3580,
5265,
3352,
399,
1718,
29934,
13566,
29059,
8079,
341,
1001,
3210,
13566,
2882,
6227,
11937,
5300,
383,
1806,
8186,
1799,
15842,
319,
349,
8322,
2965,
13309,
1718,
13,
29925,
4574,
13152,
1660,
29889,
6093,
7791,
7818,
12982,
1525,
5300,
14614,
21514,
2190,
29979,
4214,
11662,
29907,
5005,
3919,
8098,
29892,
10762,
13764,
29979,
29892,
13756,
13044,
3352,
13,
5006,
18783,
1001,
8519,
13756,
13044,
3352,
376,
3289,
8519,
1642,
5195,
29954,
3919,
29903,
379,
3289,
11698,
438,
29933,
5265,
29954,
8098,
7495,
13756,
13044,
29923,
13,
1529,
10192,
1430,
23219,
29892,
317,
4897,
15082,
29892,
11901,
25832,
2890,
29892,
12524,
29950,
23219,
13780,
29903,
29892,
6323,
16999,
4571,
29943,
28541,
29903,
29889,
13,
15945,
29908,
13,
29937,
4813,
952,
363,
4780,
1106,
14340,
297,
379,
4037,
29945,
21218,
13,
2303,
5659,
2965,
29903,
29918,
10818,
353,
525,
2527,
10817,
29915,
13,
14824,
17637,
29903,
29918,
10818,
353,
525,
12650,
29915,
13,
2303,
7068,
29918,
10818,
353,
525,
4467,
29882,
29915,
13,
29903,
4037,
29918,
10818,
353,
525,
29879,
2176,
29915,
13,
14345,
3289,
7024,
29918,
10818,
353,
525,
629,
294,
567,
29915,
13,
29954,
3960,
29925,
13171,
29903,
29918,
10818,
353,
525,
29887,
374,
22437,
29915,
13,
13967,
29918,
14345,
3289,
7024,
29918,
10818,
353,
525,
1949,
29918,
629,
294,
567,
29915,
13,
16652,
1964,
29918,
16359,
1299,
11499,
29903,
29918,
10818,
353,
525,
2997,
29918,
22100,
29915,
13,
29954,
28902,
1964,
29918,
16359,
1299,
11499,
29903,
29918,
10818,
353,
525,
10945,
29918,
22100,
29915,
13,
7068,
2891,
29918,
16359,
1299,
11499,
29903,
29918,
10818,
353,
525,
8962,
29915,
13,
29934,
1430,
8032,
3352,
29918,
2382,
29903,
29918,
10818,
353,
525,
9482,
287,
29918,
8346,
29915,
13,
29903,
1430,
29903,
1955,
29918,
14573,
29918,
10818,
353,
525,
29879,
6073,
29918,
1272,
29915,
13,
1254,
29925,
29918,
10818,
353,
525,
13844,
29918,
10590,
29915,
13,
29907,
3040,
29954,
18929,
29918,
10818,
353,
525,
7320,
29915,
13,
1529,
1799,
29918,
10818,
353,
525,
25379,
29915,
13,
6007,
29963,
5746,
29918,
2227,
11206,
2890,
29918,
10818,
353,
525,
535,
13809,
29918,
12343,
778,
29915,
13,
13,
22245,
8098,
29918,
10818,
353,
525,
2230,
29918,
11600,
29915,
13,
25832,
8127,
9375,
29918,
10818,
353,
525,
14538,
1691,
29915,
13,
25832,
8127,
29911,
29918,
10818,
353,
525,
24713,
29915,
13,
13,
29937,
848,
6611,
363,
4780,
2130,
13,
29903,
4037,
29918,
14573,
29918,
10818,
353,
525,
1272,
29915,
13,
29903,
4037,
29918,
1955,
6259,
1177,
29918,
10818,
353,
525,
12574,
29915,
13,
29903,
4037,
29918,
15989,
29918,
10818,
353,
525,
9778,
918,
29915,
13,
29903,
4037,
29918,
13152,
1660,
29918,
10818,
353,
525,
4220,
29915,
13,
29903,
4037,
29918,
29903,
5454,
1307,
29918,
10818,
353,
525,
7052,
29915,
13,
29903,
4037,
29918,
29943,
4717,
2303,
29918,
10818,
353,
525,
2557,
29915,
13,
13,
2303,
7068,
29918,
5348,
29911,
2965,
2890,
29918,
10818,
353,
525,
1765,
1575,
29915,
13,
2303,
7068,
29918,
29911,
3960,
19453,
17101,
29918,
10818,
353,
525,
3626,
19536,
29915,
13,
2303,
7068,
29918,
29940,
1955,
1529,
8547,
29918,
10818,
353,
525,
12324,
1338,
29915,
13,
2303,
7068,
29918,
13152,
1660,
29918,
10818,
353,
525,
4220,
29915,
13,
2303,
7068,
29918,
29903,
5454,
1307,
29918,
10818,
353,
525,
7052,
29915,
13,
2303,
7068,
29918,
29928,
1430,
29903,
11937,
29918,
10818,
353,
525,
21518,
537,
29915,
13,
13,
16652,
1964,
29918,
16359,
1299,
11499,
29918,
13967,
29918,
16359,
1299,
29918,
10818,
353,
525,
1949,
29918,
22100,
29915,
13,
16652,
1964,
29918,
16359,
1299,
11499,
29918,
2287,
7187,
29918,
10818,
353,
525,
2783,
924,
943,
29915,
13,
16652,
1964,
29918,
16359,
1299,
11499,
29918,
29934,
29943,
29918,
10818,
353,
525,
29878,
5847,
29915,
13,
16652,
1964,
29918,
16359,
1299,
11499,
29918,
29925,
6992,
29911,
29918,
10818,
353,
525,
9748,
29915,
13,
16652,
1964,
29918,
16359,
1299,
11499,
29918,
29940,
1955,
1529,
29931,
29918,
10818,
353,
525,
12324,
1338,
29915,
13,
7068,
2891,
29918,
16359,
1299,
11499,
29903,
29918,
10818,
353,
525,
8962,
29915,
13,
16359,
1299,
11499,
29918,
10818,
353,
525,
14394,
29915,
13,
13,
13967,
29918,
1254,
29925,
29918,
10818,
353,
525,
1949,
29918,
13844,
29918,
10590,
29915,
13,
13152,
1660,
29918,
10818,
353,
525,
4220,
29915,
13,
1254,
6181,
29918,
13152,
1660,
29918,
8618,
29933,
29918,
10818,
353,
525,
29886,
29915,
13,
1254,
6181,
29918,
13152,
1660,
29918,
1672,
29911,
29918,
10818,
353,
525,
29878,
29915,
13,
1254,
6181,
29918,
13152,
1660,
29918,
7982,
29918,
10818,
353,
525,
29916,
29900,
29915,
13,
13,
13967,
29918,
14345,
3289,
7024,
29918,
10818,
353,
525,
1949,
29918,
629,
294,
567,
29915,
13,
14345,
3289,
29925,
29918,
10818,
353,
525,
629,
4692,
29915,
13,
14345,
3289,
29925,
29918,
1367,
29918,
10818,
353,
525,
333,
29915,
13,
14345,
3289,
29925,
29918,
11116,
29918,
10818,
353,
525,
1853,
29915,
13,
14345,
3289,
29925,
29918,
25903,
4574,
8098,
29918,
10818,
353,
525,
13305,
29915,
13,
14345,
3289,
29925,
29918,
29934,
29943,
29918,
10818,
353,
525,
2557,
29915,
13,
14345,
3289,
29925,
29918,
15307,
1254,
19297,
29918,
10818,
353,
525,
16394,
29915,
13,
14345,
3289,
29925,
29918,
2303,
5659,
2965,
29903,
29918,
10818,
353,
525,
2527,
10817,
29915,
13,
14345,
3289,
29925,
29918,
16359,
1299,
11499,
29903,
29918,
10818,
353,
525,
22100,
29915,
13,
13,
14345,
3289,
29925,
29918,
16359,
1299,
11499,
29918,
5813,
29918,
10818,
353,
525,
978,
29915,
13,
14345,
3289,
29925,
29918,
16359,
1299,
11499,
29918,
11116,
29918,
10818,
353,
525,
1853,
29915,
13,
14345,
3289,
29925,
29918,
16359,
1299,
11499,
29918,
12064,
1783,
1955,
29918,
10818,
353,
525,
8111,
29915,
13,
13,
13967,
29918,
2382,
29903,
29918,
10818,
353,
525,
1949,
29918,
8346,
29915,
13,
2382,
29918,
10818,
353,
525,
3027,
29915,
13,
2382,
29918,
14573,
29918,
10818,
353,
525,
3027,
29918,
1272,
29915,
13,
2382,
29918,
29943,
4717,
2303,
29918,
10818,
353,
525,
3027,
29918,
2557,
29915,
13,
29907,
5194,
29918,
24815,
29918,
10818,
353,
525,
11108,
29918,
1066,
29915,
13,
29907,
5194,
29918,
1672,
29911,
29918,
10818,
353,
525,
11108,
29918,
5450,
29915,
13,
29907,
5194,
29918,
10192,
29918,
7982,
29918,
10818,
353,
525,
11108,
29918,
524,
29918,
415,
29915,
13,
29907,
5194,
29918,
29943,
4717,
2303,
29918,
10818,
353,
525,
11108,
29918,
2557,
29915,
13,
13,
29937,
7338,
3417,
13,
29934,
1430,
8032,
3352,
29918,
2382,
29918,
15631,
29925,
2890,
353,
6024,
10199,
13168,
742,
525,
19488,
742,
525,
7052,
29881,
29918,
19488,
2033,
13,
13,
29937,
4737,
7221,
13,
2303,
29911,
3035,
8254,
29918,
10818,
353,
525,
19635,
29915,
13,
2303,
29911,
3035,
8254,
29918,
11116,
29918,
10818,
353,
525,
1853,
29915,
13,
2303,
29911,
3035,
8254,
29918,
2287,
7187,
29918,
10818,
353,
525,
8216,
29915,
13,
2303,
29911,
3035,
8254,
29918,
29943,
3904,
29907,
29918,
10818,
353,
525,
9891,
29915,
13,
13,
29937,
1281,
484,
2954,
7117,
13,
6007,
8186,
1783,
3352,
29918,
21514,
1164,
3919,
29903,
29918,
10818,
353,
525,
18045,
29918,
14036,
29915,
13,
2
] |
bke/bke_client/forms.py | Ntermast/BKE | 0 | 53058 | <reponame>Ntermast/BKE<filename>bke/bke_client/forms.py
from django import forms
from django.core.validators import FileExtensionValidator
from .models import Channel, Podcast
class ChannelForm(forms.ModelForm):
image = forms.ImageField(required=True)
class Meta:
model = Channel
fields = ('image',)
class PodcastForm(forms.ModelForm):
image = forms.ImageField(required=True)
file = forms.FileField(required=True, validators=[FileExtensionValidator(
allowed_extensions=['mp3'])])
class Meta:
model = Podcast
fields = ('image', 'file')
class PodcastImageForm(forms.ModelForm):
image = forms.ImageField(required=True)
class Meta:
model = Podcast
fields = ('image',)
class PodcastFileForm(forms.ModelForm):
file = forms.FileField(required=True, validators=[FileExtensionValidator(
allowed_extensions=['mp3'])])
class Meta:
model = Podcast
fields = ('file',)
| [
1,
529,
276,
1112,
420,
29958,
29940,
8489,
579,
29914,
29933,
6059,
29966,
9507,
29958,
29890,
446,
29914,
29890,
446,
29918,
4645,
29914,
9514,
29889,
2272,
13,
3166,
9557,
1053,
7190,
13,
3166,
9557,
29889,
3221,
29889,
3084,
4097,
1053,
3497,
17657,
24204,
13,
3166,
869,
9794,
1053,
17368,
29892,
8594,
4384,
13,
13,
13,
1990,
17368,
2500,
29898,
9514,
29889,
3195,
2500,
1125,
13,
1678,
1967,
353,
7190,
29889,
2940,
3073,
29898,
12403,
29922,
5574,
29897,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
1904,
353,
17368,
13,
4706,
4235,
353,
6702,
3027,
742,
29897,
13,
13,
13,
1990,
8594,
4384,
2500,
29898,
9514,
29889,
3195,
2500,
1125,
13,
1678,
1967,
353,
7190,
29889,
2940,
3073,
29898,
12403,
29922,
5574,
29897,
13,
1678,
934,
353,
7190,
29889,
2283,
3073,
29898,
12403,
29922,
5574,
29892,
29871,
2854,
4097,
11759,
2283,
17657,
24204,
29898,
13,
4706,
6068,
29918,
24299,
29922,
1839,
1526,
29941,
11287,
2314,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
1904,
353,
8594,
4384,
13,
4706,
4235,
353,
6702,
3027,
742,
525,
1445,
1495,
13,
13,
13,
1990,
8594,
4384,
2940,
2500,
29898,
9514,
29889,
3195,
2500,
1125,
13,
1678,
1967,
353,
7190,
29889,
2940,
3073,
29898,
12403,
29922,
5574,
29897,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
1904,
353,
8594,
4384,
13,
4706,
4235,
353,
6702,
3027,
742,
29897,
13,
13,
13,
1990,
8594,
4384,
2283,
2500,
29898,
9514,
29889,
3195,
2500,
1125,
13,
1678,
934,
353,
7190,
29889,
2283,
3073,
29898,
12403,
29922,
5574,
29892,
29871,
2854,
4097,
11759,
2283,
17657,
24204,
29898,
13,
4706,
6068,
29918,
24299,
29922,
1839,
1526,
29941,
11287,
2314,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
1904,
353,
8594,
4384,
13,
4706,
4235,
353,
6702,
1445,
742,
29897,
13,
2
] |
cen/models/__init__.py | slabbaki/discriminative-subtyping | 1 | 125651 | <gh_stars>1-10
from . import baseline
from . import cen
from . import moe
def get(name, **kwargs):
if name == "baseline":
build_model = baseline.build_model
elif name == "cen":
build_model = cen.build_model
elif name == "moe":
build_model = moe.build_model
else:
raise ValueError(f"Unknown model name: {name}.")
return build_model(**kwargs)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
3166,
869,
1053,
2362,
5570,
13,
3166,
869,
1053,
274,
264,
13,
3166,
869,
1053,
2730,
29872,
13,
13,
13,
1753,
679,
29898,
978,
29892,
3579,
19290,
1125,
13,
1678,
565,
1024,
1275,
376,
6500,
5570,
1115,
13,
4706,
2048,
29918,
4299,
353,
2362,
5570,
29889,
4282,
29918,
4299,
13,
1678,
25342,
1024,
1275,
376,
10278,
1115,
13,
4706,
2048,
29918,
4299,
353,
274,
264,
29889,
4282,
29918,
4299,
13,
1678,
25342,
1024,
1275,
376,
4346,
29872,
1115,
13,
4706,
2048,
29918,
4299,
353,
2730,
29872,
29889,
4282,
29918,
4299,
13,
1678,
1683,
29901,
13,
4706,
12020,
7865,
2392,
29898,
29888,
29908,
14148,
1904,
1024,
29901,
426,
978,
1836,
1159,
13,
13,
1678,
736,
2048,
29918,
4299,
29898,
1068,
19290,
29897,
13,
2
] |
email_image.py | syncom/emailimg-rpi | 1 | 1613023 | <reponame>syncom/emailimg-rpi
#!/usr/bin/env python
"""Email an image to a prescribed address
This module emails an image file to a pre-configured address
"""
import os
import time
import argparse
import smtplib
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
# Tested for @outlook.com and @sina.com emails
config_file = os.path.dirname(os.path.realpath(__file__)) + '/.config'
def send_email_with_image(img_filepath, subject):
"""
This function loads email configuration from a file, and sends the
captured image to (and from) this email address as an attachment.
"""
[smtp_server, smtp_port, username, password] = get_config_info()
from_address = username
to_address = username
image_data = open(img_filepath, 'rb').read()
msg = MIMEMultipart()
msg['Subject'] = subject
msg['From'] = from_address
msg['To'] = to_address
text = MIMEText(subject)
msg.attach(text)
image = MIMEImage(image_data, name=os.path.basename(img_filepath))
msg.attach(image)
s = smtplib.SMTP(smtp_server, smtp_port)
s.ehlo()
s.starttls()
s.ehlo()
s.login(username, password)
s.sendmail(from_address, to_address, msg.as_string())
s.quit()
def get_config_info():
''' Obtain SMTP server info from file .config
Returns list
'''
f = open(config_file, 'rb')
c = f.read()
t = c.splitlines()
return t[0:4]
def get_mtime_str(fil):
''' Obtain file modification time string.
Return str
'''
try:
mtime = os.path.getmtime(fil)
except OSError:
return ''
is_dst = time.daylight and time.localtime().tm_isdst > 0
# UTC offset in seconds
offset = - (time.altzone if is_dst else time.timezone)
time_str = time.ctime(mtime) + ' UTC ' + str(offset/3600)
return time_str
def do_email(img_filepath):
'''Email, image modification time as subject and image as attachment
'''
subject = get_mtime_str(img_filepath)
if not subject:
print "Something has gone wrong. No email was sent."
else:
send_email_with_image(img_filepath, subject)
print "Emailed image taken at " + subject
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("filepath")
args = parser.parse_args()
do_email(args.filepath)
| [
1,
529,
276,
1112,
420,
29958,
19274,
510,
29914,
5269,
2492,
29899,
29878,
1631,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
13,
13,
15945,
29908,
9823,
385,
1967,
304,
263,
2225,
23059,
3211,
13,
4013,
3883,
24609,
385,
1967,
934,
304,
263,
758,
29899,
2917,
2955,
3211,
13,
15945,
29908,
13,
13,
5215,
2897,
13,
5215,
931,
13,
5215,
1852,
5510,
13,
5215,
1560,
9392,
1982,
13,
3166,
4876,
29889,
29885,
603,
29889,
726,
1053,
341,
8890,
1626,
13,
3166,
4876,
29889,
29885,
603,
29889,
3027,
1053,
341,
8890,
2940,
13,
3166,
4876,
29889,
29885,
603,
29889,
18056,
442,
1053,
341,
8890,
6857,
27494,
13,
13,
29937,
323,
2868,
363,
732,
449,
6914,
29889,
510,
322,
732,
29879,
1099,
29889,
510,
24609,
13,
2917,
29918,
1445,
353,
2897,
29889,
2084,
29889,
25721,
29898,
359,
29889,
2084,
29889,
6370,
2084,
22168,
1445,
1649,
876,
718,
525,
6294,
2917,
29915,
13,
13,
1753,
3638,
29918,
5269,
29918,
2541,
29918,
3027,
29898,
2492,
29918,
1445,
2084,
29892,
4967,
1125,
13,
1678,
9995,
13,
1678,
910,
740,
15376,
4876,
5285,
515,
263,
934,
29892,
322,
16003,
278,
13,
1678,
15468,
1967,
304,
313,
392,
515,
29897,
445,
4876,
3211,
408,
385,
26305,
29889,
13,
1678,
9995,
13,
1678,
518,
3844,
9392,
29918,
2974,
29892,
1560,
9392,
29918,
637,
29892,
8952,
29892,
4800,
29962,
353,
679,
29918,
2917,
29918,
3888,
580,
13,
1678,
515,
29918,
7328,
353,
8952,
13,
1678,
304,
29918,
7328,
353,
8952,
13,
1678,
1967,
29918,
1272,
353,
1722,
29898,
2492,
29918,
1445,
2084,
29892,
525,
6050,
2824,
949,
580,
13,
1678,
10191,
353,
341,
8890,
6857,
27494,
580,
13,
1678,
10191,
1839,
20622,
2033,
353,
4967,
13,
1678,
10191,
1839,
4591,
2033,
353,
515,
29918,
7328,
13,
1678,
10191,
1839,
1762,
2033,
353,
304,
29918,
7328,
13,
1678,
1426,
353,
341,
8890,
1626,
29898,
16009,
29897,
13,
1678,
10191,
29889,
14930,
29898,
726,
29897,
13,
1678,
1967,
353,
341,
8890,
2940,
29898,
3027,
29918,
1272,
29892,
1024,
29922,
359,
29889,
2084,
29889,
6500,
3871,
29898,
2492,
29918,
1445,
2084,
876,
13,
1678,
10191,
29889,
14930,
29898,
3027,
29897,
13,
13,
1678,
269,
353,
1560,
9392,
1982,
29889,
17061,
3557,
29898,
3844,
9392,
29918,
2974,
29892,
1560,
9392,
29918,
637,
29897,
13,
1678,
269,
29889,
14797,
417,
580,
13,
1678,
269,
29889,
2962,
29873,
3137,
580,
13,
1678,
269,
29889,
14797,
417,
580,
13,
1678,
269,
29889,
7507,
29898,
6786,
29892,
4800,
29897,
13,
1678,
269,
29889,
6717,
2549,
29898,
3166,
29918,
7328,
29892,
304,
29918,
7328,
29892,
10191,
29889,
294,
29918,
1807,
3101,
13,
1678,
269,
29889,
28358,
580,
13,
13,
1753,
679,
29918,
2917,
29918,
3888,
7295,
13,
1678,
14550,
4250,
2408,
13766,
3557,
1923,
5235,
515,
934,
869,
2917,
13,
1678,
16969,
1051,
13,
1678,
14550,
13,
1678,
285,
353,
1722,
29898,
2917,
29918,
1445,
29892,
525,
6050,
1495,
13,
1678,
274,
353,
285,
29889,
949,
580,
13,
1678,
260,
353,
274,
29889,
5451,
9012,
580,
13,
1678,
736,
260,
29961,
29900,
29901,
29946,
29962,
13,
13,
1753,
679,
29918,
29885,
2230,
29918,
710,
29898,
1777,
1125,
13,
1678,
14550,
4250,
2408,
934,
21733,
931,
1347,
29889,
13,
1678,
7106,
851,
13,
1678,
14550,
13,
1678,
1018,
29901,
13,
4706,
286,
2230,
353,
2897,
29889,
2084,
29889,
657,
29885,
2230,
29898,
1777,
29897,
13,
1678,
5174,
438,
29173,
29901,
13,
4706,
736,
6629,
13,
1678,
338,
29918,
22992,
353,
931,
29889,
3250,
4366,
322,
931,
29889,
2997,
2230,
2141,
18276,
29918,
275,
22992,
1405,
29871,
29900,
13,
1678,
396,
17998,
9210,
297,
6923,
13,
1678,
9210,
353,
448,
313,
2230,
29889,
1997,
8028,
565,
338,
29918,
22992,
1683,
931,
29889,
2230,
8028,
29897,
13,
1678,
931,
29918,
710,
353,
931,
29889,
312,
603,
29898,
29885,
2230,
29897,
718,
525,
17998,
525,
718,
851,
29898,
10289,
29914,
29941,
29953,
29900,
29900,
29897,
13,
1678,
736,
931,
29918,
710,
13,
13,
1753,
437,
29918,
5269,
29898,
2492,
29918,
1445,
2084,
1125,
13,
1678,
14550,
9823,
29892,
1967,
21733,
931,
408,
4967,
322,
1967,
408,
26305,
13,
1678,
14550,
13,
1678,
4967,
353,
679,
29918,
29885,
2230,
29918,
710,
29898,
2492,
29918,
1445,
2084,
29897,
13,
1678,
565,
451,
4967,
29901,
13,
4706,
1596,
376,
16804,
756,
7695,
2743,
29889,
1939,
4876,
471,
2665,
1213,
13,
1678,
1683,
29901,
13,
4706,
3638,
29918,
5269,
29918,
2541,
29918,
3027,
29898,
2492,
29918,
1445,
2084,
29892,
4967,
29897,
13,
4706,
1596,
376,
29923,
655,
2356,
1967,
4586,
472,
376,
718,
4967,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
13812,
353,
1852,
5510,
29889,
15730,
11726,
580,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
1445,
2084,
1159,
13,
1678,
6389,
353,
13812,
29889,
5510,
29918,
5085,
580,
13,
1678,
437,
29918,
5269,
29898,
5085,
29889,
1445,
2084,
29897,
13,
13,
13,
2
] |
gui_login_dialog.py | CharellKing/gobang | 0 | 121640 | #!/usr/bin/python
#-*-coding:utf-8-*-
import wx
import gettext
#nickname对话框
class NicknameDlg(wx.Dialog):
nickname = None
def __init__(self, *args, **kwds):
# begin wxGlade: LoginDlg.__init__
kwds["style"] = wx.RESIZE_BORDER | wx.CLOSE_BOX | wx.THICK_FRAME
wx.Dialog.__init__(self, *args, **kwds)
self.static_text = wx.StaticText(self, wx.ID_ANY, _(u"请输入你的昵称:"))
self.nick_text = wx.TextCtrl(self, wx.ID_ANY, "")
self.ok_btn = wx.Button(self, wx.ID_ANY, _(u"确定"))
self.cancel_btn = wx.Button(self, wx.ID_ANY, _(u"取消"))
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.OnOk, self.ok_btn)
self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancel_btn)
# end wxGlade
def __set_properties(self):
# begin wxGlade: LoginDlg.__set_properties
self.SetTitle(_(u"昵称"))
# end wxGlade
def OnOk(self, evt):
NicknameDlg.nickname = self.nick_text.GetValue()
self.Destroy()
def OnCancel(self, evt):
NicknameDlg.nickname = None
self.Destroy()
def __do_layout(self):
# begin wxGlade: NicknameDlg.__do_layout
grid_sizer_1 = wx.GridSizer(2, 2, 0, 0)
grid_sizer_1.Add(self.static_text, 0, 0, 0)
grid_sizer_1.Add(self.nick_text, 0, 0, 0)
grid_sizer_1.Add(self.ok_btn, 0, 0, 0)
grid_sizer_1.Add(self.cancel_btn, 0, 0, 0)
self.SetSizer(grid_sizer_1)
grid_sizer_1.Fit(self)
self.Layout()
# end wxGlade
| [
1,
18787,
4855,
29914,
2109,
29914,
4691,
13,
29937,
29899,
29930,
29899,
29883,
3689,
29901,
9420,
29899,
29947,
29899,
29930,
29899,
13,
13,
13,
5215,
26437,
13,
13,
5215,
679,
726,
13,
13,
29937,
19254,
978,
30783,
31852,
233,
164,
137,
13,
1990,
13853,
978,
29928,
19920,
29898,
23310,
29889,
7647,
1125,
13,
1678,
25985,
978,
353,
6213,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
334,
5085,
29892,
3579,
11022,
6289,
1125,
13,
4706,
396,
3380,
26437,
29954,
23373,
29901,
19130,
29928,
19920,
17255,
2344,
1649,
13,
4706,
9049,
6289,
3366,
3293,
3108,
353,
26437,
29889,
1525,
14226,
29918,
29933,
22364,
891,
26437,
29889,
29907,
3927,
1660,
29918,
8456,
29990,
891,
26437,
29889,
4690,
2965,
29968,
29918,
29943,
4717,
2303,
13,
4706,
26437,
29889,
7647,
17255,
2344,
12035,
1311,
29892,
334,
5085,
29892,
3579,
11022,
6289,
29897,
13,
4706,
1583,
29889,
7959,
29918,
726,
353,
26437,
29889,
17046,
1626,
29898,
1311,
29892,
26437,
29889,
1367,
29918,
2190,
29979,
29892,
903,
29898,
29884,
29908,
31088,
31573,
30752,
30919,
30210,
233,
155,
184,
31685,
29901,
5783,
13,
4706,
1583,
29889,
19254,
29918,
726,
353,
26437,
29889,
1626,
18069,
29898,
1311,
29892,
26437,
29889,
1367,
29918,
2190,
29979,
29892,
20569,
13,
4706,
1583,
29889,
554,
29918,
7290,
353,
26437,
29889,
3125,
29898,
1311,
29892,
26437,
29889,
1367,
29918,
2190,
29979,
29892,
903,
29898,
29884,
29908,
31835,
30495,
5783,
13,
4706,
1583,
29889,
20713,
29918,
7290,
353,
26437,
29889,
3125,
29898,
1311,
29892,
26437,
29889,
1367,
29918,
2190,
29979,
29892,
903,
29898,
29884,
29908,
30683,
31276,
5783,
13,
13,
4706,
1583,
17255,
842,
29918,
11330,
580,
13,
4706,
1583,
17255,
1867,
29918,
2680,
580,
13,
13,
4706,
1583,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
29933,
2692,
29911,
1164,
29892,
1583,
29889,
2951,
20434,
29892,
1583,
29889,
554,
29918,
7290,
29897,
13,
4706,
1583,
29889,
15708,
29898,
23310,
29889,
22240,
29911,
29918,
29933,
2692,
29911,
1164,
29892,
1583,
29889,
2951,
19420,
29892,
1583,
29889,
20713,
29918,
7290,
29897,
13,
13,
13,
4706,
396,
1095,
26437,
29954,
23373,
13,
13,
1678,
822,
4770,
842,
29918,
11330,
29898,
1311,
1125,
13,
4706,
396,
3380,
26437,
29954,
23373,
29901,
19130,
29928,
19920,
17255,
842,
29918,
11330,
13,
4706,
1583,
29889,
2697,
7030,
7373,
29898,
29884,
29908,
233,
155,
184,
31685,
5783,
13,
4706,
396,
1095,
26437,
29954,
23373,
13,
13,
1678,
822,
1551,
20434,
29898,
1311,
29892,
3415,
29873,
1125,
13,
4706,
13853,
978,
29928,
19920,
29889,
19254,
978,
353,
1583,
29889,
19254,
29918,
726,
29889,
2577,
1917,
580,
13,
4706,
1583,
29889,
14994,
4727,
580,
13,
13,
1678,
822,
1551,
19420,
29898,
1311,
29892,
3415,
29873,
1125,
13,
4706,
13853,
978,
29928,
19920,
29889,
19254,
978,
353,
6213,
13,
4706,
1583,
29889,
14994,
4727,
580,
13,
13,
13,
1678,
822,
4770,
1867,
29918,
2680,
29898,
1311,
1125,
13,
4706,
396,
3380,
26437,
29954,
23373,
29901,
13853,
978,
29928,
19920,
17255,
1867,
29918,
2680,
13,
4706,
6856,
29918,
29879,
3950,
29918,
29896,
353,
26437,
29889,
5756,
29903,
3950,
29898,
29906,
29892,
29871,
29906,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
13,
4706,
6856,
29918,
29879,
3950,
29918,
29896,
29889,
2528,
29898,
1311,
29889,
7959,
29918,
726,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
13,
4706,
6856,
29918,
29879,
3950,
29918,
29896,
29889,
2528,
29898,
1311,
29889,
19254,
29918,
726,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
13,
4706,
6856,
29918,
29879,
3950,
29918,
29896,
29889,
2528,
29898,
1311,
29889,
554,
29918,
7290,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
13,
4706,
6856,
29918,
29879,
3950,
29918,
29896,
29889,
2528,
29898,
1311,
29889,
20713,
29918,
7290,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
13,
4706,
1583,
29889,
2697,
29903,
3950,
29898,
7720,
29918,
29879,
3950,
29918,
29896,
29897,
13,
4706,
6856,
29918,
29879,
3950,
29918,
29896,
29889,
29943,
277,
29898,
1311,
29897,
13,
4706,
1583,
29889,
3453,
580,
13,
4706,
396,
1095,
26437,
29954,
23373,
13,
2
] |
member/views.py | xyhlinx/Manta | 0 | 75385 | <filename>member/views.py<gh_stars>0
import random
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.response import Response
from rest_framework.generics import ListAPIView, CreateAPIView, RetrieveAPIView, DestroyAPIView
from member.models import Tag
from member.serializer import TagDetailSerializer, UserSerializer, GroupSerializer
from rest_framework import status
from django.contrib.auth.models import Group, User
class TagListCreate(ListAPIView, CreateAPIView):
queryset = Tag.objects.all()
serializer_class = TagDetailSerializer
filter_backends = (DjangoFilterBackend,)
# filter_class = tags_filter
def get(self, request, *args, **kwargs):
return self.list(request)
def post(self, request, *args, **kwargs):
serializer = TagDetailSerializer(data=request.data)
if serializer.is_valid():
tag_obj = serializer.save()
user_ids = request.data.get('users', [])
group_id = request.data.get('group', None)
group_instance = Group.objects.filter(id=group_id)
user_instances = User.objects.filter(id__in=user_ids)
tag_obj.users.set(user_instances)
if group_instance:
tag_obj.group = group_instance[0]
tag_obj.save()
return Response({'id': tag_obj.id}, status=status.HTTP_201_CREATED)
return Response(serializer.data, status=status.HTTP_400_BAD_REQUEST)
class TagDetail(RetrieveAPIView, DestroyAPIView):
queryset = Tag.objects.all()
serializer_class = TagDetailSerializer
def get(self, request, pk):
tag_instance = self.queryset.filter(id=pk)
if not tag_instance:
return Response({'Not Found'}, status=status.HTTP_404_NOT_FOUND)
serializer = TagDetailSerializer(tag_instance[0])
return Response(serializer.data, status=status.HTTP_204_NO_CONTENT)
def delete(self, request, pk):
tag_instance = self.queryset.filter(id=pk)
if not tag_instance:
return Response({}, status=status.HTTP_404_NOT_FOUND)
tag_instance[0].delete()
return Response({}, status=status.HTTP_204_NO_CONTENT)
def put(self, request, pk):
tag_instance = self.queryset.filter(id=pk)
if not tag_instance:
return Response({}, status=status.HTTP_404_NOT_FOUND)
tag_instance = tag_instance[0]
serializer = TagDetailSerializer(tag_instance, data=request.data)
if serializer.is_valid():
serializer.save()
if 'users' in request.data:
user_ids = request.data.get('users', [])
user_instances = User.objects.filter(id__in=user_ids)
tag_instance.users.set(user_instances)
if 'group' in request.data:
group_id = request.data.get('group', None)
group_instance = Group.objects.filter(id=group_id)
if group_instance:
tag_instance.update(group=group_instance[0])
return Response({'id': tag_instance.id}, status=status.HTTP_201_CREATED)
class UserList(ListAPIView, CreateAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
filter_backends = (DjangoFilterBackend, )
def post(self, request, *args, **kwargs):
username = request.data.get('username', None)
if username:
user_instance = User.objects.create_user(username)
return Response({'id': user_instance.id}, status=status.HTTP_201_CREATED)
return Response({'error'}, status=status.HTTP_400_BAD_REQUEST)
class GroupList(ListAPIView):
queryset = Group.objects.all()
serializer_class = GroupSerializer
filter_backends = (DjangoFilterBackend, )
| [
1,
529,
9507,
29958,
14242,
29914,
7406,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
4036,
13,
13,
3166,
9557,
29918,
26705,
29889,
5060,
29918,
4468,
1053,
15337,
5072,
5841,
355,
13,
3166,
1791,
29918,
4468,
29889,
5327,
1053,
13291,
13,
3166,
1791,
29918,
4468,
29889,
4738,
1199,
1053,
2391,
8787,
1043,
29892,
6204,
8787,
1043,
29892,
4649,
29878,
2418,
8787,
1043,
29892,
15435,
4727,
8787,
1043,
13,
3166,
4509,
29889,
9794,
1053,
10522,
13,
3166,
4509,
29889,
15550,
3950,
1053,
10522,
16570,
17679,
29892,
4911,
17679,
29892,
6431,
17679,
13,
3166,
1791,
29918,
4468,
1053,
4660,
13,
3166,
9557,
29889,
21570,
29889,
5150,
29889,
9794,
1053,
6431,
29892,
4911,
13,
13,
13,
1990,
10522,
1293,
4391,
29898,
1293,
8787,
1043,
29892,
6204,
8787,
1043,
1125,
13,
1678,
2346,
842,
353,
10522,
29889,
12650,
29889,
497,
580,
13,
1678,
7797,
3950,
29918,
1990,
353,
10522,
16570,
17679,
13,
1678,
4175,
29918,
1627,
1975,
353,
313,
29928,
5364,
5072,
5841,
355,
29892,
29897,
13,
13,
1678,
396,
4175,
29918,
1990,
353,
8282,
29918,
4572,
13,
13,
1678,
822,
679,
29898,
1311,
29892,
2009,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
736,
1583,
29889,
1761,
29898,
3827,
29897,
13,
13,
1678,
822,
1400,
29898,
1311,
29892,
2009,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
7797,
3950,
353,
10522,
16570,
17679,
29898,
1272,
29922,
3827,
29889,
1272,
29897,
13,
4706,
565,
7797,
3950,
29889,
275,
29918,
3084,
7295,
13,
9651,
4055,
29918,
5415,
353,
7797,
3950,
29889,
7620,
580,
13,
9651,
1404,
29918,
4841,
353,
2009,
29889,
1272,
29889,
657,
877,
7193,
742,
518,
2314,
13,
9651,
2318,
29918,
333,
353,
2009,
29889,
1272,
29889,
657,
877,
2972,
742,
6213,
29897,
13,
9651,
2318,
29918,
8758,
353,
6431,
29889,
12650,
29889,
4572,
29898,
333,
29922,
2972,
29918,
333,
29897,
13,
9651,
1404,
29918,
2611,
2925,
353,
4911,
29889,
12650,
29889,
4572,
29898,
333,
1649,
262,
29922,
1792,
29918,
4841,
29897,
13,
9651,
4055,
29918,
5415,
29889,
7193,
29889,
842,
29898,
1792,
29918,
2611,
2925,
29897,
13,
9651,
565,
2318,
29918,
8758,
29901,
13,
18884,
4055,
29918,
5415,
29889,
2972,
353,
2318,
29918,
8758,
29961,
29900,
29962,
13,
18884,
4055,
29918,
5415,
29889,
7620,
580,
13,
9651,
736,
13291,
3319,
29915,
333,
2396,
4055,
29918,
5415,
29889,
333,
1118,
4660,
29922,
4882,
29889,
10493,
29918,
29906,
29900,
29896,
29918,
27045,
29928,
29897,
13,
4706,
736,
13291,
29898,
15550,
3950,
29889,
1272,
29892,
4660,
29922,
4882,
29889,
10493,
29918,
29946,
29900,
29900,
29918,
29933,
3035,
29918,
16244,
29897,
13,
13,
13,
1990,
10522,
16570,
29898,
8015,
29878,
2418,
8787,
1043,
29892,
15435,
4727,
8787,
1043,
1125,
13,
1678,
2346,
842,
353,
10522,
29889,
12650,
29889,
497,
580,
13,
1678,
7797,
3950,
29918,
1990,
353,
10522,
16570,
17679,
13,
13,
1678,
822,
679,
29898,
1311,
29892,
2009,
29892,
282,
29895,
1125,
13,
4706,
4055,
29918,
8758,
353,
1583,
29889,
1972,
842,
29889,
4572,
29898,
333,
29922,
20571,
29897,
13,
4706,
565,
451,
4055,
29918,
8758,
29901,
13,
9651,
736,
13291,
3319,
29915,
3664,
7460,
16675,
4660,
29922,
4882,
29889,
10493,
29918,
29946,
29900,
29946,
29918,
12256,
29918,
5800,
18783,
29897,
13,
4706,
7797,
3950,
353,
10522,
16570,
17679,
29898,
4039,
29918,
8758,
29961,
29900,
2314,
13,
4706,
736,
13291,
29898,
15550,
3950,
29889,
1272,
29892,
4660,
29922,
4882,
29889,
10493,
29918,
29906,
29900,
29946,
29918,
6632,
29918,
22412,
3919,
29897,
13,
13,
1678,
822,
5217,
29898,
1311,
29892,
2009,
29892,
282,
29895,
1125,
13,
4706,
4055,
29918,
8758,
353,
1583,
29889,
1972,
842,
29889,
4572,
29898,
333,
29922,
20571,
29897,
13,
4706,
565,
451,
4055,
29918,
8758,
29901,
13,
9651,
736,
13291,
3319,
1118,
4660,
29922,
4882,
29889,
10493,
29918,
29946,
29900,
29946,
29918,
12256,
29918,
5800,
18783,
29897,
13,
4706,
4055,
29918,
8758,
29961,
29900,
1822,
8143,
580,
13,
4706,
736,
13291,
3319,
1118,
4660,
29922,
4882,
29889,
10493,
29918,
29906,
29900,
29946,
29918,
6632,
29918,
22412,
3919,
29897,
13,
13,
1678,
822,
1925,
29898,
1311,
29892,
2009,
29892,
282,
29895,
1125,
13,
4706,
4055,
29918,
8758,
353,
1583,
29889,
1972,
842,
29889,
4572,
29898,
333,
29922,
20571,
29897,
13,
4706,
565,
451,
4055,
29918,
8758,
29901,
13,
9651,
736,
13291,
3319,
1118,
4660,
29922,
4882,
29889,
10493,
29918,
29946,
29900,
29946,
29918,
12256,
29918,
5800,
18783,
29897,
13,
4706,
4055,
29918,
8758,
353,
4055,
29918,
8758,
29961,
29900,
29962,
13,
4706,
7797,
3950,
353,
10522,
16570,
17679,
29898,
4039,
29918,
8758,
29892,
848,
29922,
3827,
29889,
1272,
29897,
13,
4706,
565,
7797,
3950,
29889,
275,
29918,
3084,
7295,
13,
9651,
7797,
3950,
29889,
7620,
580,
13,
4706,
565,
525,
7193,
29915,
297,
2009,
29889,
1272,
29901,
13,
9651,
1404,
29918,
4841,
353,
2009,
29889,
1272,
29889,
657,
877,
7193,
742,
518,
2314,
13,
9651,
1404,
29918,
2611,
2925,
353,
4911,
29889,
12650,
29889,
4572,
29898,
333,
1649,
262,
29922,
1792,
29918,
4841,
29897,
13,
9651,
4055,
29918,
8758,
29889,
7193,
29889,
842,
29898,
1792,
29918,
2611,
2925,
29897,
13,
4706,
565,
525,
2972,
29915,
297,
2009,
29889,
1272,
29901,
13,
9651,
2318,
29918,
333,
353,
2009,
29889,
1272,
29889,
657,
877,
2972,
742,
6213,
29897,
13,
9651,
2318,
29918,
8758,
353,
6431,
29889,
12650,
29889,
4572,
29898,
333,
29922,
2972,
29918,
333,
29897,
13,
9651,
565,
2318,
29918,
8758,
29901,
13,
18884,
4055,
29918,
8758,
29889,
5504,
29898,
2972,
29922,
2972,
29918,
8758,
29961,
29900,
2314,
13,
4706,
736,
13291,
3319,
29915,
333,
2396,
4055,
29918,
8758,
29889,
333,
1118,
4660,
29922,
4882,
29889,
10493,
29918,
29906,
29900,
29896,
29918,
27045,
29928,
29897,
13,
13,
13,
1990,
4911,
1293,
29898,
1293,
8787,
1043,
29892,
6204,
8787,
1043,
1125,
13,
1678,
2346,
842,
353,
4911,
29889,
12650,
29889,
497,
580,
13,
1678,
7797,
3950,
29918,
1990,
353,
4911,
17679,
13,
1678,
4175,
29918,
1627,
1975,
353,
313,
29928,
5364,
5072,
5841,
355,
29892,
1723,
13,
13,
1678,
822,
1400,
29898,
1311,
29892,
2009,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
8952,
353,
2009,
29889,
1272,
29889,
657,
877,
6786,
742,
6213,
29897,
13,
4706,
565,
8952,
29901,
13,
9651,
1404,
29918,
8758,
353,
4911,
29889,
12650,
29889,
3258,
29918,
1792,
29898,
6786,
29897,
13,
9651,
736,
13291,
3319,
29915,
333,
2396,
1404,
29918,
8758,
29889,
333,
1118,
4660,
29922,
4882,
29889,
10493,
29918,
29906,
29900,
29896,
29918,
27045,
29928,
29897,
13,
4706,
736,
13291,
3319,
29915,
2704,
16675,
4660,
29922,
4882,
29889,
10493,
29918,
29946,
29900,
29900,
29918,
29933,
3035,
29918,
16244,
29897,
13,
13,
13,
1990,
6431,
1293,
29898,
1293,
8787,
1043,
1125,
13,
1678,
2346,
842,
353,
6431,
29889,
12650,
29889,
497,
580,
13,
1678,
7797,
3950,
29918,
1990,
353,
6431,
17679,
13,
1678,
4175,
29918,
1627,
1975,
353,
313,
29928,
5364,
5072,
5841,
355,
29892,
1723,
13,
13,
2
] |
docs/p3/setup.py | khchine5/atelier | 1 | 30130 | from setuptools import setup
if __name__ == '__main__':
setup(name='foo', version='1.0.0')
| [
1,
515,
731,
21245,
8789,
1053,
6230,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
6230,
29898,
978,
2433,
5431,
742,
1873,
2433,
29896,
29889,
29900,
29889,
29900,
1495,
13,
13,
2
] |
example/test/L11_danmu_dong_ide.py | Michael8968/skulpt | 2 | 69759 | import pygame
from pygame.locals import *
import random
import time
pygame.init()
bac = pygame.image.load('lesson11/bac1.png')
screen = pygame.display.set_mode((800, 600))
dd=0
bac = []
font = pygame.font.Font('simhei.ttf', 40)
str1 = '666社会社会大吉大利今晚吃鸡嘤嘤嘤'
str2=font.render(str1, True, (200,200,0))
print(type(str2))
for i in range(7):
aa = pygame.image.load('lesson11/bac' + str(i+1) + '.png')
bac.append(aa)
num = 0
flag=0
nn=1
for i in range(10000):
time.sleep(0.03)
if flag <= 60:
flag += 1
else:
flag = 0
num += 1
if num == 7:
num = 0
screen.blit(bac[num], (0,0))
screen.blit(str2, (800-dd, 300))
dd+=1
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
pygame.display.update()
| [
1,
1053,
22028,
13,
3166,
22028,
29889,
2997,
29879,
1053,
334,
13,
5215,
4036,
13,
5215,
931,
13,
13,
13,
2272,
11802,
29889,
2344,
580,
13,
29890,
562,
353,
22028,
29889,
3027,
29889,
1359,
877,
2222,
265,
29896,
29896,
29914,
29890,
562,
29896,
29889,
2732,
1495,
13,
10525,
353,
22028,
29889,
4990,
29889,
842,
29918,
8513,
3552,
29947,
29900,
29900,
29892,
29871,
29953,
29900,
29900,
876,
29871,
13,
1289,
29922,
29900,
13,
29890,
562,
353,
5159,
13,
13,
5657,
353,
22028,
29889,
5657,
29889,
9824,
877,
3601,
354,
29875,
29889,
698,
29888,
742,
29871,
29946,
29900,
29897,
13,
710,
29896,
353,
525,
29953,
29953,
29953,
30564,
30437,
30564,
30437,
30257,
31033,
30257,
31107,
31482,
233,
156,
157,
232,
147,
134,
236,
187,
164,
232,
155,
167,
232,
155,
167,
232,
155,
167,
29915,
13,
710,
29906,
29922,
5657,
29889,
9482,
29898,
710,
29896,
29892,
5852,
29892,
313,
29906,
29900,
29900,
29892,
29906,
29900,
29900,
29892,
29900,
876,
13,
2158,
29898,
1853,
29898,
710,
29906,
876,
13,
13,
1454,
474,
297,
3464,
29898,
29955,
1125,
13,
1678,
29099,
353,
22028,
29889,
3027,
29889,
1359,
877,
2222,
265,
29896,
29896,
29914,
29890,
562,
29915,
718,
851,
29898,
29875,
29974,
29896,
29897,
718,
15300,
2732,
1495,
13,
1678,
289,
562,
29889,
4397,
29898,
7340,
29897,
13,
13,
1949,
353,
29871,
29900,
13,
15581,
29922,
29900,
13,
15755,
29922,
29896,
13,
13,
1454,
474,
297,
3464,
29898,
29896,
29900,
29900,
29900,
29900,
1125,
13,
1678,
931,
29889,
17059,
29898,
29900,
29889,
29900,
29941,
29897,
13,
1678,
565,
7353,
5277,
29871,
29953,
29900,
29901,
13,
4706,
7353,
4619,
29871,
29896,
13,
1678,
1683,
29901,
13,
4706,
7353,
353,
29871,
29900,
13,
4706,
954,
4619,
29871,
29896,
13,
1678,
565,
954,
1275,
29871,
29955,
29901,
13,
4706,
954,
353,
29871,
29900,
13,
1678,
4315,
29889,
2204,
277,
29898,
29890,
562,
29961,
1949,
1402,
313,
29900,
29892,
29900,
876,
29871,
13,
1678,
4315,
29889,
2204,
277,
29898,
710,
29906,
29892,
313,
29947,
29900,
29900,
29899,
1289,
29892,
29871,
29941,
29900,
29900,
876,
13,
1678,
24488,
23661,
29896,
13,
13,
1678,
363,
1741,
297,
22028,
29889,
3696,
29889,
657,
7295,
13,
4706,
565,
1741,
29889,
1853,
1275,
660,
29965,
1806,
29901,
13,
9651,
22028,
29889,
28358,
580,
4706,
13,
1678,
13,
1678,
22028,
29889,
4990,
29889,
5504,
580,
13,
13,
13,
2
] |
helita/sim/preft.py | jumasy/helita | 0 | 160799 | <filename>helita/sim/preft.py
import os
import numpy as np
import scipy.constants as ct
from scipy.io import readsav
#import radynpy as rd
from .load_quantities import *
from .load_arithmetic_quantities import *
from .tools import *
from .load_noeos_quantities import *
from math import ceil, floor
from scipy.sparse import coo_matrix
import torch
import imp
try:
imp.find_module('pycuda')
found = True
except ImportError:
found = False
class preft(object):
"""
Class to read preft atmosphere
Parameters
----------
fdir : str, optional
Directory with snapshots.
rootname : str
rootname of the file (wihtout params or vars).
verbose : bool, optional
If True, will print more information.
it : integer
snapshot number
"""
def __init__(self, filename, snap, *args, fdir='.',
sel_units = 'cgs', verbose=True, **kwargs):
self.filename = filename
self.fdir = fdir
a = readsav(filename, python_dict=True)
#self.la = a['la']
self.snap = snap
la = a['la']
l = a['la'][snap]
#self.zmax = (a['la'][0][3][:,2]).max()
self.extent = (0, (a['la'][0][3][:,0]).max()-(a['la'][0][3][:,0]).min(),
0, (a['la'][0][3][:,1]).max()-(a['la'][0][3][:,1]).min(),
0, (a['la'][0][3][:,2]).max()-(a['la'][0][3][:,2]).min())
self.obj = {'time':np.array([lal[0] for lal in la]),
's':np.stack([lal[1] for lal in la]),
'ux':np.stack([lal[2][:,0] for lal in la]),
'uy':np.stack([lal[2][:,1] for lal in la]),
'uz':np.stack([lal[2][:,2] for lal in la]),
'x':np.stack([lal[3][:,0] for lal in la]),
'y':np.stack([lal[3][:,1] for lal in la]),
'z':np.stack([lal[3][:,2] for lal in la]),
'rho':np.stack([lal[4] for lal in la]),
'p':np.stack([lal[5] for lal in la]),
'tg':np.stack([lal[6] for lal in la]),
'ne':np.stack([lal[7] for lal in la]),
'b':np.stack([lal[8] for lal in la]),
'units':l[9]}
#= {'time':l[0],'s':l[1],'ux':l[2][:,0],'uy':l[2][:,1],'uz':l[2][:,2],
# 'x':l[3][:,0], 'y':l[3][:,1], 'z':l[3][:,2],
# 'rho':l[4],'p':l[5],'tg':l[6],'ne':l[7],'b':l[8], 'units':l[9]}
self.x = l[3][:,0].copy()
self.x-= self.x.min() #np.array([0.0])
self.y = l[3][:,1].copy()
self.y-= self.y.min() #np.array([0.0])
self.z = l[3][:,2].copy() #np.array([0.0])
#self.z = np.flip(self.rdobj.__getattr__('zm'))
self.sel_units= sel_units
self.verbose = verbose
#self.snap = None
self.uni = PREFT_units()
#self.dx = np.array([1.0])
#self.dy = np.array([1.0])
#self.dz = np.copy(self.z)
self.nt = [1] #np.shape(self.z)[0]
self.nz = np.shape(self.z)[0]
#for it in range(0,self.nt):
#self.dz[it,:] = np.gradient(self.z[it,:])
self.dx = np.gradient(self.x)
self.dy = np.gradient(self.y)
self.dz = np.gradient(self.z)
self.dz1d = self.dz
self.dx1d = np.array([1.0])
self.dy1d = np.array([1.0])
self.nx = np.shape(self.x)
self.ny = np.shape(self.y)
#self.time = self.rdobj.__getattr__('time')
self.transunits = False
self.cstagop = False # This will not allow to use cstagger from Bifrost in load
self.hion = False # This will not allow to use HION from Bifrost in load
self.genvar()
def get_var(self, var, snap=None, iix=None, iiy=None, iiz=None, layout=None):
'''
Reads the variables from a snapshot (it).
Parameters
----------
var - string
Name of the variable to read.
cgs- logic
converts into cgs units.
Axes:
-----
z-axis is along the loop
x and y axes have only one grid.
Information about radynpy library:
--------------
'''
if snap == None:
snap = self.snap
if var in self.varn.keys():
varname=self.varn[var]
else:
varname=var
#print(var,varname,'try')
#print(self.obj.keys())
try:
if self.sel_units == 'cgs':
varu=var.replace('x','')
varu=varu.replace('y','')
varu=varu.replace('z','')
if (var in self.varn.keys()) and (varu in self.uni.uni.keys()):
cgsunits = self.uni.uni[varu]
else:
cgsunits = 1.0
else:
cgsunits = 1.0
#print(varname)
self.data = self.obj[varname][snap]*cgsunits
#self.rdobj.__getattr__(varname) * cgsunits
except:
self.data = load_quantities(self,var,PLASMA_QUANT='', CYCL_RES='',
COLFRE_QUANT='', COLFRI_QUANT='', IONP_QUANT='',
EOSTAB_QUANT='', TAU_QUANT='', DEBYE_LN_QUANT='',
CROSTAB_QUANT='', COULOMB_COL_QUANT='', AMB_QUANT='',
HALL_QUANT='', BATTERY_QUANT='', SPITZER_QUANT='',
KAPPA_QUANT='', GYROF_QUANT='', WAVE_QUANT='',
FLUX_QUANT='', CURRENT_QUANT='', COLCOU_QUANT='',
COLCOUMS_QUANT='', COLFREMX_QUANT='')
if np.shape(self.data) == ():
if self.verbose:
print('Loading arithmetic variable',end="\r",flush=True)
self.data = load_arithmetic_quantities(self,var)
if var == '':
print(help(self.get_var))
print('VARIABLES USING CGS OR GENERIC NOMENCLATURE')
for ii in self.varn:
print('use ', ii,' for ',self.varn[ii])
print(self.description['ALL'])
#print('\n radyn obj is self.rdobj, self.rdobj.var_info is as follows')
#print(self.rdobj.var_info)
return None
#self.trans2noncommaxes()
return self.data
def genvar(self):
'''
Dictionary of original variables which will allow to convert to cgs.
'''
self.varn={}
self.varn['rho']= 'rho'
self.varn['tg'] = 'tg'
self.varn['ux'] = 'ux'
self.varn['uy'] = 'uy'
self.varn['uz'] = 'uz'
self.varn['bx'] = 'bx'
self.varn['by'] = 'by'
self.varn['bz'] = 'bz'
self.varn['ne'] = 'ne'
def trans2comm(self,varname,snap=0, **kwargs):
'''
Transform the domain into a "common" format. All arrays will be 3D. The 3rd axis
is:
- for 3D atmospheres: the vertical axis
- for loop type atmospheres: along the loop
- for 1D atmosphere: the unique dimension is the 3rd axis.
At least one extra dimension needs to be created artifically.
All of them should obey the right hand rule
In all of them, the vectors (velocity, magnetic field etc) away from the Sun.
If applies, z=0 near the photosphere.
Units: everything is in cgs.
If an array is reverse, do ndarray.copy(), otherwise pytorch will complain.
'''
self.sel_units = 'cgs'
if not hasattr(self,'trans_dx'):
self.trans_dx=3e7
if not hasattr(self,'trans_dy'):
self.trans_dy=3e7
if not hasattr(self,'trans_dz'):
self.trans_dz=3e7
for key, value in kwargs.items():
if key == 'dx':
if hasattr(self,'trans_dx'):
if value != self.trans_dx:
self.transunits = False
if key == 'dz':
if hasattr(self,'trans_dz'):
if value != self.trans_dz:
self.transunits = False
if self.snap != snap:
self.snap=snap
self.transunits = False
#var = self.get_var(varname)
#What does this do?
#self.trans2commaxes(var, **kwargs)
if not hasattr(self,'trans_loop_width'):
self.trans_loop_width=1.0
if not hasattr(self,'trans_sparse'):
self.trans_sparse=True
for key, value in kwargs.items():
if key == 'loop_width':
self.trans_loop_width = value
if key == 'unscale':
do_expscale = value
if key == 'sparse':
self.trans_sparse = value
## GSK -- smax was changed 12th March 2021. See comment in trans2commaxes
##smax = s.max()
shape = (ceil(self.extent[1]/self.trans_dx),
ceil(self.extent[3]/self.trans_dy),
ceil(self.extent[5]/self.trans_dz)+1)
# In the PREFT model in the corona, successive grid points may be several pixels away from each other.
# In this case, need to refine loop.
#do_expscale = False
#for key, value in kwargs.items():
# if key == 'unscale':
# do_expscale = value
#if self.gridfactor > 1:
# if do_expscale:
# ss, var= refine(s, np.log(var),factor=self.gridfactor, unscale=np.exp)
# else:
# ss, var= refine(s, var,factor=self.gridfactor)
#else:
# ss = s
#var_copy = var.copy()
x_loop = self.obj['x'][self.snap]
y_loop = self.obj['y'][self.snap]
z_loop = self.obj['z'][self.snap]
s_loop = self.obj['s'][self.snap]
x_loop -= x_loop.min()
y_loop -= y_loop.min()
z_loop -= z_loop.min()
var = self.get_var(varname,snap=self.snap)
print(s_loop, var)
x_loop, y_loop, z_loop, var = self.trans2commaxes(x_loop, y_loop, z_loop, var, s_loop, **kwargs)
# Arc lengths (in radians)
dA = np.ones(var.shape)*self.trans_dx*self.trans_dy*self.trans_dz
xind = np.floor(x_loop/self.trans_dx).astype(np.int64)
yind = np.floor(y_loop/self.trans_dy).astype(np.int64)
zind = np.clip(np.floor(z_loop/self.trans_dz).astype(np.int64),0,shape[2]-1)
# Make copies of loops with an x-offset
for xoffset in range(-shape[0],shape[0],10):
this_snap = self.snap + xoffset + shape[0]
x_loop = self.obj['x'][this_snap]
y_loop = self.obj['y'][this_snap]
z_loop = self.obj['z'][this_snap]
s_loop = self.obj['s'][this_snap]
x_loop -= x_loop.min()
y_loop -= y_loop.min()
z_loop -= z_loop.min()
this_var = self.get_var(varname,snap=this_snap)
print(this_snap, s_loop.shape)
x_loop, y_loop, z_loop, this_var = self.trans2commaxes(x_loop, y_loop, z_loop, s_loop, this_var, **kwargs)
xind = np.concatenate((xind, np.floor((x_loop+xoffset*self.trans_dx)/self.trans_dx).astype(np.int64)))
yind = np.concatenate((yind, np.floor(y_loop/self.trans_dy).astype(np.int64)))
zind = np.concatenate((zind, np.clip(np.floor(z_loop/self.trans_dz).astype(np.int64),0,shape[2]-1)))
dA = np.concatenate((dA, np.ones(var.shape)*self.trans_dx*self.trans_dy*self.trans_dz))
var = np.concatenate((var, this_var))
good = (xind>=0)*(xind<shape[0])
good*= (yind>=0)*(yind<shape[1])
good*= (zind>=0)*(zind<shape[2])
xind = xind[good]
yind = yind[good]
zind = zind[good]
dA = dA[good]
var = var[good]
# Define matrix with column coordinate corresponding to point along loop
# and row coordinate corresponding to position in Cartesian grid
col = np.arange(len(xind),dtype=np.int64)
row = (xind*shape[1]+yind)*shape[2]+zind
if self.trans_sparse:
M = coo_matrix((dA/(self.trans_dx*self.trans_dy*self.trans_dz),
(row,col)),shape=(shape[0]*shape[1]*shape[2], len(xind)), dtype=np.float)
M = M.tocsr()
else:
M = np.zeros(shape=(shape[0]*shape[1]*shape[2], len(ss)), dtype=np.float)
M[row,col] = dA/(self.dx1d*self.dz1d.max()) #weighting by area of arc segment
# The final quantity at each Cartesian grid cell is an volume-weighted
# average of values from loop passing through this grid cell
# This arrays are not actually used for VDEM extraction
var = (M@var).reshape(shape)
self.x = np.linspace(self.x_loop.min(),self.x_loop.max(),np.shape(var)[0])
self.y = np.linspace(self.y_loop.min(),self.y_loop.max(),np.shape(var)[1])
self.z = np.linspace(self.z_loop.min(),self.z_loop.max(),np.shape(var)[2])
self.dx1d = np.gradient(self.x)
self.dy1d = np.gradient(self.y)
self.dz1d = np.gradient(self.z)
return var
def trans2commaxes(self, x, y, z, s, var, **kwargs):
if self.transunits == False:
if not hasattr(self,'trans_dx'):
self.trans_dx=3e7
if not hasattr(self,'trans_dy'):
self.trans_dy=3e7
if not hasattr(self,'trans_dz'):
self.trans_dz=3e7
for key, value in kwargs.items():
if key == 'dx':
self.trans_dx = value
if key == 'dy':
self.trans_dy = value
if key == 'dz':
self.trans_dz = value
# Semicircular loop
#s = self.obj['s'] #np.copy(self.zorig)
#good = (s >=0.0)
#s = s[good]
#x = self.x
#y = self.y
#z = self.z
#shape = (ceil(x.max()/self.trans_dx),ceil(y.max()/self.trans_dy), ceil(self.zmax/self.trans_dz))
# In the RADYN model in the corona, successive grid points may be several pixels away from each other.
# In this case, need to refine loop.
maxdl = np.sqrt((z[1:]-z[0:-1])**2+ (x[1:]-x[0:-1])**2 + (y[1:]-y[0:-1])**2 ).max()
gridfactor = ceil(2*maxdl/np.min([self.trans_dx,self.trans_dy,self.trans_dz]))
do_expscale = False
for key, value in kwargs.items():
if key == 'unscale':
do_expscale = value
if gridfactor > 1:
print(s,x)
ss, x_loop = refine(s,x, factor=gridfactor)
ss, y_loop = refine(s,y, factor=gridfactor)
ss, z_loop = refine(s,z, factor=gridfactor)
if do_expscale:
ss, var_loop = refine(s, np.log(var),factor=gridfactor, unscale=np.exp)
else:
ss, var_loop = refine(s, var,factor=gridfactor)
else:
x_loop = x.copy()
y_loop = y.copy()
z_loop = z.copy()
var_loop = var.copy()
self.dx1d_loop = np.gradient(x_loop)
self.dy1d_loop = np.gradient(y_loop)
self.dz1d_loop = np.gradient(z_loop)
self.transunits = True
return x_loop, y_loop, z_loop, var_loop
def trans2noncommaxes(self):
if self.transunits == True:
self.x = np.array([0.0])
self.y = np.array([0.0])
self.z = self.rdobj.__getattr__('zm')
self.dx = np.array([1.0])
self.dy = np.array([1.0])
self.dz = np.copy(self.z)
self.nz = np.shape(self.z)[1]
for it in range(0,self.nt):
self.dz[it,:] = np.gradient(self.z[it,:])
self.dz1d = self.dz
self.dx1d = np.array([1.0])
self.dy1d = np.array([1.0])
self.nx = np.shape(self.x)
self.ny = np.shape(self.y)
self.transunits = False
class PREFT_units(object):
def __init__(self,verbose=False):
'''
Units and constants in cgs
'''
self.uni={}
self.verbose = verbose
self.uni['tg'] = 1.0
self.uni['l'] = 1.0
self.uni['n'] = 1.0
self.uni['rho'] = 1.0
self.uni['u'] = 1.0
self.uni['b'] = 1.0
self.uni['t'] = 1.0 # seconds
self.uni['j'] = 1.0
# Units and constants in SI
convertcsgsi(self)
globalvars(self)
| [
1,
529,
9507,
29958,
3952,
2028,
29914,
3601,
29914,
1457,
615,
29889,
2272,
13,
5215,
2897,
13,
5215,
12655,
408,
7442,
13,
5215,
4560,
2272,
29889,
3075,
1934,
408,
274,
29873,
13,
3166,
4560,
2272,
29889,
601,
1053,
13623,
485,
13,
13,
29937,
5215,
2971,
948,
2272,
408,
364,
29881,
13,
3166,
869,
1359,
29918,
12150,
1907,
1053,
334,
13,
3166,
869,
1359,
29918,
279,
18542,
29918,
12150,
1907,
1053,
334,
13,
3166,
869,
8504,
1053,
334,
13,
3166,
869,
1359,
29918,
1217,
29872,
359,
29918,
12150,
1907,
1053,
334,
13,
3166,
5844,
1053,
2257,
309,
29892,
11904,
13,
3166,
4560,
2272,
29889,
29879,
5510,
1053,
1302,
29877,
29918,
5344,
13,
5215,
4842,
305,
13,
5215,
2411,
13,
13,
2202,
29901,
13,
1678,
2411,
29889,
2886,
29918,
5453,
877,
2272,
29883,
6191,
1495,
13,
1678,
1476,
353,
5852,
13,
19499,
16032,
2392,
29901,
13,
1678,
1476,
353,
7700,
13,
268,
13,
13,
1990,
758,
615,
29898,
3318,
1125,
13,
29871,
9995,
13,
29871,
4134,
304,
1303,
758,
615,
25005,
13,
13,
29871,
12662,
2699,
13,
29871,
448,
1378,
29899,
13,
29871,
285,
3972,
584,
851,
29892,
13136,
13,
418,
18862,
411,
15101,
845,
1862,
29889,
13,
29871,
3876,
978,
584,
851,
13,
418,
3876,
978,
310,
278,
934,
313,
4353,
400,
449,
8636,
470,
24987,
467,
13,
29871,
26952,
584,
6120,
29892,
13136,
13,
418,
960,
5852,
29892,
674,
1596,
901,
2472,
29889,
13,
29871,
372,
584,
6043,
29871,
13,
418,
22395,
1353,
29871,
13,
29871,
9995,
13,
29871,
822,
4770,
2344,
12035,
1311,
29892,
10422,
29892,
15101,
29892,
334,
5085,
29892,
285,
3972,
2433,
29889,
742,
29871,
13,
1669,
5535,
29918,
348,
1169,
353,
525,
29883,
3174,
742,
26952,
29922,
5574,
29892,
3579,
19290,
1125,
13,
308,
13,
1678,
1583,
29889,
9507,
353,
10422,
13,
1678,
1583,
29889,
29888,
3972,
353,
285,
3972,
13,
13,
1678,
263,
353,
13623,
485,
29898,
9507,
29892,
3017,
29918,
8977,
29922,
5574,
29897,
13,
1678,
396,
1311,
29889,
433,
353,
263,
1839,
433,
2033,
13,
1678,
1583,
29889,
29879,
8971,
353,
15101,
13,
1678,
425,
353,
263,
1839,
433,
2033,
13,
1678,
301,
353,
263,
1839,
433,
2033,
29961,
29879,
8971,
29962,
13,
268,
13,
1678,
396,
1311,
29889,
29920,
3317,
353,
313,
29874,
1839,
433,
2033,
29961,
29900,
3816,
29941,
3816,
29901,
29892,
29906,
14664,
3317,
580,
13,
268,
13,
1678,
1583,
29889,
1062,
296,
353,
313,
29900,
29892,
313,
29874,
1839,
433,
2033,
29961,
29900,
3816,
29941,
3816,
29901,
29892,
29900,
14664,
3317,
580,
17722,
29874,
1839,
433,
2033,
29961,
29900,
3816,
29941,
3816,
29901,
29892,
29900,
14664,
1195,
3285,
13,
462,
1678,
29900,
29892,
313,
29874,
1839,
433,
2033,
29961,
29900,
3816,
29941,
3816,
29901,
29892,
29896,
14664,
3317,
580,
17722,
29874,
1839,
433,
2033,
29961,
29900,
3816,
29941,
3816,
29901,
29892,
29896,
14664,
1195,
3285,
13,
462,
1678,
29900,
29892,
313,
29874,
1839,
433,
2033,
29961,
29900,
3816,
29941,
3816,
29901,
29892,
29906,
14664,
3317,
580,
17722,
29874,
1839,
433,
2033,
29961,
29900,
3816,
29941,
3816,
29901,
29892,
29906,
14664,
1195,
3101,
13,
268,
13,
1678,
1583,
29889,
5415,
353,
11117,
2230,
2396,
9302,
29889,
2378,
4197,
29880,
284,
29961,
29900,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
29879,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29896,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
1314,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29906,
3816,
29901,
29892,
29900,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
8631,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29906,
3816,
29901,
29892,
29896,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
3365,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29906,
3816,
29901,
29892,
29906,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
29916,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29941,
3816,
29901,
29892,
29900,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
29891,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29941,
3816,
29901,
29892,
29896,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
29920,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29941,
3816,
29901,
29892,
29906,
29962,
363,
301,
284,
297,
425,
11724,
632,
13,
18884,
525,
4650,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29946,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
29886,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29945,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
29873,
29887,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29953,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
484,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29955,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
29890,
2396,
9302,
29889,
1429,
4197,
29880,
284,
29961,
29947,
29962,
363,
301,
284,
297,
425,
11724,
13,
18884,
525,
348,
1169,
2396,
29880,
29961,
29929,
12258,
13,
268,
13,
1678,
396,
29922,
11117,
2230,
2396,
29880,
29961,
29900,
1402,
29915,
29879,
2396,
29880,
29961,
29896,
1402,
29915,
1314,
2396,
29880,
29961,
29906,
3816,
29901,
29892,
29900,
1402,
29915,
8631,
2396,
29880,
29961,
29906,
3816,
29901,
29892,
29896,
1402,
29915,
3365,
2396,
29880,
29961,
29906,
3816,
29901,
29892,
29906,
1402,
13,
1678,
396,
9651,
525,
29916,
2396,
29880,
29961,
29941,
3816,
29901,
29892,
29900,
1402,
525,
29891,
2396,
29880,
29961,
29941,
3816,
29901,
29892,
29896,
1402,
525,
29920,
2396,
29880,
29961,
29941,
3816,
29901,
29892,
29906,
1402,
29871,
13,
1678,
396,
9651,
525,
4650,
2396,
29880,
29961,
29946,
1402,
29915,
29886,
2396,
29880,
29961,
29945,
1402,
29915,
29873,
29887,
2396,
29880,
29961,
29953,
1402,
29915,
484,
2396,
29880,
29961,
29955,
1402,
29915,
29890,
2396,
29880,
29961,
29947,
1402,
525,
348,
1169,
2396,
29880,
29961,
29929,
12258,
13,
268,
13,
1678,
1583,
29889,
29916,
353,
301,
29961,
29941,
3816,
29901,
29892,
29900,
1822,
8552,
580,
13,
1678,
1583,
29889,
29916,
29899,
29922,
1583,
29889,
29916,
29889,
1195,
580,
396,
9302,
29889,
2378,
4197,
29900,
29889,
29900,
2314,
13,
1678,
1583,
29889,
29891,
353,
301,
29961,
29941,
3816,
29901,
29892,
29896,
1822,
8552,
580,
13,
1678,
1583,
29889,
29891,
29899,
29922,
1583,
29889,
29891,
29889,
1195,
580,
396,
9302,
29889,
2378,
4197,
29900,
29889,
29900,
2314,
13,
1678,
1583,
29889,
29920,
353,
301,
29961,
29941,
3816,
29901,
29892,
29906,
1822,
8552,
580,
396,
9302,
29889,
2378,
4197,
29900,
29889,
29900,
2314,
13,
1678,
396,
1311,
29889,
29920,
353,
7442,
29889,
29888,
3466,
29898,
1311,
29889,
5499,
5415,
17255,
657,
5552,
1649,
877,
14018,
8785,
13,
1678,
1583,
29889,
2838,
29918,
348,
1169,
29922,
5535,
29918,
348,
1169,
13,
1678,
1583,
29889,
369,
15828,
353,
26952,
13,
1678,
396,
1311,
29889,
29879,
8971,
353,
6213,
13,
1678,
1583,
29889,
3909,
353,
349,
1525,
7818,
29918,
348,
1169,
580,
13,
268,
13,
1678,
396,
1311,
29889,
8235,
353,
7442,
29889,
2378,
4197,
29896,
29889,
29900,
2314,
13,
1678,
396,
1311,
29889,
4518,
353,
7442,
29889,
2378,
4197,
29896,
29889,
29900,
2314,
13,
1678,
396,
1311,
29889,
5601,
353,
7442,
29889,
8552,
29898,
1311,
29889,
29920,
29897,
13,
1678,
1583,
29889,
593,
353,
518,
29896,
29962,
396,
9302,
29889,
12181,
29898,
1311,
29889,
29920,
9601,
29900,
29962,
13,
1678,
1583,
29889,
29876,
29920,
353,
7442,
29889,
12181,
29898,
1311,
29889,
29920,
9601,
29900,
29962,
13,
1678,
396,
1454,
372,
297,
3464,
29898,
29900,
29892,
1311,
29889,
593,
1125,
13,
1678,
396,
1311,
29889,
5601,
29961,
277,
29892,
17531,
353,
7442,
29889,
24970,
29898,
1311,
29889,
29920,
29961,
277,
29892,
29901,
2314,
13,
1678,
1583,
29889,
8235,
353,
7442,
29889,
24970,
29898,
1311,
29889,
29916,
29897,
13,
1678,
1583,
29889,
4518,
353,
7442,
29889,
24970,
29898,
1311,
29889,
29891,
29897,
13,
1678,
1583,
29889,
5601,
353,
7442,
29889,
24970,
29898,
1311,
29889,
29920,
29897,
13,
268,
13,
1678,
1583,
29889,
5601,
29896,
29881,
353,
1583,
29889,
5601,
13,
1678,
1583,
29889,
8235,
29896,
29881,
353,
7442,
29889,
2378,
4197,
29896,
29889,
29900,
2314,
13,
1678,
1583,
29889,
4518,
29896,
29881,
353,
7442,
29889,
2378,
4197,
29896,
29889,
29900,
2314,
13,
268,
13,
1678,
1583,
29889,
23818,
353,
7442,
29889,
12181,
29898,
1311,
29889,
29916,
29897,
13,
1678,
1583,
29889,
1460,
353,
7442,
29889,
12181,
29898,
1311,
29889,
29891,
29897,
13,
268,
13,
1678,
396,
1311,
29889,
2230,
353,
29871,
1583,
29889,
5499,
5415,
17255,
657,
5552,
1649,
877,
2230,
1495,
13,
13,
1678,
1583,
29889,
3286,
348,
1169,
353,
7700,
13,
13,
1678,
1583,
29889,
29883,
24403,
459,
353,
7700,
396,
910,
674,
451,
2758,
304,
671,
274,
303,
9921,
515,
350,
361,
17627,
297,
2254,
13,
1678,
1583,
29889,
29882,
291,
353,
7700,
396,
910,
674,
451,
2758,
304,
671,
379,
2725,
515,
350,
361,
17627,
297,
2254,
13,
13,
1678,
1583,
29889,
1885,
1707,
580,
13,
268,
13,
13,
29871,
822,
679,
29918,
1707,
29898,
1311,
29892,
722,
29892,
15101,
29922,
8516,
29892,
474,
861,
29922,
8516,
29892,
13607,
29891,
29922,
8516,
29892,
474,
466,
29922,
8516,
29892,
5912,
29922,
8516,
1125,
29871,
13,
1678,
14550,
13,
1678,
7523,
29879,
278,
3651,
515,
263,
22395,
313,
277,
467,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
722,
448,
1347,
13,
4706,
4408,
310,
278,
2286,
304,
1303,
29889,
13,
29871,
13,
1678,
274,
3174,
29899,
5900,
29871,
13,
4706,
29436,
964,
274,
3174,
10340,
29889,
3986,
13,
1678,
319,
9100,
29901,
29871,
13,
1678,
448,
807,
13,
4706,
503,
29899,
8990,
338,
3412,
278,
2425,
13,
4706,
921,
322,
343,
27815,
505,
871,
697,
6856,
29889,
29871,
13,
268,
13,
1678,
10343,
1048,
2971,
948,
2272,
3489,
29901,
29871,
13,
1678,
448,
9072,
29899,
13,
1678,
14550,
13,
13,
1678,
565,
15101,
1275,
6213,
29901,
13,
4706,
15101,
353,
1583,
29889,
29879,
8971,
13,
1678,
565,
722,
297,
1583,
29889,
1707,
29876,
29889,
8149,
7295,
29871,
13,
418,
722,
978,
29922,
1311,
29889,
1707,
29876,
29961,
1707,
29962,
13,
1678,
1683,
29901,
13,
418,
722,
978,
29922,
1707,
13,
13,
1678,
396,
2158,
29898,
1707,
29892,
1707,
978,
5501,
2202,
1495,
13,
1678,
396,
2158,
29898,
1311,
29889,
5415,
29889,
8149,
3101,
13,
1678,
1018,
29901,
29871,
13,
4706,
565,
1583,
29889,
2838,
29918,
348,
1169,
1275,
525,
29883,
3174,
2396,
13,
9651,
722,
29884,
29922,
1707,
29889,
6506,
877,
29916,
3788,
1495,
13,
9651,
722,
29884,
29922,
1707,
29884,
29889,
6506,
877,
29891,
3788,
1495,
13,
9651,
722,
29884,
29922,
1707,
29884,
29889,
6506,
877,
29920,
3788,
1495,
13,
632,
13,
9651,
565,
313,
1707,
297,
1583,
29889,
1707,
29876,
29889,
8149,
3101,
322,
313,
1707,
29884,
297,
1583,
29889,
3909,
29889,
3909,
29889,
8149,
580,
1125,
29871,
13,
18884,
274,
3174,
348,
1169,
353,
1583,
29889,
3909,
29889,
3909,
29961,
1707,
29884,
29962,
13,
9651,
1683,
29901,
13,
18884,
274,
3174,
348,
1169,
353,
29871,
29896,
29889,
29900,
13,
4706,
1683,
29901,
13,
9651,
274,
3174,
348,
1169,
353,
29871,
29896,
29889,
29900,
13,
308,
13,
4706,
396,
2158,
29898,
1707,
978,
29897,
13,
4706,
1583,
29889,
1272,
353,
1583,
29889,
5415,
29961,
1707,
978,
3816,
29879,
8971,
14178,
29883,
3174,
348,
1169,
259,
13,
268,
13,
1678,
396,
1311,
29889,
5499,
5415,
17255,
657,
5552,
12035,
1707,
978,
29897,
334,
274,
3174,
348,
1169,
13,
1678,
5174,
29901,
29871,
13,
13,
418,
1583,
29889,
1272,
353,
2254,
29918,
12150,
1907,
29898,
1311,
29892,
1707,
29892,
7390,
3289,
1529,
29918,
13356,
13566,
2433,
742,
315,
29979,
6154,
29918,
15989,
2433,
742,
13,
18884,
23958,
29943,
1525,
29918,
13356,
13566,
2433,
742,
23958,
29943,
3960,
29918,
13356,
13566,
2433,
742,
306,
1164,
29925,
29918,
13356,
13566,
2433,
742,
13,
18884,
382,
3718,
2882,
29918,
13356,
13566,
2433,
742,
323,
25951,
29918,
13356,
13566,
2433,
742,
5012,
22716,
29923,
29918,
29931,
29940,
29918,
13356,
13566,
2433,
742,
13,
18884,
315,
1672,
1254,
2882,
29918,
13356,
13566,
2433,
742,
4810,
29965,
3927,
9486,
29918,
15032,
29918,
13356,
13566,
2433,
742,
319,
9486,
29918,
13356,
13566,
2433,
742,
29871,
13,
18884,
379,
9818,
29918,
13356,
13566,
2433,
742,
350,
1299,
4945,
29979,
29918,
13356,
13566,
2433,
742,
10937,
1806,
29999,
1001,
29918,
13356,
13566,
2433,
742,
29871,
13,
18884,
476,
3301,
7228,
29918,
13356,
13566,
2433,
742,
402,
29979,
1672,
29943,
29918,
13356,
13566,
2433,
742,
399,
7520,
29923,
29918,
13356,
13566,
2433,
742,
29871,
13,
18884,
383,
29931,
29965,
29990,
29918,
13356,
13566,
2433,
742,
315,
4574,
29450,
29918,
13356,
13566,
2433,
742,
23958,
3217,
29965,
29918,
13356,
13566,
2433,
742,
259,
13,
18884,
23958,
3217,
29965,
4345,
29918,
13356,
13566,
2433,
742,
23958,
29943,
1525,
29924,
29990,
29918,
13356,
13566,
2433,
1495,
13,
13,
418,
565,
7442,
29889,
12181,
29898,
1311,
29889,
1272,
29897,
1275,
313,
1125,
13,
4706,
565,
1583,
29889,
369,
15828,
29901,
29871,
13,
3986,
1596,
877,
23456,
23342,
2286,
742,
355,
543,
29905,
29878,
613,
23126,
29922,
5574,
29897,
13,
4706,
1583,
29889,
1272,
353,
2254,
29918,
279,
18542,
29918,
12150,
1907,
29898,
1311,
29892,
1707,
29897,
268,
13,
13,
1678,
565,
722,
1275,
525,
2396,
29871,
13,
13,
418,
1596,
29898,
8477,
29898,
1311,
29889,
657,
29918,
1707,
876,
13,
418,
1596,
877,
26865,
29902,
6181,
29903,
3148,
4214,
8446,
29903,
6323,
402,
1430,
1001,
2965,
405,
6488,
1430,
6154,
1299,
11499,
1495,
13,
418,
363,
13607,
297,
1583,
29889,
1707,
29876,
29901,
29871,
13,
3986,
1596,
877,
1509,
13420,
13607,
5501,
363,
13420,
1311,
29889,
1707,
29876,
29961,
2236,
2314,
13,
418,
1596,
29898,
1311,
29889,
8216,
1839,
9818,
11287,
29871,
13,
418,
396,
2158,
28909,
29876,
2971,
948,
5446,
338,
1583,
29889,
5499,
5415,
29892,
1583,
29889,
5499,
5415,
29889,
1707,
29918,
3888,
338,
408,
4477,
1495,
13,
418,
396,
2158,
29898,
1311,
29889,
5499,
5415,
29889,
1707,
29918,
3888,
29897,
13,
268,
13,
418,
736,
6213,
13,
13,
1678,
396,
1311,
29889,
3286,
29906,
5464,
510,
3317,
267,
580,
13,
268,
13,
1678,
736,
1583,
29889,
1272,
13,
13,
29871,
822,
2531,
1707,
29898,
1311,
1125,
29871,
13,
1678,
14550,
13,
1678,
13343,
310,
2441,
3651,
607,
674,
2758,
304,
3588,
304,
274,
3174,
29889,
29871,
13,
1678,
14550,
13,
1678,
1583,
29889,
1707,
29876,
3790,
29913,
13,
1678,
1583,
29889,
1707,
29876,
1839,
4650,
2033,
29922,
525,
4650,
29915,
13,
1678,
1583,
29889,
1707,
29876,
1839,
29873,
29887,
2033,
353,
525,
29873,
29887,
29915,
13,
1678,
1583,
29889,
1707,
29876,
1839,
1314,
2033,
353,
525,
1314,
29915,
13,
1678,
1583,
29889,
1707,
29876,
1839,
8631,
2033,
353,
525,
8631,
29915,
13,
1678,
1583,
29889,
1707,
29876,
1839,
3365,
2033,
353,
525,
3365,
29915,
13,
1678,
1583,
29889,
1707,
29876,
1839,
29890,
29916,
2033,
353,
525,
29890,
29916,
29915,
13,
1678,
1583,
29889,
1707,
29876,
1839,
1609,
2033,
353,
525,
1609,
29915,
13,
1678,
1583,
29889,
1707,
29876,
1839,
29890,
29920,
2033,
353,
525,
29890,
29920,
29915,
13,
1678,
1583,
29889,
1707,
29876,
1839,
484,
2033,
353,
525,
484,
29915,
13,
13,
13,
29871,
822,
1301,
29906,
2055,
29898,
1311,
29892,
1707,
978,
29892,
29879,
8971,
29922,
29900,
29892,
3579,
19290,
1125,
29871,
13,
1678,
14550,
13,
1678,
4103,
689,
278,
5354,
964,
263,
376,
9435,
29908,
3402,
29889,
2178,
7049,
674,
367,
29871,
29941,
29928,
29889,
450,
29871,
29941,
5499,
9685,
29871,
13,
1678,
338,
29901,
29871,
13,
13,
418,
448,
363,
29871,
29941,
29928,
15489,
8096,
267,
29901,
29871,
278,
11408,
9685,
13,
418,
448,
363,
2425,
1134,
15489,
8096,
267,
29901,
3412,
278,
2425,
29871,
13,
418,
448,
363,
29871,
29896,
29928,
25005,
29901,
278,
5412,
9927,
338,
278,
29871,
29941,
5499,
9685,
29889,
29871,
13,
418,
2180,
3203,
697,
4805,
9927,
4225,
304,
367,
2825,
19069,
635,
29889,
29871,
13,
13,
1678,
2178,
310,
963,
881,
26449,
278,
1492,
1361,
5751,
29871,
13,
13,
1678,
512,
599,
310,
963,
29892,
278,
12047,
313,
955,
25245,
29892,
15611,
1746,
2992,
29897,
3448,
515,
278,
8991,
29889,
29871,
13,
13,
1678,
960,
16058,
29892,
503,
29922,
29900,
2978,
278,
20612,
9085,
29889,
29871,
13,
13,
1678,
28386,
29901,
4129,
338,
297,
274,
3174,
29889,
29871,
13,
268,
13,
1678,
960,
385,
1409,
338,
11837,
29892,
437,
29871,
299,
2378,
29889,
8552,
3285,
6467,
282,
3637,
25350,
674,
752,
7420,
29889,
29871,
13,
13,
1678,
14550,
13,
13,
1678,
1583,
29889,
2838,
29918,
348,
1169,
353,
525,
29883,
3174,
29915,
13,
13,
1678,
565,
451,
756,
5552,
29898,
1311,
5501,
3286,
29918,
8235,
29374,
1678,
13,
4706,
1583,
29889,
3286,
29918,
8235,
29922,
29941,
29872,
29955,
13,
1678,
565,
451,
756,
5552,
29898,
1311,
5501,
3286,
29918,
4518,
29374,
1678,
13,
4706,
1583,
29889,
3286,
29918,
4518,
29922,
29941,
29872,
29955,
13,
1678,
565,
451,
756,
5552,
29898,
1311,
5501,
3286,
29918,
5601,
29374,
1678,
13,
4706,
1583,
29889,
3286,
29918,
5601,
29922,
29941,
29872,
29955,
13,
13,
268,
13,
1678,
363,
1820,
29892,
995,
297,
9049,
5085,
29889,
7076,
7295,
13,
418,
565,
1820,
1275,
525,
8235,
2396,
29871,
13,
4706,
565,
756,
5552,
29898,
1311,
5501,
3286,
29918,
8235,
29374,
13,
9651,
565,
995,
2804,
1583,
29889,
3286,
29918,
8235,
29901,
29871,
13,
795,
1583,
29889,
3286,
348,
1169,
353,
7700,
13,
418,
565,
1820,
1275,
525,
5601,
2396,
29871,
13,
4706,
565,
756,
5552,
29898,
1311,
5501,
3286,
29918,
5601,
29374,
13,
9651,
565,
995,
2804,
1583,
29889,
3286,
29918,
5601,
29901,
29871,
13,
795,
1583,
29889,
3286,
348,
1169,
353,
7700,
13,
13,
1678,
565,
1583,
29889,
29879,
8971,
2804,
15101,
29901,
29871,
13,
4706,
1583,
29889,
29879,
8971,
29922,
29879,
8971,
13,
4706,
1583,
29889,
3286,
348,
1169,
353,
7700,
13,
268,
13,
1678,
396,
1707,
353,
1583,
29889,
657,
29918,
1707,
29898,
1707,
978,
29897,
13,
268,
13,
1678,
396,
5618,
947,
445,
437,
29973,
13,
1678,
396,
1311,
29889,
3286,
29906,
510,
3317,
267,
29898,
1707,
29892,
3579,
19290,
29897,
13,
268,
13,
1678,
565,
451,
756,
5552,
29898,
1311,
5501,
3286,
29918,
7888,
29918,
2103,
29374,
1678,
13,
4706,
1583,
29889,
3286,
29918,
7888,
29918,
2103,
29922,
29896,
29889,
29900,
13,
1678,
565,
451,
756,
5552,
29898,
1311,
5501,
3286,
29918,
29879,
5510,
29374,
1678,
13,
4706,
1583,
29889,
3286,
29918,
29879,
5510,
29922,
5574,
13,
632,
13,
1678,
363,
1820,
29892,
995,
297,
9049,
5085,
29889,
7076,
7295,
13,
418,
565,
1820,
1275,
525,
7888,
29918,
2103,
2396,
29871,
13,
4706,
1583,
29889,
3286,
29918,
7888,
29918,
2103,
353,
995,
13,
418,
565,
1820,
1275,
525,
348,
7052,
2396,
29871,
13,
4706,
437,
29918,
735,
567,
29883,
744,
353,
995,
13,
418,
565,
1820,
1275,
525,
29879,
5510,
2396,
29871,
13,
4706,
1583,
29889,
3286,
29918,
29879,
5510,
353,
995,
13,
268,
13,
1678,
444,
402,
16033,
1192,
269,
3317,
471,
3939,
29871,
29896,
29906,
386,
4779,
29871,
29906,
29900,
29906,
29896,
29889,
2823,
3440,
297,
1301,
29906,
510,
3317,
267,
13,
1678,
444,
29879,
3317,
353,
269,
29889,
3317,
580,
29871,
13,
13,
1678,
8267,
353,
313,
27696,
29898,
1311,
29889,
1062,
296,
29961,
29896,
16261,
1311,
29889,
3286,
29918,
8235,
511,
29871,
13,
632,
2257,
309,
29898,
1311,
29889,
1062,
296,
29961,
29941,
16261,
1311,
29889,
3286,
29918,
4518,
511,
29871,
13,
632,
2257,
309,
29898,
1311,
29889,
1062,
296,
29961,
29945,
16261,
1311,
29889,
3286,
29918,
5601,
7240,
29896,
29897,
13,
268,
13,
1678,
396,
512,
278,
349,
1525,
7818,
1904,
297,
278,
1034,
2681,
29892,
2551,
573,
6856,
3291,
1122,
367,
3196,
17036,
3448,
515,
1269,
916,
29889,
13,
1678,
396,
512,
445,
1206,
29892,
817,
304,
2143,
457,
2425,
29889,
13,
1678,
396,
1867,
29918,
735,
567,
29883,
744,
353,
7700,
13,
1678,
396,
1454,
1820,
29892,
995,
297,
9049,
5085,
29889,
7076,
7295,
13,
1678,
396,
1678,
565,
1820,
1275,
525,
348,
7052,
2396,
29871,
13,
1678,
396,
4706,
437,
29918,
735,
567,
29883,
744,
353,
995,
13,
632,
13,
1678,
396,
361,
1583,
29889,
7720,
19790,
1405,
29871,
29896,
29901,
13,
1678,
396,
1678,
565,
437,
29918,
735,
567,
29883,
744,
29901,
29871,
13,
1678,
396,
4706,
17971,
29892,
722,
29922,
2143,
457,
29898,
29879,
29892,
7442,
29889,
1188,
29898,
1707,
511,
19790,
29922,
1311,
29889,
7720,
19790,
29892,
443,
7052,
29922,
9302,
29889,
4548,
29897,
13,
1678,
396,
1678,
1683,
29901,
29871,
13,
1678,
396,
4706,
17971,
29892,
722,
29922,
2143,
457,
29898,
29879,
29892,
722,
29892,
19790,
29922,
1311,
29889,
7720,
19790,
29897,
13,
1678,
396,
2870,
29901,
13,
1678,
396,
1678,
17971,
353,
269,
13,
1678,
396,
1707,
29918,
8552,
353,
722,
29889,
8552,
580,
13,
13,
1678,
921,
29918,
7888,
29871,
353,
1583,
29889,
5415,
1839,
29916,
2033,
29961,
1311,
29889,
29879,
8971,
29962,
29871,
13,
1678,
343,
29918,
7888,
29871,
353,
1583,
29889,
5415,
1839,
29891,
2033,
29961,
1311,
29889,
29879,
8971,
29962,
29871,
13,
1678,
503,
29918,
7888,
29871,
353,
1583,
29889,
5415,
1839,
29920,
2033,
29961,
1311,
29889,
29879,
8971,
29962,
29871,
13,
1678,
269,
29918,
7888,
29871,
353,
1583,
29889,
5415,
1839,
29879,
2033,
29961,
1311,
29889,
29879,
8971,
29962,
13,
1678,
921,
29918,
7888,
22361,
921,
29918,
7888,
29889,
1195,
580,
13,
1678,
343,
29918,
7888,
22361,
343,
29918,
7888,
29889,
1195,
580,
13,
1678,
503,
29918,
7888,
22361,
503,
29918,
7888,
29889,
1195,
580,
13,
13,
1678,
722,
353,
1583,
29889,
657,
29918,
1707,
29898,
1707,
978,
29892,
29879,
8971,
29922,
1311,
29889,
29879,
8971,
29897,
13,
13,
1678,
1596,
29898,
29879,
29918,
7888,
29892,
722,
29897,
13,
1678,
921,
29918,
7888,
29892,
343,
29918,
7888,
29892,
503,
29918,
7888,
29892,
722,
353,
1583,
29889,
3286,
29906,
510,
3317,
267,
29898,
29916,
29918,
7888,
29892,
343,
29918,
7888,
29892,
503,
29918,
7888,
29892,
722,
29892,
269,
29918,
7888,
29892,
29871,
3579,
19290,
29897,
13,
268,
13,
1678,
396,
22711,
27497,
313,
262,
2971,
5834,
29897,
13,
1678,
270,
29909,
353,
7442,
29889,
2873,
29898,
1707,
29889,
12181,
11877,
1311,
29889,
3286,
29918,
8235,
29930,
1311,
29889,
3286,
29918,
4518,
29930,
1311,
29889,
3286,
29918,
5601,
13,
1678,
921,
513,
353,
7442,
29889,
14939,
29898,
29916,
29918,
7888,
29914,
1311,
29889,
3286,
29918,
8235,
467,
579,
668,
29898,
9302,
29889,
524,
29953,
29946,
29897,
13,
1678,
343,
513,
353,
7442,
29889,
14939,
29898,
29891,
29918,
7888,
29914,
1311,
29889,
3286,
29918,
4518,
467,
579,
668,
29898,
9302,
29889,
524,
29953,
29946,
29897,
13,
1678,
503,
513,
353,
7442,
29889,
24049,
29898,
9302,
29889,
14939,
29898,
29920,
29918,
7888,
29914,
1311,
29889,
3286,
29918,
5601,
467,
579,
668,
29898,
9302,
29889,
524,
29953,
29946,
511,
29900,
29892,
12181,
29961,
29906,
29962,
29899,
29896,
29897,
13,
13,
1678,
396,
8561,
14591,
310,
12104,
411,
385,
921,
29899,
10289,
29871,
13,
1678,
363,
921,
10289,
297,
3464,
6278,
12181,
29961,
29900,
1402,
12181,
29961,
29900,
1402,
29896,
29900,
1125,
13,
4706,
445,
29918,
29879,
8971,
353,
1583,
29889,
29879,
8971,
718,
921,
10289,
718,
8267,
29961,
29900,
29962,
13,
4706,
921,
29918,
7888,
29871,
353,
1583,
29889,
5415,
1839,
29916,
2033,
29961,
1366,
29918,
29879,
8971,
29962,
13,
4706,
343,
29918,
7888,
29871,
353,
1583,
29889,
5415,
1839,
29891,
2033,
29961,
1366,
29918,
29879,
8971,
29962,
13,
4706,
503,
29918,
7888,
29871,
353,
1583,
29889,
5415,
1839,
29920,
2033,
29961,
1366,
29918,
29879,
8971,
29962,
13,
4706,
269,
29918,
7888,
29871,
353,
1583,
29889,
5415,
1839,
29879,
2033,
29961,
1366,
29918,
29879,
8971,
29962,
13,
4706,
921,
29918,
7888,
22361,
921,
29918,
7888,
29889,
1195,
580,
13,
4706,
343,
29918,
7888,
22361,
343,
29918,
7888,
29889,
1195,
580,
13,
4706,
503,
29918,
7888,
22361,
503,
29918,
7888,
29889,
1195,
580,
13,
4706,
445,
29918,
1707,
353,
1583,
29889,
657,
29918,
1707,
29898,
1707,
978,
29892,
29879,
8971,
29922,
1366,
29918,
29879,
8971,
29897,
13,
4706,
1596,
29898,
1366,
29918,
29879,
8971,
29892,
269,
29918,
7888,
29889,
12181,
29897,
13,
308,
13,
4706,
921,
29918,
7888,
29892,
343,
29918,
7888,
29892,
503,
29918,
7888,
29892,
445,
29918,
1707,
353,
1583,
29889,
3286,
29906,
510,
3317,
267,
29898,
29916,
29918,
7888,
29892,
343,
29918,
7888,
29892,
503,
29918,
7888,
29892,
269,
29918,
7888,
29892,
445,
29918,
1707,
29892,
3579,
19290,
29897,
13,
13,
308,
13,
4706,
921,
513,
353,
7442,
29889,
535,
29883,
2579,
403,
3552,
29916,
513,
29892,
7442,
29889,
14939,
3552,
29916,
29918,
7888,
29974,
29916,
10289,
29930,
1311,
29889,
3286,
29918,
8235,
6802,
1311,
29889,
3286,
29918,
8235,
467,
579,
668,
29898,
9302,
29889,
524,
29953,
29946,
4961,
13,
4706,
343,
513,
353,
7442,
29889,
535,
29883,
2579,
403,
3552,
29891,
513,
29892,
7442,
29889,
14939,
29898,
29891,
29918,
7888,
29914,
1311,
29889,
3286,
29918,
4518,
467,
579,
668,
29898,
9302,
29889,
524,
29953,
29946,
4961,
13,
4706,
503,
513,
353,
7442,
29889,
535,
29883,
2579,
403,
3552,
29920,
513,
29892,
7442,
29889,
24049,
29898,
9302,
29889,
14939,
29898,
29920,
29918,
7888,
29914,
1311,
29889,
3286,
29918,
5601,
467,
579,
668,
29898,
9302,
29889,
524,
29953,
29946,
511,
29900,
29892,
12181,
29961,
29906,
29962,
29899,
29896,
4961,
13,
308,
13,
4706,
270,
29909,
353,
7442,
29889,
535,
29883,
2579,
403,
3552,
29881,
29909,
29892,
7442,
29889,
2873,
29898,
1707,
29889,
12181,
11877,
1311,
29889,
3286,
29918,
8235,
29930,
1311,
29889,
3286,
29918,
4518,
29930,
1311,
29889,
3286,
29918,
5601,
876,
13,
4706,
722,
353,
7442,
29889,
535,
29883,
2579,
403,
3552,
1707,
29892,
29871,
445,
29918,
1707,
876,
13,
13,
1678,
1781,
353,
313,
29916,
513,
18572,
29900,
11877,
29898,
29916,
513,
29966,
12181,
29961,
29900,
2314,
13,
1678,
1781,
29930,
29922,
313,
29891,
513,
18572,
29900,
11877,
29898,
29891,
513,
29966,
12181,
29961,
29896,
2314,
13,
1678,
1781,
29930,
29922,
313,
29920,
513,
18572,
29900,
11877,
29898,
29920,
513,
29966,
12181,
29961,
29906,
2314,
13,
1678,
921,
513,
353,
921,
513,
29961,
16773,
29962,
13,
1678,
343,
513,
353,
343,
513,
29961,
16773,
29962,
13,
1678,
503,
513,
353,
503,
513,
29961,
16773,
29962,
13,
1678,
270,
29909,
259,
353,
270,
29909,
29961,
16773,
29962,
13,
1678,
722,
353,
722,
29961,
16773,
29962,
13,
268,
13,
1678,
396,
22402,
4636,
411,
1897,
14821,
6590,
304,
1298,
3412,
2425,
13,
1678,
396,
322,
1948,
14821,
6590,
304,
2602,
297,
12370,
18970,
6856,
13,
1678,
784,
353,
7442,
29889,
279,
927,
29898,
2435,
29898,
29916,
513,
511,
29881,
1853,
29922,
9302,
29889,
524,
29953,
29946,
29897,
13,
1678,
1948,
353,
313,
29916,
513,
29930,
12181,
29961,
29896,
10062,
29891,
513,
11877,
12181,
29961,
29906,
10062,
29920,
513,
13,
13,
1678,
565,
1583,
29889,
3286,
29918,
29879,
5510,
29901,
13,
4706,
341,
353,
1302,
29877,
29918,
5344,
3552,
29881,
29909,
14571,
1311,
29889,
3286,
29918,
8235,
29930,
1311,
29889,
3286,
29918,
4518,
29930,
1311,
29889,
3286,
29918,
5601,
511,
29871,
13,
462,
4706,
313,
798,
29892,
1054,
8243,
12181,
7607,
12181,
29961,
29900,
14178,
12181,
29961,
29896,
14178,
12181,
29961,
29906,
1402,
7431,
29898,
29916,
513,
8243,
26688,
29922,
9302,
29889,
7411,
29897,
13,
4706,
341,
353,
341,
29889,
517,
2395,
29878,
580,
13,
1678,
1683,
29901,
13,
4706,
341,
353,
7442,
29889,
3298,
359,
29898,
12181,
7607,
12181,
29961,
29900,
14178,
12181,
29961,
29896,
14178,
12181,
29961,
29906,
1402,
7431,
29898,
893,
8243,
26688,
29922,
9302,
29889,
7411,
29897,
13,
4706,
341,
29961,
798,
29892,
1054,
29962,
353,
270,
29909,
14571,
1311,
29889,
8235,
29896,
29881,
29930,
1311,
29889,
5601,
29896,
29881,
29889,
3317,
3101,
29871,
396,
7915,
292,
491,
4038,
310,
15232,
10768,
13,
1678,
13,
1678,
396,
450,
2186,
14728,
472,
1269,
12370,
18970,
6856,
3038,
338,
385,
7977,
29899,
7915,
287,
29871,
13,
1678,
396,
6588,
310,
1819,
515,
2425,
6819,
1549,
445,
6856,
3038,
13,
1678,
396,
910,
7049,
526,
451,
2869,
1304,
363,
478,
2287,
29924,
4805,
428,
13,
1678,
722,
353,
313,
29924,
29992,
1707,
467,
690,
14443,
29898,
12181,
29897,
13,
13,
1678,
1583,
29889,
29916,
353,
7442,
29889,
1915,
3493,
29898,
1311,
29889,
29916,
29918,
7888,
29889,
1195,
3285,
1311,
29889,
29916,
29918,
7888,
29889,
3317,
3285,
9302,
29889,
12181,
29898,
1707,
9601,
29900,
2314,
13,
1678,
1583,
29889,
29891,
353,
7442,
29889,
1915,
3493,
29898,
1311,
29889,
29891,
29918,
7888,
29889,
1195,
3285,
1311,
29889,
29891,
29918,
7888,
29889,
3317,
3285,
9302,
29889,
12181,
29898,
1707,
9601,
29896,
2314,
13,
1678,
1583,
29889,
29920,
353,
7442,
29889,
1915,
3493,
29898,
1311,
29889,
29920,
29918,
7888,
29889,
1195,
3285,
1311,
29889,
29920,
29918,
7888,
29889,
3317,
3285,
9302,
29889,
12181,
29898,
1707,
9601,
29906,
2314,
13,
268,
13,
1678,
1583,
29889,
8235,
29896,
29881,
353,
7442,
29889,
24970,
29898,
1311,
29889,
29916,
29897,
13,
1678,
1583,
29889,
4518,
29896,
29881,
353,
7442,
29889,
24970,
29898,
1311,
29889,
29891,
29897,
13,
1678,
1583,
29889,
5601,
29896,
29881,
353,
7442,
29889,
24970,
29898,
1311,
29889,
29920,
29897,
13,
308,
13,
1678,
736,
722,
13,
13,
29871,
822,
1301,
29906,
510,
3317,
267,
29898,
1311,
29892,
921,
29892,
343,
29892,
503,
29892,
269,
29892,
722,
29892,
3579,
19290,
1125,
29871,
13,
13,
1678,
565,
1583,
29889,
3286,
348,
1169,
1275,
7700,
29901,
13,
13,
418,
565,
451,
756,
5552,
29898,
1311,
5501,
3286,
29918,
8235,
29374,
1678,
13,
4706,
1583,
29889,
3286,
29918,
8235,
29922,
29941,
29872,
29955,
13,
418,
565,
451,
756,
5552,
29898,
1311,
5501,
3286,
29918,
4518,
29374,
1678,
13,
4706,
1583,
29889,
3286,
29918,
4518,
29922,
29941,
29872,
29955,
13,
418,
565,
451,
756,
5552,
29898,
1311,
5501,
3286,
29918,
5601,
29374,
1678,
13,
4706,
1583,
29889,
3286,
29918,
5601,
29922,
29941,
29872,
29955,
13,
13,
418,
363,
1820,
29892,
995,
297,
9049,
5085,
29889,
7076,
7295,
13,
4706,
565,
1820,
1275,
525,
8235,
2396,
13,
3986,
1583,
29889,
3286,
29918,
8235,
353,
995,
13,
4706,
565,
1820,
1275,
525,
4518,
2396,
13,
3986,
1583,
29889,
3286,
29918,
4518,
353,
995,
13,
4706,
565,
1820,
1275,
525,
5601,
2396,
13,
3986,
1583,
29889,
3286,
29918,
5601,
353,
995,
13,
632,
13,
418,
396,
9444,
293,
2076,
1070,
2425,
268,
13,
418,
396,
29879,
353,
1583,
29889,
5415,
1839,
29879,
2033,
396,
9302,
29889,
8552,
29898,
1311,
29889,
29920,
12683,
29897,
13,
418,
396,
16773,
353,
313,
29879,
6736,
29900,
29889,
29900,
29897,
13,
418,
396,
29879,
353,
269,
29961,
16773,
29962,
13,
3986,
13,
418,
396,
29916,
353,
1583,
29889,
29916,
29871,
13,
418,
396,
29891,
353,
1583,
29889,
29891,
13,
418,
396,
29920,
353,
1583,
29889,
29920,
29871,
13,
268,
13,
418,
396,
12181,
353,
313,
27696,
29898,
29916,
29889,
3317,
580,
29914,
1311,
29889,
3286,
29918,
8235,
511,
27696,
29898,
29891,
29889,
3317,
580,
29914,
1311,
29889,
3286,
29918,
4518,
511,
2257,
309,
29898,
1311,
29889,
29920,
3317,
29914,
1311,
29889,
3286,
29918,
5601,
876,
13,
268,
13,
418,
396,
512,
278,
390,
3035,
29979,
29940,
1904,
297,
278,
1034,
2681,
29892,
2551,
573,
6856,
3291,
1122,
367,
3196,
17036,
3448,
515,
1269,
916,
29889,
13,
418,
396,
512,
445,
1206,
29892,
817,
304,
2143,
457,
2425,
29889,
13,
418,
4236,
11671,
353,
7442,
29889,
3676,
3552,
29920,
29961,
29896,
17531,
29899,
29920,
29961,
29900,
13018,
29896,
2314,
1068,
29906,
29974,
313,
29916,
29961,
29896,
17531,
29899,
29916,
29961,
29900,
13018,
29896,
2314,
1068,
29906,
718,
313,
29891,
29961,
29896,
17531,
29899,
29891,
29961,
29900,
13018,
29896,
2314,
1068,
29906,
13742,
3317,
580,
13,
418,
6856,
19790,
353,
2257,
309,
29898,
29906,
29930,
3317,
11671,
29914,
9302,
29889,
1195,
4197,
1311,
29889,
3286,
29918,
8235,
29892,
1311,
29889,
3286,
29918,
4518,
29892,
1311,
29889,
3286,
29918,
5601,
12622,
13,
268,
13,
418,
437,
29918,
735,
567,
29883,
744,
353,
7700,
13,
418,
363,
1820,
29892,
995,
297,
9049,
5085,
29889,
7076,
7295,
13,
4706,
565,
1820,
1275,
525,
348,
7052,
2396,
29871,
13,
9651,
437,
29918,
735,
567,
29883,
744,
353,
995,
13,
13,
418,
565,
6856,
19790,
1405,
29871,
29896,
29901,
13,
4706,
1596,
29898,
29879,
29892,
29916,
29897,
13,
4706,
17971,
29892,
921,
29918,
7888,
353,
2143,
457,
29898,
29879,
29892,
29916,
29892,
7329,
29922,
7720,
19790,
29897,
13,
4706,
17971,
29892,
343,
29918,
7888,
353,
2143,
457,
29898,
29879,
29892,
29891,
29892,
7329,
29922,
7720,
19790,
29897,
13,
4706,
17971,
29892,
503,
29918,
7888,
353,
2143,
457,
29898,
29879,
29892,
29920,
29892,
7329,
29922,
7720,
19790,
29897,
13,
4706,
565,
437,
29918,
735,
567,
29883,
744,
29901,
29871,
13,
9651,
17971,
29892,
722,
29918,
7888,
353,
2143,
457,
29898,
29879,
29892,
7442,
29889,
1188,
29898,
1707,
511,
19790,
29922,
7720,
19790,
29892,
443,
7052,
29922,
9302,
29889,
4548,
29897,
13,
4706,
1683,
29901,
29871,
13,
9651,
17971,
29892,
722,
29918,
7888,
353,
2143,
457,
29898,
29879,
29892,
722,
29892,
19790,
29922,
7720,
19790,
29897,
13,
418,
1683,
29901,
13,
4706,
921,
29918,
7888,
353,
921,
29889,
8552,
580,
13,
4706,
343,
29918,
7888,
353,
343,
29889,
8552,
580,
13,
4706,
503,
29918,
7888,
353,
503,
29889,
8552,
580,
13,
4706,
722,
29918,
7888,
353,
722,
29889,
8552,
580,
13,
13,
418,
1583,
29889,
8235,
29896,
29881,
29918,
7888,
353,
7442,
29889,
24970,
29898,
29916,
29918,
7888,
29897,
13,
418,
1583,
29889,
4518,
29896,
29881,
29918,
7888,
353,
7442,
29889,
24970,
29898,
29891,
29918,
7888,
29897,
13,
418,
1583,
29889,
5601,
29896,
29881,
29918,
7888,
353,
7442,
29889,
24970,
29898,
29920,
29918,
7888,
29897,
13,
268,
13,
418,
1583,
29889,
3286,
348,
1169,
353,
5852,
13,
418,
736,
921,
29918,
7888,
29892,
343,
29918,
7888,
29892,
503,
29918,
7888,
29892,
722,
29918,
7888,
13,
308,
13,
13,
29871,
822,
1301,
29906,
5464,
510,
3317,
267,
29898,
1311,
1125,
29871,
13,
13,
1678,
565,
1583,
29889,
3286,
348,
1169,
1275,
5852,
29901,
13,
418,
1583,
29889,
29916,
353,
7442,
29889,
2378,
4197,
29900,
29889,
29900,
2314,
13,
418,
1583,
29889,
29891,
353,
7442,
29889,
2378,
4197,
29900,
29889,
29900,
2314,
13,
418,
1583,
29889,
29920,
353,
1583,
29889,
5499,
5415,
17255,
657,
5552,
1649,
877,
14018,
1495,
13,
13,
418,
1583,
29889,
8235,
353,
7442,
29889,
2378,
4197,
29896,
29889,
29900,
2314,
13,
418,
1583,
29889,
4518,
353,
7442,
29889,
2378,
4197,
29896,
29889,
29900,
2314,
13,
418,
1583,
29889,
5601,
353,
7442,
29889,
8552,
29898,
1311,
29889,
29920,
29897,
13,
418,
1583,
29889,
29876,
29920,
353,
7442,
29889,
12181,
29898,
1311,
29889,
29920,
9601,
29896,
29962,
13,
418,
363,
372,
297,
3464,
29898,
29900,
29892,
1311,
29889,
593,
1125,
13,
4706,
1583,
29889,
5601,
29961,
277,
29892,
17531,
353,
7442,
29889,
24970,
29898,
1311,
29889,
29920,
29961,
277,
29892,
29901,
2314,
13,
418,
1583,
29889,
5601,
29896,
29881,
353,
1583,
29889,
5601,
13,
418,
1583,
29889,
8235,
29896,
29881,
353,
7442,
29889,
2378,
4197,
29896,
29889,
29900,
2314,
13,
418,
1583,
29889,
4518,
29896,
29881,
353,
7442,
29889,
2378,
4197,
29896,
29889,
29900,
2314,
13,
13,
418,
1583,
29889,
23818,
353,
7442,
29889,
12181,
29898,
1311,
29889,
29916,
29897,
13,
418,
1583,
29889,
1460,
353,
7442,
29889,
12181,
29898,
1311,
29889,
29891,
29897,
13,
418,
1583,
29889,
3286,
348,
1169,
353,
7700,
13,
13,
268,
13,
1990,
349,
1525,
7818,
29918,
348,
1169,
29898,
3318,
1125,
29871,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
369,
15828,
29922,
8824,
1125,
13,
4706,
14550,
13,
4706,
28386,
322,
17727,
297,
274,
3174,
13,
4706,
14550,
13,
4706,
1583,
29889,
3909,
3790,
29913,
13,
4706,
1583,
29889,
369,
15828,
353,
26952,
29871,
13,
4706,
1583,
29889,
3909,
1839,
29873,
29887,
2033,
268,
353,
29871,
29896,
29889,
29900,
13,
4706,
1583,
29889,
3909,
1839,
29880,
2033,
418,
353,
29871,
29896,
29889,
29900,
13,
4706,
1583,
29889,
3909,
1839,
29876,
2033,
418,
353,
29871,
29896,
29889,
29900,
13,
4706,
1583,
29889,
3909,
1839,
4650,
2033,
1678,
353,
29871,
29896,
29889,
29900,
13,
4706,
1583,
29889,
3909,
1839,
29884,
2033,
418,
353,
29871,
29896,
29889,
29900,
13,
4706,
1583,
29889,
3909,
1839,
29890,
2033,
418,
353,
29871,
29896,
29889,
29900,
13,
4706,
1583,
29889,
3909,
1839,
29873,
2033,
418,
353,
29871,
29896,
29889,
29900,
396,
6923,
13,
4706,
1583,
29889,
3909,
1839,
29926,
2033,
418,
353,
29871,
29896,
29889,
29900,
13,
13,
4706,
396,
28386,
322,
17727,
297,
22717,
13,
4706,
3588,
2395,
29887,
1039,
29898,
1311,
29897,
13,
13,
4706,
5534,
16908,
29898,
1311,
29897,
13,
2
] |
src/backend/common/models/notifications/tests/notification_test.py | bovlb/the-blue-alliance | 0 | 130477 | import pytest
from firebase_admin import messaging
from backend.common.consts.fcm.platform_priority import PlatformPriority
from backend.common.models.fcm.platform_config import PlatformConfig
from backend.common.models.notifications.notification import Notification
from backend.common.models.notifications.tests.mocks.notifications.mock_notification import (
MockNotification,
)
def test_str():
fcm_notification = messaging.Notification(title="Title Here", body="Body here")
data_payload = {"data": "payload"}
platform_config = PlatformConfig(
priority=PlatformPriority.HIGH, collapse_key="general_collapse_key"
)
apns_config = messaging.APNSConfig(headers={"apns-collapse-id": "ios_collapse_key"})
notification = MockNotification(
fcm_notification=fcm_notification,
data_payload=data_payload,
platform_config=platform_config,
apns_config=apns_config,
)
assert (
str(notification)
== "MockNotification(data_payload={'data': 'payload'} fcm_notification.title=\"Title Here\" fcm_notification.body=\"Body here\" platform_config=PlatformConfig(collapse_key=\"general_collapse_key\" priority=1) apns_config={'apns-collapse-id': 'ios_collapse_key'} webhook_message_data={'data': 'payload'})"
)
def test_type_raises():
with pytest.raises(NotImplementedError):
Notification._type()
def test_webhook_message_data_same_data_payload():
data_payload = {"data": "here"}
notification = MockNotification(data_payload=data_payload)
assert notification.data_payload == data_payload
assert notification.webhook_message_data == data_payload
def test_webhook_message_data():
webhook_message_data = {"data": "here"}
notification = MockNotification(webhook_message_data=webhook_message_data)
assert notification.data_payload is None
assert notification.webhook_message_data == webhook_message_data
| [
1,
1053,
11451,
1688,
13,
3166,
16119,
29918,
6406,
1053,
4473,
6751,
13,
13,
3166,
14998,
29889,
9435,
29889,
3075,
29879,
29889,
29888,
4912,
29889,
12120,
29918,
29886,
21766,
1053,
28096,
29925,
21766,
13,
3166,
14998,
29889,
9435,
29889,
9794,
29889,
29888,
4912,
29889,
12120,
29918,
2917,
1053,
28096,
3991,
13,
3166,
14998,
29889,
9435,
29889,
9794,
29889,
1333,
8232,
29889,
24671,
1053,
28578,
13,
3166,
14998,
29889,
9435,
29889,
9794,
29889,
1333,
8232,
29889,
21150,
29889,
17640,
29879,
29889,
1333,
8232,
29889,
17640,
29918,
24671,
1053,
313,
13,
1678,
26297,
12958,
29892,
13,
29897,
13,
13,
13,
1753,
1243,
29918,
710,
7295,
13,
1678,
285,
4912,
29918,
24671,
353,
4473,
6751,
29889,
12958,
29898,
3257,
543,
7030,
2266,
613,
3573,
543,
8434,
1244,
1159,
13,
1678,
848,
29918,
23813,
353,
8853,
1272,
1115,
376,
23813,
9092,
13,
1678,
7481,
29918,
2917,
353,
28096,
3991,
29898,
13,
4706,
20136,
29922,
21889,
29925,
21766,
29889,
29950,
6259,
29950,
29892,
24382,
29918,
1989,
543,
17492,
29918,
27756,
29918,
1989,
29908,
13,
1678,
1723,
13,
1678,
3095,
1983,
29918,
2917,
353,
4473,
6751,
29889,
3301,
3059,
3991,
29898,
13662,
3790,
29908,
481,
1983,
29899,
27756,
29899,
333,
1115,
376,
2363,
29918,
27756,
29918,
1989,
29908,
1800,
13,
13,
1678,
12519,
353,
26297,
12958,
29898,
13,
4706,
285,
4912,
29918,
24671,
29922,
29888,
4912,
29918,
24671,
29892,
13,
4706,
848,
29918,
23813,
29922,
1272,
29918,
23813,
29892,
13,
4706,
7481,
29918,
2917,
29922,
12120,
29918,
2917,
29892,
13,
4706,
3095,
1983,
29918,
2917,
29922,
481,
1983,
29918,
2917,
29892,
13,
1678,
1723,
13,
1678,
4974,
313,
13,
4706,
851,
29898,
24671,
29897,
13,
4706,
1275,
376,
18680,
12958,
29898,
1272,
29918,
23813,
3790,
29915,
1272,
2396,
525,
23813,
10827,
285,
4912,
29918,
24671,
29889,
3257,
14672,
7030,
2266,
5931,
285,
4912,
29918,
24671,
29889,
2587,
14672,
8434,
1244,
5931,
7481,
29918,
2917,
29922,
21889,
3991,
29898,
27756,
29918,
1989,
14672,
17492,
29918,
27756,
29918,
1989,
5931,
20136,
29922,
29896,
29897,
3095,
1983,
29918,
2917,
3790,
29915,
481,
1983,
29899,
27756,
29899,
333,
2396,
525,
2363,
29918,
27756,
29918,
1989,
10827,
1856,
20849,
29918,
4906,
29918,
1272,
3790,
29915,
1272,
2396,
525,
23813,
29915,
1800,
29908,
13,
1678,
1723,
13,
13,
13,
1753,
1243,
29918,
1853,
29918,
336,
4637,
7295,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
3664,
1888,
2037,
287,
2392,
1125,
13,
4706,
28578,
3032,
1853,
580,
13,
13,
13,
1753,
1243,
29918,
2676,
20849,
29918,
4906,
29918,
1272,
29918,
17642,
29918,
1272,
29918,
23813,
7295,
13,
1678,
848,
29918,
23813,
353,
8853,
1272,
1115,
376,
4150,
9092,
13,
1678,
12519,
353,
26297,
12958,
29898,
1272,
29918,
23813,
29922,
1272,
29918,
23813,
29897,
13,
1678,
4974,
12519,
29889,
1272,
29918,
23813,
1275,
848,
29918,
23813,
13,
1678,
4974,
12519,
29889,
2676,
20849,
29918,
4906,
29918,
1272,
1275,
848,
29918,
23813,
13,
13,
13,
1753,
1243,
29918,
2676,
20849,
29918,
4906,
29918,
1272,
7295,
13,
1678,
1856,
20849,
29918,
4906,
29918,
1272,
353,
8853,
1272,
1115,
376,
4150,
9092,
13,
1678,
12519,
353,
26297,
12958,
29898,
2676,
20849,
29918,
4906,
29918,
1272,
29922,
2676,
20849,
29918,
4906,
29918,
1272,
29897,
13,
1678,
4974,
12519,
29889,
1272,
29918,
23813,
338,
6213,
13,
1678,
4974,
12519,
29889,
2676,
20849,
29918,
4906,
29918,
1272,
1275,
1856,
20849,
29918,
4906,
29918,
1272,
13,
2
] |
pylink/report.py | stanford-ssi/pylink | 31 | 137208 | <reponame>stanford-ssi/pylink<gh_stars>10-100
#!/usr/bin/python
import collections
import distutils.sysconfig
import jinja2
import matplotlib.pyplot as plt
import numpy as np
import os
import site
import pylink.utils as utils
class Figure(object):
def __init__(self, title=None):
self.title = title
def to_latex(self, dname='.', fname=None):
if not fname:
fname = self.fname()
# LaTeX does NOT play nicely with backslashes in windows
path = os.path.join(dname, fname).replace('\\', '/')
return '''
\\begin{figure}
\\caption{%s}
\\includegraphics[width=\\linewidth]{%s}
\\label{fig::pfd::%s}
\\end{figure}
''' % (self.caption(), path, self.label())
def _plot_vs_el(self, y_func, dname='.', fname=None):
m = self.model
e = self.model.enum
orig_el = m.override_value(e.min_elevation_deg)
fig = plt.figure()
if self.title:
fig.suptitle(self.title)
ax = fig.add_subplot(1, 1, 1)
# Plot any limit lines
if 'pfd_limits' in vars(self) and self.pfd_limits:
x = [p[0] for p in self.pfd_limits]
y = [p[1] for p in self.pfd_limits]
ax.plot(x, y, color='r', linewidth=2, label='Limit')
# Now plot the PFD curve
x = np.linspace(0.0, 90.0, 90)
y = np.linspace(0.0, 90.0, 90)
for i in range(len(x)):
m.override(e.min_elevation_deg, x[i])
y[i] = y_func(i)
ax.plot(x, y, color='b')
ax.set_xlabel('Elevation Angle (degrees)')
ax.set_ylabel(self.ylabel())
# XXX: matplotlib is doing weird things if you set ylim this way
# if 'pfd_limits' in vars(self) and self.pfd_limits:
# upper = max(max(y), self.pfd_limits[-1][1])
# lower = min(min(y), self.pfd_limits[0][1])
# delta = upper - lower
# upper += delta*0.1
# lower -= delta*0.1
# plt.ylim(lower, upper)
# else:
# upper = max(y)
# lower = min(y)
if not fname:
fname = self.fname()
path = os.path.join(dname, fname)
fig.savefig(path, transparent=True)
if orig_el is not None:
m.override(e.min_elevation_deg, orig_el)
else:
m.reset(e.min_elevation_deg)
class CanonicalPFDFigure(Figure):
"""Power Flux Density figure for the canonical PFD vs Elevation
The canonical figure assumes complete and even use of the
spectrum, and it also tends to assume max eirp from the
transmitter. Becauses this model is really only used for
compliance purposes, we ignore things like rain losses.
This figure also assumes we are dealing with a space-to-earth
link. For NGSO to GSO, or earth-to-space, this figure is
inapplicable.
* Space-to-Earth
* Boresight
* Full BW Utilization
"""
def __init__(self,
model,
bw=4e3,
pfd_limits=None,
title=None):
"""Creates a new canonical pfd figure.
model -- The DAG model.
bw -- BW for the PFD (defaults to 4kHz
pfd_limits -- If it is PFD vs elevation, also plot these PFD limits
"""
self.title = title
self.model = model
self.pfd_limits = pfd_limits
self.bw = bw
def label(self):
return 'pfd-canonical-%d%s' % utils.human_hz(self.bw)
def fname(self):
return 'pfd-canonical-%d%s.png' % utils.human_hz(self.bw)
def ylabel(self):
return 'Boresight PFD (dBW/m^2/%d%s)' % utils.human_hz(self.bw)
def caption(self):
return "Peak PFD at Earth Station assuming full BW utilization"
def plot(self, dname='.', fname=None):
def __y(i):
m = self.model
return utils.pfd_hz_manual_adjust(m.canonical_pf_dbw_per_m2,
m.allocation_hz,
self.bw)
return self._plot_vs_el(__y, dname=dname, fname=fname)
class ExpectedPFDFigure(Figure):
"""Power Flux Density figure for the expected case
The expected case is much more complicated and includes things
like antenna patterns, satellite pointing, and modulation code
selection. Typically, when a higher modulation code is selected,
the BW utilization drops slightly resulting in slightly higher PFD
because the total signal power is spread over slightly fewer Hz.
As a result, this graph is not expected to be smooth. It should,
however, be monotonic.
This figure also assumes we are dealing with a space-to-earth
link. For NGSO to GSO, or earth-to-space, this figure is
inapplicable.
* Space-to-Earth
* Expected antenna gain
* Expected BW utilization
"""
def __init__(self,
model,
bw=4e3,
pfd_limits=None,
title=None):
"""Creates a new canonical pfd figure.
model -- The DAG model.
bw -- BW for the PFD (defaults to 4kHz
pfd_limits -- If it is PFD vs elevation, also plot these PFD limits
"""
self.title = title
self.model = model
self.pfd_limits = pfd_limits
self.bw = bw
def label(self):
return 'pfd-expected-%d%s' % utils.human_hz(self.bw)
def ylabel(self):
return 'Expected PFD (dBW/m^2/%d%s)' % utils.human_hz(self.bw)
def fname(self):
return 'pfd-expected-%d%s.png' % utils.human_hz(self.bw)
def caption(self):
return "Expected PFD at Earth Station under normal operations"
def plot(self, dname='.', fname=None):
def __y(i):
return utils.rx_pfd_hz_adjust(self.model,
self.model.pf_dbw_per_m2,
self.bw)
return self._plot_vs_el(__y, dname=dname, fname=fname)
class PFDvsBWFigure(Figure):
"""Peak Power Flux Density figure vs BandWidth
For compliance reasons, it can be useful to show a graph of the
peak acheivable PFD vs BW for both the receiver and the GSO case.
* Space-to-Earth or Earth-to-Space
* Peak antenna gain
* Full BW utilization
* GSO or Receiver
"""
def __init__(self,
model,
start_hz=1,
end_hz=4e3,
is_gso=False,
pfd_limits=None,
title=None):
"""Creates a new figure.
model -- The DAG model.
start_hz -- If so, starting BW
end_hz -- And the ending BW
is_gso -- True if looking at PFD at GSO, otherwise it is the receiver
pfd_limits -- plot these PFD limits
"""
self.title = title
self.model = model
self.start_hz = start_hz
self.end_hz = end_hz
self.is_gso = is_gso
self.pfd_limits = pfd_limits
def fname(self):
prefix = 'gso' if self.is_gso else 'rx'
prefix = 'pfd-' + prefix
return '%s_%d-%d.png' % (prefix, self.start_hz, self.end_hz)
def label(self):
prefix = 'gso' if self.is_gso else 'rx'
return '%s_%d-%d' % (prefix, self.start_hz, self.end_hz)
def caption(self):
if self.is_gso:
return 'Peak PFD at GSO vs Bandwidth'
else:
if self.model.is_downlink:
return 'Peak PFD at Surface vs Bandwidth'
else:
return 'Peak PFD at Receiver vs Bandwidth'
def plot(self, dname='.', fname=None):
m = self.model
if self.is_gso:
pf = m.peak_pf_at_geo_dbw_per_m2
else:
pf = m.peak_pf_dbw_per_m2
fig = plt.figure()
if self.title:
fig.suptitle(self.title)
ax = fig.add_subplot(1, 1, 1)
n = int(self.end_hz) - int(self.start_hz)
x = np.linspace(1, n, n-1)
x += self.start_hz
y = np.zeros(n-1)
for i in range(len(x)):
bw = x[i]
y[i] = utils.pfd_hz_manual_adjust(pf, m.allocation_hz, bw)
ax.plot(x, y, color='b', label='PFD (dBW/m^2)')
# Plot any limit lines
if self.pfd_limits:
x = [p[0] for p in self.pfd_limits]
y = [p[1] for p in self.pfd_limits]
ax.plot(x, y, color='r', linewidth=2, label='Limit')
ax.set_xlabel('Bandwidth (Hz)')
if self.is_gso:
ax.set_ylabel('PFD at GSO(dBW/m^2)')
else:
ax.set_ylabel('PFD at Receiver (dBW/m^2)')
if not fname:
fname = self.fname()
path = os.path.join(dname, fname)
fig.savefig(path, transparent=True)
class BitrateFigure(Figure):
"""Max bitrate vs Elevation Figure
This graph assumes normal operations and indicates the max
available bitrate.
"""
def __init__(self, model, title):
self.model = model
self.title = title
def label(self):
return 'max-bitrate'
def fname(self):
return 'max-bitrate.png'
def caption(self):
return 'Bitrate with %ddB of Link Margin vs Elevation' % self.model.target_margin_db
def ylabel(self):
return 'Max Bitrate (MHz)'
def plot(self, dname='.', fname=None):
def __y(i):
R = self.model.max_bitrate_hz
m = self.model
return self.model.max_bitrate_hz / 1.0e6
return self._plot_vs_el(__y, dname=dname, fname=fname)
class Report(object):
"""LaTeX report Generator.
Generates latex reports with great extensibility for either
general engineering, or compliance reports for people like
NOAA/NASA/FCC/ITU/ESA/TLA/ETLA.
"""
def __init__(self, model):
self.model = model
self.enum = model.enum
def _table(self, items, use_headers=True):
m = self.model
table = ''
table += '\\begin{tabular}{p{3in}p{1in}l}\n'
for section in items:
s = section
if section == 'Transmitter': s = 'Transmitter (%s)' % m.transmitter_name
if section == 'Receiver': s = 'Receiver (%s)' % m.rx_name
if use_headers:
table += '\\textbf{%s} & & \\\\\n' % s
table += '\\hline \\\\\n'
lines = items[section]
for line in lines:
v = line[1]
v = '%.2f' % v if isinstance(v, float) else '%s' % v
table += '%s & %s & $%s$ \\\\\n' % (line[0],
v,
line[2])
table += '\\\\\n'
table += '\\end{tabular}\n'
return table
def _rx_chain_table(self):
m = self.model
e = m.enum
chain = m.rx_rf_chain
fields = [('Element', '', 1.25),
('Gain', 'dB', .47),
('Noise Figure', 'dB', .47),
#('Gain Factor', '', .5),
#('Noise Factor', '', .5),
('Noise Temp.', 'K', .5),
('Upstream Gain Factor', '', .6),
('Contrib. Noise Temp', 'K', .5),
('Contrib. Noise Factor', '', .5),
('Noise Temp Pct Contrib.', '\\%', .75),
]
field_definitions = ''.join(['p{%sin}' % f[-1] for f in fields])
table = ['\\hspace*{-0.75in} \\begin{tabular}{%s}' % field_definitions]
# titles
row = ['\\textbf{%s}' % f[0] for f in fields]
table.append(' & '.join(row) + '\\\\')
table.append('\hline \\\\')
# Units
row = []
for f in fields:
if len(f[1]):
row.append('\\textbf{$%s$}' % (f[1]))
else:
row.append('')
table.append(' & '.join(row) + '\\\\')
table.append('\hline \\\\')
for el in chain:
pct = el.noise_temp_contrib / m.rx_system_noise_temp_k
def __process_element(val):
if isinstance(val, int):
return str(val)
if val > 100:
return str(int(val))
if val > 1000:
return '%g'%val
return '%.2f' % val
row = [el.gain_db,
el.noise_figure_db,
el.noise_temp_k,
el.prev_gain,
el.noise_temp_contrib,
el.noise_factor_contrib,
] + [pct*100.0,]
row = [el.name] + [__process_element(v) for v in row]
row = (' & '.join(row)) + '\\\\'
table.append(row)
table.append('\\end{tabular}')
return '\n'.join(table)
def _humanize_hz(self, label, val):
return (label,) + utils.human_hz(val)
def _humanize_m(self, label, val):
return (label,) + utils.human_m(val)
def _static_pfd_entry(self, bw=0, is_gso=False):
m = self.model
if is_gso:
retval = m.peak_pf_at_geo_dbw_per_m2
else:
retval = m.peak_pf_dbw_per_m2
pfd_per_hz = retval - m.required_rx_bw_dbhz
if bw:
retval = pfd_per_hz + min(utils.to_db(bw), m.required_rx_bw_dbhz)
(bw, bw_unit,) = utils.human_hz(bw)
if is_gso:
label = 'Peak PFD at GSO per %.2g%s' % (bw, bw_unit)
elif m.is_downlink:
label = 'Peak PFD at Surface per %.2g%s' % (bw, bw_unit)
else:
label = 'Peak PFD at Receiver per %.2g%s' % (bw, bw_unit)
unit = 'dBW/m^2/%.2g%s' % (bw, bw_unit)
else:
if is_gso:
label = 'Peak PFD at GSO'
else:
if m.is_downlink:
label = 'Peak PFD at Surface'
else:
label = 'Peak PFD at Receiver'
unit = 'dBW/m^2'
return (label, retval, unit,)
def _to_label(self, s):
return self._file_namify(s)
def _file_namify(self, s):
for c in "\"'. \t":
s = s.replace(c, '_')
return s
def to_latex(self,
fname,
author='',
intro='',
expo='',
rx_pfd_bws=[],
gso_pfd_bws=[],
pfd_figures=[],
added_sections=[],
added_interference_sections=[],
bitrate_figure=None,
watermark_text=None):
"""Export the budget to LaTeX
fname -- Top level latex path
author -- The author's name/entry in the header
intro -- An optional section of latex to be included after the title
expo -- An optional section of latex to be included at the end
rx_pfd_bws -- List of PFD BW's to include in the interference section
gso_pfd_bws -- List of PFD BW's to include in the interference section
added_sections -- Additional sections to add before the budget section
added_iterference_sections -- Additional subsections for interference
pfd_figures -- Any desired PFD figure objects
bitrate_figure -- Any desired bitrate figure objects
watermark_text -- Watermark text (such as DRAFT or CONFIDENTIAL)
Interference Subsections:
[('Subsection Title', [
('Item Name', item_value, 'units'),
('Another Item Name', another_value, 'units'),
]),]
Additional Sections:
[('Section Name', [
subsection,
subsection,
]),]
"""
m = self.model
e = self.model.enum
dname = os.path.dirname(fname)
if intro is None:
intro = ''
top = self._jinja().get_template('budget.tex')
orbit_items = collections.OrderedDict([
('Orbit', [
('Apoapsis', m.apoapsis_altitude_km, 'km'),
('Periapsis', m.periapsis_altitude_km, 'km'),
('Mean Altitude', m.mean_orbit_altitude_km, 'km'),
]),
('Constants', [
('Earth Radius', m.earth_radius_km, 'km'),
('GS Angle of Elevation', m.min_elevation_deg, '^{\\circ}'),
]),
('Key Outputs', [
('Slant Range', m.slant_range_km, 'km'),
('Satellite Angle from Boresight', m.satellite_antenna_angle_deg, '^{\\circ}'),
]),
])
tx_items = collections.OrderedDict([
('Antenna', [
('Sampled Gain', m.tx_antenna_gain_dbi, 'dBi'),
('Antenna Pointing Loss', m.tx_antenna_pointing_loss_db, 'dB'),
('Gain at Boresight', m.tx_antenna_boresight_gain_dbi, 'dBi'),
('Average Nadir Gain', m.tx_antenna_average_nadir_gain_dbi, 'dBi'),
('Polarization', m.tx_antenna_polarization, ''),
]),
('Transmitter', [
('Transmit Power at PA', m.tx_power_at_pa_dbw, 'dBW'),
('Inline Losses', m.tx_inline_losses_db, 'dB'),
('Transmit Power at Antenna', m.tx_power_at_antenna_dbw, 'dBW'),
('EIRP', m.tx_eirp_dbw, 'dBW'),
# EVM
]),
])
interference_sections = [
('Transmitter', [
('Transmit Power at Antenna', m.tx_power_at_antenna_dbw, 'dBW'),
('Peak Antenna Gain', m.tx_antenna_peak_gain_dbi, 'dBi'),
('Peak EIRP', m.peak_tx_eirp_dbw, 'dBW'),
('Nadir-to-GS Gain', m.tx_antenna_gain_dbi, 'dBi'),
('Nadir-to-GS EIRP', m.tx_eirp_dbw, 'dBW'),
('Average Antenna Gain', m.tx_antenna_average_gain_dbi, 'dBi'),
]),
]
pfd_lst = []
for bw in rx_pfd_bws:
pfd_lst.append(self._static_pfd_entry(bw=bw, is_gso=False))
for bw in gso_pfd_bws:
pfd_lst.append(self._static_pfd_entry(bw=bw, is_gso=True))
if len(pfd_lst):
interference_sections.append(('Peak Power Flux Density at Receiver', pfd_lst))
interference_sections += added_interference_sections
interference_items = collections.OrderedDict(interference_sections)
channel_items = collections.OrderedDict([
('Constants', [
self._humanize_hz('Center Frequency', m.center_freq_hz),
('Speed of Light', int(m.speed_of_light_m_per_s), 'm/s'),
self._humanize_hz('Allocated Bandwidth', m.allocation_hz),
self._humanize_hz('Start of Allocation', m.allocation_start_hz),
self._humanize_hz('End of Allocation', m.allocation_end_hz),
('Wavelength',) + utils.human_m(m.wavelength_m),
]),
('Losses', [
('Unity Gain Propagation Loss', m.unity_gain_propagation_loss_db, 'dB'),
('Atmospheric Loss', m.atmospheric_loss_db, 'dB'),
('Ionospheric Loss', m.ionospheric_loss_db, 'dB'),
('Rain Loss', m.rain_loss_db, 'dB'),
('Multipath Fading Loss', m.multipath_fading_db, 'dB'),
('Total Channel Loss', m.total_channel_loss_db, 'dB'),
]),
('Modulation (%s)' % m.modulation_name, [
('Modulation Name', m.modulation_name, ''),
('Modulation Code', m.best_modulation_code.name, ''),
('Tx Spectral Efficiency', m.best_modulation_code.tx_eff, ''),
self._humanize_hz('Bitrate', m.bitrate_hz),
('Bitrate', m.bitrate_dbhz, 'dBHz'),
('Required Demodulation $E_b/N_0$', m.required_demod_ebn0_db, 'dB'),
self._humanize_hz('Required Demod Bandwidth', m.required_rx_bw_hz),
('Required Demod Bandwidth', m.required_rx_bw_dbhz, 'dBHz'),
('Required Transmit Bandwidth', m.required_tx_bw_dbhz, 'dBHz'),
]),
])
rx_items = collections.OrderedDict([
('Antenna', [
('Noise Temperature', m.rx_antenna_noise_temp_k, 'K'),
('Sampled Gain', m.rx_antenna_gain_dbi, 'dBi'),
('Antenna Pointing Loss', m.rx_antenna_pointing_loss_db, 'dB'),
('Gain at Boresight', m.rx_antenna_boresight_gain_dbi, 'dBi'),
('Average Nadir Gain', m.rx_antenna_average_nadir_gain_dbi, 'dBi'),
('Polarization', m.rx_antenna_polarization, ''),
]),
('System', [
('Total Receiver Noise Temperature', m.rx_noise_temp_k, 'K'),
('Total Receiver Noise Temperature', m.rx_noise_temp_dbk, 'dBK'),
('Receive Chain Noise Temperature', m.rx_system_noise_temp_k, 'K'),
('Receive Chain Noise Factor', m.rx_system_noise_factor, ''),
('Receive Chain Noise Figure', m.rx_system_noise_figure, 'dB'),
self._humanize_hz('Receiver Noise Bandwidth', m.bitrate_hz),
('Implementation Loss', m.implementation_loss_db, 'dB'),
]),
])
budget_items = collections.OrderedDict([
('Transmitter', [
('Power at Antenna', m.tx_power_at_antenna_dbw, 'dBW'),
('Gain', m.tx_antenna_gain_dbi, 'dBi'),
('Antenna Pointing Loss', m.tx_antenna_pointing_loss_db, 'dB'),
('EIRP', m.tx_eirp_dbw, 'dBW'),
]),
('Channel', [
self._humanize_hz('Center Frequency', m.center_freq_hz),
('Free Space Loss', m.unity_gain_propagation_loss_db, 'dB'),
('Total Channel Loss', m.total_channel_loss_db, 'dB'),
('Occupied Bandwidth', m.required_tx_bw_dbhz, 'dBHz'),
]),
('Receiver', [
('Signal Power Flux at RX Antenna', m.pf_dbw_per_m2, 'dBW/m^2'),
('Antenna Gain', m.rx_antenna_gain_dbi, 'dBi'),
('Antenna Effective Area', m.rx_antenna_effective_area_dbm2, 'dBm^2'),
('Polarization Mismatch Loss', m.polarization_mismatch_loss_db, 'dB'),
('RX System Noise Temperature', m.rx_noise_temp_k, 'K'),
('RX Figure of Merit ($G/T$)', m.rx_g_over_t_db, 'dB/K'),
('Noise Spectral Density ($N_0$)', m.rx_n0_dbw_per_hz, 'dBW/Hz'),
('Received Signal Power', m.rx_power_dbw, 'dBW'),
('Excess Noise BW Loss', m.excess_noise_bandwidth_loss_db, 'dB'),
('Implementation Loss', m.implementation_loss_db, 'dB'),
('Required Demodulation $E_b/N_0$', m.required_demod_ebn0_db, 'dB'),
('Antenna Pointing Loss', m.rx_antenna_pointing_loss_db, 'dB'),
('Carrier to Noise ($C/N_0$)', m.cn0_db, 'dBHz'),
]),
('Eb/N0', [
('BitRate', m.bitrate_dbhz, 'dBHz'),
('Energy per Bit ($E_b$)', m.rx_eb, 'dBW/Hz'),
('Received $E_b/N_0$', m.rx_ebn0_db, 'dB'),
('Required $E_b/N_0$', m.required_ebn0_db, 'dB'),
]),
('Key Outputs', [
self._humanize_hz('Bitrate', m.bitrate_hz),
('Link Margin', m.link_margin_db, 'dB'),
]),
])
rx_pattern_fname = '%sRXPattern.png' % self._file_namify(m.budget_name)
m.rx_antenna_obj.plot_pattern(os.path.join(dname, rx_pattern_fname))
tx_pattern_fname = '%sTXPattern.png' % self._file_namify(m.budget_name)
m.tx_antenna_obj.plot_pattern(os.path.join(dname, tx_pattern_fname))
if watermark_text:
draft_mark = '''
\\newwatermark[allpages,color=black!10,angle=45,scale=3,xpos=0,ypos=0]{%s}
''' % watermark_text
# \\newwatermark[allpages,color=black!10,angle=45,scale=3,xpos=0,ypos=2in]{DRAFT}
else:
draft_mark = ''
if len(expo) > 0:
expo = '\\newpage\n' + expo
figs = []
for fig in pfd_figures:
fig.plot(dname=os.path.dirname(fname))
figs.append(fig.to_latex())
interference_figures = '\n'.join(figs)
if bitrate_figure:
bitrate_figure.plot(dname=os.path.dirname(fname))
budget_figures = bitrate_figure.to_latex()
else:
budget_figures = ''
added_tables = []
for section_name, section in added_sections:
added_tables.append('''
\\newpage
\\section{%s}
\\label{section::%s}
\\begin{center}
''' % (section_name, self._to_label(section_name)))
added_tables.append(self._table(collections.OrderedDict(section)))
added_tables.append('\\end{center}')
kwargs = {
'intro':intro,
'expo':expo,
'budgetTitle': m.budget_name,
'table': self._table(budget_items),
'interferenceFigures': interference_figures,
'txPatternFname': tx_pattern_fname,
'rxPatternFname': rx_pattern_fname,
'draftMark': draft_mark,
'orbitTable': self._table(orbit_items),
'transmitterTable': self._table(tx_items),
'channelTable': self._table(channel_items),
'receiverTable': self._table(rx_items),
'rxChainTable': self._rx_chain_table(),
'interferenceTable': self._table(interference_items),
'author': author,
'addedSections': '\n'.join(added_tables),
'budgetFigures': budget_figures,
}
with open(fname, 'w') as fd:
fd.write(top.render(**kwargs))
def _jinja(self, basedir=None):
if not basedir:
lib = distutils.sysconfig.get_python_lib()
rel = 'pylink/tex'
basedir = os.path.join(lib, rel)
env = jinja2.Environment(
block_start_string = '\BLOCK{',
block_end_string = '}',
variable_start_string = '\VAR{',
variable_end_string = '}',
comment_start_string = '\#{',
comment_end_string = '}',
line_statement_prefix = '%%',
line_comment_prefix = '%#',
trim_blocks = True,
autoescape = False,
loader = jinja2.FileSystemLoader(basedir))
return env
| [
1,
529,
276,
1112,
420,
29958,
14411,
4006,
29899,
893,
29875,
29914,
2272,
2324,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29899,
29896,
29900,
29900,
13,
29937,
14708,
4855,
29914,
2109,
29914,
4691,
13,
13,
5215,
16250,
13,
5215,
1320,
13239,
29889,
9675,
2917,
13,
5215,
432,
262,
1764,
29906,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
12655,
408,
7442,
13,
5215,
2897,
13,
5215,
3268,
13,
13,
5215,
11451,
2324,
29889,
13239,
408,
3667,
29879,
13,
13,
13,
1990,
11479,
29898,
3318,
1125,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3611,
29922,
8516,
1125,
13,
4706,
1583,
29889,
3257,
353,
3611,
13,
13,
1678,
822,
304,
29918,
25694,
29898,
1311,
29892,
270,
978,
2433,
29889,
742,
285,
978,
29922,
8516,
1125,
13,
13,
4706,
565,
451,
285,
978,
29901,
13,
9651,
285,
978,
353,
1583,
29889,
29888,
978,
580,
13,
13,
4706,
396,
29186,
947,
6058,
1708,
28138,
411,
1250,
17057,
267,
297,
5417,
13,
4706,
2224,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29881,
978,
29892,
285,
978,
467,
6506,
877,
1966,
742,
8207,
1495,
13,
13,
4706,
736,
14550,
13,
29871,
2474,
463,
29912,
4532,
29913,
13,
1678,
2474,
6671,
18255,
29879,
29913,
13,
1678,
2474,
7313,
29961,
2103,
29922,
1966,
16292,
3199,
29995,
29879,
29913,
13,
1678,
2474,
1643,
29912,
1003,
1057,
7810,
29881,
1057,
29995,
29879,
29913,
13,
29871,
2474,
355,
29912,
4532,
29913,
13,
4706,
14550,
1273,
313,
1311,
29889,
6671,
3285,
2224,
29892,
1583,
29889,
1643,
3101,
13,
13,
1678,
822,
903,
5317,
29918,
4270,
29918,
295,
29898,
1311,
29892,
343,
29918,
9891,
29892,
270,
978,
2433,
29889,
742,
285,
978,
29922,
8516,
1125,
13,
4706,
286,
353,
1583,
29889,
4299,
13,
4706,
321,
353,
1583,
29889,
4299,
29889,
18605,
13,
13,
4706,
1677,
29918,
295,
353,
286,
29889,
15752,
29918,
1767,
29898,
29872,
29889,
1195,
29918,
29872,
2608,
362,
29918,
12163,
29897,
13,
13,
4706,
2537,
353,
14770,
29889,
4532,
580,
13,
4706,
565,
1583,
29889,
3257,
29901,
13,
9651,
2537,
29889,
2146,
415,
1740,
29898,
1311,
29889,
3257,
29897,
13,
4706,
4853,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29897,
13,
13,
4706,
396,
18399,
738,
4046,
3454,
13,
4706,
565,
525,
7810,
29881,
29918,
12514,
29915,
297,
24987,
29898,
1311,
29897,
322,
1583,
29889,
7810,
29881,
29918,
12514,
29901,
13,
9651,
921,
353,
518,
29886,
29961,
29900,
29962,
363,
282,
297,
1583,
29889,
7810,
29881,
29918,
12514,
29962,
13,
9651,
343,
353,
518,
29886,
29961,
29896,
29962,
363,
282,
297,
1583,
29889,
7810,
29881,
29918,
12514,
29962,
13,
9651,
4853,
29889,
5317,
29898,
29916,
29892,
343,
29892,
2927,
2433,
29878,
742,
1196,
2103,
29922,
29906,
29892,
3858,
2433,
24445,
1495,
13,
13,
4706,
396,
2567,
6492,
278,
349,
26453,
11672,
13,
4706,
921,
353,
7442,
29889,
1915,
3493,
29898,
29900,
29889,
29900,
29892,
29871,
29929,
29900,
29889,
29900,
29892,
29871,
29929,
29900,
29897,
13,
4706,
343,
353,
7442,
29889,
1915,
3493,
29898,
29900,
29889,
29900,
29892,
29871,
29929,
29900,
29889,
29900,
29892,
29871,
29929,
29900,
29897,
13,
13,
4706,
363,
474,
297,
3464,
29898,
2435,
29898,
29916,
22164,
13,
9651,
286,
29889,
15752,
29898,
29872,
29889,
1195,
29918,
29872,
2608,
362,
29918,
12163,
29892,
921,
29961,
29875,
2314,
13,
9651,
343,
29961,
29875,
29962,
353,
343,
29918,
9891,
29898,
29875,
29897,
13,
13,
4706,
4853,
29889,
5317,
29898,
29916,
29892,
343,
29892,
2927,
2433,
29890,
1495,
13,
4706,
4853,
29889,
842,
29918,
29916,
1643,
877,
29923,
2608,
362,
3218,
280,
313,
311,
7979,
267,
29897,
1495,
13,
4706,
4853,
29889,
842,
29918,
29891,
1643,
29898,
1311,
29889,
29891,
1643,
3101,
13,
13,
4706,
396,
22615,
29901,
22889,
338,
2599,
13543,
2712,
565,
366,
731,
343,
2576,
445,
982,
13,
4706,
396,
565,
525,
7810,
29881,
29918,
12514,
29915,
297,
24987,
29898,
1311,
29897,
322,
1583,
29889,
7810,
29881,
29918,
12514,
29901,
13,
4706,
396,
268,
7568,
353,
4236,
29898,
3317,
29898,
29891,
511,
1583,
29889,
7810,
29881,
29918,
12514,
14352,
29896,
3816,
29896,
2314,
13,
4706,
396,
268,
5224,
353,
1375,
29898,
1195,
29898,
29891,
511,
1583,
29889,
7810,
29881,
29918,
12514,
29961,
29900,
3816,
29896,
2314,
13,
13,
4706,
396,
268,
19471,
353,
7568,
448,
5224,
13,
4706,
396,
268,
7568,
4619,
19471,
29930,
29900,
29889,
29896,
13,
4706,
396,
268,
5224,
22361,
19471,
29930,
29900,
29889,
29896,
13,
13,
4706,
396,
268,
14770,
29889,
29891,
2576,
29898,
13609,
29892,
7568,
29897,
13,
4706,
396,
1683,
29901,
13,
4706,
396,
268,
7568,
353,
4236,
29898,
29891,
29897,
13,
4706,
396,
268,
5224,
353,
1375,
29898,
29891,
29897,
13,
13,
4706,
565,
451,
285,
978,
29901,
13,
9651,
285,
978,
353,
1583,
29889,
29888,
978,
580,
13,
4706,
2224,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29881,
978,
29892,
285,
978,
29897,
13,
4706,
2537,
29889,
7620,
1003,
29898,
2084,
29892,
17772,
29922,
5574,
29897,
13,
13,
4706,
565,
1677,
29918,
295,
338,
451,
6213,
29901,
13,
9651,
286,
29889,
15752,
29898,
29872,
29889,
1195,
29918,
29872,
2608,
362,
29918,
12163,
29892,
1677,
29918,
295,
29897,
13,
4706,
1683,
29901,
13,
9651,
286,
29889,
12071,
29898,
29872,
29889,
1195,
29918,
29872,
2608,
362,
29918,
12163,
29897,
13,
13,
13,
1990,
1815,
265,
936,
13691,
4037,
335,
545,
29898,
13080,
545,
1125,
13,
1678,
9995,
21472,
2379,
1314,
360,
575,
537,
4377,
363,
278,
24420,
349,
26453,
7186,
382,
2608,
362,
13,
13,
1678,
450,
24420,
4377,
15894,
4866,
322,
1584,
671,
310,
278,
13,
1678,
18272,
29892,
322,
372,
884,
29867,
304,
5251,
4236,
321,
381,
29886,
515,
278,
13,
1678,
22649,
357,
29889,
29871,
350,
687,
1485,
267,
445,
1904,
338,
2289,
871,
1304,
363,
13,
1678,
752,
13036,
11976,
29892,
591,
11455,
2712,
763,
17251,
28495,
29889,
13,
13,
1678,
910,
4377,
884,
15894,
591,
526,
16743,
411,
263,
2913,
29899,
517,
29899,
799,
386,
13,
1678,
1544,
29889,
29871,
1152,
405,
29954,
6156,
304,
402,
6156,
29892,
470,
8437,
29899,
517,
29899,
3493,
29892,
445,
4377,
338,
13,
1678,
297,
932,
506,
519,
29889,
13,
13,
268,
334,
14121,
29899,
517,
29899,
29923,
28696,
13,
268,
334,
350,
2361,
523,
13,
268,
334,
14846,
350,
29956,
22310,
2133,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13,
462,
1904,
29892,
13,
462,
289,
29893,
29922,
29946,
29872,
29941,
29892,
13,
462,
282,
11512,
29918,
12514,
29922,
8516,
29892,
13,
462,
3611,
29922,
8516,
1125,
13,
4706,
9995,
9832,
1078,
263,
716,
24420,
282,
11512,
4377,
29889,
13,
13,
4706,
1904,
1192,
450,
360,
10051,
1904,
29889,
13,
4706,
289,
29893,
1192,
350,
29956,
363,
278,
349,
26453,
313,
4381,
29879,
304,
29871,
29946,
29895,
12661,
13,
4706,
282,
11512,
29918,
12514,
1192,
960,
372,
338,
349,
26453,
7186,
11858,
362,
29892,
884,
6492,
1438,
349,
26453,
13071,
13,
4706,
9995,
13,
4706,
1583,
29889,
3257,
353,
3611,
13,
4706,
1583,
29889,
4299,
353,
1904,
13,
4706,
1583,
29889,
7810,
29881,
29918,
12514,
353,
282,
11512,
29918,
12514,
13,
4706,
1583,
29889,
29890,
29893,
353,
289,
29893,
13,
13,
1678,
822,
3858,
29898,
1311,
1125,
13,
4706,
736,
525,
7810,
29881,
29899,
3068,
265,
936,
19222,
29881,
29995,
29879,
29915,
1273,
3667,
29879,
29889,
26029,
29918,
29882,
29920,
29898,
1311,
29889,
29890,
29893,
29897,
13,
13,
1678,
822,
285,
978,
29898,
1311,
1125,
13,
4706,
736,
525,
7810,
29881,
29899,
3068,
265,
936,
19222,
29881,
29995,
29879,
29889,
2732,
29915,
1273,
3667,
29879,
29889,
26029,
29918,
29882,
29920,
29898,
1311,
29889,
29890,
29893,
29897,
13,
13,
1678,
822,
343,
1643,
29898,
1311,
1125,
13,
4706,
736,
525,
29933,
2361,
523,
349,
26453,
313,
29881,
29933,
29956,
29914,
29885,
29985,
29906,
22584,
29881,
29995,
29879,
16029,
1273,
3667,
29879,
29889,
26029,
29918,
29882,
29920,
29898,
1311,
29889,
29890,
29893,
29897,
13,
13,
1678,
822,
5777,
683,
29898,
1311,
1125,
13,
4706,
736,
376,
15666,
557,
349,
26453,
472,
11563,
12039,
10241,
2989,
350,
29956,
3667,
2133,
29908,
13,
13,
1678,
822,
6492,
29898,
1311,
29892,
270,
978,
2433,
29889,
742,
285,
978,
29922,
8516,
1125,
13,
4706,
822,
4770,
29891,
29898,
29875,
1125,
13,
9651,
286,
353,
1583,
29889,
4299,
13,
9651,
736,
3667,
29879,
29889,
7810,
29881,
29918,
29882,
29920,
29918,
11288,
29918,
328,
5143,
29898,
29885,
29889,
3068,
265,
936,
29918,
7810,
29918,
2585,
29893,
29918,
546,
29918,
29885,
29906,
29892,
13,
462,
462,
795,
286,
29889,
284,
5479,
29918,
29882,
29920,
29892,
13,
462,
462,
795,
1583,
29889,
29890,
29893,
29897,
13,
4706,
736,
1583,
3032,
5317,
29918,
4270,
29918,
295,
22168,
29891,
29892,
270,
978,
29922,
29881,
978,
29892,
285,
978,
29922,
29888,
978,
29897,
13,
13,
13,
1990,
1222,
6021,
13691,
4037,
335,
545,
29898,
13080,
545,
1125,
13,
1678,
9995,
21472,
2379,
1314,
360,
575,
537,
4377,
363,
278,
3806,
1206,
13,
13,
1678,
450,
3806,
1206,
338,
1568,
901,
12092,
322,
7805,
2712,
13,
1678,
763,
25504,
1056,
15038,
29892,
28421,
13330,
29892,
322,
878,
2785,
775,
13,
1678,
9262,
29889,
29871,
14213,
1711,
29892,
746,
263,
6133,
878,
2785,
775,
338,
4629,
29892,
13,
1678,
278,
350,
29956,
3667,
2133,
4441,
567,
10029,
9819,
297,
10029,
6133,
349,
26453,
13,
1678,
1363,
278,
3001,
7182,
3081,
338,
9677,
975,
10029,
28145,
379,
29920,
29889,
13,
1678,
1094,
263,
1121,
29892,
445,
3983,
338,
451,
3806,
304,
367,
10597,
29889,
29871,
739,
881,
29892,
13,
1678,
3138,
29892,
367,
21196,
8927,
29889,
13,
13,
1678,
910,
4377,
884,
15894,
591,
526,
16743,
411,
263,
2913,
29899,
517,
29899,
799,
386,
13,
1678,
1544,
29889,
29871,
1152,
405,
29954,
6156,
304,
402,
6156,
29892,
470,
8437,
29899,
517,
29899,
3493,
29892,
445,
4377,
338,
13,
1678,
297,
932,
506,
519,
29889,
13,
13,
268,
334,
14121,
29899,
517,
29899,
29923,
28696,
13,
268,
334,
1222,
6021,
25504,
1056,
11581,
13,
268,
334,
1222,
6021,
350,
29956,
3667,
2133,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13,
462,
1904,
29892,
13,
462,
289,
29893,
29922,
29946,
29872,
29941,
29892,
13,
462,
282,
11512,
29918,
12514,
29922,
8516,
29892,
13,
462,
3611,
29922,
8516,
1125,
13,
4706,
9995,
9832,
1078,
263,
716,
24420,
282,
11512,
4377,
29889,
13,
13,
4706,
1904,
1192,
450,
360,
10051,
1904,
29889,
13,
4706,
289,
29893,
1192,
350,
29956,
363,
278,
349,
26453,
313,
4381,
29879,
304,
29871,
29946,
29895,
12661,
13,
4706,
282,
11512,
29918,
12514,
1192,
960,
372,
338,
349,
26453,
7186,
11858,
362,
29892,
884,
6492,
1438,
349,
26453,
13071,
13,
4706,
9995,
13,
4706,
1583,
29889,
3257,
353,
3611,
13,
4706,
1583,
29889,
4299,
353,
1904,
13,
4706,
1583,
29889,
7810,
29881,
29918,
12514,
353,
282,
11512,
29918,
12514,
13,
4706,
1583,
29889,
29890,
29893,
353,
289,
29893,
13,
13,
1678,
822,
3858,
29898,
1311,
1125,
13,
4706,
736,
525,
7810,
29881,
29899,
9684,
19222,
29881,
29995,
29879,
29915,
1273,
3667,
29879,
29889,
26029,
29918,
29882,
29920,
29898,
1311,
29889,
29890,
29893,
29897,
13,
13,
1678,
822,
343,
1643,
29898,
1311,
1125,
13,
4706,
736,
525,
1252,
6021,
349,
26453,
313,
29881,
29933,
29956,
29914,
29885,
29985,
29906,
22584,
29881,
29995,
29879,
16029,
1273,
3667,
29879,
29889,
26029,
29918,
29882,
29920,
29898,
1311,
29889,
29890,
29893,
29897,
13,
13,
1678,
822,
285,
978,
29898,
1311,
1125,
13,
4706,
736,
525,
7810,
29881,
29899,
9684,
19222,
29881,
29995,
29879,
29889,
2732,
29915,
1273,
3667,
29879,
29889,
26029,
29918,
29882,
29920,
29898,
1311,
29889,
29890,
29893,
29897,
13,
13,
1678,
822,
5777,
683,
29898,
1311,
1125,
13,
4706,
736,
376,
1252,
6021,
349,
26453,
472,
11563,
12039,
1090,
4226,
6931,
29908,
13,
13,
1678,
822,
6492,
29898,
1311,
29892,
270,
978,
2433,
29889,
742,
285,
978,
29922,
8516,
1125,
13,
4706,
822,
4770,
29891,
29898,
29875,
1125,
13,
9651,
736,
3667,
29879,
29889,
17697,
29918,
7810,
29881,
29918,
29882,
29920,
29918,
328,
5143,
29898,
1311,
29889,
4299,
29892,
13,
462,
462,
3986,
1583,
29889,
4299,
29889,
7810,
29918,
2585,
29893,
29918,
546,
29918,
29885,
29906,
29892,
13,
462,
462,
3986,
1583,
29889,
29890,
29893,
29897,
13,
4706,
736,
1583,
3032,
5317,
29918,
4270,
29918,
295,
22168,
29891,
29892,
270,
978,
29922,
29881,
978,
29892,
285,
978,
29922,
29888,
978,
29897,
13,
13,
13,
1990,
349,
26453,
4270,
29933,
29956,
13080,
545,
29898,
13080,
545,
1125,
13,
1678,
9995,
15666,
557,
9206,
2379,
1314,
360,
575,
537,
4377,
7186,
5158,
6110,
13,
13,
1678,
1152,
752,
13036,
9590,
29892,
372,
508,
367,
5407,
304,
1510,
263,
3983,
310,
278,
13,
1678,
19224,
263,
1173,
440,
519,
349,
26453,
7186,
350,
29956,
363,
1716,
278,
19870,
322,
278,
402,
6156,
1206,
29889,
13,
13,
268,
334,
14121,
29899,
517,
29899,
29923,
28696,
470,
11563,
29899,
517,
29899,
14936,
13,
268,
334,
3938,
557,
25504,
1056,
11581,
13,
268,
334,
14846,
350,
29956,
3667,
2133,
13,
268,
334,
402,
6156,
470,
24328,
2147,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13,
462,
1904,
29892,
13,
462,
1369,
29918,
29882,
29920,
29922,
29896,
29892,
13,
462,
1095,
29918,
29882,
29920,
29922,
29946,
29872,
29941,
29892,
13,
462,
338,
29918,
29887,
578,
29922,
8824,
29892,
13,
462,
282,
11512,
29918,
12514,
29922,
8516,
29892,
13,
462,
3611,
29922,
8516,
1125,
13,
4706,
9995,
9832,
1078,
263,
716,
4377,
29889,
13,
13,
4706,
1904,
1192,
450,
360,
10051,
1904,
29889,
13,
4706,
1369,
29918,
29882,
29920,
1192,
960,
577,
29892,
6257,
350,
29956,
13,
4706,
1095,
29918,
29882,
29920,
1192,
1126,
278,
17140,
350,
29956,
13,
4706,
338,
29918,
29887,
578,
1192,
5852,
565,
3063,
472,
349,
26453,
472,
402,
6156,
29892,
6467,
372,
338,
278,
19870,
13,
4706,
282,
11512,
29918,
12514,
1192,
6492,
1438,
349,
26453,
13071,
13,
4706,
9995,
13,
13,
4706,
1583,
29889,
3257,
353,
3611,
13,
4706,
1583,
29889,
4299,
353,
1904,
13,
4706,
1583,
29889,
2962,
29918,
29882,
29920,
353,
1369,
29918,
29882,
29920,
13,
4706,
1583,
29889,
355,
29918,
29882,
29920,
353,
1095,
29918,
29882,
29920,
13,
4706,
1583,
29889,
275,
29918,
29887,
578,
353,
338,
29918,
29887,
578,
13,
4706,
1583,
29889,
7810,
29881,
29918,
12514,
353,
282,
11512,
29918,
12514,
13,
13,
1678,
822,
285,
978,
29898,
1311,
1125,
13,
4706,
10944,
353,
525,
29887,
578,
29915,
565,
1583,
29889,
275,
29918,
29887,
578,
1683,
525,
17697,
29915,
13,
4706,
10944,
353,
525,
7810,
29881,
29899,
29915,
718,
10944,
13,
4706,
736,
14210,
29879,
29918,
29995,
29881,
19222,
29881,
29889,
2732,
29915,
1273,
313,
13506,
29892,
1583,
29889,
2962,
29918,
29882,
29920,
29892,
1583,
29889,
355,
29918,
29882,
29920,
29897,
13,
13,
1678,
822,
3858,
29898,
1311,
1125,
13,
4706,
10944,
353,
525,
29887,
578,
29915,
565,
1583,
29889,
275,
29918,
29887,
578,
1683,
525,
17697,
29915,
13,
4706,
736,
14210,
29879,
29918,
29995,
29881,
19222,
29881,
29915,
1273,
313,
13506,
29892,
1583,
29889,
2962,
29918,
29882,
29920,
29892,
1583,
29889,
355,
29918,
29882,
29920,
29897,
13,
13,
1678,
822,
5777,
683,
29898,
1311,
1125,
13,
4706,
565,
1583,
29889,
275,
29918,
29887,
578,
29901,
13,
9651,
736,
525,
15666,
557,
349,
26453,
472,
402,
6156,
7186,
5158,
2103,
29915,
13,
4706,
1683,
29901,
13,
9651,
565,
1583,
29889,
4299,
29889,
275,
29918,
3204,
2324,
29901,
13,
18884,
736,
525,
15666,
557,
349,
26453,
472,
6298,
2161,
7186,
5158,
2103,
29915,
13,
9651,
1683,
29901,
13,
18884,
736,
525,
15666,
557,
349,
26453,
472,
24328,
2147,
7186,
5158,
2103,
29915,
13,
13,
1678,
822,
6492,
29898,
1311,
29892,
270,
978,
2433,
29889,
742,
285,
978,
29922,
8516,
1125,
13,
4706,
286,
353,
1583,
29889,
4299,
13,
13,
4706,
565,
1583,
29889,
275,
29918,
29887,
578,
29901,
13,
9651,
282,
29888,
353,
286,
29889,
412,
557,
29918,
7810,
29918,
271,
29918,
24756,
29918,
2585,
29893,
29918,
546,
29918,
29885,
29906,
13,
4706,
1683,
29901,
13,
9651,
282,
29888,
353,
286,
29889,
412,
557,
29918,
7810,
29918,
2585,
29893,
29918,
546,
29918,
29885,
29906,
13,
13,
4706,
2537,
353,
14770,
29889,
4532,
580,
13,
4706,
565,
1583,
29889,
3257,
29901,
13,
9651,
2537,
29889,
2146,
415,
1740,
29898,
1311,
29889,
3257,
29897,
13,
4706,
4853,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29897,
13,
4706,
302,
353,
938,
29898,
1311,
29889,
355,
29918,
29882,
29920,
29897,
448,
938,
29898,
1311,
29889,
2962,
29918,
29882,
29920,
29897,
13,
4706,
921,
353,
7442,
29889,
1915,
3493,
29898,
29896,
29892,
302,
29892,
302,
29899,
29896,
29897,
13,
4706,
921,
4619,
1583,
29889,
2962,
29918,
29882,
29920,
13,
4706,
343,
353,
7442,
29889,
3298,
359,
29898,
29876,
29899,
29896,
29897,
13,
4706,
363,
474,
297,
3464,
29898,
2435,
29898,
29916,
22164,
13,
9651,
289,
29893,
353,
921,
29961,
29875,
29962,
13,
9651,
343,
29961,
29875,
29962,
353,
3667,
29879,
29889,
7810,
29881,
29918,
29882,
29920,
29918,
11288,
29918,
328,
5143,
29898,
7810,
29892,
286,
29889,
284,
5479,
29918,
29882,
29920,
29892,
289,
29893,
29897,
13,
13,
4706,
4853,
29889,
5317,
29898,
29916,
29892,
343,
29892,
2927,
2433,
29890,
742,
3858,
2433,
13691,
29928,
313,
29881,
29933,
29956,
29914,
29885,
29985,
29906,
29897,
1495,
13,
13,
4706,
396,
18399,
738,
4046,
3454,
13,
4706,
565,
1583,
29889,
7810,
29881,
29918,
12514,
29901,
13,
9651,
921,
353,
518,
29886,
29961,
29900,
29962,
363,
282,
297,
1583,
29889,
7810,
29881,
29918,
12514,
29962,
13,
9651,
343,
353,
518,
29886,
29961,
29896,
29962,
363,
282,
297,
1583,
29889,
7810,
29881,
29918,
12514,
29962,
13,
9651,
4853,
29889,
5317,
29898,
29916,
29892,
343,
29892,
2927,
2433,
29878,
742,
1196,
2103,
29922,
29906,
29892,
3858,
2433,
24445,
1495,
13,
13,
13,
4706,
4853,
29889,
842,
29918,
29916,
1643,
877,
29933,
392,
2103,
313,
12661,
29897,
1495,
13,
4706,
565,
1583,
29889,
275,
29918,
29887,
578,
29901,
13,
9651,
4853,
29889,
842,
29918,
29891,
1643,
877,
13691,
29928,
472,
402,
6156,
29898,
29881,
29933,
29956,
29914,
29885,
29985,
29906,
29897,
1495,
13,
4706,
1683,
29901,
13,
9651,
4853,
29889,
842,
29918,
29891,
1643,
877,
13691,
29928,
472,
24328,
2147,
313,
29881,
29933,
29956,
29914,
29885,
29985,
29906,
29897,
1495,
13,
4706,
565,
451,
285,
978,
29901,
13,
9651,
285,
978,
353,
1583,
29889,
29888,
978,
580,
13,
4706,
2224,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29881,
978,
29892,
285,
978,
29897,
13,
4706,
2537,
29889,
7620,
1003,
29898,
2084,
29892,
17772,
29922,
5574,
29897,
13,
13,
13,
1990,
18531,
10492,
13080,
545,
29898,
13080,
545,
1125,
13,
1678,
9995,
7976,
2586,
10492,
7186,
382,
2608,
362,
11479,
13,
13,
1678,
910,
3983,
15894,
4226,
6931,
322,
14088,
278,
4236,
13,
1678,
3625,
2586,
10492,
29889,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1904,
29892,
3611,
1125,
13,
4706,
1583,
29889,
4299,
353,
1904,
13,
4706,
1583,
29889,
3257,
353,
3611,
13,
13,
1678,
822,
3858,
29898,
1311,
1125,
13,
4706,
736,
525,
3317,
29899,
8844,
403,
29915,
13,
13,
1678,
822,
285,
978,
29898,
1311,
1125,
13,
4706,
736,
525,
3317,
29899,
8844,
403,
29889,
2732,
29915,
13,
13,
1678,
822,
5777,
683,
29898,
1311,
1125,
13,
4706,
736,
525,
21591,
10492,
411,
1273,
1289,
29933,
310,
6645,
1085,
5359,
7186,
382,
2608,
362,
29915,
1273,
1583,
29889,
4299,
29889,
5182,
29918,
9264,
29918,
2585,
13,
13,
1678,
822,
343,
1643,
29898,
1311,
1125,
13,
4706,
736,
525,
7976,
18531,
10492,
313,
29924,
12661,
16029,
13,
13,
1678,
822,
6492,
29898,
1311,
29892,
270,
978,
2433,
29889,
742,
285,
978,
29922,
8516,
1125,
13,
4706,
822,
4770,
29891,
29898,
29875,
1125,
13,
9651,
390,
353,
1583,
29889,
4299,
29889,
3317,
29918,
8844,
403,
29918,
29882,
29920,
13,
9651,
286,
353,
1583,
29889,
4299,
13,
9651,
736,
1583,
29889,
4299,
29889,
3317,
29918,
8844,
403,
29918,
29882,
29920,
847,
29871,
29896,
29889,
29900,
29872,
29953,
13,
4706,
736,
1583,
3032,
5317,
29918,
4270,
29918,
295,
22168,
29891,
29892,
270,
978,
29922,
29881,
978,
29892,
285,
978,
29922,
29888,
978,
29897,
13,
13,
13,
1990,
13969,
29898,
3318,
1125,
13,
1678,
9995,
5661,
16644,
3461,
3251,
1061,
29889,
13,
13,
1678,
3251,
1078,
5683,
29916,
13676,
411,
2107,
21103,
4127,
363,
2845,
13,
1678,
2498,
21639,
29892,
470,
752,
13036,
13676,
363,
2305,
763,
13,
1678,
11698,
6344,
29914,
29940,
3289,
29909,
29914,
29943,
4174,
29914,
1806,
29965,
29914,
2890,
29909,
29914,
29911,
4375,
29914,
2544,
4375,
29889,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1904,
1125,
13,
4706,
1583,
29889,
4299,
353,
1904,
13,
4706,
1583,
29889,
18605,
353,
1904,
29889,
18605,
13,
13,
1678,
822,
903,
2371,
29898,
1311,
29892,
4452,
29892,
671,
29918,
13662,
29922,
5574,
1125,
13,
4706,
286,
353,
1583,
29889,
4299,
13,
4706,
1591,
353,
6629,
13,
4706,
1591,
4619,
525,
1966,
463,
29912,
9456,
1157,
29886,
29912,
29941,
262,
29913,
29886,
29912,
29896,
262,
29913,
29880,
1012,
29876,
29915,
13,
4706,
363,
4004,
297,
4452,
29901,
13,
9651,
269,
353,
4004,
13,
9651,
565,
4004,
1275,
525,
4300,
2415,
357,
2396,
269,
353,
525,
4300,
2415,
357,
313,
29995,
29879,
16029,
1273,
286,
29889,
3286,
2415,
357,
29918,
978,
13,
9651,
565,
4004,
1275,
525,
22068,
2396,
269,
353,
525,
22068,
313,
29995,
29879,
16029,
1273,
286,
29889,
17697,
29918,
978,
13,
9651,
565,
671,
29918,
13662,
29901,
13,
18884,
1591,
4619,
525,
1966,
4534,
18255,
29879,
29913,
669,
669,
320,
1966,
1966,
29876,
29915,
1273,
269,
13,
18884,
1591,
4619,
525,
1966,
7760,
320,
1966,
1966,
29876,
29915,
13,
9651,
3454,
353,
4452,
29961,
2042,
29962,
13,
9651,
363,
1196,
297,
3454,
29901,
13,
18884,
325,
353,
1196,
29961,
29896,
29962,
13,
18884,
325,
353,
14210,
29889,
29906,
29888,
29915,
1273,
325,
565,
338,
8758,
29898,
29894,
29892,
5785,
29897,
1683,
14210,
29879,
29915,
1273,
325,
13,
18884,
1591,
4619,
14210,
29879,
669,
1273,
29879,
669,
395,
29995,
29879,
29938,
320,
1966,
1966,
29876,
29915,
1273,
313,
1220,
29961,
29900,
1402,
13,
462,
462,
462,
1678,
325,
29892,
13,
462,
462,
462,
1678,
1196,
29961,
29906,
2314,
13,
9651,
1591,
4619,
525,
1966,
1966,
29905,
29876,
29915,
13,
13,
4706,
1591,
4619,
525,
1966,
355,
29912,
9456,
1012,
29876,
29915,
13,
4706,
736,
1591,
13,
13,
1678,
822,
903,
17697,
29918,
14153,
29918,
2371,
29898,
1311,
1125,
13,
4706,
286,
353,
1583,
29889,
4299,
13,
4706,
321,
353,
286,
29889,
18605,
13,
4706,
9704,
353,
286,
29889,
17697,
29918,
9600,
29918,
14153,
13,
13,
4706,
4235,
353,
518,
877,
2642,
742,
15516,
29871,
29896,
29889,
29906,
29945,
511,
13,
462,
29871,
6702,
29954,
475,
742,
525,
29881,
29933,
742,
869,
29946,
29955,
511,
13,
462,
29871,
6702,
3782,
895,
11479,
742,
525,
29881,
29933,
742,
869,
29946,
29955,
511,
13,
462,
29871,
396,
877,
29954,
475,
383,
7168,
742,
15516,
869,
29945,
511,
13,
462,
29871,
396,
877,
3782,
895,
383,
7168,
742,
15516,
869,
29945,
511,
13,
462,
29871,
6702,
3782,
895,
21121,
29889,
742,
525,
29968,
742,
869,
29945,
511,
13,
462,
29871,
6702,
3373,
5461,
402,
475,
383,
7168,
742,
15516,
869,
29953,
511,
13,
462,
29871,
6702,
1323,
1091,
29889,
1939,
895,
21121,
742,
525,
29968,
742,
869,
29945,
511,
13,
462,
29871,
6702,
1323,
1091,
29889,
1939,
895,
383,
7168,
742,
15516,
869,
29945,
511,
13,
462,
29871,
6702,
3782,
895,
21121,
349,
312,
2866,
1091,
29889,
742,
525,
1966,
29995,
742,
869,
29955,
29945,
511,
13,
462,
29871,
4514,
13,
13,
4706,
1746,
29918,
25476,
2187,
353,
525,
4286,
7122,
18959,
29886,
18255,
5223,
10162,
1273,
285,
14352,
29896,
29962,
363,
285,
297,
4235,
2314,
13,
4706,
1591,
353,
6024,
1966,
14158,
29930,
8499,
29900,
29889,
29955,
29945,
262,
29913,
2474,
463,
29912,
9456,
1157,
29995,
29879,
10162,
1273,
1746,
29918,
25476,
2187,
29962,
13,
13,
4706,
396,
17735,
13,
4706,
1948,
353,
6024,
1966,
4534,
18255,
29879,
10162,
1273,
285,
29961,
29900,
29962,
363,
285,
297,
4235,
29962,
13,
4706,
1591,
29889,
4397,
877,
669,
15300,
7122,
29898,
798,
29897,
718,
525,
1966,
1966,
1495,
13,
4706,
1591,
29889,
4397,
28909,
7760,
320,
1966,
29905,
1495,
13,
13,
4706,
396,
28386,
13,
4706,
1948,
353,
5159,
13,
4706,
363,
285,
297,
4235,
29901,
13,
9651,
565,
7431,
29898,
29888,
29961,
29896,
29962,
1125,
13,
18884,
1948,
29889,
4397,
877,
1966,
4534,
8290,
29995,
29879,
29938,
10162,
1273,
313,
29888,
29961,
29896,
12622,
13,
9651,
1683,
29901,
13,
18884,
1948,
29889,
4397,
877,
1495,
13,
4706,
1591,
29889,
4397,
877,
669,
15300,
7122,
29898,
798,
29897,
718,
525,
1966,
1966,
1495,
13,
4706,
1591,
29889,
4397,
28909,
7760,
320,
1966,
29905,
1495,
13,
13,
13,
4706,
363,
560,
297,
9704,
29901,
13,
9651,
282,
312,
353,
560,
29889,
1217,
895,
29918,
7382,
29918,
21570,
847,
286,
29889,
17697,
29918,
5205,
29918,
1217,
895,
29918,
7382,
29918,
29895,
13,
13,
9651,
822,
4770,
5014,
29918,
5029,
29898,
791,
1125,
13,
18884,
565,
338,
8758,
29898,
791,
29892,
938,
1125,
13,
462,
1678,
736,
851,
29898,
791,
29897,
13,
18884,
565,
659,
1405,
29871,
29896,
29900,
29900,
29901,
13,
462,
1678,
736,
851,
29898,
524,
29898,
791,
876,
13,
18884,
565,
659,
1405,
29871,
29896,
29900,
29900,
29900,
29901,
13,
462,
1678,
736,
14210,
29887,
29915,
29995,
791,
13,
18884,
736,
14210,
29889,
29906,
29888,
29915,
1273,
659,
13,
13,
9651,
1948,
353,
518,
295,
29889,
29887,
475,
29918,
2585,
29892,
13,
462,
259,
560,
29889,
1217,
895,
29918,
4532,
29918,
2585,
29892,
13,
462,
259,
560,
29889,
1217,
895,
29918,
7382,
29918,
29895,
29892,
13,
462,
259,
560,
29889,
16304,
29918,
29887,
475,
29892,
13,
462,
259,
560,
29889,
1217,
895,
29918,
7382,
29918,
21570,
29892,
13,
462,
259,
560,
29889,
1217,
895,
29918,
19790,
29918,
21570,
29892,
13,
462,
259,
4514,
718,
518,
29886,
312,
29930,
29896,
29900,
29900,
29889,
29900,
26073,
13,
9651,
1948,
353,
518,
295,
29889,
978,
29962,
718,
518,
1649,
5014,
29918,
5029,
29898,
29894,
29897,
363,
325,
297,
1948,
29962,
13,
9651,
1948,
353,
6702,
669,
15300,
7122,
29898,
798,
876,
718,
525,
1966,
1966,
29915,
13,
9651,
1591,
29889,
4397,
29898,
798,
29897,
13,
13,
4706,
1591,
29889,
4397,
877,
1966,
355,
29912,
9456,
29913,
1495,
13,
4706,
736,
11297,
29876,
4286,
7122,
29898,
2371,
29897,
13,
13,
1678,
822,
903,
26029,
675,
29918,
29882,
29920,
29898,
1311,
29892,
3858,
29892,
659,
1125,
13,
4706,
736,
313,
1643,
29892,
29897,
718,
3667,
29879,
29889,
26029,
29918,
29882,
29920,
29898,
791,
29897,
13,
13,
1678,
822,
903,
26029,
675,
29918,
29885,
29898,
1311,
29892,
3858,
29892,
659,
1125,
13,
4706,
736,
313,
1643,
29892,
29897,
718,
3667,
29879,
29889,
26029,
29918,
29885,
29898,
791,
29897,
13,
13,
1678,
822,
903,
7959,
29918,
7810,
29881,
29918,
8269,
29898,
1311,
29892,
289,
29893,
29922,
29900,
29892,
338,
29918,
29887,
578,
29922,
8824,
1125,
13,
4706,
286,
353,
1583,
29889,
4299,
13,
13,
4706,
565,
338,
29918,
29887,
578,
29901,
13,
9651,
3240,
791,
353,
286,
29889,
412,
557,
29918,
7810,
29918,
271,
29918,
24756,
29918,
2585,
29893,
29918,
546,
29918,
29885,
29906,
13,
4706,
1683,
29901,
13,
9651,
3240,
791,
353,
286,
29889,
412,
557,
29918,
7810,
29918,
2585,
29893,
29918,
546,
29918,
29885,
29906,
13,
13,
4706,
282,
11512,
29918,
546,
29918,
29882,
29920,
353,
3240,
791,
448,
286,
29889,
12403,
29918,
17697,
29918,
29890,
29893,
29918,
2585,
29882,
29920,
13,
4706,
565,
289,
29893,
29901,
13,
9651,
3240,
791,
353,
282,
11512,
29918,
546,
29918,
29882,
29920,
718,
1375,
29898,
13239,
29889,
517,
29918,
2585,
29898,
29890,
29893,
511,
286,
29889,
12403,
29918,
17697,
29918,
29890,
29893,
29918,
2585,
29882,
29920,
29897,
13,
9651,
313,
29890,
29893,
29892,
289,
29893,
29918,
5441,
29892,
29897,
353,
3667,
29879,
29889,
26029,
29918,
29882,
29920,
29898,
29890,
29893,
29897,
13,
9651,
565,
338,
29918,
29887,
578,
29901,
13,
18884,
3858,
353,
525,
15666,
557,
349,
26453,
472,
402,
6156,
639,
18695,
29906,
29887,
29995,
29879,
29915,
1273,
313,
29890,
29893,
29892,
289,
29893,
29918,
5441,
29897,
13,
9651,
25342,
286,
29889,
275,
29918,
3204,
2324,
29901,
13,
18884,
3858,
353,
525,
15666,
557,
349,
26453,
472,
6298,
2161,
639,
18695,
29906,
29887,
29995,
29879,
29915,
1273,
313,
29890,
29893,
29892,
289,
29893,
29918,
5441,
29897,
13,
9651,
1683,
29901,
13,
18884,
3858,
353,
525,
15666,
557,
349,
26453,
472,
24328,
2147,
639,
18695,
29906,
29887,
29995,
29879,
29915,
1273,
313,
29890,
29893,
29892,
289,
29893,
29918,
5441,
29897,
13,
9651,
5190,
353,
525,
29881,
29933,
29956,
29914,
29885,
29985,
29906,
29914,
15543,
29906,
29887,
29995,
29879,
29915,
1273,
313,
29890,
29893,
29892,
289,
29893,
29918,
5441,
29897,
13,
4706,
1683,
29901,
13,
9651,
565,
338,
29918,
29887,
578,
29901,
13,
18884,
3858,
353,
525,
15666,
557,
349,
26453,
472,
402,
6156,
29915,
13,
9651,
1683,
29901,
13,
18884,
565,
286,
29889,
275,
29918,
3204,
2324,
29901,
13,
462,
1678,
3858,
353,
525,
15666,
557,
349,
26453,
472,
6298,
2161,
29915,
13,
18884,
1683,
29901,
13,
462,
1678,
3858,
353,
525,
15666,
557,
349,
26453,
472,
24328,
2147,
29915,
13,
9651,
5190,
353,
525,
29881,
29933,
29956,
29914,
29885,
29985,
29906,
29915,
13,
4706,
736,
313,
1643,
29892,
3240,
791,
29892,
5190,
29892,
29897,
13,
13,
1678,
822,
903,
517,
29918,
1643,
29898,
1311,
29892,
269,
1125,
13,
4706,
736,
1583,
3032,
1445,
29918,
8588,
1598,
29898,
29879,
29897,
13,
13,
1678,
822,
903,
1445,
29918,
8588,
1598,
29898,
1311,
29892,
269,
1125,
13,
4706,
363,
274,
297,
376,
5931,
4286,
320,
29873,
1115,
13,
9651,
269,
353,
269,
29889,
6506,
29898,
29883,
29892,
22868,
1495,
13,
4706,
736,
269,
13,
13,
1678,
822,
304,
29918,
25694,
29898,
1311,
29892,
13,
462,
285,
978,
29892,
13,
462,
4148,
2433,
742,
13,
462,
22909,
2433,
742,
13,
462,
429,
1129,
2433,
742,
13,
462,
364,
29916,
29918,
7810,
29881,
29918,
29890,
5652,
11759,
1402,
13,
462,
330,
578,
29918,
7810,
29881,
29918,
29890,
5652,
11759,
1402,
13,
462,
282,
11512,
29918,
1003,
1973,
11759,
1402,
13,
462,
2715,
29918,
27117,
11759,
1402,
13,
462,
2715,
29918,
1639,
1659,
29918,
27117,
11759,
1402,
13,
462,
2586,
10492,
29918,
4532,
29922,
8516,
29892,
13,
462,
16699,
837,
935,
29918,
726,
29922,
8516,
1125,
13,
4706,
9995,
26382,
278,
23562,
304,
29186,
13,
13,
4706,
285,
978,
1192,
7488,
3233,
5683,
29916,
2224,
13,
4706,
4148,
1192,
450,
4148,
29915,
29879,
1024,
29914,
8269,
297,
278,
4839,
13,
4706,
22909,
1192,
530,
13136,
4004,
310,
5683,
29916,
304,
367,
5134,
1156,
278,
3611,
13,
4706,
429,
1129,
1192,
530,
13136,
4004,
310,
5683,
29916,
304,
367,
5134,
472,
278,
1095,
13,
4706,
364,
29916,
29918,
7810,
29881,
29918,
29890,
5652,
1192,
2391,
310,
349,
26453,
350,
29956,
29915,
29879,
304,
3160,
297,
278,
1006,
1659,
4004,
13,
4706,
330,
578,
29918,
7810,
29881,
29918,
29890,
5652,
1192,
2391,
310,
349,
26453,
350,
29956,
29915,
29879,
304,
3160,
297,
278,
1006,
1659,
4004,
13,
4706,
2715,
29918,
27117,
1192,
3462,
3245,
13926,
304,
788,
1434,
278,
23562,
4004,
13,
4706,
2715,
29918,
1524,
1659,
29918,
27117,
1192,
3462,
3245,
1014,
27117,
363,
1006,
1659,
13,
4706,
282,
11512,
29918,
1003,
1973,
1192,
3139,
7429,
349,
26453,
4377,
3618,
13,
4706,
2586,
10492,
29918,
4532,
1192,
3139,
7429,
2586,
10492,
4377,
3618,
13,
4706,
16699,
837,
935,
29918,
726,
1192,
14269,
837,
935,
1426,
313,
14565,
408,
360,
4717,
7818,
470,
8707,
29943,
1367,
3919,
25758,
29897,
13,
13,
4706,
4124,
1659,
3323,
27117,
29901,
13,
4706,
518,
877,
4035,
2042,
18527,
742,
518,
13,
9651,
6702,
2001,
4408,
742,
2944,
29918,
1767,
29892,
525,
348,
1169,
5477,
13,
9651,
6702,
2744,
1228,
10976,
4408,
742,
1790,
29918,
1767,
29892,
525,
348,
1169,
5477,
13,
3986,
4514,
511,
29962,
13,
13,
4706,
3462,
3245,
922,
1953,
29901,
13,
4706,
518,
877,
13438,
4408,
742,
518,
13,
9651,
1014,
2042,
29892,
13,
9651,
1014,
2042,
29892,
13,
3986,
4514,
511,
29962,
13,
4706,
9995,
13,
308,
13,
4706,
286,
353,
1583,
29889,
4299,
13,
4706,
321,
353,
1583,
29889,
4299,
29889,
18605,
13,
13,
4706,
270,
978,
353,
2897,
29889,
2084,
29889,
25721,
29898,
29888,
978,
29897,
13,
13,
4706,
565,
22909,
338,
6213,
29901,
13,
9651,
22909,
353,
6629,
13,
13,
4706,
2246,
353,
1583,
3032,
28789,
1764,
2141,
657,
29918,
6886,
877,
15841,
657,
29889,
4776,
1495,
13,
13,
4706,
16980,
29918,
7076,
353,
16250,
29889,
7514,
287,
21533,
4197,
13,
9651,
6702,
2816,
2966,
742,
518,
13,
18884,
6702,
29909,
1129,
2547,
275,
742,
286,
29889,
481,
29877,
2547,
275,
29918,
1997,
4279,
29918,
8848,
29892,
525,
8848,
5477,
13,
18884,
6702,
5894,
423,
567,
275,
742,
286,
29889,
546,
423,
567,
275,
29918,
1997,
4279,
29918,
8848,
29892,
525,
8848,
5477,
13,
18884,
6702,
6816,
273,
10790,
4279,
742,
286,
29889,
12676,
29918,
272,
2966,
29918,
1997,
4279,
29918,
8848,
29892,
525,
8848,
5477,
13,
18884,
4514,
511,
13,
9651,
6702,
26570,
742,
518,
13,
18884,
6702,
29923,
28696,
4957,
2482,
742,
286,
29889,
799,
386,
29918,
13471,
29918,
8848,
29892,
525,
8848,
5477,
13,
18884,
6702,
10749,
3218,
280,
310,
382,
2608,
362,
742,
286,
29889,
1195,
29918,
29872,
2608,
362,
29918,
12163,
29892,
525,
3311,
29905,
6034,
29913,
5477,
13,
18884,
4514,
511,
13,
9651,
6702,
2558,
10604,
29879,
742,
518,
13,
18884,
6702,
16973,
424,
12146,
742,
286,
29889,
17139,
29918,
3881,
29918,
8848,
29892,
525,
8848,
5477,
13,
18884,
6702,
29903,
271,
20911,
3218,
280,
515,
350,
2361,
523,
742,
286,
29889,
29879,
271,
20911,
29918,
10204,
1056,
29918,
2521,
29918,
12163,
29892,
525,
3311,
29905,
6034,
29913,
5477,
13,
18884,
4514,
511,
13,
632,
2314,
13,
13,
4706,
25568,
29918,
7076,
353,
16250,
29889,
7514,
287,
21533,
4197,
13,
9651,
6702,
13448,
264,
1056,
742,
518,
13,
18884,
6702,
17708,
29881,
402,
475,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
13448,
264,
1056,
8984,
292,
365,
2209,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
3149,
292,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
29954,
475,
472,
350,
2361,
523,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
29890,
2361,
523,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
29909,
19698,
18496,
381,
402,
475,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
12483,
482,
29918,
28486,
381,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
7713,
279,
2133,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
3733,
279,
2133,
29892,
525,
5477,
13,
18884,
4514,
511,
13,
13,
9651,
6702,
4300,
2415,
357,
742,
518,
13,
18884,
6702,
4300,
2415,
9206,
472,
17687,
742,
286,
29889,
7508,
29918,
13519,
29918,
271,
29918,
3274,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
6702,
797,
1220,
365,
2209,
267,
742,
286,
29889,
7508,
29918,
14764,
29918,
6758,
267,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
4300,
2415,
9206,
472,
530,
841,
1056,
742,
286,
29889,
7508,
29918,
13519,
29918,
271,
29918,
10204,
1056,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
6702,
29923,
8193,
29925,
742,
286,
29889,
7508,
29918,
29872,
381,
29886,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
396,
382,
9219,
13,
18884,
4514,
511,
13,
632,
2314,
13,
13,
4706,
1006,
1659,
29918,
27117,
353,
518,
13,
9651,
6702,
4300,
2415,
357,
742,
518,
13,
18884,
6702,
4300,
2415,
9206,
472,
530,
841,
1056,
742,
286,
29889,
7508,
29918,
13519,
29918,
271,
29918,
10204,
1056,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
6702,
15666,
557,
530,
841,
1056,
402,
475,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
412,
557,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
15666,
557,
382,
8193,
29925,
742,
286,
29889,
412,
557,
29918,
7508,
29918,
29872,
381,
29886,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
6702,
29940,
328,
381,
29899,
517,
29899,
10749,
402,
475,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
29940,
328,
381,
29899,
517,
29899,
10749,
382,
8193,
29925,
742,
286,
29889,
7508,
29918,
29872,
381,
29886,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
6702,
29909,
19698,
530,
841,
1056,
402,
475,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
12483,
482,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
4514,
511,
13,
9651,
4514,
13,
13,
4706,
282,
11512,
29918,
20155,
353,
5159,
13,
4706,
363,
289,
29893,
297,
364,
29916,
29918,
7810,
29881,
29918,
29890,
5652,
29901,
13,
9651,
282,
11512,
29918,
20155,
29889,
4397,
29898,
1311,
3032,
7959,
29918,
7810,
29881,
29918,
8269,
29898,
29890,
29893,
29922,
29890,
29893,
29892,
338,
29918,
29887,
578,
29922,
8824,
876,
13,
4706,
363,
289,
29893,
297,
330,
578,
29918,
7810,
29881,
29918,
29890,
5652,
29901,
13,
9651,
282,
11512,
29918,
20155,
29889,
4397,
29898,
1311,
3032,
7959,
29918,
7810,
29881,
29918,
8269,
29898,
29890,
29893,
29922,
29890,
29893,
29892,
338,
29918,
29887,
578,
29922,
5574,
876,
13,
4706,
565,
7431,
29898,
7810,
29881,
29918,
20155,
1125,
13,
9651,
1006,
1659,
29918,
27117,
29889,
4397,
29898,
877,
15666,
557,
9206,
2379,
1314,
360,
575,
537,
472,
24328,
2147,
742,
282,
11512,
29918,
20155,
876,
13,
4706,
1006,
1659,
29918,
27117,
4619,
2715,
29918,
1639,
1659,
29918,
27117,
13,
13,
4706,
1006,
1659,
29918,
7076,
353,
16250,
29889,
7514,
287,
21533,
29898,
1639,
1659,
29918,
27117,
29897,
13,
13,
4706,
8242,
29918,
7076,
353,
16250,
29889,
7514,
287,
21533,
4197,
13,
9651,
6702,
26570,
742,
518,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
13409,
3878,
23860,
742,
286,
29889,
5064,
29918,
29888,
7971,
29918,
29882,
29920,
511,
13,
18884,
6702,
26539,
310,
12790,
742,
938,
29898,
29885,
29889,
19322,
29918,
974,
29918,
4366,
29918,
29885,
29918,
546,
29918,
29879,
511,
525,
29885,
29914,
29879,
5477,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
2499,
28809,
5158,
2103,
742,
286,
29889,
284,
5479,
29918,
29882,
29920,
511,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
4763,
310,
838,
5479,
742,
286,
29889,
284,
5479,
29918,
2962,
29918,
29882,
29920,
511,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
5044,
310,
838,
5479,
742,
286,
29889,
284,
5479,
29918,
355,
29918,
29882,
29920,
511,
13,
18884,
6702,
29956,
6447,
1477,
742,
29897,
718,
3667,
29879,
29889,
26029,
29918,
29885,
29898,
29885,
29889,
29893,
6447,
1477,
29918,
29885,
511,
13,
18884,
4514,
511,
13,
13,
9651,
6702,
29931,
2209,
267,
742,
518,
13,
18884,
6702,
2525,
537,
402,
475,
1019,
13573,
362,
365,
2209,
742,
286,
29889,
6997,
29918,
29887,
475,
29918,
7728,
351,
362,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
4178,
7681,
8096,
293,
365,
2209,
742,
286,
29889,
271,
7681,
8096,
293,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
29902,
265,
359,
8096,
293,
365,
2209,
742,
286,
29889,
291,
359,
8096,
293,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
29934,
475,
365,
2209,
742,
286,
29889,
6038,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
6857,
666,
493,
383,
9382,
365,
2209,
742,
286,
29889,
18056,
493,
29918,
29888,
9382,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
11536,
17368,
365,
2209,
742,
286,
29889,
7827,
29918,
12719,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
4514,
511,
13,
13,
9651,
6702,
2111,
2785,
313,
29995,
29879,
16029,
1273,
286,
29889,
1545,
2785,
29918,
978,
29892,
518,
13,
18884,
6702,
2111,
2785,
4408,
742,
286,
29889,
1545,
2785,
29918,
978,
29892,
525,
5477,
13,
18884,
6702,
2111,
2785,
5920,
742,
286,
29889,
13318,
29918,
1545,
2785,
29918,
401,
29889,
978,
29892,
525,
5477,
13,
18884,
6702,
29911,
29916,
27738,
1705,
382,
2416,
13396,
742,
286,
29889,
13318,
29918,
1545,
2785,
29918,
401,
29889,
7508,
29918,
12352,
29892,
525,
5477,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
21591,
10492,
742,
286,
29889,
8844,
403,
29918,
29882,
29920,
511,
13,
18884,
6702,
21591,
10492,
742,
286,
29889,
8844,
403,
29918,
2585,
29882,
29920,
29892,
525,
29881,
29933,
12661,
5477,
13,
18884,
6702,
19347,
4432,
397,
2785,
395,
29923,
29918,
29890,
29914,
29940,
29918,
29900,
29938,
742,
286,
29889,
12403,
29918,
311,
1545,
29918,
774,
29876,
29900,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
19347,
4432,
397,
5158,
2103,
742,
286,
29889,
12403,
29918,
17697,
29918,
29890,
29893,
29918,
29882,
29920,
511,
13,
18884,
6702,
19347,
4432,
397,
5158,
2103,
742,
286,
29889,
12403,
29918,
17697,
29918,
29890,
29893,
29918,
2585,
29882,
29920,
29892,
525,
29881,
29933,
12661,
5477,
13,
18884,
6702,
19347,
4103,
2415,
5158,
2103,
742,
286,
29889,
12403,
29918,
7508,
29918,
29890,
29893,
29918,
2585,
29882,
29920,
29892,
525,
29881,
29933,
12661,
5477,
13,
18884,
4514,
511,
13,
632,
2314,
13,
13,
4706,
364,
29916,
29918,
7076,
353,
16250,
29889,
7514,
287,
21533,
4197,
13,
9651,
6702,
13448,
264,
1056,
742,
518,
13,
18884,
6702,
3782,
895,
6789,
546,
1535,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
1217,
895,
29918,
7382,
29918,
29895,
29892,
525,
29968,
5477,
13,
18884,
6702,
17708,
29881,
402,
475,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
13448,
264,
1056,
8984,
292,
365,
2209,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
3149,
292,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
29954,
475,
472,
350,
2361,
523,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
29890,
2361,
523,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
29909,
19698,
18496,
381,
402,
475,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
12483,
482,
29918,
28486,
381,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
7713,
279,
2133,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
3733,
279,
2133,
29892,
525,
5477,
13,
18884,
4514,
511,
13,
13,
9651,
6702,
3924,
742,
518,
13,
18884,
6702,
11536,
24328,
2147,
1939,
895,
6789,
546,
1535,
742,
286,
29889,
17697,
29918,
1217,
895,
29918,
7382,
29918,
29895,
29892,
525,
29968,
5477,
13,
18884,
6702,
11536,
24328,
2147,
1939,
895,
6789,
546,
1535,
742,
286,
29889,
17697,
29918,
1217,
895,
29918,
7382,
29918,
2585,
29895,
29892,
525,
29881,
29933,
29968,
5477,
13,
18884,
6702,
24131,
678,
475,
1939,
895,
6789,
546,
1535,
742,
286,
29889,
17697,
29918,
5205,
29918,
1217,
895,
29918,
7382,
29918,
29895,
29892,
525,
29968,
5477,
13,
18884,
6702,
24131,
678,
475,
1939,
895,
383,
7168,
742,
286,
29889,
17697,
29918,
5205,
29918,
1217,
895,
29918,
19790,
29892,
525,
5477,
13,
18884,
6702,
24131,
678,
475,
1939,
895,
11479,
742,
286,
29889,
17697,
29918,
5205,
29918,
1217,
895,
29918,
4532,
29892,
525,
29881,
29933,
5477,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
22068,
1939,
895,
5158,
2103,
742,
286,
29889,
8844,
403,
29918,
29882,
29920,
511,
13,
18884,
6702,
1888,
14607,
365,
2209,
742,
286,
29889,
21382,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
4514,
511,
13,
632,
2314,
13,
13,
4706,
23562,
29918,
7076,
353,
16250,
29889,
7514,
287,
21533,
4197,
13,
9651,
6702,
4300,
2415,
357,
742,
518,
13,
18884,
6702,
21472,
472,
530,
841,
1056,
742,
286,
29889,
7508,
29918,
13519,
29918,
271,
29918,
10204,
1056,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
6702,
29954,
475,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
13448,
264,
1056,
8984,
292,
365,
2209,
742,
286,
29889,
7508,
29918,
10204,
1056,
29918,
3149,
292,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
29923,
8193,
29925,
742,
286,
29889,
7508,
29918,
29872,
381,
29886,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
4514,
511,
13,
462,
13,
9651,
6702,
13599,
742,
518,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
13409,
3878,
23860,
742,
286,
29889,
5064,
29918,
29888,
7971,
29918,
29882,
29920,
511,
13,
18884,
6702,
20475,
14121,
365,
2209,
742,
286,
29889,
6997,
29918,
29887,
475,
29918,
7728,
351,
362,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
11536,
17368,
365,
2209,
742,
286,
29889,
7827,
29918,
12719,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
22034,
786,
1000,
5158,
2103,
742,
286,
29889,
12403,
29918,
7508,
29918,
29890,
29893,
29918,
2585,
29882,
29920,
29892,
525,
29881,
29933,
12661,
5477,
13,
18884,
4514,
511,
13,
13,
9651,
6702,
22068,
742,
518,
13,
18884,
6702,
10140,
284,
9206,
2379,
1314,
472,
390,
29990,
530,
841,
1056,
742,
286,
29889,
7810,
29918,
2585,
29893,
29918,
546,
29918,
29885,
29906,
29892,
525,
29881,
29933,
29956,
29914,
29885,
29985,
29906,
5477,
13,
18884,
6702,
13448,
264,
1056,
402,
475,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
29887,
475,
29918,
2585,
29875,
29892,
525,
29881,
20517,
5477,
13,
18884,
6702,
13448,
264,
1056,
26475,
573,
18320,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
15987,
573,
29918,
6203,
29918,
2585,
29885,
29906,
29892,
525,
29881,
29933,
29885,
29985,
29906,
5477,
13,
18884,
6702,
7713,
279,
2133,
341,
1608,
905,
365,
2209,
742,
286,
29889,
3733,
279,
2133,
29918,
29885,
1608,
905,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
29934,
29990,
2184,
1939,
895,
6789,
546,
1535,
742,
286,
29889,
17697,
29918,
1217,
895,
29918,
7382,
29918,
29895,
29892,
525,
29968,
5477,
13,
18884,
6702,
29934,
29990,
11479,
310,
4702,
277,
3255,
29954,
29914,
29911,
10931,
742,
286,
29889,
17697,
29918,
29887,
29918,
957,
29918,
29873,
29918,
2585,
29892,
525,
29881,
29933,
29914,
29968,
5477,
13,
18884,
6702,
3782,
895,
27738,
1705,
360,
575,
537,
3255,
29940,
29918,
29900,
10931,
742,
286,
29889,
17697,
29918,
29876,
29900,
29918,
2585,
29893,
29918,
546,
29918,
29882,
29920,
29892,
525,
29881,
29933,
29956,
29914,
12661,
5477,
13,
18884,
6702,
29816,
9954,
284,
9206,
742,
286,
29889,
17697,
29918,
13519,
29918,
2585,
29893,
29892,
525,
29881,
29933,
29956,
5477,
13,
18884,
6702,
1252,
985,
1939,
895,
350,
29956,
365,
2209,
742,
286,
29889,
735,
985,
29918,
1217,
895,
29918,
4980,
2103,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
1888,
14607,
365,
2209,
742,
286,
29889,
21382,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
19347,
4432,
397,
2785,
395,
29923,
29918,
29890,
29914,
29940,
29918,
29900,
29938,
742,
286,
29889,
12403,
29918,
311,
1545,
29918,
774,
29876,
29900,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
13448,
264,
1056,
8984,
292,
365,
2209,
742,
286,
29889,
17697,
29918,
10204,
1056,
29918,
3149,
292,
29918,
6758,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
8179,
4336,
304,
1939,
895,
3255,
29907,
29914,
29940,
29918,
29900,
10931,
742,
286,
29889,
18038,
29900,
29918,
2585,
29892,
525,
29881,
29933,
12661,
5477,
13,
13,
18884,
4514,
511,
13,
13,
9651,
6702,
29923,
29890,
29914,
29940,
29900,
742,
518,
13,
18884,
6702,
21591,
19907,
742,
286,
29889,
8844,
403,
29918,
2585,
29882,
29920,
29892,
525,
29881,
29933,
12661,
5477,
13,
18884,
6702,
29923,
1089,
1927,
639,
18531,
3255,
29923,
29918,
29890,
10931,
742,
286,
29889,
17697,
29918,
774,
29892,
525,
29881,
29933,
29956,
29914,
12661,
5477,
13,
18884,
6702,
29816,
395,
29923,
29918,
29890,
29914,
29940,
29918,
29900,
29938,
742,
286,
29889,
17697,
29918,
774,
29876,
29900,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
6702,
19347,
395,
29923,
29918,
29890,
29914,
29940,
29918,
29900,
29938,
742,
286,
29889,
12403,
29918,
774,
29876,
29900,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
4514,
511,
13,
9651,
6702,
2558,
10604,
29879,
742,
518,
13,
18884,
1583,
3032,
26029,
675,
29918,
29882,
29920,
877,
21591,
10492,
742,
286,
29889,
8844,
403,
29918,
29882,
29920,
511,
13,
18884,
6702,
6595,
1085,
5359,
742,
286,
29889,
2324,
29918,
9264,
29918,
2585,
29892,
525,
29881,
29933,
5477,
13,
18884,
4514,
511,
13,
632,
2314,
13,
13,
4706,
364,
29916,
29918,
11037,
29918,
29888,
978,
353,
14210,
29879,
29934,
29990,
17144,
29889,
2732,
29915,
1273,
1583,
3032,
1445,
29918,
8588,
1598,
29898,
29885,
29889,
15841,
657,
29918,
978,
29897,
13,
4706,
286,
29889,
17697,
29918,
10204,
1056,
29918,
5415,
29889,
5317,
29918,
11037,
29898,
359,
29889,
2084,
29889,
7122,
29898,
29881,
978,
29892,
364,
29916,
29918,
11037,
29918,
29888,
978,
876,
13,
13,
4706,
25568,
29918,
11037,
29918,
29888,
978,
353,
14210,
29879,
28627,
17144,
29889,
2732,
29915,
1273,
1583,
3032,
1445,
29918,
8588,
1598,
29898,
29885,
29889,
15841,
657,
29918,
978,
29897,
13,
4706,
286,
29889,
7508,
29918,
10204,
1056,
29918,
5415,
29889,
5317,
29918,
11037,
29898,
359,
29889,
2084,
29889,
7122,
29898,
29881,
978,
29892,
25568,
29918,
11037,
29918,
29888,
978,
876,
13,
13,
4706,
565,
16699,
837,
935,
29918,
726,
29901,
13,
9651,
18195,
29918,
3502,
353,
14550,
13,
1966,
1482,
29893,
271,
837,
935,
29961,
497,
12292,
29892,
2780,
29922,
8517,
29991,
29896,
29900,
29892,
2521,
29922,
29946,
29945,
29892,
7052,
29922,
29941,
29892,
29916,
1066,
29922,
29900,
29892,
29891,
1066,
29922,
29900,
3199,
29995,
29879,
29913,
13,
12008,
1273,
16699,
837,
935,
29918,
726,
13,
29937,
2474,
1482,
29893,
271,
837,
935,
29961,
497,
12292,
29892,
2780,
29922,
8517,
29991,
29896,
29900,
29892,
2521,
29922,
29946,
29945,
29892,
7052,
29922,
29941,
29892,
29916,
1066,
29922,
29900,
29892,
29891,
1066,
29922,
29906,
262,
3199,
29928,
4717,
7818,
29913,
13,
4706,
1683,
29901,
13,
9651,
18195,
29918,
3502,
353,
6629,
13,
13,
4706,
565,
7431,
29898,
735,
1129,
29897,
1405,
29871,
29900,
29901,
13,
9651,
429,
1129,
353,
525,
1966,
1482,
3488,
29905,
29876,
29915,
718,
429,
1129,
13,
13,
4706,
2537,
29879,
353,
5159,
13,
4706,
363,
2537,
297,
282,
11512,
29918,
1003,
1973,
29901,
13,
9651,
2537,
29889,
5317,
29898,
29881,
978,
29922,
359,
29889,
2084,
29889,
25721,
29898,
29888,
978,
876,
13,
9651,
2537,
29879,
29889,
4397,
29898,
1003,
29889,
517,
29918,
25694,
3101,
13,
4706,
1006,
1659,
29918,
1003,
1973,
353,
11297,
29876,
4286,
7122,
29898,
1003,
29879,
29897,
13,
13,
4706,
565,
2586,
10492,
29918,
4532,
29901,
13,
9651,
2586,
10492,
29918,
4532,
29889,
5317,
29898,
29881,
978,
29922,
359,
29889,
2084,
29889,
25721,
29898,
29888,
978,
876,
13,
9651,
23562,
29918,
1003,
1973,
353,
2586,
10492,
29918,
4532,
29889,
517,
29918,
25694,
580,
13,
4706,
1683,
29901,
13,
9651,
23562,
29918,
1003,
1973,
353,
6629,
13,
13,
4706,
2715,
29918,
24051,
353,
5159,
13,
4706,
363,
4004,
29918,
978,
29892,
4004,
297,
2715,
29918,
27117,
29901,
13,
9651,
2715,
29918,
24051,
29889,
4397,
877,
4907,
13,
1966,
1482,
3488,
13,
1966,
2042,
18255,
29879,
29913,
13,
1966,
1643,
29912,
2042,
1057,
29995,
29879,
29913,
13,
1966,
463,
29912,
5064,
29913,
13,
12008,
1273,
313,
2042,
29918,
978,
29892,
1583,
3032,
517,
29918,
1643,
29898,
2042,
29918,
978,
4961,
13,
9651,
2715,
29918,
24051,
29889,
4397,
29898,
1311,
3032,
2371,
29898,
29027,
29889,
7514,
287,
21533,
29898,
2042,
4961,
13,
9651,
2715,
29918,
24051,
29889,
4397,
877,
1966,
355,
29912,
5064,
29913,
1495,
13,
13,
4706,
9049,
5085,
353,
426,
13,
9651,
525,
23333,
2396,
23333,
29892,
13,
9651,
525,
735,
1129,
2396,
735,
1129,
29892,
13,
9651,
525,
15841,
657,
7030,
2396,
286,
29889,
15841,
657,
29918,
978,
29892,
13,
9651,
525,
2371,
2396,
1583,
3032,
2371,
29898,
15841,
657,
29918,
7076,
511,
13,
9651,
525,
1639,
1659,
13080,
1973,
2396,
1006,
1659,
29918,
1003,
1973,
29892,
13,
9651,
525,
7508,
17144,
29943,
978,
2396,
25568,
29918,
11037,
29918,
29888,
978,
29892,
13,
9651,
525,
17697,
17144,
29943,
978,
2396,
364,
29916,
29918,
11037,
29918,
29888,
978,
29892,
13,
9651,
525,
29881,
4154,
9802,
2396,
18195,
29918,
3502,
29892,
13,
9651,
525,
272,
2966,
3562,
2396,
1583,
3032,
2371,
29898,
272,
2966,
29918,
7076,
511,
13,
9651,
525,
3286,
2415,
357,
3562,
2396,
1583,
3032,
2371,
29898,
7508,
29918,
7076,
511,
13,
9651,
525,
12719,
3562,
2396,
1583,
3032,
2371,
29898,
12719,
29918,
7076,
511,
13,
9651,
525,
13556,
2147,
3562,
2396,
1583,
3032,
2371,
29898,
17697,
29918,
7076,
511,
13,
9651,
525,
17697,
14688,
3562,
2396,
1583,
3032,
17697,
29918,
14153,
29918,
2371,
3285,
13,
9651,
525,
1639,
1659,
3562,
2396,
1583,
3032,
2371,
29898,
1639,
1659,
29918,
7076,
511,
13,
9651,
525,
8921,
2396,
4148,
29892,
13,
9651,
525,
23959,
2008,
1953,
2396,
11297,
29876,
4286,
7122,
29898,
23959,
29918,
24051,
511,
13,
9651,
525,
15841,
657,
13080,
1973,
2396,
23562,
29918,
1003,
1973,
29892,
13,
9651,
500,
13,
4706,
411,
1722,
29898,
29888,
978,
29892,
525,
29893,
1495,
408,
285,
29881,
29901,
13,
9651,
285,
29881,
29889,
3539,
29898,
3332,
29889,
9482,
29898,
1068,
19290,
876,
13,
13,
13,
1678,
822,
903,
28789,
1764,
29898,
1311,
29892,
2729,
381,
29922,
8516,
1125,
13,
4706,
565,
451,
2729,
381,
29901,
13,
9651,
4303,
353,
1320,
13239,
29889,
9675,
2917,
29889,
657,
29918,
4691,
29918,
1982,
580,
13,
9651,
1104,
353,
525,
2272,
2324,
29914,
4776,
29915,
13,
9651,
2729,
381,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1982,
29892,
1104,
29897,
13,
13,
4706,
8829,
353,
432,
262,
1764,
29906,
29889,
18649,
29898,
13,
9651,
2908,
29918,
2962,
29918,
1807,
353,
11297,
29933,
21339,
29912,
742,
13,
9651,
2908,
29918,
355,
29918,
1807,
353,
525,
29913,
742,
13,
9651,
2286,
29918,
2962,
29918,
1807,
353,
11297,
26865,
29912,
742,
13,
9651,
2286,
29918,
355,
29918,
1807,
353,
525,
29913,
742,
13,
9651,
3440,
29918,
2962,
29918,
1807,
353,
11297,
26660,
742,
13,
9651,
3440,
29918,
355,
29918,
1807,
353,
525,
29913,
742,
13,
9651,
1196,
29918,
20788,
29918,
13506,
353,
525,
7686,
742,
13,
9651,
1196,
29918,
9342,
29918,
13506,
353,
14210,
29937,
742,
13,
9651,
17151,
29918,
1271,
29879,
353,
5852,
29892,
13,
9651,
4469,
21587,
353,
7700,
29892,
13,
9651,
23466,
353,
432,
262,
1764,
29906,
29889,
2283,
3924,
10036,
29898,
6707,
381,
876,
13,
4706,
736,
8829,
13,
2
] |
pykg2vec/config/hyperparams.py | kyzhouhzau/pykg2vec | 1 | 147480 | """
hyperparams.py
====================================
It provides configuration for the tunable hyper-parameter ranges for all the algorithms.
"""
from argparse import ArgumentParser
from hyperopt import hp
from hyperopt.pyll.base import scope
import numpy as np
class HyperparamterLoader:
def __init__(self):
# This hyperparameter setting aims to reproduce the experimental setup in its original papers.
self.hyperparams_paper = {
'freebase15k':
{
'transe' : {'learning_rate': 0.01,'L1_flag': True,'hidden_size':50,'batch_size': 128,'epochs':1000,'margin':1.00,'optimizer': 'sgd','sampling':"uniform",'neg_rate':1},
'transh' : {'learning_rate': 0.005,'L1_flag':False,'hidden_size':50,'batch_size':1200,'epochs':1000,'margin': 0.5,'optimizer': 'sgd','sampling':"uniform",'neg_rate':1,'C': 0.015625},
'hole' : {'learning_rate': 0.01,'L1_flag': True,'hidden_size':50,'batch_size': 512,'epochs':1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1},
'transm' : {'learning_rate': 0.001,'L1_flag': True,'hidden_size':50,'batch_size': 128,'epochs':1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1},
'rescal' : {'learning_rate': 0.001,'L1_flag': True,'hidden_size':50,'batch_size': 128,'epochs':1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1},
'rotate' : {'learning_rate': 0.01,'L1_flag': True,'hidden_size':50,'batch_size': 128,'epochs':1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1},
'sme' : {'learning_rate': 0.001,'L1_flag': True,'hidden_size':50,'batch_size': 128,'epochs':1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1,'bilinear':False},
'transr' : {'learning_rate': 0.001,'L1_flag': True,'ent_hidden_size':50,'rel_hidden_size':50,'batch_size': 4800,'epochs': 1000,'margin': 1.0,'optimizer': 'sgd','sampling': "bern",'neg_rate':1},
'transd' : {'learning_rate': 0.001,'L1_flag':False,'ent_hidden_size':50,'rel_hidden_size':50,'batch_size': 200,'epochs': 1000,'margin': 1.0,'optimizer': 'sgd','sampling':"uniform",'neg_rate':1},
'ntn' : {'learning_rate': 0.01,'L1_flag': True,'ent_hidden_size':64,'rel_hidden_size':32,'batch_size': 128,'epochs': 1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1}, # problematic
'slm' : {'learning_rate': 0.01,'L1_flag': True,'ent_hidden_size':64,'rel_hidden_size':32,'batch_size': 128,'epochs': 1000,'margin': 1.0,'optimizer':'adam','sampling':"uniform",'neg_rate':1},
'kg2e' : {'learning_rate': 0.01,'L1_flag': True,'hidden_size':50,'batch_size':1440,'epochs':1000,'margin': 4.0,'optimizer': 'sgd','sampling':"uniform",'distance_measure': "kl_divergence",'cmax': 0.05,'cmin': 5.00,'neg_rate': 1},
'complex' : {'learning_rate': 0.5,'hidden_size':100,'batch_size':5000,'epochs':1000,'optimizer':'adagrad','sampling':"uniform",'neg_rate':10,'lmbda':0.0001},
'distmult': {'learning_rate': 0.1,'hidden_size':100,'batch_size':50000,'epochs':1000,'data':'Freebase15k','optimizer':'adagrad','sampling':"uniform",'neg_rate':1,'lmbda':0.0001},
}
}
self.hyperparams_paper['fb15k'] = self.hyperparams_paper['freebase15k']
def load_hyperparameter(self, dataset_name, algorithm):
d_name = dataset_name.lower()
a_name = algorithm.lower()
if d_name in self.hyperparams_paper and a_name in self.hyperparams_paper[d_name]:
params = self.hyperparams_paper[d_name][a_name]
return params
else:
raise Exception("We have not explored this experimental setting! (%s, %s)"%(dataset_name, algorithm))
class KGETuneArgParser:
"""The class defines the arguements accepted for the bayesian optimizer.
KGETuneArgParser utilizes the ArgumentParser module and add the arguments
accepted for tuning the model.
Args:
model (str): Name of the model/algorithm to be tuned.
debug (bool): If True, tunes the model in debugging mode.
Examples:
>>> from pykg2vec.config.hyperparams import KGETuneArgParser
>>> from pykg2vec.utils.bayesian_optimizer import BaysOptimizer
>>> args = KGETuneArgParser().get_args()
>>> bays_opt = BaysOptimizer(args=args)
Todo:
* Add more arguments!.
"""
def __init__(self):
self.parser = ArgumentParser(description='Knowledge Graph Embedding tunable configs.')
''' basic configs '''
self.parser.add_argument('-mn', dest='model', default='TransE', type=str, help='Model to tune')
self.parser.add_argument('-db', dest='debug', default=False, type=lambda x: (str(x).lower() == 'true'),
help='To use debug mode or not.')
self.parser.add_argument('-ds', dest='dataset_name', default='Freebase15k', type=str, help='The dataset name (choice: fb15k/wn18/wn18_rr/yago/fb15k_237/ks/nations/umls)')
self.parser.add_argument('-dsp', dest='dataset_path', default=None, type=str, help='The path to custom dataset.')
self.parser.add_argument('-mt', dest='max_number_trials', default=100, type=int, help='The maximum times of trials for bayesian optimizer.')
def get_args(self, args):
"""Gets the arguments from the console and parses it."""
return self.parser.parse_args(args)
class TransEParams:
"""This class defines the hyperameters and its ranges for tuning TranE algorithm.
TransEParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 10.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [500]) # always choose 10 training epochs.
}
class TransHParams:
"""This class defines the hyperameters and its ranges for tuning TranH algorithm.
TransHParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class TransMParams:
"""This class defines the hyperameters and its ranges for tuning TranM algorithm.
TransMParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class RescalParams:
"""This class defines the hyperameters and its ranges for tuning Rescal algorithm.
Rescal defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class SMEParams:
"""This class defines the hyperameters and its ranges for tuning SME algorithm.
SME defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
bilinear (bool): List of boolean values.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'bilinear': hp.choice('bilinear', [True, False]),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
# self.bilinear = [True, False]
class TransDParams:
"""This class defines the hyperameters and its ranges for tuning TranD algorithm.
TransDParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class TransRParams:
"""This class defines the hyperameters and its ranges for tuning TranR algorithm.
TransRParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
ent_hidden_size (list): List of integer values.
rel_hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'ent_hidden_size': scope.int(hp.qloguniform('ent_hidden_size', np.log(8), np.log(512),1)),
'rel_hidden_size': scope.int(hp.qloguniform('rel_hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.ent_hidden_size = [8, 16, 32, 64, 128, 256]
# self.rel_hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class NTNParams:
"""This class defines the hyperameters and its ranges for tuning NTN algorithm.
NTNParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
ent_hidden_size (list): List of integer values.
rel_hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'ent_hidden_size': scope.int(hp.qloguniform('ent_hidden_size', np.log(8), np.log(64),1)),
'rel_hidden_size': scope.int(hp.qloguniform('rel_hidden_size', np.log(8), np.log(64),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.ent_hidden_size = [8, 16, 32]
# self.rel_hidden_size = [8, 16, 32]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class SLMParams:
"""This class defines the hyperameters and its ranges for tuning SLM algorithm.
SLMParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
ent_hidden_size (list): List of integer values.
rel_hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'ent_hidden_size': scope.int(hp.qloguniform('ent_hidden_size', np.log(8), np.log(512),1)),
'rel_hidden_size': scope.int(hp.qloguniform('rel_hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.ent_hidden_size = [8, 16, 32, 64, 128, 256]
# self.rel_hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class HoLEParams:
"""This class defines the hyperameters and its ranges for tuning HoLE algorithm.
HoLEParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class RotatEParams:
"""This class defines the hyperameters and its ranges for tuning RotatE algorithm.
RotatEParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'margin': hp.uniform('margin', 0.0, 2.0),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class ConvEParams:
"""This class defines the hyperameters and its ranges for tuning ConvE algorithm.
ConvEParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
lambda (list) : List of floating point values.
feature_map_dropout (list) :List of floating point values.
input_dropout (list) : List of floating point values.
hidden_dropout (list) : List of floating point values.
use_bias (list) :List of boolean values.
label_smoothing (list) : List of floating point values.
lr_decay (float) : List of floating point values.
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.lmbda = [0.1, 0.2]
self.feature_map_dropout = [0.1, 0.2, 0.5]
self.input_dropout = [0.1, 0.2, 0.5]
self.hidden_dropout = [0.1, 0.2, 0.5]
self.use_bias = [True, False]
self.label_smoothing = [0.1, 0.2, 0.5]
self.lr_decay = [0.95, 0.9, 0.8]
self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
self.L1_flag = [True, False]
self.hidden_size = [50]
self.batch_size = [200, 400, 600]
self.epochs = [2, 5, 10]
self.margin = [0.4, 1.0, 2.0]
self.optimizer = ["adam", "sgd", 'rms']
self.sampling = ["uniform", "bern"]
class ProjE_pointwiseParams:
"""This class defines the hyperameters and its ranges for tuning ProjE_pointwise algorithm.
ProjE_pointwise defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
lambda (list) : List of floating point values.
feature_map_dropout (list) :List of floating point values.
input_dropout (list) : List of floating point values.
hidden_dropout (list) : List of floating point values.
use_bias (list) :List of boolean values.
label_smoothing (list) : List of floating point values.
lr_decay (float) : List of floating point values.
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.lmbda = [0.1, 0.2]
self.feature_map_dropout = [0.1, 0.2, 0.5]
self.input_dropout = [0.1, 0.2, 0.5]
self.hidden_dropout = [0.1, 0.2, 0.5]
self.use_bias = [True, False]
self.label_smoothing = [0.1, 0.2, 0.5]
self.lr_decay = [0.95, 0.9, 0.8]
self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
self.L1_flag = [True, False]
self.hidden_size = [8, 16]
self.batch_size = [256, 512]
self.epochs = [2, 5, 10]
self.margin = [0.4, 1.0, 2.0]
self.optimizer = ["adam", "sgd", 'rms']
self.sampling = ["uniform", "bern"]
class KG2EParams:
"""This class defines the hyperameters and its ranges for tuning KG2E algorithm.
KG2E defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
bilinear (list): List of boolean values.
distance_measure (list): [kl_divergence or expected_likelihood]
cmax (list): List of floating point values.
cmin (list): List of floating point values.
"""
def __init__(self):
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.L1_flag = [True, False]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.margin = [0.4, 1.0, 2.0]
# self.optimizer = ["adam", "sgd", 'rms']
# self.distance_measure = ["kl_divergence", "expected_likelihood"]
# self.cmax = [0.05, 0.1, 0.2]
# self.cmin = [5.00, 3.00, 2.00, 1.00]
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'L1_flag': hp.choice('L1_flag', [True, False]),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'lmbda': hp.loguniform('lmbda', np.log(0.00001), np.log(0.001)),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'margin': hp.uniform('margin', 0.5, 8.0),
'distance_measure': hp.choice('distance_measure', ["kl_divergence", "expected_likelihood"]),
'cmax': hp.loguniform('cmax', np.log(0.05), np.log(0.2)),
'cmin': hp.loguniform('cmin', np.log(1), np.log(5)),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
class ComplexParams:
"""This class defines the hyperameters and its ranges for tuning Complex algorithm.
Complex defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
lambda (list) : List of floating point values.
feature_map_dropout (list) :List of floating point values.
input_dropout (list) : List of floating point values.
hidden_dropout (list) : List of floating point values.
use_bias (list) :List of boolean values.
label_smoothing (list) : List of floating point values.
lr_decay (float) : List of floating point values.
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'lmbda': hp.loguniform('lmbda', np.log(0.00001), np.log(0.001)),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.lmbda = [0.1, 0.2]
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class DistMultParams:
"""This class defines the hyperameters and its ranges for tuning DistMult algorithm.
DistMultParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
lambda (list) : List of floating point values.
feature_map_dropout (list) :List of floating point values.
input_dropout (list) : List of floating point values.
hidden_dropout (list) : List of floating point values.
use_bias (list) :List of boolean values.
label_smoothing (list) : List of floating point values.
lr_decay (float) : List of floating point values.
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.search_space = {
'learning_rate': hp.loguniform('learning_rate', np.log(0.00001), np.log(0.1)),
'hidden_size': scope.int(hp.qloguniform('hidden_size', np.log(8), np.log(512),1)),
'batch_size': scope.int(hp.qloguniform('batch_size', np.log(8), np.log(4096),1)),
'lmbda': hp.loguniform('lmbda', np.log(0.00001), np.log(0.001)),
'optimizer': hp.choice('optimizer', ["adam", "sgd", 'rms']),
'epochs': hp.choice('epochs', [10]) # always choose 10 training epochs.
}
# self.lmbda = [0.1, 0.2]
# self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
# self.hidden_size = [8, 16, 32, 64, 128, 256]
# self.batch_size = [128, 256, 512]
# self.epochs = [2, 5, 10]
# self.optimizer = ["adam", "sgd", 'rms']
# self.sampling = ["uniform", "bern"]
class TuckERParams:
"""This class defines the hyperameters and its ranges for tuning TuckER algorithm.
TuckERParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
lambda (list) : List of floating point values.
feature_map_dropout (list) :List of floating point values.
input_dropout (list) : List of floating point values.
hidden_dropout (list) : List of floating point values.
use_bias (list) :List of boolean values.
label_smoothing (list) : List of floating point values.
lr_decay (float) : List of floating point values.
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
"""
def __init__(self):
self.lmbda = [0.1, 0.2]
self.feature_map_dropout = [0.1, 0.2, 0.5]
self.input_dropout = [0.1, 0.2, 0.5]
self.hidden_dropout = [0.1, 0.2, 0.5]
self.use_bias = [True, False]
self.label_smoothing = [0.1, 0.2, 0.5]
self.lr_decay = [0.95, 0.9, 0.8]
self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
self.L1_flag = [True, False]
self.hidden_size = [8, 16, 32, 64, 128, 256]
self.batch_size = [128, 256, 512]
self.epochs = [2, 5, 10]
self.margin = [0.4, 1.0, 2.0]
self.optimizer = ["adam", "sgd", 'rms']
self.sampling = ["uniform", "bern"]
class TransGParams:
"""This class defines the hyperameters and its ranges for tuning TransG algorithm.
TransGParams defines all the possibel values to be tuned for the algorithm. User may
change these values directly for performing the bayesian optimization of the hyper-parameters
Args:
learning_rate (list): List of floating point values.
L1_flag (list): List of boolean values.
hidden_size (list): List of integer values.
batch_size (list): List of integer values.
epochs (list): List of integer values.
margin (list): List of floating point values.
optimizer (list): List of strings defining the optimization algorithm to be used.
sampling (list): List of string defining the sampling to be used for generating negative examples.
training_threshold (float): List of floating point values.
ncluster (int): List of integer values.
CRP_factor (float): List of floating point values.
weight_norm (bool): List of boolean values.
"""
def __init__(self):
self.learning_rate = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1]
self.L1_flag = [True, False]
self.hidden_size = [8, 16, 32, 64, 128, 256]
self.batch_size = [128, 256, 512]
self.epochs = [2, 5, 10]
self.margin = [0.4, 1.0, 2.0]
self.optimizer = ["adam", "sgd", 'rms']
self.sampling = ["uniform", "bern"]
self.training_threshold = [1.0, 2.0, 3.0]
self.ncluster = [3, 4, 5, 6, 7]
self.CRP_factor = [0.01, 0.05, 0.1]
self.weight_norm = [True, False]
| [
1,
9995,
13,
24947,
7529,
29889,
2272,
13,
9166,
9166,
2751,
13,
3112,
8128,
5285,
363,
278,
18515,
519,
11266,
29899,
15501,
20238,
363,
599,
278,
14009,
29889,
13,
15945,
29908,
13,
13,
3166,
1852,
5510,
1053,
23125,
11726,
13,
3166,
11266,
3670,
1053,
298,
29886,
13,
3166,
11266,
3670,
29889,
2272,
645,
29889,
3188,
1053,
6874,
13,
5215,
12655,
408,
7442,
13,
13,
13,
1990,
26078,
3207,
357,
10036,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
418,
396,
910,
11266,
15501,
4444,
263,
9893,
304,
18532,
278,
17986,
6230,
297,
967,
2441,
15055,
29889,
29871,
13,
418,
1583,
29889,
24947,
7529,
29918,
19773,
353,
426,
13,
4706,
525,
10745,
774,
559,
29896,
29945,
29895,
2396,
29871,
13,
4706,
426,
13,
3986,
525,
509,
12350,
29915,
29871,
584,
11117,
21891,
29918,
10492,
2396,
259,
29900,
29889,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29871,
29896,
29906,
29947,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29896,
29889,
29900,
29900,
5501,
20640,
3950,
2396,
525,
5311,
29881,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
13,
3986,
525,
3286,
29882,
29915,
29871,
584,
11117,
21891,
29918,
10492,
2396,
29871,
29900,
29889,
29900,
29900,
29945,
5501,
29931,
29896,
29918,
15581,
2396,
8824,
5501,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29896,
29906,
29900,
29900,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29900,
29889,
29945,
5501,
20640,
3950,
2396,
525,
5311,
29881,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
5501,
29907,
2396,
29871,
29900,
29889,
29900,
29896,
29945,
29953,
29906,
29945,
1118,
13,
3986,
525,
29716,
29915,
1678,
584,
11117,
21891,
29918,
10492,
2396,
259,
29900,
29889,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29871,
29945,
29896,
29906,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
22099,
328,
314,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
13,
3986,
525,
3286,
29885,
29915,
29871,
584,
11117,
21891,
29918,
10492,
2396,
29871,
29900,
29889,
29900,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29871,
29896,
29906,
29947,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
22099,
328,
314,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
13,
3986,
525,
690,
1052,
29915,
29871,
584,
11117,
21891,
29918,
10492,
2396,
29871,
29900,
29889,
29900,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29871,
29896,
29906,
29947,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
22099,
328,
314,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
13,
3986,
525,
23361,
29915,
29871,
584,
11117,
21891,
29918,
10492,
2396,
259,
29900,
29889,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29871,
29896,
29906,
29947,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
22099,
328,
314,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
13,
3986,
525,
29879,
1004,
29915,
268,
584,
11117,
21891,
29918,
10492,
2396,
29871,
29900,
29889,
29900,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29871,
29896,
29906,
29947,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
22099,
328,
314,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
5501,
18152,
457,
279,
2396,
8824,
1118,
13,
3986,
525,
3286,
29878,
29915,
29871,
584,
11117,
21891,
29918,
10492,
2396,
29871,
29900,
29889,
29900,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
296,
29918,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
2674,
29918,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29871,
29946,
29947,
29900,
29900,
5501,
1022,
2878,
29879,
2396,
29871,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
2396,
525,
5311,
29881,
3788,
13445,
10335,
2396,
259,
376,
5892,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
13,
3986,
525,
3286,
29881,
29915,
29871,
584,
11117,
21891,
29918,
10492,
2396,
29871,
29900,
29889,
29900,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
8824,
5501,
296,
29918,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
2674,
29918,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
259,
29906,
29900,
29900,
5501,
1022,
2878,
29879,
2396,
29871,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
2396,
525,
5311,
29881,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
13,
3986,
525,
593,
29876,
29915,
268,
584,
11117,
21891,
29918,
10492,
2396,
259,
29900,
29889,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
296,
29918,
10892,
29918,
2311,
2396,
29953,
29946,
5501,
2674,
29918,
10892,
29918,
2311,
2396,
29941,
29906,
5501,
16175,
29918,
2311,
2396,
259,
29896,
29906,
29947,
5501,
1022,
2878,
29879,
2396,
29871,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
22099,
328,
314,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
396,
1108,
2454,
13,
3986,
525,
2536,
29885,
29915,
268,
584,
11117,
21891,
29918,
10492,
2396,
259,
29900,
29889,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
296,
29918,
10892,
29918,
2311,
2396,
29953,
29946,
5501,
2674,
29918,
10892,
29918,
2311,
2396,
29941,
29906,
5501,
16175,
29918,
2311,
2396,
259,
29896,
29906,
29947,
5501,
1022,
2878,
29879,
2396,
29871,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29896,
29889,
29900,
5501,
20640,
3950,
22099,
328,
314,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
1118,
13,
3986,
525,
9415,
29906,
29872,
29915,
1678,
584,
11117,
21891,
29918,
10492,
2396,
259,
29900,
29889,
29900,
29896,
5501,
29931,
29896,
29918,
15581,
2396,
5852,
5501,
10892,
29918,
2311,
2396,
29945,
29900,
5501,
16175,
29918,
2311,
2396,
29896,
29946,
29946,
29900,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
9264,
2396,
29871,
29946,
29889,
29900,
5501,
20640,
3950,
2396,
525,
5311,
29881,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
19244,
29918,
26658,
2396,
376,
6321,
29918,
29881,
2147,
10238,
613,
29915,
29883,
3317,
2396,
29871,
29900,
29889,
29900,
29945,
5501,
29883,
1195,
2396,
29871,
29945,
29889,
29900,
29900,
5501,
10052,
29918,
10492,
2396,
29871,
29896,
1118,
13,
3986,
525,
19676,
29915,
584,
11117,
21891,
29918,
10492,
2396,
1678,
29900,
29889,
29945,
5501,
10892,
29918,
2311,
2396,
29896,
29900,
29900,
5501,
16175,
29918,
2311,
2396,
29945,
29900,
29900,
29900,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
20640,
3950,
22099,
328,
351,
3665,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
29900,
5501,
29880,
8337,
1388,
2396,
29900,
29889,
29900,
29900,
29900,
29896,
1118,
13,
3986,
525,
5721,
4713,
2396,
11117,
21891,
29918,
10492,
2396,
1678,
29900,
29889,
29896,
5501,
10892,
29918,
2311,
2396,
29896,
29900,
29900,
5501,
16175,
29918,
2311,
2396,
29945,
29900,
29900,
29900,
29900,
5501,
1022,
2878,
29879,
2396,
29896,
29900,
29900,
29900,
5501,
1272,
22099,
23923,
774,
559,
29896,
29945,
29895,
3788,
20640,
3950,
22099,
328,
351,
3665,
3788,
13445,
10335,
2396,
29908,
29590,
613,
29915,
10052,
29918,
10492,
2396,
29896,
5501,
29880,
8337,
1388,
2396,
29900,
29889,
29900,
29900,
29900,
29896,
1118,
13,
965,
13,
4706,
500,
13,
418,
500,
13,
13,
418,
1583,
29889,
24947,
7529,
29918,
19773,
1839,
14943,
29896,
29945,
29895,
2033,
353,
1583,
29889,
24947,
7529,
29918,
19773,
1839,
10745,
774,
559,
29896,
29945,
29895,
2033,
13,
268,
13,
1678,
822,
2254,
29918,
24947,
15501,
29898,
1311,
29892,
8783,
29918,
978,
29892,
5687,
1125,
13,
418,
270,
29918,
978,
353,
8783,
29918,
978,
29889,
13609,
580,
13,
418,
263,
29918,
978,
353,
5687,
29889,
13609,
580,
13,
13,
418,
565,
270,
29918,
978,
297,
1583,
29889,
24947,
7529,
29918,
19773,
322,
263,
29918,
978,
297,
1583,
29889,
24947,
7529,
29918,
19773,
29961,
29881,
29918,
978,
5387,
13,
4706,
8636,
353,
1583,
29889,
24947,
7529,
29918,
19773,
29961,
29881,
29918,
978,
3816,
29874,
29918,
978,
29962,
13,
4706,
736,
8636,
13,
418,
1683,
29901,
13,
4706,
12020,
8960,
703,
4806,
505,
451,
3902,
4395,
445,
17986,
4444,
29991,
313,
29995,
29879,
29892,
1273,
29879,
5513,
29995,
29898,
24713,
29918,
978,
29892,
5687,
876,
13,
13,
13,
1990,
476,
7194,
1540,
8559,
11726,
29901,
13,
1678,
9995,
1576,
770,
17645,
278,
1852,
29884,
4110,
9259,
363,
278,
23041,
18970,
5994,
3950,
29889,
13,
13,
418,
476,
7194,
1540,
8559,
11726,
3667,
7093,
278,
23125,
11726,
3883,
322,
788,
278,
6273,
13,
418,
9259,
363,
18515,
292,
278,
1904,
29889,
13,
13,
418,
826,
3174,
29901,
13,
308,
1904,
313,
710,
1125,
4408,
310,
278,
1904,
29914,
20567,
304,
367,
18515,
287,
29889,
13,
308,
4744,
313,
11227,
1125,
960,
5852,
29892,
260,
7844,
278,
1904,
297,
13490,
4464,
29889,
13,
13,
418,
1222,
9422,
29901,
13,
3986,
8653,
515,
11451,
9415,
29906,
2003,
29889,
2917,
29889,
24947,
7529,
1053,
476,
7194,
1540,
8559,
11726,
13,
3986,
8653,
515,
11451,
9415,
29906,
2003,
29889,
13239,
29889,
27495,
18970,
29918,
20640,
3950,
1053,
350,
1036,
20624,
326,
3950,
13,
3986,
8653,
6389,
353,
476,
7194,
1540,
8559,
11726,
2141,
657,
29918,
5085,
580,
13,
3986,
8653,
289,
1036,
29918,
3670,
353,
350,
1036,
20624,
326,
3950,
29898,
5085,
29922,
5085,
29897,
13,
13,
539,
7561,
29877,
29901,
13,
308,
334,
3462,
901,
6273,
21520,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
16680,
353,
23125,
11726,
29898,
8216,
2433,
29968,
3707,
5485,
12367,
2812,
2580,
8497,
18515,
519,
2295,
29879,
29889,
1495,
13,
13,
4706,
14550,
6996,
2295,
29879,
14550,
13,
4706,
1583,
29889,
16680,
29889,
1202,
29918,
23516,
877,
29899,
23521,
742,
2731,
2433,
4299,
742,
2322,
2433,
4300,
29923,
742,
1134,
29922,
710,
29892,
1371,
2433,
3195,
304,
260,
1540,
1495,
13,
4706,
1583,
29889,
16680,
29889,
1202,
29918,
23516,
877,
29899,
2585,
742,
2731,
2433,
8382,
742,
2322,
29922,
8824,
29892,
1134,
29922,
2892,
921,
29901,
313,
710,
29898,
29916,
467,
13609,
580,
1275,
525,
3009,
5477,
13,
462,
462,
1371,
2433,
1762,
671,
4744,
4464,
470,
451,
29889,
1495,
13,
4706,
1583,
29889,
16680,
29889,
1202,
29918,
23516,
877,
29899,
6289,
742,
2731,
2433,
24713,
29918,
978,
742,
2322,
2433,
23923,
774,
559,
29896,
29945,
29895,
742,
1134,
29922,
710,
29892,
1371,
2433,
1576,
8783,
1024,
313,
16957,
29901,
285,
29890,
29896,
29945,
29895,
29914,
1233,
29896,
29947,
29914,
1233,
29896,
29947,
29918,
21478,
29914,
29891,
4425,
29914,
14943,
29896,
29945,
29895,
29918,
29906,
29941,
29955,
29914,
2039,
29914,
29876,
800,
29914,
398,
3137,
29897,
1495,
13,
4706,
1583,
29889,
16680,
29889,
1202,
29918,
23516,
877,
29899,
29881,
1028,
742,
2731,
2433,
24713,
29918,
2084,
742,
2322,
29922,
8516,
29892,
1134,
29922,
710,
29892,
1371,
2433,
1576,
2224,
304,
2888,
8783,
29889,
1495,
13,
4706,
1583,
29889,
16680,
29889,
1202,
29918,
23516,
877,
29899,
4378,
742,
2731,
2433,
3317,
29918,
4537,
29918,
3626,
1338,
742,
2322,
29922,
29896,
29900,
29900,
29892,
1134,
29922,
524,
29892,
1371,
2433,
1576,
7472,
3064,
310,
3367,
1338,
363,
23041,
18970,
5994,
3950,
29889,
1495,
13,
13,
1678,
822,
679,
29918,
5085,
29898,
1311,
29892,
6389,
1125,
13,
4706,
9995,
29954,
1691,
278,
6273,
515,
278,
2991,
322,
610,
29879,
267,
372,
1213,
15945,
13,
4706,
736,
1583,
29889,
16680,
29889,
5510,
29918,
5085,
29898,
5085,
29897,
13,
13,
13,
13,
1990,
4103,
29923,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
323,
661,
29923,
5687,
29889,
13,
13,
1678,
4103,
29923,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29896,
29900,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29945,
29900,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
13,
13,
1990,
4103,
29950,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
323,
661,
29950,
5687,
29889,
13,
13,
1678,
4103,
29950,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
4103,
29924,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
323,
661,
29924,
5687,
29889,
13,
13,
1678,
4103,
29924,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
2538,
1052,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
2538,
1052,
5687,
29889,
13,
13,
1678,
2538,
1052,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
317,
2303,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
317,
2303,
5687,
29889,
13,
13,
1678,
317,
2303,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
418,
13181,
457,
279,
313,
11227,
1125,
2391,
310,
7223,
1819,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
18152,
457,
279,
2396,
298,
29886,
29889,
16957,
877,
18152,
457,
279,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
4706,
396,
1583,
29889,
18152,
457,
279,
353,
518,
5574,
29892,
7700,
29962,
13,
13,
13,
1990,
4103,
29928,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
323,
661,
29928,
5687,
29889,
13,
13,
1678,
4103,
29928,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
13,
1990,
4103,
29934,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
323,
661,
29934,
5687,
29889,
13,
13,
1678,
4103,
29934,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
875,
29918,
10892,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
1104,
29918,
10892,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
296,
29918,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
296,
29918,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
2674,
29918,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
2674,
29918,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
296,
29918,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
2674,
29918,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
405,
29911,
29940,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
405,
29911,
29940,
5687,
29889,
13,
13,
1678,
405,
29911,
29940,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
875,
29918,
10892,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
1104,
29918,
10892,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
296,
29918,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
296,
29918,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29953,
29946,
511,
29896,
8243,
13,
3986,
525,
2674,
29918,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
2674,
29918,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29953,
29946,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
296,
29918,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29962,
13,
4706,
396,
1583,
29889,
2674,
29918,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
317,
26369,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
317,
26369,
5687,
29889,
13,
13,
1678,
317,
26369,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
875,
29918,
10892,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
1104,
29918,
10892,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
296,
29918,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
296,
29918,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
2674,
29918,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
2674,
29918,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
296,
29918,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
2674,
29918,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
8335,
1307,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
8335,
1307,
5687,
29889,
13,
13,
1678,
8335,
1307,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
9664,
271,
29923,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
9664,
271,
29923,
5687,
29889,
13,
13,
1678,
9664,
271,
29923,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
511,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
1281,
29894,
29923,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
1281,
29894,
29923,
5687,
29889,
13,
13,
1678,
1281,
29894,
29923,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
14013,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
4682,
29918,
1958,
29918,
8865,
449,
313,
1761,
29897,
584,
1293,
310,
16526,
1298,
1819,
29889,
13,
418,
1881,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
7934,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
671,
29918,
29890,
3173,
313,
1761,
29897,
584,
1293,
310,
7223,
1819,
29889,
13,
418,
3858,
29918,
3844,
29877,
6046,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
301,
29878,
29918,
7099,
388,
313,
7411,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
29880,
8337,
1388,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29962,
13,
4706,
1583,
29889,
14394,
29918,
1958,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
2080,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
10892,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
1509,
29918,
29890,
3173,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
1583,
29889,
1643,
29918,
3844,
29877,
6046,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
29212,
29918,
7099,
388,
353,
518,
29900,
29889,
29929,
29945,
29892,
29871,
29900,
29889,
29929,
29892,
29871,
29900,
29889,
29947,
29962,
13,
4706,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
1583,
29889,
10892,
29918,
2311,
353,
518,
29945,
29900,
29962,
13,
4706,
1583,
29889,
16175,
29918,
2311,
353,
518,
29906,
29900,
29900,
29892,
29871,
29946,
29900,
29900,
29892,
29871,
29953,
29900,
29900,
29962,
13,
4706,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
1019,
29926,
29923,
29918,
3149,
3538,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
1019,
29926,
29923,
29918,
3149,
3538,
5687,
29889,
13,
13,
1678,
1019,
29926,
29923,
29918,
3149,
3538,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
14013,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
4682,
29918,
1958,
29918,
8865,
449,
313,
1761,
29897,
584,
1293,
310,
16526,
1298,
1819,
29889,
13,
418,
1881,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
7934,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
671,
29918,
29890,
3173,
313,
1761,
29897,
584,
1293,
310,
7223,
1819,
29889,
13,
418,
3858,
29918,
3844,
29877,
6046,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
301,
29878,
29918,
7099,
388,
313,
7411,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
29880,
8337,
1388,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29962,
13,
4706,
1583,
29889,
14394,
29918,
1958,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
2080,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
10892,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
1509,
29918,
29890,
3173,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
1583,
29889,
1643,
29918,
3844,
29877,
6046,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
29212,
29918,
7099,
388,
353,
518,
29900,
29889,
29929,
29945,
29892,
29871,
29900,
29889,
29929,
29892,
29871,
29900,
29889,
29947,
29962,
13,
4706,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29962,
13,
4706,
1583,
29889,
16175,
29918,
2311,
353,
518,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
476,
29954,
29906,
29923,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
476,
29954,
29906,
29923,
5687,
29889,
13,
13,
1678,
476,
29954,
29906,
29923,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
418,
13181,
457,
279,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
5418,
29918,
26658,
313,
1761,
1125,
518,
6321,
29918,
29881,
2147,
10238,
470,
3806,
29918,
5081,
22342,
29962,
13,
418,
274,
3317,
313,
1761,
1125,
29871,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
274,
1195,
313,
1761,
1125,
29871,
2391,
310,
16526,
1298,
1819,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
19244,
29918,
26658,
353,
6796,
6321,
29918,
29881,
2147,
10238,
613,
376,
9684,
29918,
5081,
22342,
3108,
13,
4706,
396,
1583,
29889,
29883,
3317,
353,
518,
29900,
29889,
29900,
29945,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29962,
13,
4706,
396,
1583,
29889,
29883,
1195,
353,
518,
29945,
29889,
29900,
29900,
29892,
29871,
29941,
29889,
29900,
29900,
29892,
29871,
29906,
29889,
29900,
29900,
29892,
29871,
29896,
29889,
29900,
29900,
29962,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
29931,
29896,
29918,
15581,
2396,
298,
29886,
29889,
16957,
877,
29931,
29896,
29918,
15581,
742,
518,
5574,
29892,
7700,
11724,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
29880,
8337,
1388,
2396,
298,
29886,
29889,
1188,
29590,
877,
29880,
8337,
1388,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29896,
8243,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
9264,
2396,
298,
29886,
29889,
29590,
877,
9264,
742,
29871,
29900,
29889,
29945,
29892,
29871,
29947,
29889,
29900,
511,
13,
3986,
525,
19244,
29918,
26658,
2396,
298,
29886,
29889,
16957,
877,
19244,
29918,
26658,
742,
6796,
6321,
29918,
29881,
2147,
10238,
613,
376,
9684,
29918,
5081,
22342,
3108,
511,
13,
3986,
525,
29883,
3317,
2396,
298,
29886,
29889,
1188,
29590,
877,
29883,
3317,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29945,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29906,
8243,
13,
3986,
525,
29883,
1195,
2396,
298,
29886,
29889,
1188,
29590,
877,
29883,
1195,
742,
7442,
29889,
1188,
29898,
29896,
511,
7442,
29889,
1188,
29898,
29945,
8243,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
13,
13,
13,
1990,
26596,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
26596,
5687,
29889,
13,
13,
1678,
26596,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
14013,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
4682,
29918,
1958,
29918,
8865,
449,
313,
1761,
29897,
584,
1293,
310,
16526,
1298,
1819,
29889,
13,
418,
1881,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
7934,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
671,
29918,
29890,
3173,
313,
1761,
29897,
584,
1293,
310,
7223,
1819,
29889,
13,
418,
3858,
29918,
3844,
29877,
6046,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
301,
29878,
29918,
7099,
388,
313,
7411,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
29880,
8337,
1388,
2396,
298,
29886,
29889,
1188,
29590,
877,
29880,
8337,
1388,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29896,
8243,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
29880,
8337,
1388,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29962,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
6652,
6857,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
6652,
6857,
5687,
29889,
13,
13,
1678,
6652,
6857,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
14013,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
4682,
29918,
1958,
29918,
8865,
449,
313,
1761,
29897,
584,
1293,
310,
16526,
1298,
1819,
29889,
13,
418,
1881,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
7934,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
671,
29918,
29890,
3173,
313,
1761,
29897,
584,
1293,
310,
7223,
1819,
29889,
13,
418,
3858,
29918,
3844,
29877,
6046,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
301,
29878,
29918,
7099,
388,
313,
7411,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
4478,
29918,
3493,
353,
426,
13,
3986,
525,
21891,
29918,
10492,
2396,
298,
29886,
29889,
1188,
29590,
877,
21891,
29918,
10492,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29896,
8243,
13,
3986,
525,
10892,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
10892,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29945,
29896,
29906,
511,
29896,
8243,
13,
3986,
525,
16175,
29918,
2311,
2396,
6874,
29889,
524,
29898,
28887,
29889,
29939,
1188,
29590,
877,
16175,
29918,
2311,
742,
7442,
29889,
1188,
29898,
29947,
511,
7442,
29889,
1188,
29898,
29946,
29900,
29929,
29953,
511,
29896,
8243,
13,
3986,
525,
29880,
8337,
1388,
2396,
298,
29886,
29889,
1188,
29590,
877,
29880,
8337,
1388,
742,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
511,
7442,
29889,
1188,
29898,
29900,
29889,
29900,
29900,
29896,
8243,
13,
3986,
525,
20640,
3950,
2396,
298,
29886,
29889,
16957,
877,
20640,
3950,
742,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
511,
13,
3986,
525,
1022,
2878,
29879,
2396,
298,
29886,
29889,
16957,
877,
1022,
2878,
29879,
742,
518,
29896,
29900,
2314,
396,
2337,
6755,
29871,
29896,
29900,
6694,
21502,
12168,
29889,
13,
4706,
500,
13,
4706,
396,
1583,
29889,
29880,
8337,
1388,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29962,
13,
4706,
396,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
396,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
396,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
396,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
396,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
396,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
323,
2707,
1001,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
323,
2707,
1001,
5687,
29889,
13,
13,
1678,
323,
2707,
1001,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
14013,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
4682,
29918,
1958,
29918,
8865,
449,
313,
1761,
29897,
584,
1293,
310,
16526,
1298,
1819,
29889,
13,
418,
1881,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
7934,
29918,
8865,
449,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
671,
29918,
29890,
3173,
313,
1761,
29897,
584,
1293,
310,
7223,
1819,
29889,
13,
418,
3858,
29918,
3844,
29877,
6046,
313,
1761,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
301,
29878,
29918,
7099,
388,
313,
7411,
29897,
584,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
29880,
8337,
1388,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29962,
13,
4706,
1583,
29889,
14394,
29918,
1958,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
2080,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
10892,
29918,
8865,
449,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
1509,
29918,
29890,
3173,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
1583,
29889,
1643,
29918,
3844,
29877,
6046,
353,
518,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29945,
29962,
13,
4706,
1583,
29889,
29212,
29918,
7099,
388,
353,
518,
29900,
29889,
29929,
29945,
29892,
29871,
29900,
29889,
29929,
29892,
29871,
29900,
29889,
29947,
29962,
13,
4706,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
13,
13,
1990,
4103,
29954,
9629,
29901,
13,
1678,
9995,
4013,
770,
17645,
278,
11266,
314,
2699,
322,
967,
20238,
363,
18515,
292,
4103,
29954,
5687,
29889,
13,
13,
1678,
4103,
29954,
9629,
17645,
599,
278,
6458,
295,
1819,
304,
367,
18515,
287,
363,
278,
5687,
29889,
4911,
1122,
13,
1678,
1735,
1438,
1819,
4153,
363,
15859,
278,
23041,
18970,
13883,
310,
278,
11266,
29899,
16744,
13,
13,
1678,
826,
3174,
29901,
13,
418,
6509,
29918,
10492,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
365,
29896,
29918,
15581,
313,
1761,
1125,
2391,
310,
7223,
1819,
29889,
13,
418,
7934,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
9853,
29918,
2311,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
21502,
12168,
313,
1761,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
5906,
313,
1761,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
5994,
3950,
313,
1761,
1125,
2391,
310,
6031,
16184,
278,
13883,
5687,
304,
367,
1304,
29889,
13,
418,
23460,
313,
1761,
1125,
2391,
310,
1347,
16184,
278,
23460,
304,
367,
1304,
363,
14655,
8178,
6455,
29889,
13,
418,
6694,
29918,
386,
12268,
313,
7411,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
302,
19594,
313,
524,
1125,
2391,
310,
6043,
1819,
29889,
13,
418,
15600,
29925,
29918,
19790,
313,
7411,
1125,
2391,
310,
16526,
1298,
1819,
29889,
13,
418,
7688,
29918,
12324,
313,
11227,
1125,
2391,
310,
7223,
1819,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
21891,
29918,
10492,
353,
518,
29900,
29889,
29900,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29896,
29962,
13,
4706,
1583,
29889,
29931,
29896,
29918,
15581,
353,
518,
5574,
29892,
7700,
29962,
13,
4706,
1583,
29889,
10892,
29918,
2311,
353,
518,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29892,
29871,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29962,
13,
4706,
1583,
29889,
16175,
29918,
2311,
353,
518,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29962,
13,
4706,
1583,
29889,
1022,
2878,
29879,
353,
518,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29900,
29962,
13,
4706,
1583,
29889,
9264,
353,
518,
29900,
29889,
29946,
29892,
29871,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29962,
13,
4706,
1583,
29889,
20640,
3950,
353,
6796,
328,
314,
613,
376,
5311,
29881,
613,
525,
29878,
1516,
2033,
13,
4706,
1583,
29889,
13445,
10335,
353,
6796,
29590,
613,
376,
5892,
3108,
13,
4706,
1583,
29889,
26495,
29918,
386,
12268,
353,
518,
29896,
29889,
29900,
29892,
29871,
29906,
29889,
29900,
29892,
29871,
29941,
29889,
29900,
29962,
13,
4706,
1583,
29889,
29876,
19594,
353,
518,
29941,
29892,
29871,
29946,
29892,
29871,
29945,
29892,
29871,
29953,
29892,
29871,
29955,
29962,
13,
4706,
1583,
29889,
11341,
29925,
29918,
19790,
353,
518,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
29945,
29892,
29871,
29900,
29889,
29896,
29962,
13,
4706,
1583,
29889,
7915,
29918,
12324,
353,
518,
5574,
29892,
7700,
29962,
13,
2
] |
test/test_segmentation.py | platybrowser/mobie-python | 1 | 85645 | import json
import os
import subprocess
import unittest
from shutil import rmtree
from sys import platform
import numpy as np
import pandas as pd
from elf.io import open_file
from pybdv.util import get_key
from mobie import add_image
from mobie.validation import validate_source_metadata
from mobie.metadata import read_dataset_metadata
class TestSegmentation(unittest.TestCase):
test_folder = './test-folder'
root = './test-folder/data'
shape = (128, 128, 128)
dataset_name = 'test'
def init_dataset(self):
data_path = os.path.join(self.test_folder, 'data.h5')
data_key = 'data'
with open_file(data_path, 'a') as f:
f.create_dataset(data_key, data=np.random.rand(*self.shape))
tmp_folder = os.path.join(self.test_folder, 'tmp-init')
raw_name = 'test-raw'
scales = [[2, 2, 2]]
add_image(data_path, data_key, self.root, self.dataset_name, raw_name,
resolution=(1, 1, 1), chunks=(64, 64, 64), scale_factors=scales,
tmp_folder=tmp_folder)
def setUp(self):
os.makedirs(self.test_folder, exist_ok=True)
self.init_dataset()
self.seg_path = os.path.join(self.test_folder, 'seg.h5')
self.seg_key = 'seg'
self.data = np.random.randint(0, 100, size=self.shape)
with open_file(self.seg_path, 'a') as f:
f.create_dataset(self.seg_key, data=self.data)
def tearDown(self):
try:
rmtree(self.test_folder)
except OSError:
pass
def check_segmentation(self, dataset_folder, name):
self.assertTrue(os.path.exists(dataset_folder))
exp_data = self.data
# check the segmentation metadata
metadata = read_dataset_metadata(dataset_folder)
self.assertIn(name, metadata['sources'])
validate_source_metadata(name, metadata['sources'][name], dataset_folder)
# check the segmentation data
seg_path = os.path.join(dataset_folder, 'images', 'bdv-n5', f'{name}.n5')
self.assertTrue(os.path.exists(seg_path))
key = get_key(False, 0, 0, 0)
with open_file(seg_path, 'r') as f:
data = f[key][:]
self.assertTrue(np.array_equal(data, exp_data))
# check the table
table_path = os.path.join(dataset_folder, 'tables', name, 'default.tsv')
self.assertTrue(os.path.exists(table_path)), table_path
table = pd.read_csv(table_path, sep='\t')
label_ids = table['label_id'].values
exp_label_ids = np.unique(data)
if 0 in exp_label_ids:
exp_label_ids = exp_label_ids[1:]
self.assertTrue(np.array_equal(label_ids, exp_label_ids))
def test_add_segmentation(self):
from mobie import add_segmentation
dataset_folder = os.path.join(self.root, self.dataset_name)
seg_name = 'seg'
tmp_folder = os.path.join(self.test_folder, 'tmp-seg')
scales = [[2, 2, 2]]
add_segmentation(self.seg_path, self.seg_key,
self.root, self.dataset_name, seg_name,
resolution=(1, 1, 1), scale_factors=scales,
chunks=(64, 64, 64), tmp_folder=tmp_folder)
self.check_segmentation(dataset_folder, seg_name)
@unittest.skipIf(platform == "win32", "CLI does not work on windows")
def test_cli(self):
seg_name = 'seg'
resolution = json.dumps([1., 1., 1.])
scales = json.dumps([[2, 2, 2]])
chunks = json.dumps([64, 64, 64])
tmp_folder = os.path.join(self.test_folder, 'tmp-seg')
cmd = ['mobie.add_segmentation',
'--input_path', self.seg_path,
'--input_key', self.seg_key,
'--root', self.root,
'--dataset_name', self.dataset_name,
'--name', seg_name,
'--resolution', resolution,
'--scale_factors', scales,
'--chunks', chunks,
'--tmp_folder', tmp_folder]
subprocess.run(cmd)
dataset_folder = os.path.join(self.root, self.dataset_name)
self.check_segmentation(dataset_folder, seg_name)
if __name__ == '__main__':
unittest.main()
| [
1,
1053,
4390,
13,
5215,
2897,
13,
5215,
1014,
5014,
13,
5215,
443,
27958,
13,
3166,
528,
4422,
1053,
364,
4378,
929,
13,
3166,
10876,
1053,
7481,
13,
13,
5215,
12655,
408,
7442,
13,
5215,
11701,
408,
10518,
13,
13,
3166,
560,
29888,
29889,
601,
1053,
1722,
29918,
1445,
13,
3166,
11451,
6448,
29894,
29889,
4422,
1053,
679,
29918,
1989,
13,
3166,
22458,
347,
1053,
788,
29918,
3027,
13,
3166,
22458,
347,
29889,
18157,
1053,
12725,
29918,
4993,
29918,
19635,
13,
3166,
22458,
347,
29889,
19635,
1053,
1303,
29918,
24713,
29918,
19635,
13,
13,
13,
1990,
4321,
17669,
358,
362,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
1678,
1243,
29918,
12083,
353,
19283,
1688,
29899,
12083,
29915,
13,
1678,
3876,
353,
19283,
1688,
29899,
12083,
29914,
1272,
29915,
13,
1678,
8267,
353,
313,
29896,
29906,
29947,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29896,
29906,
29947,
29897,
13,
1678,
8783,
29918,
978,
353,
525,
1688,
29915,
13,
13,
1678,
822,
2069,
29918,
24713,
29898,
1311,
1125,
13,
4706,
848,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
1688,
29918,
12083,
29892,
525,
1272,
29889,
29882,
29945,
1495,
13,
4706,
848,
29918,
1989,
353,
525,
1272,
29915,
13,
4706,
411,
1722,
29918,
1445,
29898,
1272,
29918,
2084,
29892,
525,
29874,
1495,
408,
285,
29901,
13,
9651,
285,
29889,
3258,
29918,
24713,
29898,
1272,
29918,
1989,
29892,
848,
29922,
9302,
29889,
8172,
29889,
9502,
10456,
1311,
29889,
12181,
876,
13,
13,
4706,
13128,
29918,
12083,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
1688,
29918,
12083,
29892,
525,
7050,
29899,
2344,
1495,
13,
13,
4706,
10650,
29918,
978,
353,
525,
1688,
29899,
1610,
29915,
13,
4706,
23431,
353,
5519,
29906,
29892,
29871,
29906,
29892,
29871,
29906,
5262,
13,
4706,
788,
29918,
3027,
29898,
1272,
29918,
2084,
29892,
848,
29918,
1989,
29892,
1583,
29889,
4632,
29892,
1583,
29889,
24713,
29918,
978,
29892,
10650,
29918,
978,
29892,
13,
462,
29871,
10104,
7607,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
511,
521,
18801,
7607,
29953,
29946,
29892,
29871,
29953,
29946,
29892,
29871,
29953,
29946,
511,
6287,
29918,
17028,
943,
29922,
19529,
267,
29892,
13,
462,
29871,
13128,
29918,
12083,
29922,
7050,
29918,
12083,
29897,
13,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
2897,
29889,
29885,
12535,
12935,
29898,
1311,
29889,
1688,
29918,
12083,
29892,
1863,
29918,
554,
29922,
5574,
29897,
13,
4706,
1583,
29889,
2344,
29918,
24713,
580,
13,
13,
4706,
1583,
29889,
10199,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
1688,
29918,
12083,
29892,
525,
10199,
29889,
29882,
29945,
1495,
13,
4706,
1583,
29889,
10199,
29918,
1989,
353,
525,
10199,
29915,
13,
4706,
1583,
29889,
1272,
353,
7442,
29889,
8172,
29889,
9502,
524,
29898,
29900,
29892,
29871,
29896,
29900,
29900,
29892,
2159,
29922,
1311,
29889,
12181,
29897,
13,
4706,
411,
1722,
29918,
1445,
29898,
1311,
29889,
10199,
29918,
2084,
29892,
525,
29874,
1495,
408,
285,
29901,
13,
9651,
285,
29889,
3258,
29918,
24713,
29898,
1311,
29889,
10199,
29918,
1989,
29892,
848,
29922,
1311,
29889,
1272,
29897,
13,
13,
1678,
822,
734,
279,
6767,
29898,
1311,
1125,
13,
4706,
1018,
29901,
13,
9651,
364,
4378,
929,
29898,
1311,
29889,
1688,
29918,
12083,
29897,
13,
4706,
5174,
438,
29173,
29901,
13,
9651,
1209,
13,
13,
1678,
822,
1423,
29918,
28192,
362,
29898,
1311,
29892,
8783,
29918,
12083,
29892,
1024,
1125,
13,
4706,
1583,
29889,
9294,
5574,
29898,
359,
29889,
2084,
29889,
9933,
29898,
24713,
29918,
12083,
876,
13,
4706,
1518,
29918,
1272,
353,
1583,
29889,
1272,
13,
13,
4706,
396,
1423,
278,
10768,
362,
15562,
13,
4706,
15562,
353,
1303,
29918,
24713,
29918,
19635,
29898,
24713,
29918,
12083,
29897,
13,
4706,
1583,
29889,
9294,
797,
29898,
978,
29892,
15562,
1839,
29879,
2863,
11287,
13,
4706,
12725,
29918,
4993,
29918,
19635,
29898,
978,
29892,
15562,
1839,
29879,
2863,
2033,
29961,
978,
1402,
8783,
29918,
12083,
29897,
13,
13,
4706,
396,
1423,
278,
10768,
362,
848,
13,
4706,
2377,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
24713,
29918,
12083,
29892,
525,
8346,
742,
525,
6448,
29894,
29899,
29876,
29945,
742,
285,
29915,
29912,
978,
1836,
29876,
29945,
1495,
13,
4706,
1583,
29889,
9294,
5574,
29898,
359,
29889,
2084,
29889,
9933,
29898,
10199,
29918,
2084,
876,
13,
4706,
1820,
353,
679,
29918,
1989,
29898,
8824,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29897,
13,
4706,
411,
1722,
29918,
1445,
29898,
10199,
29918,
2084,
29892,
525,
29878,
1495,
408,
285,
29901,
13,
9651,
848,
353,
285,
29961,
1989,
3816,
17531,
13,
4706,
1583,
29889,
9294,
5574,
29898,
9302,
29889,
2378,
29918,
11745,
29898,
1272,
29892,
1518,
29918,
1272,
876,
13,
13,
4706,
396,
1423,
278,
1591,
13,
4706,
1591,
29918,
2084,
353,
2897,
29889,
2084,
29889,
7122,
29898,
24713,
29918,
12083,
29892,
525,
24051,
742,
1024,
29892,
525,
4381,
29889,
1372,
29894,
1495,
13,
4706,
1583,
29889,
9294,
5574,
29898,
359,
29889,
2084,
29889,
9933,
29898,
2371,
29918,
2084,
8243,
1591,
29918,
2084,
13,
4706,
1591,
353,
10518,
29889,
949,
29918,
7638,
29898,
2371,
29918,
2084,
29892,
16345,
2433,
29905,
29873,
1495,
13,
13,
4706,
3858,
29918,
4841,
353,
1591,
1839,
1643,
29918,
333,
13359,
5975,
13,
4706,
1518,
29918,
1643,
29918,
4841,
353,
7442,
29889,
13092,
29898,
1272,
29897,
13,
4706,
565,
29871,
29900,
297,
1518,
29918,
1643,
29918,
4841,
29901,
13,
9651,
1518,
29918,
1643,
29918,
4841,
353,
1518,
29918,
1643,
29918,
4841,
29961,
29896,
17531,
13,
4706,
1583,
29889,
9294,
5574,
29898,
9302,
29889,
2378,
29918,
11745,
29898,
1643,
29918,
4841,
29892,
1518,
29918,
1643,
29918,
4841,
876,
13,
13,
1678,
822,
1243,
29918,
1202,
29918,
28192,
362,
29898,
1311,
1125,
13,
4706,
515,
22458,
347,
1053,
788,
29918,
28192,
362,
13,
4706,
8783,
29918,
12083,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
4632,
29892,
1583,
29889,
24713,
29918,
978,
29897,
13,
4706,
2377,
29918,
978,
353,
525,
10199,
29915,
13,
13,
4706,
13128,
29918,
12083,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
1688,
29918,
12083,
29892,
525,
7050,
29899,
10199,
1495,
13,
13,
4706,
23431,
353,
5519,
29906,
29892,
29871,
29906,
29892,
29871,
29906,
5262,
13,
4706,
788,
29918,
28192,
362,
29898,
1311,
29889,
10199,
29918,
2084,
29892,
1583,
29889,
10199,
29918,
1989,
29892,
13,
462,
308,
1583,
29889,
4632,
29892,
1583,
29889,
24713,
29918,
978,
29892,
2377,
29918,
978,
29892,
13,
462,
308,
10104,
7607,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
511,
6287,
29918,
17028,
943,
29922,
19529,
267,
29892,
13,
462,
308,
521,
18801,
7607,
29953,
29946,
29892,
29871,
29953,
29946,
29892,
29871,
29953,
29946,
511,
13128,
29918,
12083,
29922,
7050,
29918,
12083,
29897,
13,
4706,
1583,
29889,
3198,
29918,
28192,
362,
29898,
24713,
29918,
12083,
29892,
2377,
29918,
978,
29897,
13,
13,
1678,
732,
348,
27958,
29889,
11014,
3644,
29898,
12120,
1275,
376,
5080,
29941,
29906,
613,
376,
27205,
947,
451,
664,
373,
5417,
1159,
13,
1678,
822,
1243,
29918,
11303,
29898,
1311,
1125,
13,
4706,
2377,
29918,
978,
353,
525,
10199,
29915,
13,
13,
4706,
10104,
353,
4390,
29889,
29881,
17204,
4197,
29896,
1696,
29871,
29896,
1696,
29871,
29896,
29889,
2314,
13,
4706,
23431,
353,
4390,
29889,
29881,
17204,
4197,
29961,
29906,
29892,
29871,
29906,
29892,
29871,
29906,
24960,
13,
4706,
521,
18801,
353,
4390,
29889,
29881,
17204,
4197,
29953,
29946,
29892,
29871,
29953,
29946,
29892,
29871,
29953,
29946,
2314,
13,
13,
4706,
13128,
29918,
12083,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
1688,
29918,
12083,
29892,
525,
7050,
29899,
10199,
1495,
13,
13,
4706,
9920,
353,
6024,
29885,
711,
347,
29889,
1202,
29918,
28192,
362,
742,
13,
1669,
525,
489,
2080,
29918,
2084,
742,
1583,
29889,
10199,
29918,
2084,
29892,
13,
1669,
525,
489,
2080,
29918,
1989,
742,
1583,
29889,
10199,
29918,
1989,
29892,
13,
1669,
525,
489,
4632,
742,
1583,
29889,
4632,
29892,
13,
1669,
525,
489,
24713,
29918,
978,
742,
1583,
29889,
24713,
29918,
978,
29892,
13,
1669,
525,
489,
978,
742,
2377,
29918,
978,
29892,
13,
1669,
525,
489,
9778,
918,
742,
10104,
29892,
13,
1669,
525,
489,
7052,
29918,
17028,
943,
742,
23431,
29892,
13,
1669,
525,
489,
305,
18801,
742,
521,
18801,
29892,
13,
1669,
525,
489,
7050,
29918,
12083,
742,
13128,
29918,
12083,
29962,
13,
4706,
1014,
5014,
29889,
3389,
29898,
9006,
29897,
13,
13,
4706,
8783,
29918,
12083,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
4632,
29892,
1583,
29889,
24713,
29918,
978,
29897,
13,
4706,
1583,
29889,
3198,
29918,
28192,
362,
29898,
24713,
29918,
12083,
29892,
2377,
29918,
978,
29897,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
443,
27958,
29889,
3396,
580,
13,
2
] |
pyano2/apps.py | mental689/pyano | 1 | 8019 | from django.apps import AppConfig
class Pyano2Config(AppConfig):
name = 'pyano2'
| [
1,
515,
9557,
29889,
13371,
1053,
2401,
3991,
13,
13,
13,
1990,
10772,
1562,
29906,
3991,
29898,
2052,
3991,
1125,
13,
1678,
1024,
353,
525,
2272,
1562,
29906,
29915,
13,
2
] |
utils/tools.py | alipay/Pyraformer | 7 | 16626 | <filename>utils/tools.py
from torch.nn.modules import loss
import torch
import numpy as np
def MAE(pred, true):
return np.mean(np.abs(pred-true))
def MSE(pred, true):
return np.mean((pred-true)**2)
def RMSE(pred, true):
return np.sqrt(MSE(pred, true))
def MAPE(pred, true):
return np.mean(np.abs((pred - true) / true))
def MSPE(pred, true):
return np.mean(np.square((pred - true) / true))
def metric(pred, true):
mae = MAE(pred, true)
mse = MSE(pred, true)
rmse = RMSE(pred, true)
mape = MAPE(pred, true)
mspe = MSPE(pred, true)
return mae,mse,rmse,mape,mspe
class StandardScaler():
def __init__(self):
self.mean = 0.
self.std = 1.
def fit(self, data):
self.mean = data.mean(0)
self.std = data.std(0)
def transform(self, data):
mean = torch.from_numpy(self.mean).type_as(data).to(data.device) if torch.is_tensor(data) else self.mean
std = torch.from_numpy(self.std).type_as(data).to(data.device) if torch.is_tensor(data) else self.std
return (data - mean) / std
def inverse_transform(self, data):
mean = torch.from_numpy(self.mean).type_as(data).to(data.device) if torch.is_tensor(data) else self.mean
std = torch.from_numpy(self.std).type_as(data).to(data.device) if torch.is_tensor(data) else self.std
return (data * std) + mean
class TopkMSELoss(torch.nn.Module):
def __init__(self, topk) -> None:
super().__init__()
self.topk = topk
self.criterion = torch.nn.MSELoss(reduction='none')
def forward(self, output, label):
losses = self.criterion(output, label).mean(2).mean(1)
losses = torch.topk(losses, self.topk)[0]
return losses
class SingleStepLoss(torch.nn.Module):
""" Compute top-k log-likelihood and mse. """
def __init__(self, ignore_zero):
super().__init__()
self.ignore_zero = ignore_zero
def forward(self, mu, sigma, labels, topk=0):
if self.ignore_zero:
indexes = (labels != 0)
else:
indexes = (labels >= 0)
distribution = torch.distributions.normal.Normal(mu[indexes], sigma[indexes])
likelihood = -distribution.log_prob(labels[indexes])
diff = labels[indexes] - mu[indexes]
se = diff * diff
if 0 < topk < len(likelihood):
likelihood = torch.topk(likelihood, topk)[0]
se = torch.topk(se, topk)[0]
return likelihood, se
def AE_loss(mu, labels, ignore_zero):
if ignore_zero:
indexes = (labels != 0)
else:
indexes = (labels >= 0)
ae = torch.abs(labels[indexes] - mu[indexes])
return ae
| [
1,
529,
9507,
29958,
13239,
29914,
8504,
29889,
2272,
13,
3166,
4842,
305,
29889,
15755,
29889,
7576,
1053,
6410,
13,
5215,
4842,
305,
13,
5215,
12655,
408,
7442,
13,
13,
13,
1753,
14861,
29923,
29898,
11965,
29892,
1565,
1125,
13,
1678,
736,
7442,
29889,
12676,
29898,
9302,
29889,
6897,
29898,
11965,
29899,
3009,
876,
13,
13,
1753,
341,
1660,
29898,
11965,
29892,
1565,
1125,
13,
1678,
736,
7442,
29889,
12676,
3552,
11965,
29899,
3009,
29897,
1068,
29906,
29897,
13,
13,
1753,
390,
29924,
1660,
29898,
11965,
29892,
1565,
1125,
13,
1678,
736,
7442,
29889,
3676,
29898,
29924,
1660,
29898,
11965,
29892,
1565,
876,
13,
13,
1753,
341,
3301,
29923,
29898,
11965,
29892,
1565,
1125,
13,
1678,
736,
7442,
29889,
12676,
29898,
9302,
29889,
6897,
3552,
11965,
448,
1565,
29897,
847,
1565,
876,
13,
13,
1753,
10888,
4162,
29898,
11965,
29892,
1565,
1125,
13,
1678,
736,
7442,
29889,
12676,
29898,
9302,
29889,
17619,
3552,
11965,
448,
1565,
29897,
847,
1565,
876,
13,
13,
1753,
12714,
29898,
11965,
29892,
1565,
1125,
13,
1678,
611,
29872,
353,
14861,
29923,
29898,
11965,
29892,
1565,
29897,
13,
1678,
286,
344,
353,
341,
1660,
29898,
11965,
29892,
1565,
29897,
13,
1678,
20241,
344,
353,
390,
29924,
1660,
29898,
11965,
29892,
1565,
29897,
13,
1678,
611,
412,
353,
341,
3301,
29923,
29898,
11965,
29892,
1565,
29897,
13,
1678,
286,
5965,
353,
10888,
4162,
29898,
11965,
29892,
1565,
29897,
13,
13,
1678,
736,
611,
29872,
29892,
29885,
344,
29892,
1758,
344,
29892,
655,
412,
29892,
1516,
412,
13,
13,
1990,
10117,
29636,
261,
7295,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
12676,
353,
29871,
29900,
29889,
13,
4706,
1583,
29889,
4172,
353,
29871,
29896,
29889,
13,
13,
1678,
822,
6216,
29898,
1311,
29892,
848,
1125,
13,
4706,
1583,
29889,
12676,
353,
848,
29889,
12676,
29898,
29900,
29897,
13,
4706,
1583,
29889,
4172,
353,
848,
29889,
4172,
29898,
29900,
29897,
13,
13,
1678,
822,
4327,
29898,
1311,
29892,
848,
1125,
13,
4706,
2099,
353,
4842,
305,
29889,
3166,
29918,
23749,
29898,
1311,
29889,
12676,
467,
1853,
29918,
294,
29898,
1272,
467,
517,
29898,
1272,
29889,
10141,
29897,
565,
4842,
305,
29889,
275,
29918,
20158,
29898,
1272,
29897,
1683,
1583,
29889,
12676,
13,
4706,
3659,
353,
4842,
305,
29889,
3166,
29918,
23749,
29898,
1311,
29889,
4172,
467,
1853,
29918,
294,
29898,
1272,
467,
517,
29898,
1272,
29889,
10141,
29897,
565,
4842,
305,
29889,
275,
29918,
20158,
29898,
1272,
29897,
1683,
1583,
29889,
4172,
13,
4706,
736,
313,
1272,
448,
2099,
29897,
847,
3659,
13,
13,
1678,
822,
16402,
29918,
9067,
29898,
1311,
29892,
848,
1125,
13,
4706,
2099,
353,
4842,
305,
29889,
3166,
29918,
23749,
29898,
1311,
29889,
12676,
467,
1853,
29918,
294,
29898,
1272,
467,
517,
29898,
1272,
29889,
10141,
29897,
565,
4842,
305,
29889,
275,
29918,
20158,
29898,
1272,
29897,
1683,
1583,
29889,
12676,
13,
4706,
3659,
353,
4842,
305,
29889,
3166,
29918,
23749,
29898,
1311,
29889,
4172,
467,
1853,
29918,
294,
29898,
1272,
467,
517,
29898,
1272,
29889,
10141,
29897,
565,
4842,
305,
29889,
275,
29918,
20158,
29898,
1272,
29897,
1683,
1583,
29889,
4172,
13,
4706,
736,
313,
1272,
334,
3659,
29897,
718,
2099,
13,
13,
1990,
7488,
29895,
29924,
1660,
29931,
2209,
29898,
7345,
305,
29889,
15755,
29889,
7355,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
2246,
29895,
29897,
1599,
6213,
29901,
13,
4706,
2428,
2141,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
3332,
29895,
353,
2246,
29895,
13,
4706,
1583,
29889,
29883,
5385,
291,
353,
4842,
305,
29889,
15755,
29889,
29924,
1660,
29931,
2209,
29898,
9313,
428,
2433,
9290,
1495,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
1962,
29892,
3858,
1125,
13,
4706,
28495,
353,
1583,
29889,
29883,
5385,
291,
29898,
4905,
29892,
3858,
467,
12676,
29898,
29906,
467,
12676,
29898,
29896,
29897,
13,
4706,
28495,
353,
4842,
305,
29889,
3332,
29895,
29898,
6758,
267,
29892,
1583,
29889,
3332,
29895,
9601,
29900,
29962,
13,
13,
4706,
736,
28495,
13,
13,
1990,
16740,
14448,
29931,
2209,
29898,
7345,
305,
29889,
15755,
29889,
7355,
1125,
13,
1678,
9995,
11796,
29872,
2246,
29899,
29895,
1480,
29899,
5081,
22342,
322,
286,
344,
29889,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
11455,
29918,
9171,
1125,
13,
4706,
2428,
2141,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
17281,
29918,
9171,
353,
11455,
29918,
9171,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
3887,
29892,
269,
2934,
29892,
11073,
29892,
2246,
29895,
29922,
29900,
1125,
13,
4706,
565,
1583,
29889,
17281,
29918,
9171,
29901,
13,
9651,
18111,
353,
313,
21134,
2804,
29871,
29900,
29897,
13,
4706,
1683,
29901,
13,
9651,
18111,
353,
313,
21134,
6736,
29871,
29900,
29897,
13,
13,
4706,
4978,
353,
4842,
305,
29889,
27691,
29879,
29889,
8945,
29889,
19077,
29898,
2589,
29961,
2248,
267,
1402,
269,
2934,
29961,
2248,
267,
2314,
13,
4706,
4188,
22342,
353,
448,
27691,
29889,
1188,
29918,
22795,
29898,
21134,
29961,
2248,
267,
2314,
13,
13,
4706,
2923,
353,
11073,
29961,
2248,
267,
29962,
448,
3887,
29961,
2248,
267,
29962,
13,
4706,
409,
353,
2923,
334,
2923,
13,
13,
4706,
565,
29871,
29900,
529,
2246,
29895,
529,
7431,
29898,
5081,
22342,
1125,
13,
9651,
4188,
22342,
353,
4842,
305,
29889,
3332,
29895,
29898,
5081,
22342,
29892,
2246,
29895,
9601,
29900,
29962,
13,
9651,
409,
353,
4842,
305,
29889,
3332,
29895,
29898,
344,
29892,
2246,
29895,
9601,
29900,
29962,
13,
13,
4706,
736,
4188,
22342,
29892,
409,
13,
13,
1753,
319,
29923,
29918,
6758,
29898,
2589,
29892,
11073,
29892,
11455,
29918,
9171,
1125,
13,
1678,
565,
11455,
29918,
9171,
29901,
13,
4706,
18111,
353,
313,
21134,
2804,
29871,
29900,
29897,
13,
1678,
1683,
29901,
13,
4706,
18111,
353,
313,
21134,
6736,
29871,
29900,
29897,
13,
13,
1678,
263,
29872,
353,
4842,
305,
29889,
6897,
29898,
21134,
29961,
2248,
267,
29962,
448,
3887,
29961,
2248,
267,
2314,
13,
1678,
736,
263,
29872,
13,
2
] |
cowait/tasks/definition.py | ProgHaj/cowait | 0 | 143170 | <filename>cowait/tasks/definition.py<gh_stars>0
from __future__ import annotations
from datetime import datetime, timezone
from marshmallow import Schema, fields, post_load
from ..utils import uuid
def generate_task_id(name: str) -> str:
if '.' in name:
dot = name.rfind('.')
name = name[dot+1:]
name = name.replace('.', '-')
name = name.replace('_', '-')
return '%s-%s' % (name.lower(), uuid())
class TaskDefinition(object):
"""
Defines a Task :)
Attributes:
name (str): Task import name.
image (str): Task image.
id (str): Task id. If None, an id will be autogenerated.
upstream (str): Upstream connection string. Defaults to None.
inputs (dict): Input values
meta (dict): Freeform metadata
env (dict): Environment variables
ports (dict): Port forwards
routes (dict): HTTP Ingresses
volumes (dict): List of volumes
cpu (str): CPU request
cpu_limit (str): CPU limit
memory (str): Memory request
memory_limit (str): Memory limit
owner (str): Owner name
created_at (DateTime): Creation date
"""
def __init__(
self,
name: str,
image: str,
id: str = None,
upstream: str = None,
parent: str = None,
inputs: dict = {},
meta: dict = {},
env: dict = {},
ports: dict = {},
routes: dict = {},
volumes: dict = {},
storage: dict = {},
cpu: str = None,
cpu_limit: str = None,
memory: str = None,
memory_limit: str = None,
owner: str = '',
created_at: datetime = None,
):
"""
Arguments:
name (str): Task import name.
image (str): Task image.
id (str): Task id. If None, an id will be autogenerated.
upstream (str): Upstream connection string. Defaults to None.
inputs (dict): Input values
meta (dict): Freeform metadata
env (dict): Environment variables
ports (dict): Port forwards
routes (dict): HTTP Ingresses
volumes (dict): List of volumes
cpu (str): CPU request
cpu_limit (str): CPU limit
memory (str): Memory request
memory_limit (str): Memory limit
owner (str): Owner name
created_at (DateTime): Creation date
"""
self.id = generate_task_id(name) if id is None else id
self.name = name
self.image = image
self.parent = parent
self.upstream = upstream
self.inputs = inputs
self.meta = meta
self.env = {str(k): str(v) for k, v in env.items()}
self.ports = ports
self.routes = routes
self.cpu = cpu
self.cpu_limit = cpu_limit
self.memory = memory
self.memory_limit = memory_limit
self.owner = owner
self.volumes = volumes
self.storage = storage
if created_at is None:
self.created_at = datetime.now(timezone.utc)
elif isinstance(created_at, datetime):
self.created_at = created_at
elif isinstance(created_at, str):
self.created_at = datetime.fromisoformat(created_at)
else:
raise TypeError(f'Expected created_at to be None or datetime, got {created_at}')
def serialize(self) -> dict:
""" Serialize task definition to a dict """
return TaskDefinitionSchema().dump(self)
@staticmethod
def deserialize(taskdef: dict) -> TaskDefinition:
""" Deserialize task definition from a dict """
return TaskDefinitionSchema().load(taskdef)
class TaskDefinitionSchema(Schema):
""" TaskDefinition serialization schema. """
id = fields.Str(required=True)
name = fields.Str(required=True)
image = fields.Str(required=True)
upstream = fields.Str(allow_none=True)
parent = fields.Str(allow_none=True)
inputs = fields.Dict(missing={})
meta = fields.Dict(missing={})
env = fields.Dict(missing={})
ports = fields.Dict(missing={})
routes = fields.Dict(missing={})
cpu = fields.Str(allow_none=True)
cpu_limit = fields.Str(allow_none=True)
memory = fields.Str(allow_none=True)
memory_limit = fields.Str(allow_none=True)
owner = fields.Str(missing='')
created_at = fields.DateTime('iso', default=lambda: datetime.now(timezone.utc))
storage = fields.Dict(missing={})
volumes = fields.Mapping(
keys=fields.Str(),
values=fields.Mapping(),
missing={}
)
@post_load
def make_class(self, data: dict, **kwargs):
return self.make_instance(data)
def make_instance(self, data: dict) -> TaskDefinition:
return TaskDefinition(**data)
| [
1,
529,
9507,
29958,
20587,
1249,
29914,
20673,
29914,
16553,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
4770,
29888,
9130,
1649,
1053,
25495,
13,
3166,
12865,
1053,
12865,
29892,
29431,
13,
3166,
1766,
845,
29885,
9536,
1053,
1102,
2603,
29892,
4235,
29892,
1400,
29918,
1359,
13,
3166,
6317,
13239,
1053,
318,
5416,
13,
13,
13,
1753,
5706,
29918,
7662,
29918,
333,
29898,
978,
29901,
851,
29897,
1599,
851,
29901,
13,
1678,
565,
525,
6169,
297,
1024,
29901,
13,
4706,
8329,
353,
1024,
29889,
29878,
2886,
12839,
1495,
13,
4706,
1024,
353,
1024,
29961,
6333,
29974,
29896,
17531,
13,
13,
1678,
1024,
353,
1024,
29889,
6506,
12839,
742,
17411,
1495,
13,
1678,
1024,
353,
1024,
29889,
6506,
877,
29918,
742,
17411,
1495,
13,
13,
1678,
736,
14210,
29879,
19222,
29879,
29915,
1273,
313,
978,
29889,
13609,
3285,
318,
5416,
3101,
13,
13,
13,
1990,
9330,
14683,
29898,
3318,
1125,
13,
1678,
9995,
13,
1678,
5282,
1475,
263,
9330,
4248,
13,
13,
1678,
6212,
5026,
29901,
13,
4706,
1024,
313,
710,
1125,
9330,
1053,
1024,
29889,
13,
4706,
1967,
313,
710,
1125,
9330,
1967,
29889,
13,
4706,
1178,
313,
710,
1125,
9330,
1178,
29889,
960,
6213,
29892,
385,
1178,
674,
367,
1120,
468,
759,
630,
29889,
13,
4706,
701,
5461,
313,
710,
1125,
5020,
5461,
3957,
1347,
29889,
13109,
29879,
304,
6213,
29889,
13,
4706,
10970,
313,
8977,
1125,
10567,
1819,
13,
4706,
12700,
313,
8977,
1125,
12362,
689,
15562,
13,
4706,
8829,
313,
8977,
1125,
16738,
3651,
13,
4706,
16169,
313,
8977,
1125,
3371,
363,
2935,
13,
4706,
12049,
313,
8977,
1125,
7331,
512,
3663,
267,
13,
4706,
18167,
313,
8977,
1125,
2391,
310,
18167,
13,
4706,
26403,
313,
710,
1125,
10808,
2009,
13,
4706,
26403,
29918,
13400,
313,
710,
1125,
10808,
4046,
13,
4706,
3370,
313,
710,
1125,
18914,
2009,
13,
4706,
3370,
29918,
13400,
313,
710,
1125,
18914,
4046,
13,
4706,
12271,
313,
710,
1125,
438,
23007,
1024,
13,
4706,
2825,
29918,
271,
313,
11384,
1125,
6760,
362,
2635,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
13,
4706,
1583,
29892,
13,
4706,
1024,
29901,
308,
851,
29892,
13,
4706,
1967,
29901,
4706,
851,
29892,
13,
4706,
1178,
29901,
965,
851,
353,
6213,
29892,
13,
4706,
701,
5461,
29901,
268,
851,
353,
6213,
29892,
13,
4706,
3847,
29901,
539,
851,
353,
6213,
29892,
13,
4706,
10970,
29901,
539,
9657,
353,
24335,
13,
4706,
12700,
29901,
308,
9657,
353,
24335,
13,
4706,
8829,
29901,
3986,
9657,
353,
24335,
13,
4706,
16169,
29901,
4706,
9657,
353,
24335,
13,
4706,
12049,
29901,
539,
9657,
353,
24335,
13,
4706,
18167,
29901,
418,
9657,
353,
24335,
13,
4706,
8635,
29901,
418,
9657,
353,
24335,
13,
4706,
26403,
29901,
3986,
851,
353,
6213,
29892,
13,
4706,
26403,
29918,
13400,
29901,
1678,
851,
353,
6213,
29892,
13,
4706,
3370,
29901,
539,
851,
353,
6213,
29892,
13,
4706,
3370,
29918,
13400,
29901,
851,
353,
6213,
29892,
13,
4706,
12271,
29901,
4706,
851,
353,
15516,
13,
4706,
2825,
29918,
271,
29901,
259,
12865,
353,
6213,
29892,
13,
268,
1125,
13,
4706,
9995,
13,
4706,
11842,
9331,
29901,
13,
9651,
1024,
313,
710,
1125,
9330,
1053,
1024,
29889,
13,
9651,
1967,
313,
710,
1125,
9330,
1967,
29889,
13,
9651,
1178,
313,
710,
1125,
9330,
1178,
29889,
960,
6213,
29892,
385,
1178,
674,
367,
1120,
468,
759,
630,
29889,
13,
9651,
701,
5461,
313,
710,
1125,
5020,
5461,
3957,
1347,
29889,
13109,
29879,
304,
6213,
29889,
13,
9651,
10970,
313,
8977,
1125,
10567,
1819,
13,
9651,
12700,
313,
8977,
1125,
12362,
689,
15562,
13,
9651,
8829,
313,
8977,
1125,
16738,
3651,
13,
9651,
16169,
313,
8977,
1125,
3371,
363,
2935,
13,
9651,
12049,
313,
8977,
1125,
7331,
512,
3663,
267,
13,
9651,
18167,
313,
8977,
1125,
2391,
310,
18167,
13,
9651,
26403,
313,
710,
1125,
10808,
2009,
13,
9651,
26403,
29918,
13400,
313,
710,
1125,
10808,
4046,
13,
9651,
3370,
313,
710,
1125,
18914,
2009,
13,
9651,
3370,
29918,
13400,
313,
710,
1125,
18914,
4046,
13,
9651,
12271,
313,
710,
1125,
438,
23007,
1024,
13,
9651,
2825,
29918,
271,
313,
11384,
1125,
6760,
362,
2635,
13,
4706,
9995,
13,
4706,
1583,
29889,
333,
353,
5706,
29918,
7662,
29918,
333,
29898,
978,
29897,
565,
1178,
338,
6213,
1683,
1178,
13,
4706,
1583,
29889,
978,
353,
1024,
13,
4706,
1583,
29889,
3027,
353,
1967,
13,
4706,
1583,
29889,
3560,
353,
3847,
13,
4706,
1583,
29889,
786,
5461,
353,
701,
5461,
13,
4706,
1583,
29889,
2080,
29879,
353,
10970,
13,
4706,
1583,
29889,
7299,
353,
12700,
13,
4706,
1583,
29889,
6272,
353,
426,
710,
29898,
29895,
1125,
851,
29898,
29894,
29897,
363,
413,
29892,
325,
297,
8829,
29889,
7076,
28296,
13,
4706,
1583,
29889,
4011,
353,
16169,
13,
4706,
1583,
29889,
27894,
353,
12049,
13,
4706,
1583,
29889,
21970,
353,
26403,
13,
4706,
1583,
29889,
21970,
29918,
13400,
353,
26403,
29918,
13400,
13,
4706,
1583,
29889,
14834,
353,
3370,
13,
4706,
1583,
29889,
14834,
29918,
13400,
353,
3370,
29918,
13400,
13,
4706,
1583,
29889,
20348,
353,
12271,
13,
4706,
1583,
29889,
1555,
9351,
353,
18167,
13,
4706,
1583,
29889,
12925,
353,
8635,
13,
13,
4706,
565,
2825,
29918,
271,
338,
6213,
29901,
13,
9651,
1583,
29889,
11600,
29918,
271,
353,
12865,
29889,
3707,
29898,
2230,
8028,
29889,
329,
29883,
29897,
13,
4706,
25342,
338,
8758,
29898,
11600,
29918,
271,
29892,
12865,
1125,
13,
9651,
1583,
29889,
11600,
29918,
271,
353,
2825,
29918,
271,
13,
4706,
25342,
338,
8758,
29898,
11600,
29918,
271,
29892,
851,
1125,
13,
9651,
1583,
29889,
11600,
29918,
271,
353,
12865,
29889,
3166,
10718,
4830,
29898,
11600,
29918,
271,
29897,
13,
4706,
1683,
29901,
13,
9651,
12020,
20948,
29898,
29888,
29915,
1252,
6021,
2825,
29918,
271,
304,
367,
6213,
470,
12865,
29892,
2355,
426,
11600,
29918,
271,
29913,
1495,
13,
13,
1678,
822,
28755,
29898,
1311,
29897,
1599,
9657,
29901,
13,
4706,
9995,
1816,
6646,
3414,
5023,
304,
263,
9657,
9995,
13,
4706,
736,
9330,
14683,
12763,
2141,
15070,
29898,
1311,
29897,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
16964,
6646,
29898,
7662,
1753,
29901,
9657,
29897,
1599,
9330,
14683,
29901,
13,
4706,
9995,
2726,
261,
6646,
3414,
5023,
515,
263,
9657,
9995,
13,
4706,
736,
9330,
14683,
12763,
2141,
1359,
29898,
7662,
1753,
29897,
13,
13,
13,
1990,
9330,
14683,
12763,
29898,
12763,
1125,
13,
1678,
9995,
9330,
14683,
7797,
2133,
10938,
29889,
9995,
13,
13,
1678,
1178,
353,
4235,
29889,
5015,
29898,
12403,
29922,
5574,
29897,
13,
1678,
1024,
353,
4235,
29889,
5015,
29898,
12403,
29922,
5574,
29897,
13,
1678,
1967,
353,
4235,
29889,
5015,
29898,
12403,
29922,
5574,
29897,
13,
1678,
701,
5461,
353,
4235,
29889,
5015,
29898,
9536,
29918,
9290,
29922,
5574,
29897,
13,
1678,
3847,
353,
4235,
29889,
5015,
29898,
9536,
29918,
9290,
29922,
5574,
29897,
13,
1678,
10970,
353,
4235,
29889,
21533,
29898,
27259,
3790,
1800,
13,
1678,
12700,
353,
4235,
29889,
21533,
29898,
27259,
3790,
1800,
13,
1678,
8829,
353,
4235,
29889,
21533,
29898,
27259,
3790,
1800,
13,
1678,
16169,
353,
4235,
29889,
21533,
29898,
27259,
3790,
1800,
13,
1678,
12049,
353,
4235,
29889,
21533,
29898,
27259,
3790,
1800,
13,
1678,
26403,
353,
4235,
29889,
5015,
29898,
9536,
29918,
9290,
29922,
5574,
29897,
13,
1678,
26403,
29918,
13400,
353,
4235,
29889,
5015,
29898,
9536,
29918,
9290,
29922,
5574,
29897,
13,
1678,
3370,
353,
4235,
29889,
5015,
29898,
9536,
29918,
9290,
29922,
5574,
29897,
13,
1678,
3370,
29918,
13400,
353,
4235,
29889,
5015,
29898,
9536,
29918,
9290,
29922,
5574,
29897,
13,
1678,
12271,
353,
4235,
29889,
5015,
29898,
27259,
2433,
1495,
13,
1678,
2825,
29918,
271,
353,
4235,
29889,
11384,
877,
10718,
742,
2322,
29922,
2892,
29901,
12865,
29889,
3707,
29898,
2230,
8028,
29889,
329,
29883,
876,
13,
1678,
8635,
353,
4235,
29889,
21533,
29898,
27259,
3790,
1800,
13,
1678,
18167,
353,
4235,
29889,
15845,
29898,
13,
4706,
6611,
29922,
9621,
29889,
5015,
3285,
13,
4706,
1819,
29922,
9621,
29889,
15845,
3285,
13,
4706,
4567,
3790,
29913,
13,
1678,
1723,
13,
13,
1678,
732,
2490,
29918,
1359,
13,
1678,
822,
1207,
29918,
1990,
29898,
1311,
29892,
848,
29901,
9657,
29892,
3579,
19290,
1125,
13,
4706,
736,
1583,
29889,
5675,
29918,
8758,
29898,
1272,
29897,
13,
13,
1678,
822,
1207,
29918,
8758,
29898,
1311,
29892,
848,
29901,
9657,
29897,
1599,
9330,
14683,
29901,
13,
4706,
736,
9330,
14683,
29898,
1068,
1272,
29897,
13,
2
] |
ialgebra/interpreters/interpreter.py | huashen218/pytorch-ialgebra | 2 | 146071 | import torch
import numpy as np
from ialgebra.utils.utils_data import preprocess_fn
from ialgebra.utils.utils_interpreter import resize_postfn, generate_map
device = 'cuda' if torch.cuda.is_available() else 'cpu'
class Interpreter(object):
def __init__(self, pretrained_model=None, dataset=None, target_layer=None):
super(Interpreter, self).__init__()
self.pretrained_model = pretrained_model
self.dataset = dataset
self.features = self.pretrained_model.features
self.preprocess_fn = preprocess_fn
self.device = device
self.resize_postfn = resize_postfn
self.generate_map = generate_map
self.target_layer = target_layer
def __call__(self, bx, by, batch_size=None):
return self.interpret(bx, by, batch_size=batch_size)
def get_default_config(self):
pass
def interpret_per_batch(self, bxn, byn):
pass
def interpret(self, bx, by, batch_size = None):
print("bx:", bx.size())
print("by,", by.size())
bx = bx.unsqueeze(0) if len(bx.size()) != 4 else bx # assert len(x.size) = 4, bx torch.Tensor()
batch_size = len(bx) if batch_size is None else batch_size
n_batches = (len(bx) + batch_size - 1) // batch_size
interpreter_map = []
interpreter_mapimg = []
for i in range(n_batches):
si = i * batch_size
ei = min(len(bx), si + batch_size)
bxn, byn = bx[si:ei], by[si:ei]
bxn, byn = torch.tensor(bxn, requires_grad=True), torch.tensor(byn)
gradmap, gradimg = self.interpret_per_batch(bxn, byn)
interpreter_map.append(gradmap)
interpreter_mapimg.append(gradimg)
interpreter_map = np.concatenate(interpreter_map, axis=0)
interpreter_mapimg = np.concatenate(interpreter_mapimg, axis=0)
return interpreter_map, interpreter_mapimg
| [
1,
1053,
4842,
305,
13,
5215,
12655,
408,
7442,
13,
3166,
474,
15742,
29889,
13239,
29889,
13239,
29918,
1272,
1053,
758,
5014,
29918,
9144,
13,
3166,
474,
15742,
29889,
13239,
29889,
13239,
29918,
1639,
1457,
357,
1053,
19490,
29918,
2490,
9144,
29892,
5706,
29918,
1958,
13,
13,
10141,
353,
525,
29883,
6191,
29915,
565,
4842,
305,
29889,
29883,
6191,
29889,
275,
29918,
16515,
580,
1683,
525,
21970,
29915,
13,
13,
1990,
4124,
1457,
357,
29898,
3318,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
758,
3018,
1312,
29918,
4299,
29922,
8516,
29892,
29871,
8783,
29922,
8516,
29892,
3646,
29918,
13148,
29922,
8516,
1125,
13,
13,
4706,
2428,
29898,
4074,
1457,
357,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
1457,
3018,
1312,
29918,
4299,
353,
758,
3018,
1312,
29918,
4299,
13,
4706,
1583,
29889,
24713,
353,
8783,
13,
4706,
1583,
29889,
22100,
353,
1583,
29889,
1457,
3018,
1312,
29918,
4299,
29889,
22100,
13,
4706,
1583,
29889,
1457,
5014,
29918,
9144,
353,
758,
5014,
29918,
9144,
13,
4706,
1583,
29889,
10141,
353,
4742,
13,
4706,
1583,
29889,
21476,
29918,
2490,
9144,
353,
19490,
29918,
2490,
9144,
13,
4706,
1583,
29889,
17158,
29918,
1958,
353,
5706,
29918,
1958,
13,
4706,
1583,
29889,
5182,
29918,
13148,
353,
3646,
29918,
13148,
13,
13,
1678,
822,
4770,
4804,
12035,
1311,
29892,
289,
29916,
29892,
491,
29892,
9853,
29918,
2311,
29922,
8516,
1125,
13,
4706,
736,
1583,
29889,
1639,
19819,
29898,
29890,
29916,
29892,
491,
29892,
9853,
29918,
2311,
29922,
16175,
29918,
2311,
29897,
13,
13,
1678,
822,
679,
29918,
4381,
29918,
2917,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
1678,
822,
6613,
29918,
546,
29918,
16175,
29898,
1311,
29892,
289,
29916,
29876,
29892,
491,
29876,
1125,
13,
4706,
1209,
13,
13,
1678,
822,
6613,
29898,
1311,
29892,
289,
29916,
29892,
491,
29892,
9853,
29918,
2311,
353,
6213,
1125,
13,
4706,
1596,
703,
29890,
29916,
29901,
613,
289,
29916,
29889,
2311,
3101,
13,
4706,
1596,
703,
1609,
29892,
613,
491,
29889,
2311,
3101,
13,
4706,
289,
29916,
353,
289,
29916,
29889,
6948,
802,
29872,
911,
29898,
29900,
29897,
565,
7431,
29898,
29890,
29916,
29889,
2311,
3101,
2804,
29871,
29946,
1683,
289,
29916,
3986,
396,
4974,
7431,
29898,
29916,
29889,
2311,
29897,
353,
29871,
29946,
29892,
289,
29916,
4842,
305,
29889,
29911,
6073,
580,
13,
4706,
9853,
29918,
2311,
353,
7431,
29898,
29890,
29916,
29897,
565,
9853,
29918,
2311,
338,
6213,
1683,
9853,
29918,
2311,
13,
4706,
302,
29918,
16175,
267,
353,
313,
2435,
29898,
29890,
29916,
29897,
718,
9853,
29918,
2311,
448,
29871,
29896,
29897,
849,
9853,
29918,
2311,
13,
4706,
26997,
29918,
1958,
353,
5159,
13,
4706,
26997,
29918,
1958,
2492,
353,
5159,
13,
4706,
363,
474,
297,
3464,
29898,
29876,
29918,
16175,
267,
1125,
13,
9651,
1354,
353,
474,
334,
9853,
29918,
2311,
13,
9651,
321,
29875,
353,
1375,
29898,
2435,
29898,
29890,
29916,
511,
1354,
718,
9853,
29918,
2311,
29897,
13,
9651,
289,
29916,
29876,
29892,
491,
29876,
353,
289,
29916,
29961,
1039,
29901,
10096,
1402,
491,
29961,
1039,
29901,
10096,
29962,
13,
9651,
289,
29916,
29876,
29892,
491,
29876,
353,
4842,
305,
29889,
20158,
29898,
29890,
29916,
29876,
29892,
6858,
29918,
5105,
29922,
5574,
511,
4842,
305,
29889,
20158,
29898,
29890,
948,
29897,
13,
9651,
4656,
1958,
29892,
4656,
2492,
353,
1583,
29889,
1639,
19819,
29918,
546,
29918,
16175,
29898,
29890,
29916,
29876,
29892,
491,
29876,
29897,
13,
9651,
26997,
29918,
1958,
29889,
4397,
29898,
5105,
1958,
29897,
13,
9651,
26997,
29918,
1958,
2492,
29889,
4397,
29898,
5105,
2492,
29897,
13,
4706,
26997,
29918,
1958,
353,
7442,
29889,
535,
29883,
2579,
403,
29898,
1639,
1457,
357,
29918,
1958,
29892,
9685,
29922,
29900,
29897,
13,
4706,
26997,
29918,
1958,
2492,
353,
7442,
29889,
535,
29883,
2579,
403,
29898,
1639,
1457,
357,
29918,
1958,
2492,
29892,
9685,
29922,
29900,
29897,
13,
4706,
736,
26997,
29918,
1958,
29892,
26997,
29918,
1958,
2492,
13,
2
] |
tests/test_ints.py | albatrossen/binarydataclass | 0 | 86411 | from binarydataclass import (
from_bytes,
Uint8,
Uint16,
Uint32,
Uint64,
Int8,
Int16,
Int32,
Int64,
binaryfield,
int_decoder,
)
from dataclasses import dataclass
@dataclass
class PointWithTypes:
a: Uint8
b: Uint16
c: Uint32
d: Uint64
e: Int8
f: Int16
g: Int32
h: Int64
@dataclass
class PointWithoutTypes:
a: int = binaryfield(int_decoder(bits=8))
b: int = binaryfield(int_decoder(bits=16))
c: int = binaryfield(int_decoder(bits=32))
d: int = binaryfield(int_decoder(bits=64))
e: int = binaryfield(int_decoder(bits=8, signed=True))
f: int = binaryfield(int_decoder(bits=16, signed=True))
g: int = binaryfield(int_decoder(bits=32, signed=True))
h: int = binaryfield(int_decoder(bits=64, signed=True))
def test_with_types():
obj = from_bytes(
PointWithTypes,
b"\x01\x00\x02\x00\x00\x00\x05\xff\xff\xff\xff\xff\xff\xff\xff\x01\xff\xff\x00\x00\x00\x05\xff\xff\xff\xff\xff\xff\xff\xff",
)
assert obj == PointWithTypes(1, 2, 5, 18446744073709551615, 1, -1, 5, -1)
def test_without_types():
obj = from_bytes(
PointWithoutTypes,
b"\x01\x00\x02\x00\x00\x00\x05\xff\xff\xff\xff\xff\xff\xff\xff\x01\xff\xff\x00\x00\x00\x05\xff\xff\xff\xff\xff\xff\xff\xff",
)
assert obj == PointWithoutTypes(1, 2, 5, 18446744073709551615, 1, -1, 5, -1)
| [
1,
515,
7581,
1272,
1990,
1053,
313,
13,
1678,
515,
29918,
13193,
29892,
13,
1678,
501,
524,
29947,
29892,
13,
1678,
501,
524,
29896,
29953,
29892,
13,
1678,
501,
524,
29941,
29906,
29892,
13,
1678,
501,
524,
29953,
29946,
29892,
13,
1678,
3159,
29947,
29892,
13,
1678,
3159,
29896,
29953,
29892,
13,
1678,
3159,
29941,
29906,
29892,
13,
1678,
3159,
29953,
29946,
29892,
13,
1678,
7581,
2671,
29892,
13,
1678,
938,
29918,
7099,
6119,
29892,
13,
29897,
13,
3166,
848,
13203,
1053,
848,
1990,
13,
13,
13,
29992,
1272,
1990,
13,
1990,
8984,
3047,
10562,
29901,
13,
1678,
263,
29901,
501,
524,
29947,
13,
1678,
289,
29901,
501,
524,
29896,
29953,
13,
1678,
274,
29901,
501,
524,
29941,
29906,
13,
1678,
270,
29901,
501,
524,
29953,
29946,
13,
1678,
321,
29901,
3159,
29947,
13,
1678,
285,
29901,
3159,
29896,
29953,
13,
1678,
330,
29901,
3159,
29941,
29906,
13,
1678,
298,
29901,
3159,
29953,
29946,
13,
13,
13,
29992,
1272,
1990,
13,
1990,
8984,
3047,
449,
10562,
29901,
13,
1678,
263,
29901,
938,
353,
7581,
2671,
29898,
524,
29918,
7099,
6119,
29898,
14836,
29922,
29947,
876,
13,
1678,
289,
29901,
938,
353,
7581,
2671,
29898,
524,
29918,
7099,
6119,
29898,
14836,
29922,
29896,
29953,
876,
13,
1678,
274,
29901,
938,
353,
7581,
2671,
29898,
524,
29918,
7099,
6119,
29898,
14836,
29922,
29941,
29906,
876,
13,
1678,
270,
29901,
938,
353,
7581,
2671,
29898,
524,
29918,
7099,
6119,
29898,
14836,
29922,
29953,
29946,
876,
13,
1678,
321,
29901,
938,
353,
7581,
2671,
29898,
524,
29918,
7099,
6119,
29898,
14836,
29922,
29947,
29892,
8794,
29922,
5574,
876,
13,
1678,
285,
29901,
938,
353,
7581,
2671,
29898,
524,
29918,
7099,
6119,
29898,
14836,
29922,
29896,
29953,
29892,
8794,
29922,
5574,
876,
13,
1678,
330,
29901,
938,
353,
7581,
2671,
29898,
524,
29918,
7099,
6119,
29898,
14836,
29922,
29941,
29906,
29892,
8794,
29922,
5574,
876,
13,
1678,
298,
29901,
938,
353,
7581,
2671,
29898,
524,
29918,
7099,
6119,
29898,
14836,
29922,
29953,
29946,
29892,
8794,
29922,
5574,
876,
13,
13,
13,
1753,
1243,
29918,
2541,
29918,
8768,
7295,
13,
1678,
5446,
353,
515,
29918,
13193,
29898,
13,
4706,
8984,
3047,
10562,
29892,
13,
4706,
289,
26732,
29916,
29900,
29896,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29906,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29945,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
29900,
29896,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29945,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
613,
13,
1678,
1723,
13,
1678,
4974,
5446,
1275,
8984,
3047,
10562,
29898,
29896,
29892,
29871,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29947,
29946,
29946,
29953,
29955,
29946,
29946,
29900,
29955,
29941,
29955,
29900,
29929,
29945,
29945,
29896,
29953,
29896,
29945,
29892,
29871,
29896,
29892,
448,
29896,
29892,
29871,
29945,
29892,
448,
29896,
29897,
13,
13,
13,
1753,
1243,
29918,
14037,
29918,
8768,
7295,
13,
1678,
5446,
353,
515,
29918,
13193,
29898,
13,
4706,
8984,
3047,
449,
10562,
29892,
13,
4706,
289,
26732,
29916,
29900,
29896,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29906,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29945,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
29900,
29896,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29900,
29905,
29916,
29900,
29945,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
29905,
29916,
600,
613,
13,
1678,
1723,
13,
1678,
4974,
5446,
1275,
8984,
3047,
449,
10562,
29898,
29896,
29892,
29871,
29906,
29892,
29871,
29945,
29892,
29871,
29896,
29947,
29946,
29946,
29953,
29955,
29946,
29946,
29900,
29955,
29941,
29955,
29900,
29929,
29945,
29945,
29896,
29953,
29896,
29945,
29892,
29871,
29896,
29892,
448,
29896,
29892,
29871,
29945,
29892,
448,
29896,
29897,
13,
2
] |
mult/multdiv.py | artemkin/sandbox | 0 | 98084 | <reponame>artemkin/sandbox<filename>mult/multdiv.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import random
def input_int(title, f=(lambda x: x)):
while True:
try:
return f(int(raw_input(title + ': ')))
except ValueError:
print('Ошибка. Попробуй еще раз...')
def check_bound(x, lower, upper):
if x < lower or x > upper:
raise ValueError('')
return x
mult = True
while True:
op = raw_input('Операция * или /: ')
if op == '*':
mult = True
break
elif op == '/':
mult = False
break
print('Ошибка. Попробуй еще раз...')
count = input_int('Число примеров (от 1 до 100)', (lambda x: check_bound(x, 1, 100)))
upper = input_int('Верхний порог (от 1 до 10)', (lambda x: check_bound(x, 1, 10)))
lower = input_int('Нижний порог (от 1 до ' + str(upper) + ')', (lambda x: check_bound(x, 1, upper)))
filename = 'mult.log' if mult else 'div.log'
f = open(filename, 'a')
correct = 0
for i in range(count):
a = random.randint(lower, upper)
b = random.randint(1, 10)
if mult:
c = input_int(str(a) + 'x' + str(b) + "=");
if a * b == c:
correct = correct + 1
else:
c = input_int(str(a * b) + '/' + str(a) + "=");
if b == c:
correct = correct + 1
print(a, b, c, file=f)
print('Правильных ответов:', correct, 'из', count)
star = '\xE2\xAD\x90'
kiss = '\xF0\x9F\x98\x98'
if correct == count:
print('УМНИЦА!!!!', star, star, star)
print('Ты лучшая!', kiss)
elif float(correct) / count >= 0.7:
print('У тебя почти получилось! Молодец!!!')
| [
1,
529,
276,
1112,
420,
29958,
442,
331,
9089,
29914,
29879,
26738,
29966,
9507,
29958,
4713,
29914,
4713,
4563,
29889,
2272,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
5215,
4036,
13,
13,
1753,
1881,
29918,
524,
29898,
3257,
29892,
285,
7607,
2892,
921,
29901,
921,
22164,
13,
1678,
1550,
5852,
29901,
13,
4706,
1018,
29901,
13,
9651,
736,
285,
29898,
524,
29898,
1610,
29918,
2080,
29898,
3257,
718,
525,
29901,
525,
4961,
13,
4706,
5174,
7865,
2392,
29901,
13,
9651,
1596,
877,
30038,
1911,
23348,
29889,
2195,
5945,
3378,
29977,
1694,
2402,
3212,
856,
1495,
13,
13,
1753,
1423,
29918,
9917,
29898,
29916,
29892,
5224,
29892,
7568,
1125,
13,
1678,
565,
921,
529,
5224,
470,
921,
1405,
7568,
29901,
13,
4706,
12020,
7865,
2392,
877,
1495,
13,
1678,
736,
921,
13,
13,
4713,
353,
5852,
13,
13,
8000,
5852,
29901,
13,
1678,
1015,
353,
10650,
29918,
2080,
877,
30038,
7682,
5274,
334,
7082,
847,
29901,
25710,
13,
1678,
565,
1015,
1275,
525,
29930,
2396,
13,
4706,
1773,
353,
5852,
13,
4706,
2867,
13,
1678,
25342,
1015,
1275,
8207,
2396,
13,
4706,
1773,
353,
7700,
13,
4706,
2867,
13,
13,
1678,
1596,
877,
30038,
1911,
23348,
29889,
2195,
5945,
3378,
29977,
1694,
2402,
3212,
856,
1495,
13,
13,
2798,
353,
1881,
29918,
524,
877,
30076,
11452,
843,
1695,
5508,
516,
313,
10390,
29871,
29896,
1447,
29871,
29896,
29900,
29900,
29897,
742,
795,
313,
2892,
921,
29901,
1423,
29918,
9917,
29898,
29916,
29892,
29871,
29896,
29892,
29871,
29896,
29900,
29900,
4961,
13,
21064,
353,
1881,
29918,
524,
877,
30012,
780,
29988,
2332,
733,
576,
29969,
313,
10390,
29871,
29896,
1447,
29871,
29896,
29900,
29897,
742,
18884,
313,
2892,
921,
29901,
1423,
29918,
9917,
29898,
29916,
29892,
29871,
29896,
29892,
29871,
29896,
29900,
4961,
13,
13609,
353,
1881,
29918,
524,
877,
30029,
29917,
29998,
2332,
733,
576,
29969,
313,
10390,
29871,
29896,
1447,
525,
718,
851,
29898,
21064,
29897,
718,
25710,
742,
313,
2892,
921,
29901,
1423,
29918,
9917,
29898,
29916,
29892,
29871,
29896,
29892,
7568,
4961,
13,
13,
9507,
353,
525,
4713,
29889,
1188,
29915,
565,
1773,
1683,
525,
4563,
29889,
1188,
29915,
13,
29888,
353,
1722,
29898,
9507,
29892,
525,
29874,
1495,
13,
13,
15728,
353,
29871,
29900,
13,
13,
1454,
474,
297,
3464,
29898,
2798,
1125,
13,
1678,
263,
353,
4036,
29889,
9502,
524,
29898,
13609,
29892,
7568,
29897,
13,
1678,
289,
353,
4036,
29889,
9502,
524,
29898,
29896,
29892,
29871,
29896,
29900,
29897,
13,
13,
1678,
565,
1773,
29901,
13,
4706,
274,
353,
1881,
29918,
524,
29898,
710,
29898,
29874,
29897,
718,
525,
29916,
29915,
718,
851,
29898,
29890,
29897,
718,
376,
543,
416,
13,
4706,
565,
263,
334,
289,
1275,
274,
29901,
13,
9651,
1959,
353,
1959,
718,
29871,
29896,
13,
1678,
1683,
29901,
13,
4706,
274,
353,
1881,
29918,
524,
29898,
710,
29898,
29874,
334,
289,
29897,
718,
8207,
29915,
718,
851,
29898,
29874,
29897,
718,
376,
543,
416,
13,
4706,
565,
289,
1275,
274,
29901,
13,
9651,
1959,
353,
1959,
718,
29871,
29896,
13,
13,
1678,
1596,
29898,
29874,
29892,
289,
29892,
274,
29892,
934,
29922,
29888,
29897,
13,
13,
2158,
877,
30013,
494,
1221,
25575,
1685,
7616,
516,
29901,
742,
1959,
29892,
525,
6531,
742,
2302,
29897,
13,
13,
8508,
353,
11297,
29916,
29923,
29906,
29905,
29916,
3035,
29905,
29916,
29929,
29900,
29915,
13,
29895,
790,
353,
11297,
29916,
29943,
29900,
29905,
29916,
29929,
29943,
29905,
29916,
29929,
29947,
29905,
29916,
29929,
29947,
29915,
13,
361,
1959,
1275,
2302,
29901,
13,
1678,
1596,
877,
30053,
30017,
30029,
30054,
30092,
30018,
6824,
6824,
742,
5810,
29892,
5810,
29892,
5810,
29897,
13,
1678,
1596,
877,
30041,
29982,
23321,
15766,
29991,
742,
20057,
29897,
13,
23681,
5785,
29898,
15728,
29897,
847,
2302,
6736,
29871,
29900,
29889,
29955,
29901,
13,
1678,
1596,
877,
30053,
2399,
20884,
18752,
811,
12052,
8641,
29991,
1142,
6157,
1216,
29996,
21004,
1495,
13,
13,
2
] |
lib/gui/widgets/queue_items/__init__.py | B1d1zyaKa/mff_auto | 1 | 151740 | <filename>lib/gui/widgets/queue_items/__init__.py
import inspect
import sys
import lib.logger as logging
from lib.gui.widgets.queue_items import actions
from lib.gui.widgets.queue_items import events
from lib.gui.widgets.queue_items import missions
from .general import GameMode, Action, Event
logger = logging.get_logger(__name__)
def _classes_from_module(module_name):
"""Generator for all non-imported classes inside module.
:param str module_name: module's name.
:rtype: typing.Generator[type[GameMode]]
"""
if module_name not in sys.modules:
logger.error(f"Cannot load {module_name} module.")
for name, obj in inspect.getmembers(sys.modules[module_name]):
if obj and inspect.isclass(obj) and obj.__module__ == module_name:
yield obj
def _init_classes(module_name, game):
"""Initializes all non-imported classes inside module into the game.
:param str module_name: module's name.
:param lib.game.game.Game game: instance of the game.
:rtype: list[GameMode]
"""
return [class_init(game) for class_init in _classes_from_module(module_name)]
def get_actions(game):
"""Gets all initialized actions.
:rtype: list[Action]
"""
return _init_classes(module_name=actions.__name__, game=game)
def get_events(game):
"""Gets all initialized events.
:rtype: list[Event]
"""
return _init_classes(module_name=events.__name__, game=game)
def get_missions(game):
"""Gets all initialized missions.
:rtype: list[GameMode]
"""
return _init_classes(module_name=missions.__name__, game=game)
def get_missions_dict(mission_instances):
"""Constructs menu dictionary for missions by it's instances.
:param list[GameMode] mission_instances: list of mission's instances.
:rtype: dict
"""
def find_instance(class_):
return next((inst for inst in mission_instances if inst.__class__.__name__ == class_.__name__), None)
menu_dict = {
"EPIC QUESTS": {
"FATE OF MANKIND": [find_instance(missions._HeroesReunited), find_instance(missions._IndustrialComplex),
find_instance(missions._DeviantDiversion)],
"DARK REIGN": [find_instance(missions._PlayingHero), find_instance(missions._GoldenGods),
find_instance(missions._StingOfTheScorpion), find_instance(missions._SelfDefenseProtocol),
find_instance(missions._LegacyOfBlood)],
"GALACTIC IMPERATIVE": [find_instance(missions._FateOfTheUniverse), find_instance(missions._TheFault),
find_instance(missions._DangerousSisters), find_instance(missions._CosmicRider),
find_instance(missions._QuantumPower), find_instance(missions._WingsOfDarkness)],
"FIRST FAMILY": [find_instance(missions._DoomsDay), find_instance(missions._TwistedWorld),
find_instance(missions._InhumanPrincess), find_instance(missions._MeanAndGreen),
find_instance(missions._ClobberinTime), find_instance(missions._Hothead)],
"X-FORCE": [find_instance(missions._BeginningOfTheChaos), find_instance(missions._StupidXMen),
find_instance(missions._TheBigTwin), find_instance(missions._AwManThisGuy),
find_instance(missions._DominoFalls)],
"RISE OF THE X-MEN": [find_instance(missions._MutualEnemy), find_instance(missions._VeiledSecret),
find_instance(missions._GoingRogue), find_instance(missions._FriendsAndEnemies),
find_instance(missions._WeatheringTheStorm), find_instance(missions._Blindsided)],
"SORCERER SUPREME": [find_instance(missions._DarkAdvent), find_instance(missions._IncreasingDarkness),
find_instance(missions._RoadToMonastery), find_instance(missions._MysteriousAmbush),
find_instance(missions._MonasteryInTrouble), find_instance(missions._PowerOfTheDark)]
},
"STORY MISSION": find_instance(missions._StoryMission),
"DIMENSION MISSION": find_instance(missions._DimensionMissions),
"LEGENDARY BATTLE": find_instance(missions._LegendaryBattle),
"SQUAD BATTLE": find_instance(missions._SquadBattles),
"WORLD BOSS": find_instance(missions._WorldBosses),
"TIMELINE BATTLE": find_instance(missions._TimelineBattle),
"DANGER ROOM": find_instance(missions._DangerRoom),
"ALLIANCE BATTLE": find_instance(missions._AllianceBattle),
"CO-OP PLAY": find_instance(missions._CoopPlay),
"WORLD BOSS INVASION": find_instance(missions._WorldBossInvasion),
"GIANT BOSS RAID": find_instance(missions._GiantBossRaid),
"SHADOWLAND": find_instance(missions._Shadowland)
}
return menu_dict
def get_actions_dict(action_instances):
"""Constructs menu dictionary for actions by it's instances.
:param list[Action] action_instances: list of action's instances.
:rtype: dict
"""
def find_instance(class_):
return next((inst for inst in action_instances if inst.__class__.__name__ == class_.__name__), None)
alliance = [find_instance(actions._AllianceCheckIn), find_instance(actions._AllianceDonate),
find_instance(actions._AllianceBuyEnergy), find_instance(actions._AllianceRequestSupport),
find_instance(actions._AllianceChallengesEnergy)]
inventory = [find_instance(actions._ComicCards), find_instance(actions._CustomGear),
find_instance(actions._Iso8Upgrade), find_instance(actions._Iso8Combine),
find_instance(actions._Iso8Lock), find_instance(actions._ArtifactDismantle)]
store = [find_instance(actions._CollectFreeEnergy), find_instance(actions._CollectEnergyViaAssemblePoints),
find_instance(actions._AcquireFreeHeroChest), find_instance(actions._AcquireFreeArtifactChest),
find_instance(actions._BuyArtifactChest)]
menu_dict = {
"[ACTIONS]": {
"[QUEUE CONTROL]": [find_instance(actions._RunQueue)],
"ALLIANCE": alliance,
"INVENTORY": inventory,
"STORE": store,
**{action.mode_name: action for action in action_instances if action not in [*alliance, *inventory, *store]}
}
}
return menu_dict
| [
1,
529,
9507,
29958,
1982,
29914,
23569,
29914,
8030,
29879,
29914,
9990,
29918,
7076,
29914,
1649,
2344,
26914,
2272,
13,
30143,
5215,
16096,
13,
5215,
10876,
13,
13,
5215,
4303,
29889,
21707,
408,
12183,
13,
3166,
4303,
29889,
23569,
29889,
8030,
29879,
29889,
9990,
29918,
7076,
1053,
8820,
13,
3166,
4303,
29889,
23569,
29889,
8030,
29879,
29889,
9990,
29918,
7076,
1053,
4959,
13,
3166,
4303,
29889,
23569,
29889,
8030,
29879,
29889,
9990,
29918,
7076,
1053,
3052,
1080,
13,
3166,
869,
17492,
1053,
8448,
6818,
29892,
9123,
29892,
6864,
13,
13,
21707,
353,
12183,
29889,
657,
29918,
21707,
22168,
978,
1649,
29897,
13,
13,
13,
1753,
903,
13203,
29918,
3166,
29918,
5453,
29898,
5453,
29918,
978,
1125,
13,
1678,
9995,
21575,
363,
599,
1661,
29899,
5215,
287,
4413,
2768,
3883,
29889,
13,
13,
1678,
584,
3207,
851,
3883,
29918,
978,
29901,
3883,
29915,
29879,
1024,
29889,
13,
13,
1678,
584,
29878,
1853,
29901,
19229,
29889,
21575,
29961,
1853,
29961,
14199,
6818,
5262,
13,
1678,
9995,
13,
1678,
565,
3883,
29918,
978,
451,
297,
10876,
29889,
7576,
29901,
13,
4706,
17927,
29889,
2704,
29898,
29888,
29908,
29089,
2254,
426,
5453,
29918,
978,
29913,
3883,
23157,
13,
1678,
363,
1024,
29892,
5446,
297,
16096,
29889,
657,
28109,
29898,
9675,
29889,
7576,
29961,
5453,
29918,
978,
29962,
1125,
13,
4706,
565,
5446,
322,
16096,
29889,
275,
1990,
29898,
5415,
29897,
322,
5446,
17255,
5453,
1649,
1275,
3883,
29918,
978,
29901,
13,
9651,
7709,
5446,
13,
13,
13,
1753,
903,
2344,
29918,
13203,
29898,
5453,
29918,
978,
29892,
3748,
1125,
13,
1678,
9995,
15514,
7093,
599,
1661,
29899,
5215,
287,
4413,
2768,
3883,
964,
278,
3748,
29889,
13,
13,
1678,
584,
3207,
851,
3883,
29918,
978,
29901,
3883,
29915,
29879,
1024,
29889,
13,
1678,
584,
3207,
4303,
29889,
11802,
29889,
11802,
29889,
14199,
3748,
29901,
2777,
310,
278,
3748,
29889,
13,
13,
1678,
584,
29878,
1853,
29901,
1051,
29961,
14199,
6818,
29962,
13,
1678,
9995,
13,
1678,
736,
518,
1990,
29918,
2344,
29898,
11802,
29897,
363,
770,
29918,
2344,
297,
903,
13203,
29918,
3166,
29918,
5453,
29898,
5453,
29918,
978,
4638,
13,
13,
13,
1753,
679,
29918,
7387,
29898,
11802,
1125,
13,
1678,
9995,
29954,
1691,
599,
16601,
8820,
29889,
13,
13,
1678,
584,
29878,
1853,
29901,
1051,
29961,
4276,
29962,
13,
1678,
9995,
13,
1678,
736,
903,
2344,
29918,
13203,
29898,
5453,
29918,
978,
29922,
7387,
17255,
978,
1649,
29892,
3748,
29922,
11802,
29897,
13,
13,
13,
1753,
679,
29918,
13604,
29898,
11802,
1125,
13,
1678,
9995,
29954,
1691,
599,
16601,
4959,
29889,
13,
13,
1678,
584,
29878,
1853,
29901,
1051,
29961,
2624,
29962,
13,
1678,
9995,
13,
1678,
736,
903,
2344,
29918,
13203,
29898,
5453,
29918,
978,
29922,
13604,
17255,
978,
1649,
29892,
3748,
29922,
11802,
29897,
13,
13,
13,
1753,
679,
29918,
29885,
6847,
29898,
11802,
1125,
13,
1678,
9995,
29954,
1691,
599,
16601,
3052,
1080,
29889,
13,
13,
1678,
584,
29878,
1853,
29901,
1051,
29961,
14199,
6818,
29962,
13,
1678,
9995,
13,
1678,
736,
903,
2344,
29918,
13203,
29898,
5453,
29918,
978,
29922,
29885,
6847,
17255,
978,
1649,
29892,
3748,
29922,
11802,
29897,
13,
13,
13,
1753,
679,
29918,
29885,
6847,
29918,
8977,
29898,
6737,
29918,
2611,
2925,
1125,
13,
1678,
9995,
1168,
4984,
29879,
6143,
8600,
363,
3052,
1080,
491,
372,
29915,
29879,
8871,
29889,
13,
13,
1678,
584,
3207,
1051,
29961,
14199,
6818,
29962,
10655,
29918,
2611,
2925,
29901,
1051,
310,
10655,
29915,
29879,
8871,
29889,
13,
13,
1678,
584,
29878,
1853,
29901,
9657,
13,
1678,
9995,
13,
13,
1678,
822,
1284,
29918,
8758,
29898,
1990,
29918,
1125,
13,
4706,
736,
2446,
3552,
2611,
363,
832,
297,
10655,
29918,
2611,
2925,
565,
832,
17255,
1990,
1649,
17255,
978,
1649,
1275,
770,
5396,
1649,
978,
1649,
511,
6213,
29897,
13,
13,
1678,
6143,
29918,
8977,
353,
426,
13,
4706,
376,
29923,
2227,
29907,
660,
4462,
1254,
29903,
1115,
426,
13,
9651,
376,
29943,
3040,
8079,
341,
2190,
29968,
22255,
1115,
518,
2886,
29918,
8758,
29898,
29885,
6847,
3032,
29950,
1489,
267,
1123,
348,
1573,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
2568,
504,
9315,
8909,
29916,
511,
13,
462,
18884,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
2772,
1403,
424,
29928,
1536,
291,
29897,
1402,
13,
9651,
376,
29928,
1718,
29968,
5195,
17298,
1115,
518,
2886,
29918,
8758,
29898,
29885,
6847,
3032,
13454,
292,
29950,
1489,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29954,
1025,
264,
29954,
19653,
511,
13,
462,
965,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
855,
292,
2776,
1576,
29903,
2616,
29886,
291,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
24313,
3206,
1947,
17830,
511,
13,
462,
965,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
22988,
4135,
2776,
29933,
417,
397,
29897,
1402,
13,
9651,
376,
29954,
1964,
17923,
2965,
306,
3580,
1001,
1299,
18474,
1115,
518,
2886,
29918,
8758,
29898,
29885,
6847,
3032,
29943,
403,
2776,
1576,
8110,
3901,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
1576,
29943,
1292,
511,
13,
462,
462,
1678,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29928,
4600,
681,
29903,
1531,
29879,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29907,
359,
13076,
29934,
1241,
511,
13,
462,
462,
1678,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
22930,
398,
21472,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29956,
886,
2776,
29928,
935,
2264,
29897,
1402,
13,
9651,
376,
3738,
29934,
1254,
383,
5194,
6227,
29979,
1115,
518,
2886,
29918,
8758,
29898,
29885,
6847,
3032,
6132,
4835,
12742,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
27418,
12652,
14058,
511,
13,
462,
632,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
797,
26029,
4040,
262,
985,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
6816,
273,
2855,
24599,
511,
13,
462,
632,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29907,
2127,
495,
262,
2481,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
28917,
2813,
29897,
1402,
13,
9651,
376,
29990,
29899,
22051,
4741,
1115,
518,
2886,
29918,
8758,
29898,
29885,
6847,
3032,
17946,
1076,
2776,
1576,
1451,
29874,
359,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
855,
786,
333,
29990,
28154,
511,
13,
462,
4706,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
1576,
6970,
29911,
5080,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29909,
29893,
2517,
4013,
29954,
8631,
511,
13,
462,
4706,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
11096,
1789,
29943,
4293,
29897,
1402,
13,
9651,
376,
3960,
1660,
8079,
6093,
1060,
29899,
29924,
1430,
1115,
518,
2886,
29918,
8758,
29898,
29885,
6847,
3032,
29924,
329,
950,
2369,
6764,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29963,
29872,
2356,
28459,
511,
13,
462,
462,
29871,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
8120,
292,
29934,
468,
434,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
27034,
1975,
2855,
2369,
331,
583,
511,
13,
462,
462,
29871,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
4806,
1624,
292,
1576,
855,
555,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
10358,
12772,
2618,
29897,
1402,
13,
9651,
376,
29903,
1955,
29907,
1001,
1001,
317,
4897,
1525,
2303,
1115,
518,
2886,
29918,
8758,
29898,
29885,
6847,
3032,
29928,
935,
3253,
794,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
797,
1037,
5832,
29928,
935,
2264,
511,
13,
462,
462,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
9588,
328,
1762,
7185,
1901,
29891,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29924,
858,
261,
2738,
6833,
29890,
1878,
511,
13,
462,
462,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
7185,
1901,
29891,
797,
2308,
2074,
511,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
21472,
2776,
1576,
29928,
935,
4638,
13,
4706,
2981,
13,
4706,
376,
1254,
18929,
341,
29902,
13507,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29359,
29924,
2333,
511,
13,
4706,
376,
4571,
29924,
1430,
13381,
341,
29902,
13507,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
16142,
2673,
29924,
6847,
511,
13,
4706,
376,
1307,
29954,
11794,
19926,
350,
1299,
29911,
1307,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
22988,
355,
653,
29933,
5315,
511,
13,
4706,
376,
29903,
13356,
3035,
350,
1299,
29911,
1307,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29903,
3425,
29933,
1131,
793,
511,
13,
4706,
376,
11686,
10249,
16437,
1799,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
14058,
29933,
2209,
267,
511,
13,
4706,
376,
15307,
18521,
350,
1299,
29911,
1307,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
13711,
5570,
29933,
5315,
511,
13,
4706,
376,
29928,
2190,
17070,
16641,
6488,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
29928,
4600,
9588,
290,
511,
13,
4706,
376,
1964,
5265,
23219,
350,
1299,
29911,
1307,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
2499,
13036,
29933,
5315,
511,
13,
4706,
376,
3217,
29899,
4590,
349,
18799,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
7967,
459,
13454,
511,
13,
4706,
376,
11686,
10249,
16437,
1799,
2672,
29963,
3289,
2725,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
14058,
29933,
2209,
797,
4428,
291,
511,
13,
4706,
376,
29954,
29902,
13566,
16437,
1799,
18865,
1367,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
26074,
424,
29933,
2209,
29934,
29874,
333,
511,
13,
4706,
376,
7068,
3035,
9806,
29931,
9468,
1115,
1284,
29918,
8758,
29898,
29885,
6847,
3032,
2713,
6986,
1049,
29897,
13,
1678,
500,
13,
1678,
736,
6143,
29918,
8977,
13,
13,
13,
1753,
679,
29918,
7387,
29918,
8977,
29898,
2467,
29918,
2611,
2925,
1125,
13,
1678,
9995,
1168,
4984,
29879,
6143,
8600,
363,
8820,
491,
372,
29915,
29879,
8871,
29889,
13,
13,
1678,
584,
3207,
1051,
29961,
4276,
29962,
3158,
29918,
2611,
2925,
29901,
1051,
310,
3158,
29915,
29879,
8871,
29889,
13,
13,
1678,
584,
29878,
1853,
29901,
9657,
13,
1678,
9995,
13,
13,
1678,
822,
1284,
29918,
8758,
29898,
1990,
29918,
1125,
13,
4706,
736,
2446,
3552,
2611,
363,
832,
297,
3158,
29918,
2611,
2925,
565,
832,
17255,
1990,
1649,
17255,
978,
1649,
1275,
770,
5396,
1649,
978,
1649,
511,
6213,
29897,
13,
13,
1678,
394,
13036,
353,
518,
2886,
29918,
8758,
29898,
7387,
3032,
2499,
13036,
5596,
797,
511,
1284,
29918,
8758,
29898,
7387,
3032,
2499,
13036,
10310,
403,
511,
13,
18884,
1284,
29918,
8758,
29898,
7387,
3032,
2499,
13036,
3727,
29891,
29923,
1089,
1927,
511,
1284,
29918,
8758,
29898,
7387,
3032,
2499,
13036,
3089,
14039,
511,
13,
18884,
1284,
29918,
8758,
29898,
7387,
3032,
2499,
13036,
1451,
16047,
267,
29923,
1089,
1927,
4638,
13,
1678,
11817,
706,
353,
518,
2886,
29918,
8758,
29898,
7387,
3032,
1523,
293,
29907,
3163,
511,
1284,
29918,
8758,
29898,
7387,
3032,
7281,
29954,
799,
511,
13,
462,
1284,
29918,
8758,
29898,
7387,
3032,
29902,
578,
29947,
3373,
8228,
511,
1284,
29918,
8758,
29898,
7387,
3032,
29902,
578,
29947,
1523,
26062,
511,
13,
462,
1284,
29918,
8758,
29898,
7387,
3032,
29902,
578,
29947,
16542,
511,
1284,
29918,
8758,
29898,
7387,
3032,
9986,
7060,
29928,
1608,
424,
280,
4638,
13,
1678,
3787,
353,
518,
2886,
29918,
8758,
29898,
7387,
3032,
28916,
20475,
29923,
1089,
1927,
511,
1284,
29918,
8758,
29898,
7387,
3032,
28916,
29923,
1089,
1927,
29963,
423,
7900,
6967,
20325,
511,
13,
632,
1284,
29918,
8758,
29898,
7387,
3032,
10644,
1548,
20475,
29950,
1489,
1451,
342,
511,
1284,
29918,
8758,
29898,
7387,
3032,
10644,
1548,
20475,
9986,
7060,
1451,
342,
511,
13,
632,
1284,
29918,
8758,
29898,
7387,
3032,
3727,
29891,
9986,
7060,
1451,
342,
4638,
13,
1678,
6143,
29918,
8977,
353,
426,
13,
4706,
14704,
24705,
29903,
29962,
1115,
426,
13,
9651,
14704,
11144,
4462,
8707,
29911,
1672,
29931,
29962,
1115,
518,
2886,
29918,
8758,
29898,
7387,
3032,
6558,
10620,
29897,
1402,
13,
9651,
376,
1964,
5265,
23219,
1115,
394,
13036,
29892,
13,
9651,
376,
1177,
29963,
3919,
18929,
1115,
11817,
706,
29892,
13,
9651,
376,
1254,
29949,
1525,
1115,
3787,
29892,
13,
9651,
3579,
29912,
2467,
29889,
8513,
29918,
978,
29901,
3158,
363,
3158,
297,
3158,
29918,
2611,
2925,
565,
3158,
451,
297,
518,
29930,
284,
13036,
29892,
334,
262,
23886,
29892,
334,
8899,
12258,
13,
4706,
500,
13,
1678,
500,
13,
1678,
736,
6143,
29918,
8977,
13,
2
] |
examples/openmdao.examples.enginedesign/openmdao/examples/enginedesign/engine_optimization_smarter.py | JustinSGray/OpenMDAO-Framework | 3 | 1616659 | <filename>examples/openmdao.examples.enginedesign/openmdao/examples/enginedesign/engine_optimization_smarter.py
"""
engine_optimization.py - Top level assembly for the example problem.
"""
# Optimize a Vehicle design with CONMIN
# pylint: disable-msg=E0611,F0401
from openmdao.main.api import Assembly
from openmdao.lib.drivers.api import CONMINdriver
from openmdao.examples.enginedesign.driving_sim import SimAcceleration, \
SimEconomy
from openmdao.examples.enginedesign.vehicle import Vehicle
class EngineOptimization(Assembly):
"""Optimization of a Vehicle."""
def configure(self):
# pylint: disable-msg=E1101
# Create CONMIN Optimizer instance
self.add('optimizer', CONMINdriver())
# Create Vehicle instance
self.add('vehicle', Vehicle())
# Create Driving Simulation instances
self.add('sim_acc', SimAcceleration())
self.add('sim_EPA_city', SimEconomy())
self.add('sim_EPA_highway', SimEconomy())
# add the optimizer and economy sims to driver workflow
self.driver.workflow.add(['optimizer', 'sim_EPA_city', 'sim_EPA_highway'])
# add the acceleration sim to the optimizer workflow
self.optimizer.workflow.add('sim_acc')
# Add vehicle to sim workflows.
self.sim_acc.workflow.add('vehicle')
self.sim_EPA_city.workflow.add('vehicle')
self.sim_EPA_highway.workflow.add('vehicle')
# CONMIN Flags
self.optimizer.iprint = 0
self.optimizer.itmax = 30
# CONMIN Objective
self.optimizer.add_objective('sim_acc.accel_time')
# CONMIN Design Variables
self.optimizer.add_parameter('vehicle.spark_angle', -50., 10.)
self.optimizer.add_parameter('vehicle.bore', 65., 100.)
# Acceleration Sim setup
self.sim_acc.velocity_str = 'vehicle.velocity'
self.sim_acc.throttle_str = 'vehicle.throttle'
self.sim_acc.gear_str = 'vehicle.current_gear'
self.sim_acc.acceleration_str = 'vehicle.acceleration'
self.sim_acc.overspeed_str = 'vehicle.overspeed'
# EPA City MPG Sim Setup
self.sim_EPA_city.velocity_str = 'vehicle.velocity'
self.sim_EPA_city.throttle_str = 'vehicle.throttle'
self.sim_EPA_city.gear_str = 'vehicle.current_gear'
self.sim_EPA_city.acceleration_str = 'vehicle.acceleration'
self.sim_EPA_city.fuel_burn_str = 'vehicle.fuel_burn'
self.sim_EPA_city.overspeed_str = 'vehicle.overspeed'
self.sim_EPA_city.underspeed_str = 'vehicle.underspeed'
self.sim_EPA_city.profilename = 'EPA-city.csv'
self.sim_EPA_city.force_execute = True
# EPA Highway MPG Sim Setup
self.sim_EPA_highway.velocity_str = 'vehicle.velocity'
self.sim_EPA_highway.throttle_str = 'vehicle.throttle'
self.sim_EPA_highway.gear_str = 'vehicle.current_gear'
self.sim_EPA_highway.acceleration_str = 'vehicle.acceleration'
self.sim_EPA_highway.fuel_burn_str = 'vehicle.fuel_burn'
self.sim_EPA_highway.overspeed_str = 'vehicle.overspeed'
self.sim_EPA_highway.underspeed_str = 'vehicle.underspeed'
self.sim_EPA_highway.profilename = 'EPA-highway.csv'
self.sim_EPA_highway.force_execute = True
if __name__ == "__main__": # pragma: no cover
# pylint: disable-msg=E1101
def prz(title):
""" Print before and after"""
print '---------------------------------'
print title
print '---------------------------------'
print 'Engine: Bore = ', opt_problem.vehicle.bore
print 'Engine: Spark Angle = ', opt_problem.vehicle.spark_angle
print '---------------------------------'
print '0-60 Accel Time = ', opt_problem.sim_acc.accel_time
print 'EPA City MPG = ', opt_problem.sim_EPA_city.fuel_economy
print 'EPA Highway MPG = ', opt_problem.sim_EPA_highway.fuel_economy
print '\n'
import time
opt_problem = EngineOptimization()
opt_problem.sim_acc.run()
opt_problem.sim_EPA_city.run()
opt_problem.sim_EPA_highway.run()
prz('Old Design')
tt = time.time()
opt_problem.run()
prz('New Design')
print "CONMIN Iterations: ", opt_problem.optimizer.iter_count
print ""
print "Elapsed time: ", time.time()-tt
# end engine_optimization.py
| [
1,
529,
9507,
29958,
19057,
29914,
3150,
29885,
1388,
29877,
29889,
19057,
29889,
996,
1312,
267,
647,
29914,
3150,
29885,
1388,
29877,
29914,
19057,
29914,
996,
1312,
267,
647,
29914,
10599,
29918,
20640,
2133,
29918,
29879,
3034,
357,
29889,
2272,
13,
15945,
29908,
13,
1678,
6012,
29918,
20640,
2133,
29889,
2272,
448,
7488,
3233,
11470,
363,
278,
1342,
1108,
29889,
13,
15945,
29908,
13,
13,
29937,
20693,
326,
675,
263,
8980,
29882,
2512,
2874,
411,
8707,
16173,
13,
13,
29937,
282,
2904,
524,
29901,
11262,
29899,
7645,
29922,
29923,
29900,
29953,
29896,
29896,
29892,
29943,
29900,
29946,
29900,
29896,
13,
3166,
1722,
29885,
1388,
29877,
29889,
3396,
29889,
2754,
1053,
13266,
13,
3166,
1722,
29885,
1388,
29877,
29889,
1982,
29889,
24477,
874,
29889,
2754,
1053,
8707,
16173,
9465,
13,
13,
3166,
1722,
29885,
1388,
29877,
29889,
19057,
29889,
996,
1312,
267,
647,
29889,
29881,
1150,
292,
29918,
3601,
1053,
3439,
7504,
7367,
362,
29892,
320,
13,
462,
462,
462,
539,
3439,
29923,
4599,
29891,
13,
3166,
1722,
29885,
1388,
29877,
29889,
19057,
29889,
996,
1312,
267,
647,
29889,
345,
29882,
2512,
1053,
8980,
29882,
2512,
13,
13,
1990,
10863,
20624,
326,
2133,
29898,
22400,
1125,
13,
1678,
9995,
20624,
326,
2133,
310,
263,
8980,
29882,
2512,
1213,
15945,
13,
268,
13,
1678,
822,
10822,
29898,
1311,
1125,
13,
13,
4706,
396,
282,
2904,
524,
29901,
11262,
29899,
7645,
29922,
29923,
29896,
29896,
29900,
29896,
13,
308,
13,
4706,
396,
6204,
8707,
16173,
20693,
326,
3950,
2777,
13,
4706,
1583,
29889,
1202,
877,
20640,
3950,
742,
8707,
16173,
9465,
3101,
13,
308,
13,
4706,
396,
6204,
8980,
29882,
2512,
2777,
13,
4706,
1583,
29889,
1202,
877,
345,
29882,
2512,
742,
8980,
29882,
2512,
3101,
13,
308,
13,
4706,
396,
6204,
360,
1150,
292,
3439,
2785,
8871,
13,
4706,
1583,
29889,
1202,
877,
3601,
29918,
5753,
742,
3439,
7504,
7367,
362,
3101,
13,
4706,
1583,
29889,
1202,
877,
3601,
29918,
29923,
7228,
29918,
12690,
742,
3439,
29923,
4599,
29891,
3101,
13,
4706,
1583,
29889,
1202,
877,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
742,
3439,
29923,
4599,
29891,
3101,
13,
308,
13,
4706,
396,
788,
278,
5994,
3950,
322,
26504,
1027,
29879,
304,
7156,
27321,
13,
4706,
1583,
29889,
9465,
29889,
1287,
1731,
29889,
1202,
18959,
20640,
3950,
742,
525,
3601,
29918,
29923,
7228,
29918,
12690,
742,
525,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
11287,
13,
308,
13,
4706,
396,
788,
278,
28178,
1027,
304,
278,
5994,
3950,
27321,
13,
4706,
1583,
29889,
20640,
3950,
29889,
1287,
1731,
29889,
1202,
877,
3601,
29918,
5753,
1495,
13,
308,
13,
4706,
396,
3462,
19716,
304,
1027,
27321,
29879,
29889,
13,
4706,
1583,
29889,
3601,
29918,
5753,
29889,
1287,
1731,
29889,
1202,
877,
345,
29882,
2512,
1495,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
1287,
1731,
29889,
1202,
877,
345,
29882,
2512,
1495,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
1287,
1731,
29889,
1202,
877,
345,
29882,
2512,
1495,
13,
268,
13,
4706,
396,
8707,
16173,
2379,
810,
13,
4706,
1583,
29889,
20640,
3950,
29889,
29875,
2158,
353,
29871,
29900,
13,
4706,
1583,
29889,
20640,
3950,
29889,
277,
3317,
353,
29871,
29941,
29900,
13,
308,
13,
4706,
396,
8707,
16173,
4669,
573,
29871,
13,
4706,
1583,
29889,
20640,
3950,
29889,
1202,
29918,
3318,
573,
877,
3601,
29918,
5753,
29889,
562,
2242,
29918,
2230,
1495,
13,
308,
13,
4706,
396,
8707,
16173,
12037,
9586,
1849,
29871,
13,
4706,
1583,
29889,
20640,
3950,
29889,
1202,
29918,
15501,
877,
345,
29882,
2512,
29889,
12597,
29918,
2521,
742,
448,
29945,
29900,
1696,
29871,
29896,
29900,
1846,
13,
4706,
1583,
29889,
20640,
3950,
29889,
1202,
29918,
15501,
877,
345,
29882,
2512,
29889,
29890,
487,
742,
29871,
29953,
29945,
1696,
29871,
29896,
29900,
29900,
1846,
13,
308,
13,
4706,
396,
4831,
7367,
362,
3439,
6230,
13,
4706,
1583,
29889,
3601,
29918,
5753,
29889,
955,
25245,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
955,
25245,
29915,
13,
4706,
1583,
29889,
3601,
29918,
5753,
29889,
386,
26970,
280,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
386,
26970,
280,
29915,
13,
4706,
1583,
29889,
3601,
29918,
5753,
29889,
479,
279,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
3784,
29918,
479,
279,
29915,
13,
4706,
1583,
29889,
3601,
29918,
5753,
29889,
562,
2242,
261,
362,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
562,
2242,
261,
362,
29915,
13,
4706,
1583,
29889,
3601,
29918,
5753,
29889,
29877,
874,
412,
287,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
29877,
874,
412,
287,
29915,
13,
308,
13,
4706,
396,
382,
7228,
4412,
16379,
29954,
3439,
3789,
786,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
955,
25245,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
955,
25245,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
386,
26970,
280,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
386,
26970,
280,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
479,
279,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
3784,
29918,
479,
279,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
562,
2242,
261,
362,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
562,
2242,
261,
362,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
29888,
2491,
29918,
18712,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
29888,
2491,
29918,
18712,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
29877,
874,
412,
287,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
29877,
874,
412,
287,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
870,
414,
412,
287,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
870,
414,
412,
287,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
771,
9507,
353,
525,
29923,
7228,
29899,
12690,
29889,
7638,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
10118,
29918,
7978,
353,
5852,
13,
308,
13,
4706,
396,
382,
7228,
22080,
16379,
29954,
3439,
3789,
786,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
955,
25245,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
955,
25245,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
386,
26970,
280,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
386,
26970,
280,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
479,
279,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
3784,
29918,
479,
279,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
562,
2242,
261,
362,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
562,
2242,
261,
362,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
29888,
2491,
29918,
18712,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
29888,
2491,
29918,
18712,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
29877,
874,
412,
287,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
29877,
874,
412,
287,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
870,
414,
412,
287,
29918,
710,
353,
525,
345,
29882,
2512,
29889,
870,
414,
412,
287,
29915,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
771,
9507,
353,
525,
29923,
7228,
29899,
9812,
1582,
29889,
7638,
29915,
308,
13,
4706,
1583,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
10118,
29918,
7978,
353,
5852,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
396,
282,
23929,
29901,
694,
4612,
3986,
13,
13,
1678,
396,
282,
2904,
524,
29901,
11262,
29899,
7645,
29922,
29923,
29896,
29896,
29900,
29896,
13,
13,
1678,
822,
5629,
29898,
3257,
1125,
13,
4706,
9995,
13905,
1434,
322,
1156,
15945,
29908,
13,
308,
13,
4706,
1596,
525,
2683,
2683,
29899,
29915,
13,
4706,
1596,
3611,
13,
4706,
1596,
525,
2683,
2683,
29899,
29915,
13,
4706,
1596,
525,
12412,
29901,
350,
487,
353,
13420,
3523,
29918,
17199,
29889,
345,
29882,
2512,
29889,
29890,
487,
13,
4706,
1596,
525,
12412,
29901,
20814,
3218,
280,
353,
13420,
3523,
29918,
17199,
29889,
345,
29882,
2512,
29889,
12597,
29918,
2521,
13,
4706,
1596,
525,
2683,
2683,
29899,
29915,
13,
4706,
1596,
525,
29900,
29899,
29953,
29900,
4831,
295,
5974,
353,
13420,
3523,
29918,
17199,
29889,
3601,
29918,
5753,
29889,
562,
2242,
29918,
2230,
13,
4706,
1596,
525,
29923,
7228,
4412,
16379,
29954,
353,
13420,
3523,
29918,
17199,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
29888,
2491,
29918,
29872,
4599,
29891,
13,
4706,
1596,
525,
29923,
7228,
22080,
16379,
29954,
353,
13420,
3523,
29918,
17199,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
29888,
2491,
29918,
29872,
4599,
29891,
13,
4706,
1596,
11297,
29876,
29915,
13,
268,
13,
13,
1678,
1053,
931,
13,
268,
13,
1678,
3523,
29918,
17199,
353,
10863,
20624,
326,
2133,
580,
13,
268,
13,
1678,
3523,
29918,
17199,
29889,
3601,
29918,
5753,
29889,
3389,
580,
13,
1678,
3523,
29918,
17199,
29889,
3601,
29918,
29923,
7228,
29918,
12690,
29889,
3389,
580,
13,
1678,
3523,
29918,
17199,
29889,
3601,
29918,
29923,
7228,
29918,
9812,
1582,
29889,
3389,
580,
13,
1678,
5629,
877,
21648,
12037,
1495,
13,
13,
1678,
260,
29873,
353,
931,
29889,
2230,
580,
13,
1678,
3523,
29918,
17199,
29889,
3389,
580,
13,
1678,
5629,
877,
4373,
12037,
1495,
13,
1678,
1596,
376,
6007,
16173,
20504,
800,
29901,
9162,
3523,
29918,
17199,
29889,
20640,
3950,
29889,
1524,
29918,
2798,
13,
1678,
1596,
5124,
13,
1678,
1596,
376,
29923,
23384,
931,
29901,
9162,
931,
29889,
2230,
580,
29899,
698,
13,
268,
13,
29937,
1095,
6012,
29918,
20640,
2133,
29889,
2272,
13,
2
] |
tests/test_asyncio.py | SouvikGhosh05/aioquic | 0 | 129743 | <reponame>SouvikGhosh05/aioquic
import asyncio
import binascii
import contextlib
import random
import socket
from unittest import TestCase, skipIf
from unittest.mock import patch
from cryptography.hazmat.primitives import serialization
from aioquic.asyncio.client import connect
from aioquic.asyncio.protocol import QuicConnectionProtocol
from aioquic.asyncio.server import serve
from aioquic.quic.configuration import QuicConfiguration
from aioquic.quic.logger import QuicLogger
from .utils import (
SERVER_CACERTFILE,
SERVER_CERTFILE,
SERVER_COMBINEDFILE,
SERVER_KEYFILE,
SKIP_TESTS,
asynctest,
generate_ec_certificate,
generate_ed448_certificate,
generate_ed25519_certificate,
)
real_sendto = socket.socket.sendto
def sendto_with_loss(self, data, addr=None):
"""
Simulate 25% packet loss.
"""
if random.random() > 0.25:
real_sendto(self, data, addr)
class SessionTicketStore:
def __init__(self):
self.tickets = {}
def add(self, ticket):
self.tickets[ticket.ticket] = ticket
def pop(self, label):
return self.tickets.pop(label, None)
def handle_stream(reader, writer):
async def serve():
data = await reader.read()
writer.write(bytes(reversed(data)))
writer.write_eof()
asyncio.ensure_future(serve())
class HighLevelTest(TestCase):
def setUp(self):
self.bogus_port = 1024
self.server_host = "localhost"
async def run_client(
self,
*,
port: int,
host=None,
cadata=None,
cafile=SERVER_CACERTFILE,
configuration=None,
request=b"ping",
**kwargs
):
if host is None:
host = self.server_host
if configuration is None:
configuration = QuicConfiguration(is_client=True)
configuration.load_verify_locations(cadata=cadata, cafile=cafile)
async with connect(host, port, configuration=configuration, **kwargs) as client:
# waiting for connected when connected returns immediately
await client.wait_connected()
reader, writer = await client.create_stream()
self.assertEqual(writer.can_write_eof(), True)
self.assertEqual(writer.get_extra_info("stream_id"), 0)
writer.write(request)
writer.write_eof()
response = await reader.read()
# waiting for closed when closed returns immediately
await client.wait_closed()
return response
@contextlib.asynccontextmanager
async def run_server(self, configuration=None, host="::", **kwargs):
if configuration is None:
configuration = QuicConfiguration(is_client=False)
configuration.load_cert_chain(SERVER_CERTFILE, SERVER_KEYFILE)
server = await serve(
host=host,
port=0,
configuration=configuration,
stream_handler=handle_stream,
**kwargs
)
try:
yield server._transport.get_extra_info("sockname")[1]
finally:
server.close()
@asynctest
async def test_connect_and_serve(self):
async with self.run_server() as server_port:
response = await self.run_client(port=server_port)
self.assertEqual(response, b"gnip")
@asynctest
async def test_connect_and_serve_ipv4(self):
async with self.run_server(host="0.0.0.0") as server_port:
response = await self.run_client(host="127.0.0.1", port=server_port)
self.assertEqual(response, b"gnip")
@skipIf("ipv6" in SKIP_TESTS, "Skipping IPv6 tests")
@asynctest
async def test_connect_and_serve_ipv6(self):
async with self.run_server(host="::") as server_port:
response = await self.run_client(host="::1", port=server_port)
self.assertEqual(response, b"gnip")
async def _test_connect_and_serve_with_certificate(self, certificate, private_key):
async with self.run_server(
configuration=QuicConfiguration(
certificate=certificate,
private_key=private_key,
is_client=False,
)
) as server_port:
response = await self.run_client(
cadata=certificate.public_bytes(serialization.Encoding.PEM),
cafile=None,
port=server_port,
)
self.assertEqual(response, b"gnip")
@asynctest
async def test_connect_and_serve_with_ec_certificate(self):
await self._test_connect_and_serve_with_certificate(
*generate_ec_certificate(common_name="localhost")
)
@asynctest
async def test_connect_and_serve_with_ed25519_certificate(self):
await self._test_connect_and_serve_with_certificate(
*generate_ed25519_certificate(common_name="localhost")
)
@asynctest
async def test_connect_and_serve_with_ed448_certificate(self):
await self._test_connect_and_serve_with_certificate(
*generate_ed448_certificate(common_name="localhost")
)
@asynctest
async def test_connect_and_serve_large(self):
"""
Transfer enough data to require raising MAX_DATA and MAX_STREAM_DATA.
"""
data = b"Z" * 2097152
async with self.run_server() as server_port:
response = await self.run_client(port=server_port, request=data)
self.assertEqual(response, data)
@asynctest
async def test_connect_and_serve_without_client_configuration(self):
async with self.run_server() as server_port:
with self.assertRaises(ConnectionError):
async with connect(self.server_host, server_port) as client:
await client.ping()
@asynctest
async def test_connect_and_serve_writelines(self):
async with self.run_server() as server_port:
configuration = QuicConfiguration(is_client=True)
configuration.load_verify_locations(cafile=SERVER_CACERTFILE)
async with connect(
self.server_host, server_port, configuration=configuration
) as client:
reader, writer = await client.create_stream()
assert writer.can_write_eof() is True
writer.writelines([b"01234567", b"89012345"])
writer.write_eof()
response = await reader.read()
self.assertEqual(response, b"5432109876543210")
@skipIf("loss" in SKIP_TESTS, "Skipping loss tests")
@patch("socket.socket.sendto", new_callable=lambda: sendto_with_loss)
@asynctest
async def test_connect_and_serve_with_packet_loss(self, mock_sendto):
"""
This test ensures handshake success and stream data is successfully sent
and received in the presence of packet loss (randomized 25% in each direction).
"""
data = b"Z" * 65536
server_configuration = QuicConfiguration(
is_client=False, quic_logger=QuicLogger()
)
server_configuration.load_cert_chain(SERVER_CERTFILE, SERVER_KEYFILE)
async with self.run_server(configuration=server_configuration) as server_port:
response = await self.run_client(
configuration=QuicConfiguration(
is_client=True, quic_logger=QuicLogger()
),
port=server_port,
request=data,
)
self.assertEqual(response, data)
@asynctest
async def test_connect_and_serve_with_session_ticket(self):
client_ticket = None
store = SessionTicketStore()
def save_ticket(t):
nonlocal client_ticket
client_ticket = t
async with self.run_server(
session_ticket_fetcher=store.pop, session_ticket_handler=store.add
) as server_port:
# first request
response = await self.run_client(
port=server_port, session_ticket_handler=save_ticket
)
self.assertEqual(response, b"gnip")
self.assertIsNotNone(client_ticket)
# second request
response = await self.run_client(
configuration=QuicConfiguration(
is_client=True, session_ticket=client_ticket
),
port=server_port,
)
self.assertEqual(response, b"gnip")
@asynctest
async def test_connect_and_serve_with_retry(self):
async with self.run_server(retry=True) as server_port:
response = await self.run_client(port=server_port)
self.assertEqual(response, b"gnip")
@asynctest
async def test_connect_and_serve_with_retry_bad_original_destination_connection_id(
self,
):
"""
If the server's transport parameters do not have the correct
original_destination_connection_id the connection must fail.
"""
def create_protocol(*args, **kwargs):
protocol = QuicConnectionProtocol(*args, **kwargs)
protocol._quic._original_destination_connection_id = None
return protocol
async with self.run_server(
create_protocol=create_protocol, retry=True
) as server_port:
with self.assertRaises(ConnectionError):
await self.run_client(port=server_port)
@asynctest
async def test_connect_and_serve_with_retry_bad_retry_source_connection_id(self):
"""
If the server's transport parameters do not have the correct
retry_source_connection_id the connection must fail.
"""
def create_protocol(*args, **kwargs):
protocol = QuicConnectionProtocol(*args, **kwargs)
protocol._quic._retry_source_connection_id = None
return protocol
async with self.run_server(
create_protocol=create_protocol, retry=True
) as server_port:
with self.assertRaises(ConnectionError):
await self.run_client(port=server_port)
@patch("aioquic.quic.retry.QuicRetryTokenHandler.validate_token")
@asynctest
async def test_connect_and_serve_with_retry_bad_token(self, mock_validate):
mock_validate.side_effect = ValueError("Decryption failed.")
async with self.run_server(retry=True) as server_port:
with self.assertRaises(ConnectionError):
await self.run_client(
configuration=QuicConfiguration(is_client=True, idle_timeout=4.0),
port=server_port,
)
@asynctest
async def test_connect_and_serve_with_version_negotiation(self):
async with self.run_server() as server_port:
# force version negotiation
configuration = QuicConfiguration(is_client=True, quic_logger=QuicLogger())
configuration.supported_versions.insert(0, 0x1A2A3A4A)
response = await self.run_client(
configuration=configuration, port=server_port
)
self.assertEqual(response, b"gnip")
@asynctest
async def test_connect_timeout(self):
with self.assertRaises(ConnectionError):
await self.run_client(
port=self.bogus_port,
configuration=QuicConfiguration(is_client=True, idle_timeout=5),
)
@asynctest
async def test_connect_timeout_no_wait_connected(self):
with self.assertRaises(ConnectionError):
configuration = QuicConfiguration(is_client=True, idle_timeout=5)
configuration.load_verify_locations(cafile=SERVER_CACERTFILE)
async with connect(
self.server_host,
self.bogus_port,
configuration=configuration,
wait_connected=False,
) as client:
await client.ping()
@asynctest
async def test_connect_local_port(self):
async with self.run_server() as server_port:
response = await self.run_client(local_port=3456, port=server_port)
self.assertEqual(response, b"gnip")
@asynctest
async def test_change_connection_id(self):
async with self.run_server() as server_port:
configuration = QuicConfiguration(is_client=True)
configuration.load_verify_locations(cafile=SERVER_CACERTFILE)
async with connect(
self.server_host, server_port, configuration=configuration
) as client:
await client.ping()
client.change_connection_id()
await client.ping()
@asynctest
async def test_key_update(self):
async with self.run_server() as server_port:
configuration = QuicConfiguration(is_client=True)
configuration.load_verify_locations(cafile=SERVER_CACERTFILE)
async with connect(
self.server_host, server_port, configuration=configuration
) as client:
await client.ping()
client.request_key_update()
await client.ping()
@asynctest
async def test_ping(self):
async with self.run_server() as server_port:
configuration = QuicConfiguration(is_client=True)
configuration.load_verify_locations(cafile=SERVER_CACERTFILE)
async with connect(
self.server_host, server_port, configuration=configuration
) as client:
await client.ping()
await client.ping()
@asynctest
async def test_ping_parallel(self):
async with self.run_server() as server_port:
configuration = QuicConfiguration(is_client=True)
configuration.load_verify_locations(cafile=SERVER_CACERTFILE)
async with connect(
self.server_host, server_port, configuration=configuration
) as client:
coros = [client.ping() for x in range(16)]
await asyncio.gather(*coros)
@asynctest
async def test_server_receives_garbage(self):
configuration = QuicConfiguration(is_client=False)
configuration.load_cert_chain(SERVER_CERTFILE, SERVER_KEYFILE)
server = await serve(
host=self.server_host,
port=0,
configuration=configuration,
)
server.datagram_received(binascii.unhexlify("c00000000080"), ("172.16.31.10", 1234))
server.close()
@asynctest
async def test_combined_key(self):
config1 = QuicConfiguration()
config2 = QuicConfiguration()
config1.load_cert_chain(SERVER_CERTFILE, SERVER_KEYFILE)
config2.load_cert_chain(SERVER_COMBINEDFILE)
self.assertEqual(config1.certificate, config2.certificate)
| [
1,
529,
276,
1112,
420,
29958,
29903,
5128,
638,
29954,
29882,
10578,
29900,
29945,
29914,
29874,
601,
339,
293,
13,
5215,
408,
948,
3934,
13,
5215,
9016,
294,
18869,
13,
5215,
3030,
1982,
13,
5215,
4036,
13,
5215,
9909,
13,
3166,
443,
27958,
1053,
4321,
8259,
29892,
14383,
3644,
13,
3166,
443,
27958,
29889,
17640,
1053,
13261,
13,
13,
3166,
24941,
5275,
29889,
29882,
834,
2922,
29889,
9469,
277,
3145,
1053,
7797,
2133,
13,
13,
3166,
263,
601,
339,
293,
29889,
294,
948,
3934,
29889,
4645,
1053,
4511,
13,
3166,
263,
601,
339,
293,
29889,
294,
948,
3934,
29889,
20464,
1053,
751,
293,
5350,
17830,
13,
3166,
263,
601,
339,
293,
29889,
294,
948,
3934,
29889,
2974,
1053,
9080,
13,
3166,
263,
601,
339,
293,
29889,
339,
293,
29889,
13305,
1053,
751,
293,
8614,
13,
3166,
263,
601,
339,
293,
29889,
339,
293,
29889,
21707,
1053,
751,
293,
16363,
13,
13,
3166,
869,
13239,
1053,
313,
13,
1678,
26996,
5348,
29918,
29907,
2477,
20161,
7724,
29892,
13,
1678,
26996,
5348,
29918,
29907,
20161,
7724,
29892,
13,
1678,
26996,
5348,
29918,
3217,
9486,
1177,
3352,
7724,
29892,
13,
1678,
26996,
5348,
29918,
10818,
7724,
29892,
13,
1678,
18581,
5690,
29918,
18267,
29903,
29892,
13,
1678,
408,
948,
312,
342,
29892,
13,
1678,
5706,
29918,
687,
29918,
6327,
8021,
29892,
13,
1678,
5706,
29918,
287,
29946,
29946,
29947,
29918,
6327,
8021,
29892,
13,
1678,
5706,
29918,
287,
29906,
29945,
29945,
29896,
29929,
29918,
6327,
8021,
29892,
13,
29897,
13,
13,
6370,
29918,
6717,
517,
353,
9909,
29889,
11514,
29889,
6717,
517,
13,
13,
13,
1753,
3638,
517,
29918,
2541,
29918,
6758,
29898,
1311,
29892,
848,
29892,
28915,
29922,
8516,
1125,
13,
1678,
9995,
13,
1678,
3439,
5987,
29871,
29906,
29945,
29995,
18203,
6410,
29889,
13,
1678,
9995,
13,
1678,
565,
4036,
29889,
8172,
580,
1405,
29871,
29900,
29889,
29906,
29945,
29901,
13,
4706,
1855,
29918,
6717,
517,
29898,
1311,
29892,
848,
29892,
28915,
29897,
13,
13,
13,
1990,
16441,
29911,
8522,
9044,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
24667,
1691,
353,
6571,
13,
13,
1678,
822,
788,
29898,
1311,
29892,
23381,
1125,
13,
4706,
1583,
29889,
24667,
1691,
29961,
29873,
8522,
29889,
29873,
8522,
29962,
353,
23381,
13,
13,
1678,
822,
1835,
29898,
1311,
29892,
3858,
1125,
13,
4706,
736,
1583,
29889,
24667,
1691,
29889,
7323,
29898,
1643,
29892,
6213,
29897,
13,
13,
13,
1753,
4386,
29918,
5461,
29898,
16950,
29892,
9227,
1125,
13,
1678,
7465,
822,
9080,
7295,
13,
4706,
848,
353,
7272,
9591,
29889,
949,
580,
13,
4706,
9227,
29889,
3539,
29898,
13193,
29898,
276,
874,
287,
29898,
1272,
4961,
13,
4706,
9227,
29889,
3539,
29918,
29872,
974,
580,
13,
13,
1678,
408,
948,
3934,
29889,
7469,
29918,
29888,
9130,
29898,
16349,
3101,
13,
13,
13,
1990,
5057,
10108,
3057,
29898,
3057,
8259,
1125,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
4706,
1583,
29889,
29890,
468,
375,
29918,
637,
353,
29871,
29896,
29900,
29906,
29946,
13,
4706,
1583,
29889,
2974,
29918,
3069,
353,
376,
7640,
29908,
13,
13,
1678,
7465,
822,
1065,
29918,
4645,
29898,
13,
4706,
1583,
29892,
13,
4706,
334,
29892,
13,
4706,
2011,
29901,
938,
29892,
13,
4706,
3495,
29922,
8516,
29892,
13,
4706,
274,
7221,
29922,
8516,
29892,
13,
4706,
5777,
1445,
29922,
18603,
29918,
29907,
2477,
20161,
7724,
29892,
13,
4706,
5285,
29922,
8516,
29892,
13,
4706,
2009,
29922,
29890,
29908,
15702,
613,
13,
4706,
3579,
19290,
13,
268,
1125,
13,
4706,
565,
3495,
338,
6213,
29901,
13,
9651,
3495,
353,
1583,
29889,
2974,
29918,
3069,
13,
4706,
565,
5285,
338,
6213,
29901,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29897,
13,
4706,
5285,
29889,
1359,
29918,
27902,
29918,
2029,
800,
29898,
29883,
7221,
29922,
29883,
7221,
29892,
5777,
1445,
29922,
1113,
1445,
29897,
13,
4706,
7465,
411,
4511,
29898,
3069,
29892,
2011,
29892,
5285,
29922,
13305,
29892,
3579,
19290,
29897,
408,
3132,
29901,
13,
9651,
396,
10534,
363,
6631,
746,
6631,
3639,
7389,
13,
9651,
7272,
3132,
29889,
10685,
29918,
18045,
580,
13,
13,
9651,
9591,
29892,
9227,
353,
7272,
3132,
29889,
3258,
29918,
5461,
580,
13,
9651,
1583,
29889,
9294,
9843,
29898,
13236,
29889,
3068,
29918,
3539,
29918,
29872,
974,
3285,
5852,
29897,
13,
9651,
1583,
29889,
9294,
9843,
29898,
13236,
29889,
657,
29918,
17833,
29918,
3888,
703,
5461,
29918,
333,
4968,
29871,
29900,
29897,
13,
13,
9651,
9227,
29889,
3539,
29898,
3827,
29897,
13,
9651,
9227,
29889,
3539,
29918,
29872,
974,
580,
13,
13,
9651,
2933,
353,
7272,
9591,
29889,
949,
580,
13,
13,
4706,
396,
10534,
363,
5764,
746,
5764,
3639,
7389,
13,
4706,
7272,
3132,
29889,
10685,
29918,
15603,
580,
13,
13,
4706,
736,
2933,
13,
13,
1678,
732,
4703,
1982,
29889,
12674,
4703,
12847,
13,
1678,
7465,
822,
1065,
29918,
2974,
29898,
1311,
29892,
5285,
29922,
8516,
29892,
3495,
543,
1057,
613,
3579,
19290,
1125,
13,
4706,
565,
5285,
338,
6213,
29901,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
8824,
29897,
13,
9651,
5285,
29889,
1359,
29918,
6327,
29918,
14153,
29898,
18603,
29918,
29907,
20161,
7724,
29892,
26996,
5348,
29918,
10818,
7724,
29897,
13,
4706,
1923,
353,
7272,
9080,
29898,
13,
9651,
3495,
29922,
3069,
29892,
13,
9651,
2011,
29922,
29900,
29892,
13,
9651,
5285,
29922,
13305,
29892,
13,
9651,
4840,
29918,
13789,
29922,
8411,
29918,
5461,
29892,
13,
9651,
3579,
19290,
13,
4706,
1723,
13,
4706,
1018,
29901,
13,
9651,
7709,
1923,
3032,
27882,
29889,
657,
29918,
17833,
29918,
3888,
703,
21852,
978,
1159,
29961,
29896,
29962,
13,
4706,
7146,
29901,
13,
9651,
1923,
29889,
5358,
580,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
637,
29922,
2974,
29918,
637,
29897,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
666,
29894,
29946,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
3069,
543,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
1159,
408,
1923,
29918,
637,
29901,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
3069,
543,
29896,
29906,
29955,
29889,
29900,
29889,
29900,
29889,
29896,
613,
2011,
29922,
2974,
29918,
637,
29897,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
1678,
732,
11014,
3644,
703,
666,
29894,
29953,
29908,
297,
18581,
5690,
29918,
18267,
29903,
29892,
376,
29903,
1984,
3262,
5641,
29894,
29953,
6987,
1159,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
666,
29894,
29953,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
3069,
543,
1057,
1159,
408,
1923,
29918,
637,
29901,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
3069,
543,
1057,
29896,
613,
2011,
29922,
2974,
29918,
637,
29897,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
1678,
7465,
822,
903,
1688,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
6327,
8021,
29898,
1311,
29892,
12289,
29892,
2024,
29918,
1989,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
13,
9651,
5285,
29922,
2182,
293,
8614,
29898,
13,
18884,
12289,
29922,
6327,
8021,
29892,
13,
18884,
2024,
29918,
1989,
29922,
9053,
29918,
1989,
29892,
13,
18884,
338,
29918,
4645,
29922,
8824,
29892,
13,
9651,
1723,
13,
4706,
1723,
408,
1923,
29918,
637,
29901,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
13,
18884,
274,
7221,
29922,
6327,
8021,
29889,
3597,
29918,
13193,
29898,
15550,
2133,
29889,
14934,
29889,
4162,
29924,
511,
13,
18884,
5777,
1445,
29922,
8516,
29892,
13,
18884,
2011,
29922,
2974,
29918,
637,
29892,
13,
9651,
1723,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
687,
29918,
6327,
8021,
29898,
1311,
1125,
13,
4706,
7272,
1583,
3032,
1688,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
6327,
8021,
29898,
13,
9651,
334,
17158,
29918,
687,
29918,
6327,
8021,
29898,
9435,
29918,
978,
543,
7640,
1159,
13,
4706,
1723,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
287,
29906,
29945,
29945,
29896,
29929,
29918,
6327,
8021,
29898,
1311,
1125,
13,
4706,
7272,
1583,
3032,
1688,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
6327,
8021,
29898,
13,
9651,
334,
17158,
29918,
287,
29906,
29945,
29945,
29896,
29929,
29918,
6327,
8021,
29898,
9435,
29918,
978,
543,
7640,
1159,
13,
4706,
1723,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
287,
29946,
29946,
29947,
29918,
6327,
8021,
29898,
1311,
1125,
13,
4706,
7272,
1583,
3032,
1688,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
6327,
8021,
29898,
13,
9651,
334,
17158,
29918,
287,
29946,
29946,
29947,
29918,
6327,
8021,
29898,
9435,
29918,
978,
543,
7640,
1159,
13,
4706,
1723,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
16961,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
17934,
3307,
848,
304,
1996,
29263,
18134,
29918,
14573,
322,
18134,
29918,
1254,
1525,
5194,
29918,
14573,
29889,
13,
4706,
9995,
13,
4706,
848,
353,
289,
29908,
29999,
29908,
334,
29871,
29906,
29900,
29929,
29955,
29896,
29945,
29906,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
637,
29922,
2974,
29918,
637,
29892,
2009,
29922,
1272,
29897,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
848,
29897,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
14037,
29918,
4645,
29918,
13305,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
411,
1583,
29889,
9294,
29934,
1759,
267,
29898,
5350,
2392,
1125,
13,
18884,
7465,
411,
4511,
29898,
1311,
29889,
2974,
29918,
3069,
29892,
1923,
29918,
637,
29897,
408,
3132,
29901,
13,
462,
1678,
7272,
3132,
29889,
15702,
580,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
8231,
24210,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29897,
13,
9651,
5285,
29889,
1359,
29918,
27902,
29918,
2029,
800,
29898,
1113,
1445,
29922,
18603,
29918,
29907,
2477,
20161,
7724,
29897,
13,
9651,
7465,
411,
4511,
29898,
13,
18884,
1583,
29889,
2974,
29918,
3069,
29892,
1923,
29918,
637,
29892,
5285,
29922,
13305,
13,
9651,
1723,
408,
3132,
29901,
13,
18884,
9591,
29892,
9227,
353,
7272,
3132,
29889,
3258,
29918,
5461,
580,
13,
18884,
4974,
9227,
29889,
3068,
29918,
3539,
29918,
29872,
974,
580,
338,
5852,
13,
13,
18884,
9227,
29889,
8231,
24210,
4197,
29890,
29908,
29900,
29896,
29906,
29941,
29946,
29945,
29953,
29955,
613,
289,
29908,
29947,
29929,
29900,
29896,
29906,
29941,
29946,
29945,
20068,
13,
18884,
9227,
29889,
3539,
29918,
29872,
974,
580,
13,
13,
18884,
2933,
353,
7272,
9591,
29889,
949,
580,
13,
18884,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
29945,
29946,
29941,
29906,
29896,
29900,
29929,
29947,
29955,
29953,
29945,
29946,
29941,
29906,
29896,
29900,
1159,
13,
13,
1678,
732,
11014,
3644,
703,
6758,
29908,
297,
18581,
5690,
29918,
18267,
29903,
29892,
376,
29903,
1984,
3262,
6410,
6987,
1159,
13,
1678,
732,
5041,
703,
11514,
29889,
11514,
29889,
6717,
517,
613,
716,
29918,
4804,
519,
29922,
2892,
29901,
3638,
517,
29918,
2541,
29918,
6758,
29897,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
4058,
300,
29918,
6758,
29898,
1311,
29892,
11187,
29918,
6717,
517,
1125,
13,
4706,
9995,
13,
4706,
910,
1243,
5662,
1973,
1361,
845,
1296,
2551,
322,
4840,
848,
338,
8472,
2665,
13,
4706,
322,
4520,
297,
278,
10122,
310,
18203,
6410,
313,
8172,
1891,
29871,
29906,
29945,
29995,
297,
1269,
5305,
467,
13,
4706,
9995,
13,
4706,
848,
353,
289,
29908,
29999,
29908,
334,
29871,
29953,
29945,
29945,
29941,
29953,
13,
13,
4706,
1923,
29918,
13305,
353,
751,
293,
8614,
29898,
13,
9651,
338,
29918,
4645,
29922,
8824,
29892,
439,
293,
29918,
21707,
29922,
2182,
293,
16363,
580,
13,
4706,
1723,
13,
4706,
1923,
29918,
13305,
29889,
1359,
29918,
6327,
29918,
14153,
29898,
18603,
29918,
29907,
20161,
7724,
29892,
26996,
5348,
29918,
10818,
7724,
29897,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
13305,
29922,
2974,
29918,
13305,
29897,
408,
1923,
29918,
637,
29901,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
13,
18884,
5285,
29922,
2182,
293,
8614,
29898,
13,
462,
1678,
338,
29918,
4645,
29922,
5574,
29892,
439,
293,
29918,
21707,
29922,
2182,
293,
16363,
580,
13,
18884,
10353,
13,
18884,
2011,
29922,
2974,
29918,
637,
29892,
13,
18884,
2009,
29922,
1272,
29892,
13,
9651,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
848,
29897,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
7924,
29918,
29873,
8522,
29898,
1311,
1125,
13,
4706,
3132,
29918,
29873,
8522,
353,
6213,
13,
4706,
3787,
353,
16441,
29911,
8522,
9044,
580,
13,
13,
4706,
822,
4078,
29918,
29873,
8522,
29898,
29873,
1125,
13,
9651,
1661,
2997,
3132,
29918,
29873,
8522,
13,
9651,
3132,
29918,
29873,
8522,
353,
260,
13,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
13,
9651,
4867,
29918,
29873,
8522,
29918,
9155,
261,
29922,
8899,
29889,
7323,
29892,
4867,
29918,
29873,
8522,
29918,
13789,
29922,
8899,
29889,
1202,
13,
4706,
1723,
408,
1923,
29918,
637,
29901,
13,
13,
9651,
396,
937,
2009,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
13,
18884,
2011,
29922,
2974,
29918,
637,
29892,
4867,
29918,
29873,
8522,
29918,
13789,
29922,
7620,
29918,
29873,
8522,
13,
9651,
1723,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
9651,
1583,
29889,
9294,
3624,
3664,
8516,
29898,
4645,
29918,
29873,
8522,
29897,
13,
13,
9651,
396,
1473,
2009,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
13,
18884,
5285,
29922,
2182,
293,
8614,
29898,
13,
462,
1678,
338,
29918,
4645,
29922,
5574,
29892,
4867,
29918,
29873,
8522,
29922,
4645,
29918,
29873,
8522,
13,
18884,
10353,
13,
18884,
2011,
29922,
2974,
29918,
637,
29892,
13,
9651,
1723,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
276,
2202,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
276,
2202,
29922,
5574,
29897,
408,
1923,
29918,
637,
29901,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
637,
29922,
2974,
29918,
637,
29897,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
276,
2202,
29918,
12313,
29918,
13492,
29918,
23848,
29918,
9965,
29918,
333,
29898,
13,
4706,
1583,
29892,
13,
268,
1125,
13,
4706,
9995,
13,
4706,
960,
278,
1923,
29915,
29879,
8608,
4128,
437,
451,
505,
278,
1959,
13,
4706,
2441,
29918,
23848,
29918,
9965,
29918,
333,
278,
3957,
1818,
4418,
29889,
13,
4706,
9995,
13,
13,
4706,
822,
1653,
29918,
20464,
10456,
5085,
29892,
3579,
19290,
1125,
13,
9651,
9608,
353,
751,
293,
5350,
17830,
10456,
5085,
29892,
3579,
19290,
29897,
13,
9651,
9608,
3032,
339,
293,
3032,
13492,
29918,
23848,
29918,
9965,
29918,
333,
353,
6213,
13,
9651,
736,
9608,
13,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
13,
9651,
1653,
29918,
20464,
29922,
3258,
29918,
20464,
29892,
337,
2202,
29922,
5574,
13,
4706,
1723,
408,
1923,
29918,
637,
29901,
13,
9651,
411,
1583,
29889,
9294,
29934,
1759,
267,
29898,
5350,
2392,
1125,
13,
18884,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
637,
29922,
2974,
29918,
637,
29897,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
276,
2202,
29918,
12313,
29918,
276,
2202,
29918,
4993,
29918,
9965,
29918,
333,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
960,
278,
1923,
29915,
29879,
8608,
4128,
437,
451,
505,
278,
1959,
13,
4706,
337,
2202,
29918,
4993,
29918,
9965,
29918,
333,
278,
3957,
1818,
4418,
29889,
13,
4706,
9995,
13,
13,
4706,
822,
1653,
29918,
20464,
10456,
5085,
29892,
3579,
19290,
1125,
13,
9651,
9608,
353,
751,
293,
5350,
17830,
10456,
5085,
29892,
3579,
19290,
29897,
13,
9651,
9608,
3032,
339,
293,
3032,
276,
2202,
29918,
4993,
29918,
9965,
29918,
333,
353,
6213,
13,
9651,
736,
9608,
13,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
13,
9651,
1653,
29918,
20464,
29922,
3258,
29918,
20464,
29892,
337,
2202,
29922,
5574,
13,
4706,
1723,
408,
1923,
29918,
637,
29901,
13,
9651,
411,
1583,
29889,
9294,
29934,
1759,
267,
29898,
5350,
2392,
1125,
13,
18884,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
637,
29922,
2974,
29918,
637,
29897,
13,
13,
1678,
732,
5041,
703,
29874,
601,
339,
293,
29889,
339,
293,
29889,
276,
2202,
29889,
2182,
293,
8015,
719,
6066,
4598,
29889,
15480,
29918,
6979,
1159,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
276,
2202,
29918,
12313,
29918,
6979,
29898,
1311,
29892,
11187,
29918,
15480,
1125,
13,
4706,
11187,
29918,
15480,
29889,
2975,
29918,
15987,
353,
7865,
2392,
703,
6185,
14272,
5229,
23157,
13,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
29898,
276,
2202,
29922,
5574,
29897,
408,
1923,
29918,
637,
29901,
13,
9651,
411,
1583,
29889,
9294,
29934,
1759,
267,
29898,
5350,
2392,
1125,
13,
18884,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
13,
462,
1678,
5285,
29922,
2182,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29892,
28132,
29918,
15619,
29922,
29946,
29889,
29900,
511,
13,
462,
1678,
2011,
29922,
2974,
29918,
637,
29892,
13,
18884,
1723,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
392,
29918,
16349,
29918,
2541,
29918,
3259,
29918,
10052,
327,
11685,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
396,
4889,
1873,
3480,
327,
11685,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29892,
439,
293,
29918,
21707,
29922,
2182,
293,
16363,
3101,
13,
9651,
5285,
29889,
23765,
29918,
26100,
29889,
7851,
29898,
29900,
29892,
29871,
29900,
29916,
29896,
29909,
29906,
29909,
29941,
29909,
29946,
29909,
29897,
13,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
13,
18884,
5285,
29922,
13305,
29892,
2011,
29922,
2974,
29918,
637,
13,
9651,
1723,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
15619,
29898,
1311,
1125,
13,
4706,
411,
1583,
29889,
9294,
29934,
1759,
267,
29898,
5350,
2392,
1125,
13,
9651,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
13,
18884,
2011,
29922,
1311,
29889,
29890,
468,
375,
29918,
637,
29892,
13,
18884,
5285,
29922,
2182,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29892,
28132,
29918,
15619,
29922,
29945,
511,
13,
9651,
1723,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
15619,
29918,
1217,
29918,
10685,
29918,
18045,
29898,
1311,
1125,
13,
4706,
411,
1583,
29889,
9294,
29934,
1759,
267,
29898,
5350,
2392,
1125,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29892,
28132,
29918,
15619,
29922,
29945,
29897,
13,
9651,
5285,
29889,
1359,
29918,
27902,
29918,
2029,
800,
29898,
1113,
1445,
29922,
18603,
29918,
29907,
2477,
20161,
7724,
29897,
13,
9651,
7465,
411,
4511,
29898,
13,
18884,
1583,
29889,
2974,
29918,
3069,
29892,
13,
18884,
1583,
29889,
29890,
468,
375,
29918,
637,
29892,
13,
18884,
5285,
29922,
13305,
29892,
13,
18884,
4480,
29918,
18045,
29922,
8824,
29892,
13,
9651,
1723,
408,
3132,
29901,
13,
18884,
7272,
3132,
29889,
15702,
580,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
6915,
29918,
2997,
29918,
637,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
2933,
353,
7272,
1583,
29889,
3389,
29918,
4645,
29898,
2997,
29918,
637,
29922,
29941,
29946,
29945,
29953,
29892,
2011,
29922,
2974,
29918,
637,
29897,
13,
9651,
1583,
29889,
9294,
9843,
29898,
5327,
29892,
289,
29908,
5138,
666,
1159,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
3167,
29918,
9965,
29918,
333,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29897,
13,
9651,
5285,
29889,
1359,
29918,
27902,
29918,
2029,
800,
29898,
1113,
1445,
29922,
18603,
29918,
29907,
2477,
20161,
7724,
29897,
13,
9651,
7465,
411,
4511,
29898,
13,
18884,
1583,
29889,
2974,
29918,
3069,
29892,
1923,
29918,
637,
29892,
5285,
29922,
13305,
13,
9651,
1723,
408,
3132,
29901,
13,
18884,
7272,
3132,
29889,
15702,
580,
13,
18884,
3132,
29889,
3167,
29918,
9965,
29918,
333,
580,
13,
18884,
7272,
3132,
29889,
15702,
580,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
1989,
29918,
5504,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29897,
13,
9651,
5285,
29889,
1359,
29918,
27902,
29918,
2029,
800,
29898,
1113,
1445,
29922,
18603,
29918,
29907,
2477,
20161,
7724,
29897,
13,
9651,
7465,
411,
4511,
29898,
13,
18884,
1583,
29889,
2974,
29918,
3069,
29892,
1923,
29918,
637,
29892,
5285,
29922,
13305,
13,
9651,
1723,
408,
3132,
29901,
13,
18884,
7272,
3132,
29889,
15702,
580,
13,
18884,
3132,
29889,
3827,
29918,
1989,
29918,
5504,
580,
13,
18884,
7272,
3132,
29889,
15702,
580,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
15702,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29897,
13,
9651,
5285,
29889,
1359,
29918,
27902,
29918,
2029,
800,
29898,
1113,
1445,
29922,
18603,
29918,
29907,
2477,
20161,
7724,
29897,
13,
9651,
7465,
411,
4511,
29898,
13,
18884,
1583,
29889,
2974,
29918,
3069,
29892,
1923,
29918,
637,
29892,
5285,
29922,
13305,
13,
9651,
1723,
408,
3132,
29901,
13,
18884,
7272,
3132,
29889,
15702,
580,
13,
18884,
7272,
3132,
29889,
15702,
580,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
15702,
29918,
23482,
29898,
1311,
1125,
13,
4706,
7465,
411,
1583,
29889,
3389,
29918,
2974,
580,
408,
1923,
29918,
637,
29901,
13,
9651,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
5574,
29897,
13,
9651,
5285,
29889,
1359,
29918,
27902,
29918,
2029,
800,
29898,
1113,
1445,
29922,
18603,
29918,
29907,
2477,
20161,
7724,
29897,
13,
9651,
7465,
411,
4511,
29898,
13,
18884,
1583,
29889,
2974,
29918,
3069,
29892,
1923,
29918,
637,
29892,
5285,
29922,
13305,
13,
9651,
1723,
408,
3132,
29901,
13,
18884,
1034,
359,
353,
518,
4645,
29889,
15702,
580,
363,
921,
297,
3464,
29898,
29896,
29953,
4638,
13,
18884,
7272,
408,
948,
3934,
29889,
29887,
1624,
10456,
2616,
359,
29897,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
2974,
29918,
13556,
3145,
29918,
5397,
17807,
29898,
1311,
1125,
13,
4706,
5285,
353,
751,
293,
8614,
29898,
275,
29918,
4645,
29922,
8824,
29897,
13,
4706,
5285,
29889,
1359,
29918,
6327,
29918,
14153,
29898,
18603,
29918,
29907,
20161,
7724,
29892,
26996,
5348,
29918,
10818,
7724,
29897,
13,
4706,
1923,
353,
7272,
9080,
29898,
13,
9651,
3495,
29922,
1311,
29889,
2974,
29918,
3069,
29892,
13,
9651,
2011,
29922,
29900,
29892,
13,
9651,
5285,
29922,
13305,
29892,
13,
4706,
1723,
13,
4706,
1923,
29889,
4130,
14442,
29918,
13556,
2347,
29898,
2109,
294,
18869,
29889,
348,
354,
15524,
1598,
703,
29883,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29947,
29900,
4968,
4852,
29896,
29955,
29906,
29889,
29896,
29953,
29889,
29941,
29896,
29889,
29896,
29900,
613,
29871,
29896,
29906,
29941,
29946,
876,
13,
4706,
1923,
29889,
5358,
580,
13,
13,
1678,
732,
294,
948,
312,
342,
13,
1678,
7465,
822,
1243,
29918,
17743,
1312,
29918,
1989,
29898,
1311,
1125,
13,
4706,
2295,
29896,
353,
751,
293,
8614,
580,
13,
4706,
2295,
29906,
353,
751,
293,
8614,
580,
13,
4706,
2295,
29896,
29889,
1359,
29918,
6327,
29918,
14153,
29898,
18603,
29918,
29907,
20161,
7724,
29892,
26996,
5348,
29918,
10818,
7724,
29897,
13,
4706,
2295,
29906,
29889,
1359,
29918,
6327,
29918,
14153,
29898,
18603,
29918,
3217,
9486,
1177,
3352,
7724,
29897,
13,
13,
4706,
1583,
29889,
9294,
9843,
29898,
2917,
29896,
29889,
6327,
8021,
29892,
2295,
29906,
29889,
6327,
8021,
29897,
13,
2
] |
python-algorithm/leetcode/problem_228.py | isudox/nerd-algorithm | 5 | 155403 | <reponame>isudox/nerd-algorithm
"""228. Summary Ranges
https://leetcode.com/problems/summary-ranges/
"""
from typing import List
class Solution:
def summaryRanges(self, nums: List[int]) -> List[str]:
if not nums:
return []
ans = []
nums.append(nums[-1] + 2)
n = len(nums)
pre, cnt = nums[0], 1
for i in range(1, n):
if nums[i] == pre + 1:
pre = nums[i]
cnt += 1
else:
if cnt == 1:
ans.append(str(pre))
else:
ans.append(str(pre - cnt + 1) + '->' + str(pre))
pre, cnt = nums[i], 1
return ans
| [
1,
529,
276,
1112,
420,
29958,
275,
566,
2251,
29914,
1089,
29881,
29899,
20567,
13,
15945,
29908,
29906,
29906,
29947,
29889,
6991,
5219,
390,
6916,
13,
991,
597,
280,
300,
401,
29889,
510,
29914,
17199,
29879,
29914,
7727,
29899,
29878,
6916,
29914,
13,
15945,
29908,
13,
3166,
19229,
1053,
2391,
13,
13,
13,
1990,
24380,
29901,
13,
1678,
822,
15837,
29934,
6916,
29898,
1311,
29892,
954,
29879,
29901,
2391,
29961,
524,
2314,
1599,
2391,
29961,
710,
5387,
13,
4706,
565,
451,
954,
29879,
29901,
13,
9651,
736,
5159,
13,
4706,
6063,
353,
5159,
13,
4706,
954,
29879,
29889,
4397,
29898,
1949,
29879,
14352,
29896,
29962,
718,
29871,
29906,
29897,
13,
4706,
302,
353,
7431,
29898,
1949,
29879,
29897,
13,
4706,
758,
29892,
274,
593,
353,
954,
29879,
29961,
29900,
1402,
29871,
29896,
13,
4706,
363,
474,
297,
3464,
29898,
29896,
29892,
302,
1125,
13,
9651,
565,
954,
29879,
29961,
29875,
29962,
1275,
758,
718,
29871,
29896,
29901,
13,
18884,
758,
353,
954,
29879,
29961,
29875,
29962,
13,
18884,
274,
593,
4619,
29871,
29896,
13,
9651,
1683,
29901,
13,
18884,
565,
274,
593,
1275,
29871,
29896,
29901,
13,
462,
1678,
6063,
29889,
4397,
29898,
710,
29898,
1457,
876,
13,
18884,
1683,
29901,
13,
462,
1678,
6063,
29889,
4397,
29898,
710,
29898,
1457,
448,
274,
593,
718,
29871,
29896,
29897,
718,
525,
976,
29915,
718,
851,
29898,
1457,
876,
13,
18884,
758,
29892,
274,
593,
353,
954,
29879,
29961,
29875,
1402,
29871,
29896,
13,
4706,
736,
6063,
13,
2
] |
elliot/recommender/neural/NeuMF/tf_custom_sampler_2.py | gategill/elliot | 175 | 44446 | """
Module description:
"""
__version__ = '0.3.1'
__author__ = '<NAME>, <NAME>'
__email__ = '<EMAIL>, <EMAIL>'
import tensorflow as tf
import numpy as np
import random
class Sampler():
def __init__(self, indexed_ratings=None, m=None, num_users=None, num_items=None, transactions=None, batch_size=512, random_seed=42):
np.random.seed(random_seed)
random.seed(random_seed)
self._UIDICT = {u: list(set(indexed_ratings[u])) for u in indexed_ratings}
self._POS = list({(u, i, 1) for u, items in self._UIDICT.items() for i in items})
self._POS = random.sample(self._POS, len(self._POS))
self._M = m
self._NUM_USERS = num_users
self._NUM_ITEMS = num_items
self._transactions = transactions
self._batch_size = batch_size
def _full_generator(self):
r_int = np.random.randint
n_items = self._NUM_ITEMS
ui_dict = self._UIDICT
neg = set()
for u, i, _ in self._POS:
ui = ui_dict[u]
for _ in range(self._M):
j = r_int(n_items)
while j in ui:
j = r_int(n_items)
neg.add((u, j, 0))
samples = self._POS[:]
samples.extend(list(neg))
samples = random.sample(samples, len(samples))
# u, i, b = map(np.array, zip(*samples))
# yield u,i,b
for start in range(0, len(samples), self._batch_size):
u, i, b = map(np.array, zip(*samples[start:min(start + self._batch_size, len(samples))]))
yield u, i, b
def step(self, batch_size: int):
r_int = np.random.randint
n_items = self._NUM_ITEMS
ui_dict = self._UIDICT
pos = {(u, i, 1) for u, items in ui_dict.items() for i in items}
neg = set()
for u, i, _ in pos:
ui = ui_dict[u]
for _ in range(self._M):
j = r_int(n_items)
while j in ui:
j = r_int(n_items)
neg.add((u, j, 0))
samples = list(pos)
samples.extend(list(neg))
samples = random.sample(samples, len(samples))
for start in range(0, len(samples), batch_size):
u, i, b = map(np.array, zip(*samples[start:min(start + batch_size, len(samples))]))
yield u, i, b
def create_tf_dataset(self):
data = tf.data.Dataset.from_generator(generator=self._full_generator,
output_types=(np.int64, np.int64, np.int64),
)
# data = data.unbatch().batch(batch_size=self._batch_size)
data = data.prefetch(buffer_size=tf.data.experimental.AUTOTUNE)
return data | [
1,
9995,
13,
7355,
6139,
29901,
13,
15945,
29908,
13,
1649,
3259,
1649,
353,
525,
29900,
29889,
29941,
29889,
29896,
29915,
13,
1649,
8921,
1649,
353,
12801,
5813,
10202,
529,
5813,
16299,
13,
1649,
5269,
1649,
353,
12801,
26862,
6227,
10202,
529,
26862,
6227,
16299,
13,
13,
5215,
26110,
408,
15886,
13,
5215,
12655,
408,
7442,
13,
5215,
4036,
13,
13,
13,
1990,
3685,
20069,
7295,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
27541,
29918,
3605,
886,
29922,
8516,
29892,
286,
29922,
8516,
29892,
954,
29918,
7193,
29922,
8516,
29892,
954,
29918,
7076,
29922,
8516,
29892,
22160,
29922,
8516,
29892,
9853,
29918,
2311,
29922,
29945,
29896,
29906,
29892,
4036,
29918,
26776,
29922,
29946,
29906,
1125,
13,
4706,
7442,
29889,
8172,
29889,
26776,
29898,
8172,
29918,
26776,
29897,
13,
4706,
4036,
29889,
26776,
29898,
8172,
29918,
26776,
29897,
13,
4706,
1583,
3032,
11150,
29902,
1783,
353,
426,
29884,
29901,
1051,
29898,
842,
29898,
2248,
287,
29918,
3605,
886,
29961,
29884,
12622,
363,
318,
297,
27541,
29918,
3605,
886,
29913,
13,
4706,
1583,
3032,
24815,
353,
1051,
3319,
29898,
29884,
29892,
474,
29892,
29871,
29896,
29897,
363,
318,
29892,
4452,
297,
1583,
3032,
11150,
29902,
1783,
29889,
7076,
580,
363,
474,
297,
4452,
1800,
13,
4706,
1583,
3032,
24815,
353,
4036,
29889,
11249,
29898,
1311,
3032,
24815,
29892,
7431,
29898,
1311,
3032,
24815,
876,
13,
4706,
1583,
3032,
29924,
353,
286,
13,
4706,
1583,
3032,
13967,
29918,
11889,
29903,
353,
954,
29918,
7193,
13,
4706,
1583,
3032,
13967,
29918,
9094,
4345,
353,
954,
29918,
7076,
13,
4706,
1583,
3032,
3286,
7387,
353,
22160,
13,
4706,
1583,
3032,
16175,
29918,
2311,
353,
9853,
29918,
2311,
13,
13,
1678,
822,
903,
8159,
29918,
27959,
29898,
1311,
1125,
13,
4706,
364,
29918,
524,
353,
7442,
29889,
8172,
29889,
9502,
524,
13,
4706,
302,
29918,
7076,
353,
1583,
3032,
13967,
29918,
9094,
4345,
13,
4706,
14313,
29918,
8977,
353,
1583,
3032,
11150,
29902,
1783,
13,
4706,
3480,
353,
731,
580,
13,
4706,
363,
318,
29892,
474,
29892,
903,
297,
1583,
3032,
24815,
29901,
13,
9651,
14313,
353,
14313,
29918,
8977,
29961,
29884,
29962,
13,
9651,
363,
903,
297,
3464,
29898,
1311,
3032,
29924,
1125,
13,
18884,
432,
353,
364,
29918,
524,
29898,
29876,
29918,
7076,
29897,
13,
18884,
1550,
432,
297,
14313,
29901,
13,
462,
1678,
432,
353,
364,
29918,
524,
29898,
29876,
29918,
7076,
29897,
13,
18884,
3480,
29889,
1202,
3552,
29884,
29892,
432,
29892,
29871,
29900,
876,
13,
13,
4706,
11916,
353,
1583,
3032,
24815,
7503,
29962,
13,
4706,
11916,
29889,
21843,
29898,
1761,
29898,
10052,
876,
13,
4706,
11916,
353,
4036,
29889,
11249,
29898,
27736,
29892,
7431,
29898,
27736,
876,
13,
13,
4706,
396,
318,
29892,
474,
29892,
289,
353,
2910,
29898,
9302,
29889,
2378,
29892,
14319,
10456,
27736,
876,
13,
4706,
396,
7709,
318,
29892,
29875,
29892,
29890,
13,
4706,
363,
1369,
297,
3464,
29898,
29900,
29892,
7431,
29898,
27736,
511,
1583,
3032,
16175,
29918,
2311,
1125,
13,
9651,
318,
29892,
474,
29892,
289,
353,
2910,
29898,
9302,
29889,
2378,
29892,
14319,
10456,
27736,
29961,
2962,
29901,
1195,
29898,
2962,
718,
1583,
3032,
16175,
29918,
2311,
29892,
7431,
29898,
27736,
876,
12622,
13,
9651,
7709,
318,
29892,
474,
29892,
289,
13,
13,
1678,
822,
4331,
29898,
1311,
29892,
9853,
29918,
2311,
29901,
938,
1125,
13,
4706,
364,
29918,
524,
353,
7442,
29889,
8172,
29889,
9502,
524,
13,
4706,
302,
29918,
7076,
353,
1583,
3032,
13967,
29918,
9094,
4345,
13,
4706,
14313,
29918,
8977,
353,
1583,
3032,
11150,
29902,
1783,
13,
13,
4706,
926,
353,
426,
29898,
29884,
29892,
474,
29892,
29871,
29896,
29897,
363,
318,
29892,
4452,
297,
14313,
29918,
8977,
29889,
7076,
580,
363,
474,
297,
4452,
29913,
13,
13,
4706,
3480,
353,
731,
580,
13,
4706,
363,
318,
29892,
474,
29892,
903,
297,
926,
29901,
13,
9651,
14313,
353,
14313,
29918,
8977,
29961,
29884,
29962,
13,
9651,
363,
903,
297,
3464,
29898,
1311,
3032,
29924,
1125,
13,
18884,
432,
353,
364,
29918,
524,
29898,
29876,
29918,
7076,
29897,
13,
18884,
1550,
432,
297,
14313,
29901,
13,
462,
1678,
432,
353,
364,
29918,
524,
29898,
29876,
29918,
7076,
29897,
13,
18884,
3480,
29889,
1202,
3552,
29884,
29892,
432,
29892,
29871,
29900,
876,
13,
13,
4706,
11916,
353,
1051,
29898,
1066,
29897,
13,
4706,
11916,
29889,
21843,
29898,
1761,
29898,
10052,
876,
13,
4706,
11916,
353,
4036,
29889,
11249,
29898,
27736,
29892,
7431,
29898,
27736,
876,
13,
13,
4706,
363,
1369,
297,
3464,
29898,
29900,
29892,
7431,
29898,
27736,
511,
9853,
29918,
2311,
1125,
13,
9651,
318,
29892,
474,
29892,
289,
353,
2910,
29898,
9302,
29889,
2378,
29892,
14319,
10456,
27736,
29961,
2962,
29901,
1195,
29898,
2962,
718,
9853,
29918,
2311,
29892,
7431,
29898,
27736,
876,
12622,
13,
9651,
7709,
318,
29892,
474,
29892,
289,
13,
13,
1678,
822,
1653,
29918,
13264,
29918,
24713,
29898,
1311,
1125,
13,
4706,
848,
353,
15886,
29889,
1272,
29889,
16390,
24541,
29889,
3166,
29918,
27959,
29898,
27959,
29922,
1311,
3032,
8159,
29918,
27959,
29892,
13,
462,
462,
795,
1962,
29918,
8768,
7607,
9302,
29889,
524,
29953,
29946,
29892,
7442,
29889,
524,
29953,
29946,
29892,
7442,
29889,
524,
29953,
29946,
511,
13,
462,
462,
795,
1723,
13,
4706,
396,
848,
353,
848,
29889,
348,
16175,
2141,
16175,
29898,
16175,
29918,
2311,
29922,
1311,
3032,
16175,
29918,
2311,
29897,
13,
4706,
848,
353,
848,
29889,
29886,
999,
3486,
29898,
9040,
29918,
2311,
29922,
13264,
29889,
1272,
29889,
735,
27910,
29889,
20656,
2891,
3904,
29923,
29897,
13,
4706,
736,
848,
2
] |
setup.py | kageurufu/cfddns-py | 0 | 146113 | from setuptools import setup, find_packages
setup(
name="cfddns",
version="0.1",
packages=['cfddns'],
entry_points={
'console_scripts': ["cfddns = cfddns:main"],
},
install_requires=["cloudflare", "pyyaml"],
)
| [
1,
515,
731,
21245,
8789,
1053,
6230,
29892,
1284,
29918,
8318,
13,
13,
14669,
29898,
13,
1678,
1024,
543,
6854,
1289,
1983,
613,
13,
1678,
1873,
543,
29900,
29889,
29896,
613,
13,
1678,
9741,
29922,
1839,
6854,
1289,
1983,
7464,
13,
1678,
6251,
29918,
9748,
3790,
13,
4706,
525,
11058,
29918,
16713,
2396,
6796,
6854,
1289,
1983,
353,
274,
29888,
1289,
1983,
29901,
3396,
12436,
13,
1678,
2981,
13,
1678,
2601,
29918,
276,
339,
2658,
29922,
3366,
28260,
613,
376,
2272,
25162,
12436,
13,
29897,
13,
2
] |
reservation/urls.py | aryamanak10/diner-restaurant-website | 1 | 1519 | from django.urls import path
from . import views
app_name = 'reservation'
urlpatterns = [
path('', views.reserve_table, name = 'reserve_table'),
] | [
1,
515,
9557,
29889,
26045,
1053,
2224,
13,
3166,
869,
1053,
8386,
13,
13,
932,
29918,
978,
353,
525,
690,
20525,
29915,
13,
13,
2271,
11037,
29879,
353,
518,
13,
1678,
2224,
877,
742,
8386,
29889,
690,
7143,
29918,
2371,
29892,
1024,
353,
525,
690,
7143,
29918,
2371,
5477,
13,
29962,
2
] |
voithos/lib/migrate/ubuntu.py | breqwatr/voidith | 3 | 1602984 | """ Library for Ubuntu migration operations """
import os
from pathlib import Path
from ipaddress import IPv4Interface
from voithos.lib.system import error, is_mounted, debug, get_file_contents, grep
from voithos.lib.migrate.linux_worker import LinuxWorker
class UbuntuWorker(LinuxWorker):
""" Operate on mounted RedHat systems """
def __init__(self, devices=None):
"""Operate on mounted RedHat systems
Accepts a collection of devices to operate upon
"""
super().__init__(devices=devices)
debug(f"Initiating UbuntuWorker with devices: {devices}")
def uninstall(self, package, like=False):
""" Uninstall packages from the given system """
if not like:
print(f"Uninstalling: {package}")
self.chroot_run(f"dpkg --purge {package}")
return
dpkg_lines = self.chroot_run("dpkg -l")
like_lines = [line for line in dpkg_lines if package in line]
if not like_lines:
print(f'No packages were found matching "{package}"')
return
for line in like_lines:
pkg = [elem for elem in line.split(" ") if elem][1]
print(f"Uninstalling: {pkg}")
self.chroot_run(f"dpkg --purge {pkg}")
def set_ifupdown_interface(
self,
interface_name,
is_dhcp,
mac_addr,
ip_addr=None,
prefix=None,
gateway=None,
dns=(),
domain=None,
):
""" Deploy an ifupdown styled interface file """
debug("Setting ifupdown file")
path = f"{self.ROOT_MOUNT}/etc/network/interfaces"
interfaces_contents = get_file_contents(path)
if interface_name in interfaces_contents:
error(f"ERROR: {interface_name} is already in {path} - cannot continue", exit=True)
self.debug_action(action=f"SET IFUPDOWN FILE: {path}")
mode = "dhcp" if is_dhcp else "static"
iface_lines = [
f"auto {interface_name}",
f"iface {interface_name} inet {mode}"
]
if ip_addr and prefix:
iface_lines.append(f" address {ip_addr}")
ip_obj = IPv4Interface(f"{ip_addr}/{prefix}")
iface_lines.append(f" netmask {ip_obj.netmask}")
if gateway:
iface_lines.append(f" gateway {gateway}")
if dns:
nameservers = " ".join(dns)
iface_lines.append(f" dns-nameservers {nameservers}")
if domain:
iface_lines.append(f" dns-search {domain}")
print(f"Writing: {path}")
with open(path, "a+") as iface_file:
iface_file.write("\n")
for line in iface_lines:
iface_file.write(line+ "\n")
with open(path, "r") as iface_file:
print(iface_file.read())
self.debug_action(end=True)
def set_netplan_interface(
self,
interface_name,
is_dhcp,
mac_addr,
ip_addr=None,
prefix=None,
gateway=None,
dns=(),
domain=None,
):
""" Deploy a netplan styled interface file """
netplan_dir_path = f"{self.ROOT_MOUNT}/etc/netplan"
netplan_file_path = f"{netplan_dir_path}/{interface_name}.yaml"
self.debug_action(action=f"SET NETPLAN FILE: {netplan_file_path}")
# check the yaml files in the netplan dir to see if this interface is already defined
dir_files = os.listdir(netplan_dir_path)
yaml_files = [fil for fil in dir_files if fil.endswith(".yaml") ]
# make sure this interface is not defined elsewhere
for filename in yaml_files:
file_path = f"{netplan_dir_path}/{filename}"
debug(f"Ensuring {interface_name} is not in {file_path}")
if f"{interface_name}:" in get_file_contents(file_path):
error(f"ERROR: {interface_name} found in {file_path}", exit=True)
# write the new yaml file
iface_lines = [
f"network:",
f" ethernets:",
f" {interface_name}:"
]
if ip_addr and prefix:
iface_lines.append(f" dhcp4: no")
iface_lines.append(f" addresses: [\"{ip_addr}/{prefix}\"]")
if gateway:
iface_lines.append(f" gateway4: {gateway}")
if dns:
nameservers = ', '.join('"{0}"'.format(entry) for entry in dns)
iface_lines.append(f" nameservers:")
iface_lines.append(f" addresses: [{nameservers}]")
if domain:
iface_lines.append(f" search: [\"{domain}\"]")
elif is_dhcp:
iface_lines.append(f" dhcp4: yes")
with open(netplan_file_path, "a+") as iface_file:
for line in iface_lines:
iface_file.write(line+ "\n")
print(f"# {netplan_file_path}")
with open(netplan_file_path, "r") as iface_file:
print(iface_file.read())
self.debug_action(end=True)
def set_interface(
self,
interface_name,
is_dhcp,
mac_addr,
ip_addr=None,
prefix=None,
gateway=None,
dns=(),
domain=None,
):
""" Find the interface type (netplan/ifupdown) then deploy the file """
if not is_mounted(self.ROOT_MOUNT):
error(f"ERROR: Cannot set interface file, {self.ROOT_MOUNT} is not mounted", exit=True)
if Path(f"{self.ROOT_MOUNT}/etc/netplan").exists():
# This is (probably) a newer Ubuntu OS that uses Netplan
debug("Using Netplan")
self.set_netplan_interface(
interface_name,
is_dhcp,
mac_addr,
ip_addr=ip_addr,
prefix=prefix,
gateway=gateway,
dns=dns,
domain=domain
)
else:
# This is (probably) an older Ubuntu OS that uses ifupdown
self.set_ifupdown_interface(
interface_name,
is_dhcp,
mac_addr,
ip_addr=ip_addr,
prefix=prefix,
gateway=gateway,
dns=dns,
domain=domain
)
| [
1,
9995,
9538,
363,
8294,
20332,
6931,
9995,
13,
5215,
2897,
13,
3166,
2224,
1982,
1053,
10802,
13,
3166,
10377,
7328,
1053,
5641,
29894,
29946,
10448,
13,
13,
3166,
992,
389,
359,
29889,
1982,
29889,
5205,
1053,
1059,
29892,
338,
29918,
16476,
287,
29892,
4744,
29892,
679,
29918,
1445,
29918,
10853,
29892,
12680,
13,
3166,
992,
389,
359,
29889,
1982,
29889,
26983,
403,
29889,
9389,
29918,
24602,
1053,
8074,
16164,
13,
13,
13,
1990,
8294,
16164,
29898,
24085,
16164,
1125,
13,
1678,
9995,
6607,
403,
373,
19239,
4367,
29950,
271,
6757,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
9224,
29922,
8516,
1125,
13,
4706,
9995,
7094,
403,
373,
19239,
4367,
29950,
271,
6757,
13,
4706,
29848,
29879,
263,
4333,
310,
9224,
304,
21994,
2501,
13,
4706,
9995,
13,
4706,
2428,
2141,
1649,
2344,
12035,
3359,
1575,
29922,
3359,
1575,
29897,
13,
4706,
4744,
29898,
29888,
29908,
797,
4812,
1218,
8294,
16164,
411,
9224,
29901,
426,
3359,
1575,
27195,
13,
13,
1678,
822,
27608,
29898,
1311,
29892,
3577,
29892,
763,
29922,
8824,
1125,
13,
4706,
9995,
853,
6252,
9741,
515,
278,
2183,
1788,
9995,
13,
4706,
565,
451,
763,
29901,
13,
9651,
1596,
29898,
29888,
29908,
2525,
6252,
292,
29901,
426,
5113,
27195,
13,
9651,
1583,
29889,
305,
4632,
29918,
3389,
29898,
29888,
29908,
6099,
9415,
1192,
15503,
479,
426,
5113,
27195,
13,
9651,
736,
13,
4706,
270,
15865,
29918,
9012,
353,
1583,
29889,
305,
4632,
29918,
3389,
703,
6099,
9415,
448,
29880,
1159,
13,
4706,
763,
29918,
9012,
353,
518,
1220,
363,
1196,
297,
270,
15865,
29918,
9012,
565,
3577,
297,
1196,
29962,
13,
4706,
565,
451,
763,
29918,
9012,
29901,
13,
9651,
1596,
29898,
29888,
29915,
3782,
9741,
892,
1476,
9686,
29850,
5113,
5038,
1495,
13,
9651,
736,
13,
4706,
363,
1196,
297,
763,
29918,
9012,
29901,
13,
9651,
282,
9415,
353,
518,
20461,
363,
21268,
297,
1196,
29889,
5451,
703,
16521,
565,
21268,
3816,
29896,
29962,
13,
9651,
1596,
29898,
29888,
29908,
2525,
6252,
292,
29901,
426,
15865,
27195,
13,
9651,
1583,
29889,
305,
4632,
29918,
3389,
29898,
29888,
29908,
6099,
9415,
1192,
15503,
479,
426,
15865,
27195,
13,
13,
1678,
822,
731,
29918,
361,
786,
3204,
29918,
13248,
29898,
13,
4706,
1583,
29892,
13,
4706,
5067,
29918,
978,
29892,
13,
4706,
338,
29918,
12744,
6814,
29892,
13,
4706,
5825,
29918,
10030,
29892,
13,
4706,
10377,
29918,
10030,
29922,
8516,
29892,
13,
4706,
10944,
29922,
8516,
29892,
13,
4706,
28646,
29922,
8516,
29892,
13,
4706,
270,
1983,
29922,
3285,
13,
4706,
5354,
29922,
8516,
29892,
13,
268,
1125,
13,
4706,
9995,
10034,
2376,
385,
565,
786,
3204,
15877,
839,
5067,
934,
9995,
13,
4706,
4744,
703,
29020,
565,
786,
3204,
934,
1159,
13,
4706,
2224,
353,
285,
29908,
29912,
1311,
29889,
21289,
29918,
6720,
10356,
6822,
7070,
29914,
11618,
29914,
1639,
8726,
29908,
13,
4706,
19510,
29918,
10853,
353,
679,
29918,
1445,
29918,
10853,
29898,
2084,
29897,
13,
4706,
565,
5067,
29918,
978,
297,
19510,
29918,
10853,
29901,
13,
9651,
1059,
29898,
29888,
29908,
11432,
29901,
426,
13248,
29918,
978,
29913,
338,
2307,
297,
426,
2084,
29913,
448,
2609,
6773,
613,
6876,
29922,
5574,
29897,
13,
4706,
1583,
29889,
8382,
29918,
2467,
29898,
2467,
29922,
29888,
29908,
10490,
10762,
4897,
3970,
16048,
24080,
29901,
426,
2084,
27195,
13,
4706,
4464,
353,
376,
12744,
6814,
29908,
565,
338,
29918,
12744,
6814,
1683,
376,
7959,
29908,
13,
4706,
565,
815,
29918,
9012,
353,
518,
13,
9651,
285,
29908,
6921,
426,
13248,
29918,
978,
17671,
13,
9651,
285,
29908,
361,
815,
426,
13248,
29918,
978,
29913,
297,
300,
426,
8513,
5038,
13,
4706,
4514,
13,
4706,
565,
10377,
29918,
10030,
322,
10944,
29901,
13,
9651,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
259,
3211,
426,
666,
29918,
10030,
27195,
13,
9651,
10377,
29918,
5415,
353,
5641,
29894,
29946,
10448,
29898,
29888,
29908,
29912,
666,
29918,
10030,
6822,
29912,
13506,
27195,
13,
9651,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
259,
7787,
13168,
426,
666,
29918,
5415,
29889,
1212,
13168,
27195,
13,
4706,
565,
28646,
29901,
13,
9651,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
259,
28646,
426,
17062,
1582,
27195,
13,
4706,
565,
270,
1983,
29901,
13,
9651,
2983,
261,
874,
353,
376,
11393,
7122,
29898,
29881,
1983,
29897,
13,
9651,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
259,
270,
1983,
29899,
7039,
261,
874,
426,
7039,
261,
874,
27195,
13,
4706,
565,
5354,
29901,
13,
9651,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
259,
270,
1983,
29899,
4478,
426,
7247,
27195,
13,
4706,
1596,
29898,
29888,
29908,
29956,
768,
292,
29901,
426,
2084,
27195,
13,
4706,
411,
1722,
29898,
2084,
29892,
376,
29874,
29974,
1159,
408,
565,
815,
29918,
1445,
29901,
13,
9651,
565,
815,
29918,
1445,
29889,
3539,
14182,
29876,
1159,
13,
9651,
363,
1196,
297,
565,
815,
29918,
9012,
29901,
13,
18884,
565,
815,
29918,
1445,
29889,
3539,
29898,
1220,
29974,
6634,
29876,
1159,
13,
4706,
411,
1722,
29898,
2084,
29892,
376,
29878,
1159,
408,
565,
815,
29918,
1445,
29901,
13,
9651,
1596,
29898,
361,
815,
29918,
1445,
29889,
949,
3101,
13,
4706,
1583,
29889,
8382,
29918,
2467,
29898,
355,
29922,
5574,
29897,
13,
13,
1678,
822,
731,
29918,
1212,
9018,
29918,
13248,
29898,
13,
4706,
1583,
29892,
13,
4706,
5067,
29918,
978,
29892,
13,
4706,
338,
29918,
12744,
6814,
29892,
13,
4706,
5825,
29918,
10030,
29892,
13,
4706,
10377,
29918,
10030,
29922,
8516,
29892,
13,
4706,
10944,
29922,
8516,
29892,
13,
4706,
28646,
29922,
8516,
29892,
13,
4706,
270,
1983,
29922,
3285,
13,
4706,
5354,
29922,
8516,
29892,
13,
268,
1125,
13,
4706,
9995,
10034,
2376,
263,
7787,
9018,
15877,
839,
5067,
934,
9995,
13,
4706,
7787,
9018,
29918,
3972,
29918,
2084,
353,
285,
29908,
29912,
1311,
29889,
21289,
29918,
6720,
10356,
6822,
7070,
29914,
1212,
9018,
29908,
13,
4706,
7787,
9018,
29918,
1445,
29918,
2084,
353,
285,
29908,
29912,
1212,
9018,
29918,
3972,
29918,
2084,
6822,
29912,
13248,
29918,
978,
1836,
25162,
29908,
13,
4706,
1583,
29889,
8382,
29918,
2467,
29898,
2467,
29922,
29888,
29908,
10490,
405,
2544,
7390,
2190,
24080,
29901,
426,
1212,
9018,
29918,
1445,
29918,
2084,
27195,
13,
4706,
396,
1423,
278,
343,
8807,
2066,
297,
278,
7787,
9018,
4516,
304,
1074,
565,
445,
5067,
338,
2307,
3342,
13,
4706,
4516,
29918,
5325,
353,
2897,
29889,
1761,
3972,
29898,
1212,
9018,
29918,
3972,
29918,
2084,
29897,
13,
4706,
343,
8807,
29918,
5325,
353,
518,
1777,
363,
977,
297,
4516,
29918,
5325,
565,
977,
29889,
1975,
2541,
17350,
25162,
1159,
4514,
13,
4706,
396,
1207,
1854,
445,
5067,
338,
451,
3342,
17551,
13,
4706,
363,
10422,
297,
343,
8807,
29918,
5325,
29901,
13,
9651,
934,
29918,
2084,
353,
285,
29908,
29912,
1212,
9018,
29918,
3972,
29918,
2084,
6822,
29912,
9507,
5038,
13,
9651,
4744,
29898,
29888,
29908,
29923,
1983,
3864,
426,
13248,
29918,
978,
29913,
338,
451,
297,
426,
1445,
29918,
2084,
27195,
13,
9651,
565,
285,
29908,
29912,
13248,
29918,
978,
29913,
6160,
297,
679,
29918,
1445,
29918,
10853,
29898,
1445,
29918,
2084,
1125,
13,
18884,
1059,
29898,
29888,
29908,
11432,
29901,
426,
13248,
29918,
978,
29913,
1476,
297,
426,
1445,
29918,
2084,
17671,
6876,
29922,
5574,
29897,
13,
4706,
396,
2436,
278,
716,
343,
8807,
934,
13,
4706,
565,
815,
29918,
9012,
353,
518,
13,
9651,
285,
29908,
11618,
29901,
613,
13,
9651,
285,
29908,
29871,
11314,
824,
1691,
29901,
613,
13,
9651,
285,
29908,
1678,
426,
13248,
29918,
978,
29913,
6160,
13,
4706,
4514,
13,
4706,
565,
10377,
29918,
10030,
322,
10944,
29901,
13,
9651,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
418,
270,
29882,
6814,
29946,
29901,
694,
1159,
13,
9651,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
418,
14157,
29901,
518,
5931,
29912,
666,
29918,
10030,
6822,
29912,
13506,
1012,
3108,
1159,
13,
9651,
565,
28646,
29901,
13,
18884,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
418,
28646,
29946,
29901,
426,
17062,
1582,
27195,
13,
9651,
565,
270,
1983,
29901,
13,
18884,
2983,
261,
874,
353,
13420,
15300,
7122,
877,
29908,
29912,
29900,
5038,
4286,
4830,
29898,
8269,
29897,
363,
6251,
297,
270,
1983,
29897,
13,
18884,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
418,
2983,
261,
874,
29901,
1159,
13,
18884,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
4706,
14157,
29901,
15974,
7039,
261,
874,
6525,
1159,
13,
18884,
565,
5354,
29901,
13,
462,
1678,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
4706,
2740,
29901,
518,
5931,
29912,
7247,
1012,
3108,
1159,
13,
4706,
25342,
338,
29918,
12744,
6814,
29901,
13,
9651,
565,
815,
29918,
9012,
29889,
4397,
29898,
29888,
29908,
418,
270,
29882,
6814,
29946,
29901,
4874,
1159,
13,
4706,
411,
1722,
29898,
1212,
9018,
29918,
1445,
29918,
2084,
29892,
376,
29874,
29974,
1159,
408,
565,
815,
29918,
1445,
29901,
13,
9651,
363,
1196,
297,
565,
815,
29918,
9012,
29901,
13,
18884,
565,
815,
29918,
1445,
29889,
3539,
29898,
1220,
29974,
6634,
29876,
1159,
13,
4706,
1596,
29898,
29888,
29908,
29937,
426,
1212,
9018,
29918,
1445,
29918,
2084,
27195,
13,
4706,
411,
1722,
29898,
1212,
9018,
29918,
1445,
29918,
2084,
29892,
376,
29878,
1159,
408,
565,
815,
29918,
1445,
29901,
13,
9651,
1596,
29898,
361,
815,
29918,
1445,
29889,
949,
3101,
13,
4706,
1583,
29889,
8382,
29918,
2467,
29898,
355,
29922,
5574,
29897,
13,
13,
1678,
822,
731,
29918,
13248,
29898,
13,
4706,
1583,
29892,
13,
4706,
5067,
29918,
978,
29892,
13,
4706,
338,
29918,
12744,
6814,
29892,
13,
4706,
5825,
29918,
10030,
29892,
13,
4706,
10377,
29918,
10030,
29922,
8516,
29892,
13,
4706,
10944,
29922,
8516,
29892,
13,
4706,
28646,
29922,
8516,
29892,
13,
4706,
270,
1983,
29922,
3285,
13,
4706,
5354,
29922,
8516,
29892,
13,
268,
1125,
13,
4706,
9995,
10987,
278,
5067,
1134,
313,
1212,
9018,
29914,
361,
786,
3204,
29897,
769,
7246,
278,
934,
9995,
13,
4706,
565,
451,
338,
29918,
16476,
287,
29898,
1311,
29889,
21289,
29918,
6720,
10356,
1125,
13,
9651,
1059,
29898,
29888,
29908,
11432,
29901,
15808,
731,
5067,
934,
29892,
426,
1311,
29889,
21289,
29918,
6720,
10356,
29913,
338,
451,
19239,
613,
6876,
29922,
5574,
29897,
13,
4706,
565,
10802,
29898,
29888,
29908,
29912,
1311,
29889,
21289,
29918,
6720,
10356,
6822,
7070,
29914,
1212,
9018,
2564,
9933,
7295,
13,
9651,
396,
910,
338,
313,
771,
14815,
29897,
263,
20687,
8294,
6570,
393,
3913,
12670,
9018,
13,
9651,
4744,
703,
15156,
12670,
9018,
1159,
13,
9651,
1583,
29889,
842,
29918,
1212,
9018,
29918,
13248,
29898,
13,
18884,
5067,
29918,
978,
29892,
13,
18884,
338,
29918,
12744,
6814,
29892,
13,
18884,
5825,
29918,
10030,
29892,
13,
18884,
10377,
29918,
10030,
29922,
666,
29918,
10030,
29892,
13,
18884,
10944,
29922,
13506,
29892,
13,
18884,
28646,
29922,
17062,
1582,
29892,
13,
18884,
270,
1983,
29922,
29881,
1983,
29892,
13,
18884,
5354,
29922,
7247,
13,
9651,
1723,
13,
4706,
1683,
29901,
13,
9651,
396,
910,
338,
313,
771,
14815,
29897,
385,
9642,
8294,
6570,
393,
3913,
565,
786,
3204,
13,
9651,
1583,
29889,
842,
29918,
361,
786,
3204,
29918,
13248,
29898,
13,
18884,
5067,
29918,
978,
29892,
13,
18884,
338,
29918,
12744,
6814,
29892,
13,
18884,
5825,
29918,
10030,
29892,
13,
18884,
10377,
29918,
10030,
29922,
666,
29918,
10030,
29892,
13,
18884,
10944,
29922,
13506,
29892,
13,
18884,
28646,
29922,
17062,
1582,
29892,
13,
18884,
270,
1983,
29922,
29881,
1983,
29892,
13,
18884,
5354,
29922,
7247,
13,
9651,
1723,
13,
13,
2
] |
p74/solve.py | josephok/ProjectEuler | 0 | 175732 | <filename>p74/solve.py<gh_stars>0
import math
def digit_factorial_chains(n=1000000):
number_of_chains = 0
for i in range(1, n):
if chains_length(i) == 60:
number_of_chains += 1
return number_of_chains
def sum_of_factorial(number):
return sum(math.factorial(int(i)) for i in str(number))
def chains_length(number):
chains = set()
chains.add(number)
t = number
while True:
t = sum_of_factorial(t)
if t not in chains:
chains.add(t)
else:
break
return len(chains)
if __name__ == "__main__":
print(digit_factorial_chains()) | [
1,
529,
9507,
29958,
29886,
29955,
29946,
29914,
2929,
345,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
5844,
30004,
13,
30004,
13,
1753,
13615,
29918,
19790,
616,
29918,
305,
2708,
29898,
29876,
29922,
29896,
29900,
29900,
29900,
29900,
29900,
29900,
1125,
30004,
13,
1678,
1353,
29918,
974,
29918,
305,
2708,
353,
29871,
29900,
30004,
13,
1678,
363,
474,
297,
3464,
29898,
29896,
29892,
302,
1125,
30004,
13,
4706,
565,
521,
2708,
29918,
2848,
29898,
29875,
29897,
1275,
29871,
29953,
29900,
29901,
30004,
13,
9651,
1353,
29918,
974,
29918,
305,
2708,
4619,
29871,
29896,
30004,
13,
30004,
13,
1678,
736,
1353,
29918,
974,
29918,
305,
2708,
30004,
13,
4706,
6756,
13,
30004,
13,
1753,
2533,
29918,
974,
29918,
19790,
616,
29898,
4537,
1125,
30004,
13,
1678,
736,
2533,
29898,
755,
29889,
19790,
616,
29898,
524,
29898,
29875,
876,
363,
474,
297,
851,
29898,
4537,
876,
30004,
13,
30004,
13,
1753,
521,
2708,
29918,
2848,
29898,
4537,
1125,
30004,
13,
1678,
521,
2708,
353,
731,
26471,
13,
1678,
521,
2708,
29889,
1202,
29898,
4537,
8443,
13,
1678,
260,
353,
1353,
30004,
13,
1678,
1550,
5852,
29901,
30004,
13,
4706,
260,
353,
2533,
29918,
974,
29918,
19790,
616,
29898,
29873,
8443,
13,
4706,
565,
260,
451,
297,
521,
2708,
29901,
30004,
13,
9651,
521,
2708,
29889,
1202,
29898,
29873,
8443,
13,
4706,
1683,
29901,
30004,
13,
9651,
2867,
30004,
13,
1678,
736,
7431,
29898,
305,
2708,
8443,
13,
30004,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
30004,
13,
1678,
1596,
29898,
26204,
29918,
19790,
616,
29918,
305,
2708,
3101,
2
] |
Financial_Eng/binmodels.py | AlexKH22/Finance | 0 | 150836 | import numpy as np
class BinomialModel(object):
def __init__(self, *args):
# black == False. args: S0, u, d, R
# or
# black == True. args: S0, u, d, R, q
self.S0 = args[0]
self.u = args[1]
self.d = args[2]
self.R = args[3]
self.euro = args[5]
self.call = args[6]
self.black = args[7]
if self.black:
self.q = args[4]
else:
self.q = (self.R - self.d) / (self.u - self.d)
self.up, self.down = self.create_branches()
# Value of root
self.c = 0
def create_branches(self):
# Down and up moves
return self.S0 * self.u, self.S0 * self.d
def set_c_values(self, bi_1, bi_2, K):
if self.euro:
self.c = sum(np.array([self.q, 1-self.q]) * [bi_1.c, bi_2.c])/self.R
else:
if self.call:
self.c = max(sum(np.array([self.q, 1 - self.q]) * [bi_1.c, bi_2.c])/self.R,
self.S0 - K)
else:
self.c = max(sum(np.array([self.q, 1 - self.q]) * [bi_1.c, bi_2.c])/self.R,
K - self.S0)
self.c = self.c
class MultibinomialModel(object):
def __init__(self, *args, euro=True, call=True, black=False):
# black == False. args: S0, u, d, R
# or
# black == True. args: S0, u, d, R, q
self.S0 = args[0]
self.u = args[1]
self.d = args[2]
self.R = args[3]
self.t = args[4]
self.euro = euro
self.call = call
self.black = black
if self.black:
self.q = args[5]
else:
self.q = (self.R - self.d)/(self.u - self.d)
self.branches = []
# Init root
self.branches.append([BinomialModel(self.S0, self.u, self.d, self.R, self.q,
self.euro, self.call, self.black)])
# Init first values
self.S = []
self.S.append([self.S0])
self.S.append([])
self.S[-1].append(self.branches[0][0].up)
self.S[-1].append(self.branches[0][0].down)
self.init_branches()
# Values
self.C = []
def init_branches(self):
for i in range(1, self.t):
self.branches.append([])
self.S.append([])
for num in self.S[i]:
new_model = BinomialModel(num, self.u, self.d, self.R, self.q, self.euro, self.call, self.black)
self.branches[-1].append(new_model)
if len(self.S[-1]) > 1:
self.S[-1].append(new_model.down)
else:
self.S[-1].append(new_model.up)
self.S[-1].append(new_model.down)
def count_all_values(self, K):
# All values for every node in every period
S = np.array(self.S[-1])
if self.call:
S = S - K
else:
S = K - S
S = list(map(lambda x: 0 if x < 0 else x, S))
# Init values of last branches and layer
self.C.append([])
self.C[-1] = S
ls = []
for i in range(len(self.branches[-1])):
if self.euro:
self.branches[-1][i].c = sum(np.array([self.q, 1-self.q]) *
[self.C[-1][i],
self.C[-1][i+1]])/self.R
else:
if self.call:
self.branches[-1][i].c = max(sum(np.array([self.q, 1-self.q]) *
[self.C[-1][i],
self.C[-1][i+1]])/self.R, self.branches[-1][i].S0 - K)
else:
self.branches[-1][i].c = max(sum(np.array([self.q, 1-self.q]) *
[self.C[-1][i],
self.C[-1][i+1]])/self.R,
K - self.branches[-1][i].S0)
ls.append(self.branches[-1][i].c)
self.C.append(ls)
del ls
for i in range(len(self.branches)-2, -1, -1):
self.C.append([])
for j in range(len(self.branches[i])):
self.branches[i][j].set_c_values(self.branches[i+1][j], self.branches[i+1][j+1], K)
self.C[-1].append(self.branches[i][j].c)
self.C = list(reversed(self.C))
return self.C
def create_trading_strategies(self):
for i in range(1, len(self.S)):
print("Layer {}".format(i-1))
for j in range(len(self.S[i])-1):
a = np.array([[self.S[i][j], self.R**i],
[self.S[i][j+1], self.R**i]])
b = np.array([[self.C[i][j]],
[self.C[i][j+1]]])
solution = np.linalg.solve(a, b)
x = solution[0]
y = solution[1]
print("x: {}"
"\ny: {}".format(np.round(x, 2), np.round(y, 2)))
value = np.round(x * self.S[i-1][j] + y * self.R**(i-1), 2)
print("Value is {}".format(value[0]))
print()
| [
1,
1053,
12655,
408,
7442,
13,
13,
13,
1990,
27662,
7615,
3195,
29898,
3318,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
334,
5085,
1125,
13,
4706,
396,
4628,
1275,
7700,
29889,
6389,
29901,
317,
29900,
29892,
318,
29892,
270,
29892,
390,
13,
4706,
396,
470,
13,
4706,
396,
4628,
1275,
5852,
29889,
6389,
29901,
29871,
317,
29900,
29892,
318,
29892,
270,
29892,
390,
29892,
3855,
13,
4706,
1583,
29889,
29903,
29900,
353,
6389,
29961,
29900,
29962,
13,
4706,
1583,
29889,
29884,
353,
6389,
29961,
29896,
29962,
13,
4706,
1583,
29889,
29881,
353,
6389,
29961,
29906,
29962,
13,
4706,
1583,
29889,
29934,
353,
6389,
29961,
29941,
29962,
13,
4706,
1583,
29889,
29872,
2192,
353,
6389,
29961,
29945,
29962,
13,
4706,
1583,
29889,
4804,
353,
6389,
29961,
29953,
29962,
13,
4706,
1583,
29889,
8517,
353,
6389,
29961,
29955,
29962,
13,
13,
4706,
565,
1583,
29889,
8517,
29901,
13,
9651,
1583,
29889,
29939,
353,
6389,
29961,
29946,
29962,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
29939,
353,
313,
1311,
29889,
29934,
448,
1583,
29889,
29881,
29897,
847,
313,
1311,
29889,
29884,
448,
1583,
29889,
29881,
29897,
13,
13,
4706,
1583,
29889,
786,
29892,
1583,
29889,
3204,
353,
1583,
29889,
3258,
29918,
17519,
267,
580,
13,
4706,
396,
7865,
310,
3876,
13,
4706,
1583,
29889,
29883,
353,
29871,
29900,
13,
13,
1678,
822,
1653,
29918,
17519,
267,
29898,
1311,
1125,
13,
4706,
396,
9943,
322,
701,
16229,
13,
4706,
736,
1583,
29889,
29903,
29900,
334,
1583,
29889,
29884,
29892,
1583,
29889,
29903,
29900,
334,
1583,
29889,
29881,
13,
13,
1678,
822,
731,
29918,
29883,
29918,
5975,
29898,
1311,
29892,
4768,
29918,
29896,
29892,
4768,
29918,
29906,
29892,
476,
1125,
13,
4706,
565,
1583,
29889,
29872,
2192,
29901,
13,
9651,
1583,
29889,
29883,
353,
2533,
29898,
9302,
29889,
2378,
4197,
1311,
29889,
29939,
29892,
29871,
29896,
29899,
1311,
29889,
29939,
2314,
334,
518,
5365,
29918,
29896,
29889,
29883,
29892,
4768,
29918,
29906,
29889,
29883,
2314,
29914,
1311,
29889,
29934,
13,
4706,
1683,
29901,
13,
9651,
565,
1583,
29889,
4804,
29901,
13,
18884,
1583,
29889,
29883,
353,
4236,
29898,
2083,
29898,
9302,
29889,
2378,
4197,
1311,
29889,
29939,
29892,
29871,
29896,
448,
1583,
29889,
29939,
2314,
334,
518,
5365,
29918,
29896,
29889,
29883,
29892,
4768,
29918,
29906,
29889,
29883,
2314,
29914,
1311,
29889,
29934,
29892,
13,
462,
632,
1583,
29889,
29903,
29900,
448,
476,
29897,
13,
9651,
1683,
29901,
13,
18884,
1583,
29889,
29883,
353,
4236,
29898,
2083,
29898,
9302,
29889,
2378,
4197,
1311,
29889,
29939,
29892,
29871,
29896,
448,
1583,
29889,
29939,
2314,
334,
518,
5365,
29918,
29896,
29889,
29883,
29892,
4768,
29918,
29906,
29889,
29883,
2314,
29914,
1311,
29889,
29934,
29892,
13,
462,
632,
476,
448,
1583,
29889,
29903,
29900,
29897,
13,
13,
4706,
1583,
29889,
29883,
353,
1583,
29889,
29883,
13,
13,
13,
1990,
9683,
747,
262,
7615,
3195,
29898,
3318,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
334,
5085,
29892,
27889,
29922,
5574,
29892,
1246,
29922,
5574,
29892,
4628,
29922,
8824,
1125,
13,
4706,
396,
4628,
1275,
7700,
29889,
6389,
29901,
317,
29900,
29892,
318,
29892,
270,
29892,
390,
13,
4706,
396,
470,
13,
4706,
396,
4628,
1275,
5852,
29889,
6389,
29901,
29871,
317,
29900,
29892,
318,
29892,
270,
29892,
390,
29892,
3855,
13,
4706,
1583,
29889,
29903,
29900,
353,
6389,
29961,
29900,
29962,
13,
4706,
1583,
29889,
29884,
353,
6389,
29961,
29896,
29962,
13,
4706,
1583,
29889,
29881,
353,
6389,
29961,
29906,
29962,
13,
4706,
1583,
29889,
29934,
353,
6389,
29961,
29941,
29962,
13,
4706,
1583,
29889,
29873,
353,
6389,
29961,
29946,
29962,
13,
4706,
1583,
29889,
29872,
2192,
353,
27889,
13,
4706,
1583,
29889,
4804,
353,
1246,
13,
4706,
1583,
29889,
8517,
353,
4628,
13,
13,
4706,
565,
1583,
29889,
8517,
29901,
13,
9651,
1583,
29889,
29939,
353,
6389,
29961,
29945,
29962,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
29939,
353,
313,
1311,
29889,
29934,
448,
1583,
29889,
29881,
6802,
29898,
1311,
29889,
29884,
448,
1583,
29889,
29881,
29897,
13,
13,
4706,
1583,
29889,
17519,
267,
353,
5159,
13,
13,
4706,
396,
10886,
3876,
13,
4706,
1583,
29889,
17519,
267,
29889,
4397,
4197,
29933,
262,
7615,
3195,
29898,
1311,
29889,
29903,
29900,
29892,
1583,
29889,
29884,
29892,
1583,
29889,
29881,
29892,
1583,
29889,
29934,
29892,
1583,
29889,
29939,
29892,
13,
462,
462,
9651,
1583,
29889,
29872,
2192,
29892,
1583,
29889,
4804,
29892,
1583,
29889,
8517,
29897,
2314,
13,
13,
4706,
396,
10886,
937,
1819,
13,
4706,
1583,
29889,
29903,
353,
5159,
13,
4706,
1583,
29889,
29903,
29889,
4397,
4197,
1311,
29889,
29903,
29900,
2314,
13,
4706,
1583,
29889,
29903,
29889,
4397,
4197,
2314,
13,
4706,
1583,
29889,
29903,
14352,
29896,
1822,
4397,
29898,
1311,
29889,
17519,
267,
29961,
29900,
3816,
29900,
1822,
786,
29897,
13,
4706,
1583,
29889,
29903,
14352,
29896,
1822,
4397,
29898,
1311,
29889,
17519,
267,
29961,
29900,
3816,
29900,
1822,
3204,
29897,
13,
13,
4706,
1583,
29889,
2344,
29918,
17519,
267,
580,
13,
13,
4706,
396,
2630,
1041,
13,
4706,
1583,
29889,
29907,
353,
5159,
13,
13,
1678,
822,
2069,
29918,
17519,
267,
29898,
1311,
1125,
13,
4706,
363,
474,
297,
3464,
29898,
29896,
29892,
1583,
29889,
29873,
1125,
13,
9651,
1583,
29889,
17519,
267,
29889,
4397,
4197,
2314,
13,
9651,
1583,
29889,
29903,
29889,
4397,
4197,
2314,
13,
9651,
363,
954,
297,
1583,
29889,
29903,
29961,
29875,
5387,
13,
18884,
716,
29918,
4299,
353,
27662,
7615,
3195,
29898,
1949,
29892,
1583,
29889,
29884,
29892,
1583,
29889,
29881,
29892,
1583,
29889,
29934,
29892,
1583,
29889,
29939,
29892,
1583,
29889,
29872,
2192,
29892,
1583,
29889,
4804,
29892,
1583,
29889,
8517,
29897,
13,
18884,
1583,
29889,
17519,
267,
14352,
29896,
1822,
4397,
29898,
1482,
29918,
4299,
29897,
13,
13,
18884,
565,
7431,
29898,
1311,
29889,
29903,
14352,
29896,
2314,
1405,
29871,
29896,
29901,
13,
462,
1678,
1583,
29889,
29903,
14352,
29896,
1822,
4397,
29898,
1482,
29918,
4299,
29889,
3204,
29897,
13,
18884,
1683,
29901,
13,
462,
1678,
1583,
29889,
29903,
14352,
29896,
1822,
4397,
29898,
1482,
29918,
4299,
29889,
786,
29897,
13,
462,
1678,
1583,
29889,
29903,
14352,
29896,
1822,
4397,
29898,
1482,
29918,
4299,
29889,
3204,
29897,
13,
13,
1678,
822,
2302,
29918,
497,
29918,
5975,
29898,
1311,
29892,
476,
1125,
13,
4706,
396,
2178,
1819,
363,
1432,
2943,
297,
1432,
3785,
13,
4706,
317,
353,
7442,
29889,
2378,
29898,
1311,
29889,
29903,
14352,
29896,
2314,
13,
13,
4706,
565,
1583,
29889,
4804,
29901,
13,
9651,
317,
353,
317,
448,
476,
13,
4706,
1683,
29901,
13,
9651,
317,
353,
476,
448,
317,
13,
13,
4706,
317,
353,
1051,
29898,
1958,
29898,
2892,
921,
29901,
29871,
29900,
565,
921,
529,
29871,
29900,
1683,
921,
29892,
317,
876,
13,
13,
4706,
396,
10886,
1819,
310,
1833,
14202,
322,
7546,
13,
4706,
1583,
29889,
29907,
29889,
4397,
4197,
2314,
13,
4706,
1583,
29889,
29907,
14352,
29896,
29962,
353,
317,
13,
13,
4706,
19375,
353,
5159,
13,
4706,
363,
474,
297,
3464,
29898,
2435,
29898,
1311,
29889,
17519,
267,
14352,
29896,
12622,
29901,
13,
9651,
565,
1583,
29889,
29872,
2192,
29901,
13,
18884,
1583,
29889,
17519,
267,
14352,
29896,
3816,
29875,
1822,
29883,
353,
2533,
29898,
9302,
29889,
2378,
4197,
1311,
29889,
29939,
29892,
29871,
29896,
29899,
1311,
29889,
29939,
2314,
334,
13,
462,
462,
632,
518,
1311,
29889,
29907,
14352,
29896,
3816,
29875,
1402,
13,
462,
462,
795,
1583,
29889,
29907,
14352,
29896,
3816,
29875,
29974,
29896,
24960,
29914,
1311,
29889,
29934,
13,
9651,
1683,
29901,
13,
18884,
565,
1583,
29889,
4804,
29901,
13,
462,
1678,
1583,
29889,
17519,
267,
14352,
29896,
3816,
29875,
1822,
29883,
353,
4236,
29898,
2083,
29898,
9302,
29889,
2378,
4197,
1311,
29889,
29939,
29892,
29871,
29896,
29899,
1311,
29889,
29939,
2314,
334,
13,
462,
462,
462,
518,
1311,
29889,
29907,
14352,
29896,
3816,
29875,
1402,
13,
462,
462,
462,
29871,
1583,
29889,
29907,
14352,
29896,
3816,
29875,
29974,
29896,
24960,
29914,
1311,
29889,
29934,
29892,
1583,
29889,
17519,
267,
14352,
29896,
3816,
29875,
1822,
29903,
29900,
448,
476,
29897,
13,
18884,
1683,
29901,
13,
462,
1678,
1583,
29889,
17519,
267,
14352,
29896,
3816,
29875,
1822,
29883,
353,
4236,
29898,
2083,
29898,
9302,
29889,
2378,
4197,
1311,
29889,
29939,
29892,
29871,
29896,
29899,
1311,
29889,
29939,
2314,
334,
13,
462,
462,
462,
268,
518,
1311,
29889,
29907,
14352,
29896,
3816,
29875,
1402,
13,
462,
462,
462,
418,
1583,
29889,
29907,
14352,
29896,
3816,
29875,
29974,
29896,
24960,
29914,
1311,
29889,
29934,
29892,
13,
462,
462,
462,
476,
448,
1583,
29889,
17519,
267,
14352,
29896,
3816,
29875,
1822,
29903,
29900,
29897,
13,
13,
9651,
19375,
29889,
4397,
29898,
1311,
29889,
17519,
267,
14352,
29896,
3816,
29875,
1822,
29883,
29897,
13,
4706,
1583,
29889,
29907,
29889,
4397,
29898,
3137,
29897,
13,
4706,
628,
19375,
13,
13,
4706,
363,
474,
297,
3464,
29898,
2435,
29898,
1311,
29889,
17519,
267,
6817,
29906,
29892,
448,
29896,
29892,
448,
29896,
1125,
13,
9651,
1583,
29889,
29907,
29889,
4397,
4197,
2314,
13,
9651,
363,
432,
297,
3464,
29898,
2435,
29898,
1311,
29889,
17519,
267,
29961,
29875,
12622,
29901,
13,
18884,
1583,
29889,
17519,
267,
29961,
29875,
3816,
29926,
1822,
842,
29918,
29883,
29918,
5975,
29898,
1311,
29889,
17519,
267,
29961,
29875,
29974,
29896,
3816,
29926,
1402,
1583,
29889,
17519,
267,
29961,
29875,
29974,
29896,
3816,
29926,
29974,
29896,
1402,
476,
29897,
13,
18884,
1583,
29889,
29907,
14352,
29896,
1822,
4397,
29898,
1311,
29889,
17519,
267,
29961,
29875,
3816,
29926,
1822,
29883,
29897,
13,
13,
4706,
1583,
29889,
29907,
353,
1051,
29898,
276,
874,
287,
29898,
1311,
29889,
29907,
876,
13,
4706,
736,
1583,
29889,
29907,
13,
13,
1678,
822,
1653,
29918,
509,
9382,
29918,
710,
1845,
583,
29898,
1311,
1125,
13,
4706,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
1311,
29889,
29903,
22164,
13,
9651,
1596,
703,
14420,
6571,
1642,
4830,
29898,
29875,
29899,
29896,
876,
13,
9651,
363,
432,
297,
3464,
29898,
2435,
29898,
1311,
29889,
29903,
29961,
29875,
2314,
29899,
29896,
1125,
13,
18884,
263,
353,
7442,
29889,
2378,
4197,
29961,
1311,
29889,
29903,
29961,
29875,
3816,
29926,
1402,
1583,
29889,
29934,
1068,
29875,
1402,
13,
462,
795,
518,
1311,
29889,
29903,
29961,
29875,
3816,
29926,
29974,
29896,
1402,
1583,
29889,
29934,
1068,
29875,
24960,
13,
13,
18884,
289,
353,
7442,
29889,
2378,
4197,
29961,
1311,
29889,
29907,
29961,
29875,
3816,
29926,
20526,
13,
462,
795,
518,
1311,
29889,
29907,
29961,
29875,
3816,
29926,
29974,
29896,
5262,
2314,
13,
13,
18884,
1650,
353,
7442,
29889,
29880,
979,
29887,
29889,
2929,
345,
29898,
29874,
29892,
289,
29897,
13,
13,
18884,
921,
353,
1650,
29961,
29900,
29962,
13,
18884,
343,
353,
1650,
29961,
29896,
29962,
13,
13,
18884,
1596,
703,
29916,
29901,
426,
5038,
13,
462,
418,
6634,
1460,
29901,
6571,
1642,
4830,
29898,
9302,
29889,
14486,
29898,
29916,
29892,
29871,
29906,
511,
7442,
29889,
14486,
29898,
29891,
29892,
29871,
29906,
4961,
13,
13,
18884,
995,
353,
7442,
29889,
14486,
29898,
29916,
334,
1583,
29889,
29903,
29961,
29875,
29899,
29896,
3816,
29926,
29962,
718,
343,
334,
1583,
29889,
29934,
1068,
29898,
29875,
29899,
29896,
511,
29871,
29906,
29897,
13,
13,
18884,
1596,
703,
1917,
338,
6571,
1642,
4830,
29898,
1767,
29961,
29900,
12622,
13,
18884,
1596,
580,
13,
2
] |
tests/backends/test_pyevm.py | vaporyproject/eth-tester | 1 | 73512 | <reponame>vaporyproject/eth-tester<gh_stars>1-10
from __future__ import unicode_literals
import pytest
from eth_utils import to_wei
from eth_tester import EthereumTester, PyEVMBackend
from eth_tester.backends.pyevm.main import (
generate_genesis_state_for_keys,
get_default_account_keys,
get_default_genesis_params,
)
from eth_tester.backends.pyevm.utils import is_pyevm_available
from eth_tester.exceptions import ValidationError
from eth_tester.utils.backend_testing import BaseTestBackendDirect, SIMPLE_TRANSACTION
ZERO_ADDRESS_HEX = "0x0000000000000000000000000000000000000000"
@pytest.fixture
def eth_tester():
if not is_pyevm_available():
pytest.skip("PyEVM is not available")
backend = PyEVMBackend()
return EthereumTester(backend=backend)
class TestPyEVMBackendDirect(BaseTestBackendDirect):
def test_generate_custom_genesis_state(self):
state_overrides = {"balance": to_wei(900000, "ether")}
invalid_overrides = {"gato": "con botas"}
# Test creating a specific number of accounts
account_keys = get_default_account_keys(quantity=2)
assert len(account_keys) == 2
account_keys = get_default_account_keys(quantity=10)
assert len(account_keys) == 10
# Test the underlying state merging functionality
genesis_state = generate_genesis_state_for_keys(
account_keys=account_keys, overrides=state_overrides
)
assert len(genesis_state) == len(account_keys) == 10
for _public_address, account_state in genesis_state.items():
assert account_state["balance"] == state_overrides["balance"]
assert account_state["code"] == b""
# Only existing default genesis state keys can be overridden
with pytest.raises(ValueError):
_invalid_genesis_state = generate_genesis_state_for_keys(
account_keys=account_keys, overrides=invalid_overrides
)
# Use staticmethod state overriding
genesis_state = PyEVMBackend._generate_genesis_state(
overrides=state_overrides, num_accounts=3
)
assert len(genesis_state) == 3
for _public_address, account_state in genesis_state.items():
assert account_state["balance"] == state_overrides["balance"]
assert account_state["code"] == b""
# Only existing default genesis state keys can be overridden
with pytest.raises(ValueError):
_invalid_genesis_state = PyEVMBackend._generate_genesis_state(
overrides=invalid_overrides
)
def test_override_genesis_state(self):
state_overrides = {"balance": to_wei(900000, "ether")}
test_accounts = 3
# Initialize PyEVM backend with custom genesis state
genesis_state = PyEVMBackend._generate_genesis_state(
overrides=state_overrides, num_accounts=test_accounts
)
# Test the correct number of accounts are created with the specified balance override
pyevm_backend = PyEVMBackend(genesis_state=genesis_state)
assert len(pyevm_backend.account_keys) == test_accounts
for private_key in pyevm_backend.account_keys:
account = private_key.public_key.to_canonical_address()
balance = pyevm_backend.get_balance(account=account)
assert balance == state_overrides["balance"]
# Test integration with EthereumTester
tester = EthereumTester(backend=pyevm_backend)
for private_key in pyevm_backend.account_keys:
account = private_key.public_key.to_checksum_address()
balance = tester.get_balance(account=account)
assert balance == state_overrides["balance"]
def test_generate_custom_genesis_parameters(self):
# Establish parameter overrides, for example a custom genesis gas limit
param_overrides = {"gas_limit": 4750000}
# Test the underlying default parameter merging functionality
genesis_params = get_default_genesis_params(overrides=param_overrides)
assert genesis_params["block_number"] == 0
assert genesis_params["gas_limit"] == param_overrides["gas_limit"]
# Use the the staticmethod to generate custom genesis parameters
genesis_params = PyEVMBackend._generate_genesis_params(param_overrides)
assert genesis_params["block_number"] == 0
assert genesis_params["gas_limit"] == param_overrides["gas_limit"]
# Only existing default genesis parameter keys can be overridden
invalid_overrides = {"gato": "con botas"}
with pytest.raises(ValueError):
_invalid_genesis_params = PyEVMBackend._generate_genesis_params(
overrides=invalid_overrides
)
def test_override_genesis_parameters(self):
# Establish a custom gas limit
param_overrides = {"gas_limit": 4750000}
block_one_gas_limit = 4745362
# Initialize PyEVM backend with custom genesis parameters
genesis_params = PyEVMBackend._generate_genesis_params(
overrides=param_overrides
)
pyevm_backend = PyEVMBackend(genesis_parameters=genesis_params)
genesis_block = pyevm_backend.get_block_by_number(0)
assert genesis_block["gas_limit"] == param_overrides["gas_limit"]
genesis_block = pyevm_backend.get_block_by_number(1)
assert genesis_block["gas_limit"] == block_one_gas_limit
# Integrate with EthereumTester
tester = EthereumTester(backend=pyevm_backend)
genesis_block = tester.get_block_by_number(0)
assert genesis_block["gas_limit"] == param_overrides["gas_limit"]
genesis_block = tester.get_block_by_number(1)
assert genesis_block["gas_limit"] == block_one_gas_limit
def test_send_transaction_invalid_from(self, eth_tester):
accounts = eth_tester.get_accounts()
assert accounts, "No accounts available for transaction sending"
with pytest.raises(ValidationError, match=r'No valid "from" key was provided'):
self._send_and_check_transaction(
eth_tester, SIMPLE_TRANSACTION, ZERO_ADDRESS_HEX
)
| [
1,
529,
276,
1112,
420,
29958,
29894,
481,
706,
4836,
29914,
621,
29899,
1688,
261,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
5215,
11451,
1688,
13,
3166,
11314,
29918,
13239,
1053,
304,
29918,
26599,
13,
13,
3166,
11314,
29918,
1688,
261,
1053,
382,
12711,
398,
3057,
261,
29892,
10772,
29923,
9219,
5841,
355,
13,
3166,
11314,
29918,
1688,
261,
29889,
1627,
1975,
29889,
2272,
5750,
29885,
29889,
3396,
1053,
313,
13,
1678,
5706,
29918,
1885,
6656,
29918,
3859,
29918,
1454,
29918,
8149,
29892,
13,
1678,
679,
29918,
4381,
29918,
10149,
29918,
8149,
29892,
13,
1678,
679,
29918,
4381,
29918,
1885,
6656,
29918,
7529,
29892,
13,
29897,
13,
3166,
11314,
29918,
1688,
261,
29889,
1627,
1975,
29889,
2272,
5750,
29885,
29889,
13239,
1053,
338,
29918,
2272,
5750,
29885,
29918,
16515,
13,
3166,
11314,
29918,
1688,
261,
29889,
11739,
29879,
1053,
15758,
362,
2392,
13,
3166,
11314,
29918,
1688,
261,
29889,
13239,
29889,
27852,
29918,
13424,
1053,
7399,
3057,
5841,
355,
17392,
29892,
22717,
3580,
1307,
29918,
26813,
8132,
9838,
13,
13,
13,
29999,
1001,
29949,
29918,
17744,
26785,
29918,
29950,
5746,
353,
376,
29900,
29916,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29900,
29908,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
11314,
29918,
1688,
261,
7295,
13,
1678,
565,
451,
338,
29918,
2272,
5750,
29885,
29918,
16515,
7295,
13,
4706,
11451,
1688,
29889,
11014,
703,
19737,
29923,
9219,
338,
451,
3625,
1159,
13,
1678,
14998,
353,
10772,
29923,
9219,
5841,
355,
580,
13,
1678,
736,
382,
12711,
398,
3057,
261,
29898,
27852,
29922,
27852,
29897,
13,
13,
13,
1990,
4321,
19737,
29923,
9219,
5841,
355,
17392,
29898,
5160,
3057,
5841,
355,
17392,
1125,
13,
1678,
822,
1243,
29918,
17158,
29918,
6341,
29918,
1885,
6656,
29918,
3859,
29898,
1311,
1125,
13,
4706,
2106,
29918,
957,
24040,
353,
8853,
5521,
749,
1115,
304,
29918,
26599,
29898,
29929,
29900,
29900,
29900,
29900,
29900,
29892,
376,
1979,
1159,
29913,
13,
4706,
8340,
29918,
957,
24040,
353,
8853,
29887,
1219,
1115,
376,
535,
9225,
294,
9092,
13,
13,
4706,
396,
4321,
4969,
263,
2702,
1353,
310,
15303,
13,
4706,
3633,
29918,
8149,
353,
679,
29918,
4381,
29918,
10149,
29918,
8149,
29898,
22640,
29922,
29906,
29897,
13,
4706,
4974,
7431,
29898,
10149,
29918,
8149,
29897,
1275,
29871,
29906,
13,
4706,
3633,
29918,
8149,
353,
679,
29918,
4381,
29918,
10149,
29918,
8149,
29898,
22640,
29922,
29896,
29900,
29897,
13,
4706,
4974,
7431,
29898,
10149,
29918,
8149,
29897,
1275,
29871,
29896,
29900,
13,
13,
4706,
396,
4321,
278,
14407,
2106,
2778,
3460,
9863,
13,
4706,
2531,
6656,
29918,
3859,
353,
5706,
29918,
1885,
6656,
29918,
3859,
29918,
1454,
29918,
8149,
29898,
13,
9651,
3633,
29918,
8149,
29922,
10149,
29918,
8149,
29892,
975,
24040,
29922,
3859,
29918,
957,
24040,
13,
4706,
1723,
13,
4706,
4974,
7431,
29898,
1885,
6656,
29918,
3859,
29897,
1275,
7431,
29898,
10149,
29918,
8149,
29897,
1275,
29871,
29896,
29900,
13,
4706,
363,
903,
3597,
29918,
7328,
29892,
3633,
29918,
3859,
297,
2531,
6656,
29918,
3859,
29889,
7076,
7295,
13,
9651,
4974,
3633,
29918,
3859,
3366,
5521,
749,
3108,
1275,
2106,
29918,
957,
24040,
3366,
5521,
749,
3108,
13,
9651,
4974,
3633,
29918,
3859,
3366,
401,
3108,
1275,
289,
15945,
13,
13,
4706,
396,
9333,
5923,
2322,
2531,
6656,
2106,
6611,
508,
367,
20831,
1145,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
903,
20965,
29918,
1885,
6656,
29918,
3859,
353,
5706,
29918,
1885,
6656,
29918,
3859,
29918,
1454,
29918,
8149,
29898,
13,
18884,
3633,
29918,
8149,
29922,
10149,
29918,
8149,
29892,
975,
24040,
29922,
20965,
29918,
957,
24040,
13,
9651,
1723,
13,
13,
4706,
396,
4803,
2294,
5696,
2106,
20831,
292,
13,
4706,
2531,
6656,
29918,
3859,
353,
10772,
29923,
9219,
5841,
355,
3032,
17158,
29918,
1885,
6656,
29918,
3859,
29898,
13,
9651,
975,
24040,
29922,
3859,
29918,
957,
24040,
29892,
954,
29918,
10149,
29879,
29922,
29941,
13,
4706,
1723,
13,
4706,
4974,
7431,
29898,
1885,
6656,
29918,
3859,
29897,
1275,
29871,
29941,
13,
4706,
363,
903,
3597,
29918,
7328,
29892,
3633,
29918,
3859,
297,
2531,
6656,
29918,
3859,
29889,
7076,
7295,
13,
9651,
4974,
3633,
29918,
3859,
3366,
5521,
749,
3108,
1275,
2106,
29918,
957,
24040,
3366,
5521,
749,
3108,
13,
9651,
4974,
3633,
29918,
3859,
3366,
401,
3108,
1275,
289,
15945,
13,
13,
4706,
396,
9333,
5923,
2322,
2531,
6656,
2106,
6611,
508,
367,
20831,
1145,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
903,
20965,
29918,
1885,
6656,
29918,
3859,
353,
10772,
29923,
9219,
5841,
355,
3032,
17158,
29918,
1885,
6656,
29918,
3859,
29898,
13,
18884,
975,
24040,
29922,
20965,
29918,
957,
24040,
13,
9651,
1723,
13,
13,
1678,
822,
1243,
29918,
15752,
29918,
1885,
6656,
29918,
3859,
29898,
1311,
1125,
13,
4706,
2106,
29918,
957,
24040,
353,
8853,
5521,
749,
1115,
304,
29918,
26599,
29898,
29929,
29900,
29900,
29900,
29900,
29900,
29892,
376,
1979,
1159,
29913,
13,
4706,
1243,
29918,
10149,
29879,
353,
29871,
29941,
13,
13,
4706,
396,
25455,
10772,
29923,
9219,
14998,
411,
2888,
2531,
6656,
2106,
13,
4706,
2531,
6656,
29918,
3859,
353,
10772,
29923,
9219,
5841,
355,
3032,
17158,
29918,
1885,
6656,
29918,
3859,
29898,
13,
9651,
975,
24040,
29922,
3859,
29918,
957,
24040,
29892,
954,
29918,
10149,
29879,
29922,
1688,
29918,
10149,
29879,
13,
4706,
1723,
13,
13,
4706,
396,
4321,
278,
1959,
1353,
310,
15303,
526,
2825,
411,
278,
6790,
17346,
5712,
13,
4706,
282,
4099,
6925,
29918,
27852,
353,
10772,
29923,
9219,
5841,
355,
29898,
1885,
6656,
29918,
3859,
29922,
1885,
6656,
29918,
3859,
29897,
13,
4706,
4974,
7431,
29898,
2272,
5750,
29885,
29918,
27852,
29889,
10149,
29918,
8149,
29897,
1275,
1243,
29918,
10149,
29879,
13,
4706,
363,
2024,
29918,
1989,
297,
282,
4099,
6925,
29918,
27852,
29889,
10149,
29918,
8149,
29901,
13,
9651,
3633,
353,
2024,
29918,
1989,
29889,
3597,
29918,
1989,
29889,
517,
29918,
3068,
265,
936,
29918,
7328,
580,
13,
9651,
17346,
353,
282,
4099,
6925,
29918,
27852,
29889,
657,
29918,
5521,
749,
29898,
10149,
29922,
10149,
29897,
13,
9651,
4974,
17346,
1275,
2106,
29918,
957,
24040,
3366,
5521,
749,
3108,
13,
13,
4706,
396,
4321,
13465,
411,
382,
12711,
398,
3057,
261,
13,
4706,
1243,
261,
353,
382,
12711,
398,
3057,
261,
29898,
27852,
29922,
2272,
5750,
29885,
29918,
27852,
29897,
13,
4706,
363,
2024,
29918,
1989,
297,
282,
4099,
6925,
29918,
27852,
29889,
10149,
29918,
8149,
29901,
13,
9651,
3633,
353,
2024,
29918,
1989,
29889,
3597,
29918,
1989,
29889,
517,
29918,
3198,
2083,
29918,
7328,
580,
13,
9651,
17346,
353,
1243,
261,
29889,
657,
29918,
5521,
749,
29898,
10149,
29922,
10149,
29897,
13,
9651,
4974,
17346,
1275,
2106,
29918,
957,
24040,
3366,
5521,
749,
3108,
13,
13,
1678,
822,
1243,
29918,
17158,
29918,
6341,
29918,
1885,
6656,
29918,
16744,
29898,
1311,
1125,
13,
13,
4706,
396,
2661,
370,
1674,
3443,
975,
24040,
29892,
363,
1342,
263,
2888,
2531,
6656,
10489,
4046,
13,
4706,
1828,
29918,
957,
24040,
353,
8853,
25496,
29918,
13400,
1115,
29871,
29946,
29955,
29945,
29900,
29900,
29900,
29900,
29913,
13,
13,
4706,
396,
4321,
278,
14407,
2322,
3443,
2778,
3460,
9863,
13,
4706,
2531,
6656,
29918,
7529,
353,
679,
29918,
4381,
29918,
1885,
6656,
29918,
7529,
29898,
957,
24040,
29922,
3207,
29918,
957,
24040,
29897,
13,
4706,
4974,
2531,
6656,
29918,
7529,
3366,
1271,
29918,
4537,
3108,
1275,
29871,
29900,
13,
4706,
4974,
2531,
6656,
29918,
7529,
3366,
25496,
29918,
13400,
3108,
1275,
1828,
29918,
957,
24040,
3366,
25496,
29918,
13400,
3108,
13,
13,
4706,
396,
4803,
278,
278,
2294,
5696,
304,
5706,
2888,
2531,
6656,
4128,
13,
4706,
2531,
6656,
29918,
7529,
353,
10772,
29923,
9219,
5841,
355,
3032,
17158,
29918,
1885,
6656,
29918,
7529,
29898,
3207,
29918,
957,
24040,
29897,
13,
4706,
4974,
2531,
6656,
29918,
7529,
3366,
1271,
29918,
4537,
3108,
1275,
29871,
29900,
13,
4706,
4974,
2531,
6656,
29918,
7529,
3366,
25496,
29918,
13400,
3108,
1275,
1828,
29918,
957,
24040,
3366,
25496,
29918,
13400,
3108,
13,
13,
4706,
396,
9333,
5923,
2322,
2531,
6656,
3443,
6611,
508,
367,
20831,
1145,
13,
4706,
8340,
29918,
957,
24040,
353,
8853,
29887,
1219,
1115,
376,
535,
9225,
294,
9092,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
1917,
2392,
1125,
13,
9651,
903,
20965,
29918,
1885,
6656,
29918,
7529,
353,
10772,
29923,
9219,
5841,
355,
3032,
17158,
29918,
1885,
6656,
29918,
7529,
29898,
13,
18884,
975,
24040,
29922,
20965,
29918,
957,
24040,
13,
9651,
1723,
13,
13,
1678,
822,
1243,
29918,
15752,
29918,
1885,
6656,
29918,
16744,
29898,
1311,
1125,
13,
13,
4706,
396,
2661,
370,
1674,
263,
2888,
10489,
4046,
13,
4706,
1828,
29918,
957,
24040,
353,
8853,
25496,
29918,
13400,
1115,
29871,
29946,
29955,
29945,
29900,
29900,
29900,
29900,
29913,
13,
4706,
2908,
29918,
650,
29918,
25496,
29918,
13400,
353,
29871,
29946,
29955,
29946,
29945,
29941,
29953,
29906,
13,
13,
4706,
396,
25455,
10772,
29923,
9219,
14998,
411,
2888,
2531,
6656,
4128,
13,
4706,
2531,
6656,
29918,
7529,
353,
10772,
29923,
9219,
5841,
355,
3032,
17158,
29918,
1885,
6656,
29918,
7529,
29898,
13,
9651,
975,
24040,
29922,
3207,
29918,
957,
24040,
13,
4706,
1723,
13,
4706,
282,
4099,
6925,
29918,
27852,
353,
10772,
29923,
9219,
5841,
355,
29898,
1885,
6656,
29918,
16744,
29922,
1885,
6656,
29918,
7529,
29897,
13,
4706,
2531,
6656,
29918,
1271,
353,
282,
4099,
6925,
29918,
27852,
29889,
657,
29918,
1271,
29918,
1609,
29918,
4537,
29898,
29900,
29897,
13,
4706,
4974,
2531,
6656,
29918,
1271,
3366,
25496,
29918,
13400,
3108,
1275,
1828,
29918,
957,
24040,
3366,
25496,
29918,
13400,
3108,
13,
4706,
2531,
6656,
29918,
1271,
353,
282,
4099,
6925,
29918,
27852,
29889,
657,
29918,
1271,
29918,
1609,
29918,
4537,
29898,
29896,
29897,
13,
4706,
4974,
2531,
6656,
29918,
1271,
3366,
25496,
29918,
13400,
3108,
1275,
2908,
29918,
650,
29918,
25496,
29918,
13400,
13,
13,
4706,
396,
17100,
403,
411,
382,
12711,
398,
3057,
261,
13,
4706,
1243,
261,
353,
382,
12711,
398,
3057,
261,
29898,
27852,
29922,
2272,
5750,
29885,
29918,
27852,
29897,
13,
4706,
2531,
6656,
29918,
1271,
353,
1243,
261,
29889,
657,
29918,
1271,
29918,
1609,
29918,
4537,
29898,
29900,
29897,
13,
4706,
4974,
2531,
6656,
29918,
1271,
3366,
25496,
29918,
13400,
3108,
1275,
1828,
29918,
957,
24040,
3366,
25496,
29918,
13400,
3108,
13,
4706,
2531,
6656,
29918,
1271,
353,
1243,
261,
29889,
657,
29918,
1271,
29918,
1609,
29918,
4537,
29898,
29896,
29897,
13,
4706,
4974,
2531,
6656,
29918,
1271,
3366,
25496,
29918,
13400,
3108,
1275,
2908,
29918,
650,
29918,
25496,
29918,
13400,
13,
13,
1678,
822,
1243,
29918,
6717,
29918,
20736,
29918,
20965,
29918,
3166,
29898,
1311,
29892,
11314,
29918,
1688,
261,
1125,
13,
4706,
15303,
353,
11314,
29918,
1688,
261,
29889,
657,
29918,
10149,
29879,
580,
13,
4706,
4974,
15303,
29892,
376,
3782,
15303,
3625,
363,
10804,
9348,
29908,
13,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
19448,
2392,
29892,
1993,
29922,
29878,
29915,
3782,
2854,
376,
3166,
29908,
1820,
471,
4944,
29374,
13,
9651,
1583,
3032,
6717,
29918,
392,
29918,
3198,
29918,
20736,
29898,
13,
18884,
11314,
29918,
1688,
261,
29892,
22717,
3580,
1307,
29918,
26813,
8132,
9838,
29892,
796,
1001,
29949,
29918,
17744,
26785,
29918,
29950,
5746,
13,
9651,
1723,
13,
2
] |
prev_ob_models/KaplanLansner2014/plotting_and_analysis/plot_activity_as_colormap.py | fameshpatel/olfactorybulb | 5 | 1604782 | import os, sys, inspect
# use this if you want to include modules from a subforder
cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],"../")))
if cmd_subfolder not in sys.path:
sys.path.insert(0, cmd_subfolder)
import pylab
import numpy as np
import sys
import os
import MergeSpikefiles
import simulation_parameters
from FigureCreator import plot_params
class Plotter(object):
def __init__(self, params):
self.params = params
self.Merger = MergeSpikefiles.MergeSpikefiles(params)
def plot(self, pn_max, cell_type, mc_clustering=False):
self.cell_type = cell_type
self.pn_max = pn_max
d = np.zeros((pn_max, self.params['n_%s' % cell_type]))
for pn in xrange(pn_max):
print "Celltype: %s pattern_nr: %d" % (cell_type, pn)
fn = self.params['%s_spikes_merged_fn_base' % (cell_type)] + str(pn) + '.dat'
if not os.path.exists(fn):
print 'DEBUG Merging ...\n\n'
self.Merger.merge_nspike_files(self.params['%s_spike_fn_base' % (cell_type)], self.params['%s_spikes_merged_fn_base' % (cell_type)], pn)
self.Merger.merge_spiketimes_files(self.params['%s_spiketimes_fn_base' % (cell_type)], self.params['%s_spiketimes_merged_fn_base' % (cell_type)], pn)
print "Loading data ", fn
data = np.loadtxt(fn)
idx = np.array(data[:, 0], dtype=np.int) - self.params['%s_offset' % cell_type]
# print 'debug', idx.shape, d.shape, data.shape
d[pn, idx] = data[:, 1]
if mc_clustering:
d = self.cluster_nspikes_by_mc(d)
xlabel = 'Minicolumn'
clabel = 'Average number of spikes in MC'
fig_fn = self.params['figure_folder'] + '/' + '%s_activity_%dpatterns_mcclustered.png' % (self.cell_type, self.pn_max)
else:
xlabel = 'Cells'
clabel = 'Number of spikes'
fig_fn = self.params['figure_folder'] + '/' + '%s_activity_%dpatterns.png' % (self.cell_type, self.pn_max)
self.get_units_above_thresh(d)
fig = pylab.figure()
ax = fig.add_subplot(111)
# ax.set_title('Activity for %s cells over %d patterns' % (cell_type.capitalize(), pn_max))
ax.set_xlabel(xlabel)
ax.set_ylabel('Pattern number')
print "plotting ...."
cax = ax.pcolormesh(d)#, cmap='binary')
ax.set_xlim((0, d.shape[1]))
ax.set_ylim((0, d.shape[0]))
cbar = pylab.colorbar(cax)
cbar.set_label(clabel)
print 'Saving to:', fig_fn
pylab.savefig(fig_fn, dpi=300)
pylab.show()
def cluster_nspikes_by_mc(self, all_nspikes):
n_col = self.params['n_hc'] * self.params['n_mc']
d_out = np.zeros((all_nspikes.shape[0], n_col))
n_cells_per_mc = self.params['n_%s_per_mc' % self.cell_type]
for pn in xrange(self.pn_max):
for mc in xrange(n_col):
idx0 = mc * n_cells_per_mc
idx1 = (mc + 1) * n_cells_per_mc
d_out[pn, mc] = all_nspikes[pn, idx0:idx1].sum() / n_cells_per_mc
return d_out
def get_units_above_thresh(self, activity, thresh=.02):
"""
Returns an array with the units above a certain threshold in activity.
activity
"""
n_patterns = activity.shape[0]
n_units = activity.shape[1]
# activity_thresh = thresh * np.mean(activity)
# activity_thresh = 1.
activity_thresh = thresh * np.max(activity)
print 'activity_thresh:', activity_thresh
n_active_units_per_pattern = np.zeros(n_patterns)
avg_activity_per_pattern = np.zeros((n_patterns, 2))
for pn in xrange(n_patterns):
idx = (activity[pn, :] > activity_thresh).nonzero()[0]
n_active_units_per_pattern[pn] = idx.size
avg_activity_per_pattern[pn, 0] = activity[pn ,idx].mean()
avg_activity_per_pattern[pn, 1] = activity[pn ,idx].std()
print 'n above thresh in pn %d: \t%d' % (pn, idx.size)
print 'Average activity in pn %d: %.2f +- %.2f' % (pn, avg_activity_per_pattern[pn, 0], avg_activity_per_pattern[pn, 1])
print 'Average firing rate for all patterns: %.2f +- %.2f' % (avg_activity_per_pattern[:, 0].mean() / self.params['t_sim'] * 1000., avg_activity_per_pattern[:, 1].mean() / self.params['t_sim'] * 1000.)
n_active_patterns = np.zeros(n_units)
for unit in xrange(n_units):
idx = (activity[:, unit] > activity_thresh).nonzero()[0]
# print 'unit %d is %d times above thresh' % (unit, idx.size), idx
n_active_patterns[unit] = idx.size
n_active_at_least_once = (n_active_patterns > 0).nonzero()[0].size
n_active_more_than_once = (n_active_patterns > 1).nonzero()[0].size
n_active_more_than_twice = (n_active_patterns > 2).nonzero()[0].size
n_active_more_than_threetimes = (n_active_patterns > 3).nonzero()[0].size
print 'Mean active units per pattern: %.2f +- %.2f ~ (%.2f +- %.2f percent)' % (n_active_units_per_pattern.mean(), n_active_units_per_pattern.std(), \
n_active_units_per_pattern.mean() / float(n_units) * 100, n_active_units_per_pattern.std() / float(n_units) * 100.)
print 'Mean number of active patterns per unit: %.2f +- %.2f ~ (%.2f +- %.2f percent)' % (n_active_patterns.mean(), n_active_patterns.std(), \
n_active_patterns.mean() / float(n_patterns) * 100., n_active_patterns.std() / float(n_patterns) * 100.)
print 'Number of units active at least once : %d ~ %.2f percent' % (n_active_at_least_once, n_active_at_least_once/ float(n_units) * 100.)
print 'Number of units more active than once: %d ~ %.2f percent' % (n_active_more_than_once, n_active_more_than_once / float(n_units) * 100.)
print 'Number of units more active than twice: %d ~ %.2f percent' % (n_active_more_than_twice, n_active_more_than_twice / float(n_units) * 100.)
print 'Number of units more active than threetimes: %d ~ %.2f percent' % (n_active_more_than_threetimes, n_active_more_than_threetimes / float(n_units) * 100.)
print 'Threshold is %.2e, absolute value: %.2f spikes' % (thresh, activity_thresh)
if __name__ == '__main__':
try:
folder = sys.argv[1]
params_fn = os.path.abspath(folder) + '/Parameters/simulation_parameters.json'
param_tool = simulation_parameters.parameter_storage(params_fn=params_fn)
except:
param_tool = simulation_parameters.parameter_storage()
params = param_tool.params
print 'debug n_cells', params['n_cells']
try:
cell_type = sys.argv[2]
except:
print 'Missing cell_type argument'
print 'Usage: python plot_activity_as_colormap.py FOLDER_NAME CELL_TYPE [PN_MAX]'
exit(1)
try:
pn_max = int(sys.argv[3])
except:
print 'Plotting all patterns'
pn_max = params['n_patterns']
# pn_max = 4
pylab.rcParams.update(plot_params)
P = Plotter(params)
if (cell_type == 'pyr' or cell_type == 'rsnp'):
ok = raw_input('Cluster nspikes by minicolumn?\n')
if ok.capitalize() == 'Y' or ok == '':
P.plot(pn_max, cell_type, mc_clustering=True)
else:
P.plot(pn_max, cell_type)
else:
P.plot(pn_max, cell_type)
| [
1,
1053,
2897,
29892,
10876,
29892,
16096,
13,
29937,
671,
445,
565,
366,
864,
304,
3160,
10585,
515,
263,
1014,
29888,
2098,
13,
9006,
29918,
1491,
12083,
353,
2897,
29889,
2084,
29889,
6370,
2084,
29898,
359,
29889,
2084,
29889,
370,
1028,
493,
29898,
359,
29889,
2084,
29889,
7122,
29898,
359,
29889,
2084,
29889,
5451,
29898,
1144,
1103,
29889,
657,
1445,
29898,
16096,
29889,
3784,
2557,
580,
29871,
876,
29961,
29900,
1402,
29908,
6995,
29908,
4961,
13,
361,
9920,
29918,
1491,
12083,
451,
297,
10876,
29889,
2084,
29901,
13,
1678,
10876,
29889,
2084,
29889,
7851,
29898,
29900,
29892,
9920,
29918,
1491,
12083,
29897,
13,
13,
5215,
282,
2904,
370,
13,
5215,
12655,
408,
7442,
13,
5215,
10876,
13,
5215,
2897,
13,
5215,
4702,
479,
29903,
1631,
446,
5325,
29871,
13,
5215,
17402,
29918,
16744,
13,
3166,
11479,
9832,
1061,
1053,
6492,
29918,
7529,
13,
13,
1990,
18399,
357,
29898,
3318,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
8636,
1125,
13,
13,
4706,
1583,
29889,
7529,
353,
8636,
13,
4706,
1583,
29889,
15836,
914,
353,
4702,
479,
29903,
1631,
446,
5325,
29889,
15836,
479,
29903,
1631,
446,
5325,
29898,
7529,
29897,
13,
13,
1678,
822,
6492,
29898,
1311,
29892,
282,
29876,
29918,
3317,
29892,
3038,
29918,
1853,
29892,
286,
29883,
29918,
695,
504,
3241,
29922,
8824,
1125,
13,
4706,
1583,
29889,
3729,
29918,
1853,
353,
3038,
29918,
1853,
13,
4706,
1583,
29889,
21257,
29918,
3317,
353,
282,
29876,
29918,
3317,
13,
4706,
270,
353,
7442,
29889,
3298,
359,
3552,
21257,
29918,
3317,
29892,
1583,
29889,
7529,
1839,
29876,
29918,
29995,
29879,
29915,
1273,
3038,
29918,
1853,
12622,
13,
4706,
363,
282,
29876,
297,
921,
3881,
29898,
21257,
29918,
3317,
1125,
13,
13,
9651,
1596,
376,
4617,
1853,
29901,
1273,
29879,
4766,
29918,
22230,
29901,
1273,
29881,
29908,
1273,
313,
3729,
29918,
1853,
29892,
282,
29876,
29897,
13,
9651,
7876,
353,
1583,
29889,
7529,
1839,
29995,
29879,
29918,
1028,
29379,
29918,
1050,
3192,
29918,
9144,
29918,
3188,
29915,
1273,
313,
3729,
29918,
1853,
4638,
718,
851,
29898,
21257,
29897,
718,
15300,
4130,
29915,
13,
9651,
565,
451,
2897,
29889,
2084,
29889,
9933,
29898,
9144,
1125,
13,
18884,
1596,
525,
18525,
4702,
3460,
2023,
29905,
29876,
29905,
29876,
29915,
13,
18884,
1583,
29889,
15836,
914,
29889,
14634,
29918,
29876,
1028,
9345,
29918,
5325,
29898,
1311,
29889,
7529,
1839,
29995,
29879,
29918,
1028,
9345,
29918,
9144,
29918,
3188,
29915,
1273,
313,
3729,
29918,
1853,
29897,
1402,
1583,
29889,
7529,
1839,
29995,
29879,
29918,
1028,
29379,
29918,
1050,
3192,
29918,
9144,
29918,
3188,
29915,
1273,
313,
3729,
29918,
1853,
29897,
1402,
282,
29876,
29897,
13,
18884,
1583,
29889,
15836,
914,
29889,
14634,
29918,
1028,
638,
300,
1355,
29918,
5325,
29898,
1311,
29889,
7529,
1839,
29995,
29879,
29918,
1028,
638,
300,
1355,
29918,
9144,
29918,
3188,
29915,
1273,
313,
3729,
29918,
1853,
29897,
1402,
1583,
29889,
7529,
1839,
29995,
29879,
29918,
1028,
638,
300,
1355,
29918,
1050,
3192,
29918,
9144,
29918,
3188,
29915,
1273,
313,
3729,
29918,
1853,
29897,
1402,
282,
29876,
29897,
13,
13,
9651,
1596,
376,
23456,
848,
9162,
7876,
13,
9651,
848,
353,
7442,
29889,
1359,
3945,
29898,
9144,
29897,
13,
9651,
22645,
353,
7442,
29889,
2378,
29898,
1272,
7503,
29892,
29871,
29900,
1402,
26688,
29922,
9302,
29889,
524,
29897,
448,
1583,
29889,
7529,
1839,
29995,
29879,
29918,
10289,
29915,
1273,
3038,
29918,
1853,
29962,
13,
29937,
9651,
1596,
525,
8382,
742,
22645,
29889,
12181,
29892,
270,
29889,
12181,
29892,
848,
29889,
12181,
13,
9651,
270,
29961,
21257,
29892,
22645,
29962,
353,
848,
7503,
29892,
29871,
29896,
29962,
13,
13,
4706,
565,
286,
29883,
29918,
695,
504,
3241,
29901,
13,
9651,
270,
353,
1583,
29889,
19594,
29918,
29876,
1028,
29379,
29918,
1609,
29918,
14047,
29898,
29881,
29897,
13,
9651,
921,
1643,
353,
525,
8140,
5283,
1227,
29915,
13,
9651,
1067,
1107,
353,
525,
29909,
19698,
1353,
310,
805,
29379,
297,
21271,
29915,
13,
9651,
2537,
29918,
9144,
353,
1583,
29889,
7529,
1839,
4532,
29918,
12083,
2033,
718,
8207,
29915,
718,
14210,
29879,
29918,
10072,
29918,
29995,
29881,
11037,
29879,
29918,
29885,
617,
29880,
5402,
287,
29889,
2732,
29915,
1273,
313,
1311,
29889,
3729,
29918,
1853,
29892,
1583,
29889,
21257,
29918,
3317,
29897,
13,
4706,
1683,
29901,
13,
9651,
921,
1643,
353,
525,
13418,
29915,
13,
9651,
1067,
1107,
353,
525,
4557,
310,
805,
29379,
29915,
13,
9651,
2537,
29918,
9144,
353,
1583,
29889,
7529,
1839,
4532,
29918,
12083,
2033,
718,
8207,
29915,
718,
14210,
29879,
29918,
10072,
29918,
29995,
29881,
11037,
29879,
29889,
2732,
29915,
1273,
313,
1311,
29889,
3729,
29918,
1853,
29892,
1583,
29889,
21257,
29918,
3317,
29897,
13,
13,
4706,
1583,
29889,
657,
29918,
348,
1169,
29918,
27215,
29918,
386,
3781,
29898,
29881,
29897,
13,
13,
4706,
2537,
353,
282,
2904,
370,
29889,
4532,
580,
13,
4706,
4853,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
29896,
29896,
29896,
29897,
13,
29937,
4706,
4853,
29889,
842,
29918,
3257,
877,
3886,
363,
1273,
29879,
9101,
975,
1273,
29881,
15038,
29915,
1273,
313,
3729,
29918,
1853,
29889,
5030,
2410,
675,
3285,
282,
29876,
29918,
3317,
876,
13,
4706,
4853,
29889,
842,
29918,
29916,
1643,
29898,
29916,
1643,
29897,
13,
4706,
4853,
29889,
842,
29918,
29891,
1643,
877,
17144,
1353,
1495,
13,
4706,
1596,
376,
5317,
1259,
13035,
29908,
13,
4706,
274,
1165,
353,
4853,
29889,
29886,
1054,
555,
12094,
29898,
29881,
29897,
6552,
274,
1958,
2433,
19541,
1495,
13,
4706,
4853,
29889,
842,
29918,
29916,
2576,
3552,
29900,
29892,
270,
29889,
12181,
29961,
29896,
12622,
13,
4706,
4853,
29889,
842,
29918,
29891,
2576,
3552,
29900,
29892,
270,
29889,
12181,
29961,
29900,
12622,
13,
13,
4706,
274,
1646,
353,
282,
2904,
370,
29889,
2780,
1646,
29898,
1113,
29916,
29897,
13,
4706,
274,
1646,
29889,
842,
29918,
1643,
29898,
695,
1107,
29897,
13,
4706,
1596,
525,
29903,
5555,
304,
29901,
742,
2537,
29918,
9144,
13,
4706,
282,
2904,
370,
29889,
7620,
1003,
29898,
1003,
29918,
9144,
29892,
270,
1631,
29922,
29941,
29900,
29900,
29897,
13,
4706,
282,
2904,
370,
29889,
4294,
580,
13,
13,
13,
1678,
822,
9867,
29918,
29876,
1028,
29379,
29918,
1609,
29918,
14047,
29898,
1311,
29892,
599,
29918,
29876,
1028,
29379,
1125,
13,
13,
4706,
302,
29918,
1054,
353,
1583,
29889,
7529,
1839,
29876,
29918,
29882,
29883,
2033,
334,
1583,
29889,
7529,
1839,
29876,
29918,
14047,
2033,
13,
4706,
270,
29918,
449,
353,
7442,
29889,
3298,
359,
3552,
497,
29918,
29876,
1028,
29379,
29889,
12181,
29961,
29900,
1402,
302,
29918,
1054,
876,
13,
4706,
302,
29918,
3729,
29879,
29918,
546,
29918,
14047,
353,
1583,
29889,
7529,
1839,
29876,
29918,
29995,
29879,
29918,
546,
29918,
14047,
29915,
1273,
1583,
29889,
3729,
29918,
1853,
29962,
13,
4706,
363,
282,
29876,
297,
921,
3881,
29898,
1311,
29889,
21257,
29918,
3317,
1125,
13,
9651,
363,
286,
29883,
297,
921,
3881,
29898,
29876,
29918,
1054,
1125,
13,
18884,
22645,
29900,
353,
286,
29883,
334,
302,
29918,
3729,
29879,
29918,
546,
29918,
14047,
13,
18884,
22645,
29896,
353,
313,
14047,
718,
29871,
29896,
29897,
334,
302,
29918,
3729,
29879,
29918,
546,
29918,
14047,
13,
18884,
270,
29918,
449,
29961,
21257,
29892,
286,
29883,
29962,
353,
599,
29918,
29876,
1028,
29379,
29961,
21257,
29892,
22645,
29900,
29901,
13140,
29896,
1822,
2083,
580,
847,
302,
29918,
3729,
29879,
29918,
546,
29918,
14047,
13,
13,
4706,
736,
270,
29918,
449,
13,
13,
13,
1678,
822,
679,
29918,
348,
1169,
29918,
27215,
29918,
386,
3781,
29898,
1311,
29892,
6354,
29892,
266,
3781,
21098,
29900,
29906,
1125,
13,
4706,
9995,
13,
4706,
16969,
385,
1409,
411,
278,
10340,
2038,
263,
3058,
16897,
297,
6354,
29889,
13,
4706,
6354,
29871,
13,
4706,
9995,
13,
13,
4706,
302,
29918,
11037,
29879,
353,
6354,
29889,
12181,
29961,
29900,
29962,
13,
4706,
302,
29918,
348,
1169,
353,
6354,
29889,
12181,
29961,
29896,
29962,
13,
29937,
4706,
6354,
29918,
386,
3781,
353,
266,
3781,
334,
7442,
29889,
12676,
29898,
10072,
29897,
13,
29937,
4706,
6354,
29918,
386,
3781,
353,
29871,
29896,
29889,
13,
4706,
6354,
29918,
386,
3781,
353,
266,
3781,
334,
7442,
29889,
3317,
29898,
10072,
29897,
13,
4706,
1596,
525,
10072,
29918,
386,
3781,
29901,
742,
6354,
29918,
386,
3781,
13,
4706,
302,
29918,
4925,
29918,
348,
1169,
29918,
546,
29918,
11037,
353,
7442,
29889,
3298,
359,
29898,
29876,
29918,
11037,
29879,
29897,
13,
4706,
1029,
29887,
29918,
10072,
29918,
546,
29918,
11037,
353,
7442,
29889,
3298,
359,
3552,
29876,
29918,
11037,
29879,
29892,
29871,
29906,
876,
13,
4706,
363,
282,
29876,
297,
921,
3881,
29898,
29876,
29918,
11037,
29879,
1125,
13,
9651,
22645,
353,
313,
10072,
29961,
21257,
29892,
584,
29962,
1405,
6354,
29918,
386,
3781,
467,
5464,
9171,
580,
29961,
29900,
29962,
13,
9651,
302,
29918,
4925,
29918,
348,
1169,
29918,
546,
29918,
11037,
29961,
21257,
29962,
353,
22645,
29889,
2311,
13,
9651,
1029,
29887,
29918,
10072,
29918,
546,
29918,
11037,
29961,
21257,
29892,
29871,
29900,
29962,
353,
6354,
29961,
21257,
1919,
13140,
1822,
12676,
580,
13,
9651,
1029,
29887,
29918,
10072,
29918,
546,
29918,
11037,
29961,
21257,
29892,
29871,
29896,
29962,
353,
6354,
29961,
21257,
1919,
13140,
1822,
4172,
580,
13,
13,
9651,
1596,
525,
29876,
2038,
266,
3781,
297,
282,
29876,
1273,
29881,
29901,
320,
29873,
29995,
29881,
29915,
1273,
313,
21257,
29892,
22645,
29889,
2311,
29897,
13,
9651,
1596,
525,
29909,
19698,
6354,
297,
282,
29876,
1273,
29881,
29901,
18695,
29906,
29888,
718,
29899,
18695,
29906,
29888,
29915,
1273,
313,
21257,
29892,
1029,
29887,
29918,
10072,
29918,
546,
29918,
11037,
29961,
21257,
29892,
29871,
29900,
1402,
1029,
29887,
29918,
10072,
29918,
546,
29918,
11037,
29961,
21257,
29892,
29871,
29896,
2314,
13,
13,
4706,
1596,
525,
29909,
19698,
25948,
6554,
363,
599,
15038,
29901,
18695,
29906,
29888,
718,
29899,
18695,
29906,
29888,
29915,
1273,
313,
485,
29887,
29918,
10072,
29918,
546,
29918,
11037,
7503,
29892,
29871,
29900,
1822,
12676,
580,
847,
1583,
29889,
7529,
1839,
29873,
29918,
3601,
2033,
334,
29871,
29896,
29900,
29900,
29900,
1696,
1029,
29887,
29918,
10072,
29918,
546,
29918,
11037,
7503,
29892,
29871,
29896,
1822,
12676,
580,
847,
1583,
29889,
7529,
1839,
29873,
29918,
3601,
2033,
334,
29871,
29896,
29900,
29900,
29900,
1846,
13,
4706,
302,
29918,
4925,
29918,
11037,
29879,
353,
7442,
29889,
3298,
359,
29898,
29876,
29918,
348,
1169,
29897,
13,
4706,
363,
5190,
297,
921,
3881,
29898,
29876,
29918,
348,
1169,
1125,
13,
9651,
22645,
353,
313,
10072,
7503,
29892,
5190,
29962,
1405,
6354,
29918,
386,
3781,
467,
5464,
9171,
580,
29961,
29900,
29962,
13,
29937,
9651,
1596,
525,
5441,
1273,
29881,
338,
1273,
29881,
3064,
2038,
266,
3781,
29915,
1273,
313,
5441,
29892,
22645,
29889,
2311,
511,
22645,
13,
9651,
302,
29918,
4925,
29918,
11037,
29879,
29961,
5441,
29962,
353,
22645,
29889,
2311,
13,
13,
4706,
302,
29918,
4925,
29918,
271,
29918,
280,
579,
29918,
10646,
353,
313,
29876,
29918,
4925,
29918,
11037,
29879,
1405,
29871,
29900,
467,
5464,
9171,
580,
29961,
29900,
1822,
2311,
13,
4706,
302,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
10646,
353,
313,
29876,
29918,
4925,
29918,
11037,
29879,
1405,
29871,
29896,
467,
5464,
9171,
580,
29961,
29900,
1822,
2311,
13,
4706,
302,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
7516,
625,
353,
313,
29876,
29918,
4925,
29918,
11037,
29879,
1405,
29871,
29906,
467,
5464,
9171,
580,
29961,
29900,
1822,
2311,
13,
4706,
302,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
386,
4521,
1355,
353,
313,
29876,
29918,
4925,
29918,
11037,
29879,
1405,
29871,
29941,
467,
5464,
9171,
580,
29961,
29900,
1822,
2311,
13,
13,
4706,
1596,
525,
6816,
273,
6136,
10340,
639,
4766,
29901,
18695,
29906,
29888,
718,
29899,
18695,
29906,
29888,
3695,
313,
15543,
29906,
29888,
718,
29899,
18695,
29906,
29888,
10151,
16029,
1273,
313,
29876,
29918,
4925,
29918,
348,
1169,
29918,
546,
29918,
11037,
29889,
12676,
3285,
302,
29918,
4925,
29918,
348,
1169,
29918,
546,
29918,
11037,
29889,
4172,
3285,
320,
13,
18884,
302,
29918,
4925,
29918,
348,
1169,
29918,
546,
29918,
11037,
29889,
12676,
580,
847,
5785,
29898,
29876,
29918,
348,
1169,
29897,
334,
29871,
29896,
29900,
29900,
29892,
302,
29918,
4925,
29918,
348,
1169,
29918,
546,
29918,
11037,
29889,
4172,
580,
847,
5785,
29898,
29876,
29918,
348,
1169,
29897,
334,
29871,
29896,
29900,
29900,
1846,
13,
4706,
1596,
525,
6816,
273,
1353,
310,
6136,
15038,
639,
5190,
29901,
18695,
29906,
29888,
718,
29899,
18695,
29906,
29888,
3695,
313,
15543,
29906,
29888,
718,
29899,
18695,
29906,
29888,
10151,
16029,
1273,
313,
29876,
29918,
4925,
29918,
11037,
29879,
29889,
12676,
3285,
302,
29918,
4925,
29918,
11037,
29879,
29889,
4172,
3285,
320,
13,
18884,
302,
29918,
4925,
29918,
11037,
29879,
29889,
12676,
580,
847,
5785,
29898,
29876,
29918,
11037,
29879,
29897,
334,
29871,
29896,
29900,
29900,
1696,
302,
29918,
4925,
29918,
11037,
29879,
29889,
4172,
580,
847,
5785,
29898,
29876,
29918,
11037,
29879,
29897,
334,
29871,
29896,
29900,
29900,
1846,
13,
4706,
1596,
525,
4557,
310,
10340,
6136,
472,
3203,
2748,
584,
1273,
29881,
3695,
18695,
29906,
29888,
10151,
29915,
1273,
313,
29876,
29918,
4925,
29918,
271,
29918,
280,
579,
29918,
10646,
29892,
302,
29918,
4925,
29918,
271,
29918,
280,
579,
29918,
10646,
29914,
5785,
29898,
29876,
29918,
348,
1169,
29897,
334,
29871,
29896,
29900,
29900,
1846,
13,
4706,
1596,
525,
4557,
310,
10340,
901,
6136,
1135,
2748,
29901,
1273,
29881,
3695,
18695,
29906,
29888,
10151,
29915,
1273,
313,
29876,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
10646,
29892,
302,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
10646,
847,
5785,
29898,
29876,
29918,
348,
1169,
29897,
334,
29871,
29896,
29900,
29900,
1846,
13,
4706,
1596,
525,
4557,
310,
10340,
901,
6136,
1135,
8951,
29901,
1273,
29881,
3695,
18695,
29906,
29888,
10151,
29915,
1273,
313,
29876,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
7516,
625,
29892,
302,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
7516,
625,
847,
5785,
29898,
29876,
29918,
348,
1169,
29897,
334,
29871,
29896,
29900,
29900,
1846,
13,
4706,
1596,
525,
4557,
310,
10340,
901,
6136,
1135,
266,
4521,
1355,
29901,
1273,
29881,
3695,
18695,
29906,
29888,
10151,
29915,
1273,
313,
29876,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
386,
4521,
1355,
29892,
302,
29918,
4925,
29918,
5514,
29918,
27603,
29918,
386,
4521,
1355,
847,
5785,
29898,
29876,
29918,
348,
1169,
29897,
334,
29871,
29896,
29900,
29900,
1846,
13,
4706,
1596,
525,
1349,
12268,
338,
18695,
29906,
29872,
29892,
8380,
995,
29901,
18695,
29906,
29888,
805,
29379,
29915,
1273,
313,
386,
3781,
29892,
6354,
29918,
386,
3781,
29897,
13,
13,
13,
13,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
13,
1678,
1018,
29901,
13,
4706,
4138,
353,
10876,
29889,
19218,
29961,
29896,
29962,
13,
4706,
8636,
29918,
9144,
353,
2897,
29889,
2084,
29889,
370,
1028,
493,
29898,
12083,
29897,
718,
8207,
11507,
29914,
3601,
2785,
29918,
16744,
29889,
3126,
29915,
13,
4706,
1828,
29918,
10154,
353,
17402,
29918,
16744,
29889,
15501,
29918,
12925,
29898,
7529,
29918,
9144,
29922,
7529,
29918,
9144,
29897,
13,
1678,
5174,
29901,
13,
4706,
1828,
29918,
10154,
353,
17402,
29918,
16744,
29889,
15501,
29918,
12925,
580,
13,
13,
1678,
8636,
353,
1828,
29918,
10154,
29889,
7529,
13,
1678,
1596,
525,
8382,
302,
29918,
3729,
29879,
742,
8636,
1839,
29876,
29918,
3729,
29879,
2033,
13,
13,
1678,
1018,
29901,
13,
4706,
3038,
29918,
1853,
353,
10876,
29889,
19218,
29961,
29906,
29962,
13,
1678,
5174,
29901,
13,
4706,
1596,
525,
18552,
292,
3038,
29918,
1853,
2980,
29915,
13,
4706,
1596,
525,
27573,
29901,
3017,
6492,
29918,
10072,
29918,
294,
29918,
1054,
555,
481,
29889,
2272,
383,
5607,
8032,
29918,
5813,
14645,
2208,
29918,
11116,
518,
15695,
29918,
12648,
29962,
29915,
13,
4706,
6876,
29898,
29896,
29897,
13,
13,
1678,
1018,
29901,
13,
4706,
282,
29876,
29918,
3317,
353,
938,
29898,
9675,
29889,
19218,
29961,
29941,
2314,
13,
1678,
5174,
29901,
13,
4706,
1596,
525,
20867,
1259,
599,
15038,
29915,
13,
4706,
282,
29876,
29918,
3317,
353,
8636,
1839,
29876,
29918,
11037,
29879,
2033,
13,
13,
29937,
1678,
282,
29876,
29918,
3317,
353,
29871,
29946,
13,
1678,
282,
2904,
370,
29889,
2214,
9629,
29889,
5504,
29898,
5317,
29918,
7529,
29897,
13,
1678,
349,
353,
18399,
357,
29898,
7529,
29897,
13,
13,
1678,
565,
313,
3729,
29918,
1853,
1275,
525,
2272,
29878,
29915,
470,
3038,
29918,
1853,
1275,
525,
2288,
9302,
29374,
13,
4706,
3431,
353,
10650,
29918,
2080,
877,
6821,
5402,
302,
1028,
29379,
491,
1375,
5283,
1227,
29973,
29905,
29876,
1495,
13,
4706,
565,
3431,
29889,
5030,
2410,
675,
580,
1275,
525,
29979,
29915,
470,
3431,
1275,
525,
2396,
13,
9651,
349,
29889,
5317,
29898,
21257,
29918,
3317,
29892,
3038,
29918,
1853,
29892,
286,
29883,
29918,
695,
504,
3241,
29922,
5574,
29897,
13,
4706,
1683,
29901,
13,
9651,
349,
29889,
5317,
29898,
21257,
29918,
3317,
29892,
3038,
29918,
1853,
29897,
13,
1678,
1683,
29901,
13,
4706,
349,
29889,
5317,
29898,
21257,
29918,
3317,
29892,
3038,
29918,
1853,
29897,
13,
2
] |
test/test_modify_user.py | chernenko-art/test_python | 0 | 57687 | <gh_stars>0
# -*- coding: utf-8 -*-
import random
from model.user import User
def test_modify_user_name(app, db, json_users, check_ui):
# check what groups is not empty
if len(db.get_user_list()) == 0:
user = json_users
app.user.create(user)
user = User(firstname="Piter", lastname="Ivanov", middlename="Sergeevich")
# get current user list from db
old_user_list = db.get_user_list()
# get id for modify random user
user_random = random.choice(old_user_list)
user.id = user_random.id
app.user.modify_by_id(user.id, user)
# get new user list
new_user_list = db.get_user_list()
# replace first user to modify user
old_user_list.remove(user_random)
old_user_list.append(user)
assert sorted(old_user_list, key=User.id_or_max) == sorted(new_user_list, key=User.id_or_max)
if check_ui:
assert sorted(new_user_list, key=User.id_or_max) == sorted(app.user.get_contact_list(), key=User.id_or_max)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
30004,
13,
5215,
4036,
30004,
13,
3166,
1904,
29889,
1792,
1053,
4911,
30004,
13,
30004,
13,
30004,
13,
1753,
1243,
29918,
1545,
1598,
29918,
1792,
29918,
978,
29898,
932,
29892,
4833,
29892,
4390,
29918,
7193,
29892,
1423,
29918,
1481,
1125,
30004,
13,
1678,
396,
1423,
825,
6471,
338,
451,
4069,
30004,
13,
1678,
565,
7431,
29898,
2585,
29889,
657,
29918,
1792,
29918,
1761,
3101,
1275,
29871,
29900,
29901,
30004,
13,
4706,
1404,
353,
4390,
29918,
7193,
30004,
13,
4706,
623,
29889,
1792,
29889,
3258,
29898,
1792,
8443,
13,
1678,
1404,
353,
4911,
29898,
4102,
978,
543,
29925,
1524,
613,
1833,
978,
543,
29902,
3703,
586,
613,
286,
2205,
2435,
420,
543,
1748,
479,
5750,
436,
1159,
30004,
13,
1678,
396,
679,
1857,
1404,
1051,
515,
4833,
30004,
13,
1678,
2030,
29918,
1792,
29918,
1761,
353,
4833,
29889,
657,
29918,
1792,
29918,
1761,
26471,
13,
1678,
396,
679,
1178,
363,
6623,
4036,
1404,
30004,
13,
1678,
1404,
29918,
8172,
353,
4036,
29889,
16957,
29898,
1025,
29918,
1792,
29918,
1761,
8443,
13,
1678,
1404,
29889,
333,
353,
1404,
29918,
8172,
29889,
333,
30004,
13,
1678,
623,
29889,
1792,
29889,
1545,
1598,
29918,
1609,
29918,
333,
29898,
1792,
29889,
333,
29892,
1404,
8443,
13,
1678,
396,
679,
716,
1404,
1051,
30004,
13,
1678,
716,
29918,
1792,
29918,
1761,
353,
4833,
29889,
657,
29918,
1792,
29918,
1761,
26471,
13,
1678,
396,
5191,
937,
1404,
304,
6623,
1404,
30004,
13,
1678,
2030,
29918,
1792,
29918,
1761,
29889,
5992,
29898,
1792,
29918,
8172,
8443,
13,
1678,
2030,
29918,
1792,
29918,
1761,
29889,
4397,
29898,
1792,
8443,
13,
1678,
4974,
12705,
29898,
1025,
29918,
1792,
29918,
1761,
29892,
1820,
29922,
2659,
29889,
333,
29918,
272,
29918,
3317,
29897,
1275,
12705,
29898,
1482,
29918,
1792,
29918,
1761,
29892,
1820,
29922,
2659,
29889,
333,
29918,
272,
29918,
3317,
8443,
13,
1678,
565,
1423,
29918,
1481,
29901,
30004,
13,
4706,
4974,
12705,
29898,
1482,
29918,
1792,
29918,
1761,
29892,
1820,
29922,
2659,
29889,
333,
29918,
272,
29918,
3317,
29897,
1275,
12705,
29898,
932,
29889,
1792,
29889,
657,
29918,
12346,
29918,
1761,
3285,
1820,
29922,
2659,
29889,
333,
29918,
272,
29918,
3317,
8443,
13,
2
] |
test/common/test_null.py | thatch/BitSwanPump | 17 | 183971 | import bspump.unittest
import bspump.common
class TestNullSink(bspump.unittest.ProcessorTestCase):
def test_null(self):
events = [
(None, "Don't let this out!"),
]
self.set_up_processor(bspump.common.NullSink)
output = self.execute(
events
)
self.assertEqual(
[event for context, event in output],
[]
)
| [
1,
1053,
289,
1028,
3427,
29889,
348,
27958,
13,
5215,
289,
1028,
3427,
29889,
9435,
13,
13,
13,
1990,
4321,
7327,
29903,
682,
29898,
29890,
1028,
3427,
29889,
348,
27958,
29889,
18689,
3057,
8259,
1125,
13,
13,
12,
1753,
1243,
29918,
4304,
29898,
1311,
1125,
13,
12,
12,
13604,
353,
518,
13,
12,
12,
12,
29898,
8516,
29892,
376,
10310,
29915,
29873,
1235,
445,
714,
3850,
511,
13,
12,
12,
29962,
13,
13,
12,
12,
1311,
29889,
842,
29918,
786,
29918,
26482,
29898,
29890,
1028,
3427,
29889,
9435,
29889,
7327,
29903,
682,
29897,
13,
13,
12,
12,
4905,
353,
1583,
29889,
7978,
29898,
13,
12,
12,
12,
13604,
13,
12,
12,
29897,
13,
13,
12,
12,
1311,
29889,
9294,
9843,
29898,
13,
12,
12,
12,
29961,
3696,
363,
3030,
29892,
1741,
297,
1962,
1402,
13,
12,
12,
12,
2636,
13,
12,
12,
29897,
13,
2
] |
pyec/distribution/nn/net.py | hypernicon/pyec | 2 | 126706 | """
Copyright (C) 2012 <NAME>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
import numpy as np
class RnnEvaluator(object):
"""A compiled RNN as a computable object. Takes a network in a form that
is efficient to activate so that the network can be evaluated quickly.
Produced by :class:`LayeredRnnGenotype`'s ``compile`` method.
:param numNeurons: The number of neurons in the network, incl. bias, input,
output, and hidden
:type numNeurons: ``int``
:param inputs: A list of slices or indexes that can be applied to the
current state to set input values. The list should contain
one item per input layer, and each item should be capable
of being provided to ``__setitem__`` in order to set the
input values. So, for instance, an entry ``slice(5,10)``
at index ``2`` in the array would imply that the third
input layer state values are stored between the 5th and 10th
index in the state, and that the input layer contains
five values.
:type inputs: A ``list`` of ``slice``s or ``int``s, potentially mixed
:param outputs: A list of slices or indexes that can be applied to the
current state to extract output values. Like the structure
for ``inputs``, but used to retrieve outputs.
:type outputs: A ``list`` of ``slice``s or ``int``s, potentially mixed
:param weightStack: A list of lists of entries that apply the weights
of a neural network. Each entry contains a weight
matrix (``numpy.ndarray``), a ``slice`` indicating
the source indices, and a ``slice`` indicating the
target indices. Each nested list represents a set of
operations that may be performed concurrently, i.e.
that may be parallellized. Successive elements of the
outermost list must be performed serially.
:type weightStack: A ``list`` of ``list``s each with a `tuple` containing
(``numpy.ndarray``, ``slice``, ``slice``)
:param activationStack: A list of (``slice``,function) tuples that contains
the activation functions that must be applied for
each layer. The ``slice`` indicates the location of
the layer in the state array, and the function is
used to activate that portion of the state array.
"""
def __init__(self, numNeurons, inputs, outputs, weightStack, activationStack):
self.numNeurons = numNeurons
self.inputs = inputs
self.outputs = outputs
self.weightStack = weightStack
self.activationStack = activationStack
self.clear()
def clear(self):
"""Reset the state of the network."""
self.state = np.zeros(self.numNeurons)
def setInputs(self, inputs):
"""Takes an array of arrays of floats and writes
it into the state at the inputs
:param inputs: a list of arrays of floats, with each nested array matching
the size of the input layer as specified in ``self.inputs``
:type inputs: a list of arrays/lists of floats
"""
# don't check match for efficiency
for idxs,vals in zip(self.inputs, inputs):
self.state[idxs] = vals
def getOutputs(self):
"""Produces an array of floats corresponding to the outputs.
:returns: a list of arrays of floats, with each nested array matching
the size of the input layer as specified in ``self.outputs``
"""
return [self.state[idxs] for idxs in self.outputs]
def activate(self):
"""Advance the network to the next state based on the current state."""
next = np.zeros(self.numNeurons)
for step in self.weightStack:
for w, frmIdxs, toIdxs in step:
next[toIdxs] += np.dot(w, self.state[frmIdxs])
for idxs, act in self.activationStack:
next[idxs] = act(next[idxs])
self.state = next
def call(self, inputs, times=5):
self.setInputs(inputs)
for i in xrange(times):
self.activate()
return self.getOutputs()
def __call__(self, inputs, times=5):
return self.call(inputs, times) | [
1,
9995,
13,
11882,
1266,
313,
29907,
29897,
29871,
29906,
29900,
29896,
29906,
529,
5813,
29958,
13,
13,
27293,
338,
1244,
1609,
16896,
29892,
3889,
310,
8323,
29892,
304,
738,
2022,
4017,
292,
263,
3509,
310,
445,
7047,
322,
6942,
5106,
2066,
313,
1552,
376,
6295,
14093,
4968,
304,
5376,
297,
278,
18540,
1728,
24345,
29892,
3704,
1728,
29485,
278,
10462,
304,
671,
29892,
3509,
29892,
6623,
29892,
10366,
29892,
9805,
29892,
1320,
2666,
29892,
269,
803,
1947,
29892,
322,
29914,
272,
19417,
14591,
310,
278,
18540,
29892,
322,
304,
14257,
12407,
304,
6029,
278,
18540,
338,
15252,
3276,
304,
437,
577,
29892,
4967,
304,
278,
1494,
5855,
29901,
13,
13,
1576,
2038,
3509,
1266,
8369,
322,
445,
10751,
8369,
4091,
367,
5134,
297,
599,
14591,
470,
23228,
2011,
1080,
310,
278,
18540,
29889,
13,
13,
28350,
7791,
7818,
12982,
1525,
8519,
13756,
13044,
3352,
376,
3289,
8519,
613,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29979,
8079,
13764,
29979,
476,
22255,
29892,
8528,
15094,
1799,
6323,
306,
3580,
5265,
3352,
29892,
2672,
6154,
15789,
4214,
350,
2692,
6058,
27848,
3352,
7495,
6093,
399,
1718,
29934,
13566,
29059,
8079,
341,
1001,
3210,
13566,
2882,
6227,
11937,
29892,
383,
1806,
8186,
1799,
15842,
319,
349,
8322,
2965,
13309,
1718,
349,
4574,
13152,
1660,
5300,
405,
1164,
1177,
15860,
1177,
1692,
13780,
29889,
2672,
11698,
382,
29963,
3919,
24972,
9818,
6093,
26524,
29950,
24125,
6323,
315,
4590,
29979,
22789,
3912,
379,
5607,
8032,
29903,
20700,
17705,
6181,
15842,
13764,
29979,
315,
4375,
7833,
29892,
21330,
1529,
1692,
29903,
6323,
438,
29911,
4448,
17705,
2882,
6227,
11937,
29892,
12317,
2544,
4448,
2672,
13764,
319,
9838,
8079,
8707,
29911,
4717,
1783,
29892,
323,
8476,
6323,
438,
29911,
4448,
22119,
1660,
29892,
9033,
3235,
4214,
3895,
29892,
19474,
8079,
6323,
2672,
8707,
8186,
9838,
22659,
6093,
7791,
7818,
12982,
1525,
6323,
6093,
501,
1660,
6323,
438,
29911,
4448,
5012,
1964,
4214,
29903,
2672,
6093,
7791,
7818,
12982,
1525,
29889,
13,
13,
15945,
29908,
13,
5215,
12655,
408,
7442,
13,
13,
1990,
390,
15755,
29923,
4387,
1061,
29898,
3318,
1125,
13,
1678,
9995,
29909,
13126,
390,
10262,
408,
263,
2912,
519,
1203,
29889,
323,
6926,
263,
3564,
297,
263,
883,
393,
13,
1678,
338,
8543,
304,
5039,
403,
577,
393,
278,
3564,
508,
367,
19030,
9098,
29889,
13,
268,
13,
1678,
7138,
1133,
491,
584,
1990,
18078,
14420,
287,
29934,
15755,
15462,
327,
668,
20497,
29879,
4954,
12198,
16159,
1158,
29889,
13,
268,
13,
1678,
584,
3207,
954,
29940,
5411,
787,
29901,
450,
1353,
310,
26808,
787,
297,
278,
3564,
29892,
1343,
29889,
24003,
29892,
1881,
29892,
13,
462,
539,
1962,
29892,
322,
7934,
13,
1678,
584,
1853,
954,
29940,
5411,
787,
29901,
4954,
524,
16159,
13,
1678,
584,
3207,
10970,
29901,
319,
1051,
310,
269,
29399,
470,
18111,
393,
508,
367,
7436,
304,
278,
13,
462,
259,
1857,
2106,
304,
731,
1881,
1819,
29889,
450,
1051,
881,
1712,
13,
462,
259,
697,
2944,
639,
1881,
7546,
29892,
322,
1269,
2944,
881,
367,
15390,
13,
462,
259,
310,
1641,
4944,
304,
4954,
1649,
842,
667,
1649,
16159,
297,
1797,
304,
731,
278,
13,
462,
259,
1881,
1819,
29889,
1105,
29892,
363,
2777,
29892,
385,
6251,
4954,
18337,
29898,
29945,
29892,
29896,
29900,
3569,
29952,
13,
462,
259,
472,
2380,
4954,
29906,
16159,
297,
278,
1409,
723,
22366,
393,
278,
4654,
13,
462,
259,
1881,
7546,
2106,
1819,
526,
6087,
1546,
278,
29871,
29945,
386,
322,
29871,
29896,
29900,
386,
13,
462,
259,
2380,
297,
278,
2106,
29892,
322,
393,
278,
1881,
7546,
3743,
13,
462,
259,
5320,
1819,
29889,
13,
1678,
584,
1853,
10970,
29901,
319,
4954,
1761,
16159,
310,
4954,
18337,
16159,
29879,
470,
4954,
524,
16159,
29879,
29892,
19998,
12849,
13,
1678,
584,
3207,
14391,
29901,
319,
1051,
310,
269,
29399,
470,
18111,
393,
508,
367,
7436,
304,
278,
13,
462,
1678,
1857,
2106,
304,
6597,
1962,
1819,
29889,
8502,
278,
3829,
13,
462,
1678,
363,
4954,
2080,
29879,
29952,
1673,
541,
1304,
304,
10563,
14391,
29889,
13,
1678,
584,
1853,
14391,
29901,
319,
4954,
1761,
16159,
310,
4954,
18337,
16159,
29879,
470,
4954,
524,
16159,
29879,
29892,
19998,
12849,
13,
1678,
584,
3207,
7688,
7264,
29901,
319,
1051,
310,
8857,
310,
9976,
393,
3394,
278,
18177,
13,
462,
4706,
310,
263,
19677,
3564,
29889,
7806,
6251,
3743,
263,
7688,
13,
462,
4706,
4636,
6695,
29952,
23749,
29889,
299,
2378,
16159,
511,
263,
4954,
18337,
16159,
23941,
13,
462,
4706,
278,
2752,
16285,
29892,
322,
263,
4954,
18337,
16159,
23941,
278,
13,
462,
4706,
3646,
16285,
29889,
7806,
9322,
1051,
11524,
263,
731,
310,
13,
462,
4706,
6931,
393,
1122,
367,
8560,
21984,
368,
29892,
474,
29889,
29872,
29889,
13,
462,
4706,
393,
1122,
367,
610,
3498,
645,
1891,
29889,
21397,
573,
3161,
310,
278,
13,
462,
4706,
11420,
3242,
1051,
1818,
367,
8560,
7797,
368,
29889,
13,
1678,
584,
1853,
7688,
7264,
29901,
319,
4954,
1761,
16159,
310,
4954,
1761,
16159,
29879,
1269,
411,
263,
421,
23583,
29952,
6943,
13,
462,
539,
6695,
29952,
23749,
29889,
299,
2378,
29952,
1673,
4954,
18337,
29952,
1673,
4954,
18337,
29952,
6348,
13,
1678,
584,
3207,
26229,
7264,
29901,
319,
1051,
310,
6695,
29952,
18337,
29952,
1673,
2220,
29897,
5291,
2701,
393,
3743,
13,
462,
9651,
278,
26229,
3168,
393,
1818,
367,
7436,
363,
13,
462,
9651,
1269,
7546,
29889,
450,
4954,
18337,
16159,
14088,
278,
4423,
310,
13,
462,
9651,
278,
7546,
297,
278,
2106,
1409,
29892,
322,
278,
740,
338,
13,
462,
9651,
1304,
304,
5039,
403,
393,
11910,
310,
278,
2106,
1409,
29889,
13,
268,
13,
1678,
9995,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
954,
29940,
5411,
787,
29892,
10970,
29892,
14391,
29892,
7688,
7264,
29892,
26229,
7264,
1125,
13,
4706,
1583,
29889,
1949,
29940,
5411,
787,
353,
954,
29940,
5411,
787,
13,
4706,
1583,
29889,
2080,
29879,
353,
10970,
13,
4706,
1583,
29889,
4905,
29879,
353,
14391,
13,
4706,
1583,
29889,
7915,
7264,
353,
7688,
7264,
13,
4706,
1583,
29889,
11236,
362,
7264,
353,
26229,
7264,
13,
4706,
1583,
29889,
8551,
580,
13,
308,
13,
1678,
822,
2821,
29898,
1311,
1125,
13,
4706,
9995,
27175,
278,
2106,
310,
278,
3564,
1213,
15945,
13,
4706,
1583,
29889,
3859,
353,
7442,
29889,
3298,
359,
29898,
1311,
29889,
1949,
29940,
5411,
787,
29897,
13,
308,
13,
1678,
822,
731,
4290,
29879,
29898,
1311,
29892,
10970,
1125,
13,
4706,
9995,
29911,
6926,
385,
1409,
310,
7049,
310,
5685,
1446,
322,
15873,
13,
4706,
372,
964,
278,
2106,
472,
278,
10970,
13,
308,
13,
4706,
584,
3207,
10970,
29901,
263,
1051,
310,
7049,
310,
5685,
1446,
29892,
411,
1269,
9322,
1409,
9686,
13,
462,
539,
278,
2159,
310,
278,
1881,
7546,
408,
6790,
297,
4954,
1311,
29889,
2080,
29879,
16159,
13,
4706,
584,
1853,
10970,
29901,
263,
1051,
310,
7049,
29914,
21513,
310,
5685,
1446,
13,
308,
13,
4706,
9995,
13,
4706,
396,
1016,
29915,
29873,
1423,
1993,
363,
19201,
13,
4706,
363,
1178,
10351,
29892,
791,
29879,
29871,
297,
14319,
29898,
1311,
29889,
2080,
29879,
29892,
10970,
1125,
13,
965,
1583,
29889,
3859,
29961,
333,
10351,
29962,
353,
659,
29879,
13,
268,
13,
1678,
822,
679,
6466,
29879,
29898,
1311,
1125,
13,
4706,
9995,
23665,
778,
385,
1409,
310,
5685,
1446,
6590,
304,
278,
14391,
29889,
13,
308,
13,
4706,
584,
18280,
29901,
263,
1051,
310,
7049,
310,
5685,
1446,
29892,
411,
1269,
9322,
1409,
9686,
13,
462,
29871,
278,
2159,
310,
278,
1881,
7546,
408,
6790,
297,
4954,
1311,
29889,
4905,
29879,
16159,
13,
308,
13,
4706,
9995,
13,
4706,
736,
518,
1311,
29889,
3859,
29961,
333,
10351,
29962,
363,
1178,
10351,
297,
1583,
29889,
4905,
29879,
29962,
13,
418,
13,
1678,
822,
5039,
403,
29898,
1311,
1125,
13,
4706,
9995,
3253,
29894,
749,
278,
3564,
304,
278,
2446,
2106,
2729,
373,
278,
1857,
2106,
1213,
15945,
13,
4706,
2446,
353,
7442,
29889,
3298,
359,
29898,
1311,
29889,
1949,
29940,
5411,
787,
29897,
13,
4706,
363,
4331,
297,
1583,
29889,
7915,
7264,
29901,
13,
9651,
363,
281,
29892,
1424,
29885,
1204,
10351,
29892,
304,
1204,
10351,
297,
4331,
29901,
13,
18884,
2446,
29961,
517,
1204,
10351,
29962,
4619,
7442,
29889,
6333,
29898,
29893,
29892,
1583,
29889,
3859,
29961,
1341,
29885,
1204,
10351,
2314,
13,
4706,
363,
1178,
10351,
29892,
1044,
297,
1583,
29889,
11236,
362,
7264,
29901,
13,
9651,
2446,
29961,
333,
10351,
29962,
353,
1044,
29898,
4622,
29961,
333,
10351,
2314,
13,
4706,
1583,
29889,
3859,
353,
2446,
13,
13,
1678,
822,
1246,
29898,
1311,
29892,
10970,
29892,
3064,
29922,
29945,
1125,
13,
4706,
1583,
29889,
842,
4290,
29879,
29898,
2080,
29879,
29897,
13,
4706,
363,
474,
297,
921,
3881,
29898,
3706,
1125,
13,
9651,
1583,
29889,
11236,
403,
580,
13,
4706,
736,
1583,
29889,
657,
6466,
29879,
580,
13,
268,
13,
1678,
822,
4770,
4804,
12035,
1311,
29892,
10970,
29892,
3064,
29922,
29945,
1125,
13,
4706,
736,
1583,
29889,
4804,
29898,
2080,
29879,
29892,
3064,
29897,
2
] |
dachar/utils/__init__.py | roocs/dachar | 2 | 20445 | <filename>dachar/utils/__init__.py
from .common import *
from .json_store import *
| [
1,
529,
9507,
29958,
29881,
496,
279,
29914,
13239,
29914,
1649,
2344,
26914,
2272,
13,
3166,
869,
9435,
1053,
334,
13,
3166,
869,
3126,
29918,
8899,
1053,
334,
13,
2
] |
monitor/traffic_monitor/views/video_views.py | mcdomx/TrafficMonitor | 0 | 140512 | import logging
import time
import pafy
import cv2
import cvlib as cv
from cvlib.object_detection import draw_bbox, populate_class_labels
import numpy as np
from django.http import StreamingHttpResponse
from traffic_monitor.detectors.detector_cvlib import DetectorCVlib
logger = logging.getLogger('video_models')
logger.setLevel(level=logging.DEBUG)
# VIDEO STREAM FUNCTIONS
def get_stream_url(cam: str) -> str:
"""
Determine the true url of the video stream.
Use YouTube url if not a local webcam.
"""
if type(cam) is str and cam.isdigit():
cam = int(cam)
# test video feed
read_pass = _test_cam(cam)
# if capture fails, try as YouTube Stream
# https://pypi.org/project/pafy/
if not read_pass:
if '/' in cam and 'youtube' in cam: # a full video path was given
cam = cam.split('/')[-1]
try:
video_pafy = pafy.new(cam)
except Exception:
raise Exception("No video stream found: {}".format(cam))
# get most reasonable stream h x w < 350k
res_limit = 105000
stream_num = 0
# use pafy to get the url of the stream
# find stream with resolution within res_limit
logger.info("Available stream sizes:")
for s in video_pafy.streams:
logger.info(f"\t{s}")
for i, stream in enumerate(video_pafy.streams):
x, y = np.array(stream.resolution.split('x'), dtype=int)
if x * y < res_limit:
stream_num = i
else:
break
stream = video_pafy.streams[stream_num]
logger.info(f"Selected stream: {video_pafy.streams[stream_num]}")
# test stream
read_pass = _test_cam(stream.url)
if read_pass:
cam = stream.url
logger.info("YouTube Video Stream Detected!")
logger.info("Video Resolution : {}".format(stream.resolution))
logger.info("Video Test : {}".format("OK" if read_pass else "FAIL - check that streamer is publishing"))
if not read_pass:
raise Exception("Can't acquire video source: {}".format(cam))
return cam
def _test_cam(cam: str) -> bool:
cap = cv2.VideoCapture(cam)
read_pass = cap.grab()
cap.release()
if not read_pass:
return False
return True
def get_camfps(cam: str) -> float:
"""
Return the camera's published FPS.
"""
cap = cv2.VideoCapture(cam)
cam_fps = cap.get(cv2.CAP_PROP_FPS)
cap.release()
return cam_fps
# https://github.com/arunponnusamy/object-detection-opencv/raw/master/yolov3.cfg
# https://pjreddie.com/media/files/yolov3.weights
def gen_stream():
"""Video streaming generator function."""
# set source of video stream
cam_stream = '1EiC9bvVGnk'
cam_name = get_stream_url(cam_stream)
cap = cv2.VideoCapture(cam_name)
# set the detector to use (supports: yolov3, yolov3-tiny)
detector = DetectorCVlib(model='yolov3-tiny', verbosity=3)
interval = 100
count = 0
while True:
time.sleep(.02)
success, frame = cap.read()
if not success:
continue
count += 1
if count % interval == 0:
_, frame, detections = detector.detect(frame, det_objs=None)
count = 0
frame = cv2.imencode('.jpg', frame)[1].tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
def video_feed(request):
"""Video streaming route. Put this in the src attribute of an img tag."""
return StreamingHttpResponse(gen_stream(), content_type="multipart/x-mixed-replace;boundary=frame")
# END VIDEO STEAMING FUNCTIONS ##########################
| [
1,
1053,
12183,
13,
5215,
931,
13,
13,
5215,
282,
2142,
29891,
13,
5215,
13850,
29906,
13,
5215,
13850,
1982,
408,
13850,
13,
3166,
13850,
1982,
29889,
3318,
29918,
29881,
2650,
428,
1053,
4216,
29918,
29890,
1884,
29892,
19450,
29918,
1990,
29918,
21134,
13,
5215,
12655,
408,
7442,
13,
13,
3166,
9557,
29889,
1124,
1053,
13763,
292,
5506,
5103,
13,
13,
3166,
12469,
29918,
3712,
2105,
29889,
4801,
11142,
29889,
4801,
3019,
29918,
11023,
1982,
1053,
5953,
3019,
15633,
1982,
13,
13,
21707,
353,
12183,
29889,
657,
16363,
877,
9641,
29918,
9794,
1495,
13,
21707,
29889,
842,
10108,
29898,
5563,
29922,
21027,
29889,
18525,
29897,
13,
13,
13,
29937,
478,
22027,
29949,
6850,
1525,
5194,
383,
28700,
29903,
13,
1753,
679,
29918,
5461,
29918,
2271,
29898,
11108,
29901,
851,
29897,
1599,
851,
29901,
13,
1678,
9995,
13,
1678,
5953,
837,
457,
278,
1565,
3142,
310,
278,
4863,
4840,
29889,
13,
1678,
4803,
14711,
3142,
565,
451,
263,
1887,
1856,
11108,
29889,
13,
1678,
9995,
13,
13,
1678,
565,
1134,
29898,
11108,
29897,
338,
851,
322,
3949,
29889,
275,
26204,
7295,
13,
4706,
3949,
353,
938,
29898,
11108,
29897,
13,
13,
1678,
396,
1243,
4863,
8343,
13,
1678,
1303,
29918,
3364,
353,
903,
1688,
29918,
11108,
29898,
11108,
29897,
13,
13,
1678,
396,
565,
10446,
8465,
29892,
1018,
408,
14711,
13763,
13,
1678,
396,
2045,
597,
29886,
1478,
29875,
29889,
990,
29914,
4836,
29914,
29886,
2142,
29891,
29914,
13,
1678,
565,
451,
1303,
29918,
3364,
29901,
13,
4706,
565,
8207,
29915,
297,
3949,
322,
525,
19567,
29915,
297,
3949,
29901,
29871,
396,
263,
2989,
4863,
2224,
471,
2183,
13,
9651,
3949,
353,
3949,
29889,
5451,
11219,
1495,
14352,
29896,
29962,
13,
4706,
1018,
29901,
13,
9651,
4863,
29918,
29886,
2142,
29891,
353,
282,
2142,
29891,
29889,
1482,
29898,
11108,
29897,
13,
4706,
5174,
8960,
29901,
13,
9651,
12020,
8960,
703,
3782,
4863,
4840,
1476,
29901,
6571,
1642,
4830,
29898,
11108,
876,
13,
4706,
396,
679,
1556,
15590,
4840,
298,
921,
281,
529,
29871,
29941,
29945,
29900,
29895,
13,
4706,
620,
29918,
13400,
353,
29871,
29896,
29900,
29945,
29900,
29900,
29900,
13,
4706,
4840,
29918,
1949,
353,
29871,
29900,
13,
13,
4706,
396,
671,
282,
2142,
29891,
304,
679,
278,
3142,
310,
278,
4840,
13,
4706,
396,
1284,
4840,
411,
10104,
2629,
620,
29918,
13400,
13,
4706,
17927,
29889,
3888,
703,
27635,
4840,
15786,
29901,
1159,
13,
4706,
363,
269,
297,
4863,
29918,
29886,
2142,
29891,
29889,
5461,
29879,
29901,
13,
9651,
17927,
29889,
3888,
29898,
29888,
26732,
29873,
29912,
29879,
27195,
13,
13,
4706,
363,
474,
29892,
4840,
297,
26985,
29898,
9641,
29918,
29886,
2142,
29891,
29889,
5461,
29879,
1125,
13,
9651,
921,
29892,
343,
353,
7442,
29889,
2378,
29898,
5461,
29889,
9778,
918,
29889,
5451,
877,
29916,
5477,
26688,
29922,
524,
29897,
13,
9651,
565,
921,
334,
343,
529,
620,
29918,
13400,
29901,
13,
18884,
4840,
29918,
1949,
353,
474,
13,
9651,
1683,
29901,
13,
18884,
2867,
13,
13,
4706,
4840,
353,
4863,
29918,
29886,
2142,
29891,
29889,
5461,
29879,
29961,
5461,
29918,
1949,
29962,
13,
4706,
17927,
29889,
3888,
29898,
29888,
29908,
8592,
4840,
29901,
426,
9641,
29918,
29886,
2142,
29891,
29889,
5461,
29879,
29961,
5461,
29918,
1949,
12258,
1159,
13,
13,
4706,
396,
1243,
4840,
13,
4706,
1303,
29918,
3364,
353,
903,
1688,
29918,
11108,
29898,
5461,
29889,
2271,
29897,
13,
13,
4706,
565,
1303,
29918,
3364,
29901,
13,
9651,
3949,
353,
4840,
29889,
2271,
13,
9651,
17927,
29889,
3888,
703,
3492,
13425,
13987,
13763,
5953,
26458,
29991,
1159,
13,
9651,
17927,
29889,
3888,
703,
15167,
24062,
918,
584,
6571,
1642,
4830,
29898,
5461,
29889,
9778,
918,
876,
13,
13,
1678,
17927,
29889,
3888,
703,
15167,
4321,
539,
584,
6571,
1642,
4830,
703,
8949,
29908,
565,
1303,
29918,
3364,
1683,
376,
4519,
6227,
448,
1423,
393,
4840,
261,
338,
27256,
5783,
13,
13,
1678,
565,
451,
1303,
29918,
3364,
29901,
13,
4706,
12020,
8960,
703,
6028,
29915,
29873,
1274,
1548,
4863,
2752,
29901,
6571,
1642,
4830,
29898,
11108,
876,
13,
13,
1678,
736,
3949,
13,
13,
13,
1753,
903,
1688,
29918,
11108,
29898,
11108,
29901,
851,
29897,
1599,
6120,
29901,
13,
1678,
2117,
353,
13850,
29906,
29889,
15167,
21133,
545,
29898,
11108,
29897,
13,
1678,
1303,
29918,
3364,
353,
2117,
29889,
3874,
29890,
580,
13,
1678,
2117,
29889,
14096,
580,
13,
13,
1678,
565,
451,
1303,
29918,
3364,
29901,
13,
4706,
736,
7700,
13,
13,
1678,
736,
5852,
13,
13,
13,
1753,
679,
29918,
11108,
29888,
567,
29898,
11108,
29901,
851,
29897,
1599,
5785,
29901,
13,
1678,
9995,
13,
1678,
7106,
278,
10656,
29915,
29879,
6369,
383,
7024,
29889,
13,
1678,
9995,
13,
1678,
2117,
353,
13850,
29906,
29889,
15167,
21133,
545,
29898,
11108,
29897,
13,
1678,
3949,
29918,
29888,
567,
353,
2117,
29889,
657,
29898,
11023,
29906,
29889,
29907,
3301,
29918,
8618,
29925,
29918,
29943,
7024,
29897,
13,
1678,
2117,
29889,
14096,
580,
13,
13,
1678,
736,
3949,
29918,
29888,
567,
13,
13,
13,
29937,
2045,
597,
3292,
29889,
510,
29914,
279,
348,
1112,
29876,
375,
25934,
29914,
3318,
29899,
29881,
2650,
428,
29899,
3150,
11023,
29914,
1610,
29914,
6207,
29914,
29891,
324,
586,
29941,
29889,
16859,
13,
29937,
2045,
597,
29886,
29926,
1127,
16217,
29889,
510,
29914,
9799,
29914,
5325,
29914,
29891,
324,
586,
29941,
29889,
705,
5861,
13,
13,
1753,
2531,
29918,
5461,
7295,
13,
1678,
9995,
15167,
24820,
15299,
740,
1213,
15945,
13,
13,
1678,
396,
731,
2752,
310,
4863,
4840,
13,
1678,
3949,
29918,
5461,
353,
525,
29896,
29923,
29875,
29907,
29929,
29890,
29894,
29963,
29954,
29876,
29895,
29915,
13,
1678,
3949,
29918,
978,
353,
679,
29918,
5461,
29918,
2271,
29898,
11108,
29918,
5461,
29897,
13,
1678,
2117,
353,
13850,
29906,
29889,
15167,
21133,
545,
29898,
11108,
29918,
978,
29897,
13,
13,
1678,
396,
731,
278,
1439,
3019,
304,
671,
313,
5924,
29879,
29901,
343,
324,
586,
29941,
29892,
343,
324,
586,
29941,
29899,
25649,
29897,
13,
1678,
1439,
3019,
353,
5953,
3019,
15633,
1982,
29898,
4299,
2433,
29891,
324,
586,
29941,
29899,
25649,
742,
9750,
359,
537,
29922,
29941,
29897,
13,
13,
1678,
7292,
353,
29871,
29896,
29900,
29900,
13,
1678,
2302,
353,
29871,
29900,
13,
1678,
1550,
5852,
29901,
13,
13,
4706,
931,
29889,
17059,
11891,
29900,
29906,
29897,
13,
13,
4706,
2551,
29892,
3515,
353,
2117,
29889,
949,
580,
13,
13,
4706,
565,
451,
2551,
29901,
13,
9651,
6773,
13,
13,
4706,
2302,
4619,
29871,
29896,
13,
4706,
565,
2302,
1273,
7292,
1275,
29871,
29900,
29901,
13,
9651,
17117,
3515,
29892,
1439,
29872,
1953,
353,
1439,
3019,
29889,
4801,
522,
29898,
2557,
29892,
1439,
29918,
711,
1315,
29922,
8516,
29897,
13,
9651,
2302,
353,
29871,
29900,
13,
13,
4706,
3515,
353,
13850,
29906,
29889,
326,
12508,
12839,
6173,
742,
3515,
9601,
29896,
1822,
517,
13193,
580,
13,
13,
4706,
7709,
313,
29890,
29915,
489,
2557,
29905,
29878,
29905,
29876,
29915,
13,
1669,
289,
29915,
3916,
29899,
1542,
29901,
1967,
29914,
26568,
29905,
29878,
29905,
29876,
29905,
29878,
29905,
29876,
29915,
718,
3515,
718,
289,
12764,
29878,
29905,
29876,
29905,
29878,
29905,
29876,
1495,
13,
13,
13,
1753,
4863,
29918,
18798,
29898,
3827,
1125,
13,
1678,
9995,
15167,
24820,
5782,
29889,
12065,
445,
297,
278,
4765,
5352,
310,
385,
10153,
4055,
1213,
15945,
13,
13,
1678,
736,
13763,
292,
5506,
5103,
29898,
1885,
29918,
5461,
3285,
2793,
29918,
1853,
543,
18056,
442,
29914,
29916,
29899,
29885,
11925,
29899,
6506,
29936,
9917,
653,
29922,
2557,
1159,
13,
13,
13,
29937,
11056,
478,
22027,
29949,
317,
4330,
5194,
4214,
383,
28700,
29903,
835,
13383,
4136,
2277,
29937,
13,
2
] |
src/kemokrw/transfer_basic.py | Kemok-Repos/kemokrw | 0 | 53545 | from kemokrw.transfer import Transfer
class BasicTransfer(Transfer):
"""Clase BasicTransfer implementación de la clase Transfer.
Cumple la función de verficar la compatibilidad de los objetos a transferir,
verifica si ambos extremos son "iguales" y transfiere un los atos de una fuente a la otra.
Atributos
---------
src : pandas.DataFrame Object
dst : pandas.DataFrame Object
max_transfer : int
Métodos
-------
verify():
Verifica si la fuente y el destino son compatibles.
Verifica si el destino es igual a la fuente.
transfer(retires=0):
Tranfiere los datos de la fuente a el destino.
"""
def __init__(self, src=None, dst=None, max_transfer=0):
""" Contruye los atributos necesarios para hacer una transferencia y verifica la compatibilidad de las fuentes.
Parametros
----------
src : pandas.DataFrame Object
Objeto origen resultante de una implementación de la clase Extract.
dst : pandas.DataFrame Object
Objeto destino resultante de una implementación de la clase Load.
max_transfer : int
Máxima cantidad de filas a transferir bajo este método.
Raises
------
Exception
No compatibility found.
"""
self.src = src
self.dst = dst
self.verification = None
self.max_transfer = max_transfer
def verify(self):
"""Verifica la compatibilidad de los objetos a transferir y verifica si el destino es igual a la fuente.
Este metodo utiliza el atributo metadata y la función get_metada() de los objetos src y dst. (Ver documentación)
1. Verifica la compatibilidad del modelo de ambos objetos bajo las siguientes reglas:
- La metadata tiene el mismo número de columnas (metadata[ncols])
- Las columnas de metadata tienen el mismo tipo respectivamente (metadata[columns][colX][type]
2. Verifica si la metadata es igual entre los objetos src y dst para aquellos "keys" de chequeo que se
encuentran en la metadata de ambas objetos.
Raises
------
Exception
No compatibility found.
"""
self.dst.get_metadata() # Actualiza la metadata del objeto destino
# Revisa que la cantidad de columnas sea igual
if self.src.metadata["ncols"] != self.dst.metadata["ncols"]:
raise Exception('No compatibility found. Different number of columns detected')
# Revisa que cada tipo de columna sea igual entre pares
for i in self.src.metadata["columns"]:
if self.src.metadata["columns"][i]["type"] != self.dst.metadata["columns"][i]["type"]:
raise Exception('No compatibility found. {2} "{0}" type do not match "{1}".'.format(
self.src.metadata["columns"][i]["type"], self.dst.metadata["columns"][i]["type"], i))
verification = True
# Revisa el número de filas en cada extremo
if self.src.metadata["check_rows"] != self.dst.metadata["check_rows"]:
verification = False
# Revisa que cada pareja de columnas para revisar los chequeos
if verification:
for i in self.src.metadata["columns"]:
common_params = set(self.src.metadata["columns"][i].keys()) & set(self.dst.metadata["columns"][i].keys())
common_params.discard("subtype")
for j in common_params:
if self.src.metadata["columns"][i][j] != self.dst.metadata["columns"][i][j]:
m = 'La columna {0} no hace match en la verificacion de {1}. {2} != {3}'
print(m.format(i, j, str(self.src.metadata["columns"][i][j])
, str(self.dst.metadata["columns"][i][j])))
verification = False
self.verification = verification
return verification
def transfer(self, retries=0):
"""Tranfiere y verifica los datos del origen al destino.
Este método realiza una verificación de los datos en ambos extremos y si no son iguales intenta transferir
los datos.
Parametros
----------
retries : int
Número de intentos adicionales en caso la verificación falle la primera vez
Raises
------
Exception
Verification failed after transfer.
"""
self.verify()
if not self.verification and self.src.data.empty:
self.src.get_data()
total_tries = 1+retries
n_try = 1
while n_try <= total_tries and not self.verification:
if n_try > 1:
print("Transferring data. Try {0} out of {1}".format(n_try, total_tries))
self.dst.save_data(self.src.data)
self.verify()
n_try += 1
if self.verification:
print('Transfer successful.')
else:
print(self.src.metadata)
print(self.dst.metadata)
raise Exception('Verification failed after transfer. Transfer tried {} times'.format(total_tries))
| [
1,
515,
413,
331,
554,
13975,
29889,
3286,
571,
1053,
17934,
13,
13,
13,
1990,
19219,
4300,
571,
29898,
4300,
571,
1125,
13,
1678,
9995,
6821,
559,
19219,
4300,
571,
2334,
2709,
316,
425,
1067,
559,
17934,
29889,
13,
268,
13,
1678,
315,
398,
552,
425,
2090,
1290,
316,
1147,
9639,
279,
425,
10007,
13017,
2368,
316,
1232,
13413,
359,
263,
6782,
381,
29892,
13,
1678,
1147,
15039,
1354,
27727,
9413,
359,
1487,
376,
335,
950,
267,
29908,
343,
1301,
7241,
406,
443,
1232,
472,
359,
316,
1185,
4084,
2016,
263,
425,
19744,
29889,
13,
13,
1678,
2180,
1091,
20864,
13,
1678,
448,
1378,
13,
1678,
4765,
584,
11701,
29889,
17271,
4669,
13,
1678,
29743,
584,
11701,
29889,
17271,
4669,
13,
1678,
4236,
29918,
3286,
571,
584,
938,
13,
13,
1678,
341,
1893,
24463,
13,
1678,
448,
22158,
13,
1678,
11539,
7295,
13,
4706,
1798,
15039,
1354,
425,
4084,
2016,
343,
560,
2731,
1789,
1487,
10007,
13876,
29889,
13,
4706,
1798,
15039,
1354,
560,
2731,
1789,
831,
21432,
263,
425,
4084,
2016,
29889,
13,
1678,
6782,
29898,
2267,
2658,
29922,
29900,
1125,
13,
4706,
323,
661,
7241,
406,
1232,
18683,
316,
425,
4084,
2016,
263,
560,
2731,
1789,
29889,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
4765,
29922,
8516,
29892,
29743,
29922,
8516,
29892,
4236,
29918,
3286,
571,
29922,
29900,
1125,
13,
4706,
9995,
1281,
509,
29884,
4099,
1232,
472,
1091,
20864,
16632,
8596,
1702,
14557,
1185,
6782,
5760,
343,
1147,
15039,
425,
10007,
13017,
2368,
316,
1869,
4084,
5326,
29889,
13,
13,
4706,
12662,
300,
1883,
13,
4706,
448,
1378,
29899,
13,
9651,
4765,
584,
11701,
29889,
17271,
4669,
13,
18884,
4250,
4026,
29877,
29444,
1121,
1647,
316,
1185,
2334,
2709,
316,
425,
1067,
559,
7338,
1461,
29889,
13,
9651,
29743,
584,
11701,
29889,
17271,
4669,
13,
18884,
4250,
4026,
29877,
2731,
1789,
1121,
1647,
316,
1185,
2334,
2709,
316,
425,
1067,
559,
16012,
29889,
13,
9651,
4236,
29918,
3286,
571,
584,
938,
13,
18884,
341,
29976,
2657,
29874,
5107,
2368,
316,
977,
294,
263,
6782,
381,
13085,
4404,
11510,
8144,
29889,
13,
13,
4706,
390,
1759,
267,
13,
4706,
448,
23648,
13,
4706,
8960,
13,
9651,
1939,
24521,
1476,
29889,
13,
4706,
9995,
13,
4706,
1583,
29889,
4351,
353,
4765,
13,
4706,
1583,
29889,
22992,
353,
29743,
13,
4706,
1583,
29889,
369,
2450,
353,
6213,
13,
4706,
1583,
29889,
3317,
29918,
3286,
571,
353,
4236,
29918,
3286,
571,
13,
13,
1678,
822,
11539,
29898,
1311,
1125,
13,
4706,
9995,
6565,
15039,
425,
10007,
13017,
2368,
316,
1232,
13413,
359,
263,
6782,
381,
343,
1147,
15039,
1354,
560,
2731,
1789,
831,
21432,
263,
425,
4084,
2016,
29889,
13,
13,
4706,
12723,
1539,
8144,
3667,
6619,
560,
472,
1091,
3066,
15562,
343,
425,
2090,
1290,
679,
29918,
2527,
1114,
580,
316,
1232,
13413,
359,
4765,
343,
29743,
29889,
313,
6565,
1842,
2709,
29897,
13,
13,
308,
29896,
29889,
1798,
15039,
425,
10007,
13017,
2368,
628,
29472,
316,
27727,
13413,
359,
13085,
1869,
29673,
1072,
3333,
29901,
13,
9651,
448,
997,
15562,
10258,
560,
11329,
13831,
316,
1897,
294,
313,
19635,
29961,
29876,
22724,
2314,
13,
9651,
448,
7413,
1897,
294,
316,
15562,
25358,
560,
11329,
13306,
3390,
11778,
313,
19635,
29961,
13099,
3816,
1054,
29990,
3816,
1853,
29962,
13,
308,
29906,
29889,
1798,
15039,
1354,
425,
15562,
831,
21432,
2637,
1232,
13413,
359,
4765,
343,
29743,
1702,
10592,
514,
359,
376,
8149,
29908,
316,
923,
802,
29877,
712,
409,
13,
4706,
10671,
661,
427,
425,
15562,
316,
3181,
294,
13413,
359,
29889,
13,
13,
4706,
390,
1759,
267,
13,
4706,
448,
23648,
13,
4706,
8960,
13,
9651,
1939,
24521,
1476,
29889,
13,
4706,
9995,
13,
4706,
1583,
29889,
22992,
29889,
657,
29918,
19635,
580,
1678,
396,
3185,
950,
6619,
425,
15562,
628,
13413,
29877,
2731,
1789,
13,
13,
4706,
396,
830,
1730,
29874,
712,
425,
5107,
2368,
316,
1897,
294,
7205,
21432,
13,
4706,
565,
1583,
29889,
4351,
29889,
19635,
3366,
29876,
22724,
3108,
2804,
1583,
29889,
22992,
29889,
19635,
3366,
29876,
22724,
3108,
29901,
13,
9651,
12020,
8960,
877,
3782,
24521,
1476,
29889,
360,
15622,
1353,
310,
4341,
17809,
1495,
13,
13,
4706,
396,
830,
1730,
29874,
712,
9747,
13306,
316,
784,
398,
1056,
7205,
21432,
2637,
610,
267,
13,
4706,
363,
474,
297,
1583,
29889,
4351,
29889,
19635,
3366,
13099,
3108,
29901,
13,
9651,
565,
1583,
29889,
4351,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
29962,
3366,
1853,
3108,
2804,
1583,
29889,
22992,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
29962,
3366,
1853,
3108,
29901,
13,
18884,
12020,
8960,
877,
3782,
24521,
1476,
29889,
426,
29906,
29913,
29850,
29900,
5038,
1134,
437,
451,
1993,
29850,
29896,
29913,
1642,
4286,
4830,
29898,
13,
462,
1678,
1583,
29889,
4351,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
29962,
3366,
1853,
12436,
1583,
29889,
22992,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
29962,
3366,
1853,
12436,
474,
876,
13,
13,
4706,
1147,
2450,
353,
5852,
13,
4706,
396,
830,
1730,
29874,
560,
13831,
316,
977,
294,
427,
9747,
9413,
29877,
13,
4706,
565,
1583,
29889,
4351,
29889,
19635,
3366,
3198,
29918,
5727,
3108,
2804,
1583,
29889,
22992,
29889,
19635,
3366,
3198,
29918,
5727,
3108,
29901,
13,
9651,
1147,
2450,
353,
7700,
13,
13,
4706,
396,
830,
1730,
29874,
712,
9747,
9541,
1764,
316,
1897,
294,
1702,
23484,
279,
1232,
923,
802,
359,
13,
4706,
565,
1147,
2450,
29901,
13,
9651,
363,
474,
297,
1583,
29889,
4351,
29889,
19635,
3366,
13099,
3108,
29901,
13,
18884,
3619,
29918,
7529,
353,
731,
29898,
1311,
29889,
4351,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
1822,
8149,
3101,
669,
731,
29898,
1311,
29889,
22992,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
1822,
8149,
3101,
13,
18884,
3619,
29918,
7529,
29889,
2218,
7543,
703,
1491,
1853,
1159,
13,
18884,
363,
432,
297,
3619,
29918,
7529,
29901,
13,
462,
1678,
565,
1583,
29889,
4351,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
3816,
29926,
29962,
2804,
1583,
29889,
22992,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
3816,
29926,
5387,
13,
462,
4706,
286,
353,
525,
5661,
784,
398,
1056,
426,
29900,
29913,
694,
20470,
1993,
427,
425,
1147,
928,
16337,
316,
426,
29896,
1836,
426,
29906,
29913,
2804,
426,
29941,
10162,
13,
462,
4706,
1596,
29898,
29885,
29889,
4830,
29898,
29875,
29892,
432,
29892,
851,
29898,
1311,
29889,
4351,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
3816,
29926,
2314,
13,
462,
462,
539,
1919,
851,
29898,
1311,
29889,
22992,
29889,
19635,
3366,
13099,
3108,
29961,
29875,
3816,
29926,
29962,
4961,
13,
462,
4706,
1147,
2450,
353,
7700,
13,
13,
4706,
1583,
29889,
369,
2450,
353,
1147,
2450,
13,
4706,
736,
1147,
2450,
13,
13,
1678,
822,
6782,
29898,
1311,
29892,
3240,
2722,
29922,
29900,
1125,
13,
4706,
9995,
29911,
661,
7241,
406,
343,
1147,
15039,
1232,
18683,
628,
29444,
394,
2731,
1789,
29889,
13,
13,
4706,
12723,
11510,
8144,
1855,
6619,
1185,
1147,
20718,
316,
1232,
18683,
427,
27727,
9413,
359,
343,
1354,
694,
1487,
21432,
267,
938,
6381,
6782,
381,
13,
4706,
1232,
18683,
29889,
13,
13,
4706,
12662,
300,
1883,
13,
4706,
448,
1378,
29899,
13,
4706,
3240,
2722,
584,
938,
13,
9651,
405,
30030,
1050,
29877,
316,
7609,
359,
594,
18394,
267,
427,
11986,
425,
1147,
20718,
285,
3498,
425,
8633,
7763,
13,
13,
4706,
390,
1759,
267,
13,
4706,
448,
23648,
13,
4706,
8960,
13,
9651,
1798,
2450,
5229,
1156,
6782,
29889,
13,
4706,
9995,
13,
4706,
1583,
29889,
27902,
580,
13,
13,
4706,
565,
451,
1583,
29889,
369,
2450,
322,
1583,
29889,
4351,
29889,
1272,
29889,
6310,
29901,
13,
9651,
1583,
29889,
4351,
29889,
657,
29918,
1272,
580,
13,
13,
4706,
3001,
29918,
29873,
2722,
353,
29871,
29896,
29974,
2267,
2722,
13,
4706,
302,
29918,
2202,
353,
29871,
29896,
13,
13,
4706,
1550,
302,
29918,
2202,
5277,
3001,
29918,
29873,
2722,
322,
451,
1583,
29889,
369,
2450,
29901,
13,
9651,
565,
302,
29918,
2202,
1405,
29871,
29896,
29901,
13,
18884,
1596,
703,
4300,
571,
5393,
848,
29889,
3967,
426,
29900,
29913,
714,
310,
426,
29896,
29913,
1642,
4830,
29898,
29876,
29918,
2202,
29892,
3001,
29918,
29873,
2722,
876,
13,
9651,
1583,
29889,
22992,
29889,
7620,
29918,
1272,
29898,
1311,
29889,
4351,
29889,
1272,
29897,
13,
9651,
1583,
29889,
27902,
580,
13,
9651,
302,
29918,
2202,
4619,
29871,
29896,
13,
13,
4706,
565,
1583,
29889,
369,
2450,
29901,
13,
9651,
1596,
877,
4300,
571,
9150,
29889,
1495,
13,
4706,
1683,
29901,
13,
9651,
1596,
29898,
1311,
29889,
4351,
29889,
19635,
29897,
13,
9651,
1596,
29898,
1311,
29889,
22992,
29889,
19635,
29897,
13,
9651,
12020,
8960,
877,
6565,
2450,
5229,
1156,
6782,
29889,
17934,
1898,
6571,
3064,
4286,
4830,
29898,
7827,
29918,
29873,
2722,
876,
13,
2
] |
patent_part.py | patent-python/patent-generator | 109 | 176457 | import re
def get_pars(text):
pars = re.findall(r'\[[0-9]+\]\n*(.*)', text)
pars = [p.strip() for p in pars]
return pars
def get_claims(text):
claims = re.findall(r'.*claim.*', text, re.IGNORECASE)
return claims
def get_claim_body(text):
match = re.search(r'^claim[s*]$', text, re.IGNORECASE | re.MULTILINE)
try:
claim = match.string[match.span()[0]:]
claim = claim.replace('*', '')
return claim
except(AttributeError):
return 'none'
if __name__ == '__main__':
import sys
text = sys.stdin.read()
for p in get_pars(text):
print 'PARAGRAPH'
print p
for p in get_claims(text):
print 'CLAIMS'
print p
print '---------'
print get_claim_body(text)
| [
1,
1053,
337,
13,
13,
1753,
679,
29918,
862,
29879,
29898,
726,
1125,
13,
1678,
610,
29879,
353,
337,
29889,
2886,
497,
29898,
29878,
12764,
8999,
29900,
29899,
29929,
29962,
3124,
10725,
29876,
16395,
5575,
29897,
742,
1426,
29897,
13,
1678,
610,
29879,
353,
518,
29886,
29889,
17010,
580,
363,
282,
297,
610,
29879,
29962,
13,
1678,
736,
610,
29879,
13,
13,
1753,
679,
29918,
29883,
8342,
29879,
29898,
726,
1125,
13,
1678,
16726,
353,
337,
29889,
2886,
497,
29898,
29878,
4286,
29930,
29883,
8342,
5575,
742,
1426,
29892,
337,
29889,
6259,
6632,
1525,
23487,
29897,
13,
1678,
736,
16726,
13,
13,
1753,
679,
29918,
29883,
8342,
29918,
2587,
29898,
726,
1125,
13,
1678,
1993,
353,
337,
29889,
4478,
29898,
29878,
29915,
29985,
29883,
8342,
29961,
29879,
29930,
9341,
742,
1426,
29892,
337,
29889,
6259,
6632,
1525,
23487,
891,
337,
29889,
29924,
8647,
6227,
8895,
29897,
13,
1678,
1018,
29901,
13,
4706,
5995,
353,
1993,
29889,
1807,
29961,
4352,
29889,
9653,
580,
29961,
29900,
5387,
29962,
29871,
13,
4706,
5995,
353,
5995,
29889,
6506,
877,
29930,
742,
27255,
13,
4706,
736,
5995,
13,
1678,
5174,
29898,
6708,
2392,
1125,
13,
4706,
736,
525,
9290,
29915,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
13,
1678,
1053,
10876,
13,
1678,
1426,
353,
10876,
29889,
4172,
262,
29889,
949,
580,
13,
13,
1678,
363,
282,
297,
679,
29918,
862,
29879,
29898,
726,
1125,
13,
4706,
1596,
525,
16320,
10051,
29934,
3301,
29950,
29915,
13,
4706,
1596,
282,
13,
13,
13,
1678,
363,
282,
297,
679,
29918,
29883,
8342,
29879,
29898,
726,
1125,
13,
4706,
1596,
525,
13875,
29902,
4345,
29915,
13,
4706,
1596,
282,
13,
13,
1678,
1596,
525,
1378,
29899,
29915,
13,
1678,
1596,
679,
29918,
29883,
8342,
29918,
2587,
29898,
726,
29897,
13,
13,
2
] |
flytekit/common/tasks/sagemaker/custom_training_job_task.py | tnsetting/flytekit | 0 | 1615269 | <filename>flytekit/common/tasks/sagemaker/custom_training_job_task.py<gh_stars>0
from google.protobuf.json_format import MessageToDict
from flytekit.common.constants import SdkTaskType
from flytekit.common.tasks import sdk_runnable as _sdk_runnable
from flytekit.models.sagemaker import training_job as _training_job_models
class CustomTrainingJobTask(_sdk_runnable.SdkRunnableTask):
"""
CustomTrainJobTask defines a python task that can run on SageMaker bring your own container.
"""
def __init__(
self,
task_function,
cache_version,
retries,
deprecated,
storage_request,
cpu_request,
gpu_request,
memory_request,
storage_limit,
cpu_limit,
gpu_limit,
memory_limit,
cache,
timeout,
environment,
algorithm_specification: _training_job_models.AlgorithmSpecification,
training_job_resource_config: _training_job_models.TrainingJobResourceConfig,
):
"""
:param task_function: Function container user code. This will be executed via the SDK's engine.
:param Text cache_version: string describing the version for task discovery purposes
:param int retries: Number of retries to attempt
:param Text deprecated:
:param Text storage_request:
:param Text cpu_request:
:param Text gpu_request:
:param Text memory_request:
:param Text storage_limit:
:param Text cpu_limit:
:param Text gpu_limit:
:param Text memory_limit:
:param bool cache:
:param datetime.timedelta timeout:
:param dict[Text, Text] environment:
:param _training_job_models.AlgorithmSpecification algorithm_specification:
:param _training_job_models.TrainingJobResourceConfig training_job_resource_config:
"""
# Use the training job model as a measure of type checking
self._training_job_model = _training_job_models.TrainingJob(
algorithm_specification=algorithm_specification, training_job_resource_config=training_job_resource_config
)
super().__init__(
task_function=task_function,
task_type=SdkTaskType.SAGEMAKER_CUSTOM_TRAINING_JOB_TASK,
discovery_version=cache_version,
retries=retries,
interruptible=False,
deprecated=deprecated,
storage_request=storage_request,
cpu_request=cpu_request,
gpu_request=gpu_request,
memory_request=memory_request,
storage_limit=storage_limit,
cpu_limit=cpu_limit,
gpu_limit=gpu_limit,
memory_limit=memory_limit,
discoverable=cache,
timeout=timeout,
environment=environment,
custom=MessageToDict(self._training_job_model.to_flyte_idl()),
)
@property
def training_job_model(self) -> _training_job_models.TrainingJob:
return self._training_job_model
| [
1,
529,
9507,
29958,
17652,
371,
7354,
29914,
9435,
29914,
20673,
29914,
29879,
13904,
5790,
29914,
6341,
29918,
26495,
29918,
9057,
29918,
7662,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
5386,
29889,
17529,
9721,
29889,
3126,
29918,
4830,
1053,
7777,
1762,
21533,
13,
13,
3166,
11340,
371,
7354,
29889,
9435,
29889,
3075,
1934,
1053,
317,
8181,
5398,
1542,
13,
3166,
11340,
371,
7354,
29889,
9435,
29889,
20673,
1053,
269,
8181,
29918,
3389,
29876,
519,
408,
903,
15348,
29918,
3389,
29876,
519,
13,
3166,
11340,
371,
7354,
29889,
9794,
29889,
29879,
13904,
5790,
1053,
6694,
29918,
9057,
408,
903,
26495,
29918,
9057,
29918,
9794,
13,
13,
13,
1990,
8701,
5323,
2827,
11947,
5398,
7373,
15348,
29918,
3389,
29876,
519,
29889,
29019,
29934,
21725,
5398,
1125,
13,
1678,
9995,
13,
1678,
8701,
5323,
262,
11947,
5398,
17645,
263,
3017,
3414,
393,
508,
1065,
373,
317,
482,
29924,
5790,
6963,
596,
1914,
5639,
29889,
13,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
13,
4706,
1583,
29892,
13,
4706,
3414,
29918,
2220,
29892,
13,
4706,
7090,
29918,
3259,
29892,
13,
4706,
3240,
2722,
29892,
13,
4706,
18164,
29892,
13,
4706,
8635,
29918,
3827,
29892,
13,
4706,
26403,
29918,
3827,
29892,
13,
4706,
330,
3746,
29918,
3827,
29892,
13,
4706,
3370,
29918,
3827,
29892,
13,
4706,
8635,
29918,
13400,
29892,
13,
4706,
26403,
29918,
13400,
29892,
13,
4706,
330,
3746,
29918,
13400,
29892,
13,
4706,
3370,
29918,
13400,
29892,
13,
4706,
7090,
29892,
13,
4706,
11815,
29892,
13,
4706,
5177,
29892,
13,
4706,
5687,
29918,
6550,
2450,
29901,
903,
26495,
29918,
9057,
29918,
9794,
29889,
22461,
4540,
10299,
2450,
29892,
13,
4706,
6694,
29918,
9057,
29918,
10314,
29918,
2917,
29901,
903,
26495,
29918,
9057,
29918,
9794,
29889,
5323,
2827,
11947,
6848,
3991,
29892,
13,
268,
1125,
13,
4706,
9995,
13,
4706,
584,
3207,
3414,
29918,
2220,
29901,
6680,
5639,
1404,
775,
29889,
29871,
910,
674,
367,
8283,
3025,
278,
12967,
29915,
29879,
6012,
29889,
13,
4706,
584,
3207,
3992,
7090,
29918,
3259,
29901,
1347,
20766,
278,
1873,
363,
3414,
20699,
11976,
13,
4706,
584,
3207,
938,
3240,
2722,
29901,
9681,
310,
3240,
2722,
304,
4218,
13,
4706,
584,
3207,
3992,
18164,
29901,
13,
4706,
584,
3207,
3992,
8635,
29918,
3827,
29901,
13,
4706,
584,
3207,
3992,
26403,
29918,
3827,
29901,
13,
4706,
584,
3207,
3992,
330,
3746,
29918,
3827,
29901,
13,
4706,
584,
3207,
3992,
3370,
29918,
3827,
29901,
13,
4706,
584,
3207,
3992,
8635,
29918,
13400,
29901,
13,
4706,
584,
3207,
3992,
26403,
29918,
13400,
29901,
13,
4706,
584,
3207,
3992,
330,
3746,
29918,
13400,
29901,
13,
4706,
584,
3207,
3992,
3370,
29918,
13400,
29901,
13,
4706,
584,
3207,
6120,
7090,
29901,
13,
4706,
584,
3207,
12865,
29889,
9346,
287,
2554,
11815,
29901,
13,
4706,
584,
3207,
9657,
29961,
1626,
29892,
3992,
29962,
5177,
29901,
13,
4706,
584,
3207,
903,
26495,
29918,
9057,
29918,
9794,
29889,
22461,
4540,
10299,
2450,
5687,
29918,
6550,
2450,
29901,
13,
4706,
584,
3207,
903,
26495,
29918,
9057,
29918,
9794,
29889,
5323,
2827,
11947,
6848,
3991,
6694,
29918,
9057,
29918,
10314,
29918,
2917,
29901,
13,
4706,
9995,
13,
13,
4706,
396,
4803,
278,
6694,
4982,
1904,
408,
263,
5645,
310,
1134,
8454,
13,
4706,
1583,
3032,
26495,
29918,
9057,
29918,
4299,
353,
903,
26495,
29918,
9057,
29918,
9794,
29889,
5323,
2827,
11947,
29898,
13,
9651,
5687,
29918,
6550,
2450,
29922,
20567,
29918,
6550,
2450,
29892,
6694,
29918,
9057,
29918,
10314,
29918,
2917,
29922,
26495,
29918,
9057,
29918,
10314,
29918,
2917,
13,
4706,
1723,
13,
13,
4706,
2428,
2141,
1649,
2344,
12035,
13,
9651,
3414,
29918,
2220,
29922,
7662,
29918,
2220,
29892,
13,
9651,
3414,
29918,
1853,
29922,
29019,
5398,
1542,
29889,
8132,
1692,
1529,
29968,
1001,
29918,
29907,
17321,
6488,
29918,
29911,
4717,
1177,
4214,
29918,
29967,
14824,
29918,
29911,
3289,
29968,
29892,
13,
9651,
20699,
29918,
3259,
29922,
8173,
29918,
3259,
29892,
13,
9651,
3240,
2722,
29922,
2267,
2722,
29892,
13,
9651,
23754,
1821,
29922,
8824,
29892,
13,
9651,
18164,
29922,
311,
17990,
630,
29892,
13,
9651,
8635,
29918,
3827,
29922,
12925,
29918,
3827,
29892,
13,
9651,
26403,
29918,
3827,
29922,
21970,
29918,
3827,
29892,
13,
9651,
330,
3746,
29918,
3827,
29922,
29887,
3746,
29918,
3827,
29892,
13,
9651,
3370,
29918,
3827,
29922,
14834,
29918,
3827,
29892,
13,
9651,
8635,
29918,
13400,
29922,
12925,
29918,
13400,
29892,
13,
9651,
26403,
29918,
13400,
29922,
21970,
29918,
13400,
29892,
13,
9651,
330,
3746,
29918,
13400,
29922,
29887,
3746,
29918,
13400,
29892,
13,
9651,
3370,
29918,
13400,
29922,
14834,
29918,
13400,
29892,
13,
9651,
6523,
519,
29922,
8173,
29892,
13,
9651,
11815,
29922,
15619,
29892,
13,
9651,
5177,
29922,
20944,
29892,
13,
9651,
2888,
29922,
3728,
1762,
21533,
29898,
1311,
3032,
26495,
29918,
9057,
29918,
4299,
29889,
517,
29918,
17652,
371,
29918,
333,
29880,
25739,
13,
4706,
1723,
13,
13,
1678,
732,
6799,
13,
1678,
822,
6694,
29918,
9057,
29918,
4299,
29898,
1311,
29897,
1599,
903,
26495,
29918,
9057,
29918,
9794,
29889,
5323,
2827,
11947,
29901,
13,
4706,
736,
1583,
3032,
26495,
29918,
9057,
29918,
4299,
13,
2
] |
utils/logger.py | vrindaprabhu/solofy | 0 | 185544 | import logging
from config.solofy import LOGFILENAME
class Logger:
__instance = None
@staticmethod
def get_instance(log_level=logging.info):
if Logger.__instance == None:
Logger(log_level)
return Logger.__instance
def __init__(self, log_level):
self.log_level = log_level
if Logger.__instance != None:
raise Exception("Logger is a singleton!")
else:
Logger.__instance = self
def get_logger(self):
logging.basicConfig(
filename=LOGFILENAME,
filemode="w",
format="%(asctime)s,%(msecs)d - %(name)s - %(levelname)s - [%(filename)s:%(lineno)d] - %(message)s",
datefmt="%Y-%m-%d:%H:%M:%S",
)
logger = logging.getLogger()
logger.setLevel(self.log_level)
return logger
| [
1,
1053,
12183,
13,
3166,
2295,
29889,
2929,
974,
29891,
1053,
25401,
7724,
5813,
13,
13,
13,
1990,
28468,
29901,
13,
1678,
4770,
8758,
353,
6213,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
679,
29918,
8758,
29898,
1188,
29918,
5563,
29922,
21027,
29889,
3888,
1125,
13,
4706,
565,
28468,
17255,
8758,
1275,
6213,
29901,
13,
9651,
28468,
29898,
1188,
29918,
5563,
29897,
13,
4706,
736,
28468,
17255,
8758,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1480,
29918,
5563,
1125,
13,
4706,
1583,
29889,
1188,
29918,
5563,
353,
1480,
29918,
5563,
13,
4706,
565,
28468,
17255,
8758,
2804,
6213,
29901,
13,
9651,
12020,
8960,
703,
16363,
338,
263,
27130,
29991,
1159,
13,
4706,
1683,
29901,
13,
9651,
28468,
17255,
8758,
353,
1583,
13,
13,
1678,
822,
679,
29918,
21707,
29898,
1311,
1125,
13,
4706,
12183,
29889,
16121,
3991,
29898,
13,
9651,
10422,
29922,
14480,
7724,
5813,
29892,
13,
9651,
934,
8513,
543,
29893,
613,
13,
9651,
3402,
543,
29995,
29898,
294,
312,
603,
29897,
29879,
24163,
29898,
29885,
344,
2395,
29897,
29881,
448,
1273,
29898,
978,
29897,
29879,
448,
1273,
29898,
5563,
978,
29897,
29879,
448,
518,
29995,
29898,
9507,
29897,
29879,
16664,
29898,
1915,
8154,
29897,
29881,
29962,
448,
1273,
29898,
4906,
29897,
29879,
613,
13,
9651,
2635,
23479,
543,
29995,
29979,
19222,
29885,
19222,
29881,
16664,
29950,
16664,
29924,
16664,
29903,
613,
13,
4706,
1723,
13,
4706,
17927,
353,
12183,
29889,
657,
16363,
580,
13,
4706,
17927,
29889,
842,
10108,
29898,
1311,
29889,
1188,
29918,
5563,
29897,
13,
4706,
736,
17927,
13,
2
] |
LeetCodeSolutions/LeetCode_0332.py | lih627/python-algorithm-templates | 24 | 1600915 | class Solution:
def findItinerary(self, tickets: List[List[str]]) -> List[str]:
adjacency = collections.defaultdict(list)
for a, b in tickets:
adjacency[a].append(b)
for i in adjacency:
adjacency[i].sort(reverse=True)
res = []
def dfs(cur):
while adjacency[cur]:
dfs(adjacency[cur].pop())
res.insert(0, cur)
dfs('JFK')
return res
class Solution:
def findItinerary(self, tickets: List[List[str]]) -> List[str]:
ret = []
def dfs(cur):
while graph[cur]:
nxt = heapq.heappop(graph[cur])
dfs(nxt)
ret.append(cur)
graph = collections.defaultdict(list)
for start, end in tickets:
graph[start].append(end)
for key in graph:
heapq.heapify(graph[key])
dfs('JFK')
return ret[::-1]
| [
1,
770,
24380,
29901,
13,
1678,
822,
1284,
3112,
4983,
653,
29898,
1311,
29892,
16892,
1691,
29901,
2391,
29961,
1293,
29961,
710,
24960,
1599,
2391,
29961,
710,
5387,
13,
4706,
12109,
562,
3819,
353,
16250,
29889,
4381,
8977,
29898,
1761,
29897,
13,
4706,
363,
263,
29892,
289,
297,
16892,
1691,
29901,
13,
9651,
12109,
562,
3819,
29961,
29874,
1822,
4397,
29898,
29890,
29897,
13,
4706,
363,
474,
297,
12109,
562,
3819,
29901,
13,
9651,
12109,
562,
3819,
29961,
29875,
1822,
6605,
29898,
24244,
29922,
5574,
29897,
13,
4706,
620,
353,
5159,
13,
13,
4706,
822,
4489,
29879,
29898,
2764,
1125,
13,
9651,
1550,
12109,
562,
3819,
29961,
2764,
5387,
13,
18884,
4489,
29879,
29898,
26859,
562,
3819,
29961,
2764,
1822,
7323,
3101,
13,
9651,
620,
29889,
7851,
29898,
29900,
29892,
3151,
29897,
13,
13,
4706,
4489,
29879,
877,
29967,
29943,
29968,
1495,
13,
4706,
736,
620,
13,
13,
13,
1990,
24380,
29901,
13,
1678,
822,
1284,
3112,
4983,
653,
29898,
1311,
29892,
16892,
1691,
29901,
2391,
29961,
1293,
29961,
710,
24960,
1599,
2391,
29961,
710,
5387,
13,
4706,
3240,
353,
5159,
13,
13,
4706,
822,
4489,
29879,
29898,
2764,
1125,
13,
9651,
1550,
3983,
29961,
2764,
5387,
13,
18884,
302,
486,
353,
16947,
29939,
29889,
354,
932,
459,
29898,
4262,
29961,
2764,
2314,
13,
18884,
4489,
29879,
29898,
29876,
486,
29897,
13,
9651,
3240,
29889,
4397,
29898,
2764,
29897,
13,
13,
4706,
3983,
353,
16250,
29889,
4381,
8977,
29898,
1761,
29897,
13,
4706,
363,
1369,
29892,
1095,
297,
16892,
1691,
29901,
13,
9651,
3983,
29961,
2962,
1822,
4397,
29898,
355,
29897,
13,
13,
4706,
363,
1820,
297,
3983,
29901,
13,
9651,
16947,
29939,
29889,
354,
481,
1598,
29898,
4262,
29961,
1989,
2314,
13,
4706,
4489,
29879,
877,
29967,
29943,
29968,
1495,
13,
4706,
736,
3240,
29961,
1057,
29899,
29896,
29962,
13,
2
] |
guardian/states/ending.py | alisonbnt/watchtower | 1 | 189253 | from .base import *
from colorama import Fore
class EndingState(State):
def run(self, arguments={}):
print()
print_data("This is the end of the journey. You are welcome "
"back at any time in here")
print()
print_data("There will be always creatures in the shadows, "
"waiting for an oportunity to come out")
print()
print_data("But when that time comes, there will always be the ones "
"whose light shines as bright as the sun itself")
print()
print_data("For there humble, nameless heroes, I pray for your "
"strength and for your heart.")
print()
print_data("May the light guide your actions. ")
print()
print_data("< lost connection >", Fore.MAGENTA)
print()
input("Press enter to continue...")
exit()
| [
1,
515,
869,
3188,
1053,
334,
13,
3166,
2927,
3304,
1053,
28297,
13,
13,
13,
1990,
2796,
292,
2792,
29898,
2792,
1125,
13,
13,
1678,
822,
1065,
29898,
1311,
29892,
6273,
3790,
29913,
1125,
13,
4706,
1596,
580,
13,
4706,
1596,
29918,
1272,
703,
4013,
338,
278,
1095,
310,
278,
16342,
29889,
887,
526,
12853,
376,
13,
462,
259,
376,
1627,
472,
738,
931,
297,
1244,
1159,
13,
4706,
1596,
580,
13,
4706,
1596,
29918,
1272,
703,
8439,
674,
367,
2337,
907,
3698,
297,
278,
528,
23626,
29892,
376,
13,
462,
259,
376,
10685,
292,
363,
385,
288,
637,
6997,
304,
2041,
714,
1159,
13,
13,
4706,
1596,
580,
13,
4706,
1596,
29918,
1272,
703,
6246,
746,
393,
931,
5304,
29892,
727,
674,
2337,
367,
278,
6743,
376,
13,
462,
259,
376,
1332,
852,
3578,
528,
1475,
408,
11785,
408,
278,
6575,
3528,
1159,
13,
13,
4706,
1596,
580,
13,
4706,
1596,
29918,
1272,
703,
2831,
727,
3165,
569,
29892,
6869,
6393,
13444,
267,
29892,
306,
12475,
363,
596,
376,
13,
462,
259,
376,
710,
1477,
322,
363,
596,
5192,
23157,
13,
13,
4706,
1596,
580,
13,
4706,
1596,
29918,
1272,
703,
12703,
278,
3578,
10754,
596,
8820,
29889,
16521,
13,
13,
4706,
1596,
580,
13,
4706,
1596,
29918,
1272,
28945,
5714,
3957,
1405,
613,
28297,
29889,
1529,
29954,
3919,
29909,
29897,
13,
4706,
1596,
580,
13,
4706,
1881,
703,
10923,
3896,
304,
6773,
856,
1159,
13,
4706,
6876,
580,
13,
2
] |
tests/test_graphql_ws.py | SmileyChris/graphql-ws | 7 | 112130 | from collections import OrderedDict
try:
from unittest import mock
except ImportError:
import mock
import pytest
from graphql.execution.executors.sync import SyncExecutor
from graphql_ws import base, base_sync, constants
@pytest.fixture
def cc():
cc = base.BaseConnectionContext(ws=None)
cc.operations = {"yes": "1"}
return cc
@pytest.fixture
def ss():
return base_sync.BaseSyncSubscriptionServer(schema=None)
class TestConnectionContextOperation:
def test_no_operations_initially(self):
cc = base.BaseConnectionContext(ws=None)
assert not cc.operations
def test_has_operation(self, cc):
assert cc.has_operation("yes")
def test_has_operation_missing(self, cc):
assert not cc.has_operation("no")
def test_register_operation(self, cc):
cc.register_operation("new", "2")
assert "new" in cc.operations
def test_get_operation(self, cc):
assert cc.get_operation("yes") == "1"
def test_remove_operation(self, cc):
cc.remove_operation("yes")
assert not cc.operations
class TestConnectionContextNotImplentedMethods:
def test_receive(self):
with pytest.raises(NotImplementedError):
base.BaseConnectionContext(ws=None).receive()
def test_send(self):
with pytest.raises(NotImplementedError):
base.BaseConnectionContext(ws=None).send("TEST")
def test_closed(self):
with pytest.raises(NotImplementedError):
base.BaseConnectionContext(ws=None).closed
def test_close(self):
with pytest.raises(NotImplementedError):
base.BaseConnectionContext(ws=None).close(123)
class TestProcessMessage:
def test_init(self, ss, cc):
ss.on_connection_init = mock.Mock()
ss.process_message(
cc, {"id": "1", "type": constants.GQL_CONNECTION_INIT, "payload": "payload"}
)
ss.on_connection_init.assert_called_with(cc, "1", "payload")
def test_terminate(self, ss, cc):
ss.on_connection_terminate = mock.Mock()
ss.process_message(cc, {"id": "1", "type": constants.GQL_CONNECTION_TERMINATE})
ss.on_connection_terminate.assert_called_with(cc, "1")
@pytest.mark.parametrize(
"transport_ws_protocol,expected_type",
((False, constants.GQL_START), (True, constants.GQL_SUBSCRIBE)),
)
def test_start(self, ss, cc, transport_ws_protocol, expected_type):
ss.get_graphql_params = mock.Mock()
ss.get_graphql_params.return_value = {"params": True}
cc.has_operation = mock.Mock()
cc.has_operation.return_value = False
cc.transport_ws_protocol = transport_ws_protocol
ss.unsubscribe = mock.Mock()
ss.on_start = mock.Mock()
ss.process_message(
cc, {"id": "1", "type": expected_type, "payload": {"a": "b"}}
)
assert not ss.unsubscribe.called
ss.on_start.assert_called_with(cc, "1", {"params": True})
def test_start_existing_op(self, ss, cc):
ss.get_graphql_params = mock.Mock()
ss.get_graphql_params.return_value = {"params": True}
cc.has_operation = mock.Mock()
cc.has_operation.return_value = True
cc.unsubscribe = mock.Mock()
ss.execute = mock.Mock()
ss.send_message = mock.Mock()
ss.process_message(
cc, {"id": "1", "type": constants.GQL_START, "payload": {"a": "b"}}
)
assert cc.unsubscribe.called
def test_start_bad_graphql_params(self, ss, cc):
ss.get_graphql_params = mock.Mock()
ss.get_graphql_params.return_value = None
cc.has_operation = mock.Mock()
cc.has_operation.return_value = False
ss.send_error = mock.Mock()
ss.unsubscribe = mock.Mock()
ss.on_start = mock.Mock()
ss.process_message(cc, {"id": "1", "type": None, "payload": {"a": "b"}})
assert ss.send_error.called
assert ss.send_error.call_args[0][:2] == (cc, "1")
assert isinstance(ss.send_error.call_args[0][2], Exception)
assert not ss.on_start.called
@pytest.mark.parametrize(
"transport_ws_protocol,stop_type,invalid_stop_type",
(
(False, constants.GQL_STOP, constants.GQL_COMPLETE),
(True, constants.GQL_COMPLETE, constants.GQL_STOP),
),
)
def test_stop(
self,
ss,
cc,
transport_ws_protocol,
stop_type,
invalid_stop_type,
):
ss.on_stop = mock.Mock()
ss.send_error = mock.Mock()
cc.transport_ws_protocol = transport_ws_protocol
ss.process_message(cc, {"id": "1", "type": invalid_stop_type})
assert ss.send_error.called
assert ss.send_error.call_args[0][:2] == (cc, "1")
assert isinstance(ss.send_error.call_args[0][2], Exception)
assert not ss.on_stop.called
ss.process_message(cc, {"id": "1", "type": stop_type})
ss.on_stop.assert_called_with(cc, "1")
def test_invalid(self, ss, cc):
ss.send_error = mock.Mock()
ss.process_message(cc, {"id": "1", "type": "unknown"})
assert ss.send_error.called
assert ss.send_error.call_args[0][:2] == (cc, "1")
assert isinstance(ss.send_error.call_args[0][2], Exception)
def test_get_graphql_params(ss, cc):
payload = {
"query": "req",
"variables": "vars",
"operationName": "query",
"context": {},
}
params = ss.get_graphql_params(cc, payload)
assert isinstance(params.pop("executor"), SyncExecutor)
assert params == {
"request_string": "req",
"variable_values": "vars",
"operation_name": "query",
"context_value": {},
}
def test_build_message(ss):
assert ss.build_message("1", "query", "PAYLOAD") == {
"id": "1",
"type": "query",
"payload": "PAYLOAD",
}
def test_build_message_partial(ss):
assert ss.build_message(id="1", op_type=None, payload=None) == {"id": "1"}
assert ss.build_message(id=None, op_type="query", payload=None) == {"type": "query"}
assert ss.build_message(id=None, op_type=None, payload="PAYLOAD") == {
"payload": "PAYLOAD"
}
with pytest.raises(AssertionError):
ss.build_message(id=None, op_type=None, payload=None)
@pytest.mark.parametrize(
"transport_ws_protocol,expected_type",
((False, constants.GQL_DATA), (True, constants.GQL_NEXT)),
)
def test_send_execution_result(ss, cc, transport_ws_protocol, expected_type):
cc.transport_ws_protocol = transport_ws_protocol
ss.execution_result_to_dict = mock.Mock()
ss.execution_result_to_dict.return_value = {"res": "ult"}
ss.send_message = mock.Mock()
ss.send_message.return_value = "returned"
assert "returned" == ss.send_execution_result(cc, "1", "result")
ss.send_message.assert_called_with(cc, "1", expected_type, {"res": "ult"})
def test_execution_result_to_dict(ss):
result = mock.Mock()
result.data = "DATA"
result.errors = "ER"
result_dict = ss.execution_result_to_dict(result)
assert isinstance(result_dict, OrderedDict)
assert result_dict == {
"data": "DATA",
"errors": [{"message": "E"}, {"message": "R"}],
}
def test_send_message(ss, cc):
ss.build_message = mock.Mock()
ss.build_message.return_value = {"mess": "age"}
cc.send = mock.Mock()
cc.send.return_value = "returned"
assert "returned" == ss.send_message(cc)
cc.send.assert_called_with({"mess": "age"})
class TestSSNotImplemented:
def test_handle(self, ss):
with pytest.raises(NotImplementedError):
ss.handle(ws=None, request_context=None)
| [
1,
515,
16250,
1053,
8170,
287,
21533,
13,
13,
2202,
29901,
13,
1678,
515,
443,
27958,
1053,
11187,
13,
19499,
16032,
2392,
29901,
13,
1678,
1053,
11187,
13,
13,
5215,
11451,
1688,
13,
3166,
3983,
1519,
29889,
22256,
29889,
4258,
29560,
29889,
16593,
1053,
317,
2720,
13366,
13,
13,
3166,
3983,
1519,
29918,
5652,
1053,
2967,
29892,
2967,
29918,
16593,
29892,
17727,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
21759,
7295,
13,
1678,
21759,
353,
2967,
29889,
5160,
5350,
2677,
29898,
5652,
29922,
8516,
29897,
13,
1678,
21759,
29889,
3372,
800,
353,
8853,
3582,
1115,
376,
29896,
9092,
13,
1678,
736,
21759,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
17971,
7295,
13,
1678,
736,
2967,
29918,
16593,
29889,
5160,
21077,
4035,
22371,
6004,
29898,
11010,
29922,
8516,
29897,
13,
13,
13,
1990,
4321,
5350,
2677,
10925,
29901,
13,
1678,
822,
1243,
29918,
1217,
29918,
3372,
800,
29918,
11228,
368,
29898,
1311,
1125,
13,
4706,
21759,
353,
2967,
29889,
5160,
5350,
2677,
29898,
5652,
29922,
8516,
29897,
13,
4706,
4974,
451,
21759,
29889,
3372,
800,
13,
13,
1678,
822,
1243,
29918,
5349,
29918,
16453,
29898,
1311,
29892,
21759,
1125,
13,
4706,
4974,
21759,
29889,
5349,
29918,
16453,
703,
3582,
1159,
13,
13,
1678,
822,
1243,
29918,
5349,
29918,
16453,
29918,
27259,
29898,
1311,
29892,
21759,
1125,
13,
4706,
4974,
451,
21759,
29889,
5349,
29918,
16453,
703,
1217,
1159,
13,
13,
1678,
822,
1243,
29918,
9573,
29918,
16453,
29898,
1311,
29892,
21759,
1125,
13,
4706,
21759,
29889,
9573,
29918,
16453,
703,
1482,
613,
376,
29906,
1159,
13,
4706,
4974,
376,
1482,
29908,
297,
21759,
29889,
3372,
800,
13,
13,
1678,
822,
1243,
29918,
657,
29918,
16453,
29898,
1311,
29892,
21759,
1125,
13,
4706,
4974,
21759,
29889,
657,
29918,
16453,
703,
3582,
1159,
1275,
376,
29896,
29908,
13,
13,
1678,
822,
1243,
29918,
5992,
29918,
16453,
29898,
1311,
29892,
21759,
1125,
13,
4706,
21759,
29889,
5992,
29918,
16453,
703,
3582,
1159,
13,
4706,
4974,
451,
21759,
29889,
3372,
800,
13,
13,
13,
1990,
4321,
5350,
2677,
3664,
6647,
14927,
26112,
29901,
13,
1678,
822,
1243,
29918,
13556,
573,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
3664,
1888,
2037,
287,
2392,
1125,
13,
9651,
2967,
29889,
5160,
5350,
2677,
29898,
5652,
29922,
8516,
467,
13556,
573,
580,
13,
13,
1678,
822,
1243,
29918,
6717,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
3664,
1888,
2037,
287,
2392,
1125,
13,
9651,
2967,
29889,
5160,
5350,
2677,
29898,
5652,
29922,
8516,
467,
6717,
703,
18267,
1159,
13,
13,
1678,
822,
1243,
29918,
15603,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
3664,
1888,
2037,
287,
2392,
1125,
13,
9651,
2967,
29889,
5160,
5350,
2677,
29898,
5652,
29922,
8516,
467,
15603,
13,
13,
1678,
822,
1243,
29918,
5358,
29898,
1311,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
3664,
1888,
2037,
287,
2392,
1125,
13,
9651,
2967,
29889,
5160,
5350,
2677,
29898,
5652,
29922,
8516,
467,
5358,
29898,
29896,
29906,
29941,
29897,
13,
13,
13,
1990,
4321,
7032,
3728,
29901,
13,
1678,
822,
1243,
29918,
2344,
29898,
1311,
29892,
17971,
29892,
21759,
1125,
13,
4706,
17971,
29889,
265,
29918,
9965,
29918,
2344,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
5014,
29918,
4906,
29898,
13,
9651,
21759,
29892,
8853,
333,
1115,
376,
29896,
613,
376,
1853,
1115,
17727,
29889,
29954,
2239,
29918,
6007,
8186,
9838,
29918,
26019,
29892,
376,
23813,
1115,
376,
23813,
9092,
13,
4706,
1723,
13,
4706,
17971,
29889,
265,
29918,
9965,
29918,
2344,
29889,
9294,
29918,
13998,
29918,
2541,
29898,
617,
29892,
376,
29896,
613,
376,
23813,
1159,
13,
13,
1678,
822,
1243,
29918,
18821,
403,
29898,
1311,
29892,
17971,
29892,
21759,
1125,
13,
4706,
17971,
29889,
265,
29918,
9965,
29918,
18821,
403,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
5014,
29918,
4906,
29898,
617,
29892,
8853,
333,
1115,
376,
29896,
613,
376,
1853,
1115,
17727,
29889,
29954,
2239,
29918,
6007,
8186,
9838,
29918,
4945,
16173,
3040,
1800,
13,
4706,
17971,
29889,
265,
29918,
9965,
29918,
18821,
403,
29889,
9294,
29918,
13998,
29918,
2541,
29898,
617,
29892,
376,
29896,
1159,
13,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
4706,
376,
27882,
29918,
5652,
29918,
20464,
29892,
9684,
29918,
1853,
613,
13,
4706,
5135,
8824,
29892,
17727,
29889,
29954,
2239,
29918,
25826,
511,
313,
5574,
29892,
17727,
29889,
29954,
2239,
29918,
20633,
7187,
3960,
15349,
8243,
13,
1678,
1723,
13,
1678,
822,
1243,
29918,
2962,
29898,
1311,
29892,
17971,
29892,
21759,
29892,
8608,
29918,
5652,
29918,
20464,
29892,
3806,
29918,
1853,
1125,
13,
4706,
17971,
29889,
657,
29918,
4262,
1519,
29918,
7529,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
657,
29918,
4262,
1519,
29918,
7529,
29889,
2457,
29918,
1767,
353,
8853,
7529,
1115,
5852,
29913,
13,
4706,
21759,
29889,
5349,
29918,
16453,
353,
11187,
29889,
18680,
580,
13,
4706,
21759,
29889,
5349,
29918,
16453,
29889,
2457,
29918,
1767,
353,
7700,
13,
4706,
21759,
29889,
27882,
29918,
5652,
29918,
20464,
353,
8608,
29918,
5652,
29918,
20464,
13,
4706,
17971,
29889,
348,
19496,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
265,
29918,
2962,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
5014,
29918,
4906,
29898,
13,
9651,
21759,
29892,
8853,
333,
1115,
376,
29896,
613,
376,
1853,
1115,
3806,
29918,
1853,
29892,
376,
23813,
1115,
8853,
29874,
1115,
376,
29890,
29908,
930,
13,
4706,
1723,
13,
4706,
4974,
451,
17971,
29889,
348,
19496,
29889,
13998,
13,
4706,
17971,
29889,
265,
29918,
2962,
29889,
9294,
29918,
13998,
29918,
2541,
29898,
617,
29892,
376,
29896,
613,
8853,
7529,
1115,
5852,
1800,
13,
13,
1678,
822,
1243,
29918,
2962,
29918,
735,
15423,
29918,
459,
29898,
1311,
29892,
17971,
29892,
21759,
1125,
13,
4706,
17971,
29889,
657,
29918,
4262,
1519,
29918,
7529,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
657,
29918,
4262,
1519,
29918,
7529,
29889,
2457,
29918,
1767,
353,
8853,
7529,
1115,
5852,
29913,
13,
4706,
21759,
29889,
5349,
29918,
16453,
353,
11187,
29889,
18680,
580,
13,
4706,
21759,
29889,
5349,
29918,
16453,
29889,
2457,
29918,
1767,
353,
5852,
13,
4706,
21759,
29889,
348,
19496,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
7978,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
6717,
29918,
4906,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
5014,
29918,
4906,
29898,
13,
9651,
21759,
29892,
8853,
333,
1115,
376,
29896,
613,
376,
1853,
1115,
17727,
29889,
29954,
2239,
29918,
25826,
29892,
376,
23813,
1115,
8853,
29874,
1115,
376,
29890,
29908,
930,
13,
4706,
1723,
13,
4706,
4974,
21759,
29889,
348,
19496,
29889,
13998,
13,
13,
1678,
822,
1243,
29918,
2962,
29918,
12313,
29918,
4262,
1519,
29918,
7529,
29898,
1311,
29892,
17971,
29892,
21759,
1125,
13,
4706,
17971,
29889,
657,
29918,
4262,
1519,
29918,
7529,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
657,
29918,
4262,
1519,
29918,
7529,
29889,
2457,
29918,
1767,
353,
6213,
13,
4706,
21759,
29889,
5349,
29918,
16453,
353,
11187,
29889,
18680,
580,
13,
4706,
21759,
29889,
5349,
29918,
16453,
29889,
2457,
29918,
1767,
353,
7700,
13,
4706,
17971,
29889,
6717,
29918,
2704,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
348,
19496,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
265,
29918,
2962,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
5014,
29918,
4906,
29898,
617,
29892,
8853,
333,
1115,
376,
29896,
613,
376,
1853,
1115,
6213,
29892,
376,
23813,
1115,
8853,
29874,
1115,
376,
29890,
29908,
24289,
13,
4706,
4974,
17971,
29889,
6717,
29918,
2704,
29889,
13998,
13,
4706,
4974,
17971,
29889,
6717,
29918,
2704,
29889,
4804,
29918,
5085,
29961,
29900,
3816,
29901,
29906,
29962,
1275,
313,
617,
29892,
376,
29896,
1159,
13,
4706,
4974,
338,
8758,
29898,
893,
29889,
6717,
29918,
2704,
29889,
4804,
29918,
5085,
29961,
29900,
3816,
29906,
1402,
8960,
29897,
13,
4706,
4974,
451,
17971,
29889,
265,
29918,
2962,
29889,
13998,
13,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
4706,
376,
27882,
29918,
5652,
29918,
20464,
29892,
9847,
29918,
1853,
29892,
20965,
29918,
9847,
29918,
1853,
613,
13,
4706,
313,
13,
9651,
313,
8824,
29892,
17727,
29889,
29954,
2239,
29918,
1254,
4590,
29892,
17727,
29889,
29954,
2239,
29918,
21514,
18476,
511,
13,
9651,
313,
5574,
29892,
17727,
29889,
29954,
2239,
29918,
21514,
18476,
29892,
17727,
29889,
29954,
2239,
29918,
1254,
4590,
511,
13,
4706,
10353,
13,
1678,
1723,
13,
1678,
822,
1243,
29918,
9847,
29898,
13,
4706,
1583,
29892,
13,
4706,
17971,
29892,
13,
4706,
21759,
29892,
13,
4706,
8608,
29918,
5652,
29918,
20464,
29892,
13,
4706,
5040,
29918,
1853,
29892,
13,
4706,
8340,
29918,
9847,
29918,
1853,
29892,
13,
268,
1125,
13,
4706,
17971,
29889,
265,
29918,
9847,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
6717,
29918,
2704,
353,
11187,
29889,
18680,
580,
13,
4706,
21759,
29889,
27882,
29918,
5652,
29918,
20464,
353,
8608,
29918,
5652,
29918,
20464,
13,
13,
4706,
17971,
29889,
5014,
29918,
4906,
29898,
617,
29892,
8853,
333,
1115,
376,
29896,
613,
376,
1853,
1115,
8340,
29918,
9847,
29918,
1853,
1800,
13,
4706,
4974,
17971,
29889,
6717,
29918,
2704,
29889,
13998,
13,
4706,
4974,
17971,
29889,
6717,
29918,
2704,
29889,
4804,
29918,
5085,
29961,
29900,
3816,
29901,
29906,
29962,
1275,
313,
617,
29892,
376,
29896,
1159,
13,
4706,
4974,
338,
8758,
29898,
893,
29889,
6717,
29918,
2704,
29889,
4804,
29918,
5085,
29961,
29900,
3816,
29906,
1402,
8960,
29897,
13,
4706,
4974,
451,
17971,
29889,
265,
29918,
9847,
29889,
13998,
13,
13,
4706,
17971,
29889,
5014,
29918,
4906,
29898,
617,
29892,
8853,
333,
1115,
376,
29896,
613,
376,
1853,
1115,
5040,
29918,
1853,
1800,
13,
4706,
17971,
29889,
265,
29918,
9847,
29889,
9294,
29918,
13998,
29918,
2541,
29898,
617,
29892,
376,
29896,
1159,
13,
13,
1678,
822,
1243,
29918,
20965,
29898,
1311,
29892,
17971,
29892,
21759,
1125,
13,
4706,
17971,
29889,
6717,
29918,
2704,
353,
11187,
29889,
18680,
580,
13,
4706,
17971,
29889,
5014,
29918,
4906,
29898,
617,
29892,
8853,
333,
1115,
376,
29896,
613,
376,
1853,
1115,
376,
26690,
29908,
1800,
13,
4706,
4974,
17971,
29889,
6717,
29918,
2704,
29889,
13998,
13,
4706,
4974,
17971,
29889,
6717,
29918,
2704,
29889,
4804,
29918,
5085,
29961,
29900,
3816,
29901,
29906,
29962,
1275,
313,
617,
29892,
376,
29896,
1159,
13,
4706,
4974,
338,
8758,
29898,
893,
29889,
6717,
29918,
2704,
29889,
4804,
29918,
5085,
29961,
29900,
3816,
29906,
1402,
8960,
29897,
13,
13,
13,
1753,
1243,
29918,
657,
29918,
4262,
1519,
29918,
7529,
29898,
893,
29892,
21759,
1125,
13,
1678,
20092,
353,
426,
13,
4706,
376,
1972,
1115,
376,
7971,
613,
13,
4706,
376,
20897,
1115,
376,
16908,
613,
13,
4706,
376,
16453,
1170,
1115,
376,
1972,
613,
13,
4706,
376,
4703,
1115,
24335,
13,
1678,
500,
13,
1678,
8636,
353,
17971,
29889,
657,
29918,
4262,
1519,
29918,
7529,
29898,
617,
29892,
20092,
29897,
13,
1678,
4974,
338,
8758,
29898,
7529,
29889,
7323,
703,
4258,
3406,
4968,
317,
2720,
13366,
29897,
13,
1678,
4974,
8636,
1275,
426,
13,
4706,
376,
3827,
29918,
1807,
1115,
376,
7971,
613,
13,
4706,
376,
11918,
29918,
5975,
1115,
376,
16908,
613,
13,
4706,
376,
16453,
29918,
978,
1115,
376,
1972,
613,
13,
4706,
376,
4703,
29918,
1767,
1115,
24335,
13,
1678,
500,
13,
13,
13,
1753,
1243,
29918,
4282,
29918,
4906,
29898,
893,
1125,
13,
1678,
4974,
17971,
29889,
4282,
29918,
4906,
703,
29896,
613,
376,
1972,
613,
376,
7228,
29979,
29428,
1159,
1275,
426,
13,
4706,
376,
333,
1115,
376,
29896,
613,
13,
4706,
376,
1853,
1115,
376,
1972,
613,
13,
4706,
376,
23813,
1115,
376,
7228,
29979,
29428,
613,
13,
1678,
500,
13,
13,
13,
1753,
1243,
29918,
4282,
29918,
4906,
29918,
3846,
29898,
893,
1125,
13,
1678,
4974,
17971,
29889,
4282,
29918,
4906,
29898,
333,
543,
29896,
613,
1015,
29918,
1853,
29922,
8516,
29892,
20092,
29922,
8516,
29897,
1275,
8853,
333,
1115,
376,
29896,
9092,
13,
1678,
4974,
17971,
29889,
4282,
29918,
4906,
29898,
333,
29922,
8516,
29892,
1015,
29918,
1853,
543,
1972,
613,
20092,
29922,
8516,
29897,
1275,
8853,
1853,
1115,
376,
1972,
9092,
13,
1678,
4974,
17971,
29889,
4282,
29918,
4906,
29898,
333,
29922,
8516,
29892,
1015,
29918,
1853,
29922,
8516,
29892,
20092,
543,
7228,
29979,
29428,
1159,
1275,
426,
13,
4706,
376,
23813,
1115,
376,
7228,
29979,
29428,
29908,
13,
1678,
500,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
14697,
291,
2392,
1125,
13,
4706,
17971,
29889,
4282,
29918,
4906,
29898,
333,
29922,
8516,
29892,
1015,
29918,
1853,
29922,
8516,
29892,
20092,
29922,
8516,
29897,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
27882,
29918,
5652,
29918,
20464,
29892,
9684,
29918,
1853,
613,
13,
1678,
5135,
8824,
29892,
17727,
29889,
29954,
2239,
29918,
14573,
511,
313,
5574,
29892,
17727,
29889,
29954,
2239,
29918,
29940,
12194,
8243,
13,
29897,
13,
1753,
1243,
29918,
6717,
29918,
22256,
29918,
2914,
29898,
893,
29892,
21759,
29892,
8608,
29918,
5652,
29918,
20464,
29892,
3806,
29918,
1853,
1125,
13,
1678,
21759,
29889,
27882,
29918,
5652,
29918,
20464,
353,
8608,
29918,
5652,
29918,
20464,
13,
1678,
17971,
29889,
22256,
29918,
2914,
29918,
517,
29918,
8977,
353,
11187,
29889,
18680,
580,
13,
1678,
17971,
29889,
22256,
29918,
2914,
29918,
517,
29918,
8977,
29889,
2457,
29918,
1767,
353,
8853,
690,
1115,
376,
499,
9092,
13,
1678,
17971,
29889,
6717,
29918,
4906,
353,
11187,
29889,
18680,
580,
13,
1678,
17971,
29889,
6717,
29918,
4906,
29889,
2457,
29918,
1767,
353,
376,
2457,
287,
29908,
13,
1678,
4974,
376,
2457,
287,
29908,
1275,
17971,
29889,
6717,
29918,
22256,
29918,
2914,
29898,
617,
29892,
376,
29896,
613,
376,
2914,
1159,
13,
1678,
17971,
29889,
6717,
29918,
4906,
29889,
9294,
29918,
13998,
29918,
2541,
29898,
617,
29892,
376,
29896,
613,
3806,
29918,
1853,
29892,
8853,
690,
1115,
376,
499,
29908,
1800,
13,
13,
13,
1753,
1243,
29918,
22256,
29918,
2914,
29918,
517,
29918,
8977,
29898,
893,
1125,
13,
1678,
1121,
353,
11187,
29889,
18680,
580,
13,
1678,
1121,
29889,
1272,
353,
376,
14573,
29908,
13,
1678,
1121,
29889,
12523,
353,
376,
1001,
29908,
13,
1678,
1121,
29918,
8977,
353,
17971,
29889,
22256,
29918,
2914,
29918,
517,
29918,
8977,
29898,
2914,
29897,
13,
1678,
4974,
338,
8758,
29898,
2914,
29918,
8977,
29892,
8170,
287,
21533,
29897,
13,
1678,
4974,
1121,
29918,
8977,
1275,
426,
13,
4706,
376,
1272,
1115,
376,
14573,
613,
13,
4706,
376,
12523,
1115,
518,
6377,
4906,
1115,
376,
29923,
10758,
8853,
4906,
1115,
376,
29934,
9092,
1402,
13,
1678,
500,
13,
13,
13,
1753,
1243,
29918,
6717,
29918,
4906,
29898,
893,
29892,
21759,
1125,
13,
1678,
17971,
29889,
4282,
29918,
4906,
353,
11187,
29889,
18680,
580,
13,
1678,
17971,
29889,
4282,
29918,
4906,
29889,
2457,
29918,
1767,
353,
8853,
12062,
1115,
376,
482,
9092,
13,
1678,
21759,
29889,
6717,
353,
11187,
29889,
18680,
580,
13,
1678,
21759,
29889,
6717,
29889,
2457,
29918,
1767,
353,
376,
2457,
287,
29908,
13,
1678,
4974,
376,
2457,
287,
29908,
1275,
17971,
29889,
6717,
29918,
4906,
29898,
617,
29897,
13,
1678,
21759,
29889,
6717,
29889,
9294,
29918,
13998,
29918,
2541,
3319,
29908,
12062,
1115,
376,
482,
29908,
1800,
13,
13,
13,
1990,
4321,
1799,
3664,
1888,
2037,
287,
29901,
13,
1678,
822,
1243,
29918,
8411,
29898,
1311,
29892,
17971,
1125,
13,
4706,
411,
11451,
1688,
29889,
336,
4637,
29898,
3664,
1888,
2037,
287,
2392,
1125,
13,
9651,
17971,
29889,
8411,
29898,
5652,
29922,
8516,
29892,
2009,
29918,
4703,
29922,
8516,
29897,
13,
2
] |
core/src/zeit/imp/browser/scale.py | rickdg/vivi | 5 | 159884 | from io import BytesIO
import PIL.Image
import PIL.ImageColor
import PIL.ImageDraw
import zeit.cms.browser.view
import zeit.content.image.interfaces
import zeit.imp.mask
def parse_filter_args(request, crop):
for key, value in request.form.items():
if key.startswith('filter.'):
filter_type = key.split('.', 1)[1]
try:
factor = float(value)
except ValueError:
continue
crop.add_filter(filter_type, factor)
class ScaledImage(zeit.cms.browser.view.Base):
def __call__(self, width, height):
return self.get_scaled_image(
zeit.content.image.interfaces.IMasterImage(self.context),
width, height)
def get_scaled_image(self, image, width, height):
width, height = int(width), int(height)
cropper = zeit.imp.interfaces.ICropper(image)
cropper.downsample_filter = PIL.Image.NEAREST
parse_filter_args(self.request, cropper)
pil_image = cropper.crop(width, height, 0, 0, width, height)
f = BytesIO()
pil_image.save(f, image.format)
self.request.response.setHeader(
'Cache-Control', 'public,max-age=3600')
self.request.response.setHeader('Content-Type', image.mimeType)
# Hellooo memory consumption
return f.getvalue()
class MaskImage(zeit.cms.browser.view.Base):
def __call__(self, image_width, image_height, mask_width, mask_height,
border):
image = zeit.imp.mask.Mask(
(int(image_width), int(image_height)),
(int(mask_width), int(mask_height)),
parse_border(border))
self.request.response.setHeader(
'Cache-Control', 'public,max-age=86400')
self.request.response.setHeader('Content-Type', 'image/png')
return image.open().read()
class CropImage(zeit.cms.browser.view.Base):
def __call__(self, w, h, x1, y1, x2, y2, name, border=''):
w, h = int(w), int(h)
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
cropper = zeit.imp.interfaces.ICropper(self.context)
parse_filter_args(self.request, cropper)
cropper.crop(w, h, x1, y1, x2, y2, parse_border(border))
image = zeit.imp.interfaces.IStorer(self.context).store(
name, cropper.pil_image)
return self.url(image)
def parse_border(border):
border_color = None
if border:
try:
border_color = PIL.ImageColor.getrgb(border)
except ValueError:
pass
return border_color
| [
1,
515,
12013,
1053,
2648,
2167,
5971,
13,
5215,
349,
6227,
29889,
2940,
13,
5215,
349,
6227,
29889,
2940,
3306,
13,
5215,
349,
6227,
29889,
2940,
8537,
13,
5215,
29402,
29889,
29883,
1516,
29889,
15965,
29889,
1493,
13,
5215,
29402,
29889,
3051,
29889,
3027,
29889,
1639,
8726,
13,
5215,
29402,
29889,
6574,
29889,
13168,
13,
13,
13,
1753,
6088,
29918,
4572,
29918,
5085,
29898,
3827,
29892,
274,
1336,
1125,
13,
1678,
363,
1820,
29892,
995,
297,
2009,
29889,
689,
29889,
7076,
7295,
13,
4706,
565,
1820,
29889,
27382,
2541,
877,
4572,
6169,
1125,
13,
9651,
4175,
29918,
1853,
353,
1820,
29889,
5451,
12839,
742,
29871,
29896,
9601,
29896,
29962,
13,
9651,
1018,
29901,
13,
18884,
7329,
353,
5785,
29898,
1767,
29897,
13,
9651,
5174,
7865,
2392,
29901,
13,
18884,
6773,
13,
9651,
274,
1336,
29889,
1202,
29918,
4572,
29898,
4572,
29918,
1853,
29892,
7329,
29897,
13,
13,
13,
1990,
2522,
7943,
2940,
29898,
6665,
29889,
29883,
1516,
29889,
15965,
29889,
1493,
29889,
5160,
1125,
13,
13,
1678,
822,
4770,
4804,
12035,
1311,
29892,
2920,
29892,
3171,
1125,
13,
4706,
736,
1583,
29889,
657,
29918,
7052,
29881,
29918,
3027,
29898,
13,
9651,
29402,
29889,
3051,
29889,
3027,
29889,
1639,
8726,
29889,
7833,
1901,
2940,
29898,
1311,
29889,
4703,
511,
13,
9651,
2920,
29892,
3171,
29897,
13,
13,
1678,
822,
679,
29918,
7052,
29881,
29918,
3027,
29898,
1311,
29892,
1967,
29892,
2920,
29892,
3171,
1125,
13,
4706,
2920,
29892,
3171,
353,
938,
29898,
2103,
511,
938,
29898,
3545,
29897,
13,
4706,
8182,
2496,
353,
29402,
29889,
6574,
29889,
1639,
8726,
29889,
2965,
307,
2496,
29898,
3027,
29897,
13,
4706,
8182,
2496,
29889,
3204,
11249,
29918,
4572,
353,
349,
6227,
29889,
2940,
29889,
8186,
29909,
1525,
1254,
13,
4706,
6088,
29918,
4572,
29918,
5085,
29898,
1311,
29889,
3827,
29892,
8182,
2496,
29897,
13,
4706,
8230,
29918,
3027,
353,
8182,
2496,
29889,
29883,
1336,
29898,
2103,
29892,
3171,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
2920,
29892,
3171,
29897,
13,
4706,
285,
353,
2648,
2167,
5971,
580,
13,
4706,
8230,
29918,
3027,
29889,
7620,
29898,
29888,
29892,
1967,
29889,
4830,
29897,
13,
4706,
1583,
29889,
3827,
29889,
5327,
29889,
842,
7850,
29898,
13,
9651,
525,
10408,
29899,
4809,
742,
525,
3597,
29892,
3317,
29899,
482,
29922,
29941,
29953,
29900,
29900,
1495,
13,
4706,
1583,
29889,
3827,
29889,
5327,
29889,
842,
7850,
877,
3916,
29899,
1542,
742,
1967,
29889,
29885,
603,
1542,
29897,
13,
4706,
396,
15043,
3634,
3370,
27430,
13,
4706,
736,
285,
29889,
657,
1767,
580,
13,
13,
13,
1990,
341,
1278,
2940,
29898,
6665,
29889,
29883,
1516,
29889,
15965,
29889,
1493,
29889,
5160,
1125,
13,
13,
1678,
822,
4770,
4804,
12035,
1311,
29892,
1967,
29918,
2103,
29892,
1967,
29918,
3545,
29892,
11105,
29918,
2103,
29892,
11105,
29918,
3545,
29892,
13,
462,
5139,
1125,
13,
4706,
1967,
353,
29402,
29889,
6574,
29889,
13168,
29889,
19832,
29898,
13,
9651,
313,
524,
29898,
3027,
29918,
2103,
511,
938,
29898,
3027,
29918,
3545,
8243,
13,
9651,
313,
524,
29898,
13168,
29918,
2103,
511,
938,
29898,
13168,
29918,
3545,
8243,
13,
9651,
6088,
29918,
11466,
29898,
11466,
876,
13,
4706,
1583,
29889,
3827,
29889,
5327,
29889,
842,
7850,
29898,
13,
9651,
525,
10408,
29899,
4809,
742,
525,
3597,
29892,
3317,
29899,
482,
29922,
29947,
29953,
29946,
29900,
29900,
1495,
13,
4706,
1583,
29889,
3827,
29889,
5327,
29889,
842,
7850,
877,
3916,
29899,
1542,
742,
525,
3027,
29914,
2732,
1495,
13,
4706,
736,
1967,
29889,
3150,
2141,
949,
580,
13,
13,
13,
1990,
315,
1336,
2940,
29898,
6665,
29889,
29883,
1516,
29889,
15965,
29889,
1493,
29889,
5160,
1125,
13,
13,
1678,
822,
4770,
4804,
12035,
1311,
29892,
281,
29892,
298,
29892,
921,
29896,
29892,
343,
29896,
29892,
921,
29906,
29892,
343,
29906,
29892,
1024,
29892,
5139,
2433,
29374,
13,
4706,
281,
29892,
298,
353,
938,
29898,
29893,
511,
938,
29898,
29882,
29897,
13,
4706,
921,
29896,
29892,
343,
29896,
29892,
921,
29906,
29892,
343,
29906,
353,
938,
29898,
29916,
29896,
511,
938,
29898,
29891,
29896,
511,
938,
29898,
29916,
29906,
511,
938,
29898,
29891,
29906,
29897,
13,
4706,
8182,
2496,
353,
29402,
29889,
6574,
29889,
1639,
8726,
29889,
2965,
307,
2496,
29898,
1311,
29889,
4703,
29897,
13,
4706,
6088,
29918,
4572,
29918,
5085,
29898,
1311,
29889,
3827,
29892,
8182,
2496,
29897,
13,
4706,
8182,
2496,
29889,
29883,
1336,
29898,
29893,
29892,
298,
29892,
921,
29896,
29892,
343,
29896,
29892,
921,
29906,
29892,
343,
29906,
29892,
6088,
29918,
11466,
29898,
11466,
876,
13,
4706,
1967,
353,
29402,
29889,
6574,
29889,
1639,
8726,
29889,
29902,
855,
9386,
29898,
1311,
29889,
4703,
467,
8899,
29898,
13,
9651,
1024,
29892,
8182,
2496,
29889,
29886,
309,
29918,
3027,
29897,
13,
4706,
736,
1583,
29889,
2271,
29898,
3027,
29897,
13,
13,
13,
1753,
6088,
29918,
11466,
29898,
11466,
1125,
13,
1678,
5139,
29918,
2780,
353,
6213,
13,
1678,
565,
5139,
29901,
13,
4706,
1018,
29901,
13,
9651,
5139,
29918,
2780,
353,
349,
6227,
29889,
2940,
3306,
29889,
657,
23973,
29898,
11466,
29897,
13,
4706,
5174,
7865,
2392,
29901,
13,
9651,
1209,
13,
1678,
736,
5139,
29918,
2780,
13,
2
] |
apps/abstract_models.py | kevingduck/transmission | 19 | 183402 | """
Copyright 2020 ShipChain, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from django.contrib.gis.db.models import GeometryField
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from shipchain_common.utils import AliasField, random_id
class AbstractTelemetryData(models.Model):
"""
Base model fields and meta data for Telemetry
Will be extended with FKs in child models
"""
id = models.CharField(primary_key=True, default=random_id, max_length=36)
created_at = models.DateTimeField(auto_now_add=True)
timestamp = models.DateTimeField(db_index=True)
hardware_id = models.CharField(max_length=255)
sensor_id = models.CharField(max_length=36)
value = models.FloatField()
version = models.CharField(max_length=36)
class Meta:
abstract = True
ordering = ('timestamp',)
class AbstractTrackingData(models.Model):
"""
Base model fields and meta data for Tracking
Will be extended with FKs in child models
"""
id = models.CharField(primary_key=True, default=random_id, max_length=36)
created_at = models.DateTimeField(auto_now_add=True)
latitude = models.FloatField(max_length=36)
longitude = models.FloatField(max_length=36)
altitude = models.FloatField(max_length=36, null=True, blank=True)
source = models.CharField(max_length=36)
uncertainty = models.IntegerField(validators=[MinValueValidator(0), MaxValueValidator(100)], null=True, blank=True)
speed = models.FloatField(validators=[MinValueValidator(0)], null=True, blank=True)
timestamp = models.DateTimeField(db_index=True)
time = AliasField(db_column='timestamp')
version = models.CharField(max_length=36)
point = GeometryField(spatial_index=True)
class Meta:
abstract = True
ordering = ('timestamp',)
| [
1,
9995,
13,
11882,
1266,
29871,
29906,
29900,
29906,
29900,
1383,
666,
14688,
29892,
9266,
29889,
13,
13,
29931,
293,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
6293,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
3492,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
13,
1678,
1732,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
13,
2525,
2222,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
5721,
7541,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29956,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
13,
13393,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
13400,
800,
1090,
278,
19245,
29889,
13,
15945,
29908,
13,
3166,
9557,
29889,
21570,
29889,
29887,
275,
29889,
2585,
29889,
9794,
1053,
1879,
7843,
3073,
13,
3166,
9557,
29889,
3221,
29889,
3084,
4097,
1053,
5918,
1917,
24204,
29892,
3080,
1917,
24204,
13,
3166,
9557,
29889,
2585,
1053,
4733,
13,
3166,
7751,
14153,
29918,
9435,
29889,
13239,
1053,
10785,
294,
3073,
29892,
4036,
29918,
333,
13,
13,
13,
1990,
25513,
7141,
2409,
27184,
1469,
29898,
9794,
29889,
3195,
1125,
13,
1678,
9995,
13,
1678,
7399,
1904,
4235,
322,
12700,
848,
363,
1920,
2409,
27184,
13,
1678,
2811,
367,
10410,
411,
28682,
29879,
297,
2278,
4733,
13,
1678,
9995,
13,
1678,
1178,
353,
4733,
29889,
27890,
29898,
16072,
29918,
1989,
29922,
5574,
29892,
2322,
29922,
8172,
29918,
333,
29892,
4236,
29918,
2848,
29922,
29941,
29953,
29897,
13,
1678,
2825,
29918,
271,
353,
4733,
29889,
11384,
3073,
29898,
6921,
29918,
3707,
29918,
1202,
29922,
5574,
29897,
13,
13,
1678,
14334,
353,
4733,
29889,
11384,
3073,
29898,
2585,
29918,
2248,
29922,
5574,
29897,
13,
1678,
12837,
29918,
333,
353,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
29897,
13,
1678,
23530,
29918,
333,
353,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29941,
29953,
29897,
13,
1678,
995,
353,
4733,
29889,
11031,
3073,
580,
13,
1678,
1873,
353,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29941,
29953,
29897,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
9846,
353,
5852,
13,
4706,
20520,
353,
6702,
16394,
742,
29897,
13,
13,
13,
1990,
25513,
17936,
292,
1469,
29898,
9794,
29889,
3195,
1125,
13,
1678,
9995,
13,
1678,
7399,
1904,
4235,
322,
12700,
848,
363,
17026,
292,
13,
1678,
2811,
367,
10410,
411,
28682,
29879,
297,
2278,
4733,
13,
1678,
9995,
13,
1678,
1178,
353,
4733,
29889,
27890,
29898,
16072,
29918,
1989,
29922,
5574,
29892,
2322,
29922,
8172,
29918,
333,
29892,
4236,
29918,
2848,
29922,
29941,
29953,
29897,
13,
1678,
2825,
29918,
271,
353,
4733,
29889,
11384,
3073,
29898,
6921,
29918,
3707,
29918,
1202,
29922,
5574,
29897,
13,
13,
1678,
26271,
353,
4733,
29889,
11031,
3073,
29898,
3317,
29918,
2848,
29922,
29941,
29953,
29897,
13,
1678,
28745,
353,
4733,
29889,
11031,
3073,
29898,
3317,
29918,
2848,
29922,
29941,
29953,
29897,
13,
1678,
5272,
4279,
353,
4733,
29889,
11031,
3073,
29898,
3317,
29918,
2848,
29922,
29941,
29953,
29892,
1870,
29922,
5574,
29892,
9654,
29922,
5574,
29897,
13,
1678,
2752,
353,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29941,
29953,
29897,
13,
1678,
25812,
353,
4733,
29889,
7798,
3073,
29898,
3084,
4097,
11759,
8140,
1917,
24204,
29898,
29900,
511,
5918,
1917,
24204,
29898,
29896,
29900,
29900,
29897,
1402,
1870,
29922,
5574,
29892,
9654,
29922,
5574,
29897,
13,
1678,
6210,
353,
4733,
29889,
11031,
3073,
29898,
3084,
4097,
11759,
8140,
1917,
24204,
29898,
29900,
29897,
1402,
1870,
29922,
5574,
29892,
9654,
29922,
5574,
29897,
13,
1678,
14334,
353,
4733,
29889,
11384,
3073,
29898,
2585,
29918,
2248,
29922,
5574,
29897,
13,
1678,
931,
353,
10785,
294,
3073,
29898,
2585,
29918,
4914,
2433,
16394,
1495,
13,
1678,
1873,
353,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29941,
29953,
29897,
13,
1678,
1298,
353,
1879,
7843,
3073,
29898,
1028,
15238,
29918,
2248,
29922,
5574,
29897,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
9846,
353,
5852,
13,
4706,
20520,
353,
6702,
16394,
742,
29897,
13,
2
] |
UVa 573 - The Snail/sample/main.py | tadvi/uva | 1 | 904 | '''
Created on Jun 18, 2013
@author: <NAME>
All rights reserved.
'''
import time
from multiprocessing.pool import Pool
parallelSolve = False
infinity = 1 << 30
def solve(par):
H, U, D, F = par
day = 0
amountRise = U
currH = 0
while True:
amountRise = U * (1 - 0.01 * F * day)
currH += amountRise
if currH > H:
return 'success on day %d' % (day + 1)
currH -= D
if currH < 0:
return 'failure on day %d' % (day + 1)
day += 1
class Solver:
def getInput(self):
self.input = []
self.numOfTests = 0
while True:
H, U, D, F = map(int, self.fIn.readline().strip().split())
if H == 0:
break
self.numOfTests += 1
self.input.append((H, U, D, F))
def __init__(self):
self.fIn = open('input.txt')
self.fOut = open('output.txt', 'w')
self.results = []
def parallel(self):
self.getInput()
p = Pool(4)
millis1 = int(round(time.time() * 1000))
self.results = p.map(solve, self.input)
millis2 = int(round(time.time() * 1000))
print("Time in milliseconds: %d " % (millis2 - millis1))
self.makeOutput()
def sequential(self):
self.getInput()
millis1 = int(round(time.time() * 1000))
for i in self.input:
self.results.append(solve(i))
millis2 = int(round(time.time() * 1000))
print("Time in milliseconds: %d " % (millis2 - millis1))
self.makeOutput()
def makeOutput(self):
for test in range(self.numOfTests):
self.fOut.write("Case #%d: %s\n" % (test + 1, self.results[test]))
self.fIn.close()
self.fOut.close()
if __name__ == '__main__':
solver = Solver()
if parallelSolve:
solver.parallel()
else:
solver.sequential()
| [
1,
14550,
13,
20399,
373,
8378,
29871,
29896,
29947,
29892,
29871,
29906,
29900,
29896,
29941,
13,
13,
29992,
8921,
29901,
529,
5813,
29958,
13,
13,
3596,
10462,
21676,
29889,
13,
12008,
13,
13,
5215,
931,
13,
3166,
6674,
307,
985,
292,
29889,
10109,
1053,
28625,
13,
23482,
13296,
345,
353,
7700,
13,
262,
4951,
537,
353,
29871,
29896,
3532,
29871,
29941,
29900,
13,
13,
13,
1753,
4505,
29898,
862,
1125,
13,
1678,
379,
29892,
501,
29892,
360,
29892,
383,
353,
610,
13,
1678,
2462,
353,
29871,
29900,
13,
1678,
5253,
29934,
895,
353,
501,
13,
1678,
16256,
29950,
353,
29871,
29900,
13,
1678,
1550,
5852,
29901,
13,
4706,
5253,
29934,
895,
353,
501,
334,
313,
29896,
448,
29871,
29900,
29889,
29900,
29896,
334,
383,
334,
2462,
29897,
13,
4706,
16256,
29950,
4619,
5253,
29934,
895,
13,
4706,
565,
16256,
29950,
1405,
379,
29901,
13,
9651,
736,
525,
8698,
373,
2462,
1273,
29881,
29915,
1273,
313,
3250,
718,
29871,
29896,
29897,
13,
4706,
16256,
29950,
22361,
360,
13,
4706,
565,
16256,
29950,
529,
29871,
29900,
29901,
13,
9651,
736,
525,
14057,
545,
373,
2462,
1273,
29881,
29915,
1273,
313,
3250,
718,
29871,
29896,
29897,
13,
4706,
2462,
4619,
29871,
29896,
13,
13,
13,
1990,
4956,
369,
29901,
13,
13,
1678,
822,
679,
4290,
29898,
1311,
1125,
13,
4706,
1583,
29889,
2080,
353,
5159,
13,
4706,
1583,
29889,
1949,
2776,
24376,
353,
29871,
29900,
13,
4706,
1550,
5852,
29901,
13,
9651,
379,
29892,
501,
29892,
360,
29892,
383,
353,
2910,
29898,
524,
29892,
1583,
29889,
29888,
797,
29889,
949,
1220,
2141,
17010,
2141,
5451,
3101,
13,
9651,
565,
379,
1275,
29871,
29900,
29901,
13,
18884,
2867,
13,
9651,
1583,
29889,
1949,
2776,
24376,
4619,
29871,
29896,
13,
9651,
1583,
29889,
2080,
29889,
4397,
3552,
29950,
29892,
501,
29892,
360,
29892,
383,
876,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
29888,
797,
353,
1722,
877,
2080,
29889,
3945,
1495,
13,
4706,
1583,
29889,
29888,
3744,
353,
1722,
877,
4905,
29889,
3945,
742,
525,
29893,
1495,
13,
4706,
1583,
29889,
9902,
353,
5159,
13,
13,
1678,
822,
8943,
29898,
1311,
1125,
13,
4706,
1583,
29889,
657,
4290,
580,
13,
4706,
282,
353,
28625,
29898,
29946,
29897,
13,
4706,
3533,
275,
29896,
353,
938,
29898,
14486,
29898,
2230,
29889,
2230,
580,
334,
29871,
29896,
29900,
29900,
29900,
876,
13,
4706,
1583,
29889,
9902,
353,
282,
29889,
1958,
29898,
2929,
345,
29892,
1583,
29889,
2080,
29897,
13,
4706,
3533,
275,
29906,
353,
938,
29898,
14486,
29898,
2230,
29889,
2230,
580,
334,
29871,
29896,
29900,
29900,
29900,
876,
13,
4706,
1596,
703,
2481,
297,
3533,
21462,
29901,
1273,
29881,
376,
1273,
313,
19958,
275,
29906,
448,
3533,
275,
29896,
876,
13,
4706,
1583,
29889,
5675,
6466,
580,
13,
13,
1678,
822,
8617,
2556,
29898,
1311,
1125,
13,
4706,
1583,
29889,
657,
4290,
580,
13,
4706,
3533,
275,
29896,
353,
938,
29898,
14486,
29898,
2230,
29889,
2230,
580,
334,
29871,
29896,
29900,
29900,
29900,
876,
13,
4706,
363,
474,
297,
1583,
29889,
2080,
29901,
13,
9651,
1583,
29889,
9902,
29889,
4397,
29898,
2929,
345,
29898,
29875,
876,
13,
4706,
3533,
275,
29906,
353,
938,
29898,
14486,
29898,
2230,
29889,
2230,
580,
334,
29871,
29896,
29900,
29900,
29900,
876,
13,
4706,
1596,
703,
2481,
297,
3533,
21462,
29901,
1273,
29881,
376,
1273,
313,
19958,
275,
29906,
448,
3533,
275,
29896,
876,
13,
4706,
1583,
29889,
5675,
6466,
580,
13,
13,
1678,
822,
1207,
6466,
29898,
1311,
1125,
13,
4706,
363,
1243,
297,
3464,
29898,
1311,
29889,
1949,
2776,
24376,
1125,
13,
9651,
1583,
29889,
29888,
3744,
29889,
3539,
703,
8259,
396,
29995,
29881,
29901,
1273,
29879,
29905,
29876,
29908,
1273,
313,
1688,
718,
29871,
29896,
29892,
1583,
29889,
9902,
29961,
1688,
12622,
13,
4706,
1583,
29889,
29888,
797,
29889,
5358,
580,
13,
4706,
1583,
29889,
29888,
3744,
29889,
5358,
580,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
899,
369,
353,
4956,
369,
580,
13,
1678,
565,
8943,
13296,
345,
29901,
13,
4706,
899,
369,
29889,
23482,
580,
13,
1678,
1683,
29901,
13,
4706,
899,
369,
29889,
6831,
2556,
580,
13,
2
] |
src/scheduled_task/__init__.py | Sciocatti/python_scheduler_and_clean_forced_exit | 0 | 7471 | from .scheduled_task import ScheduledTask | [
1,
515,
869,
816,
14989,
29918,
7662,
1053,
1102,
14989,
5398,
2
] |
core/config.py | Mustard030/pixiv_download | 1 | 87906 | <gh_stars>1-10
import configparser
import tkinter as tk
import tkinter.filedialog
SETTING_FILE = 'setting.ini'
# 读取配置文件
def read_config(setting_file=SETTING_FILE):
config = configparser.ConfigParser()
config.read(setting_file, encoding='UTF-8')
config_dict = dict()
try:
config_dict = dict(config.items('USER'))
except configparser.NoSectionError:
print('配置文件损坏或不存在,进行初始化设置')
download_path = config_dict.get('download_path', '')
storage_path = config_dict.get('storage_path', '')
bin_path = config_dict.get('bin_path', '')
quick_path = config_dict.get('quick_path', '')
api_key = config_dict.get('api_key', '')
if download_path:
print('图片下载路径:', download_path)
else:
root = tk.Tk()
root.withdraw()
while True:
print('图片下载路径缺失,请选择文件夹路径!')
download_path = tkinter.filedialog.askdirectory()
if not download_path:
print('此路径为程序运行必须路径,请进行设置')
else:
print('图片下载路径:', download_path)
break
if storage_path:
print('图片仓库路径:', storage_path)
if bin_path:
print('无法查找的图片路径:', bin_path)
else:
root = tk.Tk()
root.withdraw()
while True:
print('图片回收箱路径缺失,请选择文件夹路径!')
bin_path = tkinter.filedialog.askdirectory()
if not bin_path:
print('此路径为搜图功能必须路径,请进行设置')
else:
print('无法查找的图片路径:', bin_path)
break
if quick_path:
print('快速搜索图片路径:', quick_path)
if api_key:
print('API_KEY:', api_key)
write_config(setting_file, download_path=download_path,
storage_path=storage_path, bin_path=bin_path,
quick_path=quick_path, api_key=api_key)
return download_path, storage_path, bin_path, quick_path, api_key
# 写入配置文件
def write_config(setting_file=SETTING_FILE, **kwargs):
config = configparser.ConfigParser()
config.read(setting_file, encoding='UTF-8')
if not config.has_section('USER'):
config.add_section('USER')
config.set('DEFAULT', 'API_KEY', '')
for key in kwargs:
config.set('USER', key, kwargs.get(key, ''))
# config.set('USER', 'DOWNLOAD_ROOT_PATH', kwargs.get('download_path', ''))
# config.set('USER', 'SAVE_ROOT_PATH', kwargs.get('save_root_path', ''))
# config.set('USER', 'BIN_PATH', kwargs.get('bin_path', ''))
# config.set('USER', 'CACHE_PATH', kwargs.get('cache_path', ''))
# config.set('USER', 'API_KEY', kwargs.get('api_key', ''))
with open(setting_file, 'w', encoding='UTF-8') as setting_file: # 写入配置文件
config.write(setting_file)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
2295,
16680,
13,
5215,
18883,
1639,
408,
18883,
13,
5215,
18883,
1639,
29889,
1445,
15901,
13,
13,
10490,
29911,
4214,
29918,
7724,
353,
525,
26740,
29889,
2172,
29915,
13,
29937,
29871,
235,
178,
190,
30683,
31361,
30669,
30333,
30631,
13,
1753,
1303,
29918,
2917,
29898,
26740,
29918,
1445,
29922,
10490,
29911,
4214,
29918,
7724,
1125,
13,
1678,
2295,
353,
2295,
16680,
29889,
3991,
11726,
580,
13,
1678,
2295,
29889,
949,
29898,
26740,
29918,
1445,
29892,
8025,
2433,
10496,
29899,
29947,
1495,
13,
1678,
2295,
29918,
8977,
353,
9657,
580,
13,
1678,
1018,
29901,
13,
4706,
2295,
29918,
8977,
353,
9657,
29898,
2917,
29889,
7076,
877,
11889,
8785,
13,
1678,
5174,
2295,
16680,
29889,
3782,
13438,
2392,
29901,
13,
4706,
1596,
877,
31361,
30669,
30333,
30631,
233,
144,
162,
232,
160,
146,
31391,
30413,
30946,
30505,
29892,
31174,
30448,
31120,
31020,
30705,
30872,
30669,
1495,
13,
13,
1678,
5142,
29918,
2084,
353,
2295,
29918,
8977,
29889,
657,
877,
10382,
29918,
2084,
742,
27255,
13,
1678,
8635,
29918,
2084,
353,
2295,
29918,
8977,
29889,
657,
877,
12925,
29918,
2084,
742,
27255,
13,
1678,
9016,
29918,
2084,
353,
2295,
29918,
8977,
29889,
657,
877,
2109,
29918,
2084,
742,
27255,
13,
1678,
4996,
29918,
2084,
353,
2295,
29918,
8977,
29889,
657,
877,
24561,
29918,
2084,
742,
27255,
13,
1678,
7882,
29918,
1989,
353,
2295,
29918,
8977,
29889,
657,
877,
2754,
29918,
1989,
742,
27255,
13,
13,
1678,
565,
5142,
29918,
2084,
29901,
13,
4706,
1596,
877,
30861,
31122,
30557,
31526,
30874,
232,
193,
135,
29901,
742,
5142,
29918,
2084,
29897,
13,
1678,
1683,
29901,
13,
4706,
3876,
353,
18883,
29889,
29911,
29895,
580,
13,
4706,
3876,
29889,
2541,
4012,
580,
13,
4706,
1550,
5852,
29901,
13,
9651,
1596,
877,
30861,
31122,
30557,
31526,
30874,
232,
193,
135,
234,
191,
189,
31369,
29892,
31088,
31333,
233,
142,
172,
30333,
30631,
232,
167,
188,
30874,
232,
193,
135,
29991,
1495,
13,
9651,
5142,
29918,
2084,
353,
18883,
1639,
29889,
1445,
15901,
29889,
1278,
12322,
580,
13,
9651,
565,
451,
5142,
29918,
2084,
29901,
13,
18884,
1596,
877,
31389,
30874,
232,
193,
135,
30573,
31101,
31463,
31894,
30448,
31641,
236,
164,
190,
30874,
232,
193,
135,
30214,
31088,
31174,
30448,
30872,
30669,
1495,
13,
9651,
1683,
29901,
13,
18884,
1596,
877,
30861,
31122,
30557,
31526,
30874,
232,
193,
135,
29901,
742,
5142,
29918,
2084,
29897,
13,
18884,
2867,
13,
13,
1678,
565,
8635,
29918,
2084,
29901,
13,
4706,
1596,
877,
30861,
31122,
231,
190,
150,
31700,
30874,
232,
193,
135,
29901,
742,
8635,
29918,
2084,
29897,
13,
13,
1678,
565,
9016,
29918,
2084,
29901,
13,
4706,
1596,
877,
31352,
30545,
31213,
233,
140,
193,
30210,
30861,
31122,
30874,
232,
193,
135,
29901,
742,
9016,
29918,
2084,
29897,
13,
1678,
1683,
29901,
13,
4706,
3876,
353,
18883,
29889,
29911,
29895,
580,
13,
4706,
3876,
29889,
2541,
4012,
580,
13,
4706,
1550,
5852,
29901,
13,
9651,
1596,
877,
30861,
31122,
30742,
31997,
234,
177,
180,
30874,
232,
193,
135,
234,
191,
189,
31369,
29892,
31088,
31333,
233,
142,
172,
30333,
30631,
232,
167,
188,
30874,
232,
193,
135,
29991,
1495,
13,
9651,
9016,
29918,
2084,
353,
18883,
1639,
29889,
1445,
15901,
29889,
1278,
12322,
580,
13,
9651,
565,
451,
9016,
29918,
2084,
29901,
13,
18884,
1596,
877,
31389,
30874,
232,
193,
135,
30573,
233,
147,
159,
30861,
31134,
30815,
31641,
236,
164,
190,
30874,
232,
193,
135,
30214,
31088,
31174,
30448,
30872,
30669,
1495,
13,
9651,
1683,
29901,
13,
18884,
1596,
877,
31352,
30545,
31213,
233,
140,
193,
30210,
30861,
31122,
30874,
232,
193,
135,
29901,
742,
9016,
29918,
2084,
29897,
13,
18884,
2867,
13,
13,
1678,
565,
4996,
29918,
2084,
29901,
13,
4706,
1596,
877,
232,
194,
174,
31859,
233,
147,
159,
31836,
30861,
31122,
30874,
232,
193,
135,
29901,
742,
4996,
29918,
2084,
29897,
13,
13,
1678,
565,
7882,
29918,
1989,
29901,
13,
4706,
1596,
877,
8787,
29918,
10818,
29901,
742,
7882,
29918,
1989,
29897,
13,
13,
1678,
2436,
29918,
2917,
29898,
26740,
29918,
1445,
29892,
5142,
29918,
2084,
29922,
10382,
29918,
2084,
29892,
13,
462,
8635,
29918,
2084,
29922,
12925,
29918,
2084,
29892,
9016,
29918,
2084,
29922,
2109,
29918,
2084,
29892,
13,
462,
4996,
29918,
2084,
29922,
24561,
29918,
2084,
29892,
7882,
29918,
1989,
29922,
2754,
29918,
1989,
29897,
13,
1678,
736,
5142,
29918,
2084,
29892,
8635,
29918,
2084,
29892,
9016,
29918,
2084,
29892,
4996,
29918,
2084,
29892,
7882,
29918,
1989,
13,
13,
13,
29937,
29871,
31479,
30752,
31361,
30669,
30333,
30631,
13,
1753,
2436,
29918,
2917,
29898,
26740,
29918,
1445,
29922,
10490,
29911,
4214,
29918,
7724,
29892,
3579,
19290,
1125,
13,
1678,
2295,
353,
2295,
16680,
29889,
3991,
11726,
580,
13,
1678,
2295,
29889,
949,
29898,
26740,
29918,
1445,
29892,
8025,
2433,
10496,
29899,
29947,
1495,
13,
1678,
565,
451,
2295,
29889,
5349,
29918,
2042,
877,
11889,
29374,
13,
4706,
2295,
29889,
1202,
29918,
2042,
877,
11889,
1495,
13,
1678,
2295,
29889,
842,
877,
23397,
742,
525,
8787,
29918,
10818,
742,
27255,
13,
13,
1678,
363,
1820,
297,
9049,
5085,
29901,
13,
4706,
2295,
29889,
842,
877,
11889,
742,
1820,
29892,
9049,
5085,
29889,
657,
29898,
1989,
29892,
6629,
876,
13,
1678,
396,
2295,
29889,
842,
877,
11889,
742,
525,
3970,
16048,
29428,
29918,
21289,
29918,
10145,
742,
9049,
5085,
29889,
657,
877,
10382,
29918,
2084,
742,
6629,
876,
13,
1678,
396,
2295,
29889,
842,
877,
11889,
742,
525,
29903,
7520,
29923,
29918,
21289,
29918,
10145,
742,
9049,
5085,
29889,
657,
877,
7620,
29918,
4632,
29918,
2084,
742,
6629,
876,
13,
1678,
396,
2295,
29889,
842,
877,
11889,
742,
525,
29933,
1177,
29918,
10145,
742,
9049,
5085,
29889,
657,
877,
2109,
29918,
2084,
742,
6629,
876,
13,
1678,
396,
2295,
29889,
842,
877,
11889,
742,
525,
29907,
2477,
9606,
29918,
10145,
742,
9049,
5085,
29889,
657,
877,
8173,
29918,
2084,
742,
6629,
876,
13,
1678,
396,
2295,
29889,
842,
877,
11889,
742,
525,
8787,
29918,
10818,
742,
9049,
5085,
29889,
657,
877,
2754,
29918,
1989,
742,
6629,
876,
13,
13,
1678,
411,
1722,
29898,
26740,
29918,
1445,
29892,
525,
29893,
742,
8025,
2433,
10496,
29899,
29947,
1495,
408,
4444,
29918,
1445,
29901,
29871,
396,
29871,
31479,
30752,
31361,
30669,
30333,
30631,
13,
4706,
2295,
29889,
3539,
29898,
26740,
29918,
1445,
29897,
13,
2
] |
news/migrations/0001_squashed_0002_news_send_announce.py | VanirLab/VOS | 0 | 182736 | # -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-11-17 20:55
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='News',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('slug', models.SlugField(max_length=255, unique=True)),
('postdate', models.DateTimeField(db_index=True, verbose_name='post date')),
('last_modified', models.DateTimeField(db_index=True, editable=False)),
('title', models.CharField(max_length=255)),
('guid', models.CharField(editable=False, max_length=255)),
('content', models.TextField()),
('safe_mode', models.BooleanField(default=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='news_author', to=settings.AUTH_USER_MODEL)),
('send_announce', models.BooleanField(default=True)),
],
options={
'ordering': ('-postdate',),
'db_table': 'news',
'verbose_name_plural': 'news',
'get_latest_by': 'postdate',
},
),
]
| [
1,
396,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
30004,
13,
29937,
3251,
630,
491,
15337,
29871,
29896,
29889,
29896,
29896,
29889,
29896,
29945,
373,
29871,
29906,
29900,
29896,
29947,
29899,
29896,
29896,
29899,
29896,
29955,
29871,
29906,
29900,
29901,
29945,
29945,
30004,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
30004,
13,
30004,
13,
3166,
9557,
29889,
5527,
1053,
6055,
30004,
13,
3166,
9557,
29889,
2585,
1053,
9725,
800,
29892,
4733,
30004,
13,
5215,
9557,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
30004,
13,
30004,
13,
30004,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
30004,
13,
30004,
13,
1678,
2847,
353,
5852,
30004,
13,
30004,
13,
1678,
9962,
353,
518,
30004,
13,
4706,
9725,
800,
29889,
2774,
932,
519,
29918,
10836,
29898,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
511,
30004,
13,
1678,
4514,
30004,
13,
30004,
13,
1678,
6931,
353,
518,
30004,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
30004,
13,
9651,
1024,
2433,
29328,
23592,
13,
9651,
4235,
11759,
30004,
13,
18884,
6702,
333,
742,
4733,
29889,
12300,
3073,
29898,
6921,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
26952,
29918,
978,
2433,
1367,
1495,
511,
30004,
13,
18884,
6702,
29517,
742,
4733,
29889,
16973,
688,
3073,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
29892,
5412,
29922,
5574,
8243,
30004,
13,
18884,
6702,
2490,
1256,
742,
4733,
29889,
11384,
3073,
29898,
2585,
29918,
2248,
29922,
5574,
29892,
26952,
29918,
978,
2433,
2490,
2635,
1495,
511,
30004,
13,
18884,
6702,
4230,
29918,
1545,
2164,
742,
4733,
29889,
11384,
3073,
29898,
2585,
29918,
2248,
29922,
5574,
29892,
3863,
519,
29922,
8824,
8243,
30004,
13,
18884,
6702,
3257,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
8243,
30004,
13,
18884,
6702,
2543,
333,
742,
4733,
29889,
27890,
29898,
5628,
519,
29922,
8824,
29892,
4236,
29918,
2848,
29922,
29906,
29945,
29945,
8243,
30004,
13,
18884,
6702,
3051,
742,
4733,
29889,
15778,
25739,
30004,
13,
18884,
6702,
11177,
29918,
8513,
742,
4733,
29889,
18146,
3073,
29898,
4381,
29922,
5574,
8243,
30004,
13,
18884,
6702,
8921,
742,
4733,
29889,
27755,
2558,
29898,
265,
29918,
8143,
29922,
14095,
29889,
2585,
29889,
9794,
29889,
311,
1026,
291,
29889,
8618,
4330,
1783,
29892,
4475,
29918,
978,
2433,
15753,
29918,
8921,
742,
304,
29922,
11027,
29889,
20656,
29950,
29918,
11889,
29918,
20387,
29931,
8243,
30004,
13,
18884,
6702,
6717,
29918,
812,
21543,
742,
4733,
29889,
18146,
3073,
29898,
4381,
29922,
5574,
8243,
30004,
13,
9651,
21251,
30004,
13,
9651,
3987,
3790,
30004,
13,
18884,
525,
2098,
292,
2396,
6702,
29899,
2490,
1256,
742,
511,
30004,
13,
18884,
525,
2585,
29918,
2371,
2396,
525,
15753,
23592,
13,
18884,
525,
369,
15828,
29918,
978,
29918,
572,
3631,
2396,
525,
15753,
23592,
13,
18884,
525,
657,
29918,
12333,
29918,
1609,
2396,
525,
2490,
1256,
23592,
13,
9651,
2981,
30004,
13,
4706,
10353,
30004,
13,
1678,
4514,
30004,
13,
2
] |
mne/_hdf5.py | jaeilepp/eggie | 0 | 78839 | # -*- coding: utf-8 -*-
# Authors: <NAME> <<EMAIL>>
#
# License: BSD (3-clause)
import numpy as np
from os import path as op
from .utils import _check_pytables
from .externals.six import string_types, text_type
##############################################################################
# WRITE
def write_hdf5(fname, data, overwrite=False):
"""Write python object to HDF5 format using Pytables
Parameters
----------
fname : str
Filename to use.
data : object
Object to write. Can be of any of these types:
{ndarray, dict, list, tuple, int, float, str}
Note that dict objects must only have ``str`` keys.
overwrite : bool
If True, overwrite file (if it exists).
"""
tb = _check_pytables()
if op.isfile(fname) and not overwrite:
raise IOError('file "%s" exists, use overwrite=True to overwrite'
% fname)
o_f = tb.open_file if hasattr(tb, 'open_file') else tb.openFile
with o_f(fname, mode='w') as fid:
if hasattr(fid, 'create_group'):
c_g = fid.create_group
c_t = fid.create_table
c_c_a = fid.create_carray
else:
c_g = fid.createGroup
c_t = fid.createTable
c_c_a = fid.createCArray
filters = tb.Filters(complib='zlib', complevel=5)
write_params = (c_g, c_t, c_c_a, filters)
_triage_write('mnepython', data, fid.root, *write_params)
def _triage_write(key, value, root, *write_params):
tb = _check_pytables()
create_group, create_table, create_c_array, filters = write_params
if isinstance(value, dict):
sub_root = create_group(root, key, 'dict')
for key, sub_value in value.items():
if not isinstance(key, string_types):
raise TypeError('All dict keys must be strings')
_triage_write('key_{0}'.format(key), sub_value, sub_root,
*write_params)
elif isinstance(value, (list, tuple)):
title = 'list' if isinstance(value, list) else 'tuple'
sub_root = create_group(root, key, title)
for vi, sub_value in enumerate(value):
_triage_write('idx_{0}'.format(vi), sub_value, sub_root,
*write_params)
elif isinstance(value, type(None)):
atom = tb.BoolAtom()
s = create_c_array(root, key, atom, (1,), title='None',
filters=filters)
s[:] = False
elif isinstance(value, (int, float)):
if isinstance(value, int):
title = 'int'
else: # isinstance(value, float):
title = 'float'
value = np.atleast_1d(value)
atom = tb.Atom.from_dtype(value.dtype)
s = create_c_array(root, key, atom, (1,),
title=title, filters=filters)
s[:] = value
elif isinstance(value, string_types):
atom = tb.UInt8Atom()
if isinstance(value, text_type): # unicode
value = np.fromstring(value.encode('utf-8'), np.uint8)
title = 'unicode'
else:
value = np.fromstring(value.encode('ASCII'), np.uint8)
title = 'ascii'
s = create_c_array(root, key, atom, (len(value),), title=title,
filters=filters)
s[:] = value
elif isinstance(value, np.ndarray):
atom = tb.Atom.from_dtype(value.dtype)
s = create_c_array(root, key, atom, value.shape,
title='ndarray', filters=filters)
s[:] = value
else:
raise TypeError('unsupported type %s' % type(value))
##############################################################################
# READ
def read_hdf5(fname):
"""Read python object from HDF5 format using Pytables
Parameters
----------
fname : str
File to load.
Returns
-------
data : object
The loaded data. Can be of any type supported by ``write_hdf5``.
"""
tb = _check_pytables()
if not op.isfile(fname):
raise IOError('file "%s" not found' % fname)
o_f = tb.open_file if hasattr(tb, 'open_file') else tb.openFile
with o_f(fname, mode='r') as fid:
if not hasattr(fid.root, 'mnepython'):
raise TypeError('no mne-python data found')
data = _triage_read(fid.root.mnepython)
return data
def _triage_read(node):
tb = _check_pytables()
type_str = node._v_title
if isinstance(node, tb.Group):
if type_str == 'dict':
data = dict()
for subnode in node:
key = subnode._v_name[4:] # cut off "idx_" or "key_" prefix
data[key] = _triage_read(subnode)
elif type_str in ['list', 'tuple']:
data = list()
ii = 0
while True:
subnode = getattr(node, 'idx_{0}'.format(ii), None)
if subnode is None:
break
data.append(_triage_read(subnode))
ii += 1
assert len(data) == ii
data = tuple(data) if type_str == 'tuple' else data
return data
else:
raise NotImplementedError('Unknown group type: {0}'
''.format(type_str))
elif type_str == 'ndarray':
data = np.array(node)
elif type_str in ('int', 'float'):
if type_str == 'int':
cast = int
else: # type_str == 'float':
cast = float
data = cast(np.array(node)[0])
elif type_str in ('unicode', 'ascii'):
decoder = 'utf-8' if type_str == 'unicode' else 'ASCII'
cast = text_type if type_str == 'unicode' else str
data = cast(np.array(node).tostring().decode(decoder))
elif type_str == 'None':
data = None
else:
raise TypeError('Unknown node type: {0}'.format(type_str))
return data
| [
1,
396,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
29937,
13189,
943,
29901,
529,
5813,
29958,
3532,
26862,
6227,
6778,
13,
29937,
13,
29937,
19245,
29901,
350,
7230,
313,
29941,
29899,
16398,
1509,
29897,
13,
13,
5215,
12655,
408,
7442,
13,
3166,
2897,
1053,
2224,
408,
1015,
13,
13,
3166,
869,
13239,
1053,
903,
3198,
29918,
2272,
24051,
13,
3166,
869,
735,
725,
1338,
29889,
28319,
1053,
1347,
29918,
8768,
29892,
1426,
29918,
1853,
13,
13,
13,
13383,
13383,
13383,
13383,
7346,
4136,
2277,
13,
29937,
399,
29934,
9094,
13,
13,
1753,
2436,
29918,
29882,
2176,
29945,
29898,
29888,
978,
29892,
848,
29892,
26556,
29922,
8824,
1125,
13,
1678,
9995,
6113,
3017,
1203,
304,
379,
4037,
29945,
3402,
773,
349,
3637,
1849,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
285,
978,
584,
851,
13,
4706,
2514,
3871,
304,
671,
29889,
13,
1678,
848,
584,
1203,
13,
4706,
4669,
304,
2436,
29889,
1815,
367,
310,
738,
310,
1438,
4072,
29901,
13,
9651,
426,
299,
2378,
29892,
9657,
29892,
1051,
29892,
18761,
29892,
938,
29892,
5785,
29892,
851,
29913,
13,
4706,
3940,
393,
9657,
3618,
1818,
871,
505,
4954,
710,
16159,
6611,
29889,
13,
1678,
26556,
584,
6120,
13,
4706,
960,
5852,
29892,
26556,
934,
313,
361,
372,
4864,
467,
13,
1678,
9995,
13,
1678,
260,
29890,
353,
903,
3198,
29918,
2272,
24051,
580,
13,
1678,
565,
1015,
29889,
275,
1445,
29898,
29888,
978,
29897,
322,
451,
26556,
29901,
13,
4706,
12020,
10663,
2392,
877,
1445,
11860,
29879,
29908,
4864,
29892,
671,
26556,
29922,
5574,
304,
26556,
29915,
13,
462,
418,
1273,
285,
978,
29897,
13,
1678,
288,
29918,
29888,
353,
260,
29890,
29889,
3150,
29918,
1445,
565,
756,
5552,
29898,
22625,
29892,
525,
3150,
29918,
1445,
1495,
1683,
260,
29890,
29889,
3150,
2283,
13,
1678,
411,
288,
29918,
29888,
29898,
29888,
978,
29892,
4464,
2433,
29893,
1495,
408,
25947,
29901,
13,
4706,
565,
756,
5552,
29898,
29888,
333,
29892,
525,
3258,
29918,
2972,
29374,
13,
9651,
274,
29918,
29887,
353,
25947,
29889,
3258,
29918,
2972,
13,
9651,
274,
29918,
29873,
353,
25947,
29889,
3258,
29918,
2371,
13,
9651,
274,
29918,
29883,
29918,
29874,
353,
25947,
29889,
3258,
29918,
29883,
2378,
13,
4706,
1683,
29901,
13,
9651,
274,
29918,
29887,
353,
25947,
29889,
3258,
4782,
13,
9651,
274,
29918,
29873,
353,
25947,
29889,
3258,
3562,
13,
9651,
274,
29918,
29883,
29918,
29874,
353,
25947,
29889,
3258,
29907,
2588,
13,
4706,
18094,
353,
260,
29890,
29889,
3434,
2153,
29898,
2388,
1982,
2433,
29920,
1982,
742,
1614,
955,
29922,
29945,
29897,
13,
4706,
2436,
29918,
7529,
353,
313,
29883,
29918,
29887,
29892,
274,
29918,
29873,
29892,
274,
29918,
29883,
29918,
29874,
29892,
18094,
29897,
13,
4706,
903,
3626,
482,
29918,
3539,
877,
29885,
484,
4691,
742,
848,
29892,
25947,
29889,
4632,
29892,
334,
3539,
29918,
7529,
29897,
13,
13,
13,
1753,
903,
3626,
482,
29918,
3539,
29898,
1989,
29892,
995,
29892,
3876,
29892,
334,
3539,
29918,
7529,
1125,
13,
1678,
260,
29890,
353,
903,
3198,
29918,
2272,
24051,
580,
13,
1678,
1653,
29918,
2972,
29892,
1653,
29918,
2371,
29892,
1653,
29918,
29883,
29918,
2378,
29892,
18094,
353,
2436,
29918,
7529,
13,
1678,
565,
338,
8758,
29898,
1767,
29892,
9657,
1125,
13,
4706,
1014,
29918,
4632,
353,
1653,
29918,
2972,
29898,
4632,
29892,
1820,
29892,
525,
8977,
1495,
13,
4706,
363,
1820,
29892,
1014,
29918,
1767,
297,
995,
29889,
7076,
7295,
13,
9651,
565,
451,
338,
8758,
29898,
1989,
29892,
1347,
29918,
8768,
1125,
13,
18884,
12020,
20948,
877,
3596,
9657,
6611,
1818,
367,
6031,
1495,
13,
9651,
903,
3626,
482,
29918,
3539,
877,
1989,
648,
29900,
29913,
4286,
4830,
29898,
1989,
511,
1014,
29918,
1767,
29892,
1014,
29918,
4632,
29892,
13,
462,
3986,
334,
3539,
29918,
7529,
29897,
13,
1678,
25342,
338,
8758,
29898,
1767,
29892,
313,
1761,
29892,
18761,
22164,
13,
4706,
3611,
353,
525,
1761,
29915,
565,
338,
8758,
29898,
1767,
29892,
1051,
29897,
1683,
525,
23583,
29915,
13,
4706,
1014,
29918,
4632,
353,
1653,
29918,
2972,
29898,
4632,
29892,
1820,
29892,
3611,
29897,
13,
4706,
363,
3516,
29892,
1014,
29918,
1767,
297,
26985,
29898,
1767,
1125,
13,
9651,
903,
3626,
482,
29918,
3539,
877,
13140,
648,
29900,
29913,
4286,
4830,
29898,
1403,
511,
1014,
29918,
1767,
29892,
1014,
29918,
4632,
29892,
13,
462,
3986,
334,
3539,
29918,
7529,
29897,
13,
1678,
25342,
338,
8758,
29898,
1767,
29892,
1134,
29898,
8516,
22164,
13,
4706,
12301,
353,
260,
29890,
29889,
24693,
4178,
290,
580,
13,
4706,
269,
353,
1653,
29918,
29883,
29918,
2378,
29898,
4632,
29892,
1820,
29892,
12301,
29892,
313,
29896,
29892,
511,
3611,
2433,
8516,
742,
13,
462,
965,
18094,
29922,
26705,
29897,
13,
4706,
269,
7503,
29962,
353,
7700,
13,
1678,
25342,
338,
8758,
29898,
1767,
29892,
313,
524,
29892,
5785,
22164,
13,
4706,
565,
338,
8758,
29898,
1767,
29892,
938,
1125,
13,
9651,
3611,
353,
525,
524,
29915,
13,
4706,
1683,
29901,
29871,
396,
338,
8758,
29898,
1767,
29892,
5785,
1125,
13,
9651,
3611,
353,
525,
7411,
29915,
13,
4706,
995,
353,
7442,
29889,
271,
280,
579,
29918,
29896,
29881,
29898,
1767,
29897,
13,
4706,
12301,
353,
260,
29890,
29889,
4178,
290,
29889,
3166,
29918,
29881,
1853,
29898,
1767,
29889,
29881,
1853,
29897,
13,
4706,
269,
353,
1653,
29918,
29883,
29918,
2378,
29898,
4632,
29892,
1820,
29892,
12301,
29892,
313,
29896,
29892,
511,
13,
462,
965,
3611,
29922,
3257,
29892,
18094,
29922,
26705,
29897,
13,
4706,
269,
7503,
29962,
353,
995,
13,
1678,
25342,
338,
8758,
29898,
1767,
29892,
1347,
29918,
8768,
1125,
13,
4706,
12301,
353,
260,
29890,
29889,
29965,
2928,
29947,
4178,
290,
580,
13,
4706,
565,
338,
8758,
29898,
1767,
29892,
1426,
29918,
1853,
1125,
29871,
396,
29104,
13,
9651,
995,
353,
7442,
29889,
3166,
1807,
29898,
1767,
29889,
12508,
877,
9420,
29899,
29947,
5477,
7442,
29889,
13470,
29947,
29897,
13,
9651,
3611,
353,
525,
2523,
356,
29915,
13,
4706,
1683,
29901,
13,
9651,
995,
353,
7442,
29889,
3166,
1807,
29898,
1767,
29889,
12508,
877,
28599,
2687,
5477,
7442,
29889,
13470,
29947,
29897,
13,
9651,
3611,
353,
525,
294,
18869,
29915,
13,
4706,
269,
353,
1653,
29918,
29883,
29918,
2378,
29898,
4632,
29892,
1820,
29892,
12301,
29892,
313,
2435,
29898,
1767,
511,
511,
3611,
29922,
3257,
29892,
13,
462,
965,
18094,
29922,
26705,
29897,
13,
4706,
269,
7503,
29962,
353,
995,
13,
1678,
25342,
338,
8758,
29898,
1767,
29892,
7442,
29889,
299,
2378,
1125,
13,
4706,
12301,
353,
260,
29890,
29889,
4178,
290,
29889,
3166,
29918,
29881,
1853,
29898,
1767,
29889,
29881,
1853,
29897,
13,
4706,
269,
353,
1653,
29918,
29883,
29918,
2378,
29898,
4632,
29892,
1820,
29892,
12301,
29892,
995,
29889,
12181,
29892,
13,
462,
965,
3611,
2433,
299,
2378,
742,
18094,
29922,
26705,
29897,
13,
4706,
269,
7503,
29962,
353,
995,
13,
1678,
1683,
29901,
13,
4706,
12020,
20948,
877,
348,
23765,
1134,
1273,
29879,
29915,
1273,
1134,
29898,
1767,
876,
13,
13,
13,
13383,
13383,
13383,
13383,
7346,
4136,
2277,
13,
29937,
5195,
3035,
13,
13,
1753,
1303,
29918,
29882,
2176,
29945,
29898,
29888,
978,
1125,
13,
1678,
9995,
6359,
3017,
1203,
515,
379,
4037,
29945,
3402,
773,
349,
3637,
1849,
13,
13,
1678,
12662,
2699,
13,
1678,
448,
1378,
29899,
13,
1678,
285,
978,
584,
851,
13,
4706,
3497,
304,
2254,
29889,
13,
13,
1678,
16969,
13,
1678,
448,
22158,
13,
1678,
848,
584,
1203,
13,
4706,
450,
7500,
848,
29889,
1815,
367,
310,
738,
1134,
6969,
491,
4954,
3539,
29918,
29882,
2176,
29945,
29952,
1412,
13,
1678,
9995,
13,
1678,
260,
29890,
353,
903,
3198,
29918,
2272,
24051,
580,
13,
1678,
565,
451,
1015,
29889,
275,
1445,
29898,
29888,
978,
1125,
13,
4706,
12020,
10663,
2392,
877,
1445,
11860,
29879,
29908,
451,
1476,
29915,
1273,
285,
978,
29897,
13,
1678,
288,
29918,
29888,
353,
260,
29890,
29889,
3150,
29918,
1445,
565,
756,
5552,
29898,
22625,
29892,
525,
3150,
29918,
1445,
1495,
1683,
260,
29890,
29889,
3150,
2283,
13,
1678,
411,
288,
29918,
29888,
29898,
29888,
978,
29892,
4464,
2433,
29878,
1495,
408,
25947,
29901,
13,
4706,
565,
451,
756,
5552,
29898,
29888,
333,
29889,
4632,
29892,
525,
29885,
484,
4691,
29374,
13,
9651,
12020,
20948,
877,
1217,
286,
484,
29899,
4691,
848,
1476,
1495,
13,
4706,
848,
353,
903,
3626,
482,
29918,
949,
29898,
29888,
333,
29889,
4632,
29889,
29885,
484,
4691,
29897,
13,
1678,
736,
848,
13,
13,
13,
1753,
903,
3626,
482,
29918,
949,
29898,
3177,
1125,
13,
1678,
260,
29890,
353,
903,
3198,
29918,
2272,
24051,
580,
13,
1678,
1134,
29918,
710,
353,
2943,
3032,
29894,
29918,
3257,
13,
1678,
565,
338,
8758,
29898,
3177,
29892,
260,
29890,
29889,
4782,
1125,
13,
4706,
565,
1134,
29918,
710,
1275,
525,
8977,
2396,
13,
9651,
848,
353,
9657,
580,
13,
9651,
363,
1014,
3177,
297,
2943,
29901,
13,
18884,
1820,
353,
1014,
3177,
3032,
29894,
29918,
978,
29961,
29946,
17531,
29871,
396,
5700,
1283,
376,
13140,
27508,
470,
376,
1989,
27508,
10944,
13,
18884,
848,
29961,
1989,
29962,
353,
903,
3626,
482,
29918,
949,
29898,
1491,
3177,
29897,
13,
4706,
25342,
1134,
29918,
710,
297,
6024,
1761,
742,
525,
23583,
2033,
29901,
13,
9651,
848,
353,
1051,
580,
13,
9651,
13607,
353,
29871,
29900,
13,
9651,
1550,
5852,
29901,
13,
18884,
1014,
3177,
353,
679,
5552,
29898,
3177,
29892,
525,
13140,
648,
29900,
29913,
4286,
4830,
29898,
2236,
511,
6213,
29897,
13,
18884,
565,
1014,
3177,
338,
6213,
29901,
13,
462,
1678,
2867,
13,
18884,
848,
29889,
4397,
7373,
3626,
482,
29918,
949,
29898,
1491,
3177,
876,
13,
18884,
13607,
4619,
29871,
29896,
13,
9651,
4974,
7431,
29898,
1272,
29897,
1275,
13607,
13,
9651,
848,
353,
18761,
29898,
1272,
29897,
565,
1134,
29918,
710,
1275,
525,
23583,
29915,
1683,
848,
13,
9651,
736,
848,
13,
4706,
1683,
29901,
13,
9651,
12020,
2216,
1888,
2037,
287,
2392,
877,
14148,
2318,
1134,
29901,
426,
29900,
10162,
13,
462,
462,
418,
525,
4286,
4830,
29898,
1853,
29918,
710,
876,
13,
1678,
25342,
1134,
29918,
710,
1275,
525,
299,
2378,
2396,
13,
4706,
848,
353,
7442,
29889,
2378,
29898,
3177,
29897,
13,
1678,
25342,
1134,
29918,
710,
297,
6702,
524,
742,
525,
7411,
29374,
13,
4706,
565,
1134,
29918,
710,
1275,
525,
524,
2396,
13,
9651,
4320,
353,
938,
13,
4706,
1683,
29901,
29871,
396,
1134,
29918,
710,
1275,
525,
7411,
2396,
13,
9651,
4320,
353,
5785,
13,
4706,
848,
353,
4320,
29898,
9302,
29889,
2378,
29898,
3177,
9601,
29900,
2314,
13,
1678,
25342,
1134,
29918,
710,
297,
6702,
2523,
356,
742,
525,
294,
18869,
29374,
13,
4706,
1602,
6119,
353,
525,
9420,
29899,
29947,
29915,
565,
1134,
29918,
710,
1275,
525,
2523,
356,
29915,
1683,
525,
28599,
2687,
29915,
13,
4706,
4320,
353,
1426,
29918,
1853,
565,
1134,
29918,
710,
1275,
525,
2523,
356,
29915,
1683,
851,
13,
4706,
848,
353,
4320,
29898,
9302,
29889,
2378,
29898,
3177,
467,
517,
1807,
2141,
13808,
29898,
7099,
6119,
876,
13,
1678,
25342,
1134,
29918,
710,
1275,
525,
8516,
2396,
13,
4706,
848,
353,
6213,
13,
1678,
1683,
29901,
13,
4706,
12020,
20948,
877,
14148,
2943,
1134,
29901,
426,
29900,
29913,
4286,
4830,
29898,
1853,
29918,
710,
876,
13,
1678,
736,
848,
13,
2
] |
utils/config.py | a1401358759/my_site | 50 | 118511 | import os
# 数据库配置
MYSQL_HOST = os.getenv('MYSQL_HOST', 'localhost')
MYSQL_PORT = os.getenv('MYSQL_PORT', '3306')
MYSQL_DATABASE = os.getenv('MYSQL_DATABASE', 'my-site')
MYSQL_USER = os.getenv('MYSQL_USER', 'admin')
MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD', '<PASSWORD>')
# redis配置
REDIS_HOST = os.getenv('REDIS_HOST', '127.0.0.1')
REDIS_PORT = os.getenv('REDIS_PORT', '6379')
| [
1,
1053,
2897,
13,
13,
13,
29937,
29871,
30354,
30763,
31700,
31361,
30669,
13,
17870,
4176,
29918,
20832,
353,
2897,
29889,
657,
6272,
877,
17870,
4176,
29918,
20832,
742,
525,
7640,
1495,
13,
17870,
4176,
29918,
15082,
353,
2897,
29889,
657,
6272,
877,
17870,
4176,
29918,
15082,
742,
525,
29941,
29941,
29900,
29953,
1495,
13,
17870,
4176,
29918,
25832,
27982,
353,
2897,
29889,
657,
6272,
877,
17870,
4176,
29918,
25832,
27982,
742,
525,
1357,
29899,
2746,
1495,
13,
17870,
4176,
29918,
11889,
353,
2897,
29889,
657,
6272,
877,
17870,
4176,
29918,
11889,
742,
525,
6406,
1495,
13,
17870,
4176,
29918,
25711,
17013,
353,
2897,
29889,
657,
6272,
877,
17870,
4176,
29918,
25711,
17013,
742,
12801,
25711,
17013,
29958,
1495,
13,
13,
29937,
29825,
31361,
30669,
13,
19386,
3235,
29918,
20832,
353,
2897,
29889,
657,
6272,
877,
19386,
3235,
29918,
20832,
742,
525,
29896,
29906,
29955,
29889,
29900,
29889,
29900,
29889,
29896,
1495,
13,
19386,
3235,
29918,
15082,
353,
2897,
29889,
657,
6272,
877,
19386,
3235,
29918,
15082,
742,
525,
29953,
29941,
29955,
29929,
1495,
13,
2
] |
manager/director/apps/sites/migrations/0009_auto_20191220_0901.py | darius-kia/director4 | 7 | 111135 | # Generated by Django 2.2.8 on 2019-12-20 14:01
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sites', '0008_auto_20191213_0733'),
]
operations = [
migrations.AlterField(
model_name='site',
name='port',
field=models.IntegerField(unique=True, validators=[django.core.validators.MinValueValidator(10001), django.core.validators.MaxValueValidator(65535)]),
),
]
| [
1,
396,
3251,
630,
491,
15337,
29871,
29906,
29889,
29906,
29889,
29947,
373,
29871,
29906,
29900,
29896,
29929,
29899,
29896,
29906,
29899,
29906,
29900,
29871,
29896,
29946,
29901,
29900,
29896,
13,
13,
5215,
9557,
29889,
3221,
29889,
3084,
4097,
13,
3166,
9557,
29889,
2585,
1053,
9725,
800,
29892,
4733,
13,
13,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
13,
13,
1678,
9962,
353,
518,
13,
4706,
6702,
16315,
742,
525,
29900,
29900,
29900,
29947,
29918,
6921,
29918,
29906,
29900,
29896,
29929,
29896,
29906,
29896,
29941,
29918,
29900,
29955,
29941,
29941,
5477,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
2499,
357,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
2746,
742,
13,
9651,
1024,
2433,
637,
742,
13,
9651,
1746,
29922,
9794,
29889,
7798,
3073,
29898,
13092,
29922,
5574,
29892,
2854,
4097,
11759,
14095,
29889,
3221,
29889,
3084,
4097,
29889,
8140,
1917,
24204,
29898,
29896,
29900,
29900,
29900,
29896,
511,
9557,
29889,
3221,
29889,
3084,
4097,
29889,
7976,
1917,
24204,
29898,
29953,
29945,
29945,
29941,
29945,
4638,
511,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
test/unit_test/controller/test_callback.py | ArnovanHilten/NVFlare | 155 | 140412 | # Copyright (c) 2021-2022, NVIDIA 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 threading
import time
import pytest
from nvflare.apis.controller_spec import ClientTask, Task, TaskCompletionStatus
from nvflare.apis.fl_context import FLContext
from nvflare.apis.shareable import Shareable
from .controller_test import TestController, create_client, create_task, get_ready, launch_task
def _get_task_done_callback_test_cases():
task_name = "__test_task"
def task_done_cb(task: Task, fl_ctx: FLContext):
client_names = [x.client.name for x in task.client_tasks]
expected_str = "_".join(client_names)
task.props[task_name] = expected_str
input_data = Shareable()
test_cases = [
[
"broadcast",
[create_client(f"__test_client{i}") for i in range(10)],
task_name,
input_data,
task_done_cb,
"_".join([f"__test_client{i}" for i in range(10)]),
],
[
"broadcast_and_wait",
[create_client(f"__test_client{i}") for i in range(10)],
task_name,
input_data,
task_done_cb,
"_".join([f"__test_client{i}" for i in range(10)]),
],
["send", [create_client("__test_client")], task_name, input_data, task_done_cb, "__test_client"],
["send_and_wait", [create_client("__test_client")], task_name, input_data, task_done_cb, "__test_client"],
["relay", [create_client("__test_client")], task_name, input_data, task_done_cb, "__test_client"],
["relay_and_wait", [create_client("__test_client")], task_name, input_data, task_done_cb, "__test_client"],
]
return test_cases
class TestCallback(TestController):
@pytest.mark.parametrize("method", TestController.ALL_APIS)
def test_before_task_sent_cb(self, method):
def before_task_sent_cb(client_task: ClientTask, fl_ctx: FLContext):
client_task.task.data["_test_data"] = client_task.client.name
client_name = "_test_client"
controller, fl_ctx = self.start_controller()
client = create_client(name=client_name)
task = create_task("__test_task", before_task_sent_cb=before_task_sent_cb)
launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": task,
"method": method,
"fl_ctx": fl_ctx,
"kwargs": {"targets": [client]},
},
)
get_ready(launch_thread)
task_name_out, _, data = controller.process_task_request(client, fl_ctx)
expected = Shareable()
expected["_test_data"] = client_name
assert data == expected
controller.cancel_task(task)
assert task.completion_status == TaskCompletionStatus.CANCELLED
launch_thread.join()
self.stop_controller(controller, fl_ctx)
@pytest.mark.parametrize("method", TestController.ALL_APIS)
def test_result_received_cb(self, method):
def result_received_cb(client_task: ClientTask, fl_ctx: FLContext):
client_task.result["_test_data"] = client_task.client.name
client_name = "_test_client"
input_data = Shareable()
input_data["_test_data"] = "_old_data"
controller, fl_ctx = self.start_controller()
client = create_client(name=client_name)
task = create_task("__test_task", data=input_data, result_received_cb=result_received_cb)
kwargs = {"targets": [client]}
launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": task,
"method": method,
"fl_ctx": fl_ctx,
"kwargs": kwargs,
},
)
get_ready(launch_thread)
task_name_out, client_task_id, data = controller.process_task_request(client, fl_ctx)
controller.process_submission(
client=client, task_name="__test_task", task_id=client_task_id, fl_ctx=fl_ctx, result=data
)
expected = Shareable()
expected["_test_data"] = client_name
assert task.last_client_task_map[client_name].result == expected
controller._check_tasks()
assert task.completion_status == TaskCompletionStatus.OK
launch_thread.join()
self.stop_controller(controller, fl_ctx)
@pytest.mark.parametrize("task_complete", ["normal", "timeout", "cancel"])
@pytest.mark.parametrize("method,clients,task_name,input_data,cb,expected", _get_task_done_callback_test_cases())
def test_task_done_cb(self, method, clients, task_name, input_data, cb, expected, task_complete):
controller, fl_ctx = self.start_controller()
timeout = 0 if task_complete != "timeout" else 1
task = create_task("__test_task", data=input_data, task_done_cb=cb, timeout=timeout)
kwargs = {"targets": clients}
launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": task,
"method": method,
"fl_ctx": fl_ctx,
"kwargs": kwargs,
},
)
get_ready(launch_thread)
client_task_ids = len(clients) * [None]
for i, client in enumerate(clients):
task_name_out, client_task_ids[i], _ = controller.process_task_request(client, fl_ctx)
if task_name_out == "":
client_task_ids[i] = None
# in here we make up client results:
result = Shareable()
result["result"] = "result"
for client, client_task_id in zip(clients, client_task_ids):
if client_task_id is not None:
if task_complete == "normal":
controller.process_submission(
client=client, task_name="__test_task", task_id=client_task_id, fl_ctx=fl_ctx, result=result
)
if task_complete == "timeout":
time.sleep(timeout)
assert task.completion_status == TaskCompletionStatus.TIMEOUT
elif task_complete == "cancel":
controller.cancel_task(task)
assert task.completion_status == TaskCompletionStatus.CANCELLED
controller._check_tasks()
assert task.props[task_name] == expected
assert controller.get_num_standing_tasks() == 0
launch_thread.join()
self.stop_controller(controller, fl_ctx)
@pytest.mark.parametrize("method", TestController.ALL_APIS)
def test_cancel_task_before_send_cb(self, method):
def before_task_sent_cb(client_task: ClientTask, fl_ctx: FLContext):
client_task.task.completion_status = TaskCompletionStatus.CANCELLED
controller, fl_ctx = self.start_controller()
client = create_client(name="__test_client")
task = create_task("__test_task", before_task_sent_cb=before_task_sent_cb)
launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": task,
"method": method,
"fl_ctx": fl_ctx,
"kwargs": {"targets": [client]},
},
)
get_ready(launch_thread)
task_name_out, client_task_id, data = controller.process_task_request(client, fl_ctx)
assert task_name_out == ""
assert client_task_id == ""
launch_thread.join()
assert task.completion_status == TaskCompletionStatus.CANCELLED
self.stop_controller(controller, fl_ctx)
@pytest.mark.parametrize("method", TestController.ALL_APIS)
def test_cancel_task_result_received_cb(self, method):
def result_received_cb(client_task: ClientTask, fl_ctx: FLContext):
client_task.task.completion_status = TaskCompletionStatus.CANCELLED
controller, fl_ctx = self.start_controller()
client1 = create_client(name="__test_client")
client2 = create_client(name="__another_client")
task = create_task("__test_task", result_received_cb=result_received_cb)
launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": task,
"method": method,
"fl_ctx": fl_ctx,
"kwargs": {"targets": [client1, client2]},
},
)
get_ready(launch_thread)
task_name_out, client_task_id, data = controller.process_task_request(client1, fl_ctx)
result = Shareable()
result["__result"] = "__test_result"
controller.process_submission(
client=client1, task_name="__test_task", task_id=client_task_id, fl_ctx=fl_ctx, result=result
)
assert task.last_client_task_map["__test_client"].result == result
task_name_out, client_task_id, data = controller.process_task_request(client2, fl_ctx)
assert task_name_out == ""
assert client_task_id == ""
launch_thread.join()
assert task.completion_status == TaskCompletionStatus.CANCELLED
self.stop_controller(controller, fl_ctx)
@pytest.mark.parametrize("method", TestController.ALL_APIS)
@pytest.mark.parametrize("method2", ["broadcast", "send", "relay"])
def test_schedule_task_before_send_cb(self, method, method2):
def before_task_sent_cb(client_task: ClientTask, fl_ctx: FLContext):
controller = fl_ctx.get_prop(key="controller")
new_task = create_task("__new_test_task")
inner_launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": new_task,
"method": method2,
"fl_ctx": fl_ctx,
"kwargs": {"targets": [client_task.client]},
},
)
inner_launch_thread.start()
inner_launch_thread.join()
controller, fl_ctx = self.start_controller()
fl_ctx.set_prop("controller", controller)
client = create_client(name="__test_client")
task = create_task("__test_task", before_task_sent_cb=before_task_sent_cb)
launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": task,
"method": method,
"fl_ctx": fl_ctx,
"kwargs": {"targets": [client]},
},
)
launch_thread.start()
task_name_out = ""
while task_name_out == "":
task_name_out, _, _ = controller.process_task_request(client, fl_ctx)
time.sleep(0.1)
assert task_name_out == "__test_task"
new_task_name_out = ""
while new_task_name_out == "":
new_task_name_out, _, _ = controller.process_task_request(client, fl_ctx)
time.sleep(0.1)
assert new_task_name_out == "__new_test_task"
controller.cancel_task(task)
assert task.completion_status == TaskCompletionStatus.CANCELLED
launch_thread.join()
self.stop_controller(controller, fl_ctx)
@pytest.mark.parametrize("method", TestController.ALL_APIS)
@pytest.mark.parametrize("method2", ["broadcast", "send", "relay"])
def test_schedule_task_result_received_cb(self, method, method2):
def result_received_cb(client_task: ClientTask, fl_ctx: FLContext):
controller = fl_ctx.get_prop(key="controller")
new_task = create_task("__new_test_task")
inner_launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": new_task,
"method": method2,
"fl_ctx": fl_ctx,
"kwargs": {"targets": [client_task.client]},
},
)
get_ready(inner_launch_thread)
inner_launch_thread.join()
controller, fl_ctx = self.start_controller()
fl_ctx.set_prop("controller", controller)
client = create_client(name="__test_client")
task = create_task("__test_task", result_received_cb=result_received_cb)
launch_thread = threading.Thread(
target=launch_task,
kwargs={
"controller": controller,
"task": task,
"method": method,
"fl_ctx": fl_ctx,
"kwargs": {"targets": [client]},
},
)
launch_thread.start()
task_name_out = ""
client_task_id = ""
data = None
while task_name_out == "":
task_name_out, client_task_id, data = controller.process_task_request(client, fl_ctx)
time.sleep(0.1)
assert task_name_out == "__test_task"
controller.process_submission(
client=client, task_name="__test_task", task_id=client_task_id, fl_ctx=fl_ctx, result=data
)
controller._check_tasks()
assert controller.get_num_standing_tasks() == 1
new_task_name_out = ""
while new_task_name_out == "":
new_task_name_out, _, _ = controller.process_task_request(client, fl_ctx)
time.sleep(0.1)
assert new_task_name_out == "__new_test_task"
launch_thread.join()
self.stop_controller(controller, fl_ctx)
| [
1,
396,
14187,
1266,
313,
29883,
29897,
29871,
29906,
29900,
29906,
29896,
29899,
29906,
29900,
29906,
29906,
29892,
405,
13044,
10764,
315,
1955,
29925,
1955,
8098,
29889,
29871,
2178,
10462,
21676,
29889,
13,
29937,
13,
29937,
10413,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
29937,
366,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
29937,
887,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
268,
1732,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
29937,
13,
29937,
25870,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
29937,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29937,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
13,
29937,
2823,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
29937,
27028,
1090,
278,
19245,
29889,
13,
13,
5215,
3244,
292,
13,
5215,
931,
13,
13,
5215,
11451,
1688,
13,
13,
3166,
302,
29894,
29888,
8663,
29889,
11355,
29889,
8299,
29918,
6550,
1053,
12477,
5398,
29892,
9330,
29892,
9330,
28958,
5709,
13,
3166,
302,
29894,
29888,
8663,
29889,
11355,
29889,
1579,
29918,
4703,
1053,
383,
29931,
2677,
13,
3166,
302,
29894,
29888,
8663,
29889,
11355,
29889,
13653,
519,
1053,
26849,
519,
13,
13,
3166,
869,
8299,
29918,
1688,
1053,
4321,
2956,
29892,
1653,
29918,
4645,
29892,
1653,
29918,
7662,
29892,
679,
29918,
2040,
29892,
6826,
29918,
7662,
13,
13,
13,
1753,
903,
657,
29918,
7662,
29918,
15091,
29918,
14035,
29918,
1688,
29918,
11436,
7295,
13,
1678,
3414,
29918,
978,
353,
376,
1649,
1688,
29918,
7662,
29908,
13,
13,
1678,
822,
3414,
29918,
15091,
29918,
10702,
29898,
7662,
29901,
9330,
29892,
1652,
29918,
13073,
29901,
383,
29931,
2677,
1125,
13,
4706,
3132,
29918,
7039,
353,
518,
29916,
29889,
4645,
29889,
978,
363,
921,
297,
3414,
29889,
4645,
29918,
20673,
29962,
13,
4706,
3806,
29918,
710,
353,
11119,
1642,
7122,
29898,
4645,
29918,
7039,
29897,
13,
4706,
3414,
29889,
11030,
29961,
7662,
29918,
978,
29962,
353,
3806,
29918,
710,
13,
13,
1678,
1881,
29918,
1272,
353,
26849,
519,
580,
13,
1678,
1243,
29918,
11436,
353,
518,
13,
4706,
518,
13,
9651,
376,
6729,
328,
4384,
613,
13,
9651,
518,
3258,
29918,
4645,
29898,
29888,
29908,
1649,
1688,
29918,
4645,
29912,
29875,
27195,
363,
474,
297,
3464,
29898,
29896,
29900,
29897,
1402,
13,
9651,
3414,
29918,
978,
29892,
13,
9651,
1881,
29918,
1272,
29892,
13,
9651,
3414,
29918,
15091,
29918,
10702,
29892,
13,
9651,
11119,
1642,
7122,
4197,
29888,
29908,
1649,
1688,
29918,
4645,
29912,
29875,
5038,
363,
474,
297,
3464,
29898,
29896,
29900,
4638,
511,
13,
4706,
21251,
13,
4706,
518,
13,
9651,
376,
6729,
328,
4384,
29918,
392,
29918,
10685,
613,
13,
9651,
518,
3258,
29918,
4645,
29898,
29888,
29908,
1649,
1688,
29918,
4645,
29912,
29875,
27195,
363,
474,
297,
3464,
29898,
29896,
29900,
29897,
1402,
13,
9651,
3414,
29918,
978,
29892,
13,
9651,
1881,
29918,
1272,
29892,
13,
9651,
3414,
29918,
15091,
29918,
10702,
29892,
13,
9651,
11119,
1642,
7122,
4197,
29888,
29908,
1649,
1688,
29918,
4645,
29912,
29875,
5038,
363,
474,
297,
3464,
29898,
29896,
29900,
4638,
511,
13,
4706,
21251,
13,
4706,
6796,
6717,
613,
518,
3258,
29918,
4645,
703,
1649,
1688,
29918,
4645,
1159,
1402,
3414,
29918,
978,
29892,
1881,
29918,
1272,
29892,
3414,
29918,
15091,
29918,
10702,
29892,
376,
1649,
1688,
29918,
4645,
12436,
13,
4706,
6796,
6717,
29918,
392,
29918,
10685,
613,
518,
3258,
29918,
4645,
703,
1649,
1688,
29918,
4645,
1159,
1402,
3414,
29918,
978,
29892,
1881,
29918,
1272,
29892,
3414,
29918,
15091,
29918,
10702,
29892,
376,
1649,
1688,
29918,
4645,
12436,
13,
4706,
6796,
2674,
388,
613,
518,
3258,
29918,
4645,
703,
1649,
1688,
29918,
4645,
1159,
1402,
3414,
29918,
978,
29892,
1881,
29918,
1272,
29892,
3414,
29918,
15091,
29918,
10702,
29892,
376,
1649,
1688,
29918,
4645,
12436,
13,
4706,
6796,
2674,
388,
29918,
392,
29918,
10685,
613,
518,
3258,
29918,
4645,
703,
1649,
1688,
29918,
4645,
1159,
1402,
3414,
29918,
978,
29892,
1881,
29918,
1272,
29892,
3414,
29918,
15091,
29918,
10702,
29892,
376,
1649,
1688,
29918,
4645,
12436,
13,
1678,
4514,
13,
1678,
736,
1243,
29918,
11436,
13,
13,
13,
1990,
4321,
10717,
29898,
3057,
2956,
1125,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
613,
4321,
2956,
29889,
9818,
29918,
8787,
29903,
29897,
13,
1678,
822,
1243,
29918,
11083,
29918,
7662,
29918,
18616,
29918,
10702,
29898,
1311,
29892,
1158,
1125,
13,
4706,
822,
1434,
29918,
7662,
29918,
18616,
29918,
10702,
29898,
4645,
29918,
7662,
29901,
12477,
5398,
29892,
1652,
29918,
13073,
29901,
383,
29931,
2677,
1125,
13,
9651,
3132,
29918,
7662,
29889,
7662,
29889,
1272,
3366,
29918,
1688,
29918,
1272,
3108,
353,
3132,
29918,
7662,
29889,
4645,
29889,
978,
13,
13,
4706,
3132,
29918,
978,
353,
11119,
1688,
29918,
4645,
29908,
13,
4706,
4701,
29892,
1652,
29918,
13073,
353,
1583,
29889,
2962,
29918,
8299,
580,
13,
4706,
3132,
353,
1653,
29918,
4645,
29898,
978,
29922,
4645,
29918,
978,
29897,
13,
4706,
3414,
353,
1653,
29918,
7662,
703,
1649,
1688,
29918,
7662,
613,
1434,
29918,
7662,
29918,
18616,
29918,
10702,
29922,
11083,
29918,
7662,
29918,
18616,
29918,
10702,
29897,
13,
4706,
6826,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
9651,
3646,
29922,
15343,
29918,
7662,
29892,
13,
9651,
9049,
5085,
3790,
13,
18884,
376,
8299,
1115,
4701,
29892,
13,
18884,
376,
7662,
1115,
3414,
29892,
13,
18884,
376,
5696,
1115,
1158,
29892,
13,
18884,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
18884,
376,
19290,
1115,
8853,
5182,
29879,
1115,
518,
4645,
29962,
1118,
13,
9651,
2981,
13,
4706,
1723,
13,
4706,
679,
29918,
2040,
29898,
15343,
29918,
7097,
29897,
13,
13,
4706,
3414,
29918,
978,
29918,
449,
29892,
17117,
848,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29892,
1652,
29918,
13073,
29897,
13,
13,
4706,
3806,
353,
26849,
519,
580,
13,
4706,
3806,
3366,
29918,
1688,
29918,
1272,
3108,
353,
3132,
29918,
978,
13,
4706,
4974,
848,
1275,
3806,
13,
4706,
4701,
29889,
20713,
29918,
7662,
29898,
7662,
29897,
13,
4706,
4974,
3414,
29889,
5729,
12757,
29918,
4882,
1275,
9330,
28958,
5709,
29889,
29907,
23219,
29931,
20566,
13,
4706,
6826,
29918,
7097,
29889,
7122,
580,
13,
4706,
1583,
29889,
9847,
29918,
8299,
29898,
8299,
29892,
1652,
29918,
13073,
29897,
13,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
613,
4321,
2956,
29889,
9818,
29918,
8787,
29903,
29897,
13,
1678,
822,
1243,
29918,
2914,
29918,
13556,
2347,
29918,
10702,
29898,
1311,
29892,
1158,
1125,
13,
4706,
822,
1121,
29918,
13556,
2347,
29918,
10702,
29898,
4645,
29918,
7662,
29901,
12477,
5398,
29892,
1652,
29918,
13073,
29901,
383,
29931,
2677,
1125,
13,
9651,
3132,
29918,
7662,
29889,
2914,
3366,
29918,
1688,
29918,
1272,
3108,
353,
3132,
29918,
7662,
29889,
4645,
29889,
978,
13,
13,
4706,
3132,
29918,
978,
353,
11119,
1688,
29918,
4645,
29908,
13,
4706,
1881,
29918,
1272,
353,
26849,
519,
580,
13,
4706,
1881,
29918,
1272,
3366,
29918,
1688,
29918,
1272,
3108,
353,
11119,
1025,
29918,
1272,
29908,
13,
4706,
4701,
29892,
1652,
29918,
13073,
353,
1583,
29889,
2962,
29918,
8299,
580,
13,
4706,
3132,
353,
1653,
29918,
4645,
29898,
978,
29922,
4645,
29918,
978,
29897,
13,
4706,
3414,
353,
1653,
29918,
7662,
703,
1649,
1688,
29918,
7662,
613,
848,
29922,
2080,
29918,
1272,
29892,
1121,
29918,
13556,
2347,
29918,
10702,
29922,
2914,
29918,
13556,
2347,
29918,
10702,
29897,
13,
4706,
9049,
5085,
353,
8853,
5182,
29879,
1115,
518,
4645,
12258,
13,
4706,
6826,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
9651,
3646,
29922,
15343,
29918,
7662,
29892,
13,
9651,
9049,
5085,
3790,
13,
18884,
376,
8299,
1115,
4701,
29892,
13,
18884,
376,
7662,
1115,
3414,
29892,
13,
18884,
376,
5696,
1115,
1158,
29892,
13,
18884,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
18884,
376,
19290,
1115,
9049,
5085,
29892,
13,
9651,
2981,
13,
4706,
1723,
13,
4706,
679,
29918,
2040,
29898,
15343,
29918,
7097,
29897,
13,
4706,
3414,
29918,
978,
29918,
449,
29892,
3132,
29918,
7662,
29918,
333,
29892,
848,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29892,
1652,
29918,
13073,
29897,
13,
4706,
4701,
29889,
5014,
29918,
1491,
6737,
29898,
13,
9651,
3132,
29922,
4645,
29892,
3414,
29918,
978,
543,
1649,
1688,
29918,
7662,
613,
3414,
29918,
333,
29922,
4645,
29918,
7662,
29918,
333,
29892,
1652,
29918,
13073,
29922,
1579,
29918,
13073,
29892,
1121,
29922,
1272,
13,
4706,
1723,
13,
13,
4706,
3806,
353,
26849,
519,
580,
13,
4706,
3806,
3366,
29918,
1688,
29918,
1272,
3108,
353,
3132,
29918,
978,
13,
4706,
4974,
3414,
29889,
4230,
29918,
4645,
29918,
7662,
29918,
1958,
29961,
4645,
29918,
978,
1822,
2914,
1275,
3806,
13,
4706,
4701,
3032,
3198,
29918,
20673,
580,
13,
4706,
4974,
3414,
29889,
5729,
12757,
29918,
4882,
1275,
9330,
28958,
5709,
29889,
8949,
13,
4706,
6826,
29918,
7097,
29889,
7122,
580,
13,
4706,
1583,
29889,
9847,
29918,
8299,
29898,
8299,
29892,
1652,
29918,
13073,
29897,
13,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
7662,
29918,
8835,
613,
6796,
8945,
613,
376,
15619,
613,
376,
20713,
20068,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
29892,
11303,
1237,
29892,
7662,
29918,
978,
29892,
2080,
29918,
1272,
29892,
10702,
29892,
9684,
613,
903,
657,
29918,
7662,
29918,
15091,
29918,
14035,
29918,
1688,
29918,
11436,
3101,
13,
1678,
822,
1243,
29918,
7662,
29918,
15091,
29918,
10702,
29898,
1311,
29892,
1158,
29892,
13154,
29892,
3414,
29918,
978,
29892,
1881,
29918,
1272,
29892,
26324,
29892,
3806,
29892,
3414,
29918,
8835,
1125,
13,
4706,
4701,
29892,
1652,
29918,
13073,
353,
1583,
29889,
2962,
29918,
8299,
580,
13,
13,
4706,
11815,
353,
29871,
29900,
565,
3414,
29918,
8835,
2804,
376,
15619,
29908,
1683,
29871,
29896,
13,
4706,
3414,
353,
1653,
29918,
7662,
703,
1649,
1688,
29918,
7662,
613,
848,
29922,
2080,
29918,
1272,
29892,
3414,
29918,
15091,
29918,
10702,
29922,
10702,
29892,
11815,
29922,
15619,
29897,
13,
4706,
9049,
5085,
353,
8853,
5182,
29879,
1115,
13154,
29913,
13,
4706,
6826,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
9651,
3646,
29922,
15343,
29918,
7662,
29892,
13,
9651,
9049,
5085,
3790,
13,
18884,
376,
8299,
1115,
4701,
29892,
13,
18884,
376,
7662,
1115,
3414,
29892,
13,
18884,
376,
5696,
1115,
1158,
29892,
13,
18884,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
18884,
376,
19290,
1115,
9049,
5085,
29892,
13,
9651,
2981,
13,
4706,
1723,
13,
4706,
679,
29918,
2040,
29898,
15343,
29918,
7097,
29897,
13,
13,
4706,
3132,
29918,
7662,
29918,
4841,
353,
7431,
29898,
11303,
1237,
29897,
334,
518,
8516,
29962,
13,
4706,
363,
474,
29892,
3132,
297,
26985,
29898,
11303,
1237,
1125,
13,
9651,
3414,
29918,
978,
29918,
449,
29892,
3132,
29918,
7662,
29918,
4841,
29961,
29875,
1402,
903,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29892,
1652,
29918,
13073,
29897,
13,
13,
9651,
565,
3414,
29918,
978,
29918,
449,
1275,
376,
1115,
13,
18884,
3132,
29918,
7662,
29918,
4841,
29961,
29875,
29962,
353,
6213,
13,
13,
4706,
396,
297,
1244,
591,
1207,
701,
3132,
2582,
29901,
13,
4706,
1121,
353,
26849,
519,
580,
13,
4706,
1121,
3366,
2914,
3108,
353,
376,
2914,
29908,
13,
13,
4706,
363,
3132,
29892,
3132,
29918,
7662,
29918,
333,
297,
14319,
29898,
11303,
1237,
29892,
3132,
29918,
7662,
29918,
4841,
1125,
13,
9651,
565,
3132,
29918,
7662,
29918,
333,
338,
451,
6213,
29901,
13,
18884,
565,
3414,
29918,
8835,
1275,
376,
8945,
1115,
13,
462,
1678,
4701,
29889,
5014,
29918,
1491,
6737,
29898,
13,
462,
4706,
3132,
29922,
4645,
29892,
3414,
29918,
978,
543,
1649,
1688,
29918,
7662,
613,
3414,
29918,
333,
29922,
4645,
29918,
7662,
29918,
333,
29892,
1652,
29918,
13073,
29922,
1579,
29918,
13073,
29892,
1121,
29922,
2914,
13,
462,
1678,
1723,
13,
4706,
565,
3414,
29918,
8835,
1275,
376,
15619,
1115,
13,
9651,
931,
29889,
17059,
29898,
15619,
29897,
13,
9651,
4974,
3414,
29889,
5729,
12757,
29918,
4882,
1275,
9330,
28958,
5709,
29889,
15307,
12015,
13,
4706,
25342,
3414,
29918,
8835,
1275,
376,
20713,
1115,
13,
9651,
4701,
29889,
20713,
29918,
7662,
29898,
7662,
29897,
13,
9651,
4974,
3414,
29889,
5729,
12757,
29918,
4882,
1275,
9330,
28958,
5709,
29889,
29907,
23219,
29931,
20566,
13,
4706,
4701,
3032,
3198,
29918,
20673,
580,
13,
4706,
4974,
3414,
29889,
11030,
29961,
7662,
29918,
978,
29962,
1275,
3806,
13,
4706,
4974,
4701,
29889,
657,
29918,
1949,
29918,
11235,
29918,
20673,
580,
1275,
29871,
29900,
13,
4706,
6826,
29918,
7097,
29889,
7122,
580,
13,
4706,
1583,
29889,
9847,
29918,
8299,
29898,
8299,
29892,
1652,
29918,
13073,
29897,
13,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
613,
4321,
2956,
29889,
9818,
29918,
8787,
29903,
29897,
13,
1678,
822,
1243,
29918,
20713,
29918,
7662,
29918,
11083,
29918,
6717,
29918,
10702,
29898,
1311,
29892,
1158,
1125,
13,
4706,
822,
1434,
29918,
7662,
29918,
18616,
29918,
10702,
29898,
4645,
29918,
7662,
29901,
12477,
5398,
29892,
1652,
29918,
13073,
29901,
383,
29931,
2677,
1125,
13,
9651,
3132,
29918,
7662,
29889,
7662,
29889,
5729,
12757,
29918,
4882,
353,
9330,
28958,
5709,
29889,
29907,
23219,
29931,
20566,
13,
13,
4706,
4701,
29892,
1652,
29918,
13073,
353,
1583,
29889,
2962,
29918,
8299,
580,
13,
4706,
3132,
353,
1653,
29918,
4645,
29898,
978,
543,
1649,
1688,
29918,
4645,
1159,
13,
4706,
3414,
353,
1653,
29918,
7662,
703,
1649,
1688,
29918,
7662,
613,
1434,
29918,
7662,
29918,
18616,
29918,
10702,
29922,
11083,
29918,
7662,
29918,
18616,
29918,
10702,
29897,
13,
4706,
6826,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
9651,
3646,
29922,
15343,
29918,
7662,
29892,
13,
9651,
9049,
5085,
3790,
13,
18884,
376,
8299,
1115,
4701,
29892,
13,
18884,
376,
7662,
1115,
3414,
29892,
13,
18884,
376,
5696,
1115,
1158,
29892,
13,
18884,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
18884,
376,
19290,
1115,
8853,
5182,
29879,
1115,
518,
4645,
29962,
1118,
13,
9651,
2981,
13,
4706,
1723,
13,
4706,
679,
29918,
2040,
29898,
15343,
29918,
7097,
29897,
13,
13,
4706,
3414,
29918,
978,
29918,
449,
29892,
3132,
29918,
7662,
29918,
333,
29892,
848,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29892,
1652,
29918,
13073,
29897,
13,
4706,
4974,
3414,
29918,
978,
29918,
449,
1275,
5124,
13,
4706,
4974,
3132,
29918,
7662,
29918,
333,
1275,
5124,
13,
13,
4706,
6826,
29918,
7097,
29889,
7122,
580,
13,
4706,
4974,
3414,
29889,
5729,
12757,
29918,
4882,
1275,
9330,
28958,
5709,
29889,
29907,
23219,
29931,
20566,
13,
4706,
1583,
29889,
9847,
29918,
8299,
29898,
8299,
29892,
1652,
29918,
13073,
29897,
13,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
613,
4321,
2956,
29889,
9818,
29918,
8787,
29903,
29897,
13,
1678,
822,
1243,
29918,
20713,
29918,
7662,
29918,
2914,
29918,
13556,
2347,
29918,
10702,
29898,
1311,
29892,
1158,
1125,
13,
4706,
822,
1121,
29918,
13556,
2347,
29918,
10702,
29898,
4645,
29918,
7662,
29901,
12477,
5398,
29892,
1652,
29918,
13073,
29901,
383,
29931,
2677,
1125,
13,
9651,
3132,
29918,
7662,
29889,
7662,
29889,
5729,
12757,
29918,
4882,
353,
9330,
28958,
5709,
29889,
29907,
23219,
29931,
20566,
13,
13,
4706,
4701,
29892,
1652,
29918,
13073,
353,
1583,
29889,
2962,
29918,
8299,
580,
13,
4706,
3132,
29896,
353,
1653,
29918,
4645,
29898,
978,
543,
1649,
1688,
29918,
4645,
1159,
13,
4706,
3132,
29906,
353,
1653,
29918,
4645,
29898,
978,
543,
1649,
23327,
29918,
4645,
1159,
13,
4706,
3414,
353,
1653,
29918,
7662,
703,
1649,
1688,
29918,
7662,
613,
1121,
29918,
13556,
2347,
29918,
10702,
29922,
2914,
29918,
13556,
2347,
29918,
10702,
29897,
13,
4706,
6826,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
9651,
3646,
29922,
15343,
29918,
7662,
29892,
13,
9651,
9049,
5085,
3790,
13,
18884,
376,
8299,
1115,
4701,
29892,
13,
18884,
376,
7662,
1115,
3414,
29892,
13,
18884,
376,
5696,
1115,
1158,
29892,
13,
18884,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
18884,
376,
19290,
1115,
8853,
5182,
29879,
1115,
518,
4645,
29896,
29892,
3132,
29906,
29962,
1118,
13,
9651,
2981,
13,
4706,
1723,
13,
4706,
679,
29918,
2040,
29898,
15343,
29918,
7097,
29897,
13,
13,
4706,
3414,
29918,
978,
29918,
449,
29892,
3132,
29918,
7662,
29918,
333,
29892,
848,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29896,
29892,
1652,
29918,
13073,
29897,
13,
13,
4706,
1121,
353,
26849,
519,
580,
13,
4706,
1121,
3366,
1649,
2914,
3108,
353,
376,
1649,
1688,
29918,
2914,
29908,
13,
4706,
4701,
29889,
5014,
29918,
1491,
6737,
29898,
13,
9651,
3132,
29922,
4645,
29896,
29892,
3414,
29918,
978,
543,
1649,
1688,
29918,
7662,
613,
3414,
29918,
333,
29922,
4645,
29918,
7662,
29918,
333,
29892,
1652,
29918,
13073,
29922,
1579,
29918,
13073,
29892,
1121,
29922,
2914,
13,
4706,
1723,
13,
4706,
4974,
3414,
29889,
4230,
29918,
4645,
29918,
7662,
29918,
1958,
3366,
1649,
1688,
29918,
4645,
16862,
2914,
1275,
1121,
13,
13,
4706,
3414,
29918,
978,
29918,
449,
29892,
3132,
29918,
7662,
29918,
333,
29892,
848,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29906,
29892,
1652,
29918,
13073,
29897,
13,
4706,
4974,
3414,
29918,
978,
29918,
449,
1275,
5124,
13,
4706,
4974,
3132,
29918,
7662,
29918,
333,
1275,
5124,
13,
13,
4706,
6826,
29918,
7097,
29889,
7122,
580,
13,
4706,
4974,
3414,
29889,
5729,
12757,
29918,
4882,
1275,
9330,
28958,
5709,
29889,
29907,
23219,
29931,
20566,
13,
4706,
1583,
29889,
9847,
29918,
8299,
29898,
8299,
29892,
1652,
29918,
13073,
29897,
13,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
613,
4321,
2956,
29889,
9818,
29918,
8787,
29903,
29897,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
29906,
613,
6796,
6729,
328,
4384,
613,
376,
6717,
613,
376,
2674,
388,
20068,
13,
1678,
822,
1243,
29918,
816,
11272,
29918,
7662,
29918,
11083,
29918,
6717,
29918,
10702,
29898,
1311,
29892,
1158,
29892,
1158,
29906,
1125,
13,
4706,
822,
1434,
29918,
7662,
29918,
18616,
29918,
10702,
29898,
4645,
29918,
7662,
29901,
12477,
5398,
29892,
1652,
29918,
13073,
29901,
383,
29931,
2677,
1125,
13,
9651,
4701,
353,
1652,
29918,
13073,
29889,
657,
29918,
7728,
29898,
1989,
543,
8299,
1159,
13,
9651,
716,
29918,
7662,
353,
1653,
29918,
7662,
703,
1649,
1482,
29918,
1688,
29918,
7662,
1159,
13,
9651,
6426,
29918,
15343,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
18884,
3646,
29922,
15343,
29918,
7662,
29892,
13,
18884,
9049,
5085,
3790,
13,
462,
1678,
376,
8299,
1115,
4701,
29892,
13,
462,
1678,
376,
7662,
1115,
716,
29918,
7662,
29892,
13,
462,
1678,
376,
5696,
1115,
1158,
29906,
29892,
13,
462,
1678,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
462,
1678,
376,
19290,
1115,
8853,
5182,
29879,
1115,
518,
4645,
29918,
7662,
29889,
4645,
29962,
1118,
13,
18884,
2981,
13,
9651,
1723,
13,
9651,
6426,
29918,
15343,
29918,
7097,
29889,
2962,
580,
13,
9651,
6426,
29918,
15343,
29918,
7097,
29889,
7122,
580,
13,
13,
4706,
4701,
29892,
1652,
29918,
13073,
353,
1583,
29889,
2962,
29918,
8299,
580,
13,
4706,
1652,
29918,
13073,
29889,
842,
29918,
7728,
703,
8299,
613,
4701,
29897,
13,
4706,
3132,
353,
1653,
29918,
4645,
29898,
978,
543,
1649,
1688,
29918,
4645,
1159,
13,
4706,
3414,
353,
1653,
29918,
7662,
703,
1649,
1688,
29918,
7662,
613,
1434,
29918,
7662,
29918,
18616,
29918,
10702,
29922,
11083,
29918,
7662,
29918,
18616,
29918,
10702,
29897,
13,
4706,
6826,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
9651,
3646,
29922,
15343,
29918,
7662,
29892,
13,
9651,
9049,
5085,
3790,
13,
18884,
376,
8299,
1115,
4701,
29892,
13,
18884,
376,
7662,
1115,
3414,
29892,
13,
18884,
376,
5696,
1115,
1158,
29892,
13,
18884,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
18884,
376,
19290,
1115,
8853,
5182,
29879,
1115,
518,
4645,
29962,
1118,
13,
9651,
2981,
13,
4706,
1723,
13,
4706,
6826,
29918,
7097,
29889,
2962,
580,
13,
13,
4706,
3414,
29918,
978,
29918,
449,
353,
5124,
13,
4706,
1550,
3414,
29918,
978,
29918,
449,
1275,
376,
1115,
13,
9651,
3414,
29918,
978,
29918,
449,
29892,
17117,
903,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29892,
1652,
29918,
13073,
29897,
13,
9651,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
4974,
3414,
29918,
978,
29918,
449,
1275,
376,
1649,
1688,
29918,
7662,
29908,
13,
4706,
716,
29918,
7662,
29918,
978,
29918,
449,
353,
5124,
13,
4706,
1550,
716,
29918,
7662,
29918,
978,
29918,
449,
1275,
376,
1115,
13,
9651,
716,
29918,
7662,
29918,
978,
29918,
449,
29892,
17117,
903,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29892,
1652,
29918,
13073,
29897,
13,
9651,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
4974,
716,
29918,
7662,
29918,
978,
29918,
449,
1275,
376,
1649,
1482,
29918,
1688,
29918,
7662,
29908,
13,
13,
4706,
4701,
29889,
20713,
29918,
7662,
29898,
7662,
29897,
13,
4706,
4974,
3414,
29889,
5729,
12757,
29918,
4882,
1275,
9330,
28958,
5709,
29889,
29907,
23219,
29931,
20566,
13,
4706,
6826,
29918,
7097,
29889,
7122,
580,
13,
4706,
1583,
29889,
9847,
29918,
8299,
29898,
8299,
29892,
1652,
29918,
13073,
29897,
13,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
613,
4321,
2956,
29889,
9818,
29918,
8787,
29903,
29897,
13,
1678,
732,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
5696,
29906,
613,
6796,
6729,
328,
4384,
613,
376,
6717,
613,
376,
2674,
388,
20068,
13,
1678,
822,
1243,
29918,
816,
11272,
29918,
7662,
29918,
2914,
29918,
13556,
2347,
29918,
10702,
29898,
1311,
29892,
1158,
29892,
1158,
29906,
1125,
13,
4706,
822,
1121,
29918,
13556,
2347,
29918,
10702,
29898,
4645,
29918,
7662,
29901,
12477,
5398,
29892,
1652,
29918,
13073,
29901,
383,
29931,
2677,
1125,
13,
9651,
4701,
353,
1652,
29918,
13073,
29889,
657,
29918,
7728,
29898,
1989,
543,
8299,
1159,
13,
9651,
716,
29918,
7662,
353,
1653,
29918,
7662,
703,
1649,
1482,
29918,
1688,
29918,
7662,
1159,
13,
9651,
6426,
29918,
15343,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
18884,
3646,
29922,
15343,
29918,
7662,
29892,
13,
18884,
9049,
5085,
3790,
13,
462,
1678,
376,
8299,
1115,
4701,
29892,
13,
462,
1678,
376,
7662,
1115,
716,
29918,
7662,
29892,
13,
462,
1678,
376,
5696,
1115,
1158,
29906,
29892,
13,
462,
1678,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
462,
1678,
376,
19290,
1115,
8853,
5182,
29879,
1115,
518,
4645,
29918,
7662,
29889,
4645,
29962,
1118,
13,
18884,
2981,
13,
9651,
1723,
13,
9651,
679,
29918,
2040,
29898,
3993,
29918,
15343,
29918,
7097,
29897,
13,
9651,
6426,
29918,
15343,
29918,
7097,
29889,
7122,
580,
13,
13,
4706,
4701,
29892,
1652,
29918,
13073,
353,
1583,
29889,
2962,
29918,
8299,
580,
13,
4706,
1652,
29918,
13073,
29889,
842,
29918,
7728,
703,
8299,
613,
4701,
29897,
13,
4706,
3132,
353,
1653,
29918,
4645,
29898,
978,
543,
1649,
1688,
29918,
4645,
1159,
13,
4706,
3414,
353,
1653,
29918,
7662,
703,
1649,
1688,
29918,
7662,
613,
1121,
29918,
13556,
2347,
29918,
10702,
29922,
2914,
29918,
13556,
2347,
29918,
10702,
29897,
13,
4706,
6826,
29918,
7097,
353,
3244,
292,
29889,
4899,
29898,
13,
9651,
3646,
29922,
15343,
29918,
7662,
29892,
13,
9651,
9049,
5085,
3790,
13,
18884,
376,
8299,
1115,
4701,
29892,
13,
18884,
376,
7662,
1115,
3414,
29892,
13,
18884,
376,
5696,
1115,
1158,
29892,
13,
18884,
376,
1579,
29918,
13073,
1115,
1652,
29918,
13073,
29892,
13,
18884,
376,
19290,
1115,
8853,
5182,
29879,
1115,
518,
4645,
29962,
1118,
13,
9651,
2981,
13,
4706,
1723,
13,
4706,
6826,
29918,
7097,
29889,
2962,
580,
13,
13,
4706,
3414,
29918,
978,
29918,
449,
353,
5124,
13,
4706,
3132,
29918,
7662,
29918,
333,
353,
5124,
13,
4706,
848,
353,
6213,
13,
4706,
1550,
3414,
29918,
978,
29918,
449,
1275,
376,
1115,
13,
9651,
3414,
29918,
978,
29918,
449,
29892,
3132,
29918,
7662,
29918,
333,
29892,
848,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29892,
1652,
29918,
13073,
29897,
13,
9651,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
4974,
3414,
29918,
978,
29918,
449,
1275,
376,
1649,
1688,
29918,
7662,
29908,
13,
13,
4706,
4701,
29889,
5014,
29918,
1491,
6737,
29898,
13,
9651,
3132,
29922,
4645,
29892,
3414,
29918,
978,
543,
1649,
1688,
29918,
7662,
613,
3414,
29918,
333,
29922,
4645,
29918,
7662,
29918,
333,
29892,
1652,
29918,
13073,
29922,
1579,
29918,
13073,
29892,
1121,
29922,
1272,
13,
4706,
1723,
13,
4706,
4701,
3032,
3198,
29918,
20673,
580,
13,
4706,
4974,
4701,
29889,
657,
29918,
1949,
29918,
11235,
29918,
20673,
580,
1275,
29871,
29896,
13,
4706,
716,
29918,
7662,
29918,
978,
29918,
449,
353,
5124,
13,
4706,
1550,
716,
29918,
7662,
29918,
978,
29918,
449,
1275,
376,
1115,
13,
9651,
716,
29918,
7662,
29918,
978,
29918,
449,
29892,
17117,
903,
353,
4701,
29889,
5014,
29918,
7662,
29918,
3827,
29898,
4645,
29892,
1652,
29918,
13073,
29897,
13,
9651,
931,
29889,
17059,
29898,
29900,
29889,
29896,
29897,
13,
4706,
4974,
716,
29918,
7662,
29918,
978,
29918,
449,
1275,
376,
1649,
1482,
29918,
1688,
29918,
7662,
29908,
13,
4706,
6826,
29918,
7097,
29889,
7122,
580,
13,
4706,
1583,
29889,
9847,
29918,
8299,
29898,
8299,
29892,
1652,
29918,
13073,
29897,
13,
2
] |
photobox/main.py | MarkusAmshove/Photobox | 1 | 168647 | import pygame
import time
import datetime
import os
import Colors
import SwitchState
import random
from photoslideshow import Photoslideshow
class Photobox():
def __init__(self, windowsize, photofolder, camera, switch, cheesepicfolder):
pygame.init()
self.windowsize = windowsize
self.photofolder = photofolder
self.screen = pygame.display.set_mode(
self.windowsize, pygame.FULLSCREEN)
self.clock = pygame.time.Clock()
self.camera = camera
self.switch = switch
self.countdowntime = 3
self.estimatedtriggertime = 2
self.lastphototaken = datetime.datetime.now()
self.cheesepicfolder = cheesepicfolder
pygame.mouse.set_visible(0)
def start(self):
slideshow = Photoslideshow(self)
self.slideshow = slideshow
while True:
# don't crash the program if an error happens
try:
self.clearscreen()
slideshow.shownextphoto()
self.handleevents()
except Exception as e:
print type(e)
print e.args
print e
pass
self.exit_if_needed()
def exit_if_needed(self):
events = pygame.event.get()
if len(events) == 0:
return
event = events[0]
if event.type == pygame.KEYDOWN:
key = event.key
if key == pygame.K_ESCAPE:
exit()
if key == pygame.K_RETURN:
self.lastphototaken = datetime.datetime.now()
self.takenewphoto()
self.slideshow.reset_timer()
def showphoto(self, path):
self.clearscreen()
photo = pygame.image.load(path)
photo = pygame.transform.scale(photo, self.windowsize)
self.screen.blit(photo, (0, 0))
self.updatescreen()
def updatescreen(self):
pygame.display.flip()
def clearscreen(self):
self.screen.fill((0, 0, 0))
def showtext(self, text, fontsize):
self.clearscreen()
font = pygame.font.Font(None, fontsize)
fontWidth = font.size(text)[0]
fontHeight = font.size(text)[1]
midX = self.windowsize[0] / 2 - fontWidth / 2
midY = self.windowsize[1] / 2 - fontHeight / 2
screentext = font.render(text, True, Colors.randomcolor_rgb())
self.screen.blit(screentext, (midX, midY))
self.updatescreen()
def handleevents(self):
switchstate = self.switch.get_switch_state()
if switchstate == SwitchState.SHUTDOWN:
os.system("sudo shutdown now -h")
exit(0)
if switchstate == SwitchState.EXIT:
exit(0)
if self.newPhotoAllowed():
if switchstate == SwitchState.TRIGGER:
self.lastphototaken = datetime.datetime.now()
self.takenewphoto()
self.slideshow.reset_timer()
def newPhotoAllowed(self):
secondsdelta = self.countdowntime + self.estimatedtriggertime + 5
nextphotoallowed = (self.lastphototaken +
datetime.timedelta(0, secondsdelta))
timenow = datetime.datetime.now()
if timenow > nextphotoallowed:
return True
return False
def takenewphoto(self):
self.showcountdown(self.countdowntime)
randomcheesefile = self.cheesepicfolder.getrandomphoto()
randomnumber = random.randint(0, 1021)
if randomnumber % 2 == 0:
self.showphoto(randomcheesefile)
else:
self.showtext("Cheese!", 300)
nextphotophath = self.photofolder.getnextfilename_fullpath()
photoTaken = self.camera.takephoto(nextphotophath)
if photoTaken:
self.showphoto(nextphotophath)
def showcountdown(self, upperbound):
for i in range(upperbound, 0, -1):
self.showtext(str(i), 400)
time.sleep(1)
| [
1,
1053,
22028,
13,
5215,
931,
13,
5215,
12865,
13,
5215,
2897,
13,
5215,
29183,
13,
5215,
28176,
2792,
13,
5215,
4036,
13,
3166,
20612,
29880,
2247,
3525,
1053,
1963,
15788,
29880,
2247,
3525,
13,
13,
13,
1990,
19040,
23518,
7295,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
5417,
675,
29892,
6731,
974,
3194,
29892,
10656,
29892,
4607,
29892,
923,
968,
16447,
12083,
1125,
13,
4706,
22028,
29889,
2344,
580,
13,
4706,
1583,
29889,
10499,
675,
353,
5417,
675,
13,
4706,
1583,
29889,
561,
327,
974,
3194,
353,
6731,
974,
3194,
13,
4706,
1583,
29889,
10525,
353,
22028,
29889,
4990,
29889,
842,
29918,
8513,
29898,
13,
9651,
1583,
29889,
10499,
675,
29892,
22028,
29889,
29943,
3299,
7187,
1525,
1430,
29897,
13,
4706,
1583,
29889,
13058,
353,
22028,
29889,
2230,
29889,
29907,
908,
580,
13,
4706,
1583,
29889,
26065,
353,
10656,
13,
4706,
1583,
29889,
15123,
353,
4607,
13,
4706,
1583,
29889,
2798,
29881,
340,
593,
603,
353,
29871,
29941,
13,
4706,
1583,
29889,
342,
326,
630,
509,
22817,
814,
603,
353,
29871,
29906,
13,
4706,
1583,
29889,
4230,
561,
327,
327,
9424,
353,
12865,
29889,
12673,
29889,
3707,
580,
13,
4706,
1583,
29889,
1173,
968,
16447,
12083,
353,
923,
968,
16447,
12083,
13,
4706,
22028,
29889,
15769,
29889,
842,
29918,
12872,
29898,
29900,
29897,
13,
13,
1678,
822,
1369,
29898,
1311,
1125,
13,
4706,
2243,
2247,
3525,
353,
1963,
15788,
29880,
2247,
3525,
29898,
1311,
29897,
13,
4706,
1583,
29889,
2536,
2247,
3525,
353,
2243,
2247,
3525,
13,
4706,
1550,
5852,
29901,
13,
9651,
396,
1016,
29915,
29873,
8095,
278,
1824,
565,
385,
1059,
5930,
13,
9651,
1018,
29901,
13,
18884,
1583,
29889,
2841,
1503,
5576,
580,
13,
18884,
2243,
2247,
3525,
29889,
4294,
4622,
21596,
580,
13,
18884,
1583,
29889,
8411,
13604,
580,
13,
9651,
5174,
8960,
408,
321,
29901,
13,
18884,
1596,
1134,
29898,
29872,
29897,
13,
18884,
1596,
321,
29889,
5085,
13,
18884,
1596,
321,
13,
18884,
1209,
13,
9651,
1583,
29889,
13322,
29918,
361,
29918,
484,
19226,
580,
13,
13,
1678,
822,
6876,
29918,
361,
29918,
484,
19226,
29898,
1311,
1125,
13,
4706,
4959,
353,
22028,
29889,
3696,
29889,
657,
580,
13,
4706,
565,
7431,
29898,
13604,
29897,
1275,
29871,
29900,
29901,
13,
9651,
736,
13,
4706,
1741,
353,
4959,
29961,
29900,
29962,
13,
4706,
565,
1741,
29889,
1853,
1275,
22028,
29889,
10818,
3970,
16048,
29901,
13,
9651,
1820,
353,
1741,
29889,
1989,
13,
9651,
565,
1820,
1275,
22028,
29889,
29968,
29918,
2890,
29907,
3301,
29923,
29901,
13,
18884,
6876,
580,
13,
9651,
565,
1820,
1275,
22028,
29889,
29968,
29918,
1525,
29911,
24015,
29901,
13,
18884,
1583,
29889,
4230,
561,
327,
327,
9424,
353,
12865,
29889,
12673,
29889,
3707,
580,
13,
18884,
1583,
29889,
29873,
9424,
809,
21596,
580,
13,
18884,
1583,
29889,
2536,
2247,
3525,
29889,
12071,
29918,
20404,
580,
13,
13,
1678,
822,
1510,
21596,
29898,
1311,
29892,
2224,
1125,
13,
4706,
1583,
29889,
2841,
1503,
5576,
580,
13,
4706,
15373,
353,
22028,
29889,
3027,
29889,
1359,
29898,
2084,
29897,
13,
4706,
15373,
353,
22028,
29889,
9067,
29889,
7052,
29898,
21596,
29892,
1583,
29889,
10499,
675,
29897,
13,
4706,
1583,
29889,
10525,
29889,
2204,
277,
29898,
21596,
29892,
313,
29900,
29892,
29871,
29900,
876,
13,
4706,
1583,
29889,
786,
15190,
5576,
580,
13,
13,
1678,
822,
11217,
5576,
29898,
1311,
1125,
13,
4706,
22028,
29889,
4990,
29889,
29888,
3466,
580,
13,
13,
1678,
822,
4531,
1503,
5576,
29898,
1311,
1125,
13,
4706,
1583,
29889,
10525,
29889,
5589,
3552,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
876,
13,
13,
1678,
822,
1510,
726,
29898,
1311,
29892,
1426,
29892,
4079,
2311,
1125,
13,
4706,
1583,
29889,
2841,
1503,
5576,
580,
13,
4706,
4079,
353,
22028,
29889,
5657,
29889,
9824,
29898,
8516,
29892,
4079,
2311,
29897,
13,
4706,
4079,
6110,
353,
4079,
29889,
2311,
29898,
726,
9601,
29900,
29962,
13,
4706,
4079,
7011,
353,
4079,
29889,
2311,
29898,
726,
9601,
29896,
29962,
13,
4706,
7145,
29990,
353,
1583,
29889,
10499,
675,
29961,
29900,
29962,
847,
29871,
29906,
448,
4079,
6110,
847,
29871,
29906,
13,
4706,
7145,
29979,
353,
1583,
29889,
10499,
675,
29961,
29896,
29962,
847,
29871,
29906,
448,
4079,
7011,
847,
29871,
29906,
13,
4706,
885,
276,
296,
1062,
353,
4079,
29889,
9482,
29898,
726,
29892,
5852,
29892,
29183,
29889,
8172,
2780,
29918,
23973,
3101,
13,
4706,
1583,
29889,
10525,
29889,
2204,
277,
29898,
29879,
1037,
296,
1062,
29892,
313,
6563,
29990,
29892,
7145,
29979,
876,
13,
4706,
1583,
29889,
786,
15190,
5576,
580,
13,
13,
1678,
822,
4386,
13604,
29898,
1311,
1125,
13,
4706,
4607,
3859,
353,
1583,
29889,
15123,
29889,
657,
29918,
15123,
29918,
3859,
580,
13,
4706,
565,
4607,
3859,
1275,
28176,
2792,
29889,
7068,
2692,
3970,
16048,
29901,
13,
9651,
2897,
29889,
5205,
703,
15360,
12522,
3204,
1286,
448,
29882,
1159,
13,
9651,
6876,
29898,
29900,
29897,
13,
4706,
565,
4607,
3859,
1275,
28176,
2792,
29889,
5746,
1806,
29901,
13,
9651,
6876,
29898,
29900,
29897,
13,
4706,
565,
1583,
29889,
1482,
25971,
15930,
287,
7295,
13,
9651,
565,
4607,
3859,
1275,
28176,
2792,
29889,
29911,
22789,
17070,
29901,
13,
18884,
1583,
29889,
4230,
561,
327,
327,
9424,
353,
12865,
29889,
12673,
29889,
3707,
580,
13,
18884,
1583,
29889,
29873,
9424,
809,
21596,
580,
13,
18884,
1583,
29889,
2536,
2247,
3525,
29889,
12071,
29918,
20404,
580,
13,
13,
1678,
822,
716,
25971,
15930,
287,
29898,
1311,
1125,
13,
4706,
6923,
4181,
353,
1583,
29889,
2798,
29881,
340,
593,
603,
718,
1583,
29889,
342,
326,
630,
509,
22817,
814,
603,
718,
29871,
29945,
13,
4706,
2446,
21596,
24622,
353,
313,
1311,
29889,
4230,
561,
327,
327,
9424,
718,
13,
462,
9651,
12865,
29889,
9346,
287,
2554,
29898,
29900,
29892,
6923,
4181,
876,
13,
4706,
5335,
264,
340,
353,
12865,
29889,
12673,
29889,
3707,
580,
13,
4706,
565,
5335,
264,
340,
1405,
2446,
21596,
24622,
29901,
13,
9651,
736,
5852,
13,
4706,
736,
7700,
13,
13,
1678,
822,
4586,
809,
21596,
29898,
1311,
1125,
13,
4706,
1583,
29889,
4294,
2798,
3204,
29898,
1311,
29889,
2798,
29881,
340,
593,
603,
29897,
13,
4706,
4036,
1173,
968,
1445,
353,
1583,
29889,
1173,
968,
16447,
12083,
29889,
657,
8172,
21596,
580,
13,
4706,
4036,
4537,
353,
4036,
29889,
9502,
524,
29898,
29900,
29892,
29871,
29896,
29900,
29906,
29896,
29897,
13,
4706,
565,
4036,
4537,
1273,
29871,
29906,
1275,
29871,
29900,
29901,
13,
9651,
1583,
29889,
4294,
21596,
29898,
8172,
1173,
968,
1445,
29897,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
4294,
726,
703,
26856,
968,
29991,
613,
29871,
29941,
29900,
29900,
29897,
13,
13,
4706,
2446,
561,
327,
3021,
493,
353,
1583,
29889,
561,
327,
974,
3194,
29889,
657,
4622,
9507,
29918,
8159,
2084,
580,
13,
4706,
15373,
29911,
9424,
353,
1583,
29889,
26065,
29889,
19730,
21596,
29898,
4622,
561,
327,
3021,
493,
29897,
13,
4706,
565,
15373,
29911,
9424,
29901,
13,
9651,
1583,
29889,
4294,
21596,
29898,
4622,
561,
327,
3021,
493,
29897,
13,
13,
1678,
822,
1510,
2798,
3204,
29898,
1311,
29892,
7568,
9917,
1125,
13,
4706,
363,
474,
297,
3464,
29898,
21064,
9917,
29892,
29871,
29900,
29892,
448,
29896,
1125,
13,
9651,
1583,
29889,
4294,
726,
29898,
710,
29898,
29875,
511,
29871,
29946,
29900,
29900,
29897,
13,
9651,
931,
29889,
17059,
29898,
29896,
29897,
13,
2
] |
Dj_Learn_start/models.py | Daneev/Django_test | 0 | 135608 | <reponame>Daneev/Django_test<gh_stars>0
# -*- coding: utf-8 -*-
from django.db import models
# Create your models here.
from Apteki.models import Lekarstv
class Post(models.Model):
title = models.CharField(u"Заголовок", max_length=150)
text = models.TextField(u"Текст")
date_create = models.DateTimeField(u"Дата создания", auto_now_add=True)
class Meta:
ordering = ['-date_create']
verbose_name = "Запись в блоге"
verbose_name_plural = "Записи в блоге"
def __str__(self):
"""Возвращает строковое представление модели."""
return u'{} {}'.format(self.title, self.date_create)
class Order(models.Model):
lekarstvo = models.ForeignKey(Lekarstv, verbose_name='Лекарство')
name = models.CharField("Введите наименование лекарства ", max_length=50)
#price = models.CharField("price", max_length=50)
#address = models.CharField("adress", max_length=50)
class Comment(models.Model):
comment_post = models.ForeignKey(Post, verbose_name="Комментарии")
text = models.CharField("Текст комментария", max_length=200)
data = models.DateTimeField(auto_now_add=True, verbose_name="дата комментария")
class Meta:
verbose_name = "Комментарий"
verbose_name_plural = "Комментарии"
def __str__(self):
return self.text | [
1,
529,
276,
1112,
420,
29958,
29928,
1662,
5750,
29914,
29928,
5364,
29918,
1688,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
3166,
9557,
29889,
2585,
1053,
4733,
13,
13,
29937,
6204,
596,
4733,
1244,
29889,
13,
3166,
6225,
371,
1984,
29889,
9794,
1053,
951,
5689,
303,
29894,
13,
13,
13,
1990,
4918,
29898,
9794,
29889,
3195,
1125,
13,
13,
1678,
3611,
353,
4733,
29889,
27890,
29898,
29884,
29908,
15578,
588,
19071,
29951,
613,
4236,
29918,
2848,
29922,
29896,
29945,
29900,
29897,
13,
1678,
1426,
353,
4733,
29889,
15778,
29898,
29884,
29908,
30041,
3506,
464,
1159,
13,
1678,
2635,
29918,
3258,
353,
4733,
29889,
11384,
3073,
29898,
29884,
29908,
30032,
29910,
676,
14507,
1587,
613,
4469,
29918,
3707,
29918,
1202,
29922,
5574,
29897,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
20520,
353,
6024,
29899,
1256,
29918,
3258,
2033,
13,
4706,
26952,
29918,
978,
353,
376,
15578,
1668,
1210,
490,
836,
843,
5035,
29908,
13,
4706,
26952,
29918,
978,
29918,
572,
3631,
353,
376,
15578,
17307,
490,
836,
843,
5035,
29908,
13,
13,
1678,
822,
4770,
710,
12035,
1311,
1125,
13,
4706,
9995,
27129,
29972,
18524,
4826,
1257,
2091,
576,
7220,
29919,
11876,
6195,
2569,
23890,
1213,
15945,
13,
4706,
736,
318,
29915,
8875,
6571,
4286,
4830,
29898,
1311,
29889,
3257,
29892,
1583,
29889,
1256,
29918,
3258,
29897,
13,
13,
13,
13,
1990,
8170,
29898,
9794,
29889,
3195,
1125,
13,
1678,
454,
5689,
26225,
353,
4733,
29889,
27755,
2558,
29898,
29931,
1416,
279,
303,
29894,
29892,
26952,
29918,
978,
2433,
30050,
29919,
15266,
3501,
1495,
13,
1678,
1024,
353,
4733,
29889,
27890,
703,
30012,
1521,
956,
730,
25015,
2387,
1263,
1755,
4674,
15266,
3828,
9162,
4236,
29918,
2848,
29922,
29945,
29900,
29897,
13,
1678,
396,
9175,
353,
4733,
29889,
27890,
703,
9175,
613,
4236,
29918,
2848,
29922,
29945,
29900,
29897,
13,
1678,
396,
7328,
353,
4733,
29889,
27890,
703,
328,
1253,
613,
4236,
29918,
2848,
29922,
29945,
29900,
29897,
13,
13,
13,
1990,
461,
29898,
9794,
29889,
3195,
1125,
13,
1678,
3440,
29918,
2490,
353,
4733,
29889,
27755,
2558,
29898,
6747,
29892,
26952,
29918,
978,
543,
30014,
9530,
19900,
5887,
1159,
13,
1678,
1426,
353,
4733,
29889,
27890,
703,
30041,
3506,
464,
5294,
19900,
4941,
613,
4236,
29918,
2848,
29922,
29906,
29900,
29900,
29897,
13,
1678,
848,
353,
4733,
29889,
11384,
3073,
29898,
6921,
29918,
3707,
29918,
1202,
29922,
5574,
29892,
26952,
29918,
978,
543,
840,
676,
5294,
19900,
4941,
1159,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
26952,
29918,
978,
353,
376,
30014,
9530,
19900,
10598,
29908,
13,
4706,
26952,
29918,
978,
29918,
572,
3631,
353,
376,
30014,
9530,
19900,
5887,
29908,
13,
13,
1678,
822,
4770,
710,
12035,
1311,
1125,
13,
4706,
736,
1583,
29889,
726,
2
] |
syllabus/classes/class3/class3-task.py | signekb/NLP-E21 | 0 | 1608252 | <gh_stars>0
#### QUESTIONS ####
#- Best way to use the md file? bc this is not it...
#- Why does "def corpus_loader(folder: str) -> List[str]:" not work for me? - it says "List not defined"
#pip install spacy
# install smaller model
#python -m spacy download en_core_web_sm
#cd NLP-E21/syllabus/classes/class3/
#doc:
# `lemma_` which denotes the lemma of the token,
# `pos_` which denotes part-of-speech tag of the token and
# `ent_type_` which denote the entity type of the token.
#**Exercise 1**:
#Inspect the `doc`-object using `dir` and `type` along with the [documentation](https://spacy.io/api/Doc).
# You should before class have though
# i) about what is intended use (or benefit) of the `doc`-object
'''
it contains the raw text as well as the annotations which allows
us to do cool analyses on texts without us having to do that ourselves
- i.e. we can "move on" to the actual analyses instead of spending a lot of time on annotations
'''
# ii) What are the two ways in which I can create an `Doc` object?
'''
# Construction 1 - using nlp
doc = nlp("Some text")
print(doc)
-- the nlp pipeline takes in text and create component like; tokenizer, parser, NER, POS-tagger, etc.
- tokenizer: split sentence into tokens
- parser: creates dependency tree --> you can recreate the sentences using this parser
- ner: named entity recognition - tag names as names
- POS-tagger: verb, noun, etc.
- and possibly many more... (you can keep adding components to the doc class)
# Construction 2 - create words and spaces and collect in a doc object
from spacy.tokens import Doc
words = ["hello", "world", "!"]
spaces = [True, False, False]
doc = Doc(nlp.vocab, words=words, spaces=spaces) - classes are typically upper case
'''
### Corpus loader
#Before the class, you should have a corpus loader ready. This should be able to read in each
# file in the folder `syllabus/classes/data/train_corpus` as a list of strings (or similar object).
import os
#def corpus_loader(folder: str) -> List[str]:
def corpus_loader(folder):
"""
A corpus loader function which takes in a path to a
folder and returns a list of strings.
"""
corpus = []
# - 1) Loading in the files as text.
for file in os.listdir(folder):
current_file = folder+str(file)
with open(current_file) as f:
contents = f.read()
corpus.append(contents)
f.close()
return corpus
texts = corpus_loader("/work/NLP-E21/syllabus/classes/data/train_corpus/")
## Plan for class
#- 1) Talk about exercise 1
#- 2) Filter a text to keep only the lemma of nouns, adjectives and verbs
import spacy
nlp = spacy.load("en_core_web_sm")
# docs is a list of doc objects
docs = [nlp(t) for t in texts]
one_doc = docs[0]
def noun_adj_verb_filter(doc):
lemmas = []
for tok in doc:
if tok.pos_ in ['NOUN','VERB','ADJ']:
lemmas.append(tok.lemma_)
return lemmas
all_lemmas = [noun_adj_verb_filter(doc) for doc in docs]
# 3) Calculate the ratio of pos-tags in texts.
'''
from collections import Counter
pos_counts = Counter([token_pos_ for token in doc]) # return dictionary with how many
list(zip([j for j in pos_counts.keys()],[i/len(doc) for i in pos_counts.values()]))
[(pos,count/len(doc)) for pos,count in pos_counts.items()]
'''
# 4 Calculate mean dependency distance (MDD)
'''
token: "reporter"
token.head: "admitted"
take indices from each and subtract them
for i,token in enumerate(doc):
#gives us index and token for all indices in the doc
then subtract the two: abs(tokeni-token.head)
pos_counts = Counter([token.pos_ for token in doc])
[(pos, count/len(doc)) for pos, count in pos_counts.items()]
'''
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
4136,
660,
4462,
1254,
27946,
3191,
13,
29937,
29899,
6407,
982,
304,
671,
278,
22821,
934,
29973,
289,
29883,
445,
338,
451,
372,
856,
13,
29937,
29899,
3750,
947,
376,
1753,
1034,
13364,
29918,
12657,
29898,
12083,
29901,
851,
29897,
1599,
2391,
29961,
710,
5387,
29908,
451,
664,
363,
592,
29973,
448,
372,
4083,
376,
1293,
451,
3342,
29908,
13,
29937,
13096,
2601,
805,
4135,
13,
29937,
2601,
7968,
1904,
13,
29937,
4691,
448,
29885,
805,
4135,
5142,
427,
29918,
3221,
29918,
2676,
29918,
3844,
13,
29937,
2252,
405,
13208,
29899,
29923,
29906,
29896,
29914,
29879,
15114,
370,
375,
29914,
13203,
29914,
1990,
29941,
29914,
13,
13,
29937,
1514,
29901,
13,
29937,
421,
13846,
29918,
29952,
607,
20169,
278,
10383,
310,
278,
5993,
29892,
29871,
13,
29937,
421,
1066,
29918,
29952,
607,
20169,
760,
29899,
974,
29899,
5965,
5309,
4055,
310,
278,
5993,
322,
29871,
13,
29937,
421,
296,
29918,
1853,
29918,
29952,
607,
13530,
278,
7855,
1134,
310,
278,
5993,
29889,
13,
13,
29937,
1068,
1252,
6269,
895,
29871,
29896,
1068,
29901,
13,
29937,
797,
21494,
278,
421,
1514,
27969,
3318,
773,
421,
3972,
29952,
322,
421,
1853,
29952,
3412,
411,
278,
518,
12663,
850,
991,
597,
1028,
4135,
29889,
601,
29914,
2754,
29914,
14526,
467,
29871,
13,
29937,
887,
881,
1434,
770,
505,
2466,
29871,
13,
13,
29937,
474,
29897,
1048,
825,
338,
9146,
671,
313,
272,
14169,
29897,
310,
278,
421,
1514,
27969,
3318,
29871,
13,
12008,
13,
277,
3743,
278,
10650,
1426,
408,
1532,
408,
278,
25495,
607,
6511,
29871,
13,
375,
304,
437,
12528,
3483,
952,
267,
373,
26442,
1728,
502,
2534,
304,
437,
393,
20278,
29871,
13,
29899,
474,
29889,
29872,
29889,
591,
508,
376,
11631,
373,
29908,
304,
278,
3935,
3483,
952,
267,
2012,
310,
805,
2548,
263,
3287,
310,
931,
373,
25495,
13,
12008,
13,
29937,
13607,
29897,
1724,
526,
278,
1023,
5837,
297,
607,
306,
508,
1653,
385,
421,
14526,
29952,
1203,
29973,
13,
12008,
13,
29937,
5798,
4080,
29871,
29896,
448,
773,
302,
22833,
13,
1514,
353,
302,
22833,
703,
9526,
1426,
1159,
13,
2158,
29898,
1514,
29897,
13,
489,
278,
302,
22833,
16439,
4893,
297,
1426,
322,
1653,
4163,
763,
29936,
5993,
3950,
29892,
13812,
29892,
405,
1001,
29892,
349,
3267,
29899,
4039,
914,
29892,
2992,
29889,
29871,
13,
29899,
5993,
3950,
29901,
6219,
10541,
964,
18897,
13,
29899,
13812,
29901,
10017,
10609,
5447,
6660,
366,
508,
337,
3258,
278,
25260,
773,
445,
13812,
13,
29899,
26033,
29901,
4257,
7855,
19679,
448,
4055,
2983,
408,
2983,
13,
29899,
349,
3267,
29899,
4039,
914,
29901,
9750,
29892,
302,
1309,
29892,
2992,
29889,
29871,
13,
29899,
322,
10075,
1784,
901,
856,
313,
6293,
508,
3013,
4417,
7117,
304,
278,
1574,
770,
29897,
13,
13,
29937,
5798,
4080,
29871,
29906,
448,
1653,
3838,
322,
8162,
322,
6314,
297,
263,
1574,
1203,
29871,
13,
3166,
805,
4135,
29889,
517,
12360,
1053,
28197,
13,
9303,
353,
6796,
12199,
613,
376,
11526,
613,
376,
29991,
3108,
13,
22854,
353,
518,
5574,
29892,
7700,
29892,
7700,
29962,
13,
1514,
353,
28197,
29898,
12938,
29886,
29889,
29894,
542,
370,
29892,
3838,
29922,
9303,
29892,
8162,
29922,
22854,
29897,
448,
4413,
526,
12234,
7568,
1206,
13,
12008,
13,
13,
2277,
29937,
2994,
13364,
23466,
13,
29937,
18743,
278,
770,
29892,
366,
881,
505,
263,
1034,
13364,
23466,
7960,
29889,
910,
881,
367,
2221,
304,
1303,
297,
1269,
29871,
13,
29937,
934,
297,
278,
4138,
421,
29879,
15114,
370,
375,
29914,
13203,
29914,
1272,
29914,
14968,
29918,
2616,
13364,
29952,
408,
263,
1051,
310,
6031,
313,
272,
2788,
1203,
467,
13,
13,
5215,
2897,
13,
13,
29937,
1753,
1034,
13364,
29918,
12657,
29898,
12083,
29901,
851,
29897,
1599,
2391,
29961,
710,
5387,
13,
1753,
1034,
13364,
29918,
12657,
29898,
12083,
1125,
13,
1678,
9995,
13,
1678,
319,
1034,
13364,
23466,
740,
607,
4893,
297,
263,
2224,
304,
263,
29871,
13,
1678,
4138,
322,
3639,
263,
1051,
310,
6031,
29889,
13,
1678,
9995,
13,
1678,
1034,
13364,
353,
5159,
13,
1678,
396,
448,
29871,
29896,
29897,
4309,
9382,
297,
278,
2066,
408,
1426,
29889,
13,
1678,
363,
934,
297,
2897,
29889,
1761,
3972,
29898,
12083,
1125,
13,
4706,
1857,
29918,
1445,
353,
4138,
29974,
710,
29898,
1445,
29897,
13,
4706,
411,
1722,
29898,
3784,
29918,
1445,
29897,
408,
285,
29901,
13,
9651,
8118,
353,
285,
29889,
949,
580,
13,
9651,
1034,
13364,
29889,
4397,
29898,
10853,
29897,
13,
9651,
285,
29889,
5358,
580,
13,
1678,
736,
1034,
13364,
13,
13,
726,
29879,
353,
1034,
13364,
29918,
12657,
11974,
1287,
29914,
29940,
13208,
29899,
29923,
29906,
29896,
29914,
29879,
15114,
370,
375,
29914,
13203,
29914,
1272,
29914,
14968,
29918,
2616,
13364,
29914,
1159,
13,
13,
2277,
8402,
363,
770,
13,
13,
29937,
29899,
29871,
29896,
29897,
323,
2235,
1048,
15058,
29871,
29896,
13,
29937,
29899,
29871,
29906,
29897,
19916,
263,
1426,
304,
3013,
871,
278,
10383,
310,
302,
1309,
29879,
29892,
594,
622,
3145,
322,
1147,
5824,
13,
5215,
805,
4135,
13,
12938,
29886,
353,
805,
4135,
29889,
1359,
703,
264,
29918,
3221,
29918,
2676,
29918,
3844,
1159,
13,
13,
29937,
10561,
338,
263,
1051,
310,
1574,
3618,
13,
2640,
353,
518,
12938,
29886,
29898,
29873,
29897,
363,
260,
297,
26442,
29962,
13,
13,
650,
29918,
1514,
353,
10561,
29961,
29900,
29962,
13,
13,
1753,
302,
1309,
29918,
26859,
29918,
18248,
29918,
4572,
29898,
1514,
1125,
13,
1678,
454,
4317,
294,
353,
5159,
13,
1678,
363,
304,
29895,
297,
1574,
29901,
13,
4706,
565,
304,
29895,
29889,
1066,
29918,
297,
6024,
6632,
3904,
3788,
5348,
29933,
3788,
3035,
29967,
2033,
29901,
13,
9651,
454,
4317,
294,
29889,
4397,
29898,
17082,
29889,
13846,
19925,
13,
1678,
736,
454,
4317,
294,
13,
13,
497,
29918,
2409,
8247,
353,
518,
29876,
1309,
29918,
26859,
29918,
18248,
29918,
4572,
29898,
1514,
29897,
363,
1574,
297,
10561,
29962,
13,
13,
29937,
29871,
29941,
29897,
20535,
403,
278,
11959,
310,
926,
29899,
11338,
297,
26442,
29889,
29871,
13,
12008,
13,
3166,
16250,
1053,
315,
5336,
13,
1066,
29918,
2798,
29879,
353,
315,
5336,
4197,
6979,
29918,
1066,
29918,
363,
5993,
297,
1574,
2314,
396,
736,
8600,
411,
920,
1784,
29871,
13,
1761,
29898,
7554,
4197,
29926,
363,
432,
297,
926,
29918,
2798,
29879,
29889,
8149,
580,
16272,
29875,
29914,
2435,
29898,
1514,
29897,
363,
474,
297,
926,
29918,
2798,
29879,
29889,
5975,
580,
12622,
13,
13,
15625,
1066,
29892,
2798,
29914,
2435,
29898,
1514,
876,
363,
926,
29892,
2798,
297,
926,
29918,
2798,
29879,
29889,
7076,
580,
29962,
13,
12008,
13,
29937,
29871,
29946,
20535,
403,
2099,
10609,
5418,
313,
5773,
29928,
29897,
13,
12008,
13,
6979,
29901,
376,
276,
18505,
29908,
13,
6979,
29889,
2813,
29901,
376,
328,
29885,
4430,
29908,
13,
19730,
16285,
515,
1269,
322,
23197,
963,
13,
13,
1454,
474,
29892,
6979,
297,
26985,
29898,
1514,
1125,
13,
1678,
396,
29887,
3145,
502,
2380,
322,
5993,
363,
599,
16285,
297,
278,
1574,
13,
13,
6098,
23197,
278,
1023,
29901,
6425,
29898,
6979,
29875,
29899,
6979,
29889,
2813,
29897,
13,
13,
1066,
29918,
2798,
29879,
353,
315,
5336,
4197,
6979,
29889,
1066,
29918,
363,
5993,
297,
1574,
2314,
13,
15625,
1066,
29892,
2302,
29914,
2435,
29898,
1514,
876,
363,
926,
29892,
2302,
297,
926,
29918,
2798,
29879,
29889,
7076,
580,
29962,
13,
12008,
13,
2
] |
Bunnies.py | fatih-iver/Intro-to-Computer-Science-with-Python | 0 | 17213 | <filename>Bunnies.py
# Define a procedure, fibonacci, that takes a natural number as its input, and
# returns the value of that fibonacci number.
# Two Base Cases:
# fibonacci(0) => 0
# fibonacci(1) => 1
# Recursive Case:
# n > 1 : fibonacci(n) => fibonacci(n-1) + fibonacci(n-2)
def fibonacci(n):
return n if n == 0 or n == 1 else fibonacci(n-1) + fibonacci(n-2)
print (fibonacci(0))
#>>> 0
print (fibonacci(1))
#>>> 1
print (fibonacci(15))
#>>> 610 | [
1,
529,
9507,
29958,
29933,
5963,
583,
29889,
2272,
13,
29937,
22402,
263,
8792,
29892,
18755,
265,
21566,
29892,
393,
4893,
263,
5613,
1353,
408,
967,
1881,
29892,
322,
30004,
13,
29937,
3639,
278,
995,
310,
393,
18755,
265,
21566,
1353,
22993,
13,
30004,
13,
29937,
7803,
7399,
315,
2129,
29901,
30004,
13,
29937,
1678,
18755,
265,
21566,
29898,
29900,
29897,
1149,
29871,
29900,
30004,
13,
29937,
1678,
18755,
265,
21566,
29898,
29896,
29897,
1149,
29871,
29896,
30004,
13,
30004,
13,
29937,
3599,
25397,
11733,
29901,
30004,
13,
29937,
1678,
302,
1405,
29871,
29896,
584,
18755,
265,
21566,
29898,
29876,
29897,
1149,
18755,
265,
21566,
29898,
29876,
29899,
29896,
29897,
718,
18755,
265,
21566,
29898,
29876,
29899,
29906,
8443,
13,
30004,
13,
1753,
18755,
265,
21566,
29898,
29876,
1125,
30004,
13,
1678,
736,
302,
565,
302,
1275,
29871,
29900,
470,
302,
1275,
29871,
29896,
1683,
18755,
265,
21566,
29898,
29876,
29899,
29896,
29897,
718,
18755,
265,
21566,
29898,
29876,
29899,
29906,
8443,
13,
1678,
6756,
13,
2158,
313,
29888,
747,
265,
21566,
29898,
29900,
876,
30004,
13,
29937,
6778,
29958,
29871,
29900,
30004,
13,
2158,
313,
29888,
747,
265,
21566,
29898,
29896,
876,
30004,
13,
29937,
6778,
29958,
29871,
29896,
30004,
13,
2158,
313,
29888,
747,
265,
21566,
29898,
29896,
29945,
876,
30004,
13,
29937,
6778,
29958,
29871,
29953,
29896,
29900,
2
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.