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
|
---|---|---|---|---|---|
tests/conftest.py | weiss-d/baby-crawler | 0 | 85086 | import pytest
@pytest.fixture
def checkup_html() -> str:
return {
"html": """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Page Title</title>
</head>
<body>
<a href="https://google.com/">Root domain link</a>
<a href="https://google.com/1.html">Normal link 1</a>
<a href="https://google.com/2.html">Normal link 2</a>
<a href="https://google.com/2.html">Duplicate link 2</a>
<a href="https://google.com/3.html#test">Normal link 3 with anchor</a>
<a href="https://google.com/picture.png">Link to an image.</a>
<a href="https://mail.google.com/">Subdomain link</a>
<a href="/4.html">Relative link</a>
<a rel="nofollow" href="https://google.com/nofollow">Nofollow link</a>
<a href="https://yandex.ru">Foreign link</a>
<a href="mailto:<EMAIL>">Email link</a>
<a href="#fragment">Fragment link</a>
<a href="ftp://google.com">Non HTTP(S) link</a>
<a href="">Link with empty href</a>
<a>Link without a URL</a>
<title>Incorrect Title</title>
<p>Some stuff.</p>
</body>
</html>
""",
"title_nonempty_links": (
"Test Page Title",
{
"#fragment",
"/4.html",
"ftp://google.com",
"https://google.com/",
"https://google.com/1.html",
"https://google.com/2.html",
"https://google.com/3.html#test",
"https://google.com/picture.png",
"https://mail.google.com/",
"https://yandex.ru",
"mailto:<EMAIL>",
},
),
"filter_result_wo_subdomains": [
"https://google.com/1.html",
"https://google.com/2.html",
"https://google.com/3.html",
"https://google.com/4.html",
],
"filter_result_subdomains": [
"https://google.com/1.html",
"https://google.com/2.html",
"https://google.com/3.html",
"https://google.com/4.html",
"https://mail.google.com",
],
}
| [
1,
1053,
11451,
1688,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
1423,
786,
29918,
1420,
580,
1599,
851,
29901,
13,
1678,
736,
426,
13,
4706,
376,
1420,
1115,
9995,
29966,
29991,
21300,
3472,
29958,
13,
29966,
1420,
6361,
543,
264,
1013,
13,
29966,
2813,
29958,
13,
29871,
529,
7299,
17425,
543,
10496,
29899,
29947,
1013,
13,
29871,
529,
3257,
29958,
3057,
9305,
18527,
829,
3257,
29958,
13,
829,
2813,
29958,
13,
29966,
2587,
29958,
13,
29871,
529,
29874,
2822,
543,
991,
597,
3608,
29889,
510,
29914,
1013,
10303,
5354,
1544,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
991,
597,
3608,
29889,
510,
29914,
29896,
29889,
1420,
1013,
19077,
1544,
29871,
29896,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
991,
597,
3608,
29889,
510,
29914,
29906,
29889,
1420,
1013,
19077,
1544,
29871,
29906,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
991,
597,
3608,
29889,
510,
29914,
29906,
29889,
1420,
1013,
29928,
786,
5926,
1544,
29871,
29906,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
991,
597,
3608,
29889,
510,
29914,
29941,
29889,
1420,
29937,
1688,
1013,
19077,
1544,
29871,
29941,
411,
17360,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
991,
597,
3608,
29889,
510,
29914,
12095,
29889,
2732,
1013,
6595,
304,
385,
1967,
21106,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
991,
597,
2549,
29889,
3608,
29889,
510,
29914,
1013,
4035,
7247,
1544,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
13802,
29946,
29889,
1420,
1013,
18278,
1544,
829,
29874,
29958,
13,
29871,
529,
29874,
1104,
543,
4043,
29908,
2822,
543,
991,
597,
3608,
29889,
510,
29914,
4043,
1013,
29940,
974,
2952,
1544,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
991,
597,
10094,
1390,
29889,
582,
1013,
27755,
1544,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
2549,
517,
29901,
29966,
26862,
6227,
29958,
1013,
9823,
1544,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
9880,
20777,
1013,
8752,
1544,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
23102,
597,
3608,
29889,
510,
1013,
12283,
7331,
29898,
29903,
29897,
1544,
829,
29874,
29958,
13,
29871,
529,
29874,
2822,
543,
1013,
6595,
411,
4069,
2822,
829,
29874,
29958,
13,
29871,
529,
29874,
29958,
6595,
1728,
263,
3988,
829,
29874,
29958,
13,
29871,
529,
3257,
29958,
797,
15728,
18527,
829,
3257,
29958,
13,
29871,
529,
29886,
29958,
9526,
6433,
21106,
29886,
29958,
13,
829,
2587,
29958,
13,
829,
1420,
29958,
13,
15945,
613,
13,
4706,
376,
3257,
29918,
5464,
6310,
29918,
4965,
1115,
313,
13,
9651,
376,
3057,
9305,
18527,
613,
13,
9651,
426,
13,
18884,
12305,
20777,
613,
13,
18884,
5591,
29946,
29889,
1420,
613,
13,
18884,
376,
23102,
597,
3608,
29889,
510,
613,
13,
18884,
376,
991,
597,
3608,
29889,
510,
29914,
613,
13,
18884,
376,
991,
597,
3608,
29889,
510,
29914,
29896,
29889,
1420,
613,
13,
18884,
376,
991,
597,
3608,
29889,
510,
29914,
29906,
29889,
1420,
613,
13,
18884,
376,
991,
597,
3608,
29889,
510,
29914,
29941,
29889,
1420,
29937,
1688,
613,
13,
18884,
376,
991,
597,
3608,
29889,
510,
29914,
12095,
29889,
2732,
613,
13,
18884,
376,
991,
597,
2549,
29889,
3608,
29889,
510,
29914,
613,
13,
18884,
376,
991,
597,
10094,
1390,
29889,
582,
613,
13,
18884,
376,
2549,
517,
29901,
29966,
26862,
6227,
28341,
13,
9651,
2981,
13,
4706,
10353,
13,
4706,
376,
4572,
29918,
2914,
29918,
827,
29918,
1491,
3129,
2708,
1115,
518,
13,
9651,
376,
991,
597,
3608,
29889,
510,
29914,
29896,
29889,
1420,
613,
13,
9651,
376,
991,
597,
3608,
29889,
510,
29914,
29906,
29889,
1420,
613,
13,
9651,
376,
991,
597,
3608,
29889,
510,
29914,
29941,
29889,
1420,
613,
13,
9651,
376,
991,
597,
3608,
29889,
510,
29914,
29946,
29889,
1420,
613,
13,
4706,
21251,
13,
4706,
376,
4572,
29918,
2914,
29918,
1491,
3129,
2708,
1115,
518,
13,
9651,
376,
991,
597,
3608,
29889,
510,
29914,
29896,
29889,
1420,
613,
13,
9651,
376,
991,
597,
3608,
29889,
510,
29914,
29906,
29889,
1420,
613,
13,
9651,
376,
991,
597,
3608,
29889,
510,
29914,
29941,
29889,
1420,
613,
13,
9651,
376,
991,
597,
3608,
29889,
510,
29914,
29946,
29889,
1420,
613,
13,
9651,
376,
991,
597,
2549,
29889,
3608,
29889,
510,
613,
13,
4706,
21251,
13,
1678,
500,
13,
2
] |
userprofile/utils.py | praekelt/django-userprofile | 0 | 167969 | from django.conf import settings
from django.db.models.loading import get_model
def get_profile_model():
"""
Returns configured user profile model or None if not found
"""
user_profile_module = getattr(settings, 'USER_PROFILE_MODULE', None)
if user_profile_module:
app_label, model_name = user_profile_module.split('.')
return get_model(app_label, model_name)
else:
return None
| [
1,
515,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
2585,
29889,
9794,
29889,
13234,
1053,
679,
29918,
4299,
13,
13,
13,
1753,
679,
29918,
10185,
29918,
4299,
7295,
13,
1678,
9995,
13,
1678,
16969,
13252,
1404,
8722,
1904,
470,
6213,
565,
451,
1476,
13,
1678,
9995,
13,
1678,
1404,
29918,
10185,
29918,
5453,
353,
679,
5552,
29898,
11027,
29892,
525,
11889,
29918,
8618,
7724,
29918,
6720,
14849,
1307,
742,
6213,
29897,
13,
1678,
565,
1404,
29918,
10185,
29918,
5453,
29901,
13,
4706,
623,
29918,
1643,
29892,
1904,
29918,
978,
353,
1404,
29918,
10185,
29918,
5453,
29889,
5451,
12839,
1495,
13,
4706,
736,
679,
29918,
4299,
29898,
932,
29918,
1643,
29892,
1904,
29918,
978,
29897,
13,
1678,
1683,
29901,
13,
4706,
736,
6213,
13,
2
] |
Simple_AD/Simple_AD.py | elongstreet88/Python_Simple_AD | 1 | 60647 | from ldap3 import Server, Connection, ALL, NTLM, ALL_ATTRIBUTES, ALL_OPERATIONAL_ATTRIBUTES
class Simple_AD:
"""
A simple wrapper for ldap3 in an Active Directory Environment.
Examples:
0. Initilaize a connection
sad = Simple_AD(server_name="server1.mydomain.com", username="mydomain.com\\jsmith", password="<PASSWORD>")
1. Get group(s) by samaccountname
groups = sad.get_adgroup(samaccountname="Accounting")
2. Get users from a group fast
users_from_group = sad.expand_users_from_group(groups[0])
3. Get a user by samaccountname
user = sad.get_aduser(samaccountname="jsmith")
"""
def __init__(self, server_name, username, password, use_ssl=True, default_attributes=ALL_ATTRIBUTES):
"""
Class initilizer. Takes various ldap3 properties and passess them through
Args:
server_name (string): The name of the target ldap server
username (string): Username to authenticate in the format: {domain_name\\user_name}. Ex: [contoso\\jsmith]
password (string): <PASSWORD>
use_ssl (bool, optional): Binds to SSL on port 636 and should be used when possible. Defaults to True.
default_attributes: Sets the default attributes to get for an object during an LDAP query, optional. Defaults to ALL_ATTRIBUTES.
Can be set to:
ALL_OPERATIONAL_ATTRIBUTES - ldap3 operation attributes wrapper
[] - No attributes by default
["member","lastLogonDate"] - Custom attributes
"""
self.server = Server(server_name, use_ssl=use_ssl, get_info=ALL)
self.conn = Connection(self.server, auto_bind=True, user=username, password=password, authentication=NTLM)
self.base_ou = self.server.info.naming_contexts[0]
self.default_attributes = default_attributes
def get_adgroup(self, samaccountname="*", distinguishedname="*", attributes=False):
"""
Get an AD Group Object from a filter.
Can return multiple results using a wildcard '*'
Args:
samaccountname (str, optional): LDAP Property samaccountname. Defaults to "*".
distinguishedname (str, optional): LDAP Property distinguishedname.. Defaults to "*".
attributes (bool, optional): Custom attributes if not using defaults. Defaults to False.
Returns:
object: ldap3 attribute object of the group(s)
"""
if(attributes == False):
attributes = self.default_attributes
self.conn.search(
search_base=self.base_ou,
search_filter=f'(&(objectCategory=group)(samaccountname={samaccountname})(distinguishedname={distinguishedname}))',
search_scope='SUBTREE',
attributes = attributes
)
return self.conn.entries
def get_aduser(self, samaccountname="*", distinguishedname="*", attributes=False):
"""
Get an AD User Object from a filter.
Can return multiple results using a wildcard '*'
Args:
samaccountname (str, optional): LDAP Property samaccountname. Defaults to "*".
distinguishedname (str, optional): LDAP Property distinguishedname.. Defaults to "*".
attributes (bool, optional): Custom attributes if not using defaults. Defaults to False.
Returns:
object: ldap3 attribute object of the user(s)
"""
if(attributes == False):
attributes = self.default_attributes
self.conn.search(
search_base=self.base_ou,
search_filter=f'(&(objectCategory=user)(samaccountname={samaccountname})(distinguishedname={distinguishedname}))',
search_scope='SUBTREE',
attributes = attributes
)
return self.conn.entries
def expand_users_from_group(self, group, attributes=False):
"""
A handy function to quickly expand user attributes from a group object with the [member] attribute populated.
This is useful when you need to get additional attributes from a users in a group, but don't want to look them up for each.
This builds a single LDAP query for all users
Args:
group (group object): Group object with the [member] attribute populated
attributes (bool, optional): Custom attributes if not using defaults. Defaults to False.
Raises:
Exception: If [member] is not populated on the [group] argument, exception will be raised.
Returns:
object: List of AD users with their requested attributes
Examples:
1. Expand members from the group "Accounting"
sad = Simple_AD(server_name="server1.mydomain.com", username="mydomain.com\\jsmith", password="<PASSWORD>")
groups = sad.get_adgroup(samaccountname="Accounting")
users_from_group = sad.expand_users_from_group(groups[0])
"""
if not hasattr(group, 'member'):
raise Exception("Group must have attribute [member] populated.")
#Validate attributes to get
if(attributes == False):
attributes = self.default_attributes
#Build fast query in format: (|(distinguishedname=dn1)(distinguishedname=dn2)(...))
members_ldap_query = ""
for distinguishedname in group.member:
members_ldap_query += f"(distinguishedname={distinguishedname})"
members_ldap_query = "(|" + members_ldap_query + ")"
#Get the users
self.conn.search(
search_base=self.base_ou,
search_filter=members_ldap_query,
search_scope='SUBTREE',
attributes = attributes
)
#Return results
return self.conn.entries | [
1,
515,
301,
29881,
481,
29941,
1053,
5656,
29892,
15160,
29892,
15149,
29892,
405,
14632,
29924,
29892,
15149,
29918,
1299,
29911,
3960,
29933,
2692,
2890,
29892,
15149,
29918,
4590,
1001,
8098,
1964,
29918,
1299,
29911,
3960,
29933,
2692,
2890,
13,
13,
1990,
12545,
29918,
3035,
29901,
13,
1678,
9995,
29871,
13,
1678,
319,
2560,
14476,
363,
301,
29881,
481,
29941,
297,
385,
10731,
18862,
16738,
29889,
13,
13,
1678,
1222,
9422,
29901,
13,
13,
308,
29900,
29889,
10886,
4233,
675,
263,
3957,
13,
4706,
14610,
353,
12545,
29918,
3035,
29898,
2974,
29918,
978,
543,
2974,
29896,
29889,
1357,
7247,
29889,
510,
613,
8952,
543,
1357,
7247,
29889,
510,
1966,
1315,
29885,
389,
613,
4800,
543,
29966,
25711,
17013,
29958,
1159,
13,
13,
308,
29896,
29889,
3617,
2318,
29898,
29879,
29897,
491,
3514,
10149,
978,
13,
4706,
6471,
353,
14610,
29889,
657,
29918,
328,
2972,
29898,
13445,
10149,
978,
543,
10601,
292,
1159,
13,
13,
308,
29906,
29889,
3617,
4160,
515,
263,
2318,
5172,
13,
4706,
4160,
29918,
3166,
29918,
2972,
353,
14610,
29889,
18837,
29918,
7193,
29918,
3166,
29918,
2972,
29898,
13155,
29961,
29900,
2314,
13,
13,
308,
29941,
29889,
3617,
263,
1404,
491,
3514,
10149,
978,
13,
4706,
1404,
353,
14610,
29889,
657,
29918,
328,
1792,
29898,
13445,
10149,
978,
543,
1315,
29885,
389,
1159,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1923,
29918,
978,
29892,
8952,
29892,
4800,
29892,
671,
29918,
16265,
29922,
5574,
29892,
2322,
29918,
15697,
29922,
9818,
29918,
1299,
29911,
3960,
29933,
2692,
2890,
1125,
13,
4706,
9995,
13,
4706,
4134,
2069,
309,
3950,
29889,
323,
6926,
5164,
301,
29881,
481,
29941,
4426,
322,
1209,
404,
963,
1549,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
1923,
29918,
978,
313,
1807,
1125,
965,
450,
1024,
310,
278,
3646,
301,
29881,
481,
1923,
13,
9651,
8952,
313,
1807,
1125,
795,
4911,
978,
304,
15585,
403,
297,
278,
3402,
29901,
426,
7247,
29918,
978,
1966,
1792,
29918,
978,
1836,
1222,
29901,
518,
1285,
9064,
1966,
1315,
29885,
389,
29962,
13,
9651,
4800,
313,
1807,
1125,
795,
529,
25711,
17013,
29958,
13,
9651,
671,
29918,
16265,
313,
11227,
29892,
13136,
1125,
539,
350,
12772,
304,
17122,
373,
2011,
29871,
29953,
29941,
29953,
322,
881,
367,
1304,
746,
1950,
29889,
13109,
29879,
304,
5852,
29889,
13,
9651,
2322,
29918,
15697,
29901,
632,
317,
1691,
278,
2322,
8393,
304,
679,
363,
385,
1203,
2645,
385,
365,
29928,
3301,
2346,
29892,
13136,
29889,
29871,
13109,
29879,
304,
15149,
29918,
1299,
29911,
3960,
29933,
2692,
2890,
29889,
13,
18884,
1815,
367,
731,
304,
29901,
13,
462,
1678,
15149,
29918,
4590,
1001,
8098,
1964,
29918,
1299,
29911,
3960,
29933,
2692,
2890,
448,
301,
29881,
481,
29941,
5858,
8393,
14476,
13,
462,
1678,
5159,
448,
1939,
8393,
491,
2322,
13,
462,
1678,
6796,
14242,
3284,
4230,
3403,
265,
2539,
3108,
448,
8701,
8393,
13,
4706,
9995,
13,
13,
4706,
1583,
29889,
2974,
353,
5656,
29898,
2974,
29918,
978,
29892,
671,
29918,
16265,
29922,
1509,
29918,
16265,
29892,
679,
29918,
3888,
29922,
9818,
29897,
13,
4706,
1583,
29889,
13082,
353,
15160,
29898,
1311,
29889,
2974,
29892,
4469,
29918,
5355,
29922,
5574,
29892,
1404,
29922,
6786,
29892,
4800,
29922,
5630,
29892,
10760,
29922,
29940,
14632,
29924,
29897,
13,
4706,
1583,
29889,
3188,
29918,
283,
353,
1583,
29889,
2974,
29889,
3888,
29889,
8588,
292,
29918,
4703,
29879,
29961,
29900,
29962,
13,
4706,
1583,
29889,
4381,
29918,
15697,
353,
2322,
29918,
15697,
13,
13,
1678,
822,
679,
29918,
328,
2972,
29898,
1311,
29892,
3514,
10149,
978,
543,
29930,
613,
20660,
978,
543,
29930,
613,
8393,
29922,
8824,
1125,
13,
4706,
9995,
13,
4706,
3617,
385,
11033,
6431,
4669,
515,
263,
4175,
29889,
29871,
13,
4706,
1815,
736,
2999,
2582,
773,
263,
8775,
7543,
525,
29930,
29915,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
3514,
10149,
978,
313,
710,
29892,
13136,
1125,
268,
365,
29928,
3301,
9079,
3514,
10149,
978,
29889,
13109,
29879,
304,
26345,
1642,
13,
9651,
20660,
978,
313,
710,
29892,
13136,
1125,
29871,
365,
29928,
3301,
9079,
20660,
978,
636,
13109,
29879,
304,
26345,
1642,
13,
9651,
8393,
313,
11227,
29892,
13136,
1125,
4706,
8701,
8393,
565,
451,
773,
21274,
29889,
13109,
29879,
304,
7700,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
1203,
29901,
301,
29881,
481,
29941,
5352,
1203,
310,
278,
2318,
29898,
29879,
29897,
13,
4706,
9995,
13,
13,
4706,
565,
29898,
15697,
1275,
7700,
1125,
13,
9651,
8393,
353,
1583,
29889,
4381,
29918,
15697,
13,
13,
4706,
1583,
29889,
13082,
29889,
4478,
29898,
13,
9651,
2740,
29918,
3188,
29922,
1311,
29889,
3188,
29918,
283,
29892,
13,
9651,
2740,
29918,
4572,
29922,
29888,
29915,
6243,
29898,
3318,
10900,
29922,
2972,
5033,
13445,
10149,
978,
3790,
13445,
10149,
978,
1800,
29898,
5721,
6202,
3276,
978,
3790,
5721,
6202,
3276,
978,
20073,
742,
13,
9651,
2740,
29918,
6078,
2433,
20633,
29911,
21661,
742,
13,
9651,
8393,
353,
8393,
13,
4706,
1723,
13,
13,
4706,
736,
1583,
29889,
13082,
29889,
26586,
13,
13,
1678,
822,
679,
29918,
328,
1792,
29898,
1311,
29892,
3514,
10149,
978,
543,
29930,
613,
20660,
978,
543,
29930,
613,
8393,
29922,
8824,
1125,
13,
4706,
9995,
13,
4706,
3617,
385,
11033,
4911,
4669,
515,
263,
4175,
29889,
29871,
13,
4706,
1815,
736,
2999,
2582,
773,
263,
8775,
7543,
525,
29930,
29915,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
3514,
10149,
978,
313,
710,
29892,
13136,
1125,
308,
365,
29928,
3301,
9079,
3514,
10149,
978,
29889,
13109,
29879,
304,
26345,
1642,
13,
9651,
20660,
978,
313,
710,
29892,
13136,
1125,
418,
365,
29928,
3301,
9079,
20660,
978,
636,
13109,
29879,
304,
26345,
1642,
13,
9651,
8393,
313,
11227,
29892,
13136,
1125,
9651,
8701,
8393,
565,
451,
773,
21274,
29889,
13109,
29879,
304,
7700,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
1203,
29901,
301,
29881,
481,
29941,
5352,
1203,
310,
278,
1404,
29898,
29879,
29897,
13,
4706,
9995,
13,
13,
4706,
565,
29898,
15697,
1275,
7700,
1125,
13,
9651,
8393,
353,
1583,
29889,
4381,
29918,
15697,
13,
13,
4706,
1583,
29889,
13082,
29889,
4478,
29898,
13,
9651,
2740,
29918,
3188,
29922,
1311,
29889,
3188,
29918,
283,
29892,
13,
9651,
2740,
29918,
4572,
29922,
29888,
29915,
6243,
29898,
3318,
10900,
29922,
1792,
5033,
13445,
10149,
978,
3790,
13445,
10149,
978,
1800,
29898,
5721,
6202,
3276,
978,
3790,
5721,
6202,
3276,
978,
20073,
742,
13,
9651,
2740,
29918,
6078,
2433,
20633,
29911,
21661,
742,
13,
9651,
8393,
353,
8393,
13,
4706,
1723,
13,
4706,
736,
1583,
29889,
13082,
29889,
26586,
13,
13,
1678,
822,
7985,
29918,
7193,
29918,
3166,
29918,
2972,
29898,
1311,
29892,
2318,
29892,
8393,
29922,
8824,
1125,
13,
4706,
9995,
13,
4706,
319,
1361,
29891,
740,
304,
9098,
7985,
1404,
8393,
515,
263,
2318,
1203,
411,
278,
518,
14242,
29962,
5352,
24146,
29889,
13,
4706,
910,
338,
5407,
746,
366,
817,
304,
679,
5684,
8393,
515,
263,
4160,
297,
263,
2318,
29892,
541,
1016,
29915,
29873,
864,
304,
1106,
963,
701,
363,
1269,
29889,
13,
4706,
910,
23315,
263,
2323,
365,
29928,
3301,
2346,
363,
599,
4160,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
2318,
313,
2972,
1203,
1125,
965,
6431,
1203,
411,
278,
518,
14242,
29962,
5352,
24146,
13,
9651,
8393,
313,
11227,
29892,
13136,
1125,
1678,
8701,
8393,
565,
451,
773,
21274,
29889,
13109,
29879,
304,
7700,
29889,
13,
13,
4706,
390,
1759,
267,
29901,
13,
9651,
8960,
29901,
960,
518,
14242,
29962,
338,
451,
24146,
373,
278,
518,
2972,
29962,
2980,
29892,
3682,
674,
367,
10425,
29889,
13,
13,
4706,
16969,
29901,
13,
9651,
1203,
29901,
2391,
310,
11033,
4160,
411,
1009,
13877,
8393,
13,
13,
4706,
1222,
9422,
29901,
13,
632,
29896,
29889,
12027,
392,
5144,
515,
278,
2318,
376,
10601,
292,
29908,
13,
18884,
14610,
353,
12545,
29918,
3035,
29898,
2974,
29918,
978,
543,
2974,
29896,
29889,
1357,
7247,
29889,
510,
613,
8952,
543,
1357,
7247,
29889,
510,
1966,
1315,
29885,
389,
613,
4800,
543,
29966,
25711,
17013,
29958,
1159,
13,
18884,
6471,
353,
14610,
29889,
657,
29918,
328,
2972,
29898,
13445,
10149,
978,
543,
10601,
292,
1159,
13,
18884,
4160,
29918,
3166,
29918,
2972,
353,
14610,
29889,
18837,
29918,
7193,
29918,
3166,
29918,
2972,
29898,
13155,
29961,
29900,
2314,
13,
4706,
9995,
13,
13,
4706,
565,
451,
756,
5552,
29898,
2972,
29892,
525,
14242,
29374,
13,
9651,
12020,
8960,
703,
4782,
1818,
505,
5352,
518,
14242,
29962,
24146,
23157,
13,
13,
4706,
396,
7211,
403,
8393,
304,
679,
13,
4706,
565,
29898,
15697,
1275,
7700,
1125,
13,
9651,
8393,
353,
1583,
29889,
4381,
29918,
15697,
13,
13,
4706,
396,
8893,
5172,
2346,
297,
3402,
29901,
313,
29989,
29898,
5721,
6202,
3276,
978,
29922,
5200,
29896,
5033,
5721,
6202,
3276,
978,
29922,
5200,
29906,
5033,
856,
876,
13,
4706,
5144,
29918,
430,
481,
29918,
1972,
353,
5124,
13,
4706,
363,
20660,
978,
297,
2318,
29889,
14242,
29901,
13,
9651,
5144,
29918,
430,
481,
29918,
1972,
4619,
285,
29908,
29898,
5721,
6202,
3276,
978,
3790,
5721,
6202,
3276,
978,
1800,
29908,
13,
4706,
5144,
29918,
430,
481,
29918,
1972,
353,
18227,
29989,
29908,
718,
5144,
29918,
430,
481,
29918,
1972,
718,
376,
5513,
13,
462,
13,
4706,
396,
2577,
278,
4160,
13,
4706,
1583,
29889,
13082,
29889,
4478,
29898,
13,
9651,
2740,
29918,
3188,
29922,
1311,
29889,
3188,
29918,
283,
29892,
13,
9651,
2740,
29918,
4572,
29922,
28109,
29918,
430,
481,
29918,
1972,
29892,
13,
9651,
2740,
29918,
6078,
2433,
20633,
29911,
21661,
742,
13,
9651,
8393,
353,
8393,
13,
4706,
1723,
13,
13,
4706,
396,
11609,
2582,
13,
4706,
736,
1583,
29889,
13082,
29889,
26586,
2
] |
examples/plot_allpsd.py | butala/spectrum | 261 | 106429 | <filename>examples/plot_allpsd.py
"""
Spectral analysis of a two frequencies signal
==================================================
"""
###########################################################
# Context
# ----------
##############################################
# Example
# --------
#
# In the following example, we use most of the methods available to
# analyse an input signal made of the addition of two sinus and an
# additive gaussian noise
import numpy
import spectrum
from spectrum import tools
from numpy.testing import assert_array_almost_equal
import pylab
data = spectrum.marple_data
from pylab import *
nn = numpy.arange(200)
xx = cos(0.257*pi*nn) + sin(0.2*pi*nn) + 0.01*randn(size(nn));
def create_all_psd():
f = pylab.linspace(0, 1, 4096)
pylab.figure(figsize=(12,8))
# MA model
p = spectrum.pma(xx, 64,128); p(); p.plot()
"""
#ARMA 15 order
a, b, rho = spectrum.arma_estimate(data, 15,15, 30)
psd = spectrum.arma2psd(A=a,B=b, rho=rho)
newpsd = tools.cshift(psd, len(psd)//2) # switch positive and negative freq
pylab.plot(f, 10 * pylab.log10(newpsd/max(newpsd)), label='ARMA 15,15')
"""
# <NAME>
p = spectrum.pyule(xx, 7 , NFFT=4096, scale_by_freq=False); p.plot()
# equivalent to
# plot([x for x in p.frequencies()] , 10*log10(p.psd)); grid(True)
#burg method
p = spectrum.pburg(xx, 7, scale_by_freq=False); p.plot()
#pcovar
p = spectrum.pcovar(xx, 7, scale_by_freq=False); p.plot()
#pmodcovar
p = spectrum.pmodcovar(xx, 7, scale_by_freq=False); p.plot()
# correlogram
p = spectrum.pcorrelogram(xx, lag=60, NFFT=512, scale_by_freq=False); p.plot()
# minvar
p = spectrum.pminvar(xx, 7, NFFT=256, scale_by_freq=False); p.plot()
# pmusic
p = spectrum.pmusic(xx, 10,4, scale_by_freq=False); p.plot()
# pmusic
p = spectrum.pev(xx, 10, 4, scale_by_freq=False); p.plot()
# periodogram
p = spectrum.Periodogram(xx, scale_by_freq=False); p.plot()
#
legend( ["MA 32", "pyule 7", "pburg 7", "pcovar", "pmodcovar", "correlogram",
"minvar", "pmusic", "pev", "periodgram"])
pylab.ylim([-80,80])
create_all_psd()
| [
1,
529,
9507,
29958,
19057,
29914,
5317,
29918,
497,
567,
29881,
29889,
2272,
13,
15945,
29908,
13,
29903,
1103,
1705,
7418,
310,
263,
1023,
29511,
7182,
13,
9166,
9166,
9166,
1360,
13,
13,
13,
15945,
29908,
13,
13383,
13383,
13383,
7346,
2277,
29937,
13,
29937,
15228,
13,
29937,
448,
1378,
29899,
13,
13,
13383,
13383,
7346,
4136,
2277,
13,
29937,
8741,
29871,
13,
29937,
448,
26589,
13,
29937,
13,
29937,
512,
278,
1494,
1342,
29892,
591,
671,
1556,
310,
278,
3519,
3625,
304,
29871,
13,
29937,
16455,
344,
385,
1881,
7182,
1754,
310,
278,
6124,
310,
1023,
4457,
375,
322,
385,
29871,
13,
29937,
788,
3321,
330,
17019,
11462,
13,
5215,
12655,
13,
5215,
18272,
13,
3166,
18272,
1053,
8492,
13,
3166,
12655,
29889,
13424,
1053,
4974,
29918,
2378,
29918,
284,
3242,
29918,
11745,
13,
5215,
282,
2904,
370,
13,
1272,
353,
18272,
29889,
3034,
552,
29918,
1272,
13,
13,
3166,
282,
2904,
370,
1053,
334,
13,
15755,
353,
12655,
29889,
279,
927,
29898,
29906,
29900,
29900,
29897,
13,
4419,
353,
6776,
29898,
29900,
29889,
29906,
29945,
29955,
29930,
1631,
29930,
15755,
29897,
718,
4457,
29898,
29900,
29889,
29906,
29930,
1631,
29930,
15755,
29897,
718,
29871,
29900,
29889,
29900,
29896,
29930,
9502,
29876,
29898,
2311,
29898,
15755,
2483,
13,
13,
1753,
1653,
29918,
497,
29918,
567,
29881,
7295,
13,
13,
1678,
285,
353,
282,
2904,
370,
29889,
1915,
3493,
29898,
29900,
29892,
29871,
29896,
29892,
29871,
29946,
29900,
29929,
29953,
29897,
13,
13,
1678,
282,
2904,
370,
29889,
4532,
29898,
1003,
2311,
7607,
29896,
29906,
29892,
29947,
876,
13,
13,
1678,
396,
14861,
1904,
13,
1678,
282,
353,
18272,
29889,
29886,
655,
29898,
4419,
29892,
29871,
29953,
29946,
29892,
29896,
29906,
29947,
416,
282,
890,
282,
29889,
5317,
580,
13,
1678,
9995,
13,
1678,
396,
1718,
1529,
29871,
29896,
29945,
1797,
13,
1678,
263,
29892,
289,
29892,
364,
1251,
353,
18272,
29889,
22824,
29918,
342,
6490,
29898,
1272,
29892,
29871,
29896,
29945,
29892,
29896,
29945,
29892,
29871,
29941,
29900,
29897,
13,
1678,
282,
4928,
353,
18272,
29889,
22824,
29906,
567,
29881,
29898,
29909,
29922,
29874,
29892,
29933,
29922,
29890,
29892,
364,
1251,
29922,
4650,
29897,
13,
1678,
716,
567,
29881,
353,
8492,
29889,
29883,
10889,
29898,
567,
29881,
29892,
7431,
29898,
567,
29881,
29897,
458,
29906,
29897,
396,
4607,
6374,
322,
8178,
3005,
29939,
13,
1678,
282,
2904,
370,
29889,
5317,
29898,
29888,
29892,
29871,
29896,
29900,
334,
282,
2904,
370,
29889,
1188,
29896,
29900,
29898,
1482,
567,
29881,
29914,
3317,
29898,
1482,
567,
29881,
8243,
3858,
2433,
1718,
1529,
29871,
29896,
29945,
29892,
29896,
29945,
1495,
13,
1678,
9995,
13,
1678,
396,
529,
5813,
29958,
13,
1678,
282,
353,
18272,
29889,
2272,
1297,
29898,
4419,
29892,
29871,
29955,
1919,
405,
4198,
29911,
29922,
29946,
29900,
29929,
29953,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
282,
29889,
5317,
580,
13,
1678,
396,
7126,
304,
13,
1678,
396,
6492,
4197,
29916,
363,
921,
297,
282,
29889,
10745,
339,
15942,
580,
29962,
1919,
29871,
29896,
29900,
29930,
1188,
29896,
29900,
29898,
29886,
29889,
567,
29881,
2483,
6856,
29898,
5574,
29897,
13,
13,
1678,
396,
3074,
1158,
13,
1678,
282,
353,
18272,
29889,
29886,
3074,
29898,
4419,
29892,
29871,
29955,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
29871,
282,
29889,
5317,
580,
13,
13,
1678,
396,
6739,
586,
279,
13,
1678,
282,
353,
18272,
29889,
6739,
586,
279,
29898,
4419,
29892,
29871,
29955,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
29871,
282,
29889,
5317,
580,
13,
13,
1678,
396,
28871,
24542,
279,
13,
1678,
282,
353,
18272,
29889,
28871,
24542,
279,
29898,
4419,
29892,
29871,
29955,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
282,
29889,
5317,
580,
13,
13,
1678,
396,
14515,
417,
1393,
13,
1678,
282,
353,
18272,
29889,
29886,
2616,
276,
417,
1393,
29898,
4419,
29892,
11755,
29922,
29953,
29900,
29892,
405,
4198,
29911,
29922,
29945,
29896,
29906,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
282,
29889,
5317,
580,
13,
13,
1678,
396,
1375,
1707,
13,
1678,
282,
353,
18272,
29889,
29886,
1195,
1707,
29898,
4419,
29892,
29871,
29955,
29892,
405,
4198,
29911,
29922,
29906,
29945,
29953,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
282,
29889,
5317,
580,
13,
13,
1678,
396,
282,
23596,
13,
1678,
282,
353,
18272,
29889,
3358,
375,
293,
29898,
4419,
29892,
29871,
29896,
29900,
29892,
29946,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
282,
29889,
5317,
580,
13,
13,
1678,
396,
282,
23596,
13,
1678,
282,
353,
18272,
29889,
412,
29894,
29898,
4419,
29892,
29871,
29896,
29900,
29892,
29871,
29946,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
282,
29889,
5317,
580,
13,
13,
1678,
396,
3785,
13342,
13,
1678,
282,
353,
18272,
29889,
29853,
13342,
29898,
4419,
29892,
6287,
29918,
1609,
29918,
29888,
7971,
29922,
8824,
416,
282,
29889,
5317,
580,
13,
13,
1678,
396,
13,
1678,
15983,
29898,
6796,
1529,
29871,
29941,
29906,
613,
376,
2272,
1297,
29871,
29955,
613,
376,
29886,
3074,
29871,
29955,
613,
376,
6739,
586,
279,
613,
376,
28871,
24542,
279,
613,
376,
2616,
276,
417,
1393,
613,
13,
18884,
376,
1195,
1707,
613,
376,
3358,
375,
293,
613,
376,
412,
29894,
613,
376,
19145,
1393,
20068,
13,
13,
13,
1678,
282,
2904,
370,
29889,
29891,
2576,
4197,
29899,
29947,
29900,
29892,
29947,
29900,
2314,
13,
13,
3258,
29918,
497,
29918,
567,
29881,
580,
13,
2
] |
src/LDPC/pycodes/build/lib.cygwin-1.5.10-i686-2.3/pycodes/tests/channel_coding/BEC/small_BEC_test.py | Horacehxw/Multi-label | 1 | 176049 |
import random
from pycodes.utils import CodeMaker
from pycodes.utils.channel_coding_perf import *
from pycodes.utils.channels import BSCOutput
seed = random.getstate()
random.setstate(seed)
print 'using seed',seed
col_w = 3
row_w = 6
N = 1002
K = N*col_w/row_w
E = (N-K)*row_w
L = CodeMaker.make_H_gallager(N,col_w,row_w)
erasureProb = [0.4, 0.375, 0.35, 0.325]
numTrials = [250]*len(erasureProb)
maxIter = 20
tester = Tester([CodeParams(N,K,E,L,'small test','erasures',erasureProb,
BECOutput,numTrials,maxIter,algorithm='default')])
tester.ReportStats(title='Small BEC test for code of length %i' % N,
reportFile='/tmp/small_BEC_test_results.py',
imgFile='/tmp/small_BEC_test_results.eps')
| [
1,
29871,
13,
5215,
4036,
13,
3166,
282,
11078,
2631,
29889,
13239,
1053,
5920,
29924,
5790,
13,
3166,
282,
11078,
2631,
29889,
13239,
29889,
12719,
29918,
29883,
3689,
29918,
546,
29888,
1053,
334,
13,
3166,
282,
11078,
2631,
29889,
13239,
29889,
305,
12629,
1053,
350,
29903,
3217,
329,
649,
13,
13,
26776,
353,
4036,
29889,
657,
3859,
580,
13,
8172,
29889,
842,
3859,
29898,
26776,
29897,
13,
2158,
525,
4746,
16717,
742,
26776,
13,
13,
1054,
29918,
29893,
353,
29871,
29941,
13,
798,
29918,
29893,
353,
29871,
29953,
13,
29940,
353,
29871,
29896,
29900,
29900,
29906,
13,
29968,
353,
405,
29930,
1054,
29918,
29893,
29914,
798,
29918,
29893,
13,
29923,
353,
313,
29940,
29899,
29968,
11877,
798,
29918,
29893,
13,
29931,
353,
5920,
29924,
5790,
29889,
5675,
29918,
29950,
29918,
29887,
497,
1875,
29898,
29940,
29892,
1054,
29918,
29893,
29892,
798,
29918,
29893,
29897,
13,
13,
261,
3745,
1184,
29890,
353,
518,
29900,
29889,
29946,
29892,
29871,
29900,
29889,
29941,
29955,
29945,
29892,
29871,
29900,
29889,
29941,
29945,
29892,
29871,
29900,
29889,
29941,
29906,
29945,
29962,
13,
1949,
29565,
1338,
353,
518,
29906,
29945,
29900,
14178,
2435,
29898,
261,
3745,
1184,
29890,
29897,
13,
3317,
13463,
353,
29871,
29906,
29900,
13,
13,
1688,
261,
353,
323,
4156,
4197,
3399,
9629,
29898,
29940,
29892,
29968,
29892,
29923,
29892,
29931,
5501,
9278,
1243,
3788,
18464,
1973,
742,
261,
3745,
1184,
29890,
29892,
13,
462,
9651,
20700,
3217,
329,
649,
29892,
1949,
29565,
1338,
29892,
3317,
13463,
29892,
20567,
2433,
4381,
1495,
2314,
13,
1688,
261,
29889,
13020,
25060,
29898,
3257,
2433,
12636,
497,
350,
11206,
1243,
363,
775,
310,
3309,
1273,
29875,
29915,
1273,
405,
29892,
13,
462,
259,
3461,
2283,
2433,
29914,
7050,
29914,
9278,
29918,
29933,
11206,
29918,
1688,
29918,
9902,
29889,
2272,
742,
13,
462,
259,
10153,
2283,
2433,
29914,
7050,
29914,
9278,
29918,
29933,
11206,
29918,
1688,
29918,
9902,
29889,
8961,
1495,
13,
13,
2
] |
recurrent_neural_networks/hopfield_network.py | sgalella/RecurrentNeuralNetworks | 0 | 41440 | import numpy as np
import matplotlib.pyplot as plt
from utils import get_state_vowel
class HopfieldNetwork:
"""
Creates a Hopfield Network.
"""
def __init__(self, patterns):
"""
Initializes the network.
Args:
patterns (np.array): Group of states to be memorized by the network.
"""
self.num_units = patterns.shape[1]
self.passes = 0
self.state_units = np.array([1 if 2 * np.random.random() - 1 >= 0 else 0 for _ in range(self.num_units)])
self.W = np.zeros((self.num_units, self.num_units))
for pattern in patterns:
self.W += np.dot(np.transpose((2 * patterns - 1)), (2 * patterns - 1))
np.fill_diagonal(self.W, 0)
self.energy = [-0.5 * np.dot(np.dot(self.state_units.T, self.W), self.state_units)]
def _generate_sequence_units(self):
""" Selects randomly the order to update states in the next iteration."""
return np.random.choice(self.num_units, self.num_units)
def run(self):
""" Runs the network until no updates occur. """
no_update = True
while True:
for unit in self._generate_sequence_units():
unit_activation = np.dot(self.W[unit, :], self.state_units)
if unit_activation >= 0 and self.state_units[unit] == 0:
self.state_units[unit] = 1
no_update = False
elif unit_activation < 0 and self.state_units[unit] == 1:
self.state_units[unit] = 0
no_update = False
self.energy.append(-0.5 * np.dot(np.dot(self.state_units.T, self.W), self.state_units))
self.passes += 1
if no_update:
break
else:
no_update = True
def main():
np.random.seed(1234)
patterns = np.array([get_state_vowel('A'),
get_state_vowel('E'),
get_state_vowel('I'),
get_state_vowel('O'),
get_state_vowel('U')])
net = HopfieldNetwork(patterns)
net.run()
# Plot patterns and output
plt.figure(figsize=(6, 3), tight_layout=True)
plt.subplot(2, 3, 1)
plt.imshow(np.reshape(patterns[0, :], (5, 5)), cmap="Greys_r")
plt.title("A")
plt.subplot(2, 3, 2)
plt.imshow(np.reshape(patterns[1, :], (5, 5)), cmap="Greys_r")
plt.title("E")
plt.subplot(2, 3, 3)
plt.imshow(np.reshape(patterns[2, :], (5, 5)), cmap="Greys_r")
plt.title("I")
plt.subplot(2, 3, 4)
plt.imshow(np.reshape(patterns[3, :], (5, 5)), cmap="Greys_r")
plt.title("O")
plt.subplot(2, 3, 5)
plt.imshow(np.reshape(patterns[4, :], (5, 5)), cmap="Greys_r")
plt.title("U")
plt.subplot(2, 3, 6)
plt.imshow(np.reshape(net.state_units, (5, 5)), cmap="Greys_r")
plt.title("Output")
# Plot energy over time
plt.figure(figsize=(4, 2))
plt.plot(net.energy)
plt.title("Energy")
plt.show()
if __name__ == "__main__":
main()
| [
1,
1053,
12655,
408,
7442,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
3166,
3667,
29879,
1053,
679,
29918,
3859,
29918,
29894,
27531,
13,
13,
13,
1990,
20727,
2671,
13724,
29901,
13,
1678,
9995,
13,
1678,
6760,
1078,
263,
20727,
2671,
8527,
29889,
13,
1678,
9995,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
15038,
1125,
13,
4706,
9995,
13,
4706,
17250,
7093,
278,
3564,
29889,
13,
13,
4706,
826,
3174,
29901,
13,
9651,
15038,
313,
9302,
29889,
2378,
1125,
6431,
310,
5922,
304,
367,
26959,
1891,
491,
278,
3564,
29889,
13,
13,
4706,
9995,
13,
4706,
1583,
29889,
1949,
29918,
348,
1169,
353,
15038,
29889,
12181,
29961,
29896,
29962,
13,
4706,
1583,
29889,
3364,
267,
353,
29871,
29900,
13,
4706,
1583,
29889,
3859,
29918,
348,
1169,
353,
7442,
29889,
2378,
4197,
29896,
565,
29871,
29906,
334,
7442,
29889,
8172,
29889,
8172,
580,
448,
29871,
29896,
6736,
29871,
29900,
1683,
29871,
29900,
363,
903,
297,
3464,
29898,
1311,
29889,
1949,
29918,
348,
1169,
29897,
2314,
13,
4706,
1583,
29889,
29956,
353,
7442,
29889,
3298,
359,
3552,
1311,
29889,
1949,
29918,
348,
1169,
29892,
1583,
29889,
1949,
29918,
348,
1169,
876,
13,
4706,
363,
4766,
297,
15038,
29901,
13,
9651,
1583,
29889,
29956,
4619,
7442,
29889,
6333,
29898,
9302,
29889,
3286,
4220,
3552,
29906,
334,
15038,
448,
29871,
29896,
8243,
313,
29906,
334,
15038,
448,
29871,
29896,
876,
13,
4706,
7442,
29889,
5589,
29918,
6051,
351,
7177,
29898,
1311,
29889,
29956,
29892,
29871,
29900,
29897,
13,
4706,
1583,
29889,
27548,
353,
21069,
29900,
29889,
29945,
334,
7442,
29889,
6333,
29898,
9302,
29889,
6333,
29898,
1311,
29889,
3859,
29918,
348,
1169,
29889,
29911,
29892,
1583,
29889,
29956,
511,
1583,
29889,
3859,
29918,
348,
1169,
4638,
13,
13,
1678,
822,
903,
17158,
29918,
16506,
29918,
348,
1169,
29898,
1311,
1125,
13,
4706,
9995,
7605,
29879,
20459,
278,
1797,
304,
2767,
5922,
297,
278,
2446,
12541,
1213,
15945,
13,
4706,
736,
7442,
29889,
8172,
29889,
16957,
29898,
1311,
29889,
1949,
29918,
348,
1169,
29892,
1583,
29889,
1949,
29918,
348,
1169,
29897,
13,
13,
1678,
822,
1065,
29898,
1311,
1125,
13,
4706,
9995,
390,
6948,
278,
3564,
2745,
694,
11217,
6403,
29889,
9995,
13,
4706,
694,
29918,
5504,
353,
5852,
13,
4706,
1550,
5852,
29901,
13,
9651,
363,
5190,
297,
1583,
3032,
17158,
29918,
16506,
29918,
348,
1169,
7295,
13,
18884,
5190,
29918,
11236,
362,
353,
7442,
29889,
6333,
29898,
1311,
29889,
29956,
29961,
5441,
29892,
584,
1402,
1583,
29889,
3859,
29918,
348,
1169,
29897,
13,
18884,
565,
5190,
29918,
11236,
362,
6736,
29871,
29900,
322,
1583,
29889,
3859,
29918,
348,
1169,
29961,
5441,
29962,
1275,
29871,
29900,
29901,
13,
462,
1678,
1583,
29889,
3859,
29918,
348,
1169,
29961,
5441,
29962,
353,
29871,
29896,
13,
462,
1678,
694,
29918,
5504,
353,
7700,
13,
18884,
25342,
5190,
29918,
11236,
362,
529,
29871,
29900,
322,
1583,
29889,
3859,
29918,
348,
1169,
29961,
5441,
29962,
1275,
29871,
29896,
29901,
13,
462,
1678,
1583,
29889,
3859,
29918,
348,
1169,
29961,
5441,
29962,
353,
29871,
29900,
13,
462,
1678,
694,
29918,
5504,
353,
7700,
13,
18884,
1583,
29889,
27548,
29889,
4397,
6278,
29900,
29889,
29945,
334,
7442,
29889,
6333,
29898,
9302,
29889,
6333,
29898,
1311,
29889,
3859,
29918,
348,
1169,
29889,
29911,
29892,
1583,
29889,
29956,
511,
1583,
29889,
3859,
29918,
348,
1169,
876,
13,
9651,
1583,
29889,
3364,
267,
4619,
29871,
29896,
13,
9651,
565,
694,
29918,
5504,
29901,
13,
18884,
2867,
13,
9651,
1683,
29901,
13,
18884,
694,
29918,
5504,
353,
5852,
13,
13,
13,
1753,
1667,
7295,
13,
1678,
7442,
29889,
8172,
29889,
26776,
29898,
29896,
29906,
29941,
29946,
29897,
13,
1678,
15038,
353,
7442,
29889,
2378,
4197,
657,
29918,
3859,
29918,
29894,
27531,
877,
29909,
5477,
13,
462,
308,
679,
29918,
3859,
29918,
29894,
27531,
877,
29923,
5477,
13,
462,
308,
679,
29918,
3859,
29918,
29894,
27531,
877,
29902,
5477,
13,
462,
308,
679,
29918,
3859,
29918,
29894,
27531,
877,
29949,
5477,
13,
462,
308,
679,
29918,
3859,
29918,
29894,
27531,
877,
29965,
1495,
2314,
13,
1678,
7787,
353,
20727,
2671,
13724,
29898,
11037,
29879,
29897,
13,
1678,
7787,
29889,
3389,
580,
13,
13,
1678,
396,
18399,
15038,
322,
1962,
13,
1678,
14770,
29889,
4532,
29898,
1003,
2311,
7607,
29953,
29892,
29871,
29941,
511,
19932,
29918,
2680,
29922,
5574,
29897,
13,
1678,
14770,
29889,
1491,
5317,
29898,
29906,
29892,
29871,
29941,
29892,
29871,
29896,
29897,
13,
1678,
14770,
29889,
326,
4294,
29898,
9302,
29889,
690,
14443,
29898,
11037,
29879,
29961,
29900,
29892,
584,
1402,
313,
29945,
29892,
29871,
29945,
8243,
274,
1958,
543,
25120,
952,
29918,
29878,
1159,
13,
1678,
14770,
29889,
3257,
703,
29909,
1159,
13,
1678,
14770,
29889,
1491,
5317,
29898,
29906,
29892,
29871,
29941,
29892,
29871,
29906,
29897,
13,
1678,
14770,
29889,
326,
4294,
29898,
9302,
29889,
690,
14443,
29898,
11037,
29879,
29961,
29896,
29892,
584,
1402,
313,
29945,
29892,
29871,
29945,
8243,
274,
1958,
543,
25120,
952,
29918,
29878,
1159,
13,
1678,
14770,
29889,
3257,
703,
29923,
1159,
13,
1678,
14770,
29889,
1491,
5317,
29898,
29906,
29892,
29871,
29941,
29892,
29871,
29941,
29897,
13,
1678,
14770,
29889,
326,
4294,
29898,
9302,
29889,
690,
14443,
29898,
11037,
29879,
29961,
29906,
29892,
584,
1402,
313,
29945,
29892,
29871,
29945,
8243,
274,
1958,
543,
25120,
952,
29918,
29878,
1159,
13,
1678,
14770,
29889,
3257,
703,
29902,
1159,
13,
1678,
14770,
29889,
1491,
5317,
29898,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
29897,
13,
1678,
14770,
29889,
326,
4294,
29898,
9302,
29889,
690,
14443,
29898,
11037,
29879,
29961,
29941,
29892,
584,
1402,
313,
29945,
29892,
29871,
29945,
8243,
274,
1958,
543,
25120,
952,
29918,
29878,
1159,
13,
1678,
14770,
29889,
3257,
703,
29949,
1159,
13,
1678,
14770,
29889,
1491,
5317,
29898,
29906,
29892,
29871,
29941,
29892,
29871,
29945,
29897,
13,
1678,
14770,
29889,
326,
4294,
29898,
9302,
29889,
690,
14443,
29898,
11037,
29879,
29961,
29946,
29892,
584,
1402,
313,
29945,
29892,
29871,
29945,
8243,
274,
1958,
543,
25120,
952,
29918,
29878,
1159,
13,
1678,
14770,
29889,
3257,
703,
29965,
1159,
13,
1678,
14770,
29889,
1491,
5317,
29898,
29906,
29892,
29871,
29941,
29892,
29871,
29953,
29897,
13,
1678,
14770,
29889,
326,
4294,
29898,
9302,
29889,
690,
14443,
29898,
1212,
29889,
3859,
29918,
348,
1169,
29892,
313,
29945,
29892,
29871,
29945,
8243,
274,
1958,
543,
25120,
952,
29918,
29878,
1159,
13,
1678,
14770,
29889,
3257,
703,
6466,
1159,
13,
13,
1678,
396,
18399,
5864,
975,
931,
13,
1678,
14770,
29889,
4532,
29898,
1003,
2311,
7607,
29946,
29892,
29871,
29906,
876,
13,
1678,
14770,
29889,
5317,
29898,
1212,
29889,
27548,
29897,
13,
1678,
14770,
29889,
3257,
703,
29923,
1089,
1927,
1159,
13,
1678,
14770,
29889,
4294,
580,
13,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
1667,
580,
13,
2
] |
Scripts/web_scraping_api.py | ElizaBedoyaZapata/Proyecto-Principal-PowerBI | 0 | 66626 | <gh_stars>0
import pandas as pd
from sodapy import Socrata
from selenium import webdriver
#from selenium.webdriver.support.ui import Select
# Links file
links = pd.read_excel('..\Inputs\enlaces.xlsx', engine='openpyxl')
# Chrome path to web scraping
chrome_path = r"C:\Users\kmili\Downloads\chromedriver_win32\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
# Download data: Fiscal - Tasa cupon cero
tasa_cupon_cero = links.loc[19, 'Fuente']
driver.get(tasa_cupon_cero)
driver.find_element_by_xpath("//*[@id='saw_766908_3']/option[text()='tableView!3']").click()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
11701,
408,
10518,
30004,
13,
3166,
20892,
27580,
1053,
317,
8415,
532,
30004,
13,
3166,
18866,
1053,
1856,
9465,
30004,
13,
29937,
3166,
18866,
29889,
29813,
29889,
5924,
29889,
1481,
1053,
7605,
30004,
13,
30004,
13,
29937,
6645,
29879,
934,
30004,
13,
4965,
353,
10518,
29889,
949,
29918,
24633,
877,
636,
29905,
4290,
29879,
29905,
264,
6048,
29889,
20267,
29916,
742,
6012,
2433,
3150,
2272,
15524,
1495,
30004,
13,
30004,
13,
30004,
13,
29937,
10228,
2224,
304,
1856,
885,
2390,
292,
30004,
13,
18114,
29918,
2084,
353,
364,
29908,
29907,
3583,
5959,
29905,
8848,
2638,
29905,
6767,
18132,
29905,
27433,
287,
3511,
29918,
5080,
29941,
29906,
29905,
27433,
287,
3511,
29889,
8097,
19451,
13,
9465,
353,
1856,
9465,
29889,
1451,
4871,
29898,
18114,
29918,
2084,
8443,
13,
30004,
13,
30004,
13,
29937,
25553,
848,
29901,
383,
275,
1052,
448,
323,
11290,
18002,
265,
274,
1489,
30004,
13,
29873,
11290,
29918,
5231,
265,
29918,
29883,
1489,
353,
2988,
29889,
2029,
29961,
29896,
29929,
29892,
525,
29943,
29884,
2016,
2033,
30004,
13,
9465,
29889,
657,
29898,
29873,
11290,
29918,
5231,
265,
29918,
29883,
1489,
8443,
13,
30004,
13,
9465,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
23635,
703,
458,
29930,
17548,
333,
2433,
29879,
1450,
29918,
29955,
29953,
29953,
29929,
29900,
29947,
29918,
29941,
2033,
29914,
3385,
29961,
726,
580,
2433,
18125,
29991,
29941,
2033,
2564,
3808,
26471,
13,
30004,
13,
2
] |
LeetCode/0044_Wildcard_Matching.py | scott-au/PythonAlgorithms | 0 | 22273 | class Solution:
def isMatch(self, s: str, p: str) -> bool:
# this is a dynamic programming solution fot this
matrix = [[False for x in range(len(p) + 1)] for x in range(len(s) + 1)]
matrix[0][0] = True
for i in range(1, len(matrix[0])):
if p[i - 1] == "*":
matrix[0][i] = matrix[0][i - 1]
for i in range(1, len(matrix)):
for j in range(1, len(matrix[0])):
if s[i - 1] == p[j - 1] or p[j - 1] == "?":
matrix[i][j] = matrix[i - 1][j - 1]
elif p[j - 1] == "*":
matrix[i][j] = matrix[i][j - 1] or matrix[i - 1][j]
else:
matrix[i][j] = False
return matrix[len(s)][len(p)]
| [
1,
770,
24380,
29901,
13,
1678,
822,
338,
9652,
29898,
1311,
29892,
269,
29901,
851,
29892,
282,
29901,
851,
29897,
1599,
6120,
29901,
13,
4706,
396,
445,
338,
263,
7343,
8720,
1650,
10105,
445,
13,
4706,
4636,
353,
5519,
8824,
363,
921,
297,
3464,
29898,
2435,
29898,
29886,
29897,
718,
29871,
29896,
4638,
363,
921,
297,
3464,
29898,
2435,
29898,
29879,
29897,
718,
29871,
29896,
4638,
13,
4706,
4636,
29961,
29900,
3816,
29900,
29962,
353,
5852,
13,
13,
4706,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
5344,
29961,
29900,
12622,
29901,
13,
9651,
565,
282,
29961,
29875,
448,
29871,
29896,
29962,
1275,
26345,
1115,
13,
18884,
4636,
29961,
29900,
3816,
29875,
29962,
353,
4636,
29961,
29900,
3816,
29875,
448,
29871,
29896,
29962,
13,
13,
4706,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
5344,
22164,
13,
9651,
363,
432,
297,
3464,
29898,
29896,
29892,
7431,
29898,
5344,
29961,
29900,
12622,
29901,
13,
18884,
565,
269,
29961,
29875,
448,
29871,
29896,
29962,
1275,
282,
29961,
29926,
448,
29871,
29896,
29962,
470,
282,
29961,
29926,
448,
29871,
29896,
29962,
1275,
376,
29973,
1115,
13,
462,
1678,
4636,
29961,
29875,
3816,
29926,
29962,
353,
4636,
29961,
29875,
448,
29871,
29896,
3816,
29926,
448,
29871,
29896,
29962,
13,
18884,
25342,
282,
29961,
29926,
448,
29871,
29896,
29962,
1275,
26345,
1115,
13,
462,
1678,
4636,
29961,
29875,
3816,
29926,
29962,
353,
4636,
29961,
29875,
3816,
29926,
448,
29871,
29896,
29962,
470,
4636,
29961,
29875,
448,
29871,
29896,
3816,
29926,
29962,
13,
18884,
1683,
29901,
13,
462,
1678,
4636,
29961,
29875,
3816,
29926,
29962,
353,
7700,
13,
4706,
736,
4636,
29961,
2435,
29898,
29879,
29897,
3816,
2435,
29898,
29886,
4638,
13,
2
] |
src/main.py | Grant-Steinfeld/python-ubi-openshift | 7 | 20059 | from flask import Flask
from flask_restplus import Api, Resource, fields
from services.serviceHandler import convertCurrency, getCurrencyExchangeRates
from services.countryCurrencyCodeHandler import (
getCountryAndCurrencyCode,
getCurrencyNameAndCode,
)
app = Flask(__name__)
api = Api(
app,
version="1.0.0",
title="Bee Travels Currency Data Service",
description="This is a microservice that handles currency exchange rate data for Bee Travels",
)
currencyNS = api.namespace(
"Currency",
description="Operations associated with currency exchange rate conversions",
)
currencyNameOrCurrencyCode = api.model(
"currencyNameOrCurrencyCode",
{
"currencyCode": fields.String(
required=False, description="3 letter currency code"
),
"country": fields.String(required=False, description="country name"),
},
)
@currencyNS.route("/")
class CurrencyList(Resource):
"""Shows a list of currency ex rates"""
def get(self):
return getCurrencyExchangeRates()
# /currency/{currencyFromAmount}/{currencyFromCode}/{currencyToCode}
# /currency/10/EUR/USD
@currencyNS.route("/<int:currencyFromAmount>/<currencyFromCode>/<currencyToCode>")
@currencyNS.response(404, "Currency Code not found")
@currencyNS.param("currencyFromAmount", "currency to convert from value (float)")
@currencyNS.param("currencyFromCode", "currency (3 character code) to convert from")
@currencyNS.param("currencyToCode", "currency (3 character code) to convert to")
class Currency(Resource):
def get(self, currencyFromAmount, currencyFromCode, currencyToCode):
result = convertCurrency(
float(currencyFromAmount), currencyFromCode, currencyToCode
)
return {"result": result}
@currencyNS.route("/search")
@currencyNS.response(404, "Currency Code not found")
class Search(Resource):
@currencyNS.doc("search_currency_meta")
@currencyNS.expect(currencyNameOrCurrencyCode)
@currencyNS.marshal_with(currencyNameOrCurrencyCode, code=201)
def post(self):
if "currencyCode" in api.payload:
return getCountryAndCurrencyCode(api.payload["currencyCode"])
elif "country" in api.payload:
return getCurrencyNameAndCode(api.payload["country"])
else:
api.abort(400, "Pass in either the currencyCode or country name")
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True, port=7878)
| [
1,
515,
29784,
1053,
2379,
1278,
13,
3166,
29784,
29918,
5060,
11242,
1053,
29749,
29892,
18981,
29892,
4235,
13,
3166,
5786,
29889,
5509,
4598,
1053,
3588,
29907,
10880,
29892,
679,
29907,
10880,
1252,
3167,
29934,
1078,
13,
3166,
5786,
29889,
13509,
29907,
10880,
3399,
4598,
1053,
313,
13,
1678,
679,
20779,
2855,
29907,
10880,
3399,
29892,
13,
1678,
679,
29907,
10880,
1170,
2855,
3399,
29892,
13,
29897,
13,
13,
932,
353,
2379,
1278,
22168,
978,
1649,
29897,
13,
2754,
353,
29749,
29898,
13,
1678,
623,
29892,
13,
1678,
1873,
543,
29896,
29889,
29900,
29889,
29900,
613,
13,
1678,
3611,
543,
3629,
29872,
3201,
955,
29879,
315,
10880,
3630,
6692,
613,
13,
1678,
6139,
543,
4013,
338,
263,
9200,
5509,
393,
17766,
27550,
14523,
6554,
848,
363,
1522,
29872,
3201,
955,
29879,
613,
13,
29897,
13,
13,
26095,
3059,
353,
7882,
29889,
22377,
29898,
13,
1678,
376,
29907,
10880,
613,
13,
1678,
6139,
543,
7094,
800,
6942,
411,
27550,
14523,
6554,
9678,
1080,
613,
13,
29897,
13,
13,
13,
26095,
1170,
2816,
29907,
10880,
3399,
353,
7882,
29889,
4299,
29898,
13,
1678,
376,
26095,
1170,
2816,
29907,
10880,
3399,
613,
13,
1678,
426,
13,
4706,
376,
26095,
3399,
1115,
4235,
29889,
1231,
29898,
13,
9651,
3734,
29922,
8824,
29892,
6139,
543,
29941,
5497,
27550,
775,
29908,
13,
4706,
10353,
13,
4706,
376,
13509,
1115,
4235,
29889,
1231,
29898,
12403,
29922,
8824,
29892,
6139,
543,
13509,
1024,
4968,
13,
1678,
2981,
13,
29897,
13,
13,
13,
29992,
26095,
3059,
29889,
13134,
11974,
1159,
13,
1990,
315,
10880,
1293,
29898,
6848,
1125,
13,
1678,
9995,
2713,
1242,
263,
1051,
310,
27550,
429,
19257,
15945,
29908,
13,
13,
1678,
822,
679,
29898,
1311,
1125,
13,
4706,
736,
679,
29907,
10880,
1252,
3167,
29934,
1078,
580,
13,
13,
13,
29937,
29871,
847,
26095,
19248,
26095,
4591,
18087,
6822,
29912,
26095,
4591,
3399,
6822,
29912,
26095,
1762,
3399,
29913,
13,
29937,
29871,
847,
26095,
29914,
29896,
29900,
29914,
29923,
4574,
29914,
3308,
29928,
13,
13,
13,
29992,
26095,
3059,
29889,
13134,
11974,
29966,
524,
29901,
26095,
4591,
18087,
20690,
29966,
26095,
4591,
3399,
20690,
29966,
26095,
1762,
3399,
29958,
1159,
13,
29992,
26095,
3059,
29889,
5327,
29898,
29946,
29900,
29946,
29892,
376,
29907,
10880,
5920,
451,
1476,
1159,
13,
29992,
26095,
3059,
29889,
3207,
703,
26095,
4591,
18087,
613,
376,
26095,
304,
3588,
515,
995,
313,
7411,
25760,
13,
29992,
26095,
3059,
29889,
3207,
703,
26095,
4591,
3399,
613,
376,
26095,
313,
29941,
2931,
775,
29897,
304,
3588,
515,
1159,
13,
29992,
26095,
3059,
29889,
3207,
703,
26095,
1762,
3399,
613,
376,
26095,
313,
29941,
2931,
775,
29897,
304,
3588,
304,
1159,
13,
1990,
315,
10880,
29898,
6848,
1125,
13,
1678,
822,
679,
29898,
1311,
29892,
27550,
4591,
18087,
29892,
27550,
4591,
3399,
29892,
27550,
1762,
3399,
1125,
13,
13,
4706,
1121,
353,
3588,
29907,
10880,
29898,
13,
9651,
5785,
29898,
26095,
4591,
18087,
511,
27550,
4591,
3399,
29892,
27550,
1762,
3399,
13,
4706,
1723,
13,
4706,
736,
8853,
2914,
1115,
1121,
29913,
13,
13,
13,
29992,
26095,
3059,
29889,
13134,
11974,
4478,
1159,
13,
29992,
26095,
3059,
29889,
5327,
29898,
29946,
29900,
29946,
29892,
376,
29907,
10880,
5920,
451,
1476,
1159,
13,
1990,
11856,
29898,
6848,
1125,
13,
1678,
732,
26095,
3059,
29889,
1514,
703,
4478,
29918,
26095,
29918,
7299,
1159,
13,
1678,
732,
26095,
3059,
29889,
17854,
29898,
26095,
1170,
2816,
29907,
10880,
3399,
29897,
13,
1678,
732,
26095,
3059,
29889,
3034,
23258,
29918,
2541,
29898,
26095,
1170,
2816,
29907,
10880,
3399,
29892,
775,
29922,
29906,
29900,
29896,
29897,
13,
1678,
822,
1400,
29898,
1311,
1125,
13,
4706,
565,
376,
26095,
3399,
29908,
297,
7882,
29889,
23813,
29901,
13,
9651,
736,
679,
20779,
2855,
29907,
10880,
3399,
29898,
2754,
29889,
23813,
3366,
26095,
3399,
20068,
13,
4706,
25342,
376,
13509,
29908,
297,
7882,
29889,
23813,
29901,
13,
9651,
736,
679,
29907,
10880,
1170,
2855,
3399,
29898,
2754,
29889,
23813,
3366,
13509,
20068,
13,
4706,
1683,
29901,
13,
9651,
7882,
29889,
370,
441,
29898,
29946,
29900,
29900,
29892,
376,
7129,
297,
2845,
278,
27550,
3399,
470,
4234,
1024,
1159,
13,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
623,
29889,
3389,
29898,
3069,
543,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
613,
4744,
29922,
5574,
29892,
2011,
29922,
29955,
29947,
29955,
29947,
29897,
13,
2
] |
trpg/registration/utility.py | jffifa/trpg | 2 | 52037 | from django.conf import settings
def decrypt(text):
half_len = len(text)//2
return text[half_len:]
| [
1,
515,
9557,
29889,
5527,
1053,
6055,
30004,
13,
30004,
13,
30004,
13,
1753,
1602,
4641,
29898,
726,
1125,
30004,
13,
1678,
4203,
29918,
2435,
353,
7431,
29898,
726,
29897,
458,
29906,
30004,
13,
1678,
736,
1426,
29961,
24498,
29918,
2435,
17531,
30004,
13,
30004,
13,
2
] |
corehq/apps/analytics/signals.py | kkrampa/commcare-hq | 1 | 17659 | <reponame>kkrampa/commcare-hq
from __future__ import absolute_import
from __future__ import unicode_literals
import six
from django.conf import settings
from django.contrib.auth.signals import user_logged_in
from corehq.apps.analytics.tasks import (
track_user_sign_in_on_hubspot,
HUBSPOT_COOKIE,
update_hubspot_properties,
identify,
update_subscription_properties_by_domain, get_subscription_properties_by_user)
from corehq.apps.analytics.utils import get_meta
from corehq.apps.registration.views import ProcessRegistrationView
from corehq.util.decorators import handle_uncaught_exceptions
from corehq.util.python_compatibility import soft_assert_type_text
from corehq.util.soft_assert import soft_assert
from django.dispatch import receiver
from django.urls import reverse
from corehq.apps.users.models import CouchUser
from corehq.apps.accounting.signals import subscription_upgrade_or_downgrade
from corehq.apps.domain.signals import commcare_domain_post_save
from corehq.apps.users.signals import couch_user_post_save
from corehq.apps.analytics.utils import get_instance_string
_no_cookie_soft_assert = soft_assert(to=['{}<EMAIL>('<EMAIL>', '<EMAIL>'),
<EMAIL>('<EMAIL>', '<EMAIL>'),
<EMAIL>('<EMAIL>', '<EMAIL>')],
send_to_ops=False)
@receiver(couch_user_post_save)
def user_save_callback(sender, **kwargs):
couch_user = kwargs.get("couch_user", None)
if couch_user and couch_user.is_web_user():
properties = {}
properties.update(get_subscription_properties_by_user(couch_user))
properties.update(get_domain_membership_properties(couch_user))
identify.delay(couch_user.username, properties)
update_hubspot_properties.delay(couch_user, properties)
@receiver(commcare_domain_post_save)
@receiver(subscription_upgrade_or_downgrade)
def domain_save_callback(sender, domain, **kwargs):
if isinstance(domain, six.string_types):
soft_assert_type_text(domain)
domain_name = domain
else:
domain_name = domain.name
update_subscription_properties_by_domain(domain_name)
def get_domain_membership_properties(couch_user):
env = get_instance_string()
return {
"{}number_of_project_spaces".format(env): len(couch_user.domains),
"{}project_spaces_list".format(env): '\n'.join(couch_user.domains),
}
@receiver(user_logged_in)
@handle_uncaught_exceptions(mail_admins=True)
def track_user_login(sender, request, user, **kwargs):
if settings.ANALYTICS_IDS.get('HUBSPOT_API_ID'):
couch_user = CouchUser.from_django_user(user)
if couch_user and couch_user.is_web_user():
if not request or HUBSPOT_COOKIE not in request.COOKIES:
# API calls, form submissions etc.
user_confirming = request.path.startswith(reverse(ProcessRegistrationView.urlname))
if user_confirming:
_no_cookie_soft_assert(False, 'User confirmed account but had no cookie')
else:
return
meta = get_meta(request)
track_user_sign_in_on_hubspot.delay(couch_user, request.COOKIES.get(HUBSPOT_COOKIE),
meta, request.path)
| [
1,
529,
276,
1112,
420,
29958,
6859,
29878,
20056,
29914,
2055,
18020,
29899,
29882,
29939,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
5215,
4832,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
3166,
9557,
29889,
21570,
29889,
5150,
29889,
4530,
1338,
1053,
1404,
29918,
1188,
3192,
29918,
262,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
7054,
22026,
29889,
20673,
1053,
313,
13,
1678,
5702,
29918,
1792,
29918,
4530,
29918,
262,
29918,
265,
29918,
29882,
431,
17500,
29892,
13,
1678,
379,
7466,
5550,
2891,
29918,
3217,
8949,
8673,
29892,
13,
1678,
2767,
29918,
29882,
431,
17500,
29918,
11330,
29892,
13,
1678,
12439,
29892,
13,
1678,
2767,
29918,
1491,
22371,
29918,
11330,
29918,
1609,
29918,
7247,
29892,
679,
29918,
1491,
22371,
29918,
11330,
29918,
1609,
29918,
1792,
29897,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
7054,
22026,
29889,
13239,
1053,
679,
29918,
7299,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
1727,
8306,
29889,
7406,
1053,
10554,
4597,
8306,
1043,
13,
3166,
7136,
29882,
29939,
29889,
4422,
29889,
19557,
4097,
1053,
4386,
29918,
4661,
6482,
29918,
11739,
29879,
13,
3166,
7136,
29882,
29939,
29889,
4422,
29889,
4691,
29918,
12667,
4127,
1053,
4964,
29918,
9294,
29918,
1853,
29918,
726,
13,
3166,
7136,
29882,
29939,
29889,
4422,
29889,
2695,
29918,
9294,
1053,
4964,
29918,
9294,
13,
13,
3166,
9557,
29889,
13369,
1053,
19870,
13,
3166,
9557,
29889,
26045,
1053,
11837,
13,
13,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
7193,
29889,
9794,
1053,
315,
3222,
2659,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
10149,
292,
29889,
4530,
1338,
1053,
25691,
29918,
786,
8228,
29918,
272,
29918,
3204,
8228,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
7247,
29889,
4530,
1338,
1053,
844,
18020,
29918,
7247,
29918,
2490,
29918,
7620,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
7193,
29889,
4530,
1338,
1053,
274,
3222,
29918,
1792,
29918,
2490,
29918,
7620,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
7054,
22026,
29889,
13239,
1053,
679,
29918,
8758,
29918,
1807,
13,
13,
13,
29918,
1217,
29918,
21509,
29918,
2695,
29918,
9294,
353,
4964,
29918,
9294,
29898,
517,
29922,
1839,
8875,
29966,
26862,
6227,
29958,
877,
29966,
26862,
6227,
29958,
742,
12801,
26862,
6227,
29958,
5477,
13,
462,
462,
308,
529,
26862,
6227,
29958,
877,
29966,
26862,
6227,
29958,
742,
12801,
26862,
6227,
29958,
5477,
13,
462,
462,
308,
529,
26862,
6227,
29958,
877,
29966,
26862,
6227,
29958,
742,
12801,
26862,
6227,
29958,
1495,
1402,
13,
462,
462,
268,
3638,
29918,
517,
29918,
3554,
29922,
8824,
29897,
13,
13,
13,
29992,
13556,
2147,
29898,
29883,
3222,
29918,
1792,
29918,
2490,
29918,
7620,
29897,
13,
1753,
1404,
29918,
7620,
29918,
14035,
29898,
15452,
29892,
3579,
19290,
1125,
13,
1678,
274,
3222,
29918,
1792,
353,
9049,
5085,
29889,
657,
703,
29883,
3222,
29918,
1792,
613,
6213,
29897,
13,
1678,
565,
274,
3222,
29918,
1792,
322,
274,
3222,
29918,
1792,
29889,
275,
29918,
2676,
29918,
1792,
7295,
13,
4706,
4426,
353,
6571,
13,
4706,
4426,
29889,
5504,
29898,
657,
29918,
1491,
22371,
29918,
11330,
29918,
1609,
29918,
1792,
29898,
29883,
3222,
29918,
1792,
876,
13,
4706,
4426,
29889,
5504,
29898,
657,
29918,
7247,
29918,
29885,
1590,
10475,
29918,
11330,
29898,
29883,
3222,
29918,
1792,
876,
13,
4706,
12439,
29889,
18829,
29898,
29883,
3222,
29918,
1792,
29889,
6786,
29892,
4426,
29897,
13,
4706,
2767,
29918,
29882,
431,
17500,
29918,
11330,
29889,
18829,
29898,
29883,
3222,
29918,
1792,
29892,
4426,
29897,
13,
13,
13,
29992,
13556,
2147,
29898,
2055,
18020,
29918,
7247,
29918,
2490,
29918,
7620,
29897,
13,
29992,
13556,
2147,
29898,
1491,
22371,
29918,
786,
8228,
29918,
272,
29918,
3204,
8228,
29897,
13,
1753,
5354,
29918,
7620,
29918,
14035,
29898,
15452,
29892,
5354,
29892,
3579,
19290,
1125,
13,
1678,
565,
338,
8758,
29898,
7247,
29892,
4832,
29889,
1807,
29918,
8768,
1125,
13,
4706,
4964,
29918,
9294,
29918,
1853,
29918,
726,
29898,
7247,
29897,
13,
4706,
5354,
29918,
978,
353,
5354,
13,
1678,
1683,
29901,
13,
4706,
5354,
29918,
978,
353,
5354,
29889,
978,
13,
1678,
2767,
29918,
1491,
22371,
29918,
11330,
29918,
1609,
29918,
7247,
29898,
7247,
29918,
978,
29897,
13,
13,
13,
1753,
679,
29918,
7247,
29918,
29885,
1590,
10475,
29918,
11330,
29898,
29883,
3222,
29918,
1792,
1125,
13,
1678,
8829,
353,
679,
29918,
8758,
29918,
1807,
580,
13,
13,
1678,
736,
426,
13,
4706,
376,
8875,
4537,
29918,
974,
29918,
4836,
29918,
22854,
1642,
4830,
29898,
6272,
1125,
7431,
29898,
29883,
3222,
29918,
1792,
29889,
3129,
2708,
511,
13,
4706,
376,
8875,
4836,
29918,
22854,
29918,
1761,
1642,
4830,
29898,
6272,
1125,
11297,
29876,
4286,
7122,
29898,
29883,
3222,
29918,
1792,
29889,
3129,
2708,
511,
13,
1678,
500,
13,
13,
13,
29992,
13556,
2147,
29898,
1792,
29918,
1188,
3192,
29918,
262,
29897,
13,
29992,
8411,
29918,
4661,
6482,
29918,
11739,
29879,
29898,
2549,
29918,
328,
29885,
1144,
29922,
5574,
29897,
13,
1753,
5702,
29918,
1792,
29918,
7507,
29898,
15452,
29892,
2009,
29892,
1404,
29892,
3579,
19290,
1125,
13,
1678,
565,
6055,
29889,
2190,
1964,
29979,
29911,
2965,
29903,
29918,
1367,
29903,
29889,
657,
877,
29950,
7466,
5550,
2891,
29918,
8787,
29918,
1367,
29374,
13,
4706,
274,
3222,
29918,
1792,
353,
315,
3222,
2659,
29889,
3166,
29918,
14095,
29918,
1792,
29898,
1792,
29897,
13,
4706,
565,
274,
3222,
29918,
1792,
322,
274,
3222,
29918,
1792,
29889,
275,
29918,
2676,
29918,
1792,
7295,
13,
9651,
565,
451,
2009,
470,
379,
7466,
5550,
2891,
29918,
3217,
8949,
8673,
451,
297,
2009,
29889,
3217,
8949,
29059,
29901,
13,
18884,
396,
3450,
5717,
29892,
883,
11834,
6847,
2992,
29889,
13,
13,
18884,
1404,
29918,
26897,
292,
353,
2009,
29889,
2084,
29889,
27382,
2541,
29898,
24244,
29898,
7032,
4597,
8306,
1043,
29889,
2271,
978,
876,
13,
18884,
565,
1404,
29918,
26897,
292,
29901,
13,
462,
1678,
903,
1217,
29918,
21509,
29918,
2695,
29918,
9294,
29898,
8824,
29892,
525,
2659,
16725,
3633,
541,
750,
694,
15327,
1495,
13,
18884,
1683,
29901,
13,
462,
1678,
736,
13,
13,
9651,
12700,
353,
679,
29918,
7299,
29898,
3827,
29897,
13,
9651,
5702,
29918,
1792,
29918,
4530,
29918,
262,
29918,
265,
29918,
29882,
431,
17500,
29889,
18829,
29898,
29883,
3222,
29918,
1792,
29892,
2009,
29889,
3217,
8949,
29059,
29889,
657,
29898,
29950,
7466,
5550,
2891,
29918,
3217,
8949,
8673,
511,
13,
462,
462,
18884,
12700,
29892,
2009,
29889,
2084,
29897,
13,
2
] |
number-base.py | davejlin/py-checkio | 0 | 1601428 | <gh_stars>0
'''
Do you remember the radix and Numeral systems from math class?
Let's practice with it.
You are given a positive number as a string along with the radix for
it. Your function should convert it into decimal form. The radix is
less than 37 and greater than 1. The task uses digits and the letters
A-Z for the strings.
Watch out for cases when the number cannot be converted. For example:
"1A" cannot be converted with radix 9. For these cases your function
should return -1.
Input: Two arguments. A number as string and a radix as an integer.
Output: The converted number as an integer.
Example:
checkio("AF", 16) == 175
checkio("101", 2) == 5
checkio("101", 5) == 26
checkio("Z", 36) == 35
checkio("AB", 10) == -1
How it is used: Here you will learn how to work with the various
numeral systems and handle exceptions.
Precondition:
re.match("\A[A-Z0-9]\Z", str_number)
0 < len(str_number) ≤ 10
2 ≤ radix ≤ 36
'''
MAP = {
'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,
'A':10,'B':11,'C':12,'D':13,'E':14,'F':15,'G':16,'H':17,'I':18,
'J':19,'K':20,'L':21,'M':22,'N':23,'O':24,'P':25,'Q':26,'R':27,
'S':28,'T':29,'U':30,'V':31,'W':32,'X':33,'Y':34,'Z':35
}
def checkio(str_number, radix):
digits = list(map(lambda x: MAP[x], list(str_number[::-1])))
if max(digits) >= radix: return -1
return sum([digit*radix**i for i, digit in enumerate(digits)])
def checkio_online_sln(str_number, radix):
try:
return int(str_number, radix)
except ValueError:
return -1
inputs = [
("1567", 10),
("AF", 16),
("101", 2),
("101", 5),
("Z", 36),
("AB", 10),
("DEADBEEF", 16)
]
outputs = map(lambda x: checkio_online_sln(x[0],x[1]), inputs)
print(list(outputs)) | [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
12008,
29871,
13,
6132,
366,
6456,
278,
2971,
861,
322,
405,
4680,
284,
6757,
515,
5844,
770,
29973,
13,
12024,
29915,
29879,
6944,
411,
372,
29889,
13,
13,
3492,
526,
2183,
263,
6374,
1353,
408,
263,
1347,
3412,
411,
278,
2971,
861,
363,
13,
277,
29889,
3575,
740,
881,
3588,
372,
964,
13677,
883,
29889,
450,
2971,
861,
338,
13,
2222,
1135,
29871,
29941,
29955,
322,
7621,
1135,
29871,
29896,
29889,
450,
3414,
3913,
13340,
322,
278,
8721,
13,
29909,
29899,
29999,
363,
278,
6031,
29889,
13,
13,
24709,
714,
363,
4251,
746,
278,
1353,
2609,
367,
11543,
29889,
1152,
1342,
29901,
13,
29908,
29896,
29909,
29908,
2609,
367,
11543,
411,
2971,
861,
29871,
29929,
29889,
1152,
1438,
4251,
596,
740,
13,
9344,
736,
448,
29896,
29889,
13,
13,
4290,
29901,
7803,
6273,
29889,
319,
1353,
408,
1347,
322,
263,
2971,
861,
408,
385,
6043,
29889,
13,
13,
6466,
29901,
450,
11543,
1353,
408,
385,
6043,
29889,
13,
13,
14023,
29901,
13,
13,
3198,
601,
703,
5098,
613,
29871,
29896,
29953,
29897,
1275,
29871,
29896,
29955,
29945,
13,
3198,
601,
703,
29896,
29900,
29896,
613,
29871,
29906,
29897,
1275,
29871,
29945,
13,
3198,
601,
703,
29896,
29900,
29896,
613,
29871,
29945,
29897,
1275,
29871,
29906,
29953,
13,
3198,
601,
703,
29999,
613,
29871,
29941,
29953,
29897,
1275,
29871,
29941,
29945,
13,
3198,
601,
703,
2882,
613,
29871,
29896,
29900,
29897,
1275,
448,
29896,
13,
268,
13,
5328,
372,
338,
1304,
29901,
2266,
366,
674,
5110,
920,
304,
664,
411,
278,
5164,
13,
8058,
284,
6757,
322,
4386,
15283,
29889,
13,
13,
6572,
16122,
29901,
13,
13,
276,
29889,
4352,
14182,
29909,
29961,
29909,
29899,
29999,
29900,
29899,
29929,
10725,
29999,
613,
851,
29918,
4537,
29897,
13,
29900,
529,
7431,
29898,
710,
29918,
4537,
29897,
29871,
30248,
29871,
29896,
29900,
13,
29906,
29871,
30248,
2971,
861,
29871,
30248,
29871,
29941,
29953,
29871,
13,
12008,
13,
13,
23827,
353,
426,
13,
12,
29915,
29900,
2396,
29900,
5501,
29896,
2396,
29896,
5501,
29906,
2396,
29906,
5501,
29941,
2396,
29941,
5501,
29946,
2396,
29946,
5501,
29945,
2396,
29945,
5501,
29953,
2396,
29953,
5501,
29955,
2396,
29955,
5501,
29947,
2396,
29947,
5501,
29929,
2396,
29929,
29892,
13,
12,
29915,
29909,
2396,
29896,
29900,
5501,
29933,
2396,
29896,
29896,
5501,
29907,
2396,
29896,
29906,
5501,
29928,
2396,
29896,
29941,
5501,
29923,
2396,
29896,
29946,
5501,
29943,
2396,
29896,
29945,
5501,
29954,
2396,
29896,
29953,
5501,
29950,
2396,
29896,
29955,
5501,
29902,
2396,
29896,
29947,
29892,
13,
12,
29915,
29967,
2396,
29896,
29929,
5501,
29968,
2396,
29906,
29900,
5501,
29931,
2396,
29906,
29896,
5501,
29924,
2396,
29906,
29906,
5501,
29940,
2396,
29906,
29941,
5501,
29949,
2396,
29906,
29946,
5501,
29925,
2396,
29906,
29945,
5501,
29984,
2396,
29906,
29953,
5501,
29934,
2396,
29906,
29955,
29892,
13,
12,
29915,
29903,
2396,
29906,
29947,
5501,
29911,
2396,
29906,
29929,
5501,
29965,
2396,
29941,
29900,
5501,
29963,
2396,
29941,
29896,
5501,
29956,
2396,
29941,
29906,
5501,
29990,
2396,
29941,
29941,
5501,
29979,
2396,
29941,
29946,
5501,
29999,
2396,
29941,
29945,
13,
29913,
13,
13,
1753,
1423,
601,
29898,
710,
29918,
4537,
29892,
2971,
861,
1125,
13,
12,
7501,
1169,
353,
1051,
29898,
1958,
29898,
2892,
921,
29901,
341,
3301,
29961,
29916,
1402,
1051,
29898,
710,
29918,
4537,
29961,
1057,
29899,
29896,
29962,
4961,
13,
12,
361,
4236,
29898,
7501,
1169,
29897,
6736,
2971,
861,
29901,
736,
448,
29896,
13,
12,
2457,
2533,
4197,
26204,
29930,
3665,
861,
1068,
29875,
363,
474,
29892,
13615,
297,
26985,
29898,
7501,
1169,
29897,
2314,
13,
13,
1753,
1423,
601,
29918,
14627,
29918,
2536,
29876,
29898,
710,
29918,
4537,
29892,
2971,
861,
1125,
13,
1678,
1018,
29901,
13,
4706,
736,
938,
29898,
710,
29918,
4537,
29892,
2971,
861,
29897,
13,
1678,
5174,
7865,
2392,
29901,
13,
4706,
736,
448,
29896,
13,
13,
2080,
29879,
353,
518,
13,
12,
703,
29896,
29945,
29953,
29955,
613,
29871,
29896,
29900,
511,
13,
12,
703,
5098,
613,
29871,
29896,
29953,
511,
13,
12,
703,
29896,
29900,
29896,
613,
29871,
29906,
511,
13,
12,
703,
29896,
29900,
29896,
613,
29871,
29945,
511,
13,
12,
703,
29999,
613,
29871,
29941,
29953,
511,
13,
12,
703,
2882,
613,
29871,
29896,
29900,
511,
13,
12,
703,
2287,
3035,
15349,
29638,
613,
29871,
29896,
29953,
29897,
13,
29962,
13,
13,
4905,
29879,
353,
2910,
29898,
2892,
921,
29901,
1423,
601,
29918,
14627,
29918,
2536,
29876,
29898,
29916,
29961,
29900,
1402,
29916,
29961,
29896,
11724,
10970,
29897,
13,
2158,
29898,
1761,
29898,
4905,
29879,
876,
2
] |
nginx-flask/app/run.py | codenameyau/docker-cheatsheet | 1 | 1611776 | <filename>nginx-flask/app/run.py
from config import DEVELOPMENT
from routes import app
if __name__ == '__main__':
app.run(**DEVELOPMENT)
| [
1,
529,
9507,
29958,
23257,
29899,
1579,
1278,
29914,
932,
29914,
3389,
29889,
2272,
13,
3166,
2295,
1053,
5012,
12064,
3927,
13427,
3919,
13,
3166,
12049,
1053,
623,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
623,
29889,
3389,
29898,
1068,
2287,
12064,
3927,
13427,
3919,
29897,
13,
2
] |
tests/test_config_middleware.py | cjwatson/pastedeploy | 18 | 95458 | import pytest
from paste.deploy.config import ConfigMiddleware
class Bug(Exception):
pass
def app_with_exception(environ, start_response):
def cont():
yield b"something"
raise Bug
start_response('200 OK', [('Content-type', 'text/html')])
return cont()
def test_error():
# This import is conditional due to Paste not yet working on py3k
try:
from paste.fixture import TestApp
except ImportError:
raise pytest.skip('unable to import TestApp')
wrapped = ConfigMiddleware(app_with_exception, {'test': 1})
test_app = TestApp(wrapped)
pytest.raises(Bug, test_app.get, '/')
| [
1,
1053,
11451,
1688,
13,
13,
3166,
11417,
29889,
16519,
29889,
2917,
1053,
12782,
25411,
2519,
13,
13,
13,
1990,
28209,
29898,
2451,
1125,
13,
1678,
1209,
13,
13,
13,
1753,
623,
29918,
2541,
29918,
11739,
29898,
21813,
29892,
1369,
29918,
5327,
1125,
13,
1678,
822,
640,
7295,
13,
4706,
7709,
289,
29908,
14481,
29908,
13,
4706,
12020,
28209,
13,
1678,
1369,
29918,
5327,
877,
29906,
29900,
29900,
9280,
742,
518,
877,
3916,
29899,
1853,
742,
525,
726,
29914,
1420,
1495,
2314,
13,
1678,
736,
640,
580,
13,
13,
13,
1753,
1243,
29918,
2704,
7295,
13,
1678,
396,
910,
1053,
338,
15047,
2861,
304,
349,
4350,
451,
3447,
1985,
373,
11451,
29941,
29895,
13,
1678,
1018,
29901,
13,
4706,
515,
11417,
29889,
7241,
15546,
1053,
4321,
2052,
13,
1678,
5174,
16032,
2392,
29901,
13,
4706,
12020,
11451,
1688,
29889,
11014,
877,
348,
519,
304,
1053,
4321,
2052,
1495,
13,
13,
1678,
21021,
353,
12782,
25411,
2519,
29898,
932,
29918,
2541,
29918,
11739,
29892,
11117,
1688,
2396,
29871,
29896,
1800,
13,
1678,
1243,
29918,
932,
353,
4321,
2052,
29898,
29893,
336,
2986,
29897,
13,
1678,
11451,
1688,
29889,
336,
4637,
29898,
29933,
688,
29892,
1243,
29918,
932,
29889,
657,
29892,
8207,
1495,
13,
2
] |
preprocessing/preprocessing.py | sanujsriv/WTM | 0 | 83586 | ## Preprocessing.py
"""
Preprocessing Steps :-
1. Convert to lowercase
2. Remove punctuations with empty space
3. Remove digits
4. Apply lemmatization
5. Remove Stopwords
6. Remove words that do not have word embeddings
7. Remove words that have length < 3.
*** NOT APPLYING STEMMING (Instead applying lemmatization for better results)
Generating Preprocessed Docs Steps:
1. Apply Preprocessing Steps
2. Remove Documents that have length < 3
3. Apply CountVectorizer Data transform { with min_df =3 i.e. words that appear in less than 3 documents are removed }
4. Remove documents that are empty after countvectorization
5. Remove words in documents that are not in the vocab generated after countvectorization.
6. export the vocab words for which we have existing embeddings(Google Word2vec, GloVE etc.)
7. export the preprocessed data with its label.
8. (optional) Learn new embeddings using the preprocessed corpus
"""
from preprocessing_imports import *
from preprocessing_utils import *
from preprocessing_data import get_bbc_data
import gensim.downloader as api
# download and extract the GoogleNews-vectors-negative300.bin (https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz)
word2vec_model = models.KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True)
def get_data(data_to_get,dtype):
data_to_get = data_to_get.lower()
if data_to_get == 'bbc':
corpus,labels = get_bbc_data(dtype)
return corpus,labels
## Driver - Data Generation
all_data_to_get = ['bbc']
dtypes = ['short'] # short text
## Settings :-
min_doc_len = 3
min_word_length = 3
generate_skipgram_embeddings = 1 # Yes
home_dir = ''
for data_to_get in all_data_to_get:
if data_to_get == 'bbc': max_features = 2000
else: max_features = 4000
for dtype in dtypes:
os.chdir(home_dir+"/content")
docs,labels = get_data(data_to_get,dtype)
os.makedirs(home_dir+'/content/data_'+data_to_get+"/"+dtype,exist_ok=True)
os.chdir(home_dir+'/content/data_'+data_to_get+"/"+dtype)
with open(data_to_get+'_'+dtype+".txt", "a") as f:
f.write(data_to_get+" - "+dtype)
f.write("\n\n")
f.write('**'*50)
f.write("\n\n")
f.write(str(len(docs))+', '+str(len(labels))+'\n')
f.write('(labels,count): '+str(list(zip(*np.unique(labels, return_counts=True)))))
data_preprocessed,data_preprocessed_labels,embeddings,vocab = docs_labels_preprocessing(docs,labels,word2vec_model,min_doc_len,min_word_length,max_features)
f.write('\n\nlen of - \n data_preprocessed: '+str(len(data_preprocessed))+'\n data_preprocessed_labels: '+str(len(data_preprocessed_labels))+'\n vocab: '+str(len(vocab))+'\n embeddings : '+str(len(embeddings))+'\n')
len_docs = [len(d.split(" ")) for d in data_preprocessed]
f.write('\n min,mean,max docs len: '+str(np.min(len_docs))+', '+str(np.mean(len_docs).round(2))+', '+str(np.max(len_docs))+'\n\n')
save_obj(data_preprocessed,'data_preprocessed'+'_'+data_to_get+'_'+dtype)
save_obj(data_preprocessed_labels,'data_preprocessed_labels'+'_'+data_to_get+'_'+dtype)
save_obj(vocab,'vocab'+'_'+data_to_get+'_'+dtype)
save_obj(embeddings,'embeddings'+'_'+data_to_get+'_'+dtype)
f.write('**'*50)
if generate_skipgram_embeddings:
## Skipgram embeddings generation
gensim_prep_doc = [word_tokenize(d) for d in data_preprocessed]
model = gensim.models.Word2Vec(gensim_prep_doc, min_count=2, sg=1, size=300,iter=50, negative=10, window=4,workers=16)
vocab = list(model.wv.vocab)
# model.save(data_to_get+"_"+dtype+"_generated_word2vec.model")
generated_embeddings = {}
for v in list(model.wv.vocab):
vec = model.wv.__getitem__(v)
generated_embeddings[v] =vec
save_obj(generated_embeddings,'generated_embeddings_'+data_to_get+"_"+dtype)
# save_obj(vocab,'generated_vocab_'+data_to_get+"_"+dtype)
os.chdir(home_dir+'/content')
zipped_pickle_filename = data_to_get
os.system('zip -r '+zipped_pickle_filename+'_'+str(max_features)+'_.zip '+'/content/data_'+data_to_get+"/"+dtype)
| [
1,
444,
4721,
19170,
29889,
2272,
30004,
13,
15945,
19451,
13,
6572,
19170,
2443,
567,
8956,
6756,
13,
29896,
29889,
14806,
304,
5224,
4878,
30004,
13,
29906,
29889,
15154,
6035,
22999,
800,
411,
4069,
2913,
6756,
13,
29941,
29889,
15154,
13340,
30004,
13,
29946,
29889,
2401,
368,
9336,
2922,
2133,
30004,
13,
29945,
29889,
15154,
22303,
9303,
30004,
13,
29953,
29889,
15154,
3838,
393,
437,
451,
505,
1734,
8297,
29881,
886,
30004,
13,
29955,
29889,
15154,
3838,
393,
505,
3309,
529,
29871,
29941,
22993,
13,
17435,
6058,
12279,
7390,
29979,
4214,
317,
4330,
7428,
4214,
313,
3379,
1479,
15399,
9336,
2922,
2133,
363,
2253,
2582,
8443,
13,
30004,
13,
5631,
1218,
4721,
5014,
287,
360,
12332,
2443,
567,
29901,
30004,
13,
29896,
29889,
2401,
368,
4721,
19170,
2443,
567,
30004,
13,
29906,
29889,
15154,
10854,
29879,
393,
505,
3309,
529,
29871,
29941,
30004,
13,
29941,
29889,
2401,
368,
3917,
12877,
3950,
3630,
4327,
426,
411,
1375,
29918,
2176,
353,
29941,
474,
29889,
29872,
29889,
3838,
393,
2615,
297,
3109,
1135,
29871,
29941,
10701,
526,
6206,
4970,
13,
29946,
29889,
15154,
10701,
393,
526,
4069,
1156,
2302,
8111,
2133,
30004,
13,
29945,
29889,
15154,
3838,
297,
10701,
393,
526,
451,
297,
278,
7931,
370,
5759,
1156,
2302,
8111,
2133,
22993,
13,
29953,
29889,
5609,
278,
7931,
370,
3838,
363,
607,
591,
505,
5923,
8297,
29881,
886,
29898,
14207,
10803,
29906,
2003,
29892,
21806,
12064,
2992,
1846,
30004,
13,
29955,
29889,
5609,
278,
758,
5014,
287,
848,
411,
967,
3858,
22993,
13,
29947,
29889,
313,
25253,
29897,
19530,
29876,
716,
8297,
29881,
886,
773,
278,
758,
5014,
287,
1034,
13364,
6756,
13,
15945,
19451,
13,
3166,
758,
19170,
29918,
326,
4011,
1053,
334,
30004,
13,
3166,
758,
19170,
29918,
13239,
1053,
334,
30004,
13,
3166,
758,
19170,
29918,
1272,
1053,
679,
29918,
1327,
29883,
29918,
1272,
30004,
13,
5215,
26943,
326,
29889,
10382,
261,
408,
7882,
30004,
13,
30004,
13,
29937,
5142,
322,
6597,
278,
5087,
29328,
29899,
345,
14359,
29899,
22198,
29941,
29900,
29900,
29889,
2109,
313,
991,
597,
29879,
29941,
29889,
17260,
10467,
29889,
510,
29914,
11671,
29946,
29926,
29899,
27691,
29914,
14207,
29328,
29899,
345,
14359,
29899,
22198,
29941,
29900,
29900,
29889,
2109,
29889,
18828,
8443,
13,
1742,
29906,
2003,
29918,
4299,
353,
4733,
29889,
2558,
287,
29963,
11142,
29889,
1359,
29918,
1742,
29906,
2003,
29918,
4830,
877,
14207,
29328,
29899,
345,
14359,
29899,
22198,
29941,
29900,
29900,
29889,
2109,
742,
7581,
29922,
5574,
8443,
13,
30004,
13,
1753,
679,
29918,
1272,
29898,
1272,
29918,
517,
29918,
657,
29892,
29881,
1853,
1125,
30004,
13,
29871,
848,
29918,
517,
29918,
657,
353,
848,
29918,
517,
29918,
657,
29889,
13609,
26471,
13,
29871,
565,
848,
29918,
517,
29918,
657,
1275,
525,
1327,
29883,
2396,
30004,
13,
1678,
1034,
13364,
29892,
21134,
353,
679,
29918,
1327,
29883,
29918,
1272,
29898,
29881,
1853,
8443,
13,
29871,
736,
1034,
13364,
29892,
21134,
30004,
13,
30004,
13,
2277,
26391,
448,
3630,
28203,
30004,
13,
497,
29918,
1272,
29918,
517,
29918,
657,
353,
6024,
1327,
29883,
2033,
6756,
13,
29881,
8768,
353,
6024,
12759,
2033,
396,
3273,
1426,
6756,
13,
30004,
13,
2277,
19215,
8956,
6756,
13,
1195,
29918,
1514,
29918,
2435,
353,
29871,
29941,
30004,
13,
1195,
29918,
1742,
29918,
2848,
353,
29871,
29941,
30004,
13,
30004,
13,
17158,
29918,
11014,
1393,
29918,
17987,
29881,
886,
353,
29871,
29896,
396,
3869,
30004,
13,
30004,
13,
5184,
29918,
3972,
353,
6629,
30004,
13,
1454,
848,
29918,
517,
29918,
657,
297,
599,
29918,
1272,
29918,
517,
29918,
657,
29901,
30004,
13,
30004,
13,
29871,
565,
848,
29918,
517,
29918,
657,
1275,
525,
1327,
29883,
2396,
4236,
29918,
22100,
353,
29871,
29906,
29900,
29900,
29900,
30004,
13,
29871,
1683,
29901,
4236,
29918,
22100,
353,
29871,
29946,
29900,
29900,
29900,
30004,
13,
29871,
6756,
13,
29871,
363,
26688,
297,
270,
8768,
29901,
30004,
13,
1678,
2897,
29889,
305,
3972,
29898,
5184,
29918,
3972,
13578,
29914,
3051,
1159,
30004,
13,
1678,
10561,
29892,
21134,
353,
679,
29918,
1272,
29898,
1272,
29918,
517,
29918,
657,
29892,
29881,
1853,
8443,
13,
1678,
2897,
29889,
29885,
12535,
12935,
29898,
5184,
29918,
3972,
23097,
29914,
3051,
29914,
1272,
29918,
18717,
1272,
29918,
517,
29918,
657,
13578,
12975,
29974,
29881,
1853,
29892,
28997,
29918,
554,
29922,
5574,
8443,
13,
1678,
2897,
29889,
305,
3972,
29898,
5184,
29918,
3972,
23097,
29914,
3051,
29914,
1272,
29918,
18717,
1272,
29918,
517,
29918,
657,
13578,
12975,
29974,
29881,
1853,
8443,
13,
1678,
411,
1722,
29898,
1272,
29918,
517,
29918,
657,
29974,
15972,
18717,
29881,
1853,
29974,
1642,
3945,
613,
376,
29874,
1159,
408,
285,
29901,
30004,
13,
418,
285,
29889,
3539,
29898,
1272,
29918,
517,
29918,
657,
13578,
448,
15691,
29881,
1853,
8443,
13,
418,
285,
29889,
3539,
14182,
29876,
29905,
29876,
1159,
30004,
13,
418,
285,
29889,
3539,
877,
1068,
29915,
29930,
29945,
29900,
8443,
13,
418,
285,
29889,
3539,
14182,
29876,
29905,
29876,
1159,
30004,
13,
418,
285,
29889,
3539,
29898,
710,
29898,
2435,
29898,
2640,
876,
29974,
742,
525,
29974,
710,
29898,
2435,
29898,
21134,
876,
29974,
12764,
29876,
1495,
30004,
13,
418,
285,
29889,
3539,
877,
29898,
21134,
29892,
2798,
1125,
525,
29974,
710,
29898,
1761,
29898,
7554,
10456,
9302,
29889,
13092,
29898,
21134,
29892,
736,
29918,
2798,
29879,
29922,
5574,
876,
4961,
30004,
13,
418,
848,
29918,
1457,
5014,
287,
29892,
1272,
29918,
1457,
5014,
287,
29918,
21134,
29892,
17987,
29881,
886,
29892,
29894,
542,
370,
353,
10561,
29918,
21134,
29918,
1457,
19170,
29898,
2640,
29892,
21134,
29892,
1742,
29906,
2003,
29918,
4299,
29892,
1195,
29918,
1514,
29918,
2435,
29892,
1195,
29918,
1742,
29918,
2848,
29892,
3317,
29918,
22100,
8443,
13,
418,
285,
29889,
3539,
28909,
29876,
29905,
29876,
2435,
310,
448,
320,
29876,
29871,
848,
29918,
1457,
5014,
287,
29901,
525,
29974,
710,
29898,
2435,
29898,
1272,
29918,
1457,
5014,
287,
876,
29974,
12764,
29876,
29871,
848,
29918,
1457,
5014,
287,
29918,
21134,
29901,
525,
29974,
710,
29898,
2435,
29898,
1272,
29918,
1457,
5014,
287,
29918,
21134,
876,
29974,
12764,
29876,
29871,
7931,
370,
29901,
29871,
525,
29974,
710,
29898,
2435,
29898,
29894,
542,
370,
876,
29974,
12764,
29876,
29871,
8297,
29881,
886,
584,
525,
29974,
710,
29898,
2435,
29898,
17987,
29881,
886,
876,
29974,
12764,
29876,
1495,
30004,
13,
418,
7431,
29918,
2640,
353,
518,
2435,
29898,
29881,
29889,
5451,
703,
376,
876,
363,
270,
297,
848,
29918,
1457,
5014,
287,
29962,
30004,
13,
418,
285,
29889,
3539,
28909,
29876,
1375,
29892,
12676,
29892,
3317,
10561,
7431,
29901,
525,
29974,
710,
29898,
9302,
29889,
1195,
29898,
2435,
29918,
2640,
876,
29974,
742,
525,
29974,
710,
29898,
9302,
29889,
12676,
29898,
2435,
29918,
2640,
467,
14486,
29898,
29906,
876,
29974,
742,
525,
29974,
710,
29898,
9302,
29889,
3317,
29898,
2435,
29918,
2640,
876,
29974,
12764,
29876,
29905,
29876,
1495,
30004,
13,
418,
6756,
13,
418,
4078,
29918,
5415,
29898,
1272,
29918,
1457,
5014,
287,
5501,
1272,
29918,
1457,
5014,
287,
18717,
15972,
18717,
1272,
29918,
517,
29918,
657,
29974,
15972,
18717,
29881,
1853,
8443,
13,
418,
4078,
29918,
5415,
29898,
1272,
29918,
1457,
5014,
287,
29918,
21134,
5501,
1272,
29918,
1457,
5014,
287,
29918,
21134,
18717,
15972,
18717,
1272,
29918,
517,
29918,
657,
29974,
15972,
18717,
29881,
1853,
29897,
259,
6756,
13,
418,
4078,
29918,
5415,
29898,
29894,
542,
370,
5501,
29894,
542,
370,
18717,
15972,
18717,
1272,
29918,
517,
29918,
657,
29974,
15972,
18717,
29881,
1853,
8443,
13,
418,
4078,
29918,
5415,
29898,
17987,
29881,
886,
5501,
17987,
29881,
886,
18717,
15972,
18717,
1272,
29918,
517,
29918,
657,
29974,
15972,
18717,
29881,
1853,
8443,
13,
418,
285,
29889,
3539,
877,
1068,
29915,
29930,
29945,
29900,
8443,
13,
30004,
13,
361,
5706,
29918,
11014,
1393,
29918,
17987,
29881,
886,
29901,
30004,
13,
29871,
444,
4971,
666,
1393,
8297,
29881,
886,
12623,
6756,
13,
30004,
13,
29871,
26943,
326,
29918,
15287,
29918,
1514,
353,
518,
1742,
29918,
6979,
675,
29898,
29881,
29897,
363,
270,
297,
848,
29918,
1457,
5014,
287,
29962,
30004,
13,
29871,
1904,
353,
26943,
326,
29889,
9794,
29889,
14463,
29906,
25987,
29898,
17397,
326,
29918,
15287,
29918,
1514,
29892,
1375,
29918,
2798,
29922,
29906,
29892,
269,
29887,
29922,
29896,
29892,
2159,
29922,
29941,
29900,
29900,
29892,
1524,
29922,
29945,
29900,
29892,
8178,
29922,
29896,
29900,
29892,
3474,
29922,
29946,
29892,
1287,
414,
29922,
29896,
29953,
8443,
13,
29871,
7931,
370,
353,
1051,
29898,
4299,
29889,
29893,
29894,
29889,
29894,
542,
370,
8443,
13,
29871,
396,
1904,
29889,
7620,
29898,
1272,
29918,
517,
29918,
657,
13578,
29918,
17969,
29881,
1853,
13578,
29918,
13525,
29918,
1742,
29906,
2003,
29889,
4299,
1159,
30004,
13,
30004,
13,
29871,
5759,
29918,
17987,
29881,
886,
353,
6571,
30004,
13,
29871,
363,
325,
297,
1051,
29898,
4299,
29889,
29893,
29894,
29889,
29894,
542,
370,
1125,
30004,
13,
1678,
9649,
353,
1904,
29889,
29893,
29894,
17255,
657,
667,
12035,
29894,
8443,
13,
1678,
5759,
29918,
17987,
29881,
886,
29961,
29894,
29962,
353,
2003,
30004,
13,
30004,
13,
29871,
4078,
29918,
5415,
29898,
13525,
29918,
17987,
29881,
886,
5501,
13525,
29918,
17987,
29881,
886,
29918,
18717,
1272,
29918,
517,
29918,
657,
13578,
29918,
17969,
29881,
1853,
8443,
13,
29871,
396,
4078,
29918,
5415,
29898,
29894,
542,
370,
5501,
13525,
29918,
29894,
542,
370,
29918,
18717,
1272,
29918,
517,
29918,
657,
13578,
29918,
17969,
29881,
1853,
8443,
13,
30004,
13,
359,
29889,
305,
3972,
29898,
5184,
29918,
3972,
23097,
29914,
3051,
1495,
30004,
13,
2526,
2986,
29918,
23945,
280,
29918,
9507,
353,
848,
29918,
517,
29918,
657,
30004,
13,
359,
29889,
5205,
877,
7554,
448,
29878,
525,
29974,
2526,
2986,
29918,
23945,
280,
29918,
9507,
29974,
15972,
18717,
710,
29898,
3317,
29918,
22100,
7240,
29915,
5396,
7554,
525,
23097,
29914,
3051,
29914,
1272,
29918,
18717,
1272,
29918,
517,
29918,
657,
13578,
12975,
29974,
29881,
1853,
8443,
13,
2
] |
tests/test_layers.py | SauravMaheshkar/enformer | 0 | 181617 | import pytest
import tensorflow as tf
from enformer.layers.activation_layers import GELU, SoftPlus
from enformer.layers.container_layers import Residual
from enformer.layers.pooling_layers import SoftmaxPooling1D
from .utils import Identity
@pytest.mark.layers
@pytest.mark.actions
def test_softplus():
layer = SoftPlus("softplus")
assert layer.name == "softplus"
outputs = layer(tf.range(0, 2, dtype=tf.float32)).numpy()
assert len(outputs) == 2
@pytest.mark.layers
@pytest.mark.actions
def test_gelu():
layer = GELU("gelu")
assert layer.name == "gelu"
outputs = layer(tf.range(0, 2, dtype=tf.float32)).numpy()
assert len(outputs) == 2
@pytest.mark.layers
@pytest.mark.actions
def test_residual():
layer = Residual(Identity(), name="residual")
assert layer.name == "residual"
outputs = layer(inputs=tf.ones((2, 2)))
assert outputs.shape == tf.TensorShape((2, 2))
@pytest.mark.layers
@pytest.mark.actions
def test_softmax_pooling():
layer = SoftmaxPooling1D()
assert layer.name == "softmax_pooling"
outputs = layer((tf.ones([3, 4, 5])))
assert outputs.shape == tf.TensorShape((3, 2, 5))
| [
1,
1053,
11451,
1688,
13,
5215,
26110,
408,
15886,
13,
13,
3166,
427,
24784,
29889,
29277,
29889,
11236,
362,
29918,
29277,
1053,
402,
6670,
29965,
29892,
1105,
615,
29575,
13,
3166,
427,
24784,
29889,
29277,
29889,
7611,
29918,
29277,
1053,
2538,
333,
950,
13,
3166,
427,
24784,
29889,
29277,
29889,
10109,
292,
29918,
29277,
1053,
1105,
615,
3317,
11426,
292,
29896,
29928,
13,
13,
3166,
869,
13239,
1053,
27486,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
29277,
13,
29992,
2272,
1688,
29889,
3502,
29889,
7387,
13,
1753,
1243,
29918,
2695,
11242,
7295,
13,
13,
1678,
7546,
353,
1105,
615,
29575,
703,
2695,
11242,
1159,
13,
1678,
4974,
7546,
29889,
978,
1275,
376,
2695,
11242,
29908,
13,
13,
1678,
14391,
353,
7546,
29898,
13264,
29889,
3881,
29898,
29900,
29892,
29871,
29906,
29892,
26688,
29922,
13264,
29889,
7411,
29941,
29906,
8106,
23749,
580,
13,
1678,
4974,
7431,
29898,
4905,
29879,
29897,
1275,
29871,
29906,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
29277,
13,
29992,
2272,
1688,
29889,
3502,
29889,
7387,
13,
1753,
1243,
29918,
7467,
29884,
7295,
13,
13,
1678,
7546,
353,
402,
6670,
29965,
703,
7467,
29884,
1159,
13,
1678,
4974,
7546,
29889,
978,
1275,
376,
7467,
29884,
29908,
13,
13,
1678,
14391,
353,
7546,
29898,
13264,
29889,
3881,
29898,
29900,
29892,
29871,
29906,
29892,
26688,
29922,
13264,
29889,
7411,
29941,
29906,
8106,
23749,
580,
13,
1678,
4974,
7431,
29898,
4905,
29879,
29897,
1275,
29871,
29906,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
29277,
13,
29992,
2272,
1688,
29889,
3502,
29889,
7387,
13,
1753,
1243,
29918,
690,
333,
950,
7295,
13,
13,
1678,
7546,
353,
2538,
333,
950,
29898,
18415,
3285,
1024,
543,
690,
333,
950,
1159,
13,
1678,
4974,
7546,
29889,
978,
1275,
376,
690,
333,
950,
29908,
13,
13,
1678,
14391,
353,
7546,
29898,
2080,
29879,
29922,
13264,
29889,
2873,
3552,
29906,
29892,
29871,
29906,
4961,
13,
1678,
4974,
14391,
29889,
12181,
1275,
15886,
29889,
29911,
6073,
24111,
3552,
29906,
29892,
29871,
29906,
876,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
29277,
13,
29992,
2272,
1688,
29889,
3502,
29889,
7387,
13,
1753,
1243,
29918,
2695,
3317,
29918,
10109,
292,
7295,
13,
13,
1678,
7546,
353,
1105,
615,
3317,
11426,
292,
29896,
29928,
580,
13,
1678,
4974,
7546,
29889,
978,
1275,
376,
2695,
3317,
29918,
10109,
292,
29908,
13,
13,
1678,
14391,
353,
7546,
3552,
13264,
29889,
2873,
4197,
29941,
29892,
29871,
29946,
29892,
29871,
29945,
29962,
4961,
13,
1678,
4974,
14391,
29889,
12181,
1275,
15886,
29889,
29911,
6073,
24111,
3552,
29941,
29892,
29871,
29906,
29892,
29871,
29945,
876,
13,
2
] |
resist/types/models/message.py | an-dyy/Resist | 4 | 34903 | from __future__ import annotations
from typing import Literal, TypedDict, Union, final
from typing_extensions import NotRequired
from .asset import AssetData
class YoutubeLinkEmbedMetadata(TypedDict):
type: Literal["YouTube"]
id: str
timestamp: NotRequired[str]
class TwitchLinkEmbedMetadata(TypedDict):
type: Literal["Twitch"]
content_type: Literal["Channel", "Clip", "Video"]
id: str
class SpotifyLinkEmbedMetadata(TypedDict):
type: Literal["Spotify"]
content_type: str
id: str
SoundcloudLinkEmbedMetadata = TypedDict(
"SoundcloudLinkEmbedMetadata", {"type": Literal["Soundcloud"]}
)
class BandcampLinkEmbedMetadata(TypedDict):
type: Literal["Bandcamp"]
content_type: Literal["Album", "Track"]
id: str
class EmbedMediaData(TypedDict):
# base fields that both videos and images sent in embeds will have.
url: str
width: int
height: int
class EmbedImageData(EmbedMediaData):
# this contains the data about an image sent in an embed
# for example: a banner image in a URL's embed
size: Literal["Large", "Preview"]
class WebsiteEmbedData(TypedDict):
"""Represents the data of an embed for a URL."""
type: Literal["Website"]
url: NotRequired[str]
special: NotRequired[
YoutubeLinkEmbedMetadata
| SpotifyLinkEmbedMetadata
| TwitchLinkEmbedMetadata
| SoundcloudLinkEmbedMetadata
| BandcampLinkEmbedMetadata
]
title: NotRequired[str]
description: NotRequired[str]
image: NotRequired[EmbedImageData]
video: NotRequired[EmbedMediaData]
site_name: NotRequired[str]
icon_url: NotRequired[str]
colour: NotRequired[str]
class ImageEmbedData(EmbedImageData):
"""Represents the data of an image embed."""
type: Literal["Image"]
class TextEmbedData(TypedDict):
type: Literal["Text"]
icon_url: NotRequired[str]
url: NotRequired[str]
title: NotRequired[str]
description: NotRequired[str]
media: NotRequired[AssetData]
colour: NotRequired[str]
NoneEmbed = TypedDict("NoneEmbed", {"type": Literal["None"]})
@final
class SystemMessageContent(TypedDict):
type: Literal["text"]
content: str
@final
class UserActionSystemMessageContent(TypedDict):
type: Literal[
"user_added",
"user_remove",
"user_joined",
"user_left",
"user_kicked",
"user_banned",
]
id: str
by: NotRequired[str] # sent only with user_added and user_remove
@final
class ChannelActionSystemMessageContent(TypedDict):
type: Literal[
"channel_renamed", "channel_description_changed", "channel_icon_changed"
]
by: str
name: NotRequired[str] # sent only with channel_renamed
MessageEditedData = TypedDict("MessageEditedData", {"$date": str})
class MasqueradeData(TypedDict):
name: NotRequired[str]
avatar: NotRequired[str]
EmbedType = Union[WebsiteEmbedData, ImageEmbedData, TextEmbedData, NoneEmbed]
class MessageData(TypedDict):
_id: str
nonce: NotRequired[str]
channel: str
author: str
content: (
SystemMessageContent
| UserActionSystemMessageContent
| ChannelActionSystemMessageContent
| str
)
attachments: NotRequired[list[AssetData]]
edited: NotRequired[MessageEditedData]
embeds: NotRequired[list[EmbedType]]
mentions: NotRequired[list[str]]
replies: NotRequired[list[str]]
masquerade: NotRequired[MasqueradeData]
| [
1,
515,
4770,
29888,
9130,
1649,
1053,
25495,
13,
13,
3166,
19229,
1053,
5449,
284,
29892,
14213,
287,
21533,
29892,
7761,
29892,
2186,
13,
13,
3166,
19229,
29918,
24299,
1053,
2216,
19347,
13,
13,
3166,
869,
24129,
1053,
1094,
842,
1469,
13,
13,
13,
1990,
612,
15907,
6595,
6026,
2580,
18417,
29898,
24933,
287,
21533,
1125,
13,
1678,
1134,
29901,
5449,
284,
3366,
3492,
13425,
3108,
13,
1678,
1178,
29901,
851,
13,
1678,
14334,
29901,
2216,
19347,
29961,
710,
29962,
13,
13,
13,
1990,
8168,
2335,
6595,
6026,
2580,
18417,
29898,
24933,
287,
21533,
1125,
13,
1678,
1134,
29901,
5449,
284,
3366,
27418,
2335,
3108,
13,
1678,
2793,
29918,
1853,
29901,
5449,
284,
3366,
13599,
613,
376,
29907,
3466,
613,
376,
15167,
3108,
13,
1678,
1178,
29901,
851,
13,
13,
13,
1990,
1706,
327,
1598,
6595,
6026,
2580,
18417,
29898,
24933,
287,
21533,
1125,
13,
1678,
1134,
29901,
5449,
284,
3366,
5592,
327,
1598,
3108,
13,
1678,
2793,
29918,
1853,
29901,
851,
13,
1678,
1178,
29901,
851,
13,
13,
13,
29456,
9274,
6595,
6026,
2580,
18417,
353,
14213,
287,
21533,
29898,
13,
1678,
376,
29456,
9274,
6595,
6026,
2580,
18417,
613,
8853,
1853,
1115,
5449,
284,
3366,
29456,
9274,
3108,
29913,
13,
29897,
13,
13,
13,
1990,
5158,
24821,
6595,
6026,
2580,
18417,
29898,
24933,
287,
21533,
1125,
13,
1678,
1134,
29901,
5449,
284,
3366,
29933,
392,
24821,
3108,
13,
1678,
2793,
29918,
1853,
29901,
5449,
284,
3366,
2499,
2404,
613,
376,
17936,
3108,
13,
1678,
1178,
29901,
851,
13,
13,
13,
1990,
2812,
2580,
10572,
1469,
29898,
24933,
287,
21533,
1125,
13,
1678,
396,
2967,
4235,
393,
1716,
19707,
322,
4558,
2665,
297,
8297,
29879,
674,
505,
29889,
13,
1678,
3142,
29901,
851,
13,
1678,
2920,
29901,
938,
13,
1678,
3171,
29901,
938,
13,
13,
13,
1990,
2812,
2580,
2940,
1469,
29898,
6026,
2580,
10572,
1469,
1125,
13,
1678,
396,
445,
3743,
278,
848,
1048,
385,
1967,
2665,
297,
385,
8297,
13,
1678,
396,
363,
1342,
29901,
263,
289,
7310,
1967,
297,
263,
3988,
29915,
29879,
8297,
13,
1678,
2159,
29901,
5449,
284,
3366,
24105,
479,
613,
376,
6572,
1493,
3108,
13,
13,
13,
1990,
13253,
6026,
2580,
1469,
29898,
24933,
287,
21533,
1125,
13,
1678,
9995,
1123,
4569,
1237,
278,
848,
310,
385,
8297,
363,
263,
3988,
1213,
15945,
13,
13,
1678,
1134,
29901,
5449,
284,
3366,
3609,
2746,
3108,
13,
1678,
3142,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
4266,
29901,
2216,
19347,
29961,
13,
4706,
612,
15907,
6595,
6026,
2580,
18417,
13,
4706,
891,
1706,
327,
1598,
6595,
6026,
2580,
18417,
13,
4706,
891,
8168,
2335,
6595,
6026,
2580,
18417,
13,
4706,
891,
14976,
9274,
6595,
6026,
2580,
18417,
13,
4706,
891,
5158,
24821,
6595,
6026,
2580,
18417,
13,
1678,
4514,
13,
1678,
3611,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
6139,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
1967,
29901,
2216,
19347,
29961,
6026,
2580,
2940,
1469,
29962,
13,
1678,
4863,
29901,
2216,
19347,
29961,
6026,
2580,
10572,
1469,
29962,
13,
1678,
3268,
29918,
978,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
9849,
29918,
2271,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
12384,
29901,
2216,
19347,
29961,
710,
29962,
13,
13,
13,
1990,
7084,
6026,
2580,
1469,
29898,
6026,
2580,
2940,
1469,
1125,
13,
1678,
9995,
1123,
4569,
1237,
278,
848,
310,
385,
1967,
8297,
1213,
15945,
13,
13,
1678,
1134,
29901,
5449,
284,
3366,
2940,
3108,
13,
13,
13,
1990,
3992,
6026,
2580,
1469,
29898,
24933,
287,
21533,
1125,
13,
1678,
1134,
29901,
5449,
284,
3366,
1626,
3108,
13,
1678,
9849,
29918,
2271,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
3142,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
3611,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
6139,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
5745,
29901,
2216,
19347,
29961,
26405,
1469,
29962,
13,
1678,
12384,
29901,
2216,
19347,
29961,
710,
29962,
13,
13,
13,
8516,
6026,
2580,
353,
14213,
287,
21533,
703,
8516,
6026,
2580,
613,
8853,
1853,
1115,
5449,
284,
3366,
8516,
3108,
1800,
13,
13,
13,
29992,
8394,
13,
1990,
2184,
3728,
3916,
29898,
24933,
287,
21533,
1125,
13,
1678,
1134,
29901,
5449,
284,
3366,
726,
3108,
13,
1678,
2793,
29901,
851,
13,
13,
13,
29992,
8394,
13,
1990,
4911,
4276,
3924,
3728,
3916,
29898,
24933,
287,
21533,
1125,
13,
1678,
1134,
29901,
5449,
284,
29961,
13,
4706,
376,
1792,
29918,
23959,
613,
13,
4706,
376,
1792,
29918,
5992,
613,
13,
4706,
376,
1792,
29918,
2212,
1312,
613,
13,
4706,
376,
1792,
29918,
1563,
613,
13,
4706,
376,
1792,
29918,
29895,
17840,
613,
13,
4706,
376,
1792,
29918,
29890,
11310,
613,
13,
1678,
4514,
13,
1678,
1178,
29901,
851,
13,
1678,
491,
29901,
2216,
19347,
29961,
710,
29962,
29871,
396,
2665,
871,
411,
1404,
29918,
23959,
322,
1404,
29918,
5992,
13,
13,
13,
29992,
8394,
13,
1990,
17368,
4276,
3924,
3728,
3916,
29898,
24933,
287,
21533,
1125,
13,
1678,
1134,
29901,
5449,
284,
29961,
13,
4706,
376,
12719,
29918,
1267,
2795,
613,
376,
12719,
29918,
8216,
29918,
15033,
613,
376,
12719,
29918,
4144,
29918,
15033,
29908,
13,
1678,
4514,
13,
1678,
491,
29901,
851,
13,
1678,
1024,
29901,
2216,
19347,
29961,
710,
29962,
29871,
396,
2665,
871,
411,
8242,
29918,
1267,
2795,
13,
13,
13,
3728,
3853,
1573,
1469,
353,
14213,
287,
21533,
703,
3728,
3853,
1573,
1469,
613,
8853,
29938,
1256,
1115,
851,
1800,
13,
13,
13,
1990,
8622,
339,
15019,
1469,
29898,
24933,
287,
21533,
1125,
13,
1678,
1024,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
1029,
14873,
29901,
2216,
19347,
29961,
710,
29962,
13,
13,
13,
6026,
2580,
1542,
353,
7761,
29961,
3609,
2746,
6026,
2580,
1469,
29892,
7084,
6026,
2580,
1469,
29892,
3992,
6026,
2580,
1469,
29892,
6213,
6026,
2580,
29962,
13,
13,
13,
1990,
7777,
1469,
29898,
24933,
287,
21533,
1125,
13,
1678,
903,
333,
29901,
851,
13,
1678,
1661,
346,
29901,
2216,
19347,
29961,
710,
29962,
13,
1678,
8242,
29901,
851,
13,
1678,
4148,
29901,
851,
13,
1678,
2793,
29901,
313,
13,
4706,
2184,
3728,
3916,
13,
4706,
891,
4911,
4276,
3924,
3728,
3916,
13,
4706,
891,
17368,
4276,
3924,
3728,
3916,
13,
4706,
891,
851,
13,
1678,
1723,
13,
1678,
10641,
1860,
29901,
2216,
19347,
29961,
1761,
29961,
26405,
1469,
5262,
13,
1678,
8788,
29901,
2216,
19347,
29961,
3728,
3853,
1573,
1469,
29962,
13,
1678,
8297,
29879,
29901,
2216,
19347,
29961,
1761,
29961,
6026,
2580,
1542,
5262,
13,
1678,
26649,
29901,
2216,
19347,
29961,
1761,
29961,
710,
5262,
13,
1678,
1634,
3687,
29901,
2216,
19347,
29961,
1761,
29961,
710,
5262,
13,
1678,
5516,
339,
15019,
29901,
2216,
19347,
29961,
29924,
294,
339,
15019,
1469,
29962,
13,
2
] |
lemur/certificates/models.py | rajatsharma94/lemur | 2 | 193925 | """
.. module: lemur.certificates.models
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: <NAME> <<EMAIL>>
"""
from datetime import timedelta
import arrow
from cryptography import x509
from cryptography.hazmat.primitives.asymmetric import rsa
from flask import current_app
from idna.core import InvalidCodepoint
from sqlalchemy import (
event,
Integer,
ForeignKey,
String,
PassiveDefault,
func,
Column,
Text,
Boolean,
Index,
)
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import relationship
from sqlalchemy.sql.expression import case, extract
from sqlalchemy_utils.types.arrow import ArrowType
from werkzeug.utils import cached_property
from lemur.common import defaults, utils, validators
from lemur.constants import SUCCESS_METRIC_STATUS, FAILURE_METRIC_STATUS
from lemur.database import db
from lemur.domains.models import Domain
from lemur.extensions import metrics
from lemur.extensions import sentry
from lemur.models import (
certificate_associations,
certificate_source_associations,
certificate_destination_associations,
certificate_notification_associations,
certificate_replacement_associations,
roles_certificates,
pending_cert_replacement_associations,
)
from lemur.plugins.base import plugins
from lemur.policies.models import RotationPolicy
from lemur.utils import Vault
def get_sequence(name):
if "-" not in name:
return name, None
parts = name.split("-")
# see if we have an int at the end of our name
try:
seq = int(parts[-1])
except ValueError:
return name, None
# we might have a date at the end of our name
if len(parts[-1]) == 8:
return name, None
root = "-".join(parts[:-1])
return root, seq
def get_or_increase_name(name, serial):
certificates = Certificate.query.filter(Certificate.name == name).all()
if not certificates:
return name
serial_name = "{0}-{1}".format(name, hex(int(serial))[2:].upper())
certificates = Certificate.query.filter(Certificate.name == serial_name).all()
if not certificates:
return serial_name
certificates = Certificate.query.filter(
Certificate.name.ilike("{0}%".format(serial_name))
).all()
ends = [0]
root, end = get_sequence(serial_name)
for cert in certificates:
root, end = get_sequence(cert.name)
if end:
ends.append(end)
return "{0}-{1}".format(root, max(ends) + 1)
class Certificate(db.Model):
__tablename__ = "certificates"
__table_args__ = (
Index(
"ix_certificates_cn",
"cn",
postgresql_ops={"cn": "gin_trgm_ops"},
postgresql_using="gin",
),
Index(
"ix_certificates_name",
"name",
postgresql_ops={"name": "gin_trgm_ops"},
postgresql_using="gin",
),
)
id = Column(Integer, primary_key=True)
ix = Index(
"ix_certificates_id_desc", id.desc(), postgresql_using="btree", unique=True
)
external_id = Column(String(128))
owner = Column(String(128), nullable=False)
name = Column(String(256), unique=True)
description = Column(String(1024))
notify = Column(Boolean, default=True)
body = Column(Text(), nullable=False)
chain = Column(Text())
csr = Column(Text())
private_key = Column(Vault)
issuer = Column(String(128))
serial = Column(String(128))
cn = Column(String(128))
deleted = Column(Boolean, index=True, default=False)
dns_provider_id = Column(
Integer(), ForeignKey("dns_providers.id", ondelete="CASCADE"), nullable=True
)
not_before = Column(ArrowType)
not_after = Column(ArrowType)
not_after_ix = Index("ix_certificates_not_after", not_after.desc())
date_created = Column(ArrowType, PassiveDefault(func.now()), nullable=False)
signing_algorithm = Column(String(128))
status = Column(String(128))
bits = Column(Integer())
san = Column(String(1024)) # TODO this should be migrated to boolean
rotation = Column(Boolean, default=False)
user_id = Column(Integer, ForeignKey("users.id"))
authority_id = Column(Integer, ForeignKey("authorities.id", ondelete="CASCADE"))
root_authority_id = Column(
Integer, ForeignKey("authorities.id", ondelete="CASCADE")
)
rotation_policy_id = Column(Integer, ForeignKey("rotation_policies.id"))
notifications = relationship(
"Notification",
secondary=certificate_notification_associations,
backref="certificate",
)
destinations = relationship(
"Destination",
secondary=certificate_destination_associations,
backref="certificate",
)
sources = relationship(
"Source", secondary=certificate_source_associations, backref="certificate"
)
domains = relationship(
"Domain", secondary=certificate_associations, backref="certificate"
)
roles = relationship("Role", secondary=roles_certificates, backref="certificate")
replaces = relationship(
"Certificate",
secondary=certificate_replacement_associations,
primaryjoin=id == certificate_replacement_associations.c.certificate_id, # noqa
secondaryjoin=id
== certificate_replacement_associations.c.replaced_certificate_id, # noqa
backref="replaced",
)
replaced_by_pending = relationship(
"PendingCertificate",
secondary=pending_cert_replacement_associations,
backref="pending_replace",
viewonly=True,
)
logs = relationship("Log", backref="certificate")
endpoints = relationship("Endpoint", backref="certificate")
rotation_policy = relationship("RotationPolicy")
sensitive_fields = ("private_key",)
def __init__(self, **kwargs):
self.body = kwargs["body"].strip()
cert = self.parsed_cert
self.issuer = defaults.issuer(cert)
self.cn = defaults.common_name(cert)
self.san = defaults.san(cert)
self.not_before = defaults.not_before(cert)
self.not_after = defaults.not_after(cert)
self.serial = defaults.serial(cert)
# when destinations are appended they require a valid name.
if kwargs.get("name"):
self.name = get_or_increase_name(
defaults.text_to_slug(kwargs["name"]), self.serial
)
else:
self.name = get_or_increase_name(
defaults.certificate_name(
self.cn, self.issuer, self.not_before, self.not_after, self.san
),
self.serial,
)
self.owner = kwargs["owner"]
if kwargs.get("private_key"):
self.private_key = kwargs["private_key"].strip()
if kwargs.get("chain"):
self.chain = kwargs["chain"].strip()
if kwargs.get("csr"):
self.csr = kwargs["csr"].strip()
self.notify = kwargs.get("notify", True)
self.destinations = kwargs.get("destinations", [])
self.notifications = kwargs.get("notifications", [])
self.description = kwargs.get("description")
self.roles = list(set(kwargs.get("roles", [])))
self.replaces = kwargs.get("replaces", [])
self.rotation = kwargs.get("rotation")
self.rotation_policy = kwargs.get("rotation_policy")
self.signing_algorithm = defaults.signing_algorithm(cert)
self.bits = defaults.bitstrength(cert)
self.external_id = kwargs.get("external_id")
self.authority_id = kwargs.get("authority_id")
self.dns_provider_id = kwargs.get("dns_provider_id")
for domain in defaults.domains(cert):
self.domains.append(Domain(name=domain))
# Check integrity before saving anything into the database.
# For user-facing API calls, validation should also be done in schema validators.
self.check_integrity()
def check_integrity(self):
"""
Integrity checks: Does the cert have a valid chain and matching private key?
"""
if self.private_key:
validators.verify_private_key_match(
utils.parse_private_key(self.private_key),
self.parsed_cert,
error_class=AssertionError,
)
if self.chain:
chain = [self.parsed_cert] + utils.parse_cert_chain(self.chain)
validators.verify_cert_chain(chain, error_class=AssertionError)
@cached_property
def parsed_cert(self):
assert self.body, "Certificate body not set"
return utils.parse_certificate(self.body)
@property
def active(self):
return self.notify
@property
def organization(self):
return defaults.organization(self.parsed_cert)
@property
def organizational_unit(self):
return defaults.organizational_unit(self.parsed_cert)
@property
def country(self):
return defaults.country(self.parsed_cert)
@property
def state(self):
return defaults.state(self.parsed_cert)
@property
def location(self):
return defaults.location(self.parsed_cert)
@property
def distinguished_name(self):
return self.parsed_cert.subject.rfc4514_string()
@property
def key_type(self):
if isinstance(self.parsed_cert.public_key(), rsa.RSAPublicKey):
return "RSA{key_size}".format(
key_size=self.parsed_cert.public_key().key_size
)
@property
def validity_remaining(self):
return abs(self.not_after - arrow.utcnow())
@property
def validity_range(self):
return self.not_after - self.not_before
@property
def subject(self):
return self.parsed_cert.subject
@property
def public_key(self):
return self.parsed_cert.public_key()
@hybrid_property
def expired(self):
if self.not_after <= arrow.utcnow():
return True
@expired.expression
def expired(cls):
return case([(cls.not_after <= arrow.utcnow(), True)], else_=False)
@hybrid_property
def revoked(self):
if "revoked" == self.status:
return True
@revoked.expression
def revoked(cls):
return case([(cls.status == "revoked", True)], else_=False)
@hybrid_property
def has_private_key(self):
return self.private_key is not None
@has_private_key.expression
def has_private_key(cls):
return case([(cls.private_key.is_(None), True)], else_=False)
@hybrid_property
def in_rotation_window(self):
"""
Determines if a certificate is available for rotation based
on the rotation policy associated.
:return:
"""
now = arrow.utcnow()
end = now + timedelta(days=self.rotation_policy.days)
if self.not_after <= end:
return True
@in_rotation_window.expression
def in_rotation_window(cls):
"""
Determines if a certificate is available for rotation based
on the rotation policy associated.
:return:
"""
return case(
[(extract("day", cls.not_after - func.now()) <= RotationPolicy.days, True)],
else_=False,
)
@property
def extensions(self):
# setup default values
return_extensions = {"sub_alt_names": {"names": []}}
try:
for extension in self.parsed_cert.extensions:
value = extension.value
if isinstance(value, x509.BasicConstraints):
return_extensions["basic_constraints"] = value
elif isinstance(value, x509.SubjectAlternativeName):
return_extensions["sub_alt_names"]["names"] = value
elif isinstance(value, x509.ExtendedKeyUsage):
return_extensions["extended_key_usage"] = value
elif isinstance(value, x509.KeyUsage):
return_extensions["key_usage"] = value
elif isinstance(value, x509.SubjectKeyIdentifier):
return_extensions["subject_key_identifier"] = {"include_ski": True}
elif isinstance(value, x509.AuthorityInformationAccess):
return_extensions["certificate_info_access"] = {"include_aia": True}
elif isinstance(value, x509.AuthorityKeyIdentifier):
aki = {"use_key_identifier": False, "use_authority_cert": False}
if value.key_identifier:
aki["use_key_identifier"] = True
if value.authority_cert_issuer:
aki["use_authority_cert"] = True
return_extensions["authority_key_identifier"] = aki
elif isinstance(value, x509.CRLDistributionPoints):
return_extensions["crl_distribution_points"] = {
"include_crl_dp": value
}
# TODO: Not supporting custom OIDs yet. https://github.com/Netflix/lemur/issues/665
else:
current_app.logger.warning(
"Custom OIDs not yet supported for clone operation."
)
except InvalidCodepoint as e:
sentry.captureException()
current_app.logger.warning(
"Unable to parse extensions due to underscore in dns name"
)
except ValueError as e:
sentry.captureException()
current_app.logger.warning("Unable to parse")
current_app.logger.exception(e)
return return_extensions
def __repr__(self):
return "Certificate(name={name})".format(name=self.name)
@event.listens_for(Certificate.destinations, "append")
def update_destinations(target, value, initiator):
"""
Attempt to upload certificate to the new destination
:param target:
:param value:
:param initiator:
:return:
"""
destination_plugin = plugins.get(value.plugin_name)
status = FAILURE_METRIC_STATUS
try:
if target.private_key or not destination_plugin.requires_key:
destination_plugin.upload(
target.name,
target.body,
target.private_key,
target.chain,
value.options,
)
status = SUCCESS_METRIC_STATUS
except Exception as e:
sentry.captureException()
raise
metrics.send(
"destination_upload",
"counter",
1,
metric_tags={
"status": status,
"certificate": target.name,
"destination": value.label,
},
)
@event.listens_for(Certificate.replaces, "append")
def update_replacement(target, value, initiator):
"""
When a certificate is marked as 'replaced' we should not notify.
:param target:
:param value:
:param initiator:
:return:
"""
value.notify = False
| [
1,
9995,
13,
636,
3883,
29901,
9336,
332,
29889,
6327,
928,
1078,
29889,
9794,
13,
1678,
584,
12120,
29901,
26663,
13,
1678,
584,
8552,
1266,
29901,
313,
29883,
29897,
29871,
29906,
29900,
29896,
29947,
491,
12670,
20157,
29916,
9266,
1696,
1074,
26524,
29950,
24125,
363,
901,
13,
1678,
584,
506,
1947,
29901,
13380,
29892,
1074,
365,
2965,
1430,
1660,
363,
901,
4902,
29889,
13,
636,
3883,
8921,
1057,
529,
5813,
29958,
3532,
26862,
6227,
6778,
13,
15945,
29908,
13,
3166,
12865,
1053,
5335,
287,
2554,
13,
13,
5215,
16578,
13,
3166,
24941,
5275,
1053,
921,
29945,
29900,
29929,
13,
3166,
24941,
5275,
29889,
29882,
834,
2922,
29889,
9469,
277,
3145,
29889,
294,
962,
16414,
1053,
364,
4977,
13,
3166,
29784,
1053,
1857,
29918,
932,
13,
3166,
1178,
1056,
29889,
3221,
1053,
21403,
3399,
3149,
13,
3166,
4576,
284,
305,
6764,
1053,
313,
13,
1678,
1741,
29892,
13,
1678,
8102,
29892,
13,
1678,
19358,
2558,
29892,
13,
1678,
1714,
29892,
13,
1678,
6978,
573,
4592,
29892,
13,
1678,
3653,
29892,
13,
1678,
12481,
29892,
13,
1678,
3992,
29892,
13,
1678,
11185,
29892,
13,
1678,
11374,
29892,
13,
29897,
13,
3166,
4576,
284,
305,
6764,
29889,
1062,
29889,
5819,
19515,
1053,
7498,
19515,
29918,
6799,
13,
3166,
4576,
284,
305,
6764,
29889,
555,
1053,
9443,
13,
3166,
4576,
284,
305,
6764,
29889,
2850,
29889,
17471,
1053,
1206,
29892,
6597,
13,
3166,
4576,
284,
305,
6764,
29918,
13239,
29889,
8768,
29889,
2936,
1053,
826,
798,
1542,
13,
3166,
23085,
13289,
29889,
13239,
1053,
22152,
29918,
6799,
13,
13,
3166,
9336,
332,
29889,
9435,
1053,
21274,
29892,
3667,
29879,
29892,
2854,
4097,
13,
3166,
9336,
332,
29889,
3075,
1934,
1053,
20134,
26925,
29918,
2303,
5659,
2965,
29918,
27047,
29892,
13515,
6227,
11499,
29918,
2303,
5659,
2965,
29918,
27047,
13,
3166,
9336,
332,
29889,
9803,
1053,
4833,
13,
3166,
9336,
332,
29889,
3129,
2708,
29889,
9794,
1053,
28460,
13,
3166,
9336,
332,
29889,
24299,
1053,
21556,
13,
3166,
9336,
332,
29889,
24299,
1053,
2665,
719,
13,
3166,
9336,
332,
29889,
9794,
1053,
313,
13,
1678,
12289,
29918,
21264,
800,
29892,
13,
1678,
12289,
29918,
4993,
29918,
21264,
800,
29892,
13,
1678,
12289,
29918,
23848,
29918,
21264,
800,
29892,
13,
1678,
12289,
29918,
24671,
29918,
21264,
800,
29892,
13,
1678,
12289,
29918,
3445,
9552,
29918,
21264,
800,
29892,
13,
1678,
16178,
29918,
6327,
928,
1078,
29892,
13,
1678,
28235,
29918,
6327,
29918,
3445,
9552,
29918,
21264,
800,
29892,
13,
29897,
13,
3166,
9336,
332,
29889,
12800,
29889,
3188,
1053,
18224,
13,
3166,
9336,
332,
29889,
3733,
293,
583,
29889,
9794,
1053,
9664,
362,
15644,
13,
3166,
9336,
332,
29889,
13239,
1053,
478,
1292,
13,
13,
13,
1753,
679,
29918,
16506,
29898,
978,
1125,
13,
1678,
565,
11663,
29908,
451,
297,
1024,
29901,
13,
4706,
736,
1024,
29892,
6213,
13,
13,
1678,
5633,
353,
1024,
29889,
5451,
703,
29899,
1159,
13,
13,
1678,
396,
1074,
565,
591,
505,
385,
938,
472,
278,
1095,
310,
1749,
1024,
13,
1678,
1018,
29901,
13,
4706,
19359,
353,
938,
29898,
20895,
14352,
29896,
2314,
13,
1678,
5174,
7865,
2392,
29901,
13,
4706,
736,
1024,
29892,
6213,
13,
13,
1678,
396,
591,
1795,
505,
263,
2635,
472,
278,
1095,
310,
1749,
1024,
13,
1678,
565,
7431,
29898,
20895,
14352,
29896,
2314,
1275,
29871,
29947,
29901,
13,
4706,
736,
1024,
29892,
6213,
13,
13,
1678,
3876,
353,
11663,
1642,
7122,
29898,
20895,
7503,
29899,
29896,
2314,
13,
1678,
736,
3876,
29892,
19359,
13,
13,
13,
1753,
679,
29918,
272,
29918,
262,
1037,
559,
29918,
978,
29898,
978,
29892,
7797,
1125,
13,
1678,
23199,
1078,
353,
18410,
8021,
29889,
1972,
29889,
4572,
29898,
20455,
8021,
29889,
978,
1275,
1024,
467,
497,
580,
13,
13,
1678,
565,
451,
23199,
1078,
29901,
13,
4706,
736,
1024,
13,
13,
1678,
7797,
29918,
978,
353,
29850,
29900,
7402,
29912,
29896,
29913,
1642,
4830,
29898,
978,
29892,
15090,
29898,
524,
29898,
15550,
876,
29961,
29906,
29901,
1822,
21064,
3101,
13,
1678,
23199,
1078,
353,
18410,
8021,
29889,
1972,
29889,
4572,
29898,
20455,
8021,
29889,
978,
1275,
7797,
29918,
978,
467,
497,
580,
13,
13,
1678,
565,
451,
23199,
1078,
29901,
13,
4706,
736,
7797,
29918,
978,
13,
13,
1678,
23199,
1078,
353,
18410,
8021,
29889,
1972,
29889,
4572,
29898,
13,
4706,
18410,
8021,
29889,
978,
29889,
2638,
446,
703,
29912,
29900,
10560,
1642,
4830,
29898,
15550,
29918,
978,
876,
13,
1678,
13742,
497,
580,
13,
13,
1678,
10614,
353,
518,
29900,
29962,
13,
1678,
3876,
29892,
1095,
353,
679,
29918,
16506,
29898,
15550,
29918,
978,
29897,
13,
1678,
363,
2284,
297,
23199,
1078,
29901,
13,
4706,
3876,
29892,
1095,
353,
679,
29918,
16506,
29898,
6327,
29889,
978,
29897,
13,
4706,
565,
1095,
29901,
13,
9651,
10614,
29889,
4397,
29898,
355,
29897,
13,
13,
1678,
736,
29850,
29900,
7402,
29912,
29896,
29913,
1642,
4830,
29898,
4632,
29892,
4236,
29898,
1975,
29897,
718,
29871,
29896,
29897,
13,
13,
13,
1990,
18410,
8021,
29898,
2585,
29889,
3195,
1125,
13,
1678,
4770,
3891,
2435,
420,
1649,
353,
376,
6327,
928,
1078,
29908,
13,
1678,
4770,
2371,
29918,
5085,
1649,
353,
313,
13,
4706,
11374,
29898,
13,
9651,
376,
861,
29918,
6327,
928,
1078,
29918,
18038,
613,
13,
9651,
376,
18038,
613,
13,
9651,
27035,
29918,
3554,
3790,
29908,
18038,
1115,
376,
5359,
29918,
509,
29887,
29885,
29918,
3554,
10758,
13,
9651,
27035,
29918,
4746,
543,
5359,
613,
13,
4706,
10353,
13,
4706,
11374,
29898,
13,
9651,
376,
861,
29918,
6327,
928,
1078,
29918,
978,
613,
13,
9651,
376,
978,
613,
13,
9651,
27035,
29918,
3554,
3790,
29908,
978,
1115,
376,
5359,
29918,
509,
29887,
29885,
29918,
3554,
10758,
13,
9651,
27035,
29918,
4746,
543,
5359,
613,
13,
4706,
10353,
13,
1678,
1723,
13,
1678,
1178,
353,
12481,
29898,
7798,
29892,
7601,
29918,
1989,
29922,
5574,
29897,
13,
1678,
474,
29916,
353,
11374,
29898,
13,
4706,
376,
861,
29918,
6327,
928,
1078,
29918,
333,
29918,
14273,
613,
1178,
29889,
14273,
3285,
27035,
29918,
4746,
543,
3116,
929,
613,
5412,
29922,
5574,
13,
1678,
1723,
13,
1678,
7029,
29918,
333,
353,
12481,
29898,
1231,
29898,
29896,
29906,
29947,
876,
13,
1678,
12271,
353,
12481,
29898,
1231,
29898,
29896,
29906,
29947,
511,
1870,
519,
29922,
8824,
29897,
13,
1678,
1024,
353,
12481,
29898,
1231,
29898,
29906,
29945,
29953,
511,
5412,
29922,
5574,
29897,
13,
1678,
6139,
353,
12481,
29898,
1231,
29898,
29896,
29900,
29906,
29946,
876,
13,
1678,
26051,
353,
12481,
29898,
18146,
29892,
2322,
29922,
5574,
29897,
13,
13,
1678,
3573,
353,
12481,
29898,
1626,
3285,
1870,
519,
29922,
8824,
29897,
13,
1678,
9704,
353,
12481,
29898,
1626,
3101,
13,
1678,
5939,
29878,
353,
12481,
29898,
1626,
3101,
13,
1678,
2024,
29918,
1989,
353,
12481,
29898,
29963,
1292,
29897,
13,
13,
1678,
1721,
2853,
353,
12481,
29898,
1231,
29898,
29896,
29906,
29947,
876,
13,
1678,
7797,
353,
12481,
29898,
1231,
29898,
29896,
29906,
29947,
876,
13,
1678,
274,
29876,
353,
12481,
29898,
1231,
29898,
29896,
29906,
29947,
876,
13,
1678,
11132,
353,
12481,
29898,
18146,
29892,
2380,
29922,
5574,
29892,
2322,
29922,
8824,
29897,
13,
1678,
270,
1983,
29918,
18121,
29918,
333,
353,
12481,
29898,
13,
4706,
8102,
3285,
19358,
2558,
703,
29881,
1983,
29918,
771,
29454,
29889,
333,
613,
373,
8143,
543,
29907,
3289,
5454,
2287,
4968,
1870,
519,
29922,
5574,
13,
1678,
1723,
13,
13,
1678,
451,
29918,
11083,
353,
12481,
29898,
1433,
798,
1542,
29897,
13,
1678,
451,
29918,
7045,
353,
12481,
29898,
1433,
798,
1542,
29897,
13,
1678,
451,
29918,
7045,
29918,
861,
353,
11374,
703,
861,
29918,
6327,
928,
1078,
29918,
1333,
29918,
7045,
613,
451,
29918,
7045,
29889,
14273,
3101,
13,
13,
1678,
2635,
29918,
11600,
353,
12481,
29898,
1433,
798,
1542,
29892,
6978,
573,
4592,
29898,
9891,
29889,
3707,
25739,
1870,
519,
29922,
8824,
29897,
13,
13,
1678,
26188,
29918,
20567,
353,
12481,
29898,
1231,
29898,
29896,
29906,
29947,
876,
13,
1678,
4660,
353,
12481,
29898,
1231,
29898,
29896,
29906,
29947,
876,
13,
1678,
9978,
353,
12481,
29898,
7798,
3101,
13,
1678,
9753,
353,
12481,
29898,
1231,
29898,
29896,
29900,
29906,
29946,
876,
29871,
396,
14402,
445,
881,
367,
9725,
630,
304,
7223,
13,
13,
1678,
13733,
353,
12481,
29898,
18146,
29892,
2322,
29922,
8824,
29897,
13,
1678,
1404,
29918,
333,
353,
12481,
29898,
7798,
29892,
19358,
2558,
703,
7193,
29889,
333,
5783,
13,
1678,
14329,
29918,
333,
353,
12481,
29898,
7798,
29892,
19358,
2558,
703,
8921,
1907,
29889,
333,
613,
373,
8143,
543,
29907,
3289,
5454,
2287,
5783,
13,
1678,
3876,
29918,
8921,
537,
29918,
333,
353,
12481,
29898,
13,
4706,
8102,
29892,
19358,
2558,
703,
8921,
1907,
29889,
333,
613,
373,
8143,
543,
29907,
3289,
5454,
2287,
1159,
13,
1678,
1723,
13,
1678,
13733,
29918,
22197,
29918,
333,
353,
12481,
29898,
7798,
29892,
19358,
2558,
703,
5450,
362,
29918,
3733,
293,
583,
29889,
333,
5783,
13,
13,
1678,
25913,
353,
9443,
29898,
13,
4706,
376,
12958,
613,
13,
4706,
16723,
29922,
6327,
8021,
29918,
24671,
29918,
21264,
800,
29892,
13,
4706,
1250,
999,
543,
6327,
8021,
613,
13,
1678,
1723,
13,
1678,
15422,
800,
353,
9443,
29898,
13,
4706,
376,
14994,
3381,
613,
13,
4706,
16723,
29922,
6327,
8021,
29918,
23848,
29918,
21264,
800,
29892,
13,
4706,
1250,
999,
543,
6327,
8021,
613,
13,
1678,
1723,
13,
1678,
8974,
353,
9443,
29898,
13,
4706,
376,
4435,
613,
16723,
29922,
6327,
8021,
29918,
4993,
29918,
21264,
800,
29892,
1250,
999,
543,
6327,
8021,
29908,
13,
1678,
1723,
13,
1678,
21904,
353,
9443,
29898,
13,
4706,
376,
15951,
613,
16723,
29922,
6327,
8021,
29918,
21264,
800,
29892,
1250,
999,
543,
6327,
8021,
29908,
13,
1678,
1723,
13,
1678,
16178,
353,
9443,
703,
16727,
613,
16723,
29922,
307,
793,
29918,
6327,
928,
1078,
29892,
1250,
999,
543,
6327,
8021,
1159,
13,
1678,
1634,
6048,
353,
9443,
29898,
13,
4706,
376,
20455,
8021,
613,
13,
4706,
16723,
29922,
6327,
8021,
29918,
3445,
9552,
29918,
21264,
800,
29892,
13,
4706,
7601,
7122,
29922,
333,
1275,
12289,
29918,
3445,
9552,
29918,
21264,
800,
29889,
29883,
29889,
6327,
8021,
29918,
333,
29892,
29871,
396,
694,
25621,
13,
4706,
16723,
7122,
29922,
333,
13,
4706,
1275,
12289,
29918,
3445,
9552,
29918,
21264,
800,
29889,
29883,
29889,
3445,
433,
1133,
29918,
6327,
8021,
29918,
333,
29892,
29871,
396,
694,
25621,
13,
4706,
1250,
999,
543,
3445,
433,
1133,
613,
13,
1678,
1723,
13,
13,
1678,
8611,
29918,
1609,
29918,
29886,
2548,
353,
9443,
29898,
13,
4706,
376,
29925,
2548,
20455,
8021,
613,
13,
4706,
16723,
29922,
29886,
2548,
29918,
6327,
29918,
3445,
9552,
29918,
21264,
800,
29892,
13,
4706,
1250,
999,
543,
29886,
2548,
29918,
6506,
613,
13,
4706,
1776,
6194,
29922,
5574,
29892,
13,
1678,
1723,
13,
13,
1678,
10748,
353,
9443,
703,
3403,
613,
1250,
999,
543,
6327,
8021,
1159,
13,
1678,
1095,
9748,
353,
9443,
703,
25602,
613,
1250,
999,
543,
6327,
8021,
1159,
13,
1678,
13733,
29918,
22197,
353,
9443,
703,
21281,
362,
15644,
1159,
13,
1678,
20502,
29918,
9621,
353,
4852,
9053,
29918,
1989,
613,
29897,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3579,
19290,
1125,
13,
4706,
1583,
29889,
2587,
353,
9049,
5085,
3366,
2587,
16862,
17010,
580,
13,
4706,
2284,
353,
1583,
29889,
862,
8485,
29918,
6327,
13,
13,
4706,
1583,
29889,
790,
2853,
353,
21274,
29889,
790,
2853,
29898,
6327,
29897,
13,
4706,
1583,
29889,
18038,
353,
21274,
29889,
9435,
29918,
978,
29898,
6327,
29897,
13,
4706,
1583,
29889,
28455,
353,
21274,
29889,
28455,
29898,
6327,
29897,
13,
4706,
1583,
29889,
1333,
29918,
11083,
353,
21274,
29889,
1333,
29918,
11083,
29898,
6327,
29897,
13,
4706,
1583,
29889,
1333,
29918,
7045,
353,
21274,
29889,
1333,
29918,
7045,
29898,
6327,
29897,
13,
4706,
1583,
29889,
15550,
353,
21274,
29889,
15550,
29898,
6327,
29897,
13,
13,
4706,
396,
746,
15422,
800,
526,
623,
2760,
896,
1996,
263,
2854,
1024,
29889,
13,
4706,
565,
9049,
5085,
29889,
657,
703,
978,
29908,
1125,
13,
9651,
1583,
29889,
978,
353,
679,
29918,
272,
29918,
262,
1037,
559,
29918,
978,
29898,
13,
18884,
21274,
29889,
726,
29918,
517,
29918,
29517,
29898,
19290,
3366,
978,
3108,
511,
1583,
29889,
15550,
13,
9651,
1723,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
978,
353,
679,
29918,
272,
29918,
262,
1037,
559,
29918,
978,
29898,
13,
18884,
21274,
29889,
6327,
8021,
29918,
978,
29898,
13,
462,
1678,
1583,
29889,
18038,
29892,
1583,
29889,
790,
2853,
29892,
1583,
29889,
1333,
29918,
11083,
29892,
1583,
29889,
1333,
29918,
7045,
29892,
1583,
29889,
28455,
13,
18884,
10353,
13,
18884,
1583,
29889,
15550,
29892,
13,
9651,
1723,
13,
13,
4706,
1583,
29889,
20348,
353,
9049,
5085,
3366,
20348,
3108,
13,
13,
4706,
565,
9049,
5085,
29889,
657,
703,
9053,
29918,
1989,
29908,
1125,
13,
9651,
1583,
29889,
9053,
29918,
1989,
353,
9049,
5085,
3366,
9053,
29918,
1989,
16862,
17010,
580,
13,
13,
4706,
565,
9049,
5085,
29889,
657,
703,
14153,
29908,
1125,
13,
9651,
1583,
29889,
14153,
353,
9049,
5085,
3366,
14153,
16862,
17010,
580,
13,
13,
4706,
565,
9049,
5085,
29889,
657,
703,
2395,
29878,
29908,
1125,
13,
9651,
1583,
29889,
2395,
29878,
353,
9049,
5085,
3366,
2395,
29878,
16862,
17010,
580,
13,
13,
4706,
1583,
29889,
25140,
353,
9049,
5085,
29889,
657,
703,
25140,
613,
5852,
29897,
13,
4706,
1583,
29889,
7854,
262,
800,
353,
9049,
5085,
29889,
657,
703,
7854,
262,
800,
613,
518,
2314,
13,
4706,
1583,
29889,
1333,
8232,
353,
9049,
5085,
29889,
657,
703,
1333,
8232,
613,
518,
2314,
13,
4706,
1583,
29889,
8216,
353,
9049,
5085,
29889,
657,
703,
8216,
1159,
13,
4706,
1583,
29889,
307,
793,
353,
1051,
29898,
842,
29898,
19290,
29889,
657,
703,
307,
793,
613,
5159,
4961,
13,
4706,
1583,
29889,
3445,
6048,
353,
9049,
5085,
29889,
657,
703,
3445,
6048,
613,
518,
2314,
13,
4706,
1583,
29889,
5450,
362,
353,
9049,
5085,
29889,
657,
703,
5450,
362,
1159,
13,
4706,
1583,
29889,
5450,
362,
29918,
22197,
353,
9049,
5085,
29889,
657,
703,
5450,
362,
29918,
22197,
1159,
13,
4706,
1583,
29889,
4530,
292,
29918,
20567,
353,
21274,
29889,
4530,
292,
29918,
20567,
29898,
6327,
29897,
13,
4706,
1583,
29889,
14836,
353,
21274,
29889,
2966,
710,
1477,
29898,
6327,
29897,
13,
4706,
1583,
29889,
23176,
29918,
333,
353,
9049,
5085,
29889,
657,
703,
23176,
29918,
333,
1159,
13,
4706,
1583,
29889,
8921,
537,
29918,
333,
353,
9049,
5085,
29889,
657,
703,
8921,
537,
29918,
333,
1159,
13,
4706,
1583,
29889,
29881,
1983,
29918,
18121,
29918,
333,
353,
9049,
5085,
29889,
657,
703,
29881,
1983,
29918,
18121,
29918,
333,
1159,
13,
13,
4706,
363,
5354,
297,
21274,
29889,
3129,
2708,
29898,
6327,
1125,
13,
9651,
1583,
29889,
3129,
2708,
29889,
4397,
29898,
15951,
29898,
978,
29922,
7247,
876,
13,
13,
4706,
396,
5399,
28410,
1434,
14238,
3099,
964,
278,
2566,
29889,
13,
4706,
396,
1152,
1404,
29899,
29888,
9390,
3450,
5717,
29892,
8845,
881,
884,
367,
2309,
297,
10938,
2854,
4097,
29889,
13,
4706,
1583,
29889,
3198,
29918,
14146,
537,
580,
13,
13,
1678,
822,
1423,
29918,
14146,
537,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
17100,
537,
12747,
29901,
5538,
278,
2284,
505,
263,
2854,
9704,
322,
9686,
2024,
1820,
29973,
13,
4706,
9995,
13,
4706,
565,
1583,
29889,
9053,
29918,
1989,
29901,
13,
9651,
2854,
4097,
29889,
27902,
29918,
9053,
29918,
1989,
29918,
4352,
29898,
13,
18884,
3667,
29879,
29889,
5510,
29918,
9053,
29918,
1989,
29898,
1311,
29889,
9053,
29918,
1989,
511,
13,
18884,
1583,
29889,
862,
8485,
29918,
6327,
29892,
13,
18884,
1059,
29918,
1990,
29922,
14697,
291,
2392,
29892,
13,
9651,
1723,
13,
13,
4706,
565,
1583,
29889,
14153,
29901,
13,
9651,
9704,
353,
518,
1311,
29889,
862,
8485,
29918,
6327,
29962,
718,
3667,
29879,
29889,
5510,
29918,
6327,
29918,
14153,
29898,
1311,
29889,
14153,
29897,
13,
9651,
2854,
4097,
29889,
27902,
29918,
6327,
29918,
14153,
29898,
14153,
29892,
1059,
29918,
1990,
29922,
14697,
291,
2392,
29897,
13,
13,
1678,
732,
29883,
3791,
29918,
6799,
13,
1678,
822,
21213,
29918,
6327,
29898,
1311,
1125,
13,
4706,
4974,
1583,
29889,
2587,
29892,
376,
20455,
8021,
3573,
451,
731,
29908,
13,
4706,
736,
3667,
29879,
29889,
5510,
29918,
6327,
8021,
29898,
1311,
29889,
2587,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
6136,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
25140,
13,
13,
1678,
732,
6799,
13,
1678,
822,
13013,
29898,
1311,
1125,
13,
4706,
736,
21274,
29889,
6388,
2133,
29898,
1311,
29889,
862,
8485,
29918,
6327,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
8674,
1288,
29918,
5441,
29898,
1311,
1125,
13,
4706,
736,
21274,
29889,
6388,
466,
1288,
29918,
5441,
29898,
1311,
29889,
862,
8485,
29918,
6327,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
4234,
29898,
1311,
1125,
13,
4706,
736,
21274,
29889,
13509,
29898,
1311,
29889,
862,
8485,
29918,
6327,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
2106,
29898,
1311,
1125,
13,
4706,
736,
21274,
29889,
3859,
29898,
1311,
29889,
862,
8485,
29918,
6327,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
4423,
29898,
1311,
1125,
13,
4706,
736,
21274,
29889,
5479,
29898,
1311,
29889,
862,
8485,
29918,
6327,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
20660,
29918,
978,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
862,
8485,
29918,
6327,
29889,
16009,
29889,
9600,
29883,
29946,
29945,
29896,
29946,
29918,
1807,
580,
13,
13,
1678,
732,
6799,
13,
1678,
822,
1820,
29918,
1853,
29898,
1311,
1125,
13,
4706,
565,
338,
8758,
29898,
1311,
29889,
862,
8485,
29918,
6327,
29889,
3597,
29918,
1989,
3285,
364,
4977,
29889,
12445,
3301,
803,
2558,
1125,
13,
9651,
736,
376,
29934,
8132,
29912,
1989,
29918,
2311,
29913,
1642,
4830,
29898,
13,
18884,
1820,
29918,
2311,
29922,
1311,
29889,
862,
8485,
29918,
6327,
29889,
3597,
29918,
1989,
2141,
1989,
29918,
2311,
13,
9651,
1723,
13,
13,
1678,
732,
6799,
13,
1678,
822,
2854,
537,
29918,
1745,
17225,
29898,
1311,
1125,
13,
4706,
736,
6425,
29898,
1311,
29889,
1333,
29918,
7045,
448,
16578,
29889,
329,
29883,
3707,
3101,
13,
13,
1678,
732,
6799,
13,
1678,
822,
2854,
537,
29918,
3881,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
1333,
29918,
7045,
448,
1583,
29889,
1333,
29918,
11083,
13,
13,
1678,
732,
6799,
13,
1678,
822,
4967,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
862,
8485,
29918,
6327,
29889,
16009,
13,
13,
1678,
732,
6799,
13,
1678,
822,
970,
29918,
1989,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
862,
8485,
29918,
6327,
29889,
3597,
29918,
1989,
580,
13,
13,
1678,
732,
5819,
19515,
29918,
6799,
13,
1678,
822,
1518,
2859,
29898,
1311,
1125,
13,
4706,
565,
1583,
29889,
1333,
29918,
7045,
5277,
16578,
29889,
329,
29883,
3707,
7295,
13,
9651,
736,
5852,
13,
13,
1678,
732,
4548,
2859,
29889,
17471,
13,
1678,
822,
1518,
2859,
29898,
25932,
1125,
13,
4706,
736,
1206,
4197,
29898,
25932,
29889,
1333,
29918,
7045,
5277,
16578,
29889,
329,
29883,
3707,
3285,
5852,
29897,
1402,
1683,
29918,
29922,
8824,
29897,
13,
13,
1678,
732,
5819,
19515,
29918,
6799,
13,
1678,
822,
6664,
12504,
29898,
1311,
1125,
13,
4706,
565,
376,
13478,
12504,
29908,
1275,
1583,
29889,
4882,
29901,
13,
9651,
736,
5852,
13,
13,
1678,
732,
13478,
12504,
29889,
17471,
13,
1678,
822,
6664,
12504,
29898,
25932,
1125,
13,
4706,
736,
1206,
4197,
29898,
25932,
29889,
4882,
1275,
376,
13478,
12504,
613,
5852,
29897,
1402,
1683,
29918,
29922,
8824,
29897,
13,
13,
1678,
732,
5819,
19515,
29918,
6799,
13,
1678,
822,
756,
29918,
9053,
29918,
1989,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
9053,
29918,
1989,
338,
451,
6213,
13,
13,
1678,
732,
5349,
29918,
9053,
29918,
1989,
29889,
17471,
13,
1678,
822,
756,
29918,
9053,
29918,
1989,
29898,
25932,
1125,
13,
4706,
736,
1206,
4197,
29898,
25932,
29889,
9053,
29918,
1989,
29889,
275,
23538,
8516,
511,
5852,
29897,
1402,
1683,
29918,
29922,
8824,
29897,
13,
13,
1678,
732,
5819,
19515,
29918,
6799,
13,
1678,
822,
297,
29918,
5450,
362,
29918,
7165,
29898,
1311,
1125,
13,
4706,
9995,
13,
4706,
5953,
837,
1475,
565,
263,
12289,
338,
3625,
363,
13733,
2729,
13,
4706,
373,
278,
13733,
8898,
6942,
29889,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
1286,
353,
16578,
29889,
329,
29883,
3707,
580,
13,
4706,
1095,
353,
1286,
718,
5335,
287,
2554,
29898,
16700,
29922,
1311,
29889,
5450,
362,
29918,
22197,
29889,
16700,
29897,
13,
13,
4706,
565,
1583,
29889,
1333,
29918,
7045,
5277,
1095,
29901,
13,
9651,
736,
5852,
13,
13,
1678,
732,
262,
29918,
5450,
362,
29918,
7165,
29889,
17471,
13,
1678,
822,
297,
29918,
5450,
362,
29918,
7165,
29898,
25932,
1125,
13,
4706,
9995,
13,
4706,
5953,
837,
1475,
565,
263,
12289,
338,
3625,
363,
13733,
2729,
13,
4706,
373,
278,
13733,
8898,
6942,
29889,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
736,
1206,
29898,
13,
9651,
17288,
21111,
703,
3250,
613,
1067,
29879,
29889,
1333,
29918,
7045,
448,
3653,
29889,
3707,
3101,
5277,
9664,
362,
15644,
29889,
16700,
29892,
5852,
29897,
1402,
13,
9651,
1683,
29918,
29922,
8824,
29892,
13,
4706,
1723,
13,
13,
1678,
732,
6799,
13,
1678,
822,
17752,
29898,
1311,
1125,
13,
4706,
396,
6230,
2322,
1819,
13,
4706,
736,
29918,
24299,
353,
8853,
1491,
29918,
1997,
29918,
7039,
1115,
8853,
7039,
1115,
5159,
930,
13,
13,
4706,
1018,
29901,
13,
9651,
363,
6081,
297,
1583,
29889,
862,
8485,
29918,
6327,
29889,
24299,
29901,
13,
18884,
995,
353,
6081,
29889,
1767,
13,
18884,
565,
338,
8758,
29898,
1767,
29892,
921,
29945,
29900,
29929,
29889,
16616,
27427,
1125,
13,
462,
1678,
736,
29918,
24299,
3366,
16121,
29918,
13646,
29879,
3108,
353,
995,
13,
13,
18884,
25342,
338,
8758,
29898,
1767,
29892,
921,
29945,
29900,
29929,
29889,
20622,
2499,
725,
1230,
1170,
1125,
13,
462,
1678,
736,
29918,
24299,
3366,
1491,
29918,
1997,
29918,
7039,
3108,
3366,
7039,
3108,
353,
995,
13,
13,
18884,
25342,
338,
8758,
29898,
1767,
29892,
921,
29945,
29900,
29929,
29889,
5647,
2760,
2558,
27573,
1125,
13,
462,
1678,
736,
29918,
24299,
3366,
1062,
2760,
29918,
1989,
29918,
21125,
3108,
353,
995,
13,
13,
18884,
25342,
338,
8758,
29898,
1767,
29892,
921,
29945,
29900,
29929,
29889,
2558,
27573,
1125,
13,
462,
1678,
736,
29918,
24299,
3366,
1989,
29918,
21125,
3108,
353,
995,
13,
13,
18884,
25342,
338,
8758,
29898,
1767,
29892,
921,
29945,
29900,
29929,
29889,
20622,
2558,
12889,
1125,
13,
462,
1678,
736,
29918,
24299,
3366,
16009,
29918,
1989,
29918,
25378,
3108,
353,
8853,
2856,
29918,
2574,
1115,
5852,
29913,
13,
13,
18884,
25342,
338,
8758,
29898,
1767,
29892,
921,
29945,
29900,
29929,
29889,
13720,
537,
20350,
6638,
1125,
13,
462,
1678,
736,
29918,
24299,
3366,
6327,
8021,
29918,
3888,
29918,
5943,
3108,
353,
8853,
2856,
29918,
29874,
423,
1115,
5852,
29913,
13,
13,
18884,
25342,
338,
8758,
29898,
1767,
29892,
921,
29945,
29900,
29929,
29889,
13720,
537,
2558,
12889,
1125,
13,
462,
1678,
263,
1984,
353,
8853,
1509,
29918,
1989,
29918,
25378,
1115,
7700,
29892,
376,
1509,
29918,
8921,
537,
29918,
6327,
1115,
7700,
29913,
13,
13,
462,
1678,
565,
995,
29889,
1989,
29918,
25378,
29901,
13,
462,
4706,
263,
1984,
3366,
1509,
29918,
1989,
29918,
25378,
3108,
353,
5852,
13,
13,
462,
1678,
565,
995,
29889,
8921,
537,
29918,
6327,
29918,
790,
2853,
29901,
13,
462,
4706,
263,
1984,
3366,
1509,
29918,
8921,
537,
29918,
6327,
3108,
353,
5852,
13,
13,
462,
1678,
736,
29918,
24299,
3366,
8921,
537,
29918,
1989,
29918,
25378,
3108,
353,
263,
1984,
13,
13,
18884,
25342,
338,
8758,
29898,
1767,
29892,
921,
29945,
29900,
29929,
29889,
29907,
2241,
13398,
3224,
20325,
1125,
13,
462,
1678,
736,
29918,
24299,
3366,
29883,
2096,
29918,
27691,
29918,
9748,
3108,
353,
426,
13,
462,
4706,
376,
2856,
29918,
29883,
2096,
29918,
6099,
1115,
995,
13,
462,
1678,
500,
13,
13,
18884,
396,
14402,
29901,
2216,
20382,
2888,
438,
1367,
29879,
3447,
29889,
2045,
597,
3292,
29889,
510,
29914,
6779,
20157,
29916,
29914,
2409,
332,
29914,
12175,
29914,
29953,
29953,
29945,
13,
18884,
1683,
29901,
13,
462,
1678,
1857,
29918,
932,
29889,
21707,
29889,
27392,
29898,
13,
462,
4706,
376,
7281,
438,
1367,
29879,
451,
3447,
6969,
363,
17432,
5858,
1213,
13,
462,
1678,
1723,
13,
4706,
5174,
21403,
3399,
3149,
408,
321,
29901,
13,
9651,
2665,
719,
29889,
17885,
545,
2451,
580,
13,
9651,
1857,
29918,
932,
29889,
21707,
29889,
27392,
29898,
13,
18884,
376,
2525,
519,
304,
6088,
17752,
2861,
304,
23400,
3221,
297,
270,
1983,
1024,
29908,
13,
9651,
1723,
13,
4706,
5174,
7865,
2392,
408,
321,
29901,
13,
9651,
2665,
719,
29889,
17885,
545,
2451,
580,
13,
9651,
1857,
29918,
932,
29889,
21707,
29889,
27392,
703,
2525,
519,
304,
6088,
1159,
13,
9651,
1857,
29918,
932,
29889,
21707,
29889,
11739,
29898,
29872,
29897,
13,
13,
4706,
736,
736,
29918,
24299,
13,
13,
1678,
822,
4770,
276,
558,
12035,
1311,
1125,
13,
4706,
736,
376,
20455,
8021,
29898,
978,
3790,
978,
1800,
1642,
4830,
29898,
978,
29922,
1311,
29889,
978,
29897,
13,
13,
13,
29992,
3696,
29889,
1761,
575,
29918,
1454,
29898,
20455,
8021,
29889,
7854,
262,
800,
29892,
376,
4397,
1159,
13,
1753,
2767,
29918,
7854,
262,
800,
29898,
5182,
29892,
995,
29892,
14511,
1061,
1125,
13,
1678,
9995,
13,
1678,
6212,
3456,
304,
6441,
12289,
304,
278,
716,
12551,
13,
13,
1678,
584,
3207,
3646,
29901,
13,
1678,
584,
3207,
995,
29901,
13,
1678,
584,
3207,
14511,
1061,
29901,
13,
1678,
584,
2457,
29901,
13,
1678,
9995,
13,
1678,
12551,
29918,
8582,
353,
18224,
29889,
657,
29898,
1767,
29889,
8582,
29918,
978,
29897,
13,
1678,
4660,
353,
13515,
6227,
11499,
29918,
2303,
5659,
2965,
29918,
27047,
13,
1678,
1018,
29901,
13,
4706,
565,
3646,
29889,
9053,
29918,
1989,
470,
451,
12551,
29918,
8582,
29889,
276,
339,
2658,
29918,
1989,
29901,
13,
9651,
12551,
29918,
8582,
29889,
9009,
29898,
13,
18884,
3646,
29889,
978,
29892,
13,
18884,
3646,
29889,
2587,
29892,
13,
18884,
3646,
29889,
9053,
29918,
1989,
29892,
13,
18884,
3646,
29889,
14153,
29892,
13,
18884,
995,
29889,
6768,
29892,
13,
9651,
1723,
13,
9651,
4660,
353,
20134,
26925,
29918,
2303,
5659,
2965,
29918,
27047,
13,
1678,
5174,
8960,
408,
321,
29901,
13,
4706,
2665,
719,
29889,
17885,
545,
2451,
580,
13,
4706,
12020,
13,
13,
1678,
21556,
29889,
6717,
29898,
13,
4706,
376,
23848,
29918,
9009,
613,
13,
4706,
376,
11808,
613,
13,
308,
29896,
29892,
13,
4706,
12714,
29918,
11338,
3790,
13,
9651,
376,
4882,
1115,
4660,
29892,
13,
9651,
376,
6327,
8021,
1115,
3646,
29889,
978,
29892,
13,
9651,
376,
23848,
1115,
995,
29889,
1643,
29892,
13,
4706,
2981,
13,
1678,
1723,
13,
13,
13,
29992,
3696,
29889,
1761,
575,
29918,
1454,
29898,
20455,
8021,
29889,
3445,
6048,
29892,
376,
4397,
1159,
13,
1753,
2767,
29918,
3445,
9552,
29898,
5182,
29892,
995,
29892,
14511,
1061,
1125,
13,
1678,
9995,
13,
1678,
1932,
263,
12289,
338,
10902,
408,
525,
3445,
433,
1133,
29915,
591,
881,
451,
26051,
29889,
13,
13,
1678,
584,
3207,
3646,
29901,
13,
1678,
584,
3207,
995,
29901,
13,
1678,
584,
3207,
14511,
1061,
29901,
13,
1678,
584,
2457,
29901,
13,
1678,
9995,
13,
1678,
995,
29889,
25140,
353,
7700,
13,
2
] |
python/testing/parameterized/test_parameterized.py | amitsaha/playground | 4 | 73425 | <filename>python/testing/parameterized/test_parameterized.py
import unittest
from nose_parameterized import parameterized, param
@parameterized([param(2), param(3)])
def test_square(x):
assert x**2 == x**2
class AddTestCase(unittest.TestCase):
@parameterized.expand([
("string1", "string1"),
("string2", "string2")
])
def test_check_string(self, _, s):
assert isinstance(s, str)
| [
1,
529,
9507,
29958,
4691,
29914,
13424,
29914,
15501,
1891,
29914,
1688,
29918,
15501,
1891,
29889,
2272,
13,
5215,
443,
27958,
13,
3166,
26414,
29918,
15501,
1891,
1053,
3443,
1891,
29892,
1828,
13,
13,
29992,
15501,
1891,
4197,
3207,
29898,
29906,
511,
1828,
29898,
29941,
29897,
2314,
13,
1753,
1243,
29918,
17619,
29898,
29916,
1125,
13,
1678,
4974,
921,
1068,
29906,
1275,
921,
1068,
29906,
13,
13,
13,
1990,
3462,
3057,
8259,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
1678,
732,
15501,
1891,
29889,
18837,
4197,
13,
4706,
4852,
1807,
29896,
613,
376,
1807,
29896,
4968,
13,
4706,
4852,
1807,
29906,
613,
376,
1807,
29906,
1159,
13,
268,
2314,
13,
1678,
822,
1243,
29918,
3198,
29918,
1807,
29898,
1311,
29892,
17117,
269,
1125,
13,
4706,
4974,
338,
8758,
29898,
29879,
29892,
851,
29897,
13,
2
] |
geoip_test/__init__.py | soutys/geoip_test | 0 | 157236 | # -*- coding: utf-8 -*-
'''Package info module
'''
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
with_statement,
)
import os
WORK_DIR = os.path.dirname(os.path.abspath(__file__))
__author__ = 'soutys <<EMAIL>>'
__version__ = open(os.path.join(WORK_DIR, 'VERSION'), 'r').read().strip()
__classifiers__ = [
# 'Development Status :: 1 - Planning',
# 'Development Status :: 2 - Pre-Alpha',
'Development Status :: 3 - Alpha',
# 'Development Status :: 4 - Beta',
# 'Development Status :: 5 - Production/Stable',
# 'Development Status :: 6 - Mature',
# 'Development Status :: 7 - Inactive',
'Environment :: Other Environment',
'Intended Audience :: Developers',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Topic :: Utilities',
]
| [
1,
396,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
12008,
14459,
5235,
3883,
13,
12008,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
313,
13,
1678,
8380,
29918,
5215,
29892,
13,
1678,
8542,
29892,
13,
1678,
1596,
29918,
2220,
29892,
13,
1678,
29104,
29918,
20889,
1338,
29892,
13,
1678,
411,
29918,
20788,
29892,
13,
29897,
13,
13,
5215,
2897,
13,
13,
13,
11686,
29968,
29918,
9464,
353,
2897,
29889,
2084,
29889,
25721,
29898,
359,
29889,
2084,
29889,
370,
1028,
493,
22168,
1445,
1649,
876,
13,
13,
1649,
8921,
1649,
353,
525,
29879,
449,
952,
3532,
26862,
6227,
6778,
29915,
13,
1649,
3259,
1649,
353,
1722,
29898,
359,
29889,
2084,
29889,
7122,
29898,
11686,
29968,
29918,
9464,
29892,
525,
16358,
5477,
525,
29878,
2824,
949,
2141,
17010,
580,
13,
1649,
1990,
14903,
1649,
353,
518,
13,
1678,
396,
525,
21956,
358,
16034,
4761,
29871,
29896,
448,
1858,
9450,
742,
13,
1678,
396,
525,
21956,
358,
16034,
4761,
29871,
29906,
448,
4721,
29899,
28630,
742,
13,
1678,
525,
21956,
358,
16034,
4761,
29871,
29941,
448,
838,
2026,
742,
13,
1678,
396,
525,
21956,
358,
16034,
4761,
29871,
29946,
448,
350,
1187,
742,
13,
1678,
396,
525,
21956,
358,
16034,
4761,
29871,
29945,
448,
19561,
29914,
855,
519,
742,
13,
1678,
396,
525,
21956,
358,
16034,
4761,
29871,
29953,
448,
341,
1535,
742,
13,
1678,
396,
525,
21956,
358,
16034,
4761,
29871,
29955,
448,
512,
4925,
742,
13,
1678,
525,
18649,
4761,
5901,
16738,
742,
13,
1678,
525,
2928,
2760,
319,
4749,
663,
4761,
10682,
414,
742,
13,
1678,
525,
2928,
2760,
319,
4749,
663,
4761,
10682,
414,
742,
13,
1678,
525,
29931,
293,
1947,
4761,
438,
5425,
28268,
1490,
4761,
341,
1806,
19245,
742,
13,
1678,
525,
7094,
1218,
2184,
4761,
6570,
25266,
742,
13,
1678,
525,
9283,
4056,
17088,
4761,
5132,
742,
13,
1678,
525,
9283,
4056,
17088,
4761,
5132,
4761,
29871,
29906,
29889,
29955,
742,
13,
1678,
525,
9283,
4056,
17088,
4761,
5132,
4761,
29871,
29941,
29889,
29946,
742,
13,
1678,
525,
7031,
293,
4761,
22310,
1907,
742,
13,
29962,
13,
2
] |
parser/team27/G-27/execution/symbol/table.py | Lenin201/tytus | 1 | 25962 | class Table(object):
def __init__(self, name):
self.name = name
self.columns = []
def createColumn(self, column):
self.columns.append(column)
def readColumn(self, name):
for value in self.columns:
if value.name == name:
return value
def updateColumn(self, name, column):
for i in range(0,len(self.columns)):
if self.columns[i].name == name:
self.columns[i] = column
break
def deleteColumn(self, name):
for i in range(0, len(self.columns)):
if self.columns[i].name == name:
del self.columns[i]
break
| [
1,
770,
6137,
29898,
3318,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1024,
1125,
13,
4706,
1583,
29889,
978,
353,
1024,
13,
4706,
1583,
29889,
13099,
353,
5159,
13,
268,
13,
1678,
822,
1653,
4409,
29898,
1311,
29892,
1897,
1125,
13,
4706,
1583,
29889,
13099,
29889,
4397,
29898,
4914,
29897,
13,
268,
13,
1678,
822,
1303,
4409,
29898,
1311,
29892,
1024,
1125,
13,
4706,
363,
995,
297,
1583,
29889,
13099,
29901,
13,
9651,
565,
995,
29889,
978,
1275,
1024,
29901,
13,
18884,
736,
995,
13,
268,
13,
1678,
822,
2767,
4409,
29898,
1311,
29892,
1024,
29892,
1897,
1125,
13,
4706,
363,
474,
297,
3464,
29898,
29900,
29892,
2435,
29898,
1311,
29889,
13099,
22164,
13,
9651,
565,
1583,
29889,
13099,
29961,
29875,
1822,
978,
1275,
1024,
29901,
13,
18884,
1583,
29889,
13099,
29961,
29875,
29962,
353,
1897,
13,
18884,
2867,
13,
268,
13,
1678,
822,
5217,
4409,
29898,
1311,
29892,
1024,
1125,
13,
4706,
363,
474,
297,
3464,
29898,
29900,
29892,
7431,
29898,
1311,
29889,
13099,
22164,
13,
9651,
565,
1583,
29889,
13099,
29961,
29875,
1822,
978,
1275,
1024,
29901,
13,
18884,
628,
1583,
29889,
13099,
29961,
29875,
29962,
13,
18884,
2867,
13,
2
] |
flask_user/tests/test_multiple_emails.py | 80pctsols/Flask-User | 0 | 138386 | <filename>flask_user/tests/test_multiple_emails.py
"""
tests.test_all_forms.py
---------------------------
Flask-User automated tests:
Tests posting a sequence of valid forms for all possible config combinations
:copyright: (c) 2013 by <NAME>
:author: <NAME> (<EMAIL>)
:license: Simplified BSD License, see LICENSE.txt for more details.
"""
from __future__ import print_function
import datetime
from flask import current_app, url_for
# **********************
# ** Global Variables **
# **********************
# Using global variable for speed
user1 = None
# ********************************
# ** Automatically called Tests **
# ********************************
# The 'client' and 'app' parameters are set up in conftest.py
# Functions that start with 'test' will be run automatically by the test suite runner (py.test)
def test_multiple_emails(app, db, client):
"""
Test 'multiple emails per user' feature
"""
# Set Flask-User settings
um = current_app.user_manager
um.enable_register = True
um.enable_username = False
um.enable_email = True
um.enable_confirm_email = True
um.enable_change_username = False
um.enable_change_password = False
um.enable_forgot_password = False
um.enable_multiple_emails = True
um.enable_retype_password = False
# Adjust DbAdapter settings
um.db_adapter.UserEmailClass = app.UserEmailClass
# Adjust URL routes
app.add_url_rule(um.email_action_url, 'user.email_action', um.email_action_view_function)
app.add_url_rule(um.manage_emails_url, 'user.manage_emails', um.manage_emails_view_function, methods=['GET', 'POST'])
# constants
EMAIL1 = '<EMAIL>'
EMAIL2 = '<EMAIL>'
PASSWORD = '<PASSWORD>'
# Register user
response = client.post_valid_form(url_for('user.register'), email=EMAIL1, password=PASSWORD)
user_email1 = um.db_adapter.UserEmailClass.query.filter(um.db_adapter.UserEmailClass.email==EMAIL1).first()
assert user_email1 != None
# Confirm email
confirmation_token = um.generate_token(user_email1.id)
client.get_valid_page(url_for('user.confirm_email', token=confirmation_token))
# Log in using email1
client.login(email=EMAIL1, password=PASSWORD)
# Visit manage emails page
response = client.get_valid_page(url_for('user.manage_emails'))
assert response.data.find(EMAIL1) >= 0
# Add an email
response = client.post_valid_form(url_for('user.manage_emails'), email=EMAIL2)
assert response.data.find(EMAIL1) >= 0
assert response.data.find(EMAIL2) >= 0
user_email2 = um.db_adapter.UserEmailClass.query.filter(um.db_adapter.UserEmailClass.email==EMAIL2).first()
assert user_email2 != None
# Confirm email
confirmation_token = um.generate_token(user_email2.id)
client.get_valid_page(url_for('user.confirm_email', token=confirmation_token))
# Logout
client.logout()
# Log in using email1
client.login(email=EMAIL1, password=PASSWORD)
# Logout
client.logout()
# Log in using email2
client.login(email=EMAIL2, password=PASSWORD)
# Confirm
response = client.get_valid_page(url_for('user.email_action', id=user_email2.id, action='confirm'))
# Make primary
response = client.get_valid_page(url_for('user.email_action', id=user_email2.id, action='make-primary'))
# Delete
response = client.get_valid_page(url_for('user.email_action', id=user_email1.id, action='delete'))
# Logout
client.logout()
# Restore settings
um.enable_multiple_emails = False
um.enable_confirm_email = True
um.enable_retype_password = True
um.db_adapter.UserEmailClass = None
| [
1,
529,
9507,
29958,
1579,
1278,
29918,
1792,
29914,
21150,
29914,
1688,
29918,
20787,
29918,
331,
2234,
29889,
2272,
13,
15945,
29908,
13,
1678,
6987,
29889,
1688,
29918,
497,
29918,
9514,
29889,
2272,
13,
1678,
448,
2683,
28400,
13,
1678,
2379,
1278,
29899,
2659,
3345,
630,
6987,
29901,
13,
1678,
4321,
29879,
16742,
263,
5665,
310,
2854,
7190,
363,
599,
1950,
2295,
18240,
13,
13,
1678,
584,
8552,
1266,
29901,
313,
29883,
29897,
29871,
29906,
29900,
29896,
29941,
491,
529,
5813,
29958,
13,
1678,
584,
8921,
29901,
529,
5813,
29958,
313,
29966,
26862,
6227,
12948,
13,
1678,
584,
506,
1947,
29901,
3439,
572,
2164,
350,
7230,
19245,
29892,
1074,
365,
2965,
1430,
1660,
29889,
3945,
363,
901,
4902,
29889,
13,
15945,
29908,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
5215,
12865,
13,
13,
3166,
29784,
1053,
1857,
29918,
932,
29892,
3142,
29918,
1454,
13,
13,
29937,
334,
7775,
2328,
29930,
13,
29937,
3579,
12002,
9586,
1849,
3579,
13,
29937,
334,
7775,
2328,
29930,
13,
29937,
5293,
5534,
2286,
363,
6210,
13,
1792,
29896,
353,
6213,
13,
13,
29937,
334,
7775,
4189,
2328,
17435,
13,
29937,
3579,
15854,
19574,
2000,
4321,
29879,
3579,
13,
29937,
334,
7775,
4189,
2328,
17435,
13,
29937,
450,
525,
4645,
29915,
322,
525,
932,
29915,
4128,
526,
731,
701,
297,
378,
615,
342,
29889,
2272,
13,
29937,
6680,
29879,
393,
1369,
411,
525,
1688,
29915,
674,
367,
1065,
6336,
491,
278,
1243,
9460,
28877,
313,
2272,
29889,
1688,
29897,
13,
13,
1753,
1243,
29918,
20787,
29918,
331,
2234,
29898,
932,
29892,
4833,
29892,
3132,
1125,
13,
1678,
9995,
13,
1678,
4321,
525,
20787,
24609,
639,
1404,
29915,
4682,
13,
1678,
9995,
13,
13,
1678,
396,
3789,
2379,
1278,
29899,
2659,
6055,
13,
1678,
1922,
353,
1857,
29918,
932,
29889,
1792,
29918,
12847,
13,
1678,
1922,
29889,
12007,
29918,
9573,
353,
5852,
13,
1678,
1922,
29889,
12007,
29918,
6786,
353,
7700,
13,
1678,
1922,
29889,
12007,
29918,
5269,
353,
5852,
13,
1678,
1922,
29889,
12007,
29918,
26897,
29918,
5269,
353,
5852,
13,
1678,
1922,
29889,
12007,
29918,
3167,
29918,
6786,
353,
7700,
13,
1678,
1922,
29889,
12007,
29918,
3167,
29918,
5630,
353,
7700,
13,
1678,
1922,
29889,
12007,
29918,
29888,
990,
327,
29918,
5630,
353,
7700,
13,
1678,
1922,
29889,
12007,
29918,
20787,
29918,
331,
2234,
353,
5852,
13,
1678,
1922,
29889,
12007,
29918,
276,
1853,
29918,
5630,
353,
7700,
13,
13,
1678,
396,
2087,
5143,
24331,
6168,
6055,
13,
1678,
1922,
29889,
2585,
29918,
21412,
29889,
2659,
9823,
2385,
353,
623,
29889,
2659,
9823,
2385,
13,
13,
1678,
396,
2087,
5143,
3988,
12049,
13,
1678,
623,
29889,
1202,
29918,
2271,
29918,
7491,
29898,
398,
29889,
5269,
29918,
2467,
29918,
2271,
29892,
29871,
525,
1792,
29889,
5269,
29918,
2467,
742,
29871,
1922,
29889,
5269,
29918,
2467,
29918,
1493,
29918,
2220,
29897,
13,
1678,
623,
29889,
1202,
29918,
2271,
29918,
7491,
29898,
398,
29889,
1171,
482,
29918,
331,
2234,
29918,
2271,
29892,
525,
1792,
29889,
1171,
482,
29918,
331,
2234,
742,
1922,
29889,
1171,
482,
29918,
331,
2234,
29918,
1493,
29918,
2220,
29892,
3519,
29922,
1839,
7194,
742,
525,
5438,
11287,
13,
13,
1678,
396,
17727,
13,
1678,
382,
1529,
6227,
29896,
353,
12801,
26862,
6227,
16299,
13,
1678,
382,
1529,
6227,
29906,
353,
12801,
26862,
6227,
16299,
13,
1678,
17687,
1799,
17013,
353,
12801,
25711,
17013,
16299,
13,
13,
1678,
396,
12577,
1404,
13,
1678,
2933,
353,
3132,
29889,
2490,
29918,
3084,
29918,
689,
29898,
2271,
29918,
1454,
877,
1792,
29889,
9573,
5477,
4876,
29922,
26862,
6227,
29896,
29892,
4800,
29922,
25711,
17013,
29897,
13,
1678,
1404,
29918,
5269,
29896,
353,
1922,
29889,
2585,
29918,
21412,
29889,
2659,
9823,
2385,
29889,
1972,
29889,
4572,
29898,
398,
29889,
2585,
29918,
21412,
29889,
2659,
9823,
2385,
29889,
5269,
1360,
26862,
6227,
29896,
467,
4102,
580,
13,
1678,
4974,
1404,
29918,
5269,
29896,
2804,
6213,
13,
13,
1678,
396,
10811,
3568,
4876,
13,
1678,
9659,
362,
29918,
6979,
353,
1922,
29889,
17158,
29918,
6979,
29898,
1792,
29918,
5269,
29896,
29889,
333,
29897,
13,
1678,
3132,
29889,
657,
29918,
3084,
29918,
3488,
29898,
2271,
29918,
1454,
877,
1792,
29889,
26897,
29918,
5269,
742,
5993,
29922,
26897,
362,
29918,
6979,
876,
13,
13,
1678,
396,
4522,
297,
773,
4876,
29896,
13,
1678,
3132,
29889,
7507,
29898,
5269,
29922,
26862,
6227,
29896,
29892,
4800,
29922,
25711,
17013,
29897,
13,
13,
1678,
396,
5741,
277,
10933,
24609,
1813,
13,
1678,
2933,
353,
3132,
29889,
657,
29918,
3084,
29918,
3488,
29898,
2271,
29918,
1454,
877,
1792,
29889,
1171,
482,
29918,
331,
2234,
8785,
13,
1678,
4974,
2933,
29889,
1272,
29889,
2886,
29898,
26862,
6227,
29896,
29897,
6736,
29871,
29900,
13,
13,
1678,
396,
3462,
385,
4876,
13,
1678,
2933,
353,
3132,
29889,
2490,
29918,
3084,
29918,
689,
29898,
2271,
29918,
1454,
877,
1792,
29889,
1171,
482,
29918,
331,
2234,
5477,
4876,
29922,
26862,
6227,
29906,
29897,
13,
1678,
4974,
2933,
29889,
1272,
29889,
2886,
29898,
26862,
6227,
29896,
29897,
6736,
29871,
29900,
13,
1678,
4974,
2933,
29889,
1272,
29889,
2886,
29898,
26862,
6227,
29906,
29897,
6736,
29871,
29900,
13,
1678,
1404,
29918,
5269,
29906,
353,
1922,
29889,
2585,
29918,
21412,
29889,
2659,
9823,
2385,
29889,
1972,
29889,
4572,
29898,
398,
29889,
2585,
29918,
21412,
29889,
2659,
9823,
2385,
29889,
5269,
1360,
26862,
6227,
29906,
467,
4102,
580,
13,
1678,
4974,
1404,
29918,
5269,
29906,
2804,
6213,
13,
13,
1678,
396,
10811,
3568,
4876,
13,
1678,
9659,
362,
29918,
6979,
353,
1922,
29889,
17158,
29918,
6979,
29898,
1792,
29918,
5269,
29906,
29889,
333,
29897,
13,
1678,
3132,
29889,
657,
29918,
3084,
29918,
3488,
29898,
2271,
29918,
1454,
877,
1792,
29889,
26897,
29918,
5269,
742,
5993,
29922,
26897,
362,
29918,
6979,
876,
13,
13,
1678,
396,
4522,
449,
13,
1678,
3132,
29889,
1188,
449,
580,
13,
13,
1678,
396,
4522,
297,
773,
4876,
29896,
13,
1678,
3132,
29889,
7507,
29898,
5269,
29922,
26862,
6227,
29896,
29892,
4800,
29922,
25711,
17013,
29897,
13,
13,
1678,
396,
4522,
449,
13,
1678,
3132,
29889,
1188,
449,
580,
13,
13,
1678,
396,
4522,
297,
773,
4876,
29906,
13,
1678,
3132,
29889,
7507,
29898,
5269,
29922,
26862,
6227,
29906,
29892,
4800,
29922,
25711,
17013,
29897,
13,
13,
1678,
396,
10811,
3568,
13,
1678,
2933,
353,
3132,
29889,
657,
29918,
3084,
29918,
3488,
29898,
2271,
29918,
1454,
877,
1792,
29889,
5269,
29918,
2467,
742,
1178,
29922,
1792,
29918,
5269,
29906,
29889,
333,
29892,
3158,
2433,
26897,
8785,
13,
13,
1678,
396,
8561,
7601,
13,
1678,
2933,
353,
3132,
29889,
657,
29918,
3084,
29918,
3488,
29898,
2271,
29918,
1454,
877,
1792,
29889,
5269,
29918,
2467,
742,
1178,
29922,
1792,
29918,
5269,
29906,
29889,
333,
29892,
3158,
2433,
5675,
29899,
16072,
8785,
13,
13,
1678,
396,
21267,
13,
1678,
2933,
353,
3132,
29889,
657,
29918,
3084,
29918,
3488,
29898,
2271,
29918,
1454,
877,
1792,
29889,
5269,
29918,
2467,
742,
1178,
29922,
1792,
29918,
5269,
29896,
29889,
333,
29892,
3158,
2433,
8143,
8785,
13,
13,
1678,
396,
4522,
449,
13,
1678,
3132,
29889,
1188,
449,
580,
13,
13,
1678,
396,
11654,
487,
6055,
13,
1678,
1922,
29889,
12007,
29918,
20787,
29918,
331,
2234,
353,
7700,
13,
1678,
1922,
29889,
12007,
29918,
26897,
29918,
5269,
353,
5852,
13,
1678,
1922,
29889,
12007,
29918,
276,
1853,
29918,
5630,
353,
5852,
13,
1678,
1922,
29889,
2585,
29918,
21412,
29889,
2659,
9823,
2385,
353,
6213,
13,
13,
2
] |
catkin_ws/src/00-infrastructure/duckietown/include/duckietown_utils_tests/colors.py | yxiao1996/dev | 2 | 188687 | <gh_stars>1-10
from comptests.registrar import comptest, run_module_tests
from termcolor import colored
from duckietown_utils.text_utils import (get_length_on_screen, format_table_plus,
remove_escapes, make_row_red)
@comptest
def test_color_sizes():
s1 = 'one'
s2 = colored(s1, 'magenta')
# print(s1.__repr__())
# print(s2.__repr__())
l1 = get_length_on_screen(s1)
l2 = get_length_on_screen(s2)
# print l1, l2
assert l1 == l2
def get_test_table():
table = []
for i in range(3):
row = []
for j in range(5):
row.append('*' * i * j)
table.append(row)
return table
@comptest
def test_table():
table = get_test_table()
r1 = format_table_plus(table)
table[1] = make_row_red(table[1])
r2 = format_table_plus(table)
#print r1
#print r2
r2e = remove_escapes(r2)
#print r2e
assert r1 == r2e
if __name__ == '__main__':
run_module_tests()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
13,
3166,
18741,
9197,
29889,
29238,
279,
1053,
18741,
342,
29892,
1065,
29918,
5453,
29918,
21150,
13,
13,
3166,
1840,
2780,
1053,
28684,
13,
13,
3166,
868,
384,
2035,
776,
29918,
13239,
29889,
726,
29918,
13239,
1053,
313,
657,
29918,
2848,
29918,
265,
29918,
10525,
29892,
3402,
29918,
2371,
29918,
11242,
29892,
29871,
13,
462,
462,
308,
3349,
29918,
267,
5030,
267,
29892,
1207,
29918,
798,
29918,
1127,
29897,
13,
13,
13,
29992,
510,
415,
342,
13,
1753,
1243,
29918,
2780,
29918,
29879,
7093,
7295,
13,
1678,
269,
29896,
353,
525,
650,
29915,
13,
268,
13,
1678,
269,
29906,
353,
28684,
29898,
29879,
29896,
29892,
525,
11082,
6381,
1495,
13,
418,
13,
29937,
268,
1596,
29898,
29879,
29896,
17255,
276,
558,
1649,
3101,
13,
29937,
268,
1596,
29898,
29879,
29906,
17255,
276,
558,
1649,
3101,
13,
268,
13,
1678,
301,
29896,
353,
679,
29918,
2848,
29918,
265,
29918,
10525,
29898,
29879,
29896,
29897,
13,
1678,
301,
29906,
353,
679,
29918,
2848,
29918,
265,
29918,
10525,
29898,
29879,
29906,
29897,
13,
29937,
268,
1596,
301,
29896,
29892,
301,
29906,
13,
1678,
4974,
301,
29896,
1275,
301,
29906,
13,
268,
13,
268,
13,
1753,
679,
29918,
1688,
29918,
2371,
7295,
13,
1678,
1591,
353,
5159,
13,
1678,
363,
474,
297,
3464,
29898,
29941,
1125,
13,
4706,
1948,
353,
5159,
13,
4706,
363,
432,
297,
3464,
29898,
29945,
1125,
13,
9651,
1948,
29889,
4397,
877,
29930,
29915,
334,
474,
334,
432,
29897,
13,
4706,
1591,
29889,
4397,
29898,
798,
29897,
13,
1678,
736,
1591,
13,
13,
29992,
510,
415,
342,
13,
1753,
1243,
29918,
2371,
7295,
13,
268,
13,
1678,
1591,
353,
679,
29918,
1688,
29918,
2371,
580,
13,
1678,
364,
29896,
353,
3402,
29918,
2371,
29918,
11242,
29898,
2371,
29897,
13,
268,
13,
1678,
1591,
29961,
29896,
29962,
353,
1207,
29918,
798,
29918,
1127,
29898,
2371,
29961,
29896,
2314,
13,
1678,
364,
29906,
353,
3402,
29918,
2371,
29918,
11242,
29898,
2371,
29897,
13,
268,
13,
1678,
396,
2158,
364,
29896,
13,
1678,
396,
2158,
364,
29906,
13,
1678,
364,
29906,
29872,
353,
3349,
29918,
267,
5030,
267,
29898,
29878,
29906,
29897,
13,
1678,
396,
2158,
364,
29906,
29872,
13,
1678,
4974,
364,
29896,
1275,
364,
29906,
29872,
13,
268,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
1065,
29918,
5453,
29918,
21150,
580,
13,
268,
2
] |
anaf/documents/migrations/0001_initial.py | tovmeod/anaf | 2 | 18751 | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import anaf.documents.models
import anaf.documents.files
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Document',
fields=[
('object_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='core.Object')),
('title', models.CharField(max_length=255)),
('body', models.TextField(null=True, blank=True)),
],
options={
'ordering': ['-last_updated'],
},
bases=('core.object',),
),
migrations.CreateModel(
name='File',
fields=[
('object_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='core.Object')),
('name', models.CharField(max_length=255)),
('content', models.FileField(storage=anaf.documents.files.FileStorage(), upload_to=anaf.documents.models.generate_filename)),
],
options={
'ordering': ['-last_updated'],
},
bases=('core.object',),
),
migrations.CreateModel(
name='Folder',
fields=[
('object_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='core.Object')),
('name', models.CharField(max_length=255)),
('parent', models.ForeignKey(related_name='child_set', blank=True, to='documents.Folder', null=True)),
],
options={
},
bases=('core.object',),
),
migrations.CreateModel(
name='WebLink',
fields=[
('object_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='core.Object')),
('title', models.CharField(max_length=255)),
('url', models.CharField(max_length=255)),
('folder', models.ForeignKey(to='documents.Folder')),
],
options={
'ordering': ['-last_updated'],
},
bases=('core.object',),
),
migrations.AddField(
model_name='file',
name='folder',
field=models.ForeignKey(to='documents.Folder'),
preserve_default=True,
),
migrations.AddField(
model_name='document',
name='folder',
field=models.ForeignKey(to='documents.Folder'),
preserve_default=True,
),
]
| [
1,
396,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
3166,
9557,
29889,
2585,
1053,
4733,
29892,
9725,
800,
13,
5215,
385,
2142,
29889,
3225,
29879,
29889,
9794,
13,
5215,
385,
2142,
29889,
3225,
29879,
29889,
5325,
13,
13,
13,
1990,
341,
16783,
29898,
26983,
800,
29889,
29924,
16783,
1125,
13,
13,
1678,
9962,
353,
518,
13,
4706,
6702,
3221,
742,
525,
29900,
29900,
29900,
29896,
29918,
11228,
5477,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
6268,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
3318,
29918,
7414,
742,
4733,
29889,
6716,
1762,
6716,
3073,
29898,
3560,
29918,
2324,
29922,
5574,
29892,
4469,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
304,
2433,
3221,
29889,
2061,
1495,
511,
13,
18884,
6702,
3257,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
8243,
13,
18884,
6702,
2587,
742,
4733,
29889,
15778,
29898,
4304,
29922,
5574,
29892,
9654,
29922,
5574,
8243,
13,
9651,
21251,
13,
9651,
3987,
3790,
13,
18884,
525,
2098,
292,
2396,
6024,
29899,
4230,
29918,
21402,
7464,
13,
9651,
2981,
13,
9651,
22561,
29922,
877,
3221,
29889,
3318,
742,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
2283,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
3318,
29918,
7414,
742,
4733,
29889,
6716,
1762,
6716,
3073,
29898,
3560,
29918,
2324,
29922,
5574,
29892,
4469,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
304,
2433,
3221,
29889,
2061,
1495,
511,
13,
18884,
6702,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
8243,
13,
18884,
6702,
3051,
742,
4733,
29889,
2283,
3073,
29898,
12925,
29922,
1648,
29888,
29889,
3225,
29879,
29889,
5325,
29889,
2283,
10486,
3285,
6441,
29918,
517,
29922,
1648,
29888,
29889,
3225,
29879,
29889,
9794,
29889,
17158,
29918,
9507,
8243,
13,
9651,
21251,
13,
9651,
3987,
3790,
13,
18884,
525,
2098,
292,
2396,
6024,
29899,
4230,
29918,
21402,
7464,
13,
9651,
2981,
13,
9651,
22561,
29922,
877,
3221,
29889,
3318,
742,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
12924,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
3318,
29918,
7414,
742,
4733,
29889,
6716,
1762,
6716,
3073,
29898,
3560,
29918,
2324,
29922,
5574,
29892,
4469,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
304,
2433,
3221,
29889,
2061,
1495,
511,
13,
18884,
6702,
978,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
8243,
13,
18884,
6702,
3560,
742,
4733,
29889,
27755,
2558,
29898,
12817,
29918,
978,
2433,
5145,
29918,
842,
742,
9654,
29922,
5574,
29892,
304,
2433,
3225,
29879,
29889,
12924,
742,
1870,
29922,
5574,
8243,
13,
9651,
21251,
13,
9651,
3987,
3790,
13,
9651,
2981,
13,
9651,
22561,
29922,
877,
3221,
29889,
3318,
742,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
3609,
6595,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
3318,
29918,
7414,
742,
4733,
29889,
6716,
1762,
6716,
3073,
29898,
3560,
29918,
2324,
29922,
5574,
29892,
4469,
29918,
11600,
29922,
5574,
29892,
7601,
29918,
1989,
29922,
5574,
29892,
28755,
29922,
8824,
29892,
304,
2433,
3221,
29889,
2061,
1495,
511,
13,
18884,
6702,
3257,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
8243,
13,
18884,
6702,
2271,
742,
4733,
29889,
27890,
29898,
3317,
29918,
2848,
29922,
29906,
29945,
29945,
8243,
13,
18884,
6702,
12083,
742,
4733,
29889,
27755,
2558,
29898,
517,
2433,
3225,
29879,
29889,
12924,
1495,
511,
13,
9651,
21251,
13,
9651,
3987,
3790,
13,
18884,
525,
2098,
292,
2396,
6024,
29899,
4230,
29918,
21402,
7464,
13,
9651,
2981,
13,
9651,
22561,
29922,
877,
3221,
29889,
3318,
742,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
1445,
742,
13,
9651,
1024,
2433,
12083,
742,
13,
9651,
1746,
29922,
9794,
29889,
27755,
2558,
29898,
517,
2433,
3225,
29879,
29889,
12924,
5477,
13,
9651,
19905,
29918,
4381,
29922,
5574,
29892,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
3225,
742,
13,
9651,
1024,
2433,
12083,
742,
13,
9651,
1746,
29922,
9794,
29889,
27755,
2558,
29898,
517,
2433,
3225,
29879,
29889,
12924,
5477,
13,
9651,
19905,
29918,
4381,
29922,
5574,
29892,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
ibeis/algo/graph/mixin_groundtruth.py | brmscheiner/ibeis | 0 | 199584 | <filename>ibeis/algo/graph/mixin_groundtruth.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import utool as ut
import numpy as np
import vtool as vt
import pandas as pd
from ibeis.algo.graph.nx_utils import ensure_multi_index
from ibeis.algo.graph.state import POSTV, NEGTV, INCMP
print, rrr, profile = ut.inject2(__name__)
class Groundtruth(object):
def is_comparable(infr, aid_pairs, allow_guess=True):
"""
Guesses by default when real comparable information is not available.
"""
if infr.ibs is not None:
return infr.ibeis_is_comparable(aid_pairs, allow_guess)
is_comp = list(infr.gen_edge_values('gt_comparable', edges=aid_pairs,
default=True,
on_missing='default'))
return np.array(is_comp)
def is_photobomb(infr, aid_pairs):
if infr.ibs is not None:
return infr.ibeis_is_photobomb(aid_pairs)
return np.array([False] * len(aid_pairs))
def is_same(infr, aid_pairs):
if infr.ibs is not None:
return infr.ibeis_is_same(aid_pairs)
node_dict = ut.nx_node_dict(infr.graph)
nid1 = [node_dict[n1]['orig_name_label']
for n1, n2 in aid_pairs]
nid2 = [node_dict[n2]['orig_name_label']
for n1, n2 in aid_pairs]
return np.equal(nid1, nid2)
def apply_edge_truth(infr, edges=None):
if edges is None:
edges = list(infr.edges())
edge_truth_df = infr.match_state_df(edges)
edge_truth = edge_truth_df.idxmax(axis=1).to_dict()
infr.set_edge_attrs('truth', edge_truth)
infr.edge_truth.update(edge_truth)
def match_state_df(infr, index):
""" Returns groundtruth state based on ibeis controller """
index = ensure_multi_index(index, ('aid1', 'aid2'))
aid_pairs = np.asarray(index.tolist())
aid_pairs = vt.ensure_shape(aid_pairs, (None, 2))
is_same = infr.is_same(aid_pairs)
is_comp = infr.is_comparable(aid_pairs)
match_state_df = pd.DataFrame.from_items([
(NEGTV, ~is_same & is_comp),
(POSTV, is_same & is_comp),
(INCMP, ~is_comp),
])
match_state_df.index = index
return match_state_df
def match_state_gt(infr, edge):
if edge in infr.edge_truth:
truth = infr.edge_truth[edge]
elif hasattr(infr, 'dummy_verif'):
truth = infr.dummy_verif._get_truth(edge)
else:
aid_pairs = np.asarray([edge])
is_same = infr.is_same(aid_pairs)[0]
is_comp = infr.is_comparable(aid_pairs)[0]
match_state = pd.Series(dict([
(NEGTV, ~is_same & is_comp),
(POSTV, is_same & is_comp),
(INCMP, ~is_comp),
]))
truth = match_state.idxmax()
return truth
def edge_attr_df(infr, key, edges=None, default=ut.NoParam):
""" constructs DataFrame using current predictions """
edge_states = infr.gen_edge_attrs(key, edges=edges, default=default)
edge_states = list(edge_states)
if isinstance(edges, pd.MultiIndex):
index = edges
else:
if edges is None:
edges_ = ut.take_column(edge_states, 0)
else:
edges_ = ut.lmap(tuple, ut.aslist(edges))
index = pd.MultiIndex.from_tuples(edges_, names=('aid1', 'aid2'))
records = ut.itake_column(edge_states, 1)
edge_df = pd.Series.from_array(records)
edge_df.name = key
edge_df.index = index
return edge_df
| [
1,
529,
9507,
29958,
18673,
275,
29914,
284,
1484,
29914,
4262,
29914,
28084,
262,
29918,
2057,
509,
2806,
29889,
2272,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
29892,
8542,
29892,
1596,
29918,
2220,
29892,
29104,
29918,
20889,
1338,
13,
5215,
318,
10154,
408,
3477,
13,
5215,
12655,
408,
7442,
13,
5215,
325,
10154,
408,
325,
29873,
13,
5215,
11701,
408,
10518,
13,
3166,
474,
915,
275,
29889,
284,
1484,
29889,
4262,
29889,
23818,
29918,
13239,
1053,
9801,
29918,
9910,
29918,
2248,
13,
3166,
474,
915,
275,
29889,
284,
1484,
29889,
4262,
29889,
3859,
1053,
11971,
29963,
29892,
405,
11787,
8050,
29892,
2672,
29907,
3580,
13,
2158,
29892,
364,
21478,
29892,
8722,
353,
3477,
29889,
21920,
29906,
22168,
978,
1649,
29897,
13,
13,
13,
1990,
1632,
618,
509,
2806,
29898,
3318,
1125,
13,
1678,
822,
338,
29918,
510,
862,
519,
29898,
262,
1341,
29892,
16226,
29918,
29886,
7121,
29892,
2758,
29918,
2543,
404,
29922,
5574,
1125,
13,
4706,
9995,
13,
4706,
2088,
15322,
491,
2322,
746,
1855,
5734,
519,
2472,
338,
451,
3625,
29889,
13,
4706,
9995,
13,
4706,
565,
297,
1341,
29889,
747,
29879,
338,
451,
6213,
29901,
13,
9651,
736,
297,
1341,
29889,
18673,
275,
29918,
275,
29918,
510,
862,
519,
29898,
29874,
333,
29918,
29886,
7121,
29892,
2758,
29918,
2543,
404,
29897,
13,
4706,
338,
29918,
2388,
353,
1051,
29898,
262,
1341,
29889,
1885,
29918,
12864,
29918,
5975,
877,
4141,
29918,
510,
862,
519,
742,
12770,
29922,
29874,
333,
29918,
29886,
7121,
29892,
13,
462,
462,
9651,
2322,
29922,
5574,
29892,
13,
462,
462,
9651,
373,
29918,
27259,
2433,
4381,
8785,
13,
4706,
736,
7442,
29889,
2378,
29898,
275,
29918,
2388,
29897,
13,
13,
1678,
822,
338,
29918,
561,
327,
711,
3424,
29898,
262,
1341,
29892,
16226,
29918,
29886,
7121,
1125,
13,
4706,
565,
297,
1341,
29889,
747,
29879,
338,
451,
6213,
29901,
13,
9651,
736,
297,
1341,
29889,
18673,
275,
29918,
275,
29918,
561,
327,
711,
3424,
29898,
29874,
333,
29918,
29886,
7121,
29897,
13,
4706,
736,
7442,
29889,
2378,
4197,
8824,
29962,
334,
7431,
29898,
29874,
333,
29918,
29886,
7121,
876,
13,
13,
1678,
822,
338,
29918,
17642,
29898,
262,
1341,
29892,
16226,
29918,
29886,
7121,
1125,
13,
4706,
565,
297,
1341,
29889,
747,
29879,
338,
451,
6213,
29901,
13,
9651,
736,
297,
1341,
29889,
18673,
275,
29918,
275,
29918,
17642,
29898,
29874,
333,
29918,
29886,
7121,
29897,
13,
4706,
2943,
29918,
8977,
353,
3477,
29889,
23818,
29918,
3177,
29918,
8977,
29898,
262,
1341,
29889,
4262,
29897,
13,
4706,
302,
333,
29896,
353,
518,
3177,
29918,
8977,
29961,
29876,
29896,
22322,
12683,
29918,
978,
29918,
1643,
2033,
13,
18884,
363,
302,
29896,
29892,
302,
29906,
297,
16226,
29918,
29886,
7121,
29962,
13,
4706,
302,
333,
29906,
353,
518,
3177,
29918,
8977,
29961,
29876,
29906,
22322,
12683,
29918,
978,
29918,
1643,
2033,
13,
18884,
363,
302,
29896,
29892,
302,
29906,
297,
16226,
29918,
29886,
7121,
29962,
13,
4706,
736,
7442,
29889,
11745,
29898,
29876,
333,
29896,
29892,
302,
333,
29906,
29897,
13,
13,
1678,
822,
3394,
29918,
12864,
29918,
509,
2806,
29898,
262,
1341,
29892,
12770,
29922,
8516,
1125,
13,
4706,
565,
12770,
338,
6213,
29901,
13,
9651,
12770,
353,
1051,
29898,
262,
1341,
29889,
287,
2710,
3101,
13,
4706,
7636,
29918,
509,
2806,
29918,
2176,
353,
297,
1341,
29889,
4352,
29918,
3859,
29918,
2176,
29898,
287,
2710,
29897,
13,
4706,
7636,
29918,
509,
2806,
353,
7636,
29918,
509,
2806,
29918,
2176,
29889,
13140,
3317,
29898,
8990,
29922,
29896,
467,
517,
29918,
8977,
580,
13,
4706,
297,
1341,
29889,
842,
29918,
12864,
29918,
5552,
29879,
877,
509,
2806,
742,
7636,
29918,
509,
2806,
29897,
13,
4706,
297,
1341,
29889,
12864,
29918,
509,
2806,
29889,
5504,
29898,
12864,
29918,
509,
2806,
29897,
13,
13,
1678,
822,
1993,
29918,
3859,
29918,
2176,
29898,
262,
1341,
29892,
2380,
1125,
13,
4706,
9995,
16969,
5962,
509,
2806,
2106,
2729,
373,
474,
915,
275,
4701,
9995,
13,
4706,
2380,
353,
9801,
29918,
9910,
29918,
2248,
29898,
2248,
29892,
6702,
29874,
333,
29896,
742,
525,
29874,
333,
29906,
8785,
13,
4706,
16226,
29918,
29886,
7121,
353,
7442,
29889,
294,
2378,
29898,
2248,
29889,
25027,
391,
3101,
13,
4706,
16226,
29918,
29886,
7121,
353,
325,
29873,
29889,
7469,
29918,
12181,
29898,
29874,
333,
29918,
29886,
7121,
29892,
313,
8516,
29892,
29871,
29906,
876,
13,
4706,
338,
29918,
17642,
353,
297,
1341,
29889,
275,
29918,
17642,
29898,
29874,
333,
29918,
29886,
7121,
29897,
13,
4706,
338,
29918,
2388,
353,
297,
1341,
29889,
275,
29918,
510,
862,
519,
29898,
29874,
333,
29918,
29886,
7121,
29897,
13,
4706,
1993,
29918,
3859,
29918,
2176,
353,
10518,
29889,
17271,
29889,
3166,
29918,
7076,
4197,
13,
9651,
313,
8186,
29954,
8050,
29892,
3695,
275,
29918,
17642,
669,
338,
29918,
2388,
511,
13,
9651,
313,
5438,
29963,
29892,
29871,
338,
29918,
17642,
669,
338,
29918,
2388,
511,
13,
9651,
313,
1177,
29907,
3580,
29892,
3695,
275,
29918,
2388,
511,
13,
308,
2314,
13,
4706,
1993,
29918,
3859,
29918,
2176,
29889,
2248,
353,
2380,
13,
4706,
736,
1993,
29918,
3859,
29918,
2176,
13,
13,
1678,
822,
1993,
29918,
3859,
29918,
4141,
29898,
262,
1341,
29892,
7636,
1125,
13,
4706,
565,
7636,
297,
297,
1341,
29889,
12864,
29918,
509,
2806,
29901,
13,
9651,
8760,
353,
297,
1341,
29889,
12864,
29918,
509,
2806,
29961,
12864,
29962,
13,
4706,
25342,
756,
5552,
29898,
262,
1341,
29892,
525,
29881,
11770,
29918,
369,
361,
29374,
13,
9651,
8760,
353,
297,
1341,
29889,
29881,
11770,
29918,
369,
361,
3032,
657,
29918,
509,
2806,
29898,
12864,
29897,
13,
4706,
1683,
29901,
13,
9651,
16226,
29918,
29886,
7121,
353,
7442,
29889,
294,
2378,
4197,
12864,
2314,
13,
9651,
338,
29918,
17642,
353,
297,
1341,
29889,
275,
29918,
17642,
29898,
29874,
333,
29918,
29886,
7121,
9601,
29900,
29962,
13,
9651,
338,
29918,
2388,
353,
297,
1341,
29889,
275,
29918,
510,
862,
519,
29898,
29874,
333,
29918,
29886,
7121,
9601,
29900,
29962,
13,
9651,
1993,
29918,
3859,
353,
10518,
29889,
19204,
29898,
8977,
4197,
13,
18884,
313,
8186,
29954,
8050,
29892,
3695,
275,
29918,
17642,
669,
338,
29918,
2388,
511,
13,
18884,
313,
5438,
29963,
29892,
29871,
338,
29918,
17642,
669,
338,
29918,
2388,
511,
13,
18884,
313,
1177,
29907,
3580,
29892,
3695,
275,
29918,
2388,
511,
13,
9651,
4514,
876,
13,
9651,
8760,
353,
1993,
29918,
3859,
29889,
13140,
3317,
580,
13,
4706,
736,
8760,
13,
13,
1678,
822,
7636,
29918,
5552,
29918,
2176,
29898,
262,
1341,
29892,
1820,
29892,
12770,
29922,
8516,
29892,
2322,
29922,
329,
29889,
3782,
4736,
1125,
13,
4706,
9995,
3386,
29879,
3630,
4308,
773,
1857,
27303,
9995,
13,
4706,
7636,
29918,
28631,
353,
297,
1341,
29889,
1885,
29918,
12864,
29918,
5552,
29879,
29898,
1989,
29892,
12770,
29922,
287,
2710,
29892,
2322,
29922,
4381,
29897,
13,
4706,
7636,
29918,
28631,
353,
1051,
29898,
12864,
29918,
28631,
29897,
13,
4706,
565,
338,
8758,
29898,
287,
2710,
29892,
10518,
29889,
15329,
3220,
1125,
13,
9651,
2380,
353,
12770,
13,
4706,
1683,
29901,
13,
9651,
565,
12770,
338,
6213,
29901,
13,
18884,
12770,
29918,
353,
3477,
29889,
19730,
29918,
4914,
29898,
12864,
29918,
28631,
29892,
29871,
29900,
29897,
13,
9651,
1683,
29901,
13,
18884,
12770,
29918,
353,
3477,
29889,
29880,
1958,
29898,
23583,
29892,
3477,
29889,
294,
1761,
29898,
287,
2710,
876,
13,
9651,
2380,
353,
10518,
29889,
15329,
3220,
29889,
3166,
29918,
9161,
2701,
29898,
287,
2710,
3383,
2983,
29922,
877,
29874,
333,
29896,
742,
525,
29874,
333,
29906,
8785,
13,
4706,
6475,
353,
3477,
29889,
277,
1296,
29918,
4914,
29898,
12864,
29918,
28631,
29892,
29871,
29896,
29897,
13,
4706,
7636,
29918,
2176,
353,
10518,
29889,
19204,
29889,
3166,
29918,
2378,
29898,
3757,
4339,
29897,
13,
4706,
7636,
29918,
2176,
29889,
978,
353,
1820,
13,
4706,
7636,
29918,
2176,
29889,
2248,
353,
2380,
13,
4706,
736,
7636,
29918,
2176,
13,
2
] |
codetest.py | Shannon-NJIT/PyCharmsHW | 0 | 42501 | #adding two numbers
num1 = 2
num2 = 3
sum = num1 + num2
print("The sum is:", sum) | [
1,
396,
4676,
1023,
3694,
13,
13,
1949,
29896,
353,
29871,
29906,
13,
1949,
29906,
353,
29871,
29941,
13,
2083,
353,
954,
29896,
718,
954,
29906,
13,
13,
2158,
703,
1576,
2533,
338,
29901,
613,
2533,
29897,
2
] |
scripts/acled2locations.py | ynxue/FabFlee | 1 | 180693 | <filename>scripts/acled2locations.py
import pandas as pd
import warnings
import sys
import os
import calendar as cal
from datetime import datetime
def month_convert(month):
name_to_number = {name: number
for number, name in enumerate(cal.month_name) if number
} # dict month : month_num
month_num = name_to_number.get(month) # month number in int form
return month_num
def date_format(in_date):
# converting date from textbased to dd-mm-yyyy format
split_date = in_date.split()
month_num = month_convert(split_date[1])
out_date = split_date[0] + "-" + str(month_num) + "-" + split_date[2]
return out_date
def between_date(d1, d2):
# Gets difference between two dates in string format "dd-mm-yy"
d1list = d1.split("-")
d2list = d2.split("-")
date1 = datetime(int(d1list[2]), int(d1list[1]), int(d1list[0]))
date2 = datetime(int(d2list[2]), int(d2list[1]), int(d2list[0]))
return abs((date1 - date2).days) + 1 # Maybe add +1
def date_verify(date):
date_format = "%d-%m-%Y"
try:
date_obj = datetime.strptime(date, date_format)
return True
except ValueError:
print("Incorrect data format please input dd-mm-yyyy")
return False
def drop_rows(inputdata, columnname, dropparameter):
removedrows = inputdata.index[
inputdata[columnname] == dropparameter].tolist()
outputdata = inputdata.drop(removedrows)
return outputdata
def filter_table(df, colname, adminlevel):
if adminlevel == "admin1":
adminlist = df.admin1.unique()
elif adminlevel == "location":
adminlist = df.location.unique()
else:
adminlist = df.admin2.unique()
newdf = pd.DataFrame(columns=df.columns)
for admin in adminlist:
tempdf = df.loc[df[adminlevel] == admin]
tempdf.sort_values(colname, ascending=True)
newdf = newdf.append(tempdf.tail(1))
print(newdf)
return newdf
def find_csv(country):
path_to_dir = os.getcwd()
print(path_to_dir)
filename = country + "-acled.csv"
locations = os.path.join(
"config_files", country, "source_data", filename
)
print(locations)
return locations
# Takes path to acled csv file, a start date in dd-mm-yyyy format, and a
# filter (First occurence or highest fatalities)
def acled2locations(fab_flee_loc, country, start_date,
filter_opt, admin_level):
warnings.filterwarnings('ignore')
input_file = os.path.join(fab_flee_loc, "config_files",
country,
"acled.csv")
print("Current Path: ", input_file)
try:
tempdf = pd.read_csv(input_file)
except:
print("Runtime Error: File Cannot be found")
df = tempdf[["event_date", "country", "admin1", "admin2",
"location", "latitude", "longitude", "fatalities"]]
# event_date is given in incorrect format, so formatting to dd-mm-yyyy
# required
event_dates = df["event_date"].tolist()
formatted_event_dates = [date_format(date) for date in event_dates]
conflict_dates = [between_date(d, start_date)
for d in formatted_event_dates]
# replacing event_date
df.loc[:, "event_date"] = conflict_dates
df.rename(columns={'event_date': 'conflict_date'}, inplace=True)
df = drop_rows(df, 'fatalities', 0)
if filter_opt == 'earliest':
filter_opt = 'conflict_date'
try:
df = filter_table(df, filter_opt, admin_level)
except:
print("Runtime error: filter_opt value must be earliest or fatalities")
# Exporting CSV to locations.csv
output_df = df[['location', 'admin1', 'country',
'latitude', 'longitude', 'conflict_date']]
output_df.rename(columns={'location': '#name',
'admin1': 'region'}, inplace=True)
output_df["location_type"] = "conflict_zone"
output_df["population"] = "0"
output_df = output_df[
['#name', 'region', 'country', 'latitude',
'longitude', 'location_type', 'conflict_date',
'population']
]
output_file = os.path.join(fab_flee_loc, "config_files",
country, "input_csv",
"locations.csv")
try:
output_df.to_csv(output_file, index=False, mode='x')
except FileExistsError:
print("File Already exists, saving as new_locations.csv")
output_file = os.path.join(fab_flee_loc, "config_files",
country, "input_csv",
"new_locations.csv")
output_df.to_csv(output_file, index=False, mode='x')
if __name__ == '__main__':
fabflee = sys.argv[1]
country = sys.argv[2]
start_date = sys.argv[3]
filter_opt = sys.argv[4]
adminlevel = sys.argv[5]
acled2locations(fabflee, country, start_date, filter_opt, adminlevel)
| [
1,
529,
9507,
29958,
16713,
29914,
562,
839,
29906,
2029,
800,
29889,
2272,
13,
5215,
11701,
408,
10518,
13,
5215,
18116,
13,
5215,
10876,
13,
5215,
2897,
13,
5215,
17684,
408,
1208,
13,
3166,
12865,
1053,
12865,
13,
13,
13,
1753,
4098,
29918,
13441,
29898,
10874,
1125,
13,
1678,
1024,
29918,
517,
29918,
4537,
353,
426,
978,
29901,
1353,
13,
462,
418,
363,
1353,
29892,
1024,
297,
26985,
29898,
1052,
29889,
10874,
29918,
978,
29897,
565,
1353,
13,
462,
418,
500,
29871,
396,
9657,
4098,
584,
4098,
29918,
1949,
13,
1678,
4098,
29918,
1949,
353,
1024,
29918,
517,
29918,
4537,
29889,
657,
29898,
10874,
29897,
29871,
396,
4098,
1353,
297,
938,
883,
13,
1678,
736,
4098,
29918,
1949,
13,
13,
13,
1753,
2635,
29918,
4830,
29898,
262,
29918,
1256,
1125,
13,
1678,
396,
17415,
2635,
515,
1426,
6707,
304,
24488,
29899,
4317,
29899,
18855,
3402,
13,
1678,
6219,
29918,
1256,
353,
297,
29918,
1256,
29889,
5451,
580,
13,
1678,
4098,
29918,
1949,
353,
4098,
29918,
13441,
29898,
5451,
29918,
1256,
29961,
29896,
2314,
13,
1678,
714,
29918,
1256,
353,
6219,
29918,
1256,
29961,
29900,
29962,
718,
11663,
29908,
718,
851,
29898,
10874,
29918,
1949,
29897,
718,
11663,
29908,
718,
6219,
29918,
1256,
29961,
29906,
29962,
13,
1678,
736,
714,
29918,
1256,
13,
13,
13,
1753,
1546,
29918,
1256,
29898,
29881,
29896,
29892,
270,
29906,
1125,
13,
1678,
396,
402,
1691,
4328,
1546,
1023,
10116,
297,
1347,
3402,
376,
1289,
29899,
4317,
29899,
8071,
29908,
13,
1678,
270,
29896,
1761,
353,
270,
29896,
29889,
5451,
703,
29899,
1159,
13,
1678,
270,
29906,
1761,
353,
270,
29906,
29889,
5451,
703,
29899,
1159,
13,
1678,
2635,
29896,
353,
12865,
29898,
524,
29898,
29881,
29896,
1761,
29961,
29906,
11724,
938,
29898,
29881,
29896,
1761,
29961,
29896,
11724,
938,
29898,
29881,
29896,
1761,
29961,
29900,
12622,
13,
1678,
2635,
29906,
353,
12865,
29898,
524,
29898,
29881,
29906,
1761,
29961,
29906,
11724,
938,
29898,
29881,
29906,
1761,
29961,
29896,
11724,
938,
29898,
29881,
29906,
1761,
29961,
29900,
12622,
13,
13,
1678,
736,
6425,
3552,
1256,
29896,
448,
2635,
29906,
467,
16700,
29897,
718,
29871,
29896,
29871,
396,
7198,
788,
718,
29896,
13,
13,
13,
1753,
2635,
29918,
27902,
29898,
1256,
1125,
13,
1678,
2635,
29918,
4830,
353,
11860,
29881,
19222,
29885,
19222,
29979,
29908,
13,
1678,
1018,
29901,
13,
4706,
2635,
29918,
5415,
353,
12865,
29889,
710,
415,
603,
29898,
1256,
29892,
2635,
29918,
4830,
29897,
13,
4706,
736,
5852,
13,
13,
1678,
5174,
7865,
2392,
29901,
13,
4706,
1596,
703,
797,
15728,
848,
3402,
3113,
1881,
24488,
29899,
4317,
29899,
18855,
1159,
13,
4706,
736,
7700,
13,
13,
13,
1753,
5768,
29918,
5727,
29898,
2080,
1272,
29892,
1897,
978,
29892,
4441,
407,
11269,
1308,
1125,
13,
1678,
6206,
5727,
353,
1881,
1272,
29889,
2248,
29961,
13,
4706,
1881,
1272,
29961,
4914,
978,
29962,
1275,
4441,
407,
11269,
1308,
1822,
25027,
391,
580,
13,
1678,
1962,
1272,
353,
1881,
1272,
29889,
8865,
29898,
1745,
8238,
5727,
29897,
13,
1678,
736,
1962,
1272,
13,
13,
13,
1753,
4175,
29918,
2371,
29898,
2176,
29892,
784,
978,
29892,
4113,
5563,
1125,
13,
1678,
565,
4113,
5563,
1275,
376,
6406,
29896,
1115,
13,
4706,
4113,
1761,
353,
4489,
29889,
6406,
29896,
29889,
13092,
580,
13,
1678,
25342,
4113,
5563,
1275,
376,
5479,
1115,
13,
4706,
4113,
1761,
353,
4489,
29889,
5479,
29889,
13092,
580,
13,
1678,
1683,
29901,
13,
4706,
4113,
1761,
353,
4489,
29889,
6406,
29906,
29889,
13092,
580,
13,
1678,
716,
2176,
353,
10518,
29889,
17271,
29898,
13099,
29922,
2176,
29889,
13099,
29897,
13,
13,
1678,
363,
4113,
297,
4113,
1761,
29901,
13,
4706,
1350,
5140,
353,
4489,
29889,
2029,
29961,
2176,
29961,
6406,
5563,
29962,
1275,
4113,
29962,
13,
4706,
1350,
5140,
29889,
6605,
29918,
5975,
29898,
1054,
978,
29892,
12066,
2548,
29922,
5574,
29897,
13,
4706,
716,
2176,
353,
716,
2176,
29889,
4397,
29898,
1356,
5140,
29889,
18237,
29898,
29896,
876,
13,
1678,
1596,
29898,
1482,
2176,
29897,
13,
1678,
736,
716,
2176,
13,
13,
13,
1753,
1284,
29918,
7638,
29898,
13509,
1125,
13,
1678,
2224,
29918,
517,
29918,
3972,
353,
2897,
29889,
657,
29883,
9970,
580,
13,
1678,
1596,
29898,
2084,
29918,
517,
29918,
3972,
29897,
13,
1678,
10422,
353,
4234,
718,
11663,
562,
839,
29889,
7638,
29908,
13,
1678,
14354,
353,
2897,
29889,
2084,
29889,
7122,
29898,
13,
4706,
376,
2917,
29918,
5325,
613,
4234,
29892,
376,
4993,
29918,
1272,
613,
10422,
13,
1678,
1723,
13,
1678,
1596,
29898,
2029,
800,
29897,
13,
13,
1678,
736,
14354,
13,
13,
29937,
323,
6926,
2224,
304,
1274,
839,
11799,
934,
29892,
263,
1369,
2635,
297,
24488,
29899,
4317,
29899,
18855,
3402,
29892,
322,
263,
13,
29937,
4175,
313,
6730,
6403,
663,
470,
9939,
18409,
1907,
29897,
13,
13,
13,
1753,
1274,
839,
29906,
2029,
800,
29898,
16582,
29918,
29888,
17179,
29918,
2029,
29892,
4234,
29892,
1369,
29918,
1256,
29892,
13,
462,
1678,
4175,
29918,
3670,
29892,
4113,
29918,
5563,
1125,
13,
1678,
18116,
29889,
4572,
25442,
886,
877,
17281,
1495,
13,
1678,
1881,
29918,
1445,
353,
2897,
29889,
2084,
29889,
7122,
29898,
16582,
29918,
29888,
17179,
29918,
2029,
29892,
376,
2917,
29918,
5325,
613,
13,
462,
795,
4234,
29892,
13,
462,
795,
376,
562,
839,
29889,
7638,
1159,
13,
1678,
1596,
703,
7583,
10802,
29901,
9162,
1881,
29918,
1445,
29897,
13,
1678,
1018,
29901,
13,
4706,
1350,
5140,
353,
10518,
29889,
949,
29918,
7638,
29898,
2080,
29918,
1445,
29897,
13,
1678,
5174,
29901,
13,
4706,
1596,
703,
7944,
4829,
29901,
3497,
15808,
367,
1476,
1159,
13,
13,
1678,
4489,
353,
1350,
5140,
29961,
3366,
3696,
29918,
1256,
613,
376,
13509,
613,
376,
6406,
29896,
613,
376,
6406,
29906,
613,
13,
462,
376,
5479,
613,
376,
5066,
4279,
613,
376,
5426,
4279,
613,
376,
29888,
2075,
1907,
3108,
29962,
13,
1678,
396,
1741,
29918,
1256,
338,
2183,
297,
10240,
3402,
29892,
577,
15998,
304,
24488,
29899,
4317,
29899,
18855,
13,
1678,
396,
3734,
13,
1678,
1741,
29918,
15190,
353,
4489,
3366,
3696,
29918,
1256,
16862,
25027,
391,
580,
13,
1678,
20917,
29918,
3696,
29918,
15190,
353,
518,
1256,
29918,
4830,
29898,
1256,
29897,
363,
2635,
297,
1741,
29918,
15190,
29962,
13,
1678,
14529,
29918,
15190,
353,
518,
14811,
29918,
1256,
29898,
29881,
29892,
1369,
29918,
1256,
29897,
13,
462,
418,
363,
270,
297,
20917,
29918,
3696,
29918,
15190,
29962,
13,
1678,
396,
15270,
1741,
29918,
1256,
13,
1678,
4489,
29889,
2029,
7503,
29892,
376,
3696,
29918,
1256,
3108,
353,
14529,
29918,
15190,
13,
1678,
4489,
29889,
1267,
420,
29898,
13099,
3790,
29915,
3696,
29918,
1256,
2396,
525,
5527,
29176,
29918,
1256,
16675,
297,
6689,
29922,
5574,
29897,
13,
13,
1678,
4489,
353,
5768,
29918,
5727,
29898,
2176,
29892,
525,
29888,
2075,
1907,
742,
29871,
29900,
29897,
13,
1678,
565,
4175,
29918,
3670,
1275,
525,
799,
20409,
2396,
13,
4706,
4175,
29918,
3670,
353,
525,
5527,
29176,
29918,
1256,
29915,
13,
13,
1678,
1018,
29901,
13,
4706,
4489,
353,
4175,
29918,
2371,
29898,
2176,
29892,
4175,
29918,
3670,
29892,
4113,
29918,
5563,
29897,
13,
1678,
5174,
29901,
13,
4706,
1596,
703,
7944,
1059,
29901,
4175,
29918,
3670,
995,
1818,
367,
24577,
470,
18409,
1907,
1159,
13,
13,
1678,
396,
1222,
637,
292,
16874,
304,
14354,
29889,
7638,
13,
1678,
1962,
29918,
2176,
353,
4489,
29961,
1839,
5479,
742,
525,
6406,
29896,
742,
525,
13509,
742,
13,
462,
1678,
525,
5066,
4279,
742,
525,
5426,
4279,
742,
525,
5527,
29176,
29918,
1256,
2033,
29962,
13,
1678,
1962,
29918,
2176,
29889,
1267,
420,
29898,
13099,
3790,
29915,
5479,
2396,
16321,
978,
742,
13,
462,
795,
525,
6406,
29896,
2396,
525,
12803,
16675,
297,
6689,
29922,
5574,
29897,
13,
1678,
1962,
29918,
2176,
3366,
5479,
29918,
1853,
3108,
353,
376,
5527,
29176,
29918,
8028,
29908,
13,
1678,
1962,
29918,
2176,
3366,
7323,
2785,
3108,
353,
376,
29900,
29908,
13,
1678,
1962,
29918,
2176,
353,
1962,
29918,
2176,
29961,
13,
4706,
6024,
29937,
978,
742,
525,
12803,
742,
525,
13509,
742,
525,
5066,
4279,
742,
13,
308,
525,
5426,
4279,
742,
525,
5479,
29918,
1853,
742,
525,
5527,
29176,
29918,
1256,
742,
13,
308,
525,
7323,
2785,
2033,
13,
1678,
4514,
13,
1678,
1962,
29918,
1445,
353,
2897,
29889,
2084,
29889,
7122,
29898,
16582,
29918,
29888,
17179,
29918,
2029,
29892,
376,
2917,
29918,
5325,
613,
13,
462,
1669,
4234,
29892,
376,
2080,
29918,
7638,
613,
13,
462,
1669,
376,
2029,
800,
29889,
7638,
1159,
13,
13,
1678,
1018,
29901,
13,
4706,
1962,
29918,
2176,
29889,
517,
29918,
7638,
29898,
4905,
29918,
1445,
29892,
2380,
29922,
8824,
29892,
4464,
2433,
29916,
1495,
13,
1678,
5174,
3497,
24217,
2392,
29901,
13,
4706,
1596,
703,
2283,
838,
2040,
4864,
29892,
14238,
408,
716,
29918,
2029,
800,
29889,
7638,
1159,
13,
4706,
1962,
29918,
1445,
353,
2897,
29889,
2084,
29889,
7122,
29898,
16582,
29918,
29888,
17179,
29918,
2029,
29892,
376,
2917,
29918,
5325,
613,
13,
462,
462,
259,
4234,
29892,
376,
2080,
29918,
7638,
613,
13,
462,
462,
259,
376,
1482,
29918,
2029,
800,
29889,
7638,
1159,
13,
4706,
1962,
29918,
2176,
29889,
517,
29918,
7638,
29898,
4905,
29918,
1445,
29892,
2380,
29922,
8824,
29892,
4464,
2433,
29916,
1495,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
13,
1678,
10135,
29888,
17179,
353,
10876,
29889,
19218,
29961,
29896,
29962,
13,
1678,
4234,
353,
10876,
29889,
19218,
29961,
29906,
29962,
13,
1678,
1369,
29918,
1256,
353,
10876,
29889,
19218,
29961,
29941,
29962,
13,
1678,
4175,
29918,
3670,
353,
10876,
29889,
19218,
29961,
29946,
29962,
13,
1678,
4113,
5563,
353,
10876,
29889,
19218,
29961,
29945,
29962,
13,
1678,
1274,
839,
29906,
2029,
800,
29898,
16582,
29888,
17179,
29892,
4234,
29892,
1369,
29918,
1256,
29892,
4175,
29918,
3670,
29892,
4113,
5563,
29897,
13,
2
] |
supermamas/areas/service.py | oasalonen/supermamas | 0 | 43538 | from flask_babel import gettext
from dateutil import rrule, parser
from datetime import datetime, date, timedelta
from supermamas.areas.districts import District
from supermamas.areas.cities import City
class Service:
__instance = None
def __new__(cls, district_repository=None, city_repository=None):
if not Service.__instance:
Service.__instance = object.__new__(cls)
Service.__instance.district_repository = district_repository
Service.__instance.city_repository = city_repository
return Service.__instance
def _district_repository(self):
return Service.__instance.district_repository
def _city_repository(self):
return Service.__instance.city_repository
def cities(self):
return self._city_repository().get_all()
def districts(self):
return self._district_repository().get_all()
def get_city(self, city_id):
return self._city_repository().get(city_id)
def get_district(self, district_id):
return self._district_repository().get(district_id)
def get_districts_in_same_city_by_district(self, district_id):
city = self._city_repository().get_by_district(district_id)
return city.districts
def add_city(self, city_name):
errors = {}
if not city_name:
errors["city_name"] = gettext(u"City name is missing")
if not errors:
city = City()
city.name = city_name
city = self._city_repository().insert(city)
else:
city = None
return (city, errors)
def add_district(self, district_name):
errors = {}
if not district_name:
errors["district_name"] = gettext(u"District name is missing")
if not errors:
district = District()
district.name = district_name
district = self._district_repository().insert(district)
else:
district = None
return (district, errors)
def delete_city(self, city_id):
self._city_repository().remove(city_id)
def delete_district(self, district_id):
self._district_repository().remove(district_id) | [
1,
515,
29784,
29918,
28727,
1053,
679,
726,
13,
3166,
2635,
4422,
1053,
364,
7491,
29892,
13812,
13,
3166,
12865,
1053,
12865,
29892,
2635,
29892,
5335,
287,
2554,
13,
13,
3166,
2428,
29885,
314,
294,
29889,
598,
294,
29889,
29881,
6801,
29879,
1053,
7457,
13,
3166,
2428,
29885,
314,
294,
29889,
598,
294,
29889,
29883,
1907,
1053,
4412,
13,
13,
1990,
6692,
29901,
13,
1678,
4770,
8758,
353,
6213,
13,
13,
1678,
822,
4770,
1482,
12035,
25932,
29892,
6474,
29918,
19033,
29922,
8516,
29892,
4272,
29918,
19033,
29922,
8516,
1125,
13,
4706,
565,
451,
6692,
17255,
8758,
29901,
13,
9651,
6692,
17255,
8758,
353,
1203,
17255,
1482,
12035,
25932,
29897,
13,
9651,
6692,
17255,
8758,
29889,
29881,
6801,
29918,
19033,
353,
6474,
29918,
19033,
13,
9651,
6692,
17255,
8758,
29889,
12690,
29918,
19033,
353,
4272,
29918,
19033,
13,
4706,
736,
6692,
17255,
8758,
13,
13,
1678,
822,
903,
29881,
6801,
29918,
19033,
29898,
1311,
1125,
13,
4706,
736,
6692,
17255,
8758,
29889,
29881,
6801,
29918,
19033,
13,
13,
1678,
822,
903,
12690,
29918,
19033,
29898,
1311,
1125,
13,
4706,
736,
6692,
17255,
8758,
29889,
12690,
29918,
19033,
13,
13,
1678,
822,
14368,
29898,
1311,
1125,
13,
4706,
736,
1583,
3032,
12690,
29918,
19033,
2141,
657,
29918,
497,
580,
13,
13,
1678,
822,
24172,
29898,
1311,
1125,
13,
4706,
736,
1583,
3032,
29881,
6801,
29918,
19033,
2141,
657,
29918,
497,
580,
13,
13,
1678,
822,
679,
29918,
12690,
29898,
1311,
29892,
4272,
29918,
333,
1125,
13,
4706,
736,
1583,
3032,
12690,
29918,
19033,
2141,
657,
29898,
12690,
29918,
333,
29897,
13,
13,
1678,
822,
679,
29918,
29881,
6801,
29898,
1311,
29892,
6474,
29918,
333,
1125,
13,
4706,
736,
1583,
3032,
29881,
6801,
29918,
19033,
2141,
657,
29898,
29881,
6801,
29918,
333,
29897,
13,
13,
1678,
822,
679,
29918,
29881,
6801,
29879,
29918,
262,
29918,
17642,
29918,
12690,
29918,
1609,
29918,
29881,
6801,
29898,
1311,
29892,
6474,
29918,
333,
1125,
13,
4706,
4272,
353,
1583,
3032,
12690,
29918,
19033,
2141,
657,
29918,
1609,
29918,
29881,
6801,
29898,
29881,
6801,
29918,
333,
29897,
13,
4706,
736,
4272,
29889,
29881,
6801,
29879,
13,
13,
1678,
822,
788,
29918,
12690,
29898,
1311,
29892,
4272,
29918,
978,
1125,
13,
4706,
4436,
353,
6571,
13,
4706,
565,
451,
4272,
29918,
978,
29901,
13,
9651,
4436,
3366,
12690,
29918,
978,
3108,
353,
679,
726,
29898,
29884,
29908,
16885,
1024,
338,
4567,
1159,
13,
13,
4706,
565,
451,
4436,
29901,
13,
9651,
4272,
353,
4412,
580,
13,
9651,
4272,
29889,
978,
353,
4272,
29918,
978,
13,
9651,
4272,
353,
1583,
3032,
12690,
29918,
19033,
2141,
7851,
29898,
12690,
29897,
13,
4706,
1683,
29901,
13,
9651,
4272,
353,
6213,
13,
13,
4706,
736,
313,
12690,
29892,
4436,
29897,
13,
268,
13,
1678,
822,
788,
29918,
29881,
6801,
29898,
1311,
29892,
6474,
29918,
978,
1125,
13,
4706,
4436,
353,
6571,
13,
4706,
565,
451,
6474,
29918,
978,
29901,
13,
9651,
4436,
3366,
29881,
6801,
29918,
978,
3108,
353,
679,
726,
29898,
29884,
29908,
29928,
6801,
1024,
338,
4567,
1159,
13,
13,
4706,
565,
451,
4436,
29901,
13,
9651,
6474,
353,
7457,
580,
13,
9651,
6474,
29889,
978,
353,
6474,
29918,
978,
13,
9651,
6474,
353,
1583,
3032,
29881,
6801,
29918,
19033,
2141,
7851,
29898,
29881,
6801,
29897,
13,
4706,
1683,
29901,
13,
9651,
6474,
353,
6213,
13,
13,
4706,
736,
313,
29881,
6801,
29892,
4436,
29897,
13,
13,
1678,
822,
5217,
29918,
12690,
29898,
1311,
29892,
4272,
29918,
333,
1125,
13,
4706,
1583,
3032,
12690,
29918,
19033,
2141,
5992,
29898,
12690,
29918,
333,
29897,
13,
13,
1678,
822,
5217,
29918,
29881,
6801,
29898,
1311,
29892,
6474,
29918,
333,
1125,
13,
4706,
1583,
3032,
29881,
6801,
29918,
19033,
2141,
5992,
29898,
29881,
6801,
29918,
333,
29897,
2
] |
tests/highlevel_functions/test_highlevel_functions.py | meta00/vital_sqi | 4 | 173700 | <gh_stars>1-10
import pytest
import os
import numpy as np
from vital_sqi.data.signal_io import PPG_reader
from vital_sqi.highlevel_functions.highlevel import \
compute_SQI,compute_multiple_SQIs,get_clean_signals,\
get_cutpoints,basic_ecg_pipeline,basic_ppg_pipeline,segment_PPG_SQI_extraction
class TestSignalPreProcess(object):
def test_on_signal_preprocess(self):
pass
# file_name = os.path.abspath('tests/test_data/ppg_smartcare.csv')
# mock_data = PPG_reader(file_name, signal_idx=['PLETH'],
# timestamp_idx=['TIMESTAMP_MS'],
# info_idx=['PULSE_BPM', 'SPO2_PCT',
# 'PERFUSION_INDEX'],
# sampling_rate=100,
# start_datetime='2020/12/30 10:00:00')
# mock_signal = mock_data.signals
# with pytest.raises(Exception) as exc_info:
# signal_preprocess()
# assert exc_info.match("No signal provided")
# out_data = signal_preprocess(mock_signal)
# assert len(mock_signal)==len(out_data)
class TestComputeAllSQI(object):
def test_on_compute_all_SQI(self):
pass
# file_name = os.path.abspath('tests/test_data/ppg_smartcare.csv')
# mock_data = PPG_reader(file_name, signal_idx=['PLETH'],
# timestamp_idx=['TIMESTAMP_MS'],
# info_idx=['PULSE_BPM', 'SPO2_PCT',
# 'PERFUSION_INDEX'],
# sampling_rate=100,
# start_datetime='2020/12/30 10:00:00')
# mock_signal = mock_data.signals[0]
# with pytest.raises(Exception) as exc_info:
# compute_all_SQI(signal=None,segments=[],raw_signal=[])
# assert exc_info.match("Signal or segments not provided, can't extract all SQI's")
# with pytest.raises(Exception) as exc_info:
# compute_all_SQI(signal=[],segments=None,raw_signal=[])
# assert exc_info.match("Signal or segments not provided, can't extract all SQI's")
# with pytest.raises(Exception) as exc_info:
# compute_all_SQI(signal=[],segments=[],raw_signal=None)
# assert exc_info.match("Signal or segments not provided, can't extract all SQI's")
# mock_segment_length = 1000
# mock_segment = np.arange(np.floor(len(mock_signal)/mock_segment_length))\
# *mock_segment_length
# mock_segment = [int(idx) for idx in mock_segment]
# mock_sqi_list = compute_all_SQI(signal=mock_signal,segments=mock_segment,
# raw_signal=mock_signal)
# assert len(mock_sqi_list) > 0
# mock_sqi_dict = mock_sqi_list[0]
# assert type(mock_sqi_dict) is dict
# assert len(mock_sqi_dict.keys()) > 0
# for key in mock_sqi_dict.keys():
# assert mock_sqi_dict[key] is not None
class TestComputeMultipleSQIs(object):
def test_on_compute_multiple_SQIs(self):
pass
class TestMakeRuleSet(object):
def test_on_make_rule_set(self):
pass
class TestGetCutPoints(object):
def test_on_get_cutpoints(self):
pass
class TestGetCleanSignals(object):
def test_on_get_clean_signals(self):
pass
class TestBasicPpgPipeline(object):
def test_on_basic_ppg_pipeline(self):
pass
class TestBasicEcgPipeline(object):
def test_on_basic_ecg_pipeline(self):
pass
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
11451,
1688,
13,
5215,
2897,
13,
5215,
12655,
408,
7442,
13,
3166,
27131,
29918,
3044,
29875,
29889,
1272,
29889,
25436,
29918,
601,
1053,
349,
16903,
29918,
16950,
13,
3166,
27131,
29918,
3044,
29875,
29889,
9812,
5563,
29918,
12171,
29889,
9812,
5563,
1053,
320,
13,
1678,
10272,
29918,
29903,
29984,
29902,
29892,
26017,
29918,
20787,
29918,
29903,
29984,
3624,
29892,
657,
29918,
14941,
29918,
4530,
1338,
2053,
13,
1678,
679,
29918,
7582,
9748,
29892,
16121,
29918,
687,
29887,
29918,
13096,
5570,
29892,
16121,
29918,
407,
29887,
29918,
13096,
5570,
29892,
28192,
29918,
29925,
16903,
29918,
29903,
29984,
29902,
29918,
1062,
13857,
13,
13,
1990,
4321,
10140,
284,
6572,
7032,
29898,
3318,
1125,
13,
1678,
822,
1243,
29918,
265,
29918,
25436,
29918,
1457,
5014,
29898,
1311,
1125,
13,
4706,
1209,
13,
4706,
396,
934,
29918,
978,
353,
2897,
29889,
2084,
29889,
370,
1028,
493,
877,
21150,
29914,
1688,
29918,
1272,
29914,
407,
29887,
29918,
3844,
442,
18020,
29889,
7638,
1495,
13,
4706,
396,
11187,
29918,
1272,
353,
349,
16903,
29918,
16950,
29898,
1445,
29918,
978,
29892,
7182,
29918,
13140,
29922,
1839,
29925,
1307,
4690,
7464,
13,
4706,
396,
462,
29871,
14334,
29918,
13140,
29922,
1839,
15307,
1254,
19297,
29918,
4345,
7464,
13,
4706,
396,
462,
29871,
5235,
29918,
13140,
29922,
1839,
7056,
29931,
1660,
29918,
29933,
13427,
742,
525,
5550,
29949,
29906,
29918,
29925,
1783,
742,
13,
4706,
396,
462,
9651,
525,
13171,
29943,
3308,
2725,
29918,
27992,
7464,
13,
4706,
396,
462,
29871,
23460,
29918,
10492,
29922,
29896,
29900,
29900,
29892,
13,
4706,
396,
462,
29871,
1369,
29918,
12673,
2433,
29906,
29900,
29906,
29900,
29914,
29896,
29906,
29914,
29941,
29900,
29871,
29896,
29900,
29901,
29900,
29900,
29901,
29900,
29900,
1495,
13,
4706,
396,
11187,
29918,
25436,
353,
11187,
29918,
1272,
29889,
4530,
1338,
13,
4706,
396,
411,
11451,
1688,
29889,
336,
4637,
29898,
2451,
29897,
408,
5566,
29918,
3888,
29901,
13,
4706,
396,
268,
7182,
29918,
1457,
5014,
580,
13,
4706,
396,
4974,
5566,
29918,
3888,
29889,
4352,
703,
3782,
7182,
4944,
1159,
13,
4706,
396,
714,
29918,
1272,
353,
7182,
29918,
1457,
5014,
29898,
17640,
29918,
25436,
29897,
13,
4706,
396,
4974,
7431,
29898,
17640,
29918,
25436,
29897,
1360,
2435,
29898,
449,
29918,
1272,
29897,
13,
13,
1990,
4321,
20606,
29872,
3596,
29903,
29984,
29902,
29898,
3318,
1125,
13,
1678,
822,
1243,
29918,
265,
29918,
26017,
29918,
497,
29918,
29903,
29984,
29902,
29898,
1311,
1125,
13,
4706,
1209,
13,
4706,
396,
934,
29918,
978,
353,
2897,
29889,
2084,
29889,
370,
1028,
493,
877,
21150,
29914,
1688,
29918,
1272,
29914,
407,
29887,
29918,
3844,
442,
18020,
29889,
7638,
1495,
13,
4706,
396,
11187,
29918,
1272,
353,
349,
16903,
29918,
16950,
29898,
1445,
29918,
978,
29892,
7182,
29918,
13140,
29922,
1839,
29925,
1307,
4690,
7464,
13,
4706,
396,
462,
4706,
14334,
29918,
13140,
29922,
1839,
15307,
1254,
19297,
29918,
4345,
7464,
13,
4706,
396,
462,
4706,
5235,
29918,
13140,
29922,
1839,
7056,
29931,
1660,
29918,
29933,
13427,
742,
525,
5550,
29949,
29906,
29918,
29925,
1783,
742,
13,
4706,
396,
462,
462,
29871,
525,
13171,
29943,
3308,
2725,
29918,
27992,
7464,
13,
4706,
396,
462,
4706,
23460,
29918,
10492,
29922,
29896,
29900,
29900,
29892,
13,
4706,
396,
462,
4706,
1369,
29918,
12673,
2433,
29906,
29900,
29906,
29900,
29914,
29896,
29906,
29914,
29941,
29900,
29871,
29896,
29900,
29901,
29900,
29900,
29901,
29900,
29900,
1495,
13,
4706,
396,
11187,
29918,
25436,
353,
11187,
29918,
1272,
29889,
4530,
1338,
29961,
29900,
29962,
13,
4706,
396,
411,
11451,
1688,
29889,
336,
4637,
29898,
2451,
29897,
408,
5566,
29918,
3888,
29901,
13,
4706,
396,
268,
10272,
29918,
497,
29918,
29903,
29984,
29902,
29898,
25436,
29922,
8516,
29892,
10199,
1860,
11759,
1402,
1610,
29918,
25436,
11759,
2314,
13,
4706,
396,
4974,
5566,
29918,
3888,
29889,
4352,
703,
10140,
284,
470,
24611,
451,
4944,
29892,
508,
29915,
29873,
6597,
599,
317,
29984,
29902,
29915,
29879,
1159,
13,
4706,
396,
411,
11451,
1688,
29889,
336,
4637,
29898,
2451,
29897,
408,
5566,
29918,
3888,
29901,
13,
4706,
396,
268,
10272,
29918,
497,
29918,
29903,
29984,
29902,
29898,
25436,
11759,
1402,
10199,
1860,
29922,
8516,
29892,
1610,
29918,
25436,
11759,
2314,
13,
4706,
396,
4974,
5566,
29918,
3888,
29889,
4352,
703,
10140,
284,
470,
24611,
451,
4944,
29892,
508,
29915,
29873,
6597,
599,
317,
29984,
29902,
29915,
29879,
1159,
13,
4706,
396,
411,
11451,
1688,
29889,
336,
4637,
29898,
2451,
29897,
408,
5566,
29918,
3888,
29901,
13,
4706,
396,
268,
10272,
29918,
497,
29918,
29903,
29984,
29902,
29898,
25436,
11759,
1402,
10199,
1860,
11759,
1402,
1610,
29918,
25436,
29922,
8516,
29897,
13,
4706,
396,
4974,
5566,
29918,
3888,
29889,
4352,
703,
10140,
284,
470,
24611,
451,
4944,
29892,
508,
29915,
29873,
6597,
599,
317,
29984,
29902,
29915,
29879,
1159,
13,
4706,
396,
11187,
29918,
28192,
29918,
2848,
353,
29871,
29896,
29900,
29900,
29900,
13,
4706,
396,
11187,
29918,
28192,
353,
7442,
29889,
279,
927,
29898,
9302,
29889,
14939,
29898,
2435,
29898,
17640,
29918,
25436,
6802,
17640,
29918,
28192,
29918,
2848,
28986,
13,
4706,
396,
18884,
334,
17640,
29918,
28192,
29918,
2848,
13,
4706,
396,
11187,
29918,
28192,
353,
518,
524,
29898,
13140,
29897,
363,
22645,
297,
11187,
29918,
28192,
29962,
13,
4706,
396,
11187,
29918,
3044,
29875,
29918,
1761,
353,
10272,
29918,
497,
29918,
29903,
29984,
29902,
29898,
25436,
29922,
17640,
29918,
25436,
29892,
10199,
1860,
29922,
17640,
29918,
28192,
29892,
13,
4706,
396,
462,
462,
10650,
29918,
25436,
29922,
17640,
29918,
25436,
29897,
13,
4706,
396,
4974,
7431,
29898,
17640,
29918,
3044,
29875,
29918,
1761,
29897,
1405,
29871,
29900,
13,
4706,
396,
11187,
29918,
3044,
29875,
29918,
8977,
353,
11187,
29918,
3044,
29875,
29918,
1761,
29961,
29900,
29962,
13,
4706,
396,
4974,
1134,
29898,
17640,
29918,
3044,
29875,
29918,
8977,
29897,
338,
9657,
13,
4706,
396,
4974,
7431,
29898,
17640,
29918,
3044,
29875,
29918,
8977,
29889,
8149,
3101,
1405,
29871,
29900,
13,
4706,
396,
363,
1820,
297,
11187,
29918,
3044,
29875,
29918,
8977,
29889,
8149,
7295,
13,
4706,
396,
268,
4974,
11187,
29918,
3044,
29875,
29918,
8977,
29961,
1989,
29962,
338,
451,
6213,
13,
13,
1990,
4321,
20606,
29872,
15329,
552,
29903,
29984,
3624,
29898,
3318,
1125,
13,
1678,
822,
1243,
29918,
265,
29918,
26017,
29918,
20787,
29918,
29903,
29984,
3624,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
1990,
4321,
9984,
10740,
2697,
29898,
3318,
1125,
13,
1678,
822,
1243,
29918,
265,
29918,
5675,
29918,
7491,
29918,
842,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
1990,
4321,
2577,
29907,
329,
20325,
29898,
3318,
1125,
13,
1678,
822,
1243,
29918,
265,
29918,
657,
29918,
7582,
9748,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
1990,
4321,
2577,
29907,
14044,
10140,
1338,
29898,
3318,
1125,
13,
1678,
822,
1243,
29918,
265,
29918,
657,
29918,
14941,
29918,
4530,
1338,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
1990,
4321,
16616,
29925,
4061,
29925,
23828,
29898,
3318,
1125,
13,
1678,
822,
1243,
29918,
265,
29918,
16121,
29918,
407,
29887,
29918,
13096,
5570,
29898,
1311,
1125,
13,
4706,
1209,
13,
13,
1990,
4321,
16616,
29923,
29883,
29887,
29925,
23828,
29898,
3318,
1125,
13,
1678,
822,
1243,
29918,
265,
29918,
16121,
29918,
687,
29887,
29918,
13096,
5570,
29898,
1311,
1125,
13,
4706,
1209,
13,
2
] |
itests/pages/permissions.py | bonniech3n/merou | 0 | 164935 | from typing import TYPE_CHECKING
from itests.pages.base import BaseElement, BasePage
if TYPE_CHECKING:
from typing import List
class PermissionsPage(BasePage):
@property
def has_create_permission_button(self):
# type: () -> bool
return self.find_elements_by_class_name("create-permission") != []
@property
def permission_rows(self):
# type: () -> List[PermissionRow]
all_permission_rows = self.find_elements_by_class_name("permission-row")
return [PermissionRow(row) for row in all_permission_rows]
@property
def limit_label(self):
# type: () -> str
return self.find_element_by_class_name("dropdown-toggle").text.strip()
def click_show_all_button(self):
# type: () -> None
button = self.find_element_by_class_name("show-all")
button.click()
def click_show_audited_button(self):
# type: () -> None
button = self.find_element_by_class_name("show-audited")
button.click()
def click_sort_by_date(self):
# type: () -> None
heading = self.find_element_by_class_name("col-date")
link = heading.find_element_by_tag_name("a")
self.root.get(link.get_attribute("href"))
class PermissionRow(BaseElement):
@property
def name(self):
# type: () -> str
return self.find_element_by_class_name("permission-name").text
@property
def description(self):
# type: () -> str
return self.find_element_by_class_name("permission-description").text
@property
def created_on(self):
# type: () -> str
return self.find_element_by_class_name("permission-created-on").text
class PermissionGrantRow(BaseElement):
@property
def name(self):
return self.find_element_by_class_name("permission-name").text
@property
def href(self):
name = self.find_element_by_class_name("permission-name")
link = name.find_element_by_tag_name("a")
return link.get_attribute("href")
@property
def argument(self):
return self.find_element_by_class_name("permission-argument").text
@property
def source(self):
return self.find_element_by_class_name("permission-source").text
@property
def granted_on(self):
return self.find_element_by_class_name("permission-granted-on").text
| [
1,
515,
19229,
1053,
323,
6959,
29918,
3210,
16658,
4214,
13,
13,
3166,
372,
9197,
29889,
12292,
29889,
3188,
1053,
7399,
2642,
29892,
7399,
5074,
13,
13,
361,
323,
6959,
29918,
3210,
16658,
4214,
29901,
13,
1678,
515,
19229,
1053,
2391,
13,
13,
13,
1990,
20894,
6847,
5074,
29898,
5160,
5074,
1125,
13,
1678,
732,
6799,
13,
1678,
822,
756,
29918,
3258,
29918,
16074,
29918,
3092,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
6120,
13,
4706,
736,
1583,
29889,
2886,
29918,
17664,
29918,
1609,
29918,
1990,
29918,
978,
703,
3258,
29899,
16074,
1159,
2804,
5159,
13,
13,
1678,
732,
6799,
13,
1678,
822,
10751,
29918,
5727,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
2391,
29961,
27293,
4301,
29962,
13,
4706,
599,
29918,
16074,
29918,
5727,
353,
1583,
29889,
2886,
29918,
17664,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
798,
1159,
13,
4706,
736,
518,
27293,
4301,
29898,
798,
29897,
363,
1948,
297,
599,
29918,
16074,
29918,
5727,
29962,
13,
13,
1678,
732,
6799,
13,
1678,
822,
4046,
29918,
1643,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
851,
13,
4706,
736,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
19305,
29899,
13270,
2564,
726,
29889,
17010,
580,
13,
13,
1678,
822,
2828,
29918,
4294,
29918,
497,
29918,
3092,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
6213,
13,
4706,
2826,
353,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
4294,
29899,
497,
1159,
13,
4706,
2826,
29889,
3808,
580,
13,
13,
1678,
822,
2828,
29918,
4294,
29918,
15052,
1573,
29918,
3092,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
6213,
13,
4706,
2826,
353,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
4294,
29899,
15052,
1573,
1159,
13,
4706,
2826,
29889,
3808,
580,
13,
13,
1678,
822,
2828,
29918,
6605,
29918,
1609,
29918,
1256,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
6213,
13,
4706,
28435,
353,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
1054,
29899,
1256,
1159,
13,
4706,
1544,
353,
28435,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
4039,
29918,
978,
703,
29874,
1159,
13,
4706,
1583,
29889,
4632,
29889,
657,
29898,
2324,
29889,
657,
29918,
12715,
703,
12653,
5783,
13,
13,
13,
1990,
20894,
2333,
4301,
29898,
5160,
2642,
1125,
13,
1678,
732,
6799,
13,
1678,
822,
1024,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
851,
13,
4706,
736,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
978,
2564,
726,
13,
13,
1678,
732,
6799,
13,
1678,
822,
6139,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
851,
13,
4706,
736,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
8216,
2564,
726,
13,
13,
1678,
732,
6799,
13,
1678,
822,
2825,
29918,
265,
29898,
1311,
1125,
13,
4706,
396,
1134,
29901,
3861,
1599,
851,
13,
4706,
736,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
11600,
29899,
265,
2564,
726,
13,
13,
13,
1990,
20894,
2333,
3338,
424,
4301,
29898,
5160,
2642,
1125,
13,
1678,
732,
6799,
13,
1678,
822,
1024,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
978,
2564,
726,
13,
13,
1678,
732,
6799,
13,
1678,
822,
2822,
29898,
1311,
1125,
13,
4706,
1024,
353,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
978,
1159,
13,
4706,
1544,
353,
1024,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
4039,
29918,
978,
703,
29874,
1159,
13,
4706,
736,
1544,
29889,
657,
29918,
12715,
703,
12653,
1159,
13,
13,
1678,
732,
6799,
13,
1678,
822,
2980,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
23516,
2564,
726,
13,
13,
1678,
732,
6799,
13,
1678,
822,
2752,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
4993,
2564,
726,
13,
13,
1678,
732,
6799,
13,
1678,
822,
16896,
29918,
265,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
2886,
29918,
5029,
29918,
1609,
29918,
1990,
29918,
978,
703,
16074,
29899,
629,
9714,
29899,
265,
2564,
726,
13,
2
] |
tests/test_main.py | newvicx/pybatch | 0 | 125459 | <gh_stars>0
import os
from datetime import datetime
from typing import List, Union
import pandas as pd
import pytest
from dotenv import load_dotenv
from pypibatch import NoBatchesFound, PIBatch, PIBatchError
load_dotenv()
SERVER = os.getenv("PI_SERVER")
UNIT_W_SUB = os.getenv("PI_UNIT_W_SUB")
UNIT_NO_SUB = os.getenv("PI_UNIT_NO_SUB")
TEST_BATCH = os.getenv("TEST_BATCH_NO_SUB")
pi = PIBatch(SERVER)
def test_unable_to_connect_to_server():
"""
PIBatchError is raised when unable to connect to server
"""
with pytest.raises(PIBatchError):
PIBatch("UnknownServer")
def test_no_batches_found():
"""
NoBatchesFound is raised when query returns no unit batches
"""
with pytest.raises(NoBatchesFound):
pi.search("UnknownUnit")
def test_search():
"""
Query should return unit batches and sub batches as non
empty DataFrame's
"""
unit_batches, sub_batches = pi.search(UNIT_W_SUB)
assert (
isinstance(unit_batches, pd.DataFrame) and
isinstance(sub_batches, pd.DataFrame)
)
assert (
not unit_batches.empty and
not sub_batches.empty
)
def test_search_no_sub_batches():
"""
Query can return non empty unit batch and empty
sub batches
"""
unit_batches, sub_batches = pi.search(
UNIT_NO_SUB,
start_time=datetime(year=2022, month=1, day=1),
batch_id=TEST_BATCH
)
assert (
isinstance(unit_batches, pd.DataFrame) and
isinstance(sub_batches, pd.DataFrame)
)
assert (
not unit_batches.empty and
sub_batches.empty
)
@pytest.mark.parametrize(
[
"start_time",
"end_time",
"batch_id",
"product",
"procedure",
"sub_batches",
"expected"
],
[
(
datetime(2022, 1, 1),
datetime(2022, 1, 2),
["*123*", "456"],
["prod1", "prod2"],
["proc1", "proc2", "proc3"],
["sb1"],
(
"2022-01-01T00:00:00",
"2022-01-02T00:00:00",
"*123*,456",
"prod1,prod2",
"proc1,proc2,proc3",
"sb1"
)
),
(
"*-60d",
"*-5d",
"789",
"prod1",
"proc1",
"sb1",
(
"*-60d",
"*-5d",
"789",
"prod1",
"proc1",
"sb1",
)
)
]
)
def test_query_param_conversion(
start_time: Union[datetime, str],
end_time: Union[datetime, str],
batch_id: Union[List[str], str],
product: Union[List[str], str],
procedure: Union[List[str], str],
sub_batches: Union[List[str], str],
expected: tuple
):
pi = PIBatch(SERVER)
params = pi._prep_search_criteria(
start_time,
end_time,
batch_id,
product,
procedure,
sub_batches
)
assert params == expected
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
2897,
13,
3166,
12865,
1053,
12865,
13,
3166,
19229,
1053,
2391,
29892,
7761,
13,
13,
5215,
11701,
408,
10518,
13,
5215,
11451,
1688,
13,
3166,
8329,
6272,
1053,
2254,
29918,
6333,
6272,
13,
13,
3166,
282,
1478,
747,
905,
1053,
1939,
23145,
267,
9692,
29892,
349,
8979,
905,
29892,
349,
8979,
905,
2392,
13,
13,
1359,
29918,
6333,
6272,
580,
13,
13,
18603,
353,
2897,
29889,
657,
6272,
703,
2227,
29918,
18603,
1159,
13,
3904,
1806,
29918,
29956,
29918,
20633,
353,
2897,
29889,
657,
6272,
703,
2227,
29918,
3904,
1806,
29918,
29956,
29918,
20633,
1159,
13,
3904,
1806,
29918,
6632,
29918,
20633,
353,
2897,
29889,
657,
6272,
703,
2227,
29918,
3904,
1806,
29918,
6632,
29918,
20633,
1159,
13,
18267,
29918,
29933,
14789,
353,
2897,
29889,
657,
6272,
703,
18267,
29918,
29933,
14789,
29918,
6632,
29918,
20633,
1159,
13,
13,
1631,
353,
349,
8979,
905,
29898,
18603,
29897,
13,
13,
1753,
1243,
29918,
348,
519,
29918,
517,
29918,
6915,
29918,
517,
29918,
2974,
7295,
13,
1678,
9995,
13,
1678,
349,
8979,
905,
2392,
338,
10425,
746,
9368,
304,
4511,
304,
1923,
13,
1678,
9995,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
2227,
23145,
2392,
1125,
13,
4706,
349,
8979,
905,
703,
14148,
6004,
1159,
13,
13,
13,
1753,
1243,
29918,
1217,
29918,
16175,
267,
29918,
11940,
7295,
13,
1678,
9995,
13,
1678,
1939,
23145,
267,
9692,
338,
10425,
746,
2346,
3639,
694,
5190,
9853,
267,
13,
1678,
9995,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
3782,
23145,
267,
9692,
1125,
13,
4706,
2930,
29889,
4478,
703,
14148,
8325,
1159,
13,
13,
13,
1753,
1243,
29918,
4478,
7295,
13,
1678,
9995,
13,
1678,
13641,
881,
736,
5190,
9853,
267,
322,
1014,
9853,
267,
408,
1661,
13,
1678,
4069,
3630,
4308,
29915,
29879,
13,
1678,
9995,
13,
1678,
5190,
29918,
16175,
267,
29892,
1014,
29918,
16175,
267,
353,
2930,
29889,
4478,
29898,
3904,
1806,
29918,
29956,
29918,
20633,
29897,
13,
1678,
4974,
313,
13,
4706,
338,
8758,
29898,
5441,
29918,
16175,
267,
29892,
10518,
29889,
17271,
29897,
322,
13,
4706,
338,
8758,
29898,
1491,
29918,
16175,
267,
29892,
10518,
29889,
17271,
29897,
13,
1678,
1723,
13,
1678,
4974,
313,
13,
4706,
451,
5190,
29918,
16175,
267,
29889,
6310,
322,
13,
4706,
451,
1014,
29918,
16175,
267,
29889,
6310,
13,
1678,
1723,
13,
13,
13,
1753,
1243,
29918,
4478,
29918,
1217,
29918,
1491,
29918,
16175,
267,
7295,
13,
1678,
9995,
13,
1678,
13641,
508,
736,
1661,
4069,
5190,
9853,
322,
4069,
13,
1678,
1014,
9853,
267,
13,
1678,
9995,
13,
1678,
5190,
29918,
16175,
267,
29892,
1014,
29918,
16175,
267,
353,
2930,
29889,
4478,
29898,
13,
4706,
8291,
1806,
29918,
6632,
29918,
20633,
29892,
13,
4706,
1369,
29918,
2230,
29922,
12673,
29898,
6360,
29922,
29906,
29900,
29906,
29906,
29892,
4098,
29922,
29896,
29892,
2462,
29922,
29896,
511,
13,
4706,
9853,
29918,
333,
29922,
18267,
29918,
29933,
14789,
13,
1678,
1723,
13,
1678,
4974,
313,
13,
4706,
338,
8758,
29898,
5441,
29918,
16175,
267,
29892,
10518,
29889,
17271,
29897,
322,
13,
4706,
338,
8758,
29898,
1491,
29918,
16175,
267,
29892,
10518,
29889,
17271,
29897,
13,
1678,
1723,
13,
1678,
4974,
313,
13,
4706,
451,
5190,
29918,
16175,
267,
29889,
6310,
322,
13,
4706,
1014,
29918,
16175,
267,
29889,
6310,
13,
1678,
1723,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
518,
13,
4706,
376,
2962,
29918,
2230,
613,
13,
4706,
376,
355,
29918,
2230,
613,
13,
4706,
376,
16175,
29918,
333,
613,
13,
4706,
376,
4704,
613,
13,
4706,
376,
771,
26600,
613,
13,
4706,
376,
1491,
29918,
16175,
267,
613,
13,
4706,
376,
9684,
29908,
13,
1678,
21251,
13,
1678,
518,
13,
4706,
313,
13,
9651,
12865,
29898,
29906,
29900,
29906,
29906,
29892,
29871,
29896,
29892,
29871,
29896,
511,
13,
9651,
12865,
29898,
29906,
29900,
29906,
29906,
29892,
29871,
29896,
29892,
29871,
29906,
511,
13,
9651,
6796,
29930,
29896,
29906,
29941,
29930,
613,
376,
29946,
29945,
29953,
12436,
13,
9651,
6796,
10633,
29896,
613,
376,
10633,
29906,
12436,
13,
9651,
6796,
15439,
29896,
613,
376,
15439,
29906,
613,
376,
15439,
29941,
12436,
13,
9651,
6796,
20778,
29896,
12436,
13,
9651,
313,
13,
18884,
376,
29906,
29900,
29906,
29906,
29899,
29900,
29896,
29899,
29900,
29896,
29911,
29900,
29900,
29901,
29900,
29900,
29901,
29900,
29900,
613,
13,
18884,
376,
29906,
29900,
29906,
29906,
29899,
29900,
29896,
29899,
29900,
29906,
29911,
29900,
29900,
29901,
29900,
29900,
29901,
29900,
29900,
613,
13,
18884,
26345,
29896,
29906,
29941,
15966,
29946,
29945,
29953,
613,
13,
18884,
376,
10633,
29896,
29892,
10633,
29906,
613,
13,
18884,
376,
15439,
29896,
29892,
15439,
29906,
29892,
15439,
29941,
613,
13,
18884,
376,
20778,
29896,
29908,
13,
9651,
1723,
13,
4706,
10353,
13,
4706,
313,
13,
9651,
26345,
29899,
29953,
29900,
29881,
613,
13,
9651,
26345,
29899,
29945,
29881,
613,
13,
9651,
376,
29955,
29947,
29929,
613,
13,
9651,
376,
10633,
29896,
613,
13,
9651,
376,
15439,
29896,
613,
13,
9651,
376,
20778,
29896,
613,
13,
9651,
313,
13,
18884,
26345,
29899,
29953,
29900,
29881,
613,
13,
18884,
26345,
29899,
29945,
29881,
613,
13,
18884,
376,
29955,
29947,
29929,
613,
13,
18884,
376,
10633,
29896,
613,
13,
18884,
376,
15439,
29896,
613,
13,
18884,
376,
20778,
29896,
613,
13,
9651,
1723,
13,
4706,
1723,
13,
1678,
4514,
13,
29897,
13,
1753,
1243,
29918,
1972,
29918,
3207,
29918,
535,
3259,
29898,
13,
1678,
1369,
29918,
2230,
29901,
7761,
29961,
12673,
29892,
851,
1402,
13,
1678,
1095,
29918,
2230,
29901,
7761,
29961,
12673,
29892,
851,
1402,
13,
1678,
9853,
29918,
333,
29901,
7761,
29961,
1293,
29961,
710,
1402,
851,
1402,
13,
1678,
3234,
29901,
7761,
29961,
1293,
29961,
710,
1402,
851,
1402,
13,
1678,
8792,
29901,
7761,
29961,
1293,
29961,
710,
1402,
851,
1402,
13,
1678,
1014,
29918,
16175,
267,
29901,
7761,
29961,
1293,
29961,
710,
1402,
851,
1402,
13,
1678,
3806,
29901,
18761,
13,
1125,
13,
13,
1678,
2930,
353,
349,
8979,
905,
29898,
18603,
29897,
13,
1678,
8636,
353,
2930,
3032,
15287,
29918,
4478,
29918,
29883,
21977,
29898,
13,
4706,
1369,
29918,
2230,
29892,
13,
4706,
1095,
29918,
2230,
29892,
13,
4706,
9853,
29918,
333,
29892,
13,
4706,
3234,
29892,
13,
4706,
8792,
29892,
13,
4706,
1014,
29918,
16175,
267,
13,
1678,
1723,
13,
1678,
4974,
8636,
1275,
3806,
13,
13,
2
] |
tests/unit/cirrus/quality_control_test.py | Maxsparrow/cirrus | 12 | 55405 | '''
qc command tests
'''
import mock
import unittest
from cirrus.quality_control import main, run_linters, build_parser
class QCCommandTests(unittest.TestCase):
"""
test coverage for qc command module
"""
def test_build_parser(self):
"""test build_parser call"""
args = [
'--include-files', 'file1', 'file2',
'--exclude-files', 'file3', 'file4',
'--exclude-dirs', 'dir1',
'--linters', 'Pep8', 'Pyflakes'
]
qc_conf = {}
opts = build_parser(args, qc_conf)
self.assertEqual(opts.include_files, ['file1', 'file2'])
self.assertEqual(opts.exclude_files, ['file3', 'file4'])
self.assertEqual(opts.exclude_dirs, ['dir1'])
self.assertEqual(opts.linters, ['Pep8', 'Pyflakes'])
qc_conf = {'exclude_dirs': ['dir3', 'dir4']}
args = [
'--include-files', 'file1', 'file2',
'--exclude-files', 'file3', 'file4',
'--linters', 'Pep8', 'Pyflakes'
]
opts = build_parser(args, qc_conf)
self.assertEqual(opts.exclude_dirs, ['dir3', 'dir4'])
@mock.patch("cirrus.quality_control.load_configuration")
@mock.patch("cirrus.quality_control.FACTORY")
def test_run_linters(self, mock_factory, mock_conf):
"""test pass case"""
mock_linter = mock.Mock()
mock_linter.test_mode = False
mock_linter.check = mock.Mock()
mock_linter.errors = None
mock_factory.return_value = mock_linter
mock_factory.registry = {
'Pep8': None,
'Pylint': None
}
opts = mock.Mock()
opts.test_only = False
opts.linters = ['Pep8', 'Pylint']
run_linters(opts, mock_conf, {})
self.assertTrue(mock_linter.check.called)
self.assertEqual(mock_linter.check.call_count, 2)
@mock.patch("cirrus.quality_control.load_configuration")
@mock.patch("cirrus.quality_control.FACTORY")
def test_run_linters_fail(self, mock_factory, mock_conf):
"""test fail case"""
mock_linter = mock.Mock()
mock_linter.test_mode = False
mock_linter.check = mock.Mock()
mock_linter.errors = 100
mock_factory.return_value = mock_linter
mock_factory.registry = {
'Pep8': None,
'Pylint': None
}
opts = mock.Mock()
opts.test_only = False
opts.linters = ['Pep8', 'Pylint']
self.assertRaises(RuntimeError, run_linters, opts, mock_conf, {})
@mock.patch("cirrus.quality_control.load_configuration")
@mock.patch("cirrus.quality_control.FACTORY")
def test_bad_linter_name(self, mock_factory, mock_conf):
"""test fail case"""
mock_linter = mock.Mock()
mock_linter.test_mode = False
mock_linter.check = mock.Mock()
mock_linter.errors = 100
mock_factory.return_value = mock_linter
mock_factory.registry = {
'Pep8': None,
'Pylint': None
}
opts = mock.Mock()
opts.test_only = False
opts.linters = ['WOMP']
self.assertRaises(RuntimeError, run_linters, opts, mock_conf, {})
@mock.patch("cirrus.quality_control.load_configuration")
@mock.patch("cirrus.quality_control.build_parser")
@mock.patch("cirrus.quality_control.run_linters")
@mock.patch("cirrus.quality_control.get_diff_files")
def test_main(self, mock_diffs, mock_rl, mock_bp, mock_conf):
mock_qc = {}
mock_conf.quality_control = mock.Mock(return_value=mock_qc)
mock_opts = mock.Mock()
mock_opts.only_changes = False
mock_bp.return_value = mock_opts
main()
self.assertTrue(mock_rl.called)
@mock.patch("cirrus.quality_control.load_configuration")
@mock.patch("cirrus.quality_control.build_parser")
@mock.patch("cirrus.quality_control.run_linters")
@mock.patch("cirrus.quality_control.get_diff_files")
def test_main_diffs(self, mock_diffs, mock_rl, mock_bp, mock_conf):
mock_qc = {}
mock_conf.quality_control = mock.Mock(return_value=mock_qc)
mock_opts = mock.Mock()
mock_opts.only_changes = True
mock_opts.incude_files = None
mock_bp.return_value = mock_opts
mock_diffs.return_value = ['DIFF1.py', 'DIFF2.py']
main()
self.assertTrue(mock_rl.called)
self.assertEqual(mock_opts.include_files, mock_diffs.return_value)
mock_diffs.return_value = []
self.assertRaises(SystemExit, main)
if __name__ == '__main__':
unittest.main()
| [
1,
14550,
13,
29939,
29883,
1899,
6987,
13,
12008,
13,
5215,
11187,
13,
5215,
443,
27958,
13,
13,
3166,
5902,
15816,
29889,
29567,
29918,
6451,
1053,
1667,
29892,
1065,
29918,
29880,
1639,
29879,
29892,
2048,
29918,
16680,
13,
13,
13,
1990,
660,
29907,
6255,
24376,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
1678,
9995,
13,
1678,
1243,
23746,
363,
3855,
29883,
1899,
3883,
13,
13,
1678,
9995,
13,
1678,
822,
1243,
29918,
4282,
29918,
16680,
29898,
1311,
1125,
13,
4706,
9995,
1688,
2048,
29918,
16680,
1246,
15945,
29908,
13,
4706,
6389,
353,
518,
13,
9651,
525,
489,
2856,
29899,
5325,
742,
525,
1445,
29896,
742,
525,
1445,
29906,
742,
13,
9651,
525,
489,
735,
2325,
29899,
5325,
742,
525,
1445,
29941,
742,
525,
1445,
29946,
742,
13,
9651,
525,
489,
735,
2325,
29899,
3972,
29879,
742,
525,
3972,
29896,
742,
13,
9651,
525,
489,
29880,
1639,
29879,
742,
525,
29925,
1022,
29947,
742,
525,
19737,
29888,
433,
10794,
29915,
13,
4706,
4514,
13,
4706,
3855,
29883,
29918,
5527,
353,
6571,
13,
4706,
29111,
353,
2048,
29918,
16680,
29898,
5085,
29892,
3855,
29883,
29918,
5527,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
25707,
29889,
2856,
29918,
5325,
29892,
6024,
1445,
29896,
742,
525,
1445,
29906,
11287,
13,
4706,
1583,
29889,
9294,
9843,
29898,
25707,
29889,
735,
2325,
29918,
5325,
29892,
6024,
1445,
29941,
742,
525,
1445,
29946,
11287,
13,
4706,
1583,
29889,
9294,
9843,
29898,
25707,
29889,
735,
2325,
29918,
3972,
29879,
29892,
6024,
3972,
29896,
11287,
13,
4706,
1583,
29889,
9294,
9843,
29898,
25707,
29889,
29880,
1639,
29879,
29892,
6024,
29925,
1022,
29947,
742,
525,
19737,
29888,
433,
10794,
11287,
13,
13,
4706,
3855,
29883,
29918,
5527,
353,
11117,
735,
2325,
29918,
3972,
29879,
2396,
6024,
3972,
29941,
742,
525,
3972,
29946,
2033,
29913,
13,
4706,
6389,
353,
518,
13,
9651,
525,
489,
2856,
29899,
5325,
742,
525,
1445,
29896,
742,
525,
1445,
29906,
742,
13,
9651,
525,
489,
735,
2325,
29899,
5325,
742,
525,
1445,
29941,
742,
525,
1445,
29946,
742,
13,
9651,
525,
489,
29880,
1639,
29879,
742,
525,
29925,
1022,
29947,
742,
525,
19737,
29888,
433,
10794,
29915,
13,
4706,
4514,
13,
4706,
29111,
353,
2048,
29918,
16680,
29898,
5085,
29892,
3855,
29883,
29918,
5527,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
25707,
29889,
735,
2325,
29918,
3972,
29879,
29892,
6024,
3972,
29941,
742,
525,
3972,
29946,
11287,
13,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
1359,
29918,
13305,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
4519,
1783,
18929,
1159,
13,
1678,
822,
1243,
29918,
3389,
29918,
29880,
1639,
29879,
29898,
1311,
29892,
11187,
29918,
14399,
29892,
11187,
29918,
5527,
1125,
13,
4706,
9995,
1688,
1209,
1206,
15945,
29908,
13,
4706,
11187,
29918,
29880,
1639,
353,
11187,
29889,
18680,
580,
13,
4706,
11187,
29918,
29880,
1639,
29889,
1688,
29918,
8513,
353,
7700,
13,
4706,
11187,
29918,
29880,
1639,
29889,
3198,
353,
11187,
29889,
18680,
580,
13,
4706,
11187,
29918,
29880,
1639,
29889,
12523,
353,
6213,
13,
4706,
11187,
29918,
14399,
29889,
2457,
29918,
1767,
353,
11187,
29918,
29880,
1639,
13,
4706,
11187,
29918,
14399,
29889,
1727,
6020,
353,
426,
13,
9651,
525,
29925,
1022,
29947,
2396,
6213,
29892,
13,
9651,
525,
29925,
2904,
524,
2396,
6213,
13,
4706,
500,
13,
13,
4706,
29111,
353,
11187,
29889,
18680,
580,
13,
4706,
29111,
29889,
1688,
29918,
6194,
353,
7700,
13,
4706,
29111,
29889,
29880,
1639,
29879,
353,
6024,
29925,
1022,
29947,
742,
525,
29925,
2904,
524,
2033,
13,
4706,
1065,
29918,
29880,
1639,
29879,
29898,
25707,
29892,
11187,
29918,
5527,
29892,
426,
1800,
13,
4706,
1583,
29889,
9294,
5574,
29898,
17640,
29918,
29880,
1639,
29889,
3198,
29889,
13998,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
17640,
29918,
29880,
1639,
29889,
3198,
29889,
4804,
29918,
2798,
29892,
29871,
29906,
29897,
13,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
1359,
29918,
13305,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
4519,
1783,
18929,
1159,
13,
1678,
822,
1243,
29918,
3389,
29918,
29880,
1639,
29879,
29918,
14057,
29898,
1311,
29892,
11187,
29918,
14399,
29892,
11187,
29918,
5527,
1125,
13,
4706,
9995,
1688,
4418,
1206,
15945,
29908,
13,
4706,
11187,
29918,
29880,
1639,
353,
11187,
29889,
18680,
580,
13,
4706,
11187,
29918,
29880,
1639,
29889,
1688,
29918,
8513,
353,
7700,
13,
4706,
11187,
29918,
29880,
1639,
29889,
3198,
353,
11187,
29889,
18680,
580,
13,
4706,
11187,
29918,
29880,
1639,
29889,
12523,
353,
29871,
29896,
29900,
29900,
13,
4706,
11187,
29918,
14399,
29889,
2457,
29918,
1767,
353,
11187,
29918,
29880,
1639,
13,
4706,
11187,
29918,
14399,
29889,
1727,
6020,
353,
426,
13,
9651,
525,
29925,
1022,
29947,
2396,
6213,
29892,
13,
9651,
525,
29925,
2904,
524,
2396,
6213,
13,
4706,
500,
13,
13,
4706,
29111,
353,
11187,
29889,
18680,
580,
13,
4706,
29111,
29889,
1688,
29918,
6194,
353,
7700,
13,
4706,
29111,
29889,
29880,
1639,
29879,
353,
6024,
29925,
1022,
29947,
742,
525,
29925,
2904,
524,
2033,
13,
4706,
1583,
29889,
9294,
29934,
1759,
267,
29898,
7944,
2392,
29892,
1065,
29918,
29880,
1639,
29879,
29892,
29111,
29892,
11187,
29918,
5527,
29892,
426,
1800,
13,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
1359,
29918,
13305,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
4519,
1783,
18929,
1159,
13,
1678,
822,
1243,
29918,
12313,
29918,
29880,
1639,
29918,
978,
29898,
1311,
29892,
11187,
29918,
14399,
29892,
11187,
29918,
5527,
1125,
13,
4706,
9995,
1688,
4418,
1206,
15945,
29908,
13,
4706,
11187,
29918,
29880,
1639,
353,
11187,
29889,
18680,
580,
13,
4706,
11187,
29918,
29880,
1639,
29889,
1688,
29918,
8513,
353,
7700,
13,
4706,
11187,
29918,
29880,
1639,
29889,
3198,
353,
11187,
29889,
18680,
580,
13,
4706,
11187,
29918,
29880,
1639,
29889,
12523,
353,
29871,
29896,
29900,
29900,
13,
4706,
11187,
29918,
14399,
29889,
2457,
29918,
1767,
353,
11187,
29918,
29880,
1639,
13,
4706,
11187,
29918,
14399,
29889,
1727,
6020,
353,
426,
13,
9651,
525,
29925,
1022,
29947,
2396,
6213,
29892,
13,
9651,
525,
29925,
2904,
524,
2396,
6213,
13,
4706,
500,
13,
13,
4706,
29111,
353,
11187,
29889,
18680,
580,
13,
4706,
29111,
29889,
1688,
29918,
6194,
353,
7700,
13,
4706,
29111,
29889,
29880,
1639,
29879,
353,
6024,
29956,
29949,
3580,
2033,
13,
4706,
1583,
29889,
9294,
29934,
1759,
267,
29898,
7944,
2392,
29892,
1065,
29918,
29880,
1639,
29879,
29892,
29111,
29892,
11187,
29918,
5527,
29892,
426,
1800,
13,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
1359,
29918,
13305,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
4282,
29918,
16680,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
3389,
29918,
29880,
1639,
29879,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
657,
29918,
12765,
29918,
5325,
1159,
13,
1678,
822,
1243,
29918,
3396,
29898,
1311,
29892,
11187,
29918,
12765,
29879,
29892,
11187,
29918,
2096,
29892,
11187,
29918,
25288,
29892,
11187,
29918,
5527,
1125,
13,
4706,
11187,
29918,
29939,
29883,
353,
6571,
13,
4706,
11187,
29918,
5527,
29889,
29567,
29918,
6451,
353,
11187,
29889,
18680,
29898,
2457,
29918,
1767,
29922,
17640,
29918,
29939,
29883,
29897,
13,
4706,
11187,
29918,
25707,
353,
11187,
29889,
18680,
580,
13,
4706,
11187,
29918,
25707,
29889,
6194,
29918,
25990,
353,
7700,
13,
4706,
11187,
29918,
25288,
29889,
2457,
29918,
1767,
353,
11187,
29918,
25707,
13,
13,
4706,
1667,
580,
13,
4706,
1583,
29889,
9294,
5574,
29898,
17640,
29918,
2096,
29889,
13998,
29897,
13,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
1359,
29918,
13305,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
4282,
29918,
16680,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
3389,
29918,
29880,
1639,
29879,
1159,
13,
1678,
732,
17640,
29889,
5041,
703,
19052,
15816,
29889,
29567,
29918,
6451,
29889,
657,
29918,
12765,
29918,
5325,
1159,
13,
1678,
822,
1243,
29918,
3396,
29918,
12765,
29879,
29898,
1311,
29892,
11187,
29918,
12765,
29879,
29892,
11187,
29918,
2096,
29892,
11187,
29918,
25288,
29892,
11187,
29918,
5527,
1125,
13,
4706,
11187,
29918,
29939,
29883,
353,
6571,
13,
4706,
11187,
29918,
5527,
29889,
29567,
29918,
6451,
353,
11187,
29889,
18680,
29898,
2457,
29918,
1767,
29922,
17640,
29918,
29939,
29883,
29897,
13,
4706,
11187,
29918,
25707,
353,
11187,
29889,
18680,
580,
13,
4706,
11187,
29918,
25707,
29889,
6194,
29918,
25990,
353,
5852,
13,
4706,
11187,
29918,
25707,
29889,
3742,
1151,
29918,
5325,
353,
6213,
13,
4706,
11187,
29918,
25288,
29889,
2457,
29918,
1767,
353,
11187,
29918,
25707,
13,
4706,
11187,
29918,
12765,
29879,
29889,
2457,
29918,
1767,
353,
6024,
4571,
4198,
29896,
29889,
2272,
742,
525,
4571,
4198,
29906,
29889,
2272,
2033,
13,
13,
4706,
1667,
580,
13,
4706,
1583,
29889,
9294,
5574,
29898,
17640,
29918,
2096,
29889,
13998,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
17640,
29918,
25707,
29889,
2856,
29918,
5325,
29892,
11187,
29918,
12765,
29879,
29889,
2457,
29918,
1767,
29897,
13,
13,
4706,
11187,
29918,
12765,
29879,
29889,
2457,
29918,
1767,
353,
5159,
13,
4706,
1583,
29889,
9294,
29934,
1759,
267,
29898,
3924,
24365,
29892,
1667,
29897,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
443,
27958,
29889,
3396,
580,
13,
2
] |
tests/UnitTests.py | MattBussing/DistancePi | 0 | 88730 | <reponame>MattBussing/DistancePi
# This is the experimental testing suite for this app
import json
import re
import sys
import unittest
import requests
from main import Device
from custom_threads import MyThread
# TODO delete all the messages added
class TestAdd(unittest.TestCase):
url = 'https://distance-pi.herokuapp.com'
postUrl = url + '/'
test = 'test'
delUrl = url + '/' + test
delJson = {'message': 'value'}
postJson = {'message': 'value', '_to': 'testing'}
def deleteMessage(self):
return requests.delete(url=self.delUrl, json=self.delJson)
def postMessage(self, postData):
return requests.post(url=self.postUrl, json=postData)
def device(self, d):
m = d.main()
print('uploading test data')
self.messageList = ['lol', 'sadfads', 'i hate lol', 'asdfasdfasdf']
for i in self.messageList:
postProcess = MyThread(self.postMessage, postData={
'message': i, '_to': self.test})
postProcess.start()
def test_normal_run(self):
print("\n############normal_run")
# test a normal run
d = Device(name="UnitTests.py", tests=True,
onComputer=True)
self.device(d)
self.assertEqual(d.main().sort(), self.messageList.sort())
def test_sleep_variable(self):
print("\n##############sleep_variable")
d = Device(name="UnitTests.py", tests=True,
sleepOn=True, onComputer=True, verbose=True)
self.device(d)
print(self.messageList)
self.assertEqual(d.main().sort(), self.messageList.sort())
def test_rpi(self):
print("rpi")
d = Device(name="UnitTests.py", tests=True)
self.device(d)
self.assertEqual(d.main().sort(), self.messageList.sort())
if __name__ == '__main__':
unittest.main()
| [
1,
529,
276,
1112,
420,
29958,
29924,
1131,
29933,
1558,
292,
29914,
27469,
12197,
13,
29937,
910,
338,
278,
17986,
6724,
9460,
363,
445,
623,
13,
13,
5215,
4390,
13,
5215,
337,
13,
5215,
10876,
13,
5215,
443,
27958,
13,
13,
5215,
7274,
13,
13,
3166,
1667,
1053,
21830,
13,
3166,
2888,
29918,
28993,
1053,
1619,
4899,
13,
13,
29937,
14402,
5217,
599,
278,
7191,
2715,
13,
13,
13,
1990,
4321,
2528,
29898,
348,
27958,
29889,
3057,
8259,
1125,
13,
1678,
3142,
353,
525,
991,
597,
19244,
29899,
1631,
29889,
2276,
9154,
932,
29889,
510,
29915,
13,
1678,
1400,
5983,
353,
3142,
718,
8207,
29915,
13,
1678,
1243,
353,
525,
1688,
29915,
13,
1678,
628,
5983,
353,
3142,
718,
8207,
29915,
718,
1243,
13,
13,
1678,
628,
8148,
353,
11117,
4906,
2396,
525,
1767,
10827,
13,
1678,
1400,
8148,
353,
11117,
4906,
2396,
525,
1767,
742,
22868,
517,
2396,
525,
13424,
10827,
13,
13,
1678,
822,
5217,
3728,
29898,
1311,
1125,
13,
4706,
736,
7274,
29889,
8143,
29898,
2271,
29922,
1311,
29889,
6144,
5983,
29892,
4390,
29922,
1311,
29889,
6144,
8148,
29897,
13,
13,
1678,
822,
1400,
3728,
29898,
1311,
29892,
1400,
1469,
1125,
13,
4706,
736,
7274,
29889,
2490,
29898,
2271,
29922,
1311,
29889,
2490,
5983,
29892,
4390,
29922,
2490,
1469,
29897,
13,
13,
1678,
822,
4742,
29898,
1311,
29892,
270,
1125,
13,
4706,
286,
353,
270,
29889,
3396,
580,
13,
4706,
1596,
877,
9009,
292,
1243,
848,
1495,
13,
4706,
1583,
29889,
4906,
1293,
353,
6024,
29880,
324,
742,
525,
29879,
328,
29888,
7925,
742,
525,
29875,
26277,
301,
324,
742,
525,
294,
2176,
294,
2176,
294,
2176,
2033,
13,
4706,
363,
474,
297,
1583,
29889,
4906,
1293,
29901,
13,
9651,
1400,
7032,
353,
1619,
4899,
29898,
1311,
29889,
2490,
3728,
29892,
1400,
1469,
3790,
13,
462,
462,
259,
525,
4906,
2396,
474,
29892,
22868,
517,
2396,
1583,
29889,
1688,
1800,
13,
9651,
1400,
7032,
29889,
2962,
580,
13,
13,
1678,
822,
1243,
29918,
8945,
29918,
3389,
29898,
1311,
1125,
13,
4706,
1596,
14182,
29876,
7346,
4136,
8945,
29918,
3389,
1159,
13,
4706,
396,
1243,
263,
4226,
1065,
13,
4706,
270,
353,
21830,
29898,
978,
543,
8325,
24376,
29889,
2272,
613,
6987,
29922,
5574,
29892,
13,
462,
259,
373,
20606,
261,
29922,
5574,
29897,
13,
4706,
1583,
29889,
10141,
29898,
29881,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29881,
29889,
3396,
2141,
6605,
3285,
1583,
29889,
4906,
1293,
29889,
6605,
3101,
13,
13,
1678,
822,
1243,
29918,
17059,
29918,
11918,
29898,
1311,
1125,
13,
4706,
1596,
14182,
29876,
7346,
4136,
2277,
17059,
29918,
11918,
1159,
13,
4706,
270,
353,
21830,
29898,
978,
543,
8325,
24376,
29889,
2272,
613,
6987,
29922,
5574,
29892,
13,
462,
259,
8709,
2951,
29922,
5574,
29892,
373,
20606,
261,
29922,
5574,
29892,
26952,
29922,
5574,
29897,
13,
4706,
1583,
29889,
10141,
29898,
29881,
29897,
13,
4706,
1596,
29898,
1311,
29889,
4906,
1293,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29881,
29889,
3396,
2141,
6605,
3285,
1583,
29889,
4906,
1293,
29889,
6605,
3101,
13,
13,
1678,
822,
1243,
29918,
29878,
1631,
29898,
1311,
1125,
13,
4706,
1596,
703,
29878,
1631,
1159,
13,
4706,
270,
353,
21830,
29898,
978,
543,
8325,
24376,
29889,
2272,
613,
6987,
29922,
5574,
29897,
13,
4706,
1583,
29889,
10141,
29898,
29881,
29897,
13,
4706,
1583,
29889,
9294,
9843,
29898,
29881,
29889,
3396,
2141,
6605,
3285,
1583,
29889,
4906,
1293,
29889,
6605,
3101,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
443,
27958,
29889,
3396,
580,
13,
2
] |
Mundo 3/ex105.py | erickeloi/ExerciciosTreino | 0 | 35905 | <reponame>erickeloi/ExerciciosTreino
# Exercício Python 105: Analisando e gerando Dicionários
# Faça um programa que tenha uma função notas() que pode receber várias notas de alunos
# e vai retornar um dicionário com as seguintes informações:
#
# - Quantidade de notas
# - A maior nota
# - A menor nota
# - A média da turma
# - A situação (opcional)
#
# Adicione também as docstrings dessa função para consulta pelo desenvolvedor.
def notas(notas, situacao=True):
"""
-> Recebe várias notas de uma turma, faz uma análise dessas informações e retorna um Dicionário com elas.
:param notas: (Obrigatório) Várias Notas de alunos podem ser digitadas para a análise
:param situacao: (Opcional) True ou False, False por padrão
você escolhe se deseja que o dicionário contenha a análise subjetiva da turma
:return: Retorna um Dicionário com as informações:
- Maior Nota
- Menor Nota
- Média da Turma
- A Situação da Turma (Opcional): Ruim, Regular, Boa
"""
dicionario_de_alunos = dict()
sit = ""
maior = menor = media = total = 0
for contador, nota in enumerate(notas):
if contador == 0:
menor = nota
maior = nota
if nota > maior:
maior = nota
if nota < menor:
menor = nota
total += nota
media = total / len(notas)
dicionario_de_alunos = {
"Quantidade de Notas": len(notas),
"Maior Nota": maior,
"Menor Nota": menor,
"Média da Turma": media
}
if media >= 7:
sit = "Boa"
elif 5 <= media < 7:
sit = "Regular"
elif media < 5:
sit = "Ruim"
if situacao == False:
return dicionario_de_alunos
if situacao == True:
dicionario_de_alunos["Situação"] = sit
return dicionario_de_alunos
notas_alunos = list()
while True:
numero = float(input("Digite as notas dos alunos (999 para parar): "))
if numero == 999:
break
notas_alunos.append(numero)
situacao = str(input("Quer Mostrar a Situação das notas ? [S/N]")).strip().upper()[0]
while situacao not in 'SN':
situacao = str(input("Quer Mostrar a Situação das notas ? [S/N]")).strip().upper()[0]
if situacao == 'S':
situacao = True
elif situacao == 'N':
situacao = False
print(notas(notas_alunos, situacao))
| [
1,
529,
276,
1112,
420,
29958,
261,
860,
7078,
29875,
29914,
1252,
6269,
19382,
29911,
276,
1789,
13,
29937,
1222,
6269,
24394,
5132,
29871,
29896,
29900,
29945,
29901,
530,
5711,
1743,
321,
9814,
1743,
360,
15353,
26047,
13,
29937,
7748,
4277,
1922,
16914,
712,
3006,
2350,
3672,
2090,
2340,
451,
294,
580,
712,
13279,
2414,
495,
9366,
15851,
451,
294,
316,
394,
12609,
13,
29937,
321,
325,
1794,
3240,
1398,
279,
1922,
12124,
291,
12288,
419,
408,
7025,
524,
267,
1871,
25463,
29901,
13,
29937,
13,
29937,
448,
22746,
5558,
316,
451,
294,
13,
29937,
448,
319,
17136,
451,
29874,
13,
29937,
448,
319,
26764,
451,
29874,
13,
29937,
448,
319,
10283,
423,
1146,
7013,
655,
13,
29937,
448,
319,
2990,
8298,
313,
459,
29883,
1848,
29897,
13,
29937,
13,
29937,
2087,
293,
1421,
10409,
408,
1574,
19651,
6808,
29874,
2090,
2340,
1702,
8799,
29874,
10845,
20599,
1490,
272,
29889,
13,
13,
1753,
451,
294,
29898,
1333,
294,
29892,
2990,
562,
6241,
29922,
5574,
1125,
13,
1678,
9995,
13,
4706,
1599,
24328,
915,
9366,
15851,
451,
294,
316,
3672,
7013,
655,
29892,
16928,
3672,
385,
2464,
895,
6808,
294,
1871,
25463,
321,
3240,
272,
1056,
1922,
360,
15353,
12288,
419,
560,
294,
29889,
13,
13,
4706,
584,
3207,
451,
294,
29901,
313,
29949,
1182,
335,
20062,
5378,
29897,
478,
29976,
15851,
2216,
294,
316,
394,
12609,
13279,
29885,
724,
13615,
3922,
1702,
263,
385,
2464,
895,
13,
13,
4706,
584,
3207,
2990,
562,
6241,
29901,
313,
29949,
6739,
1848,
29897,
5852,
2123,
7700,
29892,
7700,
1277,
282,
7887,
1368,
13,
4706,
7931,
30037,
25224,
354,
409,
553,
29872,
1764,
712,
288,
12124,
291,
12288,
16962,
2350,
263,
385,
2464,
895,
1014,
4026,
4244,
1146,
7013,
655,
13,
13,
4706,
584,
2457,
29901,
4649,
272,
1056,
1922,
360,
15353,
12288,
419,
408,
1871,
25463,
29901,
13,
4706,
448,
3219,
1611,
2216,
29874,
13,
4706,
448,
7567,
272,
2216,
29874,
13,
4706,
448,
341,
13292,
1146,
5383,
655,
13,
4706,
448,
319,
23920,
8298,
1146,
5383,
655,
313,
29949,
6739,
1848,
1125,
9723,
326,
29892,
2169,
1070,
29892,
1952,
29874,
13,
4706,
9995,
13,
13,
1678,
12124,
25150,
29918,
311,
29918,
284,
12609,
353,
9657,
580,
13,
1678,
7845,
353,
5124,
13,
1678,
17136,
353,
26764,
353,
5745,
353,
3001,
353,
29871,
29900,
13,
13,
1678,
363,
640,
3136,
29892,
451,
29874,
297,
26985,
29898,
1333,
294,
1125,
13,
4706,
565,
640,
3136,
1275,
29871,
29900,
29901,
13,
9651,
26764,
353,
451,
29874,
13,
9651,
17136,
353,
451,
29874,
13,
4706,
565,
451,
29874,
1405,
17136,
29901,
13,
9651,
17136,
353,
451,
29874,
13,
4706,
565,
451,
29874,
529,
26764,
29901,
13,
9651,
26764,
353,
451,
29874,
13,
4706,
3001,
4619,
451,
29874,
13,
13,
1678,
5745,
353,
3001,
847,
7431,
29898,
1333,
294,
29897,
13,
13,
1678,
12124,
25150,
29918,
311,
29918,
284,
12609,
353,
426,
13,
4706,
376,
22930,
5558,
316,
2216,
294,
1115,
7431,
29898,
1333,
294,
511,
13,
4706,
376,
21870,
1611,
2216,
29874,
1115,
17136,
29892,
13,
4706,
376,
28154,
272,
2216,
29874,
1115,
26764,
29892,
13,
4706,
376,
29924,
13292,
1146,
5383,
655,
1115,
5745,
13,
1678,
500,
13,
13,
1678,
565,
5745,
6736,
29871,
29955,
29901,
13,
4706,
7845,
353,
376,
8431,
29874,
29908,
13,
1678,
25342,
29871,
29945,
5277,
5745,
529,
29871,
29955,
29901,
13,
4706,
7845,
353,
376,
4597,
1070,
29908,
13,
1678,
25342,
5745,
529,
29871,
29945,
29901,
13,
4706,
7845,
353,
376,
29934,
29884,
326,
29908,
13,
13,
1678,
565,
2990,
562,
6241,
1275,
7700,
29901,
13,
4706,
736,
12124,
25150,
29918,
311,
29918,
284,
12609,
13,
13,
1678,
565,
2990,
562,
6241,
1275,
5852,
29901,
13,
4706,
12124,
25150,
29918,
311,
29918,
284,
12609,
3366,
29903,
1981,
8298,
3108,
353,
7845,
13,
4706,
736,
12124,
25150,
29918,
311,
29918,
284,
12609,
13,
13,
13,
1333,
294,
29918,
284,
12609,
353,
1051,
580,
13,
13,
8000,
5852,
29901,
13,
1678,
17910,
353,
5785,
29898,
2080,
703,
14991,
568,
408,
451,
294,
3248,
394,
12609,
313,
29929,
29929,
29929,
1702,
610,
279,
1125,
376,
876,
13,
1678,
565,
17910,
1275,
29871,
29929,
29929,
29929,
29901,
13,
4706,
2867,
13,
1678,
451,
294,
29918,
284,
12609,
29889,
4397,
29898,
1949,
1489,
29897,
13,
29879,
1981,
562,
6241,
353,
851,
29898,
2080,
703,
2182,
261,
7849,
13678,
263,
23920,
8298,
1697,
451,
294,
1577,
518,
29903,
29914,
29940,
29962,
1159,
467,
17010,
2141,
21064,
580,
29961,
29900,
29962,
13,
8000,
2990,
562,
6241,
451,
297,
525,
19296,
2396,
13,
1678,
2990,
562,
6241,
353,
851,
29898,
2080,
703,
2182,
261,
7849,
13678,
263,
23920,
8298,
1697,
451,
294,
1577,
518,
29903,
29914,
29940,
29962,
1159,
467,
17010,
2141,
21064,
580,
29961,
29900,
29962,
13,
361,
2990,
562,
6241,
1275,
525,
29903,
2396,
13,
1678,
2990,
562,
6241,
353,
5852,
13,
23681,
2990,
562,
6241,
1275,
525,
29940,
2396,
13,
1678,
2990,
562,
6241,
353,
7700,
13,
13,
2158,
29898,
1333,
294,
29898,
1333,
294,
29918,
284,
12609,
29892,
2990,
562,
6241,
876,
13,
2
] |
dvc/output/gs.py | Abrosimov-a-a/dvc | 0 | 78428 | <reponame>Abrosimov-a-a/dvc
from __future__ import unicode_literals
from dvc.output.s3 import OutputS3
from dvc.remote.gs import RemoteGS
class OutputGS(OutputS3):
REMOTE = RemoteGS
| [
1,
529,
276,
1112,
420,
29958,
4920,
1883,
326,
586,
29899,
29874,
29899,
29874,
29914,
29881,
7071,
13,
3166,
4770,
29888,
9130,
1649,
1053,
29104,
29918,
20889,
1338,
13,
13,
3166,
270,
7071,
29889,
4905,
29889,
29879,
29941,
1053,
10604,
29903,
29941,
13,
3166,
270,
7071,
29889,
16674,
29889,
3174,
1053,
5240,
866,
10749,
13,
13,
13,
1990,
10604,
10749,
29898,
6466,
29903,
29941,
1125,
13,
1678,
5195,
29924,
2891,
29923,
353,
5240,
866,
10749,
13,
2
] |
websites/gamefaqs/gameparser.py | jb262/completewasteoftime | 6 | 115305 | <gh_stars>1-10
'''
This module contains all necessary functions to scrape
both base info (description, release date, etc.) and
advanced info (versions, add-ons, etc.) for a video game
provided a BeautifulSoup object containing the corresponding
base/advance data page.
'''
import re
def get_name(info_page):
'''
Returns the title of the game from both base and advanced info page.
:param info_page: BeautifulSoup object containing the base/advanced info page
'''
return info_page.find('h1', class_='page-title').text
def get_description(base_info_page):
'''
Returns the description of the game from the base info page.
:param base_info_page: BeautifulSoup object containing the baseinfo page
'''
return base_info_page.find('div', class_='desc').text
def get_user_ratings(base_info_page):
'''
Returns the user ratings (owned, rating, difficulty, length, completed) from the base info page.
The user ratings are stored in a fieldset having the class mygames_section.
The title of the single categories is stored in div-containers, conveniently having the class
subsection-title. Besides the category title, this element also stores the rating itself.
The votes on which the rating is based is stored in a separate paragraph with the class rate.
The owned-statistic is the only entry without a corresponding votes-statistic, thus resulting
in an error, if the text-attribute is accessed. This case is caught by assigning None to the
votes in this case. There is also a disabled element, which can be accessed by signed in users.
This element is skipped as it does not contain any relevant info.
:param base_info_page: BeautifulSoup object containing the base info page.
'''
result = dict()
user_ratings_fieldsets = base_info_page.find_all('fieldset', class_='mygames_section')
if user_ratings_fieldsets:
categories = list()
ratings = list()
votes = list()
for user_rating_fieldset in user_ratings_fieldsets:
if not 'disabled' in user_rating_fieldset.attrs:
subsection = user_rating_fieldset.find('div', class_='subsection-title')
category, rating = subsection.text.split(':')
try:
vote = subsection.find('p', 'rate').text
except AttributeError:
vote = None
categories.append(category)
ratings.append(rating)
votes.append(vote)
for category, rating, vote in zip(categories, ratings, votes):
result[category] = {
'Rating': rating,
'Votes': vote}
return result
def get_base_info(base_info_page):
'''
Returns the basic info on the game provided on the base info page
(platforms, developer, release date, genre, franchise, metacritic score, ESRB rating).
Franchise, ESRB rating and metacritic score can be missing, the latter two especially
when data of older games is scraped.
This data is stored in a div container at the upper right corner, having the class
pod_gameinfo. Inside this container is an unordered list. The list itself has a very heterogenic
structure: The core platform, ESRB rating and Metacritic score have their own unique classes,
while the other list items do not. The developing/publishing company and, if provided, the number
of DLCs/Add-Ons do not even have a label in contrast to release date, other platforms and franchise,
resulting in this long if-elif-statement.
In case of the ESRB-rating and the Metacritic score, the obtained result sets are passed to dedicated
parsing methods.
:param base_info_page: BeautifulSoup object containing the base info page
'''
result = dict()
base_info = base_info_page.find('div', class_='pod_gameinfo').find('ul')
if base_info:
categories = list()
values = list()
for info in base_info.find_all('li'):
if not 'class' in info.attrs:
contents = info.find('b')
if contents:
category = re.sub(r'\s', '-', contents.text[:-1])
value = [val.text for val in info.find_all('a')]
if len(value) == 1:
value = value[0]
else:
if re.search(r'#dlc', info.find('a')['href']):
category = 'DLC'
elif re.search(r'/company/', info.find('a')['href']):
category = 'Company'
value = info.text
categories.append(category)
elif 'core-platform' in info['class']:
categories.append('Core-Platform')
value = info.text
elif 'boxshot' in info['class']:
continue
elif 'esrb' in info['class']:
result['ESRB'] = __get_esrb_rating(info)
continue
elif 'metacritic' in info['class']:
result['Metacritic'] = __get_metacritic_score(info)
continue
else:
base_data = info.text.split(':')
categories.append(base_data[0].strip())
value = base_data[1].strip()
values.append(value)
for category, value in zip(categories, values):
result[category] = value
return result
def get_full_base_info(base_info_page):
'''
Returns the full base info on the game provided on the base info page
(base info, description, user ratings, name).
This method simply calls all available operations on the base info page
and stores the results in a dictionary.
:param base_info_page: BeautifulSoup object containing the base info page
'''
result = get_base_info(base_info_page)
result['Description'] = get_description(base_info_page)
result['User-Ratings'] = get_user_ratings(base_info_page)
result['Name'] = get_name(base_info_page)
return result
def get_advanced_info(advanced_info_page):
'''
Returns the full info on the game provided on the advanced info page.
(title data, versions, add-ons)
This method simply calls all available perations on the advanced info page
and stores the results in a dictionary.
:param advanced_info_page: BeautifulSoup object containing the advanced info page
'''
result = dict()
result['Title-Data'] = get_title_data(advanced_info_page)
result['Versions'] = get_versions(advanced_info_page)
result['DLC'] = get_dlc(advanced_info_page)
return result
def get_title_data(advanced_info_page):
'''
Returns the title data of the game provided on the advanced info page
(developer, genres, ESRB-descriptors, Wikipedia (EN) link, multiplayers, etc. ).
The retrieved data can differ from game to game given the data provided.
Example: Tales of Berseria: Genre, Developer, Local Players, Online Players, Wiki
The Sims: Genre, Developer, ESRB-Descriptors, Wiki
The title data is stored in description list, which itself is nested into a
div-container with the unique class pod-titledata.
The tags and contents are parsed separately and stored as keys and values in
a dictionary.
:param advanced_info_page: BeautifulSoup object containing the advanced info page
'''
result = dict()
title_data = advanced_info_page.find('div', 'pod_titledata')
if title_data:
categories = title_data.find_all('dt')
values = title_data.find_all('dd')
for category, value in zip(categories, values):
key = re.sub(r'\s', '-', re.sub(r'[()]', '', category.text))
value = re.sub(r' >', ',', value.text).split(',')
if len(value) > 1:
value = [val.strip() for val in value]
result[key[:-1]] = value
return result
def get_versions(advanced_info_page):
'''
Returns all published versions of the game (region, publisher, product ID, barcode, rating).
The data is stored in a table without any unique identifiers or classes. The cells in a single
table row all have unique classes corresponding to their contents, except for the product ID and
barcode cells sharing the same class. This can be bypassed by the simple rule that all elements
in the result set with an even index are product IDs and all elements with an odd index are
barcodes. This rule is valid since, even if there is no product ID or barcode provided,
parsing returns None as their values, guaranteeing elements at all indexes.
:param advanced_info_page: BeautifulSoup object containing the advanced info page
'''
result = list()
regions = advanced_info_page.find_all('td', class_='cregion')
publishers = advanced_info_page.find_all('td', class_='datacompany')
ids = advanced_info_page.find_all('td', class_='datapid')
product_ids = ids[::2]
barcodes = ids[1::2]
release_dates = advanced_info_page.find_all('td', class_='cdate')
ratings = advanced_info_page.find_all('td', class_='datarating')
if regions and publishers and product_ids and barcodes and release_dates and ratings:
for (region, publisher, product_id, barcode, release_date, rating) in zip(
regions, publishers, product_ids, barcodes, release_dates, ratings):
result.append(
{'Region': region.text.strip(),
'Publisher': publisher.text.strip(),
'Product-Id': product_id.text.strip(),
'Barcode': barcode.text.strip(),
'Release-Date': release_date.text.strip(),
'Rating': rating.text.strip()})
return result
def get_dlc(advance_info_page):
'''
Returns all released add-ons/DLCs of the game (name, gamefaqs-link).
The DLC section is very incomplete. A lot of extensions to the games are missing (example:
The Sims actually having at least 3,013,553 purchasable add-ons, while only having two according
to gamefaqs). The data itself is stored in a table with the ID dlc, making the parsing straightforward.
:param advanced_info_page: BeautifulSoup object containing the advanced info page
'''
result = list()
dlcs = advance_info_page.find('div', id='dlc')
if dlcs:
for dlc in dlcs.find_all('a', href=True):
result.append({
'Name': dlc.text,
'Link': dlc['href']})
return result
def get_questions(questions_page):
'''
Returns all asked questions either from the answered questions page or the unresolved questions page including
link and answer count.
Both answered and unresolved questions pages have the same structure: The information is stored in a container,
which holds the questions, the links to the questions and the answer count in tables with the classes qna_table
separated by topic (e.g. Enemy/Boss Help, Technical Help, etc.). The parsing is then straighforward.
If one of these sections does not have a header (i.e. a description for the topic), the section is skipped.
This line of code was only added for the sake of completeness, as this situation should not ever occur.
'''
result = list()
questions = questions_page.find_all('table', class_='qna_table')
if questions:
for topics in questions:
try:
topic = topics.find('th', class_='question').text
except AttributeError:
continue
topic_dict = {
'Topic': topic,
'Questions': list()}
questions_texts = topics.find_all('a', href=True)
answer_count = topics.find_all('td', class_='count')
for question, count in zip(questions_texts, answer_count):
topic_dict['Questions'].append({
'Question': question.text,
'Link': question['href'],
'Count': int(count.text)})
result.append(topic_dict)
return result
def get_question_details(details_page):
'''
Returns question details (i.e. the full question text) and, if any, its answers including up- and downvotes.
The container with the left span of the main content has to be selected first, otherwise the aside element
will be parsed as well, leading to nonsensical results.
Both questions and answers are stored in containers with the class friend_info. There is no strict separation
between the question and its answers in the container´s body, both are stored in spans with the class name. The only
way to distinguish them is to check, if there are any up- or downvotes stored in the container as well.
'''
result = dict()
main_content = details_page.find('div', class_='main_content').find('div', class_='span8')
details = main_content.find_all('div', class_='friend_info')
if details:
answers = list()
for detail in details:
full_text = detail.find('span', class_='name').text
upvotes = detail.find('span', class_='up')
downvotes = detail.find('span', class_='down')
if not upvotes or not downvotes:
result['Full-Question'] = full_text
else:
answers.append({
'Answer': full_text,
'Upvotes': int(upvotes.text),
'Downvotes': int(downvotes.text)})
result['Answers'] = answers
return result
def get_all_games(page):
'''
Returns a list of the next 100 games, including gamefaqs links, from an `all-games-page` of
a given console.
The info is stored in the rows of a table with the unique class results. The relevant information
- name and gamefaqs link of the game - are stored in a table data cell with the unique class
rtitle. Thus parsing is straighforward.
:param page: `All-games-page` of a given console.
'''
result = list()
games = page.find('table', class_='results')
if games:
rows = games.find_all('td', class_='rtitle')
if rows:
for row in rows:
link = row.find('a', href=True)
link_text = link['href']
game = link.text
result.append({
'Name': game,
'Link': link_text})
return result
def __get_metacritic_score(base_info_pod):
'''
Returns the average metacritic score and the number of reviews.
The score itself is stored in a div-container with the unique class score.
The total count of reviews needs to be retrieved from a link text below, from which
the actual number has to be extracted using a regular expression.
:param base_info_pod: BeautifulSoup object containing the base info box provided in the upper
right of the base info page.
'''
result = dict()
metacritic = base_info_pod.find('div', class_='review_link')
if metacritic:
metacritic_reviews = metacritic.text
try:
numbers = re.compile(r'\d+')
metacritic_review_count = int(numbers.findall(metacritic_reviews)[0])
except IndexError:
metacritic_review_count = None
result['Reviews'] = metacritic_review_count
try:
metacritic_score = int(base_info_pod.find('div', class_='score').text)
except AttributeError:
metacritic_score = None
result['Score'] = metacritic_score
return result
def __get_esrb_rating(base_info_pod):
'''
Returns the ESRB rating and the description of the rating.
The ESRB info is stored in a list entry (of the unordered list of base information) with the
unique class esrb. While hidden behind the logo on the visible website, the actual rating and
its rating can easily be retrieved by a splitting its content on a -.
:param base_info_pod: BeautifulSoup object containing the base info box provided in the upper
right of the base info page.
'''
result = dict()
if base_info_pod:
rating, description = base_info_pod.text.split("-")
rating, description = rating.strip(), description.strip()
result['Rating'] = rating
result['Description'] = description
return result | [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
12008,
13,
4013,
3883,
3743,
599,
5181,
3168,
304,
24559,
412,
13,
20313,
2967,
5235,
313,
8216,
29892,
6507,
2635,
29892,
2992,
1846,
322,
13,
328,
16858,
5235,
313,
26100,
29892,
788,
29899,
787,
29892,
2992,
1846,
363,
263,
4863,
3748,
13,
16123,
2618,
263,
25685,
29903,
1132,
1203,
6943,
278,
6590,
13,
3188,
29914,
17263,
749,
848,
1813,
29889,
13,
12008,
13,
13,
5215,
337,
13,
13,
13,
1753,
679,
29918,
978,
29898,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
3611,
310,
278,
3748,
515,
1716,
2967,
322,
12862,
5235,
1813,
29889,
13,
13,
1678,
584,
3207,
5235,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
2967,
29914,
328,
16858,
5235,
1813,
13,
1678,
14550,
13,
1678,
736,
5235,
29918,
3488,
29889,
2886,
877,
29882,
29896,
742,
770,
29918,
2433,
3488,
29899,
3257,
2824,
726,
13,
13,
13,
1753,
679,
29918,
8216,
29898,
3188,
29918,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
6139,
310,
278,
3748,
515,
278,
2967,
5235,
1813,
29889,
13,
13,
1678,
584,
3207,
2967,
29918,
3888,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
2967,
3888,
1813,
13,
1678,
14550,
13,
1678,
736,
2967,
29918,
3888,
29918,
3488,
29889,
2886,
877,
4563,
742,
770,
29918,
2433,
14273,
2824,
726,
13,
13,
13,
1753,
679,
29918,
1792,
29918,
3605,
886,
29898,
3188,
29918,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
1404,
26838,
313,
26689,
29892,
21700,
29892,
14656,
29892,
3309,
29892,
8676,
29897,
515,
278,
2967,
5235,
1813,
29889,
13,
13,
1678,
450,
1404,
26838,
526,
6087,
297,
263,
1746,
842,
2534,
278,
770,
590,
29887,
1280,
29918,
2042,
29889,
13,
1678,
450,
3611,
310,
278,
2323,
13997,
338,
6087,
297,
1933,
29899,
1285,
475,
414,
29892,
19192,
368,
2534,
278,
770,
13,
1678,
1014,
2042,
29899,
3257,
29889,
19065,
278,
7663,
3611,
29892,
445,
1543,
884,
14422,
278,
21700,
3528,
29889,
13,
1678,
450,
18952,
373,
607,
278,
21700,
338,
2729,
338,
6087,
297,
263,
5004,
14880,
411,
278,
770,
6554,
29889,
13,
1678,
450,
15205,
29899,
6112,
4695,
338,
278,
871,
6251,
1728,
263,
6590,
18952,
29899,
6112,
4695,
29892,
4550,
9819,
13,
1678,
297,
385,
1059,
29892,
565,
278,
1426,
29899,
12715,
338,
20592,
29889,
910,
1206,
338,
12624,
491,
23188,
6213,
304,
278,
13,
1678,
18952,
297,
445,
1206,
29889,
1670,
338,
884,
263,
12708,
1543,
29892,
607,
508,
367,
20592,
491,
8794,
297,
4160,
29889,
13,
1678,
910,
1543,
338,
14993,
2986,
408,
372,
947,
451,
1712,
738,
8018,
5235,
29889,
13,
13,
1678,
584,
3207,
2967,
29918,
3888,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
2967,
5235,
1813,
29889,
13,
1678,
14550,
13,
1678,
1121,
353,
9657,
580,
13,
1678,
1404,
29918,
3605,
886,
29918,
2671,
7224,
353,
2967,
29918,
3888,
29918,
3488,
29889,
2886,
29918,
497,
877,
2671,
842,
742,
770,
29918,
2433,
1357,
29887,
1280,
29918,
2042,
1495,
13,
13,
1678,
565,
1404,
29918,
3605,
886,
29918,
2671,
7224,
29901,
13,
4706,
13997,
353,
1051,
580,
13,
4706,
26838,
353,
1051,
580,
13,
4706,
18952,
353,
1051,
580,
13,
13,
4706,
363,
1404,
29918,
29741,
29918,
2671,
842,
297,
1404,
29918,
3605,
886,
29918,
2671,
7224,
29901,
13,
9651,
565,
451,
525,
18279,
29915,
297,
1404,
29918,
29741,
29918,
2671,
842,
29889,
5552,
29879,
29901,
13,
18884,
1014,
2042,
353,
1404,
29918,
29741,
29918,
2671,
842,
29889,
2886,
877,
4563,
742,
770,
29918,
2433,
7235,
29899,
3257,
1495,
13,
18884,
7663,
29892,
21700,
353,
1014,
2042,
29889,
726,
29889,
5451,
877,
29901,
1495,
13,
18884,
1018,
29901,
13,
462,
1678,
11719,
353,
1014,
2042,
29889,
2886,
877,
29886,
742,
525,
10492,
2824,
726,
13,
18884,
5174,
23833,
2392,
29901,
13,
462,
1678,
11719,
353,
6213,
13,
13,
18884,
13997,
29889,
4397,
29898,
7320,
29897,
13,
18884,
26838,
29889,
4397,
29898,
29741,
29897,
13,
18884,
18952,
29889,
4397,
29898,
15814,
29897,
13,
13,
4706,
363,
7663,
29892,
21700,
29892,
11719,
297,
14319,
29898,
20683,
29892,
26838,
29892,
18952,
1125,
13,
9651,
1121,
29961,
7320,
29962,
353,
426,
13,
18884,
525,
29934,
1218,
2396,
21700,
29892,
13,
18884,
525,
29963,
4769,
2396,
11719,
29913,
13,
13,
1678,
736,
1121,
13,
13,
13,
1753,
679,
29918,
3188,
29918,
3888,
29898,
3188,
29918,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
6996,
5235,
373,
278,
3748,
4944,
373,
278,
2967,
5235,
1813,
13,
1678,
313,
12120,
29879,
29892,
13897,
29892,
6507,
2635,
29892,
16151,
29892,
23272,
895,
29892,
1539,
562,
768,
293,
8158,
29892,
382,
14098,
29933,
21700,
467,
13,
1678,
1352,
305,
895,
29892,
382,
14098,
29933,
21700,
322,
1539,
562,
768,
293,
8158,
508,
367,
4567,
29892,
278,
7480,
1023,
7148,
13,
1678,
746,
848,
310,
9642,
8090,
338,
885,
2390,
287,
29889,
13,
13,
1678,
910,
848,
338,
6087,
297,
263,
1933,
5639,
472,
278,
7568,
1492,
11155,
29892,
2534,
278,
770,
13,
1678,
2532,
29918,
11802,
3888,
29889,
22804,
445,
5639,
338,
385,
443,
21693,
1051,
29889,
450,
1051,
3528,
756,
263,
1407,
25745,
6352,
293,
13,
1678,
3829,
29901,
450,
7136,
7481,
29892,
382,
14098,
29933,
21700,
322,
4737,
562,
768,
293,
8158,
505,
1009,
1914,
5412,
4413,
29892,
13,
1678,
1550,
278,
916,
1051,
4452,
437,
451,
29889,
450,
14338,
29914,
23679,
292,
5001,
322,
29892,
565,
4944,
29892,
278,
1353,
13,
1678,
310,
360,
12182,
29879,
29914,
2528,
29899,
29949,
1983,
437,
451,
1584,
505,
263,
3858,
297,
12814,
304,
6507,
2635,
29892,
916,
21796,
322,
23272,
895,
29892,
13,
1678,
9819,
297,
445,
1472,
565,
29899,
23681,
29899,
20788,
29889,
13,
1678,
512,
1206,
310,
278,
382,
14098,
29933,
29899,
29741,
322,
278,
4737,
562,
768,
293,
8158,
29892,
278,
7625,
1121,
6166,
526,
4502,
304,
16955,
13,
1678,
13755,
3519,
29889,
13,
13,
1678,
584,
3207,
2967,
29918,
3888,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
2967,
5235,
1813,
13,
1678,
14550,
13,
1678,
1121,
353,
9657,
580,
13,
1678,
2967,
29918,
3888,
353,
2967,
29918,
3888,
29918,
3488,
29889,
2886,
877,
4563,
742,
770,
29918,
2433,
15334,
29918,
11802,
3888,
2824,
2886,
877,
352,
1495,
13,
308,
13,
1678,
565,
2967,
29918,
3888,
29901,
13,
4706,
13997,
353,
1051,
580,
13,
4706,
1819,
353,
1051,
580,
13,
13,
4706,
363,
5235,
297,
2967,
29918,
3888,
29889,
2886,
29918,
497,
877,
492,
29374,
13,
9651,
565,
451,
525,
1990,
29915,
297,
5235,
29889,
5552,
29879,
29901,
13,
18884,
8118,
353,
5235,
29889,
2886,
877,
29890,
1495,
13,
18884,
565,
8118,
29901,
13,
462,
1678,
7663,
353,
337,
29889,
1491,
29898,
29878,
12764,
29879,
742,
17411,
742,
8118,
29889,
726,
7503,
29899,
29896,
2314,
13,
462,
1678,
995,
353,
518,
791,
29889,
726,
363,
659,
297,
5235,
29889,
2886,
29918,
497,
877,
29874,
1495,
29962,
13,
462,
1678,
565,
7431,
29898,
1767,
29897,
1275,
29871,
29896,
29901,
13,
462,
4706,
995,
353,
995,
29961,
29900,
29962,
13,
18884,
1683,
29901,
13,
462,
1678,
565,
337,
29889,
4478,
29898,
29878,
29915,
29937,
11671,
29883,
742,
5235,
29889,
2886,
877,
29874,
1495,
1839,
12653,
2033,
1125,
13,
462,
4706,
7663,
353,
525,
29928,
12182,
29915,
13,
462,
1678,
25342,
337,
29889,
4478,
29898,
29878,
29915,
29914,
14518,
29914,
742,
5235,
29889,
2886,
877,
29874,
1495,
1839,
12653,
2033,
1125,
13,
462,
4706,
7663,
353,
525,
21410,
29915,
13,
462,
1678,
995,
353,
5235,
29889,
726,
13,
18884,
13997,
29889,
4397,
29898,
7320,
29897,
13,
9651,
25342,
525,
3221,
29899,
12120,
29915,
297,
5235,
1839,
1990,
2033,
29901,
13,
18884,
13997,
29889,
4397,
877,
9203,
29899,
21889,
1495,
13,
18884,
995,
353,
5235,
29889,
726,
13,
9651,
25342,
525,
1884,
8962,
29915,
297,
5235,
1839,
1990,
2033,
29901,
13,
18884,
6773,
13,
9651,
25342,
525,
267,
6050,
29915,
297,
5235,
1839,
1990,
2033,
29901,
13,
18884,
1121,
1839,
2890,
29934,
29933,
2033,
353,
4770,
657,
29918,
267,
6050,
29918,
29741,
29898,
3888,
29897,
13,
18884,
6773,
13,
9651,
25342,
525,
2527,
562,
768,
293,
29915,
297,
5235,
1839,
1990,
2033,
29901,
13,
18884,
1121,
1839,
10095,
562,
768,
293,
2033,
353,
4770,
657,
29918,
2527,
562,
768,
293,
29918,
13628,
29898,
3888,
29897,
13,
18884,
6773,
13,
9651,
1683,
29901,
13,
18884,
2967,
29918,
1272,
353,
5235,
29889,
726,
29889,
5451,
877,
29901,
1495,
13,
18884,
13997,
29889,
4397,
29898,
3188,
29918,
1272,
29961,
29900,
1822,
17010,
3101,
13,
18884,
995,
353,
2967,
29918,
1272,
29961,
29896,
1822,
17010,
580,
13,
13,
9651,
1819,
29889,
4397,
29898,
1767,
29897,
13,
13,
4706,
363,
7663,
29892,
995,
297,
14319,
29898,
20683,
29892,
1819,
1125,
13,
9651,
1121,
29961,
7320,
29962,
353,
995,
13,
13,
1678,
736,
1121,
13,
13,
13,
1753,
679,
29918,
8159,
29918,
3188,
29918,
3888,
29898,
3188,
29918,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
2989,
2967,
5235,
373,
278,
3748,
4944,
373,
278,
2967,
5235,
1813,
13,
1678,
313,
3188,
5235,
29892,
6139,
29892,
1404,
26838,
29892,
1024,
467,
13,
13,
1678,
910,
1158,
3763,
5717,
599,
3625,
6931,
373,
278,
2967,
5235,
1813,
13,
1678,
322,
14422,
278,
2582,
297,
263,
8600,
29889,
13,
13,
1678,
584,
3207,
2967,
29918,
3888,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
2967,
5235,
1813,
13,
1678,
14550,
13,
1678,
1121,
353,
679,
29918,
3188,
29918,
3888,
29898,
3188,
29918,
3888,
29918,
3488,
29897,
13,
1678,
1121,
1839,
9868,
2033,
353,
679,
29918,
8216,
29898,
3188,
29918,
3888,
29918,
3488,
29897,
13,
1678,
1121,
1839,
2659,
29899,
29934,
271,
886,
2033,
353,
679,
29918,
1792,
29918,
3605,
886,
29898,
3188,
29918,
3888,
29918,
3488,
29897,
13,
1678,
1121,
1839,
1170,
2033,
353,
679,
29918,
978,
29898,
3188,
29918,
3888,
29918,
3488,
29897,
13,
13,
1678,
736,
1121,
13,
13,
13,
1753,
679,
29918,
328,
16858,
29918,
3888,
29898,
328,
16858,
29918,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
2989,
5235,
373,
278,
3748,
4944,
373,
278,
12862,
5235,
1813,
29889,
13,
1678,
313,
3257,
848,
29892,
6910,
29892,
788,
29899,
787,
29897,
13,
13,
1678,
910,
1158,
3763,
5717,
599,
3625,
639,
800,
373,
278,
12862,
5235,
1813,
13,
1678,
322,
14422,
278,
2582,
297,
263,
8600,
29889,
13,
13,
1678,
584,
3207,
12862,
29918,
3888,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
12862,
5235,
1813,
13,
1678,
14550,
13,
1678,
1121,
353,
9657,
580,
13,
268,
13,
1678,
1121,
1839,
7030,
29899,
1469,
2033,
353,
679,
29918,
3257,
29918,
1272,
29898,
328,
16858,
29918,
3888,
29918,
3488,
29897,
13,
1678,
1121,
1839,
29963,
414,
1080,
2033,
353,
679,
29918,
26100,
29898,
328,
16858,
29918,
3888,
29918,
3488,
29897,
13,
1678,
1121,
1839,
29928,
12182,
2033,
353,
679,
29918,
11671,
29883,
29898,
328,
16858,
29918,
3888,
29918,
3488,
29897,
13,
13,
1678,
736,
1121,
13,
13,
13,
1753,
679,
29918,
3257,
29918,
1272,
29898,
328,
16858,
29918,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
3611,
848,
310,
278,
3748,
4944,
373,
278,
12862,
5235,
1813,
13,
1678,
313,
6734,
29892,
2531,
690,
29892,
382,
14098,
29933,
29899,
2783,
924,
943,
29892,
14109,
313,
1430,
29897,
1544,
29892,
2473,
1456,
414,
29892,
2992,
29889,
13742,
13,
1678,
450,
27387,
848,
508,
1163,
515,
3748,
304,
3748,
2183,
278,
848,
4944,
29889,
13,
13,
1678,
8741,
29901,
323,
2122,
310,
350,
414,
8749,
29901,
5739,
276,
29892,
10682,
261,
29892,
9959,
7412,
414,
29892,
13542,
7412,
414,
29892,
3772,
29875,
13,
1678,
450,
3439,
29879,
29901,
5739,
276,
29892,
10682,
261,
29892,
382,
14098,
29933,
29899,
4002,
924,
943,
29892,
3772,
29875,
13,
13,
1678,
450,
3611,
848,
338,
6087,
297,
6139,
1051,
29892,
607,
3528,
338,
9322,
964,
263,
13,
1678,
1933,
29899,
7611,
411,
278,
5412,
770,
2532,
29899,
29873,
17707,
532,
29889,
13,
1678,
450,
8282,
322,
8118,
526,
21213,
16949,
322,
6087,
408,
6611,
322,
1819,
297,
13,
1678,
263,
8600,
29889,
13,
13,
1678,
584,
3207,
12862,
29918,
3888,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
12862,
5235,
1813,
13,
1678,
14550,
13,
1678,
1121,
353,
9657,
580,
13,
1678,
3611,
29918,
1272,
353,
12862,
29918,
3888,
29918,
3488,
29889,
2886,
877,
4563,
742,
525,
15334,
29918,
29873,
17707,
532,
1495,
13,
13,
1678,
565,
3611,
29918,
1272,
29901,
13,
4706,
13997,
353,
3611,
29918,
1272,
29889,
2886,
29918,
497,
877,
6008,
1495,
13,
4706,
1819,
353,
3611,
29918,
1272,
29889,
2886,
29918,
497,
877,
1289,
1495,
13,
13,
4706,
363,
7663,
29892,
995,
297,
14319,
29898,
20683,
29892,
1819,
1125,
13,
9651,
1820,
353,
337,
29889,
1491,
29898,
29878,
12764,
29879,
742,
17411,
742,
337,
29889,
1491,
29898,
29878,
29915,
29961,
580,
29962,
742,
15516,
7663,
29889,
726,
876,
13,
9651,
995,
353,
337,
29889,
1491,
29898,
29878,
29915,
1405,
742,
13420,
742,
995,
29889,
726,
467,
5451,
29317,
1495,
13,
9651,
565,
7431,
29898,
1767,
29897,
1405,
29871,
29896,
29901,
13,
18884,
995,
353,
518,
791,
29889,
17010,
580,
363,
659,
297,
995,
29962,
13,
462,
268,
13,
9651,
1121,
29961,
1989,
7503,
29899,
29896,
5262,
353,
995,
13,
13,
1678,
736,
1121,
13,
13,
13,
1753,
679,
29918,
26100,
29898,
328,
16858,
29918,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
599,
6369,
6910,
310,
278,
3748,
313,
12803,
29892,
9805,
261,
29892,
3234,
3553,
29892,
2594,
401,
29892,
21700,
467,
13,
13,
1678,
450,
848,
338,
6087,
297,
263,
1591,
1728,
738,
5412,
2893,
14903,
470,
4413,
29889,
450,
9101,
297,
263,
2323,
13,
1678,
1591,
1948,
599,
505,
5412,
4413,
6590,
304,
1009,
8118,
29892,
5174,
363,
278,
3234,
3553,
322,
13,
1678,
2594,
401,
9101,
19383,
278,
1021,
770,
29889,
910,
508,
367,
491,
3364,
287,
491,
278,
2560,
5751,
393,
599,
3161,
13,
1678,
297,
278,
1121,
731,
411,
385,
1584,
2380,
526,
3234,
23481,
322,
599,
3161,
411,
385,
7736,
2380,
526,
13,
1678,
2594,
18137,
29889,
910,
5751,
338,
2854,
1951,
29892,
1584,
565,
727,
338,
694,
3234,
3553,
470,
2594,
401,
4944,
29892,
13,
1678,
13755,
3639,
6213,
408,
1009,
1819,
29892,
18818,
292,
3161,
472,
599,
18111,
29889,
13,
13,
1678,
584,
3207,
12862,
29918,
3888,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
12862,
5235,
1813,
13,
1678,
14550,
13,
1678,
1121,
353,
1051,
580,
13,
13,
1678,
12786,
353,
12862,
29918,
3888,
29918,
3488,
29889,
2886,
29918,
497,
877,
1594,
742,
770,
29918,
2433,
1037,
29887,
291,
1495,
13,
1678,
9805,
414,
353,
12862,
29918,
3888,
29918,
3488,
29889,
2886,
29918,
497,
877,
1594,
742,
770,
29918,
2433,
1272,
14518,
1495,
13,
1678,
18999,
353,
12862,
29918,
3888,
29918,
3488,
29889,
2886,
29918,
497,
877,
1594,
742,
770,
29918,
2433,
4130,
481,
333,
1495,
13,
1678,
3234,
29918,
4841,
353,
18999,
29961,
1057,
29906,
29962,
13,
1678,
2594,
18137,
353,
18999,
29961,
29896,
1057,
29906,
29962,
13,
1678,
6507,
29918,
15190,
353,
12862,
29918,
3888,
29918,
3488,
29889,
2886,
29918,
497,
877,
1594,
742,
770,
29918,
2433,
29883,
1256,
1495,
13,
1678,
26838,
353,
12862,
29918,
3888,
29918,
3488,
29889,
2886,
29918,
497,
877,
1594,
742,
770,
29918,
2433,
4130,
279,
1218,
1495,
13,
13,
1678,
565,
12786,
322,
9805,
414,
322,
3234,
29918,
4841,
322,
2594,
18137,
322,
6507,
29918,
15190,
322,
26838,
29901,
13,
4706,
363,
313,
12803,
29892,
9805,
261,
29892,
3234,
29918,
333,
29892,
2594,
401,
29892,
6507,
29918,
1256,
29892,
21700,
29897,
297,
14319,
29898,
13,
462,
1678,
12786,
29892,
9805,
414,
29892,
3234,
29918,
4841,
29892,
2594,
18137,
29892,
6507,
29918,
15190,
29892,
26838,
1125,
13,
9651,
1121,
29889,
4397,
29898,
13,
18884,
11117,
18457,
2396,
5120,
29889,
726,
29889,
17010,
3285,
13,
18884,
525,
21076,
1674,
261,
2396,
9805,
261,
29889,
726,
29889,
17010,
3285,
13,
18884,
525,
7566,
29899,
1204,
2396,
3234,
29918,
333,
29889,
726,
29889,
17010,
3285,
13,
18884,
525,
4297,
401,
2396,
2594,
401,
29889,
726,
29889,
17010,
3285,
13,
18884,
525,
19729,
29899,
2539,
2396,
6507,
29918,
1256,
29889,
726,
29889,
17010,
3285,
13,
18884,
525,
29934,
1218,
2396,
21700,
29889,
726,
29889,
17010,
580,
1800,
13,
13,
1678,
736,
1121,
13,
13,
13,
1753,
679,
29918,
11671,
29883,
29898,
17263,
749,
29918,
3888,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
599,
5492,
788,
29899,
787,
29914,
29928,
12182,
29879,
310,
278,
3748,
313,
978,
29892,
3748,
5444,
29939,
29879,
29899,
2324,
467,
13,
13,
1678,
450,
360,
12182,
4004,
338,
1407,
28907,
29889,
319,
3287,
310,
17752,
304,
278,
8090,
526,
4567,
313,
4773,
29901,
13,
1678,
450,
3439,
29879,
2869,
2534,
472,
3203,
29871,
29941,
29892,
29900,
29896,
29941,
29892,
29945,
29945,
29941,
10596,
294,
519,
788,
29899,
787,
29892,
1550,
871,
2534,
1023,
5034,
13,
1678,
304,
3748,
5444,
29939,
29879,
467,
450,
848,
3528,
338,
6087,
297,
263,
1591,
411,
278,
3553,
270,
29880,
29883,
29892,
3907,
278,
13755,
20837,
29889,
13,
13,
1678,
584,
3207,
12862,
29918,
3888,
29918,
3488,
29901,
25685,
29903,
1132,
1203,
6943,
278,
12862,
5235,
1813,
13,
1678,
14550,
13,
1678,
1121,
353,
1051,
580,
13,
1678,
270,
29880,
2395,
353,
6564,
29918,
3888,
29918,
3488,
29889,
2886,
877,
4563,
742,
1178,
2433,
11671,
29883,
1495,
13,
13,
1678,
565,
270,
29880,
2395,
29901,
13,
4706,
363,
270,
29880,
29883,
297,
270,
29880,
2395,
29889,
2886,
29918,
497,
877,
29874,
742,
2822,
29922,
5574,
1125,
13,
9651,
1121,
29889,
4397,
3319,
13,
18884,
525,
1170,
2396,
270,
29880,
29883,
29889,
726,
29892,
13,
18884,
525,
6595,
2396,
270,
29880,
29883,
1839,
12653,
2033,
1800,
13,
1678,
736,
1121,
13,
13,
13,
1753,
679,
29918,
2619,
29898,
2619,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
599,
4433,
5155,
2845,
515,
278,
7699,
5155,
1813,
470,
278,
443,
9778,
1490,
5155,
1813,
3704,
13,
1678,
1544,
322,
1234,
2302,
29889,
13,
13,
1678,
9134,
7699,
322,
443,
9778,
1490,
5155,
6515,
505,
278,
1021,
3829,
29901,
450,
2472,
338,
6087,
297,
263,
5639,
29892,
13,
1678,
607,
8640,
278,
5155,
29892,
278,
2988,
304,
278,
5155,
322,
278,
1234,
2302,
297,
6131,
411,
278,
4413,
3855,
1056,
29918,
2371,
13,
1678,
13055,
491,
11261,
313,
29872,
29889,
29887,
29889,
1174,
6764,
29914,
29933,
2209,
22305,
29892,
8364,
936,
22305,
29892,
2992,
6250,
450,
13755,
338,
769,
5312,
1141,
11333,
29889,
13,
13,
1678,
960,
697,
310,
1438,
13926,
947,
451,
505,
263,
4839,
313,
29875,
29889,
29872,
29889,
263,
6139,
363,
278,
11261,
511,
278,
4004,
338,
14993,
2986,
29889,
13,
1678,
910,
1196,
310,
775,
471,
871,
2715,
363,
278,
16563,
310,
1614,
841,
404,
29892,
408,
445,
6434,
881,
451,
3926,
6403,
29889,
13,
1678,
14550,
13,
13,
1678,
1121,
353,
1051,
580,
13,
1678,
5155,
353,
5155,
29918,
3488,
29889,
2886,
29918,
497,
877,
2371,
742,
770,
29918,
2433,
29939,
1056,
29918,
2371,
1495,
13,
13,
1678,
565,
5155,
29901,
13,
4706,
363,
23820,
297,
5155,
29901,
13,
9651,
1018,
29901,
13,
18884,
11261,
353,
23820,
29889,
2886,
877,
386,
742,
770,
29918,
2433,
12470,
2824,
726,
13,
9651,
5174,
23833,
2392,
29901,
13,
18884,
6773,
13,
13,
9651,
11261,
29918,
8977,
353,
426,
13,
18884,
525,
7031,
293,
2396,
11261,
29892,
13,
18884,
525,
2182,
2297,
2396,
1051,
28296,
13,
13,
9651,
5155,
29918,
726,
29879,
353,
23820,
29889,
2886,
29918,
497,
877,
29874,
742,
2822,
29922,
5574,
29897,
13,
9651,
1234,
29918,
2798,
353,
23820,
29889,
2886,
29918,
497,
877,
1594,
742,
770,
29918,
2433,
2798,
1495,
13,
13,
9651,
363,
1139,
29892,
2302,
297,
14319,
29898,
2619,
29918,
726,
29879,
29892,
1234,
29918,
2798,
1125,
13,
18884,
11261,
29918,
8977,
1839,
2182,
2297,
13359,
4397,
3319,
13,
462,
1678,
525,
16492,
2396,
1139,
29889,
726,
29892,
13,
462,
1678,
525,
6595,
2396,
1139,
1839,
12653,
7464,
13,
462,
1678,
525,
3981,
2396,
938,
29898,
2798,
29889,
726,
26972,
13,
795,
13,
9651,
1121,
29889,
4397,
29898,
13010,
29918,
8977,
29897,
13,
13,
1678,
736,
1121,
13,
13,
13,
1753,
679,
29918,
12470,
29918,
14144,
29898,
14144,
29918,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
1139,
4902,
313,
29875,
29889,
29872,
29889,
278,
2989,
1139,
1426,
29897,
322,
29892,
565,
738,
29892,
967,
6089,
3704,
701,
29899,
322,
1623,
29894,
4769,
29889,
13,
13,
1678,
450,
5639,
411,
278,
2175,
10638,
310,
278,
1667,
2793,
756,
304,
367,
4629,
937,
29892,
6467,
278,
17786,
1543,
13,
1678,
674,
367,
21213,
408,
1532,
29892,
8236,
304,
302,
787,
575,
936,
2582,
29889,
13,
1678,
9134,
5155,
322,
6089,
526,
6087,
297,
22637,
411,
278,
770,
5121,
29918,
3888,
29889,
1670,
338,
694,
9406,
23683,
13,
1678,
1546,
278,
1139,
322,
967,
6089,
297,
278,
5639,
30165,
29879,
3573,
29892,
1716,
526,
6087,
297,
805,
550,
411,
278,
770,
1024,
29889,
450,
871,
13,
1678,
982,
304,
20820,
963,
338,
304,
1423,
29892,
565,
727,
526,
738,
701,
29899,
470,
1623,
29894,
4769,
6087,
297,
278,
5639,
408,
1532,
29889,
13,
1678,
14550,
13,
13,
1678,
1121,
353,
9657,
580,
13,
1678,
1667,
29918,
3051,
353,
4902,
29918,
3488,
29889,
2886,
877,
4563,
742,
770,
29918,
2433,
3396,
29918,
3051,
2824,
2886,
877,
4563,
742,
770,
29918,
2433,
9653,
29947,
1495,
13,
1678,
4902,
353,
1667,
29918,
3051,
29889,
2886,
29918,
497,
877,
4563,
742,
770,
29918,
2433,
18326,
29918,
3888,
1495,
13,
13,
1678,
565,
4902,
29901,
13,
4706,
6089,
353,
1051,
580,
13,
13,
4706,
363,
9493,
297,
4902,
29901,
13,
9651,
2989,
29918,
726,
353,
9493,
29889,
2886,
877,
9653,
742,
770,
29918,
2433,
978,
2824,
726,
13,
9651,
701,
29894,
4769,
353,
9493,
29889,
2886,
877,
9653,
742,
770,
29918,
2433,
786,
1495,
13,
9651,
1623,
29894,
4769,
353,
9493,
29889,
2886,
877,
9653,
742,
770,
29918,
2433,
3204,
1495,
13,
13,
9651,
565,
451,
701,
29894,
4769,
470,
451,
1623,
29894,
4769,
29901,
13,
18884,
1121,
1839,
13658,
29899,
16492,
2033,
353,
2989,
29918,
726,
13,
9651,
1683,
29901,
13,
18884,
6089,
29889,
4397,
3319,
13,
462,
1678,
525,
22550,
2396,
2989,
29918,
726,
29892,
13,
462,
1678,
525,
3373,
29894,
4769,
2396,
938,
29898,
786,
29894,
4769,
29889,
726,
511,
13,
462,
1678,
525,
6767,
29894,
4769,
2396,
938,
29898,
3204,
29894,
4769,
29889,
726,
26972,
13,
13,
4706,
1121,
1839,
29909,
1983,
17538,
2033,
353,
6089,
13,
13,
1678,
736,
1121,
13,
13,
1753,
679,
29918,
497,
29918,
29887,
1280,
29898,
3488,
1125,
13,
1678,
14550,
13,
1678,
16969,
263,
1051,
310,
278,
2446,
29871,
29896,
29900,
29900,
8090,
29892,
3704,
3748,
5444,
29939,
29879,
2988,
29892,
515,
385,
421,
497,
29899,
29887,
1280,
29899,
3488,
29952,
310,
13,
1678,
263,
2183,
2991,
29889,
13,
268,
13,
1678,
450,
5235,
338,
6087,
297,
278,
4206,
310,
263,
1591,
411,
278,
5412,
770,
2582,
29889,
450,
8018,
2472,
13,
1678,
448,
1024,
322,
3748,
5444,
29939,
29879,
1544,
310,
278,
3748,
448,
526,
6087,
297,
263,
1591,
848,
3038,
411,
278,
5412,
770,
13,
1678,
364,
3257,
29889,
6549,
13755,
338,
5312,
1141,
11333,
29889,
13,
13,
1678,
584,
3207,
1813,
29901,
421,
3596,
29899,
29887,
1280,
29899,
3488,
29952,
310,
263,
2183,
2991,
29889,
13,
1678,
14550,
13,
1678,
1121,
353,
1051,
580,
13,
1678,
8090,
353,
1813,
29889,
2886,
877,
2371,
742,
770,
29918,
2433,
9902,
1495,
13,
1678,
565,
8090,
29901,
13,
4706,
4206,
353,
8090,
29889,
2886,
29918,
497,
877,
1594,
742,
770,
29918,
2433,
2273,
1740,
1495,
13,
4706,
565,
4206,
29901,
13,
9651,
363,
1948,
297,
4206,
29901,
13,
18884,
1544,
353,
1948,
29889,
2886,
877,
29874,
742,
2822,
29922,
5574,
29897,
13,
18884,
1544,
29918,
726,
353,
1544,
1839,
12653,
2033,
13,
18884,
3748,
353,
1544,
29889,
726,
13,
18884,
1121,
29889,
4397,
3319,
13,
462,
1678,
525,
1170,
2396,
3748,
29892,
13,
462,
1678,
525,
6595,
2396,
1544,
29918,
726,
1800,
13,
1678,
736,
1121,
13,
13,
1753,
4770,
657,
29918,
2527,
562,
768,
293,
29918,
13628,
29898,
3188,
29918,
3888,
29918,
15334,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
6588,
1539,
562,
768,
293,
8158,
322,
278,
1353,
310,
21804,
29889,
13,
13,
1678,
450,
8158,
3528,
338,
6087,
297,
263,
1933,
29899,
7611,
411,
278,
5412,
770,
8158,
29889,
13,
1678,
450,
3001,
2302,
310,
21804,
4225,
304,
367,
27387,
515,
263,
1544,
1426,
2400,
29892,
515,
607,
13,
1678,
278,
3935,
1353,
756,
304,
367,
23892,
773,
263,
4943,
4603,
29889,
13,
13,
1678,
584,
3207,
2967,
29918,
3888,
29918,
15334,
29901,
25685,
29903,
1132,
1203,
6943,
278,
2967,
5235,
3800,
4944,
297,
278,
7568,
13,
1678,
1492,
310,
278,
2967,
5235,
1813,
29889,
13,
1678,
14550,
13,
1678,
1121,
353,
9657,
580,
13,
1678,
1539,
562,
768,
293,
353,
2967,
29918,
3888,
29918,
15334,
29889,
2886,
877,
4563,
742,
770,
29918,
2433,
27828,
29918,
2324,
1495,
13,
13,
1678,
565,
1539,
562,
768,
293,
29901,
13,
4706,
1539,
562,
768,
293,
29918,
276,
7406,
353,
1539,
562,
768,
293,
29889,
726,
13,
9651,
13,
4706,
1018,
29901,
13,
9651,
3694,
353,
337,
29889,
12198,
29898,
29878,
12764,
29881,
29974,
1495,
13,
9651,
1539,
562,
768,
293,
29918,
27828,
29918,
2798,
353,
938,
29898,
20326,
29889,
2886,
497,
29898,
2527,
562,
768,
293,
29918,
276,
7406,
9601,
29900,
2314,
13,
4706,
5174,
11374,
2392,
29901,
13,
9651,
1539,
562,
768,
293,
29918,
27828,
29918,
2798,
353,
6213,
13,
13,
4706,
1121,
1839,
1123,
7406,
2033,
353,
1539,
562,
768,
293,
29918,
27828,
29918,
2798,
13,
13,
4706,
1018,
29901,
13,
9651,
1539,
562,
768,
293,
29918,
13628,
353,
938,
29898,
3188,
29918,
3888,
29918,
15334,
29889,
2886,
877,
4563,
742,
770,
29918,
2433,
13628,
2824,
726,
29897,
13,
4706,
5174,
23833,
2392,
29901,
13,
9651,
1539,
562,
768,
293,
29918,
13628,
353,
6213,
13,
13,
4706,
1121,
1839,
20097,
2033,
353,
1539,
562,
768,
293,
29918,
13628,
13,
13,
1678,
736,
1121,
13,
13,
13,
1753,
4770,
657,
29918,
267,
6050,
29918,
29741,
29898,
3188,
29918,
3888,
29918,
15334,
1125,
13,
1678,
14550,
13,
1678,
16969,
278,
382,
14098,
29933,
21700,
322,
278,
6139,
310,
278,
21700,
29889,
13,
13,
1678,
450,
382,
14098,
29933,
5235,
338,
6087,
297,
263,
1051,
6251,
313,
974,
278,
443,
21693,
1051,
310,
2967,
2472,
29897,
411,
278,
13,
1678,
5412,
770,
831,
6050,
29889,
5806,
7934,
5742,
278,
20194,
373,
278,
7962,
4700,
29892,
278,
3935,
21700,
322,
13,
1678,
967,
21700,
508,
5948,
367,
27387,
491,
263,
24368,
967,
2793,
373,
263,
448,
29889,
13,
13,
1678,
584,
3207,
2967,
29918,
3888,
29918,
15334,
29901,
25685,
29903,
1132,
1203,
6943,
278,
2967,
5235,
3800,
4944,
297,
278,
7568,
13,
1678,
1492,
310,
278,
2967,
5235,
1813,
29889,
13,
1678,
14550,
13,
1678,
1121,
353,
9657,
580,
13,
13,
1678,
565,
2967,
29918,
3888,
29918,
15334,
29901,
13,
4706,
21700,
29892,
6139,
353,
2967,
29918,
3888,
29918,
15334,
29889,
726,
29889,
5451,
703,
29899,
1159,
13,
4706,
21700,
29892,
6139,
353,
21700,
29889,
17010,
3285,
6139,
29889,
17010,
580,
13,
4706,
1121,
1839,
29934,
1218,
2033,
353,
21700,
13,
4706,
1121,
1839,
9868,
2033,
353,
6139,
13,
13,
1678,
736,
1121,
2
] |
code/examples/example_binomial_and_log_normal_abtest.py | hugopibernat/BayesianABTestAnalysis | 0 | 3658 | #################################################
####### Author: <NAME> #######
####### Contact: <EMAIL> #######
####### Date: April 2014 #######
#################################################
from bayesianABTest import sampleSuccessRateForBinomial, sampleMeanForLogNormal, probabilityOfABetterThanB
from numpy.random import lognormal
from numpy import mean, concatenate, zeros
# Generate Log-Normal data
A_actuals = lognormal(mean=4.10, sigma=1.0, size=100)
B_actuals = lognormal(mean=4.00, sigma=1.0, size=100)
# Plus some zeros
A_data = concatenate([A_actuals,zeros(10000)])
B_data = concatenate([B_actuals,zeros(10000)])
# Modeling conversions with a binomial variable
A_purchases = sum(A_data > 0)
A_sessions = len(A_data)
B_purchases = sum(B_data > 0)
B_sessions = len(B_data)
A_CR = sampleSuccessRateForBinomial(A_sessions,A_purchases)
B_CR = sampleSuccessRateForBinomial(B_sessions,B_purchases)
# Modeling the spend with a log-normal
A_non_zero_data = A_data[A_data > 0]
B_non_zero_data = B_data[B_data > 0]
A_spend = sampleMeanForLogNormal(A_non_zero_data)
B_spend = sampleMeanForLogNormal(B_non_zero_data)
# Combining the two
A_rps = A_CR*A_spend
B_rps = B_CR*B_spend
# Result:
print probabilityOfABetterThanB(A_rps,B_rps) | [
1,
835,
13383,
13383,
7346,
4136,
2277,
13,
4136,
2277,
29937,
13361,
29901,
529,
5813,
29958,
632,
835,
4136,
13,
4136,
2277,
29937,
22387,
29901,
529,
26862,
6227,
29958,
259,
835,
4136,
13,
4136,
2277,
29937,
4712,
29901,
3786,
29871,
29906,
29900,
29896,
29946,
462,
29871,
835,
4136,
13,
13383,
13383,
13383,
29937,
13,
13,
13,
3166,
23041,
18970,
2882,
3057,
1053,
4559,
14191,
19907,
2831,
29933,
262,
7615,
29892,
4559,
6816,
273,
2831,
3403,
19077,
29892,
6976,
2776,
2882,
19036,
1349,
273,
29933,
13,
3166,
12655,
29889,
8172,
1053,
1480,
8945,
13,
3166,
12655,
1053,
2099,
29892,
16125,
403,
29892,
24786,
13,
13,
29937,
3251,
403,
4522,
29899,
19077,
848,
13,
29909,
29918,
19304,
29879,
353,
1480,
8945,
29898,
12676,
29922,
29946,
29889,
29896,
29900,
29892,
269,
2934,
29922,
29896,
29889,
29900,
29892,
2159,
29922,
29896,
29900,
29900,
29897,
13,
29933,
29918,
19304,
29879,
353,
1480,
8945,
29898,
12676,
29922,
29946,
29889,
29900,
29900,
29892,
269,
2934,
29922,
29896,
29889,
29900,
29892,
2159,
29922,
29896,
29900,
29900,
29897,
13,
29937,
15113,
777,
24786,
13,
29909,
29918,
1272,
353,
16125,
403,
4197,
29909,
29918,
19304,
29879,
29892,
3298,
359,
29898,
29896,
29900,
29900,
29900,
29900,
29897,
2314,
13,
29933,
29918,
1272,
353,
16125,
403,
4197,
29933,
29918,
19304,
29879,
29892,
3298,
359,
29898,
29896,
29900,
29900,
29900,
29900,
29897,
2314,
13,
13,
29937,
8125,
292,
9678,
1080,
411,
263,
9016,
7615,
2286,
13,
29909,
29918,
29886,
2458,
2129,
353,
2533,
29898,
29909,
29918,
1272,
1405,
29871,
29900,
29897,
13,
29909,
29918,
29879,
10964,
353,
7431,
29898,
29909,
29918,
1272,
29897,
13,
29933,
29918,
29886,
2458,
2129,
353,
2533,
29898,
29933,
29918,
1272,
1405,
29871,
29900,
29897,
13,
29933,
29918,
29879,
10964,
353,
7431,
29898,
29933,
29918,
1272,
29897,
13,
13,
29909,
29918,
11341,
353,
4559,
14191,
19907,
2831,
29933,
262,
7615,
29898,
29909,
29918,
29879,
10964,
29892,
29909,
29918,
29886,
2458,
2129,
29897,
13,
29933,
29918,
11341,
353,
4559,
14191,
19907,
2831,
29933,
262,
7615,
29898,
29933,
29918,
29879,
10964,
29892,
29933,
29918,
29886,
2458,
2129,
29897,
13,
13,
29937,
8125,
292,
278,
18864,
411,
263,
1480,
29899,
8945,
13,
29909,
29918,
5464,
29918,
9171,
29918,
1272,
353,
319,
29918,
1272,
29961,
29909,
29918,
1272,
1405,
29871,
29900,
29962,
13,
29933,
29918,
5464,
29918,
9171,
29918,
1272,
353,
350,
29918,
1272,
29961,
29933,
29918,
1272,
1405,
29871,
29900,
29962,
13,
13,
29909,
29918,
1028,
355,
353,
4559,
6816,
273,
2831,
3403,
19077,
29898,
29909,
29918,
5464,
29918,
9171,
29918,
1272,
29897,
13,
29933,
29918,
1028,
355,
353,
4559,
6816,
273,
2831,
3403,
19077,
29898,
29933,
29918,
5464,
29918,
9171,
29918,
1272,
29897,
13,
13,
29937,
422,
2109,
292,
278,
1023,
13,
29909,
29918,
29878,
567,
353,
319,
29918,
11341,
29930,
29909,
29918,
1028,
355,
13,
29933,
29918,
29878,
567,
353,
350,
29918,
11341,
29930,
29933,
29918,
1028,
355,
13,
13,
29937,
7867,
29901,
13,
2158,
6976,
2776,
2882,
19036,
1349,
273,
29933,
29898,
29909,
29918,
29878,
567,
29892,
29933,
29918,
29878,
567,
29897,
2
] |
v2/audio/audio_reader.py | safgen/deep-speaker | 0 | 40741 | <reponame>safgen/deep-speaker<filename>v2/audio/audio_reader.py
from time import time
import dill
import librosa
import numpy as np
import os
import re
from glob import glob
from random import shuffle, randint, choice
from tqdm import tqdm
from helpers.logger import Logger
logger = Logger.instance()
TMP_DIR = '/tmp/speaker-change-detection/'
if not os.path.exists(TMP_DIR):
os.makedirs(TMP_DIR)
SENTENCE_ID = 'sentence_id'
SPEAKER_ID = 'speaker_id'
FILENAME = 'filename'
class PreMergeProcessor:
@staticmethod
def ramp(sound_1, sound_2):
mask_1 = np.linspace(1, 0, len(sound_1))
mask_2 = np.linspace(0, 1, len(sound_2))
return np.expand_dims(np.multiply(mask_1, sound_1.flatten()), axis=1), \
np.expand_dims(np.multiply(mask_2, sound_2.flatten()), axis=1)
class SoundMerger:
@staticmethod
def default_merger(sound_1, sound_2):
return 0.5 * sound_1 + 0.5 * sound_2
@staticmethod
def clip_merger(sound_1, sound_2):
return np.clip(sound_1 + sound_2, -1, 1)
@staticmethod
def add_merger(sound_1, sound_2):
return sound_1 + sound_2
def find_files(directory, pattern='**/*.wav'):
"""Recursively finds all files matching the pattern."""
return sorted(glob(os.path.join(directory, pattern), recursive=True))
def read_audio_from_filename(filename, sample_rate):
audio, _ = librosa.load(filename, sr=sample_rate, mono=True)
audio = audio.reshape(-1, 1)
return audio, filename
def load_generic_audio(files, sample_rate):
for filename in files:
audio, filename = read_audio_from_filename(filename, sample_rate)
yield audio, filename
def load_vctk_audio(directory, sample_rate):
"""Generator that yields audio waveforms from the VCTK dataset, and
additionally the ID of the corresponding speaker."""
files = find_files(directory)
speaker_re = re.compile(r'p([0-9]+)_([0-9]+)\.wav')
for filename in files:
audio, _ = librosa.load(filename, sr=sample_rate, mono=True)
audio = audio.reshape(-1, 1)
matches = speaker_re.findall(filename)[0]
speaker_id, recording_id = [int(id_) for id_ in matches]
yield audio, speaker_id
def overlap(sound1, sound2, overlap_length,
merge=SoundMerger.add_merger,
pre_merge_processor=PreMergeProcessor.ramp):
tmp = np.array(sound1)
l1 = len(sound1)
l2 = len(sound2)
# print('-> l1 = {}, l2 = {}'.format(l1, l2))
if overlap_length >= l1 and overlap_length >= l2:
overlap_length = min(l1, l2)
elif overlap_length >= l2:
overlap_length = l2
elif overlap_length >= l1:
overlap_length = l1
overlap_1, overlap_2 = pre_merge_processor(tmp[-overlap_length:], sound2[:overlap_length])
overlap_part = merge(overlap_1, overlap_2)
assert len(overlap_part) == overlap_length
assert np.max(overlap_part) <= 1.0
assert np.min(overlap_part) >= -1.0
tmp[-overlap_length:] = overlap_part
out = np.concatenate((tmp, sound2[overlap_length:]))
assert len(out) == l1 + l2 - overlap_length
out = np.clip(out, -1, 1)
mid_overlap_point_offset = int(l1)
# mid_overlap_point_offset = int(l1 - overlap_length * 0.5)
return out, mid_overlap_point_offset
def trim_silence(audio, threshold):
"""Removes silence at the beginning and end of a sample."""
energy = librosa.feature.rmse(audio)
frames = np.nonzero(np.array(energy > threshold))
indices = librosa.core.frames_to_samples(frames)[1]
# Note: indices can be an empty array, if the whole audio was silence.
audio_trim = audio[0:0]
left_blank = audio[0:0]
right_blank = audio[0:0]
if indices.size:
audio_trim = audio[indices[0]:indices[-1]]
left_blank = audio[:indices[0]] # slice before.
right_blank = audio[indices[-1]:] # slice after.
return audio_trim, left_blank, right_blank
def extract_speaker_id(filename):
return filename.split('/')[-2]
def extract_sentence_id(filename):
return filename.split('/')[-1].split('_')[1].split('.')[0]
class AudioReader(object):
def __init__(self,
audio_dir,
sample_rate,
speakers_sub_list=None):
self.audio_dir = os.path.expanduser(audio_dir) # for the ~/
self.sample_rate = sample_rate
self.metadata = dict() # small cache <SPEAKER_ID -> SENTENCE_ID, filename>
self.cache = dict() # big cache <filename, data:audio librosa, blanks.>
logger.debug('Initializing AudioReader()')
logger.debug('audio_dir = {}'.format(self.audio_dir))
logger.debug('sample_rate = {}'.format(sample_rate))
logger.debug('speakers_sub_list = {}'.format(speakers_sub_list))
st = time()
if len(find_files(TMP_DIR, pattern='*.pkl')) == 0: # generate all the pickle files.
logger.debug('Nothing found at {}. Generating all the caches now.'.format(TMP_DIR))
files = find_files(self.audio_dir)
assert len(files) != 0, 'Generate your cache please.'
logger.debug('Found {} files in total in {}.'.format(len(files), self.audio_dir))
if speakers_sub_list is not None:
files = list(
filter(lambda x: any(word in extract_speaker_id(x) for word in speakers_sub_list), files))
logger.debug('{} files correspond to the speaker list {}.'.format(len(files), speakers_sub_list))
assert len(files) != 0
bar = tqdm(files)
for filename in bar:
bar.set_description(filename)
try:
speaker_id = extract_speaker_id(filename)
audio, _ = read_audio_from_filename(filename, self.sample_rate)
energy = np.abs(audio[:, 0])
silence_threshold = np.percentile(energy, 95)
offsets = np.where(energy > silence_threshold)[0]
left_blank_duration_ms = (1000.0 * offsets[0]) // self.sample_rate # frame_id to duration (ms)
right_blank_duration_ms = (1000.0 * (len(audio) - offsets[-1])) // self.sample_rate
# _, left_blank, right_blank = trim_silence(audio[:, 0], silence_threshold)
logger.info('_' * 100)
logger.info('left_blank_duration_ms = {}, right_blank_duration_ms = {}, '
'audio_length = {} frames, silence_threshold = {}'.format(left_blank_duration_ms,
right_blank_duration_ms,
len(audio),
silence_threshold))
obj = {'audio': audio,
'audio_voice_only': audio[offsets[0]:offsets[-1]],
'left_blank_duration_ms': left_blank_duration_ms,
'right_blank_duration_ms': right_blank_duration_ms,
FILENAME: filename}
cache_filename = filename.split('/')[-1].split('.')[0] + '_cache'
tmp_filename = os.path.join(TMP_DIR, cache_filename) + '.pkl'
with open(tmp_filename, 'wb') as f:
dill.dump(obj, f)
logger.debug('[DUMP AUDIO] {}'.format(tmp_filename))
# commit to metadata dictionary when you're sure no errors occurred during processing.
if speaker_id not in self.metadata:
self.metadata[speaker_id] = {}
sentence_id = extract_sentence_id(filename)
if sentence_id not in self.metadata[speaker_id]:
self.metadata[speaker_id][sentence_id] = []
self.metadata[speaker_id][sentence_id] = {SPEAKER_ID: speaker_id,
SENTENCE_ID: sentence_id,
FILENAME: filename}
except librosa.util.exceptions.ParameterError as e:
logger.error(e)
logger.error('[DUMP AUDIO ERROR SKIPPING FILENAME] {}'.format(filename))
dill.dump(self.metadata, open(os.path.join(TMP_DIR, 'metadata.pkl'), 'wb'))
logger.debug(
'Using the generated files at {}. Using them to load the cache. Be sure to have enough memory.'.format(
TMP_DIR))
self.metadata = dill.load(open(os.path.join(TMP_DIR, 'metadata.pkl'), 'rb'))
pickle_files = find_files(TMP_DIR, pattern='*.pkl')
for pkl_file in tqdm(pickle_files, desc='reading cache'):
if 'metadata' not in pkl_file:
with open(pkl_file, 'rb') as f:
obj = dill.load(f)
self.cache[obj[FILENAME]] = obj
logger.debug('Cache took {0:.2f} seconds to load. {1:} keys.'.format(time() - st, len(self.cache)))
def get_speaker_list(self):
return sorted(list(self.metadata.keys()))
def sample_speakers(self, speaker_list, num_speakers):
if speaker_list is None:
speaker_list = self.get_speaker_list()
all_speakers = list(speaker_list)
shuffle(all_speakers)
speaker_list = all_speakers[0:num_speakers]
return speaker_list
def define_random_mix(self, num_sentences=3, num_speakers=3, speaker_ids_to_choose_from=None):
speaker_ids_to_choose_from = self.sample_speakers(speaker_ids_to_choose_from, num_speakers)
targets = []
for i in range(num_sentences):
speaker_id = choice(speaker_ids_to_choose_from)
sentence_id = choice(list(self.metadata[speaker_id].keys()))
targets.append({SPEAKER_ID: speaker_id,
SENTENCE_ID: sentence_id,
FILENAME: self.metadata[speaker_id][sentence_id]['filename']})
return targets
def define_mix(self, mix_sequence):
targets = []
for speaker_sentence_id in mix_sequence:
speaker_id, sentence_id = speaker_sentence_id
if isinstance(speaker_id, int):
speaker_id = 'p' + str(speaker_id)
if isinstance(sentence_id, int):
sentence_id = str(sentence_id).zfill(3)
targets.append({SPEAKER_ID: speaker_id,
SENTENCE_ID: sentence_id,
FILENAME: self.metadata[speaker_id][sentence_id]['filename']})
return targets
def generate_mix_with_voice_only(self, targets):
if len(targets) == 0:
return [], None
audio_dict = {}
for i, target in enumerate(targets):
audio_dict[i] = self.cache[target[FILENAME]]
output = audio_dict[0]['audio_voice_only']
targets[0]['offset'] = 0 # in ms
for i in range(1, len(targets)):
offset_pos = -1
beg = targets[i - 1]['offset']
while offset_pos <= beg:
offset_pos = len(output)
output = np.concatenate((output, audio_dict[i]['audio_voice_only']))
targets[i]['offset'] = offset_pos
return targets, output
def generate_mix(self, targets):
audio_dict = {}
for i, target in enumerate(targets):
audio_dict[i] = self.cache[target[FILENAME]]
output = audio_dict[0]['audio']
targets[0]['offset'] = 0 # in ms
for i in range(1, len(targets)):
# example: sound 1 - 600 ms at the end.
dur_right_blank_1 = audio_dict[i - 1]['right_blank_duration_ms']
# example: sound 2 - 25 ms at the beginning (for silence).
dur_left_blank_2 = audio_dict[i]['left_blank_duration_ms']
blank_duration_ms = int(dur_right_blank_1 + dur_left_blank_2)
# example: sample from U[1, 600+25ms] 1 and not 0 because otherwise we have a shape error.
# ValueError: operands could not be broadcast together with shapes (723639,1) (0,1)
offset_pos = -1
beg = targets[i - 1]['offset']
while offset_pos <= beg:
# print('-> append : {}'.format(audio_dict[i][FILENAME]))
if blank_duration_ms <= 1:
rand_val = 1
else:
rand_val = int(randint(1, blank_duration_ms) * 0.8) + 1
# print('-> [{}] generated from U[1,{}]'.format(rand_val, blank_duration_ms))
output, offset_pos = overlap(output, audio_dict[i]['audio'], rand_val)
targets[i]['offset'] = offset_pos
# print(beg)
# print(offset_pos)
# print('___')
# librosa.output.write_wav('toto_{}.wav'.format(i), output[beg:offset_pos], sr=self.sample_rate)
# librosa.output.write_wav('toto.wav', output, sr=self.sample_rate)
# print('buffer length = {}'.format(len(output)))
# pprint.pprint(targets)
return targets, output
| [
1,
529,
276,
1112,
420,
29958,
29879,
2142,
1885,
29914,
24535,
29899,
5965,
5790,
29966,
9507,
29958,
29894,
29906,
29914,
18494,
29914,
18494,
29918,
16950,
29889,
2272,
13,
3166,
931,
1053,
931,
13,
13,
5215,
270,
453,
13,
5215,
4303,
1883,
29874,
13,
5215,
12655,
408,
7442,
13,
5215,
2897,
13,
5215,
337,
13,
3166,
13149,
1053,
13149,
13,
3166,
4036,
1053,
528,
21897,
29892,
20088,
524,
29892,
7348,
13,
3166,
260,
29939,
18933,
1053,
260,
29939,
18933,
13,
13,
3166,
1371,
414,
29889,
21707,
1053,
28468,
13,
13,
21707,
353,
28468,
29889,
8758,
580,
13,
13,
29911,
3580,
29918,
9464,
353,
8207,
7050,
29914,
5965,
5790,
29899,
3167,
29899,
29881,
2650,
428,
22208,
13,
361,
451,
2897,
29889,
2084,
29889,
9933,
29898,
29911,
3580,
29918,
9464,
1125,
13,
1678,
2897,
29889,
29885,
12535,
12935,
29898,
29911,
3580,
29918,
9464,
29897,
13,
13,
29903,
3919,
1430,
4741,
29918,
1367,
353,
525,
18616,
663,
29918,
333,
29915,
13,
29903,
4162,
22311,
1001,
29918,
1367,
353,
525,
5965,
5790,
29918,
333,
29915,
13,
7724,
5813,
353,
525,
9507,
29915,
13,
13,
13,
1990,
4721,
15836,
479,
18689,
29901,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
364,
1160,
29898,
29802,
29918,
29896,
29892,
6047,
29918,
29906,
1125,
13,
4706,
11105,
29918,
29896,
353,
7442,
29889,
1915,
3493,
29898,
29896,
29892,
29871,
29900,
29892,
7431,
29898,
29802,
29918,
29896,
876,
13,
4706,
11105,
29918,
29906,
353,
7442,
29889,
1915,
3493,
29898,
29900,
29892,
29871,
29896,
29892,
7431,
29898,
29802,
29918,
29906,
876,
13,
4706,
736,
7442,
29889,
18837,
29918,
6229,
29879,
29898,
9302,
29889,
18056,
368,
29898,
13168,
29918,
29896,
29892,
6047,
29918,
29896,
29889,
1579,
8606,
25739,
9685,
29922,
29896,
511,
320,
13,
1669,
7442,
29889,
18837,
29918,
6229,
29879,
29898,
9302,
29889,
18056,
368,
29898,
13168,
29918,
29906,
29892,
6047,
29918,
29906,
29889,
1579,
8606,
25739,
9685,
29922,
29896,
29897,
13,
13,
13,
1990,
14976,
15836,
914,
29901,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
2322,
29918,
1050,
914,
29898,
29802,
29918,
29896,
29892,
6047,
29918,
29906,
1125,
13,
4706,
736,
29871,
29900,
29889,
29945,
334,
6047,
29918,
29896,
718,
29871,
29900,
29889,
29945,
334,
6047,
29918,
29906,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
20102,
29918,
1050,
914,
29898,
29802,
29918,
29896,
29892,
6047,
29918,
29906,
1125,
13,
4706,
736,
7442,
29889,
24049,
29898,
29802,
29918,
29896,
718,
6047,
29918,
29906,
29892,
448,
29896,
29892,
29871,
29896,
29897,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
788,
29918,
1050,
914,
29898,
29802,
29918,
29896,
29892,
6047,
29918,
29906,
1125,
13,
4706,
736,
6047,
29918,
29896,
718,
6047,
29918,
29906,
13,
13,
13,
1753,
1284,
29918,
5325,
29898,
12322,
29892,
4766,
2433,
1068,
5515,
29889,
29893,
485,
29374,
13,
1678,
9995,
4789,
1295,
3598,
14061,
599,
2066,
9686,
278,
4766,
1213,
15945,
13,
1678,
736,
12705,
29898,
23705,
29898,
359,
29889,
2084,
29889,
7122,
29898,
12322,
29892,
4766,
511,
16732,
29922,
5574,
876,
13,
13,
13,
1753,
1303,
29918,
18494,
29918,
3166,
29918,
9507,
29898,
9507,
29892,
4559,
29918,
10492,
1125,
13,
1678,
10348,
29892,
903,
353,
4303,
1883,
29874,
29889,
1359,
29898,
9507,
29892,
27236,
29922,
11249,
29918,
10492,
29892,
1601,
29877,
29922,
5574,
29897,
13,
1678,
10348,
353,
10348,
29889,
690,
14443,
6278,
29896,
29892,
29871,
29896,
29897,
13,
1678,
736,
10348,
29892,
10422,
13,
13,
13,
1753,
2254,
29918,
19206,
29918,
18494,
29898,
5325,
29892,
4559,
29918,
10492,
1125,
13,
1678,
363,
10422,
297,
2066,
29901,
13,
4706,
10348,
29892,
10422,
353,
1303,
29918,
18494,
29918,
3166,
29918,
9507,
29898,
9507,
29892,
4559,
29918,
10492,
29897,
13,
4706,
7709,
10348,
29892,
10422,
13,
13,
13,
1753,
2254,
29918,
29894,
312,
29895,
29918,
18494,
29898,
12322,
29892,
4559,
29918,
10492,
1125,
13,
1678,
9995,
21575,
393,
17498,
10348,
10742,
9514,
515,
278,
478,
1783,
29968,
8783,
29892,
322,
13,
1678,
6124,
635,
278,
3553,
310,
278,
6590,
25657,
1213,
15945,
13,
1678,
2066,
353,
1284,
29918,
5325,
29898,
12322,
29897,
13,
1678,
25657,
29918,
276,
353,
337,
29889,
12198,
29898,
29878,
29915,
29886,
4197,
29900,
29899,
29929,
10062,
20344,
4197,
29900,
29899,
29929,
10062,
2144,
29889,
29893,
485,
1495,
13,
1678,
363,
10422,
297,
2066,
29901,
13,
4706,
10348,
29892,
903,
353,
4303,
1883,
29874,
29889,
1359,
29898,
9507,
29892,
27236,
29922,
11249,
29918,
10492,
29892,
1601,
29877,
29922,
5574,
29897,
13,
4706,
10348,
353,
10348,
29889,
690,
14443,
6278,
29896,
29892,
29871,
29896,
29897,
13,
4706,
7087,
353,
25657,
29918,
276,
29889,
2886,
497,
29898,
9507,
9601,
29900,
29962,
13,
4706,
25657,
29918,
333,
29892,
16867,
29918,
333,
353,
518,
524,
29898,
333,
19925,
363,
1178,
29918,
297,
7087,
29962,
13,
4706,
7709,
10348,
29892,
25657,
29918,
333,
13,
13,
13,
1753,
25457,
29898,
29802,
29896,
29892,
6047,
29906,
29892,
25457,
29918,
2848,
29892,
13,
9651,
10366,
29922,
29456,
15836,
914,
29889,
1202,
29918,
1050,
914,
29892,
13,
9651,
758,
29918,
14634,
29918,
26482,
29922,
6572,
15836,
479,
18689,
29889,
29878,
1160,
1125,
13,
1678,
13128,
353,
7442,
29889,
2378,
29898,
29802,
29896,
29897,
13,
1678,
301,
29896,
353,
7431,
29898,
29802,
29896,
29897,
13,
1678,
301,
29906,
353,
7431,
29898,
29802,
29906,
29897,
13,
1678,
396,
1596,
877,
976,
301,
29896,
353,
24335,
301,
29906,
353,
6571,
4286,
4830,
29898,
29880,
29896,
29892,
301,
29906,
876,
13,
1678,
565,
25457,
29918,
2848,
6736,
301,
29896,
322,
25457,
29918,
2848,
6736,
301,
29906,
29901,
13,
4706,
25457,
29918,
2848,
353,
1375,
29898,
29880,
29896,
29892,
301,
29906,
29897,
13,
1678,
25342,
25457,
29918,
2848,
6736,
301,
29906,
29901,
13,
4706,
25457,
29918,
2848,
353,
301,
29906,
13,
1678,
25342,
25457,
29918,
2848,
6736,
301,
29896,
29901,
13,
4706,
25457,
29918,
2848,
353,
301,
29896,
13,
1678,
25457,
29918,
29896,
29892,
25457,
29918,
29906,
353,
758,
29918,
14634,
29918,
26482,
29898,
7050,
14352,
957,
6984,
29918,
2848,
29901,
1402,
6047,
29906,
7503,
957,
6984,
29918,
2848,
2314,
13,
1678,
25457,
29918,
1595,
353,
10366,
29898,
957,
6984,
29918,
29896,
29892,
25457,
29918,
29906,
29897,
13,
1678,
4974,
7431,
29898,
957,
6984,
29918,
1595,
29897,
1275,
25457,
29918,
2848,
13,
1678,
4974,
7442,
29889,
3317,
29898,
957,
6984,
29918,
1595,
29897,
5277,
29871,
29896,
29889,
29900,
13,
1678,
4974,
7442,
29889,
1195,
29898,
957,
6984,
29918,
1595,
29897,
6736,
448,
29896,
29889,
29900,
13,
1678,
13128,
14352,
957,
6984,
29918,
2848,
17531,
353,
25457,
29918,
1595,
13,
1678,
714,
353,
7442,
29889,
535,
29883,
2579,
403,
3552,
7050,
29892,
6047,
29906,
29961,
957,
6984,
29918,
2848,
29901,
12622,
13,
1678,
4974,
7431,
29898,
449,
29897,
1275,
301,
29896,
718,
301,
29906,
448,
25457,
29918,
2848,
13,
1678,
714,
353,
7442,
29889,
24049,
29898,
449,
29892,
448,
29896,
29892,
29871,
29896,
29897,
13,
1678,
7145,
29918,
957,
6984,
29918,
3149,
29918,
10289,
353,
938,
29898,
29880,
29896,
29897,
13,
1678,
396,
7145,
29918,
957,
6984,
29918,
3149,
29918,
10289,
353,
938,
29898,
29880,
29896,
448,
25457,
29918,
2848,
334,
29871,
29900,
29889,
29945,
29897,
13,
1678,
736,
714,
29892,
7145,
29918,
957,
6984,
29918,
3149,
29918,
10289,
13,
13,
13,
1753,
17151,
29918,
25590,
663,
29898,
18494,
29892,
16897,
1125,
13,
1678,
9995,
7301,
586,
267,
15142,
472,
278,
6763,
322,
1095,
310,
263,
4559,
1213,
15945,
13,
1678,
5864,
353,
4303,
1883,
29874,
29889,
14394,
29889,
1758,
344,
29898,
18494,
29897,
13,
1678,
16608,
353,
7442,
29889,
5464,
9171,
29898,
9302,
29889,
2378,
29898,
27548,
1405,
16897,
876,
13,
1678,
16285,
353,
4303,
1883,
29874,
29889,
3221,
29889,
19935,
29918,
517,
29918,
27736,
29898,
19935,
9601,
29896,
29962,
13,
13,
1678,
396,
3940,
29901,
16285,
508,
367,
385,
4069,
1409,
29892,
565,
278,
3353,
10348,
471,
15142,
29889,
13,
1678,
10348,
29918,
15450,
353,
10348,
29961,
29900,
29901,
29900,
29962,
13,
1678,
2175,
29918,
19465,
353,
10348,
29961,
29900,
29901,
29900,
29962,
13,
1678,
1492,
29918,
19465,
353,
10348,
29961,
29900,
29901,
29900,
29962,
13,
1678,
565,
16285,
29889,
2311,
29901,
13,
4706,
10348,
29918,
15450,
353,
10348,
29961,
513,
1575,
29961,
29900,
5387,
513,
1575,
14352,
29896,
5262,
13,
4706,
2175,
29918,
19465,
353,
10348,
7503,
513,
1575,
29961,
29900,
5262,
29871,
396,
22780,
1434,
29889,
13,
4706,
1492,
29918,
19465,
353,
10348,
29961,
513,
1575,
14352,
29896,
5387,
29962,
29871,
396,
22780,
1156,
29889,
13,
1678,
736,
10348,
29918,
15450,
29892,
2175,
29918,
19465,
29892,
1492,
29918,
19465,
13,
13,
13,
1753,
6597,
29918,
5965,
5790,
29918,
333,
29898,
9507,
1125,
13,
1678,
736,
10422,
29889,
5451,
11219,
1495,
14352,
29906,
29962,
13,
13,
13,
1753,
6597,
29918,
18616,
663,
29918,
333,
29898,
9507,
1125,
13,
1678,
736,
10422,
29889,
5451,
11219,
1495,
14352,
29896,
1822,
5451,
877,
29918,
29861,
29896,
1822,
5451,
12839,
29861,
29900,
29962,
13,
13,
13,
1990,
21764,
6982,
29898,
3318,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13,
462,
10348,
29918,
3972,
29892,
13,
462,
4559,
29918,
10492,
29892,
13,
462,
7726,
414,
29918,
1491,
29918,
1761,
29922,
8516,
1125,
13,
4706,
1583,
29889,
18494,
29918,
3972,
353,
2897,
29889,
2084,
29889,
18837,
1792,
29898,
18494,
29918,
3972,
29897,
29871,
396,
363,
278,
3695,
29914,
13,
4706,
1583,
29889,
11249,
29918,
10492,
353,
4559,
29918,
10492,
13,
4706,
1583,
29889,
19635,
353,
9657,
580,
29871,
396,
2319,
7090,
529,
29903,
4162,
22311,
1001,
29918,
1367,
1599,
317,
3919,
1430,
4741,
29918,
1367,
29892,
10422,
29958,
13,
4706,
1583,
29889,
8173,
353,
9657,
580,
29871,
396,
4802,
7090,
529,
9507,
29892,
848,
29901,
18494,
4303,
1883,
29874,
29892,
1999,
1331,
29889,
29958,
13,
13,
4706,
17927,
29889,
8382,
877,
15514,
5281,
21764,
6982,
580,
1495,
13,
4706,
17927,
29889,
8382,
877,
18494,
29918,
3972,
353,
6571,
4286,
4830,
29898,
1311,
29889,
18494,
29918,
3972,
876,
13,
4706,
17927,
29889,
8382,
877,
11249,
29918,
10492,
353,
6571,
4286,
4830,
29898,
11249,
29918,
10492,
876,
13,
4706,
17927,
29889,
8382,
877,
5965,
21079,
29918,
1491,
29918,
1761,
353,
6571,
4286,
4830,
29898,
5965,
21079,
29918,
1491,
29918,
1761,
876,
13,
13,
4706,
380,
353,
931,
580,
13,
4706,
565,
7431,
29898,
2886,
29918,
5325,
29898,
29911,
3580,
29918,
9464,
29892,
4766,
2433,
10521,
29886,
6321,
8785,
1275,
29871,
29900,
29901,
29871,
396,
5706,
599,
278,
5839,
280,
2066,
29889,
13,
9651,
17927,
29889,
8382,
877,
26521,
1476,
472,
426,
1836,
3251,
1218,
599,
278,
274,
14520,
1286,
29889,
4286,
4830,
29898,
29911,
3580,
29918,
9464,
876,
13,
9651,
2066,
353,
1284,
29918,
5325,
29898,
1311,
29889,
18494,
29918,
3972,
29897,
13,
9651,
4974,
7431,
29898,
5325,
29897,
2804,
29871,
29900,
29892,
525,
5631,
403,
596,
7090,
3113,
6169,
13,
9651,
17927,
29889,
8382,
877,
9692,
6571,
2066,
297,
3001,
297,
426,
1836,
4286,
4830,
29898,
2435,
29898,
5325,
511,
1583,
29889,
18494,
29918,
3972,
876,
13,
9651,
565,
7726,
414,
29918,
1491,
29918,
1761,
338,
451,
6213,
29901,
13,
18884,
2066,
353,
1051,
29898,
13,
462,
1678,
4175,
29898,
2892,
921,
29901,
738,
29898,
1742,
297,
6597,
29918,
5965,
5790,
29918,
333,
29898,
29916,
29897,
363,
1734,
297,
7726,
414,
29918,
1491,
29918,
1761,
511,
2066,
876,
13,
18884,
17927,
29889,
8382,
877,
8875,
2066,
3928,
304,
278,
25657,
1051,
426,
1836,
4286,
4830,
29898,
2435,
29898,
5325,
511,
7726,
414,
29918,
1491,
29918,
1761,
876,
13,
9651,
4974,
7431,
29898,
5325,
29897,
2804,
29871,
29900,
13,
13,
9651,
2594,
353,
260,
29939,
18933,
29898,
5325,
29897,
13,
9651,
363,
10422,
297,
2594,
29901,
13,
18884,
2594,
29889,
842,
29918,
8216,
29898,
9507,
29897,
13,
18884,
1018,
29901,
13,
462,
1678,
25657,
29918,
333,
353,
6597,
29918,
5965,
5790,
29918,
333,
29898,
9507,
29897,
13,
462,
1678,
10348,
29892,
903,
353,
1303,
29918,
18494,
29918,
3166,
29918,
9507,
29898,
9507,
29892,
1583,
29889,
11249,
29918,
10492,
29897,
13,
462,
1678,
5864,
353,
7442,
29889,
6897,
29898,
18494,
7503,
29892,
29871,
29900,
2314,
13,
462,
1678,
15142,
29918,
386,
12268,
353,
7442,
29889,
25376,
488,
29898,
27548,
29892,
29871,
29929,
29945,
29897,
13,
462,
1678,
1283,
7224,
353,
7442,
29889,
3062,
29898,
27548,
1405,
15142,
29918,
386,
12268,
9601,
29900,
29962,
13,
462,
1678,
2175,
29918,
19465,
29918,
19708,
29918,
1516,
353,
313,
29896,
29900,
29900,
29900,
29889,
29900,
334,
1283,
7224,
29961,
29900,
2314,
849,
1583,
29889,
11249,
29918,
10492,
29871,
396,
3515,
29918,
333,
304,
14385,
313,
1516,
29897,
13,
462,
1678,
1492,
29918,
19465,
29918,
19708,
29918,
1516,
353,
313,
29896,
29900,
29900,
29900,
29889,
29900,
334,
313,
2435,
29898,
18494,
29897,
448,
1283,
7224,
14352,
29896,
12622,
849,
1583,
29889,
11249,
29918,
10492,
13,
462,
1678,
396,
17117,
2175,
29918,
19465,
29892,
1492,
29918,
19465,
353,
17151,
29918,
25590,
663,
29898,
18494,
7503,
29892,
29871,
29900,
1402,
15142,
29918,
386,
12268,
29897,
13,
462,
1678,
17927,
29889,
3888,
877,
29918,
29915,
334,
29871,
29896,
29900,
29900,
29897,
13,
462,
1678,
17927,
29889,
3888,
877,
1563,
29918,
19465,
29918,
19708,
29918,
1516,
353,
24335,
1492,
29918,
19465,
29918,
19708,
29918,
1516,
353,
24335,
525,
13,
462,
18884,
525,
18494,
29918,
2848,
353,
6571,
16608,
29892,
15142,
29918,
386,
12268,
353,
6571,
4286,
4830,
29898,
1563,
29918,
19465,
29918,
19708,
29918,
1516,
29892,
13,
462,
462,
462,
462,
462,
3986,
1492,
29918,
19465,
29918,
19708,
29918,
1516,
29892,
13,
462,
462,
462,
462,
462,
3986,
7431,
29898,
18494,
511,
13,
462,
462,
462,
462,
462,
3986,
15142,
29918,
386,
12268,
876,
13,
462,
1678,
5446,
353,
11117,
18494,
2396,
10348,
29892,
13,
462,
965,
525,
18494,
29918,
14917,
29918,
6194,
2396,
10348,
29961,
2696,
7224,
29961,
29900,
5387,
2696,
7224,
14352,
29896,
20526,
13,
462,
965,
525,
1563,
29918,
19465,
29918,
19708,
29918,
1516,
2396,
2175,
29918,
19465,
29918,
19708,
29918,
1516,
29892,
13,
462,
965,
525,
1266,
29918,
19465,
29918,
19708,
29918,
1516,
2396,
1492,
29918,
19465,
29918,
19708,
29918,
1516,
29892,
13,
462,
965,
24080,
5813,
29901,
10422,
29913,
13,
462,
1678,
7090,
29918,
9507,
353,
10422,
29889,
5451,
11219,
1495,
14352,
29896,
1822,
5451,
12839,
29861,
29900,
29962,
718,
22868,
8173,
29915,
13,
462,
1678,
13128,
29918,
9507,
353,
2897,
29889,
2084,
29889,
7122,
29898,
29911,
3580,
29918,
9464,
29892,
7090,
29918,
9507,
29897,
718,
15300,
29886,
6321,
29915,
13,
462,
1678,
411,
1722,
29898,
7050,
29918,
9507,
29892,
525,
29893,
29890,
1495,
408,
285,
29901,
13,
462,
4706,
270,
453,
29889,
15070,
29898,
5415,
29892,
285,
29897,
13,
462,
4706,
17927,
29889,
8382,
877,
29961,
14849,
3580,
319,
29965,
4571,
29949,
29962,
6571,
4286,
4830,
29898,
7050,
29918,
9507,
876,
13,
462,
1678,
396,
9063,
304,
15562,
8600,
746,
366,
29915,
276,
1854,
694,
4436,
10761,
2645,
9068,
29889,
13,
462,
1678,
565,
25657,
29918,
333,
451,
297,
1583,
29889,
19635,
29901,
13,
462,
4706,
1583,
29889,
19635,
29961,
5965,
5790,
29918,
333,
29962,
353,
6571,
13,
462,
1678,
10541,
29918,
333,
353,
6597,
29918,
18616,
663,
29918,
333,
29898,
9507,
29897,
13,
462,
1678,
565,
10541,
29918,
333,
451,
297,
1583,
29889,
19635,
29961,
5965,
5790,
29918,
333,
5387,
13,
462,
4706,
1583,
29889,
19635,
29961,
5965,
5790,
29918,
333,
3816,
18616,
663,
29918,
333,
29962,
353,
5159,
13,
462,
1678,
1583,
29889,
19635,
29961,
5965,
5790,
29918,
333,
3816,
18616,
663,
29918,
333,
29962,
353,
426,
29903,
4162,
22311,
1001,
29918,
1367,
29901,
25657,
29918,
333,
29892,
13,
462,
462,
462,
795,
317,
3919,
1430,
4741,
29918,
1367,
29901,
10541,
29918,
333,
29892,
13,
462,
462,
462,
795,
24080,
5813,
29901,
10422,
29913,
13,
18884,
5174,
4303,
1883,
29874,
29889,
4422,
29889,
11739,
29879,
29889,
9329,
2392,
408,
321,
29901,
13,
462,
1678,
17927,
29889,
2704,
29898,
29872,
29897,
13,
462,
1678,
17927,
29889,
2704,
877,
29961,
14849,
3580,
319,
29965,
4571,
29949,
14431,
18581,
5690,
29925,
4214,
24080,
5813,
29962,
6571,
4286,
4830,
29898,
9507,
876,
13,
9651,
270,
453,
29889,
15070,
29898,
1311,
29889,
19635,
29892,
1722,
29898,
359,
29889,
2084,
29889,
7122,
29898,
29911,
3580,
29918,
9464,
29892,
525,
19635,
29889,
29886,
6321,
5477,
525,
29893,
29890,
8785,
13,
13,
4706,
17927,
29889,
8382,
29898,
13,
9651,
525,
15156,
278,
5759,
2066,
472,
426,
1836,
5293,
963,
304,
2254,
278,
7090,
29889,
1522,
1854,
304,
505,
3307,
3370,
29889,
4286,
4830,
29898,
13,
18884,
323,
3580,
29918,
9464,
876,
13,
4706,
1583,
29889,
19635,
353,
270,
453,
29889,
1359,
29898,
3150,
29898,
359,
29889,
2084,
29889,
7122,
29898,
29911,
3580,
29918,
9464,
29892,
525,
19635,
29889,
29886,
6321,
5477,
525,
6050,
8785,
13,
13,
4706,
5839,
280,
29918,
5325,
353,
1284,
29918,
5325,
29898,
29911,
3580,
29918,
9464,
29892,
4766,
2433,
10521,
29886,
6321,
1495,
13,
4706,
363,
282,
6321,
29918,
1445,
297,
260,
29939,
18933,
29898,
23945,
280,
29918,
5325,
29892,
5153,
2433,
19715,
7090,
29374,
13,
9651,
565,
525,
19635,
29915,
451,
297,
282,
6321,
29918,
1445,
29901,
13,
18884,
411,
1722,
29898,
29886,
6321,
29918,
1445,
29892,
525,
6050,
1495,
408,
285,
29901,
13,
462,
1678,
5446,
353,
270,
453,
29889,
1359,
29898,
29888,
29897,
13,
462,
1678,
1583,
29889,
8173,
29961,
5415,
29961,
7724,
5813,
5262,
353,
5446,
13,
4706,
17927,
29889,
8382,
877,
10408,
3614,
426,
29900,
29901,
29889,
29906,
29888,
29913,
6923,
304,
2254,
29889,
426,
29896,
3854,
6611,
29889,
4286,
4830,
29898,
2230,
580,
448,
380,
29892,
7431,
29898,
1311,
29889,
8173,
4961,
13,
13,
1678,
822,
679,
29918,
5965,
5790,
29918,
1761,
29898,
1311,
1125,
13,
4706,
736,
12705,
29898,
1761,
29898,
1311,
29889,
19635,
29889,
8149,
22130,
13,
13,
1678,
822,
4559,
29918,
5965,
21079,
29898,
1311,
29892,
25657,
29918,
1761,
29892,
954,
29918,
5965,
21079,
1125,
13,
4706,
565,
25657,
29918,
1761,
338,
6213,
29901,
13,
9651,
25657,
29918,
1761,
353,
1583,
29889,
657,
29918,
5965,
5790,
29918,
1761,
580,
13,
4706,
599,
29918,
5965,
21079,
353,
1051,
29898,
5965,
5790,
29918,
1761,
29897,
13,
4706,
528,
21897,
29898,
497,
29918,
5965,
21079,
29897,
13,
4706,
25657,
29918,
1761,
353,
599,
29918,
5965,
21079,
29961,
29900,
29901,
1949,
29918,
5965,
21079,
29962,
13,
4706,
736,
25657,
29918,
1761,
13,
13,
1678,
822,
4529,
29918,
8172,
29918,
28084,
29898,
1311,
29892,
954,
29918,
18616,
2063,
29922,
29941,
29892,
954,
29918,
5965,
21079,
29922,
29941,
29892,
25657,
29918,
4841,
29918,
517,
29918,
21803,
29918,
3166,
29922,
8516,
1125,
13,
4706,
25657,
29918,
4841,
29918,
517,
29918,
21803,
29918,
3166,
353,
1583,
29889,
11249,
29918,
5965,
21079,
29898,
5965,
5790,
29918,
4841,
29918,
517,
29918,
21803,
29918,
3166,
29892,
954,
29918,
5965,
21079,
29897,
13,
4706,
22525,
353,
5159,
13,
4706,
363,
474,
297,
3464,
29898,
1949,
29918,
18616,
2063,
1125,
13,
9651,
25657,
29918,
333,
353,
7348,
29898,
5965,
5790,
29918,
4841,
29918,
517,
29918,
21803,
29918,
3166,
29897,
13,
9651,
10541,
29918,
333,
353,
7348,
29898,
1761,
29898,
1311,
29889,
19635,
29961,
5965,
5790,
29918,
333,
1822,
8149,
22130,
13,
9651,
22525,
29889,
4397,
3319,
29903,
4162,
22311,
1001,
29918,
1367,
29901,
25657,
29918,
333,
29892,
13,
462,
9651,
317,
3919,
1430,
4741,
29918,
1367,
29901,
10541,
29918,
333,
29892,
13,
462,
9651,
24080,
5813,
29901,
1583,
29889,
19635,
29961,
5965,
5790,
29918,
333,
3816,
18616,
663,
29918,
333,
22322,
9507,
2033,
1800,
13,
4706,
736,
22525,
13,
13,
1678,
822,
4529,
29918,
28084,
29898,
1311,
29892,
6837,
29918,
16506,
1125,
13,
4706,
22525,
353,
5159,
13,
4706,
363,
25657,
29918,
18616,
663,
29918,
333,
297,
6837,
29918,
16506,
29901,
13,
9651,
25657,
29918,
333,
29892,
10541,
29918,
333,
353,
25657,
29918,
18616,
663,
29918,
333,
13,
13,
9651,
565,
338,
8758,
29898,
5965,
5790,
29918,
333,
29892,
938,
1125,
13,
18884,
25657,
29918,
333,
353,
525,
29886,
29915,
718,
851,
29898,
5965,
5790,
29918,
333,
29897,
13,
9651,
565,
338,
8758,
29898,
18616,
663,
29918,
333,
29892,
938,
1125,
13,
18884,
10541,
29918,
333,
353,
851,
29898,
18616,
663,
29918,
333,
467,
29920,
5589,
29898,
29941,
29897,
13,
13,
9651,
22525,
29889,
4397,
3319,
29903,
4162,
22311,
1001,
29918,
1367,
29901,
25657,
29918,
333,
29892,
13,
462,
9651,
317,
3919,
1430,
4741,
29918,
1367,
29901,
10541,
29918,
333,
29892,
13,
462,
9651,
24080,
5813,
29901,
1583,
29889,
19635,
29961,
5965,
5790,
29918,
333,
3816,
18616,
663,
29918,
333,
22322,
9507,
2033,
1800,
13,
4706,
736,
22525,
13,
13,
1678,
822,
5706,
29918,
28084,
29918,
2541,
29918,
14917,
29918,
6194,
29898,
1311,
29892,
22525,
1125,
13,
4706,
565,
7431,
29898,
5182,
29879,
29897,
1275,
29871,
29900,
29901,
13,
9651,
736,
19997,
6213,
13,
4706,
10348,
29918,
8977,
353,
6571,
13,
4706,
363,
474,
29892,
3646,
297,
26985,
29898,
5182,
29879,
1125,
13,
9651,
10348,
29918,
8977,
29961,
29875,
29962,
353,
1583,
29889,
8173,
29961,
5182,
29961,
7724,
5813,
5262,
13,
4706,
1962,
353,
10348,
29918,
8977,
29961,
29900,
22322,
18494,
29918,
14917,
29918,
6194,
2033,
13,
4706,
22525,
29961,
29900,
22322,
10289,
2033,
353,
29871,
29900,
29871,
396,
297,
10887,
13,
4706,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
5182,
29879,
22164,
13,
9651,
9210,
29918,
1066,
353,
448,
29896,
13,
9651,
1812,
353,
22525,
29961,
29875,
448,
29871,
29896,
22322,
10289,
2033,
13,
9651,
1550,
9210,
29918,
1066,
5277,
1812,
29901,
13,
18884,
9210,
29918,
1066,
353,
7431,
29898,
4905,
29897,
13,
18884,
1962,
353,
7442,
29889,
535,
29883,
2579,
403,
3552,
4905,
29892,
10348,
29918,
8977,
29961,
29875,
22322,
18494,
29918,
14917,
29918,
6194,
25901,
13,
18884,
22525,
29961,
29875,
22322,
10289,
2033,
353,
9210,
29918,
1066,
13,
4706,
736,
22525,
29892,
1962,
13,
13,
1678,
822,
5706,
29918,
28084,
29898,
1311,
29892,
22525,
1125,
13,
4706,
10348,
29918,
8977,
353,
6571,
13,
4706,
363,
474,
29892,
3646,
297,
26985,
29898,
5182,
29879,
1125,
13,
9651,
10348,
29918,
8977,
29961,
29875,
29962,
353,
1583,
29889,
8173,
29961,
5182,
29961,
7724,
5813,
5262,
13,
13,
4706,
1962,
353,
10348,
29918,
8977,
29961,
29900,
22322,
18494,
2033,
13,
4706,
22525,
29961,
29900,
22322,
10289,
2033,
353,
29871,
29900,
29871,
396,
297,
10887,
13,
4706,
363,
474,
297,
3464,
29898,
29896,
29892,
7431,
29898,
5182,
29879,
22164,
13,
9651,
396,
1342,
29901,
6047,
29871,
29896,
448,
29871,
29953,
29900,
29900,
10887,
472,
278,
1095,
29889,
13,
9651,
1411,
29918,
1266,
29918,
19465,
29918,
29896,
353,
10348,
29918,
8977,
29961,
29875,
448,
29871,
29896,
22322,
1266,
29918,
19465,
29918,
19708,
29918,
1516,
2033,
13,
9651,
396,
1342,
29901,
6047,
29871,
29906,
448,
29871,
29906,
29945,
10887,
472,
278,
6763,
313,
1454,
15142,
467,
13,
9651,
1411,
29918,
1563,
29918,
19465,
29918,
29906,
353,
10348,
29918,
8977,
29961,
29875,
22322,
1563,
29918,
19465,
29918,
19708,
29918,
1516,
2033,
13,
9651,
9654,
29918,
19708,
29918,
1516,
353,
938,
29898,
29881,
332,
29918,
1266,
29918,
19465,
29918,
29896,
718,
1411,
29918,
1563,
29918,
19465,
29918,
29906,
29897,
13,
9651,
396,
1342,
29901,
4559,
515,
501,
29961,
29896,
29892,
29871,
29953,
29900,
29900,
29974,
29906,
29945,
1516,
29962,
29871,
29896,
322,
451,
29871,
29900,
1363,
6467,
591,
505,
263,
8267,
1059,
29889,
13,
9651,
396,
7865,
2392,
29901,
1751,
4167,
1033,
451,
367,
12672,
4208,
411,
25834,
313,
29955,
29906,
29941,
29953,
29941,
29929,
29892,
29896,
29897,
313,
29900,
29892,
29896,
29897,
13,
13,
9651,
9210,
29918,
1066,
353,
448,
29896,
13,
9651,
1812,
353,
22525,
29961,
29875,
448,
29871,
29896,
22322,
10289,
2033,
13,
9651,
1550,
9210,
29918,
1066,
5277,
1812,
29901,
13,
18884,
396,
1596,
877,
976,
9773,
584,
6571,
4286,
4830,
29898,
18494,
29918,
8977,
29961,
29875,
3816,
7724,
5813,
12622,
13,
18884,
565,
9654,
29918,
19708,
29918,
1516,
5277,
29871,
29896,
29901,
13,
462,
1678,
20088,
29918,
791,
353,
29871,
29896,
13,
18884,
1683,
29901,
13,
462,
1678,
20088,
29918,
791,
353,
938,
29898,
9502,
524,
29898,
29896,
29892,
9654,
29918,
19708,
29918,
1516,
29897,
334,
29871,
29900,
29889,
29947,
29897,
718,
29871,
29896,
13,
18884,
396,
1596,
877,
976,
15974,
6525,
5759,
515,
501,
29961,
29896,
29892,
29912,
6525,
4286,
4830,
29898,
9502,
29918,
791,
29892,
9654,
29918,
19708,
29918,
1516,
876,
13,
18884,
1962,
29892,
9210,
29918,
1066,
353,
25457,
29898,
4905,
29892,
10348,
29918,
8977,
29961,
29875,
22322,
18494,
7464,
20088,
29918,
791,
29897,
13,
18884,
22525,
29961,
29875,
22322,
10289,
2033,
353,
9210,
29918,
1066,
13,
13,
18884,
396,
1596,
29898,
28060,
29897,
13,
18884,
396,
1596,
29898,
10289,
29918,
1066,
29897,
13,
18884,
396,
1596,
877,
22359,
1495,
13,
18884,
396,
4303,
1883,
29874,
29889,
4905,
29889,
3539,
29918,
29893,
485,
877,
29873,
3747,
648,
1836,
29893,
485,
4286,
4830,
29898,
29875,
511,
1962,
29961,
28060,
29901,
10289,
29918,
1066,
1402,
27236,
29922,
1311,
29889,
11249,
29918,
10492,
29897,
13,
13,
4706,
396,
4303,
1883,
29874,
29889,
4905,
29889,
3539,
29918,
29893,
485,
877,
29873,
3747,
29889,
29893,
485,
742,
1962,
29892,
27236,
29922,
1311,
29889,
11249,
29918,
10492,
29897,
13,
4706,
396,
1596,
877,
9040,
3309,
353,
6571,
4286,
4830,
29898,
2435,
29898,
4905,
4961,
13,
4706,
396,
282,
2158,
29889,
407,
29878,
524,
29898,
5182,
29879,
29897,
13,
4706,
736,
22525,
29892,
1962,
13,
2
] |
scripts/plot.py | dfvella/vtol | 0 | 47069 | <reponame>dfvella/vtol
#!/usr/bin/env python3
import sys
import matplotlib.pyplot as plt
try:
filename = sys.argv[1]
except IndexError:
print('error: data file not specified')
exit(1)
#response = [ 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 ]
#response = [ 0.2, 0.2, 0.2, 0.2, 0.1, 0.05, 0.02, 0.02, 0.01, 0.0 ]
#response = [ 0.4, 0.3, 0.2, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] # delay <20 ms
response = [ 0.3, 0.3, 0.2, 0.2, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] # delay ~25 ms
buffer = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
assert(abs(sum(response) - 1) < 0.001)
assert(len(response) == len(buffer))
def filter(data: float, buff: list, resp: list) -> float:
buff.insert(0, data)
buff.pop()
res = 0
for data, weight in zip(buff, resp):
res += data * weight
return res
tList = []
xList = []
dList = []
fList = []
with open(filename, 'r') as f:
for line in f:
try:
t, x = line.split()
except TypeError:
print('error: failed to parse line')
exit(1)
if len(tList) > 1:
d = (xList[-1] - xList[-2]) / (tList[-1] - tList[-2])
else:
d = 0
tList.append(float(t))
xList.append(float(x))
dList.append(float(d))
fList.append(float(filter(d, buffer, response)))
plt.plot(tList, xList, label='x')
plt.plot(tList, dList, label='dx/dt')
plt.plot(tList, fList, label='filtered')
plt.title(filename)
plt.ylabel('x')
plt.xlabel('t')
plt.legend()
plt.show()
| [
1,
529,
276,
1112,
420,
29958,
2176,
955,
433,
29914,
21908,
324,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
29941,
13,
13,
5215,
10876,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
13,
2202,
29901,
13,
1678,
10422,
353,
10876,
29889,
19218,
29961,
29896,
29962,
13,
19499,
11374,
2392,
29901,
13,
1678,
1596,
877,
2704,
29901,
848,
934,
451,
6790,
1495,
13,
1678,
6876,
29898,
29896,
29897,
13,
13,
13,
29937,
5327,
353,
518,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29896,
4514,
13,
29937,
5327,
353,
518,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29900,
29945,
29892,
29871,
29900,
29889,
29900,
29906,
29892,
29871,
29900,
29889,
29900,
29906,
29892,
29871,
29900,
29889,
29900,
29896,
29892,
29871,
29900,
29889,
29900,
4514,
13,
29937,
5327,
353,
518,
29871,
29900,
29889,
29946,
29892,
29871,
29900,
29889,
29941,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29896,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
4514,
396,
9055,
529,
29906,
29900,
10887,
13,
5327,
353,
518,
29871,
29900,
29889,
29941,
29892,
29871,
29900,
29889,
29941,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29906,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
4514,
396,
9055,
3695,
29906,
29945,
10887,
13,
9040,
353,
518,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
29892,
29871,
29900,
29889,
29900,
4514,
13,
13,
9294,
29898,
6897,
29898,
2083,
29898,
5327,
29897,
448,
29871,
29896,
29897,
529,
29871,
29900,
29889,
29900,
29900,
29896,
29897,
13,
9294,
29898,
2435,
29898,
5327,
29897,
1275,
7431,
29898,
9040,
876,
13,
13,
1753,
4175,
29898,
1272,
29901,
5785,
29892,
20487,
29901,
1051,
29892,
4613,
29901,
1051,
29897,
1599,
5785,
29901,
13,
1678,
20487,
29889,
7851,
29898,
29900,
29892,
848,
29897,
13,
1678,
20487,
29889,
7323,
580,
13,
13,
1678,
620,
353,
29871,
29900,
13,
1678,
363,
848,
29892,
7688,
297,
14319,
29898,
28040,
29892,
4613,
1125,
13,
4706,
620,
4619,
848,
334,
7688,
13,
1678,
736,
620,
13,
13,
13,
29873,
1293,
353,
5159,
13,
29916,
1293,
353,
5159,
13,
29881,
1293,
353,
5159,
13,
29888,
1293,
353,
5159,
13,
13,
2541,
1722,
29898,
9507,
29892,
525,
29878,
1495,
408,
285,
29901,
13,
1678,
363,
1196,
297,
285,
29901,
13,
4706,
1018,
29901,
13,
9651,
260,
29892,
921,
353,
1196,
29889,
5451,
580,
13,
4706,
5174,
20948,
29901,
13,
9651,
1596,
877,
2704,
29901,
5229,
304,
6088,
1196,
1495,
13,
9651,
6876,
29898,
29896,
29897,
13,
13,
4706,
565,
7431,
29898,
29873,
1293,
29897,
1405,
29871,
29896,
29901,
13,
9651,
270,
353,
313,
29916,
1293,
14352,
29896,
29962,
448,
921,
1293,
14352,
29906,
2314,
847,
313,
29873,
1293,
14352,
29896,
29962,
448,
260,
1293,
14352,
29906,
2314,
13,
4706,
1683,
29901,
13,
9651,
270,
353,
29871,
29900,
13,
13,
4706,
260,
1293,
29889,
4397,
29898,
7411,
29898,
29873,
876,
13,
4706,
921,
1293,
29889,
4397,
29898,
7411,
29898,
29916,
876,
13,
4706,
270,
1293,
29889,
4397,
29898,
7411,
29898,
29881,
876,
13,
4706,
285,
1293,
29889,
4397,
29898,
7411,
29898,
4572,
29898,
29881,
29892,
6835,
29892,
2933,
4961,
13,
13,
572,
29873,
29889,
5317,
29898,
29873,
1293,
29892,
921,
1293,
29892,
3858,
2433,
29916,
1495,
13,
572,
29873,
29889,
5317,
29898,
29873,
1293,
29892,
270,
1293,
29892,
3858,
2433,
8235,
29914,
6008,
1495,
13,
572,
29873,
29889,
5317,
29898,
29873,
1293,
29892,
285,
1293,
29892,
3858,
2433,
4572,
287,
1495,
13,
572,
29873,
29889,
3257,
29898,
9507,
29897,
13,
572,
29873,
29889,
29891,
1643,
877,
29916,
1495,
13,
572,
29873,
29889,
29916,
1643,
877,
29873,
1495,
13,
572,
29873,
29889,
26172,
580,
13,
572,
29873,
29889,
4294,
580,
13,
2
] |
plugins/modules/tag.py | robertcsapo/dnacenter-ansible | 0 | 90261 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2021, Cisco Systems
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = r"""
---
module: tag
short_description: Manage Tag objects of Tag
description:
- Returns the Tags for given filter criteria.
- Creates Tag with specified Tag attributes.
- Updates a Tag specified by id.
- Deletes a Tag specified by id.
- Returns Tag specified by Id.
- Returns Tag count.
version_added: '1.0.0'
author: <NAME> (@racampos)
options:
additional_info_attributes:
description:
- AdditionalInfo.attributes query parameter.
type: str
additional_info_name_space:
description:
- AdditionalInfo.nameSpace query parameter.
type: str
field:
description:
- Available field names are 'name,id,parentId,type,additionalInfo.nameSpace,additionalInfo.attributes'.
type: str
level:
description:
- Level query parameter.
type: str
limit:
description:
- Limit query parameter.
type: str
name:
description:
- Tag name is mandatory when filter operation is used.
- TagDTO's name.
- Name query parameter.
type: str
offset:
description:
- Offset query parameter.
type: str
order:
description:
- Available values are asc and des.
type: str
size:
description:
- Size in kilobytes(KB).
type: str
sort_by:
description:
- Only supported attribute is name. SortyBy is mandatory when order is used.
type: str
system_tag:
description:
- SystemTag query parameter.
type: str
description:
description:
- TagDTO's description.
type: str
dynamicRules:
description:
- TagDTO's dynamicRules (list of objects).
type: list
elements: dict
suboptions:
memberType:
description:
- It is the Tag's memberType.
type: str
rules:
description:
- It is the Tag's rules.
type: dict
suboptions:
items:
description:
- It is the Tag's items.
type: list
name:
description:
- It is the Tag's name.
type: str
operation:
description:
- It is the Tag's operation.
type: str
value:
description:
- It is the Tag's value.
type: str
values:
description:
- It is the Tag's values.
type: list
id:
description:
- TagDTO's id.
- Tag ID.
- Required for states query and absent.
type: str
instanceTenantId:
description:
- TagDTO's instanceTenantId.
type: str
systemTag:
description:
- TagDTO's systemTag.
type: bool
attribute_name:
description:
- AttributeName query parameter.
type: str
name_space:
description:
- NameSpace query parameter.
type: str
count:
description:
- If true gets the number of objects.
- Required for state query.
type: bool
requirements:
- dnacentersdk
seealso:
# Reference by module name
- module: cisco.dnac.plugins.module_utils.definitions.tag
# Reference by Internet resource
- name: Tag reference
description: Complete reference of the Tag object model.
link: https://developer.cisco.com/docs/dna-center/api/1-3-3-x
# Reference by Internet resource
- name: Tag reference
description: SDK reference.
link: https://dnacentersdk.readthedocs.io/en/latest/api/api.html#v2-1-1-summary
"""
EXAMPLES = r"""
- name: get_tag
cisco.dnac.tag:
state: query # required
additional_info_attributes: SomeValue # string
additional_info_name_space: SomeValue # string
field: SomeValue # string
level: SomeValue # string
limit: SomeValue # string
name: SomeValue # string
offset: SomeValue # string
order: SomeValue # string
size: SomeValue # string
sort_by: SomeValue # string
system_tag: SomeValue # string
register: nm_get_tag
- name: create_tag
cisco.dnac.tag:
state: present # required
description: SomeValue # string
dynamicRules:
- memberType: SomeValue # string
rules:
values:
- SomeValue # string
items: None
operation: SomeValue # string
name: SomeValue # string
value: SomeValue # string
id: SomeValue # string
instanceTenantId: SomeValue # string
name: SomeValue # string
systemTag: True # boolean
- name: update_tag
cisco.dnac.tag:
state: present # required
description: SomeValue # string
dynamicRules:
- memberType: SomeValue # string
rules:
values:
- SomeValue # string
items: None
operation: SomeValue # string
name: SomeValue # string
value: SomeValue # string
id: SomeValue # string
instanceTenantId: SomeValue # string
name: SomeValue # string
systemTag: True # boolean
- name: delete_tag
cisco.dnac.tag:
state: absent # required
id: SomeValue # string, required
- name: get_tag_by_id
cisco.dnac.tag:
state: query # required
id: SomeValue # string, required
register: nm_get_tag_by_id
- name: get_tag_count
cisco.dnac.tag:
state: query # required
count: True # boolean, required
attribute_name: SomeValue # string
level: SomeValue # string
name: SomeValue # string
name_space: SomeValue # string
size: SomeValue # string
system_tag: SomeValue # string
register: nm_get_tag_count
"""
RETURN = r"""
dnac_response:
description: A dictionary with the response returned by the DNA Center Python SDK
returned: always
type: dict
sample: {"response": 29, "version": "1.0"}
sdk_function:
description: The DNA Center SDK function used to execute the task
returned: always
type: str
sample: tag.create_tag
missing_params:
description: Provided arguments do not comply with the schema of the DNA Center Python SDK function
returned: when the function request schema is not satisfied
type: list
sample:
"""
| [
1,
18787,
4855,
29914,
2109,
29914,
4691,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
29937,
14187,
1266,
29901,
313,
29883,
29897,
29871,
29906,
29900,
29906,
29896,
29892,
315,
275,
1111,
23985,
13,
29937,
15143,
4593,
5236,
19245,
325,
29941,
29889,
29900,
29974,
313,
4149,
365,
2965,
1430,
1660,
470,
2045,
597,
1636,
29889,
18713,
29889,
990,
29914,
506,
11259,
29914,
29887,
572,
29899,
29941,
29889,
29900,
29889,
3945,
29897,
13,
13,
28665,
5005,
3919,
8098,
353,
364,
15945,
29908,
13,
5634,
13,
5453,
29901,
4055,
13,
12759,
29918,
8216,
29901,
2315,
482,
10522,
3618,
310,
10522,
13,
8216,
29901,
13,
29899,
16969,
278,
917,
363,
2183,
4175,
16614,
29889,
13,
29899,
6760,
1078,
10522,
411,
6790,
10522,
8393,
29889,
13,
29899,
5020,
15190,
263,
10522,
6790,
491,
1178,
29889,
13,
29899,
897,
1026,
267,
263,
10522,
6790,
491,
1178,
29889,
13,
29899,
16969,
10522,
6790,
491,
5163,
29889,
13,
29899,
16969,
10522,
2302,
29889,
13,
3259,
29918,
23959,
29901,
525,
29896,
29889,
29900,
29889,
29900,
29915,
13,
8921,
29901,
529,
5813,
29958,
20164,
945,
314,
1066,
29897,
13,
6768,
29901,
13,
29871,
5684,
29918,
3888,
29918,
15697,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
3462,
3245,
3401,
29889,
15697,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
5684,
29918,
3888,
29918,
978,
29918,
3493,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
3462,
3245,
3401,
29889,
978,
14936,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
1746,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
7740,
3106,
1746,
2983,
526,
525,
978,
29892,
333,
29892,
3560,
1204,
29892,
1853,
29892,
1202,
3245,
3401,
29889,
978,
14936,
29892,
1202,
3245,
3401,
29889,
15697,
4286,
13,
1678,
1134,
29901,
851,
13,
29871,
3233,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
21597,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
4046,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
9628,
277,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
1024,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
10522,
1024,
338,
9619,
7606,
746,
4175,
5858,
338,
1304,
29889,
13,
1678,
448,
10522,
29928,
4986,
29915,
29879,
1024,
29889,
13,
1678,
448,
4408,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
9210,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
5947,
842,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
1797,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
7740,
3106,
1819,
526,
12066,
322,
553,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
2159,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
21179,
297,
4679,
18711,
2167,
29898,
26067,
467,
13,
1678,
1134,
29901,
851,
13,
29871,
2656,
29918,
1609,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
9333,
6969,
5352,
338,
1024,
29889,
20025,
29891,
2059,
338,
9619,
7606,
746,
1797,
338,
1304,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
1788,
29918,
4039,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
2184,
8176,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
6139,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
10522,
29928,
4986,
29915,
29879,
6139,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
7343,
29934,
2540,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
10522,
29928,
4986,
29915,
29879,
7343,
29934,
2540,
313,
1761,
310,
3618,
467,
13,
1678,
1134,
29901,
1051,
13,
1678,
3161,
29901,
9657,
13,
1678,
1014,
6768,
29901,
13,
418,
4509,
1542,
29901,
13,
4706,
6139,
29901,
13,
4706,
448,
739,
338,
278,
10522,
29915,
29879,
4509,
1542,
29889,
13,
4706,
1134,
29901,
851,
13,
418,
6865,
29901,
13,
4706,
6139,
29901,
13,
4706,
448,
739,
338,
278,
10522,
29915,
29879,
6865,
29889,
13,
4706,
1134,
29901,
9657,
13,
4706,
1014,
6768,
29901,
13,
3986,
4452,
29901,
13,
9651,
6139,
29901,
13,
9651,
448,
739,
338,
278,
10522,
29915,
29879,
4452,
29889,
13,
9651,
1134,
29901,
1051,
13,
3986,
1024,
29901,
13,
9651,
6139,
29901,
13,
9651,
448,
739,
338,
278,
10522,
29915,
29879,
1024,
29889,
13,
9651,
1134,
29901,
851,
13,
3986,
5858,
29901,
13,
9651,
6139,
29901,
13,
9651,
448,
739,
338,
278,
10522,
29915,
29879,
5858,
29889,
13,
9651,
1134,
29901,
851,
13,
3986,
995,
29901,
13,
9651,
6139,
29901,
13,
9651,
448,
739,
338,
278,
10522,
29915,
29879,
995,
29889,
13,
9651,
1134,
29901,
851,
13,
3986,
1819,
29901,
13,
9651,
6139,
29901,
13,
9651,
448,
739,
338,
278,
10522,
29915,
29879,
1819,
29889,
13,
9651,
1134,
29901,
1051,
13,
13,
13,
29871,
1178,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
10522,
29928,
4986,
29915,
29879,
1178,
29889,
13,
1678,
448,
10522,
3553,
29889,
13,
1678,
448,
830,
5958,
363,
5922,
2346,
322,
29207,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
2777,
29911,
27153,
1204,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
10522,
29928,
4986,
29915,
29879,
2777,
29911,
27153,
1204,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
1788,
8176,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
10522,
29928,
4986,
29915,
29879,
1788,
8176,
29889,
13,
1678,
1134,
29901,
6120,
13,
29871,
5352,
29918,
978,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
23833,
1170,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
1024,
29918,
3493,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
4408,
14936,
2346,
3443,
29889,
13,
1678,
1134,
29901,
851,
13,
29871,
2302,
29901,
13,
1678,
6139,
29901,
13,
1678,
448,
960,
1565,
4947,
278,
1353,
310,
3618,
29889,
13,
1678,
448,
830,
5958,
363,
2106,
2346,
29889,
13,
1678,
1134,
29901,
6120,
13,
13,
12277,
1860,
29901,
13,
29899,
270,
29876,
16648,
414,
8181,
13,
4149,
15189,
29901,
13,
29937,
12105,
491,
3883,
1024,
13,
29899,
3883,
29901,
274,
275,
1111,
29889,
5200,
562,
29889,
12800,
29889,
5453,
29918,
13239,
29889,
25476,
2187,
29889,
4039,
13,
29937,
12105,
491,
4685,
6503,
13,
29899,
1024,
29901,
10522,
3407,
13,
29871,
6139,
29901,
25034,
3407,
310,
278,
10522,
1203,
1904,
29889,
13,
29871,
1544,
29901,
2045,
597,
6734,
29889,
3476,
1111,
29889,
510,
29914,
2640,
29914,
29881,
1056,
29899,
5064,
29914,
2754,
29914,
29896,
29899,
29941,
29899,
29941,
29899,
29916,
13,
29937,
12105,
491,
4685,
6503,
13,
29899,
1024,
29901,
10522,
3407,
13,
29871,
6139,
29901,
12967,
3407,
29889,
13,
29871,
1544,
29901,
2045,
597,
5200,
16648,
414,
8181,
29889,
949,
386,
287,
12332,
29889,
601,
29914,
264,
29914,
12333,
29914,
2754,
29914,
2754,
29889,
1420,
29937,
29894,
29906,
29899,
29896,
29899,
29896,
29899,
7727,
13,
15945,
29908,
13,
13,
5746,
19297,
17101,
353,
364,
15945,
29908,
13,
29899,
1024,
29901,
679,
29918,
4039,
13,
29871,
274,
275,
1111,
29889,
5200,
562,
29889,
4039,
29901,
13,
1678,
2106,
29901,
2346,
29871,
396,
3734,
13,
1678,
5684,
29918,
3888,
29918,
15697,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
5684,
29918,
3888,
29918,
978,
29918,
3493,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1746,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
3233,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
4046,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1024,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
9210,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1797,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
2159,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
2656,
29918,
1609,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1788,
29918,
4039,
29901,
3834,
1917,
29871,
396,
1347,
13,
29871,
6036,
29901,
302,
29885,
29918,
657,
29918,
4039,
13,
13,
29899,
1024,
29901,
1653,
29918,
4039,
13,
29871,
274,
275,
1111,
29889,
5200,
562,
29889,
4039,
29901,
13,
1678,
2106,
29901,
2198,
29871,
396,
3734,
13,
1678,
6139,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
7343,
29934,
2540,
29901,
13,
1678,
448,
4509,
1542,
29901,
3834,
1917,
29871,
396,
1347,
13,
418,
6865,
29901,
13,
4706,
1819,
29901,
13,
4706,
448,
3834,
1917,
29871,
396,
1347,
13,
4706,
4452,
29901,
6213,
13,
4706,
5858,
29901,
3834,
1917,
29871,
396,
1347,
13,
4706,
1024,
29901,
3834,
1917,
29871,
396,
1347,
13,
4706,
995,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1178,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
2777,
29911,
27153,
1204,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1024,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1788,
8176,
29901,
5852,
29871,
396,
7223,
13,
13,
29899,
1024,
29901,
2767,
29918,
4039,
13,
29871,
274,
275,
1111,
29889,
5200,
562,
29889,
4039,
29901,
13,
1678,
2106,
29901,
2198,
29871,
396,
3734,
13,
1678,
6139,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
7343,
29934,
2540,
29901,
13,
1678,
448,
4509,
1542,
29901,
3834,
1917,
29871,
396,
1347,
13,
418,
6865,
29901,
13,
4706,
1819,
29901,
13,
4706,
448,
3834,
1917,
29871,
396,
1347,
13,
4706,
4452,
29901,
6213,
13,
4706,
5858,
29901,
3834,
1917,
29871,
396,
1347,
13,
4706,
1024,
29901,
3834,
1917,
29871,
396,
1347,
13,
4706,
995,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1178,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
2777,
29911,
27153,
1204,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1024,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1788,
8176,
29901,
5852,
29871,
396,
7223,
13,
13,
29899,
1024,
29901,
5217,
29918,
4039,
13,
29871,
274,
275,
1111,
29889,
5200,
562,
29889,
4039,
29901,
13,
1678,
2106,
29901,
29207,
29871,
396,
3734,
13,
1678,
1178,
29901,
3834,
1917,
29871,
396,
1347,
29892,
3734,
13,
13,
29899,
1024,
29901,
679,
29918,
4039,
29918,
1609,
29918,
333,
13,
29871,
274,
275,
1111,
29889,
5200,
562,
29889,
4039,
29901,
13,
1678,
2106,
29901,
2346,
29871,
396,
3734,
13,
1678,
1178,
29901,
3834,
1917,
29871,
396,
1347,
29892,
3734,
13,
29871,
6036,
29901,
302,
29885,
29918,
657,
29918,
4039,
29918,
1609,
29918,
333,
13,
13,
29899,
1024,
29901,
679,
29918,
4039,
29918,
2798,
13,
29871,
274,
275,
1111,
29889,
5200,
562,
29889,
4039,
29901,
13,
1678,
2106,
29901,
2346,
29871,
396,
3734,
13,
1678,
2302,
29901,
5852,
29871,
396,
7223,
29892,
3734,
13,
1678,
5352,
29918,
978,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
3233,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1024,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1024,
29918,
3493,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
2159,
29901,
3834,
1917,
29871,
396,
1347,
13,
1678,
1788,
29918,
4039,
29901,
3834,
1917,
29871,
396,
1347,
13,
29871,
6036,
29901,
302,
29885,
29918,
657,
29918,
4039,
29918,
2798,
13,
13,
15945,
29908,
13,
13,
1525,
29911,
24015,
353,
364,
15945,
29908,
13,
5200,
562,
29918,
5327,
29901,
13,
29871,
6139,
29901,
319,
8600,
411,
278,
2933,
4133,
491,
278,
25348,
7817,
5132,
12967,
13,
29871,
4133,
29901,
2337,
13,
29871,
1134,
29901,
9657,
13,
29871,
4559,
29901,
8853,
5327,
1115,
29871,
29906,
29929,
29892,
376,
3259,
1115,
376,
29896,
29889,
29900,
9092,
13,
15348,
29918,
2220,
29901,
13,
29871,
6139,
29901,
450,
25348,
7817,
12967,
740,
1304,
304,
6222,
278,
3414,
13,
29871,
4133,
29901,
2337,
13,
29871,
1134,
29901,
851,
13,
29871,
4559,
29901,
4055,
29889,
3258,
29918,
4039,
13,
27259,
29918,
7529,
29901,
13,
29871,
6139,
29901,
9133,
2618,
6273,
437,
451,
752,
368,
411,
278,
10938,
310,
278,
25348,
7817,
5132,
12967,
740,
13,
29871,
4133,
29901,
746,
278,
740,
2009,
10938,
338,
451,
15787,
13,
29871,
1134,
29901,
1051,
13,
29871,
4559,
29901,
13,
15945,
29908,
13,
2
] |
bin/extract_shared_or_unique_otuids.py | bhawan1/phylotoast | 19 | 1609176 | <filename>bin/extract_shared_or_unique_otuids.py<gh_stars>10-100
#! /usr/bin/env python
"""
Abstract: Get unique OTUIDs present in each category of your dataset.
Date: 06/09/2016
"""
import sys
import argparse
import os.path as osp
from itertools import combinations
from collections import defaultdict
from phylotoast import otu_calc as oc, util
try:
import biom
except ImportError as ie:
sys.exit("Please install missing module: {}.".format(ie))
try:
import pandas as pd
except ImportError as ie:
sys.exit("Please install missing module: {}.".format(ie))
def sample_group(sid, groups):
"""
Iterate through all categories in an OrderedDict and return category name if SampleID
present in that category.
:type sid: str
:param sid: SampleID from dataset.
:type groups: OrderedDict
:param groups: Returned dict from phylotoast.util.gather_categories() function.
:return type: str
:return: Category name used to classify `sid`.
"""
for name in groups:
if sid in groups[name].sids:
return name
def combine_sets(*sets):
"""
Combine multiple sets to create a single larger set.
"""
combined = set()
for s in sets:
combined.update(s)
return combined
def unique_otuids(groups):
"""
Get unique OTUIDs of each category.
:type groups: Dict
:param groups: {Category name: OTUIDs in category}
:return type: dict
:return: Dict keyed on category name and unique OTUIDs as values.
"""
uniques = {key: set() for key in groups}
for i, group in enumerate(groups):
to_combine = groups.values()[:i]+groups.values()[i+1:]
combined = combine_sets(*to_combine)
uniques[group] = groups[group].difference(combined)
return uniques
def shared_otuids(groups):
"""
Get shared OTUIDs between all unique combinations of groups.
:type groups: Dict
:param groups: {Category name: OTUIDs in category}
:return type: dict
:return: Dict keyed on group combination and their shared OTUIDs as values.
"""
for g in sorted(groups):
print("Number of OTUs in {0}: {1}".format(g, len(groups[g].results["otuids"])))
number_of_categories = len(groups)
shared = defaultdict()
for i in range(2, number_of_categories+1):
for j in combinations(sorted(groups), i):
combo_name = " & ".join(list(j))
for grp in j:
# initialize combo values
shared[combo_name] = groups[j[0]].results["otuids"].copy()
"""iterate through all groups and keep updating combo OTUIDs with set
intersection_update"""
for grp in j[1:]:
shared[combo_name].intersection_update(groups[grp].results["otuids"])
return shared
def write_uniques(path, prefix, uniques):
"""
Given a path, the method writes out one file for each group name in the
uniques dictionary with the file name in the pattern
PATH/prefix_group.txt
with each file containing the unique OTUIDs found when comparing that group
to all the other groups in uniques.
:type path: str
:param path: Output files will be saved in this PATH.
:type prefix: str
:param prefix: Prefix name added in front of output filename.
:type uniques: dict
:param uniques: Output from unique_otus() function.
"""
for group in uniques:
fp = osp.join(path, "{}_{}.txt".format(prefix, group))
with open(fp, "w") as outf:
outf.write("\n".join(uniques[group]))
def handle_program_options():
parser = argparse.ArgumentParser(description="Parse a BIOM format file and obtain a "
"list of unique OTUIDs found in each category in "
"mapping file.")
parser.add_argument("input_biom_fp", help="BIOM format file path.")
parser.add_argument("output_dir",
help="Path to save category unique OTUIDs.")
parser.add_argument("mapping_file", help="Mapping file with category information.")
parser.add_argument("category_column", help="Column in mapping file specifying the "
"category/condition of all samples.")
parser.add_argument("-p", "--prefix", default="unique", help="Provide specific text "
"to prepend the output file names. By default, the 'unique' will "
"be added in front of output filenames, for uniques calculations "
"only.")
parser.add_argument("-r", "--reverse",
help="Get shared OTUIDs among all unique combinations of groups "
"and write out the results to path provided to this option.")
return parser.parse_args()
def main():
args = handle_program_options()
try:
# Load biom format file
biomf = biom.load_table(args.input_biom_fp)
except TypeError as te:
sys.exit("The data in the path does not appear to be a BIOM format table. "
"Error: {}.".format(te))
# Determine OTUIDs present in each sample
sample_otus = oc.assign_otu_membership(biomf)
try:
# Parse mapping file
header, imap = util.parse_map_file(args.mapping_file)
except ValueError as ve:
sys.exit("Error: {}.".format(ve))
# Get relevant category information
group_data = util.gather_categories(imap, header, [args.category_column])
# Initialize results dict in group_data with {"otuids": set()} for each category
for group in group_data:
group_data[group].results["otuids"] = set()
# Collect all OTUIDs present in each category
for sid in sample_otus:
group = sample_group(sid, group_data)
group_data[group].results["otuids"].update(sample_otus[sid])
if args.reverse:
# Get shared OTUIDs
shared = shared_otuids(group_data)
# Write out shared OTUIDs results
shared_df = pd.DataFrame.from_dict(shared, orient="index").T
shared_df.to_csv(args.reverse, sep="\t", index=False)
# Create input for unique_otus
group_otuids = {group: group_data[group].results["otuids"] for group in group_data}
# Write out unique OTUIDs to file
write_uniques(args.output_dir, args.prefix, unique_otuids(group_otuids))
if __name__ == "__main__":
sys.exit(main())
| [
1,
529,
9507,
29958,
2109,
29914,
21111,
29918,
12366,
29918,
272,
29918,
13092,
29918,
327,
29884,
4841,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29900,
29899,
29896,
29900,
29900,
13,
29937,
29991,
847,
4855,
29914,
2109,
29914,
6272,
3017,
13,
15945,
29908,
13,
9118,
29901,
3617,
5412,
438,
29911,
11150,
29879,
2198,
297,
1269,
7663,
310,
596,
8783,
29889,
13,
2539,
29901,
29871,
29900,
29953,
29914,
29900,
29929,
29914,
29906,
29900,
29896,
29953,
13,
15945,
29908,
13,
5215,
10876,
13,
5215,
1852,
5510,
13,
5215,
2897,
29889,
2084,
408,
288,
1028,
13,
3166,
4256,
8504,
1053,
18240,
13,
3166,
16250,
1053,
2322,
8977,
13,
3166,
1374,
2904,
3747,
579,
1053,
4932,
29884,
29918,
28667,
408,
12954,
29892,
3667,
13,
2202,
29901,
13,
1678,
1053,
4768,
290,
13,
19499,
16032,
2392,
408,
19282,
29901,
13,
1678,
10876,
29889,
13322,
703,
12148,
2601,
4567,
3883,
29901,
6571,
1213,
29889,
4830,
29898,
347,
876,
13,
2202,
29901,
13,
1678,
1053,
11701,
408,
10518,
13,
19499,
16032,
2392,
408,
19282,
29901,
13,
1678,
10876,
29889,
13322,
703,
12148,
2601,
4567,
3883,
29901,
6571,
1213,
29889,
4830,
29898,
347,
876,
13,
13,
13,
1753,
4559,
29918,
2972,
29898,
29879,
333,
29892,
6471,
1125,
13,
1678,
9995,
13,
1678,
20504,
403,
1549,
599,
13997,
297,
385,
8170,
287,
21533,
322,
736,
7663,
1024,
565,
21029,
1367,
13,
1678,
2198,
297,
393,
7663,
29889,
13,
13,
1678,
584,
1853,
25349,
29901,
851,
13,
1678,
584,
3207,
25349,
29901,
21029,
1367,
515,
8783,
29889,
13,
13,
1678,
584,
1853,
6471,
29901,
8170,
287,
21533,
13,
1678,
584,
3207,
6471,
29901,
7106,
287,
9657,
515,
1374,
2904,
3747,
579,
29889,
4422,
29889,
29887,
1624,
29918,
20683,
580,
740,
29889,
13,
13,
1678,
584,
2457,
1134,
29901,
851,
13,
1678,
584,
2457,
29901,
17943,
1024,
1304,
304,
770,
1598,
421,
29879,
333,
1412,
13,
1678,
9995,
13,
1678,
363,
1024,
297,
6471,
29901,
13,
4706,
565,
25349,
297,
6471,
29961,
978,
1822,
29879,
4841,
29901,
13,
9651,
736,
1024,
13,
13,
13,
1753,
14405,
29918,
7224,
10456,
7224,
1125,
13,
1678,
9995,
13,
1678,
422,
26062,
2999,
6166,
304,
1653,
263,
2323,
7200,
731,
29889,
13,
1678,
9995,
13,
1678,
12420,
353,
731,
580,
13,
1678,
363,
269,
297,
6166,
29901,
13,
4706,
12420,
29889,
5504,
29898,
29879,
29897,
13,
1678,
736,
12420,
13,
13,
13,
1753,
5412,
29918,
327,
29884,
4841,
29898,
13155,
1125,
13,
1678,
9995,
13,
1678,
3617,
5412,
438,
29911,
11150,
29879,
310,
1269,
7663,
29889,
13,
13,
1678,
584,
1853,
6471,
29901,
360,
919,
13,
1678,
584,
3207,
6471,
29901,
426,
10900,
1024,
29901,
438,
29911,
11150,
29879,
297,
7663,
29913,
13,
13,
1678,
584,
2457,
1134,
29901,
9657,
13,
1678,
584,
2457,
29901,
360,
919,
1820,
287,
373,
7663,
1024,
322,
5412,
438,
29911,
11150,
29879,
408,
1819,
29889,
13,
1678,
9995,
13,
1678,
443,
3783,
353,
426,
1989,
29901,
731,
580,
363,
1820,
297,
6471,
29913,
13,
1678,
363,
474,
29892,
2318,
297,
26985,
29898,
13155,
1125,
13,
4706,
304,
29918,
17743,
457,
353,
6471,
29889,
5975,
580,
7503,
29875,
10062,
13155,
29889,
5975,
580,
29961,
29875,
29974,
29896,
17531,
13,
4706,
12420,
353,
14405,
29918,
7224,
10456,
517,
29918,
17743,
457,
29897,
13,
4706,
443,
3783,
29961,
2972,
29962,
353,
6471,
29961,
2972,
1822,
29881,
17678,
29898,
17743,
1312,
29897,
13,
1678,
736,
443,
3783,
13,
13,
13,
1753,
7258,
29918,
327,
29884,
4841,
29898,
13155,
1125,
13,
1678,
9995,
13,
1678,
3617,
7258,
438,
29911,
11150,
29879,
1546,
599,
5412,
18240,
310,
6471,
29889,
13,
13,
1678,
584,
1853,
6471,
29901,
360,
919,
13,
1678,
584,
3207,
6471,
29901,
426,
10900,
1024,
29901,
438,
29911,
11150,
29879,
297,
7663,
29913,
13,
13,
1678,
584,
2457,
1134,
29901,
9657,
13,
1678,
584,
2457,
29901,
360,
919,
1820,
287,
373,
2318,
10296,
322,
1009,
7258,
438,
29911,
11150,
29879,
408,
1819,
29889,
13,
1678,
9995,
13,
1678,
363,
330,
297,
12705,
29898,
13155,
1125,
13,
4706,
1596,
703,
4557,
310,
438,
29911,
15922,
297,
426,
29900,
6177,
426,
29896,
29913,
1642,
4830,
29898,
29887,
29892,
7431,
29898,
13155,
29961,
29887,
1822,
9902,
3366,
327,
29884,
4841,
3108,
4961,
13,
1678,
1353,
29918,
974,
29918,
20683,
353,
7431,
29898,
13155,
29897,
13,
1678,
7258,
353,
2322,
8977,
580,
13,
1678,
363,
474,
297,
3464,
29898,
29906,
29892,
1353,
29918,
974,
29918,
20683,
29974,
29896,
1125,
13,
4706,
363,
432,
297,
18240,
29898,
24582,
29898,
13155,
511,
474,
1125,
13,
9651,
419,
833,
29918,
978,
353,
376,
669,
11393,
7122,
29898,
1761,
29898,
29926,
876,
13,
9651,
363,
867,
29886,
297,
432,
29901,
13,
18884,
396,
11905,
419,
833,
1819,
13,
18884,
7258,
29961,
510,
833,
29918,
978,
29962,
353,
6471,
29961,
29926,
29961,
29900,
29962,
1822,
9902,
3366,
327,
29884,
4841,
16862,
8552,
580,
13,
18884,
9995,
1524,
403,
1549,
599,
6471,
322,
3013,
13271,
419,
833,
438,
29911,
11150,
29879,
411,
731,
13,
18884,
17686,
29918,
5504,
15945,
29908,
13,
18884,
363,
867,
29886,
297,
432,
29961,
29896,
29901,
5387,
13,
462,
1678,
7258,
29961,
510,
833,
29918,
978,
1822,
1639,
2042,
29918,
5504,
29898,
13155,
29961,
629,
29886,
1822,
9902,
3366,
327,
29884,
4841,
20068,
13,
1678,
736,
7258,
13,
13,
13,
1753,
2436,
29918,
348,
3783,
29898,
2084,
29892,
10944,
29892,
443,
3783,
1125,
13,
1678,
9995,
13,
1678,
11221,
263,
2224,
29892,
278,
1158,
15873,
714,
697,
934,
363,
1269,
2318,
1024,
297,
278,
13,
1678,
443,
3783,
8600,
411,
278,
934,
1024,
297,
278,
4766,
13,
13,
4706,
23611,
29914,
13506,
29918,
2972,
29889,
3945,
13,
13,
1678,
411,
1269,
934,
6943,
278,
5412,
438,
29911,
11150,
29879,
1476,
746,
17420,
393,
2318,
13,
1678,
304,
599,
278,
916,
6471,
297,
443,
3783,
29889,
13,
13,
1678,
584,
1853,
2224,
29901,
851,
13,
1678,
584,
3207,
2224,
29901,
10604,
2066,
674,
367,
7160,
297,
445,
23611,
29889,
13,
13,
1678,
584,
1853,
10944,
29901,
851,
13,
1678,
584,
3207,
10944,
29901,
349,
9569,
1024,
2715,
297,
4565,
310,
1962,
10422,
29889,
13,
13,
1678,
584,
1853,
443,
3783,
29901,
9657,
13,
1678,
584,
3207,
443,
3783,
29901,
10604,
515,
5412,
29918,
327,
375,
580,
740,
29889,
13,
1678,
9995,
13,
1678,
363,
2318,
297,
443,
3783,
29901,
13,
4706,
285,
29886,
353,
288,
1028,
29889,
7122,
29898,
2084,
29892,
29850,
3227,
1836,
3945,
1642,
4830,
29898,
13506,
29892,
2318,
876,
13,
4706,
411,
1722,
29898,
18091,
29892,
376,
29893,
1159,
408,
714,
29888,
29901,
13,
9651,
714,
29888,
29889,
3539,
14182,
29876,
1642,
7122,
29898,
348,
3783,
29961,
2972,
12622,
13,
13,
13,
1753,
4386,
29918,
8860,
29918,
6768,
7295,
13,
1678,
13812,
353,
1852,
5510,
29889,
15730,
11726,
29898,
8216,
543,
12914,
263,
350,
5971,
29924,
3402,
934,
322,
4017,
263,
376,
13,
462,
462,
268,
376,
1761,
310,
5412,
438,
29911,
11150,
29879,
1476,
297,
1269,
7663,
297,
376,
13,
462,
462,
268,
376,
20698,
934,
23157,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
2080,
29918,
5365,
290,
29918,
18091,
613,
1371,
543,
29933,
5971,
29924,
3402,
934,
2224,
23157,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
4905,
29918,
3972,
613,
13,
462,
4706,
1371,
543,
2605,
304,
4078,
7663,
5412,
438,
29911,
11150,
29879,
23157,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
20698,
29918,
1445,
613,
1371,
543,
15845,
934,
411,
7663,
2472,
23157,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
7320,
29918,
4914,
613,
1371,
543,
4409,
297,
10417,
934,
22146,
278,
376,
13,
462,
4706,
376,
7320,
29914,
16122,
310,
599,
11916,
23157,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
29899,
29886,
613,
376,
489,
13506,
613,
2322,
543,
13092,
613,
1371,
543,
1184,
29894,
680,
2702,
1426,
376,
13,
462,
4706,
376,
517,
8273,
355,
278,
1962,
934,
2983,
29889,
2648,
2322,
29892,
278,
525,
13092,
29915,
674,
376,
13,
462,
4706,
376,
915,
2715,
297,
4565,
310,
1962,
977,
264,
1280,
29892,
363,
443,
3783,
17203,
376,
13,
462,
4706,
376,
6194,
23157,
13,
1678,
13812,
29889,
1202,
29918,
23516,
703,
29899,
29878,
613,
376,
489,
24244,
613,
13,
462,
4706,
1371,
543,
2577,
7258,
438,
29911,
11150,
29879,
4249,
599,
5412,
18240,
310,
6471,
376,
13,
462,
632,
376,
392,
2436,
714,
278,
2582,
304,
2224,
4944,
304,
445,
2984,
23157,
13,
1678,
736,
13812,
29889,
5510,
29918,
5085,
580,
13,
13,
13,
1753,
1667,
7295,
13,
1678,
6389,
353,
4386,
29918,
8860,
29918,
6768,
580,
13,
13,
1678,
1018,
29901,
13,
4706,
396,
16012,
4768,
290,
3402,
934,
13,
4706,
4768,
290,
29888,
353,
4768,
290,
29889,
1359,
29918,
2371,
29898,
5085,
29889,
2080,
29918,
5365,
290,
29918,
18091,
29897,
13,
1678,
5174,
20948,
408,
734,
29901,
13,
4706,
10876,
29889,
13322,
703,
1576,
848,
297,
278,
2224,
947,
451,
2615,
304,
367,
263,
350,
5971,
29924,
3402,
1591,
29889,
376,
13,
462,
376,
2392,
29901,
6571,
1213,
29889,
4830,
29898,
371,
876,
13,
13,
1678,
396,
5953,
837,
457,
438,
29911,
11150,
29879,
2198,
297,
1269,
4559,
13,
1678,
4559,
29918,
327,
375,
353,
12954,
29889,
16645,
29918,
327,
29884,
29918,
29885,
1590,
10475,
29898,
5365,
290,
29888,
29897,
13,
13,
1678,
1018,
29901,
13,
4706,
396,
20969,
10417,
934,
13,
4706,
4839,
29892,
527,
481,
353,
3667,
29889,
5510,
29918,
1958,
29918,
1445,
29898,
5085,
29889,
20698,
29918,
1445,
29897,
13,
1678,
5174,
7865,
2392,
408,
2453,
29901,
13,
4706,
10876,
29889,
13322,
703,
2392,
29901,
6571,
1213,
29889,
4830,
29898,
345,
876,
13,
13,
1678,
396,
3617,
8018,
7663,
2472,
13,
1678,
2318,
29918,
1272,
353,
3667,
29889,
29887,
1624,
29918,
20683,
29898,
326,
481,
29892,
4839,
29892,
518,
5085,
29889,
7320,
29918,
4914,
2314,
13,
13,
1678,
396,
25455,
2582,
9657,
297,
2318,
29918,
1272,
411,
8853,
327,
29884,
4841,
1115,
731,
28296,
363,
1269,
7663,
13,
1678,
363,
2318,
297,
2318,
29918,
1272,
29901,
13,
4706,
2318,
29918,
1272,
29961,
2972,
1822,
9902,
3366,
327,
29884,
4841,
3108,
353,
731,
580,
13,
13,
1678,
396,
24930,
599,
438,
29911,
11150,
29879,
2198,
297,
1269,
7663,
13,
1678,
363,
25349,
297,
4559,
29918,
327,
375,
29901,
13,
4706,
2318,
353,
4559,
29918,
2972,
29898,
29879,
333,
29892,
2318,
29918,
1272,
29897,
13,
4706,
2318,
29918,
1272,
29961,
2972,
1822,
9902,
3366,
327,
29884,
4841,
16862,
5504,
29898,
11249,
29918,
327,
375,
29961,
29879,
333,
2314,
13,
13,
1678,
565,
6389,
29889,
24244,
29901,
13,
4706,
396,
3617,
7258,
438,
29911,
11150,
29879,
13,
4706,
7258,
353,
7258,
29918,
327,
29884,
4841,
29898,
2972,
29918,
1272,
29897,
13,
4706,
396,
14350,
714,
7258,
438,
29911,
11150,
29879,
2582,
13,
4706,
7258,
29918,
2176,
353,
10518,
29889,
17271,
29889,
3166,
29918,
8977,
29898,
12366,
29892,
7769,
543,
2248,
2564,
29911,
13,
4706,
7258,
29918,
2176,
29889,
517,
29918,
7638,
29898,
5085,
29889,
24244,
29892,
16345,
543,
29905,
29873,
613,
2380,
29922,
8824,
29897,
13,
1678,
396,
6204,
1881,
363,
5412,
29918,
327,
375,
13,
1678,
2318,
29918,
327,
29884,
4841,
353,
426,
2972,
29901,
2318,
29918,
1272,
29961,
2972,
1822,
9902,
3366,
327,
29884,
4841,
3108,
363,
2318,
297,
2318,
29918,
1272,
29913,
13,
1678,
396,
14350,
714,
5412,
438,
29911,
11150,
29879,
304,
934,
13,
1678,
2436,
29918,
348,
3783,
29898,
5085,
29889,
4905,
29918,
3972,
29892,
6389,
29889,
13506,
29892,
5412,
29918,
327,
29884,
4841,
29898,
2972,
29918,
327,
29884,
4841,
876,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
10876,
29889,
13322,
29898,
3396,
3101,
13,
2
] |
my_ip/migrations/0007_alter_project_project_image.py | OscarMugendi/Django-week3-IP | 0 | 112760 | <reponame>OscarMugendi/Django-week3-IP
# Generated by Django 3.2.7 on 2021-09-24 05:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('my_ip', '0006_auto_20210924_0111'),
]
operations = [
migrations.AlterField(
model_name='project',
name='project_image',
field=models.ImageField(blank=True, default=0, upload_to='images/projects/'),
),
]
| [
1,
529,
276,
1112,
420,
29958,
29949,
14494,
29924,
688,
26464,
29914,
29928,
5364,
29899,
18448,
29941,
29899,
5690,
13,
29937,
3251,
630,
491,
15337,
29871,
29941,
29889,
29906,
29889,
29955,
373,
29871,
29906,
29900,
29906,
29896,
29899,
29900,
29929,
29899,
29906,
29946,
29871,
29900,
29945,
29901,
29941,
29955,
13,
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,
1357,
29918,
666,
742,
525,
29900,
29900,
29900,
29953,
29918,
6921,
29918,
29906,
29900,
29906,
29896,
29900,
29929,
29906,
29946,
29918,
29900,
29896,
29896,
29896,
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,
4836,
742,
13,
9651,
1024,
2433,
4836,
29918,
3027,
742,
13,
9651,
1746,
29922,
9794,
29889,
2940,
3073,
29898,
19465,
29922,
5574,
29892,
2322,
29922,
29900,
29892,
6441,
29918,
517,
2433,
8346,
29914,
16418,
29914,
5477,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
bedrock/sqlalchemy_test.py | hieast/bedrock | 0 | 165297 |
from ark.db import Database
from sqlalchemy import Column, Integer
from sqlalchemy.dialects import postgresql
db = Database('postgresql://oceanuse:[email protected]:5432/ocean')
class Test(db.Model):
__tablename__ = 'test'
id = Column(Integer, primary_key=True)
query = db.session.query(Test).limit(10).offset(-1)
print query.all()
| [
1,
29871,
13,
3166,
564,
29895,
29889,
2585,
1053,
5470,
13,
3166,
4576,
284,
305,
6764,
1053,
12481,
29892,
8102,
13,
3166,
4576,
284,
305,
6764,
29889,
15321,
781,
29879,
1053,
27035,
13,
2585,
353,
5470,
877,
29272,
597,
29877,
11956,
1509,
29901,
29947,
29945,
29896,
29967,
29939,
29902,
29874,
29931,
293,
29934,
29893,
29895,
29954,
29879,
29992,
29896,
29900,
29889,
29941,
29900,
29889,
29896,
29947,
29941,
29889,
29896,
29900,
29906,
29901,
29945,
29946,
29941,
29906,
29914,
29877,
11956,
1495,
13,
13,
1990,
4321,
29898,
2585,
29889,
3195,
1125,
13,
1678,
4770,
3891,
2435,
420,
1649,
353,
525,
1688,
29915,
13,
1678,
1178,
353,
12481,
29898,
7798,
29892,
7601,
29918,
1989,
29922,
5574,
29897,
13,
1972,
353,
4833,
29889,
7924,
29889,
1972,
29898,
3057,
467,
13400,
29898,
29896,
29900,
467,
10289,
6278,
29896,
29897,
13,
2158,
2346,
29889,
497,
580,
13,
2
] |
average_screen_color.py | Animenosekai/AverageColor | 0 | 137936 | ### Code by <NAME>
###
###
import pyautogui
import PIL
def average_image_color(image):
"""
Code by olooney on GitHub
> https://gist.github.com/olooney/1246268
Returns the average color from a given image (PIL)
"""
i = image
h = i.histogram()
# split into red, green, blue
r = h[0:256]
g = h[256:256*2]
b = h[256*2: 256*3]
# perform the weighted average of each channel:
# the *index* is the channel value, and the *value* is its weight
return [
sum( i*w for i, w in enumerate(r) ) / sum(r),
sum( i*w for i, w in enumerate(g) ) / sum(g),
sum( i*w for i, w in enumerate(b) ) / sum(b)
]
if __name__ == '__main__':
import sys
import numpy as np
import matplotlib.pyplot as plt
import os
os.system('cls' if os.name == 'nt' else 'clear')
if len(sys.argv) > 1:
refresh_rate = int(sys.argv[1])
else:
refresh_rate = 10
print('Chosen refresh rate: ' + str(refresh_rate))
plt.ion()
fig = plt.gcf()
fig.show()
fig.canvas.draw()
iteration = 0
plt.title('Average Screen Color')
while True:
iteration += 1
image = pyautogui.screenshot()
rgb = average_image_color(image)
#VIZUALIZATION
spikes = np.random.random(1) #To show a rectangle
plt.xlabel('Average Color (RGB): ' + str(rgb))
plt.eventplot(spikes, orientation='horizontal', linelengths=0.9, linewidths=1000, color = [(rgb[0]/255, rgb[1]/255, rgb[2]/255)])
if iteration > refresh_rate:
iteration = 0
plt.clf()
plt.title('Average Screen Color')
fig.canvas.draw()
plt.pause(0.000001)
def get_average_screen_color():
'''
Returns the current screen average color.
'''
image = pyautogui.screenshot()
rgb = average_image_color(image)
return rgb | [
1,
835,
5920,
491,
529,
5813,
29958,
13,
2277,
29937,
13,
2277,
29937,
13,
5215,
11451,
1300,
468,
1481,
13,
5215,
349,
6227,
13,
13,
1753,
6588,
29918,
3027,
29918,
2780,
29898,
3027,
1125,
13,
12,
15945,
29908,
13,
12,
3399,
491,
288,
417,
4992,
373,
25492,
13,
12,
29958,
2045,
597,
29887,
391,
29889,
3292,
29889,
510,
29914,
3543,
4992,
29914,
29896,
29906,
29946,
29953,
29906,
29953,
29947,
13,
13,
12,
11609,
29879,
278,
6588,
2927,
515,
263,
2183,
1967,
313,
2227,
29931,
29897,
13,
12,
15945,
29908,
13,
12,
29875,
353,
1967,
13,
12,
29882,
353,
474,
29889,
29882,
391,
13342,
580,
13,
13,
12,
29937,
6219,
964,
2654,
29892,
7933,
29892,
7254,
13,
12,
29878,
353,
298,
29961,
29900,
29901,
29906,
29945,
29953,
29962,
13,
12,
29887,
353,
298,
29961,
29906,
29945,
29953,
29901,
29906,
29945,
29953,
29930,
29906,
29962,
13,
12,
29890,
353,
298,
29961,
29906,
29945,
29953,
29930,
29906,
29901,
29871,
29906,
29945,
29953,
29930,
29941,
29962,
13,
13,
12,
29937,
2189,
278,
7688,
287,
6588,
310,
1269,
8242,
29901,
13,
12,
29937,
278,
334,
2248,
29930,
338,
278,
8242,
995,
29892,
322,
278,
334,
1767,
29930,
338,
967,
7688,
13,
12,
2457,
518,
13,
12,
12,
2083,
29898,
474,
29930,
29893,
363,
474,
29892,
281,
297,
26985,
29898,
29878,
29897,
1723,
847,
2533,
29898,
29878,
511,
13,
12,
12,
2083,
29898,
474,
29930,
29893,
363,
474,
29892,
281,
297,
26985,
29898,
29887,
29897,
1723,
847,
2533,
29898,
29887,
511,
13,
12,
12,
2083,
29898,
474,
29930,
29893,
363,
474,
29892,
281,
297,
26985,
29898,
29890,
29897,
1723,
847,
2533,
29898,
29890,
29897,
13,
12,
29962,
13,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
1053,
10876,
13,
1678,
1053,
12655,
408,
7442,
13,
1678,
1053,
22889,
29889,
2272,
5317,
408,
14770,
13,
1678,
1053,
2897,
13,
1678,
2897,
29889,
5205,
877,
25932,
29915,
565,
2897,
29889,
978,
1275,
525,
593,
29915,
1683,
525,
8551,
1495,
13,
1678,
565,
7431,
29898,
9675,
29889,
19218,
29897,
1405,
29871,
29896,
29901,
13,
4706,
11086,
29918,
10492,
353,
938,
29898,
9675,
29889,
19218,
29961,
29896,
2314,
13,
1678,
1683,
29901,
13,
4706,
11086,
29918,
10492,
353,
29871,
29896,
29900,
13,
1678,
1596,
877,
1451,
7749,
11086,
6554,
29901,
525,
718,
851,
29898,
22379,
29918,
10492,
876,
13,
1678,
14770,
29889,
291,
580,
13,
13,
1678,
2537,
353,
14770,
29889,
29887,
6854,
580,
13,
1678,
2537,
29889,
4294,
580,
13,
1678,
2537,
29889,
15257,
29889,
4012,
580,
13,
13,
1678,
12541,
353,
29871,
29900,
13,
1678,
14770,
29889,
3257,
877,
29909,
19698,
22666,
9159,
1495,
13,
13,
1678,
1550,
5852,
29901,
13,
4706,
12541,
4619,
29871,
29896,
13,
4706,
1967,
353,
11451,
1300,
468,
1481,
29889,
29879,
24546,
8711,
580,
13,
4706,
15552,
29890,
353,
6588,
29918,
3027,
29918,
2780,
29898,
3027,
29897,
13,
13,
4706,
396,
18118,
29999,
29965,
1964,
26664,
8098,
13,
4706,
805,
29379,
353,
7442,
29889,
8172,
29889,
8172,
29898,
29896,
29897,
396,
1762,
1510,
263,
16701,
13,
13,
4706,
14770,
29889,
29916,
1643,
877,
29909,
19698,
9159,
313,
28212,
1125,
525,
718,
851,
29898,
23973,
876,
13,
4706,
14770,
29889,
3696,
5317,
29898,
1028,
29379,
29892,
19843,
2433,
22672,
742,
6276,
295,
1477,
29879,
29922,
29900,
29889,
29929,
29892,
1196,
2103,
29879,
29922,
29896,
29900,
29900,
29900,
29892,
2927,
353,
17288,
23973,
29961,
29900,
16261,
29906,
29945,
29945,
29892,
15552,
29890,
29961,
29896,
16261,
29906,
29945,
29945,
29892,
15552,
29890,
29961,
29906,
16261,
29906,
29945,
29945,
29897,
2314,
13,
13,
4706,
565,
12541,
1405,
11086,
29918,
10492,
29901,
13,
9651,
12541,
353,
29871,
29900,
13,
9651,
14770,
29889,
695,
29888,
580,
13,
9651,
14770,
29889,
3257,
877,
29909,
19698,
22666,
9159,
1495,
13,
13,
4706,
2537,
29889,
15257,
29889,
4012,
580,
13,
4706,
14770,
29889,
29886,
1071,
29898,
29900,
29889,
29900,
29900,
29900,
29900,
29900,
29896,
29897,
13,
13,
1753,
679,
29918,
12483,
482,
29918,
10525,
29918,
2780,
7295,
13,
1678,
14550,
13,
1678,
16969,
278,
1857,
4315,
6588,
2927,
29889,
13,
1678,
14550,
13,
1678,
1967,
353,
11451,
1300,
468,
1481,
29889,
29879,
24546,
8711,
580,
13,
1678,
15552,
29890,
353,
6588,
29918,
3027,
29918,
2780,
29898,
3027,
29897,
13,
1678,
736,
15552,
29890,
2
] |
package/__init__.py | jfcrenshaw/python-package | 0 | 146261 | __version__ = "0.1.0"
from .module import *
| [
1,
4770,
3259,
1649,
353,
376,
29900,
29889,
29896,
29889,
29900,
29908,
13,
3166,
869,
5453,
1053,
334,
13,
2
] |
tolteca/simu/__init__.py | dennis-l/tolteca | 2 | 164661 | #!/usr/bin/env python
import astropy.units as u
from typing import Union
from dataclasses import dataclass, field, is_dataclass
from cached_property import cached_property
import copy
from typing import ClassVar
from schema import Or
from tollan.utils.dataclass_schema import add_schema
from tollan.utils.log import get_logger, logit, log_to_file
from tollan.utils.fmt import pformat_yaml
from tollan.utils import rupdate
from ..utils.common_schema import PhysicalTypeSchema
from ..utils.config_registry import ConfigRegistry
from ..utils.config_schema import add_config_schema
from ..utils.runtime_context import RuntimeContext, RuntimeContextError
from ..utils import config_from_cli_args
__all__ = ['SimulatorRuntime', 'SimulatorRuntimeError']
@add_schema
@dataclass
class ObsParamsConfig(object):
"""The config class for ``simu.obs_params``."""
t_exp: Union[u.Quantity, None] = field(
default=None,
metadata={
'description': 'The duration of the observation to simulate.',
'schema': Or(PhysicalTypeSchema('time'), None),
}
)
f_smp_mapping: u.Quantity = field(
default=12. << u.Hz,
metadata={
'description': 'The sampling frequency to '
'evaluate mapping models.',
'schema': PhysicalTypeSchema("frequency"),
}
)
f_smp_probing: u.Quantity = field(
default=120. << u.Hz,
metadata={
'description': 'The sampling frequency '
'to evaluate detector signals.',
'schema': PhysicalTypeSchema("frequency"),
}
)
class Meta:
schema = {
'ignore_extra_keys': False,
'description': 'The parameters related to observation.'
}
@add_schema
@dataclass
class PerfParamsConfig(object):
"""The config class for ``simu.pef_params``."""
chunk_len: u.Quantity = field(
default=10 << u.s,
metadata={
'description': 'Chunk length to split the simulation to '
'reduce memory footprint.',
'schema': PhysicalTypeSchema("time"),
}
)
catalog_model_render_pixel_size: u.Quantity = field(
default=0.5 << u.arcsec,
metadata={
'description': 'Pixel size to render catalog source model.',
'schema': PhysicalTypeSchema("angle"),
}
)
mapping_eval_interp_len: Union[u.Quantity, None] = field(
default=None,
metadata={
'description': 'Interp length to speed-up mapping evaluation.',
'schema': PhysicalTypeSchema("time"),
}
)
mapping_erfa_interp_len: u.Quantity = field(
default=300 << u.s,
metadata={
'description': 'Interp length to speed-up AltAZ to '
'ICRS coordinate transformation.',
'schema': PhysicalTypeSchema("time"),
}
)
aplm_eval_interp_alt_step: u.Quantity = field(
default=60 << u.arcmin,
metadata={
'description': (
'Interp altitude step to speed-up '
'array power loading model eval.'),
'schema': PhysicalTypeSchema("angle"),
}
)
pre_eval_sky_bbox_padding_size: u.Quantity = field(
default=3. << u.arcmin,
metadata={
'description': (
'Padding size to add to the sky bbox for '
'pre-eval calculations.'),
'schema': PhysicalTypeSchema("angle"),
}
)
pre_eval_t_grid_size: int = field(
default=100,
metadata={
'description': 'Size of time grid used for pre-eval calculations.',
'schema': PhysicalTypeSchema("angle"),
}
)
anim_frame_rate: u.Quantity = field(
default=300 << u.s,
metadata={
'description': 'Frame rate for plotting animation.',
'schema': PhysicalTypeSchema("frequency"),
}
)
class Meta:
schema = {
'ignore_extra_keys': False,
'description': 'The parameters related to performance tuning.'
}
mapping_registry = ConfigRegistry.create(
name='MappingConfig',
dispatcher_key='type',
dispatcher_description='The mapping type.'
)
"""The registry for ``simu.mapping``."""
instrument_registry = ConfigRegistry.create(
name='InstrumentConfig',
dispatcher_key='name',
dispatcher_description='The instrument name.'
)
"""The registry for ``simu.instrument``."""
sources_registry = ConfigRegistry.create(
name='SourcesConfig',
dispatcher_key='type',
dispatcher_description='The simulator source type.'
)
"""The registry for ``simu.sources``."""
plots_registry = ConfigRegistry.create(
name='PlotsConfig',
dispatcher_key='type',
dispatcher_description='The plot type.'
)
"""The registry for ``simu.plots``."""
exports_registry = ConfigRegistry.create(
name='ExportsConfig',
dispatcher_key='type',
dispatcher_description='The export type.'
)
"""The registry for ``simu.exports``."""
# Load submodules here to populate the registries
from . import mapping as _ # noqa: F401, E402, F811
from . import sources as _ # noqa: F401, E402, F811
from . import plots as _ # noqa: F401, E402, F811
from . import exports as _ # noqa: F401, E402, F811
from . import toltec as _ # noqa: F401, E402, F811
# from . import lmt as _ # noqa: F401, E402, F811
@add_config_schema
@add_schema
@dataclass
class SimuConfig(object):
"""The config for `tolteca.simu`."""
jobkey: str = field(
metadata={
'description': 'The unique identifier the job.'
}
)
instrument: dict = field(
metadata={
'description': 'The dict contains the instrument setting.',
'schema': instrument_registry.schema,
'pformat_schema_type': f'<{instrument_registry.name}>',
})
mapping: dict = field(
metadata={
'description': "The simulator mapping trajectory config.",
'schema': mapping_registry.schema,
'pformat_schema_type': f'<{mapping_registry.name}>'
}
)
obs_params: ObsParamsConfig = field(
metadata={
'description': 'The dict contains the observation parameters.',
})
sources: list = field(
default_factory=list,
metadata={
'description': 'The list contains input sources for simulation.',
'schema': list(sources_registry.item_schemas),
'pformat_schema_type': f"[<{sources_registry.name}>, ...]"
})
perf_params: PerfParamsConfig = field(
default_factory=PerfParamsConfig,
metadata={
'description': 'The dict contains the performance related'
' parameters.',
})
plots: list = field(
default_factory=list,
metadata={
'description': 'The list contains config for plotting.',
'schema': list(plots_registry.item_schemas),
'pformat_schema_type': f"[<{plots_registry.name}>, ...]"
})
exports: list = field(
default_factory=list,
metadata={
'description': 'The list contains config for exporting.',
'schema': list(exports_registry.item_schemas),
'pformat_schema_type': f"[<{exports_registry.name}>, ...]"
})
plot_only: bool = field(
default=False,
metadata={
'description': 'Make plots of those defined in `plots`.'
})
export_only: bool = field(
default=False,
metadata={
'description': 'Export the simu config as defined in `exports`.'
})
class Meta:
schema = {
'ignore_extra_keys': True,
'description': 'The config dict for the simulator.'
}
config_key = 'simu'
logger: ClassVar = get_logger()
def get_or_create_output_dir(self):
logger = get_logger()
rootpath = self.runtime_info.config_info.runtime_context_dir
output_dir = rootpath.joinpath(self.jobkey)
if not output_dir.exists():
with logit(logger.debug, 'create output dir'):
output_dir.mkdir(parents=True, exist_ok=True)
return output_dir
def get_log_file(self):
return self.runtime_info.logdir.joinpath('simu.log')
@cached_property
def mapping_model(self):
return self.mapping(self)
@cached_property
def source_models(self):
return [s(self) for s in self.sources]
@cached_property
def simulator(self):
return self.instrument(self)
@cached_property
def t_simu(self):
"""The length of the simulation.
It equals `obs_params.t_exp` when set, otherwise ``t_pattern``
of the mapping pattern is used.
"""
t_simu = self.obs_params.t_exp
if t_simu is None:
t_pattern = self.mapping_model.t_pattern
self.logger.debug(f"mapping pattern time: {t_pattern}")
t_simu = t_pattern
self.logger.info(f"use t_simu={t_simu} from mapping pattern")
else:
self.logger.info(f"use t_simu={t_simu} from obs_params")
return t_simu
class SimulatorRuntimeError(RuntimeContextError):
"""Raise when errors occur in `SimulatorRuntime`."""
pass
class SimulatorRuntime(RuntimeContext):
"""A class that manages the runtime context of the simulator.
This class drives the execution of the simulator.
"""
config_cls = SimuConfig
logger = get_logger()
@cached_property
def simu_config(self):
"""Validate and return the simulator config object..
The validated config is cached. :meth:`SimulatorRuntime.update`
should be used to update the underlying config and re-validate.
"""
return self.config_cls.from_config(
self.config, rootpath=self.rootpath,
runtime_info=self.runtime_info)
def update(self, config):
self.config_backend.update_override_config(config)
if 'simu_config' in self.__dict__:
del self.__dict__['simu_config']
def cli_run(self, args=None):
"""Run the simulator with CLI as save the result.
"""
if args is not None:
_cli_cfg = config_from_cli_args(args)
# note the cli_cfg is under the namespace simu
cli_cfg = {self.config_cls.config_key: _cli_cfg}
if _cli_cfg:
self.logger.info(
f"config specified with commandline arguments:\n"
f"{pformat_yaml(cli_cfg)}")
self.update(cli_cfg)
cfg = self.simu_config.to_config()
# here we recursively check the cli_cfg and report
# if any of the key is ignored by the schema and
# throw an error
def _check_ignored(key_prefix, d, c):
if isinstance(d, dict) and isinstance(c, dict):
ignored = set(d.keys()) - set(c.keys())
ignored = [f'{key_prefix}.{k}' for k in ignored]
if len(ignored) > 0:
raise SimulatorRuntimeError(
f"Invalid config items specified in "
f"the commandline: {ignored}")
for k in set(d.keys()).intersection(c.keys()):
_check_ignored(f'{key_prefix}{k}', d[k], c[k])
_check_ignored('', cli_cfg, cfg)
return self.run()
def run(self):
cfg = self.simu_config
self.logger.debug(
f"run simu with config dict: "
f"{pformat_yaml(cfg.to_config())}")
if cfg.plot_only:
return self._run_plot()
if cfg.export_only:
return self._run_export()
return self._run_simu()
def _run_plot(self):
cfg = self.simu_config
self.logger.info(
f"make simu plots:\n"
f"{pformat_yaml(cfg.to_dict()['plots'])}")
results = []
for plotter in cfg.plots:
result = plotter(cfg)
results.append(result)
if plotter.save:
# TODO handle save here
pass
return results
def _run_export(self):
cfg = self.simu_config
self.logger.info(
f"export simu:\n"
f"{pformat_yaml(cfg.to_dict()['exports'])}")
results = []
for exporter in cfg.exports:
result = exporter(cfg)
results.append(result)
return results
def _run_simu(self):
"""Run the simulator."""
cfg = self.simu_config
simu = cfg.simulator
t_simu = cfg.t_simu
mapping_model = cfg.mapping_model
source_models = cfg.source_models
output_dir = cfg.get_or_create_output_dir()
self.logger.debug(
f'run {simu} with:{{}}\n'.format(
pformat_yaml({
'obs_params': cfg.obs_params.to_dict(),
'perf_params': cfg.perf_params.to_dict(),
})))
self.logger.debug(
'mapping:\n{}\n\nsources:\n{}\n'.format(
mapping_model,
'\n'.join(str(s) for s in source_models)
)
)
self.logger.debug(
f'simu output dir: {output_dir}\nsimu length={t_simu}'
)
# run the simulator
log_file = cfg.get_log_file()
self.logger.info(f'setup logging to file {log_file}')
with log_to_file(
filepath=log_file,
level='DEBUG',
disable_other_handlers=False
):
output_ctx = simu.output_context(dirpath=output_dir)
with output_ctx.open():
self.logger.info(
f"write output to {output_ctx.rootpath}")
# save the config file as YAML
config_filepath = output_ctx.make_output_filename(
'tolteca', '.yaml')
with open(config_filepath, 'w') as fo:
config = copy.deepcopy(self.config)
rupdate(config, self.simu_config.to_config())
self.yaml_dump(config, fo)
with simu.iter_eval_context(cfg) as (iter_eval, t_chunks):
# save mapping model meta
output_ctx.write_mapping_meta(
mapping=mapping_model, simu_config=cfg)
# save simulator meta
output_ctx.write_sim_meta(simu_config=cfg)
# run simulator for each chunk and save the data
n_chunks = len(t_chunks)
for ci, t in enumerate(t_chunks):
self.logger.info(
f"simulate chunk {ci}/{n_chunks} "
f"t_min={t.min()} t_max={t.max()}")
output_ctx.write_sim_data(iter_eval(t))
return output_dir
def plot(self, type, **kwargs):
"""Make plot of type `type`."""
if type not in plots_registry:
raise ValueError(
f"Invalid plot type {type}. "
f"Available types: {plots_registry.keys()}")
plotter = plots_registry[type].from_dict(kwargs)
return plotter(self.simu_config)
# make a list of all simu config item types
_locals = list(locals().values())
simu_config_item_types = list()
for v in _locals:
if is_dataclass(v) and hasattr(v, 'schema'):
simu_config_item_types.append(v)
elif isinstance(v, ConfigRegistry):
simu_config_item_types.append(v)
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
13,
5215,
8717,
14441,
29889,
348,
1169,
408,
318,
13,
3166,
19229,
1053,
7761,
13,
3166,
848,
13203,
1053,
848,
1990,
29892,
1746,
29892,
338,
29918,
1272,
1990,
13,
3166,
22152,
29918,
6799,
1053,
22152,
29918,
6799,
13,
5215,
3509,
13,
3166,
19229,
1053,
4134,
9037,
13,
3166,
10938,
1053,
1394,
13,
13,
3166,
304,
645,
273,
29889,
13239,
29889,
1272,
1990,
29918,
11010,
1053,
788,
29918,
11010,
13,
3166,
304,
645,
273,
29889,
13239,
29889,
1188,
1053,
679,
29918,
21707,
29892,
1480,
277,
29892,
1480,
29918,
517,
29918,
1445,
13,
3166,
304,
645,
273,
29889,
13239,
29889,
23479,
1053,
282,
4830,
29918,
25162,
13,
3166,
304,
645,
273,
29889,
13239,
1053,
364,
5504,
13,
13,
3166,
6317,
13239,
29889,
9435,
29918,
11010,
1053,
11661,
936,
1542,
12763,
13,
3166,
6317,
13239,
29889,
2917,
29918,
1727,
6020,
1053,
12782,
22579,
13,
3166,
6317,
13239,
29889,
2917,
29918,
11010,
1053,
788,
29918,
2917,
29918,
11010,
13,
3166,
6317,
13239,
29889,
15634,
29918,
4703,
1053,
24875,
2677,
29892,
24875,
2677,
2392,
13,
3166,
6317,
13239,
1053,
2295,
29918,
3166,
29918,
11303,
29918,
5085,
13,
13,
13,
1649,
497,
1649,
353,
6024,
8942,
9183,
7944,
742,
525,
8942,
9183,
7944,
2392,
2033,
13,
13,
13,
29992,
1202,
29918,
11010,
13,
29992,
1272,
1990,
13,
1990,
4250,
29879,
9629,
3991,
29898,
3318,
1125,
13,
1678,
9995,
1576,
2295,
770,
363,
4954,
3601,
29884,
29889,
26290,
29918,
7529,
16159,
1213,
15945,
13,
13,
1678,
260,
29918,
4548,
29901,
7761,
29961,
29884,
29889,
22930,
537,
29892,
6213,
29962,
353,
1746,
29898,
13,
4706,
2322,
29922,
8516,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
14385,
310,
278,
15500,
304,
29611,
29889,
742,
13,
9651,
525,
11010,
2396,
1394,
29898,
25847,
936,
1542,
12763,
877,
2230,
5477,
6213,
511,
13,
9651,
500,
13,
4706,
1723,
13,
13,
1678,
285,
29918,
29879,
1526,
29918,
20698,
29901,
318,
29889,
22930,
537,
353,
1746,
29898,
13,
4706,
2322,
29922,
29896,
29906,
29889,
3532,
318,
29889,
12661,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
23460,
10868,
304,
525,
13,
462,
965,
525,
24219,
403,
10417,
4733,
29889,
742,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
10745,
23860,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
285,
29918,
29879,
1526,
29918,
771,
10549,
29901,
318,
29889,
22930,
537,
353,
1746,
29898,
13,
4706,
2322,
29922,
29896,
29906,
29900,
29889,
3532,
318,
29889,
12661,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
23460,
10868,
525,
13,
462,
965,
525,
517,
14707,
1439,
3019,
18470,
29889,
742,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
10745,
23860,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
10938,
353,
426,
13,
9651,
525,
17281,
29918,
17833,
29918,
8149,
2396,
7700,
29892,
13,
9651,
525,
8216,
2396,
525,
1576,
4128,
4475,
304,
15500,
6169,
13,
9651,
500,
13,
13,
13,
29992,
1202,
29918,
11010,
13,
29992,
1272,
1990,
13,
1990,
2431,
29888,
9629,
3991,
29898,
3318,
1125,
13,
1678,
9995,
1576,
2295,
770,
363,
4954,
3601,
29884,
29889,
412,
29888,
29918,
7529,
16159,
1213,
15945,
13,
13,
1678,
19875,
29918,
2435,
29901,
318,
29889,
22930,
537,
353,
1746,
29898,
13,
4706,
2322,
29922,
29896,
29900,
3532,
318,
29889,
29879,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1451,
2960,
3309,
304,
6219,
278,
17402,
304,
525,
13,
462,
965,
525,
17469,
3370,
3661,
2158,
29889,
742,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
2230,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
16653,
29918,
4299,
29918,
9482,
29918,
29886,
15711,
29918,
2311,
29901,
318,
29889,
22930,
537,
353,
1746,
29898,
13,
4706,
2322,
29922,
29900,
29889,
29945,
3532,
318,
29889,
5666,
3471,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
29637,
2159,
304,
4050,
16653,
2752,
1904,
29889,
742,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
2521,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
10417,
29918,
14513,
29918,
1639,
29886,
29918,
2435,
29901,
7761,
29961,
29884,
29889,
22930,
537,
29892,
6213,
29962,
353,
1746,
29898,
13,
4706,
2322,
29922,
8516,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
4074,
29886,
3309,
304,
6210,
29899,
786,
10417,
17983,
29889,
742,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
2230,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
10417,
29918,
261,
5444,
29918,
1639,
29886,
29918,
2435,
29901,
318,
29889,
22930,
537,
353,
1746,
29898,
13,
4706,
2322,
29922,
29941,
29900,
29900,
3532,
318,
29889,
29879,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
4074,
29886,
3309,
304,
6210,
29899,
786,
10790,
29909,
29999,
304,
525,
13,
462,
965,
525,
2965,
12445,
14821,
13852,
29889,
742,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
2230,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
263,
572,
29885,
29918,
14513,
29918,
1639,
29886,
29918,
1997,
29918,
10568,
29901,
318,
29889,
22930,
537,
353,
1746,
29898,
13,
4706,
2322,
29922,
29953,
29900,
3532,
318,
29889,
5666,
1195,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
313,
13,
18884,
525,
4074,
29886,
5272,
4279,
4331,
304,
6210,
29899,
786,
525,
13,
18884,
525,
2378,
3081,
8363,
1904,
19745,
29889,
5477,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
2521,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
758,
29918,
14513,
29918,
7912,
29918,
29890,
1884,
29918,
12791,
29918,
2311,
29901,
318,
29889,
22930,
537,
353,
1746,
29898,
13,
4706,
2322,
29922,
29941,
29889,
3532,
318,
29889,
5666,
1195,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
313,
13,
18884,
525,
29925,
4676,
2159,
304,
788,
304,
278,
14744,
289,
1884,
363,
525,
13,
18884,
525,
1457,
29899,
14513,
17203,
29889,
5477,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
2521,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
758,
29918,
14513,
29918,
29873,
29918,
7720,
29918,
2311,
29901,
938,
353,
1746,
29898,
13,
4706,
2322,
29922,
29896,
29900,
29900,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
3505,
310,
931,
6856,
1304,
363,
758,
29899,
14513,
17203,
29889,
742,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
2521,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
13,
1678,
3778,
29918,
2557,
29918,
10492,
29901,
318,
29889,
22930,
537,
353,
1746,
29898,
13,
4706,
2322,
29922,
29941,
29900,
29900,
3532,
318,
29889,
29879,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
4308,
6554,
363,
6492,
1259,
9612,
29889,
742,
13,
9651,
525,
11010,
2396,
11661,
936,
1542,
12763,
703,
10745,
23860,
4968,
13,
9651,
500,
13,
4706,
1723,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
10938,
353,
426,
13,
9651,
525,
17281,
29918,
17833,
29918,
8149,
2396,
7700,
29892,
13,
9651,
525,
8216,
2396,
525,
1576,
4128,
4475,
304,
4180,
18515,
292,
6169,
13,
9651,
500,
13,
13,
13,
20698,
29918,
1727,
6020,
353,
12782,
22579,
29889,
3258,
29898,
13,
1678,
1024,
2433,
15845,
3991,
742,
13,
1678,
13916,
261,
29918,
1989,
2433,
1853,
742,
13,
1678,
13916,
261,
29918,
8216,
2433,
1576,
10417,
1134,
6169,
13,
1678,
1723,
13,
15945,
29908,
1576,
21235,
363,
4954,
3601,
29884,
29889,
20698,
16159,
1213,
15945,
13,
13,
13,
2611,
15461,
29918,
1727,
6020,
353,
12782,
22579,
29889,
3258,
29898,
13,
1678,
1024,
2433,
3379,
15461,
3991,
742,
13,
1678,
13916,
261,
29918,
1989,
2433,
978,
742,
13,
1678,
13916,
261,
29918,
8216,
2433,
1576,
11395,
1024,
6169,
13,
1678,
1723,
13,
15945,
29908,
1576,
21235,
363,
4954,
3601,
29884,
29889,
2611,
15461,
16159,
1213,
15945,
13,
13,
13,
29879,
2863,
29918,
1727,
6020,
353,
12782,
22579,
29889,
3258,
29898,
13,
1678,
1024,
2433,
29903,
2863,
3991,
742,
13,
1678,
13916,
261,
29918,
1989,
2433,
1853,
742,
13,
1678,
13916,
261,
29918,
8216,
2433,
1576,
1027,
9183,
2752,
1134,
6169,
13,
1678,
1723,
13,
15945,
29908,
1576,
21235,
363,
4954,
3601,
29884,
29889,
29879,
2863,
16159,
1213,
15945,
13,
13,
13,
26762,
29918,
1727,
6020,
353,
12782,
22579,
29889,
3258,
29898,
13,
1678,
1024,
2433,
3247,
1862,
3991,
742,
13,
1678,
13916,
261,
29918,
1989,
2433,
1853,
742,
13,
1678,
13916,
261,
29918,
8216,
2433,
1576,
6492,
1134,
6169,
13,
1678,
1723,
13,
15945,
29908,
1576,
21235,
363,
4954,
3601,
29884,
29889,
26762,
16159,
1213,
15945,
13,
13,
13,
26500,
29918,
1727,
6020,
353,
12782,
22579,
29889,
3258,
29898,
13,
1678,
1024,
2433,
1252,
4011,
3991,
742,
13,
1678,
13916,
261,
29918,
1989,
2433,
1853,
742,
13,
1678,
13916,
261,
29918,
8216,
2433,
1576,
5609,
1134,
6169,
13,
1678,
1723,
13,
15945,
29908,
1576,
21235,
363,
4954,
3601,
29884,
29889,
26500,
16159,
1213,
15945,
13,
13,
29937,
16012,
1014,
7576,
1244,
304,
19450,
278,
1072,
391,
2722,
13,
3166,
869,
1053,
10417,
408,
903,
29871,
396,
694,
25621,
29901,
383,
29946,
29900,
29896,
29892,
382,
29946,
29900,
29906,
29892,
383,
29947,
29896,
29896,
13,
3166,
869,
1053,
8974,
408,
903,
29871,
396,
694,
25621,
29901,
383,
29946,
29900,
29896,
29892,
382,
29946,
29900,
29906,
29892,
383,
29947,
29896,
29896,
13,
3166,
869,
1053,
24580,
408,
903,
29871,
396,
694,
25621,
29901,
383,
29946,
29900,
29896,
29892,
382,
29946,
29900,
29906,
29892,
383,
29947,
29896,
29896,
13,
3166,
869,
1053,
29586,
408,
903,
29871,
396,
694,
25621,
29901,
383,
29946,
29900,
29896,
29892,
382,
29946,
29900,
29906,
29892,
383,
29947,
29896,
29896,
13,
3166,
869,
1053,
304,
29880,
371,
29883,
408,
903,
29871,
396,
694,
25621,
29901,
383,
29946,
29900,
29896,
29892,
382,
29946,
29900,
29906,
29892,
383,
29947,
29896,
29896,
13,
29937,
515,
869,
1053,
301,
4378,
408,
903,
29871,
396,
694,
25621,
29901,
383,
29946,
29900,
29896,
29892,
382,
29946,
29900,
29906,
29892,
383,
29947,
29896,
29896,
13,
13,
13,
29992,
1202,
29918,
2917,
29918,
11010,
13,
29992,
1202,
29918,
11010,
13,
29992,
1272,
1990,
13,
1990,
3439,
29884,
3991,
29898,
3318,
1125,
13,
1678,
9995,
1576,
2295,
363,
421,
25027,
371,
1113,
29889,
3601,
29884,
29952,
1213,
15945,
13,
13,
1678,
4982,
1989,
29901,
851,
353,
1746,
29898,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
5412,
15882,
278,
4982,
6169,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
11395,
29901,
9657,
353,
1746,
29898,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
9657,
3743,
278,
11395,
4444,
29889,
742,
13,
9651,
525,
11010,
2396,
11395,
29918,
1727,
6020,
29889,
11010,
29892,
13,
9651,
525,
29886,
4830,
29918,
11010,
29918,
1853,
2396,
285,
29915,
29966,
29912,
2611,
15461,
29918,
1727,
6020,
29889,
978,
17428,
742,
13,
9651,
5615,
13,
1678,
10417,
29901,
9657,
353,
1746,
29898,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
376,
1576,
1027,
9183,
10417,
23324,
706,
2295,
19602,
13,
9651,
525,
11010,
2396,
10417,
29918,
1727,
6020,
29889,
11010,
29892,
13,
9651,
525,
29886,
4830,
29918,
11010,
29918,
1853,
2396,
285,
29915,
29966,
29912,
20698,
29918,
1727,
6020,
29889,
978,
29913,
16299,
13,
9651,
500,
13,
4706,
1723,
13,
1678,
20881,
29918,
7529,
29901,
4250,
29879,
9629,
3991,
353,
1746,
29898,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
9657,
3743,
278,
15500,
4128,
29889,
742,
13,
9651,
5615,
13,
1678,
8974,
29901,
1051,
353,
1746,
29898,
13,
4706,
2322,
29918,
14399,
29922,
1761,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
1051,
3743,
1881,
8974,
363,
17402,
29889,
742,
13,
9651,
525,
11010,
2396,
1051,
29898,
29879,
2863,
29918,
1727,
6020,
29889,
667,
29918,
11993,
511,
13,
9651,
525,
29886,
4830,
29918,
11010,
29918,
1853,
2396,
285,
29908,
29961,
29966,
29912,
29879,
2863,
29918,
1727,
6020,
29889,
978,
29913,
10202,
2023,
18017,
13,
9651,
5615,
13,
1678,
23895,
29918,
7529,
29901,
2431,
29888,
9629,
3991,
353,
1746,
29898,
13,
4706,
2322,
29918,
14399,
29922,
5894,
29888,
9629,
3991,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
9657,
3743,
278,
4180,
4475,
29915,
13,
462,
965,
525,
4128,
29889,
742,
13,
9651,
5615,
13,
1678,
24580,
29901,
1051,
353,
1746,
29898,
13,
4706,
2322,
29918,
14399,
29922,
1761,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
1051,
3743,
2295,
363,
6492,
1259,
29889,
742,
13,
9651,
525,
11010,
2396,
1051,
29898,
26762,
29918,
1727,
6020,
29889,
667,
29918,
11993,
511,
13,
9651,
525,
29886,
4830,
29918,
11010,
29918,
1853,
2396,
285,
29908,
29961,
29966,
29912,
26762,
29918,
1727,
6020,
29889,
978,
29913,
10202,
2023,
18017,
13,
9651,
5615,
13,
1678,
29586,
29901,
1051,
353,
1746,
29898,
13,
4706,
2322,
29918,
14399,
29922,
1761,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
1576,
1051,
3743,
2295,
363,
5609,
292,
29889,
742,
13,
9651,
525,
11010,
2396,
1051,
29898,
26500,
29918,
1727,
6020,
29889,
667,
29918,
11993,
511,
13,
9651,
525,
29886,
4830,
29918,
11010,
29918,
1853,
2396,
285,
29908,
29961,
29966,
29912,
26500,
29918,
1727,
6020,
29889,
978,
29913,
10202,
2023,
18017,
13,
9651,
5615,
13,
1678,
6492,
29918,
6194,
29901,
6120,
353,
1746,
29898,
13,
4706,
2322,
29922,
8824,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
9984,
24580,
310,
1906,
3342,
297,
421,
26762,
1412,
29915,
13,
9651,
5615,
13,
1678,
5609,
29918,
6194,
29901,
6120,
353,
1746,
29898,
13,
4706,
2322,
29922,
8824,
29892,
13,
4706,
15562,
3790,
13,
9651,
525,
8216,
2396,
525,
26382,
278,
1027,
29884,
2295,
408,
3342,
297,
421,
26500,
1412,
29915,
13,
9651,
5615,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
10938,
353,
426,
13,
9651,
525,
17281,
29918,
17833,
29918,
8149,
2396,
5852,
29892,
13,
9651,
525,
8216,
2396,
525,
1576,
2295,
9657,
363,
278,
1027,
9183,
6169,
13,
9651,
500,
13,
4706,
2295,
29918,
1989,
353,
525,
3601,
29884,
29915,
13,
13,
1678,
17927,
29901,
4134,
9037,
353,
679,
29918,
21707,
580,
13,
13,
1678,
822,
679,
29918,
272,
29918,
3258,
29918,
4905,
29918,
3972,
29898,
1311,
1125,
13,
4706,
17927,
353,
679,
29918,
21707,
580,
13,
4706,
3876,
2084,
353,
1583,
29889,
15634,
29918,
3888,
29889,
2917,
29918,
3888,
29889,
15634,
29918,
4703,
29918,
3972,
13,
4706,
1962,
29918,
3972,
353,
3876,
2084,
29889,
7122,
2084,
29898,
1311,
29889,
9057,
1989,
29897,
13,
4706,
565,
451,
1962,
29918,
3972,
29889,
9933,
7295,
13,
9651,
411,
1480,
277,
29898,
21707,
29889,
8382,
29892,
525,
3258,
1962,
4516,
29374,
13,
18884,
1962,
29918,
3972,
29889,
11256,
3972,
29898,
862,
1237,
29922,
5574,
29892,
1863,
29918,
554,
29922,
5574,
29897,
13,
4706,
736,
1962,
29918,
3972,
13,
13,
1678,
822,
679,
29918,
1188,
29918,
1445,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
15634,
29918,
3888,
29889,
1188,
3972,
29889,
7122,
2084,
877,
3601,
29884,
29889,
1188,
1495,
13,
13,
1678,
732,
29883,
3791,
29918,
6799,
13,
1678,
822,
10417,
29918,
4299,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
20698,
29898,
1311,
29897,
13,
13,
1678,
732,
29883,
3791,
29918,
6799,
13,
1678,
822,
2752,
29918,
9794,
29898,
1311,
1125,
13,
4706,
736,
518,
29879,
29898,
1311,
29897,
363,
269,
297,
1583,
29889,
29879,
2863,
29962,
13,
13,
1678,
732,
29883,
3791,
29918,
6799,
13,
1678,
822,
1027,
9183,
29898,
1311,
1125,
13,
4706,
736,
1583,
29889,
2611,
15461,
29898,
1311,
29897,
13,
13,
1678,
732,
29883,
3791,
29918,
6799,
13,
1678,
822,
260,
29918,
3601,
29884,
29898,
1311,
1125,
13,
4706,
9995,
1576,
3309,
310,
278,
17402,
29889,
13,
13,
4706,
739,
15743,
421,
26290,
29918,
7529,
29889,
29873,
29918,
4548,
29952,
746,
731,
29892,
6467,
4954,
29873,
29918,
11037,
16159,
13,
4706,
310,
278,
10417,
4766,
338,
1304,
29889,
13,
4706,
9995,
13,
4706,
260,
29918,
3601,
29884,
353,
1583,
29889,
26290,
29918,
7529,
29889,
29873,
29918,
4548,
13,
4706,
565,
260,
29918,
3601,
29884,
338,
6213,
29901,
13,
9651,
260,
29918,
11037,
353,
1583,
29889,
20698,
29918,
4299,
29889,
29873,
29918,
11037,
13,
9651,
1583,
29889,
21707,
29889,
8382,
29898,
29888,
29908,
20698,
4766,
931,
29901,
426,
29873,
29918,
11037,
27195,
13,
9651,
260,
29918,
3601,
29884,
353,
260,
29918,
11037,
13,
9651,
1583,
29889,
21707,
29889,
3888,
29898,
29888,
29908,
1509,
260,
29918,
3601,
29884,
3790,
29873,
29918,
3601,
29884,
29913,
515,
10417,
4766,
1159,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
21707,
29889,
3888,
29898,
29888,
29908,
1509,
260,
29918,
3601,
29884,
3790,
29873,
29918,
3601,
29884,
29913,
515,
20881,
29918,
7529,
1159,
13,
4706,
736,
260,
29918,
3601,
29884,
13,
13,
13,
1990,
3439,
9183,
7944,
2392,
29898,
7944,
2677,
2392,
1125,
13,
1678,
9995,
29934,
29874,
895,
746,
4436,
6403,
297,
421,
8942,
9183,
7944,
29952,
1213,
15945,
13,
1678,
1209,
13,
13,
13,
1990,
3439,
9183,
7944,
29898,
7944,
2677,
1125,
13,
1678,
9995,
29909,
770,
393,
767,
1179,
278,
10073,
3030,
310,
278,
1027,
9183,
29889,
13,
13,
1678,
910,
770,
25100,
278,
8225,
310,
278,
1027,
9183,
29889,
13,
1678,
9995,
13,
13,
1678,
2295,
29918,
25932,
353,
3439,
29884,
3991,
13,
13,
1678,
17927,
353,
679,
29918,
21707,
580,
13,
13,
1678,
732,
29883,
3791,
29918,
6799,
13,
1678,
822,
1027,
29884,
29918,
2917,
29898,
1311,
1125,
13,
4706,
9995,
7211,
403,
322,
736,
278,
1027,
9183,
2295,
1203,
636,
13,
13,
4706,
450,
2854,
630,
2295,
338,
22152,
29889,
584,
29885,
621,
18078,
8942,
9183,
7944,
29889,
5504,
29952,
13,
4706,
881,
367,
1304,
304,
2767,
278,
14407,
2295,
322,
337,
29899,
15480,
29889,
13,
4706,
9995,
13,
4706,
736,
1583,
29889,
2917,
29918,
25932,
29889,
3166,
29918,
2917,
29898,
13,
9651,
1583,
29889,
2917,
29892,
3876,
2084,
29922,
1311,
29889,
4632,
2084,
29892,
13,
9651,
10073,
29918,
3888,
29922,
1311,
29889,
15634,
29918,
3888,
29897,
13,
13,
1678,
822,
2767,
29898,
1311,
29892,
2295,
1125,
13,
4706,
1583,
29889,
2917,
29918,
27852,
29889,
5504,
29918,
15752,
29918,
2917,
29898,
2917,
29897,
13,
4706,
565,
525,
3601,
29884,
29918,
2917,
29915,
297,
1583,
17255,
8977,
1649,
29901,
13,
9651,
628,
1583,
17255,
8977,
1649,
1839,
3601,
29884,
29918,
2917,
2033,
13,
13,
1678,
822,
9335,
29918,
3389,
29898,
1311,
29892,
6389,
29922,
8516,
1125,
13,
4706,
9995,
6558,
278,
1027,
9183,
411,
24492,
408,
4078,
278,
1121,
29889,
13,
4706,
9995,
13,
4706,
565,
6389,
338,
451,
6213,
29901,
13,
9651,
903,
11303,
29918,
16859,
353,
2295,
29918,
3166,
29918,
11303,
29918,
5085,
29898,
5085,
29897,
13,
9651,
396,
4443,
278,
9335,
29918,
16859,
338,
1090,
278,
7397,
1027,
29884,
13,
9651,
9335,
29918,
16859,
353,
426,
1311,
29889,
2917,
29918,
25932,
29889,
2917,
29918,
1989,
29901,
903,
11303,
29918,
16859,
29913,
13,
9651,
565,
903,
11303,
29918,
16859,
29901,
13,
18884,
1583,
29889,
21707,
29889,
3888,
29898,
13,
462,
1678,
285,
29908,
2917,
6790,
411,
1899,
1220,
6273,
3583,
29876,
29908,
13,
462,
1678,
285,
29908,
29912,
29886,
4830,
29918,
25162,
29898,
11303,
29918,
16859,
2915,
1159,
13,
9651,
1583,
29889,
5504,
29898,
11303,
29918,
16859,
29897,
13,
9651,
274,
16434,
353,
1583,
29889,
3601,
29884,
29918,
2917,
29889,
517,
29918,
2917,
580,
13,
9651,
396,
1244,
591,
8304,
3598,
1423,
278,
9335,
29918,
16859,
322,
3461,
13,
9651,
396,
565,
738,
310,
278,
1820,
338,
17262,
491,
278,
10938,
322,
13,
9651,
396,
3183,
385,
1059,
13,
13,
9651,
822,
903,
3198,
29918,
647,
4395,
29898,
1989,
29918,
13506,
29892,
270,
29892,
274,
1125,
13,
18884,
565,
338,
8758,
29898,
29881,
29892,
9657,
29897,
322,
338,
8758,
29898,
29883,
29892,
9657,
1125,
13,
462,
1678,
17262,
353,
731,
29898,
29881,
29889,
8149,
3101,
448,
731,
29898,
29883,
29889,
8149,
3101,
13,
462,
1678,
17262,
353,
518,
29888,
29915,
29912,
1989,
29918,
13506,
1836,
29912,
29895,
10162,
363,
413,
297,
17262,
29962,
13,
462,
1678,
565,
7431,
29898,
647,
4395,
29897,
1405,
29871,
29900,
29901,
13,
462,
4706,
12020,
3439,
9183,
7944,
2392,
29898,
13,
462,
9651,
285,
29908,
13919,
2295,
4452,
6790,
297,
376,
13,
462,
9651,
285,
29908,
1552,
1899,
1220,
29901,
426,
647,
4395,
27195,
13,
462,
1678,
363,
413,
297,
731,
29898,
29881,
29889,
8149,
16655,
1639,
2042,
29898,
29883,
29889,
8149,
580,
1125,
13,
462,
4706,
903,
3198,
29918,
647,
4395,
29898,
29888,
29915,
29912,
1989,
29918,
13506,
1157,
29895,
29913,
742,
270,
29961,
29895,
1402,
274,
29961,
29895,
2314,
13,
9651,
903,
3198,
29918,
647,
4395,
877,
742,
9335,
29918,
16859,
29892,
274,
16434,
29897,
13,
4706,
736,
1583,
29889,
3389,
580,
13,
13,
1678,
822,
1065,
29898,
1311,
1125,
13,
4706,
274,
16434,
353,
1583,
29889,
3601,
29884,
29918,
2917,
13,
4706,
1583,
29889,
21707,
29889,
8382,
29898,
13,
9651,
285,
29908,
3389,
1027,
29884,
411,
2295,
9657,
29901,
376,
13,
9651,
285,
29908,
29912,
29886,
4830,
29918,
25162,
29898,
16859,
29889,
517,
29918,
2917,
580,
2915,
1159,
13,
13,
4706,
565,
274,
16434,
29889,
5317,
29918,
6194,
29901,
13,
9651,
736,
1583,
3032,
3389,
29918,
5317,
580,
13,
4706,
565,
274,
16434,
29889,
15843,
29918,
6194,
29901,
13,
9651,
736,
1583,
3032,
3389,
29918,
15843,
580,
13,
4706,
736,
1583,
3032,
3389,
29918,
3601,
29884,
580,
13,
13,
1678,
822,
903,
3389,
29918,
5317,
29898,
1311,
1125,
13,
4706,
274,
16434,
353,
1583,
29889,
3601,
29884,
29918,
2917,
13,
4706,
1583,
29889,
21707,
29889,
3888,
29898,
13,
9651,
285,
29908,
5675,
1027,
29884,
24580,
3583,
29876,
29908,
13,
9651,
285,
29908,
29912,
29886,
4830,
29918,
25162,
29898,
16859,
29889,
517,
29918,
8977,
580,
1839,
26762,
2033,
2915,
1159,
13,
4706,
2582,
353,
5159,
13,
4706,
363,
6492,
357,
297,
274,
16434,
29889,
26762,
29901,
13,
9651,
1121,
353,
6492,
357,
29898,
16859,
29897,
13,
9651,
2582,
29889,
4397,
29898,
2914,
29897,
13,
9651,
565,
6492,
357,
29889,
7620,
29901,
13,
18884,
396,
14402,
4386,
4078,
1244,
13,
18884,
1209,
13,
4706,
736,
2582,
13,
13,
1678,
822,
903,
3389,
29918,
15843,
29898,
1311,
1125,
13,
4706,
274,
16434,
353,
1583,
29889,
3601,
29884,
29918,
2917,
13,
4706,
1583,
29889,
21707,
29889,
3888,
29898,
13,
9651,
285,
29908,
15843,
1027,
29884,
3583,
29876,
29908,
13,
9651,
285,
29908,
29912,
29886,
4830,
29918,
25162,
29898,
16859,
29889,
517,
29918,
8977,
580,
1839,
26500,
2033,
2915,
1159,
13,
4706,
2582,
353,
5159,
13,
4706,
363,
1518,
9555,
297,
274,
16434,
29889,
26500,
29901,
13,
9651,
1121,
353,
1518,
9555,
29898,
16859,
29897,
13,
9651,
2582,
29889,
4397,
29898,
2914,
29897,
13,
4706,
736,
2582,
13,
13,
1678,
822,
903,
3389,
29918,
3601,
29884,
29898,
1311,
1125,
13,
4706,
9995,
6558,
278,
1027,
9183,
1213,
15945,
13,
4706,
274,
16434,
353,
1583,
29889,
3601,
29884,
29918,
2917,
13,
4706,
1027,
29884,
353,
274,
16434,
29889,
3601,
9183,
13,
4706,
260,
29918,
3601,
29884,
353,
274,
16434,
29889,
29873,
29918,
3601,
29884,
13,
4706,
10417,
29918,
4299,
353,
274,
16434,
29889,
20698,
29918,
4299,
13,
4706,
2752,
29918,
9794,
353,
274,
16434,
29889,
4993,
29918,
9794,
13,
4706,
1962,
29918,
3972,
353,
274,
16434,
29889,
657,
29918,
272,
29918,
3258,
29918,
4905,
29918,
3972,
580,
13,
13,
4706,
1583,
29889,
21707,
29889,
8382,
29898,
13,
9651,
285,
29915,
3389,
426,
3601,
29884,
29913,
411,
29901,
6224,
4229,
29876,
4286,
4830,
29898,
13,
18884,
282,
4830,
29918,
25162,
3319,
13,
462,
1678,
525,
26290,
29918,
7529,
2396,
274,
16434,
29889,
26290,
29918,
7529,
29889,
517,
29918,
8977,
3285,
13,
462,
1678,
525,
546,
29888,
29918,
7529,
2396,
274,
16434,
29889,
546,
29888,
29918,
7529,
29889,
517,
29918,
8977,
3285,
13,
462,
1678,
500,
4961,
13,
4706,
1583,
29889,
21707,
29889,
8382,
29898,
13,
9651,
525,
20698,
3583,
29876,
29912,
1012,
29876,
29905,
1983,
2863,
3583,
29876,
29912,
1012,
29876,
4286,
4830,
29898,
13,
18884,
10417,
29918,
4299,
29892,
13,
18884,
11297,
29876,
4286,
7122,
29898,
710,
29898,
29879,
29897,
363,
269,
297,
2752,
29918,
9794,
29897,
13,
18884,
1723,
13,
9651,
1723,
13,
4706,
1583,
29889,
21707,
29889,
8382,
29898,
13,
9651,
285,
29915,
3601,
29884,
1962,
4516,
29901,
426,
4905,
29918,
3972,
1012,
1983,
326,
29884,
3309,
3790,
29873,
29918,
3601,
29884,
10162,
13,
9651,
1723,
13,
4706,
396,
1065,
278,
1027,
9183,
13,
4706,
1480,
29918,
1445,
353,
274,
16434,
29889,
657,
29918,
1188,
29918,
1445,
580,
13,
4706,
1583,
29889,
21707,
29889,
3888,
29898,
29888,
29915,
14669,
12183,
304,
934,
426,
1188,
29918,
1445,
29913,
1495,
13,
4706,
411,
1480,
29918,
517,
29918,
1445,
29898,
13,
18884,
934,
2084,
29922,
1188,
29918,
1445,
29892,
13,
18884,
3233,
2433,
18525,
742,
13,
18884,
11262,
29918,
1228,
29918,
3179,
9306,
29922,
8824,
13,
462,
1125,
13,
9651,
1962,
29918,
13073,
353,
1027,
29884,
29889,
4905,
29918,
4703,
29898,
3972,
2084,
29922,
4905,
29918,
3972,
29897,
13,
9651,
411,
1962,
29918,
13073,
29889,
3150,
7295,
13,
18884,
1583,
29889,
21707,
29889,
3888,
29898,
13,
462,
1678,
285,
29908,
3539,
1962,
304,
426,
4905,
29918,
13073,
29889,
4632,
2084,
27195,
13,
18884,
396,
4078,
278,
2295,
934,
408,
612,
23956,
13,
18884,
2295,
29918,
1445,
2084,
353,
1962,
29918,
13073,
29889,
5675,
29918,
4905,
29918,
9507,
29898,
13,
462,
1678,
525,
25027,
371,
1113,
742,
15300,
25162,
1495,
13,
18884,
411,
1722,
29898,
2917,
29918,
1445,
2084,
29892,
525,
29893,
1495,
408,
1701,
29901,
13,
462,
1678,
2295,
353,
3509,
29889,
24535,
8552,
29898,
1311,
29889,
2917,
29897,
13,
462,
1678,
364,
5504,
29898,
2917,
29892,
1583,
29889,
3601,
29884,
29918,
2917,
29889,
517,
29918,
2917,
3101,
13,
462,
1678,
1583,
29889,
25162,
29918,
15070,
29898,
2917,
29892,
1701,
29897,
13,
18884,
411,
1027,
29884,
29889,
1524,
29918,
14513,
29918,
4703,
29898,
16859,
29897,
408,
313,
1524,
29918,
14513,
29892,
260,
29918,
305,
18801,
1125,
13,
462,
1678,
396,
4078,
10417,
1904,
12700,
13,
462,
1678,
1962,
29918,
13073,
29889,
3539,
29918,
20698,
29918,
7299,
29898,
13,
462,
4706,
10417,
29922,
20698,
29918,
4299,
29892,
1027,
29884,
29918,
2917,
29922,
16859,
29897,
13,
462,
1678,
396,
4078,
1027,
9183,
12700,
13,
462,
1678,
1962,
29918,
13073,
29889,
3539,
29918,
3601,
29918,
7299,
29898,
3601,
29884,
29918,
2917,
29922,
16859,
29897,
13,
13,
462,
1678,
396,
1065,
1027,
9183,
363,
1269,
19875,
322,
4078,
278,
848,
13,
462,
1678,
302,
29918,
305,
18801,
353,
7431,
29898,
29873,
29918,
305,
18801,
29897,
13,
462,
1678,
363,
4583,
29892,
260,
297,
26985,
29898,
29873,
29918,
305,
18801,
1125,
13,
462,
4706,
1583,
29889,
21707,
29889,
3888,
29898,
13,
462,
9651,
285,
29908,
3601,
5987,
19875,
426,
455,
6822,
29912,
29876,
29918,
305,
18801,
29913,
376,
13,
462,
9651,
285,
29908,
29873,
29918,
1195,
3790,
29873,
29889,
1195,
28296,
260,
29918,
3317,
3790,
29873,
29889,
3317,
580,
27195,
13,
462,
4706,
1962,
29918,
13073,
29889,
3539,
29918,
3601,
29918,
1272,
29898,
1524,
29918,
14513,
29898,
29873,
876,
13,
4706,
736,
1962,
29918,
3972,
13,
13,
1678,
822,
6492,
29898,
1311,
29892,
1134,
29892,
3579,
19290,
1125,
13,
4706,
9995,
9984,
6492,
310,
1134,
421,
1853,
29952,
1213,
15945,
13,
4706,
565,
1134,
451,
297,
24580,
29918,
1727,
6020,
29901,
13,
9651,
12020,
7865,
2392,
29898,
13,
18884,
285,
29908,
13919,
6492,
1134,
426,
1853,
1836,
376,
13,
18884,
285,
29908,
27635,
4072,
29901,
426,
26762,
29918,
1727,
6020,
29889,
8149,
580,
27195,
13,
4706,
6492,
357,
353,
24580,
29918,
1727,
6020,
29961,
1853,
1822,
3166,
29918,
8977,
29898,
19290,
29897,
13,
4706,
736,
6492,
357,
29898,
1311,
29889,
3601,
29884,
29918,
2917,
29897,
13,
13,
13,
29937,
1207,
263,
1051,
310,
599,
1027,
29884,
2295,
2944,
4072,
13,
29918,
2997,
29879,
353,
1051,
29898,
2997,
29879,
2141,
5975,
3101,
13,
3601,
29884,
29918,
2917,
29918,
667,
29918,
8768,
353,
1051,
580,
13,
1454,
325,
297,
903,
2997,
29879,
29901,
13,
1678,
565,
338,
29918,
1272,
1990,
29898,
29894,
29897,
322,
756,
5552,
29898,
29894,
29892,
525,
11010,
29374,
13,
4706,
1027,
29884,
29918,
2917,
29918,
667,
29918,
8768,
29889,
4397,
29898,
29894,
29897,
13,
1678,
25342,
338,
8758,
29898,
29894,
29892,
12782,
22579,
1125,
13,
4706,
1027,
29884,
29918,
2917,
29918,
667,
29918,
8768,
29889,
4397,
29898,
29894,
29897,
13,
2
] |
ticket/migrations/0011_ticketmeantimes.py | aessex24/rindr | 1 | 186681 | <reponame>aessex24/rindr
# Generated by Django 3.2.8 on 2021-11-01 19:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ticket', '0010_ticket_archived'),
]
operations = [
migrations.CreateModel(
name='TicketMeanTimes',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mean_response', models.DurationField(verbose_name='Mean Time to Response')),
('ticket_count', models.IntegerField(verbose_name='Ticket Count')),
],
options={
'db_table': 'ticket_meantimes',
'managed': False,
},
),
]
| [
1,
529,
276,
1112,
420,
29958,
29874,
5340,
29916,
29906,
29946,
29914,
29878,
513,
29878,
13,
29937,
3251,
630,
491,
15337,
29871,
29941,
29889,
29906,
29889,
29947,
373,
29871,
29906,
29900,
29906,
29896,
29899,
29896,
29896,
29899,
29900,
29896,
29871,
29896,
29929,
29901,
29906,
29945,
13,
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,
29873,
8522,
742,
525,
29900,
29900,
29896,
29900,
29918,
29873,
8522,
29918,
1279,
2347,
5477,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
4391,
3195,
29898,
13,
9651,
1024,
2433,
29911,
8522,
6816,
273,
29164,
742,
13,
9651,
4235,
11759,
13,
18884,
6702,
333,
742,
4733,
29889,
6970,
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,
13,
18884,
6702,
12676,
29918,
5327,
742,
4733,
29889,
18984,
3073,
29898,
369,
15828,
29918,
978,
2433,
6816,
273,
5974,
304,
13291,
1495,
511,
13,
18884,
6702,
29873,
8522,
29918,
2798,
742,
4733,
29889,
7798,
3073,
29898,
369,
15828,
29918,
978,
2433,
29911,
8522,
3917,
1495,
511,
13,
9651,
21251,
13,
9651,
3987,
3790,
13,
18884,
525,
2585,
29918,
2371,
2396,
525,
29873,
8522,
29918,
1004,
424,
1355,
742,
13,
18884,
525,
25240,
2396,
7700,
29892,
13,
9651,
2981,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
Python-Advanced/multidimensional_elements_exercise/2x2_squares_in_matrix.py | Xamaneone/SoftUni-Intro | 0 | 143428 | <gh_stars>0
def read_matrix():
(rows, columns) = map(int, input().split(" "))
matrix = []
for r in range(rows):
row = input().split(" ")
matrix.append(row)
return matrix, rows, columns
def subsqares_count(matrix,subsquare, rows, columns):
count = 0
for r in range(rows - (subsquare - 1)):
for c in range(columns - (subsquare - 1)):
data = set()
for r2 in range(0, subsquare):
for c2 in range(0, subsquare):
data.add(matrix[r + r2][c + c2])
if len(data) == 1:
count += 1
return count
matrix, rows, columns = read_matrix()
subsquare = 2
print(subsqares_count(matrix, subsquare, rows, columns))
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
1753,
1303,
29918,
5344,
7295,
13,
1678,
313,
5727,
29892,
4341,
29897,
353,
2910,
29898,
524,
29892,
1881,
2141,
5451,
703,
376,
876,
13,
1678,
4636,
353,
5159,
13,
1678,
363,
364,
297,
3464,
29898,
5727,
1125,
13,
4706,
1948,
353,
1881,
2141,
5451,
703,
16521,
13,
4706,
4636,
29889,
4397,
29898,
798,
29897,
13,
1678,
736,
4636,
29892,
4206,
29892,
4341,
13,
13,
1753,
1014,
3044,
5114,
29918,
2798,
29898,
5344,
29892,
1491,
17619,
29892,
4206,
29892,
4341,
1125,
13,
1678,
2302,
353,
29871,
29900,
13,
1678,
363,
364,
297,
3464,
29898,
5727,
448,
313,
1491,
17619,
448,
29871,
29896,
22164,
13,
4706,
363,
274,
297,
3464,
29898,
13099,
448,
313,
1491,
17619,
448,
29871,
29896,
22164,
13,
9651,
848,
353,
731,
580,
13,
9651,
363,
364,
29906,
297,
3464,
29898,
29900,
29892,
11684,
4718,
1125,
13,
18884,
363,
274,
29906,
297,
3464,
29898,
29900,
29892,
11684,
4718,
1125,
13,
462,
1678,
848,
29889,
1202,
29898,
5344,
29961,
29878,
718,
364,
29906,
3816,
29883,
718,
274,
29906,
2314,
13,
9651,
565,
7431,
29898,
1272,
29897,
1275,
29871,
29896,
29901,
13,
18884,
2302,
4619,
29871,
29896,
13,
1678,
736,
2302,
13,
5344,
29892,
4206,
29892,
4341,
353,
1303,
29918,
5344,
580,
13,
1491,
17619,
353,
29871,
29906,
13,
2158,
29898,
1491,
3044,
5114,
29918,
2798,
29898,
5344,
29892,
11684,
4718,
29892,
4206,
29892,
4341,
876,
13,
13,
13,
2
] |
test.py | markmelnic/Car-Indexes-Scraper | 2 | 54542 |
import os
import json
import subprocess
import mobile_de
import autoscout24_ch
import anibis_ch
if __name__ == '__main__':
try:
#autoscout24_ch.scrape_makes()
#autoscout24_ch.scrape_models()
#mobile_de.scrape_makes()
#mobile_de.scrape_models()
anibis_ch.scrape_makes()
# check "models": []
except KeyboardInterrupt:
exit(0)
except json.decoder.JSONDecodeError:
os.remove('makes.json')
subprocess.run('python test.py')
| [
1,
29871,
13,
5215,
2897,
13,
5215,
4390,
13,
5215,
1014,
5014,
13,
13,
5215,
10426,
29918,
311,
13,
5215,
1120,
359,
13147,
29906,
29946,
29918,
305,
13,
5215,
385,
747,
275,
29918,
305,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
13,
1678,
1018,
29901,
13,
4706,
396,
1300,
359,
13147,
29906,
29946,
29918,
305,
29889,
1557,
336,
412,
29918,
29885,
6926,
580,
13,
4706,
396,
1300,
359,
13147,
29906,
29946,
29918,
305,
29889,
1557,
336,
412,
29918,
9794,
580,
13,
4706,
396,
16769,
29918,
311,
29889,
1557,
336,
412,
29918,
29885,
6926,
580,
13,
4706,
396,
16769,
29918,
311,
29889,
1557,
336,
412,
29918,
9794,
580,
13,
4706,
385,
747,
275,
29918,
305,
29889,
1557,
336,
412,
29918,
29885,
6926,
580,
13,
4706,
396,
1423,
376,
9794,
1115,
5159,
13,
1678,
5174,
7670,
3377,
4074,
6685,
29901,
13,
4706,
6876,
29898,
29900,
29897,
13,
1678,
5174,
4390,
29889,
7099,
6119,
29889,
7249,
2772,
401,
2392,
29901,
13,
4706,
2897,
29889,
5992,
877,
29885,
6926,
29889,
3126,
1495,
13,
4706,
1014,
5014,
29889,
3389,
877,
4691,
1243,
29889,
2272,
1495,
13,
2
] |
oldcode/guestbook111013.py | mdreid/dinkylink | 1 | 16638 | import os
import urllib
from google.appengine.api import users
from google.appengine.ext import ndb
import jinja2
import webapp2
from sys import argv
import datetime
import pickle
import sys
sys.path.insert(0, 'libs')
import BeautifulSoup
from bs4 import BeautifulSoup
import requests
import json
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.autoescape', 'jinja2.ext.loopcontrols'],
autoescape=True)
url = 'http://www.njtransit.com/sf/sf_servlet.srv?hdnPageAction=TrainSchedulesFrom'
pu_code = "124_PRIN"
ny_code = "105_BNTN"
prs = "Princeton"
nyp = "New York Penn Station"
# get date
today = datetime.date.today()
str_date = today.__format__("%m/%d/%Y")
# trip info
toNY_dict = {'selOrigin': pu_code, 'selDestination': ny_code, 'datepicker': str_date, 'OriginDescription': prs, 'DestDescription': nyp}
toPU_dict = {'selOrigin': ny_code, 'selDestination': pu_code, 'datepicker': str_date, 'OriginDescription': nyp, 'DestDescription': prs}
# get to webpage with data for the day
with requests.Session() as re:
toNY = re.post(url, data=toNY_dict)
toPU = re.post(url, data=toPU_dict)
toPUhtml = toPU.text
toNYhtml = toNY.text
#Reads in html file and name of destination and outputs csv file with comma spliced file of train information
def scrape(html,destination):
title = str(today) + str(destination)
soup = BeautifulSoup(html)
# Improvements: instead of being so hacky with 10 search for td
# Gather all lines in table
table1 = soup.find_all("tr")
table2 = table1[10] #table1[10] contains the table of interest
table3 = table2.find_all('span')
# Create 7 lists
origin = [] #Times for departure at origin
origintrain = []
transferarrive = [] #Times for arrival at transfer
transferdepart = [] #Time for departure at transfer
transfertrain = [] #Train or bus number
destination = [] #Time of arrival at destination
total = [] #Total time of Travel
#Create 3 Columns of Text File
origin.append("Origin Departure") #Times for departure at origin
origintrain.append("Origin Train")
transferarrive.append("Transfer Arrival") #Times for arrival at transfer
transferdepart.append("Transfer Departure") #Time for departure at transfer
transfertrain.append("Transfer Train or Bus")
destination.append("Destination Arrival") #Time of arrival at destination
total.append("Total Travel Time") #Total time of Travel
#Store 4 columns into 4 lists
#Regex and pull approapriate data
for i in range(4, len(table3)-3, 4):
#origin.append(str(table3[i].text)[0:len(table3[i].text)])
origin.append(str(table3[i].text)[0:8])
origintrain.append(str(table3[i].text)[-5:])
transferarrive.append(str(table3[i+1].text)[7:15])
transferdepart.append(str(table3[i+1].text)[39:48])
transfertrain.append(str(table3[i+1].text)[-5:])
destination.append(str(table3[i+2].text)[0:len(table3[i+2].text)])
total.append(str(table3[i+3].text)[0:len(table3[i+3].text)])
#text_file = open(str(title) + ".csv", "w")
Dict = {'origin': origin[1:], 'transferarrive' : transferarrive[1:], 'transferdepart': transferdepart[1:], 'destination':destination[1:]}
return Dict
#Create csv files for to Princeton and to New York
toPUDict = scrape(toPUhtml, 'PU')
toNYDict = scrape(toNYhtml, 'NY')
class njdata(ndb.Model):
"""Models an individual Guestbook entry with author, content, and date."""
originstring = ndb.StringProperty(repeated = True)
transferarrivestring = ndb.StringProperty(repeated = True)
transferdepartstring = ndb.StringProperty(repeated = True)
destinationstring = ndb.StringProperty(repeated = True)
date = ndb.DateTimeProperty(auto_now_add=True) #Need date to get most recent data
globalPUDict = {}
class Test123(webapp2.RequestHandler):
def get(self):
toPUdata = njdata()
#toNYdata = njdata()
#toPUdata.content = pickle.dumps(toPUDict)
toPUdata.originstring = toPUDict['origin']
toPUdata.transferarrivestring = toPUDict['transferarrive']
toPUdata.transferdepartstring = toPUDict['transferdepart']
toPUdata.destinationstring = toPUDict['destination']
#Save data into data models
toPUdata.put()
#toNYdata.put()
toPUdata_query = toPUdata.query().order(-njdata.date)
a = toPUdata_query.fetch(1)
global globalPUDict
globalPUDict = {'origin': a[0].originstring, 'transferarrive': a[0].transferarrivestring, 'transferdepart': a[0].transferdepartstring, 'destination': a[0].destinationstring}
self.response.write(globalPUDict)
self.response.write(toPUDict)
class MainPage(webapp2.RequestHandler):
def get(self):
template = JINJA_ENVIRONMENT.get_template('index.html')
self.response.write(template.render())
class ToNY(webapp2.RequestHandler):
def get(self):
template = JINJA_ENVIRONMENT.get_template('toNY.html')
self.response.write(template.render(toNYDict))
class ToPU(webapp2.RequestHandler):
def get(self):
self.response.write(globalPUDict)
template = JINJA_ENVIRONMENT.get_template('toPU.html')
self.response.write(template.render(globalPUDict))
application = webapp2.WSGIApplication([
('/', MainPage),
('/toNY', ToNY),
('/toPU', ToPU),
('/test', Test123),
], debug=True)
| [
1,
1053,
2897,
13,
5215,
3142,
1982,
13,
13,
3166,
5386,
29889,
932,
10599,
29889,
2754,
1053,
4160,
13,
3166,
5386,
29889,
932,
10599,
29889,
1062,
1053,
29871,
299,
29890,
13,
13,
5215,
432,
262,
1764,
29906,
13,
5215,
1856,
932,
29906,
13,
13,
3166,
10876,
1053,
1852,
29894,
13,
13,
5215,
12865,
13,
5215,
5839,
280,
29871,
13,
13,
5215,
10876,
13,
9675,
29889,
2084,
29889,
7851,
29898,
29900,
29892,
525,
10254,
1495,
13,
13,
5215,
25685,
29903,
1132,
13,
3166,
24512,
29946,
1053,
25685,
29903,
1132,
13,
5215,
7274,
13,
13,
5215,
4390,
13,
13,
29967,
1177,
29967,
29909,
29918,
25838,
8193,
1164,
13780,
353,
432,
262,
1764,
29906,
29889,
18649,
29898,
13,
1678,
23466,
29922,
28789,
1764,
29906,
29889,
2283,
3924,
10036,
29898,
359,
29889,
2084,
29889,
25721,
22168,
1445,
1649,
8243,
13,
1678,
17752,
29922,
1839,
28789,
1764,
29906,
29889,
1062,
29889,
6921,
21587,
742,
525,
28789,
1764,
29906,
29889,
1062,
29889,
7888,
26255,
7464,
13,
1678,
4469,
21587,
29922,
5574,
29897,
13,
13,
2271,
353,
525,
1124,
597,
1636,
29889,
29876,
29926,
3286,
277,
29889,
510,
29914,
4668,
29914,
4668,
29918,
12144,
29889,
29879,
15291,
29973,
29882,
5200,
5074,
4276,
29922,
5323,
262,
4504,
287,
2540,
4591,
29915,
13,
3746,
29918,
401,
353,
376,
29896,
29906,
29946,
29918,
10593,
1177,
29908,
13,
1460,
29918,
401,
353,
376,
29896,
29900,
29945,
29918,
29933,
20321,
29940,
29908,
13,
558,
29879,
353,
376,
4040,
3742,
20666,
29908,
13,
1460,
29886,
353,
376,
4373,
3088,
349,
2108,
12039,
29908,
13,
13,
29937,
679,
2635,
13,
27765,
353,
12865,
29889,
1256,
29889,
27765,
580,
13,
710,
29918,
1256,
353,
9826,
17255,
4830,
1649,
11702,
29885,
22584,
29881,
22584,
29979,
1159,
13,
13,
29937,
17487,
5235,
13,
517,
29940,
29979,
29918,
8977,
353,
11117,
2838,
23182,
2396,
2653,
29918,
401,
29892,
525,
2838,
14994,
3381,
2396,
7098,
29918,
401,
29892,
525,
1256,
13908,
2396,
851,
29918,
1256,
29892,
525,
23182,
9868,
2396,
544,
29879,
29892,
525,
14994,
9868,
2396,
302,
1478,
29913,
13,
517,
7056,
29918,
8977,
353,
11117,
2838,
23182,
2396,
7098,
29918,
401,
29892,
525,
2838,
14994,
3381,
2396,
2653,
29918,
401,
29892,
525,
1256,
13908,
2396,
851,
29918,
1256,
29892,
525,
23182,
9868,
2396,
302,
1478,
29892,
525,
14994,
9868,
2396,
544,
29879,
29913,
13,
13,
29937,
679,
304,
24499,
411,
848,
363,
278,
2462,
13,
2541,
7274,
29889,
7317,
580,
408,
337,
29901,
13,
1678,
304,
29940,
29979,
353,
337,
29889,
2490,
29898,
2271,
29892,
848,
29922,
517,
29940,
29979,
29918,
8977,
29897,
13,
1678,
304,
7056,
353,
337,
29889,
2490,
29898,
2271,
29892,
848,
29922,
517,
7056,
29918,
8977,
29897,
13,
13,
517,
7056,
1420,
353,
304,
7056,
29889,
726,
13,
517,
29940,
29979,
1420,
353,
304,
29940,
29979,
29889,
726,
13,
13,
13,
29937,
6359,
29879,
297,
3472,
934,
322,
1024,
310,
12551,
322,
14391,
11799,
934,
411,
16694,
805,
506,
287,
934,
310,
7945,
2472,
13,
1753,
24559,
412,
29898,
1420,
29892,
23848,
1125,
13,
1678,
3611,
353,
851,
29898,
27765,
29897,
718,
851,
29898,
23848,
29897,
29871,
13,
13,
1678,
22300,
353,
25685,
29903,
1132,
29898,
1420,
29897,
13,
13,
1678,
396,
1954,
16123,
4110,
29901,
2012,
310,
1641,
577,
15833,
29891,
411,
29871,
29896,
29900,
2740,
363,
22599,
13,
1678,
396,
402,
1624,
599,
3454,
297,
1591,
13,
1678,
1591,
29896,
353,
22300,
29889,
2886,
29918,
497,
703,
509,
1159,
13,
1678,
1591,
29906,
353,
1591,
29896,
29961,
29896,
29900,
29962,
396,
2371,
29896,
29961,
29896,
29900,
29962,
3743,
278,
1591,
310,
4066,
13,
1678,
1591,
29941,
353,
1591,
29906,
29889,
2886,
29918,
497,
877,
9653,
1495,
13,
13,
1678,
396,
6204,
29871,
29955,
8857,
13,
1678,
3978,
353,
5159,
396,
29164,
363,
25619,
472,
3978,
13,
1678,
1677,
524,
6038,
353,
5159,
13,
1678,
6782,
279,
4401,
353,
5159,
396,
29164,
363,
18517,
472,
6782,
29871,
13,
1678,
6782,
311,
1595,
353,
5159,
396,
2481,
363,
25619,
472,
6782,
13,
1678,
6782,
14968,
353,
5159,
396,
5323,
262,
470,
3593,
1353,
13,
1678,
12551,
353,
5159,
396,
2481,
310,
18517,
472,
12551,
13,
1678,
3001,
353,
5159,
396,
11536,
931,
310,
3201,
955,
13,
13,
1678,
396,
4391,
29871,
29941,
12481,
29879,
310,
3992,
3497,
13,
1678,
3978,
29889,
4397,
703,
23182,
23242,
545,
1159,
396,
29164,
363,
25619,
472,
3978,
13,
1678,
1677,
524,
6038,
29889,
4397,
703,
23182,
28186,
1159,
13,
1678,
6782,
279,
4401,
29889,
4397,
703,
4300,
571,
826,
15081,
1159,
396,
29164,
363,
18517,
472,
6782,
29871,
13,
1678,
6782,
311,
1595,
29889,
4397,
703,
4300,
571,
23242,
545,
1159,
396,
2481,
363,
25619,
472,
6782,
13,
1678,
6782,
14968,
29889,
4397,
703,
4300,
571,
28186,
470,
8406,
1159,
13,
1678,
12551,
29889,
4397,
703,
14994,
3381,
826,
15081,
1159,
396,
2481,
310,
18517,
472,
12551,
13,
1678,
3001,
29889,
4397,
703,
11536,
3201,
955,
5974,
1159,
396,
11536,
931,
310,
3201,
955,
13,
13,
1678,
396,
9044,
29871,
29946,
4341,
964,
29871,
29946,
8857,
13,
1678,
396,
4597,
735,
322,
8206,
2134,
481,
374,
403,
848,
13,
13,
1678,
363,
474,
297,
3464,
29898,
29946,
29892,
7431,
29898,
2371,
29941,
6817,
29941,
29892,
29871,
29946,
1125,
13,
308,
13,
4706,
396,
12574,
29889,
4397,
29898,
710,
29898,
2371,
29941,
29961,
29875,
1822,
726,
9601,
29900,
29901,
2435,
29898,
2371,
29941,
29961,
29875,
1822,
726,
29897,
2314,
13,
4706,
3978,
29889,
4397,
29898,
710,
29898,
2371,
29941,
29961,
29875,
1822,
726,
9601,
29900,
29901,
29947,
2314,
13,
4706,
1677,
524,
6038,
29889,
4397,
29898,
710,
29898,
2371,
29941,
29961,
29875,
1822,
726,
9601,
29899,
29945,
29901,
2314,
13,
13,
4706,
6782,
279,
4401,
29889,
4397,
29898,
710,
29898,
2371,
29941,
29961,
29875,
29974,
29896,
1822,
726,
9601,
29955,
29901,
29896,
29945,
2314,
13,
4706,
6782,
311,
1595,
29889,
4397,
29898,
710,
29898,
2371,
29941,
29961,
29875,
29974,
29896,
1822,
726,
9601,
29941,
29929,
29901,
29946,
29947,
2314,
13,
4706,
6782,
14968,
29889,
4397,
29898,
710,
29898,
2371,
29941,
29961,
29875,
29974,
29896,
1822,
726,
9601,
29899,
29945,
29901,
2314,
13,
13,
4706,
12551,
29889,
4397,
29898,
710,
29898,
2371,
29941,
29961,
29875,
29974,
29906,
1822,
726,
9601,
29900,
29901,
2435,
29898,
2371,
29941,
29961,
29875,
29974,
29906,
1822,
726,
29897,
2314,
13,
13,
4706,
3001,
29889,
4397,
29898,
710,
29898,
2371,
29941,
29961,
29875,
29974,
29941,
1822,
726,
9601,
29900,
29901,
2435,
29898,
2371,
29941,
29961,
29875,
29974,
29941,
1822,
726,
29897,
2314,
13,
13,
1678,
396,
726,
29918,
1445,
353,
1722,
29898,
710,
29898,
3257,
29897,
718,
11393,
7638,
613,
376,
29893,
1159,
13,
13,
1678,
360,
919,
353,
11117,
12574,
2396,
3978,
29961,
29896,
29901,
1402,
525,
3286,
571,
279,
4401,
29915,
584,
6782,
279,
4401,
29961,
29896,
29901,
1402,
525,
3286,
571,
311,
1595,
2396,
6782,
311,
1595,
29961,
29896,
29901,
1402,
525,
23848,
2396,
23848,
29961,
29896,
29901,
12258,
13,
13,
1678,
736,
360,
919,
13,
13,
29937,
4391,
11799,
2066,
363,
304,
1588,
3742,
20666,
322,
304,
1570,
3088,
13,
517,
7056,
21533,
353,
24559,
412,
29898,
517,
7056,
1420,
29892,
525,
7056,
1495,
13,
517,
29940,
29979,
21533,
353,
24559,
412,
29898,
517,
29940,
29979,
1420,
29892,
525,
29940,
29979,
1495,
13,
13,
1990,
20199,
1272,
29898,
299,
29890,
29889,
3195,
1125,
13,
1678,
9995,
23785,
385,
5375,
2088,
342,
2909,
6251,
411,
4148,
29892,
2793,
29892,
322,
2635,
1213,
15945,
13,
1678,
3978,
1807,
353,
29871,
299,
29890,
29889,
1231,
4854,
29898,
276,
412,
630,
353,
5852,
29897,
29871,
13,
1678,
6782,
279,
1150,
342,
5393,
353,
29871,
299,
29890,
29889,
1231,
4854,
29898,
276,
412,
630,
353,
5852,
29897,
29871,
13,
1678,
6782,
311,
1595,
1807,
353,
29871,
299,
29890,
29889,
1231,
4854,
29898,
276,
412,
630,
353,
5852,
29897,
29871,
13,
1678,
12551,
1807,
353,
29871,
299,
29890,
29889,
1231,
4854,
29898,
276,
412,
630,
353,
5852,
29897,
13,
1678,
2635,
353,
29871,
299,
29890,
29889,
11384,
4854,
29898,
6921,
29918,
3707,
29918,
1202,
29922,
5574,
29897,
396,
8139,
287,
2635,
304,
679,
1556,
7786,
848,
13,
13,
10945,
7056,
21533,
353,
6571,
13,
13,
1990,
4321,
29896,
29906,
29941,
29898,
2676,
932,
29906,
29889,
3089,
4598,
1125,
13,
13,
1678,
822,
679,
29898,
1311,
1125,
13,
4706,
304,
7056,
1272,
353,
20199,
1272,
580,
13,
4706,
396,
517,
29940,
29979,
1272,
353,
20199,
1272,
580,
13,
13,
4706,
396,
517,
7056,
1272,
29889,
3051,
353,
5839,
280,
29889,
29881,
17204,
29898,
517,
7056,
21533,
29897,
13,
4706,
304,
7056,
1272,
29889,
12574,
1807,
353,
304,
7056,
21533,
1839,
12574,
2033,
13,
4706,
304,
7056,
1272,
29889,
3286,
571,
279,
1150,
342,
5393,
353,
304,
7056,
21533,
1839,
3286,
571,
279,
4401,
2033,
13,
4706,
304,
7056,
1272,
29889,
3286,
571,
311,
1595,
1807,
353,
304,
7056,
21533,
1839,
3286,
571,
311,
1595,
2033,
13,
4706,
304,
7056,
1272,
29889,
23848,
1807,
353,
304,
7056,
21533,
1839,
23848,
2033,
13,
13,
4706,
396,
11371,
848,
964,
848,
4733,
13,
4706,
304,
7056,
1272,
29889,
649,
580,
13,
4706,
396,
517,
29940,
29979,
1272,
29889,
649,
580,
13,
4706,
304,
7056,
1272,
29918,
1972,
353,
304,
7056,
1272,
29889,
1972,
2141,
2098,
6278,
29876,
29926,
1272,
29889,
1256,
29897,
13,
4706,
263,
353,
304,
7056,
1272,
29918,
1972,
29889,
9155,
29898,
29896,
29897,
13,
13,
4706,
5534,
5534,
7056,
21533,
13,
4706,
5534,
7056,
21533,
353,
11117,
12574,
2396,
263,
29961,
29900,
1822,
12574,
1807,
29892,
525,
3286,
571,
279,
4401,
2396,
263,
29961,
29900,
1822,
3286,
571,
279,
1150,
342,
5393,
29892,
525,
3286,
571,
311,
1595,
2396,
263,
29961,
29900,
1822,
3286,
571,
311,
1595,
1807,
29892,
525,
23848,
2396,
263,
29961,
29900,
1822,
23848,
1807,
29913,
13,
13,
4706,
1583,
29889,
5327,
29889,
3539,
29898,
10945,
7056,
21533,
29897,
13,
4706,
1583,
29889,
5327,
29889,
3539,
29898,
517,
7056,
21533,
29897,
13,
13,
13,
1990,
4241,
5074,
29898,
2676,
932,
29906,
29889,
3089,
4598,
1125,
13,
13,
1678,
822,
679,
29898,
1311,
1125,
13,
13,
4706,
4472,
353,
435,
1177,
29967,
29909,
29918,
25838,
8193,
1164,
13780,
29889,
657,
29918,
6886,
877,
2248,
29889,
1420,
1495,
13,
4706,
1583,
29889,
5327,
29889,
3539,
29898,
6886,
29889,
9482,
3101,
13,
13,
13,
1990,
1763,
29940,
29979,
29898,
2676,
932,
29906,
29889,
3089,
4598,
1125,
13,
13,
1678,
822,
679,
29898,
1311,
1125,
13,
13,
4706,
4472,
353,
435,
1177,
29967,
29909,
29918,
25838,
8193,
1164,
13780,
29889,
657,
29918,
6886,
877,
517,
29940,
29979,
29889,
1420,
1495,
13,
4706,
1583,
29889,
5327,
29889,
3539,
29898,
6886,
29889,
9482,
29898,
517,
29940,
29979,
21533,
876,
13,
13,
1990,
1763,
7056,
29898,
2676,
932,
29906,
29889,
3089,
4598,
1125,
13,
13,
1678,
822,
679,
29898,
1311,
1125,
13,
13,
4706,
1583,
29889,
5327,
29889,
3539,
29898,
10945,
7056,
21533,
29897,
13,
4706,
4472,
353,
435,
1177,
29967,
29909,
29918,
25838,
8193,
1164,
13780,
29889,
657,
29918,
6886,
877,
517,
7056,
29889,
1420,
1495,
13,
4706,
1583,
29889,
5327,
29889,
3539,
29898,
6886,
29889,
9482,
29898,
10945,
7056,
21533,
876,
13,
13,
6214,
353,
1856,
932,
29906,
29889,
7811,
29954,
29902,
4873,
4197,
13,
1678,
6702,
29914,
742,
4241,
5074,
511,
13,
1678,
6702,
29914,
517,
29940,
29979,
742,
1763,
29940,
29979,
511,
13,
1678,
6702,
29914,
517,
7056,
742,
1763,
7056,
511,
13,
1678,
6702,
29914,
1688,
742,
4321,
29896,
29906,
29941,
511,
13,
1402,
4744,
29922,
5574,
29897,
13,
2
] |
q2/1_Graph/pair_count.py | PostQuantum/Buckyball-Ising-Model | 8 | 108937 | import numpy as np
def count(LM):
co = 0
if LM.shape[0]>2:
index = np.argwhere(LM==1)[:5]
for it in index:
lm_ = np.delete(LM,it[0],0)
lm_ = np.delete(lm_,it[1]-1,0)
lm_ = np.delete(lm_,it[0],1)
lm = np.delete(lm_,it[1]-1,1)
LM[it[0],it[1]] = 0
LM[it[1],it[0]] = 0
co += count(lm)
elif LM.shape[0]==2:
if LM[0,0]==0 and LM[1,1]==0 and LM[0,1]==1 and LM[1,0]==1:
co = 1
else:
co = 0
return co
if __name__ == "__main__":
LMn = [[0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0],
[0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1],
[1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0],
[0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1],
[1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0],
[1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1],
[0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0],
[0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1],
[1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0],
[1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1],
[0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0],
[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]]
LMn = np.array(LMn)
print("pair_count = ",count(LMn))
| [
1,
1053,
12655,
408,
7442,
13,
13,
1753,
2302,
29898,
26369,
1125,
13,
1678,
1302,
353,
29871,
29900,
13,
1678,
565,
365,
29924,
29889,
12181,
29961,
29900,
29962,
29958,
29906,
29901,
13,
4706,
2380,
353,
7442,
29889,
1191,
3062,
29898,
26369,
1360,
29896,
29897,
7503,
29945,
29962,
13,
4706,
363,
372,
297,
2380,
29901,
13,
9651,
301,
29885,
29918,
353,
7442,
29889,
8143,
29898,
26369,
29892,
277,
29961,
29900,
1402,
29900,
29897,
13,
9651,
301,
29885,
29918,
353,
7442,
29889,
8143,
29898,
21457,
3383,
277,
29961,
29896,
29962,
29899,
29896,
29892,
29900,
29897,
13,
9651,
301,
29885,
29918,
353,
7442,
29889,
8143,
29898,
21457,
3383,
277,
29961,
29900,
1402,
29896,
29897,
13,
9651,
301,
29885,
353,
7442,
29889,
8143,
29898,
21457,
3383,
277,
29961,
29896,
29962,
29899,
29896,
29892,
29896,
29897,
13,
308,
13,
9651,
365,
29924,
29961,
277,
29961,
29900,
1402,
277,
29961,
29896,
5262,
353,
29871,
29900,
13,
9651,
365,
29924,
29961,
277,
29961,
29896,
1402,
277,
29961,
29900,
5262,
353,
29871,
29900,
13,
308,
13,
9651,
1302,
4619,
2302,
29898,
21457,
29897,
13,
268,
13,
1678,
25342,
365,
29924,
29889,
12181,
29961,
29900,
29962,
1360,
29906,
29901,
13,
4706,
565,
365,
29924,
29961,
29900,
29892,
29900,
29962,
1360,
29900,
322,
365,
29924,
29961,
29896,
29892,
29896,
29962,
1360,
29900,
322,
365,
29924,
29961,
29900,
29892,
29896,
29962,
1360,
29896,
322,
365,
29924,
29961,
29896,
29892,
29900,
29962,
1360,
29896,
29901,
13,
9651,
1302,
353,
29871,
29896,
13,
4706,
1683,
29901,
13,
9651,
1302,
353,
29871,
29900,
13,
268,
13,
1678,
736,
1302,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
365,
29924,
29876,
353,
5519,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
1402,
29871,
13,
3986,
518,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
1402,
29871,
13,
3986,
518,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
1402,
29871,
13,
3986,
518,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
1402,
29871,
13,
3986,
518,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
1402,
29871,
13,
3986,
518,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
1402,
29871,
13,
3986,
518,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
1402,
29871,
13,
3986,
518,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
1402,
29871,
13,
3986,
518,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
1402,
29871,
13,
3986,
518,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
1402,
29871,
13,
3986,
518,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
29892,
29871,
29900,
1402,
29871,
13,
3986,
518,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29896,
29892,
29871,
29900,
29892,
29871,
29900,
5262,
13,
268,
13,
1678,
365,
29924,
29876,
353,
7442,
29889,
2378,
29898,
26369,
29876,
29897,
13,
1678,
1596,
703,
18784,
29918,
2798,
353,
9162,
2798,
29898,
26369,
29876,
876,
13,
2
] |
webrecorder/test/test_colls_api.py | ssteo/webrecorder | 1,217 | 150207 | from datetime import datetime
import os
from .testutils import FullStackTests
# ============================================================================
class TestWebRecCollsAPI(FullStackTests):
@classmethod
def setup_class(cls):
super(TestWebRecCollsAPI, cls).setup_class()
def test_create_anon_coll(self):
res = self.testapp.post_json('/api/v1/collections?user={user}'.format(user=self.anon_user), params={'title': 'Temp'})
assert self.testapp.cookies['__test_sesh'] != ''
assert res.json['collection']['id'] == 'temp'
assert res.json['collection']['title'] == 'Temp'
def test_create_anon_coll_dup_error(self):
res = self.testapp.post_json('/api/v1/collections?user={user}'.format(user=self.anon_user),
params={'title': 'Temp'}, status=400)
assert self.testapp.cookies['__test_sesh'] != ''
assert res.json == {'error': 'duplicate_name'}
def test_get_anon_coll(self):
res = self.testapp.get('/api/v1/collection/temp?user={user}'.format(user=self.anon_user))
assert res.json['collection']
coll = res.json['collection']
assert coll['size'] == 0
assert coll['id'] == 'temp'
assert coll['slug'] == 'temp'
assert coll['title'] == 'Temp'
assert coll['slug_matched'] == True
assert coll['created_at'] <= datetime.utcnow().isoformat()
assert self.ISO_DT_RX.match(coll['created_at'])
assert self.ISO_DT_RX.match(coll['updated_at'])
assert coll['recordings'] == []
assert coll['public'] == False
assert coll['public_index'] == False
def test_get_anon_coll_wrong_user(self):
res = self.testapp.get('/api/v1/collection/temp?user=temp-ABC', status=404)
assert res.json['error'] == 'no_such_user'
def test_list_anon_collections(self):
res = self.testapp.get('/api/v1/collections?user={user}'.format(user=self.anon_user))
colls = res.json['collections']
assert len(colls) == 1
colls.sort(key=lambda x: x['id'])
assert colls[0]['id'] == 'temp'
assert colls[0]['title'] == 'Temp'
assert 'pages' not in colls[0]
assert 'recordings' not in colls[0]
assert 'lists' not in colls[0]
#assert colls[0]['download_url'] == 'http://localhost:80/{user}/temp/$download'.format(user=self.anon_user)
def test_error_no_title(self):
res = self.testapp.post_json('/api/v1/collections?user={user}'.format(user=self.anon_user), status=400)
assert res.json['error'] == 'invalid_coll_name'
def test_error_invalid_temp_title(self):
res = self.testapp.post_json('/api/v1/collections?user={user}'.format(user=self.anon_user),
params={'title': 'new'}, status=400)
assert res.json['error'] == 'invalid_temp_coll_name'
def test_error_external_not_allowed(self):
params = {'external': True,
'title': 'temp'
}
res = self.testapp.post_json('/api/v1/collections?user={user}'.format(user=self.anon_user), params=params,
status=403)
assert res.json == {'error': 'external_not_allowed'}
def test_error_no_such_coll(self):
res = self.testapp.get('/api/v1/collection/blah@$?user={user}'.format(user=self.anon_user), status=404)
assert res.json == {'error': 'no_such_collection'}
def test_error_missing_user_coll(self):
res = self.testapp.post_json('/api/v1/collections', params={'title': 'Recording'}, status=400)
assert res.json == {'error': 'no_user_specified'}
def test_error_invalid_user_coll(self):
res = self.testapp.post_json('/api/v1/collections?user=user', params={'title': 'Example'}, status=404)
assert res.json == {'error': 'no_such_user'}
def test_error_invalid_user_coll_2(self):
res = self.testapp.post_json('/api/v1/collections?user=temp$123', params={'title': 'Example'}, status=404)
assert res.json == {'error': 'no_such_user'}
def test_delete_coll(self):
res = self.testapp.delete('/api/v1/collection/temp?user={user}'.format(user=self.anon_user))
assert res.json == {'deleted_id': 'temp'}
| [
1,
515,
12865,
1053,
12865,
13,
5215,
2897,
13,
13,
3166,
869,
1688,
13239,
1053,
14846,
7264,
24376,
13,
13,
13,
29937,
1275,
9166,
9166,
9166,
9166,
4936,
1360,
13,
1990,
4321,
3609,
4789,
1625,
3137,
8787,
29898,
13658,
7264,
24376,
1125,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
6230,
29918,
1990,
29898,
25932,
1125,
13,
4706,
2428,
29898,
3057,
3609,
4789,
1625,
3137,
8787,
29892,
1067,
29879,
467,
14669,
29918,
1990,
580,
13,
13,
1678,
822,
1243,
29918,
3258,
29918,
19930,
29918,
22017,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
2490,
29918,
3126,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
29973,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
511,
8636,
3790,
29915,
3257,
2396,
525,
15637,
29915,
1800,
13,
13,
4706,
4974,
1583,
29889,
1688,
932,
29889,
15108,
583,
1839,
1649,
1688,
29918,
29879,
12094,
2033,
2804,
6629,
13,
13,
4706,
4974,
620,
29889,
3126,
1839,
10855,
16215,
333,
2033,
1275,
525,
7382,
29915,
13,
4706,
4974,
620,
29889,
3126,
1839,
10855,
16215,
3257,
2033,
1275,
525,
15637,
29915,
13,
13,
1678,
822,
1243,
29918,
3258,
29918,
19930,
29918,
22017,
29918,
20908,
29918,
2704,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
2490,
29918,
3126,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
29973,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
511,
13,
462,
462,
268,
8636,
3790,
29915,
3257,
2396,
525,
15637,
16675,
4660,
29922,
29946,
29900,
29900,
29897,
13,
13,
4706,
4974,
1583,
29889,
1688,
932,
29889,
15108,
583,
1839,
1649,
1688,
29918,
29879,
12094,
2033,
2804,
6629,
13,
13,
4706,
4974,
620,
29889,
3126,
1275,
11117,
2704,
2396,
525,
20908,
5926,
29918,
978,
10827,
13,
13,
1678,
822,
1243,
29918,
657,
29918,
19930,
29918,
22017,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
657,
11219,
2754,
29914,
29894,
29896,
29914,
10855,
29914,
7382,
29973,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
876,
13,
13,
4706,
4974,
620,
29889,
3126,
1839,
10855,
2033,
13,
4706,
5321,
353,
620,
29889,
3126,
1839,
10855,
2033,
13,
13,
4706,
4974,
5321,
1839,
2311,
2033,
1275,
29871,
29900,
13,
4706,
4974,
5321,
1839,
333,
2033,
1275,
525,
7382,
29915,
13,
4706,
4974,
5321,
1839,
29517,
2033,
1275,
525,
7382,
29915,
13,
4706,
4974,
5321,
1839,
3257,
2033,
1275,
525,
15637,
29915,
13,
4706,
4974,
5321,
1839,
29517,
29918,
4352,
287,
2033,
1275,
5852,
13,
4706,
4974,
5321,
1839,
11600,
29918,
271,
2033,
5277,
12865,
29889,
329,
29883,
3707,
2141,
10718,
4830,
580,
13,
13,
4706,
4974,
1583,
29889,
29096,
29918,
12972,
29918,
29934,
29990,
29889,
4352,
29898,
22017,
1839,
11600,
29918,
271,
11287,
13,
4706,
4974,
1583,
29889,
29096,
29918,
12972,
29918,
29934,
29990,
29889,
4352,
29898,
22017,
1839,
21402,
29918,
271,
11287,
13,
13,
4706,
4974,
5321,
1839,
11651,
886,
2033,
1275,
5159,
13,
4706,
4974,
5321,
1839,
3597,
2033,
1275,
7700,
13,
4706,
4974,
5321,
1839,
3597,
29918,
2248,
2033,
1275,
7700,
13,
13,
1678,
822,
1243,
29918,
657,
29918,
19930,
29918,
22017,
29918,
15866,
549,
29918,
1792,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
657,
11219,
2754,
29914,
29894,
29896,
29914,
10855,
29914,
7382,
29973,
1792,
29922,
7382,
29899,
19658,
742,
4660,
29922,
29946,
29900,
29946,
29897,
13,
13,
4706,
4974,
620,
29889,
3126,
1839,
2704,
2033,
1275,
525,
1217,
29918,
14565,
29918,
1792,
29915,
13,
13,
1678,
822,
1243,
29918,
1761,
29918,
19930,
29918,
29027,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
657,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
29973,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
876,
13,
13,
4706,
784,
3137,
353,
620,
29889,
3126,
1839,
29027,
2033,
13,
4706,
4974,
7431,
29898,
1054,
3137,
29897,
1275,
29871,
29896,
13,
13,
4706,
784,
3137,
29889,
6605,
29898,
1989,
29922,
2892,
921,
29901,
921,
1839,
333,
11287,
13,
13,
4706,
4974,
784,
3137,
29961,
29900,
22322,
333,
2033,
1275,
525,
7382,
29915,
13,
4706,
4974,
784,
3137,
29961,
29900,
22322,
3257,
2033,
1275,
525,
15637,
29915,
13,
4706,
4974,
525,
12292,
29915,
451,
297,
784,
3137,
29961,
29900,
29962,
13,
4706,
4974,
525,
11651,
886,
29915,
451,
297,
784,
3137,
29961,
29900,
29962,
13,
4706,
4974,
525,
21513,
29915,
451,
297,
784,
3137,
29961,
29900,
29962,
13,
4706,
396,
9294,
784,
3137,
29961,
29900,
22322,
10382,
29918,
2271,
2033,
1275,
525,
1124,
597,
7640,
29901,
29947,
29900,
19248,
1792,
6822,
7382,
13346,
10382,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
29897,
13,
13,
1678,
822,
1243,
29918,
2704,
29918,
1217,
29918,
3257,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
2490,
29918,
3126,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
29973,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
511,
4660,
29922,
29946,
29900,
29900,
29897,
13,
13,
4706,
4974,
620,
29889,
3126,
1839,
2704,
2033,
1275,
525,
20965,
29918,
22017,
29918,
978,
29915,
13,
13,
1678,
822,
1243,
29918,
2704,
29918,
20965,
29918,
7382,
29918,
3257,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
2490,
29918,
3126,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
29973,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
511,
13,
462,
462,
268,
8636,
3790,
29915,
3257,
2396,
525,
1482,
16675,
4660,
29922,
29946,
29900,
29900,
29897,
13,
13,
4706,
4974,
620,
29889,
3126,
1839,
2704,
2033,
1275,
525,
20965,
29918,
7382,
29918,
22017,
29918,
978,
29915,
13,
13,
1678,
822,
1243,
29918,
2704,
29918,
23176,
29918,
1333,
29918,
24622,
29898,
1311,
1125,
13,
4706,
8636,
353,
11117,
23176,
2396,
5852,
29892,
13,
462,
29871,
525,
3257,
2396,
525,
7382,
29915,
13,
462,
500,
13,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
2490,
29918,
3126,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
29973,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
511,
8636,
29922,
7529,
29892,
13,
462,
462,
268,
4660,
29922,
29946,
29900,
29941,
29897,
13,
13,
4706,
4974,
620,
29889,
3126,
1275,
11117,
2704,
2396,
525,
23176,
29918,
1333,
29918,
24622,
10827,
13,
13,
1678,
822,
1243,
29918,
2704,
29918,
1217,
29918,
14565,
29918,
22017,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
657,
11219,
2754,
29914,
29894,
29896,
29914,
10855,
29914,
29844,
29992,
15485,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
511,
4660,
29922,
29946,
29900,
29946,
29897,
13,
4706,
4974,
620,
29889,
3126,
1275,
11117,
2704,
2396,
525,
1217,
29918,
14565,
29918,
10855,
10827,
13,
13,
1678,
822,
1243,
29918,
2704,
29918,
27259,
29918,
1792,
29918,
22017,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
2490,
29918,
3126,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
742,
8636,
3790,
29915,
3257,
2396,
525,
4789,
3278,
16675,
4660,
29922,
29946,
29900,
29900,
29897,
13,
4706,
4974,
620,
29889,
3126,
1275,
11117,
2704,
2396,
525,
1217,
29918,
1792,
29918,
6550,
2164,
10827,
13,
13,
1678,
822,
1243,
29918,
2704,
29918,
20965,
29918,
1792,
29918,
22017,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
2490,
29918,
3126,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
29973,
1792,
29922,
1792,
742,
8636,
3790,
29915,
3257,
2396,
525,
14023,
16675,
4660,
29922,
29946,
29900,
29946,
29897,
13,
4706,
4974,
620,
29889,
3126,
1275,
11117,
2704,
2396,
525,
1217,
29918,
14565,
29918,
1792,
10827,
13,
13,
1678,
822,
1243,
29918,
2704,
29918,
20965,
29918,
1792,
29918,
22017,
29918,
29906,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
2490,
29918,
3126,
11219,
2754,
29914,
29894,
29896,
29914,
29027,
29973,
1792,
29922,
7382,
29938,
29896,
29906,
29941,
742,
8636,
3790,
29915,
3257,
2396,
525,
14023,
16675,
4660,
29922,
29946,
29900,
29946,
29897,
13,
4706,
4974,
620,
29889,
3126,
1275,
11117,
2704,
2396,
525,
1217,
29918,
14565,
29918,
1792,
10827,
13,
13,
1678,
822,
1243,
29918,
8143,
29918,
22017,
29898,
1311,
1125,
13,
4706,
620,
353,
1583,
29889,
1688,
932,
29889,
8143,
11219,
2754,
29914,
29894,
29896,
29914,
10855,
29914,
7382,
29973,
1792,
3790,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1311,
29889,
19930,
29918,
1792,
876,
13,
13,
4706,
4974,
620,
29889,
3126,
1275,
11117,
311,
22742,
29918,
333,
2396,
525,
7382,
10827,
13,
13,
2
] |
CangJie/CTC/RFAG/Module/sym/net/WCRLSTM.py | bigdata-ustc/CangJie | 2 | 1607491 | <reponame>bigdata-ustc/CangJie
# coding: utf-8
# 2020/1/2 @ tongshiwei
from longling.ML.MxnetHelper.gallery.layer.attention import \
DotProductAttentionCell
import mxnet as mx
from mxnet import gluon
from .net import EmbeddingLSTM
class WCRLSTM(EmbeddingLSTM):
def __init__(self,
net_type,
class_num, embedding_dim,
lstm_hidden=None, embedding_size=None,
embed_dropout=0.5, fc_dropout=0.5,
**kwargs):
r"""Our method: 包含词和字,以及字、词部首的网络模型"""
super(WCRLSTM, self).__init__(**kwargs)
self.word_length = None
self.character_length = None
self.lstm_hidden = lstm_hidden if lstm_hidden is not None else embedding_dim
self.net_type = net_type
with self.name_scope():
self.embedding = WCREmbedding(
word_embedding_size=embedding_size["w"],
word_radical_embedding_size=embedding_size["rw"],
char_embedding_size=embedding_size["c"],
char_radical_embedding_size=embedding_size["rc"],
embedding_dim=embedding_dim,
dropout=embed_dropout,
)
for i in range(4):
if self.net_type in ("bilstm", "bilstm_att"):
setattr(self, "rnn%s" % i,
gluon.rnn.BidirectionalCell(
gluon.rnn.LSTMCell(self.lstm_hidden),
gluon.rnn.LSTMCell(self.lstm_hidden))
)
elif self.net_type == "lstm":
setattr(
self, "rnn%s" % i, gluon.rnn.LSTMCell(self.lstm_hidden),
)
else:
raise TypeError(
"net_type should be lstm, bilstm or bilstm_att,"
" now is %s" % self.net_type
)
if self.net_type == "bilstm_att":
self.word_attention = DotProductAttentionCell(
units=self.lstm_hidden, scaled=False
)
self.char_attention = DotProductAttentionCell(
units=self.lstm_hidden, scaled=False
)
self.dropout = gluon.nn.Dropout(fc_dropout)
self.fc = gluon.nn.Dense(class_num)
def hybrid_forward(self, F, w, rw, c, rc, word_mask, charater_mask, *args, **kwargs):
word_length = self.word_length if self.word_length else len(w[0])
character_length = self.character_length if self.character_length else len(
c[0])
word_embedding, word_radical_embedding, character_embedding, character_radical_embedding = self.embedding(w, rw,
c, rc)
merge_outputs = True
if F is mx.symbol:
# 似乎 gluon 有问题, 对symbol
word_mask, charater_mask = None, None
if self.net_type == "bilstm_att":
w_e, (w_lo, w_ls, w_ro, w_rs) = getattr(self, "rnn0").unroll(
word_length, word_embedding,
merge_outputs=merge_outputs,
valid_length=word_mask
)
word_radical_embedding = \
self.word_attention(word_radical_embedding, w_e,
mask=word_mask
)[0]
wr_e, (wr_lo, wr_ls, wr_ro, wr_rs) = getattr(self, "rnn1").unroll(
word_length, word_radical_embedding,
begin_state=(w_ls, w_ls, w_rs, w_rs),
merge_outputs=merge_outputs,
valid_length=word_mask
)
c_e, (c_lo, c_ls, c_ro, c_rs) = getattr(self, "rnn2").unroll(
character_length, character_embedding,
merge_outputs=merge_outputs,
valid_length=charater_mask
)
character_radical_embedding = \
self.char_attention(character_radical_embedding, c_e,
mask=charater_mask
)[0]
cr_e, (cr_lo, cr_ls, cr_ro, cr_rs) = getattr(self, "rnn3").unroll(
character_length, character_radical_embedding,
begin_state=(c_ls, c_ls, c_rs, c_rs),
merge_outputs=merge_outputs,
valid_length=charater_mask
)
attention = F.concat(
w_lo, w_ro, wr_lo, wr_ro, c_lo, c_ro, cr_lo, cr_ro
)
elif self.net_type == "bilstm":
w_e, (w_lo, w_ls, w_ro, w_rs) = getattr(self, "rnn0").unroll(
word_length, word_embedding,
merge_outputs=merge_outputs,
valid_length=word_mask
)
wr_e, (wr_lo, wr_ls, wr_ro, wr_rs) = getattr(self, "rnn1").unroll(
word_length, word_radical_embedding,
merge_outputs=merge_outputs,
valid_length=word_mask
)
c_e, (c_lo, c_ls, c_ro, c_rs) = getattr(self, "rnn2").unroll(
character_length, character_embedding,
merge_outputs=merge_outputs,
valid_length=charater_mask
)
cr_e, (cr_lo, cr_ls, cr_ro, cr_rs) = getattr(self, "rnn3").unroll(
character_length, character_radical_embedding,
merge_outputs=merge_outputs,
valid_length=charater_mask
)
attention = F.concat(
w_lo, w_ro, wr_lo, wr_ro, c_lo, c_ro, cr_lo, cr_ro
)
elif self.net_type == "lstm":
w_e, (w_o, w_s) = getattr(self, "rnn0").unroll(
word_length,
word_embedding,
merge_outputs=merge_outputs,
valid_length=word_mask
)
wr_e, (wr_o, wr_s) = getattr(self, "rnn1").unroll(
word_length,
word_radical_embedding,
merge_outputs=merge_outputs,
valid_length=word_mask
)
c_e, (c_o, c_s) = getattr(self, "rnn2").unroll(
character_length,
character_embedding,
merge_outputs=merge_outputs,
valid_length=charater_mask
)
cr_e, (cr_o, cr_s) = getattr(self, "rnn3").unroll(
character_length, character_radical_embedding,
merge_outputs=merge_outputs,
valid_length=charater_mask)
attention = F.concat(w_o, wr_o, c_o, cr_o)
else:
raise TypeError(
"net_type should be lstm, bilstm or bilstm_att,"
" now is %s" % self.net_type
)
attention = self.dropout(attention)
# attention = self.dropout(
# F.Activation(self.nn(attention), act_type='softrelu')
# )
# fc_in = self.layers_attention(attention)
fc_in = attention
return self.fc(fc_in)
def set_network_unroll(self, word_length, character_length):
self.word_length = word_length
self.character_length = character_length
class WCREmbedding(gluon.HybridBlock):
def __init__(self, word_embedding_size, word_radical_embedding_size,
char_embedding_size, char_radical_embedding_size,
embedding_dim, dropout=0.5, prefix=None,
params=None):
super(WCREmbedding, self).__init__(prefix, params)
with self.name_scope():
self.word_embedding = gluon.nn.Embedding(
word_embedding_size, embedding_dim
)
self.word_radical_embedding = gluon.nn.Embedding(
word_radical_embedding_size, embedding_dim
)
self.char_embedding = gluon.nn.Embedding(
char_embedding_size, embedding_dim
)
self.char_radical_embedding = gluon.nn.Embedding(
char_radical_embedding_size, embedding_dim
)
self.word_dropout = gluon.nn.Dropout(dropout)
self.char_dropout = gluon.nn.Dropout(dropout)
def hybrid_forward(self,
F, word_seq, word_radical_seq,
character_seq, character_radical_seq,
*args, **kwargs
):
word_embedding = self.word_embedding(word_seq)
word_radical_embedding = self.word_radical_embedding(word_radical_seq)
character_embedding = self.char_embedding(character_seq)
character_radical_embedding = self.char_radical_embedding(
character_radical_seq
)
word_embedding = self.word_dropout(word_embedding)
word_radical_embedding = self.word_dropout(word_radical_embedding)
character_embedding = self.char_dropout(character_embedding)
character_radical_embedding = self.char_dropout(
character_radical_embedding
)
return word_embedding, word_radical_embedding, character_embedding, character_radical_embedding
def set_weight(self, we, rwe, ce, rce):
self.word_embedding.weight.set_data(we)
self.word_radical_embedding.weight.set_data(rwe)
self.char_embedding.weight.set_data(ce)
self.char_radical_embedding.weight.set_data(rce)
| [
1,
529,
276,
1112,
420,
29958,
3752,
1272,
29899,
504,
29883,
29914,
29907,
574,
29967,
347,
13,
29937,
14137,
29901,
23616,
29899,
29947,
13,
29937,
29871,
29906,
29900,
29906,
29900,
29914,
29896,
29914,
29906,
732,
21861,
845,
29875,
26599,
13,
3166,
1472,
1847,
29889,
1988,
29889,
29924,
29916,
1212,
10739,
29889,
29887,
23365,
29889,
13148,
29889,
1131,
2509,
1053,
320,
13,
1678,
360,
327,
7566,
4165,
2509,
4617,
13,
5215,
286,
29916,
1212,
408,
286,
29916,
13,
3166,
286,
29916,
1212,
1053,
3144,
29884,
265,
13,
13,
3166,
869,
1212,
1053,
2812,
2580,
8497,
29931,
1254,
29924,
13,
13,
13,
1990,
399,
29907,
2241,
1254,
29924,
29898,
6026,
2580,
8497,
29931,
1254,
29924,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13,
462,
7787,
29918,
1853,
29892,
13,
462,
770,
29918,
1949,
29892,
23655,
29918,
6229,
29892,
13,
462,
24471,
29885,
29918,
10892,
29922,
8516,
29892,
23655,
29918,
2311,
29922,
8516,
29892,
13,
462,
8297,
29918,
8865,
449,
29922,
29900,
29889,
29945,
29892,
285,
29883,
29918,
8865,
449,
29922,
29900,
29889,
29945,
29892,
13,
462,
3579,
19290,
1125,
13,
4706,
364,
15945,
29908,
29949,
332,
1158,
29901,
29871,
31473,
232,
147,
174,
235,
178,
144,
30503,
30578,
30214,
30651,
31436,
30578,
30330,
235,
178,
144,
30636,
31688,
30210,
31222,
234,
190,
159,
31382,
30883,
15945,
29908,
13,
4706,
2428,
29898,
29956,
29907,
2241,
1254,
29924,
29892,
1583,
467,
1649,
2344,
12035,
1068,
19290,
29897,
13,
4706,
1583,
29889,
1742,
29918,
2848,
353,
6213,
13,
4706,
1583,
29889,
18609,
29918,
2848,
353,
6213,
13,
4706,
1583,
29889,
20155,
29885,
29918,
10892,
353,
24471,
29885,
29918,
10892,
565,
24471,
29885,
29918,
10892,
338,
451,
6213,
1683,
23655,
29918,
6229,
13,
4706,
1583,
29889,
1212,
29918,
1853,
353,
7787,
29918,
1853,
13,
13,
4706,
411,
1583,
29889,
978,
29918,
6078,
7295,
13,
9651,
1583,
29889,
17987,
8497,
353,
399,
22245,
29885,
2580,
8497,
29898,
13,
18884,
1734,
29918,
17987,
8497,
29918,
2311,
29922,
17987,
8497,
29918,
2311,
3366,
29893,
12436,
13,
18884,
1734,
29918,
3665,
936,
29918,
17987,
8497,
29918,
2311,
29922,
17987,
8497,
29918,
2311,
3366,
13975,
12436,
13,
18884,
1373,
29918,
17987,
8497,
29918,
2311,
29922,
17987,
8497,
29918,
2311,
3366,
29883,
12436,
13,
18884,
1373,
29918,
3665,
936,
29918,
17987,
8497,
29918,
2311,
29922,
17987,
8497,
29918,
2311,
3366,
2214,
12436,
13,
18884,
23655,
29918,
6229,
29922,
17987,
8497,
29918,
6229,
29892,
13,
18884,
5768,
449,
29922,
17987,
29918,
8865,
449,
29892,
13,
9651,
1723,
13,
9651,
363,
474,
297,
3464,
29898,
29946,
1125,
13,
18884,
565,
1583,
29889,
1212,
29918,
1853,
297,
4852,
29890,
16613,
29885,
613,
376,
29890,
16613,
29885,
29918,
1131,
29908,
1125,
13,
462,
1678,
731,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29995,
29879,
29908,
1273,
474,
29892,
13,
462,
9651,
3144,
29884,
265,
29889,
29878,
15755,
29889,
29933,
333,
8684,
284,
4617,
29898,
13,
462,
18884,
3144,
29884,
265,
29889,
29878,
15755,
29889,
29931,
1254,
29924,
4617,
29898,
1311,
29889,
20155,
29885,
29918,
10892,
511,
13,
462,
18884,
3144,
29884,
265,
29889,
29878,
15755,
29889,
29931,
1254,
29924,
4617,
29898,
1311,
29889,
20155,
29885,
29918,
10892,
876,
13,
462,
9651,
1723,
13,
18884,
25342,
1583,
29889,
1212,
29918,
1853,
1275,
376,
20155,
29885,
1115,
13,
462,
1678,
731,
5552,
29898,
13,
462,
4706,
1583,
29892,
376,
29878,
15755,
29995,
29879,
29908,
1273,
474,
29892,
3144,
29884,
265,
29889,
29878,
15755,
29889,
29931,
1254,
29924,
4617,
29898,
1311,
29889,
20155,
29885,
29918,
10892,
511,
13,
462,
1678,
1723,
13,
18884,
1683,
29901,
13,
462,
1678,
12020,
20948,
29898,
13,
462,
4706,
376,
1212,
29918,
1853,
881,
367,
24471,
29885,
29892,
13181,
303,
29885,
470,
13181,
303,
29885,
29918,
1131,
1699,
13,
462,
4706,
376,
1286,
338,
1273,
29879,
29908,
1273,
1583,
29889,
1212,
29918,
1853,
13,
462,
1678,
1723,
13,
13,
9651,
565,
1583,
29889,
1212,
29918,
1853,
1275,
376,
29890,
16613,
29885,
29918,
1131,
1115,
13,
18884,
1583,
29889,
1742,
29918,
1131,
2509,
353,
360,
327,
7566,
4165,
2509,
4617,
29898,
13,
462,
1678,
10340,
29922,
1311,
29889,
20155,
29885,
29918,
10892,
29892,
6287,
29881,
29922,
8824,
13,
18884,
1723,
13,
18884,
1583,
29889,
3090,
29918,
1131,
2509,
353,
360,
327,
7566,
4165,
2509,
4617,
29898,
13,
462,
1678,
10340,
29922,
1311,
29889,
20155,
29885,
29918,
10892,
29892,
6287,
29881,
29922,
8824,
13,
18884,
1723,
13,
13,
9651,
1583,
29889,
8865,
449,
353,
3144,
29884,
265,
29889,
15755,
29889,
15063,
449,
29898,
13801,
29918,
8865,
449,
29897,
13,
9651,
1583,
29889,
13801,
353,
3144,
29884,
265,
29889,
15755,
29889,
29928,
1947,
29898,
1990,
29918,
1949,
29897,
13,
13,
1678,
822,
7498,
19515,
29918,
11333,
29898,
1311,
29892,
383,
29892,
281,
29892,
364,
29893,
29892,
274,
29892,
364,
29883,
29892,
1734,
29918,
13168,
29892,
1373,
1008,
29918,
13168,
29892,
334,
5085,
29892,
3579,
19290,
1125,
13,
4706,
1734,
29918,
2848,
353,
1583,
29889,
1742,
29918,
2848,
565,
1583,
29889,
1742,
29918,
2848,
1683,
7431,
29898,
29893,
29961,
29900,
2314,
13,
4706,
2931,
29918,
2848,
353,
1583,
29889,
18609,
29918,
2848,
565,
1583,
29889,
18609,
29918,
2848,
1683,
7431,
29898,
13,
9651,
274,
29961,
29900,
2314,
13,
13,
4706,
1734,
29918,
17987,
8497,
29892,
1734,
29918,
3665,
936,
29918,
17987,
8497,
29892,
2931,
29918,
17987,
8497,
29892,
2931,
29918,
3665,
936,
29918,
17987,
8497,
353,
1583,
29889,
17987,
8497,
29898,
29893,
29892,
364,
29893,
29892,
13,
462,
462,
462,
462,
462,
462,
462,
29871,
274,
29892,
364,
29883,
29897,
13,
13,
4706,
10366,
29918,
4905,
29879,
353,
5852,
13,
4706,
565,
383,
338,
286,
29916,
29889,
18098,
29901,
13,
9651,
396,
29871,
231,
191,
191,
231,
188,
145,
3144,
29884,
265,
29871,
30417,
31658,
31596,
30214,
29871,
30783,
18098,
13,
9651,
1734,
29918,
13168,
29892,
1373,
1008,
29918,
13168,
353,
6213,
29892,
6213,
13,
13,
4706,
565,
1583,
29889,
1212,
29918,
1853,
1275,
376,
29890,
16613,
29885,
29918,
1131,
1115,
13,
9651,
281,
29918,
29872,
29892,
313,
29893,
29918,
417,
29892,
281,
29918,
3137,
29892,
281,
29918,
307,
29892,
281,
29918,
2288,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29900,
2564,
348,
1245,
29898,
13,
18884,
1734,
29918,
2848,
29892,
1734,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
1742,
29918,
13168,
13,
9651,
1723,
13,
9651,
1734,
29918,
3665,
936,
29918,
17987,
8497,
353,
320,
13,
18884,
1583,
29889,
1742,
29918,
1131,
2509,
29898,
1742,
29918,
3665,
936,
29918,
17987,
8497,
29892,
281,
29918,
29872,
29892,
13,
462,
462,
1678,
11105,
29922,
1742,
29918,
13168,
13,
462,
462,
1678,
1723,
29961,
29900,
29962,
13,
9651,
2358,
29918,
29872,
29892,
313,
15866,
29918,
417,
29892,
2358,
29918,
3137,
29892,
2358,
29918,
307,
29892,
2358,
29918,
2288,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29896,
2564,
348,
1245,
29898,
13,
18884,
1734,
29918,
2848,
29892,
1734,
29918,
3665,
936,
29918,
17987,
8497,
29892,
13,
18884,
3380,
29918,
3859,
7607,
29893,
29918,
3137,
29892,
281,
29918,
3137,
29892,
281,
29918,
2288,
29892,
281,
29918,
2288,
511,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
1742,
29918,
13168,
13,
9651,
1723,
13,
9651,
274,
29918,
29872,
29892,
313,
29883,
29918,
417,
29892,
274,
29918,
3137,
29892,
274,
29918,
307,
29892,
274,
29918,
2288,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29906,
2564,
348,
1245,
29898,
13,
18884,
2931,
29918,
2848,
29892,
2931,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
3090,
1008,
29918,
13168,
13,
9651,
1723,
13,
9651,
2931,
29918,
3665,
936,
29918,
17987,
8497,
353,
320,
13,
18884,
1583,
29889,
3090,
29918,
1131,
2509,
29898,
18609,
29918,
3665,
936,
29918,
17987,
8497,
29892,
274,
29918,
29872,
29892,
13,
462,
462,
1678,
11105,
29922,
3090,
1008,
29918,
13168,
13,
462,
462,
1678,
1723,
29961,
29900,
29962,
13,
9651,
2181,
29918,
29872,
29892,
313,
7283,
29918,
417,
29892,
2181,
29918,
3137,
29892,
2181,
29918,
307,
29892,
2181,
29918,
2288,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29941,
2564,
348,
1245,
29898,
13,
18884,
2931,
29918,
2848,
29892,
2931,
29918,
3665,
936,
29918,
17987,
8497,
29892,
13,
18884,
3380,
29918,
3859,
7607,
29883,
29918,
3137,
29892,
274,
29918,
3137,
29892,
274,
29918,
2288,
29892,
274,
29918,
2288,
511,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
3090,
1008,
29918,
13168,
13,
9651,
1723,
13,
13,
9651,
8570,
353,
383,
29889,
17685,
29898,
13,
18884,
281,
29918,
417,
29892,
281,
29918,
307,
29892,
2358,
29918,
417,
29892,
2358,
29918,
307,
29892,
274,
29918,
417,
29892,
274,
29918,
307,
29892,
2181,
29918,
417,
29892,
2181,
29918,
307,
13,
9651,
1723,
13,
4706,
25342,
1583,
29889,
1212,
29918,
1853,
1275,
376,
29890,
16613,
29885,
1115,
13,
9651,
281,
29918,
29872,
29892,
313,
29893,
29918,
417,
29892,
281,
29918,
3137,
29892,
281,
29918,
307,
29892,
281,
29918,
2288,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29900,
2564,
348,
1245,
29898,
13,
18884,
1734,
29918,
2848,
29892,
1734,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
1742,
29918,
13168,
13,
9651,
1723,
13,
13,
9651,
2358,
29918,
29872,
29892,
313,
15866,
29918,
417,
29892,
2358,
29918,
3137,
29892,
2358,
29918,
307,
29892,
2358,
29918,
2288,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29896,
2564,
348,
1245,
29898,
13,
18884,
1734,
29918,
2848,
29892,
1734,
29918,
3665,
936,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
1742,
29918,
13168,
13,
9651,
1723,
13,
9651,
274,
29918,
29872,
29892,
313,
29883,
29918,
417,
29892,
274,
29918,
3137,
29892,
274,
29918,
307,
29892,
274,
29918,
2288,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29906,
2564,
348,
1245,
29898,
13,
18884,
2931,
29918,
2848,
29892,
2931,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
3090,
1008,
29918,
13168,
13,
9651,
1723,
13,
9651,
2181,
29918,
29872,
29892,
313,
7283,
29918,
417,
29892,
2181,
29918,
3137,
29892,
2181,
29918,
307,
29892,
2181,
29918,
2288,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29941,
2564,
348,
1245,
29898,
13,
18884,
2931,
29918,
2848,
29892,
2931,
29918,
3665,
936,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
3090,
1008,
29918,
13168,
13,
9651,
1723,
13,
13,
9651,
8570,
353,
383,
29889,
17685,
29898,
13,
18884,
281,
29918,
417,
29892,
281,
29918,
307,
29892,
2358,
29918,
417,
29892,
2358,
29918,
307,
29892,
274,
29918,
417,
29892,
274,
29918,
307,
29892,
2181,
29918,
417,
29892,
2181,
29918,
307,
13,
9651,
1723,
13,
4706,
25342,
1583,
29889,
1212,
29918,
1853,
1275,
376,
20155,
29885,
1115,
13,
9651,
281,
29918,
29872,
29892,
313,
29893,
29918,
29877,
29892,
281,
29918,
29879,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29900,
2564,
348,
1245,
29898,
13,
18884,
1734,
29918,
2848,
29892,
13,
18884,
1734,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
1742,
29918,
13168,
13,
9651,
1723,
13,
9651,
2358,
29918,
29872,
29892,
313,
15866,
29918,
29877,
29892,
2358,
29918,
29879,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29896,
2564,
348,
1245,
29898,
13,
18884,
1734,
29918,
2848,
29892,
13,
18884,
1734,
29918,
3665,
936,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
1742,
29918,
13168,
13,
9651,
1723,
13,
9651,
274,
29918,
29872,
29892,
313,
29883,
29918,
29877,
29892,
274,
29918,
29879,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29906,
2564,
348,
1245,
29898,
13,
18884,
2931,
29918,
2848,
29892,
13,
18884,
2931,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
3090,
1008,
29918,
13168,
13,
9651,
1723,
13,
9651,
2181,
29918,
29872,
29892,
313,
7283,
29918,
29877,
29892,
2181,
29918,
29879,
29897,
353,
679,
5552,
29898,
1311,
29892,
376,
29878,
15755,
29941,
2564,
348,
1245,
29898,
13,
18884,
2931,
29918,
2848,
29892,
2931,
29918,
3665,
936,
29918,
17987,
8497,
29892,
13,
18884,
10366,
29918,
4905,
29879,
29922,
14634,
29918,
4905,
29879,
29892,
13,
18884,
2854,
29918,
2848,
29922,
3090,
1008,
29918,
13168,
29897,
13,
13,
9651,
8570,
353,
383,
29889,
17685,
29898,
29893,
29918,
29877,
29892,
2358,
29918,
29877,
29892,
274,
29918,
29877,
29892,
2181,
29918,
29877,
29897,
13,
4706,
1683,
29901,
13,
9651,
12020,
20948,
29898,
13,
18884,
376,
1212,
29918,
1853,
881,
367,
24471,
29885,
29892,
13181,
303,
29885,
470,
13181,
303,
29885,
29918,
1131,
1699,
13,
18884,
376,
1286,
338,
1273,
29879,
29908,
1273,
1583,
29889,
1212,
29918,
1853,
13,
9651,
1723,
13,
4706,
8570,
353,
1583,
29889,
8865,
449,
29898,
1131,
2509,
29897,
13,
4706,
396,
8570,
353,
1583,
29889,
8865,
449,
29898,
13,
4706,
396,
268,
383,
29889,
21786,
362,
29898,
1311,
29889,
15755,
29898,
1131,
2509,
511,
1044,
29918,
1853,
2433,
2695,
2674,
29884,
1495,
13,
4706,
396,
1723,
13,
4706,
396,
285,
29883,
29918,
262,
353,
1583,
29889,
29277,
29918,
1131,
2509,
29898,
1131,
2509,
29897,
13,
4706,
285,
29883,
29918,
262,
353,
8570,
13,
4706,
736,
1583,
29889,
13801,
29898,
13801,
29918,
262,
29897,
13,
13,
1678,
822,
731,
29918,
11618,
29918,
348,
1245,
29898,
1311,
29892,
1734,
29918,
2848,
29892,
2931,
29918,
2848,
1125,
13,
4706,
1583,
29889,
1742,
29918,
2848,
353,
1734,
29918,
2848,
13,
4706,
1583,
29889,
18609,
29918,
2848,
353,
2931,
29918,
2848,
13,
13,
13,
1990,
399,
22245,
29885,
2580,
8497,
29898,
3820,
29884,
265,
29889,
26322,
19515,
7445,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1734,
29918,
17987,
8497,
29918,
2311,
29892,
1734,
29918,
3665,
936,
29918,
17987,
8497,
29918,
2311,
29892,
13,
462,
1373,
29918,
17987,
8497,
29918,
2311,
29892,
1373,
29918,
3665,
936,
29918,
17987,
8497,
29918,
2311,
29892,
13,
462,
23655,
29918,
6229,
29892,
5768,
449,
29922,
29900,
29889,
29945,
29892,
10944,
29922,
8516,
29892,
13,
462,
8636,
29922,
8516,
1125,
13,
4706,
2428,
29898,
29956,
22245,
29885,
2580,
8497,
29892,
1583,
467,
1649,
2344,
12035,
13506,
29892,
8636,
29897,
13,
4706,
411,
1583,
29889,
978,
29918,
6078,
7295,
13,
9651,
1583,
29889,
1742,
29918,
17987,
8497,
353,
3144,
29884,
265,
29889,
15755,
29889,
6026,
2580,
8497,
29898,
13,
18884,
1734,
29918,
17987,
8497,
29918,
2311,
29892,
23655,
29918,
6229,
13,
9651,
1723,
13,
9651,
1583,
29889,
1742,
29918,
3665,
936,
29918,
17987,
8497,
353,
3144,
29884,
265,
29889,
15755,
29889,
6026,
2580,
8497,
29898,
13,
18884,
1734,
29918,
3665,
936,
29918,
17987,
8497,
29918,
2311,
29892,
23655,
29918,
6229,
13,
9651,
1723,
13,
9651,
1583,
29889,
3090,
29918,
17987,
8497,
353,
3144,
29884,
265,
29889,
15755,
29889,
6026,
2580,
8497,
29898,
13,
18884,
1373,
29918,
17987,
8497,
29918,
2311,
29892,
23655,
29918,
6229,
13,
9651,
1723,
13,
9651,
1583,
29889,
3090,
29918,
3665,
936,
29918,
17987,
8497,
353,
3144,
29884,
265,
29889,
15755,
29889,
6026,
2580,
8497,
29898,
13,
18884,
1373,
29918,
3665,
936,
29918,
17987,
8497,
29918,
2311,
29892,
23655,
29918,
6229,
13,
9651,
1723,
13,
9651,
1583,
29889,
1742,
29918,
8865,
449,
353,
3144,
29884,
265,
29889,
15755,
29889,
15063,
449,
29898,
8865,
449,
29897,
13,
9651,
1583,
29889,
3090,
29918,
8865,
449,
353,
3144,
29884,
265,
29889,
15755,
29889,
15063,
449,
29898,
8865,
449,
29897,
13,
13,
1678,
822,
7498,
19515,
29918,
11333,
29898,
1311,
29892,
13,
462,
539,
383,
29892,
1734,
29918,
11762,
29892,
1734,
29918,
3665,
936,
29918,
11762,
29892,
13,
462,
539,
2931,
29918,
11762,
29892,
2931,
29918,
3665,
936,
29918,
11762,
29892,
13,
462,
539,
334,
5085,
29892,
3579,
19290,
13,
462,
4706,
1125,
13,
4706,
1734,
29918,
17987,
8497,
353,
1583,
29889,
1742,
29918,
17987,
8497,
29898,
1742,
29918,
11762,
29897,
13,
4706,
1734,
29918,
3665,
936,
29918,
17987,
8497,
353,
1583,
29889,
1742,
29918,
3665,
936,
29918,
17987,
8497,
29898,
1742,
29918,
3665,
936,
29918,
11762,
29897,
13,
4706,
2931,
29918,
17987,
8497,
353,
1583,
29889,
3090,
29918,
17987,
8497,
29898,
18609,
29918,
11762,
29897,
13,
4706,
2931,
29918,
3665,
936,
29918,
17987,
8497,
353,
1583,
29889,
3090,
29918,
3665,
936,
29918,
17987,
8497,
29898,
13,
9651,
2931,
29918,
3665,
936,
29918,
11762,
13,
4706,
1723,
13,
13,
4706,
1734,
29918,
17987,
8497,
353,
1583,
29889,
1742,
29918,
8865,
449,
29898,
1742,
29918,
17987,
8497,
29897,
13,
4706,
1734,
29918,
3665,
936,
29918,
17987,
8497,
353,
1583,
29889,
1742,
29918,
8865,
449,
29898,
1742,
29918,
3665,
936,
29918,
17987,
8497,
29897,
13,
4706,
2931,
29918,
17987,
8497,
353,
1583,
29889,
3090,
29918,
8865,
449,
29898,
18609,
29918,
17987,
8497,
29897,
13,
4706,
2931,
29918,
3665,
936,
29918,
17987,
8497,
353,
1583,
29889,
3090,
29918,
8865,
449,
29898,
13,
9651,
2931,
29918,
3665,
936,
29918,
17987,
8497,
13,
4706,
1723,
13,
13,
4706,
736,
1734,
29918,
17987,
8497,
29892,
1734,
29918,
3665,
936,
29918,
17987,
8497,
29892,
2931,
29918,
17987,
8497,
29892,
2931,
29918,
3665,
936,
29918,
17987,
8497,
13,
13,
1678,
822,
731,
29918,
7915,
29898,
1311,
29892,
591,
29892,
364,
705,
29892,
2257,
29892,
364,
346,
1125,
13,
4706,
1583,
29889,
1742,
29918,
17987,
8497,
29889,
7915,
29889,
842,
29918,
1272,
29898,
705,
29897,
13,
4706,
1583,
29889,
1742,
29918,
3665,
936,
29918,
17987,
8497,
29889,
7915,
29889,
842,
29918,
1272,
29898,
29878,
705,
29897,
13,
4706,
1583,
29889,
3090,
29918,
17987,
8497,
29889,
7915,
29889,
842,
29918,
1272,
29898,
346,
29897,
13,
4706,
1583,
29889,
3090,
29918,
3665,
936,
29918,
17987,
8497,
29889,
7915,
29889,
842,
29918,
1272,
29898,
29878,
346,
29897,
13,
2
] |
samples/snippets/test_export_to_bigquery.py | renovate-bot/python-contact-center-insights | 4 | 12518 | # Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import uuid
import google.auth
from google.cloud import bigquery
import pytest
import export_to_bigquery
GCLOUD_TESTS_PREFIX = "python_samples_tests"
@pytest.fixture
def project_id():
_, project_id = google.auth.default()
return project_id
@pytest.fixture
def unique_id():
uuid_hex = uuid.uuid4().hex[:8]
return f"{GCLOUD_TESTS_PREFIX}_{uuid_hex}"
@pytest.fixture
def bigquery_resources(project_id, unique_id):
# Create a BigQuery dataset.
bigquery_client = bigquery.Client()
dataset_id = unique_id
table_id = unique_id
dataset = bigquery.Dataset(f"{project_id}.{dataset_id}")
dataset.location = "US"
bigquery_client.create_dataset(dataset, timeout=30)
# Create a BigQuery table under the created dataset.
table = bigquery.Table(f"{project_id}.{dataset_id}.{table_id}")
bigquery_client.create_table(table)
yield dataset_id, table_id
# Delete the BigQuery dataset and table.
bigquery_client.delete_dataset(dataset_id, delete_contents=True)
def test_export_data_to_bigquery(capsys, project_id, bigquery_resources):
dataset_id, table_id = bigquery_resources
export_to_bigquery.export_to_bigquery(project_id, project_id, dataset_id, table_id)
out, err = capsys.readouterr()
assert "Exported data to BigQuery" in out
| [
1,
396,
14187,
1266,
29871,
29906,
29900,
29906,
29896,
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,
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,
29937,
13,
5215,
318,
5416,
13,
13,
5215,
5386,
29889,
5150,
13,
13,
3166,
5386,
29889,
9274,
1053,
4802,
1972,
13,
13,
5215,
11451,
1688,
13,
13,
5215,
5609,
29918,
517,
29918,
3752,
1972,
13,
13,
8766,
3927,
15789,
29918,
18267,
29903,
29918,
15094,
25634,
353,
376,
4691,
29918,
27736,
29918,
21150,
29908,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
2060,
29918,
333,
7295,
13,
1678,
17117,
2060,
29918,
333,
353,
5386,
29889,
5150,
29889,
4381,
580,
13,
1678,
736,
2060,
29918,
333,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
5412,
29918,
333,
7295,
13,
1678,
318,
5416,
29918,
20970,
353,
318,
5416,
29889,
25118,
29946,
2141,
20970,
7503,
29947,
29962,
13,
1678,
736,
285,
29908,
29912,
8766,
3927,
15789,
29918,
18267,
29903,
29918,
15094,
25634,
3227,
25118,
29918,
20970,
5038,
13,
13,
13,
29992,
2272,
1688,
29889,
7241,
15546,
13,
1753,
4802,
1972,
29918,
13237,
29898,
4836,
29918,
333,
29892,
5412,
29918,
333,
1125,
13,
1678,
396,
6204,
263,
7997,
3010,
8783,
29889,
13,
1678,
4802,
1972,
29918,
4645,
353,
4802,
1972,
29889,
4032,
580,
13,
1678,
8783,
29918,
333,
353,
5412,
29918,
333,
13,
1678,
1591,
29918,
333,
353,
5412,
29918,
333,
13,
13,
1678,
8783,
353,
4802,
1972,
29889,
16390,
24541,
29898,
29888,
29908,
29912,
4836,
29918,
333,
1836,
29912,
24713,
29918,
333,
27195,
13,
1678,
8783,
29889,
5479,
353,
376,
3308,
29908,
13,
1678,
4802,
1972,
29918,
4645,
29889,
3258,
29918,
24713,
29898,
24713,
29892,
11815,
29922,
29941,
29900,
29897,
13,
13,
1678,
396,
6204,
263,
7997,
3010,
1591,
1090,
278,
2825,
8783,
29889,
13,
1678,
1591,
353,
4802,
1972,
29889,
3562,
29898,
29888,
29908,
29912,
4836,
29918,
333,
1836,
29912,
24713,
29918,
333,
1836,
29912,
2371,
29918,
333,
27195,
13,
1678,
4802,
1972,
29918,
4645,
29889,
3258,
29918,
2371,
29898,
2371,
29897,
13,
13,
1678,
7709,
8783,
29918,
333,
29892,
1591,
29918,
333,
13,
13,
1678,
396,
21267,
278,
7997,
3010,
8783,
322,
1591,
29889,
13,
1678,
4802,
1972,
29918,
4645,
29889,
8143,
29918,
24713,
29898,
24713,
29918,
333,
29892,
5217,
29918,
10853,
29922,
5574,
29897,
13,
13,
13,
1753,
1243,
29918,
15843,
29918,
1272,
29918,
517,
29918,
3752,
1972,
29898,
29883,
2547,
952,
29892,
2060,
29918,
333,
29892,
4802,
1972,
29918,
13237,
1125,
13,
1678,
8783,
29918,
333,
29892,
1591,
29918,
333,
353,
4802,
1972,
29918,
13237,
13,
1678,
5609,
29918,
517,
29918,
3752,
1972,
29889,
15843,
29918,
517,
29918,
3752,
1972,
29898,
4836,
29918,
333,
29892,
2060,
29918,
333,
29892,
8783,
29918,
333,
29892,
1591,
29918,
333,
29897,
13,
1678,
714,
29892,
4589,
353,
2117,
9675,
29889,
949,
5561,
29878,
580,
13,
1678,
4974,
376,
26382,
287,
848,
304,
7997,
3010,
29908,
297,
714,
13,
2
] |
tests/functional_tests/identity_tests/test_properties.py | lycantropos/lz | 7 | 72823 | from typing import Any
from hypothesis import given
from lz.functional import (curry,
identity)
from tests import strategies
@given(strategies.scalars)
def test_currying(object_: Any) -> None:
curried = curry(identity)
result = curried(object_)
assert result is object_
| [
1,
515,
19229,
1053,
3139,
13,
13,
3166,
20051,
1053,
2183,
13,
13,
3166,
301,
29920,
29889,
2220,
284,
1053,
313,
2764,
719,
29892,
13,
462,
965,
10110,
29897,
13,
3166,
6987,
1053,
16650,
583,
13,
13,
13,
29992,
29887,
5428,
29898,
710,
1845,
583,
29889,
19529,
1503,
29897,
13,
1753,
1243,
29918,
2764,
719,
292,
29898,
3318,
29918,
29901,
3139,
29897,
1599,
6213,
29901,
13,
1678,
3151,
1255,
353,
3151,
719,
29898,
22350,
29897,
13,
13,
1678,
1121,
353,
3151,
1255,
29898,
3318,
19925,
13,
13,
1678,
4974,
1121,
338,
1203,
29918,
13,
2
] |
orm_database/create.py | SamuelSSan28/camara_bot_2.0 | 0 | 186562 | <gh_stars>0
from models import Projetos
projeto_1 = {
'protocolo':1402,
'processo':"1394 /2021",
'data':'----',
'titulo': '---',
'vereador': "---",
'situacao':'---',
'tipo':'----'
}
projetos = [projeto_1]
# Inserimos os quatro projetos na tabela 'Projetos'
Projetos.insert_many(projetos).execute()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
4733,
1053,
29871,
1019,
4026,
359,
13,
13,
771,
4026,
29877,
29918,
29896,
353,
426,
13,
1678,
525,
20464,
29877,
2396,
29896,
29946,
29900,
29906,
29892,
13,
1678,
525,
5014,
29877,
2396,
29908,
29896,
29941,
29929,
29946,
847,
29906,
29900,
29906,
29896,
613,
13,
1678,
525,
1272,
22099,
807,
742,
13,
1678,
525,
23545,
7207,
2396,
525,
5634,
742,
13,
1678,
525,
369,
1479,
272,
2396,
376,
5634,
613,
13,
1678,
525,
29879,
1981,
562,
6241,
22099,
5634,
742,
13,
1678,
525,
12632,
29877,
22099,
807,
29915,
13,
29913,
13,
13,
13,
771,
4026,
359,
353,
518,
771,
4026,
29877,
29918,
29896,
29962,
13,
13,
13,
29937,
512,
643,
18594,
2897,
439,
7816,
15744,
359,
1055,
260,
1107,
29874,
525,
1184,
4026,
359,
29915,
13,
1184,
4026,
359,
29889,
7851,
29918,
13011,
29898,
771,
4026,
359,
467,
7978,
580,
13,
2
] |
__init__.py | ModEngineer/pygraphutils | 1 | 143199 | #Copyright 2020 ModEngineer
#
#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 warnings
from copy import deepcopy
class GraphError(Exception):
"""Error class for this module"""
pass
class Auto:
"""NoneType-like object that represents the automatic value"""
def __repr__(self):
return "Auto"
def __str__(self):
return "Auto"
class ExitContainer():
"""Error container class that can be used to raise the error or to get an exit code. 0 is a generic, non-error code, negative codes should represent errors, and positive codes should represent non-error program states."""
class ExitContainerWarning(Warning):
pass
def __init__(self, exception=None, code=Auto()):
#Exit code processing with exception checking
self.exception = exception
#Auto handling
if type(code) is Auto or code is Auto:
if exception == None:
self.code = 0
else:
self.code = -0x1
else:
self.code = code
#Positive code handling and exception warning
if type(code) is int:
if code >= 0:
if exception != None:
warnings.warn(
"ExitContainer with an exception should not have a positive code.",
category=ExitContainer.ExitContainerWarning)
#Negative code handling and exception warning
elif code < 0:
if exception == None:
warnings.warn(
"ExitContainer without an exception should not have a negative code.",
category=ExitContainer.ExitContainerWarning)
def raise_exception(self):
"""A function that raises the ExitContainer's exception if it has an exception stored"""
if self.exception != None:
raise self.exception
#Graph validation function. Checks graph connections, endpoint count, and nonexistent nodes listed as connections.
def validate_graph(graphData):
try:
endpointCount = 0
for node in graphData:
if type(graphData[node]) not in [list, tuple]:
return ExitContainer(
TypeError(
"Type " + repr(type(graphData[node])) +
" is not a list or a tuple. The graphData argument requires that connections are stored in lists or tuples."
), -0x2)
try:
for connectedNode in graphData[node]:
if not node in graphData[connectedNode]:
return ExitContainer(
GraphError(
"Nodes " + repr(node) + " and " +
repr(connectedNode) +
" do not list each other in their connections."
), -0x3)
except KeyError as exc:
try:
raise GraphError("Node " + repr(exc.args[0]) +
" does not exist.") from exc
except GraphError as exc2:
return ExitContainer(exc2, -0x4)
if len(graphData[node]) % 2 == 1:
endpointCount += 1
if endpointCount > 2:
return ExitContainer(
GraphError(
"Graph cannot contain more than 2 nodes of odd degree."
), -0x5)
if not is_connected(graphData):
return ExitContainer(GraphError("Graph is not connected."), -0x6)
return ExitContainer()
except Exception as e:
return ExitContainer(e)
#Node remover
def remove_node(node, graphData):
for connection in graphData[node]:
graphData[connection].remove(node)
del graphData[node]
#Edge remover
def remove_edge(node1, node2, graphData):
graphData[node1].remove(node2)
graphData[node2].remove(node1)
#Node creator
def add_node(node, graphData):
if node in graphData.keys():
raise GraphError("Node already in graph")
graphData[node] = []
#Edge creator
def add_edge(node1, node2, graphData):
if not node1 in graphData.keys():
add_node(node1, graphData)
if not node2 in graphData.keys():
add_node(node2, graphData)
if not node1 in graphData[node2]:
graphData[node2].append(node1)
if not node2 in graphData[node1]:
graphData[node1].append(node2)
def dfs(graphData, vertex=Auto()):
s = []
discovered = []
if type(vertex) is Auto or vertex is Auto:
vertex = list(graphData.keys())[0]
s.append(vertex)
while s:
vertex = s.pop()
if not vertex in discovered:
discovered.append(vertex)
for w in graphData[vertex]:
s.append(w)
return discovered
def is_connected(graphData):
discovered = dfs(graphData)
#DFS, returns a list of discovered nodes after picking an arbitrary node
#Loop that checks if any node isn't discovered
for key in graphData.keys():
if not key in discovered:
return False
return True
#Bridge-finding.
def find_bridges(graphData):
if not is_connected(graphData):
raise GraphError("Unconnected graph cannot be tested for bridges")
#Init
processed = []
bridges = []
#Loop that removes an edge temporarily, runs DFS, and checks if the graph is still connected
for start in graphData.keys():
for end in graphData[start]:
if (start, end) in processed or (end, start) in processed:
continue
processed.append((start, end))
tempGData = deepcopy(graphData)
remove_edge(start, end, tempGData)
if not is_connected(tempGData):
bridges.append((start, end))
return bridges
#Function that collapses a list of lists into a single list
def __collapse_list_list(listList, recursive=False):
outList = []
for item in listList:
if type(item) == list:
if recursive:
item = __collapse_list_list(deepcopy(item), True)
outList += item
else:
outList.append(item)
return outList
#Function that checks if all items in subList are in containerList
def __list_contains_list(subList, containerList):
for item in subList:
if item not in containerList:
return False
return True
#Graph splitter
def split_unconnected(graphData):
if is_connected(graphData):
return [graphData]
dfsresults = []
while not __list_contains_list(graphData.keys(),
__collapse_list_list(dfsresults)):
dfsresults.append(
dfs(graphData,
vertex=[
vert for vert in graphData.keys()
if not vert in __collapse_list_list(dfsresults)
][0]))
outputGraphs = []
for result in dfsresults:
currentGraph = {}
for node in result:
currentGraph[node] = graphData[node]
outputGraphs.append(currentGraph)
return outputGraphs
def split_at_bridge(splitNode, node2, graphData):
bridgeList = find_bridges(graphData)
if not ((splitNode, node2) in bridgeList or
(node2, splitNode) in bridgeList):
raise GraphError("Cannot split graph on non-bridge")
outGraphs = []
outGraphs.append(deepcopy(graphData))
outGraphs.append(deepcopy(graphData))
for connection in outGraphs[0][splitNode]:
if connection != node2:
remove_edge(splitNode, connection, outGraphs[0])
bridgeGraphDFS = dfs(outGraphs[0], splitNode)
loopDict = deepcopy(outGraphs[0])
for node in loopDict:
if not node in bridgeGraphDFS:
remove_node(node, outGraphs[0])
loopDict = deepcopy(outGraphs[1])
for node in loopDict:
if node in bridgeGraphDFS and node != splitNode:
remove_node(node, outGraphs[1])
return outGraphs
#Fleury implementation based on Wikipedia's pseudocode
def fleury(graphData, checkPath=True):
"""Fleury's algorithm for finding a Eulerian path in an undirected graph"""
#Init
tempGData = deepcopy(graphData)
endpoints = []
#Endpoint finding
for node in tempGData:
if len(tempGData[node]) % 2 == 1:
endpoints.append(node)
if len(endpoints) == 0:
currentNode = list(tempGData.keys())[0]
else:
currentNode = endpoints[0]
path = [currentNode]
#Mainloop
while tempGData[currentNode]:
#Next-edge-finder. Prefers non-bridges
bridges = find_bridges(tempGData)
nonBridgeConnections = [
connection for connection in tempGData[currentNode]
if not connection in bridges
]
if nonBridgeConnections:
nextNode = nonBridgeConnections[0]
else:
nextNode = tempGData[currentNode][0]
#Next-node-queuing and path building
remove_edge(currentNode, nextNode, tempGData)
if not tempGData[currentNode]:
remove_node(currentNode, tempGData)
path.append(nextNode)
currentNode = nextNode
#Path validation
if checkPath:
for node in graphData:
for connection in graphData[node]:
listContainedList = False
for index in range(len(path) - 1):
if __list_contains_list([node, connection],
[path[index], path[index + 1]]):
listContainedList = True
break
if not listContainedList:
return None
return path
# Automatic splitting of graph into multiple graphs with Eulerian paths (NOT FUNCTIONAL)
# def auto_split(graphData, returnGraphs=True, returnPaths=False):
# assert returnGraphs or returnPaths, "auto_split must have a selected return value."
# output = {}
# if returnGraphs:
# output["graphs"] = []
# if returnPaths:
# output["paths"] = []
# fleuryTest = fleury(graphData)
# if fleuryTest:
# if returnGraphs:
# output["graphs"] = [graphData]
# if returnPaths:
# output["paths"] = [fleuryTest]
# return output
# eulerianParts = []
# tempGData = deepcopy(graphData)
# while tempGData:
# currentFleury = fleury(tempGData, False)
# eulerianParts.append(currentFleury)
# if returnGraphs:
# output["graphs"].append({})
# for index, node1 in enumerate(currentFleury[:-1]):
# node2 = currentFleury[index + 1]
# remove_edge(node1, node2, tempGData)
# if returnGraphs:
# add_edge(node1, node2, output["graphs"][-1])
# tempTempGData = deepcopy(tempGData)
# for node in tempTempGData:
# if not tempGData[node]:
# if returnGraphs and not node in __collapse_list_list(
# eulerianParts):
# output["graphs"].append([node])
# remove_node(node, tempGData)
# del tempTempGData
# if returnPaths:
# output["paths"] = eulerianParts
# return output | [
1,
396,
11882,
1266,
29871,
29906,
29900,
29906,
29900,
3382,
12412,
261,
13,
29937,
13,
29937,
29931,
293,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
1496,
13,
29937,
6293,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
13,
29937,
3492,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
1678,
1732,
597,
1636,
29889,
4288,
29889,
990,
29914,
506,
11259,
29914,
27888,
1430,
1660,
29899,
29906,
29889,
29900,
13,
29937,
13,
29937,
2525,
2222,
3734,
491,
22903,
4307,
470,
15502,
304,
297,
5007,
29892,
7047,
13,
29937,
5721,
7541,
1090,
278,
19245,
338,
13235,
373,
385,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
13,
29937,
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,
29937,
13393,
278,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
13,
29937,
13400,
800,
1090,
278,
19245,
29889,
13,
5215,
18116,
13,
3166,
3509,
1053,
6483,
8552,
13,
13,
13,
1990,
12367,
2392,
29898,
2451,
1125,
13,
1678,
9995,
2392,
770,
363,
445,
3883,
15945,
29908,
13,
1678,
1209,
13,
13,
13,
1990,
11133,
29901,
13,
1678,
9995,
8516,
1542,
29899,
4561,
1203,
393,
11524,
278,
18428,
995,
15945,
29908,
13,
1678,
822,
4770,
276,
558,
12035,
1311,
1125,
13,
4706,
736,
376,
12300,
29908,
13,
13,
1678,
822,
4770,
710,
12035,
1311,
1125,
13,
4706,
736,
376,
12300,
29908,
13,
13,
13,
1990,
25954,
7895,
7295,
13,
1678,
9995,
2392,
5639,
770,
393,
508,
367,
1304,
304,
12020,
278,
1059,
470,
304,
679,
385,
6876,
775,
29889,
29871,
29900,
338,
263,
10035,
29892,
1661,
29899,
2704,
775,
29892,
8178,
11561,
881,
2755,
4436,
29892,
322,
6374,
11561,
881,
2755,
1661,
29899,
2704,
1824,
5922,
1213,
15945,
13,
1678,
770,
25954,
7895,
22709,
29898,
22709,
1125,
13,
4706,
1209,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
3682,
29922,
8516,
29892,
775,
29922,
12300,
580,
1125,
13,
4706,
396,
24365,
775,
9068,
411,
3682,
8454,
13,
4706,
1583,
29889,
11739,
353,
3682,
13,
4706,
396,
12300,
11415,
13,
4706,
565,
1134,
29898,
401,
29897,
338,
11133,
470,
775,
338,
11133,
29901,
13,
9651,
565,
3682,
1275,
6213,
29901,
13,
18884,
1583,
29889,
401,
353,
29871,
29900,
13,
9651,
1683,
29901,
13,
18884,
1583,
29889,
401,
353,
448,
29900,
29916,
29896,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
401,
353,
775,
13,
4706,
396,
9135,
3321,
775,
11415,
322,
3682,
9177,
13,
4706,
565,
1134,
29898,
401,
29897,
338,
938,
29901,
13,
9651,
565,
775,
6736,
29871,
29900,
29901,
13,
18884,
565,
3682,
2804,
6213,
29901,
13,
462,
1678,
18116,
29889,
25442,
29898,
13,
462,
4706,
376,
24365,
7895,
411,
385,
3682,
881,
451,
505,
263,
6374,
775,
19602,
13,
462,
4706,
7663,
29922,
24365,
7895,
29889,
24365,
7895,
22709,
29897,
13,
9651,
396,
29940,
387,
1230,
775,
11415,
322,
3682,
9177,
13,
9651,
25342,
775,
529,
29871,
29900,
29901,
13,
18884,
565,
3682,
1275,
6213,
29901,
13,
462,
1678,
18116,
29889,
25442,
29898,
13,
462,
4706,
376,
24365,
7895,
1728,
385,
3682,
881,
451,
505,
263,
8178,
775,
19602,
13,
462,
4706,
7663,
29922,
24365,
7895,
29889,
24365,
7895,
22709,
29897,
13,
13,
1678,
822,
12020,
29918,
11739,
29898,
1311,
1125,
13,
4706,
9995,
29909,
740,
393,
1153,
4637,
278,
25954,
7895,
29915,
29879,
3682,
565,
372,
756,
385,
3682,
6087,
15945,
29908,
13,
4706,
565,
1583,
29889,
11739,
2804,
6213,
29901,
13,
9651,
12020,
1583,
29889,
11739,
13,
13,
13,
29937,
9527,
8845,
740,
29889,
5399,
29879,
3983,
12368,
29892,
16248,
2302,
29892,
322,
5642,
29916,
9696,
7573,
9904,
408,
12368,
29889,
13,
1753,
12725,
29918,
4262,
29898,
4262,
1469,
1125,
13,
13,
1678,
1018,
29901,
13,
4706,
16248,
3981,
353,
29871,
29900,
13,
4706,
363,
2943,
297,
3983,
1469,
29901,
13,
9651,
565,
1134,
29898,
4262,
1469,
29961,
3177,
2314,
451,
297,
518,
1761,
29892,
18761,
5387,
13,
18884,
736,
25954,
7895,
29898,
13,
462,
1678,
20948,
29898,
13,
462,
4706,
376,
1542,
376,
718,
2062,
29898,
1853,
29898,
4262,
1469,
29961,
3177,
12622,
718,
13,
462,
4706,
376,
338,
451,
263,
1051,
470,
263,
18761,
29889,
450,
3983,
1469,
2980,
6858,
393,
12368,
526,
6087,
297,
8857,
470,
5291,
2701,
1213,
13,
462,
1678,
10353,
448,
29900,
29916,
29906,
29897,
13,
9651,
1018,
29901,
13,
18884,
363,
6631,
4247,
297,
3983,
1469,
29961,
3177,
5387,
13,
462,
1678,
565,
451,
2943,
297,
3983,
1469,
29961,
18045,
4247,
5387,
13,
462,
4706,
736,
25954,
7895,
29898,
13,
462,
9651,
12367,
2392,
29898,
13,
462,
18884,
376,
20284,
376,
718,
2062,
29898,
3177,
29897,
718,
376,
322,
376,
718,
13,
462,
18884,
2062,
29898,
18045,
4247,
29897,
718,
13,
462,
18884,
376,
437,
451,
1051,
1269,
916,
297,
1009,
12368,
1213,
13,
462,
9651,
10353,
448,
29900,
29916,
29941,
29897,
13,
9651,
5174,
7670,
2392,
408,
5566,
29901,
13,
18884,
1018,
29901,
13,
462,
1678,
12020,
12367,
2392,
703,
4247,
376,
718,
2062,
29898,
735,
29883,
29889,
5085,
29961,
29900,
2314,
718,
13,
462,
462,
268,
376,
947,
451,
1863,
23157,
515,
5566,
13,
18884,
5174,
12367,
2392,
408,
5566,
29906,
29901,
13,
462,
1678,
736,
25954,
7895,
29898,
735,
29883,
29906,
29892,
448,
29900,
29916,
29946,
29897,
13,
9651,
565,
7431,
29898,
4262,
1469,
29961,
3177,
2314,
1273,
29871,
29906,
1275,
29871,
29896,
29901,
13,
18884,
16248,
3981,
4619,
29871,
29896,
13,
18884,
565,
16248,
3981,
1405,
29871,
29906,
29901,
13,
462,
1678,
736,
25954,
7895,
29898,
13,
462,
4706,
12367,
2392,
29898,
13,
462,
9651,
376,
9527,
2609,
1712,
901,
1135,
29871,
29906,
7573,
310,
7736,
7426,
1213,
13,
462,
4706,
10353,
448,
29900,
29916,
29945,
29897,
13,
4706,
565,
451,
338,
29918,
18045,
29898,
4262,
1469,
1125,
13,
9651,
736,
25954,
7895,
29898,
9527,
2392,
703,
9527,
338,
451,
6631,
1213,
511,
448,
29900,
29916,
29953,
29897,
13,
4706,
736,
25954,
7895,
580,
13,
1678,
5174,
8960,
408,
321,
29901,
13,
4706,
736,
25954,
7895,
29898,
29872,
29897,
13,
13,
13,
29937,
4247,
1083,
957,
13,
1753,
3349,
29918,
3177,
29898,
3177,
29892,
3983,
1469,
1125,
13,
1678,
363,
3957,
297,
3983,
1469,
29961,
3177,
5387,
13,
4706,
3983,
1469,
29961,
9965,
1822,
5992,
29898,
3177,
29897,
13,
1678,
628,
3983,
1469,
29961,
3177,
29962,
13,
13,
13,
29937,
23894,
1083,
957,
13,
1753,
3349,
29918,
12864,
29898,
3177,
29896,
29892,
2943,
29906,
29892,
3983,
1469,
1125,
13,
1678,
3983,
1469,
29961,
3177,
29896,
1822,
5992,
29898,
3177,
29906,
29897,
13,
1678,
3983,
1469,
29961,
3177,
29906,
1822,
5992,
29898,
3177,
29896,
29897,
13,
13,
13,
29937,
4247,
907,
1061,
13,
1753,
788,
29918,
3177,
29898,
3177,
29892,
3983,
1469,
1125,
13,
1678,
565,
2943,
297,
3983,
1469,
29889,
8149,
7295,
13,
4706,
12020,
12367,
2392,
703,
4247,
2307,
297,
3983,
1159,
13,
1678,
3983,
1469,
29961,
3177,
29962,
353,
5159,
13,
13,
13,
29937,
23894,
907,
1061,
13,
1753,
788,
29918,
12864,
29898,
3177,
29896,
29892,
2943,
29906,
29892,
3983,
1469,
1125,
13,
1678,
565,
451,
2943,
29896,
297,
3983,
1469,
29889,
8149,
7295,
13,
4706,
788,
29918,
3177,
29898,
3177,
29896,
29892,
3983,
1469,
29897,
13,
1678,
565,
451,
2943,
29906,
297,
3983,
1469,
29889,
8149,
7295,
13,
4706,
788,
29918,
3177,
29898,
3177,
29906,
29892,
3983,
1469,
29897,
13,
1678,
565,
451,
2943,
29896,
297,
3983,
1469,
29961,
3177,
29906,
5387,
13,
4706,
3983,
1469,
29961,
3177,
29906,
1822,
4397,
29898,
3177,
29896,
29897,
13,
1678,
565,
451,
2943,
29906,
297,
3983,
1469,
29961,
3177,
29896,
5387,
13,
4706,
3983,
1469,
29961,
3177,
29896,
1822,
4397,
29898,
3177,
29906,
29897,
13,
13,
13,
1753,
4489,
29879,
29898,
4262,
1469,
29892,
12688,
29922,
12300,
580,
1125,
13,
1678,
269,
353,
5159,
13,
1678,
10943,
353,
5159,
13,
1678,
565,
1134,
29898,
369,
4776,
29897,
338,
11133,
470,
12688,
338,
11133,
29901,
13,
4706,
12688,
353,
1051,
29898,
4262,
1469,
29889,
8149,
3101,
29961,
29900,
29962,
13,
1678,
269,
29889,
4397,
29898,
369,
4776,
29897,
13,
1678,
1550,
269,
29901,
13,
4706,
12688,
353,
269,
29889,
7323,
580,
13,
4706,
565,
451,
12688,
297,
10943,
29901,
13,
9651,
10943,
29889,
4397,
29898,
369,
4776,
29897,
13,
9651,
363,
281,
297,
3983,
1469,
29961,
369,
4776,
5387,
13,
18884,
269,
29889,
4397,
29898,
29893,
29897,
13,
1678,
736,
10943,
13,
13,
13,
1753,
338,
29918,
18045,
29898,
4262,
1469,
1125,
13,
1678,
10943,
353,
4489,
29879,
29898,
4262,
1469,
29897,
13,
1678,
396,
4037,
29903,
29892,
3639,
263,
1051,
310,
10943,
7573,
1156,
5839,
292,
385,
11472,
2943,
13,
1678,
396,
18405,
393,
12747,
565,
738,
2943,
3508,
29915,
29873,
10943,
13,
1678,
363,
1820,
297,
3983,
1469,
29889,
8149,
7295,
13,
4706,
565,
451,
1820,
297,
10943,
29901,
13,
9651,
736,
7700,
13,
1678,
736,
5852,
13,
13,
13,
29937,
29933,
8605,
29899,
2886,
292,
29889,
13,
1753,
1284,
29918,
19515,
2710,
29898,
4262,
1469,
1125,
13,
1678,
565,
451,
338,
29918,
18045,
29898,
4262,
1469,
1125,
13,
4706,
12020,
12367,
2392,
703,
2525,
18045,
3983,
2609,
367,
9528,
363,
28635,
2710,
1159,
13,
1678,
396,
6644,
13,
1678,
19356,
353,
5159,
13,
1678,
28635,
2710,
353,
5159,
13,
1678,
396,
18405,
393,
25388,
385,
7636,
5382,
6275,
29892,
6057,
360,
9998,
29892,
322,
12747,
565,
278,
3983,
338,
1603,
6631,
13,
1678,
363,
1369,
297,
3983,
1469,
29889,
8149,
7295,
13,
4706,
363,
1095,
297,
3983,
1469,
29961,
2962,
5387,
13,
9651,
565,
313,
2962,
29892,
1095,
29897,
297,
19356,
470,
313,
355,
29892,
1369,
29897,
297,
19356,
29901,
13,
18884,
6773,
13,
9651,
19356,
29889,
4397,
3552,
2962,
29892,
1095,
876,
13,
9651,
5694,
29954,
1469,
353,
6483,
8552,
29898,
4262,
1469,
29897,
13,
9651,
3349,
29918,
12864,
29898,
2962,
29892,
1095,
29892,
5694,
29954,
1469,
29897,
13,
9651,
565,
451,
338,
29918,
18045,
29898,
7382,
29954,
1469,
1125,
13,
18884,
28635,
2710,
29889,
4397,
3552,
2962,
29892,
1095,
876,
13,
1678,
736,
28635,
2710,
13,
13,
13,
29937,
6678,
393,
784,
14128,
267,
263,
1051,
310,
8857,
964,
263,
2323,
1051,
13,
1753,
4770,
27756,
29918,
1761,
29918,
1761,
29898,
1761,
1293,
29892,
16732,
29922,
8824,
1125,
13,
1678,
714,
1293,
353,
5159,
13,
1678,
363,
2944,
297,
1051,
1293,
29901,
13,
4706,
565,
1134,
29898,
667,
29897,
1275,
1051,
29901,
13,
9651,
565,
16732,
29901,
13,
18884,
2944,
353,
4770,
27756,
29918,
1761,
29918,
1761,
29898,
24535,
8552,
29898,
667,
511,
5852,
29897,
13,
9651,
714,
1293,
4619,
2944,
13,
4706,
1683,
29901,
13,
9651,
714,
1293,
29889,
4397,
29898,
667,
29897,
13,
1678,
736,
714,
1293,
13,
13,
13,
29937,
6678,
393,
12747,
565,
599,
4452,
297,
1014,
1293,
526,
297,
5639,
1293,
13,
1753,
4770,
1761,
29918,
11516,
29918,
1761,
29898,
1491,
1293,
29892,
5639,
1293,
1125,
13,
1678,
363,
2944,
297,
1014,
1293,
29901,
13,
4706,
565,
2944,
451,
297,
5639,
1293,
29901,
13,
9651,
736,
7700,
13,
1678,
736,
5852,
13,
13,
13,
29937,
9527,
6219,
357,
13,
1753,
6219,
29918,
348,
18045,
29898,
4262,
1469,
1125,
13,
13,
1678,
565,
338,
29918,
18045,
29898,
4262,
1469,
1125,
13,
4706,
736,
518,
4262,
1469,
29962,
13,
1678,
4489,
29879,
9902,
353,
5159,
13,
1678,
1550,
451,
4770,
1761,
29918,
11516,
29918,
1761,
29898,
4262,
1469,
29889,
8149,
3285,
13,
462,
462,
259,
4770,
27756,
29918,
1761,
29918,
1761,
29898,
29069,
9902,
22164,
13,
4706,
4489,
29879,
9902,
29889,
4397,
29898,
13,
9651,
4489,
29879,
29898,
4262,
1469,
29892,
13,
18884,
12688,
11759,
13,
462,
1678,
4837,
363,
4837,
297,
3983,
1469,
29889,
8149,
580,
13,
462,
1678,
565,
451,
4837,
297,
4770,
27756,
29918,
1761,
29918,
1761,
29898,
29069,
9902,
29897,
13,
462,
3816,
29900,
12622,
13,
1678,
1962,
9527,
29879,
353,
5159,
13,
1678,
363,
1121,
297,
4489,
29879,
9902,
29901,
13,
4706,
1857,
9527,
353,
6571,
13,
4706,
363,
2943,
297,
1121,
29901,
13,
9651,
1857,
9527,
29961,
3177,
29962,
353,
3983,
1469,
29961,
3177,
29962,
13,
4706,
1962,
9527,
29879,
29889,
4397,
29898,
3784,
9527,
29897,
13,
1678,
736,
1962,
9527,
29879,
13,
13,
13,
1753,
6219,
29918,
271,
29918,
18419,
29898,
5451,
4247,
29892,
2943,
29906,
29892,
3983,
1469,
1125,
13,
1678,
12945,
1293,
353,
1284,
29918,
19515,
2710,
29898,
4262,
1469,
29897,
13,
1678,
565,
451,
5135,
5451,
4247,
29892,
2943,
29906,
29897,
297,
12945,
1293,
470,
13,
9651,
313,
3177,
29906,
29892,
6219,
4247,
29897,
297,
12945,
1293,
1125,
13,
4706,
12020,
12367,
2392,
703,
29089,
6219,
3983,
373,
1661,
29899,
18419,
1159,
13,
1678,
714,
9527,
29879,
353,
5159,
13,
1678,
714,
9527,
29879,
29889,
4397,
29898,
24535,
8552,
29898,
4262,
1469,
876,
13,
1678,
714,
9527,
29879,
29889,
4397,
29898,
24535,
8552,
29898,
4262,
1469,
876,
13,
1678,
363,
3957,
297,
714,
9527,
29879,
29961,
29900,
3816,
5451,
4247,
5387,
13,
4706,
565,
3957,
2804,
2943,
29906,
29901,
13,
9651,
3349,
29918,
12864,
29898,
5451,
4247,
29892,
3957,
29892,
714,
9527,
29879,
29961,
29900,
2314,
13,
1678,
12945,
9527,
4037,
29903,
353,
4489,
29879,
29898,
449,
9527,
29879,
29961,
29900,
1402,
6219,
4247,
29897,
13,
1678,
2425,
21533,
353,
6483,
8552,
29898,
449,
9527,
29879,
29961,
29900,
2314,
13,
1678,
363,
2943,
297,
2425,
21533,
29901,
13,
4706,
565,
451,
2943,
297,
12945,
9527,
4037,
29903,
29901,
13,
9651,
3349,
29918,
3177,
29898,
3177,
29892,
714,
9527,
29879,
29961,
29900,
2314,
13,
1678,
2425,
21533,
353,
6483,
8552,
29898,
449,
9527,
29879,
29961,
29896,
2314,
13,
1678,
363,
2943,
297,
2425,
21533,
29901,
13,
4706,
565,
2943,
297,
12945,
9527,
4037,
29903,
322,
2943,
2804,
6219,
4247,
29901,
13,
9651,
3349,
29918,
3177,
29898,
3177,
29892,
714,
9527,
29879,
29961,
29896,
2314,
13,
1678,
736,
714,
9527,
29879,
13,
13,
13,
29937,
29943,
280,
2857,
5314,
2729,
373,
14109,
29915,
29879,
17381,
401,
13,
1753,
9115,
2857,
29898,
4262,
1469,
29892,
1423,
2605,
29922,
5574,
1125,
13,
1678,
9995,
29943,
280,
2857,
29915,
29879,
5687,
363,
9138,
263,
382,
8584,
713,
2224,
297,
385,
563,
1088,
287,
3983,
15945,
29908,
13,
1678,
396,
6644,
13,
1678,
5694,
29954,
1469,
353,
6483,
8552,
29898,
4262,
1469,
29897,
13,
1678,
1095,
9748,
353,
5159,
13,
1678,
396,
25602,
9138,
13,
1678,
363,
2943,
297,
5694,
29954,
1469,
29901,
13,
4706,
565,
7431,
29898,
7382,
29954,
1469,
29961,
3177,
2314,
1273,
29871,
29906,
1275,
29871,
29896,
29901,
13,
9651,
1095,
9748,
29889,
4397,
29898,
3177,
29897,
13,
1678,
565,
7431,
29898,
355,
9748,
29897,
1275,
29871,
29900,
29901,
13,
4706,
1857,
4247,
353,
1051,
29898,
7382,
29954,
1469,
29889,
8149,
3101,
29961,
29900,
29962,
13,
1678,
1683,
29901,
13,
4706,
1857,
4247,
353,
1095,
9748,
29961,
29900,
29962,
13,
1678,
2224,
353,
518,
3784,
4247,
29962,
13,
1678,
396,
6330,
7888,
13,
1678,
1550,
5694,
29954,
1469,
29961,
3784,
4247,
5387,
13,
4706,
396,
9190,
29899,
12864,
29899,
2886,
261,
29889,
27611,
414,
1661,
29899,
19515,
2710,
13,
4706,
28635,
2710,
353,
1284,
29918,
19515,
2710,
29898,
7382,
29954,
1469,
29897,
13,
4706,
1661,
29933,
8605,
20971,
1953,
353,
518,
13,
9651,
3957,
363,
3957,
297,
5694,
29954,
1469,
29961,
3784,
4247,
29962,
13,
9651,
565,
451,
3957,
297,
28635,
2710,
13,
4706,
4514,
13,
4706,
565,
1661,
29933,
8605,
20971,
1953,
29901,
13,
9651,
2446,
4247,
353,
1661,
29933,
8605,
20971,
1953,
29961,
29900,
29962,
13,
4706,
1683,
29901,
13,
9651,
2446,
4247,
353,
5694,
29954,
1469,
29961,
3784,
4247,
3816,
29900,
29962,
13,
4706,
396,
9190,
29899,
3177,
29899,
802,
26420,
322,
2224,
5214,
13,
4706,
3349,
29918,
12864,
29898,
3784,
4247,
29892,
2446,
4247,
29892,
5694,
29954,
1469,
29897,
13,
4706,
565,
451,
5694,
29954,
1469,
29961,
3784,
4247,
5387,
13,
9651,
3349,
29918,
3177,
29898,
3784,
4247,
29892,
5694,
29954,
1469,
29897,
13,
4706,
2224,
29889,
4397,
29898,
4622,
4247,
29897,
13,
4706,
1857,
4247,
353,
2446,
4247,
13,
1678,
396,
2605,
8845,
13,
1678,
565,
1423,
2605,
29901,
13,
4706,
363,
2943,
297,
3983,
1469,
29901,
13,
9651,
363,
3957,
297,
3983,
1469,
29961,
3177,
5387,
13,
18884,
1051,
1323,
7114,
1293,
353,
7700,
13,
18884,
363,
2380,
297,
3464,
29898,
2435,
29898,
2084,
29897,
448,
29871,
29896,
1125,
13,
462,
1678,
565,
4770,
1761,
29918,
11516,
29918,
1761,
4197,
3177,
29892,
3957,
1402,
13,
462,
462,
9651,
518,
2084,
29961,
2248,
1402,
2224,
29961,
2248,
718,
29871,
29896,
5262,
1125,
13,
462,
4706,
1051,
1323,
7114,
1293,
353,
5852,
13,
462,
4706,
2867,
13,
18884,
565,
451,
1051,
1323,
7114,
1293,
29901,
13,
462,
1678,
736,
6213,
13,
1678,
736,
2224,
13,
13,
13,
29937,
15854,
2454,
24368,
310,
3983,
964,
2999,
18445,
411,
382,
8584,
713,
10898,
313,
12256,
383,
28700,
1964,
29897,
13,
29937,
822,
4469,
29918,
5451,
29898,
4262,
1469,
29892,
736,
9527,
29879,
29922,
5574,
29892,
736,
2605,
29879,
29922,
8824,
1125,
13,
29937,
268,
4974,
736,
9527,
29879,
470,
736,
2605,
29879,
29892,
376,
6921,
29918,
5451,
1818,
505,
263,
4629,
736,
995,
1213,
13,
29937,
268,
1962,
353,
6571,
13,
29937,
268,
565,
736,
9527,
29879,
29901,
13,
29937,
308,
1962,
3366,
4262,
29879,
3108,
353,
5159,
13,
29937,
268,
565,
736,
2605,
29879,
29901,
13,
29937,
308,
1962,
3366,
24772,
3108,
353,
5159,
13,
29937,
268,
9115,
2857,
3057,
353,
9115,
2857,
29898,
4262,
1469,
29897,
13,
29937,
268,
565,
9115,
2857,
3057,
29901,
13,
29937,
308,
565,
736,
9527,
29879,
29901,
13,
29937,
632,
1962,
3366,
4262,
29879,
3108,
353,
518,
4262,
1469,
29962,
13,
29937,
308,
565,
736,
2605,
29879,
29901,
13,
29937,
632,
1962,
3366,
24772,
3108,
353,
518,
29888,
280,
2857,
3057,
29962,
13,
29937,
308,
736,
1962,
13,
29937,
268,
321,
8584,
713,
29925,
5708,
353,
5159,
13,
29937,
268,
5694,
29954,
1469,
353,
6483,
8552,
29898,
4262,
1469,
29897,
13,
29937,
268,
1550,
5694,
29954,
1469,
29901,
13,
29937,
308,
1857,
29943,
280,
2857,
353,
9115,
2857,
29898,
7382,
29954,
1469,
29892,
7700,
29897,
13,
29937,
308,
321,
8584,
713,
29925,
5708,
29889,
4397,
29898,
3784,
29943,
280,
2857,
29897,
13,
29937,
308,
565,
736,
9527,
29879,
29901,
13,
29937,
632,
1962,
3366,
4262,
29879,
16862,
4397,
3319,
1800,
13,
29937,
308,
363,
2380,
29892,
2943,
29896,
297,
26985,
29898,
3784,
29943,
280,
2857,
7503,
29899,
29896,
29962,
1125,
13,
29937,
632,
2943,
29906,
353,
1857,
29943,
280,
2857,
29961,
2248,
718,
29871,
29896,
29962,
13,
29937,
632,
3349,
29918,
12864,
29898,
3177,
29896,
29892,
2943,
29906,
29892,
5694,
29954,
1469,
29897,
13,
29937,
632,
565,
736,
9527,
29879,
29901,
13,
29937,
462,
788,
29918,
12864,
29898,
3177,
29896,
29892,
2943,
29906,
29892,
1962,
3366,
4262,
29879,
3108,
14352,
29896,
2314,
13,
29937,
308,
5694,
15637,
29954,
1469,
353,
6483,
8552,
29898,
7382,
29954,
1469,
29897,
13,
29937,
308,
363,
2943,
297,
5694,
15637,
29954,
1469,
29901,
13,
29937,
632,
565,
451,
5694,
29954,
1469,
29961,
3177,
5387,
13,
29937,
462,
565,
736,
9527,
29879,
322,
451,
2943,
297,
4770,
27756,
29918,
1761,
29918,
1761,
29898,
13,
29937,
462,
308,
321,
8584,
713,
29925,
5708,
1125,
13,
29937,
462,
268,
1962,
3366,
4262,
29879,
16862,
4397,
4197,
3177,
2314,
13,
29937,
462,
3349,
29918,
3177,
29898,
3177,
29892,
5694,
29954,
1469,
29897,
13,
29937,
308,
628,
5694,
15637,
29954,
1469,
13,
29937,
268,
565,
736,
2605,
29879,
29901,
13,
29937,
308,
1962,
3366,
24772,
3108,
353,
321,
8584,
713,
29925,
5708,
13,
29937,
268,
736,
1962,
2
] |
main.py | wdsrocha/anime-recommender | 0 | 144203 | from src import preprocessing, telegram_bot
if __name__ == "__main__":
preprocessing.main()
telegram_bot.main()
| [
1,
515,
4765,
1053,
758,
19170,
29892,
4382,
1393,
29918,
7451,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
758,
19170,
29889,
3396,
580,
13,
1678,
4382,
1393,
29918,
7451,
29889,
3396,
580,
13,
2
] |
direct_gd_predict/hash-profile.py | wac/meshop | 1 | 12609 | <reponame>wac/meshop<gh_stars>1-10
import sys
import heapq
import optparse
from bitcount2 import bitcount
hasher={}
profile={}
key_list=[]
key_col=0
def usage():
print sys.argv[0]," [profile_file]"
print " Load the profile lines from profile_file"
print " Hash function uses the features listed in profile_file"
print " and tests for p-value greater/less than or equal (0/1)"
print " Hash all the profiles from stdin"
exit(1)
def do_hash(hasher, p, key_list):
hashval=""
# for k, v in hasher.iteritems():
for k in key_list:
v=hasher[k]
if k in p and p[k] < v:
hashval=hashval+"1"
else:
hashval=hashval+"0"
return hashval
sep='|'
key_col=0
#feature_col=1
#score_col=6
in_feature_col=0
in_score_col=1
process_feature_col=1
process_score_col=6
parser = optparse.OptionParser()
#parser.add_option("-n", dest="heapsize",
# default=50, action="store", type="int")
#parser.add_option("-R", "--random", dest="use_random",
# default=False, action="store_true")
(options, args) = parser.parse_args(sys.argv)
if (len(args) > 1):
profile_filename=args[1]
else:
usage()
for line in open(profile_filename):
if line[0]=='#':
continue
tuples=line.strip().split(sep)
key=tuples[in_feature_col]
key_list.append(key)
hasher[key]=tuples[in_score_col]
curr_profile={}
old_key=""
for line in sys.stdin:
line=line.strip()
if line[0]=='#':
print line
continue
tuples=line.split(sep)
curr_key=tuples[key_col]
if not old_key:
old_key=curr_key
if not old_key==curr_key:
hashval=do_hash(hasher, curr_profile, key_list)
hashval_int=int(hashval, 2)
print old_key+sep+hashval+sep+str(hashval_int)+sep+str(bitcount(hashval_int))
curr_profile={}
old_key=curr_key
curr_profile[tuples[process_feature_col]]=tuples[process_score_col]
hashval=do_hash(hasher, curr_profile, key_list)
hashval_int=int(hashval, 2)
print old_key+sep+hashval+sep+str(hashval_int)+sep+str(bitcount(hashval_int))
| [
1,
529,
276,
1112,
420,
29958,
29893,
562,
29914,
4467,
29882,
459,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
10876,
13,
5215,
16947,
29939,
13,
5215,
3523,
5510,
13,
3166,
2586,
2798,
29906,
1053,
2586,
2798,
13,
13,
8568,
261,
3790,
29913,
13,
10185,
3790,
29913,
13,
1989,
29918,
1761,
29922,
2636,
13,
13,
1989,
29918,
1054,
29922,
29900,
13,
13,
1753,
8744,
7295,
13,
1678,
1596,
10876,
29889,
19218,
29961,
29900,
1402,
29908,
518,
10185,
29918,
1445,
18017,
13,
1678,
1596,
376,
29871,
16012,
278,
8722,
3454,
515,
8722,
29918,
1445,
29908,
13,
1678,
1596,
376,
29871,
11874,
740,
3913,
278,
5680,
9904,
297,
8722,
29918,
1445,
29908,
13,
1678,
1596,
376,
1678,
322,
6987,
363,
282,
29899,
1767,
7621,
29914,
2222,
1135,
470,
5186,
313,
29900,
29914,
29896,
5513,
13,
1678,
1596,
376,
29871,
11874,
599,
278,
28723,
515,
3659,
262,
29908,
29871,
13,
1678,
6876,
29898,
29896,
29897,
13,
13,
1753,
437,
29918,
8568,
29898,
8568,
261,
29892,
282,
29892,
1820,
29918,
1761,
1125,
13,
1678,
6608,
791,
13776,
13,
268,
13,
1678,
396,
1678,
363,
413,
29892,
325,
297,
756,
2276,
29889,
1524,
7076,
7295,
13,
1678,
363,
413,
297,
1820,
29918,
1761,
29901,
13,
4706,
325,
29922,
8568,
261,
29961,
29895,
29962,
13,
4706,
565,
413,
297,
282,
322,
282,
29961,
29895,
29962,
529,
325,
29901,
13,
9651,
6608,
791,
29922,
8568,
791,
13578,
29896,
29908,
13,
4706,
1683,
29901,
13,
9651,
6608,
791,
29922,
8568,
791,
13578,
29900,
29908,
13,
1678,
736,
6608,
791,
13,
13,
19570,
2433,
29989,
29915,
13,
1989,
29918,
1054,
29922,
29900,
13,
29937,
14394,
29918,
1054,
29922,
29896,
13,
29937,
13628,
29918,
1054,
29922,
29953,
13,
262,
29918,
14394,
29918,
1054,
29922,
29900,
13,
262,
29918,
13628,
29918,
1054,
29922,
29896,
13,
5014,
29918,
14394,
29918,
1054,
29922,
29896,
13,
5014,
29918,
13628,
29918,
1054,
29922,
29953,
13,
13,
13,
16680,
353,
3523,
5510,
29889,
8375,
11726,
580,
13,
29937,
16680,
29889,
1202,
29918,
3385,
703,
29899,
29876,
613,
2731,
543,
354,
481,
2311,
613,
13,
29937,
462,
29871,
2322,
29922,
29945,
29900,
29892,
3158,
543,
8899,
613,
1134,
543,
524,
1159,
13,
29937,
16680,
29889,
1202,
29918,
3385,
703,
29899,
29934,
613,
376,
489,
8172,
613,
2731,
543,
1509,
29918,
8172,
613,
13,
29937,
462,
29871,
2322,
29922,
8824,
29892,
3158,
543,
8899,
29918,
3009,
1159,
13,
13,
29898,
6768,
29892,
6389,
29897,
353,
13812,
29889,
5510,
29918,
5085,
29898,
9675,
29889,
19218,
29897,
13,
13,
361,
313,
2435,
29898,
5085,
29897,
1405,
29871,
29896,
1125,
13,
1678,
8722,
29918,
9507,
29922,
5085,
29961,
29896,
29962,
13,
2870,
29901,
13,
1678,
8744,
580,
13,
13,
1454,
1196,
297,
1722,
29898,
10185,
29918,
9507,
1125,
13,
1678,
565,
1196,
29961,
29900,
29962,
1360,
29915,
29937,
2396,
13,
4706,
6773,
13,
1678,
5291,
2701,
29922,
1220,
29889,
17010,
2141,
5451,
29898,
19570,
29897,
13,
1678,
1820,
29922,
9161,
2701,
29961,
262,
29918,
14394,
29918,
1054,
29962,
13,
1678,
1820,
29918,
1761,
29889,
4397,
29898,
1989,
29897,
13,
1678,
756,
2276,
29961,
1989,
13192,
9161,
2701,
29961,
262,
29918,
13628,
29918,
1054,
29962,
13,
13,
21962,
29918,
10185,
3790,
29913,
13,
1025,
29918,
1989,
13776,
13,
13,
1454,
1196,
297,
10876,
29889,
4172,
262,
29901,
13,
1678,
1196,
29922,
1220,
29889,
17010,
580,
13,
1678,
565,
1196,
29961,
29900,
29962,
1360,
29915,
29937,
2396,
13,
4706,
1596,
1196,
13,
4706,
6773,
13,
1678,
5291,
2701,
29922,
1220,
29889,
5451,
29898,
19570,
29897,
13,
13,
1678,
16256,
29918,
1989,
29922,
9161,
2701,
29961,
1989,
29918,
1054,
29962,
13,
13,
1678,
565,
451,
2030,
29918,
1989,
29901,
13,
4706,
2030,
29918,
1989,
29922,
21962,
29918,
1989,
13,
268,
13,
1678,
565,
451,
2030,
29918,
1989,
1360,
21962,
29918,
1989,
29901,
13,
4706,
6608,
791,
29922,
1867,
29918,
8568,
29898,
8568,
261,
29892,
16256,
29918,
10185,
29892,
1820,
29918,
1761,
29897,
13,
4706,
6608,
791,
29918,
524,
29922,
524,
29898,
8568,
791,
29892,
29871,
29906,
29897,
13,
4706,
1596,
2030,
29918,
1989,
29974,
19570,
29974,
8568,
791,
29974,
19570,
29974,
710,
29898,
8568,
791,
29918,
524,
7240,
19570,
29974,
710,
29898,
2966,
2798,
29898,
8568,
791,
29918,
524,
876,
13,
4706,
16256,
29918,
10185,
3790,
29913,
13,
4706,
2030,
29918,
1989,
29922,
21962,
29918,
1989,
13,
13,
1678,
16256,
29918,
10185,
29961,
9161,
2701,
29961,
5014,
29918,
14394,
29918,
1054,
5262,
29922,
9161,
2701,
29961,
5014,
29918,
13628,
29918,
1054,
29962,
13,
13,
8568,
791,
29922,
1867,
29918,
8568,
29898,
8568,
261,
29892,
16256,
29918,
10185,
29892,
1820,
29918,
1761,
29897,
13,
8568,
791,
29918,
524,
29922,
524,
29898,
8568,
791,
29892,
29871,
29906,
29897,
13,
2158,
2030,
29918,
1989,
29974,
19570,
29974,
8568,
791,
29974,
19570,
29974,
710,
29898,
8568,
791,
29918,
524,
7240,
19570,
29974,
710,
29898,
2966,
2798,
29898,
8568,
791,
29918,
524,
876,
13,
13,
2
] |
test/integration/broken/maint/test_vpc_host_maintenance.py | elShiaLabeouf/cloudstack | 1 | 134915 | <filename>test/integration/broken/maint/test_vpc_host_maintenance.py
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
""" Component tests VM life cycle in VPC network functionality
"""
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
import unittest
from marvin.cloudstackAPI import migrateSystemVm
from marvin.lib.utils import cleanup_resources
from marvin.lib.base import (Host,
VirtualMachine,
ServiceOffering,
VPC,
VpcOffering,
Router,
Network,
NetworkOffering,
Cluster,
Account)
from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup)
import time
class Services:
"""Test VM life cycle in VPC network services
"""
def __init__(self):
self.services = {
"account": {
"email": "<EMAIL>",
"firstname": "Test",
"lastname": "User",
"username": "test",
# Random characters are appended for unique
# username
"password": "password",
},
"service_offering": {
"name": "Tiny Instance",
"displaytext": "Tiny Instance",
"cpunumber": 1,
"cpuspeed": 100,
"memory": 64,
},
"service_offering_1": {
"name": "Tiny Instance- tagged host 1",
"displaytext": "Tiny off-tagged host2",
"cpunumber": 1,
"cpuspeed": 100,
"memory": 64,
"hosttags": "hosttag1"
},
"service_offering_2": {
"name": "Tiny Instance- tagged host 2",
"displaytext": "Tiny off-tagged host2",
"cpunumber": 1,
"cpuspeed": 100,
"memory": 64,
"hosttags": "hosttag2"
},
"network_offering": {
"name": 'VPC Network offering',
"displaytext": 'VPC Network off',
"guestiptype": 'Isolated',
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Lb,UserData,StaticNat,NetworkACL',
"traffictype": 'GUEST',
"availability": 'Optional',
"useVpc": 'on',
"serviceProviderList": {
"Dhcp": 'VpcVirtualRouter',
"Dns": 'VpcVirtualRouter',
"SourceNat": 'VpcVirtualRouter',
"PortForwarding": 'VpcVirtualRouter',
"Lb": 'VpcVirtualRouter',
"UserData": 'VpcVirtualRouter',
"StaticNat": 'VpcVirtualRouter',
"NetworkACL": 'VpcVirtualRouter'
},
},
"network_offering_no_lb": {
"name": 'VPC Network offering',
"displaytext": 'VPC Network off',
"guestiptype": 'Isolated',
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,UserData,StaticNat,NetworkACL',
"traffictype": 'GUEST',
"availability": 'Optional',
"useVpc": 'on',
"serviceProviderList": {
"Dhcp": 'VpcVirtualRouter',
"Dns": 'VpcVirtualRouter',
"SourceNat": 'VpcVirtualRouter',
"PortForwarding": 'VpcVirtualRouter',
"UserData": 'VpcVirtualRouter',
"StaticNat": 'VpcVirtualRouter',
"NetworkACL": 'VpcVirtualRouter'
},
},
"network_off_shared": {
"name": 'Shared Network offering',
"displaytext": 'Shared Network offering',
"guestiptype": 'Shared',
"traffictype": 'GUEST',
"availability": 'Optional',
"useVpc": 'on',
"specifyIpRanges": True,
"specifyVlan": True
},
"vpc_offering": {
"name": 'VPC off',
"displaytext": 'VPC off',
"supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Lb,UserData,StaticNat',
},
"vpc": {
"name": "TestVPC",
"displaytext": "TestVPC",
"cidr": '10.0.0.1/24'
},
"network": {
"name": "Test Network",
"displaytext": "Test Network",
"netmask": '255.255.255.0',
"limit": 5,
# Max networks allowed as per hypervisor
# Xenserver -> 5, VMWare -> 9
},
"lbrule": {
"name": "SSH",
"alg": "leastconn",
# Algorithm used for load balancing
"privateport": 22,
"publicport": 2222,
"openfirewall": False,
"startport": 2222,
"endport": 2222,
"protocol": "TCP",
"cidrlist": '0.0.0.0/0',
},
"natrule": {
"privateport": 22,
"publicport": 22,
"startport": 22,
"endport": 22,
"protocol": "TCP",
"cidrlist": '0.0.0.0/0',
},
"fw_rule": {
"startport": 1,
"endport": 6000,
"cidr": '0.0.0.0/0',
# Any network (For creating FW rule)
"protocol": "TCP"
},
"http_rule": {
"startport": 80,
"endport": 80,
"cidrlist": '0.0.0.0/0',
"protocol": "ICMP"
},
"virtual_machine": {
"displayname": "Test VM",
"username": "root",
"password": "password",
"ssh_port": 22,
"hypervisor": 'XenServer',
# Hypervisor type should be same as
# hypervisor type of cluster
"privateport": 22,
"publicport": 22,
"protocol": 'TCP',
"userdata": 'This is sample data',
},
"ostype": 'CentOS 5.3 (64-bit)',
# Cent OS 5.3 (64 bit)
"sleep": 60,
"timeout": 30,
"mode": 'advanced'
}
class TestVMLifeCycleHostmaintenance(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls.testClient = super(TestVMLifeCycleHostmaintenance, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.hypervisor = cls.testClient.getHypervisorInfo()
if cls.hypervisor.lower() in ['lxc']:
raise unittest.SkipTest("Template creation from root volume is not supported in LXC")
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
clusterWithSufficientHosts = None
clusters = Cluster.list(cls.api_client, zoneid=cls.zone.id)
for cluster in clusters:
cls.hosts = Host.list(cls.api_client, clusterid=cluster.id)
if len(cls.hosts) >= 2:
clusterWithSufficientHosts = cluster
break
if clusterWithSufficientHosts is None:
raise unittest.SkipTest("No Cluster with 2 hosts found")
Host.update(cls.api_client, id=cls.hosts[0].id, hosttags="hosttag1")
Host.update(cls.api_client, id=cls.hosts[1].id, hosttags="hosttag2")
cls.service_offering_1 = ServiceOffering.create(
cls.api_client,
cls.services["service_offering_1"]
)
cls.service_offering_2 = ServiceOffering.create(
cls.api_client,
cls.services["service_offering_2"]
)
cls.vpc_off = VpcOffering.create(
cls.api_client,
cls.services["vpc_offering"]
)
cls.vpc_off.update(cls.api_client, state='Enabled')
cls.account = Account.create(
cls.api_client,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
cls.vpc_off = VpcOffering.create(
cls.api_client,
cls.services["vpc_offering"]
)
cls.vpc_off.update(cls.api_client, state='Enabled')
cls.services["vpc"]["cidr"] = '10.1.1.1/16'
cls.vpc = VPC.create(
cls.api_client,
cls.services["vpc"],
vpcofferingid=cls.vpc_off.id,
zoneid=cls.zone.id,
account=cls.account.name,
domainid=cls.account.domainid
)
cls.nw_off = NetworkOffering.create(
cls.api_client,
cls.services["network_offering"],
conservemode=False
)
# Enable Network offering
cls.nw_off.update(cls.api_client, state='Enabled')
# Creating network using the network offering created
cls.network_1 = Network.create(
cls.api_client,
cls.services["network"],
accountid=cls.account.name,
domainid=cls.account.domainid,
networkofferingid=cls.nw_off.id,
zoneid=cls.zone.id,
gateway='10.1.1.1',
vpcid=cls.vpc.id
)
cls.nw_off_no_lb = NetworkOffering.create(
cls.api_client,
cls.services["network_offering_no_lb"],
conservemode=False
)
# Enable Network offering
cls.nw_off_no_lb.update(cls.api_client, state='Enabled')
# Creating network using the network offering created
cls.network_2 = Network.create(
cls.api_client,
cls.services["network"],
accountid=cls.account.name,
domainid=cls.account.domainid,
networkofferingid=cls.nw_off_no_lb.id,
zoneid=cls.zone.id,
gateway='10.1.2.1',
vpcid=cls.vpc.id
)
# Spawn an instance in that network
cls.vm_1 = VirtualMachine.create(
cls.api_client,
cls.services["virtual_machine"],
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering_1.id,
networkids=[str(cls.network_1.id)]
)
# Spawn an instance in that network
cls.vm_2 = VirtualMachine.create(
cls.api_client,
cls.services["virtual_machine"],
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering_1.id,
networkids=[str(cls.network_1.id)]
)
cls.vm_3 = VirtualMachine.create(
cls.api_client,
cls.services["virtual_machine"],
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering_2.id,
networkids=[str(cls.network_2.id)]
)
routers = Router.list(
cls.api_client,
account=cls.account.name,
domainid=cls.account.domainid,
listall=True
)
if isinstance(routers, list):
cls.vpcvr = routers[0]
cls._cleanup = [
cls.service_offering_1,
cls.service_offering_2,
cls.nw_off,
cls.nw_off_no_lb,
]
return
@classmethod
def tearDownClass(cls):
try:
#Delete the host tags
Host.update(cls.api_client, id=cls.hosts[0].id, hosttags="")
Host.update(cls.api_client, id=cls.hosts[1].id, hosttags="")
cls.account.delete(cls.api_client)
wait_for_cleanup(cls.api_client, ["account.cleanup.interval"])
#Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
cls.vpc_off.delete(cls.api_client)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.debug("Check the status of VPC virtual router")
routers = Router.list(
self.apiclient,
networkid=self.network_1.id,
listall=True
)
if not isinstance(routers, list):
raise Exception("No response from list routers API")
self.router = routers[0]
if self.router.state == "Running":
self.debug("Verified that the Router is in Running State")
self.cleanup = []
return
def tearDown(self):
try:
#Clean up, terminate the created network offerings
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def validate_vm_deployment(self):
"""Validates VM deployment on different hosts"""
vms = VirtualMachine.list(
self.apiclient,
account=self.account.name,
domainid=self.account.domainid,
networkid=self.network_1.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"List VMs shall return a valid response"
)
host_1 = vms[0].hostid
self.debug("Host for network 1: %s" % vms[0].hostid)
vms = VirtualMachine.list(
self.apiclient,
account=self.account.name,
domainid=self.account.domainid,
networkid=self.network_2.id,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"List VMs shall return a valid response"
)
host_2 = vms[0].hostid
self.debug("Host for network 2: %s" % vms[0].hostid)
self.assertNotEqual(
host_1,
host_2,
"Both the virtual machines should be deployed on diff hosts "
)
return
@attr(tags=["advanced", "intervlan"])
def test_01_enable_maintenance_with_vpc_nw(self):
""" Test enable Maintenance Mode on Hosts which have VPC elements
"""
# Validate the following
# 1. Create a VPC with cidr - 10.1.1.1/16
# 2. Add network1(10.1.1.1/24) and network2(10.1.2.1/24) to this VPC.
# 3. Deploy vm1 and vm2 in network1 and vm3 and vm4 in network2. Make
# sure vm1 and vm3 are deployed on one host in the cluster while
# vm2 and vm4 are deployed on the other host in the cluster. This
# can be done using host's tags & service offerings with host tags
# Steps:
# 1.Enable Maintenance on one of host on which VPCVR is present
# Validations:
# 1. Successfully push the host into maintenance mode.
# 2. VMs present on the above host should successfully migrate to the
# other host present in the cluster
Host.update(self.apiclient, id=self.hosts[0].id, hosttags="hosttag1,hosttag2")
Host.update(self.apiclient, id=self.hosts[1].id, hosttags="hosttag1,hosttag2")
self.validate_vm_deployment()
self.debug("Stop the host on which the VPC virtual router is running")
try:
Host.enableMaintenance(self.apiclient, id=self.vpcvr.hostid)
except Exception as e:
self.fail("Failed to enable maintenance mode on host: %s" % e)
self.debug(
"Check if all instances belonging to the account are up again?")
routers = Router.list(
self.apiclient,
account=self.account.name,
domainid=self.account.domainid,
listall=True
)
self.assertEqual(
isinstance(routers, list),
True,
"List routers shall return a valid VPCVR for account"
)
router = routers[0]
try:
timeout = self.services["timeout"]
self.debug("Timeout Value %d : " % timeout)
while True:
list_router_response = Router.list(
self.apiclient,
id = router.id,
state = "Running"
)
if list_router_response is not None:
break
elif timeout == 0:
raise Exception("Router state should be running after migration")
time.sleep(self.services["sleep"])
timeout = timeout - 1
self.debug("Waiting for %d seconds - %d tries left" % (self.services["sleep"],timeout))
self.debug("Verified that the Router is in Running State")
except Exception as e:
self.fail("Failed to find the Router in Running state %s " % e)
vms = VirtualMachine.list(
self.apiclient,
account=self.account.name,
domainid=self.account.domainid,
listall=True
)
self.assertEqual(
isinstance(vms, list),
True,
"VM response should return instances running for account"
)
for vm in vms:
self.assertEqual(
vm.state,
"Running",
"Vm state should be running after migration"
)
return
@attr(tags=["advanced", "intervlan"])
def test_02_cancel_maintenance(self):
""" Test cancel Maintenance Mode on the above Hosts + Migrate VMs Back
"""
# Steps
# 1. Cancel Maintenance Mode on the host.
# 2. Migrate the VMs back onto the host on which Maintenance mode is
# cancelled.
# Validate the following
# 1. Successfully cancel the Maintenance mode on the host.
# 2. Migrate the VMs back successfully onto the host.
# 3. Check that the network connectivity exists with the migrated VMs.
try:
timeout = self.services["timeout"]
while True:
list_host_response = Host.list(
self.apiclient,
id=self.vpcvr.hostid,
resourcestate="Maintenance")
if list_host_response is not None:
break
elif timeout == 0:
raise Exception("Failed to list the Host in Maintenance State")
time.sleep(self.services["sleep"])
timeout = timeout - 1
self.debug("Verified that the Host is in Maintenance State")
except:
self.fail("Failed to find the Host in maintenance state")
self.debug("Cancel host maintenence on which the VPCVR is running")
try:
Host.cancelMaintenance(self.apiclient, id=self.vpcvr.hostid)
timeout = self.services["timeout"]
while True:
list_host_response = Host.list(
self.apiclient,
id=self.vpcvr.hostid,
state="Up")
if list_host_response is not None:
break
elif timeout == 0:
raise Exception("Failed to list the Host in Up State after Canceling Maintenance Mode")
time.sleep(self.services["sleep"])
timeout = timeout - 1
self.debug("Verified that the Host is in Up State after Canceling Maintenance Mode")
except Exception as e:
self.fail("Failed to cancel maintenance mode on host: %s" % e)
self.debug(
"Migrating the instances back to the host: %s" %
self.vpcvr.hostid)
try:
cmd = migrateSystemVm.migrateSystemVmCmd()
cmd.hostid = self.vpcvr.hostid
cmd.virtualmachineid = self.vpcvr.id
self.apiclient.migrateSystemVm(cmd)
except Exception as e:
self.fail("Failed to migrate VPCVR back: %s" % e)
self.debug("Check the status of router after migration")
routers = Router.list(
self.apiclient,
id=self.vpcvr.id,
listall=True
)
self.assertEqual(
isinstance(routers, list),
True,
"List routers shall return the valid response"
)
self.assertEqual(
routers[0].state,
"Running",
"Router state should be running"
)
# TODO: Check for the network connectivity
return
@attr(tags=["advanced", "intervlan"])
def test_03_reconnect_host(self):
""" Test reconnect Host which has VPC elements
"""
# Steps:
# 1.Reconnect one of the host on which VPC Virtual Router is present.
# Validate the following
# 1. Host should successfully reconnect.
# 2. Network connectivity to all the VMs on the host should not be
# effected due to reconnection.
try:
timeout = self.services["timeout"]
while True:
list_host_response = Host.list(
self.apiclient,
id=self.vpcvr.hostid,
resourcestate="Enabled")
if list_host_response is not None:
break
elif timeout == 0:
raise Exception("Failed to list the Host in Up State")
time.sleep(self.services["sleep"])
timeout = timeout - 1
self.debug("Verified that the Host is in Up State")
except:
self.fail("Failed to find the Host in Up State")
self.debug("Reconnecting the host where VPC VR is running")
try:
Host.reconnect(self.apiclient, id=self.vpcvr.hostid)
except Exception as e:
self.fail("Failed to reconnect to host: %s" % e)
self.debug("Check the status of router after migration")
routers = Router.list(
self.apiclient,
id=self.vpcvr.id,
listall=True
)
self.assertEqual(
isinstance(routers, list),
True,
"List routers shall return the valid response"
)
self.assertEqual(
routers[0].state,
"Running",
"Router state should be running"
)
# TODO: Check for the network connectivity
return
| [
1,
529,
9507,
29958,
1688,
29914,
27925,
29914,
6729,
1717,
29914,
29885,
2365,
29914,
1688,
29918,
29894,
6739,
29918,
3069,
29918,
3396,
841,
749,
29889,
2272,
13,
29937,
10413,
21144,
304,
278,
13380,
18540,
10606,
313,
3289,
29943,
29897,
1090,
697,
13,
29937,
470,
901,
17737,
3406,
19405,
8571,
4110,
29889,
29871,
2823,
278,
6058,
12107,
934,
13,
29937,
13235,
411,
445,
664,
363,
5684,
2472,
13,
29937,
11211,
3509,
1266,
27428,
29889,
29871,
450,
3339,
29943,
7794,
11259,
445,
934,
13,
29937,
304,
366,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
13,
29937,
376,
29931,
293,
1947,
1496,
366,
1122,
451,
671,
445,
934,
5174,
297,
752,
13036,
13,
29937,
411,
278,
19245,
29889,
29871,
887,
1122,
4017,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
259,
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,
13,
29937,
7047,
13235,
1090,
278,
19245,
338,
13235,
373,
385,
13,
29937,
376,
3289,
8519,
29908,
350,
3289,
3235,
29892,
399,
1806,
8187,
2692,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
13,
29937,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
29871,
2823,
278,
19245,
363,
278,
13,
29937,
2702,
4086,
14765,
1076,
11239,
322,
27028,
13,
29937,
1090,
278,
19245,
29889,
13,
13,
15945,
29908,
15924,
6987,
11400,
2834,
11412,
297,
478,
9026,
3564,
9863,
13,
15945,
29908,
13,
29937,
17518,
9959,
3382,
2540,
13,
3166,
26414,
29889,
12800,
29889,
1131,
1091,
1053,
12421,
13,
3166,
1766,
3845,
29889,
9274,
1429,
3057,
8259,
1053,
9570,
1429,
3057,
8259,
13,
5215,
443,
27958,
13,
3166,
1766,
3845,
29889,
9274,
1429,
8787,
1053,
9725,
403,
3924,
29963,
29885,
13,
3166,
1766,
3845,
29889,
1982,
29889,
13239,
1053,
5941,
786,
29918,
13237,
13,
3166,
1766,
3845,
29889,
1982,
29889,
3188,
1053,
313,
8514,
29892,
13,
462,
632,
19181,
29076,
29892,
13,
462,
632,
6692,
2776,
571,
292,
29892,
13,
462,
632,
478,
9026,
29892,
13,
462,
632,
478,
6739,
2776,
571,
292,
29892,
13,
462,
632,
390,
5561,
29892,
13,
462,
632,
8527,
29892,
13,
462,
632,
8527,
2776,
571,
292,
29892,
13,
462,
632,
2233,
5402,
29892,
13,
462,
632,
16535,
29897,
13,
3166,
1766,
3845,
29889,
1982,
29889,
9435,
1053,
313,
657,
29918,
7247,
29892,
13,
462,
1669,
679,
29918,
8028,
29892,
13,
462,
1669,
679,
29918,
6886,
29892,
13,
462,
1669,
4480,
29918,
1454,
29918,
14941,
786,
29897,
13,
5215,
931,
13,
13,
13,
1990,
15538,
29901,
13,
1678,
9995,
3057,
11400,
2834,
11412,
297,
478,
9026,
3564,
5786,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
29889,
9916,
353,
426,
13,
462,
308,
376,
10149,
1115,
426,
13,
462,
462,
1678,
376,
5269,
1115,
9872,
26862,
6227,
28341,
13,
462,
462,
1678,
376,
4102,
978,
1115,
376,
3057,
613,
13,
462,
462,
1678,
376,
4230,
978,
1115,
376,
2659,
613,
13,
462,
462,
1678,
376,
6786,
1115,
376,
1688,
613,
13,
462,
462,
1678,
396,
16968,
4890,
526,
623,
2760,
363,
5412,
13,
462,
462,
1678,
396,
8952,
13,
462,
462,
1678,
376,
5630,
1115,
376,
5630,
613,
13,
462,
462,
1678,
2981,
13,
462,
308,
376,
5509,
29918,
974,
571,
292,
1115,
426,
13,
462,
462,
1678,
376,
978,
1115,
376,
29911,
4901,
2799,
749,
613,
13,
462,
462,
1678,
376,
4990,
726,
1115,
376,
29911,
4901,
2799,
749,
613,
13,
462,
462,
1678,
376,
6814,
348,
2807,
1115,
29871,
29896,
29892,
13,
462,
462,
1678,
376,
6814,
375,
412,
287,
1115,
29871,
29896,
29900,
29900,
29892,
13,
462,
462,
1678,
376,
14834,
1115,
29871,
29953,
29946,
29892,
13,
462,
462,
1678,
2981,
13,
462,
4706,
376,
5509,
29918,
974,
571,
292,
29918,
29896,
1115,
426,
13,
462,
462,
1678,
376,
978,
1115,
376,
29911,
4901,
2799,
749,
29899,
4055,
3192,
3495,
29871,
29896,
613,
13,
462,
462,
1678,
376,
4990,
726,
1115,
376,
29911,
4901,
1283,
29899,
4039,
3192,
3495,
29906,
613,
13,
462,
462,
1678,
376,
6814,
348,
2807,
1115,
29871,
29896,
29892,
13,
462,
462,
1678,
376,
6814,
375,
412,
287,
1115,
29871,
29896,
29900,
29900,
29892,
13,
462,
462,
1678,
376,
14834,
1115,
29871,
29953,
29946,
29892,
13,
462,
462,
1678,
376,
3069,
11338,
1115,
376,
3069,
4039,
29896,
29908,
13,
462,
462,
1678,
2981,
13,
462,
308,
376,
5509,
29918,
974,
571,
292,
29918,
29906,
1115,
426,
13,
462,
462,
1678,
376,
978,
1115,
376,
29911,
4901,
2799,
749,
29899,
4055,
3192,
3495,
29871,
29906,
613,
13,
462,
462,
1678,
376,
4990,
726,
1115,
376,
29911,
4901,
1283,
29899,
4039,
3192,
3495,
29906,
613,
13,
462,
462,
1678,
376,
6814,
348,
2807,
1115,
29871,
29896,
29892,
13,
462,
462,
1678,
376,
6814,
375,
412,
287,
1115,
29871,
29896,
29900,
29900,
29892,
13,
462,
462,
1678,
376,
14834,
1115,
29871,
29953,
29946,
29892,
13,
462,
462,
1678,
376,
3069,
11338,
1115,
376,
3069,
4039,
29906,
29908,
13,
462,
462,
1678,
2981,
13,
462,
308,
376,
11618,
29918,
974,
571,
292,
1115,
426,
13,
462,
462,
1678,
376,
978,
1115,
525,
29963,
9026,
8527,
27032,
742,
13,
462,
462,
1678,
376,
4990,
726,
1115,
525,
29963,
9026,
8527,
1283,
742,
13,
462,
462,
1678,
376,
2543,
11521,
415,
668,
1115,
525,
29902,
2929,
630,
742,
13,
462,
462,
1678,
376,
23765,
9916,
1115,
525,
29928,
29882,
6814,
29892,
29928,
1983,
29892,
4435,
29940,
271,
29892,
2290,
2831,
1328,
292,
29892,
29931,
29890,
29892,
2659,
1469,
29892,
17046,
29940,
271,
29892,
13724,
2477,
29931,
742,
13,
462,
462,
1678,
376,
3018,
600,
919,
668,
1115,
525,
29954,
4462,
1254,
742,
13,
462,
462,
1678,
376,
485,
737,
3097,
1115,
525,
27636,
742,
13,
462,
462,
1678,
376,
1509,
29963,
6739,
1115,
525,
265,
742,
13,
462,
462,
1678,
376,
5509,
6980,
1293,
1115,
426,
13,
462,
462,
9651,
376,
29928,
29882,
6814,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
29928,
1983,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
4435,
29940,
271,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
2290,
2831,
1328,
292,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
29931,
29890,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
2659,
1469,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
17046,
29940,
271,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
13724,
2477,
29931,
1115,
525,
29963,
6739,
21287,
23971,
29915,
13,
462,
462,
4706,
2981,
13,
462,
18884,
2981,
13,
462,
308,
376,
11618,
29918,
974,
571,
292,
29918,
1217,
29918,
27728,
1115,
426,
13,
462,
462,
1678,
376,
978,
1115,
525,
29963,
9026,
8527,
27032,
742,
13,
462,
462,
1678,
376,
4990,
726,
1115,
525,
29963,
9026,
8527,
1283,
742,
13,
462,
462,
1678,
376,
2543,
11521,
415,
668,
1115,
525,
29902,
2929,
630,
742,
13,
462,
462,
1678,
376,
23765,
9916,
1115,
525,
29928,
29882,
6814,
29892,
29928,
1983,
29892,
4435,
29940,
271,
29892,
2290,
2831,
1328,
292,
29892,
2659,
1469,
29892,
17046,
29940,
271,
29892,
13724,
2477,
29931,
742,
13,
462,
462,
1678,
376,
3018,
600,
919,
668,
1115,
525,
29954,
4462,
1254,
742,
13,
462,
462,
1678,
376,
485,
737,
3097,
1115,
525,
27636,
742,
13,
462,
462,
1678,
376,
1509,
29963,
6739,
1115,
525,
265,
742,
13,
462,
462,
1678,
376,
5509,
6980,
1293,
1115,
426,
13,
462,
462,
9651,
376,
29928,
29882,
6814,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
29928,
1983,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
4435,
29940,
271,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
2290,
2831,
1328,
292,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
2659,
1469,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
17046,
29940,
271,
1115,
525,
29963,
6739,
21287,
23971,
742,
13,
462,
462,
9651,
376,
13724,
2477,
29931,
1115,
525,
29963,
6739,
21287,
23971,
29915,
13,
462,
462,
4706,
2981,
13,
462,
18884,
2981,
13,
462,
308,
376,
11618,
29918,
2696,
29918,
12366,
1115,
426,
13,
462,
462,
1678,
376,
978,
1115,
525,
21741,
8527,
27032,
742,
13,
462,
462,
1678,
376,
4990,
726,
1115,
525,
21741,
8527,
27032,
742,
13,
462,
462,
1678,
376,
2543,
11521,
415,
668,
1115,
525,
21741,
742,
13,
462,
462,
1678,
376,
3018,
600,
919,
668,
1115,
525,
29954,
4462,
1254,
742,
13,
462,
462,
1678,
376,
485,
737,
3097,
1115,
525,
27636,
742,
13,
462,
462,
1678,
376,
1509,
29963,
6739,
1115,
525,
265,
742,
13,
462,
462,
1678,
376,
6550,
1598,
29902,
29886,
29934,
6916,
1115,
5852,
29892,
13,
462,
462,
1678,
376,
6550,
1598,
29963,
6468,
1115,
5852,
13,
462,
462,
1678,
2981,
13,
462,
308,
376,
29894,
6739,
29918,
974,
571,
292,
1115,
426,
13,
462,
462,
1678,
376,
978,
1115,
525,
29963,
9026,
1283,
742,
13,
462,
462,
1678,
376,
4990,
726,
1115,
525,
29963,
9026,
1283,
742,
13,
462,
462,
1678,
376,
23765,
9916,
1115,
525,
29928,
29882,
6814,
29892,
29928,
1983,
29892,
4435,
29940,
271,
29892,
2290,
2831,
1328,
292,
29892,
29931,
29890,
29892,
2659,
1469,
29892,
17046,
29940,
271,
742,
13,
462,
18884,
2981,
13,
462,
308,
376,
29894,
6739,
1115,
426,
13,
462,
462,
376,
978,
1115,
376,
3057,
29963,
9026,
613,
13,
462,
462,
376,
4990,
726,
1115,
376,
3057,
29963,
9026,
613,
13,
462,
462,
376,
25232,
29878,
1115,
525,
29896,
29900,
29889,
29900,
29889,
29900,
29889,
29896,
29914,
29906,
29946,
29915,
13,
462,
462,
2981,
13,
462,
308,
376,
11618,
1115,
426,
13,
462,
462,
29871,
376,
978,
1115,
376,
3057,
8527,
613,
13,
462,
462,
29871,
376,
4990,
726,
1115,
376,
3057,
8527,
613,
13,
462,
462,
29871,
376,
1212,
13168,
1115,
525,
29906,
29945,
29945,
29889,
29906,
29945,
29945,
29889,
29906,
29945,
29945,
29889,
29900,
742,
13,
462,
462,
29871,
376,
13400,
1115,
29871,
29945,
29892,
13,
462,
462,
29871,
396,
5918,
14379,
6068,
408,
639,
11266,
19188,
13,
462,
462,
29871,
396,
1060,
25594,
369,
1599,
29871,
29945,
29892,
11400,
29956,
598,
1599,
29871,
29929,
13,
462,
18884,
2981,
13,
462,
308,
376,
27728,
7491,
1115,
426,
13,
462,
462,
1678,
376,
978,
1115,
376,
1799,
29950,
613,
13,
462,
462,
1678,
376,
9564,
1115,
376,
280,
579,
13082,
613,
13,
462,
462,
1678,
396,
29068,
1304,
363,
2254,
6411,
19985,
13,
462,
462,
1678,
376,
9053,
637,
1115,
29871,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
3597,
637,
1115,
29871,
29906,
29906,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
3150,
8696,
11358,
1115,
7700,
29892,
13,
462,
462,
1678,
376,
2962,
637,
1115,
29871,
29906,
29906,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
355,
637,
1115,
29871,
29906,
29906,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
20464,
1115,
376,
29911,
6271,
613,
13,
462,
462,
1678,
376,
25232,
29878,
1761,
1115,
525,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
29914,
29900,
742,
13,
462,
18884,
2981,
13,
462,
308,
376,
8924,
7491,
1115,
426,
13,
462,
462,
1678,
376,
9053,
637,
1115,
29871,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
3597,
637,
1115,
29871,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
2962,
637,
1115,
29871,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
355,
637,
1115,
29871,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
20464,
1115,
376,
29911,
6271,
613,
13,
462,
462,
1678,
376,
25232,
29878,
1761,
1115,
525,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
29914,
29900,
742,
13,
462,
18884,
2981,
13,
462,
308,
376,
25051,
29918,
7491,
1115,
426,
13,
462,
462,
1678,
376,
2962,
637,
1115,
29871,
29896,
29892,
13,
462,
462,
1678,
376,
355,
637,
1115,
29871,
29953,
29900,
29900,
29900,
29892,
13,
462,
462,
1678,
376,
25232,
29878,
1115,
525,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
29914,
29900,
742,
13,
462,
462,
1678,
396,
3139,
3564,
313,
2831,
4969,
383,
29956,
5751,
29897,
13,
462,
462,
1678,
376,
20464,
1115,
376,
29911,
6271,
29908,
13,
462,
18884,
2981,
13,
462,
308,
376,
1124,
29918,
7491,
1115,
426,
13,
462,
462,
1678,
376,
2962,
637,
1115,
29871,
29947,
29900,
29892,
13,
462,
462,
1678,
376,
355,
637,
1115,
29871,
29947,
29900,
29892,
13,
462,
462,
1678,
376,
25232,
29878,
1761,
1115,
525,
29900,
29889,
29900,
29889,
29900,
29889,
29900,
29914,
29900,
742,
13,
462,
462,
1678,
376,
20464,
1115,
376,
2965,
3580,
29908,
13,
462,
18884,
2981,
13,
462,
308,
376,
18714,
29918,
23523,
1115,
426,
13,
462,
462,
1678,
376,
4990,
978,
1115,
376,
3057,
11400,
613,
13,
462,
462,
1678,
376,
6786,
1115,
376,
4632,
613,
13,
462,
462,
1678,
376,
5630,
1115,
376,
5630,
613,
13,
462,
462,
1678,
376,
15269,
29918,
637,
1115,
29871,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
24947,
19188,
1115,
525,
29990,
264,
6004,
742,
13,
462,
462,
1678,
396,
26078,
19188,
1134,
881,
367,
1021,
408,
13,
462,
462,
1678,
396,
11266,
19188,
1134,
310,
9867,
13,
462,
462,
1678,
376,
9053,
637,
1115,
29871,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
3597,
637,
1115,
29871,
29906,
29906,
29892,
13,
462,
462,
1678,
376,
20464,
1115,
525,
29911,
6271,
742,
13,
462,
462,
1678,
376,
1792,
1272,
1115,
525,
4013,
338,
4559,
848,
742,
13,
462,
18884,
2981,
13,
462,
308,
376,
520,
668,
1115,
525,
23369,
3267,
29871,
29945,
29889,
29941,
313,
29953,
29946,
29899,
2966,
29897,
742,
13,
462,
308,
396,
2895,
6570,
29871,
29945,
29889,
29941,
313,
29953,
29946,
2586,
29897,
13,
462,
308,
376,
17059,
1115,
29871,
29953,
29900,
29892,
13,
462,
308,
376,
15619,
1115,
29871,
29941,
29900,
29892,
13,
462,
308,
376,
8513,
1115,
525,
328,
16858,
29915,
13,
462,
1678,
500,
13,
13,
13,
1990,
4321,
29963,
1988,
1607,
29907,
13317,
8514,
3396,
841,
749,
29898,
9274,
1429,
3057,
8259,
1125,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
731,
3373,
2385,
29898,
25932,
1125,
13,
4706,
1067,
29879,
29889,
1688,
4032,
353,
2428,
29898,
3057,
29963,
1988,
1607,
29907,
13317,
8514,
3396,
841,
749,
29892,
1067,
29879,
467,
657,
29907,
3137,
3057,
4032,
580,
13,
4706,
1067,
29879,
29889,
2754,
29918,
4645,
353,
1067,
29879,
29889,
1688,
4032,
29889,
657,
11713,
4032,
580,
13,
13,
4706,
1067,
29879,
29889,
9916,
353,
15538,
2141,
9916,
13,
4706,
396,
3617,
24385,
29892,
28460,
322,
17475,
13,
4706,
1067,
29879,
29889,
7247,
353,
679,
29918,
7247,
29898,
25932,
29889,
2754,
29918,
4645,
29897,
13,
4706,
1067,
29879,
29889,
8028,
353,
679,
29918,
8028,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
1067,
29879,
29889,
1688,
4032,
29889,
657,
18482,
2831,
24376,
3101,
13,
4706,
1067,
29879,
29889,
6886,
353,
679,
29918,
6886,
29898,
13,
462,
9651,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
9651,
1067,
29879,
29889,
8028,
29889,
333,
29892,
13,
462,
9651,
1067,
29879,
29889,
9916,
3366,
520,
668,
3108,
13,
462,
9651,
1723,
13,
4706,
1067,
29879,
29889,
24947,
19188,
353,
1067,
29879,
29889,
1688,
4032,
29889,
657,
26322,
546,
19188,
3401,
580,
13,
4706,
565,
1067,
29879,
29889,
24947,
19188,
29889,
13609,
580,
297,
6024,
29880,
21791,
2033,
29901,
13,
9651,
12020,
443,
27958,
29889,
15797,
666,
3057,
703,
6733,
11265,
515,
3876,
7977,
338,
451,
6969,
297,
365,
29990,
29907,
1159,
13,
4706,
1067,
29879,
29889,
9916,
3366,
18714,
29918,
23523,
3108,
3366,
8028,
333,
3108,
353,
1067,
29879,
29889,
8028,
29889,
333,
13,
4706,
1067,
29879,
29889,
9916,
3366,
18714,
29918,
23523,
3108,
3366,
6886,
3108,
353,
1067,
29879,
29889,
6886,
29889,
333,
13,
13,
4706,
9867,
3047,
5091,
4543,
8514,
29879,
353,
6213,
13,
4706,
24554,
353,
2233,
5402,
29889,
1761,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
10640,
333,
29922,
25932,
29889,
8028,
29889,
333,
29897,
13,
4706,
363,
9867,
297,
24554,
29901,
13,
9651,
1067,
29879,
29889,
23525,
353,
16956,
29889,
1761,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
9867,
333,
29922,
19594,
29889,
333,
29897,
13,
9651,
565,
7431,
29898,
25932,
29889,
23525,
29897,
6736,
29871,
29906,
29901,
13,
18884,
9867,
3047,
5091,
4543,
8514,
29879,
353,
9867,
13,
18884,
2867,
13,
13,
4706,
565,
9867,
3047,
5091,
4543,
8514,
29879,
338,
6213,
29901,
13,
9651,
12020,
443,
27958,
29889,
15797,
666,
3057,
703,
3782,
2233,
5402,
411,
29871,
29906,
18982,
1476,
1159,
13,
13,
4706,
16956,
29889,
5504,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
1178,
29922,
25932,
29889,
23525,
29961,
29900,
1822,
333,
29892,
3495,
11338,
543,
3069,
4039,
29896,
1159,
13,
4706,
16956,
29889,
5504,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
1178,
29922,
25932,
29889,
23525,
29961,
29896,
1822,
333,
29892,
3495,
11338,
543,
3069,
4039,
29906,
1159,
13,
13,
4706,
1067,
29879,
29889,
5509,
29918,
974,
571,
292,
29918,
29896,
353,
6692,
2776,
571,
292,
29889,
3258,
29898,
13,
462,
462,
9651,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
9651,
1067,
29879,
29889,
9916,
3366,
5509,
29918,
974,
571,
292,
29918,
29896,
3108,
13,
462,
462,
9651,
1723,
13,
4706,
1067,
29879,
29889,
5509,
29918,
974,
571,
292,
29918,
29906,
353,
6692,
2776,
571,
292,
29889,
3258,
29898,
13,
462,
462,
9651,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
9651,
1067,
29879,
29889,
9916,
3366,
5509,
29918,
974,
571,
292,
29918,
29906,
3108,
13,
462,
462,
9651,
1723,
13,
4706,
1067,
29879,
29889,
29894,
6739,
29918,
2696,
353,
478,
6739,
2776,
571,
292,
29889,
3258,
29898,
13,
462,
462,
268,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
268,
1067,
29879,
29889,
9916,
3366,
29894,
6739,
29918,
974,
571,
292,
3108,
13,
462,
462,
268,
1723,
13,
4706,
1067,
29879,
29889,
29894,
6739,
29918,
2696,
29889,
5504,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
2106,
2433,
10861,
1495,
13,
13,
4706,
1067,
29879,
29889,
10149,
353,
16535,
29889,
3258,
29898,
13,
462,
462,
268,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
268,
1067,
29879,
29889,
9916,
3366,
10149,
12436,
13,
462,
462,
268,
4113,
29922,
5574,
29892,
13,
462,
462,
268,
5354,
333,
29922,
25932,
29889,
7247,
29889,
333,
13,
462,
462,
268,
1723,
13,
13,
4706,
1067,
29879,
29889,
29894,
6739,
29918,
2696,
353,
478,
6739,
2776,
571,
292,
29889,
3258,
29898,
13,
462,
462,
268,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
268,
1067,
29879,
29889,
9916,
3366,
29894,
6739,
29918,
974,
571,
292,
3108,
13,
462,
462,
268,
1723,
13,
13,
4706,
1067,
29879,
29889,
29894,
6739,
29918,
2696,
29889,
5504,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
2106,
2433,
10861,
1495,
13,
13,
4706,
1067,
29879,
29889,
9916,
3366,
29894,
6739,
3108,
3366,
25232,
29878,
3108,
353,
525,
29896,
29900,
29889,
29896,
29889,
29896,
29889,
29896,
29914,
29896,
29953,
29915,
13,
4706,
1067,
29879,
29889,
29894,
6739,
353,
478,
9026,
29889,
3258,
29898,
13,
462,
308,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
308,
1067,
29879,
29889,
9916,
3366,
29894,
6739,
12436,
13,
462,
308,
325,
6739,
974,
571,
292,
333,
29922,
25932,
29889,
29894,
6739,
29918,
2696,
29889,
333,
29892,
13,
462,
308,
10640,
333,
29922,
25932,
29889,
8028,
29889,
333,
29892,
13,
462,
308,
3633,
29922,
25932,
29889,
10149,
29889,
978,
29892,
13,
462,
308,
5354,
333,
29922,
25932,
29889,
10149,
29889,
7247,
333,
13,
462,
308,
1723,
13,
13,
4706,
1067,
29879,
29889,
29876,
29893,
29918,
2696,
353,
8527,
2776,
571,
292,
29889,
3258,
29898,
13,
462,
462,
9651,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
9651,
1067,
29879,
29889,
9916,
3366,
11618,
29918,
974,
571,
292,
12436,
13,
462,
462,
9651,
8976,
331,
356,
29922,
8824,
13,
462,
462,
9651,
1723,
13,
4706,
396,
1174,
519,
8527,
27032,
13,
4706,
1067,
29879,
29889,
29876,
29893,
29918,
2696,
29889,
5504,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
2106,
2433,
10861,
1495,
13,
13,
4706,
396,
26221,
3564,
773,
278,
3564,
27032,
2825,
13,
4706,
1067,
29879,
29889,
11618,
29918,
29896,
353,
8527,
29889,
3258,
29898,
13,
462,
18884,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
18884,
1067,
29879,
29889,
9916,
3366,
11618,
12436,
13,
462,
18884,
3633,
333,
29922,
25932,
29889,
10149,
29889,
978,
29892,
13,
462,
18884,
5354,
333,
29922,
25932,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
18884,
3564,
974,
571,
292,
333,
29922,
25932,
29889,
29876,
29893,
29918,
2696,
29889,
333,
29892,
13,
462,
18884,
10640,
333,
29922,
25932,
29889,
8028,
29889,
333,
29892,
13,
462,
18884,
28646,
2433,
29896,
29900,
29889,
29896,
29889,
29896,
29889,
29896,
742,
13,
462,
18884,
325,
6739,
333,
29922,
25932,
29889,
29894,
6739,
29889,
333,
13,
462,
18884,
1723,
13,
4706,
1067,
29879,
29889,
29876,
29893,
29918,
2696,
29918,
1217,
29918,
27728,
353,
8527,
2776,
571,
292,
29889,
3258,
29898,
13,
462,
462,
1678,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
1678,
1067,
29879,
29889,
9916,
3366,
11618,
29918,
974,
571,
292,
29918,
1217,
29918,
27728,
12436,
13,
462,
462,
1678,
8976,
331,
356,
29922,
8824,
13,
462,
462,
1678,
1723,
13,
4706,
396,
1174,
519,
8527,
27032,
13,
4706,
1067,
29879,
29889,
29876,
29893,
29918,
2696,
29918,
1217,
29918,
27728,
29889,
5504,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
2106,
2433,
10861,
1495,
13,
13,
4706,
396,
26221,
3564,
773,
278,
3564,
27032,
2825,
13,
4706,
1067,
29879,
29889,
11618,
29918,
29906,
353,
8527,
29889,
3258,
29898,
13,
462,
18884,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
18884,
1067,
29879,
29889,
9916,
3366,
11618,
12436,
13,
462,
18884,
3633,
333,
29922,
25932,
29889,
10149,
29889,
978,
29892,
13,
462,
18884,
5354,
333,
29922,
25932,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
18884,
3564,
974,
571,
292,
333,
29922,
25932,
29889,
29876,
29893,
29918,
2696,
29918,
1217,
29918,
27728,
29889,
333,
29892,
13,
462,
18884,
10640,
333,
29922,
25932,
29889,
8028,
29889,
333,
29892,
13,
462,
18884,
28646,
2433,
29896,
29900,
29889,
29896,
29889,
29906,
29889,
29896,
742,
13,
462,
18884,
325,
6739,
333,
29922,
25932,
29889,
29894,
6739,
29889,
333,
13,
462,
18884,
1723,
13,
4706,
396,
1706,
18101,
385,
2777,
297,
393,
3564,
13,
4706,
1067,
29879,
29889,
6925,
29918,
29896,
353,
19181,
29076,
29889,
3258,
29898,
13,
462,
462,
29871,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
29871,
1067,
29879,
29889,
9916,
3366,
18714,
29918,
23523,
12436,
13,
462,
462,
29871,
3633,
333,
29922,
25932,
29889,
10149,
29889,
978,
29892,
13,
462,
462,
29871,
5354,
333,
29922,
25932,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
462,
29871,
2669,
974,
571,
292,
333,
29922,
25932,
29889,
5509,
29918,
974,
571,
292,
29918,
29896,
29889,
333,
29892,
13,
462,
462,
29871,
3564,
4841,
11759,
710,
29898,
25932,
29889,
11618,
29918,
29896,
29889,
333,
4638,
13,
462,
462,
29871,
1723,
13,
4706,
396,
1706,
18101,
385,
2777,
297,
393,
3564,
13,
4706,
1067,
29879,
29889,
6925,
29918,
29906,
353,
19181,
29076,
29889,
3258,
29898,
13,
462,
462,
29871,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
29871,
1067,
29879,
29889,
9916,
3366,
18714,
29918,
23523,
12436,
13,
462,
462,
29871,
3633,
333,
29922,
25932,
29889,
10149,
29889,
978,
29892,
13,
462,
462,
29871,
5354,
333,
29922,
25932,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
462,
29871,
2669,
974,
571,
292,
333,
29922,
25932,
29889,
5509,
29918,
974,
571,
292,
29918,
29896,
29889,
333,
29892,
13,
462,
462,
29871,
3564,
4841,
11759,
710,
29898,
25932,
29889,
11618,
29918,
29896,
29889,
333,
4638,
13,
462,
462,
29871,
1723,
13,
4706,
1067,
29879,
29889,
6925,
29918,
29941,
353,
19181,
29076,
29889,
3258,
29898,
13,
462,
462,
29871,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
462,
29871,
1067,
29879,
29889,
9916,
3366,
18714,
29918,
23523,
12436,
13,
462,
462,
29871,
3633,
333,
29922,
25932,
29889,
10149,
29889,
978,
29892,
13,
462,
462,
29871,
5354,
333,
29922,
25932,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
462,
29871,
2669,
974,
571,
292,
333,
29922,
25932,
29889,
5509,
29918,
974,
571,
292,
29918,
29906,
29889,
333,
29892,
13,
462,
462,
29871,
3564,
4841,
11759,
710,
29898,
25932,
29889,
11618,
29918,
29906,
29889,
333,
4638,
13,
462,
462,
29871,
1723,
13,
4706,
16053,
2153,
353,
390,
5561,
29889,
1761,
29898,
13,
462,
795,
1067,
29879,
29889,
2754,
29918,
4645,
29892,
13,
462,
795,
3633,
29922,
25932,
29889,
10149,
29889,
978,
29892,
13,
462,
795,
5354,
333,
29922,
25932,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
795,
1051,
497,
29922,
5574,
13,
462,
795,
1723,
13,
4706,
565,
338,
8758,
29898,
27537,
2153,
29892,
1051,
1125,
13,
9651,
1067,
29879,
29889,
29894,
6739,
13416,
353,
16053,
2153,
29961,
29900,
29962,
13,
13,
4706,
1067,
29879,
3032,
14941,
786,
353,
518,
13,
462,
4706,
1067,
29879,
29889,
5509,
29918,
974,
571,
292,
29918,
29896,
29892,
13,
462,
4706,
1067,
29879,
29889,
5509,
29918,
974,
571,
292,
29918,
29906,
29892,
13,
462,
4706,
1067,
29879,
29889,
29876,
29893,
29918,
2696,
29892,
13,
462,
4706,
1067,
29879,
29889,
29876,
29893,
29918,
2696,
29918,
1217,
29918,
27728,
29892,
13,
462,
4706,
4514,
13,
4706,
736,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
734,
279,
6767,
2385,
29898,
25932,
1125,
13,
4706,
1018,
29901,
13,
9651,
396,
12498,
278,
3495,
8282,
13,
9651,
16956,
29889,
5504,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
1178,
29922,
25932,
29889,
23525,
29961,
29900,
1822,
333,
29892,
3495,
11338,
543,
1159,
13,
9651,
16956,
29889,
5504,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
1178,
29922,
25932,
29889,
23525,
29961,
29896,
1822,
333,
29892,
3495,
11338,
543,
1159,
13,
9651,
1067,
29879,
29889,
10149,
29889,
8143,
29898,
25932,
29889,
2754,
29918,
4645,
29897,
13,
9651,
4480,
29918,
1454,
29918,
14941,
786,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
6796,
10149,
29889,
14941,
786,
29889,
19207,
20068,
13,
9651,
396,
29907,
14044,
786,
7788,
1304,
13,
9651,
5941,
786,
29918,
13237,
29898,
25932,
29889,
2754,
29918,
4645,
29892,
1067,
29879,
3032,
14941,
786,
29897,
13,
9651,
1067,
29879,
29889,
29894,
6739,
29918,
2696,
29889,
8143,
29898,
25932,
29889,
2754,
29918,
4645,
29897,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
12020,
8960,
703,
22709,
29901,
8960,
2645,
5941,
786,
584,
1273,
29879,
29908,
1273,
321,
29897,
13,
4706,
736,
13,
13,
1678,
822,
731,
3373,
29898,
1311,
1125,
13,
13,
4706,
1583,
29889,
481,
293,
1593,
353,
1583,
29889,
1688,
4032,
29889,
657,
11713,
4032,
580,
13,
4706,
1583,
29889,
2585,
4645,
353,
1583,
29889,
1688,
4032,
29889,
657,
10234,
5350,
580,
13,
4706,
1583,
29889,
8382,
703,
5596,
278,
4660,
310,
478,
9026,
6901,
12876,
1159,
13,
4706,
16053,
2153,
353,
390,
5561,
29889,
1761,
29898,
13,
462,
795,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
795,
3564,
333,
29922,
1311,
29889,
11618,
29918,
29896,
29889,
333,
29892,
13,
462,
795,
1051,
497,
29922,
5574,
13,
462,
795,
1723,
13,
4706,
565,
451,
338,
8758,
29898,
27537,
2153,
29892,
1051,
1125,
13,
9651,
12020,
8960,
703,
3782,
2933,
515,
1051,
16053,
2153,
3450,
1159,
13,
13,
4706,
1583,
29889,
15140,
353,
16053,
2153,
29961,
29900,
29962,
13,
4706,
565,
1583,
29889,
15140,
29889,
3859,
1275,
376,
27795,
1115,
13,
9651,
1583,
29889,
8382,
703,
6565,
2164,
393,
278,
390,
5561,
338,
297,
19509,
4306,
1159,
13,
13,
4706,
1583,
29889,
14941,
786,
353,
5159,
13,
4706,
736,
13,
13,
1678,
822,
734,
279,
6767,
29898,
1311,
1125,
13,
4706,
1018,
29901,
13,
9651,
396,
29907,
14044,
701,
29892,
29504,
278,
2825,
3564,
5957,
886,
13,
9651,
5941,
786,
29918,
13237,
29898,
1311,
29889,
481,
293,
1593,
29892,
1583,
29889,
14941,
786,
29897,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
12020,
8960,
703,
22709,
29901,
8960,
2645,
5941,
786,
584,
1273,
29879,
29908,
1273,
321,
29897,
13,
4706,
736,
13,
13,
1678,
822,
12725,
29918,
6925,
29918,
16519,
358,
29898,
1311,
1125,
13,
4706,
9995,
7211,
1078,
11400,
18209,
373,
1422,
18982,
15945,
29908,
13,
13,
4706,
325,
1516,
353,
19181,
29076,
29889,
1761,
29898,
13,
462,
462,
29871,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
462,
29871,
3633,
29922,
1311,
29889,
10149,
29889,
978,
29892,
13,
462,
462,
29871,
5354,
333,
29922,
1311,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
462,
29871,
3564,
333,
29922,
1311,
29889,
11618,
29918,
29896,
29889,
333,
29892,
13,
462,
462,
29871,
1051,
497,
29922,
5574,
13,
462,
462,
29871,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
13,
462,
308,
338,
8758,
29898,
29894,
1516,
29892,
1051,
511,
13,
462,
308,
5852,
29892,
13,
462,
308,
376,
1293,
11400,
29879,
4091,
736,
263,
2854,
2933,
29908,
13,
462,
308,
1723,
13,
4706,
3495,
29918,
29896,
353,
325,
1516,
29961,
29900,
1822,
3069,
333,
13,
4706,
1583,
29889,
8382,
703,
8514,
363,
3564,
29871,
29896,
29901,
1273,
29879,
29908,
1273,
325,
1516,
29961,
29900,
1822,
3069,
333,
29897,
13,
13,
4706,
325,
1516,
353,
19181,
29076,
29889,
1761,
29898,
13,
462,
462,
29871,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
462,
29871,
3633,
29922,
1311,
29889,
10149,
29889,
978,
29892,
13,
462,
462,
29871,
5354,
333,
29922,
1311,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
462,
29871,
3564,
333,
29922,
1311,
29889,
11618,
29918,
29906,
29889,
333,
29892,
13,
462,
462,
29871,
1051,
497,
29922,
5574,
13,
462,
462,
29871,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
13,
462,
308,
338,
8758,
29898,
29894,
1516,
29892,
1051,
511,
13,
462,
308,
5852,
29892,
13,
462,
308,
376,
1293,
11400,
29879,
4091,
736,
263,
2854,
2933,
29908,
13,
462,
308,
1723,
13,
4706,
3495,
29918,
29906,
353,
325,
1516,
29961,
29900,
1822,
3069,
333,
13,
4706,
1583,
29889,
8382,
703,
8514,
363,
3564,
29871,
29906,
29901,
1273,
29879,
29908,
1273,
325,
1516,
29961,
29900,
1822,
3069,
333,
29897,
13,
13,
4706,
1583,
29889,
9294,
3664,
9843,
29898,
13,
18884,
3495,
29918,
29896,
29892,
13,
18884,
3495,
29918,
29906,
29892,
13,
18884,
376,
29933,
720,
278,
6901,
14884,
881,
367,
21168,
373,
2923,
18982,
376,
13,
18884,
1723,
13,
4706,
736,
13,
13,
1678,
732,
5552,
29898,
11338,
29922,
3366,
328,
16858,
613,
376,
1639,
29894,
6468,
20068,
13,
1678,
822,
1243,
29918,
29900,
29896,
29918,
12007,
29918,
3396,
841,
749,
29918,
2541,
29918,
29894,
6739,
29918,
29876,
29893,
29898,
1311,
1125,
13,
4706,
9995,
4321,
9025,
4241,
841,
749,
21864,
373,
16956,
29879,
607,
505,
478,
9026,
3161,
13,
4706,
9995,
13,
13,
4706,
396,
15758,
403,
278,
1494,
13,
4706,
396,
29871,
29896,
29889,
6204,
263,
478,
9026,
411,
274,
333,
29878,
448,
29871,
29896,
29900,
29889,
29896,
29889,
29896,
29889,
29896,
29914,
29896,
29953,
13,
4706,
396,
29871,
29906,
29889,
3462,
3564,
29896,
29898,
29896,
29900,
29889,
29896,
29889,
29896,
29889,
29896,
29914,
29906,
29946,
29897,
322,
3564,
29906,
29898,
29896,
29900,
29889,
29896,
29889,
29906,
29889,
29896,
29914,
29906,
29946,
29897,
304,
445,
478,
9026,
29889,
13,
4706,
396,
29871,
29941,
29889,
10034,
2376,
22419,
29896,
322,
22419,
29906,
297,
3564,
29896,
322,
22419,
29941,
322,
22419,
29946,
297,
3564,
29906,
29889,
8561,
13,
4706,
396,
1678,
1854,
22419,
29896,
322,
22419,
29941,
526,
21168,
373,
697,
3495,
297,
278,
9867,
1550,
13,
4706,
396,
1678,
22419,
29906,
322,
22419,
29946,
526,
21168,
373,
278,
916,
3495,
297,
278,
9867,
29889,
910,
13,
4706,
396,
1678,
508,
367,
2309,
773,
3495,
29915,
29879,
8282,
669,
2669,
5957,
886,
411,
3495,
8282,
13,
4706,
396,
2443,
567,
29901,
13,
4706,
396,
29871,
29896,
29889,
20701,
4241,
841,
749,
373,
697,
310,
3495,
373,
607,
478,
9026,
29963,
29934,
338,
2198,
13,
4706,
396,
15758,
800,
29901,
13,
4706,
396,
29871,
29896,
29889,
21397,
3730,
5503,
278,
3495,
964,
25413,
4464,
29889,
13,
4706,
396,
29871,
29906,
29889,
11400,
29879,
2198,
373,
278,
2038,
3495,
881,
8472,
9725,
403,
304,
278,
13,
4706,
396,
1678,
916,
3495,
2198,
297,
278,
9867,
13,
13,
4706,
16956,
29889,
5504,
29898,
1311,
29889,
481,
293,
1593,
29892,
1178,
29922,
1311,
29889,
23525,
29961,
29900,
1822,
333,
29892,
3495,
11338,
543,
3069,
4039,
29896,
29892,
3069,
4039,
29906,
1159,
13,
4706,
16956,
29889,
5504,
29898,
1311,
29889,
481,
293,
1593,
29892,
1178,
29922,
1311,
29889,
23525,
29961,
29896,
1822,
333,
29892,
3495,
11338,
543,
3069,
4039,
29896,
29892,
3069,
4039,
29906,
1159,
13,
13,
4706,
1583,
29889,
15480,
29918,
6925,
29918,
16519,
358,
580,
13,
4706,
1583,
29889,
8382,
703,
16329,
278,
3495,
373,
607,
278,
478,
9026,
6901,
12876,
338,
2734,
1159,
13,
4706,
1018,
29901,
13,
9651,
16956,
29889,
12007,
6330,
841,
749,
29898,
1311,
29889,
481,
293,
1593,
29892,
1178,
29922,
1311,
29889,
29894,
6739,
13416,
29889,
3069,
333,
29897,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
1583,
29889,
14057,
703,
17776,
304,
9025,
25413,
4464,
373,
3495,
29901,
1273,
29879,
29908,
1273,
321,
29897,
13,
13,
4706,
1583,
29889,
8382,
29898,
13,
9651,
376,
5596,
565,
599,
8871,
23329,
304,
278,
3633,
526,
701,
1449,
29973,
1159,
13,
4706,
16053,
2153,
353,
390,
5561,
29889,
1761,
29898,
13,
462,
795,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
795,
3633,
29922,
1311,
29889,
10149,
29889,
978,
29892,
13,
462,
795,
5354,
333,
29922,
1311,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
795,
1051,
497,
29922,
5574,
13,
462,
795,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
13,
462,
308,
338,
8758,
29898,
27537,
2153,
29892,
1051,
511,
13,
462,
308,
5852,
29892,
13,
462,
308,
376,
1293,
16053,
2153,
4091,
736,
263,
2854,
478,
9026,
29963,
29934,
363,
3633,
29908,
13,
462,
308,
1723,
13,
13,
4706,
12876,
353,
16053,
2153,
29961,
29900,
29962,
13,
13,
4706,
1018,
29901,
13,
13,
9651,
11815,
353,
1583,
29889,
9916,
3366,
15619,
3108,
13,
9651,
1583,
29889,
8382,
703,
10851,
7865,
1273,
29881,
584,
376,
1273,
11815,
29897,
13,
9651,
1550,
5852,
29901,
13,
18884,
1051,
29918,
15140,
29918,
5327,
353,
390,
5561,
29889,
1761,
29898,
13,
462,
1678,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
1678,
1178,
353,
12876,
29889,
333,
29892,
13,
462,
1678,
2106,
353,
376,
27795,
29908,
13,
18884,
1723,
13,
13,
18884,
565,
1051,
29918,
15140,
29918,
5327,
338,
451,
6213,
29901,
13,
462,
1678,
2867,
13,
18884,
25342,
11815,
1275,
29871,
29900,
29901,
13,
462,
1678,
12020,
8960,
703,
23971,
2106,
881,
367,
2734,
1156,
20332,
1159,
13,
13,
18884,
931,
29889,
17059,
29898,
1311,
29889,
9916,
3366,
17059,
20068,
13,
18884,
11815,
353,
11815,
448,
29871,
29896,
13,
18884,
1583,
29889,
8382,
703,
15716,
292,
363,
1273,
29881,
6923,
448,
1273,
29881,
14335,
2175,
29908,
1273,
313,
1311,
29889,
9916,
3366,
17059,
12436,
15619,
876,
13,
13,
9651,
1583,
29889,
8382,
703,
6565,
2164,
393,
278,
390,
5561,
338,
297,
19509,
4306,
1159,
13,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
1583,
29889,
14057,
703,
17776,
304,
1284,
278,
390,
5561,
297,
19509,
2106,
1273,
29879,
376,
1273,
321,
29897,
13,
13,
4706,
325,
1516,
353,
19181,
29076,
29889,
1761,
29898,
13,
462,
462,
29871,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
462,
29871,
3633,
29922,
1311,
29889,
10149,
29889,
978,
29892,
13,
462,
462,
29871,
5354,
333,
29922,
1311,
29889,
10149,
29889,
7247,
333,
29892,
13,
462,
462,
29871,
1051,
497,
29922,
5574,
13,
462,
462,
29871,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
13,
462,
1678,
338,
8758,
29898,
29894,
1516,
29892,
1051,
511,
13,
462,
1678,
5852,
29892,
13,
462,
1678,
376,
9219,
2933,
881,
736,
8871,
2734,
363,
3633,
29908,
13,
462,
1678,
1723,
13,
4706,
363,
22419,
297,
325,
1516,
29901,
13,
9651,
1583,
29889,
9294,
9843,
29898,
13,
462,
632,
22419,
29889,
3859,
29892,
13,
462,
632,
376,
27795,
613,
13,
462,
632,
376,
29963,
29885,
2106,
881,
367,
2734,
1156,
20332,
29908,
13,
462,
632,
1723,
13,
4706,
736,
13,
13,
1678,
732,
5552,
29898,
11338,
29922,
3366,
328,
16858,
613,
376,
1639,
29894,
6468,
20068,
13,
1678,
822,
1243,
29918,
29900,
29906,
29918,
20713,
29918,
3396,
841,
749,
29898,
1311,
1125,
13,
4706,
9995,
4321,
12611,
4241,
841,
749,
21864,
373,
278,
2038,
16956,
29879,
718,
341,
4481,
403,
11400,
29879,
7437,
13,
4706,
9995,
13,
13,
4706,
396,
2443,
567,
13,
4706,
396,
29871,
29896,
29889,
1815,
2242,
4241,
841,
749,
21864,
373,
278,
3495,
29889,
13,
4706,
396,
29871,
29906,
29889,
341,
4481,
403,
278,
11400,
29879,
1250,
11480,
278,
3495,
373,
607,
4241,
841,
749,
4464,
338,
13,
4706,
396,
1678,
12611,
839,
29889,
13,
4706,
396,
15758,
403,
278,
1494,
13,
4706,
396,
29871,
29896,
29889,
21397,
3730,
12611,
278,
4241,
841,
749,
4464,
373,
278,
3495,
29889,
13,
4706,
396,
29871,
29906,
29889,
341,
4481,
403,
278,
11400,
29879,
1250,
8472,
11480,
278,
3495,
29889,
13,
4706,
396,
29871,
29941,
29889,
5399,
393,
278,
3564,
4511,
2068,
4864,
411,
278,
9725,
630,
11400,
29879,
29889,
13,
13,
4706,
1018,
29901,
13,
9651,
11815,
353,
1583,
29889,
9916,
3366,
15619,
3108,
13,
9651,
1550,
5852,
29901,
13,
18884,
1051,
29918,
3069,
29918,
5327,
353,
16956,
29889,
1761,
29898,
13,
462,
1678,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
1678,
1178,
29922,
1311,
29889,
29894,
6739,
13416,
29889,
3069,
333,
29892,
13,
462,
1678,
620,
473,
29883,
342,
403,
543,
6330,
841,
749,
1159,
13,
13,
18884,
565,
1051,
29918,
3069,
29918,
5327,
338,
451,
6213,
29901,
13,
462,
1678,
2867,
13,
18884,
25342,
11815,
1275,
29871,
29900,
29901,
13,
462,
1678,
12020,
8960,
703,
17776,
304,
1051,
278,
16956,
297,
4241,
841,
749,
4306,
1159,
13,
13,
18884,
931,
29889,
17059,
29898,
1311,
29889,
9916,
3366,
17059,
20068,
13,
18884,
11815,
353,
11815,
448,
29871,
29896,
13,
13,
9651,
1583,
29889,
8382,
703,
6565,
2164,
393,
278,
16956,
338,
297,
4241,
841,
749,
4306,
1159,
13,
13,
4706,
5174,
29901,
13,
9651,
1583,
29889,
14057,
703,
17776,
304,
1284,
278,
16956,
297,
25413,
2106,
1159,
13,
13,
4706,
1583,
29889,
8382,
703,
19420,
3495,
16134,
663,
373,
607,
278,
478,
9026,
29963,
29934,
338,
2734,
1159,
13,
4706,
1018,
29901,
13,
9651,
16956,
29889,
20713,
6330,
841,
749,
29898,
1311,
29889,
481,
293,
1593,
29892,
1178,
29922,
1311,
29889,
29894,
6739,
13416,
29889,
3069,
333,
29897,
13,
13,
9651,
11815,
353,
1583,
29889,
9916,
3366,
15619,
3108,
13,
9651,
1550,
5852,
29901,
13,
18884,
1051,
29918,
3069,
29918,
5327,
353,
16956,
29889,
1761,
29898,
13,
462,
1678,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
1678,
1178,
29922,
1311,
29889,
29894,
6739,
13416,
29889,
3069,
333,
29892,
13,
462,
1678,
2106,
543,
3373,
1159,
13,
13,
18884,
565,
1051,
29918,
3069,
29918,
5327,
338,
451,
6213,
29901,
13,
462,
1678,
2867,
13,
18884,
25342,
11815,
1275,
29871,
29900,
29901,
13,
462,
1678,
12020,
8960,
703,
17776,
304,
1051,
278,
16956,
297,
5020,
4306,
1156,
1815,
2242,
292,
4241,
841,
749,
21864,
1159,
13,
13,
18884,
931,
29889,
17059,
29898,
1311,
29889,
9916,
3366,
17059,
20068,
13,
18884,
11815,
353,
11815,
448,
29871,
29896,
13,
13,
9651,
1583,
29889,
8382,
703,
6565,
2164,
393,
278,
16956,
338,
297,
5020,
4306,
1156,
1815,
2242,
292,
4241,
841,
749,
21864,
1159,
13,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
1583,
29889,
14057,
703,
17776,
304,
12611,
25413,
4464,
373,
3495,
29901,
1273,
29879,
29908,
1273,
321,
29897,
13,
13,
4706,
1583,
29889,
8382,
29898,
13,
9651,
376,
29924,
4481,
1218,
278,
8871,
1250,
304,
278,
3495,
29901,
1273,
29879,
29908,
1273,
13,
462,
462,
462,
4706,
1583,
29889,
29894,
6739,
13416,
29889,
3069,
333,
29897,
13,
4706,
1018,
29901,
13,
9651,
9920,
353,
9725,
403,
3924,
29963,
29885,
29889,
26983,
403,
3924,
29963,
29885,
23651,
580,
13,
9651,
9920,
29889,
3069,
333,
353,
1583,
29889,
29894,
6739,
13416,
29889,
3069,
333,
13,
9651,
9920,
29889,
18714,
23523,
333,
353,
1583,
29889,
29894,
6739,
13416,
29889,
333,
13,
9651,
1583,
29889,
481,
293,
1593,
29889,
26983,
403,
3924,
29963,
29885,
29898,
9006,
29897,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
1583,
29889,
14057,
703,
17776,
304,
9725,
403,
478,
9026,
29963,
29934,
1250,
29901,
1273,
29879,
29908,
1273,
321,
29897,
13,
13,
4706,
1583,
29889,
8382,
703,
5596,
278,
4660,
310,
12876,
1156,
20332,
1159,
13,
4706,
16053,
2153,
353,
390,
5561,
29889,
1761,
29898,
13,
462,
795,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
795,
1178,
29922,
1311,
29889,
29894,
6739,
13416,
29889,
333,
29892,
13,
462,
795,
1051,
497,
29922,
5574,
13,
462,
795,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
13,
462,
308,
338,
8758,
29898,
27537,
2153,
29892,
1051,
511,
13,
462,
308,
5852,
29892,
13,
462,
308,
376,
1293,
16053,
2153,
4091,
736,
278,
2854,
2933,
29908,
13,
462,
308,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
13,
462,
308,
16053,
2153,
29961,
29900,
1822,
3859,
29892,
13,
462,
308,
376,
27795,
613,
13,
462,
308,
376,
23971,
2106,
881,
367,
2734,
29908,
13,
462,
308,
1723,
13,
4706,
396,
29871,
14402,
29901,
5399,
363,
278,
3564,
4511,
2068,
13,
4706,
736,
13,
13,
1678,
732,
5552,
29898,
11338,
29922,
3366,
328,
16858,
613,
376,
1639,
29894,
6468,
20068,
13,
1678,
822,
1243,
29918,
29900,
29941,
29918,
276,
6915,
29918,
3069,
29898,
1311,
1125,
13,
4706,
9995,
4321,
337,
6915,
16956,
607,
756,
478,
9026,
3161,
13,
4706,
9995,
13,
13,
4706,
396,
2443,
567,
29901,
13,
4706,
396,
29871,
29896,
29889,
1123,
6915,
697,
310,
278,
3495,
373,
607,
478,
9026,
19181,
390,
5561,
338,
2198,
29889,
13,
4706,
396,
15758,
403,
278,
1494,
13,
4706,
396,
29871,
29896,
29889,
16956,
881,
8472,
337,
6915,
29889,
13,
4706,
396,
29871,
29906,
29889,
8527,
4511,
2068,
304,
599,
278,
11400,
29879,
373,
278,
3495,
881,
451,
367,
13,
4706,
396,
1678,
2779,
287,
2861,
304,
8265,
3559,
29889,
13,
13,
4706,
1018,
29901,
13,
9651,
11815,
353,
1583,
29889,
9916,
3366,
15619,
3108,
13,
9651,
1550,
5852,
29901,
13,
18884,
1051,
29918,
3069,
29918,
5327,
353,
16956,
29889,
1761,
29898,
13,
462,
1678,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
1678,
1178,
29922,
1311,
29889,
29894,
6739,
13416,
29889,
3069,
333,
29892,
13,
462,
1678,
620,
473,
29883,
342,
403,
543,
10861,
1159,
13,
13,
18884,
565,
1051,
29918,
3069,
29918,
5327,
338,
451,
6213,
29901,
13,
462,
1678,
2867,
13,
18884,
25342,
11815,
1275,
29871,
29900,
29901,
13,
462,
1678,
12020,
8960,
703,
17776,
304,
1051,
278,
16956,
297,
5020,
4306,
1159,
13,
13,
18884,
931,
29889,
17059,
29898,
1311,
29889,
9916,
3366,
17059,
20068,
13,
18884,
11815,
353,
11815,
448,
29871,
29896,
13,
13,
9651,
1583,
29889,
8382,
703,
6565,
2164,
393,
278,
16956,
338,
297,
5020,
4306,
1159,
13,
13,
4706,
5174,
29901,
13,
9651,
1583,
29889,
14057,
703,
17776,
304,
1284,
278,
16956,
297,
5020,
4306,
1159,
13,
13,
4706,
1583,
29889,
8382,
703,
1123,
6915,
292,
278,
3495,
988,
478,
9026,
478,
29934,
338,
2734,
1159,
13,
4706,
1018,
29901,
13,
9651,
16956,
29889,
276,
6915,
29898,
1311,
29889,
481,
293,
1593,
29892,
1178,
29922,
1311,
29889,
29894,
6739,
13416,
29889,
3069,
333,
29897,
13,
4706,
5174,
8960,
408,
321,
29901,
13,
9651,
1583,
29889,
14057,
703,
17776,
304,
337,
6915,
304,
3495,
29901,
1273,
29879,
29908,
1273,
321,
29897,
13,
13,
4706,
1583,
29889,
8382,
703,
5596,
278,
4660,
310,
12876,
1156,
20332,
1159,
13,
4706,
16053,
2153,
353,
390,
5561,
29889,
1761,
29898,
13,
462,
795,
1583,
29889,
481,
293,
1593,
29892,
13,
462,
795,
1178,
29922,
1311,
29889,
29894,
6739,
13416,
29889,
333,
29892,
13,
462,
795,
1051,
497,
29922,
5574,
13,
462,
795,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
13,
462,
308,
338,
8758,
29898,
27537,
2153,
29892,
1051,
511,
13,
462,
308,
5852,
29892,
13,
462,
308,
376,
1293,
16053,
2153,
4091,
736,
278,
2854,
2933,
29908,
13,
462,
308,
1723,
13,
4706,
1583,
29889,
9294,
9843,
29898,
13,
462,
308,
16053,
2153,
29961,
29900,
1822,
3859,
29892,
13,
462,
308,
376,
27795,
613,
13,
462,
308,
376,
23971,
2106,
881,
367,
2734,
29908,
13,
462,
308,
1723,
13,
4706,
396,
29871,
14402,
29901,
5399,
363,
278,
3564,
4511,
2068,
13,
4706,
736,
13,
2
] |
trac/Scripts/pygmentize-script.py | thinkbase/PortableTrac | 2 | 180713 | #!"E:\PortableTrac\Portable Python 2.7.3.1\App\python.exe"
# EASY-INSTALL-ENTRY-SCRIPT: 'Pygments==1.5','console_scripts','pygmentize'
__requires__ = 'Pygments==1.5'
import sys
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('Pygments==1.5', 'console_scripts', 'pygmentize')()
)
| [
1,
396,
3850,
29923,
3583,
2290,
519,
29911,
945,
29905,
2290,
519,
5132,
29871,
29906,
29889,
29955,
29889,
29941,
29889,
29896,
29905,
2052,
29905,
4691,
29889,
8097,
19451,
13,
29937,
382,
3289,
29979,
29899,
25580,
9818,
29899,
3919,
13207,
29899,
7187,
24290,
29901,
525,
29925,
4790,
1860,
1360,
29896,
29889,
29945,
3788,
11058,
29918,
16713,
3788,
2272,
19422,
675,
29915,
30004,
13,
1649,
276,
339,
2658,
1649,
353,
525,
29925,
4790,
1860,
1360,
29896,
29889,
29945,
29915,
30004,
13,
5215,
10876,
30004,
13,
3166,
282,
9415,
29918,
13237,
1053,
2254,
29918,
8269,
29918,
3149,
30004,
13,
30004,
13,
9675,
29889,
13322,
29898,
30004,
13,
259,
2254,
29918,
8269,
29918,
3149,
877,
29925,
4790,
1860,
1360,
29896,
29889,
29945,
742,
525,
11058,
29918,
16713,
742,
525,
2272,
19422,
675,
1495,
26471,
13,
8443,
13,
2
] |
rest_framework_sudo/expiration.py | Nekmo/djangorestframework-sudo | 1 | 95412 | <gh_stars>1-10
import datetime
from functools import wraps
from rest_framework.exceptions import PermissionDenied
from rest_framework_sudo import settings
from django.contrib.auth.models import AbstractUser
from django.utils import timezone
from rest_framework_sudo.utils import get_request_argument
def get_user_remaning_time(user: AbstractUser):
expired_time = datetime.timedelta(seconds=0)
if not user.last_login:
return expired_time
now = timezone.now()
expiration_time = user.last_login - now + settings.REST_FRAMEWORK_SUDO_EXPIRATION
if expiration_time.total_seconds() < 0:
return expired_time
return expiration_time
def expire_now(user: AbstractUser) -> None:
if not get_user_remaning_time(user):
return
user.last_login = timezone.now() - settings.REST_FRAMEWORK_SUDO_EXPIRATION - datetime.timedelta(seconds=1)
user.save()
def get_expires_at(user: AbstractUser):
return timezone.now() + get_user_remaning_time(user)
def validate_sudo(request):
if not get_user_remaning_time(request.user):
raise PermissionDenied('You need to authenticate again to perform this action.')
def sudo_required(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
request = get_request_argument(args, kwargs)
if request is None:
raise AttributeError('request is not available')
validate_sudo(request)
return fn(*args, **kwargs)
return wrapper
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
12865,
13,
3166,
2090,
312,
8789,
1053,
11463,
567,
13,
13,
3166,
1791,
29918,
4468,
29889,
11739,
29879,
1053,
20894,
2333,
29315,
1000,
13,
13,
3166,
1791,
29918,
4468,
29918,
15360,
1053,
6055,
13,
3166,
9557,
29889,
21570,
29889,
5150,
29889,
9794,
1053,
25513,
2659,
13,
3166,
9557,
29889,
13239,
1053,
29431,
13,
13,
3166,
1791,
29918,
4468,
29918,
15360,
29889,
13239,
1053,
679,
29918,
3827,
29918,
23516,
13,
13,
13,
1753,
679,
29918,
1792,
29918,
276,
1171,
292,
29918,
2230,
29898,
1792,
29901,
25513,
2659,
1125,
13,
1678,
1518,
2859,
29918,
2230,
353,
12865,
29889,
9346,
287,
2554,
29898,
23128,
29922,
29900,
29897,
13,
1678,
565,
451,
1404,
29889,
4230,
29918,
7507,
29901,
13,
4706,
736,
1518,
2859,
29918,
2230,
13,
1678,
1286,
353,
29431,
29889,
3707,
580,
13,
1678,
1518,
12232,
29918,
2230,
353,
1404,
29889,
4230,
29918,
7507,
448,
1286,
718,
6055,
29889,
1525,
1254,
29918,
29943,
4717,
2303,
11686,
29968,
29918,
14605,
3970,
29918,
5746,
2227,
29934,
8098,
13,
1678,
565,
1518,
12232,
29918,
2230,
29889,
7827,
29918,
23128,
580,
529,
29871,
29900,
29901,
13,
4706,
736,
1518,
2859,
29918,
2230,
13,
1678,
736,
1518,
12232,
29918,
2230,
13,
13,
13,
1753,
1518,
533,
29918,
3707,
29898,
1792,
29901,
25513,
2659,
29897,
1599,
6213,
29901,
13,
1678,
565,
451,
679,
29918,
1792,
29918,
276,
1171,
292,
29918,
2230,
29898,
1792,
1125,
13,
4706,
736,
13,
1678,
1404,
29889,
4230,
29918,
7507,
353,
29431,
29889,
3707,
580,
448,
6055,
29889,
1525,
1254,
29918,
29943,
4717,
2303,
11686,
29968,
29918,
14605,
3970,
29918,
5746,
2227,
29934,
8098,
448,
12865,
29889,
9346,
287,
2554,
29898,
23128,
29922,
29896,
29897,
13,
1678,
1404,
29889,
7620,
580,
13,
13,
13,
1753,
679,
29918,
4548,
2658,
29918,
271,
29898,
1792,
29901,
25513,
2659,
1125,
13,
1678,
736,
29431,
29889,
3707,
580,
718,
679,
29918,
1792,
29918,
276,
1171,
292,
29918,
2230,
29898,
1792,
29897,
13,
13,
13,
1753,
12725,
29918,
15360,
29898,
3827,
1125,
13,
1678,
565,
451,
679,
29918,
1792,
29918,
276,
1171,
292,
29918,
2230,
29898,
3827,
29889,
1792,
1125,
13,
4706,
12020,
20894,
2333,
29315,
1000,
877,
3492,
817,
304,
15585,
403,
1449,
304,
2189,
445,
3158,
29889,
1495,
13,
13,
13,
1753,
9196,
29918,
12403,
29898,
9144,
1125,
13,
1678,
732,
29893,
336,
567,
29898,
9144,
29897,
13,
1678,
822,
14476,
10456,
5085,
29892,
3579,
19290,
1125,
13,
4706,
2009,
353,
679,
29918,
3827,
29918,
23516,
29898,
5085,
29892,
9049,
5085,
29897,
13,
4706,
565,
2009,
338,
6213,
29901,
13,
9651,
12020,
23833,
2392,
877,
3827,
338,
451,
3625,
1495,
13,
4706,
12725,
29918,
15360,
29898,
3827,
29897,
13,
4706,
736,
7876,
10456,
5085,
29892,
3579,
19290,
29897,
13,
1678,
736,
14476,
13,
2
] |
src/schemas/serlializers/bright.py | rena2damas/healthcheck-service | 0 | 116669 | from marshmallow import Schema, fields
class HealthCheckSchema(Schema):
name = fields.String()
status = fields.String(attribute="status.name")
node = fields.String()
seconds_ago = fields.Integer()
timestamp = fields.Integer()
info = fields.String()
| [
1,
515,
1766,
845,
29885,
9536,
1053,
1102,
2603,
29892,
4235,
13,
13,
13,
1990,
15202,
5596,
12763,
29898,
12763,
1125,
13,
1678,
1024,
353,
4235,
29889,
1231,
580,
13,
1678,
4660,
353,
4235,
29889,
1231,
29898,
12715,
543,
4882,
29889,
978,
1159,
13,
1678,
2943,
353,
4235,
29889,
1231,
580,
13,
1678,
6923,
29918,
4425,
353,
4235,
29889,
7798,
580,
13,
1678,
14334,
353,
4235,
29889,
7798,
580,
13,
1678,
5235,
353,
4235,
29889,
1231,
580,
13,
2
] |
migration/management/commands/migratedata.py | dixonary/uwcs-zarya | 7 | 29797 | from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
from django.template.defaultfilters import slugify, linebreaks, date, truncatechars
from wagtail.core.models import Page
from wagtail.core.rich_text import RichText
from migration.models import *
from accounts.models import CompsocUser, ShellAccount, DatabaseAccount
from blog.models import BlogPage
from events.models import EventSignup, EventPage, EventType
import time
COMMS_DICT = {
'NL': 'Newsletter',
'M': 'Meeting Minutes',
'N': 'News Item'
}
def migrate_compsoc_memberinfo():
"""
Amalgamates the old user detail objects into the new CompsocUser and other models
"""
websites = WebsiteDetails.objects.using('old_data').all()
nicks = NicknameDetails.objects.using('old_data').all()
shell_accounts = OldShellAccount.objects.using('old_data').all()
db_accounts = OldDatabaseAccount.objects.using('old_data').all()
userinfo = {}
# Handle shell accounts
for account in shell_accounts:
user = get_user_model().objects.filter(id=account.user_id).first()
new_account = ShellAccount(name=account.name, user=user, status=account.status)
new_account.save()
# Handle DB accounts
for account in db_accounts:
user = get_user_model().objects.filter(id=account.user_id).first()
new_account = DatabaseAccount(name=account.name, user=user, status=account.status)
new_account.save()
# Handle transfer of Nickname info to CompsocUser model
for nick in nicks:
user_id = nick.user_id
userinfo[user_id] = {
'nickname': nick.nickname,
'website_title': '',
'website_url': ''
}
# Handle transfer of Website info to CompsocUser model
for site in websites:
user_id = site.user_id
if user_id in userinfo:
userinfo[user_id]['website_title'] = site.websiteTitle
userinfo[user_id]['website_url'] = site.websiteUrl
else:
userinfo[user_id] = {
'nickname': '',
'website_title': site.websiteTitle,
'website_url': site.websiteUrl
}
# Save new CompsocUser info
for uid, details in userinfo.items():
user = get_user_model().objects.filter(id=uid).first()
new_userinfo = CompsocUser(nickname=details['nickname'], website_title=details['website_title'],
website_url=details['website_url'], user=user)
print('Restoring {user}'.format(user=new_userinfo))
new_userinfo.save()
def migrate_old_posts():
"""
Converts all old posts from a simple page format to one Wagtail accepts
"""
# id=4 is the specific page ID for the news index page
index = Page.objects.get(id=4).specific
old_posts = Communication.objects.using('old_data').all().order_by('date')
user = get_user_model().objects.get(id=1)
for post in old_posts:
if post.title:
title = post.title
else:
title = 'Archived item from {date}'.format(date=date(post.date, 'D jS F Y'))
slug = slugify('{title} - {rand}'.format(title=title, rand=int(round(time.time() * 1000))))
if len(post.text) > 512:
intro = post.text[:512] + '...'
else:
intro = post.text
page = BlogPage(
search_description='',
seo_title=title,
show_in_menus=False,
slug=slug,
title=title,
date=post.date,
first_published_at=post.date,
intro=linebreaks(intro),
)
page.body.stream_data = [
('paragraph', RichText('<p>{body}</p>'.format(body=linebreaks(post.text))))
]
page.tags.add(COMMS_DICT[post.type])
print('Restoring article from {date}'.format(date=post.date))
index.add_child(instance=page)
revision = page.save_revision(
user=user,
submitted_for_moderation=False
)
revision.publish()
page.save()
def migrate_events():
event_index = Page.objects.get(id=6).specific
user = get_user_model().objects.get(id=1)
old_events = OldEvent.objects.using('old_data').all()
# Migrate events
for old_event in old_events:
old_event_type = old_event.type
try:
# We don't actually care about this - its a test to migrate the event across
event_type = EventType.objects.get(name=old_event_type.name, target=old_event_type.target)
except EventType.DoesNotExist:
event_type = EventType(name=old_event_type.name, target=old_event_type.target)
event_type.save()
title = '{type} on {date}'.format(type=old_event_type.name, date=date(old_event.start, 'D jS F Y'))
slug = slugify('{title} - {rand}'.format(title=title, rand=int(round(time.time() * 1000))))
if old_event.shortDescription:
description = old_event.shortDescription
else:
if old_event_type.info:
description = old_event_type.info
else:
description = old_event_type.name
new_event = EventPage(
title=title.strip(),
slug=slug,
description=description.strip(),
start=old_event.start,
finish=old_event.finish,
cancelled=old_event.cancelled,
category=event_type,
location=old_event.location.name
)
new_event.body.stream_data = [
('paragraph', RichText('<p>{body}</p>'.format(body=linebreaks(old_event.longDescription))))
]
print('Restoring event {type} from {date}'.format(type=old_event.type.name, date=old_event.start))
event_index.add_child(instance=new_event)
revision = new_event.save_revision(
user=user,
submitted_for_moderation=False
)
revision.publish()
new_event.save()
# Deal with signups
old_signups = Signup.objects.using('old_data').filter(event_id=old_event.id)
for old_signup in old_signups:
print('Restoring signup for {type} from {date}'.format(type=old_event.type.name, date=old_event.start))
new_signup = EventSignup(comment=truncatechars(old_signup.comment, 1024),
member=get_user_model().objects.get(id=old_signup.user_id),
event_id=new_event.id, signup_created=old_signup.time)
new_signup.save()
class Command(BaseCommand):
def handle(self, *args, **options):
migrate_compsoc_memberinfo()
migrate_old_posts()
migrate_events()
| [
1,
515,
9557,
29889,
3221,
29889,
21895,
29889,
3188,
1053,
7399,
6255,
13,
3166,
9557,
29889,
21570,
29889,
5150,
1053,
679,
29918,
1792,
29918,
4299,
13,
3166,
9557,
29889,
6886,
29889,
4381,
26705,
1053,
2243,
688,
1598,
29892,
1196,
8690,
29879,
29892,
2635,
29892,
21022,
403,
305,
1503,
13,
13,
3166,
281,
351,
18237,
29889,
3221,
29889,
9794,
1053,
9305,
13,
3166,
281,
351,
18237,
29889,
3221,
29889,
4018,
29918,
726,
1053,
4385,
1626,
13,
13,
3166,
20332,
29889,
9794,
1053,
334,
13,
3166,
15303,
29889,
9794,
1053,
422,
567,
542,
2659,
29892,
1383,
514,
10601,
29892,
5470,
10601,
13,
3166,
12618,
29889,
9794,
1053,
350,
1188,
5074,
13,
3166,
4959,
29889,
9794,
1053,
6864,
10140,
786,
29892,
6864,
5074,
29892,
6864,
1542,
13,
13,
5215,
931,
13,
13,
19795,
4345,
29918,
4571,
1783,
353,
426,
13,
1678,
525,
25103,
2396,
525,
29328,
15670,
742,
13,
1678,
525,
29924,
2396,
525,
6816,
15133,
3080,
2667,
742,
13,
1678,
525,
29940,
2396,
525,
29328,
10976,
29915,
13,
29913,
13,
13,
13,
1753,
9725,
403,
29918,
510,
567,
542,
29918,
14242,
3888,
7295,
13,
1678,
9995,
13,
1678,
1913,
9564,
314,
1078,
278,
2030,
1404,
9493,
3618,
964,
278,
716,
422,
567,
542,
2659,
322,
916,
4733,
13,
1678,
9995,
13,
1678,
28007,
353,
13253,
10602,
29889,
12650,
29889,
4746,
877,
1025,
29918,
1272,
2824,
497,
580,
13,
1678,
302,
7358,
353,
13853,
978,
10602,
29889,
12650,
29889,
4746,
877,
1025,
29918,
1272,
2824,
497,
580,
13,
1678,
6473,
29918,
10149,
29879,
353,
8198,
16037,
10601,
29889,
12650,
29889,
4746,
877,
1025,
29918,
1272,
2824,
497,
580,
13,
1678,
4833,
29918,
10149,
29879,
353,
8198,
9112,
10601,
29889,
12650,
29889,
4746,
877,
1025,
29918,
1272,
2824,
497,
580,
13,
1678,
1404,
3888,
353,
6571,
13,
13,
1678,
396,
29273,
6473,
15303,
13,
1678,
363,
3633,
297,
6473,
29918,
10149,
29879,
29901,
13,
4706,
1404,
353,
679,
29918,
1792,
29918,
4299,
2141,
12650,
29889,
4572,
29898,
333,
29922,
10149,
29889,
1792,
29918,
333,
467,
4102,
580,
13,
4706,
716,
29918,
10149,
353,
1383,
514,
10601,
29898,
978,
29922,
10149,
29889,
978,
29892,
1404,
29922,
1792,
29892,
4660,
29922,
10149,
29889,
4882,
29897,
13,
4706,
716,
29918,
10149,
29889,
7620,
580,
13,
13,
1678,
396,
29273,
6535,
15303,
13,
1678,
363,
3633,
297,
4833,
29918,
10149,
29879,
29901,
13,
4706,
1404,
353,
679,
29918,
1792,
29918,
4299,
2141,
12650,
29889,
4572,
29898,
333,
29922,
10149,
29889,
1792,
29918,
333,
467,
4102,
580,
13,
4706,
716,
29918,
10149,
353,
5470,
10601,
29898,
978,
29922,
10149,
29889,
978,
29892,
1404,
29922,
1792,
29892,
4660,
29922,
10149,
29889,
4882,
29897,
13,
4706,
716,
29918,
10149,
29889,
7620,
580,
13,
13,
1678,
396,
29273,
6782,
310,
13853,
978,
5235,
304,
422,
567,
542,
2659,
1904,
13,
1678,
363,
25985,
297,
302,
7358,
29901,
13,
4706,
1404,
29918,
333,
353,
25985,
29889,
1792,
29918,
333,
13,
13,
4706,
1404,
3888,
29961,
1792,
29918,
333,
29962,
353,
426,
13,
9651,
525,
19254,
978,
2396,
25985,
29889,
19254,
978,
29892,
13,
9651,
525,
22942,
29918,
3257,
2396,
15516,
13,
9651,
525,
22942,
29918,
2271,
2396,
6629,
13,
4706,
500,
13,
13,
1678,
396,
29273,
6782,
310,
13253,
5235,
304,
422,
567,
542,
2659,
1904,
13,
1678,
363,
3268,
297,
28007,
29901,
13,
4706,
1404,
29918,
333,
353,
3268,
29889,
1792,
29918,
333,
13,
13,
4706,
565,
1404,
29918,
333,
297,
1404,
3888,
29901,
13,
9651,
1404,
3888,
29961,
1792,
29918,
333,
22322,
22942,
29918,
3257,
2033,
353,
3268,
29889,
22942,
7030,
13,
9651,
1404,
3888,
29961,
1792,
29918,
333,
22322,
22942,
29918,
2271,
2033,
353,
3268,
29889,
22942,
5983,
13,
4706,
1683,
29901,
13,
9651,
1404,
3888,
29961,
1792,
29918,
333,
29962,
353,
426,
13,
18884,
525,
19254,
978,
2396,
15516,
13,
18884,
525,
22942,
29918,
3257,
2396,
3268,
29889,
22942,
7030,
29892,
13,
18884,
525,
22942,
29918,
2271,
2396,
3268,
29889,
22942,
5983,
13,
9651,
500,
13,
13,
1678,
396,
16913,
716,
422,
567,
542,
2659,
5235,
13,
1678,
363,
318,
333,
29892,
4902,
297,
1404,
3888,
29889,
7076,
7295,
13,
4706,
1404,
353,
679,
29918,
1792,
29918,
4299,
2141,
12650,
29889,
4572,
29898,
333,
29922,
5416,
467,
4102,
580,
13,
4706,
716,
29918,
1792,
3888,
353,
422,
567,
542,
2659,
29898,
19254,
978,
29922,
14144,
1839,
19254,
978,
7464,
4700,
29918,
3257,
29922,
14144,
1839,
22942,
29918,
3257,
7464,
13,
462,
462,
259,
4700,
29918,
2271,
29922,
14144,
1839,
22942,
29918,
2271,
7464,
1404,
29922,
1792,
29897,
13,
13,
4706,
1596,
877,
15078,
8253,
426,
1792,
29913,
4286,
4830,
29898,
1792,
29922,
1482,
29918,
1792,
3888,
876,
13,
13,
4706,
716,
29918,
1792,
3888,
29889,
7620,
580,
13,
13,
13,
1753,
9725,
403,
29918,
1025,
29918,
14080,
7295,
13,
1678,
9995,
13,
1678,
1281,
369,
1372,
599,
2030,
11803,
515,
263,
2560,
1813,
3402,
304,
697,
399,
351,
18237,
21486,
13,
1678,
9995,
13,
1678,
396,
1178,
29922,
29946,
338,
278,
2702,
1813,
3553,
363,
278,
9763,
2380,
1813,
13,
1678,
2380,
353,
9305,
29889,
12650,
29889,
657,
29898,
333,
29922,
29946,
467,
14940,
13,
1678,
2030,
29918,
14080,
353,
22365,
362,
29889,
12650,
29889,
4746,
877,
1025,
29918,
1272,
2824,
497,
2141,
2098,
29918,
1609,
877,
1256,
1495,
13,
1678,
1404,
353,
679,
29918,
1792,
29918,
4299,
2141,
12650,
29889,
657,
29898,
333,
29922,
29896,
29897,
13,
13,
1678,
363,
1400,
297,
2030,
29918,
14080,
29901,
13,
4706,
565,
1400,
29889,
3257,
29901,
13,
9651,
3611,
353,
1400,
29889,
3257,
13,
4706,
1683,
29901,
13,
9651,
3611,
353,
525,
13197,
2347,
2944,
515,
426,
1256,
29913,
4286,
4830,
29898,
1256,
29922,
1256,
29898,
2490,
29889,
1256,
29892,
525,
29928,
432,
29903,
383,
612,
8785,
13,
13,
4706,
2243,
688,
353,
2243,
688,
1598,
877,
29912,
3257,
29913,
448,
426,
9502,
29913,
4286,
4830,
29898,
3257,
29922,
3257,
29892,
20088,
29922,
524,
29898,
14486,
29898,
2230,
29889,
2230,
580,
334,
29871,
29896,
29900,
29900,
29900,
13697,
13,
13,
4706,
565,
7431,
29898,
2490,
29889,
726,
29897,
1405,
29871,
29945,
29896,
29906,
29901,
13,
9651,
22909,
353,
1400,
29889,
726,
7503,
29945,
29896,
29906,
29962,
718,
525,
856,
29915,
13,
4706,
1683,
29901,
13,
9651,
22909,
353,
1400,
29889,
726,
13,
13,
4706,
1813,
353,
350,
1188,
5074,
29898,
13,
9651,
2740,
29918,
8216,
2433,
742,
13,
9651,
409,
29877,
29918,
3257,
29922,
3257,
29892,
13,
9651,
1510,
29918,
262,
29918,
1527,
375,
29922,
8824,
29892,
13,
9651,
2243,
688,
29922,
29517,
29892,
13,
9651,
3611,
29922,
3257,
29892,
13,
9651,
2635,
29922,
2490,
29889,
1256,
29892,
13,
9651,
937,
29918,
5467,
3726,
29918,
271,
29922,
2490,
29889,
1256,
29892,
13,
9651,
22909,
29922,
1220,
8690,
29879,
29898,
23333,
511,
13,
4706,
1723,
13,
13,
4706,
1813,
29889,
2587,
29889,
5461,
29918,
1272,
353,
518,
13,
9651,
6702,
26956,
742,
4385,
1626,
877,
29966,
29886,
26208,
2587,
16040,
29886,
29958,
4286,
4830,
29898,
2587,
29922,
1220,
8690,
29879,
29898,
2490,
29889,
726,
13697,
13,
4706,
4514,
13,
13,
4706,
1813,
29889,
11338,
29889,
1202,
29898,
19795,
4345,
29918,
4571,
1783,
29961,
2490,
29889,
1853,
2314,
13,
13,
4706,
1596,
877,
15078,
8253,
4274,
515,
426,
1256,
29913,
4286,
4830,
29898,
1256,
29922,
2490,
29889,
1256,
876,
13,
13,
4706,
2380,
29889,
1202,
29918,
5145,
29898,
8758,
29922,
3488,
29897,
13,
4706,
26554,
353,
1813,
29889,
7620,
29918,
276,
4924,
29898,
13,
9651,
1404,
29922,
1792,
29892,
13,
9651,
18397,
29918,
1454,
29918,
1545,
261,
362,
29922,
8824,
13,
4706,
1723,
13,
4706,
26554,
29889,
23679,
580,
13,
4706,
1813,
29889,
7620,
580,
13,
13,
13,
1753,
9725,
403,
29918,
13604,
7295,
13,
1678,
1741,
29918,
2248,
353,
9305,
29889,
12650,
29889,
657,
29898,
333,
29922,
29953,
467,
14940,
13,
1678,
1404,
353,
679,
29918,
1792,
29918,
4299,
2141,
12650,
29889,
657,
29898,
333,
29922,
29896,
29897,
13,
1678,
2030,
29918,
13604,
353,
8198,
2624,
29889,
12650,
29889,
4746,
877,
1025,
29918,
1272,
2824,
497,
580,
13,
13,
1678,
396,
341,
4481,
403,
4959,
13,
1678,
363,
2030,
29918,
3696,
297,
2030,
29918,
13604,
29901,
13,
4706,
2030,
29918,
3696,
29918,
1853,
353,
2030,
29918,
3696,
29889,
1853,
13,
13,
4706,
1018,
29901,
13,
9651,
396,
1334,
1016,
29915,
29873,
2869,
2562,
1048,
445,
448,
967,
263,
1243,
304,
9725,
403,
278,
1741,
4822,
13,
9651,
1741,
29918,
1853,
353,
6864,
1542,
29889,
12650,
29889,
657,
29898,
978,
29922,
1025,
29918,
3696,
29918,
1853,
29889,
978,
29892,
3646,
29922,
1025,
29918,
3696,
29918,
1853,
29889,
5182,
29897,
13,
4706,
5174,
6864,
1542,
29889,
25125,
3664,
1252,
391,
29901,
13,
9651,
1741,
29918,
1853,
353,
6864,
1542,
29898,
978,
29922,
1025,
29918,
3696,
29918,
1853,
29889,
978,
29892,
3646,
29922,
1025,
29918,
3696,
29918,
1853,
29889,
5182,
29897,
13,
9651,
1741,
29918,
1853,
29889,
7620,
580,
13,
13,
4706,
3611,
353,
22372,
1853,
29913,
373,
426,
1256,
29913,
4286,
4830,
29898,
1853,
29922,
1025,
29918,
3696,
29918,
1853,
29889,
978,
29892,
2635,
29922,
1256,
29898,
1025,
29918,
3696,
29889,
2962,
29892,
525,
29928,
432,
29903,
383,
612,
8785,
13,
4706,
2243,
688,
353,
2243,
688,
1598,
877,
29912,
3257,
29913,
448,
426,
9502,
29913,
4286,
4830,
29898,
3257,
29922,
3257,
29892,
20088,
29922,
524,
29898,
14486,
29898,
2230,
29889,
2230,
580,
334,
29871,
29896,
29900,
29900,
29900,
13697,
13,
13,
4706,
565,
2030,
29918,
3696,
29889,
12759,
9868,
29901,
13,
9651,
6139,
353,
2030,
29918,
3696,
29889,
12759,
9868,
13,
4706,
1683,
29901,
13,
9651,
565,
2030,
29918,
3696,
29918,
1853,
29889,
3888,
29901,
13,
18884,
6139,
353,
2030,
29918,
3696,
29918,
1853,
29889,
3888,
13,
9651,
1683,
29901,
13,
18884,
6139,
353,
2030,
29918,
3696,
29918,
1853,
29889,
978,
13,
13,
4706,
716,
29918,
3696,
353,
6864,
5074,
29898,
13,
9651,
3611,
29922,
3257,
29889,
17010,
3285,
13,
9651,
2243,
688,
29922,
29517,
29892,
13,
9651,
6139,
29922,
8216,
29889,
17010,
3285,
13,
9651,
1369,
29922,
1025,
29918,
3696,
29889,
2962,
29892,
13,
9651,
8341,
29922,
1025,
29918,
3696,
29889,
4951,
728,
29892,
13,
9651,
12611,
839,
29922,
1025,
29918,
3696,
29889,
20713,
839,
29892,
13,
9651,
7663,
29922,
3696,
29918,
1853,
29892,
13,
9651,
4423,
29922,
1025,
29918,
3696,
29889,
5479,
29889,
978,
13,
4706,
1723,
13,
13,
4706,
716,
29918,
3696,
29889,
2587,
29889,
5461,
29918,
1272,
353,
518,
13,
9651,
6702,
26956,
742,
4385,
1626,
877,
29966,
29886,
26208,
2587,
16040,
29886,
29958,
4286,
4830,
29898,
2587,
29922,
1220,
8690,
29879,
29898,
1025,
29918,
3696,
29889,
5426,
9868,
13697,
13,
4706,
4514,
13,
13,
4706,
1596,
877,
15078,
8253,
1741,
426,
1853,
29913,
515,
426,
1256,
29913,
4286,
4830,
29898,
1853,
29922,
1025,
29918,
3696,
29889,
1853,
29889,
978,
29892,
2635,
29922,
1025,
29918,
3696,
29889,
2962,
876,
13,
13,
4706,
1741,
29918,
2248,
29889,
1202,
29918,
5145,
29898,
8758,
29922,
1482,
29918,
3696,
29897,
13,
4706,
26554,
353,
716,
29918,
3696,
29889,
7620,
29918,
276,
4924,
29898,
13,
9651,
1404,
29922,
1792,
29892,
13,
9651,
18397,
29918,
1454,
29918,
1545,
261,
362,
29922,
8824,
13,
4706,
1723,
13,
4706,
26554,
29889,
23679,
580,
13,
4706,
716,
29918,
3696,
29889,
7620,
580,
13,
13,
4706,
396,
897,
284,
411,
1804,
14340,
13,
4706,
2030,
29918,
4530,
14340,
353,
9954,
786,
29889,
12650,
29889,
4746,
877,
1025,
29918,
1272,
2824,
4572,
29898,
3696,
29918,
333,
29922,
1025,
29918,
3696,
29889,
333,
29897,
13,
13,
4706,
363,
2030,
29918,
4530,
786,
297,
2030,
29918,
4530,
14340,
29901,
13,
9651,
1596,
877,
15078,
8253,
1804,
786,
363,
426,
1853,
29913,
515,
426,
1256,
29913,
4286,
4830,
29898,
1853,
29922,
1025,
29918,
3696,
29889,
1853,
29889,
978,
29892,
2635,
29922,
1025,
29918,
3696,
29889,
2962,
876,
13,
9651,
716,
29918,
4530,
786,
353,
6864,
10140,
786,
29898,
9342,
29922,
509,
4661,
403,
305,
1503,
29898,
1025,
29918,
4530,
786,
29889,
9342,
29892,
29871,
29896,
29900,
29906,
29946,
511,
13,
462,
462,
268,
4509,
29922,
657,
29918,
1792,
29918,
4299,
2141,
12650,
29889,
657,
29898,
333,
29922,
1025,
29918,
4530,
786,
29889,
1792,
29918,
333,
511,
13,
462,
462,
268,
1741,
29918,
333,
29922,
1482,
29918,
3696,
29889,
333,
29892,
1804,
786,
29918,
11600,
29922,
1025,
29918,
4530,
786,
29889,
2230,
29897,
13,
9651,
716,
29918,
4530,
786,
29889,
7620,
580,
13,
13,
13,
1990,
10516,
29898,
5160,
6255,
1125,
13,
1678,
822,
4386,
29898,
1311,
29892,
334,
5085,
29892,
3579,
6768,
1125,
13,
4706,
9725,
403,
29918,
510,
567,
542,
29918,
14242,
3888,
580,
13,
4706,
9725,
403,
29918,
1025,
29918,
14080,
580,
13,
4706,
9725,
403,
29918,
13604,
580,
13,
2
] |
main.py | maxBombrun/lipidDroplets | 0 | 38511 | <reponame>maxBombrun/lipidDroplets<gh_stars>0
import os
import csv
import multiprocessing
import settings
import segmentNucAndGFP
import cellProfilerGetRelation
import measureGFPSize
import plotFeatures
import fusionCSV
import clusterDroplets
import computeZprime
settings.init()
CPPath=settings.pathList[0]
inputDataPath=settings.pathList[1]
resultPath=settings.pathList[2]
outputDetPath=settings.pathList[3]
inputCellProfilerPath=settings.pathList[4]
outputCellProfilerPath=settings.pathList[5]
nProc = multiprocessing.cpu_count()
listPlates= [x for x in os.listdir(inputDataPath) if os.path.isdir(inputDataPath+x) and x.startswith('plate')]
csv.register_dialect('unixpwd', delimiter=',',quotechar = '"', doublequote = True, skipinitialspace = False,lineterminator = '\n', quoting = csv.QUOTE_NONE)
print listPlates
## Segmentation of the nuclei and the lipid droplets
segmentNucAndGFP.segmentFatDroplet(listPlates)
## Cells approximation based on the previous segmentation
## and features extraction through CellProfiler
cellProfilerGetRelation.runCellProfilerRelationship()
## Individual lipid droplet measurements
## Creation of size distribution vectors
measureGFPSize.measureGFP()
## Classification of the cells based on the vectors
clusterDroplets.getClusterOfDroplets(nbClass=2)
## Creation of CSV output, summarizing the measurements per-cell and per-well
fusionCSV.getPerImageMeasurements()
## Plotting of the features
plotFeatures.plotFeat()
## Validation of the features through the computation of the Zprime factor
computeZprime.getZprime()
| [
1,
529,
276,
1112,
420,
29958,
3317,
29933,
290,
1182,
348,
29914,
3466,
333,
29928,
307,
552,
1372,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
5215,
2897,
30004,
13,
5215,
11799,
30004,
13,
5215,
6674,
307,
985,
292,
30004,
13,
30004,
13,
5215,
6055,
30004,
13,
5215,
10768,
29940,
1682,
2855,
29954,
26353,
30004,
13,
5215,
3038,
1184,
1777,
261,
2577,
9662,
362,
30004,
13,
5215,
5645,
29954,
26353,
3505,
30004,
13,
5215,
6492,
8263,
3698,
30004,
13,
5215,
21736,
29907,
7597,
30004,
13,
5215,
9867,
29928,
307,
552,
1372,
30004,
13,
5215,
10272,
29999,
10080,
30004,
13,
30004,
13,
30004,
13,
30004,
13,
11027,
29889,
2344,
580,
6756,
13,
30004,
13,
6271,
2605,
29922,
11027,
29889,
2084,
1293,
29961,
29900,
29962,
30004,
13,
2080,
1469,
2605,
29922,
11027,
29889,
2084,
1293,
29961,
29896,
29962,
30004,
13,
2914,
2605,
29922,
11027,
29889,
2084,
1293,
29961,
29906,
29962,
30004,
13,
4905,
6362,
2605,
29922,
11027,
29889,
2084,
1293,
29961,
29941,
29962,
30004,
13,
2080,
4617,
1184,
1777,
261,
2605,
29922,
11027,
29889,
2084,
1293,
29961,
29946,
29962,
30004,
13,
4905,
4617,
1184,
1777,
261,
2605,
29922,
11027,
29889,
2084,
1293,
29961,
29945,
29962,
30004,
13,
30004,
13,
30004,
13,
30004,
13,
29876,
27893,
353,
6674,
307,
985,
292,
29889,
21970,
29918,
2798,
26471,
13,
1761,
3247,
1078,
29922,
518,
29916,
363,
921,
297,
2897,
29889,
1761,
3972,
29898,
2080,
1469,
2605,
29897,
565,
2897,
29889,
2084,
29889,
275,
3972,
29898,
2080,
1469,
2605,
29974,
29916,
29897,
322,
921,
29889,
27382,
2541,
877,
2341,
1495,
29962,
30004,
13,
30004,
13,
7638,
29889,
9573,
29918,
15321,
781,
877,
24538,
29886,
9970,
742,
28552,
29922,
742,
742,
1396,
3090,
353,
18793,
742,
3765,
1396,
353,
5852,
29892,
14383,
11228,
3493,
353,
7700,
29892,
1915,
300,
837,
262,
1061,
353,
11297,
29876,
742,
29871,
439,
11427,
353,
11799,
29889,
13356,
2891,
29923,
29918,
29940,
12413,
8443,
13,
30004,
13,
2158,
1051,
3247,
1078,
30004,
13,
30004,
13,
2277,
6667,
358,
362,
310,
278,
11205,
16301,
322,
278,
619,
5935,
4441,
552,
1372,
30004,
13,
28192,
29940,
1682,
2855,
29954,
26353,
29889,
28192,
29943,
271,
29928,
307,
552,
29873,
29898,
1761,
3247,
1078,
8443,
13,
30004,
13,
2277,
315,
10071,
16845,
2729,
373,
278,
3517,
10768,
362,
30004,
13,
2277,
322,
5680,
4805,
428,
1549,
19413,
1184,
1777,
261,
30004,
13,
3729,
1184,
1777,
261,
2577,
9662,
362,
29889,
3389,
4617,
1184,
1777,
261,
9662,
800,
4034,
26471,
13,
30004,
13,
2277,
1894,
23352,
619,
5935,
4441,
552,
29873,
20398,
30004,
13,
2277,
6760,
362,
310,
2159,
4978,
12047,
30004,
13,
26658,
29954,
26353,
3505,
29889,
26658,
29954,
26353,
26471,
13,
30004,
13,
2277,
23236,
310,
278,
9101,
2729,
373,
278,
12047,
30004,
13,
19594,
29928,
307,
552,
1372,
29889,
657,
6821,
5402,
2776,
29928,
307,
552,
1372,
29898,
9877,
2385,
29922,
29906,
8443,
13,
30004,
13,
2277,
6760,
362,
310,
16874,
1962,
29892,
19138,
5281,
278,
20398,
639,
29899,
3729,
322,
639,
29899,
5872,
30004,
13,
29888,
3958,
29907,
7597,
29889,
657,
5894,
2940,
6816,
3745,
1860,
26471,
13,
30004,
13,
2277,
18399,
1259,
310,
278,
5680,
30004,
13,
5317,
8263,
3698,
29889,
5317,
8263,
271,
26471,
13,
30004,
13,
2277,
15758,
362,
310,
278,
5680,
1549,
278,
16287,
310,
278,
796,
10080,
7329,
30004,
13,
26017,
29999,
10080,
29889,
657,
29999,
10080,
26471,
13,
30004,
13,
30004,
13,
2
] |
examples/tasks/dtw-energy-plus-models-data/code.py | dburian/ivis-core | 2 | 14106 | <gh_stars>1-10
import sys
import os
import json
from elasticsearch import Elasticsearch, helpers
from datetime import datetime, timezone
import numpy as np
from dtw import dtw
# Get parameters and set up elasticsearch
data = json.loads(sys.stdin.readline())
es = Elasticsearch([{'host': data['es']['host'], 'port': int(data['es']['port'])}])
state = data.get('state')
params= data['params']
entities= data['entities']
# Get ES index and fields
sensor_set = entities['signalSets'][params['sensors']]
sensor_ts = entities['signals'][params['sensors']][params['ts']]
sensor_co2 = entities['signals'][params['sensors']][params['co2']]
limit_val = float(params['limitValue'])
limit = limit_val
if state is None or state.get('index') is None:
ns = sensor_set['namespace']
msg = {}
msg['type'] = 'sets'
# Request new signal set creation
msg['sigSet'] = {
"cid" : "e_plus_mod",
"name" : "E+ comparison" ,
"namespace": ns,
"description" : "Comparison of Energy+ models" ,
"aggs" : "0"
}
signals= []
signals.append({
"cid": "ts",
"name": "ts",
"description": "timestamp",
"namespace": ns,
"type": "date",
"indexed": False,
"settings": {}
})
signals.append({
"cid": "mod",
"name": "mod",
"description": "mod",
"namespace": ns,
"type": "keyword",
"indexed": False,
"settings": {}
})
signals.append({
"cid": "model",
"name": "model",
"description": "Closest model's cid",
"namespace": ns,
"type": "keyword",
"indexed": False,
"settings": {}
})
msg['sigSet']['signals'] = signals
ret = os.write(3,(json.dumps(msg) + '\n').encode())
state = json.loads(sys.stdin.readline())
error = state.get('error')
if error:
sys.stderr.write(error+"\n")
sys.exit(1)
else:
store_msg = {}
store_msg["type"] = "store"
store_msg["state"] = state
ret = os.write(3,(json.dumps(store_msg) + '\n').encode())
def get_co2_values(index,ts_field, co2_field):
# sensor data query
query = {
'_source': [co2_field, ts_field],
'sort': [{ts_field: 'asc'}],
'query': {
"range" : {
ts_field : {
"gt" : "now-180m/m",
"lt" : "now/m"
}
}
}
}
results = es.search(index=index, body=query)
sensor_data = []
for item in results['hits']['hits']:
val = item["_source"][co2_field]
if val is not None:
sensor_data.append(val)
else:
continue
return sensor_data
sensor_data = get_co2_values(sensor_set['index'], sensor_ts['field'], sensor_co2['field'])
if not sensor_data:
print('No sensor data to measure on')
exit()
sensor_np = np.array(sensor_data, dtype=float).reshape(-1, 1)
euclidean_norm = lambda x, y: np.abs(x - y)
min_model={}
min_distance=float("inf")
for model in params['models']:
ts =entities['signals'][model['sigSet']][model['ts']]['field']
co2 =entities['signals'][model['sigSet']][model['co2']]['field']
sig_set = entities['signalSets'][model['sigSet']]['index']
model_data = get_co2_values(sig_set, ts,co2)
if not model_data:
print(f'No data for signal set {sig_set}')
continue
# Calculate for all models
model_np = np.array(model_data, dtype=float).reshape(-1, 1)
# Calculate for all models
d, cost_matrix, acc_cost_matrix, path = dtw(sensor_np, model_np, dist=euclidean_norm)
if d<min_distance:
min_distance = d
min_model['name'] = entities["signalSets"][model["sigSet"]]["name"]
min_model['cid'] = model["sigSet"]
min_model['ts'] = ts
min_model['co2'] = co2
min_model['index'] = sig_set
# Do something with closest model
if not min_model:
print('No model found')
exit()
print(f'Closest model is: {min_model["name"]}')
# Query prediction
query = {
'_source': [min_model['co2'], min_model['ts']],
'sort': [{min_model['ts']: 'asc'}],
"aggs" : {
"max_co2" : { "max" : { "field" : min_model['co2'] } }
},
'query': {
"range" : {
min_model['ts'] : {
"gt" : "now/m",
"lt" : "now+60m/m"
}
}
}
}
results = es.search(index=min_model['index'], body=query)
max_co2 = results['aggregations']['max_co2']['value']
# Get current mode
# TODO this will probably change later on to take data from the actual system
query = {
'size': 1,
'_source': [state['fields']['mod']],
'sort': [{state['fields']['ts']: 'desc'}],
'query': {
"match_all": {}
}
}
results = es.search(index=state['index'], body=query)
mod = results['hits']['hits'][0]['_source'][state['fields']['mod']] if results['hits']['total'] > 0 else 'mod1'
# If currently over limit or going to be according to models data, open more
if sensor_data[-1] > limit or max_co2 > limit:
mod = 'mod2'
elif sensor_data[-1] < limit - 200:
mod = 'mod1'
print(f'Chosen: {mod}')
ts = datetime.now(timezone.utc).astimezone()
doc = {
state['fields']['ts']: ts,
state['fields']['model']: min_model['cid'],
state['fields']['mod']: mod
}
res = es.index(index=state['index'], doc_type='_doc', id=ts, body=doc)
#prediction_data = []
#for item in results['hits']['hits']:
# val = item["_source"][min_model['co2']]
# if val is not None:
# prediction_data.append(val)
# else:
# continue
#print (prediction_data)
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
10876,
13,
5215,
2897,
13,
5215,
4390,
13,
3166,
560,
20291,
1053,
1260,
20291,
29892,
1371,
414,
13,
13,
3166,
12865,
1053,
12865,
29892,
29431,
13,
5215,
12655,
408,
7442,
13,
3166,
270,
7516,
1053,
270,
7516,
13,
13,
29937,
3617,
4128,
322,
731,
701,
560,
20291,
13,
1272,
353,
4390,
29889,
18132,
29898,
9675,
29889,
4172,
262,
29889,
949,
1220,
3101,
13,
267,
353,
1260,
20291,
4197,
10998,
3069,
2396,
848,
1839,
267,
16215,
3069,
7464,
525,
637,
2396,
938,
29898,
1272,
1839,
267,
16215,
637,
2033,
2915,
2314,
13,
13,
3859,
353,
848,
29889,
657,
877,
3859,
1495,
13,
13,
7529,
29922,
848,
1839,
7529,
2033,
13,
296,
1907,
29922,
848,
1839,
296,
1907,
2033,
13,
13,
29937,
3617,
17956,
2380,
322,
4235,
13,
29879,
6073,
29918,
842,
353,
16212,
1839,
25436,
29903,
1691,
2033,
29961,
7529,
1839,
23149,
943,
2033,
29962,
13,
29879,
6073,
29918,
1372,
353,
16212,
1839,
4530,
1338,
2033,
29961,
7529,
1839,
23149,
943,
2033,
3816,
7529,
1839,
1372,
2033,
29962,
13,
29879,
6073,
29918,
1111,
29906,
353,
16212,
1839,
4530,
1338,
2033,
29961,
7529,
1839,
23149,
943,
2033,
3816,
7529,
1839,
1111,
29906,
2033,
29962,
13,
13,
13400,
29918,
791,
353,
5785,
29898,
7529,
1839,
13400,
1917,
11287,
13,
13,
13400,
353,
4046,
29918,
791,
13,
13,
361,
2106,
338,
6213,
470,
2106,
29889,
657,
877,
2248,
1495,
338,
6213,
29901,
13,
1678,
17534,
353,
23530,
29918,
842,
1839,
22377,
2033,
13,
259,
13,
1678,
10191,
353,
6571,
13,
1678,
10191,
1839,
1853,
2033,
353,
525,
7224,
29915,
13,
1678,
396,
10729,
716,
7182,
731,
11265,
29871,
13,
1678,
10191,
1839,
18816,
2697,
2033,
353,
426,
13,
1678,
376,
25232,
29908,
584,
376,
29872,
29918,
11242,
29918,
1545,
613,
13,
1678,
376,
978,
29908,
584,
376,
29923,
29974,
10230,
29908,
1919,
13,
1678,
376,
22377,
1115,
17534,
29892,
13,
1678,
376,
8216,
29908,
584,
376,
1523,
20941,
310,
24836,
29974,
4733,
29908,
1919,
13,
1678,
376,
351,
3174,
29908,
584,
29871,
376,
29900,
29908,
29871,
13,
1678,
500,
13,
13,
1678,
18470,
29922,
5159,
29871,
13,
1678,
18470,
29889,
4397,
3319,
13,
418,
376,
25232,
1115,
376,
1372,
613,
13,
418,
376,
978,
1115,
376,
1372,
613,
13,
418,
376,
8216,
1115,
376,
16394,
613,
13,
418,
376,
22377,
1115,
17534,
29892,
13,
418,
376,
1853,
1115,
376,
1256,
613,
13,
418,
376,
2248,
287,
1115,
7700,
29892,
13,
418,
376,
11027,
1115,
6571,
13,
1678,
5615,
13,
1678,
18470,
29889,
4397,
3319,
13,
418,
376,
25232,
1115,
376,
1545,
613,
13,
418,
376,
978,
1115,
376,
1545,
613,
13,
418,
376,
8216,
1115,
376,
1545,
613,
13,
418,
376,
22377,
1115,
17534,
29892,
13,
418,
376,
1853,
1115,
376,
26766,
613,
13,
418,
376,
2248,
287,
1115,
7700,
29892,
13,
418,
376,
11027,
1115,
6571,
13,
1678,
5615,
13,
1678,
18470,
29889,
4397,
3319,
13,
418,
376,
25232,
1115,
376,
4299,
613,
13,
418,
376,
978,
1115,
376,
4299,
613,
13,
418,
376,
8216,
1115,
376,
29907,
5409,
342,
1904,
29915,
29879,
274,
333,
613,
13,
418,
376,
22377,
1115,
17534,
29892,
13,
418,
376,
1853,
1115,
376,
26766,
613,
13,
418,
376,
2248,
287,
1115,
7700,
29892,
13,
418,
376,
11027,
1115,
6571,
13,
1678,
5615,
13,
1678,
10191,
1839,
18816,
2697,
16215,
4530,
1338,
2033,
353,
18470,
13,
13,
1678,
3240,
353,
2897,
29889,
3539,
29898,
29941,
22657,
3126,
29889,
29881,
17204,
29898,
7645,
29897,
718,
11297,
29876,
2824,
12508,
3101,
13,
1678,
2106,
353,
4390,
29889,
18132,
29898,
9675,
29889,
4172,
262,
29889,
949,
1220,
3101,
13,
1678,
1059,
353,
2106,
29889,
657,
877,
2704,
1495,
13,
1678,
565,
1059,
29901,
13,
418,
10876,
29889,
303,
20405,
29889,
3539,
29898,
2704,
13578,
29905,
29876,
1159,
13,
418,
10876,
29889,
13322,
29898,
29896,
29897,
13,
1678,
1683,
29901,
13,
418,
3787,
29918,
7645,
353,
6571,
13,
418,
3787,
29918,
7645,
3366,
1853,
3108,
353,
376,
8899,
29908,
13,
418,
3787,
29918,
7645,
3366,
3859,
3108,
353,
2106,
13,
418,
3240,
353,
2897,
29889,
3539,
29898,
29941,
22657,
3126,
29889,
29881,
17204,
29898,
8899,
29918,
7645,
29897,
718,
11297,
29876,
2824,
12508,
3101,
13,
13,
1753,
679,
29918,
1111,
29906,
29918,
5975,
29898,
2248,
29892,
1372,
29918,
2671,
29892,
1302,
29906,
29918,
2671,
1125,
13,
29871,
396,
23530,
848,
2346,
13,
29871,
2346,
353,
426,
13,
418,
22868,
4993,
2396,
518,
1111,
29906,
29918,
2671,
29892,
18696,
29918,
2671,
1402,
13,
418,
525,
6605,
2396,
15974,
1372,
29918,
2671,
29901,
525,
6151,
10827,
1402,
13,
418,
525,
1972,
2396,
426,
13,
4706,
376,
3881,
29908,
584,
426,
13,
3986,
18696,
29918,
2671,
584,
426,
13,
9651,
376,
4141,
29908,
584,
376,
3707,
29899,
29896,
29947,
29900,
29885,
29914,
29885,
613,
13,
9651,
376,
1896,
29908,
584,
376,
3707,
29914,
29885,
29908,
13,
3986,
500,
13,
4706,
500,
13,
418,
500,
13,
29871,
500,
13,
259,
13,
29871,
2582,
353,
831,
29889,
4478,
29898,
2248,
29922,
2248,
29892,
3573,
29922,
1972,
29897,
13,
259,
13,
29871,
23530,
29918,
1272,
353,
5159,
13,
29871,
363,
2944,
297,
2582,
1839,
29882,
1169,
16215,
29882,
1169,
2033,
29901,
13,
1678,
659,
353,
2944,
3366,
29918,
4993,
3108,
29961,
1111,
29906,
29918,
2671,
29962,
13,
1678,
565,
659,
338,
451,
6213,
29901,
13,
418,
23530,
29918,
1272,
29889,
4397,
29898,
791,
29897,
13,
1678,
1683,
29901,
13,
418,
6773,
13,
259,
13,
29871,
736,
23530,
29918,
1272,
13,
13,
29879,
6073,
29918,
1272,
353,
679,
29918,
1111,
29906,
29918,
5975,
29898,
29879,
6073,
29918,
842,
1839,
2248,
7464,
23530,
29918,
1372,
1839,
2671,
7464,
23530,
29918,
1111,
29906,
1839,
2671,
11287,
13,
13,
361,
451,
23530,
29918,
1272,
29901,
13,
29871,
1596,
877,
3782,
23530,
848,
304,
5645,
373,
1495,
13,
29871,
6876,
580,
13,
13,
29879,
6073,
29918,
9302,
353,
7442,
29889,
2378,
29898,
29879,
6073,
29918,
1272,
29892,
26688,
29922,
7411,
467,
690,
14443,
6278,
29896,
29892,
29871,
29896,
29897,
13,
13,
29872,
27511,
29918,
12324,
353,
14013,
921,
29892,
343,
29901,
7442,
29889,
6897,
29898,
29916,
448,
343,
29897,
13,
13,
1195,
29918,
4299,
3790,
29913,
13,
1195,
29918,
19244,
29922,
7411,
703,
7192,
1159,
13,
1454,
1904,
297,
8636,
1839,
9794,
2033,
29901,
13,
259,
13,
29871,
18696,
353,
296,
1907,
1839,
4530,
1338,
2033,
29961,
4299,
1839,
18816,
2697,
2033,
3816,
4299,
1839,
1372,
2033,
22322,
2671,
2033,
13,
29871,
1302,
29906,
353,
296,
1907,
1839,
4530,
1338,
2033,
29961,
4299,
1839,
18816,
2697,
2033,
3816,
4299,
1839,
1111,
29906,
2033,
22322,
2671,
2033,
13,
29871,
4365,
29918,
842,
353,
16212,
1839,
25436,
29903,
1691,
2033,
29961,
4299,
1839,
18816,
2697,
2033,
22322,
2248,
2033,
13,
259,
13,
29871,
1904,
29918,
1272,
353,
679,
29918,
1111,
29906,
29918,
5975,
29898,
18816,
29918,
842,
29892,
18696,
29892,
1111,
29906,
29897,
13,
29871,
565,
451,
1904,
29918,
1272,
29901,
13,
1678,
1596,
29898,
29888,
29915,
3782,
848,
363,
7182,
731,
426,
18816,
29918,
842,
29913,
1495,
13,
1678,
6773,
13,
29871,
396,
20535,
403,
363,
599,
4733,
13,
29871,
1904,
29918,
9302,
353,
7442,
29889,
2378,
29898,
4299,
29918,
1272,
29892,
26688,
29922,
7411,
467,
690,
14443,
6278,
29896,
29892,
29871,
29896,
29897,
13,
259,
13,
29871,
396,
20535,
403,
363,
599,
4733,
13,
29871,
270,
29892,
3438,
29918,
5344,
29892,
1035,
29918,
18253,
29918,
5344,
29892,
2224,
353,
270,
7516,
29898,
29879,
6073,
29918,
9302,
29892,
1904,
29918,
9302,
29892,
1320,
29922,
29872,
27511,
29918,
12324,
29897,
13,
259,
13,
29871,
565,
270,
29966,
1195,
29918,
19244,
29901,
13,
1678,
1375,
29918,
19244,
353,
270,
13,
1678,
1375,
29918,
4299,
1839,
978,
2033,
353,
16212,
3366,
25436,
29903,
1691,
3108,
29961,
4299,
3366,
18816,
2697,
3108,
29962,
3366,
978,
3108,
13,
1678,
1375,
29918,
4299,
1839,
25232,
2033,
353,
1904,
3366,
18816,
2697,
3108,
13,
1678,
1375,
29918,
4299,
1839,
1372,
2033,
353,
18696,
13,
1678,
1375,
29918,
4299,
1839,
1111,
29906,
2033,
353,
1302,
29906,
13,
1678,
1375,
29918,
4299,
1839,
2248,
2033,
353,
4365,
29918,
842,
13,
13,
29937,
1938,
1554,
411,
21438,
1904,
13,
361,
451,
1375,
29918,
4299,
29901,
13,
29871,
1596,
877,
3782,
1904,
1476,
1495,
13,
29871,
6876,
580,
13,
2158,
29898,
29888,
29915,
29907,
5409,
342,
1904,
338,
29901,
426,
1195,
29918,
4299,
3366,
978,
3108,
29913,
1495,
13,
13,
29937,
13641,
18988,
13,
1972,
353,
426,
13,
1678,
22868,
4993,
2396,
518,
1195,
29918,
4299,
1839,
1111,
29906,
7464,
1375,
29918,
4299,
1839,
1372,
2033,
1402,
13,
1678,
525,
6605,
2396,
15974,
1195,
29918,
4299,
1839,
1372,
2033,
29901,
525,
6151,
10827,
1402,
13,
1678,
376,
351,
3174,
29908,
584,
426,
13,
4706,
376,
3317,
29918,
1111,
29906,
29908,
584,
426,
376,
3317,
29908,
584,
426,
376,
2671,
29908,
584,
1375,
29918,
4299,
1839,
1111,
29906,
2033,
500,
500,
13,
1678,
2981,
13,
1678,
525,
1972,
2396,
426,
13,
418,
376,
3881,
29908,
584,
426,
13,
4706,
1375,
29918,
4299,
1839,
1372,
2033,
584,
426,
13,
3986,
376,
4141,
29908,
584,
376,
3707,
29914,
29885,
613,
13,
3986,
376,
1896,
29908,
584,
376,
3707,
29974,
29953,
29900,
29885,
29914,
29885,
29908,
13,
4706,
500,
13,
418,
500,
13,
1678,
500,
13,
29913,
13,
13,
13,
9902,
353,
831,
29889,
4478,
29898,
2248,
29922,
1195,
29918,
4299,
1839,
2248,
7464,
3573,
29922,
1972,
29897,
13,
3317,
29918,
1111,
29906,
353,
2582,
1839,
26193,
800,
16215,
3317,
29918,
1111,
29906,
16215,
1767,
2033,
13,
13,
29937,
3617,
1857,
4464,
29871,
13,
29937,
14402,
445,
674,
3117,
1735,
2678,
373,
304,
2125,
848,
515,
278,
3935,
1788,
13,
1972,
353,
426,
13,
259,
525,
2311,
2396,
29871,
29896,
29892,
13,
259,
22868,
4993,
2396,
518,
3859,
1839,
9621,
16215,
1545,
2033,
1402,
13,
259,
525,
6605,
2396,
15974,
3859,
1839,
9621,
16215,
1372,
2033,
29901,
525,
14273,
10827,
1402,
13,
259,
525,
1972,
2396,
426,
13,
418,
376,
4352,
29918,
497,
1115,
6571,
13,
259,
500,
13,
29913,
13,
9902,
353,
831,
29889,
4478,
29898,
2248,
29922,
3859,
1839,
2248,
7464,
3573,
29922,
1972,
29897,
13,
1545,
353,
2582,
1839,
29882,
1169,
16215,
29882,
1169,
2033,
29961,
29900,
22322,
29918,
4993,
2033,
29961,
3859,
1839,
9621,
16215,
1545,
2033,
29962,
565,
2582,
1839,
29882,
1169,
16215,
7827,
2033,
1405,
29871,
29900,
1683,
525,
1545,
29896,
29915,
13,
13,
29937,
960,
5279,
975,
4046,
470,
2675,
304,
367,
5034,
304,
4733,
848,
29892,
1722,
901,
13,
361,
23530,
29918,
1272,
14352,
29896,
29962,
1405,
4046,
470,
4236,
29918,
1111,
29906,
1405,
4046,
29901,
13,
29871,
878,
353,
525,
1545,
29906,
29915,
13,
23681,
23530,
29918,
1272,
14352,
29896,
29962,
529,
4046,
448,
29871,
29906,
29900,
29900,
29901,
13,
29871,
878,
353,
525,
1545,
29896,
29915,
13,
13,
2158,
29898,
29888,
29915,
1451,
7749,
29901,
426,
1545,
29913,
1495,
13,
13,
1372,
353,
12865,
29889,
3707,
29898,
2230,
8028,
29889,
329,
29883,
467,
579,
603,
8028,
580,
13,
1514,
353,
426,
13,
29871,
2106,
1839,
9621,
16215,
1372,
2033,
29901,
18696,
29892,
13,
29871,
2106,
1839,
9621,
16215,
4299,
2033,
29901,
1375,
29918,
4299,
1839,
25232,
7464,
13,
29871,
2106,
1839,
9621,
16215,
1545,
2033,
29901,
878,
29871,
13,
29913,
13,
690,
353,
831,
29889,
2248,
29898,
2248,
29922,
3859,
1839,
2248,
7464,
1574,
29918,
1853,
2433,
29918,
1514,
742,
1178,
29922,
1372,
29892,
3573,
29922,
1514,
29897,
13,
13,
29937,
11965,
2463,
29918,
1272,
353,
5159,
13,
29937,
1454,
2944,
297,
2582,
1839,
29882,
1169,
16215,
29882,
1169,
2033,
29901,
13,
29937,
29871,
659,
353,
2944,
3366,
29918,
4993,
3108,
29961,
1195,
29918,
4299,
1839,
1111,
29906,
2033,
29962,
13,
29937,
29871,
565,
659,
338,
451,
6213,
29901,
13,
29937,
1678,
18988,
29918,
1272,
29889,
4397,
29898,
791,
29897,
13,
29937,
29871,
1683,
29901,
13,
29937,
1678,
6773,
13,
29937,
2158,
313,
11965,
2463,
29918,
1272,
29897,
13,
2
] |
src/lib/detectors/ddd.py | nerminsamet/houghnet | 161 | 67088 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import cv2
import numpy as np
from progress.bar import Bar
import time
import torch
from src.lib.external.nms import soft_nms
from src.lib.models.decode import ddd_decode
from src.lib.models.utils import flip_tensor
from src.lib.utils.image import get_affine_transform
from src.lib.utils.post_process import ddd_post_process
from src.lib.utils.debugger import Debugger
from src.lib.utils.ddd_utils import compute_box_3d, project_to_image, alpha2rot_y
from src.lib.utils.ddd_utils import draw_box_3d, unproject_2d_to_3d
from .base_detector import BaseDetector
class DddDetector(BaseDetector):
def __init__(self, opt):
super(DddDetector, self).__init__(opt)
self.calib = np.array([[707.0493, 0, 604.0814, 45.75831],
[0, 707.0493, 180.5066, -0.3454157],
[0, 0, 1., 0.004981016]], dtype=np.float32)
def pre_process(self, image, scale, calib=None):
height, width = image.shape[0:2]
inp_height, inp_width = self.opt.input_h, self.opt.input_w
c = np.array([width / 2, height / 2], dtype=np.float32)
if self.opt.keep_res:
s = np.array([inp_width, inp_height], dtype=np.int32)
else:
s = np.array([width, height], dtype=np.int32)
trans_input = get_affine_transform(c, s, 0, [inp_width, inp_height])
resized_image = image #cv2.resize(image, (width, height))
inp_image = cv2.warpAffine(
resized_image, trans_input, (inp_width, inp_height),
flags=cv2.INTER_LINEAR)
inp_image = (inp_image.astype(np.float32) / 255.)
inp_image = (inp_image - self.mean) / self.std
images = inp_image.transpose(2, 0, 1)[np.newaxis, ...]
calib = np.array(calib, dtype=np.float32) if calib is not None \
else self.calib
images = torch.from_numpy(images)
meta = {'c': c, 's': s,
'out_height': inp_height // self.opt.down_ratio,
'out_width': inp_width // self.opt.down_ratio,
'calib': calib}
return images, meta
def process(self, images, return_time=False):
with torch.no_grad():
torch.cuda.synchronize()
output = self.model(images)[-1]
output['hm'] = output['hm'].sigmoid_()
output['dep'] = 1. / (output['dep'].sigmoid() + 1e-6) - 1.
wh = output['wh'] if self.opt.reg_bbox else None
reg = output['reg'] if self.opt.reg_offset else None
torch.cuda.synchronize()
forward_time = time.time()
dets = ddd_decode(output['hm'], output['rot'], output['dep'],
output['dim'], wh=wh, reg=reg, K=self.opt.K)
if return_time:
return output, dets, forward_time
else:
return output, dets
def post_process(self, dets, meta, scale=1):
dets = dets.detach().cpu().numpy()
detections = ddd_post_process(
dets.copy(), [meta['c']], [meta['s']], [meta['calib']], self.opt)
self.this_calib = meta['calib']
return detections[0]
def merge_outputs(self, detections):
results = detections[0]
for j in range(1, self.num_classes + 1):
if len(results[j] > 0):
keep_inds = (results[j][:, -1] > self.opt.peak_thresh)
results[j] = results[j][keep_inds]
return results
def debug(self, debugger, images, dets, output, scale=1):
dets = dets.detach().cpu().numpy()
img = images[0].detach().cpu().numpy().transpose(1, 2, 0)
img = ((img * self.std + self.mean) * 255).astype(np.uint8)
pred = debugger.gen_colormap(output['hm'][0].detach().cpu().numpy())
debugger.add_blend_img(img, pred, 'pred_hm')
debugger.add_ct_detection(
img, dets[0], show_box=self.opt.reg_bbox,
center_thresh=self.opt.vis_thresh, img_id='det_pred')
def show_results(self, debugger, image, results):
debugger.add_3d_detection(
image, results, self.this_calib,
center_thresh=self.opt.vis_thresh, img_id='add_pred')
debugger.add_bird_view(
results, center_thresh=self.opt.vis_thresh, img_id='bird_pred')
debugger.show_all_imgs(pause=self.pause) | [
1,
515,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8542,
13,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
13,
5215,
13850,
29906,
13,
5215,
12655,
408,
7442,
13,
3166,
6728,
29889,
1646,
1053,
2261,
13,
5215,
931,
13,
5215,
4842,
305,
13,
13,
3166,
4765,
29889,
1982,
29889,
23176,
29889,
29876,
1516,
1053,
4964,
29918,
29876,
1516,
13,
3166,
4765,
29889,
1982,
29889,
9794,
29889,
13808,
1053,
270,
1289,
29918,
13808,
13,
3166,
4765,
29889,
1982,
29889,
9794,
29889,
13239,
1053,
285,
3466,
29918,
20158,
13,
3166,
4765,
29889,
1982,
29889,
13239,
29889,
3027,
1053,
679,
29918,
3470,
457,
29918,
9067,
13,
3166,
4765,
29889,
1982,
29889,
13239,
29889,
2490,
29918,
5014,
1053,
270,
1289,
29918,
2490,
29918,
5014,
13,
3166,
4765,
29889,
1982,
29889,
13239,
29889,
8382,
914,
1053,
16171,
914,
13,
3166,
4765,
29889,
1982,
29889,
13239,
29889,
1289,
29881,
29918,
13239,
1053,
10272,
29918,
1884,
29918,
29941,
29881,
29892,
2060,
29918,
517,
29918,
3027,
29892,
15595,
29906,
5450,
29918,
29891,
13,
3166,
4765,
29889,
1982,
29889,
13239,
29889,
1289,
29881,
29918,
13239,
1053,
4216,
29918,
1884,
29918,
29941,
29881,
29892,
443,
4836,
29918,
29906,
29881,
29918,
517,
29918,
29941,
29881,
13,
13,
3166,
869,
3188,
29918,
4801,
3019,
1053,
7399,
6362,
3019,
13,
13,
1990,
360,
1289,
6362,
3019,
29898,
5160,
6362,
3019,
1125,
13,
29871,
822,
4770,
2344,
12035,
1311,
29892,
3523,
1125,
13,
1678,
2428,
29898,
29928,
1289,
6362,
3019,
29892,
1583,
467,
1649,
2344,
12035,
3670,
29897,
13,
1678,
1583,
29889,
1052,
747,
353,
7442,
29889,
2378,
4197,
29961,
29955,
29900,
29955,
29889,
29900,
29946,
29929,
29941,
29892,
29871,
29900,
29892,
29871,
29953,
29900,
29946,
29889,
29900,
29947,
29896,
29946,
29892,
29871,
29946,
29945,
29889,
29955,
29945,
29947,
29941,
29896,
1402,
13,
462,
965,
518,
29900,
29892,
29871,
29955,
29900,
29955,
29889,
29900,
29946,
29929,
29941,
29892,
29871,
29896,
29947,
29900,
29889,
29945,
29900,
29953,
29953,
29892,
448,
29900,
29889,
29941,
29946,
29945,
29946,
29896,
29945,
29955,
1402,
13,
462,
965,
518,
29900,
29892,
29871,
29900,
29892,
29871,
29896,
1696,
29871,
29900,
29889,
29900,
29900,
29946,
29929,
29947,
29896,
29900,
29896,
29953,
20526,
26688,
29922,
9302,
29889,
7411,
29941,
29906,
29897,
13,
13,
13,
29871,
822,
758,
29918,
5014,
29898,
1311,
29892,
1967,
29892,
6287,
29892,
1208,
747,
29922,
8516,
1125,
13,
1678,
3171,
29892,
2920,
353,
1967,
29889,
12181,
29961,
29900,
29901,
29906,
29962,
13,
268,
13,
1678,
297,
29886,
29918,
3545,
29892,
297,
29886,
29918,
2103,
353,
1583,
29889,
3670,
29889,
2080,
29918,
29882,
29892,
1583,
29889,
3670,
29889,
2080,
29918,
29893,
13,
1678,
274,
353,
7442,
29889,
2378,
4197,
2103,
847,
29871,
29906,
29892,
3171,
847,
29871,
29906,
1402,
26688,
29922,
9302,
29889,
7411,
29941,
29906,
29897,
13,
1678,
565,
1583,
29889,
3670,
29889,
17462,
29918,
690,
29901,
13,
418,
269,
353,
7442,
29889,
2378,
4197,
262,
29886,
29918,
2103,
29892,
297,
29886,
29918,
3545,
1402,
26688,
29922,
9302,
29889,
524,
29941,
29906,
29897,
13,
1678,
1683,
29901,
13,
418,
269,
353,
7442,
29889,
2378,
4197,
2103,
29892,
3171,
1402,
26688,
29922,
9302,
29889,
524,
29941,
29906,
29897,
13,
13,
1678,
1301,
29918,
2080,
353,
679,
29918,
3470,
457,
29918,
9067,
29898,
29883,
29892,
269,
29892,
29871,
29900,
29892,
518,
262,
29886,
29918,
2103,
29892,
297,
29886,
29918,
3545,
2314,
13,
1678,
620,
1891,
29918,
3027,
353,
1967,
396,
11023,
29906,
29889,
21476,
29898,
3027,
29892,
313,
2103,
29892,
3171,
876,
13,
1678,
297,
29886,
29918,
3027,
353,
13850,
29906,
29889,
4495,
29886,
27867,
457,
29898,
13,
418,
620,
1891,
29918,
3027,
29892,
1301,
29918,
2080,
29892,
313,
262,
29886,
29918,
2103,
29892,
297,
29886,
29918,
3545,
511,
13,
418,
13449,
29922,
11023,
29906,
29889,
23845,
29918,
18521,
1718,
29897,
13,
1678,
297,
29886,
29918,
3027,
353,
313,
262,
29886,
29918,
3027,
29889,
579,
668,
29898,
9302,
29889,
7411,
29941,
29906,
29897,
847,
29871,
29906,
29945,
29945,
1846,
13,
1678,
297,
29886,
29918,
3027,
353,
313,
262,
29886,
29918,
3027,
448,
1583,
29889,
12676,
29897,
847,
1583,
29889,
4172,
13,
1678,
4558,
353,
297,
29886,
29918,
3027,
29889,
3286,
4220,
29898,
29906,
29892,
29871,
29900,
29892,
29871,
29896,
9601,
9302,
29889,
1482,
8990,
29892,
2023,
29962,
13,
1678,
1208,
747,
353,
7442,
29889,
2378,
29898,
1052,
747,
29892,
26688,
29922,
9302,
29889,
7411,
29941,
29906,
29897,
565,
1208,
747,
338,
451,
6213,
320,
13,
9651,
1683,
1583,
29889,
1052,
747,
13,
1678,
4558,
353,
4842,
305,
29889,
3166,
29918,
23749,
29898,
8346,
29897,
13,
1678,
12700,
353,
11117,
29883,
2396,
274,
29892,
525,
29879,
2396,
269,
29892,
29871,
13,
9651,
525,
449,
29918,
3545,
2396,
297,
29886,
29918,
3545,
849,
1583,
29889,
3670,
29889,
3204,
29918,
3605,
601,
29892,
29871,
13,
9651,
525,
449,
29918,
2103,
2396,
297,
29886,
29918,
2103,
849,
1583,
29889,
3670,
29889,
3204,
29918,
3605,
601,
29892,
13,
9651,
525,
1052,
747,
2396,
1208,
747,
29913,
13,
1678,
736,
4558,
29892,
12700,
13,
259,
13,
29871,
822,
1889,
29898,
1311,
29892,
4558,
29892,
736,
29918,
2230,
29922,
8824,
1125,
13,
1678,
411,
4842,
305,
29889,
1217,
29918,
5105,
7295,
13,
418,
4842,
305,
29889,
29883,
6191,
29889,
29879,
9524,
675,
580,
13,
418,
1962,
353,
1583,
29889,
4299,
29898,
8346,
9601,
29899,
29896,
29962,
13,
418,
1962,
1839,
7184,
2033,
353,
1962,
1839,
7184,
13359,
18816,
29885,
3398,
29918,
580,
13,
418,
1962,
1839,
2716,
2033,
353,
29871,
29896,
29889,
847,
313,
4905,
1839,
2716,
13359,
18816,
29885,
3398,
580,
718,
29871,
29896,
29872,
29899,
29953,
29897,
448,
29871,
29896,
29889,
13,
418,
377,
353,
1962,
1839,
1332,
2033,
565,
1583,
29889,
3670,
29889,
1727,
29918,
29890,
1884,
1683,
6213,
13,
418,
1072,
353,
1962,
1839,
1727,
2033,
565,
1583,
29889,
3670,
29889,
1727,
29918,
10289,
1683,
6213,
13,
418,
4842,
305,
29889,
29883,
6191,
29889,
29879,
9524,
675,
580,
13,
418,
6375,
29918,
2230,
353,
931,
29889,
2230,
580,
13,
539,
13,
418,
1439,
29879,
353,
270,
1289,
29918,
13808,
29898,
4905,
1839,
7184,
7464,
1962,
1839,
5450,
7464,
1962,
1839,
2716,
7464,
13,
462,
3986,
1962,
1839,
6229,
7464,
377,
29922,
1332,
29892,
1072,
29922,
1727,
29892,
476,
29922,
1311,
29889,
3670,
29889,
29968,
29897,
13,
1678,
565,
736,
29918,
2230,
29901,
13,
418,
736,
1962,
29892,
1439,
29879,
29892,
6375,
29918,
2230,
13,
1678,
1683,
29901,
13,
418,
736,
1962,
29892,
1439,
29879,
13,
13,
29871,
822,
1400,
29918,
5014,
29898,
1311,
29892,
1439,
29879,
29892,
12700,
29892,
6287,
29922,
29896,
1125,
13,
1678,
1439,
29879,
353,
1439,
29879,
29889,
4801,
496,
2141,
21970,
2141,
23749,
580,
13,
1678,
1439,
29872,
1953,
353,
270,
1289,
29918,
2490,
29918,
5014,
29898,
13,
418,
1439,
29879,
29889,
8552,
3285,
518,
7299,
1839,
29883,
2033,
1402,
518,
7299,
1839,
29879,
2033,
1402,
518,
7299,
1839,
1052,
747,
2033,
1402,
1583,
29889,
3670,
29897,
13,
1678,
1583,
29889,
1366,
29918,
1052,
747,
353,
12700,
1839,
1052,
747,
2033,
13,
1678,
736,
1439,
29872,
1953,
29961,
29900,
29962,
13,
13,
29871,
822,
10366,
29918,
4905,
29879,
29898,
1311,
29892,
1439,
29872,
1953,
1125,
13,
1678,
2582,
353,
1439,
29872,
1953,
29961,
29900,
29962,
13,
1678,
363,
432,
297,
3464,
29898,
29896,
29892,
1583,
29889,
1949,
29918,
13203,
718,
29871,
29896,
1125,
13,
418,
565,
7431,
29898,
9902,
29961,
29926,
29962,
1405,
29871,
29900,
1125,
13,
4706,
3013,
29918,
12772,
353,
313,
9902,
29961,
29926,
3816,
29901,
29892,
448,
29896,
29962,
1405,
1583,
29889,
3670,
29889,
412,
557,
29918,
386,
3781,
29897,
13,
4706,
2582,
29961,
29926,
29962,
353,
2582,
29961,
29926,
3816,
17462,
29918,
12772,
29962,
13,
1678,
736,
2582,
13,
13,
29871,
822,
4744,
29898,
1311,
29892,
18297,
29892,
4558,
29892,
1439,
29879,
29892,
1962,
29892,
6287,
29922,
29896,
1125,
13,
1678,
1439,
29879,
353,
1439,
29879,
29889,
4801,
496,
2141,
21970,
2141,
23749,
580,
13,
1678,
10153,
353,
4558,
29961,
29900,
1822,
4801,
496,
2141,
21970,
2141,
23749,
2141,
3286,
4220,
29898,
29896,
29892,
29871,
29906,
29892,
29871,
29900,
29897,
13,
1678,
10153,
353,
5135,
2492,
334,
1583,
29889,
4172,
718,
1583,
29889,
12676,
29897,
334,
29871,
29906,
29945,
29945,
467,
579,
668,
29898,
9302,
29889,
13470,
29947,
29897,
13,
1678,
4450,
353,
18297,
29889,
1885,
29918,
1054,
555,
481,
29898,
4905,
1839,
7184,
2033,
29961,
29900,
1822,
4801,
496,
2141,
21970,
2141,
23749,
3101,
13,
1678,
18297,
29889,
1202,
29918,
2204,
355,
29918,
2492,
29898,
2492,
29892,
4450,
29892,
525,
11965,
29918,
7184,
1495,
13,
1678,
18297,
29889,
1202,
29918,
312,
29918,
29881,
2650,
428,
29898,
13,
418,
10153,
29892,
1439,
29879,
29961,
29900,
1402,
1510,
29918,
1884,
29922,
1311,
29889,
3670,
29889,
1727,
29918,
29890,
1884,
29892,
29871,
13,
418,
4818,
29918,
386,
3781,
29922,
1311,
29889,
3670,
29889,
1730,
29918,
386,
3781,
29892,
10153,
29918,
333,
2433,
4801,
29918,
11965,
1495,
13,
259,
13,
29871,
822,
1510,
29918,
9902,
29898,
1311,
29892,
18297,
29892,
1967,
29892,
2582,
1125,
13,
1678,
18297,
29889,
1202,
29918,
29941,
29881,
29918,
29881,
2650,
428,
29898,
13,
418,
1967,
29892,
2582,
29892,
1583,
29889,
1366,
29918,
1052,
747,
29892,
13,
418,
4818,
29918,
386,
3781,
29922,
1311,
29889,
3670,
29889,
1730,
29918,
386,
3781,
29892,
10153,
29918,
333,
2433,
1202,
29918,
11965,
1495,
13,
1678,
18297,
29889,
1202,
29918,
18513,
29918,
1493,
29898,
13,
418,
2582,
29892,
4818,
29918,
386,
3781,
29922,
1311,
29889,
3670,
29889,
1730,
29918,
386,
3781,
29892,
10153,
29918,
333,
2433,
18513,
29918,
11965,
1495,
13,
1678,
18297,
29889,
4294,
29918,
497,
29918,
2492,
29879,
29898,
29886,
1071,
29922,
1311,
29889,
29886,
1071,
29897,
2
] |
biserici_inlemnite/biserici/migrations/0047_auto_20210804_1305.py | ck-tm/biserici-inlemnite | 0 | 184213 | <reponame>ck-tm/biserici-inlemnite<gh_stars>0
# Generated by Django 3.1.13 on 2021-08-04 10:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('biserici', '0046_auto_20210804_1253'),
]
operations = [
migrations.AddField(
model_name='componentaartistica',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='descriere',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='finisaj',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='fotografii',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='historicalcomponentaartistica',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='historicaldescriere',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='historicalfinisaj',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='historicalfotografii',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='historicalidentificare',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
migrations.AddField(
model_name='identificare',
name='missing_fields',
field=models.JSONField(blank=True, null=True),
),
]
| [
1,
529,
276,
1112,
420,
29958,
384,
29899,
18276,
29914,
29890,
7608,
1654,
29899,
262,
2409,
29876,
568,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
29937,
3251,
630,
491,
15337,
29871,
29941,
29889,
29896,
29889,
29896,
29941,
373,
29871,
29906,
29900,
29906,
29896,
29899,
29900,
29947,
29899,
29900,
29946,
29871,
29896,
29900,
29901,
29900,
29945,
13,
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,
29890,
7608,
1654,
742,
525,
29900,
29900,
29946,
29953,
29918,
6921,
29918,
29906,
29900,
29906,
29896,
29900,
29947,
29900,
29946,
29918,
29896,
29906,
29945,
29941,
5477,
13,
1678,
4514,
13,
13,
1678,
6931,
353,
518,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
9700,
29874,
442,
24504,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
2783,
699,
406,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
4951,
275,
1175,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
29888,
327,
2345,
2236,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
16211,
936,
9700,
29874,
442,
24504,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
16211,
936,
2783,
699,
406,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
16211,
936,
4951,
275,
1175,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
16211,
936,
29888,
327,
2345,
2236,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
16211,
936,
1693,
928,
598,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
4706,
9725,
800,
29889,
2528,
3073,
29898,
13,
9651,
1904,
29918,
978,
2433,
1693,
928,
598,
742,
13,
9651,
1024,
2433,
27259,
29918,
9621,
742,
13,
9651,
1746,
29922,
9794,
29889,
7249,
3073,
29898,
19465,
29922,
5574,
29892,
1870,
29922,
5574,
511,
13,
4706,
10353,
13,
1678,
4514,
13,
2
] |
hyperparameter_tuning/mxnet_gluon_cifar10_random_search/random_tuner.py | zanhsieh/amazon-sagemaker-examples | 3 | 197064 | <gh_stars>1-10
import random
import time
import boto3
import re
import pandas as pd
import numpy as np
#################
# Hyperparameters
#################
class CategoricalParameter():
'''
Class for categorical hyperparameters.
Takes one argument which is a list of possible hyperparameter values.
'''
def __init__(self, values):
self.values = values
def get_value(self):
return random.choice(self.values)
class IntegerParameter():
'''
Class for integer hyperparameters.
Takes two arguments: min_value and then max_value.
'''
def __init__(self, min_value, max_value):
self.min_value = min_value
self.max_value = max_value
def get_value(self):
return random.randint(self.min_value, self.max_value)
class ContinuousParameter():
'''
Class for continuous hyperparameters.
Takes two arguments: min_value and then max_value.
'''
def __init__(self, min_value, max_value):
self.min_value = min_value
self.max_value = max_value
def get_value(self):
return random.uniform(self.min_value, self.max_value)
###############
# Random search
###############
def _get_random_hyperparameter_values(hyperparameters):
'''
Converts a dict using hyperparameter classes to a dict of hyperparameter values.
'''
hps = {}
for hp, definition in hyperparameters.items():
if isinstance(definition, (CategoricalParameter, IntegerParameter,
ContinuousParameter)):
hps[hp] = definition.get_value()
else:
hps[hp] = definition
return hps
def random_search(train_fn,
hyperparameters,
base_name=None,
max_jobs=100,
max_parallel_jobs=100):
'''
Runs random search for hyperparameters.
Takes in:
train_fn: A function that kicks off a training job based on two positional arguments-
job name and hyperparameter dictionary. Note, wait must be set to False if using .fit()
hyperparameters: A dictonary of hyperparameters defined with hyperparameter classes.
base_name: Base name for training jobs. Defaults to 'random-hp-<timestamp>'.
max_jobs: Total number of training jobs to run.
max_parallel_jobs: Most training jobs to run concurrently. This does not affect the quality
of search, just helps stay under account service limits.
Returns a dictionary of max_jobs job names with associated hyperparameter values.
'''
if base_name is None:
base_name = 'random-hp-' + time.strftime('%Y-%m-%d-%H-%M-%S-%j', time.gmtime())
client = boto3.client('sagemaker')
jobs = {}
running_jobs = {}
for i in range(max_jobs):
job = base_name + '-' + str(i)
hps = _get_random_hyperparameter_values(hyperparameters)
jobs[job] = hps.copy()
train_fn(job, hps)
running_jobs[job] = True
while len(running_jobs) == max_parallel_jobs:
for job in running_jobs.keys():
if client.describe_training_job(TrainingJobName=job)['TrainingJobStatus'] != 'InProgress':
running_jobs.pop(job)
time.sleep(20)
return jobs
################
# Analyze output
################
def get_metrics(jobs, regex):
'''
Gets CloudWatch metrics for training jobs
Takes in:
jobs: A dictionary where training job names are keys.
regex: a regular expression string to parse the objective metric value.
Returns a dictionary of training job names as keys and corresponding list
which contains the objective metric from each log stream.
'''
job_metrics = {}
for job in jobs.keys():
client = boto3.client('logs')
streams = client.describe_log_streams(logGroupName='/aws/sagemaker/TrainingJobs',
logStreamNamePrefix=job + '/')
streams = [s['logStreamName'] for s in streams['logStreams']]
stream_metrics = []
for stream in streams:
events = client.get_log_events(logGroupName='/aws/sagemaker/TrainingJobs',
logStreamName=stream)['events']
message = [e['message'] for e in events]
metrics = []
for m in message:
try:
metrics.append(re.search(regex, m).group(1))
except:
pass
stream_metrics.extend(metrics)
job_metrics[job] = stream_metrics
return job_metrics
def table_metrics(jobs, metrics):
'''
Returns Pandas DataFrame of jobs, hyperparameter values, and objective metric value
'''
job_metrics = jobs.copy()
for job in job_metrics.keys():
objective = float(metrics[job][-1]) if len(metrics[job]) > 0 else np.nan
job_metrics[job].update({'objective': objective,
'job_number': int(job.split('-')[-1])})
return pd.DataFrame.from_dict(job_metrics, orient='index')
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
4036,
13,
5215,
931,
13,
5215,
289,
3747,
29941,
13,
5215,
337,
13,
5215,
11701,
408,
10518,
13,
5215,
12655,
408,
7442,
13,
13,
13,
13383,
29937,
13,
29937,
26078,
16744,
13,
13383,
29937,
13,
13,
13,
1990,
315,
20440,
936,
9329,
7295,
13,
1678,
14550,
13,
1678,
4134,
363,
11608,
936,
11266,
16744,
29889,
13,
1678,
323,
6926,
697,
2980,
607,
338,
263,
1051,
310,
1950,
11266,
15501,
1819,
29889,
13,
1678,
14550,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1819,
1125,
13,
4706,
1583,
29889,
5975,
353,
1819,
13,
1678,
822,
679,
29918,
1767,
29898,
1311,
1125,
13,
4706,
736,
4036,
29889,
16957,
29898,
1311,
29889,
5975,
29897,
13,
13,
13,
1990,
8102,
9329,
7295,
13,
1678,
14550,
13,
1678,
4134,
363,
6043,
11266,
16744,
29889,
13,
1678,
323,
6926,
1023,
6273,
29901,
1375,
29918,
1767,
322,
769,
4236,
29918,
1767,
29889,
13,
1678,
14550,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1375,
29918,
1767,
29892,
4236,
29918,
1767,
1125,
13,
4706,
1583,
29889,
1195,
29918,
1767,
353,
1375,
29918,
1767,
13,
4706,
1583,
29889,
3317,
29918,
1767,
353,
4236,
29918,
1767,
13,
1678,
822,
679,
29918,
1767,
29898,
1311,
1125,
13,
4706,
736,
4036,
29889,
9502,
524,
29898,
1311,
29889,
1195,
29918,
1767,
29892,
1583,
29889,
3317,
29918,
1767,
29897,
13,
13,
13,
1990,
2866,
8675,
681,
9329,
7295,
13,
1678,
14550,
13,
1678,
4134,
363,
9126,
11266,
16744,
29889,
13,
1678,
323,
6926,
1023,
6273,
29901,
1375,
29918,
1767,
322,
769,
4236,
29918,
1767,
29889,
13,
1678,
14550,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
1375,
29918,
1767,
29892,
4236,
29918,
1767,
1125,
13,
4706,
1583,
29889,
1195,
29918,
1767,
353,
1375,
29918,
1767,
13,
4706,
1583,
29889,
3317,
29918,
1767,
353,
4236,
29918,
1767,
13,
1678,
822,
679,
29918,
1767,
29898,
1311,
1125,
13,
4706,
736,
4036,
29889,
29590,
29898,
1311,
29889,
1195,
29918,
1767,
29892,
1583,
29889,
3317,
29918,
1767,
29897,
13,
13,
13,
7346,
4136,
2277,
29937,
13,
29937,
16968,
2740,
13,
7346,
4136,
2277,
29937,
13,
13,
13,
1753,
903,
657,
29918,
8172,
29918,
24947,
15501,
29918,
5975,
29898,
24947,
16744,
1125,
13,
1678,
14550,
13,
1678,
1281,
369,
1372,
263,
9657,
773,
11266,
15501,
4413,
304,
263,
9657,
310,
11266,
15501,
1819,
29889,
13,
1678,
14550,
13,
1678,
298,
567,
353,
6571,
13,
1678,
363,
298,
29886,
29892,
5023,
297,
11266,
16744,
29889,
7076,
7295,
13,
4706,
565,
338,
8758,
29898,
16553,
29892,
313,
29907,
20440,
936,
9329,
29892,
8102,
9329,
29892,
13,
462,
462,
259,
2866,
8675,
681,
9329,
22164,
13,
9651,
298,
567,
29961,
28887,
29962,
353,
5023,
29889,
657,
29918,
1767,
580,
13,
4706,
1683,
29901,
13,
9651,
298,
567,
29961,
28887,
29962,
353,
5023,
13,
1678,
736,
298,
567,
13,
13,
13,
1753,
4036,
29918,
4478,
29898,
14968,
29918,
9144,
29892,
13,
462,
29871,
11266,
16744,
29892,
13,
462,
29871,
2967,
29918,
978,
29922,
8516,
29892,
13,
462,
29871,
4236,
29918,
9057,
29879,
29922,
29896,
29900,
29900,
29892,
13,
462,
29871,
4236,
29918,
23482,
29918,
9057,
29879,
29922,
29896,
29900,
29900,
1125,
13,
1678,
14550,
13,
1678,
390,
6948,
4036,
2740,
363,
11266,
16744,
29889,
13,
1678,
323,
6926,
297,
29901,
13,
4706,
7945,
29918,
9144,
29901,
319,
740,
393,
413,
7358,
1283,
263,
6694,
4982,
2729,
373,
1023,
2602,
284,
6273,
29899,
13,
9651,
4982,
1024,
322,
11266,
15501,
8600,
29889,
29871,
3940,
29892,
4480,
1818,
367,
731,
304,
7700,
565,
773,
869,
9202,
580,
13,
4706,
11266,
16744,
29901,
319,
12124,
880,
653,
310,
11266,
16744,
3342,
411,
11266,
15501,
4413,
29889,
13,
4706,
2967,
29918,
978,
29901,
7399,
1024,
363,
6694,
17643,
29889,
29871,
13109,
29879,
304,
525,
8172,
29899,
28887,
29899,
29966,
16394,
29958,
4286,
13,
4706,
4236,
29918,
9057,
29879,
29901,
14990,
1353,
310,
6694,
17643,
304,
1065,
29889,
13,
4706,
4236,
29918,
23482,
29918,
9057,
29879,
29901,
7849,
6694,
17643,
304,
1065,
21984,
368,
29889,
910,
947,
451,
6602,
278,
11029,
13,
9651,
310,
2740,
29892,
925,
6911,
7952,
1090,
3633,
2669,
13071,
29889,
13,
1678,
16969,
263,
8600,
310,
4236,
29918,
9057,
29879,
4982,
2983,
411,
6942,
11266,
15501,
1819,
29889,
13,
1678,
14550,
13,
13,
1678,
565,
2967,
29918,
978,
338,
6213,
29901,
13,
4706,
2967,
29918,
978,
353,
525,
8172,
29899,
28887,
29899,
29915,
718,
931,
29889,
710,
615,
603,
877,
29995,
29979,
19222,
29885,
19222,
29881,
19222,
29950,
19222,
29924,
19222,
29903,
19222,
29926,
742,
931,
29889,
29887,
29885,
2230,
3101,
13,
13,
1678,
3132,
353,
289,
3747,
29941,
29889,
4645,
877,
29879,
13904,
5790,
1495,
13,
1678,
17643,
353,
6571,
13,
1678,
2734,
29918,
9057,
29879,
353,
6571,
13,
1678,
363,
474,
297,
3464,
29898,
3317,
29918,
9057,
29879,
1125,
13,
4706,
4982,
353,
2967,
29918,
978,
718,
17411,
29915,
718,
851,
29898,
29875,
29897,
13,
4706,
298,
567,
353,
903,
657,
29918,
8172,
29918,
24947,
15501,
29918,
5975,
29898,
24947,
16744,
29897,
13,
4706,
17643,
29961,
9057,
29962,
353,
298,
567,
29889,
8552,
580,
13,
4706,
7945,
29918,
9144,
29898,
9057,
29892,
298,
567,
29897,
13,
4706,
2734,
29918,
9057,
29879,
29961,
9057,
29962,
353,
5852,
13,
4706,
1550,
7431,
29898,
21094,
29918,
9057,
29879,
29897,
1275,
4236,
29918,
23482,
29918,
9057,
29879,
29901,
13,
9651,
363,
4982,
297,
2734,
29918,
9057,
29879,
29889,
8149,
7295,
13,
18884,
565,
3132,
29889,
2783,
29581,
29918,
26495,
29918,
9057,
29898,
5323,
2827,
11947,
1170,
29922,
9057,
29897,
1839,
5323,
2827,
11947,
5709,
2033,
2804,
525,
797,
14470,
2396,
13,
462,
1678,
2734,
29918,
9057,
29879,
29889,
7323,
29898,
9057,
29897,
13,
9651,
931,
29889,
17059,
29898,
29906,
29900,
29897,
13,
13,
1678,
736,
17643,
13,
13,
13,
13383,
13,
29937,
11597,
29891,
911,
1962,
13,
13383,
13,
13,
13,
1753,
679,
29918,
2527,
10817,
29898,
9057,
29879,
29892,
6528,
1125,
13,
1678,
14550,
13,
1678,
402,
1691,
14293,
24709,
21556,
363,
6694,
17643,
13,
1678,
323,
6926,
297,
29901,
13,
4706,
17643,
29901,
319,
8600,
988,
6694,
4982,
2983,
526,
6611,
29889,
13,
4706,
6528,
29901,
263,
4943,
4603,
1347,
304,
6088,
278,
12091,
12714,
995,
29889,
13,
1678,
16969,
263,
8600,
310,
6694,
4982,
2983,
408,
6611,
322,
6590,
1051,
13,
4706,
607,
3743,
278,
12091,
12714,
515,
1269,
1480,
4840,
29889,
13,
1678,
14550,
13,
1678,
4982,
29918,
2527,
10817,
353,
6571,
13,
1678,
363,
4982,
297,
17643,
29889,
8149,
7295,
13,
4706,
3132,
353,
289,
3747,
29941,
29889,
4645,
877,
20756,
1495,
13,
4706,
20873,
353,
3132,
29889,
2783,
29581,
29918,
1188,
29918,
5461,
29879,
29898,
1188,
4782,
1170,
2433,
29914,
10467,
29914,
29879,
13904,
5790,
29914,
5323,
2827,
11947,
29879,
742,
13,
462,
462,
795,
1480,
3835,
1170,
23095,
29922,
9057,
718,
8207,
1495,
13,
4706,
20873,
353,
518,
29879,
1839,
1188,
3835,
1170,
2033,
363,
269,
297,
20873,
1839,
1188,
3835,
29879,
2033,
29962,
13,
4706,
4840,
29918,
2527,
10817,
353,
5159,
13,
4706,
363,
4840,
297,
20873,
29901,
13,
9651,
4959,
353,
3132,
29889,
657,
29918,
1188,
29918,
13604,
29898,
1188,
4782,
1170,
2433,
29914,
10467,
29914,
29879,
13904,
5790,
29914,
5323,
2827,
11947,
29879,
742,
13,
462,
462,
965,
1480,
3835,
1170,
29922,
5461,
29897,
1839,
13604,
2033,
13,
9651,
2643,
353,
518,
29872,
1839,
4906,
2033,
363,
321,
297,
4959,
29962,
13,
9651,
21556,
353,
5159,
13,
9651,
363,
286,
297,
2643,
29901,
13,
18884,
1018,
29901,
13,
462,
1678,
21556,
29889,
4397,
29898,
276,
29889,
4478,
29898,
13087,
29892,
286,
467,
2972,
29898,
29896,
876,
13,
18884,
5174,
29901,
13,
462,
1678,
1209,
13,
9651,
4840,
29918,
2527,
10817,
29889,
21843,
29898,
2527,
10817,
29897,
13,
4706,
4982,
29918,
2527,
10817,
29961,
9057,
29962,
353,
4840,
29918,
2527,
10817,
13,
1678,
736,
4982,
29918,
2527,
10817,
13,
13,
13,
1753,
1591,
29918,
2527,
10817,
29898,
9057,
29879,
29892,
21556,
1125,
13,
1678,
14550,
13,
1678,
16969,
349,
7086,
3630,
4308,
310,
17643,
29892,
11266,
15501,
1819,
29892,
322,
12091,
12714,
995,
13,
1678,
14550,
13,
1678,
4982,
29918,
2527,
10817,
353,
17643,
29889,
8552,
580,
13,
1678,
363,
4982,
297,
4982,
29918,
2527,
10817,
29889,
8149,
7295,
13,
4706,
12091,
353,
5785,
29898,
2527,
10817,
29961,
9057,
3816,
29899,
29896,
2314,
565,
7431,
29898,
2527,
10817,
29961,
9057,
2314,
1405,
29871,
29900,
1683,
7442,
29889,
13707,
13,
4706,
4982,
29918,
2527,
10817,
29961,
9057,
1822,
5504,
3319,
29915,
3318,
573,
2396,
12091,
29892,
13,
462,
462,
525,
9057,
29918,
4537,
2396,
938,
29898,
9057,
29889,
5451,
877,
29899,
1495,
14352,
29896,
2314,
1800,
13,
1678,
736,
10518,
29889,
17271,
29889,
3166,
29918,
8977,
29898,
9057,
29918,
2527,
10817,
29892,
7769,
2433,
2248,
1495,
13,
2
] |
tracardi/service/wf/domain/work_flow.py | Tracardi/tracardi | 153 | 182186 | from typing import Tuple, List
from tracardi.domain.event import Event
from tracardi.domain.payload.tracker_payload import TrackerPayload
from tracardi.domain.profile import Profile
from tracardi.domain.session import Session
from .debug_info import DebugInfo
from .flow import Flow
from .flow_history import FlowHistory
from ..utils.dag_error import DagGraphError
from ..utils.dag_processor import DagProcessor
from ..utils.flow_graph_converter import FlowGraphConverter
from tracardi.service.plugin.domain.console import Log
class WorkFlow:
def __init__(self, flow_history: FlowHistory, tracker_payload: TrackerPayload = None):
self.tracker_payload = tracker_payload
self.flow_history = flow_history
async def invoke(self, flow: Flow, event: Event, profile, session, ux: list, debug=False) -> Tuple[DebugInfo, List[Log], 'Event', 'Profile', 'Session']:
"""
Invokes workflow and returns DebugInfo and list of saved Logs.
"""
if event is None:
raise DagGraphError(
"Flow `{}` has no context event defined.".format(
flow.id))
if not flow.flowGraph:
raise DagGraphError("Flow {} is empty".format(flow.id))
if self.flow_history.is_acyclic(flow.id):
# Convert Editor graph to exec graph
converter = FlowGraphConverter(flow.flowGraph.dict())
dag_graph = converter.convert_to_dag_graph()
dag = DagProcessor(dag_graph)
try:
exec_dag = dag.make_execution_dag(debug=debug)
except DagGraphError as e:
raise DagGraphError("Flow `{}` returned the following error: `{}`".format(flow.id, str(e)))
# Init and run with event
await exec_dag.init(flow,
self.flow_history,
event,
session,
profile,
self.tracker_payload,
ux)
debug_info, log_list, profile, session = await exec_dag.run(
payload={},
flow=flow,
event=event,
profile=profile,
session=session
)
await exec_dag.close()
return debug_info, log_list, event, profile, session
raise RuntimeError("Workflow has circular reference.")
| [
1,
515,
19229,
1053,
12603,
552,
29892,
2391,
13,
13,
3166,
16703,
18015,
29889,
7247,
29889,
3696,
1053,
6864,
13,
3166,
16703,
18015,
29889,
7247,
29889,
23813,
29889,
3018,
4937,
29918,
23813,
1053,
3201,
4937,
15467,
1359,
13,
3166,
16703,
18015,
29889,
7247,
29889,
10185,
1053,
20802,
13,
3166,
16703,
18015,
29889,
7247,
29889,
7924,
1053,
16441,
13,
3166,
869,
8382,
29918,
3888,
1053,
16171,
3401,
13,
3166,
869,
1731,
1053,
22787,
13,
3166,
869,
1731,
29918,
18434,
1053,
22787,
20570,
13,
3166,
6317,
13239,
29889,
24157,
29918,
2704,
1053,
360,
351,
9527,
2392,
13,
3166,
6317,
13239,
29889,
24157,
29918,
26482,
1053,
360,
351,
18689,
13,
3166,
6317,
13239,
29889,
1731,
29918,
4262,
29918,
535,
13549,
1053,
22787,
9527,
18545,
13,
3166,
16703,
18015,
29889,
5509,
29889,
8582,
29889,
7247,
29889,
11058,
1053,
4522,
13,
13,
13,
1990,
5244,
17907,
29901,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
4972,
29918,
18434,
29901,
22787,
20570,
29892,
1020,
4937,
29918,
23813,
29901,
3201,
4937,
15467,
1359,
353,
6213,
1125,
13,
4706,
1583,
29889,
3018,
4937,
29918,
23813,
353,
1020,
4937,
29918,
23813,
13,
4706,
1583,
29889,
1731,
29918,
18434,
353,
4972,
29918,
18434,
13,
13,
1678,
7465,
822,
15928,
29898,
1311,
29892,
4972,
29901,
22787,
29892,
1741,
29901,
6864,
29892,
8722,
29892,
4867,
29892,
318,
29916,
29901,
1051,
29892,
4744,
29922,
8824,
29897,
1599,
12603,
552,
29961,
11862,
3401,
29892,
2391,
29961,
3403,
1402,
525,
2624,
742,
525,
13909,
742,
525,
7317,
2033,
29901,
13,
13,
4706,
9995,
13,
4706,
15518,
23195,
27321,
322,
3639,
16171,
3401,
322,
1051,
310,
7160,
4522,
29879,
29889,
13,
4706,
9995,
13,
13,
4706,
565,
1741,
338,
6213,
29901,
13,
9651,
12020,
360,
351,
9527,
2392,
29898,
13,
18884,
376,
17907,
421,
8875,
29952,
756,
694,
3030,
1741,
3342,
1213,
29889,
4830,
29898,
13,
462,
1678,
4972,
29889,
333,
876,
13,
13,
4706,
565,
451,
4972,
29889,
1731,
9527,
29901,
13,
9651,
12020,
360,
351,
9527,
2392,
703,
17907,
6571,
338,
4069,
1642,
4830,
29898,
1731,
29889,
333,
876,
13,
13,
4706,
565,
1583,
29889,
1731,
29918,
18434,
29889,
275,
29918,
4135,
28746,
29898,
1731,
29889,
333,
1125,
13,
13,
9651,
396,
14806,
14059,
3983,
304,
2279,
3983,
13,
9651,
29105,
353,
22787,
9527,
18545,
29898,
1731,
29889,
1731,
9527,
29889,
8977,
3101,
13,
9651,
12136,
29918,
4262,
353,
29105,
29889,
13441,
29918,
517,
29918,
24157,
29918,
4262,
580,
13,
9651,
12136,
353,
360,
351,
18689,
29898,
24157,
29918,
4262,
29897,
13,
13,
9651,
1018,
29901,
13,
18884,
2279,
29918,
24157,
353,
12136,
29889,
5675,
29918,
22256,
29918,
24157,
29898,
8382,
29922,
8382,
29897,
13,
9651,
5174,
360,
351,
9527,
2392,
408,
321,
29901,
13,
18884,
12020,
360,
351,
9527,
2392,
703,
17907,
421,
8875,
29952,
4133,
278,
1494,
1059,
29901,
421,
8875,
29952,
1642,
4830,
29898,
1731,
29889,
333,
29892,
851,
29898,
29872,
4961,
13,
13,
9651,
396,
10886,
322,
1065,
411,
1741,
13,
9651,
7272,
2279,
29918,
24157,
29889,
2344,
29898,
1731,
29892,
13,
462,
18884,
1583,
29889,
1731,
29918,
18434,
29892,
13,
462,
18884,
1741,
29892,
13,
462,
18884,
4867,
29892,
13,
462,
18884,
8722,
29892,
13,
462,
18884,
1583,
29889,
3018,
4937,
29918,
23813,
29892,
13,
462,
18884,
318,
29916,
29897,
13,
13,
9651,
4744,
29918,
3888,
29892,
1480,
29918,
1761,
29892,
8722,
29892,
4867,
353,
7272,
2279,
29918,
24157,
29889,
3389,
29898,
13,
18884,
20092,
3790,
1118,
13,
18884,
4972,
29922,
1731,
29892,
13,
18884,
1741,
29922,
3696,
29892,
13,
18884,
8722,
29922,
10185,
29892,
13,
18884,
4867,
29922,
7924,
13,
9651,
1723,
13,
13,
9651,
7272,
2279,
29918,
24157,
29889,
5358,
580,
13,
13,
9651,
736,
4744,
29918,
3888,
29892,
1480,
29918,
1761,
29892,
1741,
29892,
8722,
29892,
4867,
13,
13,
4706,
12020,
24875,
2392,
703,
5531,
1731,
756,
19308,
3407,
23157,
13,
2
] |
imgapp/management/commands/create_token.py | Thakursim/dodjapp | 0 | 126334 | <reponame>Thakursim/dodjapp<filename>imgapp/management/commands/create_token.py
import getpass
from django.core.management import BaseCommand
from django.contrib.auth.models import User
from django.db import IntegrityError
from rest_framework.authtoken.models import Token
#The class must be named Command, and subclass BaseCommand
class Command(BaseCommand):
# Show this when the user types help
help = "Command to create user and get token in response"
# A command must define handle()
def handle(self, *args, **options):
success = True
while success:
try:
username = str(raw_input('Username: '))
password = getpass.getpass('Password: ')
user = User.objects.create(username=username, password=password)
api_key=Token.objects.create(user=user)
success = False
print "User Created Successfully with this token -> %s" % api_key.key
except IntegrityError as e:
if 'UNIQUE constraint failed: auth_user.username' in e.message:
print "Username already exists, Please try again with different username"
else:
print (e)
except Exception as e:
print(e) | [
1,
529,
276,
1112,
420,
29958,
1349,
557,
1295,
326,
29914,
29881,
397,
29926,
932,
29966,
9507,
29958,
2492,
932,
29914,
21895,
29914,
26381,
29914,
3258,
29918,
6979,
29889,
2272,
13,
5215,
679,
3364,
13,
13,
3166,
9557,
29889,
3221,
29889,
21895,
1053,
7399,
6255,
13,
3166,
9557,
29889,
21570,
29889,
5150,
29889,
9794,
1053,
4911,
13,
3166,
9557,
29889,
2585,
1053,
17100,
537,
2392,
13,
13,
3166,
1791,
29918,
4468,
29889,
1300,
400,
4476,
29889,
9794,
1053,
25159,
13,
13,
29937,
1576,
770,
1818,
367,
4257,
10516,
29892,
322,
19481,
7399,
6255,
13,
1990,
10516,
29898,
5160,
6255,
1125,
13,
12,
29937,
7704,
445,
746,
278,
1404,
4072,
1371,
13,
12,
8477,
353,
376,
6255,
304,
1653,
1404,
322,
679,
5993,
297,
2933,
29908,
13,
13,
12,
29937,
319,
1899,
1818,
4529,
4386,
580,
13,
12,
1753,
4386,
29898,
1311,
29892,
334,
5085,
29892,
3579,
6768,
1125,
13,
12,
12,
8698,
353,
5852,
13,
12,
12,
8000,
2551,
29901,
13,
12,
12,
12,
2202,
29901,
13,
12,
12,
12,
12,
6786,
353,
851,
29898,
1610,
29918,
2080,
877,
20249,
29901,
525,
876,
13,
12,
12,
12,
12,
5630,
353,
679,
3364,
29889,
657,
3364,
877,
10048,
29901,
25710,
13,
12,
12,
12,
12,
1792,
353,
4911,
29889,
12650,
29889,
3258,
29898,
6786,
29922,
6786,
29892,
4800,
29922,
5630,
29897,
13,
12,
12,
12,
12,
2754,
29918,
1989,
29922,
6066,
29889,
12650,
29889,
3258,
29898,
1792,
29922,
1792,
29897,
13,
12,
12,
12,
12,
8698,
353,
7700,
13,
12,
12,
12,
12,
2158,
376,
2659,
6760,
630,
21397,
3730,
411,
445,
5993,
1599,
1273,
29879,
29908,
1273,
7882,
29918,
1989,
29889,
1989,
13,
12,
12,
12,
19499,
17100,
537,
2392,
408,
321,
29901,
13,
12,
12,
12,
12,
361,
525,
3904,
29902,
11144,
7276,
5229,
29901,
4817,
29918,
1792,
29889,
6786,
29915,
297,
321,
29889,
4906,
29901,
13,
12,
12,
12,
12,
12,
2158,
376,
20249,
2307,
4864,
29892,
3529,
1018,
1449,
411,
1422,
8952,
29908,
13,
12,
12,
12,
12,
2870,
29901,
13,
12,
12,
12,
12,
12,
2158,
313,
29872,
29897,
13,
12,
12,
12,
19499,
8960,
408,
321,
29901,
13,
12,
12,
12,
12,
2158,
29898,
29872,
29897,
2
] |
examples/trivial_post_input.py | ajCameron/mewbot | 0 | 183169 | #!/usr/bin/env python3
"""
Implementing a new Input - as it happens to be the first input,
a few other things are going to have to go on
- like defining some behaviors
- and actually building a bot
- and fixing any weird type errors
"""
from __future__ import annotations
from typing import Set, Type, Dict, Any
from mewbot.bot import Bot
from mewbot.behaviour import Behaviour
from mewbot.core import InputEvent, OutputEvent
from mewbot.api.v1 import Trigger, Condition, Action
from mewbot.http_post import PostInput, PostIOConfig, PostInputEvent
class TrivialTrigger(Trigger):
"""
Nothing fancy - just fires whenever there is an PostInputEvent.
Will be used in the PrintBehavior.
"""
@staticmethod
def consumes_inputs() -> Set[Type[InputEvent]]:
return {
PostInputEvent,
}
def matches(self, event: InputEvent) -> bool:
return True
class TrivialCondition(Condition):
"""
Allows every input
"""
@staticmethod
def consumes_inputs() -> Set[Type[InputEvent]]:
return {
PostInputEvent,
}
def allows(self, event: InputEvent) -> bool:
return True
class PrintAction(Action):
"""
Print every InputEvent.
"""
@staticmethod
def consumes_inputs() -> Set[Type[InputEvent]]:
return {
PostInputEvent,
}
@staticmethod
def produces_outputs() -> Set[Type[OutputEvent]]:
return set()
async def act(self, event: InputEvent, state: Dict[str, Any]) -> None:
print(event)
if __name__ == "__main__":
# - Behavior
# Construct the print_behavior - which just prints every input event
print_behavior = Behaviour()
# Triggers on all PostInput events
print_behavior.add(TrivialTrigger())
# Passes all incoming events
print_behavior.add(TrivialCondition())
# Prints all the events which make their way into the bot
print_behavior.add(PrintAction())
# - IOConfig
post_ioconfig = PostIOConfig()
post_ioconfig.inputs.append(PostInput())
test_bot = Bot()
test_bot.name = "TrivialWebhookExample"
test_bot.add_io_config(post_ioconfig)
test_bot.add_behaviour(print_behavior)
test_bot.run()
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
29941,
13,
13,
15945,
29908,
13,
1888,
2037,
292,
263,
716,
10567,
448,
408,
372,
5930,
304,
367,
278,
937,
1881,
29892,
13,
29874,
2846,
916,
2712,
526,
2675,
304,
505,
304,
748,
373,
13,
13,
29899,
763,
16184,
777,
4010,
18930,
13,
29899,
322,
2869,
5214,
263,
9225,
13,
29899,
322,
27826,
738,
13543,
1134,
4436,
13,
15945,
29908,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
25495,
13,
13,
3166,
19229,
1053,
3789,
29892,
5167,
29892,
360,
919,
29892,
3139,
13,
13,
3166,
592,
29893,
7451,
29889,
7451,
1053,
11273,
13,
3166,
592,
29893,
7451,
29889,
915,
8708,
8975,
1053,
1522,
8708,
8975,
13,
3166,
592,
29893,
7451,
29889,
3221,
1053,
10567,
2624,
29892,
10604,
2624,
13,
3166,
592,
29893,
7451,
29889,
2754,
29889,
29894,
29896,
1053,
1605,
3567,
29892,
11790,
654,
29892,
9123,
13,
13,
3166,
592,
29893,
7451,
29889,
1124,
29918,
2490,
1053,
4918,
4290,
29892,
4918,
5971,
3991,
29892,
4918,
4290,
2624,
13,
13,
13,
1990,
323,
9473,
20211,
29898,
20211,
1125,
13,
1678,
9995,
13,
1678,
9531,
19231,
448,
925,
24237,
10940,
727,
338,
385,
4918,
4290,
2624,
29889,
13,
1678,
2811,
367,
1304,
297,
278,
13905,
28100,
29889,
13,
1678,
9995,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
1136,
9351,
29918,
2080,
29879,
580,
1599,
3789,
29961,
1542,
29961,
4290,
2624,
5262,
29901,
13,
4706,
736,
426,
13,
9651,
4918,
4290,
2624,
29892,
13,
4706,
500,
13,
13,
1678,
822,
7087,
29898,
1311,
29892,
1741,
29901,
10567,
2624,
29897,
1599,
6120,
29901,
13,
4706,
736,
5852,
13,
13,
13,
1990,
323,
9473,
25255,
29898,
25255,
1125,
13,
1678,
9995,
13,
1678,
2178,
1242,
1432,
1881,
13,
1678,
9995,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
1136,
9351,
29918,
2080,
29879,
580,
1599,
3789,
29961,
1542,
29961,
4290,
2624,
5262,
29901,
13,
4706,
736,
426,
13,
9651,
4918,
4290,
2624,
29892,
13,
4706,
500,
13,
13,
1678,
822,
6511,
29898,
1311,
29892,
1741,
29901,
10567,
2624,
29897,
1599,
6120,
29901,
13,
4706,
736,
5852,
13,
13,
13,
1990,
13905,
4276,
29898,
4276,
1125,
13,
1678,
9995,
13,
1678,
13905,
1432,
10567,
2624,
29889,
13,
1678,
9995,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
1136,
9351,
29918,
2080,
29879,
580,
1599,
3789,
29961,
1542,
29961,
4290,
2624,
5262,
29901,
13,
4706,
736,
426,
13,
9651,
4918,
4290,
2624,
29892,
13,
4706,
500,
13,
13,
1678,
732,
7959,
5696,
13,
1678,
822,
13880,
29918,
4905,
29879,
580,
1599,
3789,
29961,
1542,
29961,
6466,
2624,
5262,
29901,
13,
4706,
736,
731,
580,
13,
13,
1678,
7465,
822,
1044,
29898,
1311,
29892,
1741,
29901,
10567,
2624,
29892,
2106,
29901,
360,
919,
29961,
710,
29892,
3139,
2314,
1599,
6213,
29901,
13,
4706,
1596,
29898,
3696,
29897,
13,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
13,
1678,
396,
448,
1522,
16300,
13,
1678,
396,
1281,
4984,
278,
1596,
29918,
915,
16300,
448,
607,
925,
14677,
1432,
1881,
1741,
13,
1678,
1596,
29918,
915,
16300,
353,
1522,
8708,
8975,
580,
13,
1678,
396,
1605,
335,
5743,
373,
599,
4918,
4290,
4959,
13,
1678,
1596,
29918,
915,
16300,
29889,
1202,
29898,
29911,
9473,
20211,
3101,
13,
1678,
396,
6978,
267,
599,
23235,
4959,
13,
1678,
1596,
29918,
915,
16300,
29889,
1202,
29898,
29911,
9473,
25255,
3101,
13,
1678,
396,
1588,
9466,
599,
278,
4959,
607,
1207,
1009,
982,
964,
278,
9225,
13,
1678,
1596,
29918,
915,
16300,
29889,
1202,
29898,
11816,
4276,
3101,
13,
13,
1678,
396,
448,
10663,
3991,
13,
1678,
1400,
29918,
601,
2917,
353,
4918,
5971,
3991,
580,
13,
1678,
1400,
29918,
601,
2917,
29889,
2080,
29879,
29889,
4397,
29898,
6747,
4290,
3101,
13,
13,
1678,
1243,
29918,
7451,
353,
11273,
580,
13,
1678,
1243,
29918,
7451,
29889,
978,
353,
376,
29911,
9473,
3609,
20849,
14023,
29908,
13,
1678,
1243,
29918,
7451,
29889,
1202,
29918,
601,
29918,
2917,
29898,
2490,
29918,
601,
2917,
29897,
13,
1678,
1243,
29918,
7451,
29889,
1202,
29918,
915,
8708,
8975,
29898,
2158,
29918,
915,
16300,
29897,
13,
1678,
1243,
29918,
7451,
29889,
3389,
580,
13,
2
] |
face.py | justinham/rasp | 0 | 48965 | <reponame>justinham/rasp<filename>face.py
import os
import glob
import numpy as np
import cv2
import tensorflow as tf
from fr_utils import *
from inception_blocks_v2 import *
from keras import backend as K
from easyfacenet.simple import facenet
def triplet_loss(y_true, y_pred, alpha = 0.3):
anchor, positive, negative = y_pred[0], y_pred[1], y_pred[2]
pos_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, positive)), axis=-1)
neg_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, negative)), axis=-1)
basic_loss = tf.add(tf.subtract(pos_dist, neg_dist), alpha)
loss = tf.reduce_sum(tf.maximum(basic_loss, 0.0))
return loss
def prepare_database():
database = {}
for file in glob.glob("images/*"):
identity = os.path.splitext(os.path.basename(file))[0]
database[identity] = img_path_to_encoding(file, FRmodel)
return database
def who_is_it(image, database, model):
encoding = img_to_encoding(image, model)
min_dist = 100
identity = None
# Loop over the database dictionary's names and encodings.
for (name, db_enc) in database.items():
dist = np.linalg.norm(db_enc - encoding)
print('distance for %s is %s' %(name, dist))
if dist < min_dist:
min_dist = dist
identity = name
if min_dist > 0.52:
return None
else:
return identity
K.set_image_data_format('channels_first')
FRmodel = faceRecoModel(input_shape=(3, 96, 96))
FRmodel.compile(optimizer = 'adam', loss = triplet_loss, metrics = ['accuracy'])
load_weights_from_FaceNet(FRmodel)
images = ['images/image1.jpg', 'images/image2.jpg', 'images/image3.jpg']
aligned = facenet.align_face(images)
embeddings = facenet.embedding(aligned)
comparisons = facenet.compare(aligned)
print("Is image 1 and 2 similar? ", bool(comparisons[0][1])) | [
1,
529,
276,
1112,
420,
29958,
5143,
262,
3391,
29914,
3417,
29886,
29966,
9507,
29958,
2161,
29889,
2272,
13,
5215,
2897,
13,
5215,
13149,
13,
5215,
12655,
408,
7442,
13,
5215,
13850,
29906,
13,
5215,
26110,
408,
15886,
13,
3166,
1424,
29918,
13239,
1053,
334,
13,
3166,
297,
1441,
29918,
1271,
29879,
29918,
29894,
29906,
1053,
334,
13,
3166,
13023,
294,
1053,
14998,
408,
476,
13,
3166,
4780,
17470,
264,
300,
29889,
12857,
1053,
4024,
264,
300,
13,
13,
13,
13,
1753,
21954,
29873,
29918,
6758,
29898,
29891,
29918,
3009,
29892,
343,
29918,
11965,
29892,
15595,
353,
29871,
29900,
29889,
29941,
1125,
13,
12,
25367,
29892,
6374,
29892,
8178,
353,
343,
29918,
11965,
29961,
29900,
1402,
343,
29918,
11965,
29961,
29896,
1402,
343,
29918,
11965,
29961,
29906,
29962,
13,
13,
12,
1066,
29918,
5721,
353,
15886,
29889,
17469,
29918,
2083,
29898,
13264,
29889,
17619,
29898,
13264,
29889,
1491,
29873,
1461,
29898,
25367,
29892,
6374,
8243,
9685,
10457,
29896,
29897,
13,
12,
10052,
29918,
5721,
353,
15886,
29889,
17469,
29918,
2083,
29898,
13264,
29889,
17619,
29898,
13264,
29889,
1491,
29873,
1461,
29898,
25367,
29892,
8178,
8243,
9685,
10457,
29896,
29897,
13,
12,
16121,
29918,
6758,
353,
15886,
29889,
1202,
29898,
13264,
29889,
1491,
29873,
1461,
29898,
1066,
29918,
5721,
29892,
3480,
29918,
5721,
511,
15595,
29897,
13,
12,
6758,
353,
15886,
29889,
17469,
29918,
2083,
29898,
13264,
29889,
27525,
398,
29898,
16121,
29918,
6758,
29892,
29871,
29900,
29889,
29900,
876,
13,
13,
12,
2457,
6410,
13,
13,
13,
13,
1753,
19012,
29918,
9803,
7295,
13,
12,
9803,
353,
6571,
13,
13,
12,
1454,
934,
297,
13149,
29889,
23705,
703,
8346,
5515,
29908,
1125,
13,
12,
12,
22350,
353,
2897,
29889,
2084,
29889,
23579,
568,
486,
29898,
359,
29889,
2084,
29889,
6500,
3871,
29898,
1445,
876,
29961,
29900,
29962,
13,
12,
12,
9803,
29961,
22350,
29962,
353,
10153,
29918,
2084,
29918,
517,
29918,
22331,
29898,
1445,
29892,
23788,
4299,
29897,
13,
13,
12,
2457,
2566,
13,
13,
13,
13,
1753,
1058,
29918,
275,
29918,
277,
29898,
3027,
29892,
2566,
29892,
1904,
1125,
13,
12,
22331,
353,
10153,
29918,
517,
29918,
22331,
29898,
3027,
29892,
1904,
29897,
13,
12,
13,
12,
1195,
29918,
5721,
353,
29871,
29896,
29900,
29900,
13,
12,
22350,
353,
6213,
13,
12,
13,
12,
29937,
21493,
975,
278,
2566,
8600,
29915,
29879,
2983,
322,
2094,
397,
886,
29889,
13,
12,
1454,
313,
978,
29892,
4833,
29918,
3977,
29897,
297,
2566,
29889,
7076,
7295,
13,
12,
12,
5721,
353,
7442,
29889,
29880,
979,
29887,
29889,
12324,
29898,
2585,
29918,
3977,
448,
8025,
29897,
13,
12,
12,
2158,
877,
19244,
363,
1273,
29879,
338,
1273,
29879,
29915,
1273,
29898,
978,
29892,
1320,
876,
13,
12,
12,
361,
1320,
529,
1375,
29918,
5721,
29901,
13,
12,
12,
12,
1195,
29918,
5721,
353,
1320,
13,
12,
12,
12,
22350,
353,
1024,
13,
12,
13,
12,
361,
1375,
29918,
5721,
1405,
29871,
29900,
29889,
29945,
29906,
29901,
13,
12,
12,
2457,
6213,
13,
12,
2870,
29901,
13,
12,
12,
2457,
10110,
13,
13,
13,
13,
29968,
29889,
842,
29918,
3027,
29918,
1272,
29918,
4830,
877,
305,
12629,
29918,
4102,
1495,
13,
15860,
4299,
353,
3700,
4789,
29877,
3195,
29898,
2080,
29918,
12181,
7607,
29941,
29892,
29871,
29929,
29953,
29892,
29871,
29929,
29953,
876,
13,
13,
15860,
4299,
29889,
12198,
29898,
20640,
3950,
353,
525,
328,
314,
742,
6410,
353,
21954,
29873,
29918,
6758,
29892,
21556,
353,
6024,
562,
2764,
4135,
11287,
13,
1359,
29918,
705,
5861,
29918,
3166,
29918,
23360,
6779,
29898,
15860,
4299,
29897,
13,
13,
8346,
353,
6024,
8346,
29914,
3027,
29896,
29889,
6173,
742,
525,
8346,
29914,
3027,
29906,
29889,
6173,
742,
525,
8346,
29914,
3027,
29941,
29889,
6173,
2033,
13,
13671,
353,
4024,
264,
300,
29889,
2520,
29918,
2161,
29898,
8346,
29897,
13,
17987,
29881,
886,
353,
4024,
264,
300,
29889,
17987,
8497,
29898,
13671,
29897,
13,
510,
862,
14125,
353,
4024,
264,
300,
29889,
18307,
29898,
13671,
29897,
13,
2158,
703,
3624,
1967,
29871,
29896,
322,
29871,
29906,
2788,
29973,
9162,
6120,
29898,
510,
862,
14125,
29961,
29900,
3816,
29896,
12622,
2
] |
Python_Projects/numeric/lossofsignificance.py | arifBurakDemiray/TheCodesThatIWrote | 1 | 18869 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 13 13:35:33 2020
"""
#for finding loss of significances
x=1e-1
flag = True
a=0
while (flag):
print (((2*x)/(1-(x**2))),"......",(1/(1+x))-(1/(1-x)))
x= x*(1e-1)
a=a+1
if(a==25):
flag=False
| [
1,
396,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
15945,
29908,
13,
20399,
373,
2598,
319,
558,
29871,
29896,
29941,
29871,
29896,
29941,
29901,
29941,
29945,
29901,
29941,
29941,
29871,
29906,
29900,
29906,
29900,
13,
13,
13,
15945,
29908,
13,
13,
29937,
1454,
9138,
6410,
310,
4991,
2925,
13,
29916,
29922,
29896,
29872,
29899,
29896,
13,
15581,
353,
5852,
13,
29874,
29922,
29900,
13,
8000,
313,
15581,
1125,
13,
1678,
1596,
313,
3552,
29906,
29930,
29916,
6802,
29898,
29896,
17722,
29916,
1068,
29906,
876,
511,
29908,
3045,
636,
613,
29898,
29896,
14571,
29896,
29974,
29916,
876,
17722,
29896,
14571,
29896,
29899,
29916,
4961,
13,
1678,
921,
29922,
921,
16395,
29896,
29872,
29899,
29896,
29897,
13,
1678,
263,
29922,
29874,
29974,
29896,
13,
1678,
565,
29898,
29874,
1360,
29906,
29945,
1125,
13,
4706,
7353,
29922,
8824,
13,
2
] |
09-mock-challenge/my_library/module.py | haneyr/pytest-examples | 0 | 124652 | import pandas as pd
def is_sum_of_series_big(series):
# Lets check if this dataframe has over a thousand rows
if series.sum() > 1000:
return True
else:
return False
if __name__ == "__main__":
s1 = pd.Series([1000, 1000])
print(s1)
print(is_sum_of_series_big(s1))
s2 = pd.Series([1, 1])
print(s2)
print(is_sum_of_series_big(s2))
| [
1,
1053,
11701,
408,
10518,
13,
13,
1753,
338,
29918,
2083,
29918,
974,
29918,
13757,
29918,
3752,
29898,
13757,
1125,
13,
1678,
396,
365,
1691,
1423,
565,
445,
12205,
756,
975,
263,
10405,
4206,
13,
1678,
565,
3652,
29889,
2083,
580,
1405,
29871,
29896,
29900,
29900,
29900,
29901,
13,
4706,
736,
5852,
13,
1678,
1683,
29901,
13,
4706,
736,
7700,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
269,
29896,
353,
10518,
29889,
19204,
4197,
29896,
29900,
29900,
29900,
29892,
29871,
29896,
29900,
29900,
29900,
2314,
13,
1678,
1596,
29898,
29879,
29896,
29897,
13,
1678,
1596,
29898,
275,
29918,
2083,
29918,
974,
29918,
13757,
29918,
3752,
29898,
29879,
29896,
876,
13,
13,
1678,
269,
29906,
353,
10518,
29889,
19204,
4197,
29896,
29892,
29871,
29896,
2314,
13,
1678,
1596,
29898,
29879,
29906,
29897,
13,
1678,
1596,
29898,
275,
29918,
2083,
29918,
974,
29918,
13757,
29918,
3752,
29898,
29879,
29906,
876,
13,
2
] |
synmock/sphere.py | bengranett/synmock | 1 | 167923 | <filename>synmock/sphere.py<gh_stars>1-10
import numpy as np
import healpy
ic = 180/np.pi
def xyz2lonlat(x,y,z,norm=True,getr=False):
""" """
if norm:
r = np.sqrt(x*x+y*y+z*z)
else:
r = np.ones(x.shape)
ii = r > 0
lat = np.zeros(len(r), dtype=float)
lon = np.zeros(len(r), dtype=float)
lat[ii] = np.arcsin(z[ii]/r[ii])*ic
lon[ii] = np.arctan2(y[ii],x[ii])*ic
lon = lon%360
if getr:
return lon,lat,r
return lon,lat
def expand_mask(mask, fwhm=1, threshold=0.1):
""" """
mask_sm = healpy.smoothing(mask, fwhm=fwhm*np.pi/180)
mask_out = mask * 0
sel = mask_sm > threshold
mask_out[sel] = 1
return mask_out | [
1,
529,
9507,
29958,
19274,
17640,
29914,
29879,
9085,
29889,
2272,
29966,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
5215,
12655,
408,
7442,
13,
5215,
540,
284,
2272,
13,
13,
293,
353,
29871,
29896,
29947,
29900,
29914,
9302,
29889,
1631,
13,
13,
13,
1753,
921,
12339,
29906,
12957,
5066,
29898,
29916,
29892,
29891,
29892,
29920,
29892,
12324,
29922,
5574,
29892,
657,
29878,
29922,
8824,
1125,
13,
1678,
9995,
9995,
13,
1678,
565,
6056,
29901,
13,
4706,
364,
353,
7442,
29889,
3676,
29898,
29916,
29930,
29916,
29974,
29891,
29930,
29891,
29974,
29920,
29930,
29920,
29897,
13,
1678,
1683,
29901,
13,
4706,
364,
353,
7442,
29889,
2873,
29898,
29916,
29889,
12181,
29897,
13,
1678,
13607,
353,
364,
1405,
29871,
29900,
13,
13,
1678,
3405,
353,
7442,
29889,
3298,
359,
29898,
2435,
29898,
29878,
511,
26688,
29922,
7411,
29897,
13,
1678,
23123,
353,
7442,
29889,
3298,
359,
29898,
2435,
29898,
29878,
511,
26688,
29922,
7411,
29897,
13,
13,
1678,
3405,
29961,
2236,
29962,
353,
7442,
29889,
279,
2395,
262,
29898,
29920,
29961,
2236,
16261,
29878,
29961,
2236,
2314,
29930,
293,
13,
1678,
23123,
29961,
2236,
29962,
353,
7442,
29889,
27014,
273,
29906,
29898,
29891,
29961,
2236,
1402,
29916,
29961,
2236,
2314,
29930,
293,
13,
13,
1678,
23123,
353,
23123,
29995,
29941,
29953,
29900,
13,
13,
1678,
565,
679,
29878,
29901,
13,
4706,
736,
23123,
29892,
5066,
29892,
29878,
13,
1678,
736,
23123,
29892,
5066,
13,
13,
13,
1753,
7985,
29918,
13168,
29898,
13168,
29892,
285,
1332,
29885,
29922,
29896,
29892,
16897,
29922,
29900,
29889,
29896,
1125,
13,
1678,
9995,
9995,
13,
1678,
11105,
29918,
3844,
353,
540,
284,
2272,
29889,
3844,
29877,
6046,
29898,
13168,
29892,
285,
1332,
29885,
29922,
29888,
1332,
29885,
29930,
9302,
29889,
1631,
29914,
29896,
29947,
29900,
29897,
13,
1678,
11105,
29918,
449,
353,
11105,
334,
29871,
29900,
13,
1678,
5535,
353,
11105,
29918,
3844,
1405,
16897,
13,
1678,
11105,
29918,
449,
29961,
2838,
29962,
353,
29871,
29896,
13,
1678,
736,
11105,
29918,
449,
2
] |
api/subscription_api/serializers.py | vmariiechko/sport-club | 0 | 103890 | <reponame>vmariiechko/sport-club<filename>api/subscription_api/serializers.py
from django.utils import timezone
from rest_framework import serializers
from ..accounts_api.models import Member
from ..cards_api.models import Pass
from .models import Subscription
class SubscriptionSerializer(serializers.ModelSerializer):
member = serializers.SlugRelatedField(queryset=Member.objects.all(), slug_field='email')
card = serializers.SlugRelatedField(queryset=Pass.objects.all(), slug_field='name')
class Meta:
model = Subscription
fields = ('member', 'card', 'visits_count', 'purchased', 'expires')
extra_kwargs = {
'visits_count': {'read_only': True},
'purchased': {'read_only': True},
'expires': {'read_only': True}
}
def validate_member(self, value):
if Subscription.objects.filter(member=value, expires__gt=timezone.now(), visits_count__gt=0).exists():
raise serializers.ValidationError("You already have an active subscription")
return value
def create(self, validated_data):
instance = super().create(validated_data)
instance.visits_count = validated_data['card'].visits_count
instance.save()
return instance
| [
1,
529,
276,
1112,
420,
29958,
6925,
1306,
22149,
2901,
29914,
29879,
637,
29899,
29066,
29966,
9507,
29958,
2754,
29914,
1491,
22371,
29918,
2754,
29914,
15550,
19427,
29889,
2272,
13,
3166,
9557,
29889,
13239,
1053,
29431,
13,
3166,
1791,
29918,
4468,
1053,
7797,
19427,
13,
13,
3166,
6317,
10149,
29879,
29918,
2754,
29889,
9794,
1053,
19495,
13,
3166,
6317,
28160,
29918,
2754,
29889,
9794,
1053,
6978,
13,
3166,
869,
9794,
1053,
3323,
22371,
13,
13,
13,
1990,
3323,
22371,
17679,
29898,
15550,
19427,
29889,
3195,
17679,
1125,
13,
13,
1678,
4509,
353,
7797,
19427,
29889,
16973,
688,
9662,
630,
3073,
29898,
1972,
842,
29922,
13404,
29889,
12650,
29889,
497,
3285,
2243,
688,
29918,
2671,
2433,
5269,
1495,
13,
1678,
5881,
353,
7797,
19427,
29889,
16973,
688,
9662,
630,
3073,
29898,
1972,
842,
29922,
7129,
29889,
12650,
29889,
497,
3285,
2243,
688,
29918,
2671,
2433,
978,
1495,
13,
13,
1678,
770,
20553,
29901,
13,
4706,
1904,
353,
3323,
22371,
13,
4706,
4235,
353,
6702,
14242,
742,
525,
7543,
742,
525,
1730,
1169,
29918,
2798,
742,
525,
29886,
2458,
1463,
742,
525,
4548,
2658,
1495,
13,
4706,
4805,
29918,
19290,
353,
426,
13,
9651,
525,
1730,
1169,
29918,
2798,
2396,
11117,
949,
29918,
6194,
2396,
5852,
1118,
13,
9651,
525,
29886,
2458,
1463,
2396,
11117,
949,
29918,
6194,
2396,
5852,
1118,
13,
9651,
525,
4548,
2658,
2396,
11117,
949,
29918,
6194,
2396,
5852,
29913,
13,
4706,
500,
13,
13,
1678,
822,
12725,
29918,
14242,
29898,
1311,
29892,
995,
1125,
13,
4706,
565,
3323,
22371,
29889,
12650,
29889,
4572,
29898,
14242,
29922,
1767,
29892,
1518,
2658,
1649,
4141,
29922,
2230,
8028,
29889,
3707,
3285,
1998,
1169,
29918,
2798,
1649,
4141,
29922,
29900,
467,
9933,
7295,
13,
9651,
12020,
7797,
19427,
29889,
19448,
2392,
703,
3492,
2307,
505,
385,
6136,
25691,
1159,
13,
4706,
736,
995,
13,
13,
1678,
822,
1653,
29898,
1311,
29892,
2854,
630,
29918,
1272,
1125,
13,
4706,
2777,
353,
2428,
2141,
3258,
29898,
3084,
630,
29918,
1272,
29897,
13,
4706,
2777,
29889,
1730,
1169,
29918,
2798,
353,
2854,
630,
29918,
1272,
1839,
7543,
13359,
1730,
1169,
29918,
2798,
13,
4706,
2777,
29889,
7620,
580,
13,
4706,
736,
2777,
13,
2
] |
tests/rororo/test_openapi.py | fajfer/rororo | 105 | 43711 | import datetime
import io
import json
import zipfile
from pathlib import Path
import pyrsistent
import pytest
import yaml
from aiohttp import web
from openapi_core.shortcuts import create_spec
from yarl import URL
from rororo import (
BaseSettings,
get_openapi_context,
get_openapi_schema,
get_openapi_spec,
openapi_context,
OperationTableDef,
setup_openapi,
setup_settings_from_environ,
)
from rororo.annotations import DictStrAny
from rororo.openapi import get_validated_data
from rororo.openapi.exceptions import (
ConfigurationError,
OperationError,
validation_error_context,
ValidationError,
)
ROOT_PATH = Path(__file__).parent
INVALID_OPENAPI_JSON_PATH = ROOT_PATH / "invalid-openapi.json"
INVALID_OPENAPI_YAML_PATH = ROOT_PATH / "invalid-openapi.yaml"
OPENAPI_JSON_PATH = ROOT_PATH / "openapi.json"
OPENAPI_YAML_PATH = ROOT_PATH / "openapi.yaml"
TEST_NESTED_OBJECT = {
"uid": "6fccda1b-0873-4c8a-bceb-a2acfe5851da",
"type": "nested-object",
"data": {
"data_item": {"key": "value1", "any_data": {}},
"data_items": [
{"key": "value2", "any_data": {"two": 2}},
{"key": "value3", "any_data": {"three": 3}},
],
"str_items": ["1", "2", "3"],
},
"any_data": {"key1": "value1", "key2": "value2", "list": [1, 2, 3]},
}
operations = OperationTableDef()
invalid_operations = OperationTableDef()
def custom_json_loader(content: bytes) -> DictStrAny:
return json.load(io.BytesIO(content))
def custom_yaml_loader(content: bytes) -> DictStrAny:
return yaml.load(content, Loader=yaml.SafeLoader)
@invalid_operations.register("does-not-exist")
async def does_not_exist(request: web.Request) -> web.Response:
return web.Response(text="Hello, world!")
@operations.register("create-post")
async def create_post(request: web.Request) -> web.Response:
data = get_validated_data(request)
published_at: datetime.datetime = data["published_at"]
with validation_error_context("body", "published_at"):
if published_at.tzinfo is None:
raise ValidationError(message="Invalid value")
return web.json_response(
{**data, "id": 1, "published_at": data["published_at"].isoformat()},
status=201,
)
@operations.register
async def hello_world(request: web.Request) -> web.Response:
with openapi_context(request) as context:
name = context.parameters.query.get("name") or "world"
email = context.parameters.query.get("email") or "<EMAIL>"
return web.json_response(
{"message": f"Hello, {name}!", "email": email}
)
@operations.register
async def retrieve_any_object_from_request_body(
request: web.Request,
) -> web.Response:
return web.json_response(pyrsistent.thaw(get_validated_data(request)))
@operations.register
async def retrieve_array_from_request_body(
request: web.Request,
) -> web.Response:
with openapi_context(request) as context:
return web.json_response(pyrsistent.thaw(context.data))
@operations.register
async def retrieve_empty(request: web.Request) -> web.Response:
context = get_openapi_context(request)
return web.Response(
status=204, headers={"X-API-Key": context.security.get("apiKey") or ""}
)
@operations.register
async def retrieve_invalid_response(request: web.Request) -> web.Response:
return web.json_response({})
@operations.register
async def retrieve_post(request: web.Request) -> web.Response:
context = get_openapi_context(request)
return web.json_response(
{"id": context.parameters.path["post_id"], "title": "The Post"}
)
@operations.register
async def retrieve_nested_object_from_request_body(
request: web.Request,
) -> web.Response:
with openapi_context(request) as context:
data = pyrsistent.thaw(context.data)
data["uid"] = str(data["uid"])
return web.json_response(
data,
headers={
"X-Data-Type": str(type(context.data)),
"X-Data-Data-Data-Items-Type": str(
type(context.data["data"]["data_items"])
),
"X-Data-Data-Str-Items-Type": str(
type(context.data["data"]["str_items"])
),
"X-Data-UID-Type": str(type(context.data["uid"])),
},
)
@operations.register
async def retrieve_zip(request: web.Request) -> web.Response:
output = io.BytesIO()
with zipfile.ZipFile(output, "w") as handler:
handler.writestr("hello.txt", "Hello, world!")
output.seek(0)
return web.Response(
body=output,
content_type="application/zip",
headers={"Content-Disposition": "attachment; filename=hello.zip"},
)
@operations.register
async def upload_image(request: web.Request) -> web.Response:
return web.Response(
body=get_openapi_context(request).data,
content_type=request.content_type,
status=201,
)
@operations.register
async def upload_text(request: web.Request) -> web.Response:
return web.Response(
text=get_openapi_context(request).data,
content_type=request.content_type,
status=201,
)
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_any_object_request_body(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(), schema_path, operations, server_url=URL("/api/")
)
client = await aiohttp_client(app)
response = await client.post("/api/any-object", json=TEST_NESTED_OBJECT)
assert response.status == 200
assert await response.json() == TEST_NESTED_OBJECT
@pytest.mark.parametrize(
"data, expected_status, expected_response",
(
(
{},
422,
{"detail": [{"loc": ["body"], "message": "[] is too short"}]},
),
(
[],
422,
{"detail": [{"loc": ["body"], "message": "[] is too short"}]},
),
(
[""],
422,
{"detail": [{"loc": ["body", 0], "message": "'' is too short"}]},
),
(["Hello", "world!"], 200, ["Hello", "world!"]),
),
)
async def test_array_request_body(
aiohttp_client, data, expected_status, expected_response
):
app = setup_openapi(
web.Application(),
OPENAPI_YAML_PATH,
operations,
server_url=URL("/api"),
)
client = await aiohttp_client(app)
response = await client.post("/api/array", json=data)
assert response.status == expected_status
assert await response.json() == expected_response
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_create_post_201(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api/"
)
published_at = "2020-04-01T12:00:00+02:00"
client = await aiohttp_client(app)
response = await client.post(
"/api/create-post",
json={
"title": "Post",
"slug": "post",
"content": "Post Content",
"published_at": published_at,
},
)
assert response.status == 201
assert await response.json() == {
"id": 1,
"title": "Post",
"slug": "post",
"content": "Post Content",
"published_at": published_at,
}
@pytest.mark.parametrize(
"schema_path, invalid_data, expected_detail",
(
(
OPENAPI_JSON_PATH,
{},
[
{"loc": ["body", "title"], "message": "Field required"},
{"loc": ["body", "slug"], "message": "Field required"},
{"loc": ["body", "content"], "message": "Field required"},
{"loc": ["body", "published_at"], "message": "Field required"},
],
),
(
OPENAPI_YAML_PATH,
{"title": "Title"},
[
{"loc": ["body", "slug"], "message": "Field required"},
{"loc": ["body", "content"], "message": "Field required"},
{"loc": ["body", "published_at"], "message": "Field required"},
],
),
(
OPENAPI_JSON_PATH,
{"title": "Title", "slug": "slug"},
[
{"loc": ["body", "content"], "message": "Field required"},
{"loc": ["body", "published_at"], "message": "Field required"},
],
),
(
OPENAPI_YAML_PATH,
{"title": "Title", "slug": "slug", "content": "Content"},
[{"loc": ["body", "published_at"], "message": "Field required"}],
),
),
)
async def test_create_post_422(
aiohttp_client, schema_path, invalid_data, expected_detail
):
app = setup_openapi(
web.Application(),
schema_path,
operations,
server_url=URL("/dev-api"),
)
client = await aiohttp_client(app)
response = await client.post("/dev-api/create-post", json=invalid_data)
assert response.status == 422
assert (await response.json())["detail"] == expected_detail
@pytest.mark.parametrize(
"schema_path, schema_loader",
(
(OPENAPI_JSON_PATH, custom_json_loader),
(OPENAPI_YAML_PATH, custom_yaml_loader),
),
)
def test_custom_schema_loader(schema_path, schema_loader):
app = setup_openapi(
web.Application(),
schema_path,
operations,
server_url="/api/",
schema_loader=schema_loader,
)
assert isinstance(get_openapi_schema(app), dict)
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_email_format(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api/"
)
client = await aiohttp_client(app)
response = await client.get(
"/api/hello", params={"email": "<EMAIL>"}
)
assert response.status == 200
assert (await response.json())["email"] == "<EMAIL>"
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_invalid_parameter_format(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api/"
)
client = await aiohttp_client(app)
response = await client.get("/api/posts/not-an-integer")
assert response.status == 422
assert await response.json() == {
"detail": [
{
"loc": ["parameters", "post_id"],
"message": "'not-an-integer' is not a type of 'integer'",
}
]
}
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_invalid_parameter_value(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api/"
)
client = await aiohttp_client(app)
response = await client.get("/api/posts/0")
assert response.status == 422
assert await response.json() == {
"detail": [
{
"loc": ["parameters", "post_id"],
"message": "0 is less than the minimum of 1",
}
]
}
def test_get_openapi_schema_no_schema():
with pytest.raises(ConfigurationError):
get_openapi_schema(web.Application())
def test_get_openapi_spec_no_spec():
with pytest.raises(ConfigurationError):
get_openapi_spec(web.Application())
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_multiple_request_errors(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api/"
)
client = await aiohttp_client(app)
response = await client.get("/api/hello?name=&email=")
assert response.status == 422
assert await response.json() == {
"detail": [
{
"loc": ["parameters", "name"],
"message": "Empty parameter value",
},
{
"loc": ["parameters", "email"],
"message": "Empty parameter value",
},
]
}
@pytest.mark.parametrize(
"schema_path, query_string, expected_message",
(
(OPENAPI_JSON_PATH, None, "Hello, world!"),
(OPENAPI_JSON_PATH, "?name=Name", "Hello, Name!"),
(str(OPENAPI_JSON_PATH), None, "Hello, world!"),
(str(OPENAPI_JSON_PATH), "?name=Name", "Hello, Name!"),
(OPENAPI_YAML_PATH, None, "Hello, world!"),
(OPENAPI_YAML_PATH, "?name=Name", "Hello, Name!"),
(str(OPENAPI_YAML_PATH), None, "Hello, world!"),
(str(OPENAPI_YAML_PATH), "?name=Name", "Hello, Name!"),
),
)
async def test_openapi(
aiohttp_client, schema_path, query_string, expected_message
):
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api"
)
client = await aiohttp_client(app)
url = "/api/hello"
response = await client.get(
f"{url}{query_string}" if query_string is not None else url
)
assert response.status == 200
assert (await response.json())["message"] == expected_message
@pytest.mark.parametrize("is_enabled", (False, True))
async def test_openapi_validate_response(aiohttp_client, is_enabled):
app = web.Application()
setup_openapi(
app,
OPENAPI_YAML_PATH,
operations,
server_url="/api",
is_validate_response=is_enabled,
)
client = await aiohttp_client(app)
response = await client.get("/api/hello")
assert response.status == 200
assert await response.json() == {
"message": "Hello, world!",
"email": "<EMAIL>",
}
@pytest.mark.parametrize(
"has_openapi_schema_handler, url, expected_status",
(
(True, "/api/openapi.json", 200),
(False, "/api/openapi.yaml", 404),
(True, "/api/openapi.yaml", 200),
(False, "/api/openapi.yaml", 404),
(True, "/api/openapi.txt", 500),
(False, "/api/openapi.txt", 404),
),
)
async def test_openapi_schema_handler(
aiohttp_client, has_openapi_schema_handler, url, expected_status
):
app = web.Application()
setup_openapi(
app,
OPENAPI_YAML_PATH,
operations,
server_url=URL("/api"),
has_openapi_schema_handler=has_openapi_schema_handler,
)
client = await aiohttp_client(app)
response = await client.get(url)
assert response.status == expected_status
@pytest.mark.parametrize(
"schema_path, headers, expected",
(
(OPENAPI_JSON_PATH, {}, ""),
(OPENAPI_JSON_PATH, {"X-API-Key": "apiKey"}, "apiKey"),
(OPENAPI_YAML_PATH, {}, ""),
(OPENAPI_YAML_PATH, {"X-API-Key": "apiKey"}, "apiKey"),
),
)
async def test_optional_security_scheme(
aiohttp_client, schema_path, headers, expected
):
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api/"
)
client = await aiohttp_client(app)
response = await client.get("/api/empty", headers=headers)
assert response.status == 204
assert response.headers["X-API-Key"] == expected
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_request_body_nested_object(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api/"
)
client = await aiohttp_client(app)
response = await client.post("/api/nested-object", json=TEST_NESTED_OBJECT)
assert response.status == 200
assert response.headers["X-Data-Type"] == "<class 'pyrsistent._pmap.PMap'>"
assert (
response.headers["X-Data-Data-Data-Items-Type"]
== "<class 'pvectorc.PVector'>"
)
assert (
response.headers["X-Data-Data-Str-Items-Type"]
== "<class 'pvectorc.PVector'>"
)
assert response.headers["X-Data-UID-Type"] == "<class 'uuid.UUID'>"
assert await response.json() == TEST_NESTED_OBJECT
@pytest.mark.parametrize(
"schema_path, loader",
(
(OPENAPI_JSON_PATH, custom_json_loader),
(OPENAPI_YAML_PATH, custom_yaml_loader),
),
)
async def test_setup_openapi_schema_and_spec(
aiohttp_client, schema_path, loader
):
schema = loader(schema_path.read_bytes())
spec = create_spec(schema)
app = setup_openapi(
web.Application(),
operations,
schema=schema,
spec=spec,
server_url="/api/",
)
client = await aiohttp_client(app)
response = await client.get("/api/hello")
assert response.status == 200
assert await response.json() == {
"message": "Hello, world!",
"email": "<EMAIL>",
}
@pytest.mark.parametrize(
"schema_path, loader",
(
(OPENAPI_JSON_PATH, custom_json_loader),
(OPENAPI_YAML_PATH, custom_yaml_loader),
),
)
async def test_setup_openapi_schema_and_path_ignore_invalid_schema_path(
aiohttp_client, schema_path, loader
):
schema = loader(schema_path.read_bytes())
spec = create_spec(schema)
setup_openapi(
web.Application(),
INVALID_OPENAPI_JSON_PATH,
operations,
schema=schema,
spec=spec,
server_url="/api/",
)
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
def test_setup_openapi_invalid_operation(schema_path):
with pytest.raises(OperationError):
setup_openapi(
web.Application(),
schema_path,
invalid_operations,
server_url="/api",
)
def test_setup_openapi_invalid_path():
with pytest.raises(ConfigurationError):
setup_openapi(
web.Application(), ROOT_PATH / "does-not-exist.yaml", operations
)
def test_setup_openapi_invalid_file():
with pytest.raises(ConfigurationError):
setup_openapi(web.Application(), ROOT_PATH / "settings.py", operations)
@pytest.mark.parametrize(
"schema_path", (INVALID_OPENAPI_JSON_PATH, INVALID_OPENAPI_YAML_PATH)
)
def test_setup_openapi_invalid_spec(schema_path):
with pytest.raises(ConfigurationError):
setup_openapi(web.Application(), schema_path, operations)
@pytest.mark.parametrize(
"schema_path, level, url, expected_status",
(
(OPENAPI_JSON_PATH, "test", "/api/hello", 200),
(OPENAPI_JSON_PATH, "test", "/dev-api/hello", 404),
(OPENAPI_YAML_PATH, "test", "/api/hello", 200),
(OPENAPI_YAML_PATH, "test", "/dev-api/hello", 404),
(OPENAPI_JSON_PATH, "dev", "/api/hello", 404),
(OPENAPI_JSON_PATH, "dev", "/dev-api/hello", 200),
(OPENAPI_YAML_PATH, "dev", "/api/hello", 404),
(OPENAPI_YAML_PATH, "dev", "/dev-api/hello", 200),
),
)
async def test_setup_openapi_server_url_from_settings(
monkeypatch, aiohttp_client, schema_path, level, url, expected_status
):
monkeypatch.setenv("LEVEL", level)
app = setup_openapi(
setup_settings_from_environ(web.Application(), BaseSettings),
schema_path,
operations,
)
client = await aiohttp_client(app)
response = await client.get(url)
assert response.status == expected_status
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
def test_setup_openapi_server_url_invalid_level(monkeypatch, schema_path):
monkeypatch.setenv("LEVEL", "prod")
with pytest.raises(ConfigurationError):
setup_openapi(
setup_settings_from_environ(web.Application(), BaseSettings),
schema_path,
operations,
)
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
def test_setup_openapi_server_url_does_not_set(schema_path):
with pytest.raises(ConfigurationError):
setup_openapi(web.Application(), schema_path, operations)
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_upload_image(aiohttp_client, schema_path):
blank_png = (Path(__file__).parent / "data" / "blank.png").read_bytes()
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api"
)
client = await aiohttp_client(app)
response = await client.post(
"/api/upload-image",
data=blank_png,
headers={"Content-Type": "image/png"},
)
assert response.status == 201
assert await response.read() == blank_png
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_upload_text(aiohttp_client, schema_path):
text = "Hello, world! And other things..."
app = setup_openapi(
web.Application(), schema_path, operations, server_url="/api"
)
client = await aiohttp_client(app)
response = await client.post(
"/api/upload-text",
data=text.encode("utf-8"),
headers={"Content-Type": "text/plain"},
)
assert response.status == 201
assert await response.text() == text
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_validate_binary_response(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(),
schema_path,
operations,
server_url="/api",
is_validate_response=True,
)
client = await aiohttp_client(app)
response = await client.get("/api/download.zip")
assert response.status == 200
assert response.content_type == "application/zip"
content = io.BytesIO(await response.read())
with zipfile.ZipFile(content) as handler:
with handler.open("hello.txt") as item:
assert item.read() == b"Hello, world!"
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_validate_empty_response(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(),
schema_path,
operations,
server_url="/api",
is_validate_response=True,
)
client = await aiohttp_client(app)
response = await client.get("/api/empty")
assert response.status == 204
@pytest.mark.parametrize(
"schema_path, is_validate_response, expected_status",
(
(OPENAPI_JSON_PATH, False, 200),
(OPENAPI_JSON_PATH, True, 422),
(OPENAPI_YAML_PATH, False, 200),
(OPENAPI_JSON_PATH, True, 422),
),
)
async def test_validate_response(
aiohttp_client, schema_path, is_validate_response, expected_status
):
app = setup_openapi(
web.Application(),
schema_path,
operations,
server_url="/api",
is_validate_response=is_validate_response,
)
client = await aiohttp_client(app)
response = await client.get("/api/invalid-response")
assert response.status == expected_status
@pytest.mark.parametrize("schema_path", (OPENAPI_JSON_PATH, OPENAPI_YAML_PATH))
async def test_validate_response_error(aiohttp_client, schema_path):
app = setup_openapi(
web.Application(),
schema_path,
operations,
server_url="/api",
is_validate_response=True,
)
client = await aiohttp_client(app)
response = await client.get("/api/invalid-response")
assert response.status == 422
assert await response.json() == {
"detail": [
{"loc": ["response", "uid"], "message": "Field required"},
{"loc": ["response", "type"], "message": "Field required"},
{"loc": ["response", "data"], "message": "Field required"},
{"loc": ["response", "any_data"], "message": "Field required"},
]
}
| [
1,
1053,
12865,
13,
5215,
12013,
13,
5215,
4390,
13,
5215,
14319,
1445,
13,
3166,
2224,
1982,
1053,
10802,
13,
13,
5215,
11451,
2288,
9696,
13,
5215,
11451,
1688,
13,
5215,
343,
8807,
13,
3166,
263,
601,
1124,
1053,
1856,
13,
3166,
1722,
2754,
29918,
3221,
29889,
12759,
7582,
29879,
1053,
1653,
29918,
6550,
13,
3166,
343,
279,
29880,
1053,
3988,
13,
13,
3166,
364,
272,
5801,
1053,
313,
13,
1678,
7399,
9585,
29892,
13,
1678,
679,
29918,
3150,
2754,
29918,
4703,
29892,
13,
1678,
679,
29918,
3150,
2754,
29918,
11010,
29892,
13,
1678,
679,
29918,
3150,
2754,
29918,
6550,
29892,
13,
1678,
1722,
2754,
29918,
4703,
29892,
13,
1678,
20462,
3562,
3206,
29892,
13,
1678,
6230,
29918,
3150,
2754,
29892,
13,
1678,
6230,
29918,
11027,
29918,
3166,
29918,
21813,
29892,
13,
29897,
13,
3166,
364,
272,
5801,
29889,
6735,
800,
1053,
360,
919,
5015,
10773,
13,
3166,
364,
272,
5801,
29889,
3150,
2754,
1053,
679,
29918,
3084,
630,
29918,
1272,
13,
3166,
364,
272,
5801,
29889,
3150,
2754,
29889,
11739,
29879,
1053,
313,
13,
1678,
20999,
2392,
29892,
13,
1678,
20462,
2392,
29892,
13,
1678,
8845,
29918,
2704,
29918,
4703,
29892,
13,
1678,
15758,
362,
2392,
29892,
13,
29897,
13,
13,
13,
21289,
29918,
10145,
353,
10802,
22168,
1445,
1649,
467,
3560,
13,
13,
1177,
26707,
29918,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
353,
16641,
2891,
29918,
10145,
847,
376,
20965,
29899,
3150,
2754,
29889,
3126,
29908,
13,
1177,
26707,
29918,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
353,
16641,
2891,
29918,
10145,
847,
376,
20965,
29899,
3150,
2754,
29889,
25162,
29908,
13,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
353,
16641,
2891,
29918,
10145,
847,
376,
3150,
2754,
29889,
3126,
29908,
13,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
353,
16641,
2891,
29918,
10145,
847,
376,
3150,
2754,
29889,
25162,
29908,
13,
18267,
29918,
8186,
1254,
3352,
29918,
14824,
17637,
353,
426,
13,
1678,
376,
5416,
1115,
376,
29953,
29888,
617,
1388,
29896,
29890,
29899,
29900,
29947,
29955,
29941,
29899,
29946,
29883,
29947,
29874,
29899,
29890,
346,
29890,
29899,
29874,
29906,
562,
1725,
29945,
29947,
29945,
29896,
1388,
613,
13,
1678,
376,
1853,
1115,
376,
27420,
29899,
3318,
613,
13,
1678,
376,
1272,
1115,
426,
13,
4706,
376,
1272,
29918,
667,
1115,
8853,
1989,
1115,
376,
1767,
29896,
613,
376,
1384,
29918,
1272,
1115,
426,
11656,
13,
4706,
376,
1272,
29918,
7076,
1115,
518,
13,
9651,
8853,
1989,
1115,
376,
1767,
29906,
613,
376,
1384,
29918,
1272,
1115,
8853,
10184,
1115,
29871,
29906,
11656,
13,
9651,
8853,
1989,
1115,
376,
1767,
29941,
613,
376,
1384,
29918,
1272,
1115,
8853,
17536,
1115,
29871,
29941,
11656,
13,
4706,
21251,
13,
4706,
376,
710,
29918,
7076,
1115,
6796,
29896,
613,
376,
29906,
613,
376,
29941,
12436,
13,
1678,
2981,
13,
1678,
376,
1384,
29918,
1272,
1115,
8853,
1989,
29896,
1115,
376,
1767,
29896,
613,
376,
1989,
29906,
1115,
376,
1767,
29906,
613,
376,
1761,
1115,
518,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29962,
1118,
13,
29913,
13,
13,
3372,
800,
353,
20462,
3562,
3206,
580,
13,
20965,
29918,
3372,
800,
353,
20462,
3562,
3206,
580,
13,
13,
13,
1753,
2888,
29918,
3126,
29918,
12657,
29898,
3051,
29901,
6262,
29897,
1599,
360,
919,
5015,
10773,
29901,
13,
1678,
736,
4390,
29889,
1359,
29898,
601,
29889,
11207,
5971,
29898,
3051,
876,
13,
13,
13,
1753,
2888,
29918,
25162,
29918,
12657,
29898,
3051,
29901,
6262,
29897,
1599,
360,
919,
5015,
10773,
29901,
13,
1678,
736,
343,
8807,
29889,
1359,
29898,
3051,
29892,
4309,
1664,
29922,
25162,
29889,
17618,
1725,
10036,
29897,
13,
13,
13,
29992,
20965,
29918,
3372,
800,
29889,
9573,
703,
13221,
29899,
1333,
29899,
28997,
1159,
13,
12674,
822,
947,
29918,
1333,
29918,
28997,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
736,
1856,
29889,
5103,
29898,
726,
543,
10994,
29892,
3186,
29991,
1159,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
703,
3258,
29899,
2490,
1159,
13,
12674,
822,
1653,
29918,
2490,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
848,
353,
679,
29918,
3084,
630,
29918,
1272,
29898,
3827,
29897,
13,
13,
1678,
6369,
29918,
271,
29901,
12865,
29889,
12673,
353,
848,
3366,
5467,
3726,
29918,
271,
3108,
13,
1678,
411,
8845,
29918,
2704,
29918,
4703,
703,
2587,
613,
376,
5467,
3726,
29918,
271,
29908,
1125,
13,
4706,
565,
6369,
29918,
271,
29889,
17559,
3888,
338,
6213,
29901,
13,
9651,
12020,
15758,
362,
2392,
29898,
4906,
543,
13919,
995,
1159,
13,
13,
1678,
736,
1856,
29889,
3126,
29918,
5327,
29898,
13,
4706,
426,
1068,
1272,
29892,
376,
333,
1115,
29871,
29896,
29892,
376,
5467,
3726,
29918,
271,
1115,
848,
3366,
5467,
3726,
29918,
271,
16862,
10718,
4830,
580,
1118,
13,
4706,
4660,
29922,
29906,
29900,
29896,
29892,
13,
1678,
1723,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
22172,
29918,
11526,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
411,
1722,
2754,
29918,
4703,
29898,
3827,
29897,
408,
3030,
29901,
13,
4706,
1024,
353,
3030,
29889,
16744,
29889,
1972,
29889,
657,
703,
978,
1159,
470,
376,
11526,
29908,
13,
4706,
4876,
353,
3030,
29889,
16744,
29889,
1972,
29889,
657,
703,
5269,
1159,
470,
9872,
26862,
6227,
11903,
13,
4706,
736,
1856,
29889,
3126,
29918,
5327,
29898,
13,
9651,
8853,
4906,
1115,
285,
29908,
10994,
29892,
426,
978,
29913,
29991,
613,
376,
5269,
1115,
4876,
29913,
13,
4706,
1723,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
10563,
29918,
1384,
29918,
3318,
29918,
3166,
29918,
3827,
29918,
2587,
29898,
13,
1678,
2009,
29901,
1856,
29889,
3089,
29892,
13,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
736,
1856,
29889,
3126,
29918,
5327,
29898,
2272,
2288,
9696,
29889,
386,
1450,
29898,
657,
29918,
3084,
630,
29918,
1272,
29898,
3827,
4961,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
10563,
29918,
2378,
29918,
3166,
29918,
3827,
29918,
2587,
29898,
13,
1678,
2009,
29901,
1856,
29889,
3089,
29892,
13,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
411,
1722,
2754,
29918,
4703,
29898,
3827,
29897,
408,
3030,
29901,
13,
4706,
736,
1856,
29889,
3126,
29918,
5327,
29898,
2272,
2288,
9696,
29889,
386,
1450,
29898,
4703,
29889,
1272,
876,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
10563,
29918,
6310,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
3030,
353,
679,
29918,
3150,
2754,
29918,
4703,
29898,
3827,
29897,
13,
1678,
736,
1856,
29889,
5103,
29898,
13,
4706,
4660,
29922,
29906,
29900,
29946,
29892,
9066,
3790,
29908,
29990,
29899,
8787,
29899,
2558,
1115,
3030,
29889,
8926,
29889,
657,
703,
2754,
2558,
1159,
470,
5124,
29913,
13,
1678,
1723,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
10563,
29918,
20965,
29918,
5327,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
736,
1856,
29889,
3126,
29918,
5327,
3319,
1800,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
10563,
29918,
2490,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
3030,
353,
679,
29918,
3150,
2754,
29918,
4703,
29898,
3827,
29897,
13,
1678,
736,
1856,
29889,
3126,
29918,
5327,
29898,
13,
4706,
8853,
333,
1115,
3030,
29889,
16744,
29889,
2084,
3366,
2490,
29918,
333,
12436,
376,
3257,
1115,
376,
1576,
4918,
9092,
13,
1678,
1723,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
10563,
29918,
27420,
29918,
3318,
29918,
3166,
29918,
3827,
29918,
2587,
29898,
13,
1678,
2009,
29901,
1856,
29889,
3089,
29892,
13,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
411,
1722,
2754,
29918,
4703,
29898,
3827,
29897,
408,
3030,
29901,
13,
4706,
848,
353,
11451,
2288,
9696,
29889,
386,
1450,
29898,
4703,
29889,
1272,
29897,
13,
4706,
848,
3366,
5416,
3108,
353,
851,
29898,
1272,
3366,
5416,
20068,
13,
13,
4706,
736,
1856,
29889,
3126,
29918,
5327,
29898,
13,
9651,
848,
29892,
13,
9651,
9066,
3790,
13,
18884,
376,
29990,
29899,
1469,
29899,
1542,
1115,
851,
29898,
1853,
29898,
4703,
29889,
1272,
8243,
13,
18884,
376,
29990,
29899,
1469,
29899,
1469,
29899,
1469,
29899,
6913,
29899,
1542,
1115,
851,
29898,
13,
462,
1678,
1134,
29898,
4703,
29889,
1272,
3366,
1272,
3108,
3366,
1272,
29918,
7076,
20068,
13,
18884,
10353,
13,
18884,
376,
29990,
29899,
1469,
29899,
1469,
29899,
5015,
29899,
6913,
29899,
1542,
1115,
851,
29898,
13,
462,
1678,
1134,
29898,
4703,
29889,
1272,
3366,
1272,
3108,
3366,
710,
29918,
7076,
20068,
13,
18884,
10353,
13,
18884,
376,
29990,
29899,
1469,
29899,
11150,
29899,
1542,
1115,
851,
29898,
1853,
29898,
4703,
29889,
1272,
3366,
5416,
20068,
511,
13,
9651,
2981,
13,
4706,
1723,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
10563,
29918,
7554,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
1962,
353,
12013,
29889,
11207,
5971,
580,
13,
13,
1678,
411,
14319,
1445,
29889,
26264,
2283,
29898,
4905,
29892,
376,
29893,
1159,
408,
7834,
29901,
13,
4706,
7834,
29889,
8231,
16444,
703,
12199,
29889,
3945,
613,
376,
10994,
29892,
3186,
29991,
1159,
13,
13,
1678,
1962,
29889,
344,
1416,
29898,
29900,
29897,
13,
1678,
736,
1856,
29889,
5103,
29898,
13,
4706,
3573,
29922,
4905,
29892,
13,
4706,
2793,
29918,
1853,
543,
6214,
29914,
7554,
613,
13,
4706,
9066,
3790,
29908,
3916,
29899,
4205,
3283,
1115,
376,
14930,
358,
29936,
10422,
29922,
12199,
29889,
7554,
10758,
13,
1678,
1723,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
6441,
29918,
3027,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
736,
1856,
29889,
5103,
29898,
13,
4706,
3573,
29922,
657,
29918,
3150,
2754,
29918,
4703,
29898,
3827,
467,
1272,
29892,
13,
4706,
2793,
29918,
1853,
29922,
3827,
29889,
3051,
29918,
1853,
29892,
13,
4706,
4660,
29922,
29906,
29900,
29896,
29892,
13,
1678,
1723,
13,
13,
13,
29992,
3372,
800,
29889,
9573,
13,
12674,
822,
6441,
29918,
726,
29898,
3827,
29901,
1856,
29889,
3089,
29897,
1599,
1856,
29889,
5103,
29901,
13,
1678,
736,
1856,
29889,
5103,
29898,
13,
4706,
1426,
29922,
657,
29918,
3150,
2754,
29918,
4703,
29898,
3827,
467,
1272,
29892,
13,
4706,
2793,
29918,
1853,
29922,
3827,
29889,
3051,
29918,
1853,
29892,
13,
4706,
4660,
29922,
29906,
29900,
29896,
29892,
13,
1678,
1723,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
1384,
29918,
3318,
29918,
3827,
29918,
2587,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
29922,
4219,
11974,
2754,
29914,
1159,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
2490,
11974,
2754,
29914,
1384,
29899,
3318,
613,
4390,
29922,
18267,
29918,
8186,
1254,
3352,
29918,
14824,
17637,
29897,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29900,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
17067,
1254,
29918,
8186,
1254,
3352,
29918,
14824,
17637,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
1272,
29892,
3806,
29918,
4882,
29892,
3806,
29918,
5327,
613,
13,
1678,
313,
13,
4706,
313,
13,
9651,
24335,
13,
632,
29946,
29906,
29906,
29892,
13,
9651,
8853,
16432,
1115,
518,
6377,
2029,
1115,
6796,
2587,
12436,
376,
4906,
1115,
376,
2636,
338,
2086,
3273,
29908,
6525,
1118,
13,
4706,
10353,
13,
4706,
313,
13,
9651,
19997,
13,
632,
29946,
29906,
29906,
29892,
13,
9651,
8853,
16432,
1115,
518,
6377,
2029,
1115,
6796,
2587,
12436,
376,
4906,
1115,
376,
2636,
338,
2086,
3273,
29908,
6525,
1118,
13,
4706,
10353,
13,
4706,
313,
13,
9651,
6796,
12436,
13,
632,
29946,
29906,
29906,
29892,
13,
9651,
8853,
16432,
1115,
518,
6377,
2029,
1115,
6796,
2587,
613,
29871,
29900,
1402,
376,
4906,
1115,
376,
4907,
338,
2086,
3273,
29908,
6525,
1118,
13,
4706,
10353,
13,
4706,
313,
3366,
10994,
613,
376,
11526,
3850,
1402,
29871,
29906,
29900,
29900,
29892,
6796,
10994,
613,
376,
11526,
29991,
3108,
511,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
2378,
29918,
3827,
29918,
2587,
29898,
13,
1678,
263,
601,
1124,
29918,
4645,
29892,
848,
29892,
3806,
29918,
4882,
29892,
3806,
29918,
5327,
13,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
29922,
4219,
11974,
2754,
4968,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
2490,
11974,
2754,
29914,
2378,
613,
4390,
29922,
1272,
29897,
13,
1678,
4974,
2933,
29889,
4882,
1275,
3806,
29918,
4882,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
3806,
29918,
5327,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
3258,
29918,
2490,
29918,
29906,
29900,
29896,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
12975,
13,
1678,
1723,
13,
1678,
6369,
29918,
271,
353,
376,
29906,
29900,
29906,
29900,
29899,
29900,
29946,
29899,
29900,
29896,
29911,
29896,
29906,
29901,
29900,
29900,
29901,
29900,
29900,
29974,
29900,
29906,
29901,
29900,
29900,
29908,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
2490,
29898,
13,
4706,
5591,
2754,
29914,
3258,
29899,
2490,
613,
13,
4706,
4390,
3790,
13,
9651,
376,
3257,
1115,
376,
6747,
613,
13,
9651,
376,
29517,
1115,
376,
2490,
613,
13,
9651,
376,
3051,
1115,
376,
6747,
10576,
613,
13,
9651,
376,
5467,
3726,
29918,
271,
1115,
6369,
29918,
271,
29892,
13,
4706,
2981,
13,
1678,
1723,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29896,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
426,
13,
4706,
376,
333,
1115,
29871,
29896,
29892,
13,
4706,
376,
3257,
1115,
376,
6747,
613,
13,
4706,
376,
29517,
1115,
376,
2490,
613,
13,
4706,
376,
3051,
1115,
376,
6747,
10576,
613,
13,
4706,
376,
5467,
3726,
29918,
271,
1115,
6369,
29918,
271,
29892,
13,
1678,
500,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
29892,
8340,
29918,
1272,
29892,
3806,
29918,
16432,
613,
13,
1678,
313,
13,
4706,
313,
13,
9651,
6418,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
13,
9651,
24335,
13,
9651,
518,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
3257,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
29517,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
3051,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
5467,
3726,
29918,
271,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
313,
13,
9651,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
13,
9651,
8853,
3257,
1115,
376,
7030,
10758,
13,
9651,
518,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
29517,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
3051,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
5467,
3726,
29918,
271,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
313,
13,
9651,
6418,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
13,
9651,
8853,
3257,
1115,
376,
7030,
613,
376,
29517,
1115,
376,
29517,
10758,
13,
9651,
518,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
3051,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
18884,
8853,
2029,
1115,
6796,
2587,
613,
376,
5467,
3726,
29918,
271,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
9651,
21251,
13,
4706,
10353,
13,
4706,
313,
13,
9651,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
13,
9651,
8853,
3257,
1115,
376,
7030,
613,
376,
29517,
1115,
376,
29517,
613,
376,
3051,
1115,
376,
3916,
10758,
13,
9651,
518,
6377,
2029,
1115,
6796,
2587,
613,
376,
5467,
3726,
29918,
271,
12436,
376,
4906,
1115,
376,
3073,
3734,
9092,
1402,
13,
4706,
10353,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
3258,
29918,
2490,
29918,
29946,
29906,
29906,
29898,
13,
1678,
263,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
29892,
8340,
29918,
1272,
29892,
3806,
29918,
16432,
13,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
10938,
29918,
2084,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
29922,
4219,
11974,
3359,
29899,
2754,
4968,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
2490,
11974,
3359,
29899,
2754,
29914,
3258,
29899,
2490,
613,
4390,
29922,
20965,
29918,
1272,
29897,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29946,
29906,
29906,
13,
1678,
4974,
313,
20675,
2933,
29889,
3126,
3101,
3366,
16432,
3108,
1275,
3806,
29918,
16432,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
29892,
10938,
29918,
12657,
613,
13,
1678,
313,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
2888,
29918,
3126,
29918,
12657,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
2888,
29918,
25162,
29918,
12657,
511,
13,
1678,
10353,
13,
29897,
13,
1753,
1243,
29918,
6341,
29918,
11010,
29918,
12657,
29898,
11010,
29918,
2084,
29892,
10938,
29918,
12657,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
10938,
29918,
2084,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
13802,
2754,
29914,
613,
13,
4706,
10938,
29918,
12657,
29922,
11010,
29918,
12657,
29892,
13,
1678,
1723,
13,
1678,
4974,
338,
8758,
29898,
657,
29918,
3150,
2754,
29918,
11010,
29898,
932,
511,
9657,
29897,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
5269,
29918,
4830,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
12975,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
29898,
13,
4706,
5591,
2754,
29914,
12199,
613,
8636,
3790,
29908,
5269,
1115,
9872,
26862,
6227,
29958,
9092,
13,
1678,
1723,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29900,
13,
1678,
4974,
313,
20675,
2933,
29889,
3126,
3101,
3366,
5269,
3108,
1275,
9872,
26862,
6227,
11903,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
20965,
29918,
15501,
29918,
4830,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
12975,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
14080,
29914,
1333,
29899,
273,
29899,
16031,
1159,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29946,
29906,
29906,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
426,
13,
4706,
376,
16432,
1115,
518,
13,
9651,
426,
13,
18884,
376,
2029,
1115,
6796,
16744,
613,
376,
2490,
29918,
333,
12436,
13,
18884,
376,
4906,
1115,
13577,
1333,
29899,
273,
29899,
16031,
29915,
338,
451,
263,
1134,
310,
525,
16031,
29915,
613,
13,
9651,
500,
13,
4706,
4514,
13,
1678,
500,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
20965,
29918,
15501,
29918,
1767,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
12975,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
14080,
29914,
29900,
1159,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29946,
29906,
29906,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
426,
13,
4706,
376,
16432,
1115,
518,
13,
9651,
426,
13,
18884,
376,
2029,
1115,
6796,
16744,
613,
376,
2490,
29918,
333,
12436,
13,
18884,
376,
4906,
1115,
376,
29900,
338,
3109,
1135,
278,
9212,
310,
29871,
29896,
613,
13,
9651,
500,
13,
4706,
4514,
13,
1678,
500,
13,
13,
13,
1753,
1243,
29918,
657,
29918,
3150,
2754,
29918,
11010,
29918,
1217,
29918,
11010,
7295,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
8614,
2392,
1125,
13,
4706,
679,
29918,
3150,
2754,
29918,
11010,
29898,
2676,
29889,
4873,
3101,
13,
13,
13,
1753,
1243,
29918,
657,
29918,
3150,
2754,
29918,
6550,
29918,
1217,
29918,
6550,
7295,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
8614,
2392,
1125,
13,
4706,
679,
29918,
3150,
2754,
29918,
6550,
29898,
2676,
29889,
4873,
3101,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
20787,
29918,
3827,
29918,
12523,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
12975,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
12199,
29973,
978,
29332,
5269,
543,
29897,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29946,
29906,
29906,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
426,
13,
4706,
376,
16432,
1115,
518,
13,
9651,
426,
13,
18884,
376,
2029,
1115,
6796,
16744,
613,
376,
978,
12436,
13,
18884,
376,
4906,
1115,
376,
8915,
3443,
995,
613,
13,
9651,
2981,
13,
9651,
426,
13,
18884,
376,
2029,
1115,
6796,
16744,
613,
376,
5269,
12436,
13,
18884,
376,
4906,
1115,
376,
8915,
3443,
995,
613,
13,
9651,
2981,
13,
4706,
4514,
13,
1678,
500,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
29892,
2346,
29918,
1807,
29892,
3806,
29918,
4906,
613,
13,
1678,
313,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6213,
29892,
376,
10994,
29892,
3186,
3850,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
376,
29973,
978,
29922,
1170,
613,
376,
10994,
29892,
4408,
3850,
511,
13,
4706,
313,
710,
29898,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
511,
6213,
29892,
376,
10994,
29892,
3186,
3850,
511,
13,
4706,
313,
710,
29898,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
511,
376,
29973,
978,
29922,
1170,
613,
376,
10994,
29892,
4408,
3850,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
6213,
29892,
376,
10994,
29892,
3186,
3850,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
376,
29973,
978,
29922,
1170,
613,
376,
10994,
29892,
4408,
3850,
511,
13,
4706,
313,
710,
29898,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
511,
6213,
29892,
376,
10994,
29892,
3186,
3850,
511,
13,
4706,
313,
710,
29898,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
511,
376,
29973,
978,
29922,
1170,
613,
376,
10994,
29892,
4408,
3850,
511,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
3150,
2754,
29898,
13,
1678,
263,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
29892,
2346,
29918,
1807,
29892,
3806,
29918,
4906,
13,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
29908,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
3142,
353,
5591,
2754,
29914,
12199,
29908,
13,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
29898,
13,
4706,
285,
29908,
29912,
2271,
1157,
1972,
29918,
1807,
5038,
565,
2346,
29918,
1807,
338,
451,
6213,
1683,
3142,
13,
1678,
1723,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29900,
13,
1678,
4974,
313,
20675,
2933,
29889,
3126,
3101,
3366,
4906,
3108,
1275,
3806,
29918,
4906,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
275,
29918,
17590,
613,
313,
8824,
29892,
5852,
876,
13,
12674,
822,
1243,
29918,
3150,
2754,
29918,
15480,
29918,
5327,
29898,
29874,
601,
1124,
29918,
4645,
29892,
338,
29918,
17590,
1125,
13,
1678,
623,
353,
1856,
29889,
4873,
580,
13,
1678,
6230,
29918,
3150,
2754,
29898,
13,
4706,
623,
29892,
13,
4706,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
13802,
2754,
613,
13,
4706,
338,
29918,
15480,
29918,
5327,
29922,
275,
29918,
17590,
29892,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
12199,
1159,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29900,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
426,
13,
4706,
376,
4906,
1115,
376,
10994,
29892,
3186,
29991,
613,
13,
4706,
376,
5269,
1115,
9872,
26862,
6227,
28341,
13,
1678,
500,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
5349,
29918,
3150,
2754,
29918,
11010,
29918,
13789,
29892,
3142,
29892,
3806,
29918,
4882,
613,
13,
1678,
313,
13,
4706,
313,
5574,
29892,
5591,
2754,
29914,
3150,
2754,
29889,
3126,
613,
29871,
29906,
29900,
29900,
511,
13,
4706,
313,
8824,
29892,
5591,
2754,
29914,
3150,
2754,
29889,
25162,
613,
29871,
29946,
29900,
29946,
511,
13,
4706,
313,
5574,
29892,
5591,
2754,
29914,
3150,
2754,
29889,
25162,
613,
29871,
29906,
29900,
29900,
511,
13,
4706,
313,
8824,
29892,
5591,
2754,
29914,
3150,
2754,
29889,
25162,
613,
29871,
29946,
29900,
29946,
511,
13,
4706,
313,
5574,
29892,
5591,
2754,
29914,
3150,
2754,
29889,
3945,
613,
29871,
29945,
29900,
29900,
511,
13,
4706,
313,
8824,
29892,
5591,
2754,
29914,
3150,
2754,
29889,
3945,
613,
29871,
29946,
29900,
29946,
511,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
3150,
2754,
29918,
11010,
29918,
13789,
29898,
13,
1678,
263,
601,
1124,
29918,
4645,
29892,
756,
29918,
3150,
2754,
29918,
11010,
29918,
13789,
29892,
3142,
29892,
3806,
29918,
4882,
13,
1125,
13,
1678,
623,
353,
1856,
29889,
4873,
580,
13,
1678,
6230,
29918,
3150,
2754,
29898,
13,
4706,
623,
29892,
13,
4706,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
29922,
4219,
11974,
2754,
4968,
13,
4706,
756,
29918,
3150,
2754,
29918,
11010,
29918,
13789,
29922,
5349,
29918,
3150,
2754,
29918,
11010,
29918,
13789,
29892,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
29898,
2271,
29897,
13,
1678,
4974,
2933,
29889,
4882,
1275,
3806,
29918,
4882,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
29892,
9066,
29892,
3806,
613,
13,
1678,
313,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
24335,
376,
4968,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
8853,
29990,
29899,
8787,
29899,
2558,
1115,
376,
2754,
2558,
10758,
376,
2754,
2558,
4968,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
24335,
376,
4968,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
8853,
29990,
29899,
8787,
29899,
2558,
1115,
376,
2754,
2558,
10758,
376,
2754,
2558,
4968,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
25253,
29918,
8926,
29918,
816,
2004,
29898,
13,
1678,
263,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
29892,
9066,
29892,
3806,
13,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
12975,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
6310,
613,
9066,
29922,
13662,
29897,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29946,
13,
1678,
4974,
2933,
29889,
13662,
3366,
29990,
29899,
8787,
29899,
2558,
3108,
1275,
3806,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
3827,
29918,
2587,
29918,
27420,
29918,
3318,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
12975,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
2490,
11974,
2754,
29914,
27420,
29899,
3318,
613,
4390,
29922,
18267,
29918,
8186,
1254,
3352,
29918,
14824,
17637,
29897,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29900,
13,
1678,
4974,
2933,
29889,
13662,
3366,
29990,
29899,
1469,
29899,
1542,
3108,
1275,
9872,
1990,
525,
2272,
2288,
9696,
3032,
29886,
1958,
29889,
29925,
3388,
11041,
29908,
13,
1678,
4974,
313,
13,
4706,
2933,
29889,
13662,
3366,
29990,
29899,
1469,
29899,
1469,
29899,
1469,
29899,
6913,
29899,
1542,
3108,
13,
4706,
1275,
9872,
1990,
525,
29886,
8111,
29883,
29889,
29925,
12877,
11041,
29908,
13,
1678,
1723,
13,
1678,
4974,
313,
13,
4706,
2933,
29889,
13662,
3366,
29990,
29899,
1469,
29899,
1469,
29899,
5015,
29899,
6913,
29899,
1542,
3108,
13,
4706,
1275,
9872,
1990,
525,
29886,
8111,
29883,
29889,
29925,
12877,
11041,
29908,
13,
1678,
1723,
13,
1678,
4974,
2933,
29889,
13662,
3366,
29990,
29899,
1469,
29899,
11150,
29899,
1542,
3108,
1275,
9872,
1990,
525,
25118,
29889,
29965,
11150,
11041,
29908,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
17067,
1254,
29918,
8186,
1254,
3352,
29918,
14824,
17637,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
29892,
23466,
613,
13,
1678,
313,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
2888,
29918,
3126,
29918,
12657,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
2888,
29918,
25162,
29918,
12657,
511,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
11010,
29918,
392,
29918,
6550,
29898,
13,
1678,
263,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
29892,
23466,
13,
1125,
13,
1678,
10938,
353,
23466,
29898,
11010,
29918,
2084,
29889,
949,
29918,
13193,
3101,
13,
1678,
1580,
353,
1653,
29918,
6550,
29898,
11010,
29897,
13,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
6931,
29892,
13,
4706,
10938,
29922,
11010,
29892,
13,
4706,
1580,
29922,
6550,
29892,
13,
4706,
1923,
29918,
2271,
13802,
2754,
29914,
613,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
12199,
1159,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29900,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
426,
13,
4706,
376,
4906,
1115,
376,
10994,
29892,
3186,
29991,
613,
13,
4706,
376,
5269,
1115,
9872,
26862,
6227,
28341,
13,
1678,
500,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
29892,
23466,
613,
13,
1678,
313,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
2888,
29918,
3126,
29918,
12657,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
2888,
29918,
25162,
29918,
12657,
511,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
11010,
29918,
392,
29918,
2084,
29918,
17281,
29918,
20965,
29918,
11010,
29918,
2084,
29898,
13,
1678,
263,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
29892,
23466,
13,
1125,
13,
1678,
10938,
353,
23466,
29898,
11010,
29918,
2084,
29889,
949,
29918,
13193,
3101,
13,
1678,
1580,
353,
1653,
29918,
6550,
29898,
11010,
29897,
13,
13,
1678,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
2672,
26707,
29918,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
13,
4706,
6931,
29892,
13,
4706,
10938,
29922,
11010,
29892,
13,
4706,
1580,
29922,
6550,
29892,
13,
4706,
1923,
29918,
2271,
13802,
2754,
29914,
613,
13,
1678,
1723,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
1753,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
20965,
29918,
16453,
29898,
11010,
29918,
2084,
1125,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
10925,
2392,
1125,
13,
4706,
6230,
29918,
3150,
2754,
29898,
13,
9651,
1856,
29889,
4873,
3285,
13,
9651,
10938,
29918,
2084,
29892,
13,
9651,
8340,
29918,
3372,
800,
29892,
13,
9651,
1923,
29918,
2271,
13802,
2754,
613,
13,
4706,
1723,
13,
13,
13,
1753,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
20965,
29918,
2084,
7295,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
8614,
2392,
1125,
13,
4706,
6230,
29918,
3150,
2754,
29898,
13,
9651,
1856,
29889,
4873,
3285,
16641,
2891,
29918,
10145,
847,
376,
13221,
29899,
1333,
29899,
28997,
29889,
25162,
613,
6931,
13,
4706,
1723,
13,
13,
13,
1753,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
20965,
29918,
1445,
7295,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
8614,
2392,
1125,
13,
4706,
6230,
29918,
3150,
2754,
29898,
2676,
29889,
4873,
3285,
16641,
2891,
29918,
10145,
847,
376,
11027,
29889,
2272,
613,
6931,
29897,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
613,
313,
1177,
26707,
29918,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
2672,
26707,
29918,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29897,
13,
29897,
13,
1753,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
20965,
29918,
6550,
29898,
11010,
29918,
2084,
1125,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
8614,
2392,
1125,
13,
4706,
6230,
29918,
3150,
2754,
29898,
2676,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29897,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
29892,
3233,
29892,
3142,
29892,
3806,
29918,
4882,
613,
13,
1678,
313,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
376,
1688,
613,
5591,
2754,
29914,
12199,
613,
29871,
29906,
29900,
29900,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
376,
1688,
613,
5591,
3359,
29899,
2754,
29914,
12199,
613,
29871,
29946,
29900,
29946,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
376,
1688,
613,
5591,
2754,
29914,
12199,
613,
29871,
29906,
29900,
29900,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
376,
1688,
613,
5591,
3359,
29899,
2754,
29914,
12199,
613,
29871,
29946,
29900,
29946,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
376,
3359,
613,
5591,
2754,
29914,
12199,
613,
29871,
29946,
29900,
29946,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
376,
3359,
613,
5591,
3359,
29899,
2754,
29914,
12199,
613,
29871,
29906,
29900,
29900,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
376,
3359,
613,
5591,
2754,
29914,
12199,
613,
29871,
29946,
29900,
29946,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
376,
3359,
613,
5591,
3359,
29899,
2754,
29914,
12199,
613,
29871,
29906,
29900,
29900,
511,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
2974,
29918,
2271,
29918,
3166,
29918,
11027,
29898,
13,
1678,
1601,
446,
1478,
905,
29892,
263,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
29892,
3233,
29892,
3142,
29892,
3806,
29918,
4882,
13,
1125,
13,
1678,
1601,
446,
1478,
905,
29889,
842,
6272,
703,
1307,
29963,
6670,
613,
3233,
29897,
13,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
6230,
29918,
11027,
29918,
3166,
29918,
21813,
29898,
2676,
29889,
4873,
3285,
7399,
9585,
511,
13,
4706,
10938,
29918,
2084,
29892,
13,
4706,
6931,
29892,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
29898,
2271,
29897,
13,
1678,
4974,
2933,
29889,
4882,
1275,
3806,
29918,
4882,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
1753,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
2974,
29918,
2271,
29918,
20965,
29918,
5563,
29898,
3712,
446,
1478,
905,
29892,
10938,
29918,
2084,
1125,
13,
1678,
1601,
446,
1478,
905,
29889,
842,
6272,
703,
1307,
29963,
6670,
613,
376,
10633,
1159,
13,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
8614,
2392,
1125,
13,
4706,
6230,
29918,
3150,
2754,
29898,
13,
9651,
6230,
29918,
11027,
29918,
3166,
29918,
21813,
29898,
2676,
29889,
4873,
3285,
7399,
9585,
511,
13,
9651,
10938,
29918,
2084,
29892,
13,
9651,
6931,
29892,
13,
4706,
1723,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
1753,
1243,
29918,
14669,
29918,
3150,
2754,
29918,
2974,
29918,
2271,
29918,
13221,
29918,
1333,
29918,
842,
29898,
11010,
29918,
2084,
1125,
13,
1678,
411,
11451,
1688,
29889,
336,
4637,
29898,
8614,
2392,
1125,
13,
4706,
6230,
29918,
3150,
2754,
29898,
2676,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29897,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
9009,
29918,
3027,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
9654,
29918,
2732,
353,
313,
2605,
22168,
1445,
1649,
467,
3560,
847,
376,
1272,
29908,
847,
376,
19465,
29889,
2732,
2564,
949,
29918,
13193,
580,
13,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
29908,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
2490,
29898,
13,
4706,
5591,
2754,
29914,
9009,
29899,
3027,
613,
13,
4706,
848,
29922,
19465,
29918,
2732,
29892,
13,
4706,
9066,
3790,
29908,
3916,
29899,
1542,
1115,
376,
3027,
29914,
2732,
10758,
13,
1678,
1723,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29896,
13,
1678,
4974,
7272,
2933,
29889,
949,
580,
1275,
9654,
29918,
2732,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
9009,
29918,
726,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
1426,
353,
376,
10994,
29892,
3186,
29991,
1126,
916,
2712,
17794,
13,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
10938,
29918,
2084,
29892,
6931,
29892,
1923,
29918,
2271,
13802,
2754,
29908,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
2490,
29898,
13,
4706,
5591,
2754,
29914,
9009,
29899,
726,
613,
13,
4706,
848,
29922,
726,
29889,
12508,
703,
9420,
29899,
29947,
4968,
13,
4706,
9066,
3790,
29908,
3916,
29899,
1542,
1115,
376,
726,
29914,
24595,
10758,
13,
1678,
1723,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29896,
13,
1678,
4974,
7272,
2933,
29889,
726,
580,
1275,
1426,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
15480,
29918,
19541,
29918,
5327,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
10938,
29918,
2084,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
13802,
2754,
613,
13,
4706,
338,
29918,
15480,
29918,
5327,
29922,
5574,
29892,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
10382,
29889,
7554,
1159,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29900,
13,
1678,
4974,
2933,
29889,
3051,
29918,
1853,
1275,
376,
6214,
29914,
7554,
29908,
13,
13,
1678,
2793,
353,
12013,
29889,
11207,
5971,
29898,
20675,
2933,
29889,
949,
3101,
13,
1678,
411,
14319,
1445,
29889,
26264,
2283,
29898,
3051,
29897,
408,
7834,
29901,
13,
4706,
411,
7834,
29889,
3150,
703,
12199,
29889,
3945,
1159,
408,
2944,
29901,
13,
9651,
4974,
2944,
29889,
949,
580,
1275,
289,
29908,
10994,
29892,
3186,
3850,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
15480,
29918,
6310,
29918,
5327,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
10938,
29918,
2084,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
13802,
2754,
613,
13,
4706,
338,
29918,
15480,
29918,
5327,
29922,
5574,
29892,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
6310,
1159,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29906,
29900,
29946,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
29898,
13,
1678,
376,
11010,
29918,
2084,
29892,
338,
29918,
15480,
29918,
5327,
29892,
3806,
29918,
4882,
613,
13,
1678,
313,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
7700,
29892,
29871,
29906,
29900,
29900,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
5852,
29892,
29871,
29946,
29906,
29906,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
29892,
7700,
29892,
29871,
29906,
29900,
29900,
511,
13,
4706,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
5852,
29892,
29871,
29946,
29906,
29906,
511,
13,
1678,
10353,
13,
29897,
13,
12674,
822,
1243,
29918,
15480,
29918,
5327,
29898,
13,
1678,
263,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
29892,
338,
29918,
15480,
29918,
5327,
29892,
3806,
29918,
4882,
13,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
10938,
29918,
2084,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
13802,
2754,
613,
13,
4706,
338,
29918,
15480,
29918,
5327,
29922,
275,
29918,
15480,
29918,
5327,
29892,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
20965,
29899,
5327,
1159,
13,
1678,
4974,
2933,
29889,
4882,
1275,
3806,
29918,
4882,
13,
13,
13,
29992,
2272,
1688,
29889,
3502,
29889,
3207,
300,
374,
911,
703,
11010,
29918,
2084,
613,
313,
4590,
1430,
8787,
29918,
7249,
29918,
10145,
29892,
6418,
1430,
8787,
29918,
29979,
23956,
29918,
10145,
876,
13,
12674,
822,
1243,
29918,
15480,
29918,
5327,
29918,
2704,
29898,
29874,
601,
1124,
29918,
4645,
29892,
10938,
29918,
2084,
1125,
13,
1678,
623,
353,
6230,
29918,
3150,
2754,
29898,
13,
4706,
1856,
29889,
4873,
3285,
13,
4706,
10938,
29918,
2084,
29892,
13,
4706,
6931,
29892,
13,
4706,
1923,
29918,
2271,
13802,
2754,
613,
13,
4706,
338,
29918,
15480,
29918,
5327,
29922,
5574,
29892,
13,
1678,
1723,
13,
13,
1678,
3132,
353,
7272,
263,
601,
1124,
29918,
4645,
29898,
932,
29897,
13,
1678,
2933,
353,
7272,
3132,
29889,
657,
11974,
2754,
29914,
20965,
29899,
5327,
1159,
13,
1678,
4974,
2933,
29889,
4882,
1275,
29871,
29946,
29906,
29906,
13,
1678,
4974,
7272,
2933,
29889,
3126,
580,
1275,
426,
13,
4706,
376,
16432,
1115,
518,
13,
9651,
8853,
2029,
1115,
6796,
5327,
613,
376,
5416,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
9651,
8853,
2029,
1115,
6796,
5327,
613,
376,
1853,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
9651,
8853,
2029,
1115,
6796,
5327,
613,
376,
1272,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
9651,
8853,
2029,
1115,
6796,
5327,
613,
376,
1384,
29918,
1272,
12436,
376,
4906,
1115,
376,
3073,
3734,
10758,
13,
4706,
4514,
13,
1678,
500,
13,
2
] |
src/rnn/text_classification_train.py | jorgemf/kaggle_redefining_cancer_treatment | 20 | 52106 | import tensorflow as tf
import csv
import time
from datetime import timedelta
import sys
import numpy as np
from tensorflow.python.training import training_util
from tensorflow.contrib import slim
from tensorflow.python.ops import variables as tf_variables
from ..configuration import *
from .. import trainer, evaluator, metrics
from ..task_spec import get_task_spec
from .text_classification_dataset import TextClassificationDataset
def _load_embeddings(vocabulary_size, embeddings_size,
filename_prefix='embeddings', from_dir=DIR_DATA_WORD2VEC):
embeddings = []
embeddings_file = '{}_{}_{}'.format(filename_prefix, vocabulary_size, embeddings_size)
with open(os.path.join(from_dir, embeddings_file), 'r') as file:
reader = csv.reader(file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for row in reader:
embeddings.append([float(r) for r in row])
return embeddings
class TextClassificationTrainer(trainer.Trainer):
"""
Helper class to run the training and create the model for the training. See trainer.Trainer for
more details.
"""
def __init__(self, dataset, text_classification_model, log_dir=DIR_TC_LOGDIR,
use_end_sequence=False, task_spec=None, max_steps=None):
self.text_classification_model = text_classification_model
self.use_end_sequence = use_end_sequence
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
super(TextClassificationTrainer, self).__init__(log_dir=log_dir, dataset=dataset,
task_spec=task_spec, max_steps=max_steps,
monitored_training_session_config=config)
def model(self, input_text_begin, input_text_end, gene, variation, expected_labels, batch_size,
vocabulary_size=VOCABULARY_SIZE, embeddings_size=EMBEDDINGS_SIZE, output_classes=9):
# embeddings
embeddings = _load_embeddings(vocabulary_size, embeddings_size)
# global step
self.global_step = training_util.get_or_create_global_step()
# model
with slim.arg_scope(self.text_classification_model.model_arg_scope()):
outputs = self.text_classification_model.model(input_text_begin, input_text_end,
gene, variation, output_classes,
embeddings=embeddings,
batch_size=batch_size)
# loss
targets = self.text_classification_model.targets(expected_labels, output_classes)
self.loss = self.text_classification_model.loss(targets, outputs)
tf.summary.scalar('loss', self.loss)
# learning rate
self.optimizer, self.learning_rate = \
self.text_classification_model.optimize(self.loss, self.global_step)
if self.learning_rate is not None:
tf.summary.scalar('learning_rate', self.learning_rate)
# metrics
self.metrics = metrics.single_label(outputs['prediction'], targets)
# saver to save the model
self.saver = tf.train.Saver()
# check a nan value in the loss
self.loss = tf.check_numerics(self.loss, 'loss is nan')
return None
def create_graph(self, dataset_tensor, batch_size):
input_text_begin, input_text_end, gene, variation, expected_labels = dataset_tensor
if not self.use_end_sequence:
input_text_end = None
return self.model(input_text_begin, input_text_end, gene, variation, expected_labels, batch_size)
def step(self, session, graph_data):
lr, _, loss, step, metrics = \
session.run([self.learning_rate, self.optimizer, self.loss, self.global_step,
self.metrics])
if self.is_chief and time.time() > self.print_timestamp + 5 * 60:
self.print_timestamp = time.time()
elapsed_time = str(timedelta(seconds=time.time() - self.init_time))
m = 'step: {} loss: {:0.4f} learning_rate = {:0.6f} elapsed seconds: {} ' \
'precision: {} recall: {} accuracy: {}'
logging.info(m.format(step, loss, lr, elapsed_time,
metrics['precision'], metrics['recall'], metrics['accuracy']))
def after_create_session(self, session, coord):
self.init_time = time.time()
self.print_timestamp = time.time()
class TextClassificationTest(evaluator.Evaluator):
"""Evaluator for distributed training"""
def __init__(self, dataset, text_classification_model, output_path, log_dir=DIR_TC_LOGDIR,
use_end_sequence=False,max_steps=None):
self.use_end_sequence = use_end_sequence
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
super(TextClassificationTest, self).__init__(checkpoints_dir=log_dir, dataset=dataset,
output_path=output_path, max_steps=max_steps,
singular_monitored_session_config=config)
self.text_classification_model = text_classification_model
self.eval_writer = tf.summary.FileWriter(log_dir)
def model(self, input_text_begin, input_text_end, gene, variation, expected_labels, batch_size,
vocabulary_size=VOCABULARY_SIZE, embeddings_size=EMBEDDINGS_SIZE, output_classes=9):
# embeddings
embeddings = _load_embeddings(vocabulary_size, embeddings_size)
# model
with slim.arg_scope(self.text_classification_model.model_arg_scope()):
outputs = self.text_classification_model.model(input_text_begin, input_text_end,
gene, variation, output_classes,
embeddings=embeddings,
batch_size=batch_size,
training=False)
# loss
targets = self.text_classification_model.targets(expected_labels, output_classes)
loss = self.text_classification_model.loss(targets, outputs)
self.accumulated_loss = tf.Variable(0.0, dtype=tf.float32, name='accumulated_loss',
trainable=False)
self.accumulated_loss = tf.assign_add(self.accumulated_loss, loss)
step = tf.Variable(0, dtype=tf.int32, name='eval_step', trainable=False)
step_increase = tf.assign_add(step, 1)
self.loss = self.accumulated_loss / tf.cast(step_increase, dtype=tf.float32)
tf.summary.scalar('loss', self.loss)
# metrics
self.metrics = metrics.single_label(outputs['prediction'], targets, moving_average=False)
return None
def create_graph(self, dataset_tensor, batch_size):
input_text_begin, input_text_end, gene, variation, expected_labels = dataset_tensor
if not self.use_end_sequence:
input_text_end = None
graph_data = self.model(input_text_begin, input_text_end, gene, variation,
expected_labels, batch_size)
return graph_data
def step(self, session, graph_data, summary_op):
summary, self.loss_result, self.metrics_results = \
session.run([summary_op, self.loss, self.metrics])
return summary
def end(self, session):
super(TextClassificationTest, self).end(session)
chk_step = int(self.lastest_checkpoint.split('-')[-1])
m = 'step: {} loss: {:0.4f} precision: {} recall: {} accuracy: {}'
logging.info(m.format(chk_step, self.loss_result, self.metrics_results['precision'],
self.metrics_results['recall'], self.metrics_results['accuracy']))
def after_create_session(self, session, coord):
# checkpoints_file = os.path.join(self.checkpoints_dir, 'checkpoint')
# alt_checkpoints_dir = '{}_tp'.format(self.checkpoints_dir)
# import glob
# files = glob.glob('{}/model.ckpt-*.data-*'.format(alt_checkpoints_dir))
# chk_step = 0
# for f in files:
# num = f.split('model.ckpt-')[1].split('.')[0]
# num = int(num)
# if chk_step == 0 or num < chk_step:
# chk_step = num
# if chk_step != 0:
# ckpt_files = glob.glob('{}/model.ckpt-{}.data-*'.format(alt_checkpoints_dir, chk_step))
# ckpt_files = [x.split('/')[-1] for x in ckpt_files]
# for f in ckpt_files + ['model.ckpt-{}.index', 'model.ckpt-{}.meta']:
# f = f.format(chk_step)
# os.rename(os.path.join(alt_checkpoints_dir, f), os.path.join(self.checkpoints_dir, f))
# with open(checkpoints_file, 'wb') as f:
# f.write('model_checkpoint_path: "./model.ckpt-{}"\n'.format(chk_step))
# f.write('all_model_checkpoint_paths: "./model.ckpt-{}"\n'.format(chk_step))
super(TextClassificationTest, self).after_create_session(session, coord)
# with open(checkpoints_file, 'wb') as f:
# f.write('model_checkpoint_path: "./model.ckpt-"\n')
# f.write('all_model_checkpoint_paths: "./model.ckpt-"\n')
class TextClassificationEval(evaluator.Evaluator):
"""Evaluator for text classification"""
def __init__(self, dataset, text_classification_model, output_path, log_dir=DIR_TC_LOGDIR,
use_end_sequence=False):
self.use_end_sequence = use_end_sequence
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
super(TextClassificationEval, self).__init__(checkpoints_dir=log_dir,
output_path=output_path,
infinite_loop=False,
singular_monitored_session_config=config)
self.dataset = dataset
self.text_classification_model = text_classification_model
def model(self, input_text_begin, input_text_end, gene, variation, batch_size,
vocabulary_size=VOCABULARY_SIZE, embeddings_size=EMBEDDINGS_SIZE, output_classes=9):
# embeddings
embeddings = _load_embeddings(vocabulary_size, embeddings_size)
# global step
self.global_step = training_util.get_or_create_global_step()
self.global_step = tf.assign_add(self.global_step, 1)
# model
with tf.control_dependencies([self.global_step]):
with slim.arg_scope(self.text_classification_model.model_arg_scope()):
self.outputs = self.text_classification_model.model(input_text_begin, input_text_end,
gene, variation, output_classes,
embeddings=embeddings,
batch_size=batch_size,
training=False)
# restore only the trainable variables
self.saver = tf.train.Saver(var_list=tf_variables.trainable_variables())
return self.outputs
def create_graph(self, dataset_tensor, batch_size):
input_text_begin, input_text_end, gene, variation = dataset_tensor
if not self.use_end_sequence:
input_text_end = None
return self.model(input_text_begin, input_text_end, gene, variation, batch_size)
def after_create_session(self, session, coord):
super(TextClassificationEval, self).after_create_session(session, coord)
print('ID,class1,class2,class3,class4,class5,class6,class7,class8,class9')
def step(self, session, graph_data, summary_op):
step, predictions = session.run([self.global_step, self.outputs['prediction']])
predictions = predictions[0]
predictions = [p + 0.01 for p in predictions] # penalize less the mistakes
sum = np.sum(predictions)
predictions = [p / sum for p in predictions]
print('{},{}'.format(step, ','.join(['{:.3f}'.format(x) for x in predictions])))
return None
import logging
def main(model, name, sentence_split=False, end_sequence=USE_END_SEQUENCE, batch_size=TC_BATCH_SIZE):
"""
Main method to execute the text_classification models
:param ModelSimple model: object model based on ModelSimple
:param str name: name of the model
:param bool sentence_split: whether to split the dataset in sentneces or not,
only used for hatt model
:param bool end_sequence: whether to use or not the end of the sequences in the models
:param int batch_size: batch size of the models
"""
logging.getLogger().setLevel(logging.INFO)
log_dir = '{}_{}'.format(DIR_TC_LOGDIR, name)
if len(sys.argv) > 1 and sys.argv[1] == 'test':
# execute the test with the train dataset
dataset = TextClassificationDataset(type='train', sentence_split=sentence_split)
tester = TextClassificationTest(dataset=dataset, text_classification_model=model,
log_dir=log_dir,
output_path=os.path.join(log_dir, 'test_trainset'),
use_end_sequence=end_sequence)
tester.run()
elif len(sys.argv) > 1 and sys.argv[1] == 'validate':
dataset = TextClassificationDataset(type='val', sentence_split=sentence_split)
tester = TextClassificationTest(dataset=dataset, text_classification_model=model,
log_dir=log_dir,
output_path=os.path.join(log_dir, 'validate'),
use_end_sequence=end_sequence)
tester.run()
elif len(sys.argv) > 1 and sys.argv[1] == 'eval':
# evaluate the data of the test dataset. We submit this output to kaggle
dataset = TextClassificationDataset(type='test', sentence_split=sentence_split)
evaluator = TextClassificationEval(dataset=dataset, text_classification_model=model,
log_dir=log_dir,
output_path=os.path.join(log_dir, 'test'),
use_end_sequence=end_sequence)
evaluator.run()
elif len(sys.argv) > 1 and sys.argv[1] == 'eval_stage2':
# evaluate the data of the test dataset. We submit this output to kaggle
dataset = TextClassificationDataset(type='stage2_test', sentence_split=sentence_split)
evaluator = TextClassificationEval(dataset=dataset, text_classification_model=model,
log_dir=log_dir,
output_path=os.path.join(log_dir, 'test_stage2'),
use_end_sequence=end_sequence)
evaluator.run()
else:
# training
task_spec = get_task_spec(with_evaluator=USE_LAST_WORKER_FOR_VALIDATION)
if task_spec.join_if_ps():
# join if it is a parameters server and do nothing else
return
with(tf.gfile.Open(os.path.join(DIR_DATA_TEXT_CLASSIFICATION, 'train_set'))) as f:
max_steps = int(TC_EPOCHS * len(f.readlines()) / batch_size)
if task_spec.is_evaluator():
dataset = TextClassificationDataset(type='val', sentence_split=sentence_split)
# evaluator running in the last worker
tester = TextClassificationTest(dataset=dataset, text_classification_model=model,
log_dir=log_dir,
output_path=os.path.join(log_dir, 'val'),
use_end_sequence=end_sequence,
max_steps=max_steps)
tester.run()
else:
dataset = TextClassificationDataset(type='train', sentence_split=sentence_split)
trainer = TextClassificationTrainer(dataset=dataset, text_classification_model=model,
log_dir=log_dir, use_end_sequence=end_sequence,
task_spec=task_spec, max_steps=max_steps)
trainer.run(epochs=TC_EPOCHS, batch_size=batch_size)
| [
1,
1053,
26110,
408,
15886,
13,
5215,
11799,
13,
5215,
931,
13,
3166,
12865,
1053,
5335,
287,
2554,
13,
5215,
10876,
13,
5215,
12655,
408,
7442,
13,
3166,
26110,
29889,
4691,
29889,
26495,
1053,
6694,
29918,
4422,
13,
3166,
26110,
29889,
21570,
1053,
2243,
326,
13,
3166,
26110,
29889,
4691,
29889,
3554,
1053,
3651,
408,
15886,
29918,
20897,
13,
3166,
6317,
13305,
1053,
334,
13,
3166,
6317,
1053,
1020,
4983,
29892,
6161,
1061,
29892,
21556,
13,
3166,
6317,
7662,
29918,
6550,
1053,
679,
29918,
7662,
29918,
6550,
13,
3166,
869,
726,
29918,
1990,
2450,
29918,
24713,
1053,
3992,
2385,
2450,
16390,
24541,
13,
13,
13,
1753,
903,
1359,
29918,
17987,
29881,
886,
29898,
29894,
542,
370,
352,
653,
29918,
2311,
29892,
8297,
29881,
886,
29918,
2311,
29892,
13,
462,
268,
10422,
29918,
13506,
2433,
17987,
29881,
886,
742,
515,
29918,
3972,
29922,
9464,
29918,
14573,
29918,
17013,
29906,
29963,
11206,
1125,
13,
1678,
8297,
29881,
886,
353,
5159,
13,
1678,
8297,
29881,
886,
29918,
1445,
353,
22372,
3227,
3227,
29913,
4286,
4830,
29898,
9507,
29918,
13506,
29892,
7931,
370,
352,
653,
29918,
2311,
29892,
8297,
29881,
886,
29918,
2311,
29897,
13,
1678,
411,
1722,
29898,
359,
29889,
2084,
29889,
7122,
29898,
3166,
29918,
3972,
29892,
8297,
29881,
886,
29918,
1445,
511,
525,
29878,
1495,
408,
934,
29901,
13,
4706,
9591,
353,
11799,
29889,
16950,
29898,
1445,
29892,
28552,
29922,
742,
742,
14978,
3090,
2433,
29908,
742,
439,
11427,
29922,
7638,
29889,
13356,
2891,
29923,
29918,
16173,
2260,
29931,
29897,
13,
4706,
363,
1948,
297,
9591,
29901,
13,
9651,
8297,
29881,
886,
29889,
4397,
4197,
7411,
29898,
29878,
29897,
363,
364,
297,
1948,
2314,
13,
1678,
736,
8297,
29881,
886,
13,
13,
13,
1990,
3992,
2385,
2450,
5323,
4983,
29898,
3018,
4983,
29889,
5323,
4983,
1125,
13,
1678,
9995,
13,
1678,
6162,
546,
770,
304,
1065,
278,
6694,
322,
1653,
278,
1904,
363,
278,
6694,
29889,
2823,
1020,
4983,
29889,
5323,
4983,
363,
13,
1678,
901,
4902,
29889,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
8783,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29892,
1480,
29918,
3972,
29922,
9464,
29918,
9472,
29918,
14480,
9464,
29892,
13,
462,
671,
29918,
355,
29918,
16506,
29922,
8824,
29892,
3414,
29918,
6550,
29922,
8516,
29892,
4236,
29918,
24530,
29922,
8516,
1125,
13,
4706,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
353,
1426,
29918,
1990,
2450,
29918,
4299,
13,
4706,
1583,
29889,
1509,
29918,
355,
29918,
16506,
353,
671,
29918,
355,
29918,
16506,
13,
4706,
2295,
353,
15886,
29889,
3991,
1184,
517,
580,
13,
4706,
2295,
29889,
29887,
3746,
29918,
6768,
29889,
9536,
29918,
29887,
798,
386,
353,
5852,
13,
4706,
2428,
29898,
1626,
2385,
2450,
5323,
4983,
29892,
1583,
467,
1649,
2344,
12035,
1188,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
8783,
29922,
24713,
29892,
13,
462,
462,
462,
4706,
3414,
29918,
6550,
29922,
7662,
29918,
6550,
29892,
4236,
29918,
24530,
29922,
3317,
29918,
24530,
29892,
13,
462,
462,
462,
4706,
11819,
287,
29918,
26495,
29918,
7924,
29918,
2917,
29922,
2917,
29897,
13,
13,
1678,
822,
1904,
29898,
1311,
29892,
1881,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
29892,
3806,
29918,
21134,
29892,
9853,
29918,
2311,
29892,
13,
795,
7931,
370,
352,
653,
29918,
2311,
29922,
29963,
20166,
2882,
13309,
19926,
29918,
14226,
29892,
8297,
29881,
886,
29918,
2311,
29922,
29923,
9486,
3352,
29928,
4214,
29903,
29918,
14226,
29892,
1962,
29918,
13203,
29922,
29929,
1125,
13,
4706,
396,
8297,
29881,
886,
13,
4706,
8297,
29881,
886,
353,
903,
1359,
29918,
17987,
29881,
886,
29898,
29894,
542,
370,
352,
653,
29918,
2311,
29892,
8297,
29881,
886,
29918,
2311,
29897,
13,
13,
4706,
396,
5534,
4331,
13,
4706,
1583,
29889,
10945,
29918,
10568,
353,
6694,
29918,
4422,
29889,
657,
29918,
272,
29918,
3258,
29918,
10945,
29918,
10568,
580,
13,
13,
4706,
396,
1904,
13,
4706,
411,
2243,
326,
29889,
1191,
29918,
6078,
29898,
1311,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
4299,
29918,
1191,
29918,
6078,
580,
1125,
13,
9651,
14391,
353,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
4299,
29898,
2080,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
13,
462,
462,
462,
965,
18530,
29892,
19262,
29892,
1962,
29918,
13203,
29892,
13,
462,
462,
462,
965,
8297,
29881,
886,
29922,
17987,
29881,
886,
29892,
13,
462,
462,
462,
965,
9853,
29918,
2311,
29922,
16175,
29918,
2311,
29897,
13,
13,
4706,
396,
6410,
13,
4706,
22525,
353,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
5182,
29879,
29898,
9684,
29918,
21134,
29892,
1962,
29918,
13203,
29897,
13,
4706,
1583,
29889,
6758,
353,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
6758,
29898,
5182,
29879,
29892,
14391,
29897,
13,
4706,
15886,
29889,
7727,
29889,
19529,
279,
877,
6758,
742,
1583,
29889,
6758,
29897,
13,
13,
4706,
396,
6509,
6554,
13,
4706,
1583,
29889,
20640,
3950,
29892,
1583,
29889,
21891,
29918,
10492,
353,
320,
13,
9651,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
20640,
675,
29898,
1311,
29889,
6758,
29892,
1583,
29889,
10945,
29918,
10568,
29897,
13,
4706,
565,
1583,
29889,
21891,
29918,
10492,
338,
451,
6213,
29901,
13,
9651,
15886,
29889,
7727,
29889,
19529,
279,
877,
21891,
29918,
10492,
742,
1583,
29889,
21891,
29918,
10492,
29897,
13,
13,
4706,
396,
21556,
13,
4706,
1583,
29889,
2527,
10817,
353,
21556,
29889,
14369,
29918,
1643,
29898,
4905,
29879,
1839,
11965,
2463,
7464,
22525,
29897,
13,
13,
4706,
396,
872,
369,
304,
4078,
278,
1904,
13,
4706,
1583,
29889,
4977,
369,
353,
15886,
29889,
14968,
29889,
29903,
12483,
580,
13,
4706,
396,
1423,
263,
23432,
995,
297,
278,
6410,
13,
4706,
1583,
29889,
6758,
353,
15886,
29889,
3198,
29918,
8058,
1199,
29898,
1311,
29889,
6758,
29892,
525,
6758,
338,
23432,
1495,
13,
13,
4706,
736,
6213,
13,
13,
1678,
822,
1653,
29918,
4262,
29898,
1311,
29892,
8783,
29918,
20158,
29892,
9853,
29918,
2311,
1125,
13,
4706,
1881,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
29892,
3806,
29918,
21134,
353,
8783,
29918,
20158,
13,
4706,
565,
451,
1583,
29889,
1509,
29918,
355,
29918,
16506,
29901,
13,
9651,
1881,
29918,
726,
29918,
355,
353,
6213,
13,
4706,
736,
1583,
29889,
4299,
29898,
2080,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
29892,
3806,
29918,
21134,
29892,
9853,
29918,
2311,
29897,
13,
13,
1678,
822,
4331,
29898,
1311,
29892,
4867,
29892,
3983,
29918,
1272,
1125,
13,
4706,
301,
29878,
29892,
17117,
6410,
29892,
4331,
29892,
21556,
353,
320,
13,
9651,
4867,
29889,
3389,
4197,
1311,
29889,
21891,
29918,
10492,
29892,
1583,
29889,
20640,
3950,
29892,
1583,
29889,
6758,
29892,
1583,
29889,
10945,
29918,
10568,
29892,
13,
462,
308,
1583,
29889,
2527,
10817,
2314,
13,
4706,
565,
1583,
29889,
275,
29918,
305,
2575,
322,
931,
29889,
2230,
580,
1405,
1583,
29889,
2158,
29918,
16394,
718,
29871,
29945,
334,
29871,
29953,
29900,
29901,
13,
9651,
1583,
29889,
2158,
29918,
16394,
353,
931,
29889,
2230,
580,
13,
9651,
560,
28170,
29918,
2230,
353,
851,
29898,
9346,
287,
2554,
29898,
23128,
29922,
2230,
29889,
2230,
580,
448,
1583,
29889,
2344,
29918,
2230,
876,
13,
9651,
286,
353,
525,
10568,
29901,
6571,
29871,
6410,
29901,
12365,
29900,
29889,
29946,
29888,
29913,
29871,
6509,
29918,
10492,
353,
12365,
29900,
29889,
29953,
29888,
29913,
29871,
560,
28170,
6923,
29901,
6571,
29871,
525,
320,
13,
18884,
525,
17990,
2459,
29901,
6571,
29871,
17386,
29901,
6571,
29871,
13600,
29901,
6571,
29915,
13,
9651,
12183,
29889,
3888,
29898,
29885,
29889,
4830,
29898,
10568,
29892,
6410,
29892,
301,
29878,
29892,
560,
28170,
29918,
2230,
29892,
13,
462,
462,
29871,
21556,
1839,
17990,
2459,
7464,
21556,
1839,
3757,
497,
7464,
21556,
1839,
562,
2764,
4135,
25901,
13,
13,
1678,
822,
1156,
29918,
3258,
29918,
7924,
29898,
1311,
29892,
4867,
29892,
29311,
1125,
13,
4706,
1583,
29889,
2344,
29918,
2230,
353,
931,
29889,
2230,
580,
13,
4706,
1583,
29889,
2158,
29918,
16394,
353,
931,
29889,
2230,
580,
13,
13,
13,
1990,
3992,
2385,
2450,
3057,
29898,
24219,
1061,
29889,
29923,
4387,
1061,
1125,
13,
1678,
9995,
29923,
4387,
1061,
363,
13235,
6694,
15945,
29908,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
8783,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29892,
1962,
29918,
2084,
29892,
1480,
29918,
3972,
29922,
9464,
29918,
9472,
29918,
14480,
9464,
29892,
13,
462,
671,
29918,
355,
29918,
16506,
29922,
8824,
29892,
3317,
29918,
24530,
29922,
8516,
1125,
13,
4706,
1583,
29889,
1509,
29918,
355,
29918,
16506,
353,
671,
29918,
355,
29918,
16506,
13,
4706,
2295,
353,
15886,
29889,
3991,
1184,
517,
580,
13,
4706,
2295,
29889,
29887,
3746,
29918,
6768,
29889,
9536,
29918,
29887,
798,
386,
353,
5852,
13,
4706,
2428,
29898,
1626,
2385,
2450,
3057,
29892,
1583,
467,
1649,
2344,
12035,
3198,
9748,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
8783,
29922,
24713,
29892,
13,
462,
462,
462,
268,
1962,
29918,
2084,
29922,
4905,
29918,
2084,
29892,
4236,
29918,
24530,
29922,
3317,
29918,
24530,
29892,
13,
462,
462,
462,
268,
13512,
29918,
3712,
2105,
287,
29918,
7924,
29918,
2917,
29922,
2917,
29897,
13,
4706,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
353,
1426,
29918,
1990,
2450,
29918,
4299,
13,
4706,
1583,
29889,
14513,
29918,
13236,
353,
15886,
29889,
7727,
29889,
2283,
10507,
29898,
1188,
29918,
3972,
29897,
13,
13,
1678,
822,
1904,
29898,
1311,
29892,
1881,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
29892,
3806,
29918,
21134,
29892,
9853,
29918,
2311,
29892,
13,
795,
7931,
370,
352,
653,
29918,
2311,
29922,
29963,
20166,
2882,
13309,
19926,
29918,
14226,
29892,
8297,
29881,
886,
29918,
2311,
29922,
29923,
9486,
3352,
29928,
4214,
29903,
29918,
14226,
29892,
1962,
29918,
13203,
29922,
29929,
1125,
13,
4706,
396,
8297,
29881,
886,
13,
4706,
8297,
29881,
886,
353,
903,
1359,
29918,
17987,
29881,
886,
29898,
29894,
542,
370,
352,
653,
29918,
2311,
29892,
8297,
29881,
886,
29918,
2311,
29897,
13,
4706,
396,
1904,
13,
4706,
411,
2243,
326,
29889,
1191,
29918,
6078,
29898,
1311,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
4299,
29918,
1191,
29918,
6078,
580,
1125,
13,
9651,
14391,
353,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
4299,
29898,
2080,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
13,
462,
462,
462,
965,
18530,
29892,
19262,
29892,
1962,
29918,
13203,
29892,
13,
462,
462,
462,
965,
8297,
29881,
886,
29922,
17987,
29881,
886,
29892,
13,
462,
462,
462,
965,
9853,
29918,
2311,
29922,
16175,
29918,
2311,
29892,
13,
462,
462,
462,
965,
6694,
29922,
8824,
29897,
13,
4706,
396,
6410,
13,
4706,
22525,
353,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
5182,
29879,
29898,
9684,
29918,
21134,
29892,
1962,
29918,
13203,
29897,
13,
4706,
6410,
353,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
6758,
29898,
5182,
29879,
29892,
14391,
29897,
13,
4706,
1583,
29889,
5753,
398,
7964,
29918,
6758,
353,
15886,
29889,
16174,
29898,
29900,
29889,
29900,
29892,
26688,
29922,
13264,
29889,
7411,
29941,
29906,
29892,
1024,
2433,
5753,
398,
7964,
29918,
6758,
742,
13,
462,
462,
9651,
7945,
519,
29922,
8824,
29897,
13,
4706,
1583,
29889,
5753,
398,
7964,
29918,
6758,
353,
15886,
29889,
16645,
29918,
1202,
29898,
1311,
29889,
5753,
398,
7964,
29918,
6758,
29892,
6410,
29897,
13,
4706,
4331,
353,
15886,
29889,
16174,
29898,
29900,
29892,
26688,
29922,
13264,
29889,
524,
29941,
29906,
29892,
1024,
2433,
14513,
29918,
10568,
742,
7945,
519,
29922,
8824,
29897,
13,
4706,
4331,
29918,
262,
1037,
559,
353,
15886,
29889,
16645,
29918,
1202,
29898,
10568,
29892,
29871,
29896,
29897,
13,
4706,
1583,
29889,
6758,
353,
1583,
29889,
5753,
398,
7964,
29918,
6758,
847,
15886,
29889,
4384,
29898,
10568,
29918,
262,
1037,
559,
29892,
26688,
29922,
13264,
29889,
7411,
29941,
29906,
29897,
13,
4706,
15886,
29889,
7727,
29889,
19529,
279,
877,
6758,
742,
1583,
29889,
6758,
29897,
13,
4706,
396,
21556,
13,
4706,
1583,
29889,
2527,
10817,
353,
21556,
29889,
14369,
29918,
1643,
29898,
4905,
29879,
1839,
11965,
2463,
7464,
22525,
29892,
8401,
29918,
12483,
482,
29922,
8824,
29897,
13,
4706,
736,
6213,
13,
13,
1678,
822,
1653,
29918,
4262,
29898,
1311,
29892,
8783,
29918,
20158,
29892,
9853,
29918,
2311,
1125,
13,
4706,
1881,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
29892,
3806,
29918,
21134,
353,
8783,
29918,
20158,
13,
4706,
565,
451,
1583,
29889,
1509,
29918,
355,
29918,
16506,
29901,
13,
9651,
1881,
29918,
726,
29918,
355,
353,
6213,
13,
4706,
3983,
29918,
1272,
353,
1583,
29889,
4299,
29898,
2080,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
29892,
13,
462,
18884,
3806,
29918,
21134,
29892,
9853,
29918,
2311,
29897,
13,
4706,
736,
3983,
29918,
1272,
13,
13,
1678,
822,
4331,
29898,
1311,
29892,
4867,
29892,
3983,
29918,
1272,
29892,
15837,
29918,
459,
1125,
13,
4706,
15837,
29892,
1583,
29889,
6758,
29918,
2914,
29892,
1583,
29889,
2527,
10817,
29918,
9902,
353,
320,
13,
9651,
4867,
29889,
3389,
4197,
7727,
29918,
459,
29892,
1583,
29889,
6758,
29892,
1583,
29889,
2527,
10817,
2314,
13,
4706,
736,
15837,
13,
13,
1678,
822,
1095,
29898,
1311,
29892,
4867,
1125,
13,
4706,
2428,
29898,
1626,
2385,
2450,
3057,
29892,
1583,
467,
355,
29898,
7924,
29897,
13,
4706,
521,
29895,
29918,
10568,
353,
938,
29898,
1311,
29889,
4230,
342,
29918,
3198,
3149,
29889,
5451,
877,
29899,
1495,
14352,
29896,
2314,
13,
4706,
286,
353,
525,
10568,
29901,
6571,
29871,
6410,
29901,
12365,
29900,
29889,
29946,
29888,
29913,
29871,
16716,
29901,
6571,
29871,
17386,
29901,
6571,
29871,
13600,
29901,
6571,
29915,
13,
4706,
12183,
29889,
3888,
29898,
29885,
29889,
4830,
29898,
29570,
29918,
10568,
29892,
1583,
29889,
6758,
29918,
2914,
29892,
1583,
29889,
2527,
10817,
29918,
9902,
1839,
17990,
2459,
7464,
13,
462,
795,
1583,
29889,
2527,
10817,
29918,
9902,
1839,
3757,
497,
7464,
1583,
29889,
2527,
10817,
29918,
9902,
1839,
562,
2764,
4135,
25901,
13,
13,
1678,
822,
1156,
29918,
3258,
29918,
7924,
29898,
1311,
29892,
4867,
29892,
29311,
1125,
13,
4706,
396,
1423,
9748,
29918,
1445,
353,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
3198,
9748,
29918,
3972,
29892,
525,
3198,
3149,
1495,
13,
4706,
396,
5272,
29918,
3198,
9748,
29918,
3972,
353,
22372,
2403,
9392,
4286,
4830,
29898,
1311,
29889,
3198,
9748,
29918,
3972,
29897,
13,
4706,
396,
1053,
13149,
13,
4706,
396,
2066,
353,
13149,
29889,
23705,
877,
29912,
6822,
4299,
29889,
384,
415,
29899,
10521,
1272,
29899,
29930,
4286,
4830,
29898,
1997,
29918,
3198,
9748,
29918,
3972,
876,
13,
4706,
396,
521,
29895,
29918,
10568,
353,
29871,
29900,
13,
4706,
396,
363,
285,
297,
2066,
29901,
13,
4706,
396,
268,
954,
353,
285,
29889,
5451,
877,
4299,
29889,
384,
415,
29899,
29861,
29896,
1822,
5451,
12839,
29861,
29900,
29962,
13,
4706,
396,
268,
954,
353,
938,
29898,
1949,
29897,
13,
4706,
396,
268,
565,
521,
29895,
29918,
10568,
1275,
29871,
29900,
470,
954,
529,
521,
29895,
29918,
10568,
29901,
13,
4706,
396,
308,
521,
29895,
29918,
10568,
353,
954,
13,
4706,
396,
565,
521,
29895,
29918,
10568,
2804,
29871,
29900,
29901,
13,
4706,
396,
268,
274,
29895,
415,
29918,
5325,
353,
13149,
29889,
23705,
877,
29912,
6822,
4299,
29889,
384,
415,
29899,
29912,
1836,
1272,
29899,
29930,
4286,
4830,
29898,
1997,
29918,
3198,
9748,
29918,
3972,
29892,
521,
29895,
29918,
10568,
876,
13,
4706,
396,
268,
274,
29895,
415,
29918,
5325,
353,
518,
29916,
29889,
5451,
11219,
1495,
14352,
29896,
29962,
363,
921,
297,
274,
29895,
415,
29918,
5325,
29962,
13,
4706,
396,
268,
363,
285,
297,
274,
29895,
415,
29918,
5325,
718,
6024,
4299,
29889,
384,
415,
29899,
29912,
1836,
2248,
742,
525,
4299,
29889,
384,
415,
29899,
29912,
1836,
7299,
2033,
29901,
13,
4706,
396,
308,
285,
353,
285,
29889,
4830,
29898,
29570,
29918,
10568,
29897,
13,
4706,
396,
308,
2897,
29889,
1267,
420,
29898,
359,
29889,
2084,
29889,
7122,
29898,
1997,
29918,
3198,
9748,
29918,
3972,
29892,
285,
511,
2897,
29889,
2084,
29889,
7122,
29898,
1311,
29889,
3198,
9748,
29918,
3972,
29892,
285,
876,
13,
4706,
396,
268,
411,
1722,
29898,
3198,
9748,
29918,
1445,
29892,
525,
29893,
29890,
1495,
408,
285,
29901,
13,
4706,
396,
308,
285,
29889,
3539,
877,
4299,
29918,
3198,
3149,
29918,
2084,
29901,
376,
6904,
4299,
29889,
384,
415,
29899,
29912,
5038,
29905,
29876,
4286,
4830,
29898,
29570,
29918,
10568,
876,
13,
4706,
396,
308,
285,
29889,
3539,
877,
497,
29918,
4299,
29918,
3198,
3149,
29918,
24772,
29901,
376,
6904,
4299,
29889,
384,
415,
29899,
29912,
5038,
29905,
29876,
4286,
4830,
29898,
29570,
29918,
10568,
876,
13,
4706,
2428,
29898,
1626,
2385,
2450,
3057,
29892,
1583,
467,
7045,
29918,
3258,
29918,
7924,
29898,
7924,
29892,
29311,
29897,
13,
4706,
396,
411,
1722,
29898,
3198,
9748,
29918,
1445,
29892,
525,
29893,
29890,
1495,
408,
285,
29901,
13,
4706,
396,
268,
285,
29889,
3539,
877,
4299,
29918,
3198,
3149,
29918,
2084,
29901,
376,
6904,
4299,
29889,
384,
415,
29899,
26732,
29876,
1495,
13,
4706,
396,
268,
285,
29889,
3539,
877,
497,
29918,
4299,
29918,
3198,
3149,
29918,
24772,
29901,
376,
6904,
4299,
29889,
384,
415,
29899,
26732,
29876,
1495,
13,
13,
13,
1990,
3992,
2385,
2450,
29923,
791,
29898,
24219,
1061,
29889,
29923,
4387,
1061,
1125,
13,
1678,
9995,
29923,
4387,
1061,
363,
1426,
12965,
15945,
29908,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
8783,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29892,
1962,
29918,
2084,
29892,
1480,
29918,
3972,
29922,
9464,
29918,
9472,
29918,
14480,
9464,
29892,
13,
462,
671,
29918,
355,
29918,
16506,
29922,
8824,
1125,
13,
4706,
1583,
29889,
1509,
29918,
355,
29918,
16506,
353,
671,
29918,
355,
29918,
16506,
13,
4706,
2295,
353,
15886,
29889,
3991,
1184,
517,
580,
13,
4706,
2295,
29889,
29887,
3746,
29918,
6768,
29889,
9536,
29918,
29887,
798,
386,
353,
5852,
13,
4706,
2428,
29898,
1626,
2385,
2450,
29923,
791,
29892,
1583,
467,
1649,
2344,
12035,
3198,
9748,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
13,
462,
462,
462,
268,
1962,
29918,
2084,
29922,
4905,
29918,
2084,
29892,
13,
462,
462,
462,
268,
10362,
29918,
7888,
29922,
8824,
29892,
13,
462,
462,
462,
268,
13512,
29918,
3712,
2105,
287,
29918,
7924,
29918,
2917,
29922,
2917,
29897,
13,
4706,
1583,
29889,
24713,
353,
8783,
13,
4706,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
353,
1426,
29918,
1990,
2450,
29918,
4299,
13,
13,
1678,
822,
1904,
29898,
1311,
29892,
1881,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
29892,
9853,
29918,
2311,
29892,
13,
795,
7931,
370,
352,
653,
29918,
2311,
29922,
29963,
20166,
2882,
13309,
19926,
29918,
14226,
29892,
8297,
29881,
886,
29918,
2311,
29922,
29923,
9486,
3352,
29928,
4214,
29903,
29918,
14226,
29892,
1962,
29918,
13203,
29922,
29929,
1125,
13,
4706,
396,
8297,
29881,
886,
13,
4706,
8297,
29881,
886,
353,
903,
1359,
29918,
17987,
29881,
886,
29898,
29894,
542,
370,
352,
653,
29918,
2311,
29892,
8297,
29881,
886,
29918,
2311,
29897,
13,
4706,
396,
5534,
4331,
13,
4706,
1583,
29889,
10945,
29918,
10568,
353,
6694,
29918,
4422,
29889,
657,
29918,
272,
29918,
3258,
29918,
10945,
29918,
10568,
580,
13,
4706,
1583,
29889,
10945,
29918,
10568,
353,
15886,
29889,
16645,
29918,
1202,
29898,
1311,
29889,
10945,
29918,
10568,
29892,
29871,
29896,
29897,
13,
4706,
396,
1904,
13,
4706,
411,
15886,
29889,
6451,
29918,
22594,
4197,
1311,
29889,
10945,
29918,
10568,
29962,
1125,
13,
9651,
411,
2243,
326,
29889,
1191,
29918,
6078,
29898,
1311,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
4299,
29918,
1191,
29918,
6078,
580,
1125,
13,
18884,
1583,
29889,
4905,
29879,
353,
1583,
29889,
726,
29918,
1990,
2450,
29918,
4299,
29889,
4299,
29898,
2080,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
13,
462,
462,
462,
462,
1678,
18530,
29892,
19262,
29892,
1962,
29918,
13203,
29892,
13,
462,
462,
462,
462,
1678,
8297,
29881,
886,
29922,
17987,
29881,
886,
29892,
13,
462,
462,
462,
462,
1678,
9853,
29918,
2311,
29922,
16175,
29918,
2311,
29892,
13,
462,
462,
462,
462,
1678,
6694,
29922,
8824,
29897,
13,
4706,
396,
17749,
871,
278,
7945,
519,
3651,
13,
4706,
1583,
29889,
4977,
369,
353,
15886,
29889,
14968,
29889,
29903,
12483,
29898,
1707,
29918,
1761,
29922,
13264,
29918,
20897,
29889,
14968,
519,
29918,
20897,
3101,
13,
4706,
736,
1583,
29889,
4905,
29879,
13,
13,
1678,
822,
1653,
29918,
4262,
29898,
1311,
29892,
8783,
29918,
20158,
29892,
9853,
29918,
2311,
1125,
13,
4706,
1881,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
353,
8783,
29918,
20158,
13,
4706,
565,
451,
1583,
29889,
1509,
29918,
355,
29918,
16506,
29901,
13,
9651,
1881,
29918,
726,
29918,
355,
353,
6213,
13,
4706,
736,
1583,
29889,
4299,
29898,
2080,
29918,
726,
29918,
463,
29892,
1881,
29918,
726,
29918,
355,
29892,
18530,
29892,
19262,
29892,
9853,
29918,
2311,
29897,
13,
13,
1678,
822,
1156,
29918,
3258,
29918,
7924,
29898,
1311,
29892,
4867,
29892,
29311,
1125,
13,
4706,
2428,
29898,
1626,
2385,
2450,
29923,
791,
29892,
1583,
467,
7045,
29918,
3258,
29918,
7924,
29898,
7924,
29892,
29311,
29897,
13,
4706,
1596,
877,
1367,
29892,
1990,
29896,
29892,
1990,
29906,
29892,
1990,
29941,
29892,
1990,
29946,
29892,
1990,
29945,
29892,
1990,
29953,
29892,
1990,
29955,
29892,
1990,
29947,
29892,
1990,
29929,
1495,
13,
13,
1678,
822,
4331,
29898,
1311,
29892,
4867,
29892,
3983,
29918,
1272,
29892,
15837,
29918,
459,
1125,
13,
4706,
4331,
29892,
27303,
353,
4867,
29889,
3389,
4197,
1311,
29889,
10945,
29918,
10568,
29892,
1583,
29889,
4905,
29879,
1839,
11965,
2463,
2033,
2314,
13,
4706,
27303,
353,
27303,
29961,
29900,
29962,
13,
4706,
27303,
353,
518,
29886,
718,
29871,
29900,
29889,
29900,
29896,
363,
282,
297,
27303,
29962,
29871,
396,
6584,
284,
675,
3109,
278,
28947,
13,
4706,
2533,
353,
7442,
29889,
2083,
29898,
27711,
1080,
29897,
13,
4706,
27303,
353,
518,
29886,
847,
2533,
363,
282,
297,
27303,
29962,
13,
4706,
1596,
877,
29912,
1118,
8875,
4286,
4830,
29898,
10568,
29892,
13420,
4286,
7122,
18959,
25641,
29889,
29941,
29888,
29913,
4286,
4830,
29898,
29916,
29897,
363,
921,
297,
27303,
29962,
4961,
13,
4706,
736,
6213,
13,
13,
13,
5215,
12183,
13,
13,
13,
1753,
1667,
29898,
4299,
29892,
1024,
29892,
10541,
29918,
5451,
29922,
8824,
29892,
1095,
29918,
16506,
29922,
17171,
29918,
11794,
29918,
1660,
13356,
1430,
4741,
29892,
9853,
29918,
2311,
29922,
9472,
29918,
29933,
14789,
29918,
14226,
1125,
13,
1678,
9995,
13,
1678,
4241,
1158,
304,
6222,
278,
1426,
29918,
1990,
2450,
4733,
13,
1678,
584,
3207,
8125,
15427,
1904,
29901,
1203,
1904,
2729,
373,
8125,
15427,
13,
1678,
584,
3207,
851,
1024,
29901,
1024,
310,
278,
1904,
13,
1678,
584,
3207,
6120,
10541,
29918,
5451,
29901,
3692,
304,
6219,
278,
8783,
297,
2665,
484,
778,
470,
451,
29892,
13,
1678,
871,
1304,
363,
298,
1131,
1904,
13,
1678,
584,
3207,
6120,
1095,
29918,
16506,
29901,
3692,
304,
671,
470,
451,
278,
1095,
310,
278,
15602,
297,
278,
4733,
13,
1678,
584,
3207,
938,
9853,
29918,
2311,
29901,
9853,
2159,
310,
278,
4733,
13,
1678,
9995,
13,
1678,
12183,
29889,
657,
16363,
2141,
842,
10108,
29898,
21027,
29889,
11690,
29897,
13,
1678,
1480,
29918,
3972,
353,
22372,
3227,
29913,
4286,
4830,
29898,
9464,
29918,
9472,
29918,
14480,
9464,
29892,
1024,
29897,
13,
1678,
565,
7431,
29898,
9675,
29889,
19218,
29897,
1405,
29871,
29896,
322,
10876,
29889,
19218,
29961,
29896,
29962,
1275,
525,
1688,
2396,
13,
4706,
396,
6222,
278,
1243,
411,
278,
7945,
8783,
13,
4706,
8783,
353,
3992,
2385,
2450,
16390,
24541,
29898,
1853,
2433,
14968,
742,
10541,
29918,
5451,
29922,
18616,
663,
29918,
5451,
29897,
13,
4706,
1243,
261,
353,
3992,
2385,
2450,
3057,
29898,
24713,
29922,
24713,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29922,
4299,
29892,
13,
462,
462,
4706,
1480,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
13,
462,
462,
4706,
1962,
29918,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
1188,
29918,
3972,
29892,
525,
1688,
29918,
14968,
842,
5477,
13,
462,
462,
4706,
671,
29918,
355,
29918,
16506,
29922,
355,
29918,
16506,
29897,
13,
4706,
1243,
261,
29889,
3389,
580,
13,
1678,
25342,
7431,
29898,
9675,
29889,
19218,
29897,
1405,
29871,
29896,
322,
10876,
29889,
19218,
29961,
29896,
29962,
1275,
525,
15480,
2396,
13,
4706,
8783,
353,
3992,
2385,
2450,
16390,
24541,
29898,
1853,
2433,
791,
742,
10541,
29918,
5451,
29922,
18616,
663,
29918,
5451,
29897,
13,
4706,
1243,
261,
353,
3992,
2385,
2450,
3057,
29898,
24713,
29922,
24713,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29922,
4299,
29892,
13,
462,
462,
4706,
1480,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
13,
462,
462,
4706,
1962,
29918,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
1188,
29918,
3972,
29892,
525,
15480,
5477,
13,
462,
462,
4706,
671,
29918,
355,
29918,
16506,
29922,
355,
29918,
16506,
29897,
13,
4706,
1243,
261,
29889,
3389,
580,
13,
1678,
25342,
7431,
29898,
9675,
29889,
19218,
29897,
1405,
29871,
29896,
322,
10876,
29889,
19218,
29961,
29896,
29962,
1275,
525,
14513,
2396,
13,
4706,
396,
14707,
278,
848,
310,
278,
1243,
8783,
29889,
1334,
9752,
445,
1962,
304,
413,
351,
6234,
13,
4706,
8783,
353,
3992,
2385,
2450,
16390,
24541,
29898,
1853,
2433,
1688,
742,
10541,
29918,
5451,
29922,
18616,
663,
29918,
5451,
29897,
13,
4706,
6161,
1061,
353,
3992,
2385,
2450,
29923,
791,
29898,
24713,
29922,
24713,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29922,
4299,
29892,
13,
462,
462,
965,
1480,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
13,
462,
462,
965,
1962,
29918,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
1188,
29918,
3972,
29892,
525,
1688,
5477,
13,
462,
462,
965,
671,
29918,
355,
29918,
16506,
29922,
355,
29918,
16506,
29897,
13,
4706,
6161,
1061,
29889,
3389,
580,
13,
1678,
25342,
7431,
29898,
9675,
29889,
19218,
29897,
1405,
29871,
29896,
322,
10876,
29889,
19218,
29961,
29896,
29962,
1275,
525,
14513,
29918,
19190,
29906,
2396,
13,
4706,
396,
14707,
278,
848,
310,
278,
1243,
8783,
29889,
1334,
9752,
445,
1962,
304,
413,
351,
6234,
13,
4706,
8783,
353,
3992,
2385,
2450,
16390,
24541,
29898,
1853,
2433,
19190,
29906,
29918,
1688,
742,
10541,
29918,
5451,
29922,
18616,
663,
29918,
5451,
29897,
13,
4706,
6161,
1061,
353,
3992,
2385,
2450,
29923,
791,
29898,
24713,
29922,
24713,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29922,
4299,
29892,
13,
462,
462,
965,
1480,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
13,
462,
462,
965,
1962,
29918,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
1188,
29918,
3972,
29892,
525,
1688,
29918,
19190,
29906,
5477,
13,
462,
462,
965,
671,
29918,
355,
29918,
16506,
29922,
355,
29918,
16506,
29897,
13,
4706,
6161,
1061,
29889,
3389,
580,
13,
1678,
1683,
29901,
13,
4706,
396,
6694,
13,
4706,
3414,
29918,
6550,
353,
679,
29918,
7662,
29918,
6550,
29898,
2541,
29918,
24219,
1061,
29922,
17171,
29918,
4375,
1254,
29918,
11686,
29968,
1001,
29918,
22051,
29918,
26707,
8098,
29897,
13,
4706,
565,
3414,
29918,
6550,
29889,
7122,
29918,
361,
29918,
567,
7295,
13,
9651,
396,
5988,
565,
372,
338,
263,
4128,
1923,
322,
437,
3078,
1683,
13,
9651,
736,
13,
13,
4706,
411,
29898,
13264,
29889,
29887,
1445,
29889,
6585,
29898,
359,
29889,
2084,
29889,
7122,
29898,
9464,
29918,
14573,
29918,
16975,
29918,
13875,
1799,
6545,
28541,
29892,
525,
14968,
29918,
842,
29915,
4961,
408,
285,
29901,
13,
9651,
4236,
29918,
24530,
353,
938,
29898,
9472,
29918,
29923,
13152,
3210,
29903,
334,
7431,
29898,
29888,
29889,
949,
9012,
3101,
847,
9853,
29918,
2311,
29897,
13,
13,
4706,
565,
3414,
29918,
6550,
29889,
275,
29918,
24219,
1061,
7295,
13,
9651,
8783,
353,
3992,
2385,
2450,
16390,
24541,
29898,
1853,
2433,
791,
742,
10541,
29918,
5451,
29922,
18616,
663,
29918,
5451,
29897,
13,
9651,
396,
6161,
1061,
2734,
297,
278,
1833,
15645,
13,
9651,
1243,
261,
353,
3992,
2385,
2450,
3057,
29898,
24713,
29922,
24713,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29922,
4299,
29892,
13,
462,
462,
9651,
1480,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
13,
462,
462,
9651,
1962,
29918,
2084,
29922,
359,
29889,
2084,
29889,
7122,
29898,
1188,
29918,
3972,
29892,
525,
791,
5477,
13,
462,
462,
9651,
671,
29918,
355,
29918,
16506,
29922,
355,
29918,
16506,
29892,
13,
462,
462,
9651,
4236,
29918,
24530,
29922,
3317,
29918,
24530,
29897,
13,
9651,
1243,
261,
29889,
3389,
580,
13,
4706,
1683,
29901,
13,
9651,
8783,
353,
3992,
2385,
2450,
16390,
24541,
29898,
1853,
2433,
14968,
742,
10541,
29918,
5451,
29922,
18616,
663,
29918,
5451,
29897,
13,
9651,
1020,
4983,
353,
3992,
2385,
2450,
5323,
4983,
29898,
24713,
29922,
24713,
29892,
1426,
29918,
1990,
2450,
29918,
4299,
29922,
4299,
29892,
13,
462,
462,
18884,
1480,
29918,
3972,
29922,
1188,
29918,
3972,
29892,
671,
29918,
355,
29918,
16506,
29922,
355,
29918,
16506,
29892,
13,
462,
462,
18884,
3414,
29918,
6550,
29922,
7662,
29918,
6550,
29892,
4236,
29918,
24530,
29922,
3317,
29918,
24530,
29897,
13,
9651,
1020,
4983,
29889,
3389,
29898,
1022,
2878,
29879,
29922,
9472,
29918,
29923,
13152,
3210,
29903,
29892,
9853,
29918,
2311,
29922,
16175,
29918,
2311,
29897,
13,
2
] |
tests/test_middleware/test_pure_asgi_middleware.py | adamantike/starlette-context | 242 | 73327 | <reponame>adamantike/starlette-context
from starlette import status
from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette.requests import Request
from starlette.responses import JSONResponse
from starlette.testclient import TestClient
from starlette_context import context, plugins
from starlette_context.header_keys import HeaderKeys
from starlette_context.middleware import RawContextMiddleware
plugins_to_use = (
plugins.CorrelationIdPlugin(),
plugins.RequestIdPlugin(),
plugins.UserAgentPlugin(),
plugins.ForwardedForPlugin(),
plugins.DateHeaderPlugin(),
)
middleware = [
Middleware(
RawContextMiddleware,
plugins=plugins_to_use,
)
]
app = Starlette(middleware=middleware)
client = TestClient(app)
@app.route("/")
async def index(request: Request) -> JSONResponse:
return JSONResponse(content=context.data)
def test_valid_request():
resp = client.get("/")
assert resp.status_code == status.HTTP_200_OK
for plugin in plugins_to_use:
assert plugin.key in resp.text
assert HeaderKeys.correlation_id in resp.headers
assert HeaderKeys.request_id in resp.headers
| [
1,
529,
276,
1112,
420,
29958,
328,
314,
3656,
446,
29914,
8508,
20200,
29899,
4703,
13,
3166,
5810,
20200,
1053,
4660,
13,
3166,
5810,
20200,
29889,
932,
5795,
1053,
7828,
20200,
13,
3166,
5810,
20200,
29889,
17662,
2519,
1053,
14253,
2519,
13,
3166,
5810,
20200,
29889,
24830,
1053,
10729,
13,
3166,
5810,
20200,
29889,
26679,
267,
1053,
4663,
5103,
13,
3166,
5810,
20200,
29889,
1688,
4645,
1053,
4321,
4032,
13,
13,
3166,
5810,
20200,
29918,
4703,
1053,
3030,
29892,
18224,
13,
3166,
5810,
20200,
29918,
4703,
29889,
6672,
29918,
8149,
1053,
19345,
15506,
13,
3166,
5810,
20200,
29918,
4703,
29889,
17662,
2519,
1053,
22038,
2677,
25411,
2519,
13,
13,
12800,
29918,
517,
29918,
1509,
353,
313,
13,
1678,
18224,
29889,
12521,
23445,
1204,
16288,
3285,
13,
1678,
18224,
29889,
3089,
1204,
16288,
3285,
13,
1678,
18224,
29889,
2659,
19661,
16288,
3285,
13,
1678,
18224,
29889,
2831,
1328,
287,
2831,
16288,
3285,
13,
1678,
18224,
29889,
2539,
7850,
16288,
3285,
13,
29897,
13,
13,
17662,
2519,
353,
518,
13,
1678,
14253,
2519,
29898,
13,
4706,
22038,
2677,
25411,
2519,
29892,
13,
4706,
18224,
29922,
12800,
29918,
517,
29918,
1509,
29892,
13,
1678,
1723,
13,
29962,
13,
13,
932,
353,
7828,
20200,
29898,
17662,
2519,
29922,
17662,
2519,
29897,
13,
4645,
353,
4321,
4032,
29898,
932,
29897,
13,
13,
13,
29992,
932,
29889,
13134,
11974,
1159,
13,
12674,
822,
2380,
29898,
3827,
29901,
10729,
29897,
1599,
4663,
5103,
29901,
13,
1678,
736,
4663,
5103,
29898,
3051,
29922,
4703,
29889,
1272,
29897,
13,
13,
13,
1753,
1243,
29918,
3084,
29918,
3827,
7295,
13,
1678,
4613,
353,
3132,
29889,
657,
11974,
1159,
13,
13,
1678,
4974,
4613,
29889,
4882,
29918,
401,
1275,
4660,
29889,
10493,
29918,
29906,
29900,
29900,
29918,
8949,
13,
13,
1678,
363,
7079,
297,
18224,
29918,
517,
29918,
1509,
29901,
13,
4706,
4974,
7079,
29889,
1989,
297,
4613,
29889,
726,
13,
13,
1678,
4974,
19345,
15506,
29889,
2616,
23445,
29918,
333,
297,
4613,
29889,
13662,
13,
1678,
4974,
19345,
15506,
29889,
3827,
29918,
333,
297,
4613,
29889,
13662,
13,
2
] |
corehq/ex-submodules/casexml/apps/phone/fixtures.py | johan--/commcare-hq | 0 | 196102 | <gh_stars>0
from collections import namedtuple
from casexml.apps.case.xml import V1
from django.conf import settings
from corehq.apps.users.models import CommCareUser
from dimagi.utils.modules import to_function
import itertools
class FixtureGenerator(object):
"""
The generator object, which gets fixtures from your config file that should
be included when OTA restoring.
See: https://bitbucket.org/javarosa/javarosa/wiki/externalinstances
To use, add the following to your settings.py
FIXTURE_GENERATORS = {
'group1': [
"myapp.fixturegenerators.gen1",
"myapp.fixturegenerators.gen2",
...
],
...
}
The values in the file should be paths to objects that
implement the following API:
provider(user, version, last_sync) --> [list of fixture objects]
provider.id --> the ID of the fixture
If the provider generates multiple fixtures it should use an ID format as follows:
"prefix:dynamic"
In this case 'provider.id' should just be the ID prefix.
The function should return an empty list if there are no fixtures
"""
def __init__(self):
self._generator_providers = {}
if hasattr(settings, "FIXTURE_GENERATORS"):
for group, func_paths in settings.FIXTURE_GENERATORS.items():
self._generator_providers[group] = filter(None, [
to_function(func_path) for func_path in func_paths
])
def _get_fixtures(self, group, fixture_id, user, version, last_sync):
if version == V1:
return [] # V1 phones will never use or want fixtures
if getattr(user, "_hq_user", False):
user = user._hq_user
if not isinstance(user, CommCareUser):
return []
if group:
providers = self._generator_providers.get(group, [])
else:
providers = itertools.chain(*self._generator_providers.values())
if fixture_id:
full_id = fixture_id
prefix = fixture_id.split(':', 1)[0]
def provider_matches(provider):
# some providers generate fixtures with dynamic ID's e.g. item-list:my-item-list
# in which case provider.id is just the prefix.
return provider.id == full_id or provider.id == prefix
providers = [provider for provider in providers if provider_matches(provider)]
return itertools.chain(*[provider(user, version, last_sync)
for provider in providers])
def get_fixture_by_id(self, fixture_id, user, version, last_sync=None):
"""
Only get fixtures with the specified ID.
"""
fixtures = self._get_fixtures(None, fixture_id, user, version, last_sync)
for fixture in fixtures:
if fixture.attrib.get("id") == fixture_id:
return fixture
def get_fixtures(self, user, version, last_sync=None, group=None):
"""
Gets all fixtures associated with an OTA restore operation
"""
return self._get_fixtures(group, None, user, version, last_sync)
generator = FixtureGenerator()
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29900,
13,
3166,
16250,
1053,
4257,
23583,
13,
3166,
1206,
3134,
29889,
13371,
29889,
4878,
29889,
3134,
1053,
478,
29896,
13,
3166,
9557,
29889,
5527,
1053,
6055,
13,
3166,
7136,
29882,
29939,
29889,
13371,
29889,
7193,
29889,
9794,
1053,
1876,
29907,
598,
2659,
13,
3166,
3964,
17698,
29889,
13239,
29889,
7576,
1053,
304,
29918,
2220,
13,
5215,
4256,
8504,
13,
13,
13,
1990,
383,
29875,
15546,
21575,
29898,
3318,
1125,
13,
1678,
9995,
13,
1678,
450,
15299,
1203,
29892,
607,
4947,
5713,
486,
1973,
515,
596,
2295,
934,
393,
881,
13,
1678,
367,
5134,
746,
438,
6040,
1791,
8253,
29889,
13,
268,
13,
1678,
2823,
29901,
2045,
597,
2966,
21454,
29889,
990,
29914,
9494,
279,
3628,
29914,
9494,
279,
3628,
29914,
4594,
29914,
23176,
2611,
2925,
13,
268,
13,
1678,
1763,
671,
29892,
788,
278,
1494,
304,
596,
6055,
29889,
2272,
13,
268,
13,
1678,
383,
6415,
29911,
11499,
29918,
24647,
1001,
1299,
24125,
353,
426,
13,
4706,
525,
2972,
29896,
2396,
518,
13,
965,
376,
1357,
932,
29889,
7241,
15546,
4738,
4097,
29889,
1885,
29896,
613,
13,
965,
376,
1357,
932,
29889,
7241,
15546,
4738,
4097,
29889,
1885,
29906,
613,
13,
9651,
2023,
13,
4706,
21251,
13,
4706,
2023,
13,
1678,
500,
13,
268,
13,
1678,
450,
1819,
297,
278,
934,
881,
367,
10898,
304,
3618,
393,
13,
1678,
2334,
278,
1494,
3450,
29901,
13,
268,
13,
1678,
13113,
29898,
1792,
29892,
1873,
29892,
1833,
29918,
16593,
29897,
6660,
518,
1761,
310,
5713,
15546,
3618,
29962,
13,
1678,
13113,
29889,
333,
6660,
278,
3553,
310,
278,
5713,
15546,
13,
13,
1678,
960,
278,
13113,
16785,
2999,
5713,
486,
1973,
372,
881,
671,
385,
3553,
3402,
408,
4477,
29901,
13,
4706,
376,
13506,
29901,
16626,
29908,
13,
1678,
512,
445,
1206,
525,
18121,
29889,
333,
29915,
881,
925,
367,
278,
3553,
10944,
29889,
13,
268,
13,
1678,
450,
740,
881,
736,
385,
4069,
1051,
565,
727,
526,
694,
5713,
486,
1973,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
1583,
3032,
27959,
29918,
771,
29454,
353,
6571,
13,
4706,
565,
756,
5552,
29898,
11027,
29892,
376,
3738,
12188,
11499,
29918,
24647,
1001,
1299,
24125,
29908,
1125,
13,
9651,
363,
2318,
29892,
3653,
29918,
24772,
297,
6055,
29889,
3738,
12188,
11499,
29918,
24647,
1001,
1299,
24125,
29889,
7076,
7295,
13,
18884,
1583,
3032,
27959,
29918,
771,
29454,
29961,
2972,
29962,
353,
4175,
29898,
8516,
29892,
518,
13,
462,
1678,
304,
29918,
2220,
29898,
9891,
29918,
2084,
29897,
363,
3653,
29918,
2084,
297,
3653,
29918,
24772,
13,
462,
2314,
13,
13,
1678,
822,
903,
657,
29918,
7241,
486,
1973,
29898,
1311,
29892,
2318,
29892,
5713,
15546,
29918,
333,
29892,
1404,
29892,
1873,
29892,
1833,
29918,
16593,
1125,
13,
4706,
565,
1873,
1275,
478,
29896,
29901,
13,
9651,
736,
5159,
29871,
396,
478,
29896,
1374,
2873,
674,
2360,
671,
470,
864,
5713,
486,
1973,
13,
13,
4706,
565,
679,
5552,
29898,
1792,
29892,
11119,
29882,
29939,
29918,
1792,
613,
7700,
1125,
13,
9651,
1404,
353,
1404,
3032,
29882,
29939,
29918,
1792,
13,
13,
4706,
565,
451,
338,
8758,
29898,
1792,
29892,
1876,
29907,
598,
2659,
1125,
13,
9651,
736,
5159,
13,
13,
4706,
565,
2318,
29901,
13,
9651,
1326,
11376,
353,
1583,
3032,
27959,
29918,
771,
29454,
29889,
657,
29898,
2972,
29892,
518,
2314,
13,
4706,
1683,
29901,
13,
9651,
1326,
11376,
353,
4256,
8504,
29889,
14153,
10456,
1311,
3032,
27959,
29918,
771,
29454,
29889,
5975,
3101,
13,
13,
4706,
565,
5713,
15546,
29918,
333,
29901,
13,
9651,
2989,
29918,
333,
353,
5713,
15546,
29918,
333,
13,
9651,
10944,
353,
5713,
15546,
29918,
333,
29889,
5451,
877,
29901,
742,
29871,
29896,
9601,
29900,
29962,
13,
13,
9651,
822,
13113,
29918,
20317,
29898,
18121,
1125,
13,
18884,
396,
777,
1326,
11376,
5706,
5713,
486,
1973,
411,
7343,
3553,
29915,
29879,
321,
29889,
29887,
29889,
2944,
29899,
1761,
29901,
1357,
29899,
667,
29899,
1761,
13,
18884,
396,
297,
607,
1206,
13113,
29889,
333,
338,
925,
278,
10944,
29889,
13,
18884,
736,
13113,
29889,
333,
1275,
2989,
29918,
333,
470,
13113,
29889,
333,
1275,
10944,
13,
13,
9651,
1326,
11376,
353,
518,
18121,
363,
13113,
297,
1326,
11376,
565,
13113,
29918,
20317,
29898,
18121,
4638,
13,
13,
4706,
736,
4256,
8504,
29889,
14153,
10456,
29961,
18121,
29898,
1792,
29892,
1873,
29892,
1833,
29918,
16593,
29897,
13,
462,
462,
363,
13113,
297,
1326,
11376,
2314,
13,
13,
1678,
822,
679,
29918,
7241,
15546,
29918,
1609,
29918,
333,
29898,
1311,
29892,
5713,
15546,
29918,
333,
29892,
1404,
29892,
1873,
29892,
1833,
29918,
16593,
29922,
8516,
1125,
13,
4706,
9995,
13,
4706,
9333,
679,
5713,
486,
1973,
411,
278,
6790,
3553,
29889,
13,
4706,
9995,
13,
4706,
5713,
486,
1973,
353,
1583,
3032,
657,
29918,
7241,
486,
1973,
29898,
8516,
29892,
5713,
15546,
29918,
333,
29892,
1404,
29892,
1873,
29892,
1833,
29918,
16593,
29897,
13,
4706,
363,
5713,
15546,
297,
5713,
486,
1973,
29901,
13,
9651,
565,
5713,
15546,
29889,
1131,
1091,
29889,
657,
703,
333,
1159,
1275,
5713,
15546,
29918,
333,
29901,
13,
18884,
736,
5713,
15546,
13,
13,
1678,
822,
679,
29918,
7241,
486,
1973,
29898,
1311,
29892,
1404,
29892,
1873,
29892,
1833,
29918,
16593,
29922,
8516,
29892,
2318,
29922,
8516,
1125,
13,
4706,
9995,
13,
4706,
402,
1691,
599,
5713,
486,
1973,
6942,
411,
385,
438,
6040,
17749,
5858,
13,
4706,
9995,
13,
4706,
736,
1583,
3032,
657,
29918,
7241,
486,
1973,
29898,
2972,
29892,
6213,
29892,
1404,
29892,
1873,
29892,
1833,
29918,
16593,
29897,
13,
13,
13,
27959,
353,
383,
29875,
15546,
21575,
580,
13,
2
] |
src/modax/layers/network.py | GJBoth/modax | 2 | 36463 | from typing import Callable
from jax import lax
from flax import linen as nn
class MultiTaskDense(nn.Module):
features: int
n_tasks: int
kernel_init: Callable = nn.initializers.lecun_normal()
bias_init: Callable = nn.initializers.zeros
@nn.compact
def __call__(self, inputs):
kernel = self.param(
"kernel", self.kernel_init, (self.n_tasks, inputs.shape[-1], self.features)
)
y = lax.dot_general(
inputs, kernel, dimension_numbers=(((2,), (1,)), ((0,), (0,)))
)
bias = self.param("bias", self.bias_init, (self.n_tasks, 1, self.features))
y = y + bias
return y
| [
1,
515,
19229,
1053,
8251,
519,
13,
3166,
432,
1165,
1053,
425,
29916,
13,
3166,
17422,
29916,
1053,
6276,
264,
408,
302,
29876,
13,
13,
13,
1990,
14974,
5398,
29928,
1947,
29898,
15755,
29889,
7355,
1125,
13,
1678,
5680,
29901,
938,
13,
1678,
302,
29918,
20673,
29901,
938,
13,
1678,
8466,
29918,
2344,
29901,
8251,
519,
353,
302,
29876,
29889,
11228,
19427,
29889,
280,
29883,
348,
29918,
8945,
580,
13,
1678,
24003,
29918,
2344,
29901,
8251,
519,
353,
302,
29876,
29889,
11228,
19427,
29889,
3298,
359,
13,
13,
1678,
732,
15755,
29889,
2388,
627,
13,
1678,
822,
4770,
4804,
12035,
1311,
29892,
10970,
1125,
13,
4706,
8466,
353,
1583,
29889,
3207,
29898,
13,
9651,
376,
17460,
613,
1583,
29889,
17460,
29918,
2344,
29892,
313,
1311,
29889,
29876,
29918,
20673,
29892,
10970,
29889,
12181,
14352,
29896,
1402,
1583,
29889,
22100,
29897,
13,
4706,
1723,
13,
4706,
343,
353,
425,
29916,
29889,
6333,
29918,
17492,
29898,
13,
9651,
10970,
29892,
8466,
29892,
9927,
29918,
20326,
29922,
3552,
29898,
29906,
29892,
511,
313,
29896,
29892,
8243,
5135,
29900,
29892,
511,
313,
29900,
29892,
4961,
13,
4706,
1723,
13,
4706,
24003,
353,
1583,
29889,
3207,
703,
29890,
3173,
613,
1583,
29889,
29890,
3173,
29918,
2344,
29892,
313,
1311,
29889,
29876,
29918,
20673,
29892,
29871,
29896,
29892,
1583,
29889,
22100,
876,
13,
4706,
343,
353,
343,
718,
24003,
13,
4706,
736,
343,
13,
2
] |
mmdet/models/backbones/cspresnet.py | jie311/miemiedetection | 65 | 120322 | # Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmdet.models.ops import get_act_fn
from mmdet.models.custom_layers import ShapeSpec
class ConvBNLayer(nn.Module):
def __init__(self,
ch_in,
ch_out,
filter_size=3,
stride=1,
groups=1,
padding=0,
act=None):
super(ConvBNLayer, self).__init__()
self.conv = nn.Conv2d(
in_channels=ch_in,
out_channels=ch_out,
kernel_size=filter_size,
stride=stride,
padding=padding,
groups=groups,
bias=False)
self.bn = nn.BatchNorm2d(ch_out)
self.act = get_act_fn(act) if act is None or isinstance(act, (
str, dict)) else act
def forward(self, x):
x = self.conv(x)
x = self.bn(x)
x = self.act(x)
return x
def add_param_group(self, param_groups, base_lr, base_wd, need_clip, clip_norm):
if isinstance(self.conv, torch.nn.Conv2d):
if self.conv.weight.requires_grad:
param_group_conv = {'params': [self.conv.weight]}
param_group_conv['lr'] = base_lr * 1.0
param_group_conv['base_lr'] = base_lr * 1.0
param_group_conv['weight_decay'] = base_wd
param_group_conv['need_clip'] = need_clip
param_group_conv['clip_norm'] = clip_norm
param_groups.append(param_group_conv)
if self.bn is not None:
if self.bn.weight.requires_grad:
param_group_norm_weight = {'params': [self.bn.weight]}
param_group_norm_weight['lr'] = base_lr * 1.0
param_group_norm_weight['base_lr'] = base_lr * 1.0
param_group_norm_weight['weight_decay'] = 0.0
param_group_norm_weight['need_clip'] = need_clip
param_group_norm_weight['clip_norm'] = clip_norm
param_groups.append(param_group_norm_weight)
if self.bn.bias.requires_grad:
param_group_norm_bias = {'params': [self.bn.bias]}
param_group_norm_bias['lr'] = base_lr * 1.0
param_group_norm_bias['base_lr'] = base_lr * 1.0
param_group_norm_bias['weight_decay'] = 0.0
param_group_norm_bias['need_clip'] = need_clip
param_group_norm_bias['clip_norm'] = clip_norm
param_groups.append(param_group_norm_bias)
class RepVggBlock(nn.Module):
def __init__(self, ch_in, ch_out, act='relu'):
super(RepVggBlock, self).__init__()
self.ch_in = ch_in
self.ch_out = ch_out
self.conv1 = ConvBNLayer(
ch_in, ch_out, 3, stride=1, padding=1, act=None)
self.conv2 = ConvBNLayer(
ch_in, ch_out, 1, stride=1, padding=0, act=None)
self.act = get_act_fn(act) if act is None or isinstance(act, (
str, dict)) else act
def forward(self, x):
if hasattr(self, 'conv'):
y = self.conv(x)
else:
y = self.conv1(x) + self.conv2(x)
y = self.act(y)
return y
def add_param_group(self, param_groups, base_lr, base_wd, need_clip, clip_norm):
if hasattr(self, 'conv'):
self.conv.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
else:
self.conv1.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
self.conv2.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
def convert_to_deploy(self):
if not hasattr(self, 'conv'):
self.conv = nn.Conv2d(
in_channels=self.ch_in,
out_channels=self.ch_out,
kernel_size=3,
stride=1,
padding=1,
groups=1)
kernel, bias = self.get_equivalent_kernel_bias()
self.conv.weight.copy_(kernel)
self.conv.bias.copy_(bias)
self.__delattr__('conv1')
self.__delattr__('conv2')
def get_equivalent_kernel_bias(self):
kernel3x3, bias3x3 = self._fuse_bn_tensor(self.conv1)
kernel1x1, bias1x1 = self._fuse_bn_tensor(self.conv2)
return kernel3x3 + self._pad_1x1_to_3x3_tensor(
kernel1x1), bias3x3 + bias1x1
def _pad_1x1_to_3x3_tensor(self, kernel1x1):
if kernel1x1 is None:
return 0
else:
return nn.functional.pad(kernel1x1, [1, 1, 1, 1])
def _fuse_bn_tensor(self, branch):
if branch is None:
return 0, 0
kernel = branch.conv.weight
running_mean = branch.bn._mean
running_var = branch.bn._variance
gamma = branch.bn.weight
beta = branch.bn.bias
eps = branch.bn._epsilon
std = (running_var + eps).sqrt()
t = (gamma / std).reshape((-1, 1, 1, 1))
return kernel * t, beta - running_mean * gamma / std
class BasicBlock(nn.Module):
def __init__(self, ch_in, ch_out, act='relu', shortcut=True):
super(BasicBlock, self).__init__()
assert ch_in == ch_out
self.conv1 = ConvBNLayer(ch_in, ch_out, 3, stride=1, padding=1, act=act)
self.conv2 = RepVggBlock(ch_out, ch_out, act=act)
self.shortcut = shortcut
def forward(self, x):
y = self.conv1(x)
y = self.conv2(y)
if self.shortcut:
return x + y
else:
return y
def add_param_group(self, param_groups, base_lr, base_wd, need_clip, clip_norm):
self.conv1.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
self.conv2.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
class EffectiveSELayer(nn.Module):
""" Effective Squeeze-Excitation
From `CenterMask : Real-Time Anchor-Free Instance Segmentation` - https://arxiv.org/abs/1911.06667
"""
def __init__(self, channels, act='hardsigmoid'):
super(EffectiveSELayer, self).__init__()
self.fc = nn.Conv2d(channels, channels, kernel_size=1, padding=0)
self.act = get_act_fn(act) if act is None or isinstance(act, (
str, dict)) else act
def forward(self, x):
x_se = x.mean((2, 3), keepdim=True)
x_se = self.fc(x_se)
return x * self.act(x_se)
def add_param_group(self, param_groups, base_lr, base_wd, need_clip, clip_norm):
if isinstance(self.fc, torch.nn.Conv2d):
if self.fc.weight.requires_grad:
param_group_conv_weight = {'params': [self.fc.weight]}
param_group_conv_weight['lr'] = base_lr * 1.0
param_group_conv_weight['base_lr'] = base_lr * 1.0
param_group_conv_weight['weight_decay'] = base_wd
param_group_conv_weight['need_clip'] = need_clip
param_group_conv_weight['clip_norm'] = clip_norm
param_groups.append(param_group_conv_weight)
if self.fc.bias.requires_grad:
param_group_conv_bias = {'params': [self.fc.bias]}
param_group_conv_bias['lr'] = base_lr * 1.0
param_group_conv_bias['base_lr'] = base_lr * 1.0
param_group_conv_bias['weight_decay'] = base_wd
param_group_conv_bias['need_clip'] = need_clip
param_group_conv_bias['clip_norm'] = clip_norm
param_groups.append(param_group_conv_bias)
class CSPResStage(nn.Module):
def __init__(self,
block_fn,
ch_in,
ch_out,
n,
stride,
act='relu',
attn='eca'):
super(CSPResStage, self).__init__()
ch_mid = (ch_in + ch_out) // 2
if stride == 2:
self.conv_down = ConvBNLayer(
ch_in, ch_mid, 3, stride=2, padding=1, act=act)
else:
self.conv_down = None
self.conv1 = ConvBNLayer(ch_mid, ch_mid // 2, 1, act=act)
self.conv2 = ConvBNLayer(ch_mid, ch_mid // 2, 1, act=act)
self.blocks = nn.Sequential(*[
block_fn(
ch_mid // 2, ch_mid // 2, act=act, shortcut=True)
for i in range(n)
])
if attn:
self.attn = EffectiveSELayer(ch_mid, act='hardsigmoid')
else:
self.attn = None
self.conv3 = ConvBNLayer(ch_mid, ch_out, 1, act=act)
def forward(self, x):
if self.conv_down is not None:
x = self.conv_down(x)
y1 = self.conv1(x)
y2 = self.blocks(self.conv2(x))
y = torch.cat([y1, y2], 1)
if self.attn is not None:
y = self.attn(y)
y = self.conv3(y)
return y
def add_param_group(self, param_groups, base_lr, base_wd, need_clip, clip_norm):
if self.conv_down is not None:
self.conv_down.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
self.conv1.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
self.conv2.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
for layer in self.blocks:
layer.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
if self.attn is not None:
self.attn.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
self.conv3.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
class CSPResNet(nn.Module):
__shared__ = ['width_mult', 'depth_mult', 'trt']
def __init__(self,
layers=[3, 6, 6, 3],
channels=[64, 128, 256, 512, 1024],
act='swish',
return_idx=[0, 1, 2, 3, 4],
depth_wise=False,
use_large_stem=False,
width_mult=1.0,
depth_mult=1.0,
freeze_at=-1,
trt=False):
super(CSPResNet, self).__init__()
channels = [max(round(c * width_mult), 1) for c in channels]
layers = [max(round(l * depth_mult), 1) for l in layers]
act = get_act_fn(
act, trt=trt) if act is None or isinstance(act,
(str, dict)) else act
if use_large_stem:
self.stem = nn.Sequential()
self.stem.add_module('conv1', ConvBNLayer(3, channels[0] // 2, 3, stride=2, padding=1, act=act))
self.stem.add_module('conv2', ConvBNLayer(channels[0] // 2, channels[0] // 2, 3, stride=1, padding=1, act=act))
self.stem.add_module('conv3', ConvBNLayer(channels[0] // 2, channels[0], 3, stride=1, padding=1, act=act))
else:
self.stem = nn.Sequential()
self.stem.add_module('conv1', ConvBNLayer(3, channels[0] // 2, 3, stride=2, padding=1, act=act))
self.stem.add_module('conv2', ConvBNLayer(channels[0] // 2, channels[0], 3, stride=1, padding=1, act=act))
n = len(channels) - 1
self.stages = nn.Sequential()
for i in range(n):
self.stages.add_module(str(i), CSPResStage(BasicBlock, channels[i], channels[i + 1], layers[i], 2, act=act))
self._out_channels = channels[1:]
self._out_strides = [4, 8, 16, 32]
self.return_idx = return_idx
if freeze_at >= 0:
self._freeze_parameters(self.stem)
for i in range(min(freeze_at + 1, n)):
self._freeze_parameters(self.stages[i])
def _freeze_parameters(self, m):
for p in m.parameters():
p.requires_grad_(False)
def forward(self, inputs):
x = self.stem(inputs)
outs = []
for idx, stage in enumerate(self.stages):
x = stage(x)
if idx in self.return_idx:
outs.append(x)
return outs
def add_param_group(self, param_groups, base_lr, base_wd, need_clip, clip_norm):
for layer in self.stem:
layer.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
for idx, stage in enumerate(self.stages):
stage.add_param_group(param_groups, base_lr, base_wd, need_clip, clip_norm)
@property
def out_shape(self):
return [
ShapeSpec(
channels=self._out_channels[i], stride=self._out_strides[i])
for i in self.return_idx
]
| [
1,
396,
14187,
1266,
313,
29883,
29897,
29871,
29906,
29900,
29906,
29896,
349,
22352,
29925,
22352,
13189,
943,
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,
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,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8542,
13,
3166,
4770,
29888,
9130,
1649,
1053,
1596,
29918,
2220,
13,
13,
5215,
4842,
305,
13,
5215,
4842,
305,
29889,
15755,
408,
302,
29876,
13,
5215,
4842,
305,
29889,
15755,
29889,
2220,
284,
408,
383,
13,
13,
3166,
286,
3487,
300,
29889,
9794,
29889,
3554,
1053,
679,
29918,
627,
29918,
9144,
13,
3166,
286,
3487,
300,
29889,
9794,
29889,
6341,
29918,
29277,
1053,
1383,
4085,
10299,
13,
13,
13,
1990,
1281,
29894,
29933,
29940,
14420,
29898,
15755,
29889,
7355,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13,
462,
521,
29918,
262,
29892,
13,
462,
521,
29918,
449,
29892,
13,
462,
4175,
29918,
2311,
29922,
29941,
29892,
13,
462,
380,
2426,
29922,
29896,
29892,
13,
462,
6471,
29922,
29896,
29892,
13,
462,
7164,
29922,
29900,
29892,
13,
462,
1044,
29922,
8516,
1125,
13,
4706,
2428,
29898,
1168,
29894,
29933,
29940,
14420,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
13,
4706,
1583,
29889,
20580,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
13,
9651,
297,
29918,
305,
12629,
29922,
305,
29918,
262,
29892,
13,
9651,
714,
29918,
305,
12629,
29922,
305,
29918,
449,
29892,
13,
9651,
8466,
29918,
2311,
29922,
4572,
29918,
2311,
29892,
13,
9651,
380,
2426,
29922,
303,
2426,
29892,
13,
9651,
7164,
29922,
12791,
29892,
13,
9651,
6471,
29922,
13155,
29892,
13,
9651,
24003,
29922,
8824,
29897,
13,
13,
4706,
1583,
29889,
11197,
353,
302,
29876,
29889,
23145,
29940,
555,
29906,
29881,
29898,
305,
29918,
449,
29897,
13,
4706,
1583,
29889,
627,
353,
679,
29918,
627,
29918,
9144,
29898,
627,
29897,
565,
1044,
338,
6213,
470,
338,
8758,
29898,
627,
29892,
313,
13,
9651,
851,
29892,
9657,
876,
1683,
1044,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
921,
353,
1583,
29889,
20580,
29898,
29916,
29897,
13,
4706,
921,
353,
1583,
29889,
11197,
29898,
29916,
29897,
13,
4706,
921,
353,
1583,
29889,
627,
29898,
29916,
29897,
13,
13,
4706,
736,
921,
13,
13,
1678,
822,
788,
29918,
3207,
29918,
2972,
29898,
1311,
29892,
1828,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
1125,
13,
4706,
565,
338,
8758,
29898,
1311,
29889,
20580,
29892,
4842,
305,
29889,
15755,
29889,
1168,
29894,
29906,
29881,
1125,
13,
9651,
565,
1583,
29889,
20580,
29889,
7915,
29889,
276,
339,
2658,
29918,
5105,
29901,
13,
18884,
1828,
29918,
2972,
29918,
20580,
353,
11117,
7529,
2396,
518,
1311,
29889,
20580,
29889,
7915,
12258,
13,
18884,
1828,
29918,
2972,
29918,
20580,
1839,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
20580,
1839,
3188,
29918,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
20580,
1839,
7915,
29918,
7099,
388,
2033,
353,
2967,
29918,
9970,
13,
18884,
1828,
29918,
2972,
29918,
20580,
1839,
26180,
29918,
24049,
2033,
353,
817,
29918,
24049,
13,
18884,
1828,
29918,
2972,
29918,
20580,
1839,
24049,
29918,
12324,
2033,
353,
20102,
29918,
12324,
13,
18884,
1828,
29918,
13155,
29889,
4397,
29898,
3207,
29918,
2972,
29918,
20580,
29897,
13,
4706,
565,
1583,
29889,
11197,
338,
451,
6213,
29901,
13,
9651,
565,
1583,
29889,
11197,
29889,
7915,
29889,
276,
339,
2658,
29918,
5105,
29901,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
7915,
353,
11117,
7529,
2396,
518,
1311,
29889,
11197,
29889,
7915,
12258,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
7915,
1839,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
7915,
1839,
3188,
29918,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
7915,
1839,
7915,
29918,
7099,
388,
2033,
353,
29871,
29900,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
7915,
1839,
26180,
29918,
24049,
2033,
353,
817,
29918,
24049,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
7915,
1839,
24049,
29918,
12324,
2033,
353,
20102,
29918,
12324,
13,
18884,
1828,
29918,
13155,
29889,
4397,
29898,
3207,
29918,
2972,
29918,
12324,
29918,
7915,
29897,
13,
9651,
565,
1583,
29889,
11197,
29889,
29890,
3173,
29889,
276,
339,
2658,
29918,
5105,
29901,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
29890,
3173,
353,
11117,
7529,
2396,
518,
1311,
29889,
11197,
29889,
29890,
3173,
12258,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
29890,
3173,
1839,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
29890,
3173,
1839,
3188,
29918,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
29890,
3173,
1839,
7915,
29918,
7099,
388,
2033,
353,
29871,
29900,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
29890,
3173,
1839,
26180,
29918,
24049,
2033,
353,
817,
29918,
24049,
13,
18884,
1828,
29918,
2972,
29918,
12324,
29918,
29890,
3173,
1839,
24049,
29918,
12324,
2033,
353,
20102,
29918,
12324,
13,
18884,
1828,
29918,
13155,
29889,
4397,
29898,
3207,
29918,
2972,
29918,
12324,
29918,
29890,
3173,
29897,
13,
13,
13,
1990,
10088,
29963,
1505,
7445,
29898,
15755,
29889,
7355,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
521,
29918,
262,
29892,
521,
29918,
449,
29892,
1044,
2433,
2674,
29884,
29374,
13,
4706,
2428,
29898,
5612,
29963,
1505,
7445,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
305,
29918,
262,
353,
521,
29918,
262,
13,
4706,
1583,
29889,
305,
29918,
449,
353,
521,
29918,
449,
13,
4706,
1583,
29889,
20580,
29896,
353,
1281,
29894,
29933,
29940,
14420,
29898,
13,
9651,
521,
29918,
262,
29892,
521,
29918,
449,
29892,
29871,
29941,
29892,
380,
2426,
29922,
29896,
29892,
7164,
29922,
29896,
29892,
1044,
29922,
8516,
29897,
13,
4706,
1583,
29889,
20580,
29906,
353,
1281,
29894,
29933,
29940,
14420,
29898,
13,
9651,
521,
29918,
262,
29892,
521,
29918,
449,
29892,
29871,
29896,
29892,
380,
2426,
29922,
29896,
29892,
7164,
29922,
29900,
29892,
1044,
29922,
8516,
29897,
13,
4706,
1583,
29889,
627,
353,
679,
29918,
627,
29918,
9144,
29898,
627,
29897,
565,
1044,
338,
6213,
470,
338,
8758,
29898,
627,
29892,
313,
13,
9651,
851,
29892,
9657,
876,
1683,
1044,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
565,
756,
5552,
29898,
1311,
29892,
525,
20580,
29374,
13,
9651,
343,
353,
1583,
29889,
20580,
29898,
29916,
29897,
13,
4706,
1683,
29901,
13,
9651,
343,
353,
1583,
29889,
20580,
29896,
29898,
29916,
29897,
718,
1583,
29889,
20580,
29906,
29898,
29916,
29897,
13,
4706,
343,
353,
1583,
29889,
627,
29898,
29891,
29897,
13,
4706,
736,
343,
13,
13,
1678,
822,
788,
29918,
3207,
29918,
2972,
29898,
1311,
29892,
1828,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
1125,
13,
4706,
565,
756,
5552,
29898,
1311,
29892,
525,
20580,
29374,
13,
9651,
1583,
29889,
20580,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
20580,
29896,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
9651,
1583,
29889,
20580,
29906,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
13,
1678,
822,
3588,
29918,
517,
29918,
16519,
29898,
1311,
1125,
13,
4706,
565,
451,
756,
5552,
29898,
1311,
29892,
525,
20580,
29374,
13,
9651,
1583,
29889,
20580,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
13,
18884,
297,
29918,
305,
12629,
29922,
1311,
29889,
305,
29918,
262,
29892,
13,
18884,
714,
29918,
305,
12629,
29922,
1311,
29889,
305,
29918,
449,
29892,
13,
18884,
8466,
29918,
2311,
29922,
29941,
29892,
13,
18884,
380,
2426,
29922,
29896,
29892,
13,
18884,
7164,
29922,
29896,
29892,
13,
18884,
6471,
29922,
29896,
29897,
13,
4706,
8466,
29892,
24003,
353,
1583,
29889,
657,
29918,
1686,
27445,
29918,
17460,
29918,
29890,
3173,
580,
13,
4706,
1583,
29889,
20580,
29889,
7915,
29889,
8552,
23538,
17460,
29897,
13,
4706,
1583,
29889,
20580,
29889,
29890,
3173,
29889,
8552,
23538,
29890,
3173,
29897,
13,
4706,
1583,
17255,
6144,
5552,
1649,
877,
20580,
29896,
1495,
13,
4706,
1583,
17255,
6144,
5552,
1649,
877,
20580,
29906,
1495,
13,
13,
1678,
822,
679,
29918,
1686,
27445,
29918,
17460,
29918,
29890,
3173,
29898,
1311,
1125,
13,
4706,
8466,
29941,
29916,
29941,
29892,
24003,
29941,
29916,
29941,
353,
1583,
3032,
29888,
1509,
29918,
11197,
29918,
20158,
29898,
1311,
29889,
20580,
29896,
29897,
13,
4706,
8466,
29896,
29916,
29896,
29892,
24003,
29896,
29916,
29896,
353,
1583,
3032,
29888,
1509,
29918,
11197,
29918,
20158,
29898,
1311,
29889,
20580,
29906,
29897,
13,
4706,
736,
8466,
29941,
29916,
29941,
718,
1583,
3032,
8305,
29918,
29896,
29916,
29896,
29918,
517,
29918,
29941,
29916,
29941,
29918,
20158,
29898,
13,
9651,
8466,
29896,
29916,
29896,
511,
24003,
29941,
29916,
29941,
718,
24003,
29896,
29916,
29896,
13,
13,
1678,
822,
903,
8305,
29918,
29896,
29916,
29896,
29918,
517,
29918,
29941,
29916,
29941,
29918,
20158,
29898,
1311,
29892,
8466,
29896,
29916,
29896,
1125,
13,
4706,
565,
8466,
29896,
29916,
29896,
338,
6213,
29901,
13,
9651,
736,
29871,
29900,
13,
4706,
1683,
29901,
13,
9651,
736,
302,
29876,
29889,
2220,
284,
29889,
8305,
29898,
17460,
29896,
29916,
29896,
29892,
518,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
2314,
13,
13,
1678,
822,
903,
29888,
1509,
29918,
11197,
29918,
20158,
29898,
1311,
29892,
5443,
1125,
13,
4706,
565,
5443,
338,
6213,
29901,
13,
9651,
736,
29871,
29900,
29892,
29871,
29900,
13,
4706,
8466,
353,
5443,
29889,
20580,
29889,
7915,
13,
4706,
2734,
29918,
12676,
353,
5443,
29889,
11197,
3032,
12676,
13,
4706,
2734,
29918,
1707,
353,
5443,
29889,
11197,
3032,
1707,
8837,
13,
4706,
330,
2735,
353,
5443,
29889,
11197,
29889,
7915,
13,
4706,
21762,
353,
5443,
29889,
11197,
29889,
29890,
3173,
13,
4706,
321,
567,
353,
5443,
29889,
11197,
3032,
5463,
13,
4706,
3659,
353,
313,
21094,
29918,
1707,
718,
321,
567,
467,
3676,
580,
13,
4706,
260,
353,
313,
4283,
847,
3659,
467,
690,
14443,
3552,
29899,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
29892,
29871,
29896,
876,
13,
4706,
736,
8466,
334,
260,
29892,
21762,
448,
2734,
29918,
12676,
334,
330,
2735,
847,
3659,
13,
13,
13,
1990,
19219,
7445,
29898,
15755,
29889,
7355,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
521,
29918,
262,
29892,
521,
29918,
449,
29892,
1044,
2433,
2674,
29884,
742,
21697,
29922,
5574,
1125,
13,
4706,
2428,
29898,
16616,
7445,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
4974,
521,
29918,
262,
1275,
521,
29918,
449,
13,
4706,
1583,
29889,
20580,
29896,
353,
1281,
29894,
29933,
29940,
14420,
29898,
305,
29918,
262,
29892,
521,
29918,
449,
29892,
29871,
29941,
29892,
380,
2426,
29922,
29896,
29892,
7164,
29922,
29896,
29892,
1044,
29922,
627,
29897,
13,
4706,
1583,
29889,
20580,
29906,
353,
10088,
29963,
1505,
7445,
29898,
305,
29918,
449,
29892,
521,
29918,
449,
29892,
1044,
29922,
627,
29897,
13,
4706,
1583,
29889,
12759,
7582,
353,
21697,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
343,
353,
1583,
29889,
20580,
29896,
29898,
29916,
29897,
13,
4706,
343,
353,
1583,
29889,
20580,
29906,
29898,
29891,
29897,
13,
4706,
565,
1583,
29889,
12759,
7582,
29901,
13,
9651,
736,
921,
718,
343,
13,
4706,
1683,
29901,
13,
9651,
736,
343,
13,
13,
1678,
822,
788,
29918,
3207,
29918,
2972,
29898,
1311,
29892,
1828,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
1125,
13,
4706,
1583,
29889,
20580,
29896,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
4706,
1583,
29889,
20580,
29906,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
13,
13,
1990,
26475,
573,
1660,
14420,
29898,
15755,
29889,
7355,
1125,
13,
1678,
9995,
26475,
573,
317,
802,
29872,
911,
29899,
1252,
29883,
7018,
13,
1678,
3645,
421,
13409,
19832,
584,
8195,
29899,
2481,
530,
8420,
29899,
20475,
2799,
749,
6667,
358,
362,
29952,
448,
2045,
597,
279,
26560,
29889,
990,
29914,
6897,
29914,
29896,
29929,
29896,
29896,
29889,
29900,
29953,
29953,
29953,
29955,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
18196,
29892,
1044,
2433,
29882,
3163,
335,
29885,
3398,
29374,
13,
4706,
2428,
29898,
13971,
573,
1660,
14420,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
1583,
29889,
13801,
353,
302,
29876,
29889,
1168,
29894,
29906,
29881,
29898,
305,
12629,
29892,
18196,
29892,
8466,
29918,
2311,
29922,
29896,
29892,
7164,
29922,
29900,
29897,
13,
4706,
1583,
29889,
627,
353,
679,
29918,
627,
29918,
9144,
29898,
627,
29897,
565,
1044,
338,
6213,
470,
338,
8758,
29898,
627,
29892,
313,
13,
9651,
851,
29892,
9657,
876,
1683,
1044,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
921,
29918,
344,
353,
921,
29889,
12676,
3552,
29906,
29892,
29871,
29941,
511,
3013,
6229,
29922,
5574,
29897,
13,
4706,
921,
29918,
344,
353,
1583,
29889,
13801,
29898,
29916,
29918,
344,
29897,
13,
4706,
736,
921,
334,
1583,
29889,
627,
29898,
29916,
29918,
344,
29897,
13,
13,
1678,
822,
788,
29918,
3207,
29918,
2972,
29898,
1311,
29892,
1828,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
1125,
13,
4706,
565,
338,
8758,
29898,
1311,
29889,
13801,
29892,
4842,
305,
29889,
15755,
29889,
1168,
29894,
29906,
29881,
1125,
13,
9651,
565,
1583,
29889,
13801,
29889,
7915,
29889,
276,
339,
2658,
29918,
5105,
29901,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
7915,
353,
11117,
7529,
2396,
518,
1311,
29889,
13801,
29889,
7915,
12258,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
7915,
1839,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
7915,
1839,
3188,
29918,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
7915,
1839,
7915,
29918,
7099,
388,
2033,
353,
2967,
29918,
9970,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
7915,
1839,
26180,
29918,
24049,
2033,
353,
817,
29918,
24049,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
7915,
1839,
24049,
29918,
12324,
2033,
353,
20102,
29918,
12324,
13,
18884,
1828,
29918,
13155,
29889,
4397,
29898,
3207,
29918,
2972,
29918,
20580,
29918,
7915,
29897,
13,
9651,
565,
1583,
29889,
13801,
29889,
29890,
3173,
29889,
276,
339,
2658,
29918,
5105,
29901,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
29890,
3173,
353,
11117,
7529,
2396,
518,
1311,
29889,
13801,
29889,
29890,
3173,
12258,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
29890,
3173,
1839,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
29890,
3173,
1839,
3188,
29918,
29212,
2033,
353,
2967,
29918,
29212,
334,
29871,
29896,
29889,
29900,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
29890,
3173,
1839,
7915,
29918,
7099,
388,
2033,
353,
2967,
29918,
9970,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
29890,
3173,
1839,
26180,
29918,
24049,
2033,
353,
817,
29918,
24049,
13,
18884,
1828,
29918,
2972,
29918,
20580,
29918,
29890,
3173,
1839,
24049,
29918,
12324,
2033,
353,
20102,
29918,
12324,
13,
18884,
1828,
29918,
13155,
29889,
4397,
29898,
3207,
29918,
2972,
29918,
20580,
29918,
29890,
3173,
29897,
13,
13,
13,
1990,
315,
5550,
1666,
27276,
29898,
15755,
29889,
7355,
1125,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13,
462,
2908,
29918,
9144,
29892,
13,
462,
521,
29918,
262,
29892,
13,
462,
521,
29918,
449,
29892,
13,
462,
302,
29892,
13,
462,
380,
2426,
29892,
13,
462,
1044,
2433,
2674,
29884,
742,
13,
462,
1098,
29876,
2433,
13273,
29374,
13,
4706,
2428,
29898,
29907,
5550,
1666,
27276,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
13,
4706,
521,
29918,
6563,
353,
313,
305,
29918,
262,
718,
521,
29918,
449,
29897,
849,
29871,
29906,
13,
4706,
565,
380,
2426,
1275,
29871,
29906,
29901,
13,
9651,
1583,
29889,
20580,
29918,
3204,
353,
1281,
29894,
29933,
29940,
14420,
29898,
13,
18884,
521,
29918,
262,
29892,
521,
29918,
6563,
29892,
29871,
29941,
29892,
380,
2426,
29922,
29906,
29892,
7164,
29922,
29896,
29892,
1044,
29922,
627,
29897,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
20580,
29918,
3204,
353,
6213,
13,
4706,
1583,
29889,
20580,
29896,
353,
1281,
29894,
29933,
29940,
14420,
29898,
305,
29918,
6563,
29892,
521,
29918,
6563,
849,
29871,
29906,
29892,
29871,
29896,
29892,
1044,
29922,
627,
29897,
13,
4706,
1583,
29889,
20580,
29906,
353,
1281,
29894,
29933,
29940,
14420,
29898,
305,
29918,
6563,
29892,
521,
29918,
6563,
849,
29871,
29906,
29892,
29871,
29896,
29892,
1044,
29922,
627,
29897,
13,
4706,
1583,
29889,
1271,
29879,
353,
302,
29876,
29889,
16941,
2556,
10456,
29961,
13,
9651,
2908,
29918,
9144,
29898,
13,
18884,
521,
29918,
6563,
849,
29871,
29906,
29892,
521,
29918,
6563,
849,
29871,
29906,
29892,
1044,
29922,
627,
29892,
21697,
29922,
5574,
29897,
13,
9651,
363,
474,
297,
3464,
29898,
29876,
29897,
13,
308,
2314,
13,
4706,
565,
1098,
29876,
29901,
13,
9651,
1583,
29889,
1131,
29876,
353,
26475,
573,
1660,
14420,
29898,
305,
29918,
6563,
29892,
1044,
2433,
29882,
3163,
335,
29885,
3398,
1495,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
1131,
29876,
353,
6213,
13,
13,
4706,
1583,
29889,
20580,
29941,
353,
1281,
29894,
29933,
29940,
14420,
29898,
305,
29918,
6563,
29892,
521,
29918,
449,
29892,
29871,
29896,
29892,
1044,
29922,
627,
29897,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
921,
1125,
13,
4706,
565,
1583,
29889,
20580,
29918,
3204,
338,
451,
6213,
29901,
13,
9651,
921,
353,
1583,
29889,
20580,
29918,
3204,
29898,
29916,
29897,
13,
4706,
343,
29896,
353,
1583,
29889,
20580,
29896,
29898,
29916,
29897,
13,
4706,
343,
29906,
353,
1583,
29889,
1271,
29879,
29898,
1311,
29889,
20580,
29906,
29898,
29916,
876,
13,
4706,
343,
353,
4842,
305,
29889,
4117,
4197,
29891,
29896,
29892,
343,
29906,
1402,
29871,
29896,
29897,
13,
4706,
565,
1583,
29889,
1131,
29876,
338,
451,
6213,
29901,
13,
9651,
343,
353,
1583,
29889,
1131,
29876,
29898,
29891,
29897,
13,
4706,
343,
353,
1583,
29889,
20580,
29941,
29898,
29891,
29897,
13,
4706,
736,
343,
13,
13,
1678,
822,
788,
29918,
3207,
29918,
2972,
29898,
1311,
29892,
1828,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
1125,
13,
4706,
565,
1583,
29889,
20580,
29918,
3204,
338,
451,
6213,
29901,
13,
9651,
1583,
29889,
20580,
29918,
3204,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
4706,
1583,
29889,
20580,
29896,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
4706,
1583,
29889,
20580,
29906,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
4706,
363,
7546,
297,
1583,
29889,
1271,
29879,
29901,
13,
9651,
7546,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
4706,
565,
1583,
29889,
1131,
29876,
338,
451,
6213,
29901,
13,
9651,
1583,
29889,
1131,
29876,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
4706,
1583,
29889,
20580,
29941,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
13,
13,
1990,
315,
5550,
1666,
6779,
29898,
15755,
29889,
7355,
1125,
13,
1678,
4770,
12366,
1649,
353,
6024,
2103,
29918,
4713,
742,
525,
19488,
29918,
4713,
742,
525,
509,
29873,
2033,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
13,
462,
15359,
11759,
29941,
29892,
29871,
29953,
29892,
29871,
29953,
29892,
29871,
29941,
1402,
13,
462,
18196,
11759,
29953,
29946,
29892,
29871,
29896,
29906,
29947,
29892,
29871,
29906,
29945,
29953,
29892,
29871,
29945,
29896,
29906,
29892,
29871,
29896,
29900,
29906,
29946,
1402,
13,
462,
1044,
2433,
2774,
728,
742,
13,
462,
736,
29918,
13140,
11759,
29900,
29892,
29871,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29892,
29871,
29946,
1402,
13,
462,
10809,
29918,
3538,
29922,
8824,
29892,
13,
462,
671,
29918,
16961,
29918,
303,
331,
29922,
8824,
29892,
13,
462,
2920,
29918,
4713,
29922,
29896,
29889,
29900,
29892,
13,
462,
10809,
29918,
4713,
29922,
29896,
29889,
29900,
29892,
13,
462,
3889,
911,
29918,
271,
10457,
29896,
29892,
13,
462,
534,
29873,
29922,
8824,
1125,
13,
4706,
2428,
29898,
29907,
5550,
1666,
6779,
29892,
1583,
467,
1649,
2344,
1649,
580,
13,
4706,
18196,
353,
518,
3317,
29898,
14486,
29898,
29883,
334,
2920,
29918,
4713,
511,
29871,
29896,
29897,
363,
274,
297,
18196,
29962,
13,
4706,
15359,
353,
518,
3317,
29898,
14486,
29898,
29880,
334,
10809,
29918,
4713,
511,
29871,
29896,
29897,
363,
301,
297,
15359,
29962,
13,
4706,
1044,
353,
679,
29918,
627,
29918,
9144,
29898,
13,
9651,
1044,
29892,
534,
29873,
29922,
509,
29873,
29897,
565,
1044,
338,
6213,
470,
338,
8758,
29898,
627,
29892,
13,
462,
462,
462,
539,
313,
710,
29892,
9657,
876,
1683,
1044,
13,
13,
4706,
565,
671,
29918,
16961,
29918,
303,
331,
29901,
13,
9651,
1583,
29889,
303,
331,
353,
302,
29876,
29889,
16941,
2556,
580,
13,
9651,
1583,
29889,
303,
331,
29889,
1202,
29918,
5453,
877,
20580,
29896,
742,
1281,
29894,
29933,
29940,
14420,
29898,
29941,
29892,
18196,
29961,
29900,
29962,
849,
29871,
29906,
29892,
29871,
29941,
29892,
380,
2426,
29922,
29906,
29892,
7164,
29922,
29896,
29892,
1044,
29922,
627,
876,
13,
9651,
1583,
29889,
303,
331,
29889,
1202,
29918,
5453,
877,
20580,
29906,
742,
1281,
29894,
29933,
29940,
14420,
29898,
305,
12629,
29961,
29900,
29962,
849,
29871,
29906,
29892,
18196,
29961,
29900,
29962,
849,
29871,
29906,
29892,
29871,
29941,
29892,
380,
2426,
29922,
29896,
29892,
7164,
29922,
29896,
29892,
1044,
29922,
627,
876,
13,
9651,
1583,
29889,
303,
331,
29889,
1202,
29918,
5453,
877,
20580,
29941,
742,
1281,
29894,
29933,
29940,
14420,
29898,
305,
12629,
29961,
29900,
29962,
849,
29871,
29906,
29892,
18196,
29961,
29900,
1402,
29871,
29941,
29892,
380,
2426,
29922,
29896,
29892,
7164,
29922,
29896,
29892,
1044,
29922,
627,
876,
13,
4706,
1683,
29901,
13,
9651,
1583,
29889,
303,
331,
353,
302,
29876,
29889,
16941,
2556,
580,
13,
9651,
1583,
29889,
303,
331,
29889,
1202,
29918,
5453,
877,
20580,
29896,
742,
1281,
29894,
29933,
29940,
14420,
29898,
29941,
29892,
18196,
29961,
29900,
29962,
849,
29871,
29906,
29892,
29871,
29941,
29892,
380,
2426,
29922,
29906,
29892,
7164,
29922,
29896,
29892,
1044,
29922,
627,
876,
13,
9651,
1583,
29889,
303,
331,
29889,
1202,
29918,
5453,
877,
20580,
29906,
742,
1281,
29894,
29933,
29940,
14420,
29898,
305,
12629,
29961,
29900,
29962,
849,
29871,
29906,
29892,
18196,
29961,
29900,
1402,
29871,
29941,
29892,
380,
2426,
29922,
29896,
29892,
7164,
29922,
29896,
29892,
1044,
29922,
627,
876,
13,
13,
4706,
302,
353,
7431,
29898,
305,
12629,
29897,
448,
29871,
29896,
13,
4706,
1583,
29889,
303,
1179,
353,
302,
29876,
29889,
16941,
2556,
580,
13,
4706,
363,
474,
297,
3464,
29898,
29876,
1125,
13,
9651,
1583,
29889,
303,
1179,
29889,
1202,
29918,
5453,
29898,
710,
29898,
29875,
511,
315,
5550,
1666,
27276,
29898,
16616,
7445,
29892,
18196,
29961,
29875,
1402,
18196,
29961,
29875,
718,
29871,
29896,
1402,
15359,
29961,
29875,
1402,
29871,
29906,
29892,
1044,
29922,
627,
876,
13,
13,
4706,
1583,
3032,
449,
29918,
305,
12629,
353,
18196,
29961,
29896,
17531,
13,
4706,
1583,
3032,
449,
29918,
710,
2247,
353,
518,
29946,
29892,
29871,
29947,
29892,
29871,
29896,
29953,
29892,
29871,
29941,
29906,
29962,
13,
4706,
1583,
29889,
2457,
29918,
13140,
353,
736,
29918,
13140,
13,
13,
4706,
565,
3889,
911,
29918,
271,
6736,
29871,
29900,
29901,
13,
9651,
1583,
3032,
9021,
911,
29918,
16744,
29898,
1311,
29889,
303,
331,
29897,
13,
9651,
363,
474,
297,
3464,
29898,
1195,
29898,
9021,
911,
29918,
271,
718,
29871,
29896,
29892,
302,
22164,
13,
18884,
1583,
3032,
9021,
911,
29918,
16744,
29898,
1311,
29889,
303,
1179,
29961,
29875,
2314,
13,
13,
1678,
822,
903,
9021,
911,
29918,
16744,
29898,
1311,
29892,
286,
1125,
13,
4706,
363,
282,
297,
286,
29889,
16744,
7295,
13,
9651,
282,
29889,
276,
339,
2658,
29918,
5105,
23538,
8824,
29897,
13,
13,
1678,
822,
6375,
29898,
1311,
29892,
10970,
1125,
13,
4706,
921,
353,
1583,
29889,
303,
331,
29898,
2080,
29879,
29897,
13,
4706,
714,
29879,
353,
5159,
13,
4706,
363,
22645,
29892,
7408,
297,
26985,
29898,
1311,
29889,
303,
1179,
1125,
13,
9651,
921,
353,
7408,
29898,
29916,
29897,
13,
9651,
565,
22645,
297,
1583,
29889,
2457,
29918,
13140,
29901,
13,
18884,
714,
29879,
29889,
4397,
29898,
29916,
29897,
13,
13,
4706,
736,
714,
29879,
13,
13,
1678,
822,
788,
29918,
3207,
29918,
2972,
29898,
1311,
29892,
1828,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
1125,
13,
4706,
363,
7546,
297,
1583,
29889,
303,
331,
29901,
13,
9651,
7546,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
4706,
363,
22645,
29892,
7408,
297,
26985,
29898,
1311,
29889,
303,
1179,
1125,
13,
9651,
7408,
29889,
1202,
29918,
3207,
29918,
2972,
29898,
3207,
29918,
13155,
29892,
2967,
29918,
29212,
29892,
2967,
29918,
9970,
29892,
817,
29918,
24049,
29892,
20102,
29918,
12324,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
714,
29918,
12181,
29898,
1311,
1125,
13,
4706,
736,
518,
13,
9651,
1383,
4085,
10299,
29898,
13,
18884,
18196,
29922,
1311,
3032,
449,
29918,
305,
12629,
29961,
29875,
1402,
380,
2426,
29922,
1311,
3032,
449,
29918,
710,
2247,
29961,
29875,
2314,
13,
9651,
363,
474,
297,
1583,
29889,
2457,
29918,
13140,
13,
4706,
4514,
13,
2
] |
src/OTLMOW/OTLModel/Classes/DwarseMarkeringVerschuind.py | davidvlaminck/OTLClassPython | 2 | 22698 | # coding=utf-8
from OTLMOW.OTLModel.BaseClasses.OTLAttribuut import OTLAttribuut
from OTLMOW.OTLModel.Classes.DwarseMarkeringToegang import DwarseMarkeringToegang
from OTLMOW.OTLModel.Datatypes.KlDwarseMarkeringVerschuindCode import KlDwarseMarkeringVerschuindCode
from OTLMOW.OTLModel.Datatypes.KlDwarseMarkeringVerschuindSoort import KlDwarseMarkeringVerschuindSoort
from OTLMOW.OTLModel.Datatypes.KwantWrdInDecimaleGraden import KwantWrdInDecimaleGraden
from OTLMOW.OTLModel.Datatypes.KwantWrdInVierkanteMeter import KwantWrdInVierkanteMeter
# Generated with OTLClassCreator. To modify: extend, do not edit
class DwarseMarkeringVerschuind(DwarseMarkeringToegang):
"""Een schuine markering dwars op de weg aangebracht om het verkeer te waarschuwen, informeren of regelen."""
typeURI = 'https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#DwarseMarkeringVerschuind'
"""De URI van het object volgens https://www.w3.org/2001/XMLSchema#anyURI."""
def __init__(self):
super().__init__()
self._basisoppervlakte = OTLAttribuut(field=KwantWrdInVierkanteMeter,
naam='basisoppervlakte',
label='oppervlakte',
objectUri='https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#DwarseMarkeringVerschuind.basisoppervlakte',
definition='De basisoppervlakte van de dwarse markering in vierkante meter.',
owner=self)
self._code = OTLAttribuut(field=KlDwarseMarkeringVerschuindCode,
naam='code',
label='code',
objectUri='https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#DwarseMarkeringVerschuind.code',
definition='De (COPRO/BENOR) code van dwarse markering.',
owner=self)
self._hoek = OTLAttribuut(field=KwantWrdInDecimaleGraden,
naam='hoek',
label='hoek',
objectUri='https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#DwarseMarkeringVerschuind.hoek',
definition='De hoek van de verschuinde dwarsmarkering in decimale graden.',
owner=self)
self._oppervlakte = OTLAttribuut(field=KwantWrdInVierkanteMeter,
naam='oppervlakte',
label='oppervlakte',
objectUri='https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#DwarseMarkeringVerschuind.oppervlakte',
definition='De oppervlakte van een dwarsmarkering na verschuining.',
owner=self)
self._soortOmschrijving = OTLAttribuut(field=KlDwarseMarkeringVerschuindSoort,
naam='soortOmschrijving',
label='soort omschrijving',
objectUri='https://wegenenverkeer.data.vlaanderen.be/ns/onderdeel#DwarseMarkeringVerschuind.soortOmschrijving',
definition='De soort en tevens de omschrijving van dwarse markering.',
owner=self)
@property
def basisoppervlakte(self):
"""De basisoppervlakte van de dwarse markering in vierkante meter."""
return self._basisoppervlakte.get_waarde()
@basisoppervlakte.setter
def basisoppervlakte(self, value):
self._basisoppervlakte.set_waarde(value, owner=self)
@property
def code(self):
"""De (COPRO/BENOR) code van dwarse markering."""
return self._code.get_waarde()
@code.setter
def code(self, value):
self._code.set_waarde(value, owner=self)
@property
def hoek(self):
"""De hoek van de verschuinde dwarsmarkering in decimale graden."""
return self._hoek.get_waarde()
@hoek.setter
def hoek(self, value):
self._hoek.set_waarde(value, owner=self)
@property
def oppervlakte(self):
"""De oppervlakte van een dwarsmarkering na verschuining."""
return self._oppervlakte.get_waarde()
@oppervlakte.setter
def oppervlakte(self, value):
self._oppervlakte.set_waarde(value, owner=self)
@property
def soortOmschrijving(self):
"""De soort en tevens de omschrijving van dwarse markering."""
return self._soortOmschrijving.get_waarde()
@soortOmschrijving.setter
def soortOmschrijving(self, value):
self._soortOmschrijving.set_waarde(value, owner=self)
| [
1,
396,
14137,
29922,
9420,
29899,
29947,
13,
3166,
438,
14632,
6720,
29956,
29889,
2891,
29931,
3195,
29889,
5160,
27403,
29889,
2891,
29931,
4165,
7741,
329,
1053,
438,
14632,
4165,
7741,
329,
13,
3166,
438,
14632,
6720,
29956,
29889,
2891,
29931,
3195,
29889,
27403,
29889,
29928,
4495,
344,
9802,
3241,
1762,
387,
574,
1053,
360,
4495,
344,
9802,
3241,
1762,
387,
574,
13,
3166,
438,
14632,
6720,
29956,
29889,
2891,
29931,
3195,
29889,
16390,
271,
7384,
29889,
29968,
29880,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
3399,
1053,
12043,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
3399,
13,
3166,
438,
14632,
6720,
29956,
29889,
2891,
29931,
3195,
29889,
16390,
271,
7384,
29889,
29968,
29880,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
6295,
441,
1053,
12043,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
6295,
441,
13,
3166,
438,
14632,
6720,
29956,
29889,
2891,
29931,
3195,
29889,
16390,
271,
7384,
29889,
29968,
29893,
424,
29956,
5499,
797,
6185,
326,
744,
3338,
4858,
1053,
476,
29893,
424,
29956,
5499,
797,
6185,
326,
744,
3338,
4858,
13,
3166,
438,
14632,
6720,
29956,
29889,
2891,
29931,
3195,
29889,
16390,
271,
7384,
29889,
29968,
29893,
424,
29956,
5499,
797,
29963,
631,
29895,
1647,
29924,
1308,
1053,
476,
29893,
424,
29956,
5499,
797,
29963,
631,
29895,
1647,
29924,
1308,
13,
13,
13,
29937,
3251,
630,
411,
438,
14632,
2385,
9832,
1061,
29889,
1763,
6623,
29901,
10985,
29892,
437,
451,
3863,
13,
1990,
360,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
29898,
29928,
4495,
344,
9802,
3241,
1762,
387,
574,
1125,
13,
1678,
9995,
29923,
264,
1364,
29884,
457,
2791,
3241,
11988,
1503,
1015,
316,
20669,
263,
927,
2634,
2570,
2703,
1681,
1147,
446,
261,
734,
7739,
816,
7262,
264,
29892,
1871,
4578,
310,
1072,
4498,
1213,
15945,
13,
13,
1678,
1134,
15551,
353,
525,
991,
597,
29893,
3442,
264,
369,
446,
261,
29889,
1272,
29889,
29894,
433,
3825,
264,
29889,
915,
29914,
1983,
29914,
8417,
311,
295,
29937,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
29915,
13,
1678,
9995,
2772,
23539,
1109,
1681,
1203,
1700,
17397,
2045,
597,
1636,
29889,
29893,
29941,
29889,
990,
29914,
29906,
29900,
29900,
29896,
29914,
9165,
12763,
29937,
1384,
15551,
1213,
15945,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
2428,
2141,
1649,
2344,
1649,
580,
13,
13,
4706,
1583,
3032,
6500,
10718,
2496,
29894,
433,
8190,
353,
438,
14632,
4165,
7741,
329,
29898,
2671,
29922,
29968,
29893,
424,
29956,
5499,
797,
29963,
631,
29895,
1647,
29924,
1308,
29892,
13,
462,
462,
795,
8483,
2433,
6500,
10718,
2496,
29894,
433,
8190,
742,
13,
462,
462,
795,
3858,
2433,
29877,
2496,
29894,
433,
8190,
742,
13,
462,
462,
795,
1203,
14702,
2433,
991,
597,
29893,
3442,
264,
369,
446,
261,
29889,
1272,
29889,
29894,
433,
3825,
264,
29889,
915,
29914,
1983,
29914,
8417,
311,
295,
29937,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
29889,
6500,
10718,
2496,
29894,
433,
8190,
742,
13,
462,
462,
795,
5023,
2433,
2772,
8405,
29877,
2496,
29894,
433,
8190,
1109,
316,
270,
4495,
344,
2791,
3241,
297,
8545,
29895,
1647,
11134,
29889,
742,
13,
462,
462,
795,
12271,
29922,
1311,
29897,
13,
13,
4706,
1583,
3032,
401,
353,
438,
14632,
4165,
7741,
329,
29898,
2671,
29922,
29968,
29880,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
3399,
29892,
13,
462,
462,
29871,
8483,
2433,
401,
742,
13,
462,
462,
29871,
3858,
2433,
401,
742,
13,
462,
462,
29871,
1203,
14702,
2433,
991,
597,
29893,
3442,
264,
369,
446,
261,
29889,
1272,
29889,
29894,
433,
3825,
264,
29889,
915,
29914,
1983,
29914,
8417,
311,
295,
29937,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
29889,
401,
742,
13,
462,
462,
29871,
5023,
2433,
2772,
313,
3217,
8618,
29914,
29933,
1430,
1955,
29897,
29871,
775,
1109,
270,
4495,
344,
2791,
3241,
29889,
742,
13,
462,
462,
29871,
12271,
29922,
1311,
29897,
13,
13,
4706,
1583,
3032,
1251,
1416,
353,
438,
14632,
4165,
7741,
329,
29898,
2671,
29922,
29968,
29893,
424,
29956,
5499,
797,
6185,
326,
744,
3338,
4858,
29892,
13,
462,
462,
29871,
8483,
2433,
1251,
1416,
742,
13,
462,
462,
29871,
3858,
2433,
1251,
1416,
742,
13,
462,
462,
29871,
1203,
14702,
2433,
991,
597,
29893,
3442,
264,
369,
446,
261,
29889,
1272,
29889,
29894,
433,
3825,
264,
29889,
915,
29914,
1983,
29914,
8417,
311,
295,
29937,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
29889,
1251,
1416,
742,
13,
462,
462,
29871,
5023,
2433,
2772,
5089,
1416,
1109,
316,
8038,
29884,
25201,
11988,
1503,
3502,
3241,
297,
1602,
326,
744,
4656,
264,
29889,
742,
13,
462,
462,
29871,
12271,
29922,
1311,
29897,
13,
13,
4706,
1583,
3032,
29877,
2496,
29894,
433,
8190,
353,
438,
14632,
4165,
7741,
329,
29898,
2671,
29922,
29968,
29893,
424,
29956,
5499,
797,
29963,
631,
29895,
1647,
29924,
1308,
29892,
13,
462,
462,
308,
8483,
2433,
29877,
2496,
29894,
433,
8190,
742,
13,
462,
462,
308,
3858,
2433,
29877,
2496,
29894,
433,
8190,
742,
13,
462,
462,
308,
1203,
14702,
2433,
991,
597,
29893,
3442,
264,
369,
446,
261,
29889,
1272,
29889,
29894,
433,
3825,
264,
29889,
915,
29914,
1983,
29914,
8417,
311,
295,
29937,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
29889,
29877,
2496,
29894,
433,
8190,
742,
13,
462,
462,
308,
5023,
2433,
2772,
288,
2496,
29894,
433,
8190,
1109,
1739,
11988,
1503,
3502,
3241,
1055,
8038,
29884,
2827,
29889,
742,
13,
462,
462,
308,
12271,
29922,
1311,
29897,
13,
13,
4706,
1583,
3032,
578,
441,
5673,
816,
4927,
1747,
353,
438,
14632,
4165,
7741,
329,
29898,
2671,
29922,
29968,
29880,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
6295,
441,
29892,
13,
462,
462,
1669,
8483,
2433,
578,
441,
5673,
816,
4927,
1747,
742,
13,
462,
462,
1669,
3858,
2433,
578,
441,
2703,
816,
4927,
1747,
742,
13,
462,
462,
1669,
1203,
14702,
2433,
991,
597,
29893,
3442,
264,
369,
446,
261,
29889,
1272,
29889,
29894,
433,
3825,
264,
29889,
915,
29914,
1983,
29914,
8417,
311,
295,
29937,
29928,
4495,
344,
9802,
3241,
29963,
7092,
29884,
513,
29889,
578,
441,
5673,
816,
4927,
1747,
742,
13,
462,
462,
1669,
5023,
2433,
2772,
8615,
427,
734,
9852,
316,
2703,
816,
4927,
1747,
1109,
270,
4495,
344,
2791,
3241,
29889,
742,
13,
462,
462,
1669,
12271,
29922,
1311,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
8405,
29877,
2496,
29894,
433,
8190,
29898,
1311,
1125,
13,
4706,
9995,
2772,
8405,
29877,
2496,
29894,
433,
8190,
1109,
316,
270,
4495,
344,
2791,
3241,
297,
8545,
29895,
1647,
11134,
1213,
15945,
13,
4706,
736,
1583,
3032,
6500,
10718,
2496,
29894,
433,
8190,
29889,
657,
29918,
2766,
19755,
580,
13,
13,
1678,
732,
6500,
10718,
2496,
29894,
433,
8190,
29889,
842,
357,
13,
1678,
822,
8405,
29877,
2496,
29894,
433,
8190,
29898,
1311,
29892,
995,
1125,
13,
4706,
1583,
3032,
6500,
10718,
2496,
29894,
433,
8190,
29889,
842,
29918,
2766,
19755,
29898,
1767,
29892,
12271,
29922,
1311,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
775,
29898,
1311,
1125,
13,
4706,
9995,
2772,
313,
3217,
8618,
29914,
29933,
1430,
1955,
29897,
29871,
775,
1109,
270,
4495,
344,
2791,
3241,
1213,
15945,
13,
4706,
736,
1583,
3032,
401,
29889,
657,
29918,
2766,
19755,
580,
13,
13,
1678,
732,
401,
29889,
842,
357,
13,
1678,
822,
775,
29898,
1311,
29892,
995,
1125,
13,
4706,
1583,
3032,
401,
29889,
842,
29918,
2766,
19755,
29898,
1767,
29892,
12271,
29922,
1311,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
5089,
1416,
29898,
1311,
1125,
13,
4706,
9995,
2772,
5089,
1416,
1109,
316,
8038,
29884,
25201,
11988,
1503,
3502,
3241,
297,
1602,
326,
744,
4656,
264,
1213,
15945,
13,
4706,
736,
1583,
3032,
1251,
1416,
29889,
657,
29918,
2766,
19755,
580,
13,
13,
1678,
732,
1251,
1416,
29889,
842,
357,
13,
1678,
822,
5089,
1416,
29898,
1311,
29892,
995,
1125,
13,
4706,
1583,
3032,
1251,
1416,
29889,
842,
29918,
2766,
19755,
29898,
1767,
29892,
12271,
29922,
1311,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
288,
2496,
29894,
433,
8190,
29898,
1311,
1125,
13,
4706,
9995,
2772,
288,
2496,
29894,
433,
8190,
1109,
1739,
11988,
1503,
3502,
3241,
1055,
8038,
29884,
2827,
1213,
15945,
13,
4706,
736,
1583,
3032,
29877,
2496,
29894,
433,
8190,
29889,
657,
29918,
2766,
19755,
580,
13,
13,
1678,
732,
29877,
2496,
29894,
433,
8190,
29889,
842,
357,
13,
1678,
822,
288,
2496,
29894,
433,
8190,
29898,
1311,
29892,
995,
1125,
13,
4706,
1583,
3032,
29877,
2496,
29894,
433,
8190,
29889,
842,
29918,
2766,
19755,
29898,
1767,
29892,
12271,
29922,
1311,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
8615,
5673,
816,
4927,
1747,
29898,
1311,
1125,
13,
4706,
9995,
2772,
8615,
427,
734,
9852,
316,
2703,
816,
4927,
1747,
1109,
270,
4495,
344,
2791,
3241,
1213,
15945,
13,
4706,
736,
1583,
3032,
578,
441,
5673,
816,
4927,
1747,
29889,
657,
29918,
2766,
19755,
580,
13,
13,
1678,
732,
578,
441,
5673,
816,
4927,
1747,
29889,
842,
357,
13,
1678,
822,
8615,
5673,
816,
4927,
1747,
29898,
1311,
29892,
995,
1125,
13,
4706,
1583,
3032,
578,
441,
5673,
816,
4927,
1747,
29889,
842,
29918,
2766,
19755,
29898,
1767,
29892,
12271,
29922,
1311,
29897,
13,
2
] |
titan/files/mixins/versions_views.py | GoogleCloudPlatform/titan | 19 | 109441 | <filename>titan/files/mixins/versions_views.py
#!/usr/bin/env python
# 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.
"""Handlers for Titan Files versions service."""
import json
import logging
import webapp2
from titan import files
from titan.common import handlers
from titan.files.mixins import versions
class ChangesetHandler(handlers.BaseHandler):
"""RESTful handler for versions.Changeset."""
def post(self):
"""POST handler."""
try:
namespace = self.request.get('namespace', None)
vcs = versions.VersionControlService()
changeset = vcs.new_staging_changeset(namespace=namespace)
self.write_json_response(changeset)
self.response.set_status(201)
except (TypeError, ValueError):
self.error(400)
logging.exception('Bad request:')
class ChangesetCommitHandler(handlers.BaseHandler):
"""RESTful handler for VersionControlService.Commit."""
def post(self):
"""POST handler."""
try:
namespace = self.request.get('namespace', None)
save_manifest = self.request.get('save_manifest', 'true') == 'true'
vcs = versions.VersionControlService()
staging_changeset = versions.Changeset(
int(self.request.get('changeset')), namespace=namespace)
force = bool(self.request.get('force', False))
manifest = self.request.POST.get('manifest', None)
if not force and not manifest or force and manifest:
self.error(400)
logging.error('Exactly one of "manifest" or "force" params is required')
return
# If a client has full knowledge of the files uploaded to a changeset,
# the "manifest" param may be given to ensure a strongly consistent
# commit. If given, associate the files to the changeset and finalize it.
if manifest:
manifest = json.loads(manifest)
for path in manifest:
titan_file = files.File(path, changeset=staging_changeset,
namespace=namespace, _internal=True)
staging_changeset.associate_file(titan_file)
staging_changeset.finalize_associated_files()
final_changeset = vcs.commit(
staging_changeset, force=force, save_manifest=save_manifest)
self.write_json_response(final_changeset)
self.response.set_status(201)
except (TypeError, ValueError):
self.error(400)
logging.exception('Bad request:')
ROUTES = (
('/_titan/files/versions/changeset', ChangesetHandler),
('/_titan/files/versions/changeset/commit', ChangesetCommitHandler),
)
application = webapp2.WSGIApplication(ROUTES, debug=False)
| [
1,
529,
9507,
29958,
29873,
8929,
29914,
5325,
29914,
28084,
1144,
29914,
26100,
29918,
7406,
29889,
2272,
13,
29937,
14708,
4855,
29914,
2109,
29914,
6272,
3017,
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,
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,
15945,
29908,
3481,
9306,
363,
323,
8929,
12745,
6910,
2669,
1213,
15945,
13,
13,
5215,
4390,
13,
5215,
12183,
13,
13,
5215,
1856,
932,
29906,
13,
13,
3166,
4329,
273,
1053,
2066,
13,
3166,
4329,
273,
29889,
9435,
1053,
25795,
13,
3166,
4329,
273,
29889,
5325,
29889,
28084,
1144,
1053,
6910,
13,
13,
1990,
678,
6916,
300,
4598,
29898,
3179,
9306,
29889,
5160,
4598,
1125,
13,
29871,
9995,
1525,
1254,
1319,
7834,
363,
6910,
29889,
21459,
300,
1213,
15945,
13,
13,
29871,
822,
1400,
29898,
1311,
1125,
13,
1678,
9995,
5438,
7834,
1213,
15945,
13,
1678,
1018,
29901,
13,
418,
7397,
353,
1583,
29889,
3827,
29889,
657,
877,
22377,
742,
6213,
29897,
13,
418,
325,
2395,
353,
6910,
29889,
6594,
4809,
3170,
580,
13,
418,
3620,
300,
353,
325,
2395,
29889,
1482,
29918,
303,
6751,
29918,
25990,
300,
29898,
22377,
29922,
22377,
29897,
13,
418,
1583,
29889,
3539,
29918,
3126,
29918,
5327,
29898,
25990,
300,
29897,
13,
418,
1583,
29889,
5327,
29889,
842,
29918,
4882,
29898,
29906,
29900,
29896,
29897,
13,
1678,
5174,
313,
1542,
2392,
29892,
7865,
2392,
1125,
13,
418,
1583,
29889,
2704,
29898,
29946,
29900,
29900,
29897,
13,
418,
12183,
29889,
11739,
877,
22050,
2009,
29901,
1495,
13,
13,
1990,
678,
6916,
300,
1523,
2415,
4598,
29898,
3179,
9306,
29889,
5160,
4598,
1125,
13,
29871,
9995,
1525,
1254,
1319,
7834,
363,
10079,
4809,
3170,
29889,
1523,
2415,
1213,
15945,
13,
13,
29871,
822,
1400,
29898,
1311,
1125,
13,
1678,
9995,
5438,
7834,
1213,
15945,
13,
1678,
1018,
29901,
13,
418,
7397,
353,
1583,
29889,
3827,
29889,
657,
877,
22377,
742,
6213,
29897,
13,
418,
4078,
29918,
29135,
353,
1583,
29889,
3827,
29889,
657,
877,
7620,
29918,
29135,
742,
525,
3009,
1495,
1275,
525,
3009,
29915,
13,
418,
325,
2395,
353,
6910,
29889,
6594,
4809,
3170,
580,
13,
418,
380,
6751,
29918,
25990,
300,
353,
6910,
29889,
21459,
300,
29898,
13,
3986,
938,
29898,
1311,
29889,
3827,
29889,
657,
877,
25990,
300,
1495,
511,
7397,
29922,
22377,
29897,
13,
418,
4889,
353,
6120,
29898,
1311,
29889,
3827,
29889,
657,
877,
10118,
742,
7700,
876,
13,
418,
10419,
353,
1583,
29889,
3827,
29889,
5438,
29889,
657,
877,
29135,
742,
6213,
29897,
13,
418,
565,
451,
4889,
322,
451,
10419,
470,
4889,
322,
10419,
29901,
13,
4706,
1583,
29889,
2704,
29898,
29946,
29900,
29900,
29897,
13,
4706,
12183,
29889,
2704,
877,
1252,
23617,
697,
310,
376,
29135,
29908,
470,
376,
10118,
29908,
8636,
338,
3734,
1495,
13,
4706,
736,
13,
13,
418,
396,
960,
263,
3132,
756,
2989,
7134,
310,
278,
2066,
20373,
304,
263,
3620,
300,
29892,
13,
418,
396,
278,
376,
29135,
29908,
1828,
1122,
367,
2183,
304,
9801,
263,
13818,
13747,
13,
418,
396,
9063,
29889,
960,
2183,
29892,
25836,
278,
2066,
304,
278,
3620,
300,
322,
2186,
675,
372,
29889,
13,
418,
565,
10419,
29901,
13,
4706,
10419,
353,
4390,
29889,
18132,
29898,
29135,
29897,
13,
4706,
363,
2224,
297,
10419,
29901,
13,
3986,
4329,
273,
29918,
1445,
353,
2066,
29889,
2283,
29898,
2084,
29892,
3620,
300,
29922,
303,
6751,
29918,
25990,
300,
29892,
13,
462,
462,
29871,
7397,
29922,
22377,
29892,
903,
7564,
29922,
5574,
29897,
13,
3986,
380,
6751,
29918,
25990,
300,
29889,
21264,
403,
29918,
1445,
29898,
29873,
8929,
29918,
1445,
29897,
13,
4706,
380,
6751,
29918,
25990,
300,
29889,
8394,
675,
29918,
21264,
630,
29918,
5325,
580,
13,
13,
418,
2186,
29918,
25990,
300,
353,
325,
2395,
29889,
15060,
29898,
13,
3986,
380,
6751,
29918,
25990,
300,
29892,
4889,
29922,
10118,
29892,
4078,
29918,
29135,
29922,
7620,
29918,
29135,
29897,
13,
418,
1583,
29889,
3539,
29918,
3126,
29918,
5327,
29898,
8394,
29918,
25990,
300,
29897,
13,
418,
1583,
29889,
5327,
29889,
842,
29918,
4882,
29898,
29906,
29900,
29896,
29897,
13,
1678,
5174,
313,
1542,
2392,
29892,
7865,
2392,
1125,
13,
418,
1583,
29889,
2704,
29898,
29946,
29900,
29900,
29897,
13,
418,
12183,
29889,
11739,
877,
22050,
2009,
29901,
1495,
13,
13,
1672,
2692,
2890,
353,
313,
13,
1678,
6702,
19891,
29873,
8929,
29914,
5325,
29914,
26100,
29914,
25990,
300,
742,
678,
6916,
300,
4598,
511,
13,
1678,
6702,
19891,
29873,
8929,
29914,
5325,
29914,
26100,
29914,
25990,
300,
29914,
15060,
742,
678,
6916,
300,
1523,
2415,
4598,
511,
13,
29897,
13,
6214,
353,
1856,
932,
29906,
29889,
7811,
29954,
29902,
4873,
29898,
1672,
2692,
2890,
29892,
4744,
29922,
8824,
29897,
13,
2
] |
x_tef2/profiles.py | parkermac/LiveOcean | 4 | 126096 | <filename>x_tef2/profiles.py
"""
Make profiles of salt or density vs. depth at each section.
Goal is to explore time evolution of ds/dx at places like Admiralty Inlet.
"""
# setup
import netCDF4 as nc
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime
import scipy.stats as stats
import pandas as pd
import os
import sys
sys.path.append(os.path.abspath('../alpha'))
import Lfun
import zfun
Ldir = Lfun.Lstart()
indir0 = Ldir['LOo'] + 'tef2/'
# choose the tef extraction to process
#item = Lfun.choose_item(indir0)
year = 2017
item = 'cas6_v3_lo8b_'+str(year)+'.01.01_'+str(year)+'.12.31'
indir0 = indir0 + item + '/'
indir = indir0 + 'extractions/'
sect_list_raw = os.listdir(indir)
sect_list_raw.sort()
sect_list = [item for item in sect_list_raw if ('.nc' in item)]
testing = True
if testing:
sect_list = ['ai1.nc','ai2.nc','ai3.nc']
else:
pass
outdir = indir0 + 'profiles/'
Lfun.make_dir(outdir)
if testing:
plt.close('all')
# create z edges and bins
zedges = np.linspace(-100, 0, 26) # original was 1001 used 5001 for Willapa
zbins = zedges[:-1] + np.diff(zedges)/2
for fn in sect_list:
if testing:
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(111)
print(fn)
df = pd.DataFrame(index=zbins , columns = range(1,13,1))
# load fields
ds = nc.Dataset(indir + fn)
s = ds['salt'][:]
mask = s[0,:,:].squeeze().mask
th = ds['temp'][:]
z0 = ds['z0'][:]
ot = ds['ocean_time'][:]
gtagex = ds.gtagex
ds0 = ds.date_string0
ds1 = ds.date_string1
ds.close()
dt = []
mo = []
for t in ot:
this_dt = Lfun.modtime_to_datetime(t)
this_mo = this_dt.month
dt.append(this_dt)
mo.append(this_mo)
mo[-1] = 12 # fix last point
mo = np.array(mo)
if mask.size > 1:
z0m = z0[~mask].data
else:
z0m = z0.flatten()
for mm in (range(1,13,1)):
i0 = np.argwhere(mo==mm)[0][0]
i1 = np.argwhere(mo==mm)[-1][0]
si = s[i0:i1+1,:,:].mean(axis=0)
if mask.size > 1:
sm = si[~mask].data
else:
sm = si.flatten()
ss = stats.binned_statistic(z0m, sm, statistic='mean', bins=zedges)
sb = ss.statistic
df.loc[:,mm] = sb
if testing:
df.plot(ax=ax, title=fn)
df.to_pickle(outdir + fn.replace('.nc','.p'))
plt.show()
| [
1,
529,
9507,
29958,
29916,
29918,
371,
29888,
29906,
29914,
771,
5325,
29889,
2272,
13,
15945,
29908,
13,
9984,
28723,
310,
15795,
470,
9027,
7186,
29889,
10809,
472,
1269,
4004,
29889,
13,
13,
8120,
284,
338,
304,
26987,
931,
14675,
310,
18031,
29914,
8235,
472,
7600,
763,
23946,
18745,
512,
1026,
29889,
13,
15945,
29908,
13,
13,
29937,
6230,
13,
5215,
7787,
29907,
4037,
29946,
408,
302,
29883,
13,
5215,
22889,
29889,
2272,
5317,
408,
14770,
13,
5215,
12655,
408,
7442,
13,
3166,
12865,
1053,
12865,
13,
5215,
4560,
2272,
29889,
16202,
408,
22663,
13,
5215,
11701,
408,
10518,
13,
13,
5215,
2897,
13,
5215,
10876,
13,
9675,
29889,
2084,
29889,
4397,
29898,
359,
29889,
2084,
29889,
370,
1028,
493,
877,
6995,
2312,
8785,
13,
5215,
365,
7692,
13,
5215,
503,
7692,
13,
13,
29931,
3972,
353,
365,
7692,
29889,
29931,
2962,
580,
13,
13,
513,
381,
29900,
353,
365,
3972,
1839,
3927,
29877,
2033,
718,
525,
371,
29888,
29906,
22208,
13,
29937,
6755,
278,
734,
29888,
4805,
428,
304,
1889,
13,
29937,
667,
353,
365,
7692,
29889,
21803,
29918,
667,
29898,
513,
381,
29900,
29897,
13,
6360,
353,
29871,
29906,
29900,
29896,
29955,
13,
667,
353,
525,
9398,
29953,
29918,
29894,
29941,
29918,
417,
29947,
29890,
29918,
18717,
710,
29898,
6360,
7240,
4286,
29900,
29896,
29889,
29900,
29896,
29918,
18717,
710,
29898,
6360,
7240,
4286,
29896,
29906,
29889,
29941,
29896,
29915,
13,
513,
381,
29900,
353,
1399,
381,
29900,
718,
2944,
718,
8207,
29915,
13,
513,
381,
353,
1399,
381,
29900,
718,
525,
17833,
1953,
22208,
13,
13,
8803,
29918,
1761,
29918,
1610,
353,
2897,
29889,
1761,
3972,
29898,
513,
381,
29897,
13,
8803,
29918,
1761,
29918,
1610,
29889,
6605,
580,
13,
8803,
29918,
1761,
353,
518,
667,
363,
2944,
297,
21149,
29918,
1761,
29918,
1610,
565,
313,
4286,
17608,
29915,
297,
2944,
4638,
13,
13,
13424,
353,
5852,
13,
13,
361,
6724,
29901,
13,
1678,
21149,
29918,
1761,
353,
6024,
1794,
29896,
29889,
17608,
3788,
1794,
29906,
29889,
17608,
3788,
1794,
29941,
29889,
17608,
2033,
13,
2870,
29901,
13,
1678,
1209,
13,
268,
13,
449,
3972,
353,
1399,
381,
29900,
718,
525,
771,
5325,
22208,
13,
29931,
7692,
29889,
5675,
29918,
3972,
29898,
449,
3972,
29897,
13,
13,
361,
6724,
29901,
13,
1678,
14770,
29889,
5358,
877,
497,
1495,
13,
13,
29937,
1653,
503,
12770,
322,
289,
1144,
13,
24688,
2710,
353,
7442,
29889,
1915,
3493,
6278,
29896,
29900,
29900,
29892,
29871,
29900,
29892,
29871,
29906,
29953,
29897,
396,
2441,
471,
29871,
29896,
29900,
29900,
29896,
1304,
29871,
29945,
29900,
29900,
29896,
363,
399,
2911,
3274,
13,
29920,
29890,
1144,
353,
503,
287,
2710,
7503,
29899,
29896,
29962,
718,
7442,
29889,
12765,
29898,
24688,
2710,
6802,
29906,
13,
13,
1454,
7876,
297,
21149,
29918,
1761,
29901,
13,
268,
13,
1678,
565,
6724,
29901,
13,
4706,
2537,
353,
14770,
29889,
4532,
29898,
1003,
2311,
7607,
29896,
29900,
29892,
29896,
29900,
876,
13,
4706,
4853,
353,
2537,
29889,
1202,
29918,
1491,
5317,
29898,
29896,
29896,
29896,
29897,
13,
308,
13,
1678,
1596,
29898,
9144,
29897,
13,
268,
13,
1678,
4489,
353,
10518,
29889,
17271,
29898,
2248,
29922,
29920,
29890,
1144,
1919,
4341,
353,
3464,
29898,
29896,
29892,
29896,
29941,
29892,
29896,
876,
13,
13,
1678,
396,
2254,
4235,
13,
1678,
18031,
353,
302,
29883,
29889,
16390,
24541,
29898,
513,
381,
718,
7876,
29897,
13,
1678,
269,
353,
18031,
1839,
29879,
1997,
2033,
7503,
29962,
13,
1678,
11105,
353,
269,
29961,
29900,
29892,
29901,
29892,
29901,
1822,
29879,
802,
29872,
911,
2141,
13168,
13,
1678,
266,
353,
18031,
1839,
7382,
2033,
7503,
29962,
13,
1678,
503,
29900,
353,
18031,
1839,
29920,
29900,
2033,
7503,
29962,
13,
1678,
4932,
353,
18031,
1839,
29877,
11956,
29918,
2230,
2033,
7503,
29962,
13,
1678,
330,
29873,
482,
29916,
353,
18031,
29889,
4141,
482,
29916,
13,
1678,
18031,
29900,
353,
18031,
29889,
1256,
29918,
1807,
29900,
13,
1678,
18031,
29896,
353,
18031,
29889,
1256,
29918,
1807,
29896,
13,
1678,
18031,
29889,
5358,
580,
13,
268,
13,
1678,
11636,
353,
5159,
13,
1678,
2730,
353,
5159,
13,
1678,
363,
260,
297,
4932,
29901,
13,
4706,
445,
29918,
6008,
353,
365,
7692,
29889,
1545,
2230,
29918,
517,
29918,
12673,
29898,
29873,
29897,
13,
4706,
445,
29918,
4346,
353,
445,
29918,
6008,
29889,
10874,
13,
4706,
11636,
29889,
4397,
29898,
1366,
29918,
6008,
29897,
13,
4706,
2730,
29889,
4397,
29898,
1366,
29918,
4346,
29897,
13,
1678,
2730,
14352,
29896,
29962,
353,
29871,
29896,
29906,
396,
2329,
1833,
1298,
13,
1678,
2730,
353,
7442,
29889,
2378,
29898,
4346,
29897,
13,
268,
13,
1678,
565,
11105,
29889,
2311,
1405,
29871,
29896,
29901,
13,
4706,
503,
29900,
29885,
353,
503,
29900,
29961,
30022,
13168,
1822,
1272,
13,
1678,
1683,
29901,
13,
4706,
503,
29900,
29885,
353,
503,
29900,
29889,
1579,
8606,
580,
13,
268,
13,
1678,
363,
5654,
297,
313,
3881,
29898,
29896,
29892,
29896,
29941,
29892,
29896,
22164,
13,
4706,
474,
29900,
353,
7442,
29889,
1191,
3062,
29898,
4346,
1360,
4317,
9601,
29900,
3816,
29900,
29962,
13,
4706,
474,
29896,
353,
7442,
29889,
1191,
3062,
29898,
4346,
1360,
4317,
9601,
29899,
29896,
3816,
29900,
29962,
13,
4706,
1354,
353,
269,
29961,
29875,
29900,
29901,
29875,
29896,
29974,
29896,
29892,
29901,
29892,
29901,
1822,
12676,
29898,
8990,
29922,
29900,
29897,
13,
4706,
565,
11105,
29889,
2311,
1405,
29871,
29896,
29901,
13,
9651,
1560,
353,
1354,
29961,
30022,
13168,
1822,
1272,
13,
4706,
1683,
29901,
13,
9651,
1560,
353,
1354,
29889,
1579,
8606,
580,
13,
4706,
17971,
353,
22663,
29889,
2109,
9571,
29918,
6112,
4695,
29898,
29920,
29900,
29885,
29892,
1560,
29892,
1002,
4695,
2433,
12676,
742,
289,
1144,
29922,
24688,
2710,
29897,
13,
4706,
17444,
353,
17971,
29889,
6112,
4695,
308,
13,
4706,
4489,
29889,
2029,
7503,
29892,
4317,
29962,
353,
17444,
13,
308,
13,
1678,
565,
6724,
29901,
13,
4706,
4489,
29889,
5317,
29898,
1165,
29922,
1165,
29892,
3611,
29922,
9144,
29897,
13,
308,
13,
1678,
4489,
29889,
517,
29918,
23945,
280,
29898,
449,
3972,
718,
7876,
29889,
6506,
12839,
17608,
3788,
29889,
29886,
8785,
13,
268,
13,
572,
29873,
29889,
4294,
580,
13,
268,
13,
13,
2
] |
forte/multipack_pipeline.py | huzecong/forte | 0 | 186819 | <reponame>huzecong/forte
import logging
from typing import Dict, List, Optional
import yaml
from texar.torch import HParams
from forte.base_pipeline import BasePipeline
from forte.data.multi_pack import MultiPack
from forte.data.selector import Selector
from forte.utils import get_class
logger = logging.getLogger(__name__)
__all__ = [
"MultiPackPipeline"
]
# pylint: disable=attribute-defined-outside-init
class MultiPackPipeline(BasePipeline[MultiPack]):
"""
The pipeline consists of a list of predictors.
"""
def __init__(self):
super().__init__()
self._selectors: List[Selector] = []
@property
def selectors(self):
return self._selectors
def init_from_config(self, configs: Dict):
"""
Parse the configuration sections from the input config,
into a list of [processor, config]
Initialize the pipeline with the configurations
"""
if "Reader" not in configs or configs["Reader"] is None:
raise KeyError('No reader in the configuration')
reader_config = configs["Reader"]
reader, _ = create_class_with_kwargs(
class_name=reader_config["type"],
class_args=reader_config.get("kwargs", {}),
)
self.set_reader(reader)
# HParams cannot create HParams from the inner dict of list
if "Processors" in configs and configs["Processors"] is not None:
for processor_configs in configs["Processors"]:
p, processor_hparams = create_class_with_kwargs(
class_name=processor_configs["type"],
class_args=processor_configs.get("kwargs", {}),
h_params=processor_configs.get("hparams", {}),
)
selector_hparams = processor_hparams.selector
selector_class = get_class(selector_hparams['type'])
selector_kwargs = selector_hparams["kwargs"]
selector = selector_class(**selector_kwargs)
self.add_processor(p, processor_hparams, selector)
self.initialize()
def create_class_with_kwargs(
class_name: str, class_args: Dict, h_params: Optional[Dict] = None):
cls = get_class(class_name)
if not class_args:
class_args = {}
obj = cls(**class_args)
p_params: Dict = {}
if h_params is not None and \
"config_path" in h_params and \
h_params["config_path"] is not None:
filebased_hparams = yaml.safe_load(open(h_params["config_path"]))
else:
filebased_hparams = {}
p_params.update(filebased_hparams)
if h_params is not None:
p_params.update(h_params.get("overwrite_configs", {}))
default_processor_hparams = cls.default_hparams()
processor_hparams = HParams(p_params,
default_processor_hparams)
return obj, processor_hparams
| [
1,
529,
276,
1112,
420,
29958,
6905,
911,
21015,
29914,
1454,
371,
13,
5215,
12183,
13,
3166,
19229,
1053,
360,
919,
29892,
2391,
29892,
28379,
13,
13,
5215,
343,
8807,
13,
3166,
19696,
279,
29889,
7345,
305,
1053,
379,
9629,
13,
13,
3166,
19624,
29889,
3188,
29918,
13096,
5570,
1053,
7399,
29925,
23828,
13,
3166,
19624,
29889,
1272,
29889,
9910,
29918,
4058,
1053,
14974,
16638,
13,
3166,
19624,
29889,
1272,
29889,
14357,
1053,
7605,
272,
13,
3166,
19624,
29889,
13239,
1053,
679,
29918,
1990,
13,
13,
21707,
353,
12183,
29889,
657,
16363,
22168,
978,
1649,
29897,
13,
13,
1649,
497,
1649,
353,
518,
13,
1678,
376,
15329,
16638,
29925,
23828,
29908,
13,
29962,
13,
13,
13,
29937,
282,
2904,
524,
29901,
11262,
29922,
12715,
29899,
12119,
29899,
449,
2975,
29899,
2344,
13,
13,
1990,
14974,
16638,
29925,
23828,
29898,
5160,
29925,
23828,
29961,
15329,
16638,
29962,
1125,
13,
1678,
9995,
13,
1678,
450,
16439,
11624,
310,
263,
1051,
310,
8500,
943,
29889,
13,
1678,
9995,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
13,
4706,
2428,
2141,
1649,
2344,
1649,
580,
13,
4706,
1583,
3032,
2622,
943,
29901,
2391,
29961,
10378,
29962,
353,
5159,
13,
13,
1678,
732,
6799,
13,
1678,
822,
1831,
943,
29898,
1311,
1125,
13,
4706,
736,
1583,
3032,
2622,
943,
13,
13,
1678,
822,
2069,
29918,
3166,
29918,
2917,
29898,
1311,
29892,
2295,
29879,
29901,
360,
919,
1125,
13,
4706,
9995,
13,
4706,
20969,
278,
5285,
13926,
515,
278,
1881,
2295,
29892,
13,
9651,
964,
263,
1051,
310,
518,
26482,
29892,
2295,
29962,
13,
4706,
25455,
278,
16439,
411,
278,
22920,
13,
4706,
9995,
13,
4706,
565,
376,
6982,
29908,
451,
297,
2295,
29879,
470,
2295,
29879,
3366,
6982,
3108,
338,
6213,
29901,
13,
9651,
12020,
7670,
2392,
877,
3782,
9591,
297,
278,
5285,
1495,
13,
13,
4706,
9591,
29918,
2917,
353,
2295,
29879,
3366,
6982,
3108,
13,
13,
4706,
9591,
29892,
903,
353,
1653,
29918,
1990,
29918,
2541,
29918,
19290,
29898,
13,
9651,
770,
29918,
978,
29922,
16950,
29918,
2917,
3366,
1853,
12436,
13,
9651,
770,
29918,
5085,
29922,
16950,
29918,
2917,
29889,
657,
703,
19290,
613,
6571,
511,
13,
4706,
1723,
13,
13,
4706,
1583,
29889,
842,
29918,
16950,
29898,
16950,
29897,
13,
13,
4706,
396,
379,
9629,
2609,
1653,
379,
9629,
515,
278,
6426,
9657,
310,
1051,
13,
4706,
565,
376,
7032,
943,
29908,
297,
2295,
29879,
322,
2295,
29879,
3366,
7032,
943,
3108,
338,
451,
6213,
29901,
13,
9651,
363,
21433,
29918,
2917,
29879,
297,
2295,
29879,
3366,
7032,
943,
3108,
29901,
13,
18884,
282,
29892,
21433,
29918,
29882,
7529,
353,
1653,
29918,
1990,
29918,
2541,
29918,
19290,
29898,
13,
462,
1678,
770,
29918,
978,
29922,
26482,
29918,
2917,
29879,
3366,
1853,
12436,
13,
462,
1678,
770,
29918,
5085,
29922,
26482,
29918,
2917,
29879,
29889,
657,
703,
19290,
613,
6571,
511,
13,
462,
1678,
298,
29918,
7529,
29922,
26482,
29918,
2917,
29879,
29889,
657,
703,
29882,
7529,
613,
6571,
511,
13,
18884,
1723,
13,
13,
18884,
11764,
29918,
29882,
7529,
353,
21433,
29918,
29882,
7529,
29889,
14357,
13,
18884,
11764,
29918,
1990,
353,
679,
29918,
1990,
29898,
14357,
29918,
29882,
7529,
1839,
1853,
11287,
13,
18884,
11764,
29918,
19290,
353,
11764,
29918,
29882,
7529,
3366,
19290,
3108,
13,
13,
18884,
11764,
353,
11764,
29918,
1990,
29898,
1068,
14357,
29918,
19290,
29897,
13,
13,
18884,
1583,
29889,
1202,
29918,
26482,
29898,
29886,
29892,
21433,
29918,
29882,
7529,
29892,
11764,
29897,
13,
13,
9651,
1583,
29889,
24926,
580,
13,
13,
13,
1753,
1653,
29918,
1990,
29918,
2541,
29918,
19290,
29898,
13,
4706,
770,
29918,
978,
29901,
851,
29892,
770,
29918,
5085,
29901,
360,
919,
29892,
298,
29918,
7529,
29901,
28379,
29961,
21533,
29962,
353,
6213,
1125,
13,
1678,
1067,
29879,
353,
679,
29918,
1990,
29898,
1990,
29918,
978,
29897,
13,
1678,
565,
451,
770,
29918,
5085,
29901,
13,
4706,
770,
29918,
5085,
353,
6571,
13,
1678,
5446,
353,
1067,
29879,
29898,
1068,
1990,
29918,
5085,
29897,
13,
13,
1678,
282,
29918,
7529,
29901,
360,
919,
353,
6571,
13,
13,
1678,
565,
298,
29918,
7529,
338,
451,
6213,
322,
320,
13,
9651,
376,
2917,
29918,
2084,
29908,
297,
298,
29918,
7529,
322,
320,
13,
9651,
298,
29918,
7529,
3366,
2917,
29918,
2084,
3108,
338,
451,
6213,
29901,
13,
4706,
934,
6707,
29918,
29882,
7529,
353,
343,
8807,
29889,
11177,
29918,
1359,
29898,
3150,
29898,
29882,
29918,
7529,
3366,
2917,
29918,
2084,
3108,
876,
13,
1678,
1683,
29901,
13,
4706,
934,
6707,
29918,
29882,
7529,
353,
6571,
13,
1678,
282,
29918,
7529,
29889,
5504,
29898,
1445,
6707,
29918,
29882,
7529,
29897,
13,
13,
1678,
565,
298,
29918,
7529,
338,
451,
6213,
29901,
13,
4706,
282,
29918,
7529,
29889,
5504,
29898,
29882,
29918,
7529,
29889,
657,
703,
957,
3539,
29918,
2917,
29879,
613,
6571,
876,
13,
1678,
2322,
29918,
26482,
29918,
29882,
7529,
353,
1067,
29879,
29889,
4381,
29918,
29882,
7529,
580,
13,
13,
1678,
21433,
29918,
29882,
7529,
353,
379,
9629,
29898,
29886,
29918,
7529,
29892,
13,
462,
18884,
2322,
29918,
26482,
29918,
29882,
7529,
29897,
13,
13,
1678,
736,
5446,
29892,
21433,
29918,
29882,
7529,
13,
2
] |
vjezba1/UDP_client.py | vmilkovic/primjena-blockchain-tehnologije | 0 | 133187 | <filename>vjezba1/UDP_client.py
import socket
HOST = '127.0.0.1'
PORT = 6444
poruka = input("unesi: ")
poruka = poruka.encode()
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.sendto(poruka, (HOST, PORT))
data = s.recv(1024)
print('Received from server ', data)
| [
1,
529,
9507,
29958,
29894,
1324,
29920,
2291,
29896,
29914,
29965,
11191,
29918,
4645,
29889,
2272,
13,
5215,
9909,
13,
13,
20832,
353,
525,
29896,
29906,
29955,
29889,
29900,
29889,
29900,
29889,
29896,
29915,
13,
15082,
353,
29871,
29953,
29946,
29946,
29946,
13,
13,
1971,
22971,
353,
1881,
703,
7844,
29875,
29901,
16521,
13,
1971,
22971,
353,
1277,
22971,
29889,
12508,
580,
13,
13,
2541,
9909,
29889,
11514,
29898,
11514,
29889,
5098,
29918,
1177,
2544,
29892,
9909,
29889,
6156,
7077,
29918,
29928,
29954,
25058,
29897,
408,
269,
29901,
13,
1678,
269,
29889,
6717,
517,
29898,
1971,
22971,
29892,
313,
20832,
29892,
349,
8476,
876,
13,
1678,
848,
353,
269,
29889,
3757,
29894,
29898,
29896,
29900,
29906,
29946,
29897,
13,
1678,
1596,
877,
29816,
515,
1923,
13420,
848,
29897,
13,
2
] |
code/Built-in-Types/set.py | zhangsucheng/Python-pracive | 0 | 179481 | set1 = set()
set1.add(1)
set2 = {1, 2, 3}
print(set1)
print(set1 | set2)
print(set1 & set2)
| [
1,
731,
29896,
353,
731,
580,
13,
842,
29896,
29889,
1202,
29898,
29896,
29897,
13,
842,
29906,
353,
426,
29896,
29892,
29871,
29906,
29892,
29871,
29941,
29913,
13,
2158,
29898,
842,
29896,
29897,
13,
2158,
29898,
842,
29896,
891,
731,
29906,
29897,
13,
2158,
29898,
842,
29896,
669,
731,
29906,
29897,
13,
2
] |
timeeval_experiments/algorithms/mstamp.py | HPI-Information-Systems/TimeEval | 2 | 190720 | <reponame>HPI-Information-Systems/TimeEval
from durations import Duration
from typing import Any, Dict, Optional
from timeeval import Algorithm, TrainingType, InputDimensionality
from timeeval.adapters import DockerAdapter
from timeeval.params import ParameterConfig
import numpy as np
from timeeval.utils.window import ReverseWindowing
# post-processing for left_stampi
def post_mstamp(scores: np.ndarray, args: dict) -> np.ndarray:
window_size = args.get("hyper_params", {}).get("anomaly_window_size", 50)
return ReverseWindowing(window_size=window_size).fit_transform(scores)
_mstamp_parameters: Dict[str, Dict[str, Any]] = {
"anomaly_window_size": {
"defaultValue": 50,
"description": "Size of the sliding windows",
"name": "anomaly_window_size",
"type": "int"
},
"random_state": {
"defaultValue": 42,
"description": "Seed for the random number generator",
"name": "random_state",
"type": "int"
}
}
def mstamp(params: ParameterConfig = None, skip_pull: bool = False, timeout: Optional[Duration] = None) -> Algorithm:
return Algorithm(
name="mSTAMP",
main=DockerAdapter(
image_name="registry.gitlab.hpi.de/akita/i/mstamp",
skip_pull=skip_pull,
timeout=timeout,
group_privileges="akita",
),
preprocess=None,
postprocess=post_mstamp,
param_schema=_mstamp_parameters,
param_config=params or ParameterConfig.defaults(),
data_as_file=True,
training_type=TrainingType.UNSUPERVISED,
input_dimensionality=InputDimensionality("multivariate")
)
| [
1,
529,
276,
1112,
420,
29958,
29950,
2227,
29899,
20350,
29899,
3924,
29879,
29914,
2481,
29923,
791,
13,
3166,
1411,
800,
1053,
360,
2633,
13,
3166,
19229,
1053,
3139,
29892,
360,
919,
29892,
28379,
13,
13,
3166,
931,
14513,
1053,
29068,
29892,
26101,
1542,
29892,
10567,
16142,
8180,
537,
13,
3166,
931,
14513,
29889,
328,
481,
2153,
1053,
20868,
6168,
13,
3166,
931,
14513,
29889,
7529,
1053,
24953,
3991,
13,
13,
5215,
12655,
408,
7442,
13,
13,
13,
3166,
931,
14513,
29889,
13239,
29889,
7165,
1053,
830,
3901,
5907,
292,
13,
29937,
1400,
29899,
19170,
363,
2175,
29918,
303,
1160,
29875,
13,
1753,
1400,
29918,
29885,
303,
1160,
29898,
1557,
2361,
29901,
7442,
29889,
299,
2378,
29892,
6389,
29901,
9657,
29897,
1599,
7442,
29889,
299,
2378,
29901,
13,
1678,
3474,
29918,
2311,
353,
6389,
29889,
657,
703,
24947,
29918,
7529,
613,
6571,
467,
657,
703,
273,
290,
14997,
29918,
7165,
29918,
2311,
613,
29871,
29945,
29900,
29897,
13,
1678,
736,
830,
3901,
5907,
292,
29898,
7165,
29918,
2311,
29922,
7165,
29918,
2311,
467,
9202,
29918,
9067,
29898,
1557,
2361,
29897,
13,
13,
13,
29918,
29885,
303,
1160,
29918,
16744,
29901,
360,
919,
29961,
710,
29892,
360,
919,
29961,
710,
29892,
3139,
5262,
353,
426,
13,
376,
273,
290,
14997,
29918,
7165,
29918,
2311,
1115,
426,
13,
29871,
376,
4381,
1917,
1115,
29871,
29945,
29900,
29892,
13,
29871,
376,
8216,
1115,
376,
3505,
310,
278,
2243,
4821,
5417,
613,
13,
29871,
376,
978,
1115,
376,
273,
290,
14997,
29918,
7165,
29918,
2311,
613,
13,
29871,
376,
1853,
1115,
376,
524,
29908,
13,
2981,
13,
376,
8172,
29918,
3859,
1115,
426,
13,
29871,
376,
4381,
1917,
1115,
29871,
29946,
29906,
29892,
13,
29871,
376,
8216,
1115,
376,
2008,
287,
363,
278,
4036,
1353,
15299,
613,
13,
29871,
376,
978,
1115,
376,
8172,
29918,
3859,
613,
13,
29871,
376,
1853,
1115,
376,
524,
29908,
13,
500,
13,
29913,
13,
13,
13,
1753,
286,
303,
1160,
29898,
7529,
29901,
24953,
3991,
353,
6213,
29892,
14383,
29918,
26746,
29901,
6120,
353,
7700,
29892,
11815,
29901,
28379,
29961,
18984,
29962,
353,
6213,
29897,
1599,
29068,
29901,
13,
1678,
736,
29068,
29898,
13,
4706,
1024,
543,
29885,
1254,
19297,
613,
13,
4706,
1667,
29922,
29928,
8658,
6168,
29898,
13,
9651,
1967,
29918,
978,
543,
1727,
6020,
29889,
5559,
8205,
29889,
29882,
1631,
29889,
311,
29914,
557,
2028,
29914,
29875,
29914,
29885,
303,
1160,
613,
13,
9651,
14383,
29918,
26746,
29922,
11014,
29918,
26746,
29892,
13,
9651,
11815,
29922,
15619,
29892,
13,
9651,
2318,
29918,
22534,
488,
2710,
543,
557,
2028,
613,
13,
4706,
10353,
13,
4706,
758,
5014,
29922,
8516,
29892,
13,
4706,
1400,
5014,
29922,
2490,
29918,
29885,
303,
1160,
29892,
13,
4706,
1828,
29918,
11010,
29922,
29918,
29885,
303,
1160,
29918,
16744,
29892,
13,
4706,
1828,
29918,
2917,
29922,
7529,
470,
24953,
3991,
29889,
4381,
29879,
3285,
13,
4706,
848,
29918,
294,
29918,
1445,
29922,
5574,
29892,
13,
4706,
6694,
29918,
1853,
29922,
5323,
2827,
1542,
29889,
29965,
3059,
4897,
1001,
18118,
1660,
29928,
29892,
13,
4706,
1881,
29918,
12531,
537,
29922,
4290,
16142,
8180,
537,
703,
4713,
27432,
403,
1159,
13,
1678,
1723,
13,
2
] |
test/integration/objectstore/test_mixed_store_by.py | beatrizserrano/galaxy | 0 | 85116 | <reponame>beatrizserrano/galaxy<gh_stars>0
"""Integration tests for mixing store_by."""
import os
import re
import string
from galaxy.util import is_uuid
from ._base import (
BaseObjectStoreIntegrationTestCase,
files_count,
)
DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(
"""<?xml version="1.0"?>
<object_store type="distributed" id="primary" order="0">
<backends>
<backend id="files1" type="disk" weight="1" store_by="uuid">
<files_dir path="${temp_directory}/files1"/>
<extra_dir type="temp" path="${temp_directory}/tmp1"/>
<extra_dir type="job_work" path="${temp_directory}/job_working_directory1"/>
</backend>
<backend id="files2" type="disk" weight="1" store_by="id">
<files_dir path="${temp_directory}/files2"/>
<extra_dir type="temp" path="${temp_directory}/tmp2"/>
<extra_dir type="job_work" path="${temp_directory}/job_working_directory2"/>
</backend>
</backends>
</object_store>
"""
)
TEST_INPUT_FILES_CONTENT = "1 2 3"
class MixedStoreByObjectStoreIntegrationTestCase(BaseObjectStoreIntegrationTestCase):
# setup by _configure_object_store
files1_path: str
files2_path: str
@classmethod
def handle_galaxy_config_kwds(cls, config):
cls._configure_object_store(DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE, config)
def test_both_types(self):
"""Test each object store configures files correctly."""
i = 0
with self.dataset_populator.test_history() as history_id:
# Loop breaks once each object store has at least once file of each type.
while True:
hda = self.dataset_populator.new_dataset(history_id, content=TEST_INPUT_FILES_CONTENT, wait=True)
content = self.dataset_populator.get_history_dataset_content(history_id, hda["id"])
assert content.strip() == TEST_INPUT_FILES_CONTENT
files1_count = files_count(self.files1_path)
files2_count = files_count(self.files2_path)
if files1_count and files2_count:
break
i += 1
if i > 50:
raise Exception(
"Problem with logic of test, randomly each object store should have at least one file by now"
)
def strip_to_id(x):
match = re.match(r"dataset_(.*)\.dat", os.path.basename(x))
assert match
return match.group(1)
files1_paths = [strip_to_id(p) for p in _get_datasets_files_in_path(self.files1_path)]
files2_paths = [strip_to_id(p) for p in _get_datasets_files_in_path(self.files2_path)]
for files1_path in files1_paths:
assert is_uuid(files1_path)
for files2_path in files2_paths:
assert files2_path.isdigit()
def _get_datasets_files_in_path(directory):
files = []
for path, _, filename in os.walk(directory):
for f in filename:
if f.endswith(".dat"):
files.append(os.path.join(path, f))
return files
| [
1,
529,
276,
1112,
420,
29958,
915,
271,
7485,
643,
12776,
29914,
23014,
26825,
29966,
12443,
29918,
303,
1503,
29958,
29900,
13,
15945,
29908,
23573,
362,
6987,
363,
24907,
3787,
29918,
1609,
1213,
15945,
13,
13,
5215,
2897,
13,
5215,
337,
13,
5215,
1347,
13,
13,
3166,
15400,
29891,
29889,
4422,
1053,
338,
29918,
25118,
13,
3166,
869,
29918,
3188,
1053,
313,
13,
1678,
7399,
2061,
9044,
23573,
362,
3057,
8259,
29892,
13,
1678,
2066,
29918,
2798,
29892,
13,
29897,
13,
13,
4571,
1254,
3960,
29933,
2692,
3352,
29918,
14824,
17637,
29918,
1254,
29949,
1525,
29918,
25903,
29918,
4330,
3580,
29931,
3040,
353,
1347,
29889,
6733,
29898,
13,
1678,
9995,
8169,
3134,
1873,
543,
29896,
29889,
29900,
18943,
13,
29966,
3318,
29918,
8899,
1134,
543,
5721,
7541,
29908,
1178,
543,
16072,
29908,
1797,
543,
29900,
1013,
13,
1678,
529,
1627,
1975,
29958,
13,
4706,
529,
27852,
1178,
543,
5325,
29896,
29908,
1134,
543,
20960,
29908,
7688,
543,
29896,
29908,
3787,
29918,
1609,
543,
25118,
1013,
13,
9651,
529,
5325,
29918,
3972,
2224,
19070,
7382,
29918,
12322,
6822,
5325,
29896,
4681,
13,
9651,
529,
17833,
29918,
3972,
1134,
543,
7382,
29908,
2224,
19070,
7382,
29918,
12322,
6822,
7050,
29896,
4681,
13,
9651,
529,
17833,
29918,
3972,
1134,
543,
9057,
29918,
1287,
29908,
2224,
19070,
7382,
29918,
12322,
6822,
9057,
29918,
22899,
29918,
12322,
29896,
4681,
13,
4706,
1533,
27852,
29958,
13,
4706,
529,
27852,
1178,
543,
5325,
29906,
29908,
1134,
543,
20960,
29908,
7688,
543,
29896,
29908,
3787,
29918,
1609,
543,
333,
1013,
13,
9651,
529,
5325,
29918,
3972,
2224,
19070,
7382,
29918,
12322,
6822,
5325,
29906,
4681,
13,
9651,
529,
17833,
29918,
3972,
1134,
543,
7382,
29908,
2224,
19070,
7382,
29918,
12322,
6822,
7050,
29906,
4681,
13,
9651,
529,
17833,
29918,
3972,
1134,
543,
9057,
29918,
1287,
29908,
2224,
19070,
7382,
29918,
12322,
6822,
9057,
29918,
22899,
29918,
12322,
29906,
4681,
13,
4706,
1533,
27852,
29958,
13,
1678,
1533,
1627,
1975,
29958,
13,
829,
3318,
29918,
8899,
29958,
13,
15945,
29908,
13,
29897,
13,
13,
18267,
29918,
1177,
12336,
29918,
24483,
29918,
22412,
3919,
353,
376,
29896,
29871,
29906,
29871,
29941,
29908,
13,
13,
13,
1990,
341,
11925,
9044,
2059,
2061,
9044,
23573,
362,
3057,
8259,
29898,
5160,
2061,
9044,
23573,
362,
3057,
8259,
1125,
13,
1678,
396,
6230,
491,
903,
17591,
29918,
3318,
29918,
8899,
13,
1678,
2066,
29896,
29918,
2084,
29901,
851,
13,
1678,
2066,
29906,
29918,
2084,
29901,
851,
13,
13,
1678,
732,
1990,
5696,
13,
1678,
822,
4386,
29918,
23014,
26825,
29918,
2917,
29918,
11022,
6289,
29898,
25932,
29892,
2295,
1125,
13,
4706,
1067,
29879,
3032,
17591,
29918,
3318,
29918,
8899,
29898,
4571,
1254,
3960,
29933,
2692,
3352,
29918,
14824,
17637,
29918,
1254,
29949,
1525,
29918,
25903,
29918,
4330,
3580,
29931,
3040,
29892,
2295,
29897,
13,
13,
1678,
822,
1243,
29918,
20313,
29918,
8768,
29898,
1311,
1125,
13,
4706,
9995,
3057,
1269,
1203,
3787,
2295,
1973,
2066,
5149,
1213,
15945,
13,
4706,
474,
353,
29871,
29900,
13,
4706,
411,
1583,
29889,
24713,
29918,
7323,
9183,
29889,
1688,
29918,
18434,
580,
408,
4955,
29918,
333,
29901,
13,
9651,
396,
21493,
16706,
2748,
1269,
1203,
3787,
756,
472,
3203,
2748,
934,
310,
1269,
1134,
29889,
13,
9651,
1550,
5852,
29901,
13,
18884,
298,
1388,
353,
1583,
29889,
24713,
29918,
7323,
9183,
29889,
1482,
29918,
24713,
29898,
18434,
29918,
333,
29892,
2793,
29922,
18267,
29918,
1177,
12336,
29918,
24483,
29918,
22412,
3919,
29892,
4480,
29922,
5574,
29897,
13,
18884,
2793,
353,
1583,
29889,
24713,
29918,
7323,
9183,
29889,
657,
29918,
18434,
29918,
24713,
29918,
3051,
29898,
18434,
29918,
333,
29892,
298,
1388,
3366,
333,
20068,
13,
18884,
4974,
2793,
29889,
17010,
580,
1275,
17067,
1254,
29918,
1177,
12336,
29918,
24483,
29918,
22412,
3919,
13,
18884,
2066,
29896,
29918,
2798,
353,
2066,
29918,
2798,
29898,
1311,
29889,
5325,
29896,
29918,
2084,
29897,
13,
18884,
2066,
29906,
29918,
2798,
353,
2066,
29918,
2798,
29898,
1311,
29889,
5325,
29906,
29918,
2084,
29897,
13,
18884,
565,
2066,
29896,
29918,
2798,
322,
2066,
29906,
29918,
2798,
29901,
13,
462,
1678,
2867,
13,
18884,
474,
4619,
29871,
29896,
13,
18884,
565,
474,
1405,
29871,
29945,
29900,
29901,
13,
462,
1678,
12020,
8960,
29898,
13,
462,
4706,
376,
26604,
411,
5900,
310,
1243,
29892,
20459,
1269,
1203,
3787,
881,
505,
472,
3203,
697,
934,
491,
1286,
29908,
13,
462,
1678,
1723,
13,
13,
9651,
822,
17820,
29918,
517,
29918,
333,
29898,
29916,
1125,
13,
18884,
1993,
353,
337,
29889,
4352,
29898,
29878,
29908,
24713,
23538,
5575,
2144,
29889,
4130,
613,
2897,
29889,
2084,
29889,
6500,
3871,
29898,
29916,
876,
13,
18884,
4974,
1993,
13,
18884,
736,
1993,
29889,
2972,
29898,
29896,
29897,
13,
13,
9651,
2066,
29896,
29918,
24772,
353,
518,
17010,
29918,
517,
29918,
333,
29898,
29886,
29897,
363,
282,
297,
903,
657,
29918,
14538,
1691,
29918,
5325,
29918,
262,
29918,
2084,
29898,
1311,
29889,
5325,
29896,
29918,
2084,
4638,
13,
9651,
2066,
29906,
29918,
24772,
353,
518,
17010,
29918,
517,
29918,
333,
29898,
29886,
29897,
363,
282,
297,
903,
657,
29918,
14538,
1691,
29918,
5325,
29918,
262,
29918,
2084,
29898,
1311,
29889,
5325,
29906,
29918,
2084,
4638,
13,
9651,
363,
2066,
29896,
29918,
2084,
297,
2066,
29896,
29918,
24772,
29901,
13,
18884,
4974,
338,
29918,
25118,
29898,
5325,
29896,
29918,
2084,
29897,
13,
9651,
363,
2066,
29906,
29918,
2084,
297,
2066,
29906,
29918,
24772,
29901,
13,
18884,
4974,
2066,
29906,
29918,
2084,
29889,
275,
26204,
580,
13,
13,
13,
1753,
903,
657,
29918,
14538,
1691,
29918,
5325,
29918,
262,
29918,
2084,
29898,
12322,
1125,
13,
1678,
2066,
353,
5159,
13,
1678,
363,
2224,
29892,
17117,
10422,
297,
2897,
29889,
20919,
29898,
12322,
1125,
13,
4706,
363,
285,
297,
10422,
29901,
13,
9651,
565,
285,
29889,
1975,
2541,
17350,
4130,
29908,
1125,
13,
18884,
2066,
29889,
4397,
29898,
359,
29889,
2084,
29889,
7122,
29898,
2084,
29892,
285,
876,
13,
1678,
736,
2066,
13,
2
] |
src/pyrin/cli/core/template/__init__.py | wilsonGmn/pyrin | 0 | 41891 | <filename>src/pyrin/cli/core/template/__init__.py
# -*- coding: utf-8 -*-
"""
cli core template package.
"""
from pyrin.packaging.base import Package
class CLICoreTemplatePackage(Package):
"""
cli core template package class.
"""
NAME = __name__
| [
1,
529,
9507,
29958,
4351,
29914,
2272,
17056,
29914,
11303,
29914,
3221,
29914,
6886,
29914,
1649,
2344,
26914,
2272,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
15945,
29908,
13,
11303,
7136,
4472,
3577,
29889,
13,
15945,
29908,
13,
13,
3166,
282,
4316,
262,
29889,
4058,
6751,
29889,
3188,
1053,
22029,
13,
13,
13,
1990,
17332,
2965,
487,
6733,
14459,
29898,
14459,
1125,
13,
1678,
9995,
13,
1678,
9335,
7136,
4472,
3577,
770,
29889,
13,
1678,
9995,
13,
13,
1678,
27085,
353,
4770,
978,
1649,
13,
2
] |
jreast.py | setomits/jreaststatus | 0 | 48265 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from lxml import html
class JREast:
URL = 'http://traininfo.jreast.co.jp/train_info/{}.aspx'
lines = {
'kanto': ('東海道線', '京浜東北線', '横須賀線', '南武線', '横浜線',
'伊東線', '相模線', '鶴見線',
'宇都宮線', '高崎線', '京浜東北線', '埼京線', '川越線',
'武蔵野線', '上越線', '信越本線', '吾妻線', '烏山線',
'八高線', '日光線', '両毛線',
'中央線快速電車', '中央・総武各駅停車', '中央本線',
'武蔵野線', '五日市線', '青梅線', '八高線', '小海線',
'常磐線', '常磐線快速電車', '常磐線各駅停車', '水郡線',
'水戸線',
'総武快速線', '総武本線', '中央・総武各駅停車', '京葉線',
'武蔵野線', '内房線', '鹿島線', '久留里線', '外房線',
'東金線', '成田線',
'山手線',
'上野東京ライン', '湘南新宿ライン'),
'tohoku': ('羽越本線', '奥羽本線', '奥羽本線(山形線)', '常磐線',
'仙山線', '仙石線', '仙石東北ライン', '東北本線',
'磐越西線', '左沢線', '石巻線', '大船渡線',
'大船渡線BRT', '大湊線', '男鹿線', '釜石線', '北上線',
'気仙沼線', '気仙沼線BRT', '五能線', '水郡線',
'田沢湖線', '只見線', '津軽線', '八戸線', '花輪線',
'磐越東線', '山田線', '米坂線', '陸羽西線', '陸羽東線'),
'shinetsu': ('羽越本線', '信越本線', '上越線', '篠ノ井線', '中央本線',
'白新線', '磐越西線', '飯山線', '越後線', '大糸線',
'小海線', '只見線', '弥彦線', '米坂線')
}
def _extract_status(self, th):
s = {}
td = th.getnext()
s['status'] = td.xpath('img')[0].attrib['alt']
if s['status'] != '平常運転':
td = td.getnext()
s['publishedAt'] = td.text.strip()
td = th.getparent().getnext().xpath('td[@class="cause"]')[0]
s['detail'] = td.text.strip()
return s
def status(self, line):
self.area = None
for area in JREast.lines:
for l in JREast.lines[area]:
if l == line:
self.area = area
break
if self.area:
break
m = {'area': self.area, 'line': line, 'statuses': []}
if self.area:
url = JREast.URL.format(self.area)
else:
return m
dom = html.parse(url)
th = None
for node in dom.xpath('//th[@class="text-tit-xlarge"]'):
if node.text.strip() == line:
m['statuses'].append(self._extract_status(node))
return m
if __name__ == '__main__':
import pprint
jr = JREast()
pprint.pprint(jr.status('山田線'))
pprint.pprint(jr.status('京葉線'))
| [
1,
18787,
4855,
29914,
2109,
29914,
6272,
3017,
13,
29937,
448,
29930,
29899,
14137,
29901,
23616,
29899,
29947,
448,
29930,
29899,
13,
13,
3166,
301,
3134,
1053,
3472,
13,
13,
1990,
435,
1525,
579,
29901,
13,
1678,
3988,
353,
525,
1124,
597,
14968,
3888,
29889,
29926,
276,
579,
29889,
1111,
29889,
16865,
29914,
14968,
29918,
3888,
19248,
1836,
6307,
29915,
13,
13,
1678,
3454,
353,
426,
13,
4706,
525,
29895,
5361,
2396,
6702,
30591,
30581,
30397,
31357,
742,
525,
30675,
233,
184,
159,
30591,
30662,
31357,
742,
525,
233,
171,
173,
236,
163,
139,
235,
182,
131,
31357,
742,
525,
30601,
30819,
31357,
742,
525,
233,
171,
173,
233,
184,
159,
31357,
742,
13,
462,
29871,
525,
31308,
30591,
31357,
742,
525,
30990,
31382,
31357,
742,
525,
236,
185,
183,
31192,
31357,
742,
13,
13,
462,
29871,
525,
31503,
30769,
31004,
31357,
742,
525,
30528,
31416,
31357,
742,
525,
30675,
233,
184,
159,
30591,
30662,
31357,
742,
525,
232,
162,
191,
30675,
31357,
742,
525,
30575,
31844,
31357,
742,
13,
462,
29871,
525,
30819,
235,
151,
184,
30661,
31357,
742,
525,
30429,
31844,
31357,
742,
525,
30689,
31844,
30346,
31357,
742,
525,
232,
147,
193,
232,
169,
190,
31357,
742,
525,
234,
134,
146,
30329,
31357,
742,
29871,
13,
462,
29871,
525,
31044,
30528,
31357,
742,
525,
30325,
30867,
31357,
742,
525,
231,
187,
164,
233,
178,
158,
31357,
742,
13,
13,
462,
29871,
525,
30275,
232,
167,
177,
31357,
232,
194,
174,
31859,
31385,
31587,
742,
525,
30275,
232,
167,
177,
30290,
234,
186,
146,
30819,
232,
147,
135,
30920,
232,
132,
159,
31587,
742,
525,
30275,
232,
167,
177,
30346,
31357,
742,
13,
462,
29871,
525,
30819,
235,
151,
184,
30661,
31357,
742,
525,
30904,
30325,
30461,
31357,
742,
525,
30986,
31948,
31357,
742,
525,
31044,
30528,
31357,
742,
525,
30446,
30581,
31357,
742,
13,
13,
462,
29871,
525,
31190,
234,
166,
147,
31357,
742,
525,
31190,
234,
166,
147,
31357,
232,
194,
174,
31859,
31385,
31587,
742,
525,
31190,
234,
166,
147,
31357,
232,
147,
135,
30920,
232,
132,
159,
31587,
742,
525,
30716,
31103,
31357,
742,
29871,
13,
462,
29871,
525,
30716,
31627,
31357,
742,
13,
13,
462,
29871,
525,
234,
186,
146,
30819,
232,
194,
174,
31859,
31357,
742,
525,
234,
186,
146,
30819,
30346,
31357,
742,
525,
30275,
232,
167,
177,
30290,
234,
186,
146,
30819,
232,
147,
135,
30920,
232,
132,
159,
31587,
742,
525,
30675,
31602,
31357,
742,
13,
462,
29871,
525,
30819,
235,
151,
184,
30661,
31357,
742,
525,
30728,
31975,
31357,
742,
525,
236,
188,
194,
30721,
31357,
742,
525,
31347,
234,
152,
156,
30755,
31357,
742,
525,
31066,
31975,
31357,
742,
13,
462,
29871,
525,
30591,
30659,
31357,
742,
525,
30494,
30395,
31357,
742,
13,
13,
462,
29871,
525,
30329,
30880,
31357,
742,
13,
13,
462,
29871,
525,
30429,
30661,
30591,
30675,
30281,
30260,
30203,
742,
525,
233,
188,
155,
30601,
30374,
31612,
30281,
30260,
30203,
5477,
13,
13,
4706,
525,
517,
29882,
9154,
2396,
6702,
234,
193,
192,
31844,
30346,
31357,
742,
525,
232,
168,
168,
234,
193,
192,
30346,
31357,
742,
525,
232,
168,
168,
234,
193,
192,
30346,
31357,
30419,
30329,
31305,
31357,
30409,
742,
525,
31190,
234,
166,
147,
31357,
742,
29871,
13,
462,
259,
525,
231,
190,
156,
30329,
31357,
742,
525,
231,
190,
156,
30814,
31357,
742,
525,
231,
190,
156,
30814,
30591,
30662,
30281,
30260,
30203,
742,
525,
30591,
30662,
30346,
31357,
742,
13,
462,
259,
525,
234,
166,
147,
31844,
30602,
31357,
742,
525,
31651,
31740,
31357,
742,
525,
30814,
232,
186,
190,
31357,
742,
525,
30257,
235,
139,
188,
31858,
31357,
742,
29871,
13,
462,
259,
525,
30257,
235,
139,
188,
31858,
31357,
242,
191,
165,
242,
191,
181,
242,
191,
183,
742,
525,
30257,
233,
188,
141,
31357,
742,
525,
31203,
236,
188,
194,
31357,
742,
525,
236,
138,
159,
30814,
31357,
742,
525,
30662,
30429,
31357,
742,
29871,
13,
462,
259,
525,
31648,
231,
190,
156,
233,
181,
191,
31357,
742,
525,
31648,
231,
190,
156,
233,
181,
191,
31357,
242,
191,
165,
242,
191,
181,
242,
191,
183,
742,
525,
30904,
30815,
31357,
742,
525,
30716,
31103,
31357,
742,
13,
462,
259,
525,
30395,
31740,
31496,
31357,
742,
525,
31557,
31192,
31357,
742,
525,
31365,
235,
190,
192,
31357,
742,
525,
31044,
31627,
31357,
742,
525,
30830,
235,
191,
173,
31357,
742,
13,
462,
259,
525,
234,
166,
147,
31844,
30591,
31357,
742,
525,
30329,
30395,
31357,
742,
525,
31902,
31813,
31357,
742,
525,
236,
156,
187,
234,
193,
192,
30602,
31357,
742,
525,
236,
156,
187,
234,
193,
192,
30591,
31357,
5477,
13,
13,
4706,
525,
845,
262,
1691,
29884,
2396,
6702,
234,
193,
192,
31844,
30346,
31357,
742,
525,
30689,
31844,
30346,
31357,
742,
525,
30429,
31844,
31357,
742,
525,
234,
178,
163,
30901,
30945,
31357,
742,
525,
30275,
232,
167,
177,
30346,
31357,
742,
13,
462,
268,
525,
30868,
30374,
31357,
742,
525,
234,
166,
147,
31844,
30602,
31357,
742,
525,
236,
166,
178,
30329,
31357,
742,
525,
31844,
31220,
31357,
742,
525,
30257,
234,
182,
187,
31357,
742,
29871,
13,
462,
268,
525,
30446,
30581,
31357,
742,
525,
31557,
31192,
31357,
742,
525,
232,
191,
168,
31898,
31357,
742,
525,
31902,
31813,
31357,
1495,
13,
4706,
500,
13,
13,
13,
1678,
822,
903,
21111,
29918,
4882,
29898,
1311,
29892,
266,
1125,
13,
4706,
269,
353,
6571,
13,
13,
4706,
22599,
353,
266,
29889,
657,
4622,
580,
13,
4706,
269,
1839,
4882,
2033,
353,
22599,
29889,
23635,
877,
2492,
29861,
29900,
1822,
1131,
1091,
1839,
1997,
2033,
13,
4706,
565,
269,
1839,
4882,
2033,
2804,
525,
30606,
31190,
236,
132,
142,
235,
190,
165,
2396,
13,
9651,
22599,
353,
22599,
29889,
657,
4622,
580,
13,
9651,
269,
1839,
5467,
3726,
4178,
2033,
353,
22599,
29889,
726,
29889,
17010,
580,
13,
9651,
22599,
353,
266,
29889,
657,
3560,
2141,
657,
4622,
2141,
23635,
877,
1594,
17548,
1990,
543,
29883,
1071,
3108,
29861,
29900,
29962,
13,
9651,
269,
1839,
16432,
2033,
353,
22599,
29889,
726,
29889,
17010,
580,
13,
13,
4706,
736,
269,
13,
13,
1678,
822,
4660,
29898,
1311,
29892,
1196,
1125,
13,
4706,
1583,
29889,
6203,
353,
6213,
13,
13,
4706,
363,
4038,
297,
435,
1525,
579,
29889,
9012,
29901,
13,
9651,
363,
301,
297,
435,
1525,
579,
29889,
9012,
29961,
6203,
5387,
13,
18884,
565,
301,
1275,
1196,
29901,
13,
462,
1678,
1583,
29889,
6203,
353,
4038,
13,
462,
1678,
2867,
13,
13,
9651,
565,
1583,
29889,
6203,
29901,
13,
18884,
2867,
13,
13,
4706,
286,
353,
11117,
6203,
2396,
1583,
29889,
6203,
29892,
525,
1220,
2396,
1196,
29892,
525,
4882,
267,
2396,
5159,
29913,
13,
13,
4706,
565,
1583,
29889,
6203,
29901,
13,
9651,
3142,
353,
435,
1525,
579,
29889,
4219,
29889,
4830,
29898,
1311,
29889,
6203,
29897,
13,
4706,
1683,
29901,
13,
9651,
736,
286,
13,
13,
4706,
2432,
353,
3472,
29889,
5510,
29898,
2271,
29897,
13,
13,
4706,
266,
353,
6213,
13,
4706,
363,
2943,
297,
2432,
29889,
23635,
877,
458,
386,
17548,
1990,
543,
726,
29899,
23545,
29899,
29916,
16961,
3108,
29374,
13,
9651,
565,
2943,
29889,
726,
29889,
17010,
580,
1275,
1196,
29901,
13,
18884,
286,
1839,
4882,
267,
13359,
4397,
29898,
1311,
3032,
21111,
29918,
4882,
29898,
3177,
876,
13,
632,
13,
4706,
736,
286,
13,
13,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
13,
1678,
1053,
282,
2158,
13,
13,
1678,
432,
29878,
353,
435,
1525,
579,
580,
13,
13,
1678,
282,
2158,
29889,
407,
29878,
524,
29898,
29926,
29878,
29889,
4882,
877,
30329,
30395,
31357,
8785,
13,
1678,
282,
2158,
29889,
407,
29878,
524,
29898,
29926,
29878,
29889,
4882,
877,
30675,
31602,
31357,
8785,
13,
2
] |
server/util/stringutil.py | rleir/MediaCloud-Web-Tools | 0 | 193733 | <filename>server/util/stringutil.py
import logging
from datetime import datetime
from server import mc
logger = logging.getLogger(__name__)
def ids_from_comma_separated_str(comma_separated_string):
id_list = []
if len(comma_separated_string) > 0:
id_list = [int(cid) for cid in comma_separated_string.split(",") if len(cid) > 0]
return id_list
def trim_solr_date(date_str):
return datetime.strptime(date_str, mc.SENTENCE_PUBLISH_DATE_FORMAT).strftime("%Y-%m-%d")
| [
1,
529,
9507,
29958,
2974,
29914,
4422,
29914,
1807,
4422,
29889,
2272,
13,
5215,
12183,
13,
3166,
12865,
1053,
12865,
13,
3166,
1923,
1053,
286,
29883,
29871,
13,
13,
21707,
353,
12183,
29889,
657,
16363,
22168,
978,
1649,
29897,
13,
13,
13,
1753,
18999,
29918,
3166,
29918,
510,
655,
29918,
25048,
630,
29918,
710,
29898,
510,
655,
29918,
25048,
630,
29918,
1807,
1125,
13,
1678,
1178,
29918,
1761,
353,
5159,
13,
1678,
565,
7431,
29898,
510,
655,
29918,
25048,
630,
29918,
1807,
29897,
1405,
29871,
29900,
29901,
13,
4706,
1178,
29918,
1761,
353,
518,
524,
29898,
25232,
29897,
363,
274,
333,
297,
16694,
29918,
25048,
630,
29918,
1807,
29889,
5451,
28165,
1159,
565,
7431,
29898,
25232,
29897,
1405,
29871,
29900,
29962,
13,
1678,
736,
1178,
29918,
1761,
13,
13,
13,
1753,
17151,
29918,
2929,
29878,
29918,
1256,
29898,
1256,
29918,
710,
1125,
13,
29871,
736,
12865,
29889,
710,
415,
603,
29898,
1256,
29918,
710,
29892,
286,
29883,
29889,
29903,
3919,
1430,
4741,
29918,
7056,
13367,
3235,
29950,
29918,
6248,
29918,
19094,
1299,
467,
710,
615,
603,
11702,
29979,
19222,
29885,
19222,
29881,
1159,
13,
2
] |
smartsheet/models/alternate_email.py | Funtimes-Smarts/Python-import-Smart | 0 | 1613839 | # pylint: disable=C0111,R0902,R0904,R0912,R0913,R0915,E1101
# Smartsheet Python SDK.
#
# Copyright 2016 Smartsheet.com, 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 __future__ import absolute_import
from ..types import TypedList
from ..util import prep
from datetime import datetime
import json
import logging
import six
class AlternateEmail(object):
"""Smartsheet AlternateEmail data model."""
def __init__(self, props=None, base_obj=None):
"""Initialize the AlternateEmail model."""
self._base = None
if base_obj is not None:
self._base = base_obj
self._pre_request_filter = None
self._log = logging.getLogger(__name__)
self._confirmed = False
self._email = None
self.__id = None
if props:
# account for alternate variable names from raw API response
if 'confirmed' in props:
self.confirmed = props['confirmed']
if 'email' in props:
self.email = props['email']
# read only
if 'id' in props:
self._id = props['id']
# requests package Response object
self.request_response = None
self.__initialized = True
def __getattr__(self, key):
if key == 'id':
return self._id
else:
raise AttributeError(key)
@property
def confirmed(self):
return self._confirmed
@confirmed.setter
def confirmed(self, value):
if isinstance(value, bool):
self._confirmed = value
@property
def email(self):
return self._email
@email.setter
def email(self, value):
if isinstance(value, six.string_types):
self._email = value
@property
def _id(self):
return self.__id
@_id.setter
def _id(self, value):
if isinstance(value, six.integer_types):
self.__id = value
@property
def pre_request_filter(self):
return self._pre_request_filter
@pre_request_filter.setter
def pre_request_filter(self, value):
self._pre_request_filter = value
def to_dict(self, op_id=None, method=None):
obj = {
'confirmed': prep(self._confirmed),
'email': prep(self._email),
'id': prep(self.__id)}
return self._apply_pre_request_filter(obj)
def _apply_pre_request_filter(self, obj):
if self.pre_request_filter == 'add_alternate_email':
permitted = ['email']
all_keys = list(obj.keys())
for key in all_keys:
if key not in permitted:
self._log.debug(
'deleting %s from obj (filter: %s)',
key, self.pre_request_filter)
del obj[key]
return obj
def to_json(self):
return json.dumps(self.to_dict(), indent=2)
def __str__(self):
return json.dumps(self.to_dict())
| [
1,
396,
282,
2904,
524,
29901,
11262,
29922,
29907,
29900,
29896,
29896,
29896,
29892,
29934,
29900,
29929,
29900,
29906,
29892,
29934,
29900,
29929,
29900,
29946,
29892,
29934,
29900,
29929,
29896,
29906,
29892,
29934,
29900,
29929,
29896,
29941,
29892,
29934,
29900,
29929,
29896,
29945,
29892,
29923,
29896,
29896,
29900,
29896,
13,
29937,
4116,
5708,
4155,
5132,
12967,
29889,
13,
29937,
13,
29937,
14187,
1266,
29871,
29906,
29900,
29896,
29953,
4116,
5708,
4155,
29889,
510,
29892,
9266,
29889,
13,
29937,
13,
29937,
10413,
21144,
1090,
278,
13380,
19245,
29892,
10079,
29871,
29906,
29889,
29900,
313,
1552,
376,
29931,
293,
1947,
29908,
1125,
366,
1122,
13,
29937,
451,
671,
445,
934,
5174,
297,
752,
13036,
411,
278,
19245,
29889,
887,
1122,
4017,
13,
29937,
263,
3509,
310,
278,
19245,
472,
13,
29937,
13,
29937,
1678,
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,
399,
1806,
8187,
2692,
13,
29937,
399,
1718,
29934,
13566,
29059,
6323,
8707,
29928,
22122,
29903,
8079,
13764,
29979,
476,
22255,
29892,
2845,
4653,
470,
2411,
2957,
29889,
2823,
278,
13,
29937,
19245,
363,
278,
2702,
4086,
14765,
1076,
11239,
322,
27028,
13,
29937,
1090,
278,
19245,
29889,
13,
13,
3166,
4770,
29888,
9130,
1649,
1053,
8380,
29918,
5215,
13,
13,
3166,
6317,
8768,
1053,
14213,
287,
1293,
13,
3166,
6317,
4422,
1053,
8273,
13,
3166,
12865,
1053,
12865,
13,
5215,
4390,
13,
5215,
12183,
13,
5215,
4832,
13,
13,
1990,
12440,
403,
9823,
29898,
3318,
1125,
13,
13,
1678,
9995,
12636,
5708,
4155,
12440,
403,
9823,
848,
1904,
1213,
15945,
13,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
17761,
29922,
8516,
29892,
2967,
29918,
5415,
29922,
8516,
1125,
13,
4706,
9995,
6644,
6646,
278,
12440,
403,
9823,
1904,
1213,
15945,
13,
4706,
1583,
3032,
3188,
353,
6213,
13,
4706,
565,
2967,
29918,
5415,
338,
451,
6213,
29901,
13,
9651,
1583,
3032,
3188,
353,
2967,
29918,
5415,
13,
4706,
1583,
3032,
1457,
29918,
3827,
29918,
4572,
353,
6213,
13,
4706,
1583,
3032,
1188,
353,
12183,
29889,
657,
16363,
22168,
978,
1649,
29897,
13,
13,
4706,
1583,
3032,
5527,
381,
2168,
353,
7700,
13,
4706,
1583,
3032,
5269,
353,
6213,
13,
4706,
1583,
17255,
333,
353,
6213,
13,
13,
4706,
565,
17761,
29901,
13,
9651,
396,
3633,
363,
25010,
2286,
2983,
515,
10650,
3450,
2933,
13,
9651,
565,
525,
5527,
381,
2168,
29915,
297,
17761,
29901,
13,
18884,
1583,
29889,
5527,
381,
2168,
353,
17761,
1839,
5527,
381,
2168,
2033,
13,
9651,
565,
525,
5269,
29915,
297,
17761,
29901,
13,
18884,
1583,
29889,
5269,
353,
17761,
1839,
5269,
2033,
13,
9651,
396,
1303,
871,
13,
9651,
565,
525,
333,
29915,
297,
17761,
29901,
13,
18884,
1583,
3032,
333,
353,
17761,
1839,
333,
2033,
13,
4706,
396,
7274,
3577,
13291,
1203,
13,
4706,
1583,
29889,
3827,
29918,
5327,
353,
6213,
13,
4706,
1583,
17255,
11228,
1891,
353,
5852,
13,
13,
1678,
822,
4770,
657,
5552,
12035,
1311,
29892,
1820,
1125,
13,
4706,
565,
1820,
1275,
525,
333,
2396,
13,
9651,
736,
1583,
3032,
333,
13,
4706,
1683,
29901,
13,
9651,
12020,
23833,
2392,
29898,
1989,
29897,
13,
13,
1678,
732,
6799,
13,
1678,
822,
16725,
29898,
1311,
1125,
13,
4706,
736,
1583,
3032,
5527,
381,
2168,
13,
13,
1678,
732,
5527,
381,
2168,
29889,
842,
357,
13,
1678,
822,
16725,
29898,
1311,
29892,
995,
1125,
13,
4706,
565,
338,
8758,
29898,
1767,
29892,
6120,
1125,
13,
9651,
1583,
3032,
5527,
381,
2168,
353,
995,
13,
13,
1678,
732,
6799,
13,
1678,
822,
4876,
29898,
1311,
1125,
13,
4706,
736,
1583,
3032,
5269,
13,
13,
1678,
732,
5269,
29889,
842,
357,
13,
1678,
822,
4876,
29898,
1311,
29892,
995,
1125,
13,
4706,
565,
338,
8758,
29898,
1767,
29892,
4832,
29889,
1807,
29918,
8768,
1125,
13,
9651,
1583,
3032,
5269,
353,
995,
13,
13,
1678,
732,
6799,
13,
1678,
822,
903,
333,
29898,
1311,
1125,
13,
4706,
736,
1583,
17255,
333,
13,
13,
1678,
732,
29918,
333,
29889,
842,
357,
13,
1678,
822,
903,
333,
29898,
1311,
29892,
995,
1125,
13,
4706,
565,
338,
8758,
29898,
1767,
29892,
4832,
29889,
16031,
29918,
8768,
1125,
13,
9651,
1583,
17255,
333,
353,
995,
13,
13,
1678,
732,
6799,
13,
1678,
822,
758,
29918,
3827,
29918,
4572,
29898,
1311,
1125,
13,
4706,
736,
1583,
3032,
1457,
29918,
3827,
29918,
4572,
13,
13,
1678,
732,
1457,
29918,
3827,
29918,
4572,
29889,
842,
357,
13,
1678,
822,
758,
29918,
3827,
29918,
4572,
29898,
1311,
29892,
995,
1125,
13,
4706,
1583,
3032,
1457,
29918,
3827,
29918,
4572,
353,
995,
13,
13,
1678,
822,
304,
29918,
8977,
29898,
1311,
29892,
1015,
29918,
333,
29922,
8516,
29892,
1158,
29922,
8516,
1125,
13,
4706,
5446,
353,
426,
13,
9651,
525,
5527,
381,
2168,
2396,
8273,
29898,
1311,
3032,
5527,
381,
2168,
511,
13,
9651,
525,
5269,
2396,
8273,
29898,
1311,
3032,
5269,
511,
13,
9651,
525,
333,
2396,
8273,
29898,
1311,
17255,
333,
2915,
13,
4706,
736,
1583,
3032,
7302,
29918,
1457,
29918,
3827,
29918,
4572,
29898,
5415,
29897,
13,
13,
1678,
822,
903,
7302,
29918,
1457,
29918,
3827,
29918,
4572,
29898,
1311,
29892,
5446,
1125,
13,
4706,
565,
1583,
29889,
1457,
29918,
3827,
29918,
4572,
1275,
525,
1202,
29918,
26123,
403,
29918,
5269,
2396,
13,
9651,
21905,
353,
6024,
5269,
2033,
13,
9651,
599,
29918,
8149,
353,
1051,
29898,
5415,
29889,
8149,
3101,
13,
9651,
363,
1820,
297,
599,
29918,
8149,
29901,
13,
18884,
565,
1820,
451,
297,
21905,
29901,
13,
462,
1678,
1583,
3032,
1188,
29889,
8382,
29898,
13,
462,
4706,
525,
311,
1026,
292,
1273,
29879,
515,
5446,
313,
4572,
29901,
1273,
29879,
29897,
742,
13,
462,
4706,
1820,
29892,
1583,
29889,
1457,
29918,
3827,
29918,
4572,
29897,
13,
462,
1678,
628,
5446,
29961,
1989,
29962,
13,
13,
4706,
736,
5446,
13,
13,
1678,
822,
304,
29918,
3126,
29898,
1311,
1125,
13,
4706,
736,
4390,
29889,
29881,
17204,
29898,
1311,
29889,
517,
29918,
8977,
3285,
29536,
29922,
29906,
29897,
13,
13,
1678,
822,
4770,
710,
12035,
1311,
1125,
13,
4706,
736,
4390,
29889,
29881,
17204,
29898,
1311,
29889,
517,
29918,
8977,
3101,
13,
2
] |
backend/Layer/layer/validation/param_check.py | cvc-Fujii/line-api-use-case-reservation-Restaurant | 8 | 160324 | <gh_stars>1-10
import datetime
class ParamCheck():
"""
パラメータチェックを実施するクラス。
"""
def __init__(self):
"""
初期化を実施する。
"""
pass
def check_required(self, columns, column_name):
"""
必須チェックを実施する。
Parameters
----------
columns : obj
必須チェックをする項目
column_name: str
項目名
Returns
-------
str
エラー内容
"""
columns_replaced = str(columns).replace(' ', '')
if columns is None or not columns_replaced:
return '必須入力エラー:' + column_name
def check_length(self, columns, column_name, min, max):
"""
文字数チェックを実施する。
Parameters
----------
columns : obj
文字数チェックをする項目
column_name: str
項目名
min : int
最小桁数
max : int
最大桁数
Returns
-------
str
エラー内容
"""
if type(columns) is int:
columns = str(columns)
if min and int(min) > len(columns):
return f'文字数エラー(最小文字数[{min}]未満):{column_name}'
if max and int(max) < len(columns):
return f'文字数エラー(最大文字数[{max}]超過):{column_name}'
def check_int(self, columns, column_name):
"""
int型チェックを実施する。
Parameters
----------
columns : obj
int型チェックをする項目
column_name: str
項目名
Returns
-------
str
エラー内容
"""
if isinstance(columns, int):
columns_replaced = True
else:
columns_replaced = columns.isnumeric()
if columns is None or not columns_replaced:
return 'int型チェックエラー:' + column_name
def check_year_month(self, columns, column_name):
"""
年月の形式をチェックする。
Parameters
----------
columns : obj
形式チェックをする項目
column_name: str
項目名
Returns
-------
str
エラー内容
"""
# 日付のハイフンとスラッシュ区切りに対応
columns_replaced = columns.replace('-', '').replace('/', '')
try:
datetime.datetime.strptime(columns_replaced, "%Y%m")
except ValueError:
return f'年月形式エラー : {column_name}({columns})'
def check_year_month_day(self, columns, column_name):
"""
年月日の形式をチェックする。
Parameters
----------
columns : obj
形式チェックをする項目
column_name: str
項目名
Returns
-------
str
エラー内容
"""
# 日付のハイフンとスラッシュ区切りに対応
columns_replaced = columns.replace('-', '').replace('/', '')
try:
datetime.datetime.strptime(columns_replaced, "%Y%m%d")
except ValueError:
return f'年月日形式エラー : {column_name}({columns})'
def check_time_format(self, columns, column_name, time_format):
"""
時間の形式をチェックする。
Parameters
----------
columns : obj
形式チェックをする項目
column_name: str
項目名
time_format: str
チェックしたいフォーマット
Returns
-------
str
エラー内容
"""
# 日付のハイフンとスラッシュ区切りに対応
columns_replaced = columns.replace(':', '')
try:
datetime.datetime.strptime(columns_replaced, time_format)
except ValueError:
return f'時間形式エラー : {column_name}({columns})'
| [
1,
529,
12443,
29918,
303,
1503,
29958,
29896,
29899,
29896,
29900,
13,
30004,
13,
5215,
12865,
30004,
13,
30004,
13,
30004,
13,
1990,
12662,
5596,
7295,
30004,
13,
1678,
9995,
30004,
13,
268,
30715,
30281,
30604,
30185,
30369,
30656,
30887,
30317,
30305,
30396,
31525,
233,
153,
192,
30427,
30332,
30305,
30281,
30255,
30267,
30004,
13,
1678,
9995,
30004,
13,
30004,
13,
1678,
822,
4770,
2344,
12035,
1311,
1125,
30004,
13,
4706,
9995,
30004,
13,
308,
31120,
31117,
30705,
30396,
31525,
233,
153,
192,
30427,
30332,
30267,
30004,
13,
4706,
9995,
30004,
13,
4706,
1209,
30004,
13,
30004,
13,
1678,
822,
1423,
29918,
12403,
29898,
1311,
29892,
4341,
29892,
1897,
29918,
978,
1125,
30004,
13,
4706,
9995,
30004,
13,
308,
31641,
236,
163,
139,
30656,
30887,
30317,
30305,
30396,
31525,
233,
153,
192,
30427,
30332,
30267,
30004,
13,
30004,
13,
4706,
12662,
2699,
30004,
13,
4706,
448,
1378,
29899,
30004,
13,
4706,
4341,
584,
5446,
30004,
13,
632,
31641,
236,
163,
139,
30656,
30887,
30317,
30305,
30396,
30427,
30332,
236,
163,
136,
30895,
30004,
13,
4706,
1897,
29918,
978,
29901,
851,
30004,
13,
632,
236,
163,
136,
30895,
30548,
30004,
13,
30004,
13,
4706,
16969,
30004,
13,
4706,
448,
22158,
30004,
13,
4706,
851,
30004,
13,
632,
30600,
30281,
30185,
30728,
31294,
30004,
13,
4706,
9995,
30004,
13,
4706,
4341,
29918,
3445,
433,
1133,
353,
851,
29898,
13099,
467,
6506,
877,
13420,
27255,
30004,
13,
30004,
13,
4706,
565,
4341,
338,
6213,
470,
451,
4341,
29918,
3445,
433,
1133,
29901,
30004,
13,
9651,
736,
525,
31641,
236,
163,
139,
30752,
31074,
30600,
30281,
30185,
11283,
718,
1897,
29918,
978,
30004,
13,
30004,
13,
1678,
822,
1423,
29918,
2848,
29898,
1311,
29892,
4341,
29892,
1897,
29918,
978,
29892,
1375,
29892,
4236,
1125,
30004,
13,
4706,
9995,
30004,
13,
308,
30333,
30578,
30354,
30656,
30887,
30317,
30305,
30396,
31525,
233,
153,
192,
30427,
30332,
30267,
30004,
13,
30004,
13,
4706,
12662,
2699,
30004,
13,
4706,
448,
1378,
29899,
30004,
13,
4706,
4341,
584,
5446,
30004,
13,
632,
30333,
30578,
30354,
30656,
30887,
30317,
30305,
30396,
30427,
30332,
236,
163,
136,
30895,
30004,
13,
4706,
1897,
29918,
978,
29901,
851,
30004,
13,
632,
236,
163,
136,
30895,
30548,
30004,
13,
4706,
1375,
584,
938,
30004,
13,
632,
30878,
30446,
233,
164,
132,
30354,
30004,
13,
4706,
4236,
584,
938,
30004,
13,
632,
30878,
30257,
233,
164,
132,
30354,
30004,
13,
30004,
13,
4706,
16969,
30004,
13,
4706,
448,
22158,
30004,
13,
4706,
851,
30004,
13,
632,
30600,
30281,
30185,
30728,
31294,
30004,
13,
4706,
9995,
30004,
13,
4706,
565,
1134,
29898,
13099,
29897,
338,
938,
29901,
30004,
13,
9651,
4341,
353,
851,
29898,
13099,
8443,
13,
30004,
13,
4706,
565,
1375,
322,
938,
29898,
1195,
29897,
1405,
7431,
29898,
13099,
1125,
30004,
13,
9651,
736,
285,
29915,
30333,
30578,
30354,
30600,
30281,
30185,
30419,
30878,
30446,
30333,
30578,
30354,
19660,
1195,
6525,
31295,
233,
189,
131,
30409,
26254,
4914,
29918,
978,
10162,
30004,
13,
30004,
13,
4706,
565,
4236,
322,
938,
29898,
3317,
29897,
529,
7431,
29898,
13099,
1125,
30004,
13,
9651,
736,
285,
29915,
30333,
30578,
30354,
30600,
30281,
30185,
30419,
30878,
30257,
30333,
30578,
30354,
19660,
3317,
6525,
31480,
236,
132,
145,
30409,
26254,
4914,
29918,
978,
10162,
30004,
13,
30004,
13,
1678,
822,
1423,
29918,
524,
29898,
1311,
29892,
4341,
29892,
1897,
29918,
978,
1125,
30004,
13,
4706,
9995,
30004,
13,
4706,
938,
30883,
30656,
30887,
30317,
30305,
30396,
31525,
233,
153,
192,
30427,
30332,
30267,
30004,
13,
30004,
13,
4706,
12662,
2699,
30004,
13,
4706,
448,
1378,
29899,
30004,
13,
4706,
4341,
584,
5446,
30004,
13,
9651,
938,
30883,
30656,
30887,
30317,
30305,
30396,
30427,
30332,
236,
163,
136,
30895,
30004,
13,
4706,
1897,
29918,
978,
29901,
851,
30004,
13,
632,
236,
163,
136,
30895,
30548,
30004,
13,
30004,
13,
4706,
16969,
30004,
13,
4706,
448,
22158,
30004,
13,
4706,
851,
30004,
13,
632,
30600,
30281,
30185,
30728,
31294,
30004,
13,
4706,
9995,
30004,
13,
4706,
565,
338,
8758,
29898,
13099,
29892,
938,
1125,
30004,
13,
9651,
4341,
29918,
3445,
433,
1133,
353,
5852,
30004,
13,
4706,
1683,
29901,
30004,
13,
9651,
4341,
29918,
3445,
433,
1133,
353,
4341,
29889,
275,
21574,
26471,
13,
30004,
13,
4706,
565,
4341,
338,
6213,
470,
451,
4341,
29918,
3445,
433,
1133,
29901,
30004,
13,
9651,
736,
525,
524,
30883,
30656,
30887,
30317,
30305,
30600,
30281,
30185,
11283,
718,
1897,
29918,
978,
30004,
13,
30004,
13,
1678,
822,
1423,
29918,
6360,
29918,
10874,
29898,
1311,
29892,
4341,
29892,
1897,
29918,
978,
1125,
30004,
13,
4706,
9995,
30004,
13,
308,
30470,
30534,
30199,
31305,
30607,
30396,
30656,
30887,
30317,
30305,
30427,
30332,
30267,
30004,
13,
30004,
13,
4706,
12662,
2699,
30004,
13,
4706,
448,
1378,
29899,
30004,
13,
4706,
4341,
584,
5446,
30004,
13,
632,
31305,
30607,
30656,
30887,
30317,
30305,
30396,
30427,
30332,
236,
163,
136,
30895,
30004,
13,
4706,
1897,
29918,
978,
29901,
851,
30004,
13,
632,
236,
163,
136,
30895,
30548,
30004,
13,
30004,
13,
4706,
16969,
30004,
13,
4706,
448,
22158,
30004,
13,
4706,
851,
30004,
13,
632,
30600,
30281,
30185,
30728,
31294,
30004,
13,
4706,
9995,
30004,
13,
4706,
396,
29871,
30325,
31689,
30199,
30758,
30260,
30423,
30203,
30364,
30255,
30281,
30317,
30373,
30645,
30467,
31757,
30453,
30353,
232,
178,
193,
232,
194,
159,
30004,
13,
4706,
4341,
29918,
3445,
433,
1133,
353,
4341,
29889,
6506,
877,
29899,
742,
525,
2824,
6506,
11219,
742,
27255,
30004,
13,
4706,
1018,
29901,
30004,
13,
9651,
12865,
29889,
12673,
29889,
710,
415,
603,
29898,
13099,
29918,
3445,
433,
1133,
29892,
11860,
29979,
29995,
29885,
1159,
30004,
13,
4706,
5174,
7865,
2392,
29901,
30004,
13,
9651,
736,
285,
29915,
30470,
30534,
31305,
30607,
30600,
30281,
30185,
584,
426,
4914,
29918,
978,
2119,
29912,
13099,
1800,
29915,
30004,
13,
30004,
13,
1678,
822,
1423,
29918,
6360,
29918,
10874,
29918,
3250,
29898,
1311,
29892,
4341,
29892,
1897,
29918,
978,
1125,
30004,
13,
4706,
9995,
30004,
13,
308,
30470,
30534,
30325,
30199,
31305,
30607,
30396,
30656,
30887,
30317,
30305,
30427,
30332,
30267,
30004,
13,
30004,
13,
4706,
12662,
2699,
30004,
13,
4706,
448,
1378,
29899,
30004,
13,
4706,
4341,
584,
5446,
30004,
13,
632,
31305,
30607,
30656,
30887,
30317,
30305,
30396,
30427,
30332,
236,
163,
136,
30895,
30004,
13,
4706,
1897,
29918,
978,
29901,
851,
30004,
13,
632,
236,
163,
136,
30895,
30548,
30004,
13,
30004,
13,
4706,
16969,
30004,
13,
4706,
448,
22158,
30004,
13,
4706,
851,
30004,
13,
632,
30600,
30281,
30185,
30728,
31294,
30004,
13,
4706,
9995,
30004,
13,
4706,
396,
29871,
30325,
31689,
30199,
30758,
30260,
30423,
30203,
30364,
30255,
30281,
30317,
30373,
30645,
30467,
31757,
30453,
30353,
232,
178,
193,
232,
194,
159,
30004,
13,
4706,
4341,
29918,
3445,
433,
1133,
353,
4341,
29889,
6506,
877,
29899,
742,
525,
2824,
6506,
11219,
742,
27255,
30004,
13,
4706,
1018,
29901,
30004,
13,
9651,
12865,
29889,
12673,
29889,
710,
415,
603,
29898,
13099,
29918,
3445,
433,
1133,
29892,
11860,
29979,
29995,
29885,
29995,
29881,
1159,
30004,
13,
4706,
5174,
7865,
2392,
29901,
30004,
13,
9651,
736,
285,
29915,
30470,
30534,
30325,
31305,
30607,
30600,
30281,
30185,
584,
426,
4914,
29918,
978,
2119,
29912,
13099,
1800,
29915,
30004,
13,
30004,
13,
1678,
822,
1423,
29918,
2230,
29918,
4830,
29898,
1311,
29892,
4341,
29892,
1897,
29918,
978,
29892,
931,
29918,
4830,
1125,
30004,
13,
4706,
9995,
30004,
13,
308,
30974,
31069,
30199,
31305,
30607,
30396,
30656,
30887,
30317,
30305,
30427,
30332,
30267,
30004,
13,
30004,
13,
4706,
12662,
2699,
30004,
13,
4706,
448,
1378,
29899,
30004,
13,
4706,
4341,
584,
5446,
30004,
13,
632,
31305,
30607,
30656,
30887,
30317,
30305,
30396,
30427,
30332,
236,
163,
136,
30895,
30004,
13,
4706,
1897,
29918,
978,
29901,
851,
30004,
13,
632,
236,
163,
136,
30895,
30548,
30004,
13,
4706,
931,
29918,
4830,
29901,
851,
30004,
13,
632,
30656,
30887,
30317,
30305,
30326,
30366,
30298,
30423,
31402,
30185,
30388,
30317,
30279,
30004,
13,
30004,
13,
4706,
16969,
30004,
13,
4706,
448,
22158,
30004,
13,
4706,
851,
30004,
13,
632,
30600,
30281,
30185,
30728,
31294,
30004,
13,
4706,
9995,
30004,
13,
4706,
396,
29871,
30325,
31689,
30199,
30758,
30260,
30423,
30203,
30364,
30255,
30281,
30317,
30373,
30645,
30467,
31757,
30453,
30353,
232,
178,
193,
232,
194,
159,
30004,
13,
4706,
4341,
29918,
3445,
433,
1133,
353,
4341,
29889,
6506,
877,
29901,
742,
27255,
30004,
13,
4706,
1018,
29901,
30004,
13,
9651,
12865,
29889,
12673,
29889,
710,
415,
603,
29898,
13099,
29918,
3445,
433,
1133,
29892,
931,
29918,
4830,
8443,
13,
4706,
5174,
7865,
2392,
29901,
30004,
13,
9651,
736,
285,
29915,
30974,
31069,
31305,
30607,
30600,
30281,
30185,
584,
426,
4914,
29918,
978,
2119,
29912,
13099,
1800,
29915,
30004,
13,
2
] |
tests/networks/test_enas_net.py | marsggbo/hyperbox | 1 | 1602836 |
import torch
from hyperbox.networks.enas import ENASMicroNetwork
from hyperbox.mutator.random_mutator import RandomMutator
if __name__ == '__main__':
net = ENASMicroNetwork(
num_layers=2,
num_nodes=3,
).cuda()
m = RandomMutator(net)
m.reset()
x = torch.rand(2,3,64,64).cuda()
output = net(x)
print(output.shape)
pass | [
1,
6756,
13,
5215,
4842,
305,
30004,
13,
30004,
13,
3166,
11266,
1884,
29889,
11618,
29879,
29889,
23509,
1053,
12524,
3289,
29924,
2357,
13724,
30004,
13,
3166,
11266,
1884,
29889,
6149,
1061,
29889,
8172,
29918,
6149,
1061,
1053,
16968,
29924,
329,
1061,
30004,
13,
30004,
13,
361,
4770,
978,
1649,
1275,
525,
1649,
3396,
1649,
2396,
30004,
13,
1678,
7787,
353,
12524,
3289,
29924,
2357,
13724,
29898,
30004,
13,
4706,
954,
29918,
29277,
29922,
29906,
11167,
13,
4706,
954,
29918,
18010,
29922,
29941,
11167,
13,
1678,
13742,
29883,
6191,
26471,
13,
1678,
286,
353,
16968,
29924,
329,
1061,
29898,
1212,
8443,
13,
1678,
286,
29889,
12071,
26471,
13,
1678,
921,
353,
4842,
305,
29889,
9502,
29898,
29906,
29892,
29941,
29892,
29953,
29946,
29892,
29953,
29946,
467,
29883,
6191,
26471,
13,
1678,
1962,
353,
7787,
29898,
29916,
8443,
13,
1678,
1596,
29898,
4905,
29889,
12181,
8443,
13,
1678,
1209,
2
] |
Anylink-server/add_user.py | orike122/anylink | 3 | 57188 | from config import Configuration
if __name__ == "__main__":
config = Configuration("/home/orikeidar01/config.json", "anylink")
config.database.add_user("<EMAIL>",
"ECD71870D1963316A97E3AC3408C9835AD8CF0F3C1BC703527C30265534F75AE", "anylink")
| [
1,
515,
2295,
1053,
20999,
13,
13,
361,
4770,
978,
1649,
1275,
376,
1649,
3396,
1649,
1115,
13,
1678,
2295,
353,
20999,
11974,
5184,
29914,
4170,
446,
333,
279,
29900,
29896,
29914,
2917,
29889,
3126,
613,
376,
1384,
2324,
1159,
13,
1678,
2295,
29889,
9803,
29889,
1202,
29918,
1792,
28945,
26862,
6227,
28341,
13,
462,
632,
376,
29923,
6530,
29955,
29896,
29947,
29955,
29900,
29928,
29896,
29929,
29953,
29941,
29941,
29896,
29953,
29909,
29929,
29955,
29923,
29941,
2477,
29941,
29946,
29900,
29947,
29907,
29929,
29947,
29941,
29945,
3035,
29947,
9207,
29900,
29943,
29941,
29907,
29896,
5371,
29955,
29900,
29941,
29945,
29906,
29955,
29907,
29941,
29900,
29906,
29953,
29945,
29945,
29941,
29946,
29943,
29955,
29945,
16036,
613,
376,
1384,
2324,
1159,
13,
2
] |
symbols/grucnn.py | gkfthddk/keras | 0 | 145928 | <reponame>gkfthddk/keras
from keras.models import Sequential, Model
from keras.layers import Dense, Dropout, Flatten, Reshape, Concatenate
from keras.layers import Input, Conv2D, MaxPooling2D, ZeroPadding2D
from keras.layers import SimpleRNN, LSTM, GRU
from keras.optimizers import SGD
import cv2, numpy as np
def get_symbol(input_shape1,input_shape2,weights_path=None):
input1 = Input(shape=input_shape1)
input2 = Input(shape=input_shape2)
# group 1
padd1_1=ZeroPadding2D((1,0))(input1)
conv1_1=Conv2D(64, (3, 1), activation='relu')(padd1_1)
padd1_2=ZeroPadding2D((0,1))(conv1_1)
conv1_2=Conv2D(64, (1, 3), activation='relu')(padd1_2)
pool1=MaxPooling2D((2,2), strides=(2,2))(conv1_2)
# group 2
padd2_1=ZeroPadding2D((1,0))(pool1)
conv2_1=Conv2D(128, (3, 1), activation='relu')(padd2_1)
padd2_2=ZeroPadding2D((0,1))(conv2_1)
conv2_2=Conv2D(128, (1, 3), activation='relu')(padd2_2)
padd2_3=ZeroPadding2D((1,0))(conv2_2)
conv2_3=Conv2D(128, (3, 1), activation='relu')(padd2_3)
padd2_4=ZeroPadding2D((0,1))(conv2_3)
conv2_4=Conv2D(128, (1, 3), activation='relu')(padd2_4)
pool2=MaxPooling2D((2,2), strides=(2,2))(conv2_4)
# group 3
flat1=Flatten()(pool2)
dens1=Dense(1024, activation='relu')(flat1)
drop1=Dropout(0.5)(dens1)
rnn=GRU(units=128,dropout=0.2,return_sequences=True)(input2)
flatr=Flatten()(rnn)
densr=Dense(256,activation='relu')(flatr)
dropr=Dropout(0.5)(densr)
concat=Concatenate(axis=1)([drop1,dropr])
dens2=Dense(1024, activation='relu')(concat)
drop2=Dropout(0.5)(dens2)
out=Dense(2,activation='softmax')(drop2)
if weights_path:
model.load_weights(weights_path)
return Model([input1,input2],out)
def rc():
return "rc"
| [
1,
529,
276,
1112,
420,
29958,
29887,
29895,
29888,
386,
1289,
29895,
29914,
3946,
294,
13,
3166,
13023,
294,
29889,
9794,
1053,
922,
339,
2556,
29892,
8125,
13,
3166,
13023,
294,
29889,
29277,
1053,
360,
1947,
29892,
20724,
449,
29892,
2379,
8606,
29892,
2538,
14443,
29892,
23924,
2579,
403,
13,
3166,
13023,
294,
29889,
29277,
1053,
10567,
29892,
1281,
29894,
29906,
29928,
29892,
5918,
11426,
292,
29906,
29928,
29892,
28933,
29925,
4676,
29906,
29928,
13,
3166,
13023,
294,
29889,
29277,
1053,
12545,
29934,
10262,
29892,
365,
1254,
29924,
29892,
18016,
29965,
29871,
13,
3166,
13023,
294,
29889,
20640,
19427,
1053,
317,
29954,
29928,
13,
5215,
13850,
29906,
29892,
12655,
408,
7442,
13,
13,
1753,
679,
29918,
18098,
29898,
2080,
29918,
12181,
29896,
29892,
2080,
29918,
12181,
29906,
29892,
705,
5861,
29918,
2084,
29922,
8516,
1125,
13,
1678,
1881,
29896,
353,
10567,
29898,
12181,
29922,
2080,
29918,
12181,
29896,
29897,
13,
1678,
1881,
29906,
353,
10567,
29898,
12181,
29922,
2080,
29918,
12181,
29906,
29897,
13,
1678,
396,
2318,
29871,
29896,
13,
1678,
282,
1202,
29896,
29918,
29896,
29922,
24214,
29925,
4676,
29906,
29928,
3552,
29896,
29892,
29900,
876,
29898,
2080,
29896,
29897,
13,
1678,
7602,
29896,
29918,
29896,
29922,
1168,
29894,
29906,
29928,
29898,
29953,
29946,
29892,
313,
29941,
29892,
29871,
29896,
511,
26229,
2433,
2674,
29884,
1495,
29898,
29886,
1202,
29896,
29918,
29896,
29897,
13,
1678,
282,
1202,
29896,
29918,
29906,
29922,
24214,
29925,
4676,
29906,
29928,
3552,
29900,
29892,
29896,
876,
29898,
20580,
29896,
29918,
29896,
29897,
13,
1678,
7602,
29896,
29918,
29906,
29922,
1168,
29894,
29906,
29928,
29898,
29953,
29946,
29892,
313,
29896,
29892,
29871,
29941,
511,
26229,
2433,
2674,
29884,
1495,
29898,
29886,
1202,
29896,
29918,
29906,
29897,
13,
1678,
11565,
29896,
29922,
7976,
11426,
292,
29906,
29928,
3552,
29906,
29892,
29906,
511,
851,
2247,
7607,
29906,
29892,
29906,
876,
29898,
20580,
29896,
29918,
29906,
29897,
13,
1678,
396,
2318,
29871,
29906,
13,
1678,
282,
1202,
29906,
29918,
29896,
29922,
24214,
29925,
4676,
29906,
29928,
3552,
29896,
29892,
29900,
876,
29898,
10109,
29896,
29897,
13,
1678,
7602,
29906,
29918,
29896,
29922,
1168,
29894,
29906,
29928,
29898,
29896,
29906,
29947,
29892,
313,
29941,
29892,
29871,
29896,
511,
26229,
2433,
2674,
29884,
1495,
29898,
29886,
1202,
29906,
29918,
29896,
29897,
13,
1678,
282,
1202,
29906,
29918,
29906,
29922,
24214,
29925,
4676,
29906,
29928,
3552,
29900,
29892,
29896,
876,
29898,
20580,
29906,
29918,
29896,
29897,
13,
1678,
7602,
29906,
29918,
29906,
29922,
1168,
29894,
29906,
29928,
29898,
29896,
29906,
29947,
29892,
313,
29896,
29892,
29871,
29941,
511,
26229,
2433,
2674,
29884,
1495,
29898,
29886,
1202,
29906,
29918,
29906,
29897,
13,
1678,
282,
1202,
29906,
29918,
29941,
29922,
24214,
29925,
4676,
29906,
29928,
3552,
29896,
29892,
29900,
876,
29898,
20580,
29906,
29918,
29906,
29897,
13,
1678,
7602,
29906,
29918,
29941,
29922,
1168,
29894,
29906,
29928,
29898,
29896,
29906,
29947,
29892,
313,
29941,
29892,
29871,
29896,
511,
26229,
2433,
2674,
29884,
1495,
29898,
29886,
1202,
29906,
29918,
29941,
29897,
13,
1678,
282,
1202,
29906,
29918,
29946,
29922,
24214,
29925,
4676,
29906,
29928,
3552,
29900,
29892,
29896,
876,
29898,
20580,
29906,
29918,
29941,
29897,
13,
1678,
7602,
29906,
29918,
29946,
29922,
1168,
29894,
29906,
29928,
29898,
29896,
29906,
29947,
29892,
313,
29896,
29892,
29871,
29941,
511,
26229,
2433,
2674,
29884,
1495,
29898,
29886,
1202,
29906,
29918,
29946,
29897,
13,
1678,
11565,
29906,
29922,
7976,
11426,
292,
29906,
29928,
3552,
29906,
29892,
29906,
511,
851,
2247,
7607,
29906,
29892,
29906,
876,
29898,
20580,
29906,
29918,
29946,
29897,
13,
1678,
396,
2318,
29871,
29941,
13,
13,
1678,
12151,
29896,
29922,
29943,
5066,
841,
580,
29898,
10109,
29906,
29897,
13,
1678,
6245,
29896,
29922,
29928,
1947,
29898,
29896,
29900,
29906,
29946,
29892,
26229,
2433,
2674,
29884,
1495,
29898,
20620,
29896,
29897,
13,
1678,
5768,
29896,
29922,
15063,
449,
29898,
29900,
29889,
29945,
5033,
21518,
29896,
29897,
13,
268,
13,
1678,
364,
15755,
29922,
14345,
29965,
29898,
348,
1169,
29922,
29896,
29906,
29947,
29892,
8865,
449,
29922,
29900,
29889,
29906,
29892,
2457,
29918,
6831,
2063,
29922,
5574,
5033,
2080,
29906,
29897,
13,
1678,
1652,
8141,
29922,
29943,
5066,
841,
580,
29898,
29878,
15755,
29897,
13,
1678,
6245,
29878,
29922,
29928,
1947,
29898,
29906,
29945,
29953,
29892,
11236,
362,
2433,
2674,
29884,
1495,
29898,
1579,
8141,
29897,
13,
1678,
4441,
558,
29922,
15063,
449,
29898,
29900,
29889,
29945,
5033,
21518,
29878,
29897,
13,
13,
1678,
3022,
271,
29922,
1168,
29883,
2579,
403,
29898,
8990,
29922,
29896,
29897,
4197,
8865,
29896,
29892,
26419,
558,
2314,
13,
1678,
6245,
29906,
29922,
29928,
1947,
29898,
29896,
29900,
29906,
29946,
29892,
26229,
2433,
2674,
29884,
1495,
29898,
17685,
29897,
13,
1678,
5768,
29906,
29922,
15063,
449,
29898,
29900,
29889,
29945,
5033,
21518,
29906,
29897,
13,
13,
13,
1678,
714,
29922,
29928,
1947,
29898,
29906,
29892,
11236,
362,
2433,
2695,
3317,
1495,
29898,
8865,
29906,
29897,
13,
13,
1678,
565,
18177,
29918,
2084,
29901,
13,
4706,
1904,
29889,
1359,
29918,
705,
5861,
29898,
705,
5861,
29918,
2084,
29897,
13,
13,
1678,
736,
8125,
4197,
2080,
29896,
29892,
2080,
29906,
1402,
449,
29897,
13,
13,
1753,
364,
29883,
7295,
13,
1678,
736,
376,
2214,
29908,
13,
2
] |
speedysvc/web_monitor/WebServiceManager.py | mcyph/shmrpc | 4 | 50905 | import sys
from datetime import datetime
LColours = [
'red', 'green', 'blue',
'purple', 'orange', 'brown',
'pink', 'cyan', 'magenta',
'yellow'
]
class WebServiceManager:
def __init__(self, jinja2_env):
self.jinja2_env = jinja2_env
self.DServices = {} # TODO: Replace me, directly using the Services instance!
def set_services(self, services):
self.services = services
def set_logger_parent(self, logger_parent):
"""
Set the logger parent (a FIFOJSONLog instance)
:param logger_parent:
:return:
"""
# TODO: Move this somewhere more appropriate!
self.logger_parent = logger_parent
def iter_services_by_name(self):
"""
:return:
"""
for service in sorted(
self.DServices.values(),
key=lambda service: service.name.lower()
):
yield service
def iter_services_by_port(self):
"""
:return:
"""
for service in sorted(
self.DServices.values(),
key=lambda service: service.port
):
yield service
def iter_service_ports(self):
"""
:return:
"""
for port in sorted(self.DServices):
yield port
#=====================================================================#
# Manage Web Services #
#=====================================================================#
def add_service(self, service):
"""
:param service:
:return:
"""
self.DServices[service.original_server_methods.port] = service
def remove_service(self, port):
"""
:param port:
:return:
"""
del self.DServices[port]
def start_service(self, port):
"""
:param port:
:return:
"""
self.services.start_service_by_port(port)
def stop_service(self, port):
"""
:param port:
:return:
"""
self.services.stop_service_by_port(port)
#=====================================================================#
# Get All Service Status/Stats #
#=====================================================================#
def get_overall_log(self, offset=None):
"""
Get the "overall" log for all services
:param offset:
:return:
"""
offset, LHTML = self.logger_parent.get_html_log(
offset=offset
)
return offset, '<br>'.join(LHTML) + ('<br>' if LHTML else '')
def get_overall_table_html(self, add_links=True):
"""
:param add_links:
:return:
"""
return self.jinja2_env.from_string(
'{% from "service_macros.html" import service_status_table %}\n'
'{{ service_status_table(LServiceTable, add_links) }}'
).render(
LServiceTable=self.get_overall_service_table(),
add_links=add_links
)
def get_overall_service_table(self):
"""
:return:
"""
L = []
for service in self.iter_services_by_name():
L.append(self.get_D_service_info(service.original_server_methods.port))
return L
def get_overall_service_methods(self, max_methods=15):
"""
Get a summary of the methods from all services, sorted
by total time the method has taken over all calls
:param max_methods:
:return:
"""
L = []
for service in self.iter_services_by_name():
DMethodStats = service.get_D_method_stats()
L.extend([
(
service.original_server_methods.port,
service.original_server_methods.name,
method_name,
D['num_calls'],
D['avg_call_time'],
D['total_time'])
for method_name, D
in DMethodStats.items()
])
L.sort(key=lambda i: -i[-1])
if max_methods is not None:
L = L[:max_methods]
return L
def get_overall_service_methods_html(self, max_methods=15):
L = self.get_overall_service_methods(max_methods)
return self.jinja2_env.from_string(
'{% from "service_macros.html" import overall_method_stats_html %}\n'
'{{ overall_method_stats_html(LMethodStats) }}'
).render(
LMethodStats=L
)
#=====================================================================#
# Get Single Service Status/Stats #
#=====================================================================#
def get_D_service_info(self, port, console_offset=None):
"""
:param port:
:param console_offset:
:return:
"""
service = self.DServices[port]
stsd = service.service_time_series_data
recent_values = stsd.get_recent_values()
offset, LHTML = service.fifo_json_log.get_html_log(
offset=console_offset
)
method_stats_html = self.get_method_stats_html(port)
D = {
"graphs": self.__get_D_graphs(recent_values),
"console_text": '\n'.join(LHTML),
"console_offset": offset,
"method_stats_html": method_stats_html
}
D.update(self.__get_D_table_info(port, recent_values))
D["table_html"] = self.__get_table_html(D)
return D
def get_method_stats_html(self, port):
"""
:param port:
:return:
"""
DMethodStats = self.DServices[port].get_D_method_stats()
LMethodStats = [
(method_name, D['num_calls'], D['avg_call_time'], D['total_time'])
for method_name, D
in DMethodStats.items()
]
return self.jinja2_env.from_string(
'{% from "service_macros.html" import method_stats_html %}\n'
'{{ method_stats_html(LMethodStats) }}'
).render(
LMethodStats=LMethodStats
)
def __get_D_table_info(self, port, recent_values):
"""
:param port:
:param recent_values:
:return:
"""
service = self.DServices[port]
return {
"port": port,
"name": service.original_server_methods.name,
"bound_to_tcp": service.tcp_bind,
"status": service.get_service_status(),
'workers': len(service.LPIDs), # TODO: MAKE BASED ON INTERFACE, NOT IMPLEMENTATION!
'physical_mem': recent_values[-1]['physical_mem'] // 1024 // 1024,
# We'll average over 3 iterations, as this can spike pretty quickly.
# Note that recent_values is actually reversed for displaying on the graph rtl
'cpu': round(sum([recent_values[-x]['cpu_usage_pc'] for x in range(3)]) / 3)
}
def __get_D_graphs(self, recent_values):
"""
:param recent_values:
:return:
"""
labels = [
datetime.utcfromtimestamp(D['timestamp']).strftime(
'%H:%M:%S' # %m/%d
) for D in recent_values
]
return {
"labels": labels,
"ram": self.__get_data_for_keys(
recent_values,
*(
('shared_mem', 'physical_mem', 'virtual_mem')
if sys.platform != 'win32'
else ('physical_mem', 'virtual_mem')
),
divisor=1024 * 1024
),
"io": self.__get_data_for_keys(
recent_values,
'io_read', 'io_written',
divisor=1024 * 1024
),
"cpu": self.__get_data_for_keys(
recent_values,
'cpu_usage_pc'
),
}
def __get_data_for_keys(self, values, *keys, divisor=None):
"""
:param values:
:param keys:
:param divisor:
:return:
"""
LData = []
for x, key in enumerate(keys):
LOut = []
for D in values:
i = D[key]
if divisor is not None:
i //= divisor
LOut.append(i)
LData.append([key, LOut, LColours[x]])
return LData
def __get_table_html(self, DService):
"""
:param DService:
:return:
"""
return self.jinja2_env.from_string(
'{% from "service_macros.html" import service_status_table %}\n'
'{{ service_status_table([DService]) }}'
).render(
DService=DService
)
| [
1,
1053,
10876,
13,
3166,
12865,
1053,
12865,
13,
13,
13,
29931,
1625,
2470,
353,
518,
13,
1678,
525,
1127,
742,
525,
12692,
742,
525,
9539,
742,
13,
1678,
525,
15503,
552,
742,
525,
272,
927,
742,
525,
29890,
4708,
742,
13,
1678,
525,
29886,
682,
742,
525,
1270,
273,
742,
525,
11082,
6381,
742,
13,
1678,
525,
29136,
29915,
13,
29962,
13,
13,
13,
1990,
2563,
3170,
3260,
29901,
13,
1678,
822,
4770,
2344,
12035,
1311,
29892,
432,
262,
1764,
29906,
29918,
6272,
1125,
13,
4706,
1583,
29889,
28789,
1764,
29906,
29918,
6272,
353,
432,
262,
1764,
29906,
29918,
6272,
13,
4706,
1583,
29889,
29928,
13779,
353,
6571,
29871,
396,
14402,
29901,
22108,
592,
29892,
4153,
773,
278,
15538,
2777,
29991,
13,
13,
1678,
822,
731,
29918,
9916,
29898,
1311,
29892,
5786,
1125,
13,
4706,
1583,
29889,
9916,
353,
5786,
13,
13,
1678,
822,
731,
29918,
21707,
29918,
3560,
29898,
1311,
29892,
17927,
29918,
3560,
1125,
13,
4706,
9995,
13,
4706,
3789,
278,
17927,
3847,
313,
29874,
9338,
5800,
7249,
3403,
2777,
29897,
13,
4706,
584,
3207,
17927,
29918,
3560,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
396,
14402,
29901,
25249,
445,
9051,
901,
8210,
29991,
13,
4706,
1583,
29889,
21707,
29918,
3560,
353,
17927,
29918,
3560,
13,
13,
1678,
822,
4256,
29918,
9916,
29918,
1609,
29918,
978,
29898,
1311,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
363,
2669,
297,
12705,
29898,
13,
9651,
1583,
29889,
29928,
13779,
29889,
5975,
3285,
13,
9651,
1820,
29922,
2892,
2669,
29901,
2669,
29889,
978,
29889,
13609,
580,
13,
308,
1125,
13,
9651,
7709,
2669,
13,
13,
1678,
822,
4256,
29918,
9916,
29918,
1609,
29918,
637,
29898,
1311,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
363,
2669,
297,
12705,
29898,
13,
9651,
1583,
29889,
29928,
13779,
29889,
5975,
3285,
13,
9651,
1820,
29922,
2892,
2669,
29901,
2669,
29889,
637,
13,
308,
1125,
13,
9651,
7709,
2669,
13,
13,
1678,
822,
4256,
29918,
5509,
29918,
4011,
29898,
1311,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
363,
2011,
297,
12705,
29898,
1311,
29889,
29928,
13779,
1125,
13,
9651,
7709,
2011,
13,
13,
1678,
396,
9166,
9166,
9166,
9166,
2751,
29922,
29937,
13,
1678,
396,
462,
4706,
2315,
482,
2563,
15538,
462,
3986,
396,
13,
1678,
396,
9166,
9166,
9166,
9166,
2751,
29922,
29937,
13,
13,
1678,
822,
788,
29918,
5509,
29898,
1311,
29892,
2669,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
2669,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
1583,
29889,
29928,
13779,
29961,
5509,
29889,
13492,
29918,
2974,
29918,
23515,
29889,
637,
29962,
353,
2669,
13,
13,
1678,
822,
3349,
29918,
5509,
29898,
1311,
29892,
2011,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
2011,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
628,
1583,
29889,
29928,
13779,
29961,
637,
29962,
13,
13,
1678,
822,
1369,
29918,
5509,
29898,
1311,
29892,
2011,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
2011,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
1583,
29889,
9916,
29889,
2962,
29918,
5509,
29918,
1609,
29918,
637,
29898,
637,
29897,
13,
13,
1678,
822,
5040,
29918,
5509,
29898,
1311,
29892,
2011,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
2011,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
1583,
29889,
9916,
29889,
9847,
29918,
5509,
29918,
1609,
29918,
637,
29898,
637,
29897,
13,
13,
1678,
396,
9166,
9166,
9166,
9166,
2751,
29922,
29937,
13,
1678,
396,
462,
268,
3617,
2178,
6692,
16034,
29914,
25060,
462,
1678,
396,
13,
1678,
396,
9166,
9166,
9166,
9166,
2751,
29922,
29937,
13,
13,
1678,
822,
679,
29918,
957,
497,
29918,
1188,
29898,
1311,
29892,
9210,
29922,
8516,
1125,
13,
4706,
9995,
13,
4706,
3617,
278,
376,
957,
497,
29908,
1480,
363,
599,
5786,
13,
4706,
584,
3207,
9210,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
9210,
29892,
365,
7020,
353,
1583,
29889,
21707,
29918,
3560,
29889,
657,
29918,
1420,
29918,
1188,
29898,
13,
9651,
9210,
29922,
10289,
13,
4706,
1723,
13,
4706,
736,
9210,
29892,
12801,
1182,
29958,
4286,
7122,
29898,
29931,
7020,
29897,
718,
6702,
29966,
1182,
16299,
565,
365,
7020,
1683,
27255,
13,
13,
1678,
822,
679,
29918,
957,
497,
29918,
2371,
29918,
1420,
29898,
1311,
29892,
788,
29918,
4965,
29922,
5574,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
788,
29918,
4965,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
736,
1583,
29889,
28789,
1764,
29906,
29918,
6272,
29889,
3166,
29918,
1807,
29898,
13,
9651,
525,
18255,
515,
376,
5509,
29918,
8628,
1883,
29889,
1420,
29908,
1053,
2669,
29918,
4882,
29918,
2371,
1273,
1012,
29876,
29915,
13,
9651,
525,
6224,
2669,
29918,
4882,
29918,
2371,
29898,
29931,
3170,
3562,
29892,
788,
29918,
4965,
29897,
9156,
29915,
13,
4706,
13742,
9482,
29898,
13,
9651,
365,
3170,
3562,
29922,
1311,
29889,
657,
29918,
957,
497,
29918,
5509,
29918,
2371,
3285,
13,
9651,
788,
29918,
4965,
29922,
1202,
29918,
4965,
13,
4706,
1723,
13,
13,
1678,
822,
679,
29918,
957,
497,
29918,
5509,
29918,
2371,
29898,
1311,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
365,
353,
5159,
13,
4706,
363,
2669,
297,
1583,
29889,
1524,
29918,
9916,
29918,
1609,
29918,
978,
7295,
13,
9651,
365,
29889,
4397,
29898,
1311,
29889,
657,
29918,
29928,
29918,
5509,
29918,
3888,
29898,
5509,
29889,
13492,
29918,
2974,
29918,
23515,
29889,
637,
876,
13,
4706,
736,
365,
13,
13,
1678,
822,
679,
29918,
957,
497,
29918,
5509,
29918,
23515,
29898,
1311,
29892,
4236,
29918,
23515,
29922,
29896,
29945,
1125,
13,
4706,
9995,
13,
4706,
3617,
263,
15837,
310,
278,
3519,
515,
599,
5786,
29892,
12705,
13,
4706,
491,
3001,
931,
278,
1158,
756,
4586,
975,
599,
5717,
13,
4706,
584,
3207,
4236,
29918,
23515,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
365,
353,
5159,
13,
4706,
363,
2669,
297,
1583,
29889,
1524,
29918,
9916,
29918,
1609,
29918,
978,
7295,
13,
9651,
360,
4062,
25060,
353,
2669,
29889,
657,
29918,
29928,
29918,
5696,
29918,
16202,
580,
13,
13,
9651,
365,
29889,
21843,
4197,
13,
18884,
313,
13,
462,
1678,
2669,
29889,
13492,
29918,
2974,
29918,
23515,
29889,
637,
29892,
13,
462,
1678,
2669,
29889,
13492,
29918,
2974,
29918,
23515,
29889,
978,
29892,
13,
462,
1678,
1158,
29918,
978,
29892,
13,
462,
1678,
360,
1839,
1949,
29918,
29883,
4293,
7464,
13,
462,
1678,
360,
1839,
485,
29887,
29918,
4804,
29918,
2230,
7464,
13,
462,
1678,
360,
1839,
7827,
29918,
2230,
11287,
13,
18884,
363,
1158,
29918,
978,
29892,
360,
13,
18884,
297,
360,
4062,
25060,
29889,
7076,
580,
13,
632,
2314,
13,
13,
4706,
365,
29889,
6605,
29898,
1989,
29922,
2892,
474,
29901,
448,
29875,
14352,
29896,
2314,
13,
4706,
565,
4236,
29918,
23515,
338,
451,
6213,
29901,
13,
9651,
365,
353,
365,
7503,
3317,
29918,
23515,
29962,
13,
13,
4706,
736,
365,
13,
13,
1678,
822,
679,
29918,
957,
497,
29918,
5509,
29918,
23515,
29918,
1420,
29898,
1311,
29892,
4236,
29918,
23515,
29922,
29896,
29945,
1125,
13,
4706,
365,
353,
1583,
29889,
657,
29918,
957,
497,
29918,
5509,
29918,
23515,
29898,
3317,
29918,
23515,
29897,
13,
4706,
736,
1583,
29889,
28789,
1764,
29906,
29918,
6272,
29889,
3166,
29918,
1807,
29898,
13,
9651,
525,
18255,
515,
376,
5509,
29918,
8628,
1883,
29889,
1420,
29908,
1053,
12463,
29918,
5696,
29918,
16202,
29918,
1420,
1273,
1012,
29876,
29915,
13,
9651,
525,
6224,
12463,
29918,
5696,
29918,
16202,
29918,
1420,
29898,
29931,
4062,
25060,
29897,
9156,
29915,
13,
4706,
13742,
9482,
29898,
13,
9651,
365,
4062,
25060,
29922,
29931,
13,
4706,
1723,
13,
13,
1678,
396,
9166,
9166,
9166,
9166,
2751,
29922,
29937,
13,
1678,
396,
462,
259,
3617,
16740,
6692,
16034,
29914,
25060,
462,
259,
396,
13,
1678,
396,
9166,
9166,
9166,
9166,
2751,
29922,
29937,
13,
13,
1678,
822,
679,
29918,
29928,
29918,
5509,
29918,
3888,
29898,
1311,
29892,
2011,
29892,
2991,
29918,
10289,
29922,
8516,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
2011,
29901,
13,
4706,
584,
3207,
2991,
29918,
10289,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
2669,
353,
1583,
29889,
29928,
13779,
29961,
637,
29962,
13,
4706,
380,
4928,
353,
2669,
29889,
5509,
29918,
2230,
29918,
13757,
29918,
1272,
13,
4706,
7786,
29918,
5975,
353,
380,
4928,
29889,
657,
29918,
276,
1760,
29918,
5975,
580,
13,
4706,
9210,
29892,
365,
7020,
353,
2669,
29889,
28491,
29877,
29918,
3126,
29918,
1188,
29889,
657,
29918,
1420,
29918,
1188,
29898,
13,
9651,
9210,
29922,
11058,
29918,
10289,
13,
4706,
1723,
13,
4706,
1158,
29918,
16202,
29918,
1420,
353,
1583,
29889,
657,
29918,
5696,
29918,
16202,
29918,
1420,
29898,
637,
29897,
13,
13,
4706,
360,
353,
426,
13,
9651,
376,
4262,
29879,
1115,
1583,
17255,
657,
29918,
29928,
29918,
4262,
29879,
29898,
276,
1760,
29918,
5975,
511,
13,
9651,
376,
11058,
29918,
726,
1115,
11297,
29876,
4286,
7122,
29898,
29931,
7020,
511,
13,
9651,
376,
11058,
29918,
10289,
1115,
9210,
29892,
13,
9651,
376,
5696,
29918,
16202,
29918,
1420,
1115,
1158,
29918,
16202,
29918,
1420,
13,
4706,
500,
13,
4706,
360,
29889,
5504,
29898,
1311,
17255,
657,
29918,
29928,
29918,
2371,
29918,
3888,
29898,
637,
29892,
7786,
29918,
5975,
876,
13,
4706,
360,
3366,
2371,
29918,
1420,
3108,
353,
1583,
17255,
657,
29918,
2371,
29918,
1420,
29898,
29928,
29897,
13,
4706,
736,
360,
13,
13,
1678,
822,
679,
29918,
5696,
29918,
16202,
29918,
1420,
29898,
1311,
29892,
2011,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
2011,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
360,
4062,
25060,
353,
1583,
29889,
29928,
13779,
29961,
637,
1822,
657,
29918,
29928,
29918,
5696,
29918,
16202,
580,
13,
13,
4706,
365,
4062,
25060,
353,
518,
13,
9651,
313,
5696,
29918,
978,
29892,
360,
1839,
1949,
29918,
29883,
4293,
7464,
360,
1839,
485,
29887,
29918,
4804,
29918,
2230,
7464,
360,
1839,
7827,
29918,
2230,
11287,
13,
9651,
363,
1158,
29918,
978,
29892,
360,
13,
9651,
297,
360,
4062,
25060,
29889,
7076,
580,
13,
4706,
4514,
13,
4706,
736,
1583,
29889,
28789,
1764,
29906,
29918,
6272,
29889,
3166,
29918,
1807,
29898,
13,
9651,
525,
18255,
515,
376,
5509,
29918,
8628,
1883,
29889,
1420,
29908,
1053,
1158,
29918,
16202,
29918,
1420,
1273,
1012,
29876,
29915,
13,
9651,
525,
6224,
1158,
29918,
16202,
29918,
1420,
29898,
29931,
4062,
25060,
29897,
9156,
29915,
13,
4706,
13742,
9482,
29898,
13,
9651,
365,
4062,
25060,
29922,
29931,
4062,
25060,
13,
4706,
1723,
13,
13,
1678,
822,
4770,
657,
29918,
29928,
29918,
2371,
29918,
3888,
29898,
1311,
29892,
2011,
29892,
7786,
29918,
5975,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
2011,
29901,
13,
4706,
584,
3207,
7786,
29918,
5975,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
2669,
353,
1583,
29889,
29928,
13779,
29961,
637,
29962,
13,
4706,
736,
426,
13,
9651,
376,
637,
1115,
2011,
29892,
13,
9651,
376,
978,
1115,
2669,
29889,
13492,
29918,
2974,
29918,
23515,
29889,
978,
29892,
13,
9651,
376,
9917,
29918,
517,
29918,
23981,
1115,
2669,
29889,
23981,
29918,
5355,
29892,
13,
9651,
376,
4882,
1115,
2669,
29889,
657,
29918,
5509,
29918,
4882,
3285,
13,
9651,
525,
1287,
414,
2396,
7431,
29898,
5509,
29889,
13208,
1367,
29879,
511,
29871,
396,
14402,
29901,
14861,
6059,
350,
8127,
29928,
6732,
2672,
4945,
29943,
11538,
29892,
6058,
306,
3580,
1307,
13780,
8098,
29991,
13,
9651,
525,
14017,
936,
29918,
6954,
2396,
7786,
29918,
5975,
14352,
29896,
22322,
14017,
936,
29918,
6954,
2033,
849,
29871,
29896,
29900,
29906,
29946,
849,
29871,
29896,
29900,
29906,
29946,
29892,
13,
9651,
396,
1334,
29915,
645,
6588,
975,
29871,
29941,
24372,
29892,
408,
445,
508,
805,
9345,
5051,
9098,
29889,
13,
9651,
396,
3940,
393,
7786,
29918,
5975,
338,
2869,
18764,
287,
363,
16384,
373,
278,
3983,
364,
15206,
13,
9651,
525,
21970,
2396,
4513,
29898,
2083,
4197,
276,
1760,
29918,
5975,
14352,
29916,
22322,
21970,
29918,
21125,
29918,
6739,
2033,
363,
921,
297,
3464,
29898,
29941,
29897,
2314,
847,
29871,
29941,
29897,
13,
4706,
500,
13,
13,
1678,
822,
4770,
657,
29918,
29928,
29918,
4262,
29879,
29898,
1311,
29892,
7786,
29918,
5975,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
7786,
29918,
5975,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
11073,
353,
518,
13,
9651,
12865,
29889,
329,
29883,
3166,
16394,
29898,
29928,
1839,
16394,
2033,
467,
710,
615,
603,
29898,
13,
18884,
14210,
29950,
16664,
29924,
16664,
29903,
29915,
396,
1273,
29885,
22584,
29881,
13,
9651,
1723,
363,
360,
297,
7786,
29918,
5975,
13,
4706,
4514,
13,
4706,
736,
426,
13,
9651,
376,
21134,
1115,
11073,
29892,
13,
9651,
376,
2572,
1115,
1583,
17255,
657,
29918,
1272,
29918,
1454,
29918,
8149,
29898,
13,
18884,
7786,
29918,
5975,
29892,
13,
18884,
334,
29898,
13,
462,
1678,
6702,
12366,
29918,
6954,
742,
525,
14017,
936,
29918,
6954,
742,
525,
18714,
29918,
6954,
1495,
13,
462,
1678,
565,
10876,
29889,
12120,
2804,
525,
5080,
29941,
29906,
29915,
13,
462,
1678,
1683,
6702,
14017,
936,
29918,
6954,
742,
525,
18714,
29918,
6954,
1495,
13,
18884,
10353,
13,
18884,
8572,
272,
29922,
29896,
29900,
29906,
29946,
334,
29871,
29896,
29900,
29906,
29946,
13,
9651,
10353,
13,
9651,
376,
601,
1115,
1583,
17255,
657,
29918,
1272,
29918,
1454,
29918,
8149,
29898,
13,
18884,
7786,
29918,
5975,
29892,
13,
18884,
525,
601,
29918,
949,
742,
525,
601,
29918,
17625,
742,
13,
18884,
8572,
272,
29922,
29896,
29900,
29906,
29946,
334,
29871,
29896,
29900,
29906,
29946,
13,
9651,
10353,
13,
9651,
376,
21970,
1115,
1583,
17255,
657,
29918,
1272,
29918,
1454,
29918,
8149,
29898,
13,
18884,
7786,
29918,
5975,
29892,
13,
18884,
525,
21970,
29918,
21125,
29918,
6739,
29915,
13,
9651,
10353,
13,
4706,
500,
13,
13,
1678,
822,
4770,
657,
29918,
1272,
29918,
1454,
29918,
8149,
29898,
1311,
29892,
1819,
29892,
334,
8149,
29892,
8572,
272,
29922,
8516,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
1819,
29901,
13,
4706,
584,
3207,
6611,
29901,
13,
4706,
584,
3207,
8572,
272,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
365,
1469,
353,
5159,
13,
4706,
363,
921,
29892,
1820,
297,
26985,
29898,
8149,
1125,
13,
9651,
365,
3744,
353,
5159,
13,
9651,
363,
360,
297,
1819,
29901,
13,
18884,
474,
353,
360,
29961,
1989,
29962,
13,
18884,
565,
8572,
272,
338,
451,
6213,
29901,
13,
462,
1678,
474,
849,
29922,
8572,
272,
13,
18884,
365,
3744,
29889,
4397,
29898,
29875,
29897,
13,
9651,
365,
1469,
29889,
4397,
4197,
1989,
29892,
365,
3744,
29892,
365,
1625,
2470,
29961,
29916,
24960,
13,
4706,
736,
365,
1469,
13,
13,
1678,
822,
4770,
657,
29918,
2371,
29918,
1420,
29898,
1311,
29892,
360,
3170,
1125,
13,
4706,
9995,
13,
13,
4706,
584,
3207,
360,
3170,
29901,
13,
4706,
584,
2457,
29901,
13,
4706,
9995,
13,
4706,
736,
1583,
29889,
28789,
1764,
29906,
29918,
6272,
29889,
3166,
29918,
1807,
29898,
13,
9651,
525,
18255,
515,
376,
5509,
29918,
8628,
1883,
29889,
1420,
29908,
1053,
2669,
29918,
4882,
29918,
2371,
1273,
1012,
29876,
29915,
13,
9651,
525,
6224,
2669,
29918,
4882,
29918,
2371,
4197,
29928,
3170,
2314,
9156,
29915,
13,
4706,
13742,
9482,
29898,
13,
9651,
360,
3170,
29922,
29928,
3170,
13,
4706,
1723,
13,
2
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.